@indielayer/ui 1.9.2 → 1.10.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/docs/components/menu/DocsMenu.vue +1 -0
- package/docs/pages/component/form/usage.vue +2 -0
- package/docs/pages/component/menu/usage.vue +2 -0
- package/docs/pages/component/select/index.vue +7 -0
- package/docs/pages/component/select/multiple.vue +42 -0
- package/docs/pages/component/select/usage.vue +8 -12
- package/docs/pages/component/table/virtual.vue +19 -6
- package/docs/pages/component/toggle/index.vue +1 -1
- package/docs/pages/component/tooltip/index.vue +1 -1
- package/docs/pages/component/upload/index.vue +29 -0
- package/docs/pages/component/upload/usage.vue +115 -0
- package/docs/search/components.json +1 -1
- package/lib/common/icons.d.ts +2 -0
- package/lib/common/icons.js +17 -15
- package/lib/components/checkbox/Checkbox.vue2.js +9 -9
- package/lib/components/datepicker/Datepicker.vue.d.ts +4 -4
- package/lib/components/datepicker/Datepicker.vue.js +1 -1
- package/lib/components/drawer/Drawer.vue.js +1 -17
- package/lib/components/form/Form.vue.d.ts +4 -4
- package/lib/components/form/Form.vue.js +34 -34
- package/lib/components/formGroup/FormGroup.vue.d.ts +1 -1
- package/lib/components/formGroup/FormGroup.vue.js +39 -37
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +68 -66
- package/lib/components/label/theme/Label.base.theme.js +7 -7
- package/lib/components/menu/Menu.vue.d.ts +2 -0
- package/lib/components/menu/MenuItem.vue.d.ts +15 -3
- package/lib/components/menu/MenuItem.vue.js +1 -1
- package/lib/components/menu/MenuItem.vue2.js +43 -37
- package/lib/components/modal/Modal.vue.d.ts +4 -4
- package/lib/components/modal/Modal.vue.js +38 -34
- package/lib/components/notifications/Notifications.vue.d.ts +15 -0
- package/lib/components/notifications/Notifications.vue.js +149 -127
- package/lib/components/progress/Progress.vue.d.ts +4 -4
- package/lib/components/progress/Progress.vue.js +7 -7
- package/lib/components/scroll/Scroll.vue2.js +1 -1
- package/lib/components/select/Select.vue.d.ts +43 -1
- package/lib/components/select/Select.vue.js +358 -258
- package/lib/components/select/theme/Select.base.theme.js +1 -0
- package/lib/components/tab/Tab.vue.js +1 -1
- package/lib/components/tab/TabGroup.vue.js +2 -2
- package/lib/components/table/Table.vue.d.ts +4 -4
- package/lib/components/table/Table.vue.js +37 -37
- package/lib/components/table/TableCell.vue.d.ts +1 -1
- package/lib/components/tag/Tag.vue.js +23 -21
- package/lib/components/textarea/Textarea.vue.js +1 -1
- package/lib/components/upload/Upload.vue.d.ts +195 -0
- package/lib/components/upload/Upload.vue.js +264 -0
- package/lib/components/upload/Upload.vue2.js +4 -0
- package/lib/components/upload/__tests__/Upload.spec.d.ts +1 -0
- package/lib/components/upload/index.d.ts +2 -0
- package/lib/components/upload/theme/Upload.base.theme.d.ts +3 -0
- package/lib/components/upload/theme/Upload.base.theme.js +8 -0
- package/lib/components/upload/theme/Upload.carbon.theme.d.ts +3 -0
- package/lib/components/upload/theme/Upload.carbon.theme.js +5 -0
- package/lib/composables/useVirtualList.js +56 -53
- package/lib/index.js +43 -41
- package/lib/index.umd.js +4 -4
- package/lib/node_modules/.pnpm/@vueuse_core@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js +501 -0
- package/lib/node_modules/.pnpm/@vueuse_shared@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/shared/index.js +96 -0
- package/lib/theme.d.ts +2 -1
- package/lib/themes/base/components.d.ts +1 -0
- package/lib/themes/base/components.js +23 -21
- package/lib/themes/carbon/components.d.ts +1 -0
- package/lib/themes/carbon/components.js +23 -21
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -3
- package/src/common/icons.ts +2 -0
- package/src/components/checkbox/Checkbox.vue +5 -5
- package/src/components/drawer/Drawer.vue +0 -16
- package/src/components/form/Form.vue +10 -4
- package/src/components/formGroup/FormGroup.vue +2 -0
- package/src/components/index.ts +1 -0
- package/src/components/label/theme/Label.base.theme.ts +7 -5
- package/src/components/menu/Menu.vue +2 -0
- package/src/components/menu/MenuItem.vue +8 -6
- package/src/components/modal/Modal.vue +6 -1
- package/src/components/notifications/Notifications.vue +34 -4
- package/src/components/progress/Progress.vue +2 -2
- package/src/components/select/Select.vue +165 -67
- package/src/components/select/theme/Select.base.theme.ts +2 -0
- package/src/components/table/Table.vue +2 -3
- package/src/components/tag/Tag.vue +11 -9
- package/src/components/upload/Upload.vue +365 -0
- package/src/components/upload/__tests__/Upload.spec.ts +11 -0
- package/src/components/upload/index.ts +2 -0
- package/src/components/upload/theme/Upload.base.theme.ts +9 -0
- package/src/components/upload/theme/Upload.carbon.theme.ts +7 -0
- package/src/composables/useInputtable.ts +1 -1
- package/src/composables/useVirtualList.ts +8 -5
- package/src/theme.ts +2 -0
- package/src/themes/base/components.ts +1 -0
- package/src/themes/carbon/components.ts +1 -0
- package/src/version.ts +1 -1
- package/volar.d.ts +1 -0
- package/lib/node_modules/.pnpm/@vueuse_core@10.2.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js +0 -412
- package/lib/node_modules/.pnpm/@vueuse_shared@10.2.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/shared/index.js +0 -90
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { defineComponent as te, ref as y, computed as oe, watch as ne, openBlock as d, createElementBlock as f, normalizeClass as b, unref as s, createVNode as x, normalizeStyle as se, withCtx as ie, createElementVNode as l, mergeProps as ae, toHandlers as le, renderSlot as k, toDisplayString as _, createBlock as g, createCommentVNode as w, Fragment as de, renderList as ce } from "vue";
|
|
2
|
+
import { useDropZone as ue } from "../../node_modules/.pnpm/@vueuse_core@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js";
|
|
3
|
+
import { useCommon as pe } from "../../composables/useCommon.js";
|
|
4
|
+
import { useInteractive as U } from "../../composables/useInteractive.js";
|
|
5
|
+
import { useInputtable as I } from "../../composables/useInputtable.js";
|
|
6
|
+
import { useTheme as me } from "../../composables/useTheme.js";
|
|
7
|
+
import { uploadIcon as fe, fileIcon as ge, closeIcon as he } from "../../common/icons.js";
|
|
8
|
+
import ve from "../label/Label.vue.js";
|
|
9
|
+
import O from "../inputFooter/InputFooter.vue.js";
|
|
10
|
+
import ye from "../progress/Progress.vue.js";
|
|
11
|
+
import S from "../icon/Icon.vue.js";
|
|
12
|
+
const be = ["id", "disabled", "name", "accept", "multiple", "readonly"], xe = { class: "text-secondary-500 dark:text-secondary-400" }, ke = { class: "flex items-center" }, _e = ["src"], we = { class: "truncate flex-1 pr-2" }, Se = { class: "font-medium truncate" }, Ie = { class: "text-xs text-secondary-500" }, $e = ["onClick"], Ve = {
|
|
13
|
+
...pe.validators(),
|
|
14
|
+
variant: ["box"]
|
|
15
|
+
}, Ce = {
|
|
16
|
+
...U.props(),
|
|
17
|
+
...I.props(),
|
|
18
|
+
placeholder: String,
|
|
19
|
+
accept: String,
|
|
20
|
+
multiple: Boolean,
|
|
21
|
+
maxFiles: [Number, String],
|
|
22
|
+
maxFileSize: [Number, String],
|
|
23
|
+
variant: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: "box"
|
|
26
|
+
},
|
|
27
|
+
// URL to submit data to.
|
|
28
|
+
action: String,
|
|
29
|
+
// Additional HTTP headers
|
|
30
|
+
headers: Object,
|
|
31
|
+
method: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "POST"
|
|
34
|
+
},
|
|
35
|
+
withCredentials: Boolean
|
|
36
|
+
}, Ee = {
|
|
37
|
+
name: "XUpload",
|
|
38
|
+
validators: Ve
|
|
39
|
+
}, Fe = /* @__PURE__ */ te({
|
|
40
|
+
...Ee,
|
|
41
|
+
props: Ce,
|
|
42
|
+
emits: [...I.emits(), "upload", "remove"],
|
|
43
|
+
setup(j, { expose: D, emit: q }) {
|
|
44
|
+
const o = j, u = q, $ = y(null), p = oe(() => !!o.action), i = y([]);
|
|
45
|
+
ne(i, (e) => {
|
|
46
|
+
u("update:modelValue", e);
|
|
47
|
+
}, { deep: !0, immediate: !0 });
|
|
48
|
+
const { focus: V, blur: P } = U($);
|
|
49
|
+
function h(e) {
|
|
50
|
+
if (!e)
|
|
51
|
+
return !1;
|
|
52
|
+
if (!o.multiple && e.length > 1 || o.maxFiles && e.length > Number(o.maxFiles))
|
|
53
|
+
return m.value = "Too many files", !1;
|
|
54
|
+
if (o.maxFileSize) {
|
|
55
|
+
for (let t = 0; t < e.length; t++)
|
|
56
|
+
if (e[t].size > Number(o.maxFileSize))
|
|
57
|
+
return m.value = "File size is too large", !1;
|
|
58
|
+
}
|
|
59
|
+
if (o.accept) {
|
|
60
|
+
const t = o.accept.split(",").map((r) => r.trim());
|
|
61
|
+
for (let r = 0; r < e.length; r++) {
|
|
62
|
+
const n = e[r];
|
|
63
|
+
if (!t.some((c) => n.type === c || n.name.endsWith(c)))
|
|
64
|
+
return m.value = "Invalid file type", !1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return !0;
|
|
68
|
+
}
|
|
69
|
+
function T(e) {
|
|
70
|
+
const r = e.target.files;
|
|
71
|
+
h(r) && u("change", e);
|
|
72
|
+
}
|
|
73
|
+
function F(e) {
|
|
74
|
+
const r = e.target.files;
|
|
75
|
+
h(r) && (N(r), o.validateOnInput && !K.value && v(i.value), u("input", e));
|
|
76
|
+
}
|
|
77
|
+
const C = y(null);
|
|
78
|
+
function M(e) {
|
|
79
|
+
h(e) && N(e);
|
|
80
|
+
}
|
|
81
|
+
const { isOverDropZone: E } = ue(C, {
|
|
82
|
+
onDrop: M,
|
|
83
|
+
multiple: o.multiple,
|
|
84
|
+
preventDefaultForUnhandled: !1
|
|
85
|
+
});
|
|
86
|
+
function N(e) {
|
|
87
|
+
i.value = e ? Array.from(e).map((t) => ({
|
|
88
|
+
file: t,
|
|
89
|
+
completed: !p.value,
|
|
90
|
+
progress: p.value ? 0 : 100,
|
|
91
|
+
error: ""
|
|
92
|
+
})) : [], p.value && W();
|
|
93
|
+
}
|
|
94
|
+
function Z(e) {
|
|
95
|
+
const t = i.value.findIndex((r) => r.file === e);
|
|
96
|
+
t !== -1 && (u("remove", i.value[t]), i.value.splice(t, 1));
|
|
97
|
+
}
|
|
98
|
+
function B(e) {
|
|
99
|
+
const t = ["jpg", "jpeg", "png", "gif", "webp", "svg"];
|
|
100
|
+
return e.type.startsWith("image") || t.some((r) => e.name.endsWith(r));
|
|
101
|
+
}
|
|
102
|
+
function z(e) {
|
|
103
|
+
return URL.createObjectURL(e);
|
|
104
|
+
}
|
|
105
|
+
function A(e) {
|
|
106
|
+
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(2)} KB` : e < 1024 * 1024 * 1024 ? `${(e / 1024 / 1024).toFixed(2)} MB` : `${(e / 1024 / 1024 / 1024).toFixed(2)} GB`;
|
|
107
|
+
}
|
|
108
|
+
async function H(e) {
|
|
109
|
+
return new Promise((t, r) => {
|
|
110
|
+
if (!o.action)
|
|
111
|
+
r(new Error("No action provided"));
|
|
112
|
+
else {
|
|
113
|
+
const n = new XMLHttpRequest(), c = new FormData();
|
|
114
|
+
c.append("file", e.file), n.open(o.method, o.action, !0), o.headers && typeof o.headers == "object" && Object.keys(o.headers).forEach((a) => {
|
|
115
|
+
n.setRequestHeader(a, o.headers[a]);
|
|
116
|
+
}), n.upload.addEventListener("progress", (a) => {
|
|
117
|
+
if (a.lengthComputable) {
|
|
118
|
+
const L = a.loaded / a.total * 100;
|
|
119
|
+
e.progress = L, console.log(`Upload progress: ${L}%`);
|
|
120
|
+
}
|
|
121
|
+
}), n.addEventListener("load", () => {
|
|
122
|
+
if (n.status === 200) {
|
|
123
|
+
e.completed = !0;
|
|
124
|
+
try {
|
|
125
|
+
e.response = JSON.parse(n.responseText);
|
|
126
|
+
} catch {
|
|
127
|
+
e.response = n.responseText;
|
|
128
|
+
}
|
|
129
|
+
t(n.responseText);
|
|
130
|
+
} else {
|
|
131
|
+
const a = `Upload failed. Status: ${n.status}`;
|
|
132
|
+
e.error = a, r(new Error(a));
|
|
133
|
+
}
|
|
134
|
+
}), n.addEventListener("error", () => {
|
|
135
|
+
e.error = "An error occurred during the upload.", r(new Error("An error occurred during the upload."));
|
|
136
|
+
}), n.send(c);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async function W() {
|
|
141
|
+
if (!o.action && !i.value)
|
|
142
|
+
return;
|
|
143
|
+
const e = [];
|
|
144
|
+
for (let t = 0; t < i.value.length; t++)
|
|
145
|
+
e.push(H(i.value[t]));
|
|
146
|
+
await Promise.all(e), v(i.value);
|
|
147
|
+
}
|
|
148
|
+
const {
|
|
149
|
+
errorInternal: m,
|
|
150
|
+
hideFooterInternal: X,
|
|
151
|
+
isInsideForm: G,
|
|
152
|
+
inputListeners: J,
|
|
153
|
+
isFirstValidation: K,
|
|
154
|
+
reset: Q,
|
|
155
|
+
validate: v,
|
|
156
|
+
setError: Y
|
|
157
|
+
} = I(o, { focus: V, emit: u }), { styles: ee, classes: R, className: re } = me("Upload", {}, o);
|
|
158
|
+
return D({ focus: V, blur: P, reset: Q, validate: v, setError: Y }), (e, t) => (d(), f("div", {
|
|
159
|
+
class: b([
|
|
160
|
+
s(re),
|
|
161
|
+
s(R).wrapper
|
|
162
|
+
])
|
|
163
|
+
}, [
|
|
164
|
+
x(ve, {
|
|
165
|
+
style: se(s(ee)),
|
|
166
|
+
disabled: e.disabled,
|
|
167
|
+
required: e.required,
|
|
168
|
+
"is-inside-form": s(G),
|
|
169
|
+
label: e.label,
|
|
170
|
+
tooltip: e.tooltip
|
|
171
|
+
}, {
|
|
172
|
+
default: ie(() => [
|
|
173
|
+
l("input", ae({
|
|
174
|
+
id: e.id,
|
|
175
|
+
ref_key: "elRef",
|
|
176
|
+
ref: $,
|
|
177
|
+
type: "file",
|
|
178
|
+
class: [
|
|
179
|
+
"sr-only",
|
|
180
|
+
s(R).input
|
|
181
|
+
],
|
|
182
|
+
disabled: e.disabled,
|
|
183
|
+
name: e.name,
|
|
184
|
+
accept: e.accept,
|
|
185
|
+
multiple: e.multiple,
|
|
186
|
+
readonly: e.readonly
|
|
187
|
+
}, le({
|
|
188
|
+
...s(J),
|
|
189
|
+
input: F,
|
|
190
|
+
change: T
|
|
191
|
+
}, !0)), null, 16, be),
|
|
192
|
+
k(e.$slots, "box", { isOver: s(E) }, () => [
|
|
193
|
+
l("div", {
|
|
194
|
+
ref_key: "dropZoneRef",
|
|
195
|
+
ref: C,
|
|
196
|
+
class: b(["border border-dashed rounded-md flex items-center justify-center gap-2 p-4 cursor-pointer transition-colors duration-500 hover:border-primary-500 dark:hover:border-primary-400", {
|
|
197
|
+
"border-primary-500 dark:border-primary-400": s(E)
|
|
198
|
+
}])
|
|
199
|
+
}, [
|
|
200
|
+
x(S, { icon: s(fe) }, null, 8, ["icon"]),
|
|
201
|
+
l("span", xe, _(e.placeholder), 1),
|
|
202
|
+
t[0] || (t[0] = l("span", { class: "text-xs text-secondary-400 dark:text-secondary-500" }, "or drag and drop", -1))
|
|
203
|
+
], 2)
|
|
204
|
+
]),
|
|
205
|
+
s(X) ? w("", !0) : (d(), g(O, {
|
|
206
|
+
key: 0,
|
|
207
|
+
error: s(m),
|
|
208
|
+
helper: e.helper
|
|
209
|
+
}, null, 8, ["error", "helper"]))
|
|
210
|
+
]),
|
|
211
|
+
_: 3
|
|
212
|
+
}, 8, ["style", "disabled", "required", "is-inside-form", "label", "tooltip"]),
|
|
213
|
+
k(e.$slots, "files", { files: i.value }, () => [
|
|
214
|
+
(d(!0), f(de, null, ce(i.value, (r, n) => (d(), f("div", {
|
|
215
|
+
key: n,
|
|
216
|
+
class: "border rounded-md p-2 bg-secondary-100 my-2"
|
|
217
|
+
}, [
|
|
218
|
+
l("div", ke, [
|
|
219
|
+
l("div", {
|
|
220
|
+
class: b(["rounded-md w-9 h-9 flex items-center justify-center mr-2 border", {
|
|
221
|
+
"p-2 bg-white": !B(r.file)
|
|
222
|
+
}])
|
|
223
|
+
}, [
|
|
224
|
+
B(r.file) ? (d(), f("img", {
|
|
225
|
+
key: 0,
|
|
226
|
+
src: z(r.file),
|
|
227
|
+
class: "w-full h-full object-cover rounded-md"
|
|
228
|
+
}, null, 8, _e)) : (d(), g(S, {
|
|
229
|
+
key: 1,
|
|
230
|
+
icon: s(ge)
|
|
231
|
+
}, null, 8, ["icon"]))
|
|
232
|
+
], 2),
|
|
233
|
+
l("div", we, [
|
|
234
|
+
l("div", Se, _(r.file.name), 1),
|
|
235
|
+
l("div", Ie, _(A(r.file.size)), 1)
|
|
236
|
+
]),
|
|
237
|
+
l("button", {
|
|
238
|
+
type: "button",
|
|
239
|
+
class: "shrink-0",
|
|
240
|
+
onClick: (c) => Z(r.file)
|
|
241
|
+
}, [
|
|
242
|
+
k(e.$slots, "removeIcon", {}, () => [
|
|
243
|
+
x(S, { icon: s(he) }, null, 8, ["icon"])
|
|
244
|
+
])
|
|
245
|
+
], 8, $e)
|
|
246
|
+
]),
|
|
247
|
+
p.value ? (d(), g(ye, {
|
|
248
|
+
key: 0,
|
|
249
|
+
percentage: r.progress,
|
|
250
|
+
class: "mt-1",
|
|
251
|
+
color: r.error ? "warning" : "success"
|
|
252
|
+
}, null, 8, ["percentage", "color"])) : w("", !0),
|
|
253
|
+
r.error ? (d(), g(O, {
|
|
254
|
+
key: 1,
|
|
255
|
+
error: r.error
|
|
256
|
+
}, null, 8, ["error"])) : w("", !0)
|
|
257
|
+
]))), 128))
|
|
258
|
+
])
|
|
259
|
+
], 2));
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
export {
|
|
263
|
+
Fe as default
|
|
264
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { useElementSize as
|
|
3
|
-
function
|
|
1
|
+
import { computed as h, unref as C, ref as v, shallowRef as P, watch as O } from "vue";
|
|
2
|
+
import { useElementSize as x } from "../node_modules/.pnpm/@vueuse_core@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js";
|
|
3
|
+
function Y(t, e) {
|
|
4
4
|
if (e.disabled)
|
|
5
5
|
return {
|
|
6
|
-
list:
|
|
6
|
+
list: h(() => C(t).map((a, u) => ({ data: a, index: u }))),
|
|
7
7
|
scrollTo: () => {
|
|
8
8
|
},
|
|
9
9
|
reset: () => {
|
|
10
10
|
},
|
|
11
11
|
containerProps: {
|
|
12
|
-
ref:
|
|
12
|
+
ref: v(null),
|
|
13
13
|
style: {},
|
|
14
14
|
onScroll: () => {
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
wrapperProps: {}
|
|
18
18
|
};
|
|
19
|
-
const { containerStyle:
|
|
19
|
+
const { containerStyle: r, wrapperProps: o, scrollTo: n, calculateRange: l, currentList: s, containerRef: c } = _(e, t);
|
|
20
20
|
return {
|
|
21
21
|
list: s,
|
|
22
|
-
scrollTo:
|
|
22
|
+
scrollTo: n,
|
|
23
23
|
reset: l,
|
|
24
24
|
containerProps: {
|
|
25
25
|
ref: c,
|
|
26
26
|
onScroll: () => {
|
|
27
27
|
l();
|
|
28
28
|
},
|
|
29
|
-
style:
|
|
29
|
+
style: r
|
|
30
30
|
},
|
|
31
31
|
wrapperProps: o
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
const e =
|
|
36
|
-
return { state:
|
|
34
|
+
function G(t) {
|
|
35
|
+
const e = v(null), r = x(e), o = v([]), n = P(t);
|
|
36
|
+
return { state: v({ start: 0, end: 10 }), source: n, currentList: o, size: r, containerRef: e };
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function H(t, e, r) {
|
|
39
39
|
return (o) => {
|
|
40
|
-
if (typeof
|
|
41
|
-
return Math.ceil(o /
|
|
42
|
-
const { start:
|
|
40
|
+
if (typeof r == "number")
|
|
41
|
+
return Math.ceil(o / r);
|
|
42
|
+
const { start: n = 0 } = t.value;
|
|
43
43
|
let l = 0, s = 0;
|
|
44
|
-
for (let c =
|
|
45
|
-
const a =
|
|
44
|
+
for (let c = n; c < e.value.length; c++) {
|
|
45
|
+
const a = r(c);
|
|
46
46
|
if (l += a, s = c, l > o)
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
|
-
return s -
|
|
49
|
+
return s - n;
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
return (
|
|
52
|
+
function k(t, e) {
|
|
53
|
+
return (r) => {
|
|
54
54
|
if (typeof e == "number")
|
|
55
|
-
return Math.floor(
|
|
56
|
-
let o = 0,
|
|
55
|
+
return Math.floor(r / e) + 1;
|
|
56
|
+
let o = 0, n = 0;
|
|
57
57
|
for (let l = 0; l < t.value.length; l++) {
|
|
58
58
|
const s = e(l);
|
|
59
|
-
if (o += s, o >=
|
|
60
|
-
|
|
59
|
+
if (o += s, o >= r) {
|
|
60
|
+
n = l;
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
return
|
|
64
|
+
return n + 1;
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function z(t, e, r, o, { containerRef: n, state: l, currentList: s, source: c }) {
|
|
68
68
|
return () => {
|
|
69
|
-
const a =
|
|
69
|
+
const a = n.value;
|
|
70
70
|
if (a) {
|
|
71
|
-
const u =
|
|
71
|
+
const u = r(t === "vertical" ? a.scrollTop : a.scrollLeft), f = o(t === "vertical" ? a.clientHeight : a.clientWidth), i = u - e, p = u + f + e;
|
|
72
72
|
l.value = {
|
|
73
73
|
start: i < 0 ? 0 : i,
|
|
74
|
-
end:
|
|
74
|
+
end: p > c.value.length ? c.value.length : p
|
|
75
75
|
}, s.value = c.value.slice(l.value.start, l.value.end).map((g, y) => ({
|
|
76
76
|
data: g,
|
|
77
77
|
index: y + l.value.start
|
|
@@ -79,45 +79,48 @@ function H(t, e, n, o, { containerRef: r, state: l, currentList: s, source: c })
|
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
return (
|
|
82
|
+
function D(t, e) {
|
|
83
|
+
return (r) => typeof t == "number" ? r * t : e.value.slice(0, r).reduce((n, l, s) => n + t(s), 0);
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
|
|
87
|
-
o()
|
|
85
|
+
function E(t, e, r, o) {
|
|
86
|
+
O([t.width, t.height, e, r], () => {
|
|
87
|
+
o();
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
return
|
|
90
|
+
function F(t, e) {
|
|
91
|
+
return h(() => typeof t == "number" ? e.value.length * t : e.value.reduce((r, o, n) => r + t(n), 0));
|
|
92
92
|
}
|
|
93
|
-
const
|
|
93
|
+
const M = {
|
|
94
94
|
horizontal: "scrollLeft",
|
|
95
95
|
vertical: "scrollTop"
|
|
96
96
|
};
|
|
97
|
-
function
|
|
98
|
-
return (
|
|
99
|
-
o.value && (o.value[
|
|
97
|
+
function W(t, e, r, o) {
|
|
98
|
+
return (n) => {
|
|
99
|
+
o.value && (o.value[M[t]] = r(n), e());
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
function
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
function _(t, e) {
|
|
103
|
+
const r = G(e), { state: o, source: n, currentList: l, size: s, containerRef: c } = r, a = { overflowY: "auto" }, { itemHeight: u, topOffset: f = 0, bottomOffset: i = 0, overscan: p = 5 } = t, g = H(o, n, u), y = k(n, u), d = z("vertical", p, y, g, r), m = D(u, n), T = h(() => m(o.value.start)), w = F(u, n), R = W("vertical", d, m, c);
|
|
104
|
+
E(s, n, c, d);
|
|
105
|
+
const V = h(() => {
|
|
106
|
+
const b = w.value + f + i, L = T.value > b ? b : T.value;
|
|
107
|
+
return {
|
|
108
|
+
style: {
|
|
109
|
+
width: "100%",
|
|
110
|
+
height: `${w.value - L + f + i}px`,
|
|
111
|
+
marginTop: `${L}px`
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
});
|
|
112
115
|
return {
|
|
113
116
|
calculateRange: d,
|
|
114
|
-
scrollTo:
|
|
117
|
+
scrollTo: R,
|
|
115
118
|
containerStyle: a,
|
|
116
|
-
wrapperProps:
|
|
119
|
+
wrapperProps: V,
|
|
117
120
|
currentList: l,
|
|
118
121
|
containerRef: c
|
|
119
122
|
};
|
|
120
123
|
}
|
|
121
124
|
export {
|
|
122
|
-
|
|
125
|
+
Y as useVirtualList
|
|
123
126
|
};
|