@acusti/dropdown 0.51.0 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Dropdown.js +691 -922
- package/dist/Dropdown.js.map +1 -1
- package/dist/styles.d.ts +1 -1
- package/package.json +6 -6
package/dist/Dropdown.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { c } from "react/compiler-runtime";
|
|
3
2
|
import { SYSTEM_UI_FONT, Style } from "@acusti/styling";
|
|
4
3
|
import useBoundingClientRect from "@acusti/use-bounding-client-rect";
|
|
5
4
|
import useKeyboardEvents, { isEventTargetUsingKeyEvent } from "@acusti/use-keyboard-events";
|
|
6
5
|
import clsx from "clsx";
|
|
7
|
-
import { Children,
|
|
6
|
+
import { Children, Fragment, isValidElement, useEffect, useRef, useState } from "react";
|
|
8
7
|
import { getBestMatch } from "@acusti/matchmaking";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
const ROOT_CLASS_NAME = "uktdropdown";
|
|
10
10
|
const ROOT_SELECTOR = `.${ROOT_CLASS_NAME}`;
|
|
11
11
|
const BODY_CLASS_NAME = `${ROOT_CLASS_NAME}-body`;
|
|
@@ -39,6 +39,7 @@ ${TRIGGER_SELECTOR} {
|
|
|
39
39
|
}
|
|
40
40
|
${ROOT_SELECTOR} {
|
|
41
41
|
width: max-content;
|
|
42
|
+
anchor-scope: --uktdd-anchor;
|
|
42
43
|
}
|
|
43
44
|
${ROOT_SELECTOR}.disabled {
|
|
44
45
|
pointer-events: none;
|
|
@@ -46,6 +47,9 @@ ${ROOT_SELECTOR}.disabled {
|
|
|
46
47
|
${ROOT_SELECTOR} > * {
|
|
47
48
|
cursor: default;
|
|
48
49
|
}
|
|
50
|
+
${ROOT_SELECTOR} > :first-child {
|
|
51
|
+
anchor-name: --uktdd-anchor;
|
|
52
|
+
}
|
|
49
53
|
${LABEL_SELECTOR} {
|
|
50
54
|
display: flex;
|
|
51
55
|
align-items: center;
|
|
@@ -56,6 +60,7 @@ ${LABEL_TEXT_SELECTOR} {
|
|
|
56
60
|
${BODY_SELECTOR} {
|
|
57
61
|
box-sizing: border-box;
|
|
58
62
|
position: absolute;
|
|
63
|
+
position-anchor: --uktdd-anchor;
|
|
59
64
|
top: anchor(bottom);
|
|
60
65
|
left: anchor(left);
|
|
61
66
|
bottom: auto;
|
|
@@ -99,932 +104,696 @@ ${BODY_SELECTOR} [data-ukt-active] {
|
|
|
99
104
|
`;
|
|
100
105
|
const ITEM_SELECTOR = `[data-ukt-item], [data-ukt-value]`;
|
|
101
106
|
const getItemElements = (dropdownElement) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
return items;
|
|
107
|
+
if (!dropdownElement) return null;
|
|
108
|
+
const bodyElement = dropdownElement.querySelector(BODY_SELECTOR);
|
|
109
|
+
if (!bodyElement) return null;
|
|
110
|
+
let items = bodyElement.querySelectorAll(ITEM_SELECTOR);
|
|
111
|
+
if (items.length) return items;
|
|
112
|
+
items = bodyElement.children;
|
|
113
|
+
while (items.length === 1) {
|
|
114
|
+
if (items[0].children == null) break;
|
|
115
|
+
items = items[0].children;
|
|
116
|
+
}
|
|
117
|
+
if (items.length === 1) items = bodyElement.children;
|
|
118
|
+
return items;
|
|
116
119
|
};
|
|
117
120
|
const getActiveItemElement = (dropdownElement) => {
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
if (!dropdownElement) return null;
|
|
122
|
+
return dropdownElement.querySelector("[data-ukt-active]");
|
|
120
123
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
});
|
|
124
|
+
var clearItemElementsState = (itemElements) => {
|
|
125
|
+
itemElements.forEach((itemElement) => {
|
|
126
|
+
if (itemElement.hasAttribute("data-ukt-active")) delete itemElement.dataset.uktActive;
|
|
127
|
+
});
|
|
127
128
|
};
|
|
128
|
-
const setActiveItem = ({
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
189
|
-
let {
|
|
190
|
-
parentElement
|
|
191
|
-
} = nextActiveItem;
|
|
192
|
-
let scrollableParent = null;
|
|
193
|
-
while (!scrollableParent && parentElement && parentElement !== dropdownElement) {
|
|
194
|
-
const isScrollable = parentElement.scrollHeight > parentElement.clientHeight + 15;
|
|
195
|
-
if (isScrollable) {
|
|
196
|
-
scrollableParent = parentElement;
|
|
197
|
-
} else {
|
|
198
|
-
parentElement = parentElement.parentElement;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
if (scrollableParent) {
|
|
202
|
-
const parentRect = scrollableParent.getBoundingClientRect();
|
|
203
|
-
const itemRect = nextActiveItem.getBoundingClientRect();
|
|
204
|
-
const isAboveTop = itemRect.top < parentRect.top;
|
|
205
|
-
const isBelowBottom = itemRect.bottom > parentRect.bottom;
|
|
206
|
-
if (isAboveTop || isBelowBottom) {
|
|
207
|
-
let {
|
|
208
|
-
scrollTop
|
|
209
|
-
} = scrollableParent;
|
|
210
|
-
if (isAboveTop) {
|
|
211
|
-
scrollTop -= parentRect.top - itemRect.top;
|
|
212
|
-
} else {
|
|
213
|
-
scrollTop += itemRect.bottom - parentRect.bottom;
|
|
214
|
-
}
|
|
215
|
-
scrollableParent.scrollTop = scrollTop;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
129
|
+
const setActiveItem = ({ dropdownElement, element, event, index, indexAddend, isExactMatch, onActiveItem, text }) => {
|
|
130
|
+
const items = getItemElements(dropdownElement);
|
|
131
|
+
if (!items) return;
|
|
132
|
+
const itemElements = Array.from(items);
|
|
133
|
+
if (!itemElements.length) return;
|
|
134
|
+
const lastIndex = itemElements.length - 1;
|
|
135
|
+
const currentActiveIndex = itemElements.findIndex((itemElement) => itemElement.hasAttribute("data-ukt-active"));
|
|
136
|
+
let nextActiveIndex = currentActiveIndex;
|
|
137
|
+
if (typeof index === "number") nextActiveIndex = index < 0 ? itemElements.length + index : index;
|
|
138
|
+
if (element) nextActiveIndex = itemElements.findIndex((itemElement) => itemElement === element);
|
|
139
|
+
else if (typeof indexAddend === "number") {
|
|
140
|
+
if (currentActiveIndex === -1 && indexAddend === -1) nextActiveIndex = lastIndex;
|
|
141
|
+
else nextActiveIndex += indexAddend;
|
|
142
|
+
nextActiveIndex = Math.max(0, Math.min(nextActiveIndex, lastIndex));
|
|
143
|
+
} else if (typeof text === "string") {
|
|
144
|
+
if (!text) {
|
|
145
|
+
clearItemElementsState(itemElements);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const itemTexts = itemElements.map((itemElement) => itemElement.innerText);
|
|
149
|
+
if (isExactMatch) {
|
|
150
|
+
const textToCompare = text.toLowerCase();
|
|
151
|
+
nextActiveIndex = itemTexts.findIndex((itemText) => itemText.toLowerCase().startsWith(textToCompare));
|
|
152
|
+
if (nextActiveIndex === -1) clearItemElementsState(itemElements);
|
|
153
|
+
} else {
|
|
154
|
+
const bestMatch = getBestMatch({
|
|
155
|
+
items: itemTexts,
|
|
156
|
+
text
|
|
157
|
+
});
|
|
158
|
+
nextActiveIndex = itemTexts.findIndex((itemText) => itemText === bestMatch);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const nextActiveItem = items[nextActiveIndex];
|
|
162
|
+
if (nextActiveItem == null || nextActiveIndex === currentActiveIndex) return;
|
|
163
|
+
clearItemElementsState(itemElements);
|
|
164
|
+
nextActiveItem.setAttribute("data-ukt-active", "");
|
|
165
|
+
const label = nextActiveItem.innerText;
|
|
166
|
+
const value = nextActiveItem.dataset.uktValue ?? label;
|
|
167
|
+
onActiveItem?.({
|
|
168
|
+
element: nextActiveItem,
|
|
169
|
+
event,
|
|
170
|
+
label,
|
|
171
|
+
value
|
|
172
|
+
});
|
|
173
|
+
let { parentElement } = nextActiveItem;
|
|
174
|
+
let scrollableParent = null;
|
|
175
|
+
while (!scrollableParent && parentElement && parentElement !== dropdownElement) if (parentElement.scrollHeight > parentElement.clientHeight + 15) scrollableParent = parentElement;
|
|
176
|
+
else parentElement = parentElement.parentElement;
|
|
177
|
+
if (scrollableParent) {
|
|
178
|
+
const parentRect = scrollableParent.getBoundingClientRect();
|
|
179
|
+
const itemRect = nextActiveItem.getBoundingClientRect();
|
|
180
|
+
const isAboveTop = itemRect.top < parentRect.top;
|
|
181
|
+
const isBelowBottom = itemRect.bottom > parentRect.bottom;
|
|
182
|
+
if (isAboveTop || isBelowBottom) {
|
|
183
|
+
let { scrollTop } = scrollableParent;
|
|
184
|
+
if (isAboveTop) scrollTop -= parentRect.top - itemRect.top;
|
|
185
|
+
else scrollTop += itemRect.bottom - parentRect.bottom;
|
|
186
|
+
scrollableParent.scrollTop = scrollTop;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
218
189
|
};
|
|
219
|
-
|
|
220
|
-
|
|
190
|
+
var CHILDREN_ERROR = "@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.";
|
|
191
|
+
var CLICKABLE_SELECTOR = "button, a[href], input[type=\"button\"], input[type=\"submit\"]";
|
|
192
|
+
var TEXT_INPUT_SELECTOR = "input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea";
|
|
221
193
|
function Dropdown(t0) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
trigger = t222;
|
|
817
|
-
} else {
|
|
818
|
-
let t202;
|
|
819
|
-
if ($[45] !== trigger) {
|
|
820
|
-
t202 = /* @__PURE__ */ jsx("button", { className: TRIGGER_CLASS_NAME, tabIndex: 0, type: "button", children: trigger });
|
|
821
|
-
$[45] = trigger;
|
|
822
|
-
$[46] = t202;
|
|
823
|
-
} else {
|
|
824
|
-
t202 = $[46];
|
|
825
|
-
}
|
|
826
|
-
trigger = t202;
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
if (label) {
|
|
830
|
-
let t202;
|
|
831
|
-
if ($[47] !== label) {
|
|
832
|
-
t202 = /* @__PURE__ */ jsx("div", { className: LABEL_TEXT_CLASS_NAME, children: label });
|
|
833
|
-
$[47] = label;
|
|
834
|
-
$[48] = t202;
|
|
835
|
-
} else {
|
|
836
|
-
t202 = $[48];
|
|
837
|
-
}
|
|
838
|
-
let t212;
|
|
839
|
-
if ($[49] !== t202 || $[50] !== trigger) {
|
|
840
|
-
t212 = /* @__PURE__ */ jsxs("label", { className: LABEL_CLASS_NAME, children: [
|
|
841
|
-
t202,
|
|
842
|
-
trigger
|
|
843
|
-
] });
|
|
844
|
-
$[49] = t202;
|
|
845
|
-
$[50] = trigger;
|
|
846
|
-
$[51] = t212;
|
|
847
|
-
} else {
|
|
848
|
-
t212 = $[51];
|
|
849
|
-
}
|
|
850
|
-
trigger = t212;
|
|
851
|
-
}
|
|
852
|
-
const dropdownRect = useBoundingClientRect(dropdownElement);
|
|
853
|
-
const dropdownBodyRect = useBoundingClientRect(dropdownBodyElement);
|
|
854
|
-
let t20;
|
|
855
|
-
if ($[52] !== dropdownBodyElement) {
|
|
856
|
-
t20 = getBoundingAncestor(dropdownBodyElement);
|
|
857
|
-
$[52] = dropdownBodyElement;
|
|
858
|
-
$[53] = t20;
|
|
859
|
-
} else {
|
|
860
|
-
t20 = $[53];
|
|
861
|
-
}
|
|
862
|
-
const boundingElement = t20;
|
|
863
|
-
const boundingElementRect = useBoundingClientRect(boundingElement);
|
|
864
|
-
let maxHeight;
|
|
865
|
-
let maxWidth;
|
|
866
|
-
if (dropdownBodyRect.top != null && dropdownRect.top != null && boundingElementRect.top != null) {
|
|
867
|
-
const maxHeightUp = dropdownBodyRect.bottom - boundingElementRect.top;
|
|
868
|
-
const maxHeightDown = boundingElementRect.bottom - dropdownBodyRect.top;
|
|
869
|
-
let t212;
|
|
870
|
-
if ($[54] !== dropdownBodyRect.top || $[55] !== dropdownRect.top || $[56] !== maxHeightDown || $[57] !== maxHeightUp) {
|
|
871
|
-
t212 = Math.round(dropdownBodyRect.top > dropdownRect.top ? maxHeightDown : maxHeightUp);
|
|
872
|
-
$[54] = dropdownBodyRect.top;
|
|
873
|
-
$[55] = dropdownRect.top;
|
|
874
|
-
$[56] = maxHeightDown;
|
|
875
|
-
$[57] = maxHeightUp;
|
|
876
|
-
$[58] = t212;
|
|
877
|
-
} else {
|
|
878
|
-
t212 = $[58];
|
|
879
|
-
}
|
|
880
|
-
maxHeight = t212;
|
|
881
|
-
const maxWidthLeft = dropdownBodyRect.right - boundingElementRect.left;
|
|
882
|
-
const maxWidthRight = boundingElementRect.right - dropdownBodyRect.left;
|
|
883
|
-
let t222;
|
|
884
|
-
if ($[59] !== dropdownBodyRect.left || $[60] !== dropdownRect.left || $[61] !== maxWidthLeft || $[62] !== maxWidthRight) {
|
|
885
|
-
t222 = Math.round(dropdownBodyRect.left > dropdownRect.left ? maxWidthRight : maxWidthLeft);
|
|
886
|
-
$[59] = dropdownBodyRect.left;
|
|
887
|
-
$[60] = dropdownRect.left;
|
|
888
|
-
$[61] = maxWidthLeft;
|
|
889
|
-
$[62] = maxWidthRight;
|
|
890
|
-
$[63] = t222;
|
|
891
|
-
} else {
|
|
892
|
-
t222 = $[63];
|
|
893
|
-
}
|
|
894
|
-
maxWidth = t222;
|
|
895
|
-
}
|
|
896
|
-
let t21;
|
|
897
|
-
if ($[64] !== maxHeight || $[65] !== minHeightBody) {
|
|
898
|
-
t21 = maxHeight != null && maxHeight > minHeightBody ? {
|
|
899
|
-
[BODY_MAX_HEIGHT_VAR]: `calc(${maxHeight}px - var(--uktdd-body-buffer))`
|
|
900
|
-
} : null;
|
|
901
|
-
$[64] = maxHeight;
|
|
902
|
-
$[65] = minHeightBody;
|
|
903
|
-
$[66] = t21;
|
|
904
|
-
} else {
|
|
905
|
-
t21 = $[66];
|
|
906
|
-
}
|
|
907
|
-
let t22;
|
|
908
|
-
if ($[67] !== maxWidth || $[68] !== minWidthBody) {
|
|
909
|
-
t22 = maxWidth != null && maxWidth > minWidthBody ? {
|
|
910
|
-
[BODY_MAX_WIDTH_VAR]: `calc(${maxWidth}px - var(--uktdd-body-buffer))`
|
|
911
|
-
} : null;
|
|
912
|
-
$[67] = maxWidth;
|
|
913
|
-
$[68] = minWidthBody;
|
|
914
|
-
$[69] = t22;
|
|
915
|
-
} else {
|
|
916
|
-
t22 = $[69];
|
|
917
|
-
}
|
|
918
|
-
let t23;
|
|
919
|
-
if ($[70] !== styleFromProps || $[71] !== t21 || $[72] !== t22) {
|
|
920
|
-
t23 = {
|
|
921
|
-
...styleFromProps,
|
|
922
|
-
...t21,
|
|
923
|
-
...t22
|
|
924
|
-
};
|
|
925
|
-
$[70] = styleFromProps;
|
|
926
|
-
$[71] = t21;
|
|
927
|
-
$[72] = t22;
|
|
928
|
-
$[73] = t23;
|
|
929
|
-
} else {
|
|
930
|
-
t23 = $[73];
|
|
931
|
-
}
|
|
932
|
-
const style = t23;
|
|
933
|
-
const anchorStyles = `[data-ukt-id="${id}"] > :first-child {
|
|
934
|
-
anchor-name: --uktdd-anchor${id};
|
|
935
|
-
}
|
|
936
|
-
[data-ukt-id="${id}"] ${BODY_SELECTOR} {
|
|
937
|
-
position-anchor: --uktdd-anchor${id};
|
|
938
|
-
}`;
|
|
939
|
-
let t24;
|
|
940
|
-
if ($[74] === Symbol.for("react.memo_cache_sentinel")) {
|
|
941
|
-
t24 = /* @__PURE__ */ jsx(Style, { href: "@acusti/dropdown/Dropdown", children: STYLES });
|
|
942
|
-
$[74] = t24;
|
|
943
|
-
} else {
|
|
944
|
-
t24 = $[74];
|
|
945
|
-
}
|
|
946
|
-
const t25 = `@acusti/dropdown/Dropdown/${id}`;
|
|
947
|
-
let t26;
|
|
948
|
-
if ($[75] !== anchorStyles || $[76] !== t25) {
|
|
949
|
-
t26 = /* @__PURE__ */ jsx(Style, { href: t25, children: anchorStyles });
|
|
950
|
-
$[75] = anchorStyles;
|
|
951
|
-
$[76] = t25;
|
|
952
|
-
$[77] = t26;
|
|
953
|
-
} else {
|
|
954
|
-
t26 = $[77];
|
|
955
|
-
}
|
|
956
|
-
let t27;
|
|
957
|
-
if ($[78] !== className || $[79] !== disabled || $[80] !== isOpen || $[81] !== isSearchable) {
|
|
958
|
-
t27 = clsx(ROOT_CLASS_NAME, className, {
|
|
959
|
-
disabled,
|
|
960
|
-
"is-open": isOpen,
|
|
961
|
-
"is-searchable": isSearchable
|
|
962
|
-
});
|
|
963
|
-
$[78] = className;
|
|
964
|
-
$[79] = disabled;
|
|
965
|
-
$[80] = isOpen;
|
|
966
|
-
$[81] = isSearchable;
|
|
967
|
-
$[82] = t27;
|
|
968
|
-
} else {
|
|
969
|
-
t27 = $[82];
|
|
970
|
-
}
|
|
971
|
-
let t28;
|
|
972
|
-
if ($[83] !== children || $[84] !== childrenCount || $[85] !== isOpen) {
|
|
973
|
-
t28 = isOpen ? /* @__PURE__ */ jsx("div", { className: BODY_CLASS_NAME, ref: setDropdownBodyElement, children: childrenCount > 1 ? children[1] : children }) : null;
|
|
974
|
-
$[83] = children;
|
|
975
|
-
$[84] = childrenCount;
|
|
976
|
-
$[85] = isOpen;
|
|
977
|
-
$[86] = t28;
|
|
978
|
-
} else {
|
|
979
|
-
t28 = $[86];
|
|
980
|
-
}
|
|
981
|
-
let t29;
|
|
982
|
-
if ($[87] !== handleMouseDown || $[88] !== handleMouseOut || $[89] !== handleMouseOver || $[90] !== handleMouseUp || $[91] !== handleRef || $[92] !== id || $[93] !== onClick || $[94] !== style || $[95] !== t27 || $[96] !== t28 || $[97] !== trigger) {
|
|
983
|
-
t29 = /* @__PURE__ */ jsxs("div", { className: t27, "data-ukt-id": id, onClick, onMouseDown: handleMouseDown, onMouseMove: handleMouseMove, onMouseOut: handleMouseOut, onMouseOver: handleMouseOver, onMouseUp: handleMouseUp, ref: handleRef, style, children: [
|
|
984
|
-
trigger,
|
|
985
|
-
t28
|
|
986
|
-
] });
|
|
987
|
-
$[87] = handleMouseDown;
|
|
988
|
-
$[88] = handleMouseOut;
|
|
989
|
-
$[89] = handleMouseOver;
|
|
990
|
-
$[90] = handleMouseUp;
|
|
991
|
-
$[91] = handleRef;
|
|
992
|
-
$[92] = id;
|
|
993
|
-
$[93] = onClick;
|
|
994
|
-
$[94] = style;
|
|
995
|
-
$[95] = t27;
|
|
996
|
-
$[96] = t28;
|
|
997
|
-
$[97] = trigger;
|
|
998
|
-
$[98] = t29;
|
|
999
|
-
} else {
|
|
1000
|
-
t29 = $[98];
|
|
1001
|
-
}
|
|
1002
|
-
let t30;
|
|
1003
|
-
if ($[99] !== t26 || $[100] !== t29) {
|
|
1004
|
-
t30 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1005
|
-
t24,
|
|
1006
|
-
t26,
|
|
1007
|
-
t29
|
|
1008
|
-
] });
|
|
1009
|
-
$[99] = t26;
|
|
1010
|
-
$[100] = t29;
|
|
1011
|
-
$[101] = t30;
|
|
1012
|
-
} else {
|
|
1013
|
-
t30 = $[101];
|
|
1014
|
-
}
|
|
1015
|
-
return t30;
|
|
194
|
+
const $ = c(86);
|
|
195
|
+
const { allowCreate, allowEmpty: t1, children, className, disabled, hasItems: t2, isOpenOnMount, isSearchable, keepOpenOnSubmit: t3, label, minHeightBody: t4, minWidthBody: t5, name, onActiveItem, onClick, onClose, onMouseDown, onMouseUp, onOpen, onSubmitItem, placeholder, style: styleFromProps, tabIndex, value } = t0;
|
|
196
|
+
const allowEmpty = t1 === void 0 ? true : t1;
|
|
197
|
+
const hasItems = t2 === void 0 ? true : t2;
|
|
198
|
+
const keepOpenOnSubmit = t3 === void 0 ? !hasItems : t3;
|
|
199
|
+
const minHeightBody = t4 === void 0 ? 30 : t4;
|
|
200
|
+
const childrenCount = Children.count(children);
|
|
201
|
+
if (childrenCount !== 1 && childrenCount !== 2) {
|
|
202
|
+
if (childrenCount === 0) throw new Error(CHILDREN_ERROR + " Received no children.");
|
|
203
|
+
console.error(`${CHILDREN_ERROR} Received ${childrenCount} children.`);
|
|
204
|
+
}
|
|
205
|
+
let trigger;
|
|
206
|
+
if (childrenCount > 1) trigger = children[0];
|
|
207
|
+
const [isOpen, setIsOpen] = useState(isOpenOnMount ?? false);
|
|
208
|
+
const [isOpening, setIsOpening] = useState(!isOpenOnMount);
|
|
209
|
+
const [dropdownElement, setDropdownElement] = useState(null);
|
|
210
|
+
const [dropdownBodyElement, setDropdownBodyElement] = useState(null);
|
|
211
|
+
const inputElementRef = useRef(null);
|
|
212
|
+
const closingTimerRef = useRef(null);
|
|
213
|
+
const isOpeningTimerRef = useRef(null);
|
|
214
|
+
const currentInputMethodRef = useRef("mouse");
|
|
215
|
+
const clearEnteredCharactersTimerRef = useRef(null);
|
|
216
|
+
const enteredCharactersRef = useRef("");
|
|
217
|
+
const mouseDownPositionRef = useRef(null);
|
|
218
|
+
const allowCreateRef = useRef(allowCreate);
|
|
219
|
+
const allowEmptyRef = useRef(allowEmpty);
|
|
220
|
+
const hasItemsRef = useRef(hasItems);
|
|
221
|
+
const isOpenRef = useRef(isOpen);
|
|
222
|
+
const isOpeningRef = useRef(isOpening);
|
|
223
|
+
const keepOpenOnSubmitRef = useRef(keepOpenOnSubmit);
|
|
224
|
+
const onCloseRef = useRef(onClose);
|
|
225
|
+
const onOpenRef = useRef(onOpen);
|
|
226
|
+
const onSubmitItemRef = useRef(onSubmitItem);
|
|
227
|
+
const valueRef = useRef(value);
|
|
228
|
+
let t6;
|
|
229
|
+
let t7;
|
|
230
|
+
if ($[0] !== allowCreate || $[1] !== allowEmpty || $[2] !== hasItems || $[3] !== isOpen || $[4] !== isOpening || $[5] !== keepOpenOnSubmit || $[6] !== onClose || $[7] !== onOpen || $[8] !== onSubmitItem || $[9] !== value) {
|
|
231
|
+
t6 = () => {
|
|
232
|
+
allowCreateRef.current = allowCreate;
|
|
233
|
+
allowEmptyRef.current = allowEmpty;
|
|
234
|
+
hasItemsRef.current = hasItems;
|
|
235
|
+
isOpenRef.current = isOpen;
|
|
236
|
+
isOpeningRef.current = isOpening;
|
|
237
|
+
keepOpenOnSubmitRef.current = keepOpenOnSubmit;
|
|
238
|
+
onCloseRef.current = onClose;
|
|
239
|
+
onOpenRef.current = onOpen;
|
|
240
|
+
onSubmitItemRef.current = onSubmitItem;
|
|
241
|
+
valueRef.current = value;
|
|
242
|
+
};
|
|
243
|
+
t7 = [
|
|
244
|
+
allowCreate,
|
|
245
|
+
allowEmpty,
|
|
246
|
+
hasItems,
|
|
247
|
+
isOpen,
|
|
248
|
+
isOpening,
|
|
249
|
+
keepOpenOnSubmit,
|
|
250
|
+
onClose,
|
|
251
|
+
onOpen,
|
|
252
|
+
onSubmitItem,
|
|
253
|
+
value
|
|
254
|
+
];
|
|
255
|
+
$[0] = allowCreate;
|
|
256
|
+
$[1] = allowEmpty;
|
|
257
|
+
$[2] = hasItems;
|
|
258
|
+
$[3] = isOpen;
|
|
259
|
+
$[4] = isOpening;
|
|
260
|
+
$[5] = keepOpenOnSubmit;
|
|
261
|
+
$[6] = onClose;
|
|
262
|
+
$[7] = onOpen;
|
|
263
|
+
$[8] = onSubmitItem;
|
|
264
|
+
$[9] = value;
|
|
265
|
+
$[10] = t6;
|
|
266
|
+
$[11] = t7;
|
|
267
|
+
} else {
|
|
268
|
+
t6 = $[10];
|
|
269
|
+
t7 = $[11];
|
|
270
|
+
}
|
|
271
|
+
useEffect(t6, t7);
|
|
272
|
+
const isMountedRef = useRef(false);
|
|
273
|
+
let t8;
|
|
274
|
+
let t9;
|
|
275
|
+
if ($[12] !== isOpen) {
|
|
276
|
+
t8 = () => {
|
|
277
|
+
if (!isMountedRef.current) {
|
|
278
|
+
isMountedRef.current = true;
|
|
279
|
+
if (isOpenRef.current && onOpenRef.current) onOpenRef.current();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (isOpen && onOpenRef.current) onOpenRef.current();
|
|
283
|
+
else if (!isOpen && onCloseRef.current) onCloseRef.current();
|
|
284
|
+
};
|
|
285
|
+
t9 = [isOpen];
|
|
286
|
+
$[12] = isOpen;
|
|
287
|
+
$[13] = t8;
|
|
288
|
+
$[14] = t9;
|
|
289
|
+
} else {
|
|
290
|
+
t8 = $[13];
|
|
291
|
+
t9 = $[14];
|
|
292
|
+
}
|
|
293
|
+
useEffect(t8, t9);
|
|
294
|
+
let t10;
|
|
295
|
+
if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
|
|
296
|
+
t10 = () => {
|
|
297
|
+
setIsOpen(false);
|
|
298
|
+
setIsOpening(false);
|
|
299
|
+
mouseDownPositionRef.current = null;
|
|
300
|
+
if (closingTimerRef.current != null) {
|
|
301
|
+
clearTimeout(closingTimerRef.current);
|
|
302
|
+
closingTimerRef.current = null;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
$[15] = t10;
|
|
306
|
+
} else t10 = $[15];
|
|
307
|
+
const closeDropdown = t10;
|
|
308
|
+
let t11;
|
|
309
|
+
if ($[16] !== dropdownElement) {
|
|
310
|
+
t11 = (event) => {
|
|
311
|
+
if (isOpenRef.current && !keepOpenOnSubmitRef.current) closingTimerRef.current = setTimeout(closeDropdown, 90);
|
|
312
|
+
if (!hasItemsRef.current) return;
|
|
313
|
+
const element = getActiveItemElement(dropdownElement);
|
|
314
|
+
if (!element && !allowCreateRef.current) {
|
|
315
|
+
if (!allowEmptyRef.current) return;
|
|
316
|
+
if (inputElementRef.current?.value) return;
|
|
317
|
+
}
|
|
318
|
+
let itemLabel = element?.innerText ?? "";
|
|
319
|
+
if (inputElementRef.current) {
|
|
320
|
+
if (!element) itemLabel = inputElementRef.current.value;
|
|
321
|
+
else inputElementRef.current.value = itemLabel;
|
|
322
|
+
if (inputElementRef.current === inputElementRef.current.ownerDocument.activeElement) inputElementRef.current.blur();
|
|
323
|
+
}
|
|
324
|
+
const nextValue = element?.dataset.uktValue ?? itemLabel;
|
|
325
|
+
if (valueRef.current && valueRef.current === nextValue) return;
|
|
326
|
+
if (element) {
|
|
327
|
+
const eventTarget = event.target;
|
|
328
|
+
if (element.matches(CLICKABLE_SELECTOR)) {
|
|
329
|
+
if (element !== eventTarget && !element.contains(eventTarget)) element.click();
|
|
330
|
+
} else {
|
|
331
|
+
const clickableElements = element.querySelectorAll(CLICKABLE_SELECTOR);
|
|
332
|
+
if (clickableElements.length === 1) {
|
|
333
|
+
const clickableElement = clickableElements[0];
|
|
334
|
+
if (clickableElement !== eventTarget && !clickableElement.contains(eventTarget)) clickableElement.click();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
onSubmitItemRef.current?.({
|
|
339
|
+
element,
|
|
340
|
+
event,
|
|
341
|
+
label: itemLabel,
|
|
342
|
+
value: nextValue
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
$[16] = dropdownElement;
|
|
346
|
+
$[17] = t11;
|
|
347
|
+
} else t11 = $[17];
|
|
348
|
+
const handleSubmitItem = t11;
|
|
349
|
+
let t12;
|
|
350
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
351
|
+
t12 = (t13) => {
|
|
352
|
+
const { clientX, clientY } = t13;
|
|
353
|
+
currentInputMethodRef.current = "mouse";
|
|
354
|
+
const initialPosition = mouseDownPositionRef.current;
|
|
355
|
+
if (!initialPosition) return;
|
|
356
|
+
if (Math.abs(initialPosition.clientX - clientX) < 12 && Math.abs(initialPosition.clientY - clientY) < 12) return;
|
|
357
|
+
setIsOpening(false);
|
|
358
|
+
};
|
|
359
|
+
$[18] = t12;
|
|
360
|
+
} else t12 = $[18];
|
|
361
|
+
const handleMouseMove = t12;
|
|
362
|
+
let t13;
|
|
363
|
+
if ($[19] !== dropdownElement || $[20] !== onActiveItem) {
|
|
364
|
+
t13 = (event_0) => {
|
|
365
|
+
if (!hasItemsRef.current) return;
|
|
366
|
+
if (currentInputMethodRef.current !== "mouse") return;
|
|
367
|
+
if (!dropdownElement) return;
|
|
368
|
+
const itemElements = getItemElements(dropdownElement);
|
|
369
|
+
if (!itemElements) return;
|
|
370
|
+
const eventTarget_0 = event_0.target;
|
|
371
|
+
const element_0 = eventTarget_0.closest(ITEM_SELECTOR) ?? eventTarget_0;
|
|
372
|
+
for (const itemElement of itemElements) if (itemElement === element_0) {
|
|
373
|
+
setActiveItem({
|
|
374
|
+
dropdownElement,
|
|
375
|
+
element: element_0,
|
|
376
|
+
event: event_0,
|
|
377
|
+
onActiveItem
|
|
378
|
+
});
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
$[19] = dropdownElement;
|
|
383
|
+
$[20] = onActiveItem;
|
|
384
|
+
$[21] = t13;
|
|
385
|
+
} else t13 = $[21];
|
|
386
|
+
const handleMouseOver = t13;
|
|
387
|
+
let t14;
|
|
388
|
+
if ($[22] !== dropdownElement) {
|
|
389
|
+
t14 = (event_1) => {
|
|
390
|
+
if (!hasItemsRef.current) return;
|
|
391
|
+
const activeItem = getActiveItemElement(dropdownElement);
|
|
392
|
+
if (!activeItem) return;
|
|
393
|
+
const eventRelatedTarget = event_1.relatedTarget;
|
|
394
|
+
if (activeItem !== event_1.target || activeItem.contains(eventRelatedTarget)) return;
|
|
395
|
+
delete activeItem.dataset.uktActive;
|
|
396
|
+
};
|
|
397
|
+
$[22] = dropdownElement;
|
|
398
|
+
$[23] = t14;
|
|
399
|
+
} else t14 = $[23];
|
|
400
|
+
const handleMouseOut = t14;
|
|
401
|
+
let t15;
|
|
402
|
+
if ($[24] !== onMouseDown) {
|
|
403
|
+
t15 = (event_2) => {
|
|
404
|
+
if (onMouseDown) onMouseDown(event_2);
|
|
405
|
+
if (isOpenRef.current) return;
|
|
406
|
+
setIsOpen(true);
|
|
407
|
+
setIsOpening(true);
|
|
408
|
+
mouseDownPositionRef.current = {
|
|
409
|
+
clientX: event_2.clientX,
|
|
410
|
+
clientY: event_2.clientY
|
|
411
|
+
};
|
|
412
|
+
isOpeningTimerRef.current = setTimeout(() => {
|
|
413
|
+
setIsOpening(false);
|
|
414
|
+
isOpeningTimerRef.current = null;
|
|
415
|
+
}, 1e3);
|
|
416
|
+
};
|
|
417
|
+
$[24] = onMouseDown;
|
|
418
|
+
$[25] = t15;
|
|
419
|
+
} else t15 = $[25];
|
|
420
|
+
const handleMouseDown = t15;
|
|
421
|
+
let t16;
|
|
422
|
+
if ($[26] !== handleSubmitItem || $[27] !== onMouseUp) {
|
|
423
|
+
t16 = (event_3) => {
|
|
424
|
+
if (onMouseUp) onMouseUp(event_3);
|
|
425
|
+
if (isOpeningRef.current || !isOpenRef.current || closingTimerRef.current != null) return;
|
|
426
|
+
const eventTarget_1 = event_3.target;
|
|
427
|
+
if (!eventTarget_1.closest(BODY_SELECTOR)) {
|
|
428
|
+
if (!isOpeningRef.current && inputElementRef.current !== eventTarget_1.ownerDocument.activeElement) closeDropdown();
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
if (!hasItemsRef.current) return;
|
|
432
|
+
handleSubmitItem(event_3);
|
|
433
|
+
};
|
|
434
|
+
$[26] = handleSubmitItem;
|
|
435
|
+
$[27] = onMouseUp;
|
|
436
|
+
$[28] = t16;
|
|
437
|
+
} else t16 = $[28];
|
|
438
|
+
const handleMouseUp = t16;
|
|
439
|
+
let t17;
|
|
440
|
+
if ($[29] !== dropdownElement || $[30] !== handleSubmitItem || $[31] !== onActiveItem) {
|
|
441
|
+
t17 = (event_4) => {
|
|
442
|
+
const { altKey, ctrlKey, key, metaKey } = event_4;
|
|
443
|
+
const eventTarget_2 = event_4.target;
|
|
444
|
+
if (!dropdownElement) return;
|
|
445
|
+
const onEventHandled = () => {
|
|
446
|
+
event_4.stopPropagation();
|
|
447
|
+
event_4.preventDefault();
|
|
448
|
+
currentInputMethodRef.current = "keyboard";
|
|
449
|
+
};
|
|
450
|
+
const isEventTargetingDropdown = dropdownElement.contains(eventTarget_2);
|
|
451
|
+
if (!isOpenRef.current) {
|
|
452
|
+
if (!isEventTargetingDropdown) return;
|
|
453
|
+
if (key === " " || key === "Enter" || hasItemsRef.current && (key === "ArrowUp" || key === "ArrowDown")) {
|
|
454
|
+
onEventHandled();
|
|
455
|
+
setIsOpen(true);
|
|
456
|
+
}
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const isTargetUsingKeyEvents = isEventTargetUsingKeyEvent(event_4);
|
|
460
|
+
if (hasItemsRef.current && !isTargetUsingKeyEvents) {
|
|
461
|
+
let isEditingCharacters = !ctrlKey && !metaKey && /^[A-Za-z0-9]$/.test(key);
|
|
462
|
+
if (!isEditingCharacters && enteredCharactersRef.current) isEditingCharacters = key === " " || key === "Backspace";
|
|
463
|
+
if (isEditingCharacters) {
|
|
464
|
+
onEventHandled();
|
|
465
|
+
if (key === "Backspace") enteredCharactersRef.current = enteredCharactersRef.current.slice(0, -1);
|
|
466
|
+
else enteredCharactersRef.current = enteredCharactersRef.current + key;
|
|
467
|
+
setActiveItem({
|
|
468
|
+
dropdownElement,
|
|
469
|
+
event: event_4,
|
|
470
|
+
isExactMatch: allowCreateRef.current,
|
|
471
|
+
onActiveItem,
|
|
472
|
+
text: enteredCharactersRef.current
|
|
473
|
+
});
|
|
474
|
+
if (clearEnteredCharactersTimerRef.current != null) clearTimeout(clearEnteredCharactersTimerRef.current);
|
|
475
|
+
clearEnteredCharactersTimerRef.current = setTimeout(() => {
|
|
476
|
+
enteredCharactersRef.current = "";
|
|
477
|
+
clearEnteredCharactersTimerRef.current = null;
|
|
478
|
+
}, 1500);
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (key === "Enter" || key === " " && !inputElementRef.current) {
|
|
483
|
+
onEventHandled();
|
|
484
|
+
handleSubmitItem(event_4);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
if (key === "Escape" || isEventTargetingDropdown && key === " " && !hasItemsRef.current) {
|
|
488
|
+
if (hasItemsRef.current || !isTargetUsingKeyEvents) closeDropdown();
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (hasItemsRef.current) {
|
|
492
|
+
if (key === "ArrowUp") {
|
|
493
|
+
onEventHandled();
|
|
494
|
+
if (altKey || metaKey) setActiveItem({
|
|
495
|
+
dropdownElement,
|
|
496
|
+
event: event_4,
|
|
497
|
+
index: 0,
|
|
498
|
+
onActiveItem
|
|
499
|
+
});
|
|
500
|
+
else setActiveItem({
|
|
501
|
+
dropdownElement,
|
|
502
|
+
event: event_4,
|
|
503
|
+
indexAddend: -1,
|
|
504
|
+
onActiveItem
|
|
505
|
+
});
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
if (key === "ArrowDown") {
|
|
509
|
+
onEventHandled();
|
|
510
|
+
if (altKey || metaKey) setActiveItem({
|
|
511
|
+
dropdownElement,
|
|
512
|
+
event: event_4,
|
|
513
|
+
index: -1,
|
|
514
|
+
onActiveItem
|
|
515
|
+
});
|
|
516
|
+
else setActiveItem({
|
|
517
|
+
dropdownElement,
|
|
518
|
+
event: event_4,
|
|
519
|
+
indexAddend: 1,
|
|
520
|
+
onActiveItem
|
|
521
|
+
});
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
$[29] = dropdownElement;
|
|
527
|
+
$[30] = handleSubmitItem;
|
|
528
|
+
$[31] = onActiveItem;
|
|
529
|
+
$[32] = t17;
|
|
530
|
+
} else t17 = $[32];
|
|
531
|
+
const handleKeyDown = t17;
|
|
532
|
+
let t18;
|
|
533
|
+
if ($[33] !== handleKeyDown) {
|
|
534
|
+
t18 = {
|
|
535
|
+
ignoreUsedKeyboardEvents: false,
|
|
536
|
+
onKeyDown: handleKeyDown
|
|
537
|
+
};
|
|
538
|
+
$[33] = handleKeyDown;
|
|
539
|
+
$[34] = t18;
|
|
540
|
+
} else t18 = $[34];
|
|
541
|
+
useKeyboardEvents(t18);
|
|
542
|
+
let t19;
|
|
543
|
+
if ($[35] !== isOpenOnMount || $[36] !== onActiveItem) {
|
|
544
|
+
t19 = (ref) => {
|
|
545
|
+
setDropdownElement(ref);
|
|
546
|
+
if (!ref) return;
|
|
547
|
+
const { ownerDocument } = ref;
|
|
548
|
+
let inputElement = inputElementRef.current;
|
|
549
|
+
if (!inputElement && ref.firstElementChild) {
|
|
550
|
+
if (ref.firstElementChild.matches(TEXT_INPUT_SELECTOR)) inputElement = ref.firstElementChild;
|
|
551
|
+
else inputElement = ref.firstElementChild.querySelector(TEXT_INPUT_SELECTOR);
|
|
552
|
+
inputElementRef.current = inputElement;
|
|
553
|
+
}
|
|
554
|
+
const handleGlobalMouseDown = (t20) => {
|
|
555
|
+
const { target } = t20;
|
|
556
|
+
const eventTarget_3 = target;
|
|
557
|
+
if (!ref.contains(eventTarget_3)) closeDropdown();
|
|
558
|
+
};
|
|
559
|
+
const handleGlobalMouseUp = (t21) => {
|
|
560
|
+
const { target: target_0 } = t21;
|
|
561
|
+
if (!isOpenRef.current || closingTimerRef.current != null) return;
|
|
562
|
+
if (isOpeningRef.current) {
|
|
563
|
+
setIsOpening(false);
|
|
564
|
+
if (isOpeningTimerRef.current != null) {
|
|
565
|
+
clearTimeout(isOpeningTimerRef.current);
|
|
566
|
+
isOpeningTimerRef.current = null;
|
|
567
|
+
}
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
const eventTarget_4 = target_0;
|
|
571
|
+
if (!ref.contains(eventTarget_4)) closeDropdown();
|
|
572
|
+
};
|
|
573
|
+
const handleGlobalFocusIn = (t22) => {
|
|
574
|
+
const { target: target_1 } = t22;
|
|
575
|
+
if (!isOpenRef.current) return;
|
|
576
|
+
const eventTarget_5 = target_1;
|
|
577
|
+
if (ref.contains(eventTarget_5) || eventTarget_5.contains(ref)) return;
|
|
578
|
+
closeDropdown();
|
|
579
|
+
};
|
|
580
|
+
document.addEventListener("focusin", handleGlobalFocusIn);
|
|
581
|
+
document.addEventListener("mousedown", handleGlobalMouseDown);
|
|
582
|
+
document.addEventListener("mouseup", handleGlobalMouseUp);
|
|
583
|
+
if (ownerDocument !== document) {
|
|
584
|
+
ownerDocument.addEventListener("focusin", handleGlobalFocusIn);
|
|
585
|
+
ownerDocument.addEventListener("mousedown", handleGlobalMouseDown);
|
|
586
|
+
ownerDocument.addEventListener("mouseup", handleGlobalMouseUp);
|
|
587
|
+
}
|
|
588
|
+
if (isOpenOnMount) ref.focus();
|
|
589
|
+
const handleInput = (event_5) => {
|
|
590
|
+
if (!isOpenRef.current) setIsOpen(true);
|
|
591
|
+
const input = event_5.target;
|
|
592
|
+
const isDeleting = enteredCharactersRef.current.length > input.value.length;
|
|
593
|
+
enteredCharactersRef.current = input.value;
|
|
594
|
+
if (isDeleting && input.value.length && getActiveItemElement(ref)) return;
|
|
595
|
+
setActiveItem({
|
|
596
|
+
dropdownElement: ref,
|
|
597
|
+
event: event_5,
|
|
598
|
+
isExactMatch: allowCreateRef.current,
|
|
599
|
+
onActiveItem,
|
|
600
|
+
text: enteredCharactersRef.current
|
|
601
|
+
});
|
|
602
|
+
};
|
|
603
|
+
if (inputElement) inputElement.addEventListener("input", handleInput);
|
|
604
|
+
return () => {
|
|
605
|
+
document.removeEventListener("focusin", handleGlobalFocusIn);
|
|
606
|
+
document.removeEventListener("mousedown", handleGlobalMouseDown);
|
|
607
|
+
document.removeEventListener("mouseup", handleGlobalMouseUp);
|
|
608
|
+
if (ownerDocument !== document) {
|
|
609
|
+
ownerDocument.removeEventListener("focusin", handleGlobalFocusIn);
|
|
610
|
+
ownerDocument.removeEventListener("mousedown", handleGlobalMouseDown);
|
|
611
|
+
ownerDocument.removeEventListener("mouseup", handleGlobalMouseUp);
|
|
612
|
+
}
|
|
613
|
+
if (inputElement) inputElement.removeEventListener("input", handleInput);
|
|
614
|
+
};
|
|
615
|
+
};
|
|
616
|
+
$[35] = isOpenOnMount;
|
|
617
|
+
$[36] = onActiveItem;
|
|
618
|
+
$[37] = t19;
|
|
619
|
+
} else t19 = $[37];
|
|
620
|
+
const handleRef = t19;
|
|
621
|
+
if (!isValidElement(trigger)) if (isSearchable) {
|
|
622
|
+
const t20 = value ?? "";
|
|
623
|
+
let t21;
|
|
624
|
+
if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
|
|
625
|
+
t21 = () => setIsOpen(true);
|
|
626
|
+
$[38] = t21;
|
|
627
|
+
} else t21 = $[38];
|
|
628
|
+
let t22;
|
|
629
|
+
if ($[39] !== disabled || $[40] !== name || $[41] !== placeholder || $[42] !== t20 || $[43] !== tabIndex) {
|
|
630
|
+
t22 = /* @__PURE__ */ jsx("input", {
|
|
631
|
+
autoComplete: "off",
|
|
632
|
+
className: TRIGGER_CLASS_NAME,
|
|
633
|
+
defaultValue: t20,
|
|
634
|
+
disabled,
|
|
635
|
+
name,
|
|
636
|
+
onFocus: t21,
|
|
637
|
+
placeholder,
|
|
638
|
+
ref: inputElementRef,
|
|
639
|
+
tabIndex,
|
|
640
|
+
type: "text"
|
|
641
|
+
});
|
|
642
|
+
$[39] = disabled;
|
|
643
|
+
$[40] = name;
|
|
644
|
+
$[41] = placeholder;
|
|
645
|
+
$[42] = t20;
|
|
646
|
+
$[43] = tabIndex;
|
|
647
|
+
$[44] = t22;
|
|
648
|
+
} else t22 = $[44];
|
|
649
|
+
trigger = t22;
|
|
650
|
+
} else {
|
|
651
|
+
let t20;
|
|
652
|
+
if ($[45] !== trigger) {
|
|
653
|
+
t20 = /* @__PURE__ */ jsx("button", {
|
|
654
|
+
className: TRIGGER_CLASS_NAME,
|
|
655
|
+
tabIndex: 0,
|
|
656
|
+
type: "button",
|
|
657
|
+
children: trigger
|
|
658
|
+
});
|
|
659
|
+
$[45] = trigger;
|
|
660
|
+
$[46] = t20;
|
|
661
|
+
} else t20 = $[46];
|
|
662
|
+
trigger = t20;
|
|
663
|
+
}
|
|
664
|
+
if (label) {
|
|
665
|
+
let t20;
|
|
666
|
+
if ($[47] !== label) {
|
|
667
|
+
t20 = /* @__PURE__ */ jsx("div", {
|
|
668
|
+
className: LABEL_TEXT_CLASS_NAME,
|
|
669
|
+
children: label
|
|
670
|
+
});
|
|
671
|
+
$[47] = label;
|
|
672
|
+
$[48] = t20;
|
|
673
|
+
} else t20 = $[48];
|
|
674
|
+
let t21;
|
|
675
|
+
if ($[49] !== t20 || $[50] !== trigger) {
|
|
676
|
+
t21 = /* @__PURE__ */ jsxs("label", {
|
|
677
|
+
className: LABEL_CLASS_NAME,
|
|
678
|
+
children: [t20, trigger]
|
|
679
|
+
});
|
|
680
|
+
$[49] = t20;
|
|
681
|
+
$[50] = trigger;
|
|
682
|
+
$[51] = t21;
|
|
683
|
+
} else t21 = $[51];
|
|
684
|
+
trigger = t21;
|
|
685
|
+
}
|
|
686
|
+
const dropdownRect = useBoundingClientRect(dropdownElement);
|
|
687
|
+
const dropdownBodyRect = useBoundingClientRect(dropdownBodyElement);
|
|
688
|
+
let t20;
|
|
689
|
+
if ($[52] !== dropdownBodyElement) {
|
|
690
|
+
t20 = getBoundingAncestor(dropdownBodyElement);
|
|
691
|
+
$[52] = dropdownBodyElement;
|
|
692
|
+
$[53] = t20;
|
|
693
|
+
} else t20 = $[53];
|
|
694
|
+
const boundingElementRect = useBoundingClientRect(t20);
|
|
695
|
+
let maxHeight;
|
|
696
|
+
if (dropdownBodyRect.top != null && dropdownRect.top != null && boundingElementRect.top != null) {
|
|
697
|
+
const maxHeightUp = dropdownBodyRect.bottom - boundingElementRect.top;
|
|
698
|
+
const maxHeightDown = boundingElementRect.bottom - dropdownBodyRect.top;
|
|
699
|
+
let t21;
|
|
700
|
+
if ($[54] !== dropdownBodyRect.top || $[55] !== dropdownRect.top || $[56] !== maxHeightDown || $[57] !== maxHeightUp) {
|
|
701
|
+
t21 = Math.round(dropdownBodyRect.top > dropdownRect.top ? maxHeightDown : maxHeightUp);
|
|
702
|
+
$[54] = dropdownBodyRect.top;
|
|
703
|
+
$[55] = dropdownRect.top;
|
|
704
|
+
$[56] = maxHeightDown;
|
|
705
|
+
$[57] = maxHeightUp;
|
|
706
|
+
$[58] = t21;
|
|
707
|
+
} else t21 = $[58];
|
|
708
|
+
maxHeight = t21;
|
|
709
|
+
}
|
|
710
|
+
let t21;
|
|
711
|
+
if ($[59] !== maxHeight || $[60] !== minHeightBody) {
|
|
712
|
+
t21 = maxHeight != null && maxHeight > minHeightBody ? { [BODY_MAX_HEIGHT_VAR]: `calc(${maxHeight}px - var(--uktdd-body-buffer))` } : null;
|
|
713
|
+
$[59] = maxHeight;
|
|
714
|
+
$[60] = minHeightBody;
|
|
715
|
+
$[61] = t21;
|
|
716
|
+
} else t21 = $[61];
|
|
717
|
+
let t22;
|
|
718
|
+
if ($[62] !== styleFromProps || $[63] !== t21) {
|
|
719
|
+
t22 = {
|
|
720
|
+
...styleFromProps,
|
|
721
|
+
...t21
|
|
722
|
+
};
|
|
723
|
+
$[62] = styleFromProps;
|
|
724
|
+
$[63] = t21;
|
|
725
|
+
$[64] = t22;
|
|
726
|
+
} else t22 = $[64];
|
|
727
|
+
const style = t22;
|
|
728
|
+
let t23;
|
|
729
|
+
if ($[65] === Symbol.for("react.memo_cache_sentinel")) {
|
|
730
|
+
t23 = /* @__PURE__ */ jsx(Style, {
|
|
731
|
+
href: "@acusti/dropdown/Dropdown",
|
|
732
|
+
children: STYLES
|
|
733
|
+
});
|
|
734
|
+
$[65] = t23;
|
|
735
|
+
} else t23 = $[65];
|
|
736
|
+
let t24;
|
|
737
|
+
if ($[66] !== className || $[67] !== disabled || $[68] !== isOpen || $[69] !== isSearchable) {
|
|
738
|
+
t24 = clsx(ROOT_CLASS_NAME, className, {
|
|
739
|
+
disabled,
|
|
740
|
+
"is-open": isOpen,
|
|
741
|
+
"is-searchable": isSearchable
|
|
742
|
+
});
|
|
743
|
+
$[66] = className;
|
|
744
|
+
$[67] = disabled;
|
|
745
|
+
$[68] = isOpen;
|
|
746
|
+
$[69] = isSearchable;
|
|
747
|
+
$[70] = t24;
|
|
748
|
+
} else t24 = $[70];
|
|
749
|
+
let t25;
|
|
750
|
+
if ($[71] !== children || $[72] !== childrenCount || $[73] !== isOpen) {
|
|
751
|
+
t25 = isOpen ? /* @__PURE__ */ jsx("div", {
|
|
752
|
+
className: BODY_CLASS_NAME,
|
|
753
|
+
ref: setDropdownBodyElement,
|
|
754
|
+
children: childrenCount > 1 ? children[1] : children
|
|
755
|
+
}) : null;
|
|
756
|
+
$[71] = children;
|
|
757
|
+
$[72] = childrenCount;
|
|
758
|
+
$[73] = isOpen;
|
|
759
|
+
$[74] = t25;
|
|
760
|
+
} else t25 = $[74];
|
|
761
|
+
let t26;
|
|
762
|
+
if ($[75] !== handleMouseDown || $[76] !== handleMouseOut || $[77] !== handleMouseOver || $[78] !== handleMouseUp || $[79] !== handleRef || $[80] !== onClick || $[81] !== style || $[82] !== t24 || $[83] !== t25 || $[84] !== trigger) {
|
|
763
|
+
t26 = /* @__PURE__ */ jsxs(Fragment, { children: [t23, /* @__PURE__ */ jsxs("div", {
|
|
764
|
+
className: t24,
|
|
765
|
+
onClick,
|
|
766
|
+
onMouseDown: handleMouseDown,
|
|
767
|
+
onMouseMove: handleMouseMove,
|
|
768
|
+
onMouseOut: handleMouseOut,
|
|
769
|
+
onMouseOver: handleMouseOver,
|
|
770
|
+
onMouseUp: handleMouseUp,
|
|
771
|
+
ref: handleRef,
|
|
772
|
+
style,
|
|
773
|
+
children: [trigger, t25]
|
|
774
|
+
})] });
|
|
775
|
+
$[75] = handleMouseDown;
|
|
776
|
+
$[76] = handleMouseOut;
|
|
777
|
+
$[77] = handleMouseOver;
|
|
778
|
+
$[78] = handleMouseUp;
|
|
779
|
+
$[79] = handleRef;
|
|
780
|
+
$[80] = onClick;
|
|
781
|
+
$[81] = style;
|
|
782
|
+
$[82] = t24;
|
|
783
|
+
$[83] = t25;
|
|
784
|
+
$[84] = trigger;
|
|
785
|
+
$[85] = t26;
|
|
786
|
+
} else t26 = $[85];
|
|
787
|
+
return t26;
|
|
1016
788
|
}
|
|
1017
789
|
function getBoundingAncestor(element) {
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
}
|
|
1025
|
-
return null;
|
|
790
|
+
while (element?.parentElement) {
|
|
791
|
+
if (element.parentElement.tagName === "BODY") return element.parentElement;
|
|
792
|
+
if (getComputedStyle(element.parentElement).overflowX !== "visible") return element.parentElement;
|
|
793
|
+
element = element.parentElement;
|
|
794
|
+
}
|
|
795
|
+
return null;
|
|
1026
796
|
}
|
|
1027
|
-
export {
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
//# sourceMappingURL=Dropdown.js.map
|
|
797
|
+
export { Dropdown as default };
|
|
798
|
+
|
|
799
|
+
//# sourceMappingURL=Dropdown.js.map
|