tableRowFoundation.ts 1.2 KB

12345678910111213141516171819202122232425262728293031
  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. // eslint-disable-next-line max-len
  10. export default class TableRowFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TableRowAdapter<P, S>, P, S> {
  11. handleClick(e: any) {
  12. const { expanded, rowKey } = this.getProps();
  13. this._adapter.notifyClick(rowKey, e, expanded);
  14. }
  15. handleDoubleClick(e: any) {
  16. this._adapter.notifyDoubleClick(this.getProp('record'), e);
  17. }
  18. handleMouseEnter(e: any) {
  19. const record = this.getProp('record');
  20. this._adapter.notifyMouseEnter(record, e);
  21. }
  22. handleMouseLeave(e: any) {
  23. const record = this.getProp('record');
  24. this._adapter.notifyMouseLeave(record, e);
  25. }
  26. }