popconfirmFoundation.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* eslint-disable @typescript-eslint/no-empty-function */
  2. import BaseFoundation, { DefaultAdapter } from '../base/foundation';
  3. export interface PopconfirmAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
  4. setVisible: (visible: boolean) => void;
  5. notifyConfirm: (e: any) => void;
  6. notifyCancel: (e: any) => void;
  7. notifyVisibleChange: (visible: boolean) => void;
  8. notifyClickOutSide: (e: any) => void;
  9. }
  10. export default class PopConfirmFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<PopconfirmAdapter<P, S>, P, S> {
  11. init(): void {}
  12. destroy(): void {}
  13. handleCancel(e: any): void {
  14. this._adapter.notifyCancel(e);
  15. this.handleVisibleChange(false);
  16. }
  17. handleConfirm(e: any): void {
  18. this._adapter.notifyConfirm(e);
  19. this.handleVisibleChange(false);
  20. }
  21. handleClickOutSide(e: any): void {
  22. this._adapter.notifyClickOutSide(e);
  23. }
  24. handleVisibleChange(visible: boolean): void {
  25. if (!this._isControlledComponent('visible')) {
  26. this._adapter.setVisible(visible);
  27. }
  28. this._adapter.notifyVisibleChange(visible);
  29. }
  30. }