@tiny-codes/react-easy 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/es/components/BreakLines/index.d.ts +13 -19
- package/es/components/BreakLines/index.js +2 -3
- package/es/components/BreakLines/index.js.map +1 -1
- package/es/components/ConfigProvider/context.d.ts +20 -26
- package/es/components/ConfigProvider/context.js.map +1 -1
- package/es/components/ConfigProvider/index.d.ts +5 -7
- package/es/components/ConfigProvider/index.js +2 -3
- package/es/components/ConfigProvider/index.js.map +1 -1
- package/es/components/ConfirmAction/index.d.ts +58 -89
- package/es/components/ConfirmAction/index.js +12 -18
- package/es/components/ConfirmAction/index.js.map +1 -1
- package/es/components/DeleteConfirmAction/index.d.ts +2 -3
- package/es/components/DeleteConfirmAction/index.js +8 -12
- package/es/components/DeleteConfirmAction/index.js.map +1 -1
- package/es/components/EditableText/form.d.ts +144 -0
- package/es/components/EditableText/form.js +309 -0
- package/es/components/EditableText/form.js.map +1 -0
- package/es/components/EditableText/index.d.ts +138 -0
- package/es/components/EditableText/index.js +216 -0
- package/es/components/EditableText/index.js.map +1 -0
- package/es/components/EditableText/style/index.d.ts +3 -0
- package/es/components/EditableText/style/index.js +76 -0
- package/es/components/EditableText/style/index.js.map +1 -0
- package/es/components/FloatDrawer/index.d.ts +89 -86
- package/es/components/FloatDrawer/index.js +43 -20
- package/es/components/FloatDrawer/index.js.map +1 -1
- package/es/components/FloatDrawer/style/index.js +42 -23
- package/es/components/FloatDrawer/style/index.js.map +1 -1
- package/es/components/Loading/index.d.ts +66 -0
- package/es/components/Loading/index.js +97 -0
- package/es/components/Loading/index.js.map +1 -0
- package/es/components/Loading/style/index.d.ts +3 -0
- package/es/components/Loading/style/index.js +27 -0
- package/es/components/Loading/style/index.js.map +1 -0
- package/es/components/ModalAction/index.d.ts +98 -139
- package/es/components/ModalAction/index.js +25 -37
- package/es/components/ModalAction/index.js.map +1 -1
- package/es/components/OverflowTags/index.d.ts +30 -8
- package/es/components/OverflowTags/index.js +26 -7
- package/es/components/OverflowTags/index.js.map +1 -1
- package/es/components/OverflowTags/style/index.js +1 -3
- package/es/components/OverflowTags/style/index.js.map +1 -1
- package/es/components/index.d.ts +4 -0
- package/es/components/index.js +2 -0
- package/es/components/index.js.map +1 -1
- package/es/hooks/useRefFunction.d.ts +4 -5
- package/es/hooks/useRefFunction.js +6 -7
- package/es/hooks/useRefFunction.js.map +1 -1
- package/es/hooks/useRefValue.d.ts +2 -3
- package/es/hooks/useRefValue.js +2 -3
- package/es/hooks/useRefValue.js.map +1 -1
- package/es/hooks/useT.js +1 -2
- package/es/hooks/useT.js.map +1 -1
- package/es/hooks/useValidator.d.ts +2 -3
- package/es/hooks/useValidator.js +2 -3
- package/es/hooks/useValidator.js.map +1 -1
- package/es/hooks/useValidatorBuilder.d.ts +41 -61
- package/es/hooks/useValidatorBuilder.js +4 -6
- package/es/hooks/useValidatorBuilder.js.map +1 -1
- package/es/hooks/useValidators.d.ts +62 -83
- package/es/hooks/useValidators.js +3 -4
- package/es/hooks/useValidators.js.map +1 -1
- package/es/locales/index.d.ts +15 -0
- package/es/locales/langs/en-US.d.ts +5 -0
- package/es/locales/langs/en-US.js +5 -0
- package/es/locales/langs/en-US.js.map +1 -1
- package/es/locales/langs/zh-CN.d.ts +5 -0
- package/es/locales/langs/zh-CN.js +5 -0
- package/es/locales/langs/zh-CN.js.map +1 -1
- package/lib/components/BreakLines/index.d.ts +13 -19
- package/lib/components/BreakLines/index.js.map +2 -2
- package/lib/components/ConfigProvider/context.d.ts +20 -26
- package/lib/components/ConfigProvider/context.js.map +2 -2
- package/lib/components/ConfigProvider/index.d.ts +5 -7
- package/lib/components/ConfigProvider/index.js.map +2 -2
- package/lib/components/ConfirmAction/index.d.ts +58 -89
- package/lib/components/ConfirmAction/index.js.map +2 -2
- package/lib/components/DeleteConfirmAction/index.d.ts +2 -3
- package/lib/components/DeleteConfirmAction/index.js.map +2 -2
- package/lib/components/EditableText/form.d.ts +144 -0
- package/lib/components/EditableText/form.js +223 -0
- package/lib/components/EditableText/form.js.map +7 -0
- package/lib/components/EditableText/index.d.ts +138 -0
- package/lib/components/EditableText/index.js +174 -0
- package/lib/components/EditableText/index.js.map +7 -0
- package/lib/components/EditableText/style/index.d.ts +3 -0
- package/lib/components/EditableText/style/index.js +118 -0
- package/lib/components/EditableText/style/index.js.map +7 -0
- package/lib/components/FloatDrawer/index.d.ts +89 -86
- package/lib/components/FloatDrawer/index.js +64 -39
- package/lib/components/FloatDrawer/index.js.map +2 -2
- package/lib/components/FloatDrawer/style/index.js +60 -23
- package/lib/components/FloatDrawer/style/index.js.map +2 -2
- package/lib/components/Loading/index.d.ts +66 -0
- package/lib/components/Loading/index.js +81 -0
- package/lib/components/Loading/index.js.map +7 -0
- package/lib/components/Loading/style/index.d.ts +3 -0
- package/lib/components/Loading/style/index.js +50 -0
- package/lib/components/Loading/style/index.js.map +7 -0
- package/lib/components/ModalAction/index.d.ts +98 -139
- package/lib/components/ModalAction/index.js.map +2 -2
- package/lib/components/OverflowTags/index.d.ts +30 -8
- package/lib/components/OverflowTags/index.js +7 -5
- package/lib/components/OverflowTags/index.js.map +2 -2
- package/lib/components/OverflowTags/style/index.js +1 -1
- package/lib/components/OverflowTags/style/index.js.map +2 -2
- package/lib/components/index.d.ts +4 -0
- package/lib/components/index.js +6 -0
- package/lib/components/index.js.map +2 -2
- package/lib/hooks/useRefFunction.d.ts +4 -5
- package/lib/hooks/useRefFunction.js.map +2 -2
- package/lib/hooks/useRefValue.d.ts +2 -3
- package/lib/hooks/useRefValue.js.map +2 -2
- package/lib/hooks/useT.js.map +2 -2
- package/lib/hooks/useValidator.d.ts +2 -3
- package/lib/hooks/useValidator.js.map +2 -2
- package/lib/hooks/useValidatorBuilder.d.ts +41 -61
- package/lib/hooks/useValidatorBuilder.js.map +2 -2
- package/lib/hooks/useValidators.d.ts +62 -83
- package/lib/hooks/useValidators.js.map +2 -2
- package/lib/locales/index.d.ts +15 -0
- package/lib/locales/langs/en-US.d.ts +5 -0
- package/lib/locales/langs/en-US.js +5 -0
- package/lib/locales/langs/en-US.js.map +2 -2
- package/lib/locales/langs/zh-CN.d.ts +5 -0
- package/lib/locales/langs/zh-CN.js +5 -0
- package/lib/locales/langs/zh-CN.js.map +2 -2
- package/package.json +1 -1
|
@@ -45,15 +45,16 @@ var OverflowTags = (props) => {
|
|
|
45
45
|
randomColors,
|
|
46
46
|
getTagName: getTagNameInProps,
|
|
47
47
|
getTagKey,
|
|
48
|
-
|
|
48
|
+
getTagProps: getTagPropsInProps,
|
|
49
49
|
tagProps,
|
|
50
50
|
ellipsisTagProps,
|
|
51
51
|
className,
|
|
52
|
+
prefixCls: prefixClsInProps,
|
|
52
53
|
...restProps
|
|
53
54
|
} = props;
|
|
54
55
|
const { token } = import_antd.theme.useToken();
|
|
55
56
|
const { getPrefixCls } = (0, import_react.useContext)(import_antd.ConfigProvider.ConfigContext);
|
|
56
|
-
const prefixCls = getPrefixCls("
|
|
57
|
+
const prefixCls = getPrefixCls("easy-overflow-tags", prefixClsInProps);
|
|
57
58
|
const [wrapCSSVar, hashId, cssVarCls] = (0, import_style.default)(prefixCls);
|
|
58
59
|
const colors = (0, import_react.useMemo)(
|
|
59
60
|
() => import_internal.PresetColors.filter((c) => !["lime", "yellow", "magenta"].includes(c)).map((color) => token[`${color}-3`]),
|
|
@@ -61,16 +62,17 @@ var OverflowTags = (props) => {
|
|
|
61
62
|
);
|
|
62
63
|
const getTagName = (0, import_react.useCallback)(
|
|
63
64
|
(tag) => {
|
|
64
|
-
return getTagNameInProps ? getTagNameInProps(tag) : tag.name;
|
|
65
|
+
return getTagNameInProps ? getTagNameInProps(tag) : tag.label ?? tag.name;
|
|
65
66
|
},
|
|
66
67
|
[getTagNameInProps]
|
|
67
68
|
);
|
|
68
69
|
const renderTag = (item) => {
|
|
69
|
-
const customProps =
|
|
70
|
+
const customProps = getTagPropsInProps == null ? void 0 : getTagPropsInProps(item, tags);
|
|
70
71
|
return /* @__PURE__ */ React.createElement(
|
|
71
72
|
import_antd.Tag,
|
|
72
73
|
{
|
|
73
74
|
...tagProps,
|
|
75
|
+
icon: item.icon,
|
|
74
76
|
color: randomColors ? colors[(0, import_math.random)(0, colors.length - 1)] : item.color ?? "default",
|
|
75
77
|
...customProps
|
|
76
78
|
},
|
|
@@ -91,7 +93,7 @@ var OverflowTags = (props) => {
|
|
|
91
93
|
menu: {
|
|
92
94
|
items: omittedItems.map((tag) => ({
|
|
93
95
|
type: "item",
|
|
94
|
-
key: getTagKey ? getTagKey(tag) : tag.id ?? getTagName(tag),
|
|
96
|
+
key: getTagKey ? getTagKey(tag) : tag.value ?? tag.id ?? getTagName(tag),
|
|
95
97
|
label: getTagName(tag)
|
|
96
98
|
}))
|
|
97
99
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/OverflowTags/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { ReactNode } from 'react';\nimport { useCallback, useContext, useMemo } from 'react';\nimport type { TagProps } from 'antd';\nimport { ConfigProvider, Dropdown, Tag, theme } from 'antd';\nimport { PresetColors } from 'antd/es/theme/internal';\nimport classNames from 'classnames';\nimport type { OverflowProps } from 'rc-overflow';\nimport Overflow from 'rc-overflow';\nimport { random } from '../../utils/math';\nimport useStyle from './style';\n\nexport interface OverflowTagsProps<T extends Record<string, unknown> = Record<string, unknown>>\n extends OverflowProps<T> {\n /**\n * **CN**: 标签集合的数据\n *\n * **EN**: Data collection of tags\n */\n tags: T[] | undefined;\n /**\n * **EN**: Function to get the tag name, default is `tag.name`\n *\n * **CN**: 获取标签名称的函数,默认取`tag.name`\n */\n getTagName?: (tag: T) => ReactNode;\n /**\n * **EN**: Function to get the unique identifier of the tag, default is `tag.id`\n *\n * **CN**: 获取标签唯一标识的函数,默认取`tag.id`\n */\n getTagKey?: (tag: T) => React.Key;\n /**\n * **EN**:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAiD;AAEjD,kBAAqD;AACrD,sBAA6B;AAC7B,wBAAuB;AAEvB,yBAAqB;AACrB,kBAAuB;AACvB,mBAAqB;
|
|
4
|
+
"sourcesContent": ["import type { ReactNode } from 'react';\nimport { useCallback, useContext, useMemo } from 'react';\nimport type { TagProps } from 'antd';\nimport { ConfigProvider, Dropdown, Tag, theme } from 'antd';\nimport { PresetColors } from 'antd/es/theme/internal';\nimport classNames from 'classnames';\nimport type { OverflowProps } from 'rc-overflow';\nimport Overflow from 'rc-overflow';\nimport { random } from '../../utils/math';\nimport useStyle from './style';\n\nexport interface OverflowTagsProps<T extends Record<string, unknown> = Record<string, unknown>>\n extends Omit<OverflowProps<T>, 'renderItem'> {\n /**\n * **CN**: 标签集合的数据\n *\n * **EN**: Data collection of tags\n */\n tags: T[] | undefined;\n /**\n * **EN**: Function to get the tag name, default is `tag.label` or `tag.name`\n *\n * **CN**: 获取标签名称的函数,默认取`tag.label`或`tag.name`\n */\n getTagName?: (tag: T) => ReactNode;\n /**\n * **EN**: Function to get the unique identifier of the tag, default is `tag.value` or `tag.id`\n *\n * **CN**: 获取标签唯一标识的函数,默认取`tag.value`或`tag.id`\n */\n getTagKey?: (tag: T) => React.Key;\n\n /**\n * **EN**: Custom tag rendering function\n *\n * **CN**: 标签渲染函数\n */\n renderTag?: OverflowProps<T>['renderItem'];\n /**\n * **EN**: Custom properties for the default tag rendering function, returning `TagProps`\n *\n * **CN**: 对于默认的标签渲染函数,自定义标签的属性,返回`TagProps`\n */\n getTagProps?: (tag: T, tags: T[]) => TagProps;\n /**\n * **EN**: Custom properties for the tag component, if `renderTag` is also specified, the latter\n * will override the former\n *\n * **CN**: 自定义标签的组件属性,如果同时指定了`renderTag`,则后者会覆盖前者\n */\n tagProps?: TagProps;\n /**\n * **EN**: When the number of tags exceeds the maximum display count, an ellipsis tag will be\n * shown. This property is used to set the style of the ellipsis tag.\n *\n * **CN**: 当标签数量超过最大显示数量时,会显示省略号的标签,此属性用于设置省略号标签的样式\n */\n ellipsisTagProps?: TagProps;\n /**\n * **EN**: Whether to use random colors, default is `false`. Note that the tag object can also\n * contain a `color` property to specify the color, and the latter takes precedence.\n *\n * **CN**: 是否使用随机颜色,默认`false`。注意,tag对象还可以包含`color`属性来指定颜色,而且后者优先级更高。\n */\n randomColors?: boolean;\n}\n\n/**\n * - **EN:** Overflow tags component, used to display a collection of tags that can overflow and be\n * truncated. It supports displaying tags in a dropdown when the number of tags exceeds the\n * maximum display count. It also supports custom tag rendering and properties.\n * - **CN:** 溢出标签组件,用于显示一组可以溢出和截断的标签集合。当标签数量超过最大显示数量时,支持在下拉菜单中显示标签。还支持自定义标签渲染和属性。\n *\n * @example\n * <OverflowTags\n * tags={[\n * { value: 1, label: 'Tag1', icon: <Icon1 /> },\n * { value: 2, label: 'Tag2', icon: <Icon2 /> },\n * ]}\n * tagProps={{ color: 'blue' }}\n * ellipsisTagProps={{ color: 'grey' }}\n * />;\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst OverflowTags = <T extends Record<string, any>>(props: OverflowTagsProps<T>) => {\n const {\n tags = [],\n randomColors,\n getTagName: getTagNameInProps,\n getTagKey,\n getTagProps: getTagPropsInProps,\n tagProps,\n ellipsisTagProps,\n className,\n prefixCls: prefixClsInProps,\n ...restProps\n } = props;\n const { token } = theme.useToken();\n const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);\n const prefixCls = getPrefixCls('easy-overflow-tags', prefixClsInProps);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n\n const colors = useMemo(\n () => PresetColors.filter((c) => !['lime', 'yellow', 'magenta'].includes(c)).map((color) => token[`${color}-3`]),\n [token]\n );\n const getTagName = useCallback(\n (tag: T) => {\n return getTagNameInProps ? getTagNameInProps(tag) : (tag.label ?? tag.name);\n },\n [getTagNameInProps]\n );\n const renderTag = (item: T) => {\n const customProps = getTagPropsInProps?.(item, tags);\n return (\n <Tag\n {...tagProps}\n icon={item.icon}\n color={randomColors ? colors[random(0, colors.length - 1)] : (item.color ?? 'default')}\n {...customProps}\n >\n {getTagName(item)}\n </Tag>\n );\n };\n\n return wrapCSSVar(\n <Overflow<T>\n className={classNames(hashId, cssVarCls, prefixCls, className)}\n data={tags}\n maxCount=\"responsive\"\n renderItem={renderTag}\n renderRest={(omittedItems) => (\n <Dropdown\n menu={{\n items: omittedItems.map((tag) => ({\n type: 'item',\n key: getTagKey ? getTagKey(tag) : (tag.value ?? tag.id ?? getTagName(tag)),\n label: getTagName(tag),\n })),\n }}\n >\n <Tag {...ellipsisTagProps}>+ {omittedItems.length}...</Tag>\n </Dropdown>\n )}\n {...restProps}\n />\n );\n};\n\nexport default OverflowTags;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAiD;AAEjD,kBAAqD;AACrD,sBAA6B;AAC7B,wBAAuB;AAEvB,yBAAqB;AACrB,kBAAuB;AACvB,mBAAqB;AA2ErB,IAAM,eAAe,CAAgC,UAAgC;AACnF,QAAM;AAAA,IACJ,OAAO,CAAC;AAAA,IACR;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,EAAE,MAAM,IAAI,kBAAM,SAAS;AACjC,QAAM,EAAE,aAAa,QAAI,yBAAW,2BAAe,aAAa;AAChE,QAAM,YAAY,aAAa,sBAAsB,gBAAgB;AACrE,QAAM,CAAC,YAAY,QAAQ,SAAS,QAAI,aAAAA,SAAS,SAAS;AAE1D,QAAM,aAAS;AAAA,IACb,MAAM,6BAAa,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,UAAU,SAAS,EAAE,SAAS,CAAC,CAAC,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3
3
|
"sources": ["../../../../src/components/OverflowTags/style/index.ts"],
|
|
4
|
-
"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\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8B;AAO9B,IAAM,WAA6C,CAAC,UAAqB;AACvE,QAAM,EAAE,aAAa,IAAI;AACzB,SAAO;AAAA,IACL,CAAC,YAAY,GAAG;AAAA,MACd,SAAS;AAAA,MACT,UAAU;AAAA,MACV,OAAO;AAAA,MACP,UAAU;AAAA,MACV,UAAU;AAAA,IACZ;AAAA,EACF;AACF;
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8B;AAO9B,IAAM,WAA6C,CAAC,UAAqB;AACvE,QAAM,EAAE,aAAa,IAAI;AACzB,SAAO;AAAA,IACL,CAAC,YAAY,GAAG;AAAA,MACd,SAAS;AAAA,MACT,UAAU;AAAA,MACV,OAAO;AAAA,MACP,UAAU;AAAA,MACV,UAAU;AAAA,IACZ;AAAA,EACF;AACF;AAEA,IAAO,oBAAQ,+BAAc,oBAA6B,QAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,8 +8,12 @@ export type { ConfirmActionProps, ConfirmActionTrigger, ConfirmActionRef } from
|
|
|
8
8
|
export { withDefaultConfirmActionProps } from './ConfirmAction';
|
|
9
9
|
export { default as ConfirmAction } from './ConfirmAction';
|
|
10
10
|
export { default as DeleteConfirmAction } from './DeleteConfirmAction';
|
|
11
|
+
export type { EditableTextProps } from './EditableText';
|
|
12
|
+
export { default as EditableText } from './EditableText';
|
|
11
13
|
export type { FloatDrawerProps } from './FloatDrawer';
|
|
12
14
|
export { default as FloatDrawer } from './FloatDrawer';
|
|
15
|
+
export type { LoadingProps } from './Loading';
|
|
16
|
+
export { default as Loading } from './Loading';
|
|
13
17
|
export type { ModalActionProps, FormCompPropsConstraint, ModalActionTrigger, ModalActionRef } from './ModalAction';
|
|
14
18
|
export { withDefaultModalActionProps, withModalAction } from './ModalAction';
|
|
15
19
|
export { default as ModalAction } from './ModalAction';
|
package/lib/components/index.js
CHANGED
|
@@ -33,7 +33,9 @@ __export(components_exports, {
|
|
|
33
33
|
ConfigProvider: () => import_ConfigProvider.default,
|
|
34
34
|
ConfirmAction: () => import_ConfirmAction2.default,
|
|
35
35
|
DeleteConfirmAction: () => import_DeleteConfirmAction.default,
|
|
36
|
+
EditableText: () => import_EditableText.default,
|
|
36
37
|
FloatDrawer: () => import_FloatDrawer.default,
|
|
38
|
+
Loading: () => import_Loading.default,
|
|
37
39
|
ModalAction: () => import_ModalAction2.default,
|
|
38
40
|
OverflowTags: () => import_OverflowTags.default,
|
|
39
41
|
ReactEasyContext: () => import_context.default,
|
|
@@ -48,7 +50,9 @@ var import_context = __toESM(require("./ConfigProvider/context"));
|
|
|
48
50
|
var import_ConfirmAction = require("./ConfirmAction");
|
|
49
51
|
var import_ConfirmAction2 = __toESM(require("./ConfirmAction"));
|
|
50
52
|
var import_DeleteConfirmAction = __toESM(require("./DeleteConfirmAction"));
|
|
53
|
+
var import_EditableText = __toESM(require("./EditableText"));
|
|
51
54
|
var import_FloatDrawer = __toESM(require("./FloatDrawer"));
|
|
55
|
+
var import_Loading = __toESM(require("./Loading"));
|
|
52
56
|
var import_ModalAction = require("./ModalAction");
|
|
53
57
|
var import_ModalAction2 = __toESM(require("./ModalAction"));
|
|
54
58
|
var import_OverflowTags = __toESM(require("./OverflowTags"));
|
|
@@ -58,7 +62,9 @@ var import_OverflowTags = __toESM(require("./OverflowTags"));
|
|
|
58
62
|
ConfigProvider,
|
|
59
63
|
ConfirmAction,
|
|
60
64
|
DeleteConfirmAction,
|
|
65
|
+
EditableText,
|
|
61
66
|
FloatDrawer,
|
|
67
|
+
Loading,
|
|
62
68
|
ModalAction,
|
|
63
69
|
OverflowTags,
|
|
64
70
|
ReactEasyContext,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/components/index.tsx"],
|
|
4
|
-
"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 { 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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAAsC;AAGtC,4BAA0C;AAE1C,qBAA4C;AAG5C,2BAA8C;AAC9C,IAAAA,wBAAyC;AAGzC,iCAA+C;AAG/C,yBAAuC;AAGvC,yBAA6D;AAC7D,IAAAC,sBAAuC;AAGvC,0BAAwC;",
|
|
4
|
+
"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 { 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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAAsC;AAGtC,4BAA0C;AAE1C,qBAA4C;AAG5C,2BAA8C;AAC9C,IAAAA,wBAAyC;AAGzC,iCAA+C;AAG/C,0BAAwC;AAGxC,yBAAuC;AAGvC,qBAAmC;AAGnC,yBAA6D;AAC7D,IAAAC,sBAAuC;AAGvC,0BAAwC;",
|
|
6
6
|
"names": ["import_ConfirmAction", "import_ModalAction"]
|
|
7
7
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* **EN:** Generate an immutable function reference, the dependencies inside the function will be
|
|
3
|
-
*
|
|
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/useRefFunction.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useRef } from 'react';\n\n/**\n * **EN:** Generate an immutable function reference, the dependencies inside the function will be\n *
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AAapC,IAAM,iBAAiB,CAAoC,OAAsB;AAC/E,QAAM,UAAM,qBAAsB,EAAE;AACpC,MAAI,UAAU;AAGd,aAAO,0BAAa,IAAI,SAAa;AAlBvC;AAkB0C,qBAAI,YAAJ,6BAAc,GAAG;AAAA,KAAa,CAAC,CAAC;AAC1E;AAEA,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/useRefValue.ts"],
|
|
4
|
-
"sourcesContent": ["import { useRef } from 'react';\n\n/**\n * **EN:** Get a mutable ref object and automatically update the value change\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAUvB,IAAM,cAAc,CAAI,UAAa;AACnC,QAAM,UAAM,qBAAU,KAAK;AAC3B,MAAI,UAAU;AACd,SAAO;AACT;AAEA,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/hooks/useT.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/useT.ts"],
|
|
4
|
-
"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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AACpC,qBAA6B;AAC7B,qBAAkB;AAElB,IAAM,OAAO,MAAgB;AAC3B,QAAM,cAAU,yBAAW,eAAAA,OAAgB;AAC3C,QAAM,OAAO,QAAQ;
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AACpC,qBAA6B;AAC7B,qBAAkB;AAElB,IAAM,OAAO,MAAgB;AAC3B,QAAM,cAAU,yBAAW,eAAAA,OAAgB;AAC3C,QAAM,OAAO,QAAQ;AAGrB,aAAO,sBAAQ,MAAM,kBAAG,CAAC,IAAI,CAAC;AAChC;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": ["ReactEasyContext"]
|
|
7
7
|
}
|
|
@@ -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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/useValidator.ts"],
|
|
4
|
-
"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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwB;AAExB,iCAAgC;
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwB;AAExB,iCAAgC;AAMhC,IAAM,eAAe,CAAC,UAA0B;AAC9C,QAAM,cAAU,2BAAAA,SAAoB;AACpC,aAAO,sBAAQ,MAAM,QAAQ,KAAK,GAAG,CAAC,SAAS,KAAK,CAAC;AACvD;AAEA,IAAO,uBAAQ;",
|
|
6
6
|
"names": ["useValidatorBuilder"]
|
|
7
7
|
}
|
|
@@ -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
|
-
*
|
|
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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/useValidatorBuilder.ts"],
|
|
4
|
-
"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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwB;AACxB,kCAAmB;AACnB,kBAAiB;AAEjB,IAAM,gBAAgB;
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwB;AACxB,kCAAmB;AACnB,kBAAiB;AAEjB,IAAM,gBAAgB;AAMtB,IAAM,sBAAsB,MAAM;AAChC,QAAM,QAAI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