@arbor-education/design-system.components 0.16.1 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gather/instructions/project-overview.md +0 -4
- package/.gather/skills/aroo-hunni/SKILL.md +58 -0
- package/CHANGELOG.md +31 -0
- package/CONTRIBUTING.md +1 -0
- package/dist/components/arborLogo/ArborLogo.d.ts +9 -0
- package/dist/components/arborLogo/ArborLogo.d.ts.map +1 -0
- package/dist/components/arborLogo/ArborLogo.js +17 -0
- package/dist/components/arborLogo/ArborLogo.js.map +1 -0
- package/dist/components/arborLogo/ArborLogo.stories.d.ts +94 -0
- package/dist/components/arborLogo/ArborLogo.stories.d.ts.map +1 -0
- package/dist/components/arborLogo/ArborLogo.stories.js +418 -0
- package/dist/components/arborLogo/ArborLogo.stories.js.map +1 -0
- package/dist/components/arborLogo/ArborLogo.test.d.ts +2 -0
- package/dist/components/arborLogo/ArborLogo.test.d.ts.map +1 -0
- package/dist/components/arborLogo/ArborLogo.test.js +32 -0
- package/dist/components/arborLogo/ArborLogo.test.js.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.d.ts +19 -0
- package/dist/components/dataViewCard/DataViewCard.d.ts.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.js +13 -0
- package/dist/components/dataViewCard/DataViewCard.js.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.stories.d.ts +100 -0
- package/dist/components/dataViewCard/DataViewCard.stories.d.ts.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.stories.js +317 -0
- package/dist/components/dataViewCard/DataViewCard.stories.js.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.test.d.ts +2 -0
- package/dist/components/dataViewCard/DataViewCard.test.d.ts.map +1 -0
- package/dist/components/dataViewCard/DataViewCard.test.js +67 -0
- package/dist/components/dataViewCard/DataViewCard.test.js.map +1 -0
- package/dist/components/row/Row.d.ts +2 -1
- package/dist/components/row/Row.d.ts.map +1 -1
- package/dist/components/row/Row.js +2 -2
- package/dist/components/row/Row.js.map +1 -1
- package/dist/components/treeRow/TreeRow.d.ts +32 -0
- package/dist/components/treeRow/TreeRow.d.ts.map +1 -0
- package/dist/components/treeRow/TreeRow.js +19 -0
- package/dist/components/treeRow/TreeRow.js.map +1 -0
- package/dist/components/treeRow/TreeRow.stories.d.ts +13 -0
- package/dist/components/treeRow/TreeRow.stories.d.ts.map +1 -0
- package/dist/components/treeRow/TreeRow.stories.js +774 -0
- package/dist/components/treeRow/TreeRow.stories.js.map +1 -0
- package/dist/components/treeRow/TreeRow.test.d.ts +2 -0
- package/dist/components/treeRow/TreeRow.test.d.ts.map +1 -0
- package/dist/components/treeRow/TreeRow.test.js +262 -0
- package/dist/components/treeRow/TreeRow.test.js.map +1 -0
- package/dist/components/treeRow/TreeRowSection.d.ts +12 -0
- package/dist/components/treeRow/TreeRowSection.d.ts.map +1 -0
- package/dist/components/treeRow/TreeRowSection.js +20 -0
- package/dist/components/treeRow/TreeRowSection.js.map +1 -0
- package/dist/index.css +146 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/components/arborLogo/ArborLogo.stories.tsx +663 -0
- package/src/components/arborLogo/ArborLogo.test.tsx +36 -0
- package/src/components/arborLogo/ArborLogo.tsx +92 -0
- package/src/components/arborLogo/__snapshots__/ArborLogo.test.tsx.snap +424 -0
- package/src/components/dataViewCard/DataViewCard.stories.tsx +464 -0
- package/src/components/dataViewCard/DataViewCard.test.tsx +127 -0
- package/src/components/dataViewCard/DataViewCard.tsx +62 -0
- package/src/components/dataViewCard/dataViewCard.scss +25 -0
- package/src/components/row/Row.tsx +4 -1
- package/src/components/row/row.scss +9 -1
- package/src/components/treeRow/TreeRow.stories.tsx +870 -0
- package/src/components/treeRow/TreeRow.test.tsx +371 -0
- package/src/components/treeRow/TreeRow.tsx +85 -0
- package/src/components/treeRow/TreeRowSection.tsx +56 -0
- package/src/components/treeRow/treeRow.scss +134 -0
- package/src/docs/Contributing.mdx +1 -0
- package/src/index.scss +2 -0
- package/src/index.ts +4 -1
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Controls, Heading as DocHeading, Markdown, Primary as DocPrimary, Stories, Subtitle, Title, } from '@storybook/addon-docs/blocks';
|
|
3
|
+
import { DataViewCard } from './DataViewCard';
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Docs page content
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
const DESCRIPTION_INTRO = [
|
|
8
|
+
'DataViewCard is a precomposed [`Card`](?path=/docs/components-card--docs) variant for displaying a person or entity',
|
|
9
|
+
'as a tile — an [`Avatar`](?path=/docs/components-avatar--docs) on the left, a [`Heading`](?path=/docs/components-heading--docs)',
|
|
10
|
+
'for the name, and a stack of key-value [`Row`](?path=/docs/components-row--docs)s separated by [`Separator`](?path=/docs/components-separator--docs)s.',
|
|
11
|
+
'Built for grids of records (e.g. browse-students, staff directories) where the whole tile navigates to a profile.',
|
|
12
|
+
].join('\n');
|
|
13
|
+
const USAGE_GUIDANCE = [
|
|
14
|
+
'### When to use',
|
|
15
|
+
'',
|
|
16
|
+
'- **Browse views of people / records** — staff list, student list, contact directory',
|
|
17
|
+
'- **Tile-based navigation** — when clicking the whole card should drill into a detail view',
|
|
18
|
+
'- **Summary at a glance** — a heading plus 2–4 quick facts (year group, role, ID, etc.)',
|
|
19
|
+
'',
|
|
20
|
+
'---',
|
|
21
|
+
'',
|
|
22
|
+
'### When NOT to use',
|
|
23
|
+
'',
|
|
24
|
+
'| Situation | Use instead |',
|
|
25
|
+
'|---|---|',
|
|
26
|
+
'| Free-form content (paragraphs, mixed media) | [`ArticleCard`](?path=/docs/components-articlecard--docs) |',
|
|
27
|
+
'| Single metric / KPI display | [`KPICard`](?path=/docs/components-kpicard--docs) |',
|
|
28
|
+
'| Long lists where row density matters | [`Table`](?path=/docs/components-table--docs) |',
|
|
29
|
+
'| Just an avatar with name and role | [`SingleUser`](?path=/docs/components-singleuser--docs) |',
|
|
30
|
+
].join('\n');
|
|
31
|
+
const DEVELOPER_NOTES = [
|
|
32
|
+
'### Critical usage patterns',
|
|
33
|
+
'',
|
|
34
|
+
'**`aria-label` (or `aria-labelledby`) is REQUIRED when `onClick` is set.** The underlying `Card` renders',
|
|
35
|
+
'`role="button"` for clickable cards — a button without an accessible name is a WCAG 2.1 failure (4.1.2).',
|
|
36
|
+
'',
|
|
37
|
+
'**Rows are passed as data, not children.** The component owns the layout — you provide an array of',
|
|
38
|
+
'`{ label, value, note? }` objects and the component renders them as `Row`s with separators between.',
|
|
39
|
+
'',
|
|
40
|
+
'**Avatar is optional.** Omit the `avatar` prop entirely when you do not have an image (the layout collapses',
|
|
41
|
+
'cleanly to header-plus-rows). Pass full `Avatar.Props` for full control over `src`/`initials`/`size`/`alt`.',
|
|
42
|
+
'',
|
|
43
|
+
'**Header is `string` only.** Use the `aria-labelledby` pattern if you need richer markup for the accessible',
|
|
44
|
+
'name; otherwise pass the plain person/entity name as `header`.',
|
|
45
|
+
'',
|
|
46
|
+
'---',
|
|
47
|
+
'',
|
|
48
|
+
'### Accessibility',
|
|
49
|
+
'',
|
|
50
|
+
'- Heading renders as a real `<h4>` — fits inside an `<h3>` section/page heading',
|
|
51
|
+
'- Whole card is keyboard activatable (`Enter` / `Space`) when `onClick` is set, via the `Card` shell',
|
|
52
|
+
'- `disabled` removes click handling and applies `aria-disabled="true"` — focus is preserved',
|
|
53
|
+
'- Always pair an `Avatar` with `alt` text describing who it represents (or empty `alt=""` if purely decorative)',
|
|
54
|
+
'',
|
|
55
|
+
'---',
|
|
56
|
+
'',
|
|
57
|
+
'### TypeScript types',
|
|
58
|
+
'',
|
|
59
|
+
'```ts',
|
|
60
|
+
"import { DataViewCard } from '@arbor-education/design-system.components';",
|
|
61
|
+
'',
|
|
62
|
+
'function MyCard(props: DataViewCard.Props) { ... }',
|
|
63
|
+
'const rows: DataViewCard.RowData[] = [{ label: \'Year\', value: \'Year 8\' }];',
|
|
64
|
+
'```',
|
|
65
|
+
'',
|
|
66
|
+
'| Type | Description |',
|
|
67
|
+
'|---|---|',
|
|
68
|
+
'| `DataViewCard.Props` | Full props interface |',
|
|
69
|
+
'| `DataViewCard.RowData` | Alias for `Row.Props` — accepts the full [`Row`](?path=/docs/components-row--docs) API (`label`, `value`, `note`, plus `onClick` / `className`) |',
|
|
70
|
+
].join('\n');
|
|
71
|
+
const RELATED_COMPONENTS = [
|
|
72
|
+
'## Related components',
|
|
73
|
+
'',
|
|
74
|
+
'[Card](?path=/docs/components-card--docs) · [ArticleCard](?path=/docs/components-articlecard--docs) · [KPICard](?path=/docs/components-kpicard--docs) · [Avatar](?path=/docs/components-avatar--docs) · [Row](?path=/docs/components-row--docs) · [Heading](?path=/docs/components-heading--docs) · [Separator](?path=/docs/components-separator--docs)',
|
|
75
|
+
].join('\n');
|
|
76
|
+
const PROPS_INTRO = 'The preview below is wired to the **Controls** panel — tweak any prop to see the story update in real time.';
|
|
77
|
+
function DataViewCardDocsPage() {
|
|
78
|
+
return (_jsxs(_Fragment, { children: [_jsx(Title, {}), _jsx(Subtitle, {}), _jsx(Markdown, { children: DESCRIPTION_INTRO }), _jsx(DocHeading, { children: "Interactive example" }), _jsx(Markdown, { children: PROPS_INTRO }), _jsx(DocPrimary, {}), _jsx(Controls, {}), _jsx(DocHeading, { children: "Usage guidance" }), _jsx(Markdown, { children: USAGE_GUIDANCE }), _jsx(DocHeading, { children: "Developer notes" }), _jsx(Markdown, { children: DEVELOPER_NOTES }), _jsx(DocHeading, { children: "Examples" }), _jsx(Stories, { title: "" }), _jsx(Markdown, { children: RELATED_COMPONENTS })] }));
|
|
79
|
+
}
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Meta
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
const sampleRows = [
|
|
84
|
+
{ label: 'Year', value: 'Year 13' },
|
|
85
|
+
{ label: 'Form', value: 'Form 13DZ' },
|
|
86
|
+
{ label: 'DOB', value: '20 May 1932' },
|
|
87
|
+
];
|
|
88
|
+
const AVATAR_BASE = 'https://i.pravatar.cc/150?img=';
|
|
89
|
+
const meta = {
|
|
90
|
+
title: 'Components/Card/DataViewCard',
|
|
91
|
+
component: DataViewCard,
|
|
92
|
+
parameters: {
|
|
93
|
+
layout: 'padded',
|
|
94
|
+
docs: {
|
|
95
|
+
page: DataViewCardDocsPage,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
tags: ['autodocs'],
|
|
99
|
+
argTypes: {
|
|
100
|
+
'header': {
|
|
101
|
+
control: 'text',
|
|
102
|
+
description: 'The card heading — rendered as an `<h4>`. Pass the person or entity name.',
|
|
103
|
+
table: {
|
|
104
|
+
type: { summary: 'string' },
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
'avatar': {
|
|
108
|
+
control: 'object',
|
|
109
|
+
description: [
|
|
110
|
+
'Optional `Avatar.Props` — accepts `src`, `initials`, `alt`, and `size` (defaults to `extra-large`).',
|
|
111
|
+
'Omit the prop entirely to render the card without an avatar.',
|
|
112
|
+
].join(' '),
|
|
113
|
+
table: {
|
|
114
|
+
type: { summary: 'Avatar.Props' },
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
'rows': {
|
|
118
|
+
control: 'object',
|
|
119
|
+
description: 'Array of `{ label, value, note? }` — each is rendered as a `Row`, separated by `Separator`s.',
|
|
120
|
+
table: {
|
|
121
|
+
type: { summary: 'DataViewCard.RowData[]' },
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
'disabled': {
|
|
125
|
+
control: 'boolean',
|
|
126
|
+
description: 'Disables click handling and applies `aria-disabled="true"`.',
|
|
127
|
+
table: {
|
|
128
|
+
type: { summary: 'boolean' },
|
|
129
|
+
defaultValue: { summary: 'false' },
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
'onClick': {
|
|
133
|
+
control: false,
|
|
134
|
+
description: 'When set, the whole card becomes a `role="button"` and `aria-label` (or `aria-labelledby`) is required.',
|
|
135
|
+
table: {
|
|
136
|
+
type: { summary: '(e: MouseEvent<HTMLElement>) => void' },
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
'aria-label': {
|
|
140
|
+
control: 'text',
|
|
141
|
+
description: 'Required when `onClick` is set (unless `aria-labelledby` is provided).',
|
|
142
|
+
table: {
|
|
143
|
+
type: { summary: 'string' },
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
'aria-labelledby': {
|
|
147
|
+
control: false,
|
|
148
|
+
description: 'Alternative to `aria-label` — point to a visible element\'s id when one exists.',
|
|
149
|
+
table: {
|
|
150
|
+
type: { summary: 'string' },
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
'className': {
|
|
154
|
+
control: false,
|
|
155
|
+
description: 'Additional CSS class names on the underlying Card root.',
|
|
156
|
+
table: {
|
|
157
|
+
type: { summary: 'string' },
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
export default meta;
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
// Helpers
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
const withDescription = (story, description) => ({
|
|
167
|
+
...story,
|
|
168
|
+
parameters: {
|
|
169
|
+
...story.parameters,
|
|
170
|
+
docs: {
|
|
171
|
+
...story.parameters?.docs,
|
|
172
|
+
description: {
|
|
173
|
+
story: description,
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
// ---------------------------------------------------------------------------
|
|
179
|
+
// Templates
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
const GridTemplate = () => (_jsxs("div", { style: {
|
|
182
|
+
display: 'grid',
|
|
183
|
+
gap: 'var(--spacing-large)',
|
|
184
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(320px, 1fr))',
|
|
185
|
+
}, children: [_jsx(DataViewCard, { "aria-label": "View Dorothy Zbornak", avatar: { src: `${AVATAR_BASE}47`, alt: 'Dorothy Zbornak' }, header: "Dorothy Zbornak", onClick: () => { }, rows: [
|
|
186
|
+
{ label: 'Year', value: 'Year 13' },
|
|
187
|
+
{ label: 'Form', value: 'Form 13DZ' },
|
|
188
|
+
{ label: 'DOB', value: '20 May 1932' },
|
|
189
|
+
] }), _jsx(DataViewCard, { "aria-label": "View Rose Nylund", avatar: { src: `${AVATAR_BASE}5`, alt: 'Rose Nylund' }, header: "Rose Nylund", onClick: () => { }, rows: [
|
|
190
|
+
{ label: 'Year', value: 'Year 12' },
|
|
191
|
+
{ label: 'Form', value: 'Form 12RN' },
|
|
192
|
+
{ label: 'DOB', value: '21 Jul 1928' },
|
|
193
|
+
] }), _jsx(DataViewCard, { "aria-label": "View Blanche Devereaux", avatar: { src: `${AVATAR_BASE}49`, alt: 'Blanche Devereaux' }, header: "Blanche Devereaux", onClick: () => { }, rows: [
|
|
194
|
+
{ label: 'Year', value: 'Year 13' },
|
|
195
|
+
{ label: 'Form', value: 'Form 13BD' },
|
|
196
|
+
{ label: 'DOB', value: '17 Aug 1934' },
|
|
197
|
+
] }), _jsx(DataViewCard, { "aria-label": "View Sophia Petrillo", avatar: { initials: 'SP', alt: 'Sophia Petrillo' }, header: "Sophia Petrillo", onClick: () => { }, rows: [
|
|
198
|
+
{ label: 'Year', value: 'Year 13' },
|
|
199
|
+
{ label: 'Form', value: 'Form 13SP' },
|
|
200
|
+
{ label: 'DOB', value: '17 Mar 1908' },
|
|
201
|
+
] }), _jsx(DataViewCard, { "aria-label": "View Bella Swan", avatar: { src: `${AVATAR_BASE}21`, alt: 'Bella Swan' }, header: "Bella Swan", onClick: () => { }, rows: [
|
|
202
|
+
{ label: 'Year', value: 'Year 11' },
|
|
203
|
+
{ label: 'Form', value: 'Form 11FH' },
|
|
204
|
+
{ label: 'DOB', value: '13 Sep 1987' },
|
|
205
|
+
] }), _jsx(DataViewCard, { "aria-label": "View Jacob Black", avatar: { initials: 'JB', alt: 'Jacob Black' }, header: "Jacob Black", onClick: () => { }, rows: [
|
|
206
|
+
{ label: 'Year', value: 'Year 11' },
|
|
207
|
+
{ label: 'Form', value: 'Form 11LP' },
|
|
208
|
+
{ label: 'DOB', value: '14 Jan 1990' },
|
|
209
|
+
] })] }));
|
|
210
|
+
const NoAvatarTemplate = () => (_jsx(DataViewCard, { "aria-label": "View record A1024", header: "Record A1024", onClick: () => { }, rows: [
|
|
211
|
+
{ label: 'Type', value: 'Behaviour incident' },
|
|
212
|
+
{ label: 'Reported', value: '14 Mar 2026' },
|
|
213
|
+
{ label: 'Status', value: 'Open' },
|
|
214
|
+
] }));
|
|
215
|
+
const StaticTemplate = () => (_jsx(DataViewCard, { avatar: { src: `${AVATAR_BASE}58`, alt: 'Edward Cullen' }, header: "Edward Cullen", rows: [
|
|
216
|
+
{ label: 'Year', value: 'Year 11' },
|
|
217
|
+
{ label: 'Form', value: 'Form 11FH' },
|
|
218
|
+
{ label: 'DOB', value: '20 Jun 1901' },
|
|
219
|
+
] }));
|
|
220
|
+
const DisabledTemplate = () => (_jsx(DataViewCard, { "aria-label": "View Alice Cullen", avatar: { src: `${AVATAR_BASE}25`, alt: 'Alice Cullen' }, disabled: true, header: "Alice Cullen", onClick: () => { }, rows: [
|
|
221
|
+
{ label: 'Year', value: 'Year 12' },
|
|
222
|
+
{ label: 'Form', value: 'Form 12FH' },
|
|
223
|
+
{ label: 'DOB', value: '06 Jan 1901' },
|
|
224
|
+
] }));
|
|
225
|
+
const WithNoteTemplate = () => (_jsx(DataViewCard, { "aria-label": "View Blanche Devereaux", avatar: { src: `${AVATAR_BASE}49`, alt: 'Blanche Devereaux' }, header: "Blanche Devereaux", onClick: () => { }, rows: [
|
|
226
|
+
{ label: 'Year', value: 'Year 13', note: 'Glamour studies major' },
|
|
227
|
+
{ label: 'Form', value: 'Form 13BD', note: 'Tutor: Ms Petrillo' },
|
|
228
|
+
{ label: 'DOB', value: '17 Aug 1934' },
|
|
229
|
+
] }));
|
|
230
|
+
// ---------------------------------------------------------------------------
|
|
231
|
+
// Stories
|
|
232
|
+
// ---------------------------------------------------------------------------
|
|
233
|
+
export const Default = withDescription({
|
|
234
|
+
args: {
|
|
235
|
+
'aria-label': 'View Dorothy Zbornak',
|
|
236
|
+
'avatar': { src: `${AVATAR_BASE}47`, alt: 'Dorothy Zbornak' },
|
|
237
|
+
'header': 'Dorothy Zbornak',
|
|
238
|
+
'onClick': () => { },
|
|
239
|
+
'rows': sampleRows,
|
|
240
|
+
},
|
|
241
|
+
render: args => _jsx(DataViewCard, { ...args }),
|
|
242
|
+
}, [
|
|
243
|
+
'The interactive canvas — every prop is wired to the Controls panel below.',
|
|
244
|
+
'Tweak the `rows` array, swap the `avatar` for `{ src: \'…\' }` to test imagery, or remove `onClick` to flip the card to a static figure.',
|
|
245
|
+
].join(' '));
|
|
246
|
+
export const Grid = withDescription({
|
|
247
|
+
render: GridTemplate,
|
|
248
|
+
parameters: {
|
|
249
|
+
controls: { disable: true },
|
|
250
|
+
docs: {
|
|
251
|
+
source: {
|
|
252
|
+
language: 'tsx',
|
|
253
|
+
code: `
|
|
254
|
+
import { DataViewCard } from '@arbor-education/design-system.components';
|
|
255
|
+
|
|
256
|
+
function StudentGrid() {
|
|
257
|
+
return (
|
|
258
|
+
<div
|
|
259
|
+
style={{
|
|
260
|
+
display: 'grid',
|
|
261
|
+
gap: 'var(--spacing-large)',
|
|
262
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(320px, 1fr))',
|
|
263
|
+
}}
|
|
264
|
+
>
|
|
265
|
+
<DataViewCard
|
|
266
|
+
aria-label="View Dorothy Zbornak"
|
|
267
|
+
avatar={{ src: 'https://i.pravatar.cc/150?img=47', alt: 'Dorothy Zbornak' }}
|
|
268
|
+
header="Dorothy Zbornak"
|
|
269
|
+
onClick={() => {}}
|
|
270
|
+
rows={[
|
|
271
|
+
{ label: 'Year', value: 'Year 13' },
|
|
272
|
+
{ label: 'Form', value: 'Form 13DZ' },
|
|
273
|
+
{ label: 'DOB', value: '20 May 1932' },
|
|
274
|
+
]}
|
|
275
|
+
/>
|
|
276
|
+
{/* …more cards… */}
|
|
277
|
+
</div>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
export default StudentGrid;
|
|
281
|
+
`.trim(),
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
}, [
|
|
286
|
+
'The canonical browse-students layout: a responsive CSS grid of clickable cards (`auto-fill, minmax(320px, 1fr)`).',
|
|
287
|
+
'Each card has a unique `aria-label` describing the record it links to.',
|
|
288
|
+
].join(' '));
|
|
289
|
+
export const NoAvatar = withDescription({
|
|
290
|
+
render: NoAvatarTemplate,
|
|
291
|
+
parameters: { controls: { disable: true } },
|
|
292
|
+
}, [
|
|
293
|
+
'When the record has no portrait or logo, simply omit the `avatar` prop —',
|
|
294
|
+
'the layout collapses to header-plus-rows without leaving an empty placeholder.',
|
|
295
|
+
].join(' '));
|
|
296
|
+
export const Static = withDescription({
|
|
297
|
+
render: StaticTemplate,
|
|
298
|
+
parameters: { controls: { disable: true } },
|
|
299
|
+
}, [
|
|
300
|
+
'Without an `onClick`, the card renders as a static `<figure>` with no `role="button"` and no chevron icon.',
|
|
301
|
+
'Use this when the card is a read-only summary alongside a separate action button.',
|
|
302
|
+
].join(' '));
|
|
303
|
+
export const Disabled = withDescription({
|
|
304
|
+
render: DisabledTemplate,
|
|
305
|
+
parameters: { controls: { disable: true } },
|
|
306
|
+
}, [
|
|
307
|
+
'The `disabled` prop suppresses click handling and sets `aria-disabled="true"` on the underlying Card.',
|
|
308
|
+
'The card still renders fully and remains focusable — only the click is suppressed.',
|
|
309
|
+
].join(' '));
|
|
310
|
+
export const WithNote = withDescription({
|
|
311
|
+
render: WithNoteTemplate,
|
|
312
|
+
parameters: { controls: { disable: true } },
|
|
313
|
+
}, [
|
|
314
|
+
'Each row supports an optional `note` (italicised by `Row`) for secondary context — e.g. tutor name, promotion date.',
|
|
315
|
+
'Leave it off when not needed; rows render at consistent height regardless.',
|
|
316
|
+
].join(' '));
|
|
317
|
+
//# sourceMappingURL=DataViewCard.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataViewCard.stories.js","sourceRoot":"","sources":["../../../src/components/dataViewCard/DataViewCard.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,QAAQ,EACR,OAAO,IAAI,UAAU,EACrB,QAAQ,EACR,OAAO,IAAI,UAAU,EACrB,OAAO,EACP,QAAQ,EACR,KAAK,GACN,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E,MAAM,iBAAiB,GAAG;IACxB,qHAAqH;IACrH,iIAAiI;IACjI,wJAAwJ;IACxJ,mHAAmH;CACpH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,cAAc,GAAG;IACrB,iBAAiB;IACjB,EAAE;IACF,sFAAsF;IACtF,4FAA4F;IAC5F,yFAAyF;IACzF,EAAE;IACF,KAAK;IACL,EAAE;IACF,qBAAqB;IACrB,EAAE;IACF,6BAA6B;IAC7B,WAAW;IACX,6GAA6G;IAC7G,qFAAqF;IACrF,0FAA0F;IAC1F,iGAAiG;CAClG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,eAAe,GAAG;IACtB,6BAA6B;IAC7B,EAAE;IACF,0GAA0G;IAC1G,0GAA0G;IAC1G,EAAE;IACF,oGAAoG;IACpG,qGAAqG;IACrG,EAAE;IACF,6GAA6G;IAC7G,6GAA6G;IAC7G,EAAE;IACF,6GAA6G;IAC7G,gEAAgE;IAChE,EAAE;IACF,KAAK;IACL,EAAE;IACF,mBAAmB;IACnB,EAAE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,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;CAC5C,EACD;IACE,4GAA4G;IAC5G,mFAAmF;CACpF,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAU,eAAe,CAC5C;IACE,MAAM,EAAE,gBAAgB;IACxB,UAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;CAC5C,EACD;IACE,uGAAuG;IACvG,oFAAoF;CACrF,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAU,eAAe,CAC5C;IACE,MAAM,EAAE,gBAAgB;IACxB,UAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;CAC5C,EACD;IACE,qHAAqH;IACrH,4EAA4E;CAC7E,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataViewCard.test.d.ts","sourceRoot":"","sources":["../../../src/components/dataViewCard/DataViewCard.test.tsx"],"names":[],"mappings":"AACA,OAAO,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/vitest';
|
|
4
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
5
|
+
import { DataViewCard } from './DataViewCard';
|
|
6
|
+
const baseRows = [
|
|
7
|
+
{ label: 'Year', value: 'Year 8' },
|
|
8
|
+
{ label: 'Form', value: 'Form 8LR' },
|
|
9
|
+
{ label: 'DOB', value: '29 Jan 2012' },
|
|
10
|
+
];
|
|
11
|
+
describe('DataViewCard', () => {
|
|
12
|
+
test('renders the header as an h4', () => {
|
|
13
|
+
render(_jsx(DataViewCard, { header: "Christopher Longbottom", rows: baseRows }));
|
|
14
|
+
expect(screen.getByRole('heading', { level: 4 })).toHaveTextContent('Christopher Longbottom');
|
|
15
|
+
});
|
|
16
|
+
test('renders every row label and value', () => {
|
|
17
|
+
render(_jsx(DataViewCard, { header: "Christopher Longbottom", rows: baseRows }));
|
|
18
|
+
baseRows.forEach((row) => {
|
|
19
|
+
expect(screen.getByText(row.label)).toBeInTheDocument();
|
|
20
|
+
expect(screen.getByText(row.value)).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
test('renders a row note when provided', () => {
|
|
24
|
+
render(_jsx(DataViewCard, { header: "Christopher Longbottom", rows: [{ label: 'Year', value: 'Year 8', note: 'Promoted Sept 2024' }] }));
|
|
25
|
+
expect(screen.getByText('Promoted Sept 2024')).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
test('renders an Avatar when avatar props are provided', () => {
|
|
28
|
+
const { container } = render(_jsx(DataViewCard, { avatar: { initials: 'CL', alt: 'Christopher Longbottom avatar' }, header: "Christopher Longbottom", rows: baseRows }));
|
|
29
|
+
expect(container.querySelector('.ds-avatar')).toBeInTheDocument();
|
|
30
|
+
expect(screen.getByText('CL')).toBeInTheDocument();
|
|
31
|
+
});
|
|
32
|
+
test('omits the Avatar when no avatar props are provided', () => {
|
|
33
|
+
const { container } = render(_jsx(DataViewCard, { header: "Christopher Longbottom", rows: baseRows }));
|
|
34
|
+
expect(container.querySelector('.ds-avatar')).not.toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
test('uses the Card shell as a button when onClick is provided', () => {
|
|
37
|
+
const handleClick = vi.fn();
|
|
38
|
+
render(_jsx(DataViewCard, { "aria-label": "View Christopher Longbottom", header: "Christopher Longbottom", onClick: handleClick, rows: baseRows }));
|
|
39
|
+
const card = screen.getByRole('button', { name: 'View Christopher Longbottom' });
|
|
40
|
+
fireEvent.click(card);
|
|
41
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
42
|
+
});
|
|
43
|
+
test('renders as a static figure when not clickable', () => {
|
|
44
|
+
const { container } = render(_jsx(DataViewCard, { header: "Christopher Longbottom", rows: baseRows }));
|
|
45
|
+
const card = container.querySelector('figure');
|
|
46
|
+
expect(card).toBeInTheDocument();
|
|
47
|
+
expect(card).not.toHaveAttribute('role', 'button');
|
|
48
|
+
});
|
|
49
|
+
test('does not invoke onClick when disabled', () => {
|
|
50
|
+
const handleClick = vi.fn();
|
|
51
|
+
render(_jsx(DataViewCard, { "aria-label": "View Christopher Longbottom", disabled: true, header: "Christopher Longbottom", onClick: handleClick, rows: baseRows }));
|
|
52
|
+
const card = screen.getByLabelText('View Christopher Longbottom');
|
|
53
|
+
fireEvent.click(card);
|
|
54
|
+
expect(handleClick).not.toHaveBeenCalled();
|
|
55
|
+
expect(card).toHaveAttribute('aria-disabled', 'true');
|
|
56
|
+
});
|
|
57
|
+
test('renders no rows when an empty rows array is provided', () => {
|
|
58
|
+
render(_jsx(DataViewCard, { header: "Christopher Longbottom", rows: [] }));
|
|
59
|
+
expect(screen.getByRole('heading', { level: 4 })).toBeInTheDocument();
|
|
60
|
+
expect(screen.queryByText('Year')).not.toBeInTheDocument();
|
|
61
|
+
});
|
|
62
|
+
test('forwards a custom className to the underlying Card', () => {
|
|
63
|
+
const { container } = render(_jsx(DataViewCard, { className: "custom-data-view-card", header: "Christopher Longbottom", rows: baseRows }));
|
|
64
|
+
expect(container.querySelector('.custom-data-view-card')).toBeInTheDocument();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=DataViewCard.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataViewCard.test.js","sourceRoot":"","sources":["../../../src/components/dataViewCard/DataViewCard.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,kCAAkC,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE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EAAE;QAChE,MAAM,CAAC,KAAC,YAAY,IAAC,MAAM,EAAC,wBAAwB,EAAC,IAAI,EAAE,EAAE,GAAI,CAAC,CAAC;QAEnE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QACtE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC9D,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,YAAY,IACX,SAAS,EAAC,uBAAuB,EACjC,MAAM,EAAC,wBAAwB,EAC/B,IAAI,EAAE,QAAQ,GACd,CACH,CAAC;QAEF,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAChF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../src/components/row/Row.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../src/components/row/Row.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG1E,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,GAAG,GAAI,OAAO,QAAQ,4CA0ClC,CAAC;AAEF,yBAAiB,GAAG,CAAC;IACnB,KAAY,KAAK,GAAG,QAAQ,CAAC;CAC9B"}
|
|
@@ -3,11 +3,11 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { Icon } from '../icon/Icon';
|
|
4
4
|
import { ENTER_KEY, SPACE_KEY } from '../../utils/keyboardConstants';
|
|
5
5
|
export const Row = (props) => {
|
|
6
|
-
const { className, label, value, note, onClick, } = props;
|
|
6
|
+
const { className, style, label, value, note, onClick, } = props;
|
|
7
7
|
const isClickable = !!onClick;
|
|
8
8
|
return (_jsxs("div", { className: classNames('ds-row', {
|
|
9
9
|
'ds-row--clickable': isClickable,
|
|
10
|
-
}, className), onClick: onClick, onKeyDown: (e) => {
|
|
10
|
+
}, className), style: style, onClick: onClick, onKeyDown: (e) => {
|
|
11
11
|
if (isClickable && [ENTER_KEY, SPACE_KEY].includes(e.key)) {
|
|
12
12
|
e.preventDefault();
|
|
13
13
|
onClick(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.js","sourceRoot":"","sources":["../../../src/components/row/Row.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Row.js","sourceRoot":"","sources":["../../../src/components/row/Row.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAW/D,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,KAAe,EAAE,EAAE;IACrC,MAAM,EACJ,SAAS,EACT,KAAK,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,OAAO,GACR,GAAG,KAAK,CAAC;IAEV,MAAM,WAAW,GAAG,CAAC,CAAC,OAAO,CAAC;IAE9B,OAAO,CACL,eACE,SAAS,EAAE,UAAU,CACnB,QAAQ,EACR;YACE,mBAAmB,EAAE,WAAW;SACjC,EACD,SAAS,CACV,EACD,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;YACf,IAAI,WAAW,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1D,CAAC,CAAC,cAAc,EAAE,CAAC;gBACnB,OAAO,CAAC,CAA0C,CAAC,CAAC;YACtD,CAAC;QACH,CAAC,EACD,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAE9B,eAAM,SAAS,EAAC,eAAe,YAAE,KAAK,GAAQ,EAC9C,eAAM,SAAS,EAAC,eAAe,YAAE,KAAK,GAAQ,EAC9C,eAAM,SAAS,EAAC,cAAc,YAAE,IAAI,GAAQ,EAC3C,WAAW,IAAI,CACd,8BACE,KAAC,IAAI,IAAC,IAAI,EAAC,eAAe,EAAC,SAAS,EAAC,oBAAoB,EAAC,IAAI,EAAE,EAAE,GAAI,EACtE,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,EAAC,SAAS,EAAC,oBAAoB,EAAC,IAAI,EAAE,EAAE,GAAI,IACnE,CACJ,IACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
export type { TreeRowSectionProps } from '../treeRow/TreeRowSection';
|
|
3
|
+
export type TreeRowItem = {
|
|
4
|
+
id?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
note?: string;
|
|
8
|
+
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
9
|
+
children?: TreeRowItem[];
|
|
10
|
+
};
|
|
11
|
+
type TreeRowBaseProps = {
|
|
12
|
+
defaultValue?: string[];
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
type TreeRowDataDrivenProps = TreeRowBaseProps & {
|
|
16
|
+
items: TreeRowItem[];
|
|
17
|
+
children?: never;
|
|
18
|
+
};
|
|
19
|
+
type TreeRowCompoundProps = TreeRowBaseProps & {
|
|
20
|
+
items?: never;
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
};
|
|
23
|
+
export type TreeRowProps = TreeRowDataDrivenProps | TreeRowCompoundProps;
|
|
24
|
+
export declare const TreeRow: {
|
|
25
|
+
({ items, defaultValue, children, className }: TreeRowProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
Section: ({ id: idProp, label, children, className, onClick }: import("../treeRow/TreeRowSection").TreeRowSectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
};
|
|
28
|
+
export declare namespace TreeRow {
|
|
29
|
+
type Item = TreeRowItem;
|
|
30
|
+
type Props = TreeRowProps;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=TreeRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeRow.d.ts","sourceRoot":"","sources":["../../../src/components/treeRow/TreeRow.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAM1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,sBAAsB,GAAG,gBAAgB,GAAG;IAC/C,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CAAC;AAEF,KAAK,oBAAoB,GAAG,gBAAgB,GAAG;IAC7C,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,sBAAsB,GAAG,oBAAoB,CAAC;AAkCzE,eAAO,MAAM,OAAO;mDAAkD,YAAY;;CAUjF,CAAC;AAIF,yBAAiB,OAAO,CAAC;IACvB,KAAY,IAAI,GAAG,WAAW,CAAC;IAC/B,KAAY,KAAK,GAAG,YAAY,CAAC;CAClC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import * as Accordion from '@radix-ui/react-accordion';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { Row } from '../row/Row';
|
|
6
|
+
import { DepthContext, getDepthPadding, TreeRowSection } from '../treeRow/TreeRowSection';
|
|
7
|
+
const DataDrivenList = ({ items }) => {
|
|
8
|
+
const depth = useContext(DepthContext);
|
|
9
|
+
return (_jsx(_Fragment, { children: items.map((item, index) => {
|
|
10
|
+
const hasChildren = Array.isArray(item.children) && item.children.length > 0;
|
|
11
|
+
if (!hasChildren) {
|
|
12
|
+
return (_jsx(Row, { label: item.label, value: item.value, note: item.note, onClick: item.onClick, className: "ds-tree-row__row", style: { paddingLeft: getDepthPadding(depth) } }, item.id ?? item.label ?? String(index)));
|
|
13
|
+
}
|
|
14
|
+
return (_jsx(TreeRowSection, { id: item.id, label: item.label ?? '', onClick: item.onClick, children: _jsx(DataDrivenList, { items: item.children ?? [] }) }, item.id ?? item.label ?? String(index)));
|
|
15
|
+
}) }));
|
|
16
|
+
};
|
|
17
|
+
export const TreeRow = ({ items, defaultValue, children, className }) => (_jsx(Accordion.Root, { type: "multiple", defaultValue: defaultValue, className: classNames('ds-tree-row', className), children: _jsx(DepthContext.Provider, { value: 0, children: items ? _jsx(DataDrivenList, { items: items }) : children }) }));
|
|
18
|
+
TreeRow.Section = TreeRowSection;
|
|
19
|
+
//# sourceMappingURL=TreeRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeRow.js","sourceRoot":"","sources":["../../../src/components/treeRow/TreeRow.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AACvD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AA8BlG,MAAM,cAAc,GAAG,CAAC,EAAE,KAAK,EAA4B,EAAE,EAAE;IAC7D,MAAM,KAAK,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAEvC,OAAO,CACL,4BACG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACzB,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;YAE7E,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,OAAO,CACL,KAAC,GAAG,IAEF,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StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { TreeRow } from '../treeRow/TreeRow';
|
|
3
|
+
declare const meta: Meta<typeof TreeRow>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof TreeRow>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const PreOpenedSections: Story;
|
|
8
|
+
export declare const DeepNesting: Story;
|
|
9
|
+
export declare const ClickableSections: Story;
|
|
10
|
+
export declare const ClickableRows: Story;
|
|
11
|
+
export declare const MixedClickability: Story;
|
|
12
|
+
export declare const WithClickFeedback: Story;
|
|
13
|
+
//# sourceMappingURL=TreeRow.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeRow.stories.d.ts","sourceRoot":"","sources":["../../../src/components/treeRow/TreeRow.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAW5D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AA+JrD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,OAAO,CA8C9B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,OAAO,CAAC,CAAC;AAMtC,eAAO,MAAM,OAAO,EAAE,KAwBrB,CAAC;AAMF,eAAO,MAAM,iBAAiB,EAAE,KA6F/B,CAAC;AAMF,eAAO,MAAM,WAAW,EAAE,KAuHzB,CAAC;AAMF,eAAO,MAAM,iBAAiB,EAAE,KA2F/B,CAAC;AAMF,eAAO,MAAM,aAAa,EAAE,KAiF3B,CAAC;AAMF,eAAO,MAAM,iBAAiB,EAAE,KA6F/B,CAAC;AAkDF,eAAO,MAAM,iBAAiB,EAAE,KA8D/B,CAAC"}
|