@trackunit/react-table-base-components 1.6.5 → 1.6.7

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
@@ -59,6 +59,20 @@ const TimeSince = ({ date, timeZone, locale }) => {
59
59
  }
60
60
  };
61
61
 
62
+ const cvaHighlightCell = cssClassVarianceUtilities.cvaMerge(["flex", "gap-2"]);
63
+
64
+ /**
65
+ * The HighlightCell is used for rendering a list of highlights in a table cell
66
+ *
67
+ * @param {HighlightCellProps} props - The props for the HighlightCell component
68
+ * @returns {ReactElement} HighlightCell component
69
+ */
70
+ const HighlightCell = ({ className, highlights, dataTestId }) => {
71
+ return (jsxRuntime.jsx("div", { className: cvaHighlightCell({ className }), "data-testid": dataTestId, children: highlights.map((highlight, index) => (jsxRuntime.jsx(reactComponents.Highlight, { color: "warning",
72
+ dataTestId: `${dataTestId}-${index}`,
73
+ ...(typeof highlight === "string" ? { children: highlight } : highlight) }, index))) }));
74
+ };
75
+
62
76
  const cvaIdentityCell = cssClassVarianceUtilities.cvaMerge(["grid", "items-center", "text-sm"], {
63
77
  variants: {
64
78
  hasThumbnail: {
@@ -575,6 +589,7 @@ const cvaTr = cssClassVarianceUtilities.cvaMerge(["w-full", "h-max", "border-b",
575
589
  exports.ButtonCell = ButtonCell;
576
590
  exports.CheckboxCell = CheckboxCell;
577
591
  exports.DateTimeCell = DateTimeCell;
592
+ exports.HighlightCell = HighlightCell;
578
593
  exports.IdentityCell = IdentityCell;
579
594
  exports.ImageCell = ImageCell;
580
595
  exports.IndicatorCell = IndicatorCell;
package/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { Button, Icon, Heading, Indicator, ExternalLink, Tooltip, Tag, Notice, IconButton, MoreMenu, MenuList, MenuItem, MenuDivider, Spinner } from '@trackunit/react-components';
2
+ import { Button, Icon, Highlight, Heading, Indicator, ExternalLink, Tooltip, Tag, Notice, IconButton, MoreMenu, MenuList, MenuItem, MenuDivider, Spinner } from '@trackunit/react-components';
3
3
  import { Checkbox } from '@trackunit/react-form-components';
4
4
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
5
5
  import { formatDateUtil, timeSinceAuto, timeSinceInDays } from '@trackunit/date-and-time-utils';
@@ -57,6 +57,20 @@ const TimeSince = ({ date, timeZone, locale }) => {
57
57
  }
58
58
  };
59
59
 
60
+ const cvaHighlightCell = cvaMerge(["flex", "gap-2"]);
61
+
62
+ /**
63
+ * The HighlightCell is used for rendering a list of highlights in a table cell
64
+ *
65
+ * @param {HighlightCellProps} props - The props for the HighlightCell component
66
+ * @returns {ReactElement} HighlightCell component
67
+ */
68
+ const HighlightCell = ({ className, highlights, dataTestId }) => {
69
+ return (jsx("div", { className: cvaHighlightCell({ className }), "data-testid": dataTestId, children: highlights.map((highlight, index) => (jsx(Highlight, { color: "warning",
70
+ dataTestId: `${dataTestId}-${index}`,
71
+ ...(typeof highlight === "string" ? { children: highlight } : highlight) }, index))) }));
72
+ };
73
+
60
74
  const cvaIdentityCell = cvaMerge(["grid", "items-center", "text-sm"], {
61
75
  variants: {
62
76
  hasThumbnail: {
@@ -570,4 +584,4 @@ const cvaTr = cvaMerge(["w-full", "h-max", "border-b", "border-neutral-200"], {
570
584
  },
571
585
  });
572
586
 
573
- export { ButtonCell, CheckboxCell, DateTimeCell, IdentityCell, ImageCell, IndicatorCell, LinkCell, MultiRowTableCell, MultiValueTextCell, NoticeCell, NumberCell, PlainDateCell, ResizeHandle, RowActions, SortIndicator, TableRoot, TagsCell, Tbody, Td, TextCell, Tfoot, Th, Thead, Tr };
587
+ export { ButtonCell, CheckboxCell, DateTimeCell, HighlightCell, IdentityCell, ImageCell, IndicatorCell, LinkCell, MultiRowTableCell, MultiValueTextCell, NoticeCell, NumberCell, PlainDateCell, ResizeHandle, RowActions, SortIndicator, TableRoot, TagsCell, Tbody, Td, TextCell, Tfoot, Th, Thead, Tr };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-table-base-components",
3
- "version": "1.6.5",
3
+ "version": "1.6.7",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -9,13 +9,13 @@
9
9
  "dependencies": {
10
10
  "react": "19.0.0",
11
11
  "@js-temporal/polyfill": "^0.4.4",
12
- "@trackunit/react-components": "1.7.5",
13
- "@trackunit/ui-icons": "1.6.4",
14
- "@trackunit/react-form-components": "1.6.5",
15
- "@trackunit/css-class-variance-utilities": "1.6.4",
16
- "@trackunit/date-and-time-utils": "1.6.4",
17
- "@trackunit/shared-utils": "1.8.4",
18
- "@trackunit/react-test-setup": "1.3.4"
12
+ "@trackunit/react-components": "1.7.7",
13
+ "@trackunit/ui-icons": "1.6.6",
14
+ "@trackunit/react-form-components": "1.6.7",
15
+ "@trackunit/css-class-variance-utilities": "1.6.6",
16
+ "@trackunit/date-and-time-utils": "1.6.6",
17
+ "@trackunit/shared-utils": "1.8.6",
18
+ "@trackunit/react-test-setup": "1.3.6"
19
19
  },
20
20
  "module": "./index.esm.js",
21
21
  "main": "./index.cjs.js",
@@ -0,0 +1,27 @@
1
+ import { CommonProps } from "@trackunit/react-components";
2
+ import { HTMLAttributes } from "react";
3
+ export interface HighlightCellProps extends CommonProps, HTMLAttributes<HTMLTableSectionElement> {
4
+ /**
5
+ * A id that can be used in tests to get the component
6
+ */
7
+ dataTestId?: string;
8
+ /**
9
+ * Custom classNames that will be merged with the default classNames.
10
+ */
11
+ className?: string;
12
+ /**
13
+ * Array of highlights that the component should show.
14
+ * Can be strings (which will use default warning color) or objects with Highlight props.
15
+ */
16
+ highlights: Array<string> | Array<{
17
+ color?: "info" | "success" | "warning" | "danger" | "unknown";
18
+ children: string;
19
+ }>;
20
+ }
21
+ /**
22
+ * The HighlightCell is used for rendering a list of highlights in a table cell
23
+ *
24
+ * @param {HighlightCellProps} props - The props for the HighlightCell component
25
+ * @returns {ReactElement} HighlightCell component
26
+ */
27
+ export declare const HighlightCell: ({ className, highlights, dataTestId }: HighlightCellProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { Meta, StoryObj } from "@storybook/react-webpack5";
2
+ import { HighlightCell } from "./HighlightCell";
3
+ type Story = StoryObj<typeof HighlightCell>;
4
+ declare const meta: Meta<typeof HighlightCell>;
5
+ export default meta;
6
+ export declare const packageName: () => import("react/jsx-runtime").JSX.Element;
7
+ export declare const Default: Story;
8
+ export declare const WithCustomColors: Story;
9
+ export declare const SingleHighlight: Story;
@@ -0,0 +1 @@
1
+ export declare const cvaHighlightCell: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
@@ -0,0 +1,2 @@
1
+ export { HighlightCell } from "./HighlightCell";
2
+ export type { HighlightCellProps } from "./HighlightCell";
package/src/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./components/ButtonCell/ButtonCell";
2
2
  export * from "./components/CheckboxCell/CheckboxCell";
3
3
  export * from "./components/DateTimeCell/DateTimeCell";
4
+ export * from "./components/HighlightCell";
4
5
  export * from "./components/IdentityCell/IdentityCell";
5
6
  export * from "./components/ImageCell/ImageCell";
6
7
  export * from "./components/IndicatorCell/IndicatorCell";