@tiny-codes/react-easy 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -1
- package/es/components/BreakLines/index.js +43 -26
- package/es/components/BreakLines/index.js.map +1 -1
- package/es/components/ConfigProvider/context.js +3 -3
- package/es/components/ConfigProvider/context.js.map +1 -1
- package/es/components/ConfigProvider/index.js +37 -35
- package/es/components/ConfigProvider/index.js.map +1 -1
- package/es/components/ConfirmAction/index.d.ts +74 -6
- package/es/components/ConfirmAction/index.js +210 -104
- package/es/components/ConfirmAction/index.js.map +1 -1
- package/es/components/DeleteConfirmAction/index.js +22 -20
- package/es/components/DeleteConfirmAction/index.js.map +1 -1
- package/es/components/ModalAction/index.d.ts +45 -5
- package/es/components/ModalAction/index.js +393 -209
- package/es/components/ModalAction/index.js.map +1 -1
- package/es/components/index.d.ts +5 -1
- package/es/components/index.js +10 -7
- package/es/components/index.js.map +1 -1
- package/es/hooks/index.js +4 -4
- package/es/hooks/index.js.map +1 -1
- package/es/hooks/useContextValidator.js +7 -12
- package/es/hooks/useContextValidator.js.map +1 -1
- package/es/hooks/useLocalizedText.js +6 -4
- package/es/hooks/useLocalizedText.js.map +1 -1
- package/es/hooks/useRefFunction.js +13 -6
- package/es/hooks/useRefFunction.js.map +1 -1
- package/es/hooks/useT.js +11 -8
- package/es/hooks/useT.js.map +1 -1
- package/es/hooks/useValidator.js +7 -4
- package/es/hooks/useValidator.js.map +1 -1
- package/es/hooks/useValidatorBuilder.js +146 -117
- package/es/hooks/useValidatorBuilder.js.map +1 -1
- package/es/hooks/useValidators.js +94 -58
- package/es/hooks/useValidators.js.map +1 -1
- package/es/index.js +2 -2
- package/es/index.js.map +1 -1
- package/es/locales/index.js +19 -13
- package/es/locales/index.js.map +1 -1
- package/es/locales/langs/en-US.js +20 -20
- package/es/locales/langs/en-US.js.map +1 -1
- package/es/locales/langs/en.js +1 -1
- package/es/locales/langs/en.js.map +1 -1
- package/es/locales/langs/zh-CN.js +20 -20
- package/es/locales/langs/zh-CN.js.map +1 -1
- package/es/utils/index.js +1 -1
- package/es/utils/index.js.map +1 -1
- package/lib/components/BreakLines/index.js +50 -37
- package/lib/components/BreakLines/index.js.map +7 -1
- package/lib/components/ConfigProvider/context.js +35 -6
- package/lib/components/ConfigProvider/context.js.map +7 -1
- package/lib/components/ConfigProvider/index.js +56 -42
- package/lib/components/ConfigProvider/index.js.map +7 -1
- package/lib/components/ConfirmAction/index.d.ts +74 -6
- package/lib/components/ConfirmAction/index.js +194 -138
- package/lib/components/ConfirmAction/index.js.map +7 -1
- package/lib/components/DeleteConfirmAction/index.js +50 -51
- package/lib/components/DeleteConfirmAction/index.js.map +7 -1
- package/lib/components/ModalAction/index.d.ts +45 -5
- package/lib/components/ModalAction/index.js +303 -243
- package/lib/components/ModalAction/index.js.map +7 -1
- package/lib/components/index.d.ts +5 -1
- package/lib/components/index.js +63 -10
- package/lib/components/index.js.map +7 -1
- package/lib/hooks/index.js +49 -5
- package/lib/hooks/index.js.map +7 -1
- package/lib/hooks/useContextValidator.js +47 -11
- package/lib/hooks/useContextValidator.js.map +7 -1
- package/lib/hooks/useLocalizedText.js +41 -15
- package/lib/hooks/useLocalizedText.js.map +7 -1
- package/lib/hooks/useRefFunction.js +34 -21
- package/lib/hooks/useRefFunction.js.map +7 -1
- package/lib/hooks/useT.js +43 -11
- package/lib/hooks/useT.js.map +7 -1
- package/lib/hooks/useValidator.js +41 -12
- package/lib/hooks/useValidator.js.map +7 -1
- package/lib/hooks/useValidatorBuilder.js +149 -132
- package/lib/hooks/useValidatorBuilder.js.map +7 -1
- package/lib/hooks/useValidators.js +104 -67
- package/lib/hooks/useValidators.js.map +7 -1
- package/lib/index.js +26 -3
- package/lib/index.js.map +7 -1
- package/lib/locales/index.js +58 -15
- package/lib/locales/index.js.map +7 -1
- package/lib/locales/langs/en-US.js +46 -22
- package/lib/locales/langs/en-US.js.map +7 -1
- package/lib/locales/langs/en.js +37 -3
- package/lib/locales/langs/en.js.map +7 -1
- package/lib/locales/langs/zh-CN.js +46 -22
- package/lib/locales/langs/zh-CN.js.map +7 -1
- package/lib/utils/index.js +1 -2
- package/lib/utils/index.js.map +7 -1
- package/package.json +14 -15
- package/es/hooks/useValidateContext.d.ts +0 -2
- package/es/hooks/useValidateContext.js +0 -16
- package/es/hooks/useValidateContext.js.map +0 -1
- package/lib/hooks/useValidateContext.d.ts +0 -2
- package/lib/hooks/useValidateContext.js +0 -16
- package/lib/hooks/useValidateContext.js.map +0 -1
|
@@ -1,139 +1,156 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/hooks/useValidatorBuilder.ts
|
|
30
|
+
var useValidatorBuilder_exports = {};
|
|
31
|
+
__export(useValidatorBuilder_exports, {
|
|
32
|
+
default: () => useValidatorBuilder_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(useValidatorBuilder_exports);
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_escape_string_regexp = __toESM(require("escape-string-regexp"));
|
|
37
|
+
var import_useT = __toESM(require("./useT"));
|
|
38
|
+
var nameSeparator = "validation.rule.buildRule.token.separator";
|
|
39
|
+
var useValidatorBuilder = () => {
|
|
40
|
+
const t = (0, import_useT.default)();
|
|
41
|
+
return (0, import_react.useMemo)(() => (props) => buildRule({ ...props, t }), [t]);
|
|
13
42
|
};
|
|
14
|
-
/**
|
|
15
|
-
* **EN:** Build regular expression rules dynamically, compatible with ant-design rules
|
|
16
|
-
*
|
|
17
|
-
* **CN:** 动态构建正则表达式规则,与 ant-design 的规则兼容
|
|
18
|
-
*/
|
|
19
43
|
function buildRule(options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
messages.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
messages.unshift(`${meta.messages.join(t(nameSeparator))}`);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
messages.unshift(`${meta.messages.join(t(nameSeparator))}`);
|
|
56
|
-
}
|
|
57
|
-
if (min && max) {
|
|
58
|
-
messages.push(t('validation.rule.buildRule.rangeLength', {
|
|
59
|
-
min,
|
|
60
|
-
max,
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
if (min > 1) {
|
|
65
|
-
messages.push(t('validation.rule.buildRule.minLength', { min }));
|
|
66
|
-
}
|
|
67
|
-
if (max) {
|
|
68
|
-
messages.push(t('validation.rule.buildRule.maxLength', { max }));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
44
|
+
const { allowed, startsWith, flags, t } = options;
|
|
45
|
+
if (!Object.values(allowed).some((v) => v === true)) {
|
|
46
|
+
throw new Error(t("validation.rule.buildRule.includeMandatory"));
|
|
47
|
+
}
|
|
48
|
+
const symbols = [];
|
|
49
|
+
const messages = [];
|
|
50
|
+
symbols.push(`^`);
|
|
51
|
+
if (startsWith) {
|
|
52
|
+
const meta = buildRuleMeta({
|
|
53
|
+
flags: startsWith,
|
|
54
|
+
t
|
|
55
|
+
});
|
|
56
|
+
symbols.push(`[${meta.symbols.join("")}]`);
|
|
57
|
+
messages.push(
|
|
58
|
+
t("validation.rule.buildRule.startsWithFormat", {
|
|
59
|
+
prefix: meta.messages.join(t(nameSeparator))
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
{
|
|
64
|
+
const meta = buildRuleMeta({ flags: allowed, t });
|
|
65
|
+
const min = allowed.min ?? 0;
|
|
66
|
+
const max = allowed.max ?? 0;
|
|
67
|
+
const cMin = min && startsWith ? min - 1 : min;
|
|
68
|
+
const cMax = max && startsWith ? max - 1 : max;
|
|
69
|
+
symbols.push(`[${meta.symbols.join("")}]{${cMin},${cMax || ""}}`);
|
|
70
|
+
if (meta.messages.length === 0) {
|
|
71
|
+
messages.unshift(``);
|
|
72
|
+
} else if (meta.messages.length === 1) {
|
|
73
|
+
messages.unshift(`${meta.messages.join(t(nameSeparator))}`);
|
|
74
|
+
} else {
|
|
75
|
+
messages.unshift(`${meta.messages.join(t(nameSeparator))}`);
|
|
71
76
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
if (min && max) {
|
|
78
|
+
messages.push(
|
|
79
|
+
t("validation.rule.buildRule.rangeLength", {
|
|
80
|
+
min,
|
|
81
|
+
max
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
} else {
|
|
85
|
+
if (min > 1) {
|
|
86
|
+
messages.push(t("validation.rule.buildRule.minLength", { min }));
|
|
87
|
+
}
|
|
88
|
+
if (max) {
|
|
89
|
+
messages.push(t("validation.rule.buildRule.maxLength", { max }));
|
|
90
|
+
}
|
|
76
91
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
92
|
+
}
|
|
93
|
+
symbols.push(`$`);
|
|
94
|
+
let message = messages.join("");
|
|
95
|
+
if (message.startsWith(t(nameSeparator))) {
|
|
96
|
+
message = message.slice(1);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
pattern: new RegExp(symbols.join(""), flags),
|
|
100
|
+
message: t("validation.rule.buildRule.messageFormat", { content: message }),
|
|
101
|
+
allowedOptions: allowed,
|
|
102
|
+
startsWithOptions: startsWith,
|
|
103
|
+
flags
|
|
104
|
+
};
|
|
84
105
|
}
|
|
85
106
|
function buildRuleMeta(options) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
symbols,
|
|
135
|
-
messages,
|
|
136
|
-
};
|
|
107
|
+
const { flags, t } = options;
|
|
108
|
+
const symbols = [];
|
|
109
|
+
const messages = [];
|
|
110
|
+
if (flags.chineseCharacter) {
|
|
111
|
+
symbols.push(`一-龥`);
|
|
112
|
+
messages.push(t("validation.rule.buildRule.token.chinese"));
|
|
113
|
+
}
|
|
114
|
+
if (flags.chinesePunctuation) {
|
|
115
|
+
symbols.push(` -〞`);
|
|
116
|
+
symbols.push(`〡-〿`);
|
|
117
|
+
symbols.push(`-`);
|
|
118
|
+
messages.push(t("validation.rule.buildRule.token.chinesePunctuation"));
|
|
119
|
+
}
|
|
120
|
+
if (flags.letter) {
|
|
121
|
+
symbols.push(`a-zA-Z`);
|
|
122
|
+
messages.push(t("validation.rule.buildRule.token.letter"));
|
|
123
|
+
} else if (flags.lowerLetter) {
|
|
124
|
+
symbols.push(`a-z`);
|
|
125
|
+
messages.push(t("validation.rule.buildRule.token.lowerLetter"));
|
|
126
|
+
} else if (flags.upperLetter) {
|
|
127
|
+
symbols.push(`A-Z`);
|
|
128
|
+
messages.push(t("validation.rule.buildRule.token.upperLetter"));
|
|
129
|
+
}
|
|
130
|
+
if (flags.number) {
|
|
131
|
+
symbols.push(`0-9`);
|
|
132
|
+
messages.push(t("validation.rule.buildRule.token.number"));
|
|
133
|
+
}
|
|
134
|
+
const excludeSpecials = [];
|
|
135
|
+
if (flags.hyphen) {
|
|
136
|
+
symbols.push(`\\-`);
|
|
137
|
+
messages.push(`-`);
|
|
138
|
+
excludeSpecials.push("-");
|
|
139
|
+
}
|
|
140
|
+
if (flags.underscore) {
|
|
141
|
+
symbols.push(`_`);
|
|
142
|
+
messages.push(`_`);
|
|
143
|
+
excludeSpecials.push("_");
|
|
144
|
+
}
|
|
145
|
+
if (flags.special) {
|
|
146
|
+
const specials = flags.special.filter((v) => !excludeSpecials.includes(v));
|
|
147
|
+
symbols.push((0, import_escape_string_regexp.default)(specials.join("")));
|
|
148
|
+
messages.push(specials.join(t(nameSeparator)));
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
symbols,
|
|
152
|
+
messages
|
|
153
|
+
};
|
|
137
154
|
}
|
|
138
|
-
|
|
139
|
-
//# sourceMappingURL=useValidatorBuilder.js.map
|
|
155
|
+
var useValidatorBuilder_default = useValidatorBuilder;
|
|
156
|
+
//# sourceMappingURL=useValidatorBuilder.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 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 *\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"],
|
|
5
|
+
"mappings": ";;;;;;;;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codeWithMax = useRefFunction((max) => build({
|
|
15
|
-
allowed: { letter: true, number: true, underscore: true, max },
|
|
16
|
-
startsWith: { letter: true },
|
|
17
|
-
}));
|
|
18
|
-
const nameWithMax = useRefFunction((max) => build({
|
|
19
|
-
allowed: { letter: true, number: true, hyphen: true, underscore: true, chineseCharacter: true, max },
|
|
20
|
-
startsWith: { chineseCharacter: true, letter: true },
|
|
21
|
-
}));
|
|
22
|
-
const strongNameWithMax = useRefFunction((max) => build({
|
|
23
|
-
allowed: { letter: true, number: true, hyphen: true, underscore: true, chineseCharacter: true, max },
|
|
24
|
-
startsWith: { chineseCharacter: true, letter: true },
|
|
25
|
-
}));
|
|
26
|
-
return useMemo(() => ({
|
|
27
|
-
number: {
|
|
28
|
-
pattern: /^\d+$/,
|
|
29
|
-
message: t('validation.rule.number.message'),
|
|
30
|
-
},
|
|
31
|
-
floatNumber: {
|
|
32
|
-
pattern: /^-?\d+(\.\d+)?$/,
|
|
33
|
-
message: t('validation.rule.floatNumber.message'),
|
|
34
|
-
},
|
|
35
|
-
email: {
|
|
36
|
-
pattern: /^[A-Za-z0-9_\u4e00-\u9fa5-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
|
|
37
|
-
message: t('validation.rule.email.message'),
|
|
38
|
-
},
|
|
39
|
-
ip: {
|
|
40
|
-
pattern: /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
|
|
41
|
-
message: t('validation.rule.ip.message'),
|
|
42
|
-
},
|
|
43
|
-
cnMobile: {
|
|
44
|
-
pattern: /^(?:\+86\s*)?1[23456789]\d{9}$/,
|
|
45
|
-
message: t('validation.rule.mobile.message'),
|
|
46
|
-
},
|
|
47
|
-
password: {
|
|
48
|
-
pattern: /^(?![\d]+$)(?![a-z]+$)(?![A-Z]+$)(?![!@#$%^&*~()-+`_=|\\{};:'"/,.<>?]+$)[\da-zA-z!@#$%^&*~()-+`_=|\\{};:'"/,.<>?]{8,16}$/,
|
|
49
|
-
message: 'validation.rule.password.message',
|
|
50
|
-
},
|
|
51
|
-
code: codeWithMax(undefined),
|
|
52
|
-
codeMax20: codeWithMax(20),
|
|
53
|
-
codeMax64: codeWithMax(64),
|
|
54
|
-
codeMax128: codeWithMax(128),
|
|
55
|
-
codeWithMax,
|
|
56
|
-
name: nameWithMax(undefined),
|
|
57
|
-
nameMax20: nameWithMax(20),
|
|
58
|
-
nameMax64: nameWithMax(64),
|
|
59
|
-
nameMax128: nameWithMax(128),
|
|
60
|
-
nameWithMax,
|
|
61
|
-
strongName: strongNameWithMax(undefined),
|
|
62
|
-
strongNameMax64: strongNameWithMax(64),
|
|
63
|
-
strongNameMax128: strongNameWithMax(128),
|
|
64
|
-
strongNameWithMax,
|
|
65
|
-
}), [codeWithMax, nameWithMax, strongNameWithMax, t]);
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
66
10
|
};
|
|
67
|
-
|
|
68
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/hooks/useValidators.ts
|
|
30
|
+
var useValidators_exports = {};
|
|
31
|
+
__export(useValidators_exports, {
|
|
32
|
+
default: () => useValidators_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(useValidators_exports);
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_useRefFunction = __toESM(require("./useRefFunction"));
|
|
37
|
+
var import_useT = __toESM(require("./useT"));
|
|
38
|
+
var import_useValidatorBuilder = __toESM(require("./useValidatorBuilder"));
|
|
39
|
+
var useValidators = () => {
|
|
40
|
+
const t = (0, import_useT.default)();
|
|
41
|
+
const build = (0, import_useValidatorBuilder.default)();
|
|
42
|
+
const codeWithMax = (0, import_useRefFunction.default)(
|
|
43
|
+
(max) => build({
|
|
44
|
+
allowed: { letter: true, number: true, underscore: true, max },
|
|
45
|
+
startsWith: { letter: true }
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
const nameWithMax = (0, import_useRefFunction.default)(
|
|
49
|
+
(max) => build({
|
|
50
|
+
allowed: { letter: true, number: true, hyphen: true, underscore: true, chineseCharacter: true, max },
|
|
51
|
+
startsWith: { chineseCharacter: true, letter: true }
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
const strongNameWithMax = (0, import_useRefFunction.default)(
|
|
55
|
+
(max) => build({
|
|
56
|
+
allowed: { letter: true, number: true, hyphen: true, underscore: true, chineseCharacter: true, max },
|
|
57
|
+
startsWith: { chineseCharacter: true, letter: true }
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
return (0, import_react.useMemo)(
|
|
61
|
+
() => ({
|
|
62
|
+
number: {
|
|
63
|
+
pattern: /^\d+$/,
|
|
64
|
+
message: t("validation.rule.number.message")
|
|
65
|
+
},
|
|
66
|
+
floatNumber: {
|
|
67
|
+
pattern: /^-?\d+(\.\d+)?$/,
|
|
68
|
+
message: t("validation.rule.floatNumber.message")
|
|
69
|
+
},
|
|
70
|
+
email: {
|
|
71
|
+
pattern: /^[A-Za-z0-9_\u4e00-\u9fa5-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
|
|
72
|
+
message: t("validation.rule.email.message")
|
|
73
|
+
},
|
|
74
|
+
ip: {
|
|
75
|
+
pattern: /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
|
|
76
|
+
message: t("validation.rule.ip.message")
|
|
77
|
+
},
|
|
78
|
+
cnMobile: {
|
|
79
|
+
pattern: /^(?:\+86\s*)?1[23456789]\d{9}$/,
|
|
80
|
+
message: t("validation.rule.mobile.message")
|
|
81
|
+
},
|
|
82
|
+
password: {
|
|
83
|
+
pattern: /^(?![\d]+$)(?![a-z]+$)(?![A-Z]+$)(?![!@#$%^&*~()-+`_=|\\{};:'"/,.<>?]+$)[\da-zA-z!@#$%^&*~()-+`_=|\\{};:'"/,.<>?]{8,16}$/,
|
|
84
|
+
message: "validation.rule.password.message"
|
|
85
|
+
},
|
|
86
|
+
code: codeWithMax(void 0),
|
|
87
|
+
codeMax20: codeWithMax(20),
|
|
88
|
+
codeMax64: codeWithMax(64),
|
|
89
|
+
codeMax128: codeWithMax(128),
|
|
90
|
+
codeWithMax,
|
|
91
|
+
name: nameWithMax(void 0),
|
|
92
|
+
nameMax20: nameWithMax(20),
|
|
93
|
+
nameMax64: nameWithMax(64),
|
|
94
|
+
nameMax128: nameWithMax(128),
|
|
95
|
+
nameWithMax,
|
|
96
|
+
strongName: strongNameWithMax(void 0),
|
|
97
|
+
strongNameMax64: strongNameWithMax(64),
|
|
98
|
+
strongNameMax128: strongNameWithMax(128),
|
|
99
|
+
strongNameWithMax
|
|
100
|
+
}),
|
|
101
|
+
[codeWithMax, nameWithMax, strongNameWithMax, t]
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
var useValidators_default = useValidators;
|
|
105
|
+
//# sourceMappingURL=useValidators.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/useValidators.ts"],
|
|
4
|
+
"sourcesContent": ["import { useMemo } from 'react';\nimport useRefFunction from './useRefFunction';\nimport useT from './useT';\nimport useValidatorBuilder, { type Validator, type ValidatorRule } from './useValidatorBuilder';\n\n/**\n * **EN:** Get built-in validation rules, used to verify common data formats, compatible with\n * ant-design rules\n *\n * **CN:** 获取内置的校验规则,用于校验常见的数据格式,与 ant-design 的规则兼容\n */\nconst useValidators = (): ValidatorRuleMap => {\n const t = useT();\n const build = useValidatorBuilder();\n\n const codeWithMax = useRefFunction((max?: number) =>\n build({\n allowed: { letter: true, number: true, underscore: true, max },\n startsWith: { letter: true },\n })\n );\n const nameWithMax = useRefFunction((max?: number) =>\n build({\n allowed: { letter: true, number: true, hyphen: true, underscore: true, chineseCharacter: true, max },\n startsWith: { chineseCharacter: true, letter: true },\n })\n );\n const strongNameWithMax = useRefFunction((max?: number) =>\n build({\n allowed: { letter: true, number: true, hyphen: true, underscore: true, chineseCharacter: true, max },\n startsWith: { chineseCharacter: true, letter: true },\n })\n );\n\n return useMemo<ValidatorRuleMap>(\n () => ({\n number: {\n pattern: /^\\d+$/,\n message: t('validation.rule.number.message'),\n },\n floatNumber: {\n pattern: /^-?\\d+(\\.\\d+)?$/,\n message: t('validation.rule.floatNumber.message'),\n },\n email: {\n pattern: /^[A-Za-z0-9_\\u4e00-\\u9fa5-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$/,\n message: t('validation.rule.email.message'),\n },\n ip: {\n pattern: /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,\n message: t('validation.rule.ip.message'),\n },\n cnMobile: {\n pattern: /^(?:\\+86\\s*)?1[23456789]\\d{9}$/,\n message: t('validation.rule.mobile.message'),\n },\n password: {\n pattern:\n /^(?![\\d]+$)(?![a-z]+$)(?![A-Z]+$)(?![!@#$%^&*~()-+`_=|\\\\{};:'\"/,.<>?]+$)[\\da-zA-z!@#$%^&*~()-+`_=|\\\\{};:'\"/,.<>?]{8,16}$/,\n message: 'validation.rule.password.message',\n },\n\n code: codeWithMax(undefined),\n codeMax20: codeWithMax(20),\n codeMax64: codeWithMax(64),\n codeMax128: codeWithMax(128),\n codeWithMax,\n\n name: nameWithMax(undefined),\n nameMax20: nameWithMax(20),\n nameMax64: nameWithMax(64),\n nameMax128: nameWithMax(128),\n nameWithMax,\n\n strongName: strongNameWithMax(undefined),\n strongNameMax64: strongNameWithMax(64),\n strongNameMax128: strongNameWithMax(128),\n strongNameWithMax,\n }),\n [codeWithMax, nameWithMax, strongNameWithMax, t]\n );\n};\n\nexport interface ValidatorRuleMap {\n /**\n * **EN:** Number\n *\n * **CN:** 数字\n */\n number: Validator;\n /**\n * **EN:** Floating point number\n *\n * **CN:** 浮点数\n */\n floatNumber: Validator;\n /**\n * **EN:** Email address regular expression (supports Chinese names)\n *\n * **CN:** 邮箱正则表达式(支持中文名称)\n */\n email: Validator;\n /**\n * **EN:** IP address regular expression\n *\n * **CN:** ip地址正则表达式\n */\n ip: Validator;\n /**\n * **EN:** Chine mobile phone number regular expression. If this rule does not meet the\n * requirements, please use the `useValidator` method to customize the rule.\n *\n * **CN:** 中国手机号正则表达式。如果这个规则不满足需求,请使用 `useValidator` 方法自定义规则。\n */\n cnMobile: Validator;\n /**\n * **EN:** Default password verification rule: 8-16 digit password, at least two of numbers,\n * letters, and symbols. If this rule does not meet the requirements, please use the\n * `useValidator` method to customize the rule.\n *\n * **CN:** 默认密码验证规则:8-16位密码,数字、字母、符号至少包含两种。如果这个规则不满足需求,请使用 `useValidator` 方法自定义规则。\n */\n password: Validator;\n\n /**\n * **EN:** Used to verify the code rule: letters, numbers, _, starting with a letter, no limit on\n * the number of characters\n *\n * **CN:** 用于校验编码的规则:字母、数字、_,以字母开头,不限制字符数量\n */\n code: ValidatorRule;\n /**\n * **EN:** Used to verify the code rule: letters, numbers, _, starting with a letter, up to 20\n * characters\n *\n * **CN:** 用于校验编码的规则:字母、数字、_,以字母开头,最多20个字符\n */\n codeMax20: ValidatorRule;\n /**\n * **EN:** Used to verify the code rule: letters, numbers, _, starting with a letter, up to 64\n * characters\n *\n * **CN:** 用于校验编码的规则:字母、数字、_,以字母开头,最多64个字符\n */\n codeMax64: ValidatorRule;\n /**\n * **EN:** Used to verify the code rule: letters, numbers, _, starting with a letter, up to 128\n * characters\n *\n * **CN:** 用于校验编码的规则:字母、数字、_,以字母开头,最多128个字符\n */\n codeMax128: ValidatorRule;\n /**\n * **EN:** Used to verify the code rule: letters, numbers, _, starting with a letter, up to {max}\n * characters\n *\n * **CN:** 用于校验名称的规则,可以自定义最大字符数:字母、汉字、数字、-、_,以汉字、字母开头,{max}字符以内\n */\n codeWithMax: (max?: number) => ValidatorRule;\n\n /**\n * **EN:** Used to verify the name rule: letters, Chinese characters, numbers, -, _, up to 20\n * characters\n *\n * **CN:** 用于校验名称的规则:字母、汉字、数字、-、_,最多20个字符,\n */\n name: ValidatorRule;\n /**\n * **EN:** Used to verify the name rule: letters, Chinese characters, numbers, -, _, up to 64\n *\n * **CN:** 用于校验名称的规则:字母、汉字、数字、-、_,不限制字符数量\n */\n nameMax20: ValidatorRule;\n /**\n * **EN:** Used to verify the name rule: letters, Chinese characters, numbers, -, _, up to 64\n * characters\n *\n * **CN:** 用于校验名称的规则:字母、汉字、数字、-、_,最多64个字符\n */\n nameMax64: ValidatorRule;\n /**\n * **EN:** Used to verify the name rule: letters, Chinese characters, numbers, -, _, up to 128\n * characters\n *\n * **CN:** 用于校验名称的规则:字母、汉字、数字、-、_,最多128个字符\n */\n nameMax128: ValidatorRule;\n /**\n * **EN:** Used to verify the name rule: letters, Chinese characters, numbers, -, _, up to {max}\n * characters\n *\n * **CN:** 用于校验名称的规则,可以自定义最大字符数:字母、汉字、数字、-、_,以汉字、字母开头,{max}字符以内\n */\n nameWithMax: (max?: number) => ValidatorRule;\n\n /**\n * **EN:** Used to verify the name rule, but it needs to start with Chinese characters or letters:\n * letters, Chinese characters, numbers, -, _, starting with Chinese characters or letters\n *\n * **CN:** 用于校验名称的规则,但需要以汉字或字母开头:字母、汉字、数字、-、_,以汉字、字母开头\n */\n strongName: ValidatorRule;\n /**\n * **EN:** Used to verify the name rule, but it needs to start with Chinese characters or letters:\n * letters, Chinese characters, numbers, -, _, starting with Chinese characters or letters, up to\n * 64 characters\n *\n * **CN:** 用于校验名称的规则,但需要以汉字或字母开头:字母、汉字、数字、-、_,以汉字、字母开头,最多64个字符\n */\n strongNameMax64: ValidatorRule;\n /**\n * **EN:** Used to verify the name rule, but it needs to start with Chinese characters or letters:\n * letters, Chinese characters, numbers, -, _, starting with Chinese characters or letters, up to\n * 128 characters\n *\n * **CN:** 用于校验名称的规则,但需要以汉字或字母开头:字母、汉字、数字、-、_,以汉字、字母开头,最多128个字符\n */\n strongNameMax128: ValidatorRule;\n /**\n * **EN:** Used to verify the name rule, but it needs to start with Chinese characters or letters:\n * letters, Chinese characters, numbers, -, _, starting with Chinese characters or letters, up to\n * {max} characters\n *\n * **CN:** 用于校验名称的规则,但需要以汉字或字母开头:字母、汉字、数字、-、_,以汉字、字母开头,{max}字符以内\n */\n strongNameWithMax: (max?: number) => ValidatorRule;\n}\n\nexport default useValidators;\n"],
|
|
5
|
+
"mappings": ";;;;;;;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AAA,QACR,SAAS;AAAA,QACT,SAAS,EAAE,gCAAgC;AAAA,MAC7C;AAAA,MACA,UAAU;AAAA,QACR,SACE;AAAA,QACF,SAAS;AAAA,MACX;AAAA,MAEA,MAAM,YAAY,MAAS;AAAA,MAC3B,WAAW,YAAY,EAAE;AAAA,MACzB,WAAW,YAAY,EAAE;AAAA,MACzB,YAAY,YAAY,GAAG;AAAA,MAC3B;AAAA,MAEA,MAAM,YAAY,MAAS;AAAA,MAC3B,WAAW,YAAY,EAAE;AAAA,MACzB,WAAW,YAAY,EAAE;AAAA,MACzB,YAAY,YAAY,GAAG;AAAA,MAC3B;AAAA,MAEA,YAAY,kBAAkB,MAAS;AAAA,MACvC,iBAAiB,kBAAkB,EAAE;AAAA,MACrC,kBAAkB,kBAAkB,GAAG;AAAA,MACvC;AAAA,IACF;AAAA,IACA,CAAC,aAAa,aAAa,mBAAmB,CAAC;AAAA,EACjD;AACF;AAmJA,IAAO,wBAAQ;",
|
|
6
|
+
"names": ["useT", "useValidatorBuilder", "useRefFunction"]
|
|
7
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
|
19
|
+
__reExport(src_exports, require("./components"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./hooks"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("./components"),
|
|
24
|
+
...require("./hooks")
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './components';\nexport * from './hooks';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,yBAAd;AACA,wBAAc,oBADd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|