1
0

tableRowFoundation.ts 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import BaseFoundation, { DefaultAdapter } from '../base/foundation';
  2. import { BaseRowKeyType } from './foundation';
  3. export interface TableRowAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
  4. notifyClick: (rowKey: BaseRowKeyType, e: any, expand: boolean) => void;
  5. notifyDoubleClick: (record: Record<string, any>, e: any) => void;
  6. notifyMouseEnter: (record: Record<string, any>, e: any) => void;
  7. notifyMouseLeave: (record: Record<string, any>, e: any) => void
  8. }
  9. export default class TableRowFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TableRowAdapter<P, S>, P, S> {
  10. handleClick(e: any) {
  11. const { expanded, rowKey } = this.getProps();
  12. this._adapter.notifyClick(rowKey, e, expanded);
  13. }
  14. handleDoubleClick(e: any) {
  15. this._adapter.notifyDoubleClick(this.getProp('record'), e);
  16. }
  17. handleMouseEnter(e: any) {
  18. const record = this.getProp('record');
  19. this._adapter.notifyMouseEnter(record, e);
  20. }
  21. handleMouseLeave(e: any) {
  22. const record = this.getProp('record');
  23. this._adapter.notifyMouseLeave(record, e);
  24. }
  25. }