@trackunit/react-components 0.5.28 → 0.5.30

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 CHANGED
@@ -19,7 +19,6 @@ var omit = require('lodash/omit');
19
19
  var tailwindMerge = require('tailwind-merge');
20
20
  var reactHelmetAsync = require('react-helmet-async');
21
21
  var reactTabs = require('@radix-ui/react-tabs');
22
- var dateAndTimeUtils = require('@trackunit/date-and-time-utils');
23
22
  var reactTablePagination = require('@trackunit/react-table-pagination');
24
23
 
25
24
  function _interopNamespaceDefault(e) {
@@ -809,154 +808,6 @@ const Badge = ({ color = "primary", className, count, max, hideZero = false, dat
809
808
  return (jsxRuntime.jsx("span", { className: cvaBadge({ color, className }), "data-testid": dataTestId, children: displayedCount }));
810
809
  };
811
810
 
812
- /**
813
- * Sets a value in the local storage with the specified key.
814
- * Thin wrapper around localStorage.setItem() that is slightly more type safe
815
- * Stringifies value automatically.
816
- * Useful if you for some reason can't use the useLocalStorage hook for React lifecycle reasons
817
- *
818
- * @template TValue - The type of value to be stored.
819
- * @param {string} key - The key under which to store the value.
820
- * @param {TValue} value - The value to store in the local storage.
821
- */
822
- const setLocalStorage = (key, value) => {
823
- localStorage.setItem(key, JSON.stringify(value));
824
- };
825
-
826
- /**
827
- * Validates the state object using a Zod schema.
828
- *
829
- * @template TState - The type of the state.
830
- * @param {ValidateStateOptions<TState>} params - The parameters for the validateState function.
831
- */
832
- const validateState = ({ state, schema, onValidationFailed, onValidationSuccessful, defaultState, }) => {
833
- try {
834
- const parsedState = schema.parse(state);
835
- onValidationSuccessful === null || onValidationSuccessful === void 0 ? void 0 : onValidationSuccessful(parsedState);
836
- return parsedState;
837
- }
838
- catch (error) {
839
- // eslint-disable-next-line no-console
840
- console.error("Failed to parse and validate the state from local storage.", error);
841
- onValidationFailed === null || onValidationFailed === void 0 ? void 0 : onValidationFailed(error);
842
- return defaultState;
843
- }
844
- };
845
-
846
- /**
847
- * Initializes the state from local storage, parsing and validating it if a Zod schema is provided.
848
- *
849
- * @template TState - The type of the state stored in local storage.
850
- * @param {Omit<LocalStorageParams<TState>, "state">} params - The parameters for initializing the local storage state.
851
- * @returns {TState} - The initialized state.
852
- */
853
- const initLocalStorageState = ({ key, defaultState, schema, }) => {
854
- const localStorageItem = localStorage.getItem(key);
855
- if (!localStorageItem) {
856
- return defaultState;
857
- }
858
- const localStorageItemJSON = JSON.parse(localStorageItem);
859
- if (!schema) {
860
- return localStorageItemJSON;
861
- }
862
- return validateState({ state: localStorageItemJSON, defaultState, schema });
863
- };
864
-
865
- /**
866
- * The usePrevious hook is a useful tool for tracking the previous value of a variable in a functional component. This can be particularly handy in scenarios where it is necessary to compare the current value with the previous one, such as triggering actions or rendering based on changes.
867
- *
868
- * @example
869
- * const [color, setColor] = React.useState(getRandomColor());
870
- const previousColor = usePrevious(color);
871
- */
872
- const usePrevious = (value) => {
873
- const ref = React.useRef();
874
- React.useEffect(() => {
875
- ref.current = value;
876
- }, [value]);
877
- return ref.current;
878
- };
879
-
880
- /**
881
- * Custom hook for synchronizing a state variable with local storage,
882
- * with optional schema validation and callbacks.
883
- *
884
- * @template TState - The type of the state variable.
885
- * @param {LocalStorageParams<TState> & LocalStorageCallbacks & { state: TState }} params - The parameters for the useLocalStorageEffect hook.
886
- */
887
- const useLocalStorageEffect = ({ key, state, defaultState, schema, onValidationFailed, onValidationSuccessful, }) => {
888
- const prevState = usePrevious(state);
889
- React.useEffect(() => {
890
- if (JSON.stringify(prevState) === JSON.stringify(state)) {
891
- return;
892
- }
893
- if (schema) {
894
- validateState({
895
- state,
896
- schema,
897
- defaultState,
898
- onValidationFailed: error => {
899
- // eslint-disable-next-line no-console
900
- console.error(`State validation failed. Resetting local storage to default state: ${defaultState}.`, error);
901
- localStorage.removeItem(key);
902
- onValidationFailed === null || onValidationFailed === void 0 ? void 0 : onValidationFailed(error);
903
- },
904
- onValidationSuccessful: data => {
905
- setLocalStorage(key, data);
906
- onValidationSuccessful === null || onValidationSuccessful === void 0 ? void 0 : onValidationSuccessful(data);
907
- },
908
- });
909
- }
910
- else {
911
- const stringifiedState = JSON.stringify(state);
912
- localStorage.setItem(key, stringifiedState);
913
- }
914
- }, [state, key, schema, defaultState, prevState, onValidationFailed, onValidationSuccessful]);
915
- };
916
-
917
- /**
918
- * Works like a normal useState, but saves to local storage and has optional schema validation.
919
- *
920
- * @template TState - The type of the value stored in local storage.
921
- * @param {Omit<LocalStorageParams<TState>, "state"> & LocalStorageCallbacks} options - The options for useLocalStorage.
922
- * @returns {[TState, Dispatch<SetStateAction<TState>>, () => void]} - A tuple containing the current value, a function to update the value, and a function to remove the value from local storage.
923
- */
924
- const useLocalStorage = ({ key, defaultState, schema, onValidationFailed, onValidationSuccessful, }) => {
925
- if (!key) {
926
- throw new Error("useLocalStorage key may not be falsy");
927
- }
928
- const [state, setState] = React.useState(initLocalStorageState({ key, defaultState, schema }));
929
- useLocalStorageEffect({
930
- key,
931
- state,
932
- defaultState,
933
- schema,
934
- onValidationFailed,
935
- onValidationSuccessful,
936
- });
937
- const reset = () => {
938
- setState(defaultState);
939
- };
940
- return [state, setState, reset];
941
- };
942
-
943
- /**
944
- * Works like a normal useReducer, but saves to local storage and has optional schema validation.
945
- *
946
- * @template TState - The type of the state.
947
- * @template TAction - The type of the action.
948
- * @param {LocalStorageParams<TState> & LocalStorageCallbacks} params - The parameters for the useLocalStorageReducer function.
949
- * @returns {[TState, Dispatch<TAction>]} - A tuple containing the state and the dispatch function.
950
- */
951
- const useLocalStorageReducer = ({ key, defaultState, reducer, schema, onValidationFailed, onValidationSuccessful, }) => {
952
- if (!key) {
953
- throw new Error("useLocalStorage key may not be falsy");
954
- }
955
- const [state, dispatch] = React.useReducer(reducer, defaultState, () => initLocalStorageState({ key, defaultState, schema }));
956
- useLocalStorageEffect({ key, state, defaultState, schema, onValidationFailed, onValidationSuccessful });
957
- return [state, dispatch];
958
- };
959
-
960
811
  /**
961
812
  * Custom hook to handle click outside events.
962
813
  *
@@ -4690,52 +4541,6 @@ const Tabs = ({ children, forceRender, className, dataTestId, fullWidth, ...rest
4690
4541
  return (jsxRuntime.jsx(reactTabs.Root, { className: cvaTabsRoot({ className }), "data-testid": dataTestId, ...rest, children: children }));
4691
4542
  };
4692
4543
 
4693
- const cvaTimeline = cssClassVarianceUtilities.cvaMerge("ml-4");
4694
- const cvaTimelineElement = cssClassVarianceUtilities.cvaMerge([
4695
- "grid",
4696
- "grid-cols-[min-content_auto]",
4697
- "grid-rows-[auto_auto]",
4698
- "items-start",
4699
- "border-l-[8px]",
4700
- "border-gray-100",
4701
- "pb-4",
4702
- "last:border-transparent",
4703
- ]);
4704
- const cvaTimelineDot = cssClassVarianceUtilities.cvaMerge(["flex", "space-x-4", "items-start", "ml-[calc(-50%-8px)]"]);
4705
-
4706
- /**
4707
- * Timeline - used to contain TimelineElements for building a sequence of timed entries - each rendered on a line
4708
- * - with an indicator (dot)
4709
- * - a header (next to the dot)
4710
- * - and a body.
4711
- *
4712
- * @param {TimelineProps} props - The props for the Timeline component
4713
- * @returns {JSX.Element} Timeline component
4714
- */
4715
- const Timeline = ({ className, dataTestId, children }) => {
4716
- return (jsxRuntime.jsx("ol", { className: cvaTimeline({ className }), "data-testid": dataTestId, children: children }));
4717
- };
4718
- /**
4719
- * TimelineElement - entry on a timeline - rendered with an icon on the timeline
4720
- * - a date as the header and the children provided as body.
4721
- *
4722
- * @param {TimeLineElementProps} props the props
4723
- * @returns {JSX.Element} component
4724
- */
4725
- const TimelineElement = ({ date, showTime, children, className, dataTestId = "timeline-date", dot = jsxRuntime.jsx(Indicator, { className: "mt-[-1px]", color: "neutral", icon: jsxRuntime.jsx(Icon, { name: "Calendar", size: "large" }) }), header = defaultHeader(date, showTime), onClick, }) => {
4726
- return (jsxRuntime.jsxs("li", { className: cvaTimelineElement({ className }), "data-date": `${date}`, "data-testid": dataTestId ? `${dataTestId}` : null, onClick: () => onClick && onClick(), children: [jsxRuntime.jsx("div", { className: cvaTimelineDot(), children: dot }), jsxRuntime.jsx("div", { className: "text-secondary-500 text-sm", children: header }), jsxRuntime.jsx("div", {}), jsxRuntime.jsx("div", { children: jsxRuntime.jsx("div", { children: children }) })] }));
4727
- };
4728
- function defaultHeader(date, showTime) {
4729
- return `${formattedDate(date, showTime)} (${dateAndTimeUtils.timeSinceAuto(date, new Date())})`;
4730
- }
4731
- const formattedDate = (date, showTime) => {
4732
- return dateAndTimeUtils.formatDateUtil(date, {
4733
- dateFormat: "medium",
4734
- timeFormat: "short",
4735
- selectFormat: !showTime ? "dateOnly" : undefined,
4736
- });
4737
- };
4738
-
4739
4544
  const cvaToggleGroup = cssClassVarianceUtilities.cvaMerge(["inline-flex", "divide-x", "divide-slate-300"]);
4740
4545
  const cvaToggleItem = cssClassVarianceUtilities.cvaMerge(["text-slate-600", "rounded-none", "bg-transparent", "flex", "border-x-0", "bg-white"], {
4741
4546
  variants: {
@@ -5064,8 +4869,6 @@ exports.TabList = TabList;
5064
4869
  exports.Tabs = Tabs;
5065
4870
  exports.Tag = Tag;
5066
4871
  exports.Text = Text;
5067
- exports.Timeline = Timeline;
5068
- exports.TimelineElement = TimelineElement;
5069
4872
  exports.ToggleGroup = ToggleGroup;
5070
4873
  exports.ToggleItem = ToggleItem;
5071
4874
  exports.Tooltip = Tooltip;
@@ -5094,7 +4897,6 @@ exports.getDevicePixelRatio = getDevicePixelRatio;
5094
4897
  exports.getValueBarColorByValue = getValueBarColorByValue;
5095
4898
  exports.iconColorNames = iconColorNames;
5096
4899
  exports.iconPalette = iconPalette;
5097
- exports.setLocalStorage = setLocalStorage;
5098
4900
  exports.useClickOutside = useClickOutside;
5099
4901
  exports.useContainerBreakpoints = useContainerBreakpoints;
5100
4902
  exports.useContinuousTimeout = useContinuousTimeout;
@@ -5105,12 +4907,9 @@ exports.useHover = useHover;
5105
4907
  exports.useIsFirstRender = useIsFirstRender;
5106
4908
  exports.useIsFullscreen = useIsFullscreen;
5107
4909
  exports.useIsTextCutOff = useIsTextCutOff;
5108
- exports.useLocalStorage = useLocalStorage;
5109
- exports.useLocalStorageReducer = useLocalStorageReducer;
5110
4910
  exports.useOptionallyElevatedState = useOptionallyElevatedState;
5111
4911
  exports.useOverflowItems = useOverflowItems;
5112
4912
  exports.usePopoverContext = usePopoverContext;
5113
- exports.usePrevious = usePrevious;
5114
4913
  exports.usePrompt = usePrompt;
5115
4914
  exports.useResize = useResize;
5116
4915
  exports.useScrollDetection = useScrollDetection;
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
- import React__default, { useRef, useMemo, useEffect, useState, useReducer, useCallback, memo, forwardRef, createContext, useContext, isValidElement, cloneElement, Children } from 'react';
3
+ import React__default, { useRef, useMemo, useEffect, useState, useCallback, memo, forwardRef, createContext, useContext, isValidElement, cloneElement, Children } from 'react';
4
4
  import { objectKeys, uuidv4, objectEntries, objectValues } from '@trackunit/shared-utils';
5
5
  import { rentalStatusPalette, intentPalette, generalPalette, criticalityPalette, activityPalette, utilizationPalette, sitesPalette, themeScreenSizeAsNumber, color } from '@trackunit/ui-design-tokens';
6
6
  import { iconNames } from '@trackunit/ui-icons';
@@ -18,7 +18,6 @@ import omit from 'lodash/omit';
18
18
  import { twMerge } from 'tailwind-merge';
19
19
  import { HelmetProvider, Helmet } from 'react-helmet-async';
20
20
  import { Trigger, Content, List, Root } from '@radix-ui/react-tabs';
21
- import { timeSinceAuto, formatDateUtil } from '@trackunit/date-and-time-utils';
22
21
  import { useInfiniteScroll, noPagination } from '@trackunit/react-table-pagination';
23
22
 
24
23
  const docs = {
@@ -789,154 +788,6 @@ const Badge = ({ color = "primary", className, count, max, hideZero = false, dat
789
788
  return (jsx("span", { className: cvaBadge({ color, className }), "data-testid": dataTestId, children: displayedCount }));
790
789
  };
791
790
 
792
- /**
793
- * Sets a value in the local storage with the specified key.
794
- * Thin wrapper around localStorage.setItem() that is slightly more type safe
795
- * Stringifies value automatically.
796
- * Useful if you for some reason can't use the useLocalStorage hook for React lifecycle reasons
797
- *
798
- * @template TValue - The type of value to be stored.
799
- * @param {string} key - The key under which to store the value.
800
- * @param {TValue} value - The value to store in the local storage.
801
- */
802
- const setLocalStorage = (key, value) => {
803
- localStorage.setItem(key, JSON.stringify(value));
804
- };
805
-
806
- /**
807
- * Validates the state object using a Zod schema.
808
- *
809
- * @template TState - The type of the state.
810
- * @param {ValidateStateOptions<TState>} params - The parameters for the validateState function.
811
- */
812
- const validateState = ({ state, schema, onValidationFailed, onValidationSuccessful, defaultState, }) => {
813
- try {
814
- const parsedState = schema.parse(state);
815
- onValidationSuccessful === null || onValidationSuccessful === void 0 ? void 0 : onValidationSuccessful(parsedState);
816
- return parsedState;
817
- }
818
- catch (error) {
819
- // eslint-disable-next-line no-console
820
- console.error("Failed to parse and validate the state from local storage.", error);
821
- onValidationFailed === null || onValidationFailed === void 0 ? void 0 : onValidationFailed(error);
822
- return defaultState;
823
- }
824
- };
825
-
826
- /**
827
- * Initializes the state from local storage, parsing and validating it if a Zod schema is provided.
828
- *
829
- * @template TState - The type of the state stored in local storage.
830
- * @param {Omit<LocalStorageParams<TState>, "state">} params - The parameters for initializing the local storage state.
831
- * @returns {TState} - The initialized state.
832
- */
833
- const initLocalStorageState = ({ key, defaultState, schema, }) => {
834
- const localStorageItem = localStorage.getItem(key);
835
- if (!localStorageItem) {
836
- return defaultState;
837
- }
838
- const localStorageItemJSON = JSON.parse(localStorageItem);
839
- if (!schema) {
840
- return localStorageItemJSON;
841
- }
842
- return validateState({ state: localStorageItemJSON, defaultState, schema });
843
- };
844
-
845
- /**
846
- * The usePrevious hook is a useful tool for tracking the previous value of a variable in a functional component. This can be particularly handy in scenarios where it is necessary to compare the current value with the previous one, such as triggering actions or rendering based on changes.
847
- *
848
- * @example
849
- * const [color, setColor] = React.useState(getRandomColor());
850
- const previousColor = usePrevious(color);
851
- */
852
- const usePrevious = (value) => {
853
- const ref = useRef();
854
- useEffect(() => {
855
- ref.current = value;
856
- }, [value]);
857
- return ref.current;
858
- };
859
-
860
- /**
861
- * Custom hook for synchronizing a state variable with local storage,
862
- * with optional schema validation and callbacks.
863
- *
864
- * @template TState - The type of the state variable.
865
- * @param {LocalStorageParams<TState> & LocalStorageCallbacks & { state: TState }} params - The parameters for the useLocalStorageEffect hook.
866
- */
867
- const useLocalStorageEffect = ({ key, state, defaultState, schema, onValidationFailed, onValidationSuccessful, }) => {
868
- const prevState = usePrevious(state);
869
- useEffect(() => {
870
- if (JSON.stringify(prevState) === JSON.stringify(state)) {
871
- return;
872
- }
873
- if (schema) {
874
- validateState({
875
- state,
876
- schema,
877
- defaultState,
878
- onValidationFailed: error => {
879
- // eslint-disable-next-line no-console
880
- console.error(`State validation failed. Resetting local storage to default state: ${defaultState}.`, error);
881
- localStorage.removeItem(key);
882
- onValidationFailed === null || onValidationFailed === void 0 ? void 0 : onValidationFailed(error);
883
- },
884
- onValidationSuccessful: data => {
885
- setLocalStorage(key, data);
886
- onValidationSuccessful === null || onValidationSuccessful === void 0 ? void 0 : onValidationSuccessful(data);
887
- },
888
- });
889
- }
890
- else {
891
- const stringifiedState = JSON.stringify(state);
892
- localStorage.setItem(key, stringifiedState);
893
- }
894
- }, [state, key, schema, defaultState, prevState, onValidationFailed, onValidationSuccessful]);
895
- };
896
-
897
- /**
898
- * Works like a normal useState, but saves to local storage and has optional schema validation.
899
- *
900
- * @template TState - The type of the value stored in local storage.
901
- * @param {Omit<LocalStorageParams<TState>, "state"> & LocalStorageCallbacks} options - The options for useLocalStorage.
902
- * @returns {[TState, Dispatch<SetStateAction<TState>>, () => void]} - A tuple containing the current value, a function to update the value, and a function to remove the value from local storage.
903
- */
904
- const useLocalStorage = ({ key, defaultState, schema, onValidationFailed, onValidationSuccessful, }) => {
905
- if (!key) {
906
- throw new Error("useLocalStorage key may not be falsy");
907
- }
908
- const [state, setState] = useState(initLocalStorageState({ key, defaultState, schema }));
909
- useLocalStorageEffect({
910
- key,
911
- state,
912
- defaultState,
913
- schema,
914
- onValidationFailed,
915
- onValidationSuccessful,
916
- });
917
- const reset = () => {
918
- setState(defaultState);
919
- };
920
- return [state, setState, reset];
921
- };
922
-
923
- /**
924
- * Works like a normal useReducer, but saves to local storage and has optional schema validation.
925
- *
926
- * @template TState - The type of the state.
927
- * @template TAction - The type of the action.
928
- * @param {LocalStorageParams<TState> & LocalStorageCallbacks} params - The parameters for the useLocalStorageReducer function.
929
- * @returns {[TState, Dispatch<TAction>]} - A tuple containing the state and the dispatch function.
930
- */
931
- const useLocalStorageReducer = ({ key, defaultState, reducer, schema, onValidationFailed, onValidationSuccessful, }) => {
932
- if (!key) {
933
- throw new Error("useLocalStorage key may not be falsy");
934
- }
935
- const [state, dispatch] = useReducer(reducer, defaultState, () => initLocalStorageState({ key, defaultState, schema }));
936
- useLocalStorageEffect({ key, state, defaultState, schema, onValidationFailed, onValidationSuccessful });
937
- return [state, dispatch];
938
- };
939
-
940
791
  /**
941
792
  * Custom hook to handle click outside events.
942
793
  *
@@ -4670,52 +4521,6 @@ const Tabs = ({ children, forceRender, className, dataTestId, fullWidth, ...rest
4670
4521
  return (jsx(Root, { className: cvaTabsRoot({ className }), "data-testid": dataTestId, ...rest, children: children }));
4671
4522
  };
4672
4523
 
4673
- const cvaTimeline = cvaMerge("ml-4");
4674
- const cvaTimelineElement = cvaMerge([
4675
- "grid",
4676
- "grid-cols-[min-content_auto]",
4677
- "grid-rows-[auto_auto]",
4678
- "items-start",
4679
- "border-l-[8px]",
4680
- "border-gray-100",
4681
- "pb-4",
4682
- "last:border-transparent",
4683
- ]);
4684
- const cvaTimelineDot = cvaMerge(["flex", "space-x-4", "items-start", "ml-[calc(-50%-8px)]"]);
4685
-
4686
- /**
4687
- * Timeline - used to contain TimelineElements for building a sequence of timed entries - each rendered on a line
4688
- * - with an indicator (dot)
4689
- * - a header (next to the dot)
4690
- * - and a body.
4691
- *
4692
- * @param {TimelineProps} props - The props for the Timeline component
4693
- * @returns {JSX.Element} Timeline component
4694
- */
4695
- const Timeline = ({ className, dataTestId, children }) => {
4696
- return (jsx("ol", { className: cvaTimeline({ className }), "data-testid": dataTestId, children: children }));
4697
- };
4698
- /**
4699
- * TimelineElement - entry on a timeline - rendered with an icon on the timeline
4700
- * - a date as the header and the children provided as body.
4701
- *
4702
- * @param {TimeLineElementProps} props the props
4703
- * @returns {JSX.Element} component
4704
- */
4705
- const TimelineElement = ({ date, showTime, children, className, dataTestId = "timeline-date", dot = jsx(Indicator, { className: "mt-[-1px]", color: "neutral", icon: jsx(Icon, { name: "Calendar", size: "large" }) }), header = defaultHeader(date, showTime), onClick, }) => {
4706
- return (jsxs("li", { className: cvaTimelineElement({ className }), "data-date": `${date}`, "data-testid": dataTestId ? `${dataTestId}` : null, onClick: () => onClick && onClick(), children: [jsx("div", { className: cvaTimelineDot(), children: dot }), jsx("div", { className: "text-secondary-500 text-sm", children: header }), jsx("div", {}), jsx("div", { children: jsx("div", { children: children }) })] }));
4707
- };
4708
- function defaultHeader(date, showTime) {
4709
- return `${formattedDate(date, showTime)} (${timeSinceAuto(date, new Date())})`;
4710
- }
4711
- const formattedDate = (date, showTime) => {
4712
- return formatDateUtil(date, {
4713
- dateFormat: "medium",
4714
- timeFormat: "short",
4715
- selectFormat: !showTime ? "dateOnly" : undefined,
4716
- });
4717
- };
4718
-
4719
4524
  const cvaToggleGroup = cvaMerge(["inline-flex", "divide-x", "divide-slate-300"]);
4720
4525
  const cvaToggleItem = cvaMerge(["text-slate-600", "rounded-none", "bg-transparent", "flex", "border-x-0", "bg-white"], {
4721
4526
  variants: {
@@ -4994,4 +4799,4 @@ const cvaClickable = cvaMerge([
4994
4799
  },
4995
4800
  });
4996
4801
 
4997
- export { Alert, Badge, Breadcrumb, BreadcrumbContainer, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, EmptyState, EmptyValue, ExternalLink, Heading, Icon, IconButton, Indicator, KPICard, MenuDivider, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, Timeline, TimelineElement, ToggleGroup, ToggleItem, Tooltip, ValueBar, VirtualizedList, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInteractableItem, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrevious, usePrompt, useResize, useScrollDetection, useSelfUpdatingRef, useTimeout, useViewportBreakpoints, useWindowActivity };
4802
+ export { Alert, Badge, Breadcrumb, BreadcrumbContainer, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, EmptyState, EmptyValue, ExternalLink, Heading, Icon, IconButton, Indicator, KPICard, MenuDivider, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, ToggleGroup, ToggleItem, Tooltip, ValueBar, VirtualizedList, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInteractableItem, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useScrollDetection, useSelfUpdatingRef, useTimeout, useViewportBreakpoints, useWindowActivity };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.5.28",
3
+ "version": "0.5.30",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -10,14 +10,12 @@
10
10
  "@trackunit/ui-design-tokens": "*",
11
11
  "@radix-ui/react-slot": "^1.0.2",
12
12
  "react": "18.3.1",
13
- "@trackunit/date-and-time-utils": "*",
14
13
  "@trackunit/css-class-variance-utilities": "*",
15
14
  "usehooks-ts": "^3.1.0",
16
15
  "@radix-ui/react-tabs": "^1.0.4",
17
16
  "@trackunit/ui-icons": "*",
18
17
  "@trackunit/shared-utils": "*",
19
18
  "react-helmet-async": "^1.3.0",
20
- "zod": "3.22.4",
21
19
  "lodash": "4.17.21",
22
20
  "jest-fetch-mock": "^3.0.3",
23
21
  "@testing-library/react": "15.0.6",
@@ -35,7 +35,6 @@ export * from "./Tabs/TabList";
35
35
  export * from "./Tabs/Tabs";
36
36
  export * from "./Tag";
37
37
  export * from "./Text";
38
- export * from "./Timeline/Timeline";
39
38
  export * from "./ToggleGroup/ToggleGroup";
40
39
  export * from "./Tooltip";
41
40
  export * from "./ValueBar";
@@ -1,6 +1,3 @@
1
- export * from "./localStorage/setLocalStorage";
2
- export * from "./localStorage/useLocalStorage";
3
- export * from "./localStorage/useLocalStorageReducer";
4
1
  export * from "./useClickOutside";
5
2
  export * from "./useContainerBreakpoints";
6
3
  export * from "./useContinuousTimeout";
@@ -12,7 +9,6 @@ export * from "./useIsFirstRender";
12
9
  export * from "./useIsFullScreen";
13
10
  export * from "./useIsTextCutOff";
14
11
  export * from "./useOptionallyElevatedState";
15
- export * from "./usePrevious";
16
12
  export * from "./useResize";
17
13
  export * from "./useScrollDetection";
18
14
  export * from "./useSelfUpdatingRef";
@@ -1,31 +0,0 @@
1
- import { CommonProps } from "../../common/CommonProps";
2
- export interface TimelineProps extends CommonProps {
3
- children: React.ReactNode;
4
- }
5
- /**
6
- * Timeline - used to contain TimelineElements for building a sequence of timed entries - each rendered on a line
7
- * - with an indicator (dot)
8
- * - a header (next to the dot)
9
- * - and a body.
10
- *
11
- * @param {TimelineProps} props - The props for the Timeline component
12
- * @returns {JSX.Element} Timeline component
13
- */
14
- export declare const Timeline: ({ className, dataTestId, children }: TimelineProps) => import("react/jsx-runtime").JSX.Element;
15
- interface TimeLineElementProps extends CommonProps {
16
- date: Date;
17
- showTime?: boolean;
18
- header?: React.ReactNode;
19
- children: React.ReactNode;
20
- dot?: React.ReactNode;
21
- onClick?: () => void;
22
- }
23
- /**
24
- * TimelineElement - entry on a timeline - rendered with an icon on the timeline
25
- * - a date as the header and the children provided as body.
26
- *
27
- * @param {TimeLineElementProps} props the props
28
- * @returns {JSX.Element} component
29
- */
30
- export declare const TimelineElement: ({ date, showTime, children, className, dataTestId, dot, header, onClick, }: TimeLineElementProps) => import("react/jsx-runtime").JSX.Element;
31
- export {};
@@ -1,3 +0,0 @@
1
- export declare const cvaTimeline: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
2
- export declare const cvaTimelineElement: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
3
- export declare const cvaTimelineDot: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
@@ -1,9 +0,0 @@
1
- import { LocalStorageParams } from "./types";
2
- /**
3
- * Initializes the state from local storage, parsing and validating it if a Zod schema is provided.
4
- *
5
- * @template TState - The type of the state stored in local storage.
6
- * @param {Omit<LocalStorageParams<TState>, "state">} params - The parameters for initializing the local storage state.
7
- * @returns {TState} - The initialized state.
8
- */
9
- export declare const initLocalStorageState: <TState>({ key, defaultState, schema, }: Omit<LocalStorageParams<TState>, "state">) => any;
@@ -1,11 +0,0 @@
1
- /**
2
- * Sets a value in the local storage with the specified key.
3
- * Thin wrapper around localStorage.setItem() that is slightly more type safe
4
- * Stringifies value automatically.
5
- * Useful if you for some reason can't use the useLocalStorage hook for React lifecycle reasons
6
- *
7
- * @template TValue - The type of value to be stored.
8
- * @param {string} key - The key under which to store the value.
9
- * @param {TValue} value - The value to store in the local storage.
10
- */
11
- export declare const setLocalStorage: <TValue>(key: string, value: TValue) => void;
@@ -1,27 +0,0 @@
1
- import { z } from "zod";
2
- export interface LocalStorageParams<TState> {
3
- /**
4
- * The key used to store the value in local storage.
5
- */
6
- key: string;
7
- /**
8
- * The default state value.
9
- */
10
- defaultState: TState;
11
- /**
12
- * Optional schema for validating the state.
13
- */
14
- schema?: z.Schema<TState>;
15
- }
16
- export interface LocalStorageCallbacks<TState> {
17
- /**
18
- * Optional callback function called when validation fails.
19
- *
20
- * @param error - The validation error object.
21
- */
22
- onValidationFailed?: (error: unknown) => void;
23
- /**
24
- * Optional callback function called when validation succeeds.
25
- */
26
- onValidationSuccessful?: (data: TState) => void;
27
- }
@@ -1,10 +0,0 @@
1
- import { Dispatch, SetStateAction } from "react";
2
- import { LocalStorageCallbacks, LocalStorageParams } from "./types";
3
- /**
4
- * Works like a normal useState, but saves to local storage and has optional schema validation.
5
- *
6
- * @template TState - The type of the value stored in local storage.
7
- * @param {Omit<LocalStorageParams<TState>, "state"> & LocalStorageCallbacks} options - The options for useLocalStorage.
8
- * @returns {[TState, Dispatch<SetStateAction<TState>>, () => void]} - A tuple containing the current value, a function to update the value, and a function to remove the value from local storage.
9
- */
10
- export declare const useLocalStorage: <TState>({ key, defaultState, schema, onValidationFailed, onValidationSuccessful, }: LocalStorageParams<TState> & LocalStorageCallbacks<TState>) => readonly [TState, Dispatch<SetStateAction<TState>>, () => void];
@@ -1,11 +0,0 @@
1
- import { LocalStorageCallbacks, LocalStorageParams } from "./types";
2
- /**
3
- * Custom hook for synchronizing a state variable with local storage,
4
- * with optional schema validation and callbacks.
5
- *
6
- * @template TState - The type of the state variable.
7
- * @param {LocalStorageParams<TState> & LocalStorageCallbacks & { state: TState }} params - The parameters for the useLocalStorageEffect hook.
8
- */
9
- export declare const useLocalStorageEffect: <TState>({ key, state, defaultState, schema, onValidationFailed, onValidationSuccessful, }: LocalStorageParams<TState> & LocalStorageCallbacks<TState> & {
10
- state: TState;
11
- }) => void;
@@ -1,13 +0,0 @@
1
- import { Dispatch } from "react";
2
- import { LocalStorageCallbacks, LocalStorageParams } from "./types";
3
- /**
4
- * Works like a normal useReducer, but saves to local storage and has optional schema validation.
5
- *
6
- * @template TState - The type of the state.
7
- * @template TAction - The type of the action.
8
- * @param {LocalStorageParams<TState> & LocalStorageCallbacks} params - The parameters for the useLocalStorageReducer function.
9
- * @returns {[TState, Dispatch<TAction>]} - A tuple containing the state and the dispatch function.
10
- */
11
- export declare const useLocalStorageReducer: <TState, TAction>({ key, defaultState, reducer, schema, onValidationFailed, onValidationSuccessful, }: {
12
- reducer: (state: TState, action: TAction) => TState;
13
- } & LocalStorageParams<TState> & LocalStorageCallbacks<TState>) => readonly [TState, Dispatch<TAction>];
@@ -1,13 +0,0 @@
1
- import { LocalStorageCallbacks, LocalStorageParams } from "./types";
2
- type ValidateStateOptions<TState> = Required<Pick<LocalStorageParams<TState>, "schema">> & {
3
- state: TState;
4
- defaultState: TState;
5
- } & LocalStorageCallbacks<TState>;
6
- /**
7
- * Validates the state object using a Zod schema.
8
- *
9
- * @template TState - The type of the state.
10
- * @param {ValidateStateOptions<TState>} params - The parameters for the validateState function.
11
- */
12
- export declare const validateState: <TState>({ state, schema, onValidationFailed, onValidationSuccessful, defaultState, }: ValidateStateOptions<TState>) => TState;
13
- export {};
@@ -1,8 +0,0 @@
1
- /**
2
- * The usePrevious hook is a useful tool for tracking the previous value of a variable in a functional component. This can be particularly handy in scenarios where it is necessary to compare the current value with the previous one, such as triggering actions or rendering based on changes.
3
- *
4
- * @example
5
- * const [color, setColor] = React.useState(getRandomColor());
6
- const previousColor = usePrevious(color);
7
- */
8
- export declare const usePrevious: <TValue>(value: TValue) => TValue | undefined;