@tiny-codes/react-easy 1.0.2 → 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 (98) hide show
  1. package/CHANGELOG.md +23 -1
  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.d.ts +5 -1
  17. package/es/components/index.js +10 -7
  18. package/es/components/index.js.map +1 -1
  19. package/es/hooks/index.js +4 -4
  20. package/es/hooks/index.js.map +1 -1
  21. package/es/hooks/useContextValidator.js +7 -12
  22. package/es/hooks/useContextValidator.js.map +1 -1
  23. package/es/hooks/useLocalizedText.js +6 -4
  24. package/es/hooks/useLocalizedText.js.map +1 -1
  25. package/es/hooks/useRefFunction.js +13 -6
  26. package/es/hooks/useRefFunction.js.map +1 -1
  27. package/es/hooks/useT.js +11 -8
  28. package/es/hooks/useT.js.map +1 -1
  29. package/es/hooks/useValidator.js +7 -4
  30. package/es/hooks/useValidator.js.map +1 -1
  31. package/es/hooks/useValidatorBuilder.js +146 -117
  32. package/es/hooks/useValidatorBuilder.js.map +1 -1
  33. package/es/hooks/useValidators.js +94 -58
  34. package/es/hooks/useValidators.js.map +1 -1
  35. package/es/index.js +2 -2
  36. package/es/index.js.map +1 -1
  37. package/es/locales/index.js +19 -13
  38. package/es/locales/index.js.map +1 -1
  39. package/es/locales/langs/en-US.js +20 -20
  40. package/es/locales/langs/en-US.js.map +1 -1
  41. package/es/locales/langs/en.js +1 -1
  42. package/es/locales/langs/en.js.map +1 -1
  43. package/es/locales/langs/zh-CN.js +20 -20
  44. package/es/locales/langs/zh-CN.js.map +1 -1
  45. package/es/utils/index.js +1 -1
  46. package/es/utils/index.js.map +1 -1
  47. package/lib/components/BreakLines/index.js +50 -37
  48. package/lib/components/BreakLines/index.js.map +7 -1
  49. package/lib/components/ConfigProvider/context.js +35 -6
  50. package/lib/components/ConfigProvider/context.js.map +7 -1
  51. package/lib/components/ConfigProvider/index.js +56 -42
  52. package/lib/components/ConfigProvider/index.js.map +7 -1
  53. package/lib/components/ConfirmAction/index.d.ts +74 -6
  54. package/lib/components/ConfirmAction/index.js +194 -138
  55. package/lib/components/ConfirmAction/index.js.map +7 -1
  56. package/lib/components/DeleteConfirmAction/index.js +50 -51
  57. package/lib/components/DeleteConfirmAction/index.js.map +7 -1
  58. package/lib/components/ModalAction/index.d.ts +45 -5
  59. package/lib/components/ModalAction/index.js +303 -243
  60. package/lib/components/ModalAction/index.js.map +7 -1
  61. package/lib/components/index.d.ts +5 -1
  62. package/lib/components/index.js +63 -10
  63. package/lib/components/index.js.map +7 -1
  64. package/lib/hooks/index.js +49 -5
  65. package/lib/hooks/index.js.map +7 -1
  66. package/lib/hooks/useContextValidator.js +47 -11
  67. package/lib/hooks/useContextValidator.js.map +7 -1
  68. package/lib/hooks/useLocalizedText.js +41 -15
  69. package/lib/hooks/useLocalizedText.js.map +7 -1
  70. package/lib/hooks/useRefFunction.js +34 -21
  71. package/lib/hooks/useRefFunction.js.map +7 -1
  72. package/lib/hooks/useT.js +43 -11
  73. package/lib/hooks/useT.js.map +7 -1
  74. package/lib/hooks/useValidator.js +41 -12
  75. package/lib/hooks/useValidator.js.map +7 -1
  76. package/lib/hooks/useValidatorBuilder.js +149 -132
  77. package/lib/hooks/useValidatorBuilder.js.map +7 -1
  78. package/lib/hooks/useValidators.js +104 -67
  79. package/lib/hooks/useValidators.js.map +7 -1
  80. package/lib/index.js +26 -3
  81. package/lib/index.js.map +7 -1
  82. package/lib/locales/index.js +58 -15
  83. package/lib/locales/index.js.map +7 -1
  84. package/lib/locales/langs/en-US.js +46 -22
  85. package/lib/locales/langs/en-US.js.map +7 -1
  86. package/lib/locales/langs/en.js +37 -3
  87. package/lib/locales/langs/en.js.map +7 -1
  88. package/lib/locales/langs/zh-CN.js +46 -22
  89. package/lib/locales/langs/zh-CN.js.map +7 -1
  90. package/lib/utils/index.js +1 -2
  91. package/lib/utils/index.js.map +7 -1
  92. package/package.json +14 -15
  93. package/es/hooks/useValidateContext.d.ts +0 -2
  94. package/es/hooks/useValidateContext.js +0 -16
  95. package/es/hooks/useValidateContext.js.map +0 -1
  96. package/lib/hooks/useValidateContext.d.ts +0 -2
  97. package/lib/hooks/useValidateContext.js +0 -16
  98. package/lib/hooks/useValidateContext.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,13 +2,35 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## 1.0.4
6
+
7
+ 2025-3-28
8
+
9
+ ### Features
10
+
11
+ - 🔥 Add `triggerProps.show` prop to `ModalAction` component
12
+ - 🔥 Add `danger` prop to `ConfirmAction` and `DeleteConfirmAction` components
13
+
14
+ ### Bug Fixes
15
+
16
+ - 🐞 Fix key warning in `BreakLines`
17
+
18
+ ## 1.0.3
19
+
20
+ 2025-2-17
21
+
22
+ ### Features
23
+
24
+ - 🔥 Adds `BreakLines` component
25
+
5
26
  ## 1.0.2
6
27
 
7
28
  2025-2-17
8
29
 
9
30
  ### Features
10
31
 
11
- - 🔥 Adds `BreakLines` 组件
32
+ - 🔥 adds `useValidator` to build a custom validator
33
+ - 🔥 adds `useValidatorBuilder` to get a function that builds a custom validator
12
34
 
13
35
  ## 1.0.1
14
36
 
@@ -1,5 +1,7 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { createElement } from 'react';
1
+ import { createElement, Fragment } from 'react';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { jsxs as _jsxs } from "react/jsx-runtime";
4
+ import { Fragment as _Fragment } from "react/jsx-runtime";
3
5
  /**
4
6
  * **EN:** Output a piece of text, keeping line breaks
5
7
  *
@@ -9,32 +11,47 @@ import { createElement } from 'react';
9
11
  * <BreakLines value="hello \n world" />;
10
12
  * // hello <br/> world
11
13
  */
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 {
14
+ var BreakLines = function BreakLines(props) {
15
+ var value = props.value,
16
+ className = props.className,
17
+ _props$tagName = props.tagName,
18
+ tagName = _props$tagName === void 0 ? false : _props$tagName,
19
+ _props$enabled = props.enabled,
20
+ enabled = _props$enabled === void 0 ? true : _props$enabled,
21
+ _props$EOL = props.EOL,
22
+ EOL = _props$EOL === void 0 ? '\n' : _props$EOL;
23
+ var content;
24
+ if (value) {
25
+ if (enabled) {
26
+ if (value.includes(EOL)) {
27
+ var segments = value === null || value === void 0 ? void 0 : value.split(EOL);
28
+ content = segments.map(function (str, i) {
29
+ return (
30
+ /*#__PURE__*/
31
+ // eslint-disable-next-line react/no-array-index-key
32
+ _jsxs(Fragment, {
33
+ children: [str, i !== segments.length - 1 && /*#__PURE__*/_jsx("br", {})]
34
+ }, "".concat(str, ":").concat(i))
35
+ );
36
+ });
37
+ } else {
30
38
  content = value;
39
+ }
40
+ } else {
41
+ content = value;
31
42
  }
32
- if (tagName) {
33
- return createElement(tagName, { className }, content);
34
- }
35
- else {
36
- return _jsx(_Fragment, { children: content });
37
- }
43
+ } else {
44
+ content = value;
45
+ }
46
+ if (tagName) {
47
+ return /*#__PURE__*/createElement(tagName, {
48
+ className: className
49
+ }, content);
50
+ } else {
51
+ return /*#__PURE__*/_jsx(_Fragment, {
52
+ children: content
53
+ });
54
+ }
38
55
  };
39
56
  export default BreakLines;
40
57
  //# sourceMappingURL=index.js.map
@@ -1 +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
+ {"version":3,"names":["createElement","Fragment","jsx","_jsx","jsxs","_jsxs","_Fragment","BreakLines","props","value","className","_props$tagName","tagName","_props$enabled","enabled","_props$EOL","EOL","content","includes","segments","split","map","str","i","children","length","concat"],"sources":["../../../src/components/BreakLines/index.tsx"],"sourcesContent":["import { createElement, type FC, Fragment, type ReactNode } from 'react';\n\nexport interface BreakLinesProps {\n /**\n * **EN:** Text content\n *\n * **CN:** 文本内容\n */\n value: string | undefined;\n /**\n * **EN:** Whether to enable line breaking\n *\n * **CN:** 是否启用换行功能\n *\n * @default true\n */\n enabled?: boolean;\n /**\n * **EN:** Line break character\n *\n * **CN:** 换行符\n *\n * @default '\\n'\n */\n EOL?: string;\n /**\n * **CN:** 渲染dom节点的标签名\n *\n * **EN:** Render the tag name of the DOM node\n *\n * @default false\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n tagName?: 'span' | 'div' | 'i' | 'pre' | (string & {}) | false;\n /**\n * **EN:** The CSS class name of the dom node, if `tagName` is set to false, this property is\n * invalid\n *\n * **CN:** dom节点的css类名,如果`tagName`设置为false,则此属性无效\n */\n className?: string;\n}\n\n/**\n * **EN:** Output a piece of text, keeping line breaks\n *\n * **CN:** 输出一段文本,保留换行符\n *\n * @example\n * <BreakLines value=\"hello \\n world\" />;\n * // hello <br/> world\n */\nconst BreakLines: FC<BreakLinesProps> = (props) => {\n const { value, className, tagName = false, enabled = true, EOL = '\\n' } = props;\n\n let content: ReactNode;\n if (value) {\n if (enabled) {\n if (value.includes(EOL)) {\n const segments = value?.split(EOL);\n content = segments.map((str, i) => (\n // eslint-disable-next-line react/no-array-index-key\n <Fragment key={`${str}:${i}`}>\n {str}\n {i !== segments.length - 1 && <br />}\n </Fragment>\n ));\n } else {\n content = value;\n }\n } else {\n content = value;\n }\n } else {\n content = value;\n }\n\n if (tagName) {\n return createElement(tagName, { className }, content);\n } else {\n return <>{content}</>;\n }\n};\n\nexport default BreakLines;\n"],"mappings":"AAAA,SAASA,aAAa,EAAWC,QAAQ,QAAwB,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAAA,SAAAJ,QAAA,IAAAK,SAAA;AA2CzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,UAA+B,GAAG,SAAlCA,UAA+BA,CAAIC,KAAK,EAAK;EACjD,IAAQC,KAAK,GAA6DD,KAAK,CAAvEC,KAAK;IAAEC,SAAS,GAAkDF,KAAK,CAAhEE,SAAS;IAAAC,cAAA,GAAkDH,KAAK,CAArDI,OAAO;IAAPA,OAAO,GAAAD,cAAA,cAAG,KAAK,GAAAA,cAAA;IAAAE,cAAA,GAAiCL,KAAK,CAApCM,OAAO;IAAPA,OAAO,GAAAD,cAAA,cAAG,IAAI,GAAAA,cAAA;IAAAE,UAAA,GAAiBP,KAAK,CAApBQ,GAAG;IAAHA,GAAG,GAAAD,UAAA,cAAG,IAAI,GAAAA,UAAA;EAErE,IAAIE,OAAkB;EACtB,IAAIR,KAAK,EAAE;IACT,IAAIK,OAAO,EAAE;MACX,IAAIL,KAAK,CAACS,QAAQ,CAACF,GAAG,CAAC,EAAE;QACvB,IAAMG,QAAQ,GAAGV,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEW,KAAK,CAACJ,GAAG,CAAC;QAClCC,OAAO,GAAGE,QAAQ,CAACE,GAAG,CAAC,UAACC,GAAG,EAAEC,CAAC;UAAA;YAAA;YAC5B;YACAlB,KAAA,CAACJ,QAAQ;cAAAuB,QAAA,GACNF,GAAG,EACHC,CAAC,KAAKJ,QAAQ,CAACM,MAAM,GAAG,CAAC,iBAAItB,IAAA,SAAK,CAAC;YAAA,MAAAuB,MAAA,CAFpBJ,GAAG,OAAAI,MAAA,CAAIH,CAAC,CAGhB;UAAC;QAAA,CACZ,CAAC;MACJ,CAAC,MAAM;QACLN,OAAO,GAAGR,KAAK;MACjB;IACF,CAAC,MAAM;MACLQ,OAAO,GAAGR,KAAK;IACjB;EACF,CAAC,MAAM;IACLQ,OAAO,GAAGR,KAAK;EACjB;EAEA,IAAIG,OAAO,EAAE;IACX,oBAAOZ,aAAa,CAACY,OAAO,EAAE;MAAEF,SAAS,EAATA;IAAU,CAAC,EAAEO,OAAO,CAAC;EACvD,CAAC,MAAM;IACL,oBAAOd,IAAA,CAAAG,SAAA;MAAAkB,QAAA,EAAGP;IAAO,CAAG,CAAC;EACvB;AACF,CAAC;AAED,eAAeV,UAAU"}
@@ -1,7 +1,7 @@
1
1
  import { createContext } from 'react';
2
- export const defaultContextValue = {
3
- lang: 'en',
2
+ export var defaultContextValue = {
3
+ lang: 'en'
4
4
  };
5
- const ReactEasyContext = createContext(defaultContextValue);
5
+ var ReactEasyContext = /*#__PURE__*/createContext(defaultContextValue);
6
6
  export default ReactEasyContext;
7
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;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
+ {"version":3,"names":["createContext","defaultContextValue","lang","ReactEasyContext"],"sources":["../../../src/components/ConfigProvider/context.tsx"],"sourcesContent":["import { createContext, type ReactNode } from 'react';\nimport type { Langs } from '../../locales';\n\nexport interface ReactEasyContextProps {\n /**\n * **EN:** Language of the component, used for global configuration, can be 'en-US' or 'zh-CN'\n *\n * **CN:** 组件的语言,用于全局配置,可以是'en-US'或'zh-CN'\n */\n lang?: Langs;\n /**\n * **EN:** Default title of the confirm dialog, used for global configuration, can be normal text\n * or the key of localized resources, the key of localized resources will be converted into\n * localized text through the `localize` method\n *\n * **CN:** 确认弹框的默认标题,用于全局配置,可以是普通文本或本地化资源的键值,本地化资源的键值会通过`localize`方法转换成本地化文本\n */\n defaultConfirmTitle?: ReactNode;\n /**\n * **EN:** Default content of the confirm dialog, used for global configuration, can be normal\n * text or the key of localized resources, the key of localized resources will be converted into\n * localized text through the `localize` method\n *\n * **CN:** 确认弹框的默认内容,用于全局配置,可以是普通文本或本地化资源的键值,本地化资源的键值会通过`localize`方法转换成本地化文本\n */\n defaultConfirmContent?: ReactNode;\n\n /**\n * **EN:** Default title of the deletion confirmation dialog, used for global configuration, can\n * be normal text or the key of localized resources, the key of localized resources will be\n * converted into localized text through the `localize` method\n *\n * **CN:** 删除确认弹框的默认标题,用于全局配置,可以是普通文本或本地化资源的键值,本地化资源的键值会通过`localize`方法转换成本地化文本\n */\n defaultDeletionConfirmTitle?: ReactNode;\n\n /**\n * **EN:** Default content of the deletion confirmation dialog, used for global configuration, can\n * be normal text or the key of localized resources, the key of localized resources will be\n * converted into localized text through the `localize` method\n *\n * **CN:** 删除确认弹框的默认内容,用于全局配置,可以是普通文本或本地化资源的键值,本地化资源的键值会通过`localize`方法转换成本地化文本\n */\n defaultDeletionConfirmContent?: ReactNode;\n\n // /** 获取本地化文本 */\n /**\n * **EN:** Get localized text\n *\n * **CN:** 获取本地化文本\n *\n * @param key Normal text or key of local resource | 普通文本或本地资源的键值\n * @param args Parameters of the localized text | 本地化文本的参数\n *\n * @returns Localized text | 本地化文本\n */\n localize?: <T>(key: T, args?: Record<string, unknown>) => ReactNode;\n}\n\nexport const defaultContextValue: ReactEasyContextProps = {\n lang: 'en',\n};\n\nconst ReactEasyContext = createContext<ReactEasyContextProps>(defaultContextValue);\n\nexport default ReactEasyContext;\n"],"mappings":"AAAA,SAASA,aAAa,QAAwB,OAAO;AA2DrD,OAAO,IAAMC,mBAA0C,GAAG;EACxDC,IAAI,EAAE;AACR,CAAC;AAED,IAAMC,gBAAgB,gBAAGH,aAAa,CAAwBC,mBAAmB,CAAC;AAElF,eAAeE,gBAAgB"}
@@ -1,44 +1,46 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["children", "locales"];
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
10
  import { useEffect } from 'react';
14
- import locales, { langs, resources } from '../../locales';
15
- import ReactEasyContext from './context';
11
+ import locales, { langs, resources } from "../../locales";
12
+ import ReactEasyContext from "./context";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
16
14
  /**
17
15
  * **EN:** Provide global configuration for AntdHelper
18
16
  *
19
17
  * **CN:** 提供AntdHelper的全局配置
20
18
  */
21
- const ConfigProvider = (props) => {
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 });
19
+ var ConfigProvider = function ConfigProvider(props) {
20
+ var children = props.children,
21
+ userLocales = props.locales,
22
+ restProps = _objectWithoutProperties(props, _excluded);
23
+ var langInProps = restProps.lang;
24
+ useEffect(function () {
25
+ // Dynamically add language pack
26
+ if (userLocales) {
27
+ var lang = langInProps || 'en';
28
+ if (lang && langs.includes(lang)) {
29
+ locales.removeResourceBundle(lang, 'translation');
30
+ locales.addResourceBundle(lang, 'translation', _objectSpread(_objectSpread({}, resources[lang].translation), userLocales));
31
+ } else {
32
+ locales.addResourceBundle(lang, 'translation', _objectSpread(_objectSpread({}, resources.en.translation), userLocales));
33
+ }
34
+ }
35
+ }, [langInProps, userLocales]);
36
+ useEffect(function () {
37
+ // Set the language of the component
38
+ locales.changeLanguage(langInProps || 'en');
39
+ }, [langInProps]);
40
+ return /*#__PURE__*/_jsx(ReactEasyContext.Provider, {
41
+ value: restProps,
42
+ children: children
43
+ });
42
44
  };
43
45
  export default ConfigProvider;
44
46
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"names":["useEffect","locales","langs","resources","ReactEasyContext","jsx","_jsx","ConfigProvider","props","children","userLocales","restProps","_objectWithoutProperties","_excluded","langInProps","lang","includes","removeResourceBundle","addResourceBundle","_objectSpread","translation","en","changeLanguage","Provider","value"],"sources":["../../../src/components/ConfigProvider/index.tsx"],"sourcesContent":["import { type FC, type ReactNode, useEffect } from 'react';\nimport locales, { langs, resources } from '../../locales';\nimport type localesEn from '../../locales/langs/en';\nimport ReactEasyContext, { type ReactEasyContextProps } from './context';\n\nexport interface ConfigProviderProps extends ReactEasyContextProps {\n /**\n * **EN:** Custom localization resources, if `lang` exists, it will override the localization\n * resources of that language, otherwise, it will add a new language\n *\n * **CN:** 自定义本地化资源,如果`lang`存在,则会覆盖该语言的本地化资源,否则,会添加一种新的语言\n */\n locales?: Partial<typeof localesEn>;\n children: ReactNode;\n}\n\n/**\n * **EN:** Provide global configuration for AntdHelper\n *\n * **CN:** 提供AntdHelper的全局配置\n */\nconst ConfigProvider: FC<ConfigProviderProps> = (props) => {\n const { children, locales: userLocales, ...restProps } = props;\n const { lang: langInProps } = restProps;\n\n useEffect(() => {\n // Dynamically add language pack\n if (userLocales) {\n const lang = langInProps || 'en';\n if (lang && langs.includes(lang)) {\n locales.removeResourceBundle(lang, 'translation');\n locales.addResourceBundle(lang, 'translation', { ...resources[lang].translation, ...userLocales });\n } else {\n locales.addResourceBundle(lang, 'translation', { ...resources.en.translation, ...userLocales });\n }\n }\n }, [langInProps, userLocales]);\n\n useEffect(() => {\n // Set the language of the component\n locales.changeLanguage(langInProps || 'en');\n }, [langInProps]);\n\n return <ReactEasyContext.Provider value={restProps}>{children}</ReactEasyContext.Provider>;\n};\n\nexport default ConfigProvider;\n"],"mappings":";;;;;;;;;AAAA,SAAkCA,SAAS,QAAQ,OAAO;AAC1D,OAAOC,OAAO,IAAIC,KAAK,EAAEC,SAAS;AAElC,OAAOC,gBAAgB;AAAkD,SAAAC,GAAA,IAAAC,IAAA;AAazE;AACA;AACA;AACA;AACA;AACA,IAAMC,cAAuC,GAAG,SAA1CA,cAAuCA,CAAIC,KAAK,EAAK;EACzD,IAAQC,QAAQ,GAAyCD,KAAK,CAAtDC,QAAQ;IAAWC,WAAW,GAAmBF,KAAK,CAA5CP,OAAO;IAAkBU,SAAS,GAAAC,wBAAA,CAAKJ,KAAK,EAAAK,SAAA;EAC9D,IAAcC,WAAW,GAAKH,SAAS,CAA/BI,IAAI;EAEZf,SAAS,CAAC,YAAM;IACd;IACA,IAAIU,WAAW,EAAE;MACf,IAAMK,IAAI,GAAGD,WAAW,IAAI,IAAI;MAChC,IAAIC,IAAI,IAAIb,KAAK,CAACc,QAAQ,CAACD,IAAI,CAAC,EAAE;QAChCd,OAAO,CAACgB,oBAAoB,CAACF,IAAI,EAAE,aAAa,CAAC;QACjDd,OAAO,CAACiB,iBAAiB,CAACH,IAAI,EAAE,aAAa,EAAAI,aAAA,CAAAA,aAAA,KAAOhB,SAAS,CAACY,IAAI,CAAC,CAACK,WAAW,GAAKV,WAAW,CAAE,CAAC;MACpG,CAAC,MAAM;QACLT,OAAO,CAACiB,iBAAiB,CAACH,IAAI,EAAE,aAAa,EAAAI,aAAA,CAAAA,aAAA,KAAOhB,SAAS,CAACkB,EAAE,CAACD,WAAW,GAAKV,WAAW,CAAE,CAAC;MACjG;IACF;EACF,CAAC,EAAE,CAACI,WAAW,EAAEJ,WAAW,CAAC,CAAC;EAE9BV,SAAS,CAAC,YAAM;IACd;IACAC,OAAO,CAACqB,cAAc,CAACR,WAAW,IAAI,IAAI,CAAC;EAC7C,CAAC,EAAE,CAACA,WAAW,CAAC,CAAC;EAEjB,oBAAOR,IAAA,CAACF,gBAAgB,CAACmB,QAAQ;IAACC,KAAK,EAAEb,SAAU;IAAAF,QAAA,EAAEA;EAAQ,CAA4B,CAAC;AAC5F,CAAC;AAED,eAAeF,cAAc"}
@@ -5,6 +5,18 @@ import type confirm from 'antd/es/modal/confirm';
5
5
  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
+ /**
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
+ *
13
+ * - You can explicitly set `titleColor`, `iconColor`, and `okButtonProps.type` to override
14
+ *
15
+ * **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。
16
+ *
17
+ * - 可以显式设置`titleColor`、`iconColor`和`okButtonProps.type`来覆盖
18
+ */
19
+ danger?: boolean;
8
20
  /**
9
21
  * **EN:** The color of confirm box title, default is `warning`
10
22
  *
@@ -85,7 +97,7 @@ export type ConfirmActionRef = ReturnType<typeof confirm> & {
85
97
  * @returns Component render method | 组件render方法
86
98
  */
87
99
  export declare const genRenderer: (defaultProps: Partial<ConfirmActionProps<any, never>> & {
88
- confirmType: "normal" | "delete";
100
+ confirmType: 'normal' | 'delete';
89
101
  }) => {
90
102
  <TP extends object, E extends keyof TP>(props: ConfirmActionProps<TP, E>, ref: ForwardedRef<ConfirmActionRef>): import("react/jsx-runtime").JSX.Element;
91
103
  displayName: string;
@@ -98,25 +110,37 @@ export declare const genRenderer: (defaultProps: Partial<ConfirmActionProps<any,
98
110
  * @param WrappedComponent ConfirmAction component | ConfirmAction组件
99
111
  * @param defaultProps Default properties | 默认属性
100
112
  */
101
- 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> & {
113
+ export declare const withDefaultConfirmActionProps: <TP extends object, E extends keyof TP>(WrappedComponent: ComponentType<Omit<ModalFuncProps, "onOk"> & ConfirmActionTrigger<TP, E> & {
114
+ /**
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
+ *
119
+ * - You can explicitly set `titleColor`, `iconColor`, and `okButtonProps.type` to override
120
+ *
121
+ * **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。
122
+ *
123
+ * - 可以显式设置`titleColor`、`iconColor`和`okButtonProps.type`来覆盖
124
+ */
125
+ danger?: boolean | undefined;
102
126
  /**
103
127
  * **EN:** The color of confirm box title, default is `warning`
104
128
  *
105
129
  * **CN:** 弹框标题颜色,默认`warning`
106
130
  */
107
- titleColor?: TextProps["type"] | "primary";
131
+ titleColor?: TextProps['type'] | 'primary';
108
132
  /**
109
133
  * **EN:** The color of confirm box content
110
134
  *
111
135
  * **CN:** 弹框内容文本颜色
112
136
  */
113
- contentColor?: TextProps["type"] | "primary";
137
+ contentColor?: TextProps['type'] | 'primary';
114
138
  /**
115
139
  * **EN:** The color of confirm box title icon, default is the same as `titleColor`
116
140
  *
117
141
  * **CN:** 弹框标题图标颜色,默认与`titleColor`相同
118
142
  */
119
- iconColor?: TextProps["type"] | "primary";
143
+ iconColor?: TextProps['type'] | 'primary';
120
144
  /**
121
145
  * **EN:** Callback when click confirm button
122
146
  *
@@ -129,7 +153,51 @@ export declare const withDefaultConfirmActionProps: <TP extends object, E extend
129
153
  *
130
154
  * **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值
131
155
  */
132
- afterOk?: (data?: any) => void;
156
+ afterOk?: ((data?: any) => void) | undefined;
157
+ } & RefAttributes<ConfirmActionRef>>, defaultProps?: Partial<ConfirmActionProps<TP, E>> | undefined) => import("react").ForwardRefExoticComponent<Omit<ModalFuncProps, "onOk"> & ConfirmActionTrigger<TP, E> & {
158
+ /**
159
+ * **EN:** Whether to display in red danger mode, which will automatically affect the color of
160
+ * the title, icon, and confirm button. Default is `false`, for DeleteConfirmAction, the
161
+ * defaults is `true`.
162
+ *
163
+ * - You can explicitly set `titleColor`, `iconColor`, and `okButtonProps.type` to override
164
+ *
165
+ * **CN:** 是否显示为红色危险模式,会自动影响标题、图标和确认按钮的颜色。默认`false`,DeleteConfirmAction组件的默认值为`true`。
166
+ *
167
+ * - 可以显式设置`titleColor`、`iconColor`和`okButtonProps.type`来覆盖
168
+ */
169
+ danger?: boolean | undefined;
170
+ /**
171
+ * **EN:** The color of confirm box title, default is `warning`
172
+ *
173
+ * **CN:** 弹框标题颜色,默认`warning`
174
+ */
175
+ titleColor?: TextProps['type'] | 'primary';
176
+ /**
177
+ * **EN:** The color of confirm box content
178
+ *
179
+ * **CN:** 弹框内容文本颜色
180
+ */
181
+ contentColor?: TextProps['type'] | 'primary';
182
+ /**
183
+ * **EN:** The color of confirm box title icon, default is the same as `titleColor`
184
+ *
185
+ * **CN:** 弹框标题图标颜色,默认与`titleColor`相同
186
+ */
187
+ iconColor?: TextProps['type'] | 'primary';
188
+ /**
189
+ * **EN:** Callback when click confirm button
190
+ *
191
+ * **CN:** 点击确认按钮的回调
192
+ */
193
+ onOk?: ((...args: Parameters<TP[E]>) => unknown | Promise<unknown>) | undefined;
194
+ /**
195
+ * **EN:** Callback after confirm event, won't trigger if failed, the argument is the return
196
+ * value of `onOk`
197
+ *
198
+ * **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值
199
+ */
200
+ afterOk?: ((data?: any) => void) | undefined;
133
201
  } & RefAttributes<ConfirmActionRef>>;
134
202
  /**
135
203
  * **EN:** Interface of generic type component