{"version":3,"file":"modal.mjs","sources":["../../../../../../packages/components/modal/src/modal.ts"],"sourcesContent":["import { buildProps, definePropType } from '@sgui-plus/utils/props'\r\nimport { UPDATE_MODEL_EVENT } from '@sgui-plus/utils/constants'\r\nimport { modalContentProps } from './modal-content'\r\n\r\nimport type { AppContext, ExtractPropTypes, VNode } from 'vue'\r\n\r\n// type DoneFn = (cancel?: boolean) => void\r\n// export type ModalBeforeCloseFn = (done: DoneFn) => void\r\n\r\nexport const modalProps = buildProps({\r\n  ...modalContentProps,\r\n  id: {\r\n    type: String,\r\n    default: '',\r\n  },\r\n  transfer: {\r\n    type: Boolean,\r\n    default: true\r\n  },\r\n  beforeCancel: {\r\n    type: definePropType<() => boolean>(Function),\r\n  },\r\n  destroyOnClose: {\r\n    type: Boolean,\r\n    default: false\r\n  },\r\n  closeOnPressEscape: {\r\n    type: Boolean,\r\n    default: true\r\n  },\r\n  lockScroll: {\r\n    type: Boolean,\r\n    default: true\r\n  },\r\n  mask: {\r\n    type: Boolean,\r\n    default: true\r\n  },\r\n  maskClass: String,\r\n  openDelay: {\r\n    type: Number,\r\n    default: 0\r\n  },\r\n  closeDelay: {\r\n    type: Number,\r\n    default: 0\r\n  },\r\n  top: {\r\n    type: String\r\n  },\r\n  left: {\r\n    type: [String, Number]\r\n  },\r\n  modelValue: {\r\n    type: Boolean,\r\n    default: false\r\n  },\r\n  width: {\r\n    type: [String, Number]\r\n  },\r\n  height: {\r\n    type: [String, Number]\r\n  },\r\n  zIndex: {\r\n    type: Number\r\n  }\r\n} as const)\r\n\r\nexport type ModalProps = ExtractPropTypes<typeof modalProps>\r\n\r\nexport interface ModalFnProps extends Partial<ModalProps> {\r\n  content?: string | VNode\r\n  appContext?: AppContext | null\r\n  onOk?: (...args: any[]) => any\r\n  onCancel?: (...args: any[]) => any\r\n  onOpen?: () => void\r\n  onHidden?: () => void\r\n}\r\n\r\nexport const modalEmits = {\r\n  open: () => true,\r\n  hidden: () => true,\r\n  ok: () => true,\r\n  cancel: () => true,\r\n  [UPDATE_MODEL_EVENT]: (value: boolean) => typeof value === 'boolean',\r\n  dragStart: () => true,\r\n  dragEnd: () => true,\r\n  maximize: (value: boolean) => typeof value === 'boolean',\r\n  minimize: (value: boolean) => typeof value === 'boolean',\r\n  fullscreen: (value: boolean) => typeof value === 'boolean'\r\n}\r\nexport type ModalEmits = typeof modalEmits\r\n\r\nexport type ModalParams = ModalFnProps | string | VNode\r\nexport type ModalFn = ((options?: ModalParams) => Promise<any>)\r\n\r\nexport interface IModal extends ModalFn {\r\n  readonly confirm: ModalFn\r\n  readonly info: ModalFn\r\n  readonly success: ModalFn\r\n  readonly warning: ModalFn\r\n  readonly error: ModalFn\r\n  readonly alert: ModalFn,\r\n  readonly show: ModalFn,\r\n  readonly remove: (id: string) => void\r\n}\r\n"],"names":[],"mappings":";;;;AAGY,MAAC,UAAU,GAAG,UAAU,CAAC;AACrC,EAAE,GAAG,iBAAiB;AACtB,EAAE,EAAE,EAAE;AACN,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,YAAY,EAAE;AAChB,IAAI,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC;AAClC,GAAG;AACH,EAAE,cAAc,EAAE;AAClB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,KAAK;AAClB,GAAG;AACH,EAAE,kBAAkB,EAAE;AACtB,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAA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