@tiny-codes/react-easy 1.0.3 → 1.0.4

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 (96) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/es/components/BreakLines/index.js +43 -26
  3. package/es/components/BreakLines/index.js.map +1 -1
  4. package/es/components/ConfigProvider/context.js +3 -3
  5. package/es/components/ConfigProvider/context.js.map +1 -1
  6. package/es/components/ConfigProvider/index.js +37 -35
  7. package/es/components/ConfigProvider/index.js.map +1 -1
  8. package/es/components/ConfirmAction/index.d.ts +74 -6
  9. package/es/components/ConfirmAction/index.js +210 -104
  10. package/es/components/ConfirmAction/index.js.map +1 -1
  11. package/es/components/DeleteConfirmAction/index.js +22 -20
  12. package/es/components/DeleteConfirmAction/index.js.map +1 -1
  13. package/es/components/ModalAction/index.d.ts +45 -5
  14. package/es/components/ModalAction/index.js +393 -209
  15. package/es/components/ModalAction/index.js.map +1 -1
  16. package/es/components/index.js +10 -8
  17. package/es/components/index.js.map +1 -1
  18. package/es/hooks/index.js +4 -4
  19. package/es/hooks/index.js.map +1 -1
  20. package/es/hooks/useContextValidator.js +7 -12
  21. package/es/hooks/useContextValidator.js.map +1 -1
  22. package/es/hooks/useLocalizedText.js +6 -4
  23. package/es/hooks/useLocalizedText.js.map +1 -1
  24. package/es/hooks/useRefFunction.js +13 -6
  25. package/es/hooks/useRefFunction.js.map +1 -1
  26. package/es/hooks/useT.js +11 -8
  27. package/es/hooks/useT.js.map +1 -1
  28. package/es/hooks/useValidator.js +7 -4
  29. package/es/hooks/useValidator.js.map +1 -1
  30. package/es/hooks/useValidatorBuilder.js +146 -117
  31. package/es/hooks/useValidatorBuilder.js.map +1 -1
  32. package/es/hooks/useValidators.js +94 -58
  33. package/es/hooks/useValidators.js.map +1 -1
  34. package/es/index.js +2 -2
  35. package/es/index.js.map +1 -1
  36. package/es/locales/index.js +19 -13
  37. package/es/locales/index.js.map +1 -1
  38. package/es/locales/langs/en-US.js +20 -20
  39. package/es/locales/langs/en-US.js.map +1 -1
  40. package/es/locales/langs/en.js +1 -1
  41. package/es/locales/langs/en.js.map +1 -1
  42. package/es/locales/langs/zh-CN.js +20 -20
  43. package/es/locales/langs/zh-CN.js.map +1 -1
  44. package/es/utils/index.js +1 -1
  45. package/es/utils/index.js.map +1 -1
  46. package/lib/components/BreakLines/index.js +50 -37
  47. package/lib/components/BreakLines/index.js.map +7 -1
  48. package/lib/components/ConfigProvider/context.js +35 -6
  49. package/lib/components/ConfigProvider/context.js.map +7 -1
  50. package/lib/components/ConfigProvider/index.js +56 -42
  51. package/lib/components/ConfigProvider/index.js.map +7 -1
  52. package/lib/components/ConfirmAction/index.d.ts +74 -6
  53. package/lib/components/ConfirmAction/index.js +194 -138
  54. package/lib/components/ConfirmAction/index.js.map +7 -1
  55. package/lib/components/DeleteConfirmAction/index.js +50 -51
  56. package/lib/components/DeleteConfirmAction/index.js.map +7 -1
  57. package/lib/components/ModalAction/index.d.ts +45 -5
  58. package/lib/components/ModalAction/index.js +303 -243
  59. package/lib/components/ModalAction/index.js.map +7 -1
  60. package/lib/components/index.js +63 -11
  61. package/lib/components/index.js.map +7 -1
  62. package/lib/hooks/index.js +49 -5
  63. package/lib/hooks/index.js.map +7 -1
  64. package/lib/hooks/useContextValidator.js +47 -11
  65. package/lib/hooks/useContextValidator.js.map +7 -1
  66. package/lib/hooks/useLocalizedText.js +41 -15
  67. package/lib/hooks/useLocalizedText.js.map +7 -1
  68. package/lib/hooks/useRefFunction.js +34 -21
  69. package/lib/hooks/useRefFunction.js.map +7 -1
  70. package/lib/hooks/useT.js +43 -11
  71. package/lib/hooks/useT.js.map +7 -1
  72. package/lib/hooks/useValidator.js +41 -12
  73. package/lib/hooks/useValidator.js.map +7 -1
  74. package/lib/hooks/useValidatorBuilder.js +149 -132
  75. package/lib/hooks/useValidatorBuilder.js.map +7 -1
  76. package/lib/hooks/useValidators.js +104 -67
  77. package/lib/hooks/useValidators.js.map +7 -1
  78. package/lib/index.js +26 -3
  79. package/lib/index.js.map +7 -1
  80. package/lib/locales/index.js +58 -15
  81. package/lib/locales/index.js.map +7 -1
  82. package/lib/locales/langs/en-US.js +46 -22
  83. package/lib/locales/langs/en-US.js.map +7 -1
  84. package/lib/locales/langs/en.js +37 -3
  85. package/lib/locales/langs/en.js.map +7 -1
  86. package/lib/locales/langs/zh-CN.js +46 -22
  87. package/lib/locales/langs/zh-CN.js.map +7 -1
  88. package/lib/utils/index.js +1 -2
  89. package/lib/utils/index.js.map +7 -1
  90. package/package.json +14 -15
  91. package/es/hooks/useValidateContext.d.ts +0 -2
  92. package/es/hooks/useValidateContext.js +0 -16
  93. package/es/hooks/useValidateContext.js.map +0 -1
  94. package/lib/hooks/useValidateContext.d.ts +0 -2
  95. package/lib/hooks/useValidateContext.js +0 -16
  96. package/lib/hooks/useValidateContext.js.map +0 -1
@@ -8,7 +8,7 @@ import type { LinkProps } from 'antd/es/typography/Link';
8
8
  * **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效
9
9
  */
10
10
  export declare const SubmitWithoutClosingSymbol: unique symbol;
11
- export type ModalActionProps<FD extends object, CP extends FormCompPropsConstraint<FD>, TP extends object, E extends keyof TP, CRef extends object> = Omit<ModalProps, 'onOk'> & ModalActionTrigger<TP, E> & {
11
+ 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> & {
12
12
  /**
13
13
  * **EN:** Form editing component, do not use the Form component inside the component, the form
14
14
  * component and form instance are automatically created by the parent component
@@ -102,7 +102,7 @@ export interface FormCompPropsConstraint<FD> {
102
102
  */
103
103
  triggerEventData?: any[];
104
104
  }
105
- export interface ModalActionTrigger<TP extends object, E extends keyof TP> {
105
+ export interface ModalActionTrigger<FD extends object, CP extends FormCompPropsConstraint<FD>, TP extends object, E extends keyof TP> {
106
106
  /**
107
107
  * **EN:** Trigger component, click to show the dialog
108
108
  *
@@ -114,7 +114,18 @@ export interface ModalActionTrigger<TP extends object, E extends keyof TP> {
114
114
  *
115
115
  * **CN:** 触发器组件的Props属性
116
116
  */
117
- triggerProps?: TP;
117
+ triggerProps?: TP & {
118
+ /**
119
+ * **EN:** Set a custom function to determine whether to show the trigger button
120
+ *
121
+ * **CN:** 设置一个自定义函数,用于判断是否显示触发器按钮
122
+ *
123
+ * @default true
124
+ *
125
+ * @param formProps Form component props | 表单组件的props
126
+ */
127
+ show?: boolean | ((formProps?: Omit<CP, keyof FormCompPropsConstraint<FD>>) => boolean);
128
+ };
118
129
  /**
119
130
  * **EN:** The event name that triggers the dialog
120
131
  *
@@ -149,7 +160,7 @@ export declare const genModalActionRenderer: (defaultProps: Partial<ModalActionP
149
160
  * @param WrappedComponent ModalAction component | ModalAction组件
150
161
  * @param defaultProps Default properties | 默认属性
151
162
  */
152
- 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<TP, E> & {
163
+ export declare const withDefaultModalActionProps: <FD extends object, CP extends FormCompPropsConstraint<FD>, TP extends object, E extends keyof TP, CRef extends object>(WrappedComponent: ComponentType<Omit<ModalProps, "onOk"> & ModalActionTrigger<FD, CP, TP, E> & {
153
164
  /**
154
165
  * **EN:** Form editing component, do not use the Form component inside the component, the form
155
166
  * component and form instance are automatically created by the parent component
@@ -177,7 +188,36 @@ export declare const withDefaultModalActionProps: <FD extends object, CP extends
177
188
  *
178
189
  * **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值
179
190
  */
180
- afterOk?: (data?: any) => void;
191
+ afterOk?: ((data?: any) => void) | undefined;
192
+ } & RefAttributes<ModalActionRef<CRef>>>, defaultProps?: Partial<ModalActionProps<FD, CP, TP, E, CRef>> | (() => Partial<ModalActionProps<FD, CP, TP, E, CRef>>) | undefined) => import("react").ForwardRefExoticComponent<Omit<ModalProps, "onOk"> & ModalActionTrigger<FD, CP, TP, E> & {
193
+ /**
194
+ * **EN:** Form editing component, do not use the Form component inside the component, the form
195
+ * component and form instance are automatically created by the parent component
196
+ *
197
+ * **CN:** 表单编辑组件,组件内部不要使用Form组件,表单组件及表单实例由父组件自动创建
198
+ */
199
+ formComp: ComponentType<CP & RefAttributes<CRef>>;
200
+ /**
201
+ * **EN:** Props of the form editing component
202
+ *
203
+ * **CN:** 表单编辑组件的Props属性
204
+ */
205
+ formProps?: Omit<CP, keyof FormCompPropsConstraint<FD_1>> | undefined;
206
+ /**
207
+ * **EN:** The callback when clicks the confirmation button, support asynchronous saving, return
208
+ * `SubmitWithoutClosingSymbol` can prevent the dialog from closing, return other values will be
209
+ * passed to the `afterOk` event, if any
210
+ *
211
+ * **CN:** 点击确认按钮的回调,支持异步保存,返回`SubmitWithoutClosingSymbol`可以阻止弹框关闭,返回其他值会传递给`afterOk`事件,如果有的话
212
+ */
213
+ onOk?: ((formData: FD, ...args: Parameters<TP[E]>) => unknown | Promise<unknown>) | undefined;
214
+ /**
215
+ * **EN:** The callback after the confirmation event is completed, it will not be triggered when
216
+ * it fails, the parameter is the return value of `onOk`
217
+ *
218
+ * **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值
219
+ */
220
+ afterOk?: ((data?: any) => void) | undefined;
181
221
  } & RefAttributes<ModalActionRef<CRef>>>;
182
222
  /**
183
223
  * **EN:** ModalAction component type