@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.
Files changed (48) hide show
  1. package/AGENTS.md +4 -3
  2. package/CHANGELOG.md +18 -0
  3. package/dist/components/date-picker/DatePicker.js +1 -1
  4. package/dist/components/field/Field.d.ts +2 -1
  5. package/dist/components/field/Field.js +13 -8
  6. package/dist/components/field-pair/FieldPair.d.ts +29 -13
  7. package/dist/components/field-pair/FieldPair.js +20 -6
  8. package/dist/components/text-field/TextField.d.ts +97 -2
  9. package/dist/components/text-field/TextField.js +76 -5
  10. package/dist/components/text-field/index.d.ts +2 -2
  11. package/dist/components/textarea/Textarea.js +1 -1
  12. package/dist/components/unit-field/UnitField.js +1 -1
  13. package/dist/index.d.ts +3 -5
  14. package/dist/index.js +2 -3
  15. package/dist/internal/useDateFieldTrigger.d.ts +60 -0
  16. package/dist/internal/useDateFieldTrigger.js +68 -16
  17. package/dist/internal/useFormReset.js +10 -3
  18. package/docs/Consuming.mdx +20 -3
  19. package/llms.txt +7 -13
  20. package/package.json +1 -5
  21. package/src/components/date-picker/DatePicker.mdx +18 -14
  22. package/src/components/date-picker/DatePicker.stories.tsx +1 -1
  23. package/src/components/field/Field.tsx +40 -18
  24. package/src/components/field-pair/FieldPair.mdx +13 -9
  25. package/src/components/field-pair/FieldPair.stories.tsx +11 -2
  26. package/src/components/field-pair/FieldPair.tsx +76 -27
  27. package/src/components/filter-facet/FilterFacet.tsx +1 -1
  28. package/src/components/subject-lookup-field/SubjectLookupField.tsx +3 -3
  29. package/src/components/text-field/TextField.mdx +258 -38
  30. package/src/components/text-field/TextField.stories.tsx +311 -3
  31. package/src/components/text-field/TextField.tsx +259 -5
  32. package/src/components/text-field/index.ts +3 -0
  33. package/src/components/textarea/Textarea.mdx +2 -2
  34. package/src/components/textarea/Textarea.tsx +1 -1
  35. package/src/components/unit-field/UnitField.mdx +1 -1
  36. package/src/components/unit-field/UnitField.tsx +1 -1
  37. package/src/index.ts +0 -1
  38. package/src/internal/useDateFieldTrigger.tsx +178 -38
  39. package/src/internal/useFormReset.ts +13 -3
  40. package/src/recipes/Form.stories.tsx +5 -0
  41. package/dist/components/date-field/DateField.d.ts +0 -52
  42. package/dist/components/date-field/DateField.js +0 -45
  43. package/dist/components/date-field/index.d.ts +0 -2
  44. package/dist/components/date-field/index.js +0 -1
  45. package/src/components/date-field/DateField.mdx +0 -340
  46. package/src/components/date-field/DateField.stories.tsx +0 -221
  47. package/src/components/date-field/DateField.tsx +0 -176
  48. package/src/components/date-field/index.ts +0 -1
package/dist/index.js CHANGED
@@ -26,12 +26,11 @@ import { CardSelect, cardSelectVariants } from "./components/card-select/CardSel
26
26
  import { Checkbox, checkboxVariants } from "./components/checkbox/Checkbox.js";
27
27
  import { Chip, chipVariants } from "./components/chip/Chip.js";
28
28
  import { ColumnHeader, columnHeaderVariants } from "./components/column-header/ColumnHeader.js";
29
+ import { DatePicker } from "./components/date-picker/DatePicker.js";
29
30
  import { TextField, textFieldShellVariants, textFieldValueVariants } from "./components/text-field/TextField.js";
30
31
  import { ComboboxField } from "./components/combobox-field/ComboboxField.js";
31
32
  import { ListRow, listRowVariants } from "./components/list-row/ListRow.js";
32
33
  import { Combobox } from "./components/combobox-field/Combobox.js";
33
- import { DatePicker } from "./components/date-picker/DatePicker.js";
34
- import { DateField } from "./components/date-field/DateField.js";
35
34
  import { Drawer, drawerVariants } from "./components/drawer/Drawer.js";
36
35
  import { DropdownButton, dropdownButtonVariants } from "./components/dropdown-button/DropdownButton.js";
37
36
  import { HeadingGroup, headingGroupVariants } from "./components/heading-group/HeadingGroup.js";
@@ -72,4 +71,4 @@ import { useTableLayout } from "./internal/table/TableLayout.js";
72
71
  import { Table } from "./components/table/Table.js";
73
72
  import { UnitField, unitFieldShellVariants } from "./components/unit-field/UnitField.js";
74
73
  import { progressBarItemVariants } from "./internal/progressBarItem.js";
75
- export { ALERT_STATUS_ICONS, AVAILABLE_ICONS, ActionRow, Alert, AlertActionHelper, AlertActionLink, AnchoredPanelWithGroup as AnchoredPanel, AnchoredPanelGroup, BADGE_STATUS_ICONS, Badge, Banner, BannerAction, Button, ButtonGroup, ButtonGroupItem, CardSelect, CardSelectGroup, CardSelectGroupContext, Checkbox, Chip, ColumnHeader, Combobox, ComboboxField, DateField, DatePicker, Divider, Drawer, DropdownButton, FAQ, Field, FieldGroup, FieldLegend, FieldPair, FieldSeparator, FieldSet, FileUpload, FilterChip, FilterFacet, FirmAvatar, FodsProvider, FormActions, FormBlock, FormSection, FormSectionCell, FormSectionPair, FormSectionTrio, HEADING_SIZE_BY_LEVEL, Heading, HeadingGroup, Hero, Icon, IconButton, ItemRow, ListRow, Menu, Modal, ModalTitle, NavLink, NumberField, Pagination, PortalContainerContext, ProgressBar, PromoSticker, PromoSurface, Radio, RadioGroup, RadioGroupContext, Select, SelectField, Skeleton, SplitButton, StatusSummaryBar, SubjectLookupField, Switch, TABLE_DEFAULT_PAGE_SIZE, TABLE_PAGE_SIZE_OPTIONS, Table, TableChildRowPrefix, TextField, TextLink, Textarea, Tooltip, TooltipArrow, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, UnitField, actionRowVariants, alertVariants, badgeVariants, bannerVariants, buttonGroupContainerVariants, buttonGroupItemVariants, buttonSegmentVariants, publicButtonVariants as buttonVariants, cardSelectVariants, checkboxVariants, chipVariants, cn, columnHeaderVariants, createTableColumnHelper, dividerVariants, drawerVariants, dropdownButtonVariants, faqVariants, fieldGroupVariants, fieldLegendVariants, fieldPairContainerVariants, fieldSegmentVariants, fieldSeparatorVariants, fieldSetVariants, fileUploadVariants, filterChipVariants, firmAvatarVariants, firmInitials, floatingLabelVariants, formActionsVariants, formBlockVariants, formSectionVariants, hasOpenFloatingPanel, headingGroupVariants, headingVariants, helperTextVariants, heroVariants, iconButtonVariants, itemRowVariants, listRowVariants, modalVariants, navLinkVariants, numberFieldShellVariants, optionalLabelVariants, paginationItemVariants, paginationRange, paginationVariants, popoverBodyClass, popoverGroupClass, popoverSurfaceVariants, progressBarItemVariants, progressBarVariants, promoStickerVariants, promoSurfaceVariants, radioVariants, resolveCellSpanClasses, skeletonVariants, splitButtonContainerVariants, statusSummaryBarVariants, subjectLookupButtonVariants, subjectLookupGlyphVariants, switchVariants, tableFeatureSet, textFieldShellVariants, textFieldValueVariants, textLinkVariants, textareaCounterVariants, textareaShellVariants, textareaValueVariants, tooltipVariants, unitFieldShellVariants, useAnchoredPanel, useFormBlock, useFormBlockCloseMs, useTableLayout };
74
+ export { ALERT_STATUS_ICONS, AVAILABLE_ICONS, ActionRow, Alert, AlertActionHelper, AlertActionLink, AnchoredPanelWithGroup as AnchoredPanel, AnchoredPanelGroup, BADGE_STATUS_ICONS, Badge, Banner, BannerAction, Button, ButtonGroup, ButtonGroupItem, CardSelect, CardSelectGroup, CardSelectGroupContext, Checkbox, Chip, ColumnHeader, Combobox, ComboboxField, DatePicker, Divider, Drawer, DropdownButton, FAQ, Field, FieldGroup, FieldLegend, FieldPair, FieldSeparator, FieldSet, FileUpload, FilterChip, FilterFacet, FirmAvatar, FodsProvider, FormActions, FormBlock, FormSection, FormSectionCell, FormSectionPair, FormSectionTrio, HEADING_SIZE_BY_LEVEL, Heading, HeadingGroup, Hero, Icon, IconButton, ItemRow, ListRow, Menu, Modal, ModalTitle, NavLink, NumberField, Pagination, PortalContainerContext, ProgressBar, PromoSticker, PromoSurface, Radio, RadioGroup, RadioGroupContext, Select, SelectField, Skeleton, SplitButton, StatusSummaryBar, SubjectLookupField, Switch, TABLE_DEFAULT_PAGE_SIZE, TABLE_PAGE_SIZE_OPTIONS, Table, TableChildRowPrefix, TextField, TextLink, Textarea, Tooltip, TooltipArrow, TooltipContent, TooltipPortal, TooltipProvider, TooltipRoot, TooltipTrigger, UnitField, actionRowVariants, alertVariants, badgeVariants, bannerVariants, buttonGroupContainerVariants, buttonGroupItemVariants, buttonSegmentVariants, publicButtonVariants as buttonVariants, cardSelectVariants, checkboxVariants, chipVariants, cn, columnHeaderVariants, createTableColumnHelper, dividerVariants, drawerVariants, dropdownButtonVariants, faqVariants, fieldGroupVariants, fieldLegendVariants, fieldPairContainerVariants, fieldSegmentVariants, fieldSeparatorVariants, fieldSetVariants, fileUploadVariants, filterChipVariants, firmAvatarVariants, firmInitials, floatingLabelVariants, formActionsVariants, formBlockVariants, formSectionVariants, hasOpenFloatingPanel, headingGroupVariants, headingVariants, helperTextVariants, heroVariants, iconButtonVariants, itemRowVariants, listRowVariants, modalVariants, navLinkVariants, numberFieldShellVariants, optionalLabelVariants, paginationItemVariants, paginationRange, paginationVariants, popoverBodyClass, popoverGroupClass, popoverSurfaceVariants, progressBarItemVariants, progressBarVariants, promoStickerVariants, promoSurfaceVariants, radioVariants, resolveCellSpanClasses, skeletonVariants, splitButtonContainerVariants, statusSummaryBarVariants, subjectLookupButtonVariants, subjectLookupGlyphVariants, switchVariants, tableFeatureSet, textFieldShellVariants, textFieldValueVariants, textLinkVariants, textareaCounterVariants, textareaShellVariants, textareaValueVariants, tooltipVariants, unitFieldShellVariants, useAnchoredPanel, useFormBlock, useFormBlockCloseMs, useTableLayout };
@@ -0,0 +1,60 @@
1
+ import { DatePickerNavLabels } from "../components/date-picker/DatePicker.js";
2
+ import * as React from "react";
3
+ import { Locale } from "date-fns";
4
+ export interface UseDateFieldTriggerOptions {
5
+ /**
6
+ * `false` makes the hook inert — the panel never opens and nothing is
7
+ * rendered. A `FieldPair` cell that is not in date mode still has to CALL the
8
+ * hook (rules of hooks), so it passes `enabled: false` instead of skipping it.
9
+ */
10
+ enabled?: boolean;
11
+ /** The chosen date. Controlled. */
12
+ value?: Date;
13
+ onValueChange?: (value: Date | undefined) => void;
14
+ /**
15
+ * Display + parse pattern, date-fns syntax (e.g. `dd. MM. yyyy` for CZ,
16
+ * `MM/dd/yyyy` for US). Required, no default: the market's pattern comes from
17
+ * the consumer.
18
+ */
19
+ dateFormat: string;
20
+ /**
21
+ * The market's date-fns Locale — the panel's week start, weekday names and
22
+ * month caption, and the parse. Required, no default.
23
+ */
24
+ locale: Locale;
25
+ /** Earliest / latest selectable date. */
26
+ minDate?: Date;
27
+ maxDate?: Date;
28
+ disabled?: boolean;
29
+ readOnly?: boolean;
30
+ /**
31
+ * Id(s) of the visible text that names the field — its `<label>` — pointed at
32
+ * by the panel's `aria-labelledby`. A portalled `role="dialog"` inherits no
33
+ * name from its trigger, and the visible label is the name it should carry
34
+ * (overlay-behavior.md § Naming; COMPONENT-CODE-CONVENTIONS.md §4 "Any overlay
35
+ * panel"). When set it wins over `panelLabel`.
36
+ */
37
+ panelLabelledBy?: string;
38
+ /**
39
+ * Fallback accessible name for the calendar panel, used only when
40
+ * `panelLabelledBy` is absent — i.e. nothing visible names the field. Optional,
41
+ * because a labelled field never reads it; never defaulted, because the design
42
+ * system is locale-agnostic. With neither a labelled-by id nor a non-empty
43
+ * name the dialog would be anonymous, so the hook warns in development.
44
+ */
45
+ panelLabel?: string;
46
+ /**
47
+ * Called when a typed draft is rejected on commit: `'unparseable'` when it
48
+ * does not parse in `dateFormat`, `'out-of-range'` when it parses but falls
49
+ * outside `minDate` / `maxDate`. The typed text stays in the input and the
50
+ * value becomes `undefined`; this lets the consumer say why (Error on the
51
+ * Field).
52
+ */
53
+ onInvalidInput?: (raw: string, reason: DateInputInvalidReason) => void;
54
+ /** Accessible names for the panel's four navigation chevrons. */
55
+ navLabels: DatePickerNavLabels;
56
+ /** External ref to merge into the input (`TextField` forwards one). */
57
+ inputRef?: React.Ref<HTMLInputElement>;
58
+ }
59
+ /** Why a typed draft was rejected — see `onInvalidInput`. */
60
+ export type DateInputInvalidReason = 'unparseable' | 'out-of-range';
@@ -6,10 +6,18 @@ import * as React from "react";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { FloatingFocusManager, FloatingPortal } from "@floating-ui/react";
8
8
  import { format, isAfter, isBefore, isValid, parse, startOfDay } from "date-fns";
9
- import { cs } from "date-fns/locale/cs";
10
9
  // src/internal/useDateFieldTrigger.tsx
11
- function useDateFieldTrigger({ enabled = true, value, onValueChange, dateFormat = "dd. MM. yyyy", locale = cs, minDate, maxDate, disabled, readOnly, panelLabel, navLabels, inputRef: externalRef }) {
12
- const [open, setOpen] = React.useState(false);
10
+ function useDateFieldTrigger({ enabled = true, value, onValueChange, dateFormat, locale, minDate, maxDate, disabled, readOnly, panelLabelledBy, panelLabel, onInvalidInput, navLabels, inputRef: externalRef }) {
11
+ const [openState, setOpen] = React.useState(false);
12
+ const panelName = panelLabel?.trim() ? panelLabel : void 0;
13
+ React.useEffect(() => {
14
+ if (process.env.NODE_ENV === "production" || !enabled) return;
15
+ if (!panelLabelledBy && !panelName) console.warn("Date field: the calendar dialog has no accessible name — put the field in a labelled `Field`, or pass `aria-label` / `aria-labelledby` or `panelLabel`.");
16
+ }, [
17
+ enabled,
18
+ panelLabelledBy,
19
+ panelName
20
+ ]);
13
21
  const inputRef = React.useRef(null);
14
22
  const setInputRef = React.useCallback((node) => {
15
23
  inputRef.current = node;
@@ -19,12 +27,26 @@ function useDateFieldTrigger({ enabled = true, value, onValueChange, dateFormat
19
27
  const [openedByKeyboard, setOpenedByKeyboard] = React.useState(false);
20
28
  const panelId = React.useId();
21
29
  const canOpen = enabled && !disabled && !readOnly;
30
+ const open = openState && canOpen;
31
+ if (openState && !canOpen) setOpen(false);
22
32
  const openPanel = (byKeyboard) => {
23
33
  if (!canOpen || open) return;
24
34
  setOpenedByKeyboard(byKeyboard);
25
35
  setOpen(true);
26
36
  };
27
37
  const [draft, setDraft] = React.useState(null);
38
+ const rulesKey = `${minDate?.getTime()}|${maxDate?.getTime()}|${dateFormat}|${locale?.code}`;
39
+ const [rejectedUnder, setRejectedUnder] = React.useState(null);
40
+ const rejected = rejectedUnder !== null;
41
+ const valueTime = value?.getTime();
42
+ const [prevValueTime, setPrevValueTime] = React.useState(valueTime);
43
+ if (!Object.is(valueTime, prevValueTime)) {
44
+ setPrevValueTime(valueTime);
45
+ if (valueTime !== void 0 && rejected) {
46
+ setDraft(null);
47
+ setRejectedUnder(null);
48
+ }
49
+ }
28
50
  const displayValue = draft ?? (value ? format(value, dateFormat, { locale }) : "");
29
51
  const panel = useAnchoredPanel({
30
52
  open,
@@ -38,7 +60,7 @@ function useDateFieldTrigger({ enabled = true, value, onValueChange, dateFormat
38
60
  });
39
61
  /**
40
62
  * Anywhere in the trigger opens the calendar — the shell padding (and, in
41
- * `DateField`, the glyph) is part of the trigger, not decoration you can click
63
+ * `TextField type="date"`, the glyph) is part of the trigger, not decoration you can click
42
64
  * through. A press that missed the input keeps focus there (see
43
65
  * `handleTriggerMouseDown`), so the field stays typeable.
44
66
  *
@@ -63,6 +85,10 @@ function useDateFieldTrigger({ enabled = true, value, onValueChange, dateFormat
63
85
  * the second branch a keyboard user could only reach the grid by tabbing.
64
86
  */
65
87
  const handleTriggerKeyDown = (event) => {
88
+ if (event.key === "Enter") {
89
+ commitDraft();
90
+ return;
91
+ }
66
92
  if (event.key !== "ArrowDown") return;
67
93
  if (!open) {
68
94
  event.preventDefault();
@@ -75,30 +101,49 @@ function useDateFieldTrigger({ enabled = true, value, onValueChange, dateFormat
75
101
  day.focus();
76
102
  };
77
103
  /**
78
- * Commit a typed draft. An unparseable draft is discarded, not coerced — and
79
- * so is one that parses but falls outside `minDate` / `maxDate`: the panel
104
+ * Commit a typed draft. An unparseable draft is never coerced — and neither
105
+ * is one that parses but falls outside `minDate` / `maxDate`: the panel
80
106
  * hard-disables those days, so typing must not be a back door around the same
81
107
  * bound. Comparison is day-granular to match the panel's own matchers, where
82
108
  * `{ before: minDate }` bounds by day and a `minDate` carrying a time
83
109
  * component must still leave its own day selectable.
110
+ *
111
+ * An invalid draft stays in the input (text-field manifest 2.15.0
112
+ * `delivery.react`): the consumer's error message belongs next to the text the
113
+ * user typed, and swapping it back for the old date would read as a false
114
+ * alarm. The old date is withdrawn — `onValueChange(undefined)` — so a form
115
+ * cannot submit a date the user no longer sees.
84
116
  */
85
117
  const commitDraft = () => {
86
- if (draft === null) return;
118
+ if (draft === null || rejectedUnder === rulesKey) return;
87
119
  const trimmed = draft.trim();
88
- setDraft(null);
89
120
  if (trimmed === "") {
121
+ setDraft(null);
90
122
  onValueChange?.(void 0);
91
123
  return;
92
124
  }
125
+ const reject = (reason) => {
126
+ setRejectedUnder(rulesKey);
127
+ if (value !== void 0) onValueChange?.(void 0);
128
+ onInvalidInput?.(draft, reason);
129
+ };
93
130
  const parsed = parse(trimmed, dateFormat, /* @__PURE__ */ new Date(), { locale });
94
- if (!isValid(parsed)) return;
131
+ if (!isValid(parsed)) {
132
+ reject("unparseable");
133
+ return;
134
+ }
95
135
  const day = startOfDay(parsed);
96
- if (minDate && isBefore(day, startOfDay(minDate))) return;
97
- if (maxDate && isAfter(day, startOfDay(maxDate))) return;
136
+ if (minDate && isBefore(day, startOfDay(minDate)) || maxDate && isAfter(day, startOfDay(maxDate))) {
137
+ reject("out-of-range");
138
+ return;
139
+ }
140
+ setDraft(null);
141
+ setRejectedUnder(null);
98
142
  onValueChange?.(parsed);
99
143
  };
100
144
  const handleSelect = (next) => {
101
145
  setDraft(null);
146
+ setRejectedUnder(null);
102
147
  onValueChange?.(next);
103
148
  setOpen(false);
104
149
  inputRef.current?.focus();
@@ -121,6 +166,7 @@ function useDateFieldTrigger({ enabled = true, value, onValueChange, dateFormat
121
166
  value: displayValue,
122
167
  onChange: (event) => {
123
168
  setDraft(event.target.value);
169
+ setRejectedUnder(null);
124
170
  userChange?.(event);
125
171
  },
126
172
  onBlur: (event) => {
@@ -131,16 +177,22 @@ function useDateFieldTrigger({ enabled = true, value, onValueChange, dateFormat
131
177
  handleTriggerKeyDown(event);
132
178
  userKeyDown?.(event);
133
179
  },
134
- role: "combobox",
135
- "aria-haspopup": "dialog",
136
- "aria-expanded": open,
137
- "aria-controls": open ? panelId : void 0
180
+ ...enabled && !readOnly ? {
181
+ role: "combobox",
182
+ "aria-haspopup": "dialog",
183
+ "aria-expanded": open,
184
+ "aria-controls": open ? panelId : void 0
185
+ } : {}
138
186
  };
139
187
  };
140
188
  return {
141
189
  open,
142
190
  displayValue,
143
191
  setInputRef,
192
+ clearDraft: () => {
193
+ setDraft(null);
194
+ setRejectedUnder(null);
195
+ },
144
196
  triggerProps: {
145
197
  ref: panel.refs.setReference,
146
198
  onMouseDown: handleTriggerMouseDown,
@@ -160,7 +212,7 @@ function useDateFieldTrigger({ enabled = true, value, onValueChange, dateFormat
160
212
  className: "z-dropdown outline-none",
161
213
  ...panel.getFloatingProps({
162
214
  id: panelId,
163
- "aria-label": panelLabel
215
+ ...panelLabelledBy ? { "aria-labelledby": panelLabelledBy } : panelName ? { "aria-label": panelName } : {}
164
216
  }),
165
217
  children: /* @__PURE__ */ jsx("div", {
166
218
  className: popoverSurfaceVariants({ className: "gap-0 py-0" }),
@@ -8,7 +8,10 @@ import * as React from "react";
8
8
  * `change`/`input`, so state an uncontrolled component mirrors from `onChange`
9
9
  * (emptiness, checked, a character count) would go stale. The `reset` event is
10
10
  * dispatched BEFORE the browser restores the values — and is cancelable — so the
11
- * value is read one task later, which also covers a reset that was prevented.
11
+ * value is read one task later. A reset that was prevented restores nothing, so
12
+ * `onReset` is skipped when every reset in that task was canceled: a callback
13
+ * that writes a default (a date field's `defaultValue`) must not run when the
14
+ * native controls kept theirs.
12
15
  *
13
16
  * `formAttr` is the control's `form` attribute: changing it re-associates the
14
17
  * control with another form, so the listener is moved along.
@@ -20,11 +23,15 @@ function useFormReset(elementRef, onReset, formAttr) {
20
23
  const form = elementRef.current?.form;
21
24
  if (!form) return;
22
25
  let timeout;
23
- const handleReset = () => {
26
+ let pending = [];
27
+ const handleReset = (event) => {
24
28
  clearTimeout(timeout);
29
+ pending.push(event);
25
30
  timeout = setTimeout(() => {
26
31
  const element = elementRef.current;
27
- if (element) onResetRef.current(element);
32
+ const restored = pending.some((e) => !e.defaultPrevented);
33
+ pending = [];
34
+ if (element && restored) onResetRef.current(element);
28
35
  }, 0);
29
36
  };
30
37
  form.addEventListener("reset", handleReset);
@@ -273,7 +273,7 @@ Several components render outside their place in the DOM:
273
273
  `FilterFacet` and `SubjectLookupField` are Radix dialogs portalled to `document.body`.
274
274
  - The bubble of `Tooltip` is portalled to `document.body`.
275
275
  - The floating panels (`AnchoredPanel`, and the desktop panels of `Menu`, `Select`,
276
- `Combobox`, `FilterFacet`, `SubjectLookupField`, `DateField`, `FieldPair` and the column
276
+ `Combobox`, `FilterFacet`, `SubjectLookupField`, a `TextField` with `type="date"`, `FieldPair` and the column
277
277
  settings of `Table`) and the `toggletip` bubble portal into the enclosing `Modal` or
278
278
  `Drawer` when their trigger sits inside one, and to `document.body` otherwise. Inside a
279
279
  dialog they have to, to stay inside its focus trap.
@@ -362,8 +362,25 @@ Some of them never show in a visual check: `loadedLabel`, Modal `closeLabel`, th
362
362
 
363
363
  Number and date formatting default to Czech as well: `locale` is `'cs'` on `NumberField`,
364
364
  `UnitField`, `FieldPair`, `ItemRow` and `FilterChip`, and the `cs` locale of date-fns on
365
- `DatePicker`, `DateField` and a `FieldPair` in date mode (there the prop is `dateLocale`):
366
- weekday names, month caption, week start.
365
+ `DatePicker`: weekday names, month caption, week start.
366
+
367
+ A date field has no default at all. A `TextField` with `type="date"` and a `FieldPair` in
368
+ date mode require the market's date format and date-fns locale: `dateFormat` and `locale`
369
+ on `TextField`, `dateFormat` and `dateLocale` on `FieldPair`. The field shows and parses the
370
+ typed text in that format and hands back a `Date`; converting it to what your API stores is
371
+ yours.
372
+
373
+ ```tsx
374
+ <TextField
375
+ type="date"
376
+ dateFormat={market.dateFormat} // 'dd. MM. yyyy' cs, 'MM/dd/yyyy' en-US, 'dd-MM-yyyy' nl
377
+ locale={market.dateLocale} // the date-fns Locale of the same market
378
+ value={issuedOn} // a Date, parsed from your API value
379
+ onValueChange={setIssuedOn} // a Date, or undefined when cleared
380
+ aria-label="Datum vystavení" // or a labelled Field; the calendar takes the same name
381
+ navLabels={navLabels}
382
+ />
383
+ ```
367
384
 
368
385
  ## Known gaps
369
386
 
package/llms.txt CHANGED
@@ -57,7 +57,7 @@ Copied from `AGENTS.md` → Rules, the single source; a change goes there.
57
57
  resolves the same copy of `motion` as the package.
58
58
  - **Portals:** Modal, Drawer, the mobile bottom sheets and the Tooltip bubble portal to
59
59
  `document.body`; the desktop floating panels (AnchoredPanel, Menu, Select, Combobox,
60
- DateField…) and the toggletip bubble go into the enclosing Modal or Drawer, else
60
+ `TextField type="date"`…) and the toggletip bubble go into the enclosing Modal or Drawer, else
61
61
  `document.body`. To portal elsewhere, provide the element through `PortalContainerContext`.
62
62
  - **Assets:** `dist/assets/` travels with `styles.css` / `shared.css` (`url()` relative to
63
63
  the stylesheet); only PromoSurface (a background image) and PromoSticker (a CSS mask, CORS
@@ -74,8 +74,9 @@ Copied from `AGENTS.md` → Rules, the single source; a change goes there.
74
74
  default (Modal `closeLabel`, Pagination `labels`, Table `loadedLabel` and
75
75
  `mobile.moreLabel`, FilterFacet `doneLabel`, FileUpload `triggerLabel`, `dropHintText`,
76
76
  `viewLabel`, `removeLabel` and `uploadingLabel`), and number and date formatting defaults
77
- to Czech (`locale` of NumberField, UnitField, FieldPair, ItemRow, FilterChip, DatePicker,
78
- DateField; `dateLocale` of a date FieldPair). The hidden close button of the mobile bottom
77
+ to Czech (`locale` of NumberField, UnitField, FieldPair, ItemRow, FilterChip, DatePicker).
78
+ A date field has no default: `TextField type="date"` requires `dateFormat` + `locale`, a
79
+ date FieldPair `dateFormat` + `dateLocale`, both the market's. The hidden close button of the mobile bottom
79
80
  sheets defaults to «Zavřít»; Menu, Select, Combobox, FilterFacet and SubjectLookupField
80
81
  take its name in `sheetCloseLabel`. An app with more than one language version passes
81
82
  every one of these from its translations on every use, including the screen-reader-only
@@ -100,8 +101,8 @@ Copied from `AGENTS.md` → Rules, the single source; a change goes there.
100
101
 
101
102
  - Import: `import { ActionRow } from '@invoiceonline/ui-react'` or `from '@invoiceonline/ui-react/action-row'`
102
103
  - Exports: `ActionRow`, `actionRowVariants`
103
- - Summary: Firm row in the account menu — one row per firm; selecting a row switches the active firm.
104
- - When to use: Use inside the account menu to list and switch firms — one row per firm, selecting a row switches the active firm (Show avatar on: Firm Avatar Size=sm, Fill follows State — Solid on Selected, Subtle otherwise). Also used for manageable-entity rows (bank accounts, units) on a management surface — there use Show leading with an entity glyph instead of the avatar. NOT a listbox option and NOT a ListRow — its inner button (a real <button>, not the row element) holds real DOM focus via roving tabindex, with the action icons as its siblings, so reach for it only where a row must both navigate and be acted on.
104
+ - Summary: A row the user picks and acts on — a firm in the account menu, a bank account in a form.
105
+ - When to use: Use inside the account menu to list and switch firms — one row per firm, selecting a row switches the active firm (Show avatar on: Firm Avatar Size=sm, Fill follows State — Solid on Selected, Subtle otherwise). Also used for manageable-entity rows (bank accounts, units) on a management surface — there use Show leading with an entity glyph instead of the avatar. NOT a listbox option and NOT a ListRow — its inner button (a real <button>, not the row element) holds real DOM focus via roving tabindex, with the action icons as its siblings, so reach for it only where a row must both navigate and be acted on. Two kinds of row action, never interchangeable: a HOVER ACTION is an edit done in place, in the row, with no surface opening (rename, set home) — revealed on hover or keyboard focus, Desktop only; a BUTTON is an action that opens something (a form, a confirmation) — an Icon Button in the `buttons` slot, visible at all times on both platforms. The invoice form's bank-account list is the first consumer of the slot (edit opens the account form, delete opens a confirmation).
105
106
  - Docs: `src/components/action-row/ActionRow.mdx`, examples in `ActionRow.stories.tsx`, props in `ActionRow.tsx`; Storybook docs ID `design-system-atoms-actionrow--docs`
106
107
 
107
108
  ### Alert
@@ -191,13 +192,6 @@ Copied from `AGENTS.md` → Rules, the single source; a change goes there.
191
192
  - When to use: Use as the GENERIC TRIGGER for a type-to-narrow picker over a set too large to scan, where picking commits one plain value into the field. It opens the Combobox / Search or Combobox / Inline overlay. NOT for the ARES subject lookup — the customer (Odběratel) and supplier (Dodavatel) search that queries saved contacts and the registry at once, autofills the identity block and collapses to a summary card is its own molecule (→ Subject Lookup Field). NOT for a scannable fixed set (→ Select Field), free-form text (→ Text Field), or dates (→ Date Picker).
192
193
  - Docs: `src/components/combobox-field/ComboboxField.mdx`, examples in `ComboboxField.stories.tsx`, props in `ComboboxField.tsx`; Storybook docs ID `design-system-molecules-comboboxfield--docs`
193
194
 
194
- ### DateField
195
-
196
- - Import: `import { DateField } from '@invoiceonline/ui-react'` or `from '@invoiceonline/ui-react/date-field'`
197
- - Exports: `DateField`
198
- - Summary: No manifest in the FODS spec; the MDX page and the source are the reference.
199
- - Docs: `src/components/date-field/DateField.mdx`, examples in `DateField.stories.tsx`, props in `DateField.tsx`; Storybook docs ID `design-system-molecules-datefield--docs`
200
-
201
195
  ### DatePicker
202
196
 
203
197
  - Import: `import { DatePicker } from '@invoiceonline/ui-react'` or `from '@invoiceonline/ui-react/date-picker'`
@@ -460,7 +454,7 @@ Copied from `AGENTS.md` → Rules, the single source; a change goes there.
460
454
  - Import: `import { SelectField } from '@invoiceonline/ui-react'` or `from '@invoiceonline/ui-react/select-field'`
461
455
  - Exports: `SelectField`
462
456
  - Summary: The closed trigger of a single-select dropdown — a Text Field shell with a caret; opens a listbox panel of options.
463
- - When to use: Use to pick ONE value from a fixed, known set (currency, country, VAT rate, payment method). NOT for free-form text (→ Text Field), a searchable/typed set (→ Combobox Field), multi-select or toggles (→ a Popover + checkbox list), or navigation/commands (→ Menu). This component is the TRIGGER only; the option panel is composed separately (Popover surface + List Row) — see rules.
457
+ - When to use: Use to pick ONE value from a fixed, known set (country, VAT rate, payment method). A set long enough to be typed into, currency included, is a Combobox Field. NOT for free-form text (→ Text Field), a searchable/typed set (→ Combobox Field), multi-select or toggles (→ a Popover + checkbox list), or navigation/commands (→ Menu). This component is the TRIGGER only; the option panel is composed separately (Popover surface + List Row) — see rules.
464
458
  - Docs: `src/components/select-field/SelectField.mdx`, examples in `SelectField.stories.tsx`, props in `SelectField.tsx`; Storybook docs ID `design-system-molecules-selectfield--docs`
465
459
 
466
460
  ### Skeleton
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invoiceonline/ui-react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "React components of FODS, the FakturaOnline design system, with the design tokens they are built on.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -74,10 +74,6 @@
74
74
  "types": "./dist/components/combobox-field/index.d.ts",
75
75
  "default": "./dist/components/combobox-field/index.js"
76
76
  },
77
- "./date-field": {
78
- "types": "./dist/components/date-field/index.d.ts",
79
- "default": "./dist/components/date-field/index.js"
80
- },
81
77
  "./date-picker": {
82
78
  "types": "./dist/components/date-picker/index.d.ts",
83
79
  "default": "./dist/components/date-picker/index.js"
@@ -15,7 +15,7 @@ import * as DatePickerStories from './DatePicker.stories';
15
15
 
16
16
  ## Overview
17
17
 
18
- `DatePicker` is the **calendar content a date field opens** — for an invoice issue / due date, an expense date or a report period. It has two layout modes: **Single month** picks **one day** (the everyday form case) and **Dual month** picks a **range** across two months. This component is the **content only — it paints no surface** (no fill, border, radius or shadow, manifest 1.0.0). The **host** owns the surface: an anchored date field wraps it in the [Popover surface recipe](?path=/docs/design-system-patterns-popover-surface--docs), a filter drawer or bottom sheet is the surface itself. [`DateField`](?path=/docs/design-system-molecules-datefield--docs) is the trigger that anchors it and owns the `role="dialog"` semantics. Every story on this page renders it inside that Popover surface host.
18
+ `DatePicker` is the **calendar content a date field opens** — for an invoice issue / due date, an expense date or a report period. It has two layout modes: **Single month** picks **one day** (the everyday form case) and **Dual month** picks a **range** across two months. This component is the **content only — it paints no surface** (no fill, border, radius or shadow, manifest 1.0.0). The **host** owns the surface: an anchored date field wraps it in the [Popover surface recipe](?path=/docs/design-system-patterns-popover-surface--docs), a filter drawer or bottom sheet is the surface itself. [`TextField type="date"`](?path=/story/design-system-atoms-textfield--date-mode) is the trigger that anchors it and owns the `role="dialog"` semantics; a date field is that atom, not a separate component. Every story on this page renders it inside that Popover surface host.
19
19
 
20
20
  Reach for it whenever a field needs a calendar. Do **not** use it as an always-visible inline calendar (a different, unbuilt pattern), as a month/year jump picker, or as a scheduling grid — it is the popover a trigger opens and dismisses.
21
21
 
@@ -124,7 +124,7 @@ A **date range** on mobile is not this component at all: it is a [`FieldPair`](?
124
124
 
125
125
  ### Who does the swap
126
126
 
127
- **Nothing here switches automatically, by design.** The spec puts the swap in the *consuming form*, not in this component: *"a breakpoint-level change in the consuming form, not a Date Picker variant"*. There is no `useIsMobile` anywhere in `DatePicker` / `DateField` / `FieldPair` — the only responsive thing in the whole family is the `md:` padding class above.
127
+ **Nothing here switches automatically, by design.** The spec puts the swap in the *consuming form*, not in this component: *"a breakpoint-level change in the consuming form, not a Date Picker variant"*. There is no `useIsMobile` anywhere in `DatePicker` / `TextField` / `FieldPair` — the only responsive thing in the whole family is the `md:` padding class above.
128
128
 
129
129
  That is not an omission. The two forms do not hold the same data: the dual panel owns **one** `DateRange` (`{ from, to }`) with one `onValueChange`, while a FieldPair owns **two independent** dates with two callbacks and its own reactive range error. Swapping is a change of form state, not of appearance, so the form has to own it:
130
130
 
@@ -137,7 +137,8 @@ return isMobile ? (
137
137
  <FieldPair
138
138
  format="date"
139
139
  showUnit={false}
140
- panelLabel={t('datePicker.panel')}
140
+ dateFormat={market.dateFormat} // the market's pattern and date-fns Locale, no default
141
+ dateLocale={market.dateLocale}
141
142
  navLabels={navLabels}
142
143
  aria-label={t('filter.period')}
143
144
  from={{ label: t('from'), value: from, onValueChange: setFrom, error: invalid }}
@@ -293,7 +294,7 @@ accessible name that only a screen reader ever hears is the one that ships untra
293
294
 
294
295
  ## Do / Don't
295
296
 
296
- - ✅ Open it from a date field as an **anchored overlay** (`DateField` owns the trigger and the dialog role)
297
+ - ✅ Open it from a date field as an **anchored overlay** (`TextField type="date"` owns the trigger and the dialog role)
297
298
  - ✅ Put it inside a **host surface** — the Popover surface recipe for an anchored panel, the drawer or sheet itself on mobile
298
299
  - ✅ Pick the variant by task: one day → `single-month`, a range → `dual-month`
299
300
  - ✅ Let the **locale** decide the first weekday and the abbreviations
@@ -314,7 +315,7 @@ accessible name that only a screen reader ever hears is the one that ships untra
314
315
 
315
316
  ## Accessibility
316
317
 
317
- - **Semantics** — the **host** is the `role="dialog"` (anchored Popover surface, sheet or drawer), named by `aria-labelledby` / `aria-label`; the Date Picker itself renders no dialog. For a date field the dialog role, anchoring and dismissal are set by **`DateField`** (`useDateFieldTrigger`) on the floating wrapper it renders *around* this component, which is also where the Popover surface is drawn. Each month is a `role="grid"` with `role="row"` rows and `role="gridcell"` cells. The selectable content of a cell is a `<button>` **that fills the whole 48×36 cell**; the 36px indicator disc is a non-interactive `<span>` inside it.
318
+ - **Semantics** — the **host** is the `role="dialog"` (anchored Popover surface, sheet or drawer), named by `aria-labelledby` / `aria-label`; the Date Picker itself renders no dialog. For a date field the dialog role, anchoring and dismissal are set by **`TextField type="date"`** (through the internal `useDateFieldTrigger`) on the floating wrapper it renders *around* this component, named by the field's visible label through `aria-labelledby` (`panelLabel` only when nothing visible names the field); the Popover surface is drawn inside that wrapper. Each month is a `role="grid"` with `role="row"` rows and `role="gridcell"` cells. The selectable content of a cell is a `<button>` **that fills the whole 48×36 cell**; the 36px indicator disc is a non-interactive `<span>` inside it.
318
319
  - **Keyboard** — each grid holds **one** roving `tabindex`, and it is literally one tab stop: exactly one day button carries `tabindex="0"` — the **selected date, else today, else the first day** — and every other day carries `tabindex="-1"`. Arrow keys move the focused day; `Home` / `End` jump to the start / end of the week; `PageUp` / `PageDown` page by **month**; `Shift+PageUp` / `Shift+PageDown` page by **year** (single month); `Enter` / `Space` selects; `Esc` closes the overlay and returns focus to the trigger. The chevrons sit in the tab order as a pointer shortcut for the same paging.
319
320
  - **Focus** — a single roving `:focus-visible` ring owned by the grid, drawn as an inset double band inside the disc, never a per-cell resting border and never an offset ring (see [States](#states)). `:focus-visible`, `Enter` / `Space` and the ring all belong to the **button**, never to the disc — the disc is only where the ring is *painted*. The chevrons carry their own `IconButton` focus rings. `autoFocus` moves focus into the grid on mount, landing on the selected day (or today) — an overlay consumer should set it so the keyboard lands on a date, not on the first chevron.
320
321
  - **ARIA state** — `aria-selected="true"` on the chosen date; out-of-range days carry **both** the native `disabled` attribute and `aria-disabled="true"`. Each grid is named by its own caption through `aria-labelledby` (`Duben 2023`), so the name can never drift from the text on screen.
@@ -327,20 +328,23 @@ Accessibility floor for every FODS component: `spec/01-foundations/accessibility
327
328
  ## Usage
328
329
 
329
330
  ```tsx
330
- // Good — single day in a form, opened from a DateField
331
+ // Good — single day in a form: a date field is TextField type="date", which
332
+ // opens this panel in the Popover surface for you. The market's format and
333
+ // locale are required (no Czech default), as are the dialog and chevron names.
331
334
  const [issuedOn, setIssuedOn] = React.useState<Date | undefined>();
332
335
 
333
- // DateField renders this for you — shown here to make the host visible.
334
- <div role="dialog" aria-label="Datum vystavení" className={popoverSurfaceVariants({ className: 'gap-0 py-0' })}>
335
- <DatePicker
336
- variant="single-month"
336
+ <Field label="Datum vystavení">
337
+ <TextField
338
+ id="issued-on"
339
+ type="date"
340
+ dateFormat="dd. MM. yyyy"
341
+ locale={cs}
337
342
  navLabels={navLabels}
338
343
  value={issuedOn}
339
344
  onValueChange={setIssuedOn}
340
345
  minDate={new Date(2023, 0, 1)}
341
- autoFocus
342
346
  />
343
- </div>;
347
+ </Field>;
344
348
  ```
345
349
 
346
350
  ```tsx
@@ -373,8 +377,8 @@ const [period, setPeriod] = React.useState<DateRange | undefined>({
373
377
 
374
378
  ## Related
375
379
 
376
- - [`DateField`](?path=/docs/design-system-molecules-datefield--docs) — the trigger that opens and anchors this panel, and owns the dialog semantics
377
- - [`TextField`](?path=/docs/design-system-atoms-textfield--docs) — the input shell `DateField` reuses
380
+ - [`TextField type="date"`](?path=/story/design-system-atoms-textfield--date-mode) — the trigger that opens and anchors this panel, and owns the dialog semantics; [another market](?path=/story/design-system-atoms-textfield--date-other-market) shows the consumer's `dateFormat` + `locale` at work
381
+ - [`TextField`](?path=/docs/design-system-atoms-textfield--docs) — the atom whose `type="date"` mode is the date field
378
382
  - [`Field`](?path=/docs/design-system-atoms-field--docs) — floating label / helper / error chrome around the field
379
383
  - [`IconButton`](?path=/docs/design-system-atoms-iconbutton--docs) — the four header chevrons (`variant="secondary"`, `size="sm"`)
380
384
  - [`Popover Surface`](?path=/docs/design-system-patterns-popover-surface--docs) — the **host** of an anchored picker since 1.0.0: `popoverSurfaceVariants`, padless (`gap-0 py-0`), draws the fill, border, radius and `--shadow-overlay` the picker no longer has
@@ -162,7 +162,7 @@ const meta = {
162
162
  description: {
163
163
  component: componentDoc({
164
164
  summary:
165
- 'The calendar content a date field opens — Single month to pick one day, Dual month to pick a range. It paints no surface of its own (1.0.0): the host draws fill, border, radius and shadow — the Popover surface recipe for an anchored panel, the drawer or sheet itself on mobile. `DateField` is the trigger that anchors it. Built on react-day-picker with every visual bound to FODS tokens (its own stylesheet is never imported).',
165
+ 'The calendar content a date field opens — Single month to pick one day, Dual month to pick a range. It paints no surface of its own (1.0.0): the host draws fill, border, radius and shadow — the Popover surface recipe for an anchored panel, the drawer or sheet itself on mobile. `TextField type="date"` is the trigger that anchors it. Built on react-day-picker with every visual bound to FODS tokens (its own stylesheet is never imported).',
166
166
  useCases: [
167
167
  '`variant="single-month"` — one day in a form: expense date, invoice issue / due date. Its header adds year double-chevrons (« ») so a form user can jump years fast',
168
168
  '`variant="dual-month"` — a range across a month boundary: filters, accounting period, report window. Month chevrons only, no year jump',
@@ -355,10 +355,11 @@ function hasInputAdornments(childProps: any): boolean {
355
355
  interface FieldChildTraits {
356
356
  /**
357
357
  * The label never rests inside: the field always shows a value, a placeholder
358
- * or a trigger glyph. DateField is deliberately absent — it is a Text Field
359
- * sibling and follows the one floating-label rule (spec text-field.md §
360
- * States), so an empty, unfocused, valid date field rests its label inside;
361
- * with a format `placeholder` it floats through `hasPlaceholder` instead.
358
+ * or a trigger glyph. `TextField type="date"` deliberately does not set it —
359
+ * it is a Text Field and follows the one floating-label rule (spec
360
+ * text-field.md § States), so an empty, unfocused, valid date field rests its
361
+ * label inside; with a format `placeholder` it floats through `hasPlaceholder`
362
+ * instead.
362
363
  */
363
364
  autoFloating?: boolean;
364
365
  /**
@@ -378,19 +379,32 @@ interface FieldChildTraits {
378
379
  /**
379
380
  * What the wrapper needs to know about a field it cannot read off the rendered
380
381
  * element, keyed by `displayName` (the only identity a cloned child exposes).
381
- * One entry per field so a new one is registered in a single place.
382
+ * One entry per field so a new one is registered in a single place. An entry
383
+ * that depends on a MODE of the field reads the child's props.
382
384
  */
383
- const FIELD_CHILD_TRAITS: Record<string, FieldChildTraits> = {
384
- // DateField renders a TextField, so it inherits the dash.
385
- DateField: { leadingIcon: 'always', emptyDash: 'disabled-or-readonly' },
385
+ const FIELD_CHILD_TRAITS: Record<
386
+ string,
387
+ FieldChildTraits | ((childProps: FieldChildProps) => FieldChildTraits)
388
+ > = {
386
389
  NumberField: { autoFloating: true },
387
390
  Select: { autoFloating: true },
388
391
  SelectField: { autoFloating: true, emptyDash: 'disabled' },
389
- TextField: { emptyDash: 'disabled-or-readonly' },
392
+ // `type="date"` forces the calendar glyph into the leading slot on the shell
393
+ // it renders internally, so the prop never shows on the child Field inspects.
394
+ // The date mode is still a TextField, so it keeps the dash.
395
+ TextField: childProps => ({
396
+ emptyDash: 'disabled-or-readonly',
397
+ ...(childProps.type === 'date' ? { leadingIcon: 'always' } : {}),
398
+ }),
390
399
  Textarea: { emptyDash: 'disabled' },
391
400
  UnitField: { autoFloating: true },
392
401
  };
393
402
 
403
+ function resolveChildTraits(childType: string, childProps: FieldChildProps): FieldChildTraits {
404
+ const entry = FIELD_CHILD_TRAITS[childType];
405
+ return typeof entry === 'function' ? entry(childProps) : (entry ?? {});
406
+ }
407
+
394
408
  export type FieldSize = 'md' | 'sm';
395
409
 
396
410
  export interface FieldProps {
@@ -434,10 +448,12 @@ export interface FieldProps {
434
448
 
435
449
  interface FieldChildProps {
436
450
  id?: string;
437
- // `Date` covers DateField, whose value is the date itself rather than the
438
- // formatted string the input displays.
451
+ // Read by the traits map: `TextField type="date"` is a mode with its own traits.
452
+ type?: string;
453
+ // `Date` covers `TextField type="date"`, whose value is the date itself rather
454
+ // than the formatted string the input displays.
439
455
  value?: string | number | readonly string[] | Date;
440
- defaultValue?: string | number | readonly string[];
456
+ defaultValue?: string | number | readonly string[] | Date;
441
457
  placeholder?: string;
442
458
  disabled?: boolean;
443
459
  readOnly?: boolean;
@@ -460,7 +476,8 @@ interface FieldChildProps {
460
476
  // hands the label's id down and the child points its panel at it.
461
477
  'aria-label'?: string;
462
478
  'aria-labelledby'?: string;
463
- // Combobox: same hand-down, but onto the panel only — its input is named by `htmlFor`.
479
+ // Combobox and `TextField type="date"`: same hand-down, but onto the panel only
480
+ // — their input is named by `htmlFor`.
464
481
  panelLabelledBy?: string;
465
482
  // Select-specific props
466
483
  state?: 'default' | 'error' | 'success' | 'focused' | 'disabled' | 'readonly';
@@ -498,7 +515,7 @@ const Field: React.FC<FieldProps> = ({
498
515
  const disabled = childProps.disabled ?? childProps.state === 'disabled';
499
516
 
500
517
  const childType = (children.type as any)?.displayName || (children.type as any)?.name || '';
501
- const childTraits = FIELD_CHILD_TRAITS[childType] ?? {};
518
+ const childTraits = resolveChildTraits(childType, childProps);
502
519
 
503
520
  // Check if component has adornments (prefix/suffix) that would overlap with non-floating label
504
521
  const hasAdornments = hasInputAdornments(childProps);
@@ -510,6 +527,10 @@ const Field: React.FC<FieldProps> = ({
510
527
 
511
528
  const shouldAutoFloat = Boolean(childTraits.autoFloating) || hasAdornments;
512
529
  const isSelect = childType === 'Select';
530
+ // The children whose portalled panel takes its name from this label: Combobox's
531
+ // listbox and the date mode's calendar dialog.
532
+ const namesPanel =
533
+ childType === 'Combobox' || (childType === 'TextField' && childProps.type === 'date');
513
534
 
514
535
  const isReadOnly = childProps.readOnly ?? childProps.state === 'readonly';
515
536
 
@@ -639,10 +660,11 @@ const Field: React.FC<FieldProps> = ({
639
660
  state: error ? 'error' : success ? 'success' : childProps.state,
640
661
  ...(error ? { 'aria-invalid': true } : {}),
641
662
  'aria-describedby': displayHelperText && fieldId ? `${fieldId}-helper` : undefined,
642
- // Combobox's portalled listbox takes its name from this label too
643
- // (overlay-behavior.md § Naming). Unlike Select, the input is already named
644
- // through `htmlFor`, so the reference goes to the panel alone.
645
- ...(childType === 'Combobox' && label
663
+ // Combobox's portalled listbox and the date mode's calendar dialog take
664
+ // their name from this label too (overlay-behavior.md § Naming). Unlike
665
+ // Select, the input is already named through `htmlFor`, so the reference
666
+ // goes to the panel alone.
667
+ ...(namesPanel && label
646
668
  ? { panelLabelledBy: childProps.panelLabelledBy ?? labelId }
647
669
  : {}),
648
670
  });