anysystem-design 0.0.6 → 0.0.7
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/combobox-CUB-N452.js +888 -0
- package/dist/components/AutoComplete/AutoComplete.d.ts +14 -0
- package/dist/components/AutoComplete/AutoComplete.js +22 -0
- package/dist/components/AutoComplete/AutoCompleteBase.d.ts +20 -0
- package/dist/components/AutoComplete/AutoCompleteBase.js +113 -0
- package/dist/components/AutoComplete/AutoCompleteMultiple.d.ts +20 -0
- package/dist/components/AutoComplete/AutoCompleteMultiple.js +160 -0
- package/dist/components/AutoComplete/index.d.ts +2 -0
- package/dist/components/AutoComplete/index.js +8 -0
- package/dist/components/Checkbox/CheckboxBase.js +1 -1
- package/dist/components/Icon/Icon.js +1 -1
- package/dist/components/Selectbox/SelectboxBase.js +32 -31
- package/dist/components/Selectbox/SelectboxMultiple.js +105 -3779
- package/dist/components/Selectbox/helper.js +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +38 -32
- package/dist/{index-TmOGnUkt.js → index-DaQhM816.js} +66 -65
- package/dist/index-WJdgKpVa.js +3632 -0
- package/dist/index.css +1 -1
- package/dist/index.js +32 -26
- package/dist/listbox-BoGLpnJ5.js +306 -0
- package/dist/lodash-XYp3qmxI.js +3680 -0
- package/package.json +1 -1
- package/dist/index-BSptVng4.js +0 -3870
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
import { h as $e, i as g, n as q, Z as Ke, ae as Ue, M as Re, W as re, K as qe, j as Ge, l as Je, T as Ye, k as Qe, m as te, F as Ze, z as Xe, v as et, q as tt, r as ce, t as nt, w as le, x as ot, y as de, A as it, N as De, p as st, I as be, G as rt, $ as Fe, C as ke, E as ge, D as lt, J as at, L as ut, U as ct, Y as dt, O as pt, V as ft, P as ht, Q as mt, R as vt, _ as ye, a0 as bt, S as Ce, a1 as gt, af as xt, a2 as we, a3 as St, a6 as _, a7 as F, a9 as It, ag as Ot, ac as Me, ad as Et } from "./index-WJdgKpVa.js";
|
|
2
|
+
import * as ie from "react";
|
|
3
|
+
import $, { useEffect as xe, useRef as N, createContext as Se, useReducer as Tt, createRef as Rt, useCallback as _e, useMemo as G, useId as pe, useContext as Ie, useState as yt, Fragment as Ae } from "react";
|
|
4
|
+
import { r as X } from "./index-DsprzSCj.js";
|
|
5
|
+
function oe(e, s, t) {
|
|
6
|
+
let n = t.initialDeps ?? [], o;
|
|
7
|
+
return () => {
|
|
8
|
+
var l, r, i, a;
|
|
9
|
+
let p;
|
|
10
|
+
t.key && ((l = t.debug) != null && l.call(t)) && (p = Date.now());
|
|
11
|
+
const d = e();
|
|
12
|
+
if (!(d.length !== n.length || d.some((u, S) => n[S] !== u)))
|
|
13
|
+
return o;
|
|
14
|
+
n = d;
|
|
15
|
+
let I;
|
|
16
|
+
if (t.key && ((r = t.debug) != null && r.call(t)) && (I = Date.now()), o = s(...d), t.key && ((i = t.debug) != null && i.call(t))) {
|
|
17
|
+
const u = Math.round((Date.now() - p) * 100) / 100, S = Math.round((Date.now() - I) * 100) / 100, x = S / 16, h = (R, D) => {
|
|
18
|
+
for (R = String(R); R.length < D; )
|
|
19
|
+
R = " " + R;
|
|
20
|
+
return R;
|
|
21
|
+
};
|
|
22
|
+
console.info(
|
|
23
|
+
`%c⏱ ${h(S, 5)} /${h(u, 5)} ms`,
|
|
24
|
+
`
|
|
25
|
+
font-size: .6rem;
|
|
26
|
+
font-weight: bold;
|
|
27
|
+
color: hsl(${Math.max(
|
|
28
|
+
0,
|
|
29
|
+
Math.min(120 - 120 * x, 120)
|
|
30
|
+
)}deg 100% 31%);`,
|
|
31
|
+
t == null ? void 0 : t.key
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return (a = t == null ? void 0 : t.onChange) == null || a.call(t, o), o;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function me(e, s) {
|
|
38
|
+
if (e === void 0)
|
|
39
|
+
throw new Error("Unexpected undefined");
|
|
40
|
+
return e;
|
|
41
|
+
}
|
|
42
|
+
const Ct = (e, s) => Math.abs(e - s) < 1, wt = (e, s, t) => {
|
|
43
|
+
let n;
|
|
44
|
+
return function(...o) {
|
|
45
|
+
e.clearTimeout(n), n = e.setTimeout(() => s.apply(this, o), t);
|
|
46
|
+
};
|
|
47
|
+
}, Mt = (e) => e, _t = (e) => {
|
|
48
|
+
const s = Math.max(e.startIndex - e.overscan, 0), t = Math.min(e.endIndex + e.overscan, e.count - 1), n = [];
|
|
49
|
+
for (let o = s; o <= t; o++)
|
|
50
|
+
n.push(o);
|
|
51
|
+
return n;
|
|
52
|
+
}, Pt = (e, s) => {
|
|
53
|
+
const t = e.scrollElement;
|
|
54
|
+
if (!t)
|
|
55
|
+
return;
|
|
56
|
+
const n = e.targetWindow;
|
|
57
|
+
if (!n)
|
|
58
|
+
return;
|
|
59
|
+
const o = (r) => {
|
|
60
|
+
const { width: i, height: a } = r;
|
|
61
|
+
s({ width: Math.round(i), height: Math.round(a) });
|
|
62
|
+
};
|
|
63
|
+
if (o(t.getBoundingClientRect()), !n.ResizeObserver)
|
|
64
|
+
return () => {
|
|
65
|
+
};
|
|
66
|
+
const l = new n.ResizeObserver((r) => {
|
|
67
|
+
const i = r[0];
|
|
68
|
+
if (i != null && i.borderBoxSize) {
|
|
69
|
+
const a = i.borderBoxSize[0];
|
|
70
|
+
if (a) {
|
|
71
|
+
o({ width: a.inlineSize, height: a.blockSize });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
o(t.getBoundingClientRect());
|
|
76
|
+
});
|
|
77
|
+
return l.observe(t, { box: "border-box" }), () => {
|
|
78
|
+
l.unobserve(t);
|
|
79
|
+
};
|
|
80
|
+
}, Pe = {
|
|
81
|
+
passive: !0
|
|
82
|
+
}, zt = typeof window > "u" ? !0 : "onscrollend" in window, $t = (e, s) => {
|
|
83
|
+
const t = e.scrollElement;
|
|
84
|
+
if (!t)
|
|
85
|
+
return;
|
|
86
|
+
const n = e.targetWindow;
|
|
87
|
+
if (!n)
|
|
88
|
+
return;
|
|
89
|
+
let o = 0;
|
|
90
|
+
const l = zt ? () => {
|
|
91
|
+
} : wt(
|
|
92
|
+
n,
|
|
93
|
+
() => {
|
|
94
|
+
s(o, !1);
|
|
95
|
+
},
|
|
96
|
+
e.options.isScrollingResetDelay
|
|
97
|
+
), r = (p) => () => {
|
|
98
|
+
o = t[e.options.horizontal ? "scrollLeft" : "scrollTop"], l(), s(o, p);
|
|
99
|
+
}, i = r(!0), a = r(!1);
|
|
100
|
+
return a(), t.addEventListener("scroll", i, Pe), t.addEventListener("scrollend", a, Pe), () => {
|
|
101
|
+
t.removeEventListener("scroll", i), t.removeEventListener("scrollend", a);
|
|
102
|
+
};
|
|
103
|
+
}, Dt = (e, s, t) => {
|
|
104
|
+
if (s != null && s.borderBoxSize) {
|
|
105
|
+
const n = s.borderBoxSize[0];
|
|
106
|
+
if (n)
|
|
107
|
+
return Math.round(
|
|
108
|
+
n[t.options.horizontal ? "inlineSize" : "blockSize"]
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
return Math.round(
|
|
112
|
+
e.getBoundingClientRect()[t.options.horizontal ? "width" : "height"]
|
|
113
|
+
);
|
|
114
|
+
}, Ft = (e, {
|
|
115
|
+
adjustments: s = 0,
|
|
116
|
+
behavior: t
|
|
117
|
+
}, n) => {
|
|
118
|
+
var o, l;
|
|
119
|
+
const r = e + s;
|
|
120
|
+
(l = (o = n.scrollElement) == null ? void 0 : o.scrollTo) == null || l.call(o, {
|
|
121
|
+
[n.options.horizontal ? "left" : "top"]: r,
|
|
122
|
+
behavior: t
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
class kt {
|
|
126
|
+
constructor(s) {
|
|
127
|
+
this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollToIndexTimeoutId = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
|
|
128
|
+
let t = null;
|
|
129
|
+
const n = () => t || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : t = new this.targetWindow.ResizeObserver((o) => {
|
|
130
|
+
o.forEach((l) => {
|
|
131
|
+
this._measureElement(l.target, l);
|
|
132
|
+
});
|
|
133
|
+
}));
|
|
134
|
+
return {
|
|
135
|
+
disconnect: () => {
|
|
136
|
+
var o;
|
|
137
|
+
return (o = n()) == null ? void 0 : o.disconnect();
|
|
138
|
+
},
|
|
139
|
+
observe: (o) => {
|
|
140
|
+
var l;
|
|
141
|
+
return (l = n()) == null ? void 0 : l.observe(o, { box: "border-box" });
|
|
142
|
+
},
|
|
143
|
+
unobserve: (o) => {
|
|
144
|
+
var l;
|
|
145
|
+
return (l = n()) == null ? void 0 : l.unobserve(o);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
})(), this.range = null, this.setOptions = (t) => {
|
|
149
|
+
Object.entries(t).forEach(([n, o]) => {
|
|
150
|
+
typeof o > "u" && delete t[n];
|
|
151
|
+
}), this.options = {
|
|
152
|
+
debug: !1,
|
|
153
|
+
initialOffset: 0,
|
|
154
|
+
overscan: 1,
|
|
155
|
+
paddingStart: 0,
|
|
156
|
+
paddingEnd: 0,
|
|
157
|
+
scrollPaddingStart: 0,
|
|
158
|
+
scrollPaddingEnd: 0,
|
|
159
|
+
horizontal: !1,
|
|
160
|
+
getItemKey: Mt,
|
|
161
|
+
rangeExtractor: _t,
|
|
162
|
+
onChange: () => {
|
|
163
|
+
},
|
|
164
|
+
measureElement: Dt,
|
|
165
|
+
initialRect: { width: 0, height: 0 },
|
|
166
|
+
scrollMargin: 0,
|
|
167
|
+
gap: 0,
|
|
168
|
+
indexAttribute: "data-index",
|
|
169
|
+
initialMeasurementsCache: [],
|
|
170
|
+
lanes: 1,
|
|
171
|
+
isScrollingResetDelay: 150,
|
|
172
|
+
enabled: !0,
|
|
173
|
+
...t
|
|
174
|
+
};
|
|
175
|
+
}, this.notify = (t, n) => {
|
|
176
|
+
var o, l;
|
|
177
|
+
const { startIndex: r, endIndex: i } = this.range ?? {
|
|
178
|
+
startIndex: void 0,
|
|
179
|
+
endIndex: void 0
|
|
180
|
+
}, a = this.calculateRange();
|
|
181
|
+
(t || r !== (a == null ? void 0 : a.startIndex) || i !== (a == null ? void 0 : a.endIndex)) && ((l = (o = this.options).onChange) == null || l.call(o, this, n));
|
|
182
|
+
}, this.cleanup = () => {
|
|
183
|
+
this.unsubs.filter(Boolean).forEach((t) => t()), this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.observer.disconnect(), this.elementsCache.clear();
|
|
184
|
+
}, this._didMount = () => () => {
|
|
185
|
+
this.cleanup();
|
|
186
|
+
}, this._willUpdate = () => {
|
|
187
|
+
var t;
|
|
188
|
+
const n = this.options.enabled ? this.options.getScrollElement() : null;
|
|
189
|
+
if (this.scrollElement !== n) {
|
|
190
|
+
if (this.cleanup(), !n) {
|
|
191
|
+
this.notify(!1, !1);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
this.scrollElement = n, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((t = this.scrollElement) == null ? void 0 : t.window) ?? null, this._scrollToOffset(this.getScrollOffset(), {
|
|
195
|
+
adjustments: void 0,
|
|
196
|
+
behavior: void 0
|
|
197
|
+
}), this.unsubs.push(
|
|
198
|
+
this.options.observeElementRect(this, (o) => {
|
|
199
|
+
this.scrollRect = o, this.notify(!1, !1);
|
|
200
|
+
})
|
|
201
|
+
), this.unsubs.push(
|
|
202
|
+
this.options.observeElementOffset(this, (o, l) => {
|
|
203
|
+
this.scrollAdjustments = 0, this.scrollDirection = l ? this.getScrollOffset() < o ? "forward" : "backward" : null, this.scrollOffset = o;
|
|
204
|
+
const r = this.isScrolling;
|
|
205
|
+
this.isScrolling = l, this.notify(r !== l, l);
|
|
206
|
+
})
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (t, n) => {
|
|
210
|
+
const o = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
211
|
+
for (let r = n - 1; r >= 0; r--) {
|
|
212
|
+
const i = t[r];
|
|
213
|
+
if (o.has(i.lane))
|
|
214
|
+
continue;
|
|
215
|
+
const a = l.get(
|
|
216
|
+
i.lane
|
|
217
|
+
);
|
|
218
|
+
if (a == null || i.end > a.end ? l.set(i.lane, i) : i.end < a.end && o.set(i.lane, !0), o.size === this.options.lanes)
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
return l.size === this.options.lanes ? Array.from(l.values()).sort((r, i) => r.end === i.end ? r.index - i.index : r.end - i.end)[0] : void 0;
|
|
222
|
+
}, this.getMeasurementOptions = oe(
|
|
223
|
+
() => [
|
|
224
|
+
this.options.count,
|
|
225
|
+
this.options.paddingStart,
|
|
226
|
+
this.options.scrollMargin,
|
|
227
|
+
this.options.getItemKey,
|
|
228
|
+
this.options.enabled
|
|
229
|
+
],
|
|
230
|
+
(t, n, o, l, r) => (this.pendingMeasuredCacheIndexes = [], {
|
|
231
|
+
count: t,
|
|
232
|
+
paddingStart: n,
|
|
233
|
+
scrollMargin: o,
|
|
234
|
+
getItemKey: l,
|
|
235
|
+
enabled: r
|
|
236
|
+
}),
|
|
237
|
+
{
|
|
238
|
+
key: !1
|
|
239
|
+
}
|
|
240
|
+
), this.getMeasurements = oe(
|
|
241
|
+
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
|
242
|
+
({ count: t, paddingStart: n, scrollMargin: o, getItemKey: l, enabled: r }, i) => {
|
|
243
|
+
var a;
|
|
244
|
+
if (!r)
|
|
245
|
+
return this.measurementsCache = [], this.itemSizeCache.clear(), [];
|
|
246
|
+
this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((c) => {
|
|
247
|
+
this.itemSizeCache.set(c.key, c.size);
|
|
248
|
+
}));
|
|
249
|
+
const p = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
|
250
|
+
this.pendingMeasuredCacheIndexes = [];
|
|
251
|
+
const d = this.measurementsCache.slice(0, p);
|
|
252
|
+
for (let c = p; c < t; c++) {
|
|
253
|
+
let I = (a = this.measurementsCache[c]) == null ? void 0 : a.measureElement;
|
|
254
|
+
I || (I = (E) => {
|
|
255
|
+
const y = l(c), O = this.elementsCache.get(y);
|
|
256
|
+
if (!E) {
|
|
257
|
+
O && (this.observer.unobserve(O), this.elementsCache.delete(y));
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
O !== E && (O && this.observer.unobserve(O), this.observer.observe(E), this.elementsCache.set(y, E)), E.isConnected && this.resizeItem(
|
|
261
|
+
c,
|
|
262
|
+
this.options.measureElement(E, void 0, this)
|
|
263
|
+
);
|
|
264
|
+
});
|
|
265
|
+
const u = l(c), S = this.options.lanes === 1 ? d[c - 1] : this.getFurthestMeasurement(d, c), x = S ? S.end + this.options.gap : n + o, h = i.get(u), R = typeof h == "number" ? h : this.options.estimateSize(c), D = x + R, M = S ? S.lane : c % this.options.lanes;
|
|
266
|
+
d[c] = {
|
|
267
|
+
index: c,
|
|
268
|
+
start: x,
|
|
269
|
+
size: R,
|
|
270
|
+
end: D,
|
|
271
|
+
key: u,
|
|
272
|
+
lane: M,
|
|
273
|
+
measureElement: I
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
return this.measurementsCache = d, d;
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
|
280
|
+
debug: () => this.options.debug
|
|
281
|
+
}
|
|
282
|
+
), this.calculateRange = oe(
|
|
283
|
+
() => [this.getMeasurements(), this.getSize(), this.getScrollOffset()],
|
|
284
|
+
(t, n, o) => this.range = t.length > 0 && n > 0 ? At({
|
|
285
|
+
measurements: t,
|
|
286
|
+
outerSize: n,
|
|
287
|
+
scrollOffset: o
|
|
288
|
+
}) : null,
|
|
289
|
+
{
|
|
290
|
+
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
|
291
|
+
debug: () => this.options.debug
|
|
292
|
+
}
|
|
293
|
+
), this.getIndexes = oe(
|
|
294
|
+
() => [
|
|
295
|
+
this.options.rangeExtractor,
|
|
296
|
+
this.calculateRange(),
|
|
297
|
+
this.options.overscan,
|
|
298
|
+
this.options.count
|
|
299
|
+
],
|
|
300
|
+
(t, n, o, l) => n === null ? [] : t({
|
|
301
|
+
startIndex: n.startIndex,
|
|
302
|
+
endIndex: n.endIndex,
|
|
303
|
+
overscan: o,
|
|
304
|
+
count: l
|
|
305
|
+
}),
|
|
306
|
+
{
|
|
307
|
+
key: process.env.NODE_ENV !== "production" && "getIndexes",
|
|
308
|
+
debug: () => this.options.debug
|
|
309
|
+
}
|
|
310
|
+
), this.indexFromElement = (t) => {
|
|
311
|
+
const n = this.options.indexAttribute, o = t.getAttribute(n);
|
|
312
|
+
return o ? parseInt(o, 10) : (console.warn(
|
|
313
|
+
`Missing attribute name '${n}={index}' on measured element.`
|
|
314
|
+
), -1);
|
|
315
|
+
}, this._measureElement = (t, n) => {
|
|
316
|
+
const o = this.indexFromElement(t), l = this.getMeasurements()[o];
|
|
317
|
+
if (!l || !t.isConnected) {
|
|
318
|
+
this.elementsCache.forEach((i, a) => {
|
|
319
|
+
i === t && (this.observer.unobserve(t), this.elementsCache.delete(a));
|
|
320
|
+
});
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const r = this.elementsCache.get(l.key);
|
|
324
|
+
r !== t && (r && this.observer.unobserve(r), this.observer.observe(t), this.elementsCache.set(l.key, t)), this.resizeItem(o, this.options.measureElement(t, n, this));
|
|
325
|
+
}, this.resizeItem = (t, n) => {
|
|
326
|
+
const o = this.getMeasurements()[t];
|
|
327
|
+
if (!o)
|
|
328
|
+
return;
|
|
329
|
+
const l = this.itemSizeCache.get(o.key) ?? o.size, r = n - l;
|
|
330
|
+
r !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(o, r, this) : o.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", r), this._scrollToOffset(this.getScrollOffset(), {
|
|
331
|
+
adjustments: this.scrollAdjustments += r,
|
|
332
|
+
behavior: void 0
|
|
333
|
+
})), this.pendingMeasuredCacheIndexes.push(o.index), this.itemSizeCache = new Map(this.itemSizeCache.set(o.key, n)), this.notify(!0, !1));
|
|
334
|
+
}, this.measureElement = (t) => {
|
|
335
|
+
t && this._measureElement(t, void 0);
|
|
336
|
+
}, this.getVirtualItems = oe(
|
|
337
|
+
() => [this.getIndexes(), this.getMeasurements()],
|
|
338
|
+
(t, n) => {
|
|
339
|
+
const o = [];
|
|
340
|
+
for (let l = 0, r = t.length; l < r; l++) {
|
|
341
|
+
const i = t[l], a = n[i];
|
|
342
|
+
o.push(a);
|
|
343
|
+
}
|
|
344
|
+
return o;
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
key: process.env.NODE_ENV !== "production" && "getIndexes",
|
|
348
|
+
debug: () => this.options.debug
|
|
349
|
+
}
|
|
350
|
+
), this.getVirtualItemForOffset = (t) => {
|
|
351
|
+
const n = this.getMeasurements();
|
|
352
|
+
if (n.length !== 0)
|
|
353
|
+
return me(
|
|
354
|
+
n[Le(
|
|
355
|
+
0,
|
|
356
|
+
n.length - 1,
|
|
357
|
+
(o) => me(n[o]).start,
|
|
358
|
+
t
|
|
359
|
+
)]
|
|
360
|
+
);
|
|
361
|
+
}, this.getOffsetForAlignment = (t, n) => {
|
|
362
|
+
const o = this.getSize(), l = this.getScrollOffset();
|
|
363
|
+
n === "auto" && (t <= l ? n = "start" : t >= l + o ? n = "end" : n = "start"), n === "start" ? t = t : n === "end" ? t = t - o : n === "center" && (t = t - o / 2);
|
|
364
|
+
const r = this.options.horizontal ? "scrollWidth" : "scrollHeight", a = (this.scrollElement ? "document" in this.scrollElement ? this.scrollElement.document.documentElement[r] : this.scrollElement[r] : 0) - o;
|
|
365
|
+
return Math.max(Math.min(a, t), 0);
|
|
366
|
+
}, this.getOffsetForIndex = (t, n = "auto") => {
|
|
367
|
+
t = Math.max(0, Math.min(t, this.options.count - 1));
|
|
368
|
+
const o = this.getMeasurements()[t];
|
|
369
|
+
if (!o)
|
|
370
|
+
return;
|
|
371
|
+
const l = this.getSize(), r = this.getScrollOffset();
|
|
372
|
+
if (n === "auto")
|
|
373
|
+
if (o.end >= r + l - this.options.scrollPaddingEnd)
|
|
374
|
+
n = "end";
|
|
375
|
+
else if (o.start <= r + this.options.scrollPaddingStart)
|
|
376
|
+
n = "start";
|
|
377
|
+
else
|
|
378
|
+
return [r, n];
|
|
379
|
+
const i = n === "end" ? o.end + this.options.scrollPaddingEnd : o.start - this.options.scrollPaddingStart;
|
|
380
|
+
return [this.getOffsetForAlignment(i, n), n];
|
|
381
|
+
}, this.isDynamicMode = () => this.elementsCache.size > 0, this.cancelScrollToIndex = () => {
|
|
382
|
+
this.scrollToIndexTimeoutId !== null && this.targetWindow && (this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId), this.scrollToIndexTimeoutId = null);
|
|
383
|
+
}, this.scrollToOffset = (t, { align: n = "start", behavior: o } = {}) => {
|
|
384
|
+
this.cancelScrollToIndex(), o === "smooth" && this.isDynamicMode() && console.warn(
|
|
385
|
+
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
386
|
+
), this._scrollToOffset(this.getOffsetForAlignment(t, n), {
|
|
387
|
+
adjustments: void 0,
|
|
388
|
+
behavior: o
|
|
389
|
+
});
|
|
390
|
+
}, this.scrollToIndex = (t, { align: n = "auto", behavior: o } = {}) => {
|
|
391
|
+
t = Math.max(0, Math.min(t, this.options.count - 1)), this.cancelScrollToIndex(), o === "smooth" && this.isDynamicMode() && console.warn(
|
|
392
|
+
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
393
|
+
);
|
|
394
|
+
const l = this.getOffsetForIndex(t, n);
|
|
395
|
+
if (!l) return;
|
|
396
|
+
const [r, i] = l;
|
|
397
|
+
this._scrollToOffset(r, { adjustments: void 0, behavior: o }), o !== "smooth" && this.isDynamicMode() && this.targetWindow && (this.scrollToIndexTimeoutId = this.targetWindow.setTimeout(() => {
|
|
398
|
+
if (this.scrollToIndexTimeoutId = null, this.elementsCache.has(
|
|
399
|
+
this.options.getItemKey(t)
|
|
400
|
+
)) {
|
|
401
|
+
const [p] = me(
|
|
402
|
+
this.getOffsetForIndex(t, i)
|
|
403
|
+
);
|
|
404
|
+
Ct(p, this.getScrollOffset()) || this.scrollToIndex(t, { align: i, behavior: o });
|
|
405
|
+
} else
|
|
406
|
+
this.scrollToIndex(t, { align: i, behavior: o });
|
|
407
|
+
}));
|
|
408
|
+
}, this.scrollBy = (t, { behavior: n } = {}) => {
|
|
409
|
+
this.cancelScrollToIndex(), n === "smooth" && this.isDynamicMode() && console.warn(
|
|
410
|
+
"The `smooth` scroll behavior is not fully supported with dynamic size."
|
|
411
|
+
), this._scrollToOffset(this.getScrollOffset() + t, {
|
|
412
|
+
adjustments: void 0,
|
|
413
|
+
behavior: n
|
|
414
|
+
});
|
|
415
|
+
}, this.getTotalSize = () => {
|
|
416
|
+
var t;
|
|
417
|
+
const n = this.getMeasurements();
|
|
418
|
+
let o;
|
|
419
|
+
return n.length === 0 ? o = this.options.paddingStart : o = this.options.lanes === 1 ? ((t = n[n.length - 1]) == null ? void 0 : t.end) ?? 0 : Math.max(
|
|
420
|
+
...n.slice(-this.options.lanes).map((l) => l.end)
|
|
421
|
+
), o - this.options.scrollMargin + this.options.paddingEnd;
|
|
422
|
+
}, this._scrollToOffset = (t, {
|
|
423
|
+
adjustments: n,
|
|
424
|
+
behavior: o
|
|
425
|
+
}) => {
|
|
426
|
+
this.options.scrollToFn(t, { behavior: o, adjustments: n }, this);
|
|
427
|
+
}, this.measure = () => {
|
|
428
|
+
var t, n;
|
|
429
|
+
this.itemSizeCache = /* @__PURE__ */ new Map(), (n = (t = this.options).onChange) == null || n.call(t, this, !1);
|
|
430
|
+
}, this.setOptions(s);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
const Le = (e, s, t, n) => {
|
|
434
|
+
for (; e <= s; ) {
|
|
435
|
+
const o = (e + s) / 2 | 0, l = t(o);
|
|
436
|
+
if (l < n)
|
|
437
|
+
e = o + 1;
|
|
438
|
+
else if (l > n)
|
|
439
|
+
s = o - 1;
|
|
440
|
+
else
|
|
441
|
+
return o;
|
|
442
|
+
}
|
|
443
|
+
return e > 0 ? e - 1 : 0;
|
|
444
|
+
};
|
|
445
|
+
function At({
|
|
446
|
+
measurements: e,
|
|
447
|
+
outerSize: s,
|
|
448
|
+
scrollOffset: t
|
|
449
|
+
}) {
|
|
450
|
+
const n = e.length - 1, l = Le(0, n, (i) => e[i].start, t);
|
|
451
|
+
let r = l;
|
|
452
|
+
for (; r < n && e[r].end < t + s; )
|
|
453
|
+
r++;
|
|
454
|
+
return { startIndex: l, endIndex: r };
|
|
455
|
+
}
|
|
456
|
+
const Lt = typeof document < "u" ? ie.useLayoutEffect : ie.useEffect;
|
|
457
|
+
function Nt(e) {
|
|
458
|
+
const s = ie.useReducer(() => ({}), {})[1], t = {
|
|
459
|
+
...e,
|
|
460
|
+
onChange: (o, l) => {
|
|
461
|
+
var r;
|
|
462
|
+
l ? X.flushSync(s) : s(), (r = e.onChange) == null || r.call(e, o, l);
|
|
463
|
+
}
|
|
464
|
+
}, [n] = ie.useState(
|
|
465
|
+
() => new kt(t)
|
|
466
|
+
);
|
|
467
|
+
return n.setOptions(t), ie.useEffect(() => n._didMount(), []), Lt(() => n._willUpdate()), n;
|
|
468
|
+
}
|
|
469
|
+
function Vt(e) {
|
|
470
|
+
return Nt({
|
|
471
|
+
observeElementRect: Pt,
|
|
472
|
+
observeElementOffset: $t,
|
|
473
|
+
scrollToFn: Ft,
|
|
474
|
+
...e
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function Bt(e, s, t, n) {
|
|
478
|
+
let o = $e(t);
|
|
479
|
+
xe(() => {
|
|
480
|
+
e = e ?? window;
|
|
481
|
+
function l(r) {
|
|
482
|
+
o.current(r);
|
|
483
|
+
}
|
|
484
|
+
return e.addEventListener(s, l, n), () => e.removeEventListener(s, l, n);
|
|
485
|
+
}, [e, s, n]);
|
|
486
|
+
}
|
|
487
|
+
function Ne(e) {
|
|
488
|
+
let s = N({ value: "", selectionStart: null, selectionEnd: null });
|
|
489
|
+
return Bt(e.current, "blur", (t) => {
|
|
490
|
+
let n = t.target;
|
|
491
|
+
n instanceof HTMLInputElement && (s.current = { value: n.value, selectionStart: n.selectionStart, selectionEnd: n.selectionEnd });
|
|
492
|
+
}), g(() => {
|
|
493
|
+
let t = e.current;
|
|
494
|
+
if (document.activeElement !== t && t instanceof HTMLInputElement && t.isConnected) {
|
|
495
|
+
if (t.focus({ preventScroll: !0 }), t.value !== s.current.value) t.setSelectionRange(t.value.length, t.value.length);
|
|
496
|
+
else {
|
|
497
|
+
let { selectionStart: n, selectionEnd: o } = s.current;
|
|
498
|
+
n !== null && o !== null && t.setSelectionRange(n, o);
|
|
499
|
+
}
|
|
500
|
+
s.current = { value: "", selectionStart: null, selectionEnd: null };
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
function Wt(e, { container: s, accept: t, walk: n }) {
|
|
505
|
+
let o = N(t), l = N(n);
|
|
506
|
+
xe(() => {
|
|
507
|
+
o.current = t, l.current = n;
|
|
508
|
+
}, [t, n]), q(() => {
|
|
509
|
+
if (!s || !e) return;
|
|
510
|
+
let r = Ke(s);
|
|
511
|
+
if (!r) return;
|
|
512
|
+
let i = o.current, a = l.current, p = Object.assign((c) => i(c), { acceptNode: i }), d = r.createTreeWalker(s, NodeFilter.SHOW_ELEMENT, p, !1);
|
|
513
|
+
for (; d.nextNode(); ) a(d.currentNode);
|
|
514
|
+
}, [s, e, o, l]);
|
|
515
|
+
}
|
|
516
|
+
function ze(e, s) {
|
|
517
|
+
let t = N([]), n = g(e);
|
|
518
|
+
xe(() => {
|
|
519
|
+
let o = [...t.current];
|
|
520
|
+
for (let [l, r] of s.entries()) if (t.current[l] !== r) {
|
|
521
|
+
let i = n(s, o);
|
|
522
|
+
return t.current = s, i;
|
|
523
|
+
}
|
|
524
|
+
}, [n, ...s]);
|
|
525
|
+
}
|
|
526
|
+
function jt(e) {
|
|
527
|
+
function s() {
|
|
528
|
+
document.readyState !== "loading" && (e(), document.removeEventListener("DOMContentLoaded", s));
|
|
529
|
+
}
|
|
530
|
+
typeof window < "u" && typeof document < "u" && (document.addEventListener("DOMContentLoaded", s), s());
|
|
531
|
+
}
|
|
532
|
+
let Z = [];
|
|
533
|
+
jt(() => {
|
|
534
|
+
function e(s) {
|
|
535
|
+
if (!(s.target instanceof HTMLElement) || s.target === document.body || Z[0] === s.target) return;
|
|
536
|
+
let t = s.target;
|
|
537
|
+
t = t.closest(Ue), Z.unshift(t ?? s.target), Z = Z.filter((n) => n != null && n.isConnected), Z.splice(10);
|
|
538
|
+
}
|
|
539
|
+
window.addEventListener("click", e, { capture: !0 }), window.addEventListener("mousedown", e, { capture: !0 }), window.addEventListener("focus", e, { capture: !0 }), document.body.addEventListener("click", e, { capture: !0 }), document.body.addEventListener("mousedown", e, { capture: !0 }), document.body.addEventListener("focus", e, { capture: !0 });
|
|
540
|
+
});
|
|
541
|
+
var Oe = ((e) => (e[e.Left = 0] = "Left", e[e.Right = 2] = "Right", e))(Oe || {}), Ht = ((e) => (e[e.Open = 0] = "Open", e[e.Closed = 1] = "Closed", e))(Ht || {}), Kt = ((e) => (e[e.Single = 0] = "Single", e[e.Multi = 1] = "Multi", e))(Kt || {}), Ut = ((e) => (e[e.Pointer = 0] = "Pointer", e[e.Focus = 1] = "Focus", e[e.Other = 2] = "Other", e))(Ut || {}), qt = ((e) => (e[e.OpenCombobox = 0] = "OpenCombobox", e[e.CloseCombobox = 1] = "CloseCombobox", e[e.GoToOption = 2] = "GoToOption", e[e.SetTyping = 3] = "SetTyping", e[e.RegisterOption = 4] = "RegisterOption", e[e.UnregisterOption = 5] = "UnregisterOption", e[e.SetActivationTrigger = 6] = "SetActivationTrigger", e[e.UpdateVirtualConfiguration = 7] = "UpdateVirtualConfiguration", e))(qt || {});
|
|
542
|
+
function ve(e, s = (t) => t) {
|
|
543
|
+
let t = e.activeOptionIndex !== null ? e.options[e.activeOptionIndex] : null, n = s(e.options.slice()), o = n.length > 0 && n[0].dataRef.current.order !== null ? n.sort((r, i) => r.dataRef.current.order - i.dataRef.current.order) : Et(n, (r) => r.dataRef.current.domRef.current), l = t ? o.indexOf(t) : null;
|
|
544
|
+
return l === -1 && (l = null), { options: o, activeOptionIndex: l };
|
|
545
|
+
}
|
|
546
|
+
let Gt = { 1(e) {
|
|
547
|
+
var s;
|
|
548
|
+
return (s = e.dataRef.current) != null && s.disabled || e.comboboxState === 1 ? e : { ...e, activeOptionIndex: null, comboboxState: 1, isTyping: !1, activationTrigger: 2, __demoMode: !1 };
|
|
549
|
+
}, 0(e) {
|
|
550
|
+
var s, t;
|
|
551
|
+
if ((s = e.dataRef.current) != null && s.disabled || e.comboboxState === 0) return e;
|
|
552
|
+
if ((t = e.dataRef.current) != null && t.value) {
|
|
553
|
+
let n = e.dataRef.current.calculateIndex(e.dataRef.current.value);
|
|
554
|
+
if (n !== -1) return { ...e, activeOptionIndex: n, comboboxState: 0, __demoMode: !1 };
|
|
555
|
+
}
|
|
556
|
+
return { ...e, comboboxState: 0, __demoMode: !1 };
|
|
557
|
+
}, 3(e, s) {
|
|
558
|
+
return e.isTyping === s.isTyping ? e : { ...e, isTyping: s.isTyping };
|
|
559
|
+
}, 2(e, s) {
|
|
560
|
+
var t, n, o, l, r;
|
|
561
|
+
if ((t = e.dataRef.current) != null && t.disabled || (n = e.dataRef.current) != null && n.optionsRef.current && !((o = e.dataRef.current) != null && o.optionsPropsRef.current.static) && e.comboboxState === 1) return e;
|
|
562
|
+
if (e.virtual) {
|
|
563
|
+
let { options: d, disabled: c } = e.virtual, I = s.focus === _.Specific ? s.idx : Me(s, { resolveItems: () => d, resolveActiveIndex: () => {
|
|
564
|
+
var S, x;
|
|
565
|
+
return (x = (S = e.activeOptionIndex) != null ? S : d.findIndex((h) => !c(h))) != null ? x : null;
|
|
566
|
+
}, resolveDisabled: c, resolveId() {
|
|
567
|
+
throw new Error("Function not implemented.");
|
|
568
|
+
} }), u = (l = s.trigger) != null ? l : 2;
|
|
569
|
+
return e.activeOptionIndex === I && e.activationTrigger === u ? e : { ...e, activeOptionIndex: I, activationTrigger: u, isTyping: !1, __demoMode: !1 };
|
|
570
|
+
}
|
|
571
|
+
let i = ve(e);
|
|
572
|
+
if (i.activeOptionIndex === null) {
|
|
573
|
+
let d = i.options.findIndex((c) => !c.dataRef.current.disabled);
|
|
574
|
+
d !== -1 && (i.activeOptionIndex = d);
|
|
575
|
+
}
|
|
576
|
+
let a = s.focus === _.Specific ? s.idx : Me(s, { resolveItems: () => i.options, resolveActiveIndex: () => i.activeOptionIndex, resolveId: (d) => d.id, resolveDisabled: (d) => d.dataRef.current.disabled }), p = (r = s.trigger) != null ? r : 2;
|
|
577
|
+
return e.activeOptionIndex === a && e.activationTrigger === p ? e : { ...e, ...i, isTyping: !1, activeOptionIndex: a, activationTrigger: p, __demoMode: !1 };
|
|
578
|
+
}, 4: (e, s) => {
|
|
579
|
+
var t, n, o;
|
|
580
|
+
if ((t = e.dataRef.current) != null && t.virtual) return { ...e, options: [...e.options, s.payload] };
|
|
581
|
+
let l = s.payload, r = ve(e, (a) => (a.push(l), a));
|
|
582
|
+
e.activeOptionIndex === null && (n = e.dataRef.current) != null && n.isSelected(s.payload.dataRef.current.value) && (r.activeOptionIndex = r.options.indexOf(l));
|
|
583
|
+
let i = { ...e, ...r, activationTrigger: 2 };
|
|
584
|
+
return (o = e.dataRef.current) != null && o.__demoMode && e.dataRef.current.value === void 0 && (i.activeOptionIndex = 0), i;
|
|
585
|
+
}, 5: (e, s) => {
|
|
586
|
+
var t;
|
|
587
|
+
if ((t = e.dataRef.current) != null && t.virtual) return { ...e, options: e.options.filter((o) => o.id !== s.id) };
|
|
588
|
+
let n = ve(e, (o) => {
|
|
589
|
+
let l = o.findIndex((r) => r.id === s.id);
|
|
590
|
+
return l !== -1 && o.splice(l, 1), o;
|
|
591
|
+
});
|
|
592
|
+
return { ...e, ...n, activationTrigger: 2 };
|
|
593
|
+
}, 6: (e, s) => e.activationTrigger === s.trigger ? e : { ...e, activationTrigger: s.trigger }, 7: (e, s) => {
|
|
594
|
+
var t, n;
|
|
595
|
+
if (e.virtual === null) return { ...e, virtual: { options: s.options, disabled: (t = s.disabled) != null ? t : () => !1 } };
|
|
596
|
+
if (e.virtual.options === s.options && e.virtual.disabled === s.disabled) return e;
|
|
597
|
+
let o = e.activeOptionIndex;
|
|
598
|
+
if (e.activeOptionIndex !== null) {
|
|
599
|
+
let l = s.options.indexOf(e.virtual.options[e.activeOptionIndex]);
|
|
600
|
+
l !== -1 ? o = l : o = null;
|
|
601
|
+
}
|
|
602
|
+
return { ...e, activeOptionIndex: o, virtual: { options: s.options, disabled: (n = s.disabled) != null ? n : () => !1 } };
|
|
603
|
+
} }, Ee = Se(null);
|
|
604
|
+
Ee.displayName = "ComboboxActionsContext";
|
|
605
|
+
function ae(e) {
|
|
606
|
+
let s = Ie(Ee);
|
|
607
|
+
if (s === null) {
|
|
608
|
+
let t = new Error(`<${e} /> is missing a parent <Combobox /> component.`);
|
|
609
|
+
throw Error.captureStackTrace && Error.captureStackTrace(t, ae), t;
|
|
610
|
+
}
|
|
611
|
+
return s;
|
|
612
|
+
}
|
|
613
|
+
let Ve = Se(null);
|
|
614
|
+
function Jt(e) {
|
|
615
|
+
let s = ne("VirtualProvider"), { options: t } = s.virtual, [n, o] = G(() => {
|
|
616
|
+
let p = s.optionsRef.current;
|
|
617
|
+
if (!p) return [0, 0];
|
|
618
|
+
let d = window.getComputedStyle(p);
|
|
619
|
+
return [parseFloat(d.paddingBlockStart || d.paddingTop), parseFloat(d.paddingBlockEnd || d.paddingBottom)];
|
|
620
|
+
}, [s.optionsRef.current]), l = Vt({ enabled: t.length !== 0, scrollPaddingStart: n, scrollPaddingEnd: o, count: t.length, estimateSize() {
|
|
621
|
+
return 40;
|
|
622
|
+
}, getScrollElement() {
|
|
623
|
+
var p;
|
|
624
|
+
return (p = s.optionsRef.current) != null ? p : null;
|
|
625
|
+
}, overscan: 12 }), [r, i] = yt(0);
|
|
626
|
+
q(() => {
|
|
627
|
+
i((p) => p + 1);
|
|
628
|
+
}, [t]);
|
|
629
|
+
let a = l.getVirtualItems();
|
|
630
|
+
return a.length === 0 ? null : $.createElement(Ve.Provider, { value: l }, $.createElement("div", { style: { position: "relative", width: "100%", height: `${l.getTotalSize()}px` }, ref: (p) => {
|
|
631
|
+
if (p) {
|
|
632
|
+
if (typeof process < "u" && process.env.JEST_WORKER_ID !== void 0 || s.activationTrigger === 0) return;
|
|
633
|
+
s.activeOptionIndex !== null && t.length > s.activeOptionIndex && l.scrollToIndex(s.activeOptionIndex);
|
|
634
|
+
}
|
|
635
|
+
} }, a.map((p) => {
|
|
636
|
+
var d;
|
|
637
|
+
return $.createElement(Ae, { key: p.key }, $.cloneElement((d = e.children) == null ? void 0 : d.call(e, { ...e.slot, option: t[p.index] }), { key: `${r}-${p.key}`, "data-index": p.index, "aria-setsize": t.length, "aria-posinset": p.index + 1, style: { position: "absolute", top: 0, left: 0, transform: `translateY(${p.start}px)`, overflowAnchor: "none" } }));
|
|
638
|
+
})));
|
|
639
|
+
}
|
|
640
|
+
let se = Se(null);
|
|
641
|
+
se.displayName = "ComboboxDataContext";
|
|
642
|
+
function ne(e) {
|
|
643
|
+
let s = Ie(se);
|
|
644
|
+
if (s === null) {
|
|
645
|
+
let t = new Error(`<${e} /> is missing a parent <Combobox /> component.`);
|
|
646
|
+
throw Error.captureStackTrace && Error.captureStackTrace(t, ne), t;
|
|
647
|
+
}
|
|
648
|
+
return s;
|
|
649
|
+
}
|
|
650
|
+
function Yt(e, s) {
|
|
651
|
+
return te(s.type, Gt, e, s);
|
|
652
|
+
}
|
|
653
|
+
let Qt = Ae;
|
|
654
|
+
function Zt(e, s) {
|
|
655
|
+
var t, n;
|
|
656
|
+
let o = Ge(), { value: l, defaultValue: r, onChange: i, form: a, name: p, by: d, disabled: c = o || !1, onClose: I, __demoMode: u = !1, multiple: S = !1, immediate: x = !1, virtual: h = null, nullable: R, ...D } = e, M = Je(r), [E = S ? [] : void 0, y] = Ye(l, i, M), [O, b] = Tt(Yt, { dataRef: Rt(), comboboxState: u ? 0 : 1, isTyping: !1, options: [], virtual: h ? { options: h.options, disabled: (t = h.disabled) != null ? t : () => !1 } : null, activeOptionIndex: null, activationTrigger: 2, __demoMode: u }), V = N(!1), U = N({ static: !1, hold: !1 }), J = N(null), j = N(null), Y = N(null), k = Qe(d), C = g((v) => h ? d === null ? h.options.indexOf(v) : h.options.findIndex((T) => k(T, v)) : O.options.findIndex((T) => k(T.dataRef.current.value, v))), A = _e((v) => te(m.mode, { 1: () => E.some((T) => k(T, v)), 0: () => k(E, v) }), [E]), Q = g((v) => O.activeOptionIndex === C(v)), m = G(() => ({ ...O, immediate: x, optionsPropsRef: U, inputRef: J, buttonRef: j, optionsRef: Y, value: E, defaultValue: M, disabled: c, mode: S ? 1 : 0, virtual: h ? O.virtual : null, get activeOptionIndex() {
|
|
657
|
+
if (V.current && O.activeOptionIndex === null && (h ? h.options.length > 0 : O.options.length > 0)) {
|
|
658
|
+
if (h) {
|
|
659
|
+
let T = h.options.findIndex((K) => {
|
|
660
|
+
var ue, Te;
|
|
661
|
+
return !((Te = (ue = h.disabled) == null ? void 0 : ue.call(h, K)) != null && Te);
|
|
662
|
+
});
|
|
663
|
+
if (T !== -1) return T;
|
|
664
|
+
}
|
|
665
|
+
let v = O.options.findIndex((T) => !T.dataRef.current.disabled);
|
|
666
|
+
if (v !== -1) return v;
|
|
667
|
+
}
|
|
668
|
+
return O.activeOptionIndex;
|
|
669
|
+
}, calculateIndex: C, compare: k, isSelected: A, isActive: Q }), [E, M, c, S, u, O, h]);
|
|
670
|
+
q(() => {
|
|
671
|
+
var v;
|
|
672
|
+
h && b({ type: 7, options: h.options, disabled: (v = h.disabled) != null ? v : null });
|
|
673
|
+
}, [h, h == null ? void 0 : h.options, h == null ? void 0 : h.disabled]), q(() => {
|
|
674
|
+
O.dataRef.current = m;
|
|
675
|
+
}, [m]);
|
|
676
|
+
let ee = m.comboboxState === 0;
|
|
677
|
+
Ze(ee, [m.buttonRef, m.inputRef, m.optionsRef], () => H.closeCombobox());
|
|
678
|
+
let z = G(() => {
|
|
679
|
+
var v, T, K;
|
|
680
|
+
return { open: m.comboboxState === 0, disabled: c, activeIndex: m.activeOptionIndex, activeOption: m.activeOptionIndex === null ? null : m.virtual ? m.virtual.options[(v = m.activeOptionIndex) != null ? v : 0] : (K = (T = m.options[m.activeOptionIndex]) == null ? void 0 : T.dataRef.current.value) != null ? K : null, value: E };
|
|
681
|
+
}, [m, c, E]), fe = g(() => {
|
|
682
|
+
if (m.activeOptionIndex !== null) {
|
|
683
|
+
if (H.setIsTyping(!1), m.virtual) w(m.virtual.options[m.activeOptionIndex]);
|
|
684
|
+
else {
|
|
685
|
+
let { dataRef: v } = m.options[m.activeOptionIndex];
|
|
686
|
+
w(v.current.value);
|
|
687
|
+
}
|
|
688
|
+
H.goToOption(_.Specific, m.activeOptionIndex);
|
|
689
|
+
}
|
|
690
|
+
}), he = g(() => {
|
|
691
|
+
b({ type: 0 }), V.current = !0;
|
|
692
|
+
}), f = g(() => {
|
|
693
|
+
b({ type: 1 }), V.current = !1, I == null || I();
|
|
694
|
+
}), B = g((v) => {
|
|
695
|
+
b({ type: 3, isTyping: v });
|
|
696
|
+
}), P = g((v, T, K) => (V.current = !1, v === _.Specific ? b({ type: 2, focus: _.Specific, idx: T, trigger: K }) : b({ type: 2, focus: v, trigger: K }))), W = g((v, T) => (b({ type: 4, payload: { id: v, dataRef: T } }), () => {
|
|
697
|
+
m.isActive(T.current.value) && (V.current = !0), b({ type: 5, id: v });
|
|
698
|
+
})), w = g((v) => te(m.mode, { 0() {
|
|
699
|
+
return y == null ? void 0 : y(v);
|
|
700
|
+
}, 1() {
|
|
701
|
+
let T = m.value.slice(), K = T.findIndex((ue) => k(ue, v));
|
|
702
|
+
return K === -1 ? T.push(v) : T.splice(K, 1), y == null ? void 0 : y(T);
|
|
703
|
+
} })), L = g((v) => {
|
|
704
|
+
b({ type: 6, trigger: v });
|
|
705
|
+
}), H = G(() => ({ onChange: w, registerOption: W, goToOption: P, setIsTyping: B, closeCombobox: f, openCombobox: he, setActivationTrigger: L, selectActiveOption: fe }), []), [Be, We] = Xe(), je = s === null ? {} : { ref: s }, He = _e(() => {
|
|
706
|
+
if (M !== void 0) return y == null ? void 0 : y(M);
|
|
707
|
+
}, [y, M]);
|
|
708
|
+
return $.createElement(We, { value: Be, props: { htmlFor: (n = m.inputRef.current) == null ? void 0 : n.id }, slot: { open: m.comboboxState === 0, disabled: c } }, $.createElement(et, null, $.createElement(Ee.Provider, { value: H }, $.createElement(se.Provider, { value: m }, $.createElement(tt, { value: te(m.comboboxState, { 0: ce.Open, 1: ce.Closed }) }, p != null && $.createElement(nt, { disabled: c, data: E != null ? { [p]: E } : {}, form: a, onReset: He }), le({ ourProps: je, theirProps: D, slot: z, defaultTag: Qt, name: "Combobox" }))))));
|
|
709
|
+
}
|
|
710
|
+
let Xt = "input";
|
|
711
|
+
function en(e, s) {
|
|
712
|
+
var t, n, o, l, r;
|
|
713
|
+
let i = ne("Combobox.Input"), a = ae("Combobox.Input"), p = pe(), d = ot(), { id: c = d || `headlessui-combobox-input-${p}`, onChange: I, displayValue: u, disabled: S = i.disabled || !1, autoFocus: x = !1, type: h = "text", ...R } = e, D = de(i.inputRef, s, it()), M = De(i.inputRef), E = st(), y = g(() => {
|
|
714
|
+
a.onChange(null), i.optionsRef.current && (i.optionsRef.current.scrollTop = 0), a.goToOption(_.Nothing);
|
|
715
|
+
}), O = G(() => {
|
|
716
|
+
var f;
|
|
717
|
+
return typeof u == "function" && i.value !== void 0 ? (f = u(i.value)) != null ? f : "" : typeof i.value == "string" ? i.value : "";
|
|
718
|
+
}, [i.value, u]);
|
|
719
|
+
ze(([f, B], [P, W]) => {
|
|
720
|
+
if (i.isTyping) return;
|
|
721
|
+
let w = i.inputRef.current;
|
|
722
|
+
w && ((W === 0 && B === 1 || f !== P) && (w.value = f), requestAnimationFrame(() => {
|
|
723
|
+
if (i.isTyping || !w || (M == null ? void 0 : M.activeElement) !== w) return;
|
|
724
|
+
let { selectionStart: L, selectionEnd: H } = w;
|
|
725
|
+
Math.abs((H ?? 0) - (L ?? 0)) === 0 && L === 0 && w.setSelectionRange(w.value.length, w.value.length);
|
|
726
|
+
}));
|
|
727
|
+
}, [O, i.comboboxState, M, i.isTyping]), ze(([f], [B]) => {
|
|
728
|
+
if (f === 0 && B === 1) {
|
|
729
|
+
if (i.isTyping) return;
|
|
730
|
+
let P = i.inputRef.current;
|
|
731
|
+
if (!P) return;
|
|
732
|
+
let W = P.value, { selectionStart: w, selectionEnd: L, selectionDirection: H } = P;
|
|
733
|
+
P.value = "", P.value = W, H !== null ? P.setSelectionRange(w, L, H) : P.setSelectionRange(w, L);
|
|
734
|
+
}
|
|
735
|
+
}, [i.comboboxState]);
|
|
736
|
+
let b = N(!1), V = g(() => {
|
|
737
|
+
b.current = !0;
|
|
738
|
+
}), U = g(() => {
|
|
739
|
+
E.nextFrame(() => {
|
|
740
|
+
b.current = !1;
|
|
741
|
+
});
|
|
742
|
+
}), J = g((f) => {
|
|
743
|
+
switch (a.setIsTyping(!0), f.key) {
|
|
744
|
+
case F.Enter:
|
|
745
|
+
if (i.comboboxState !== 0 || b.current) return;
|
|
746
|
+
if (f.preventDefault(), f.stopPropagation(), i.activeOptionIndex === null) {
|
|
747
|
+
a.closeCombobox();
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
a.selectActiveOption(), i.mode === 0 && a.closeCombobox();
|
|
751
|
+
break;
|
|
752
|
+
case F.ArrowDown:
|
|
753
|
+
return f.preventDefault(), f.stopPropagation(), te(i.comboboxState, { 0: () => a.goToOption(_.Next), 1: () => a.openCombobox() });
|
|
754
|
+
case F.ArrowUp:
|
|
755
|
+
return f.preventDefault(), f.stopPropagation(), te(i.comboboxState, { 0: () => a.goToOption(_.Previous), 1: () => {
|
|
756
|
+
X.flushSync(() => a.openCombobox()), i.value || a.goToOption(_.Last);
|
|
757
|
+
} });
|
|
758
|
+
case F.Home:
|
|
759
|
+
if (f.shiftKey) break;
|
|
760
|
+
return f.preventDefault(), f.stopPropagation(), a.goToOption(_.First);
|
|
761
|
+
case F.PageUp:
|
|
762
|
+
return f.preventDefault(), f.stopPropagation(), a.goToOption(_.First);
|
|
763
|
+
case F.End:
|
|
764
|
+
if (f.shiftKey) break;
|
|
765
|
+
return f.preventDefault(), f.stopPropagation(), a.goToOption(_.Last);
|
|
766
|
+
case F.PageDown:
|
|
767
|
+
return f.preventDefault(), f.stopPropagation(), a.goToOption(_.Last);
|
|
768
|
+
case F.Escape:
|
|
769
|
+
return i.comboboxState !== 0 ? void 0 : (f.preventDefault(), i.optionsRef.current && !i.optionsPropsRef.current.static && f.stopPropagation(), i.mode === 0 && i.value === null && y(), a.closeCombobox());
|
|
770
|
+
case F.Tab:
|
|
771
|
+
if (i.comboboxState !== 0) return;
|
|
772
|
+
i.mode === 0 && i.activationTrigger !== 1 && a.selectActiveOption(), a.closeCombobox();
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
775
|
+
}), j = g((f) => {
|
|
776
|
+
I == null || I(f), i.mode === 0 && f.target.value === "" && y(), a.openCombobox();
|
|
777
|
+
}), Y = g((f) => {
|
|
778
|
+
var B, P, W;
|
|
779
|
+
let w = (B = f.relatedTarget) != null ? B : Z.find((L) => L !== f.currentTarget);
|
|
780
|
+
if (!((P = i.optionsRef.current) != null && P.contains(w)) && !((W = i.buttonRef.current) != null && W.contains(w)) && i.comboboxState === 0) return f.preventDefault(), i.mode === 0 && i.value === null && y(), a.closeCombobox();
|
|
781
|
+
}), k = g((f) => {
|
|
782
|
+
var B, P, W;
|
|
783
|
+
let w = (B = f.relatedTarget) != null ? B : Z.find((L) => L !== f.currentTarget);
|
|
784
|
+
(P = i.buttonRef.current) != null && P.contains(w) || (W = i.optionsRef.current) != null && W.contains(w) || i.disabled || i.immediate && i.comboboxState !== 0 && E.microTask(() => {
|
|
785
|
+
X.flushSync(() => a.openCombobox()), a.setActivationTrigger(1);
|
|
786
|
+
});
|
|
787
|
+
}), C = be(), A = rt(), { isFocused: Q, focusProps: m } = Fe({ autoFocus: x }), { isHovered: ee, hoverProps: z } = ke({ isDisabled: S }), fe = G(() => ({ open: i.comboboxState === 0, disabled: S, hover: ee, focus: Q, autofocus: x }), [i, ee, Q, x, S]), he = ge({ ref: D, id: c, role: "combobox", type: h, "aria-controls": (t = i.optionsRef.current) == null ? void 0 : t.id, "aria-expanded": i.comboboxState === 0, "aria-activedescendant": i.activeOptionIndex === null ? void 0 : i.virtual ? (n = i.options.find((f) => !f.dataRef.current.disabled && i.compare(f.dataRef.current.value, i.virtual.options[i.activeOptionIndex]))) == null ? void 0 : n.id : (o = i.options[i.activeOptionIndex]) == null ? void 0 : o.id, "aria-labelledby": C, "aria-describedby": A, "aria-autocomplete": "list", defaultValue: (r = (l = e.defaultValue) != null ? l : i.defaultValue !== void 0 ? u == null ? void 0 : u(i.defaultValue) : null) != null ? r : i.defaultValue, disabled: S || void 0, autoFocus: x, onCompositionStart: V, onCompositionEnd: U, onKeyDown: J, onChange: j, onFocus: k, onBlur: Y }, m, z);
|
|
788
|
+
return le({ ourProps: he, theirProps: R, slot: fe, defaultTag: Xt, name: "Combobox.Input" });
|
|
789
|
+
}
|
|
790
|
+
let tn = "button";
|
|
791
|
+
function nn(e, s) {
|
|
792
|
+
var t;
|
|
793
|
+
let n = ne("Combobox.Button"), o = ae("Combobox.Button"), l = de(n.buttonRef, s), r = pe(), { id: i = `headlessui-combobox-button-${r}`, disabled: a = n.disabled || !1, autoFocus: p = !1, ...d } = e, c = Ne(n.inputRef), I = g((b) => {
|
|
794
|
+
switch (b.key) {
|
|
795
|
+
case F.Space:
|
|
796
|
+
case F.Enter:
|
|
797
|
+
b.preventDefault(), b.stopPropagation(), n.comboboxState === 1 && X.flushSync(() => o.openCombobox()), c();
|
|
798
|
+
return;
|
|
799
|
+
case F.ArrowDown:
|
|
800
|
+
b.preventDefault(), b.stopPropagation(), n.comboboxState === 1 && (X.flushSync(() => o.openCombobox()), n.value || o.goToOption(_.First)), c();
|
|
801
|
+
return;
|
|
802
|
+
case F.ArrowUp:
|
|
803
|
+
b.preventDefault(), b.stopPropagation(), n.comboboxState === 1 && (X.flushSync(() => o.openCombobox()), n.value || o.goToOption(_.Last)), c();
|
|
804
|
+
return;
|
|
805
|
+
case F.Escape:
|
|
806
|
+
if (n.comboboxState !== 0) return;
|
|
807
|
+
b.preventDefault(), n.optionsRef.current && !n.optionsPropsRef.current.static && b.stopPropagation(), X.flushSync(() => o.closeCombobox()), c();
|
|
808
|
+
return;
|
|
809
|
+
default:
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
}), u = g((b) => {
|
|
813
|
+
b.preventDefault(), !It(b.currentTarget) && (b.button === Oe.Left && (n.comboboxState === 0 ? o.closeCombobox() : o.openCombobox()), c());
|
|
814
|
+
}), S = be([i]), { isFocusVisible: x, focusProps: h } = Fe({ autoFocus: p }), { isHovered: R, hoverProps: D } = ke({ isDisabled: a }), { pressed: M, pressProps: E } = lt({ disabled: a }), y = G(() => ({ open: n.comboboxState === 0, active: M || n.comboboxState === 0, disabled: a, value: n.value, hover: R, focus: x }), [n, R, x, M, a]), O = ge({ ref: l, id: i, type: at(e, n.buttonRef), tabIndex: -1, "aria-haspopup": "listbox", "aria-controls": (t = n.optionsRef.current) == null ? void 0 : t.id, "aria-expanded": n.comboboxState === 0, "aria-labelledby": S, disabled: a || void 0, autoFocus: p, onMouseDown: u, onKeyDown: I }, h, D, E);
|
|
815
|
+
return le({ ourProps: O, theirProps: d, slot: y, defaultTag: tn, name: "Combobox.Button" });
|
|
816
|
+
}
|
|
817
|
+
let on = "div", sn = Re.RenderStrategy | Re.Static;
|
|
818
|
+
function rn(e, s) {
|
|
819
|
+
var t, n, o;
|
|
820
|
+
let l = pe(), { id: r = `headlessui-combobox-options-${l}`, hold: i = !1, anchor: a, portal: p = !1, modal: d = !0, transition: c = !1, ...I } = e, u = ne("Combobox.Options"), S = ae("Combobox.Options"), x = ut(a);
|
|
821
|
+
x && (p = !0);
|
|
822
|
+
let [h, R] = ct(x), D = dt(), M = de(u.optionsRef, s, x ? h : null), E = De(u.optionsRef), y = pt(), [O, b] = ft(c, u.optionsRef, y !== null ? (y & ce.Open) === ce.Open : u.comboboxState === 0);
|
|
823
|
+
ht(O, u.inputRef, S.closeCombobox);
|
|
824
|
+
let V = u.__demoMode ? !1 : d && u.comboboxState === 0;
|
|
825
|
+
mt(V, E);
|
|
826
|
+
let U = u.__demoMode ? !1 : d && u.comboboxState === 0;
|
|
827
|
+
vt(U, { allowed: g(() => [u.inputRef.current, u.buttonRef.current, u.optionsRef.current]) }), q(() => {
|
|
828
|
+
var z;
|
|
829
|
+
u.optionsPropsRef.current.static = (z = e.static) != null ? z : !1;
|
|
830
|
+
}, [u.optionsPropsRef, e.static]), q(() => {
|
|
831
|
+
u.optionsPropsRef.current.hold = i;
|
|
832
|
+
}, [u.optionsPropsRef, i]), Wt(u.comboboxState === 0, { container: u.optionsRef.current, accept(z) {
|
|
833
|
+
return z.getAttribute("role") === "option" ? NodeFilter.FILTER_REJECT : z.hasAttribute("role") ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
834
|
+
}, walk(z) {
|
|
835
|
+
z.setAttribute("role", "none");
|
|
836
|
+
} });
|
|
837
|
+
let J = be([(t = u.buttonRef.current) == null ? void 0 : t.id]), j = G(() => ({ open: u.comboboxState === 0, option: void 0 }), [u.comboboxState]), Y = g(() => {
|
|
838
|
+
S.setActivationTrigger(0);
|
|
839
|
+
}), k = g((z) => {
|
|
840
|
+
z.preventDefault(), S.setActivationTrigger(0);
|
|
841
|
+
}), C = ge(x ? D() : {}, { "aria-labelledby": J, role: "listbox", "aria-multiselectable": u.mode === 1 ? !0 : void 0, id: r, ref: M, style: { ...I.style, ...R, "--input-width": ye(u.inputRef, !0).width, "--button-width": ye(u.buttonRef, !0).width }, onWheel: u.activationTrigger === 0 ? void 0 : Y, onMouseDown: k, ...bt(b) }), A = O && u.comboboxState === 1, Q = Ce(A, (n = u.virtual) == null ? void 0 : n.options), m = Ce(A, u.value), ee = g((z) => u.compare(m, z));
|
|
842
|
+
if (u.virtual) {
|
|
843
|
+
if (Q === void 0) throw new Error("Missing `options` in virtual mode");
|
|
844
|
+
Object.assign(I, { children: $.createElement(se.Provider, { value: Q !== u.virtual.options ? { ...u, virtual: { ...u.virtual, options: Q } } : u }, $.createElement(Jt, { slot: j }, I.children)) });
|
|
845
|
+
}
|
|
846
|
+
return $.createElement(gt, { enabled: p ? e.static || O : !1 }, $.createElement(se.Provider, { value: u.mode === 1 ? u : { ...u, isSelected: ee } }, le({ ourProps: C, theirProps: { ...I, children: $.createElement(xt, { freeze: A }, typeof I.children == "function" ? (o = I.children) == null ? void 0 : o.call(I, j) : I.children) }, slot: j, defaultTag: on, features: sn, visible: O, name: "Combobox.Options" })));
|
|
847
|
+
}
|
|
848
|
+
let ln = "div";
|
|
849
|
+
function an(e, s) {
|
|
850
|
+
var t, n, o, l;
|
|
851
|
+
let r = ne("Combobox.Option"), i = ae("Combobox.Option"), a = pe(), { id: p = `headlessui-combobox-option-${a}`, value: d, disabled: c = (o = (n = (t = r.virtual) == null ? void 0 : t.disabled) == null ? void 0 : n.call(t, d)) != null ? o : !1, order: I = null, ...u } = e, S = Ne(r.inputRef), x = r.virtual ? r.activeOptionIndex === r.calculateIndex(d) : r.activeOptionIndex === null ? !1 : ((l = r.options[r.activeOptionIndex]) == null ? void 0 : l.id) === p, h = r.isSelected(d), R = N(null), D = $e({ disabled: c, value: d, domRef: R, order: I }), M = Ie(Ve), E = de(s, R, M ? M.measureElement : null), y = g(() => {
|
|
852
|
+
i.setIsTyping(!1), i.onChange(d);
|
|
853
|
+
});
|
|
854
|
+
q(() => i.registerOption(p, D), [D, p]);
|
|
855
|
+
let O = N(!(r.virtual || r.__demoMode));
|
|
856
|
+
q(() => {
|
|
857
|
+
if (!r.virtual && !r.__demoMode) return we().requestAnimationFrame(() => {
|
|
858
|
+
O.current = !0;
|
|
859
|
+
});
|
|
860
|
+
}, [r.virtual, r.__demoMode]), q(() => {
|
|
861
|
+
if (O.current && r.comboboxState === 0 && x && r.activationTrigger !== 0) return we().requestAnimationFrame(() => {
|
|
862
|
+
var C, A;
|
|
863
|
+
(A = (C = R.current) == null ? void 0 : C.scrollIntoView) == null || A.call(C, { block: "nearest" });
|
|
864
|
+
});
|
|
865
|
+
}, [R, x, r.comboboxState, r.activationTrigger, r.activeOptionIndex]);
|
|
866
|
+
let b = g((C) => {
|
|
867
|
+
C.preventDefault(), C.button === Oe.Left && (c || (y(), Ot() || requestAnimationFrame(() => S()), r.mode === 0 && i.closeCombobox()));
|
|
868
|
+
}), V = g(() => {
|
|
869
|
+
if (c) return i.goToOption(_.Nothing);
|
|
870
|
+
let C = r.calculateIndex(d);
|
|
871
|
+
i.goToOption(_.Specific, C);
|
|
872
|
+
}), U = St(), J = g((C) => U.update(C)), j = g((C) => {
|
|
873
|
+
if (!U.wasMoved(C) || c || x) return;
|
|
874
|
+
let A = r.calculateIndex(d);
|
|
875
|
+
i.goToOption(_.Specific, A, 0);
|
|
876
|
+
}), Y = g((C) => {
|
|
877
|
+
U.wasMoved(C) && (c || x && (r.optionsPropsRef.current.hold || i.goToOption(_.Nothing)));
|
|
878
|
+
}), k = G(() => ({ active: x, focus: x, selected: h, disabled: c }), [x, h, c]);
|
|
879
|
+
return le({ ourProps: { id: p, ref: E, role: "option", tabIndex: c === !0 ? void 0 : -1, "aria-disabled": c === !0 ? !0 : void 0, "aria-selected": h, disabled: void 0, onMouseDown: b, onFocus: V, onPointerEnter: J, onMouseEnter: J, onPointerMove: j, onMouseMove: j, onPointerLeave: Y, onMouseLeave: Y }, theirProps: u, slot: k, defaultTag: ln, name: "Combobox.Option" });
|
|
880
|
+
}
|
|
881
|
+
let un = re(Zt), cn = re(nn), dn = re(en), pn = qe, fn = re(rn), hn = re(an), gn = Object.assign(un, { Input: dn, Button: cn, Label: pn, Options: fn, Option: hn });
|
|
882
|
+
export {
|
|
883
|
+
dn as G,
|
|
884
|
+
cn as H,
|
|
885
|
+
hn as K,
|
|
886
|
+
gn as N,
|
|
887
|
+
fn as z
|
|
888
|
+
};
|