mochi-island-ui 1.1.0 → 1.2.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/components/select/MochiSelect.module.js +1 -1
- package/dist/components/select/MochiSelect.vue.d.ts +9 -1
- package/dist/components/select/MochiSelect.vue_vue_type_script_setup_true_lang.js +102 -94
- package/dist/components/table/MochiTable.module.js +1 -1
- package/dist/components/table/MochiTable.vue.d.ts +15 -0
- package/dist/components/table/MochiTable.vue_vue_type_script_setup_true_lang.js +76 -51
- package/dist/components/tree/MochiTree.module.js +1 -1
- package/dist/components/tree/MochiTree.vue.d.ts +7 -0
- package/dist/components/tree/MochiTree.vue_vue_type_script_setup_true_lang.js +35 -25
- package/dist/components/tree/MochiTreeRow.vue.d.ts +2 -0
- package/dist/components/tree/MochiTreeRow.vue_vue_type_script_setup_true_lang.js +43 -37
- package/dist/style.css +1 -1
- package/dist/styles/virtual.d.ts +21 -0
- package/dist/styles/virtual.js +8 -0
- package/dist/styles/virtual.module.js +3 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/select/MochiSelect.module.css
|
|
2
|
-
var e = "
|
|
2
|
+
var e = "_root_19v55_2", t = "_trigger_19v55_6", n = "_value_19v55_31", r = "_chevron_19v55_42", i = "_list_19v55_64", a = "_listUp_19v55_88", o = "_indicator_19v55_95", s = "_option_19v55_114", c = "_popEnter_19v55_135", l = "_popIn_19v55_1", u = "_popLeave_19v55_139", d = "_popOut_19v55_1", f = {
|
|
3
3
|
root: e,
|
|
4
4
|
trigger: t,
|
|
5
5
|
value: n,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MochiSelectOption } from './types';
|
|
2
|
+
import { MochiVirtualSetting } from '../../styles/virtual';
|
|
2
3
|
type __VLS_Props = {
|
|
3
4
|
options: MochiSelectOption[];
|
|
4
5
|
label?: string;
|
|
@@ -7,6 +8,11 @@ type __VLS_Props = {
|
|
|
7
8
|
placeholder?: string;
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
invalid?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* CSS 虚拟化三态:true 强制开(弹层里屏外选项跳过布局/绘制,DOM 保留);
|
|
13
|
+
* false 强制关;'auto'(默认)按硬件自适应——低端设备自动开。
|
|
14
|
+
*/
|
|
15
|
+
virtual?: MochiVirtualSetting;
|
|
10
16
|
};
|
|
11
17
|
type __VLS_ModelProps = {
|
|
12
18
|
modelValue?: string;
|
|
@@ -16,6 +22,8 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {},
|
|
|
16
22
|
"update:modelValue": (value: string) => any;
|
|
17
23
|
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
18
24
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
19
|
-
}>, {
|
|
25
|
+
}>, {
|
|
26
|
+
virtual: MochiVirtualSetting;
|
|
27
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
20
28
|
declare const _default: typeof __VLS_export;
|
|
21
29
|
export default _default;
|
|
@@ -1,75 +1,82 @@
|
|
|
1
1
|
import { useMessages as e } from "../../locale.js";
|
|
2
2
|
import t from "../../internal/FieldShell.js";
|
|
3
3
|
import n from "./MochiSelect.module.js";
|
|
4
|
-
import
|
|
4
|
+
import r from "../../styles/virtual.module.js";
|
|
5
|
+
import { shouldVirtualize as i } from "../../styles/virtual.js";
|
|
6
|
+
import { Fragment as a, Transition as o, computed as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createVNode as d, defineComponent as f, mergeModels as p, nextTick as m, normalizeClass as h, normalizeStyle as g, onBeforeUnmount as _, openBlock as v, ref as y, renderList as b, toDisplayString as x, unref as S, useId as C, useModel as ee, watch as w, withCtx as T } from "vue";
|
|
5
7
|
// src/components/select/MochiSelect.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
-
var
|
|
8
|
+
var E = [
|
|
7
9
|
"id",
|
|
8
10
|
"aria-expanded",
|
|
9
11
|
"aria-controls",
|
|
10
12
|
"aria-invalid",
|
|
11
13
|
"aria-describedby",
|
|
12
14
|
"disabled"
|
|
13
|
-
],
|
|
15
|
+
], D = ["data-placeholder"], O = ["data-open"], k = ["id"], A = ["data-ready"], j = [
|
|
16
|
+
"data-virtual",
|
|
14
17
|
"aria-selected",
|
|
15
18
|
"aria-disabled",
|
|
16
19
|
"data-active",
|
|
17
20
|
"data-selected",
|
|
18
21
|
"onClick",
|
|
19
22
|
"onMouseenter"
|
|
20
|
-
],
|
|
23
|
+
], M = /*@__PURE__*/ f({
|
|
21
24
|
name: "MochiSelect",
|
|
22
25
|
__name: "MochiSelect",
|
|
23
|
-
props: /*@__PURE__*/
|
|
26
|
+
props: /*@__PURE__*/ p({
|
|
24
27
|
options: {},
|
|
25
28
|
label: {},
|
|
26
29
|
hint: {},
|
|
27
30
|
placeholder: {},
|
|
28
31
|
disabled: { type: Boolean },
|
|
29
|
-
invalid: { type: Boolean }
|
|
32
|
+
invalid: { type: Boolean },
|
|
33
|
+
virtual: {
|
|
34
|
+
type: [Boolean, String],
|
|
35
|
+
default: "auto"
|
|
36
|
+
}
|
|
30
37
|
}, {
|
|
31
38
|
modelValue: { default: "" },
|
|
32
39
|
modelModifiers: {}
|
|
33
40
|
}),
|
|
34
41
|
emits: ["update:modelValue"],
|
|
35
|
-
setup(
|
|
36
|
-
let
|
|
42
|
+
setup(f) {
|
|
43
|
+
let p = e(), M = f, N = ee(f, "modelValue"), P = C(), F = s(() => `${P}-hint`), I = s(() => `${P}-list`), L = y(!1), R = y(!1), z = y(-1), B = y(), V = y(), H = y(), U = y({
|
|
37
44
|
top: 0,
|
|
38
45
|
height: 0
|
|
39
|
-
}),
|
|
40
|
-
function K() {
|
|
41
|
-
if (j.disabled) return;
|
|
42
|
-
I.value = !0;
|
|
43
|
-
let e = z.value?.getBoundingClientRect(), t = Math.min(240, j.options.length * 40 + 8);
|
|
44
|
-
L.value = e ? e.bottom + t + 8 > window.innerHeight : !1;
|
|
45
|
-
let n = j.options.findIndex((e) => e.value === M.value);
|
|
46
|
-
R.value = n >= 0 ? n : G.value[0] ?? -1;
|
|
47
|
-
}
|
|
48
|
-
function q(e = !1) {
|
|
49
|
-
I.value = !1, R.value = -1, e && z.value?.focus();
|
|
50
|
-
}
|
|
46
|
+
}), W = y(!1), G = s(() => M.options.find((e) => e.value === N.value)), K = s(() => M.options.map((e, t) => e.disabled ? -1 : t).filter((e) => e >= 0)), q = s(() => i(M.options.length, M.virtual));
|
|
51
47
|
function J() {
|
|
52
|
-
|
|
48
|
+
if (M.disabled) return;
|
|
49
|
+
L.value = !0;
|
|
50
|
+
let e = B.value?.getBoundingClientRect(), t = Math.min(240, M.options.length * 40 + 8);
|
|
51
|
+
R.value = e ? e.bottom + t + 8 > window.innerHeight : !1;
|
|
52
|
+
let n = M.options.findIndex((e) => e.value === N.value);
|
|
53
|
+
z.value = n >= 0 ? n : K.value[0] ?? -1;
|
|
53
54
|
}
|
|
54
|
-
function Y(e) {
|
|
55
|
-
|
|
55
|
+
function Y(e = !1) {
|
|
56
|
+
L.value = !1, z.value = -1, e && B.value?.focus();
|
|
57
|
+
}
|
|
58
|
+
function te() {
|
|
59
|
+
L.value ? Y() : J();
|
|
56
60
|
}
|
|
57
61
|
function X(e) {
|
|
58
|
-
|
|
62
|
+
e.disabled || (N.value = e.value, Y(!0));
|
|
63
|
+
}
|
|
64
|
+
function Z(e) {
|
|
65
|
+
let t = K.value;
|
|
59
66
|
if (!t.length) return;
|
|
60
|
-
let n = t[(t.indexOf(
|
|
61
|
-
n !== void 0 && (
|
|
67
|
+
let n = t[(t.indexOf(z.value) + e + t.length) % t.length];
|
|
68
|
+
n !== void 0 && (z.value = n);
|
|
62
69
|
}
|
|
63
|
-
function
|
|
64
|
-
let e =
|
|
65
|
-
e && (
|
|
70
|
+
function Q() {
|
|
71
|
+
let e = H.value?.querySelector("[data-active=\"true\"]");
|
|
72
|
+
e && (U.value = {
|
|
66
73
|
top: e.offsetTop,
|
|
67
74
|
height: e.offsetHeight
|
|
68
75
|
});
|
|
69
76
|
}
|
|
70
|
-
|
|
71
|
-
function
|
|
72
|
-
if (!
|
|
77
|
+
w(z, () => m(Q));
|
|
78
|
+
function ne(e) {
|
|
79
|
+
if (!M.disabled && [
|
|
73
80
|
"ArrowDown",
|
|
74
81
|
"ArrowUp",
|
|
75
82
|
"Home",
|
|
@@ -78,92 +85,93 @@ var T = [
|
|
|
78
85
|
" ",
|
|
79
86
|
"Escape"
|
|
80
87
|
].includes(e.key)) {
|
|
81
|
-
if (e.preventDefault(), !
|
|
82
|
-
else if (e.key === "ArrowDown")
|
|
83
|
-
else if (e.key === "ArrowUp")
|
|
84
|
-
else if (e.key === "Home")
|
|
85
|
-
else if (e.key === "End")
|
|
86
|
-
else if (e.key === "Escape")
|
|
88
|
+
if (e.preventDefault(), !L.value) e.key !== "Escape" && J();
|
|
89
|
+
else if (e.key === "ArrowDown") Z(1);
|
|
90
|
+
else if (e.key === "ArrowUp") Z(-1);
|
|
91
|
+
else if (e.key === "Home") z.value = K.value[0] ?? -1;
|
|
92
|
+
else if (e.key === "End") z.value = K.value.at(-1) ?? -1;
|
|
93
|
+
else if (e.key === "Escape") Y(!0);
|
|
87
94
|
else {
|
|
88
|
-
let e =
|
|
89
|
-
e &&
|
|
95
|
+
let e = M.options[z.value];
|
|
96
|
+
e && X(e);
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
99
|
}
|
|
93
|
-
|
|
94
|
-
e ? (await
|
|
95
|
-
|
|
96
|
-
}), (
|
|
100
|
+
w(L, async (e) => {
|
|
101
|
+
e ? (await m(), Q(), requestAnimationFrame(() => {
|
|
102
|
+
W.value = !0;
|
|
103
|
+
}), (V.value?.querySelector("[data-active=\"true\"]"))?.scrollIntoView?.({ block: "nearest" })) : W.value = !1;
|
|
97
104
|
});
|
|
98
105
|
function $(e) {
|
|
99
|
-
|
|
106
|
+
L.value && V.value && !V.value.contains(e.target) && Y();
|
|
100
107
|
}
|
|
101
|
-
return
|
|
108
|
+
return w(L, (e) => {
|
|
102
109
|
e ? document.addEventListener("pointerdown", $) : document.removeEventListener("pointerdown", $);
|
|
103
|
-
}),
|
|
110
|
+
}), _(() => document.removeEventListener("pointerdown", $)), (e, i) => (v(), l("div", {
|
|
104
111
|
ref_key: "root",
|
|
105
|
-
ref:
|
|
106
|
-
class:
|
|
107
|
-
}, [
|
|
108
|
-
label:
|
|
109
|
-
hint:
|
|
110
|
-
"field-id":
|
|
111
|
-
"hint-id":
|
|
112
|
-
invalid:
|
|
112
|
+
ref: V,
|
|
113
|
+
class: h(S(n).root)
|
|
114
|
+
}, [d(t, {
|
|
115
|
+
label: f.label,
|
|
116
|
+
hint: f.hint,
|
|
117
|
+
"field-id": S(P),
|
|
118
|
+
"hint-id": F.value,
|
|
119
|
+
invalid: f.invalid
|
|
113
120
|
}, {
|
|
114
|
-
default:
|
|
115
|
-
id:
|
|
121
|
+
default: T(() => [u("button", {
|
|
122
|
+
id: S(P),
|
|
116
123
|
ref_key: "trigger",
|
|
117
|
-
ref:
|
|
118
|
-
class:
|
|
124
|
+
ref: B,
|
|
125
|
+
class: h(S(n).trigger),
|
|
119
126
|
type: "button",
|
|
120
127
|
role: "combobox",
|
|
121
128
|
"aria-haspopup": "listbox",
|
|
122
|
-
"aria-expanded":
|
|
123
|
-
"aria-controls":
|
|
124
|
-
"aria-invalid":
|
|
125
|
-
"aria-describedby":
|
|
126
|
-
disabled:
|
|
127
|
-
onClick:
|
|
128
|
-
onKeydown:
|
|
129
|
-
}, [
|
|
130
|
-
class:
|
|
131
|
-
"data-placeholder": !
|
|
132
|
-
},
|
|
133
|
-
class:
|
|
134
|
-
"data-open":
|
|
129
|
+
"aria-expanded": L.value,
|
|
130
|
+
"aria-controls": I.value,
|
|
131
|
+
"aria-invalid": f.invalid || void 0,
|
|
132
|
+
"aria-describedby": f.hint ? F.value : void 0,
|
|
133
|
+
disabled: f.disabled,
|
|
134
|
+
onClick: te,
|
|
135
|
+
onKeydown: ne
|
|
136
|
+
}, [u("span", {
|
|
137
|
+
class: h(S(n).value),
|
|
138
|
+
"data-placeholder": !G.value || void 0
|
|
139
|
+
}, x(G.value?.label ?? f.placeholder ?? S(p).selectPlaceholder), 11, D), (v(), l("svg", {
|
|
140
|
+
class: h(S(n).chevron),
|
|
141
|
+
"data-open": L.value,
|
|
135
142
|
viewBox: "0 0 12 12",
|
|
136
143
|
"aria-hidden": "true"
|
|
137
|
-
}, [...
|
|
138
|
-
"enter-active-class":
|
|
139
|
-
"leave-active-class":
|
|
144
|
+
}, [...i[0] ||= [u("path", { d: "M2 4.5 L6 8.5 L10 4.5" }, null, -1)]], 10, O))], 42, E), d(o, {
|
|
145
|
+
"enter-active-class": S(n).popEnter,
|
|
146
|
+
"leave-active-class": S(n).popLeave
|
|
140
147
|
}, {
|
|
141
|
-
default:
|
|
148
|
+
default: T(() => [L.value ? (v(), l("ul", {
|
|
142
149
|
key: 0,
|
|
143
|
-
id:
|
|
150
|
+
id: I.value,
|
|
144
151
|
ref_key: "listEl",
|
|
145
|
-
ref:
|
|
146
|
-
class:
|
|
152
|
+
ref: H,
|
|
153
|
+
class: h(S(n).list),
|
|
147
154
|
role: "listbox"
|
|
148
|
-
}, [
|
|
149
|
-
class:
|
|
150
|
-
"data-ready":
|
|
151
|
-
style:
|
|
152
|
-
transform: `translateY(${
|
|
153
|
-
height: `${
|
|
155
|
+
}, [u("span", {
|
|
156
|
+
class: h(S(n).indicator),
|
|
157
|
+
"data-ready": W.value || void 0,
|
|
158
|
+
style: g({
|
|
159
|
+
transform: `translateY(${U.value.top}px)`,
|
|
160
|
+
height: `${U.value.height}px`
|
|
154
161
|
}),
|
|
155
162
|
"aria-hidden": "true"
|
|
156
|
-
}, null, 14,
|
|
163
|
+
}, null, 14, A), (v(!0), l(a, null, b(f.options, (e, t) => (v(), l("li", {
|
|
157
164
|
key: e.value,
|
|
158
|
-
class:
|
|
165
|
+
class: h([S(n).option, q.value && S(r).row]),
|
|
159
166
|
role: "option",
|
|
160
|
-
"
|
|
167
|
+
"data-virtual": q.value || void 0,
|
|
168
|
+
"aria-selected": e.value === N.value,
|
|
161
169
|
"aria-disabled": e.disabled || void 0,
|
|
162
|
-
"data-active": t ===
|
|
163
|
-
"data-selected": e.value ===
|
|
164
|
-
onClick: (t) =>
|
|
165
|
-
onMouseenter: (n) => !e.disabled && (
|
|
166
|
-
},
|
|
170
|
+
"data-active": t === z.value || void 0,
|
|
171
|
+
"data-selected": e.value === N.value || void 0,
|
|
172
|
+
onClick: (t) => X(e),
|
|
173
|
+
onMouseenter: (n) => !e.disabled && (z.value = t)
|
|
174
|
+
}, x(e.label), 43, j))), 128))], 10, k)) : c("", !0)]),
|
|
167
175
|
_: 1
|
|
168
176
|
}, 8, ["enter-active-class", "leave-active-class"])]),
|
|
169
177
|
_: 1
|
|
@@ -176,4 +184,4 @@ var T = [
|
|
|
176
184
|
])], 2));
|
|
177
185
|
}
|
|
178
186
|
});
|
|
179
|
-
export {
|
|
187
|
+
export { M as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/table/MochiTable.module.css
|
|
2
|
-
var e = "
|
|
2
|
+
var e = "_wrap_1py51_7", t = "_root_1py51_14", n = "_th_1py51_25", r = "_sorter_1py51_37", i = "_arrow_1py51_60", a = "_tr_1py51_95", o = "_rowIn_1py51_1", s = "_rowMove_1py51_106", c = "_td_1py51_129", l = "_empty_1py51_140", u = {
|
|
3
3
|
wrap: e,
|
|
4
4
|
root: t,
|
|
5
5
|
th: n,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MochiTableColumn, MochiTableSort } from './types';
|
|
2
|
+
import { MochiVirtualSetting } from '../../styles/virtual';
|
|
2
3
|
type __VLS_Props = {
|
|
3
4
|
columns: MochiTableColumn[];
|
|
4
5
|
rows: Record<string, unknown>[];
|
|
@@ -6,6 +7,18 @@ type __VLS_Props = {
|
|
|
6
7
|
rowKey?: string;
|
|
7
8
|
striped?: boolean;
|
|
8
9
|
emptyText?: string;
|
|
10
|
+
/**
|
|
11
|
+
* CSS 虚拟化三态:true 强制开(屏外行跳过布局/绘制,DOM 保留);
|
|
12
|
+
* false 强制关;'auto'(默认)按硬件自适应——低端设备自动开。
|
|
13
|
+
*/
|
|
14
|
+
virtual?: MochiVirtualSetting;
|
|
15
|
+
/**
|
|
16
|
+
* 渐进分片渲染:行数超阈值时先渲染首块(200 行)尽快出屏,其余行在
|
|
17
|
+
* idle 期补齐,DOM 最终全量保留(可 Ctrl+F)。补块大小按上一块的实际
|
|
18
|
+
* patch 耗时 AIMD 调节(预算内翻倍、超时减半),慢硬件自动缩小、快硬件
|
|
19
|
+
* 自动放大。排序/换数据会重置分片。
|
|
20
|
+
*/
|
|
21
|
+
progressive?: boolean;
|
|
9
22
|
};
|
|
10
23
|
declare var __VLS_11: `cell-${string}`, __VLS_12: {
|
|
11
24
|
row: Record<string, unknown>;
|
|
@@ -22,7 +35,9 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {},
|
|
|
22
35
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
23
36
|
"onSort-change"?: ((args_0: MochiTableSort | null) => any) | undefined;
|
|
24
37
|
}>, {
|
|
38
|
+
virtual: MochiVirtualSetting;
|
|
25
39
|
rowKey: string;
|
|
40
|
+
progressive: boolean;
|
|
26
41
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
27
42
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
28
43
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useMessages as e } from "../../locale.js";
|
|
2
|
-
import t from "
|
|
3
|
-
import {
|
|
2
|
+
import t from "../../styles/virtual.module.js";
|
|
3
|
+
import { shouldVirtualize as n } from "../../styles/virtual.js";
|
|
4
|
+
import r from "./MochiTable.module.js";
|
|
5
|
+
import { Fragment as i, TransitionGroup as a, computed as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, defineComponent as f, nextTick as p, normalizeClass as m, normalizeStyle as h, onBeforeUnmount as g, openBlock as _, ref as v, renderList as y, renderSlot as b, toDisplayString as x, unref as S, watch as C, withCtx as w } from "vue";
|
|
4
6
|
// src/components/table/MochiTable.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var
|
|
7
|
+
var T = ["data-striped"], E = ["aria-sort"], D = ["onClick"], O = ["data-order"], k = ["data-virtual"], A = { key: 0 }, j = ["colspan"], M = 200, N = 3200, P = 96, F = /*@__PURE__*/ f({
|
|
6
8
|
name: "MochiTable",
|
|
7
9
|
__name: "MochiTable",
|
|
8
10
|
props: {
|
|
@@ -10,80 +12,103 @@ var b = ["data-striped"], x = ["aria-sort"], S = ["onClick"], C = ["data-order"]
|
|
|
10
12
|
rows: {},
|
|
11
13
|
rowKey: { default: "id" },
|
|
12
14
|
striped: { type: Boolean },
|
|
13
|
-
emptyText: {}
|
|
15
|
+
emptyText: {},
|
|
16
|
+
virtual: {
|
|
17
|
+
type: [Boolean, String],
|
|
18
|
+
default: "auto"
|
|
19
|
+
},
|
|
20
|
+
progressive: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: !0
|
|
23
|
+
}
|
|
14
24
|
},
|
|
15
25
|
emits: ["sort-change"],
|
|
16
|
-
setup(
|
|
17
|
-
let
|
|
18
|
-
let e =
|
|
19
|
-
if (!e) return
|
|
26
|
+
setup(f, { emit: F }) {
|
|
27
|
+
let I = e(), L = f, R = F, z = v(null), B = o(() => {
|
|
28
|
+
let e = z.value;
|
|
29
|
+
if (!e) return L.rows;
|
|
20
30
|
let t = e.order === "asc" ? 1 : -1;
|
|
21
|
-
return [...
|
|
31
|
+
return [...L.rows].sort((n, r) => {
|
|
22
32
|
let i = n[e.key], a = r[e.key];
|
|
23
33
|
return i === a ? 0 : typeof i == "number" && typeof a == "number" ? (i - a) * t : String(i).localeCompare(String(a), "zh-CN") * t;
|
|
24
34
|
});
|
|
25
35
|
});
|
|
26
|
-
function
|
|
27
|
-
e.sortable && (
|
|
36
|
+
function V(e) {
|
|
37
|
+
e.sortable && (z.value?.key === e.key ? z.value.order === "asc" ? z.value = {
|
|
28
38
|
key: e.key,
|
|
29
39
|
order: "desc"
|
|
30
|
-
} :
|
|
40
|
+
} : z.value = null : z.value = {
|
|
31
41
|
key: e.key,
|
|
32
42
|
order: "asc"
|
|
33
|
-
},
|
|
43
|
+
}, R("sort-change", z.value));
|
|
44
|
+
}
|
|
45
|
+
function H(e) {
|
|
46
|
+
return z.value?.key === e.key ? z.value.order === "asc" ? "ascending" : "descending" : "none";
|
|
34
47
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
48
|
+
let U = o(() => n(B.value.length, L.virtual)), W = typeof requestIdleCallback == "function" ? (e) => requestIdleCallback(e, { timeout: 200 }) : (e) => window.setTimeout(e, 16), G = typeof cancelIdleCallback == "function" ? cancelIdleCallback : window.clearTimeout, K = o(() => n(B.value.length, L.progressive !== !1)), q = v(Infinity), J = o(() => B.value.slice(0, q.value)), Y = null, X = M, Z = !1;
|
|
49
|
+
function Q() {
|
|
50
|
+
Y = null;
|
|
51
|
+
let e = B.value.length, t = X;
|
|
52
|
+
q.value = Math.min(q.value + t, e);
|
|
53
|
+
let n = performance.now();
|
|
54
|
+
p(() => {
|
|
55
|
+
Z || (X = performance.now() - n <= P ? Math.min(t * 2, N) : Math.max(Math.round(t / 2), M), q.value < e && (Y = W(Q)));
|
|
56
|
+
});
|
|
37
57
|
}
|
|
38
|
-
return (
|
|
39
|
-
|
|
40
|
-
|
|
58
|
+
return C(B, (e) => {
|
|
59
|
+
Y !== null && G(Y), Y = null, X = M, K.value ? (q.value = Math.min(M, e.length), q.value < e.length && (Y = W(Q))) : q.value = Infinity;
|
|
60
|
+
}, { immediate: !0 }), g(() => {
|
|
61
|
+
Z = !0, Y !== null && G(Y);
|
|
62
|
+
}), (e, n) => (_(), c("div", { class: m(S(r).wrap) }, [l("table", {
|
|
63
|
+
class: m(S(r).root),
|
|
64
|
+
"data-striped": f.striped || void 0
|
|
41
65
|
}, [
|
|
42
|
-
|
|
66
|
+
l("thead", null, [l("tr", null, [(_(!0), c(i, null, y(f.columns, (e) => (_(), c("th", {
|
|
43
67
|
key: e.key,
|
|
44
|
-
class:
|
|
45
|
-
style:
|
|
68
|
+
class: m(S(r).th),
|
|
69
|
+
style: h({
|
|
46
70
|
width: e.width,
|
|
47
71
|
textAlign: e.align ?? "left"
|
|
48
72
|
}),
|
|
49
73
|
scope: "col",
|
|
50
|
-
"aria-sort": e.sortable ?
|
|
51
|
-
}, [e.sortable ? (
|
|
74
|
+
"aria-sort": e.sortable ? H(e) : void 0
|
|
75
|
+
}, [e.sortable ? (_(), c("button", {
|
|
52
76
|
key: 0,
|
|
53
|
-
class:
|
|
77
|
+
class: m(S(r).sorter),
|
|
54
78
|
type: "button",
|
|
55
|
-
onClick: (t) =>
|
|
56
|
-
}, [
|
|
57
|
-
class:
|
|
58
|
-
"data-order":
|
|
79
|
+
onClick: (t) => V(e)
|
|
80
|
+
}, [u(x(e.title) + " ", 1), (_(), c("svg", {
|
|
81
|
+
class: m(S(r).arrow),
|
|
82
|
+
"data-order": z.value?.key === e.key ? z.value.order : "none",
|
|
59
83
|
viewBox: "0 0 10 12",
|
|
60
84
|
"aria-hidden": "true"
|
|
61
|
-
}, [...
|
|
62
|
-
|
|
85
|
+
}, [...n[0] ||= [l("path", { d: "M5 1 L8.5 5 L1.5 5 Z" }, null, -1), l("path", { d: "M5 11 L1.5 7 L8.5 7 Z" }, null, -1)]], 10, O))], 10, D)) : (_(), c(i, { key: 1 }, [u(x(e.title), 1)], 64))], 14, E))), 128))])]),
|
|
86
|
+
d(a, {
|
|
63
87
|
tag: "tbody",
|
|
64
|
-
class:
|
|
65
|
-
"move-class":
|
|
88
|
+
class: m(S(r).tbody),
|
|
89
|
+
"move-class": S(r).rowMove
|
|
66
90
|
}, {
|
|
67
|
-
default:
|
|
68
|
-
key: String(
|
|
69
|
-
class:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
91
|
+
default: w(() => [(_(!0), c(i, null, y(J.value, (n, a) => (_(), c("tr", {
|
|
92
|
+
key: String(n[f.rowKey] ?? a),
|
|
93
|
+
class: m([S(r).tr, U.value && S(t).row]),
|
|
94
|
+
"data-virtual": U.value || void 0,
|
|
95
|
+
style: h({ "--_i": a })
|
|
96
|
+
}, [(_(!0), c(i, null, y(f.columns, (t) => (_(), c("td", {
|
|
97
|
+
key: t.key,
|
|
98
|
+
class: m(S(r).td),
|
|
99
|
+
style: h({ textAlign: t.align ?? "left" })
|
|
100
|
+
}, [b(e.$slots, `cell-${t.key}`, {
|
|
101
|
+
row: n,
|
|
102
|
+
value: n[t.key],
|
|
103
|
+
index: a
|
|
104
|
+
}, () => [u(x(n[t.key]), 1)])], 6))), 128))], 14, k))), 128))]),
|
|
80
105
|
_: 3
|
|
81
106
|
}, 8, ["class", "move-class"]),
|
|
82
|
-
|
|
83
|
-
class:
|
|
84
|
-
colspan:
|
|
85
|
-
}, [
|
|
86
|
-
], 10,
|
|
107
|
+
B.value.length ? s("", !0) : (_(), c("tbody", A, [l("tr", null, [l("td", {
|
|
108
|
+
class: m(S(r).empty),
|
|
109
|
+
colspan: f.columns.length
|
|
110
|
+
}, [b(e.$slots, "empty", {}, () => [u(x(f.emptyText ?? S(I).tableEmpty), 1)])], 10, j)])]))
|
|
111
|
+
], 10, T)], 2));
|
|
87
112
|
}
|
|
88
113
|
});
|
|
89
|
-
export {
|
|
114
|
+
export { F as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/tree/MochiTree.module.css
|
|
2
|
-
var e = "
|
|
2
|
+
var e = "_root_1d8sg_7", t = "_item_1d8sg_17", n = "_row_1d8sg_21", r = "_branch_1d8sg_58", i = "_label_1d8sg_89", a = "_group_1d8sg_96", o = "_children_1d8sg_106", s = {
|
|
3
3
|
root: e,
|
|
4
4
|
item: t,
|
|
5
5
|
row: n,
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { MochiTreeNode } from './types';
|
|
2
|
+
import { MochiVirtualSetting } from '../../styles/virtual';
|
|
2
3
|
type __VLS_Props = {
|
|
3
4
|
data: MochiTreeNode[];
|
|
4
5
|
defaultExpandAll?: boolean;
|
|
5
6
|
label?: string;
|
|
7
|
+
/**
|
|
8
|
+
* CSS 虚拟化三态:true 强制开(屏外行跳过布局/绘制,DOM 保留);
|
|
9
|
+
* false 强制关;'auto'(默认)按硬件自适应——低端设备自动开。
|
|
10
|
+
*/
|
|
11
|
+
virtual?: MochiVirtualSetting;
|
|
6
12
|
};
|
|
7
13
|
type __VLS_ModelProps = {
|
|
8
14
|
'selected'?: string;
|
|
@@ -13,6 +19,7 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {},
|
|
|
13
19
|
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
14
20
|
"onUpdate:selected"?: ((value: string) => any) | undefined;
|
|
15
21
|
}>, {
|
|
22
|
+
virtual: MochiVirtualSetting;
|
|
16
23
|
defaultExpandAll: boolean;
|
|
17
24
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
18
25
|
declare const _default: typeof __VLS_export;
|