@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
|
@@ -9,21 +9,25 @@ import * as TextFieldStories from './TextField.stories';
|
|
|
9
9
|
## Metadata
|
|
10
10
|
|
|
11
11
|
- **Layer:** atom
|
|
12
|
-
- **Status:**
|
|
13
|
-
|
|
12
|
+
- **Status:** draft — the `type="date"` mode built against manifest 2.15.0 has no recorded design
|
|
13
|
+
acceptance yet; the page returns to `stable` once it does.
|
|
14
|
+
- **Manifest version:** `2.15.0`
|
|
14
15
|
- **Tokens used:** `--bg-primary`, `--bg-readonly`, `--border-width-100`, `--border-width-200`, `--disabled-background`, `--disabled-foreground`, `--font-body`, `--font-size-base`, `--font-size-heading-h5`, `--font-size-sm`, `--font-size-xs`, `--font-size-xxs`, `--font-weight-bold`, `--font-weight-normal`, `--icon-muted`, `--leading-loose`, `--leading-relaxed`, `--outline-default`, `--outline-focus`, `--outline-strong`, `--radius-200`, `--radius-400`, `--size-icon`, `--size-icon-small`, `--space-1000`, `--space-1100`, `--space-200`, `--space-300`, `--space-400`, `--space-500`, `--space-700`, `--space-800`, `--status-danger`, `--status-success-solid`, `--status-success-tint-foreground`, `--text-placeholder`, `--text-primary`, `--text-secondary`, `--text-wrap-body`
|
|
15
16
|
|
|
16
17
|
## Overview
|
|
17
18
|
|
|
18
19
|
TextField is the single-line text input for short, free-form values: name, IČO / DIČ, e-mail,
|
|
19
|
-
phone, web, address, amount, or a search / filter box. `type` is a non-visual prop
|
|
20
|
-
(`text · email · tel · url · search · password`) — it changes the on-screen
|
|
21
|
-
behaviour, never the look.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
a
|
|
20
|
+
phone, web, address, amount, date, or a search / filter box. `type` is a non-visual prop
|
|
21
|
+
(`text · email · tel · url · search · password · numeric`, plus `date`) — it changes the on-screen
|
|
22
|
+
keyboard and slot behaviour, never the look (`numeric` only right-aligns the value); any other HTML input type does not type-check. `type="date"` turns the field into a date field: a typeable date with
|
|
23
|
+
the calendar glyph and the Single month Date Picker (see [Date mode](#date-mode)). A date field is
|
|
24
|
+
this component, not a separate one.
|
|
25
|
+
|
|
26
|
+
Reach for a different component when: the value spans multiple lines (→ **Textarea**), it comes from
|
|
27
|
+
a fixed set of options (→ **Select**), or it needs an in-field unit / computed suffix
|
|
28
|
+
(→ **UnitField** / **NumberField**). A field that _looks_ editable but offers a list is a Select, not
|
|
29
|
+
a TextField. The **Date Picker** is not a competing field: it is the panel a `type="date"` TextField
|
|
30
|
+
opens.
|
|
27
31
|
|
|
28
32
|
TextField is only the **shell + value**. The floating label, helper text and error / success
|
|
29
33
|
messaging live in the `Field` wrapper — the canonical usage is
|
|
@@ -58,15 +62,14 @@ TextField codifies the parts that were previously implicit:
|
|
|
58
62
|
than clipping mid-glyph (spec `text.placeholder.overflow = truncate`). `text-overflow` has to sit on
|
|
59
63
|
the `<input>` — `::placeholder` ignores it (verified in Chrome) — which leaves `text.value.overflow =
|
|
60
64
|
scroll` intact: a focused input still scrolls horizontally natively, so the ellipsis only appears on a
|
|
61
|
-
resting, unfocused, overflowing value.
|
|
62
|
-
|
|
65
|
+
resting, unfocused, overflowing value. The `type="date"` mode renders this same shell, so it
|
|
66
|
+
behaves the same.
|
|
63
67
|
- **Trailing slot** (optional, `trailingIcon`) — 24/20px affordance (clear, password reveal). Becomes
|
|
64
68
|
an interactive `<button>` when `onTrailingIconClick` is set (`trailingIconLabel` is its accessible
|
|
65
69
|
name). On Error / Success this slot is taken by the intrinsic status icon and the user affordance is
|
|
66
70
|
suppressed.
|
|
67
|
-
- **Status icon** (Error / Success) — trailing `warning-circle` (`--status-danger`) or `check`
|
|
68
|
-
(`--status-success-solid`)
|
|
69
|
-
differs — the icon set ships `check-circle` too, but this component renders the bare `check`.
|
|
71
|
+
- **Status icon** (Error / Success) — trailing `warning-circle` (`--status-danger`) or `check-circle`
|
|
72
|
+
(`--status-success-solid`), both the Figma glyphs.
|
|
70
73
|
- **Focus** — on Default the shell border swaps to `--outline-focus` (1px, same weight). No additive
|
|
71
74
|
ring: the border swap is the sole focus indicator. On an **invalid** field the
|
|
72
75
|
border keeps `--status-danger` and thickens from `--border-width-100` to `--border-width-200`
|
|
@@ -211,7 +214,7 @@ state is derived from the `state` prop.
|
|
|
211
214
|
</tr>
|
|
212
215
|
<tr>
|
|
213
216
|
<td><code>success</code></td>
|
|
214
|
-
<td><code>--status-success-solid</code> border + trailing <code>check</code> icon (non-text); <code>Field</code> label + confirmation message in <code>--status-success-tint-foreground</code> (AA)</td>
|
|
217
|
+
<td><code>--status-success-solid</code> border + trailing <code>check-circle</code> icon (non-text); <code>Field</code> label + confirmation message in <code>--status-success-tint-foreground</code> (AA)</td>
|
|
215
218
|
<td>colour + icon, never colour alone</td>
|
|
216
219
|
</tr>
|
|
217
220
|
<tr>
|
|
@@ -304,9 +307,162 @@ The `--space-200` settle is a deliberate calm-motion exception (like Hero's); te
|
|
|
304
307
|
for the resting label — the manifest does not bind the floated label's fade-out separately. The
|
|
305
308
|
floated label's notch is painted on the label itself, so the border shows through it while it fades
|
|
306
309
|
in. The field family inherits this through the shared `Field` label (Textarea, Select / Combobox
|
|
307
|
-
Field,
|
|
310
|
+
Field, Subject Lookup Field, and TextField's own `type="date"` mode) and Field Pair's cells (`_field-segment`); fields whose
|
|
308
311
|
label is always floated (Unit Field, Number Field, Select Field) never change pose and never animate.
|
|
309
312
|
|
|
313
|
+
## Date mode
|
|
314
|
+
|
|
315
|
+
<Canvas of={TextFieldStories.DateMode} />
|
|
316
|
+
|
|
317
|
+
`type="date"` is this field with a calendar (manifest `delivery.react`, 2.15.0). What changes:
|
|
318
|
+
|
|
319
|
+
- **The value is a `Date`**, in through `value` (controlled) or `defaultValue` (uncontrolled) and out
|
|
320
|
+
through `onValueChange`, never the formatted string. Clearing the field reports `undefined`.
|
|
321
|
+
Turning the `Date` into what the API stores is the consumer's job. The native string `value` /
|
|
322
|
+
`defaultValue` / `onChange` of the plain field give way to these `Date` props.
|
|
323
|
+
- **The format is the market's, not the design system's.** `dateFormat` (a date-fns pattern) and
|
|
324
|
+
`locale` (a date-fns `Locale`) are both required, with no default and no Czech fallback: the
|
|
325
|
+
consumer passes the format and locale of the market the field is shown in, and the field both
|
|
326
|
+
displays and parses the typed text in that format. `locale` also sets the calendar's week start,
|
|
327
|
+
weekday and month names. Examples: Czech `dd. MM. yyyy`, US `MM/dd/yyyy`, Dutch `dd-MM-yyyy`.
|
|
328
|
+
- **The native input stays `type="text"`**, never the native date input: no browser picker, no native
|
|
329
|
+
formatting. A typist keys the date straight in; the calendar is a faster alternative, never the only
|
|
330
|
+
way in.
|
|
331
|
+
- **The whole field is the trigger.** A click anywhere on the field (the input, the glyph or the shell
|
|
332
|
+
padding) opens the Single month Date Picker anchored to it. A press that misses the input keeps focus
|
|
333
|
+
and a half-typed draft in the input. Clicking the input again while the calendar is open does not
|
|
334
|
+
close it, so the caret can be placed.
|
|
335
|
+
- **The `calendar-dots` glyph is decorative.** It is forced into the leading slot, `aria-hidden` and not
|
|
336
|
+
focusable; there is no button in the field. `leadingIcon`, `trailingIcon` and the trailing-button
|
|
337
|
+
props are not accepted in this mode.
|
|
338
|
+
- **`minDate` / `maxDate` bound both routes.** The calendar disables the days outside them, and a typed
|
|
339
|
+
date outside them is rejected, the same as an unparseable one. Both bounds are inclusive and compared
|
|
340
|
+
by day.
|
|
341
|
+
- **The typed draft commits on blur, and on Enter.** Enter commits before it submits the form, so a
|
|
342
|
+
submit never carries a date the input no longer shows. The draft is parsed against `dateFormat` and `locale`; a draft that does
|
|
343
|
+
not parse, or parses to a day outside `minDate` / `maxDate`, is never coerced and never swapped back
|
|
344
|
+
for the old date. The typed text stays in the input, and the value becomes `undefined`
|
|
345
|
+
(`onValueChange(undefined)`, unless it already was), so a form cannot submit a date the user no
|
|
346
|
+
longer sees. The field raises no error state of its own; validation messaging stays the form's job
|
|
347
|
+
(`state="error"` + `error` on `Field`). `onInvalidInput(raw, reason)` tells the form why: `'unparseable'`
|
|
348
|
+
or `'out-of-range'`, with the text the user typed — the hook for the [Copy](#copy) error pattern,
|
|
349
|
+
shown next to that text (story `Date — Invalid typed date`). A valid or an emptied draft does not
|
|
350
|
+
fire it, and a rejected text the user has not edited is reported once, not on every blur; after a
|
|
351
|
+
change of `minDate` / `maxDate` or the format, the next blur or Enter judges it again. Picking
|
|
352
|
+
a day, a date the consumer sets, or a native form reset replaces the rejected text; text the user
|
|
353
|
+
is still typing is never replaced by an outside value change. Setting `value` to `undefined` does
|
|
354
|
+
not clear the rejected text (the value already is `undefined`); to empty the field from code,
|
|
355
|
+
reset its form or remount it with a new `key`.
|
|
356
|
+
- **One action reports one value.** Picking a day over a half-typed draft reports only the picked day:
|
|
357
|
+
the blur that moves focus into the calendar does not commit the draft.
|
|
358
|
+
- **Read-only never opens the calendar.** The glyph stays as a quiet marker in `--icon-muted`; the value
|
|
359
|
+
stays focusable and copyable. Disabled does not open it either. A calendar that is open when the
|
|
360
|
+
field turns disabled or read-only closes, and unlocking the field does not reopen it.
|
|
361
|
+
- **The label follows the one floating-label rule.** An empty, unfocused, valid date field without a
|
|
362
|
+
placeholder rests its `Field` label inside; a value, focus or a format placeholder floats it. The label
|
|
363
|
+
is offset past the calendar glyph in both poses.
|
|
364
|
+
|
|
365
|
+
The same field for another market, here `dateFormat="MM/dd/yyyy"` + `locale={enUS}`:
|
|
366
|
+
|
|
367
|
+
<Canvas of={TextFieldStories.DateOtherMarket} />
|
|
368
|
+
|
|
369
|
+
State × size, as for the plain field:
|
|
370
|
+
|
|
371
|
+
<Canvas of={TextFieldStories.DateMatrix} />
|
|
372
|
+
|
|
373
|
+
The calendar open from the keyboard (focus the field, press `ArrowDown`): focus lands on the selected
|
|
374
|
+
day, and the dialog is named by the field's label.
|
|
375
|
+
|
|
376
|
+
<Canvas of={TextFieldStories.DateOpen} />
|
|
377
|
+
|
|
378
|
+
An invalid typed date stays where the user typed it: `32. 13. 2026` + Tab keeps the text, the value
|
|
379
|
+
becomes `undefined`, and the form shows the [Copy](#copy) error next to it.
|
|
380
|
+
|
|
381
|
+
<Canvas of={TextFieldStories.DateInvalid} />
|
|
382
|
+
|
|
383
|
+
The date-mode props (the shared ones, `state`, `size`, `disabled`, `readOnly`, `placeholder`, `id`
|
|
384
|
+
and the rest, work as for the plain field):
|
|
385
|
+
|
|
386
|
+
<table>
|
|
387
|
+
<thead>
|
|
388
|
+
<tr><th>Prop</th><th>Type</th><th>Required</th><th>Notes</th></tr>
|
|
389
|
+
</thead>
|
|
390
|
+
<tbody>
|
|
391
|
+
<tr>
|
|
392
|
+
<td><code>type</code></td>
|
|
393
|
+
<td><code>'date'</code></td>
|
|
394
|
+
<td>yes</td>
|
|
395
|
+
<td>selects the date mode</td>
|
|
396
|
+
</tr>
|
|
397
|
+
<tr>
|
|
398
|
+
<td><code>value</code></td>
|
|
399
|
+
<td><code>Date</code></td>
|
|
400
|
+
<td>no</td>
|
|
401
|
+
<td>the chosen date; controlled while it is not <code>undefined</code></td>
|
|
402
|
+
</tr>
|
|
403
|
+
<tr>
|
|
404
|
+
<td><code>defaultValue</code></td>
|
|
405
|
+
<td><code>Date</code></td>
|
|
406
|
+
<td>no</td>
|
|
407
|
+
<td>initial date of an uncontrolled field (<code>value</code> left out)</td>
|
|
408
|
+
</tr>
|
|
409
|
+
<tr>
|
|
410
|
+
<td><code>onValueChange</code></td>
|
|
411
|
+
<td><code>(value: Date | undefined) => void</code></td>
|
|
412
|
+
<td>no</td>
|
|
413
|
+
<td>the committed date: a parsed typed draft, a picked day, or <code>undefined</code> when cleared</td>
|
|
414
|
+
</tr>
|
|
415
|
+
<tr>
|
|
416
|
+
<td><code>onInvalidInput</code></td>
|
|
417
|
+
<td><code>(raw: string, reason: 'unparseable' | 'out-of-range') => void</code></td>
|
|
418
|
+
<td>no</td>
|
|
419
|
+
<td>a typed draft was rejected on commit (blur or Enter): not in <code>dateFormat</code>, or outside <code>minDate</code> / <code>maxDate</code>; the typed text stays and the value becomes <code>undefined</code> (reported through <code>onValueChange</code> first). Use it to show the error on <code>Field</code></td>
|
|
420
|
+
</tr>
|
|
421
|
+
<tr>
|
|
422
|
+
<td><code>dateFormat</code></td>
|
|
423
|
+
<td><code>string</code></td>
|
|
424
|
+
<td>yes, no default</td>
|
|
425
|
+
<td>display + parse pattern in date-fns syntax, the market's (<code>dd. MM. yyyy</code>, <code>MM/dd/yyyy</code>, <code>dd-MM-yyyy</code>)</td>
|
|
426
|
+
</tr>
|
|
427
|
+
<tr>
|
|
428
|
+
<td><code>locale</code></td>
|
|
429
|
+
<td><code>Locale</code> (date-fns)</td>
|
|
430
|
+
<td>yes, no default</td>
|
|
431
|
+
<td>the market's locale: the calendar's week start, weekday and month names, and the parse</td>
|
|
432
|
+
</tr>
|
|
433
|
+
<tr>
|
|
434
|
+
<td><code>minDate</code> / <code>maxDate</code></td>
|
|
435
|
+
<td><code>Date</code></td>
|
|
436
|
+
<td>no</td>
|
|
437
|
+
<td>earliest / latest selectable day, inclusive; bounds the calendar and a typed date</td>
|
|
438
|
+
</tr>
|
|
439
|
+
<tr>
|
|
440
|
+
<td><code>panelLabelledBy</code></td>
|
|
441
|
+
<td><code>string</code></td>
|
|
442
|
+
<td>no</td>
|
|
443
|
+
<td>id of the visible text naming the calendar dialog (<code>aria-labelledby</code>); <code>Field</code> fills it with its <code><label></code> id, so inside a labelled <code>Field</code> there is nothing to pass. Wins over <code>panelLabel</code></td>
|
|
444
|
+
</tr>
|
|
445
|
+
<tr>
|
|
446
|
+
<td><code>panelLabel</code></td>
|
|
447
|
+
<td><code>string</code></td>
|
|
448
|
+
<td>no, no default</td>
|
|
449
|
+
<td>fallback accessible name (<code>aria-label</code>) of the calendar dialog, used only when nothing visible names the field. Without it the dialog takes the field's own <code>aria-labelledby</code> / <code>aria-label</code>; with no name at all it warns in development</td>
|
|
450
|
+
</tr>
|
|
451
|
+
<tr>
|
|
452
|
+
<td><code>navLabels</code></td>
|
|
453
|
+
<td><code>DatePickerNavLabels</code></td>
|
|
454
|
+
<td>yes</td>
|
|
455
|
+
<td>accessible names of the calendar's four chevrons: <code>previousMonth</code>, <code>nextMonth</code>, <code>previousYear</code>, <code>nextYear</code></td>
|
|
456
|
+
</tr>
|
|
457
|
+
<tr>
|
|
458
|
+
<td><code>className</code></td>
|
|
459
|
+
<td><code>string</code></td>
|
|
460
|
+
<td>no</td>
|
|
461
|
+
<td>applied to the trigger wrapper around the shell</td>
|
|
462
|
+
</tr>
|
|
463
|
+
</tbody>
|
|
464
|
+
</table>
|
|
465
|
+
|
|
310
466
|
## API
|
|
311
467
|
|
|
312
468
|
<Controls />
|
|
@@ -316,8 +472,10 @@ label is always floated (Unit Field, Number Field, Select Field) never change po
|
|
|
316
472
|
- ✅ Always wrap in `Field` and give the `<input>` an `id` — the floating `<label>` is the accessible name.
|
|
317
473
|
- ✅ Use `state="readonly"` for locked values — it stays copyable and in the tab order.
|
|
318
474
|
- ✅ Write specific, impersonal errors ("IČO musí mít 8 číslic" — problem + fix) and pair `state="error"` with a matching `error` on `Field`.
|
|
319
|
-
- ✅ Reach for the right component — Select for a fixed set, Textarea for multi-line
|
|
475
|
+
- ✅ Reach for the right component — Select for a fixed set, Textarea for multi-line; a date is a `type="date"` TextField that opens the Date Picker.
|
|
476
|
+
- ✅ For a date, pass the `dateFormat` and `locale` of the market the field is shown in, from the app's market config.
|
|
320
477
|
- ❌ Don't use the placeholder as the only label — it disappears on input and fails a11y.
|
|
478
|
+
- ❌ Don't build a separate "date field" component — a date field is this one with `type="date"`.
|
|
321
479
|
- ❌ Don't use `disabled` for a value the user still needs to read or copy.
|
|
322
480
|
- ❌ Don't ship generic "Neplatná hodnota" or commands ("Zadejte…").
|
|
323
481
|
- ❌ Don't place a TextField on a tinted / secondary background — the shell fill and contrast are built for `--bg-primary` only.
|
|
@@ -331,6 +489,28 @@ label is always floated (Unit Field, Number Field, Select Field) never change po
|
|
|
331
489
|
(handled by `Field`). `readonly` sets `aria-readonly`. A label-less filter / search field needs an
|
|
332
490
|
explicit `aria-label` — the placeholder is not a label (WCAG 1.3.1 / 3.3.2). An interactive trailing
|
|
333
491
|
icon (`onTrailingIconClick`) requires `trailingIconLabel`.
|
|
492
|
+
- **Date mode: keyboard** — the input is typeable like any TextField. `ArrowDown` opens the calendar and
|
|
493
|
+
moves focus onto the selected day (or today); with the calendar already open from a click, `ArrowDown`
|
|
494
|
+
moves focus into the grid. Opening by click leaves focus in the input, so typing keeps working.
|
|
495
|
+
Picking a day closes the calendar and returns focus to the input; `Esc` closes it and returns focus
|
|
496
|
+
to the field. With the calendar open, `Tab` runs from the input through the year and month
|
|
497
|
+
chevrons to the day, then leaves the calendar. A half-typed draft commits when `Tab` leaves the
|
|
498
|
+
input, as on any blur, so `onValueChange` or `onInvalidInput` fires before focus reaches the
|
|
499
|
+
calendar. The draft is kept only when focus moves straight into the open calendar — `ArrowDown`,
|
|
500
|
+
or a press on a day or a chevron: picking a day there replaces the draft, and only the picked day
|
|
501
|
+
is reported.
|
|
502
|
+
- **Date mode: format** — tell the user the format in the helper (or in the error), never only in the
|
|
503
|
+
placeholder, which disappears as soon as they type (WCAG 3.3.2). The Date story does it with the
|
|
504
|
+
helper «Formát DD. MM. RRRR».
|
|
505
|
+
- **Date mode: ARIA** — the input itself is the trigger: `role="combobox"`, `aria-haspopup="dialog"`,
|
|
506
|
+
`aria-expanded`, and `aria-controls` pointing at the calendar while it is open. A disabled date
|
|
507
|
+
field keeps the combobox role; a read-only one owns no calendar, so it is a plain textbox without
|
|
508
|
+
`role="combobox"` or `aria-haspopup`. The calendar is `role="dialog"`, named by the field's visible
|
|
509
|
+
`<label>` through `aria-labelledby` (`Field` passes it as `panelLabelledBy`); `panelLabel` is the
|
|
510
|
+
`aria-label` fallback for a field with no visible label, and without it the field's own
|
|
511
|
+
`aria-label` names the dialog too. Its chevrons are named by `navLabels`, which is required and
|
|
512
|
+
has no default — the consumer passes the names in the market's language. The calendar glyph is `aria-hidden`. Inside a `Modal` the calendar renders within the modal's dialog, so a day can take focus
|
|
513
|
+
past the focus trap.
|
|
334
514
|
- **Screen reader** — the floating `<label>` from `Field` is the accessible name; error / success are
|
|
335
515
|
conveyed by colour **and** a status icon (WCAG 1.4.1), so the cue is not colour-only.
|
|
336
516
|
- **Announcement** (manifest 2.9.1) — `Field` keeps the helper / message line **always mounted** as a
|
|
@@ -343,9 +523,9 @@ label is always floated (Unit Field, Number Field, Select Field) never change po
|
|
|
343
523
|
- **Contrast & motion** — focus is a 1px `--outline-focus` border swap with **no** ring. ⚠️ Accepted
|
|
344
524
|
tradeoff: a 1px swap is weaker than an offset ring and borderline for WCAG 2.4.11. The mitigation — thicken the focus border, never re-add a ring — is applied on invalid
|
|
345
525
|
fields: Error + focus keeps `--status-danger` and goes to `--border-width-200`, so focus stays
|
|
346
|
-
visible without trading the error colour for blue. Besides the border, the only motion
|
|
347
|
-
floating label's cross-fade (see States → Motion), which honours `prefers-reduced-motion` and
|
|
348
|
-
the pose at once there.
|
|
526
|
+
visible without trading the error colour for blue. Besides the border, the only motion of the field
|
|
527
|
+
is the floating label's cross-fade (see States → Motion), which honours `prefers-reduced-motion` and
|
|
528
|
+
swaps the pose at once there.
|
|
349
529
|
|
|
350
530
|
Accessibility floor for every FODS component: `spec/01-foundations/accessibility.md`.
|
|
351
531
|
|
|
@@ -389,7 +569,9 @@ Per text run:
|
|
|
389
569
|
optional fields **only**.
|
|
390
570
|
|
|
391
571
|
Error pattern: `[what's wrong]( + [expected format])`, impersonal, e.g. "Neplatné datum — formát
|
|
392
|
-
DD. MM. RRRR".
|
|
572
|
+
DD. MM. RRRR". The format named is the market's own (see [Date mode](#date-mode)); `DD. MM. RRRR` is
|
|
573
|
+
the Czech one, and the same holds for a date field's format placeholder. Not a command ("Zadejte…"),
|
|
574
|
+
not a bare label ("Chyba").
|
|
393
575
|
|
|
394
576
|
<table>
|
|
395
577
|
<thead>
|
|
@@ -426,6 +608,42 @@ DD. MM. RRRR". Not a command ("Zadejte…"), not a bare label ("Chyba").
|
|
|
426
608
|
|
|
427
609
|
// Good — search / filter field with a leading glyph and an aria-label
|
|
428
610
|
<TextField leadingIcon="magnifying-glass" placeholder="Hledat…" aria-label="Hledat" />
|
|
611
|
+
|
|
612
|
+
// Good — a date: a Date in and out; format, locale and the calendar's names
|
|
613
|
+
// come from the market the field is shown in (here the Czech one); the helper
|
|
614
|
+
// states the format, and a rejected draft becomes the Field's error, shown
|
|
615
|
+
// next to the text the user typed
|
|
616
|
+
const [issuedOn, setIssuedOn] = React.useState<Date | undefined>();
|
|
617
|
+
const [dateError, setDateError] = React.useState<string>();
|
|
618
|
+
|
|
619
|
+
<Field
|
|
620
|
+
label="Datum vystavení"
|
|
621
|
+
helperText="Formát DD. MM. RRRR"
|
|
622
|
+
error={dateError}
|
|
623
|
+
>
|
|
624
|
+
<TextField
|
|
625
|
+
type="date"
|
|
626
|
+
id="issued-on"
|
|
627
|
+
state={dateError ? 'error' : undefined}
|
|
628
|
+
value={issuedOn}
|
|
629
|
+
onValueChange={date => { setDateError(undefined); setIssuedOn(date); }}
|
|
630
|
+
onInvalidInput={(_raw, reason) => setDateError(
|
|
631
|
+
reason === 'out-of-range'
|
|
632
|
+
? 'Datum musí být nejdříve 1. 1. 2020'
|
|
633
|
+
: 'Neplatné datum — formát DD. MM. RRRR',
|
|
634
|
+
)}
|
|
635
|
+
dateFormat="dd. MM. yyyy" // another market passes its own pattern and texts
|
|
636
|
+
locale={cs} // the date-fns Locale of the market
|
|
637
|
+
navLabels={{
|
|
638
|
+
previousMonth: 'Předchozí měsíc',
|
|
639
|
+
nextMonth: 'Další měsíc',
|
|
640
|
+
previousYear: 'Předchozí rok',
|
|
641
|
+
nextYear: 'Další rok',
|
|
642
|
+
}}
|
|
643
|
+
placeholder="DD. MM. RRRR"
|
|
644
|
+
minDate={new Date(2020, 0, 1)}
|
|
645
|
+
/>
|
|
646
|
+
</Field>
|
|
429
647
|
```
|
|
430
648
|
|
|
431
649
|
```tsx
|
|
@@ -434,12 +652,17 @@ DD. MM. RRRR". Not a command ("Zadejte…"), not a bare label ("Chyba").
|
|
|
434
652
|
|
|
435
653
|
// Don't — disabled hides a value the user still needs to read / copy
|
|
436
654
|
<TextField state="disabled" defaultValue="20260721" />
|
|
655
|
+
|
|
656
|
+
// Don't — a formatted string is not a date value; the value is a Date
|
|
657
|
+
<TextField type="date" value="15. 04. 2026" {...marketDateProps} />
|
|
437
658
|
```
|
|
438
659
|
|
|
439
660
|
## Related
|
|
440
661
|
|
|
441
|
-
- [`Field`](
|
|
442
|
-
- [`Textarea`](
|
|
662
|
+
- [`Field`](?path=/docs/design-system-atoms-field--docs) — the wrapper that supplies the floating label, helper and error / success messaging (mandatory partner).
|
|
663
|
+
- [`Textarea`](?path=/docs/design-system-atoms-textarea--docs) — multi-line sibling sharing the same shell.
|
|
664
|
+
- [`DatePicker`](?path=/docs/design-system-molecules-datepicker--docs) — the calendar panel `type="date"` opens; use it directly for a dual-month range.
|
|
665
|
+
- [`FieldPair`](?path=/docs/design-system-molecules-fieldpair--docs) — `format="date"`: a date range as two fused cells, each opening its own single-month calendar.
|
|
443
666
|
- `UnitField` — TextField shell with an in-field unit / suffix (`Kč`, `%`).
|
|
444
667
|
- `NumberField` — the stepper variant for numeric quantities.
|
|
445
668
|
- `Select` — for choosing from a fixed set of options; reuses the same field shell.
|
|
@@ -453,15 +676,14 @@ DD. MM. RRRR". Not a command ("Zadejte…"), not a bare label ("Chyba").
|
|
|
453
676
|
Motion) and has no transition at all — status ink changes (error ↔ default) are now instant too, as
|
|
454
677
|
the manifest's motion block lists nothing else that moves. Field Pair dropped its own copy of the
|
|
455
678
|
old transition (`SEGMENT_LABEL_TRANSITION`) and cross-fades its cells the same way.
|
|
456
|
-
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
question.
|
|
679
|
+
- **Manifest 2.15.0 (2026-11-19) — `type="date"` built.** The type that manifest 2.7.0 added is now
|
|
680
|
+
implemented (see [Date mode](#date-mode)); before, `type` was passed straight to the input. 2.15.0
|
|
681
|
+
makes the format the market's: the value is a `Date`, and `dateFormat` + `locale` are required props
|
|
682
|
+
with no Czech default. A `type="date"` TextField without them, or with a string `value`, does not
|
|
683
|
+
type-check. `type` is also narrowed to the manifest's list (`text`, `email`, `tel`, `url`,
|
|
684
|
+
`search`, `password`, `numeric`, `date`). `numeric` is not an HTML input type: it renders
|
|
685
|
+
`type="text"` with `inputMode="numeric"`, right-aligned, so a digit string such as an IČO keeps its
|
|
686
|
+
leading zeros. A number you calculate with belongs in `NumberField` or `UnitField`.
|
|
465
687
|
- **`Help` (the label's ⓘ Tooltip trigger) is specified upstream but NOT built here.** The manifest
|
|
466
688
|
property `Help` (on the nested `_labelContainer`) puts an info ⓘ after the label text; `Field` has
|
|
467
689
|
no prop for it. Manifest 2.11.0 (2026-10-13) adds that a field with `Help` on floats its label even
|
|
@@ -472,8 +694,6 @@ DD. MM. RRRR". Not a command ("Zadejte…"), not a bare label ("Chyba").
|
|
|
472
694
|
- **Numeric quantities** with a stepper are a **separate NumberField component**, not a TextField
|
|
473
695
|
variant. **In-field units / computed suffixes** (`Kč`, `%`) live in the **separate UnitField**,
|
|
474
696
|
keeping TextField's trailing slot icons-only.
|
|
475
|
-
- **Icon names match the spec
|
|
476
|
-
|
|
477
|
-
part of `IconName` in React.
|
|
478
|
-
Success, which renders the bare `check` where the spec names `check-circle` (the icon set has that
|
|
479
|
-
one too).
|
|
697
|
+
- **Icon names match the spec.** The component uses the canonical FODS names (Error
|
|
698
|
+
`warning-circle`, Success `check-circle`, leading `magnifying-glass`); the legacy icon-font names
|
|
699
|
+
are not part of `IconName` in React.
|