@trackunit/react-components 0.1.389 → 0.1.391
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/index.cjs.js +311 -64
- package/index.esm.js +312 -65
- package/package.json +3 -2
- package/src/components/Drawer/Drawer.d.ts +17 -13
- package/src/components/Drawer/Drawer.variants.d.ts +17 -3
- package/src/components/Drawer/Overlay.d.ts +14 -0
- package/src/components/Drawer/ToogleButton.d.ts +19 -0
- package/src/components/Drawer/index.d.ts +1 -0
- package/src/components/index.d.ts +2 -2
package/index.cjs.js
CHANGED
|
@@ -15,6 +15,7 @@ var reactSlot = require('@radix-ui/react-slot');
|
|
|
15
15
|
var isEqual = require('lodash/isEqual');
|
|
16
16
|
var reactUse = require('react-use');
|
|
17
17
|
var reactRouter = require('@tanstack/react-router');
|
|
18
|
+
var reactSwipeable = require('react-swipeable');
|
|
18
19
|
var react = require('@floating-ui/react');
|
|
19
20
|
var omit = require('lodash/omit');
|
|
20
21
|
var reactHelmetAsync = require('react-helmet-async');
|
|
@@ -1817,54 +1818,300 @@ const CopyableText = ({ text, alternativeText, dataTestId, className }) => {
|
|
|
1817
1818
|
return (jsxRuntime.jsx("span", { className: cvaCopyableText({ animating, className }), "data-testid": dataTestId, onAnimationEnd: () => setAnimating(false), onClick: handleOnClick, title: value, children: text }));
|
|
1818
1819
|
};
|
|
1819
1820
|
|
|
1820
|
-
const
|
|
1821
|
-
"
|
|
1822
|
-
"block",
|
|
1821
|
+
const cvaDialog = cssClassVarianceUtilities.cvaMerge([
|
|
1822
|
+
"fixed",
|
|
1823
1823
|
"z-toast",
|
|
1824
|
-
"
|
|
1824
|
+
"pointer-events-auto",
|
|
1825
1825
|
"absolute",
|
|
1826
|
+
"transform",
|
|
1827
|
+
"flex-col",
|
|
1828
|
+
"bg-neutral-50",
|
|
1829
|
+
"transition-transform",
|
|
1830
|
+
"duration-300",
|
|
1831
|
+
"ease-in-out",
|
|
1832
|
+
"shadow-lg",
|
|
1833
|
+
], {
|
|
1834
|
+
variants: {
|
|
1835
|
+
position: {
|
|
1836
|
+
left: "left-0 top-0 h-full w-fit rounded-r-lg",
|
|
1837
|
+
right: "right-0 top-0 h-full w-fit rounded-l-lg",
|
|
1838
|
+
top: "left-0 top-0 h-fit w-full rounded-b-lg",
|
|
1839
|
+
bottom: "bottom-0 left-0 right-0 h-fit w-full rounded-t-lg",
|
|
1840
|
+
},
|
|
1841
|
+
sidebarMode: {
|
|
1842
|
+
closed: "translate-y-[calc(100%-2.2rem)] rounded-t-lg",
|
|
1843
|
+
half: "translate-y-[30%] rounded-t-lg",
|
|
1844
|
+
full: "h-full translate-y-0 rounded-none",
|
|
1845
|
+
},
|
|
1846
|
+
isLargeScreen: {
|
|
1847
|
+
true: "",
|
|
1848
|
+
false: "bottom-0 left-0 right-0 w-full w-full sm:rounded-none",
|
|
1849
|
+
},
|
|
1850
|
+
open: {
|
|
1851
|
+
true: "",
|
|
1852
|
+
false: "",
|
|
1853
|
+
},
|
|
1854
|
+
},
|
|
1855
|
+
defaultVariants: {
|
|
1856
|
+
position: "left",
|
|
1857
|
+
},
|
|
1858
|
+
compoundVariants: [
|
|
1859
|
+
{
|
|
1860
|
+
isLargeScreen: true,
|
|
1861
|
+
open: true,
|
|
1862
|
+
position: "left",
|
|
1863
|
+
className: "translate-x-0",
|
|
1864
|
+
},
|
|
1865
|
+
{
|
|
1866
|
+
isLargeScreen: true,
|
|
1867
|
+
open: false,
|
|
1868
|
+
position: "left",
|
|
1869
|
+
className: "-translate-x-full",
|
|
1870
|
+
},
|
|
1871
|
+
{
|
|
1872
|
+
isLargeScreen: true,
|
|
1873
|
+
open: true,
|
|
1874
|
+
position: "right",
|
|
1875
|
+
className: "translate-x-0",
|
|
1876
|
+
},
|
|
1877
|
+
{
|
|
1878
|
+
isLargeScreen: true,
|
|
1879
|
+
open: false,
|
|
1880
|
+
position: "right",
|
|
1881
|
+
className: "translate-x-full",
|
|
1882
|
+
},
|
|
1883
|
+
{
|
|
1884
|
+
isLargeScreen: true,
|
|
1885
|
+
open: true,
|
|
1886
|
+
position: "top",
|
|
1887
|
+
className: "translate-y-0",
|
|
1888
|
+
},
|
|
1889
|
+
{
|
|
1890
|
+
isLargeScreen: true,
|
|
1891
|
+
open: false,
|
|
1892
|
+
position: "top",
|
|
1893
|
+
className: "-translate-y-full",
|
|
1894
|
+
},
|
|
1895
|
+
{
|
|
1896
|
+
isLargeScreen: true,
|
|
1897
|
+
open: true,
|
|
1898
|
+
position: "bottom",
|
|
1899
|
+
className: "translate-y-0",
|
|
1900
|
+
},
|
|
1901
|
+
{
|
|
1902
|
+
isLargeScreen: true,
|
|
1903
|
+
open: false,
|
|
1904
|
+
position: "bottom",
|
|
1905
|
+
className: "translate-y-full",
|
|
1906
|
+
},
|
|
1907
|
+
],
|
|
1908
|
+
});
|
|
1909
|
+
const cvaDialogContainer = cssClassVarianceUtilities.cvaMerge(["relative", "flex", "h-full", "flex-col", "p-4"]);
|
|
1910
|
+
const cvaSwipeContainer = cssClassVarianceUtilities.cvaMerge(["mb-4", "flex", "items-center", "justify-center", "lg:hidden"]);
|
|
1911
|
+
const cvaSwipeIcon = cssClassVarianceUtilities.cvaMerge(["block", "h-1", "w-10", "rounded-full", "bg-gray-400"]);
|
|
1912
|
+
const cvaToogleContainer = cssClassVarianceUtilities.cvaMerge(["z-8", "absolute"], {
|
|
1913
|
+
variants: {
|
|
1914
|
+
position: {
|
|
1915
|
+
left: "right-[-24px] top-[calc(50%-24px)]",
|
|
1916
|
+
right: "left-[-24px] top-[calc(50%-24px)]",
|
|
1917
|
+
top: "bottom-[-24px] left-[calc(50%-24px)]",
|
|
1918
|
+
bottom: "left-[calc(50%-24px)] top-[-24px]",
|
|
1919
|
+
},
|
|
1920
|
+
},
|
|
1921
|
+
defaultVariants: {
|
|
1922
|
+
position: "left",
|
|
1923
|
+
},
|
|
1924
|
+
});
|
|
1925
|
+
const cvaToogleButton = cssClassVarianceUtilities.cvaMerge([
|
|
1926
|
+
"flex",
|
|
1826
1927
|
"cursor-pointer",
|
|
1827
|
-
"
|
|
1828
|
-
|
|
1829
|
-
|
|
1928
|
+
"items-center",
|
|
1929
|
+
"justify-center",
|
|
1930
|
+
"border-gray-300",
|
|
1931
|
+
"bg-neutral-50",
|
|
1932
|
+
"bg-center",
|
|
1933
|
+
"bg-no-repeat",
|
|
1934
|
+
"shadow-md",
|
|
1935
|
+
], {
|
|
1830
1936
|
variants: {
|
|
1831
1937
|
position: {
|
|
1832
|
-
left: "
|
|
1833
|
-
right: "
|
|
1834
|
-
|
|
1835
|
-
|
|
1938
|
+
left: "h-12 w-6 rounded-r-lg",
|
|
1939
|
+
right: "h-12 w-6 rounded-l-lg",
|
|
1940
|
+
top: "h-6 w-12 rounded-b-lg",
|
|
1941
|
+
bottom: "h-6 w-12 rounded-t-lg",
|
|
1836
1942
|
},
|
|
1837
1943
|
},
|
|
1838
1944
|
defaultVariants: {
|
|
1839
1945
|
position: "left",
|
|
1840
1946
|
},
|
|
1841
1947
|
});
|
|
1948
|
+
const cvaOverlayContainer = cssClassVarianceUtilities.cvaMerge([
|
|
1949
|
+
"fixed",
|
|
1950
|
+
"flex",
|
|
1951
|
+
"items-center",
|
|
1952
|
+
"justify-center",
|
|
1953
|
+
"inset-0",
|
|
1954
|
+
"bg-black/30",
|
|
1955
|
+
"bg-opacity-50",
|
|
1956
|
+
"transition-opacity",
|
|
1957
|
+
"duration-200",
|
|
1958
|
+
"ease-in-out",
|
|
1959
|
+
"opacity-100",
|
|
1960
|
+
], {
|
|
1961
|
+
variants: {
|
|
1962
|
+
open: {
|
|
1963
|
+
true: "opacity-1 z-popover",
|
|
1964
|
+
false: "z-[-1] opacity-0",
|
|
1965
|
+
},
|
|
1966
|
+
},
|
|
1967
|
+
});
|
|
1842
1968
|
|
|
1843
1969
|
/**
|
|
1844
|
-
*
|
|
1845
|
-
|
|
1846
|
-
* @param {
|
|
1847
|
-
* @
|
|
1970
|
+
* Overlay Component
|
|
1971
|
+
*
|
|
1972
|
+
* @param {object} props - The Overlay component properties
|
|
1973
|
+
* @param {boolean} props.open - Open status of the Overlay
|
|
1974
|
+
* @param {Function} props.onClose - Callback function when Overlay is closed
|
|
1975
|
+
* @returns {JSX.Element|null} The Overlay component
|
|
1848
1976
|
*/
|
|
1849
|
-
const
|
|
1850
|
-
const { context } = react.useFloating();
|
|
1977
|
+
const Overlay = ({ open, onClose }) => {
|
|
1851
1978
|
React.useEffect(() => {
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1979
|
+
if (!onClose) {
|
|
1980
|
+
return;
|
|
1981
|
+
}
|
|
1982
|
+
const handleEscape = (event) => {
|
|
1983
|
+
if (event.key === "Escape") {
|
|
1984
|
+
onClose(event);
|
|
1856
1985
|
}
|
|
1857
1986
|
};
|
|
1858
1987
|
if (open) {
|
|
1859
|
-
window.addEventListener("keyup",
|
|
1988
|
+
window.addEventListener("keyup", handleEscape);
|
|
1860
1989
|
}
|
|
1861
1990
|
return () => {
|
|
1862
|
-
window.removeEventListener("keyup",
|
|
1991
|
+
window.removeEventListener("keyup", handleEscape);
|
|
1863
1992
|
};
|
|
1864
1993
|
}, [open, onClose]);
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1994
|
+
const handleClick = (event) => {
|
|
1995
|
+
if (onClose) {
|
|
1996
|
+
onClose(event);
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
return (jsxRuntime.jsx("div", { "aria-hidden": open, className: cvaOverlayContainer({ open }), "data-testid": "sidebar-overlay", onClick: handleClick }));
|
|
2000
|
+
};
|
|
2001
|
+
|
|
2002
|
+
const getIconName = (open, position) => {
|
|
2003
|
+
switch (position) {
|
|
2004
|
+
case "left":
|
|
2005
|
+
return open ? "ChevronLeft" : "ChevronRight";
|
|
2006
|
+
case "right":
|
|
2007
|
+
return open ? "ChevronRight" : "ChevronLeft";
|
|
2008
|
+
case "top":
|
|
2009
|
+
return open ? "ChevronUp" : "ChevronDown";
|
|
2010
|
+
case "bottom":
|
|
2011
|
+
return open ? "ChevronDown" : "ChevronUp";
|
|
2012
|
+
default:
|
|
2013
|
+
return open ? "ChevronLeft" : "ChevronRight";
|
|
2014
|
+
}
|
|
2015
|
+
};
|
|
2016
|
+
/**
|
|
2017
|
+
* ToggleButton is a React functional component that returns a button with a chevron icon.
|
|
2018
|
+
* The direction of the chevron changes depending on the state of the 'open' prop and
|
|
2019
|
+
* the side the button is positioned ('position' prop).
|
|
2020
|
+
* The button might be disabled based on the 'disableButton' prop.
|
|
2021
|
+
*
|
|
2022
|
+
* @param {object} props - The properties passed to the component
|
|
2023
|
+
* @param {boolean} props.open - Indicates if the button is in "open" state
|
|
2024
|
+
* @param {Function} [props.onToggle] - Optional callback function for when the button is clicked
|
|
2025
|
+
* @param {Position} props.position - The position of the button relative to its container
|
|
2026
|
+
*/
|
|
2027
|
+
const ToogleButton = ({ open, position, onToggle }) => {
|
|
2028
|
+
const name = getIconName(open, position);
|
|
2029
|
+
return (jsxRuntime.jsx("div", { className: cvaToogleContainer({ position }), children: jsxRuntime.jsx("button", { className: cvaToogleButton({ position }), "data-testid": "toggle-button", onClick: onToggle, children: jsxRuntime.jsx(Icon, { name: name }) }) }));
|
|
2030
|
+
};
|
|
2031
|
+
|
|
2032
|
+
/**
|
|
2033
|
+
* MapSidebar is a sidebar component used with Maps.
|
|
2034
|
+
* It provides a slide over sidebar drawer which can be used for displaying map related information or controls.
|
|
2035
|
+
*
|
|
2036
|
+
* @param {DrawerProps} props - The props for the MapSidebar component
|
|
2037
|
+
* @returns {JSX.Element | null} Drawer component
|
|
2038
|
+
*/
|
|
2039
|
+
const Drawer = ({ open = true, onToggle, onClose, disableOverlay, position = "left", children, dataTestId, }) => {
|
|
2040
|
+
const { width } = useResize();
|
|
2041
|
+
const isLargeScreen = width >= 1024;
|
|
2042
|
+
const initialSidebarMode = () => {
|
|
2043
|
+
if (!open) {
|
|
2044
|
+
return "closed";
|
|
2045
|
+
}
|
|
2046
|
+
return isLargeScreen ? "full" : "half";
|
|
2047
|
+
};
|
|
2048
|
+
const [sidebarMode, setSidebarMode] = React.useState(initialSidebarMode);
|
|
2049
|
+
const [isVisible, setIsVisible] = React.useState(open);
|
|
2050
|
+
const [isAnimationStart, setStartAnimation] = React.useState(open);
|
|
2051
|
+
React.useEffect(() => {
|
|
2052
|
+
if (!isLargeScreen && open) {
|
|
2053
|
+
setSidebarMode("half");
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2056
|
+
if (onToggle) {
|
|
2057
|
+
setStartAnimation(open);
|
|
2058
|
+
return;
|
|
2059
|
+
}
|
|
2060
|
+
manageVisibilityAndAnimation(open);
|
|
2061
|
+
}, [onToggle, isLargeScreen, open]);
|
|
2062
|
+
const manageVisibilityAndAnimation = (isOpen) => {
|
|
2063
|
+
if (!isOpen) {
|
|
2064
|
+
setStartAnimation(false);
|
|
2065
|
+
return;
|
|
2066
|
+
}
|
|
2067
|
+
setIsVisible(true);
|
|
2068
|
+
setTimeout(() => {
|
|
2069
|
+
setStartAnimation(true);
|
|
2070
|
+
}, 150);
|
|
2071
|
+
};
|
|
2072
|
+
const handlers = reactSwipeable.useSwipeable({
|
|
2073
|
+
onSwipedUp: () => !isLargeScreen && handleSwipedUp(),
|
|
2074
|
+
onSwipedDown: () => !isLargeScreen && handleSwipedDown(),
|
|
2075
|
+
trackMouse: true,
|
|
2076
|
+
});
|
|
2077
|
+
const handleSwipedUp = () => {
|
|
2078
|
+
setSidebarMode(prev => {
|
|
2079
|
+
switch (prev) {
|
|
2080
|
+
case "closed":
|
|
2081
|
+
return "half";
|
|
2082
|
+
case "half":
|
|
2083
|
+
return "full";
|
|
2084
|
+
default:
|
|
2085
|
+
return prev;
|
|
2086
|
+
}
|
|
2087
|
+
});
|
|
2088
|
+
};
|
|
2089
|
+
const handleSwipedDown = () => {
|
|
2090
|
+
setSidebarMode(prev => {
|
|
2091
|
+
switch (prev) {
|
|
2092
|
+
case "full":
|
|
2093
|
+
return "half";
|
|
2094
|
+
case "half":
|
|
2095
|
+
return "closed";
|
|
2096
|
+
default:
|
|
2097
|
+
return prev;
|
|
2098
|
+
}
|
|
2099
|
+
});
|
|
2100
|
+
};
|
|
2101
|
+
const handleAnimationEnd = () => {
|
|
2102
|
+
if (!open && !onToggle) {
|
|
2103
|
+
setIsVisible(false);
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
if (!isVisible && !onToggle) {
|
|
2107
|
+
return null;
|
|
2108
|
+
}
|
|
2109
|
+
return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, children: [!disableOverlay ? jsxRuntime.jsx(Overlay, { onClose: onClose, open: isAnimationStart }) : null, jsxRuntime.jsx("div", { ...handlers, className: cvaDialog({
|
|
2110
|
+
sidebarMode: isLargeScreen ? null : sidebarMode,
|
|
2111
|
+
isLargeScreen,
|
|
2112
|
+
open: isAnimationStart,
|
|
2113
|
+
position,
|
|
2114
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, onTransitionEnd: handleAnimationEnd, children: jsxRuntime.jsxs("div", { className: cvaDialogContainer(), children: [jsxRuntime.jsx("div", { className: cvaSwipeContainer(), children: jsxRuntime.jsx("div", { className: cvaSwipeIcon() }) }), isLargeScreen && onToggle ? jsxRuntime.jsx(ToogleButton, { onToggle: onToggle, open: open, position: position }) : null, children] }) })] }));
|
|
1868
2115
|
};
|
|
1869
2116
|
|
|
1870
2117
|
const cvaSkeletonLine = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -4334,6 +4581,44 @@ function defaultHeader(date, showTime) {
|
|
|
4334
4581
|
})})`;
|
|
4335
4582
|
}
|
|
4336
4583
|
|
|
4584
|
+
const cvaToggleGroup = cssClassVarianceUtilities.cvaMerge(["inline-flex", "divide-x", "divide-slate-300"]);
|
|
4585
|
+
const cvaToggleItem = cssClassVarianceUtilities.cvaMerge(["text-slate-600", "rounded-none", "bg-transparent", "flex", "border-x-0"], {
|
|
4586
|
+
variants: {
|
|
4587
|
+
selected: {
|
|
4588
|
+
true: ["bg-slate-300", "hover:bg-slate-300", "text-slate-700"],
|
|
4589
|
+
false: [],
|
|
4590
|
+
},
|
|
4591
|
+
},
|
|
4592
|
+
});
|
|
4593
|
+
const cvaToggleItemText = cssClassVarianceUtilities.cvaMerge(["text-ellipsis", "truncate", "flex-grow"], {
|
|
4594
|
+
variants: {
|
|
4595
|
+
disabledAndSelected: {
|
|
4596
|
+
true: ["text-slate-800"],
|
|
4597
|
+
false: [],
|
|
4598
|
+
},
|
|
4599
|
+
maxWidth: {
|
|
4600
|
+
sm: ["max-w-[80px]"],
|
|
4601
|
+
md: ["max-w-[120px]"],
|
|
4602
|
+
},
|
|
4603
|
+
},
|
|
4604
|
+
});
|
|
4605
|
+
|
|
4606
|
+
/**
|
|
4607
|
+
* Toggle Group allows users to toggle between two or more closely related options, and immediately apply that selection.
|
|
4608
|
+
*
|
|
4609
|
+
* @param {ToggleGroupProps} props - The props for the ToggleGroup component
|
|
4610
|
+
* @returns {JSX.Element} ToggleGroup component
|
|
4611
|
+
*/
|
|
4612
|
+
const ToggleGroup = ({ list, selected, setSelected, onClick, disabled = false, size = "medium", isIconOnly = false, className, dataTestId, }) => {
|
|
4613
|
+
return (jsxRuntime.jsx("div", { className: cvaToggleGroup(), "data-testid": dataTestId, children: list.map((item, index) => (jsxRuntime.jsx(ToggleItem, { className: tailwindMerge.twMerge(className, index === 0 ? ["rounded-l-md", "border-l"] : "", index === list.length - 1 ? ["rounded-r-md", "border-r"] : ""), dataTestId: item.dataTestId, disabled: disabled, iconName: item.iconName, isIconOnly: isIconOnly, onClick: () => {
|
|
4614
|
+
onClick && onClick();
|
|
4615
|
+
setSelected(item.id);
|
|
4616
|
+
}, selected: selected === item.id, size: size, text: item.text, title: item.title, tooltip: item.tooltip }, item.id))) }));
|
|
4617
|
+
};
|
|
4618
|
+
const ToggleItem = ({ title, onClick, disabled, isIconOnly, iconName, size, className, selected, text, tooltip, dataTestId, }) => {
|
|
4619
|
+
return isIconOnly ? (jsxRuntime.jsx(Tooltip, { label: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) || title, placement: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.placement) || "top", children: jsxRuntime.jsx(IconButton, { className: cvaToggleItem({ className, selected }), "data-testid": dataTestId, disabled: disabled, icon: iconName ? jsxRuntime.jsx(Icon, { name: iconName, size: "small" }) : null, onClick: onClick, size: size, title: iconName, variant: "secondary" }) })) : (jsxRuntime.jsx(Tooltip, { disabled: !(text === null || text === void 0 ? void 0 : text.truncate) && (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) === undefined, label: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) || title, placement: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.placement) || "top", children: jsxRuntime.jsx(Button, { className: cvaToggleItem({ className, selected }), "data-testid": dataTestId, disabled: disabled, onClick: onClick, prefix: iconName ? jsxRuntime.jsx(Icon, { name: iconName, size: "small" }) : null, size: size, variant: "secondary", children: jsxRuntime.jsx("span", { className: cvaToggleItemText({ disabledAndSelected: disabled && selected, maxWidth: text === null || text === void 0 ? void 0 : text.maxWidth }), children: title }) }) }));
|
|
4620
|
+
};
|
|
4621
|
+
|
|
4337
4622
|
const cvaValueBar = cssClassVarianceUtilities.cvaMerge(["w-full"], {
|
|
4338
4623
|
variants: {
|
|
4339
4624
|
size: {
|
|
@@ -4540,44 +4825,6 @@ const WidgetBody = ({ density = "auto", children, dataTestId, className, disable
|
|
|
4540
4825
|
return (jsxRuntime.jsx("div", { className: cvaWidgetBodyDensityContainer({ density, disableGap, className }), "data-testid": dataTestId, children: children }));
|
|
4541
4826
|
};
|
|
4542
4827
|
|
|
4543
|
-
const cvaToggleGroup = cssClassVarianceUtilities.cvaMerge(["inline-flex", "divide-x", "divide-slate-300"]);
|
|
4544
|
-
const cvaToggleItem = cssClassVarianceUtilities.cvaMerge(["text-slate-600", "rounded-none", "bg-transparent", "flex", "border-x-0"], {
|
|
4545
|
-
variants: {
|
|
4546
|
-
selected: {
|
|
4547
|
-
true: ["bg-slate-300", "hover:bg-slate-300", "text-slate-700"],
|
|
4548
|
-
false: [],
|
|
4549
|
-
},
|
|
4550
|
-
},
|
|
4551
|
-
});
|
|
4552
|
-
const cvaToggleItemText = cssClassVarianceUtilities.cvaMerge(["text-ellipsis", "truncate", "flex-grow"], {
|
|
4553
|
-
variants: {
|
|
4554
|
-
disabledAndSelected: {
|
|
4555
|
-
true: ["text-slate-800"],
|
|
4556
|
-
false: [],
|
|
4557
|
-
},
|
|
4558
|
-
maxWidth: {
|
|
4559
|
-
sm: ["max-w-[80px]"],
|
|
4560
|
-
md: ["max-w-[120px]"],
|
|
4561
|
-
},
|
|
4562
|
-
},
|
|
4563
|
-
});
|
|
4564
|
-
|
|
4565
|
-
/**
|
|
4566
|
-
* Toggle Group allows users to toggle between two or more closely related options, and immediately apply that selection.
|
|
4567
|
-
*
|
|
4568
|
-
* @param {ToggleGroupProps} props - The props for the ToggleGroup component
|
|
4569
|
-
* @returns {JSX.Element} ToggleGroup component
|
|
4570
|
-
*/
|
|
4571
|
-
const ToggleGroup = ({ list, selected, setSelected, onClick, disabled = false, size = "medium", isIconOnly = false, className, dataTestId, }) => {
|
|
4572
|
-
return (jsxRuntime.jsx("div", { className: cvaToggleGroup(), "data-testid": dataTestId, children: list.map((item, index) => (jsxRuntime.jsx(ToggleItem, { className: tailwindMerge.twMerge(className, index === 0 ? ["rounded-l-md", "border-l"] : "", index === list.length - 1 ? ["rounded-r-md", "border-r"] : ""), dataTestId: item.dataTestId, disabled: disabled, iconName: item.iconName, isIconOnly: isIconOnly, onClick: () => {
|
|
4573
|
-
onClick && onClick();
|
|
4574
|
-
setSelected(item.id);
|
|
4575
|
-
}, selected: selected === item.id, size: size, text: item.text, title: item.title, tooltip: item.tooltip }, item.id))) }));
|
|
4576
|
-
};
|
|
4577
|
-
const ToggleItem = ({ title, onClick, disabled, isIconOnly, iconName, size, className, selected, text, tooltip, dataTestId, }) => {
|
|
4578
|
-
return isIconOnly ? (jsxRuntime.jsx(Tooltip, { label: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) || title, placement: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.placement) || "top", children: jsxRuntime.jsx(IconButton, { className: cvaToggleItem({ className, selected }), "data-testid": dataTestId, disabled: disabled, icon: iconName ? jsxRuntime.jsx(Icon, { name: iconName, size: "small" }) : null, onClick: onClick, size: size, title: iconName, variant: "secondary" }) })) : (jsxRuntime.jsx(Tooltip, { disabled: !(text === null || text === void 0 ? void 0 : text.truncate) && (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) === undefined, label: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) || title, placement: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.placement) || "top", children: jsxRuntime.jsx(Button, { className: cvaToggleItem({ className, selected }), "data-testid": dataTestId, disabled: disabled, onClick: onClick, prefix: iconName ? jsxRuntime.jsx(Icon, { name: iconName, size: "small" }) : null, size: size, variant: "secondary", children: jsxRuntime.jsx("span", { className: cvaToggleItemText({ disabledAndSelected: disabled && selected, maxWidth: text === null || text === void 0 ? void 0 : text.maxWidth }), children: title }) }) }));
|
|
4579
|
-
};
|
|
4580
|
-
|
|
4581
4828
|
const cvaClickable = cssClassVarianceUtilities.cvaMerge([
|
|
4582
4829
|
"shadow-lg",
|
|
4583
4830
|
"rounded-lg",
|
package/index.esm.js
CHANGED
|
@@ -14,7 +14,8 @@ import { Slottable, Slot } from '@radix-ui/react-slot';
|
|
|
14
14
|
import isEqual from 'lodash/isEqual';
|
|
15
15
|
import { usePrevious, useMeasure, useCopyToClipboard } from 'react-use';
|
|
16
16
|
import { Link, useBlocker } from '@tanstack/react-router';
|
|
17
|
-
import {
|
|
17
|
+
import { useSwipeable } from 'react-swipeable';
|
|
18
|
+
import { useFloating, autoUpdate, offset, flip, shift, size, useClick, useDismiss, useHover as useHover$1, useRole, useInteractions, useMergeRefs, FloatingPortal, FloatingFocusManager, arrow, useTransitionStatus, FloatingArrow } from '@floating-ui/react';
|
|
18
19
|
import omit from 'lodash/omit';
|
|
19
20
|
import { HelmetProvider, Helmet } from 'react-helmet-async';
|
|
20
21
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -1797,54 +1798,300 @@ const CopyableText = ({ text, alternativeText, dataTestId, className }) => {
|
|
|
1797
1798
|
return (jsx("span", { className: cvaCopyableText({ animating, className }), "data-testid": dataTestId, onAnimationEnd: () => setAnimating(false), onClick: handleOnClick, title: value, children: text }));
|
|
1798
1799
|
};
|
|
1799
1800
|
|
|
1800
|
-
const
|
|
1801
|
-
"
|
|
1802
|
-
"block",
|
|
1801
|
+
const cvaDialog = cvaMerge([
|
|
1802
|
+
"fixed",
|
|
1803
1803
|
"z-toast",
|
|
1804
|
-
"
|
|
1804
|
+
"pointer-events-auto",
|
|
1805
1805
|
"absolute",
|
|
1806
|
+
"transform",
|
|
1807
|
+
"flex-col",
|
|
1808
|
+
"bg-neutral-50",
|
|
1809
|
+
"transition-transform",
|
|
1810
|
+
"duration-300",
|
|
1811
|
+
"ease-in-out",
|
|
1812
|
+
"shadow-lg",
|
|
1813
|
+
], {
|
|
1814
|
+
variants: {
|
|
1815
|
+
position: {
|
|
1816
|
+
left: "left-0 top-0 h-full w-fit rounded-r-lg",
|
|
1817
|
+
right: "right-0 top-0 h-full w-fit rounded-l-lg",
|
|
1818
|
+
top: "left-0 top-0 h-fit w-full rounded-b-lg",
|
|
1819
|
+
bottom: "bottom-0 left-0 right-0 h-fit w-full rounded-t-lg",
|
|
1820
|
+
},
|
|
1821
|
+
sidebarMode: {
|
|
1822
|
+
closed: "translate-y-[calc(100%-2.2rem)] rounded-t-lg",
|
|
1823
|
+
half: "translate-y-[30%] rounded-t-lg",
|
|
1824
|
+
full: "h-full translate-y-0 rounded-none",
|
|
1825
|
+
},
|
|
1826
|
+
isLargeScreen: {
|
|
1827
|
+
true: "",
|
|
1828
|
+
false: "bottom-0 left-0 right-0 w-full w-full sm:rounded-none",
|
|
1829
|
+
},
|
|
1830
|
+
open: {
|
|
1831
|
+
true: "",
|
|
1832
|
+
false: "",
|
|
1833
|
+
},
|
|
1834
|
+
},
|
|
1835
|
+
defaultVariants: {
|
|
1836
|
+
position: "left",
|
|
1837
|
+
},
|
|
1838
|
+
compoundVariants: [
|
|
1839
|
+
{
|
|
1840
|
+
isLargeScreen: true,
|
|
1841
|
+
open: true,
|
|
1842
|
+
position: "left",
|
|
1843
|
+
className: "translate-x-0",
|
|
1844
|
+
},
|
|
1845
|
+
{
|
|
1846
|
+
isLargeScreen: true,
|
|
1847
|
+
open: false,
|
|
1848
|
+
position: "left",
|
|
1849
|
+
className: "-translate-x-full",
|
|
1850
|
+
},
|
|
1851
|
+
{
|
|
1852
|
+
isLargeScreen: true,
|
|
1853
|
+
open: true,
|
|
1854
|
+
position: "right",
|
|
1855
|
+
className: "translate-x-0",
|
|
1856
|
+
},
|
|
1857
|
+
{
|
|
1858
|
+
isLargeScreen: true,
|
|
1859
|
+
open: false,
|
|
1860
|
+
position: "right",
|
|
1861
|
+
className: "translate-x-full",
|
|
1862
|
+
},
|
|
1863
|
+
{
|
|
1864
|
+
isLargeScreen: true,
|
|
1865
|
+
open: true,
|
|
1866
|
+
position: "top",
|
|
1867
|
+
className: "translate-y-0",
|
|
1868
|
+
},
|
|
1869
|
+
{
|
|
1870
|
+
isLargeScreen: true,
|
|
1871
|
+
open: false,
|
|
1872
|
+
position: "top",
|
|
1873
|
+
className: "-translate-y-full",
|
|
1874
|
+
},
|
|
1875
|
+
{
|
|
1876
|
+
isLargeScreen: true,
|
|
1877
|
+
open: true,
|
|
1878
|
+
position: "bottom",
|
|
1879
|
+
className: "translate-y-0",
|
|
1880
|
+
},
|
|
1881
|
+
{
|
|
1882
|
+
isLargeScreen: true,
|
|
1883
|
+
open: false,
|
|
1884
|
+
position: "bottom",
|
|
1885
|
+
className: "translate-y-full",
|
|
1886
|
+
},
|
|
1887
|
+
],
|
|
1888
|
+
});
|
|
1889
|
+
const cvaDialogContainer = cvaMerge(["relative", "flex", "h-full", "flex-col", "p-4"]);
|
|
1890
|
+
const cvaSwipeContainer = cvaMerge(["mb-4", "flex", "items-center", "justify-center", "lg:hidden"]);
|
|
1891
|
+
const cvaSwipeIcon = cvaMerge(["block", "h-1", "w-10", "rounded-full", "bg-gray-400"]);
|
|
1892
|
+
const cvaToogleContainer = cvaMerge(["z-8", "absolute"], {
|
|
1893
|
+
variants: {
|
|
1894
|
+
position: {
|
|
1895
|
+
left: "right-[-24px] top-[calc(50%-24px)]",
|
|
1896
|
+
right: "left-[-24px] top-[calc(50%-24px)]",
|
|
1897
|
+
top: "bottom-[-24px] left-[calc(50%-24px)]",
|
|
1898
|
+
bottom: "left-[calc(50%-24px)] top-[-24px]",
|
|
1899
|
+
},
|
|
1900
|
+
},
|
|
1901
|
+
defaultVariants: {
|
|
1902
|
+
position: "left",
|
|
1903
|
+
},
|
|
1904
|
+
});
|
|
1905
|
+
const cvaToogleButton = cvaMerge([
|
|
1906
|
+
"flex",
|
|
1806
1907
|
"cursor-pointer",
|
|
1807
|
-
"
|
|
1808
|
-
|
|
1809
|
-
|
|
1908
|
+
"items-center",
|
|
1909
|
+
"justify-center",
|
|
1910
|
+
"border-gray-300",
|
|
1911
|
+
"bg-neutral-50",
|
|
1912
|
+
"bg-center",
|
|
1913
|
+
"bg-no-repeat",
|
|
1914
|
+
"shadow-md",
|
|
1915
|
+
], {
|
|
1810
1916
|
variants: {
|
|
1811
1917
|
position: {
|
|
1812
|
-
left: "
|
|
1813
|
-
right: "
|
|
1814
|
-
|
|
1815
|
-
|
|
1918
|
+
left: "h-12 w-6 rounded-r-lg",
|
|
1919
|
+
right: "h-12 w-6 rounded-l-lg",
|
|
1920
|
+
top: "h-6 w-12 rounded-b-lg",
|
|
1921
|
+
bottom: "h-6 w-12 rounded-t-lg",
|
|
1816
1922
|
},
|
|
1817
1923
|
},
|
|
1818
1924
|
defaultVariants: {
|
|
1819
1925
|
position: "left",
|
|
1820
1926
|
},
|
|
1821
1927
|
});
|
|
1928
|
+
const cvaOverlayContainer = cvaMerge([
|
|
1929
|
+
"fixed",
|
|
1930
|
+
"flex",
|
|
1931
|
+
"items-center",
|
|
1932
|
+
"justify-center",
|
|
1933
|
+
"inset-0",
|
|
1934
|
+
"bg-black/30",
|
|
1935
|
+
"bg-opacity-50",
|
|
1936
|
+
"transition-opacity",
|
|
1937
|
+
"duration-200",
|
|
1938
|
+
"ease-in-out",
|
|
1939
|
+
"opacity-100",
|
|
1940
|
+
], {
|
|
1941
|
+
variants: {
|
|
1942
|
+
open: {
|
|
1943
|
+
true: "opacity-1 z-popover",
|
|
1944
|
+
false: "z-[-1] opacity-0",
|
|
1945
|
+
},
|
|
1946
|
+
},
|
|
1947
|
+
});
|
|
1822
1948
|
|
|
1823
1949
|
/**
|
|
1824
|
-
*
|
|
1825
|
-
|
|
1826
|
-
* @param {
|
|
1827
|
-
* @
|
|
1950
|
+
* Overlay Component
|
|
1951
|
+
*
|
|
1952
|
+
* @param {object} props - The Overlay component properties
|
|
1953
|
+
* @param {boolean} props.open - Open status of the Overlay
|
|
1954
|
+
* @param {Function} props.onClose - Callback function when Overlay is closed
|
|
1955
|
+
* @returns {JSX.Element|null} The Overlay component
|
|
1828
1956
|
*/
|
|
1829
|
-
const
|
|
1830
|
-
const { context } = useFloating();
|
|
1957
|
+
const Overlay = ({ open, onClose }) => {
|
|
1831
1958
|
useEffect(() => {
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1959
|
+
if (!onClose) {
|
|
1960
|
+
return;
|
|
1961
|
+
}
|
|
1962
|
+
const handleEscape = (event) => {
|
|
1963
|
+
if (event.key === "Escape") {
|
|
1964
|
+
onClose(event);
|
|
1836
1965
|
}
|
|
1837
1966
|
};
|
|
1838
1967
|
if (open) {
|
|
1839
|
-
window.addEventListener("keyup",
|
|
1968
|
+
window.addEventListener("keyup", handleEscape);
|
|
1840
1969
|
}
|
|
1841
1970
|
return () => {
|
|
1842
|
-
window.removeEventListener("keyup",
|
|
1971
|
+
window.removeEventListener("keyup", handleEscape);
|
|
1843
1972
|
};
|
|
1844
1973
|
}, [open, onClose]);
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1974
|
+
const handleClick = (event) => {
|
|
1975
|
+
if (onClose) {
|
|
1976
|
+
onClose(event);
|
|
1977
|
+
}
|
|
1978
|
+
};
|
|
1979
|
+
return (jsx("div", { "aria-hidden": open, className: cvaOverlayContainer({ open }), "data-testid": "sidebar-overlay", onClick: handleClick }));
|
|
1980
|
+
};
|
|
1981
|
+
|
|
1982
|
+
const getIconName = (open, position) => {
|
|
1983
|
+
switch (position) {
|
|
1984
|
+
case "left":
|
|
1985
|
+
return open ? "ChevronLeft" : "ChevronRight";
|
|
1986
|
+
case "right":
|
|
1987
|
+
return open ? "ChevronRight" : "ChevronLeft";
|
|
1988
|
+
case "top":
|
|
1989
|
+
return open ? "ChevronUp" : "ChevronDown";
|
|
1990
|
+
case "bottom":
|
|
1991
|
+
return open ? "ChevronDown" : "ChevronUp";
|
|
1992
|
+
default:
|
|
1993
|
+
return open ? "ChevronLeft" : "ChevronRight";
|
|
1994
|
+
}
|
|
1995
|
+
};
|
|
1996
|
+
/**
|
|
1997
|
+
* ToggleButton is a React functional component that returns a button with a chevron icon.
|
|
1998
|
+
* The direction of the chevron changes depending on the state of the 'open' prop and
|
|
1999
|
+
* the side the button is positioned ('position' prop).
|
|
2000
|
+
* The button might be disabled based on the 'disableButton' prop.
|
|
2001
|
+
*
|
|
2002
|
+
* @param {object} props - The properties passed to the component
|
|
2003
|
+
* @param {boolean} props.open - Indicates if the button is in "open" state
|
|
2004
|
+
* @param {Function} [props.onToggle] - Optional callback function for when the button is clicked
|
|
2005
|
+
* @param {Position} props.position - The position of the button relative to its container
|
|
2006
|
+
*/
|
|
2007
|
+
const ToogleButton = ({ open, position, onToggle }) => {
|
|
2008
|
+
const name = getIconName(open, position);
|
|
2009
|
+
return (jsx("div", { className: cvaToogleContainer({ position }), children: jsx("button", { className: cvaToogleButton({ position }), "data-testid": "toggle-button", onClick: onToggle, children: jsx(Icon, { name: name }) }) }));
|
|
2010
|
+
};
|
|
2011
|
+
|
|
2012
|
+
/**
|
|
2013
|
+
* MapSidebar is a sidebar component used with Maps.
|
|
2014
|
+
* It provides a slide over sidebar drawer which can be used for displaying map related information or controls.
|
|
2015
|
+
*
|
|
2016
|
+
* @param {DrawerProps} props - The props for the MapSidebar component
|
|
2017
|
+
* @returns {JSX.Element | null} Drawer component
|
|
2018
|
+
*/
|
|
2019
|
+
const Drawer = ({ open = true, onToggle, onClose, disableOverlay, position = "left", children, dataTestId, }) => {
|
|
2020
|
+
const { width } = useResize();
|
|
2021
|
+
const isLargeScreen = width >= 1024;
|
|
2022
|
+
const initialSidebarMode = () => {
|
|
2023
|
+
if (!open) {
|
|
2024
|
+
return "closed";
|
|
2025
|
+
}
|
|
2026
|
+
return isLargeScreen ? "full" : "half";
|
|
2027
|
+
};
|
|
2028
|
+
const [sidebarMode, setSidebarMode] = useState(initialSidebarMode);
|
|
2029
|
+
const [isVisible, setIsVisible] = useState(open);
|
|
2030
|
+
const [isAnimationStart, setStartAnimation] = useState(open);
|
|
2031
|
+
useEffect(() => {
|
|
2032
|
+
if (!isLargeScreen && open) {
|
|
2033
|
+
setSidebarMode("half");
|
|
2034
|
+
return;
|
|
2035
|
+
}
|
|
2036
|
+
if (onToggle) {
|
|
2037
|
+
setStartAnimation(open);
|
|
2038
|
+
return;
|
|
2039
|
+
}
|
|
2040
|
+
manageVisibilityAndAnimation(open);
|
|
2041
|
+
}, [onToggle, isLargeScreen, open]);
|
|
2042
|
+
const manageVisibilityAndAnimation = (isOpen) => {
|
|
2043
|
+
if (!isOpen) {
|
|
2044
|
+
setStartAnimation(false);
|
|
2045
|
+
return;
|
|
2046
|
+
}
|
|
2047
|
+
setIsVisible(true);
|
|
2048
|
+
setTimeout(() => {
|
|
2049
|
+
setStartAnimation(true);
|
|
2050
|
+
}, 150);
|
|
2051
|
+
};
|
|
2052
|
+
const handlers = useSwipeable({
|
|
2053
|
+
onSwipedUp: () => !isLargeScreen && handleSwipedUp(),
|
|
2054
|
+
onSwipedDown: () => !isLargeScreen && handleSwipedDown(),
|
|
2055
|
+
trackMouse: true,
|
|
2056
|
+
});
|
|
2057
|
+
const handleSwipedUp = () => {
|
|
2058
|
+
setSidebarMode(prev => {
|
|
2059
|
+
switch (prev) {
|
|
2060
|
+
case "closed":
|
|
2061
|
+
return "half";
|
|
2062
|
+
case "half":
|
|
2063
|
+
return "full";
|
|
2064
|
+
default:
|
|
2065
|
+
return prev;
|
|
2066
|
+
}
|
|
2067
|
+
});
|
|
2068
|
+
};
|
|
2069
|
+
const handleSwipedDown = () => {
|
|
2070
|
+
setSidebarMode(prev => {
|
|
2071
|
+
switch (prev) {
|
|
2072
|
+
case "full":
|
|
2073
|
+
return "half";
|
|
2074
|
+
case "half":
|
|
2075
|
+
return "closed";
|
|
2076
|
+
default:
|
|
2077
|
+
return prev;
|
|
2078
|
+
}
|
|
2079
|
+
});
|
|
2080
|
+
};
|
|
2081
|
+
const handleAnimationEnd = () => {
|
|
2082
|
+
if (!open && !onToggle) {
|
|
2083
|
+
setIsVisible(false);
|
|
2084
|
+
}
|
|
2085
|
+
};
|
|
2086
|
+
if (!isVisible && !onToggle) {
|
|
2087
|
+
return null;
|
|
2088
|
+
}
|
|
2089
|
+
return (jsxs("div", { "data-testid": dataTestId, children: [!disableOverlay ? jsx(Overlay, { onClose: onClose, open: isAnimationStart }) : null, jsx("div", { ...handlers, className: cvaDialog({
|
|
2090
|
+
sidebarMode: isLargeScreen ? null : sidebarMode,
|
|
2091
|
+
isLargeScreen,
|
|
2092
|
+
open: isAnimationStart,
|
|
2093
|
+
position,
|
|
2094
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, onTransitionEnd: handleAnimationEnd, children: jsxs("div", { className: cvaDialogContainer(), children: [jsx("div", { className: cvaSwipeContainer(), children: jsx("div", { className: cvaSwipeIcon() }) }), isLargeScreen && onToggle ? jsx(ToogleButton, { onToggle: onToggle, open: open, position: position }) : null, children] }) })] }));
|
|
1848
2095
|
};
|
|
1849
2096
|
|
|
1850
2097
|
const cvaSkeletonLine = cvaMerge([
|
|
@@ -4314,6 +4561,44 @@ function defaultHeader(date, showTime) {
|
|
|
4314
4561
|
})})`;
|
|
4315
4562
|
}
|
|
4316
4563
|
|
|
4564
|
+
const cvaToggleGroup = cvaMerge(["inline-flex", "divide-x", "divide-slate-300"]);
|
|
4565
|
+
const cvaToggleItem = cvaMerge(["text-slate-600", "rounded-none", "bg-transparent", "flex", "border-x-0"], {
|
|
4566
|
+
variants: {
|
|
4567
|
+
selected: {
|
|
4568
|
+
true: ["bg-slate-300", "hover:bg-slate-300", "text-slate-700"],
|
|
4569
|
+
false: [],
|
|
4570
|
+
},
|
|
4571
|
+
},
|
|
4572
|
+
});
|
|
4573
|
+
const cvaToggleItemText = cvaMerge(["text-ellipsis", "truncate", "flex-grow"], {
|
|
4574
|
+
variants: {
|
|
4575
|
+
disabledAndSelected: {
|
|
4576
|
+
true: ["text-slate-800"],
|
|
4577
|
+
false: [],
|
|
4578
|
+
},
|
|
4579
|
+
maxWidth: {
|
|
4580
|
+
sm: ["max-w-[80px]"],
|
|
4581
|
+
md: ["max-w-[120px]"],
|
|
4582
|
+
},
|
|
4583
|
+
},
|
|
4584
|
+
});
|
|
4585
|
+
|
|
4586
|
+
/**
|
|
4587
|
+
* Toggle Group allows users to toggle between two or more closely related options, and immediately apply that selection.
|
|
4588
|
+
*
|
|
4589
|
+
* @param {ToggleGroupProps} props - The props for the ToggleGroup component
|
|
4590
|
+
* @returns {JSX.Element} ToggleGroup component
|
|
4591
|
+
*/
|
|
4592
|
+
const ToggleGroup = ({ list, selected, setSelected, onClick, disabled = false, size = "medium", isIconOnly = false, className, dataTestId, }) => {
|
|
4593
|
+
return (jsx("div", { className: cvaToggleGroup(), "data-testid": dataTestId, children: list.map((item, index) => (jsx(ToggleItem, { className: twMerge(className, index === 0 ? ["rounded-l-md", "border-l"] : "", index === list.length - 1 ? ["rounded-r-md", "border-r"] : ""), dataTestId: item.dataTestId, disabled: disabled, iconName: item.iconName, isIconOnly: isIconOnly, onClick: () => {
|
|
4594
|
+
onClick && onClick();
|
|
4595
|
+
setSelected(item.id);
|
|
4596
|
+
}, selected: selected === item.id, size: size, text: item.text, title: item.title, tooltip: item.tooltip }, item.id))) }));
|
|
4597
|
+
};
|
|
4598
|
+
const ToggleItem = ({ title, onClick, disabled, isIconOnly, iconName, size, className, selected, text, tooltip, dataTestId, }) => {
|
|
4599
|
+
return isIconOnly ? (jsx(Tooltip, { label: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) || title, placement: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.placement) || "top", children: jsx(IconButton, { className: cvaToggleItem({ className, selected }), "data-testid": dataTestId, disabled: disabled, icon: iconName ? jsx(Icon, { name: iconName, size: "small" }) : null, onClick: onClick, size: size, title: iconName, variant: "secondary" }) })) : (jsx(Tooltip, { disabled: !(text === null || text === void 0 ? void 0 : text.truncate) && (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) === undefined, label: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) || title, placement: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.placement) || "top", children: jsx(Button, { className: cvaToggleItem({ className, selected }), "data-testid": dataTestId, disabled: disabled, onClick: onClick, prefix: iconName ? jsx(Icon, { name: iconName, size: "small" }) : null, size: size, variant: "secondary", children: jsx("span", { className: cvaToggleItemText({ disabledAndSelected: disabled && selected, maxWidth: text === null || text === void 0 ? void 0 : text.maxWidth }), children: title }) }) }));
|
|
4600
|
+
};
|
|
4601
|
+
|
|
4317
4602
|
const cvaValueBar = cvaMerge(["w-full"], {
|
|
4318
4603
|
variants: {
|
|
4319
4604
|
size: {
|
|
@@ -4520,44 +4805,6 @@ const WidgetBody = ({ density = "auto", children, dataTestId, className, disable
|
|
|
4520
4805
|
return (jsx("div", { className: cvaWidgetBodyDensityContainer({ density, disableGap, className }), "data-testid": dataTestId, children: children }));
|
|
4521
4806
|
};
|
|
4522
4807
|
|
|
4523
|
-
const cvaToggleGroup = cvaMerge(["inline-flex", "divide-x", "divide-slate-300"]);
|
|
4524
|
-
const cvaToggleItem = cvaMerge(["text-slate-600", "rounded-none", "bg-transparent", "flex", "border-x-0"], {
|
|
4525
|
-
variants: {
|
|
4526
|
-
selected: {
|
|
4527
|
-
true: ["bg-slate-300", "hover:bg-slate-300", "text-slate-700"],
|
|
4528
|
-
false: [],
|
|
4529
|
-
},
|
|
4530
|
-
},
|
|
4531
|
-
});
|
|
4532
|
-
const cvaToggleItemText = cvaMerge(["text-ellipsis", "truncate", "flex-grow"], {
|
|
4533
|
-
variants: {
|
|
4534
|
-
disabledAndSelected: {
|
|
4535
|
-
true: ["text-slate-800"],
|
|
4536
|
-
false: [],
|
|
4537
|
-
},
|
|
4538
|
-
maxWidth: {
|
|
4539
|
-
sm: ["max-w-[80px]"],
|
|
4540
|
-
md: ["max-w-[120px]"],
|
|
4541
|
-
},
|
|
4542
|
-
},
|
|
4543
|
-
});
|
|
4544
|
-
|
|
4545
|
-
/**
|
|
4546
|
-
* Toggle Group allows users to toggle between two or more closely related options, and immediately apply that selection.
|
|
4547
|
-
*
|
|
4548
|
-
* @param {ToggleGroupProps} props - The props for the ToggleGroup component
|
|
4549
|
-
* @returns {JSX.Element} ToggleGroup component
|
|
4550
|
-
*/
|
|
4551
|
-
const ToggleGroup = ({ list, selected, setSelected, onClick, disabled = false, size = "medium", isIconOnly = false, className, dataTestId, }) => {
|
|
4552
|
-
return (jsx("div", { className: cvaToggleGroup(), "data-testid": dataTestId, children: list.map((item, index) => (jsx(ToggleItem, { className: twMerge(className, index === 0 ? ["rounded-l-md", "border-l"] : "", index === list.length - 1 ? ["rounded-r-md", "border-r"] : ""), dataTestId: item.dataTestId, disabled: disabled, iconName: item.iconName, isIconOnly: isIconOnly, onClick: () => {
|
|
4553
|
-
onClick && onClick();
|
|
4554
|
-
setSelected(item.id);
|
|
4555
|
-
}, selected: selected === item.id, size: size, text: item.text, title: item.title, tooltip: item.tooltip }, item.id))) }));
|
|
4556
|
-
};
|
|
4557
|
-
const ToggleItem = ({ title, onClick, disabled, isIconOnly, iconName, size, className, selected, text, tooltip, dataTestId, }) => {
|
|
4558
|
-
return isIconOnly ? (jsx(Tooltip, { label: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) || title, placement: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.placement) || "top", children: jsx(IconButton, { className: cvaToggleItem({ className, selected }), "data-testid": dataTestId, disabled: disabled, icon: iconName ? jsx(Icon, { name: iconName, size: "small" }) : null, onClick: onClick, size: size, title: iconName, variant: "secondary" }) })) : (jsx(Tooltip, { disabled: !(text === null || text === void 0 ? void 0 : text.truncate) && (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) === undefined, label: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.content) || title, placement: (tooltip === null || tooltip === void 0 ? void 0 : tooltip.placement) || "top", children: jsx(Button, { className: cvaToggleItem({ className, selected }), "data-testid": dataTestId, disabled: disabled, onClick: onClick, prefix: iconName ? jsx(Icon, { name: iconName, size: "small" }) : null, size: size, variant: "secondary", children: jsx("span", { className: cvaToggleItemText({ disabledAndSelected: disabled && selected, maxWidth: text === null || text === void 0 ? void 0 : text.maxWidth }), children: title }) }) }));
|
|
4559
|
-
};
|
|
4560
|
-
|
|
4561
4808
|
const cvaClickable = cvaMerge([
|
|
4562
4809
|
"shadow-lg",
|
|
4563
4810
|
"rounded-lg",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.391",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"jest-fetch-mock": "^3.0.3",
|
|
23
23
|
"@testing-library/react": "15.0.6",
|
|
24
24
|
"@floating-ui/react": "^0.26.6",
|
|
25
|
-
"@tanstack/react-router": "1.
|
|
25
|
+
"@tanstack/react-router": "1.47.1",
|
|
26
|
+
"react-swipeable": "^7.0.1",
|
|
26
27
|
"string-ts": "^2.0.0",
|
|
27
28
|
"tailwind-merge": "^2.0.0",
|
|
28
29
|
"@trackunit/react-table-pagination": "*",
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { CommonProps } from "../../common";
|
|
3
2
|
export type Position = "left" | "right" | "top" | "bottom";
|
|
4
3
|
export interface DrawerProps extends CommonProps {
|
|
5
4
|
/**
|
|
6
|
-
* Specifies whether the drawer is open or not.
|
|
5
|
+
* Specifies whether the sidebar drawer is open or not.
|
|
7
6
|
*/
|
|
8
|
-
open
|
|
7
|
+
open?: boolean;
|
|
9
8
|
/**
|
|
10
9
|
* The onClose handler for the drawer.
|
|
11
10
|
*/
|
|
12
|
-
onClose?: () => void;
|
|
11
|
+
onClose?: (event: React.MouseEvent | KeyboardEvent) => void;
|
|
12
|
+
/**
|
|
13
|
+
* The handler for toggling the drawer state.
|
|
14
|
+
*/
|
|
15
|
+
onToggle?: (event: React.MouseEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the drawer needs an overlay or not. Without the overlay, user will have to handle mechanism for closing the drawer.
|
|
18
|
+
*/
|
|
19
|
+
disableOverlay?: boolean;
|
|
13
20
|
/**
|
|
14
21
|
* The position of the drawer.
|
|
15
22
|
*/
|
|
@@ -18,15 +25,12 @@ export interface DrawerProps extends CommonProps {
|
|
|
18
25
|
* The child node that will be rendered inside the drawer.
|
|
19
26
|
*/
|
|
20
27
|
children?: React.ReactNode;
|
|
21
|
-
/**
|
|
22
|
-
* Whether the drawer needs an overlay or not. Without the overlay, user will have to handle mechanism for closing the drawer.
|
|
23
|
-
*/
|
|
24
|
-
disableOverlay?: boolean;
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
30
|
+
* MapSidebar is a sidebar component used with Maps.
|
|
31
|
+
* It provides a slide over sidebar drawer which can be used for displaying map related information or controls.
|
|
32
|
+
*
|
|
33
|
+
* @param {DrawerProps} props - The props for the MapSidebar component
|
|
34
|
+
* @returns {JSX.Element | null} Drawer component
|
|
31
35
|
*/
|
|
32
|
-
export declare const Drawer: ({ open,
|
|
36
|
+
export declare const Drawer: ({ open, onToggle, onClose, disableOverlay, position, children, dataTestId, }: DrawerProps) => JSX.Element | null;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const cvaDialog: (props?: ({
|
|
2
|
+
position?: "left" | "right" | "top" | "bottom" | null | undefined;
|
|
3
|
+
sidebarMode?: "closed" | "half" | "full" | null | undefined;
|
|
4
|
+
isLargeScreen?: boolean | null | undefined;
|
|
5
|
+
open?: boolean | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
|
+
export declare const cvaDialogContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
8
|
+
export declare const cvaSwipeContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
9
|
+
export declare const cvaSwipeIcon: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
10
|
+
export declare const cvaToogleContainer: (props?: ({
|
|
11
|
+
position?: "left" | "right" | "top" | "bottom" | null | undefined;
|
|
12
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
13
|
+
export declare const cvaToogleButton: (props?: ({
|
|
14
|
+
position?: "left" | "right" | "top" | "bottom" | null | undefined;
|
|
15
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
16
|
+
export declare const cvaOverlayContainer: (props?: ({
|
|
17
|
+
open?: boolean | null | undefined;
|
|
4
18
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface OverlayProps {
|
|
2
|
+
open: boolean;
|
|
3
|
+
onClose?: (event: React.MouseEvent | KeyboardEvent) => void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Overlay Component
|
|
7
|
+
*
|
|
8
|
+
* @param {object} props - The Overlay component properties
|
|
9
|
+
* @param {boolean} props.open - Open status of the Overlay
|
|
10
|
+
* @param {Function} props.onClose - Callback function when Overlay is closed
|
|
11
|
+
* @returns {JSX.Element|null} The Overlay component
|
|
12
|
+
*/
|
|
13
|
+
declare const Overlay: ({ open, onClose }: OverlayProps) => JSX.Element | null;
|
|
14
|
+
export default Overlay;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Position } from "./Drawer";
|
|
2
|
+
interface ToogleButtonProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onToggle?: (event: React.MouseEvent) => void;
|
|
5
|
+
position: Position;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* ToggleButton is a React functional component that returns a button with a chevron icon.
|
|
9
|
+
* The direction of the chevron changes depending on the state of the 'open' prop and
|
|
10
|
+
* the side the button is positioned ('position' prop).
|
|
11
|
+
* The button might be disabled based on the 'disableButton' prop.
|
|
12
|
+
*
|
|
13
|
+
* @param {object} props - The properties passed to the component
|
|
14
|
+
* @param {boolean} props.open - Indicates if the button is in "open" state
|
|
15
|
+
* @param {Function} [props.onToggle] - Optional callback function for when the button is clicked
|
|
16
|
+
* @param {Position} props.position - The position of the button relative to its container
|
|
17
|
+
*/
|
|
18
|
+
declare const ToogleButton: ({ open, position, onToggle }: ToogleButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export default ToogleButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Drawer";
|
|
@@ -5,7 +5,7 @@ export * from "./Card";
|
|
|
5
5
|
export * from "./Collapse";
|
|
6
6
|
export * from "./CompletionStatusIndicator/CompletionStatusIndicator";
|
|
7
7
|
export * from "./CopyableText";
|
|
8
|
-
export * from "./Drawer
|
|
8
|
+
export * from "./Drawer";
|
|
9
9
|
export * from "./EmptyState/EmptyState";
|
|
10
10
|
export * from "./EmptyValue/EmptyValue";
|
|
11
11
|
export * from "./ExternalLink/ExternalLink";
|
|
@@ -34,9 +34,9 @@ export * from "./Tabs/Tabs";
|
|
|
34
34
|
export * from "./Tag";
|
|
35
35
|
export * from "./Text";
|
|
36
36
|
export * from "./Timeline/Timeline";
|
|
37
|
+
export * from "./ToggleGroup/ToggleGroup";
|
|
37
38
|
export * from "./Tooltip";
|
|
38
39
|
export * from "./ValueBar";
|
|
39
40
|
export * from "./VirtualizedList/VirtualizedList";
|
|
40
41
|
export * from "./Widget";
|
|
41
42
|
export * from "./buttons";
|
|
42
|
-
export * from "./ToggleGroup/ToggleGroup";
|