@serendie/ui 2.0.0 → 2.1.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/CheckBox/CheckBox.js +36 -35
- package/dist/components/ChoiceBox/ChoiceBox.js +41 -41
- package/dist/components/DataTable/DataTableComponent.d.ts +3 -20
- package/dist/components/DataTable/DataTableComponent.js +38 -36
- package/dist/components/DataTable/table/HeaderCheckbox.js +29 -19
- package/dist/components/Search/Search.d.ts +3 -1
- package/dist/components/Search/Search.js +34 -33
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Select/Select.js +47 -41
- package/dist/components/Tooltip/Tooltip.d.ts +14 -0
- package/dist/components/Tooltip/Tooltip.js +70 -0
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/components/Tooltip/index.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -10
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-content.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-indicator.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-trigger.js +10 -12
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item.js +16 -16
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/use-accordion.js +13 -20
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/avatar-root.js +1 -5
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/use-avatar.js +14 -18
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-hidden-input.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/use-checkbox.js +22 -28
- package/dist/node_modules/@ark-ui/react/dist/components/collapsible/collapsible-content.js +7 -9
- package/dist/node_modules/@ark-ui/react/dist/components/collapsible/use-collapsible.js +14 -21
- package/dist/node_modules/@ark-ui/react/dist/components/collection/list-collection.js +5 -0
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-content.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-item-group.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-positioner.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-root.js +17 -18
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-trigger.js +10 -9
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/use-combobox-item-context.js +5 -7
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/use-combobox.js +21 -45
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-backdrop.js +10 -9
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-close-trigger.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-content.js +6 -5
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-description.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/use-dialog.js +13 -22
- package/dist/node_modules/@ark-ui/react/dist/components/factory.js +26 -24
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-content.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item-group.js +1 -3
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item.js +15 -13
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-root.js +13 -14
- package/dist/node_modules/@ark-ui/react/dist/components/menu/use-menu-option-item-props-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/menu/use-menu.js +14 -21
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-ellipsis.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-next-trigger.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-prev-trigger.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-root.js +5 -4
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/use-pagination.js +13 -19
- package/dist/node_modules/@ark-ui/react/dist/components/portal/portal.js +25 -16
- package/dist/node_modules/@ark-ui/react/dist/components/presence/split-presence-props.js +3 -2
- package/dist/node_modules/@ark-ui/react/dist/components/presence/use-presence.js +18 -18
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-control.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-text.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item.js +1 -5
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/use-radio-group.js +14 -22
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-content.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-root.js +11 -12
- package/dist/node_modules/@ark-ui/react/dist/components/select/use-select.js +20 -47
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-hidden-input.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/switch/use-switch.js +20 -26
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/tabs-root.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/use-tabs.js +14 -21
- package/dist/node_modules/@ark-ui/react/dist/components/toast/create-toaster.js +3 -7
- package/dist/node_modules/@ark-ui/react/dist/components/toast/toaster.js +28 -15
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-arrow-tip.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-arrow.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-content.js +15 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-positioner.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-root.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-trigger.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/use-tooltip-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/use-tooltip.js +17 -0
- package/dist/node_modules/@ark-ui/react/dist/utils/compose-refs.js +13 -7
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +92 -90
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +230 -216
- package/dist/node_modules/@zag-js/accordion/dist/index.js +210 -227
- package/dist/node_modules/@zag-js/aria-hidden/dist/index.js +49 -12
- package/dist/node_modules/@zag-js/avatar/dist/index.js +119 -134
- package/dist/node_modules/@zag-js/checkbox/dist/index.js +196 -197
- package/dist/node_modules/@zag-js/collapsible/dist/index.js +250 -198
- package/dist/node_modules/@zag-js/collection/dist/index.js +172 -179
- package/dist/node_modules/@zag-js/combobox/dist/index.js +1176 -1082
- package/dist/node_modules/@zag-js/core/dist/index.js +77 -496
- package/dist/node_modules/@zag-js/dialog/dist/index.js +243 -270
- package/dist/node_modules/@zag-js/dismissable/dist/index.js +62 -60
- package/dist/node_modules/@zag-js/dom-query/dist/index.js +465 -253
- package/dist/node_modules/@zag-js/focus-trap/dist/index.js +307 -0
- package/dist/node_modules/@zag-js/focus-visible/dist/index.js +48 -47
- package/dist/node_modules/@zag-js/interact-outside/dist/index.js +112 -80
- package/dist/node_modules/@zag-js/menu/dist/index.js +998 -884
- package/dist/node_modules/@zag-js/pagination/dist/index.js +207 -213
- package/dist/node_modules/@zag-js/popper/dist/index.js +130 -129
- package/dist/node_modules/@zag-js/presence/dist/index.js +139 -122
- package/dist/node_modules/@zag-js/radio-group/dist/index.js +297 -302
- package/dist/node_modules/@zag-js/react/dist/index.js +255 -103
- package/dist/node_modules/@zag-js/remove-scroll/dist/index.js +18 -31
- package/dist/node_modules/@zag-js/select/dist/index.js +889 -885
- package/dist/node_modules/@zag-js/store/dist/index.js +98 -137
- package/dist/node_modules/@zag-js/switch/dist/index.js +199 -191
- package/dist/node_modules/@zag-js/tabs/dist/index.js +383 -386
- package/dist/node_modules/@zag-js/toast/dist/index.js +646 -633
- package/dist/node_modules/@zag-js/tooltip/dist/index.js +459 -0
- package/dist/node_modules/@zag-js/types/dist/index.js +6 -6
- package/dist/node_modules/@zag-js/utils/dist/index.js +112 -99
- package/dist/node_modules/proxy-compare/dist/index.js +4 -106
- package/dist/styles.css +1 -1
- package/package.json +5 -5
- package/dist/node_modules/@ark-ui/react/dist/utils/use-is-server.js +0 -10
- package/dist/node_modules/@zag-js/dom-event/dist/index.js +0 -130
- package/dist/node_modules/@zag-js/element-rect/dist/index.js +0 -32
- package/dist/node_modules/@zag-js/form-utils/dist/index.js +0 -51
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -52
- package/dist/node_modules/focus-trap/dist/focus-trap.esm.js +0 -431
- package/dist/node_modules/klona/full/index.js +0 -21
- package/dist/node_modules/tabbable/dist/index.esm.js +0 -202
|
@@ -1,113 +1,159 @@
|
|
|
1
|
-
import { isEqual as
|
|
2
|
-
var
|
|
3
|
-
itemToValue(
|
|
4
|
-
return typeof
|
|
1
|
+
import { isEqual as O, isObject as d, hasProp as p } from "../../utils/dist/index.js";
|
|
2
|
+
var S = Object.defineProperty, v = (n, h, t) => h in n ? S(n, h, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[h] = t, r = (n, h, t) => v(n, typeof h != "symbol" ? h + "" : h, t), c = {
|
|
3
|
+
itemToValue(n) {
|
|
4
|
+
return typeof n == "string" ? n : d(n) && p(n, "value") ? n.value : "";
|
|
5
5
|
},
|
|
6
|
-
itemToString(
|
|
7
|
-
return typeof
|
|
6
|
+
itemToString(n) {
|
|
7
|
+
return typeof n == "string" ? n : d(n) && p(n, "label") ? n.label : c.itemToValue(n);
|
|
8
8
|
},
|
|
9
|
-
isItemDisabled(
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
constructor(
|
|
14
|
-
this.options =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
9
|
+
isItemDisabled(n) {
|
|
10
|
+
return d(n) && p(n, "disabled") ? !!n.disabled : !1;
|
|
11
|
+
}
|
|
12
|
+
}, w = class x {
|
|
13
|
+
constructor(h) {
|
|
14
|
+
this.options = h, r(this, "items"), r(this, "copy", (t) => new x({ ...this.options, items: t ?? [...this.items] })), r(this, "isEqual", (t) => O(this.items, t.items)), r(this, "setItems", (t) => this.copy(t)), r(this, "getValues", (t = this.items) => Array.from(t).map((e) => this.getItemValue(e)).filter(Boolean)), r(this, "find", (t) => {
|
|
15
|
+
if (t == null) return null;
|
|
16
|
+
const e = this.indexOf(t);
|
|
17
|
+
return e != null ? this.at(e) : null;
|
|
18
|
+
}), r(this, "findMany", (t) => Array.from(t).map((e) => this.find(e)).filter((e) => e != null)), r(this, "at", (t) => {
|
|
19
|
+
if (!this.options.groupBy && !this.options.groupSort)
|
|
20
|
+
return this.items[t] ?? null;
|
|
21
|
+
let e = 0;
|
|
22
|
+
const i = this.group();
|
|
23
|
+
for (const [, s] of i)
|
|
24
|
+
for (const u of s) {
|
|
25
|
+
if (e === t) return u;
|
|
26
|
+
e++;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}), r(this, "sortFn", (t, e) => {
|
|
30
|
+
const i = this.indexOf(t), s = this.indexOf(e);
|
|
31
|
+
return (i ?? 0) - (s ?? 0);
|
|
32
|
+
}), r(this, "sort", (t) => [...t].sort(this.sortFn.bind(this))), r(this, "getItemValue", (t) => {
|
|
33
|
+
var e, i;
|
|
34
|
+
return t == null ? null : ((i = (e = this.options).itemToValue) == null ? void 0 : i.call(e, t)) ?? c.itemToValue(t);
|
|
35
|
+
}), r(this, "getItemDisabled", (t) => {
|
|
36
|
+
var e, i;
|
|
37
|
+
return t == null ? !1 : ((i = (e = this.options).isItemDisabled) == null ? void 0 : i.call(e, t)) ?? c.isItemDisabled(t);
|
|
38
|
+
}), r(this, "stringifyItem", (t) => {
|
|
39
|
+
var e, i;
|
|
40
|
+
return t == null ? null : ((i = (e = this.options).itemToString) == null ? void 0 : i.call(e, t)) ?? c.itemToString(t);
|
|
41
|
+
}), r(this, "stringify", (t) => t == null ? null : this.stringifyItem(this.find(t))), r(this, "stringifyItems", (t, e = ", ") => Array.from(t).map((i) => this.stringifyItem(i)).filter(Boolean).join(e)), r(this, "stringifyMany", (t, e) => this.stringifyItems(this.findMany(t), e)), r(this, "has", (t) => this.indexOf(t) !== -1), r(this, "hasItem", (t) => t == null ? !1 : this.has(this.getItemValue(t))), r(this, "group", () => {
|
|
42
|
+
const { groupBy: t, groupSort: e } = this.options;
|
|
43
|
+
if (!t) return [["", [...this.items]]];
|
|
44
|
+
const i = /* @__PURE__ */ new Map();
|
|
45
|
+
this.items.forEach((u, l) => {
|
|
46
|
+
const o = t(u, l);
|
|
47
|
+
i.has(o) || i.set(o, []), i.get(o).push(u);
|
|
48
|
+
});
|
|
49
|
+
let s = Array.from(i.entries());
|
|
50
|
+
return e && s.sort(([u], [l]) => {
|
|
51
|
+
if (typeof e == "function") return e(u, l);
|
|
52
|
+
if (Array.isArray(e)) {
|
|
53
|
+
const o = e.indexOf(u), f = e.indexOf(l);
|
|
54
|
+
return o === -1 ? 1 : f === -1 ? -1 : o - f;
|
|
55
|
+
}
|
|
56
|
+
return e === "asc" ? u.localeCompare(l) : e === "desc" ? l.localeCompare(u) : 0;
|
|
57
|
+
}), s;
|
|
58
|
+
}), r(this, "getNextValue", (t, e = 1, i = !1) => {
|
|
59
|
+
let s = this.indexOf(t);
|
|
60
|
+
if (s === -1) return null;
|
|
61
|
+
for (s = i ? Math.min(s + e, this.size - 1) : s + e; s <= this.size && this.getItemDisabled(this.at(s)); ) s++;
|
|
62
|
+
return this.getItemValue(this.at(s));
|
|
63
|
+
}), r(this, "getPreviousValue", (t, e = 1, i = !1) => {
|
|
64
|
+
let s = this.indexOf(t);
|
|
65
|
+
if (s === -1) return null;
|
|
66
|
+
for (s = i ? Math.max(s - e, 0) : s - e; s >= 0 && this.getItemDisabled(this.at(s)); ) s--;
|
|
67
|
+
return this.getItemValue(this.at(s));
|
|
68
|
+
}), r(this, "indexOf", (t) => {
|
|
69
|
+
if (t == null) return -1;
|
|
70
|
+
if (!this.options.groupBy && !this.options.groupSort)
|
|
71
|
+
return this.items.findIndex((s) => this.getItemValue(s) === t);
|
|
72
|
+
let e = 0;
|
|
73
|
+
const i = this.group();
|
|
74
|
+
for (const [, s] of i)
|
|
75
|
+
for (const u of s) {
|
|
76
|
+
if (this.getItemValue(u) === t) return e;
|
|
77
|
+
e++;
|
|
78
|
+
}
|
|
79
|
+
return -1;
|
|
80
|
+
}), r(this, "getByText", (t, e) => {
|
|
81
|
+
let i = e != null ? A(this.items, this.indexOf(e)) : this.items;
|
|
82
|
+
return t.length === 1 && (i = i.filter((u) => this.getItemValue(u) !== e)), i.find((u) => B(this.stringifyItem(u), t));
|
|
83
|
+
}), r(this, "search", (t, e) => {
|
|
84
|
+
const { state: i, currentValue: s, timeout: u = 350 } = e, l = i.keysSoFar + t, f = l.length > 1 && Array.from(l).every((m) => m === l[0]) ? l[0] : l, V = this.getByText(f, s), b = this.getItemValue(V);
|
|
85
|
+
function y() {
|
|
86
|
+
clearTimeout(i.timer), i.timer = -1;
|
|
87
|
+
}
|
|
88
|
+
function I(m) {
|
|
89
|
+
i.keysSoFar = m, y(), m !== "" && (i.timer = +setTimeout(() => {
|
|
90
|
+
I(""), y();
|
|
91
|
+
}, u));
|
|
92
|
+
}
|
|
93
|
+
return I(l), b;
|
|
94
|
+
}), r(this, "update", (t, e) => {
|
|
95
|
+
let i = this.items.findIndex((s) => this.getItemValue(s) === t);
|
|
96
|
+
return i === -1 ? this : this.copy([...this.items.slice(0, i), e, ...this.items.slice(i + 1)]);
|
|
97
|
+
}), r(this, "insert", (t, ...e) => this.copy(a(this.items, t, ...e))), r(this, "insertBefore", (t, ...e) => {
|
|
98
|
+
let i = this.indexOf(t);
|
|
99
|
+
if (i === -1)
|
|
100
|
+
if (this.items.length === 0) i = 0;
|
|
101
|
+
else return this;
|
|
102
|
+
return this.copy(a(this.items, i, ...e));
|
|
103
|
+
}), r(this, "insertAfter", (t, ...e) => {
|
|
104
|
+
let i = this.indexOf(t);
|
|
105
|
+
if (i === -1)
|
|
106
|
+
if (this.items.length === 0) i = 0;
|
|
107
|
+
else return this;
|
|
108
|
+
return this.copy(a(this.items, i + 1, ...e));
|
|
109
|
+
}), r(this, "prepend", (...t) => this.copy(a(this.items, 0, ...t))), r(this, "append", (...t) => this.copy(a(this.items, this.items.length, ...t))), r(this, "filter", (t) => {
|
|
110
|
+
const e = this.items.filter((i, s) => t(this.stringifyItem(i), s));
|
|
111
|
+
return this.copy(e);
|
|
112
|
+
}), r(this, "remove", (...t) => {
|
|
113
|
+
const e = t.map(
|
|
114
|
+
(i) => typeof i == "string" ? i : this.getItemValue(i)
|
|
115
|
+
);
|
|
116
|
+
return this.copy(
|
|
117
|
+
this.items.filter((i) => {
|
|
118
|
+
const s = this.getItemValue(i);
|
|
119
|
+
return s == null ? !1 : !e.includes(s);
|
|
120
|
+
})
|
|
121
|
+
);
|
|
122
|
+
}), r(this, "move", (t, e) => {
|
|
123
|
+
const i = this.indexOf(t);
|
|
124
|
+
return i === -1 ? this : this.copy(g(this.items, [i], e));
|
|
125
|
+
}), r(this, "moveBefore", (t, ...e) => {
|
|
126
|
+
let i = this.items.findIndex((u) => this.getItemValue(u) === t);
|
|
127
|
+
if (i === -1) return this;
|
|
128
|
+
let s = e.map((u) => this.items.findIndex((l) => this.getItemValue(l) === u)).sort((u, l) => u - l);
|
|
129
|
+
return this.copy(g(this.items, s, i));
|
|
130
|
+
}), r(this, "moveAfter", (t, ...e) => {
|
|
131
|
+
let i = this.items.findIndex((u) => this.getItemValue(u) === t);
|
|
132
|
+
if (i === -1) return this;
|
|
133
|
+
let s = e.map((u) => this.items.findIndex((l) => this.getItemValue(l) === u)).sort((u, l) => u - l);
|
|
134
|
+
return this.copy(g(this.items, s, i + 1));
|
|
135
|
+
}), r(this, "reorder", (t, e) => this.copy(g(this.items, [t], e))), r(this, "compareValue", (t, e) => {
|
|
136
|
+
const i = this.indexOf(t), s = this.indexOf(e);
|
|
137
|
+
return i < s ? -1 : i > s ? 1 : 0;
|
|
138
|
+
}), r(this, "range", (t, e) => {
|
|
139
|
+
let i = [], s = t;
|
|
140
|
+
for (; s != null; ) {
|
|
141
|
+
if (this.find(s) && i.push(s), s === e) return i;
|
|
142
|
+
s = this.getNextValue(s);
|
|
143
|
+
}
|
|
144
|
+
return [];
|
|
145
|
+
}), r(this, "getValueRange", (t, e) => t && e ? this.compareValue(t, e) <= 0 ? this.range(t, e) : this.range(e, t) : []), r(this, "toString", () => {
|
|
146
|
+
let t = "";
|
|
147
|
+
for (const e of this.items) {
|
|
148
|
+
const i = this.getItemValue(e), s = this.stringifyItem(e), u = this.getItemDisabled(e), l = [i, s, u].filter(Boolean).join(":");
|
|
149
|
+
t += l + ",";
|
|
150
|
+
}
|
|
151
|
+
return t;
|
|
152
|
+
}), r(this, "toJSON", () => ({
|
|
153
|
+
size: this.size,
|
|
154
|
+
first: this.firstValue,
|
|
155
|
+
last: this.lastValue
|
|
156
|
+
})), this.items = [...h.items];
|
|
111
157
|
}
|
|
112
158
|
/**
|
|
113
159
|
* Returns the number of items in the collection
|
|
@@ -119,85 +165,32 @@ var y = Object.defineProperty, I = (t, e, i) => e in t ? y(t, e, { enumerable: !
|
|
|
119
165
|
* Returns the first value in the collection
|
|
120
166
|
*/
|
|
121
167
|
get firstValue() {
|
|
122
|
-
let
|
|
123
|
-
for (; this.getItemDisabled(this.at(
|
|
124
|
-
return this.getItemValue(this.at(
|
|
168
|
+
let h = 0;
|
|
169
|
+
for (; this.getItemDisabled(this.at(h)); ) h++;
|
|
170
|
+
return this.getItemValue(this.at(h));
|
|
125
171
|
}
|
|
126
172
|
/**
|
|
127
173
|
* Returns the last value in the collection
|
|
128
174
|
*/
|
|
129
175
|
get lastValue() {
|
|
130
|
-
let
|
|
131
|
-
for (; this.getItemDisabled(this.at(
|
|
132
|
-
return this.getItemValue(this.at(
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Returns the next value in the collection
|
|
136
|
-
*/
|
|
137
|
-
getNextValue(t, e = 1, i = !1) {
|
|
138
|
-
let s = this.indexOf(t);
|
|
139
|
-
if (s === -1) return null;
|
|
140
|
-
for (s = i ? Math.min(s + e, this.size - 1) : s + e; s <= this.size && this.getItemDisabled(this.at(s)); ) s++;
|
|
141
|
-
return this.getItemValue(this.at(s));
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Returns the previous value in the collection
|
|
145
|
-
*/
|
|
146
|
-
getPreviousValue(t, e = 1, i = !1) {
|
|
147
|
-
let s = this.indexOf(t);
|
|
148
|
-
if (s === -1) return null;
|
|
149
|
-
for (s = i ? Math.max(s - e, 0) : s - e; s >= 0 && this.getItemDisabled(this.at(s)); ) s--;
|
|
150
|
-
return this.getItemValue(this.at(s));
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Get the index of an item based on its key
|
|
154
|
-
*/
|
|
155
|
-
indexOf(t) {
|
|
156
|
-
return t == null ? -1 : this.items.findIndex((e) => this.getItemValue(e) === t);
|
|
157
|
-
}
|
|
158
|
-
getByText(t, e) {
|
|
159
|
-
let i = e != null ? x(this.items, this.indexOf(e)) : this.items;
|
|
160
|
-
return t.length === 1 && (i = i.filter((n) => this.getItemValue(n) !== e)), i.find((n) => V(this.stringifyItem(n), t));
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Search for a value based on a query
|
|
164
|
-
*/
|
|
165
|
-
search(t, e) {
|
|
166
|
-
const { state: i, currentValue: s, timeout: n = 350 } = e, r = i.keysSoFar + t, m = r.length > 1 && Array.from(r).every((l) => l === r[0]) ? r[0] : r, d = this.getByText(m, s), g = this.getItemValue(d);
|
|
167
|
-
function f() {
|
|
168
|
-
clearTimeout(i.timer), i.timer = -1;
|
|
169
|
-
}
|
|
170
|
-
function o(l) {
|
|
171
|
-
i.keysSoFar = l, f(), l !== "" && (i.timer = +setTimeout(() => {
|
|
172
|
-
o(""), f();
|
|
173
|
-
}, n));
|
|
174
|
-
}
|
|
175
|
-
return o(r), g;
|
|
176
|
+
let h = this.size - 1;
|
|
177
|
+
for (; this.getItemDisabled(this.at(h)); ) h--;
|
|
178
|
+
return this.getItemValue(this.at(h));
|
|
176
179
|
}
|
|
177
180
|
*[Symbol.iterator]() {
|
|
178
181
|
yield* this.items;
|
|
179
182
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
this.items.splice(e, 0, i);
|
|
192
|
-
}
|
|
193
|
-
json() {
|
|
194
|
-
return {
|
|
195
|
-
size: this.size,
|
|
196
|
-
first: this.firstValue,
|
|
197
|
-
last: this.lastValue
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
}, V = (t, e) => !!(t != null && t.toLowerCase().startsWith(e.toLowerCase())), x = (t, e) => t.map((i, s) => t[(Math.max(e, 0) + s) % t.length]);
|
|
183
|
+
}, B = (n, h) => !!(n != null && n.toLowerCase().startsWith(h.toLowerCase())), A = (n, h) => n.map((t, e) => n[(Math.max(h, 0) + e) % n.length]);
|
|
184
|
+
function a(n, h, ...t) {
|
|
185
|
+
return [...n.slice(0, h), ...t, ...n.slice(h)];
|
|
186
|
+
}
|
|
187
|
+
function g(n, h, t) {
|
|
188
|
+
h = [...h].sort((i, s) => i - s);
|
|
189
|
+
const e = h.map((i) => n[i]);
|
|
190
|
+
for (let i = h.length - 1; i >= 0; i--)
|
|
191
|
+
n = [...n.slice(0, h[i]), ...n.slice(h[i] + 1)];
|
|
192
|
+
return t = Math.max(0, t - h.filter((i) => i < t).length), [...n.slice(0, t), ...e, ...n.slice(t)];
|
|
193
|
+
}
|
|
201
194
|
export {
|
|
202
|
-
|
|
195
|
+
w as ListCollection
|
|
203
196
|
};
|