@x-plat/design-system 0.14.11 → 0.14.13
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/components/Dropdown/index.cjs +32 -14
- package/dist/components/Dropdown/index.js +32 -14
- package/dist/components/PopOver/index.cjs +31 -14
- package/dist/components/PopOver/index.js +31 -14
- package/dist/components/Select/index.cjs +32 -14
- package/dist/components/Select/index.css +6 -4
- package/dist/components/Select/index.js +32 -14
- package/dist/components/TimePicker/index.cjs +30 -12
- package/dist/components/TimePicker/index.js +30 -12
- package/dist/components/index.cjs +35 -18
- package/dist/components/index.css +6 -4
- package/dist/components/index.js +35 -18
- package/dist/index.cjs +35 -18
- package/dist/index.css +6 -4
- package/dist/index.js +35 -18
- package/package.json +1 -1
package/dist/components/index.js
CHANGED
|
@@ -3902,6 +3902,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
3902
3902
|
const roomAbove = triggerRect.top - clip.top;
|
|
3903
3903
|
let direction;
|
|
3904
3904
|
let top;
|
|
3905
|
+
let maxHeight = null;
|
|
3905
3906
|
if (popH <= roomBelow) {
|
|
3906
3907
|
direction = "bottom";
|
|
3907
3908
|
top = triggerRect.bottom;
|
|
@@ -3909,38 +3910,48 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
3909
3910
|
direction = "top";
|
|
3910
3911
|
top = triggerRect.top - popH;
|
|
3911
3912
|
} else {
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3913
|
+
const room = Math.max(roomBelow, roomAbove, 0);
|
|
3914
|
+
if (roomBelow >= roomAbove) {
|
|
3915
|
+
direction = "bottom";
|
|
3916
|
+
top = triggerRect.bottom;
|
|
3917
|
+
} else {
|
|
3918
|
+
direction = "top";
|
|
3919
|
+
top = triggerRect.top - room;
|
|
3920
|
+
}
|
|
3921
|
+
maxHeight = room;
|
|
3916
3922
|
}
|
|
3917
3923
|
let left = triggerRect.left;
|
|
3918
3924
|
if (left + popW > clip.right - 8) {
|
|
3919
3925
|
left = triggerRect.right - popW;
|
|
3920
3926
|
}
|
|
3921
3927
|
if (left < clip.left + 8) left = clip.left + 8;
|
|
3928
|
+
const drawnH = maxHeight === null ? popH : Math.min(popH, maxHeight);
|
|
3922
3929
|
return {
|
|
3923
3930
|
direction,
|
|
3924
3931
|
top,
|
|
3925
3932
|
left,
|
|
3933
|
+
maxHeight,
|
|
3926
3934
|
over: {
|
|
3927
3935
|
top: Math.max(0, clip.top - top),
|
|
3928
3936
|
right: Math.max(0, left + popW - clip.right),
|
|
3929
|
-
bottom: Math.max(0, top +
|
|
3937
|
+
bottom: Math.max(0, top + drawnH - clip.bottom),
|
|
3930
3938
|
left: Math.max(0, clip.left - left)
|
|
3931
3939
|
}
|
|
3932
3940
|
};
|
|
3933
3941
|
};
|
|
3934
3942
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
3935
|
-
const [direction, setDirection] = React19.useState("bottom");
|
|
3936
3943
|
const directionRef = React19.useRef("bottom");
|
|
3937
3944
|
const sizeRef = React19.useRef(null);
|
|
3938
3945
|
const scrollParentRef = React19.useRef(null);
|
|
3946
|
+
const placedRef = React19.useRef(false);
|
|
3939
3947
|
const calculatePosition = React19.useCallback((remeasure = false) => {
|
|
3940
3948
|
const pop = popRef.current;
|
|
3941
3949
|
if (!triggerRef.current || !pop) return;
|
|
3942
3950
|
if (remeasure || !sizeRef.current) {
|
|
3943
|
-
sizeRef.current = {
|
|
3951
|
+
sizeRef.current = {
|
|
3952
|
+
w: pop.offsetWidth,
|
|
3953
|
+
h: Math.max(pop.offsetHeight, pop.scrollHeight)
|
|
3954
|
+
};
|
|
3944
3955
|
}
|
|
3945
3956
|
const { w: popW, h: popH } = sizeRef.current;
|
|
3946
3957
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
@@ -3955,7 +3966,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
3955
3966
|
left: Math.max(parentRect?.left ?? 0, 0),
|
|
3956
3967
|
right: Math.min(parentRect?.right ?? window.innerWidth, window.innerWidth)
|
|
3957
3968
|
};
|
|
3958
|
-
const
|
|
3969
|
+
const first = !placedRef.current;
|
|
3970
|
+
if (first) pop.style.transition = "none";
|
|
3971
|
+
const { direction: next, top, left, over, maxHeight } = computePlacement(
|
|
3959
3972
|
triggerRect,
|
|
3960
3973
|
popW,
|
|
3961
3974
|
popH,
|
|
@@ -3963,16 +3976,22 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
3963
3976
|
);
|
|
3964
3977
|
pop.style.top = `${top + window.scrollY}px`;
|
|
3965
3978
|
pop.style.left = `${left + window.scrollX}px`;
|
|
3979
|
+
pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
|
|
3966
3980
|
pop.style.clipPath = over.top || over.right || over.bottom || over.left ? `inset(${over.top}px ${over.right}px ${over.bottom}px ${over.left}px)` : "none";
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3981
|
+
directionRef.current = next;
|
|
3982
|
+
pop.classList.toggle("top", next === "top");
|
|
3983
|
+
pop.classList.toggle("bottom", next === "bottom");
|
|
3984
|
+
if (first) {
|
|
3985
|
+
void pop.offsetHeight;
|
|
3986
|
+
pop.style.transition = "";
|
|
3987
|
+
placedRef.current = true;
|
|
3970
3988
|
}
|
|
3971
3989
|
}, [triggerRef, popRef]);
|
|
3972
3990
|
React19.useLayoutEffect(() => {
|
|
3973
3991
|
if (!enabled) {
|
|
3974
3992
|
sizeRef.current = null;
|
|
3975
3993
|
scrollParentRef.current = null;
|
|
3994
|
+
placedRef.current = false;
|
|
3976
3995
|
return;
|
|
3977
3996
|
}
|
|
3978
3997
|
if (triggerRef.current) {
|
|
@@ -4001,7 +4020,6 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
4001
4020
|
window.removeEventListener("scroll", onScroll, true);
|
|
4002
4021
|
};
|
|
4003
4022
|
}, [calculatePosition, enabled]);
|
|
4004
|
-
return { direction };
|
|
4005
4023
|
};
|
|
4006
4024
|
var useAutoPosition_default = useAutoPosition;
|
|
4007
4025
|
|
|
@@ -4039,7 +4057,7 @@ var Dropdown = (props) => {
|
|
|
4039
4057
|
const [visible, setVisible] = React21.useState(false);
|
|
4040
4058
|
const triggerRef = React21.useRef(null);
|
|
4041
4059
|
const menuRef = React21.useRef(null);
|
|
4042
|
-
|
|
4060
|
+
useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
4043
4061
|
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
4044
4062
|
useCloseOnContainerScroll(isOpen, menuRef, () => setIsOpen(false));
|
|
4045
4063
|
useEscapeKey(isOpen, () => {
|
|
@@ -4075,7 +4093,7 @@ var Dropdown = (props) => {
|
|
|
4075
4093
|
"div",
|
|
4076
4094
|
{
|
|
4077
4095
|
ref: menuRef,
|
|
4078
|
-
className: clsx_default("lib-xplat-dropdown-menu",
|
|
4096
|
+
className: clsx_default("lib-xplat-dropdown-menu", { visible }),
|
|
4079
4097
|
role: "menu",
|
|
4080
4098
|
children: items.map((item) => /* @__PURE__ */ jsx322(
|
|
4081
4099
|
"button",
|
|
@@ -5977,7 +5995,7 @@ var PopOver = (props) => {
|
|
|
5977
5995
|
onClose();
|
|
5978
5996
|
triggerRef.current?.focus({ preventScroll: true });
|
|
5979
5997
|
});
|
|
5980
|
-
|
|
5998
|
+
useAutoPosition_default(triggerRef, popRef, localOpen);
|
|
5981
5999
|
React27.useEffect(() => {
|
|
5982
6000
|
if (isOpen) {
|
|
5983
6001
|
setLocalOpen(isOpen);
|
|
@@ -6006,7 +6024,6 @@ var PopOver = (props) => {
|
|
|
6006
6024
|
{
|
|
6007
6025
|
className: clsx_default(
|
|
6008
6026
|
"lib-xplat-pop-over-content",
|
|
6009
|
-
position.direction,
|
|
6010
6027
|
eventTrigger && "visible"
|
|
6011
6028
|
),
|
|
6012
6029
|
ref: popRef,
|
|
@@ -6258,7 +6275,7 @@ var SelectRoot = (props) => {
|
|
|
6258
6275
|
close();
|
|
6259
6276
|
triggerRef.current?.focus({ preventScroll: true });
|
|
6260
6277
|
});
|
|
6261
|
-
|
|
6278
|
+
useAutoPosition_default(triggerRef, contentRef, mounted);
|
|
6262
6279
|
const setSelected = React31.useCallback(
|
|
6263
6280
|
(label2, itemValue) => {
|
|
6264
6281
|
if (!isControlled) {
|
|
@@ -6351,7 +6368,7 @@ var SelectRoot = (props) => {
|
|
|
6351
6368
|
mounted && /* @__PURE__ */ jsx337(Portal_default, { children: /* @__PURE__ */ jsxs216(
|
|
6352
6369
|
"div",
|
|
6353
6370
|
{
|
|
6354
|
-
className: clsx_default("lib-xplat-select-content", size,
|
|
6371
|
+
className: clsx_default("lib-xplat-select-content", size, stateClass),
|
|
6355
6372
|
ref: contentRef,
|
|
6356
6373
|
style: { width: triggerRef.current?.offsetWidth },
|
|
6357
6374
|
role: "listbox",
|
package/dist/index.cjs
CHANGED
|
@@ -8416,6 +8416,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
8416
8416
|
const roomAbove = triggerRect.top - clip.top;
|
|
8417
8417
|
let direction;
|
|
8418
8418
|
let top;
|
|
8419
|
+
let maxHeight = null;
|
|
8419
8420
|
if (popH <= roomBelow) {
|
|
8420
8421
|
direction = "bottom";
|
|
8421
8422
|
top = triggerRect.bottom;
|
|
@@ -8423,38 +8424,48 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
8423
8424
|
direction = "top";
|
|
8424
8425
|
top = triggerRect.top - popH;
|
|
8425
8426
|
} else {
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8427
|
+
const room = Math.max(roomBelow, roomAbove, 0);
|
|
8428
|
+
if (roomBelow >= roomAbove) {
|
|
8429
|
+
direction = "bottom";
|
|
8430
|
+
top = triggerRect.bottom;
|
|
8431
|
+
} else {
|
|
8432
|
+
direction = "top";
|
|
8433
|
+
top = triggerRect.top - room;
|
|
8434
|
+
}
|
|
8435
|
+
maxHeight = room;
|
|
8430
8436
|
}
|
|
8431
8437
|
let left = triggerRect.left;
|
|
8432
8438
|
if (left + popW > clip.right - 8) {
|
|
8433
8439
|
left = triggerRect.right - popW;
|
|
8434
8440
|
}
|
|
8435
8441
|
if (left < clip.left + 8) left = clip.left + 8;
|
|
8442
|
+
const drawnH = maxHeight === null ? popH : Math.min(popH, maxHeight);
|
|
8436
8443
|
return {
|
|
8437
8444
|
direction,
|
|
8438
8445
|
top,
|
|
8439
8446
|
left,
|
|
8447
|
+
maxHeight,
|
|
8440
8448
|
over: {
|
|
8441
8449
|
top: Math.max(0, clip.top - top),
|
|
8442
8450
|
right: Math.max(0, left + popW - clip.right),
|
|
8443
|
-
bottom: Math.max(0, top +
|
|
8451
|
+
bottom: Math.max(0, top + drawnH - clip.bottom),
|
|
8444
8452
|
left: Math.max(0, clip.left - left)
|
|
8445
8453
|
}
|
|
8446
8454
|
};
|
|
8447
8455
|
};
|
|
8448
8456
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
8449
|
-
const [direction, setDirection] = import_react19.default.useState("bottom");
|
|
8450
8457
|
const directionRef = import_react19.default.useRef("bottom");
|
|
8451
8458
|
const sizeRef = import_react19.default.useRef(null);
|
|
8452
8459
|
const scrollParentRef = import_react19.default.useRef(null);
|
|
8460
|
+
const placedRef = import_react19.default.useRef(false);
|
|
8453
8461
|
const calculatePosition = import_react19.default.useCallback((remeasure = false) => {
|
|
8454
8462
|
const pop = popRef.current;
|
|
8455
8463
|
if (!triggerRef.current || !pop) return;
|
|
8456
8464
|
if (remeasure || !sizeRef.current) {
|
|
8457
|
-
sizeRef.current = {
|
|
8465
|
+
sizeRef.current = {
|
|
8466
|
+
w: pop.offsetWidth,
|
|
8467
|
+
h: Math.max(pop.offsetHeight, pop.scrollHeight)
|
|
8468
|
+
};
|
|
8458
8469
|
}
|
|
8459
8470
|
const { w: popW, h: popH } = sizeRef.current;
|
|
8460
8471
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
@@ -8469,7 +8480,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
8469
8480
|
left: Math.max(parentRect?.left ?? 0, 0),
|
|
8470
8481
|
right: Math.min(parentRect?.right ?? window.innerWidth, window.innerWidth)
|
|
8471
8482
|
};
|
|
8472
|
-
const
|
|
8483
|
+
const first = !placedRef.current;
|
|
8484
|
+
if (first) pop.style.transition = "none";
|
|
8485
|
+
const { direction: next, top, left, over, maxHeight } = computePlacement(
|
|
8473
8486
|
triggerRect,
|
|
8474
8487
|
popW,
|
|
8475
8488
|
popH,
|
|
@@ -8477,16 +8490,22 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
8477
8490
|
);
|
|
8478
8491
|
pop.style.top = `${top + window.scrollY}px`;
|
|
8479
8492
|
pop.style.left = `${left + window.scrollX}px`;
|
|
8493
|
+
pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
|
|
8480
8494
|
pop.style.clipPath = over.top || over.right || over.bottom || over.left ? `inset(${over.top}px ${over.right}px ${over.bottom}px ${over.left}px)` : "none";
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8495
|
+
directionRef.current = next;
|
|
8496
|
+
pop.classList.toggle("top", next === "top");
|
|
8497
|
+
pop.classList.toggle("bottom", next === "bottom");
|
|
8498
|
+
if (first) {
|
|
8499
|
+
void pop.offsetHeight;
|
|
8500
|
+
pop.style.transition = "";
|
|
8501
|
+
placedRef.current = true;
|
|
8484
8502
|
}
|
|
8485
8503
|
}, [triggerRef, popRef]);
|
|
8486
8504
|
import_react19.default.useLayoutEffect(() => {
|
|
8487
8505
|
if (!enabled) {
|
|
8488
8506
|
sizeRef.current = null;
|
|
8489
8507
|
scrollParentRef.current = null;
|
|
8508
|
+
placedRef.current = false;
|
|
8490
8509
|
return;
|
|
8491
8510
|
}
|
|
8492
8511
|
if (triggerRef.current) {
|
|
@@ -8515,7 +8534,6 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
8515
8534
|
window.removeEventListener("scroll", onScroll, true);
|
|
8516
8535
|
};
|
|
8517
8536
|
}, [calculatePosition, enabled]);
|
|
8518
|
-
return { direction };
|
|
8519
8537
|
};
|
|
8520
8538
|
var useAutoPosition_default = useAutoPosition;
|
|
8521
8539
|
|
|
@@ -8553,7 +8571,7 @@ var Dropdown = (props) => {
|
|
|
8553
8571
|
const [visible, setVisible] = import_react21.default.useState(false);
|
|
8554
8572
|
const triggerRef = import_react21.default.useRef(null);
|
|
8555
8573
|
const menuRef = import_react21.default.useRef(null);
|
|
8556
|
-
|
|
8574
|
+
useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
8557
8575
|
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
8558
8576
|
useCloseOnContainerScroll(isOpen, menuRef, () => setIsOpen(false));
|
|
8559
8577
|
useEscapeKey(isOpen, () => {
|
|
@@ -8589,7 +8607,7 @@ var Dropdown = (props) => {
|
|
|
8589
8607
|
"div",
|
|
8590
8608
|
{
|
|
8591
8609
|
ref: menuRef,
|
|
8592
|
-
className: clsx_default("lib-xplat-dropdown-menu",
|
|
8610
|
+
className: clsx_default("lib-xplat-dropdown-menu", { visible }),
|
|
8593
8611
|
role: "menu",
|
|
8594
8612
|
children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
|
|
8595
8613
|
"button",
|
|
@@ -10491,7 +10509,7 @@ var PopOver = (props) => {
|
|
|
10491
10509
|
onClose();
|
|
10492
10510
|
triggerRef.current?.focus({ preventScroll: true });
|
|
10493
10511
|
});
|
|
10494
|
-
|
|
10512
|
+
useAutoPosition_default(triggerRef, popRef, localOpen);
|
|
10495
10513
|
import_react27.default.useEffect(() => {
|
|
10496
10514
|
if (isOpen) {
|
|
10497
10515
|
setLocalOpen(isOpen);
|
|
@@ -10520,7 +10538,6 @@ var PopOver = (props) => {
|
|
|
10520
10538
|
{
|
|
10521
10539
|
className: clsx_default(
|
|
10522
10540
|
"lib-xplat-pop-over-content",
|
|
10523
|
-
position.direction,
|
|
10524
10541
|
eventTrigger && "visible"
|
|
10525
10542
|
),
|
|
10526
10543
|
ref: popRef,
|
|
@@ -10772,7 +10789,7 @@ var SelectRoot = (props) => {
|
|
|
10772
10789
|
close();
|
|
10773
10790
|
triggerRef.current?.focus({ preventScroll: true });
|
|
10774
10791
|
});
|
|
10775
|
-
|
|
10792
|
+
useAutoPosition_default(triggerRef, contentRef, mounted);
|
|
10776
10793
|
const setSelected = import_react31.default.useCallback(
|
|
10777
10794
|
(label2, itemValue) => {
|
|
10778
10795
|
if (!isControlled) {
|
|
@@ -10865,7 +10882,7 @@ var SelectRoot = (props) => {
|
|
|
10865
10882
|
mounted && /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(Portal_default, { children: /* @__PURE__ */ (0, import_jsx_runtime337.jsxs)(
|
|
10866
10883
|
"div",
|
|
10867
10884
|
{
|
|
10868
|
-
className: clsx_default("lib-xplat-select-content", size,
|
|
10885
|
+
className: clsx_default("lib-xplat-select-content", size, stateClass),
|
|
10869
10886
|
ref: contentRef,
|
|
10870
10887
|
style: { width: triggerRef.current?.offsetWidth },
|
|
10871
10888
|
role: "listbox",
|
package/dist/index.css
CHANGED
|
@@ -4513,7 +4513,7 @@
|
|
|
4513
4513
|
transition: transform 0.2s ease, opacity 0.2s ease;
|
|
4514
4514
|
}
|
|
4515
4515
|
.lib-xplat-select-content.bottom {
|
|
4516
|
-
transform: translateY(
|
|
4516
|
+
transform: translateY(8px);
|
|
4517
4517
|
}
|
|
4518
4518
|
.lib-xplat-select-content.bottom.visible {
|
|
4519
4519
|
opacity: 1;
|
|
@@ -4521,10 +4521,12 @@
|
|
|
4521
4521
|
}
|
|
4522
4522
|
.lib-xplat-select-content.bottom.exit {
|
|
4523
4523
|
opacity: 0;
|
|
4524
|
-
transform: translateY(
|
|
4524
|
+
transform: translateY(8px);
|
|
4525
|
+
}
|
|
4526
|
+
.lib-xplat-select-content {
|
|
4525
4527
|
}
|
|
4526
4528
|
.lib-xplat-select-content.top {
|
|
4527
|
-
transform: translateY(8px);
|
|
4529
|
+
transform: translateY(-8px);
|
|
4528
4530
|
}
|
|
4529
4531
|
.lib-xplat-select-content.top.visible {
|
|
4530
4532
|
opacity: 1;
|
|
@@ -4532,7 +4534,7 @@
|
|
|
4532
4534
|
}
|
|
4533
4535
|
.lib-xplat-select-content.top.exit {
|
|
4534
4536
|
opacity: 0;
|
|
4535
|
-
transform: translateY(8px);
|
|
4537
|
+
transform: translateY(-8px);
|
|
4536
4538
|
}
|
|
4537
4539
|
.lib-xplat-select-content.sm .select-item {
|
|
4538
4540
|
padding: var(--spacing-space-2) var(--spacing-space-2);
|
package/dist/index.js
CHANGED
|
@@ -8005,6 +8005,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
8005
8005
|
const roomAbove = triggerRect.top - clip.top;
|
|
8006
8006
|
let direction;
|
|
8007
8007
|
let top;
|
|
8008
|
+
let maxHeight = null;
|
|
8008
8009
|
if (popH <= roomBelow) {
|
|
8009
8010
|
direction = "bottom";
|
|
8010
8011
|
top = triggerRect.bottom;
|
|
@@ -8012,38 +8013,48 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
|
8012
8013
|
direction = "top";
|
|
8013
8014
|
top = triggerRect.top - popH;
|
|
8014
8015
|
} else {
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8016
|
+
const room = Math.max(roomBelow, roomAbove, 0);
|
|
8017
|
+
if (roomBelow >= roomAbove) {
|
|
8018
|
+
direction = "bottom";
|
|
8019
|
+
top = triggerRect.bottom;
|
|
8020
|
+
} else {
|
|
8021
|
+
direction = "top";
|
|
8022
|
+
top = triggerRect.top - room;
|
|
8023
|
+
}
|
|
8024
|
+
maxHeight = room;
|
|
8019
8025
|
}
|
|
8020
8026
|
let left = triggerRect.left;
|
|
8021
8027
|
if (left + popW > clip.right - 8) {
|
|
8022
8028
|
left = triggerRect.right - popW;
|
|
8023
8029
|
}
|
|
8024
8030
|
if (left < clip.left + 8) left = clip.left + 8;
|
|
8031
|
+
const drawnH = maxHeight === null ? popH : Math.min(popH, maxHeight);
|
|
8025
8032
|
return {
|
|
8026
8033
|
direction,
|
|
8027
8034
|
top,
|
|
8028
8035
|
left,
|
|
8036
|
+
maxHeight,
|
|
8029
8037
|
over: {
|
|
8030
8038
|
top: Math.max(0, clip.top - top),
|
|
8031
8039
|
right: Math.max(0, left + popW - clip.right),
|
|
8032
|
-
bottom: Math.max(0, top +
|
|
8040
|
+
bottom: Math.max(0, top + drawnH - clip.bottom),
|
|
8033
8041
|
left: Math.max(0, clip.left - left)
|
|
8034
8042
|
}
|
|
8035
8043
|
};
|
|
8036
8044
|
};
|
|
8037
8045
|
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
8038
|
-
const [direction, setDirection] = React19.useState("bottom");
|
|
8039
8046
|
const directionRef = React19.useRef("bottom");
|
|
8040
8047
|
const sizeRef = React19.useRef(null);
|
|
8041
8048
|
const scrollParentRef = React19.useRef(null);
|
|
8049
|
+
const placedRef = React19.useRef(false);
|
|
8042
8050
|
const calculatePosition = React19.useCallback((remeasure = false) => {
|
|
8043
8051
|
const pop = popRef.current;
|
|
8044
8052
|
if (!triggerRef.current || !pop) return;
|
|
8045
8053
|
if (remeasure || !sizeRef.current) {
|
|
8046
|
-
sizeRef.current = {
|
|
8054
|
+
sizeRef.current = {
|
|
8055
|
+
w: pop.offsetWidth,
|
|
8056
|
+
h: Math.max(pop.offsetHeight, pop.scrollHeight)
|
|
8057
|
+
};
|
|
8047
8058
|
}
|
|
8048
8059
|
const { w: popW, h: popH } = sizeRef.current;
|
|
8049
8060
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
@@ -8058,7 +8069,9 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
8058
8069
|
left: Math.max(parentRect?.left ?? 0, 0),
|
|
8059
8070
|
right: Math.min(parentRect?.right ?? window.innerWidth, window.innerWidth)
|
|
8060
8071
|
};
|
|
8061
|
-
const
|
|
8072
|
+
const first = !placedRef.current;
|
|
8073
|
+
if (first) pop.style.transition = "none";
|
|
8074
|
+
const { direction: next, top, left, over, maxHeight } = computePlacement(
|
|
8062
8075
|
triggerRect,
|
|
8063
8076
|
popW,
|
|
8064
8077
|
popH,
|
|
@@ -8066,16 +8079,22 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
8066
8079
|
);
|
|
8067
8080
|
pop.style.top = `${top + window.scrollY}px`;
|
|
8068
8081
|
pop.style.left = `${left + window.scrollX}px`;
|
|
8082
|
+
pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
|
|
8069
8083
|
pop.style.clipPath = over.top || over.right || over.bottom || over.left ? `inset(${over.top}px ${over.right}px ${over.bottom}px ${over.left}px)` : "none";
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8084
|
+
directionRef.current = next;
|
|
8085
|
+
pop.classList.toggle("top", next === "top");
|
|
8086
|
+
pop.classList.toggle("bottom", next === "bottom");
|
|
8087
|
+
if (first) {
|
|
8088
|
+
void pop.offsetHeight;
|
|
8089
|
+
pop.style.transition = "";
|
|
8090
|
+
placedRef.current = true;
|
|
8073
8091
|
}
|
|
8074
8092
|
}, [triggerRef, popRef]);
|
|
8075
8093
|
React19.useLayoutEffect(() => {
|
|
8076
8094
|
if (!enabled) {
|
|
8077
8095
|
sizeRef.current = null;
|
|
8078
8096
|
scrollParentRef.current = null;
|
|
8097
|
+
placedRef.current = false;
|
|
8079
8098
|
return;
|
|
8080
8099
|
}
|
|
8081
8100
|
if (triggerRef.current) {
|
|
@@ -8104,7 +8123,6 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
|
8104
8123
|
window.removeEventListener("scroll", onScroll, true);
|
|
8105
8124
|
};
|
|
8106
8125
|
}, [calculatePosition, enabled]);
|
|
8107
|
-
return { direction };
|
|
8108
8126
|
};
|
|
8109
8127
|
var useAutoPosition_default = useAutoPosition;
|
|
8110
8128
|
|
|
@@ -8142,7 +8160,7 @@ var Dropdown = (props) => {
|
|
|
8142
8160
|
const [visible, setVisible] = React21.useState(false);
|
|
8143
8161
|
const triggerRef = React21.useRef(null);
|
|
8144
8162
|
const menuRef = React21.useRef(null);
|
|
8145
|
-
|
|
8163
|
+
useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
8146
8164
|
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
8147
8165
|
useCloseOnContainerScroll(isOpen, menuRef, () => setIsOpen(false));
|
|
8148
8166
|
useEscapeKey(isOpen, () => {
|
|
@@ -8178,7 +8196,7 @@ var Dropdown = (props) => {
|
|
|
8178
8196
|
"div",
|
|
8179
8197
|
{
|
|
8180
8198
|
ref: menuRef,
|
|
8181
|
-
className: clsx_default("lib-xplat-dropdown-menu",
|
|
8199
|
+
className: clsx_default("lib-xplat-dropdown-menu", { visible }),
|
|
8182
8200
|
role: "menu",
|
|
8183
8201
|
children: items.map((item) => /* @__PURE__ */ jsx322(
|
|
8184
8202
|
"button",
|
|
@@ -10080,7 +10098,7 @@ var PopOver = (props) => {
|
|
|
10080
10098
|
onClose();
|
|
10081
10099
|
triggerRef.current?.focus({ preventScroll: true });
|
|
10082
10100
|
});
|
|
10083
|
-
|
|
10101
|
+
useAutoPosition_default(triggerRef, popRef, localOpen);
|
|
10084
10102
|
React27.useEffect(() => {
|
|
10085
10103
|
if (isOpen) {
|
|
10086
10104
|
setLocalOpen(isOpen);
|
|
@@ -10109,7 +10127,6 @@ var PopOver = (props) => {
|
|
|
10109
10127
|
{
|
|
10110
10128
|
className: clsx_default(
|
|
10111
10129
|
"lib-xplat-pop-over-content",
|
|
10112
|
-
position.direction,
|
|
10113
10130
|
eventTrigger && "visible"
|
|
10114
10131
|
),
|
|
10115
10132
|
ref: popRef,
|
|
@@ -10361,7 +10378,7 @@ var SelectRoot = (props) => {
|
|
|
10361
10378
|
close();
|
|
10362
10379
|
triggerRef.current?.focus({ preventScroll: true });
|
|
10363
10380
|
});
|
|
10364
|
-
|
|
10381
|
+
useAutoPosition_default(triggerRef, contentRef, mounted);
|
|
10365
10382
|
const setSelected = React31.useCallback(
|
|
10366
10383
|
(label2, itemValue) => {
|
|
10367
10384
|
if (!isControlled) {
|
|
@@ -10454,7 +10471,7 @@ var SelectRoot = (props) => {
|
|
|
10454
10471
|
mounted && /* @__PURE__ */ jsx337(Portal_default, { children: /* @__PURE__ */ jsxs216(
|
|
10455
10472
|
"div",
|
|
10456
10473
|
{
|
|
10457
|
-
className: clsx_default("lib-xplat-select-content", size,
|
|
10474
|
+
className: clsx_default("lib-xplat-select-content", size, stateClass),
|
|
10458
10475
|
ref: contentRef,
|
|
10459
10476
|
style: { width: triggerRef.current?.offsetWidth },
|
|
10460
10477
|
role: "listbox",
|