@unicom-cloud/utils 0.1.12 → 0.1.13
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/filesize/src/constants.js +22 -22
- package/filesize/src/filesize.js +32 -33
- package/package.json +1 -1
- package/snapdom/src/api/preCache.js +23 -23
- package/snapdom/src/api/snapdom.js +42 -42
- package/snapdom/src/core/cache.js +19 -8
- package/snapdom/src/core/capture.js +60 -59
- package/snapdom/src/core/clone.js +96 -31
- package/snapdom/src/core/prepare.js +35 -38
- package/snapdom/src/modules/background.js +29 -20
- package/snapdom/src/modules/fonts.js +97 -105
- package/snapdom/src/modules/pseudo.js +32 -32
- package/snapdom/src/modules/styles.js +22 -22
- package/snapdom/src/utils/cssTools.js +41 -41
- package/snapdom/src/utils/helpers.js +143 -146
- package/tree/index.js +1 -1
- package/tree/search/index.js +90 -0
- package/tree.js +1 -1
- package/types/filesize/src/constants.d.ts +12 -12
- package/types/filesize/src/filesize.d.ts +63 -22
- package/types/snapdom/src/core/cache.d.ts +17 -11
- package/types/snapdom/src/core/capture.d.ts +4 -0
- package/types/snapdom/src/core/clone.d.ts +4 -5
- package/types/snapdom/src/core/prepare.d.ts +8 -1
- package/types/snapdom/src/modules/background.d.ts +1 -2
- package/types/snapdom/src/modules/pseudo.d.ts +1 -3
- package/types/snapdom/src/modules/styles.d.ts +1 -1
- package/types/snapdom/src/utils/cssTools.d.ts +1 -2
- package/types/tree/index.d.ts +1 -1
- package/types/tree/search/index.d.ts +80 -0
- package/types/ui-color/index.d.ts +28 -3
- package/ui-color/index.js +70 -63
- package/uiColor.js +19 -18
- package/tree/searchTree.js +0 -54
- package/types/tree/searchTree.d.ts +0 -20
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import "../../is/index.js";
|
|
2
|
+
import A from "lodash/isArray";
|
|
3
|
+
import z from "lodash/isObjectLike";
|
|
4
|
+
import w from "lodash/isString";
|
|
5
|
+
import T from "lodash/isFunction";
|
|
6
|
+
function v(r, l, a, f) {
|
|
7
|
+
return l && r ? { shouldExit: !0, newMatch: !0 } : a && !r ? { shouldExit: !0, newMatch: !1 } : { shouldExit: !1, newMatch: f || r };
|
|
8
|
+
}
|
|
9
|
+
function q(r, l, a = {}) {
|
|
10
|
+
if (!A(r)) throw new TypeError("参数treeData必须是一个数组");
|
|
11
|
+
if (!z(l)) throw new TypeError("参数searchCondition必须是一个对象");
|
|
12
|
+
const f = {
|
|
13
|
+
strategy: "BFS",
|
|
14
|
+
childrenKey: "children",
|
|
15
|
+
strict: !1,
|
|
16
|
+
fuzzyMatch: !1,
|
|
17
|
+
returnAllMatches: !1,
|
|
18
|
+
caseSensitive: !1,
|
|
19
|
+
allowEmptyString: !1,
|
|
20
|
+
matchMode: "AND",
|
|
21
|
+
...a
|
|
22
|
+
// 用户配置覆盖默认值
|
|
23
|
+
}, {
|
|
24
|
+
strategy: p,
|
|
25
|
+
childrenKey: S,
|
|
26
|
+
strict: x,
|
|
27
|
+
fuzzyMatch: O,
|
|
28
|
+
returnAllMatches: y,
|
|
29
|
+
caseSensitive: m,
|
|
30
|
+
allowEmptyString: B,
|
|
31
|
+
matchMode: E
|
|
32
|
+
} = f, M = E === "OR", g = E === "AND", h = p === "BFS";
|
|
33
|
+
if (!(h || p === "DFS")) throw new Error('配置 strategy 必须是 "BFS" 或 "DFS"');
|
|
34
|
+
if (!(M || g)) throw new Error('配置 matchMode 必须是 "AND" 或 "OR"');
|
|
35
|
+
if (!w(S)) throw new TypeError("配置 childrenKey 必须是字符串");
|
|
36
|
+
const c = [...r], F = [], D = Object.entries(l);
|
|
37
|
+
if (D.length) {
|
|
38
|
+
const N = (s) => {
|
|
39
|
+
let t = !1;
|
|
40
|
+
for (const [n, e] of D) {
|
|
41
|
+
const i = s[n];
|
|
42
|
+
if (e === "" && !B)
|
|
43
|
+
continue;
|
|
44
|
+
let o = !1;
|
|
45
|
+
try {
|
|
46
|
+
if (e instanceof RegExp)
|
|
47
|
+
o = w(i) ? e.test(i) : !1;
|
|
48
|
+
else if (T(e))
|
|
49
|
+
o = !!e(i);
|
|
50
|
+
else if (O && w(e)) {
|
|
51
|
+
const d = String(i), R = m ? e : e.toLowerCase();
|
|
52
|
+
o = (m ? d : d.toLowerCase()).includes(R);
|
|
53
|
+
} else
|
|
54
|
+
o = x ? i === e : i == e;
|
|
55
|
+
} catch {
|
|
56
|
+
o = !1;
|
|
57
|
+
}
|
|
58
|
+
const u = v(o, M, g, t);
|
|
59
|
+
if (u.shouldExit)
|
|
60
|
+
return u.newMatch;
|
|
61
|
+
t = u.newMatch;
|
|
62
|
+
}
|
|
63
|
+
return t;
|
|
64
|
+
};
|
|
65
|
+
for (; c.length > 0; ) {
|
|
66
|
+
const s = h ? c.shift() : c.pop();
|
|
67
|
+
if (!s) continue;
|
|
68
|
+
try {
|
|
69
|
+
if (N(s))
|
|
70
|
+
if (y)
|
|
71
|
+
F.push(s);
|
|
72
|
+
else
|
|
73
|
+
return s;
|
|
74
|
+
} catch {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const t = s[S];
|
|
78
|
+
if (A(t))
|
|
79
|
+
if (h)
|
|
80
|
+
c.push(...t);
|
|
81
|
+
else
|
|
82
|
+
for (let n = t.length - 1; n >= 0; n--)
|
|
83
|
+
c.push(t[n]);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return y ? F : null;
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
q as default
|
|
90
|
+
};
|
package/tree.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { default as a } from "./tree/
|
|
1
|
+
import { default as a } from "./tree/search/index.js";
|
|
2
2
|
import { getItemBy as y, findNodeBy as m, getChildWithParentBy as B, getItemBy as g, getItemBy2 as o, getItemBy3 as I, getItemByID as d, getLabelFromDictionaryByValue as f } from "./tree/index.js";
|
|
3
3
|
export {
|
|
4
4
|
y as default,
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const INVALID_NUMBER: "Invalid number";
|
|
2
|
+
export const INVALID_ROUND: "Invalid rounding method";
|
|
3
|
+
export const IEC: "iec";
|
|
4
|
+
export const JEDEC: "jedec";
|
|
5
|
+
export const SI: "si";
|
|
2
6
|
export const BIT: "bit";
|
|
3
7
|
export const BITS: "bits";
|
|
4
8
|
export const BYTE: "byte";
|
|
5
9
|
export const BYTES: "bytes";
|
|
6
|
-
export const
|
|
7
|
-
export const
|
|
10
|
+
export const SI_KBIT: "kbit";
|
|
11
|
+
export const SI_KBYTE: "kB";
|
|
12
|
+
export const ARRAY: "array";
|
|
8
13
|
export const FUNCTION: "function";
|
|
9
|
-
export const IEC: "iec";
|
|
10
|
-
export const INVALID_NUMBER: "Invalid number";
|
|
11
|
-
export const INVALID_ROUND: "Invalid rounding method";
|
|
12
|
-
export const JEDEC: "jedec";
|
|
13
14
|
export const OBJECT: "object";
|
|
14
|
-
export const
|
|
15
|
+
export const STRING: "string";
|
|
16
|
+
export const EXPONENT: "exponent";
|
|
15
17
|
export const ROUND: "round";
|
|
18
|
+
export const EMPTY: "";
|
|
19
|
+
export const PERIOD: ".";
|
|
16
20
|
export const S: "s";
|
|
17
|
-
export const SI: "si";
|
|
18
|
-
export const SI_KBIT: "kbit";
|
|
19
|
-
export const SI_KBYTE: "kB";
|
|
20
21
|
export const SPACE: " ";
|
|
21
|
-
export const STRING: "string";
|
|
22
22
|
export const ZERO: "0";
|
|
23
23
|
export namespace STRINGS {
|
|
24
24
|
namespace symbol {
|
|
@@ -1,47 +1,88 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Converts a file size in bytes to a human-readable string with appropriate units
|
|
3
|
+
* @param {number|string|bigint} arg - The file size in bytes to convert
|
|
4
|
+
* @param {Object} [options={}] - Configuration options for formatting
|
|
5
|
+
* @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes
|
|
6
|
+
* @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter
|
|
7
|
+
* @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)
|
|
8
|
+
* @param {number} [options.round=2] - Number of decimal places to round to
|
|
9
|
+
* @param {string|boolean} [options.locale=""] - Locale for number formatting, true for system locale
|
|
10
|
+
* @param {Object} [options.localeOptions={}] - Additional options for locale formatting
|
|
11
|
+
* @param {string} [options.separator=""] - Custom decimal separator
|
|
12
|
+
* @param {string} [options.spacer=" "] - String to separate value and unit
|
|
13
|
+
* @param {Object} [options.symbols={}] - Custom unit symbols
|
|
14
|
+
* @param {string} [options.standard=""] - Unit standard to use (SI, IEC, JEDEC)
|
|
15
|
+
* @param {string} [options.output="string"] - Output format: "string", "array", "object", or "exponent"
|
|
16
|
+
* @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations
|
|
17
|
+
* @param {Array} [options.fullforms=[]] - Custom full unit names
|
|
18
|
+
* @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)
|
|
19
|
+
* @param {string} [options.roundingMethod="round"] - Math rounding method to use
|
|
20
|
+
* @param {number} [options.precision=0] - Number of significant digits (0 for auto)
|
|
21
|
+
* @returns {string|Array|Object|number} Formatted file size based on output option
|
|
22
|
+
* @throws {TypeError} When arg is not a valid number or roundingMethod is invalid
|
|
23
|
+
* @example
|
|
24
|
+
* filesize(1024) // "1 KB"
|
|
25
|
+
* filesize(1024, {bits: true}) // "8 Kb"
|
|
26
|
+
* filesize(1024, {output: "object"}) // {value: 1, symbol: "KB", exponent: 1, unit: "KB"}
|
|
27
|
+
*/
|
|
28
|
+
export function filesize(arg: number | string | bigint, { bits, pad, base, round, locale, localeOptions, separator, spacer, symbols, standard, output, fullform, fullforms, exponent, roundingMethod, precision, }?: {
|
|
2
29
|
bits?: boolean | undefined;
|
|
3
30
|
pad?: boolean | undefined;
|
|
4
31
|
base?: number | undefined;
|
|
5
32
|
round?: number | undefined;
|
|
6
|
-
locale?: string | undefined;
|
|
7
|
-
localeOptions?:
|
|
33
|
+
locale?: string | boolean | undefined;
|
|
34
|
+
localeOptions?: Object | undefined;
|
|
8
35
|
separator?: string | undefined;
|
|
9
36
|
spacer?: string | undefined;
|
|
10
|
-
symbols?:
|
|
37
|
+
symbols?: Object | undefined;
|
|
11
38
|
standard?: string | undefined;
|
|
12
39
|
output?: string | undefined;
|
|
13
40
|
fullform?: boolean | undefined;
|
|
14
|
-
fullforms?:
|
|
41
|
+
fullforms?: any[] | undefined;
|
|
15
42
|
exponent?: number | undefined;
|
|
16
43
|
roundingMethod?: string | undefined;
|
|
17
44
|
precision?: number | undefined;
|
|
18
|
-
}): string |
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
45
|
+
}): string | any[] | Object | number;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a partially applied version of filesize with preset options
|
|
48
|
+
* @param {Object} [options={}] - Default options to apply to the returned function
|
|
49
|
+
* @param {boolean} [options.bits=false] - If true, calculates bits instead of bytes
|
|
50
|
+
* @param {boolean} [options.pad=false] - If true, pads decimal places to match round parameter
|
|
51
|
+
* @param {number} [options.base=-1] - Number base (2 for binary, 10 for decimal, -1 for auto)
|
|
52
|
+
* @param {number} [options.round=2] - Number of decimal places to round to
|
|
53
|
+
* @param {string|boolean} [options.locale=""] - Locale for number formatting, true for system locale
|
|
54
|
+
* @param {Object} [options.localeOptions={}] - Additional options for locale formatting
|
|
55
|
+
* @param {string} [options.separator=""] - Custom decimal separator
|
|
56
|
+
* @param {string} [options.spacer=" "] - String to separate value and unit
|
|
57
|
+
* @param {Object} [options.symbols={}] - Custom unit symbols
|
|
58
|
+
* @param {string} [options.standard=""] - Unit standard to use (SI, IEC, JEDEC)
|
|
59
|
+
* @param {string} [options.output="string"] - Output format: "string", "array", "object", or "exponent"
|
|
60
|
+
* @param {boolean} [options.fullform=false] - If true, uses full unit names instead of abbreviations
|
|
61
|
+
* @param {Array} [options.fullforms=[]] - Custom full unit names
|
|
62
|
+
* @param {number} [options.exponent=-1] - Force specific exponent (-1 for auto)
|
|
63
|
+
* @param {string} [options.roundingMethod="round"] - Math rounding method to use
|
|
64
|
+
* @param {number} [options.precision=0] - Number of significant digits (0 for auto)
|
|
65
|
+
* @returns {Function} A function that takes a file size and returns formatted output
|
|
66
|
+
* @example
|
|
67
|
+
* const formatBytes = partial({round: 1, standard: "IEC"});
|
|
68
|
+
* formatBytes(1024) // "1.0 KiB"
|
|
69
|
+
* formatBytes(2048) // "2.0 KiB"
|
|
70
|
+
*/
|
|
24
71
|
export function partial({ bits, pad, base, round, locale, localeOptions, separator, spacer, symbols, standard, output, fullform, fullforms, exponent, roundingMethod, precision, }?: {
|
|
25
72
|
bits?: boolean | undefined;
|
|
26
73
|
pad?: boolean | undefined;
|
|
27
74
|
base?: number | undefined;
|
|
28
75
|
round?: number | undefined;
|
|
29
|
-
locale?: string | undefined;
|
|
30
|
-
localeOptions?:
|
|
76
|
+
locale?: string | boolean | undefined;
|
|
77
|
+
localeOptions?: Object | undefined;
|
|
31
78
|
separator?: string | undefined;
|
|
32
79
|
spacer?: string | undefined;
|
|
33
|
-
symbols?:
|
|
80
|
+
symbols?: Object | undefined;
|
|
34
81
|
standard?: string | undefined;
|
|
35
82
|
output?: string | undefined;
|
|
36
83
|
fullform?: boolean | undefined;
|
|
37
|
-
fullforms?:
|
|
84
|
+
fullforms?: any[] | undefined;
|
|
38
85
|
exponent?: number | undefined;
|
|
39
86
|
roundingMethod?: string | undefined;
|
|
40
87
|
precision?: number | undefined;
|
|
41
|
-
}):
|
|
42
|
-
value: any;
|
|
43
|
-
symbol: any;
|
|
44
|
-
exponent: number;
|
|
45
|
-
unit: string;
|
|
46
|
-
};
|
|
47
|
-
export default filesize;
|
|
88
|
+
}): Function;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
1
|
+
export namespace cache {
|
|
2
|
+
export let image: Map<any, any>;
|
|
3
|
+
export let background: Map<any, any>;
|
|
4
|
+
export let resource: Map<any, any>;
|
|
5
|
+
export let defaultStyle: Map<any, any>;
|
|
6
|
+
export let baseStyle: Map<any, any>;
|
|
7
|
+
export let computedStyle: WeakMap<WeakKey, any>;
|
|
8
|
+
export let font: Set<any>;
|
|
9
|
+
export let snapshot: WeakMap<WeakKey, any>;
|
|
10
|
+
export let snapshotKey: Map<any, any>;
|
|
11
|
+
export let preStyleMap: Map<any, any>;
|
|
12
|
+
export let preStyle: WeakMap<WeakKey, any>;
|
|
13
|
+
export let preNodeMap: Map<any, any>;
|
|
14
|
+
export { resetCache as reset };
|
|
15
|
+
}
|
|
16
|
+
declare function resetCache(): void;
|
|
17
|
+
export {};
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* @param {boolean} [options.embedFonts=false] - Whether to embed custom fonts
|
|
8
8
|
* @param {boolean} [options.fast=true] - Whether to skip idle delay for faster results
|
|
9
9
|
* @param {number} [options.scale=1] - Output scale multiplier
|
|
10
|
+
* @param {string[]} [options.exclude] - CSS selectors for elements to exclude
|
|
11
|
+
* @param {Function} [options.filter] - Custom filter function
|
|
10
12
|
* @returns {Promise<string>} Promise that resolves to an SVG data URL
|
|
11
13
|
*/
|
|
12
14
|
export function captureDOM(element: Element, options?: {
|
|
@@ -14,4 +16,6 @@ export function captureDOM(element: Element, options?: {
|
|
|
14
16
|
embedFonts?: boolean | undefined;
|
|
15
17
|
fast?: boolean | undefined;
|
|
16
18
|
scale?: number | undefined;
|
|
19
|
+
exclude?: string[] | undefined;
|
|
20
|
+
filter?: Function | undefined;
|
|
17
21
|
}): Promise<string>;
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
* Creates a deep clone of a DOM node, including styles, shadow DOM, and special handling for excluded/placeholder/canvas nodes.
|
|
3
3
|
*
|
|
4
4
|
* @param {Node} node - Node to clone
|
|
5
|
-
* @param {Map} styleMap - Map to store element-to-style-key mappings
|
|
6
|
-
* @param {WeakMap} styleCache - Cache of computed styles
|
|
7
|
-
* @param {WeakMap} nodeMap - Map to track original-to-clone node relationships
|
|
8
5
|
* @param {boolean} compress - Whether to compress style keys
|
|
9
|
-
* @
|
|
6
|
+
* @param {Object} [options={}] - Capture options including exclude and filter
|
|
7
|
+
* @param {Node} [originalRoot] - Original root element being captured
|
|
8
|
+
* @returns {Node|null} Cloned node with styles and shadow DOM content, or null for empty text nodes or filtered elements
|
|
10
9
|
*/
|
|
11
|
-
export function deepClone(node: Node,
|
|
10
|
+
export function deepClone(node: Node, compress: boolean, options?: Object, originalRoot?: Node): Node | null;
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {Element} element - Element to clone
|
|
5
5
|
* @param {boolean} [compress=false] - Whether to compress style keys
|
|
6
|
+
* @param {boolean} [embedFonts=false] - Whether to embed custom fonts
|
|
7
|
+
* @param {Object} [options={}] - Capture options
|
|
8
|
+
* @param {string[]} [options.exclude] - CSS selectors for elements to exclude
|
|
9
|
+
* @param {Function} [options.filter] - Custom filter function
|
|
6
10
|
* @returns {Promise<Object>} Object containing the clone, generated CSS, and style cache
|
|
7
11
|
*/
|
|
8
|
-
export function prepareClone(element: Element, compress?: boolean, embedFonts?: boolean,
|
|
12
|
+
export function prepareClone(element: Element, compress?: boolean, embedFonts?: boolean, options?: {
|
|
13
|
+
exclude?: string[] | undefined;
|
|
14
|
+
filter?: Function | undefined;
|
|
15
|
+
}): Promise<Object>;
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {Element} source - Original element
|
|
5
5
|
* @param {Element} clone - Cloned element
|
|
6
|
-
* @param {WeakMap} styleCache - Cache of computed styles
|
|
7
6
|
* @param {Object} [options={}] - Options for image processing
|
|
8
7
|
* @returns {Promise<void>} Promise that resolves when all background images are processed
|
|
9
8
|
*/
|
|
10
|
-
export function inlineBackgroundImages(source: Element, clone: Element,
|
|
9
|
+
export function inlineBackgroundImages(source: Element, clone: Element, options?: Object): Promise<void>;
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {Element} source - Original element
|
|
5
5
|
* @param {Element} clone - Cloned element
|
|
6
|
-
* @param {Map} styleMap - Map to store element-to-style-key mappings
|
|
7
|
-
* @param {WeakMap} styleCache - Cache of computed styles
|
|
8
6
|
* @param {boolean} compress - Whether to compress style keys
|
|
9
7
|
* @param {boolean} embedFonts - Whether to embed icon fonts as images
|
|
10
8
|
* @returns {Promise} Promise that resolves when all pseudo-elements are processed
|
|
11
9
|
*/
|
|
12
|
-
export function inlinePseudoElements(source: Element, clone: Element,
|
|
10
|
+
export function inlinePseudoElements(source: Element, clone: Element, compress: boolean, embedFonts: boolean | undefined, useProxy: any): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function inlineAllStyles(source: any, clone: any,
|
|
1
|
+
export function inlineAllStyles(source: any, clone: any, compress: any): void;
|
|
@@ -32,7 +32,6 @@ export function generateDedupedBaseCSS(usedTagNames: string[]): string;
|
|
|
32
32
|
/**
|
|
33
33
|
* Generates CSS classes from a style map.
|
|
34
34
|
*
|
|
35
|
-
* @param {Map} styleMap - Map of elements to style keys
|
|
36
35
|
* @returns {Map} Map of style keys to class names
|
|
37
36
|
*/
|
|
38
|
-
export function generateCSSClasses(
|
|
37
|
+
export function generateCSSClasses(): Map<any, any>;
|
package/types/tree/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export function getLabelFromDictionaryByValue(a: any, value: any, 保底?: boole
|
|
|
6
6
|
export function getChildWithParentBy(root: any, key: any, value: any, childrenKey?: string): null | undefined;
|
|
7
7
|
export function getItemBy2(root: any, key: any, value: any, childrenKey?: string): any;
|
|
8
8
|
export default getItemBy;
|
|
9
|
-
export { default as searchTree } from "./
|
|
9
|
+
export { default as searchTree } from "./search";
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 基础原始类型定义(string/number/boolean/symbol/null/undefined)
|
|
3
|
+
*/
|
|
4
|
+
type Primitive = string | number | boolean | symbol | null | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* 条件值类型,可以是:
|
|
7
|
+
* 1. 原始值(Primitive)
|
|
8
|
+
* 2. 判断函数(接收节点值返回boolean)
|
|
9
|
+
* 3. 正则表达式
|
|
10
|
+
* @template T 节点值的泛型类型
|
|
11
|
+
*/
|
|
12
|
+
type ConditionValue<T = unknown> = Primitive | ((value: T) => boolean) | RegExp;
|
|
13
|
+
/**
|
|
14
|
+
* 树搜索配置选项接口
|
|
15
|
+
*/
|
|
16
|
+
interface SearchOptions {
|
|
17
|
+
/**
|
|
18
|
+
* 遍历策略:广度优先(BFS)或深度优先(DFS)
|
|
19
|
+
* @default 'BFS'
|
|
20
|
+
*/
|
|
21
|
+
strategy?: 'BFS' | 'DFS';
|
|
22
|
+
/**
|
|
23
|
+
* 子节点字段名
|
|
24
|
+
* @default 'children'
|
|
25
|
+
*/
|
|
26
|
+
childrenKey?: string;
|
|
27
|
+
/**
|
|
28
|
+
* 是否启用严格模式比较(===)
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
strict?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* 是否启用字符串模糊匹配
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
fuzzyMatch?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 是否返回所有匹配结果(否则返回第一个匹配)
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
returnAllMatches?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* 字符串匹配是否区分大小写
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
caseSensitive?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 多条件匹配模式:AND(所有条件需满足)或OR(任一条件满足)
|
|
49
|
+
* @default 'AND'
|
|
50
|
+
*/
|
|
51
|
+
matchMode?: 'AND' | 'OR';
|
|
52
|
+
/**
|
|
53
|
+
* 字符串匹配是否允许空字符
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
allowEmptyString?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 树节点接口定义
|
|
60
|
+
*/
|
|
61
|
+
interface TreeNode {
|
|
62
|
+
/**
|
|
63
|
+
* 动态属性(任意键值对)
|
|
64
|
+
*/
|
|
65
|
+
[key: string]: unknown;
|
|
66
|
+
/**
|
|
67
|
+
* 子节点数组(可选)
|
|
68
|
+
*/
|
|
69
|
+
children?: TreeNode[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 高级树搜索函数
|
|
73
|
+
* @param treeData 要搜索的树数据(必须是数组)
|
|
74
|
+
* @param searchCondition 搜索条件对象(键值对)
|
|
75
|
+
* @param options 搜索配置选项
|
|
76
|
+
* @returns 返回匹配的节点或节点数组(根据returnAllMatches决定)
|
|
77
|
+
* @throws 当参数不符合要求时抛出TypeError或Error
|
|
78
|
+
*/
|
|
79
|
+
declare function searchTree(treeData: TreeNode[], searchCondition: Record<string, ConditionValue>, options?: SearchOptions): TreeNode | TreeNode[] | null;
|
|
80
|
+
export default searchTree;
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
export namespace PRIMARY_COLOR_KEY_MAPPING {
|
|
2
|
+
namespace primary {
|
|
3
|
+
let label: string;
|
|
4
|
+
let key: string;
|
|
5
|
+
}
|
|
6
|
+
namespace success {
|
|
7
|
+
let label_1: string;
|
|
8
|
+
export { label_1 as label };
|
|
9
|
+
let key_1: string;
|
|
10
|
+
export { key_1 as key };
|
|
11
|
+
}
|
|
12
|
+
namespace warning {
|
|
13
|
+
let label_2: string;
|
|
14
|
+
export { label_2 as label };
|
|
15
|
+
let key_2: string;
|
|
16
|
+
export { key_2 as key };
|
|
17
|
+
}
|
|
18
|
+
namespace danger {
|
|
19
|
+
let label_3: string;
|
|
20
|
+
export { label_3 as label };
|
|
21
|
+
let key_3: string;
|
|
22
|
+
export { key_3 as key };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
1
25
|
export { default as compareColorByRange } from "./compareColorByRange";
|
|
2
26
|
export namespace blue {
|
|
3
27
|
namespace name {
|
|
@@ -59,11 +83,12 @@ export namespace gray {
|
|
|
59
83
|
export { value_3 as value };
|
|
60
84
|
}
|
|
61
85
|
export namespace grayPresets {
|
|
62
|
-
|
|
86
|
+
let key_4: string;
|
|
87
|
+
export { key_4 as key };
|
|
63
88
|
import name_4 = gray.name;
|
|
64
89
|
export { name_4 as name };
|
|
65
|
-
import
|
|
66
|
-
export { primary };
|
|
90
|
+
import primary_1 = gray.value;
|
|
91
|
+
export { primary_1 as primary };
|
|
67
92
|
export let light: TinyColor[];
|
|
68
93
|
export let dark: TinyColor[];
|
|
69
94
|
}
|