@trackunit/react-table-base-components 1.13.25 → 1.13.27

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
@@ -89,9 +89,21 @@ const ButtonCell = ({ children, className, "data-testid": dataTestId, iconColor
89
89
  const cvaCheckboxCell = cssClassVarianceUtilities.cvaMerge([""]);
90
90
 
91
91
  /**
92
- * CheckboxCell is used for render a checkbox in a table cell-
93
- * The checkbox is not editable.
92
+ * CheckboxCell renders a read-only checkbox inside a table cell. The checkbox reflects a boolean value
93
+ * but cannot be toggled by the user — it is purely for display purposes.
94
94
  *
95
+ * ### When to use
96
+ * Use CheckboxCell to display a boolean field (e.g., active/inactive, enabled/disabled) as a visual checkbox in a table column.
97
+ *
98
+ * ### When not to use
99
+ * Do not use CheckboxCell for row selection — use `useTableSelection` which provides an interactive selection column.
100
+ *
101
+ * @example Boolean status in a table column
102
+ * ```tsx
103
+ * import { CheckboxCell } from "@trackunit/react-table-base-components";
104
+ *
105
+ * const cell = ({ row }) => <CheckboxCell checked={row.original.isActive} />;
106
+ * ```
95
107
  * @param {CheckboxCellProps} props - The props for the CheckboxCell component
96
108
  * @returns {ReactElement} CheckboxCell component
97
109
  */
@@ -181,8 +193,27 @@ const TimeSince = ({ date, timeZone, locale }) => {
181
193
  const cvaHighlightCell = cssClassVarianceUtilities.cvaMerge(["flex", "gap-2"]);
182
194
 
183
195
  /**
184
- * The HighlightCell is used for rendering a list of highlights in a table cell
196
+ * HighlightCell renders one or more colored highlight badges inside a table cell. Each highlight
197
+ * can be a simple string (displayed with the default warning color) or an object with a custom color.
198
+ * It is used to draw attention to out-of-range or notable values in a table row.
185
199
  *
200
+ * ### When to use
201
+ * Use HighlightCell to display threshold warnings, status flags, or tagged values inside a table column.
202
+ *
203
+ * ### When not to use
204
+ * Do not use HighlightCell for general status indicators — use `IndicatorCell`.
205
+ *
206
+ * @example Highlight cell with warning values
207
+ * ```tsx
208
+ * import { HighlightCell } from "@trackunit/react-table-base-components";
209
+ *
210
+ * const cell = ({ row }) => (
211
+ * <HighlightCell highlights={[
212
+ * { color: "danger", children: "High Temp" },
213
+ * { color: "warning", children: "Low Battery" },
214
+ * ]} />
215
+ * );
216
+ * ```
186
217
  * @param {HighlightCellProps} props - The props for the HighlightCell component
187
218
  * @returns {ReactElement} HighlightCell component
188
219
  */
@@ -296,20 +327,56 @@ const IdentityCell = ({ link, className, "data-testid": dataTestId, ref, title,
296
327
  };
297
328
 
298
329
  /**
299
- * The `<ImageCell>` component is used for displaying images in a table cell.
330
+ * ImageCell renders a thumbnail image inside a table cell with configurable width, height, and alt text.
331
+ * It is used to display asset photos, user avatars, or product images alongside other table data.
332
+ *
333
+ * ### When to use
334
+ * Use ImageCell when a table column needs to display a thumbnail or image preview.
335
+ *
336
+ * ### When not to use
337
+ * Do not use ImageCell for icons or status indicators — use `IndicatorCell`.
300
338
  *
301
- * @param {ImageCellProps} props - The props for the Image component.
302
- * @returns {ReactElement} The Image component.
339
+ * @example Asset image in a table column
340
+ * ```tsx
341
+ * import { ImageCell } from "@trackunit/react-table-base-components";
342
+ *
343
+ * const cell = ({ row }) => (
344
+ * <ImageCell imageUrl={row.original.imageUrl} alt={row.original.name} width={60} height={60} />
345
+ * );
346
+ * ```
347
+ * @param {ImageCellProps} props - The props for the ImageCell component
348
+ * @returns {ReactElement} ImageCell component
303
349
  */
304
350
  const ImageCell = ({ imageUrl, alt = "", width = 100, height = 100, "data-testid": dataTestId, ref, ...rest }) => {
305
351
  return jsxRuntime.jsx("img", { alt: alt, "data-testid": dataTestId, height: height, ref: ref, src: imageUrl, width: width, ...rest });
306
352
  };
307
353
 
308
354
  /**
309
- * The IndicatorCell is used for render an indicator in a table cell
355
+ * IndicatorCell renders a colored icon indicator with an optional text label inside a table cell.
356
+ * It wraps the Indicator component and supports background highlighting, a pinging animation for urgency,
357
+ * and hiding the label to show it on hover instead.
310
358
  *
311
- * @param {IndicatorCellProps} props - The props for the LinkCell component
312
- * @returns {ReactElement} LinkCell component
359
+ * ### When to use
360
+ * Use IndicatorCell to display status indicators in a table — for example, online/offline status, health state, or connectivity.
361
+ *
362
+ * ### When not to use
363
+ * Do not use IndicatorCell for text-based status labels — use `TextCell` or `NoticeCell`.
364
+ *
365
+ * @example Status indicator in a table column
366
+ * ```tsx
367
+ * import { IndicatorCell } from "@trackunit/react-table-base-components";
368
+ * import { Icon } from "@trackunit/react-components";
369
+ *
370
+ * const cell = ({ row }) => (
371
+ * <IndicatorCell
372
+ * icon={<Icon name="CheckCircle" size="small" />}
373
+ * color="success"
374
+ * label="Online"
375
+ * />
376
+ * );
377
+ * ```
378
+ * @param {IndicatorCellProps} props - The props for the IndicatorCell component
379
+ * @returns {ReactElement} IndicatorCell component
313
380
  */
314
381
  const IndicatorCell = ({ withBackground = false, weight = "normal", ref, ...rest }) => {
315
382
  return jsxRuntime.jsx(reactComponents.Indicator, { ref: ref, weight: weight, withBackground: withBackground, ...rest });
@@ -390,8 +457,24 @@ const cvaMainRowText = cssClassVarianceUtilities.cvaMerge(["overflow-hidden", "t
390
457
  const cvaSecondaryRowText = cssClassVarianceUtilities.cvaMerge(["overflow-hidden", "text-ellipsis", "text-neutral-500", "text-xs"]);
391
458
 
392
459
  /**
393
- * The MultiRowTableCell component helps to display two rows inside a table cell.
460
+ * MultiRowTableCell renders two stacked rows inside a single table cell — a primary `main` row
461
+ * and a secondary row below it. String values are automatically styled with appropriate text sizes.
462
+ *
463
+ * ### When to use
464
+ * Use MultiRowTableCell when a table cell needs to display a primary value with secondary metadata below —
465
+ * for example, an asset name with its serial number, or a user name with their email.
466
+ *
467
+ * ### When not to use
468
+ * Do not use MultiRowTableCell for single-line text — use `TextCell`.
394
469
  *
470
+ * @example Name with description in a table cell
471
+ * ```tsx
472
+ * import { MultiRowTableCell } from "@trackunit/react-table-base-components";
473
+ *
474
+ * const cell = ({ row }) => (
475
+ * <MultiRowTableCell main={row.original.name} secondary={row.original.serialNumber} />
476
+ * );
477
+ * ```
395
478
  * @param {MultiRowTableCellProps} props - The props for the MultiRowTableCell component
396
479
  * @returns {ReactElement} MultiRowTableCell component
397
480
  */
@@ -468,8 +551,22 @@ const MultiValueTextCell = ({ content, count, countTooltip, icon, iconTooltip, "
468
551
  };
469
552
 
470
553
  /**
471
- * The NoticeCell is used for rendering a Notice in a table cell
554
+ * NoticeCell renders a Notice component inside a table cell, displaying an inline colored message
555
+ * (info, warning, success, danger). It accepts the same props as Notice.
556
+ *
557
+ * ### When to use
558
+ * Use NoticeCell to display contextual messages or status banners within a table row —
559
+ * for example, a warning about an expired certificate or an info notice about a pending update.
560
+ *
561
+ * ### When not to use
562
+ * Do not use NoticeCell for simple colored text — use `HighlightCell`.
472
563
  *
564
+ * @example Warning notice in a table cell
565
+ * ```tsx
566
+ * import { NoticeCell } from "@trackunit/react-table-base-components";
567
+ *
568
+ * const cell = () => <NoticeCell color="warning">Certificate expires soon</NoticeCell>;
569
+ * ```
473
570
  * @param {NoticeCellProps} props - The props for the NoticeCell component
474
571
  * @returns {ReactElement} NoticeCell component
475
572
  */
@@ -535,8 +632,26 @@ const cvaDateTime = cssClassVarianceUtilities.cvaMerge(["slashed-zero", "text-sm
535
632
  const cvaDateTimeSince = cssClassVarianceUtilities.cvaMerge(["slashed-zero", "text-neutral-500", "text-xs", "text-ellipsis"]);
536
633
 
537
634
  /**
538
- * PlainDateCell is used for render a date and or time in a table cell.
635
+ * PlainDateCell renders a `Temporal.PlainDate` inside a table cell as a formatted date string.
636
+ * By default it also shows the number of days since the date on a second line (e.g., "15 days ago").
637
+ * Returns `null` when no date is provided.
638
+ *
639
+ * ### When to use
640
+ * Use PlainDateCell for date columns in tables where you work with `Temporal.PlainDate` values —
641
+ * for example, "Last Service Date" or "Created On" columns.
642
+ *
643
+ * ### When not to use
644
+ * Do not use PlainDateCell for `Date` objects or ISO strings — use the `DateTime` component instead.
539
645
  *
646
+ * @example Date column with days-since indicator
647
+ * ```tsx
648
+ * import { PlainDateCell } from "@trackunit/react-table-base-components";
649
+ * import { Temporal } from "@js-temporal/polyfill";
650
+ *
651
+ * const cell = ({ row }) => (
652
+ * <PlainDateCell date={Temporal.PlainDate.from(row.original.lastServiceDate)} />
653
+ * );
654
+ * ```
540
655
  * @param {PlainDateCellProps} props - The props for the PlainDateCell component
541
656
  * @returns {ReactElement} PlainDateCell component
542
657
  */
@@ -754,18 +869,32 @@ const IconWithLoader = ({ action, size }) => {
754
869
  };
755
870
 
756
871
  /**
757
- * The SortIndicator is used in the table header to indicate the current sort order of the column.
758
- * This is a visual only component and does not handle the sorting logic.
872
+ * SortIndicator renders ascending/descending arrow indicators in a table column header.
873
+ * It is a visual-only component it does not handle sorting logic. Set `sortingState` to
874
+ * `"asc"`, `"desc"`, or `false` (hidden).
759
875
  *
760
- * In most cases, we recommend using the Table Component which already handles sorting indication.
761
- * However, if you need to construct a custom table, the Table Base Components can be utilized.
876
+ * In most cases, use the Table component which handles sort indication automatically.
877
+ * Use SortIndicator directly only when building custom table headers with the Table Base Components.
762
878
  *
763
- * @param {object} props - Props for the sorting indicator.
764
- * @param {boolean} [props.sortingState=false] - Indicates the sorting state (ascending/descending).
765
- * @param {string} [props."data-testid"] - A data-testid attribute for testing purposes.
766
- * @param {string} [props.className] - Additional CSS classes to apply to the sorting indicator.
767
- * @param {import('react').Ref<HTMLDivElement>} [props.ref] - Ref forwarded to the root DOM element.
768
- * @returns {ReactElement} A React element representing the sorting indicator.
879
+ * ### When to use
880
+ * Use SortIndicator in custom table header cells that need to show the current sort direction.
881
+ *
882
+ * ### When not to use
883
+ * Do not use SortIndicator when using the `Table` component — sorting indicators are built in.
884
+ *
885
+ * @example Sort indicator in a custom header
886
+ * ```tsx
887
+ * import { SortIndicator } from "@trackunit/react-table-base-components";
888
+ *
889
+ * const CustomHeader = ({ sortDirection }: { sortDirection: "asc" | "desc" | false }) => (
890
+ * <div className="flex items-center gap-1">
891
+ * <span>Column Name</span>
892
+ * <SortIndicator sortingState={sortDirection} />
893
+ * </div>
894
+ * );
895
+ * ```
896
+ * @param {SortIndicatorProps} props - The props for the SortIndicator component
897
+ * @returns {ReactElement} SortIndicator component
769
898
  */
770
899
  const SortIndicator = ({ sortingState = false, "data-testid": dataTestId, className, ref, ...rest }) => {
771
900
  return (jsxRuntime.jsx("div", { className: cvaSortIndicator({ sortingState, className }), "data-testid": dataTestId, ref: ref, role: "separator", ...rest }));
package/index.esm.js CHANGED
@@ -87,9 +87,21 @@ const ButtonCell = ({ children, className, "data-testid": dataTestId, iconColor
87
87
  const cvaCheckboxCell = cvaMerge([""]);
88
88
 
89
89
  /**
90
- * CheckboxCell is used for render a checkbox in a table cell-
91
- * The checkbox is not editable.
90
+ * CheckboxCell renders a read-only checkbox inside a table cell. The checkbox reflects a boolean value
91
+ * but cannot be toggled by the user — it is purely for display purposes.
92
92
  *
93
+ * ### When to use
94
+ * Use CheckboxCell to display a boolean field (e.g., active/inactive, enabled/disabled) as a visual checkbox in a table column.
95
+ *
96
+ * ### When not to use
97
+ * Do not use CheckboxCell for row selection — use `useTableSelection` which provides an interactive selection column.
98
+ *
99
+ * @example Boolean status in a table column
100
+ * ```tsx
101
+ * import { CheckboxCell } from "@trackunit/react-table-base-components";
102
+ *
103
+ * const cell = ({ row }) => <CheckboxCell checked={row.original.isActive} />;
104
+ * ```
93
105
  * @param {CheckboxCellProps} props - The props for the CheckboxCell component
94
106
  * @returns {ReactElement} CheckboxCell component
95
107
  */
@@ -179,8 +191,27 @@ const TimeSince = ({ date, timeZone, locale }) => {
179
191
  const cvaHighlightCell = cvaMerge(["flex", "gap-2"]);
180
192
 
181
193
  /**
182
- * The HighlightCell is used for rendering a list of highlights in a table cell
194
+ * HighlightCell renders one or more colored highlight badges inside a table cell. Each highlight
195
+ * can be a simple string (displayed with the default warning color) or an object with a custom color.
196
+ * It is used to draw attention to out-of-range or notable values in a table row.
183
197
  *
198
+ * ### When to use
199
+ * Use HighlightCell to display threshold warnings, status flags, or tagged values inside a table column.
200
+ *
201
+ * ### When not to use
202
+ * Do not use HighlightCell for general status indicators — use `IndicatorCell`.
203
+ *
204
+ * @example Highlight cell with warning values
205
+ * ```tsx
206
+ * import { HighlightCell } from "@trackunit/react-table-base-components";
207
+ *
208
+ * const cell = ({ row }) => (
209
+ * <HighlightCell highlights={[
210
+ * { color: "danger", children: "High Temp" },
211
+ * { color: "warning", children: "Low Battery" },
212
+ * ]} />
213
+ * );
214
+ * ```
184
215
  * @param {HighlightCellProps} props - The props for the HighlightCell component
185
216
  * @returns {ReactElement} HighlightCell component
186
217
  */
@@ -294,20 +325,56 @@ const IdentityCell = ({ link, className, "data-testid": dataTestId, ref, title,
294
325
  };
295
326
 
296
327
  /**
297
- * The `<ImageCell>` component is used for displaying images in a table cell.
328
+ * ImageCell renders a thumbnail image inside a table cell with configurable width, height, and alt text.
329
+ * It is used to display asset photos, user avatars, or product images alongside other table data.
330
+ *
331
+ * ### When to use
332
+ * Use ImageCell when a table column needs to display a thumbnail or image preview.
333
+ *
334
+ * ### When not to use
335
+ * Do not use ImageCell for icons or status indicators — use `IndicatorCell`.
298
336
  *
299
- * @param {ImageCellProps} props - The props for the Image component.
300
- * @returns {ReactElement} The Image component.
337
+ * @example Asset image in a table column
338
+ * ```tsx
339
+ * import { ImageCell } from "@trackunit/react-table-base-components";
340
+ *
341
+ * const cell = ({ row }) => (
342
+ * <ImageCell imageUrl={row.original.imageUrl} alt={row.original.name} width={60} height={60} />
343
+ * );
344
+ * ```
345
+ * @param {ImageCellProps} props - The props for the ImageCell component
346
+ * @returns {ReactElement} ImageCell component
301
347
  */
302
348
  const ImageCell = ({ imageUrl, alt = "", width = 100, height = 100, "data-testid": dataTestId, ref, ...rest }) => {
303
349
  return jsx("img", { alt: alt, "data-testid": dataTestId, height: height, ref: ref, src: imageUrl, width: width, ...rest });
304
350
  };
305
351
 
306
352
  /**
307
- * The IndicatorCell is used for render an indicator in a table cell
353
+ * IndicatorCell renders a colored icon indicator with an optional text label inside a table cell.
354
+ * It wraps the Indicator component and supports background highlighting, a pinging animation for urgency,
355
+ * and hiding the label to show it on hover instead.
308
356
  *
309
- * @param {IndicatorCellProps} props - The props for the LinkCell component
310
- * @returns {ReactElement} LinkCell component
357
+ * ### When to use
358
+ * Use IndicatorCell to display status indicators in a table — for example, online/offline status, health state, or connectivity.
359
+ *
360
+ * ### When not to use
361
+ * Do not use IndicatorCell for text-based status labels — use `TextCell` or `NoticeCell`.
362
+ *
363
+ * @example Status indicator in a table column
364
+ * ```tsx
365
+ * import { IndicatorCell } from "@trackunit/react-table-base-components";
366
+ * import { Icon } from "@trackunit/react-components";
367
+ *
368
+ * const cell = ({ row }) => (
369
+ * <IndicatorCell
370
+ * icon={<Icon name="CheckCircle" size="small" />}
371
+ * color="success"
372
+ * label="Online"
373
+ * />
374
+ * );
375
+ * ```
376
+ * @param {IndicatorCellProps} props - The props for the IndicatorCell component
377
+ * @returns {ReactElement} IndicatorCell component
311
378
  */
312
379
  const IndicatorCell = ({ withBackground = false, weight = "normal", ref, ...rest }) => {
313
380
  return jsx(Indicator, { ref: ref, weight: weight, withBackground: withBackground, ...rest });
@@ -388,8 +455,24 @@ const cvaMainRowText = cvaMerge(["overflow-hidden", "text-ellipsis", "text-sm"])
388
455
  const cvaSecondaryRowText = cvaMerge(["overflow-hidden", "text-ellipsis", "text-neutral-500", "text-xs"]);
389
456
 
390
457
  /**
391
- * The MultiRowTableCell component helps to display two rows inside a table cell.
458
+ * MultiRowTableCell renders two stacked rows inside a single table cell — a primary `main` row
459
+ * and a secondary row below it. String values are automatically styled with appropriate text sizes.
460
+ *
461
+ * ### When to use
462
+ * Use MultiRowTableCell when a table cell needs to display a primary value with secondary metadata below —
463
+ * for example, an asset name with its serial number, or a user name with their email.
464
+ *
465
+ * ### When not to use
466
+ * Do not use MultiRowTableCell for single-line text — use `TextCell`.
392
467
  *
468
+ * @example Name with description in a table cell
469
+ * ```tsx
470
+ * import { MultiRowTableCell } from "@trackunit/react-table-base-components";
471
+ *
472
+ * const cell = ({ row }) => (
473
+ * <MultiRowTableCell main={row.original.name} secondary={row.original.serialNumber} />
474
+ * );
475
+ * ```
393
476
  * @param {MultiRowTableCellProps} props - The props for the MultiRowTableCell component
394
477
  * @returns {ReactElement} MultiRowTableCell component
395
478
  */
@@ -466,8 +549,22 @@ const MultiValueTextCell = ({ content, count, countTooltip, icon, iconTooltip, "
466
549
  };
467
550
 
468
551
  /**
469
- * The NoticeCell is used for rendering a Notice in a table cell
552
+ * NoticeCell renders a Notice component inside a table cell, displaying an inline colored message
553
+ * (info, warning, success, danger). It accepts the same props as Notice.
554
+ *
555
+ * ### When to use
556
+ * Use NoticeCell to display contextual messages or status banners within a table row —
557
+ * for example, a warning about an expired certificate or an info notice about a pending update.
558
+ *
559
+ * ### When not to use
560
+ * Do not use NoticeCell for simple colored text — use `HighlightCell`.
470
561
  *
562
+ * @example Warning notice in a table cell
563
+ * ```tsx
564
+ * import { NoticeCell } from "@trackunit/react-table-base-components";
565
+ *
566
+ * const cell = () => <NoticeCell color="warning">Certificate expires soon</NoticeCell>;
567
+ * ```
471
568
  * @param {NoticeCellProps} props - The props for the NoticeCell component
472
569
  * @returns {ReactElement} NoticeCell component
473
570
  */
@@ -533,8 +630,26 @@ const cvaDateTime = cvaMerge(["slashed-zero", "text-sm", "text-ellipsis"]);
533
630
  const cvaDateTimeSince = cvaMerge(["slashed-zero", "text-neutral-500", "text-xs", "text-ellipsis"]);
534
631
 
535
632
  /**
536
- * PlainDateCell is used for render a date and or time in a table cell.
633
+ * PlainDateCell renders a `Temporal.PlainDate` inside a table cell as a formatted date string.
634
+ * By default it also shows the number of days since the date on a second line (e.g., "15 days ago").
635
+ * Returns `null` when no date is provided.
636
+ *
637
+ * ### When to use
638
+ * Use PlainDateCell for date columns in tables where you work with `Temporal.PlainDate` values —
639
+ * for example, "Last Service Date" or "Created On" columns.
640
+ *
641
+ * ### When not to use
642
+ * Do not use PlainDateCell for `Date` objects or ISO strings — use the `DateTime` component instead.
537
643
  *
644
+ * @example Date column with days-since indicator
645
+ * ```tsx
646
+ * import { PlainDateCell } from "@trackunit/react-table-base-components";
647
+ * import { Temporal } from "@js-temporal/polyfill";
648
+ *
649
+ * const cell = ({ row }) => (
650
+ * <PlainDateCell date={Temporal.PlainDate.from(row.original.lastServiceDate)} />
651
+ * );
652
+ * ```
538
653
  * @param {PlainDateCellProps} props - The props for the PlainDateCell component
539
654
  * @returns {ReactElement} PlainDateCell component
540
655
  */
@@ -752,18 +867,32 @@ const IconWithLoader = ({ action, size }) => {
752
867
  };
753
868
 
754
869
  /**
755
- * The SortIndicator is used in the table header to indicate the current sort order of the column.
756
- * This is a visual only component and does not handle the sorting logic.
870
+ * SortIndicator renders ascending/descending arrow indicators in a table column header.
871
+ * It is a visual-only component it does not handle sorting logic. Set `sortingState` to
872
+ * `"asc"`, `"desc"`, or `false` (hidden).
757
873
  *
758
- * In most cases, we recommend using the Table Component which already handles sorting indication.
759
- * However, if you need to construct a custom table, the Table Base Components can be utilized.
874
+ * In most cases, use the Table component which handles sort indication automatically.
875
+ * Use SortIndicator directly only when building custom table headers with the Table Base Components.
760
876
  *
761
- * @param {object} props - Props for the sorting indicator.
762
- * @param {boolean} [props.sortingState=false] - Indicates the sorting state (ascending/descending).
763
- * @param {string} [props."data-testid"] - A data-testid attribute for testing purposes.
764
- * @param {string} [props.className] - Additional CSS classes to apply to the sorting indicator.
765
- * @param {import('react').Ref<HTMLDivElement>} [props.ref] - Ref forwarded to the root DOM element.
766
- * @returns {ReactElement} A React element representing the sorting indicator.
877
+ * ### When to use
878
+ * Use SortIndicator in custom table header cells that need to show the current sort direction.
879
+ *
880
+ * ### When not to use
881
+ * Do not use SortIndicator when using the `Table` component — sorting indicators are built in.
882
+ *
883
+ * @example Sort indicator in a custom header
884
+ * ```tsx
885
+ * import { SortIndicator } from "@trackunit/react-table-base-components";
886
+ *
887
+ * const CustomHeader = ({ sortDirection }: { sortDirection: "asc" | "desc" | false }) => (
888
+ * <div className="flex items-center gap-1">
889
+ * <span>Column Name</span>
890
+ * <SortIndicator sortingState={sortDirection} />
891
+ * </div>
892
+ * );
893
+ * ```
894
+ * @param {SortIndicatorProps} props - The props for the SortIndicator component
895
+ * @returns {ReactElement} SortIndicator component
767
896
  */
768
897
  const SortIndicator = ({ sortingState = false, "data-testid": dataTestId, className, ref, ...rest }) => {
769
898
  return (jsx("div", { className: cvaSortIndicator({ sortingState, className }), "data-testid": dataTestId, ref: ref, role: "separator", ...rest }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-table-base-components",
3
- "version": "1.13.25",
3
+ "version": "1.13.27",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,9 +8,9 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "react": "19.0.0",
11
- "@trackunit/react-components": "1.17.22",
11
+ "@trackunit/react-components": "1.17.24",
12
12
  "@trackunit/ui-icons": "1.11.42",
13
- "@trackunit/react-form-components": "1.14.25",
13
+ "@trackunit/react-form-components": "1.14.27",
14
14
  "@trackunit/css-class-variance-utilities": "1.11.43",
15
15
  "@trackunit/date-and-time-utils": "1.11.44",
16
16
  "@trackunit/shared-utils": "1.13.43",
@@ -3,9 +3,21 @@ export interface CheckboxCellProps extends CommonProps {
3
3
  checked: boolean;
4
4
  }
5
5
  /**
6
- * CheckboxCell is used for render a checkbox in a table cell-
7
- * The checkbox is not editable.
6
+ * CheckboxCell renders a read-only checkbox inside a table cell. The checkbox reflects a boolean value
7
+ * but cannot be toggled by the user — it is purely for display purposes.
8
8
  *
9
+ * ### When to use
10
+ * Use CheckboxCell to display a boolean field (e.g., active/inactive, enabled/disabled) as a visual checkbox in a table column.
11
+ *
12
+ * ### When not to use
13
+ * Do not use CheckboxCell for row selection — use `useTableSelection` which provides an interactive selection column.
14
+ *
15
+ * @example Boolean status in a table column
16
+ * ```tsx
17
+ * import { CheckboxCell } from "@trackunit/react-table-base-components";
18
+ *
19
+ * const cell = ({ row }) => <CheckboxCell checked={row.original.isActive} />;
20
+ * ```
9
21
  * @param {CheckboxCellProps} props - The props for the CheckboxCell component
10
22
  * @returns {ReactElement} CheckboxCell component
11
23
  */
@@ -19,8 +19,27 @@ export interface HighlightCellProps extends CommonProps, HTMLAttributes<HTMLTabl
19
19
  }>;
20
20
  }
21
21
  /**
22
- * The HighlightCell is used for rendering a list of highlights in a table cell
22
+ * HighlightCell renders one or more colored highlight badges inside a table cell. Each highlight
23
+ * can be a simple string (displayed with the default warning color) or an object with a custom color.
24
+ * It is used to draw attention to out-of-range or notable values in a table row.
23
25
  *
26
+ * ### When to use
27
+ * Use HighlightCell to display threshold warnings, status flags, or tagged values inside a table column.
28
+ *
29
+ * ### When not to use
30
+ * Do not use HighlightCell for general status indicators — use `IndicatorCell`.
31
+ *
32
+ * @example Highlight cell with warning values
33
+ * ```tsx
34
+ * import { HighlightCell } from "@trackunit/react-table-base-components";
35
+ *
36
+ * const cell = ({ row }) => (
37
+ * <HighlightCell highlights={[
38
+ * { color: "danger", children: "High Temp" },
39
+ * { color: "warning", children: "Low Battery" },
40
+ * ]} />
41
+ * );
42
+ * ```
24
43
  * @param {HighlightCellProps} props - The props for the HighlightCell component
25
44
  * @returns {ReactElement} HighlightCell component
26
45
  */
@@ -22,9 +22,24 @@ export interface ImageCellProps extends CommonProps, Refable<HTMLImageElement> {
22
22
  "data-testid"?: string;
23
23
  }
24
24
  /**
25
- * The `<ImageCell>` component is used for displaying images in a table cell.
25
+ * ImageCell renders a thumbnail image inside a table cell with configurable width, height, and alt text.
26
+ * It is used to display asset photos, user avatars, or product images alongside other table data.
26
27
  *
27
- * @param {ImageCellProps} props - The props for the Image component.
28
- * @returns {ReactElement} The Image component.
28
+ * ### When to use
29
+ * Use ImageCell when a table column needs to display a thumbnail or image preview.
30
+ *
31
+ * ### When not to use
32
+ * Do not use ImageCell for icons or status indicators — use `IndicatorCell`.
33
+ *
34
+ * @example Asset image in a table column
35
+ * ```tsx
36
+ * import { ImageCell } from "@trackunit/react-table-base-components";
37
+ *
38
+ * const cell = ({ row }) => (
39
+ * <ImageCell imageUrl={row.original.imageUrl} alt={row.original.name} width={60} height={60} />
40
+ * );
41
+ * ```
42
+ * @param {ImageCellProps} props - The props for the ImageCell component
43
+ * @returns {ReactElement} ImageCell component
29
44
  */
30
45
  export declare const ImageCell: ({ imageUrl, alt, width, height, "data-testid": dataTestId, ref, ...rest }: ImageCellProps) => import("react/jsx-runtime").JSX.Element;
@@ -31,9 +31,30 @@ export interface IndicatorCellProps extends IndicatorProps, HTMLAttributes<HTMLT
31
31
  weight?: "normal" | "medium";
32
32
  }
33
33
  /**
34
- * The IndicatorCell is used for render an indicator in a table cell
34
+ * IndicatorCell renders a colored icon indicator with an optional text label inside a table cell.
35
+ * It wraps the Indicator component and supports background highlighting, a pinging animation for urgency,
36
+ * and hiding the label to show it on hover instead.
35
37
  *
36
- * @param {IndicatorCellProps} props - The props for the LinkCell component
37
- * @returns {ReactElement} LinkCell component
38
+ * ### When to use
39
+ * Use IndicatorCell to display status indicators in a table — for example, online/offline status, health state, or connectivity.
40
+ *
41
+ * ### When not to use
42
+ * Do not use IndicatorCell for text-based status labels — use `TextCell` or `NoticeCell`.
43
+ *
44
+ * @example Status indicator in a table column
45
+ * ```tsx
46
+ * import { IndicatorCell } from "@trackunit/react-table-base-components";
47
+ * import { Icon } from "@trackunit/react-components";
48
+ *
49
+ * const cell = ({ row }) => (
50
+ * <IndicatorCell
51
+ * icon={<Icon name="CheckCircle" size="small" />}
52
+ * color="success"
53
+ * label="Online"
54
+ * />
55
+ * );
56
+ * ```
57
+ * @param {IndicatorCellProps} props - The props for the IndicatorCell component
58
+ * @returns {ReactElement} IndicatorCell component
38
59
  */
39
60
  export declare const IndicatorCell: ({ withBackground, weight, ref, ...rest }: IndicatorCellProps) => import("react/jsx-runtime").JSX.Element;
@@ -11,8 +11,24 @@ export interface MultiRowTableCellProps extends CommonProps {
11
11
  secondary: ReactNode;
12
12
  }
13
13
  /**
14
- * The MultiRowTableCell component helps to display two rows inside a table cell.
14
+ * MultiRowTableCell renders two stacked rows inside a single table cell — a primary `main` row
15
+ * and a secondary row below it. String values are automatically styled with appropriate text sizes.
15
16
  *
17
+ * ### When to use
18
+ * Use MultiRowTableCell when a table cell needs to display a primary value with secondary metadata below —
19
+ * for example, an asset name with its serial number, or a user name with their email.
20
+ *
21
+ * ### When not to use
22
+ * Do not use MultiRowTableCell for single-line text — use `TextCell`.
23
+ *
24
+ * @example Name with description in a table cell
25
+ * ```tsx
26
+ * import { MultiRowTableCell } from "@trackunit/react-table-base-components";
27
+ *
28
+ * const cell = ({ row }) => (
29
+ * <MultiRowTableCell main={row.original.name} secondary={row.original.serialNumber} />
30
+ * );
31
+ * ```
16
32
  * @param {MultiRowTableCellProps} props - The props for the MultiRowTableCell component
17
33
  * @returns {ReactElement} MultiRowTableCell component
18
34
  */
@@ -1,8 +1,22 @@
1
1
  import { NoticeProps } from "@trackunit/react-components";
2
2
  export type NoticeCellProps = NoticeProps;
3
3
  /**
4
- * The NoticeCell is used for rendering a Notice in a table cell
4
+ * NoticeCell renders a Notice component inside a table cell, displaying an inline colored message
5
+ * (info, warning, success, danger). It accepts the same props as Notice.
5
6
  *
7
+ * ### When to use
8
+ * Use NoticeCell to display contextual messages or status banners within a table row —
9
+ * for example, a warning about an expired certificate or an info notice about a pending update.
10
+ *
11
+ * ### When not to use
12
+ * Do not use NoticeCell for simple colored text — use `HighlightCell`.
13
+ *
14
+ * @example Warning notice in a table cell
15
+ * ```tsx
16
+ * import { NoticeCell } from "@trackunit/react-table-base-components";
17
+ *
18
+ * const cell = () => <NoticeCell color="warning">Certificate expires soon</NoticeCell>;
19
+ * ```
6
20
  * @param {NoticeCellProps} props - The props for the NoticeCell component
7
21
  * @returns {ReactElement} NoticeCell component
8
22
  */
@@ -20,8 +20,26 @@ export interface PlainDateCellProps extends CommonProps, Refable<HTMLDivElement>
20
20
  locale?: string;
21
21
  }
22
22
  /**
23
- * PlainDateCell is used for render a date and or time in a table cell.
23
+ * PlainDateCell renders a `Temporal.PlainDate` inside a table cell as a formatted date string.
24
+ * By default it also shows the number of days since the date on a second line (e.g., "15 days ago").
25
+ * Returns `null` when no date is provided.
24
26
  *
27
+ * ### When to use
28
+ * Use PlainDateCell for date columns in tables where you work with `Temporal.PlainDate` values —
29
+ * for example, "Last Service Date" or "Created On" columns.
30
+ *
31
+ * ### When not to use
32
+ * Do not use PlainDateCell for `Date` objects or ISO strings — use the `DateTime` component instead.
33
+ *
34
+ * @example Date column with days-since indicator
35
+ * ```tsx
36
+ * import { PlainDateCell } from "@trackunit/react-table-base-components";
37
+ * import { Temporal } from "@js-temporal/polyfill";
38
+ *
39
+ * const cell = ({ row }) => (
40
+ * <PlainDateCell date={Temporal.PlainDate.from(row.original.lastServiceDate)} />
41
+ * );
42
+ * ```
25
43
  * @param {PlainDateCellProps} props - The props for the PlainDateCell component
26
44
  * @returns {ReactElement} PlainDateCell component
27
45
  */
@@ -15,17 +15,31 @@ export interface SortIndicatorProps extends CommonProps, HTMLAttributes<HTMLSpan
15
15
  sortingState?: false | "asc" | "desc";
16
16
  }
17
17
  /**
18
- * The SortIndicator is used in the table header to indicate the current sort order of the column.
19
- * This is a visual only component and does not handle the sorting logic.
18
+ * SortIndicator renders ascending/descending arrow indicators in a table column header.
19
+ * It is a visual-only component it does not handle sorting logic. Set `sortingState` to
20
+ * `"asc"`, `"desc"`, or `false` (hidden).
20
21
  *
21
- * In most cases, we recommend using the Table Component which already handles sorting indication.
22
- * However, if you need to construct a custom table, the Table Base Components can be utilized.
22
+ * In most cases, use the Table component which handles sort indication automatically.
23
+ * Use SortIndicator directly only when building custom table headers with the Table Base Components.
23
24
  *
24
- * @param {object} props - Props for the sorting indicator.
25
- * @param {boolean} [props.sortingState=false] - Indicates the sorting state (ascending/descending).
26
- * @param {string} [props."data-testid"] - A data-testid attribute for testing purposes.
27
- * @param {string} [props.className] - Additional CSS classes to apply to the sorting indicator.
28
- * @param {import('react').Ref<HTMLDivElement>} [props.ref] - Ref forwarded to the root DOM element.
29
- * @returns {ReactElement} A React element representing the sorting indicator.
25
+ * ### When to use
26
+ * Use SortIndicator in custom table header cells that need to show the current sort direction.
27
+ *
28
+ * ### When not to use
29
+ * Do not use SortIndicator when using the `Table` component — sorting indicators are built in.
30
+ *
31
+ * @example Sort indicator in a custom header
32
+ * ```tsx
33
+ * import { SortIndicator } from "@trackunit/react-table-base-components";
34
+ *
35
+ * const CustomHeader = ({ sortDirection }: { sortDirection: "asc" | "desc" | false }) => (
36
+ * <div className="flex items-center gap-1">
37
+ * <span>Column Name</span>
38
+ * <SortIndicator sortingState={sortDirection} />
39
+ * </div>
40
+ * );
41
+ * ```
42
+ * @param {SortIndicatorProps} props - The props for the SortIndicator component
43
+ * @returns {ReactElement} SortIndicator component
30
44
  */
31
45
  export declare const SortIndicator: ({ sortingState, "data-testid": dataTestId, className, ref, ...rest }: SortIndicatorProps) => ReactElement;