Skip to content

Commit b968dee

Browse files
zernoniaclaude
andauthored
feat(v3): date and time field composables (#2723) (#3073)
* refactor(DateField): shared segment field surfaces and navigation Rename the internal segment composable to useDateFieldSegment; it now commits through setModelValue(value, reason, event). Add segmentField.ts with the segment and root part surfaces, the segment navigation, the locale watcher and the change bridge that the six date and time families share. Part of #2723. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(DateField)!: useDateField composable with change details DateFieldRoot and DateFieldInput become thin shells over useDateField(). modelValue and placeholder go through useControllableState: a cancellable beforeUpdate:* fires before update:*(value, details), with a DateFieldChangeReason (segment-input, segment-increment, segment-decrement, segment-clear, step-snap). A cancelled typed change puts the segments back. null is a controlled empty field, and an unchanged value emits nothing. BREAKING CHANGE: update:modelValue and update:placeholder receive a details argument. The root context's modelValue and placeholder are writable computeds that report imperative-action; setModelValue and setPlaceholder are new. The time zone segment renders data-readonly="" instead of "true". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(TimeField)!: useTimeField composable with change details TimeFieldRoot and TimeFieldInput become thin shells over useTimeField(), with the same model contract as DateField and a TimeFieldChangeReason. New isTimeUnavailable prop, which receives the time as a date-time and marks the field invalid. BREAKING CHANGE: update:modelValue and update:placeholder receive a details argument. update:placeholder emits a Time when the placeholder is a Time (it emitted a CalendarDateTime). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(DateRangeField)!: useDateRangeField composable with change details DateRangeFieldRoot and DateRangeFieldInput become thin shells over useDateRangeField(). A typed change to either end commits the whole range with a DateRangeFieldChangeReason. New stepSnapping prop, as on DateField. The context reuses DateRange and gains setModelValue, setRangeValue and setPlaceholder. BREAKING CHANGE: update:modelValue and update:placeholder receive a details argument. The modelValue slot prop is typed DateRange, empty as { start: undefined, end: undefined } (it was DateRange | null). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(TimeRangeField)!: useTimeRangeField composable with change details TimeRangeFieldRoot and TimeRangeFieldInput become thin shells over useTimeRangeField(), with a TimeRangeFieldChangeReason and a new stepSnapping prop. BREAKING CHANGE: update:modelValue and update:placeholder receive a details argument. The modelValue slot prop is typed TimeRange (it was TimeRange | undefined). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(RangeCalendar)!: update:startValue carries change details update:startValue receives (date, details) with the press reason and event. The start watcher keeps its own copy of the pending reason: the [startValue, endValue] watcher runs first and reset it, so the start and the placeholder that follows it reported imperative-action instead of cell-press. BREAKING CHANGE: update:startValue receives a details argument. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(DatePicker)!: useDatePicker composes the field, popover and calendar useDatePicker() owns the value, placeholder, open (through usePopover) and view models. DatePickerRoot provides the Popover context itself instead of rendering PopoverRoot. The field and calendar are controlled by the picker: their beforeUpdate:modelValue runs the picker's change, so each change emits one beforeUpdate/update pair from the root with a DatePickerChangeReason, and a cancel on the root undoes the typed segments. getFieldProps() and getCalendarProps() compose useDateField() and useCalendar() standalone. stepSnapping now reaches the field. BREAKING CHANGE: update:modelValue and update:placeholder receive a details argument. DatePickerRoot no longer renders a PopoverRoot component. onDateChange and onPlaceholderChange on the context take an optional reason and event and return a boolean. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(DateRangePicker)!: useDateRangePicker composes the field, popover and calendar The range picker follows DatePicker: useDateRangePicker() owns the range, placeholder, start value, open and view models, the root provides the Popover context, and the field and range calendar are bridged into one emit pair with a DateRangePickerChangeReason. startValue is a model with beforeUpdate:startValue; cancelling it only suppresses update:startValue. stepSnapping is new and reaches the field. BREAKING CHANGE: update:modelValue, update:placeholder and update:startValue receive a details argument. DateRangePickerRoot no longer renders a PopoverRoot component. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(DateField): migration notes and API meta for the date and time fields Add the six roots to the converted list and their reason unions to both migration pages, a "Date and time fields" section to the guide and section 17 to the agent page, and regenerate the API meta. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(DateField): a cancelled typed change keeps the typed segments A cancelled commit rolled the segments back to the committed value on the next tick. A year is typed one digit at a time and every digit commits, so a "no past dates" guard cancelled 0002 and reset the field: the user could never type a date. A cancel now rolls back only the model, as v2 did when a parent ignored the update, and a range field never touches the other end's segments. The segments still follow a real model change, including a parent that transforms the value. Applies to DateField, TimeField, DateRangeField and TimeRangeField. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(Calendar): null is a controlled empty value useCalendar mapped a null modelValue to undefined, which made the calendar uncontrolled, so a pick the parent ignored still showed as selected. null now keeps it controlled and reads as undefined, as with v2's useVModel. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(DatePicker): keep the calendar controlled while the picker is empty Pass null to the calendar when the picker has no value, so a controlled-empty picker's calendar is controlled too. Add onBeforeUpdatePlaceholder to useDatePicker, and move the explanatory comments out of the template roots of DatePickerField and DatePickerCalendar so they no longer create dev-only fragments. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(DateRangePicker): compare startValue with the calendar's real anchor The picker deduped startValue against the last value it had emitted, so a change made by the field or while the popover was closed could swallow a later press of that day. The picker now tracks the real anchor (moved by every calendar report and by the range's start) and emits every change the calendar reports. startValue events are typed with RangeCalendarChangeReason, stepSnapping defaults to false, and useDateRangePicker gains onBeforeUpdatePlaceholder. The template-root comments move into the script. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(RangeCalendar): only a press that moves an end leaves a reason select() set the pending reasons before its early returns, so a press that changed nothing left cell-press behind for the next programmatic change. The reasons are now cleared when the press moved neither end, and the range watcher consumes them before its early return. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(DateField): cancel, calendar system and null notes for the date fields Document that a cancelled typed change keeps the typed segments, that the inherited ConfigProvider locale also picks the calendar system of the emitted values (with the Gregorian opt-out and an agent ask step), null on CalendarRoot and the picker's calendar, attribute order in snapshots, and regenerate the DateRangePickerRoot meta. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * docs(DateField): per-root reason unions and controlled-null context reads List the matching change reason union for each date and time root in the agent page's wrapper emit rule, and say what each root context reads for a controlled null: undefined modelValue on the single roots, undefined startValue and endValue on the range fields, and an empty range on DateRangePickerRoot. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(DateField): scope locale calendar note to date roots and type-clean tests The ConfigProvider calendar note now names only the date-valued roots; TimeFieldRoot and TimeRangeFieldRoot default to a Time and keep the calendar of any date-time placeholder they are given. Tests pass weekStartsOn to useRangeCalendar and hold date models in shallowRef, since ref unwrapping strips the private fields of the @internationalized/date classes and fails vue-tsc on test files. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 96d432a commit b968dee

49 files changed

Lines changed: 4724 additions & 1714 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/content/docs/guides/migration-v3-agent.md‎

Lines changed: 42 additions & 3 deletions
Large diffs are not rendered by default.

‎docs/content/docs/guides/migration-v3.md‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Because both values are now always emitted, any styles that relied on the attrib
8282

8383
`update:*` events on stateful roots now receive a second argument, a `ChangeEventDetails` object, and a cancellable `beforeUpdate:*` event fires before every change. `v-model` keeps working unchanged. The details tell you *why* the state changed (`details.reason`) and which native event caused it (`details.event`), and `details.cancel()` inside `beforeUpdate:*` keeps the current state.
8484

85-
Converted so far: `SwitchRoot`, `TabsRoot`, `Toggle`, `ToggleGroupRoot`, `CheckboxRoot`, `CheckboxGroupRoot`, `RadioGroupRoot`, `ListboxRoot`, `AccordionRoot` (`modelValue`), `DropdownMenuRoot`, `DropdownMenuSub`, `ContextMenuRoot`, `ContextMenuSub`, `MenubarRoot` (`modelValue`), `MenubarSub`, `DialogRoot`, `AlertDialogRoot`, `PopoverRoot`, `TooltipRoot`, `HoverCardRoot`, `CollapsibleRoot`, `DatePickerRoot` and `DateRangePickerRoot` (`open`, `view`), `CalendarRoot` and `RangeCalendarRoot` (`modelValue`, `placeholder`, `view`), `ColorAreaRoot`, `ColorFieldRoot`, `ColorSliderRoot` and `ColorSwatchPickerRoot` (`modelValue`), `ComboboxRoot` and `AutocompleteRoot` (`modelValue`, `open`), `NumberFieldRoot`, `PinInputRoot`, `RatingRoot`, `SliderRoot`, `TagsInputRoot`, `TagGroupRoot` and `EditableRoot` (`modelValue`), `SelectRoot` (`modelValue`, `open`), `TreeRoot` (`modelValue`, `expanded`), `PaginationRoot` (`page`), `StepperRoot` (`modelValue`), and `ToolbarToggleGroup` (through the `ToggleGroupRoot` it wraps). The remaining families follow as they move to their headless composables.
85+
Converted so far: `SwitchRoot`, `TabsRoot`, `Toggle`, `ToggleGroupRoot`, `CheckboxRoot`, `CheckboxGroupRoot`, `RadioGroupRoot`, `ListboxRoot`, `AccordionRoot` (`modelValue`), `DropdownMenuRoot`, `DropdownMenuSub`, `ContextMenuRoot`, `ContextMenuSub`, `MenubarRoot` (`modelValue`), `MenubarSub`, `DialogRoot`, `AlertDialogRoot`, `PopoverRoot`, `TooltipRoot`, `HoverCardRoot`, `CollapsibleRoot`, `DateFieldRoot`, `TimeFieldRoot`, `DateRangeFieldRoot` and `TimeRangeFieldRoot` (`modelValue`, `placeholder`), `DatePickerRoot` and `DateRangePickerRoot` (`modelValue`, `placeholder`, `open`, `view`, and `startValue` on `DateRangePickerRoot`), `CalendarRoot` and `RangeCalendarRoot` (`modelValue`, `placeholder`, `view`), `ColorAreaRoot`, `ColorFieldRoot`, `ColorSliderRoot` and `ColorSwatchPickerRoot` (`modelValue`), `ComboboxRoot` and `AutocompleteRoot` (`modelValue`, `open`), `NumberFieldRoot`, `PinInputRoot`, `RatingRoot`, `SliderRoot`, `TagsInputRoot`, `TagGroupRoot` and `EditableRoot` (`modelValue`), `SelectRoot` (`modelValue`, `open`), `TreeRoot` (`modelValue`, `expanded`), `PaginationRoot` (`page`), `StepperRoot` (`modelValue`), and `ToolbarToggleGroup` (through the `ToggleGroupRoot` it wraps). The remaining families follow as they move to their headless composables.
8686

8787
`DrawerRoot` keeps the contract it was ported with from Base UI. Its `update:open` already carried `(value, details)` and still fires before the change, so `details.cancel()` inside `update:open` keeps the drawer as it is. It has no `beforeUpdate:open`, and `update:snapPoint` stays single-argument.
8888

@@ -109,6 +109,8 @@ Wrapper families reuse the union of the family they wrap. `AlertDialogOpenChange
109109
- ArrowLeft or ArrowRight inside a menu reports `list-navigation`;
110110
- a close reports the menu's reason (`item-press`, `escape-key`, `outside-press` or `focus-outside`).
111111

112+
The four segmented fields share one union, exported as `DateFieldChangeReason`, `TimeFieldChangeReason`, `DateRangeFieldChangeReason` and `TimeRangeFieldChangeReason`: `'segment-input'` (a typed digit, or `a` / `p` on the day period), `'segment-increment'` and `'segment-decrement'` (ArrowUp and ArrowDown), `'segment-clear'` (Backspace) and `'step-snap'` (`stepSnapping` rounding a segment when it loses focus). The pickers report the reason of whichever part made the change: `DatePickerChangeReason` is `DateFieldChangeReason | CalendarChangeReason` and `DateRangePickerChangeReason` is `DateRangeFieldChangeReason | RangeCalendarChangeReason`, so a typed date reports `'segment-input'` and a picked day `'cell-press'` or `'cell-keydown'`. A placeholder that follows a new value reports `'imperative-action'`.
113+
112114
What to check in your code:
113115

114116
- Explicit `@update:open` / `@update:model-value` listeners receive an extra argument. Handlers that only read the first argument keep working; handlers typed with a single-parameter signature still type-check.
@@ -519,3 +521,26 @@ In v2, `TagsInputRoot` and `PinInputRoot` kept a local copy of the model (a pass
519521
- New: `baseId`, `isSelected`, `pressItem`, `selectedLabels`, `displayValue`, `getNavigationIntent`.
520522
- On `injectSelectItemContext()`, `value` is read live from the item's prop.
521523
- **New and additive:** `displayValue` and `getNavigationIntent` on `SelectRoot`, the `selectedLabels` slot prop on `SelectValue` (an alias of `selectedLabel`), and the composables.
524+
525+
## Date and time fields
526+
527+
`DateFieldRoot`, `TimeFieldRoot`, `DateRangeFieldRoot`, `TimeRangeFieldRoot`, `DatePickerRoot` and `DateRangePickerRoot` are built on `useDateField()`, `useTimeField()`, `useDateRangeField()`, `useTimeRangeField()`, `useDatePicker()` and `useDateRangePicker()`. Their `modelValue` and `placeholder` follow [Change events carry details](#change-events-carry-details), and so does `startValue` on `DateRangePickerRoot`. The rendered elements are the same. Attributes can come in a different order, and the time zone segment's `data-readonly` value changes (below), so update snapshots.
528+
529+
What changed:
530+
531+
- **The picker roots no longer render a `PopoverRoot`.** `DatePickerRoot` and `DateRangePickerRoot` provide the Popover context themselves, through the `usePopover()` the picker composables compose, so `open` has one model. A test that looked up a `PopoverRoot` component under a picker finds nothing; assert on the picker root's `update:open` instead.
532+
- **One change, one event pair.** A date typed in `DatePickerField` or picked in `DatePickerCalendar` emits `beforeUpdate:modelValue` and `update:modelValue` once, from the picker root, with the reason of the part that made it. `details.cancel()` on the picker root cancels the typed change too.
533+
- **A cancelled typed change keeps the typed segments.** Cancelling `beforeUpdate:modelValue` keeps the last committed value, but the segments keep what the user typed. A year is typed one digit at a time and every digit commits, so a guard such as "no dates before 2000" cancels 0002, 0020 and 0202 and accepts 2024. The segments follow the model only when it actually changes: a controlled parent that ignores an update (an `update:modelValue` handler that does not write the value) leaves them showing the typed value, as in v2.
534+
- **`null` is a controlled empty value.** `:model-value="null"` keeps a field or picker controlled and empty, and a controlled-empty `DatePickerRoot` keeps its calendar controlled too: a pick the parent does not accept is not shown as selected. `CalendarRoot` treats `null` the same way, as v2 did. For a controlled `null`, `modelValue` on the `DateFieldRoot`, `TimeFieldRoot` and `DatePickerRoot` contexts reads `undefined`; the `DateRangeFieldRoot` and `TimeRangeFieldRoot` contexts have no `modelValue` and read `undefined` from `startValue` and `endValue`; `modelValue` on the `DateRangePickerRoot` context reads the empty range `{ start: undefined, end: undefined }`. Clearing a field emits `undefined` (a single field) or `{ start: undefined, end: undefined }` (a range). The range roots' `modelValue` slot prop is typed `DateRange` / `TimeRange` (v2: `DateRange | null` / `TimeRange | undefined`), and is `{ start: undefined, end: undefined }` when empty.
535+
- **No event for an unchanged value.** Setting the model to a value equal to the current one (the same date in the same calendar, compared by value) emits nothing. `DateRangePickerRoot` compares both ends.
536+
- **`update:startValue` carries details.** `RangeCalendarRoot` and `DateRangePickerRoot` emit `update:startValue(date, details)` with the press reason and event. On `DateRangePickerRoot`, `beforeUpdate:startValue` is new; cancelling it only suppresses that `update:startValue`. The calendar's anchor still moves, because the next press needs it.
537+
- **`TimeFieldRoot` emits a `Time` placeholder** when its placeholder is a `Time`. v2 converted it to a `CalendarDateTime` before emitting `update:placeholder`.
538+
- **Root contexts.** On the field and picker root contexts, `modelValue` and `placeholder` (and `startValue` / `endValue` on the range field contexts) are writable computeds: assigning them still works and reports `'imperative-action'`. New on every context: `setModelValue(value, reason?, event?)` and `setPlaceholder(value, reason?, event?)`, plus `setRangeValue(type, value, reason?, event?)` on the range field contexts. Each returns `false` when the change was cancelled or did not change the value. On the picker contexts, `onDateChange` and `onPlaceholderChange` take the same optional reason and event and return a boolean, and `onStartValueChange(date, details?)` takes the calendar's details.
539+
- **Segment attributes.** The time zone segment renders `data-readonly=""` instead of `data-readonly="true"`. Select it with `[data-readonly]`.
540+
- **The default placeholder of `DateFieldRoot`, `DateRangeFieldRoot`, `DatePickerRoot` and `DateRangePickerRoot` uses the `ConfigProvider` locale** when the root has no `locale` prop and no `placeholder`. v2 built it from the prop alone. The placeholder carries the locale's calendar system, and typed values are built from it, so under `<ConfigProvider locale="th-TH">` (or `fa-IR`, `ar-SA`, and other locales with a non-Gregorian default) a field emits dates in that calendar: a Buddhist `CalendarDate` whose `.year` is 2567 for 2024, and the year segment is typed in that calendar too. This matches passing the same `locale` to the field directly. To keep Gregorian values, pass a Gregorian `placeholder` (`today(getLocalTimeZone())`) or `locale="en-US"`, or convert with `toCalendar(value, new GregorianCalendar())` from `@internationalized/date`. `TimeFieldRoot` and `TimeRangeFieldRoot` are unaffected: their default placeholder is a `Time`, which has no calendar, and a `CalendarDateTime` or `ZonedDateTime` placeholder or model keeps the calendar it was created with.
541+
542+
New and additive:
543+
544+
- **`isTimeUnavailable` on `TimeFieldRoot`**, as on `TimeRangeFieldRoot`. It receives the time as a date-time (a `Time` is placed on today's date) and marks the field invalid when it returns `true`.
545+
- **`stepSnapping` on `DateRangeFieldRoot`, `TimeRangeFieldRoot` and `DateRangePickerRoot`**, as on the single fields. `DatePickerRoot` and `DateRangePickerRoot` now pass `stepSnapping` on to their field; v2 accepted it on `DatePickerRoot` but never applied it.
546+
- **The composables.** A field built without the components binds `root.attrs` on a container and one `createInputSurface(part)` per segment. `useDatePicker()` / `useDateRangePicker()` return `getFieldProps()` and `getCalendarProps()`, which make a `useDateField()` / `useCalendar()` (or the range ones) the picker's field and calendar.

‎docs/content/meta/DateFieldRoot.md‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
},
9191
{
9292
'name': 'modelValue',
93-
'description': '<p>The controlled value of the field. Can be bound as <code>v-model</code>.</p>\n',
93+
'description': '<p>The controlled value of the field. Can be bound as <code>v-model</code>. <code>null</code> is a controlled empty field.</p>\n',
9494
'type': 'DateValue | null',
9595
'required': false
9696
},
@@ -135,15 +135,25 @@
135135
]" />
136136

137137
<EmitsTable :data="[
138+
{
139+
'name': 'beforeUpdate:modelValue',
140+
'description': '<p>Called before the value changes; <code>details.cancel()</code> keeps the current value.</p>\n',
141+
'type': '[date: DateValue | undefined, details: ChangeEventDetails&lt;DateFieldChangeReason, Event&gt;]'
142+
},
143+
{
144+
'name': 'beforeUpdate:placeholder',
145+
'description': '<p>Called before the placeholder changes; <code>details.cancel()</code> keeps the current placeholder.</p>\n',
146+
'type': '[date: DateValue, details: ChangeEventDetails&lt;DateFieldChangeReason, Event&gt;]'
147+
},
138148
{
139149
'name': 'update:modelValue',
140150
'description': '<p>Event handler called whenever the model value changes</p>\n',
141-
'type': '[date: DateValue | undefined]'
151+
'type': '[date: DateValue | undefined, details: ChangeEventDetails&lt;DateFieldChangeReason, Event&gt;]'
142152
},
143153
{
144154
'name': 'update:placeholder',
145155
'description': '<p>Event handler called whenever the placeholder value changes</p>\n',
146-
'type': '[date: DateValue]'
156+
'type': '[date: DateValue, details: ChangeEventDetails&lt;DateFieldChangeReason, Event&gt;]'
147157
}
148158
]" />
149159

@@ -194,7 +204,7 @@
194204
| `locale` | The locale to use for formatting dates | `string` | No | - |
195205
| `maxValue` | The maximum date that can be selected | `DateValue` | No | - |
196206
| `minValue` | The minimum date that can be selected | `DateValue` | No | - |
197-
| `modelValue` | The controlled value of the field. Can be bound as v-model. | `DateValue \| null` | No | - |
207+
| `modelValue` | The controlled value of the field. Can be bound as v-model. null is a controlled empty field. | `DateValue \| null` | No | - |
198208
| `name` | The name of the field. Submitted with its owning form as part of a name/value pair. | `string` | No | - |
199209
| `placeholder` | The placeholder date, which is used to determine what month to display when no date is selected. This updates as the user navigates the calendar and can be used to programmatically control the calendar view | `DateValue` | No | - |
200210
| `readonly` | Whether or not the date field is readonly | `boolean` | No | `false` |
@@ -206,8 +216,10 @@
206216

207217
| Name | Description | Type |
208218
| --- | --- | --- |
209-
| `update:modelValue` | Event handler called whenever the model value changes | `[date: DateValue \| undefined]` |
210-
| `update:placeholder` | Event handler called whenever the placeholder value changes | `[date: DateValue]` |
219+
| `beforeUpdate:modelValue` | Called before the value changes; details.cancel() keeps the current value. | `[date: DateValue \| undefined, details: ChangeEventDetails<DateFieldChangeReason, Event>]` |
220+
| `beforeUpdate:placeholder` | Called before the placeholder changes; details.cancel() keeps the current placeholder. | `[date: DateValue, details: ChangeEventDetails<DateFieldChangeReason, Event>]` |
221+
| `update:modelValue` | Event handler called whenever the model value changes | `[date: DateValue \| undefined, details: ChangeEventDetails<DateFieldChangeReason, Event>]` |
222+
| `update:placeholder` | Event handler called whenever the placeholder value changes | `[date: DateValue, details: ChangeEventDetails<DateFieldChangeReason, Event>]` |
211223

212224
**Slots**
213225

‎docs/content/meta/DatePickerRoot.md‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
},
132132
{
133133
'name': 'modelValue',
134-
'description': '<p>The controlled value of the field. Can be bound as <code>v-model</code>.</p>\n',
134+
'description': '<p>The controlled value of the field. Can be bound as <code>v-model</code>. <code>null</code> is a controlled empty field.</p>\n',
135135
'type': 'DateValue | null',
136136
'required': false
137137
},
@@ -228,11 +228,21 @@
228228
]" />
229229

230230
<EmitsTable :data="[
231+
{
232+
'name': 'beforeUpdate:modelValue',
233+
'description': '<p>Called before the value changes, from the field or the calendar; <code>details.cancel()</code> keeps the current value.</p>\n',
234+
'type': '[date: DateValue | undefined, details: ChangeEventDetails&lt;DatePickerChangeReason, Event&gt;]'
235+
},
231236
{
232237
'name': 'beforeUpdate:open',
233238
'description': '<p>Called before the open state changes; <code>details.cancel()</code> keeps the current state.</p>\n',
234239
'type': '[value: boolean, details: ChangeEventDetails&lt;DatePickerOpenChangeReason, Event&gt;]'
235240
},
241+
{
242+
'name': 'beforeUpdate:placeholder',
243+
'description': '<p>Called before the placeholder changes; <code>details.cancel()</code> keeps the current placeholder.</p>\n',
244+
'type': '[date: DateValue, details: ChangeEventDetails&lt;DatePickerChangeReason, Event&gt;]'
245+
},
236246
{
237247
'name': 'beforeUpdate:view',
238248
'description': '<p>Called before the calendar view changes; <code>details.cancel()</code> keeps the current view.</p>\n',
@@ -241,7 +251,7 @@
241251
{
242252
'name': 'update:modelValue',
243253
'description': '<p>Event handler called whenever the model value changes</p>\n',
244-
'type': '[date: DateValue | undefined]'
254+
'type': '[date: DateValue | undefined, details: ChangeEventDetails&lt;DatePickerChangeReason, Event&gt;]'
245255
},
246256
{
247257
'name': 'update:open',
@@ -251,7 +261,7 @@
251261
{
252262
'name': 'update:placeholder',
253263
'description': '<p>Event handler called whenever the placeholder value changes</p>\n',
254-
'type': '[date: DateValue]'
264+
'type': '[date: DateValue, details: ChangeEventDetails&lt;DatePickerChangeReason, Event&gt;]'
255265
},
256266
{
257267
'name': 'update:view',
@@ -287,7 +297,7 @@
287297
| `maxView` | The coarsest view DatePickerViewTrigger can switch to. | `"day" \| "month" \| "year"` | No | `"year"` |
288298
| `minValue` | The minimum date that can be selected | `DateValue` | No | - |
289299
| `modal` | The modality of the popover. When true, page scroll is locked, the rest of the page (except the trigger) is covered by an internal backdrop that closes the popover on press, and only the popover content is visible to screen readers. | `boolean` | No | `false` |
290-
| `modelValue` | The controlled value of the field. Can be bound as v-model. | `DateValue \| null` | No | - |
300+
| `modelValue` | The controlled value of the field. Can be bound as v-model. null is a controlled empty field. | `DateValue \| null` | No | - |
291301
| `name` | The name of the field. Submitted with its owning form as part of a name/value pair. | `string` | No | - |
292302
| `numberOfMonths` | The number of months to display at once in the day view | `number` | No | `1` |
293303
| `open` | The controlled open state of the popover. | `boolean` | No | - |
@@ -307,11 +317,13 @@
307317

308318
| Name | Description | Type |
309319
| --- | --- | --- |
320+
| `beforeUpdate:modelValue` | Called before the value changes, from the field or the calendar; details.cancel() keeps the current value. | `[date: DateValue \| undefined, details: ChangeEventDetails<DatePickerChangeReason, Event>]` |
310321
| `beforeUpdate:open` | Called before the open state changes; details.cancel() keeps the current state. | `[value: boolean, details: ChangeEventDetails<DatePickerOpenChangeReason, Event>]` |
322+
| `beforeUpdate:placeholder` | Called before the placeholder changes; details.cancel() keeps the current placeholder. | `[date: DateValue, details: ChangeEventDetails<DatePickerChangeReason, Event>]` |
311323
| `beforeUpdate:view` | Called before the calendar view changes; details.cancel() keeps the current view. | `[view: CalendarUnit, details: ChangeEventDetails<CalendarChangeReason, Event>]` |
312-
| `update:modelValue` | Event handler called whenever the model value changes | `[date: DateValue \| undefined]` |
324+
| `update:modelValue` | Event handler called whenever the model value changes | `[date: DateValue \| undefined, details: ChangeEventDetails<DatePickerChangeReason, Event>]` |
313325
| `update:open` | Event handler called when the open state of the popover changes. | `[value: boolean, details: ChangeEventDetails<DatePickerOpenChangeReason, Event>]` |
314-
| `update:placeholder` | Event handler called whenever the placeholder value changes | `[date: DateValue]` |
326+
| `update:placeholder` | Event handler called whenever the placeholder value changes | `[date: DateValue, details: ChangeEventDetails<DatePickerChangeReason, Event>]` |
315327
| `update:view` | Event handler called whenever the calendar view changes | `[view: CalendarUnit, details: ChangeEventDetails<CalendarChangeReason, Event>]` |
316328

317329
</llm-only>

0 commit comments

Comments
 (0)