@agregio-solutions/design-system 1.90.1 → 1.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/design-system.cjs +9 -5
  2. package/dist/design-system.js +14 -6
  3. package/dist/packages/components/Accordion/doc.md +342 -0
  4. package/dist/packages/components/Badge/doc.md +192 -0
  5. package/dist/packages/components/Breadcrumbs/doc.md +332 -0
  6. package/dist/packages/components/Button/doc.md +425 -0
  7. package/dist/packages/components/Calendar/doc.md +465 -0
  8. package/dist/packages/components/ChartLegend/doc.md +151 -0
  9. package/dist/packages/components/ChartTooltip/doc.md +124 -0
  10. package/dist/packages/components/Checkbox/doc.md +329 -0
  11. package/dist/packages/components/CheckboxGroup/doc.md +242 -0
  12. package/dist/packages/components/Chip/doc.md +99 -0
  13. package/dist/packages/components/Combobox/Combobox.d.ts +8 -0
  14. package/dist/packages/components/Combobox/doc.md +680 -0
  15. package/dist/packages/components/DataTable/doc.md +1124 -0
  16. package/dist/packages/components/DatePicker/doc.md +579 -0
  17. package/dist/packages/components/DateRangePicker/doc.md +638 -0
  18. package/dist/packages/components/Drawer/doc.md +338 -0
  19. package/dist/packages/components/Dropdown/Dropdown.d.ts +4 -0
  20. package/dist/packages/components/Dropdown/doc.md +205 -0
  21. package/dist/packages/components/EmptyState/doc.md +101 -0
  22. package/dist/packages/components/FileUpload/doc.md +449 -0
  23. package/dist/packages/components/Filter/doc.md +196 -0
  24. package/dist/packages/components/Header/doc.md +373 -0
  25. package/dist/packages/components/I18nProvider/doc.md +187 -0
  26. package/dist/packages/components/Icon/doc.md +63 -0
  27. package/dist/packages/components/Label/doc.md +60 -0
  28. package/dist/packages/components/LinearProgressBar/doc.md +148 -0
  29. package/dist/packages/components/Link/doc.md +206 -0
  30. package/dist/packages/components/List/doc.md +481 -0
  31. package/dist/packages/components/Loader/doc.md +53 -0
  32. package/dist/packages/components/Menu/Menu.d.ts +5 -1
  33. package/dist/packages/components/Menu/doc.md +231 -0
  34. package/dist/packages/components/Message/doc.md +166 -0
  35. package/dist/packages/components/Modal/doc.md +289 -0
  36. package/dist/packages/components/Navigation/doc.md +992 -0
  37. package/dist/packages/components/NavigationItem/doc.md +167 -0
  38. package/dist/packages/components/NotificationCard/doc.md +206 -0
  39. package/dist/packages/components/Notifications/doc.md +240 -0
  40. package/dist/packages/components/NumberField/doc.md +582 -0
  41. package/dist/packages/components/PageLayout/doc.md +651 -0
  42. package/dist/packages/components/Pagination/doc.md +227 -0
  43. package/dist/packages/components/Popover/doc.md +245 -0
  44. package/dist/packages/components/Radio/doc.md +370 -0
  45. package/dist/packages/components/RouterProvider/doc.md +64 -0
  46. package/dist/packages/components/SearchBar/doc.md +504 -0
  47. package/dist/packages/components/SegmentedControl/doc.md +398 -0
  48. package/dist/packages/components/Select/Select.d.ts +4 -0
  49. package/dist/packages/components/Select/doc.md +1133 -0
  50. package/dist/packages/components/Skeleton/doc.md +129 -0
  51. package/dist/packages/components/Slider/doc.md +362 -0
  52. package/dist/packages/components/Stepper/doc.md +104 -0
  53. package/dist/packages/components/Switch/doc.md +296 -0
  54. package/dist/packages/components/Tabs/doc.md +295 -0
  55. package/dist/packages/components/Tag/doc.md +81 -0
  56. package/dist/packages/components/TextInput/doc.md +490 -0
  57. package/dist/packages/components/TimeField/doc.md +353 -0
  58. package/dist/packages/components/Timeline/doc.md +1046 -0
  59. package/dist/packages/components/Toaster/doc.md +263 -0
  60. package/dist/packages/components/ToggleButton/doc.md +108 -0
  61. package/dist/packages/components/ToggleButtonGroup/doc.md +307 -0
  62. package/dist/packages/components/Tooltip/doc.md +206 -0
  63. package/dist/packages/components/YearMonthPicker/YearMonthPicker.d.ts +8 -0
  64. package/dist/packages/components/YearMonthPicker/doc.md +638 -0
  65. package/dist/public_docs/components.md +68 -0
  66. package/dist/public_docs/index.md +30 -0
  67. package/dist/public_docs/tokens.md +121 -0
  68. package/package.json +3 -2
@@ -0,0 +1,370 @@
1
+ # Radio
2
+
3
+ ## Props
4
+
5
+ The complete Props documentation with JS doc for this component is available at this path:
6
+
7
+ node_modules/@agregio-solutions/design-system/dist/packages/components/Radio/Radio.d.ts
8
+
9
+ ## Example usage
10
+
11
+ Here are the Storybook Stories.
12
+
13
+ Base stories:
14
+
15
+ ```tsx
16
+ import { Meta, StoryObj } from "@storybook/react-vite";
17
+ import Radio from "./Radio";
18
+ import { userEvent, within, expect, fn } from "storybook/test";
19
+ import Icon from "@components/Icon/Icon";
20
+
21
+ const meta: Meta<typeof Radio> = {
22
+ component: Radio,
23
+ argTypes: {
24
+ label: { control: "text" },
25
+ },
26
+ parameters: {
27
+ layout: "centered",
28
+ },
29
+ };
30
+ export default meta;
31
+
32
+ export const WithLabel: StoryObj<typeof Radio> = {
33
+ args: {
34
+ id: "radio-id",
35
+ label: "Label",
36
+ onChange: fn(),
37
+ },
38
+ play: async ({ canvasElement }) => {
39
+ const canvas = within(canvasElement);
40
+ await canvas.findByText("Label");
41
+ await expect(canvas.getByLabelText("Label")).not.toBeChecked();
42
+ },
43
+ };
44
+
45
+ export const WithLabelSelected: StoryObj<typeof Radio> = {
46
+ args: {
47
+ ...WithLabel.args,
48
+ checked: true,
49
+ },
50
+ play: async ({ canvasElement }) => {
51
+ const canvas = within(canvasElement);
52
+ await canvas.findByText("Label");
53
+ await expect(canvas.getByLabelText("Label")).toBeChecked();
54
+ },
55
+ };
56
+
57
+ export const WithLabelDisabled: StoryObj<typeof Radio> = {
58
+ args: {
59
+ ...WithLabel.args,
60
+ disabled: true,
61
+ },
62
+ play: async ({ canvasElement, args }) => {
63
+ const canvas = within(canvasElement);
64
+ await canvas.findByText("Label");
65
+ await expect(canvas.getByLabelText("Label")).not.toBeChecked();
66
+ await userEvent.click(canvas.getByLabelText("Label"));
67
+ await expect(args.onChange).toHaveBeenCalledTimes(0);
68
+ await expect(canvas.getByLabelText("Label")).not.toBeChecked();
69
+ },
70
+ };
71
+
72
+ export const WithLabelFocus: StoryObj<typeof Radio> = {
73
+ args: {
74
+ ...WithLabel.args,
75
+ labelProps: {
76
+ // @ts-ignore
77
+ "data-force-focus": true,
78
+ },
79
+ },
80
+ };
81
+
82
+ export const WithoutLabel: StoryObj<typeof Radio> = {
83
+ args: {
84
+ label: undefined,
85
+ "aria-label": "Label",
86
+ title: "Title",
87
+ onChange: fn(),
88
+ },
89
+ play: async ({ canvasElement }) => {
90
+ const canvas = within(canvasElement);
91
+ await canvas.findByLabelText("Label");
92
+ await canvas.findByTitle("Title");
93
+ await expect(canvas.getByLabelText("Label")).not.toBeChecked();
94
+ },
95
+ };
96
+
97
+ export const WithoutLabelSelected: StoryObj<typeof Radio> = {
98
+ args: {
99
+ ...WithoutLabel.args,
100
+ checked: true,
101
+ },
102
+ play: async ({ canvasElement }) => {
103
+ const canvas = within(canvasElement);
104
+ await canvas.findByLabelText("Label");
105
+ await expect(canvas.getByLabelText("Label")).toBeChecked();
106
+ },
107
+ };
108
+
109
+ export const WithoutLabelDisabled: StoryObj<typeof Radio> = {
110
+ args: {
111
+ ...WithoutLabel.args,
112
+ disabled: true,
113
+ },
114
+ play: async ({ canvasElement, args }) => {
115
+ const canvas = within(canvasElement);
116
+ await canvas.findByLabelText("Label");
117
+ await expect(canvas.getByLabelText("Label")).not.toBeChecked();
118
+ await userEvent.click(canvas.getByLabelText("Label"));
119
+ await expect(args.onChange).toHaveBeenCalledTimes(0);
120
+ await expect(canvas.getByLabelText("Label")).not.toBeChecked();
121
+ },
122
+ };
123
+
124
+ export const WithoutLabelFocus: StoryObj<typeof Radio> = {
125
+ args: {
126
+ ...WithoutLabel.args,
127
+ labelProps: {
128
+ // @ts-ignore
129
+ "data-force-focus": true,
130
+ },
131
+ },
132
+ };
133
+
134
+ export const WithLongText: StoryObj<typeof Radio> = {
135
+ args: {
136
+ ...WithLabel.args,
137
+ label: "This is a very long text that should be truncated",
138
+ },
139
+ decorators: [
140
+ (Story) => (
141
+ <div style={{ width: 200 }}>
142
+ <Story />
143
+ </div>
144
+ ),
145
+ ],
146
+ };
147
+
148
+ export const WithComponent: StoryObj<typeof Radio> = {
149
+ args: {
150
+ ...WithLabel.args,
151
+ label: <Icon name="star" style={{ fontSize: 60 }} />,
152
+ },
153
+ };
154
+ ```
155
+
156
+ ## How to test this component
157
+
158
+ Here are some more advanced stories with more testing coverage and examples that you can read to understand how to test this component.
159
+
160
+ ```tsx
161
+ import { Meta, StoryObj } from "@storybook/react-vite";
162
+ import Radio from "../Radio";
163
+ import { fireEvent, within, expect } from "storybook/test";
164
+ import { useState } from "react";
165
+ import { useForm, useWatch } from "react-hook-form";
166
+ import { someTime } from "@internal/test-utils-storybook/test-utils-storybook";
167
+
168
+ const meta: Meta<typeof Radio> = {
169
+ component: Radio,
170
+ argTypes: {
171
+ label: { control: "text" },
172
+ },
173
+ parameters: {
174
+ layout: "centered",
175
+ chromatic: { disableSnapshot: true },
176
+ },
177
+ };
178
+ export default meta;
179
+
180
+ // Be warned ! There is a known issue with the userEvent.click on radio inputs in Firefox
181
+ // This is why we use a mix of userEvent and fireEvent, waiting for a fix in userEvent
182
+ // See: https://github.com/testing-library/user-event/issues/1149
183
+
184
+ export const ExampleControlled: StoryObj<typeof Radio> = {
185
+ render: (args) => {
186
+ type ControlledExampleProps = {
187
+ initialSelected?: string;
188
+ };
189
+
190
+ const ControlledExample = ({ initialSelected }: ControlledExampleProps) => {
191
+ const [selected, setSelected] = useState<string>(initialSelected || "");
192
+ return (
193
+ <div>
194
+ <div>Debug selected: {selected}</div>
195
+
196
+ <div>
197
+ <Radio
198
+ id="radio-id-1"
199
+ label="Option 1"
200
+ checked={selected === "radio-id-1"}
201
+ onChange={() => setSelected("radio-id-1")}
202
+ />
203
+ </div>
204
+ <div>
205
+ <Radio
206
+ id="radio-id-2"
207
+ label="Option 2"
208
+ checked={selected === "radio-id-2"}
209
+ onChange={() => setSelected("radio-id-2")}
210
+ />
211
+ </div>
212
+ </div>
213
+ );
214
+ };
215
+
216
+ return <ControlledExample {...args} />;
217
+ },
218
+ };
219
+
220
+ export const TestControlled: StoryObj<typeof Radio> = {
221
+ render: ExampleControlled.render,
222
+ play: async ({ canvasElement }) => {
223
+ const canvas = within(canvasElement);
224
+ await canvas.findByText("Debug selected:");
225
+ await expect(canvas.getByLabelText("Option 1")).not.toBeChecked();
226
+ await expect(canvas.getByLabelText("Option 2")).not.toBeChecked();
227
+ await fireEvent.click(canvas.getByLabelText("Option 1"));
228
+ await expect(canvas.getByLabelText("Option 1")).toBeChecked();
229
+ await expect(canvas.getByLabelText("Option 2")).not.toBeChecked();
230
+ await canvas.findByText("Debug selected: radio-id-1");
231
+ await fireEvent.click(canvas.getByLabelText("Option 2"));
232
+ await expect(canvas.getByLabelText("Option 1")).not.toBeChecked();
233
+ await expect(canvas.getByLabelText("Option 2")).toBeChecked();
234
+ await canvas.findByText("Debug selected: radio-id-2");
235
+ },
236
+ };
237
+
238
+ export const TestControlledWithInitialValue: StoryObj<typeof Radio> = {
239
+ // @ts-ignore
240
+ render: () => ExampleControlled.render({ initialSelected: "radio-id-1" }),
241
+ play: async ({ canvasElement }) => {
242
+ const canvas = within(canvasElement);
243
+ await expect(canvas.getByLabelText("Option 1")).toBeChecked();
244
+ await expect(canvas.getByLabelText("Option 2")).not.toBeChecked();
245
+ await canvas.findByText("Debug selected: radio-id-1");
246
+ await fireEvent.click(canvas.getByLabelText("Option 2"));
247
+ await expect(canvas.getByLabelText("Option 1")).not.toBeChecked();
248
+ await expect(canvas.getByLabelText("Option 2")).toBeChecked();
249
+ await canvas.findByText("Debug selected: radio-id-2");
250
+ },
251
+ };
252
+
253
+ export const ExampleWithReactHookForm: StoryObj<typeof Radio> = {
254
+ render: (args) => {
255
+ type ReactHookFormExampleProps = {
256
+ initialSelected?: string;
257
+ };
258
+
259
+ const ReactHookFormExample = ({
260
+ initialSelected,
261
+ }: ReactHookFormExampleProps) => {
262
+ const { register, control } = useForm({
263
+ defaultValues: {
264
+ radio: initialSelected || "",
265
+ },
266
+ });
267
+ const radio = useWatch({ control, name: "radio" });
268
+
269
+ return (
270
+ <form>
271
+ <div>Debug selected: {radio}</div>
272
+ <div>
273
+ <Radio
274
+ {...register("radio")}
275
+ id="radio-id-1"
276
+ label="Option 1"
277
+ value="radio-id-1"
278
+ />
279
+ </div>
280
+ <div>
281
+ <Radio
282
+ {...register("radio")}
283
+ id="radio-id-2"
284
+ label="Option 2"
285
+ value="radio-id-2"
286
+ />
287
+ </div>
288
+ </form>
289
+ );
290
+ };
291
+
292
+ return <ReactHookFormExample {...args} />;
293
+ },
294
+ };
295
+
296
+ export const TestWithReactHookForm: StoryObj<typeof Radio> = {
297
+ render: ExampleWithReactHookForm.render,
298
+ play: async ({ canvasElement }) => {
299
+ const canvas = within(canvasElement);
300
+ await someTime(500);
301
+ await canvas.findByText("Debug selected:");
302
+ await expect(canvas.getByLabelText("Option 1")).not.toBeChecked();
303
+ await expect(canvas.getByLabelText("Option 2")).not.toBeChecked();
304
+ await fireEvent.click(canvas.getByLabelText("Option 1"));
305
+ await expect(canvas.getByLabelText("Option 1")).toBeChecked();
306
+ await expect(canvas.getByLabelText("Option 2")).not.toBeChecked();
307
+ await canvas.findByText("Debug selected: radio-id-1");
308
+ await fireEvent.click(canvas.getByLabelText("Option 2"));
309
+ await expect(canvas.getByLabelText("Option 1")).not.toBeChecked();
310
+ await expect(canvas.getByLabelText("Option 2")).toBeChecked();
311
+ await canvas.findByText("Debug selected: radio-id-2");
312
+ },
313
+ };
314
+
315
+ export const TestWithReactHookFormAndInitialValue: StoryObj<typeof Radio> = {
316
+ render: () =>
317
+ // @ts-ignore
318
+ ExampleWithReactHookForm.render({ initialSelected: "radio-id-1" }),
319
+ play: async ({ canvasElement }) => {
320
+ const canvas = within(canvasElement);
321
+ await someTime(500);
322
+ await await expect(canvas.getByLabelText("Option 1")).toBeChecked();
323
+ await expect(canvas.getByLabelText("Option 2")).not.toBeChecked();
324
+ await canvas.findByText("Debug selected: radio-id-1");
325
+ await fireEvent.click(canvas.getByLabelText("Option 2"));
326
+ await expect(canvas.getByLabelText("Option 1")).not.toBeChecked();
327
+ await expect(canvas.getByLabelText("Option 2")).toBeChecked();
328
+ await canvas.findByText("Debug selected: radio-id-2");
329
+ },
330
+ };
331
+ ```
332
+
333
+ ## Developer notes
334
+
335
+ Here are the notes available for the developer on the built Storybook, you can read them to understand the component and how to use it.
336
+
337
+ ```mdx
338
+ import {
339
+ Canvas,
340
+ Meta,
341
+ Stories,
342
+ Controls,
343
+ Source,
344
+ } from "@storybook/addon-docs/blocks";
345
+
346
+ import * as Radio from "./Radio.stories";
347
+ import * as RadioTests from "./tests/Radio.stories";
348
+
349
+ <Meta of={Radio} />
350
+
351
+ # Radio
352
+
353
+ Use this component exactly like an `<input type="radio">` but with an added `label` prop.
354
+
355
+ <Canvas of={Radio.WithLabel} />
356
+
357
+ ## Uncontrolled example (with react-hook-form)
358
+
359
+ <Source of={RadioTests.ExampleWithReactHookForm} type="code" dark />
360
+
361
+ ## Controlled example
362
+
363
+ <Source of={RadioTests.ExampleControlled} type="code" dark />
364
+
365
+ ### Radio props
366
+
367
+ <Controls of={Radio.WithLabel} />
368
+
369
+ <Stories />
370
+ ```
@@ -0,0 +1,64 @@
1
+ # RouterProvider
2
+
3
+ ## Props
4
+
5
+ The complete Props documentation with JS doc for this component is available at this path:
6
+
7
+ node_modules/@agregio-solutions/design-system/dist/packages/components/RouterProvider/RouterProvider.d.ts
8
+
9
+ ## Example usage
10
+
11
+ Here are the Storybook Stories.
12
+
13
+ Base stories:
14
+
15
+ ```tsx
16
+ import { Meta, StoryObj } from "@storybook/react-vite";
17
+ import RouterProvider from "./RouterProvider";
18
+
19
+ const meta: Meta<typeof RouterProvider> = {
20
+ component: RouterProvider,
21
+ parameters: {
22
+ layout: "centered",
23
+ chromatic: { disableSnapshot: true },
24
+ },
25
+ };
26
+ export default meta;
27
+
28
+ export const Default: StoryObj<typeof RouterProvider> = {
29
+ args: {
30
+ children: "demo",
31
+ },
32
+ };
33
+ ```
34
+
35
+ ## Developer notes
36
+
37
+ Here are the notes available for the developer on the built Storybook, you can read them to understand the component and how to use it.
38
+
39
+ ````mdx
40
+ import { Meta } from "@storybook/addon-docs/blocks";
41
+
42
+ import * as RouterProvider from "./RouterProvider.stories";
43
+
44
+ <Meta of={RouterProvider} />
45
+
46
+ # RouterProvider
47
+
48
+ This component should be used if :
49
+
50
+ - you use components from the Design System that handle links (like `Link`, `Tabs` or `Breadcrumbs`)
51
+ - you want to use the client side routing from your router (like `react-router-dom`)
52
+
53
+ The setup is simple, but differs from framework to framework.
54
+
55
+ Because the `RouterProvider` of the Design System is just a re-export of the React Aria once, we prefer to redirect you to the official doc for an up-to-date instructions with clean sections (instead of copy-pasting everything here).
56
+
57
+ **The only difference is that you will import `RouterProvider` from "@agregio-solutions/design-system" and not from "react-aria-components".**
58
+
59
+ ```tsx
60
+ import { RouterProvider } from "@agregio-solutions/design-system";
61
+ ```
62
+
63
+ Read and apply the setup depending on your framework in the React Aria docs : https://react-spectrum.adobe.com/react-aria/routing.html
64
+ ````