@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,638 @@
1
+ # YearMonthPicker
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/YearMonthPicker/YearMonthPicker.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 { expect, fn, screen, userEvent, within } from "storybook/test";
18
+ import YearMonthPicker, { YearMonthPickerValue } from "./YearMonthPicker";
19
+ import { I18nProvider } from "react-aria-components";
20
+ import { useState } from "react";
21
+
22
+ const meta: Meta<typeof YearMonthPicker> = {
23
+ component: YearMonthPicker,
24
+ parameters: {
25
+ layout: "centered",
26
+ },
27
+ args: {
28
+ onChange: fn(),
29
+ },
30
+ argTypes: {
31
+ label: { control: "text" },
32
+ value: { control: false },
33
+ description: { control: "text" },
34
+ helperText: { control: "text" },
35
+ errorHelperText: { control: "text" },
36
+ successHelperText: { control: "text" },
37
+ },
38
+ decorators: [
39
+ (Story) => (
40
+ <I18nProvider locale="en-EN">
41
+ <Story />
42
+ </I18nProvider>
43
+ ),
44
+ ],
45
+ };
46
+ export default meta;
47
+
48
+ type Story = StoryObj<typeof meta>;
49
+
50
+ export const PlaygroundMonth: Story = {
51
+ args: {
52
+ label: "Pick a month",
53
+ mode: "month",
54
+ required: true,
55
+ labelIconRight: "help_outline",
56
+ labelIconRightTooltip: "Additional information",
57
+ buttonProps: {
58
+ style: { width: 220 },
59
+ },
60
+ },
61
+ render: (args) => {
62
+ function Parent() {
63
+ const [value, setValue] = useState<YearMonthPickerValue>({
64
+ month: args.value?.month || null,
65
+ });
66
+
67
+ return (
68
+ <div>
69
+ <YearMonthPicker
70
+ {...args}
71
+ mode={args.mode}
72
+ value={value}
73
+ onChange={(value) => {
74
+ args.onChange?.(value);
75
+ setValue(value);
76
+ }}
77
+ />
78
+ </div>
79
+ );
80
+ }
81
+ return <Parent />;
82
+ },
83
+ };
84
+
85
+ export const PlaygroundYear: Story = {
86
+ args: {
87
+ label: "Pick a year",
88
+ mode: "year",
89
+ firstYear: 2020,
90
+ lastYear: 2025,
91
+ buttonProps: {
92
+ style: { width: 220 },
93
+ },
94
+ },
95
+ render: (args) => {
96
+ function Parent() {
97
+ const [value, setValue] = useState<YearMonthPickerValue>({
98
+ year: args.value?.year || null,
99
+ });
100
+
101
+ return (
102
+ <div>
103
+ <YearMonthPicker
104
+ {...args}
105
+ mode={args.mode}
106
+ value={value}
107
+ onChange={(value) => {
108
+ args.onChange?.(value);
109
+ setValue(value);
110
+ }}
111
+ />
112
+ </div>
113
+ );
114
+ }
115
+ return <Parent />;
116
+ },
117
+ };
118
+
119
+ export const PlaygroundYearAndMonth: Story = {
120
+ args: {
121
+ label: "Pick a month and year",
122
+ mode: "month-year",
123
+ firstYear: 2020,
124
+ lastYear: 2025,
125
+ buttonProps: {
126
+ style: { width: 220 },
127
+ },
128
+ },
129
+ render: (args) => {
130
+ function Parent() {
131
+ const [value, setValue] = useState<YearMonthPickerValue>({
132
+ year: args.value?.year || null,
133
+ month: args.value?.month || null,
134
+ });
135
+
136
+ return (
137
+ <div>
138
+ <YearMonthPicker
139
+ {...args}
140
+ mode={args.mode}
141
+ value={value}
142
+ onChange={(value) => {
143
+ args.onChange?.(value);
144
+ setValue(value);
145
+ }}
146
+ />
147
+ </div>
148
+ );
149
+ }
150
+ return <Parent />;
151
+ },
152
+ };
153
+
154
+ export const MonthWithInitialValue: Story = {
155
+ args: {
156
+ ...PlaygroundMonth.args,
157
+ value: {
158
+ month: "02",
159
+ },
160
+ },
161
+ play: async ({ canvasElement }) => {
162
+ const canvas = within(canvasElement);
163
+ await canvas.findByText("February");
164
+ },
165
+ };
166
+
167
+ export const YearWithInitialValue: Story = {
168
+ args: {
169
+ ...PlaygroundYear.args,
170
+ value: {
171
+ year: "2024",
172
+ },
173
+ },
174
+ play: async ({ canvasElement }) => {
175
+ const canvas = within(canvasElement);
176
+ await canvas.findByText("2024");
177
+ },
178
+ };
179
+
180
+ export const MonthAndYearWithInitialValue: Story = {
181
+ args: {
182
+ ...PlaygroundYearAndMonth.args,
183
+ value: {
184
+ month: "02",
185
+ year: "2024",
186
+ },
187
+ buttonProps: undefined,
188
+ },
189
+ play: async ({ canvasElement }) => {
190
+ const canvas = within(canvasElement);
191
+ await canvas.findByText("February 2024");
192
+ },
193
+ };
194
+
195
+ export const WithHelperText: Story = {
196
+ args: {
197
+ ...PlaygroundMonth.args,
198
+ helperText: "Some helper text",
199
+ helperTextIcon: "help_outline",
200
+ },
201
+ play: async ({ canvasElement }) => {
202
+ const canvas = within(canvasElement);
203
+ await canvas.findByText("Some helper text");
204
+ },
205
+ };
206
+
207
+ export const WithErrorHelperText: Story = {
208
+ args: {
209
+ ...PlaygroundMonth.args,
210
+ errorHelperText: "Some error helper text",
211
+ errorHelperTextIcon: "error_outline",
212
+ },
213
+ play: async ({ canvasElement }) => {
214
+ const canvas = within(canvasElement);
215
+ await canvas.findByText("Some error helper text");
216
+ },
217
+ };
218
+
219
+ export const WithSuccessHelperText: Story = {
220
+ args: {
221
+ ...PlaygroundMonth.args,
222
+ successHelperText: "Some success helper text",
223
+ successHelperTextIcon: "check",
224
+ },
225
+ };
226
+
227
+ export const WithWarningHelperText: Story = {
228
+ args: {
229
+ ...PlaygroundMonth.args,
230
+ warningHelperText: "Some warning helper text",
231
+ warningHelperTextIcon: "warning_amber",
232
+ },
233
+ };
234
+
235
+ export const WithLabelIconRight: Story = {
236
+ args: {
237
+ ...PlaygroundMonth.args,
238
+ labelIconRight: "help_outline",
239
+ },
240
+ };
241
+
242
+ export const WithCustomInputIcon: Story = {
243
+ args: {
244
+ ...PlaygroundMonth.args,
245
+ inputIcon: "help_outline",
246
+ },
247
+ };
248
+
249
+ export const Horizontal: Story = {
250
+ args: {
251
+ ...PlaygroundMonth.args,
252
+ orientation: "horizontal",
253
+ helperText: "Some helper text",
254
+ helperTextIcon: "help_outline",
255
+ },
256
+ };
257
+
258
+ export const FullWidth: Story = {
259
+ parameters: {
260
+ layout: "padded",
261
+ },
262
+ args: {
263
+ ...PlaygroundMonth.args,
264
+ buttonProps: undefined,
265
+ fullWidth: true,
266
+ },
267
+ };
268
+
269
+ export const Disabled: Story = {
270
+ args: {
271
+ ...PlaygroundMonth.args,
272
+ disabled: true,
273
+ },
274
+ };
275
+
276
+ export const DescendingYears: Story = {
277
+ args: {
278
+ ...PlaygroundYear.args,
279
+ sortYears: "descending",
280
+ },
281
+ };
282
+
283
+ export const WithTallDropdown: Story = {
284
+ args: {
285
+ ...PlaygroundYearAndMonth.args,
286
+ tallDropdown: true,
287
+ },
288
+ render: (args) => {
289
+ function Parent() {
290
+ const [value, setValue] = useState<YearMonthPickerValue>({
291
+ year: args.value?.year || null,
292
+ month: args.value?.month || null,
293
+ });
294
+
295
+ return (
296
+ <div>
297
+ <YearMonthPicker
298
+ {...args}
299
+ mode="month-year"
300
+ value={value}
301
+ onChange={(value) => {
302
+ args.onChange?.(value);
303
+ setValue(value);
304
+ }}
305
+ />
306
+ </div>
307
+ );
308
+ }
309
+ return <Parent />;
310
+ },
311
+ play: async ({ canvasElement }) => {
312
+ const canvas = within(canvasElement);
313
+ const user = userEvent.setup();
314
+ await user.click(canvas.getByLabelText("Open: Pick a month and year"));
315
+ const listbox = await screen.findByRole("listbox");
316
+ await expect(listbox).toHaveAttribute("data-tall", "true");
317
+ },
318
+ };
319
+ ```
320
+
321
+ ## How to test this component
322
+
323
+ Here are some more advanced stories with more testing coverage and examples that you can read to understand how to test this component.
324
+
325
+ ```tsx
326
+ import { Meta, StoryObj } from "@storybook/react-vite";
327
+ import { useState } from "react";
328
+ import { userEvent, within, screen, expect } from "storybook/test";
329
+ import YearMonthPicker, { YearMonthPickerValue } from "../YearMonthPicker";
330
+ import * as YearMonthPickerStories from "../YearMonthPicker.stories";
331
+
332
+ const meta: Meta<typeof YearMonthPicker> = {
333
+ ...YearMonthPickerStories.default,
334
+ component: YearMonthPicker,
335
+ parameters: {
336
+ ...YearMonthPickerStories.default.parameters,
337
+ chromatic: { disableSnapshot: true },
338
+ },
339
+ };
340
+ export default meta;
341
+
342
+ type Story = StoryObj<typeof meta>;
343
+
344
+ export const MonthShouldSelectAValue: Story = {
345
+ args: { ...YearMonthPickerStories.PlaygroundMonth.args },
346
+ // @ts-expect-error
347
+ render: (args) => YearMonthPickerStories.PlaygroundMonth.render(args),
348
+ play: async ({ canvasElement, args }) => {
349
+ const canvas = within(canvasElement);
350
+ const user = userEvent.setup({ delay: 50 });
351
+ await user.click(canvas.getByLabelText("Open: Pick a month"));
352
+ await user.click(await screen.findByText("January"));
353
+ await expect(args.onChange).toHaveBeenCalledWith({ month: "01" });
354
+ await expect(canvas.getByLabelText("Open: Pick a month")).toHaveTextContent(
355
+ "January",
356
+ );
357
+ },
358
+ };
359
+
360
+ export const MonthShouldChangeAnInitialValue: Story = {
361
+ args: {
362
+ ...YearMonthPickerStories.PlaygroundMonth.args,
363
+ value: { month: "02" },
364
+ },
365
+ // @ts-expect-error
366
+ render: (args) => YearMonthPickerStories.PlaygroundMonth.render(args),
367
+ play: async ({ canvasElement, args }) => {
368
+ const canvas = within(canvasElement);
369
+ const user = userEvent.setup({ delay: 50 });
370
+ await expect(canvas.getByLabelText("Open: Pick a month")).toHaveTextContent(
371
+ "February",
372
+ );
373
+ await user.click(canvas.getByLabelText("Open: Pick a month"));
374
+ await user.click(await screen.findByText("January"));
375
+ await expect(args.onChange).toHaveBeenCalledWith({ month: "01" });
376
+ await expect(canvas.getByLabelText("Open: Pick a month")).toHaveTextContent(
377
+ "January",
378
+ );
379
+ },
380
+ };
381
+
382
+ export const YearShouldSelectAValue: Story = {
383
+ args: { ...YearMonthPickerStories.PlaygroundYear.args },
384
+ // @ts-expect-error
385
+ render: (args) => YearMonthPickerStories.PlaygroundYear.render(args),
386
+ play: async ({ canvasElement, args }) => {
387
+ const canvas = within(canvasElement);
388
+ const user = userEvent.setup({ delay: 50 });
389
+ await user.click(canvas.getByLabelText("Open: Pick a year"));
390
+ await user.click(await screen.findByText("2023"));
391
+ await expect(args.onChange).toHaveBeenCalledWith({ year: "2023" });
392
+ await expect(canvas.getByLabelText("Open: Pick a year")).toHaveTextContent(
393
+ "2023",
394
+ );
395
+ },
396
+ };
397
+
398
+ export const YearShouldChangeAnInitialValue: Story = {
399
+ args: {
400
+ ...YearMonthPickerStories.PlaygroundYear.args,
401
+ value: { year: "2024" },
402
+ },
403
+ // @ts-expect-error
404
+ render: (args) => YearMonthPickerStories.PlaygroundYear.render(args),
405
+ play: async ({ canvasElement, args }) => {
406
+ const canvas = within(canvasElement);
407
+ const user = userEvent.setup({ delay: 50 });
408
+ await expect(canvas.getByLabelText("Open: Pick a year")).toHaveTextContent(
409
+ "2024",
410
+ );
411
+ await user.click(canvas.getByLabelText("Open: Pick a year"));
412
+ await user.click(await screen.findByText("2023"));
413
+ await expect(args.onChange).toHaveBeenCalledWith({ year: "2023" });
414
+ await expect(canvas.getByLabelText("Open: Pick a year")).toHaveTextContent(
415
+ "2023",
416
+ );
417
+ },
418
+ };
419
+
420
+ export const MonthAndYearShouldSelectAValue: Story = {
421
+ args: { ...YearMonthPickerStories.PlaygroundYearAndMonth.args },
422
+ // @ts-expect-error
423
+ render: (args) => YearMonthPickerStories.PlaygroundYearAndMonth.render(args),
424
+ play: async ({ canvasElement, args }) => {
425
+ const canvas = within(canvasElement);
426
+ const user = userEvent.setup({ delay: 50 });
427
+ await user.click(canvas.getByLabelText("Open: Pick a month and year"));
428
+ await user.click(await screen.findByText("February"));
429
+ await expect(args.onChange).toHaveBeenCalledWith({
430
+ month: "02",
431
+ year: null,
432
+ });
433
+ await expect(
434
+ canvas.getByLabelText("Open: Pick a month and year"),
435
+ ).toHaveTextContent("February");
436
+ await user.click(await screen.findByText("2023"));
437
+ await expect(args.onChange).toHaveBeenCalledWith({
438
+ month: "02",
439
+ year: "2023",
440
+ });
441
+ await expect(
442
+ canvas.getByLabelText("Open: Pick a month and year"),
443
+ ).toHaveTextContent("February");
444
+ await expect(
445
+ canvas.getByLabelText("Open: Pick a month and year"),
446
+ ).toHaveTextContent("2023");
447
+ },
448
+ };
449
+
450
+ export const MonthAndYearShouldChangeAnInitialValue: Story = {
451
+ args: {
452
+ ...YearMonthPickerStories.PlaygroundYearAndMonth.args,
453
+ value: { month: "02", year: "2023" },
454
+ },
455
+ // @ts-expect-error
456
+ render: (args) => YearMonthPickerStories.PlaygroundYearAndMonth.render(args),
457
+ play: async ({ canvasElement, args }) => {
458
+ const canvas = within(canvasElement);
459
+ const user = userEvent.setup({ delay: 50 });
460
+ await canvas.findByText("February 2023");
461
+ await user.click(canvas.getByLabelText("Open: Pick a month and year"));
462
+ await user.click(await screen.findByText("March"));
463
+ await expect(args.onChange).toHaveBeenCalledWith({
464
+ month: "03",
465
+ year: "2023",
466
+ });
467
+ await expect(
468
+ canvas.getByLabelText("Open: Pick a month and year"),
469
+ ).toHaveTextContent("March 2023");
470
+ await expect(
471
+ canvas.getByLabelText("Open: Pick a month and year"),
472
+ ).toHaveTextContent("2023");
473
+ await user.click(await screen.findByText("2022"));
474
+ await expect(args.onChange).toHaveBeenCalledWith({
475
+ month: "03",
476
+ year: "2022",
477
+ });
478
+ await expect(
479
+ canvas.getByLabelText("Open: Pick a month and year"),
480
+ ).toHaveTextContent("March");
481
+ await expect(
482
+ canvas.getByLabelText("Open: Pick a month and year"),
483
+ ).toHaveTextContent("2022");
484
+ },
485
+ };
486
+
487
+ export const ShouldAllowReSelectingTheSameValue: Story = {
488
+ args: {
489
+ ...YearMonthPickerStories.PlaygroundYearAndMonth.args,
490
+ value: { month: "02", year: "2023" },
491
+ },
492
+ // @ts-expect-error
493
+ render: (args) => YearMonthPickerStories.PlaygroundYearAndMonth.render(args),
494
+ play: async ({ canvasElement, args }) => {
495
+ const canvas = within(canvasElement);
496
+ const user = userEvent.setup({ delay: 50 });
497
+ await canvas.findByText("February 2023");
498
+ await user.click(canvas.getByLabelText("Open: Pick a month and year"));
499
+ await user.click(await screen.findByText("February", { selector: "span" }));
500
+ await expect(args.onChange).not.toHaveBeenCalled();
501
+ await expect(
502
+ canvas.getByLabelText("Open: Pick a month and year"),
503
+ ).toHaveTextContent("February");
504
+ await expect(
505
+ canvas.getByLabelText("Open: Pick a month and year"),
506
+ ).toHaveTextContent("2023");
507
+ await user.click(await screen.findByText("2023"));
508
+ await expect(args.onChange).not.toHaveBeenCalled();
509
+ await expect(
510
+ canvas.getByLabelText("Open: Pick a month and year"),
511
+ ).toHaveTextContent("February 2023");
512
+ },
513
+ };
514
+
515
+ export const ExampleUsageMonthMode: Story = {
516
+ render: () => {
517
+ function Parent() {
518
+ const [value, setValue] = useState<YearMonthPickerValue>({
519
+ month: null,
520
+ });
521
+
522
+ return (
523
+ <YearMonthPicker
524
+ label="Pick a month"
525
+ mode="month"
526
+ value={value}
527
+ onChange={setValue}
528
+ />
529
+ );
530
+ }
531
+ return <Parent />;
532
+ },
533
+ };
534
+
535
+ export const ExampleUsageYearMode: Story = {
536
+ render: () => {
537
+ function Parent() {
538
+ const [value, setValue] = useState<YearMonthPickerValue>({
539
+ year: null,
540
+ });
541
+
542
+ return (
543
+ <YearMonthPicker
544
+ label="Pick a year"
545
+ mode="year"
546
+ value={value}
547
+ onChange={setValue}
548
+ />
549
+ );
550
+ }
551
+ return <Parent />;
552
+ },
553
+ };
554
+
555
+ export const ExampleUsageYearAndMonthMode: Story = {
556
+ render: () => {
557
+ function Parent() {
558
+ const [value, setValue] = useState<YearMonthPickerValue>({
559
+ year: null,
560
+ month: null,
561
+ });
562
+
563
+ return (
564
+ <YearMonthPicker
565
+ label="Pick a month and year"
566
+ mode="month-year"
567
+ value={value}
568
+ onChange={setValue}
569
+ />
570
+ );
571
+ }
572
+ return <Parent />;
573
+ },
574
+ };
575
+ ```
576
+
577
+ ## Developer notes
578
+
579
+ 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.
580
+
581
+ ```mdx
582
+ import {
583
+ Canvas,
584
+ Meta,
585
+ Stories,
586
+ Controls,
587
+ Source,
588
+ } from "@storybook/addon-docs/blocks";
589
+
590
+ import * as YearMonthPicker from "./YearMonthPicker.stories";
591
+ import * as YearMonthPickerTests from "./tests/YearMonthPicker.stories";
592
+
593
+ <Meta of={YearMonthPicker} />
594
+
595
+ # YearMonthPicker
596
+
597
+ The YearMonthPicker component allows users to pick a month, a year, or both!
598
+
599
+ This component **should always be controlled** with the `value` and `onChange` props.
600
+
601
+ ## Example usage -> Month mode
602
+
603
+ <Source of={YearMonthPickerTests.ExampleUsageMonthMode} type="code" dark />
604
+
605
+ ## Example usage -> Year mode
606
+
607
+ <Source of={YearMonthPickerTests.ExampleUsageYearMode} type="code" dark />
608
+
609
+ ## Example usage -> Month and Year mode
610
+
611
+ <Source
612
+ of={YearMonthPickerTests.ExampleUsageYearAndMonthMode}
613
+ type="code"
614
+ dark
615
+ />
616
+
617
+ ## Usage with react-hook-form
618
+
619
+ The usage is the same, you just need to use a `Controller` component (or `useController`) to control the file upload because it does not work on uncontrolled mode.
620
+
621
+ ## How to test this component
622
+
623
+ 1. Open the picker with the trigger button, which have an aria-label that says "Open: \{label prop\}". (for example "Open: Pick a month")
624
+ 2. Click on a value (using `screen` from testing library because the value is inside a dialog)
625
+ 3. Assert that the correct value was selected
626
+
627
+ Here is an example code of how to test the component:
628
+
629
+ <Source of={YearMonthPickerTests.MonthShouldSelectAValue} type="code" dark />
630
+
631
+ ## Playground & Props
632
+
633
+ <Canvas of={YearMonthPicker.PlaygroundYearAndMonth} />
634
+
635
+ <Controls of={YearMonthPicker.PlaygroundYearAndMonth} />
636
+
637
+ <Stories />
638
+ ```