@dczy/tie-core 0.1.0
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/date.d.ts +2 -0
- package/dist/date.d.ts.map +1 -0
- package/dist/id.d.ts +2 -0
- package/dist/id.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/object.d.ts +6 -0
- package/dist/object.d.ts.map +1 -0
- package/dist/tie-core.cjs +1 -0
- package/dist/tie-core.js +285 -0
- package/dist/tree.d.ts +26 -0
- package/dist/tree.d.ts.map +1 -0
- package/dist/validate.d.ts +16 -0
- package/dist/validate.d.ts.map +1 -0
- package/package.json +27 -0
package/dist/date.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../src/date.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,UAgC7D"}
|
package/dist/id.d.ts
ADDED
package/dist/id.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../src/id.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,WAMzB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const DCZY_TIE_CORE_VERSION = "0.1.0";
|
|
2
|
+
export type DczySize = "small" | "medium" | "large";
|
|
3
|
+
export interface DczyThemeTokens {
|
|
4
|
+
primaryColor?: string;
|
|
5
|
+
borderRadius?: string;
|
|
6
|
+
classPrefix?: string;
|
|
7
|
+
}
|
|
8
|
+
export * from "./date";
|
|
9
|
+
export * from "./id";
|
|
10
|
+
export * from "./object";
|
|
11
|
+
export * from "./tree";
|
|
12
|
+
export * from "./validate";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,UAAU,CAAA;AAE5C,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEnD,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,MAAM,CAAA;AACpB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA"}
|
package/dist/object.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function getValueByPath(data: unknown, path: string): any;
|
|
2
|
+
export declare function deepClone<T = any>(source: T, noClone?: string[]): T;
|
|
3
|
+
export declare function cloneArrayWithItems<T extends any[]>(source: T, items: T): T;
|
|
4
|
+
export declare function cloneArrayWithItem<TItem>(source: TItem[], item: TItem): TItem[];
|
|
5
|
+
export declare function parseJsonObjects(payload: string): any[];
|
|
6
|
+
//# sourceMappingURL=object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAsB/D;AAiED,wBAAgB,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,GAAE,MAAM,EAAO,GAAG,CAAC,CAGvE;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAKvE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,WAIrE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,SAuB/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function S(e,n){if(!e||e==="0001-01-01T00:00:00")return"";const i=typeof e=="string"&&!e.includes("T")?e.replace(/-/g,"/"):e,t=new Date(i),r={"M+":t.getMonth()+1,"d+":t.getDate(),"H+":t.getHours(),"m+":t.getMinutes(),"s+":t.getSeconds(),"q+":Math.floor((t.getMonth()+3)/3),S:t.getMilliseconds()},s=/(y+)/.exec(n);return s&&(n=n.replace(s[1],`${t.getFullYear()}`.substring(4-s[1].length))),Object.keys(r).forEach(o=>{const c=new RegExp(`(${o})`).exec(n);if(!c)return;const l=`${r[o]}`;n=n.replace(c[1],c[1].length===1?l:`00${l}`.substring(l.length))}),n}function N(){function e(){return((1+Math.random())*65536|0).toString(16).substring(1)}return`${e()}${e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}function g(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function E(e){return g(e,"String")}function T(e){return typeof e<"u"}function $(e){return!T(e)}function A(e){return typeof e=="function"}function w(e){return g(e,"Number")}function O(e){return e!==null&&g(e,"Object")}function I(e){return Array.isArray(e)}function x(e){if(!e)return!1;const n=e.substring(e.lastIndexOf(".")).toLowerCase();return[".png",".jpg",".jpeg",".gif",".bmp",".webp"].includes(n)}function D(e){return/^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})(\/[\w.-]*)*\/?$/.test(e)}function M(e){return/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(e)}function P(e){return/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(String(e))}function z(e){return/^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(e)}function C(e){return/^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(e)}function R(e){return/^[A-Za-z0-9+/]+={0,2}$/.test(e)&&e.length%4===0}function b(e,n){if(!e)return;const i=n.split(".").filter(t=>t!=="");if(!i.length)return e;if(Array.isArray(e)){const t=Number.parseInt(i[0],10);if(Number.isNaN(t)||e.length-1<t)return;const r=e[t],s=i.slice(1);return s.length>0?b(r,s.join(".")):r}if(O(e)){const t=e[i[0]],r=i.slice(1);return r.length>0?b(t,r.join(".")):t}}function v(e){return new Date(e.valueOf())}function V(e){const n=new RegExp(e.source,e.flags);return n.lastIndex=e.lastIndex,n}function p(e,n,i){if(e===null||typeof e!="object")return e;if(e instanceof Date)return v(e);if(e instanceof RegExp)return V(e);const t=e,r=i.get(t);if(r)return r;if(e instanceof Map){const u=new Map;return i.set(t,u),e.forEach((a,d)=>{u.set(p(d,n,i),p(a,n,i))}),u}if(e instanceof Set){const u=new Set;return i.set(t,u),e.forEach(a=>{u.add(p(a,n,i))}),u}const s=Array.isArray(e)?new Array(e.length):Object.create(Object.getPrototypeOf(t)),o=e,c=s,l=[...Object.keys(o),...Object.getOwnPropertySymbols(t).filter(u=>Object.prototype.propertyIsEnumerable.call(t,u))];return i.set(t,s),l.forEach(u=>{typeof u=="string"&&n.includes(u)?c[u]=o[u]:c[u]=p(o[u],n,i)}),s}function h(e,n=[]){return e==null?e:p(e,n,new WeakMap)}function Z(e,n){const i=h(e),t=h(n);return i.push(...t),i}function _(e,n){const i=h(e);return i.push(h(n)),i}function F(e){let n=e;return e.includes("[DONE]")&&(n=e.replace(/\[DONE\]|[\r\n]/g,"")),n.replace(/},\s*"Solution"/g,'}{"Solution"').split(new RegExp("(?<=})\\s*(?={)")).map(r=>{const s=r.replace(/([{,]\s*)(\w+)(\s*:)/g,'$1"$2"$3');try{return s.split(" ").join("").length?JSON.parse(s):null}catch(o){return console.error("Invalid JSON:",s,o),null}}).filter(r=>r!==null)}const y={id:"id",children:"children",pid:"pid"};function f(e){return{...y,...e||{}}}function W(e,n,i={}){const{id:t,pid:r,children:s}=f(n),o=new Map,c=[],l=i.cloneNodes!==!1;for(const u of e){const a=l?{...u}:u;o.set(u[t],a)}for(const u of e){const a=o.get(u[t]),d=o.get(u[r]);d&&!d[s]&&(d[s]=[]),(d?d[s]:c).push(a)}return c}function B(e,n){const{children:i}=f(n),t=[...e];for(let r=0;r<t.length;r++){const s=t[r];s[i]&&t.splice(r+1,0,...s[i])}return t}function H(e,n,i){const{children:t}=f(i),r=[...e];for(const s of r){if(n(s))return s;s[t]&&r.push(...s[t])}return null}function J(e,n,i){const{children:t}=f(i),r=[...e],s=[];for(const o of r)n(o)&&s.push(o),o[t]&&r.push(...o[t]);return s}function L(e,n,i){const t=[],r=[...e],s=new Set,{children:o}=f(i);for(;r.length;){const c=r[0];if(s.has(c))t.pop(),r.shift();else if(s.add(c),c[o]&&r.unshift(...c[o]),t.push(c),n(c))return t}return null}function Y(e,n,i){const t=[],r=[...e],s=[],o=new Set,{children:c}=f(i);for(;r.length;){const l=r[0];o.has(l)?(t.pop(),r.shift()):(o.add(l),l[c]&&r.unshift(...l[c]),t.push(l),n(l)&&s.push([...t]))}return s}function G(e,n,i){const{children:t}=f(i);function r(s){return s.map(o=>({...o})).filter(o=>{const c=o;return c[t]=c[t]&&r(c[t]),n(o)||c[t]&&c[t].length})}return r(e)}function U(e,n,i){const t=[...e],{children:r}=f(i);for(let s=0;s<t.length;s++){if(n(t[s]))return;t[s][r]&&t.splice(s+1,0,...t[s][r])}}function q(e,n){return e.map(i=>j(i,n))}function j(e,{children:n="children",conversion:i}){const t=Array.isArray(e[n])&&e[n].length>0,r=i(e)||{};return t?{...r,[n]:e[n].map(s=>j(s,{children:n,conversion:i}))}:{...r}}function m(e,n,i={}){e.forEach(t=>{const r=n(t,i)||t;t.children&&m(t.children,n,r)})}const X="0.1.0";exports.DCZY_TIE_CORE_VERSION=X;exports.cloneArrayWithItem=_;exports.cloneArrayWithItems=Z;exports.createGuid=N;exports.deepClone=h;exports.defaultTreeHelperConfig=y;exports.eachTree=m;exports.filterTree=G;exports.findTreeNode=H;exports.findTreeNodes=J;exports.findTreePath=L;exports.findTreePaths=Y;exports.forEachTree=U;exports.formatDate=S;exports.getValueByPath=b;exports.is=g;exports.isArray=I;exports.isBase64=R;exports.isDef=T;exports.isEmail=M;exports.isExternal=D;exports.isFunction=A;exports.isIdCard=z;exports.isImgFiles=x;exports.isMobilePhone=P;exports.isNumber=w;exports.isObject=O;exports.isString=E;exports.isTelephone=C;exports.isUnDef=$;exports.listToTree=W;exports.mapTree=q;exports.normalizeTreeConfig=f;exports.parseJsonObjects=F;exports.treeToList=B;
|
package/dist/tie-core.js
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
function T(t, e) {
|
|
2
|
+
if (!t || t === "0001-01-01T00:00:00") return "";
|
|
3
|
+
const s = typeof t == "string" && !t.includes("T") ? t.replace(/-/g, "/") : t, n = new Date(s), r = {
|
|
4
|
+
"M+": n.getMonth() + 1,
|
|
5
|
+
"d+": n.getDate(),
|
|
6
|
+
"H+": n.getHours(),
|
|
7
|
+
"m+": n.getMinutes(),
|
|
8
|
+
"s+": n.getSeconds(),
|
|
9
|
+
"q+": Math.floor((n.getMonth() + 3) / 3),
|
|
10
|
+
S: n.getMilliseconds()
|
|
11
|
+
}, o = /(y+)/.exec(e);
|
|
12
|
+
return o && (e = e.replace(
|
|
13
|
+
o[1],
|
|
14
|
+
`${n.getFullYear()}`.substring(4 - o[1].length)
|
|
15
|
+
)), Object.keys(r).forEach((i) => {
|
|
16
|
+
const c = new RegExp(`(${i})`).exec(e);
|
|
17
|
+
if (!c) return;
|
|
18
|
+
const f = `${r[i]}`;
|
|
19
|
+
e = e.replace(c[1], c[1].length === 1 ? f : `00${f}`.substring(f.length));
|
|
20
|
+
}), e;
|
|
21
|
+
}
|
|
22
|
+
function A() {
|
|
23
|
+
function t() {
|
|
24
|
+
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
25
|
+
}
|
|
26
|
+
return `${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`;
|
|
27
|
+
}
|
|
28
|
+
function g(t, e) {
|
|
29
|
+
return Object.prototype.toString.call(t) === `[object ${e}]`;
|
|
30
|
+
}
|
|
31
|
+
function x(t) {
|
|
32
|
+
return g(t, "String");
|
|
33
|
+
}
|
|
34
|
+
function O(t) {
|
|
35
|
+
return typeof t < "u";
|
|
36
|
+
}
|
|
37
|
+
function E(t) {
|
|
38
|
+
return !O(t);
|
|
39
|
+
}
|
|
40
|
+
function m(t) {
|
|
41
|
+
return typeof t == "function";
|
|
42
|
+
}
|
|
43
|
+
function M(t) {
|
|
44
|
+
return g(t, "Number");
|
|
45
|
+
}
|
|
46
|
+
function y(t) {
|
|
47
|
+
return t !== null && g(t, "Object");
|
|
48
|
+
}
|
|
49
|
+
function I(t) {
|
|
50
|
+
return Array.isArray(t);
|
|
51
|
+
}
|
|
52
|
+
function D(t) {
|
|
53
|
+
if (!t) return !1;
|
|
54
|
+
const e = t.substring(t.lastIndexOf(".")).toLowerCase();
|
|
55
|
+
return [".png", ".jpg", ".jpeg", ".gif", ".bmp", ".webp"].includes(e);
|
|
56
|
+
}
|
|
57
|
+
function z(t) {
|
|
58
|
+
return /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})(\/[\w.-]*)*\/?$/.test(t);
|
|
59
|
+
}
|
|
60
|
+
function P(t) {
|
|
61
|
+
return /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/.test(t);
|
|
62
|
+
}
|
|
63
|
+
function v(t) {
|
|
64
|
+
return /^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(String(t));
|
|
65
|
+
}
|
|
66
|
+
function R(t) {
|
|
67
|
+
return /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(t);
|
|
68
|
+
}
|
|
69
|
+
function Z(t) {
|
|
70
|
+
return /^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(t);
|
|
71
|
+
}
|
|
72
|
+
function V(t) {
|
|
73
|
+
return /^[A-Za-z0-9+/]+={0,2}$/.test(t) && t.length % 4 === 0;
|
|
74
|
+
}
|
|
75
|
+
function b(t, e) {
|
|
76
|
+
if (!t) return;
|
|
77
|
+
const s = e.split(".").filter((n) => n !== "");
|
|
78
|
+
if (!s.length) return t;
|
|
79
|
+
if (Array.isArray(t)) {
|
|
80
|
+
const n = Number.parseInt(s[0], 10);
|
|
81
|
+
if (Number.isNaN(n) || t.length - 1 < n) return;
|
|
82
|
+
const r = t[n], o = s.slice(1);
|
|
83
|
+
return o.length > 0 ? b(r, o.join(".")) : r;
|
|
84
|
+
}
|
|
85
|
+
if (y(t)) {
|
|
86
|
+
const n = t[s[0]], r = s.slice(1);
|
|
87
|
+
return r.length > 0 ? b(n, r.join(".")) : n;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function $(t) {
|
|
91
|
+
return new Date(t.valueOf());
|
|
92
|
+
}
|
|
93
|
+
function S(t) {
|
|
94
|
+
const e = new RegExp(t.source, t.flags);
|
|
95
|
+
return e.lastIndex = t.lastIndex, e;
|
|
96
|
+
}
|
|
97
|
+
function p(t, e, s) {
|
|
98
|
+
if (t === null || typeof t != "object") return t;
|
|
99
|
+
if (t instanceof Date) return $(t);
|
|
100
|
+
if (t instanceof RegExp) return S(t);
|
|
101
|
+
const n = t, r = s.get(n);
|
|
102
|
+
if (r) return r;
|
|
103
|
+
if (t instanceof Map) {
|
|
104
|
+
const u = /* @__PURE__ */ new Map();
|
|
105
|
+
return s.set(n, u), t.forEach((a, d) => {
|
|
106
|
+
u.set(p(d, e, s), p(a, e, s));
|
|
107
|
+
}), u;
|
|
108
|
+
}
|
|
109
|
+
if (t instanceof Set) {
|
|
110
|
+
const u = /* @__PURE__ */ new Set();
|
|
111
|
+
return s.set(n, u), t.forEach((a) => {
|
|
112
|
+
u.add(p(a, e, s));
|
|
113
|
+
}), u;
|
|
114
|
+
}
|
|
115
|
+
const o = Array.isArray(t) ? new Array(t.length) : Object.create(Object.getPrototypeOf(n)), i = t, c = o, f = [
|
|
116
|
+
...Object.keys(i),
|
|
117
|
+
...Object.getOwnPropertySymbols(n).filter(
|
|
118
|
+
(u) => Object.prototype.propertyIsEnumerable.call(n, u)
|
|
119
|
+
)
|
|
120
|
+
];
|
|
121
|
+
return s.set(n, o), f.forEach((u) => {
|
|
122
|
+
typeof u == "string" && e.includes(u) ? c[u] = i[u] : c[u] = p(i[u], e, s);
|
|
123
|
+
}), o;
|
|
124
|
+
}
|
|
125
|
+
function h(t, e = []) {
|
|
126
|
+
return t == null ? t : p(t, e, /* @__PURE__ */ new WeakMap());
|
|
127
|
+
}
|
|
128
|
+
function C(t, e) {
|
|
129
|
+
const s = h(t), n = h(e);
|
|
130
|
+
return s.push(...n), s;
|
|
131
|
+
}
|
|
132
|
+
function _(t, e) {
|
|
133
|
+
const s = h(t);
|
|
134
|
+
return s.push(h(e)), s;
|
|
135
|
+
}
|
|
136
|
+
function F(t) {
|
|
137
|
+
let e = t;
|
|
138
|
+
return t.includes("[DONE]") && (e = t.replace(/\[DONE\]|[\r\n]/g, "")), e.replace(/},\s*"Solution"/g, '}{"Solution"').split(new RegExp("(?<=})\\s*(?={)")).map((r) => {
|
|
139
|
+
const o = r.replace(/([{,]\s*)(\w+)(\s*:)/g, '$1"$2"$3');
|
|
140
|
+
try {
|
|
141
|
+
return o.split(" ").join("").length ? JSON.parse(o) : null;
|
|
142
|
+
} catch (i) {
|
|
143
|
+
return console.error("Invalid JSON:", o, i), null;
|
|
144
|
+
}
|
|
145
|
+
}).filter((r) => r !== null);
|
|
146
|
+
}
|
|
147
|
+
const w = {
|
|
148
|
+
id: "id",
|
|
149
|
+
children: "children",
|
|
150
|
+
pid: "pid"
|
|
151
|
+
};
|
|
152
|
+
function l(t) {
|
|
153
|
+
return {
|
|
154
|
+
...w,
|
|
155
|
+
...t || {}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function H(t, e, s = {}) {
|
|
159
|
+
const { id: n, pid: r, children: o } = l(e), i = /* @__PURE__ */ new Map(), c = [], f = s.cloneNodes !== !1;
|
|
160
|
+
for (const u of t) {
|
|
161
|
+
const a = f ? { ...u } : u;
|
|
162
|
+
i.set(u[n], a);
|
|
163
|
+
}
|
|
164
|
+
for (const u of t) {
|
|
165
|
+
const a = i.get(u[n]), d = i.get(u[r]);
|
|
166
|
+
d && !d[o] && (d[o] = []), (d ? d[o] : c).push(a);
|
|
167
|
+
}
|
|
168
|
+
return c;
|
|
169
|
+
}
|
|
170
|
+
function J(t, e) {
|
|
171
|
+
const { children: s } = l(e), n = [...t];
|
|
172
|
+
for (let r = 0; r < n.length; r++) {
|
|
173
|
+
const o = n[r];
|
|
174
|
+
o[s] && n.splice(r + 1, 0, ...o[s]);
|
|
175
|
+
}
|
|
176
|
+
return n;
|
|
177
|
+
}
|
|
178
|
+
function L(t, e, s) {
|
|
179
|
+
const { children: n } = l(s), r = [...t];
|
|
180
|
+
for (const o of r) {
|
|
181
|
+
if (e(o)) return o;
|
|
182
|
+
o[n] && r.push(...o[n]);
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
function W(t, e, s) {
|
|
187
|
+
const { children: n } = l(s), r = [...t], o = [];
|
|
188
|
+
for (const i of r)
|
|
189
|
+
e(i) && o.push(i), i[n] && r.push(...i[n]);
|
|
190
|
+
return o;
|
|
191
|
+
}
|
|
192
|
+
function B(t, e, s) {
|
|
193
|
+
const n = [], r = [...t], o = /* @__PURE__ */ new Set(), { children: i } = l(s);
|
|
194
|
+
for (; r.length; ) {
|
|
195
|
+
const c = r[0];
|
|
196
|
+
if (o.has(c))
|
|
197
|
+
n.pop(), r.shift();
|
|
198
|
+
else if (o.add(c), c[i] && r.unshift(...c[i]), n.push(c), e(c)) return n;
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
function Y(t, e, s) {
|
|
203
|
+
const n = [], r = [...t], o = [], i = /* @__PURE__ */ new Set(), { children: c } = l(s);
|
|
204
|
+
for (; r.length; ) {
|
|
205
|
+
const f = r[0];
|
|
206
|
+
i.has(f) ? (n.pop(), r.shift()) : (i.add(f), f[c] && r.unshift(...f[c]), n.push(f), e(f) && o.push([...n]));
|
|
207
|
+
}
|
|
208
|
+
return o;
|
|
209
|
+
}
|
|
210
|
+
function q(t, e, s) {
|
|
211
|
+
const { children: n } = l(s);
|
|
212
|
+
function r(o) {
|
|
213
|
+
return o.map((i) => ({ ...i })).filter((i) => {
|
|
214
|
+
const c = i;
|
|
215
|
+
return c[n] = c[n] && r(c[n]), e(i) || c[n] && c[n].length;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return r(t);
|
|
219
|
+
}
|
|
220
|
+
function G(t, e, s) {
|
|
221
|
+
const n = [...t], { children: r } = l(s);
|
|
222
|
+
for (let o = 0; o < n.length; o++) {
|
|
223
|
+
if (e(n[o])) return;
|
|
224
|
+
n[o][r] && n.splice(o + 1, 0, ...n[o][r]);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function U(t, e) {
|
|
228
|
+
return t.map((s) => j(s, e));
|
|
229
|
+
}
|
|
230
|
+
function j(t, { children: e = "children", conversion: s }) {
|
|
231
|
+
const n = Array.isArray(t[e]) && t[e].length > 0, r = s(t) || {};
|
|
232
|
+
return n ? {
|
|
233
|
+
...r,
|
|
234
|
+
[e]: t[e].map(
|
|
235
|
+
(o) => j(o, {
|
|
236
|
+
children: e,
|
|
237
|
+
conversion: s
|
|
238
|
+
})
|
|
239
|
+
)
|
|
240
|
+
} : { ...r };
|
|
241
|
+
}
|
|
242
|
+
function N(t, e, s = {}) {
|
|
243
|
+
t.forEach((n) => {
|
|
244
|
+
const r = e(n, s) || n;
|
|
245
|
+
n.children && N(n.children, e, r);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
const X = "0.1.0";
|
|
249
|
+
export {
|
|
250
|
+
X as DCZY_TIE_CORE_VERSION,
|
|
251
|
+
_ as cloneArrayWithItem,
|
|
252
|
+
C as cloneArrayWithItems,
|
|
253
|
+
A as createGuid,
|
|
254
|
+
h as deepClone,
|
|
255
|
+
w as defaultTreeHelperConfig,
|
|
256
|
+
N as eachTree,
|
|
257
|
+
q as filterTree,
|
|
258
|
+
L as findTreeNode,
|
|
259
|
+
W as findTreeNodes,
|
|
260
|
+
B as findTreePath,
|
|
261
|
+
Y as findTreePaths,
|
|
262
|
+
G as forEachTree,
|
|
263
|
+
T as formatDate,
|
|
264
|
+
b as getValueByPath,
|
|
265
|
+
g as is,
|
|
266
|
+
I as isArray,
|
|
267
|
+
V as isBase64,
|
|
268
|
+
O as isDef,
|
|
269
|
+
P as isEmail,
|
|
270
|
+
z as isExternal,
|
|
271
|
+
m as isFunction,
|
|
272
|
+
R as isIdCard,
|
|
273
|
+
D as isImgFiles,
|
|
274
|
+
v as isMobilePhone,
|
|
275
|
+
M as isNumber,
|
|
276
|
+
y as isObject,
|
|
277
|
+
x as isString,
|
|
278
|
+
Z as isTelephone,
|
|
279
|
+
E as isUnDef,
|
|
280
|
+
H as listToTree,
|
|
281
|
+
U as mapTree,
|
|
282
|
+
l as normalizeTreeConfig,
|
|
283
|
+
F as parseJsonObjects,
|
|
284
|
+
J as treeToList
|
|
285
|
+
};
|
package/dist/tree.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface TreeHelperConfig {
|
|
2
|
+
id: string;
|
|
3
|
+
children: string;
|
|
4
|
+
pid: string;
|
|
5
|
+
}
|
|
6
|
+
export interface TreeConversionOptions<T = any, R = T> {
|
|
7
|
+
children?: string;
|
|
8
|
+
conversion: (node: T) => R;
|
|
9
|
+
}
|
|
10
|
+
export interface ListToTreeOptions {
|
|
11
|
+
cloneNodes?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export type TreePredicate<T = any> = (node: T) => boolean;
|
|
14
|
+
export declare const defaultTreeHelperConfig: TreeHelperConfig;
|
|
15
|
+
export declare function normalizeTreeConfig(config?: Partial<TreeHelperConfig>): TreeHelperConfig;
|
|
16
|
+
export declare function listToTree<T extends Record<string, any> = any>(list: T[], config?: Partial<TreeHelperConfig>, options?: ListToTreeOptions): T[];
|
|
17
|
+
export declare function treeToList<T extends Record<string, any> = any>(tree: T[], config?: Partial<TreeHelperConfig>): T[];
|
|
18
|
+
export declare function findTreeNode<T extends Record<string, any> = any>(tree: T[], predicate: TreePredicate<T>, config?: Partial<TreeHelperConfig>): T | null;
|
|
19
|
+
export declare function findTreeNodes<T extends Record<string, any> = any>(tree: T[], predicate: TreePredicate<T>, config?: Partial<TreeHelperConfig>): T[];
|
|
20
|
+
export declare function findTreePath<T extends Record<string, any> = any>(tree: T[], predicate: TreePredicate<T>, config?: Partial<TreeHelperConfig>): T[] | null;
|
|
21
|
+
export declare function findTreePaths<T extends Record<string, any> = any>(tree: T[], predicate: TreePredicate<T>, config?: Partial<TreeHelperConfig>): T[][];
|
|
22
|
+
export declare function filterTree<T extends Record<string, any> = any>(tree: T[], predicate: TreePredicate<T>, config?: Partial<TreeHelperConfig>): T[];
|
|
23
|
+
export declare function forEachTree<T extends Record<string, any> = any>(tree: T[], callback: (node: T) => any, config?: Partial<TreeHelperConfig>): void;
|
|
24
|
+
export declare function mapTree<T extends Record<string, any> = any, R extends Record<string, any> = any>(tree: T[], options: TreeConversionOptions<T, R>): R[];
|
|
25
|
+
export declare function eachTree<T extends Record<string, any> = any>(tree: T[], callback: (node: T, parentNode: any) => T | void, parentNode?: any): void;
|
|
26
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,C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,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAC9F,IAAI,EAAE,CAAC,EAAE,EACT,OAAO,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,GACnC,CAAC,EAAE,CAEL;AAsBD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAC1D,IAAI,EAAE,CAAC,EAAE,EACT,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,EAChD,UAAU,GAAE,GAAQ,QAQrB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare function is(val: unknown, type: string): boolean;
|
|
2
|
+
export declare function isString(val: unknown): val is string;
|
|
3
|
+
export declare function isDef<T = unknown>(val?: T): val is T;
|
|
4
|
+
export declare function isUnDef<T = unknown>(val?: T): val is T;
|
|
5
|
+
export declare function isFunction(val: unknown): val is (...args: any[]) => any;
|
|
6
|
+
export declare function isNumber(val: unknown): val is number;
|
|
7
|
+
export declare function isObject(val: unknown): val is Record<PropertyKey, any>;
|
|
8
|
+
export declare function isArray<T = unknown>(val: unknown): val is T[];
|
|
9
|
+
export declare function isImgFiles(url: string): boolean;
|
|
10
|
+
export declare function isExternal(path: string): boolean;
|
|
11
|
+
export declare function isEmail(path: string): boolean;
|
|
12
|
+
export declare function isMobilePhone(tel: unknown): boolean;
|
|
13
|
+
export declare function isIdCard(id: string): boolean;
|
|
14
|
+
export declare function isTelephone(tel: string): boolean;
|
|
15
|
+
export declare function isBase64(str: string): boolean;
|
|
16
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,wBAAgB,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAE5C;AAED,w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|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/tie-core.cjs",
|
|
7
|
+
"module": "./dist/tie-core.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/tie-core.js",
|
|
13
|
+
"require": "./dist/tie-core.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/**/*.js",
|
|
18
|
+
"dist/**/*.cjs",
|
|
19
|
+
"dist/**/*.d.ts",
|
|
20
|
+
"dist/**/*.d.ts.map"
|
|
21
|
+
],
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "vite build && tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
25
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
26
|
+
}
|
|
27
|
+
}
|