rift-ds 1.28.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 (140) hide show
  1. package/README.md +5 -4
  2. package/bin/rift-ds.mjs +5 -4
  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/app/shader/page.module.css +75 -0
  8. package/bin/templates/blocks/app/shader/page.tsx +81 -0
  9. package/bin/templates/blocks/components/blocks/AppShell.module.css +8 -41
  10. package/bin/templates/blocks/components/blocks/AppShell.tsx +9 -11
  11. package/bin/templates/blocks/components/blocks/emberScene.ts +53 -0
  12. package/bin/templates/blocks/registry.json +24 -0
  13. package/bin/templates/chat/app/api/chat/feedback/route.ts +0 -3
  14. package/bin/templates/chat/app/api/chat/followups/route.ts +0 -3
  15. package/bin/templates/chat/app/api/chat/route.ts +0 -2
  16. package/chat/ChatLauncher.d.ts +9 -1
  17. package/chat/ChatLauncher.js +3 -1
  18. package/chat/threads.js +7 -4
  19. package/components/Alert/Alert.css +12 -0
  20. package/components/Alert/Alert.d.ts +2 -0
  21. package/components/Alert/Alert.js +3 -1
  22. package/components/Attachment/Attachment.css +92 -0
  23. package/components/Attachment/FileRow.d.ts +47 -0
  24. package/components/Attachment/FileRow.js +38 -0
  25. package/components/Avatar/Avatar.css +14 -0
  26. package/components/Avatar/Avatar.d.ts +3 -1
  27. package/components/Avatar/Avatar.js +3 -2
  28. package/components/Button/Button.css +38 -0
  29. package/components/Button/Button.d.ts +8 -0
  30. package/components/Button/Button.js +2 -0
  31. package/components/Chart/AreaChart.d.ts +2 -0
  32. package/components/Chart/AreaChart.js +2 -1
  33. package/components/Chart/BarChart.d.ts +2 -0
  34. package/components/Chart/BarChart.js +2 -1
  35. package/components/Chart/ComboChart.d.ts +4 -0
  36. package/components/Chart/ComboChart.js +4 -2
  37. package/components/Chart/LineChart.d.ts +2 -0
  38. package/components/Chart/LineChart.js +2 -1
  39. package/components/Chart/PieChart.d.ts +4 -4
  40. package/components/Chart/PieChart.js +1 -1
  41. package/components/Chart/ScatterChart.d.ts +2 -0
  42. package/components/Chart/ScatterChart.js +2 -1
  43. package/components/Checklist/Checklist.css +123 -0
  44. package/components/Checklist/Checklist.d.ts +66 -0
  45. package/components/Checklist/Checklist.js +115 -0
  46. package/components/CircularButton/CircularButton.css +39 -0
  47. package/components/CircularButton/CircularButton.d.ts +13 -0
  48. package/components/CircularButton/CircularButton.js +18 -4
  49. package/components/ColourSwatch/ColourSwatch.css +3 -1
  50. package/components/ColourSwatch/ColourSwatch.d.ts +5 -3
  51. package/components/ColourSwatch/ColourSwatch.js +5 -0
  52. package/components/Combobox/Combobox.d.ts +4 -2
  53. package/components/Combobox/Combobox.js +7 -3
  54. package/components/DataTable/DataTable.css +35 -0
  55. package/components/DataTable/DataTable.d.ts +34 -2
  56. package/components/DataTable/DataTable.js +58 -5
  57. package/components/DataTable/columnTypes.d.ts +1 -1
  58. package/components/DataTable/columnTypes.js +1 -1
  59. package/components/DateInput/DateInput.d.ts +4 -2
  60. package/components/DateInput/DateInput.js +7 -3
  61. package/components/DescriptionList/DescriptionList.css +28 -0
  62. package/components/DescriptionList/DescriptionList.d.ts +3 -1
  63. package/components/DescriptionList/DescriptionList.js +4 -3
  64. package/components/DescriptionList/DescriptionListCopy.js +2 -0
  65. package/components/Dropdown/Dropdown.d.ts +4 -2
  66. package/components/Dropdown/Dropdown.js +7 -3
  67. package/components/EmptyState/EmptyState.css +12 -0
  68. package/components/EmptyState/EmptyState.d.ts +7 -0
  69. package/components/EmptyState/EmptyState.js +2 -0
  70. package/components/EventCalendar/EventCalendar.css +59 -0
  71. package/components/EventCalendar/EventCalendar.d.ts +24 -2
  72. package/components/EventCalendar/EventCalendar.js +104 -19
  73. package/components/FormSection/FormSection.css +70 -0
  74. package/components/FormSection/FormSection.d.ts +35 -0
  75. package/components/FormSection/FormSection.js +35 -0
  76. package/components/Grid/Grid.css +52 -0
  77. package/components/Grid/Grid.d.ts +30 -0
  78. package/components/Grid/Grid.js +36 -0
  79. package/components/Icon/Icon.css +55 -0
  80. package/components/Icon/Icon.d.ts +27 -0
  81. package/components/Icon/Icon.js +42 -0
  82. package/components/NumberInput/NumberInput.d.ts +4 -2
  83. package/components/NumberInput/NumberInput.js +7 -3
  84. package/components/OrgChart/OrgChart.css +143 -0
  85. package/components/OrgChart/OrgChart.d.ts +44 -0
  86. package/components/OrgChart/OrgChart.js +26 -0
  87. package/components/PageHeader/PageHeader.css +74 -0
  88. package/components/PageHeader/PageHeader.d.ts +39 -0
  89. package/components/PageHeader/PageHeader.js +33 -0
  90. package/components/Panel/Panel.css +7 -0
  91. package/components/Panel/Panel.d.ts +5 -2
  92. package/components/Panel/Panel.js +2 -1
  93. package/components/ResourceTimeline/ResourceTimeline.css +194 -0
  94. package/components/ResourceTimeline/ResourceTimeline.d.ts +57 -0
  95. package/components/ResourceTimeline/ResourceTimeline.js +129 -0
  96. package/components/ShaderField/useShaderField.js +13 -1
  97. package/components/ShaderScene/ShaderScene.d.ts +39 -15
  98. package/components/ShaderScene/ShaderScene.js +87 -6
  99. package/components/ShaderScene/assemble.d.ts +10 -3
  100. package/components/ShaderScene/assemble.js +29 -0
  101. package/components/ShaderScene/renderer.d.ts +12 -4
  102. package/components/ShaderScene/renderer.js +32 -20
  103. package/components/ShaderScene/scenes.d.ts +78 -0
  104. package/components/ShaderScene/scenes.js +933 -1
  105. package/components/ShaderScene/types.d.ts +52 -23
  106. package/components/Stack/Stack.css +68 -0
  107. package/components/Stack/Stack.d.ts +37 -0
  108. package/components/Stack/Stack.js +39 -0
  109. package/components/Stat/Stat.css +65 -0
  110. package/components/Stat/Stat.d.ts +7 -1
  111. package/components/Stat/Stat.js +16 -1
  112. package/components/Table/Table.css +11 -0
  113. package/components/Table/Table.d.ts +2 -0
  114. package/components/Table/Table.js +5 -1
  115. package/components/Tabs/Tabs.css +23 -0
  116. package/components/Tabs/Tabs.d.ts +9 -8
  117. package/components/Tabs/Tabs.js +38 -5
  118. package/components/Textarea/Textarea.d.ts +4 -2
  119. package/components/Textarea/Textarea.js +7 -3
  120. package/components/ThemeToggle/colorMode.d.ts +17 -1
  121. package/components/ThemeToggle/colorMode.js +11 -2
  122. package/components/Widget/Widget.css +21 -0
  123. package/components/Widget/Widget.d.ts +4 -0
  124. package/components/Widget/Widget.js +13 -5
  125. package/components/Wizard/Wizard.css +67 -0
  126. package/components/Wizard/Wizard.d.ts +54 -0
  127. package/components/Wizard/Wizard.js +71 -0
  128. package/components/registry.d.ts +25 -0
  129. package/components/registry.js +8 -0
  130. package/components/registry.json +234 -33
  131. package/components/registry.json.d.ts +234 -33
  132. package/components/registry.json.js +1 -1
  133. package/index.d.ts +10 -0
  134. package/index.js +20 -0
  135. package/package.json +1 -1
  136. package/tokens/motion.d.ts +2 -0
  137. package/tokens/motion.js +2 -0
  138. package/tokens/values.d.ts +31 -0
  139. package/tokens/values.js +16 -0
  140. package/tokens/values.json.js +1 -1
@@ -5,51 +5,80 @@
5
5
  * with theirs. Every setting is declared as data, so the panel draws its
6
6
  * sliders from the declaration and never needs a hand-built control.
7
7
  */
8
- /** One numeric setting, drawn as a slider. */
9
- export type ParamSpec = {
8
+ /** One numeric setting of a scene, drawn as a slider by a host that offers controls. */
9
+ export type ShaderSceneParamSpec = {
10
+ /** The setting's name: a GLSL identifier, which the scene reads as `uniform float u_<key>`. */
10
11
  key: string;
12
+ /** The name a host prints beside the slider. */
11
13
  label: string;
14
+ /** The lowest value the slider offers. */
12
15
  min: number;
16
+ /** The highest value the slider offers. */
13
17
  max: number;
18
+ /** The slider's step. */
14
19
  step: number;
20
+ /** The value the scene takes when `params` does not set this key. */
15
21
  default: number;
16
22
  };
23
+ /** The engine's own name for a setting; `ShaderSceneParamSpec` is the published one. */
24
+ export type ParamSpec = ShaderSceneParamSpec;
17
25
  /**
18
- * A look. `glsl` defines `vec3 scene(vec2 uv, float t)`, returning the
19
- * final linear colour of the pixel over the page ground (`u_ground`). Its
20
- * settings arrive as `uniform float u_<key>`, and its colours as
21
- * `u_col[i]` in the order `colours` lists their tokens.
26
+ * A scene of your own, as ShaderScene's `scene` prop takes it: the colour
27
+ * roles it reads, its settings, and the GLSL that paints it. Hold it at
28
+ * module scope or pass it inline; the program is rebuilt only when its
29
+ * content changes.
22
30
  */
23
- export type Scene = {
24
- id: string;
25
- label: string;
26
- description: string;
27
- /** Colour tokens, resolved from the live cascade into `u_col[0..]`. */
31
+ export type ShaderSceneSource = {
32
+ /**
33
+ * The colour custom properties the scene reads, resolved from the live
34
+ * cascade at the scene into `u_col[0..]` in this order, eight at most.
35
+ * Name the `--color-ambient-*` roles and the scene re-themes with the page.
36
+ */
28
37
  colours: string[];
29
38
  /**
30
- * `dark` for a scene that only reads on a dark ground (it adds light).
31
- * On a light page its surface paints a near-black ground of its own
32
- * (coloursFor), rather than setting data-theme on itself: a nested
33
- * [data-theme] matches the base dark tokens and would hide the theme
34
- * preset's colours.
39
+ * `dark` for a scene that only adds light and so only reads on a dark
40
+ * ground. On a light page its light is computed against a near-black
41
+ * ground of its own and laid onto the page as a pale tint. A scene
42
+ * without it paints for both modes itself, from the page ground
43
+ * (`u_ground`).
35
44
  */
36
45
  mode?: "dark";
37
46
  /**
38
- * A ramp of characters, thin to heavy, for a scene that prints type. The
39
- * renderer draws it once into a strip texture in the theme's code face
40
- * (`--font-family-code`) and hands it to the GLSL as `u_glyphs`, with
41
- * the number of characters in `u_glyphCount`.
47
+ * A ramp of characters, thin to heavy, for a scene that prints type. It
48
+ * is drawn once into a strip texture in the theme's code face
49
+ * (`--font-family-code`) and reaches the GLSL as `u_glyphs`, with the
50
+ * number of characters in `u_glyphCount`.
42
51
  */
43
52
  glyphs?: string;
44
53
  /**
45
54
  * The most drawing-buffer pixels per CSS pixel the scene may use, for a
46
- * scene with detail finer than soft light (type). Defaults to 1; the
47
- * ratio in use reaches the GLSL as `u_ratio`.
55
+ * scene with detail finer than soft light (type, points). Defaults to 1;
56
+ * the ratio in use reaches the GLSL as `u_ratio`.
48
57
  */
49
58
  pixelRatio?: number;
50
- params: ParamSpec[];
59
+ /** The scene's settings. Each arrives in the GLSL as `uniform float u_<key>`, declared for you. */
60
+ params: ShaderSceneParamSpec[];
61
+ /**
62
+ * GLSL ES 3.00 defining `vec3 scene(vec2 uv, float t)`, which returns the
63
+ * pixel's linear colour over the ground (`u_ground`). `uv` runs 0 to 1
64
+ * from the bottom left and `t` is the scene's clock in seconds. The
65
+ * uniforms and the noise helpers are declared before it.
66
+ */
51
67
  glsl: string;
52
68
  };
69
+ /**
70
+ * A scene the library ships: a source with the id it is picked by, and the
71
+ * label and description a picker prints. `glsl` defines
72
+ * `vec3 scene(vec2 uv, float t)`, returning the final linear colour of the
73
+ * pixel over the page ground (`u_ground`). Its settings arrive as
74
+ * `uniform float u_<key>`, and its colours as `u_col[i]` in the order
75
+ * `colours` lists their tokens.
76
+ */
77
+ export type Scene = ShaderSceneSource & {
78
+ id: string;
79
+ label: string;
80
+ description: string;
81
+ };
53
82
  /**
54
83
  * A finishing step. `glsl` defines one function named `pass_<id>`: a
55
84
  * `light` pass takes and returns the linear colour, before encoding; an
@@ -0,0 +1,68 @@
1
+ /* ============================================
2
+ STACK
3
+ Children in one direction, a gap from the
4
+ scale between them. The gap arrives as
5
+ --ds-stack-gap, set from the `gap` prop.
6
+ ============================================ */
7
+
8
+ /* Base */
9
+ .ds-stack {
10
+ display: flex;
11
+ gap: var(--ds-stack-gap, var(--gap-400));
12
+ min-width: 0;
13
+ margin: 0;
14
+ padding: 0;
15
+ border: 0;
16
+ list-style: none;
17
+ }
18
+
19
+ /* Direction */
20
+ .ds-stack--column {
21
+ flex-direction: column;
22
+ }
23
+
24
+ .ds-stack--row {
25
+ flex-direction: row;
26
+ }
27
+
28
+ .ds-stack--wrap {
29
+ flex-wrap: wrap;
30
+ }
31
+
32
+ /* Alignment across the stack */
33
+ .ds-stack--align-start {
34
+ align-items: flex-start;
35
+ }
36
+
37
+ .ds-stack--align-center {
38
+ align-items: center;
39
+ }
40
+
41
+ .ds-stack--align-end {
42
+ align-items: flex-end;
43
+ }
44
+
45
+ .ds-stack--align-baseline {
46
+ align-items: baseline;
47
+ }
48
+
49
+ .ds-stack--align-stretch {
50
+ align-items: stretch;
51
+ }
52
+
53
+ /* Spread along the stack */
54
+ .ds-stack--justify-start {
55
+ justify-content: flex-start;
56
+ }
57
+
58
+ .ds-stack--justify-center {
59
+ justify-content: center;
60
+ }
61
+
62
+ .ds-stack--justify-end {
63
+ justify-content: flex-end;
64
+ }
65
+
66
+ .ds-stack--justify-between {
67
+ justify-content: space-between;
68
+ }
@@ -0,0 +1,37 @@
1
+ import { default as React } from 'react';
2
+ /** A step on the gap scale, as the `--gap-*` token it names. */
3
+ export type StackGap = '050' | '100' | '200' | '300' | '400' | '500' | '1000' | '1500' | '2000' | '3000';
4
+ /** Props owned by Stack itself; everything else falls through to the root element. */
5
+ type StackOwnProps = {
6
+ /** `column` lays the children top to bottom; `row` lays them in the reading direction. */
7
+ direction?: 'column' | 'row';
8
+ /** The space between children, as a step on the gap scale (`--gap-400` by default). */
9
+ gap?: StackGap;
10
+ /**
11
+ * How children line up across the stack: `stretch` fills it, which keeps
12
+ * cards in a row the same height. A column stretches and a row centres
13
+ * unless it is set.
14
+ * @default 'stretch' in a column, 'center' in a row
15
+ */
16
+ align?: 'start' | 'center' | 'end' | 'baseline' | 'stretch';
17
+ /** How children spread along the stack. `between` pushes the first and last to the ends. */
18
+ justify?: 'start' | 'center' | 'end' | 'between';
19
+ /** Lets a row wrap onto more lines when it runs out of room, keeping the gap between lines. */
20
+ wrap?: boolean;
21
+ /** The element the stack renders as, so it can be a list, a section or a form. */
22
+ as?: 'div' | 'section' | 'ul' | 'ol' | 'li' | 'form' | 'fieldset' | 'header' | 'footer' | 'nav' | 'span';
23
+ /** The stack's children. */
24
+ children?: React.ReactNode;
25
+ /** Additional CSS classes */
26
+ className?: string;
27
+ };
28
+ export interface StackProps extends StackOwnProps, Omit<React.ComponentPropsWithRef<'div'>, keyof StackOwnProps> {
29
+ }
30
+ /**
31
+ * Lays children out in one direction with a gap from the scale: the column
32
+ * every page, panel and form is made of, or a row of controls or cards.
33
+ * Presentational and server-renderable; it adds no semantics, so `as` picks
34
+ * the element when the stack is a list or a section.
35
+ */
36
+ export declare function Stack({ direction, gap, align, justify, wrap, as, className, style, children, ref, ...rest }: StackProps): React.JSX.Element;
37
+ export {};
@@ -0,0 +1,39 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import "react";
3
+ import "./Stack.css";
4
+ function Stack({
5
+ direction = "column",
6
+ gap = "400",
7
+ align,
8
+ justify = "start",
9
+ wrap = false,
10
+ as = "div",
11
+ className = "",
12
+ style,
13
+ children,
14
+ ref,
15
+ ...rest
16
+ }) {
17
+ const Element = as;
18
+ const classes = [
19
+ "ds-stack",
20
+ `ds-stack--${direction}`,
21
+ `ds-stack--align-${align ?? (direction === "row" ? "center" : "stretch")}`,
22
+ `ds-stack--justify-${justify}`,
23
+ wrap ? "ds-stack--wrap" : "",
24
+ className
25
+ ].filter(Boolean).join(" ");
26
+ return /* @__PURE__ */ jsx(
27
+ Element,
28
+ {
29
+ ...rest,
30
+ ref,
31
+ className: classes,
32
+ style: { ...style, "--ds-stack-gap": `var(--gap-${gap})` },
33
+ children
34
+ }
35
+ );
36
+ }
37
+ export {
38
+ Stack
39
+ };
@@ -33,6 +33,50 @@
33
33
  letter-spacing: var(--font-display-2-letter-spacing);
34
34
  }
35
35
 
36
+ /* ============================================
37
+ HEAD — an icon tile and a caption above the
38
+ value. A headed stat fills its tile's width,
39
+ so the caption reaches the far end.
40
+ ============================================ */
41
+
42
+ .ds-stat--headed {
43
+ display: flex;
44
+ gap: var(--gap-050);
45
+ }
46
+
47
+ .ds-stat__head {
48
+ display: flex;
49
+ align-items: center;
50
+ justify-content: space-between;
51
+ gap: var(--gap-200);
52
+ align-self: stretch;
53
+ /* The head sits --gap-300 above the value: the stat's own row gap
54
+ (--gap-050) plus this margin. */
55
+ margin-block-end: calc(var(--gap-300) - var(--gap-050));
56
+ }
57
+
58
+ /* A node passed as the icon sits where Icon's tile would. */
59
+ .ds-stat__icon {
60
+ flex-shrink: 0;
61
+ }
62
+
63
+ .ds-stat__caption {
64
+ margin-inline-start: auto;
65
+ font-family: var(--font-caption-family);
66
+ font-size: var(--font-caption-size);
67
+ font-weight: var(--font-caption-weight);
68
+ line-height: var(--font-caption-line-height);
69
+ letter-spacing: var(--font-caption-letter-spacing);
70
+ color: var(--color-text-tertiary);
71
+ }
72
+
73
+ /* What follows the figures (a Sparkline, an AvatarGroup) runs the stat's width. */
74
+ .ds-stat__extra {
75
+ display: block;
76
+ align-self: stretch;
77
+ margin-block-start: var(--gap-200);
78
+ }
79
+
36
80
  /* ============================================
37
81
  LABEL
38
82
  ============================================ */
@@ -95,6 +139,22 @@
95
139
  row-gap: var(--gap-050);
96
140
  }
97
141
 
142
+ /* A head and the extras run the grid's full width, above and below. */
143
+ .ds-stat--delta-inline.ds-stat--headed {
144
+ grid-template-areas:
145
+ 'head head'
146
+ 'value delta'
147
+ 'label label';
148
+ }
149
+
150
+ .ds-stat--delta-inline .ds-stat__head {
151
+ grid-area: head;
152
+ }
153
+
154
+ .ds-stat--delta-inline .ds-stat__extra {
155
+ grid-column: 1 / -1;
156
+ }
157
+
98
158
  .ds-stat--delta-inline .ds-stat__value {
99
159
  grid-area: value;
100
160
  }
@@ -125,6 +185,11 @@
125
185
  container: ds-stat / inline-size;
126
186
  }
127
187
 
188
+ /* The auto root is a block, with no row gap: the margin is the whole space. */
189
+ .ds-stat--delta-auto .ds-stat__head {
190
+ margin-block-end: var(--gap-300);
191
+ }
192
+
128
193
  .ds-stat__body {
129
194
  display: grid;
130
195
  grid-template-columns: auto 1fr;
@@ -19,12 +19,18 @@ type StatOwnProps = {
19
19
  deltaPlacement?: 'stacked' | 'inline' | 'auto';
20
20
  /** Stat size */
21
21
  size?: 'default' | 'large';
22
+ /** A decorative mark in a round tile above the value, naming what the metric is about: a Material Symbol name (string) or a node. */
23
+ icon?: string | React.ReactNode;
24
+ /** A short note at the far end of the top row, in the caption face: the period the figure covers ("Last 30 days"), its source. */
25
+ caption?: React.ReactNode;
26
+ /** Shown after the value, label and delta, such as a Sparkline of the metric's recent history or an AvatarGroup of who it counts. */
27
+ children?: React.ReactNode;
22
28
  /** The BCP 47 locale a number `value` 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. */
23
29
  locale?: string;
24
30
  /** Additional CSS classes */
25
31
  className?: string;
26
32
  };
27
- export interface StatProps extends StatOwnProps, Omit<React.ComponentPropsWithoutRef<'div'>, keyof StatOwnProps | 'children'> {
33
+ export interface StatProps extends StatOwnProps, Omit<React.ComponentPropsWithoutRef<'div'>, keyof StatOwnProps> {
28
34
  }
29
35
  /**
30
36
  * Stat component — a single headline metric with a label and an
@@ -3,6 +3,7 @@ import React from "react";
3
3
  import "./Stat.css";
4
4
  import "../../fonts/material-symbols.css";
5
5
  import { formatNumber, DEFAULT_LOCALE } from "../../behaviors/locale.js";
6
+ import { Icon } from "../Icon/Icon.js";
6
7
  const TREND_ICONS = {
7
8
  up: "arrow_upward",
8
9
  down: "arrow_downward",
@@ -16,16 +17,23 @@ const Stat = React.forwardRef(
16
17
  trend = "neutral",
17
18
  deltaPlacement = "stacked",
18
19
  size = "default",
20
+ icon,
21
+ caption,
22
+ children,
19
23
  locale = DEFAULT_LOCALE,
20
24
  className = "",
21
25
  ...rest
22
26
  }, ref) => {
23
27
  const baseClass = "ds-stat";
28
+ const hasIcon = icon != null && icon !== false && icon !== "";
29
+ const hasCaption = caption != null && caption !== false && caption !== "";
30
+ const hasHead = hasIcon || hasCaption;
24
31
  const classes = [
25
32
  baseClass,
26
33
  `${baseClass}--${size}`,
27
34
  deltaPlacement === "inline" ? `${baseClass}--delta-inline` : "",
28
35
  deltaPlacement === "auto" ? `${baseClass}--delta-auto` : "",
36
+ hasHead ? `${baseClass}--headed` : "",
29
37
  className
30
38
  ].filter(Boolean).join(" ");
31
39
  const parts = /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -36,7 +44,14 @@ const Stat = React.forwardRef(
36
44
  delta
37
45
  ] })
38
46
  ] });
39
- return /* @__PURE__ */ jsx("div", { ...rest, ref, className: classes, children: deltaPlacement === "auto" ? /* @__PURE__ */ jsx("span", { className: `${baseClass}__body`, children: parts }) : parts });
47
+ return /* @__PURE__ */ jsxs("div", { ...rest, ref, className: classes, children: [
48
+ hasHead && /* @__PURE__ */ jsxs("span", { className: `${baseClass}__head`, children: [
49
+ hasIcon && (typeof icon === "string" ? /* @__PURE__ */ jsx(Icon, { name: icon, size: "500", tile: true, className: `${baseClass}__icon` }) : /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon`, "aria-hidden": "true", children: icon })),
50
+ hasCaption && /* @__PURE__ */ jsx("span", { className: `${baseClass}__caption`, children: caption })
51
+ ] }),
52
+ deltaPlacement === "auto" ? /* @__PURE__ */ jsx("span", { className: `${baseClass}__body`, children: parts }) : parts,
53
+ children != null && children !== false && /* @__PURE__ */ jsx("span", { className: `${baseClass}__extra`, children })
54
+ ] });
40
55
  }
41
56
  );
42
57
  Stat.displayName = "Stat";
@@ -52,6 +52,17 @@
52
52
  transition: background-color var(--motion-duration-base) var(--motion-ease-standard);
53
53
  }
54
54
 
55
+ /* A row that heads a group, and a row the ones above add up to: both in
56
+ the emphasis weight, the total under a heavier rule. */
57
+ .ds-table__row--heading .ds-table__cell,
58
+ .ds-table__row--total .ds-table__cell {
59
+ font-weight: var(--font-paragraph-emphasis-weight);
60
+ }
61
+
62
+ .ds-table__row--total {
63
+ border-top: var(--border-050) solid var(--color-table-divider);
64
+ }
65
+
55
66
  /* ============================================
56
67
  HEADER CELL
57
68
  ============================================ */
@@ -20,6 +20,8 @@ export interface TableRow {
20
20
  cells: Record<string, React.ReactNode>;
21
21
  /** Whether the row is selected, drawn with the table's selected-row tint. */
22
22
  selected?: boolean;
23
+ /** `heading` opens a group of rows in the emphasis weight; `total` is a row the ones above add up to, in the emphasis weight under a heavier rule. */
24
+ variant?: 'default' | 'heading' | 'total';
23
25
  }
24
26
  /** Props owned by Table itself — everything else falls through to the <table>. */
25
27
  type TableOwnProps = {
@@ -51,7 +51,11 @@ const Table = React.forwardRef(
51
51
  /* @__PURE__ */ jsx("tbody", { className: `${baseClass}__body`, children: rows.map((row) => /* @__PURE__ */ jsx(
52
52
  "tr",
53
53
  {
54
- className: row.selected ? `${baseClass}__row ${baseClass}__row--selected` : `${baseClass}__row`,
54
+ className: [
55
+ `${baseClass}__row`,
56
+ row.selected ? `${baseClass}__row--selected` : "",
57
+ row.variant && row.variant !== "default" ? `${baseClass}__row--${row.variant}` : ""
58
+ ].filter(Boolean).join(" "),
55
59
  children: columns.map((col) => {
56
60
  const content = /* @__PURE__ */ jsx(
57
61
  "div",
@@ -74,6 +74,15 @@
74
74
  transition: color var(--motion-duration-base) var(--motion-ease-standard);
75
75
  }
76
76
 
77
+ /* ============================================
78
+ COUNT
79
+ ============================================ */
80
+
81
+ .ds-tabs__count {
82
+ color: var(--color-text-tertiary);
83
+ font-variant-numeric: tabular-nums;
84
+ }
85
+
77
86
  /* ============================================
78
87
  ICON
79
88
  ============================================ */
@@ -138,3 +147,17 @@
138
147
  opacity: 0.4;
139
148
  cursor: not-allowed;
140
149
  }
150
+
151
+ /* ============================================
152
+ PANELS — rendered when the tabs carry content
153
+ ============================================ */
154
+
155
+ .ds-tabs__panel {
156
+ padding-block-start: var(--padding-500);
157
+ }
158
+
159
+ .ds-tabs__panel:focus-visible {
160
+ outline: 2px solid var(--color-action-primary-bg);
161
+ outline-offset: 2px;
162
+ border-radius: var(--radius-200);
163
+ }
@@ -6,10 +6,14 @@ export interface Tab {
6
6
  label: string;
7
7
  /** Optional icon — Material Symbol name (string) or custom element (ReactNode) */
8
8
  icon?: string | React.ReactNode;
9
+ /** A count after the label (unread items, results), written in the resolved locale; the tab's name carries it through `countLabel`. */
10
+ count?: number;
9
11
  /** Whether this tab is disabled */
10
12
  disabled?: boolean;
11
- /** The id of the `role="tabpanel"` element this tab shows, written as the tab's `aria-controls`. The consumer renders the panels. */
13
+ /** The id of the `role="tabpanel"` element this tab shows, written as the tab's `aria-controls`. Set it when you render the panels yourself; with `content`, Tabs names its own panel and this id is used for it. */
12
14
  panelId?: string;
15
+ /** What the tab shows. When any tab has content, Tabs renders a `role="tabpanel"` for each after the tab list, the selected one shown, each named by its tab. The panels are the tab list's siblings, with no wrapper, and the ref and `className` stay on the tab list. Leave it out to render the panels yourself. */
16
+ content?: React.ReactNode;
13
17
  }
14
18
  /** Props owned by Tabs itself — everything else falls through to the tablist. */
15
19
  type TabsOwnProps = {
@@ -43,6 +47,10 @@ type TabsOwnProps = {
43
47
  size?: 'default' | 'compact';
44
48
  /** Whether tabs fill the available width */
45
49
  fullWidth?: boolean;
50
+ /** What a screen reader hears after a tab's label for its count, given the count already written in the resolved locale. Defaults to ", 3"; say what it counts (", 3 unread") when the label does not. */
51
+ countLabel?: (count: string) => string;
52
+ /** The BCP 47 locale the tab counts are written in, such as `ar-EG`. Defaults to the nearest LocaleProvider's, else `en-US`. */
53
+ locale?: string;
46
54
  /** Additional CSS classes */
47
55
  className?: string;
48
56
  /**
@@ -54,12 +62,5 @@ type TabsOwnProps = {
54
62
  };
55
63
  export interface TabsProps extends TabsOwnProps, Omit<React.ComponentPropsWithoutRef<'div'>, keyof TabsOwnProps | 'children'> {
56
64
  }
57
- /**
58
- * Tabs switch between related views in one place.
59
- *
60
- * Forwards a ref to the `role="tablist"` element, which is the component's
61
- * only wrapper, and spreads unrecognised props onto it. The list is named
62
- * "Tabs" unless a native `aria-label` or `aria-labelledby` says otherwise.
63
- */
64
65
  export declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
65
66
  export {};
@@ -1,9 +1,13 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import React, { useState } from "react";
2
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
+ import React, { useId, useState } from "react";
4
+ import "../../behaviors/visually-hidden.css";
4
5
  import "./Tabs.css";
5
6
  import "../../fonts/material-symbols.css";
6
7
  import { mirrorClass, logicalArrowKey } from "../../behaviors/direction.js";
8
+ import { formatNumber } from "../../behaviors/locale.js";
9
+ import { useLocale } from "../../behaviors/LocaleProvider.js";
10
+ const defaultCountLabel = (count) => `, ${count}`;
7
11
  const Tabs = React.forwardRef(
8
12
  ({
9
13
  tabs,
@@ -14,11 +18,18 @@ const Tabs = React.forwardRef(
14
18
  onTabChange,
15
19
  size = "default",
16
20
  fullWidth = false,
21
+ locale: localeProp,
22
+ countLabel = defaultCountLabel,
17
23
  className = "",
18
24
  ariaLabel,
19
25
  ...rest
20
26
  }, ref) => {
21
27
  const baseClass = "ds-tabs";
28
+ const baseId = useId();
29
+ const ownsPanels = tabs.some((tab) => tab.content !== void 0);
30
+ const tabId = (index) => `${baseId}-tab-${index}`;
31
+ const panelIdOf = (tab, index) => tab.panelId ?? (ownsPanels ? `${baseId}-panel-${index}` : void 0);
32
+ const locale = useLocale(localeProp);
22
33
  const sizeClass = `${baseClass}--${size}`;
23
34
  const fullWidthClass = fullWidth ? `${baseClass}--full-width` : "";
24
35
  const controlledValue = value ?? activeTab;
@@ -64,7 +75,7 @@ const Tabs = React.forwardRef(
64
75
  targetEl?.focus();
65
76
  }
66
77
  };
67
- return /* @__PURE__ */ jsx(
78
+ const list = /* @__PURE__ */ jsx(
68
79
  "div",
69
80
  {
70
81
  "aria-label": ariaLabel ?? "Tabs",
@@ -87,14 +98,19 @@ const Tabs = React.forwardRef(
87
98
  role: "tab",
88
99
  "aria-selected": isActive,
89
100
  "aria-disabled": tab.disabled,
90
- "aria-controls": tab.panelId,
101
+ id: ownsPanels ? tabId(index) : void 0,
102
+ "aria-controls": panelIdOf(tab, index),
91
103
  tabIndex: isActive ? 0 : -1,
92
104
  "data-tab-value": tab.value,
93
105
  onClick: () => !tab.disabled && select(tab.value),
94
106
  onKeyDown: (e) => handleKeyDown(e, index),
95
107
  children: [
96
108
  tab.icon && (typeof tab.icon === "string" ? /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon material-symbols-rounded ${mirrorClass(tab.icon)}`, "aria-hidden": "true", children: tab.icon }) : /* @__PURE__ */ jsx("span", { className: `${baseClass}__icon`, "aria-hidden": "true", children: tab.icon })),
97
- /* @__PURE__ */ jsx("span", { className: `${baseClass}__label`, children: tab.label })
109
+ /* @__PURE__ */ jsxs("span", { className: `${baseClass}__label`, children: [
110
+ tab.label,
111
+ tab.count !== void 0 && /* @__PURE__ */ jsx("span", { className: "ds-visually-hidden", children: countLabel(formatNumber(tab.count, locale)) })
112
+ ] }),
113
+ tab.count !== void 0 && /* @__PURE__ */ jsx("span", { className: `${baseClass}__count`, "aria-hidden": "true", children: formatNumber(tab.count, locale) })
98
114
  ]
99
115
  },
100
116
  tab.value
@@ -102,6 +118,23 @@ const Tabs = React.forwardRef(
102
118
  })
103
119
  }
104
120
  );
121
+ if (!ownsPanels) return list;
122
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
123
+ list,
124
+ tabs.map((tab, index) => /* @__PURE__ */ jsx(
125
+ "div",
126
+ {
127
+ id: panelIdOf(tab, index),
128
+ role: "tabpanel",
129
+ "aria-labelledby": tabId(index),
130
+ hidden: tab.value !== selectedValue,
131
+ tabIndex: 0,
132
+ className: `${baseClass}__panel`,
133
+ children: tab.content
134
+ },
135
+ tab.value
136
+ ))
137
+ ] });
105
138
  }
106
139
  );
107
140
  Tabs.displayName = "Tabs";
@@ -12,10 +12,12 @@ type TextareaOwnProps = {
12
12
  defaultValue?: string;
13
13
  /** Component size */
14
14
  size?: 'default' | 'compact';
15
- /** Error state — shows error styling and message */
15
+ /** Error state: marks the control invalid and, in the older form without `errorText`, recolours the helper text as the error message. */
16
16
  error?: boolean;
17
- /** Helper or error message displayed below */
17
+ /** Helper text displayed below the control. With the older `error` flag and no `errorText`, it doubles as the error message. */
18
18
  helperText?: string;
19
+ /** 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. */
20
+ errorText?: React.ReactNode;
19
21
  /** Whether the textarea is resizable */
20
22
  resize?: 'none' | 'vertical' | 'horizontal' | 'both';
21
23
  /** Max character count — shows counter when set */