rift-ds 1.29.0 → 1.30.0

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.
Files changed (126) hide show
  1. package/README.md +4 -3
  2. package/bin/rift-ds.mjs +1 -1
  3. package/bin/templates/app/components/rift/ColorModeScript.tsx +7 -3
  4. package/bin/templates/blocks/app/settings/ProfileForm.tsx +98 -0
  5. package/bin/templates/blocks/app/settings/page.module.css +11 -0
  6. package/bin/templates/blocks/app/settings/page.tsx +84 -0
  7. package/bin/templates/blocks/components/blocks/AppShell.module.css +8 -41
  8. package/bin/templates/blocks/components/blocks/AppShell.tsx +9 -11
  9. package/bin/templates/blocks/registry.json +13 -0
  10. package/bin/templates/chat/app/api/chat/feedback/route.ts +0 -3
  11. package/bin/templates/chat/app/api/chat/followups/route.ts +0 -3
  12. package/bin/templates/chat/app/api/chat/route.ts +0 -2
  13. package/chat/ChatLauncher.d.ts +9 -1
  14. package/chat/ChatLauncher.js +3 -1
  15. package/components/Alert/Alert.css +12 -0
  16. package/components/Alert/Alert.d.ts +2 -0
  17. package/components/Alert/Alert.js +3 -1
  18. package/components/Attachment/Attachment.css +92 -0
  19. package/components/Attachment/FileRow.d.ts +47 -0
  20. package/components/Attachment/FileRow.js +38 -0
  21. package/components/Avatar/Avatar.css +14 -0
  22. package/components/Avatar/Avatar.d.ts +3 -1
  23. package/components/Avatar/Avatar.js +3 -2
  24. package/components/Chart/AreaChart.d.ts +2 -0
  25. package/components/Chart/AreaChart.js +2 -1
  26. package/components/Chart/BarChart.d.ts +2 -0
  27. package/components/Chart/BarChart.js +2 -1
  28. package/components/Chart/ComboChart.d.ts +4 -0
  29. package/components/Chart/ComboChart.js +4 -2
  30. package/components/Chart/LineChart.d.ts +2 -0
  31. package/components/Chart/LineChart.js +2 -1
  32. package/components/Chart/PieChart.d.ts +4 -4
  33. package/components/Chart/PieChart.js +1 -1
  34. package/components/Chart/ScatterChart.d.ts +2 -0
  35. package/components/Chart/ScatterChart.js +2 -1
  36. package/components/Checklist/Checklist.css +123 -0
  37. package/components/Checklist/Checklist.d.ts +66 -0
  38. package/components/Checklist/Checklist.js +115 -0
  39. package/components/CircularButton/CircularButton.css +39 -0
  40. package/components/CircularButton/CircularButton.d.ts +13 -0
  41. package/components/CircularButton/CircularButton.js +18 -4
  42. package/components/ColourSwatch/ColourSwatch.css +3 -1
  43. package/components/ColourSwatch/ColourSwatch.d.ts +5 -3
  44. package/components/ColourSwatch/ColourSwatch.js +5 -0
  45. package/components/Combobox/Combobox.d.ts +4 -2
  46. package/components/Combobox/Combobox.js +7 -3
  47. package/components/DataTable/DataTable.css +35 -0
  48. package/components/DataTable/DataTable.d.ts +34 -2
  49. package/components/DataTable/DataTable.js +58 -5
  50. package/components/DataTable/columnTypes.d.ts +1 -1
  51. package/components/DataTable/columnTypes.js +1 -1
  52. package/components/DateInput/DateInput.d.ts +4 -2
  53. package/components/DateInput/DateInput.js +7 -3
  54. package/components/DescriptionList/DescriptionList.css +28 -0
  55. package/components/DescriptionList/DescriptionList.d.ts +3 -1
  56. package/components/DescriptionList/DescriptionList.js +4 -3
  57. package/components/DescriptionList/DescriptionListCopy.js +2 -0
  58. package/components/Dropdown/Dropdown.d.ts +4 -2
  59. package/components/Dropdown/Dropdown.js +7 -3
  60. package/components/EmptyState/EmptyState.css +12 -0
  61. package/components/EmptyState/EmptyState.d.ts +7 -0
  62. package/components/EmptyState/EmptyState.js +2 -0
  63. package/components/EventCalendar/EventCalendar.css +59 -0
  64. package/components/EventCalendar/EventCalendar.d.ts +24 -2
  65. package/components/EventCalendar/EventCalendar.js +104 -19
  66. package/components/FormSection/FormSection.css +70 -0
  67. package/components/FormSection/FormSection.d.ts +35 -0
  68. package/components/FormSection/FormSection.js +35 -0
  69. package/components/Grid/Grid.css +52 -0
  70. package/components/Grid/Grid.d.ts +30 -0
  71. package/components/Grid/Grid.js +36 -0
  72. package/components/Icon/Icon.css +55 -0
  73. package/components/Icon/Icon.d.ts +27 -0
  74. package/components/Icon/Icon.js +42 -0
  75. package/components/NumberInput/NumberInput.d.ts +4 -2
  76. package/components/NumberInput/NumberInput.js +7 -3
  77. package/components/OrgChart/OrgChart.css +143 -0
  78. package/components/OrgChart/OrgChart.d.ts +44 -0
  79. package/components/OrgChart/OrgChart.js +26 -0
  80. package/components/PageHeader/PageHeader.css +74 -0
  81. package/components/PageHeader/PageHeader.d.ts +39 -0
  82. package/components/PageHeader/PageHeader.js +33 -0
  83. package/components/Panel/Panel.css +7 -0
  84. package/components/Panel/Panel.d.ts +5 -2
  85. package/components/Panel/Panel.js +2 -1
  86. package/components/ResourceTimeline/ResourceTimeline.css +194 -0
  87. package/components/ResourceTimeline/ResourceTimeline.d.ts +57 -0
  88. package/components/ResourceTimeline/ResourceTimeline.js +129 -0
  89. package/components/ShaderField/useShaderField.js +13 -1
  90. package/components/ShaderScene/ShaderScene.d.ts +3 -2
  91. package/components/ShaderScene/ShaderScene.js +47 -4
  92. package/components/Stack/Stack.css +68 -0
  93. package/components/Stack/Stack.d.ts +37 -0
  94. package/components/Stack/Stack.js +39 -0
  95. package/components/Stat/Stat.css +65 -0
  96. package/components/Stat/Stat.d.ts +7 -1
  97. package/components/Stat/Stat.js +16 -1
  98. package/components/Table/Table.css +11 -0
  99. package/components/Table/Table.d.ts +2 -0
  100. package/components/Table/Table.js +5 -1
  101. package/components/Tabs/Tabs.css +23 -0
  102. package/components/Tabs/Tabs.d.ts +9 -8
  103. package/components/Tabs/Tabs.js +38 -5
  104. package/components/Textarea/Textarea.d.ts +4 -2
  105. package/components/Textarea/Textarea.js +7 -3
  106. package/components/ThemeToggle/colorMode.d.ts +17 -1
  107. package/components/ThemeToggle/colorMode.js +11 -2
  108. package/components/Widget/Widget.css +21 -0
  109. package/components/Widget/Widget.d.ts +4 -0
  110. package/components/Widget/Widget.js +13 -5
  111. package/components/Wizard/Wizard.css +67 -0
  112. package/components/Wizard/Wizard.d.ts +54 -0
  113. package/components/Wizard/Wizard.js +71 -0
  114. package/components/registry.d.ts +25 -0
  115. package/components/registry.js +8 -0
  116. package/components/registry.json +233 -32
  117. package/components/registry.json.d.ts +233 -32
  118. package/components/registry.json.js +1 -1
  119. package/index.d.ts +10 -0
  120. package/index.js +20 -0
  121. package/package.json +1 -1
  122. package/tokens/motion.d.ts +2 -0
  123. package/tokens/motion.js +2 -0
  124. package/tokens/values.d.ts +31 -0
  125. package/tokens/values.js +16 -0
  126. package/tokens/values.json.js +1 -1
@@ -388,3 +388,42 @@
388
388
  outline: 2px solid var(--color-action-primary-bg);
389
389
  outline-offset: 2px;
390
390
  }
391
+
392
+ /* ============================================
393
+ BADGE
394
+ A count or a dot on the top-end corner, in
395
+ BottomNav's count-badge treatment.
396
+ ============================================ */
397
+
398
+ .ds-circular-button--badged {
399
+ position: relative;
400
+ }
401
+
402
+ .ds-circular-button__badge {
403
+ position: absolute;
404
+ inset-block-start: calc(var(--padding-100) * -1);
405
+ inset-inline-end: calc(var(--padding-100) * -1);
406
+ box-sizing: border-box;
407
+ min-width: 16px;
408
+ height: 16px;
409
+ padding: 0 var(--padding-100);
410
+ border-radius: var(--radius-pill);
411
+ background-color: var(--color-count-badge-bg);
412
+ color: var(--color-count-badge-text);
413
+ font-family: var(--font-caption-family);
414
+ font-size: var(--font-caption-size);
415
+ font-weight: var(--font-paragraph-sm-emphasis-weight);
416
+ line-height: var(--font-caption-line-height);
417
+ text-align: center;
418
+ white-space: nowrap;
419
+ pointer-events: none;
420
+ }
421
+
422
+ .ds-circular-button__badge--dot {
423
+ inset-block-start: var(--padding-050);
424
+ inset-inline-end: var(--padding-050);
425
+ min-width: 0;
426
+ width: 8px;
427
+ height: 8px;
428
+ padding: 0;
429
+ }
@@ -64,6 +64,19 @@ type CircularButtonOwnProps = {
64
64
  target?: string;
65
65
  /** Optional rel attribute for links */
66
66
  rel?: string;
67
+ /** A mark on the button's top-end corner, as BottomNav draws one: a count (a notification bell's unread), or `true` for a dot with no number. */
68
+ badge?: number | string | true;
69
+ /** The highest count the badge spells out; a larger one reads "99+". Defaults to 99. */
70
+ badgeMax?: number;
71
+ /**
72
+ * Text read after `ariaLabel` while the button carries a badge, given the
73
+ * badge. Defaults to ", new" for a dot and ", 3 new" for a count; the
74
+ * leading comma and space are part of the text. The tooltip keeps
75
+ * `ariaLabel` alone.
76
+ */
77
+ badgeLabel?: (badge: number | string | true) => string;
78
+ /** The BCP 47 locale a numeric badge is written in, such as `ar-EG`. Defaults to `en-US`. This component can render from a Server Component, so it takes the prop alone and reads no LocaleProvider. */
79
+ locale?: string;
67
80
  /** Additional CSS classes */
68
81
  className?: string;
69
82
  /**
@@ -1,10 +1,11 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import React from "react";
3
3
  import { Spinner } from "../Spinner/Spinner.js";
4
4
  import { Tooltip } from "../Tooltip/Tooltip.js";
5
5
  import "./CircularButton.css";
6
6
  import "../../fonts/material-symbols.css";
7
7
  import { mirrorClass } from "../../behaviors/direction.js";
8
+ import { formatNumber, DEFAULT_LOCALE } from "../../behaviors/locale.js";
8
9
  function resolveCircularButtonCell(variant, tone) {
9
10
  const emphasis = variant === "neutral" ? "primary" : variant;
10
11
  const resolvedTone = tone ?? (variant === "neutral" ? "neutral" : "default");
@@ -32,6 +33,10 @@ const CircularButton = React.forwardRef(
32
33
  href,
33
34
  target,
34
35
  rel,
36
+ badge,
37
+ badgeMax = 99,
38
+ badgeLabel = defaultBadgeLabel,
39
+ locale = DEFAULT_LOCALE,
35
40
  className = "",
36
41
  linkComponent,
37
42
  ...rest
@@ -48,9 +53,17 @@ const CircularButton = React.forwardRef(
48
53
  `${baseClass}--${resolvedState}`,
49
54
  `${baseClass}--${size}`,
50
55
  isLoading && `${baseClass}--loading`,
56
+ badge !== void 0 && `${baseClass}--badged`,
51
57
  className
52
58
  ].filter(Boolean).join(" ");
53
- const children = isLoading ? /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon`, "aria-hidden": "true", children: /* @__PURE__ */ jsx(Spinner, { size: size === "compact" ? "sm" : "md", tone: "inherit" }) }) : /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon${typeof icon === "string" ? ` material-symbols-rounded ${mirrorClass(icon)}` : ""}`, "aria-hidden": "true", children: icon });
59
+ const glyph = isLoading ? /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon`, "aria-hidden": "true", children: /* @__PURE__ */ jsx(Spinner, { size: size === "compact" ? "sm" : "md", tone: "inherit" }) }) : /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon${typeof icon === "string" ? ` material-symbols-rounded ${mirrorClass(icon)}` : ""}`, "aria-hidden": "true", children: icon });
60
+ const badgeText = badge === void 0 || badge === true ? null : typeof badge === "number" ? badge > badgeMax ? `${formatNumber(badgeMax, locale)}+` : formatNumber(badge, locale) : badge;
61
+ const children = /* @__PURE__ */ jsxs(Fragment, { children: [
62
+ glyph,
63
+ badge === true && /* @__PURE__ */ jsx("span", { className: `${baseClass}__badge ${baseClass}__badge--dot`, "aria-hidden": "true" }),
64
+ badgeText !== null && /* @__PURE__ */ jsx("span", { className: `${baseClass}__badge`, "aria-hidden": "true", children: badgeText })
65
+ ] });
66
+ const accessibleName = badge === void 0 ? ariaLabel : `${ariaLabel}${badgeLabel(badge)}`;
54
67
  const control = href && !isDisabled && !isLoading ? /* @__PURE__ */ jsx(
55
68
  Link,
56
69
  {
@@ -60,7 +73,7 @@ const CircularButton = React.forwardRef(
60
73
  href,
61
74
  target,
62
75
  rel,
63
- "aria-label": ariaLabel,
76
+ "aria-label": accessibleName,
64
77
  children
65
78
  }
66
79
  ) : /* @__PURE__ */ jsx(
@@ -72,7 +85,7 @@ const CircularButton = React.forwardRef(
72
85
  className: classes,
73
86
  disabled: isDisabled || isLoading,
74
87
  "aria-busy": isLoading || void 0,
75
- "aria-label": ariaLabel,
88
+ "aria-label": accessibleName,
76
89
  children
77
90
  }
78
91
  );
@@ -82,6 +95,7 @@ const CircularButton = React.forwardRef(
82
95
  }
83
96
  );
84
97
  CircularButton.displayName = "CircularButton";
98
+ const defaultBadgeLabel = (badge) => badge === true ? ", new" : `, ${badge} new`;
85
99
  export {
86
100
  CircularButton
87
101
  };
@@ -13,7 +13,9 @@
13
13
  /* Sizing */
14
14
  flex: 1 1 0;
15
15
  min-width: 250px;
16
- height: 360px;
16
+ /* A floor, not a fixed height: a long token name wraps onto more lines in
17
+ a narrow column, and the card grows rather than cutting its last row. */
18
+ min-height: 360px;
17
19
 
18
20
  /* Appearance */
19
21
  border: var(--border-025) solid var(--color-bg-container-border);
@@ -22,13 +22,15 @@ export interface ColourSwatchProps {
22
22
  status?: boolean;
23
23
  /** CSS custom property for the status left border colour */
24
24
  borderVar?: string;
25
+ /** The label of the row that prints the token's name, the value of `cssVar`, as text */
26
+ tokenLabel?: string;
25
27
  /** Additional CSS classes */
26
28
  className?: string;
27
29
  }
28
30
  /**
29
31
  * ColourSwatch component from Figma design system
30
- * Displays a colour swatch card with a values box showing
31
- * Primitive, Hex, and RGB. Values switch when theme changes.
32
+ * Displays a colour swatch card with a values box showing the
33
+ * token's name, then Primitive, Hex, and RGB. Values switch when theme changes.
32
34
  * Used on Semantic colours and Primitive colours pages.
33
35
  */
34
- export declare const ColourSwatch: ({ label, cssVar, dark, light, theme, status, borderVar, className, }: ColourSwatchProps) => React.JSX.Element;
36
+ export declare const ColourSwatch: ({ label, cssVar, dark, light, theme, status, borderVar, tokenLabel, className, }: ColourSwatchProps) => React.JSX.Element;
@@ -9,6 +9,7 @@ const ColourSwatch = ({
9
9
  theme = "dark",
10
10
  status = false,
11
11
  borderVar,
12
+ tokenLabel = "Token",
12
13
  className = ""
13
14
  }) => {
14
15
  const baseClass = "ds-colour-swatch";
@@ -22,6 +23,10 @@ const ColourSwatch = ({
22
23
  return /* @__PURE__ */ jsxs("div", { className: classes, style, children: [
23
24
  /* @__PURE__ */ jsx("div", { className: `${baseClass}__title-box`, children: /* @__PURE__ */ jsx("h3", { className: `${baseClass}__title`, children: label }) }),
24
25
  /* @__PURE__ */ jsxs("div", { className: `${baseClass}__values`, children: [
26
+ /* @__PURE__ */ jsxs("div", { className: `${baseClass}__row`, children: [
27
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__label`, children: tokenLabel }),
28
+ /* @__PURE__ */ jsx("span", { className: `${baseClass}__data`, children: cssVar })
29
+ ] }),
25
30
  values.primitive && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__row`, children: [
26
31
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__label`, children: "Primitive" }),
27
32
  /* @__PURE__ */ jsx("span", { className: `${baseClass}__data`, children: values.primitive })
@@ -45,10 +45,12 @@ type ComboboxOwnProps = {
45
45
  disabled?: boolean;
46
46
  /** Whether the combobox is required */
47
47
  required?: boolean;
48
- /** Error state — shows error styling and message */
48
+ /** Error state: marks the control invalid and, in the older form without `errorText`, recolours the helper text as the error message. */
49
49
  error?: boolean;
50
- /** Helper or error message displayed below the field */
50
+ /** Helper text displayed below the control. With the older `error` flag and no `errorText`, it doubles as the error message. */
51
51
  helperText?: string;
52
+ /** The error message, shown under the control while the helper text keeps its place. Setting it marks the control invalid, so `error` is not needed alongside it; Field's spec owns the wiring. */
53
+ errorText?: React.ReactNode;
52
54
  /** Show a loading affordance in the menu — for async option fetching */
53
55
  loading?: boolean;
54
56
  /** Message shown when the filter matches no options */
@@ -20,6 +20,7 @@ const Combobox = React.forwardRef(({
20
20
  required = false,
21
21
  error = false,
22
22
  helperText,
23
+ errorText,
23
24
  loading = false,
24
25
  emptyMessage = "No results found",
25
26
  loadingMessage = "Loading…",
@@ -212,11 +213,13 @@ const Combobox = React.forwardRef(({
212
213
  }, [focusedIndex, isOpen]);
213
214
  const listboxId = `${inputId}-listbox`;
214
215
  const activeOptionId = focusedIndex >= 0 && filteredOptions[focusedIndex] ? `${inputId}-option-${filteredOptions[focusedIndex].value}` : void 0;
216
+ const hasErrorText = errorText != null && errorText !== false && errorText !== "";
217
+ const invalid = error || hasErrorText;
215
218
  const classes = [
216
219
  baseClass,
217
220
  size === "compact" ? `${baseClass}--compact` : "",
218
221
  isOpen ? `${baseClass}--open` : "",
219
- error ? `${baseClass}--error` : "",
222
+ invalid ? `${baseClass}--error` : "",
220
223
  disabled ? `${baseClass}--disabled` : "",
221
224
  multiple ? `${baseClass}--multiple` : "",
222
225
  className
@@ -259,6 +262,7 @@ const Combobox = React.forwardRef(({
259
262
  ref: setRootRef,
260
263
  label,
261
264
  helperText,
265
+ errorText,
262
266
  error,
263
267
  required,
264
268
  disabled,
@@ -306,8 +310,8 @@ const Combobox = React.forwardRef(({
306
310
  "aria-activedescendant": activeOptionId,
307
311
  "aria-label": ariaLabelAttr ?? ariaLabel ?? (!label ? placeholder : void 0),
308
312
  "aria-labelledby": ariaLabelledBy,
309
- "aria-describedby": [ariaDescribedBy, helperText ? `${inputId}-helper` : void 0].filter(Boolean).join(" ") || void 0,
310
- "aria-invalid": error || void 0,
313
+ "aria-describedby": [ariaDescribedBy, hasErrorText ? `${inputId}-error` : void 0, helperText ? `${inputId}-helper` : void 0].filter(Boolean).join(" ") || void 0,
314
+ "aria-invalid": invalid || void 0,
311
315
  "aria-required": required || void 0,
312
316
  placeholder: multiple && hasSelection ? "" : placeholder,
313
317
  value: inputValue,
@@ -846,6 +846,41 @@
846
846
  text-decoration: underline;
847
847
  }
848
848
 
849
+ /* ============================================
850
+ ROW ACTION (rowHref / onRowClick)
851
+ ============================================ */
852
+
853
+ /* The whole row is one target: the pointer says so, and the row's name
854
+ takes its underline while the row is hovered, the way a link answers. */
855
+ .ds-data-table__row--action {
856
+ cursor: pointer;
857
+ }
858
+
859
+ .ds-data-table__row-link {
860
+ /* Body text in the cell's own type, as the rest of the row reads: the
861
+ row's hover and the underline mark it, not the action colour. */
862
+ color: inherit;
863
+ font: inherit;
864
+ text-align: inherit;
865
+ text-decoration: none;
866
+ background: none;
867
+ border: none;
868
+ padding: 0;
869
+ margin: 0;
870
+ cursor: pointer;
871
+ border-radius: var(--radius-100);
872
+ }
873
+
874
+ .ds-data-table__row--action:hover .ds-data-table__row-link,
875
+ .ds-data-table__row-link:focus-visible {
876
+ text-decoration: underline;
877
+ }
878
+
879
+ .ds-data-table__row-link:focus-visible {
880
+ outline: 2px solid var(--color-action-primary-bg);
881
+ outline-offset: 2px;
882
+ }
883
+
849
884
  /* ============================================
850
885
  STACKED
851
886
  `phoneLayout="stack"` narrower than a phone:
@@ -20,6 +20,14 @@ export interface DataTableColumn<R extends DataTableRow = DataTableRow> {
20
20
  align?: 'start' | 'center' | 'end' | 'left' | 'right';
21
21
  /** Render the cell for a row; defaults to the row's raw value for this key. */
22
22
  render?: (row: R) => React.ReactNode;
23
+ /**
24
+ * Derives the column's value from the row's other values, such as a line's
25
+ * total from its quantity and unit price (`(values) => Number(values.quantity) * Number(values.price)`).
26
+ * The table reads it wherever it reads a value, so it sorts, filters, totals
27
+ * and groups, and it follows an edit to the cells it reads as the edit is
28
+ * made. A computed column is never editable.
29
+ */
30
+ compute?: (values: R['values']) => DataTableValue;
23
31
  /** Whether this column names each row: its cells render as row headers, and its value names the row's checkbox ("Select Ada Lovelace"). One column per table. */
24
32
  rowHeader?: boolean;
25
33
  /** Narrowest width a resize can reach, in pixels. Defaults to what the header needs (its padding, two letters of label, and its sort glyph and menu button) or, for an editable column, its editor, whichever is wider. */
@@ -73,6 +81,14 @@ export interface DataTableColumn<R extends DataTableRow = DataTableRow> {
73
81
  format?: DataTableColumnFormat;
74
82
  /** Whether the table can be grouped by this column, from its header menu or a TableToolbar. Defaults to false. */
75
83
  groupable?: boolean;
84
+ /**
85
+ * The order this column's groups take, as the values they gather by
86
+ * (`['Revenue', 'Cost of sales', 'Expenses']`): the groups listed come
87
+ * first, in this order whichever way the column sorts, and any others
88
+ * follow in the column's own order. A `status` column already groups in
89
+ * its options' order.
90
+ */
91
+ groupOrder?: string[];
76
92
  /**
77
93
  * The calculation a group row shows in this column, and the totals
78
94
  * footer's starting pick: `sum`, `avg`, `min`, `max`, `count`,
@@ -346,8 +362,24 @@ type DataTableOwnProps<R extends DataTableRow = DataTableRow> = {
346
362
  defaultSorts?: DataTableSort[];
347
363
  /** Fires with every sort after one changes, first sort first. `onSortChange` fires too, with the first or `null`. */
348
364
  onSortsChange?: (sorts: DataTableSort[]) => void;
349
- /** The link component a `link` column's cells render through, so the app's router handles them. Defaults to the nearest `LinkProvider`'s, else a plain anchor. */
365
+ /** The link component a `link` column's cells and `rowHref` render through, so the app's router handles them. Defaults to the nearest `LinkProvider`'s, else a plain anchor. */
350
366
  linkComponent?: LinkComponent;
367
+ /**
368
+ * Makes each row a link to the address it returns. The row header's content
369
+ * (the `rowHeader` column, else the first column shown) becomes the link,
370
+ * so a keyboard and a screen reader reach it as one, and a click anywhere
371
+ * else on the row follows it, except on the row's own controls or while
372
+ * text is being selected. A row it returns `undefined` for stays plain. A
373
+ * row header's `render` should not draw a link of its own alongside it.
374
+ */
375
+ rowHref?: (row: R) => string | undefined;
376
+ /**
377
+ * Makes each row open something in place (a drawer, a dialog) instead of
378
+ * navigating: the row header's content becomes a button that calls it, and
379
+ * a click anywhere else on the row presses that button, except on the
380
+ * row's own controls. `rowHref` wins on a row both give an action.
381
+ */
382
+ onRowClick?: (row: R) => void;
351
383
  /**
352
384
  * Draws only the rows in view, so a table of thousands scrolls as
353
385
  * smoothly as one of ten. `auto` (the default) does it for an unpaged,
@@ -574,7 +606,7 @@ type DataTableOwnProps<R extends DataTableRow = DataTableRow> = {
574
606
  };
575
607
  export interface DataTableProps<R extends DataTableRow = DataTableRow> extends DataTableOwnProps<R>, Omit<React.ComponentPropsWithRef<'div'>, keyof DataTableOwnProps<R>> {
576
608
  }
577
- export declare function DataTable<R extends DataTableRow = DataTableRow>({ columns: columnsProp, rows, pageSize: pageSizeProp, defaultPageSize, onPageSizeChange, pageSizeOptions, page: pageProp, defaultPage, onPageChange, pageSizeLabel, phoneLayout, selectable, selectedIds, defaultSelectedIds, onSelectionChange, sort, defaultSort, onSortChange, sorts: sortsProp, defaultSorts, onSortsChange, multiSort, onViewChange, virtualize, onLoadMore, hasMore, renderDetail, expandedIds: expandedProp, defaultExpandedIds, onExpandedIdsChange, expandMode, grouping: groupingProp, defaultGrouping, onGroupingChange, totalsRow, totals: totalsProp, defaultTotals, onTotalsChange, linkComponent, searchable, searchPlaceholder, toolbar, size: sizeProp, defaultSize, onSizeChange, filters: filtersProp, defaultFilters, onFiltersChange, search: searchProp, defaultSearch, onSearchChange, filterLabels: filterLabelsProp, striped, caption, emptyState, selectAllLabel, selectRowLabel, sortLabel, sortRankLabel, sortAnnouncement, pageAnnouncement, resultsLabel, selectedLabel, paginationLabels, emptyStateLabels, resizableColumns, reorderableColumns, columnMenu, reorderableRows, stickyHeader, maxHeight, navigation, columnWidths, defaultColumnWidths, onColumnWidthsChange, columnOrder, defaultColumnOrder, onColumnOrderChange, columnPinning, defaultColumnPinning, onColumnPinningChange, hiddenColumns, defaultHiddenColumns, onHiddenColumnsChange, rowOrder, defaultRowOrder, onRowOrderChange, columnLabels, columnDividers, cellText, rowActions, rowActionsVisibility, editMode, onCellEdit, onRowEdit, manual, rowCount: rowCountProp, loading, error, onRetry, loadLabels, locale: localeProp, className, ref, ...rest }: DataTableProps<R>): React.JSX.Element;
609
+ export declare function DataTable<R extends DataTableRow = DataTableRow>({ columns: columnsProp, rows: rowsProp, pageSize: pageSizeProp, defaultPageSize, onPageSizeChange, pageSizeOptions, page: pageProp, defaultPage, onPageChange, pageSizeLabel, phoneLayout, selectable, selectedIds, defaultSelectedIds, onSelectionChange, sort, defaultSort, onSortChange, sorts: sortsProp, defaultSorts, onSortsChange, multiSort, onViewChange, virtualize, onLoadMore, hasMore, renderDetail, expandedIds: expandedProp, defaultExpandedIds, onExpandedIdsChange, expandMode, grouping: groupingProp, defaultGrouping, onGroupingChange, totalsRow, totals: totalsProp, defaultTotals, onTotalsChange, linkComponent, rowHref, onRowClick, searchable, searchPlaceholder, toolbar, size: sizeProp, defaultSize, onSizeChange, filters: filtersProp, defaultFilters, onFiltersChange, search: searchProp, defaultSearch, onSearchChange, filterLabels: filterLabelsProp, striped, caption, emptyState, selectAllLabel, selectRowLabel, sortLabel, sortRankLabel, sortAnnouncement, pageAnnouncement, resultsLabel, selectedLabel, paginationLabels, emptyStateLabels, resizableColumns, reorderableColumns, columnMenu, reorderableRows, stickyHeader, maxHeight, navigation, columnWidths, defaultColumnWidths, onColumnWidthsChange, columnOrder, defaultColumnOrder, onColumnOrderChange, columnPinning, defaultColumnPinning, onColumnPinningChange, hiddenColumns, defaultHiddenColumns, onHiddenColumnsChange, rowOrder, defaultRowOrder, onRowOrderChange, columnLabels, columnDividers, cellText, rowActions, rowActionsVisibility, editMode, onCellEdit, onRowEdit, manual, rowCount: rowCountProp, loading, error, onRetry, loadLabels, locale: localeProp, className, ref, ...rest }: DataTableProps<R>): React.JSX.Element;
578
610
  /**
579
611
  * A stored view made safe for a table's columns as they are now: columns
580
612
  * that no longer exist drop out of every part of it, a filter whose
@@ -169,7 +169,7 @@ function withType(col, locale) {
169
169
  }
170
170
  function DataTable({
171
171
  columns: columnsProp,
172
- rows,
172
+ rows: rowsProp,
173
173
  pageSize: pageSizeProp,
174
174
  defaultPageSize,
175
175
  onPageSizeChange,
@@ -207,6 +207,8 @@ function DataTable({
207
207
  defaultTotals,
208
208
  onTotalsChange,
209
209
  linkComponent,
210
+ rowHref,
211
+ onRowClick,
210
212
  searchable = false,
211
213
  searchPlaceholder = "Search",
212
214
  toolbar,
@@ -278,6 +280,15 @@ function DataTable({
278
280
  ref,
279
281
  ...rest
280
282
  }) {
283
+ const rows = useMemo(() => {
284
+ const computed = columnsProp.filter((col) => col.compute);
285
+ if (computed.length === 0) return rowsProp;
286
+ return rowsProp.map((row) => {
287
+ const values = { ...row.values };
288
+ for (const col of computed) values[col.key] = col.compute(values);
289
+ return { ...row, values };
290
+ });
291
+ }, [rowsProp, columnsProp]);
281
292
  const baseClass = "ds-data-table";
282
293
  const locale = useLocale(localeProp);
283
294
  const collator = useMemo(() => textCollator(locale), [locale]);
@@ -578,7 +589,11 @@ function DataTable({
578
589
  const compare = typedComparator(groupCol.type, groupCol.options, compareValues);
579
590
  const desc = sortOf(groupKey)?.direction === "desc";
580
591
  const first = (key) => byValue.get(key)[0].values[groupKey];
592
+ const listed = groupCol.groupOrder ?? [];
581
593
  const keys = [...byValue.keys()].sort((a, b) => {
594
+ const ia = listed.indexOf(a);
595
+ const ib = listed.indexOf(b);
596
+ if (ia !== -1 || ib !== -1) return ia === -1 ? 1 : ib === -1 ? -1 : ia - ib;
582
597
  if (a === "" || b === "") return a === "" ? b === "" ? 0 : 1 : -1;
583
598
  const order = compare(first(a), first(b));
584
599
  return desc ? -order : order;
@@ -1287,8 +1302,12 @@ function DataTable({
1287
1302
  const kind = kindOf$1(col);
1288
1303
  return kind !== void 0 && LIVE_KINDS.has(kind);
1289
1304
  };
1290
- const canEdit = (col, row) => Boolean(col?.editor) && (typeof col?.editable === "function" ? col.editable(row) : col?.editable ?? true);
1291
- const valueOf = (row, key) => pending[row.id] && key in pending[row.id] ? pending[row.id][key] : row.values[key];
1305
+ const canEdit = (col, row) => !col?.compute && Boolean(col?.editor) && (typeof col?.editable === "function" ? col.editable(row) : col?.editable ?? true);
1306
+ const valueOf = (row, key) => {
1307
+ const compute = byKey.get(key)?.compute;
1308
+ if (compute && pending[row.id]) return compute({ ...row.values, ...pending[row.id] });
1309
+ return pending[row.id] && key in pending[row.id] ? pending[row.id][key] : row.values[key];
1310
+ };
1292
1311
  const rowView = (row) => pending[row.id] ? { ...row, values: { ...row.values, ...pending[row.id] } } : row;
1293
1312
  const sameValue = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
1294
1313
  const isThenable = (value) => typeof value?.then === "function";
@@ -1423,6 +1442,26 @@ function DataTable({
1423
1442
  commitEdit("none");
1424
1443
  };
1425
1444
  const linkEl = useLinkComponent(linkComponent);
1445
+ const RowLink = linkEl;
1446
+ const actionKey = rowHeaderKey ?? visibleKeys[0];
1447
+ const followRowAction = (event) => {
1448
+ if (event.defaultPrevented || editing) return;
1449
+ const target = event.target;
1450
+ if (target.closest('a, button, input, select, textarea, label, [role="checkbox"], [role="switch"], [data-cell-control], [contenteditable="true"]'))
1451
+ return;
1452
+ if (window.getSelection()?.toString()) return;
1453
+ const control = event.currentTarget.querySelector(`.${baseClass}__row-link`);
1454
+ control?.dispatchEvent(
1455
+ new MouseEvent("click", {
1456
+ bubbles: true,
1457
+ cancelable: true,
1458
+ ctrlKey: event.ctrlKey,
1459
+ metaKey: event.metaKey,
1460
+ shiftKey: event.shiftKey,
1461
+ altKey: event.altKey
1462
+ })
1463
+ );
1464
+ };
1426
1465
  const typedWords = { checked: labels.checkedValue, unchecked: labels.uncheckedValue, more: labels.moreValues };
1427
1466
  const optionLabel = (col) => (v) => col.options?.find((option) => option.value === v)?.label ?? v;
1428
1467
  const numericColumn = (col) => col.type === "number" || col.type === "currency" || col.type === "progress" || !col.type && rows.some((row) => typeof row.values[col.key] === "number") && rows.every((row) => row.values[col.key] == null || typeof row.values[col.key] === "number");
@@ -1933,6 +1972,8 @@ function DataTable({
1933
1972
  const name = rowName(row);
1934
1973
  const expandedHere = Boolean(renderDetail) && expandedState.includes(row.id);
1935
1974
  const detailId = `${tableId}-detail-${row.id}`;
1975
+ const href = rowHref?.(rowView(row));
1976
+ const rowAction = href !== void 0 || Boolean(onRowClick);
1936
1977
  const record = /* @__PURE__ */ jsxs(
1937
1978
  "tr",
1938
1979
  {
@@ -1941,8 +1982,10 @@ function DataTable({
1941
1982
  "data-index": slot && part === "record" ? slot.index : void 0,
1942
1983
  "aria-rowindex": slot && part === "record" ? slot.index + 2 : void 0,
1943
1984
  role: stacked ? "row" : void 0,
1985
+ onClick: rowAction ? followRowAction : void 0,
1944
1986
  className: [
1945
1987
  "ds-table__row",
1988
+ rowAction ? `${baseClass}__row--action` : "",
1946
1989
  isSelected ? "ds-table__row--selected" : "",
1947
1990
  editMode === "row" && editing?.row === row.id ? `${baseClass}__row--editing` : ""
1948
1991
  ].filter(Boolean).join(" "),
@@ -2085,13 +2128,23 @@ function DataTable({
2085
2128
  link: linkEl
2086
2129
  }
2087
2130
  ) : displayOf(col, raw);
2088
- if (fit === "wrap") return content;
2131
+ const linked = rowAction && key === actionKey && !editingHere ? href !== void 0 ? /* @__PURE__ */ jsx(RowLink, { href, className: `${baseClass}__row-link`, tabIndex: innerTab, children: content }) : /* @__PURE__ */ jsx(
2132
+ "button",
2133
+ {
2134
+ type: "button",
2135
+ className: `${baseClass}__row-link`,
2136
+ tabIndex: innerTab,
2137
+ onClick: () => onRowClick?.(rowView(row)),
2138
+ children: content
2139
+ }
2140
+ ) : content;
2141
+ if (fit === "wrap") return linked;
2089
2142
  return /* @__PURE__ */ jsx(
2090
2143
  "span",
2091
2144
  {
2092
2145
  className: `${baseClass}__text ${baseClass}__text--${fit}`,
2093
2146
  title: fit === "truncate" || fit === "lines-2" ? raw == null ? void 0 : col.type ? typedText(col.type, raw, col.format, optionLabel(col), typedWords) || void 0 : String(displayOf(col, raw)) : void 0,
2094
- children: content
2147
+ children: linked
2095
2148
  }
2096
2149
  );
2097
2150
  })()
@@ -8,7 +8,7 @@ export interface ColumnFormat {
8
8
  locale?: string;
9
9
  /** ISO 4217 code for a `currency` column. Defaults to `USD`. */
10
10
  currency?: string;
11
- /** Digits after the point for `number`, `currency` and `progress`. Defaults to none for money and progress, and up to two for a number. */
11
+ /** Digits after the point for `number`, `currency` and `progress`. Defaults to the currency's own minor units for money (two for USD, none for JPY), none for progress, and up to two for a number. */
12
12
  fractionDigits?: number;
13
13
  /** How a `date` column reads: `short` (11/04/26), `medium` (Nov 4, 2026), `long` (November 4, 2026) or `relative` (in 3 days). Defaults to `medium`; the full date shows on hover either way. */
14
14
  date?: 'short' | 'medium' | 'long' | 'relative';
@@ -28,7 +28,7 @@ const formatNumber = (type, value, format) => {
28
28
  const locale = format?.locale ?? DEFAULT_LOCALE;
29
29
  const digits = format?.fractionDigits;
30
30
  if (type === "currency")
31
- return formatMoney(value, { currency: format?.currency ?? "USD", locale, fractionDigits: digits ?? 0 });
31
+ return formatMoney(value, { currency: format?.currency ?? "USD", locale, fractionDigits: digits });
32
32
  if (type === "progress")
33
33
  return new Intl.NumberFormat(locale, {
34
34
  style: "percent",
@@ -7,10 +7,12 @@ type DateInputOwnProps = {
7
7
  value?: string;
8
8
  /** Component size (not the native character-width `size` attribute) */
9
9
  size?: 'default' | 'compact';
10
- /** Error state */
10
+ /** Error state: marks the control invalid and, in the older form without `errorText`, recolours the helper text as the error message. */
11
11
  error?: boolean;
12
- /** Helper or error message */
12
+ /** Helper text displayed below the control. With the older `error` flag and no `errorText`, it doubles as the error message. */
13
13
  helperText?: string;
14
+ /** The error message, shown under the control while the helper text keeps its place. Setting it marks the control invalid, so `error` is not needed alongside it; Field's spec owns the wiring. */
15
+ errorText?: React.ReactNode;
14
16
  /** Minimum selectable date (YYYY-MM-DD) */
15
17
  min?: string;
16
18
  /** Maximum selectable date (YYYY-MM-DD) */
@@ -14,6 +14,7 @@ const DateInput = React.forwardRef(
14
14
  required = false,
15
15
  error = false,
16
16
  helperText,
17
+ errorText,
17
18
  min,
18
19
  max,
19
20
  onChange,
@@ -25,10 +26,12 @@ const DateInput = React.forwardRef(
25
26
  ...rest
26
27
  }, ref) => {
27
28
  const baseClass = "ds-date-input";
29
+ const hasErrorText = errorText != null && errorText !== false && errorText !== "";
30
+ const invalid = error || hasErrorText;
28
31
  const classes = [
29
32
  baseClass,
30
33
  `${baseClass}--${size}`,
31
- error ? `${baseClass}--error` : "",
34
+ invalid ? `${baseClass}--error` : "",
32
35
  disabled ? `${baseClass}--disabled` : "",
33
36
  className
34
37
  ].filter(Boolean).join(" ");
@@ -43,6 +46,7 @@ const DateInput = React.forwardRef(
43
46
  className: classes,
44
47
  label,
45
48
  helperText,
49
+ errorText,
46
50
  error,
47
51
  required,
48
52
  disabled,
@@ -66,8 +70,8 @@ const DateInput = React.forwardRef(
66
70
  min,
67
71
  max,
68
72
  "aria-label": rest["aria-label"] ?? ariaLabel ?? label,
69
- "aria-invalid": error,
70
- "aria-describedby": [rest["aria-describedby"], helperText ? `${inputId}-helper` : void 0].filter(Boolean).join(" ") || void 0,
73
+ "aria-invalid": invalid,
74
+ "aria-describedby": [rest["aria-describedby"], hasErrorText ? `${inputId}-error` : void 0, helperText ? `${inputId}-helper` : void 0].filter(Boolean).join(" ") || void 0,
71
75
  onChange: handleChange
72
76
  }
73
77
  )
@@ -97,6 +97,34 @@
97
97
  letter-spacing: var(--font-paragraph-sm-letter-spacing);
98
98
  }
99
99
 
100
+ /* Emphasis: the entry the others add up to, under a rule, its term and
101
+ value in the emphasis weight and the primary text colour. With dividers
102
+ the entry above already draws the rule. */
103
+ .ds-description-list__item--emphasis {
104
+ padding-block-start: var(--padding-300);
105
+ border-block-start: var(--border-025) solid var(--color-divider);
106
+ }
107
+
108
+ .ds-description-list--dividers .ds-description-list__item--emphasis {
109
+ border-block-start: none;
110
+ }
111
+
112
+ .ds-description-list__item--emphasis .ds-description-list__term {
113
+ color: var(--color-text-primary);
114
+ }
115
+
116
+ .ds-description-list--default .ds-description-list__item--emphasis .ds-description-list__term,
117
+ .ds-description-list--default .ds-description-list__item--emphasis .ds-description-list__details {
118
+ font-family: var(--font-paragraph-emphasis-family);
119
+ font-weight: var(--font-paragraph-emphasis-weight);
120
+ }
121
+
122
+ .ds-description-list--compact .ds-description-list__item--emphasis .ds-description-list__term,
123
+ .ds-description-list--compact .ds-description-list__item--emphasis .ds-description-list__details {
124
+ font-family: var(--font-paragraph-sm-emphasis-family);
125
+ font-weight: var(--font-paragraph-sm-emphasis-weight);
126
+ }
127
+
100
128
  /* Inline: term and value in two columns, the term a quarter, a third or a half */
101
129
  .ds-description-list--inline .ds-description-list__item {
102
130
  display: grid;
@@ -11,6 +11,8 @@ export type DescriptionListEntry = {
11
11
  action?: React.ReactNode;
12
12
  /** Offer a copy button: `true` copies the value when it is text, a string copies that string (the unformatted account number behind a formatted one). */
13
13
  copyable?: boolean | string;
14
+ /** Sets the entry apart as the one the others add up to (a total, a balance due): its term and value in the emphasis weight and the primary text colour, under a rule. */
15
+ emphasis?: boolean;
14
16
  };
15
17
  /** Props owned by DescriptionList itself; everything else falls through to the `<dl>`. */
16
18
  type DescriptionListOwnProps = {
@@ -60,5 +62,5 @@ type DescriptionListItemOwnProps = Omit<DescriptionListEntry, 'id'> & {
60
62
  export interface DescriptionListItemProps extends DescriptionListItemOwnProps, Omit<React.ComponentPropsWithRef<'div'>, keyof DescriptionListItemOwnProps> {
61
63
  }
62
64
  /** One term and its value inside a DescriptionList, for a list written out by hand. Server-renderable. */
63
- export declare function DescriptionListItem({ term, details, children, action, copyable, className, ref, ...rest }: DescriptionListItemProps): React.JSX.Element;
65
+ export declare function DescriptionListItem({ term, details, children, action, copyable, emphasis, className, ref, ...rest }: DescriptionListItemProps): React.JSX.Element;
64
66
  export {};
@@ -5,11 +5,11 @@ import "../../behaviors/visually-hidden.css";
5
5
  import "./DescriptionList.css";
6
6
  const isEmpty = (value) => value == null || value === false || value === "";
7
7
  const textOf = (value) => typeof value === "string" || typeof value === "number" ? String(value) : null;
8
- function renderEntry({ term, details, id, action, copyable }, settings, className = "", rest = {}, ref) {
8
+ function renderEntry({ term, details, id, action, copyable, emphasis }, settings, className = "", rest = {}, ref) {
9
9
  const empty = isEmpty(details);
10
10
  const copyText = empty ? null : typeof copyable === "string" ? copyable : copyable ? textOf(details) : null;
11
11
  const termText = textOf(term);
12
- const classes = ["ds-description-list__item", className].filter(Boolean).join(" ");
12
+ const classes = ["ds-description-list__item", emphasis && "ds-description-list__item--emphasis", className].filter(Boolean).join(" ");
13
13
  return /* @__PURE__ */ jsxs("div", { ...rest, ref, id: id ?? rest.id, className: classes, children: [
14
14
  /* @__PURE__ */ jsx("dt", { className: "ds-description-list__term", children: term }),
15
15
  /* @__PURE__ */ jsxs("dd", { className: "ds-description-list__details", children: [
@@ -75,6 +75,7 @@ function DescriptionListItem({
75
75
  children,
76
76
  action,
77
77
  copyable,
78
+ emphasis,
78
79
  className = "",
79
80
  ref,
80
81
  ...rest
@@ -87,7 +88,7 @@ function DescriptionListItem({
87
88
  onValueCopy: passed?.onValueCopy
88
89
  };
89
90
  return renderEntry(
90
- { term, details: details ?? children, action, copyable },
91
+ { term, details: details ?? children, action, copyable, emphasis },
91
92
  settings,
92
93
  className,
93
94
  divRest,