@tiny-codes/react-easy 1.0.0 → 1.0.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -6
- package/README.md +65 -2
- package/README.zh-CN.md +2 -2
- package/es/components/BreakLines/index.d.ts +51 -0
- package/es/components/BreakLines/index.js +40 -0
- package/es/components/BreakLines/index.js.map +1 -0
- package/es/components/ConfigProvider/context.d.ts +11 -4
- package/es/components/ConfigProvider/context.js +5 -3
- package/es/components/ConfigProvider/context.js.map +1 -1
- package/es/components/ConfigProvider/index.d.ts +11 -3
- package/es/components/ConfigProvider/index.js +23 -3
- package/es/components/ConfigProvider/index.js.map +1 -1
- package/es/components/ConfirmAction/index.js +5 -5
- package/es/components/ConfirmAction/index.js.map +1 -1
- package/es/components/ModalAction/index.d.ts +58 -8
- package/es/components/ModalAction/index.js +2 -2
- package/es/components/ModalAction/index.js.map +1 -1
- package/es/components/index.js +1 -0
- package/es/components/index.js.map +1 -1
- package/es/hooks/index.d.ts +3 -0
- package/es/hooks/index.js +1 -0
- package/es/hooks/index.js.map +1 -1
- package/es/hooks/useContextValidator.d.ts +2 -0
- package/{lib/hooks/useValidateContext.js → es/hooks/useContextValidator.js} +5 -5
- package/es/hooks/useContextValidator.js.map +1 -0
- package/es/hooks/useLocalizedText.d.ts +2 -2
- package/es/hooks/useT.d.ts +3 -0
- package/es/hooks/useT.js +12 -0
- package/es/hooks/useT.js.map +1 -0
- package/es/hooks/useValidator.d.ts +8 -0
- package/es/hooks/useValidator.js +13 -0
- package/es/hooks/useValidator.js.map +1 -0
- package/es/hooks/useValidatorBuilder.d.ts +133 -0
- package/es/hooks/useValidatorBuilder.js +139 -0
- package/es/hooks/useValidatorBuilder.js.map +1 -0
- package/es/hooks/useValidators.d.ts +150 -0
- package/es/hooks/useValidators.js +68 -0
- package/es/hooks/useValidators.js.map +1 -0
- package/es/locales/index.d.ts +74 -0
- package/es/locales/index.js +19 -0
- package/es/locales/index.js.map +1 -0
- package/es/locales/langs/en-US.d.ts +21 -0
- package/es/locales/langs/en-US.js +22 -0
- package/es/locales/langs/en-US.js.map +1 -0
- package/es/locales/langs/en.d.ts +2 -0
- package/es/locales/langs/en.js +3 -0
- package/es/locales/langs/en.js.map +1 -0
- package/es/locales/langs/zh-CN.d.ts +21 -0
- package/es/locales/langs/zh-CN.js +22 -0
- package/es/locales/langs/zh-CN.js.map +1 -0
- package/es/utils/index.d.ts +0 -0
- package/es/utils/index.js +2 -0
- package/es/utils/index.js.map +1 -0
- package/lib/components/BreakLines/index.d.ts +51 -0
- package/lib/components/BreakLines/index.js +40 -0
- package/lib/components/BreakLines/index.js.map +1 -0
- package/lib/components/ConfigProvider/context.d.ts +11 -4
- package/lib/components/ConfigProvider/context.js +5 -3
- package/lib/components/ConfigProvider/context.js.map +1 -1
- package/lib/components/ConfigProvider/index.d.ts +11 -3
- package/lib/components/ConfigProvider/index.js +23 -3
- package/lib/components/ConfigProvider/index.js.map +1 -1
- package/lib/components/ConfirmAction/index.js +5 -5
- package/lib/components/ConfirmAction/index.js.map +1 -1
- package/lib/components/ModalAction/index.d.ts +58 -8
- package/lib/components/ModalAction/index.js +2 -2
- package/lib/components/ModalAction/index.js.map +1 -1
- package/lib/components/index.js +1 -0
- package/lib/components/index.js.map +1 -1
- package/lib/hooks/index.d.ts +3 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useContextValidator.d.ts +2 -0
- package/{es/hooks/useValidateContext.js → lib/hooks/useContextValidator.js} +5 -5
- package/lib/hooks/useContextValidator.js.map +1 -0
- package/lib/hooks/useLocalizedText.d.ts +2 -2
- package/lib/hooks/useT.d.ts +3 -0
- package/lib/hooks/useT.js +12 -0
- package/lib/hooks/useT.js.map +1 -0
- package/lib/hooks/useValidator.d.ts +8 -0
- package/lib/hooks/useValidator.js +13 -0
- package/lib/hooks/useValidator.js.map +1 -0
- package/lib/hooks/useValidatorBuilder.d.ts +133 -0
- package/lib/hooks/useValidatorBuilder.js +139 -0
- package/lib/hooks/useValidatorBuilder.js.map +1 -0
- package/lib/hooks/useValidators.d.ts +150 -0
- package/lib/hooks/useValidators.js +68 -0
- package/lib/hooks/useValidators.js.map +1 -0
- package/lib/locales/index.d.ts +74 -0
- package/lib/locales/index.js +19 -0
- package/lib/locales/index.js.map +1 -0
- package/lib/locales/langs/en-US.d.ts +21 -0
- package/lib/locales/langs/en-US.js +22 -0
- package/lib/locales/langs/en-US.js.map +1 -0
- package/lib/locales/langs/en.d.ts +2 -0
- package/lib/locales/langs/en.js +3 -0
- package/lib/locales/langs/en.js.map +1 -0
- package/lib/locales/langs/zh-CN.d.ts +21 -0
- package/lib/locales/langs/zh-CN.js +22 -0
- package/lib/locales/langs/zh-CN.js.map +1 -0
- package/lib/utils/index.d.ts +0 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/index.js.map +1 -0
- package/package.json +4 -2
- package/es/hooks/useValidateContext.d.ts +0 -2
- package/es/hooks/useValidateContext.js.map +0 -1
- package/lib/hooks/useValidateContext.d.ts +0 -2
- package/lib/hooks/useValidateContext.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 1.0.2
|
|
6
|
+
|
|
7
|
+
2025-2-15
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- 🔥 Adds `BreakLines` 组件
|
|
12
|
+
|
|
13
|
+
## 1.0.1
|
|
14
|
+
|
|
15
|
+
2025-2-13
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
- 🔥 Support internationalization
|
|
20
|
+
|
|
21
|
+
**ConfigProvider**
|
|
22
|
+
|
|
23
|
+
- 🔥 `lang` prop is added to provide the language
|
|
24
|
+
- 🔥 `locales` prop is added to customize built-in locale resources or add a new language
|
|
25
|
+
|
|
26
|
+
**Hooks**
|
|
27
|
+
|
|
28
|
+
- 🔥 adds `useValidators` to get built-in validator rules
|
|
29
|
+
- 🔥 adds `useValidator` to build a custom validator
|
|
30
|
+
- 🔥 adds `useValidatorBuilder` to get a function that builds a custom validator
|
|
31
|
+
|
|
32
|
+
## 1.0.0
|
|
6
33
|
|
|
7
34
|
2025-2-7
|
|
8
35
|
|
|
@@ -10,11 +37,11 @@ The first release ships the following contents
|
|
|
10
37
|
|
|
11
38
|
- **Components**
|
|
12
39
|
|
|
13
|
-
- `ConfirmAction` component that renders a button that triggers a confirmation modal before executing the action
|
|
14
|
-
- `DeleteConfirmAction` component that renders a button that triggers a deletion confirmation modal before deleting action
|
|
15
|
-
- `ModalAction` component that renders a button that triggers a modal with a form to collect user input
|
|
16
|
-
- `ConfigProvider` component that provides a global configuration for the components
|
|
40
|
+
- 🔥 `ConfirmAction` component that renders a button that triggers a confirmation modal before executing the action
|
|
41
|
+
- 🔥 `DeleteConfirmAction` component that renders a button that triggers a deletion confirmation modal before deleting action
|
|
42
|
+
- 🔥 `ModalAction` component that renders a button that triggers a modal with a form to collect user input
|
|
43
|
+
- 🔥 `ConfigProvider` component that provides a global configuration for the components
|
|
17
44
|
|
|
18
45
|
- **Hooks**
|
|
19
46
|
|
|
20
|
-
- `useRefFunction` hook that wraps a function to an immutable function
|
|
47
|
+
- 🔥 `useRefFunction` hook that wraps a function to an immutable function
|
package/README.md
CHANGED
|
@@ -116,7 +116,7 @@ import { ModalAction } from '@tiny-codes/react-easy';
|
|
|
116
116
|
|
|
117
117
|
This is a higher-order component that wraps a form component into a modal, and when you click the button to display the modal, the content of the modal is the form component, which is used to edit data.
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
_**form.tsx**_
|
|
120
120
|
|
|
121
121
|
```jsx
|
|
122
122
|
import { withModalAction, FormCompPropsConstraint } from '@tiny-codes/react-easy';
|
|
@@ -149,7 +149,7 @@ const EditForm: React.FC<FormProps & FormCompPropsConstraint<FormData>> = (props
|
|
|
149
149
|
export default withModalAction(EditForm);
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
_**app.tsx**_
|
|
153
153
|
|
|
154
154
|
```jsx
|
|
155
155
|
<EditModalAction>Edit</EditModalAction>
|
|
@@ -179,6 +179,65 @@ const Foo: React.FC<{ value: string; }> = (props) => {
|
|
|
179
179
|
};
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
+
### useValidators
|
|
183
|
+
|
|
184
|
+
`useValidators` is used to get some built-in validator rules or build a custom rule.
|
|
185
|
+
|
|
186
|
+
```jsx
|
|
187
|
+
import { useValidators } from '@tiny-codes/react-easy';
|
|
188
|
+
import { Form } from 'antd';
|
|
189
|
+
|
|
190
|
+
const { number, email, code } = useValidators();
|
|
191
|
+
|
|
192
|
+
<Form>
|
|
193
|
+
<Form.Item name="number" rules={[{ validator: number }]}>
|
|
194
|
+
<Input />
|
|
195
|
+
</Form.Item>
|
|
196
|
+
<Form.Item name="email" rules={[{ validator: email }]}>
|
|
197
|
+
<Input />
|
|
198
|
+
</Form.Item>
|
|
199
|
+
<Form.Item name="code" rules={[{ validator: code }]}>
|
|
200
|
+
<Input />
|
|
201
|
+
</Form.Item>
|
|
202
|
+
</Form>;
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### useValidator
|
|
206
|
+
|
|
207
|
+
`useValidator` is used to build a custom validator rule.
|
|
208
|
+
|
|
209
|
+
```jsx
|
|
210
|
+
import { useValidator } from '@tiny-codes/react-easy';
|
|
211
|
+
|
|
212
|
+
const validator = useValidator({
|
|
213
|
+
allowed: {
|
|
214
|
+
number: true,
|
|
215
|
+
letter: true,
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
<Form.Item name="letterAndNumberOnly" rules={[{ validator }]}>
|
|
220
|
+
<Input />
|
|
221
|
+
</Form.Item>;
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### useValidatorBuilder
|
|
225
|
+
|
|
226
|
+
`useValidatorBuilder` is used to get a function that builds a custom validator rule.
|
|
227
|
+
|
|
228
|
+
```jsx
|
|
229
|
+
import { useValidatorBuilder } from '@tiny-codes/react-easy';
|
|
230
|
+
|
|
231
|
+
const build = useValidatorBuilder();
|
|
232
|
+
|
|
233
|
+
const validator = build({
|
|
234
|
+
allowed: {
|
|
235
|
+
number: true,
|
|
236
|
+
letter: true,
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
182
241
|
## Compatibility
|
|
183
242
|
|
|
184
243
|
- `react` >= 16.8.0
|
|
@@ -192,3 +251,7 @@ const Foo: React.FC<{ value: string; }> = (props) => {
|
|
|
192
251
|
```
|
|
193
252
|
|
|
194
253
|
```
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
```
|
package/README.zh-CN.md
CHANGED
|
@@ -116,7 +116,7 @@ import { ModalAction } from '@tiny-codes/react-easy';
|
|
|
116
116
|
|
|
117
117
|
这是一个高阶组件,用于将一个表单组件包装成一个模态框,当点击按钮显示模态框时,模态框内容就是这个表单组件,用于编辑数据。
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
_**form.tsx**_
|
|
120
120
|
|
|
121
121
|
```jsx
|
|
122
122
|
import { withModalAction, FormCompPropsConstraint } from '@tiny-codes/react-easy';
|
|
@@ -149,7 +149,7 @@ const EditForm: React.FC<FormProps & FormCompPropsConstraint<FormData>> = (props
|
|
|
149
149
|
export default withModalAction(EditForm);
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
_**app.tsx**_
|
|
153
153
|
|
|
154
154
|
```jsx
|
|
155
155
|
<EditModalAction>编辑</EditModalAction>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
export interface BreakLinesProps {
|
|
3
|
+
/**
|
|
4
|
+
* **EN:** Text content
|
|
5
|
+
*
|
|
6
|
+
* **CN:** 文本内容
|
|
7
|
+
*/
|
|
8
|
+
value: string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* **EN:** Whether to enable line breaking
|
|
11
|
+
*
|
|
12
|
+
* **CN:** 是否启用换行功能
|
|
13
|
+
*
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* **EN:** Line break character
|
|
19
|
+
*
|
|
20
|
+
* **CN:** 换行符
|
|
21
|
+
*
|
|
22
|
+
* @default '\n'
|
|
23
|
+
*/
|
|
24
|
+
EOL?: string;
|
|
25
|
+
/**
|
|
26
|
+
* **CN:** 渲染dom节点的标签名
|
|
27
|
+
*
|
|
28
|
+
* **EN:** Render the tag name of the DOM node
|
|
29
|
+
*
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
tagName?: 'span' | 'div' | 'i' | 'pre' | (string & {}) | false;
|
|
33
|
+
/**
|
|
34
|
+
* **EN:** The CSS class name of the dom node, if `tagName` is set to false, this property is
|
|
35
|
+
* invalid
|
|
36
|
+
*
|
|
37
|
+
* **CN:** dom节点的css类名,如果`tagName`设置为false,则此属性无效
|
|
38
|
+
*/
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* **EN:** Output a piece of text, keeping line breaks
|
|
43
|
+
*
|
|
44
|
+
* **CN:** 输出一段文本,保留换行符
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* <BreakLines value="hello \n world" />;
|
|
48
|
+
* // hello <br/> world
|
|
49
|
+
*/
|
|
50
|
+
declare const BreakLines: FC<BreakLinesProps>;
|
|
51
|
+
export default BreakLines;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* **EN:** Output a piece of text, keeping line breaks
|
|
5
|
+
*
|
|
6
|
+
* **CN:** 输出一段文本,保留换行符
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <BreakLines value="hello \n world" />;
|
|
10
|
+
* // hello <br/> world
|
|
11
|
+
*/
|
|
12
|
+
const BreakLines = (props) => {
|
|
13
|
+
const { value, className, tagName = false, enabled = true, EOL = '\n' } = props;
|
|
14
|
+
let content;
|
|
15
|
+
if (value) {
|
|
16
|
+
if (enabled) {
|
|
17
|
+
if (value.includes(EOL)) {
|
|
18
|
+
const segments = value === null || value === void 0 ? void 0 : value.split(EOL);
|
|
19
|
+
content = segments.map((str, i) => (_jsxs(_Fragment, { children: [str, i !== segments.length - 1 && _jsx("br", {})] })));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
content = value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
content = value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
content = value;
|
|
31
|
+
}
|
|
32
|
+
if (tagName) {
|
|
33
|
+
return createElement(tagName, { className }, content);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return _jsx(_Fragment, { children: content });
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export default BreakLines;
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/BreakLines/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAA2B,MAAM,OAAO,CAAC;AA2C/D;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAwB,CAAC,KAAK,EAAE,EAAE;IAChD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,GAAG,KAAK,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAEhF,IAAI,OAAkB,CAAC;IACvB,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxB,MAAM,QAAQ,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC,GAAG,CAAC,CAAC;gBACnC,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CACjC,8BACG,GAAG,EACH,CAAC,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,cAAM,IACnC,CACJ,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,KAAK,CAAC;YAClB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,KAAK,CAAC;IAClB,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,aAAa,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,OAAO,4BAAG,OAAO,GAAI,CAAC;IACxB,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
import type { Langs } from '../../locales';
|
|
3
|
+
export interface ReactEasyContextProps {
|
|
4
|
+
/**
|
|
5
|
+
* **EN:** Language of the component, used for global configuration, can be 'en-US' or 'zh-CN'
|
|
6
|
+
*
|
|
7
|
+
* **CN:** 组件的语言,用于全局配置,可以是'en-US'或'zh-CN'
|
|
8
|
+
*/
|
|
9
|
+
lang?: Langs;
|
|
3
10
|
/**
|
|
4
11
|
* **EN:** Default title of the confirm dialog, used for global configuration, can be normal text
|
|
5
12
|
* or the key of localized resources, the key of localized resources will be converted into
|
|
@@ -44,6 +51,6 @@ export interface AntHelperContextProps {
|
|
|
44
51
|
*/
|
|
45
52
|
localize?: <T>(key: T, args?: Record<string, unknown>) => ReactNode;
|
|
46
53
|
}
|
|
47
|
-
export declare const defaultContextValue:
|
|
48
|
-
declare const
|
|
49
|
-
export default
|
|
54
|
+
export declare const defaultContextValue: ReactEasyContextProps;
|
|
55
|
+
declare const ReactEasyContext: import("react").Context<ReactEasyContextProps>;
|
|
56
|
+
export default ReactEasyContext;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
|
-
export const defaultContextValue = {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export const defaultContextValue = {
|
|
3
|
+
lang: 'en',
|
|
4
|
+
};
|
|
5
|
+
const ReactEasyContext = createContext(defaultContextValue);
|
|
6
|
+
export default ReactEasyContext;
|
|
5
7
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/components/ConfigProvider/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/components/ConfigProvider/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AA2DtD,MAAM,CAAC,MAAM,mBAAmB,GAA0B;IACxD,IAAI,EAAE,IAAI;CACX,CAAC;AAEF,MAAM,gBAAgB,GAAG,aAAa,CAAwB,mBAAmB,CAAC,CAAC;AAEnF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { type FC, type ReactNode } from 'react';
|
|
2
|
+
import type localesEn from '../../locales/langs/en';
|
|
3
|
+
import { type ReactEasyContextProps } from './context';
|
|
4
|
+
export interface ConfigProviderProps extends ReactEasyContextProps {
|
|
5
|
+
/**
|
|
6
|
+
* **EN:** Custom localized resources, if `lang` exists, it will override the localized resources
|
|
7
|
+
* of the corresponding language,
|
|
8
|
+
*
|
|
9
|
+
* **CN:** 自定义本地化资源,如果`lang`存在,则会覆盖对应语言的本地化资源,如果`lang`不存在,则会添加一种新的语言
|
|
10
|
+
*/
|
|
11
|
+
locales?: Partial<typeof localesEn>;
|
|
4
12
|
children: ReactNode;
|
|
5
13
|
}
|
|
6
14
|
/**
|
|
@@ -10,15 +10,35 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import
|
|
13
|
+
import { useEffect } from 'react';
|
|
14
|
+
import locales, { langs, resources } from '../../locales';
|
|
15
|
+
import ReactEasyContext from './context';
|
|
14
16
|
/**
|
|
15
17
|
* **EN:** Provide global configuration for AntdHelper
|
|
16
18
|
*
|
|
17
19
|
* **CN:** 提供AntdHelper的全局配置
|
|
18
20
|
*/
|
|
19
21
|
const ConfigProvider = (props) => {
|
|
20
|
-
const { children } = props, restProps = __rest(props, ["children"]);
|
|
21
|
-
|
|
22
|
+
const { children, locales: userLocales } = props, restProps = __rest(props, ["children", "locales"]);
|
|
23
|
+
const { lang: langInProps } = restProps;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
// Dynamically add language pack
|
|
26
|
+
if (userLocales) {
|
|
27
|
+
const lang = langInProps || 'en';
|
|
28
|
+
if (lang && langs.includes(lang)) {
|
|
29
|
+
locales.removeResourceBundle(lang, 'translation');
|
|
30
|
+
locales.addResourceBundle(lang, 'translation', Object.assign(Object.assign({}, resources[lang].translation), userLocales));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
locales.addResourceBundle(lang, 'translation', Object.assign(Object.assign({}, resources.en.translation), userLocales));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}, [langInProps, userLocales]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
// Set the language of the component
|
|
39
|
+
locales.changeLanguage(langInProps || 'en');
|
|
40
|
+
}, [langInProps]);
|
|
41
|
+
return _jsx(ReactEasyContext.Provider, { value: restProps, children: children });
|
|
22
42
|
};
|
|
23
43
|
export default ConfigProvider;
|
|
24
44
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ConfigProvider/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ConfigProvider/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAA2B,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,gBAAgD,MAAM,WAAW,CAAC;AAazE;;;;GAIG;AACH,MAAM,cAAc,GAA4B,CAAC,KAAK,EAAE,EAAE;IACxD,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,KAAmB,KAAK,EAAnB,SAAS,UAAK,KAAK,EAAxD,uBAAgD,CAAQ,CAAC;IAC/D,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;IAExC,SAAS,CAAC,GAAG,EAAE;QACb,gCAAgC;QAChC,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,IAAI,GAAG,WAAW,IAAI,IAAI,CAAC;YACjC,IAAI,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjC,OAAO,CAAC,oBAAoB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;gBAClD,OAAO,CAAC,iBAAiB,CAAC,IAAI,EAAE,aAAa,kCAAO,SAAS,CAAC,IAAI,CAAC,CAAC,WAAW,GAAK,WAAW,EAAG,CAAC;YACrG,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,iBAAiB,CAAC,IAAI,EAAE,aAAa,kCAAO,SAAS,CAAC,EAAE,CAAC,WAAW,GAAK,WAAW,EAAG,CAAC;YAClG,CAAC;QACH,CAAC;IACH,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;IAE/B,SAAS,CAAC,GAAG,EAAE;QACb,oCAAoC;QACpC,OAAO,CAAC,cAAc,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC;IAC9C,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,SAAS,YAAG,QAAQ,GAA6B,CAAC;AAC7F,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -22,10 +22,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
22
22
|
import { forwardRef, useContext, useImperativeHandle, useRef, useState } from 'react';
|
|
23
23
|
import { App, Button, Modal, Switch, Typography } from 'antd';
|
|
24
24
|
import useToken from 'antd/es/theme/useToken';
|
|
25
|
+
import useContextValidator from '../../hooks/useContextValidator';
|
|
25
26
|
import useLocalizedText from '../../hooks/useLocalizedText';
|
|
26
27
|
import useRefFunction from '../../hooks/useRefFunction';
|
|
27
|
-
import
|
|
28
|
-
import AntHelperContext from '../ConfigProvider/context';
|
|
28
|
+
import ReactEasyContext from '../ConfigProvider/context';
|
|
29
29
|
/**
|
|
30
30
|
* **EN:** Generate a confirm box component
|
|
31
31
|
*
|
|
@@ -44,14 +44,14 @@ defaultProps) => {
|
|
|
44
44
|
const mergedProps = Object.assign(Object.assign(Object.assign({}, restDefaults), props), { okButtonProps: Object.assign(Object.assign({}, restDefaults.okButtonProps), props.okButtonProps), cancelButtonProps: Object.assign(Object.assign({}, restDefaults.cancelButtonProps), props.cancelButtonProps), bodyProps: Object.assign(Object.assign({}, restDefaults.bodyProps), props.bodyProps), maskProps: Object.assign(Object.assign({}, restDefaults.maskProps), props.maskProps), wrapProps: Object.assign(Object.assign({}, restDefaults.wrapProps), props.wrapProps), triggerProps: Object.assign(Object.assign(Object.assign({}, restDefaults.triggerProps), props.triggerProps), { style: Object.assign(Object.assign({}, (_a = restDefaults.triggerProps) === null || _a === void 0 ? void 0 : _a.style), (props.triggerProps && 'style' in props.triggerProps && typeof props.triggerProps.style === 'object'
|
|
45
45
|
? props.triggerProps.style
|
|
46
46
|
: {})) }) });
|
|
47
|
-
const context = useContext(
|
|
47
|
+
const context = useContext(ReactEasyContext);
|
|
48
48
|
const defaultTitle = useLocalizedText(confirmType === 'delete' ? context.defaultDeletionConfirmTitle : context.defaultConfirmTitle);
|
|
49
49
|
const defaultContent = useLocalizedText(confirmType === 'delete' ? context.defaultDeletionConfirmContent : context.defaultConfirmContent);
|
|
50
50
|
const { triggerComponent: Trigger = Button, triggerEvent = 'onClick', triggerProps, title = defaultTitle, content = defaultContent, titleColor = 'warning', contentColor, icon, iconColor, onOk, afterOk, children } = mergedProps, restProps = __rest(mergedProps, ["triggerComponent", "triggerEvent", "triggerProps", "title", "content", "titleColor", "contentColor", "icon", "iconColor", "onOk", "afterOk", "children"]);
|
|
51
|
-
|
|
51
|
+
useContextValidator();
|
|
52
52
|
const { modal: modalFromApp } = App.useApp();
|
|
53
53
|
const modal = modalFromApp !== null && modalFromApp !== void 0 ? modalFromApp : Modal;
|
|
54
|
-
const { localize } = useContext(
|
|
54
|
+
const { localize } = useContext(ReactEasyContext);
|
|
55
55
|
const [, token] = useToken();
|
|
56
56
|
const [confirmApi, setConfirmApi] = useState();
|
|
57
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ConfirmAction/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtF,OAAO,EAAE,GAAG,EAAE,MAAM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FD extends object, CP extends FormCompPropsConstrai
|
|
|
39
39
|
afterOk?: (data?: any) => void;
|
|
40
40
|
};
|
|
41
41
|
export interface FormCompPropsConstraint<FD> {
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* **EN:** Automatically generated form instance, use this form instance in FormComp, do not
|
|
44
|
+
* create a new instance
|
|
45
|
+
*
|
|
46
|
+
* **CN:** 自动生成的表单实例,编辑表单要使用这个表单实例,不要新创建实例
|
|
47
|
+
*/
|
|
43
48
|
form: FormInstance<FD>;
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
/**
|
|
50
|
+
* **EN:** Register the form save event, the callback function passed in will be called when the
|
|
51
|
+
* confirm button is clicked, support asynchronous saving
|
|
52
|
+
*
|
|
53
|
+
* **CN:** 注册表单保存事件,传入的回调函数会在点击确认按钮时被调用,支持异步保存
|
|
54
|
+
*
|
|
55
|
+
* @param handler Event handler | 事件处理函数
|
|
56
|
+
*/
|
|
57
|
+
onSave: (handler: (
|
|
58
|
+
/**
|
|
59
|
+
* **EN:** Form data
|
|
60
|
+
*
|
|
61
|
+
* **CN:** 表单数据
|
|
62
|
+
*/
|
|
63
|
+
formData: FD,
|
|
64
|
+
/**
|
|
65
|
+
* **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get
|
|
66
|
+
* the value of the switch; for the `Button` type trigger, you can get the click event object
|
|
67
|
+
* of the button
|
|
68
|
+
*
|
|
69
|
+
* **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值;对于`Button`类型的触发器,可以获取按钮的点击事件对象
|
|
70
|
+
*/
|
|
71
|
+
...triggerEventData: any[]) => unknown | Promise<unknown>) => void;
|
|
72
|
+
/**
|
|
73
|
+
* **EN:** Listen to the open and close status of the dialog. When `destroyOnClose` is set to
|
|
74
|
+
* false, the form component instance is cached, and the dialog can only be listened to in this
|
|
75
|
+
* way
|
|
76
|
+
*
|
|
77
|
+
* **CN:** 监听弹框打开关闭状态。当`destroyOnClose`设置为false时,表单组件实例被缓存,只能通过这种方式监听弹框
|
|
78
|
+
*
|
|
79
|
+
* @param handler Event handler | 事件处理函数
|
|
80
|
+
*/
|
|
81
|
+
onOpenChange: (handler: ModalProps['afterOpenChange']) => void;
|
|
82
|
+
/**
|
|
83
|
+
* **EN:** Set the dialog open status
|
|
84
|
+
*
|
|
85
|
+
* **CN:** 设置弹框打开状态
|
|
86
|
+
*
|
|
87
|
+
* @param open Whether is open or not | 弹窗是否打开
|
|
88
|
+
*/
|
|
49
89
|
setOpen: (open: boolean) => void;
|
|
50
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* **EN:** Modify the properties of the dialog, such as title, width, button properties, etc.
|
|
92
|
+
*
|
|
93
|
+
* **CN:** 修改弹窗的属性,例如标题、宽度,按钮属性等
|
|
94
|
+
*/
|
|
51
95
|
updateModalProps: (props: Partial<ModalProps>) => void;
|
|
52
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get the
|
|
98
|
+
* value of the switch; for the `Button` type trigger, you can get the click event object of the
|
|
99
|
+
* button
|
|
100
|
+
*
|
|
101
|
+
* **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值,对于`Button`类型的触发器,可以获取按钮的点击事件对象
|
|
102
|
+
*/
|
|
53
103
|
triggerEventData?: any[];
|
|
54
104
|
}
|
|
55
105
|
export interface ModalActionTrigger<TP extends object, E extends keyof TP> {
|
|
@@ -22,7 +22,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
22
22
|
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
23
23
|
import { Button, Form, Modal, Switch, Typography } from 'antd';
|
|
24
24
|
import { isForwardRef } from 'react-is';
|
|
25
|
-
import
|
|
25
|
+
import useContextValidator from '../../hooks/useContextValidator';
|
|
26
26
|
/**
|
|
27
27
|
* **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when
|
|
28
28
|
* returning in the `onSave` event of the editing form component
|
|
@@ -38,7 +38,7 @@ export const genModalActionRenderer = (defaultProps) => {
|
|
|
38
38
|
let mergedProps = mergeProps(defaultProps, props);
|
|
39
39
|
mergedProps = mergeProps(mergedProps, userModalProps);
|
|
40
40
|
const { formComp, formProps, triggerComponent: Trigger = Button, triggerEvent = 'onClick', triggerProps, open: openInProps, destroyOnClose = true, maskClosable = false, onOk, afterOk, onCancel, onClose, children } = mergedProps, restProps = __rest(mergedProps, ["formComp", "formProps", "triggerComponent", "triggerEvent", "triggerProps", "open", "destroyOnClose", "maskClosable", "onOk", "afterOk", "onCancel", "onClose", "children"]);
|
|
41
|
-
|
|
41
|
+
useContextValidator();
|
|
42
42
|
const FormComp = formComp;
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
44
|
const triggerEventArgsRef = useRef(undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ModalAction/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ModalAction/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElG,OAAO,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|
package/es/components/index.js
CHANGED
|
@@ -6,4 +6,5 @@ export { default as ConfirmAction } from './ConfirmAction';
|
|
|
6
6
|
export { default as DeleteConfirmAction } from './DeleteConfirmAction';
|
|
7
7
|
export { withDefaultModalActionProps, withModalAction } from './ModalAction';
|
|
8
8
|
export { default as ModalAction } from './ModalAction';
|
|
9
|
+
// export * from '../utils';
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3D,yCAAyC;AACzC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3D,yCAAyC;AACzC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AAEvD,4BAA4B"}
|
package/es/hooks/index.d.ts
CHANGED
package/es/hooks/index.js
CHANGED
package/es/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAI7D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
const context = useContext(
|
|
2
|
+
import ReactEasyContext, { defaultContextValue } from '../components/ConfigProvider/context';
|
|
3
|
+
const useContextValidator = () => {
|
|
4
|
+
const context = useContext(ReactEasyContext);
|
|
5
5
|
if (!context || context === defaultContextValue) {
|
|
6
6
|
console.warn(`ConfigProvider should be wrapped outside of any components of @tiny-codes/react-easy!
|
|
7
7
|
|
|
@@ -12,5 +12,5 @@ import { ConfigProvider } from '@tiny-codes/react-easy';
|
|
|
12
12
|
}
|
|
13
13
|
return context;
|
|
14
14
|
};
|
|
15
|
-
export default
|
|
16
|
-
//# sourceMappingURL=
|
|
15
|
+
export default useContextValidator;
|
|
16
|
+
//# sourceMappingURL=useContextValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContextValidator.js","sourceRoot":"","sources":["../../src/hooks/useContextValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,gBAAgB,EAAE,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE7F,MAAM,mBAAmB,GAAG,GAAG,EAAE;IAC/B,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,mBAAmB,EAAE,CAAC;QAChD,OAAO,CAAC,IAAI,CACV;;;;;kBAKY,CACb,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ReactEasyContextProps } from '../components/ConfigProvider/context';
|
|
2
2
|
/**
|
|
3
3
|
* A custom hook that converts input content to localized text using the localize method from
|
|
4
4
|
* AntdHelperContext
|
|
@@ -7,5 +7,5 @@ import { type AntHelperContextProps } from '../components/ConfigProvider/context
|
|
|
7
7
|
*
|
|
8
8
|
* @returns The localized text
|
|
9
9
|
*/
|
|
10
|
-
declare const useLocalizedText: NonNullable<
|
|
10
|
+
declare const useLocalizedText: NonNullable<ReactEasyContextProps['localize']>;
|
|
11
11
|
export default useLocalizedText;
|