@tiny-codes/react-easy 1.6.5 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/ConfirmAction/index.tsx"],
4
- "sourcesContent": ["import type { ComponentType, ForwardedRef, PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useContext, useImperativeHandle, useRef, useState } from 'react';\nimport type { ButtonProps, ModalFuncProps, SwitchProps } from 'antd';\nimport { App, Button, Modal, Switch, Typography } from 'antd';\nimport type { ModalFunc } from 'antd/es/modal/confirm';\nimport type confirm from 'antd/es/modal/confirm';\nimport useToken from 'antd/es/theme/useToken';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport useContextValidator from '../../hooks/useContextValidator';\nimport useLocalizedText from '../../hooks/useLocalizedText';\nimport useRefFunction from '../../hooks/useRefFunction';\nimport ReactEasyContext from '../ConfigProvider/context';\n\nexport type ConfirmActionProps<TriggerProp extends object, Event extends keyof TriggerProp> = Omit<\n ModalFuncProps,\n 'onOk'\n> &\n ConfirmActionTrigger<TriggerProp, Event> & {\n /**\n * - **EN:** Whether to display in red danger mode, which will automatically affect the color of\n * the title, icon, and confirm button. Default is `false`, for DeleteConfirmAction, the\n * defaults is `true`.\n *\n * > You can explicitly set `titleColor`, `iconColor`, and `okButtonProps.type` to override\n *\n * - **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。\n *\n * > 可以显式设置`titleColor`、`iconColor`和`okButtonProps.type`来覆盖\n */\n danger?: boolean;\n /**\n * - **EN:** The color of confirm box title, default is `warning`\n * - **CN:** 弹框标题颜色,默认`warning`\n */\n titleColor?: TextProps['type'] | 'primary';\n /**\n * - **EN:** The color of confirm box content\n * - **CN:** 弹框内容文本颜色\n */\n contentColor?: TextProps['type'] | 'primary';\n /**\n * - **EN:** The color of confirm box title icon, default is the same as `titleColor`\n * - **CN:** 弹框标题图标颜色,默认与`titleColor`相同\n */\n iconColor?: TextProps['type'] | 'primary';\n /**\n * - **EN:** Callback when click confirm button\n * - **CN:** 点击确认按钮的回调\n */\n // @ts-expect-error: because TriggerProp[Event] should be casted to function type\n onOk?: (...args: Parameters<TriggerProp[Event]>) => unknown | Promise<unknown>;\n /**\n * - **EN:** Callback after confirm event, won't trigger if failed, the argument is the return\n * value of `onOk`\n * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface ConfirmActionTrigger<TriggerProp extends object, Event extends keyof TriggerProp> {\n /**\n * - **EN:** Trigger component, trigger to show confirm box\n * - **CN:** 触发器组件,触发显示确认弹框\n */\n triggerComponent?: ComponentType<TriggerProp>;\n /**\n * - **EN:** Props of trigger component\n * - **CN:** 触发器组件的Props属性\n */\n triggerProps?: TriggerProp;\n /**\n * **EN:** The event name that triggers the dialog\n *\n * **CN:** 触发弹窗的事件名称\n *\n * - `Button`: 'onClick'\n * - `Switch`: 'onChange'\n * - `Link`: 'onClick'\n */\n triggerEvent?: Event;\n /**\n * - **EN:** Custom trigger content\n * - **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type ConfirmActionRef<R = {}> = R &\n ReturnType<ModalFunc> & {\n /**\n * - **EN:** Show confirm box\n * - **CN:** 显示确认弹框\n */\n show: (props?: Parameters<ModalFunc>[0]) => ReturnType<ModalFunc>;\n };\n\n/**\n * - **EN:** Generate a confirm box component\n * - **CN:** 生成一个确认弹框组件\n *\n * @param defaultProps Default props | 默认属性\n *\n * @returns Component render method | 组件render方法\n */\nexport const genRenderer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n defaultProps: Partial<ConfirmActionProps<any, never>> & { confirmType: 'normal' | 'delete' }\n) => {\n const Render = <TriggerProp extends object, Event extends keyof TriggerProp>(\n props: ConfirmActionProps<TriggerProp, Event>,\n ref: ForwardedRef<ConfirmActionRef>\n ) => {\n const { confirmType, ...restDefaults } = defaultProps;\n const mergedProps: ConfirmActionProps<TriggerProp, Event> = {\n ...restDefaults,\n ...props,\n okButtonProps: {\n ...restDefaults.okButtonProps,\n ...props.okButtonProps,\n },\n cancelButtonProps: {\n ...restDefaults.cancelButtonProps,\n ...props.cancelButtonProps,\n },\n bodyProps: {\n ...restDefaults.bodyProps,\n ...props.bodyProps,\n },\n maskProps: {\n ...restDefaults.maskProps,\n ...props.maskProps,\n },\n wrapProps: {\n ...restDefaults.wrapProps,\n ...props.wrapProps,\n },\n triggerProps: {\n ...restDefaults.triggerProps,\n ...props.triggerProps,\n style: {\n ...restDefaults.triggerProps?.style,\n ...(props.triggerProps && 'style' in props.triggerProps && typeof props.triggerProps.style === 'object'\n ? props.triggerProps.style\n : {}),\n },\n } as TriggerProp,\n };\n const context = useContext(ReactEasyContext);\n const defaultTitle = useLocalizedText(\n confirmType === 'delete' ? context.defaultDeletionConfirmTitle : context.defaultConfirmTitle\n );\n const defaultContent = useLocalizedText(\n confirmType === 'delete' ? context.defaultDeletionConfirmContent : context.defaultConfirmContent\n );\n const {\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as Event,\n triggerProps,\n danger,\n title = defaultTitle,\n content = defaultContent,\n titleColor,\n contentColor,\n icon,\n iconColor,\n okButtonProps,\n cancelButtonProps,\n onOk,\n afterOk,\n children,\n ...restProps\n } = mergedProps;\n\n useContextValidator();\n\n const app = App.useApp();\n // @ts-expect-error: because app may return a stub object when App is not used\n const modal = app.modal?.confirm ? app.modal : Modal;\n const { localize } = useContext(ReactEasyContext);\n const [, token] = useToken();\n const [confirmApi, setConfirmApi] = useState<ReturnType<typeof confirm>>();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n\n const fallbackColor = danger ? 'danger' : undefined;\n // Text with color\n const coloredText = (text: ReactNode, color?: TextProps['type'] | 'primary') => {\n const textContent = typeof text === 'string' ? (localize?.(text) ?? text) : text;\n if (!color) {\n return textContent;\n }\n if (color === 'primary') {\n return <Typography.Text style={{ color: token.colorPrimary }}>{textContent}</Typography.Text>;\n }\n return textContent ? <Typography.Text type={color}>{textContent}</Typography.Text> : undefined;\n };\n\n // Show confirm box\n const showConfirm: ConfirmActionRef['show'] = useRefFunction(() => {\n const okProps: ButtonProps = {\n ...(danger ? { type: 'primary', danger: true } : {}),\n ...(okButtonProps ?? {}),\n };\n const cancelProps: ButtonProps = {\n ...(cancelButtonProps ?? {}),\n };\n const api = modal.confirm({\n title: coloredText(title, titleColor ?? fallbackColor ?? 'warning'),\n content: coloredText(content, contentColor),\n icon: coloredText(icon, iconColor ?? fallbackColor ?? 'warning'),\n autoFocusButton: null,\n closable: true,\n okButtonProps: okProps,\n cancelButtonProps: cancelProps,\n onOk: async () => {\n try {\n api.update({\n closable: false,\n okButtonProps: {\n loading: true,\n ...okProps,\n },\n cancelButtonProps: {\n disabled: true,\n ...cancelProps,\n },\n });\n const result = await onOk?.(...((triggerEventArgsRef.current ?? []) as Parameters<typeof onOk>));\n afterOk?.(result);\n } finally {\n api.update({\n closable: true,\n okButtonProps: {\n loading: false,\n ...okProps,\n },\n cancelButtonProps: {\n disabled: false,\n ...cancelProps,\n },\n });\n }\n },\n ...restProps,\n });\n setConfirmApi(api);\n return api;\n });\n\n // Output ref\n useImperativeHandle(ref, () => ({ show: showConfirm, ...confirmApi! }), [showConfirm, confirmApi]);\n\n // Render trigger component\n return (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n const api = showConfirm();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args, { api });\n }\n },\n }\n : {}) as TriggerProp)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n );\n };\n Render.displayName = 'ConfirmAction';\n return Render;\n};\n\n/**\n * - **EN:** Add default properties to the ConfirmAction component\n * - **CN:** 给ConfirmAction组件添加默认属性\n *\n * @param RenderComponent The component that renders the ConfirmAction | 实际渲染组件\n * @param defaultProps Add some default values based on the props passed to the component |\n * 在组件传入的props基础上,添加一些默认值\n */\nexport const withDefaultConfirmActionProps = <\n P extends ActionCompConstraint,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n RenderComponent: ComponentType<\n PropsWithoutRef<P & ConfirmActionProps<TriggerProp, Event>> & RefAttributes<ConfirmActionRef<Ref>>\n >,\n defaultProps?:\n | Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event>>\n | ((\n actualProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event>\n ) => Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event>>)\n) => {\n const WithDefaultProps = forwardRef(\n (\n props: PropsWithoutRef<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event>>,\n ref: ForwardedRef<ConfirmActionRef<Ref>>\n ) => {\n const actualProps = props as Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event>;\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(actualProps);\n const mergedProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event> =\n typeof defaultProps === 'function'\n ? {\n ...actualProps,\n ...defaults,\n triggerProps: {\n ...actualProps.triggerProps,\n ...defaults?.triggerProps,\n },\n }\n : {\n ...defaults,\n ...actualProps,\n triggerProps: {\n ...defaults?.triggerProps,\n ...actualProps.triggerProps,\n },\n };\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return <RenderComponent ref={ref} {...(mergedProps as any)} />;\n }\n );\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n return WithDefaultProps;\n};\n\nconst renderConfirmAction = genRenderer({\n confirmType: 'normal',\n});\nconst forwarded = forwardRef(renderConfirmAction);\nforwarded.displayName = 'ForwardRef(ConfirmAction)';\n\n/**\n * - **EN:** Confirm box component with trigger\n * - **CN:** 带触发器的确认框组件\n */\nconst ConfirmAction = forwarded as unknown as ConfirmActionWithStatic;\n// Type of button\n// eslint-disable-next-line @typescript-eslint/ban-types\nConfirmAction.Button = withDefaultConfirmActionProps<ActionCompConstraint, ButtonProps, 'onClick', {}>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwarded as any,\n {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n }\n);\n// Type of switch\n// eslint-disable-next-line @typescript-eslint/ban-types\nConfirmAction.Switch = withDefaultConfirmActionProps<ActionCompConstraint, SwitchProps, 'onChange', {}>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwarded as any,\n {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n }\n);\n// Type of link\n// eslint-disable-next-line @typescript-eslint/ban-types\nConfirmAction.Link = withDefaultConfirmActionProps<ActionCompConstraint, LinkProps, 'onClick', {}>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwarded as any,\n {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n }\n);\n\nexport interface ActionCompConstraint extends ReturnType<ModalFunc> {\n /**\n * - **EN:** Register the confirm action save event, the passed callback function will be called\n * when the confirm button is clicked, supports asynchronous saving\n * - **CN:** 注册确认框保存事件,传入的回调函数会在点击确认按钮时调用,支持异步保存\n *\n * @param handler Event handler | 事件处理函数\n */\n setOK: (\n handler: (\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get\n * the value of the switch; for the `Button` type trigger, you can get the click event\n * object of the button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值;对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n ...triggerEventArgs: any[]\n ) => unknown | Promise<unknown>\n ) => void;\n\n /**\n * - **EN:** Default trigger DOM element used to render the trigger\n * - **CN:** 默认的触发器组件的 DOM 元素,用于渲染触发器\n */\n triggerDom: ReactNode;\n}\n\n/**\n * - **EN:** Interface of generic type component\n * - **CN:** 泛型组件的接口\n */\nexport type GenericConfirmActionInterface = <TriggerProp extends object, Event extends keyof TriggerProp>(\n props: PropsWithoutRef<TypedConfirmActionProps<TriggerProp, Event>> & RefAttributes<ConfirmActionRef>\n) => ReactElement;\n\n/**\n * - **EN:** Interface of specific type component\n * - **CN:** 具体类型组件的接口\n */\nexport type TypedConfirmActionInterface<TriggerProp extends object, Event extends keyof TriggerProp> = ComponentType<\n PropsWithoutRef<TypedConfirmActionProps<TriggerProp, Event>> & RefAttributes<ConfirmActionRef>\n>;\n\n/**\n * - **EN:** Props definition of specific type component\n * - **CN:** 具体类型组件的Props定义\n */\ntype TypedConfirmActionProps<TriggerProp extends object, Event extends keyof TriggerProp> = Omit<\n ConfirmActionProps<TriggerProp, Event>,\n 'triggerComponent' | 'triggerEvent'\n>;\nexport type ConfirmActionWithStatic = GenericConfirmActionInterface & {\n /**\n * - **EN:** Confirm box with button trigger\n * - **CN:** 按钮类型的确认框\n */\n Button: TypedConfirmActionInterface<ButtonProps, 'onClick'>;\n /**\n * - **EN:** Confirm box with switch trigger\n * - **CN:** 开关类型的确认框\n */\n Switch: TypedConfirmActionInterface<SwitchProps, 'onChange'>;\n /**\n * - **EN:** Confirm box with link trigger\n * - **CN:** 链接类型的确认框\n */\n Link: TypedConfirmActionInterface<LinkProps, 'onClick'>;\n};\n\nexport default ConfirmAction;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA8E;AAE9E,kBAAuD;AAGvD,s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c;AACpB,YAAM,kBAAkB,OAAO,iBAAiB,aAAa,eAAe,MAAM;AAClF,YAAM,WAAW,gBAAgB,WAAW;AAC5C,YAAM,cACJ,OAAO,iBAAiB,aACpB;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACH,cAAc;AAAA,UACZ,GAAG,YAAY;AAAA,UACf,GAAG,qCAAU;AAAA,QACf;AAAA,MACF,IACA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,QACH,cAAc;AAAA,UACZ,GAAG,qCAAU;AAAA,UACb,GAAG,YAAY;AAAA,QACjB;AAAA,MACF;AAEN,aAAO,oCAAC,mBAAgB,KAAW,GAAI,aAAqB;AAAA,IAC9D;AAAA,EACF;AACA,mBAAiB,cAAc;AAC/B,SAAO;AACT;AAEA,IAAM,sBAAsB,YAAY;AAAA,EACtC,aAAa;AACf,CAAC;AACD,IAAM,gBAAY,yBAAW,mBAAmB;AAChD,UAAU,cAAc;AAMxB,IAAM,gBAAgB;AAGtB,cAAc,SAAS;AAAA;AAAA,EAErB;AAAA,EACA;AAAA,IACE,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,cAAc,CAAC;AAAA,EACjB;AACF;AAGA,cAAc,SAAS;AAAA;AAAA,EAErB;AAAA,EACA;AAAA,IACE,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,cAAc,CAAC;AAAA,EACjB;AACF;AAGA,cAAc,OAAO;AAAA;AAAA,EAEnB;AAAA,EACA;AAAA,IACE,kBAAkB,uBAAW;AAAA,IAC7B,cAAc;AAAA,IACd,cAAc;AAAA,MACZ,OAAO,EAAE,YAAY,SAAS;AAAA,IAChC;AAAA,EACF;AACF;AAuEA,IAAO,wBAAQ;",
4
+ "sourcesContent": ["import type { ComponentType, ForwardedRef, PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useContext, useImperativeHandle, useRef, useState } from 'react';\nimport type { ButtonProps, ModalFuncProps, SwitchProps } from 'antd';\nimport { App, Button, Modal, Switch, Typography } from 'antd';\nimport type { ModalFunc } from 'antd/es/modal/confirm';\nimport type confirm from 'antd/es/modal/confirm';\nimport useToken from 'antd/es/theme/useToken';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport useContextValidator from '../../hooks/useContextValidator';\nimport useLocalizedText from '../../hooks/useLocalizedText';\nimport useRefFunction from '../../hooks/useRefFunction';\nimport ReactEasyContext from '../ConfigProvider/context';\n\nexport type ConfirmActionProps<TriggerProp extends object, Event extends keyof TriggerProp> = Omit<\n ModalFuncProps,\n 'onOk'\n> &\n ConfirmActionTrigger<TriggerProp, Event> & {\n /**\n * - **EN:** Whether to display in red danger mode, which will automatically affect the color of\n * the title, icon, and confirm button. Default is `false`, for DeleteConfirmAction, the\n * defaults is `true`.\n *\n * > You can explicitly set `titleColor`, `iconColor`, and `okButtonProps.type` to override\n *\n * - **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。\n *\n * > 可以显式设置`titleColor`、`iconColor`和`okButtonProps.type`来覆盖\n */\n danger?: boolean;\n /**\n * - **EN:** The color of confirm box title, default is `warning`\n * - **CN:** 弹框标题颜色,默认`warning`\n */\n titleColor?: TextProps['type'] | 'primary';\n /**\n * - **EN:** The color of confirm box content\n * - **CN:** 弹框内容文本颜色\n */\n contentColor?: TextProps['type'] | 'primary';\n /**\n * - **EN:** The color of confirm box title icon, default is the same as `titleColor`\n * - **CN:** 弹框标题图标颜色,默认与`titleColor`相同\n */\n iconColor?: TextProps['type'] | 'primary';\n /**\n * - **EN:** Callback when click confirm button\n * - **CN:** 点击确认按钮的回调\n */\n // @ts-expect-error: because TriggerProp[Event] should be casted to function type\n onOk?: (...args: Parameters<TriggerProp[Event]>) => unknown | Promise<unknown>;\n /**\n * - **EN:** Callback after confirm event, won't trigger if failed, the argument is the return\n * value of `onOk`\n * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface ConfirmActionTrigger<TriggerProp extends object, Event extends keyof TriggerProp> {\n /**\n * - **EN:** Trigger component, trigger to show confirm box\n * - **CN:** 触发器组件,触发显示确认弹框\n */\n triggerComponent?: ComponentType<TriggerProp>;\n /**\n * - **EN:** Props of trigger component\n * - **CN:** 触发器组件的Props属性\n */\n triggerProps?: TriggerProp;\n /**\n * **EN:** The event name that triggers the dialog\n *\n * **CN:** 触发弹窗的事件名称\n *\n * - `Button`: 'onClick'\n * - `Switch`: 'onChange'\n * - `Link`: 'onClick'\n */\n triggerEvent?: Event;\n /**\n * - **EN:** Custom trigger content\n * - **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type ConfirmActionRef<R = {}> = R &\n ReturnType<ModalFunc> & {\n /**\n * - **EN:** Show confirm box\n * - **CN:** 显示确认弹框\n */\n show: (props?: Parameters<ModalFunc>[0]) => ReturnType<ModalFunc>;\n };\n\n/**\n * - **EN:** Generate a confirm box component\n * - **CN:** 生成一个确认弹框组件\n *\n * @param defaultProps Default props | 默认属性\n *\n * @returns Component render method | 组件render方法\n */\nexport const genRenderer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n defaultProps: Partial<ConfirmActionProps<any, never>> & { confirmType: 'normal' | 'delete' }\n) => {\n const Render = <TriggerProp extends object, Event extends keyof TriggerProp>(\n props: ConfirmActionProps<TriggerProp, Event>,\n ref: ForwardedRef<ConfirmActionRef>\n ) => {\n const { confirmType, ...restDefaults } = defaultProps;\n\n const context = useContext(ReactEasyContext);\n const globalDefaults = confirmType === 'delete' ? context.DeletionConfirmAction : context.ConfirmAction;\n\n const defaultTitle = useLocalizedText(\n confirmType === 'delete'\n ? context.DeletionConfirmAction?.title || context.defaultDeletionConfirmTitle\n : context.ConfirmAction?.title || context.defaultConfirmTitle\n );\n const defaultContent = useLocalizedText(\n confirmType === 'delete'\n ? context.DeletionConfirmAction?.content || context.defaultDeletionConfirmContent\n : context.ConfirmAction?.content || context.defaultConfirmContent\n );\n\n const mergedProps: ConfirmActionProps<TriggerProp, Event> = {\n ...restDefaults,\n ...globalDefaults,\n ...props,\n title: props.title ?? defaultTitle ?? restDefaults.title,\n content: props.content ?? defaultContent ?? restDefaults.content,\n okButtonProps: {\n ...restDefaults.okButtonProps,\n ...globalDefaults?.okButtonProps,\n ...props.okButtonProps,\n },\n cancelButtonProps: {\n ...restDefaults.cancelButtonProps,\n ...globalDefaults?.cancelButtonProps,\n ...props.cancelButtonProps,\n },\n bodyProps: {\n ...restDefaults.bodyProps,\n ...globalDefaults?.bodyProps,\n ...props.bodyProps,\n },\n maskProps: {\n ...restDefaults.maskProps,\n ...globalDefaults?.maskProps,\n ...props.maskProps,\n },\n wrapProps: {\n ...restDefaults.wrapProps,\n ...globalDefaults?.wrapProps,\n ...props.wrapProps,\n },\n triggerProps: {\n ...restDefaults.triggerProps,\n ...globalDefaults?.triggerProps,\n ...props.triggerProps,\n style: {\n ...restDefaults.triggerProps?.style,\n ...(globalDefaults?.triggerProps &&\n 'style' in globalDefaults.triggerProps &&\n typeof globalDefaults.triggerProps.style === 'object'\n ? globalDefaults.triggerProps.style\n : {}),\n ...(props.triggerProps && 'style' in props.triggerProps && typeof props.triggerProps.style === 'object'\n ? props.triggerProps.style\n : {}),\n },\n } as TriggerProp,\n };\n const {\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as Event,\n triggerProps,\n danger,\n title,\n content,\n titleColor,\n contentColor,\n icon,\n iconColor,\n okButtonProps,\n cancelButtonProps,\n onOk,\n afterOk,\n children,\n ...restProps\n } = mergedProps;\n\n useContextValidator();\n\n const app = App.useApp();\n // @ts-expect-error: because app may return a stub object when App is not used\n const modal = app.modal?.confirm ? app.modal : Modal;\n const { localize } = useContext(ReactEasyContext);\n const [, token] = useToken();\n const [confirmApi, setConfirmApi] = useState<ReturnType<typeof confirm>>();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n\n const fallbackColor = danger ? 'danger' : undefined;\n // Text with color\n const coloredText = (text: ReactNode, color?: TextProps['type'] | 'primary') => {\n const textContent = typeof text === 'string' ? (localize?.(text) ?? text) : text;\n if (!color) {\n return textContent;\n }\n if (color === 'primary') {\n return <Typography.Text style={{ color: token.colorPrimary }}>{textContent}</Typography.Text>;\n }\n return textContent ? <Typography.Text type={color}>{textContent}</Typography.Text> : undefined;\n };\n\n // Show confirm box\n const showConfirm: ConfirmActionRef['show'] = useRefFunction(() => {\n const okProps: ButtonProps = {\n ...(danger ? { type: 'primary', danger: true } : {}),\n ...(okButtonProps ?? {}),\n };\n const cancelProps: ButtonProps = {\n ...(cancelButtonProps ?? {}),\n };\n const api = modal.confirm({\n title: coloredText(title, titleColor ?? fallbackColor ?? 'warning'),\n content: coloredText(content, contentColor),\n icon: coloredText(icon, iconColor ?? fallbackColor ?? 'warning'),\n autoFocusButton: null,\n closable: true,\n okButtonProps: okProps,\n cancelButtonProps: cancelProps,\n onOk: async () => {\n try {\n api.update({\n closable: false,\n okButtonProps: {\n loading: true,\n ...okProps,\n },\n cancelButtonProps: {\n disabled: true,\n ...cancelProps,\n },\n });\n const result = await onOk?.(...((triggerEventArgsRef.current ?? []) as Parameters<typeof onOk>));\n afterOk?.(result);\n } finally {\n api.update({\n closable: true,\n okButtonProps: {\n loading: false,\n ...okProps,\n },\n cancelButtonProps: {\n disabled: false,\n ...cancelProps,\n },\n });\n }\n },\n ...restProps,\n });\n setConfirmApi(api);\n return api;\n });\n\n // Output ref\n useImperativeHandle(ref, () => ({ show: showConfirm, ...confirmApi! }), [showConfirm, confirmApi]);\n\n // Render trigger component\n return (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n const api = showConfirm();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args, { api });\n }\n },\n }\n : {}) as TriggerProp)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n );\n };\n Render.displayName = 'ConfirmAction';\n return Render;\n};\n\n/**\n * - **EN:** Add default properties to the ConfirmAction component\n * - **CN:** 给ConfirmAction组件添加默认属性\n *\n * @param RenderComponent The component that renders the ConfirmAction | 实际渲染组件\n * @param defaultProps Add some default values based on the props passed to the component |\n * 在组件传入的props基础上,添加一些默认值\n */\nexport const withDefaultConfirmActionProps = <\n P extends ActionCompConstraint,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n RenderComponent: ComponentType<\n PropsWithoutRef<P & ConfirmActionProps<TriggerProp, Event>> & RefAttributes<ConfirmActionRef<Ref>>\n >,\n defaultProps?:\n | Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event>>\n | ((\n actualProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event>\n ) => Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event>>)\n) => {\n const WithDefaultProps = forwardRef(\n (\n props: PropsWithoutRef<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event>>,\n ref: ForwardedRef<ConfirmActionRef<Ref>>\n ) => {\n const actualProps = props as Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event>;\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(actualProps);\n const mergedProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<TriggerProp, Event> =\n typeof defaultProps === 'function'\n ? {\n ...actualProps,\n ...defaults,\n triggerProps: {\n ...actualProps.triggerProps,\n ...defaults?.triggerProps,\n },\n }\n : {\n ...defaults,\n ...actualProps,\n triggerProps: {\n ...defaults?.triggerProps,\n ...actualProps.triggerProps,\n },\n };\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return <RenderComponent ref={ref} {...(mergedProps as any)} />;\n }\n );\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n return WithDefaultProps;\n};\n\nconst renderConfirmAction = genRenderer({\n confirmType: 'normal',\n});\nconst forwarded = forwardRef(renderConfirmAction);\nforwarded.displayName = 'ForwardRef(ConfirmAction)';\n\n/**\n * - **EN:** Confirm box component with trigger\n * - **CN:** 带触发器的确认框组件\n */\nconst ConfirmAction = forwarded as unknown as ConfirmActionWithStatic;\n// Type of button\n// eslint-disable-next-line @typescript-eslint/ban-types\nConfirmAction.Button = withDefaultConfirmActionProps<ActionCompConstraint, ButtonProps, 'onClick', {}>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwarded as any,\n {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n }\n);\n// Type of switch\n// eslint-disable-next-line @typescript-eslint/ban-types\nConfirmAction.Switch = withDefaultConfirmActionProps<ActionCompConstraint, SwitchProps, 'onChange', {}>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwarded as any,\n {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n }\n);\n// Type of link\n// eslint-disable-next-line @typescript-eslint/ban-types\nConfirmAction.Link = withDefaultConfirmActionProps<ActionCompConstraint, LinkProps, 'onClick', {}>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n forwarded as any,\n {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n }\n);\n\nexport interface ActionCompConstraint extends ReturnType<ModalFunc> {\n /**\n * - **EN:** Register the confirm action save event, the passed callback function will be called\n * when the confirm button is clicked, supports asynchronous saving\n * - **CN:** 注册确认框保存事件,传入的回调函数会在点击确认按钮时调用,支持异步保存\n *\n * @param handler Event handler | 事件处理函数\n */\n setOK: (\n handler: (\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get\n * the value of the switch; for the `Button` type trigger, you can get the click event\n * object of the button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值;对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n ...triggerEventArgs: any[]\n ) => unknown | Promise<unknown>\n ) => void;\n\n /**\n * - **EN:** Default trigger DOM element used to render the trigger\n * - **CN:** 默认的触发器组件的 DOM 元素,用于渲染触发器\n */\n triggerDom: ReactNode;\n}\n\n/**\n * - **EN:** Interface of generic type component\n * - **CN:** 泛型组件的接口\n */\nexport type GenericConfirmActionInterface = <TriggerProp extends object, Event extends keyof TriggerProp>(\n props: PropsWithoutRef<TypedConfirmActionProps<TriggerProp, Event>> & RefAttributes<ConfirmActionRef>\n) => ReactElement;\n\n/**\n * - **EN:** Interface of specific type component\n * - **CN:** 具体类型组件的接口\n */\nexport type TypedConfirmActionInterface<TriggerProp extends object, Event extends keyof TriggerProp> = ComponentType<\n PropsWithoutRef<TypedConfirmActionProps<TriggerProp, Event>> & RefAttributes<ConfirmActionRef>\n>;\n\n/**\n * - **EN:** Props definition of specific type component\n * - **CN:** 具体类型组件的Props定义\n */\ntype TypedConfirmActionProps<TriggerProp extends object, Event extends keyof TriggerProp> = Omit<\n ConfirmActionProps<TriggerProp, Event>,\n 'triggerComponent' | 'triggerEvent'\n>;\nexport type ConfirmActionWithStatic = GenericConfirmActionInterface & {\n /**\n * - **EN:** Confirm box with button trigger\n * - **CN:** 按钮类型的确认框\n */\n Button: TypedConfirmActionInterface<ButtonProps, 'onClick'>;\n /**\n * - **EN:** Confirm box with switch trigger\n * - **CN:** 开关类型的确认框\n */\n Switch: TypedConfirmActionInterface<SwitchProps, 'onChange'>;\n /**\n * - **EN:** Confirm box with link trigger\n * - **CN:** 链接类型的确认框\n */\n Link: TypedConfirmActionInterface<LinkProps, 'onClick'>;\n};\n\nexport default ConfirmAction;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;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AAS;AAAA;AAAA,EAErB;AAAA,EACA;AAAA,IACE,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,cAAc,CAAC;AAAA,EACjB;AACF;AAGA,cAAc,SAAS;AAAA;AAAA,EAErB;AAAA,EACA;AAAA,IACE,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,cAAc,CAAC;AAAA,EACjB;AACF;AAGA,cAAc,OAAO;AAAA;AAAA,EAEnB;AAAA,EACA;AAAA,IACE,kBAAkB,uBAAW;AAAA,IAC7B,cAAc;AAAA,IACd,cAAc;AAAA,MACZ,OAAO,EAAE,YAAY,SAAS;AAAA,IAChC;AAAA,EACF;AACF;AAuEA,IAAO,wBAAQ;",
6
6
  "names": ["ReactEasyContext", "useLocalizedText", "useContextValidator", "useToken", "useRefFunction"]
7
7
  }
@@ -11,9 +11,9 @@ import { type ActionComponentInterface } from '../ConfirmAction/withConfirmActio
11
11
  */
12
12
  export default function withDeleteConfirmAction<P extends ActionCompConstraint, OuterTriggerProp extends object, OuterEvent extends keyof OuterTriggerProp, Ref extends object>(ActionComponent: ActionComponentInterface<P, Ref>, defaultProps?: Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>> | ((actualProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>) => Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>)): (<TriggerProp extends object, Event extends keyof TriggerProp>(props: import("react").PropsWithoutRef<Omit<P, keyof ActionCompConstraint>> & Omit<import("antd").ModalFuncProps, "onOk"> & import("../ConfirmAction").ConfirmActionTrigger<TriggerProp, Event> & {
13
13
  danger?: boolean | undefined;
14
- titleColor?: "primary" | import("antd/es/typography/Base").BaseType | undefined;
15
- contentColor?: "primary" | import("antd/es/typography/Base").BaseType | undefined;
16
- iconColor?: "primary" | import("antd/es/typography/Base").BaseType | undefined;
14
+ titleColor?: import("antd/es/typography/Base").BaseType | "primary" | undefined;
15
+ contentColor?: import("antd/es/typography/Base").BaseType | "primary" | undefined;
16
+ iconColor?: import("antd/es/typography/Base").BaseType | "primary" | undefined;
17
17
  onOk?: ((...args: Parameters<TriggerProp[Event]>) => unknown) | undefined;
18
18
  afterOk?: ((data?: any) => void) | undefined;
19
19
  } & import("react").RefAttributes<import("../ConfirmAction").ConfirmActionRef<Ref>>) => import("react").ReactNode) & import("../ConfirmAction/withConfirmAction").TypedTriggers<P, Ref>;
@@ -40,6 +40,7 @@ var import_react = require("react");
40
40
  var import_antd = require("antd");
41
41
  var import_react_is = require("react-is");
42
42
  var import_useContextValidator = __toESM(require("../../hooks/useContextValidator"));
43
+ var import_context = __toESM(require("../ConfigProvider/context"));
43
44
  var SubmitWithoutClosingSymbol = Symbol("[SubmitWithoutClose]");
44
45
  var genModalActionRenderer = (defaultProps) => {
45
46
  const ModalActionRenderer = (props, ref) => {
@@ -220,40 +221,49 @@ var genModalActionRenderer = (defaultProps) => {
220
221
  };
221
222
  return ModalActionRenderer;
222
223
  };
223
- function mergeProps(first, second) {
224
+ function mergeProps(first, second, third) {
224
225
  return {
225
226
  ...first,
226
227
  ...second,
228
+ ...third,
227
229
  okButtonProps: {
228
230
  ...first == null ? void 0 : first.okButtonProps,
229
- ...second == null ? void 0 : second.okButtonProps
231
+ ...second == null ? void 0 : second.okButtonProps,
232
+ ...third == null ? void 0 : third.okButtonProps
230
233
  },
231
234
  cancelButtonProps: {
232
235
  ...first == null ? void 0 : first.cancelButtonProps,
233
- ...second == null ? void 0 : second.cancelButtonProps
236
+ ...second == null ? void 0 : second.cancelButtonProps,
237
+ ...third == null ? void 0 : third.cancelButtonProps
234
238
  },
235
239
  bodyProps: {
236
240
  ...first == null ? void 0 : first.bodyProps,
237
- ...second == null ? void 0 : second.bodyProps
241
+ ...second == null ? void 0 : second.bodyProps,
242
+ ...third == null ? void 0 : third.bodyProps
238
243
  },
239
244
  maskProps: {
240
245
  ...first == null ? void 0 : first.maskProps,
241
- ...second == null ? void 0 : second.maskProps
246
+ ...second == null ? void 0 : second.maskProps,
247
+ ...third == null ? void 0 : third.maskProps
242
248
  },
243
249
  wrapProps: {
244
250
  ...first == null ? void 0 : first.wrapProps,
245
- ...second == null ? void 0 : second.wrapProps
251
+ ...second == null ? void 0 : second.wrapProps,
252
+ ...third == null ? void 0 : third.wrapProps
246
253
  },
247
254
  formProps: {
248
255
  ...first == null ? void 0 : first.formProps,
249
- ...second == null ? void 0 : second.formProps
256
+ ...second == null ? void 0 : second.formProps,
257
+ ...third == null ? void 0 : third.formProps
250
258
  },
251
259
  triggerProps: {
252
260
  ...first == null ? void 0 : first.triggerProps,
253
261
  ...second == null ? void 0 : second.triggerProps,
262
+ ...third == null ? void 0 : third.triggerProps,
254
263
  style: {
255
264
  ...(first == null ? void 0 : first.triggerProps) && "style" in first.triggerProps && typeof first.triggerProps.style === "object" ? first.triggerProps.style : {},
256
- ...(second == null ? void 0 : second.triggerProps) && "style" in second.triggerProps && typeof second.triggerProps.style === "object" ? second.triggerProps.style : {}
265
+ ...(second == null ? void 0 : second.triggerProps) && "style" in second.triggerProps && typeof second.triggerProps.style === "object" ? second.triggerProps.style : {},
266
+ ...(third == null ? void 0 : third.triggerProps) && "style" in third.triggerProps && typeof third.triggerProps.style === "object" ? third.triggerProps.style : {}
257
267
  }
258
268
  }
259
269
  };
@@ -321,10 +331,12 @@ ModalAction.SubmitWithoutClosing = SubmitWithoutClosingSymbol;
321
331
  function withModalAction(formComp, defaultProps) {
322
332
  const ForwardedModalAction = forwardedModalAction;
323
333
  const WithDefaultProps = (0, import_react.forwardRef)((props, ref) => {
334
+ const context = (0, import_react.useContext)(import_context.default);
335
+ const globalDefaults = context == null ? void 0 : context.ModalAction;
324
336
  const [modalActionRef, setModalActionRef] = (0, import_react.useState)(null);
325
337
  const useDefaultProps = typeof defaultProps === "function" ? defaultProps : () => defaultProps;
326
338
  const defaults = useDefaultProps(props, modalActionRef);
327
- const mergedProps = typeof defaultProps === "function" ? mergeProps(props, defaults) : mergeProps(defaults, props);
339
+ const mergedProps = typeof defaultProps === "function" ? mergeProps(globalDefaults, props, defaults) : mergeProps(globalDefaults, defaults, props);
328
340
  WithDefaultProps.displayName = "ForwardRef(WithDefaultProps)";
329
341
  (0, import_react.useImperativeHandle)(ref, () => modalActionRef, [modalActionRef]);
330
342
  return /* @__PURE__ */ React.createElement(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/ModalAction/index.tsx"],
4
- "sourcesContent": ["import type { ComponentType, FC, ForwardedRef, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport type { ButtonProps, FormInstance, ModalProps, SwitchProps } from 'antd';\nimport { Button, Form, Modal, Switch, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { isForwardRef } from 'react-is';\nimport useContextValidator from '../../hooks/useContextValidator';\n\n/**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\nexport const SubmitWithoutClosingSymbol = Symbol('[SubmitWithoutClose]');\n\nexport type ModalActionProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = Omit<ModalProps, 'onOk'> &\n ModalActionTrigger<FormData, P, TriggerProp, Event> & {\n /**\n * - **EN:** Form editing component, do not use the Form component inside the component, the form\n * component and form instance are automatically created by the parent component\n * - **CN:** 表单编辑组件,组件内部不要使用Form组件,表单组件及表单实例由父组件自动创建\n */\n formComp: ComponentType<P & RefAttributes<Ref>>;\n /**\n * - **EN:** Props of the form editing component\n * - **CN:** 表单编辑组件的Props属性\n */\n formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>;\n /**\n * - **EN:** The callback when clicks the confirmation button, support asynchronous saving, return\n * `SubmitWithoutClosingSymbol` can prevent the dialog from closing, return other values will\n * be passed to the `afterOk` event, if any\n * - **CN:** 点击确认按钮的回调,支持异步保存,返回`SubmitWithoutClosingSymbol`可以阻止弹框关闭,返回其他值会传递给`afterOk`事件,如果有的话\n */\n onOk?: (\n formData: FormData,\n // @ts-expect-error: because TP[E] should be a function type\n ...args: Parameters<TriggerProp[Event]>\n ) => unknown | Promise<unknown>;\n /**\n * - **EN:** The callback after the confirmation event is completed, it will not be triggered when\n * it fails, the parameter is the return value of `onOk`\n * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface FormCompPropsConstraint<FormData> {\n /**\n * - **EN:** Automatically generated form instance, use this form instance in FormComp, do not\n * create a new instance\n * - **CN:** 自动生成的表单实例,编辑表单要使用这个表单实例,不要新创建实例\n */\n form: FormInstance<FormData>;\n /**\n * - **EN:** Register the form save event, the callback function passed in will be called when the\n * confirm button is clicked, support asynchronous saving\n * - **CN:** 注册表单保存事件,传入的回调函数会在点击确认按钮时被调用,支持异步保存\n *\n * @param handler Event handler | 事件处理函数\n */\n onSave: (\n handler: (\n /**\n * - **EN:** Form data\n * - **CN:** 表单数据\n */\n formData: FormData,\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get\n * the value of the switch; for the `Button` type trigger, you can get the click event\n * object of the button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值;对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n ...triggerEventData: any[]\n ) => unknown | Promise<unknown>\n ) => void;\n /**\n * - **EN:** Listen to the open and close status of the dialog. When `destroyOnHidden` is set to\n * false, the form component instance is cached, and the dialog can only be listened to in this\n * way\n * - **CN:** 监听弹框打开关闭状态。当`destroyOnHidden`设置为false时,表单组件实例被缓存,只能通过这种方式监听弹框\n *\n * @param handler Event handler | 事件处理函数\n */\n onOpenChange: (handler: ModalProps['afterOpenChange']) => void;\n /**\n * - **EN:** Set the dialog open status\n * - **CN:** 设置弹框打开状态\n *\n * @param open Whether is open or not | 弹窗是否打开\n */\n setOpen: (open: boolean) => void;\n /**\n * - **EN:** Modify the properties of the dialog, such as title, width, button properties, etc.\n * - **CN:** 修改弹窗的属性,例如标题、宽度,按钮属性等\n */\n updateModalProps: (props: Partial<ModalProps>) => void;\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get the\n * value of the switch; for the `Button` type trigger, you can get the click event object of the\n * button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值,对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n triggerEventData?: any[];\n}\n\nexport interface ModalActionTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n> {\n /**\n * - **EN:** Trigger component, click to show the dialog\n * - **CN:** 弹窗触发器组件,点击触发显示弹框\n */\n triggerComponent?: ComponentType<TriggerProp> | FC<TriggerProp>;\n /**\n * - **EN:** Props of the trigger component\n * - **CN:** 触发器组件的Props属性\n */\n triggerProps?: TriggerProp & {\n /**\n * - **EN:** Set a custom function to determine whether to show the trigger button\n * - **CN:** 设置一个自定义函数,用于判断是否显示触发器按钮\n *\n * @default true\n *\n * @param formProps Form component props | 表单组件的props\n */\n show?: boolean | ((formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>) => boolean);\n };\n /**\n * - **EN:** The event name that triggers the dialog\n * - **CN:** 触发弹窗的事件名称\n * - `Button`: 'onClick'\n * - `Switch`: 'onChange'\n * - `Link`: 'onClick'\n */\n triggerEvent?: Event;\n /**\n * - **EN:** Custom trigger content\n * - **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\n// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any\nexport type ModalActionRef<R = {}, FormData extends object = any> = R & {\n form: FormInstance<FormData> | undefined;\n /**\n * - **EN:** Show the dialog\n * - **CN:** 显示弹框\n */\n show: () => void;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const genModalActionRenderer = (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => {\n const ModalActionRenderer = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n >(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref>,\n ref: ForwardedRef<ModalActionRef<Ref, FormData>>\n ) => {\n const [userModalProps, setUserModalProps] = useState<Partial<ModalProps>>({});\n let mergedProps = mergeProps<FormData, P, TriggerProp, Event, Ref>(defaultProps, props);\n mergedProps = mergeProps(mergedProps, userModalProps as typeof props);\n const {\n formComp,\n formProps,\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as Event,\n triggerProps,\n open: openInProps,\n destroyOnClose = true,\n destroyOnHidden = true,\n maskClosable = false,\n okButtonProps,\n cancelButtonProps,\n onOk,\n afterOk,\n onCancel,\n afterClose,\n children,\n ...restProps\n } = mergedProps;\n useContextValidator();\n const FormComp = formComp as ComponentType<FormCompPropsConstraint<FormData> & RefAttributes<Ref>>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n const [open, setOpen] = useState(false);\n const saveFuncRef = useRef<(formData: FormData, ...args: any[]) => unknown>(undefined);\n const [isSaving, setIsSaving] = useState(false);\n const [formCompRef, setFormCompRef] = useState<Ref | null>(null);\n const [form, setForm] = useState<FormInstance<FormData>>();\n const formRef = useRef<FormInstance<FormData>>(form);\n formRef.current = form;\n const destroyOnCloseRef = useRef(destroyOnClose);\n destroyOnCloseRef.current = destroyOnClose || destroyOnHidden;\n const openListenerRef = useRef<ModalProps['afterOpenChange']>(undefined);\n\n // Listen to the open props changes\n useEffect(() => {\n if (openInProps !== undefined) {\n setOpen(openInProps);\n }\n }, [openInProps]);\n\n // Reset the form after closed\n useEffect(() => {\n if (!destroyOnCloseRef.current && open && formRef.current) {\n formRef.current.resetFields();\n }\n }, [open]);\n\n // show trigger\n const showInProps = triggerProps?.show;\n const showTrigger = useMemo(() => {\n if (typeof showInProps === 'boolean') {\n return showInProps;\n } else if (typeof showInProps === 'function') {\n return showInProps(formProps);\n }\n return true;\n }, [showInProps, formProps]);\n\n // Show the dialog\n const showModal = useCallback(() => {\n setOpen(true);\n openListenerRef.current?.(true);\n }, []);\n // Hide the dialog\n const hideModal = useCallback(() => {\n setOpen(false);\n openListenerRef.current?.(false);\n }, []);\n // Set the dialog status listener\n const setOpenListener = useCallback(\n (listener: ModalProps['afterOpenChange']) => {\n openListenerRef.current = listener;\n // Call once when initialized\n openListenerRef.current?.(open);\n },\n [open]\n );\n // Receive the onSave callback method passed by the form component\n const setOnSaveHandler: FormCompPropsConstraint<FormData>['onSave'] = useCallback((handler) => {\n saveFuncRef.current = handler;\n }, []);\n // Set the dialog status and trigger the onOpenChange event of the form component\n const handleSetOpen = useCallback((open: boolean) => {\n setOpen(open);\n openListenerRef.current?.(open);\n }, []);\n\n // Output ref\n useImperativeHandle(ref, () => ({ ...formCompRef, form, show: showModal }) as ModalActionRef<Ref, FormData>, [\n formCompRef,\n showModal,\n form,\n ]);\n\n // Render the trigger component\n return (\n <>\n {showTrigger && (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n showModal();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args);\n }\n },\n }\n : {}) as TriggerProp)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n )}\n <Modal\n open={open}\n confirmLoading={isSaving}\n destroyOnClose={destroyOnClose}\n destroyOnHidden={destroyOnHidden}\n maskClosable={maskClosable}\n okButtonProps={{\n loading: isSaving,\n ...okButtonProps,\n }}\n cancelButtonProps={{\n disabled: isSaving,\n ...cancelButtonProps,\n }}\n onOk={async () => {\n let formData: FormData;\n try {\n formData = (await form?.validateFields()) as FormData;\n } catch (e) {\n // Validation error, should not throw error\n return;\n }\n if (Object.keys(formData).length === 0) {\n console.warn(\n 'form.getFieldsValue() is empty. Please use the form instance passed to formComp instead of creating the form instance yourself.'\n );\n }\n try {\n setIsSaving(true);\n // First call onSave of the form component\n let result = await saveFuncRef.current?.(formData, ...(triggerEventArgsRef.current ?? []));\n // The onSave of the form component has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // Then call onOk of the dialog, support asynchronous, and will pass the return value of onSave, if any\n if (onOk) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result = await onOk((result as FormData) ?? formData, ...((triggerEventArgsRef.current ?? []) as any));\n }\n // onOk also has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // If onOK is successful, close the dialog and trigger the afterOk event\n hideModal();\n afterOk?.(result);\n } catch (error) {\n console.error(error);\n } finally {\n setIsSaving(false);\n }\n }}\n onCancel={async (e) => {\n hideModal();\n onCancel?.(e);\n }}\n afterClose={() => {\n hideModal();\n afterClose?.();\n }}\n {...restProps}\n >\n <FormCreator<FormData> onCreate={setForm} />\n {form && (\n <FormComp\n ref={isForwardRef(FormComp) ? setFormCompRef : undefined}\n {...formProps}\n form={form}\n onOpenChange={setOpenListener}\n onSave={setOnSaveHandler}\n triggerEventData={triggerEventArgsRef.current}\n setOpen={handleSetOpen}\n updateModalProps={setUserModalProps}\n />\n )}\n </Modal>\n </>\n );\n };\n return ModalActionRenderer;\n};\n\nfunction mergeProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n first?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>,\n second?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n) {\n return {\n ...first,\n ...second,\n okButtonProps: {\n ...first?.okButtonProps,\n ...second?.okButtonProps,\n },\n cancelButtonProps: {\n ...first?.cancelButtonProps,\n ...second?.cancelButtonProps,\n },\n bodyProps: {\n ...first?.bodyProps,\n ...second?.bodyProps,\n },\n maskProps: {\n ...first?.maskProps,\n ...second?.maskProps,\n },\n wrapProps: {\n ...first?.wrapProps,\n ...second?.wrapProps,\n },\n formProps: {\n ...first?.formProps,\n ...second?.formProps,\n },\n triggerProps: {\n ...first?.triggerProps,\n ...second?.triggerProps,\n style: {\n ...(first?.triggerProps && 'style' in first.triggerProps && typeof first.triggerProps.style === 'object'\n ? first.triggerProps.style\n : {}),\n ...(second?.triggerProps && 'style' in second.triggerProps && typeof second.triggerProps.style === 'object'\n ? second.triggerProps.style\n : {}),\n },\n },\n } as unknown as ModalActionProps<FormData, P, TriggerProp, Event, Ref>;\n}\n\nfunction FormCreator<FD extends object>(props: { onCreate: (form: FormInstance<FD> | undefined) => void }) {\n const { onCreate } = props;\n const onCreateRef = useRef(onCreate);\n onCreateRef.current = onCreate;\n const [form] = Form.useForm<FD>();\n\n // output ref\n useEffect(() => {\n onCreateRef.current(form);\n return () => {\n onCreateRef.current(undefined);\n };\n }, [form]);\n\n return null;\n}\n\n/**\n * - **EN:** Add default properties to the ModalAction component\n * - **CN:** 给ModalAction组件添加默认属性\n *\n * @param WrappedComponent ModalAction component | ModalAction组件\n * @param defaultProps Default properties | 默认属性\n */\nexport const withDefaultModalActionProps = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n WrappedComponent: ComponentType<\n ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n >,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n | ((\n /**\n * - **EN:** Actual properties passed to the ModalAction component\n * - **CN:** 实际传递给ModalAction组件的属性\n */\n actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>,\n /**\n * - **EN:** Ref of the ModalAction component. Note that this ref may be null because the\n * component has not been rendered yet when executed for the first time.\n * - **CN:** ModalAction组件的ref对象。注意,该ref可能为null,因为第一次执行时组件还未渲染。\n */\n ref: ModalActionRef<Ref, FormData> | null\n ) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>)\n) => {\n const WithDefaultProps = forwardRef<\n ModalActionRef<Ref, FormData>,\n ModalActionProps<FormData, P, TriggerProp, Event, Ref>\n >((props, ref) => {\n const [modalActionRef, setModalActionRef] = useState<ModalActionRef<Ref, FormData> | null>(null);\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props, modalActionRef);\n const mergedProps = typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n\n useImperativeHandle(ref, () => modalActionRef as ModalActionRef<Ref, FormData>, [modalActionRef]);\n\n return <WrappedComponent ref={setModalActionRef} {...mergedProps} />;\n });\n return WithDefaultProps;\n};\n\nconst renderModalAction = genModalActionRenderer({});\nconst forwardedModalAction = forwardRef(renderModalAction);\nforwardedModalAction.displayName = 'ForwardRef(ModalAction)';\n/**\n * - **EN:** ModalAction component type\n * - **CN:** ModalAction组件的类型\n */\nexport type ModalActionInterface<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = ComponentType<\n ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n>;\n/**\n * - **EN:** ModalAction component with generic type\n * - **CN:** ModalAction泛型组件的类型\n */\nexport type GenericModalActionInterface = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode;\n/**\n * - **EN:** ModalAction with specified trigger type (specified form component)\n * - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)\n */\ntype ModalActionWithTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n OMIT extends string = never,\n> = ComponentType<\n Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n>;\n\n/**\n * - **EN:** ModalAction with specified trigger type (unspecified form component, keep generic)\n * - **CN:** 已指定Trigger类型的ModalAction(未指定表单组件,保持泛型)\n */\ntype GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n>(\n props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode;\n\n/**\n * - **EN:** Built-in trigger types (specified form components)\n * - **CN:** 内置的几种触发器类型(已指定表单组件)\n */\nexport interface TypedTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: ModalActionWithTrigger<FormData, P, ButtonProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: ModalActionWithTrigger<FormData, P, SwitchProps, 'onChange', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: ModalActionWithTrigger<FormData, P, LinkProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\n/**\n * - **EN:** Built-in trigger types (generic types, unspecified form components)\n * - **CN:** 内置的几种触发器类型(泛型类型,未指定表单组件)\n */\ninterface GenericTypedTriggers<OMIT extends string = never> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: GenericModalActionWithTrigger<ButtonProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: GenericModalActionWithTrigger<SwitchProps, 'onChange', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: GenericModalActionWithTrigger<LinkProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\ntype WithGenericTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> = (<TriggerProp extends object, Event extends keyof TriggerProp>(\n props: Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode) &\n (P extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FormData, P, Ref, OMIT>);\n\n/**\n * - **EN:** Add trigger types to the ModalAction component\n * - **CN:** 给ModalAction组件添加子触发器类型\n */\nconst addTriggers = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n OMIT extends string = never,\n>(\n comp: ComponentType<\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n >\n) => {\n const patchedComp = comp as WithGenericTriggers<FormData, P, Ref, OMIT>;\n // Type of button trigger\n patchedComp.Button = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, ButtonProps, 'onClick', Ref>,\n {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of switch trigger\n patchedComp.Switch = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, SwitchProps, 'onChange', Ref>,\n {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of link trigger\n patchedComp.Link = withDefaultModalActionProps(comp as ModalActionInterface<FormData, P, LinkProps, 'onClick', Ref>, {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any;\n return patchedComp;\n};\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nconst ModalAction = addTriggers(forwardedModalAction);\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nexport type ModalActionWithStatic = typeof ModalAction & {\n /**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\n SubmitWithoutClosing: symbol;\n};\n(ModalAction as ModalActionWithStatic).SubmitWithoutClosing = SubmitWithoutClosingSymbol;\n\n/**\n * - **EN:** Generate a dialog component based on the editing form component\n * - **CN:** 基于编辑表单组件生成一个弹框组件\n *\n * @template FormData Form data type | 表单数据类型\n * @template P Form component props type | 表单组件的props类型\n * @template OuterTriggerProp Outer trigger props type | 外部触发器的props类型\n * @template OuterEvent Outer trigger event type | 外部触发器的事件类型\n * @template Ref Form component ref type | 表单组件的ref类型\n *\n * @param formComp Component of dialog content | 弹窗内容组件\n * @param defaultProps Default properties of the dialog | 弹窗的默认属性\n */\nexport function withModalAction<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n formComp: ComponentType<P & FormCompPropsConstraint<FormData> & RefAttributes<Ref>>,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>\n | ((\n /**\n * - **EN:** Actual properties passed to the ModalAction component\n * - **CN:** 实际传递给ModalAction组件的属性\n */\n actualProps: ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>,\n /**\n * - **EN:** Ref of the ModalAction component. Note that this ref may be null because the\n * component has not been rendered yet when executed for the first time.\n * - **CN:** ModalAction组件的ref对象。注意,该ref可能为null,因为第一次执行时组件还未渲染。\n */\n ref: ModalActionRef<Ref, FormData> | null\n ) => Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)\n) {\n const ForwardedModalAction = forwardedModalAction as unknown as ModalActionInterface<\n FormData,\n P,\n OuterTriggerProp,\n OuterEvent,\n Ref\n >;\n const WithDefaultProps = forwardRef<\n ModalActionRef<Ref, FormData>,\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>\n >((props, ref) => {\n const [modalActionRef, setModalActionRef] = useState<ModalActionRef<Ref, FormData> | null>(null);\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props, modalActionRef);\n const mergedProps = typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n\n useImperativeHandle(ref, () => modalActionRef as ModalActionRef<Ref, FormData>, [modalActionRef]);\n\n return (\n <ForwardedModalAction\n ref={setModalActionRef}\n formComp={formComp}\n {...(mergedProps as Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)}\n />\n );\n });\n return addTriggers<FormData, P, OuterTriggerProp, OuterEvent, Ref, 'formComp'>(WithDefa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,MACd,cAAc,CAAC;AAAA,IACjB;AAAA;AAAA,EAEF;AAEA,cAAY,OAAO,4BAA4B,MAAsE;AAAA,IACnH,kBAAkB,uBAAW;AAAA,IAC7B,cAAc;AAAA,IACd,cAAc;AAAA,MACZ,OAAO,EAAE,YAAY,SAAS;AAAA,IAChC;AAAA;AAAA,EAEF,CAAC;AACD,SAAO;AACT;AAMA,IAAM,cAAc,YAAY,oBAAoB;AAcnD,YAAsC,uBAAuB;AAevD,SAAS,gBAOd,UACA,cAeA;AACA,QAAM,uBAAuB;AAO7B,QAAM,uBAAmB,yBAGvB,CAAC,OAAO,QAAQ;AAChB,UAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAA+C,IAAI;AAC/F,UAAM,kBAAkB,OAAO,iBAAiB,aAAa,eAAe,MAAM;AAClF,UAAM,WAAW,gBAAgB,OAAO,cAAc;AACtD,UAAM,cAAc,OAAO,iBAAiB,aAAa,WAAW,OAAO,QAAQ,IAAI,WAAW,UAAU,KAAK;AACjH,qBAAiB,cAAc;AAE/B,0CAAoB,KAAK,MAAM,gBAAiD,CAAC,cAAc,CAAC;AAEhG,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACC,GAAI;AAAA;AAAA,IACP;AAAA,EAEJ,CAAC;AACD,SAAO,YAAwE,gBAAgB;AACjG;AAEA,IAAO,sBAAQ;",
6
- "names": ["useContextValidator", "open"]
4
+ "sourcesContent": ["import type { ComponentType, FC, ForwardedRef, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport type { ButtonProps, FormInstance, ModalProps, SwitchProps } from 'antd';\nimport { Button, Form, Modal, Switch, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { isForwardRef } from 'react-is';\nimport useContextValidator from '../../hooks/useContextValidator';\nimport ReactEasyContext from '../ConfigProvider/context';\n\n/**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\nexport const SubmitWithoutClosingSymbol = Symbol('[SubmitWithoutClose]');\n\nexport type ModalActionProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = Omit<ModalProps, 'onOk'> &\n ModalActionTrigger<FormData, P, TriggerProp, Event> & {\n /**\n * - **EN:** Form editing component, do not use the Form component inside the component, the form\n * component and form instance are automatically created by the parent component\n * - **CN:** 表单编辑组件,组件内部不要使用Form组件,表单组件及表单实例由父组件自动创建\n */\n formComp: ComponentType<P & RefAttributes<Ref>>;\n /**\n * - **EN:** Props of the form editing component\n * - **CN:** 表单编辑组件的Props属性\n */\n formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>;\n /**\n * - **EN:** The callback when clicks the confirmation button, support asynchronous saving, return\n * `SubmitWithoutClosingSymbol` can prevent the dialog from closing, return other values will\n * be passed to the `afterOk` event, if any\n * - **CN:** 点击确认按钮的回调,支持异步保存,返回`SubmitWithoutClosingSymbol`可以阻止弹框关闭,返回其他值会传递给`afterOk`事件,如果有的话\n */\n onOk?: (\n formData: FormData,\n // @ts-expect-error: because TP[E] should be a function type\n ...args: Parameters<TriggerProp[Event]>\n ) => unknown | Promise<unknown>;\n /**\n * - **EN:** The callback after the confirmation event is completed, it will not be triggered when\n * it fails, the parameter is the return value of `onOk`\n * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface FormCompPropsConstraint<FormData> {\n /**\n * - **EN:** Automatically generated form instance, use this form instance in FormComp, do not\n * create a new instance\n * - **CN:** 自动生成的表单实例,编辑表单要使用这个表单实例,不要新创建实例\n */\n form: FormInstance<FormData>;\n /**\n * - **EN:** Register the form save event, the callback function passed in will be called when the\n * confirm button is clicked, support asynchronous saving\n * - **CN:** 注册表单保存事件,传入的回调函数会在点击确认按钮时被调用,支持异步保存\n *\n * @param handler Event handler | 事件处理函数\n */\n onSave: (\n handler: (\n /**\n * - **EN:** Form data\n * - **CN:** 表单数据\n */\n formData: FormData,\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get\n * the value of the switch; for the `Button` type trigger, you can get the click event\n * object of the button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值;对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n ...triggerEventData: any[]\n ) => unknown | Promise<unknown>\n ) => void;\n /**\n * - **EN:** Listen to the open and close status of the dialog. When `destroyOnHidden` is set to\n * false, the form component instance is cached, and the dialog can only be listened to in this\n * way\n * - **CN:** 监听弹框打开关闭状态。当`destroyOnHidden`设置为false时,表单组件实例被缓存,只能通过这种方式监听弹框\n *\n * @param handler Event handler | 事件处理函数\n */\n onOpenChange: (handler: ModalProps['afterOpenChange']) => void;\n /**\n * - **EN:** Set the dialog open status\n * - **CN:** 设置弹框打开状态\n *\n * @param open Whether is open or not | 弹窗是否打开\n */\n setOpen: (open: boolean) => void;\n /**\n * - **EN:** Modify the properties of the dialog, such as title, width, button properties, etc.\n * - **CN:** 修改弹窗的属性,例如标题、宽度,按钮属性等\n */\n updateModalProps: (props: Partial<ModalProps>) => void;\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get the\n * value of the switch; for the `Button` type trigger, you can get the click event object of the\n * button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值,对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n triggerEventData?: any[];\n}\n\nexport interface ModalActionTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n> {\n /**\n * - **EN:** Trigger component, click to show the dialog\n * - **CN:** 弹窗触发器组件,点击触发显示弹框\n */\n triggerComponent?: ComponentType<TriggerProp> | FC<TriggerProp>;\n /**\n * - **EN:** Props of the trigger component\n * - **CN:** 触发器组件的Props属性\n */\n triggerProps?: TriggerProp & {\n /**\n * - **EN:** Set a custom function to determine whether to show the trigger button\n * - **CN:** 设置一个自定义函数,用于判断是否显示触发器按钮\n *\n * @default true\n *\n * @param formProps Form component props | 表单组件的props\n */\n show?: boolean | ((formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>) => boolean);\n };\n /**\n * - **EN:** The event name that triggers the dialog\n * - **CN:** 触发弹窗的事件名称\n * - `Button`: 'onClick'\n * - `Switch`: 'onChange'\n * - `Link`: 'onClick'\n */\n triggerEvent?: Event;\n /**\n * - **EN:** Custom trigger content\n * - **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\n// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any\nexport type ModalActionRef<R = {}, FormData extends object = any> = R & {\n form: FormInstance<FormData> | undefined;\n /**\n * - **EN:** Show the dialog\n * - **CN:** 显示弹框\n */\n show: () => void;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const genModalActionRenderer = (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => {\n const ModalActionRenderer = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n >(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref>,\n ref: ForwardedRef<ModalActionRef<Ref, FormData>>\n ) => {\n const [userModalProps, setUserModalProps] = useState<Partial<ModalProps>>({});\n let mergedProps = mergeProps<FormData, P, TriggerProp, Event, Ref>(defaultProps, props);\n mergedProps = mergeProps(mergedProps, userModalProps as typeof props);\n const {\n formComp,\n formProps,\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as Event,\n triggerProps,\n open: openInProps,\n destroyOnClose = true,\n destroyOnHidden = true,\n maskClosable = false,\n okButtonProps,\n cancelButtonProps,\n onOk,\n afterOk,\n onCancel,\n afterClose,\n children,\n ...restProps\n } = mergedProps;\n useContextValidator();\n const FormComp = formComp as ComponentType<FormCompPropsConstraint<FormData> & RefAttributes<Ref>>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n const [open, setOpen] = useState(false);\n const saveFuncRef = useRef<(formData: FormData, ...args: any[]) => unknown>(undefined);\n const [isSaving, setIsSaving] = useState(false);\n const [formCompRef, setFormCompRef] = useState<Ref | null>(null);\n const [form, setForm] = useState<FormInstance<FormData>>();\n const formRef = useRef<FormInstance<FormData>>(form);\n formRef.current = form;\n const destroyOnCloseRef = useRef(destroyOnClose);\n destroyOnCloseRef.current = destroyOnClose || destroyOnHidden;\n const openListenerRef = useRef<ModalProps['afterOpenChange']>(undefined);\n\n // Listen to the open props changes\n useEffect(() => {\n if (openInProps !== undefined) {\n setOpen(openInProps);\n }\n }, [openInProps]);\n\n // Reset the form after closed\n useEffect(() => {\n if (!destroyOnCloseRef.current && open && formRef.current) {\n formRef.current.resetFields();\n }\n }, [open]);\n\n // show trigger\n const showInProps = triggerProps?.show;\n const showTrigger = useMemo(() => {\n if (typeof showInProps === 'boolean') {\n return showInProps;\n } else if (typeof showInProps === 'function') {\n return showInProps(formProps);\n }\n return true;\n }, [showInProps, formProps]);\n\n // Show the dialog\n const showModal = useCallback(() => {\n setOpen(true);\n openListenerRef.current?.(true);\n }, []);\n // Hide the dialog\n const hideModal = useCallback(() => {\n setOpen(false);\n openListenerRef.current?.(false);\n }, []);\n // Set the dialog status listener\n const setOpenListener = useCallback(\n (listener: ModalProps['afterOpenChange']) => {\n openListenerRef.current = listener;\n // Call once when initialized\n openListenerRef.current?.(open);\n },\n [open]\n );\n // Receive the onSave callback method passed by the form component\n const setOnSaveHandler: FormCompPropsConstraint<FormData>['onSave'] = useCallback((handler) => {\n saveFuncRef.current = handler;\n }, []);\n // Set the dialog status and trigger the onOpenChange event of the form component\n const handleSetOpen = useCallback((open: boolean) => {\n setOpen(open);\n openListenerRef.current?.(open);\n }, []);\n\n // Output ref\n useImperativeHandle(ref, () => ({ ...formCompRef, form, show: showModal }) as ModalActionRef<Ref, FormData>, [\n formCompRef,\n showModal,\n form,\n ]);\n\n // Render the trigger component\n return (\n <>\n {showTrigger && (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n showModal();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args);\n }\n },\n }\n : {}) as TriggerProp)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n )}\n <Modal\n open={open}\n confirmLoading={isSaving}\n destroyOnClose={destroyOnClose}\n destroyOnHidden={destroyOnHidden}\n maskClosable={maskClosable}\n okButtonProps={{\n loading: isSaving,\n ...okButtonProps,\n }}\n cancelButtonProps={{\n disabled: isSaving,\n ...cancelButtonProps,\n }}\n onOk={async () => {\n let formData: FormData;\n try {\n formData = (await form?.validateFields()) as FormData;\n } catch (e) {\n // Validation error, should not throw error\n return;\n }\n if (Object.keys(formData).length === 0) {\n console.warn(\n 'form.getFieldsValue() is empty. Please use the form instance passed to formComp instead of creating the form instance yourself.'\n );\n }\n try {\n setIsSaving(true);\n // First call onSave of the form component\n let result = await saveFuncRef.current?.(formData, ...(triggerEventArgsRef.current ?? []));\n // The onSave of the form component has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // Then call onOk of the dialog, support asynchronous, and will pass the return value of onSave, if any\n if (onOk) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result = await onOk((result as FormData) ?? formData, ...((triggerEventArgsRef.current ?? []) as any));\n }\n // onOk also has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // If onOK is successful, close the dialog and trigger the afterOk event\n hideModal();\n afterOk?.(result);\n } catch (error) {\n console.error(error);\n } finally {\n setIsSaving(false);\n }\n }}\n onCancel={async (e) => {\n hideModal();\n onCancel?.(e);\n }}\n afterClose={() => {\n hideModal();\n afterClose?.();\n }}\n {...restProps}\n >\n <FormCreator<FormData> onCreate={setForm} />\n {form && (\n <FormComp\n ref={isForwardRef(FormComp) ? setFormCompRef : undefined}\n {...formProps}\n form={form}\n onOpenChange={setOpenListener}\n onSave={setOnSaveHandler}\n triggerEventData={triggerEventArgsRef.current}\n setOpen={handleSetOpen}\n updateModalProps={setUserModalProps}\n />\n )}\n </Modal>\n </>\n );\n };\n return ModalActionRenderer;\n};\n\nfunction mergeProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n first?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>,\n second?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>,\n third?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n) {\n return {\n ...first,\n ...second,\n ...third,\n okButtonProps: {\n ...first?.okButtonProps,\n ...second?.okButtonProps,\n ...third?.okButtonProps,\n },\n cancelButtonProps: {\n ...first?.cancelButtonProps,\n ...second?.cancelButtonProps,\n ...third?.cancelButtonProps,\n },\n bodyProps: {\n ...first?.bodyProps,\n ...second?.bodyProps,\n ...third?.bodyProps,\n },\n maskProps: {\n ...first?.maskProps,\n ...second?.maskProps,\n ...third?.maskProps,\n },\n wrapProps: {\n ...first?.wrapProps,\n ...second?.wrapProps,\n ...third?.wrapProps,\n },\n formProps: {\n ...first?.formProps,\n ...second?.formProps,\n ...third?.formProps,\n },\n triggerProps: {\n ...first?.triggerProps,\n ...second?.triggerProps,\n ...third?.triggerProps,\n style: {\n ...(first?.triggerProps && 'style' in first.triggerProps && typeof first.triggerProps.style === 'object'\n ? first.triggerProps.style\n : {}),\n ...(second?.triggerProps && 'style' in second.triggerProps && typeof second.triggerProps.style === 'object'\n ? second.triggerProps.style\n : {}),\n ...(third?.triggerProps && 'style' in third.triggerProps && typeof third.triggerProps.style === 'object'\n ? third.triggerProps.style\n : {}),\n },\n },\n } as unknown as ModalActionProps<FormData, P, TriggerProp, Event, Ref>;\n}\n\nfunction FormCreator<FD extends object>(props: { onCreate: (form: FormInstance<FD> | undefined) => void }) {\n const { onCreate } = props;\n const onCreateRef = useRef(onCreate);\n onCreateRef.current = onCreate;\n const [form] = Form.useForm<FD>();\n\n // output ref\n useEffect(() => {\n onCreateRef.current(form);\n return () => {\n onCreateRef.current(undefined);\n };\n }, [form]);\n\n return null;\n}\n\n/**\n * - **EN:** Add default properties to the ModalAction component\n * - **CN:** 给ModalAction组件添加默认属性\n *\n * @param WrappedComponent ModalAction component | ModalAction组件\n * @param defaultProps Default properties | 默认属性\n */\nexport const withDefaultModalActionProps = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n WrappedComponent: ComponentType<\n ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n >,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n | ((\n /**\n * - **EN:** Actual properties passed to the ModalAction component\n * - **CN:** 实际传递给ModalAction组件的属性\n */\n actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>,\n /**\n * - **EN:** Ref of the ModalAction component. Note that this ref may be null because the\n * component has not been rendered yet when executed for the first time.\n * - **CN:** ModalAction组件的ref对象。注意,该ref可能为null,因为第一次执行时组件还未渲染。\n */\n ref: ModalActionRef<Ref, FormData> | null\n ) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>)\n) => {\n const WithDefaultProps = forwardRef<\n ModalActionRef<Ref, FormData>,\n ModalActionProps<FormData, P, TriggerProp, Event, Ref>\n >((props, ref) => {\n const [modalActionRef, setModalActionRef] = useState<ModalActionRef<Ref, FormData> | null>(null);\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props, modalActionRef);\n const mergedProps = typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n\n useImperativeHandle(ref, () => modalActionRef as ModalActionRef<Ref, FormData>, [modalActionRef]);\n\n return <WrappedComponent ref={setModalActionRef} {...mergedProps} />;\n });\n return WithDefaultProps;\n};\n\nconst renderModalAction = genModalActionRenderer({});\nconst forwardedModalAction = forwardRef(renderModalAction);\nforwardedModalAction.displayName = 'ForwardRef(ModalAction)';\n/**\n * - **EN:** ModalAction component type\n * - **CN:** ModalAction组件的类型\n */\nexport type ModalActionInterface<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = ComponentType<\n ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n>;\n/**\n * - **EN:** ModalAction component with generic type\n * - **CN:** ModalAction泛型组件的类型\n */\nexport type GenericModalActionInterface = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode;\n/**\n * - **EN:** ModalAction with specified trigger type (specified form component)\n * - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)\n */\ntype ModalActionWithTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n OMIT extends string = never,\n> = ComponentType<\n Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n>;\n\n/**\n * - **EN:** ModalAction with specified trigger type (unspecified form component, keep generic)\n * - **CN:** 已指定Trigger类型的ModalAction(未指定表单组件,保持泛型)\n */\ntype GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n>(\n props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode;\n\n/**\n * - **EN:** Built-in trigger types (specified form components)\n * - **CN:** 内置的几种触发器类型(已指定表单组件)\n */\nexport interface TypedTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: ModalActionWithTrigger<FormData, P, ButtonProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: ModalActionWithTrigger<FormData, P, SwitchProps, 'onChange', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: ModalActionWithTrigger<FormData, P, LinkProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\n/**\n * - **EN:** Built-in trigger types (generic types, unspecified form components)\n * - **CN:** 内置的几种触发器类型(泛型类型,未指定表单组件)\n */\ninterface GenericTypedTriggers<OMIT extends string = never> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: GenericModalActionWithTrigger<ButtonProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: GenericModalActionWithTrigger<SwitchProps, 'onChange', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: GenericModalActionWithTrigger<LinkProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\ntype WithGenericTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> = (<TriggerProp extends object, Event extends keyof TriggerProp>(\n props: Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode) &\n (P extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FormData, P, Ref, OMIT>);\n\n/**\n * - **EN:** Add trigger types to the ModalAction component\n * - **CN:** 给ModalAction组件添加子触发器类型\n */\nconst addTriggers = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n OMIT extends string = never,\n>(\n comp: ComponentType<\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n >\n) => {\n const patchedComp = comp as WithGenericTriggers<FormData, P, Ref, OMIT>;\n // Type of button trigger\n patchedComp.Button = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, ButtonProps, 'onClick', Ref>,\n {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of switch trigger\n patchedComp.Switch = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, SwitchProps, 'onChange', Ref>,\n {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of link trigger\n patchedComp.Link = withDefaultModalActionProps(comp as ModalActionInterface<FormData, P, LinkProps, 'onClick', Ref>, {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any;\n return patchedComp;\n};\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nconst ModalAction = addTriggers(forwardedModalAction);\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nexport type ModalActionWithStatic = typeof ModalAction & {\n /**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\n SubmitWithoutClosing: symbol;\n};\n(ModalAction as ModalActionWithStatic).SubmitWithoutClosing = SubmitWithoutClosingSymbol;\n\n/**\n * - **EN:** Generate a dialog component based on the editing form component\n * - **CN:** 基于编辑表单组件生成一个弹框组件\n *\n * @template FormData Form data type | 表单数据类型\n * @template P Form component props type | 表单组件的props类型\n * @template OuterTriggerProp Outer trigger props type | 外部触发器的props类型\n * @template OuterEvent Outer trigger event type | 外部触发器的事件类型\n * @template Ref Form component ref type | 表单组件的ref类型\n *\n * @param formComp Component of dialog content | 弹窗内容组件\n * @param defaultProps Default properties of the dialog | 弹窗的默认属性\n */\nexport function withModalAction<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n formComp: ComponentType<P & FormCompPropsConstraint<FormData> & RefAttributes<Ref>>,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>\n | ((\n /**\n * - **EN:** Actual properties passed to the ModalAction component\n * - **CN:** 实际传递给ModalAction组件的属性\n */\n actualProps: ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>,\n /**\n * - **EN:** Ref of the ModalAction component. Note that this ref may be null because the\n * component has not been rendered yet when executed for the first time.\n * - **CN:** ModalAction组件的ref对象。注意,该ref可能为null,因为第一次执行时组件还未渲染。\n */\n ref: ModalActionRef<Ref, FormData> | null\n ) => Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)\n) {\n const ForwardedModalAction = forwardedModalAction as unknown as ModalActionInterface<\n FormData,\n P,\n OuterTriggerProp,\n OuterEvent,\n Ref\n >;\n const WithDefaultProps = forwardRef<\n ModalActionRef<Ref, FormData>,\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>\n >((props, ref) => {\n const context = useContext(ReactEasyContext);\n const globalDefaults = context?.ModalAction;\n const [modalActionRef, setModalActionRef] = useState<ModalActionRef<Ref, FormData> | null>(null);\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props, modalActionRef);\n const mergedProps =\n typeof defaultProps === 'function'\n ? mergeProps(globalDefaults, props, defaults)\n : mergeProps(globalDefaults, defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n\n useImperativeHandle(ref, () => modalActionRef as ModalActionRef<Ref, FormData>, [modalActionRef]);\n\n return (\n <ForwardedModalAction\n ref={setModalActionRef}\n formComp={formComp}\n {...(mergedProps as Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)}\n />\n );\n });\n return addTriggers<FormData, P, OuterTriggerProp, OuterEvent, Ref, 'formComp'>(WithDefaultProps);\n}\n\nexport default ModalAction as ModalActionWithStatic;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA+G;AAE/G,kBAAwD;AAExD,sBAA6B;AAC7B,iCAAgC;AAChC,qBAA6B;AAOtB,IAAM,6BAA6B,OAAO,sBAAsB;AAyJhE,IAAM,yBAAyB,CAAC,iBAAyE;AAC9G,QAAM,sBAAsB,CAO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;AAAA,MACd,cAAc,CAAC;AAAA,IACjB;AAAA;AAAA,EAEF;AAEA,cAAY,OAAO,4BAA4B,MAAsE;AAAA,IACnH,kBAAkB,uBAAW;AAAA,IAC7B,cAAc;AAAA,IACd,cAAc;AAAA,MACZ,OAAO,EAAE,YAAY,SAAS;AAAA,IAChC;AAAA;AAAA,EAEF,CAAC;AACD,SAAO;AACT;AAMA,IAAM,cAAc,YAAY,oBAAoB;AAcnD,YAAsC,uBAAuB;AAevD,SAAS,gBAOd,UACA,cAeA;AACA,QAAM,uBAAuB;AAO7B,QAAM,uBAAmB,yBAGvB,CAAC,OAAO,QAAQ;AAChB,UAAM,cAAU,yBAAW,eAAAC,OAAgB;AAC3C,UAAM,iBAAiB,mCAAS;AAChC,UAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAA+C,IAAI;AAC/F,UAAM,kBAAkB,OAAO,iBAAiB,aAAa,eAAe,MAAM;AAClF,UAAM,WAAW,gBAAgB,OAAO,cAAc;AACtD,UAAM,cACJ,OAAO,iBAAiB,aACpB,WAAW,gBAAgB,OAAO,QAAQ,IAC1C,WAAW,gBAAgB,UAAU,KAAK;AAChD,qBAAiB,cAAc;AAE/B,0CAAoB,KAAK,MAAM,gBAAiD,CAAC,cAAc,CAAC;AAEhG,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACC,GAAI;AAAA;AAAA,IACP;AAAA,EAEJ,CAAC;AACD,SAAO,YAAwE,gBAAgB;AACjG;AAEA,IAAO,sBAAQ;",
6
+ "names": ["useContextValidator", "open", "ReactEasyContext"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-codes/react-easy",
3
- "version": "1.6.5",
3
+ "version": "1.7.0",
4
4
  "description": "Simplify React and AntDesign development with practical components and hooks",
5
5
  "keywords": [
6
6
  "react",