@x-plat/design-system 0.14.14 → 0.14.16
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 +17 -14
- package/dist/components/Dropdown/index.js +17 -14
- package/dist/components/Modal/index.cjs +15 -10
- package/dist/components/Modal/index.js +15 -10
- package/dist/components/PopOver/index.cjs +17 -14
- package/dist/components/PopOver/index.js +17 -14
- package/dist/components/Select/index.cjs +17 -14
- package/dist/components/Select/index.js +17 -14
- package/dist/components/TimePicker/index.cjs +17 -14
- package/dist/components/TimePicker/index.js +17 -14
- package/dist/components/index.cjs +199 -194
- package/dist/components/index.js +199 -194
- package/dist/index.cjs +199 -194
- package/dist/index.js +199 -194
- package/guidelines/MIGRATION.md +40 -29
- package/package.json +1 -1
|
@@ -38,7 +38,7 @@ __export(DatePicker_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(DatePicker_exports);
|
|
39
39
|
|
|
40
40
|
// src/components/DatePicker/InputDatePicker/index.tsx
|
|
41
|
-
var
|
|
41
|
+
var import_react8 = __toESM(require("react"), 1);
|
|
42
42
|
|
|
43
43
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
44
44
|
function r(e) {
|
|
@@ -456,11 +456,16 @@ var PasswordInput = import_react2.default.forwardRef(
|
|
|
456
456
|
PasswordInput.displayName = "PasswordInput";
|
|
457
457
|
|
|
458
458
|
// src/components/Modal/Modal.tsx
|
|
459
|
-
var
|
|
459
|
+
var import_react5 = __toESM(require("react"), 1);
|
|
460
460
|
var import_react_dom = require("react-dom");
|
|
461
461
|
|
|
462
462
|
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
463
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
464
|
+
|
|
465
|
+
// src/tokens/hooks/useAutoPosition.ts
|
|
463
466
|
var import_react3 = __toESM(require("react"), 1);
|
|
467
|
+
|
|
468
|
+
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
464
469
|
var FOCUSABLE = [
|
|
465
470
|
"a[href]",
|
|
466
471
|
"button:not([disabled])",
|
|
@@ -474,7 +479,7 @@ var focusableIn = (el) => Array.from(el.querySelectorAll(FOCUSABLE)).filter(
|
|
|
474
479
|
(n) => n.offsetWidth > 0 || n.offsetHeight > 0 || n === document.activeElement
|
|
475
480
|
);
|
|
476
481
|
var useEscapeKey = (enabled, onEscape) => {
|
|
477
|
-
|
|
482
|
+
import_react4.default.useEffect(() => {
|
|
478
483
|
if (!enabled) return;
|
|
479
484
|
const onKey = (e) => {
|
|
480
485
|
if (e.key !== "Escape") return;
|
|
@@ -488,8 +493,8 @@ var useEscapeKey = (enabled, onEscape) => {
|
|
|
488
493
|
};
|
|
489
494
|
var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
490
495
|
const { trap = false, initialFocus } = options;
|
|
491
|
-
const restoreRef =
|
|
492
|
-
|
|
496
|
+
const restoreRef = import_react4.default.useRef(null);
|
|
497
|
+
import_react4.default.useEffect(() => {
|
|
493
498
|
if (!enabled) return;
|
|
494
499
|
restoreRef.current = document.activeElement;
|
|
495
500
|
const raf = requestAnimationFrame(() => {
|
|
@@ -507,7 +512,7 @@ var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
|
507
512
|
if (prev && document.contains(prev)) prev.focus({ preventScroll: true });
|
|
508
513
|
};
|
|
509
514
|
}, [enabled, containerRef, initialFocus]);
|
|
510
|
-
|
|
515
|
+
import_react4.default.useEffect(() => {
|
|
511
516
|
if (!enabled || !trap) return;
|
|
512
517
|
const onKey = (e) => {
|
|
513
518
|
if (e.key !== "Tab") return;
|
|
@@ -539,13 +544,13 @@ var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
|
539
544
|
var ANIMATION_DURATION_MS = 200;
|
|
540
545
|
var Modal = (props) => {
|
|
541
546
|
const { isOpen, onClose, children } = props;
|
|
542
|
-
const [mounted, setMounted] =
|
|
543
|
-
const [visible, setVisible] =
|
|
544
|
-
const [settled, setSettled] =
|
|
545
|
-
const boxRef =
|
|
547
|
+
const [mounted, setMounted] = import_react5.default.useState(false);
|
|
548
|
+
const [visible, setVisible] = import_react5.default.useState(false);
|
|
549
|
+
const [settled, setSettled] = import_react5.default.useState(false);
|
|
550
|
+
const boxRef = import_react5.default.useRef(null);
|
|
546
551
|
useEscapeKey(isOpen, onClose);
|
|
547
552
|
useFocusTrap(boxRef, isOpen && mounted, { trap: true });
|
|
548
|
-
|
|
553
|
+
import_react5.default.useEffect(() => {
|
|
549
554
|
if (isOpen) {
|
|
550
555
|
setMounted(true);
|
|
551
556
|
const show = setTimeout(() => setVisible(true), 1);
|
|
@@ -1500,15 +1505,15 @@ var import_jsx_runtime298 = require("react/jsx-runtime");
|
|
|
1500
1505
|
var import_jsx_runtime299 = require("react/jsx-runtime");
|
|
1501
1506
|
|
|
1502
1507
|
// src/components/DatePicker/SingleDatePicker/index.tsx
|
|
1503
|
-
var
|
|
1508
|
+
var import_react7 = __toESM(require("react"), 1);
|
|
1504
1509
|
|
|
1505
1510
|
// src/components/Calendar/useCalendar.ts
|
|
1506
|
-
var
|
|
1511
|
+
var import_react6 = __toESM(require("react"), 1);
|
|
1507
1512
|
var useCalendar = (initialYear, initialMonth) => {
|
|
1508
1513
|
const today = /* @__PURE__ */ new Date();
|
|
1509
|
-
const [year, setYear] =
|
|
1510
|
-
const [month, setMonth] =
|
|
1511
|
-
const days =
|
|
1514
|
+
const [year, setYear] = import_react6.default.useState(initialYear ?? today.getFullYear());
|
|
1515
|
+
const [month, setMonth] = import_react6.default.useState(initialMonth ?? today.getMonth());
|
|
1516
|
+
const days = import_react6.default.useMemo(() => {
|
|
1512
1517
|
const firstDay = new Date(year, month, 1);
|
|
1513
1518
|
const lastDay = new Date(year, month + 1, 0);
|
|
1514
1519
|
const startDayOfWeek = firstDay.getDay();
|
|
@@ -1551,7 +1556,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1551
1556
|
}
|
|
1552
1557
|
return result;
|
|
1553
1558
|
}, [year, month]);
|
|
1554
|
-
const goToPrevMonth =
|
|
1559
|
+
const goToPrevMonth = import_react6.default.useCallback(() => {
|
|
1555
1560
|
setMonth((prev) => {
|
|
1556
1561
|
if (prev === 0) {
|
|
1557
1562
|
setYear((y) => y - 1);
|
|
@@ -1560,7 +1565,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1560
1565
|
return prev - 1;
|
|
1561
1566
|
});
|
|
1562
1567
|
}, []);
|
|
1563
|
-
const goToNextMonth =
|
|
1568
|
+
const goToNextMonth = import_react6.default.useCallback(() => {
|
|
1564
1569
|
setMonth((prev) => {
|
|
1565
1570
|
if (prev === 11) {
|
|
1566
1571
|
setYear((y) => y + 1);
|
|
@@ -1569,7 +1574,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1569
1574
|
return prev + 1;
|
|
1570
1575
|
});
|
|
1571
1576
|
}, []);
|
|
1572
|
-
const goToToday =
|
|
1577
|
+
const goToToday = import_react6.default.useCallback(() => {
|
|
1573
1578
|
setYear(today.getFullYear());
|
|
1574
1579
|
setMonth(today.getMonth());
|
|
1575
1580
|
}, []);
|
|
@@ -1604,7 +1609,7 @@ var MONTH_LABELS = {
|
|
|
1604
1609
|
|
|
1605
1610
|
// src/components/DatePicker/SingleDatePicker/index.tsx
|
|
1606
1611
|
var import_jsx_runtime300 = require("react/jsx-runtime");
|
|
1607
|
-
var DayCell =
|
|
1612
|
+
var DayCell = import_react7.default.memo(
|
|
1608
1613
|
({
|
|
1609
1614
|
day,
|
|
1610
1615
|
disabled,
|
|
@@ -1653,33 +1658,33 @@ var SingleDatePicker = (props) => {
|
|
|
1653
1658
|
required,
|
|
1654
1659
|
validations
|
|
1655
1660
|
} = props;
|
|
1656
|
-
const labelId =
|
|
1661
|
+
const labelId = import_react7.default.useId();
|
|
1657
1662
|
const initialYear = value?.getFullYear();
|
|
1658
1663
|
const initialMonth = value?.getMonth();
|
|
1659
1664
|
const { year, month, days, goToPrevMonth, goToNextMonth, setYear, setMonth } = useCalendar(
|
|
1660
1665
|
initialYear,
|
|
1661
1666
|
initialMonth
|
|
1662
1667
|
);
|
|
1663
|
-
const [pickerMode, setPickerMode] =
|
|
1664
|
-
const [yearRangeStart, setYearRangeStart] =
|
|
1668
|
+
const [pickerMode, setPickerMode] = import_react7.default.useState("days");
|
|
1669
|
+
const [yearRangeStart, setYearRangeStart] = import_react7.default.useState(
|
|
1665
1670
|
Math.floor((initialYear ?? (/* @__PURE__ */ new Date()).getFullYear()) / 12) * 12
|
|
1666
1671
|
);
|
|
1667
|
-
const minTime =
|
|
1672
|
+
const minTime = import_react7.default.useMemo(
|
|
1668
1673
|
() => minDate ? new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate()).getTime() : -Infinity,
|
|
1669
1674
|
[minDate]
|
|
1670
1675
|
);
|
|
1671
|
-
const maxTime =
|
|
1676
|
+
const maxTime = import_react7.default.useMemo(
|
|
1672
1677
|
() => maxDate ? new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate()).getTime() : Infinity,
|
|
1673
1678
|
[maxDate]
|
|
1674
1679
|
);
|
|
1675
|
-
const highlightSet =
|
|
1680
|
+
const highlightSet = import_react7.default.useMemo(() => {
|
|
1676
1681
|
const set = /* @__PURE__ */ new Set();
|
|
1677
1682
|
for (const h of highlightDates) {
|
|
1678
1683
|
set.add(`${h.getFullYear()}-${h.getMonth()}-${h.getDate()}`);
|
|
1679
1684
|
}
|
|
1680
1685
|
return set;
|
|
1681
1686
|
}, [highlightDates]);
|
|
1682
|
-
const handleSelect =
|
|
1687
|
+
const handleSelect = import_react7.default.useCallback(
|
|
1683
1688
|
(date) => {
|
|
1684
1689
|
onChange?.(date);
|
|
1685
1690
|
},
|
|
@@ -1822,8 +1827,8 @@ var InputDatePicker = (props) => {
|
|
|
1822
1827
|
required,
|
|
1823
1828
|
validations
|
|
1824
1829
|
} = props;
|
|
1825
|
-
const [isOpen, setIsOpen] =
|
|
1826
|
-
const [tempDate, setTempDate] =
|
|
1830
|
+
const [isOpen, setIsOpen] = import_react8.default.useState(false);
|
|
1831
|
+
const [tempDate, setTempDate] = import_react8.default.useState(value ?? /* @__PURE__ */ new Date());
|
|
1827
1832
|
const handleOpen = () => {
|
|
1828
1833
|
if (disabled) return;
|
|
1829
1834
|
setTempDate(value ?? /* @__PURE__ */ new Date());
|
|
@@ -1875,18 +1880,18 @@ InputDatePicker.displayName = "InputDatePicker";
|
|
|
1875
1880
|
var InputDatePicker_default = InputDatePicker;
|
|
1876
1881
|
|
|
1877
1882
|
// src/components/DatePicker/PopupPicker/index.tsx
|
|
1878
|
-
var
|
|
1883
|
+
var import_react12 = __toESM(require("react"), 1);
|
|
1879
1884
|
|
|
1880
1885
|
// src/components/DatePicker/RangePicker/index.tsx
|
|
1881
|
-
var
|
|
1886
|
+
var import_react11 = __toESM(require("react"), 1);
|
|
1882
1887
|
|
|
1883
1888
|
// src/components/Tab/Tab.tsx
|
|
1884
|
-
var
|
|
1889
|
+
var import_react10 = __toESM(require("react"), 1);
|
|
1885
1890
|
|
|
1886
1891
|
// src/components/Tab/TabItem.tsx
|
|
1887
|
-
var
|
|
1892
|
+
var import_react9 = __toESM(require("react"), 1);
|
|
1888
1893
|
var import_jsx_runtime302 = require("react/jsx-runtime");
|
|
1889
|
-
var TabItem =
|
|
1894
|
+
var TabItem = import_react9.default.forwardRef((props, ref) => {
|
|
1890
1895
|
const { isActive, title, onClick } = props;
|
|
1891
1896
|
return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(
|
|
1892
1897
|
"button",
|
|
@@ -1910,11 +1915,11 @@ var import_jsx_runtime303 = require("react/jsx-runtime");
|
|
|
1910
1915
|
var Tab = (props) => {
|
|
1911
1916
|
const { activeIndex, onChange, tabs, variant, type, size = "md" } = props;
|
|
1912
1917
|
const shape = variant ?? type ?? "default";
|
|
1913
|
-
const [underlineStyle, setUnderlineStyle] =
|
|
1918
|
+
const [underlineStyle, setUnderlineStyle] = import_react10.default.useState({
|
|
1914
1919
|
left: 0,
|
|
1915
1920
|
width: 0
|
|
1916
1921
|
});
|
|
1917
|
-
const itemRefs =
|
|
1922
|
+
const itemRefs = import_react10.default.useRef([]);
|
|
1918
1923
|
const handleKeyDown = (e) => {
|
|
1919
1924
|
const last = tabs.length - 1;
|
|
1920
1925
|
let next = null;
|
|
@@ -1930,7 +1935,7 @@ var Tab = (props) => {
|
|
|
1930
1935
|
const handleChangeActiveTab = (tabItem, tabIdx) => {
|
|
1931
1936
|
onChange(tabItem, tabIdx);
|
|
1932
1937
|
};
|
|
1933
|
-
|
|
1938
|
+
import_react10.default.useEffect(() => {
|
|
1934
1939
|
const el = itemRefs.current[activeIndex];
|
|
1935
1940
|
if (el) {
|
|
1936
1941
|
setUnderlineStyle({ left: el.offsetLeft, width: el.offsetWidth });
|
|
@@ -1986,8 +1991,8 @@ var RangePicker = (props) => {
|
|
|
1986
1991
|
required,
|
|
1987
1992
|
validations
|
|
1988
1993
|
} = props;
|
|
1989
|
-
const labelId =
|
|
1990
|
-
const [activeTab, setActiveTab] =
|
|
1994
|
+
const labelId = import_react11.default.useId();
|
|
1995
|
+
const [activeTab, setActiveTab] = import_react11.default.useState("start");
|
|
1991
1996
|
const handleStartChange = (date) => {
|
|
1992
1997
|
if (!date) return;
|
|
1993
1998
|
const newStart = date > endDate ? endDate : date;
|
|
@@ -2081,7 +2086,7 @@ var RangePicker_default = RangePicker;
|
|
|
2081
2086
|
var import_jsx_runtime305 = require("react/jsx-runtime");
|
|
2082
2087
|
var PopupPicker = (props) => {
|
|
2083
2088
|
const { component, type, locale } = props;
|
|
2084
|
-
const [isOpen, setIsOpen] =
|
|
2089
|
+
const [isOpen, setIsOpen] = import_react12.default.useState(false);
|
|
2085
2090
|
const handleClick = () => setIsOpen(true);
|
|
2086
2091
|
const handleClose = () => setIsOpen(false);
|
|
2087
2092
|
const handleSingleChange = (date) => {
|
|
@@ -2090,7 +2095,7 @@ var PopupPicker = (props) => {
|
|
|
2090
2095
|
handleClose();
|
|
2091
2096
|
};
|
|
2092
2097
|
return /* @__PURE__ */ (0, import_jsx_runtime305.jsxs)("div", { className: "lib-xplat-popup-datepicker", children: [
|
|
2093
|
-
|
|
2098
|
+
import_react12.default.cloneElement(component, { onClick: handleClick }),
|
|
2094
2099
|
/* @__PURE__ */ (0, import_jsx_runtime305.jsx)(Modal_default, { isOpen, onClose: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime305.jsxs)("div", { className: clsx_default("lib-xplat-popup-datepicker-card", type === "range" && "range-mode"), children: [
|
|
2095
2100
|
/* @__PURE__ */ (0, import_jsx_runtime305.jsxs)("div", { className: "popup-datepicker-content", children: [
|
|
2096
2101
|
type === "single" && /* @__PURE__ */ (0, import_jsx_runtime305.jsx)(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/DatePicker/InputDatePicker/index.tsx
|
|
2
|
-
import
|
|
2
|
+
import React8 from "react";
|
|
3
3
|
|
|
4
4
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
5
5
|
function r(e) {
|
|
@@ -417,11 +417,16 @@ var PasswordInput = React2.forwardRef(
|
|
|
417
417
|
PasswordInput.displayName = "PasswordInput";
|
|
418
418
|
|
|
419
419
|
// src/components/Modal/Modal.tsx
|
|
420
|
-
import
|
|
420
|
+
import React5 from "react";
|
|
421
421
|
import { createPortal } from "react-dom";
|
|
422
422
|
|
|
423
423
|
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
424
|
+
import React4 from "react";
|
|
425
|
+
|
|
426
|
+
// src/tokens/hooks/useAutoPosition.ts
|
|
424
427
|
import React3 from "react";
|
|
428
|
+
|
|
429
|
+
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
425
430
|
var FOCUSABLE = [
|
|
426
431
|
"a[href]",
|
|
427
432
|
"button:not([disabled])",
|
|
@@ -435,7 +440,7 @@ var focusableIn = (el) => Array.from(el.querySelectorAll(FOCUSABLE)).filter(
|
|
|
435
440
|
(n) => n.offsetWidth > 0 || n.offsetHeight > 0 || n === document.activeElement
|
|
436
441
|
);
|
|
437
442
|
var useEscapeKey = (enabled, onEscape) => {
|
|
438
|
-
|
|
443
|
+
React4.useEffect(() => {
|
|
439
444
|
if (!enabled) return;
|
|
440
445
|
const onKey = (e) => {
|
|
441
446
|
if (e.key !== "Escape") return;
|
|
@@ -449,8 +454,8 @@ var useEscapeKey = (enabled, onEscape) => {
|
|
|
449
454
|
};
|
|
450
455
|
var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
451
456
|
const { trap = false, initialFocus } = options;
|
|
452
|
-
const restoreRef =
|
|
453
|
-
|
|
457
|
+
const restoreRef = React4.useRef(null);
|
|
458
|
+
React4.useEffect(() => {
|
|
454
459
|
if (!enabled) return;
|
|
455
460
|
restoreRef.current = document.activeElement;
|
|
456
461
|
const raf = requestAnimationFrame(() => {
|
|
@@ -468,7 +473,7 @@ var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
|
468
473
|
if (prev && document.contains(prev)) prev.focus({ preventScroll: true });
|
|
469
474
|
};
|
|
470
475
|
}, [enabled, containerRef, initialFocus]);
|
|
471
|
-
|
|
476
|
+
React4.useEffect(() => {
|
|
472
477
|
if (!enabled || !trap) return;
|
|
473
478
|
const onKey = (e) => {
|
|
474
479
|
if (e.key !== "Tab") return;
|
|
@@ -500,13 +505,13 @@ import { jsx as jsx10 } from "react/jsx-runtime";
|
|
|
500
505
|
var ANIMATION_DURATION_MS = 200;
|
|
501
506
|
var Modal = (props) => {
|
|
502
507
|
const { isOpen, onClose, children } = props;
|
|
503
|
-
const [mounted, setMounted] =
|
|
504
|
-
const [visible, setVisible] =
|
|
505
|
-
const [settled, setSettled] =
|
|
506
|
-
const boxRef =
|
|
508
|
+
const [mounted, setMounted] = React5.useState(false);
|
|
509
|
+
const [visible, setVisible] = React5.useState(false);
|
|
510
|
+
const [settled, setSettled] = React5.useState(false);
|
|
511
|
+
const boxRef = React5.useRef(null);
|
|
507
512
|
useEscapeKey(isOpen, onClose);
|
|
508
513
|
useFocusTrap(boxRef, isOpen && mounted, { trap: true });
|
|
509
|
-
|
|
514
|
+
React5.useEffect(() => {
|
|
510
515
|
if (isOpen) {
|
|
511
516
|
setMounted(true);
|
|
512
517
|
const show = setTimeout(() => setVisible(true), 1);
|
|
@@ -1461,15 +1466,15 @@ import { jsx as jsx298, jsxs as jsxs189 } from "react/jsx-runtime";
|
|
|
1461
1466
|
import { jsx as jsx299, jsxs as jsxs190 } from "react/jsx-runtime";
|
|
1462
1467
|
|
|
1463
1468
|
// src/components/DatePicker/SingleDatePicker/index.tsx
|
|
1464
|
-
import
|
|
1469
|
+
import React7 from "react";
|
|
1465
1470
|
|
|
1466
1471
|
// src/components/Calendar/useCalendar.ts
|
|
1467
|
-
import
|
|
1472
|
+
import React6 from "react";
|
|
1468
1473
|
var useCalendar = (initialYear, initialMonth) => {
|
|
1469
1474
|
const today = /* @__PURE__ */ new Date();
|
|
1470
|
-
const [year, setYear] =
|
|
1471
|
-
const [month, setMonth] =
|
|
1472
|
-
const days =
|
|
1475
|
+
const [year, setYear] = React6.useState(initialYear ?? today.getFullYear());
|
|
1476
|
+
const [month, setMonth] = React6.useState(initialMonth ?? today.getMonth());
|
|
1477
|
+
const days = React6.useMemo(() => {
|
|
1473
1478
|
const firstDay = new Date(year, month, 1);
|
|
1474
1479
|
const lastDay = new Date(year, month + 1, 0);
|
|
1475
1480
|
const startDayOfWeek = firstDay.getDay();
|
|
@@ -1512,7 +1517,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1512
1517
|
}
|
|
1513
1518
|
return result;
|
|
1514
1519
|
}, [year, month]);
|
|
1515
|
-
const goToPrevMonth =
|
|
1520
|
+
const goToPrevMonth = React6.useCallback(() => {
|
|
1516
1521
|
setMonth((prev) => {
|
|
1517
1522
|
if (prev === 0) {
|
|
1518
1523
|
setYear((y) => y - 1);
|
|
@@ -1521,7 +1526,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1521
1526
|
return prev - 1;
|
|
1522
1527
|
});
|
|
1523
1528
|
}, []);
|
|
1524
|
-
const goToNextMonth =
|
|
1529
|
+
const goToNextMonth = React6.useCallback(() => {
|
|
1525
1530
|
setMonth((prev) => {
|
|
1526
1531
|
if (prev === 11) {
|
|
1527
1532
|
setYear((y) => y + 1);
|
|
@@ -1530,7 +1535,7 @@ var useCalendar = (initialYear, initialMonth) => {
|
|
|
1530
1535
|
return prev + 1;
|
|
1531
1536
|
});
|
|
1532
1537
|
}, []);
|
|
1533
|
-
const goToToday =
|
|
1538
|
+
const goToToday = React6.useCallback(() => {
|
|
1534
1539
|
setYear(today.getFullYear());
|
|
1535
1540
|
setMonth(today.getMonth());
|
|
1536
1541
|
}, []);
|
|
@@ -1565,7 +1570,7 @@ var MONTH_LABELS = {
|
|
|
1565
1570
|
|
|
1566
1571
|
// src/components/DatePicker/SingleDatePicker/index.tsx
|
|
1567
1572
|
import { Fragment as Fragment2, jsx as jsx300, jsxs as jsxs191 } from "react/jsx-runtime";
|
|
1568
|
-
var DayCell =
|
|
1573
|
+
var DayCell = React7.memo(
|
|
1569
1574
|
({
|
|
1570
1575
|
day,
|
|
1571
1576
|
disabled,
|
|
@@ -1614,33 +1619,33 @@ var SingleDatePicker = (props) => {
|
|
|
1614
1619
|
required,
|
|
1615
1620
|
validations
|
|
1616
1621
|
} = props;
|
|
1617
|
-
const labelId =
|
|
1622
|
+
const labelId = React7.useId();
|
|
1618
1623
|
const initialYear = value?.getFullYear();
|
|
1619
1624
|
const initialMonth = value?.getMonth();
|
|
1620
1625
|
const { year, month, days, goToPrevMonth, goToNextMonth, setYear, setMonth } = useCalendar(
|
|
1621
1626
|
initialYear,
|
|
1622
1627
|
initialMonth
|
|
1623
1628
|
);
|
|
1624
|
-
const [pickerMode, setPickerMode] =
|
|
1625
|
-
const [yearRangeStart, setYearRangeStart] =
|
|
1629
|
+
const [pickerMode, setPickerMode] = React7.useState("days");
|
|
1630
|
+
const [yearRangeStart, setYearRangeStart] = React7.useState(
|
|
1626
1631
|
Math.floor((initialYear ?? (/* @__PURE__ */ new Date()).getFullYear()) / 12) * 12
|
|
1627
1632
|
);
|
|
1628
|
-
const minTime =
|
|
1633
|
+
const minTime = React7.useMemo(
|
|
1629
1634
|
() => minDate ? new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate()).getTime() : -Infinity,
|
|
1630
1635
|
[minDate]
|
|
1631
1636
|
);
|
|
1632
|
-
const maxTime =
|
|
1637
|
+
const maxTime = React7.useMemo(
|
|
1633
1638
|
() => maxDate ? new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate()).getTime() : Infinity,
|
|
1634
1639
|
[maxDate]
|
|
1635
1640
|
);
|
|
1636
|
-
const highlightSet =
|
|
1641
|
+
const highlightSet = React7.useMemo(() => {
|
|
1637
1642
|
const set = /* @__PURE__ */ new Set();
|
|
1638
1643
|
for (const h of highlightDates) {
|
|
1639
1644
|
set.add(`${h.getFullYear()}-${h.getMonth()}-${h.getDate()}`);
|
|
1640
1645
|
}
|
|
1641
1646
|
return set;
|
|
1642
1647
|
}, [highlightDates]);
|
|
1643
|
-
const handleSelect =
|
|
1648
|
+
const handleSelect = React7.useCallback(
|
|
1644
1649
|
(date) => {
|
|
1645
1650
|
onChange?.(date);
|
|
1646
1651
|
},
|
|
@@ -1783,8 +1788,8 @@ var InputDatePicker = (props) => {
|
|
|
1783
1788
|
required,
|
|
1784
1789
|
validations
|
|
1785
1790
|
} = props;
|
|
1786
|
-
const [isOpen, setIsOpen] =
|
|
1787
|
-
const [tempDate, setTempDate] =
|
|
1791
|
+
const [isOpen, setIsOpen] = React8.useState(false);
|
|
1792
|
+
const [tempDate, setTempDate] = React8.useState(value ?? /* @__PURE__ */ new Date());
|
|
1788
1793
|
const handleOpen = () => {
|
|
1789
1794
|
if (disabled) return;
|
|
1790
1795
|
setTempDate(value ?? /* @__PURE__ */ new Date());
|
|
@@ -1836,18 +1841,18 @@ InputDatePicker.displayName = "InputDatePicker";
|
|
|
1836
1841
|
var InputDatePicker_default = InputDatePicker;
|
|
1837
1842
|
|
|
1838
1843
|
// src/components/DatePicker/PopupPicker/index.tsx
|
|
1839
|
-
import
|
|
1844
|
+
import React12 from "react";
|
|
1840
1845
|
|
|
1841
1846
|
// src/components/DatePicker/RangePicker/index.tsx
|
|
1842
|
-
import
|
|
1847
|
+
import React11 from "react";
|
|
1843
1848
|
|
|
1844
1849
|
// src/components/Tab/Tab.tsx
|
|
1845
|
-
import
|
|
1850
|
+
import React10 from "react";
|
|
1846
1851
|
|
|
1847
1852
|
// src/components/Tab/TabItem.tsx
|
|
1848
|
-
import
|
|
1853
|
+
import React9 from "react";
|
|
1849
1854
|
import { jsx as jsx302 } from "react/jsx-runtime";
|
|
1850
|
-
var TabItem =
|
|
1855
|
+
var TabItem = React9.forwardRef((props, ref) => {
|
|
1851
1856
|
const { isActive, title, onClick } = props;
|
|
1852
1857
|
return /* @__PURE__ */ jsx302(
|
|
1853
1858
|
"button",
|
|
@@ -1871,11 +1876,11 @@ import { jsx as jsx303, jsxs as jsxs193 } from "react/jsx-runtime";
|
|
|
1871
1876
|
var Tab = (props) => {
|
|
1872
1877
|
const { activeIndex, onChange, tabs, variant, type, size = "md" } = props;
|
|
1873
1878
|
const shape = variant ?? type ?? "default";
|
|
1874
|
-
const [underlineStyle, setUnderlineStyle] =
|
|
1879
|
+
const [underlineStyle, setUnderlineStyle] = React10.useState({
|
|
1875
1880
|
left: 0,
|
|
1876
1881
|
width: 0
|
|
1877
1882
|
});
|
|
1878
|
-
const itemRefs =
|
|
1883
|
+
const itemRefs = React10.useRef([]);
|
|
1879
1884
|
const handleKeyDown = (e) => {
|
|
1880
1885
|
const last = tabs.length - 1;
|
|
1881
1886
|
let next = null;
|
|
@@ -1891,7 +1896,7 @@ var Tab = (props) => {
|
|
|
1891
1896
|
const handleChangeActiveTab = (tabItem, tabIdx) => {
|
|
1892
1897
|
onChange(tabItem, tabIdx);
|
|
1893
1898
|
};
|
|
1894
|
-
|
|
1899
|
+
React10.useEffect(() => {
|
|
1895
1900
|
const el = itemRefs.current[activeIndex];
|
|
1896
1901
|
if (el) {
|
|
1897
1902
|
setUnderlineStyle({ left: el.offsetLeft, width: el.offsetWidth });
|
|
@@ -1947,8 +1952,8 @@ var RangePicker = (props) => {
|
|
|
1947
1952
|
required,
|
|
1948
1953
|
validations
|
|
1949
1954
|
} = props;
|
|
1950
|
-
const labelId =
|
|
1951
|
-
const [activeTab, setActiveTab] =
|
|
1955
|
+
const labelId = React11.useId();
|
|
1956
|
+
const [activeTab, setActiveTab] = React11.useState("start");
|
|
1952
1957
|
const handleStartChange = (date) => {
|
|
1953
1958
|
if (!date) return;
|
|
1954
1959
|
const newStart = date > endDate ? endDate : date;
|
|
@@ -2042,7 +2047,7 @@ var RangePicker_default = RangePicker;
|
|
|
2042
2047
|
import { jsx as jsx305, jsxs as jsxs195 } from "react/jsx-runtime";
|
|
2043
2048
|
var PopupPicker = (props) => {
|
|
2044
2049
|
const { component, type, locale } = props;
|
|
2045
|
-
const [isOpen, setIsOpen] =
|
|
2050
|
+
const [isOpen, setIsOpen] = React12.useState(false);
|
|
2046
2051
|
const handleClick = () => setIsOpen(true);
|
|
2047
2052
|
const handleClose = () => setIsOpen(false);
|
|
2048
2053
|
const handleSingleChange = (date) => {
|
|
@@ -2051,7 +2056,7 @@ var PopupPicker = (props) => {
|
|
|
2051
2056
|
handleClose();
|
|
2052
2057
|
};
|
|
2053
2058
|
return /* @__PURE__ */ jsxs195("div", { className: "lib-xplat-popup-datepicker", children: [
|
|
2054
|
-
|
|
2059
|
+
React12.cloneElement(component, { onClick: handleClick }),
|
|
2055
2060
|
/* @__PURE__ */ jsx305(Modal_default, { isOpen, onClose: handleClose, children: /* @__PURE__ */ jsxs195("div", { className: clsx_default("lib-xplat-popup-datepicker-card", type === "range" && "range-mode"), children: [
|
|
2056
2061
|
/* @__PURE__ */ jsxs195("div", { className: "popup-datepicker-content", children: [
|
|
2057
2062
|
type === "single" && /* @__PURE__ */ jsx305(
|
|
@@ -35,11 +35,16 @@ __export(Drawer_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(Drawer_exports);
|
|
36
36
|
|
|
37
37
|
// src/components/Drawer/Drawer.tsx
|
|
38
|
-
var
|
|
38
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
39
39
|
var import_react_dom = require("react-dom");
|
|
40
40
|
|
|
41
41
|
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
42
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
43
|
+
|
|
44
|
+
// src/tokens/hooks/useAutoPosition.ts
|
|
42
45
|
var import_react = __toESM(require("react"), 1);
|
|
46
|
+
|
|
47
|
+
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
43
48
|
var FOCUSABLE = [
|
|
44
49
|
"a[href]",
|
|
45
50
|
"button:not([disabled])",
|
|
@@ -53,7 +58,7 @@ var focusableIn = (el) => Array.from(el.querySelectorAll(FOCUSABLE)).filter(
|
|
|
53
58
|
(n) => n.offsetWidth > 0 || n.offsetHeight > 0 || n === document.activeElement
|
|
54
59
|
);
|
|
55
60
|
var useEscapeKey = (enabled, onEscape) => {
|
|
56
|
-
|
|
61
|
+
import_react2.default.useEffect(() => {
|
|
57
62
|
if (!enabled) return;
|
|
58
63
|
const onKey = (e) => {
|
|
59
64
|
if (e.key !== "Escape") return;
|
|
@@ -67,8 +72,8 @@ var useEscapeKey = (enabled, onEscape) => {
|
|
|
67
72
|
};
|
|
68
73
|
var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
69
74
|
const { trap = false, initialFocus } = options;
|
|
70
|
-
const restoreRef =
|
|
71
|
-
|
|
75
|
+
const restoreRef = import_react2.default.useRef(null);
|
|
76
|
+
import_react2.default.useEffect(() => {
|
|
72
77
|
if (!enabled) return;
|
|
73
78
|
restoreRef.current = document.activeElement;
|
|
74
79
|
const raf = requestAnimationFrame(() => {
|
|
@@ -86,7 +91,7 @@ var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
|
86
91
|
if (prev && document.contains(prev)) prev.focus({ preventScroll: true });
|
|
87
92
|
};
|
|
88
93
|
}, [enabled, containerRef, initialFocus]);
|
|
89
|
-
|
|
94
|
+
import_react2.default.useEffect(() => {
|
|
90
95
|
if (!enabled || !trap) return;
|
|
91
96
|
const onKey = (e) => {
|
|
92
97
|
if (e.key !== "Tab") return;
|
|
@@ -134,12 +139,12 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
134
139
|
var ANIMATION_DURATION_MS = 250;
|
|
135
140
|
var Drawer = (props) => {
|
|
136
141
|
const { isOpen, onClose, placement = "right", size = "md", title, children } = props;
|
|
137
|
-
const [mounted, setMounted] =
|
|
138
|
-
const [visible, setVisible] =
|
|
139
|
-
const panelRef =
|
|
142
|
+
const [mounted, setMounted] = import_react3.default.useState(false);
|
|
143
|
+
const [visible, setVisible] = import_react3.default.useState(false);
|
|
144
|
+
const panelRef = import_react3.default.useRef(null);
|
|
140
145
|
useEscapeKey(isOpen, onClose);
|
|
141
146
|
useFocusTrap(panelRef, isOpen && mounted, { trap: true });
|
|
142
|
-
|
|
147
|
+
import_react3.default.useEffect(() => {
|
|
143
148
|
if (isOpen) {
|
|
144
149
|
setMounted(true);
|
|
145
150
|
const t2 = setTimeout(() => setVisible(true), 1);
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
// src/components/Drawer/Drawer.tsx
|
|
2
|
-
import
|
|
2
|
+
import React3 from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
|
|
5
5
|
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
6
|
+
import React2 from "react";
|
|
7
|
+
|
|
8
|
+
// src/tokens/hooks/useAutoPosition.ts
|
|
6
9
|
import React from "react";
|
|
10
|
+
|
|
11
|
+
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
7
12
|
var FOCUSABLE = [
|
|
8
13
|
"a[href]",
|
|
9
14
|
"button:not([disabled])",
|
|
@@ -17,7 +22,7 @@ var focusableIn = (el) => Array.from(el.querySelectorAll(FOCUSABLE)).filter(
|
|
|
17
22
|
(n) => n.offsetWidth > 0 || n.offsetHeight > 0 || n === document.activeElement
|
|
18
23
|
);
|
|
19
24
|
var useEscapeKey = (enabled, onEscape) => {
|
|
20
|
-
|
|
25
|
+
React2.useEffect(() => {
|
|
21
26
|
if (!enabled) return;
|
|
22
27
|
const onKey = (e) => {
|
|
23
28
|
if (e.key !== "Escape") return;
|
|
@@ -31,8 +36,8 @@ var useEscapeKey = (enabled, onEscape) => {
|
|
|
31
36
|
};
|
|
32
37
|
var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
33
38
|
const { trap = false, initialFocus } = options;
|
|
34
|
-
const restoreRef =
|
|
35
|
-
|
|
39
|
+
const restoreRef = React2.useRef(null);
|
|
40
|
+
React2.useEffect(() => {
|
|
36
41
|
if (!enabled) return;
|
|
37
42
|
restoreRef.current = document.activeElement;
|
|
38
43
|
const raf = requestAnimationFrame(() => {
|
|
@@ -50,7 +55,7 @@ var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
|
50
55
|
if (prev && document.contains(prev)) prev.focus({ preventScroll: true });
|
|
51
56
|
};
|
|
52
57
|
}, [enabled, containerRef, initialFocus]);
|
|
53
|
-
|
|
58
|
+
React2.useEffect(() => {
|
|
54
59
|
if (!enabled || !trap) return;
|
|
55
60
|
const onKey = (e) => {
|
|
56
61
|
if (e.key !== "Tab") return;
|
|
@@ -98,12 +103,12 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
98
103
|
var ANIMATION_DURATION_MS = 250;
|
|
99
104
|
var Drawer = (props) => {
|
|
100
105
|
const { isOpen, onClose, placement = "right", size = "md", title, children } = props;
|
|
101
|
-
const [mounted, setMounted] =
|
|
102
|
-
const [visible, setVisible] =
|
|
103
|
-
const panelRef =
|
|
106
|
+
const [mounted, setMounted] = React3.useState(false);
|
|
107
|
+
const [visible, setVisible] = React3.useState(false);
|
|
108
|
+
const panelRef = React3.useRef(null);
|
|
104
109
|
useEscapeKey(isOpen, onClose);
|
|
105
110
|
useFocusTrap(panelRef, isOpen && mounted, { trap: true });
|
|
106
|
-
|
|
111
|
+
React3.useEffect(() => {
|
|
107
112
|
if (isOpen) {
|
|
108
113
|
setMounted(true);
|
|
109
114
|
const t2 = setTimeout(() => setVisible(true), 1);
|