@trackunit/react-components 0.1.119 → 0.1.126
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/051071830dacb5a2.svg +36 -0
- package/143a6e982b3d1ec9.svg +59 -0
- package/8df3d27593b5fba4.svg +70 -0
- package/building_error.cjs +181 -0
- package/building_error.js +159 -0
- package/index.cjs +533 -338
- package/index.js +531 -341
- package/package.json +4 -3
- package/road_block.cjs +244 -0
- package/road_block.js +222 -0
- package/src/components/EmptyState/EmptyState.d.ts +29 -0
- package/src/components/EmptyState/EmptyState.variants.d.ts +2 -0
- package/src/components/EmptyState/images/index.d.ts +4 -0
- package/src/components/Menu/MenuItem/MenuItem.d.ts +0 -8
- package/src/components/Menu/MenuItem/MenuItem.variants.d.ts +12 -0
- package/src/components/Menu/MenuList/MenuList.d.ts +2 -9
- package/src/components/Menu/MenuList/MenuList.variants.d.ts +4 -0
- package/src/components/Menu/MoreMenu/MoreMenu.variants.d.ts +1 -0
- package/src/components/Modal/Modal.variants.d.ts +5 -0
- package/src/components/Text/Text.variants.d.ts +9 -0
- package/src/components/index.d.ts +1 -0
- package/src/hooks/index.d.ts +2 -2
- package/src/hooks/localStorage/initLocalStorageState.d.ts +9 -0
- package/src/hooks/localStorage/types.d.ts +27 -0
- package/src/hooks/localStorage/useLocalStorage.d.ts +10 -0
- package/src/hooks/localStorage/useLocalStorageEffect.d.ts +11 -0
- package/src/hooks/localStorage/useLocalStorageReducer.d.ts +13 -0
- package/src/hooks/localStorage/validateState.d.ts +13 -0
- package/src/index.d.ts +1 -0
- package/wall_construction.cjs +308 -0
- package/wall_construction.js +286 -0
- package/src/hooks/useLocalStorage.d.ts +0 -9
- package/src/hooks/useLocalStorageReducer.d.ts +0 -7
package/index.cjs
CHANGED
|
@@ -86,6 +86,16 @@ function __rest$1(s, e) {
|
|
|
86
86
|
t[p[i]] = s[p[i]];
|
|
87
87
|
}
|
|
88
88
|
return t;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
92
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
93
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
94
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
95
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
96
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
97
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
98
|
+
});
|
|
89
99
|
}
|
|
90
100
|
|
|
91
101
|
const cvaSpinner = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -444,6 +454,53 @@ const StarButton = ({ starred, onClick }) => {
|
|
|
444
454
|
return (jsxRuntime.jsx("div", { onClick: onClick, "data-test-id": "starred-filter", children: jsxRuntime.jsx(Icon, { name: "StarIcon", color: starred ? "primary" : "neutral", type: starred ? "solid" : "outline", size: "medium" }) }));
|
|
445
455
|
};
|
|
446
456
|
|
|
457
|
+
const cvaText = cssClassVarianceUtilities.cvaMerge(["m-0", "relative", "text-sm", "font-normal"], {
|
|
458
|
+
variants: {
|
|
459
|
+
align: {
|
|
460
|
+
left: "text-left",
|
|
461
|
+
right: "text-right",
|
|
462
|
+
center: "text-center",
|
|
463
|
+
},
|
|
464
|
+
italic: {
|
|
465
|
+
true: "italic",
|
|
466
|
+
false: "",
|
|
467
|
+
},
|
|
468
|
+
uppercase: {
|
|
469
|
+
true: "uppercase",
|
|
470
|
+
false: "",
|
|
471
|
+
},
|
|
472
|
+
underline: {
|
|
473
|
+
true: [
|
|
474
|
+
"underline",
|
|
475
|
+
"after:bg-inherit",
|
|
476
|
+
"after:content-none",
|
|
477
|
+
"after:absolute",
|
|
478
|
+
"after:w-full",
|
|
479
|
+
"after:h-0.5",
|
|
480
|
+
"after:bottom-0",
|
|
481
|
+
"after:left-0",
|
|
482
|
+
],
|
|
483
|
+
false: "",
|
|
484
|
+
},
|
|
485
|
+
weight: {
|
|
486
|
+
normal: "font-normal",
|
|
487
|
+
bold: "font-medium",
|
|
488
|
+
thick: "font-semibold",
|
|
489
|
+
},
|
|
490
|
+
size: {
|
|
491
|
+
small: "text-xs",
|
|
492
|
+
medium: "text-sm",
|
|
493
|
+
large: "text-base",
|
|
494
|
+
},
|
|
495
|
+
color: {
|
|
496
|
+
default: "text-black",
|
|
497
|
+
subtleInverted: "text-neutral-300",
|
|
498
|
+
subtle: "text-neutral-600",
|
|
499
|
+
inverted: "text-white",
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
});
|
|
503
|
+
|
|
447
504
|
/**
|
|
448
505
|
* The Text component is used to apply Trackunit default typography styles to text.
|
|
449
506
|
*
|
|
@@ -455,49 +512,10 @@ const StarButton = ({ starred, onClick }) => {
|
|
|
455
512
|
* @returns {JSX.Element} Text component
|
|
456
513
|
*/
|
|
457
514
|
const Text = ({ children, type = "p", size = "medium", align = "left", weight = "normal", underline = false, inverted = false, subtle = false, italicize = false, uppercase = false, className, dataTestId, }) => {
|
|
458
|
-
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
small: tailwindStyledComponents.tws `tu-text--small`,
|
|
463
|
-
large: tailwindStyledComponents.tws `tu-text--large`,
|
|
464
|
-
medium: null,
|
|
465
|
-
default: null,
|
|
466
|
-
};
|
|
467
|
-
return sizes[$size];
|
|
468
|
-
};
|
|
469
|
-
const getTextWeight = () => ({ $weight }) => {
|
|
470
|
-
const weights = {
|
|
471
|
-
thick: tailwindStyledComponents.tws `tu-text--medium`,
|
|
472
|
-
bold: tailwindStyledComponents.tws `tu-text--semibold`,
|
|
473
|
-
normal: null,
|
|
474
|
-
default: null,
|
|
475
|
-
};
|
|
476
|
-
return weights[$weight];
|
|
477
|
-
};
|
|
478
|
-
const getFontColor = () => ({ $inverted, $subtle }) => {
|
|
479
|
-
const subtle = $inverted ? tailwindStyledComponents.tws `tu-text--subtle-inverted` : tailwindStyledComponents.tws `tu-text--subtle`;
|
|
480
|
-
const inverted = $inverted ? tailwindStyledComponents.tws `tu-text--inverted` : null;
|
|
481
|
-
return $subtle ? subtle : inverted;
|
|
482
|
-
};
|
|
483
|
-
const getTextAlignment = () => ({ $align }) => {
|
|
484
|
-
const alignments = {
|
|
485
|
-
left: tailwindStyledComponents.tws `tu-text--align-left`,
|
|
486
|
-
center: tailwindStyledComponents.tws `tu-text--align-center`,
|
|
487
|
-
right: tailwindStyledComponents.tws `tu-text--align-right`,
|
|
488
|
-
};
|
|
489
|
-
return alignments[$align];
|
|
490
|
-
};
|
|
491
|
-
const StyledText = tailwindStyledComponents.tw.text `
|
|
492
|
-
tu-text
|
|
493
|
-
${getFontColor()}
|
|
494
|
-
${p => (p.$italicize ? tailwindStyledComponents.tws `tu-text--italic` : "")}
|
|
495
|
-
${p => (p.$uppercase ? tailwindStyledComponents.tws `tu-text--uppercase` : "")}
|
|
496
|
-
${getTextAlignment()}
|
|
497
|
-
${p => (p.$underline ? tailwindStyledComponents.tws `tu-text--underline` : "")}
|
|
498
|
-
${getTextSize()}
|
|
499
|
-
${getTextWeight()}
|
|
500
|
-
`;
|
|
515
|
+
const color = inverted && subtle ? "subtleInverted" : inverted ? "inverted" : subtle ? "subtle" : "default";
|
|
516
|
+
return (jsxRuntime.jsx(StyledText, { "$as": type, className: cvaText({ color, uppercase, align, italic: italicize, size, underline, weight, className }), "data-testid": dataTestId, children: children }));
|
|
517
|
+
};
|
|
518
|
+
const StyledText = tailwindStyledComponents.tw.text ``;
|
|
501
519
|
|
|
502
520
|
const cvaAlert = cssClassVarianceUtilities.cvaMerge(["flex", "relative", "p-4", "rounded"], {
|
|
503
521
|
variants: {
|
|
@@ -1092,6 +1110,14 @@ var useCopyToClipboard$1 = useCopyToClipboard;
|
|
|
1092
1110
|
var useIsomorphicLayoutEffect$1 = isBrowser ? React.useLayoutEffect : React.useEffect;
|
|
1093
1111
|
var useIsomorphicLayoutEffect$2 = useIsomorphicLayoutEffect$1;
|
|
1094
1112
|
|
|
1113
|
+
function usePrevious(state) {
|
|
1114
|
+
var ref = React.useRef();
|
|
1115
|
+
React.useEffect(function () {
|
|
1116
|
+
ref.current = state;
|
|
1117
|
+
});
|
|
1118
|
+
return ref.current;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1095
1121
|
var defaultState = {
|
|
1096
1122
|
x: 0,
|
|
1097
1123
|
y: 0,
|
|
@@ -14572,7 +14598,7 @@ function Month(props) {
|
|
|
14572
14598
|
}
|
|
14573
14599
|
|
|
14574
14600
|
/** Render the container with the months according to the number of months to display. */
|
|
14575
|
-
function Root
|
|
14601
|
+
function Root(_a) {
|
|
14576
14602
|
var initialProps = _a.initialProps;
|
|
14577
14603
|
var dayPicker = useDayPicker();
|
|
14578
14604
|
var focusContext = useFocusContext();
|
|
@@ -14715,7 +14741,7 @@ function RootProvider(props) {
|
|
|
14715
14741
|
*/
|
|
14716
14742
|
function DayPicker$1(props) {
|
|
14717
14743
|
return (React__default["default"].createElement(RootProvider, __assign({}, props),
|
|
14718
|
-
React__default["default"].createElement(Root
|
|
14744
|
+
React__default["default"].createElement(Root, { initialProps: props })));
|
|
14719
14745
|
}
|
|
14720
14746
|
|
|
14721
14747
|
const localeLookup = {
|
|
@@ -18804,6 +18830,93 @@ const Drawer = ({ open, onClose = () => { }, children, disableOverlay = false, p
|
|
|
18804
18830
|
jsxRuntime.jsx(jsxRuntime.Fragment, {})) }));
|
|
18805
18831
|
};
|
|
18806
18832
|
|
|
18833
|
+
const cvaSkeletonLine = cssClassVarianceUtilities.cvaMerge([
|
|
18834
|
+
"rounded-md",
|
|
18835
|
+
"h-3",
|
|
18836
|
+
"opacity-20",
|
|
18837
|
+
"animate-pulse",
|
|
18838
|
+
"bg-black/50",
|
|
18839
|
+
"bg-auto",
|
|
18840
|
+
"bg-gradient-to-r",
|
|
18841
|
+
"from-black/0",
|
|
18842
|
+
"via-black/50",
|
|
18843
|
+
"to-black/20",
|
|
18844
|
+
]);
|
|
18845
|
+
|
|
18846
|
+
/**
|
|
18847
|
+
* Display placeholder lines before the data gets loaded to reduce load-time frustration.
|
|
18848
|
+
*/
|
|
18849
|
+
const SkeletonLines = React.memo(({ margin = "10px 0", lines = 1, height, width = "100%", className, dataTestId }) => {
|
|
18850
|
+
const skeletonLines = [];
|
|
18851
|
+
const getWidth = (index) => {
|
|
18852
|
+
if (width instanceof Array) {
|
|
18853
|
+
return width[index] || "100%";
|
|
18854
|
+
}
|
|
18855
|
+
return width;
|
|
18856
|
+
};
|
|
18857
|
+
const getHeight = (index) => {
|
|
18858
|
+
if (height instanceof Array) {
|
|
18859
|
+
return height[index] || "auto";
|
|
18860
|
+
}
|
|
18861
|
+
return height;
|
|
18862
|
+
};
|
|
18863
|
+
for (let i = 0; i < lines; i++) {
|
|
18864
|
+
skeletonLines.push(jsxRuntime.jsx("div", { "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "skeleton-lines", "data-type": "loading-skeleton-line", className: cvaSkeletonLine({ className }), style: { height: getHeight(i), width: getWidth(i), margin: lines > 1 ? margin : "" }, children: lines > 1 && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "\u00A0" }) }, i));
|
|
18865
|
+
}
|
|
18866
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
18867
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: skeletonLines });
|
|
18868
|
+
});
|
|
18869
|
+
|
|
18870
|
+
const containerStyles = cssClassVarianceUtilities.cvaMerge(["flex flex-col items-center gap-5 p-12 text-center justify-center h-full"]);
|
|
18871
|
+
const textStyles = cssClassVarianceUtilities.cvaMerge(["flex flex-col items-center gap-2"]);
|
|
18872
|
+
|
|
18873
|
+
var WorkerWithSign = "8df3d27593b5fba4.svg";
|
|
18874
|
+
|
|
18875
|
+
/**
|
|
18876
|
+
* Component representing an empty state.
|
|
18877
|
+
* Use this component when there is no data to display or when an error occurs.
|
|
18878
|
+
*
|
|
18879
|
+
*
|
|
18880
|
+
* @param {EmptyStateProps} props props
|
|
18881
|
+
* @returns {JSX.Element} component
|
|
18882
|
+
* @example
|
|
18883
|
+
* <EmptyState
|
|
18884
|
+
* title="No results found"
|
|
18885
|
+
* description="Try changing your search criteria"
|
|
18886
|
+
* altText="No results found"
|
|
18887
|
+
* image="BUILDING_ERROR"
|
|
18888
|
+
* />
|
|
18889
|
+
*/
|
|
18890
|
+
const EmptyState = ({ title, description, altText, image, customImageSrc, action, loading, dataTestId, className, }) => {
|
|
18891
|
+
const [imageSource, setImageSource] = React.useState(WorkerWithSign);
|
|
18892
|
+
React.useEffect(() => {
|
|
18893
|
+
const lazyLoadImage = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18894
|
+
let importedImage = null;
|
|
18895
|
+
switch (image) {
|
|
18896
|
+
case "WORKER_WITH_SIGN":
|
|
18897
|
+
importedImage = WorkerWithSign;
|
|
18898
|
+
break;
|
|
18899
|
+
case "ROAD_BLOCK":
|
|
18900
|
+
importedImage = (yield Promise.resolve().then(function () { return require('./road_block.cjs'); })).default;
|
|
18901
|
+
break;
|
|
18902
|
+
case "BUILDING_ERROR":
|
|
18903
|
+
importedImage = (yield Promise.resolve().then(function () { return require('./building_error.cjs'); })).default;
|
|
18904
|
+
break;
|
|
18905
|
+
case "WALL_CONSTRUCTION":
|
|
18906
|
+
importedImage = (yield Promise.resolve().then(function () { return require('./wall_construction.cjs'); })).default;
|
|
18907
|
+
break;
|
|
18908
|
+
default:
|
|
18909
|
+
importedImage = WorkerWithSign;
|
|
18910
|
+
}
|
|
18911
|
+
setImageSource(importedImage);
|
|
18912
|
+
});
|
|
18913
|
+
if (!customImageSrc && image) {
|
|
18914
|
+
lazyLoadImage();
|
|
18915
|
+
}
|
|
18916
|
+
}, [customImageSrc, image]);
|
|
18917
|
+
return (jsxRuntime.jsx("div", { className: `${containerStyles()} ${className}`, "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "empty-state", children: loading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Spinner, { dataTestId: "spinner", size: "large", centering: "centered" }), jsxRuntime.jsx(SkeletonLines, { dataTestId: "skeleton-lines", width: 50 })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("img", { src: customImageSrc ? customImageSrc : imageSource, alt: altText }), jsxRuntime.jsxs("div", { className: textStyles(), children: [jsxRuntime.jsx(Heading, { variant: "secondary", children: title }), jsxRuntime.jsx(Text, { align: "center", children: description })] }), action] })) }));
|
|
18918
|
+
};
|
|
18919
|
+
|
|
18807
18920
|
/**
|
|
18808
18921
|
* The external link component is used to link to an external page outside the Trackunit Manager.
|
|
18809
18922
|
*
|
|
@@ -18915,6 +19028,68 @@ const Indicator = (_a) => {
|
|
|
18915
19028
|
return (jsxRuntime.jsxs("div", Object.assign({ className: cvaIndicator({ className }), "data-testid": dataTestId }, rest, { title: !withLabel ? label : undefined, children: [jsxRuntime.jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping && (jsxRuntime.jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })), icon] }), label !== undefined && withLabel && (jsxRuntime.jsx("div", { className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label", children: label }))] })));
|
|
18916
19029
|
};
|
|
18917
19030
|
|
|
19031
|
+
const cvaMenuItem = cssClassVarianceUtilities.cvaMerge([
|
|
19032
|
+
"py-2",
|
|
19033
|
+
"pl-2",
|
|
19034
|
+
"pr-3",
|
|
19035
|
+
"w-full",
|
|
19036
|
+
"h-auto",
|
|
19037
|
+
"cursor-pointer",
|
|
19038
|
+
"flex",
|
|
19039
|
+
"flex-row",
|
|
19040
|
+
"items-center",
|
|
19041
|
+
"gap-x-2",
|
|
19042
|
+
"select-none",
|
|
19043
|
+
"rounded",
|
|
19044
|
+
"hover:bg-slate-100",
|
|
19045
|
+
], {
|
|
19046
|
+
variants: {
|
|
19047
|
+
selected: {
|
|
19048
|
+
true: "bg-primary-100 hover:bg-primary-200",
|
|
19049
|
+
false: "",
|
|
19050
|
+
},
|
|
19051
|
+
disabled: {
|
|
19052
|
+
true: "!bg-slate-100 pointer-events-none",
|
|
19053
|
+
false: "",
|
|
19054
|
+
},
|
|
19055
|
+
focused: {
|
|
19056
|
+
true: "bg-slate-100",
|
|
19057
|
+
false: "",
|
|
19058
|
+
},
|
|
19059
|
+
},
|
|
19060
|
+
compoundVariants: [
|
|
19061
|
+
{
|
|
19062
|
+
focused: true,
|
|
19063
|
+
selected: true,
|
|
19064
|
+
className: "bg-primary-200",
|
|
19065
|
+
},
|
|
19066
|
+
],
|
|
19067
|
+
});
|
|
19068
|
+
const cvaMenuItemLabel = cssClassVarianceUtilities.cvaMerge([
|
|
19069
|
+
"flex-grow",
|
|
19070
|
+
"text-gray-700",
|
|
19071
|
+
"text-ellipsis",
|
|
19072
|
+
"truncate",
|
|
19073
|
+
"group-hover:text-gray-900",
|
|
19074
|
+
"group-active:text-gray-700",
|
|
19075
|
+
]);
|
|
19076
|
+
const cvaMenuItemSuffix = cssClassVarianceUtilities.cvaMerge(["self-center", "flex-grow-0", "text-slate-400"], {
|
|
19077
|
+
variants: {
|
|
19078
|
+
selected: {
|
|
19079
|
+
true: "text-primary-600 hover:text-primary-700",
|
|
19080
|
+
false: "",
|
|
19081
|
+
},
|
|
19082
|
+
},
|
|
19083
|
+
});
|
|
19084
|
+
const cvaMenuItemPrefix = cssClassVarianceUtilities.cvaMerge(["self-center", "flex-grow-0", "text-slate-400", "group-hover:text-slate-600"], {
|
|
19085
|
+
variants: {
|
|
19086
|
+
selected: {
|
|
19087
|
+
true: "text-primary-600 hover:text-primary-700",
|
|
19088
|
+
false: "",
|
|
19089
|
+
},
|
|
19090
|
+
},
|
|
19091
|
+
});
|
|
19092
|
+
|
|
18918
19093
|
/**
|
|
18919
19094
|
* The MenuItem component is used to display a menu, primarily meant to be used in a list form.
|
|
18920
19095
|
*
|
|
@@ -18922,30 +19097,32 @@ const Indicator = (_a) => {
|
|
|
18922
19097
|
* @returns {JSX.Element} MenuItem component
|
|
18923
19098
|
*/
|
|
18924
19099
|
const MenuItem = ({ className, dataTestId, label, children, selected, focused, prefix, suffix, disabled, onClick, }) => {
|
|
18925
|
-
const containerProps = useContainerProps({ className, dataTestId });
|
|
18926
|
-
return (jsxRuntime.jsxs(
|
|
19100
|
+
const containerProps = useContainerProps({ className, dataTestId: dataTestId || "menu-item" });
|
|
19101
|
+
return (jsxRuntime.jsxs("div", Object.assign({}, containerProps, { className: cvaMenuItem({
|
|
19102
|
+
selected,
|
|
19103
|
+
focused,
|
|
19104
|
+
disabled,
|
|
19105
|
+
className: containerProps.className,
|
|
19106
|
+
}), onClick: e => {
|
|
18927
19107
|
e.stopPropagation();
|
|
18928
19108
|
onClick && onClick(e);
|
|
18929
|
-
},
|
|
19109
|
+
}, tabIndex: 0, children: [prefix && (jsxRuntime.jsx("div", { className: cvaMenuItemPrefix({ selected }), "data-testid": dataTestId && `${dataTestId}-prefix`, children: prefix })), children && typeof children !== "string" ? (children) : (jsxRuntime.jsx("div", { className: cvaMenuItemLabel(), "data-testid": dataTestId && `${dataTestId}-label`, children: children !== null && children !== void 0 ? children : label })), suffix && (jsxRuntime.jsx("div", { className: cvaMenuItemSuffix({ selected }), "data-testid": dataTestId && `${dataTestId}-suffix`, children: suffix }))] })));
|
|
18930
19110
|
};
|
|
18931
|
-
const Container$1 = tailwindStyledComponents.tw.div `
|
|
18932
|
-
group tu-menu-item
|
|
18933
|
-
${({ $selected }) => ($selected ? tailwindStyledComponents.tws `tu-menu-item--selected ` : "tu-menu-item--unselected")}
|
|
18934
|
-
${({ $focused }) => ($focused ? tailwindStyledComponents.tws `tu-menu-item--focused ` : "")}
|
|
18935
|
-
${({ $disabled }) => ($disabled ? tailwindStyledComponents.tws `tu-menu-item--disabled ` : "")}
|
|
18936
19111
|
|
|
18937
|
-
|
|
18938
|
-
|
|
18939
|
-
|
|
18940
|
-
|
|
18941
|
-
|
|
18942
|
-
|
|
18943
|
-
|
|
18944
|
-
|
|
18945
|
-
|
|
18946
|
-
|
|
18947
|
-
|
|
18948
|
-
|
|
19112
|
+
const cvaMenuList = cssClassVarianceUtilities.cvaMerge(["shadow-md", "rounded-lg", "z-20", "bg-white", "p-1", "border", "border-slate-300", "gap-1", "grid"], {
|
|
19113
|
+
variants: {
|
|
19114
|
+
stickyHeader: {
|
|
19115
|
+
true: "grid grid-rows-min-fr !p-0",
|
|
19116
|
+
false: "",
|
|
19117
|
+
},
|
|
19118
|
+
},
|
|
19119
|
+
});
|
|
19120
|
+
const cvaMenuListDivider = cssClassVarianceUtilities.cvaMerge([
|
|
19121
|
+
"file:w-full",
|
|
19122
|
+
"selection:col-span-full",
|
|
19123
|
+
"selection:h-px",
|
|
19124
|
+
"selection:bg-slate-200",
|
|
19125
|
+
]);
|
|
18949
19126
|
|
|
18950
19127
|
/**
|
|
18951
19128
|
* The MenuList component is used for menus and selects.
|
|
@@ -18957,211 +19134,62 @@ const MenuList = (_a) => {
|
|
|
18957
19134
|
var { dataTestId, className, children, withStickyHeader = false, showDivider = false } = _a; __rest$1(_a, ["dataTestId", "className", "children", "withStickyHeader", "showDivider"]);
|
|
18958
19135
|
const childrenArr = React.Children.toArray(children);
|
|
18959
19136
|
const isLastItem = (index) => index === childrenArr.length - 1;
|
|
18960
|
-
return (jsxRuntime.jsx(
|
|
18961
|
-
};
|
|
18962
|
-
const Container = tailwindStyledComponents.tw.div `
|
|
18963
|
-
tu-menu-list
|
|
18964
|
-
${props => props.$withStickyHeader && tailwindStyledComponents.tws `tu-menu-list--sticky-header`}
|
|
18965
|
-
`;
|
|
18966
|
-
const Divider = tailwindStyledComponents.tw.hr `
|
|
18967
|
-
tu-menu-list__divider
|
|
18968
|
-
`;
|
|
18969
|
-
|
|
18970
|
-
/**
|
|
18971
|
-
* Custom hook to handle click outside events.
|
|
18972
|
-
*
|
|
18973
|
-
* @param {RefObject<HTMLElement> | Array<RefObject<HTMLElement>>} el - The reference(s) to the element(s) to watch for click outside events.
|
|
18974
|
-
* @param {Object | Function} [options={}] - Configuration options or the click event handler if options are not provided.
|
|
18975
|
-
* @param {boolean} [options.active=true] - Whether the click outside event listener should be active.
|
|
18976
|
-
* @param {Function} [onClick] - The event handler for the click outside event.
|
|
18977
|
-
*/
|
|
18978
|
-
const useClickOutside = (el, options = {}, onClick) => {
|
|
18979
|
-
const els = Array.isArray(el) ? el : [el];
|
|
18980
|
-
let active = true;
|
|
18981
|
-
if (!onClick && typeof options === "function") {
|
|
18982
|
-
onClick = options;
|
|
18983
|
-
}
|
|
18984
|
-
else if (typeof options === "object") {
|
|
18985
|
-
active = options.active !== undefined ? options.active : active;
|
|
18986
|
-
}
|
|
18987
|
-
const handler = (ev) => {
|
|
18988
|
-
const target = ev.target;
|
|
18989
|
-
if (els.every(ref => !ref.current || !ref.current.contains(target))) {
|
|
18990
|
-
onClick && onClick(ev);
|
|
18991
|
-
}
|
|
18992
|
-
};
|
|
18993
|
-
const cleanup = () => window.removeEventListener("click", handler);
|
|
18994
|
-
React.useEffect(() => {
|
|
18995
|
-
if (active) {
|
|
18996
|
-
window.addEventListener("click", handler);
|
|
18997
|
-
}
|
|
18998
|
-
else {
|
|
18999
|
-
cleanup();
|
|
19000
|
-
}
|
|
19001
|
-
return cleanup;
|
|
19002
|
-
});
|
|
19137
|
+
return (jsxRuntime.jsx("div", { "data-testid": dataTestId, className: cvaMenuList({ stickyHeader: withStickyHeader, className }), tabIndex: 0, role: "list", children: React.Children.map(childrenArr, (menuItem, index) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [menuItem, showDivider && !isLastItem(index) && jsxRuntime.jsx("hr", { className: cvaMenuListDivider() })] }))) }));
|
|
19003
19138
|
};
|
|
19004
19139
|
|
|
19005
19140
|
/**
|
|
19006
|
-
*
|
|
19141
|
+
* Validates the state object using a Zod schema.
|
|
19007
19142
|
*
|
|
19008
|
-
* @
|
|
19009
|
-
* @param {
|
|
19010
|
-
* @
|
|
19011
|
-
* @returns {any} The latest value received
|
|
19143
|
+
* @template State - The type of the state.
|
|
19144
|
+
* @param {ValidateStateOptions<State>} params - The parameters for the validateState function.
|
|
19145
|
+
* @returns {boolean} - `true` if the state is valid according to the schema, `false` otherwise.
|
|
19012
19146
|
*/
|
|
19013
|
-
|
|
19014
|
-
|
|
19015
|
-
|
|
19016
|
-
|
|
19017
|
-
|
|
19018
|
-
React.useEffect(() => {
|
|
19019
|
-
let handler;
|
|
19020
|
-
if ((direction === "in" && !debouncedValue && value) ||
|
|
19021
|
-
(direction === "out" && debouncedValue && !value) ||
|
|
19022
|
-
direction === "both" ||
|
|
19023
|
-
!direction) {
|
|
19024
|
-
handler = setTimeout(() => {
|
|
19025
|
-
setDebouncedValue(value);
|
|
19026
|
-
}, delay);
|
|
19147
|
+
const validateState = ({ state, schema, onValidationFailed, onValidationSuccessful, }) => {
|
|
19148
|
+
try {
|
|
19149
|
+
schema.parse(state);
|
|
19150
|
+
if (onValidationSuccessful) {
|
|
19151
|
+
onValidationSuccessful();
|
|
19027
19152
|
}
|
|
19028
|
-
|
|
19029
|
-
|
|
19153
|
+
return true;
|
|
19154
|
+
}
|
|
19155
|
+
catch (error) {
|
|
19156
|
+
// eslint-disable-next-line no-console
|
|
19157
|
+
console.error("State validation failed.", error);
|
|
19158
|
+
if (onValidationFailed) {
|
|
19159
|
+
onValidationFailed(error);
|
|
19030
19160
|
}
|
|
19031
|
-
return
|
|
19032
|
-
|
|
19033
|
-
};
|
|
19034
|
-
}, [value, delay, direction, debouncedValue]);
|
|
19035
|
-
return debouncedValue;
|
|
19161
|
+
return false;
|
|
19162
|
+
}
|
|
19036
19163
|
};
|
|
19037
19164
|
|
|
19038
|
-
// Copied from https://github.com/rexxars/use-device-pixel-ratio
|
|
19039
19165
|
/**
|
|
19040
|
-
*
|
|
19041
|
-
* Will emit new values if it changes.
|
|
19166
|
+
* Initializes the state from local storage, parsing and validating it if a Zod schema is provided.
|
|
19042
19167
|
*
|
|
19043
|
-
* @
|
|
19044
|
-
* @
|
|
19168
|
+
* @template State - The type of the state stored in local storage.
|
|
19169
|
+
* @param {Omit<LocalStorageParams<State>, "state">} params - The parameters for initializing the local storage state.
|
|
19170
|
+
* @returns {State} - The initialized state.
|
|
19045
19171
|
*/
|
|
19046
|
-
|
|
19047
|
-
const
|
|
19048
|
-
|
|
19049
|
-
|
|
19050
|
-
|
|
19051
|
-
|
|
19052
|
-
|
|
19053
|
-
|
|
19054
|
-
|
|
19055
|
-
const updateDpr = () => setCurrentDpr(getDevicePixelRatio({ defaultDpr, maxDpr, round }));
|
|
19056
|
-
const mediaMatcher = window.matchMedia(`screen and (resolution: ${currentDpr}dppx)`);
|
|
19057
|
-
// Safari 13.1 does not have `addEventListener`, but does have `addListener`
|
|
19058
|
-
if (mediaMatcher.addEventListener) {
|
|
19059
|
-
mediaMatcher.addEventListener("change", updateDpr);
|
|
19060
|
-
}
|
|
19061
|
-
else {
|
|
19062
|
-
mediaMatcher.addListener(updateDpr);
|
|
19063
|
-
}
|
|
19064
|
-
return () => {
|
|
19065
|
-
if (mediaMatcher.removeEventListener) {
|
|
19066
|
-
mediaMatcher.removeEventListener("change", updateDpr);
|
|
19172
|
+
const initLocalStorageState = ({ key, defaultState, schema, }) => {
|
|
19173
|
+
const localStorageItem = localStorage.getItem(key);
|
|
19174
|
+
if (localStorageItem) {
|
|
19175
|
+
try {
|
|
19176
|
+
const parsedState = JSON.parse(localStorageItem);
|
|
19177
|
+
if (schema) {
|
|
19178
|
+
if (validateState({ state: parsedState, schema })) {
|
|
19179
|
+
return parsedState;
|
|
19180
|
+
}
|
|
19067
19181
|
}
|
|
19068
19182
|
else {
|
|
19069
|
-
|
|
19183
|
+
return parsedState;
|
|
19070
19184
|
}
|
|
19071
|
-
};
|
|
19072
|
-
}, [currentDpr, defaultDpr, maxDpr, round]);
|
|
19073
|
-
return currentDpr;
|
|
19074
|
-
}
|
|
19075
|
-
/**
|
|
19076
|
-
* Returns the current device pixel ratio (DPR) given the passed options
|
|
19077
|
-
*
|
|
19078
|
-
* @param { DevicePixelRatioOptions } options the options object
|
|
19079
|
-
* @returns { number } current device pixel ratio
|
|
19080
|
-
*/
|
|
19081
|
-
function getDevicePixelRatio(options) {
|
|
19082
|
-
const { defaultDpr = 1, maxDpr = 3, round = true } = options || {};
|
|
19083
|
-
const hasDprProp = typeof window !== "undefined" && typeof window.devicePixelRatio === "number";
|
|
19084
|
-
const dpr = hasDprProp ? window.devicePixelRatio : defaultDpr;
|
|
19085
|
-
const rounded = Math.min(Math.max(1, round ? Math.floor(dpr) : dpr), maxDpr);
|
|
19086
|
-
return rounded;
|
|
19087
|
-
}
|
|
19088
|
-
|
|
19089
|
-
/**
|
|
19090
|
-
* The useHover hook returns a onMouseEnter, onMouseLeave and a boolean indicating whether the element is being hovered.
|
|
19091
|
-
* The boolean will be true if the element is being hovered, and false if it is not.
|
|
19092
|
-
* Can be directionally debounced.
|
|
19093
|
-
*
|
|
19094
|
-
* @param {ConditionalUseHoverProps} param0 The options
|
|
19095
|
-
* @returns {Object} The object containing the onMouseEnter, onMouseLeave and hovering props
|
|
19096
|
-
*/
|
|
19097
|
-
const useHover = ({ debounced = false, delay = 100, direction = "out" } = { debounced: false }) => {
|
|
19098
|
-
const [hovering, setHovering] = React.useState(false);
|
|
19099
|
-
const debouncedHovering = useDebounce(hovering, delay, direction);
|
|
19100
|
-
const onMouseEnter = () => {
|
|
19101
|
-
setHovering(true);
|
|
19102
|
-
};
|
|
19103
|
-
const onMouseLeave = () => {
|
|
19104
|
-
setHovering(false);
|
|
19105
|
-
};
|
|
19106
|
-
return { onMouseEnter, onMouseLeave, hovering: debounced ? debouncedHovering : hovering };
|
|
19107
|
-
};
|
|
19108
|
-
|
|
19109
|
-
/**
|
|
19110
|
-
* Differentiate between the first and subsequent renders.
|
|
19111
|
-
*
|
|
19112
|
-
* @returns {boolean} Returns true if it is the first render, false otherwise.
|
|
19113
|
-
*/
|
|
19114
|
-
const useIsFirstRender = () => {
|
|
19115
|
-
const renderRef = React.useRef(true);
|
|
19116
|
-
if (renderRef.current === true) {
|
|
19117
|
-
renderRef.current = false;
|
|
19118
|
-
return true;
|
|
19119
|
-
}
|
|
19120
|
-
return renderRef.current;
|
|
19121
|
-
};
|
|
19122
|
-
|
|
19123
|
-
/**
|
|
19124
|
-
* The useLocalStorage hook works like useState, but saves to localstorage.
|
|
19125
|
-
*
|
|
19126
|
-
* @param {string} key - The key the values is saved under.
|
|
19127
|
-
* @param {string | null | undefined} initialValue - The initial value for the state/local storage item
|
|
19128
|
-
* @returns {string | null | undefined} value
|
|
19129
|
-
*/
|
|
19130
|
-
const useLocalStorage = (key, initialValue) => {
|
|
19131
|
-
if (!key) {
|
|
19132
|
-
throw new Error("useLocalStorage key may not be falsy");
|
|
19133
|
-
}
|
|
19134
|
-
const setLocalStorageItem = React.useCallback((value) => window.localStorage.setItem(key, typeof value === "object" ? JSON.stringify(value) : `${value}`), [key]);
|
|
19135
|
-
const removeLocalStorageItem = React.useCallback(() => window.localStorage.removeItem(key), [key]);
|
|
19136
|
-
const [item, setValue] = React.useState(() => {
|
|
19137
|
-
const value = window.localStorage.getItem(key);
|
|
19138
|
-
if (value !== undefined && value !== null) {
|
|
19139
|
-
const parsedValue = tryParse(value);
|
|
19140
|
-
return parsedValue;
|
|
19141
|
-
}
|
|
19142
|
-
return initialValue !== null && initialValue !== void 0 ? initialValue : null;
|
|
19143
|
-
});
|
|
19144
|
-
React.useEffect(() => {
|
|
19145
|
-
if (item !== undefined && item !== null) {
|
|
19146
|
-
setLocalStorageItem(item);
|
|
19147
19185
|
}
|
|
19148
|
-
|
|
19149
|
-
|
|
19186
|
+
catch (error) {
|
|
19187
|
+
// eslint-disable-next-line no-console
|
|
19188
|
+
console.error("Failed to parse and validate the state from local storage.", error);
|
|
19150
19189
|
}
|
|
19151
|
-
}, [item, setLocalStorageItem, removeLocalStorageItem, key]);
|
|
19152
|
-
const removeItem = () => {
|
|
19153
|
-
setValue(null);
|
|
19154
|
-
};
|
|
19155
|
-
return [item, setValue, removeItem];
|
|
19156
|
-
};
|
|
19157
|
-
function tryParse(value) {
|
|
19158
|
-
try {
|
|
19159
|
-
return JSON.parse(value);
|
|
19160
19190
|
}
|
|
19161
|
-
|
|
19162
|
-
|
|
19163
|
-
}
|
|
19164
|
-
}
|
|
19191
|
+
return defaultState;
|
|
19192
|
+
};
|
|
19165
19193
|
|
|
19166
19194
|
var lodash = {exports: {}};
|
|
19167
19195
|
|
|
@@ -36365,47 +36393,229 @@ var lodash = {exports: {}};
|
|
|
36365
36393
|
}(lodash, lodash.exports));
|
|
36366
36394
|
|
|
36367
36395
|
/**
|
|
36368
|
-
*
|
|
36396
|
+
* Custom hook for synchronizing a state variable with local storage,
|
|
36397
|
+
* with optional schema validation and callbacks.
|
|
36398
|
+
*
|
|
36399
|
+
* @template State - The type of the state variable.
|
|
36400
|
+
* @param {LocalStorageParams<State> & LocalStorageCallbacks & { state: State }} params - The parameters for the useLocalStorageEffect hook.
|
|
36369
36401
|
*/
|
|
36370
|
-
|
|
36371
|
-
|
|
36372
|
-
const ref = React.useRef();
|
|
36402
|
+
const useLocalStorageEffect = ({ key, state, defaultState, schema, onValidationFailed, onValidationSuccessful, }) => {
|
|
36403
|
+
const prevState = usePrevious(state);
|
|
36373
36404
|
React.useEffect(() => {
|
|
36374
|
-
|
|
36405
|
+
if (lodash.exports.isEqual(prevState, state)) {
|
|
36406
|
+
return;
|
|
36407
|
+
}
|
|
36408
|
+
if (schema) {
|
|
36409
|
+
validateState({
|
|
36410
|
+
state,
|
|
36411
|
+
schema,
|
|
36412
|
+
onValidationFailed: error => {
|
|
36413
|
+
// eslint-disable-next-line no-console
|
|
36414
|
+
console.error(`State validation failed. Resetting local storage to default state: ${defaultState}.`, error);
|
|
36415
|
+
localStorage.removeItem(key);
|
|
36416
|
+
onValidationFailed === null || onValidationFailed === void 0 ? void 0 : onValidationFailed(error);
|
|
36417
|
+
},
|
|
36418
|
+
onValidationSuccessful: () => {
|
|
36419
|
+
const stringifiedState = JSON.stringify(state);
|
|
36420
|
+
localStorage.setItem(key, stringifiedState);
|
|
36421
|
+
onValidationSuccessful === null || onValidationSuccessful === void 0 ? void 0 : onValidationSuccessful();
|
|
36422
|
+
},
|
|
36423
|
+
});
|
|
36424
|
+
}
|
|
36425
|
+
else {
|
|
36426
|
+
const stringifiedState = JSON.stringify(state);
|
|
36427
|
+
localStorage.setItem(key, stringifiedState);
|
|
36428
|
+
}
|
|
36429
|
+
}, [state, key, schema, defaultState, prevState, onValidationFailed, onValidationSuccessful]);
|
|
36430
|
+
};
|
|
36431
|
+
|
|
36432
|
+
/**
|
|
36433
|
+
* Works like a normal useState, but saves to local storage and has optional schema validation.
|
|
36434
|
+
*
|
|
36435
|
+
* @template State - The type of the value stored in local storage.
|
|
36436
|
+
* @param {Omit<LocalStorageParams<State>, "state"> & LocalStorageCallbacks} options - The options for useLocalStorage.
|
|
36437
|
+
* @returns {[State, Dispatch<SetStateAction<State>>, () => void]} - A tuple containing the current value, a function to update the value, and a function to remove the value from local storage.
|
|
36438
|
+
*/
|
|
36439
|
+
const useLocalStorage = ({ key, defaultState, schema, onValidationFailed, onValidationSuccessful, }) => {
|
|
36440
|
+
if (!key) {
|
|
36441
|
+
throw new Error("useLocalStorage key may not be falsy");
|
|
36442
|
+
}
|
|
36443
|
+
const [state, setState] = React.useState(initLocalStorageState({ key, defaultState, schema }));
|
|
36444
|
+
useLocalStorageEffect({ key, state, defaultState, schema, onValidationFailed, onValidationSuccessful });
|
|
36445
|
+
const reset = () => {
|
|
36446
|
+
setState(defaultState);
|
|
36447
|
+
};
|
|
36448
|
+
return [state, setState, reset];
|
|
36449
|
+
};
|
|
36450
|
+
|
|
36451
|
+
/**
|
|
36452
|
+
* Works like a normal useReducer, but saves to local storage and has optional schema validation.
|
|
36453
|
+
*
|
|
36454
|
+
* @template State - The type of the state.
|
|
36455
|
+
* @template Action - The type of the action.
|
|
36456
|
+
* @param {LocalStorageParams<State> & LocalStorageCallbacks} params - The parameters for the useLocalStorageReducer function.
|
|
36457
|
+
* @returns {[State, Dispatch<Action>]} - A tuple containing the state and the dispatch function.
|
|
36458
|
+
*/
|
|
36459
|
+
const useLocalStorageReducer = ({ key, defaultState, reducer, schema, onValidationFailed, onValidationSuccessful, }) => {
|
|
36460
|
+
if (!key) {
|
|
36461
|
+
throw new Error("useLocalStorage key may not be falsy");
|
|
36462
|
+
}
|
|
36463
|
+
const [state, dispatch] = React.useReducer(reducer, defaultState, () => initLocalStorageState({ key, defaultState, schema }));
|
|
36464
|
+
useLocalStorageEffect({ key, state, defaultState, schema, onValidationFailed, onValidationSuccessful });
|
|
36465
|
+
return [state, dispatch];
|
|
36466
|
+
};
|
|
36467
|
+
|
|
36468
|
+
/**
|
|
36469
|
+
* Custom hook to handle click outside events.
|
|
36470
|
+
*
|
|
36471
|
+
* @param {RefObject<HTMLElement> | Array<RefObject<HTMLElement>>} el - The reference(s) to the element(s) to watch for click outside events.
|
|
36472
|
+
* @param {Object | Function} [options={}] - Configuration options or the click event handler if options are not provided.
|
|
36473
|
+
* @param {boolean} [options.active=true] - Whether the click outside event listener should be active.
|
|
36474
|
+
* @param {Function} [onClick] - The event handler for the click outside event.
|
|
36475
|
+
*/
|
|
36476
|
+
const useClickOutside = (el, options = {}, onClick) => {
|
|
36477
|
+
const els = Array.isArray(el) ? el : [el];
|
|
36478
|
+
let active = true;
|
|
36479
|
+
if (!onClick && typeof options === "function") {
|
|
36480
|
+
onClick = options;
|
|
36481
|
+
}
|
|
36482
|
+
else if (typeof options === "object") {
|
|
36483
|
+
active = options.active !== undefined ? options.active : active;
|
|
36484
|
+
}
|
|
36485
|
+
const handler = (ev) => {
|
|
36486
|
+
const target = ev.target;
|
|
36487
|
+
if (els.every(ref => !ref.current || !ref.current.contains(target))) {
|
|
36488
|
+
onClick && onClick(ev);
|
|
36489
|
+
}
|
|
36490
|
+
};
|
|
36491
|
+
const cleanup = () => window.removeEventListener("click", handler);
|
|
36492
|
+
React.useEffect(() => {
|
|
36493
|
+
if (active) {
|
|
36494
|
+
window.addEventListener("click", handler);
|
|
36495
|
+
}
|
|
36496
|
+
else {
|
|
36497
|
+
cleanup();
|
|
36498
|
+
}
|
|
36499
|
+
return cleanup;
|
|
36375
36500
|
});
|
|
36376
|
-
|
|
36377
|
-
|
|
36501
|
+
};
|
|
36502
|
+
|
|
36378
36503
|
/**
|
|
36379
|
-
*
|
|
36504
|
+
* The useDebounce hook works like useState, but adds a delay where previous values will be ignored.
|
|
36380
36505
|
*
|
|
36381
|
-
* @param {
|
|
36506
|
+
* @param {any} value The value to set
|
|
36507
|
+
* @param {number} delay The debounce time
|
|
36508
|
+
* @param {"in" | "out" | "both"} direction Considers truthiness of value. If set to "in", the value will only be debounced if it is truthy. If set to "out", the value will only be debounced if it is falsy. If set to "both" or if not defined, the value will be debounced regardless of truthiness.
|
|
36509
|
+
* @returns {any} The latest value received
|
|
36382
36510
|
*/
|
|
36383
|
-
|
|
36384
|
-
|
|
36385
|
-
|
|
36386
|
-
|
|
36387
|
-
|
|
36388
|
-
|
|
36389
|
-
|
|
36390
|
-
|
|
36391
|
-
|
|
36392
|
-
|
|
36393
|
-
|
|
36394
|
-
|
|
36511
|
+
/**
|
|
36512
|
+
*
|
|
36513
|
+
*/
|
|
36514
|
+
const useDebounce = (value, delay = 500, direction) => {
|
|
36515
|
+
const [debouncedValue, setDebouncedValue] = React.useState(value);
|
|
36516
|
+
React.useEffect(() => {
|
|
36517
|
+
let handler;
|
|
36518
|
+
if ((direction === "in" && !debouncedValue && value) ||
|
|
36519
|
+
(direction === "out" && debouncedValue && !value) ||
|
|
36520
|
+
direction === "both" ||
|
|
36521
|
+
!direction) {
|
|
36522
|
+
handler = setTimeout(() => {
|
|
36523
|
+
setDebouncedValue(value);
|
|
36524
|
+
}, delay);
|
|
36395
36525
|
}
|
|
36396
36526
|
else {
|
|
36397
|
-
|
|
36527
|
+
setDebouncedValue(value);
|
|
36398
36528
|
}
|
|
36399
|
-
|
|
36400
|
-
|
|
36401
|
-
|
|
36529
|
+
return () => {
|
|
36530
|
+
clearTimeout(handler);
|
|
36531
|
+
};
|
|
36532
|
+
}, [value, delay, direction, debouncedValue]);
|
|
36533
|
+
return debouncedValue;
|
|
36534
|
+
};
|
|
36535
|
+
|
|
36536
|
+
// Copied from https://github.com/rexxars/use-device-pixel-ratio
|
|
36537
|
+
/**
|
|
36538
|
+
* Get the device pixel ratio, potentially rounded and capped.
|
|
36539
|
+
* Will emit new values if it changes.
|
|
36540
|
+
*
|
|
36541
|
+
* @param {DevicePixelRatioOptions} options the options object
|
|
36542
|
+
* @returns { number } The current device pixel ratio, or the default if none can be resolved
|
|
36543
|
+
*/
|
|
36544
|
+
function useDevicePixelRatio(options) {
|
|
36545
|
+
const dpr = getDevicePixelRatio(options);
|
|
36546
|
+
const [currentDpr, setCurrentDpr] = React.useState(dpr);
|
|
36547
|
+
const { defaultDpr, maxDpr, round } = options || {};
|
|
36402
36548
|
React.useEffect(() => {
|
|
36403
|
-
|
|
36404
|
-
|
|
36405
|
-
|
|
36549
|
+
const canListen = typeof window !== "undefined" && "matchMedia" in window;
|
|
36550
|
+
if (!canListen) {
|
|
36551
|
+
return;
|
|
36406
36552
|
}
|
|
36407
|
-
|
|
36408
|
-
|
|
36553
|
+
const updateDpr = () => setCurrentDpr(getDevicePixelRatio({ defaultDpr, maxDpr, round }));
|
|
36554
|
+
const mediaMatcher = window.matchMedia(`screen and (resolution: ${currentDpr}dppx)`);
|
|
36555
|
+
// Safari 13.1 does not have `addEventListener`, but does have `addListener`
|
|
36556
|
+
if (mediaMatcher.addEventListener) {
|
|
36557
|
+
mediaMatcher.addEventListener("change", updateDpr);
|
|
36558
|
+
}
|
|
36559
|
+
else {
|
|
36560
|
+
mediaMatcher.addListener(updateDpr);
|
|
36561
|
+
}
|
|
36562
|
+
return () => {
|
|
36563
|
+
if (mediaMatcher.removeEventListener) {
|
|
36564
|
+
mediaMatcher.removeEventListener("change", updateDpr);
|
|
36565
|
+
}
|
|
36566
|
+
else {
|
|
36567
|
+
mediaMatcher.removeListener(updateDpr);
|
|
36568
|
+
}
|
|
36569
|
+
};
|
|
36570
|
+
}, [currentDpr, defaultDpr, maxDpr, round]);
|
|
36571
|
+
return currentDpr;
|
|
36572
|
+
}
|
|
36573
|
+
/**
|
|
36574
|
+
* Returns the current device pixel ratio (DPR) given the passed options
|
|
36575
|
+
*
|
|
36576
|
+
* @param { DevicePixelRatioOptions } options the options object
|
|
36577
|
+
* @returns { number } current device pixel ratio
|
|
36578
|
+
*/
|
|
36579
|
+
function getDevicePixelRatio(options) {
|
|
36580
|
+
const { defaultDpr = 1, maxDpr = 3, round = true } = options || {};
|
|
36581
|
+
const hasDprProp = typeof window !== "undefined" && typeof window.devicePixelRatio === "number";
|
|
36582
|
+
const dpr = hasDprProp ? window.devicePixelRatio : defaultDpr;
|
|
36583
|
+
const rounded = Math.min(Math.max(1, round ? Math.floor(dpr) : dpr), maxDpr);
|
|
36584
|
+
return rounded;
|
|
36585
|
+
}
|
|
36586
|
+
|
|
36587
|
+
/**
|
|
36588
|
+
* The useHover hook returns a onMouseEnter, onMouseLeave and a boolean indicating whether the element is being hovered.
|
|
36589
|
+
* The boolean will be true if the element is being hovered, and false if it is not.
|
|
36590
|
+
* Can be directionally debounced.
|
|
36591
|
+
*
|
|
36592
|
+
* @param {ConditionalUseHoverProps} param0 The options
|
|
36593
|
+
* @returns {Object} The object containing the onMouseEnter, onMouseLeave and hovering props
|
|
36594
|
+
*/
|
|
36595
|
+
const useHover = ({ debounced = false, delay = 100, direction = "out" } = { debounced: false }) => {
|
|
36596
|
+
const [hovering, setHovering] = React.useState(false);
|
|
36597
|
+
const debouncedHovering = useDebounce(hovering, delay, direction);
|
|
36598
|
+
const onMouseEnter = () => {
|
|
36599
|
+
setHovering(true);
|
|
36600
|
+
};
|
|
36601
|
+
const onMouseLeave = () => {
|
|
36602
|
+
setHovering(false);
|
|
36603
|
+
};
|
|
36604
|
+
return { onMouseEnter, onMouseLeave, hovering: debounced ? debouncedHovering : hovering };
|
|
36605
|
+
};
|
|
36606
|
+
|
|
36607
|
+
/**
|
|
36608
|
+
* Differentiate between the first and subsequent renders.
|
|
36609
|
+
*
|
|
36610
|
+
* @returns {boolean} Returns true if it is the first render, false otherwise.
|
|
36611
|
+
*/
|
|
36612
|
+
const useIsFirstRender = () => {
|
|
36613
|
+
const renderRef = React.useRef(true);
|
|
36614
|
+
if (renderRef.current === true) {
|
|
36615
|
+
renderRef.current = false;
|
|
36616
|
+
return true;
|
|
36617
|
+
}
|
|
36618
|
+
return renderRef.current;
|
|
36409
36619
|
};
|
|
36410
36620
|
|
|
36411
36621
|
/**
|
|
@@ -36477,6 +36687,8 @@ const useTimeout = ({ onTimeout, duration }) => {
|
|
|
36477
36687
|
return [isReady, stopTimeout, startTimeout];
|
|
36478
36688
|
};
|
|
36479
36689
|
|
|
36690
|
+
const cvaMoreMenu = cssClassVarianceUtilities.cvaMerge(["p-4"]);
|
|
36691
|
+
|
|
36480
36692
|
/**
|
|
36481
36693
|
* A kebab menu component.
|
|
36482
36694
|
* Advice: fill it with MenuList
|
|
@@ -36498,14 +36710,41 @@ const MoreMenu = ({ className, dataTestId, menuPlacement, iconProps = {
|
|
|
36498
36710
|
useClickOutside(actionMenuRef, () => {
|
|
36499
36711
|
setActionMenuIsOpen(false);
|
|
36500
36712
|
});
|
|
36501
|
-
return (jsxRuntime.jsx(
|
|
36713
|
+
return (jsxRuntime.jsx("div", { ref: actionMenuRef, className: cvaMoreMenu({ className }), "data-testid": dataTestId, children: jsxRuntime.jsxs(Popover, { placement: menuPlacement, children: [jsxRuntime.jsx(PopoverTrigger, { children: customButton !== null && customButton !== void 0 ? customButton : (jsxRuntime.jsx(IconButton, Object.assign({}, iconButtonProps, { icon: iconProps.name ? jsxRuntime.jsx(Icon, Object.assign({}, iconProps, { name: iconProps.name })) : null, onClick: () => {
|
|
36502
36714
|
setActionMenuIsOpen(!actionMenuIsOpen);
|
|
36503
36715
|
} }))) }), jsxRuntime.jsx(PopoverContent, { children: close => (typeof children === "function" ? children(close) : children) })] }) }));
|
|
36504
36716
|
};
|
|
36505
|
-
|
|
36506
|
-
|
|
36507
|
-
|
|
36508
|
-
|
|
36717
|
+
|
|
36718
|
+
const cvaModalContainer = cssClassVarianceUtilities.cvaMerge(["h-full", "w-full", "flex", "items-center"]);
|
|
36719
|
+
const cvaModalCard = cssClassVarianceUtilities.cvaMerge([
|
|
36720
|
+
"m-auto",
|
|
36721
|
+
"shadow-2xl",
|
|
36722
|
+
"w-[calc(100%-1rem)]",
|
|
36723
|
+
"max-h-[min(100%-1rem,30%+600px)]",
|
|
36724
|
+
"max-w-[min(100%-1rem,30%+600px)]",
|
|
36725
|
+
]);
|
|
36726
|
+
const cvaModalBackdrop = cssClassVarianceUtilities.cvaMerge([
|
|
36727
|
+
"flex",
|
|
36728
|
+
"justify-center",
|
|
36729
|
+
"items-center",
|
|
36730
|
+
"fixed",
|
|
36731
|
+
"top-0",
|
|
36732
|
+
"left-0",
|
|
36733
|
+
"w-full",
|
|
36734
|
+
"h-full",
|
|
36735
|
+
"bg-black/50",
|
|
36736
|
+
"z-20",
|
|
36737
|
+
"invisible",
|
|
36738
|
+
"opacity-0",
|
|
36739
|
+
"transition-all",
|
|
36740
|
+
], {
|
|
36741
|
+
variants: {
|
|
36742
|
+
show: {
|
|
36743
|
+
true: "animate-modal-fade",
|
|
36744
|
+
false: "",
|
|
36745
|
+
},
|
|
36746
|
+
},
|
|
36747
|
+
});
|
|
36509
36748
|
|
|
36510
36749
|
/**
|
|
36511
36750
|
* The Backdrop for the modal.
|
|
@@ -36515,7 +36754,7 @@ const Root = tailwindStyledComponents.tw.div `
|
|
|
36515
36754
|
*/
|
|
36516
36755
|
const ModalBackdrop = ({ children, isVisible, onClick }) => {
|
|
36517
36756
|
const ref = React__namespace.useRef(null);
|
|
36518
|
-
return (jsxRuntime.jsx(
|
|
36757
|
+
return (jsxRuntime.jsx("div", { ref: ref, className: cvaModalBackdrop({ show: isVisible }), onMouseDown: e => {
|
|
36519
36758
|
var _a, _b;
|
|
36520
36759
|
// only react on click on backdrop - accessing first child to get around styled element element
|
|
36521
36760
|
if (ref.current !== null) {
|
|
@@ -36525,12 +36764,6 @@ const ModalBackdrop = ({ children, isVisible, onClick }) => {
|
|
|
36525
36764
|
}
|
|
36526
36765
|
}, children: children }));
|
|
36527
36766
|
};
|
|
36528
|
-
const Backdrop = tailwindStyledComponents.tw.div `
|
|
36529
|
-
tu-modal-backdrop
|
|
36530
|
-
${({ $isVisible }) => {
|
|
36531
|
-
return $isVisible && tailwindStyledComponents.tws `tu-modal-backdrop--show`;
|
|
36532
|
-
}}
|
|
36533
|
-
`;
|
|
36534
36767
|
|
|
36535
36768
|
/**
|
|
36536
36769
|
* - Modals are used to present critical information or request user input needed to complete a user's workflow.
|
|
@@ -36540,14 +36773,8 @@ const Backdrop = tailwindStyledComponents.tw.div `
|
|
|
36540
36773
|
const Modal = React__namespace.forwardRef(({ isOpen, children, dataTestId, className, role = "", onDismissClick = () => {
|
|
36541
36774
|
return;
|
|
36542
36775
|
}, }, ref) => {
|
|
36543
|
-
return (jsxRuntime.jsx(ModalBackdrop, { isVisible: isOpen, onClick: onDismissClick, children: isOpen && (jsxRuntime.jsx(
|
|
36776
|
+
return (jsxRuntime.jsx(ModalBackdrop, { isVisible: isOpen, onClick: onDismissClick, children: isOpen && (jsxRuntime.jsx("div", { className: cvaModalContainer(), ref: ref, role: role, children: jsxRuntime.jsx(Card, { dataTestId: dataTestId, className: cvaModalCard({ className }), children: children }) })) }));
|
|
36544
36777
|
});
|
|
36545
|
-
const StyledCard = tailwindStyledComponents.twx(Card) `
|
|
36546
|
-
tu-modal__card
|
|
36547
|
-
`;
|
|
36548
|
-
const StyledDiv = tailwindStyledComponents.tw.div `
|
|
36549
|
-
tu-modal__container
|
|
36550
|
-
`;
|
|
36551
36778
|
|
|
36552
36779
|
var usePortal$1 = {};
|
|
36553
36780
|
|
|
@@ -36959,43 +37186,6 @@ const PageHeader = ({ className, dataTestId, action, showLoading, description, l
|
|
|
36959
37186
|
return (jsxRuntime.jsxs("div", { className: cvaPageHeader({ className: `${className} tu-page-header` }), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId && `${dataTestId}-heading-container`, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo && (jsxRuntime.jsx(IconButton, { to: backTo, color: "tertiary", variant: "transparent", size: "small", icon: jsxRuntime.jsx(Icon, { name: "ArrowLeftIcon" }) })), jsxRuntime.jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId && `${dataTestId}-heading`, children: title }), description && !showLoading && (jsxRuntime.jsx(Tip, { dataTestId: dataTestId && `${dataTestId}-tip`, iconProps: { name: "QuestionMarkCircleIcon" }, link: link, children: description }))] }), tag && !showLoading && jsxRuntime.jsx(Tag, { dataTestId: dataTestId, children: tag }), showLoading && jsxRuntime.jsx(Spinner, { dataTestId: dataTestId && `${dataTestId}-spinner`, centering: "vertically" }), action] }), jsxRuntime.jsx("div", { className: cvaPageHeaderChildContainer(), children: children })] }));
|
|
36960
37187
|
};
|
|
36961
37188
|
|
|
36962
|
-
const cvaSkeletonLine = cssClassVarianceUtilities.cvaMerge([
|
|
36963
|
-
"rounded-md",
|
|
36964
|
-
"h-3",
|
|
36965
|
-
"opacity-20",
|
|
36966
|
-
"animate-pulse",
|
|
36967
|
-
"bg-black/50",
|
|
36968
|
-
"bg-auto",
|
|
36969
|
-
"bg-gradient-to-r",
|
|
36970
|
-
"from-black/0",
|
|
36971
|
-
"via-black/50",
|
|
36972
|
-
"to-black/20",
|
|
36973
|
-
]);
|
|
36974
|
-
|
|
36975
|
-
/**
|
|
36976
|
-
* Display placeholder lines before the data gets loaded to reduce load-time frustration.
|
|
36977
|
-
*/
|
|
36978
|
-
const SkeletonLines = React.memo(({ margin = "10px 0", lines = 1, height, width = "100%", className, dataTestId }) => {
|
|
36979
|
-
const skeletonLines = [];
|
|
36980
|
-
const getWidth = (index) => {
|
|
36981
|
-
if (width instanceof Array) {
|
|
36982
|
-
return width[index] || "100%";
|
|
36983
|
-
}
|
|
36984
|
-
return width;
|
|
36985
|
-
};
|
|
36986
|
-
const getHeight = (index) => {
|
|
36987
|
-
if (height instanceof Array) {
|
|
36988
|
-
return height[index] || "auto";
|
|
36989
|
-
}
|
|
36990
|
-
return height;
|
|
36991
|
-
};
|
|
36992
|
-
for (let i = 0; i < lines; i++) {
|
|
36993
|
-
skeletonLines.push(jsxRuntime.jsx("div", { "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "skeleton-lines", "data-type": "loading-skeleton-line", className: cvaSkeletonLine({ className }), style: { height: getHeight(i), width: getWidth(i), margin: lines > 1 ? margin : "" }, children: lines > 1 && jsxRuntime.jsx(jsxRuntime.Fragment, { children: "\u00A0" }) }, i));
|
|
36994
|
-
}
|
|
36995
|
-
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
36996
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: skeletonLines });
|
|
36997
|
-
});
|
|
36998
|
-
|
|
36999
37189
|
const cvaPagination = cssClassVarianceUtilities.cvaMerge(["flex", "items-center", "gap-1"]);
|
|
37000
37190
|
const cvaPaginationText = cssClassVarianceUtilities.cvaMerge("whitespace-nowrap");
|
|
37001
37191
|
|
|
@@ -39076,6 +39266,7 @@ exports.DayPickerPopover = DayPickerPopover;
|
|
|
39076
39266
|
exports.DayRangePicker = DayRangePicker;
|
|
39077
39267
|
exports.DensityContainer = DensityContainer;
|
|
39078
39268
|
exports.Drawer = Drawer;
|
|
39269
|
+
exports.EmptyState = EmptyState;
|
|
39079
39270
|
exports.ExternalLink = ExternalLink;
|
|
39080
39271
|
exports.FilterListMapLayout = FilterListMapLayout;
|
|
39081
39272
|
exports.FullWidthRepeatingLayout = FullWidthRepeatingLayout;
|
|
@@ -39124,6 +39315,10 @@ exports.cvaIndicatorIcon = cvaIndicatorIcon;
|
|
|
39124
39315
|
exports.cvaIndicatorIconBackground = cvaIndicatorIconBackground;
|
|
39125
39316
|
exports.cvaIndicatorLabel = cvaIndicatorLabel;
|
|
39126
39317
|
exports.cvaIndicatorPing = cvaIndicatorPing;
|
|
39318
|
+
exports.cvaMenuItem = cvaMenuItem;
|
|
39319
|
+
exports.cvaMenuItemLabel = cvaMenuItemLabel;
|
|
39320
|
+
exports.cvaMenuItemPrefix = cvaMenuItemPrefix;
|
|
39321
|
+
exports.cvaMenuItemSuffix = cvaMenuItemSuffix;
|
|
39127
39322
|
exports.docs = docs;
|
|
39128
39323
|
exports.getDevicePixelRatio = getDevicePixelRatio;
|
|
39129
39324
|
exports.getValueBarColorByValue = getValueBarColorByValue;
|