@trackunit/react-components 0.3.4 → 0.3.6

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
@@ -2215,13 +2215,14 @@ const cvaContainerStyles = cssClassVarianceUtilities.cvaMerge([
2215
2215
  "flex",
2216
2216
  "flex-col",
2217
2217
  "items-center",
2218
- "gap-2",
2218
+ "gap-6",
2219
2219
  "p-4",
2220
2220
  "sm:p-6",
2221
2221
  "md:p-12",
2222
2222
  "text-center",
2223
2223
  "justify-center",
2224
2224
  "h-full",
2225
+ "self-center",
2225
2226
  ]);
2226
2227
  const cvaImgStyles = cssClassVarianceUtilities.cvaMerge(["w-2/3", "min-w-[60px]", "max-w-[200px]"]);
2227
2228
 
@@ -3527,49 +3528,36 @@ var SvgWorkerWithSign = (_ref, ref) => {
3527
3528
  var ForwardRef = /*#__PURE__*/React.forwardRef(SvgWorkerWithSign);
3528
3529
 
3529
3530
  /**
3530
- * Component representing an empty state.
3531
- * Use this component when there is no data to display or when an error occurs.
3532
3531
  *
3533
- * @param {EmptyStateProps} props props
3534
- * @returns {JSX.Element} component
3535
- * @example
3536
- * <EmptyState
3537
- * title="No results found"
3538
- * description="Try changing your search criteria"
3539
- * altText="No results found"
3540
- * image="BUILDING_ERROR"
3541
- * />
3532
+ * Empty states serve as placeholders when there's no content to display in either a table or card. They guide users out of the empty state towards actionable steps, highlighting ways to progress. It’s recommended to suggest simple actions that can help the users move out of the empty states towards the content that fits their goals.
3533
+ * ## **When to Use**
3534
+ * - When user actions yield no results (e.g., empty search results or unfilled data).
3535
+ * - To offer guidance on navigating out of the empty state.
3536
+ * - In cases of errors (e.g., failed content loading, unexpected errors).
3537
+ * - For guidance purposes (e.g., onboarding, adjusting filters, exploring alternative approaches).
3538
+ * - In celebratory instances (e.g., no new notifications, services up to date).
3542
3539
  */
3543
- const EmptyState = ({ title, description, altText, image, customImageSrc, action, loading, dataTestId, className, }) => {
3540
+ const EmptyState = ({ description, altText, image = "WORKER_WITH_SIGN", customImageSrc, loading, dataTestId, className, primaryAction, secondaryAction, additionalHelpAction, }) => {
3541
+ var _a, _b, _c;
3544
3542
  const ImageSource = React.useMemo(() => {
3545
- let importedImage = ForwardRef;
3546
3543
  switch (image) {
3547
3544
  case "WORKER_WITH_SIGN":
3548
- importedImage = ForwardRef;
3549
- break;
3545
+ return ForwardRef;
3550
3546
  case "ROAD_BLOCK":
3551
- importedImage = ForwardRef$3;
3552
- break;
3547
+ return ForwardRef$3;
3553
3548
  case "BUILDING_ERROR":
3554
- importedImage = ForwardRef$5;
3555
- break;
3549
+ return ForwardRef$5;
3556
3550
  case "WALL_CONSTRUCTION":
3557
- importedImage = ForwardRef$1;
3558
- break;
3551
+ return ForwardRef$1;
3559
3552
  case "PHONE_LOCK_SECURITY":
3560
- importedImage = ForwardRef$4;
3561
- break;
3553
+ return ForwardRef$4;
3562
3554
  case "SEARCH_DOCUMENT":
3563
- importedImage = ForwardRef$2;
3564
- break;
3555
+ return ForwardRef$2;
3565
3556
  default:
3566
- importedImage = ForwardRef;
3557
+ return ForwardRef;
3567
3558
  }
3568
- return importedImage;
3569
3559
  }, [image]);
3570
- return (jsxRuntime.jsx("div", { className: cvaContainerStyles({ className }), "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "empty-state", children: loading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Spinner, { centering: "centered", dataTestId: "spinner" }), jsxRuntime.jsx(SkeletonLines, { dataTestId: "skeleton-lines", width: 50 })] })) : (
3571
- // eslint-disable-next-line react/jsx-no-useless-fragment
3572
- jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [customImageSrc ? (jsxRuntime.jsx("img", { alt: altText, className: cvaImgStyles(), height: 200, src: customImageSrc, width: 200 })) : (typeof ImageSource !== "undefined" && jsxRuntime.jsx(ImageSource, { height: 200, width: 200 })), title ? jsxRuntime.jsx(Heading, { variant: "secondary", children: title }) : null, description ? jsxRuntime.jsx(Text, { align: "center", children: description }) : null, action] })) }));
3560
+ return (jsxRuntime.jsx("div", { className: cvaContainerStyles({ className }), "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "empty-state", children: loading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Spinner, { centering: "centered", dataTestId: "spinner" }), jsxRuntime.jsx(SkeletonLines, { dataTestId: "skeleton-lines", width: 50 })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [customImageSrc ? (jsxRuntime.jsx("img", { alt: altText, className: cvaImgStyles(), height: 200, src: customImageSrc, width: 200 })) : (typeof ImageSource !== "undefined" && (jsxRuntime.jsx(ImageSource, { "data-testid": "empty-state-image", height: 200, width: 200 }, image))), description ? (jsxRuntime.jsx(Text, { align: "center", size: "large", children: description })) : null, jsxRuntime.jsxs("div", { className: "grid gap-3", children: [jsxRuntime.jsxs("div", { className: "flex gap-3", children: [secondaryAction ? (jsxRuntime.jsx(Button, { dataTestId: "empty-state-secondary-button", disabled: secondaryAction.disabled, onClick: secondaryAction.onClick, variant: "secondary", children: secondaryAction.to ? (jsxRuntime.jsx(reactRouter.Link, { params: secondaryAction.to.parameters, to: secondaryAction.to.pathname, children: secondaryAction.title })) : (secondaryAction.title) })) : null, primaryAction ? (jsxRuntime.jsx(Button, { dataTestId: "empty-state-primary-button", disabled: primaryAction.disabled, onClick: primaryAction.onClick, children: primaryAction.to ? (jsxRuntime.jsx(reactRouter.Link, { params: primaryAction.to.parameters, to: primaryAction.to.pathname, children: primaryAction.title })) : (primaryAction.title) })) : null] }), additionalHelpAction ? (jsxRuntime.jsx(Button, { asChild: true, dataTestId: "empty-state-additional-button", disabled: additionalHelpAction.disabled, onClick: additionalHelpAction.onClick, suffix: jsxRuntime.jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" }), variant: "ghost", children: jsxRuntime.jsx(reactRouter.Link, { params: (_a = additionalHelpAction.to) === null || _a === void 0 ? void 0 : _a.parameters, target: (_b = additionalHelpAction.to) === null || _b === void 0 ? void 0 : _b.target, to: (_c = additionalHelpAction.to) === null || _c === void 0 ? void 0 : _c.pathname, children: additionalHelpAction.title }) })) : null] })] })) }));
3573
3561
  };
3574
3562
 
3575
3563
  const cvaEmptyValue = cssClassVarianceUtilities.cvaMerge(["text-gray-400"]);
@@ -4108,7 +4096,7 @@ const MenuItem = ({ className, dataTestId, label, size, children, selected, pref
4108
4096
  }, tabIndex: tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0, children: [prefix ? (jsxRuntime.jsx("div", { className: cvaMenuItemPrefix({ selected }), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, children: prefix })) : null, children && typeof children !== "string" ? (children) : (jsxRuntime.jsx("div", { className: cvaMenuItemLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : null, children: children !== null && children !== void 0 ? children : label })), suffix ? (jsxRuntime.jsx("div", { className: cvaMenuItemSuffix({ selected }), "data-testid": dataTestId ? `${dataTestId}-suffix` : null, children: suffix })) : null] }));
4109
4097
  };
4110
4098
 
4111
- const cvaMenuList = cssClassVarianceUtilities.cvaMerge(["shadow-md", "rounded-lg", "z-20", "bg-white", "border", "border-slate-300", "grid"], {
4099
+ const cvaMenuList = cssClassVarianceUtilities.cvaMerge(["shadow-md", "rounded-lg", "z-popover", "bg-white", "border", "border-slate-300", "grid"], {
4112
4100
  variants: {
4113
4101
  stickyHeader: {
4114
4102
  true: "grid-rows-min-fr grid overflow-y-hidden p-0",
package/index.esm.js CHANGED
@@ -2195,13 +2195,14 @@ const cvaContainerStyles = cvaMerge([
2195
2195
  "flex",
2196
2196
  "flex-col",
2197
2197
  "items-center",
2198
- "gap-2",
2198
+ "gap-6",
2199
2199
  "p-4",
2200
2200
  "sm:p-6",
2201
2201
  "md:p-12",
2202
2202
  "text-center",
2203
2203
  "justify-center",
2204
2204
  "h-full",
2205
+ "self-center",
2205
2206
  ]);
2206
2207
  const cvaImgStyles = cvaMerge(["w-2/3", "min-w-[60px]", "max-w-[200px]"]);
2207
2208
 
@@ -3507,49 +3508,36 @@ var SvgWorkerWithSign = (_ref, ref) => {
3507
3508
  var ForwardRef = /*#__PURE__*/forwardRef(SvgWorkerWithSign);
3508
3509
 
3509
3510
  /**
3510
- * Component representing an empty state.
3511
- * Use this component when there is no data to display or when an error occurs.
3512
3511
  *
3513
- * @param {EmptyStateProps} props props
3514
- * @returns {JSX.Element} component
3515
- * @example
3516
- * <EmptyState
3517
- * title="No results found"
3518
- * description="Try changing your search criteria"
3519
- * altText="No results found"
3520
- * image="BUILDING_ERROR"
3521
- * />
3512
+ * Empty states serve as placeholders when there's no content to display in either a table or card. They guide users out of the empty state towards actionable steps, highlighting ways to progress. It’s recommended to suggest simple actions that can help the users move out of the empty states towards the content that fits their goals.
3513
+ * ## **When to Use**
3514
+ * - When user actions yield no results (e.g., empty search results or unfilled data).
3515
+ * - To offer guidance on navigating out of the empty state.
3516
+ * - In cases of errors (e.g., failed content loading, unexpected errors).
3517
+ * - For guidance purposes (e.g., onboarding, adjusting filters, exploring alternative approaches).
3518
+ * - In celebratory instances (e.g., no new notifications, services up to date).
3522
3519
  */
3523
- const EmptyState = ({ title, description, altText, image, customImageSrc, action, loading, dataTestId, className, }) => {
3520
+ const EmptyState = ({ description, altText, image = "WORKER_WITH_SIGN", customImageSrc, loading, dataTestId, className, primaryAction, secondaryAction, additionalHelpAction, }) => {
3521
+ var _a, _b, _c;
3524
3522
  const ImageSource = useMemo(() => {
3525
- let importedImage = ForwardRef;
3526
3523
  switch (image) {
3527
3524
  case "WORKER_WITH_SIGN":
3528
- importedImage = ForwardRef;
3529
- break;
3525
+ return ForwardRef;
3530
3526
  case "ROAD_BLOCK":
3531
- importedImage = ForwardRef$3;
3532
- break;
3527
+ return ForwardRef$3;
3533
3528
  case "BUILDING_ERROR":
3534
- importedImage = ForwardRef$5;
3535
- break;
3529
+ return ForwardRef$5;
3536
3530
  case "WALL_CONSTRUCTION":
3537
- importedImage = ForwardRef$1;
3538
- break;
3531
+ return ForwardRef$1;
3539
3532
  case "PHONE_LOCK_SECURITY":
3540
- importedImage = ForwardRef$4;
3541
- break;
3533
+ return ForwardRef$4;
3542
3534
  case "SEARCH_DOCUMENT":
3543
- importedImage = ForwardRef$2;
3544
- break;
3535
+ return ForwardRef$2;
3545
3536
  default:
3546
- importedImage = ForwardRef;
3537
+ return ForwardRef;
3547
3538
  }
3548
- return importedImage;
3549
3539
  }, [image]);
3550
- return (jsx("div", { className: cvaContainerStyles({ className }), "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "empty-state", children: loading ? (jsxs(Fragment, { children: [jsx(Spinner, { centering: "centered", dataTestId: "spinner" }), jsx(SkeletonLines, { dataTestId: "skeleton-lines", width: 50 })] })) : (
3551
- // eslint-disable-next-line react/jsx-no-useless-fragment
3552
- jsxs(Fragment, { children: [customImageSrc ? (jsx("img", { alt: altText, className: cvaImgStyles(), height: 200, src: customImageSrc, width: 200 })) : (typeof ImageSource !== "undefined" && jsx(ImageSource, { height: 200, width: 200 })), title ? jsx(Heading, { variant: "secondary", children: title }) : null, description ? jsx(Text, { align: "center", children: description }) : null, action] })) }));
3540
+ return (jsx("div", { className: cvaContainerStyles({ className }), "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : "empty-state", children: loading ? (jsxs(Fragment, { children: [jsx(Spinner, { centering: "centered", dataTestId: "spinner" }), jsx(SkeletonLines, { dataTestId: "skeleton-lines", width: 50 })] })) : (jsxs(Fragment, { children: [customImageSrc ? (jsx("img", { alt: altText, className: cvaImgStyles(), height: 200, src: customImageSrc, width: 200 })) : (typeof ImageSource !== "undefined" && (jsx(ImageSource, { "data-testid": "empty-state-image", height: 200, width: 200 }, image))), description ? (jsx(Text, { align: "center", size: "large", children: description })) : null, jsxs("div", { className: "grid gap-3", children: [jsxs("div", { className: "flex gap-3", children: [secondaryAction ? (jsx(Button, { dataTestId: "empty-state-secondary-button", disabled: secondaryAction.disabled, onClick: secondaryAction.onClick, variant: "secondary", children: secondaryAction.to ? (jsx(Link, { params: secondaryAction.to.parameters, to: secondaryAction.to.pathname, children: secondaryAction.title })) : (secondaryAction.title) })) : null, primaryAction ? (jsx(Button, { dataTestId: "empty-state-primary-button", disabled: primaryAction.disabled, onClick: primaryAction.onClick, children: primaryAction.to ? (jsx(Link, { params: primaryAction.to.parameters, to: primaryAction.to.pathname, children: primaryAction.title })) : (primaryAction.title) })) : null] }), additionalHelpAction ? (jsx(Button, { asChild: true, dataTestId: "empty-state-additional-button", disabled: additionalHelpAction.disabled, onClick: additionalHelpAction.onClick, suffix: jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" }), variant: "ghost", children: jsx(Link, { params: (_a = additionalHelpAction.to) === null || _a === void 0 ? void 0 : _a.parameters, target: (_b = additionalHelpAction.to) === null || _b === void 0 ? void 0 : _b.target, to: (_c = additionalHelpAction.to) === null || _c === void 0 ? void 0 : _c.pathname, children: additionalHelpAction.title }) })) : null] })] })) }));
3553
3541
  };
3554
3542
 
3555
3543
  const cvaEmptyValue = cvaMerge(["text-gray-400"]);
@@ -4088,7 +4076,7 @@ const MenuItem = ({ className, dataTestId, label, size, children, selected, pref
4088
4076
  }, tabIndex: tabIndex !== null && tabIndex !== void 0 ? tabIndex : 0, children: [prefix ? (jsx("div", { className: cvaMenuItemPrefix({ selected }), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, children: prefix })) : null, children && typeof children !== "string" ? (children) : (jsx("div", { className: cvaMenuItemLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : null, children: children !== null && children !== void 0 ? children : label })), suffix ? (jsx("div", { className: cvaMenuItemSuffix({ selected }), "data-testid": dataTestId ? `${dataTestId}-suffix` : null, children: suffix })) : null] }));
4089
4077
  };
4090
4078
 
4091
- const cvaMenuList = cvaMerge(["shadow-md", "rounded-lg", "z-20", "bg-white", "border", "border-slate-300", "grid"], {
4079
+ const cvaMenuList = cvaMerge(["shadow-md", "rounded-lg", "z-popover", "bg-white", "border", "border-slate-300", "grid"], {
4092
4080
  variants: {
4093
4081
  stickyHeader: {
4094
4082
  true: "grid-rows-min-fr grid overflow-y-hidden p-0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -1,27 +1,34 @@
1
1
  import { CommonProps } from "../../common";
2
- type Image = "WORKER_WITH_SIGN" | "ROAD_BLOCK" | "BUILDING_ERROR" | "WALL_CONSTRUCTION" | "PHONE_LOCK_SECURITY" | "SEARCH_DOCUMENT";
2
+ type EmptyStateImage = "WORKER_WITH_SIGN" | "ROAD_BLOCK" | "BUILDING_ERROR" | "WALL_CONSTRUCTION" | "PHONE_LOCK_SECURITY" | "SEARCH_DOCUMENT";
3
+ type EmptyStateButtonAction = {
4
+ disabled?: boolean;
5
+ onClick?: () => void;
6
+ title: string;
7
+ to?: {
8
+ pathname: string;
9
+ parameters?: Record<string, string>;
10
+ target?: string;
11
+ };
12
+ };
3
13
  export interface EmptyStateProps extends CommonProps {
4
- title?: string;
5
14
  description?: string;
6
15
  altText?: string;
7
- image?: Image;
16
+ image?: EmptyStateImage;
8
17
  customImageSrc?: string;
9
- action?: React.ReactNode;
18
+ primaryAction?: EmptyStateButtonAction;
19
+ secondaryAction?: EmptyStateButtonAction;
20
+ additionalHelpAction?: EmptyStateButtonAction;
10
21
  loading?: boolean;
11
22
  }
12
23
  /**
13
- * Component representing an empty state.
14
- * Use this component when there is no data to display or when an error occurs.
15
24
  *
16
- * @param {EmptyStateProps} props props
17
- * @returns {JSX.Element} component
18
- * @example
19
- * <EmptyState
20
- * title="No results found"
21
- * description="Try changing your search criteria"
22
- * altText="No results found"
23
- * image="BUILDING_ERROR"
24
- * />
25
+ * Empty states serve as placeholders when there's no content to display in either a table or card. They guide users out of the empty state towards actionable steps, highlighting ways to progress. It’s recommended to suggest simple actions that can help the users move out of the empty states towards the content that fits their goals.
26
+ * ## **When to Use**
27
+ * - When user actions yield no results (e.g., empty search results or unfilled data).
28
+ * - To offer guidance on navigating out of the empty state.
29
+ * - In cases of errors (e.g., failed content loading, unexpected errors).
30
+ * - For guidance purposes (e.g., onboarding, adjusting filters, exploring alternative approaches).
31
+ * - In celebratory instances (e.g., no new notifications, services up to date).
25
32
  */
26
- export declare const EmptyState: ({ title, description, altText, image, customImageSrc, action, loading, dataTestId, className, }: EmptyStateProps) => import("react/jsx-runtime").JSX.Element;
33
+ export declare const EmptyState: ({ description, altText, image, customImageSrc, loading, dataTestId, className, primaryAction, secondaryAction, additionalHelpAction, }: EmptyStateProps) => import("react/jsx-runtime").JSX.Element;
27
34
  export {};