@tiny-codes/react-easy 1.1.2 → 1.2.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.
Files changed (140) hide show
  1. package/CHANGELOG.md +24 -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 +66 -89
  11. package/es/components/ConfirmAction/index.js +27 -18
  12. package/es/components/ConfirmAction/index.js.map +1 -1
  13. package/es/components/ContextMenu/index.d.ts +42 -0
  14. package/es/components/ContextMenu/index.js +188 -0
  15. package/es/components/ContextMenu/index.js.map +1 -0
  16. package/es/components/ContextMenu/style/index.d.ts +3 -0
  17. package/es/components/ContextMenu/style/index.js +25 -0
  18. package/es/components/ContextMenu/style/index.js.map +1 -0
  19. package/es/components/DeleteConfirmAction/index.d.ts +2 -3
  20. package/es/components/DeleteConfirmAction/index.js +8 -12
  21. package/es/components/DeleteConfirmAction/index.js.map +1 -1
  22. package/es/components/EditableText/form.d.ts +150 -0
  23. package/es/components/EditableText/form.js +359 -0
  24. package/es/components/EditableText/form.js.map +1 -0
  25. package/es/components/EditableText/index.d.ts +160 -0
  26. package/es/components/EditableText/index.js +222 -0
  27. package/es/components/EditableText/index.js.map +1 -0
  28. package/es/components/EditableText/style/index.d.ts +3 -0
  29. package/es/components/EditableText/style/index.js +76 -0
  30. package/es/components/EditableText/style/index.js.map +1 -0
  31. package/es/components/FloatDrawer/index.d.ts +89 -86
  32. package/es/components/FloatDrawer/index.js +43 -20
  33. package/es/components/FloatDrawer/index.js.map +1 -1
  34. package/es/components/FloatDrawer/style/index.js +42 -21
  35. package/es/components/FloatDrawer/style/index.js.map +1 -1
  36. package/es/components/Loading/index.d.ts +9 -14
  37. package/es/components/Loading/index.js +7 -6
  38. package/es/components/Loading/index.js.map +1 -1
  39. package/es/components/Loading/style/index.js +1 -1
  40. package/es/components/Loading/style/index.js.map +1 -1
  41. package/es/components/ModalAction/index.d.ts +98 -139
  42. package/es/components/ModalAction/index.js +25 -37
  43. package/es/components/ModalAction/index.js.map +1 -1
  44. package/es/components/OverflowTags/index.d.ts +30 -8
  45. package/es/components/OverflowTags/index.js +26 -7
  46. package/es/components/OverflowTags/index.js.map +1 -1
  47. package/es/components/OverflowTags/style/index.js +1 -1
  48. package/es/components/OverflowTags/style/index.js.map +1 -1
  49. package/es/components/index.d.ts +4 -0
  50. package/es/components/index.js +2 -0
  51. package/es/components/index.js.map +1 -1
  52. package/es/hooks/useRefFunction.d.ts +4 -5
  53. package/es/hooks/useRefFunction.js +6 -7
  54. package/es/hooks/useRefFunction.js.map +1 -1
  55. package/es/hooks/useRefValue.d.ts +2 -3
  56. package/es/hooks/useRefValue.js +2 -3
  57. package/es/hooks/useRefValue.js.map +1 -1
  58. package/es/hooks/useT.js +1 -2
  59. package/es/hooks/useT.js.map +1 -1
  60. package/es/hooks/useValidator.d.ts +2 -3
  61. package/es/hooks/useValidator.js +2 -3
  62. package/es/hooks/useValidator.js.map +1 -1
  63. package/es/hooks/useValidatorBuilder.d.ts +41 -61
  64. package/es/hooks/useValidatorBuilder.js +4 -6
  65. package/es/hooks/useValidatorBuilder.js.map +1 -1
  66. package/es/hooks/useValidators.d.ts +62 -83
  67. package/es/hooks/useValidators.js +3 -4
  68. package/es/hooks/useValidators.js.map +1 -1
  69. package/es/locales/index.d.ts +15 -0
  70. package/es/locales/langs/en-US.d.ts +5 -0
  71. package/es/locales/langs/en-US.js +5 -0
  72. package/es/locales/langs/en-US.js.map +1 -1
  73. package/es/locales/langs/zh-CN.d.ts +5 -0
  74. package/es/locales/langs/zh-CN.js +5 -0
  75. package/es/locales/langs/zh-CN.js.map +1 -1
  76. package/lib/components/BreakLines/index.d.ts +13 -19
  77. package/lib/components/BreakLines/index.js.map +2 -2
  78. package/lib/components/ConfigProvider/context.d.ts +20 -26
  79. package/lib/components/ConfigProvider/context.js.map +2 -2
  80. package/lib/components/ConfigProvider/index.d.ts +5 -7
  81. package/lib/components/ConfigProvider/index.js.map +2 -2
  82. package/lib/components/ConfirmAction/index.d.ts +66 -89
  83. package/lib/components/ConfirmAction/index.js +9 -0
  84. package/lib/components/ConfirmAction/index.js.map +2 -2
  85. package/lib/components/ContextMenu/index.d.ts +42 -0
  86. package/lib/components/ContextMenu/index.js +190 -0
  87. package/lib/components/ContextMenu/index.js.map +7 -0
  88. package/lib/components/ContextMenu/style/index.d.ts +3 -0
  89. package/lib/components/ContextMenu/style/index.js +48 -0
  90. package/lib/components/ContextMenu/style/index.js.map +7 -0
  91. package/lib/components/DeleteConfirmAction/index.d.ts +2 -3
  92. package/lib/components/DeleteConfirmAction/index.js.map +2 -2
  93. package/lib/components/EditableText/form.d.ts +150 -0
  94. package/lib/components/EditableText/form.js +253 -0
  95. package/lib/components/EditableText/form.js.map +7 -0
  96. package/lib/components/EditableText/index.d.ts +160 -0
  97. package/lib/components/EditableText/index.js +181 -0
  98. package/lib/components/EditableText/index.js.map +7 -0
  99. package/lib/components/EditableText/style/index.d.ts +3 -0
  100. package/lib/components/EditableText/style/index.js +118 -0
  101. package/lib/components/EditableText/style/index.js.map +7 -0
  102. package/lib/components/FloatDrawer/index.d.ts +89 -86
  103. package/lib/components/FloatDrawer/index.js +64 -39
  104. package/lib/components/FloatDrawer/index.js.map +2 -2
  105. package/lib/components/FloatDrawer/style/index.js +60 -23
  106. package/lib/components/FloatDrawer/style/index.js.map +2 -2
  107. package/lib/components/Loading/index.d.ts +9 -14
  108. package/lib/components/Loading/index.js +13 -4
  109. package/lib/components/Loading/index.js.map +2 -2
  110. package/lib/components/Loading/style/index.js +1 -1
  111. package/lib/components/Loading/style/index.js.map +2 -2
  112. package/lib/components/ModalAction/index.d.ts +98 -139
  113. package/lib/components/ModalAction/index.js.map +2 -2
  114. package/lib/components/OverflowTags/index.d.ts +30 -8
  115. package/lib/components/OverflowTags/index.js +7 -5
  116. package/lib/components/OverflowTags/index.js.map +2 -2
  117. package/lib/components/OverflowTags/style/index.js +1 -1
  118. package/lib/components/OverflowTags/style/index.js.map +2 -2
  119. package/lib/components/index.d.ts +4 -0
  120. package/lib/components/index.js +6 -0
  121. package/lib/components/index.js.map +2 -2
  122. package/lib/hooks/useRefFunction.d.ts +4 -5
  123. package/lib/hooks/useRefFunction.js.map +2 -2
  124. package/lib/hooks/useRefValue.d.ts +2 -3
  125. package/lib/hooks/useRefValue.js.map +2 -2
  126. package/lib/hooks/useT.js.map +2 -2
  127. package/lib/hooks/useValidator.d.ts +2 -3
  128. package/lib/hooks/useValidator.js.map +2 -2
  129. package/lib/hooks/useValidatorBuilder.d.ts +41 -61
  130. package/lib/hooks/useValidatorBuilder.js.map +2 -2
  131. package/lib/hooks/useValidators.d.ts +62 -83
  132. package/lib/hooks/useValidators.js.map +2 -2
  133. package/lib/locales/index.d.ts +15 -0
  134. package/lib/locales/langs/en-US.d.ts +5 -0
  135. package/lib/locales/langs/en-US.js +5 -0
  136. package/lib/locales/langs/en-US.js.map +2 -2
  137. package/lib/locales/langs/zh-CN.d.ts +5 -0
  138. package/lib/locales/langs/zh-CN.js +5 -0
  139. package/lib/locales/langs/zh-CN.js.map +2 -2
  140. package/package.json +3 -2
@@ -13,5 +13,5 @@ var genStyle = function genStyle(token) {
13
13
  position: 'relative'
14
14
  });
15
15
  };
16
- export default genStyleHooks('easy-overflow-tags', genStyle);
16
+ export default genStyleHooks('EasyOverflowTags', genStyle);
17
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["genStyleHooks","genStyle","token","componentCls","_defineProperty","display","flexWrap","width","maxWidth","position"],"sources":["../../../../src/components/OverflowTags/style/index.ts"],"sourcesContent":["import { genStyleHooks } from 'antd/es/theme/internal';\nimport type { AliasToken, GenerateStyle } from 'antd/es/theme/internal';\nimport type { CSSObject } from '@ant-design/cssinjs';\nimport type { FullToken } from '@ant-design/cssinjs-utils';\n\ntype OverflowTagsToken = FullToken<{ ''?: object }, AliasToken, ''>;\n\nconst genStyle: GenerateStyle<OverflowTagsToken> = (token): CSSObject => {\n const { componentCls } = token;\n return {\n [componentCls]: {\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n maxWidth: '100%',\n position: 'relative',\n },\n };\n};\n\nexport default genStyleHooks('easy-overflow-tags' as never, genStyle);\n"],"mappings":";;;;AAAA,SAASA,aAAa,QAAQ,wBAAwB;AAOtD,IAAMC,QAA0C,GAAG,SAA7CA,QAA0CA,CAAIC,KAAK,EAAgB;EACvE,IAAQC,YAAY,GAAKD,KAAK,CAAtBC,YAAY;EACpB,OAAAC,eAAA,KACGD,YAAY,EAAG;IACdE,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE,MAAM;IAChBC,KAAK,EAAE,MAAM;IACbC,QAAQ,EAAE,MAAM;IAChBC,QAAQ,EAAE;EACZ,CAAC;AAEL,CAAC;AAED,eAAeT,aAAa,CAAC,oBAAoB,EAAWC,QAAQ,CAAC"}
1
+ {"version":3,"names":["genStyleHooks","genStyle","token","componentCls","_defineProperty","display","flexWrap","width","maxWidth","position"],"sources":["../../../../src/components/OverflowTags/style/index.ts"],"sourcesContent":["import { genStyleHooks } from 'antd/es/theme/internal';\nimport type { AliasToken, GenerateStyle } from 'antd/es/theme/internal';\nimport type { CSSObject } from '@ant-design/cssinjs';\nimport type { FullToken } from '@ant-design/cssinjs-utils';\n\ntype OverflowTagsToken = FullToken<{ ''?: object }, AliasToken, ''>;\n\nconst genStyle: GenerateStyle<OverflowTagsToken> = (token): CSSObject => {\n const { componentCls } = token;\n return {\n [componentCls]: {\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n maxWidth: '100%',\n position: 'relative',\n },\n };\n};\n\nexport default genStyleHooks('EasyOverflowTags' as never, genStyle);\n"],"mappings":";;;;AAAA,SAASA,aAAa,QAAQ,wBAAwB;AAOtD,IAAMC,QAA0C,GAAG,SAA7CA,QAA0CA,CAAIC,KAAK,EAAgB;EACvE,IAAQC,YAAY,GAAKD,KAAK,CAAtBC,YAAY;EACpB,OAAAC,eAAA,KACGD,YAAY,EAAG;IACdE,OAAO,EAAE,MAAM;IACfC,QAAQ,EAAE,MAAM;IAChBC,KAAK,EAAE,MAAM;IACbC,QAAQ,EAAE,MAAM;IAChBC,QAAQ,EAAE;EACZ,CAAC;AAEL,CAAC;AAED,eAAeT,aAAa,CAAC,kBAAkB,EAAWC,QAAQ,CAAC"}
@@ -7,7 +7,11 @@ export { default as ReactEasyContext } from './ConfigProvider/context';
7
7
  export type { ConfirmActionProps, ConfirmActionTrigger, ConfirmActionRef } from './ConfirmAction';
8
8
  export { withDefaultConfirmActionProps } from './ConfirmAction';
9
9
  export { default as ConfirmAction } from './ConfirmAction';
10
+ export type { ContextMenuProps, ContextMenuItem, ContextMenuSeparator, ContextMenuSubmenu, ContextMenuRef, } from './ContextMenu';
11
+ export { default as ContextMenu } from './ContextMenu';
10
12
  export { default as DeleteConfirmAction } from './DeleteConfirmAction';
13
+ export type { EditableTextProps } from './EditableText';
14
+ export { default as EditableText } from './EditableText';
11
15
  export type { FloatDrawerProps } from './FloatDrawer';
12
16
  export { default as FloatDrawer } from './FloatDrawer';
13
17
  export type { LoadingProps } from './Loading';
@@ -3,9 +3,11 @@ export { default as ConfigProvider } from "./ConfigProvider";
3
3
  export { default as ReactEasyContext } from "./ConfigProvider/context";
4
4
  export { withDefaultConfirmActionProps } from "./ConfirmAction";
5
5
  export { default as ConfirmAction } from "./ConfirmAction";
6
+ export { default as ContextMenu } from "./ContextMenu";
6
7
 
7
8
  // export * from './DeleteConfirmAction';
8
9
  export { default as DeleteConfirmAction } from "./DeleteConfirmAction";
10
+ export { default as EditableText } from "./EditableText";
9
11
  export { default as FloatDrawer } from "./FloatDrawer";
10
12
  export { default as Loading } from "./Loading";
11
13
  export { withDefaultModalActionProps, withModalAction } from "./ModalAction";
@@ -1 +1 @@
1
- {"version":3,"names":["default","BreakLines","ConfigProvider","ReactEasyContext","withDefaultConfirmActionProps","ConfirmAction","DeleteConfirmAction","FloatDrawer","Loading","withDefaultModalActionProps","withModalAction","ModalAction","OverflowTags"],"sources":["../../src/components/index.tsx"],"sourcesContent":["export type { BreakLinesProps } from './BreakLines';\nexport { default as BreakLines } from './BreakLines';\n\nexport type { ConfigProviderProps } from './ConfigProvider';\nexport { default as ConfigProvider } from './ConfigProvider';\nexport type { ReactEasyContextProps } from './ConfigProvider/context';\nexport { default as ReactEasyContext } from './ConfigProvider/context';\n\nexport type { ConfirmActionProps, ConfirmActionTrigger, ConfirmActionRef } from './ConfirmAction';\nexport { withDefaultConfirmActionProps } from './ConfirmAction';\nexport { default as ConfirmAction } from './ConfirmAction';\n\n// export * from './DeleteConfirmAction';\nexport { default as DeleteConfirmAction } from './DeleteConfirmAction';\n\nexport type { FloatDrawerProps } from './FloatDrawer';\nexport { default as FloatDrawer } from './FloatDrawer';\n\nexport type { LoadingProps } from './Loading';\nexport { default as Loading } from './Loading';\n\nexport type { ModalActionProps, FormCompPropsConstraint, ModalActionTrigger, ModalActionRef } from './ModalAction';\nexport { withDefaultModalActionProps, withModalAction } from './ModalAction';\nexport { default as ModalAction } from './ModalAction';\n\nexport type { OverflowTagsProps } from './OverflowTags';\nexport { default as OverflowTags } from './OverflowTags';\n"],"mappings":"AACA,SAASA,OAAO,IAAIC,UAAU;AAG9B,SAASD,OAAO,IAAIE,cAAc;AAElC,SAASF,OAAO,IAAIG,gBAAgB;AAGpC,SAASC,6BAA6B;AACtC,SAASJ,OAAO,IAAIK,aAAa;;AAEjC;AACA,SAASL,OAAO,IAAIM,mBAAmB;AAGvC,SAASN,OAAO,IAAIO,WAAW;AAG/B,SAASP,OAAO,IAAIQ,OAAO;AAG3B,SAASC,2BAA2B,EAAEC,eAAe;AACrD,SAASV,OAAO,IAAIW,WAAW;AAG/B,SAASX,OAAO,IAAIY,YAAY"}
1
+ {"version":3,"names":["default","BreakLines","ConfigProvider","ReactEasyContext","withDefaultConfirmActionProps","ConfirmAction","ContextMenu","DeleteConfirmAction","EditableText","FloatDrawer","Loading","withDefaultModalActionProps","withModalAction","ModalAction","OverflowTags"],"sources":["../../src/components/index.tsx"],"sourcesContent":["export type { BreakLinesProps } from './BreakLines';\nexport { default as BreakLines } from './BreakLines';\n\nexport type { ConfigProviderProps } from './ConfigProvider';\nexport { default as ConfigProvider } from './ConfigProvider';\nexport type { ReactEasyContextProps } from './ConfigProvider/context';\nexport { default as ReactEasyContext } from './ConfigProvider/context';\n\nexport type { ConfirmActionProps, ConfirmActionTrigger, ConfirmActionRef } from './ConfirmAction';\nexport { withDefaultConfirmActionProps } from './ConfirmAction';\nexport { default as ConfirmAction } from './ConfirmAction';\n\nexport type {\n ContextMenuProps,\n ContextMenuItem,\n ContextMenuSeparator,\n ContextMenuSubmenu,\n ContextMenuRef,\n} from './ContextMenu';\nexport { default as ContextMenu } from './ContextMenu';\n\n// export * from './DeleteConfirmAction';\nexport { default as DeleteConfirmAction } from './DeleteConfirmAction';\n\nexport type { EditableTextProps } from './EditableText';\nexport { default as EditableText } from './EditableText';\n\nexport type { FloatDrawerProps } from './FloatDrawer';\nexport { default as FloatDrawer } from './FloatDrawer';\n\nexport type { LoadingProps } from './Loading';\nexport { default as Loading } from './Loading';\n\nexport type { ModalActionProps, FormCompPropsConstraint, ModalActionTrigger, ModalActionRef } from './ModalAction';\nexport { withDefaultModalActionProps, withModalAction } from './ModalAction';\nexport { default as ModalAction } from './ModalAction';\n\nexport type { OverflowTagsProps } from './OverflowTags';\nexport { default as OverflowTags } from './OverflowTags';\n"],"mappings":"AACA,SAASA,OAAO,IAAIC,UAAU;AAG9B,SAASD,OAAO,IAAIE,cAAc;AAElC,SAASF,OAAO,IAAIG,gBAAgB;AAGpC,SAASC,6BAA6B;AACtC,SAASJ,OAAO,IAAIK,aAAa;AASjC,SAASL,OAAO,IAAIM,WAAW;;AAE/B;AACA,SAASN,OAAO,IAAIO,mBAAmB;AAGvC,SAASP,OAAO,IAAIQ,YAAY;AAGhC,SAASR,OAAO,IAAIS,WAAW;AAG/B,SAAST,OAAO,IAAIU,OAAO;AAG3B,SAASC,2BAA2B,EAAEC,eAAe;AACrD,SAASZ,OAAO,IAAIa,WAAW;AAG/B,SAASb,OAAO,IAAIc,YAAY"}
@@ -1,9 +1,8 @@
1
1
  /**
2
- * **EN:** Generate an immutable function reference, the dependencies inside the function will be
3
- * updated in real time, but the function itself will not change, which is very useful when used as
4
- * a dependency of `useEffect`.
5
- *
6
- * **CN:** 生成一个引用不可变的函数,函数内部的依赖项会保持实时更新,但函数本身不会变化,在作为 `useEffect` 的依赖时非常有用
2
+ * - **EN:** Generate an immutable function reference, the dependencies inside the function will be
3
+ * updated in real time, but the function itself will not change, which is very useful when used
4
+ * as a dependency of `useEffect`.
5
+ * - **CN:** 生成一个引用不可变的函数,函数内部的依赖项会保持实时更新,但函数本身不会变化,在作为 `useEffect` 的依赖时非常有用
7
6
  *
8
7
  * @param fn Function body | 函数体
9
8
  *
@@ -1,11 +1,10 @@
1
1
  import { useCallback, useRef } from 'react';
2
2
 
3
3
  /**
4
- * **EN:** Generate an immutable function reference, the dependencies inside the function will be
5
- * updated in real time, but the function itself will not change, which is very useful when used as
6
- * a dependency of `useEffect`.
7
- *
8
- * **CN:** 生成一个引用不可变的函数,函数内部的依赖项会保持实时更新,但函数本身不会变化,在作为 `useEffect` 的依赖时非常有用
4
+ * - **EN:** Generate an immutable function reference, the dependencies inside the function will be
5
+ * updated in real time, but the function itself will not change, which is very useful when used
6
+ * as a dependency of `useEffect`.
7
+ * - **CN:** 生成一个引用不可变的函数,函数内部的依赖项会保持实时更新,但函数本身不会变化,在作为 `useEffect` 的依赖时非常有用
9
8
  *
10
9
  * @param fn Function body | 函数体
11
10
  *
@@ -15,8 +14,8 @@ import { useCallback, useRef } from 'react';
15
14
  var useRefFunction = function useRefFunction(fn) {
16
15
  var ref = useRef(fn);
17
16
  ref.current = fn;
18
- // eslint-disable-next-line eslint-comments/no-restricted-disable
19
- // eslint-disable-next-line react-hooks/exhaustive-deps
17
+
18
+ // eslint-disable-next-line @tiny-codes/react-hooks/exhaustive-deps
20
19
  return useCallback(function () {
21
20
  var _ref$current;
22
21
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useRef","useRefFunction","fn","ref","current","_ref$current","_len","arguments","length","args","Array","_key","call","apply","concat"],"sources":["../../src/hooks/useRefFunction.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\n\n/**\n * **EN:** Generate an immutable function reference, the dependencies inside the function will be\n * updated in real time, but the function itself will not change, which is very useful when used as\n * a dependency of `useEffect`.\n *\n * **CN:** 生成一个引用不可变的函数,函数内部的依赖项会保持实时更新,但函数本身不会变化,在作为 `useEffect` 的依赖时非常有用\n *\n * @param fn Function body | 函数体\n *\n * @returns An function with immutable reference | 引用不可变的函数\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst useRefFunction = <T extends (...args: any[]) => any>(fn: T | undefined) => {\n const ref = useRef<T | undefined>(fn);\n ref.current = fn;\n // eslint-disable-next-line eslint-comments/no-restricted-disable\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useCallback(((...args: any[]) => ref.current?.(...args)) as T, []);\n};\n\nexport default useRefFunction;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ,OAAO;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAuCC,EAAiB,EAAK;EAC/E,IAAMC,GAAG,GAAGH,MAAM,CAAgBE,EAAE,CAAC;EACrCC,GAAG,CAACC,OAAO,GAAGF,EAAE;EAChB;EACA;EACA,OAAOH,WAAW,CAAE;IAAA,IAAAM,YAAA;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAIC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAAA,QAAAN,YAAA,GAAYF,GAAG,CAACC,OAAO,cAAAC,YAAA,uBAAXA,YAAA,CAAAO,IAAA,CAAAC,KAAA,CAAAR,YAAA,GAAAF,GAAG,EAAAW,MAAA,CAAcL,IAAI,EAAC;EAAA,GAAQ,EAAE,CAAC;AAC3E,CAAC;AAED,eAAeR,cAAc"}
1
+ {"version":3,"names":["useCallback","useRef","useRefFunction","fn","ref","current","_ref$current","_len","arguments","length","args","Array","_key","call","apply","concat"],"sources":["../../src/hooks/useRefFunction.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\n\n/**\n * - **EN:** Generate an immutable function reference, the dependencies inside the function will be\n * updated in real time, but the function itself will not change, which is very useful when used\n * as a dependency of `useEffect`.\n * - **CN:** 生成一个引用不可变的函数,函数内部的依赖项会保持实时更新,但函数本身不会变化,在作为 `useEffect` 的依赖时非常有用\n *\n * @param fn Function body | 函数体\n *\n * @returns An function with immutable reference | 引用不可变的函数\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst useRefFunction = <T extends (...args: any[]) => any>(fn: T | undefined) => {\n const ref = useRef<T | undefined>(fn);\n ref.current = fn;\n\n // eslint-disable-next-line @tiny-codes/react-hooks/exhaustive-deps\n return useCallback(((...args: any[]) => ref.current?.(...args)) as T, []);\n};\n\nexport default useRefFunction;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ,OAAO;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAuCC,EAAiB,EAAK;EAC/E,IAAMC,GAAG,GAAGH,MAAM,CAAgBE,EAAE,CAAC;EACrCC,GAAG,CAACC,OAAO,GAAGF,EAAE;;EAEhB;EACA,OAAOH,WAAW,CAAE;IAAA,IAAAM,YAAA;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAIC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAAA,QAAAN,YAAA,GAAYF,GAAG,CAACC,OAAO,cAAAC,YAAA,uBAAXA,YAAA,CAAAO,IAAA,CAAAC,KAAA,CAAAR,YAAA,GAAAF,GAAG,EAAAW,MAAA,CAAcL,IAAI,EAAC;EAAA,GAAQ,EAAE,CAAC;AAC3E,CAAC;AAED,eAAeR,cAAc"}
@@ -1,8 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  /**
3
- * **EN:** Get a mutable ref object and automatically update the value change
4
- *
5
- * **CN:** 获取一个可变的ref对象,并自动更新值变化
3
+ * - **EN:** Get a mutable ref object and automatically update the value change
4
+ * - **CN:** 获取一个可变的ref对象,并自动更新值变化
6
5
  *
7
6
  * @param value the wrapped value | 被包装的值
8
7
  *
@@ -1,9 +1,8 @@
1
1
  import { useRef } from 'react';
2
2
 
3
3
  /**
4
- * **EN:** Get a mutable ref object and automatically update the value change
5
- *
6
- * **CN:** 获取一个可变的ref对象,并自动更新值变化
4
+ * - **EN:** Get a mutable ref object and automatically update the value change
5
+ * - **CN:** 获取一个可变的ref对象,并自动更新值变化
7
6
  *
8
7
  * @param value the wrapped value | 被包装的值
9
8
  *
@@ -1 +1 @@
1
- {"version":3,"names":["useRef","useRefValue","value","ref","current"],"sources":["../../src/hooks/useRefValue.ts"],"sourcesContent":["import { useRef } from 'react';\n\n/**\n * **EN:** Get a mutable ref object and automatically update the value change\n *\n * **CN:** 获取一个可变的ref对象,并自动更新值变化\n *\n * @param value the wrapped value | 被包装的值\n *\n * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变\n */\nconst useRefValue = <T>(value: T) => {\n const ref = useRef<T>(value);\n ref.current = value;\n return ref;\n};\n\nexport default useRefValue;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAOC,KAAQ,EAAK;EACnC,IAAMC,GAAG,GAAGH,MAAM,CAAIE,KAAK,CAAC;EAC5BC,GAAG,CAACC,OAAO,GAAGF,KAAK;EACnB,OAAOC,GAAG;AACZ,CAAC;AAED,eAAeF,WAAW"}
1
+ {"version":3,"names":["useRef","useRefValue","value","ref","current"],"sources":["../../src/hooks/useRefValue.ts"],"sourcesContent":["import { useRef } from 'react';\n\n/**\n * - **EN:** Get a mutable ref object and automatically update the value change\n * - **CN:** 获取一个可变的ref对象,并自动更新值变化\n *\n * @param value the wrapped value | 被包装的值\n *\n * @returns A mutable ref object, but the reference is immutable | 可变的ref对象,但引用不可变\n */\nconst useRefValue = <T>(value: T) => {\n const ref = useRef<T>(value);\n ref.current = value;\n return ref;\n};\n\nexport default useRefValue;\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAOC,KAAQ,EAAK;EACnC,IAAMC,GAAG,GAAGH,MAAM,CAAIE,KAAK,CAAC;EAC5BC,GAAG,CAACC,OAAO,GAAGF,KAAK;EACnB,OAAOC,GAAG;AACZ,CAAC;AAED,eAAeF,WAAW"}
package/es/hooks/useT.js CHANGED
@@ -5,8 +5,7 @@ var useT = function useT() {
5
5
  var context = useContext(ReactEasyContext);
6
6
  var lang = context.lang;
7
7
 
8
- // eslint-disable-next-line eslint-comments/no-restricted-disable
9
- // eslint-disable-next-line react-hooks/exhaustive-deps
8
+ // eslint-disable-next-line @tiny-codes/react-hooks/exhaustive-deps
10
9
  return useMemo(function () {
11
10
  return t;
12
11
  }, [lang]);
@@ -1 +1 @@
1
- {"version":3,"names":["useContext","useMemo","ReactEasyContext","t","useT","context","lang"],"sources":["../../src/hooks/useT.ts"],"sourcesContent":["import { useContext, useMemo } from 'react';\nimport ReactEasyContext from '../components/ConfigProvider/context';\nimport { t } from '../locales';\n\nconst useT = (): typeof t => {\n const context = useContext(ReactEasyContext);\n const lang = context.lang;\n\n // eslint-disable-next-line eslint-comments/no-restricted-disable\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => t, [lang]);\n};\n\nexport default useT;\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,OAAOC,gBAAgB;AACvB,SAASC,CAAC;AAEV,IAAMC,IAAI,GAAG,SAAPA,IAAIA,CAAA,EAAmB;EAC3B,IAAMC,OAAO,GAAGL,UAAU,CAACE,gBAAgB,CAAC;EAC5C,IAAMI,IAAI,GAAGD,OAAO,CAACC,IAAI;;EAEzB;EACA;EACA,OAAOL,OAAO,CAAC;IAAA,OAAME,CAAC;EAAA,GAAE,CAACG,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,eAAeF,IAAI"}
1
+ {"version":3,"names":["useContext","useMemo","ReactEasyContext","t","useT","context","lang"],"sources":["../../src/hooks/useT.ts"],"sourcesContent":["import { useContext, useMemo } from 'react';\nimport ReactEasyContext from '../components/ConfigProvider/context';\nimport { t } from '../locales';\n\nconst useT = (): typeof t => {\n const context = useContext(ReactEasyContext);\n const lang = context.lang;\n\n // eslint-disable-next-line @tiny-codes/react-hooks/exhaustive-deps\n return useMemo(() => t, [lang]);\n};\n\nexport default useT;\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,OAAOC,gBAAgB;AACvB,SAASC,CAAC;AAEV,IAAMC,IAAI,GAAG,SAAPA,IAAIA,CAAA,EAAmB;EAC3B,IAAMC,OAAO,GAAGL,UAAU,CAACE,gBAAgB,CAAC;EAC5C,IAAMI,IAAI,GAAGD,OAAO,CAACC,IAAI;;EAEzB;EACA,OAAOL,OAAO,CAAC;IAAA,OAAME,CAAC;EAAA,GAAE,CAACG,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,eAAeF,IAAI"}
@@ -1,8 +1,7 @@
1
1
  import type { BuilderOptions } from './useValidatorBuilder';
2
2
  /**
3
- * **EN:** Dynamically generate a validation rule, compatible with ant-design rules
4
- *
5
- * **CN:** 动态生成一个校验规则,与 ant-design 的规则兼容
3
+ * - **EN:** Dynamically generate a validation rule, compatible with ant-design rules
4
+ * - **CN:** 动态生成一个校验规则,与 ant-design 的规则兼容
6
5
  */
7
6
  declare const useValidator: (props: BuilderOptions) => import("./useValidatorBuilder").ValidatorRule;
8
7
  export default useValidator;
@@ -2,9 +2,8 @@ import { useMemo } from 'react';
2
2
  import useValidatorBuilder from "./useValidatorBuilder";
3
3
 
4
4
  /**
5
- * **EN:** Dynamically generate a validation rule, compatible with ant-design rules
6
- *
7
- * **CN:** 动态生成一个校验规则,与 ant-design 的规则兼容
5
+ * - **EN:** Dynamically generate a validation rule, compatible with ant-design rules
6
+ * - **CN:** 动态生成一个校验规则,与 ant-design 的规则兼容
8
7
  */
9
8
  var useValidator = function useValidator(props) {
10
9
  var builder = useValidatorBuilder();
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","useValidatorBuilder","useValidator","props","builder"],"sources":["../../src/hooks/useValidator.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { BuilderOptions } from './useValidatorBuilder';\nimport useValidatorBuilder from './useValidatorBuilder';\n\n/**\n * **EN:** Dynamically generate a validation rule, compatible with ant-design rules\n *\n * **CN:** 动态生成一个校验规则,与 ant-design 的规则兼容\n */\nconst useValidator = (props: BuilderOptions) => {\n const builder = useValidatorBuilder();\n return useMemo(() => builder(props), [builder, props]);\n};\n\nexport default useValidator;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAE/B,OAAOC,mBAAmB;;AAE1B;AACA;AACA;AACA;AACA;AACA,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAIC,KAAqB,EAAK;EAC9C,IAAMC,OAAO,GAAGH,mBAAmB,CAAC,CAAC;EACrC,OAAOD,OAAO,CAAC;IAAA,OAAMI,OAAO,CAACD,KAAK,CAAC;EAAA,GAAE,CAACC,OAAO,EAAED,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,eAAeD,YAAY"}
1
+ {"version":3,"names":["useMemo","useValidatorBuilder","useValidator","props","builder"],"sources":["../../src/hooks/useValidator.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { BuilderOptions } from './useValidatorBuilder';\nimport useValidatorBuilder from './useValidatorBuilder';\n\n/**\n * - **EN:** Dynamically generate a validation rule, compatible with ant-design rules\n * - **CN:** 动态生成一个校验规则,与 ant-design 的规则兼容\n */\nconst useValidator = (props: BuilderOptions) => {\n const builder = useValidatorBuilder();\n return useMemo(() => builder(props), [builder, props]);\n};\n\nexport default useValidator;\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAE/B,OAAOC,mBAAmB;;AAE1B;AACA;AACA;AACA;AACA,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAIC,KAAqB,EAAK;EAC9C,IAAMC,OAAO,GAAGH,mBAAmB,CAAC,CAAC;EACrC,OAAOD,OAAO,CAAC;IAAA,OAAMI,OAAO,CAACD,KAAK,CAAC;EAAA,GAAE,CAACC,OAAO,EAAED,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,eAAeD,YAAY"}
@@ -1,132 +1,112 @@
1
1
  /**
2
- * **EN:** Get a validation rule builder to build validation rules
3
- *
4
- * **CN:** 获取一个校验规则生成器,用来构建校验规则
2
+ * - **EN:** Get a validation rule builder to build validation rules
3
+ * - **CN:** 获取一个校验规则生成器,用来构建校验规则
5
4
  */
6
5
  declare const useValidatorBuilder: () => (props: BuilderOptions) => ValidatorRule;
7
6
  export interface BuilderOptions {
8
7
  /**
9
- * **EN:** The rule of allowed characters
10
- *
11
- * **CN:** 允许字符的规则
8
+ * - **EN:** The rule of allowed characters
9
+ * - **CN:** 允许字符的规则
12
10
  */
13
11
  allowed: RuleRegExpFlags;
14
12
  /**
15
- * **EN:** The rule of the starting character
16
- *
17
- * **CN:** 开头字符的规则
13
+ * - **EN:** The rule of the starting character
14
+ * - **CN:** 开头字符的规则
18
15
  */
19
16
  startsWith?: Omit<RuleRegExpFlags, 'min' | 'max'>;
20
17
  /**
21
- * **EN:** Regular expression flags
22
- *
23
- * **CN:** 正则表达式的标志
18
+ * - **EN:** Regular expression flags
19
+ * - **CN:** 正则表达式的标志
24
20
  */
25
21
  flags?: string;
26
22
  }
27
23
  export interface RuleRegExpFlags {
28
24
  /**
29
- * **EN:** Include lowercase and uppercase Latin characters. If set to true, `lowerLetter` and
30
- * `upperLetter` option are not effective
31
- *
32
- * **CN:**: 包含大小写拉丁字符。如果设置为true,则`lowerLetter`和`upperLetter`属性不生效
25
+ * - **EN:** Include lowercase and uppercase Latin characters. If set to true, `lowerLetter` and
26
+ * `upperLetter` option are not effective
27
+ * - **CN:**: 包含大小写拉丁字符。如果设置为true,则`lowerLetter`和`upperLetter`属性不生效
33
28
  */
34
29
  letter?: boolean;
35
30
  /**
36
- * **EN:** Include lowercase English letters
37
- *
38
- * **CN:**: 包含小写英文字符
31
+ * - **EN:** Include lowercase English letters
32
+ * - **CN:**: 包含小写英文字符
39
33
  */
40
34
  lowerLetter?: boolean;
41
35
  /**
42
- * **EN:** Include uppercase English letters
43
- *
44
- * **CN:**: 包含大写英文字符
36
+ * - **EN:** Include uppercase English letters
37
+ * - **CN:**: 包含大写英文字符
45
38
  */
46
39
  upperLetter?: boolean;
47
40
  /**
48
- * **EN:** Include Chinese characters
49
- *
50
- * **CN:** 包含中文字符
41
+ * - **EN:** Include Chinese characters
42
+ * - **CN:** 包含中文字符
51
43
  */
52
44
  chineseCharacter?: boolean;
53
45
  /**
54
- * **EN:** Include Chinese (full-width) punctuation
55
- *
56
- * **CN:** 包含中文(全角)标点符号
46
+ * - **EN:** Include Chinese (full-width) punctuation
47
+ * - **CN:** 包含中文(全角)标点符号
57
48
  */
58
49
  chinesePunctuation?: boolean;
59
50
  /**
60
- * **EN:** Include numbers
61
- *
62
- * **CN:** 包含数字
51
+ * - **EN:** Include numbers
52
+ * - **CN:** 包含数字
63
53
  */
64
54
  number?: boolean;
65
55
  /**
66
- * **EN:** Include hyphens (-)
67
- *
68
- * **CN:** 包含连字符(-)
56
+ * - **EN:** Include hyphens (-)
57
+ * - **CN:** 包含连字符(-)
69
58
  */
70
59
  hyphen?: boolean;
71
60
  /**
72
- * **EN:** Include underscores (_)
73
- *
74
- * **CN:** 包含下划线(_)
61
+ * - **EN:** Include underscores (_)
62
+ * - **CN:** 包含下划线(_)
75
63
  */
76
64
  underscore?: boolean;
77
65
  /**
78
- * **EN:** Include specified special characters
79
- *
80
- * **CN:** 包含指定的特殊字符
66
+ * - **EN:** Include specified special characters
67
+ * - **CN:** 包含指定的特殊字符
81
68
  */
82
69
  special?: string[];
83
70
  /**
84
- * **EN:** Minimum number of characters
85
- *
86
- * **CN:** 最小字符数量
71
+ * - **EN:** Minimum number of characters
72
+ * - **CN:** 最小字符数量
87
73
  *
88
74
  * @default 1
89
75
  */
90
76
  min?: number;
91
77
  /**
92
- * **EN:** Maximum number of characters
93
- *
94
- * **CN:** 最大字符数量
78
+ * - **EN:** Maximum number of characters
79
+ * - **CN:** 最大字符数量
95
80
  */
96
81
  max?: number;
97
82
  }
98
83
  export type StartsWithRegExpFlags = RuleRegExpFlags;
99
84
  export interface ValidatorRule extends Validator {
100
85
  /**
101
- * **EN:** The options of allowed characters
102
- *
103
- * **CN:** 允许字符的规则设置
86
+ * - **EN:** The options of allowed characters
87
+ * - **CN:** 允许字符的规则设置
104
88
  */
105
89
  allowedOptions: RuleRegExpFlags;
106
90
  /**
107
- * **EN:** The options of the starting character
108
- *
109
- * **CN:** 开头字符的规则设置
91
+ * - **EN:** The options of the starting character
92
+ * - **CN:** 开头字符的规则设置
110
93
  */
111
94
  startsWithOptions?: StartsWithRegExpFlags;
112
95
  /**
113
- * **EN:** Regular expression flags
114
- *
115
- * **CN:** 正则表达式的标志
96
+ * - **EN:** Regular expression flags
97
+ * - **CN:** 正则表达式的标志
116
98
  */
117
99
  flags?: string;
118
100
  }
119
101
  export interface Validator {
120
102
  /**
121
- * **EN:** Regular expression for verification
122
- *
123
- * **CN:** 校验正则表达式
103
+ * - **EN:** Regular expression for verification
104
+ * - **CN:** 校验正则表达式
124
105
  */
125
106
  pattern: RegExp;
126
107
  /**
127
- * **EN:** Prompt message when verification fails
128
- *
129
- * **CN:** 校验失败时的提示信息
108
+ * - **EN:** Prompt message when verification fails
109
+ * - **CN:** 校验失败时的提示信息
130
110
  */
131
111
  message: string;
132
112
  }
@@ -10,9 +10,8 @@ import useT from "./useT";
10
10
  var nameSeparator = 'validation.rule.buildRule.token.separator';
11
11
 
12
12
  /**
13
- * **EN:** Get a validation rule builder to build validation rules
14
- *
15
- * **CN:** 获取一个校验规则生成器,用来构建校验规则
13
+ * - **EN:** Get a validation rule builder to build validation rules
14
+ * - **CN:** 获取一个校验规则生成器,用来构建校验规则
16
15
  */
17
16
  var useValidatorBuilder = function useValidatorBuilder() {
18
17
  var t = useT();
@@ -26,9 +25,8 @@ var useValidatorBuilder = function useValidatorBuilder() {
26
25
  };
27
26
 
28
27
  /**
29
- * **EN:** Build regular expression rules dynamically, compatible with ant-design rules
30
- *
31
- * **CN:** 动态构建正则表达式规则,与 ant-design 的规则兼容
28
+ * - **EN:** Build regular expression rules dynamically, compatible with ant-design rules
29
+ * - **CN:** 动态构建正则表达式规则,与 ant-design 的规则兼容
32
30
  */
33
31
  function buildRule(options) {
34
32
  var allowed = options.allowed,
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","escape","useT","nameSeparator","useValidatorBuilder","t","props","buildRule","_objectSpread","options","allowed","startsWith","flags","Object","values","some","v","Error","symbols","messages","push","meta","buildRuleMeta","concat","join","prefix","_allowed$min","_allowed$max","min","max","cMin","cMax","length","unshift","message","slice","pattern","RegExp","content","allowedOptions","startsWithOptions","chineseCharacter","chinesePunctuation","letter","lowerLetter","upperLetter","number","excludeSpecials","hyphen","underscore","special","specials","filter","includes"],"sources":["../../src/hooks/useValidatorBuilder.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport escape from 'escape-string-regexp';\nimport useT from './useT';\n\nconst nameSeparator = 'validation.rule.buildRule.token.separator';\n\n/**\n * **EN:** Get a validation rule builder to build validation rules\n *\n * **CN:** 获取一个校验规则生成器,用来构建校验规则\n */\nconst useValidatorBuilder = () => {\n const t = useT();\n return useMemo(() => (props: BuilderOptions) => buildRule({ ...props, t }), [t]);\n};\n\n/**\n * **EN:** Build regular expression rules dynamically, compatible with ant-design rules\n *\n * **CN:** 动态构建正则表达式规则,与 ant-design 的规则兼容\n */\nfunction buildRule(\n options: BuilderOptions & {\n /**\n * **EN:** Internationalization function\n *\n * **CN:** 国际化函数\n */\n t: ReturnType<typeof useT>;\n }\n): ValidatorRule {\n const { allowed, startsWith, flags, t } = options;\n if (!Object.values(allowed).some((v) => v === true)) {\n throw new Error(t('validation.rule.buildRule.includeMandatory'));\n }\n\n const symbols: string[] = [];\n const messages: string[] = [];\n symbols.push(`^`);\n\n // Process startsWith rules\n if (startsWith) {\n const meta = buildRuleMeta({\n flags: startsWith,\n t,\n });\n symbols.push(`[${meta.symbols.join('')}]`);\n messages.push(\n t('validation.rule.buildRule.startsWithFormat', {\n prefix: meta.messages.join(t(nameSeparator)),\n })\n );\n }\n\n // Process allowed rules\n {\n const meta = buildRuleMeta({ flags: allowed, t });\n\n const min = allowed.min ?? 0;\n const max = allowed.max ?? 0; // 0 means unlimited\n\n // If there is startWith in the regular expression, the limited data amount needs to be reduced by 1\n const cMin = min && startsWith ? min - 1 : min;\n const cMax = max && startsWith ? max - 1 : max;\n\n symbols.push(`[${meta.symbols.join('')}]{${cMin},${cMax || ''}}`);\n if (meta.messages.length === 0) {\n messages.unshift(``);\n } else if (meta.messages.length === 1) {\n messages.unshift(`${meta.messages.join(t(nameSeparator))}`);\n } else {\n messages.unshift(`${meta.messages.join(t(nameSeparator))}`);\n }\n if (min && max) {\n messages.push(\n t('validation.rule.buildRule.rangeLength', {\n min,\n max,\n })\n );\n } else {\n if (min > 1) {\n messages.push(t('validation.rule.buildRule.minLength', { min }));\n }\n if (max) {\n messages.push(t('validation.rule.buildRule.maxLength', { max }));\n }\n }\n }\n symbols.push(`$`);\n\n let message = messages.join('');\n if (message.startsWith(t(nameSeparator))) {\n message = message.slice(1);\n }\n return {\n pattern: new RegExp(symbols.join(''), flags),\n message: t('validation.rule.buildRule.messageFormat', { content: message }),\n allowedOptions: allowed,\n startsWithOptions: startsWith,\n flags,\n };\n}\n\nfunction buildRuleMeta(options: { flags: RuleRegExpFlags; t: ReturnType<typeof useT> }): RuleMeta {\n const { flags, t } = options;\n const symbols: string[] = [];\n const messages: string[] = [];\n if (flags.chineseCharacter) {\n // Chinese characters\n symbols.push(`\\u4e00-\\u9fa5`);\n messages.push(t('validation.rule.buildRule.token.chinese'));\n }\n if (flags.chinesePunctuation) {\n // Chinese punctuation\n symbols.push(`\\u3000-\\u301e`);\n symbols.push(`\\u3021-\\u303f`);\n symbols.push(`\\uff00-\\uffef`);\n messages.push(t('validation.rule.buildRule.token.chinesePunctuation'));\n }\n if (flags.letter) {\n symbols.push(`a-zA-Z`);\n messages.push(t('validation.rule.buildRule.token.letter'));\n } else if (flags.lowerLetter) {\n symbols.push(`a-z`);\n messages.push(t('validation.rule.buildRule.token.lowerLetter'));\n } else if (flags.upperLetter) {\n symbols.push(`A-Z`);\n messages.push(t('validation.rule.buildRule.token.upperLetter'));\n }\n if (flags.number) {\n symbols.push(`0-9`);\n messages.push(t('validation.rule.buildRule.token.number'));\n }\n const excludeSpecials: string[] = [];\n if (flags.hyphen) {\n symbols.push(`\\\\-`);\n messages.push(`-`);\n excludeSpecials.push('-');\n }\n if (flags.underscore) {\n symbols.push(`_`);\n messages.push(`_`);\n excludeSpecials.push('_');\n }\n if (flags.special) {\n const specials = flags.special.filter((v) => !excludeSpecials.includes(v));\n symbols.push(escape(specials.join('')));\n messages.push(specials.join(t(nameSeparator)));\n }\n return {\n symbols,\n messages,\n };\n}\n\nexport interface BuilderOptions {\n /**\n * **EN:** The rule of allowed characters\n *\n * **CN:** 允许字符的规则\n */\n allowed: RuleRegExpFlags;\n /**\n * **EN:** The rule of the starting character\n *\n * **CN:** 开头字符的规则\n */\n startsWith?: Omit<RuleRegExpFlags, 'min' | 'max'>;\n /**\n * **EN:** Regular expression flags\n *\n * **CN:** 正则表达式的标志\n */\n flags?: string;\n}\n\nexport interface RuleRegExpFlags {\n /**\n * **EN:** Include lowercase and uppercase Latin characters. If set to true, `lowerLetter` and\n * `upperLetter` option are not effective\n *\n * **CN:**: 包含大小写拉丁字符。如果设置为true,则`lowerLetter`和`upperLetter`属性不生效\n */\n\n letter?: boolean;\n /**\n * **EN:** Include lowercase English letters\n *\n * **CN:**: 包含小写英文字符\n */\n lowerLetter?: boolean;\n /**\n * **EN:** Include uppercase English letters\n *\n * **CN:**: 包含大写英文字符\n */\n upperLetter?: boolean;\n /**\n * **EN:** Include Chinese characters\n *\n * **CN:** 包含中文字符\n */\n chineseCharacter?: boolean;\n /**\n * **EN:** Include Chinese (full-width) punctuation\n *\n * **CN:** 包含中文(全角)标点符号\n */\n chinesePunctuation?: boolean;\n /**\n * **EN:** Include numbers\n *\n * **CN:** 包含数字\n */\n number?: boolean;\n /**\n * **EN:** Include hyphens (-)\n *\n * **CN:** 包含连字符(-)\n */\n hyphen?: boolean;\n /**\n * **EN:** Include underscores (_)\n *\n * **CN:** 包含下划线(_)\n */\n underscore?: boolean;\n /**\n * **EN:** Include specified special characters\n *\n * **CN:** 包含指定的特殊字符\n */\n special?: string[];\n /**\n * **EN:** Minimum number of characters\n *\n * **CN:** 最小字符数量\n *\n * @default 1\n */\n min?: number;\n /**\n * **EN:** Maximum number of characters\n *\n * **CN:** 最大字符数量\n */\n max?: number;\n}\n\nexport type StartsWithRegExpFlags = RuleRegExpFlags;\n\nexport interface ValidatorRule extends Validator {\n /**\n * **EN:** The options of allowed characters\n *\n * **CN:** 允许字符的规则设置\n */\n allowedOptions: RuleRegExpFlags;\n /**\n * **EN:** The options of the starting character\n *\n * **CN:** 开头字符的规则设置\n */\n startsWithOptions?: StartsWithRegExpFlags;\n /**\n * **EN:** Regular expression flags\n *\n * **CN:** 正则表达式的标志\n */\n flags?: string;\n}\n\ninterface RuleMeta {\n symbols: string[];\n messages: string[];\n}\n\nexport interface Validator {\n /**\n * **EN:** Regular expression for verification\n *\n * **CN:** 校验正则表达式\n */\n pattern: RegExp;\n /**\n * **EN:** Prompt message when verification fails\n *\n * **CN:** 校验失败时的提示信息\n */\n message: string;\n}\n\nexport default useValidatorBuilder;\n"],"mappings":";;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,OAAOC,MAAM,MAAM,sBAAsB;AACzC,OAAOC,IAAI;AAEX,IAAMC,aAAa,GAAG,2CAA2C;;AAEjE;AACA;AACA;AACA;AACA;AACA,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAA,EAAS;EAChC,IAAMC,CAAC,GAAGH,IAAI,CAAC,CAAC;EAChB,OAAOF,OAAO,CAAC;IAAA,OAAM,UAACM,KAAqB;MAAA,OAAKC,SAAS,CAAAC,aAAA,CAAAA,aAAA,KAAMF,KAAK;QAAED,CAAC,EAADA;MAAC,EAAE,CAAC;IAAA;EAAA,GAAE,CAACA,CAAC,CAAC,CAAC;AAClF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,SAASE,SAASA,CAChBE,OAOC,EACc;EACf,IAAQC,OAAO,GAA2BD,OAAO,CAAzCC,OAAO;IAAEC,UAAU,GAAeF,OAAO,CAAhCE,UAAU;IAAEC,KAAK,GAAQH,OAAO,CAApBG,KAAK;IAAEP,CAAC,GAAKI,OAAO,CAAbJ,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AARA;EACF,CAAC;AACH;AA2IA,eAAef,mBAAmB"}
1
+ {"version":3,"names":["useMemo","escape","useT","nameSeparator","useValidatorBuilder","t","props","buildRule","_objectSpread","options","allowed","startsWith","flags","Object","values","some","v","Error","symbols","messages","push","meta","buildRuleMeta","concat","join","prefix","_allowed$min","_allowed$max","min","max","cMin","cMax","length","unshift","message","slice","pattern","RegExp","content","allowedOptions","startsWithOptions","chineseCharacter","chinesePunctuation","letter","lowerLetter","upperLetter","number","excludeSpecials","hyphen","underscore","special","specials","filter","includes"],"sources":["../../src/hooks/useValidatorBuilder.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport escape from 'escape-string-regexp';\nimport useT from './useT';\n\nconst nameSeparator = 'validation.rule.buildRule.token.separator';\n\n/**\n * - **EN:** Get a validation rule builder to build validation rules\n * - **CN:** 获取一个校验规则生成器,用来构建校验规则\n */\nconst useValidatorBuilder = () => {\n const t = useT();\n return useMemo(() => (props: BuilderOptions) => buildRule({ ...props, t }), [t]);\n};\n\n/**\n * - **EN:** Build regular expression rules dynamically, compatible with ant-design rules\n * - **CN:** 动态构建正则表达式规则,与 ant-design 的规则兼容\n */\nfunction buildRule(\n options: BuilderOptions & {\n /**\n * - **EN:** Internationalization function\n * - **CN:** 国际化函数\n */\n t: ReturnType<typeof useT>;\n }\n): ValidatorRule {\n const { allowed, startsWith, flags, t } = options;\n if (!Object.values(allowed).some((v) => v === true)) {\n throw new Error(t('validation.rule.buildRule.includeMandatory'));\n }\n\n const symbols: string[] = [];\n const messages: string[] = [];\n symbols.push(`^`);\n\n // Process startsWith rules\n if (startsWith) {\n const meta = buildRuleMeta({\n flags: startsWith,\n t,\n });\n symbols.push(`[${meta.symbols.join('')}]`);\n messages.push(\n t('validation.rule.buildRule.startsWithFormat', {\n prefix: meta.messages.join(t(nameSeparator)),\n })\n );\n }\n\n // Process allowed rules\n {\n const meta = buildRuleMeta({ flags: allowed, t });\n\n const min = allowed.min ?? 0;\n const max = allowed.max ?? 0; // 0 means unlimited\n\n // If there is startWith in the regular expression, the limited data amount needs to be reduced by 1\n const cMin = min && startsWith ? min - 1 : min;\n const cMax = max && startsWith ? max - 1 : max;\n\n symbols.push(`[${meta.symbols.join('')}]{${cMin},${cMax || ''}}`);\n if (meta.messages.length === 0) {\n messages.unshift(``);\n } else if (meta.messages.length === 1) {\n messages.unshift(`${meta.messages.join(t(nameSeparator))}`);\n } else {\n messages.unshift(`${meta.messages.join(t(nameSeparator))}`);\n }\n if (min && max) {\n messages.push(\n t('validation.rule.buildRule.rangeLength', {\n min,\n max,\n })\n );\n } else {\n if (min > 1) {\n messages.push(t('validation.rule.buildRule.minLength', { min }));\n }\n if (max) {\n messages.push(t('validation.rule.buildRule.maxLength', { max }));\n }\n }\n }\n symbols.push(`$`);\n\n let message = messages.join('');\n if (message.startsWith(t(nameSeparator))) {\n message = message.slice(1);\n }\n return {\n pattern: new RegExp(symbols.join(''), flags),\n message: t('validation.rule.buildRule.messageFormat', { content: message }),\n allowedOptions: allowed,\n startsWithOptions: startsWith,\n flags,\n };\n}\n\nfunction buildRuleMeta(options: { flags: RuleRegExpFlags; t: ReturnType<typeof useT> }): RuleMeta {\n const { flags, t } = options;\n const symbols: string[] = [];\n const messages: string[] = [];\n if (flags.chineseCharacter) {\n // Chinese characters\n symbols.push(`\\u4e00-\\u9fa5`);\n messages.push(t('validation.rule.buildRule.token.chinese'));\n }\n if (flags.chinesePunctuation) {\n // Chinese punctuation\n symbols.push(`\\u3000-\\u301e`);\n symbols.push(`\\u3021-\\u303f`);\n symbols.push(`\\uff00-\\uffef`);\n messages.push(t('validation.rule.buildRule.token.chinesePunctuation'));\n }\n if (flags.letter) {\n symbols.push(`a-zA-Z`);\n messages.push(t('validation.rule.buildRule.token.letter'));\n } else if (flags.lowerLetter) {\n symbols.push(`a-z`);\n messages.push(t('validation.rule.buildRule.token.lowerLetter'));\n } else if (flags.upperLetter) {\n symbols.push(`A-Z`);\n messages.push(t('validation.rule.buildRule.token.upperLetter'));\n }\n if (flags.number) {\n symbols.push(`0-9`);\n messages.push(t('validation.rule.buildRule.token.number'));\n }\n const excludeSpecials: string[] = [];\n if (flags.hyphen) {\n symbols.push(`\\\\-`);\n messages.push(`-`);\n excludeSpecials.push('-');\n }\n if (flags.underscore) {\n symbols.push(`_`);\n messages.push(`_`);\n excludeSpecials.push('_');\n }\n if (flags.special) {\n const specials = flags.special.filter((v) => !excludeSpecials.includes(v));\n symbols.push(escape(specials.join('')));\n messages.push(specials.join(t(nameSeparator)));\n }\n return {\n symbols,\n messages,\n };\n}\n\nexport interface BuilderOptions {\n /**\n * - **EN:** The rule of allowed characters\n * - **CN:** 允许字符的规则\n */\n allowed: RuleRegExpFlags;\n /**\n * - **EN:** The rule of the starting character\n * - **CN:** 开头字符的规则\n */\n startsWith?: Omit<RuleRegExpFlags, 'min' | 'max'>;\n /**\n * - **EN:** Regular expression flags\n * - **CN:** 正则表达式的标志\n */\n flags?: string;\n}\n\nexport interface RuleRegExpFlags {\n /**\n * - **EN:** Include lowercase and uppercase Latin characters. If set to true, `lowerLetter` and\n * `upperLetter` option are not effective\n * - **CN:**: 包含大小写拉丁字符。如果设置为true,则`lowerLetter`和`upperLetter`属性不生效\n */\n\n letter?: boolean;\n /**\n * - **EN:** Include lowercase English letters\n * - **CN:**: 包含小写英文字符\n */\n lowerLetter?: boolean;\n /**\n * - **EN:** Include uppercase English letters\n * - **CN:**: 包含大写英文字符\n */\n upperLetter?: boolean;\n /**\n * - **EN:** Include Chinese characters\n * - **CN:** 包含中文字符\n */\n chineseCharacter?: boolean;\n /**\n * - **EN:** Include Chinese (full-width) punctuation\n * - **CN:** 包含中文(全角)标点符号\n */\n chinesePunctuation?: boolean;\n /**\n * - **EN:** Include numbers\n * - **CN:** 包含数字\n */\n number?: boolean;\n /**\n * - **EN:** Include hyphens (-)\n * - **CN:** 包含连字符(-)\n */\n hyphen?: boolean;\n /**\n * - **EN:** Include underscores (_)\n * - **CN:** 包含下划线(_)\n */\n underscore?: boolean;\n /**\n * - **EN:** Include specified special characters\n * - **CN:** 包含指定的特殊字符\n */\n special?: string[];\n /**\n * - **EN:** Minimum number of characters\n * - **CN:** 最小字符数量\n *\n * @default 1\n */\n min?: number;\n /**\n * - **EN:** Maximum number of characters\n * - **CN:** 最大字符数量\n */\n max?: number;\n}\n\nexport type StartsWithRegExpFlags = RuleRegExpFlags;\n\nexport interface ValidatorRule extends Validator {\n /**\n * - **EN:** The options of allowed characters\n * - **CN:** 允许字符的规则设置\n */\n allowedOptions: RuleRegExpFlags;\n /**\n * - **EN:** The options of the starting character\n * - **CN:** 开头字符的规则设置\n */\n startsWithOptions?: StartsWithRegExpFlags;\n /**\n * - **EN:** Regular expression flags\n * - **CN:** 正则表达式的标志\n */\n flags?: string;\n}\n\ninterface RuleMeta {\n symbols: string[];\n messages: string[];\n}\n\nexport interface Validator {\n /**\n * - **EN:** Regular expression for verification\n * - **CN:** 校验正则表达式\n */\n pattern: RegExp;\n /**\n * - **EN:** Prompt message when verification fails\n * - **CN:** 校验失败时的提示信息\n */\n message: string;\n}\n\nexport default useValidatorBuilder;\n"],"mappings":";;;;;;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,OAAOC,MAAM,MAAM,sBAAsB;AACzC,OAAOC,IAAI;AAEX,IAAMC,aAAa,GAAG,2CAA2C;;AAEjE;AACA;AACA;AACA;AACA,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAA,EAAS;EAChC,IAAMC,CAAC,GAAGH,IAAI,CAAC,CAAC;EAChB,OAAOF,OAAO,CAAC;IAAA,OAAM,UAACM,KAAqB;MAAA,OAAKC,SAAS,CAAAC,aAAA,CAAAA,aAAA,KAAMF,KAAK;QAAED,CAAC,EAADA;MAAC,EAAE,CAAC;IAAA;EAAA,GAAE,CAACA,CAAC,CAAC,CAAC;AAClF,CAAC;;AAED;AACA;AACA;AACA;AACA,SAASE,SAASA,CAChBE,OAMC,EACc;EACf,IAAQC,OAAO,GAA2BD,OAAO,CAAzCC,OAAO;IA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