@trackunit/react-components 0.1.396 → 0.1.398

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
@@ -18,8 +18,8 @@ var reactRouter = require('@tanstack/react-router');
18
18
  var reactSwipeable = require('react-swipeable');
19
19
  var react = require('@floating-ui/react');
20
20
  var omit = require('lodash/omit');
21
- var reactHelmetAsync = require('react-helmet-async');
22
21
  var tailwindMerge = require('tailwind-merge');
22
+ var reactHelmetAsync = require('react-helmet-async');
23
23
  var reactTabs = require('@radix-ui/react-tabs');
24
24
  var dateFns = require('date-fns');
25
25
  var reactTablePagination = require('@trackunit/react-table-pagination');
@@ -3913,7 +3913,64 @@ const KPICard = ({ asChild = false, title, value, loading, unit, iconName, iconB
3913
3913
  return (jsxRuntime.jsxs(Comp, { className: cvaKPICardContainer({ className, isClickable: Boolean(asChild || onClick) }), "data-testid": `${dataTestId}-comp`, onClick: onClick, ...rest, children: [tooltipLabel ? (jsxRuntime.jsx(Tooltip, { className: "w-full", label: tooltipLabel, placement: "bottom", children: jsxRuntime.jsx(CardContent, {}) })) : (jsxRuntime.jsx(CardContent, {})), !loading && jsxRuntime.jsx(reactSlot.Slottable, { children: rest.children })] }));
3914
3914
  };
3915
3915
 
3916
- const cvaMenuItem = cssClassVarianceUtilities.cvaMerge([
3916
+ /**
3917
+ * The cvaInteractableItem variant is used to set the standardized styles that change through interaction with the element (background color, hover, focus, and disabled).
3918
+ * To be used for elements that do not have typical interactive roles and behaviors, such as divs, table rows, cards etc.
3919
+ *
3920
+ * To not be used for buttons, links, or other elements that have their own specific interactive roles.
3921
+ *
3922
+ * @returns a cva function that takes in the selected, disabled, showPointer, and focusRing props
3923
+ */
3924
+ const cvaInteractableItem = cssClassVarianceUtilities.cvaMerge(["outline-none"], {
3925
+ variants: {
3926
+ showPointer: {
3927
+ true: "cursor-pointer",
3928
+ false: "",
3929
+ },
3930
+ selected: {
3931
+ true: "bg-primary-600/[.08] hover:bg-primary-600/[.12] [&:has(:focus-visible)]:bg-primary-600/[.12] focus-visible:bg-primary-600/[.12]", // opacity 8% and 12% selected based on example at https://mui.com/x/react-data-grid/row-selection/#disable-row-selection-on-click
3932
+ false: "",
3933
+ },
3934
+ disabled: {
3935
+ true: "pointer-events-none !bg-neutral-100",
3936
+ false: "",
3937
+ },
3938
+ focusRing: {
3939
+ // necessary for accessibility during keyboard navigation
3940
+ // used in compound variant below since it depends on other conditions to be applied
3941
+ true: "",
3942
+ false: "",
3943
+ },
3944
+ },
3945
+ compoundVariants: [
3946
+ {
3947
+ disabled: false,
3948
+ selected: false,
3949
+ className: "hover:bg-neutral-600/5 focus-visible:bg-neutral-600/5 [&:has(:focus-visible)]:bg-neutral-600/5",
3950
+ },
3951
+ {
3952
+ disabled: false,
3953
+ focusRing: true,
3954
+ className:
3955
+ // focus-visible is a pseudo-class that is used to style an element when it is focused, and the user is navigating using the keyboard.
3956
+ // here we are targeting the parent element of the focus-visible element (so the parent containing a checkbox or radio button)
3957
+ "[&:has(:focus-visible)]:ring-primary-700 focus-visible:ring-primary-700 focus-visible:ring-2 focus-visible:ring-inset [&:has(:focus-visible)]:ring-2 [&:has(:focus-visible)]:ring-inset",
3958
+ },
3959
+ ],
3960
+ defaultVariants: {
3961
+ showPointer: false,
3962
+ selected: false,
3963
+ disabled: false,
3964
+ focusRing: false,
3965
+ },
3966
+ });
3967
+
3968
+ /**
3969
+ * Extends the cvaInteractableItem variant in order to set the padding, width, height, cursor, and other styles particular to the MenuItem component.
3970
+ * The cvaInteractableItem variant is used to set the standardized styles that change through interaction with the element (background color, hover, focus, and disabled).
3971
+ */
3972
+ const cvaMenuItem = ({ size, selected, disabled, focusRing, className } = {}) => tailwindMerge.twMerge(cvaMenuItemStyle({ size }), cvaInteractableItem({ selected, disabled, showPointer: true, focusRing }), className);
3973
+ const cvaMenuItemStyle = cssClassVarianceUtilities.cvaMerge([
3917
3974
  "py-2",
3918
3975
  "pl-2",
3919
3976
  "pr-3",
@@ -3926,35 +3983,13 @@ const cvaMenuItem = cssClassVarianceUtilities.cvaMerge([
3926
3983
  "gap-x-2",
3927
3984
  "select-none",
3928
3985
  "rounded",
3929
- "hover:bg-slate-100",
3930
- "focus-within:outline-native",
3931
3986
  ], {
3932
3987
  variants: {
3933
- selected: {
3934
- true: "bg-primary-100 hover:bg-primary-200",
3935
- false: "",
3936
- },
3937
- disabled: {
3938
- true: "pointer-events-none !bg-slate-100",
3939
- false: "",
3940
- },
3941
- focused: {
3942
- true: "bg-slate-100",
3943
- false: "",
3944
- },
3945
3988
  size: {
3946
3989
  small: "py-1",
3947
3990
  medium: "py-2",
3948
3991
  },
3949
3992
  },
3950
- compoundVariants: [
3951
- {
3952
- focused: true,
3953
- selected: true,
3954
- className: "bg-primary-200",
3955
- size: "medium",
3956
- },
3957
- ],
3958
3993
  });
3959
3994
  const cvaMenuItemLabel = cssClassVarianceUtilities.cvaMerge([
3960
3995
  "flex-grow",
@@ -3987,12 +4022,12 @@ const cvaMenuItemPrefix = cssClassVarianceUtilities.cvaMerge(["self-center", "fl
3987
4022
  * @param {MenuItemProps} props - The props for the MenuItem component
3988
4023
  * @returns {JSX.Element} MenuItem component
3989
4024
  */
3990
- const MenuItem = ({ className, dataTestId, label, size, children, selected, focused, prefix, suffix, disabled, onClick, stopPropagation = true, id, tabIndex, }) => {
4025
+ const MenuItem = ({ className, dataTestId, label, size, children, selected, focusRing = true, prefix, suffix, disabled, onClick, stopPropagation = true, id, tabIndex, }) => {
3991
4026
  const containerProps = useContainerProps({ className, dataTestId: dataTestId || "menu-item" });
3992
4027
  return (jsxRuntime.jsxs("div", { ...containerProps, className: cvaMenuItem({
3993
4028
  selected,
3994
- focused,
3995
4029
  disabled,
4030
+ focusRing,
3996
4031
  size,
3997
4032
  className: containerProps.className,
3998
4033
  }), id: id, onClick: e => {
@@ -4893,9 +4928,11 @@ exports.cvaIndicatorIcon = cvaIndicatorIcon;
4893
4928
  exports.cvaIndicatorIconBackground = cvaIndicatorIconBackground;
4894
4929
  exports.cvaIndicatorLabel = cvaIndicatorLabel;
4895
4930
  exports.cvaIndicatorPing = cvaIndicatorPing;
4931
+ exports.cvaInteractableItem = cvaInteractableItem;
4896
4932
  exports.cvaMenuItem = cvaMenuItem;
4897
4933
  exports.cvaMenuItemLabel = cvaMenuItemLabel;
4898
4934
  exports.cvaMenuItemPrefix = cvaMenuItemPrefix;
4935
+ exports.cvaMenuItemStyle = cvaMenuItemStyle;
4899
4936
  exports.cvaMenuItemSuffix = cvaMenuItemSuffix;
4900
4937
  exports.docs = docs;
4901
4938
  exports.getDevicePixelRatio = getDevicePixelRatio;
package/index.esm.js CHANGED
@@ -17,8 +17,8 @@ import { Link, useBlocker } from '@tanstack/react-router';
17
17
  import { useSwipeable } from 'react-swipeable';
18
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';
19
19
  import omit from 'lodash/omit';
20
- import { HelmetProvider, Helmet } from 'react-helmet-async';
21
20
  import { twMerge } from 'tailwind-merge';
21
+ import { HelmetProvider, Helmet } from 'react-helmet-async';
22
22
  import { Trigger, Content, List, Root } from '@radix-ui/react-tabs';
23
23
  import { format, formatDistance } from 'date-fns';
24
24
  import { useInfiniteScroll, noPagination } from '@trackunit/react-table-pagination';
@@ -3893,7 +3893,64 @@ const KPICard = ({ asChild = false, title, value, loading, unit, iconName, iconB
3893
3893
  return (jsxs(Comp, { className: cvaKPICardContainer({ className, isClickable: Boolean(asChild || onClick) }), "data-testid": `${dataTestId}-comp`, onClick: onClick, ...rest, children: [tooltipLabel ? (jsx(Tooltip, { className: "w-full", label: tooltipLabel, placement: "bottom", children: jsx(CardContent, {}) })) : (jsx(CardContent, {})), !loading && jsx(Slottable, { children: rest.children })] }));
3894
3894
  };
3895
3895
 
3896
- const cvaMenuItem = cvaMerge([
3896
+ /**
3897
+ * The cvaInteractableItem variant is used to set the standardized styles that change through interaction with the element (background color, hover, focus, and disabled).
3898
+ * To be used for elements that do not have typical interactive roles and behaviors, such as divs, table rows, cards etc.
3899
+ *
3900
+ * To not be used for buttons, links, or other elements that have their own specific interactive roles.
3901
+ *
3902
+ * @returns a cva function that takes in the selected, disabled, showPointer, and focusRing props
3903
+ */
3904
+ const cvaInteractableItem = cvaMerge(["outline-none"], {
3905
+ variants: {
3906
+ showPointer: {
3907
+ true: "cursor-pointer",
3908
+ false: "",
3909
+ },
3910
+ selected: {
3911
+ true: "bg-primary-600/[.08] hover:bg-primary-600/[.12] [&:has(:focus-visible)]:bg-primary-600/[.12] focus-visible:bg-primary-600/[.12]", // opacity 8% and 12% selected based on example at https://mui.com/x/react-data-grid/row-selection/#disable-row-selection-on-click
3912
+ false: "",
3913
+ },
3914
+ disabled: {
3915
+ true: "pointer-events-none !bg-neutral-100",
3916
+ false: "",
3917
+ },
3918
+ focusRing: {
3919
+ // necessary for accessibility during keyboard navigation
3920
+ // used in compound variant below since it depends on other conditions to be applied
3921
+ true: "",
3922
+ false: "",
3923
+ },
3924
+ },
3925
+ compoundVariants: [
3926
+ {
3927
+ disabled: false,
3928
+ selected: false,
3929
+ className: "hover:bg-neutral-600/5 focus-visible:bg-neutral-600/5 [&:has(:focus-visible)]:bg-neutral-600/5",
3930
+ },
3931
+ {
3932
+ disabled: false,
3933
+ focusRing: true,
3934
+ className:
3935
+ // focus-visible is a pseudo-class that is used to style an element when it is focused, and the user is navigating using the keyboard.
3936
+ // here we are targeting the parent element of the focus-visible element (so the parent containing a checkbox or radio button)
3937
+ "[&:has(:focus-visible)]:ring-primary-700 focus-visible:ring-primary-700 focus-visible:ring-2 focus-visible:ring-inset [&:has(:focus-visible)]:ring-2 [&:has(:focus-visible)]:ring-inset",
3938
+ },
3939
+ ],
3940
+ defaultVariants: {
3941
+ showPointer: false,
3942
+ selected: false,
3943
+ disabled: false,
3944
+ focusRing: false,
3945
+ },
3946
+ });
3947
+
3948
+ /**
3949
+ * Extends the cvaInteractableItem variant in order to set the padding, width, height, cursor, and other styles particular to the MenuItem component.
3950
+ * The cvaInteractableItem variant is used to set the standardized styles that change through interaction with the element (background color, hover, focus, and disabled).
3951
+ */
3952
+ const cvaMenuItem = ({ size, selected, disabled, focusRing, className } = {}) => twMerge(cvaMenuItemStyle({ size }), cvaInteractableItem({ selected, disabled, showPointer: true, focusRing }), className);
3953
+ const cvaMenuItemStyle = cvaMerge([
3897
3954
  "py-2",
3898
3955
  "pl-2",
3899
3956
  "pr-3",
@@ -3906,35 +3963,13 @@ const cvaMenuItem = cvaMerge([
3906
3963
  "gap-x-2",
3907
3964
  "select-none",
3908
3965
  "rounded",
3909
- "hover:bg-slate-100",
3910
- "focus-within:outline-native",
3911
3966
  ], {
3912
3967
  variants: {
3913
- selected: {
3914
- true: "bg-primary-100 hover:bg-primary-200",
3915
- false: "",
3916
- },
3917
- disabled: {
3918
- true: "pointer-events-none !bg-slate-100",
3919
- false: "",
3920
- },
3921
- focused: {
3922
- true: "bg-slate-100",
3923
- false: "",
3924
- },
3925
3968
  size: {
3926
3969
  small: "py-1",
3927
3970
  medium: "py-2",
3928
3971
  },
3929
3972
  },
3930
- compoundVariants: [
3931
- {
3932
- focused: true,
3933
- selected: true,
3934
- className: "bg-primary-200",
3935
- size: "medium",
3936
- },
3937
- ],
3938
3973
  });
3939
3974
  const cvaMenuItemLabel = cvaMerge([
3940
3975
  "flex-grow",
@@ -3967,12 +4002,12 @@ const cvaMenuItemPrefix = cvaMerge(["self-center", "flex-grow-0", "text-slate-40
3967
4002
  * @param {MenuItemProps} props - The props for the MenuItem component
3968
4003
  * @returns {JSX.Element} MenuItem component
3969
4004
  */
3970
- const MenuItem = ({ className, dataTestId, label, size, children, selected, focused, prefix, suffix, disabled, onClick, stopPropagation = true, id, tabIndex, }) => {
4005
+ const MenuItem = ({ className, dataTestId, label, size, children, selected, focusRing = true, prefix, suffix, disabled, onClick, stopPropagation = true, id, tabIndex, }) => {
3971
4006
  const containerProps = useContainerProps({ className, dataTestId: dataTestId || "menu-item" });
3972
4007
  return (jsxs("div", { ...containerProps, className: cvaMenuItem({
3973
4008
  selected,
3974
- focused,
3975
4009
  disabled,
4010
+ focusRing,
3976
4011
  size,
3977
4012
  className: containerProps.className,
3978
4013
  }), id: id, onClick: e => {
@@ -4806,4 +4841,4 @@ const cvaClickable = cvaMerge([
4806
4841
  },
4807
4842
  });
4808
4843
 
4809
- export { Alert, Badge, Breadcrumb, BreadcrumbContainer, BreadcrumbItem, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, Drawer, EmptyState, EmptyValue, ExternalLink, Heading, Icon, IconButton, Indicator, KPICard, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, Timeline, TimelineElement, ToggleGroup, Tooltip, ValueBar, VirtualizedList, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useSelfUpdatingRef, useTimeout, useWindowActivity };
4844
+ export { Alert, Badge, Breadcrumb, BreadcrumbContainer, BreadcrumbItem, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, Drawer, EmptyState, EmptyValue, ExternalLink, Heading, Icon, IconButton, Indicator, KPICard, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, Timeline, TimelineElement, ToggleGroup, 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, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useSelfUpdatingRef, useTimeout, useWindowActivity };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.396",
3
+ "version": "0.1.398",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The cvaInteractableItem variant is used to set the standardized styles that change through interaction with the element (background color, hover, focus, and disabled).
3
+ * To be used for elements that do not have typical interactive roles and behaviors, such as divs, table rows, cards etc.
4
+ *
5
+ * To not be used for buttons, links, or other elements that have their own specific interactive roles.
6
+ *
7
+ * @returns a cva function that takes in the selected, disabled, showPointer, and focusRing props
8
+ */
9
+ export declare const cvaInteractableItem: (props?: ({
10
+ showPointer?: boolean | null | undefined;
11
+ selected?: boolean | null | undefined;
12
+ disabled?: boolean | null | undefined;
13
+ focusRing?: boolean | null | undefined;
14
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
@@ -42,12 +42,12 @@ export interface MenuItemProps extends CommonProps {
42
42
  */
43
43
  onClick?: React.MouseEventHandler<HTMLDivElement>;
44
44
  /**
45
- * An boolean flag to turn on/off focused state
46
- * This is typically used for keyboard navigation
45
+ * An boolean flag to turn on/off focus rings
46
+ * This is used for keyboard navigation
47
47
  *
48
48
  * @memberof MenuItemProps
49
49
  */
50
- focused?: boolean;
50
+ focusRing?: boolean;
51
51
  /**
52
52
  * A boolean prop to set menu item to disabled state
53
53
  * used in disabled select options
@@ -66,5 +66,5 @@ export interface MenuItemProps extends CommonProps {
66
66
  * @param {MenuItemProps} props - The props for the MenuItem component
67
67
  * @returns {JSX.Element} MenuItem component
68
68
  */
69
- export declare const MenuItem: ({ className, dataTestId, label, size, children, selected, focused, prefix, suffix, disabled, onClick, stopPropagation, id, tabIndex, }: MenuItemProps) => JSX.Element;
69
+ export declare const MenuItem: ({ className, dataTestId, label, size, children, selected, focusRing, prefix, suffix, disabled, onClick, stopPropagation, id, tabIndex, }: MenuItemProps) => JSX.Element;
70
70
  export {};
@@ -1,7 +1,16 @@
1
- export declare const cvaMenuItem: (props?: ({
2
- selected?: boolean | null | undefined;
3
- disabled?: boolean | null | undefined;
4
- focused?: boolean | null | undefined;
1
+ interface CvaMenuItemProps {
2
+ size?: "small" | "medium";
3
+ selected?: boolean;
4
+ disabled?: boolean;
5
+ focusRing?: boolean;
6
+ className?: string;
7
+ }
8
+ /**
9
+ * Extends the cvaInteractableItem variant in order to set the padding, width, height, cursor, and other styles particular to the MenuItem component.
10
+ * The cvaInteractableItem variant is used to set the standardized styles that change through interaction with the element (background color, hover, focus, and disabled).
11
+ */
12
+ export declare const cvaMenuItem: ({ size, selected, disabled, focusRing, className }?: CvaMenuItemProps) => string;
13
+ export declare const cvaMenuItemStyle: (props?: ({
5
14
  size?: "small" | "medium" | null | undefined;
6
15
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
16
  export declare const cvaMenuItemLabel: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
@@ -11,3 +20,4 @@ export declare const cvaMenuItemSuffix: (props?: ({
11
20
  export declare const cvaMenuItemPrefix: (props?: ({
12
21
  selected?: boolean | null | undefined;
13
22
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
23
+ export {};
package/src/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  export * from "./common";
2
2
  export * from "./common/PackageNameStoryComponent";
3
3
  export * from "./components";
4
+ export * from "./components/buttons/shared/Button.variants";
4
5
  export * from "./components/Clickable/Clickable.variants";
5
6
  export * from "./components/Indicator/Indicator.variants";
7
+ export * from "./components/InteractableItem/InteractableItem.variants";
6
8
  export * from "./components/Menu/MenuItem/MenuItem.variants";
7
- export * from "./components/buttons/shared/Button.variants";
8
9
  export * from "./hooks";