@arbor-education/design-system.components 4.0.0-react19-alpha.0 → 4.1.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.
- package/.github/workflows/pr-review-approve.yaml +2 -1
- package/CHANGELOG.md +28 -0
- package/dist/components/formField/FormField.d.ts +4 -0
- package/dist/components/formField/FormField.d.ts.map +1 -1
- package/dist/components/formField/FormField.js +2 -1
- package/dist/components/formField/FormField.js.map +1 -1
- package/dist/components/formField/FormField.stories.d.ts.map +1 -1
- package/dist/components/formField/FormField.stories.js +10 -7
- package/dist/components/formField/FormField.stories.js.map +1 -1
- package/dist/components/formField/FormField.test.js +14 -0
- package/dist/components/formField/FormField.test.js.map +1 -1
- package/dist/components/formField/inputs/singleFile/SingleFileInput.d.ts +14 -0
- package/dist/components/formField/inputs/singleFile/SingleFileInput.d.ts.map +1 -0
- package/dist/components/formField/inputs/singleFile/SingleFileInput.js +35 -0
- package/dist/components/formField/inputs/singleFile/SingleFileInput.js.map +1 -0
- package/dist/components/formField/inputs/singleFile/SingleFileInput.stories.d.ts +170 -0
- package/dist/components/formField/inputs/singleFile/SingleFileInput.stories.d.ts.map +1 -0
- package/dist/components/formField/inputs/singleFile/SingleFileInput.stories.js +242 -0
- package/dist/components/formField/inputs/singleFile/SingleFileInput.stories.js.map +1 -0
- package/dist/components/formField/inputs/singleFile/SingleFileInput.test.d.ts +2 -0
- package/dist/components/formField/inputs/singleFile/SingleFileInput.test.d.ts.map +1 -0
- package/dist/components/formField/inputs/singleFile/SingleFileInput.test.js +135 -0
- package/dist/components/formField/inputs/singleFile/SingleFileInput.test.js.map +1 -0
- package/dist/components/widget/types.d.ts +9 -0
- package/dist/components/widget/types.d.ts.map +1 -1
- package/dist/components/widgetCalendar/WidgetCalendar.d.ts +5 -2
- package/dist/components/widgetCalendar/WidgetCalendar.d.ts.map +1 -1
- package/dist/components/widgetCalendar/WidgetCalendar.js +30 -5
- package/dist/components/widgetCalendar/WidgetCalendar.js.map +1 -1
- package/dist/components/widgetCalendar/WidgetCalendar.stories.d.ts +20 -2
- package/dist/components/widgetCalendar/WidgetCalendar.stories.d.ts.map +1 -1
- package/dist/components/widgetCalendar/WidgetCalendar.stories.js +269 -2
- package/dist/components/widgetCalendar/WidgetCalendar.stories.js.map +1 -1
- package/dist/components/widgetCalendar/WidgetCalendar.test.js +179 -2
- package/dist/components/widgetCalendar/WidgetCalendar.test.js.map +1 -1
- package/dist/components/widgetCalendar/WidgetCalendarItem.d.ts +1 -0
- package/dist/components/widgetCalendar/WidgetCalendarItem.d.ts.map +1 -1
- package/dist/components/widgetCalendar/WidgetCalendarItem.js +7 -2
- package/dist/components/widgetCalendar/WidgetCalendarItem.js.map +1 -1
- package/dist/components/widgetFavourites/WidgetFavourites.d.ts.map +1 -1
- package/dist/components/widgetFavourites/WidgetFavourites.js +5 -4
- package/dist/components/widgetFavourites/WidgetFavourites.js.map +1 -1
- package/dist/components/widgetFavourites/WidgetFavourites.stories.d.ts +3 -0
- package/dist/components/widgetFavourites/WidgetFavourites.stories.d.ts.map +1 -1
- package/dist/components/widgetFavourites/WidgetFavourites.stories.js +157 -0
- package/dist/components/widgetFavourites/WidgetFavourites.stories.js.map +1 -1
- package/dist/components/widgetFavourites/WidgetFavourites.test.js +41 -1
- package/dist/components/widgetFavourites/WidgetFavourites.test.js.map +1 -1
- package/dist/components/widgetFavourites/WidgetFavouritesItem.d.ts.map +1 -1
- package/dist/components/widgetFavourites/WidgetFavouritesItem.js +2 -2
- package/dist/components/widgetFavourites/WidgetFavouritesItem.js.map +1 -1
- package/dist/components/widgetFavourites/types.d.ts +4 -2
- package/dist/components/widgetFavourites/types.d.ts.map +1 -1
- package/dist/index.css +34 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/packageManifest.test.d.ts +2 -0
- package/dist/packageManifest.test.d.ts.map +1 -0
- package/dist/packageManifest.test.js +22 -0
- package/dist/packageManifest.test.js.map +1 -0
- package/package.json +1 -1
- package/src/components/formField/FormField.stories.tsx +10 -7
- package/src/components/formField/FormField.test.tsx +35 -0
- package/src/components/formField/FormField.tsx +5 -0
- package/src/components/formField/inputs/singleFile/SingleFileInput.stories.tsx +339 -0
- package/src/components/formField/inputs/singleFile/SingleFileInput.test.tsx +181 -0
- package/src/components/formField/inputs/singleFile/SingleFileInput.tsx +101 -0
- package/src/components/formField/inputs/singleFile/singleFileInput.scss +17 -0
- package/src/components/widget/types.ts +13 -0
- package/src/components/widgetCalendar/WidgetCalendar.stories.tsx +310 -2
- package/src/components/widgetCalendar/WidgetCalendar.test.tsx +315 -1
- package/src/components/widgetCalendar/WidgetCalendar.tsx +77 -31
- package/src/components/widgetCalendar/WidgetCalendarItem.tsx +14 -1
- package/src/components/widgetCalendar/widgetCalendar.scss +9 -0
- package/src/components/widgetFavourites/WidgetFavourites.stories.tsx +217 -0
- package/src/components/widgetFavourites/WidgetFavourites.test.tsx +99 -0
- package/src/components/widgetFavourites/WidgetFavourites.tsx +6 -2
- package/src/components/widgetFavourites/WidgetFavouritesItem.tsx +2 -1
- package/src/components/widgetFavourites/types.ts +5 -2
- package/src/components/widgetFavourites/widgetFavourites.scss +7 -0
- package/src/index.scss +1 -0
- package/src/index.ts +1 -0
- package/src/packageManifest.test.ts +43 -0
- package/src/tokens.scss +1 -0
- package/tokens/json/Arbor.json +4 -0
- package/.changeset/empty-clocks-jog.md +0 -5
- package/dist/components/combobox/useElementWidth.d.ts +0 -2
- package/dist/components/combobox/useElementWidth.d.ts.map +0 -1
- package/dist/components/combobox/useElementWidth.js +0 -31
- package/dist/components/combobox/useElementWidth.js.map +0 -1
- package/dist/components/combobox/useVisibleChips.d.ts +0 -21
- package/dist/components/combobox/useVisibleChips.d.ts.map +0 -1
- package/dist/components/combobox/useVisibleChips.js +0 -59
- package/dist/components/combobox/useVisibleChips.js.map +0 -1
- package/dist/components/combobox/useVisibleChips.test.d.ts +0 -2
- package/dist/components/combobox/useVisibleChips.test.d.ts.map +0 -1
- package/dist/components/combobox/useVisibleChips.test.js +0 -81
- package/dist/components/combobox/useVisibleChips.test.js.map +0 -1
- package/dist/components/icoText/IcoText.d.ts +0 -37
- package/dist/components/icoText/IcoText.d.ts.map +0 -1
- package/dist/components/icoText/IcoText.js +0 -29
- package/dist/components/icoText/IcoText.js.map +0 -1
- package/dist/components/icoText/IcoText.stories.d.ts +0 -60
- package/dist/components/icoText/IcoText.stories.d.ts.map +0 -1
- package/dist/components/icoText/IcoText.stories.js +0 -319
- package/dist/components/icoText/IcoText.stories.js.map +0 -1
- package/dist/components/icoText/IcoText.test.d.ts +0 -2
- package/dist/components/icoText/IcoText.test.d.ts.map +0 -1
- package/dist/components/icoText/IcoText.test.js +0 -27
- package/dist/components/icoText/IcoText.test.js.map +0 -1
- package/dist/components/tree-row/TreeRow.d.ts +0 -32
- package/dist/components/tree-row/TreeRow.d.ts.map +0 -1
- package/dist/components/tree-row/TreeRow.js +0 -19
- package/dist/components/tree-row/TreeRow.js.map +0 -1
- package/dist/components/tree-row/TreeRow.stories.d.ts +0 -13
- package/dist/components/tree-row/TreeRow.stories.d.ts.map +0 -1
- package/dist/components/tree-row/TreeRow.stories.js +0 -774
- package/dist/components/tree-row/TreeRow.stories.js.map +0 -1
- package/dist/components/tree-row/TreeRow.test.d.ts +0 -2
- package/dist/components/tree-row/TreeRow.test.d.ts.map +0 -1
- package/dist/components/tree-row/TreeRow.test.js +0 -262
- package/dist/components/tree-row/TreeRow.test.js.map +0 -1
- package/dist/components/tree-row/TreeRowSection.d.ts +0 -12
- package/dist/components/tree-row/TreeRowSection.d.ts.map +0 -1
- package/dist/components/tree-row/TreeRowSection.js +0 -20
- package/dist/components/tree-row/TreeRowSection.js.map +0 -1
- package/dist/utils/PopupParentContext.d.ts +0 -3
- package/dist/utils/PopupParentContext.d.ts.map +0 -1
- package/dist/utils/PopupParentContext.js +0 -6
- package/dist/utils/PopupParentContext.js.map +0 -1
- package/dist/utils/PopupParentContext.stories.d.ts +0 -17
- package/dist/utils/PopupParentContext.stories.d.ts.map +0 -1
- package/dist/utils/PopupParentContext.stories.js +0 -266
- package/dist/utils/PopupParentContext.stories.js.map +0 -1
- package/dist/utils/getDefaultPopupParent.d.ts +0 -2
- package/dist/utils/getDefaultPopupParent.d.ts.map +0 -1
- package/dist/utils/getDefaultPopupParent.js +0 -19
- package/dist/utils/getDefaultPopupParent.js.map +0 -1
|
@@ -0,0 +1,242 @@
|
|
|
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 { useState } from 'react';
|
|
4
|
+
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
5
|
+
import { FormField } from '../../FormField.js';
|
|
6
|
+
import { SingleFileInput } from './SingleFileInput.js';
|
|
7
|
+
const DESCRIPTION_INTRO = [
|
|
8
|
+
'The **SingleFileInput** lets a user pick exactly one file for a conventional form POST.',
|
|
9
|
+
'It shows the chosen file name in a read-only text field, with a button that opens the native file picker.',
|
|
10
|
+
'The selected file is submitted under the `name` you give it, like any other form control.',
|
|
11
|
+
].join('\n');
|
|
12
|
+
const USAGE_GUIDANCE = [
|
|
13
|
+
'### When to use',
|
|
14
|
+
'',
|
|
15
|
+
'- Attaching one document to a form that is submitted with a normal `<form>` POST: a consent letter, a photo, a CSV import',
|
|
16
|
+
'- Anywhere a legacy single-file field needs a Design System equivalent',
|
|
17
|
+
'- Inside `FormField` with `inputType="singleFile"` (the recommended pattern in real forms)',
|
|
18
|
+
'',
|
|
19
|
+
'---',
|
|
20
|
+
'',
|
|
21
|
+
'### When NOT to use',
|
|
22
|
+
'',
|
|
23
|
+
'| Instead of SingleFileInput... | Use... | Why |',
|
|
24
|
+
'|---|---|---|',
|
|
25
|
+
'| Several files, drag and drop, upload progress or per-file delete | [`FileUpload`](?path=/docs/components-fileupload--docs) | Async multi-file dropzone |',
|
|
26
|
+
'| Free-form text | [`TextInput`](?path=/docs/components-formfield-inputs-textinput--docs) | No file is involved |',
|
|
27
|
+
'',
|
|
28
|
+
'---',
|
|
29
|
+
'',
|
|
30
|
+
'### Design guidance',
|
|
31
|
+
'',
|
|
32
|
+
'- **Width is always 100%** of its container: size the wrapper, not the input.',
|
|
33
|
+
'- **Use FormField in real forms** so the label, description, helper link and error text are wired up for you.',
|
|
34
|
+
'- **hasError + disabled is an anti-pattern** because a user cannot correct an error on a field they cannot edit.',
|
|
35
|
+
].join('\n');
|
|
36
|
+
const DEVELOPER_NOTES = [
|
|
37
|
+
'### Critical usage patterns',
|
|
38
|
+
'',
|
|
39
|
+
'**1. Reading the selected `File`.** `onChange` receives the native change event from the hidden file input.',
|
|
40
|
+
'Read `event.currentTarget.files?.[0]` **inside the handler** (React clears `currentTarget` afterwards) to validate',
|
|
41
|
+
'type or size, then show the result through `FormField`\'s `errorText`.',
|
|
42
|
+
'',
|
|
43
|
+
'**2. Form submission.** `name`, `accept` and `required` are applied to the native `<input type="file">`, which is',
|
|
44
|
+
'the only control that carries a `name`, so only the file itself is submitted.',
|
|
45
|
+
'The visible read-only field never submits.',
|
|
46
|
+
'',
|
|
47
|
+
'**3. `ref`.** The forwarded ref points at the native file input, so `ref.current.files` works as usual.',
|
|
48
|
+
'To reset the selection, submit a form containing the field or dispatch a DOM `reset` event on that form —',
|
|
49
|
+
'setting `ref.current.value = ""` clears the native input but leaves the displayed file name stale,',
|
|
50
|
+
'because a programmatic value change does not fire `change`.',
|
|
51
|
+
'',
|
|
52
|
+
'**4. Always provide `id` inside FormField.** The label targets the visible read-only field, which is what',
|
|
53
|
+
'assistive technology lands on.',
|
|
54
|
+
'',
|
|
55
|
+
'**5. Single file only.** `multiple` is not supported.',
|
|
56
|
+
'',
|
|
57
|
+
'**6. No focus or key handlers.** `onFocus`, `onBlur` and `onKeyDown` are not accepted: the native input never receives focus.',
|
|
58
|
+
'',
|
|
59
|
+
'---',
|
|
60
|
+
'',
|
|
61
|
+
'### Accessibility',
|
|
62
|
+
'',
|
|
63
|
+
'- Keyboard: `Tab` moves from the read-only field to the **Choose file** button; `Enter` or `Space` opens the picker.',
|
|
64
|
+
'- The hidden native input is removed from the tab order and the accessibility tree, so the field is not announced twice.',
|
|
65
|
+
'- The chosen file name is the value of the labelled read-only field, so it is announced on focus.',
|
|
66
|
+
'- Pair `hasError` with `aria-invalid={true}` when used standalone. `FormField` does this automatically.',
|
|
67
|
+
].join('\n');
|
|
68
|
+
const RELATED_COMPONENTS = [
|
|
69
|
+
'## Related components',
|
|
70
|
+
'',
|
|
71
|
+
'[FormField](?path=/docs/components-formfield--docs) · [FileUpload](?path=/docs/components-fileupload--docs) · [Button](?path=/docs/components-button--docs)',
|
|
72
|
+
].join('\n');
|
|
73
|
+
function SingleFileInputDocsPage() {
|
|
74
|
+
return (_jsxs(_Fragment, { children: [_jsx(Title, {}), _jsx(Subtitle, {}), _jsx(Markdown, { children: DESCRIPTION_INTRO }), _jsx(DocHeading, { children: "Interactive example" }), _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 })] }));
|
|
75
|
+
}
|
|
76
|
+
const meta = {
|
|
77
|
+
title: 'Components/FormField/Inputs/SingleFileInput',
|
|
78
|
+
component: SingleFileInput,
|
|
79
|
+
tags: ['autodocs'],
|
|
80
|
+
parameters: {
|
|
81
|
+
layout: 'padded',
|
|
82
|
+
docs: {
|
|
83
|
+
page: SingleFileInputDocsPage,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
args: {
|
|
87
|
+
'aria-label': 'Attachment',
|
|
88
|
+
'onChange': fn(),
|
|
89
|
+
},
|
|
90
|
+
argTypes: {
|
|
91
|
+
'hasError': {
|
|
92
|
+
description: 'Applies error-state styling. Does not set `aria-invalid`: pair it when used standalone.',
|
|
93
|
+
control: 'boolean',
|
|
94
|
+
table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' } },
|
|
95
|
+
},
|
|
96
|
+
'disabled': {
|
|
97
|
+
description: 'Disables the field, the button and the native file input.',
|
|
98
|
+
control: 'boolean',
|
|
99
|
+
table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' } },
|
|
100
|
+
},
|
|
101
|
+
'required': {
|
|
102
|
+
description: 'Marks the native file input as required for form validation and the visible field as required for assistive technology.',
|
|
103
|
+
control: 'boolean',
|
|
104
|
+
table: { type: { summary: 'boolean' } },
|
|
105
|
+
},
|
|
106
|
+
'name': {
|
|
107
|
+
description: 'Name the selected file is submitted under.',
|
|
108
|
+
control: 'text',
|
|
109
|
+
table: { type: { summary: 'string' } },
|
|
110
|
+
},
|
|
111
|
+
'accept': {
|
|
112
|
+
description: 'Comma-separated list of accepted file types, passed to the native file input (for example `.pdf,image/*`).',
|
|
113
|
+
control: 'text',
|
|
114
|
+
table: { type: { summary: 'string' } },
|
|
115
|
+
},
|
|
116
|
+
'buttonLabel': {
|
|
117
|
+
description: 'Label of the button that opens the native file picker.',
|
|
118
|
+
control: 'text',
|
|
119
|
+
table: { type: { summary: 'string' }, defaultValue: { summary: "'Choose file'" } },
|
|
120
|
+
},
|
|
121
|
+
'placeholder': {
|
|
122
|
+
description: 'Text shown in the read-only field while no file is chosen.',
|
|
123
|
+
control: 'text',
|
|
124
|
+
table: { type: { summary: 'string' }, defaultValue: { summary: "'No file chosen'" } },
|
|
125
|
+
},
|
|
126
|
+
'id': {
|
|
127
|
+
description: 'Set on the visible read-only field, so a `<label htmlFor>` targets it. `FormField` passes this automatically.',
|
|
128
|
+
control: 'text',
|
|
129
|
+
table: { type: { summary: 'string' } },
|
|
130
|
+
},
|
|
131
|
+
'className': {
|
|
132
|
+
description: 'Extra class name(s) added to the wrapper element, alongside `ds-single-file-input`.',
|
|
133
|
+
control: 'text',
|
|
134
|
+
table: { type: { summary: 'string' } },
|
|
135
|
+
},
|
|
136
|
+
'aria-label': {
|
|
137
|
+
description: 'Accessible name for the visible read-only field when there is no visible label.',
|
|
138
|
+
control: 'text',
|
|
139
|
+
table: { type: { summary: 'string' } },
|
|
140
|
+
},
|
|
141
|
+
'aria-labelledby': {
|
|
142
|
+
description: 'ID(s) of the element(s) that label the visible read-only field.',
|
|
143
|
+
control: 'text',
|
|
144
|
+
table: { type: { summary: 'string' } },
|
|
145
|
+
},
|
|
146
|
+
'aria-describedby': {
|
|
147
|
+
description: 'ID(s) of the element(s) that describe the visible read-only field, such as helper or error text. `FormField` sets this automatically.',
|
|
148
|
+
control: 'text',
|
|
149
|
+
table: { type: { summary: 'string' } },
|
|
150
|
+
},
|
|
151
|
+
'aria-invalid': {
|
|
152
|
+
description: 'Marks the visible read-only field as invalid for assistive technology. `FormField` sets this automatically from `errorText`.',
|
|
153
|
+
control: 'boolean',
|
|
154
|
+
table: { type: { summary: 'boolean' } },
|
|
155
|
+
},
|
|
156
|
+
'onChange': {
|
|
157
|
+
description: 'Fired with the native change event. Read `event.currentTarget.files?.[0]` to get the selected `File`.',
|
|
158
|
+
control: false,
|
|
159
|
+
table: { type: { summary: '(event: ChangeEvent<HTMLInputElement>) => void' } },
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
export default meta;
|
|
164
|
+
const withDescription = (story, description) => ({
|
|
165
|
+
...story,
|
|
166
|
+
parameters: {
|
|
167
|
+
...story.parameters,
|
|
168
|
+
docs: {
|
|
169
|
+
...story.parameters?.docs,
|
|
170
|
+
description: { story: description },
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
const sampleFile = () => new File(['%PDF-1.4'], 'consent-letter.pdf', { type: 'application/pdf' });
|
|
175
|
+
const wrap = (node) => (_jsx("div", { style: { maxWidth: '28rem', padding: 'var(--spacing-xlarge)' }, children: node }));
|
|
176
|
+
export const Default = withDescription({
|
|
177
|
+
render: args => wrap(_jsx(SingleFileInput, { ...args })),
|
|
178
|
+
}, 'No file chosen yet. The read-only field shows its placeholder and the **Choose file** button opens the native picker.');
|
|
179
|
+
export const Selected = withDescription({
|
|
180
|
+
render: args => wrap(_jsx(SingleFileInput, { ...args })),
|
|
181
|
+
play: async ({ canvasElement, args }) => {
|
|
182
|
+
const canvas = within(canvasElement);
|
|
183
|
+
const nativeInput = canvasElement.querySelector('input[type="file"]');
|
|
184
|
+
await userEvent.upload(nativeInput, sampleFile());
|
|
185
|
+
await expect(canvas.getByRole('textbox', { name: 'Attachment' })).toHaveValue('consent-letter.pdf');
|
|
186
|
+
await expect(args.onChange).toHaveBeenCalled();
|
|
187
|
+
},
|
|
188
|
+
}, 'After a file is chosen its name replaces the placeholder in the read-only field.');
|
|
189
|
+
export const Disabled = withDescription({
|
|
190
|
+
args: { disabled: true },
|
|
191
|
+
render: args => wrap(_jsx(SingleFileInput, { ...args })),
|
|
192
|
+
}, 'The field, button and native input are all disabled.');
|
|
193
|
+
export const WithError = withDescription({
|
|
194
|
+
render: () => wrap(_jsx(FormField, { id: "attachment-error", label: "Attachment", inputType: "singleFile", errorText: "Attach a file to continue", inputProps: { name: 'attachment', required: true } })),
|
|
195
|
+
play: async ({ canvasElement }) => {
|
|
196
|
+
const canvas = within(canvasElement);
|
|
197
|
+
const field = canvas.getByRole('textbox', { name: 'Attachment' });
|
|
198
|
+
await expect(field).toBeInvalid();
|
|
199
|
+
await expect(field).toHaveAccessibleDescription('Attach a file to continue');
|
|
200
|
+
},
|
|
201
|
+
}, 'Inside `FormField`, `errorText` turns on the error styling, `aria-invalid` and the described-by link to the message.');
|
|
202
|
+
const ValidationTemplate = () => {
|
|
203
|
+
const [error, setError] = useState();
|
|
204
|
+
const maxBytes = 1024;
|
|
205
|
+
return (_jsx(FormField, { id: "attachment-validated", label: "Attachment", inputType: "singleFile", fieldDescription: "PDF, 1KB maximum", errorText: error, inputProps: {
|
|
206
|
+
name: 'attachment',
|
|
207
|
+
accept: '.pdf',
|
|
208
|
+
onChange: (event) => {
|
|
209
|
+
const file = event.currentTarget.files?.[0];
|
|
210
|
+
setError(file && file.size > maxBytes ? `${file.name} is larger than 1KB` : undefined);
|
|
211
|
+
},
|
|
212
|
+
} }));
|
|
213
|
+
};
|
|
214
|
+
export const WithValidation = withDescription({
|
|
215
|
+
render: () => wrap(_jsx(ValidationTemplate, {})),
|
|
216
|
+
play: async ({ canvasElement }) => {
|
|
217
|
+
const canvas = within(canvasElement);
|
|
218
|
+
const nativeInput = canvasElement.querySelector('input[type="file"]');
|
|
219
|
+
const oversized = new File([new Uint8Array(2048)], 'big.pdf', { type: 'application/pdf' });
|
|
220
|
+
await userEvent.upload(nativeInput, oversized);
|
|
221
|
+
await expect(canvas.getByText('big.pdf is larger than 1KB')).toBeInTheDocument();
|
|
222
|
+
await expect(canvas.getByRole('textbox', { name: 'Attachment' })).toBeInvalid();
|
|
223
|
+
},
|
|
224
|
+
}, 'The consumer reads the selected `File` in `onChange`, validates it, and reports the result through `errorText`.');
|
|
225
|
+
export const InAForm = withDescription({
|
|
226
|
+
render: () => wrap(_jsx("form", { children: _jsx(FormField, { id: "attachment-form", label: "Consent letter", inputType: "singleFile", fieldDescription: "Attach the signed letter", helperLinkText: "Letter template", helperLinkUrl: "https://example.com/template", inputProps: { name: 'consentLetter', accept: '.pdf' } }) })),
|
|
227
|
+
play: async ({ canvasElement }) => {
|
|
228
|
+
const canvas = within(canvasElement);
|
|
229
|
+
const form = canvasElement.querySelector('form');
|
|
230
|
+
const nativeInput = form.querySelector('input[type="file"]');
|
|
231
|
+
// user-event only stubs `files`, so build a real FileList for FormData to read.
|
|
232
|
+
const transfer = new DataTransfer();
|
|
233
|
+
transfer.items.add(sampleFile());
|
|
234
|
+
nativeInput.files = transfer.files;
|
|
235
|
+
nativeInput.dispatchEvent(new Event('change', { bubbles: true }));
|
|
236
|
+
const submitted = new FormData(form).get('consentLetter');
|
|
237
|
+
await expect(submitted).toBeInstanceOf(File);
|
|
238
|
+
await expect(submitted.name).toBe('consent-letter.pdf');
|
|
239
|
+
await expect(canvas.getByRole('textbox', { name: 'Consent letter' })).toHaveValue('consent-letter.pdf');
|
|
240
|
+
},
|
|
241
|
+
}, 'Within a native `<form>`, the chosen file is submitted under the file input\'s `name`.');
|
|
242
|
+
//# sourceMappingURL=SingleFileInput.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleFileInput.stories.js","sourceRoot":"","sources":["../../../../../src/components/formField/inputs/singleFile/SingleFileInput.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,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,iBAAiB,GAAG;IACxB,yFAAyF;IACzF,2GAA2G;IAC3G,2FAA2F;CAC5F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,cAAc,GAAG;IACrB,iBAAiB;IACjB,EAAE;IACF,2HAA2H;IAC3H,wEAAwE;IACxE,4FAA4F;IAC5F,EAAE;IACF,KAAK;IACL,EAAE;IACF,qBAAqB;IACrB,EAAE;IACF,kDAAkD;IAClD,eAAe;IACf,4JAA4J;IAC5J,mHAAmH;IACnH,EAAE;IACF,KAAK;IACL,EAAE;IACF,qBAAqB;IACrB,EAAE;IACF,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MAAM,MAAM,CAAE,SAAkB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClE,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAC1G,CAAC;CACF,EACD,wFAAwF,CACzF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleFileInput.test.d.ts","sourceRoot":"","sources":["../../../../../src/components/formField/inputs/singleFile/SingleFileInput.test.tsx"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import '@testing-library/jest-dom/vitest';
|
|
3
|
+
import { act, render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import { createRef } from 'react';
|
|
6
|
+
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
7
|
+
import { SingleFileInput } from './SingleFileInput.js';
|
|
8
|
+
const pdf = new File(['pdf'], 'report.pdf', { type: 'application/pdf' });
|
|
9
|
+
describe('SingleFileInput', () => {
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
vi.restoreAllMocks();
|
|
12
|
+
});
|
|
13
|
+
test('renders an empty read-only field with the default placeholder and a choose button', () => {
|
|
14
|
+
render(_jsx(SingleFileInput, { "aria-label": "Attachment" }));
|
|
15
|
+
const field = screen.getByLabelText('Attachment');
|
|
16
|
+
expect(field).toHaveAttribute('readonly');
|
|
17
|
+
expect(field).toHaveValue('');
|
|
18
|
+
expect(field).toHaveAttribute('placeholder', 'No file chosen');
|
|
19
|
+
expect(screen.getByRole('button', { name: 'Choose file' })).toBeInTheDocument();
|
|
20
|
+
});
|
|
21
|
+
test('uses a custom placeholder', () => {
|
|
22
|
+
render(_jsx(SingleFileInput, { "aria-label": "Attachment", placeholder: "Pick a PDF" }));
|
|
23
|
+
expect(screen.getByLabelText('Attachment')).toHaveAttribute('placeholder', 'Pick a PDF');
|
|
24
|
+
});
|
|
25
|
+
test('clicking the button opens the native file picker', async () => {
|
|
26
|
+
const user = userEvent.setup();
|
|
27
|
+
const click = vi.spyOn(HTMLInputElement.prototype, 'click');
|
|
28
|
+
const ref = createRef();
|
|
29
|
+
render(_jsx(SingleFileInput, { ref: ref, "aria-label": "Attachment" }));
|
|
30
|
+
await user.click(screen.getByRole('button', { name: 'Choose file' }));
|
|
31
|
+
expect(click).toHaveBeenCalledWith();
|
|
32
|
+
expect(click.mock.contexts).toContain(ref.current);
|
|
33
|
+
});
|
|
34
|
+
test('shows the chosen file name in the labelled read-only field', async () => {
|
|
35
|
+
const user = userEvent.setup();
|
|
36
|
+
const ref = createRef();
|
|
37
|
+
render(_jsx(SingleFileInput, { ref: ref, "aria-label": "Attachment" }));
|
|
38
|
+
await user.upload(ref.current, pdf);
|
|
39
|
+
expect(screen.getByRole('textbox', { name: 'Attachment' })).toHaveValue('report.pdf');
|
|
40
|
+
});
|
|
41
|
+
test('clears the file name when the selection is cleared', async () => {
|
|
42
|
+
const user = userEvent.setup();
|
|
43
|
+
const ref = createRef();
|
|
44
|
+
render(_jsx(SingleFileInput, { ref: ref, "aria-label": "Attachment" }));
|
|
45
|
+
await user.upload(ref.current, pdf);
|
|
46
|
+
await user.upload(ref.current, []);
|
|
47
|
+
expect(screen.getByLabelText('Attachment')).toHaveValue('');
|
|
48
|
+
});
|
|
49
|
+
test('clears the file name when the surrounding form is reset', async () => {
|
|
50
|
+
const user = userEvent.setup();
|
|
51
|
+
const ref = createRef();
|
|
52
|
+
render(_jsx("form", { "aria-label": "Upload", children: _jsx(SingleFileInput, { ref: ref, "aria-label": "Attachment" }) }));
|
|
53
|
+
await user.upload(ref.current, pdf);
|
|
54
|
+
expect(screen.getByLabelText('Attachment')).toHaveValue('report.pdf');
|
|
55
|
+
act(() => {
|
|
56
|
+
screen.getByRole('form', { name: 'Upload' }).dispatchEvent(new Event('reset'));
|
|
57
|
+
});
|
|
58
|
+
expect(screen.getByLabelText('Attachment')).toHaveValue('');
|
|
59
|
+
});
|
|
60
|
+
test('calls onChange with the native event so the consumer can read the File', async () => {
|
|
61
|
+
const user = userEvent.setup();
|
|
62
|
+
let selectedFile;
|
|
63
|
+
const onChange = vi.fn((event) => {
|
|
64
|
+
selectedFile = event.currentTarget.files?.[0];
|
|
65
|
+
});
|
|
66
|
+
const ref = createRef();
|
|
67
|
+
render(_jsx(SingleFileInput, { ref: ref, "aria-label": "Attachment", onChange: onChange }));
|
|
68
|
+
await user.upload(ref.current, pdf);
|
|
69
|
+
expect(onChange).toHaveBeenCalledTimes(1);
|
|
70
|
+
expect(selectedFile).toBe(pdf);
|
|
71
|
+
});
|
|
72
|
+
test('passes name, accept and required to the native file input', () => {
|
|
73
|
+
const ref = createRef();
|
|
74
|
+
render(_jsx(SingleFileInput, { ref: ref, "aria-label": "Attachment", name: "attachment", accept: ".pdf", required: true }));
|
|
75
|
+
expect(ref.current).toHaveAttribute('type', 'file');
|
|
76
|
+
expect(ref.current).toHaveAttribute('name', 'attachment');
|
|
77
|
+
expect(ref.current).toHaveAttribute('accept', '.pdf');
|
|
78
|
+
expect(ref.current).toBeRequired();
|
|
79
|
+
expect(ref.current).not.toHaveAttribute('multiple');
|
|
80
|
+
});
|
|
81
|
+
test('exposes required to assistive technology on the visible field', () => {
|
|
82
|
+
render(_jsx(SingleFileInput, { "aria-label": "Attachment", required: true }));
|
|
83
|
+
expect(screen.getByLabelText('Attachment')).toBeRequired();
|
|
84
|
+
});
|
|
85
|
+
test('does not submit the visible read-only field', () => {
|
|
86
|
+
const { container } = render(_jsx("form", { children: _jsx(SingleFileInput, { "aria-label": "Attachment", name: "attachment" }) }));
|
|
87
|
+
const namedControls = container.querySelectorAll('[name]');
|
|
88
|
+
expect(namedControls).toHaveLength(1);
|
|
89
|
+
expect(namedControls[0]).toHaveAttribute('type', 'file');
|
|
90
|
+
});
|
|
91
|
+
test('disables the field, button and native input', () => {
|
|
92
|
+
const ref = createRef();
|
|
93
|
+
render(_jsx(SingleFileInput, { ref: ref, "aria-label": "Attachment", disabled: true }));
|
|
94
|
+
expect(screen.getByLabelText('Attachment')).toBeDisabled();
|
|
95
|
+
expect(screen.getByRole('button', { name: 'Choose file' })).toBeDisabled();
|
|
96
|
+
expect(ref.current).toBeDisabled();
|
|
97
|
+
});
|
|
98
|
+
test('applies error styling to the field and the button', () => {
|
|
99
|
+
render(_jsx(SingleFileInput, { "aria-label": "Attachment", hasError: true }));
|
|
100
|
+
expect(screen.getByLabelText('Attachment')).toHaveClass('ds-input--error');
|
|
101
|
+
expect(screen.getByRole('button', { name: 'Choose file' })).toHaveClass('ds-button--error');
|
|
102
|
+
});
|
|
103
|
+
test('forwards id and aria attributes to the visible field', () => {
|
|
104
|
+
render(_jsx(SingleFileInput, { id: "attachment", "aria-label": "Attachment", "aria-describedby": "hint", "aria-invalid": true }));
|
|
105
|
+
const field = screen.getByLabelText('Attachment');
|
|
106
|
+
expect(field).toHaveAttribute('id', 'attachment');
|
|
107
|
+
expect(field).toHaveAttribute('aria-describedby', 'hint');
|
|
108
|
+
expect(field).toBeInvalid();
|
|
109
|
+
});
|
|
110
|
+
test('tabs from the read-only field to the button and skips the hidden native input', async () => {
|
|
111
|
+
const user = userEvent.setup();
|
|
112
|
+
render(_jsx(SingleFileInput, { "aria-label": "Attachment" }));
|
|
113
|
+
await user.tab();
|
|
114
|
+
expect(screen.getByLabelText('Attachment')).toHaveFocus();
|
|
115
|
+
await user.tab();
|
|
116
|
+
expect(screen.getByRole('button', { name: 'Choose file' })).toHaveFocus();
|
|
117
|
+
});
|
|
118
|
+
test('opens the file picker from the keyboard with Enter and Space', async () => {
|
|
119
|
+
const user = userEvent.setup();
|
|
120
|
+
const click = vi.spyOn(HTMLInputElement.prototype, 'click');
|
|
121
|
+
render(_jsx(SingleFileInput, { "aria-label": "Attachment" }));
|
|
122
|
+
await user.tab();
|
|
123
|
+
await user.tab();
|
|
124
|
+
await user.keyboard('{Enter}');
|
|
125
|
+
expect(click).toHaveBeenCalledTimes(1);
|
|
126
|
+
await user.keyboard(' ');
|
|
127
|
+
expect(click).toHaveBeenCalledTimes(2);
|
|
128
|
+
});
|
|
129
|
+
test('uses a custom button label', () => {
|
|
130
|
+
render(_jsx(SingleFileInput, { "aria-label": "Attachment", buttonLabel: "Browse" }));
|
|
131
|
+
expect(screen.getByRole('button', { name: 'Browse' })).toBeInTheDocument();
|
|
132
|
+
expect(screen.queryByRole('button', { name: 'Choose file' })).not.toBeInTheDocument();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
//# sourceMappingURL=SingleFileInput.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SingleFileInput.test.js","sourceRoot":"","sources":["../../../../../src/components/formField/inputs/singleFile/SingleFileInput.test.tsx"],"names":[],"mappings":";AAAA,OAAO,kCAAkC,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,SAAS,EAAoB,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAEzE,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,SAAS,CAAC,GAAG,EAAE;QACb,EAAE,CAAC,eAAe,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,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M,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAEvC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACtC,MAAM,CAAC,KAAC,eAAe,kBAAY,YAAY,EAAC,WAAW,EAAC,QAAQ,GAAG,CAAC,CAAC;QAEzE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;QAC3E,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;IACxF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -39,5 +39,14 @@ export type WidgetStaticProps = WidgetBaseProps & {
|
|
|
39
39
|
collapsible?: false;
|
|
40
40
|
};
|
|
41
41
|
export type WidgetProps = WidgetLinkedProps | WidgetCollapsibleProps | WidgetStaticProps;
|
|
42
|
+
export type WidgetHeadingLinkProps = {
|
|
43
|
+
headingHref: string;
|
|
44
|
+
renderLink?: WidgetLinkedProps['renderLink'];
|
|
45
|
+
linkProps?: WidgetLinkedProps['linkProps'];
|
|
46
|
+
} | {
|
|
47
|
+
headingHref?: undefined;
|
|
48
|
+
renderLink?: never;
|
|
49
|
+
linkProps?: never;
|
|
50
|
+
};
|
|
42
51
|
export {};
|
|
43
52
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../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xB,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WidgetHeadingLinkProps } from '../widget/types.js';
|
|
1
2
|
import type { WidgetCalendarEventType, WidgetCalendarItemProps } from './WidgetCalendarItem.js';
|
|
2
3
|
type WidgetCalendarItemData = {
|
|
3
4
|
id: string;
|
|
@@ -10,16 +11,18 @@ type WidgetCalendarItemData = {
|
|
|
10
11
|
eventLocation?: string;
|
|
11
12
|
eventSecondaryDefinition?: React.ReactNode;
|
|
12
13
|
buttonA11yText?: string;
|
|
14
|
+
tooltip?: string;
|
|
15
|
+
group?: string;
|
|
13
16
|
};
|
|
14
|
-
type WidgetCalendarProps = {
|
|
17
|
+
type WidgetCalendarProps = WidgetHeadingLinkProps & {
|
|
15
18
|
heading: React.ReactNode;
|
|
16
19
|
tooltip?: string;
|
|
17
|
-
headingHref?: string;
|
|
18
20
|
items: WidgetCalendarItemData[];
|
|
19
21
|
isFloating?: boolean;
|
|
20
22
|
onItemClick?: (id: string) => void;
|
|
21
23
|
emptyState?: React.ReactNode;
|
|
22
24
|
className?: string;
|
|
25
|
+
groupItems?: boolean;
|
|
23
26
|
};
|
|
24
27
|
export declare const WidgetCalendar: {
|
|
25
28
|
(props: WidgetCalendarProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetCalendar.d.ts","sourceRoot":"","sources":["../../../src/components/widgetCalendar/WidgetCalendar.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"WidgetCalendar.d.ts","sourceRoot":"","sources":["../../../src/components/widgetCalendar/WidgetCalendar.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,K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}
|
|
@@ -1,22 +1,47 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { EmptyState } from '../emptyState/EmptyState.js';
|
|
3
3
|
import { Icon } from '../icon/Icon.js';
|
|
4
4
|
import { Widget } from '../widget/Widget.js';
|
|
5
5
|
import { WidgetCalendarItem } from './WidgetCalendarItem.js';
|
|
6
|
+
import { Fragment } from 'react/jsx-runtime';
|
|
6
7
|
const defaultEmptyState = (_jsx(EmptyState, { padding: "md", illustration: _jsx(Icon, { name: "date", size: 24 }), heading: "Nothing scheduled", subHeading: "There are no upcoming events." }));
|
|
7
8
|
export const WidgetCalendar = (props) => {
|
|
8
|
-
const { heading, tooltip, headingHref, items, isFloating = false, onItemClick, emptyState = defaultEmptyState, className, } = props;
|
|
9
|
+
const { heading, tooltip, headingHref, renderLink, linkProps, items, isFloating = false, onItemClick, emptyState = defaultEmptyState, className, groupItems, } = props;
|
|
9
10
|
const isEmpty = items.length === 0;
|
|
10
|
-
const
|
|
11
|
+
const groups = ['_ungrouped'];
|
|
12
|
+
const groupMap = {
|
|
13
|
+
_ungrouped: [],
|
|
14
|
+
};
|
|
15
|
+
if (groupItems) {
|
|
16
|
+
items.forEach((item) => {
|
|
17
|
+
if (item.group) {
|
|
18
|
+
if (!groups.includes(item.group)) {
|
|
19
|
+
groupMap[item.group] = [];
|
|
20
|
+
groups.push(item.group);
|
|
21
|
+
}
|
|
22
|
+
groupMap[item.group]?.push(item);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
groupMap._ungrouped.push(item);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
groupMap._ungrouped = [...items];
|
|
31
|
+
}
|
|
11
32
|
const widgetProps = {
|
|
12
33
|
tooltip,
|
|
13
34
|
isFloating,
|
|
14
35
|
isEmpty,
|
|
15
36
|
emptyState,
|
|
16
37
|
className,
|
|
17
|
-
...(headingHref ? { href: headingHref } : {}),
|
|
38
|
+
...(headingHref ? { href: headingHref, renderLink, linkProps } : {}),
|
|
18
39
|
};
|
|
19
|
-
return (
|
|
40
|
+
return (_jsxs(Widget, { ...widgetProps, children: [_jsx(Widget.Header, { children: heading }), _jsx(Widget.Body, { children: !isEmpty && (groups.map((group) => {
|
|
41
|
+
const label = group;
|
|
42
|
+
const eventItems = groupMap[group];
|
|
43
|
+
return (_jsxs(Fragment, { children: [label !== '_ungrouped' && (_jsx("span", { className: "ds-widget-calendar__group-heading", children: label }, `groupLabel_${label}`)), eventItems.length > 0 && (_jsx("ul", { className: "ds-widget-calendar__list", children: eventItems.map(item => (_jsx(WidgetCalendarItem, { id: item.id, eventType: item.eventType, eventPrimaryTerm: item.eventPrimaryTerm, eventPrimaryDefinition: item.eventPrimaryDefinition, eventSecondaryTerm: item.eventSecondaryTerm, eventDateTime: item.eventDateTime, eventTimeLabel: item.eventTimeLabel, eventLocation: item.eventLocation, eventSecondaryDefinition: item.eventSecondaryDefinition, buttonA11yText: item.buttonA11yText, onItemClick: onItemClick ? () => onItemClick(item.id) : undefined, tooltip: item.tooltip }, item.id))) }, label))] }, `widgetCalendarGroup_${group}`));
|
|
44
|
+
})) })] }));
|
|
20
45
|
};
|
|
21
46
|
WidgetCalendar.Item = WidgetCalendarItem;
|
|
22
47
|
//# sourceMappingURL=WidgetCalendar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetCalendar.js","sourceRoot":"","sources":["../../../src/components/widgetCalendar/WidgetCalendar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"WidgetCalendar.js","sourceRoot":"","sources":["../../../src/components/widgetCalendar/WidgetCal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AAI,CAAC,gBAAgB,EACvC,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EACnD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,EAC3C,aAAa,EAAE,IAAI,CAAC,aAAa,EACjC,cAAc,EAAE,IAAI,CAAC,cAAc,EACnC,aAAa,EAAE,IAAI,CAAC,aAAa,EACjC,wBAAwB,EAAE,IAAI,CAAC,wBAAwB,EACvD,cAAc,EAAE,IAAI,CAAC,cAAc,EACnC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,EACjE,OAAO,EAAE,IAAI,CAAC,OAAO,IAZhB,IAAI,CAAC,EAAE,CAaZ,CACH,CAAC,IAjBK,KAAK,CAkBT,CACN,KA7BY,uBAAuB,KAAK,EAAE,CA8BlC,CACZ,CAAC;gBACJ,CAAC,CAAC,CACH,GACW,IACP,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,cAAc,CAAC,IAAI,GAAG,kBAAkB,CAAC"}
|
|
@@ -4,10 +4,9 @@ declare function WidgetCalendarDocsPage(): import("react").JSX.Element;
|
|
|
4
4
|
declare const meta: {
|
|
5
5
|
title: string;
|
|
6
6
|
component: {
|
|
7
|
-
(props: {
|
|
7
|
+
(props: import("../widget/types.js").WidgetHeadingLinkProps & {
|
|
8
8
|
heading: React.ReactNode;
|
|
9
9
|
tooltip?: string;
|
|
10
|
-
headingHref?: string;
|
|
11
10
|
items: {
|
|
12
11
|
id: string;
|
|
13
12
|
eventType?: import("./WidgetCalendarItem.js").WidgetCalendarEventType;
|
|
@@ -19,11 +18,14 @@ declare const meta: {
|
|
|
19
18
|
eventLocation?: string;
|
|
20
19
|
eventSecondaryDefinition?: React.ReactNode;
|
|
21
20
|
buttonA11yText?: string;
|
|
21
|
+
tooltip?: string;
|
|
22
|
+
group?: string;
|
|
22
23
|
}[];
|
|
23
24
|
isFloating?: boolean;
|
|
24
25
|
onItemClick?: (id: string) => void;
|
|
25
26
|
emptyState?: React.ReactNode;
|
|
26
27
|
className?: string;
|
|
28
|
+
groupItems?: boolean;
|
|
27
29
|
}): React.JSX.Element;
|
|
28
30
|
Item: (props: import("./WidgetCalendarItem.js").WidgetCalendarItemProps) => React.JSX.Element;
|
|
29
31
|
};
|
|
@@ -113,20 +115,36 @@ declare const meta: {
|
|
|
113
115
|
};
|
|
114
116
|
};
|
|
115
117
|
};
|
|
118
|
+
groupItems: {
|
|
119
|
+
control: "boolean";
|
|
120
|
+
description: string;
|
|
121
|
+
table: {
|
|
122
|
+
type: {
|
|
123
|
+
summary: string;
|
|
124
|
+
};
|
|
125
|
+
defaultValue: {
|
|
126
|
+
summary: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
};
|
|
116
130
|
};
|
|
117
131
|
};
|
|
118
132
|
export default meta;
|
|
119
133
|
type Story = StoryObj<typeof WidgetCalendar>;
|
|
120
134
|
export declare const Default: Story;
|
|
121
135
|
export declare const Interactive: Story;
|
|
136
|
+
export declare const WithHeadingLinkProps: Story;
|
|
122
137
|
export declare const PrimaryEventType: Story;
|
|
123
138
|
export declare const SecondaryEventType: Story;
|
|
124
139
|
export declare const NonInteractiveItems: Story;
|
|
125
140
|
export declare const WithoutLocation: Story;
|
|
126
141
|
export declare const CustomSecondaryContent: Story;
|
|
127
142
|
export declare const WithTooltip: Story;
|
|
143
|
+
export declare const WithItemTooltips: Story;
|
|
128
144
|
export declare const Empty: Story;
|
|
129
145
|
export declare const CustomEmptyState: Story;
|
|
130
146
|
export declare const FixedHeightOverflow: Story;
|
|
131
147
|
export declare const Composable: Story;
|
|
148
|
+
export declare const Grouped: Story;
|
|
149
|
+
export declare const Ungrouped: Story;
|
|
132
150
|
//# sourceMappingURL=WidgetCalendar.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetCalendar.stories.d.ts","sourceRoot":"","sources":["../../../src/components/widgetCalendar/WidgetCalendar.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAa5D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"WidgetCalendar.stories.d.ts","sourceRoot":"","sources":["../../../src/components/widgetCalendar/WidgetCalendar.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAa5D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAwOrD,iBAAS,sBAAsB,gCAmB9B;AAMD,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiG6B,CAAC;AAExC,eAAe,IAAI,CAAC;AAGpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,cAAc,CAAC,CAAC;AAoJ7C,eAAO,MAAM,OAAO,EAAE,KAgBrB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAsCzB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KAgDlC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KA6B9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KA6BhC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KA6BjC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAwB7B,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,KA0BpC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAoBzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAwC9B,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAUnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAiB9B,CAAC;AAE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