phecda-core 1.1.1 → 1.2.1

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/dist/index.mjs CHANGED
@@ -223,29 +223,6 @@ function Tag(tag) {
223
223
  };
224
224
  }
225
225
  __name(Tag, "Tag");
226
- function Storage(target) {
227
- init(target.prototype);
228
- const tag = target.prototype._namespace.__TAG__;
229
- if (tag === "")
230
- throw new Error("miss tag");
231
- const uniTag = Symbol(tag);
232
- setModalVar(target.prototype, uniTag);
233
- regisHandler(target.prototype, uniTag, {
234
- init: (instance) => {
235
- const { state } = instance;
236
- globalThis.addEventListener("beforeunload", () => {
237
- localStorage.setItem(`_phecda_${tag}`, JSON.stringify(state));
238
- });
239
- const lastObjStr = localStorage.getItem(`_phecda_${tag}`);
240
- if (lastObjStr && lastObjStr !== "undefined") {
241
- const lastObj = JSON.parse(lastObjStr);
242
- for (const i in lastObj)
243
- state[i] = lastObj[i];
244
- }
245
- }
246
- });
247
- }
248
- __name(Storage, "Storage");
249
226
  function Global(target) {
250
227
  if (!globalThis.__PHECDA__)
251
228
  globalThis.__PHECDA__ = {};
@@ -330,83 +307,6 @@ function addDecoToClass(c, key, handler, type = "normal") {
330
307
  }
331
308
  __name(addDecoToClass, "addDecoToClass");
332
309
 
333
- // src/preset/rule.ts
334
- function isArray(info) {
335
- return Rule((param) => Array.isArray(param), info || "it should be an array");
336
- }
337
- __name(isArray, "isArray");
338
- function isBoolean(info) {
339
- return Rule((param) => [
340
- true,
341
- false
342
- ].includes(param), info || "it should be true or false");
343
- }
344
- __name(isBoolean, "isBoolean");
345
- function isNumber(info) {
346
- return Rule((param) => typeof param === "number", info || "it should be true or false");
347
- }
348
- __name(isNumber, "isNumber");
349
- function isString(info) {
350
- return Rule((param) => typeof param === "string", info || "it should be a string");
351
- }
352
- __name(isString, "isString");
353
- function isObject2(info) {
354
- return Rule((param) => {
355
- return Object.prototype.toString.call(param) === "[object Object]";
356
- }, info || "it should be an object");
357
- }
358
- __name(isObject2, "isObject");
359
- function isMobile(info) {
360
- return Rule(/^((\+|00)86)?1((3[\d])|(4[5,6,7,9])|(5[0-3,5-9])|(6[5-7])|(7[0-8])|(8[\d])|(9[1,8,9]))\d{8}$/, info || "it should be a mobile phone number");
361
- }
362
- __name(isMobile, "isMobile");
363
- function isLandline(info) {
364
- return Rule(/\d{3}-\d{8}|\d{4}-\d{7}/, info || "it should be a mobile phone number");
365
- }
366
- __name(isLandline, "isLandline");
367
- function isMailBox(info) {
368
- return Rule(/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, info || "it should be a mailbox number");
369
- }
370
- __name(isMailBox, "isMailBox");
371
- function isIdCard(info) {
372
- return Rule(/(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0\d|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/, info || "it should be an identity card number");
373
- }
374
- __name(isIdCard, "isIdCard");
375
- function isCnName(info) {
376
- return Rule(/^([\u4E00-\u9FA5·]{2,16})$/, info || "\u9700\u8981\u662F\u4E00\u4E2A\u5408\u7406\u7684\u4E2D\u6587\u540D\u5B57");
377
- }
378
- __name(isCnName, "isCnName");
379
- function isEnName(info) {
380
- return Rule(/(^[a-zA-Z]{1}[a-zA-Z\s]{0,20}[a-zA-Z]{1}$)/, info || "it should be a valid en-name");
381
- }
382
- __name(isEnName, "isEnName");
383
- function isDate(info) {
384
- return Rule(/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/, info || "it should be a valid date");
385
- }
386
- __name(isDate, "isDate");
387
- function isWechat(info) {
388
- return Rule(/^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/, info || "it should be a valid date");
389
- }
390
- __name(isWechat, "isWechat");
391
- function isHexColor(info) {
392
- return Rule(/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/, info || "it should be a valid hex-color");
393
- }
394
- __name(isHexColor, "isHexColor");
395
- function isPostalCode(info) {
396
- return Rule(/^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/, info || "it should be a valid postal code");
397
- }
398
- __name(isPostalCode, "isPostalCode");
399
-
400
- // src/preset/pipe.ts
401
- function toNumber() {
402
- return Pipe(to((param) => Number(param)));
403
- }
404
- __name(toNumber, "toNumber");
405
- function toString() {
406
- return Pipe(to((param) => String(param)));
407
- }
408
- __name(toString, "toString");
409
-
410
310
  // src/namespace.ts
411
311
  var activeInstance = {};
412
312
  function injectProperty(key, value) {
@@ -436,6 +336,41 @@ function Watcher(eventName, options) {
436
336
  };
437
337
  }
438
338
  __name(Watcher, "Watcher");
339
+ function Storage(storeKey) {
340
+ return (target, key) => {
341
+ let tag;
342
+ if (key) {
343
+ init(target);
344
+ tag = storeKey || target._namespace.__TAG__;
345
+ const uniTag = Symbol(tag);
346
+ setModalVar(target, uniTag);
347
+ regisHandler(target, uniTag, {
348
+ init: (instance) => {
349
+ getProperty("storage")?.({
350
+ instance,
351
+ key,
352
+ tag
353
+ });
354
+ }
355
+ });
356
+ } else {
357
+ init(target.prototype);
358
+ tag = storeKey || `${target.prototype._namespace.__TAG__}_${key}`;
359
+ const uniTag = Symbol(tag);
360
+ setModalVar(target.prototype, uniTag);
361
+ regisHandler(target.prototype, uniTag, {
362
+ init: (instance) => {
363
+ getProperty("storage")?.({
364
+ instance,
365
+ key: "",
366
+ tag
367
+ });
368
+ }
369
+ });
370
+ }
371
+ };
372
+ }
373
+ __name(Storage, "Storage");
439
374
  export {
440
375
  Clear,
441
376
  Err,
@@ -461,22 +396,7 @@ export {
461
396
  getTag,
462
397
  init,
463
398
  injectProperty,
464
- isArray,
465
- isBoolean,
466
- isCnName,
467
- isDate,
468
- isEnName,
469
- isHexColor,
470
- isIdCard,
471
- isLandline,
472
- isMailBox,
473
- isMobile,
474
- isNumber,
475
- isObject2 as isObject,
476
399
  isPhecda,
477
- isPostalCode,
478
- isString,
479
- isWechat,
480
400
  mergeOptions,
481
401
  mergeState,
482
402
  plainToClass,
@@ -489,7 +409,5 @@ export {
489
409
  setModalVar,
490
410
  snapShot,
491
411
  to,
492
- toNumber,
493
- toString,
494
412
  validate
495
413
  };
@@ -0,0 +1,20 @@
1
+ declare function isArray(info?: string): (obj: any, key: PropertyKey) => void;
2
+ declare function isBoolean(info?: string): (obj: any, key: PropertyKey) => void;
3
+ declare function isNumber(info?: string): (obj: any, key: PropertyKey) => void;
4
+ declare function isString(info?: string): (obj: any, key: PropertyKey) => void;
5
+ declare function isObject(info?: string): (obj: any, key: PropertyKey) => void;
6
+ declare function isMobile(info?: string): (obj: any, key: PropertyKey) => void;
7
+ declare function isLandline(info?: string): (obj: any, key: PropertyKey) => void;
8
+ declare function isMailBox(info?: string): (obj: any, key: PropertyKey) => void;
9
+ declare function isIdCard(info?: string): (obj: any, key: PropertyKey) => void;
10
+ declare function isCnName(info?: string): (obj: any, key: PropertyKey) => void;
11
+ declare function isEnName(info?: string): (obj: any, key: PropertyKey) => void;
12
+ declare function isDate(info?: string): (obj: any, key: PropertyKey) => void;
13
+ declare function isWechat(info?: string): (obj: any, key: PropertyKey) => void;
14
+ declare function isHexColor(info?: string): (obj: any, key: PropertyKey) => void;
15
+ declare function isPostalCode(info?: string): (obj: any, key: PropertyKey) => void;
16
+
17
+ declare function toNumber(): (obj: any, key: PropertyKey) => void;
18
+ declare function toString(): (obj: any, key: PropertyKey) => void;
19
+
20
+ export { isArray, isBoolean, isCnName, isDate, isEnName, isHexColor, isIdCard, isLandline, isMailBox, isMobile, isNumber, isObject, isPostalCode, isString, isWechat, toNumber, toString };
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ var Phecda = (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to2, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to2, key) && key !== except)
16
+ __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to2;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/preset/index.ts
23
+ var preset_exports = {};
24
+ __export(preset_exports, {
25
+ isArray: () => isArray,
26
+ isBoolean: () => isBoolean,
27
+ isCnName: () => isCnName,
28
+ isDate: () => isDate,
29
+ isEnName: () => isEnName,
30
+ isHexColor: () => isHexColor,
31
+ isIdCard: () => isIdCard,
32
+ isLandline: () => isLandline,
33
+ isMailBox: () => isMailBox,
34
+ isMobile: () => isMobile,
35
+ isNumber: () => isNumber,
36
+ isObject: () => isObject,
37
+ isPostalCode: () => isPostalCode,
38
+ isString: () => isString,
39
+ isWechat: () => isWechat,
40
+ toNumber: () => toNumber,
41
+ toString: () => toString
42
+ });
43
+
44
+ // src/core.ts
45
+ function init(target) {
46
+ if (!target._namespace) {
47
+ target._namespace = {
48
+ __TAG__: "",
49
+ __INIT_EVENT__: /* @__PURE__ */ new Set(),
50
+ __EXPOSE_VAR__: /* @__PURE__ */ new Set(),
51
+ __IGNORE_VAR__: /* @__PURE__ */ new Set(),
52
+ __STATE_VAR__: /* @__PURE__ */ new Set(),
53
+ __STATE_HANDLER__: /* @__PURE__ */ new Map(),
54
+ __STATE_NAMESPACE__: /* @__PURE__ */ new Map()
55
+ };
56
+ }
57
+ }
58
+ __name(init, "init");
59
+ function setModalVar(target, key) {
60
+ init(target);
61
+ target._namespace.__STATE_VAR__.add(key);
62
+ setExposeKey(target, key);
63
+ }
64
+ __name(setModalVar, "setModalVar");
65
+ function setExposeKey(target, key) {
66
+ init(target);
67
+ target._namespace.__EXPOSE_VAR__.add(key);
68
+ }
69
+ __name(setExposeKey, "setExposeKey");
70
+ function regisHandler(target, key, handler) {
71
+ init(target);
72
+ if (!target._namespace.__STATE_HANDLER__.has(key))
73
+ target._namespace.__STATE_HANDLER__.set(key, [
74
+ handler
75
+ ]);
76
+ else
77
+ target._namespace.__STATE_HANDLER__.get(key).push(handler);
78
+ }
79
+ __name(regisHandler, "regisHandler");
80
+
81
+ // src/decorators.ts
82
+ function Rule(rule, info, meta) {
83
+ return (obj, key) => {
84
+ setModalVar(obj, key);
85
+ regisHandler(obj, key, {
86
+ rule,
87
+ info,
88
+ meta
89
+ });
90
+ };
91
+ }
92
+ __name(Rule, "Rule");
93
+ function Pipe(v) {
94
+ return (obj, key) => {
95
+ setModalVar(obj, key);
96
+ regisHandler(obj, key, {
97
+ async pipe(instance) {
98
+ const tasks = v.value;
99
+ for (const task of tasks)
100
+ instance[key] = await task(instance[key]);
101
+ }
102
+ });
103
+ };
104
+ }
105
+ __name(Pipe, "Pipe");
106
+
107
+ // src/preset/rule.ts
108
+ function isArray(info) {
109
+ return Rule((param) => Array.isArray(param), info || "it should be an array");
110
+ }
111
+ __name(isArray, "isArray");
112
+ function isBoolean(info) {
113
+ return Rule((param) => [
114
+ true,
115
+ false
116
+ ].includes(param), info || "it should be true or false");
117
+ }
118
+ __name(isBoolean, "isBoolean");
119
+ function isNumber(info) {
120
+ return Rule((param) => typeof param === "number", info || "it should be true or false");
121
+ }
122
+ __name(isNumber, "isNumber");
123
+ function isString(info) {
124
+ return Rule((param) => typeof param === "string", info || "it should be a string");
125
+ }
126
+ __name(isString, "isString");
127
+ function isObject(info) {
128
+ return Rule((param) => {
129
+ return Object.prototype.toString.call(param) === "[object Object]";
130
+ }, info || "it should be an object");
131
+ }
132
+ __name(isObject, "isObject");
133
+ function isMobile(info) {
134
+ return Rule(/^((\+|00)86)?1((3[\d])|(4[5,6,7,9])|(5[0-3,5-9])|(6[5-7])|(7[0-8])|(8[\d])|(9[1,8,9]))\d{8}$/, info || "it should be a mobile phone number");
135
+ }
136
+ __name(isMobile, "isMobile");
137
+ function isLandline(info) {
138
+ return Rule(/\d{3}-\d{8}|\d{4}-\d{7}/, info || "it should be a mobile phone number");
139
+ }
140
+ __name(isLandline, "isLandline");
141
+ function isMailBox(info) {
142
+ return Rule(/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, info || "it should be a mailbox number");
143
+ }
144
+ __name(isMailBox, "isMailBox");
145
+ function isIdCard(info) {
146
+ return Rule(/(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0\d|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/, info || "it should be an identity card number");
147
+ }
148
+ __name(isIdCard, "isIdCard");
149
+ function isCnName(info) {
150
+ return Rule(/^([\u4E00-\u9FA5·]{2,16})$/, info || "\u9700\u8981\u662F\u4E00\u4E2A\u5408\u7406\u7684\u4E2D\u6587\u540D\u5B57");
151
+ }
152
+ __name(isCnName, "isCnName");
153
+ function isEnName(info) {
154
+ return Rule(/(^[a-zA-Z]{1}[a-zA-Z\s]{0,20}[a-zA-Z]{1}$)/, info || "it should be a valid en-name");
155
+ }
156
+ __name(isEnName, "isEnName");
157
+ function isDate(info) {
158
+ return Rule(/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/, info || "it should be a valid date");
159
+ }
160
+ __name(isDate, "isDate");
161
+ function isWechat(info) {
162
+ return Rule(/^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/, info || "it should be a valid date");
163
+ }
164
+ __name(isWechat, "isWechat");
165
+ function isHexColor(info) {
166
+ return Rule(/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/, info || "it should be a valid hex-color");
167
+ }
168
+ __name(isHexColor, "isHexColor");
169
+ function isPostalCode(info) {
170
+ return Rule(/^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/, info || "it should be a valid postal code");
171
+ }
172
+ __name(isPostalCode, "isPostalCode");
173
+
174
+ // src/helper.ts
175
+ function to(task, oldTasks) {
176
+ const tasks = oldTasks || [];
177
+ tasks.push(task);
178
+ return {
179
+ to: (task2) => to(task2, tasks),
180
+ value: tasks
181
+ };
182
+ }
183
+ __name(to, "to");
184
+
185
+ // src/preset/pipe.ts
186
+ function toNumber() {
187
+ return Pipe(to((param) => Number(param)));
188
+ }
189
+ __name(toNumber, "toNumber");
190
+ function toString() {
191
+ return Pipe(to((param) => String(param)));
192
+ }
193
+ __name(toString, "toString");
194
+ return __toCommonJS(preset_exports);
195
+ })();
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to2, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to2, key) && key !== except)
15
+ __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to2;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/preset/index.ts
22
+ var preset_exports = {};
23
+ __export(preset_exports, {
24
+ isArray: () => isArray,
25
+ isBoolean: () => isBoolean,
26
+ isCnName: () => isCnName,
27
+ isDate: () => isDate,
28
+ isEnName: () => isEnName,
29
+ isHexColor: () => isHexColor,
30
+ isIdCard: () => isIdCard,
31
+ isLandline: () => isLandline,
32
+ isMailBox: () => isMailBox,
33
+ isMobile: () => isMobile,
34
+ isNumber: () => isNumber,
35
+ isObject: () => isObject,
36
+ isPostalCode: () => isPostalCode,
37
+ isString: () => isString,
38
+ isWechat: () => isWechat,
39
+ toNumber: () => toNumber,
40
+ toString: () => toString
41
+ });
42
+ module.exports = __toCommonJS(preset_exports);
43
+
44
+ // src/core.ts
45
+ function init(target) {
46
+ if (!target._namespace) {
47
+ target._namespace = {
48
+ __TAG__: "",
49
+ __INIT_EVENT__: /* @__PURE__ */ new Set(),
50
+ __EXPOSE_VAR__: /* @__PURE__ */ new Set(),
51
+ __IGNORE_VAR__: /* @__PURE__ */ new Set(),
52
+ __STATE_VAR__: /* @__PURE__ */ new Set(),
53
+ __STATE_HANDLER__: /* @__PURE__ */ new Map(),
54
+ __STATE_NAMESPACE__: /* @__PURE__ */ new Map()
55
+ };
56
+ }
57
+ }
58
+ __name(init, "init");
59
+ function setModalVar(target, key) {
60
+ init(target);
61
+ target._namespace.__STATE_VAR__.add(key);
62
+ setExposeKey(target, key);
63
+ }
64
+ __name(setModalVar, "setModalVar");
65
+ function setExposeKey(target, key) {
66
+ init(target);
67
+ target._namespace.__EXPOSE_VAR__.add(key);
68
+ }
69
+ __name(setExposeKey, "setExposeKey");
70
+ function regisHandler(target, key, handler) {
71
+ init(target);
72
+ if (!target._namespace.__STATE_HANDLER__.has(key))
73
+ target._namespace.__STATE_HANDLER__.set(key, [
74
+ handler
75
+ ]);
76
+ else
77
+ target._namespace.__STATE_HANDLER__.get(key).push(handler);
78
+ }
79
+ __name(regisHandler, "regisHandler");
80
+
81
+ // src/decorators.ts
82
+ function Rule(rule, info, meta) {
83
+ return (obj, key) => {
84
+ setModalVar(obj, key);
85
+ regisHandler(obj, key, {
86
+ rule,
87
+ info,
88
+ meta
89
+ });
90
+ };
91
+ }
92
+ __name(Rule, "Rule");
93
+ function Pipe(v) {
94
+ return (obj, key) => {
95
+ setModalVar(obj, key);
96
+ regisHandler(obj, key, {
97
+ async pipe(instance) {
98
+ const tasks = v.value;
99
+ for (const task of tasks)
100
+ instance[key] = await task(instance[key]);
101
+ }
102
+ });
103
+ };
104
+ }
105
+ __name(Pipe, "Pipe");
106
+
107
+ // src/preset/rule.ts
108
+ function isArray(info) {
109
+ return Rule((param) => Array.isArray(param), info || "it should be an array");
110
+ }
111
+ __name(isArray, "isArray");
112
+ function isBoolean(info) {
113
+ return Rule((param) => [
114
+ true,
115
+ false
116
+ ].includes(param), info || "it should be true or false");
117
+ }
118
+ __name(isBoolean, "isBoolean");
119
+ function isNumber(info) {
120
+ return Rule((param) => typeof param === "number", info || "it should be true or false");
121
+ }
122
+ __name(isNumber, "isNumber");
123
+ function isString(info) {
124
+ return Rule((param) => typeof param === "string", info || "it should be a string");
125
+ }
126
+ __name(isString, "isString");
127
+ function isObject(info) {
128
+ return Rule((param) => {
129
+ return Object.prototype.toString.call(param) === "[object Object]";
130
+ }, info || "it should be an object");
131
+ }
132
+ __name(isObject, "isObject");
133
+ function isMobile(info) {
134
+ return Rule(/^((\+|00)86)?1((3[\d])|(4[5,6,7,9])|(5[0-3,5-9])|(6[5-7])|(7[0-8])|(8[\d])|(9[1,8,9]))\d{8}$/, info || "it should be a mobile phone number");
135
+ }
136
+ __name(isMobile, "isMobile");
137
+ function isLandline(info) {
138
+ return Rule(/\d{3}-\d{8}|\d{4}-\d{7}/, info || "it should be a mobile phone number");
139
+ }
140
+ __name(isLandline, "isLandline");
141
+ function isMailBox(info) {
142
+ return Rule(/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, info || "it should be a mailbox number");
143
+ }
144
+ __name(isMailBox, "isMailBox");
145
+ function isIdCard(info) {
146
+ return Rule(/(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0\d|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/, info || "it should be an identity card number");
147
+ }
148
+ __name(isIdCard, "isIdCard");
149
+ function isCnName(info) {
150
+ return Rule(/^([\u4E00-\u9FA5·]{2,16})$/, info || "\u9700\u8981\u662F\u4E00\u4E2A\u5408\u7406\u7684\u4E2D\u6587\u540D\u5B57");
151
+ }
152
+ __name(isCnName, "isCnName");
153
+ function isEnName(info) {
154
+ return Rule(/(^[a-zA-Z]{1}[a-zA-Z\s]{0,20}[a-zA-Z]{1}$)/, info || "it should be a valid en-name");
155
+ }
156
+ __name(isEnName, "isEnName");
157
+ function isDate(info) {
158
+ return Rule(/^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/, info || "it should be a valid date");
159
+ }
160
+ __name(isDate, "isDate");
161
+ function isWechat(info) {
162
+ return Rule(/^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/, info || "it should be a valid date");
163
+ }
164
+ __name(isWechat, "isWechat");
165
+ function isHexColor(info) {
166
+ return Rule(/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/, info || "it should be a valid hex-color");
167
+ }
168
+ __name(isHexColor, "isHexColor");
169
+ function isPostalCode(info) {
170
+ return Rule(/^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/, info || "it should be a valid postal code");
171
+ }
172
+ __name(isPostalCode, "isPostalCode");
173
+
174
+ // src/helper.ts
175
+ function to(task, oldTasks) {
176
+ const tasks = oldTasks || [];
177
+ tasks.push(task);
178
+ return {
179
+ to: (task2) => to(task2, tasks),
180
+ value: tasks
181
+ };
182
+ }
183
+ __name(to, "to");
184
+
185
+ // src/preset/pipe.ts
186
+ function toNumber() {
187
+ return Pipe(to((param) => Number(param)));
188
+ }
189
+ __name(toNumber, "toNumber");
190
+ function toString() {
191
+ return Pipe(to((param) => String(param)));
192
+ }
193
+ __name(toString, "toString");
194
+ // Annotate the CommonJS export names for ESM import in node:
195
+ 0 && (module.exports = {
196
+ isArray,
197
+ isBoolean,
198
+ isCnName,
199
+ isDate,
200
+ isEnName,
201
+ isHexColor,
202
+ isIdCard,
203
+ isLandline,
204
+ isMailBox,
205
+ isMobile,
206
+ isNumber,
207
+ isObject,
208
+ isPostalCode,
209
+ isString,
210
+ isWechat,
211
+ toNumber,
212
+ toString
213
+ });