@tiny-codes/react-easy 1.1.1 → 1.1.3

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 (129) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/es/components/BreakLines/index.d.ts +13 -19
  3. package/es/components/BreakLines/index.js +2 -3
  4. package/es/components/BreakLines/index.js.map +1 -1
  5. package/es/components/ConfigProvider/context.d.ts +20 -26
  6. package/es/components/ConfigProvider/context.js.map +1 -1
  7. package/es/components/ConfigProvider/index.d.ts +5 -7
  8. package/es/components/ConfigProvider/index.js +2 -3
  9. package/es/components/ConfigProvider/index.js.map +1 -1
  10. package/es/components/ConfirmAction/index.d.ts +58 -89
  11. package/es/components/ConfirmAction/index.js +12 -18
  12. package/es/components/ConfirmAction/index.js.map +1 -1
  13. package/es/components/DeleteConfirmAction/index.d.ts +2 -3
  14. package/es/components/DeleteConfirmAction/index.js +8 -12
  15. package/es/components/DeleteConfirmAction/index.js.map +1 -1
  16. package/es/components/EditableText/form.d.ts +144 -0
  17. package/es/components/EditableText/form.js +309 -0
  18. package/es/components/EditableText/form.js.map +1 -0
  19. package/es/components/EditableText/index.d.ts +138 -0
  20. package/es/components/EditableText/index.js +216 -0
  21. package/es/components/EditableText/index.js.map +1 -0
  22. package/es/components/EditableText/style/index.d.ts +3 -0
  23. package/es/components/EditableText/style/index.js +76 -0
  24. package/es/components/EditableText/style/index.js.map +1 -0
  25. package/es/components/FloatDrawer/index.d.ts +89 -86
  26. package/es/components/FloatDrawer/index.js +43 -20
  27. package/es/components/FloatDrawer/index.js.map +1 -1
  28. package/es/components/FloatDrawer/style/index.js +42 -23
  29. package/es/components/FloatDrawer/style/index.js.map +1 -1
  30. package/es/components/Loading/index.d.ts +66 -0
  31. package/es/components/Loading/index.js +97 -0
  32. package/es/components/Loading/index.js.map +1 -0
  33. package/es/components/Loading/style/index.d.ts +3 -0
  34. package/es/components/Loading/style/index.js +27 -0
  35. package/es/components/Loading/style/index.js.map +1 -0
  36. package/es/components/ModalAction/index.d.ts +98 -139
  37. package/es/components/ModalAction/index.js +25 -37
  38. package/es/components/ModalAction/index.js.map +1 -1
  39. package/es/components/OverflowTags/index.d.ts +30 -8
  40. package/es/components/OverflowTags/index.js +26 -7
  41. package/es/components/OverflowTags/index.js.map +1 -1
  42. package/es/components/OverflowTags/style/index.js +1 -3
  43. package/es/components/OverflowTags/style/index.js.map +1 -1
  44. package/es/components/index.d.ts +4 -0
  45. package/es/components/index.js +2 -0
  46. package/es/components/index.js.map +1 -1
  47. package/es/hooks/useRefFunction.d.ts +4 -5
  48. package/es/hooks/useRefFunction.js +6 -7
  49. package/es/hooks/useRefFunction.js.map +1 -1
  50. package/es/hooks/useRefValue.d.ts +2 -3
  51. package/es/hooks/useRefValue.js +2 -3
  52. package/es/hooks/useRefValue.js.map +1 -1
  53. package/es/hooks/useT.js +1 -2
  54. package/es/hooks/useT.js.map +1 -1
  55. package/es/hooks/useValidator.d.ts +2 -3
  56. package/es/hooks/useValidator.js +2 -3
  57. package/es/hooks/useValidator.js.map +1 -1
  58. package/es/hooks/useValidatorBuilder.d.ts +41 -61
  59. package/es/hooks/useValidatorBuilder.js +4 -6
  60. package/es/hooks/useValidatorBuilder.js.map +1 -1
  61. package/es/hooks/useValidators.d.ts +62 -83
  62. package/es/hooks/useValidators.js +3 -4
  63. package/es/hooks/useValidators.js.map +1 -1
  64. package/es/locales/index.d.ts +15 -0
  65. package/es/locales/langs/en-US.d.ts +5 -0
  66. package/es/locales/langs/en-US.js +5 -0
  67. package/es/locales/langs/en-US.js.map +1 -1
  68. package/es/locales/langs/zh-CN.d.ts +5 -0
  69. package/es/locales/langs/zh-CN.js +5 -0
  70. package/es/locales/langs/zh-CN.js.map +1 -1
  71. package/lib/components/BreakLines/index.d.ts +13 -19
  72. package/lib/components/BreakLines/index.js.map +2 -2
  73. package/lib/components/ConfigProvider/context.d.ts +20 -26
  74. package/lib/components/ConfigProvider/context.js.map +2 -2
  75. package/lib/components/ConfigProvider/index.d.ts +5 -7
  76. package/lib/components/ConfigProvider/index.js.map +2 -2
  77. package/lib/components/ConfirmAction/index.d.ts +58 -89
  78. package/lib/components/ConfirmAction/index.js.map +2 -2
  79. package/lib/components/DeleteConfirmAction/index.d.ts +2 -3
  80. package/lib/components/DeleteConfirmAction/index.js.map +2 -2
  81. package/lib/components/EditableText/form.d.ts +144 -0
  82. package/lib/components/EditableText/form.js +223 -0
  83. package/lib/components/EditableText/form.js.map +7 -0
  84. package/lib/components/EditableText/index.d.ts +138 -0
  85. package/lib/components/EditableText/index.js +174 -0
  86. package/lib/components/EditableText/index.js.map +7 -0
  87. package/lib/components/EditableText/style/index.d.ts +3 -0
  88. package/lib/components/EditableText/style/index.js +118 -0
  89. package/lib/components/EditableText/style/index.js.map +7 -0
  90. package/lib/components/FloatDrawer/index.d.ts +89 -86
  91. package/lib/components/FloatDrawer/index.js +64 -39
  92. package/lib/components/FloatDrawer/index.js.map +2 -2
  93. package/lib/components/FloatDrawer/style/index.js +60 -23
  94. package/lib/components/FloatDrawer/style/index.js.map +2 -2
  95. package/lib/components/Loading/index.d.ts +66 -0
  96. package/lib/components/Loading/index.js +81 -0
  97. package/lib/components/Loading/index.js.map +7 -0
  98. package/lib/components/Loading/style/index.d.ts +3 -0
  99. package/lib/components/Loading/style/index.js +50 -0
  100. package/lib/components/Loading/style/index.js.map +7 -0
  101. package/lib/components/ModalAction/index.d.ts +98 -139
  102. package/lib/components/ModalAction/index.js.map +2 -2
  103. package/lib/components/OverflowTags/index.d.ts +30 -8
  104. package/lib/components/OverflowTags/index.js +7 -5
  105. package/lib/components/OverflowTags/index.js.map +2 -2
  106. package/lib/components/OverflowTags/style/index.js +1 -1
  107. package/lib/components/OverflowTags/style/index.js.map +2 -2
  108. package/lib/components/index.d.ts +4 -0
  109. package/lib/components/index.js +6 -0
  110. package/lib/components/index.js.map +2 -2
  111. package/lib/hooks/useRefFunction.d.ts +4 -5
  112. package/lib/hooks/useRefFunction.js.map +2 -2
  113. package/lib/hooks/useRefValue.d.ts +2 -3
  114. package/lib/hooks/useRefValue.js.map +2 -2
  115. package/lib/hooks/useT.js.map +2 -2
  116. package/lib/hooks/useValidator.d.ts +2 -3
  117. package/lib/hooks/useValidator.js.map +2 -2
  118. package/lib/hooks/useValidatorBuilder.d.ts +41 -61
  119. package/lib/hooks/useValidatorBuilder.js.map +2 -2
  120. package/lib/hooks/useValidators.d.ts +62 -83
  121. package/lib/hooks/useValidators.js.map +2 -2
  122. package/lib/locales/index.d.ts +15 -0
  123. package/lib/locales/langs/en-US.d.ts +5 -0
  124. package/lib/locales/langs/en-US.js +5 -0
  125. package/lib/locales/langs/en-US.js.map +2 -2
  126. package/lib/locales/langs/zh-CN.d.ts +5 -0
  127. package/lib/locales/langs/zh-CN.js +5 -0
  128. package/lib/locales/langs/zh-CN.js.map +2 -2
  129. package/package.json +1 -1
@@ -6,91 +6,76 @@ import type { LinkProps } from 'antd/es/typography/Link';
6
6
  import type { TextProps } from 'antd/es/typography/Text';
7
7
  export type ConfirmActionProps<TP extends object, E extends keyof TP> = Omit<ModalFuncProps, 'onOk'> & ConfirmActionTrigger<TP, E> & {
8
8
  /**
9
- * **EN:** Whether to display in red danger mode, which will automatically affect the color of
10
- * the title, icon, and confirm button. Default is `false`, for DeleteConfirmAction, the
11
- * defaults is `true`.
12
- *
9
+ * - **EN:** Whether to display in red danger mode, which will automatically affect the color of
10
+ * the title, icon, and confirm button. Default is `false`, for DeleteConfirmAction, the
11
+ * defaults is `true`.
13
12
  * - You can explicitly set `titleColor`, `iconColor`, and `okButtonProps.type` to override
14
- *
15
- * **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。
16
- *
13
+ * - **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。
17
14
  * - 可以显式设置`titleColor`、`iconColor`和`okButtonProps.type`来覆盖
18
15
  */
19
16
  danger?: boolean;
20
17
  /**
21
- * **EN:** The color of confirm box title, default is `warning`
22
- *
23
- * **CN:** 弹框标题颜色,默认`warning`
18
+ * - **EN:** The color of confirm box title, default is `warning`
19
+ * - **CN:** 弹框标题颜色,默认`warning`
24
20
  */
25
21
  titleColor?: TextProps['type'] | 'primary';
26
22
  /**
27
- * **EN:** The color of confirm box content
28
- *
29
- * **CN:** 弹框内容文本颜色
23
+ * - **EN:** The color of confirm box content
24
+ * - **CN:** 弹框内容文本颜色
30
25
  */
31
26
  contentColor?: TextProps['type'] | 'primary';
32
27
  /**
33
- * **EN:** The color of confirm box title icon, default is the same as `titleColor`
34
- *
35
- * **CN:** 弹框标题图标颜色,默认与`titleColor`相同
28
+ * - **EN:** The color of confirm box title icon, default is the same as `titleColor`
29
+ * - **CN:** 弹框标题图标颜色,默认与`titleColor`相同
36
30
  */
37
31
  iconColor?: TextProps['type'] | 'primary';
38
32
  /**
39
- * **EN:** Callback when click confirm button
40
- *
41
- * **CN:** 点击确认按钮的回调
33
+ * - **EN:** Callback when click confirm button
34
+ * - **CN:** 点击确认按钮的回调
42
35
  */
43
36
  onOk?: (...args: Parameters<TP[E]>) => unknown | Promise<unknown>;
44
37
  /**
45
- * **EN:** Callback after confirm event, won't trigger if failed, the argument is the return
46
- * value of `onOk`
47
- *
48
- * **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值
38
+ * - **EN:** Callback after confirm event, won't trigger if failed, the argument is the return
39
+ * value of `onOk`
40
+ * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值
49
41
  */
50
42
  afterOk?: (data?: any) => void;
51
43
  };
52
44
  export interface ConfirmActionTrigger<TP extends object, E extends keyof TP> {
53
45
  /**
54
- * **EN:** Trigger component, trigger to show confirm box
55
- *
56
- * **CN:** 触发器组件,触发显示确认弹框
46
+ * - **EN:** Trigger component, trigger to show confirm box
47
+ * - **CN:** 触发器组件,触发显示确认弹框
57
48
  */
58
49
  triggerComponent?: ComponentType<TP>;
59
50
  /**
60
- * **EN:** Props of trigger component
61
- *
62
- * **CN:** 触发器组件的Props属性
51
+ * - **EN:** Props of trigger component
52
+ * - **CN:** 触发器组件的Props属性
63
53
  */
64
54
  triggerProps?: TP;
65
55
  /**
66
- * **EN:** The event name that triggers the dialog
67
- *
68
- * **CN:** 触发弹窗的事件名称
69
- *
56
+ * - **EN:** The event name that triggers the dialog
57
+ * - **CN:** 触发弹窗的事件名称
70
58
  * - `Button`: 'onClick'
71
59
  * - `Switch`: 'onChange'
72
60
  * - `Link`: 'onClick'
73
61
  */
74
62
  triggerEvent?: E;
75
63
  /**
76
- * **EN:** Custom trigger content
77
- *
78
- * **CN:** 自定义触发器内容
64
+ * - **EN:** Custom trigger content
65
+ * - **CN:** 自定义触发器内容
79
66
  */
80
67
  children?: ReactNode;
81
68
  }
82
69
  export type ConfirmActionRef = ReturnType<typeof confirm> & {
83
70
  /**
84
- * **EN:** Show confirm box
85
- *
86
- * **CN:** 显示确认弹框
71
+ * - **EN:** Show confirm box
72
+ * - **CN:** 显示确认弹框
87
73
  */
88
74
  show: (props?: Parameters<ModalFunc>[0]) => ReturnType<ModalFunc>;
89
75
  };
90
76
  /**
91
- * **EN:** Generate a confirm box component
92
- *
93
- * **CN:** 生成一个确认弹框组件
77
+ * - **EN:** Generate a confirm box component
78
+ * - **CN:** 生成一个确认弹框组件
94
79
  *
95
80
  * @param defaultProps Default props | 默认属性
96
81
  *
@@ -103,100 +88,84 @@ export declare const genRenderer: (defaultProps: Partial<ConfirmActionProps<any,
103
88
  displayName: string;
104
89
  };
105
90
  /**
106
- * **EN:** Add default properties to the ConfirmAction component
107
- *
108
- * **CN:** 给ConfirmAction组件添加默认属性
91
+ * - **EN:** Add default properties to the ConfirmAction component
92
+ * - **CN:** 给ConfirmAction组件添加默认属性
109
93
  *
110
94
  * @param WrappedComponent ConfirmAction component | ConfirmAction组件
111
95
  * @param defaultProps Default properties | 默认属性
112
96
  */
113
97
  export declare const withDefaultConfirmActionProps: <TP extends object, E extends keyof TP>(WrappedComponent: ComponentType<PropsWithoutRef<ConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>>, defaultProps?: Partial<ConfirmActionProps<TP, E>>) => import("react").ForwardRefExoticComponent<Omit<ModalFuncProps, "onOk"> & ConfirmActionTrigger<TP, E> & {
114
98
  /**
115
- * **EN:** Whether to display in red danger mode, which will automatically affect the color of
116
- * the title, icon, and confirm button. Default is `false`, for DeleteConfirmAction, the
117
- * defaults is `true`.
118
- *
99
+ * - **EN:** Whether to display in red danger mode, which will automatically affect the color of
100
+ * the title, icon, and confirm button. Default is `false`, for DeleteConfirmAction, the
101
+ * defaults is `true`.
119
102
  * - You can explicitly set `titleColor`, `iconColor`, and `okButtonProps.type` to override
120
- *
121
- * **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。
122
- *
103
+ * - **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。
123
104
  * - 可以显式设置`titleColor`、`iconColor`和`okButtonProps.type`来覆盖
124
105
  */
125
106
  danger?: boolean | undefined;
126
107
  /**
127
- * **EN:** The color of confirm box title, default is `warning`
128
- *
129
- * **CN:** 弹框标题颜色,默认`warning`
108
+ * - **EN:** The color of confirm box title, default is `warning`
109
+ * - **CN:** 弹框标题颜色,默认`warning`
130
110
  */
131
111
  titleColor?: TextProps['type'] | 'primary';
132
112
  /**
133
- * **EN:** The color of confirm box content
134
- *
135
- * **CN:** 弹框内容文本颜色
113
+ * - **EN:** The color of confirm box content
114
+ * - **CN:** 弹框内容文本颜色
136
115
  */
137
116
  contentColor?: TextProps['type'] | 'primary';
138
117
  /**
139
- * **EN:** The color of confirm box title icon, default is the same as `titleColor`
140
- *
141
- * **CN:** 弹框标题图标颜色,默认与`titleColor`相同
118
+ * - **EN:** The color of confirm box title icon, default is the same as `titleColor`
119
+ * - **CN:** 弹框标题图标颜色,默认与`titleColor`相同
142
120
  */
143
121
  iconColor?: TextProps['type'] | 'primary';
144
122
  /**
145
- * **EN:** Callback when click confirm button
146
- *
147
- * **CN:** 点击确认按钮的回调
123
+ * - **EN:** Callback when click confirm button
124
+ * - **CN:** 点击确认按钮的回调
148
125
  */
149
126
  onOk?: ((...args: Parameters<TP[E]>) => unknown | Promise<unknown>) | undefined;
150
127
  /**
151
- * **EN:** Callback after confirm event, won't trigger if failed, the argument is the return
152
- * value of `onOk`
153
- *
154
- * **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值
128
+ * - **EN:** Callback after confirm event, won't trigger if failed, the argument is the return
129
+ * value of `onOk`
130
+ * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值
155
131
  */
156
132
  afterOk?: ((data?: any) => void) | undefined;
157
133
  } & RefAttributes<ConfirmActionRef>>;
158
134
  /**
159
- * **EN:** Interface of generic type component
160
- *
161
- * **CN:** 泛型组件的接口
135
+ * - **EN:** Interface of generic type component
136
+ * - **CN:** 泛型组件的接口
162
137
  */
163
138
  export type GenericConfirmActionInterface = <TP extends object, E extends keyof TP>(props: PropsWithoutRef<TypedConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>) => ReactElement;
164
139
  /**
165
- * **EN:** Interface of specific type component
166
- *
167
- * **CN:** 具体类型组件的接口
140
+ * - **EN:** Interface of specific type component
141
+ * - **CN:** 具体类型组件的接口
168
142
  */
169
143
  export type TypedConfirmActionInterface<TP extends object, E extends keyof TP> = ComponentType<PropsWithoutRef<TypedConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>>;
170
144
  /**
171
- * **EN:** Props definition of specific type component
172
- *
173
- * **CN:** 具体类型组件的Props定义
145
+ * - **EN:** Props definition of specific type component
146
+ * - **CN:** 具体类型组件的Props定义
174
147
  */
175
148
  type TypedConfirmActionProps<TP extends object, E extends keyof TP> = Omit<ConfirmActionProps<TP, E>, 'triggerComponent' | 'triggerEvent'>;
176
149
  export type ConfirmActionWithStatic = GenericConfirmActionInterface & {
177
150
  /**
178
- * **EN:** Confirm box with button trigger
179
- *
180
- * **CN:** 按钮类型的确认框
151
+ * - **EN:** Confirm box with button trigger
152
+ * - **CN:** 按钮类型的确认框
181
153
  */
182
154
  Button: TypedConfirmActionInterface<ButtonProps, 'onClick'>;
183
155
  /**
184
- * **EN:** Confirm box with switch trigger
185
- *
186
- * **CN:** 开关类型的确认框
156
+ * - **EN:** Confirm box with switch trigger
157
+ * - **CN:** 开关类型的确认框
187
158
  */
188
159
  Switch: TypedConfirmActionInterface<SwitchProps, 'onChange'>;
189
160
  /**
190
- * **EN:** Confirm box with link trigger
191
- *
192
- * **CN:** 链接类型的确认框
161
+ * - **EN:** Confirm box with link trigger
162
+ * - **CN:** 链接类型的确认框
193
163
  */
194
164
  Link: TypedConfirmActionInterface<LinkProps, 'onClick'>;
195
165
  };
196
166
  /**
197
- * **EN:** Confirm box component with trigger
198
- *
199
- * **CN:** 带触发器的确认框组件
167
+ * - **EN:** Confirm box component with trigger
168
+ * - **CN:** 带触发器的确认框组件
200
169
  */
201
170
  declare const ConfirmAction: ConfirmActionWithStatic;
202
171
  export default ConfirmAction;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/ConfirmAction/index.tsx"],
4
- "sourcesContent": ["import type { ComponentType, ForwardedRef, PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useContext, useImperativeHandle, useRef, useState } from 'react';\nimport type { ButtonProps, ModalFuncProps, SwitchProps } from 'antd';\nimport { App, Button, Modal, Switch, Typography } from 'antd';\nimport type { ModalFunc } from 'antd/es/modal/confirm';\nimport type confirm from 'antd/es/modal/confirm';\nimport useToken from 'antd/es/theme/useToken';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport useContextValidator from '../../hooks/useContextValidator';\nimport useLocalizedText from '../../hooks/useLocalizedText';\nimport useRefFunction from '../../hooks/useRefFunction';\nimport ReactEasyContext from '../ConfigProvider/context';\n\nexport type ConfirmActionProps<TP extends object, E extends keyof TP> = Omit<ModalFuncProps, 'onOk'> &\n ConfirmActionTrigger<TP, E> & {\n /**\n * **EN:** Whether to display in red danger mode, which will automatically affect the color of\n * the title, icon, and confirm button. Default is `false`, for DeleteConfirmAction, the\n * defaults is `true`.\n *\n * - You can explicitly set `titleColor`, `iconColor`, and `okButtonProps.type` to override\n *\n * **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。\n *\n * - 可以显式设置`titleColor`、`iconColor`和`okButtonProps.type`来覆盖\n */\n danger?: boolean;\n /**\n * **EN:** The color of confirm box title, default is `warning`\n *\n * **CN:** 弹框标题颜色,默认`warning`\n */\n titleColor?: TextProps['type'] | 'primary';\n /**\n * **EN:** The color of confirm box content\n *\n * **CN:** 弹框内容文本颜色\n */\n contentColor?: TextProps['type'] | 'primary';\n /**\n * **EN:** The color of confirm box title icon, default is the same as `titleColor`\n *\n * **CN:** 弹框标题图标颜色,默认与`titleColor`相同\n */\n iconColor?: TextProps['type'] | 'primary';\n /**\n * **EN:** Callback when click confirm button\n *\n * **CN:** 点击确认按钮的回调\n */\n // @ts-expect-error: because TP[E] should be casted to function type\n onOk?: (...args: Parameters<TP[E]>) => unknown | Promise<unknown>;\n /**\n * **EN:** Callback after confirm event, won't trigger if failed, the argument is the return\n * value of `onOk`\n *\n * **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface ConfirmActionTrigger<TP extends object, E extends keyof TP> {\n /**\n * **EN:** Trigger component, trigger to show confirm box\n *\n * **CN:** 触发器组件,触发显示确认弹框\n */\n triggerComponent?: ComponentType<TP>;\n /**\n * **EN:** Props of trigger component\n *\n * **CN:** 触发器组件的Props属性\n */\n triggerProps?: TP;\n /**\n * **EN:** The event name that triggers the dialog\n *\n * **CN:** 触发弹窗的事件名称\n *\n * - `Button`: 'onClick'\n * - `Switch`: 'onChange'\n * - `Link`: 'onClick'\n */\n triggerEvent?: E;\n /**\n * **EN:** Custom trigger content\n *\n * **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\nexport type ConfirmActionRef = ReturnType<typeof confirm> & {\n /**\n * **EN:** Show confirm box\n *\n * **CN:** 显示确认弹框\n */\n show: (props?: Parameters<ModalFunc>[0]) => ReturnType<ModalFunc>;\n};\n\n/**\n * **EN:** Generate a confirm box component\n *\n * **CN:** 生成一个确认弹框组件\n *\n * @param defaultProps Default props | 默认属性\n *\n * @returns Component render method | 组件render方法\n */\nexport const genRenderer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n defaultProps: Partial<ConfirmActionProps<any, never>> & { confirmType: 'normal' | 'delete' }\n) => {\n const Render = <TP extends object, E extends keyof TP>(\n props: ConfirmActionProps<TP, E>,\n ref: ForwardedRef<ConfirmActionRef>\n ) => {\n const { confirmType, ...restDefaults } = defaultProps;\n const mergedProps: ConfirmActionProps<TP, E> = {\n ...restDefaults,\n ...props,\n okButtonProps: {\n ...restDefaults.okButtonProps,\n ...props.okButtonProps,\n },\n cancelButtonProps: {\n ...restDefaults.cancelButtonProps,\n ...props.cancelButtonProps,\n },\n bodyProps: {\n ...restDefaults.bodyProps,\n ...props.bodyProps,\n },\n maskProps: {\n ...restDefaults.maskProps,\n ...props.maskProps,\n },\n wrapProps: {\n ...restDefaults.wrapProps,\n ...props.wrapProps,\n },\n triggerProps: {\n ...restDefaults.triggerProps,\n ...props.triggerProps,\n style: {\n ...restDefaults.triggerProps?.style,\n ...(props.triggerProps && 'style' in props.triggerProps && typeof props.triggerProps.style === 'object'\n ? props.triggerProps.style\n : {}),\n },\n } as TP,\n };\n const context = useContext(ReactEasyContext);\n const defaultTitle = useLocalizedText(\n confirmType === 'delete' ? context.defaultDeletionConfirmTitle : context.defaultConfirmTitle\n );\n const defaultContent = useLocalizedText(\n confirmType === 'delete' ? context.defaultDeletionConfirmContent : context.defaultConfirmContent\n );\n const {\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as E,\n triggerProps,\n danger,\n title = defaultTitle,\n content = defaultContent,\n titleColor,\n contentColor,\n icon,\n iconColor,\n okButtonProps,\n cancelButtonProps,\n onOk,\n afterOk,\n children,\n ...restProps\n } = mergedProps;\n\n useContextValidator();\n\n const app = App.useApp();\n // @ts-expect-error: because app may return a stub object when App is not used\n const modal = app.modal?.confirm ? app.modal : Modal;\n const { localize } = useContext(ReactEasyContext);\n const [, token] = useToken();\n const [confirmApi, setConfirmApi] = useState<ReturnType<typeof confirm>>();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n\n const fallbackColor = danger ? 'danger' : undefined;\n // Text with color\n const coloredText = (text: ReactNode, color?: TextProps['type'] | 'primary') => {\n const textContent = typeof text === 'string' ? (localize?.(text) ?? text) : text;\n if (!color) {\n return textContent;\n }\n if (color === 'primary') {\n return <Typography.Text style={{ color: token.colorPrimary }}>{textContent}</Typography.Text>;\n }\n return textContent ? <Typography.Text type={color}>{textContent}</Typography.Text> : undefined;\n };\n\n // Show confirm box\n const showConfirm: ConfirmActionRef['show'] = useRefFunction(() => {\n const okProps: ButtonProps = {\n ...(danger ? { type: 'primary', danger: true } : {}),\n ...(okButtonProps ?? {}),\n };\n const cancelProps: ButtonProps = {\n ...(cancelButtonProps ?? {}),\n };\n const api = modal.confirm({\n title: coloredText(title, titleColor ?? fallbackColor ?? 'warning'),\n content: coloredText(content, contentColor),\n icon: coloredText(icon, iconColor ?? fallbackColor ?? 'warning'),\n autoFocusButton: null,\n okButtonProps: okProps,\n cancelButtonProps: cancelProps,\n onOk: async () => {\n try {\n api.update({\n closable: true,\n okButtonProps: {\n loading: true,\n ...okProps,\n },\n cancelButtonProps: {\n disabled: true,\n ...cancelProps,\n },\n });\n const result = await onOk?.(...((triggerEventArgsRef.current ?? []) as Parameters<typeof onOk>));\n afterOk?.(result);\n } finally {\n api.update({\n closable: false,\n okButtonProps: {\n loading: false,\n ...okProps,\n },\n cancelButtonProps: {\n disabled: false,\n ...cancelProps,\n },\n });\n }\n },\n ...restProps,\n });\n setConfirmApi(api);\n return api;\n });\n\n // Output ref\n useImperativeHandle(ref, () => ({ show: showConfirm, ...confirmApi! }), [showConfirm, confirmApi]);\n\n // Render trigger component\n return (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n const api = showConfirm();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args, { api });\n }\n },\n }\n : {}) as TP)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n );\n };\n Render.displayName = 'ConfirmAction';\n return Render;\n};\n\n/**\n * **EN:** Add default properties to the ConfirmAction component\n *\n * **CN:** 给ConfirmAction组件添加默认属性\n *\n * @param WrappedComponent ConfirmAction component | ConfirmAction组件\n * @param defaultProps Default properties | 默认属性\n */\nexport const withDefaultConfirmActionProps = <TP extends object, E extends keyof TP>(\n WrappedComponent: ComponentType<PropsWithoutRef<ConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>>,\n defaultProps?: Partial<ConfirmActionProps<TP, E>>\n) => {\n const WithDefaultProps = forwardRef<ConfirmActionRef, ConfirmActionProps<TP, E>>((props, ref) => {\n const mergedProps: ConfirmActionProps<TP, E> = {\n ...defaultProps,\n ...props,\n triggerProps: {\n ...defaultProps?.triggerProps,\n ...props.triggerProps,\n } as TP,\n };\n return <WrappedComponent ref={ref} {...mergedProps} />;\n });\n WithDefaultProps.displayName = 'ForwardedRef(WithDefaultProps)';\n return WithDefaultProps;\n};\n\nconst renderConfirmAction = genRenderer({\n confirmType: 'normal',\n});\nconst forwarded = forwardRef(renderConfirmAction);\nforwarded.displayName = 'ForwardedRef(ConfirmAction)';\n\n/**\n * **EN:** Interface of generic type component\n *\n * **CN:** 泛型组件的接口\n */\nexport type GenericConfirmActionInterface = <TP extends object, E extends keyof TP>(\n props: PropsWithoutRef<TypedConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>\n) => ReactElement;\n\n/**\n * **EN:** Interface of specific type component\n *\n * **CN:** 具体类型组件的接口\n */\nexport type TypedConfirmActionInterface<TP extends object, E extends keyof TP> = ComponentType<\n PropsWithoutRef<TypedConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>\n>;\n\n/**\n * **EN:** Props definition of specific type component\n *\n * **CN:** 具体类型组件的Props定义\n */\ntype TypedConfirmActionProps<TP extends object, E extends keyof TP> = Omit<\n ConfirmActionProps<TP, E>,\n 'triggerComponent' | 'triggerEvent'\n>;\nexport type ConfirmActionWithStatic = GenericConfirmActionInterface & {\n /**\n * **EN:** Confirm box with button trigger\n *\n * **CN:** 按钮类型的确认框\n */\n Button: TypedConfirmActionInterface<ButtonProps, 'onClick'>;\n /**\n * **EN:** Confirm box with switch trigger\n *\n * **CN:** 开关类型的确认框\n */\n Switch: TypedConfirmActionInterface<SwitchProps, 'onChange'>;\n /**\n * **EN:** Confirm box with link trigger\n *\n * **CN:** 链接类型的确认框\n */\n Link: TypedConfirmActionInterface<LinkProps, 'onClick'>;\n};\n\n/**\n * **EN:** Confirm box component with trigger\n *\n * **CN:** 带触发器的确认框组件\n */\nconst ConfirmAction = forwarded as unknown as ConfirmActionWithStatic;\n// Type of button\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.Button = withDefaultConfirmActionProps<ButtonProps, 'onClick'>(forwarded as any, {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n});\n// Type of switch\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.Switch = withDefaultConfirmActionProps<SwitchProps, 'onChange'>(forwarded as any, {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n});\n// Type of link\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.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 ConfirmAction;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA8E;AAE9E,kBAAuD;AAGvD,sBAAqB;AAGrB,iCAAgC;AAChC,8BAA6B;AAC7B,4BAA2B;AAC3B,qBAA6B;AAmGtB,IAAM,cAAc,CAEzB,iBACG;AACH,QAAM,SAAS,CACb,OACA,QACG;AAtHP;AAuHI,UAAM,EAAE,aAAa,GAAG,aAAa,IAAI;AACzC,UAAM,cAAyC;AAAA,MAC7C,GAAG;AAAA,MACH,GAAG;AAAA,MACH,eAAe;AAAA,QACb,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,mBAAmB;AAAA,QACjB,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,cAAc;AAAA,QACZ,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,QACT,OAAO;AAAA,UACL,IAAG,kBAAa,iBAAb,mBAA2B;AAAA,UAC9B,GAAI,MAAM,gBAAgB,WAAW,MAAM,gBAAgB,OAAO,MAAM,aAAa,UAAU,WAC3F,MAAM,aAAa,QACnB,CAAC;AAAA,QACP;AAAA,MACF;AAAA,IACF;AACA,UAA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O,aAAa,YAAY,MAAM,YAAY;AACpE,cAAC,aAAa,YAAY,EAA+B,GAAG,MAAM,EAAE,IAAI,CAAC;AAAA,YAC3E;AAAA,UACF;AAAA,QACF,IACA,CAAC;AAAA;AAAA,MAEH,aAA0C,YAAY;AAAA,IAC1D;AAAA,EAEJ;AACA,SAAO,cAAc;AACrB,SAAO;AACT;AAUO,IAAM,gCAAgC,CAC3C,kBACA,iBACG;AACH,QAAM,uBAAmB,yBAAwD,CAAC,OAAO,QAAQ;AAC/F,UAAM,cAAyC;AAAA,MAC7C,GAAG;AAAA,MACH,GAAG;AAAA,MACH,cAAc;AAAA,QACZ,GAAG,6CAAc;AAAA,QACjB,GAAG,MAAM;AAAA,MACX;AAAA,IACF;AACA,WAAO,oCAAC,oBAAiB,KAAW,GAAG,aAAa;AAAA,EACtD,CAAC;AACD,mBAAiB,cAAc;AAC/B,SAAO;AACT;AAEA,IAAM,sBAAsB,YAAY;AAAA,EACtC,aAAa;AACf,CAAC;AACD,IAAM,gBAAY,yBAAW,mBAAmB;AAChD,UAAU,cAAc;AAuDxB,IAAM,gBAAgB;AAGtB,cAAc,SAAS,8BAAsD,WAAkB;AAAA,EAC7F,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,cAAc,CAAC;AACjB,CAAC;AAGD,cAAc,SAAS,8BAAuD,WAAkB;AAAA,EAC9F,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,cAAc,CAAC;AACjB,CAAC;AAGD,cAAc,OAAO,8BAAoD,WAAkB;AAAA,EACzF,kBAAkB,uBAAW;AAAA,EAC7B,cAAc;AAAA,EACd,cAAc;AAAA,IACZ,OAAO,EAAE,YAAY,SAAS;AAAA,EAChC;AACF,CAAC;AAED,IAAO,wBAAQ;",
4
+ "sourcesContent": ["import type { ComponentType, ForwardedRef, PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useContext, useImperativeHandle, useRef, useState } from 'react';\nimport type { ButtonProps, ModalFuncProps, SwitchProps } from 'antd';\nimport { App, Button, Modal, Switch, Typography } from 'antd';\nimport type { ModalFunc } from 'antd/es/modal/confirm';\nimport type confirm from 'antd/es/modal/confirm';\nimport useToken from 'antd/es/theme/useToken';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport useContextValidator from '../../hooks/useContextValidator';\nimport useLocalizedText from '../../hooks/useLocalizedText';\nimport useRefFunction from '../../hooks/useRefFunction';\nimport ReactEasyContext from '../ConfigProvider/context';\n\nexport type ConfirmActionProps<TP extends object, E extends keyof TP> = Omit<ModalFuncProps, 'onOk'> &\n ConfirmActionTrigger<TP, E> & {\n /**\n * - **EN:** Whether to display in red danger mode, which will automatically affect the color of\n * the title, icon, and confirm button. Default is `false`, for DeleteConfirmAction, the\n * defaults is `true`.\n * - You can explicitly set `titleColor`, `iconColor`, and `okButtonProps.type` to override\n * - **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。\n * - 可以显式设置`titleColor`、`iconColor`和`okButtonProps.type`来覆盖\n */\n danger?: boolean;\n /**\n * - **EN:** The color of confirm box title, default is `warning`\n * - **CN:** 弹框标题颜色,默认`warning`\n */\n titleColor?: TextProps['type'] | 'primary';\n /**\n * - **EN:** The color of confirm box content\n * - **CN:** 弹框内容文本颜色\n */\n contentColor?: TextProps['type'] | 'primary';\n /**\n * - **EN:** The color of confirm box title icon, default is the same as `titleColor`\n * - **CN:** 弹框标题图标颜色,默认与`titleColor`相同\n */\n iconColor?: TextProps['type'] | 'primary';\n /**\n * - **EN:** Callback when click confirm button\n * - **CN:** 点击确认按钮的回调\n */\n // @ts-expect-error: because TP[E] should be casted to function type\n onOk?: (...args: Parameters<TP[E]>) => unknown | Promise<unknown>;\n /**\n * - **EN:** Callback after confirm event, won't trigger if failed, the argument is the return\n * value of `onOk`\n * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface ConfirmActionTrigger<TP extends object, E extends keyof TP> {\n /**\n * - **EN:** Trigger component, trigger to show confirm box\n * - **CN:** 触发器组件,触发显示确认弹框\n */\n triggerComponent?: ComponentType<TP>;\n /**\n * - **EN:** Props of trigger component\n * - **CN:** 触发器组件的Props属性\n */\n triggerProps?: TP;\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 ConfirmActionRef = ReturnType<typeof confirm> & {\n /**\n * - **EN:** Show confirm box\n * - **CN:** 显示确认弹框\n */\n show: (props?: Parameters<ModalFunc>[0]) => ReturnType<ModalFunc>;\n};\n\n/**\n * - **EN:** Generate a confirm box component\n * - **CN:** 生成一个确认弹框组件\n *\n * @param defaultProps Default props | 默认属性\n *\n * @returns Component render method | 组件render方法\n */\nexport const genRenderer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n defaultProps: Partial<ConfirmActionProps<any, never>> & { confirmType: 'normal' | 'delete' }\n) => {\n const Render = <TP extends object, E extends keyof TP>(\n props: ConfirmActionProps<TP, E>,\n ref: ForwardedRef<ConfirmActionRef>\n ) => {\n const { confirmType, ...restDefaults } = defaultProps;\n const mergedProps: ConfirmActionProps<TP, E> = {\n ...restDefaults,\n ...props,\n okButtonProps: {\n ...restDefaults.okButtonProps,\n ...props.okButtonProps,\n },\n cancelButtonProps: {\n ...restDefaults.cancelButtonProps,\n ...props.cancelButtonProps,\n },\n bodyProps: {\n ...restDefaults.bodyProps,\n ...props.bodyProps,\n },\n maskProps: {\n ...restDefaults.maskProps,\n ...props.maskProps,\n },\n wrapProps: {\n ...restDefaults.wrapProps,\n ...props.wrapProps,\n },\n triggerProps: {\n ...restDefaults.triggerProps,\n ...props.triggerProps,\n style: {\n ...restDefaults.triggerProps?.style,\n ...(props.triggerProps && 'style' in props.triggerProps && typeof props.triggerProps.style === 'object'\n ? props.triggerProps.style\n : {}),\n },\n } as TP,\n };\n const context = useContext(ReactEasyContext);\n const defaultTitle = useLocalizedText(\n confirmType === 'delete' ? context.defaultDeletionConfirmTitle : context.defaultConfirmTitle\n );\n const defaultContent = useLocalizedText(\n confirmType === 'delete' ? context.defaultDeletionConfirmContent : context.defaultConfirmContent\n );\n const {\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as E,\n triggerProps,\n danger,\n title = defaultTitle,\n content = defaultContent,\n titleColor,\n contentColor,\n icon,\n iconColor,\n okButtonProps,\n cancelButtonProps,\n onOk,\n afterOk,\n children,\n ...restProps\n } = mergedProps;\n\n useContextValidator();\n\n const app = App.useApp();\n // @ts-expect-error: because app may return a stub object when App is not used\n const modal = app.modal?.confirm ? app.modal : Modal;\n const { localize } = useContext(ReactEasyContext);\n const [, token] = useToken();\n const [confirmApi, setConfirmApi] = useState<ReturnType<typeof confirm>>();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n\n const fallbackColor = danger ? 'danger' : undefined;\n // Text with color\n const coloredText = (text: ReactNode, color?: TextProps['type'] | 'primary') => {\n const textContent = typeof text === 'string' ? (localize?.(text) ?? text) : text;\n if (!color) {\n return textContent;\n }\n if (color === 'primary') {\n return <Typography.Text style={{ color: token.colorPrimary }}>{textContent}</Typography.Text>;\n }\n return textContent ? <Typography.Text type={color}>{textContent}</Typography.Text> : undefined;\n };\n\n // Show confirm box\n const showConfirm: ConfirmActionRef['show'] = useRefFunction(() => {\n const okProps: ButtonProps = {\n ...(danger ? { type: 'primary', danger: true } : {}),\n ...(okButtonProps ?? {}),\n };\n const cancelProps: ButtonProps = {\n ...(cancelButtonProps ?? {}),\n };\n const api = modal.confirm({\n title: coloredText(title, titleColor ?? fallbackColor ?? 'warning'),\n content: coloredText(content, contentColor),\n icon: coloredText(icon, iconColor ?? fallbackColor ?? 'warning'),\n autoFocusButton: null,\n okButtonProps: okProps,\n cancelButtonProps: cancelProps,\n onOk: async () => {\n try {\n api.update({\n closable: true,\n okButtonProps: {\n loading: true,\n ...okProps,\n },\n cancelButtonProps: {\n disabled: true,\n ...cancelProps,\n },\n });\n const result = await onOk?.(...((triggerEventArgsRef.current ?? []) as Parameters<typeof onOk>));\n afterOk?.(result);\n } finally {\n api.update({\n closable: false,\n okButtonProps: {\n loading: false,\n ...okProps,\n },\n cancelButtonProps: {\n disabled: false,\n ...cancelProps,\n },\n });\n }\n },\n ...restProps,\n });\n setConfirmApi(api);\n return api;\n });\n\n // Output ref\n useImperativeHandle(ref, () => ({ show: showConfirm, ...confirmApi! }), [showConfirm, confirmApi]);\n\n // Render trigger component\n return (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n const api = showConfirm();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args, { api });\n }\n },\n }\n : {}) as TP)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n );\n };\n Render.displayName = 'ConfirmAction';\n return Render;\n};\n\n/**\n * - **EN:** Add default properties to the ConfirmAction component\n * - **CN:** 给ConfirmAction组件添加默认属性\n *\n * @param WrappedComponent ConfirmAction component | ConfirmAction组件\n * @param defaultProps Default properties | 默认属性\n */\nexport const withDefaultConfirmActionProps = <TP extends object, E extends keyof TP>(\n WrappedComponent: ComponentType<PropsWithoutRef<ConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>>,\n defaultProps?: Partial<ConfirmActionProps<TP, E>>\n) => {\n const WithDefaultProps = forwardRef<ConfirmActionRef, ConfirmActionProps<TP, E>>((props, ref) => {\n const mergedProps: ConfirmActionProps<TP, E> = {\n ...defaultProps,\n ...props,\n triggerProps: {\n ...defaultProps?.triggerProps,\n ...props.triggerProps,\n } as TP,\n };\n return <WrappedComponent ref={ref} {...mergedProps} />;\n });\n WithDefaultProps.displayName = 'ForwardedRef(WithDefaultProps)';\n return WithDefaultProps;\n};\n\nconst renderConfirmAction = genRenderer({\n confirmType: 'normal',\n});\nconst forwarded = forwardRef(renderConfirmAction);\nforwarded.displayName = 'ForwardedRef(ConfirmAction)';\n\n/**\n * - **EN:** Interface of generic type component\n * - **CN:** 泛型组件的接口\n */\nexport type GenericConfirmActionInterface = <TP extends object, E extends keyof TP>(\n props: PropsWithoutRef<TypedConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>\n) => ReactElement;\n\n/**\n * - **EN:** Interface of specific type component\n * - **CN:** 具体类型组件的接口\n */\nexport type TypedConfirmActionInterface<TP extends object, E extends keyof TP> = ComponentType<\n PropsWithoutRef<TypedConfirmActionProps<TP, E>> & RefAttributes<ConfirmActionRef>\n>;\n\n/**\n * - **EN:** Props definition of specific type component\n * - **CN:** 具体类型组件的Props定义\n */\ntype TypedConfirmActionProps<TP extends object, E extends keyof TP> = Omit<\n ConfirmActionProps<TP, E>,\n 'triggerComponent' | 'triggerEvent'\n>;\nexport type ConfirmActionWithStatic = GenericConfirmActionInterface & {\n /**\n * - **EN:** Confirm box with button trigger\n * - **CN:** 按钮类型的确认框\n */\n Button: TypedConfirmActionInterface<ButtonProps, 'onClick'>;\n /**\n * - **EN:** Confirm box with switch trigger\n * - **CN:** 开关类型的确认框\n */\n Switch: TypedConfirmActionInterface<SwitchProps, 'onChange'>;\n /**\n * - **EN:** Confirm box with link trigger\n * - **CN:** 链接类型的确认框\n */\n Link: TypedConfirmActionInterface<LinkProps, 'onClick'>;\n};\n\n/**\n * - **EN:** Confirm box component with trigger\n * - **CN:** 带触发器的确认框组件\n */\nconst ConfirmAction = forwarded as unknown as ConfirmActionWithStatic;\n// Type of button\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.Button = withDefaultConfirmActionProps<ButtonProps, 'onClick'>(forwarded as any, {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n});\n// Type of switch\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.Switch = withDefaultConfirmActionProps<SwitchProps, 'onChange'>(forwarded as any, {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n});\n// Type of link\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nConfirmAction.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 ConfirmAction;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA8E;AAE9E,kBAAuD;AAGvD,sBAAqB;AAGrB,iCAAgC;AAChC,8BAA6B;AAC7B,4BAA2B;AAC3B,qBAA6B;AAoFtB,IAAM,cAAc,CAEzB,iBACG;AACH,QAAM,SAAS,CACb,OACA,QACG;AAvGP;AAwGI,UAAM,EAAE,aAAa,GAAG,aAAa,IAAI;AACzC,UAAM,cAAyC;AAAA,MAC7C,GAAG;AAAA,MACH,GAAG;AAAA,MACH,eAAe;AAAA,QACb,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,mBAAmB;AAAA,QACjB,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,WAAW;AAAA,QACT,GAAG,aAAa;AAAA,QAChB,GAAG,MAAM;AAAA,MACX;AAAA,MACA,cAAc;AAAA,QACZ,GAAG,aAAa;AAAA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IACZ,OAAO,EAAE,YAAY,SAAS;AAAA,EAChC;AACF,CAAC;AAED,IAAO,wBAAQ;",
6
6
  "names": ["ReactEasyContext", "useLocalizedText", "useContextValidator", "useToken", "useRefFunction"]
7
7
  }
@@ -1,8 +1,7 @@
1
1
  import { type ConfirmActionWithStatic } from '../ConfirmAction';
2
2
  /**
3
- * **EN:** Delete operation confirmation box
4
- *
5
- * **CN:** 删除操作确认框
3
+ * - **EN:** Delete operation confirmation box
4
+ * - **CN:** 删除操作确认框
6
5
  */
7
6
  declare const DeleteConfirmAction: ConfirmActionWithStatic;
8
7
  export default DeleteConfirmAction;
@@ -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 *\n * **CN:** 删除操作确认框\n */\nconst DeleteConfirmAction = forwarded as unknown as ConfirmActionWithStatic;\n/**\n * **EN:** Deletion confirmation box with button type\n *\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 *\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 *\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;AAOtD,IAAM,sBAAsB;AAO5B,oBAAoB,aAAS,oDAAsD,WAAkB;AAAA,EACnG,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,cAAc,CAAC;AACjB,CAAC;AAOD,oBAAoB,aAAS,oDAAuD,WAAkB;AAAA,EACpG,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,cAAc,CAAC;AACjB,CAAC;AAOD,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 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;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,144 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { ButtonProps, FormItemProps, FormProps, InputProps, SpaceProps } from 'antd';
3
+ import type { TextAreaProps } from 'antd/es/input';
4
+ export interface EditableFormProps<IT extends 'Input' | 'TextArea'> {
5
+ prefixCls?: string;
6
+ /**
7
+ * - **EN:** The value to edit
8
+ * - **CN:** 编辑的值
9
+ */
10
+ value: string | undefined;
11
+ /**
12
+ * - **EN:** Whether the text is required when editing, default is `true`, if `formItemProps.rules`
13
+ * is set, it will override this value
14
+ * - **CN:** 编辑文本时是否必填,默认值为`true`,如果设置了`formItemProps.rules`,将会覆盖此值
15
+ *
16
+ * @default true
17
+ */
18
+ required?: boolean;
19
+ /**
20
+ * - **EN:** Form properties
21
+ * - **CN:** 表单属性
22
+ */
23
+ formProps?: FormProps;
24
+ /**
25
+ * - **EN:** Form item properties
26
+ * - **CN:** 表单项属性
27
+ */
28
+ formItemProps?: FormItemProps;
29
+ /**
30
+ * - **EN:** Custom component type for rendering the input box
31
+ * - **CN:** 自定义设置渲染输入框的组件类型
32
+ *
33
+ * @default 'Input'
34
+ */
35
+ inputComp?: IT;
36
+ /**
37
+ * - **EN:** Input component properties
38
+ * - **CN:** 输入框组件属性
39
+ */
40
+ inputProps?: IT extends 'TextArea' ? TextAreaProps : InputProps;
41
+ /**
42
+ * - **EN:** Whether to display as a block-level element, with width 100%
43
+ * - **CN:** 是否显示为块级元素,宽度100%
44
+ *
45
+ * @default false
46
+ */
47
+ block?: boolean;
48
+ /**
49
+ * - **EN:** Semantic class names
50
+ * - **CN:** 语义化类名
51
+ */
52
+ classNames?: {
53
+ /**
54
+ * - **EN:** Edit mode parent container class name
55
+ * - **CN:** 编辑模式父容器类名
56
+ */
57
+ wrapper?: string;
58
+ /**
59
+ * - **EN:** Submit button class name
60
+ * - **CN:** 提交按钮类名
61
+ */
62
+ submitButton?: string;
63
+ /**
64
+ * - **EN:** Cancel button class name
65
+ * - **CN:** 取消按钮类名
66
+ */
67
+ cancelButton?: string;
68
+ /**
69
+ * - **EN:** Submit button icon class name
70
+ * - **CN:** 提交按钮图标类名
71
+ */
72
+ submitIcon?: string;
73
+ /**
74
+ * - **EN:** Cancel button icon class name
75
+ * - **CN:** 取消按钮图标类名
76
+ */
77
+ cancelIcon?: string;
78
+ };
79
+ /**
80
+ * - **EN:** Semantic styles
81
+ * - **CN:** 语义化样式
82
+ */
83
+ styles?: {
84
+ /**
85
+ * - **EN:** Edit mode parent container style
86
+ * - **CN:** 编辑模式父容器样式
87
+ */
88
+ wrapper?: CSSProperties;
89
+ /**
90
+ * - **EN:** Submit button style
91
+ * - **CN:** 提交按钮样式
92
+ */
93
+ submitButton?: CSSProperties;
94
+ /**
95
+ * - **EN:** Cancel button style
96
+ * - **CN:** 取消按钮样式
97
+ */
98
+ cancelButton?: CSSProperties;
99
+ /**
100
+ * - **EN:** Submit button icon style
101
+ * - **CN:** 提交按钮图标样式
102
+ */
103
+ submitIcon?: CSSProperties;
104
+ /**
105
+ * - **EN:** Cancel button icon style
106
+ * - **CN:** 取消按钮图标样式
107
+ */
108
+ cancelIcon?: CSSProperties;
109
+ };
110
+ /**
111
+ * **EN:** Submit and cancel action button alignment
112
+ *
113
+ * **CN:** 提交、取消操作按钮的对齐方式
114
+ *
115
+ * - `start` - align to the top | 顶部对齐
116
+ * - `center` - align to the center | 居中对齐
117
+ * - `end` - align to the bottom | 底部对齐
118
+ *
119
+ * @default 'center'
120
+ */
121
+ actionAlign?: SpaceProps['align'];
122
+ /**
123
+ * - **EN:** Submit button properties
124
+ * - **CN:** 提交操作按钮属性
125
+ */
126
+ submitProps?: ButtonProps;
127
+ /**
128
+ * - **EN:** Cancel button properties
129
+ * - **CN:** 取消操作按钮属性
130
+ */
131
+ cancelProps?: ButtonProps;
132
+ /**
133
+ * - **EN:** Confirm button click event, supports asynchronous operations
134
+ * - **CN:** 确认按钮点击事件,支持异步操作
135
+ */
136
+ onOk: (value: string) => void | Promise<void>;
137
+ /**
138
+ * - **EN:** Cancel button click event, supports asynchronous operations
139
+ * - **CN:** 取消按钮点击事件,支持异步操作
140
+ */
141
+ onCancel?: () => void | Promise<void>;
142
+ }
143
+ declare const EditableTextForm: <IT extends "Input" | "TextArea">({ prefixCls, value, required, classNames, styles: styleNames, inputComp, block: blockInProps, formProps, formItemProps, inputProps, actionAlign, submitProps, cancelProps, onOk, onCancel, }: EditableFormProps<IT>) => import("react/jsx-runtime").JSX.Element;
144
+ export default EditableTextForm;