@arbor-education/design-system.components 0.25.1 → 0.25.3

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 (44) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/row/Row.d.ts +5 -4
  3. package/dist/components/row/Row.d.ts.map +1 -1
  4. package/dist/components/row/Row.js +4 -2
  5. package/dist/components/row/Row.js.map +1 -1
  6. package/dist/components/row/Row.stories.d.ts +114 -4
  7. package/dist/components/row/Row.stories.d.ts.map +1 -1
  8. package/dist/components/row/Row.stories.js +451 -63
  9. package/dist/components/row/Row.stories.js.map +1 -1
  10. package/dist/components/row/Row.test.js +39 -0
  11. package/dist/components/row/Row.test.js.map +1 -1
  12. package/dist/components/toggleGroup/ToggleGroup.d.ts +29 -0
  13. package/dist/components/toggleGroup/ToggleGroup.d.ts.map +1 -0
  14. package/dist/components/toggleGroup/ToggleGroup.js +26 -0
  15. package/dist/components/toggleGroup/ToggleGroup.js.map +1 -0
  16. package/dist/components/toggleGroup/ToggleGroup.stories.d.ts +86 -0
  17. package/dist/components/toggleGroup/ToggleGroup.stories.d.ts.map +1 -0
  18. package/dist/components/toggleGroup/ToggleGroup.stories.js +342 -0
  19. package/dist/components/toggleGroup/ToggleGroup.stories.js.map +1 -0
  20. package/dist/components/toggleGroup/ToggleGroup.test.d.ts +2 -0
  21. package/dist/components/toggleGroup/ToggleGroup.test.d.ts.map +1 -0
  22. package/dist/components/toggleGroup/ToggleGroup.test.js +123 -0
  23. package/dist/components/toggleGroup/ToggleGroup.test.js.map +1 -0
  24. package/dist/components/toggleGroup/ToggleGroupItem.d.ts +10 -0
  25. package/dist/components/toggleGroup/ToggleGroupItem.d.ts.map +1 -0
  26. package/dist/components/toggleGroup/ToggleGroupItem.js +5 -0
  27. package/dist/components/toggleGroup/ToggleGroupItem.js.map +1 -0
  28. package/dist/index.css +33 -0
  29. package/dist/index.css.map +1 -1
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +1 -0
  33. package/dist/index.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/components/row/Row.stories.tsx +638 -80
  36. package/src/components/row/Row.test.tsx +48 -0
  37. package/src/components/row/Row.tsx +15 -5
  38. package/src/components/toggleGroup/ToggleGroup.stories.tsx +429 -0
  39. package/src/components/toggleGroup/ToggleGroup.test.tsx +155 -0
  40. package/src/components/toggleGroup/ToggleGroup.tsx +74 -0
  41. package/src/components/toggleGroup/ToggleGroupItem.tsx +24 -0
  42. package/src/components/toggleGroup/toggleGroup.scss +43 -0
  43. package/src/index.scss +1 -0
  44. package/src/index.ts +1 -0
@@ -1,22 +1,28 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Controls, Heading as DocHeading, Markdown, Primary as DocPrimary, Stories, Subtitle, Title, } from '@storybook/addon-docs/blocks';
3
3
  import { fn } from 'storybook/test';
4
+ import { Section } from '../section/Section.js';
4
5
  import { Row } from './Row.js';
6
+ import { Badge } from '../badge/Badge.js';
7
+ import { Tag } from '../tag/Tag.js';
8
+ import { Icon } from '../icon/Icon.js';
5
9
  // ---------------------------------------------------------------------------
6
- // Content strings for the custom DocsPage
10
+ // Docs page content
7
11
  // ---------------------------------------------------------------------------
8
12
  const DESCRIPTION_INTRO = [
9
- '`Row` is a single-line display component used to present a labelled piece of data — optionally with a supporting note — inside summary panels, detail cards, or any section-style layout.',
10
- 'When an `onClick` handler is provided the row becomes fully interactive: it gains hover and focus styles, renders a pair of animated directional icons, and responds to keyboard activation via **Enter** and **Space**.',
13
+ '`Row` is a single-line display component for presenting a labelled piece of data inside summary panels, detail cards, or section-style layouts.',
14
+ 'Pass an `onClick` handler to make the row fully interactive it enters the tab order, gains hover and focus styles, and renders a pair of animated directional icons.',
15
+ 'Pass `href` to turn the value into a native anchor link, supporting any protocol including `mailto:` and `tel:`.',
11
16
  ].join(' ');
12
17
  const PROPS_INTRO = 'The preview below is wired to the **Controls** panel — tweak any prop to see the story update in real time.';
13
18
  const USAGE_GUIDANCE = [
14
19
  '### When to use',
15
20
  '',
16
- '- Displaying a labelled piece of read-only data inside a detail panel or summary card (e.g. "Year group · Year 9").',
21
+ '- Displaying a labelled key-value pair in a detail panel or summary card (e.g. "Year group · Year 9").',
17
22
  '- Rendering a list of named data points where a consistent label/value layout improves scannability.',
18
- '- Providing a tappable/clickable drill-down link to a related record or page when `onClick` is supplied.',
19
- '- Showing supplementary context alongside a value (e.g. a last-updated timestamp in the `note` slot).',
23
+ '- Providing a clickable drill-down link to a related record when `onClick` is supplied.',
24
+ '- Wrapping a value in a native link (URL, email address, phone number) via the `href` prop.',
25
+ '- Showing supplementary context alongside a value (e.g. a threshold note or timestamp in the `note` slot).',
20
26
  '',
21
27
  '---',
22
28
  '',
@@ -24,44 +30,75 @@ const USAGE_GUIDANCE = [
24
30
  '',
25
31
  '| Situation | Use instead |',
26
32
  '|---|---|',
27
- '| Navigation links | Native `<a>` or router `<Link>` — a `div` with `onClick` is not a true anchor |',
28
33
  '| Tabular data with sortable columns | [`Table`](?path=/docs/components-table--docs) |',
34
+ '| Form controls with labels | [`FormField`](?path=/docs/components-formfield--docs) |',
29
35
  '| Toggling or selecting items | Checkbox or radio group |',
30
- '| Form controls | [`FormField`](?path=/docs/components-formfield--docs) with an appropriate input |',
36
+ '| Navigation links standing alone | Native `<a>` or router `<Link>` |',
31
37
  ].join('\n');
32
38
  const DEVELOPER_NOTES = [
33
39
  '### Clickable vs static rows',
34
40
  '',
35
- 'The `onClick` prop is the **sole toggle** for all clickable behaviour — there is no separate `isClickable` prop or variant enum.',
41
+ 'The `onClick` prop is the **sole toggle** for all interactive behaviour — there is no separate `isClickable` prop.',
36
42
  '',
37
43
  '| State | `tabIndex` | CSS modifier | Icons rendered |',
38
44
  '|---|---|---|---|',
39
45
  '| Static | `-1` (not in tab order) | — | None |',
40
46
  '| Clickable | `0` (in tab order) | `ds-row--clickable` | `chevron-right` + `arrow-right` |',
41
47
  '',
42
- '**Dual-icon swap:** Both icons are always rendered when `onClick` is provided, but CSS controls their visibility:',
48
+ '**Dual-icon swap:** Both icons are always in the DOM when `onClick` is provided. CSS controls visibility ',
49
+ 'at rest `chevron-right` shows; on hover/focus `arrow-right` shows. No JavaScript state is involved.',
43
50
  '',
44
- '- **At rest:** `chevron-right` is visible; `arrow-right` is hidden via `display: none`.',
45
- '- **On hover / focus:** `chevron-right` is hidden; `arrow-right` becomes visible.',
51
+ '---',
52
+ '',
53
+ '### The `href` prop and value fallback',
54
+ '',
55
+ 'When `href` is provided, the value is wrapped in a native `<a>` element:',
56
+ '',
57
+ '```tsx',
58
+ '// value becomes the link text',
59
+ '<Row label="Email" value="admin@school.com" href="mailto:admin@school.com" />',
46
60
  '',
47
- 'This swap is driven entirely by CSSno JavaScript state is involved.',
61
+ '// href becomes the link text when value is omitted avoid with special protocols',
62
+ '<Row label="Profile" href="/students/123" />',
63
+ '```',
64
+ '',
65
+ '> **⚠️ Always provide `value` when using `mailto:` or `tel:` hrefs.** Without `value`, the raw protocol',
66
+ '> string (e.g. `"mailto:admin@school.com"`) is used as link text.',
48
67
  '',
49
68
  '---',
50
69
  '',
51
70
  '### Keyboard activation',
52
71
  '',
53
- 'Clickable rows respond to **Enter** and **Space** keydown events by firing the `onClick` handler.',
72
+ 'Clickable rows respond to **Enter** and **Space** keydown events.',
73
+ 'The focus ring uses `box-shadow: 0 0 0 3px var(--color-brand-300)` — applied on `:focus`.',
54
74
  '',
55
75
  '---',
56
76
  '',
57
77
  '### Accessibility gap',
58
78
  '',
59
- '> **Known limitation:** Clickable `Row` instances render as a `<div>` with no `role="button"` attribute.',
60
- '> Screen readers will not announce the element as a button, and `getByRole("button")` will not find it.',
79
+ '> **Known limitation:** The clickable row renders as a `<div>` with no `role="button"` attribute.',
80
+ '> Screen readers will not announce it as interactive. Keyboard users can still activate it, but',
81
+ '> VoiceOver/NVDA users have no indication the row is actionable.',
82
+ '',
83
+ '`href` rows render a real `<a>` tag — full native link semantics and announced correctly by screen readers.',
84
+ '',
85
+ '`Row` does **not** spread arbitrary HTML attributes. `className` and `style` are the only escape hatches.',
61
86
  '',
62
- '`Row` does **not** spread arbitrary HTML attributes. The `className` prop is the only escape hatch.',
63
- 'Consumers **cannot** add `aria-label`, `aria-describedby`, `data-testid`, or any HTML attribute without modifying the component source.',
64
- 'These are documented design-debt items for a future accessibility audit.',
87
+ '---',
88
+ '',
89
+ '### Component tokens',
90
+ '',
91
+ 'Row is themed entirely through `--section-list-row-*` component tokens:',
92
+ '',
93
+ '| Token | Purpose |',
94
+ '|---|---|',
95
+ '| `--section-list-row-default-color-background` | Resting background colour |',
96
+ '| `--section-list-row-hover-hover-bg` | Hover background (clickable rows only) |',
97
+ '| `--section-list-row-spacing-vertical` | Top/bottom padding |',
98
+ '| `--section-list-row-spacing-horizontal` | Left/right padding |',
99
+ '| `--section-list-row-radius` | Border radius |',
100
+ '| `--section-list-row-default-color-icon-arrow` | Chevron/arrow icon stroke at rest |',
101
+ '| `--section-list-row-hover-color-icon-arrow` | Chevron/arrow icon stroke on hover |',
65
102
  '',
66
103
  '---',
67
104
  '',
@@ -70,12 +107,15 @@ const DEVELOPER_NOTES = [
70
107
  '```ts',
71
108
  "import { Row } from '@arbor-education/design-system.components';",
72
109
  "import type { RowProps } from '@arbor-education/design-system.components';",
110
+ "import type { ReactNode } from 'react';",
73
111
  '',
74
112
  'type RowProps = {',
75
113
  ' className?: string;',
76
- ' label?: string;',
77
- ' value?: string;',
78
- ' note?: string;',
114
+ ' style?: CSSProperties;',
115
+ ' label?: ReactNode;',
116
+ ' value?: ReactNode;',
117
+ ' href?: string;',
118
+ ' note?: ReactNode;',
79
119
  ' onClick?: MouseEventHandler<HTMLDivElement>;',
80
120
  '};',
81
121
  '```',
@@ -83,7 +123,7 @@ const DEVELOPER_NOTES = [
83
123
  const RELATED_COMPONENTS = [
84
124
  '## Related components',
85
125
  '',
86
- '[Section](?path=/docs/components-section--docs) · [Card](?path=/docs/components-card--docs) · [Table](?path=/docs/components-table--docs)',
126
+ '[Section](?path=/docs/components-section--docs) · [Card](?path=/docs/components-card--docs) · [Table](?path=/docs/components-table--docs) · [FormField](?path=/docs/components-formfield--docs)',
87
127
  ].join('\n');
88
128
  // ---------------------------------------------------------------------------
89
129
  // Custom DocsPage
@@ -99,6 +139,7 @@ const meta = {
99
139
  component: Row,
100
140
  tags: ['autodocs'],
101
141
  parameters: {
142
+ layout: 'padded',
102
143
  docs: {
103
144
  page: RowDocsPage,
104
145
  },
@@ -106,12 +147,12 @@ const meta = {
106
147
  argTypes: {
107
148
  label: {
108
149
  description: [
109
- 'The left-hand label that identifies the data point.',
110
- 'Renders inside a `<span>` with a minimum width of 190 px so labels align consistently across stacked rows.',
150
+ 'Left-column text identifying the data point.',
151
+ 'Rendered in a `<span>` with semi-bold weight and a maximum width of 190 px so labels align consistently across stacked rows.',
111
152
  ].join(' '),
112
153
  control: 'text',
113
154
  table: {
114
- type: { summary: 'string' },
155
+ type: { summary: 'ReactNode' },
115
156
  defaultValue: { summary: 'undefined' },
116
157
  },
117
158
  },
@@ -119,6 +160,20 @@ const meta = {
119
160
  description: [
120
161
  'The right-hand value corresponding to the label.',
121
162
  'Renders in the centre column with `flex-grow: 1`, filling available width.',
163
+ 'When `href` is provided, this becomes the anchor text.',
164
+ 'If `href` is set and `value` is omitted, the href string itself is used as the link text.',
165
+ ].join(' '),
166
+ control: 'text',
167
+ table: {
168
+ type: { summary: 'ReactNode' },
169
+ defaultValue: { summary: 'undefined' },
170
+ },
171
+ },
172
+ href: {
173
+ description: [
174
+ 'When provided, wraps `value` in a native `<a>` element pointing to this URL.',
175
+ 'Supports any protocol — `https://`, `mailto:`, `tel:`, etc.',
176
+ 'Always provide `value` when using `mailto:` or `tel:` — without it the raw protocol string becomes the link text.',
122
177
  ].join(' '),
123
178
  control: 'text',
124
179
  table: {
@@ -128,8 +183,9 @@ const meta = {
128
183
  },
129
184
  note: {
130
185
  description: [
131
- 'Optional supplementary text rendered after the value — displayed in italics.',
132
- 'Useful for timestamps, caveats, or secondary context.',
186
+ 'Supplementary italic text rendered right-aligned after the value.',
187
+ 'When present, the CSS `:has()` selector reduces the value column\'s `flex-basis` from 70% to 50% to make room.',
188
+ 'Useful for thresholds, last-updated timestamps, or secondary context.',
133
189
  ].join(' '),
134
190
  control: 'text',
135
191
  table: {
@@ -139,9 +195,9 @@ const meta = {
139
195
  },
140
196
  onClick: {
141
197
  description: [
142
- 'When provided, the row becomes interactive: it enters the tab order (`tabIndex={0}`),',
143
- 'gains the `ds-row--clickable` modifier, shows hover/focus styles, and renders dual directional icons.',
144
- 'Supports **Enter** and **Space** keyboard activation.',
198
+ 'When provided, activates all clickable behaviour: the row enters the tab order (`tabIndex={0}`),',
199
+ 'gains the `ds-row--clickable` modifier, shows hover/focus styles, and renders the dual directional icon pair.',
200
+ 'Responds to **Enter** and **Space** keyboard events.',
145
201
  ].join(' '),
146
202
  action: 'onClick',
147
203
  control: false,
@@ -151,16 +207,21 @@ const meta = {
151
207
  },
152
208
  },
153
209
  className: {
154
- description: [
155
- 'Additional CSS class names applied to the root `<div>`.',
156
- 'This is the only HTML-attribute escape hatch — arbitrary HTML attributes cannot be passed via props.',
157
- ].join(' '),
210
+ description: 'Additional CSS class names applied to the root `<div>`. The only HTML-attribute escape hatch — arbitrary attributes like `aria-label` or `data-testid` cannot be passed without modifying the component.',
158
211
  control: 'text',
159
212
  table: {
160
213
  type: { summary: 'string' },
161
214
  defaultValue: { summary: 'undefined' },
162
215
  },
163
216
  },
217
+ style: {
218
+ description: 'Inline styles applied to the root `<div>`.',
219
+ control: false,
220
+ table: {
221
+ type: { summary: 'CSSProperties' },
222
+ defaultValue: { summary: 'undefined' },
223
+ },
224
+ },
164
225
  },
165
226
  };
166
227
  export default meta;
@@ -171,10 +232,21 @@ const withDescription = (story, description) => ({
171
232
  ...story,
172
233
  parameters: {
173
234
  ...story.parameters,
174
- docs: { ...story.parameters?.docs, description: { story: description } },
235
+ docs: {
236
+ ...story.parameters?.docs,
237
+ description: {
238
+ story: description,
239
+ },
240
+ },
175
241
  },
176
242
  });
177
243
  // ---------------------------------------------------------------------------
244
+ // Template components
245
+ // ---------------------------------------------------------------------------
246
+ const MixedClickableAndStaticTemplate = () => (_jsxs(Section, { title: "Pupil details", children: [_jsx(Row, { label: "Name", value: "Amara Osei-Bonsu" }), _jsx(Row, { label: "Year group", value: "Year 10" }), _jsx(Row, { label: "Form", value: "10JH" }), _jsx(Row, { label: "SEN status", value: "SEN Support", note: "Review due May 2026", onClick: () => { } }), _jsx(Row, { label: "Attendance (YTD)", value: "88.3%", note: "Below 90% threshold", onClick: () => { } })] }));
247
+ const InSectionTemplate = () => (_jsxs(Section, { title: "Personal details", children: [_jsx(Row, { label: "Pupil", value: "Amara Osei-Bonsu" }), _jsx(Row, { label: "Date of birth", value: "14 March 2010" }), _jsx(Row, { label: "Admission number", value: "001847" }), _jsx(Row, { label: "UPN", value: "A823456789012" }), _jsx(Row, { label: "Email address", value: "a.osei-bonsu@pupil.school.example", href: "mailto:a.osei-bonsu@pupil.school.example" })] }));
248
+ const AccessibilityNotesTemplate = () => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-large)' }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }, children: [_jsxs("p", { style: { margin: 0, color: 'var(--color-grey-600)', fontSize: 'var(--font-size-3-14)' }, children: ["Static row \u2014", ' ', _jsx("code", { children: "tabIndex=\"-1\"" }), ", no ARIA role, not in tab order"] }), _jsx(Row, { label: "Year group", value: "Year 9" })] }), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }, children: [_jsxs("p", { style: { margin: 0, color: 'var(--color-grey-600)', fontSize: 'var(--font-size-3-14)' }, children: ["Clickable row \u2014", ' ', _jsx("code", { children: "tabIndex=\"0\"" }), ", keyboard-activatable, but", ' ', _jsxs("strong", { children: ["no", _jsx("code", { children: "role=\"button\"" })] }), ' ', "\u2014 screen readers may not announce it as interactive"] }), _jsx(Row, { label: "SEN record", value: "SEN Support", onClick: () => { } })] }), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }, children: [_jsxs("p", { style: { margin: 0, color: 'var(--color-grey-600)', fontSize: 'var(--font-size-3-14)' }, children: ["href row \u2014 renders a real", ' ', _jsx("code", { children: "<a>" }), ' ', "tag with full native link semantics \u2713"] }), _jsx(Row, { label: "Email address", value: "admin@school.example", href: "mailto:admin@school.example" })] })] }));
249
+ // ---------------------------------------------------------------------------
178
250
  // Stories
179
251
  // ---------------------------------------------------------------------------
180
252
  export const Default = withDescription({
@@ -185,7 +257,7 @@ export const Default = withDescription({
185
257
  onClick: fn(),
186
258
  },
187
259
  render: args => _jsx(Row, { ...args }),
188
- }, 'The default story is wired to the Controls panel. By default it is clickable — remove `onClick` from the controls to switch to static mode and observe how the icons and hover behaviour disappear.');
260
+ }, 'The interactive canvas — every prop is wired to the Controls panel. By default the row is clickable — clear `onClick` from the controls to switch to static mode and observe how the icons and hover behaviour disappear.');
189
261
  export const LabelOnly = withDescription({
190
262
  parameters: {
191
263
  controls: { disable: true },
@@ -204,8 +276,8 @@ export default EnrolmentStatusRow;
204
276
  },
205
277
  },
206
278
  render: () => _jsx(Row, { label: "Enrolment status" }),
207
- }, 'Minimum meaningful render — a label with no value or note. Both sibling `<span>` elements still render in the DOM (they are unconditionally present), but remain empty.');
208
- export const LabelAndValue = withDescription({
279
+ }, 'Minimum meaningful render — a label with no value, href, or note. The value and note `<span>` elements still render in the DOM but remain empty. The row holds its correct minimum height.');
280
+ export const ValueOnly = withDescription({
209
281
  parameters: {
210
282
  controls: { disable: true },
211
283
  docs: {
@@ -214,16 +286,16 @@ export const LabelAndValue = withDescription({
214
286
  code: `
215
287
  import { Row } from '@arbor-education/design-system.components';
216
288
 
217
- function DateOfBirthRow() {
218
- return <Row label="Date of birth" value="14 March 2009" />;
289
+ function ActiveStatusRow() {
290
+ return <Row value="Active" />;
219
291
  }
220
- export default DateOfBirthRow;
292
+ export default ActiveStatusRow;
221
293
  `.trim(),
222
294
  },
223
295
  },
224
296
  },
225
- render: () => _jsx(Row, { label: "Date of birth", value: "14 March 2009" }),
226
- }, 'The canonical two-column layout. The label column enforces a minimum width of 190 px so values align consistently when multiple rows are stacked.');
297
+ render: () => _jsx(Row, { value: "Active" }),
298
+ }, 'A value with no label — the label column renders empty. Valid but uncommon; most real-world rows pair a label with every value.');
227
299
  export const WithNote = withDescription({
228
300
  parameters: {
229
301
  controls: { disable: true },
@@ -248,7 +320,103 @@ export default AttendanceRow;
248
320
  },
249
321
  },
250
322
  render: () => (_jsx(Row, { label: "Attendance this term", value: "91.4%", note: "Below school target of 95%" })),
251
- }, 'Adding a `note` renders supplementary italic text alongside the value. Use it for thresholds, last-updated timestamps, or secondary context that helps a user interpret the value.');
323
+ }, 'Adding `note` renders supplementary italic text right-aligned after the value. The CSS `:has()` selector automatically shrinks the value column from 70% to 50% flex-basis to make room. Use notes for thresholds, last-updated timestamps, or secondary context that helps interpret the value.');
324
+ export const WithHref = withDescription({
325
+ parameters: {
326
+ controls: { disable: true },
327
+ docs: {
328
+ source: {
329
+ language: 'tsx',
330
+ code: `
331
+ import { Row } from '@arbor-education/design-system.components';
332
+
333
+ function ProfileLinkRow() {
334
+ return (
335
+ <Row
336
+ label="Student profile"
337
+ value="View full profile"
338
+ href="/students/amara-osei-bonsu"
339
+ />
340
+ );
341
+ }
342
+ export default ProfileLinkRow;
343
+ `.trim(),
344
+ },
345
+ },
346
+ },
347
+ render: () => (_jsx(Row, { label: "Student profile", value: "View full profile", href: "/students/amara-osei-bonsu" })),
348
+ }, 'When `href` is provided alongside `value`, the value text becomes the anchor text. The `<a>` element carries full native link semantics — right-click opens the browser context menu, the link can be opened in a new tab, and screen readers announce it correctly as a link.');
349
+ export const WithHrefFallback = withDescription({
350
+ parameters: {
351
+ controls: { disable: true },
352
+ docs: {
353
+ source: {
354
+ language: 'tsx',
355
+ code: `
356
+ import { Row } from '@arbor-education/design-system.components';
357
+
358
+ // ⚠️ href without value — the href string becomes the link text
359
+ function HrefFallbackRow() {
360
+ return <Row label="Profile" href="/students/123" />;
361
+ }
362
+ export default HrefFallbackRow;
363
+ `.trim(),
364
+ },
365
+ },
366
+ },
367
+ render: () => _jsx(Row, { label: "Profile", href: "/students/123" }),
368
+ }, 'When `href` is set but `value` is omitted, the href string itself is used as the link text (`value || href`). For plain paths like `/students/123` this is acceptable. For `mailto:` or `tel:` hrefs, the raw URI string is exposed to the user — always pair those with an explicit `value`. See the **WithHrefMailto** story for the correct email pattern.');
369
+ export const WithHrefMailto = withDescription({
370
+ parameters: {
371
+ controls: { disable: true },
372
+ docs: {
373
+ source: {
374
+ language: 'tsx',
375
+ code: `
376
+ import { Row } from '@arbor-education/design-system.components';
377
+
378
+ function EmailRow() {
379
+ return (
380
+ <Row
381
+ label="Email address"
382
+ value="j.smith@school.example"
383
+ href="mailto:j.smith@school.example"
384
+ />
385
+ );
386
+ }
387
+ export default EmailRow;
388
+ `.trim(),
389
+ },
390
+ },
391
+ },
392
+ render: () => (_jsx(Row, { label: "Email address", value: "j.smith@school.example", href: "mailto:j.smith@school.example" })),
393
+ }, 'The canonical email-address pattern: `href="mailto:..."` opens the user\'s mail client and `value` is the human-readable address shown as link text. Always provide `value` with `mailto:` hrefs — omitting it exposes the raw protocol string (e.g. `"mailto:j.smith@school.example"`) as link text.');
394
+ export const WithHrefAndNote = withDescription({
395
+ parameters: {
396
+ controls: { disable: true },
397
+ docs: {
398
+ source: {
399
+ language: 'tsx',
400
+ code: `
401
+ import { Row } from '@arbor-education/design-system.components';
402
+
403
+ function GuardianEmailRow() {
404
+ return (
405
+ <Row
406
+ label="Guardian email"
407
+ value="s.okafor@guardian.example"
408
+ href="mailto:s.okafor@guardian.example"
409
+ note="Primary contact"
410
+ />
411
+ );
412
+ }
413
+ export default GuardianEmailRow;
414
+ `.trim(),
415
+ },
416
+ },
417
+ },
418
+ render: () => (_jsx(Row, { label: "Guardian email", value: "s.okafor@guardian.example", href: "mailto:s.okafor@guardian.example", note: "Primary contact" })),
419
+ }, '`href` and `note` used together. The anchor sits in the value column while the note stays right-aligned. The CSS `:has()` reflow is active — the value column narrows to 50% flex-basis to accommodate the note.');
252
420
  export const Clickable = withDescription({
253
421
  parameters: {
254
422
  controls: { disable: true },
@@ -273,7 +441,7 @@ export default ClassRow;
273
441
  },
274
442
  },
275
443
  render: () => (_jsx(Row, { label: "Class", value: "9B/En1 \u2014 English", onClick: fn() })),
276
- }, 'Providing an `onClick` handler activates all clickable behaviour: the row gains `ds-row--clickable`, enters the tab order, shows hover/focus styles, and renders the dual-icon pair. **Hover the row** to see the icon swap from `chevron-right` to `arrow-right`. Press **Enter** or **Space** to fire the handler.');
444
+ }, 'Providing `onClick` activates all clickable behaviour: `ds-row--clickable` modifier, pointer cursor, hover background, and the dual icon pair. **Hover the row** to see `chevron-right` swap to `arrow-right` — a pure CSS transition with no JavaScript state. Press **Tab** to focus, then **Enter** or **Space** to fire the handler.');
277
445
  export const ClickableWithNote = withDescription({
278
446
  parameters: {
279
447
  controls: { disable: true },
@@ -299,7 +467,75 @@ export default GuardianRow;
299
467
  },
300
468
  },
301
469
  render: () => (_jsx(Row, { label: "Guardian", value: "Sarah Okafor", note: "Primary contact", onClick: fn() })),
302
- }, 'All four content props used together with a clickable row. The note remains visible while the row is fully interactive useful when secondary context (like "Primary contact") helps the user decide whether to navigate.');
470
+ }, 'Clickable row with all three right-side elements active: value, note, and the chevron/arrow icon pair. The note takes 20% flex-basis; the value narrows to 50%; the icon is flex-shrunk. The secondary context ("Primary contact") persists alongside the navigation affordance.');
471
+ export const MixedClickableAndStatic = withDescription({
472
+ parameters: {
473
+ controls: { disable: true },
474
+ docs: {
475
+ source: {
476
+ language: 'tsx',
477
+ code: `
478
+ import { Row, Section } from '@arbor-education/design-system.components';
479
+
480
+ function PupilDetailSection() {
481
+ return (
482
+ <Section title="Pupil details">
483
+ <Row label="Name" value="Amara Osei-Bonsu" />
484
+ <Row label="Year group" value="Year 10" />
485
+ <Row label="Form" value="10JH" />
486
+ <Row
487
+ label="SEN status"
488
+ value="SEN Support"
489
+ note="Review due May 2026"
490
+ onClick={() => navigateToSENRecord()}
491
+ />
492
+ <Row
493
+ label="Attendance (YTD)"
494
+ value="88.3%"
495
+ note="Below 90% threshold"
496
+ onClick={() => navigateToAttendance()}
497
+ />
498
+ </Section>
499
+ );
500
+ }
501
+ export default PupilDetailSection;
502
+ `.trim(),
503
+ },
504
+ },
505
+ },
506
+ render: MixedClickableAndStaticTemplate,
507
+ }, 'Static and clickable rows freely mixed inside a `Section`. Static rows display data; clickable rows provide navigation affordance. The visual contrast — pointer cursor, hover background, directional icon — makes the interactive rows immediately distinguishable without extra labelling.');
508
+ export const InSection = withDescription({
509
+ parameters: {
510
+ controls: { disable: true },
511
+ docs: {
512
+ source: {
513
+ language: 'tsx',
514
+ code: `
515
+ import { Row, Section } from '@arbor-education/design-system.components';
516
+
517
+ function PersonalDetailsSection() {
518
+ return (
519
+ <Section title="Personal details">
520
+ <Row label="Pupil" value="Amara Osei-Bonsu" />
521
+ <Row label="Date of birth" value="14 March 2010" />
522
+ <Row label="Admission number" value="001847" />
523
+ <Row label="UPN" value="A823456789012" />
524
+ <Row
525
+ label="Email address"
526
+ value="a.osei-bonsu@pupil.school.example"
527
+ href="mailto:a.osei-bonsu@pupil.school.example"
528
+ />
529
+ </Section>
530
+ );
531
+ }
532
+ export default PersonalDetailsSection;
533
+ `.trim(),
534
+ },
535
+ },
536
+ },
537
+ render: InSectionTemplate,
538
+ }, 'The canonical real-world usage: `Row` components as children of a `Section`. The `Section` provides the container heading and background; each `Row` handles the label/value layout. Most product uses of `Row` are inside a `Section`.');
303
539
  export const LongContent = withDescription({
304
540
  parameters: {
305
541
  controls: { disable: true },
@@ -311,7 +547,7 @@ import { Row } from '@arbor-education/design-system.components';
311
547
 
312
548
  function LongContentExample() {
313
549
  return (
314
- <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-small)' }}>
550
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }}>
315
551
  <Row
316
552
  label="Special educational needs and disabilities coordinator"
317
553
  value="Mrs Jacqueline Abernathy-Thornton"
@@ -331,8 +567,8 @@ export default LongContentExample;
331
567
  },
332
568
  },
333
569
  },
334
- render: () => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-small)' }, children: [_jsx(Row, { label: "Special educational needs and disabilities coordinator", value: "Mrs Jacqueline Abernathy-Thornton", note: "Updated 3 January 2026" }), _jsx(Row, { label: "Pupil premium eligibility reason", value: "Free school meals \u2014 ever 6", note: "Verified by LA", onClick: fn() })] })),
335
- }, 'Long label and value strings exercise the flex layout. The label column maintains its 190 px minimum width, which may compress the value column significantly in narrow containers.');
570
+ render: () => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }, children: [_jsx(Row, { label: "Special educational needs and disabilities coordinator", value: "Mrs Jacqueline Abernathy-Thornton", note: "Updated 3 January 2026" }), _jsx(Row, { label: "Pupil premium eligibility reason", value: "Free school meals \u2014 ever 6", note: "Verified by LA", onClick: fn() })] })),
571
+ }, 'Long label and value strings exercise the flex layout. The label column enforces a 190 px maximum width long labels wrap rather than compress the value column. Test your specific container widths if you have long copy in narrow panels.');
336
572
  export const MultipleRows = withDescription({
337
573
  parameters: {
338
574
  controls: { disable: true },
@@ -342,34 +578,186 @@ export const MultipleRows = withDescription({
342
578
  code: `
343
579
  import { Row } from '@arbor-education/design-system.components';
344
580
 
345
- function PupilDetailPanel() {
581
+ function PupilDataList() {
346
582
  return (
347
- <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-small)' }}>
583
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }}>
348
584
  <Row label="Pupil" value="Amara Osei-Bonsu" />
349
585
  <Row label="Year group" value="Year 10" />
350
586
  <Row label="Form" value="10JH" />
351
587
  <Row label="Admission number" value="001847" />
352
588
  <Row label="UPN" value="A823456789012" />
589
+ </div>
590
+ );
591
+ }
592
+ export default PupilDataList;
593
+ `.trim(),
594
+ },
595
+ },
596
+ },
597
+ render: () => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-xsmall)' }, children: [_jsx(Row, { label: "Pupil", value: "Amara Osei-Bonsu" }), _jsx(Row, { label: "Year group", value: "Year 10" }), _jsx(Row, { label: "Form", value: "10JH" }), _jsx(Row, { label: "Admission number", value: "001847" }), _jsx(Row, { label: "UPN", value: "A823456789012" })] })),
598
+ }, 'Multiple static rows stacked with `gap: var(--spacing-xsmall)`. Each `Row` carries its own background and padding — the gap sits between rows. Use `Section` as the outer container in production to get the correct heading and container treatment.');
599
+ export const ReactNodeInValue = withDescription({
600
+ parameters: {
601
+ controls: { disable: true },
602
+ docs: {
603
+ source: {
604
+ language: 'tsx',
605
+ code: `
606
+ import { Row, Badge } from '@arbor-education/design-system.components';
607
+
608
+ function SENStatusRows() {
609
+ return (
610
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-small)' }}>
611
+ <Row label="SEN status" value={<Badge colour="orange">SEN Support</Badge>} />
612
+ <Row label="Admission type" value={<Badge colour="blue">Looked after child</Badge>} />
613
+ </div>
614
+ );
615
+ }
616
+ export default SENStatusRows;
617
+ `.trim(),
618
+ },
619
+ },
620
+ },
621
+ render: () => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-small)' }, children: [_jsx(Row, { label: "SEN status", value: _jsx(Badge, { colour: "orange", children: "SEN Support" }) }), _jsx(Row, { label: "Admission type", value: _jsx(Badge, { colour: "blue", children: "Looked after child" }) })] })),
622
+ }, 'The `value` prop accepts any `ReactNode`, so status badges, coloured indicators, or formatted markup can replace plain strings. A `Badge` communicates urgency or category at a glance without the reader having to interpret the text alone.');
623
+ export const ReactNodeInNote = withDescription({
624
+ parameters: {
625
+ controls: { disable: true },
626
+ docs: {
627
+ source: {
628
+ language: 'tsx',
629
+ code: `
630
+ import { Row, Tag } from '@arbor-education/design-system.components';
631
+
632
+ function AttendanceRows() {
633
+ return (
634
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-small)' }}>
635
+ <Row label="Attendance this term" value="91.4%" note={<Tag color="orange">Below target</Tag>} />
636
+ <Row label="Reading age" value="8y 4m" note={<Tag color="green">On track</Tag>} />
637
+ </div>
638
+ );
639
+ }
640
+ export default AttendanceRows;
641
+ `.trim(),
642
+ },
643
+ },
644
+ },
645
+ render: () => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-small)' }, children: [_jsx(Row, { label: "Attendance this term", value: "91.4%", note: _jsx(Tag, { color: "orange", children: "Below target" }) }), _jsx(Row, { label: "Reading age", value: "8y 4m", note: _jsx(Tag, { color: "green", children: "On track" }) })] })),
646
+ }, 'The `note` slot accepts any `ReactNode` — a coloured `Tag` conveys urgency or status at a glance without burying it in prose. Pair with a plain-text `value` so the primary reading stays clean while the note provides a quick visual cue about whether the value is within an expected range.');
647
+ export const ReactNodeInLabel = withDescription({
648
+ parameters: {
649
+ controls: { disable: true },
650
+ docs: {
651
+ source: {
652
+ language: 'tsx',
653
+ code: `
654
+ import { Row, Icon } from '@arbor-education/design-system.components';
655
+
656
+ function AnnotatedLabelRows() {
657
+ return (
658
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-small)' }}>
353
659
  <Row
354
- label="SEN status"
355
- value="SEN Support"
356
- note="Review due May 2026"
357
- onClick={() => navigateToSENRecord()}
660
+ label={
661
+ <span style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
662
+ Pupil premium <Icon name="info" size={16} />
663
+ </span>
664
+ }
665
+ value="Free school meals — ever 6"
358
666
  />
359
667
  <Row
360
- label="Attendance (YTD)"
361
- value="88.3%"
362
- note="Below 90% threshold"
363
- onClick={() => navigateToAttendance()}
668
+ label={
669
+ <span style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
670
+ EHCP status <Icon name="info" size={16} />
671
+ </span>
672
+ }
673
+ value="EHC plan in place"
364
674
  />
365
675
  </div>
366
676
  );
367
677
  }
368
- export default PupilDetailPanel;
678
+ export default AnnotatedLabelRows;
679
+ `.trim(),
680
+ },
681
+ },
682
+ },
683
+ render: () => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-small)' }, children: [_jsx(Row, { label: (_jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: ["Pupil premium", ' ', _jsx(Icon, { name: "info", size: 16 })] })), value: "Free school meals \u2014 ever 6" }), _jsx(Row, { label: (_jsxs("span", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: ["EHCP status", ' ', _jsx(Icon, { name: "info", size: 16 })] })), value: "EHC plan in place" })] })),
684
+ }, 'The `label` slot accepts any `ReactNode` — inline icons can annotate labels that require clarification. An `Icon` placed inline with the label text signals to the user that more information is available, without cluttering the value column.');
685
+ export const AccessibilityNotes = withDescription({
686
+ parameters: {
687
+ controls: { disable: true },
688
+ docs: {
689
+ source: {
690
+ language: 'tsx',
691
+ code: `
692
+ import { Row } from '@arbor-education/design-system.components';
693
+
694
+ // Static: tabIndex="-1", no ARIA role, not keyboard-focusable
695
+ <Row label="Year group" value="Year 9" />
696
+
697
+ // Clickable: tabIndex="0", Enter/Space activate onClick
698
+ // ⚠️ No role="button" — screen readers may not announce as interactive
699
+ <Row label="SEN record" value="SEN Support" onClick={handleClick} />
700
+
701
+ // href: real <a> tag — full native link semantics, announced as a link ✓
702
+ <Row label="Email address" value="admin@school.example" href="mailto:admin@school.example" />
703
+ `.trim(),
704
+ },
705
+ },
706
+ },
707
+ render: AccessibilityNotesTemplate,
708
+ }, [
709
+ '**Known accessibility gap:** Clickable rows (`onClick` provided) render as a `<div>` with no `role="button"`.',
710
+ 'Screen readers will not announce them as interactive.',
711
+ 'Keyboard users can still activate via Tab + Enter/Space, but VoiceOver/NVDA users have no indication the row is actionable.',
712
+ '',
713
+ '`href` rows are the exception — they render a real `<a>` tag with full native link semantics.',
714
+ '',
715
+ 'If your use case requires screen-reader announcements on clickable rows, pass `className` with a workaround or request a component update.',
716
+ ].join(' '));
717
+ export const CustomClassAndStyle = withDescription({
718
+ parameters: {
719
+ controls: { disable: true },
720
+ docs: {
721
+ source: {
722
+ language: 'tsx',
723
+ code: `
724
+ import { Row } from '@arbor-education/design-system.components';
725
+
726
+ function HighlightedRow() {
727
+ return (
728
+ <Row
729
+ label="Safeguarding flag"
730
+ value="CP Plan — Stage 3"
731
+ className="my-highlighted-row"
732
+ style={{ borderLeft: '4px solid var(--color-semantic-destructive-600)' }}
733
+ />
734
+ );
735
+ }
736
+ export default HighlightedRow;
737
+ `.trim(),
738
+ },
739
+ },
740
+ },
741
+ render: () => (_jsx(Row, { label: "Safeguarding flag", value: "CP Plan \u2014 Stage 3", className: "my-highlighted-row", style: { borderLeft: '4px solid var(--color-semantic-destructive-600)' } })),
742
+ }, '`className` and `style` are the only HTML-attribute escape hatches — `Row` does not spread arbitrary HTML attributes. Use `className` to apply component-token overrides or modifier classes; use `style` for one-off inline tweaks.');
743
+ export const EmptyRow = withDescription({
744
+ parameters: {
745
+ controls: { disable: true },
746
+ docs: {
747
+ source: {
748
+ language: 'tsx',
749
+ code: `
750
+ import { Row } from '@arbor-education/design-system.components';
751
+
752
+ // All props omitted — renders three empty spans in a flex container
753
+ function EmptyRowExample() {
754
+ return <Row />;
755
+ }
756
+ export default EmptyRowExample;
369
757
  `.trim(),
370
758
  },
371
759
  },
372
760
  },
373
- render: () => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-small)' }, children: [_jsx(Row, { label: "Pupil", value: "Amara Osei-Bonsu" }), _jsx(Row, { label: "Year group", value: "Year 10" }), _jsx(Row, { label: "Form", value: "10JH" }), _jsx(Row, { label: "Admission number", value: "001847" }), _jsx(Row, { label: "UPN", value: "A823456789012" }), _jsx(Row, { label: "SEN status", value: "SEN Support", note: "Review due May 2026", onClick: fn() }), _jsx(Row, { label: "Attendance (YTD)", value: "88.3%", note: "Below 90% threshold", onClick: fn() })] })),
374
- }, 'A realistic pupil detail panelthe most common real-world usage. Static and clickable rows can be freely mixed. The `gap: var(--spacing-small)` wrapper token matches the spacing the component uses internally, keeping visual rhythm consistent.');
761
+ render: () => _jsx(Row, {}),
762
+ }, 'All props omitted. The component renders without crashing three empty `<span>` elements in a flex container at the default row height. A `Row` with no props is visible as an empty strip, not invisible, so conditionally-rendered row content produces a layout placeholder rather than disappearing silently.');
375
763
  //# sourceMappingURL=Row.stories.js.map