mimir-ui-kit 1.38.6 → 1.38.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{combobox-DgSZTriw.js → combobox-CVtJDVoZ.js} +251 -254
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Accordion/Accordion.js +3 -3
- package/dist/components/CheckboxMimir/CheckboxMimir.js +4 -4
- package/dist/components/Dropdown/Dropdown.js +32 -32
- package/dist/components/MultiSelectSearch/MultiSelectSearch.d.ts +1 -0
- package/dist/components/MultiSelectSearch/MultiSelectSearch.js +175 -157
- package/dist/components/MultiSelectSearch/constants.d.ts +3 -0
- package/dist/components/MultiSelectSearch/constants.js +6 -2
- package/dist/components/MultiSelectSearch/types.d.ts +4 -0
- package/dist/components/MultiSelectSearch/utils.d.ts +1 -0
- package/dist/components/MultiSelectSearch/utils.js +19 -14
- package/dist/components/RadioGroup/RadioGroup.js +3 -3
- package/dist/components/SelectSearch/SelectSearch.js +21 -21
- package/dist/components/Slider/Slider.d.ts +21 -8
- package/dist/components/Slider/Slider.js +388 -383
- package/dist/components/Switcher/Switcher.js +4 -4
- package/dist/components/TabTrail/TabTrail.js +4 -4
- package/dist/{field-C1kt7aNM.js → field-FJ34aSs4.js} +2 -2
- package/dist/{focus-management-BtPpk3D1.js → focus-management-DE4t_lW3.js} +1 -1
- package/dist/{hidden-PvGXrYUY.js → hidden-DbgtYPOH.js} +1 -1
- package/dist/{keyboard-mgWkd2Vh.js → keyboard-B0lm_zyn.js} +111 -114
- package/dist/{label-D4GFpe5F.js → label-y3ANLTNC.js} +2 -2
- package/dist/open-closed-CdldUPoq.js +86 -0
- package/dist/portal-WDFNoIMz.js +1908 -0
- package/dist/{use-active-press-CqLGIFz7.js → use-active-press-86hajhdd.js} +1 -1
- package/package.json +1 -1
- package/dist/open-closed-D2VjDhAN.js +0 -86
- package/dist/portal-DPqg52FR.js +0 -1946
@@ -1,34 +1,34 @@
|
|
1
|
-
import { n as
|
1
|
+
import { n as H, u as Ne, d as xe, o as g, M as _e, W as ue, a as te, H as ce, y as fe, p as Qe, $ as Ve, b as Be, D as Ie, I as Je, s as Ze, c as k } from "./keyboard-B0lm_zyn.js";
|
2
2
|
import * as se from "react";
|
3
|
-
import
|
3
|
+
import z, { useRef as V, useEffect as We, useState as Te, createContext as ye, useReducer as et, createRef as tt, useCallback as Ee, useMemo as G, useId as he, useContext as Ce, Fragment as He } from "react";
|
4
4
|
import { flushSync as Z } from "react-dom";
|
5
|
-
import { w as nt } from "./use-active-press-
|
5
|
+
import { w as nt } from "./use-active-press-86hajhdd.js";
|
6
6
|
import { u as ot } from "./use-by-comparator-CVuf9KBq.js";
|
7
|
-
import { K as it, a as rt, b as st, T as lt, z as at, j as ut, u as ct, I as we, G as dt } from "./label-
|
8
|
-
import { c as pt, E as mt, R as ft,
|
9
|
-
import { e as
|
10
|
-
import { c as
|
11
|
-
import { f as Rt, _ as $t } from "./focus-management-
|
7
|
+
import { K as it, a as rt, b as st, T as lt, z as at, j as ut, u as ct, I as we, G as dt } from "./label-y3ANLTNC.js";
|
8
|
+
import { c as pt, E as mt, R as ft, v as ht, y as vt, n as je, x as bt, a as gt, b as xt, m as Et, f as Ot, d as Pe, t as St, g as It } from "./portal-WDFNoIMz.js";
|
9
|
+
import { e as Tt } from "./use-resolve-button-type-DhFdPxnv.js";
|
10
|
+
import { c as yt, i as me, u as Ct, R as wt, H as Mt } from "./open-closed-CdldUPoq.js";
|
11
|
+
import { f as Rt, _ as $t } from "./focus-management-DE4t_lW3.js";
|
12
12
|
import { r as _t } from "./bugs-diTMAGNw.js";
|
13
|
-
function
|
13
|
+
function re(e, i, t) {
|
14
14
|
let n = t.initialDeps ?? [], o;
|
15
15
|
return () => {
|
16
16
|
var r, l, s, a;
|
17
17
|
let c;
|
18
18
|
t.key && ((r = t.debug) != null && r.call(t)) && (c = Date.now());
|
19
19
|
const d = e();
|
20
|
-
if (!(d.length !== n.length || d.some((u,
|
20
|
+
if (!(d.length !== n.length || d.some((u, x) => n[x] !== u)))
|
21
21
|
return o;
|
22
22
|
n = d;
|
23
23
|
let b;
|
24
24
|
if (t.key && ((l = t.debug) != null && l.call(t)) && (b = Date.now()), o = i(...d), t.key && ((s = t.debug) != null && s.call(t))) {
|
25
|
-
const u = Math.round((Date.now() - c) * 100) / 100,
|
26
|
-
for (
|
27
|
-
|
28
|
-
return
|
25
|
+
const u = Math.round((Date.now() - c) * 100) / 100, x = Math.round((Date.now() - b) * 100) / 100, O = x / 16, h = (y, $) => {
|
26
|
+
for (y = String(y); y.length < $; )
|
27
|
+
y = " " + y;
|
28
|
+
return y;
|
29
29
|
};
|
30
30
|
console.info(
|
31
|
-
`%c⏱ ${h(
|
31
|
+
`%c⏱ ${h(x, 5)} /${h(u, 5)} ms`,
|
32
32
|
`
|
33
33
|
font-size: .6rem;
|
34
34
|
font-weight: bold;
|
@@ -87,7 +87,7 @@ const Pt = (e, i) => Math.abs(e - i) < 1, zt = (e, i, t) => {
|
|
87
87
|
};
|
88
88
|
}, ze = {
|
89
89
|
passive: !0
|
90
|
-
}, At = typeof window > "u" ? !0 : "onscrollend" in window,
|
90
|
+
}, At = typeof window > "u" ? !0 : "onscrollend" in window, Lt = (e, i) => {
|
91
91
|
const t = e.scrollElement;
|
92
92
|
if (!t)
|
93
93
|
return;
|
@@ -103,13 +103,12 @@ const Pt = (e, i) => Math.abs(e - i) < 1, zt = (e, i, t) => {
|
|
103
103
|
},
|
104
104
|
e.options.isScrollingResetDelay
|
105
105
|
), l = (c) => () => {
|
106
|
-
|
107
|
-
o = d ? t.scrollLeft * (v && -1 || 1) : t.scrollTop, r(), i(o, c);
|
106
|
+
o = t[e.options.horizontal ? "scrollLeft" : "scrollTop"], r(), i(o, c);
|
108
107
|
}, s = l(!0), a = l(!1);
|
109
108
|
return a(), t.addEventListener("scroll", s, ze), t.addEventListener("scrollend", a, ze), () => {
|
110
109
|
t.removeEventListener("scroll", s), t.removeEventListener("scrollend", a);
|
111
110
|
};
|
112
|
-
},
|
111
|
+
}, Nt = (e, i, t) => {
|
113
112
|
if (i != null && i.borderBoxSize) {
|
114
113
|
const n = i.borderBoxSize[0];
|
115
114
|
if (n)
|
@@ -143,7 +142,7 @@ class Bt {
|
|
143
142
|
return {
|
144
143
|
disconnect: () => {
|
145
144
|
var o;
|
146
|
-
(o = n()) == null
|
145
|
+
return (o = n()) == null ? void 0 : o.disconnect();
|
147
146
|
},
|
148
147
|
observe: (o) => {
|
149
148
|
var r;
|
@@ -170,7 +169,7 @@ class Bt {
|
|
170
169
|
rangeExtractor: Ft,
|
171
170
|
onChange: () => {
|
172
171
|
},
|
173
|
-
measureElement:
|
172
|
+
measureElement: Nt,
|
174
173
|
initialRect: { width: 0, height: 0 },
|
175
174
|
scrollMargin: 0,
|
176
175
|
gap: 0,
|
@@ -179,32 +178,17 @@ class Bt {
|
|
179
178
|
lanes: 1,
|
180
179
|
isScrollingResetDelay: 150,
|
181
180
|
enabled: !0,
|
182
|
-
isRtl: !1,
|
183
181
|
...t
|
184
182
|
};
|
185
|
-
}, this.notify = (t) => {
|
186
|
-
var
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
]),
|
194
|
-
(t) => {
|
195
|
-
this.notify(t);
|
196
|
-
},
|
197
|
-
{
|
198
|
-
key: process.env.NODE_ENV !== "production" && "maybeNotify",
|
199
|
-
debug: () => this.options.debug,
|
200
|
-
initialDeps: [
|
201
|
-
this.isScrolling,
|
202
|
-
this.range ? this.range.startIndex : null,
|
203
|
-
this.range ? this.range.endIndex : null
|
204
|
-
]
|
205
|
-
}
|
206
|
-
), this.cleanup = () => {
|
207
|
-
this.unsubs.filter(Boolean).forEach((t) => t()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
|
183
|
+
}, this.notify = (t, n) => {
|
184
|
+
var o, r;
|
185
|
+
const { startIndex: l, endIndex: s } = this.range ?? {
|
186
|
+
startIndex: void 0,
|
187
|
+
endIndex: void 0
|
188
|
+
}, a = this.calculateRange();
|
189
|
+
(t || l !== (a == null ? void 0 : a.startIndex) || s !== (a == null ? void 0 : a.endIndex)) && ((r = (o = this.options).onChange) == null || r.call(o, this, n));
|
190
|
+
}, this.cleanup = () => {
|
191
|
+
this.unsubs.filter(Boolean).forEach((t) => t()), this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.observer.disconnect(), this.elementsCache.clear();
|
208
192
|
}, this._didMount = () => () => {
|
209
193
|
this.cleanup();
|
210
194
|
}, this._willUpdate = () => {
|
@@ -212,21 +196,21 @@ class Bt {
|
|
212
196
|
const n = this.options.enabled ? this.options.getScrollElement() : null;
|
213
197
|
if (this.scrollElement !== n) {
|
214
198
|
if (this.cleanup(), !n) {
|
215
|
-
this.
|
199
|
+
this.notify(!1, !1);
|
216
200
|
return;
|
217
201
|
}
|
218
|
-
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.
|
219
|
-
this.observer.observe(o);
|
220
|
-
}), this._scrollToOffset(this.getScrollOffset(), {
|
202
|
+
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(), {
|
221
203
|
adjustments: void 0,
|
222
204
|
behavior: void 0
|
223
205
|
}), this.unsubs.push(
|
224
206
|
this.options.observeElementRect(this, (o) => {
|
225
|
-
this.scrollRect = o, this.
|
207
|
+
this.scrollRect = o, this.notify(!1, !1);
|
226
208
|
})
|
227
209
|
), this.unsubs.push(
|
228
210
|
this.options.observeElementOffset(this, (o, r) => {
|
229
|
-
this.scrollAdjustments = 0, this.scrollDirection = r ? this.getScrollOffset() < o ? "forward" : "backward" : null, this.scrollOffset = o
|
211
|
+
this.scrollAdjustments = 0, this.scrollDirection = r ? this.getScrollOffset() < o ? "forward" : "backward" : null, this.scrollOffset = o;
|
212
|
+
const l = this.isScrolling;
|
213
|
+
this.isScrolling = r, this.notify(l !== r, r);
|
230
214
|
})
|
231
215
|
);
|
232
216
|
}
|
@@ -243,7 +227,7 @@ class Bt {
|
|
243
227
|
break;
|
244
228
|
}
|
245
229
|
return r.size === this.options.lanes ? Array.from(r.values()).sort((l, s) => l.end === s.end ? l.index - s.index : l.end - s.end)[0] : void 0;
|
246
|
-
}, this.getMeasurementOptions =
|
230
|
+
}, this.getMeasurementOptions = re(
|
247
231
|
() => [
|
248
232
|
this.options.count,
|
249
233
|
this.options.paddingStart,
|
@@ -261,37 +245,51 @@ class Bt {
|
|
261
245
|
{
|
262
246
|
key: !1
|
263
247
|
}
|
264
|
-
), this.getMeasurements =
|
248
|
+
), this.getMeasurements = re(
|
265
249
|
() => [this.getMeasurementOptions(), this.itemSizeCache],
|
266
250
|
({ count: t, paddingStart: n, scrollMargin: o, getItemKey: r, enabled: l }, s) => {
|
251
|
+
var a;
|
267
252
|
if (!l)
|
268
253
|
return this.measurementsCache = [], this.itemSizeCache.clear(), [];
|
269
|
-
this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((
|
270
|
-
this.itemSizeCache.set(
|
254
|
+
this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((m) => {
|
255
|
+
this.itemSizeCache.set(m.key, m.size);
|
271
256
|
}));
|
272
|
-
const
|
257
|
+
const c = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
|
273
258
|
this.pendingMeasuredCacheIndexes = [];
|
274
|
-
const
|
275
|
-
for (let
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
259
|
+
const d = this.measurementsCache.slice(0, c);
|
260
|
+
for (let m = c; m < t; m++) {
|
261
|
+
let b = (a = this.measurementsCache[m]) == null ? void 0 : a.measureElement;
|
262
|
+
b || (b = (S) => {
|
263
|
+
const w = r(m), I = this.elementsCache.get(w);
|
264
|
+
if (!S) {
|
265
|
+
I && (this.observer.unobserve(I), this.elementsCache.delete(w));
|
266
|
+
return;
|
267
|
+
}
|
268
|
+
I !== S && (I && this.observer.unobserve(I), this.observer.observe(S), this.elementsCache.set(w, S)), S.isConnected && this.resizeItem(
|
269
|
+
m,
|
270
|
+
this.options.measureElement(S, void 0, this)
|
271
|
+
);
|
272
|
+
});
|
273
|
+
const u = r(m), x = this.options.lanes === 1 ? d[m - 1] : this.getFurthestMeasurement(d, m), O = x ? x.end + this.options.gap : n + o, h = s.get(u), y = typeof h == "number" ? h : this.options.estimateSize(m), $ = O + y, _ = x ? x.lane : m % this.options.lanes;
|
274
|
+
d[m] = {
|
275
|
+
index: m,
|
276
|
+
start: O,
|
277
|
+
size: y,
|
278
|
+
end: $,
|
279
|
+
key: u,
|
280
|
+
lane: _,
|
281
|
+
measureElement: b
|
284
282
|
};
|
285
283
|
}
|
286
|
-
return this.measurementsCache =
|
284
|
+
return this.measurementsCache = d, d;
|
287
285
|
},
|
288
286
|
{
|
289
287
|
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
290
288
|
debug: () => this.options.debug
|
291
289
|
}
|
292
|
-
), this.calculateRange =
|
290
|
+
), this.calculateRange = re(
|
293
291
|
() => [this.getMeasurements(), this.getSize(), this.getScrollOffset()],
|
294
|
-
(t, n, o) => this.range = t.length > 0 && n > 0 ?
|
292
|
+
(t, n, o) => this.range = t.length > 0 && n > 0 ? Wt({
|
295
293
|
measurements: t,
|
296
294
|
outerSize: n,
|
297
295
|
scrollOffset: o
|
@@ -300,7 +298,7 @@ class Bt {
|
|
300
298
|
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
301
299
|
debug: () => this.options.debug
|
302
300
|
}
|
303
|
-
), this.getIndexes =
|
301
|
+
), this.getIndexes = re(
|
304
302
|
() => [
|
305
303
|
this.options.rangeExtractor,
|
306
304
|
this.calculateRange(),
|
@@ -323,29 +321,27 @@ class Bt {
|
|
323
321
|
`Missing attribute name '${n}={index}' on measured element.`
|
324
322
|
), -1);
|
325
323
|
}, this._measureElement = (t, n) => {
|
326
|
-
const o = this.indexFromElement(t), r = this.
|
327
|
-
if (!r)
|
324
|
+
const o = this.indexFromElement(t), r = this.getMeasurements()[o];
|
325
|
+
if (!r || !t.isConnected) {
|
326
|
+
this.elementsCache.forEach((s, a) => {
|
327
|
+
s === t && (this.observer.unobserve(t), this.elementsCache.delete(a));
|
328
|
+
});
|
328
329
|
return;
|
329
|
-
|
330
|
-
|
330
|
+
}
|
331
|
+
const l = this.elementsCache.get(r.key);
|
332
|
+
l !== t && (l && this.observer.unobserve(l), this.observer.observe(t), this.elementsCache.set(r.key, t)), this.resizeItem(o, this.options.measureElement(t, n, this));
|
331
333
|
}, this.resizeItem = (t, n) => {
|
332
|
-
const o = this.
|
334
|
+
const o = this.getMeasurements()[t];
|
333
335
|
if (!o)
|
334
336
|
return;
|
335
337
|
const r = this.itemSizeCache.get(o.key) ?? o.size, l = n - r;
|
336
338
|
l !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(o, l, this) : o.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", l), this._scrollToOffset(this.getScrollOffset(), {
|
337
339
|
adjustments: this.scrollAdjustments += l,
|
338
340
|
behavior: void 0
|
339
|
-
})), this.pendingMeasuredCacheIndexes.push(o.index), this.itemSizeCache = new Map(this.itemSizeCache.set(o.key, n)), this.notify(!1));
|
341
|
+
})), this.pendingMeasuredCacheIndexes.push(o.index), this.itemSizeCache = new Map(this.itemSizeCache.set(o.key, n)), this.notify(!0, !1));
|
340
342
|
}, this.measureElement = (t) => {
|
341
|
-
|
342
|
-
|
343
|
-
n.isConnected || (this.observer.unobserve(n), this.elementsCache.delete(o));
|
344
|
-
});
|
345
|
-
return;
|
346
|
-
}
|
347
|
-
this._measureElement(t, void 0);
|
348
|
-
}, this.getVirtualItems = te(
|
343
|
+
t && this._measureElement(t, void 0);
|
344
|
+
}, this.getVirtualItems = re(
|
349
345
|
() => [this.getIndexes(), this.getMeasurements()],
|
350
346
|
(t, n) => {
|
351
347
|
const o = [];
|
@@ -356,7 +352,7 @@ class Bt {
|
|
356
352
|
return o;
|
357
353
|
},
|
358
354
|
{
|
359
|
-
key: process.env.NODE_ENV !== "production" && "
|
355
|
+
key: process.env.NODE_ENV !== "production" && "getIndexes",
|
360
356
|
debug: () => this.options.debug
|
361
357
|
}
|
362
358
|
), this.getVirtualItemForOffset = (t) => {
|
@@ -377,7 +373,7 @@ class Bt {
|
|
377
373
|
return Math.max(Math.min(a, t), 0);
|
378
374
|
}, this.getOffsetForIndex = (t, n = "auto") => {
|
379
375
|
t = Math.max(0, Math.min(t, this.options.count - 1));
|
380
|
-
const o = this.
|
376
|
+
const o = this.getMeasurements()[t];
|
381
377
|
if (!o)
|
382
378
|
return;
|
383
379
|
const r = this.getSize(), l = this.getScrollOffset();
|
@@ -430,17 +426,15 @@ class Bt {
|
|
430
426
|
let o;
|
431
427
|
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(
|
432
428
|
...n.slice(-this.options.lanes).map((r) => r.end)
|
433
|
-
),
|
434
|
-
o - this.options.scrollMargin + this.options.paddingEnd,
|
435
|
-
0
|
436
|
-
);
|
429
|
+
), o - this.options.scrollMargin + this.options.paddingEnd;
|
437
430
|
}, this._scrollToOffset = (t, {
|
438
431
|
adjustments: n,
|
439
432
|
behavior: o
|
440
433
|
}) => {
|
441
434
|
this.options.scrollToFn(t, { behavior: o, adjustments: n }, this);
|
442
435
|
}, this.measure = () => {
|
443
|
-
|
436
|
+
var t, n;
|
437
|
+
this.itemSizeCache = /* @__PURE__ */ new Map(), (n = (t = this.options).onChange) == null || n.call(t, this, !1);
|
444
438
|
}, this.setOptions(i);
|
445
439
|
}
|
446
440
|
}
|
@@ -456,7 +450,7 @@ const Ue = (e, i, t, n) => {
|
|
456
450
|
}
|
457
451
|
return e > 0 ? e - 1 : 0;
|
458
452
|
};
|
459
|
-
function
|
453
|
+
function Wt({
|
460
454
|
measurements: e,
|
461
455
|
outerSize: i,
|
462
456
|
scrollOffset: t
|
@@ -467,8 +461,8 @@ function jt({
|
|
467
461
|
l++;
|
468
462
|
return { startIndex: r, endIndex: l };
|
469
463
|
}
|
470
|
-
const
|
471
|
-
function
|
464
|
+
const Ht = typeof document < "u" ? se.useLayoutEffect : se.useEffect;
|
465
|
+
function jt(e) {
|
472
466
|
const i = se.useReducer(() => ({}), {})[1], t = {
|
473
467
|
...e,
|
474
468
|
onChange: (o, r) => {
|
@@ -478,12 +472,12 @@ function Ht(e) {
|
|
478
472
|
}, [n] = se.useState(
|
479
473
|
() => new Bt(t)
|
480
474
|
);
|
481
|
-
return n.setOptions(t), se.useEffect(() => n._didMount(), []),
|
475
|
+
return n.setOptions(t), se.useEffect(() => n._didMount(), []), Ht(() => n._willUpdate()), n;
|
482
476
|
}
|
483
477
|
function Ut(e) {
|
484
|
-
return
|
478
|
+
return jt({
|
485
479
|
observeElementRect: kt,
|
486
|
-
observeElementOffset:
|
480
|
+
observeElementOffset: Lt,
|
487
481
|
scrollToFn: Vt,
|
488
482
|
...e
|
489
483
|
});
|
@@ -503,7 +497,7 @@ function Fe(e) {
|
|
503
497
|
}
|
504
498
|
function Kt(e, { allowed: i, disallowed: t } = {}) {
|
505
499
|
let n = pt(e, "inert-others");
|
506
|
-
|
500
|
+
H(() => {
|
507
501
|
var o, r;
|
508
502
|
if (!n) return;
|
509
503
|
let l = xe();
|
@@ -511,11 +505,11 @@ function Kt(e, { allowed: i, disallowed: t } = {}) {
|
|
511
505
|
let s = (r = i == null ? void 0 : i()) != null ? r : [];
|
512
506
|
for (let a of s) {
|
513
507
|
if (!a) continue;
|
514
|
-
let c =
|
508
|
+
let c = Ne(a);
|
515
509
|
if (!c) continue;
|
516
510
|
let d = a.parentElement;
|
517
511
|
for (; d && d !== c.body; ) {
|
518
|
-
for (let
|
512
|
+
for (let m of d.children) s.some((b) => m.contains(b)) || l.add(De(m));
|
519
513
|
d = d.parentElement;
|
520
514
|
}
|
521
515
|
}
|
@@ -552,19 +546,19 @@ function Gt() {
|
|
552
546
|
}
|
553
547
|
function qt(e, { container: i, accept: t, walk: n }) {
|
554
548
|
let o = V(t), r = V(n);
|
555
|
-
|
549
|
+
We(() => {
|
556
550
|
o.current = t, r.current = n;
|
557
|
-
}, [t, n]),
|
551
|
+
}, [t, n]), H(() => {
|
558
552
|
if (!i || !e) return;
|
559
|
-
let l =
|
553
|
+
let l = Ne(i);
|
560
554
|
if (!l) return;
|
561
|
-
let s = o.current, a = r.current, c = Object.assign((
|
555
|
+
let s = o.current, a = r.current, c = Object.assign((m) => s(m), { acceptNode: s }), d = l.createTreeWalker(i, NodeFilter.SHOW_ELEMENT, c, !1);
|
562
556
|
for (; d.nextNode(); ) a(d.currentNode);
|
563
557
|
}, [i, e, o, r]);
|
564
558
|
}
|
565
559
|
function Ae(e, i) {
|
566
560
|
let t = V([]), n = g(e);
|
567
|
-
|
561
|
+
We(() => {
|
568
562
|
let o = [...t.current];
|
569
563
|
for (let [r, l] of i.entries()) if (t.current[r] !== l) {
|
570
564
|
let s = n(i, o);
|
@@ -574,10 +568,10 @@ function Ae(e, i) {
|
|
574
568
|
}
|
575
569
|
function Yt({ children: e, freeze: i }) {
|
576
570
|
let t = Se(i, e);
|
577
|
-
return
|
571
|
+
return z.createElement(z.Fragment, null, t);
|
578
572
|
}
|
579
573
|
function Se(e, i) {
|
580
|
-
let [t, n] =
|
574
|
+
let [t, n] = Te(i);
|
581
575
|
return !e && t !== i && n(i), e ? t : i;
|
582
576
|
}
|
583
577
|
function Xt(e) {
|
@@ -598,8 +592,8 @@ Xt(() => {
|
|
598
592
|
function Qt(e) {
|
599
593
|
throw new Error("Unexpected object: " + e);
|
600
594
|
}
|
601
|
-
var
|
602
|
-
function
|
595
|
+
var M = ((e) => (e[e.First = 0] = "First", e[e.Previous = 1] = "Previous", e[e.Next = 2] = "Next", e[e.Last = 3] = "Last", e[e.Specific = 4] = "Specific", e[e.Nothing = 5] = "Nothing", e))(M || {});
|
596
|
+
function Le(e, i) {
|
603
597
|
let t = i.resolveItems();
|
604
598
|
if (t.length <= 0) return null;
|
605
599
|
let n = i.resolveActiveIndex(), o = n ?? -1;
|
@@ -653,20 +647,20 @@ let nn = { 1(e) {
|
|
653
647
|
var t, n, o, r;
|
654
648
|
if ((t = e.dataRef.current) != null && t.disabled || e.optionsElement && !((n = e.dataRef.current) != null && n.optionsPropsRef.current.static) && e.comboboxState === 1) return e;
|
655
649
|
if (e.virtual) {
|
656
|
-
let { options: c, disabled: d } = e.virtual,
|
657
|
-
var u,
|
658
|
-
return (
|
650
|
+
let { options: c, disabled: d } = e.virtual, m = i.focus === M.Specific ? i.idx : Le(i, { resolveItems: () => c, resolveActiveIndex: () => {
|
651
|
+
var u, x;
|
652
|
+
return (x = (u = e.activeOptionIndex) != null ? u : c.findIndex((O) => !d(O))) != null ? x : null;
|
659
653
|
}, resolveDisabled: d, resolveId() {
|
660
654
|
throw new Error("Function not implemented.");
|
661
655
|
} }), b = (o = i.trigger) != null ? o : 2;
|
662
|
-
return e.activeOptionIndex ===
|
656
|
+
return e.activeOptionIndex === m && e.activationTrigger === b ? e : { ...e, activeOptionIndex: m, activationTrigger: b, isTyping: !1, __demoMode: !1 };
|
663
657
|
}
|
664
658
|
let l = ge(e);
|
665
659
|
if (l.activeOptionIndex === null) {
|
666
660
|
let c = l.options.findIndex((d) => !d.dataRef.current.disabled);
|
667
661
|
c !== -1 && (l.activeOptionIndex = c);
|
668
662
|
}
|
669
|
-
let s = i.focus ===
|
663
|
+
let s = i.focus === M.Specific ? i.idx : Le(i, { resolveItems: () => l.options, resolveActiveIndex: () => l.activeOptionIndex, resolveId: (c) => c.id, resolveDisabled: (c) => c.dataRef.current.disabled }), a = (r = i.trigger) != null ? r : 2;
|
670
664
|
return e.activeOptionIndex === s && e.activationTrigger === a ? e : { ...e, ...l, isTyping: !1, activeOptionIndex: s, activationTrigger: a, __demoMode: !1 };
|
671
665
|
}, 4: (e, i) => {
|
672
666
|
var t, n, o;
|
@@ -693,7 +687,7 @@ let nn = { 1(e) {
|
|
693
687
|
r !== -1 ? o = r : o = null;
|
694
688
|
}
|
695
689
|
return { ...e, activeOptionIndex: o, virtual: { options: i.options, disabled: (n = i.disabled) != null ? n : () => !1 } };
|
696
|
-
}, 8: (e, i) => e.inputElement === i.element ? e : { ...e, inputElement: i.element }, 9: (e, i) => e.buttonElement === i.element ? e : { ...e, buttonElement: i.element }, 10: (e, i) => e.optionsElement === i.element ? e : { ...e, optionsElement: i.element } }, Re =
|
690
|
+
}, 8: (e, i) => e.inputElement === i.element ? e : { ...e, inputElement: i.element }, 9: (e, i) => e.buttonElement === i.element ? e : { ...e, buttonElement: i.element }, 10: (e, i) => e.optionsElement === i.element ? e : { ...e, optionsElement: i.element } }, Re = ye(null);
|
697
691
|
Re.displayName = "ComboboxActionsContext";
|
698
692
|
function de(e) {
|
699
693
|
let i = Ce(Re);
|
@@ -703,9 +697,9 @@ function de(e) {
|
|
703
697
|
}
|
704
698
|
return i;
|
705
699
|
}
|
706
|
-
let Ge =
|
700
|
+
let Ge = ye(null);
|
707
701
|
function on(e) {
|
708
|
-
let i =
|
702
|
+
let i = ne("VirtualProvider"), { options: t } = i.virtual, [n, o] = G(() => {
|
709
703
|
let c = i.optionsElement;
|
710
704
|
if (!c) return [0, 0];
|
711
705
|
let d = window.getComputedStyle(c);
|
@@ -714,215 +708,218 @@ function on(e) {
|
|
714
708
|
return 40;
|
715
709
|
}, getScrollElement() {
|
716
710
|
return i.optionsElement;
|
717
|
-
}, overscan: 12 }), [l, s] =
|
718
|
-
|
711
|
+
}, overscan: 12 }), [l, s] = Te(0);
|
712
|
+
H(() => {
|
719
713
|
s((c) => c + 1);
|
720
714
|
}, [t]);
|
721
715
|
let a = r.getVirtualItems();
|
722
|
-
return a.length === 0 ? null :
|
723
|
-
|
716
|
+
return a.length === 0 ? null : z.createElement(Ge.Provider, { value: r }, z.createElement("div", { style: { position: "relative", width: "100%", height: `${r.getTotalSize()}px` }, ref: (c) => {
|
717
|
+
if (c) {
|
718
|
+
if (typeof process < "u" && process.env.JEST_WORKER_ID !== void 0 || i.activationTrigger === 0) return;
|
719
|
+
i.activeOptionIndex !== null && t.length > i.activeOptionIndex && r.scrollToIndex(i.activeOptionIndex);
|
720
|
+
}
|
724
721
|
} }, a.map((c) => {
|
725
722
|
var d;
|
726
|
-
return
|
723
|
+
return z.createElement(He, { key: c.key }, z.cloneElement((d = e.children) == null ? void 0 : d.call(e, { ...e.slot, option: t[c.index] }), { key: `${l}-${c.key}`, "data-index": c.index, "aria-setsize": t.length, "aria-posinset": c.index + 1, style: { position: "absolute", top: 0, left: 0, transform: `translateY(${c.start}px)`, overflowAnchor: "none" } }));
|
727
724
|
})));
|
728
725
|
}
|
729
|
-
let ae =
|
726
|
+
let ae = ye(null);
|
730
727
|
ae.displayName = "ComboboxDataContext";
|
731
|
-
function
|
728
|
+
function ne(e) {
|
732
729
|
let i = Ce(ae);
|
733
730
|
if (i === null) {
|
734
731
|
let t = new Error(`<${e} /> is missing a parent <Combobox /> component.`);
|
735
|
-
throw Error.captureStackTrace && Error.captureStackTrace(t,
|
732
|
+
throw Error.captureStackTrace && Error.captureStackTrace(t, ne), t;
|
736
733
|
}
|
737
734
|
return i;
|
738
735
|
}
|
739
736
|
function rn(e, i) {
|
740
|
-
return
|
737
|
+
return te(i.type, nn, e, i);
|
741
738
|
}
|
742
|
-
let sn =
|
739
|
+
let sn = He;
|
743
740
|
function ln(e, i) {
|
744
741
|
var t, n;
|
745
|
-
let o = rt(), { value: r, defaultValue: l, onChange: s, form: a, name: c, by: d, disabled:
|
746
|
-
if (
|
742
|
+
let o = rt(), { value: r, defaultValue: l, onChange: s, form: a, name: c, by: d, disabled: m = o || !1, onClose: b, __demoMode: u = !1, multiple: x = !1, immediate: O = !1, virtual: h = null, nullable: y, ...$ } = e, _ = st(l), [S = x ? [] : void 0, w] = lt(r, s, _), [I, C] = et(rn, { dataRef: tt(), comboboxState: u ? 0 : 1, isTyping: !1, options: [], virtual: h ? { options: h.options, disabled: (t = h.disabled) != null ? t : () => !1 } : null, activeOptionIndex: null, activationTrigger: 2, inputElement: null, buttonElement: null, optionsElement: null, __demoMode: u }), E = V(!1), j = V({ static: !1, hold: !1 }), A = ot(d), U = g((v) => h ? d === null ? h.options.indexOf(v) : h.options.findIndex((T) => A(T, v)) : I.options.findIndex((T) => A(T.dataRef.current.value, v))), q = Ee((v) => te(p.mode, { 1: () => S.some((T) => A(T, v)), 0: () => A(S, v) }), [S]), K = g((v) => I.activeOptionIndex === U(v)), p = G(() => ({ ...I, immediate: O, optionsPropsRef: j, value: S, defaultValue: _, disabled: m, mode: x ? 1 : 0, virtual: h ? I.virtual : null, get activeOptionIndex() {
|
743
|
+
if (E.current && I.activeOptionIndex === null && (h ? h.options.length > 0 : I.options.length > 0)) {
|
747
744
|
if (h) {
|
748
|
-
let
|
745
|
+
let T = h.options.findIndex((W) => {
|
749
746
|
var pe, $e;
|
750
|
-
return !(($e = (pe = h.disabled) == null ? void 0 : pe.call(h,
|
747
|
+
return !(($e = (pe = h.disabled) == null ? void 0 : pe.call(h, W)) != null && $e);
|
751
748
|
});
|
752
|
-
if (
|
749
|
+
if (T !== -1) return T;
|
753
750
|
}
|
754
|
-
let
|
755
|
-
if (
|
751
|
+
let v = I.options.findIndex((T) => !T.dataRef.current.disabled);
|
752
|
+
if (v !== -1) return v;
|
756
753
|
}
|
757
754
|
return I.activeOptionIndex;
|
758
|
-
}, calculateIndex: U, compare: A, isSelected: q, isActive: K }), [
|
759
|
-
|
760
|
-
var
|
761
|
-
h &&
|
762
|
-
}, [h, h == null ? void 0 : h.options, h == null ? void 0 : h.disabled]),
|
755
|
+
}, calculateIndex: U, compare: A, isSelected: q, isActive: K }), [S, _, m, x, u, I, h]);
|
756
|
+
H(() => {
|
757
|
+
var v;
|
758
|
+
h && C({ type: 7, options: h.options, disabled: (v = h.disabled) != null ? v : null });
|
759
|
+
}, [h, h == null ? void 0 : h.options, h == null ? void 0 : h.disabled]), H(() => {
|
763
760
|
I.dataRef.current = p;
|
764
761
|
}, [p]);
|
765
762
|
let B = p.comboboxState === 0;
|
766
763
|
ft(B, [p.buttonElement, p.inputElement, p.optionsElement], () => F.closeCombobox());
|
767
|
-
let
|
768
|
-
var
|
769
|
-
return { open: p.comboboxState === 0, disabled:
|
770
|
-
}, [p,
|
764
|
+
let oe = G(() => {
|
765
|
+
var v, T, W;
|
766
|
+
return { open: p.comboboxState === 0, disabled: m, activeIndex: p.activeOptionIndex, activeOption: p.activeOptionIndex === null ? null : p.virtual ? p.virtual.options[(v = p.activeOptionIndex) != null ? v : 0] : (W = (T = p.options[p.activeOptionIndex]) == null ? void 0 : T.dataRef.current.value) != null ? W : null, value: S };
|
767
|
+
}, [p, m, S]), Y = g(() => {
|
771
768
|
if (p.activeOptionIndex !== null) {
|
772
|
-
if (F.setIsTyping(!1), p.virtual)
|
769
|
+
if (F.setIsTyping(!1), p.virtual) f(p.virtual.options[p.activeOptionIndex]);
|
773
770
|
else {
|
774
|
-
let { dataRef:
|
775
|
-
|
771
|
+
let { dataRef: v } = p.options[p.activeOptionIndex];
|
772
|
+
f(v.current.value);
|
776
773
|
}
|
777
|
-
F.goToOption(
|
774
|
+
F.goToOption(M.Specific, p.activeOptionIndex);
|
778
775
|
}
|
779
776
|
}), X = g(() => {
|
780
|
-
|
777
|
+
C({ type: 0 }), E.current = !0;
|
781
778
|
}), ee = g(() => {
|
782
|
-
|
783
|
-
}),
|
784
|
-
|
785
|
-
}), D = g((
|
786
|
-
p.isActive(
|
787
|
-
})),
|
788
|
-
return
|
779
|
+
C({ type: 1 }), E.current = !1, b == null || b();
|
780
|
+
}), ie = g((v) => {
|
781
|
+
C({ type: 3, isTyping: v });
|
782
|
+
}), D = g((v, T, W) => (E.current = !1, v === M.Specific ? C({ type: 2, focus: M.Specific, idx: T, trigger: W }) : C({ type: 2, focus: v, trigger: W }))), ve = g((v, T) => (C({ type: 4, payload: { id: v, dataRef: T } }), () => {
|
783
|
+
p.isActive(T.current.value) && (E.current = !0), C({ type: 5, id: v });
|
784
|
+
})), f = g((v) => te(p.mode, { 0() {
|
785
|
+
return w == null ? void 0 : w(v);
|
789
786
|
}, 1() {
|
790
|
-
let
|
791
|
-
return
|
792
|
-
} })),
|
793
|
-
|
794
|
-
}),
|
795
|
-
|
796
|
-
}),
|
797
|
-
|
798
|
-
}),
|
799
|
-
|
800
|
-
}), F = G(() => ({ onChange:
|
801
|
-
if (
|
802
|
-
}, [
|
803
|
-
return
|
787
|
+
let T = p.value.slice(), W = T.findIndex((pe) => A(pe, v));
|
788
|
+
return W === -1 ? T.push(v) : T.splice(W, 1), w == null ? void 0 : w(T);
|
789
|
+
} })), L = g((v) => {
|
790
|
+
C({ type: 6, trigger: v });
|
791
|
+
}), P = g((v) => {
|
792
|
+
C({ type: 8, element: v });
|
793
|
+
}), N = g((v) => {
|
794
|
+
C({ type: 9, element: v });
|
795
|
+
}), R = g((v) => {
|
796
|
+
C({ type: 10, element: v });
|
797
|
+
}), F = G(() => ({ onChange: f, registerOption: ve, goToOption: D, setIsTyping: ie, closeCombobox: ee, openCombobox: X, setActivationTrigger: L, selectActiveOption: Y, setInputElement: P, setButtonElement: N, setOptionsElement: R }), []), [Q, qe] = at(), Ye = i === null ? {} : { ref: i }, Xe = Ee(() => {
|
798
|
+
if (_ !== void 0) return w == null ? void 0 : w(_);
|
799
|
+
}, [w, _]);
|
800
|
+
return z.createElement(qe, { value: Q, props: { htmlFor: (n = p.inputElement) == null ? void 0 : n.id }, slot: { open: p.comboboxState === 0, disabled: m } }, z.createElement(ht, null, z.createElement(Re.Provider, { value: F }, z.createElement(ae.Provider, { value: p }, z.createElement(yt, { value: te(p.comboboxState, { 0: me.Open, 1: me.Closed }) }, c != null && z.createElement(ut, { disabled: m, data: S != null ? { [c]: S } : {}, form: a, onReset: Xe }), ce({ ourProps: Ye, theirProps: $, slot: oe, defaultTag: sn, name: "Combobox" }))))));
|
804
801
|
}
|
805
802
|
let an = "input";
|
806
803
|
function un(e, i) {
|
807
804
|
var t, n, o, r, l;
|
808
|
-
let s =
|
809
|
-
a.onChange(null), s.optionsElement && (s.optionsElement.scrollTop = 0), a.goToOption(
|
810
|
-
}),
|
811
|
-
var
|
812
|
-
return typeof u == "function" && s.value !== void 0 ? (
|
805
|
+
let s = ne("Combobox.Input"), a = de("Combobox.Input"), c = he(), d = ct(), { id: m = d || `headlessui-combobox-input-${c}`, onChange: b, displayValue: u, disabled: x = s.disabled || !1, autoFocus: O = !1, type: h = "text", ...y } = e, $ = V(null), _ = fe($, i, vt(), a.setInputElement), S = je(s.inputElement), w = Qe(), I = g(() => {
|
806
|
+
a.onChange(null), s.optionsElement && (s.optionsElement.scrollTop = 0), a.goToOption(M.Nothing);
|
807
|
+
}), C = G(() => {
|
808
|
+
var f;
|
809
|
+
return typeof u == "function" && s.value !== void 0 ? (f = u(s.value)) != null ? f : "" : typeof s.value == "string" ? s.value : "";
|
813
810
|
}, [s.value, u]);
|
814
|
-
Ae(([
|
811
|
+
Ae(([f, L], [P, N]) => {
|
815
812
|
if (s.isTyping) return;
|
816
|
-
let
|
817
|
-
|
818
|
-
if (s.isTyping || !
|
819
|
-
let { selectionStart: F, selectionEnd: Q } =
|
820
|
-
Math.abs((Q ?? 0) - (F ?? 0)) === 0 && F === 0 &&
|
813
|
+
let R = $.current;
|
814
|
+
R && ((N === 0 && L === 1 || f !== P) && (R.value = f), requestAnimationFrame(() => {
|
815
|
+
if (s.isTyping || !R || (S == null ? void 0 : S.activeElement) !== R) return;
|
816
|
+
let { selectionStart: F, selectionEnd: Q } = R;
|
817
|
+
Math.abs((Q ?? 0) - (F ?? 0)) === 0 && F === 0 && R.setSelectionRange(R.value.length, R.value.length);
|
821
818
|
}));
|
822
|
-
}, [
|
823
|
-
if (
|
819
|
+
}, [C, s.comboboxState, S, s.isTyping]), Ae(([f], [L]) => {
|
820
|
+
if (f === 0 && L === 1) {
|
824
821
|
if (s.isTyping) return;
|
825
|
-
let
|
826
|
-
if (!
|
827
|
-
let
|
828
|
-
|
822
|
+
let P = $.current;
|
823
|
+
if (!P) return;
|
824
|
+
let N = P.value, { selectionStart: R, selectionEnd: F, selectionDirection: Q } = P;
|
825
|
+
P.value = "", P.value = N, Q !== null ? P.setSelectionRange(R, F, Q) : P.setSelectionRange(R, F);
|
829
826
|
}
|
830
827
|
}, [s.comboboxState]);
|
831
|
-
let
|
832
|
-
|
828
|
+
let E = V(!1), j = g(() => {
|
829
|
+
E.current = !0;
|
833
830
|
}), A = g(() => {
|
834
|
-
|
835
|
-
|
831
|
+
w.nextFrame(() => {
|
832
|
+
E.current = !1;
|
836
833
|
});
|
837
|
-
}), U = g((
|
838
|
-
switch (a.setIsTyping(!0),
|
834
|
+
}), U = g((f) => {
|
835
|
+
switch (a.setIsTyping(!0), f.key) {
|
839
836
|
case k.Enter:
|
840
|
-
if (s.comboboxState !== 0 ||
|
841
|
-
if (
|
837
|
+
if (s.comboboxState !== 0 || E.current) return;
|
838
|
+
if (f.preventDefault(), f.stopPropagation(), s.activeOptionIndex === null) {
|
842
839
|
a.closeCombobox();
|
843
840
|
return;
|
844
841
|
}
|
845
842
|
a.selectActiveOption(), s.mode === 0 && a.closeCombobox();
|
846
843
|
break;
|
847
844
|
case k.ArrowDown:
|
848
|
-
return
|
845
|
+
return f.preventDefault(), f.stopPropagation(), te(s.comboboxState, { 0: () => a.goToOption(M.Next), 1: () => a.openCombobox() });
|
849
846
|
case k.ArrowUp:
|
850
|
-
return
|
851
|
-
Z(() => a.openCombobox()), s.value || a.goToOption(
|
847
|
+
return f.preventDefault(), f.stopPropagation(), te(s.comboboxState, { 0: () => a.goToOption(M.Previous), 1: () => {
|
848
|
+
Z(() => a.openCombobox()), s.value || a.goToOption(M.Last);
|
852
849
|
} });
|
853
850
|
case k.Home:
|
854
|
-
if (
|
855
|
-
return
|
851
|
+
if (f.shiftKey) break;
|
852
|
+
return f.preventDefault(), f.stopPropagation(), a.goToOption(M.First);
|
856
853
|
case k.PageUp:
|
857
|
-
return
|
854
|
+
return f.preventDefault(), f.stopPropagation(), a.goToOption(M.First);
|
858
855
|
case k.End:
|
859
|
-
if (
|
860
|
-
return
|
856
|
+
if (f.shiftKey) break;
|
857
|
+
return f.preventDefault(), f.stopPropagation(), a.goToOption(M.Last);
|
861
858
|
case k.PageDown:
|
862
|
-
return
|
859
|
+
return f.preventDefault(), f.stopPropagation(), a.goToOption(M.Last);
|
863
860
|
case k.Escape:
|
864
|
-
return s.comboboxState !== 0 ? void 0 : (
|
861
|
+
return s.comboboxState !== 0 ? void 0 : (f.preventDefault(), s.optionsElement && !s.optionsPropsRef.current.static && f.stopPropagation(), s.mode === 0 && s.value === null && I(), a.closeCombobox());
|
865
862
|
case k.Tab:
|
866
863
|
if (s.comboboxState !== 0) return;
|
867
864
|
s.mode === 0 && s.activationTrigger !== 1 && a.selectActiveOption(), a.closeCombobox();
|
868
865
|
break;
|
869
866
|
}
|
870
|
-
}), q = g((
|
871
|
-
b == null || b(
|
872
|
-
}), K = g((
|
873
|
-
var
|
874
|
-
let
|
875
|
-
if (!((
|
876
|
-
}), p = g((
|
877
|
-
var
|
878
|
-
let
|
879
|
-
(
|
867
|
+
}), q = g((f) => {
|
868
|
+
b == null || b(f), s.mode === 0 && f.target.value === "" && I(), a.openCombobox();
|
869
|
+
}), K = g((f) => {
|
870
|
+
var L, P, N;
|
871
|
+
let R = (L = f.relatedTarget) != null ? L : J.find((F) => F !== f.currentTarget);
|
872
|
+
if (!((P = s.optionsElement) != null && P.contains(R)) && !((N = s.buttonElement) != null && N.contains(R)) && s.comboboxState === 0) return f.preventDefault(), s.mode === 0 && s.value === null && I(), a.closeCombobox();
|
873
|
+
}), p = g((f) => {
|
874
|
+
var L, P, N;
|
875
|
+
let R = (L = f.relatedTarget) != null ? L : J.find((F) => F !== f.currentTarget);
|
876
|
+
(P = s.buttonElement) != null && P.contains(R) || (N = s.optionsElement) != null && N.contains(R) || s.disabled || s.immediate && s.comboboxState !== 0 && w.microTask(() => {
|
880
877
|
Z(() => a.openCombobox()), a.setActivationTrigger(1);
|
881
878
|
});
|
882
|
-
}), B = we(),
|
883
|
-
return ce({ ourProps: ve, theirProps:
|
879
|
+
}), B = we(), oe = dt(), { isFocused: Y, focusProps: X } = Ve({ autoFocus: O }), { isHovered: ee, hoverProps: ie } = Be({ isDisabled: x }), D = G(() => ({ open: s.comboboxState === 0, disabled: x, hover: ee, focus: Y, autofocus: O }), [s, ee, Y, O, x]), ve = Ie({ ref: _, id: m, role: "combobox", type: h, "aria-controls": (t = s.optionsElement) == null ? void 0 : t.id, "aria-expanded": s.comboboxState === 0, "aria-activedescendant": s.activeOptionIndex === null ? void 0 : s.virtual ? (n = s.options.find((f) => !f.dataRef.current.disabled && s.compare(f.dataRef.current.value, s.virtual.options[s.activeOptionIndex]))) == null ? void 0 : n.id : (o = s.options[s.activeOptionIndex]) == null ? void 0 : o.id, "aria-labelledby": B, "aria-describedby": oe, "aria-autocomplete": "list", defaultValue: (l = (r = e.defaultValue) != null ? r : s.defaultValue !== void 0 ? u == null ? void 0 : u(s.defaultValue) : null) != null ? l : s.defaultValue, disabled: x || void 0, autoFocus: O, onCompositionStart: j, onCompositionEnd: A, onKeyDown: U, onChange: q, onFocus: p, onBlur: K }, X, ie);
|
880
|
+
return ce({ ourProps: ve, theirProps: y, slot: D, defaultTag: an, name: "Combobox.Input" });
|
884
881
|
}
|
885
882
|
let cn = "button";
|
886
883
|
function dn(e, i) {
|
887
884
|
var t;
|
888
|
-
let n =
|
889
|
-
switch (
|
885
|
+
let n = ne("Combobox.Button"), o = de("Combobox.Button"), r = fe(i, o.setButtonElement), l = Je(), s = he(), { id: a = `headlessui-combobox-button-${s}`, disabled: c = n.disabled || !1, autoFocus: d = !1, ...m } = e, b = Ke(n.inputElement), u = g((E) => {
|
886
|
+
switch (E.key) {
|
890
887
|
case k.Space:
|
891
888
|
case k.Enter:
|
892
|
-
|
889
|
+
E.preventDefault(), E.stopPropagation(), n.comboboxState === 1 && Z(() => o.openCombobox()), b();
|
893
890
|
return;
|
894
891
|
case k.ArrowDown:
|
895
|
-
|
892
|
+
E.preventDefault(), E.stopPropagation(), n.comboboxState === 1 && (Z(() => o.openCombobox()), n.value || o.goToOption(M.First)), b();
|
896
893
|
return;
|
897
894
|
case k.ArrowUp:
|
898
|
-
|
895
|
+
E.preventDefault(), E.stopPropagation(), n.comboboxState === 1 && (Z(() => o.openCombobox()), n.value || o.goToOption(M.Last)), b();
|
899
896
|
return;
|
900
897
|
case k.Escape:
|
901
898
|
if (n.comboboxState !== 0) return;
|
902
|
-
|
899
|
+
E.preventDefault(), n.optionsElement && !n.optionsPropsRef.current.static && E.stopPropagation(), Z(() => o.closeCombobox()), b();
|
903
900
|
return;
|
904
901
|
default:
|
905
902
|
return;
|
906
903
|
}
|
907
|
-
}),
|
908
|
-
|
909
|
-
}), O = we([a]), { isFocusVisible: h, focusProps:
|
910
|
-
return ce({ mergeRefs: l, ourProps:
|
904
|
+
}), x = g((E) => {
|
905
|
+
E.preventDefault(), !_t(E.currentTarget) && (E.button === Me.Left && (n.comboboxState === 0 ? o.closeCombobox() : o.openCombobox()), b());
|
906
|
+
}), O = we([a]), { isFocusVisible: h, focusProps: y } = Ve({ autoFocus: d }), { isHovered: $, hoverProps: _ } = Be({ isDisabled: c }), { pressed: S, pressProps: w } = nt({ disabled: c }), I = G(() => ({ open: n.comboboxState === 0, active: S || n.comboboxState === 0, disabled: c, value: n.value, hover: $, focus: h }), [n, $, h, S, c]), C = Ie({ ref: r, id: a, type: Tt(e, n.buttonElement), tabIndex: -1, "aria-haspopup": "listbox", "aria-controls": (t = n.optionsElement) == null ? void 0 : t.id, "aria-expanded": n.comboboxState === 0, "aria-labelledby": O, disabled: c || void 0, autoFocus: d, onMouseDown: x, onKeyDown: u }, y, _, w);
|
907
|
+
return ce({ mergeRefs: l, ourProps: C, theirProps: m, slot: I, defaultTag: cn, name: "Combobox.Button" });
|
911
908
|
}
|
912
909
|
let pn = "div", mn = _e.RenderStrategy | _e.Static;
|
913
910
|
function fn(e, i) {
|
914
911
|
var t, n, o;
|
915
|
-
let r = he(), { id: l = `headlessui-combobox-options-${r}`, hold: s = !1, anchor: a, portal: c = !1, modal: d = !0, transition:
|
912
|
+
let r = he(), { id: l = `headlessui-combobox-options-${r}`, hold: s = !1, anchor: a, portal: c = !1, modal: d = !0, transition: m = !1, ...b } = e, u = ne("Combobox.Options"), x = de("Combobox.Options"), O = bt(a);
|
916
913
|
O && (c = !0);
|
917
|
-
let [h,
|
918
|
-
Et(
|
914
|
+
let [h, y] = gt(O), [$, _] = Te(null), S = xt(), w = fe(i, O ? h : null, x.setOptionsElement, _), I = je(u.optionsElement), C = Ct(), [E, j] = wt(m, $, C !== null ? (C & me.Open) === me.Open : u.comboboxState === 0);
|
915
|
+
Et(E, u.inputElement, x.closeCombobox);
|
919
916
|
let A = u.__demoMode ? !1 : d && u.comboboxState === 0;
|
920
917
|
Ot(A, I);
|
921
918
|
let U = u.__demoMode ? !1 : d && u.comboboxState === 0;
|
922
|
-
Kt(U, { allowed: Ee(() => [u.inputElement, u.buttonElement, u.optionsElement], [u.inputElement, u.buttonElement, u.optionsElement]) }),
|
919
|
+
Kt(U, { allowed: Ee(() => [u.inputElement, u.buttonElement, u.optionsElement], [u.inputElement, u.buttonElement, u.optionsElement]) }), H(() => {
|
923
920
|
var D;
|
924
921
|
u.optionsPropsRef.current.static = (D = e.static) != null ? D : !1;
|
925
|
-
}, [u.optionsPropsRef, e.static]),
|
922
|
+
}, [u.optionsPropsRef, e.static]), H(() => {
|
926
923
|
u.optionsPropsRef.current.hold = s;
|
927
924
|
}, [u.optionsPropsRef, s]), qt(u.comboboxState === 0, { container: u.optionsElement, accept(D) {
|
928
925
|
return D.getAttribute("role") === "option" ? NodeFilter.FILTER_REJECT : D.hasAttribute("role") ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
@@ -930,48 +927,48 @@ function fn(e, i) {
|
|
930
927
|
D.setAttribute("role", "none");
|
931
928
|
} });
|
932
929
|
let q = we([(t = u.buttonElement) == null ? void 0 : t.id]), K = G(() => ({ open: u.comboboxState === 0, option: void 0 }), [u.comboboxState]), p = g(() => {
|
933
|
-
|
930
|
+
x.setActivationTrigger(0);
|
934
931
|
}), B = g((D) => {
|
935
|
-
D.preventDefault(),
|
936
|
-
}),
|
932
|
+
D.preventDefault(), x.setActivationTrigger(0);
|
933
|
+
}), oe = Ie(O ? S() : {}, { "aria-labelledby": q, role: "listbox", "aria-multiselectable": u.mode === 1 ? !0 : void 0, id: l, ref: w, style: { ...b.style, ...y, "--input-width": Pe(u.inputElement, !0).width, "--button-width": Pe(u.buttonElement, !0).width }, onWheel: u.activationTrigger === 0 ? void 0 : p, onMouseDown: B, ...Mt(j) }), Y = E && u.comboboxState === 1, X = Se(Y, (n = u.virtual) == null ? void 0 : n.options), ee = Se(Y, u.value), ie = g((D) => u.compare(ee, D));
|
937
934
|
if (u.virtual) {
|
938
935
|
if (X === void 0) throw new Error("Missing `options` in virtual mode");
|
939
|
-
Object.assign(b, { children:
|
936
|
+
Object.assign(b, { children: z.createElement(ae.Provider, { value: X !== u.virtual.options ? { ...u, virtual: { ...u.virtual, options: X } } : u }, z.createElement(on, { slot: K }, b.children)) });
|
940
937
|
}
|
941
|
-
return
|
938
|
+
return z.createElement(St, { enabled: c ? e.static || E : !1 }, z.createElement(ae.Provider, { value: u.mode === 1 ? u : { ...u, isSelected: ie } }, ce({ ourProps: oe, theirProps: { ...b, children: z.createElement(Yt, { freeze: Y }, typeof b.children == "function" ? (o = b.children) == null ? void 0 : o.call(b, K) : b.children) }, slot: K, defaultTag: pn, features: mn, visible: E, name: "Combobox.Options" })));
|
942
939
|
}
|
943
940
|
let hn = "div";
|
944
941
|
function vn(e, i) {
|
945
942
|
var t, n, o, r;
|
946
|
-
let l =
|
943
|
+
let l = ne("Combobox.Option"), s = de("Combobox.Option"), a = he(), { id: c = `headlessui-combobox-option-${a}`, value: d, disabled: m = (o = (n = (t = l.virtual) == null ? void 0 : t.disabled) == null ? void 0 : n.call(t, d)) != null ? o : !1, order: b = null, ...u } = e, x = Ke(l.inputElement), O = l.virtual ? l.activeOptionIndex === l.calculateIndex(d) : l.activeOptionIndex === null ? !1 : ((r = l.options[l.activeOptionIndex]) == null ? void 0 : r.id) === c, h = l.isSelected(d), y = V(null), $ = Ze({ disabled: m, value: d, domRef: y, order: b }), _ = Ce(Ge), S = fe(i, y, _ ? _.measureElement : null), w = g(() => {
|
947
944
|
s.setIsTyping(!1), s.onChange(d);
|
948
945
|
});
|
949
|
-
|
946
|
+
H(() => s.registerOption(c, $), [$, c]);
|
950
947
|
let I = V(!(l.virtual || l.__demoMode));
|
951
|
-
|
948
|
+
H(() => {
|
952
949
|
if (!l.virtual && !l.__demoMode) return xe().requestAnimationFrame(() => {
|
953
950
|
I.current = !0;
|
954
951
|
});
|
955
|
-
}, [l.virtual, l.__demoMode]),
|
952
|
+
}, [l.virtual, l.__demoMode]), H(() => {
|
956
953
|
if (I.current && l.comboboxState === 0 && O && l.activationTrigger !== 0) return xe().requestAnimationFrame(() => {
|
957
954
|
var p, B;
|
958
|
-
(B = (p =
|
955
|
+
(B = (p = y.current) == null ? void 0 : p.scrollIntoView) == null || B.call(p, { block: "nearest" });
|
959
956
|
});
|
960
|
-
}, [
|
961
|
-
let
|
962
|
-
p.preventDefault(), p.button === Me.Left && (
|
963
|
-
}),
|
964
|
-
if (
|
957
|
+
}, [y, O, l.comboboxState, l.activationTrigger, l.activeOptionIndex]);
|
958
|
+
let C = g((p) => {
|
959
|
+
p.preventDefault(), p.button === Me.Left && (m || (w(), It() || requestAnimationFrame(() => x()), l.mode === 0 && s.closeCombobox()));
|
960
|
+
}), E = g(() => {
|
961
|
+
if (m) return s.goToOption(M.Nothing);
|
965
962
|
let p = l.calculateIndex(d);
|
966
|
-
s.goToOption(
|
967
|
-
}),
|
968
|
-
if (!
|
963
|
+
s.goToOption(M.Specific, p);
|
964
|
+
}), j = Gt(), A = g((p) => j.update(p)), U = g((p) => {
|
965
|
+
if (!j.wasMoved(p) || m || O) return;
|
969
966
|
let B = l.calculateIndex(d);
|
970
|
-
s.goToOption(
|
967
|
+
s.goToOption(M.Specific, B, 0);
|
971
968
|
}), q = g((p) => {
|
972
|
-
|
973
|
-
}), K = G(() => ({ active: O, focus: O, selected: h, disabled:
|
974
|
-
return ce({ ourProps: { id: c, ref:
|
969
|
+
j.wasMoved(p) && (m || O && (l.optionsPropsRef.current.hold || s.goToOption(M.Nothing)));
|
970
|
+
}), K = G(() => ({ active: O, focus: O, selected: h, disabled: m }), [O, h, m]);
|
971
|
+
return ce({ ourProps: { id: c, ref: S, role: "option", tabIndex: m === !0 ? void 0 : -1, "aria-disabled": m === !0 ? !0 : void 0, "aria-selected": h, disabled: void 0, onMouseDown: C, onFocus: E, onPointerEnter: A, onMouseEnter: A, onPointerMove: U, onMouseMove: U, onPointerLeave: q, onMouseLeave: q }, theirProps: u, slot: K, defaultTag: hn, name: "Combobox.Option" });
|
975
972
|
}
|
976
973
|
let bn = ue(ln), gn = ue(dn), xn = ue(un), En = it, On = ue(fn), Sn = ue(vn), Dn = Object.assign(bn, { Input: xn, Button: gn, Label: En, Options: On, Option: Sn });
|
977
974
|
export {
|
@@ -979,5 +976,5 @@ export {
|
|
979
976
|
Dn as H,
|
980
977
|
On as K,
|
981
978
|
gn as U,
|
982
|
-
Sn as
|
979
|
+
Sn as W
|
983
980
|
};
|