@tiny-codes/react-easy 1.2.0 → 1.2.1

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/es/components/ConfirmAction/index.d.ts +97 -36
  3. package/es/components/ConfirmAction/index.js +44 -40
  4. package/es/components/ConfirmAction/index.js.map +1 -1
  5. package/es/components/ConfirmAction/withConfirmAction.d.ts +48 -0
  6. package/es/components/ConfirmAction/withConfirmAction.js +131 -0
  7. package/es/components/ConfirmAction/withConfirmAction.js.map +1 -0
  8. package/es/components/DeleteConfirmAction/index.d.ts +1 -1
  9. package/es/components/DeleteConfirmAction/index.js +9 -3
  10. package/es/components/DeleteConfirmAction/index.js.map +1 -1
  11. package/es/components/DeleteConfirmAction/withDeleteConfirmAction.d.ts +19 -0
  12. package/es/components/DeleteConfirmAction/withDeleteConfirmAction.js +20 -0
  13. package/es/components/DeleteConfirmAction/withDeleteConfirmAction.js.map +1 -0
  14. package/es/components/ModalAction/index.d.ts +35 -29
  15. package/es/components/ModalAction/index.js +16 -9
  16. package/es/components/ModalAction/index.js.map +1 -1
  17. package/es/components/index.d.ts +3 -1
  18. package/es/components/index.js +2 -0
  19. package/es/components/index.js.map +1 -1
  20. package/lib/components/ConfirmAction/index.d.ts +97 -36
  21. package/lib/components/ConfirmAction/index.js +57 -41
  22. package/lib/components/ConfirmAction/index.js.map +2 -2
  23. package/lib/components/ConfirmAction/withConfirmAction.d.ts +48 -0
  24. package/lib/components/ConfirmAction/withConfirmAction.js +123 -0
  25. package/lib/components/ConfirmAction/withConfirmAction.js.map +7 -0
  26. package/lib/components/DeleteConfirmAction/index.d.ts +1 -1
  27. package/lib/components/DeleteConfirmAction/index.js +28 -16
  28. package/lib/components/DeleteConfirmAction/index.js.map +2 -2
  29. package/lib/components/DeleteConfirmAction/withDeleteConfirmAction.d.ts +19 -0
  30. package/lib/components/DeleteConfirmAction/withDeleteConfirmAction.js +38 -0
  31. package/lib/components/DeleteConfirmAction/withDeleteConfirmAction.js.map +7 -0
  32. package/lib/components/ModalAction/index.d.ts +35 -29
  33. package/lib/components/ModalAction/index.js +22 -17
  34. package/lib/components/ModalAction/index.js.map +2 -2
  35. package/lib/components/index.d.ts +3 -1
  36. package/lib/components/index.js +6 -0
  37. package/lib/components/index.js.map +2 -2
  38. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import type { ComponentType, FC, ForwardedRef, ReactElement, ReactNode, RefAttributes } from 'react';
1
+ import type { ComponentType, FC, ForwardedRef, ReactNode, RefAttributes } from 'react';
2
2
  import type { ButtonProps, FormInstance, ModalProps, SwitchProps } from 'antd';
3
3
  import type { LinkProps } from 'antd/es/typography/Link';
4
4
  /**
@@ -7,25 +7,25 @@ import type { LinkProps } from 'antd/es/typography/Link';
7
7
  * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效
8
8
  */
9
9
  export declare const SubmitWithoutClosingSymbol: unique symbol;
10
- export type ModalActionProps<FD extends object, CP extends FormCompPropsConstraint<FD>, TP extends object, E extends keyof TP, CRef extends object> = Omit<ModalProps, 'onOk'> & ModalActionTrigger<FD, CP, TP, E> & {
10
+ export type ModalActionProps<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object> = Omit<ModalProps, 'onOk'> & ModalActionTrigger<FormData, P, TriggerProp, Event> & {
11
11
  /**
12
12
  * - **EN:** Form editing component, do not use the Form component inside the component, the form
13
13
  * component and form instance are automatically created by the parent component
14
14
  * - **CN:** 表单编辑组件,组件内部不要使用Form组件,表单组件及表单实例由父组件自动创建
15
15
  */
16
- formComp: ComponentType<CP & RefAttributes<CRef>>;
16
+ formComp: ComponentType<P & RefAttributes<Ref>>;
17
17
  /**
18
18
  * - **EN:** Props of the form editing component
19
19
  * - **CN:** 表单编辑组件的Props属性
20
20
  */
21
- formProps?: Omit<CP, keyof FormCompPropsConstraint<FD>>;
21
+ formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>;
22
22
  /**
23
23
  * - **EN:** The callback when clicks the confirmation button, support asynchronous saving, return
24
24
  * `SubmitWithoutClosingSymbol` can prevent the dialog from closing, return other values will
25
25
  * be passed to the `afterOk` event, if any
26
26
  * - **CN:** 点击确认按钮的回调,支持异步保存,返回`SubmitWithoutClosingSymbol`可以阻止弹框关闭,返回其他值会传递给`afterOk`事件,如果有的话
27
27
  */
28
- onOk?: (formData: FD, ...args: Parameters<TP[E]>) => unknown | Promise<unknown>;
28
+ onOk?: (formData: FormData, ...args: Parameters<TriggerProp[Event]>) => unknown | Promise<unknown>;
29
29
  /**
30
30
  * - **EN:** The callback after the confirmation event is completed, it will not be triggered when
31
31
  * it fails, the parameter is the return value of `onOk`
@@ -33,13 +33,13 @@ export type ModalActionProps<FD extends object, CP extends FormCompPropsConstrai
33
33
  */
34
34
  afterOk?: (data?: any) => void;
35
35
  };
36
- export interface FormCompPropsConstraint<FD> {
36
+ export interface FormCompPropsConstraint<FormData> {
37
37
  /**
38
38
  * - **EN:** Automatically generated form instance, use this form instance in FormComp, do not
39
39
  * create a new instance
40
40
  * - **CN:** 自动生成的表单实例,编辑表单要使用这个表单实例,不要新创建实例
41
41
  */
42
- form: FormInstance<FD>;
42
+ form: FormInstance<FormData>;
43
43
  /**
44
44
  * - **EN:** Register the form save event, the callback function passed in will be called when the
45
45
  * confirm button is clicked, support asynchronous saving
@@ -52,7 +52,7 @@ export interface FormCompPropsConstraint<FD> {
52
52
  * - **EN:** Form data
53
53
  * - **CN:** 表单数据
54
54
  */
55
- formData: FD,
55
+ formData: FormData,
56
56
  /**
57
57
  * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get
58
58
  * the value of the switch; for the `Button` type trigger, you can get the click event
@@ -89,17 +89,17 @@ export interface FormCompPropsConstraint<FD> {
89
89
  */
90
90
  triggerEventData?: any[];
91
91
  }
92
- export interface ModalActionTrigger<FD extends object, CP extends FormCompPropsConstraint<FD>, TP extends object, E extends keyof TP> {
92
+ export interface ModalActionTrigger<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp> {
93
93
  /**
94
94
  * - **EN:** Trigger component, click to show the dialog
95
95
  * - **CN:** 弹窗触发器组件,点击触发显示弹框
96
96
  */
97
- triggerComponent?: ComponentType<TP> | FC<TP>;
97
+ triggerComponent?: ComponentType<TriggerProp> | FC<TriggerProp>;
98
98
  /**
99
99
  * - **EN:** Props of the trigger component
100
100
  * - **CN:** 触发器组件的Props属性
101
101
  */
102
- triggerProps?: TP & {
102
+ triggerProps?: TriggerProp & {
103
103
  /**
104
104
  * - **EN:** Set a custom function to determine whether to show the trigger button
105
105
  * - **CN:** 设置一个自定义函数,用于判断是否显示触发器按钮
@@ -108,7 +108,7 @@ export interface ModalActionTrigger<FD extends object, CP extends FormCompPropsC
108
108
  *
109
109
  * @param formProps Form component props | 表单组件的props
110
110
  */
111
- show?: boolean | ((formProps?: Omit<CP, keyof FormCompPropsConstraint<FD>>) => boolean);
111
+ show?: boolean | ((formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>) => boolean);
112
112
  };
113
113
  /**
114
114
  * - **EN:** The event name that triggers the dialog
@@ -117,7 +117,7 @@ export interface ModalActionTrigger<FD extends object, CP extends FormCompPropsC
117
117
  * - `Switch`: 'onChange'
118
118
  * - `Link`: 'onClick'
119
119
  */
120
- triggerEvent?: E;
120
+ triggerEvent?: Event;
121
121
  /**
122
122
  * - **EN:** Custom trigger content
123
123
  * - **CN:** 自定义触发器内容
@@ -131,7 +131,7 @@ export type ModalActionRef<R> = R & {
131
131
  */
132
132
  show: () => void;
133
133
  };
134
- export declare const genModalActionRenderer: (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => <FD extends object, CP extends FormCompPropsConstraint<FD>, TP extends object, E extends keyof TP, CRef extends object>(props: ModalActionProps<FD, CP, TP, E, CRef>, ref: ForwardedRef<ModalActionRef<CRef>>) => import("react/jsx-runtime").JSX.Element;
134
+ export declare const genModalActionRenderer: (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(props: ModalActionProps<FormData, P, TriggerProp, Event, Ref>, ref: ForwardedRef<ModalActionRef<Ref>>) => import("react/jsx-runtime").JSX.Element;
135
135
  /**
136
136
  * - **EN:** Add default properties to the ModalAction component
137
137
  * - **CN:** 给ModalAction组件添加默认属性
@@ -139,72 +139,72 @@ export declare const genModalActionRenderer: (defaultProps: Partial<ModalActionP
139
139
  * @param WrappedComponent ModalAction component | ModalAction组件
140
140
  * @param defaultProps Default properties | 默认属性
141
141
  */
142
- export declare const withDefaultModalActionProps: <FD extends object, CP extends FormCompPropsConstraint<FD>, TP extends object, E extends keyof TP, CRef extends object>(WrappedComponent: ComponentType<ModalActionProps<FD, CP, TP, E, CRef> & RefAttributes<ModalActionRef<CRef>>>, defaultProps?: Partial<ModalActionProps<FD, CP, TP, E, CRef>> | (() => Partial<ModalActionProps<FD, CP, TP, E, CRef>>)) => import("react").ForwardRefExoticComponent<Omit<ModalProps, "onOk"> & ModalActionTrigger<FD, CP, TP, E> & {
142
+ export declare const withDefaultModalActionProps: <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(WrappedComponent: ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>>, defaultProps?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>> | ((actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>) | undefined) => import("react").ForwardRefExoticComponent<Omit<ModalProps, "onOk"> & ModalActionTrigger<FormData, P, TriggerProp, Event> & {
143
143
  /**
144
144
  * - **EN:** Form editing component, do not use the Form component inside the component, the form
145
145
  * component and form instance are automatically created by the parent component
146
146
  * - **CN:** 表单编辑组件,组件内部不要使用Form组件,表单组件及表单实例由父组件自动创建
147
147
  */
148
- formComp: ComponentType<CP & RefAttributes<CRef>>;
148
+ formComp: ComponentType<P & RefAttributes<Ref>>;
149
149
  /**
150
150
  * - **EN:** Props of the form editing component
151
151
  * - **CN:** 表单编辑组件的Props属性
152
152
  */
153
- formProps?: Omit<CP, keyof FormCompPropsConstraint<FD_1>> | undefined;
153
+ formProps?: Omit<P, keyof FormCompPropsConstraint<FormData_1>> | undefined;
154
154
  /**
155
155
  * - **EN:** The callback when clicks the confirmation button, support asynchronous saving, return
156
156
  * `SubmitWithoutClosingSymbol` can prevent the dialog from closing, return other values will
157
157
  * be passed to the `afterOk` event, if any
158
158
  * - **CN:** 点击确认按钮的回调,支持异步保存,返回`SubmitWithoutClosingSymbol`可以阻止弹框关闭,返回其他值会传递给`afterOk`事件,如果有的话
159
159
  */
160
- onOk?: ((formData: FD, ...args: Parameters<TP[E]>) => unknown | Promise<unknown>) | undefined;
160
+ onOk?: ((formData: FormData, ...args: Parameters<TriggerProp[Event]>) => unknown | Promise<unknown>) | undefined;
161
161
  /**
162
162
  * - **EN:** The callback after the confirmation event is completed, it will not be triggered when
163
163
  * it fails, the parameter is the return value of `onOk`
164
164
  * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值
165
165
  */
166
166
  afterOk?: ((data?: any) => void) | undefined;
167
- } & RefAttributes<ModalActionRef<CRef>>>;
167
+ } & RefAttributes<ModalActionRef<Ref>>>;
168
168
  /**
169
169
  * - **EN:** ModalAction component type
170
170
  * - **CN:** ModalAction组件的类型
171
171
  */
172
- export type ModalActionInterface<FD extends object, CP extends FormCompPropsConstraint<FD>, TP extends object, E extends keyof TP, CRef extends object> = ComponentType<ModalActionProps<FD, CP, TP, E, CRef> & RefAttributes<ModalActionRef<CRef>>>;
172
+ export type ModalActionInterface<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object> = ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>>;
173
173
  /**
174
174
  * - **EN:** ModalAction component with generic type
175
175
  * - **CN:** ModalAction泛型组件的类型
176
176
  */
177
- export type GenericModalActionInterface = <FD extends object, CP extends FormCompPropsConstraint<FD>, TP extends object, E extends keyof TP, CRef extends object>(props: ModalActionProps<FD, CP, TP, E, CRef> & RefAttributes<ModalActionRef<CRef>>) => ReactElement;
177
+ export type GenericModalActionInterface = <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(props: ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>) => ReactNode;
178
178
  /**
179
179
  * - **EN:** ModalAction with specified trigger type (specified form component)
180
180
  * - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)
181
181
  */
182
- type ModalActionWithTrigger<FD extends object, CP extends FormCompPropsConstraint<FD>, TP extends object, E extends keyof TP, CRef extends object, OMIT extends string = never> = ComponentType<Omit<ModalActionProps<FD, CP, TP, E, CRef>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<CRef>>>;
182
+ type ModalActionWithTrigger<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object, OMIT extends string = never> = ComponentType<Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<Ref>>>;
183
183
  /**
184
184
  * - **EN:** ModalAction with specified trigger type (unspecified form component, keep generic)
185
185
  * - **CN:** 已指定Trigger类型的ModalAction(未指定表单组件,保持泛型)
186
186
  */
187
- type GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <FD extends object, CP extends FormCompPropsConstraint<FD>, CRef extends object>(props: Omit<ModalActionProps<FD, CP, TP, E, CRef>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<CRef>>) => ReactElement;
187
+ type GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <FormData extends object, P extends FormCompPropsConstraint<FormData>, Ref extends object>(props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<Ref>>) => ReactNode;
188
188
  /**
189
189
  * - **EN:** Built-in trigger types (specified form components)
190
190
  * - **CN:** 内置的几种触发器类型(已指定表单组件)
191
191
  */
192
- interface TypedTriggers<FD extends object, CP extends FormCompPropsConstraint<FD>, CRef extends object, OMIT extends string = never> {
192
+ interface TypedTriggers<FormData extends object, P extends FormCompPropsConstraint<FormData>, Ref extends object, OMIT extends string = never> {
193
193
  /**
194
194
  * - **EN:** Dialog with button type trigger
195
195
  * - **CN:** 按钮类型的弹窗
196
196
  */
197
- Button: ModalActionWithTrigger<FD, CP, ButtonProps, 'onClick', CRef, 'triggerComponent' | 'triggerEvent' | OMIT>;
197
+ Button: ModalActionWithTrigger<FormData, P, ButtonProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;
198
198
  /**
199
199
  * - **EN:** Dialog with switch type trigger
200
200
  * - **CN:** 开关类型的弹窗
201
201
  */
202
- Switch: ModalActionWithTrigger<FD, CP, SwitchProps, 'onChange', CRef, 'triggerComponent' | 'triggerEvent' | OMIT>;
202
+ Switch: ModalActionWithTrigger<FormData, P, SwitchProps, 'onChange', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;
203
203
  /**
204
204
  * - **EN:** Dialog with link type trigger
205
205
  * - **CN:** 链接类型的弹窗
206
206
  */
207
- Link: ModalActionWithTrigger<FD, CP, LinkProps, 'onClick', CRef, 'triggerComponent' | 'triggerEvent' | OMIT>;
207
+ Link: ModalActionWithTrigger<FormData, P, LinkProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;
208
208
  }
209
209
  /**
210
210
  * - **EN:** Built-in trigger types (generic types, unspecified form components)
@@ -227,7 +227,7 @@ interface GenericTypedTriggers<OMIT extends string = never> {
227
227
  */
228
228
  Link: GenericModalActionWithTrigger<LinkProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;
229
229
  }
230
- type WithGenericTriggers<FD extends object, CP extends FormCompPropsConstraint<FD>, CRef extends object, OMIT extends string = never> = (<TP extends object, E extends keyof TP>(props: Omit<ModalActionProps<FD, CP, TP, E, CRef>, OMIT> & RefAttributes<ModalActionRef<CRef>>) => ReactElement) & (CP extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FD, CP, CRef, OMIT>);
230
+ type WithGenericTriggers<FormData extends object, P extends FormCompPropsConstraint<FormData>, Ref extends object, OMIT extends string = never> = (<TriggerProp extends object, Event extends keyof TriggerProp>(props: Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, OMIT> & RefAttributes<ModalActionRef<Ref>>) => ReactNode) & (P extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FormData, P, Ref, OMIT>);
231
231
  /**
232
232
  * - **EN:** Dialog component with trigger
233
233
  * - **CN:** 带触发器的弹窗组件
@@ -249,9 +249,15 @@ export type ModalActionWithStatic = typeof ModalAction & {
249
249
  * - **EN:** Generate a dialog component based on the editing form component
250
250
  * - **CN:** 基于编辑表单组件生成一个弹框组件
251
251
  *
252
+ * @template FormData Form data type | 表单数据类型
253
+ * @template P Form component props type | 表单组件的props类型
254
+ * @template OuterTriggerProp Outer trigger props type | 外部触发器的props类型
255
+ * @template OuterEvent Outer trigger event type | 外部触发器的事件类型
256
+ * @template Ref Form component ref type | 表单组件的ref类型
257
+ *
252
258
  * @param formComp Component of dialog content | 弹窗内容组件
253
259
  * @param defaultProps Default properties of the dialog | 弹窗的默认属性
254
260
  */
255
- export declare function withModalAction<FD extends object, CP extends FormCompPropsConstraint<FD>, OuterTP extends object, OuterE extends keyof OuterTP, CRef extends object>(formComp: ComponentType<CP & FormCompPropsConstraint<FD> & RefAttributes<CRef>>, defaultProps?: Partial<ModalActionProps<FD, CP, OuterTP, OuterE, CRef>> | (() => Partial<ModalActionProps<FD, CP, OuterTP, OuterE, CRef>>)): WithGenericTriggers<FD, CP, CRef, "formComp">;
261
+ export declare function withModalAction<FormData extends object, P extends FormCompPropsConstraint<FormData>, OuterTriggerProp extends object, OuterEvent extends keyof OuterTriggerProp, Ref extends object>(formComp: ComponentType<P & FormCompPropsConstraint<FormData> & RefAttributes<Ref>>, defaultProps?: Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>> | ((actualProps: ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>) => Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)): WithGenericTriggers<FormData, P, Ref, "formComp">;
256
262
  declare const _default: ModalActionWithStatic;
257
263
  export default _default;
@@ -265,26 +265,31 @@ function FormCreator(props) {
265
265
  return null;
266
266
  }
267
267
  var withDefaultModalActionProps = (WrappedComponent, defaultProps) => {
268
- const WithDefaultProps = (0, import_react.forwardRef)((props, ref) => {
269
- const useDefaultProps = typeof defaultProps === "function" ? defaultProps : () => defaultProps;
270
- const defaults = useDefaultProps();
271
- const mergedProps = mergeProps(defaults, props);
272
- WithDefaultProps.displayName = "ForwardedRef(WithDefaultProps)";
273
- return /* @__PURE__ */ React.createElement(WrappedComponent, { ref, ...mergedProps });
274
- });
268
+ const WithDefaultProps = (0, import_react.forwardRef)(
269
+ (props, ref) => {
270
+ const useDefaultProps = typeof defaultProps === "function" ? defaultProps : () => defaultProps;
271
+ const defaults = useDefaultProps(props);
272
+ const mergedProps = typeof defaultProps === "function" ? mergeProps(props, defaults) : mergeProps(defaults, props);
273
+ WithDefaultProps.displayName = "ForwardRef(WithDefaultProps)";
274
+ return /* @__PURE__ */ React.createElement(WrappedComponent, { ref, ...mergedProps });
275
+ }
276
+ );
275
277
  return WithDefaultProps;
276
278
  };
277
279
  var renderModalAction = genModalActionRenderer({});
278
280
  var forwardedModalAction = (0, import_react.forwardRef)(renderModalAction);
279
- forwardedModalAction.displayName = "ForwardedRef(ModalAction)";
281
+ forwardedModalAction.displayName = "ForwardRef(ModalAction)";
280
282
  var addTriggers = (comp) => {
281
283
  const patchedComp = comp;
282
- patchedComp.Button = withDefaultModalActionProps(comp, {
283
- triggerComponent: import_antd.Button,
284
- triggerEvent: "onClick",
285
- triggerProps: {}
284
+ patchedComp.Button = withDefaultModalActionProps(
285
+ comp,
286
+ {
287
+ triggerComponent: import_antd.Button,
288
+ triggerEvent: "onClick",
289
+ triggerProps: {}
290
+ }
286
291
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
287
- });
292
+ );
288
293
  patchedComp.Switch = withDefaultModalActionProps(
289
294
  comp,
290
295
  {
@@ -307,18 +312,18 @@ var addTriggers = (comp) => {
307
312
  var ModalAction = addTriggers(forwardedModalAction);
308
313
  ModalAction.SubmitWithoutClosing = SubmitWithoutClosingSymbol;
309
314
  function withModalAction(formComp, defaultProps) {
310
- const withForm = withDefaultModalActionProps(
315
+ const withDefaults = withDefaultModalActionProps(
311
316
  forwardedModalAction,
312
- () => {
317
+ (props) => {
313
318
  const useDefaultProps = typeof defaultProps === "function" ? defaultProps : () => defaultProps;
314
- const defaults = useDefaultProps();
319
+ const defaults = useDefaultProps(props);
315
320
  return {
316
321
  formComp,
317
322
  ...defaults
318
323
  };
319
324
  }
320
325
  );
321
- return addTriggers(withForm);
326
+ return addTriggers(withDefaults);
322
327
  }
323
328
  var ModalAction_default = ModalAction;
324
329
  // Annotate the CommonJS export names for ESM import in node:
@@ -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, ReactElement, 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 FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n TP extends object,\n E extends keyof TP,\n CRef extends object,\n> = Omit<ModalProps, 'onOk'> &\n ModalActionTrigger<FD, CP, TP, E> & {\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<CP & RefAttributes<CRef>>;\n /**\n * - **EN:** Props of the form editing component\n * - **CN:** 表单编辑组件的Props属性\n */\n formProps?: Omit<CP, keyof FormCompPropsConstraint<FD>>;\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: FD,\n // @ts-expect-error: because TP[E] should be a function type\n ...args: Parameters<TP[E]>\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<FD> {\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<FD>;\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: FD,\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 FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n TP extends object,\n E extends keyof TP,\n> {\n /**\n * - **EN:** Trigger component, click to show the dialog\n * - **CN:** 弹窗触发器组件,点击触发显示弹框\n */\n triggerComponent?: ComponentType<TP> | FC<TP>;\n /**\n * - **EN:** Props of the trigger component\n * - **CN:** 触发器组件的Props属性\n */\n triggerProps?: TP & {\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<CP, keyof FormCompPropsConstraint<FD>>) => 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?: E;\n /**\n * - **EN:** Custom trigger content\n * - **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\nexport type ModalActionRef<R> = R & {\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 FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n TP extends object,\n E extends keyof TP,\n CRef extends object,\n >(\n props: ModalActionProps<FD, CP, TP, E, CRef>,\n ref: ForwardedRef<ModalActionRef<CRef>>\n ) => {\n const [userModalProps, setUserModalProps] = useState<Partial<ModalProps>>({});\n let mergedProps = mergeProps<FD, CP, TP, E, CRef>(defaultProps, props);\n mergedProps = mergeProps(mergedProps, userModalProps as typeof props);\n const {\n formComp,\n formProps,\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as E,\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<FD> & RefAttributes<CRef>>;\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: FD, ...args: any[]) => unknown>(undefined);\n const [isSaving, setIsSaving] = useState(false);\n const [formCompRef, setFormCompRef] = useState<CRef | null>(null);\n const [form, setForm] = useState<FormInstance<FD>>();\n const formRef = useRef<FormInstance<FD>>(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) {\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<FD>['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, show: showModal }) as ModalActionRef<CRef>, [\n formCompRef,\n showModal,\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 TP)}\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: FD;\n try {\n formData = (await form?.validateFields()) as FD;\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result = await onOk?.((result as FD) ?? formData, ...((triggerEventArgsRef.current ?? []) as any));\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<FD> 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 FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n TP extends object,\n E extends keyof TP,\n CRef extends object,\n>(first?: Partial<ModalActionProps<FD, CP, TP, E, CRef>>, second?: Partial<ModalActionProps<FD, CP, TP, E, CRef>>) {\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 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<FD, CP, TP, E, CRef>;\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 FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n TP extends object,\n E extends keyof TP,\n CRef extends object,\n>(\n WrappedComponent: ComponentType<ModalActionProps<FD, CP, TP, E, CRef> & RefAttributes<ModalActionRef<CRef>>>,\n defaultProps?: Partial<ModalActionProps<FD, CP, TP, E, CRef>> | (() => Partial<ModalActionProps<FD, CP, TP, E, CRef>>)\n) => {\n const WithDefaultProps = forwardRef<ModalActionRef<CRef>, ModalActionProps<FD, CP, TP, E, CRef>>((props, ref) => {\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps();\n const mergedProps = mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardedRef(WithDefaultProps)';\n return <WrappedComponent ref={ref} {...mergedProps} />;\n });\n return WithDefaultProps;\n};\n\nconst renderModalAction = genModalActionRenderer({});\nconst forwardedModalAction = forwardRef(renderModalAction);\nforwardedModalAction.displayName = 'ForwardedRef(ModalAction)';\n/**\n * - **EN:** ModalAction component type\n * - **CN:** ModalAction组件的类型\n */\nexport type ModalActionInterface<\n FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n TP extends object,\n E extends keyof TP,\n CRef extends object,\n> = ComponentType<ModalActionProps<FD, CP, TP, E, CRef> & RefAttributes<ModalActionRef<CRef>>>;\n/**\n * - **EN:** ModalAction component with generic type\n * - **CN:** ModalAction泛型组件的类型\n */\nexport type GenericModalActionInterface = <\n FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n TP extends object,\n E extends keyof TP,\n CRef extends object,\n>(\n props: ModalActionProps<FD, CP, TP, E, CRef> & RefAttributes<ModalActionRef<CRef>>\n) => ReactElement;\n/**\n * - **EN:** ModalAction with specified trigger type (specified form component)\n * - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)\n */\ntype ModalActionWithTrigger<\n FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n TP extends object,\n E extends keyof TP,\n CRef extends object,\n OMIT extends string = never,\n> = ComponentType<\n Omit<ModalActionProps<FD, CP, TP, E, CRef>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<CRef>>\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 FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n CRef extends object,\n>(\n props: Omit<ModalActionProps<FD, CP, TP, E, CRef>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<CRef>>\n) => ReactElement;\n\n/**\n * - **EN:** Built-in trigger types (specified form components)\n * - **CN:** 内置的几种触发器类型(已指定表单组件)\n */\ninterface TypedTriggers<\n FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n CRef extends object,\n OMIT extends string = never,\n> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: ModalActionWithTrigger<FD, CP, ButtonProps, 'onClick', CRef, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: ModalActionWithTrigger<FD, CP, SwitchProps, 'onChange', CRef, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: ModalActionWithTrigger<FD, CP, LinkProps, 'onClick', CRef, '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 FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n CRef extends object,\n OMIT extends string = never,\n> = (<TP extends object, E extends keyof TP>(\n props: Omit<ModalActionProps<FD, CP, TP, E, CRef>, OMIT> & RefAttributes<ModalActionRef<CRef>>\n) => ReactElement) &\n (CP extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FD, CP, CRef, OMIT>);\n\n/**\n * - **EN:** Add trigger types to the ModalAction component\n * - **CN:** 给ModalAction组件添加子触发器类型\n */\nconst addTriggers = <\n FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n OuterTP extends object,\n OuterE extends keyof OuterTP,\n CRef extends object,\n OMIT extends string = never,\n>(\n comp: ComponentType<ModalActionProps<FD, CP, OuterTP, OuterE, CRef> & RefAttributes<ModalActionRef<CRef>>>\n) => {\n const patchedComp = comp as WithGenericTriggers<FD, CP, CRef, OMIT>;\n // Type of button trigger\n patchedComp.Button = withDefaultModalActionProps(comp as ModalActionInterface<FD, CP, ButtonProps, 'onClick', CRef>, {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\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<FD, CP, SwitchProps, 'onChange', CRef>,\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<FD, CP, LinkProps, 'onClick', CRef>, {\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 * @param formComp Component of dialog content | 弹窗内容组件\n * @param defaultProps Default properties of the dialog | 弹窗的默认属性\n */\nexport function withModalAction<\n FD extends object,\n CP extends FormCompPropsConstraint<FD>,\n OuterTP extends object,\n OuterE extends keyof OuterTP,\n CRef extends object,\n>(\n formComp: ComponentType<CP & FormCompPropsConstraint<FD> & RefAttributes<CRef>>,\n defaultProps?:\n | Partial<ModalActionProps<FD, CP, OuterTP, OuterE, CRef>>\n | (() => Partial<ModalActionProps<FD, CP, OuterTP, OuterE, CRef>>)\n) {\n const withForm = withDefaultModalActionProps(\n forwardedModalAction as unknown as ModalActionInterface<FD, CP, OuterTP, OuterE, CRef>,\n () => {\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps();\n return {\n formComp,\n ...defaults,\n };\n }\n ) as unknown as <TP extends object, E extends keyof TP>(\n props: Omit<ModalActionProps<FD, CP, TP, E, CRef>, 'formComp'> & RefAttributes<ModalActionRef<CRef>>\n ) => ReactElement;\n return addTriggers<FD, CP, OuterTP, OuterE, CRef, 'formComp'>(withForm);\n}\n\nexport default ModalAction as ModalActionWithStatic;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAmG;AAEnG,kBAAwD;AAExD,sBAA6B;AAC7B,iCAAgC;AAOzB,IAAM,6BAA6B,OAAO,sBAAsB;AAuJhE,IAAM,yBAAyB,CAAC,iBAAyE;AAC9G,QAAM,sBAAsB,CAO1B,OACA,QACG;AACH,UAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAA8B,CAAC,CAAC;AAC5E,QAAI,cAAc,WAAgC,cAAc,KAAK;AACrE,kBAAc,WAAW,aAAa,cAA8B;AACpE,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,kBAAkB,UAAU;AAAA,MAC5B,eAAe;AAAA,MACf;AAAA,MACA,MAAM;AAAA,MACN,iBAAiB;AAAA,MACjB,kBAAkB;AAAA,MAClB,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AACJ,mCAAAA,SAAoB;AACpB,UAAM,WAAW;AAEjB,UAAM,0BAAsB,qBAAc,MAAS;AACnD,UAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AACtC,UAAM,kBAAc,qBAAkD,MAAS;AAC/E,UAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,KAAK;AAC9C,UAAM,CAAC,aAAa,cAAc,QAAI,uBAAsB,IAAI;AAChE,UAAM,CAAC,MAAM,OAAO,QAAI,u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AW;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;AASvD,SAAS,gBAOd,UACA,cAGA;AACA,QAAM,WAAW;AAAA,IACf;AAAA,IACA,MAAM;AACJ,YAAM,kBAAkB,OAAO,iBAAiB,aAAa,eAAe,MAAM;AAClF,YAAM,WAAW,gBAAgB;AACjC,aAAO;AAAA,QACL;AAAA,QACA,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAGA,SAAO,YAAuD,QAAQ;AACxE;AAEA,IAAO,sBAAQ;",
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}\nexport type ModalActionRef<R> = R & {\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>>\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) {\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, show: showModal }) as ModalActionRef<Ref>, [\n formCompRef,\n showModal,\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result = await onOk?.((result as FormData) ?? formData, ...((triggerEventArgsRef.current ?? []) as any));\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 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>>\n >,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n | ((\n actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>\n ) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>)\n) => {\n const WithDefaultProps = forwardRef<ModalActionRef<Ref>, ModalActionProps<FormData, P, TriggerProp, Event, Ref>>(\n (props, ref) => {\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props);\n const mergedProps =\n typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n return <WrappedComponent ref={ref} {...mergedProps} />;\n }\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<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>>;\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>>\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>>\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>>\n) => ReactNode;\n\n/**\n * - **EN:** Built-in trigger types (specified form components)\n * - **CN:** 内置的几种触发器类型(已指定表单组件)\n */\ninterface 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> & RefAttributes<ModalActionRef<Ref>>\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>>\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 actualProps: ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>\n ) => Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)\n) {\n const withDefaults = withDefaultModalActionProps(\n forwardedModalAction as unknown as ModalActionInterface<FormData, P, OuterTriggerProp, OuterEvent, Ref>,\n (props) => {\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props);\n return {\n formComp,\n ...defaults,\n };\n }\n ) as unknown as <TP extends object, E extends keyof TP>(\n props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'formComp'> & RefAttributes<ModalActionRef<Ref>>\n ) => ReactNode;\n return addTriggers<FormData, P, OuterTriggerProp, OuterEvent, Ref, 'formComp'>(withDefaults);\n}\n\nexport default ModalAction as ModalActionWithStatic;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAmG;AAEnG,kBAAwD;AAExD,sBAA6B;AAC7B,iCAAgC;AAOzB,IAAM,6BAA6B,OAAO,sBAAsB;AAuJhE,IAAM,yBAAyB,CAAC,iBAAyE;AAC9G,QAAM,sBAAsB,CAO1B,OACA,QACG;AACH,UAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAA8B,CAAC,CAAC;AAC5E,QAAI,cAAc,WAAiD,cAAc,KAAK;AACtF,kBAAc,WAAW,aAAa,cAA8B;AACpE,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,kBAAkB,UAAU;AAAA,MAC5B,eAAe;AAAA,MACf;AAAA,MACA,MAAM;AAAA,MACN,iBAAiB;AAAA,MACjB,kBAAkB;AAAA,MAClB,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AACJ,mCAAAA,SAAoB;AACpB,UAAM,WAAW;AAEjB,UAAM,0BAAsB,qBAAc,MAAS;AACnD,UAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AACtC,UAAM,kBAAc,qBAAwD,MAAS;AACrF,UAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,KAAK;AAC9C,UAAM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A,MACE,kBAAkB;AAAA,MAClB,cAAc;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,cAKA;AACA,QAAM,eAAe;AAAA,IACnB;AAAA,IACA,CAAC,UAAU;AACT,YAAM,kBAAkB,OAAO,iBAAiB,aAAa,eAAe,MAAM;AAClF,YAAM,WAAW,gBAAgB,KAAK;AACtC,aAAO;AAAA,QACL;AAAA,QACA,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAGA,SAAO,YAAwE,YAAY;AAC7F;AAEA,IAAO,sBAAQ;",
6
6
  "names": ["useContextValidator", "open"]
7
7
  }
@@ -4,12 +4,14 @@ export type { ConfigProviderProps } from './ConfigProvider';
4
4
  export { default as ConfigProvider } from './ConfigProvider';
5
5
  export type { ReactEasyContextProps } from './ConfigProvider/context';
6
6
  export { default as ReactEasyContext } from './ConfigProvider/context';
7
- export type { ConfirmActionProps, ConfirmActionTrigger, ConfirmActionRef } from './ConfirmAction';
7
+ export type { ConfirmActionProps, ConfirmActionTrigger, ConfirmActionRef, ActionCompConstraint } from './ConfirmAction';
8
8
  export { withDefaultConfirmActionProps } from './ConfirmAction';
9
+ export { default as withConfirmAction } from './ConfirmAction/withConfirmAction';
9
10
  export { default as ConfirmAction } from './ConfirmAction';
10
11
  export type { ContextMenuProps, ContextMenuItem, ContextMenuSeparator, ContextMenuSubmenu, ContextMenuRef, } from './ContextMenu';
11
12
  export { default as ContextMenu } from './ContextMenu';
12
13
  export { default as DeleteConfirmAction } from './DeleteConfirmAction';
14
+ export { default as withDeleteConfirmAction } from './DeleteConfirmAction/withDeleteConfirmAction';
13
15
  export type { EditableTextProps } from './EditableText';
14
16
  export { default as EditableText } from './EditableText';
15
17
  export type { FloatDrawerProps } from './FloatDrawer';
@@ -40,8 +40,10 @@ __export(components_exports, {
40
40
  ModalAction: () => import_ModalAction2.default,
41
41
  OverflowTags: () => import_OverflowTags.default,
42
42
  ReactEasyContext: () => import_context.default,
43
+ withConfirmAction: () => import_withConfirmAction.default,
43
44
  withDefaultConfirmActionProps: () => import_ConfirmAction.withDefaultConfirmActionProps,
44
45
  withDefaultModalActionProps: () => import_ModalAction.withDefaultModalActionProps,
46
+ withDeleteConfirmAction: () => import_withDeleteConfirmAction.default,
45
47
  withModalAction: () => import_ModalAction.withModalAction
46
48
  });
47
49
  module.exports = __toCommonJS(components_exports);
@@ -49,9 +51,11 @@ var import_BreakLines = __toESM(require("./BreakLines"));
49
51
  var import_ConfigProvider = __toESM(require("./ConfigProvider"));
50
52
  var import_context = __toESM(require("./ConfigProvider/context"));
51
53
  var import_ConfirmAction = require("./ConfirmAction");
54
+ var import_withConfirmAction = __toESM(require("./ConfirmAction/withConfirmAction"));
52
55
  var import_ConfirmAction2 = __toESM(require("./ConfirmAction"));
53
56
  var import_ContextMenu = __toESM(require("./ContextMenu"));
54
57
  var import_DeleteConfirmAction = __toESM(require("./DeleteConfirmAction"));
58
+ var import_withDeleteConfirmAction = __toESM(require("./DeleteConfirmAction/withDeleteConfirmAction"));
55
59
  var import_EditableText = __toESM(require("./EditableText"));
56
60
  var import_FloatDrawer = __toESM(require("./FloatDrawer"));
57
61
  var import_Loading = __toESM(require("./Loading"));
@@ -71,8 +75,10 @@ var import_OverflowTags = __toESM(require("./OverflowTags"));
71
75
  ModalAction,
72
76
  OverflowTags,
73
77
  ReactEasyContext,
78
+ withConfirmAction,
74
79
  withDefaultConfirmActionProps,
75
80
  withDefaultModalActionProps,
81
+ withDeleteConfirmAction,
76
82
  withModalAction
77
83
  });
78
84
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/components/index.tsx"],
4
- "sourcesContent": ["export type { BreakLinesProps } from './BreakLines';\nexport { default as BreakLines } from './BreakLines';\n\nexport type { ConfigProviderProps } from './ConfigProvider';\nexport { default as ConfigProvider } from './ConfigProvider';\nexport type { ReactEasyContextProps } from './ConfigProvider/context';\nexport { default as ReactEasyContext } from './ConfigProvider/context';\n\nexport type { ConfirmActionProps, ConfirmActionTrigger, ConfirmActionRef } from './ConfirmAction';\nexport { withDefaultConfirmActionProps } from './ConfirmAction';\nexport { default as ConfirmAction } from './ConfirmAction';\n\nexport type {\n ContextMenuProps,\n ContextMenuItem,\n ContextMenuSeparator,\n ContextMenuSubmenu,\n ContextMenuRef,\n} from './ContextMenu';\nexport { default as ContextMenu } from './ContextMenu';\n\n// export * from './DeleteConfirmAction';\nexport { default as DeleteConfirmAction } from './DeleteConfirmAction';\n\nexport type { EditableTextProps } from './EditableText';\nexport { default as EditableText } from './EditableText';\n\nexport type { FloatDrawerProps } from './FloatDrawer';\nexport { default as FloatDrawer } from './FloatDrawer';\n\nexport type { LoadingProps } from './Loading';\nexport { default as Loading } from './Loading';\n\nexport type { ModalActionProps, FormCompPropsConstraint, ModalActionTrigger, ModalActionRef } from './ModalAction';\nexport { withDefaultModalActionProps, withModalAction } from './ModalAction';\nexport { default as ModalAction } from './ModalAction';\n\nexport type { OverflowTagsProps } from './OverflowTags';\nexport { default as OverflowTags } from './OverflowTags';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAAsC;AAGtC,4BAA0C;AAE1C,qBAA4C;AAG5C,2BAA8C;AAC9C,IAAAA,wBAAyC;AASzC,yBAAuC;AAGvC,iCAA+C;AAG/C,0BAAwC;AAGxC,yBAAuC;AAGvC,qBAAmC;AAGnC,yBAA6D;AAC7D,IAAAC,sBAAuC;AAGvC,0BAAwC;",
4
+ "sourcesContent": ["export type { BreakLinesProps } from './BreakLines';\nexport { default as BreakLines } from './BreakLines';\n\nexport type { ConfigProviderProps } from './ConfigProvider';\nexport { default as ConfigProvider } from './ConfigProvider';\nexport type { ReactEasyContextProps } from './ConfigProvider/context';\nexport { default as ReactEasyContext } from './ConfigProvider/context';\n\nexport type { ConfirmActionProps, ConfirmActionTrigger, ConfirmActionRef, ActionCompConstraint } from './ConfirmAction';\nexport { withDefaultConfirmActionProps } from './ConfirmAction';\nexport { default as withConfirmAction } from './ConfirmAction/withConfirmAction';\nexport { default as ConfirmAction } from './ConfirmAction';\n\nexport type {\n ContextMenuProps,\n ContextMenuItem,\n ContextMenuSeparator,\n ContextMenuSubmenu,\n ContextMenuRef,\n} from './ContextMenu';\nexport { default as ContextMenu } from './ContextMenu';\n\n// export * from './DeleteConfirmAction';\nexport { default as DeleteConfirmAction } from './DeleteConfirmAction';\nexport { default as withDeleteConfirmAction } from './DeleteConfirmAction/withDeleteConfirmAction';\n\nexport type { EditableTextProps } from './EditableText';\nexport { default as EditableText } from './EditableText';\n\nexport type { FloatDrawerProps } from './FloatDrawer';\nexport { default as FloatDrawer } from './FloatDrawer';\n\nexport type { LoadingProps } from './Loading';\nexport { default as Loading } from './Loading';\n\nexport type { ModalActionProps, FormCompPropsConstraint, ModalActionTrigger, ModalActionRef } from './ModalAction';\nexport { withDefaultModalActionProps, withModalAction } from './ModalAction';\nexport { default as ModalAction } from './ModalAction';\n\nexport type { OverflowTagsProps } from './OverflowTags';\nexport { default as OverflowTags } from './OverflowTags';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAAsC;AAGtC,4BAA0C;AAE1C,qBAA4C;AAG5C,2BAA8C;AAC9C,+BAA6C;AAC7C,IAAAA,wBAAyC;AASzC,yBAAuC;AAGvC,iCAA+C;AAC/C,qCAAmD;AAGnD,0BAAwC;AAGxC,yBAAuC;AAGvC,qBAAmC;AAGnC,yBAA6D;AAC7D,IAAAC,sBAAuC;AAGvC,0BAAwC;",
6
6
  "names": ["import_ConfirmAction", "import_ModalAction"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-codes/react-easy",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Simplify React and AntDesign development with practical components and hooks",
5
5
  "keywords": [
6
6
  "react",