@vef-framework/shared 1.0.128 → 1.0.129
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/cjs/color.cjs +1 -10
- package/cjs/constants.cjs +1 -38
- package/cjs/context.cjs +1 -35
- package/cjs/dom.cjs +1 -22
- package/cjs/error.cjs +1 -29
- package/cjs/event.cjs +1 -10
- package/cjs/expression.cjs +1 -26
- package/cjs/function.cjs +1 -15
- package/cjs/icons.cjs +1 -135
- package/cjs/id.cjs +1 -13
- package/cjs/index.cjs +1 -319
- package/cjs/json.cjs +1 -17
- package/cjs/message.cjs +1 -302
- package/cjs/module.cjs +1 -13
- package/cjs/path.cjs +1 -39
- package/cjs/pinyin.cjs +1 -32
- package/cjs/security.cjs +1 -26
- package/cjs/store.cjs +1 -103
- package/cjs/styles.cjs +1 -54
- package/cjs/temporal.cjs +1 -26
- package/cjs/theme-variables.cjs +1 -353
- package/cjs/types.cjs +0 -2
- package/cjs/utils.cjs +1 -322
- package/cjs/validation.cjs +1 -188
- package/cjs/yaml.cjs +1 -10
- package/cjs/zod.cjs +1 -26
- package/esm/color.js +1 -8
- package/esm/constants.js +1 -30
- package/esm/context.js +1 -33
- package/esm/dom.js +1 -20
- package/esm/error.js +1 -27
- package/esm/event.js +1 -8
- package/esm/expression.js +1 -22
- package/esm/function.js +1 -13
- package/esm/icons.js +1 -128
- package/esm/id.js +1 -11
- package/esm/index.js +1 -32
- package/esm/json.js +1 -15
- package/esm/message.js +1 -281
- package/esm/module.js +1 -11
- package/esm/path.js +1 -32
- package/esm/pinyin.js +1 -29
- package/esm/security.js +1 -23
- package/esm/store.js +1 -98
- package/esm/styles.js +1 -50
- package/esm/temporal.js +1 -22
- package/esm/theme-variables.js +1 -351
- package/esm/utils.js +1 -110
- package/esm/validation.js +1 -150
- package/esm/yaml.js +1 -8
- package/esm/zod.js +1 -21
- package/package.json +1 -1
package/esm/utils.js
CHANGED
|
@@ -1,111 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import { isFunction,
|
|
3
|
-
export { assign, camel as camelCase, capitalize, clone, cloneDeep, cluster, dash as dashCase, debounce, get, isArray, isBoolean, isDate, isEmpty, isError, isFloat, isFunction, isInt, isIntString, isMap, isNullish, isNumber, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isUndefined, isWeakMap, isWeakSet, max, memo as memoize, min, noop, omit, once, pascal as pascalCase, pick, set, similarity, snake as snakeCase, sum, template, throttle, toFloat, toInt, trim, unique } from 'radashi';
|
|
4
|
-
export { default as isDeepEqual } from 'react-fast-compare';
|
|
5
|
-
export { shallow as isShallowEqual } from 'zustand/shallow';
|
|
6
|
-
|
|
7
|
-
"use strict";
|
|
8
|
-
function isAsyncFunction(fn) {
|
|
9
|
-
if (!isFunction(fn)) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
return fn.constructor.name === "AsyncFunction" || Object.prototype.toString.call(fn) === "[object AsyncFunction]" || fn.toString().startsWith("async ");
|
|
13
|
-
}
|
|
14
|
-
async function invokeMaybeAsyncFn(fn, {
|
|
15
|
-
beforeInvoke,
|
|
16
|
-
onSuccess,
|
|
17
|
-
onFinally
|
|
18
|
-
}, ...args) {
|
|
19
|
-
if (isAsyncFunction(fn)) {
|
|
20
|
-
try {
|
|
21
|
-
beforeInvoke?.();
|
|
22
|
-
const result = await fn(...args);
|
|
23
|
-
onSuccess?.(result);
|
|
24
|
-
return result;
|
|
25
|
-
} finally {
|
|
26
|
-
onFinally?.();
|
|
27
|
-
}
|
|
28
|
-
} else {
|
|
29
|
-
const returned = fn(...args);
|
|
30
|
-
if (returned instanceof Promise) {
|
|
31
|
-
try {
|
|
32
|
-
beforeInvoke?.();
|
|
33
|
-
const result = await returned;
|
|
34
|
-
onSuccess?.(result);
|
|
35
|
-
return result;
|
|
36
|
-
} finally {
|
|
37
|
-
onFinally?.();
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
return returned;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function difference(oldValues, newValues) {
|
|
45
|
-
return Object.keys(newValues).filter((key) => oldValues[key] !== newValues[key]).reduce(
|
|
46
|
-
(acc, key) => {
|
|
47
|
-
acc[key] = newValues[key];
|
|
48
|
-
return acc;
|
|
49
|
-
},
|
|
50
|
-
{}
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
function constantCase(value) {
|
|
54
|
-
return snake(value).toUpperCase();
|
|
55
|
-
}
|
|
56
|
-
function isInternalFunction(fn) {
|
|
57
|
-
if (isAsyncFunction(fn) && Reflect.has(fn, "name") && Reflect.has(fn, "key") && Reflect.get(fn, "name") === "apiFn") {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
function getStringLength(value) {
|
|
63
|
-
if (isNumber(value)) {
|
|
64
|
-
return `${value}px`;
|
|
65
|
-
}
|
|
66
|
-
return value;
|
|
67
|
-
}
|
|
68
|
-
function buildRouteParentMenusMappings(menus) {
|
|
69
|
-
return new Map(doBuildRouteParentMenusMappings(menus));
|
|
70
|
-
}
|
|
71
|
-
function doBuildRouteParentMenusMappings(menus, parents = []) {
|
|
72
|
-
return menus.flatMap((menu) => {
|
|
73
|
-
if (menu.type === "item") {
|
|
74
|
-
return [[menu.key, [menu, parents]]];
|
|
75
|
-
} else if (menu.type === "submenu" || menu.type === "group") {
|
|
76
|
-
const { children, ...parent } = menu;
|
|
77
|
-
return [
|
|
78
|
-
[
|
|
79
|
-
parent.key,
|
|
80
|
-
[
|
|
81
|
-
{
|
|
82
|
-
...parent,
|
|
83
|
-
children: []
|
|
84
|
-
},
|
|
85
|
-
parents
|
|
86
|
-
]
|
|
87
|
-
],
|
|
88
|
-
...doBuildRouteParentMenusMappings(children, [
|
|
89
|
-
...parents,
|
|
90
|
-
{
|
|
91
|
-
...parent,
|
|
92
|
-
children: children.filter((child) => child.type !== "divider").map((child) => {
|
|
93
|
-
if (child.type === "item") {
|
|
94
|
-
return {
|
|
95
|
-
...child
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
...child,
|
|
100
|
-
children: []
|
|
101
|
-
};
|
|
102
|
-
})
|
|
103
|
-
}
|
|
104
|
-
])
|
|
105
|
-
];
|
|
106
|
-
}
|
|
107
|
-
return [];
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export { buildRouteParentMenusMappings, constantCase, difference, getStringLength, invokeMaybeAsyncFn, isAsyncFunction, isInternalFunction };
|
|
2
|
+
import{isFunction as u,snake as l,isNumber as p}from"radashi";import{assign as S,camel as x,capitalize as M,clone as C,cloneDeep as j,cluster as w,dash as A,debounce as E,get as I,isArray as P,isBoolean as R,isDate as v,isEmpty as O,isError as q,isFloat as D,isFunction as N,isInt as W,isIntString as z,isMap as U,isNullish as B,isNumber as L,isObject as $,isPlainObject as G,isPrimitive as H,isPromise as J,isRegExp as K,isSet as Q,isString as T,isSymbol as V,isUndefined as X,isWeakMap as Y,isWeakSet as Z,max as _,memo as ee,min as ne,noop as te,omit as ie,once as se,pascal as ae,pick as re,set as oe,similarity as ce,snake as ue,sum as le,template as pe,throttle as me,toFloat as fe,toInt as ye,trim as de,unique as he}from"radashi";import{default as ge}from"react-fast-compare";import{shallow as Fe}from"zustand/shallow";function r(e){return u(e)?e.constructor.name==="AsyncFunction"||Object.prototype.toString.call(e)==="[object AsyncFunction]"||e.toString().startsWith("async "):!1}async function m(e,{beforeInvoke:i,onSuccess:n,onFinally:s},...a){if(r(e))try{i?.();const t=await e(...a);return n?.(t),t}finally{s?.()}else{const t=e(...a);if(t instanceof Promise)try{i?.();const o=await t;return n?.(o),o}finally{s?.()}else return t}}function f(e,i){return Object.keys(i).filter(n=>e[n]!==i[n]).reduce((n,s)=>(n[s]=i[s],n),{})}function y(e){return l(e).toUpperCase()}function d(e){return!!(r(e)&&Reflect.has(e,"name")&&Reflect.has(e,"key")&&Reflect.get(e,"name")==="apiFn")}function h(e){return p(e)?`${e}px`:e}function b(e){return new Map(c(e))}function c(e,i=[]){return e.flatMap(n=>{if(n.type==="item")return[[n.key,[n,i]]];if(n.type==="submenu"||n.type==="group"){const{children:s,...a}=n;return[[a.key,[{...a,children:[]},i]],...c(s,[...i,{...a,children:s.filter(t=>t.type!=="divider").map(t=>t.type==="item"?{...t}:{...t,children:[]})}])]}return[]})}export{S as assign,b as buildRouteParentMenusMappings,x as camelCase,M as capitalize,C as clone,j as cloneDeep,w as cluster,y as constantCase,A as dashCase,E as debounce,f as difference,I as get,h as getStringLength,m as invokeMaybeAsyncFn,P as isArray,r as isAsyncFunction,R as isBoolean,v as isDate,ge as isDeepEqual,O as isEmpty,q as isError,D as isFloat,N as isFunction,W as isInt,z as isIntString,d as isInternalFunction,U as isMap,B as isNullish,L as isNumber,$ as isObject,G as isPlainObject,H as isPrimitive,J as isPromise,K as isRegExp,Q as isSet,Fe as isShallowEqual,T as isString,V as isSymbol,X as isUndefined,Y as isWeakMap,Z as isWeakSet,_ as max,ee as memoize,ne as min,te as noop,ie as omit,se as once,ae as pascalCase,re as pick,oe as set,ce as similarity,ue as snakeCase,le as sum,pe as template,me as throttle,fe as toFloat,ye as toInt,de as trim,he as unique};
|
package/esm/validation.js
CHANGED
|
@@ -1,151 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
"use strict";
|
|
5
|
-
function isAlpha(value) {
|
|
6
|
-
return validator.isAlpha(value);
|
|
7
|
-
}
|
|
8
|
-
function isAlphanumeric(value) {
|
|
9
|
-
return validator.isAlphanumeric(value);
|
|
10
|
-
}
|
|
11
|
-
function isAscii(value) {
|
|
12
|
-
return validator.isAscii(value);
|
|
13
|
-
}
|
|
14
|
-
function isNumeric(value) {
|
|
15
|
-
return validator.isNumeric(value);
|
|
16
|
-
}
|
|
17
|
-
function isDecimal(value) {
|
|
18
|
-
return validator.isDecimal(value);
|
|
19
|
-
}
|
|
20
|
-
function isFloat(value, options) {
|
|
21
|
-
return validator.isFloat(value, options);
|
|
22
|
-
}
|
|
23
|
-
function isBoolean(value) {
|
|
24
|
-
return validator.isBoolean(value, {
|
|
25
|
-
loose: false
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function isDate(value) {
|
|
29
|
-
return validator.isDate(value, {
|
|
30
|
-
format: "YYYY-MM-DD",
|
|
31
|
-
strictMode: true
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function isEmpty(value) {
|
|
35
|
-
return validator.isEmpty(value);
|
|
36
|
-
}
|
|
37
|
-
function isBlank(value) {
|
|
38
|
-
return validator.isEmpty(value, {
|
|
39
|
-
ignore_whitespace: true
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
function isIdentityCard(value) {
|
|
43
|
-
return validator.isIdentityCard(value, "zh-CN");
|
|
44
|
-
}
|
|
45
|
-
function isAfter(value, date) {
|
|
46
|
-
return validator.isAfter(value, date);
|
|
47
|
-
}
|
|
48
|
-
function isBefore(value, date) {
|
|
49
|
-
return validator.isBefore(value, date);
|
|
50
|
-
}
|
|
51
|
-
function isEmail(value) {
|
|
52
|
-
return validator.isEmail(value);
|
|
53
|
-
}
|
|
54
|
-
function isHexColor(value) {
|
|
55
|
-
return validator.isHexColor(value);
|
|
56
|
-
}
|
|
57
|
-
function isIn(value, values) {
|
|
58
|
-
return validator.isIn(value, values);
|
|
59
|
-
}
|
|
60
|
-
function isInt(value, options) {
|
|
61
|
-
return validator.isInt(value, options);
|
|
62
|
-
}
|
|
63
|
-
function isIp(value, version) {
|
|
64
|
-
return validator.isIP(value, version);
|
|
65
|
-
}
|
|
66
|
-
function isIpRange(value, version) {
|
|
67
|
-
return validator.isIPRange(value, version);
|
|
68
|
-
}
|
|
69
|
-
function isJson(value) {
|
|
70
|
-
return validator.isJSON(value);
|
|
71
|
-
}
|
|
72
|
-
function isJwt(value) {
|
|
73
|
-
return validator.isJWT(value);
|
|
74
|
-
}
|
|
75
|
-
function isLatLong(value) {
|
|
76
|
-
return validator.isLatLong(value);
|
|
77
|
-
}
|
|
78
|
-
function isLength(value, options) {
|
|
79
|
-
return validator.isLength(value, options);
|
|
80
|
-
}
|
|
81
|
-
function isMimeType(value) {
|
|
82
|
-
return validator.isMimeType(value);
|
|
83
|
-
}
|
|
84
|
-
function isMobilePhone(value) {
|
|
85
|
-
return validator.isMobilePhone(value, "zh-CN");
|
|
86
|
-
}
|
|
87
|
-
function isPort(value) {
|
|
88
|
-
return validator.isPort(value);
|
|
89
|
-
}
|
|
90
|
-
function isPostalCode(value) {
|
|
91
|
-
return validator.isPostalCode(value, "CN");
|
|
92
|
-
}
|
|
93
|
-
function isSemVer(value) {
|
|
94
|
-
return validator.isSemVer(value);
|
|
95
|
-
}
|
|
96
|
-
function isSlug(value) {
|
|
97
|
-
return validator.isSlug(value);
|
|
98
|
-
}
|
|
99
|
-
function isStrongPassword(value) {
|
|
100
|
-
return validator.isStrongPassword(value, {
|
|
101
|
-
minLength: 8,
|
|
102
|
-
minLowercase: 1,
|
|
103
|
-
minUppercase: 1,
|
|
104
|
-
minNumbers: 1,
|
|
105
|
-
minSymbols: 1
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
function isTime(value, options) {
|
|
109
|
-
return validator.isTime(value, options);
|
|
110
|
-
}
|
|
111
|
-
function isUrl(value) {
|
|
112
|
-
return validator.isURL(value, {
|
|
113
|
-
protocols: ["http", "https"],
|
|
114
|
-
require_tld: true,
|
|
115
|
-
require_protocol: true,
|
|
116
|
-
require_host: true,
|
|
117
|
-
require_port: false,
|
|
118
|
-
require_valid_protocol: true,
|
|
119
|
-
allow_underscores: true
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
function isUri(value) {
|
|
123
|
-
return validator.isURL(value, {
|
|
124
|
-
protocols: [],
|
|
125
|
-
require_tld: false,
|
|
126
|
-
require_protocol: false,
|
|
127
|
-
require_host: false,
|
|
128
|
-
require_port: false,
|
|
129
|
-
require_valid_protocol: false,
|
|
130
|
-
allow_underscores: true,
|
|
131
|
-
allow_fragments: false,
|
|
132
|
-
allow_query_components: false,
|
|
133
|
-
allow_protocol_relative_urls: false
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
function isUuid(value, version) {
|
|
137
|
-
return validator.isUUID(value, version);
|
|
138
|
-
}
|
|
139
|
-
function isDateTime(value) {
|
|
140
|
-
const [date, time] = value.split(" ", 2);
|
|
141
|
-
return isDate(date) && isTime(time);
|
|
142
|
-
}
|
|
143
|
-
function matches(value, pattern, modifiers) {
|
|
144
|
-
return validator.matches(value, pattern, modifiers);
|
|
145
|
-
}
|
|
146
|
-
const chineseNameRegExp = /^[\u4E00-\u9FA5]+\d*$/;
|
|
147
|
-
function isChineseName(value) {
|
|
148
|
-
return chineseNameRegExp.test(value);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export { isAfter, isAlpha, isAlphanumeric, isAscii, isBefore, isBlank, isBoolean, isChineseName, isDate, isDateTime, isDecimal, isEmail, isEmpty, isFloat, isHexColor, isIdentityCard, isIn, isInt, isIp, isIpRange, isJson, isJwt, isLatLong, isLength, isMimeType, isMobilePhone, isNumeric, isPort, isPostalCode, isSemVer, isSlug, isStrongPassword, isTime, isUri, isUrl, isUuid, matches };
|
|
2
|
+
import n from"validator";function s(i){return n.isAlpha(i)}function u(i){return n.isAlphanumeric(i)}function c(i){return n.isAscii(i)}function l(i){return n.isNumeric(i)}function f(i){return n.isDecimal(i)}function a(i,r){return n.isFloat(i,r)}function m(i){return n.isBoolean(i,{loose:!1})}function e(i){return n.isDate(i,{format:"YYYY-MM-DD",strictMode:!0})}function p(i){return n.isEmpty(i)}function _(i){return n.isEmpty(i,{ignore_whitespace:!0})}function h(i){return n.isIdentityCard(i,"zh-CN")}function d(i,r){return n.isAfter(i,r)}function g(i,r){return n.isBefore(i,r)}function q(i){return n.isEmail(i)}function I(i){return n.isHexColor(i)}function w(i,r){return n.isIn(i,r)}function C(i,r){return n.isInt(i,r)}function L(i,r){return n.isIP(i,r)}function P(i,r){return n.isIPRange(i,r)}function y(i){return n.isJSON(i)}function A(i){return n.isJWT(i)}function D(i){return n.isLatLong(i)}function N(i,r){return n.isLength(i,r)}function S(i){return n.isMimeType(i)}function U(i){return n.isMobilePhone(i,"zh-CN")}function M(i){return n.isPort(i)}function E(i){return n.isPostalCode(i,"CN")}function T(i){return n.isSemVer(i)}function B(i){return n.isSlug(i)}function b(i){return n.isStrongPassword(i,{minLength:8,minLowercase:1,minUppercase:1,minNumbers:1,minSymbols:1})}function o(i,r){return n.isTime(i,r)}function J(i){return n.isURL(i,{protocols:["http","https"],require_tld:!0,require_protocol:!0,require_host:!0,require_port:!1,require_valid_protocol:!0,allow_underscores:!0})}function R(i){return n.isURL(i,{protocols:[],require_tld:!1,require_protocol:!1,require_host:!1,require_port:!1,require_valid_protocol:!1,allow_underscores:!0,allow_fragments:!1,allow_query_components:!1,allow_protocol_relative_urls:!1})}function Y(i,r){return n.isUUID(i,r)}function v(i){const[r,t]=i.split(" ",2);return e(r)&&o(t)}function x(i,r,t){return n.matches(i,r,t)}const F=/^[\u4E00-\u9FA5]+\d*$/;function z(i){return F.test(i)}export{d as isAfter,s as isAlpha,u as isAlphanumeric,c as isAscii,g as isBefore,_ as isBlank,m as isBoolean,z as isChineseName,e as isDate,v as isDateTime,f as isDecimal,q as isEmail,p as isEmpty,a as isFloat,I as isHexColor,h as isIdentityCard,w as isIn,C as isInt,L as isIp,P as isIpRange,y as isJson,A as isJwt,D as isLatLong,N as isLength,S as isMimeType,U as isMobilePhone,l as isNumeric,M as isPort,E as isPostalCode,T as isSemVer,B as isSlug,b as isStrongPassword,o as isTime,R as isUri,J as isUrl,Y as isUuid,x as matches};
|
package/esm/yaml.js
CHANGED
package/esm/zod.js
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import i18next from
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
export { z } from 'zod';
|
|
5
|
-
import { zodI18nMap } from 'zod-i18n-map';
|
|
6
|
-
import translation from 'zod-i18n-map/locales/zh-CN/zod.json';
|
|
7
|
-
|
|
8
|
-
"use strict";
|
|
9
|
-
function initZod() {
|
|
10
|
-
i18next.init({
|
|
11
|
-
lng: "zh-CN",
|
|
12
|
-
fallbackLng: false,
|
|
13
|
-
resources: {
|
|
14
|
-
"zh-CN": {
|
|
15
|
-
zod: translation
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
z.setErrorMap(zodI18nMap);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { initZod };
|
|
2
|
+
import r from"i18next";import{z as o}from"zod";import{z as a}from"zod";import{zodI18nMap as t}from"zod-i18n-map";import i from"zod-i18n-map/locales/zh-CN/zod.json";function m(){r.init({lng:"zh-CN",fallbackLng:!1,resources:{"zh-CN":{zod:i}}}),o.setErrorMap(t)}export{m as initZod,a as z};
|