@vef-framework/shared 1.0.128 → 1.0.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/cjs/color.cjs +1 -10
  2. package/cjs/constants.cjs +1 -38
  3. package/cjs/context.cjs +1 -35
  4. package/cjs/dom.cjs +1 -22
  5. package/cjs/error.cjs +1 -29
  6. package/cjs/event.cjs +1 -10
  7. package/cjs/expression.cjs +1 -26
  8. package/cjs/function.cjs +1 -15
  9. package/cjs/icons.cjs +1 -135
  10. package/cjs/id.cjs +1 -13
  11. package/cjs/index.cjs +1 -319
  12. package/cjs/json.cjs +1 -17
  13. package/cjs/message.cjs +1 -302
  14. package/cjs/module.cjs +1 -13
  15. package/cjs/path.cjs +1 -39
  16. package/cjs/pinyin.cjs +1 -32
  17. package/cjs/security.cjs +1 -26
  18. package/cjs/store.cjs +1 -103
  19. package/cjs/styles.cjs +1 -54
  20. package/cjs/temporal.cjs +1 -26
  21. package/cjs/theme-variables.cjs +1 -353
  22. package/cjs/types.cjs +0 -2
  23. package/cjs/utils.cjs +1 -322
  24. package/cjs/validation.cjs +1 -188
  25. package/cjs/yaml.cjs +1 -10
  26. package/cjs/zod.cjs +1 -26
  27. package/esm/color.js +1 -8
  28. package/esm/constants.js +1 -30
  29. package/esm/context.js +1 -33
  30. package/esm/dom.js +1 -20
  31. package/esm/error.js +1 -27
  32. package/esm/event.js +1 -8
  33. package/esm/expression.js +1 -22
  34. package/esm/function.js +1 -13
  35. package/esm/icons.js +1 -128
  36. package/esm/id.js +1 -11
  37. package/esm/index.js +1 -32
  38. package/esm/json.js +1 -15
  39. package/esm/message.js +1 -281
  40. package/esm/module.js +1 -11
  41. package/esm/path.js +1 -32
  42. package/esm/pinyin.js +1 -29
  43. package/esm/security.js +1 -23
  44. package/esm/store.js +1 -98
  45. package/esm/styles.js +1 -50
  46. package/esm/temporal.js +1 -22
  47. package/esm/theme-variables.js +1 -351
  48. package/esm/utils.js +1 -110
  49. package/esm/validation.js +1 -150
  50. package/esm/yaml.js +1 -8
  51. package/esm/zod.js +1 -21
  52. package/package.json +1 -1
package/cjs/path.cjs CHANGED
@@ -1,40 +1,2 @@
1
1
  "use strict";
2
- 'use strict';
3
-
4
- var path = require('path-browserify');
5
-
6
- "use strict";
7
- const {
8
- basename,
9
- dirname,
10
- extname,
11
- isAbsolute,
12
- join,
13
- normalize
14
- } = path;
15
- function extractBaseName(path2, keepExt = true) {
16
- const ext = keepExt ? void 0 : extname(path2);
17
- return basename(path2, ext);
18
- }
19
- function extractExtName(path2) {
20
- return extname(path2);
21
- }
22
- function extractDirName(path2) {
23
- return dirname(path2);
24
- }
25
- function joinPaths(...paths) {
26
- return join(...paths);
27
- }
28
- function isAbsolutePath(path2) {
29
- return isAbsolute(path2);
30
- }
31
- function normalizePath(path2) {
32
- return normalize(path2);
33
- }
34
-
35
- exports.extractBaseName = extractBaseName;
36
- exports.extractDirName = extractDirName;
37
- exports.extractExtName = extractExtName;
38
- exports.isAbsolutePath = isAbsolutePath;
39
- exports.joinPaths = joinPaths;
40
- exports.normalizePath = normalizePath;
2
+ "use strict";var r=require("path-browserify");const{basename:i,dirname:o,extname:e,isAbsolute:u,join:s,normalize:c}=r;function m(t,n=!0){const a=n?void 0:e(t);return i(t,a)}function x(t){return e(t)}function f(t){return o(t)}function h(...t){return s(...t)}function l(t){return u(t)}function N(t){return c(t)}exports.extractBaseName=m,exports.extractDirName=f,exports.extractExtName=x,exports.isAbsolutePath=l,exports.joinPaths=h,exports.normalizePath=N;
package/cjs/pinyin.cjs CHANGED
@@ -1,33 +1,2 @@
1
1
  "use strict";
2
- 'use strict';
3
-
4
- var pinyinPro = require('pinyin-pro');
5
-
6
- "use strict";
7
- function parsePinyin(text) {
8
- return pinyinPro.pinyin(
9
- text,
10
- {
11
- pattern: "pinyin",
12
- toneType: "none",
13
- type: "array",
14
- mode: "normal",
15
- nonZh: "consecutive"
16
- }
17
- );
18
- }
19
- function parsePinyinFirstLetter(text) {
20
- return pinyinPro.pinyin(
21
- text,
22
- {
23
- pattern: "first",
24
- toneType: "none",
25
- type: "array",
26
- mode: "normal",
27
- nonZh: "consecutive"
28
- }
29
- );
30
- }
31
-
32
- exports.parsePinyin = parsePinyin;
33
- exports.parsePinyinFirstLetter = parsePinyinFirstLetter;
2
+ "use strict";var e=require("pinyin-pro");function r(n){return e.pinyin(n,{pattern:"pinyin",toneType:"none",type:"array",mode:"normal",nonZh:"consecutive"})}function i(n){return e.pinyin(n,{pattern:"first",toneType:"none",type:"array",mode:"normal",nonZh:"consecutive"})}exports.parsePinyin=r,exports.parsePinyinFirstLetter=i;
package/cjs/security.cjs CHANGED
@@ -1,27 +1,2 @@
1
1
  "use strict";
2
- 'use strict';
3
-
4
- var JSEncrypt = require('jsencrypt');
5
-
6
- "use strict";
7
- function encryptRsa(value, publicKey) {
8
- const rsa = new JSEncrypt();
9
- rsa.setPublicKey(publicKey);
10
- const encrypted = rsa.encrypt(value);
11
- if (!encrypted) {
12
- throw new Error(`Failed to encrypt value [${value}] using RSA`);
13
- }
14
- return encrypted;
15
- }
16
- function decryptRsa(value, privateKey) {
17
- const rsa = new JSEncrypt();
18
- rsa.setPrivateKey(privateKey);
19
- const decrypted = rsa.decrypt(value);
20
- if (!decrypted) {
21
- throw new Error(`Failed to decrypt value [${value}] using RSA`);
22
- }
23
- return decrypted;
24
- }
25
-
26
- exports.decryptRsa = decryptRsa;
27
- exports.encryptRsa = encryptRsa;
2
+ "use strict";var c=require("jsencrypt");function s(e,n){const t=new c;t.setPublicKey(n);const r=t.encrypt(e);if(!r)throw new Error(`Failed to encrypt value [${e}] using RSA`);return r}function i(e,n){const t=new c;t.setPrivateKey(n);const r=t.decrypt(e);if(!r)throw new Error(`Failed to decrypt value [${e}] using RSA`);return r}exports.decryptRsa=i,exports.encryptRsa=s;
package/cjs/store.cjs CHANGED
@@ -1,104 +1,2 @@
1
1
  "use strict";
2
- 'use strict';
3
-
4
- var react = require('react');
5
- var middleware = require('zustand/middleware');
6
- var traditional = require('zustand/traditional');
7
- var vanilla = require('zustand/vanilla');
8
- var utils = require('./utils.cjs');
9
- var radashi = require('radashi');
10
- var shallow = require('zustand/shallow');
11
-
12
- "use strict";
13
- function createStorageProxy(storage) {
14
- const delegate = middleware.createJSONStorage(() => storage === "local" ? localStorage : sessionStorage);
15
- return {
16
- getItem: delegate.getItem,
17
- setItem(name, value) {
18
- if (radashi.isNullish(value.state)) {
19
- return;
20
- }
21
- delegate.setItem(name, value);
22
- },
23
- removeItem: delegate.removeItem
24
- };
25
- }
26
- function createStore(stateCreator, persistenceOptions) {
27
- const name = persistenceOptions?.name ?? "UNKNOWN";
28
- const storage = persistenceOptions?.storage ?? "local";
29
- const selector = persistenceOptions ? persistenceOptions.selector : () => null;
30
- const storageInstance = createStorageProxy(storage);
31
- return traditional.createWithEqualityFn(
32
- middleware.persist(
33
- middleware.subscribeWithSelector(stateCreator),
34
- {
35
- name: `__VEF_STORE__${utils.constantCase(name)}__`,
36
- storage: storageInstance,
37
- version: 1,
38
- partialize: selector
39
- }
40
- ),
41
- shallow.shallow
42
- );
43
- }
44
- function createUnboundStore(stateCreator) {
45
- return vanilla.createStore(
46
- middleware.subscribeWithSelector(stateCreator)
47
- );
48
- }
49
- function useUnboundStore(store, selector, equalityFn) {
50
- return traditional.useStoreWithEqualityFn(
51
- store,
52
- selector,
53
- equalityFn ?? shallow.shallow
54
- );
55
- }
56
- function createComponentStore(name, getStateCreator) {
57
- const StoreContext = react.createContext(null);
58
- const StoreProvider = ({ initialState, children }) => {
59
- const [store] = react.useState(() => {
60
- const creator = getStateCreator(initialState);
61
- return createUnboundStore(creator);
62
- });
63
- const isMounted = react.useRef(false);
64
- react.useEffect(() => () => {
65
- isMounted.current = false;
66
- }, []);
67
- react.useEffect(() => {
68
- if (!isMounted.current) {
69
- isMounted.current = true;
70
- }
71
- if (initialState) {
72
- store.setState({
73
- ...initialState
74
- });
75
- }
76
- }, [initialState, store]);
77
- return react.createElement(
78
- StoreContext.Provider,
79
- { value: store },
80
- children
81
- );
82
- };
83
- const useStoreApi = () => {
84
- const store = react.useContext(StoreContext);
85
- if (!store) {
86
- throw new Error(`${name}Store can be used only inside ${name}StoreProvider`);
87
- }
88
- return store;
89
- };
90
- const useStore = (selector) => useUnboundStore(
91
- useStoreApi(),
92
- selector
93
- );
94
- return {
95
- StoreProvider,
96
- useStore,
97
- useStoreApi
98
- };
99
- }
100
-
101
- exports.createComponentStore = createComponentStore;
102
- exports.createStore = createStore;
103
- exports.createUnboundStore = createUnboundStore;
104
- exports.useUnboundStore = useUnboundStore;
2
+ "use strict";var n=require("react"),u=require("zustand/middleware"),l=require("zustand/traditional"),h=require("zustand/vanilla"),b=require("./utils.cjs"),q=require("radashi"),S=require("zustand/shallow");function E(r){const e=u.createJSONStorage(()=>r==="local"?localStorage:sessionStorage);return{getItem:e.getItem,setItem(o,a){q.isNullish(a.state)||e.setItem(o,a)},removeItem:e.removeItem}}function g(r,e){const o=e?.name??"UNKNOWN",a=e?.storage??"local",s=e?e.selector:()=>null,t=E(a);return l.createWithEqualityFn(u.persist(u.subscribeWithSelector(r),{name:`__VEF_STORE__${b.constantCase(o)}__`,storage:t,version:1,partialize:s}),S.shallow)}function v(r){return h.createStore(u.subscribeWithSelector(r))}function d(r,e,o){return l.useStoreWithEqualityFn(r,e,o??S.shallow)}function _(r,e){const o=n.createContext(null),a=({initialState:t,children:m})=>{const[i]=n.useState(()=>{const f=e(t);return v(f)}),c=n.useRef(!1);return n.useEffect(()=>()=>{c.current=!1},[]),n.useEffect(()=>{c.current||(c.current=!0),t&&i.setState({...t})},[t,i]),n.createElement(o.Provider,{value:i},m)},s=()=>{const t=n.useContext(o);if(!t)throw new Error(`${r}Store can be used only inside ${r}StoreProvider`);return t};return{StoreProvider:a,useStore:t=>d(s(),t),useStoreApi:s}}exports.createComponentStore=_,exports.createStore=g,exports.createUnboundStore=v,exports.useUnboundStore=d;
package/cjs/styles.cjs CHANGED
@@ -1,55 +1,2 @@
1
1
  "use strict";
2
- 'use strict';
3
-
4
- var react = require('@emotion/react');
5
-
6
- "use strict";
7
- const breakpointWidths = {
8
- xs: 0,
9
- sm: 576,
10
- md: 768,
11
- lg: 992,
12
- xl: 1200,
13
- xxl: 1400
14
- };
15
- const breakpoints = [
16
- "xs",
17
- "sm",
18
- "md",
19
- "lg",
20
- "xl",
21
- "xxl"
22
- ];
23
- const bmq = Object.keys(breakpointWidths).reduce(
24
- (acc, label) => {
25
- acc[label] = `@media (min-width: ${breakpointWidths[label]}px)`;
26
- return acc;
27
- },
28
- {}
29
- );
30
- const styles = {
31
- // Flex center style
32
- flexCenter: react.css({
33
- display: "flex",
34
- justifyContent: "center",
35
- alignItems: "center"
36
- }),
37
- // Full height style
38
- fullHeight: react.css({
39
- height: "100%"
40
- }),
41
- // Full width style
42
- fullWidth: react.css({
43
- width: "100%"
44
- }),
45
- // Scrollbar style
46
- scrollbar: react.css({
47
- scrollbarWidth: "thin",
48
- scrollbarColor: "rgba(0, 0, 0, 0.3) transparent",
49
- scrollbarGutter: "stable"
50
- })
51
- };
52
-
53
- exports.bmq = bmq;
54
- exports.breakpoints = breakpoints;
55
- exports.styles = styles;
2
+ "use strict";var s=require("@emotion/react");const l={xs:0,sm:576,md:768,lg:992,xl:1200,xxl:1400},r=["xs","sm","md","lg","xl","xxl"],c=Object.keys(l).reduce((t,e)=>(t[e]=`@media (min-width: ${l[e]}px)`,t),{}),i={flexCenter:s.css({display:"flex",justifyContent:"center",alignItems:"center"}),fullHeight:s.css({height:"100%"}),fullWidth:s.css({width:"100%"}),scrollbar:s.css({scrollbarWidth:"thin",scrollbarColor:"rgba(0, 0, 0, 0.3) transparent",scrollbarGutter:"stable"})};exports.bmq=c,exports.breakpoints=r,exports.styles=i;
package/cjs/temporal.cjs CHANGED
@@ -1,27 +1,2 @@
1
1
  "use strict";
2
- 'use strict';
3
-
4
- var tz = require('@date-fns/tz');
5
- var dateFns = require('date-fns');
6
- var locale = require('date-fns/locale');
7
-
8
- "use strict";
9
- function getNowDate() {
10
- return /* @__PURE__ */ new Date();
11
- }
12
- function getNowDateString() {
13
- return dateFns.format(getNowDate(), "yyyy-MM-dd", {
14
- locale: locale.zhCN,
15
- in: tz.tz("Asia/Shanghai")
16
- });
17
- }
18
- function getTodayString() {
19
- return dateFns.format(getNowDate(), "PPPPpp", {
20
- locale: locale.zhCN,
21
- in: tz.tz("Asia/Shanghai")
22
- });
23
- }
24
-
25
- exports.getNowDate = getNowDate;
26
- exports.getNowDateString = getNowDateString;
27
- exports.getTodayString = getTodayString;
2
+ "use strict";var e=require("@date-fns/tz"),r=require("date-fns"),a=require("date-fns/locale");function t(){return new Date}function n(){return r.format(t(),"yyyy-MM-dd",{locale:a.zhCN,in:e.tz("Asia/Shanghai")})}function i(){return r.format(t(),"PPPPpp",{locale:a.zhCN,in:e.tz("Asia/Shanghai")})}exports.getNowDate=t,exports.getNowDateString=n,exports.getTodayString=i;