@acusti/dropdown 0.50.1 → 0.52.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/README.md +264 -17
- package/dist/Dropdown.d.ts +2 -1
- package/dist/Dropdown.js +227 -190
- package/dist/Dropdown.js.map +1 -1
- package/dist/helpers.d.ts +14 -20
- package/package.json +9 -9
package/dist/Dropdown.js
CHANGED
|
@@ -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
|
-
|
|
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,46 +174,53 @@ 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
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
219
|
const CHILDREN_ERROR = "@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.";
|
|
220
|
+
const CLICKABLE_SELECTOR = 'button, a[href], input[type="button"], input[type="submit"]';
|
|
216
221
|
const TEXT_INPUT_SELECTOR = "input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea";
|
|
217
222
|
function Dropdown(t0) {
|
|
218
|
-
const $ = c(
|
|
223
|
+
const $ = c(102);
|
|
219
224
|
const {
|
|
220
225
|
allowCreate,
|
|
221
226
|
allowEmpty: t1,
|
|
@@ -230,6 +235,7 @@ function Dropdown(t0) {
|
|
|
230
235
|
minHeightBody: t4,
|
|
231
236
|
minWidthBody: t5,
|
|
232
237
|
name,
|
|
238
|
+
onActiveItem,
|
|
233
239
|
onClick,
|
|
234
240
|
onClose,
|
|
235
241
|
onMouseDown,
|
|
@@ -390,14 +396,28 @@ function Dropdown(t0) {
|
|
|
390
396
|
if (valueRef.current && valueRef.current === nextValue) {
|
|
391
397
|
return;
|
|
392
398
|
}
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
399
|
+
if (element) {
|
|
400
|
+
const eventTarget = event.target;
|
|
401
|
+
if (element.matches(CLICKABLE_SELECTOR)) {
|
|
402
|
+
if (element !== eventTarget && !element.contains(eventTarget)) {
|
|
403
|
+
element.click();
|
|
404
|
+
}
|
|
405
|
+
} else {
|
|
406
|
+
const clickableElements = element.querySelectorAll(CLICKABLE_SELECTOR);
|
|
407
|
+
if (clickableElements.length === 1) {
|
|
408
|
+
const clickableElement = clickableElements[0];
|
|
409
|
+
if (clickableElement !== eventTarget && !clickableElement.contains(eventTarget)) {
|
|
410
|
+
clickableElement.click();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
400
414
|
}
|
|
415
|
+
onSubmitItemRef.current?.({
|
|
416
|
+
element,
|
|
417
|
+
event,
|
|
418
|
+
label: itemLabel,
|
|
419
|
+
value: nextValue
|
|
420
|
+
});
|
|
401
421
|
};
|
|
402
422
|
$[16] = dropdownElement;
|
|
403
423
|
$[17] = t11;
|
|
@@ -428,7 +448,7 @@ function Dropdown(t0) {
|
|
|
428
448
|
}
|
|
429
449
|
const handleMouseMove = t12;
|
|
430
450
|
let t13;
|
|
431
|
-
if ($[19] !== dropdownElement) {
|
|
451
|
+
if ($[19] !== dropdownElement || $[20] !== onActiveItem) {
|
|
432
452
|
t13 = (event_0) => {
|
|
433
453
|
if (!hasItemsRef.current) {
|
|
434
454
|
return;
|
|
@@ -443,27 +463,30 @@ function Dropdown(t0) {
|
|
|
443
463
|
if (!itemElements) {
|
|
444
464
|
return;
|
|
445
465
|
}
|
|
446
|
-
const
|
|
447
|
-
const item =
|
|
448
|
-
const element_0 = item ??
|
|
466
|
+
const eventTarget_0 = event_0.target;
|
|
467
|
+
const item = eventTarget_0.closest(ITEM_SELECTOR);
|
|
468
|
+
const element_0 = item ?? eventTarget_0;
|
|
449
469
|
for (const itemElement of itemElements) {
|
|
450
470
|
if (itemElement === element_0) {
|
|
451
471
|
setActiveItem({
|
|
452
472
|
dropdownElement,
|
|
453
|
-
element: element_0
|
|
473
|
+
element: element_0,
|
|
474
|
+
event: event_0,
|
|
475
|
+
onActiveItem
|
|
454
476
|
});
|
|
455
477
|
return;
|
|
456
478
|
}
|
|
457
479
|
}
|
|
458
480
|
};
|
|
459
481
|
$[19] = dropdownElement;
|
|
460
|
-
$[20] =
|
|
482
|
+
$[20] = onActiveItem;
|
|
483
|
+
$[21] = t13;
|
|
461
484
|
} else {
|
|
462
|
-
t13 = $[
|
|
485
|
+
t13 = $[21];
|
|
463
486
|
}
|
|
464
487
|
const handleMouseOver = t13;
|
|
465
488
|
let t14;
|
|
466
|
-
if ($[
|
|
489
|
+
if ($[22] !== dropdownElement) {
|
|
467
490
|
t14 = (event_1) => {
|
|
468
491
|
if (!hasItemsRef.current) {
|
|
469
492
|
return;
|
|
@@ -478,14 +501,14 @@ function Dropdown(t0) {
|
|
|
478
501
|
}
|
|
479
502
|
delete activeItem.dataset.uktActive;
|
|
480
503
|
};
|
|
481
|
-
$[
|
|
482
|
-
$[
|
|
504
|
+
$[22] = dropdownElement;
|
|
505
|
+
$[23] = t14;
|
|
483
506
|
} else {
|
|
484
|
-
t14 = $[
|
|
507
|
+
t14 = $[23];
|
|
485
508
|
}
|
|
486
509
|
const handleMouseOut = t14;
|
|
487
510
|
let t15;
|
|
488
|
-
if ($[
|
|
511
|
+
if ($[24] !== onMouseDown) {
|
|
489
512
|
t15 = (event_2) => {
|
|
490
513
|
if (onMouseDown) {
|
|
491
514
|
onMouseDown(event_2);
|
|
@@ -504,14 +527,14 @@ function Dropdown(t0) {
|
|
|
504
527
|
isOpeningTimerRef.current = null;
|
|
505
528
|
}, 1e3);
|
|
506
529
|
};
|
|
507
|
-
$[
|
|
508
|
-
$[
|
|
530
|
+
$[24] = onMouseDown;
|
|
531
|
+
$[25] = t15;
|
|
509
532
|
} else {
|
|
510
|
-
t15 = $[
|
|
533
|
+
t15 = $[25];
|
|
511
534
|
}
|
|
512
535
|
const handleMouseDown = t15;
|
|
513
536
|
let t16;
|
|
514
|
-
if ($[
|
|
537
|
+
if ($[26] !== handleSubmitItem || $[27] !== onMouseUp) {
|
|
515
538
|
t16 = (event_3) => {
|
|
516
539
|
if (onMouseUp) {
|
|
517
540
|
onMouseUp(event_3);
|
|
@@ -519,9 +542,9 @@ function Dropdown(t0) {
|
|
|
519
542
|
if (isOpeningRef.current || !isOpenRef.current || closingTimerRef.current) {
|
|
520
543
|
return;
|
|
521
544
|
}
|
|
522
|
-
const
|
|
523
|
-
if (!
|
|
524
|
-
if (!isOpeningRef.current && inputElementRef.current !==
|
|
545
|
+
const eventTarget_1 = event_3.target;
|
|
546
|
+
if (!eventTarget_1.closest(BODY_SELECTOR)) {
|
|
547
|
+
if (!isOpeningRef.current && inputElementRef.current !== eventTarget_1.ownerDocument.activeElement) {
|
|
525
548
|
closeDropdown();
|
|
526
549
|
}
|
|
527
550
|
return;
|
|
@@ -531,15 +554,15 @@ function Dropdown(t0) {
|
|
|
531
554
|
}
|
|
532
555
|
handleSubmitItem(event_3);
|
|
533
556
|
};
|
|
534
|
-
$[
|
|
535
|
-
$[
|
|
536
|
-
$[
|
|
557
|
+
$[26] = handleSubmitItem;
|
|
558
|
+
$[27] = onMouseUp;
|
|
559
|
+
$[28] = t16;
|
|
537
560
|
} else {
|
|
538
|
-
t16 = $[
|
|
561
|
+
t16 = $[28];
|
|
539
562
|
}
|
|
540
563
|
const handleMouseUp = t16;
|
|
541
564
|
let t17;
|
|
542
|
-
if ($[
|
|
565
|
+
if ($[29] !== dropdownElement || $[30] !== handleSubmitItem || $[31] !== onActiveItem) {
|
|
543
566
|
t17 = (event_4) => {
|
|
544
567
|
const {
|
|
545
568
|
altKey,
|
|
@@ -547,7 +570,7 @@ function Dropdown(t0) {
|
|
|
547
570
|
key,
|
|
548
571
|
metaKey
|
|
549
572
|
} = event_4;
|
|
550
|
-
const
|
|
573
|
+
const eventTarget_2 = event_4.target;
|
|
551
574
|
if (!dropdownElement) {
|
|
552
575
|
return;
|
|
553
576
|
}
|
|
@@ -556,7 +579,7 @@ function Dropdown(t0) {
|
|
|
556
579
|
event_4.preventDefault();
|
|
557
580
|
currentInputMethodRef.current = "keyboard";
|
|
558
581
|
};
|
|
559
|
-
const isEventTargetingDropdown = dropdownElement.contains(
|
|
582
|
+
const isEventTargetingDropdown = dropdownElement.contains(eventTarget_2);
|
|
560
583
|
if (!isOpenRef.current) {
|
|
561
584
|
if (!isEventTargetingDropdown) {
|
|
562
585
|
return;
|
|
@@ -582,7 +605,9 @@ function Dropdown(t0) {
|
|
|
582
605
|
}
|
|
583
606
|
setActiveItem({
|
|
584
607
|
dropdownElement,
|
|
608
|
+
event: event_4,
|
|
585
609
|
isExactMatch: allowCreateRef.current,
|
|
610
|
+
onActiveItem,
|
|
586
611
|
text: enteredCharactersRef.current
|
|
587
612
|
});
|
|
588
613
|
if (clearEnteredCharactersTimerRef.current) {
|
|
@@ -612,12 +637,16 @@ function Dropdown(t0) {
|
|
|
612
637
|
if (altKey || metaKey) {
|
|
613
638
|
setActiveItem({
|
|
614
639
|
dropdownElement,
|
|
615
|
-
|
|
640
|
+
event: event_4,
|
|
641
|
+
index: 0,
|
|
642
|
+
onActiveItem
|
|
616
643
|
});
|
|
617
644
|
} else {
|
|
618
645
|
setActiveItem({
|
|
619
646
|
dropdownElement,
|
|
620
|
-
|
|
647
|
+
event: event_4,
|
|
648
|
+
indexAddend: -1,
|
|
649
|
+
onActiveItem
|
|
621
650
|
});
|
|
622
651
|
}
|
|
623
652
|
return;
|
|
@@ -627,39 +656,44 @@ function Dropdown(t0) {
|
|
|
627
656
|
if (altKey || metaKey) {
|
|
628
657
|
setActiveItem({
|
|
629
658
|
dropdownElement,
|
|
630
|
-
|
|
659
|
+
event: event_4,
|
|
660
|
+
index: -1,
|
|
661
|
+
onActiveItem
|
|
631
662
|
});
|
|
632
663
|
} else {
|
|
633
664
|
setActiveItem({
|
|
634
665
|
dropdownElement,
|
|
635
|
-
|
|
666
|
+
event: event_4,
|
|
667
|
+
indexAddend: 1,
|
|
668
|
+
onActiveItem
|
|
636
669
|
});
|
|
637
670
|
}
|
|
638
671
|
return;
|
|
639
672
|
}
|
|
640
673
|
}
|
|
641
674
|
};
|
|
642
|
-
$[
|
|
643
|
-
$[
|
|
644
|
-
$[
|
|
675
|
+
$[29] = dropdownElement;
|
|
676
|
+
$[30] = handleSubmitItem;
|
|
677
|
+
$[31] = onActiveItem;
|
|
678
|
+
$[32] = t17;
|
|
645
679
|
} else {
|
|
646
|
-
t17 = $[
|
|
680
|
+
t17 = $[32];
|
|
647
681
|
}
|
|
648
682
|
const handleKeyDown = t17;
|
|
649
683
|
let t18;
|
|
650
|
-
if ($[
|
|
684
|
+
if ($[33] !== handleKeyDown) {
|
|
651
685
|
t18 = {
|
|
652
686
|
ignoreUsedKeyboardEvents: false,
|
|
653
687
|
onKeyDown: handleKeyDown
|
|
654
688
|
};
|
|
655
|
-
$[
|
|
656
|
-
$[
|
|
689
|
+
$[33] = handleKeyDown;
|
|
690
|
+
$[34] = t18;
|
|
657
691
|
} else {
|
|
658
|
-
t18 = $[
|
|
692
|
+
t18 = $[34];
|
|
659
693
|
}
|
|
660
694
|
useKeyboardEvents(t18);
|
|
661
695
|
let t19;
|
|
662
|
-
if ($[
|
|
696
|
+
if ($[35] !== isOpenOnMount || $[36] !== onActiveItem) {
|
|
663
697
|
t19 = (ref) => {
|
|
664
698
|
setDropdownElement(ref);
|
|
665
699
|
if (!ref) {
|
|
@@ -681,8 +715,8 @@ function Dropdown(t0) {
|
|
|
681
715
|
const {
|
|
682
716
|
target
|
|
683
717
|
} = t202;
|
|
684
|
-
const
|
|
685
|
-
if (!ref.contains(
|
|
718
|
+
const eventTarget_3 = target;
|
|
719
|
+
if (!ref.contains(eventTarget_3)) {
|
|
686
720
|
closeDropdown();
|
|
687
721
|
}
|
|
688
722
|
};
|
|
@@ -701,8 +735,8 @@ function Dropdown(t0) {
|
|
|
701
735
|
}
|
|
702
736
|
return;
|
|
703
737
|
}
|
|
704
|
-
const
|
|
705
|
-
if (!ref.contains(
|
|
738
|
+
const eventTarget_4 = target_0;
|
|
739
|
+
if (!ref.contains(eventTarget_4)) {
|
|
706
740
|
closeDropdown();
|
|
707
741
|
}
|
|
708
742
|
};
|
|
@@ -713,8 +747,8 @@ function Dropdown(t0) {
|
|
|
713
747
|
if (!isOpenRef.current) {
|
|
714
748
|
return;
|
|
715
749
|
}
|
|
716
|
-
const
|
|
717
|
-
if (ref.contains(
|
|
750
|
+
const eventTarget_5 = target_1;
|
|
751
|
+
if (ref.contains(eventTarget_5) || eventTarget_5.contains(ref)) {
|
|
718
752
|
return;
|
|
719
753
|
}
|
|
720
754
|
closeDropdown();
|
|
@@ -742,7 +776,9 @@ function Dropdown(t0) {
|
|
|
742
776
|
}
|
|
743
777
|
setActiveItem({
|
|
744
778
|
dropdownElement: ref,
|
|
779
|
+
event: event_5,
|
|
745
780
|
isExactMatch: allowCreateRef.current,
|
|
781
|
+
onActiveItem,
|
|
746
782
|
text: enteredCharactersRef.current
|
|
747
783
|
});
|
|
748
784
|
};
|
|
@@ -763,79 +799,80 @@ function Dropdown(t0) {
|
|
|
763
799
|
}
|
|
764
800
|
};
|
|
765
801
|
};
|
|
766
|
-
$[
|
|
767
|
-
$[
|
|
802
|
+
$[35] = isOpenOnMount;
|
|
803
|
+
$[36] = onActiveItem;
|
|
804
|
+
$[37] = t19;
|
|
768
805
|
} else {
|
|
769
|
-
t19 = $[
|
|
806
|
+
t19 = $[37];
|
|
770
807
|
}
|
|
771
808
|
const handleRef = t19;
|
|
772
809
|
if (!isValidElement(trigger)) {
|
|
773
810
|
if (isSearchable) {
|
|
774
811
|
const t202 = value ?? "";
|
|
775
812
|
let t212;
|
|
776
|
-
if ($[
|
|
813
|
+
if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
|
|
777
814
|
t212 = () => setIsOpen(true);
|
|
778
|
-
$[
|
|
815
|
+
$[38] = t212;
|
|
779
816
|
} else {
|
|
780
|
-
t212 = $[
|
|
817
|
+
t212 = $[38];
|
|
781
818
|
}
|
|
782
819
|
let t222;
|
|
783
|
-
if ($[
|
|
820
|
+
if ($[39] !== disabled || $[40] !== name || $[41] !== placeholder || $[42] !== t202 || $[43] !== tabIndex) {
|
|
784
821
|
t222 = /* @__PURE__ */ jsx("input", { autoComplete: "off", className: TRIGGER_CLASS_NAME, defaultValue: t202, disabled, name, onFocus: t212, placeholder, ref: inputElementRef, tabIndex, type: "text" });
|
|
785
|
-
$[
|
|
786
|
-
$[
|
|
787
|
-
$[
|
|
788
|
-
$[
|
|
789
|
-
$[
|
|
790
|
-
$[
|
|
822
|
+
$[39] = disabled;
|
|
823
|
+
$[40] = name;
|
|
824
|
+
$[41] = placeholder;
|
|
825
|
+
$[42] = t202;
|
|
826
|
+
$[43] = tabIndex;
|
|
827
|
+
$[44] = t222;
|
|
791
828
|
} else {
|
|
792
|
-
t222 = $[
|
|
829
|
+
t222 = $[44];
|
|
793
830
|
}
|
|
794
831
|
trigger = t222;
|
|
795
832
|
} else {
|
|
796
833
|
let t202;
|
|
797
|
-
if ($[
|
|
798
|
-
t202 = /* @__PURE__ */ jsx("button", { className: TRIGGER_CLASS_NAME, tabIndex: 0, children: trigger });
|
|
799
|
-
$[
|
|
800
|
-
$[
|
|
834
|
+
if ($[45] !== trigger) {
|
|
835
|
+
t202 = /* @__PURE__ */ jsx("button", { className: TRIGGER_CLASS_NAME, tabIndex: 0, type: "button", children: trigger });
|
|
836
|
+
$[45] = trigger;
|
|
837
|
+
$[46] = t202;
|
|
801
838
|
} else {
|
|
802
|
-
t202 = $[
|
|
839
|
+
t202 = $[46];
|
|
803
840
|
}
|
|
804
841
|
trigger = t202;
|
|
805
842
|
}
|
|
806
843
|
}
|
|
807
844
|
if (label) {
|
|
808
845
|
let t202;
|
|
809
|
-
if ($[
|
|
846
|
+
if ($[47] !== label) {
|
|
810
847
|
t202 = /* @__PURE__ */ jsx("div", { className: LABEL_TEXT_CLASS_NAME, children: label });
|
|
811
|
-
$[
|
|
812
|
-
$[
|
|
848
|
+
$[47] = label;
|
|
849
|
+
$[48] = t202;
|
|
813
850
|
} else {
|
|
814
|
-
t202 = $[
|
|
851
|
+
t202 = $[48];
|
|
815
852
|
}
|
|
816
853
|
let t212;
|
|
817
|
-
if ($[
|
|
854
|
+
if ($[49] !== t202 || $[50] !== trigger) {
|
|
818
855
|
t212 = /* @__PURE__ */ jsxs("label", { className: LABEL_CLASS_NAME, children: [
|
|
819
856
|
t202,
|
|
820
857
|
trigger
|
|
821
858
|
] });
|
|
822
|
-
$[
|
|
823
|
-
$[
|
|
824
|
-
$[
|
|
859
|
+
$[49] = t202;
|
|
860
|
+
$[50] = trigger;
|
|
861
|
+
$[51] = t212;
|
|
825
862
|
} else {
|
|
826
|
-
t212 = $[
|
|
863
|
+
t212 = $[51];
|
|
827
864
|
}
|
|
828
865
|
trigger = t212;
|
|
829
866
|
}
|
|
830
867
|
const dropdownRect = useBoundingClientRect(dropdownElement);
|
|
831
868
|
const dropdownBodyRect = useBoundingClientRect(dropdownBodyElement);
|
|
832
869
|
let t20;
|
|
833
|
-
if ($[
|
|
870
|
+
if ($[52] !== dropdownBodyElement) {
|
|
834
871
|
t20 = getBoundingAncestor(dropdownBodyElement);
|
|
835
|
-
$[
|
|
836
|
-
$[
|
|
872
|
+
$[52] = dropdownBodyElement;
|
|
873
|
+
$[53] = t20;
|
|
837
874
|
} else {
|
|
838
|
-
t20 = $[
|
|
875
|
+
t20 = $[53];
|
|
839
876
|
}
|
|
840
877
|
const boundingElement = t20;
|
|
841
878
|
const boundingElementRect = useBoundingClientRect(boundingElement);
|
|
@@ -845,67 +882,67 @@ function Dropdown(t0) {
|
|
|
845
882
|
const maxHeightUp = dropdownBodyRect.bottom - boundingElementRect.top;
|
|
846
883
|
const maxHeightDown = boundingElementRect.bottom - dropdownBodyRect.top;
|
|
847
884
|
let t212;
|
|
848
|
-
if ($[
|
|
885
|
+
if ($[54] !== dropdownBodyRect.top || $[55] !== dropdownRect.top || $[56] !== maxHeightDown || $[57] !== maxHeightUp) {
|
|
849
886
|
t212 = Math.round(dropdownBodyRect.top > dropdownRect.top ? maxHeightDown : maxHeightUp);
|
|
850
|
-
$[
|
|
851
|
-
$[
|
|
852
|
-
$[
|
|
853
|
-
$[
|
|
854
|
-
$[
|
|
887
|
+
$[54] = dropdownBodyRect.top;
|
|
888
|
+
$[55] = dropdownRect.top;
|
|
889
|
+
$[56] = maxHeightDown;
|
|
890
|
+
$[57] = maxHeightUp;
|
|
891
|
+
$[58] = t212;
|
|
855
892
|
} else {
|
|
856
|
-
t212 = $[
|
|
893
|
+
t212 = $[58];
|
|
857
894
|
}
|
|
858
895
|
maxHeight = t212;
|
|
859
896
|
const maxWidthLeft = dropdownBodyRect.right - boundingElementRect.left;
|
|
860
897
|
const maxWidthRight = boundingElementRect.right - dropdownBodyRect.left;
|
|
861
898
|
let t222;
|
|
862
|
-
if ($[
|
|
899
|
+
if ($[59] !== dropdownBodyRect.left || $[60] !== dropdownRect.left || $[61] !== maxWidthLeft || $[62] !== maxWidthRight) {
|
|
863
900
|
t222 = Math.round(dropdownBodyRect.left > dropdownRect.left ? maxWidthRight : maxWidthLeft);
|
|
864
|
-
$[
|
|
865
|
-
$[
|
|
866
|
-
$[
|
|
867
|
-
$[
|
|
868
|
-
$[
|
|
901
|
+
$[59] = dropdownBodyRect.left;
|
|
902
|
+
$[60] = dropdownRect.left;
|
|
903
|
+
$[61] = maxWidthLeft;
|
|
904
|
+
$[62] = maxWidthRight;
|
|
905
|
+
$[63] = t222;
|
|
869
906
|
} else {
|
|
870
|
-
t222 = $[
|
|
907
|
+
t222 = $[63];
|
|
871
908
|
}
|
|
872
909
|
maxWidth = t222;
|
|
873
910
|
}
|
|
874
911
|
let t21;
|
|
875
|
-
if ($[
|
|
912
|
+
if ($[64] !== maxHeight || $[65] !== minHeightBody) {
|
|
876
913
|
t21 = maxHeight != null && maxHeight > minHeightBody ? {
|
|
877
914
|
[BODY_MAX_HEIGHT_VAR]: `calc(${maxHeight}px - var(--uktdd-body-buffer))`
|
|
878
915
|
} : null;
|
|
879
|
-
$[
|
|
880
|
-
$[
|
|
881
|
-
$[
|
|
916
|
+
$[64] = maxHeight;
|
|
917
|
+
$[65] = minHeightBody;
|
|
918
|
+
$[66] = t21;
|
|
882
919
|
} else {
|
|
883
|
-
t21 = $[
|
|
920
|
+
t21 = $[66];
|
|
884
921
|
}
|
|
885
922
|
let t22;
|
|
886
|
-
if ($[
|
|
923
|
+
if ($[67] !== maxWidth || $[68] !== minWidthBody) {
|
|
887
924
|
t22 = maxWidth != null && maxWidth > minWidthBody ? {
|
|
888
925
|
[BODY_MAX_WIDTH_VAR]: `calc(${maxWidth}px - var(--uktdd-body-buffer))`
|
|
889
926
|
} : null;
|
|
890
|
-
$[
|
|
891
|
-
$[
|
|
892
|
-
$[
|
|
927
|
+
$[67] = maxWidth;
|
|
928
|
+
$[68] = minWidthBody;
|
|
929
|
+
$[69] = t22;
|
|
893
930
|
} else {
|
|
894
|
-
t22 = $[
|
|
931
|
+
t22 = $[69];
|
|
895
932
|
}
|
|
896
933
|
let t23;
|
|
897
|
-
if ($[
|
|
934
|
+
if ($[70] !== styleFromProps || $[71] !== t21 || $[72] !== t22) {
|
|
898
935
|
t23 = {
|
|
899
936
|
...styleFromProps,
|
|
900
937
|
...t21,
|
|
901
938
|
...t22
|
|
902
939
|
};
|
|
903
|
-
$[
|
|
904
|
-
$[
|
|
905
|
-
$[
|
|
906
|
-
$[
|
|
940
|
+
$[70] = styleFromProps;
|
|
941
|
+
$[71] = t21;
|
|
942
|
+
$[72] = t22;
|
|
943
|
+
$[73] = t23;
|
|
907
944
|
} else {
|
|
908
|
-
t23 = $[
|
|
945
|
+
t23 = $[73];
|
|
909
946
|
}
|
|
910
947
|
const style = t23;
|
|
911
948
|
const anchorStyles = `[data-ukt-id="${id}"] > :first-child {
|
|
@@ -915,80 +952,80 @@ function Dropdown(t0) {
|
|
|
915
952
|
position-anchor: --uktdd-anchor${id};
|
|
916
953
|
}`;
|
|
917
954
|
let t24;
|
|
918
|
-
if ($[
|
|
955
|
+
if ($[74] === Symbol.for("react.memo_cache_sentinel")) {
|
|
919
956
|
t24 = /* @__PURE__ */ jsx(Style, { href: "@acusti/dropdown/Dropdown", children: STYLES });
|
|
920
|
-
$[
|
|
957
|
+
$[74] = t24;
|
|
921
958
|
} else {
|
|
922
|
-
t24 = $[
|
|
959
|
+
t24 = $[74];
|
|
923
960
|
}
|
|
924
961
|
const t25 = `@acusti/dropdown/Dropdown/${id}`;
|
|
925
962
|
let t26;
|
|
926
|
-
if ($[
|
|
963
|
+
if ($[75] !== anchorStyles || $[76] !== t25) {
|
|
927
964
|
t26 = /* @__PURE__ */ jsx(Style, { href: t25, children: anchorStyles });
|
|
928
|
-
$[
|
|
929
|
-
$[
|
|
930
|
-
$[
|
|
965
|
+
$[75] = anchorStyles;
|
|
966
|
+
$[76] = t25;
|
|
967
|
+
$[77] = t26;
|
|
931
968
|
} else {
|
|
932
|
-
t26 = $[
|
|
969
|
+
t26 = $[77];
|
|
933
970
|
}
|
|
934
971
|
let t27;
|
|
935
|
-
if ($[
|
|
972
|
+
if ($[78] !== className || $[79] !== disabled || $[80] !== isOpen || $[81] !== isSearchable) {
|
|
936
973
|
t27 = clsx(ROOT_CLASS_NAME, className, {
|
|
937
974
|
disabled,
|
|
938
975
|
"is-open": isOpen,
|
|
939
976
|
"is-searchable": isSearchable
|
|
940
977
|
});
|
|
941
|
-
$[
|
|
942
|
-
$[
|
|
943
|
-
$[
|
|
944
|
-
$[
|
|
945
|
-
$[
|
|
978
|
+
$[78] = className;
|
|
979
|
+
$[79] = disabled;
|
|
980
|
+
$[80] = isOpen;
|
|
981
|
+
$[81] = isSearchable;
|
|
982
|
+
$[82] = t27;
|
|
946
983
|
} else {
|
|
947
|
-
t27 = $[
|
|
984
|
+
t27 = $[82];
|
|
948
985
|
}
|
|
949
986
|
let t28;
|
|
950
|
-
if ($[
|
|
987
|
+
if ($[83] !== children || $[84] !== childrenCount || $[85] !== isOpen) {
|
|
951
988
|
t28 = isOpen ? /* @__PURE__ */ jsx("div", { className: BODY_CLASS_NAME, ref: setDropdownBodyElement, children: childrenCount > 1 ? children[1] : children }) : null;
|
|
952
|
-
$[
|
|
953
|
-
$[
|
|
954
|
-
$[
|
|
955
|
-
$[
|
|
989
|
+
$[83] = children;
|
|
990
|
+
$[84] = childrenCount;
|
|
991
|
+
$[85] = isOpen;
|
|
992
|
+
$[86] = t28;
|
|
956
993
|
} else {
|
|
957
|
-
t28 = $[
|
|
994
|
+
t28 = $[86];
|
|
958
995
|
}
|
|
959
996
|
let t29;
|
|
960
|
-
if ($[
|
|
997
|
+
if ($[87] !== handleMouseDown || $[88] !== handleMouseOut || $[89] !== handleMouseOver || $[90] !== handleMouseUp || $[91] !== handleRef || $[92] !== id || $[93] !== onClick || $[94] !== style || $[95] !== t27 || $[96] !== t28 || $[97] !== trigger) {
|
|
961
998
|
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: [
|
|
962
999
|
trigger,
|
|
963
1000
|
t28
|
|
964
1001
|
] });
|
|
965
|
-
$[
|
|
966
|
-
$[
|
|
967
|
-
$[
|
|
968
|
-
$[
|
|
969
|
-
$[
|
|
970
|
-
$[
|
|
971
|
-
$[
|
|
972
|
-
$[
|
|
973
|
-
$[
|
|
974
|
-
$[
|
|
975
|
-
$[
|
|
976
|
-
$[
|
|
1002
|
+
$[87] = handleMouseDown;
|
|
1003
|
+
$[88] = handleMouseOut;
|
|
1004
|
+
$[89] = handleMouseOver;
|
|
1005
|
+
$[90] = handleMouseUp;
|
|
1006
|
+
$[91] = handleRef;
|
|
1007
|
+
$[92] = id;
|
|
1008
|
+
$[93] = onClick;
|
|
1009
|
+
$[94] = style;
|
|
1010
|
+
$[95] = t27;
|
|
1011
|
+
$[96] = t28;
|
|
1012
|
+
$[97] = trigger;
|
|
1013
|
+
$[98] = t29;
|
|
977
1014
|
} else {
|
|
978
|
-
t29 = $[
|
|
1015
|
+
t29 = $[98];
|
|
979
1016
|
}
|
|
980
1017
|
let t30;
|
|
981
|
-
if ($[
|
|
1018
|
+
if ($[99] !== t26 || $[100] !== t29) {
|
|
982
1019
|
t30 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
983
1020
|
t24,
|
|
984
1021
|
t26,
|
|
985
1022
|
t29
|
|
986
1023
|
] });
|
|
987
|
-
$[
|
|
988
|
-
$[
|
|
989
|
-
$[
|
|
1024
|
+
$[99] = t26;
|
|
1025
|
+
$[100] = t29;
|
|
1026
|
+
$[101] = t30;
|
|
990
1027
|
} else {
|
|
991
|
-
t30 = $[
|
|
1028
|
+
t30 = $[101];
|
|
992
1029
|
}
|
|
993
1030
|
return t30;
|
|
994
1031
|
}
|