@tiny-codes/react-easy 1.2.0 → 1.2.2

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 +28 -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 +18 -10
  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 +24 -18
  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
@@ -0,0 +1,123 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/ConfirmAction/withConfirmAction.tsx
20
+ var withConfirmAction_exports = {};
21
+ __export(withConfirmAction_exports, {
22
+ default: () => withConfirmAction,
23
+ withConfirmActionInternal: () => withConfirmActionInternal
24
+ });
25
+ module.exports = __toCommonJS(withConfirmAction_exports);
26
+ var import_react = require("react");
27
+ var import__ = require(".");
28
+ var import_antd = require("antd");
29
+ var import_react_is = require("react-is");
30
+ function withConfirmAction(ActionComponent, defaultProps) {
31
+ return withConfirmActionInternal(
32
+ ActionComponent,
33
+ {
34
+ confirmType: "normal"
35
+ },
36
+ defaultProps
37
+ );
38
+ }
39
+ function withConfirmActionInternal(ActionComponent, renderDefaultProps, defaultProps) {
40
+ const ConfirmActionWithRef = (0, import_react.forwardRef)((0, import__.genRenderer)(renderDefaultProps));
41
+ ConfirmActionWithRef.displayName = "ForwardRef(ConfirmAction)";
42
+ const WrappedActionComponent = (0, import_react.forwardRef)(
43
+ (propsWithDefaults, ref) => {
44
+ const actionRef = (0, import_react.useRef)(null);
45
+ const [customRef, setCustomRef] = (0, import_react.useState)(null);
46
+ const saveFuncRef = (0, import_react.useRef)(void 0);
47
+ const setOnOk = (0, import_react.useCallback)((handler) => {
48
+ saveFuncRef.current = handler;
49
+ }, []);
50
+ (0, import_react.useImperativeHandle)(ref, () => {
51
+ return {
52
+ ...actionRef.current,
53
+ ...customRef
54
+ };
55
+ }, [customRef]);
56
+ const triggerDom = /* @__PURE__ */ React.createElement(
57
+ ConfirmActionWithRef,
58
+ {
59
+ ...propsWithDefaults,
60
+ onOk: saveFuncRef.current,
61
+ ref: actionRef
62
+ }
63
+ );
64
+ return /* @__PURE__ */ React.createElement(
65
+ ActionComponent,
66
+ {
67
+ ...propsWithDefaults,
68
+ ref: (0, import_react_is.isForwardRef)(ActionComponent) ? setCustomRef : void 0,
69
+ setOK: setOnOk,
70
+ triggerDom
71
+ }
72
+ );
73
+ }
74
+ );
75
+ WrappedActionComponent.displayName = "ConfirmAction(ActionComponent)";
76
+ const withDefaults = (0, import__.withDefaultConfirmActionProps)(
77
+ WrappedActionComponent,
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ defaultProps
80
+ );
81
+ return addTriggers(withDefaults);
82
+ }
83
+ function addTriggers(comp) {
84
+ const patchedComp = comp;
85
+ patchedComp.Button = (0, import__.withDefaultConfirmActionProps)(
86
+ // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here
87
+ comp,
88
+ {
89
+ triggerComponent: import_antd.Button,
90
+ triggerEvent: "onClick",
91
+ triggerProps: {}
92
+ }
93
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
+ );
95
+ patchedComp.Switch = (0, import__.withDefaultConfirmActionProps)(
96
+ // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here
97
+ comp,
98
+ {
99
+ triggerComponent: import_antd.Switch,
100
+ triggerEvent: "onChange",
101
+ triggerProps: {}
102
+ }
103
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
104
+ );
105
+ patchedComp.Link = (0, import__.withDefaultConfirmActionProps)(
106
+ // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here
107
+ comp,
108
+ {
109
+ triggerComponent: import_antd.Typography.Link,
110
+ triggerEvent: "onClick",
111
+ triggerProps: {
112
+ style: { whiteSpace: "nowrap" }
113
+ }
114
+ }
115
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
116
+ );
117
+ return patchedComp;
118
+ }
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
121
+ withConfirmActionInternal
122
+ });
123
+ //# sourceMappingURL=withConfirmAction.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/ConfirmAction/withConfirmAction.tsx"],
4
+ "sourcesContent": ["import type { ComponentType, PropsWithoutRef, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';\nimport type { ActionCompConstraint, ConfirmActionProps, ConfirmActionRef } from '.';\nimport { genRenderer, withDefaultConfirmActionProps } from '.';\nimport { Button, type ButtonProps, Switch, type SwitchProps, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { isForwardRef } from 'react-is';\n\n/**\n * - **EN:** Generate a confirm box component with custom trigger and default props\n * - **CN:** 将一个组件包装成一个确认弹框组件,支持自定义触发器和默认属性\n *\n * @param actionComponent Custom trigger component | 自定义触发器组件\n * @param defaultProps Default properties of the confirm box | 确认弹框的默认属性\n */\nexport default function withConfirmAction<\n P extends ActionCompConstraint,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n ActionComponent: ActionComponentInterface<P, Ref>,\n defaultProps?:\n | Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>\n | ((\n actualProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>\n ) => Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>)\n) {\n return withConfirmActionInternal(\n ActionComponent,\n {\n confirmType: 'normal',\n },\n defaultProps\n );\n}\n\nexport function withConfirmActionInternal<\n P extends ActionCompConstraint,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n ActionComponent: ActionComponentInterface<P, Ref>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n renderDefaultProps: Partial<ConfirmActionProps<any, never>> & { confirmType: 'normal' | 'delete' },\n defaultProps?:\n | Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>\n | ((\n actualProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>\n ) => Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>)\n) {\n const ConfirmActionWithRef = forwardRef(genRenderer(renderDefaultProps));\n ConfirmActionWithRef.displayName = 'ForwardRef(ConfirmAction)';\n\n const WrappedActionComponent = forwardRef<Ref, ConfirmActionProps<OuterTriggerProp, OuterEvent>>(\n (propsWithDefaults, ref) => {\n const actionRef = useRef<ConfirmActionRef>(null);\n const [customRef, setCustomRef] = useState<Ref | null>(null);\n const saveFuncRef = useRef<(...triggerEventArgs: any[]) => unknown | Promise<unknown>>(undefined);\n\n // Receive the onSave callback method passed by the form component\n const setOnOk: ActionCompConstraint['setOK'] = useCallback((handler) => {\n saveFuncRef.current = handler;\n }, []);\n\n // Merge the default ref and custom ref and output to the parent component\n useImperativeHandle(ref, () => {\n return {\n ...actionRef.current,\n ...customRef,\n } as ConfirmActionRef<Ref>;\n }, [customRef]);\n\n // Render the default trigger DOM element, and pass it to the custom ActionComponent\n const triggerDom = (\n <ConfirmActionWithRef\n {...(propsWithDefaults as ConfirmActionProps<object, never>)}\n onOk={saveFuncRef.current}\n ref={actionRef}\n />\n );\n\n return (\n <ActionComponent\n {...(propsWithDefaults as P)}\n ref={isForwardRef(ActionComponent) ? setCustomRef : undefined}\n setOK={setOnOk}\n triggerDom={triggerDom}\n />\n );\n }\n );\n WrappedActionComponent.displayName = 'ConfirmAction(ActionComponent)';\n\n const withDefaults = withDefaultConfirmActionProps(\n WrappedActionComponent,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n defaultProps as any\n ) as unknown as ComponentType<\n Omit<ConfirmActionProps<OuterTriggerProp, OuterEvent>, 'triggerComponent'> & RefAttributes<ConfirmActionRef>\n >;\n // return withDefaults;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return addTriggers<P, OuterTriggerProp, OuterEvent, Ref>(withDefaults as any);\n}\n\n/**\n * - **EN:** Add trigger types to the ModalAction component\n * - **CN:** 给ModalAction组件添加子触发器类型\n */\nfunction addTriggers<\n P extends ActionCompConstraint,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(comp: ComponentType<ConfirmActionProps<OuterTriggerProp, OuterEvent> & RefAttributes<ConfirmActionRef<Ref>>>) {\n const patchedComp = comp as unknown as WithGenericTriggers<P, Ref>;\n // Type of button trigger\n patchedComp.Button = withDefaultConfirmActionProps<P, ButtonProps, 'onClick', Ref>(\n // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here\n comp,\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 = withDefaultConfirmActionProps<P, SwitchProps, 'onChange', Ref>(\n // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here\n comp,\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 = withDefaultConfirmActionProps<P, LinkProps, 'onClick', Ref>(\n // @ts-expect-error: because the type is a little bit complex, so we ignore the type error here\n comp,\n {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n return patchedComp;\n}\n\n/**\n * - **EN:** ModalAction component type\n * - **CN:** ModalAction组件的类型\n */\nexport type ActionComponentInterface<P extends ActionCompConstraint, Ref extends object> = ComponentType<\n P & RefAttributes<ConfirmActionRef<Ref>>\n>;\n\ntype WithGenericTriggers<P extends ActionCompConstraint, Ref extends object> = (<\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n>(\n props: PropsWithoutRef<Omit<P, keyof ActionCompConstraint>> &\n ConfirmActionProps<TriggerProp, Event> &\n RefAttributes<ConfirmActionRef<Ref>>\n) => ReactNode) &\n TypedTriggers<P, Ref>;\n\n/**\n * - **EN:** Built-in trigger types (specified form components)\n * - **CN:** 内置的几种触发器类型(已指定表单组件)\n */\nexport interface TypedTriggers<P extends ActionCompConstraint, Ref extends object> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: ConfirmActionWithTrigger<P, ButtonProps, 'onClick', Ref>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: ConfirmActionWithTrigger<P, SwitchProps, 'onChange', Ref>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: ConfirmActionWithTrigger<P, LinkProps, 'onClick', Ref>;\n}\n\n/**\n * - **EN:** ModalAction with specified trigger type (specified form component)\n * - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)\n */\ntype ConfirmActionWithTrigger<\n P extends ActionCompConstraint,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n OMIT extends string = never,\n> = ComponentType<\n Omit<\n PropsWithoutRef<Omit<P, keyof ActionCompConstraint>> & ConfirmActionProps<TriggerProp, Event>,\n 'triggerComponent' | 'triggerEvent' | OMIT\n > &\n RefAttributes<ConfirmActionRef<Ref>>\n>;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA+E;AAE/E,eAA2D;AAC3D,kBAA+E;AAE/E,sBAA6B;AASd,SAAR,kBAML,iBACA,cAKA;AACA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,aAAa;AAAA,IACf;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,0BAMd,iBAEA,oBACA,cAKA;AACA,QAAM,2BAAuB,6BAAW,sBAAY,kBAAkB,CAAC;AACvE,uBAAqB,cAAc;AAEnC,QAAM,6BAAyB;AAAA,IAC7B,CAAC,mBAAmB,QAAQ;AAC1B,YAAM,gBAAY,qBAAyB,IAAI;AAC/C,YAAM,CAAC,WAAW,YAAY,QAAI,uBAAqB,IAAI;AAC3D,YAAM,kBAAc,qBAAmE,MAAS;AAGhG,YAAM,cAAyC,0BAAY,CAAC,YAAY;AACtE,oBAAY,UAAU;AAAA,MACxB,GAAG,CAAC,CAAC;AAGL,4CAAoB,KAAK,MAAM;AAC7B,eAAO;AAAA,UACL,GAAG,UAAU;AAAA,UACb,GAAG;AAAA,QACL;AAAA,MACF,GAAG,CAAC,SAAS,CAAC;AAGd,YAAM,aACJ;AAAA,QAAC;AAAA;AAAA,UACE,GAAI;AAAA,UACL,MAAM,YAAY;AAAA,UAClB,KAAK;AAAA;AAAA,MACP;AAGF,aACE;AAAA,QAAC;AAAA;AAAA,UACE,GAAI;AAAA,UACL,SAAK,8BAAa,eAAe,IAAI,eAAe;AAAA,UACpD,OAAO;AAAA,UACP;AAAA;AAAA,MACF;AAAA,IAEJ;AAAA,EACF;AACA,yBAAuB,cAAc;AAErC,QAAM,mBAAe;AAAA,IACnB;AAAA;AAAA,IAEA;AAAA,EACF;AAKA,SAAO,YAAkD,YAAmB;AAC9E;AAMA,SAAS,YAKP,MAA8G;AAC9G,QAAM,cAAc;AAEpB,cAAY,aAAS;AAAA;AAAA,IAEnB;AAAA,IACA;AAAA,MACE,kBAAkB;AAAA,MAClB,cAAc;AAAA,MACd,cAAc,CAAC;AAAA,IACjB;AAAA;AAAA,EAEF;AAEA,cAAY,aAAS;AAAA;AAAA,IAEnB;AAAA,IACA;AAAA,MACE,kBAAkB;AAAA,MAClB,cAAc;AAAA,MACd,cAAc,CAAC;AAAA,IACjB;AAAA;AAAA,EAEF;AAEA,cAAY,WAAO;AAAA;AAAA,IAEjB;AAAA,IACA;AAAA,MACE,kBAAkB,uBAAW;AAAA,MAC7B,cAAc;AAAA,MACd,cAAc;AAAA,QACZ,OAAO,EAAE,YAAY,SAAS;AAAA,MAChC;AAAA,IACF;AAAA;AAAA,EAEF;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -1,4 +1,4 @@
1
- import { type ConfirmActionWithStatic } from '../ConfirmAction';
1
+ import type { ConfirmActionWithStatic } from '../ConfirmAction';
2
2
  /**
3
3
  * - **EN:** Delete operation confirmation box
4
4
  * - **CN:** 删除操作确认框
@@ -33,22 +33,34 @@ var renderDeleteConfirmAction = (0, import_ConfirmAction.genRenderer)({
33
33
  });
34
34
  var forwarded = (0, import_react.forwardRef)(renderDeleteConfirmAction);
35
35
  var DeleteConfirmAction = forwarded;
36
- DeleteConfirmAction.Button = (0, import_ConfirmAction.withDefaultConfirmActionProps)(forwarded, {
37
- triggerComponent: import_antd.Button,
38
- triggerEvent: "onClick",
39
- triggerProps: {}
40
- });
41
- DeleteConfirmAction.Switch = (0, import_ConfirmAction.withDefaultConfirmActionProps)(forwarded, {
42
- triggerComponent: import_antd.Switch,
43
- triggerEvent: "onChange",
44
- triggerProps: {}
45
- });
46
- DeleteConfirmAction.Link = (0, import_ConfirmAction.withDefaultConfirmActionProps)(forwarded, {
47
- triggerComponent: import_antd.Typography.Link,
48
- triggerEvent: "onClick",
49
- triggerProps: {
50
- style: { whiteSpace: "nowrap" }
36
+ DeleteConfirmAction.Button = (0, import_ConfirmAction.withDefaultConfirmActionProps)(
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ forwarded,
39
+ {
40
+ triggerComponent: import_antd.Button,
41
+ triggerEvent: "onClick",
42
+ triggerProps: {}
51
43
  }
52
- });
44
+ );
45
+ DeleteConfirmAction.Switch = (0, import_ConfirmAction.withDefaultConfirmActionProps)(
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ forwarded,
48
+ {
49
+ triggerComponent: import_antd.Switch,
50
+ triggerEvent: "onChange",
51
+ triggerProps: {}
52
+ }
53
+ );
54
+ DeleteConfirmAction.Link = (0, import_ConfirmAction.withDefaultConfirmActionProps)(
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ forwarded,
57
+ {
58
+ triggerComponent: import_antd.Typography.Link,
59
+ triggerEvent: "onClick",
60
+ triggerProps: {
61
+ style: { whiteSpace: "nowrap" }
62
+ }
63
+ }
64
+ );
53
65
  var DeleteConfirmAction_default = DeleteConfirmAction;
54
66
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/DeleteConfirmAction/index.tsx"],
4
- "sourcesContent": ["import { forwardRef } from 'react';\nimport type { ButtonProps, SwitchProps } from 'antd';\nimport { Button, Switch, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { CloseCircleFilled } from '@ant-design/icons';\nimport { type ConfirmActionWithStatic, genRenderer, withDefaultConfirmActionProps } from '../ConfirmAction';\n\nconst renderDeleteConfirmAction = genRenderer({\n confirmType: 'delete',\n danger: true,\n icon: <CloseCircleFilled />,\n});\nconst forwarded = forwardRef(renderDeleteConfirmAction);\n\n/**\n * - **EN:** Delete operation confirmation box\n * - **CN:** 删除操作确认框\n */\nconst DeleteConfirmAction = forwarded as unknown as ConfirmActionWithStatic;\n/**\n * - **EN:** Deletion confirmation box with button type\n * - **CN:** 按钮类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nDeleteConfirmAction.Button = withDefaultConfirmActionProps<ButtonProps, 'onClick'>(forwarded as any, {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n});\n/**\n * - **EN:** Deletion confirmation box with switch type\n * - **CN:** 开关类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nDeleteConfirmAction.Switch = withDefaultConfirmActionProps<SwitchProps, 'onChange'>(forwarded as any, {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n});\n/**\n * - **EN:** Deletion confirmation box with link type\n * - **CN:** 链接类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nDeleteConfirmAction.Link = withDefaultConfirmActionProps<LinkProps, 'onClick'>(forwarded as any, {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n});\n\nexport default DeleteConfirmAction;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAE3B,kBAA2C;AAE3C,mBAAkC;AAClC,2BAAyF;AAEzF,IAAM,gCAA4B,kCAAY;AAAA,EAC5C,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,MAAM,oCAAC,oCAAkB;AAC3B,CAAC;AACD,IAAM,gBAAY,yBAAW,yBAAyB;AAMtD,IAAM,sBAAsB;AAM5B,oBAAoB,aAAS,oDAAsD,WAAkB;AAAA,EACnG,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,cAAc,CAAC;AACjB,CAAC;AAMD,oBAAoB,aAAS,oDAAuD,WAAkB;AAAA,EACpG,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,cAAc,CAAC;AACjB,CAAC;AAMD,oBAAoB,WAAO,oDAAoD,WAAkB;AAAA,EAC/F,kBAAkB,uBAAW;AAAA,EAC7B,cAAc;AAAA,EACd,cAAc;AAAA,IACZ,OAAO,EAAE,YAAY,SAAS;AAAA,EAChC;AACF,CAAC;AAED,IAAO,8BAAQ;",
4
+ "sourcesContent": ["import { forwardRef } from 'react';\nimport type { ButtonProps, SwitchProps } from 'antd';\nimport { Button, Switch, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { CloseCircleFilled } from '@ant-design/icons';\nimport type { ActionCompConstraint, ConfirmActionWithStatic } from '../ConfirmAction';\nimport { genRenderer, withDefaultConfirmActionProps } from '../ConfirmAction';\n\nconst renderDeleteConfirmAction = genRenderer({\n confirmType: 'delete',\n danger: true,\n icon: <CloseCircleFilled />,\n});\nconst forwarded = forwardRef(renderDeleteConfirmAction);\n\n/**\n * - **EN:** Delete operation confirmation box\n * - **CN:** 删除操作确认框\n */\nconst DeleteConfirmAction = forwarded as unknown as ConfirmActionWithStatic;\n/**\n * - **EN:** Deletion confirmation box with button type\n * - **CN:** 按钮类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\nDeleteConfirmAction.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/**\n * - **EN:** Deletion confirmation box with switch type\n * - **CN:** 开关类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\nDeleteConfirmAction.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/**\n * - **EN:** Deletion confirmation box with link type\n * - **CN:** 链接类型的删除确认框\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\nDeleteConfirmAction.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 default DeleteConfirmAction;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAE3B,kBAA2C;AAE3C,mBAAkC;AAElC,2BAA2D;AAE3D,IAAM,gCAA4B,kCAAY;AAAA,EAC5C,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,MAAM,oCAAC,oCAAkB;AAC3B,CAAC;AACD,IAAM,gBAAY,yBAAW,yBAAyB;AAMtD,IAAM,sBAAsB;AAM5B,oBAAoB,aAAS;AAAA;AAAA,EAE3B;AAAA,EACA;AAAA,IACE,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,cAAc,CAAC;AAAA,EACjB;AACF;AAMA,oBAAoB,aAAS;AAAA;AAAA,EAE3B;AAAA,EACA;AAAA,IACE,kBAAkB;AAAA,IAClB,cAAc;AAAA,IACd,cAAc,CAAC;AAAA,EACjB;AACF;AAMA,oBAAoB,WAAO;AAAA;AAAA,EAEzB;AAAA,EACA;AAAA,IACE,kBAAkB,uBAAW;AAAA,IAC7B,cAAc;AAAA,IACd,cAAc;AAAA,MACZ,OAAO,EAAE,YAAY,SAAS;AAAA,IAChC;AAAA,EACF;AACF;AAEA,IAAO,8BAAQ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import type { ActionCompConstraint, ConfirmActionProps } from '../ConfirmAction';
3
+ import { type ActionComponentInterface } from '../ConfirmAction/withConfirmAction';
4
+ /**
5
+ * - **EN:** Wrap a component into a delete confirmation dialog component, supporting custom triggers
6
+ * and default properties
7
+ * - **CN:** 将一个组件包装成一个删除确认弹框组件,支持自定义触发器和默认属性
8
+ *
9
+ * @param actionComponent Custom trigger component | 自定义触发器组件
10
+ * @param defaultProps Default properties of the deletion confirm box | 删除确认弹框的默认属性
11
+ */
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
+ danger?: boolean | 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
+ onOk?: ((...args: Parameters<TriggerProp[Event]>) => unknown) | undefined;
18
+ afterOk?: ((data?: any) => void) | undefined;
19
+ } & import("react").RefAttributes<import("../ConfirmAction").ConfirmActionRef<Ref>>) => import("react").ReactNode) & import("../ConfirmAction/withConfirmAction").TypedTriggers<P, Ref>;
@@ -0,0 +1,38 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/DeleteConfirmAction/withDeleteConfirmAction.tsx
20
+ var withDeleteConfirmAction_exports = {};
21
+ __export(withDeleteConfirmAction_exports, {
22
+ default: () => withDeleteConfirmAction
23
+ });
24
+ module.exports = __toCommonJS(withDeleteConfirmAction_exports);
25
+ var import_icons = require("@ant-design/icons");
26
+ var import_withConfirmAction = require("../ConfirmAction/withConfirmAction");
27
+ function withDeleteConfirmAction(ActionComponent, defaultProps) {
28
+ return (0, import_withConfirmAction.withConfirmActionInternal)(
29
+ ActionComponent,
30
+ {
31
+ confirmType: "delete",
32
+ danger: true,
33
+ icon: /* @__PURE__ */ React.createElement(import_icons.CloseCircleFilled, null)
34
+ },
35
+ defaultProps
36
+ );
37
+ }
38
+ //# sourceMappingURL=withDeleteConfirmAction.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/DeleteConfirmAction/withDeleteConfirmAction.tsx"],
4
+ "sourcesContent": ["import { CloseCircleFilled } from '@ant-design/icons';\nimport type { ActionCompConstraint, ConfirmActionProps } from '../ConfirmAction';\nimport { type ActionComponentInterface, withConfirmActionInternal } from '../ConfirmAction/withConfirmAction';\n\n/**\n * - **EN:** Wrap a component into a delete confirmation dialog component, supporting custom triggers\n * and default properties\n * - **CN:** 将一个组件包装成一个删除确认弹框组件,支持自定义触发器和默认属性\n *\n * @param actionComponent Custom trigger component | 自定义触发器组件\n * @param defaultProps Default properties of the deletion confirm box | 删除确认弹框的默认属性\n */\nexport default function withDeleteConfirmAction<\n P extends ActionCompConstraint,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n ActionComponent: ActionComponentInterface<P, Ref>,\n defaultProps?:\n | Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>\n | ((\n actualProps: Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>\n ) => Partial<Omit<P, keyof ActionCompConstraint> & ConfirmActionProps<OuterTriggerProp, OuterEvent>>)\n) {\n return withConfirmActionInternal(\n ActionComponent,\n {\n confirmType: 'delete',\n danger: true,\n icon: <CloseCircleFilled />,\n },\n defaultProps\n );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AAElC,+BAAyE;AAU1D,SAAR,wBAML,iBACA,cAKA;AACA,aAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,MAAM,oCAAC,oCAAkB;AAAA,IAC3B;AAAA,IACA;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -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,19 @@ 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);
320
+ const mergedProps = typeof defaultProps === "function" ? mergeProps(props, defaults) : mergeProps(defaults, props);
315
321
  return {
316
322
  formComp,
317
- ...defaults
323
+ ...mergedProps
318
324
  };
319
325
  }
320
326
  );
321
- return addTriggers(withForm);
327
+ return addTriggers(withDefaults);
322
328
  }
323
329
  var ModalAction_default = ModalAction;
324
330
  // Annotate the CommonJS export names for ESM import in node: