@invoiceonline/ui-react 0.1.0 → 0.2.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/AGENTS.md +4 -3
- package/CHANGELOG.md +18 -0
- package/dist/components/date-picker/DatePicker.js +1 -1
- package/dist/components/field/Field.d.ts +2 -1
- package/dist/components/field/Field.js +13 -8
- package/dist/components/field-pair/FieldPair.d.ts +29 -13
- package/dist/components/field-pair/FieldPair.js +20 -6
- package/dist/components/text-field/TextField.d.ts +97 -2
- package/dist/components/text-field/TextField.js +76 -5
- package/dist/components/text-field/index.d.ts +2 -2
- package/dist/components/textarea/Textarea.js +1 -1
- package/dist/components/unit-field/UnitField.js +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.js +2 -3
- package/dist/internal/useDateFieldTrigger.d.ts +60 -0
- package/dist/internal/useDateFieldTrigger.js +68 -16
- package/dist/internal/useFormReset.js +10 -3
- package/docs/Consuming.mdx +20 -3
- package/llms.txt +7 -13
- package/package.json +1 -5
- package/src/components/date-picker/DatePicker.mdx +18 -14
- package/src/components/date-picker/DatePicker.stories.tsx +1 -1
- package/src/components/field/Field.tsx +40 -18
- package/src/components/field-pair/FieldPair.mdx +13 -9
- package/src/components/field-pair/FieldPair.stories.tsx +11 -2
- package/src/components/field-pair/FieldPair.tsx +76 -27
- package/src/components/filter-facet/FilterFacet.tsx +1 -1
- package/src/components/subject-lookup-field/SubjectLookupField.tsx +3 -3
- package/src/components/text-field/TextField.mdx +258 -38
- package/src/components/text-field/TextField.stories.tsx +311 -3
- package/src/components/text-field/TextField.tsx +259 -5
- package/src/components/text-field/index.ts +3 -0
- package/src/components/textarea/Textarea.mdx +2 -2
- package/src/components/textarea/Textarea.tsx +1 -1
- package/src/components/unit-field/UnitField.mdx +1 -1
- package/src/components/unit-field/UnitField.tsx +1 -1
- package/src/index.ts +0 -1
- package/src/internal/useDateFieldTrigger.tsx +178 -38
- package/src/internal/useFormReset.ts +13 -3
- package/src/recipes/Form.stories.tsx +5 -0
- package/dist/components/date-field/DateField.d.ts +0 -52
- package/dist/components/date-field/DateField.js +0 -45
- package/dist/components/date-field/index.d.ts +0 -2
- package/dist/components/date-field/index.js +0 -1
- package/src/components/date-field/DateField.mdx +0 -340
- package/src/components/date-field/DateField.stories.tsx +0 -221
- package/src/components/date-field/DateField.tsx +0 -176
- package/src/components/date-field/index.ts +0 -1
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
3
|
import type { ReactNode } from 'react';
|
|
4
|
+
import { expect, userEvent, waitFor, within } from 'storybook/test';
|
|
5
|
+
import { cs } from 'date-fns/locale/cs';
|
|
6
|
+
import { enUS } from 'date-fns/locale/en-US';
|
|
7
|
+
import { nl } from 'date-fns/locale/nl';
|
|
3
8
|
import { TextField } from './TextField';
|
|
4
9
|
import { Field } from '../field/Field';
|
|
5
|
-
import type { TextFieldBaseProps } from './TextField';
|
|
10
|
+
import type { TextFieldBaseProps, TextFieldInputType } from './TextField';
|
|
6
11
|
import { Section, Showcase } from '../../storybook/Section';
|
|
7
12
|
import { componentDoc } from '../../storybook/componentDoc';
|
|
8
13
|
import { FORCE_ERROR_FOCUS, FieldErrorFocusStyles } from '../../storybook/forceStates';
|
|
@@ -15,6 +20,8 @@ type TextFieldStoryArgs = TextFieldBaseProps;
|
|
|
15
20
|
|
|
16
21
|
const SIZES = ['md', 'sm'] as const;
|
|
17
22
|
const STATES = ['default', 'focused', 'error', 'success', 'disabled', 'readonly'] as const;
|
|
23
|
+
// The plain field's types (manifest delivery.react); `date` has its own stories.
|
|
24
|
+
const TYPES = ['text', 'email', 'tel', 'url', 'search', 'password', 'numeric'] as const satisfies readonly TextFieldInputType[];
|
|
18
25
|
// Manifest `axes.content` — Figma calls it "Has value" (True/False). It is not a
|
|
19
26
|
// prop: content IS the presence of a value, so each cell is described by the
|
|
20
27
|
// props it renders with (`placeholder` for Empty, `defaultValue` for Filled).
|
|
@@ -27,6 +34,26 @@ const LABEL = 'Název firmy';
|
|
|
27
34
|
const SEARCH_LABEL = 'Hledat';
|
|
28
35
|
const PASSWORD_LABEL = 'Heslo';
|
|
29
36
|
|
|
37
|
+
// type="date": the market's format + locale, the calendar dialog name and its four
|
|
38
|
+
// chevron names are all required — the field is market-agnostic and the consumer
|
|
39
|
+
// owns them. Storybook is the consumer here, Czech by default. The interactive Date
|
|
40
|
+
// demos start on today's date — a designer should see today's calendar; the static
|
|
41
|
+
// matrix and the open-panel story pin one, so their render does not change by day.
|
|
42
|
+
const today = new Date();
|
|
43
|
+
const FIXED_DATE = new Date(2026, 3, 15);
|
|
44
|
+
const DATE_LABEL = 'Datum vystavení';
|
|
45
|
+
const DATE_CS = {
|
|
46
|
+
dateFormat: 'dd. MM. yyyy',
|
|
47
|
+
locale: cs,
|
|
48
|
+
panelLabel: 'Kalendář',
|
|
49
|
+
navLabels: {
|
|
50
|
+
previousMonth: 'Předchozí měsíc',
|
|
51
|
+
nextMonth: 'Další měsíc',
|
|
52
|
+
previousYear: 'Předchozí rok',
|
|
53
|
+
nextYear: 'Další rok',
|
|
54
|
+
},
|
|
55
|
+
} as const;
|
|
56
|
+
|
|
30
57
|
const Frame = ({ children }: { children: ReactNode }) => (
|
|
31
58
|
<div className="w-[calc(var(--space-1200)*4)]">{children}</div>
|
|
32
59
|
);
|
|
@@ -48,13 +75,14 @@ const meta = {
|
|
|
48
75
|
'`leadingIcon="magnifying-glass"` — filter / search fields (usually placeholder-only)',
|
|
49
76
|
'`trailingIcon` + `onTrailingIconClick` — clear or password-reveal affordance',
|
|
50
77
|
'`state="readonly"` — a value the user can see and copy but not edit here',
|
|
78
|
+
'`type="date"` — a typeable date with the DS calendar: a `Date` in `value`, out through `onValueChange`; the market\'s `dateFormat` + `locale` are required (no Czech default), as are `panelLabel` / `navLabels`',
|
|
51
79
|
],
|
|
52
80
|
bestPractices: [
|
|
53
81
|
'Always wrap in `Field` and give the input an `id` — the floating `<label>` is the accessible name, never the placeholder',
|
|
54
82
|
'Use `state="readonly"` (native `readonly`) for locked values, never `disabled` — read-only stays copyable and in the tab order',
|
|
55
83
|
'Write specific, impersonal errors ("IČO musí mít 8 číslic"), not "Neplatná hodnota"',
|
|
56
84
|
'Pair `state="error"` with a matching `error` message on the `Field`',
|
|
57
|
-
'Reach for the right component — Select for a fixed set, Textarea for multi-line,
|
|
85
|
+
'Reach for the right component — Select for a fixed set, Textarea for multi-line; a date is `type="date"` here, never a separate field',
|
|
58
86
|
],
|
|
59
87
|
knownIssues: [
|
|
60
88
|
'Error uses `warning-circle`, Success uses `check` (not the spec `check-circle`) in the trailing slot',
|
|
@@ -72,17 +100,27 @@ type Story = StoryObj<TextFieldStoryArgs>;
|
|
|
72
100
|
|
|
73
101
|
export const Playground: Story = {
|
|
74
102
|
args: {
|
|
103
|
+
type: 'text',
|
|
75
104
|
placeholder: 'Value',
|
|
76
105
|
size: 'md',
|
|
77
106
|
state: 'default',
|
|
78
107
|
},
|
|
79
108
|
argTypes: {
|
|
109
|
+
type: { control: 'select', options: TYPES },
|
|
80
110
|
size: { control: 'select', options: SIZES },
|
|
81
111
|
state: { control: 'select', options: STATES },
|
|
82
112
|
placeholder: { control: 'text' },
|
|
83
113
|
leadingIcon: { control: 'text' },
|
|
84
114
|
trailingIcon: { control: 'text' },
|
|
85
115
|
},
|
|
116
|
+
parameters: {
|
|
117
|
+
docs: {
|
|
118
|
+
description: {
|
|
119
|
+
story:
|
|
120
|
+
'The plain field — `type` covers text / email / tel / url / search / password / numeric (a right-aligned text input with the numeric keyboard). `type="date"` is not in the control: it swaps the value to a `Date` and requires `dateFormat`, `locale` and `navLabels`, so it has its own Playground (Date — Playground) and stories (Date, Date — Open, Date — Matrix).',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
86
124
|
/*
|
|
87
125
|
* Wrapped in `Field`, which is how the component actually ships: the floating
|
|
88
126
|
* label is the real <label> and is what gives the input its accessible name
|
|
@@ -116,7 +154,7 @@ export const Matrix: Story = {
|
|
|
116
154
|
docs: {
|
|
117
155
|
description: {
|
|
118
156
|
story:
|
|
119
|
-
'Full state × size matrix — mirrors the Figma labelled grid. Rows = states, columns = sizes. Error/Success carry the trailing status icon; Disabled and Read-only
|
|
157
|
+
'Full state × size matrix — mirrors the Figma labelled grid. Rows = states, columns = sizes. Error/Success carry the trailing status icon; Disabled and Read-only keep the `--outline-default` border — Disabled on the `--disabled-background` fill with all ink dimmed, Read-only on the `--bg-readonly` fill with the value at full contrast (`--text-primary`).',
|
|
120
158
|
},
|
|
121
159
|
},
|
|
122
160
|
},
|
|
@@ -364,3 +402,273 @@ export const Motion: Story = {
|
|
|
364
402
|
</Showcase>
|
|
365
403
|
),
|
|
366
404
|
};
|
|
405
|
+
|
|
406
|
+
// Stateful demos live in named components: a hook called straight inside a story's
|
|
407
|
+
// `render` breaks rules-of-hooks (repo convention — see ActionRow).
|
|
408
|
+
function DateDemo() {
|
|
409
|
+
const [value, setValue] = React.useState<Date | undefined>(today);
|
|
410
|
+
return (
|
|
411
|
+
<Frame>
|
|
412
|
+
<Field label={DATE_LABEL} helperText="Formát DD. MM. RRRR">
|
|
413
|
+
<TextField
|
|
414
|
+
type="date"
|
|
415
|
+
id="date-cs"
|
|
416
|
+
{...DATE_CS}
|
|
417
|
+
value={value}
|
|
418
|
+
onValueChange={setValue}
|
|
419
|
+
placeholder="DD. MM. RRRR"
|
|
420
|
+
/>
|
|
421
|
+
</Field>
|
|
422
|
+
</Frame>
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function DateOtherMarketDemo() {
|
|
427
|
+
const [value, setValue] = React.useState<Date | undefined>(today);
|
|
428
|
+
return (
|
|
429
|
+
<Frame>
|
|
430
|
+
<Field label="Issue date" helperText="Format MM/DD/YYYY">
|
|
431
|
+
<TextField
|
|
432
|
+
type="date"
|
|
433
|
+
id="date-en-us"
|
|
434
|
+
dateFormat="MM/dd/yyyy"
|
|
435
|
+
locale={enUS}
|
|
436
|
+
panelLabel="Calendar"
|
|
437
|
+
navLabels={{
|
|
438
|
+
previousMonth: 'Previous month',
|
|
439
|
+
nextMonth: 'Next month',
|
|
440
|
+
previousYear: 'Previous year',
|
|
441
|
+
nextYear: 'Next year',
|
|
442
|
+
}}
|
|
443
|
+
value={value}
|
|
444
|
+
onValueChange={setValue}
|
|
445
|
+
placeholder="MM/DD/YYYY"
|
|
446
|
+
/>
|
|
447
|
+
</Field>
|
|
448
|
+
</Frame>
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export const DateMode: Story = {
|
|
453
|
+
name: 'Date',
|
|
454
|
+
parameters: {
|
|
455
|
+
docs: {
|
|
456
|
+
description: {
|
|
457
|
+
story:
|
|
458
|
+
'`type="date"` — a date field is this component, not a separate one. The input stays a typeable text input (never the native date input); the leading slot carries the decorative `calendar-dots` glyph, and a click anywhere on the field opens the Single month Date Picker (ArrowDown from the keyboard moves into the grid, Esc closes and returns focus). The value is a `Date`; a typed draft is parsed in the market\'s `dateFormat` on commit (blur or Enter); one that does not parse or falls outside `minDate` / `maxDate` stays in the input and the value becomes `undefined` (see «Date — Invalid typed date»). Czech market here: `dd. MM. yyyy` + `cs`; the helper line states the format, because a placeholder disappears as soon as the user types. Inside a labelled `Field` the calendar dialog is named by that label (`aria-labelledby`); `panelLabel` is only the fallback for a field nothing visible names.',
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
render: () => <DateDemo />,
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
export const DateOtherMarket: Story = {
|
|
466
|
+
name: 'Date (another market)',
|
|
467
|
+
parameters: {
|
|
468
|
+
docs: {
|
|
469
|
+
description: {
|
|
470
|
+
story:
|
|
471
|
+
'The same field for the US market: `dateFormat="MM/dd/yyyy"` + `locale={enUS}` — the text is shown and parsed as `MM/DD/YYYY`, and the calendar starts its week on Sunday with English month and weekday names. The format and locale always come from the consumer\'s market config; the field never assumes Czech. Every text — label, helper, placeholder, the dialog and chevron names — is in the market\'s language too.',
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
render: () => <DateOtherMarketDemo />,
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
const DATE_LOCALES = { cs, enUS, nl } as const;
|
|
479
|
+
|
|
480
|
+
type DatePlaygroundArgs = {
|
|
481
|
+
dateFormat: string;
|
|
482
|
+
locale: keyof typeof DATE_LOCALES;
|
|
483
|
+
minDate?: number;
|
|
484
|
+
maxDate?: number;
|
|
485
|
+
panelLabel?: string;
|
|
486
|
+
navLabels: typeof DATE_CS.navLabels;
|
|
487
|
+
placeholder?: string;
|
|
488
|
+
size: (typeof SIZES)[number];
|
|
489
|
+
state: (typeof STATES)[number];
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
/*
|
|
493
|
+
* The date-mode props, each on a control. `minDate` / `maxDate` come from
|
|
494
|
+
* Storybook's date control as timestamps and are turned back into `Date`s; the
|
|
495
|
+
* locale control maps a name onto the date-fns Locale object.
|
|
496
|
+
*/
|
|
497
|
+
export const DatePlayground: StoryObj<DatePlaygroundArgs> = {
|
|
498
|
+
name: 'Date — Playground',
|
|
499
|
+
args: {
|
|
500
|
+
dateFormat: DATE_CS.dateFormat,
|
|
501
|
+
locale: 'cs',
|
|
502
|
+
panelLabel: DATE_CS.panelLabel,
|
|
503
|
+
navLabels: DATE_CS.navLabels,
|
|
504
|
+
placeholder: 'DD. MM. RRRR',
|
|
505
|
+
size: 'md',
|
|
506
|
+
state: 'default',
|
|
507
|
+
},
|
|
508
|
+
argTypes: {
|
|
509
|
+
dateFormat: { control: 'text' },
|
|
510
|
+
locale: { control: 'select', options: Object.keys(DATE_LOCALES) },
|
|
511
|
+
minDate: { control: 'date' },
|
|
512
|
+
maxDate: { control: 'date' },
|
|
513
|
+
panelLabel: { control: 'text' },
|
|
514
|
+
navLabels: { control: 'object' },
|
|
515
|
+
placeholder: { control: 'text' },
|
|
516
|
+
size: { control: 'select', options: SIZES },
|
|
517
|
+
state: { control: 'select', options: STATES },
|
|
518
|
+
},
|
|
519
|
+
parameters: {
|
|
520
|
+
docs: {
|
|
521
|
+
description: {
|
|
522
|
+
story:
|
|
523
|
+
'`type="date"` with every date-mode prop on a control. Change `dateFormat` and `locale` together — they are one market. Inside the labelled `Field` the calendar dialog takes the label as its name, so `panelLabel` is read only by a field nothing visible names.',
|
|
524
|
+
},
|
|
525
|
+
},
|
|
526
|
+
},
|
|
527
|
+
render: function DatePlaygroundRender({ minDate, maxDate, locale, ...args }) {
|
|
528
|
+
const [value, setValue] = React.useState<Date | undefined>();
|
|
529
|
+
return (
|
|
530
|
+
<Frame>
|
|
531
|
+
<Field label={DATE_LABEL}>
|
|
532
|
+
<TextField
|
|
533
|
+
{...args}
|
|
534
|
+
type="date"
|
|
535
|
+
id="date-playground"
|
|
536
|
+
locale={DATE_LOCALES[locale]}
|
|
537
|
+
minDate={minDate === undefined ? undefined : new Date(minDate)}
|
|
538
|
+
maxDate={maxDate === undefined ? undefined : new Date(maxDate)}
|
|
539
|
+
value={value}
|
|
540
|
+
onValueChange={setValue}
|
|
541
|
+
/>
|
|
542
|
+
</Field>
|
|
543
|
+
</Frame>
|
|
544
|
+
);
|
|
545
|
+
},
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
export const DateMatrix: Story = {
|
|
549
|
+
name: 'Date — Matrix',
|
|
550
|
+
parameters: {
|
|
551
|
+
docs: {
|
|
552
|
+
description: {
|
|
553
|
+
story:
|
|
554
|
+
'`type="date"` across state × size. Read-only keeps the calendar glyph as a quiet marker (`--icon-muted`) but never opens the panel; Disabled keeps the `--outline-default` border on the `--disabled-background` fill and dims all ink.',
|
|
555
|
+
},
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
render: () => (
|
|
559
|
+
<Showcase>
|
|
560
|
+
{STATES.map(state => (
|
|
561
|
+
<Section key={state} title={state} layout="row">
|
|
562
|
+
{SIZES.map(size => (
|
|
563
|
+
<div key={size} className="w-[calc(var(--space-1200)*5)]">
|
|
564
|
+
<TextField
|
|
565
|
+
type="date"
|
|
566
|
+
aria-label={DATE_LABEL}
|
|
567
|
+
{...DATE_CS}
|
|
568
|
+
state={state}
|
|
569
|
+
size={size}
|
|
570
|
+
value={FIXED_DATE}
|
|
571
|
+
/>
|
|
572
|
+
</div>
|
|
573
|
+
))}
|
|
574
|
+
</Section>
|
|
575
|
+
))}
|
|
576
|
+
</Showcase>
|
|
577
|
+
),
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
function DateOpenDemo() {
|
|
581
|
+
const [value, setValue] = React.useState<Date | undefined>(FIXED_DATE);
|
|
582
|
+
return (
|
|
583
|
+
<Frame>
|
|
584
|
+
<Field label={DATE_LABEL} helperText="Formát DD. MM. RRRR">
|
|
585
|
+
<TextField
|
|
586
|
+
type="date"
|
|
587
|
+
id="date-open"
|
|
588
|
+
{...DATE_CS}
|
|
589
|
+
value={value}
|
|
590
|
+
onValueChange={setValue}
|
|
591
|
+
placeholder="DD. MM. RRRR"
|
|
592
|
+
/>
|
|
593
|
+
</Field>
|
|
594
|
+
</Frame>
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
export const DateOpen: Story = {
|
|
599
|
+
name: 'Date — Open',
|
|
600
|
+
parameters: {
|
|
601
|
+
docs: {
|
|
602
|
+
description: {
|
|
603
|
+
story:
|
|
604
|
+
'The calendar open from the keyboard: focus the field and press ArrowDown — the Single month Date Picker opens in its Popover host and focus lands on the selected day. The dialog is named by the field\'s label through `aria-labelledby`, and the input points at it with `aria-controls` while it is open. The story test runs the accessibility audit on this open state.',
|
|
605
|
+
},
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
render: () => <DateOpenDemo />,
|
|
609
|
+
play: async ({ canvasElement }) => {
|
|
610
|
+
const canvas = within(canvasElement);
|
|
611
|
+
const input = canvas.getByRole('combobox', { name: DATE_LABEL });
|
|
612
|
+
input.focus();
|
|
613
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
614
|
+
|
|
615
|
+
// The panel is portalled out of the canvas.
|
|
616
|
+
const body = within(canvasElement.ownerDocument.body);
|
|
617
|
+
const dialog = await body.findByRole('dialog', { name: DATE_LABEL });
|
|
618
|
+
await expect(input).toHaveAttribute('aria-expanded', 'true');
|
|
619
|
+
await expect(input).toHaveAttribute('aria-controls', dialog.id);
|
|
620
|
+
await waitFor(() =>
|
|
621
|
+
expect(within(dialog).getByRole('button', { name: '15. dubna 2026' })).toHaveFocus(),
|
|
622
|
+
);
|
|
623
|
+
},
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
const DATE_INVALID_ERROR = 'Neplatné datum — formát DD. MM. RRRR';
|
|
627
|
+
|
|
628
|
+
function DateInvalidDemo() {
|
|
629
|
+
const [value, setValue] = React.useState<Date | undefined>(today);
|
|
630
|
+
const [error, setError] = React.useState<string>();
|
|
631
|
+
return (
|
|
632
|
+
<Frame>
|
|
633
|
+
<Field label={DATE_LABEL} helperText="Formát DD. MM. RRRR" error={error}>
|
|
634
|
+
<TextField
|
|
635
|
+
type="date"
|
|
636
|
+
id="date-invalid"
|
|
637
|
+
{...DATE_CS}
|
|
638
|
+
state={error ? 'error' : undefined}
|
|
639
|
+
value={value}
|
|
640
|
+
onValueChange={(next) => {
|
|
641
|
+
setError(undefined);
|
|
642
|
+
setValue(next);
|
|
643
|
+
}}
|
|
644
|
+
onInvalidInput={() => setError(DATE_INVALID_ERROR)}
|
|
645
|
+
placeholder="DD. MM. RRRR"
|
|
646
|
+
/>
|
|
647
|
+
</Field>
|
|
648
|
+
</Frame>
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
export const DateInvalid: Story = {
|
|
653
|
+
name: 'Date — Invalid typed date',
|
|
654
|
+
parameters: {
|
|
655
|
+
docs: {
|
|
656
|
+
description: {
|
|
657
|
+
story:
|
|
658
|
+
'A typed date that does not parse (or falls outside `minDate` / `maxDate`) stays in the input after commit (blur or Enter); it is never swapped back for the old date. The value becomes `undefined` (`onValueChange` first), then `onInvalidInput` tells the form why, and the form shows Error with the Copy pattern next to the text the user typed. The story test types `32. 13. 2026` and leaves with Tab.',
|
|
659
|
+
},
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
render: () => <DateInvalidDemo />,
|
|
663
|
+
play: async ({ canvasElement }) => {
|
|
664
|
+
const canvas = within(canvasElement);
|
|
665
|
+
const input = canvas.getByRole('combobox', { name: DATE_LABEL });
|
|
666
|
+
await userEvent.clear(input);
|
|
667
|
+
await userEvent.type(input, '32. 13. 2026');
|
|
668
|
+
await userEvent.tab();
|
|
669
|
+
|
|
670
|
+
await expect(input).toHaveValue('32. 13. 2026');
|
|
671
|
+
await expect(input).toHaveAttribute('aria-invalid', 'true');
|
|
672
|
+
await expect(await canvas.findByText(DATE_INVALID_ERROR)).toBeInTheDocument();
|
|
673
|
+
},
|
|
674
|
+
};
|