@nmorph/nmorph-ui-kit 2.2.36 → 2.2.38
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/basic/nmorph-button/NmorphButton.vue2.js +8 -8
- package/dist/components/basic/nmorph-icon/NmorphIcon.vue2.js +3 -3
- package/dist/components/basic/nmorph-layout/NmorphLayout.vue2.js +14 -13
- package/dist/components/basic/nmorph-link/NmorphLink.vue2.js +1 -1
- package/dist/components/basic/nmorph-scroll/NmorphScroll.css +1 -0
- package/dist/components/basic/nmorph-scroll/NmorphScroll.vue.js +6 -4
- package/dist/components/basic/nmorph-scroll/NmorphScroll.vue2.js +1 -0
- package/dist/components/basic/nmorph-space/NmorphSpace.vue2.js +15 -19
- package/dist/components/data/nmorph-avatar/NmorphAvatar.css +1 -1
- package/dist/components/data/nmorph-avatar/NmorphAvatar.vue2.js +5 -5
- package/dist/components/data/nmorph-badge/NmorphBadge.vue2.js +37 -36
- package/dist/components/data/nmorph-calendar/NmorphCalendar.vue2.js +41 -40
- package/dist/components/data/nmorph-card/NmorphCard.vue2.js +19 -15
- package/dist/components/data/nmorph-collapse/components/nmorph-collapse-item/NmorphCollapseItem.vue2.js +5 -9
- package/dist/components/data/nmorph-empty/NmorphEmpty.vue.js +3 -3
- package/dist/components/data/nmorph-empty/NmorphEmpty.vue2.js +17 -14
- package/dist/components/data/nmorph-image/NmorphImage.css +1 -0
- package/dist/components/data/nmorph-image/NmorphImage.vue.js +14 -12
- package/dist/components/data/nmorph-image/NmorphImage.vue2.js +3 -2
- package/dist/components/data/nmorph-image-preview/NmorphImagePreview.vue2.js +36 -35
- package/dist/components/data/nmorph-pagination/NmorphPagination.vue2.js +1 -1
- package/dist/components/data/nmorph-progress/NmorphProgress.vue2.js +19 -18
- package/dist/components/data/nmorph-qr-code/NmorphQRCode.vue2.js +20 -19
- package/dist/components/data/nmorph-skeleton/NmorphSkeleton.vue2.js +1 -1
- package/dist/components/data/nmorph-table/NmorphTable.vue2.js +39 -43
- package/dist/components/data/nmorph-virtual-list/NmorphVirtualList.vue2.js +34 -33
- package/dist/components/feedback/nmorph-alert/NmorphAlert.vue2.js +1 -1
- package/dist/components/feedback/nmorph-callout/NmorphCallout.vue2.js +7 -6
- package/dist/components/feedback/nmorph-dialog/NmorphDialog.css +1 -1
- package/dist/components/feedback/nmorph-dialog/NmorphDialog.vue.js +25 -20
- package/dist/components/feedback/nmorph-dialog/NmorphDialog.vue2.js +37 -37
- package/dist/components/feedback/nmorph-drawer/NmorphDrawer.vue2.js +22 -21
- package/dist/components/feedback/nmorph-tooltip/NmorphTooltip.vue2.js +26 -25
- package/dist/components/form/nmorph-autocomplete/NmorphAutocomplete.vue2.js +65 -71
- package/dist/components/form/nmorph-checkbox/NmorphCheckbox.css +1 -1
- package/dist/components/form/nmorph-checkbox/NmorphCheckbox.vue2.js +30 -28
- package/dist/components/form/nmorph-checkbox-group/NmorphCheckboxGroup.vue2.js +25 -20
- package/dist/components/form/nmorph-color-picker/NmorphColorPicker.vue2.js +43 -42
- package/dist/components/form/nmorph-date-picker/NmorphDatePicker.vue2.js +53 -40
- package/dist/components/form/nmorph-file-upload/NmorphFileUpload.vue.js +20 -16
- package/dist/components/form/nmorph-file-upload/NmorphFileUpload.vue2.js +113 -86
- package/dist/components/form/nmorph-form/NmorphForm.vue2.js +9 -9
- package/dist/components/form/nmorph-form/components/nmorph-form-item/NmorphFormItem.vue2.js +33 -24
- package/dist/components/form/nmorph-form/components/nmorph-form-item/inner-components/nmorph-error-box/NmorphErrorBox.vue2.js +1 -1
- package/dist/components/form/nmorph-form/use-form-item-input.js +29 -8
- package/dist/components/form/nmorph-number-input/NmorphNumberInput.vue2.js +42 -39
- package/dist/components/form/nmorph-otp-input/NmorphOTPInput.vue2.js +66 -62
- package/dist/components/form/nmorph-radio/NmorphRadio.css +1 -1
- package/dist/components/form/nmorph-radio/NmorphRadio.vue2.js +1 -1
- package/dist/components/form/nmorph-radio-group/NmorphRadioGroup.vue2.js +24 -22
- package/dist/components/form/nmorph-select/NmorphSelect.css +1 -1
- package/dist/components/form/nmorph-select/NmorphSelect.vue2.js +83 -81
- package/dist/components/form/nmorph-select/components/nmorph-select-option/NmorphSelectOption.vue2.js +4 -4
- package/dist/components/form/nmorph-select-button/NmorphSelectButton.vue2.js +28 -25
- package/dist/components/form/nmorph-select-button/components/nmorph-select-button-item/NmorphSelectButtonItem.vue2.js +1 -1
- package/dist/components/form/nmorph-slider/NmorphSlider.vue2.js +51 -49
- package/dist/components/form/nmorph-switch/NmorphSwitch.vue2.js +35 -33
- package/dist/components/form/nmorph-text-input/NmorphTextInput.css +1 -0
- package/dist/components/form/nmorph-text-input/NmorphTextInput.vue.js +5 -3
- package/dist/components/form/nmorph-text-input/NmorphTextInput.vue2.js +37 -35
- package/dist/components/form/nmorph-textarea/NmorphTextarea.vue.js +1 -1
- package/dist/components/form/nmorph-textarea/NmorphTextarea.vue2.js +30 -26
- package/dist/components/form/nmorph-time-picker/NmorphTimePicker.vue.js +1 -1
- package/dist/components/form/nmorph-time-picker/NmorphTimePicker.vue2.js +68 -66
- package/dist/components/navigation/nmorph-backtop/NmorphBacktop.vue2.js +1 -1
- package/dist/components/navigation/nmorph-dropdown/NmorphDropdown.vue2.js +32 -31
- package/dist/components/navigation/nmorph-tabs/NmorphTabs.vue2.js +1 -1
- package/dist/components/others/nmorph-overlay/NmorphOverlay.vue2.js +1 -1
- package/dist/hooks/use-common-styles.js +18 -278
- package/dist/hooks/use-field-validation.js +71 -42
- package/dist/hooks/use-form-validation.js +62 -24
- package/dist/hooks/use-virtual-list.js +38 -32
- package/dist/index.umd.js +26 -286
- package/dist/package.json.js +1 -1
- package/dist/src/components/basic/nmorph-button/NmorphButton.vue.d.ts +2 -2
- package/dist/src/components/basic/nmorph-link/NmorphLink.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-avatar/NmorphAvatar.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-badge/NmorphBadge.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-collapse/components/nmorph-collapse-item/NmorphCollapseItem.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-empty/NmorphEmpty.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-pagination/NmorphPagination.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-progress/NmorphProgress.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-table/NmorphTable.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-tag-list/components/nmorph-tag-item/NmorphTagItem.vue.d.ts +1 -1
- package/dist/src/components/feedback/nmorph-callout/NmorphCallout.vue.d.ts +1 -1
- package/dist/src/components/feedback/nmorph-dialog/NmorphDialog.vue.d.ts +4 -4
- package/dist/src/components/form/nmorph-autocomplete/NmorphAutocomplete.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-checkbox-group/NmorphCheckboxGroup.vue.d.ts +3 -3
- package/dist/src/components/form/nmorph-color-picker/NmorphColorPicker.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-date-picker/NmorphDatePicker.vue.d.ts +3 -3
- package/dist/src/components/form/nmorph-file-upload/NmorphFileUpload.vue.d.ts +6 -3
- package/dist/src/components/form/nmorph-file-upload/types.d.ts +4 -0
- package/dist/src/components/form/nmorph-form/components/nmorph-form-item/NmorphFormItem.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-form/components/nmorph-form-item/inner-components/nmorph-error-box/NmorphErrorBox.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-form/types.d.ts +15 -5
- package/dist/src/components/form/nmorph-form/use-form-item-input.d.ts +10 -0
- package/dist/src/components/form/nmorph-number-input/NmorphNumberInput.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-otp-input/NmorphOTPInput.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-radio-group/NmorphRadioGroup.vue.d.ts +3 -3
- package/dist/src/components/form/nmorph-select/NmorphSelect.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-select-button/NmorphSelectButton.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-text-input/NmorphTextInput.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-textarea/NmorphTextarea.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-time-picker/NmorphTimePicker.vue.d.ts +1 -1
- package/dist/src/hooks/use-field-validation.d.ts +15 -0
- package/dist/src/hooks/use-form-validation.d.ts +5 -0
- package/dist/src/hooks/use-virtual-list.d.ts +6 -0
- package/dist/src/types/index.d.ts +2 -1
- package/dist/src/utils/common.d.ts +5 -0
- package/dist/src/utils/create-modifiers.d.ts +4 -2
- package/dist/style.css +1 -1
- package/dist/utils/common.js +9 -3
- package/dist/utils/create-modifiers.js +6 -6
- package/package.json +1 -1
|
@@ -1,74 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { resolution as L } from "../components/form/nmorph-file-upload/types.js";
|
|
2
|
+
import { ref as h } from "vue";
|
|
3
|
+
const S = Object.entries(L), z = (t) => t.split("/")[1]?.toLowerCase() || "", B = (t) => {
|
|
4
|
+
const o = t.split(".").pop()?.toLowerCase();
|
|
5
|
+
return o && o !== t.toLowerCase() ? o : "";
|
|
6
|
+
}, I = (t) => S.find(([, o]) => o.toLowerCase() === t.toLowerCase())?.[0] || "", M = (t) => Array.from(
|
|
7
|
+
new Set(
|
|
8
|
+
[
|
|
9
|
+
t.type.toLowerCase(),
|
|
10
|
+
I(t.type),
|
|
11
|
+
B(t.name),
|
|
12
|
+
z(t.type)
|
|
13
|
+
].filter(Boolean).map((o) => o.toLowerCase())
|
|
14
|
+
)
|
|
15
|
+
), w = (t) => typeof File < "u" && t instanceof File, q = (t) => !!t && typeof t == "object" && "data" in t && w(t.data), E = (t) => {
|
|
16
|
+
if (w(t)) return [t];
|
|
17
|
+
if (!Array.isArray(t)) return null;
|
|
18
|
+
const o = t;
|
|
19
|
+
return o.length === 0 ? [] : o.every(w) ? o : o.every(q) ? o.map((s) => s.data) : null;
|
|
20
|
+
}, j = (t, o) => {
|
|
21
|
+
if (o.length === 0) return !0;
|
|
22
|
+
const s = M(t);
|
|
23
|
+
return o.some((c) => s.includes(String(c).toLowerCase()));
|
|
24
|
+
}, P = (t) => {
|
|
25
|
+
const { inputValue: o, rules: s } = t, c = h([]), y = h(!1), m = h(!1);
|
|
4
26
|
return {
|
|
5
|
-
touched:
|
|
6
|
-
valid:
|
|
27
|
+
touched: m,
|
|
28
|
+
valid: y,
|
|
7
29
|
errors: c,
|
|
8
30
|
validate: () => {
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
11
|
-
|
|
31
|
+
const g = s?.length > 0;
|
|
32
|
+
if (c.value = [], !g) {
|
|
33
|
+
y.value = !0;
|
|
12
34
|
return;
|
|
13
35
|
}
|
|
14
|
-
if (
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
36
|
+
if (o === null) return;
|
|
37
|
+
const i = o, u = (a) => g && s.some((r) => a in r), C = typeof i == "string" && u("pattern"), F = typeof i == "number" && u("numberCompareType"), T = (typeof i == "string" || typeof i == "boolean") && u("booleanCompareType"), v = Array.isArray(i) && u("arrayCompareType"), x = u("fileMaxSize") || u("maxFileSize") || u("fileAllowedTypes") || u("allowedTypes") || u("fileMaxCount") || u("maxFiles"), b = x ? E(i) : null, A = x && b !== null;
|
|
38
|
+
if (!F && !C && !T && !v && !A) {
|
|
17
39
|
console.warn("The input value and the provided rules do not match");
|
|
18
40
|
return;
|
|
19
41
|
}
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
c.value =
|
|
42
|
+
if (m.value || (m.value = !0), C) {
|
|
43
|
+
const a = s;
|
|
44
|
+
c.value = a.reduce((r, n) => (i.match(n.pattern) || r.push(n.error), r), []);
|
|
23
45
|
}
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
26
|
-
switch (
|
|
46
|
+
if (F) {
|
|
47
|
+
const a = (n, e, l) => {
|
|
48
|
+
switch (l) {
|
|
27
49
|
case "eq":
|
|
28
|
-
return
|
|
50
|
+
return n === e;
|
|
29
51
|
case "gt":
|
|
30
|
-
return
|
|
52
|
+
return n > e;
|
|
31
53
|
case "lt":
|
|
32
|
-
return
|
|
54
|
+
return n < e;
|
|
33
55
|
case "lte":
|
|
34
|
-
return
|
|
56
|
+
return n <= e;
|
|
35
57
|
case "gte":
|
|
36
|
-
return
|
|
58
|
+
return n >= e;
|
|
37
59
|
}
|
|
38
|
-
},
|
|
39
|
-
c.value =
|
|
60
|
+
}, r = s;
|
|
61
|
+
c.value = r.reduce((n, e) => (a(i, e.compareValue, e.numberCompareType) && n.push(e.error), n), []);
|
|
40
62
|
}
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
c.value =
|
|
63
|
+
if (T) {
|
|
64
|
+
const a = s;
|
|
65
|
+
c.value = a.reduce((r, n) => {
|
|
44
66
|
let e = !1;
|
|
45
|
-
const { compareValue:
|
|
46
|
-
return
|
|
67
|
+
const { compareValue: l, booleanCompareType: f } = n;
|
|
68
|
+
return f === "not-eq" && (e = i === l), f === "eq" && (e = i !== l), e || r.push(n.error), r;
|
|
47
69
|
}, []);
|
|
48
70
|
}
|
|
49
|
-
if (
|
|
50
|
-
const
|
|
51
|
-
switch (
|
|
71
|
+
if (v) {
|
|
72
|
+
const a = s, r = (n, e, l) => {
|
|
73
|
+
switch (l) {
|
|
52
74
|
case "contains-one":
|
|
53
|
-
return
|
|
75
|
+
return n.some((p) => e.includes(p));
|
|
54
76
|
case "full-eq":
|
|
55
|
-
if (
|
|
56
|
-
const
|
|
57
|
-
return
|
|
77
|
+
if (n.length !== e.length) return !1;
|
|
78
|
+
const f = [...n].sort(), d = [...e].sort();
|
|
79
|
+
return f.every((p, R) => p === d[R]);
|
|
58
80
|
case "not-contains":
|
|
59
|
-
return !
|
|
81
|
+
return !n.some((p) => e.includes(p));
|
|
60
82
|
}
|
|
61
83
|
};
|
|
62
|
-
c.value =
|
|
63
|
-
|
|
84
|
+
c.value = a.reduce((n, e) => (r(
|
|
85
|
+
i.map((f) => String(f)),
|
|
64
86
|
e.compareValue,
|
|
65
87
|
e.arrayCompareType
|
|
66
|
-
) ||
|
|
88
|
+
) || n.push(e.error), n), []);
|
|
89
|
+
}
|
|
90
|
+
if (A) {
|
|
91
|
+
const a = s, r = b || [];
|
|
92
|
+
c.value = a.reduce((n, e) => {
|
|
93
|
+
const l = e.fileMaxSize ?? e.maxFileSize, f = e.fileAllowedTypes ?? e.allowedTypes, d = e.fileMaxCount ?? e.maxFiles;
|
|
94
|
+
return typeof l == "number" && r.some((p) => p.size > l) && n.push(e.error), f && r.some((p) => !j(p, f)) && n.push(e.error), typeof d == "number" && r.length > d && n.push(e.error), n;
|
|
95
|
+
}, []);
|
|
67
96
|
}
|
|
68
|
-
|
|
97
|
+
y.value = c.value.length === 0;
|
|
69
98
|
}
|
|
70
99
|
};
|
|
71
100
|
};
|
|
72
101
|
export {
|
|
73
|
-
|
|
102
|
+
P as useFieldValidation
|
|
74
103
|
};
|
|
@@ -1,30 +1,68 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
import { deepClone as F } from "../utils/common.js";
|
|
1
|
+
import { reactive as f, ref as h, watch as w, readonly as b } from "vue";
|
|
3
2
|
import { useFieldValidation as c } from "./use-field-validation.js";
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
const z = (e) => typeof File < "u" && e instanceof File, p = (e) => z(e) ? {
|
|
4
|
+
name: e.name,
|
|
5
|
+
size: e.size,
|
|
6
|
+
type: e.type,
|
|
7
|
+
lastModified: e.lastModified
|
|
8
|
+
} : e instanceof Date ? e.toISOString() : e instanceof RegExp ? e.toString() : typeof e == "function" ? String(e) : Array.isArray(e) ? e.map(p) : e && typeof e == "object" ? Object.fromEntries(
|
|
9
|
+
Object.entries(e).map(([s, i]) => [
|
|
10
|
+
s,
|
|
11
|
+
p(i)
|
|
12
|
+
])
|
|
13
|
+
) : e, m = (e) => Object.fromEntries(
|
|
14
|
+
Object.entries(e).map(([s, i]) => [
|
|
15
|
+
s,
|
|
16
|
+
JSON.stringify(p(i))
|
|
17
|
+
])
|
|
18
|
+
), O = (e) => {
|
|
19
|
+
const s = e.valid;
|
|
20
|
+
return typeof s == "boolean" ? s : s.value;
|
|
21
|
+
}, H = (e, s = !1) => {
|
|
22
|
+
const i = f({}), a = f({}), F = f(m(e)), V = h(!1), d = h(!1), j = () => {
|
|
23
|
+
const t = Object.values(a).every(O), n = Object.values(i).every(O);
|
|
24
|
+
V.value = t && n;
|
|
25
|
+
}, u = () => {
|
|
26
|
+
Object.entries(e).forEach(([t, n]) => {
|
|
27
|
+
a[t] = c({ inputValue: n.value, rules: n.rules }), a[t].validate();
|
|
28
|
+
}), j();
|
|
29
|
+
}, g = () => {
|
|
30
|
+
Object.entries(e).forEach(([t, n]) => {
|
|
31
|
+
i[t] = c({ inputValue: n.value, rules: n.rules }), i[t].validate();
|
|
32
|
+
}), u();
|
|
33
|
+
}, y = (t, n) => {
|
|
34
|
+
const r = e[t];
|
|
35
|
+
if (!r) return;
|
|
36
|
+
const o = c({
|
|
37
|
+
inputValue: n ?? r.value,
|
|
38
|
+
rules: r.rules
|
|
12
39
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
t[
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
40
|
+
return o.validate(), i[t] = o, u(), d.value = !0, o;
|
|
41
|
+
}, S = (t, n) => {
|
|
42
|
+
const r = e[t];
|
|
43
|
+
r && (r.value = n, y(t, n));
|
|
44
|
+
}, v = (t, n) => {
|
|
45
|
+
const r = m(n);
|
|
46
|
+
return { changedFields: Object.keys(n).filter((l) => {
|
|
47
|
+
const E = t[l] ?? null, A = r[l];
|
|
48
|
+
return E !== A;
|
|
49
|
+
}), newSnapshot: r };
|
|
50
|
+
};
|
|
51
|
+
return w(e, (t) => {
|
|
52
|
+
const { changedFields: n, newSnapshot: r } = v(F, t);
|
|
53
|
+
n.forEach((o) => {
|
|
54
|
+
const l = t[o];
|
|
55
|
+
i[o] = c({ inputValue: l.value, rules: l.rules }), i[o].validate();
|
|
56
|
+
}), Object.assign(F, r), u(), d.value = !0;
|
|
57
|
+
}, { deep: !0 }), s && g(), {
|
|
58
|
+
formValue: e,
|
|
59
|
+
fields: i,
|
|
60
|
+
updateFieldValue: S,
|
|
61
|
+
validateField: y,
|
|
62
|
+
isFormValid: b(V),
|
|
63
|
+
isAnyTouched: b(d)
|
|
26
64
|
};
|
|
27
65
|
};
|
|
28
66
|
export {
|
|
29
|
-
|
|
67
|
+
H as useFormValidation
|
|
30
68
|
};
|
|
@@ -1,72 +1,78 @@
|
|
|
1
|
-
import { ref as m, computed as
|
|
2
|
-
const C = (
|
|
3
|
-
const x = m(null), c = m(0), d = m(0), s =
|
|
1
|
+
import { ref as m, computed as a, onMounted as V, nextTick as M, onUnmounted as $, watch as k } from "vue";
|
|
2
|
+
const C = (n, h) => {
|
|
3
|
+
const x = m(null), c = m(0), d = m(0), s = a(() => h.enabled?.value ?? !0), i = a(() => Math.max(h.overscan?.value ?? 0, 0)), u = a(() => h.dynamic?.value ?? !1), o = a(() => Math.max(h.itemHeight.value, 1)), g = m({}), w = (e) => u.value && g.value[e] || o.value, f = a(() => {
|
|
4
4
|
const e = [];
|
|
5
5
|
let t = 0;
|
|
6
|
-
for (let l = 0; l <
|
|
7
|
-
e[l] = t, t +=
|
|
6
|
+
for (let l = 0; l < n.value.length; l++)
|
|
7
|
+
e[l] = t, t += w(l);
|
|
8
8
|
return { offsets: e, total: t };
|
|
9
|
-
}),
|
|
9
|
+
}), p = a(() => s.value ? u.value ? f.value.total : n.value.length * o.value : 0), r = () => {
|
|
10
10
|
const e = x.value;
|
|
11
11
|
if (!e) return;
|
|
12
|
-
const t = Math.max(
|
|
12
|
+
const t = Math.max(p.value - e.clientHeight, 0);
|
|
13
13
|
e.scrollTop > t && (e.scrollTop = t), c.value = e.scrollTop, d.value = e.clientHeight;
|
|
14
|
-
},
|
|
14
|
+
}, y = () => {
|
|
15
15
|
r();
|
|
16
|
-
}, v =
|
|
16
|
+
}, v = a(() => {
|
|
17
17
|
if (!s.value) return 0;
|
|
18
18
|
if (u.value) {
|
|
19
|
-
const e = f.value.offsets.findIndex((t, l) => t +
|
|
19
|
+
const e = f.value.offsets.findIndex((t, l) => t + w(l) >= c.value);
|
|
20
20
|
return Math.max(e === -1 ? 0 : e - i.value, 0);
|
|
21
21
|
}
|
|
22
22
|
return Math.max(Math.floor(c.value / o.value) - i.value, 0);
|
|
23
|
-
}), H =
|
|
24
|
-
if (!s.value) return
|
|
23
|
+
}), H = a(() => {
|
|
24
|
+
if (!s.value) return n.value.length;
|
|
25
25
|
if (u.value) {
|
|
26
26
|
const t = c.value + d.value;
|
|
27
27
|
let l = v.value;
|
|
28
|
-
for (; l <
|
|
28
|
+
for (; l < n.value.length && f.value.offsets[l] <= t; )
|
|
29
29
|
l++;
|
|
30
|
-
return Math.min(l + i.value,
|
|
30
|
+
return Math.min(l + i.value, n.value.length);
|
|
31
31
|
}
|
|
32
32
|
const e = Math.ceil((c.value + d.value) / o.value) + i.value;
|
|
33
|
-
return Math.min(Math.max(e, v.value + i.value),
|
|
34
|
-
}),
|
|
33
|
+
return Math.min(Math.max(e, v.value + i.value), n.value.length);
|
|
34
|
+
}), T = a(
|
|
35
35
|
() => u.value ? f.value.offsets[v.value] || 0 : v.value * o.value
|
|
36
|
-
), z =
|
|
36
|
+
), z = a(() => s.value ? n.value.slice(v.value, H.value).map((e, t) => ({
|
|
37
37
|
item: e,
|
|
38
38
|
index: v.value + t
|
|
39
|
-
})) :
|
|
39
|
+
})) : n.value.map((e, t) => ({ item: e, index: t }))), E = a(() => ({
|
|
40
|
+
height: `${p.value}px`
|
|
41
|
+
})), L = a(() => ({
|
|
42
|
+
transform: `translateY(${T.value}px)`
|
|
43
|
+
})), S = (e) => {
|
|
40
44
|
const t = x.value;
|
|
41
45
|
if (!t || !s.value) return;
|
|
42
|
-
const l = Math.min(Math.max(e, 0), Math.max(
|
|
43
|
-
t.scrollTop =
|
|
44
|
-
},
|
|
46
|
+
const l = Math.min(Math.max(e, 0), Math.max(n.value.length - 1, 0)), R = u.value ? f.value.offsets[l] || 0 : l * o.value;
|
|
47
|
+
t.scrollTop = R, r();
|
|
48
|
+
}, b = (e, t) => {
|
|
45
49
|
if (!u.value || !t) return;
|
|
46
50
|
const l = Math.ceil(t.getBoundingClientRect().height || t.offsetHeight);
|
|
47
51
|
!l || g.value[e] === l || (g.value = { ...g.value, [e]: l }, M(r));
|
|
48
|
-
},
|
|
52
|
+
}, I = () => {
|
|
49
53
|
r();
|
|
50
54
|
};
|
|
51
|
-
return
|
|
52
|
-
M(r), typeof window < "u" && window.addEventListener("resize",
|
|
53
|
-
}),
|
|
54
|
-
typeof window < "u" && window.removeEventListener("resize",
|
|
55
|
+
return V(() => {
|
|
56
|
+
M(r), typeof window < "u" && window.addEventListener("resize", I);
|
|
57
|
+
}), $(() => {
|
|
58
|
+
typeof window < "u" && window.removeEventListener("resize", I);
|
|
55
59
|
}), k(
|
|
56
|
-
() => [
|
|
60
|
+
() => [n.value.length, s.value, o.value, u.value],
|
|
57
61
|
() => {
|
|
58
62
|
M(r);
|
|
59
63
|
}
|
|
60
64
|
), {
|
|
61
65
|
containerRef: x,
|
|
66
|
+
contentStyle: L,
|
|
62
67
|
endIndex: H,
|
|
63
|
-
offsetTop:
|
|
68
|
+
offsetTop: T,
|
|
64
69
|
refresh: r,
|
|
65
|
-
measureElement:
|
|
66
|
-
scrollHandler:
|
|
67
|
-
scrollToIndex:
|
|
70
|
+
measureElement: b,
|
|
71
|
+
scrollHandler: y,
|
|
72
|
+
scrollToIndex: S,
|
|
73
|
+
spacerStyle: E,
|
|
68
74
|
startIndex: v,
|
|
69
|
-
totalHeight:
|
|
75
|
+
totalHeight: p,
|
|
70
76
|
viewportHeight: d,
|
|
71
77
|
virtualItems: z
|
|
72
78
|
};
|