infinity-ui-elements 1.8.8 → 1.8.10
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/DatePicker.d.ts +124 -0
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -0
- package/dist/components/DatePicker/DatePicker.stories.d.ts +26 -0
- package/dist/components/DatePicker/DatePicker.stories.d.ts.map +1 -0
- package/dist/components/DatePicker/index.d.ts +3 -0
- package/dist/components/DatePicker/index.d.ts.map +1 -0
- package/dist/components/SearchableDropdown/SearchableDropdown.stories.d.ts +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +586 -354
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +586 -352
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -8,6 +8,8 @@ var reactSpinners = require('react-spinners');
|
|
|
8
8
|
var clsx = require('clsx');
|
|
9
9
|
var tailwindMerge = require('tailwind-merge');
|
|
10
10
|
var lucideReact = require('lucide-react');
|
|
11
|
+
var Calendar = require('react-calendar');
|
|
12
|
+
require('react-calendar/dist/Calendar.css');
|
|
11
13
|
var reactDom = require('react-dom');
|
|
12
14
|
var reactTable = require('@tanstack/react-table');
|
|
13
15
|
|
|
@@ -1709,374 +1711,113 @@ const Counter = React__namespace.forwardRef(({ value, max, size = "medium", colo
|
|
|
1709
1711
|
});
|
|
1710
1712
|
Counter.displayName = "Counter";
|
|
1711
1713
|
|
|
1712
|
-
const
|
|
1714
|
+
const tooltipVariants = classVarianceAuthority.cva("fixed z-50 bg-popup-fill-intense text-action-ink-on-primary-normal rounded-medium border border-popup-outline-subtle flex flex-col p-4 rounded-xlarge min-w-[200px] max-w-[300px] transition-opacity duration-200", {
|
|
1713
1715
|
variants: {
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
},
|
|
1718
|
-
thickness: {
|
|
1719
|
-
thinner: "",
|
|
1720
|
-
thin: "",
|
|
1721
|
-
thick: "",
|
|
1722
|
-
thicker: "",
|
|
1723
|
-
},
|
|
1724
|
-
lineStyle: {
|
|
1725
|
-
solid: "border-solid",
|
|
1726
|
-
dashed: "border-dashed",
|
|
1727
|
-
},
|
|
1728
|
-
variant: {
|
|
1729
|
-
normal: "",
|
|
1730
|
-
subtle: "",
|
|
1731
|
-
muted: "",
|
|
1716
|
+
isVisible: {
|
|
1717
|
+
true: "opacity-100 pointer-events-auto shadow-[0_4px_20px_rgba(0,0,0,0.15)]",
|
|
1718
|
+
false: "opacity-0 pointer-events-none",
|
|
1732
1719
|
},
|
|
1733
1720
|
},
|
|
1734
|
-
compoundVariants: [
|
|
1735
|
-
// Horizontal orientation with thickness
|
|
1736
|
-
{
|
|
1737
|
-
orientation: "horizontal",
|
|
1738
|
-
thickness: "thinner",
|
|
1739
|
-
class: "border-t-[0.5px]",
|
|
1740
|
-
},
|
|
1741
|
-
{
|
|
1742
|
-
orientation: "horizontal",
|
|
1743
|
-
thickness: "thin",
|
|
1744
|
-
class: "border-t-[1px]",
|
|
1745
|
-
},
|
|
1746
|
-
{
|
|
1747
|
-
orientation: "horizontal",
|
|
1748
|
-
thickness: "thick",
|
|
1749
|
-
class: "border-t-[2px]",
|
|
1750
|
-
},
|
|
1751
|
-
{
|
|
1752
|
-
orientation: "horizontal",
|
|
1753
|
-
thickness: "thicker",
|
|
1754
|
-
class: "border-t-[3px]",
|
|
1755
|
-
},
|
|
1756
|
-
// Vertical orientation with thickness
|
|
1757
|
-
{
|
|
1758
|
-
orientation: "vertical",
|
|
1759
|
-
thickness: "thinner",
|
|
1760
|
-
class: "border-l-[0.5px]",
|
|
1761
|
-
},
|
|
1762
|
-
{
|
|
1763
|
-
orientation: "vertical",
|
|
1764
|
-
thickness: "thin",
|
|
1765
|
-
class: "border-l-[1px]",
|
|
1766
|
-
},
|
|
1767
|
-
{
|
|
1768
|
-
orientation: "vertical",
|
|
1769
|
-
thickness: "thick",
|
|
1770
|
-
class: "border-l-[2px]",
|
|
1771
|
-
},
|
|
1772
|
-
{
|
|
1773
|
-
orientation: "vertical",
|
|
1774
|
-
thickness: "thicker",
|
|
1775
|
-
class: "border-l-[3px]",
|
|
1776
|
-
},
|
|
1777
|
-
// Normal variant colors
|
|
1778
|
-
{
|
|
1779
|
-
variant: "normal",
|
|
1780
|
-
class: "border-surface-outline-neutral-normal",
|
|
1781
|
-
},
|
|
1782
|
-
// Subtle variant colors
|
|
1783
|
-
{
|
|
1784
|
-
variant: "subtle",
|
|
1785
|
-
class: "border-surface-outline-neutral-subtle",
|
|
1786
|
-
},
|
|
1787
|
-
// Muted variant colors
|
|
1788
|
-
{
|
|
1789
|
-
variant: "muted",
|
|
1790
|
-
class: "border-surface-outline-neutral-muted",
|
|
1791
|
-
},
|
|
1792
|
-
],
|
|
1793
1721
|
defaultVariants: {
|
|
1794
|
-
|
|
1795
|
-
thickness: "thin",
|
|
1796
|
-
lineStyle: "solid",
|
|
1797
|
-
variant: "normal",
|
|
1722
|
+
isVisible: false,
|
|
1798
1723
|
},
|
|
1799
1724
|
});
|
|
1800
|
-
const
|
|
1801
|
-
return (jsxRuntime.jsx("div", { ref: ref, role: "separator", "aria-orientation": orientation, className: cn(dividerVariants({ orientation, thickness, lineStyle, variant }), className), ...props }));
|
|
1802
|
-
});
|
|
1803
|
-
Divider.displayName = "Divider";
|
|
1804
|
-
|
|
1805
|
-
const listItemVariants = classVarianceAuthority.cva("flex items-start gap-3 p-3 rounded-medium transition-colors cursor-pointer", {
|
|
1725
|
+
const tooltipArrowVariants = classVarianceAuthority.cva("absolute w-0 h-0 border-solid border-[6px] -translate-x-1/2", {
|
|
1806
1726
|
variants: {
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
bordered: "border border-action-outline-primary-faded hover:bg-surface-fill-primary-subtle",
|
|
1815
|
-
primary: `hover:bg-action-fill-neutral-faded
|
|
1816
|
-
focus:bg-action-fill-neutral-faded
|
|
1817
|
-
focus:ring-2
|
|
1818
|
-
ring-action-outline-primary-faded-hover
|
|
1819
|
-
border border-transparent
|
|
1820
|
-
`,
|
|
1821
|
-
negative: `hover:bg-action-fill-negative-faded
|
|
1822
|
-
focus:bg-action-fill-negative-faded
|
|
1823
|
-
focus:ring-2 ring-action-outline-negative-faded-hover
|
|
1824
|
-
border border-transparent
|
|
1825
|
-
`,
|
|
1826
|
-
},
|
|
1827
|
-
isDisabled: {
|
|
1828
|
-
true: "cursor-not-allowed opacity-60",
|
|
1829
|
-
false: "",
|
|
1830
|
-
},
|
|
1831
|
-
isSelected: {
|
|
1832
|
-
true: "bg-action-fill-primary-faded border-action-outline-primary-faded",
|
|
1833
|
-
false: "",
|
|
1727
|
+
placement: {
|
|
1728
|
+
"top-start": "top-full border-t-popup-fill-intense border-x-transparent border-b-transparent",
|
|
1729
|
+
top: "top-full border-t-popup-fill-intense border-x-transparent border-b-transparent",
|
|
1730
|
+
"top-end": "top-full border-t-popup-fill-intense border-x-transparent border-b-transparent",
|
|
1731
|
+
"bottom-start": "bottom-full border-b-popup-fill-intense border-x-transparent border-t-transparent",
|
|
1732
|
+
bottom: "bottom-full border-b-popup-fill-intense border-x-transparent border-t-transparent",
|
|
1733
|
+
"bottom-end": "bottom-full border-b-popup-fill-intense border-x-transparent border-t-transparent",
|
|
1834
1734
|
},
|
|
1835
1735
|
},
|
|
1836
1736
|
defaultVariants: {
|
|
1837
|
-
|
|
1838
|
-
isDisabled: false,
|
|
1839
|
-
isSelected: false,
|
|
1737
|
+
placement: "top",
|
|
1840
1738
|
},
|
|
1841
1739
|
});
|
|
1842
|
-
const
|
|
1843
|
-
const
|
|
1844
|
-
const [
|
|
1845
|
-
|
|
1846
|
-
React__namespace.
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
const
|
|
1850
|
-
|
|
1740
|
+
const Tooltip = React__namespace.forwardRef(({ children, heading, description, placement = "top", showArrow = true, className, delay = 200, disabled = false, }, ref) => {
|
|
1741
|
+
const [isVisible, setIsVisible] = React__namespace.useState(false);
|
|
1742
|
+
const [position, setPosition] = React__namespace.useState({ top: 0, left: 0 });
|
|
1743
|
+
const [arrowPosition, setArrowPosition] = React__namespace.useState({ left: 0 });
|
|
1744
|
+
const [actualPlacement, setActualPlacement] = React__namespace.useState(placement);
|
|
1745
|
+
const timeoutRef = React__namespace.useRef(null);
|
|
1746
|
+
const triggerRef = React__namespace.useRef(null);
|
|
1747
|
+
const tooltipRef = React__namespace.useRef(null);
|
|
1748
|
+
const calculatePosition = React__namespace.useCallback(() => {
|
|
1749
|
+
if (!triggerRef.current || !tooltipRef.current)
|
|
1851
1750
|
return;
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1751
|
+
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
1752
|
+
const tooltipRect = tooltipRef.current.getBoundingClientRect();
|
|
1753
|
+
const gap = 8; // 8px gap between trigger and tooltip
|
|
1754
|
+
const arrowSize = 6; // Size of the arrow
|
|
1755
|
+
const viewportPadding = 8; // Minimum padding from viewport edges
|
|
1756
|
+
let top = 0;
|
|
1757
|
+
let left = 0;
|
|
1758
|
+
let currentPlacement = placement;
|
|
1759
|
+
// Calculate initial position based on placement
|
|
1760
|
+
switch (placement) {
|
|
1761
|
+
case "top-start":
|
|
1762
|
+
top = triggerRect.top - tooltipRect.height - gap - arrowSize;
|
|
1763
|
+
left = triggerRect.left;
|
|
1764
|
+
break;
|
|
1765
|
+
case "top":
|
|
1766
|
+
top = triggerRect.top - tooltipRect.height - gap - arrowSize;
|
|
1767
|
+
left =
|
|
1768
|
+
triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
|
|
1769
|
+
break;
|
|
1770
|
+
case "top-end":
|
|
1771
|
+
top = triggerRect.top - tooltipRect.height - gap - arrowSize;
|
|
1772
|
+
left = triggerRect.right - tooltipRect.width;
|
|
1773
|
+
break;
|
|
1774
|
+
case "bottom-start":
|
|
1775
|
+
top = triggerRect.bottom + gap + arrowSize;
|
|
1776
|
+
left = triggerRect.left;
|
|
1777
|
+
break;
|
|
1778
|
+
case "bottom":
|
|
1779
|
+
top = triggerRect.bottom + gap + arrowSize;
|
|
1780
|
+
left =
|
|
1781
|
+
triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
|
|
1782
|
+
break;
|
|
1783
|
+
case "bottom-end":
|
|
1784
|
+
top = triggerRect.bottom + gap + arrowSize;
|
|
1785
|
+
left = triggerRect.right - tooltipRect.width;
|
|
1786
|
+
break;
|
|
1856
1787
|
}
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
if (
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
setInternalSelected(newSelected);
|
|
1865
|
-
onSelectionChange?.(newSelected);
|
|
1866
|
-
};
|
|
1867
|
-
return (jsxRuntime.jsxs("div", { ref: ref, className: cn(listItemVariants({
|
|
1868
|
-
variant,
|
|
1869
|
-
isDisabled,
|
|
1870
|
-
isSelected: type === "multiple" ? internalSelected : false,
|
|
1871
|
-
}), containerClassName), onClick: handleClick, role: type === "multiple" ? "checkbox" : "button", "aria-checked": type === "multiple" ? internalSelected : undefined, "aria-disabled": isDisabled, tabIndex: isDisabled ? -1 : 0, ...props, children: [type === "multiple" && (jsxRuntime.jsx(Checkbox, { checked: internalSelected, onChange: handleCheckboxChange, isDisabled: isDisabled, size: checkboxSize, className: "shrink-0 mt-0.5" })), leadingIcon && (jsxRuntime.jsx("div", { className: cn(`shrink-0 flex items-center justify-center mt-0.5`, variant === "primary"
|
|
1872
|
-
? "text-action-ink-primary-normal"
|
|
1873
|
-
: variant === "negative"
|
|
1874
|
-
? "text-action-ink-negative-normal"
|
|
1875
|
-
: "text-action-ink-neutral-subtle", isDisabled && "text-surface-ink-neutral-disabled"), children: leadingIcon })), jsxRuntime.jsxs("div", { className: cn("flex-1 min-w-0 flex flex-col justify-center", contentClassName), children: [jsxRuntime.jsx("div", { className: cn("text-body-medium-regular truncate", variant === "primary"
|
|
1876
|
-
? "text-action-ink-primary-normal"
|
|
1877
|
-
: variant === "negative"
|
|
1878
|
-
? "text-action-ink-negative-normal"
|
|
1879
|
-
: "text-action-ink-neutral-normal", isDisabled && "text-surface-ink-neutral-disabled"), children: title }), description && (jsxRuntime.jsx("div", { className: cn("text-body-small-regular text-surface-ink-neutral-muted mt-0.5 line-clamp-2", isDisabled && "text-surface-ink-neutral-disabled"), children: description }))] }), (trailingIcon || showChevron) && (jsxRuntime.jsx("div", { className: "shrink-0 self-center text-action-ink-neutral-subtle", children: trailingIcon || jsxRuntime.jsx(ChevronRightIcon, {}) }))] }));
|
|
1880
|
-
});
|
|
1881
|
-
ListItem.displayName = "ListItem";
|
|
1882
|
-
|
|
1883
|
-
const DropdownMenu = React__namespace.forwardRef(({ items = [], customContent, sectionHeading, isLoading = false, isEmpty = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText = "Primary", secondaryButtonText = "Secondary", onPrimaryClick, onSecondaryClick, showChevron = false, emptyIcon, disableFooter = false, showFooter, footerLayout = "horizontal", onClose, focusedIndex = -1, className, width = "auto", }, ref) => {
|
|
1884
|
-
const renderContent = () => {
|
|
1885
|
-
if (isLoading) {
|
|
1886
|
-
return (jsxRuntime.jsx("div", { className: "flex flex-col items-center justify-center py-12 px-6", children: jsxRuntime.jsx(lucideReact.Loader2, { className: "w-12 h-12 text-action-ink-primary-normal mb-4 animate-spin" }) }));
|
|
1788
|
+
// Get viewport dimensions
|
|
1789
|
+
const viewportWidth = window.innerWidth;
|
|
1790
|
+
const viewportHeight = window.innerHeight;
|
|
1791
|
+
// Adjust horizontal position to keep tooltip within viewport
|
|
1792
|
+
if (left < viewportPadding) {
|
|
1793
|
+
// Tooltip would overflow on the left
|
|
1794
|
+
left = viewportPadding;
|
|
1887
1795
|
}
|
|
1888
|
-
if (
|
|
1889
|
-
|
|
1796
|
+
else if (left + tooltipRect.width > viewportWidth - viewportPadding) {
|
|
1797
|
+
// Tooltip would overflow on the right
|
|
1798
|
+
left = viewportWidth - tooltipRect.width - viewportPadding;
|
|
1890
1799
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
size: {
|
|
1913
|
-
small: "w-64",
|
|
1914
|
-
medium: "w-80",
|
|
1915
|
-
large: "w-96",
|
|
1916
|
-
},
|
|
1917
|
-
},
|
|
1918
|
-
defaultVariants: {
|
|
1919
|
-
size: "medium",
|
|
1920
|
-
},
|
|
1921
|
-
});
|
|
1922
|
-
const Dropdown = React__namespace.forwardRef(({ className, trigger, items = [], customContent, sectionHeading, isLoading = false, isEmpty = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText = "Primary", secondaryButtonText = "Secondary", onPrimaryClick, onSecondaryClick, size = "medium", open: controlledOpen, defaultOpen = false, onOpenChange, containerClassName, menuClassName, showChevron = false, emptyIcon, disableFooter = false, showFooter, ...props }, ref) => {
|
|
1923
|
-
const [uncontrolledOpen, setUncontrolledOpen] = React__namespace.useState(defaultOpen);
|
|
1924
|
-
const isOpen = controlledOpen !== undefined ? controlledOpen : uncontrolledOpen;
|
|
1925
|
-
const dropdownRef = React__namespace.useRef(null);
|
|
1926
|
-
const handleOpenChange = (newOpen) => {
|
|
1927
|
-
if (controlledOpen === undefined) {
|
|
1928
|
-
setUncontrolledOpen(newOpen);
|
|
1929
|
-
}
|
|
1930
|
-
onOpenChange?.(newOpen);
|
|
1931
|
-
};
|
|
1932
|
-
const toggleOpen = () => {
|
|
1933
|
-
handleOpenChange(!isOpen);
|
|
1934
|
-
};
|
|
1935
|
-
// Close dropdown when clicking outside
|
|
1936
|
-
React__namespace.useEffect(() => {
|
|
1937
|
-
const handleClickOutside = (event) => {
|
|
1938
|
-
if (dropdownRef.current &&
|
|
1939
|
-
!dropdownRef.current.contains(event.target)) {
|
|
1940
|
-
handleOpenChange(false);
|
|
1941
|
-
}
|
|
1942
|
-
};
|
|
1943
|
-
if (isOpen) {
|
|
1944
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
1945
|
-
return () => {
|
|
1946
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
1947
|
-
};
|
|
1948
|
-
}
|
|
1949
|
-
}, [isOpen]);
|
|
1950
|
-
// Close on escape key
|
|
1951
|
-
React__namespace.useEffect(() => {
|
|
1952
|
-
const handleEscape = (event) => {
|
|
1953
|
-
if (event.key === "Escape") {
|
|
1954
|
-
handleOpenChange(false);
|
|
1955
|
-
}
|
|
1956
|
-
};
|
|
1957
|
-
if (isOpen) {
|
|
1958
|
-
document.addEventListener("keydown", handleEscape);
|
|
1959
|
-
return () => {
|
|
1960
|
-
document.removeEventListener("keydown", handleEscape);
|
|
1961
|
-
};
|
|
1962
|
-
}
|
|
1963
|
-
}, [isOpen]);
|
|
1964
|
-
const sizeMap = {
|
|
1965
|
-
small: "w-64",
|
|
1966
|
-
medium: "w-80",
|
|
1967
|
-
large: "w-96",
|
|
1968
|
-
};
|
|
1969
|
-
return (jsxRuntime.jsxs("div", { ref: dropdownRef, className: cn("relative inline-block", containerClassName), ...props, children: [trigger && (jsxRuntime.jsx("div", { onClick: toggleOpen, className: "cursor-pointer", children: trigger })), isOpen && (jsxRuntime.jsx(DropdownMenu, { ref: ref, items: items, customContent: customContent, sectionHeading: sectionHeading, isLoading: isLoading, isEmpty: isEmpty, emptyTitle: emptyTitle, emptyDescription: emptyDescription, emptyLinkText: emptyLinkText, onEmptyLinkClick: onEmptyLinkClick, primaryButtonText: primaryButtonText, secondaryButtonText: secondaryButtonText, onPrimaryClick: onPrimaryClick, onSecondaryClick: onSecondaryClick, showChevron: showChevron, emptyIcon: emptyIcon, disableFooter: disableFooter, showFooter: showFooter, onClose: () => handleOpenChange(false), className: cn("absolute z-50 mt-2", menuClassName, className), width: sizeMap[size] }))] }));
|
|
1970
|
-
});
|
|
1971
|
-
Dropdown.displayName = "Dropdown";
|
|
1972
|
-
|
|
1973
|
-
const tooltipVariants = classVarianceAuthority.cva("fixed z-50 bg-popup-fill-intense text-action-ink-on-primary-normal rounded-medium border border-popup-outline-subtle flex flex-col p-4 rounded-xlarge min-w-[200px] max-w-[300px] transition-opacity duration-200", {
|
|
1974
|
-
variants: {
|
|
1975
|
-
isVisible: {
|
|
1976
|
-
true: "opacity-100 pointer-events-auto shadow-[0_4px_20px_rgba(0,0,0,0.15)]",
|
|
1977
|
-
false: "opacity-0 pointer-events-none",
|
|
1978
|
-
},
|
|
1979
|
-
},
|
|
1980
|
-
defaultVariants: {
|
|
1981
|
-
isVisible: false,
|
|
1982
|
-
},
|
|
1983
|
-
});
|
|
1984
|
-
const tooltipArrowVariants = classVarianceAuthority.cva("absolute w-0 h-0 border-solid border-[6px] -translate-x-1/2", {
|
|
1985
|
-
variants: {
|
|
1986
|
-
placement: {
|
|
1987
|
-
"top-start": "top-full border-t-popup-fill-intense border-x-transparent border-b-transparent",
|
|
1988
|
-
top: "top-full border-t-popup-fill-intense border-x-transparent border-b-transparent",
|
|
1989
|
-
"top-end": "top-full border-t-popup-fill-intense border-x-transparent border-b-transparent",
|
|
1990
|
-
"bottom-start": "bottom-full border-b-popup-fill-intense border-x-transparent border-t-transparent",
|
|
1991
|
-
bottom: "bottom-full border-b-popup-fill-intense border-x-transparent border-t-transparent",
|
|
1992
|
-
"bottom-end": "bottom-full border-b-popup-fill-intense border-x-transparent border-t-transparent",
|
|
1993
|
-
},
|
|
1994
|
-
},
|
|
1995
|
-
defaultVariants: {
|
|
1996
|
-
placement: "top",
|
|
1997
|
-
},
|
|
1998
|
-
});
|
|
1999
|
-
const Tooltip = React__namespace.forwardRef(({ children, heading, description, placement = "top", showArrow = true, className, delay = 200, disabled = false, }, ref) => {
|
|
2000
|
-
const [isVisible, setIsVisible] = React__namespace.useState(false);
|
|
2001
|
-
const [position, setPosition] = React__namespace.useState({ top: 0, left: 0 });
|
|
2002
|
-
const [arrowPosition, setArrowPosition] = React__namespace.useState({ left: 0 });
|
|
2003
|
-
const [actualPlacement, setActualPlacement] = React__namespace.useState(placement);
|
|
2004
|
-
const timeoutRef = React__namespace.useRef(null);
|
|
2005
|
-
const triggerRef = React__namespace.useRef(null);
|
|
2006
|
-
const tooltipRef = React__namespace.useRef(null);
|
|
2007
|
-
const calculatePosition = React__namespace.useCallback(() => {
|
|
2008
|
-
if (!triggerRef.current || !tooltipRef.current)
|
|
2009
|
-
return;
|
|
2010
|
-
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
2011
|
-
const tooltipRect = tooltipRef.current.getBoundingClientRect();
|
|
2012
|
-
const gap = 8; // 8px gap between trigger and tooltip
|
|
2013
|
-
const arrowSize = 6; // Size of the arrow
|
|
2014
|
-
const viewportPadding = 8; // Minimum padding from viewport edges
|
|
2015
|
-
let top = 0;
|
|
2016
|
-
let left = 0;
|
|
2017
|
-
let currentPlacement = placement;
|
|
2018
|
-
// Calculate initial position based on placement
|
|
2019
|
-
switch (placement) {
|
|
2020
|
-
case "top-start":
|
|
2021
|
-
top = triggerRect.top - tooltipRect.height - gap - arrowSize;
|
|
2022
|
-
left = triggerRect.left;
|
|
2023
|
-
break;
|
|
2024
|
-
case "top":
|
|
2025
|
-
top = triggerRect.top - tooltipRect.height - gap - arrowSize;
|
|
2026
|
-
left =
|
|
2027
|
-
triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
|
|
2028
|
-
break;
|
|
2029
|
-
case "top-end":
|
|
2030
|
-
top = triggerRect.top - tooltipRect.height - gap - arrowSize;
|
|
2031
|
-
left = triggerRect.right - tooltipRect.width;
|
|
2032
|
-
break;
|
|
2033
|
-
case "bottom-start":
|
|
2034
|
-
top = triggerRect.bottom + gap + arrowSize;
|
|
2035
|
-
left = triggerRect.left;
|
|
2036
|
-
break;
|
|
2037
|
-
case "bottom":
|
|
2038
|
-
top = triggerRect.bottom + gap + arrowSize;
|
|
2039
|
-
left =
|
|
2040
|
-
triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
|
|
2041
|
-
break;
|
|
2042
|
-
case "bottom-end":
|
|
2043
|
-
top = triggerRect.bottom + gap + arrowSize;
|
|
2044
|
-
left = triggerRect.right - tooltipRect.width;
|
|
2045
|
-
break;
|
|
2046
|
-
}
|
|
2047
|
-
// Get viewport dimensions
|
|
2048
|
-
const viewportWidth = window.innerWidth;
|
|
2049
|
-
const viewportHeight = window.innerHeight;
|
|
2050
|
-
// Adjust horizontal position to keep tooltip within viewport
|
|
2051
|
-
if (left < viewportPadding) {
|
|
2052
|
-
// Tooltip would overflow on the left
|
|
2053
|
-
left = viewportPadding;
|
|
2054
|
-
}
|
|
2055
|
-
else if (left + tooltipRect.width > viewportWidth - viewportPadding) {
|
|
2056
|
-
// Tooltip would overflow on the right
|
|
2057
|
-
left = viewportWidth - tooltipRect.width - viewportPadding;
|
|
2058
|
-
}
|
|
2059
|
-
// Adjust vertical position to keep tooltip within viewport
|
|
2060
|
-
if (top < viewportPadding) {
|
|
2061
|
-
// Tooltip would overflow at the top
|
|
2062
|
-
// Try to flip to bottom if there's more space there
|
|
2063
|
-
const spaceBelow = viewportHeight - triggerRect.bottom;
|
|
2064
|
-
const spaceAbove = triggerRect.top;
|
|
2065
|
-
if (spaceBelow > spaceAbove) {
|
|
2066
|
-
// Flip to bottom
|
|
2067
|
-
top = triggerRect.bottom + gap + arrowSize;
|
|
2068
|
-
// Update placement to reflect the flip
|
|
2069
|
-
if (placement === "top-start")
|
|
2070
|
-
currentPlacement = "bottom-start";
|
|
2071
|
-
else if (placement === "top")
|
|
2072
|
-
currentPlacement = "bottom";
|
|
2073
|
-
else if (placement === "top-end")
|
|
2074
|
-
currentPlacement = "bottom-end";
|
|
2075
|
-
}
|
|
2076
|
-
else {
|
|
2077
|
-
// Keep at top but adjust to stay in viewport
|
|
2078
|
-
top = viewportPadding;
|
|
2079
|
-
}
|
|
1800
|
+
// Adjust vertical position to keep tooltip within viewport
|
|
1801
|
+
if (top < viewportPadding) {
|
|
1802
|
+
// Tooltip would overflow at the top
|
|
1803
|
+
// Try to flip to bottom if there's more space there
|
|
1804
|
+
const spaceBelow = viewportHeight - triggerRect.bottom;
|
|
1805
|
+
const spaceAbove = triggerRect.top;
|
|
1806
|
+
if (spaceBelow > spaceAbove) {
|
|
1807
|
+
// Flip to bottom
|
|
1808
|
+
top = triggerRect.bottom + gap + arrowSize;
|
|
1809
|
+
// Update placement to reflect the flip
|
|
1810
|
+
if (placement === "top-start")
|
|
1811
|
+
currentPlacement = "bottom-start";
|
|
1812
|
+
else if (placement === "top")
|
|
1813
|
+
currentPlacement = "bottom";
|
|
1814
|
+
else if (placement === "top-end")
|
|
1815
|
+
currentPlacement = "bottom-end";
|
|
1816
|
+
}
|
|
1817
|
+
else {
|
|
1818
|
+
// Keep at top but adjust to stay in viewport
|
|
1819
|
+
top = viewportPadding;
|
|
1820
|
+
}
|
|
2080
1821
|
}
|
|
2081
1822
|
else if (top + tooltipRect.height > viewportHeight - viewportPadding) {
|
|
2082
1823
|
// Tooltip would overflow at the bottom
|
|
@@ -2229,6 +1970,497 @@ const FormHeader = React__namespace.forwardRef(({ label, size = "medium", isOpti
|
|
|
2229
1970
|
});
|
|
2230
1971
|
FormHeader.displayName = "FormHeader";
|
|
2231
1972
|
|
|
1973
|
+
const datePickerVariants = classVarianceAuthority.cva("relative flex items-center gap-2 border rounded-large transition-all font-display font-size-100 leading-100", {
|
|
1974
|
+
variants: {
|
|
1975
|
+
size: {
|
|
1976
|
+
small: "h-[28px] px-3 text-xs gap-2",
|
|
1977
|
+
medium: "h-[36px] px-4 text-sm gap-2",
|
|
1978
|
+
large: "h-[44px] px-5 text-base gap-3",
|
|
1979
|
+
},
|
|
1980
|
+
validationState: {
|
|
1981
|
+
none: `
|
|
1982
|
+
border-action-outline-neutral-faded
|
|
1983
|
+
hover:border-action-outline-primary-hover
|
|
1984
|
+
focus-within:border-action-outline-primary-hover
|
|
1985
|
+
focus-within:ring-2
|
|
1986
|
+
ring-action-outline-primary-faded-hover`,
|
|
1987
|
+
positive: `
|
|
1988
|
+
border-action-outline-positive-default
|
|
1989
|
+
focus-within:border-action-outline-positive-hover
|
|
1990
|
+
focus-within:ring-2
|
|
1991
|
+
ring-action-outline-positive-faded-hover`,
|
|
1992
|
+
negative: `border-action-outline-negative-default
|
|
1993
|
+
focus-within:border-action-outline-negative-hover
|
|
1994
|
+
focus-within:ring-2
|
|
1995
|
+
ring-action-outline-negative-faded-hover`,
|
|
1996
|
+
},
|
|
1997
|
+
isDisabled: {
|
|
1998
|
+
true: `
|
|
1999
|
+
border-[var(--border-width-thinner)]
|
|
2000
|
+
hover:border-action-outline-neutral-disabled
|
|
2001
|
+
border-action-outline-neutral-disabled
|
|
2002
|
+
bg-surface-fill-neutral-intense cursor-not-allowed opacity-60`,
|
|
2003
|
+
false: "bg-surface-fill-neutral-intense",
|
|
2004
|
+
},
|
|
2005
|
+
},
|
|
2006
|
+
defaultVariants: {
|
|
2007
|
+
size: "medium",
|
|
2008
|
+
validationState: "none",
|
|
2009
|
+
isDisabled: false,
|
|
2010
|
+
},
|
|
2011
|
+
});
|
|
2012
|
+
// Helper functions
|
|
2013
|
+
const parseDate = (date) => {
|
|
2014
|
+
if (!date)
|
|
2015
|
+
return null;
|
|
2016
|
+
if (date instanceof Date)
|
|
2017
|
+
return date;
|
|
2018
|
+
if (typeof date === "string") {
|
|
2019
|
+
const parsed = new Date(date);
|
|
2020
|
+
return isNaN(parsed.getTime()) ? null : parsed;
|
|
2021
|
+
}
|
|
2022
|
+
return null;
|
|
2023
|
+
};
|
|
2024
|
+
const formatDateDefault = (date) => {
|
|
2025
|
+
return date.toLocaleDateString("en-US", {
|
|
2026
|
+
year: "numeric",
|
|
2027
|
+
month: "short",
|
|
2028
|
+
day: "numeric",
|
|
2029
|
+
});
|
|
2030
|
+
};
|
|
2031
|
+
const DatePicker = React__namespace.forwardRef(({ className, value: controlledValue, defaultValue, onChange, placeholder = "Select a date", label, helperText, errorText, successText, validationState = "none", isDisabled = false, isRequired = false, isOptional = false, size = "medium", showClearButton = false, onClear, containerClassName, labelClassName, triggerClassName, calendarClassName, minDate, maxDate, formatDate = formatDateDefault, infoHeading, infoDescription, LinkComponent, linkText, linkHref, onLinkClick, ...props }, ref) => {
|
|
2032
|
+
const [uncontrolledValue, setUncontrolledValue] = React__namespace.useState(parseDate(defaultValue));
|
|
2033
|
+
const [isOpen, setIsOpen] = React__namespace.useState(false);
|
|
2034
|
+
const datePickerRef = React__namespace.useRef(null);
|
|
2035
|
+
const calendarRef = React__namespace.useRef(null);
|
|
2036
|
+
const [dropdownPlacement, setDropdownPlacement] = React__namespace.useState("bottom");
|
|
2037
|
+
const value = controlledValue !== undefined
|
|
2038
|
+
? parseDate(controlledValue)
|
|
2039
|
+
: uncontrolledValue;
|
|
2040
|
+
const hasValue = value !== null;
|
|
2041
|
+
// Determine which helper text to show
|
|
2042
|
+
const displayHelperText = errorText || successText || helperText;
|
|
2043
|
+
const currentValidationState = errorText
|
|
2044
|
+
? "negative"
|
|
2045
|
+
: successText
|
|
2046
|
+
? "positive"
|
|
2047
|
+
: validationState;
|
|
2048
|
+
const handleOpenChange = (newOpen) => {
|
|
2049
|
+
if (!isDisabled) {
|
|
2050
|
+
setIsOpen(newOpen);
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
const toggleOpen = () => {
|
|
2054
|
+
handleOpenChange(!isOpen);
|
|
2055
|
+
};
|
|
2056
|
+
const handleCalendarChange = (value, event) => {
|
|
2057
|
+
// react-calendar can return Date, Date[], or null
|
|
2058
|
+
// We only support single date selection, so we take the first date if it's an array
|
|
2059
|
+
if (!value) {
|
|
2060
|
+
if (controlledValue === undefined) {
|
|
2061
|
+
setUncontrolledValue(null);
|
|
2062
|
+
}
|
|
2063
|
+
onChange?.(null);
|
|
2064
|
+
setIsOpen(false);
|
|
2065
|
+
return;
|
|
2066
|
+
}
|
|
2067
|
+
const selectedDate = Array.isArray(value) ? value[0] : value;
|
|
2068
|
+
// Ensure we have a valid Date object
|
|
2069
|
+
if (selectedDate instanceof Date) {
|
|
2070
|
+
if (controlledValue === undefined) {
|
|
2071
|
+
setUncontrolledValue(selectedDate);
|
|
2072
|
+
}
|
|
2073
|
+
onChange?.(selectedDate);
|
|
2074
|
+
setIsOpen(false);
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
const handleClear = (e) => {
|
|
2078
|
+
e.stopPropagation();
|
|
2079
|
+
if (onClear) {
|
|
2080
|
+
onClear();
|
|
2081
|
+
}
|
|
2082
|
+
else {
|
|
2083
|
+
if (controlledValue === undefined) {
|
|
2084
|
+
setUncontrolledValue(null);
|
|
2085
|
+
}
|
|
2086
|
+
onChange?.(null);
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2089
|
+
const updateDropdownPlacement = React__namespace.useCallback(() => {
|
|
2090
|
+
if (typeof window === "undefined")
|
|
2091
|
+
return;
|
|
2092
|
+
const trigger = datePickerRef.current;
|
|
2093
|
+
if (!trigger)
|
|
2094
|
+
return;
|
|
2095
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
2096
|
+
const spaceBelow = window.innerHeight - triggerRect.bottom;
|
|
2097
|
+
const spaceAbove = triggerRect.top;
|
|
2098
|
+
const calendarHeight = calendarRef.current
|
|
2099
|
+
? calendarRef.current.offsetHeight
|
|
2100
|
+
: 0;
|
|
2101
|
+
if (calendarHeight === 0) {
|
|
2102
|
+
setDropdownPlacement(spaceBelow >= spaceAbove ? "bottom" : "top");
|
|
2103
|
+
return;
|
|
2104
|
+
}
|
|
2105
|
+
if (spaceBelow >= calendarHeight || spaceBelow >= spaceAbove) {
|
|
2106
|
+
setDropdownPlacement("bottom");
|
|
2107
|
+
}
|
|
2108
|
+
else {
|
|
2109
|
+
setDropdownPlacement("top");
|
|
2110
|
+
}
|
|
2111
|
+
}, []);
|
|
2112
|
+
React__namespace.useEffect(() => {
|
|
2113
|
+
if (!isOpen)
|
|
2114
|
+
return;
|
|
2115
|
+
if (typeof window === "undefined")
|
|
2116
|
+
return;
|
|
2117
|
+
let rafId = requestAnimationFrame(updateDropdownPlacement);
|
|
2118
|
+
const handleUpdate = () => updateDropdownPlacement();
|
|
2119
|
+
window.addEventListener("resize", handleUpdate);
|
|
2120
|
+
window.addEventListener("scroll", handleUpdate, true);
|
|
2121
|
+
return () => {
|
|
2122
|
+
cancelAnimationFrame(rafId);
|
|
2123
|
+
window.removeEventListener("resize", handleUpdate);
|
|
2124
|
+
window.removeEventListener("scroll", handleUpdate, true);
|
|
2125
|
+
};
|
|
2126
|
+
}, [isOpen, updateDropdownPlacement]);
|
|
2127
|
+
React__namespace.useEffect(() => {
|
|
2128
|
+
if (isOpen) {
|
|
2129
|
+
updateDropdownPlacement();
|
|
2130
|
+
}
|
|
2131
|
+
}, [isOpen, updateDropdownPlacement]);
|
|
2132
|
+
// Close calendar when clicking outside
|
|
2133
|
+
React__namespace.useEffect(() => {
|
|
2134
|
+
const handleClickOutside = (event) => {
|
|
2135
|
+
if (datePickerRef.current &&
|
|
2136
|
+
!datePickerRef.current.contains(event.target)) {
|
|
2137
|
+
handleOpenChange(false);
|
|
2138
|
+
}
|
|
2139
|
+
};
|
|
2140
|
+
if (isOpen) {
|
|
2141
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
2142
|
+
return () => {
|
|
2143
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2146
|
+
}, [isOpen]);
|
|
2147
|
+
// Close on escape key
|
|
2148
|
+
React__namespace.useEffect(() => {
|
|
2149
|
+
const handleEscape = (event) => {
|
|
2150
|
+
if (event.key === "Escape") {
|
|
2151
|
+
handleOpenChange(false);
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
if (isOpen) {
|
|
2155
|
+
document.addEventListener("keydown", handleEscape);
|
|
2156
|
+
return () => {
|
|
2157
|
+
document.removeEventListener("keydown", handleEscape);
|
|
2158
|
+
};
|
|
2159
|
+
}
|
|
2160
|
+
}, [isOpen]);
|
|
2161
|
+
const minDateParsed = parseDate(minDate);
|
|
2162
|
+
const maxDateParsed = parseDate(maxDate);
|
|
2163
|
+
const sizeConfig = {
|
|
2164
|
+
small: {
|
|
2165
|
+
gap: "gap-2",
|
|
2166
|
+
},
|
|
2167
|
+
medium: {
|
|
2168
|
+
gap: "gap-2",
|
|
2169
|
+
},
|
|
2170
|
+
large: {
|
|
2171
|
+
gap: "gap-3",
|
|
2172
|
+
},
|
|
2173
|
+
};
|
|
2174
|
+
return (jsxRuntime.jsxs("div", { className: cn("w-full flex flex-col", sizeConfig[size].gap, containerClassName), children: [label && (jsxRuntime.jsx(FormHeader, { label: label, size: size, isRequired: isRequired, isOptional: isOptional, infoHeading: infoHeading, infoDescription: infoDescription, LinkComponent: LinkComponent, linkText: linkText, linkHref: linkHref, onLinkClick: onLinkClick, htmlFor: props.id, className: "mb-2", labelClassName: labelClassName })), jsxRuntime.jsxs("div", { ref: datePickerRef, className: cn(datePickerVariants({
|
|
2175
|
+
size,
|
|
2176
|
+
validationState: currentValidationState,
|
|
2177
|
+
isDisabled,
|
|
2178
|
+
}), "relative w-full cursor-pointer", className), onClick: !isDisabled ? toggleOpen : undefined, role: "button", "aria-haspopup": "dialog", "aria-expanded": isOpen, "aria-disabled": isDisabled, ...props, children: [jsxRuntime.jsx(lucideReact.Calendar, { className: cn("shrink-0 w-4 h-4", isDisabled
|
|
2179
|
+
? "text-surface-ink-neutral-disabled"
|
|
2180
|
+
: currentValidationState === "positive"
|
|
2181
|
+
? "text-feedback-ink-positive-intense"
|
|
2182
|
+
: currentValidationState === "negative"
|
|
2183
|
+
? "text-feedback-ink-negative-subtle"
|
|
2184
|
+
: "text-surface-ink-neutral-muted") }), jsxRuntime.jsx("span", { className: cn("flex-1 text-left truncate", !hasValue && "text-surface-ink-neutral-muted", isDisabled && "text-surface-ink-neutral-disabled"), children: hasValue && value ? formatDate(value) : placeholder }), showClearButton && hasValue && !isDisabled && (jsxRuntime.jsx("button", { type: "button", onClick: handleClear, className: "shrink-0 flex items-center justify-center text-surface-ink-neutral-muted hover:text-surface-ink-neutral-normal transition-colors", tabIndex: -1, children: jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntime.jsx("path", { d: "M12 4L4 12M4 4L12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) })), isOpen && !isDisabled && (jsxRuntime.jsx("div", { ref: calendarRef, className: cn("absolute z-50 left-0 bg-surface-fill-neutral-intense rounded-large shadow-lg p-4", dropdownPlacement === "bottom"
|
|
2185
|
+
? "top-full mt-1"
|
|
2186
|
+
: "bottom-full mb-1", calendarClassName), onClick: (e) => e.stopPropagation(), children: jsxRuntime.jsx("div", { className: "react-calendar-wrapper w-fit", children: jsxRuntime.jsx(Calendar, { onChange: handleCalendarChange, value: value ?? null, minDate: minDateParsed ?? undefined, maxDate: maxDateParsed ?? undefined, locale: "en-US", formatShortWeekday: (locale, date) => {
|
|
2187
|
+
const weekdayNames = [
|
|
2188
|
+
"Su",
|
|
2189
|
+
"Mo",
|
|
2190
|
+
"Tu",
|
|
2191
|
+
"We",
|
|
2192
|
+
"Th",
|
|
2193
|
+
"Fr",
|
|
2194
|
+
"Sa",
|
|
2195
|
+
];
|
|
2196
|
+
return weekdayNames[date.getDay()];
|
|
2197
|
+
} }) }) }))] }), jsxRuntime.jsx(FormFooter, { helperText: displayHelperText, validationState: currentValidationState === "none"
|
|
2198
|
+
? "default"
|
|
2199
|
+
: currentValidationState, size: size, isDisabled: isDisabled, className: "mt-1" })] }));
|
|
2200
|
+
});
|
|
2201
|
+
DatePicker.displayName = "DatePicker";
|
|
2202
|
+
|
|
2203
|
+
const dividerVariants = classVarianceAuthority.cva("", {
|
|
2204
|
+
variants: {
|
|
2205
|
+
orientation: {
|
|
2206
|
+
horizontal: "w-full",
|
|
2207
|
+
vertical: "h-full",
|
|
2208
|
+
},
|
|
2209
|
+
thickness: {
|
|
2210
|
+
thinner: "",
|
|
2211
|
+
thin: "",
|
|
2212
|
+
thick: "",
|
|
2213
|
+
thicker: "",
|
|
2214
|
+
},
|
|
2215
|
+
lineStyle: {
|
|
2216
|
+
solid: "border-solid",
|
|
2217
|
+
dashed: "border-dashed",
|
|
2218
|
+
},
|
|
2219
|
+
variant: {
|
|
2220
|
+
normal: "",
|
|
2221
|
+
subtle: "",
|
|
2222
|
+
muted: "",
|
|
2223
|
+
},
|
|
2224
|
+
},
|
|
2225
|
+
compoundVariants: [
|
|
2226
|
+
// Horizontal orientation with thickness
|
|
2227
|
+
{
|
|
2228
|
+
orientation: "horizontal",
|
|
2229
|
+
thickness: "thinner",
|
|
2230
|
+
class: "border-t-[0.5px]",
|
|
2231
|
+
},
|
|
2232
|
+
{
|
|
2233
|
+
orientation: "horizontal",
|
|
2234
|
+
thickness: "thin",
|
|
2235
|
+
class: "border-t-[1px]",
|
|
2236
|
+
},
|
|
2237
|
+
{
|
|
2238
|
+
orientation: "horizontal",
|
|
2239
|
+
thickness: "thick",
|
|
2240
|
+
class: "border-t-[2px]",
|
|
2241
|
+
},
|
|
2242
|
+
{
|
|
2243
|
+
orientation: "horizontal",
|
|
2244
|
+
thickness: "thicker",
|
|
2245
|
+
class: "border-t-[3px]",
|
|
2246
|
+
},
|
|
2247
|
+
// Vertical orientation with thickness
|
|
2248
|
+
{
|
|
2249
|
+
orientation: "vertical",
|
|
2250
|
+
thickness: "thinner",
|
|
2251
|
+
class: "border-l-[0.5px]",
|
|
2252
|
+
},
|
|
2253
|
+
{
|
|
2254
|
+
orientation: "vertical",
|
|
2255
|
+
thickness: "thin",
|
|
2256
|
+
class: "border-l-[1px]",
|
|
2257
|
+
},
|
|
2258
|
+
{
|
|
2259
|
+
orientation: "vertical",
|
|
2260
|
+
thickness: "thick",
|
|
2261
|
+
class: "border-l-[2px]",
|
|
2262
|
+
},
|
|
2263
|
+
{
|
|
2264
|
+
orientation: "vertical",
|
|
2265
|
+
thickness: "thicker",
|
|
2266
|
+
class: "border-l-[3px]",
|
|
2267
|
+
},
|
|
2268
|
+
// Normal variant colors
|
|
2269
|
+
{
|
|
2270
|
+
variant: "normal",
|
|
2271
|
+
class: "border-surface-outline-neutral-normal",
|
|
2272
|
+
},
|
|
2273
|
+
// Subtle variant colors
|
|
2274
|
+
{
|
|
2275
|
+
variant: "subtle",
|
|
2276
|
+
class: "border-surface-outline-neutral-subtle",
|
|
2277
|
+
},
|
|
2278
|
+
// Muted variant colors
|
|
2279
|
+
{
|
|
2280
|
+
variant: "muted",
|
|
2281
|
+
class: "border-surface-outline-neutral-muted",
|
|
2282
|
+
},
|
|
2283
|
+
],
|
|
2284
|
+
defaultVariants: {
|
|
2285
|
+
orientation: "horizontal",
|
|
2286
|
+
thickness: "thin",
|
|
2287
|
+
lineStyle: "solid",
|
|
2288
|
+
variant: "normal",
|
|
2289
|
+
},
|
|
2290
|
+
});
|
|
2291
|
+
const Divider = React__namespace.forwardRef(({ className, orientation = "horizontal", thickness = "thin", lineStyle = "solid", variant = "normal", ...props }, ref) => {
|
|
2292
|
+
return (jsxRuntime.jsx("div", { ref: ref, role: "separator", "aria-orientation": orientation, className: cn(dividerVariants({ orientation, thickness, lineStyle, variant }), className), ...props }));
|
|
2293
|
+
});
|
|
2294
|
+
Divider.displayName = "Divider";
|
|
2295
|
+
|
|
2296
|
+
const listItemVariants = classVarianceAuthority.cva("flex items-start gap-3 p-3 rounded-medium transition-colors cursor-pointer", {
|
|
2297
|
+
variants: {
|
|
2298
|
+
variant: {
|
|
2299
|
+
default: `hover:bg-action-fill-neutral-faded
|
|
2300
|
+
focus:bg-action-fill-neutral-faded
|
|
2301
|
+
focus:ring-2
|
|
2302
|
+
ring-action-outline-primary-faded-hover
|
|
2303
|
+
border border-transparent
|
|
2304
|
+
`,
|
|
2305
|
+
bordered: "border border-action-outline-primary-faded hover:bg-surface-fill-primary-subtle",
|
|
2306
|
+
primary: `hover:bg-action-fill-neutral-faded
|
|
2307
|
+
focus:bg-action-fill-neutral-faded
|
|
2308
|
+
focus:ring-2
|
|
2309
|
+
ring-action-outline-primary-faded-hover
|
|
2310
|
+
border border-transparent
|
|
2311
|
+
`,
|
|
2312
|
+
negative: `hover:bg-action-fill-negative-faded
|
|
2313
|
+
focus:bg-action-fill-negative-faded
|
|
2314
|
+
focus:ring-2 ring-action-outline-negative-faded-hover
|
|
2315
|
+
border border-transparent
|
|
2316
|
+
`,
|
|
2317
|
+
},
|
|
2318
|
+
isDisabled: {
|
|
2319
|
+
true: "cursor-not-allowed opacity-60",
|
|
2320
|
+
false: "",
|
|
2321
|
+
},
|
|
2322
|
+
isSelected: {
|
|
2323
|
+
true: "bg-action-fill-primary-faded border-action-outline-primary-faded",
|
|
2324
|
+
false: "",
|
|
2325
|
+
},
|
|
2326
|
+
},
|
|
2327
|
+
defaultVariants: {
|
|
2328
|
+
variant: "default",
|
|
2329
|
+
isDisabled: false,
|
|
2330
|
+
isSelected: false,
|
|
2331
|
+
},
|
|
2332
|
+
});
|
|
2333
|
+
const ChevronRightIcon = ({ className }) => (jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, children: jsxRuntime.jsx("path", { d: "M7.5 15L12.5 10L7.5 5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
2334
|
+
const ListItem = React__namespace.forwardRef(({ className, type = "single", leadingIcon, title, description, trailingIcon, showChevron = true, variant = "default", isDisabled = false, isSelected = false, onSelectionChange, checkboxSize = "small", containerClassName, contentClassName, onClick, ...props }, ref) => {
|
|
2335
|
+
const [internalSelected, setInternalSelected] = React__namespace.useState(isSelected);
|
|
2336
|
+
// Sync internal state with prop
|
|
2337
|
+
React__namespace.useEffect(() => {
|
|
2338
|
+
setInternalSelected(isSelected);
|
|
2339
|
+
}, [isSelected]);
|
|
2340
|
+
const handleClick = (e) => {
|
|
2341
|
+
if (isDisabled)
|
|
2342
|
+
return;
|
|
2343
|
+
if (type === "multiple") {
|
|
2344
|
+
const newSelected = !internalSelected;
|
|
2345
|
+
setInternalSelected(newSelected);
|
|
2346
|
+
onSelectionChange?.(newSelected);
|
|
2347
|
+
}
|
|
2348
|
+
onClick?.(e);
|
|
2349
|
+
};
|
|
2350
|
+
const handleCheckboxChange = (e) => {
|
|
2351
|
+
e.stopPropagation();
|
|
2352
|
+
if (isDisabled)
|
|
2353
|
+
return;
|
|
2354
|
+
const newSelected = e.target.checked;
|
|
2355
|
+
setInternalSelected(newSelected);
|
|
2356
|
+
onSelectionChange?.(newSelected);
|
|
2357
|
+
};
|
|
2358
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: cn(listItemVariants({
|
|
2359
|
+
variant,
|
|
2360
|
+
isDisabled,
|
|
2361
|
+
isSelected: type === "multiple" ? internalSelected : false,
|
|
2362
|
+
}), containerClassName), onClick: handleClick, role: type === "multiple" ? "checkbox" : "button", "aria-checked": type === "multiple" ? internalSelected : undefined, "aria-disabled": isDisabled, tabIndex: isDisabled ? -1 : 0, ...props, children: [type === "multiple" && (jsxRuntime.jsx(Checkbox, { checked: internalSelected, onChange: handleCheckboxChange, isDisabled: isDisabled, size: checkboxSize, className: "shrink-0 mt-0.5" })), leadingIcon && (jsxRuntime.jsx("div", { className: cn(`shrink-0 flex items-center justify-center mt-0.5`, variant === "primary"
|
|
2363
|
+
? "text-action-ink-primary-normal"
|
|
2364
|
+
: variant === "negative"
|
|
2365
|
+
? "text-action-ink-negative-normal"
|
|
2366
|
+
: "text-action-ink-neutral-subtle", isDisabled && "text-surface-ink-neutral-disabled"), children: leadingIcon })), jsxRuntime.jsxs("div", { className: cn("flex-1 min-w-0 flex flex-col justify-center", contentClassName), children: [jsxRuntime.jsx("div", { className: cn("text-body-medium-regular truncate", variant === "primary"
|
|
2367
|
+
? "text-action-ink-primary-normal"
|
|
2368
|
+
: variant === "negative"
|
|
2369
|
+
? "text-action-ink-negative-normal"
|
|
2370
|
+
: "text-action-ink-neutral-normal", isDisabled && "text-surface-ink-neutral-disabled"), children: title }), description && (jsxRuntime.jsx("div", { className: cn("text-body-small-regular text-surface-ink-neutral-muted mt-0.5 line-clamp-2", isDisabled && "text-surface-ink-neutral-disabled"), children: description }))] }), (trailingIcon || showChevron) && (jsxRuntime.jsx("div", { className: "shrink-0 self-center text-action-ink-neutral-subtle", children: trailingIcon || jsxRuntime.jsx(ChevronRightIcon, {}) }))] }));
|
|
2371
|
+
});
|
|
2372
|
+
ListItem.displayName = "ListItem";
|
|
2373
|
+
|
|
2374
|
+
const DropdownMenu = React__namespace.forwardRef(({ items = [], customContent, sectionHeading, isLoading = false, isEmpty = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText = "Primary", secondaryButtonText = "Secondary", onPrimaryClick, onSecondaryClick, showChevron = false, emptyIcon, disableFooter = false, showFooter, footerLayout = "horizontal", onClose, focusedIndex = -1, className, width = "auto", }, ref) => {
|
|
2375
|
+
const renderContent = () => {
|
|
2376
|
+
if (isLoading) {
|
|
2377
|
+
return (jsxRuntime.jsx("div", { className: "flex flex-col items-center justify-center py-12 px-6", children: jsxRuntime.jsx(lucideReact.Loader2, { className: "w-12 h-12 text-action-ink-primary-normal mb-4 animate-spin" }) }));
|
|
2378
|
+
}
|
|
2379
|
+
if (customContent) {
|
|
2380
|
+
return (jsxRuntime.jsxs("div", { className: "py-3 px-3 max-h-[400px] overflow-y-auto", children: [sectionHeading && (jsxRuntime.jsx(Text, { as: "div", variant: "body", size: "small", weight: "medium", className: "text-body-small-medium text-surface-ink-neutral-muted px-3 py-2 mb-1", children: sectionHeading })), jsxRuntime.jsx("div", { className: "px-1", children: customContent })] }));
|
|
2381
|
+
}
|
|
2382
|
+
if (isEmpty || items.length === 0) {
|
|
2383
|
+
return (jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center py-8 px-6 text-center", children: [emptyIcon || (jsxRuntime.jsx(lucideReact.Search, { className: "w-12 h-12 text-surface-ink-neutral-muted mb-4" })), jsxRuntime.jsx(Text, { as: "h3", variant: "body", size: "small", weight: "semibold", className: "text-surface-ink-neutral-normal mb-2", children: emptyTitle }), jsxRuntime.jsx(Text, { as: "p", variant: "body", size: "small", weight: "regular", className: "text-surface-ink-neutral-muted mb-3", children: emptyDescription }), emptyLinkText && (jsxRuntime.jsx(Link, { type: "anchor", color: "primary", size: "small", onClick: onEmptyLinkClick, children: emptyLinkText }))] }));
|
|
2384
|
+
}
|
|
2385
|
+
return (jsxRuntime.jsxs("div", { className: "py-3 px-3 max-h-[400px] overflow-y-auto", children: [sectionHeading && (jsxRuntime.jsx(Text, { as: "div", variant: "body", size: "small", weight: "medium", className: "text-surface-ink-neutral-muted px-3 py-2 mb-1", children: sectionHeading })), jsxRuntime.jsx("div", { className: "flex flex-col gap-1", children: items.map((item, index) => (jsxRuntime.jsx(ListItem, { title: item.label, description: item.description, leadingIcon: item.leadingIcon, trailingIcon: item.trailingIcon, showChevron: showChevron, isDisabled: item.isDisabled, isSelected: index === focusedIndex, variant: item.variant, onClick: () => {
|
|
2386
|
+
item.onClick?.();
|
|
2387
|
+
onClose?.();
|
|
2388
|
+
}, containerClassName: cn(index === focusedIndex && "bg-action-fill-primary-faded") }, item.value))) })] }));
|
|
2389
|
+
};
|
|
2390
|
+
const widthClass = width === "full" ? "w-full" : width === "auto" ? "w-auto" : "";
|
|
2391
|
+
const footerVisible = showFooter ?? !disableFooter;
|
|
2392
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: cn("bg-white rounded-large overflow-hidden", widthClass, className), style: {
|
|
2393
|
+
boxShadow: "0 1px 2px rgba(25, 25, 30, 0.1), 0 2px 6px rgba(25, 25, 30, 0.06)",
|
|
2394
|
+
...(width !== "full" && width !== "auto" ? { width } : {}),
|
|
2395
|
+
}, children: [renderContent(), footerVisible && (jsxRuntime.jsxs("div", { className: "flex flex-col", children: [jsxRuntime.jsx(Divider, { thickness: "thin", variant: "muted" }), jsxRuntime.jsxs("div", { className: cn("flex gap-3 p-4", footerLayout === "vertical"
|
|
2396
|
+
? "flex-col"
|
|
2397
|
+
: "items-center flex-row"), children: [jsxRuntime.jsx(Button, { variant: "secondary", color: "primary", size: "medium", isFullWidth: true, onClick: onSecondaryClick, children: secondaryButtonText }), jsxRuntime.jsx(Button, { variant: "primary", color: "primary", size: "medium", isFullWidth: true, onClick: onPrimaryClick, children: primaryButtonText })] })] }))] }));
|
|
2398
|
+
});
|
|
2399
|
+
DropdownMenu.displayName = "DropdownMenu";
|
|
2400
|
+
|
|
2401
|
+
const dropdownVariants = classVarianceAuthority.cva("bg-surface-fill-primary-normal border border-surface-outline-neutral-subtle rounded-large", {
|
|
2402
|
+
variants: {
|
|
2403
|
+
size: {
|
|
2404
|
+
small: "w-64",
|
|
2405
|
+
medium: "w-80",
|
|
2406
|
+
large: "w-96",
|
|
2407
|
+
},
|
|
2408
|
+
},
|
|
2409
|
+
defaultVariants: {
|
|
2410
|
+
size: "medium",
|
|
2411
|
+
},
|
|
2412
|
+
});
|
|
2413
|
+
const Dropdown = React__namespace.forwardRef(({ className, trigger, items = [], customContent, sectionHeading, isLoading = false, isEmpty = false, emptyTitle = "No Search Results Found", emptyDescription = "Add description of what the user can search for here.", emptyLinkText = "Link to support site", onEmptyLinkClick, primaryButtonText = "Primary", secondaryButtonText = "Secondary", onPrimaryClick, onSecondaryClick, size = "medium", open: controlledOpen, defaultOpen = false, onOpenChange, containerClassName, menuClassName, showChevron = false, emptyIcon, disableFooter = false, showFooter, ...props }, ref) => {
|
|
2414
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React__namespace.useState(defaultOpen);
|
|
2415
|
+
const isOpen = controlledOpen !== undefined ? controlledOpen : uncontrolledOpen;
|
|
2416
|
+
const dropdownRef = React__namespace.useRef(null);
|
|
2417
|
+
const handleOpenChange = (newOpen) => {
|
|
2418
|
+
if (controlledOpen === undefined) {
|
|
2419
|
+
setUncontrolledOpen(newOpen);
|
|
2420
|
+
}
|
|
2421
|
+
onOpenChange?.(newOpen);
|
|
2422
|
+
};
|
|
2423
|
+
const toggleOpen = () => {
|
|
2424
|
+
handleOpenChange(!isOpen);
|
|
2425
|
+
};
|
|
2426
|
+
// Close dropdown when clicking outside
|
|
2427
|
+
React__namespace.useEffect(() => {
|
|
2428
|
+
const handleClickOutside = (event) => {
|
|
2429
|
+
if (dropdownRef.current &&
|
|
2430
|
+
!dropdownRef.current.contains(event.target)) {
|
|
2431
|
+
handleOpenChange(false);
|
|
2432
|
+
}
|
|
2433
|
+
};
|
|
2434
|
+
if (isOpen) {
|
|
2435
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
2436
|
+
return () => {
|
|
2437
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
2438
|
+
};
|
|
2439
|
+
}
|
|
2440
|
+
}, [isOpen]);
|
|
2441
|
+
// Close on escape key
|
|
2442
|
+
React__namespace.useEffect(() => {
|
|
2443
|
+
const handleEscape = (event) => {
|
|
2444
|
+
if (event.key === "Escape") {
|
|
2445
|
+
handleOpenChange(false);
|
|
2446
|
+
}
|
|
2447
|
+
};
|
|
2448
|
+
if (isOpen) {
|
|
2449
|
+
document.addEventListener("keydown", handleEscape);
|
|
2450
|
+
return () => {
|
|
2451
|
+
document.removeEventListener("keydown", handleEscape);
|
|
2452
|
+
};
|
|
2453
|
+
}
|
|
2454
|
+
}, [isOpen]);
|
|
2455
|
+
const sizeMap = {
|
|
2456
|
+
small: "w-64",
|
|
2457
|
+
medium: "w-80",
|
|
2458
|
+
large: "w-96",
|
|
2459
|
+
};
|
|
2460
|
+
return (jsxRuntime.jsxs("div", { ref: dropdownRef, className: cn("relative inline-block", containerClassName), ...props, children: [trigger && (jsxRuntime.jsx("div", { onClick: toggleOpen, className: "cursor-pointer", children: trigger })), isOpen && (jsxRuntime.jsx(DropdownMenu, { ref: ref, items: items, customContent: customContent, sectionHeading: sectionHeading, isLoading: isLoading, isEmpty: isEmpty, emptyTitle: emptyTitle, emptyDescription: emptyDescription, emptyLinkText: emptyLinkText, onEmptyLinkClick: onEmptyLinkClick, primaryButtonText: primaryButtonText, secondaryButtonText: secondaryButtonText, onPrimaryClick: onPrimaryClick, onSecondaryClick: onSecondaryClick, showChevron: showChevron, emptyIcon: emptyIcon, disableFooter: disableFooter, showFooter: showFooter, onClose: () => handleOpenChange(false), className: cn("absolute z-50 mt-2", menuClassName, className), width: sizeMap[size] }))] }));
|
|
2461
|
+
});
|
|
2462
|
+
Dropdown.displayName = "Dropdown";
|
|
2463
|
+
|
|
2232
2464
|
const Modal = React__namespace.forwardRef(({ isOpen, onClose, title, description, footer, children, size = "medium", showCloseButton = true, closeOnOverlayClick = true, closeOnEscape = true, className, contentClassName, headerClassName, bodyClassName, footerClassName, overlayClassName, ariaLabel, ariaDescribedBy, }, ref) => {
|
|
2233
2465
|
const modalRef = React__namespace.useRef(null);
|
|
2234
2466
|
const contentRef = ref || modalRef;
|
|
@@ -3742,6 +3974,7 @@ exports.Button = Button;
|
|
|
3742
3974
|
exports.ButtonGroup = ButtonGroup;
|
|
3743
3975
|
exports.Checkbox = Checkbox;
|
|
3744
3976
|
exports.Counter = Counter;
|
|
3977
|
+
exports.DatePicker = DatePicker;
|
|
3745
3978
|
exports.Divider = Divider;
|
|
3746
3979
|
exports.Dropdown = Dropdown;
|
|
3747
3980
|
exports.DropdownMenu = DropdownMenu;
|
|
@@ -3778,6 +4011,7 @@ exports.buttonVariants = buttonVariants;
|
|
|
3778
4011
|
exports.checkboxVariants = checkboxVariants;
|
|
3779
4012
|
exports.cn = cn;
|
|
3780
4013
|
exports.counterVariants = counterVariants;
|
|
4014
|
+
exports.datePickerVariants = datePickerVariants;
|
|
3781
4015
|
exports.dropdownVariants = dropdownVariants;
|
|
3782
4016
|
exports.getAvailableIcons = getAvailableIcons;
|
|
3783
4017
|
exports.hasIcon = hasIcon;
|