@acusti/dropdown 0.50.0 → 0.51.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 CHANGED
@@ -4,7 +4,7 @@ import { SYSTEM_UI_FONT, Style } from "@acusti/styling";
4
4
  import useBoundingClientRect from "@acusti/use-bounding-client-rect";
5
5
  import useKeyboardEvents, { isEventTargetUsingKeyEvent } from "@acusti/use-keyboard-events";
6
6
  import clsx from "clsx";
7
- import { Children, isValidElement, useState, useRef, useEffect, Fragment } from "react";
7
+ import { Children, useState, useId, useRef, useEffect, isValidElement, Fragment } from "react";
8
8
  import { getBestMatch } from "@acusti/matchmaking";
9
9
  const ROOT_CLASS_NAME = "uktdropdown";
10
10
  const ROOT_SELECTOR = `.${ROOT_CLASS_NAME}`;
@@ -128,9 +128,11 @@ const clearItemElementsState = (itemElements) => {
128
128
  const setActiveItem = ({
129
129
  dropdownElement,
130
130
  element,
131
+ event,
131
132
  index,
132
133
  indexAddend,
133
134
  isExactMatch,
135
+ onActiveItem,
134
136
  text
135
137
  }) => {
136
138
  const items = getItemElements(dropdownElement);
@@ -151,11 +153,7 @@ const setActiveItem = ({
151
153
  } else {
152
154
  nextActiveIndex += indexAddend;
153
155
  }
154
- if (nextActiveIndex < 0) {
155
- nextActiveIndex = 0;
156
- } else if (nextActiveIndex > lastIndex) {
157
- nextActiveIndex = lastIndex;
158
- }
156
+ nextActiveIndex = Math.max(0, Math.min(nextActiveIndex, lastIndex));
159
157
  } else if (typeof text === "string") {
160
158
  if (!text) {
161
159
  clearItemElementsState(itemElements);
@@ -176,47 +174,50 @@ const setActiveItem = ({
176
174
  nextActiveIndex = itemTexts.findIndex((itemText) => itemText === bestMatch);
177
175
  }
178
176
  }
179
- if (nextActiveIndex === -1 || nextActiveIndex === currentActiveIndex) return;
180
- clearItemElementsState(itemElements);
181
177
  const nextActiveItem = items[nextActiveIndex];
182
- if (nextActiveItem != null) {
183
- nextActiveItem.setAttribute("data-ukt-active", "");
184
- let {
185
- parentElement
186
- } = nextActiveItem;
187
- let scrollableParent = null;
188
- while (!scrollableParent && parentElement && parentElement !== dropdownElement) {
189
- const isScrollable = parentElement.scrollHeight > parentElement.clientHeight + 15;
190
- if (isScrollable) {
191
- scrollableParent = parentElement;
192
- } else {
193
- parentElement = parentElement.parentElement;
194
- }
178
+ if (nextActiveItem == null || nextActiveIndex === currentActiveIndex) return;
179
+ clearItemElementsState(itemElements);
180
+ nextActiveItem.setAttribute("data-ukt-active", "");
181
+ const label = nextActiveItem.innerText;
182
+ const value = nextActiveItem.dataset.uktValue ?? label;
183
+ onActiveItem?.({
184
+ element: nextActiveItem,
185
+ event,
186
+ label,
187
+ value
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;
195
199
  }
196
- if (scrollableParent) {
197
- const parentRect = scrollableParent.getBoundingClientRect();
198
- const itemRect = nextActiveItem.getBoundingClientRect();
199
- const isAboveTop = itemRect.top < parentRect.top;
200
- const isBelowBottom = itemRect.bottom > parentRect.bottom;
201
- if (isAboveTop || isBelowBottom) {
202
- let {
203
- scrollTop
204
- } = scrollableParent;
205
- if (isAboveTop) {
206
- scrollTop -= parentRect.top - itemRect.top;
207
- } else {
208
- scrollTop += itemRect.bottom - parentRect.bottom;
209
- }
210
- scrollableParent.scrollTop = scrollTop;
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;
211
214
  }
215
+ scrollableParent.scrollTop = scrollTop;
212
216
  }
213
217
  }
214
218
  };
215
- const noop = () => {
216
- };
217
219
  const CHILDREN_ERROR = "@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.";
218
220
  const TEXT_INPUT_SELECTOR = "input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea";
219
- let idCounter = 0;
220
221
  function Dropdown(t0) {
221
222
  const $ = c(102);
222
223
  const {
@@ -233,6 +234,7 @@ function Dropdown(t0) {
233
234
  minHeightBody: t4,
234
235
  minWidthBody: t5,
235
236
  name,
237
+ onActiveItem,
236
238
  onClick,
237
239
  onClose,
238
240
  onMouseDown,
@@ -260,20 +262,11 @@ function Dropdown(t0) {
260
262
  if (childrenCount > 1) {
261
263
  trigger = children[0];
262
264
  }
263
- let t6;
264
- if ($[0] !== trigger) {
265
- t6 = isValidElement(trigger);
266
- $[0] = trigger;
267
- $[1] = t6;
268
- } else {
269
- t6 = $[1];
270
- }
271
- const isTriggerFromProps = t6;
272
265
  const [isOpen, setIsOpen] = useState(isOpenOnMount ?? false);
273
266
  const [isOpening, setIsOpening] = useState(!isOpenOnMount);
274
267
  const [dropdownElement, setDropdownElement] = useState(null);
275
268
  const [dropdownBodyElement, setDropdownBodyElement] = useState(null);
276
- const [id] = useState(_temp);
269
+ const id = useId();
277
270
  const inputElementRef = useRef(null);
278
271
  const closingTimerRef = useRef(null);
279
272
  const isOpeningTimerRef = useRef(null);
@@ -291,10 +284,10 @@ function Dropdown(t0) {
291
284
  const onOpenRef = useRef(onOpen);
292
285
  const onSubmitItemRef = useRef(onSubmitItem);
293
286
  const valueRef = useRef(value);
287
+ let t6;
294
288
  let t7;
295
- let t8;
296
- if ($[2] !== allowCreate || $[3] !== allowEmpty || $[4] !== hasItems || $[5] !== isOpen || $[6] !== isOpening || $[7] !== keepOpenOnSubmit || $[8] !== onClose || $[9] !== onOpen || $[10] !== onSubmitItem || $[11] !== value) {
297
- t7 = () => {
289
+ if ($[0] !== allowCreate || $[1] !== allowEmpty || $[2] !== hasItems || $[3] !== isOpen || $[4] !== isOpening || $[5] !== keepOpenOnSubmit || $[6] !== onClose || $[7] !== onOpen || $[8] !== onSubmitItem || $[9] !== value) {
290
+ t6 = () => {
298
291
  allowCreateRef.current = allowCreate;
299
292
  allowEmptyRef.current = allowEmpty;
300
293
  hasItemsRef.current = hasItems;
@@ -306,29 +299,29 @@ function Dropdown(t0) {
306
299
  onSubmitItemRef.current = onSubmitItem;
307
300
  valueRef.current = value;
308
301
  };
309
- t8 = [allowCreate, allowEmpty, hasItems, isOpen, isOpening, keepOpenOnSubmit, onClose, onOpen, onSubmitItem, value];
310
- $[2] = allowCreate;
311
- $[3] = allowEmpty;
312
- $[4] = hasItems;
313
- $[5] = isOpen;
314
- $[6] = isOpening;
315
- $[7] = keepOpenOnSubmit;
316
- $[8] = onClose;
317
- $[9] = onOpen;
318
- $[10] = onSubmitItem;
319
- $[11] = value;
320
- $[12] = t7;
321
- $[13] = t8;
302
+ t7 = [allowCreate, allowEmpty, hasItems, isOpen, isOpening, keepOpenOnSubmit, onClose, onOpen, onSubmitItem, value];
303
+ $[0] = allowCreate;
304
+ $[1] = allowEmpty;
305
+ $[2] = hasItems;
306
+ $[3] = isOpen;
307
+ $[4] = isOpening;
308
+ $[5] = keepOpenOnSubmit;
309
+ $[6] = onClose;
310
+ $[7] = onOpen;
311
+ $[8] = onSubmitItem;
312
+ $[9] = value;
313
+ $[10] = t6;
314
+ $[11] = t7;
322
315
  } else {
323
- t7 = $[12];
324
- t8 = $[13];
316
+ t6 = $[10];
317
+ t7 = $[11];
325
318
  }
326
- useEffect(t7, t8);
319
+ useEffect(t6, t7);
327
320
  const isMountedRef = useRef(false);
328
- let t10;
321
+ let t8;
329
322
  let t9;
330
- if ($[14] !== isOpen) {
331
- t9 = () => {
323
+ if ($[12] !== isOpen) {
324
+ t8 = () => {
332
325
  if (!isMountedRef.current) {
333
326
  isMountedRef.current = true;
334
327
  if (isOpenRef.current && onOpenRef.current) {
@@ -344,18 +337,18 @@ function Dropdown(t0) {
344
337
  }
345
338
  }
346
339
  };
347
- t10 = [isOpen];
348
- $[14] = isOpen;
349
- $[15] = t10;
350
- $[16] = t9;
340
+ t9 = [isOpen];
341
+ $[12] = isOpen;
342
+ $[13] = t8;
343
+ $[14] = t9;
351
344
  } else {
352
- t10 = $[15];
353
- t9 = $[16];
345
+ t8 = $[13];
346
+ t9 = $[14];
354
347
  }
355
- useEffect(t9, t10);
356
- let t11;
357
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
358
- t11 = () => {
348
+ useEffect(t8, t9);
349
+ let t10;
350
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
351
+ t10 = () => {
359
352
  setIsOpen(false);
360
353
  setIsOpening(false);
361
354
  mouseDownPositionRef.current = null;
@@ -364,15 +357,14 @@ function Dropdown(t0) {
364
357
  closingTimerRef.current = null;
365
358
  }
366
359
  };
367
- $[17] = t11;
360
+ $[15] = t10;
368
361
  } else {
369
- t11 = $[17];
362
+ t10 = $[15];
370
363
  }
371
- const closeDropdown = t11;
372
- let t12;
373
- if ($[18] !== dropdownElement) {
374
- t12 = (event) => {
375
- var _a;
364
+ const closeDropdown = t10;
365
+ let t11;
366
+ if ($[16] !== dropdownElement) {
367
+ t11 = (event) => {
376
368
  if (isOpenRef.current && !keepOpenOnSubmitRef.current) {
377
369
  closingTimerRef.current = setTimeout(closeDropdown, 90);
378
370
  }
@@ -384,11 +376,11 @@ function Dropdown(t0) {
384
376
  if (!allowEmptyRef.current) {
385
377
  return;
386
378
  }
387
- if ((_a = inputElementRef.current) == null ? void 0 : _a.value) {
379
+ if (inputElementRef.current?.value) {
388
380
  return;
389
381
  }
390
382
  }
391
- let itemLabel = (element == null ? void 0 : element.innerText) ?? "";
383
+ let itemLabel = element?.innerText ?? "";
392
384
  if (inputElementRef.current) {
393
385
  if (!element) {
394
386
  itemLabel = inputElementRef.current.value;
@@ -399,7 +391,7 @@ function Dropdown(t0) {
399
391
  inputElementRef.current.blur();
400
392
  }
401
393
  }
402
- const nextValue = (element == null ? void 0 : element.dataset.uktValue) ?? itemLabel;
394
+ const nextValue = element?.dataset.uktValue ?? itemLabel;
403
395
  if (valueRef.current && valueRef.current === nextValue) {
404
396
  return;
405
397
  }
@@ -412,19 +404,19 @@ function Dropdown(t0) {
412
404
  });
413
405
  }
414
406
  };
415
- $[18] = dropdownElement;
416
- $[19] = t12;
407
+ $[16] = dropdownElement;
408
+ $[17] = t11;
417
409
  } else {
418
- t12 = $[19];
410
+ t11 = $[17];
419
411
  }
420
- const handleSubmitItem = t12;
421
- let t13;
422
- if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
423
- t13 = (t142) => {
412
+ const handleSubmitItem = t11;
413
+ let t12;
414
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
415
+ t12 = (t132) => {
424
416
  const {
425
417
  clientX,
426
418
  clientY
427
- } = t142;
419
+ } = t132;
428
420
  currentInputMethodRef.current = "mouse";
429
421
  const initialPosition = mouseDownPositionRef.current;
430
422
  if (!initialPosition) {
@@ -435,14 +427,14 @@ function Dropdown(t0) {
435
427
  }
436
428
  setIsOpening(false);
437
429
  };
438
- $[20] = t13;
430
+ $[18] = t12;
439
431
  } else {
440
- t13 = $[20];
432
+ t12 = $[18];
441
433
  }
442
- const handleMouseMove = t13;
443
- let t14;
444
- if ($[21] !== dropdownElement) {
445
- t14 = (event_0) => {
434
+ const handleMouseMove = t12;
435
+ let t13;
436
+ if ($[19] !== dropdownElement || $[20] !== onActiveItem) {
437
+ t13 = (event_0) => {
446
438
  if (!hasItemsRef.current) {
447
439
  return;
448
440
  }
@@ -463,21 +455,24 @@ function Dropdown(t0) {
463
455
  if (itemElement === element_0) {
464
456
  setActiveItem({
465
457
  dropdownElement,
466
- element: element_0
458
+ element: element_0,
459
+ event: event_0,
460
+ onActiveItem
467
461
  });
468
462
  return;
469
463
  }
470
464
  }
471
465
  };
472
- $[21] = dropdownElement;
473
- $[22] = t14;
466
+ $[19] = dropdownElement;
467
+ $[20] = onActiveItem;
468
+ $[21] = t13;
474
469
  } else {
475
- t14 = $[22];
470
+ t13 = $[21];
476
471
  }
477
- const handleMouseOver = t14;
478
- let t15;
479
- if ($[23] !== dropdownElement) {
480
- t15 = (event_1) => {
472
+ const handleMouseOver = t13;
473
+ let t14;
474
+ if ($[22] !== dropdownElement) {
475
+ t14 = (event_1) => {
481
476
  if (!hasItemsRef.current) {
482
477
  return;
483
478
  }
@@ -491,15 +486,15 @@ function Dropdown(t0) {
491
486
  }
492
487
  delete activeItem.dataset.uktActive;
493
488
  };
494
- $[23] = dropdownElement;
495
- $[24] = t15;
489
+ $[22] = dropdownElement;
490
+ $[23] = t14;
496
491
  } else {
497
- t15 = $[24];
492
+ t14 = $[23];
498
493
  }
499
- const handleMouseOut = t15;
500
- let t16;
501
- if ($[25] !== onMouseDown) {
502
- t16 = (event_2) => {
494
+ const handleMouseOut = t14;
495
+ let t15;
496
+ if ($[24] !== onMouseDown) {
497
+ t15 = (event_2) => {
503
498
  if (onMouseDown) {
504
499
  onMouseDown(event_2);
505
500
  }
@@ -517,15 +512,15 @@ function Dropdown(t0) {
517
512
  isOpeningTimerRef.current = null;
518
513
  }, 1e3);
519
514
  };
520
- $[25] = onMouseDown;
521
- $[26] = t16;
515
+ $[24] = onMouseDown;
516
+ $[25] = t15;
522
517
  } else {
523
- t16 = $[26];
518
+ t15 = $[25];
524
519
  }
525
- const handleMouseDown = t16;
526
- let t17;
527
- if ($[27] !== handleSubmitItem || $[28] !== onMouseUp) {
528
- t17 = (event_3) => {
520
+ const handleMouseDown = t15;
521
+ let t16;
522
+ if ($[26] !== handleSubmitItem || $[27] !== onMouseUp) {
523
+ t16 = (event_3) => {
529
524
  if (onMouseUp) {
530
525
  onMouseUp(event_3);
531
526
  }
@@ -544,16 +539,16 @@ function Dropdown(t0) {
544
539
  }
545
540
  handleSubmitItem(event_3);
546
541
  };
547
- $[27] = handleSubmitItem;
548
- $[28] = onMouseUp;
549
- $[29] = t17;
542
+ $[26] = handleSubmitItem;
543
+ $[27] = onMouseUp;
544
+ $[28] = t16;
550
545
  } else {
551
- t17 = $[29];
546
+ t16 = $[28];
552
547
  }
553
- const handleMouseUp = t17;
554
- let t18;
555
- if ($[30] !== dropdownElement || $[31] !== handleSubmitItem) {
556
- t18 = (event_4) => {
548
+ const handleMouseUp = t16;
549
+ let t17;
550
+ if ($[29] !== dropdownElement || $[30] !== handleSubmitItem || $[31] !== onActiveItem) {
551
+ t17 = (event_4) => {
557
552
  const {
558
553
  altKey,
559
554
  ctrlKey,
@@ -595,7 +590,9 @@ function Dropdown(t0) {
595
590
  }
596
591
  setActiveItem({
597
592
  dropdownElement,
593
+ event: event_4,
598
594
  isExactMatch: allowCreateRef.current,
595
+ onActiveItem,
599
596
  text: enteredCharactersRef.current
600
597
  });
601
598
  if (clearEnteredCharactersTimerRef.current) {
@@ -625,12 +622,16 @@ function Dropdown(t0) {
625
622
  if (altKey || metaKey) {
626
623
  setActiveItem({
627
624
  dropdownElement,
628
- index: 0
625
+ event: event_4,
626
+ index: 0,
627
+ onActiveItem
629
628
  });
630
629
  } else {
631
630
  setActiveItem({
632
631
  dropdownElement,
633
- indexAddend: -1
632
+ event: event_4,
633
+ indexAddend: -1,
634
+ onActiveItem
634
635
  });
635
636
  }
636
637
  return;
@@ -640,52 +641,54 @@ function Dropdown(t0) {
640
641
  if (altKey || metaKey) {
641
642
  setActiveItem({
642
643
  dropdownElement,
643
- index: -1
644
+ event: event_4,
645
+ index: -1,
646
+ onActiveItem
644
647
  });
645
648
  } else {
646
649
  setActiveItem({
647
650
  dropdownElement,
648
- indexAddend: 1
651
+ event: event_4,
652
+ indexAddend: 1,
653
+ onActiveItem
649
654
  });
650
655
  }
651
656
  return;
652
657
  }
653
658
  }
654
659
  };
655
- $[30] = dropdownElement;
656
- $[31] = handleSubmitItem;
657
- $[32] = t18;
660
+ $[29] = dropdownElement;
661
+ $[30] = handleSubmitItem;
662
+ $[31] = onActiveItem;
663
+ $[32] = t17;
658
664
  } else {
659
- t18 = $[32];
665
+ t17 = $[32];
660
666
  }
661
- const handleKeyDown = t18;
662
- let t19;
667
+ const handleKeyDown = t17;
668
+ let t18;
663
669
  if ($[33] !== handleKeyDown) {
664
- t19 = {
670
+ t18 = {
665
671
  ignoreUsedKeyboardEvents: false,
666
672
  onKeyDown: handleKeyDown
667
673
  };
668
674
  $[33] = handleKeyDown;
669
- $[34] = t19;
675
+ $[34] = t18;
670
676
  } else {
671
- t19 = $[34];
677
+ t18 = $[34];
672
678
  }
673
- useKeyboardEvents(t19);
674
- const cleanupEventListenersRef = useRef(noop);
675
- let t20;
676
- if ($[35] !== isOpenOnMount || $[36] !== isTriggerFromProps) {
677
- t20 = (ref) => {
679
+ useKeyboardEvents(t18);
680
+ let t19;
681
+ if ($[35] !== isOpenOnMount || $[36] !== onActiveItem) {
682
+ t19 = (ref) => {
678
683
  setDropdownElement(ref);
679
684
  if (!ref) {
680
- cleanupEventListenersRef.current();
681
- cleanupEventListenersRef.current = noop;
682
685
  return;
683
686
  }
684
687
  const {
685
688
  ownerDocument
686
689
  } = ref;
687
690
  let inputElement = inputElementRef.current;
688
- if (isTriggerFromProps && !inputElement && ref.firstElementChild) {
691
+ if (!inputElement && ref.firstElementChild) {
689
692
  if (ref.firstElementChild.matches(TEXT_INPUT_SELECTOR)) {
690
693
  inputElement = ref.firstElementChild;
691
694
  } else {
@@ -693,19 +696,19 @@ function Dropdown(t0) {
693
696
  }
694
697
  inputElementRef.current = inputElement;
695
698
  }
696
- const handleGlobalMouseDown = (t212) => {
699
+ const handleGlobalMouseDown = (t202) => {
697
700
  const {
698
701
  target
699
- } = t212;
702
+ } = t202;
700
703
  const eventTarget_2 = target;
701
704
  if (!ref.contains(eventTarget_2)) {
702
705
  closeDropdown();
703
706
  }
704
707
  };
705
- const handleGlobalMouseUp = (t222) => {
708
+ const handleGlobalMouseUp = (t212) => {
706
709
  const {
707
710
  target: target_0
708
- } = t222;
711
+ } = t212;
709
712
  if (!isOpenRef.current || closingTimerRef.current) {
710
713
  return;
711
714
  }
@@ -722,10 +725,10 @@ function Dropdown(t0) {
722
725
  closeDropdown();
723
726
  }
724
727
  };
725
- const handleGlobalFocusIn = (t232) => {
728
+ const handleGlobalFocusIn = (t222) => {
726
729
  const {
727
730
  target: target_1
728
- } = t232;
731
+ } = t222;
729
732
  if (!isOpenRef.current) {
730
733
  return;
731
734
  }
@@ -758,14 +761,16 @@ function Dropdown(t0) {
758
761
  }
759
762
  setActiveItem({
760
763
  dropdownElement: ref,
764
+ event: event_5,
761
765
  isExactMatch: allowCreateRef.current,
766
+ onActiveItem,
762
767
  text: enteredCharactersRef.current
763
768
  });
764
769
  };
765
770
  if (inputElement) {
766
771
  inputElement.addEventListener("input", handleInput);
767
772
  }
768
- cleanupEventListenersRef.current = () => {
773
+ return () => {
769
774
  document.removeEventListener("focusin", handleGlobalFocusIn);
770
775
  document.removeEventListener("mousedown", handleGlobalMouseDown);
771
776
  document.removeEventListener("mouseup", handleGlobalMouseUp);
@@ -780,177 +785,177 @@ function Dropdown(t0) {
780
785
  };
781
786
  };
782
787
  $[35] = isOpenOnMount;
783
- $[36] = isTriggerFromProps;
784
- $[37] = t20;
788
+ $[36] = onActiveItem;
789
+ $[37] = t19;
785
790
  } else {
786
- t20 = $[37];
791
+ t19 = $[37];
787
792
  }
788
- const handleRef = t20;
789
- if (!isTriggerFromProps) {
793
+ const handleRef = t19;
794
+ if (!isValidElement(trigger)) {
790
795
  if (isSearchable) {
791
- const t212 = value ?? "";
792
- let t222;
796
+ const t202 = value ?? "";
797
+ let t212;
793
798
  if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
794
- t222 = () => setIsOpen(true);
795
- $[38] = t222;
799
+ t212 = () => setIsOpen(true);
800
+ $[38] = t212;
796
801
  } else {
797
- t222 = $[38];
802
+ t212 = $[38];
798
803
  }
799
- let t232;
800
- if ($[39] !== disabled || $[40] !== name || $[41] !== placeholder || $[42] !== t212 || $[43] !== tabIndex) {
801
- t232 = /* @__PURE__ */ jsx("input", { autoComplete: "off", className: TRIGGER_CLASS_NAME, defaultValue: t212, disabled, name, onFocus: t222, placeholder, ref: inputElementRef, tabIndex, type: "text" });
804
+ let t222;
805
+ if ($[39] !== disabled || $[40] !== name || $[41] !== placeholder || $[42] !== t202 || $[43] !== tabIndex) {
806
+ t222 = /* @__PURE__ */ jsx("input", { autoComplete: "off", className: TRIGGER_CLASS_NAME, defaultValue: t202, disabled, name, onFocus: t212, placeholder, ref: inputElementRef, tabIndex, type: "text" });
802
807
  $[39] = disabled;
803
808
  $[40] = name;
804
809
  $[41] = placeholder;
805
- $[42] = t212;
810
+ $[42] = t202;
806
811
  $[43] = tabIndex;
807
- $[44] = t232;
812
+ $[44] = t222;
808
813
  } else {
809
- t232 = $[44];
814
+ t222 = $[44];
810
815
  }
811
- trigger = t232;
816
+ trigger = t222;
812
817
  } else {
813
- let t212;
818
+ let t202;
814
819
  if ($[45] !== trigger) {
815
- t212 = /* @__PURE__ */ jsx("button", { className: TRIGGER_CLASS_NAME, tabIndex: 0, children: trigger });
820
+ t202 = /* @__PURE__ */ jsx("button", { className: TRIGGER_CLASS_NAME, tabIndex: 0, type: "button", children: trigger });
816
821
  $[45] = trigger;
817
- $[46] = t212;
822
+ $[46] = t202;
818
823
  } else {
819
- t212 = $[46];
824
+ t202 = $[46];
820
825
  }
821
- trigger = t212;
826
+ trigger = t202;
822
827
  }
823
828
  }
824
829
  if (label) {
825
- let t212;
830
+ let t202;
826
831
  if ($[47] !== label) {
827
- t212 = /* @__PURE__ */ jsx("div", { className: LABEL_TEXT_CLASS_NAME, children: label });
832
+ t202 = /* @__PURE__ */ jsx("div", { className: LABEL_TEXT_CLASS_NAME, children: label });
828
833
  $[47] = label;
829
- $[48] = t212;
834
+ $[48] = t202;
830
835
  } else {
831
- t212 = $[48];
836
+ t202 = $[48];
832
837
  }
833
- let t222;
834
- if ($[49] !== t212 || $[50] !== trigger) {
835
- t222 = /* @__PURE__ */ jsxs("label", { className: LABEL_CLASS_NAME, children: [
836
- t212,
838
+ let t212;
839
+ if ($[49] !== t202 || $[50] !== trigger) {
840
+ t212 = /* @__PURE__ */ jsxs("label", { className: LABEL_CLASS_NAME, children: [
841
+ t202,
837
842
  trigger
838
843
  ] });
839
- $[49] = t212;
844
+ $[49] = t202;
840
845
  $[50] = trigger;
841
- $[51] = t222;
846
+ $[51] = t212;
842
847
  } else {
843
- t222 = $[51];
848
+ t212 = $[51];
844
849
  }
845
- trigger = t222;
850
+ trigger = t212;
846
851
  }
847
852
  const dropdownRect = useBoundingClientRect(dropdownElement);
848
853
  const dropdownBodyRect = useBoundingClientRect(dropdownBodyElement);
849
- let t21;
854
+ let t20;
850
855
  if ($[52] !== dropdownBodyElement) {
851
- t21 = getBoundingAncestor(dropdownBodyElement);
856
+ t20 = getBoundingAncestor(dropdownBodyElement);
852
857
  $[52] = dropdownBodyElement;
853
- $[53] = t21;
858
+ $[53] = t20;
854
859
  } else {
855
- t21 = $[53];
860
+ t20 = $[53];
856
861
  }
857
- const boundingElement = t21;
862
+ const boundingElement = t20;
858
863
  const boundingElementRect = useBoundingClientRect(boundingElement);
859
864
  let maxHeight;
860
865
  let maxWidth;
861
866
  if (dropdownBodyRect.top != null && dropdownRect.top != null && boundingElementRect.top != null) {
862
867
  const maxHeightUp = dropdownBodyRect.bottom - boundingElementRect.top;
863
868
  const maxHeightDown = boundingElementRect.bottom - dropdownBodyRect.top;
864
- let t222;
869
+ let t212;
865
870
  if ($[54] !== dropdownBodyRect.top || $[55] !== dropdownRect.top || $[56] !== maxHeightDown || $[57] !== maxHeightUp) {
866
- t222 = Math.round(dropdownBodyRect.top > dropdownRect.top ? maxHeightDown : maxHeightUp);
871
+ t212 = Math.round(dropdownBodyRect.top > dropdownRect.top ? maxHeightDown : maxHeightUp);
867
872
  $[54] = dropdownBodyRect.top;
868
873
  $[55] = dropdownRect.top;
869
874
  $[56] = maxHeightDown;
870
875
  $[57] = maxHeightUp;
871
- $[58] = t222;
876
+ $[58] = t212;
872
877
  } else {
873
- t222 = $[58];
878
+ t212 = $[58];
874
879
  }
875
- maxHeight = t222;
880
+ maxHeight = t212;
876
881
  const maxWidthLeft = dropdownBodyRect.right - boundingElementRect.left;
877
882
  const maxWidthRight = boundingElementRect.right - dropdownBodyRect.left;
878
- let t232;
883
+ let t222;
879
884
  if ($[59] !== dropdownBodyRect.left || $[60] !== dropdownRect.left || $[61] !== maxWidthLeft || $[62] !== maxWidthRight) {
880
- t232 = Math.round(dropdownBodyRect.left > dropdownRect.left ? maxWidthRight : maxWidthLeft);
885
+ t222 = Math.round(dropdownBodyRect.left > dropdownRect.left ? maxWidthRight : maxWidthLeft);
881
886
  $[59] = dropdownBodyRect.left;
882
887
  $[60] = dropdownRect.left;
883
888
  $[61] = maxWidthLeft;
884
889
  $[62] = maxWidthRight;
885
- $[63] = t232;
890
+ $[63] = t222;
886
891
  } else {
887
- t232 = $[63];
892
+ t222 = $[63];
888
893
  }
889
- maxWidth = t232;
894
+ maxWidth = t222;
890
895
  }
891
- let t22;
896
+ let t21;
892
897
  if ($[64] !== maxHeight || $[65] !== minHeightBody) {
893
- t22 = maxHeight != null && maxHeight > minHeightBody ? {
898
+ t21 = maxHeight != null && maxHeight > minHeightBody ? {
894
899
  [BODY_MAX_HEIGHT_VAR]: `calc(${maxHeight}px - var(--uktdd-body-buffer))`
895
900
  } : null;
896
901
  $[64] = maxHeight;
897
902
  $[65] = minHeightBody;
898
- $[66] = t22;
903
+ $[66] = t21;
899
904
  } else {
900
- t22 = $[66];
905
+ t21 = $[66];
901
906
  }
902
- let t23;
907
+ let t22;
903
908
  if ($[67] !== maxWidth || $[68] !== minWidthBody) {
904
- t23 = maxWidth != null && maxWidth > minWidthBody ? {
909
+ t22 = maxWidth != null && maxWidth > minWidthBody ? {
905
910
  [BODY_MAX_WIDTH_VAR]: `calc(${maxWidth}px - var(--uktdd-body-buffer))`
906
911
  } : null;
907
912
  $[67] = maxWidth;
908
913
  $[68] = minWidthBody;
909
- $[69] = t23;
914
+ $[69] = t22;
910
915
  } else {
911
- t23 = $[69];
916
+ t22 = $[69];
912
917
  }
913
- let t24;
914
- if ($[70] !== styleFromProps || $[71] !== t22 || $[72] !== t23) {
915
- t24 = {
918
+ let t23;
919
+ if ($[70] !== styleFromProps || $[71] !== t21 || $[72] !== t22) {
920
+ t23 = {
916
921
  ...styleFromProps,
917
- ...t22,
918
- ...t23
922
+ ...t21,
923
+ ...t22
919
924
  };
920
925
  $[70] = styleFromProps;
921
- $[71] = t22;
922
- $[72] = t23;
923
- $[73] = t24;
926
+ $[71] = t21;
927
+ $[72] = t22;
928
+ $[73] = t23;
924
929
  } else {
925
- t24 = $[73];
930
+ t23 = $[73];
926
931
  }
927
- const style = t24;
932
+ const style = t23;
928
933
  const anchorStyles = `[data-ukt-id="${id}"] > :first-child {
929
934
  anchor-name: --uktdd-anchor${id};
930
935
  }
931
936
  [data-ukt-id="${id}"] ${BODY_SELECTOR} {
932
937
  position-anchor: --uktdd-anchor${id};
933
938
  }`;
934
- let t25;
939
+ let t24;
935
940
  if ($[74] === Symbol.for("react.memo_cache_sentinel")) {
936
- t25 = /* @__PURE__ */ jsx(Style, { href: "@acusti/dropdown/Dropdown", children: STYLES });
937
- $[74] = t25;
941
+ t24 = /* @__PURE__ */ jsx(Style, { href: "@acusti/dropdown/Dropdown", children: STYLES });
942
+ $[74] = t24;
938
943
  } else {
939
- t25 = $[74];
944
+ t24 = $[74];
940
945
  }
941
- const t26 = `@acusti/dropdown/Dropdown/${id}`;
942
- let t27;
943
- if ($[75] !== anchorStyles || $[76] !== t26) {
944
- t27 = /* @__PURE__ */ jsx(Style, { href: t26, children: anchorStyles });
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 });
945
950
  $[75] = anchorStyles;
946
- $[76] = t26;
947
- $[77] = t27;
951
+ $[76] = t25;
952
+ $[77] = t26;
948
953
  } else {
949
- t27 = $[77];
954
+ t26 = $[77];
950
955
  }
951
- let t28;
956
+ let t27;
952
957
  if ($[78] !== className || $[79] !== disabled || $[80] !== isOpen || $[81] !== isSearchable) {
953
- t28 = clsx(ROOT_CLASS_NAME, className, {
958
+ t27 = clsx(ROOT_CLASS_NAME, className, {
954
959
  disabled,
955
960
  "is-open": isOpen,
956
961
  "is-searchable": isSearchable
@@ -959,25 +964,25 @@ function Dropdown(t0) {
959
964
  $[79] = disabled;
960
965
  $[80] = isOpen;
961
966
  $[81] = isSearchable;
962
- $[82] = t28;
967
+ $[82] = t27;
963
968
  } else {
964
- t28 = $[82];
969
+ t27 = $[82];
965
970
  }
966
- let t29;
971
+ let t28;
967
972
  if ($[83] !== children || $[84] !== childrenCount || $[85] !== isOpen) {
968
- t29 = isOpen ? /* @__PURE__ */ jsx("div", { className: BODY_CLASS_NAME, ref: setDropdownBodyElement, children: childrenCount > 1 ? children[1] : children }) : null;
973
+ t28 = isOpen ? /* @__PURE__ */ jsx("div", { className: BODY_CLASS_NAME, ref: setDropdownBodyElement, children: childrenCount > 1 ? children[1] : children }) : null;
969
974
  $[83] = children;
970
975
  $[84] = childrenCount;
971
976
  $[85] = isOpen;
972
- $[86] = t29;
977
+ $[86] = t28;
973
978
  } else {
974
- t29 = $[86];
979
+ t28 = $[86];
975
980
  }
976
- let t30;
977
- if ($[87] !== handleMouseDown || $[88] !== handleMouseOut || $[89] !== handleMouseOver || $[90] !== handleMouseUp || $[91] !== handleRef || $[92] !== id || $[93] !== onClick || $[94] !== style || $[95] !== t28 || $[96] !== t29 || $[97] !== trigger) {
978
- t30 = /* @__PURE__ */ jsxs("div", { className: t28, "data-ukt-id": id, onClick, onMouseDown: handleMouseDown, onMouseMove: handleMouseMove, onMouseOut: handleMouseOut, onMouseOver: handleMouseOver, onMouseUp: handleMouseUp, ref: handleRef, style, children: [
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: [
979
984
  trigger,
980
- t29
985
+ t28
981
986
  ] });
982
987
  $[87] = handleMouseDown;
983
988
  $[88] = handleMouseOut;
@@ -987,34 +992,30 @@ function Dropdown(t0) {
987
992
  $[92] = id;
988
993
  $[93] = onClick;
989
994
  $[94] = style;
990
- $[95] = t28;
991
- $[96] = t29;
995
+ $[95] = t27;
996
+ $[96] = t28;
992
997
  $[97] = trigger;
993
- $[98] = t30;
998
+ $[98] = t29;
994
999
  } else {
995
- t30 = $[98];
1000
+ t29 = $[98];
996
1001
  }
997
- let t31;
998
- if ($[99] !== t27 || $[100] !== t30) {
999
- t31 = /* @__PURE__ */ jsxs(Fragment, { children: [
1000
- t25,
1001
- t27,
1002
- t30
1002
+ let t30;
1003
+ if ($[99] !== t26 || $[100] !== t29) {
1004
+ t30 = /* @__PURE__ */ jsxs(Fragment, { children: [
1005
+ t24,
1006
+ t26,
1007
+ t29
1003
1008
  ] });
1004
- $[99] = t27;
1005
- $[100] = t30;
1006
- $[101] = t31;
1009
+ $[99] = t26;
1010
+ $[100] = t29;
1011
+ $[101] = t30;
1007
1012
  } else {
1008
- t31 = $[101];
1013
+ t30 = $[101];
1009
1014
  }
1010
- return t31;
1011
- }
1012
- function _temp() {
1013
- idCounter = idCounter >= 999999 ? 0 : idCounter + 1;
1014
- return idCounter;
1015
+ return t30;
1015
1016
  }
1016
1017
  function getBoundingAncestor(element) {
1017
- while (element == null ? void 0 : element.parentElement) {
1018
+ while (element?.parentElement) {
1018
1019
  if (element.parentElement.tagName === "BODY") return element.parentElement;
1019
1020
  if (getComputedStyle(element.parentElement).overflowX !== "visible") {
1020
1021
  return element.parentElement;