@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
|
@@ -61,8 +61,8 @@ FieldPair promotes the from–to relationship rather than reinventing the field:
|
|
|
61
61
|
<td>value <code>--text-primary</code>; formatting via <code>NumberFormatInput</code></td>
|
|
62
62
|
</tr>
|
|
63
63
|
<tr>
|
|
64
|
-
<td><code>format="date"</code> (+ required <code>
|
|
65
|
-
<td>Date range — each cell becomes its own trigger opening its own single-month Date Picker. The type pairs it with <code>showUnit={false}</code>. See <a href="#date-mode--one-picker-per-cell">Date mode</a>.</td>
|
|
64
|
+
<td><code>format="date"</code> (+ required <code>dateFormat</code> / <code>dateLocale</code> / <code>navLabels</code>, none defaulted; optional <code>panelLabel</code>)</td>
|
|
65
|
+
<td>Date range — each cell becomes its own trigger opening its own single-month Date Picker. The type pairs it with <code>showUnit={false}</code>. The market's <code>dateFormat</code> (date-fns pattern) and <code>dateLocale</code> (date-fns <code>Locale</code>) apply to both cells; there is no Czech default. See <a href="#date-mode--one-picker-per-cell">Date mode</a>.</td>
|
|
66
66
|
<td>value <code>--text-primary</code>; panel per <code>DatePicker</code></td>
|
|
67
67
|
</tr>
|
|
68
68
|
<tr>
|
|
@@ -103,11 +103,12 @@ That is deliberate, not a simplification: this pair **is** the mobile substitute
|
|
|
103
103
|
|
|
104
104
|
<Canvas of={FieldPairStories.DateRange} />
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
A few things about the opt-in, the contract and the anatomy are easy to get wrong:
|
|
107
107
|
|
|
108
108
|
- **It is `format="date"`, not `showUnit={false}`.** The spec phrases the condition as *"Show unit=False **and the pair represents a date range**"* — two conditions, and Figma can only carry the first (it has no cell-type axis). `showUnit={false}` already covers a plain text range and a plain number range, neither of which may silently grow a calendar. The type still enforces the spec's coupling one-directionally: `format="date"` requires `showUnit={false}`.
|
|
109
|
-
- **`
|
|
110
|
-
- **
|
|
109
|
+
- **`dateFormat`, `dateLocale` and `navLabels` are required and never defaulted**, the same contract a standalone [`TextField type="date"`](?path=/story/design-system-atoms-textfield--date-mode) carries — the design system is locale-agnostic. `dateFormat` (the market's date-fns pattern, e.g. `dd. MM. yyyy` or `MM/dd/yyyy`) and `dateLocale` (the market's date-fns `Locale`: parsing, week start, month and weekday names) apply to both cells; the market comes from the consumer, never a Czech default ([another market](?path=/story/design-system-atoms-textfield--date-other-market)). It is `dateLocale`, not `locale`, because `locale` here is already the number formatter's locale string. Each cell's calendar dialog is named by `aria-labelledby` with the same ids that name its input: the cell's own label („Od“), or, under a group label, the group label followed by the cell's label („Období do“). `panelLabel` is optional: it names the dialog only for a cell with no visible label, before that cell's own `aria-label`. A dialog left with no name at all warns in development, and a date pair missing `dateFormat`, `dateLocale` or `navLabels` logs an error and renders plain text cells. `navLabels` are shared by both panels, and only one panel is ever open.
|
|
110
|
+
- **Per-cell `onInvalidInput(raw, reason)`.** A date cell (`from` / `to`) takes its own `onInvalidInput`, the same contract as `TextField type="date"`: when a typed draft is rejected on commit (blur or Enter) it receives the raw text and `'unparseable'` (the draft does not parse with `dateFormat`) or `'out-of-range'` (outside that cell's `minDate` / `maxDate`). The typed text stays in the cell and the cell's value becomes `undefined`: `onValueChange(undefined)` comes first, unless the value already was `undefined`. Enter commits the draft before a form submits, and a native form reset drops it; setting the cell's `value` to `undefined` does not, because it already is `undefined` (reset the form or remount with a new `key`).
|
|
111
|
+
- **A leading calendar glyph, like the standalone `TextField type="date"`.** `_field-segment` 1.6.0 gained `slots.leading-icon`, and Field Pair turns it on in **both** cells in date mode — the cell opens a Date Picker, so it has to say so; before the slot existed it looked completely inert. The glyph shifts the **content**, not the shell: `paddingX` stays `--space-500` and the label *and* the value both start at `--space-500 + icon + gap`, so the label never sits under the glyph and floating stays a purely vertical move. The whole cell is still the trigger: click anywhere in it, or `ArrowDown` from the keyboard.
|
|
111
112
|
- **In date mode the status icon moves to the trailing end.** The status glyph and the other end-glyph always sit on opposite ends (the Unit Field law, inherited by `_field-segment`): in **amount** mode the trailing end is permanently the `Kč` unit, so the error icon goes **leading**; in **date** mode the leading end holds the calendar, so it goes **trailing** — Text Field's position. No end ever carries two glyphs.
|
|
112
113
|
|
|
113
114
|
### Number formatting
|
|
@@ -196,7 +197,7 @@ border and the divider are not transitioned. Details: [Text Field → States →
|
|
|
196
197
|
- **Focus** — a per-cell `:focus-visible` offset ring (2px <code>--outline-focus</code>, 2px outside) rendered as a <code>::before</code> pseudo-element; the floating label's opaque backing masks the ring at the top edge so it never crosses the label.
|
|
197
198
|
- **State & ARIA** — each cell is a real `<input>` with its own `aria-invalid`; the SINGLE shared message is referenced by BOTH cells via `aria-describedby`. In amount mode the cell's unit comes first, `aria-describedby="{unit-id} {helper-id}"`, so `Kč` is read with the value and never sits in the input's `value` (the [Unit Field](?path=/docs/design-system-atoms-unitfield--docs) suffix rule). The message line is always mounted as a polite live region (Text Field's message line) and fills when a message arrives. Error is signalled by colour AND the `warning-circle` status icon (WCAG 1.4.1 — not colour alone) AND the message: a cell in error always needs `error` text.
|
|
198
199
|
- **1px cell gap** — the divider is the fused-segments exception shared with Button Group and Split Button: the cells read as one control, and each cell's focus ring is drawn outside the pair.
|
|
199
|
-
- **Date mode** — each cell's input is `role="combobox" aria-haspopup="dialog"` (APG Date Picker Combobox) with its **own** `aria-expanded` / `aria-controls`; the two panels are fully independent and only one is ever open. `ArrowDown` opens the panel and moves focus onto a day (the grid keeps a single tabstop); a click opens it but leaves the caret in the input, so the cell stays typeable. `Escape` and an outside click dismiss and return focus to the cell. The shared `aria-describedby` still reaches both cells.
|
|
200
|
+
- **Date mode** — each cell's input is `role="combobox" aria-haspopup="dialog"` (APG Date Picker Combobox) with its **own** `aria-expanded` / `aria-controls`; the two panels are fully independent and only one is ever open. Each dialog is named by `aria-labelledby` pointing at what names its cell („Od“, or „Období do“ under a group label); `panelLabel` is the `aria-label` fallback for a cell with no visible label. `ArrowDown` opens the panel and moves focus onto a day (the grid keeps a single tabstop); a click opens it but leaves the caret in the input, so the cell stays typeable. `Escape` and an outside click dismiss and return focus to the cell. A cell that receives `readOnly` is a plain textbox (no combobox role, no popup), since its panel never opens; a `disabled` cell keeps the combobox role. If a cell becomes `disabled` or `readOnly` while its panel is open, the panel closes on that render. The shared `aria-describedby` still reaches both cells.
|
|
200
201
|
- **Contrast** — a bound word is never placeholder-only. Floated or resting, it is <code>--text-secondary</code> (claudy/600, 6.45:1): at rest it is the cell's only visible label, so the <code>--text-placeholder</code> exception (2.71:1, which rests on a floating label duplicating the placeholder) does not apply (manifest `parts.bound-word`). The `Kč` suffix keeps the Unit Field exception. The old <code>--text-tertiary</code> was sub-AA (deprecated 2026-07-08).
|
|
201
202
|
|
|
202
203
|
Accessibility floor for every FODS component: `spec/01-foundations/accessibility.md`.
|
|
@@ -228,11 +229,14 @@ Voice: the field copy rules of [TextField](?path=/docs/design-system-atoms-textf
|
|
|
228
229
|
|
|
229
230
|
```tsx
|
|
230
231
|
// Good — a date range: each cell opens its OWN single-month picker. The cell
|
|
231
|
-
// value is a Date
|
|
232
|
+
// value is a Date; dateFormat/dateLocale (the market's, no default) and
|
|
233
|
+
// navLabels are required (locale-agnostic component); the labelled cells
|
|
234
|
+
// name their calendars, so panelLabel is not needed
|
|
232
235
|
<FieldPair
|
|
233
236
|
format="date"
|
|
234
237
|
showUnit={false}
|
|
235
|
-
|
|
238
|
+
dateFormat="dd. MM. yyyy"
|
|
239
|
+
dateLocale={cs} // import { cs } from 'date-fns/locale/cs'
|
|
236
240
|
navLabels={navLabels}
|
|
237
241
|
aria-label="Datum vystavení"
|
|
238
242
|
from={{ label: 'Od', value: from, onValueChange: setFrom }}
|
|
@@ -291,7 +295,7 @@ Voice: the field copy rules of [TextField](?path=/docs/design-system-atoms-textf
|
|
|
291
295
|
- **[TextField](?path=/docs/design-system-atoms-textfield--docs)** — the standalone bordered field; FieldPair reuses its internals.
|
|
292
296
|
- **[UnitField](?path=/docs/design-system-atoms-unitfield--docs)** — same `--text-placeholder` rule for the unit suffix.
|
|
293
297
|
- **[Field](?path=/docs/design-system-atoms-field--docs)** — the floating-label / helper primitive the cells compose.
|
|
294
|
-
- **[
|
|
298
|
+
- **[TextField `type="date"`](?path=/story/design-system-atoms-textfield--date-mode)** — the standalone date field; a date-mode cell is the same behaviour in a borderless shell (same leading glyph, but an offset `::before` ring instead of the border swap).
|
|
295
299
|
- **[DatePicker](?path=/docs/design-system-molecules-datepicker--docs)** — the panel each date cell opens; its Dual month mode is what this pair replaces on mobile.
|
|
296
300
|
- Spec: `spec/04-molecules/field-pair.md`
|
|
297
301
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { ComponentType } from 'react';
|
|
3
3
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
4
|
+
import { cs } from 'date-fns/locale/cs';
|
|
4
5
|
import { FieldPair } from './FieldPair';
|
|
5
6
|
import type {
|
|
6
7
|
FieldPairBaseProps,
|
|
@@ -31,8 +32,10 @@ type FieldPairStoryArgs = FieldPairBaseProps & {
|
|
|
31
32
|
label?: string;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
|
-
//
|
|
35
|
-
// same contract
|
|
35
|
+
// The market's date format + locale (Czech here) and the accessible names for the
|
|
36
|
+
// date-mode panels — required and never defaulted, the same contract TextField
|
|
37
|
+
// type="date" carries.
|
|
38
|
+
const DATE_FORMAT = 'dd. MM. yyyy';
|
|
36
39
|
const PANEL_LABEL = 'Kalendář';
|
|
37
40
|
const NAV_LABELS = {
|
|
38
41
|
previousMonth: 'Předchozí měsíc',
|
|
@@ -400,6 +403,8 @@ function DateRangeDemo({ size = 'md' as FieldPairSize }) {
|
|
|
400
403
|
size={size}
|
|
401
404
|
format="date"
|
|
402
405
|
showUnit={false}
|
|
406
|
+
dateFormat={DATE_FORMAT}
|
|
407
|
+
dateLocale={cs}
|
|
403
408
|
panelLabel={PANEL_LABEL}
|
|
404
409
|
navLabels={NAV_LABELS}
|
|
405
410
|
aria-label="Datum vystavení"
|
|
@@ -417,6 +422,8 @@ function DateRangeInvalidDemo() {
|
|
|
417
422
|
<FieldPair
|
|
418
423
|
format="date"
|
|
419
424
|
showUnit={false}
|
|
425
|
+
dateFormat={DATE_FORMAT}
|
|
426
|
+
dateLocale={cs}
|
|
420
427
|
panelLabel={PANEL_LABEL}
|
|
421
428
|
navLabels={NAV_LABELS}
|
|
422
429
|
aria-label="Datum vystavení"
|
|
@@ -435,6 +442,8 @@ function GroupLabelDateDemo() {
|
|
|
435
442
|
size="sm"
|
|
436
443
|
format="date"
|
|
437
444
|
showUnit={false}
|
|
445
|
+
dateFormat={DATE_FORMAT}
|
|
446
|
+
dateLocale={cs}
|
|
438
447
|
panelLabel={PANEL_LABEL}
|
|
439
448
|
navLabels={NAV_LABELS}
|
|
440
449
|
label="Období"
|
|
@@ -14,7 +14,9 @@ import { floatingLabelVariants, helperTextVariants } from '../field/Field';
|
|
|
14
14
|
import { textFieldValueVariants } from '../text-field/TextField';
|
|
15
15
|
import { NumberFormatInput, type NumberFormatInputProps } from '../../internal/NumberFormatInput';
|
|
16
16
|
import { type DatePickerNavLabels } from '../date-picker/DatePicker';
|
|
17
|
+
import { useFormReset } from '../../internal/useFormReset';
|
|
17
18
|
import { useDateFieldTrigger, type UseDateFieldTriggerOptions } from '../../internal/useDateFieldTrigger';
|
|
19
|
+
import { enUS } from 'date-fns/locale/en-US';
|
|
18
20
|
|
|
19
21
|
// =============================================================================
|
|
20
22
|
// FieldPair — two fused fields that read as one bounded range (od–do), spec
|
|
@@ -185,12 +187,19 @@ export interface FieldPairCell
|
|
|
185
187
|
/**
|
|
186
188
|
* A cell in `format="date"` — the value is the `Date` itself, not the text the
|
|
187
189
|
* input shows. The cell formats and parses it exactly like a standalone
|
|
188
|
-
* `
|
|
190
|
+
* `TextField type="date"` does.
|
|
189
191
|
*/
|
|
190
192
|
export interface FieldPairDateCell
|
|
191
193
|
extends Omit<FieldPairCell, 'value' | 'defaultValue' | 'onChange' | 'onValueChange'> {
|
|
192
194
|
value?: Date;
|
|
193
195
|
onValueChange?: (value: Date | undefined) => void;
|
|
196
|
+
/**
|
|
197
|
+
* A typed draft in this cell was rejected on commit (blur or Enter) — `'unparseable'` or
|
|
198
|
+
* `'out-of-range'` (outside this cell's `minDate` / `maxDate`). Same contract
|
|
199
|
+
* as `TextField type="date"`: the typed text stays and the cell's value
|
|
200
|
+
* becomes `undefined`.
|
|
201
|
+
*/
|
|
202
|
+
onInvalidInput?: UseDateFieldTriggerOptions['onInvalidInput'];
|
|
194
203
|
/**
|
|
195
204
|
* Per-cell selectable window. Deliberately NOT cross-wired to the sibling —
|
|
196
205
|
* spec field-pair.md § Field Segment: "no cross-field minDate/maxDate
|
|
@@ -302,9 +311,8 @@ type FieldPairValueMode = {
|
|
|
302
311
|
* condition is two-part ("Show unit=False AND the pair represents a date
|
|
303
312
|
* range"). Two things ride on the distinction: `showUnit={false}` already
|
|
304
313
|
* carries plain text and plain number ranges, which must not silently grow a
|
|
305
|
-
* calendar — and `
|
|
306
|
-
* mode is in the type
|
|
307
|
-
* and an anonymous one. The spec's date ⇒ no-unit coupling is still enforced,
|
|
314
|
+
* calendar — and `dateFormat` / `dateLocale` / `navLabels` can only be made
|
|
315
|
+
* REQUIRED when the mode is in the type. The spec's date ⇒ no-unit coupling is still enforced,
|
|
308
316
|
* one-directionally, by requiring `showUnit: false` here.
|
|
309
317
|
*/
|
|
310
318
|
type FieldPairDateMode = {
|
|
@@ -313,19 +321,28 @@ type FieldPairDateMode = {
|
|
|
313
321
|
unit?: never;
|
|
314
322
|
from: FieldPairDateCell;
|
|
315
323
|
to: FieldPairDateCell;
|
|
316
|
-
/** Display + parse pattern (date-fns), applied to BOTH cells. */
|
|
317
|
-
dateFormat?: string;
|
|
318
324
|
/**
|
|
319
|
-
* date-fns
|
|
320
|
-
*
|
|
321
|
-
*
|
|
325
|
+
* Display + parse pattern (date-fns), applied to BOTH cells — the MARKET's
|
|
326
|
+
* (e.g. `dd. MM. yyyy` CZ, `MM/dd/yyyy` US). Required, no default, the same
|
|
327
|
+
* contract as `TextField type="date"` (text-field manifest 2.15.0).
|
|
328
|
+
*/
|
|
329
|
+
dateFormat: string;
|
|
330
|
+
/**
|
|
331
|
+
* The market's date-fns Locale for both cells (parse, week start, weekday and
|
|
332
|
+
* month names). Required, no default. Named `dateLocale` because `locale` on
|
|
333
|
+
* this component is already the NUMBER formatter's locale string —
|
|
334
|
+
* harmonising the two names would collapse the union to `string | Locale`.
|
|
322
335
|
*/
|
|
323
|
-
dateLocale
|
|
336
|
+
dateLocale: Locale;
|
|
324
337
|
/**
|
|
325
|
-
*
|
|
326
|
-
*
|
|
338
|
+
* Fallback accessible name for each cell's calendar dialog. A cell with a
|
|
339
|
+
* visible `label` names its dialog with that label instead (`aria-labelledby`,
|
|
340
|
+
* the same ids that name its input — „Cena od"); this string is used only for
|
|
341
|
+
* a cell without one, before that cell's own `aria-label`. Optional — a
|
|
342
|
+
* labelled cell never reads it — and never defaulted; a dialog left without
|
|
343
|
+
* any name warns in development.
|
|
327
344
|
*/
|
|
328
|
-
panelLabel
|
|
345
|
+
panelLabel?: string;
|
|
329
346
|
/** Accessible names for the panels' navigation chevrons. */
|
|
330
347
|
navLabels: DatePickerNavLabels;
|
|
331
348
|
locale?: never;
|
|
@@ -344,7 +361,7 @@ export type FieldPairProps = FieldPairBaseProps &
|
|
|
344
361
|
// -----------------------------------------------------------------------------
|
|
345
362
|
|
|
346
363
|
/** Everything a date-mode cell hands to its own trigger. */
|
|
347
|
-
type FieldSegmentDateConfig = Omit<UseDateFieldTriggerOptions, 'enabled' | 'disabled' | 'readOnly' | 'inputRef'>;
|
|
364
|
+
type FieldSegmentDateConfig = Omit<UseDateFieldTriggerOptions, 'enabled' | 'disabled' | 'readOnly' | 'inputRef' | 'panelLabelledBy'>;
|
|
348
365
|
|
|
349
366
|
/**
|
|
350
367
|
* A cell that is not in date mode still has to CALL the trigger hook (rules of
|
|
@@ -353,7 +370,11 @@ type FieldSegmentDateConfig = Omit<UseDateFieldTriggerOptions, 'enabled' | 'disa
|
|
|
353
370
|
*/
|
|
354
371
|
const INERT_DATE_TRIGGER: UseDateFieldTriggerOptions = {
|
|
355
372
|
enabled: false,
|
|
356
|
-
|
|
373
|
+
// Placeholders for the required fields: an inert hook formats nothing (no
|
|
374
|
+
// value) and never mounts the panel, so neither is read. `enUS` is date-fns's
|
|
375
|
+
// own built-in locale — no market is implied.
|
|
376
|
+
dateFormat: '',
|
|
377
|
+
locale: enUS,
|
|
357
378
|
navLabels: { previousMonth: '', nextMonth: '', previousYear: '', nextYear: '' },
|
|
358
379
|
};
|
|
359
380
|
|
|
@@ -418,9 +439,27 @@ function FieldSegment({
|
|
|
418
439
|
// Called unconditionally — inert unless this cell is in date mode. Cell-level
|
|
419
440
|
// disabled / read-only are deferred at the visual level (see the file header),
|
|
420
441
|
// but the native attributes still reach the input, so the trigger honours them.
|
|
442
|
+
const labelId = `${resolvedId}-label`;
|
|
443
|
+
// With a group label the bound word completes the input's name („Cena od").
|
|
444
|
+
const cellLabelledBy = groupLabelId && label ? `${groupLabelId} ${labelId}` : undefined;
|
|
445
|
+
// A native form reset drops a typed or rejected draft, as in a standalone
|
|
446
|
+
// date TextField; the cell then shows its `value` again. Inert outside date
|
|
447
|
+
// mode, where the ref stays empty.
|
|
448
|
+
const dateInputRef = React.useRef<HTMLInputElement | null>(null);
|
|
449
|
+
useFormReset(dateInputRef, () => trigger.clearDraft(), inputProps.form);
|
|
421
450
|
const trigger = useDateFieldTrigger(
|
|
422
451
|
date
|
|
423
|
-
? {
|
|
452
|
+
? {
|
|
453
|
+
...date,
|
|
454
|
+
inputRef: dateInputRef,
|
|
455
|
+
// The calendar dialog carries the name of what visibly names the cell
|
|
456
|
+
// (overlay-behavior.md § Naming) — the same ids as the input; the
|
|
457
|
+
// config's `panelLabel` is the fallback for a cell with no label.
|
|
458
|
+
panelLabelledBy: cellLabelledBy ?? (label ? labelId : undefined),
|
|
459
|
+
panelLabel: date.panelLabel ?? inputProps['aria-label'],
|
|
460
|
+
disabled: Boolean(inputProps.disabled),
|
|
461
|
+
readOnly: Boolean(inputProps.readOnly),
|
|
462
|
+
}
|
|
424
463
|
: INERT_DATE_TRIGGER,
|
|
425
464
|
);
|
|
426
465
|
// In date mode the input's text comes from the trigger (the formatted Date, or
|
|
@@ -439,9 +478,6 @@ function FieldSegment({
|
|
|
439
478
|
}
|
|
440
479
|
}, [boundValue]);
|
|
441
480
|
|
|
442
|
-
const labelId = `${resolvedId}-label`;
|
|
443
|
-
// With a group label the bound word completes the input's name („Cena od").
|
|
444
|
-
const cellLabelledBy = groupLabelId && label ? `${groupLabelId} ${labelId}` : undefined;
|
|
445
481
|
// The unit is read with the value, ahead of the shared message (field-pair
|
|
446
482
|
// 1.12.0, the Unit Field suffix rule): "{unit-id} {helper-id}".
|
|
447
483
|
const unitId = unit ? `${resolvedId}-unit` : undefined;
|
|
@@ -556,7 +592,8 @@ function FieldSegment({
|
|
|
556
592
|
scopes its reset to these attributes.
|
|
557
593
|
In date mode the WHOLE CELL is the trigger — the cell padding is part of
|
|
558
594
|
it, not dead area — so the anchor ref and the open handler sit here, on
|
|
559
|
-
the same element, exactly as
|
|
595
|
+
the same element, exactly as TextField type="date" puts them on its
|
|
596
|
+
field wrapper.
|
|
560
597
|
The leading calendar glyph is what SAYS so: `_field-segment` 1.6.0 gained
|
|
561
598
|
`slots.leading-icon`, and Field Pair turns it on in both cells in date
|
|
562
599
|
mode — without it the cell opens a Date Picker while looking inert. */}
|
|
@@ -566,8 +603,8 @@ function FieldSegment({
|
|
|
566
603
|
className={cn(fieldSegmentVariants({ position }), className)}
|
|
567
604
|
>
|
|
568
605
|
{/* Decorative: the cell itself is the trigger, and the field's own label
|
|
569
|
-
is the accessible name — the same reasoning
|
|
570
|
-
leading slot. */}
|
|
606
|
+
is the accessible name — the same reasoning TextField type="date"
|
|
607
|
+
applies to its leading slot. */}
|
|
571
608
|
{date && (
|
|
572
609
|
<Icon
|
|
573
610
|
data-fods-part="leading-icon"
|
|
@@ -662,18 +699,18 @@ function FieldSegment({
|
|
|
662
699
|
|
|
663
700
|
/**
|
|
664
701
|
* Split a cell into the props the segment renders and the config its trigger
|
|
665
|
-
* owns. In date mode `value` / `onValueChange` / `minDate` / `maxDate` MUST
|
|
702
|
+
* owns. In date mode `value` / `onValueChange` / `onInvalidInput` / `minDate` / `maxDate` MUST
|
|
666
703
|
* leave the segment props: a stray `value` (a Date object) would reach the
|
|
667
704
|
* native <input> and fight the trigger's own display string, freezing the field
|
|
668
705
|
* with no warning.
|
|
669
706
|
*/
|
|
670
707
|
function splitDateCell(
|
|
671
708
|
cell: FieldPairCell | FieldPairDateCell,
|
|
672
|
-
common: Omit<FieldSegmentDateConfig, 'value' | 'onValueChange' | 'minDate' | 'maxDate'> | undefined,
|
|
709
|
+
common: Omit<FieldSegmentDateConfig, 'value' | 'onValueChange' | 'onInvalidInput' | 'minDate' | 'maxDate'> | undefined,
|
|
673
710
|
): { cell: FieldPairCell; date?: FieldSegmentDateConfig } {
|
|
674
711
|
if (!common) return { cell: cell as FieldPairCell };
|
|
675
|
-
const { value, onValueChange, minDate, maxDate, ...rest } = cell as FieldPairDateCell;
|
|
676
|
-
return { cell: rest, date: { ...common, value, onValueChange, minDate, maxDate } };
|
|
712
|
+
const { value, onValueChange, onInvalidInput, minDate, maxDate, ...rest } = cell as FieldPairDateCell;
|
|
713
|
+
return { cell: rest, date: { ...common, value, onValueChange, onInvalidInput, minDate, maxDate } };
|
|
677
714
|
}
|
|
678
715
|
|
|
679
716
|
export function FieldPair({
|
|
@@ -735,8 +772,20 @@ export function FieldPair({
|
|
|
735
772
|
const numberProps = { format, locale, precision, fixedDecimals };
|
|
736
773
|
// Panel config shared by both cells — the two PANELS stay independent, only
|
|
737
774
|
// their accessible names are shared (never both open at once).
|
|
775
|
+
// Date mode is decided by `format` alone; its required config is checked, not
|
|
776
|
+
// silently treated as "not a date pair" (a JS consumer or an empty string
|
|
777
|
+
// would otherwise get a plain text pair with no word of why).
|
|
778
|
+
const dateConfigComplete = Boolean(dateFormat && dateLocale && navLabels);
|
|
779
|
+
React.useEffect(() => {
|
|
780
|
+
if (process.env.NODE_ENV === 'production' || format !== 'date' || dateConfigComplete) return;
|
|
781
|
+
// eslint-disable-next-line no-console
|
|
782
|
+
console.error(
|
|
783
|
+
'FieldPair format="date": `dateFormat`, `dateLocale` and `navLabels` are required — '
|
|
784
|
+
+ 'the cells render as plain text inputs until all three are set.',
|
|
785
|
+
);
|
|
786
|
+
}, [format, dateConfigComplete]);
|
|
738
787
|
const dateCommon =
|
|
739
|
-
format === 'date' &&
|
|
788
|
+
format === 'date' && dateFormat && dateLocale && navLabels
|
|
740
789
|
? { dateFormat, locale: dateLocale, panelLabel, navLabels }
|
|
741
790
|
: undefined;
|
|
742
791
|
const fromCell = splitDateCell(from, dateCommon);
|
|
@@ -274,7 +274,7 @@ interface SearchHeaderProps {
|
|
|
274
274
|
query: string;
|
|
275
275
|
onQueryChange: (query: string) => void;
|
|
276
276
|
/** Combobox wiring for the single-value facet's input (`role`, `aria-*`, keys). */
|
|
277
|
-
inputProps?: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'>;
|
|
277
|
+
inputProps?: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'>;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
const SearchHeader = ({ search, query, onQueryChange, inputProps }: SearchHeaderProps) => (
|
|
@@ -772,9 +772,9 @@ function SubjectLookupFieldInner<T extends SubjectLookupItem = SubjectLookupItem
|
|
|
772
772
|
);
|
|
773
773
|
|
|
774
774
|
// Below `sm` the field is a read-only trigger that opens a dialog. It stays a
|
|
775
|
-
// `combobox` (as Combobox and
|
|
776
|
-
// `aria-expanded` nor a dialog popup, so without the role the
|
|
777
|
-
// invalid ARIA. The sheet's own search input owns the listbox contract.
|
|
775
|
+
// `combobox` (as Combobox and TextField type="date" do): a plain text input
|
|
776
|
+
// supports neither `aria-expanded` nor a dialog popup, so without the role the
|
|
777
|
+
// open state would be invalid ARIA. The sheet's own search input owns the listbox contract.
|
|
778
778
|
const fieldInteraction = isSheet
|
|
779
779
|
? ({ role: 'combobox', readOnly: true, 'aria-haspopup': 'dialog', 'aria-expanded': open } as const)
|
|
780
780
|
: {
|