@qy_better_lib/core 0.1.2 → 0.1.4
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/DOCUMENTATION.md +2945 -0
- package/dist/@qy_better_lib/core.min.js +1 -1
- package/lib/directives/{click-outside.d.ts → click_outside.d.ts} +3 -0
- package/lib/directives/click_outside.js +92 -0
- package/lib/directives/index.d.ts +7 -1
- package/lib/directives/index.js +8 -0
- package/lib/index.js +209 -55
- package/lib/types/auto-imports.d.ts +76 -0
- package/lib/types/components.d.ts +13 -0
- package/lib/utils/color.d.ts +68 -5
- package/lib/utils/color.js +77 -10
- package/lib/utils/date.d.ts +71 -7
- package/lib/utils/date.js +102 -0
- package/lib/utils/dom.d.ts +176 -5
- package/lib/utils/dom.js +196 -12
- package/lib/utils/echarts.d.ts +132 -4
- package/lib/utils/echarts.js +209 -12
- package/lib/utils/file.d.ts +79 -3
- package/lib/utils/file.js +137 -14
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/is.d.ts +109 -19
- package/lib/utils/is.js +115 -32
- package/lib/utils/number.d.ts +76 -6
- package/lib/utils/number.js +94 -10
- package/lib/utils/object.d.ts +76 -6
- package/lib/utils/object.js +238 -64
- package/lib/utils/random.d.ts +87 -8
- package/lib/utils/random.js +101 -11
- package/lib/utils/share.d.ts +75 -10
- package/lib/utils/share.js +158 -13
- package/lib/utils/storage.d.ts +103 -14
- package/lib/utils/storage.js +169 -31
- package/lib/utils/tree.d.ts +176 -4
- package/lib/utils/tree.js +450 -10
- package/package.json +10 -3
- package/types/index.d.ts +39 -1
- package/vitest.config.ts +15 -0
- package/lib/directives/click-outside.js +0 -39
package/types/index.d.ts
CHANGED
|
@@ -1 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
// 工具函数类型定义
|
|
2
|
+
declare type Fn = (...args: any[]) => any;
|
|
3
|
+
|
|
4
|
+
// 防抖函数类型
|
|
5
|
+
declare function debounce(fn: Fn, delay?: number): (...args: any[]) => void;
|
|
6
|
+
|
|
7
|
+
// 节流函数类型
|
|
8
|
+
declare function throttle(fn: Fn, interval?: number): (...args: any[]) => void;
|
|
9
|
+
|
|
10
|
+
// Echarts相关函数类型
|
|
11
|
+
declare function auto_size(size: number, defalteWidth?: number): number;
|
|
12
|
+
declare function get_chart_gradient_color(type: 'v' | 'h', start_color: string, end_color: string): {
|
|
13
|
+
type: string;
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
x2: number;
|
|
17
|
+
y2: number;
|
|
18
|
+
colorStops: Array<{
|
|
19
|
+
offset: number;
|
|
20
|
+
color: string;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// 指令类型定义
|
|
25
|
+
declare const ClickOutside: any;
|
|
26
|
+
|
|
27
|
+
// 模块导出声明
|
|
28
|
+
declare module '@qy_better_lib/core' {
|
|
29
|
+
export * from '@qy_better_lib/core/lib/utils';
|
|
30
|
+
export * from '@qy_better_lib/core/lib/directives';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare module '@qy_better_lib/core/utils' {
|
|
34
|
+
export * from '@qy_better_lib/core/lib/utils';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare module '@qy_better_lib/core/directives' {
|
|
38
|
+
export * from '@qy_better_lib/core/lib/directives';
|
|
39
|
+
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
globals: true,
|
|
6
|
+
environment: 'happy-dom',
|
|
7
|
+
include: ['src/**/__tests__/*.test.ts'],
|
|
8
|
+
exclude: ['node_modules'],
|
|
9
|
+
coverage: {
|
|
10
|
+
reporter: ['text', 'json', 'html'],
|
|
11
|
+
include: ['src/**/*.ts'],
|
|
12
|
+
exclude: ['src/**/__tests__/*', 'node_modules']
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { isClient as x, isElement as E } from "../utils/is.js";
|
|
2
|
-
const s = /* @__PURE__ */ new Map();
|
|
3
|
-
let d;
|
|
4
|
-
x && (document.addEventListener("mousedown", (e) => d = e), document.addEventListener("mouseup", (e) => {
|
|
5
|
-
for (const t of s.values())
|
|
6
|
-
for (const { documentHandler: n } of t)
|
|
7
|
-
n(e, d);
|
|
8
|
-
}));
|
|
9
|
-
function i(e, t) {
|
|
10
|
-
let n = [];
|
|
11
|
-
return Array.isArray(t.arg) ? n = t.arg : E(t.arg) && n.push(t.arg), function(o, a) {
|
|
12
|
-
const r = t.instance.popperRef, c = o.target, u = a?.target, l = !t || !t.instance, f = !c || !u, p = e.contains(c) || e.contains(u), m = e === c, h = n.length && n.some((v) => v?.contains(c)) || n.length && n.includes(u), g = r && (r.contains(c) || r.contains(u));
|
|
13
|
-
l || f || p || m || h || g || t.value(o, a);
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
const C = {
|
|
17
|
-
beforeMount(e, t) {
|
|
18
|
-
s.has(e) || s.set(e, []), s.get(e)?.push({
|
|
19
|
-
documentHandler: i(e, t),
|
|
20
|
-
bindingFn: t.value
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
updated(e, t) {
|
|
24
|
-
s.has(e) || s.set(e, []);
|
|
25
|
-
const n = s.get(e), o = n?.findIndex(
|
|
26
|
-
(r) => r.bindingFn === t.oldValue
|
|
27
|
-
), a = {
|
|
28
|
-
documentHandler: i(e, t),
|
|
29
|
-
bindingFn: t.value
|
|
30
|
-
};
|
|
31
|
-
o && o >= 0 ? n?.splice(o, 1, a) : n?.push(a);
|
|
32
|
-
},
|
|
33
|
-
unmounted(e) {
|
|
34
|
-
s.delete(e);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export {
|
|
38
|
-
C as default
|
|
39
|
-
};
|