@x-plat/design-system 0.14.14 → 0.14.15
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/DatePicker/index.cjs +46 -41
- package/dist/components/DatePicker/index.js +46 -41
- package/dist/components/Drawer/index.cjs +14 -9
- package/dist/components/Drawer/index.js +14 -9
- package/dist/components/Dropdown/index.cjs +14 -14
- package/dist/components/Dropdown/index.js +14 -14
- package/dist/components/Modal/index.cjs +15 -10
- package/dist/components/Modal/index.js +15 -10
- package/dist/components/PopOver/index.cjs +14 -14
- package/dist/components/PopOver/index.js +14 -14
- package/dist/components/Select/index.cjs +14 -14
- package/dist/components/Select/index.js +14 -14
- package/dist/components/TimePicker/index.cjs +14 -14
- package/dist/components/TimePicker/index.js +14 -14
- package/dist/components/index.cjs +196 -194
- package/dist/components/index.js +196 -194
- package/dist/index.cjs +196 -194
- package/dist/index.js +196 -194
- package/guidelines/MIGRATION.md +28 -30
- package/package.json +1 -1
|
@@ -3053,7 +3053,7 @@ Chip.displayName = "Chip";
|
|
|
3053
3053
|
var Chip_default = Chip;
|
|
3054
3054
|
|
|
3055
3055
|
// src/components/DatePicker/InputDatePicker/index.tsx
|
|
3056
|
-
var
|
|
3056
|
+
var import_react14 = __toESM(require("react"), 1);
|
|
3057
3057
|
|
|
3058
3058
|
// src/components/Input/Input.tsx
|
|
3059
3059
|
var import_react8 = __toESM(require("react"), 1);
|
|
@@ -3226,11 +3226,149 @@ PasswordInput.displayName = "PasswordInput";
|
|
|
3226
3226
|
var PasswordInput_default = PasswordInput;
|
|
3227
3227
|
|
|
3228
3228
|
// src/components/Modal/Modal.tsx
|
|
3229
|
-
var
|
|
3229
|
+
var import_react12 = __toESM(require("react"), 1);
|
|
3230
3230
|
var import_react_dom = require("react-dom");
|
|
3231
3231
|
|
|
3232
3232
|
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
3233
|
+
var import_react11 = __toESM(require("react"), 1);
|
|
3234
|
+
|
|
3235
|
+
// src/tokens/hooks/useAutoPosition.ts
|
|
3233
3236
|
var import_react10 = __toESM(require("react"), 1);
|
|
3237
|
+
var findScrollParent = (el) => {
|
|
3238
|
+
for (let p = el.parentElement; p; p = p.parentElement) {
|
|
3239
|
+
const { overflowY, overflowX } = getComputedStyle(p);
|
|
3240
|
+
if (/(auto|scroll)/.test(overflowY) || /(auto|scroll)/.test(overflowX)) return p;
|
|
3241
|
+
}
|
|
3242
|
+
return null;
|
|
3243
|
+
};
|
|
3244
|
+
var TRIGGER_GAP = 8;
|
|
3245
|
+
var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
3246
|
+
const roomBelow = clip.bottom - triggerRect.bottom - TRIGGER_GAP;
|
|
3247
|
+
const roomAbove = triggerRect.top - clip.top - TRIGGER_GAP;
|
|
3248
|
+
let direction;
|
|
3249
|
+
let top;
|
|
3250
|
+
let maxHeight = null;
|
|
3251
|
+
if (popH <= roomBelow) {
|
|
3252
|
+
direction = "bottom";
|
|
3253
|
+
top = triggerRect.bottom + TRIGGER_GAP;
|
|
3254
|
+
} else if (popH <= roomAbove) {
|
|
3255
|
+
direction = "top";
|
|
3256
|
+
top = triggerRect.top - TRIGGER_GAP - popH;
|
|
3257
|
+
} else {
|
|
3258
|
+
const room = Math.max(roomBelow, roomAbove, 0);
|
|
3259
|
+
if (roomBelow >= roomAbove) {
|
|
3260
|
+
direction = "bottom";
|
|
3261
|
+
top = triggerRect.bottom + TRIGGER_GAP;
|
|
3262
|
+
} else {
|
|
3263
|
+
direction = "top";
|
|
3264
|
+
top = triggerRect.top - TRIGGER_GAP - room;
|
|
3265
|
+
}
|
|
3266
|
+
maxHeight = room;
|
|
3267
|
+
}
|
|
3268
|
+
let left = triggerRect.left;
|
|
3269
|
+
if (left + popW > clip.right - 8) {
|
|
3270
|
+
left = triggerRect.right - popW;
|
|
3271
|
+
}
|
|
3272
|
+
if (left < clip.left + 8) left = clip.left + 8;
|
|
3273
|
+
const drawnH = maxHeight === null ? popH : Math.min(popH, maxHeight);
|
|
3274
|
+
return {
|
|
3275
|
+
direction,
|
|
3276
|
+
top,
|
|
3277
|
+
left,
|
|
3278
|
+
maxHeight,
|
|
3279
|
+
over: {
|
|
3280
|
+
top: Math.max(0, clip.top - top),
|
|
3281
|
+
right: Math.max(0, left + popW - clip.right),
|
|
3282
|
+
bottom: Math.max(0, top + drawnH - clip.bottom),
|
|
3283
|
+
left: Math.max(0, clip.left - left)
|
|
3284
|
+
}
|
|
3285
|
+
};
|
|
3286
|
+
};
|
|
3287
|
+
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
3288
|
+
const directionRef = import_react10.default.useRef("bottom");
|
|
3289
|
+
const sizeRef = import_react10.default.useRef(null);
|
|
3290
|
+
const scrollParentRef = import_react10.default.useRef(null);
|
|
3291
|
+
const placedRef = import_react10.default.useRef(false);
|
|
3292
|
+
const calculatePosition = import_react10.default.useCallback((remeasure = false) => {
|
|
3293
|
+
const pop = popRef.current;
|
|
3294
|
+
if (!triggerRef.current || !pop) return;
|
|
3295
|
+
if (remeasure || !sizeRef.current) {
|
|
3296
|
+
sizeRef.current = {
|
|
3297
|
+
w: pop.offsetWidth,
|
|
3298
|
+
h: Math.max(pop.offsetHeight, pop.scrollHeight)
|
|
3299
|
+
};
|
|
3300
|
+
}
|
|
3301
|
+
const { w: popW, h: popH } = sizeRef.current;
|
|
3302
|
+
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
3303
|
+
if (popH === 0 || popW === 0) {
|
|
3304
|
+
sizeRef.current = null;
|
|
3305
|
+
return;
|
|
3306
|
+
}
|
|
3307
|
+
const parentRect = scrollParentRef.current?.getBoundingClientRect();
|
|
3308
|
+
const clip = {
|
|
3309
|
+
top: Math.max(parentRect?.top ?? 0, 0),
|
|
3310
|
+
bottom: Math.min(parentRect?.bottom ?? window.innerHeight, window.innerHeight),
|
|
3311
|
+
left: Math.max(parentRect?.left ?? 0, 0),
|
|
3312
|
+
right: Math.min(parentRect?.right ?? window.innerWidth, window.innerWidth)
|
|
3313
|
+
};
|
|
3314
|
+
const first = !placedRef.current;
|
|
3315
|
+
if (first) pop.style.transition = "none";
|
|
3316
|
+
const { direction: next, top, left, over, maxHeight } = computePlacement(
|
|
3317
|
+
triggerRect,
|
|
3318
|
+
popW,
|
|
3319
|
+
popH,
|
|
3320
|
+
clip
|
|
3321
|
+
);
|
|
3322
|
+
pop.style.top = `${top + window.scrollY}px`;
|
|
3323
|
+
pop.style.left = `${left + window.scrollX}px`;
|
|
3324
|
+
pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
|
|
3325
|
+
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";
|
|
3326
|
+
directionRef.current = next;
|
|
3327
|
+
pop.classList.toggle("top", next === "top");
|
|
3328
|
+
pop.classList.toggle("bottom", next === "bottom");
|
|
3329
|
+
if (first) {
|
|
3330
|
+
void pop.offsetHeight;
|
|
3331
|
+
pop.style.transition = "";
|
|
3332
|
+
placedRef.current = true;
|
|
3333
|
+
}
|
|
3334
|
+
}, [triggerRef, popRef]);
|
|
3335
|
+
import_react10.default.useLayoutEffect(() => {
|
|
3336
|
+
if (!enabled) {
|
|
3337
|
+
sizeRef.current = null;
|
|
3338
|
+
scrollParentRef.current = null;
|
|
3339
|
+
placedRef.current = false;
|
|
3340
|
+
return;
|
|
3341
|
+
}
|
|
3342
|
+
if (triggerRef.current) {
|
|
3343
|
+
scrollParentRef.current = findScrollParent(triggerRef.current);
|
|
3344
|
+
}
|
|
3345
|
+
calculatePosition(true);
|
|
3346
|
+
const raf = requestAnimationFrame(() => calculatePosition(true));
|
|
3347
|
+
return () => cancelAnimationFrame(raf);
|
|
3348
|
+
}, [calculatePosition, enabled, triggerRef]);
|
|
3349
|
+
import_react10.default.useEffect(() => {
|
|
3350
|
+
if (!enabled || !popRef.current) return;
|
|
3351
|
+
const observer = new ResizeObserver(() => {
|
|
3352
|
+
calculatePosition(true);
|
|
3353
|
+
});
|
|
3354
|
+
observer.observe(popRef.current);
|
|
3355
|
+
return () => observer.disconnect();
|
|
3356
|
+
}, [calculatePosition, enabled, popRef]);
|
|
3357
|
+
import_react10.default.useEffect(() => {
|
|
3358
|
+
if (!enabled) return;
|
|
3359
|
+
const onScroll = () => calculatePosition();
|
|
3360
|
+
const onResize = () => calculatePosition(true);
|
|
3361
|
+
window.addEventListener("resize", onResize, { passive: true });
|
|
3362
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
3363
|
+
return () => {
|
|
3364
|
+
window.removeEventListener("resize", onResize);
|
|
3365
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
3366
|
+
};
|
|
3367
|
+
}, [calculatePosition, enabled]);
|
|
3368
|
+
};
|
|
3369
|
+
var useAutoPosition_default = useAutoPosition;
|
|
3370
|
+
|
|
3371
|
+
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
3234
3372
|
var FOCUSABLE = [
|
|
3235
3373
|
"a[href]",
|
|
3236
3374
|
"button:not([disabled])",
|
|
@@ -3244,7 +3382,7 @@ var focusableIn = (el) => Array.from(el.querySelectorAll(FOCUSABLE)).filter(
|
|
|
3244
3382
|
(n) => n.offsetWidth > 0 || n.offsetHeight > 0 || n === document.activeElement
|
|
3245
3383
|
);
|
|
3246
3384
|
var useEscapeKey = (enabled, onEscape) => {
|
|
3247
|
-
|
|
3385
|
+
import_react11.default.useEffect(() => {
|
|
3248
3386
|
if (!enabled) return;
|
|
3249
3387
|
const onKey = (e) => {
|
|
3250
3388
|
if (e.key !== "Escape") return;
|
|
@@ -3258,8 +3396,8 @@ var useEscapeKey = (enabled, onEscape) => {
|
|
|
3258
3396
|
};
|
|
3259
3397
|
var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
3260
3398
|
const { trap = false, initialFocus } = options;
|
|
3261
|
-
const restoreRef =
|
|
3262
|
-
|
|
3399
|
+
const restoreRef = import_react11.default.useRef(null);
|
|
3400
|
+
import_react11.default.useEffect(() => {
|
|
3263
3401
|
if (!enabled) return;
|
|
3264
3402
|
restoreRef.current = document.activeElement;
|
|
3265
3403
|
const raf = requestAnimationFrame(() => {
|
|
@@ -3277,7 +3415,7 @@ var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
|
3277
3415
|
if (prev && document.contains(prev)) prev.focus({ preventScroll: true });
|
|
3278
3416
|
};
|
|
3279
3417
|
}, [enabled, containerRef, initialFocus]);
|
|
3280
|
-
|
|
3418
|
+
import_react11.default.useEffect(() => {
|
|
3281
3419
|
if (!enabled || !trap) return;
|
|
3282
3420
|
const onKey = (e) => {
|
|
3283
3421
|
if (e.key !== "Tab") return;
|
|
@@ -3303,22 +3441,22 @@ var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
|
3303
3441
|
return () => document.removeEventListener("keydown", onKey);
|
|
3304
3442
|
}, [enabled, trap, containerRef]);
|
|
3305
3443
|
};
|
|
3306
|
-
var
|
|
3307
|
-
const onCloseRef =
|
|
3444
|
+
var useCloseWhenTriggerHidden = (enabled, triggerRef, onClose) => {
|
|
3445
|
+
const onCloseRef = import_react11.default.useRef(onClose);
|
|
3308
3446
|
onCloseRef.current = onClose;
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
}
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
return () =>
|
|
3321
|
-
}, [enabled,
|
|
3447
|
+
import_react11.default.useEffect(() => {
|
|
3448
|
+
const trigger = triggerRef.current;
|
|
3449
|
+
if (!enabled || !trigger) return;
|
|
3450
|
+
const observer = new IntersectionObserver(
|
|
3451
|
+
([entry]) => {
|
|
3452
|
+
if (!entry.isIntersecting) onCloseRef.current();
|
|
3453
|
+
},
|
|
3454
|
+
// 그릇이 없으면 root: null → 뷰포트 기준
|
|
3455
|
+
{ root: findScrollParent(trigger), threshold: 0 }
|
|
3456
|
+
);
|
|
3457
|
+
observer.observe(trigger);
|
|
3458
|
+
return () => observer.disconnect();
|
|
3459
|
+
}, [enabled, triggerRef]);
|
|
3322
3460
|
};
|
|
3323
3461
|
|
|
3324
3462
|
// src/components/Modal/Modal.tsx
|
|
@@ -3326,13 +3464,13 @@ var import_jsx_runtime313 = require("react/jsx-runtime");
|
|
|
3326
3464
|
var ANIMATION_DURATION_MS = 200;
|
|
3327
3465
|
var Modal = (props) => {
|
|
3328
3466
|
const { isOpen, onClose, children } = props;
|
|
3329
|
-
const [mounted, setMounted] =
|
|
3330
|
-
const [visible, setVisible] =
|
|
3331
|
-
const [settled, setSettled] =
|
|
3332
|
-
const boxRef =
|
|
3467
|
+
const [mounted, setMounted] = import_react12.default.useState(false);
|
|
3468
|
+
const [visible, setVisible] = import_react12.default.useState(false);
|
|
3469
|
+
const [settled, setSettled] = import_react12.default.useState(false);
|
|
3470
|
+
const boxRef = import_react12.default.useRef(null);
|
|
3333
3471
|
useEscapeKey(isOpen, onClose);
|
|
3334
3472
|
useFocusTrap(boxRef, isOpen && mounted, { trap: true });
|
|
3335
|
-
|
|
3473
|
+
import_react12.default.useEffect(() => {
|
|
3336
3474
|
if (isOpen) {
|
|
3337
3475
|
setMounted(true);
|
|
3338
3476
|
const show = setTimeout(() => setVisible(true), 1);
|
|
@@ -3376,9 +3514,9 @@ Modal.displayName = "Modal";
|
|
|
3376
3514
|
var Modal_default = Modal;
|
|
3377
3515
|
|
|
3378
3516
|
// src/components/DatePicker/SingleDatePicker/index.tsx
|
|
3379
|
-
var
|
|
3517
|
+
var import_react13 = __toESM(require("react"), 1);
|
|
3380
3518
|
var import_jsx_runtime314 = require("react/jsx-runtime");
|
|
3381
|
-
var DayCell2 =
|
|
3519
|
+
var DayCell2 = import_react13.default.memo(
|
|
3382
3520
|
({
|
|
3383
3521
|
day,
|
|
3384
3522
|
disabled,
|
|
@@ -3427,33 +3565,33 @@ var SingleDatePicker = (props) => {
|
|
|
3427
3565
|
required,
|
|
3428
3566
|
validations
|
|
3429
3567
|
} = props;
|
|
3430
|
-
const labelId =
|
|
3568
|
+
const labelId = import_react13.default.useId();
|
|
3431
3569
|
const initialYear = value?.getFullYear();
|
|
3432
3570
|
const initialMonth = value?.getMonth();
|
|
3433
3571
|
const { year, month, days, goToPrevMonth, goToNextMonth, setYear, setMonth } = useCalendar(
|
|
3434
3572
|
initialYear,
|
|
3435
3573
|
initialMonth
|
|
3436
3574
|
);
|
|
3437
|
-
const [pickerMode, setPickerMode] =
|
|
3438
|
-
const [yearRangeStart, setYearRangeStart] =
|
|
3575
|
+
const [pickerMode, setPickerMode] = import_react13.default.useState("days");
|
|
3576
|
+
const [yearRangeStart, setYearRangeStart] = import_react13.default.useState(
|
|
3439
3577
|
Math.floor((initialYear ?? (/* @__PURE__ */ new Date()).getFullYear()) / 12) * 12
|
|
3440
3578
|
);
|
|
3441
|
-
const minTime =
|
|
3579
|
+
const minTime = import_react13.default.useMemo(
|
|
3442
3580
|
() => minDate ? new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate()).getTime() : -Infinity,
|
|
3443
3581
|
[minDate]
|
|
3444
3582
|
);
|
|
3445
|
-
const maxTime =
|
|
3583
|
+
const maxTime = import_react13.default.useMemo(
|
|
3446
3584
|
() => maxDate ? new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate()).getTime() : Infinity,
|
|
3447
3585
|
[maxDate]
|
|
3448
3586
|
);
|
|
3449
|
-
const highlightSet =
|
|
3587
|
+
const highlightSet = import_react13.default.useMemo(() => {
|
|
3450
3588
|
const set = /* @__PURE__ */ new Set();
|
|
3451
3589
|
for (const h of highlightDates) {
|
|
3452
3590
|
set.add(`${h.getFullYear()}-${h.getMonth()}-${h.getDate()}`);
|
|
3453
3591
|
}
|
|
3454
3592
|
return set;
|
|
3455
3593
|
}, [highlightDates]);
|
|
3456
|
-
const handleSelect =
|
|
3594
|
+
const handleSelect = import_react13.default.useCallback(
|
|
3457
3595
|
(date) => {
|
|
3458
3596
|
onChange?.(date);
|
|
3459
3597
|
},
|
|
@@ -3596,8 +3734,8 @@ var InputDatePicker = (props) => {
|
|
|
3596
3734
|
required,
|
|
3597
3735
|
validations
|
|
3598
3736
|
} = props;
|
|
3599
|
-
const [isOpen, setIsOpen] =
|
|
3600
|
-
const [tempDate, setTempDate] =
|
|
3737
|
+
const [isOpen, setIsOpen] = import_react14.default.useState(false);
|
|
3738
|
+
const [tempDate, setTempDate] = import_react14.default.useState(value ?? /* @__PURE__ */ new Date());
|
|
3601
3739
|
const handleOpen = () => {
|
|
3602
3740
|
if (disabled) return;
|
|
3603
3741
|
setTempDate(value ?? /* @__PURE__ */ new Date());
|
|
@@ -3649,18 +3787,18 @@ InputDatePicker.displayName = "InputDatePicker";
|
|
|
3649
3787
|
var InputDatePicker_default = InputDatePicker;
|
|
3650
3788
|
|
|
3651
3789
|
// src/components/DatePicker/PopupPicker/index.tsx
|
|
3652
|
-
var
|
|
3790
|
+
var import_react18 = __toESM(require("react"), 1);
|
|
3653
3791
|
|
|
3654
3792
|
// src/components/DatePicker/RangePicker/index.tsx
|
|
3655
|
-
var
|
|
3793
|
+
var import_react17 = __toESM(require("react"), 1);
|
|
3656
3794
|
|
|
3657
3795
|
// src/components/Tab/Tab.tsx
|
|
3658
|
-
var
|
|
3796
|
+
var import_react16 = __toESM(require("react"), 1);
|
|
3659
3797
|
|
|
3660
3798
|
// src/components/Tab/TabItem.tsx
|
|
3661
|
-
var
|
|
3799
|
+
var import_react15 = __toESM(require("react"), 1);
|
|
3662
3800
|
var import_jsx_runtime316 = require("react/jsx-runtime");
|
|
3663
|
-
var TabItem =
|
|
3801
|
+
var TabItem = import_react15.default.forwardRef((props, ref) => {
|
|
3664
3802
|
const { isActive: isActive2, title, onClick } = props;
|
|
3665
3803
|
return /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
|
|
3666
3804
|
"button",
|
|
@@ -3684,11 +3822,11 @@ var import_jsx_runtime317 = require("react/jsx-runtime");
|
|
|
3684
3822
|
var Tab = (props) => {
|
|
3685
3823
|
const { activeIndex, onChange, tabs, variant, type, size = "md" } = props;
|
|
3686
3824
|
const shape = variant ?? type ?? "default";
|
|
3687
|
-
const [underlineStyle, setUnderlineStyle] =
|
|
3825
|
+
const [underlineStyle, setUnderlineStyle] = import_react16.default.useState({
|
|
3688
3826
|
left: 0,
|
|
3689
3827
|
width: 0
|
|
3690
3828
|
});
|
|
3691
|
-
const itemRefs =
|
|
3829
|
+
const itemRefs = import_react16.default.useRef([]);
|
|
3692
3830
|
const handleKeyDown = (e) => {
|
|
3693
3831
|
const last = tabs.length - 1;
|
|
3694
3832
|
let next = null;
|
|
@@ -3704,7 +3842,7 @@ var Tab = (props) => {
|
|
|
3704
3842
|
const handleChangeActiveTab = (tabItem, tabIdx) => {
|
|
3705
3843
|
onChange(tabItem, tabIdx);
|
|
3706
3844
|
};
|
|
3707
|
-
|
|
3845
|
+
import_react16.default.useEffect(() => {
|
|
3708
3846
|
const el = itemRefs.current[activeIndex];
|
|
3709
3847
|
if (el) {
|
|
3710
3848
|
setUnderlineStyle({ left: el.offsetLeft, width: el.offsetWidth });
|
|
@@ -3760,8 +3898,8 @@ var RangePicker = (props) => {
|
|
|
3760
3898
|
required,
|
|
3761
3899
|
validations
|
|
3762
3900
|
} = props;
|
|
3763
|
-
const labelId =
|
|
3764
|
-
const [activeTab, setActiveTab] =
|
|
3901
|
+
const labelId = import_react17.default.useId();
|
|
3902
|
+
const [activeTab, setActiveTab] = import_react17.default.useState("start");
|
|
3765
3903
|
const handleStartChange = (date) => {
|
|
3766
3904
|
if (!date) return;
|
|
3767
3905
|
const newStart = date > endDate ? endDate : date;
|
|
@@ -3855,7 +3993,7 @@ var RangePicker_default = RangePicker;
|
|
|
3855
3993
|
var import_jsx_runtime319 = require("react/jsx-runtime");
|
|
3856
3994
|
var PopupPicker = (props) => {
|
|
3857
3995
|
const { component, type, locale } = props;
|
|
3858
|
-
const [isOpen, setIsOpen] =
|
|
3996
|
+
const [isOpen, setIsOpen] = import_react18.default.useState(false);
|
|
3859
3997
|
const handleClick = () => setIsOpen(true);
|
|
3860
3998
|
const handleClose = () => setIsOpen(false);
|
|
3861
3999
|
const handleSingleChange = (date) => {
|
|
@@ -3864,7 +4002,7 @@ var PopupPicker = (props) => {
|
|
|
3864
4002
|
handleClose();
|
|
3865
4003
|
};
|
|
3866
4004
|
return /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)("div", { className: "lib-xplat-popup-datepicker", children: [
|
|
3867
|
-
|
|
4005
|
+
import_react18.default.cloneElement(component, { onClick: handleClick }),
|
|
3868
4006
|
/* @__PURE__ */ (0, import_jsx_runtime319.jsx)(Modal_default, { isOpen, onClose: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime319.jsxs)("div", { className: clsx_default("lib-xplat-popup-datepicker-card", type === "range" && "range-mode"), children: [
|
|
3869
4007
|
/* @__PURE__ */ (0, import_jsx_runtime319.jsxs)("div", { className: "popup-datepicker-content", children: [
|
|
3870
4008
|
type === "single" && /* @__PURE__ */ (0, import_jsx_runtime319.jsx)(
|
|
@@ -3923,18 +4061,18 @@ Divider.displayName = "Divider";
|
|
|
3923
4061
|
var Divider_default = Divider;
|
|
3924
4062
|
|
|
3925
4063
|
// src/components/Drawer/Drawer.tsx
|
|
3926
|
-
var
|
|
4064
|
+
var import_react19 = __toESM(require("react"), 1);
|
|
3927
4065
|
var import_react_dom2 = require("react-dom");
|
|
3928
4066
|
var import_jsx_runtime321 = require("react/jsx-runtime");
|
|
3929
4067
|
var ANIMATION_DURATION_MS2 = 250;
|
|
3930
4068
|
var Drawer = (props) => {
|
|
3931
4069
|
const { isOpen, onClose, placement = "right", size = "md", title, children } = props;
|
|
3932
|
-
const [mounted, setMounted] =
|
|
3933
|
-
const [visible, setVisible] =
|
|
3934
|
-
const panelRef =
|
|
4070
|
+
const [mounted, setMounted] = import_react19.default.useState(false);
|
|
4071
|
+
const [visible, setVisible] = import_react19.default.useState(false);
|
|
4072
|
+
const panelRef = import_react19.default.useRef(null);
|
|
3935
4073
|
useEscapeKey(isOpen, onClose);
|
|
3936
4074
|
useFocusTrap(panelRef, isOpen && mounted, { trap: true });
|
|
3937
|
-
|
|
4075
|
+
import_react19.default.useEffect(() => {
|
|
3938
4076
|
if (isOpen) {
|
|
3939
4077
|
setMounted(true);
|
|
3940
4078
|
const t2 = setTimeout(() => setVisible(true), 1);
|
|
@@ -3990,142 +4128,6 @@ var Portal = ({ children }) => {
|
|
|
3990
4128
|
Portal.displayName = "Portal";
|
|
3991
4129
|
var Portal_default = Portal;
|
|
3992
4130
|
|
|
3993
|
-
// src/tokens/hooks/useAutoPosition.ts
|
|
3994
|
-
var import_react19 = __toESM(require("react"), 1);
|
|
3995
|
-
var findScrollParent = (el) => {
|
|
3996
|
-
for (let p = el.parentElement; p; p = p.parentElement) {
|
|
3997
|
-
const { overflowY, overflowX } = getComputedStyle(p);
|
|
3998
|
-
if (/(auto|scroll)/.test(overflowY) || /(auto|scroll)/.test(overflowX)) return p;
|
|
3999
|
-
}
|
|
4000
|
-
return null;
|
|
4001
|
-
};
|
|
4002
|
-
var TRIGGER_GAP = 8;
|
|
4003
|
-
var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
4004
|
-
const roomBelow = clip.bottom - triggerRect.bottom - TRIGGER_GAP;
|
|
4005
|
-
const roomAbove = triggerRect.top - clip.top - TRIGGER_GAP;
|
|
4006
|
-
let direction;
|
|
4007
|
-
let top;
|
|
4008
|
-
let maxHeight = null;
|
|
4009
|
-
if (popH <= roomBelow) {
|
|
4010
|
-
direction = "bottom";
|
|
4011
|
-
top = triggerRect.bottom + TRIGGER_GAP;
|
|
4012
|
-
} else if (popH <= roomAbove) {
|
|
4013
|
-
direction = "top";
|
|
4014
|
-
top = triggerRect.top - TRIGGER_GAP - popH;
|
|
4015
|
-
} else {
|
|
4016
|
-
const room = Math.max(roomBelow, roomAbove, 0);
|
|
4017
|
-
if (roomBelow >= roomAbove) {
|
|
4018
|
-
direction = "bottom";
|
|
4019
|
-
top = triggerRect.bottom + TRIGGER_GAP;
|
|
4020
|
-
} else {
|
|
4021
|
-
direction = "top";
|
|
4022
|
-
top = triggerRect.top - TRIGGER_GAP - room;
|
|
4023
|
-
}
|
|
4024
|
-
maxHeight = room;
|
|
4025
|
-
}
|
|
4026
|
-
let left = triggerRect.left;
|
|
4027
|
-
if (left + popW > clip.right - 8) {
|
|
4028
|
-
left = triggerRect.right - popW;
|
|
4029
|
-
}
|
|
4030
|
-
if (left < clip.left + 8) left = clip.left + 8;
|
|
4031
|
-
const drawnH = maxHeight === null ? popH : Math.min(popH, maxHeight);
|
|
4032
|
-
return {
|
|
4033
|
-
direction,
|
|
4034
|
-
top,
|
|
4035
|
-
left,
|
|
4036
|
-
maxHeight,
|
|
4037
|
-
over: {
|
|
4038
|
-
top: Math.max(0, clip.top - top),
|
|
4039
|
-
right: Math.max(0, left + popW - clip.right),
|
|
4040
|
-
bottom: Math.max(0, top + drawnH - clip.bottom),
|
|
4041
|
-
left: Math.max(0, clip.left - left)
|
|
4042
|
-
}
|
|
4043
|
-
};
|
|
4044
|
-
};
|
|
4045
|
-
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
4046
|
-
const directionRef = import_react19.default.useRef("bottom");
|
|
4047
|
-
const sizeRef = import_react19.default.useRef(null);
|
|
4048
|
-
const scrollParentRef = import_react19.default.useRef(null);
|
|
4049
|
-
const placedRef = import_react19.default.useRef(false);
|
|
4050
|
-
const calculatePosition = import_react19.default.useCallback((remeasure = false) => {
|
|
4051
|
-
const pop = popRef.current;
|
|
4052
|
-
if (!triggerRef.current || !pop) return;
|
|
4053
|
-
if (remeasure || !sizeRef.current) {
|
|
4054
|
-
sizeRef.current = {
|
|
4055
|
-
w: pop.offsetWidth,
|
|
4056
|
-
h: Math.max(pop.offsetHeight, pop.scrollHeight)
|
|
4057
|
-
};
|
|
4058
|
-
}
|
|
4059
|
-
const { w: popW, h: popH } = sizeRef.current;
|
|
4060
|
-
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
4061
|
-
if (popH === 0 || popW === 0) {
|
|
4062
|
-
sizeRef.current = null;
|
|
4063
|
-
return;
|
|
4064
|
-
}
|
|
4065
|
-
const parentRect = scrollParentRef.current?.getBoundingClientRect();
|
|
4066
|
-
const clip = {
|
|
4067
|
-
top: Math.max(parentRect?.top ?? 0, 0),
|
|
4068
|
-
bottom: Math.min(parentRect?.bottom ?? window.innerHeight, window.innerHeight),
|
|
4069
|
-
left: Math.max(parentRect?.left ?? 0, 0),
|
|
4070
|
-
right: Math.min(parentRect?.right ?? window.innerWidth, window.innerWidth)
|
|
4071
|
-
};
|
|
4072
|
-
const first = !placedRef.current;
|
|
4073
|
-
if (first) pop.style.transition = "none";
|
|
4074
|
-
const { direction: next, top, left, over, maxHeight } = computePlacement(
|
|
4075
|
-
triggerRect,
|
|
4076
|
-
popW,
|
|
4077
|
-
popH,
|
|
4078
|
-
clip
|
|
4079
|
-
);
|
|
4080
|
-
pop.style.top = `${top + window.scrollY}px`;
|
|
4081
|
-
pop.style.left = `${left + window.scrollX}px`;
|
|
4082
|
-
pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
|
|
4083
|
-
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";
|
|
4084
|
-
directionRef.current = next;
|
|
4085
|
-
pop.classList.toggle("top", next === "top");
|
|
4086
|
-
pop.classList.toggle("bottom", next === "bottom");
|
|
4087
|
-
if (first) {
|
|
4088
|
-
void pop.offsetHeight;
|
|
4089
|
-
pop.style.transition = "";
|
|
4090
|
-
placedRef.current = true;
|
|
4091
|
-
}
|
|
4092
|
-
}, [triggerRef, popRef]);
|
|
4093
|
-
import_react19.default.useLayoutEffect(() => {
|
|
4094
|
-
if (!enabled) {
|
|
4095
|
-
sizeRef.current = null;
|
|
4096
|
-
scrollParentRef.current = null;
|
|
4097
|
-
placedRef.current = false;
|
|
4098
|
-
return;
|
|
4099
|
-
}
|
|
4100
|
-
if (triggerRef.current) {
|
|
4101
|
-
scrollParentRef.current = findScrollParent(triggerRef.current);
|
|
4102
|
-
}
|
|
4103
|
-
calculatePosition(true);
|
|
4104
|
-
const raf = requestAnimationFrame(() => calculatePosition(true));
|
|
4105
|
-
return () => cancelAnimationFrame(raf);
|
|
4106
|
-
}, [calculatePosition, enabled, triggerRef]);
|
|
4107
|
-
import_react19.default.useEffect(() => {
|
|
4108
|
-
if (!enabled || !popRef.current) return;
|
|
4109
|
-
const observer = new ResizeObserver(() => {
|
|
4110
|
-
calculatePosition(true);
|
|
4111
|
-
});
|
|
4112
|
-
observer.observe(popRef.current);
|
|
4113
|
-
return () => observer.disconnect();
|
|
4114
|
-
}, [calculatePosition, enabled, popRef]);
|
|
4115
|
-
import_react19.default.useEffect(() => {
|
|
4116
|
-
if (!enabled) return;
|
|
4117
|
-
const onScroll = () => calculatePosition();
|
|
4118
|
-
const onResize = () => calculatePosition(true);
|
|
4119
|
-
window.addEventListener("resize", onResize, { passive: true });
|
|
4120
|
-
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
4121
|
-
return () => {
|
|
4122
|
-
window.removeEventListener("resize", onResize);
|
|
4123
|
-
window.removeEventListener("scroll", onScroll, true);
|
|
4124
|
-
};
|
|
4125
|
-
}, [calculatePosition, enabled]);
|
|
4126
|
-
};
|
|
4127
|
-
var useAutoPosition_default = useAutoPosition;
|
|
4128
|
-
|
|
4129
4131
|
// src/tokens/hooks/useClickOutside.ts
|
|
4130
4132
|
var import_react20 = __toESM(require("react"), 1);
|
|
4131
4133
|
var useClickOutside = (refs, handler, enabled = true) => {
|
|
@@ -4162,7 +4164,7 @@ var Dropdown = (props) => {
|
|
|
4162
4164
|
const menuRef = import_react21.default.useRef(null);
|
|
4163
4165
|
useAutoPosition_default(triggerRef, menuRef, mounted);
|
|
4164
4166
|
useClickOutside_default([triggerRef, menuRef], () => setIsOpen(false), isOpen);
|
|
4165
|
-
|
|
4167
|
+
useCloseWhenTriggerHidden(isOpen, triggerRef, () => setIsOpen(false));
|
|
4166
4168
|
useEscapeKey(isOpen, () => {
|
|
4167
4169
|
setIsOpen(false);
|
|
4168
4170
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -6093,7 +6095,7 @@ var PopOver = (props) => {
|
|
|
6093
6095
|
const [localOpen, setLocalOpen] = import_react27.default.useState(false);
|
|
6094
6096
|
const [eventTrigger, setEventTrigger] = import_react27.default.useState(false);
|
|
6095
6097
|
useClickOutside_default([popRef, triggerRef], onClose, isOpen);
|
|
6096
|
-
|
|
6098
|
+
useCloseWhenTriggerHidden(isOpen, triggerRef, onClose);
|
|
6097
6099
|
useEscapeKey(isOpen, () => {
|
|
6098
6100
|
onClose();
|
|
6099
6101
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -6373,7 +6375,7 @@ var SelectRoot = (props) => {
|
|
|
6373
6375
|
}, []);
|
|
6374
6376
|
const toggle = import_react31.default.useCallback(() => setOpen((prev) => !prev), []);
|
|
6375
6377
|
useClickOutside_default([contentRef, triggerRef], close, isOpen);
|
|
6376
|
-
|
|
6378
|
+
useCloseWhenTriggerHidden(isOpen, triggerRef, close);
|
|
6377
6379
|
useEscapeKey(isOpen, () => {
|
|
6378
6380
|
close();
|
|
6379
6381
|
triggerRef.current?.focus({ preventScroll: true });
|
|
@@ -7314,7 +7316,7 @@ var TimePicker = (props) => {
|
|
|
7314
7316
|
}, [step, min, max]);
|
|
7315
7317
|
const close = import_react40.default.useCallback(() => setOpen(false), []);
|
|
7316
7318
|
useClickOutside_default([triggerRef, contentRef], close, isOpen);
|
|
7317
|
-
|
|
7319
|
+
useCloseWhenTriggerHidden(isOpen, triggerRef, close);
|
|
7318
7320
|
useEscapeKey(isOpen, () => {
|
|
7319
7321
|
close();
|
|
7320
7322
|
triggerRef.current?.focus({ preventScroll: true });
|