@slotted/react 0.1.0-beta.42 → 0.1.0-beta.43
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/dist/{app-shell-D54YkU7E.js → app-shell-DsWhsSMU.js} +3 -2
- package/dist/app-shell.js +1 -1
- package/dist/attachment-TZykYNu5.js +300 -0
- package/dist/attachment.js +2 -2
- package/dist/{avatar-group-bJaZE1_C.js → avatar-group-Bzmmj2HI.js} +2 -1
- package/dist/avatar-group.js +1 -1
- package/dist/{carousel-B9nMK7Yf.js → carousel-CRNz-T3g.js} +1 -1
- package/dist/carousel.js +1 -1
- package/dist/{command-palette-C90CzfQi.js → command-palette-Bgf5tfCI.js} +160 -156
- package/dist/command-palette.js +1 -1
- package/dist/{data-grid-D106baPp.js → data-grid-DUft3rJb.js} +1 -1
- package/dist/data-grid.js +1 -1
- package/dist/{data-list-BA0xrySM.js → data-list-Dv3orBtf.js} +15 -15
- package/dist/data-list.js +1 -1
- package/dist/detail-panel-Cke3ZFU3.js +342 -0
- package/dist/detail-panel.js +2 -2
- package/dist/docs/action-bar.examples.md +768 -0
- package/dist/docs/action-bar.json +74 -50
- package/dist/docs/action-bar.md +49 -311
- package/dist/docs/app-shell.examples.md +1221 -64
- package/dist/docs/app-shell.json +92 -60
- package/dist/docs/app-shell.md +92 -57
- package/dist/docs/attachment.examples.md +689 -0
- package/dist/docs/attachment.json +69 -37
- package/dist/docs/attachment.md +44 -203
- package/dist/docs/avatar-group.json +111 -23
- package/dist/docs/avatar-group.md +487 -28
- package/dist/docs/button-group.json +98 -2
- package/dist/docs/button-group.md +411 -8
- package/dist/docs/calendar.examples.md +512 -0
- package/dist/docs/calendar.json +72 -24
- package/dist/docs/calendar.md +18 -147
- package/dist/docs/carousel.examples.md +868 -0
- package/dist/docs/carousel.json +58 -50
- package/dist/docs/carousel.md +66 -300
- package/dist/docs/cascader.examples.md +1269 -0
- package/dist/docs/cascader.json +72 -16
- package/dist/docs/cascader.md +78 -154
- package/dist/docs/chart.examples.md +734 -24
- package/dist/docs/chart.json +93 -13
- package/dist/docs/chart.md +28 -7
- package/dist/docs/clock.json +71 -15
- package/dist/docs/clock.md +326 -21
- package/dist/docs/code-block.json +79 -55
- package/dist/docs/code-block.md +417 -74
- package/dist/docs/color-picker.json +60 -12
- package/dist/docs/color-picker.md +245 -22
- package/dist/docs/column-manager.examples.md +764 -0
- package/dist/docs/column-manager.json +68 -12
- package/dist/docs/column-manager.md +44 -203
- package/dist/docs/command-palette.examples.md +747 -0
- package/dist/docs/command-palette.json +48 -24
- package/dist/docs/command-palette.md +60 -339
- package/dist/docs/currency-field.examples.md +355 -73
- package/dist/docs/currency-field.json +96 -64
- package/dist/docs/currency-field.md +57 -50
- package/dist/docs/dashboard-grid.examples.md +629 -0
- package/dist/docs/dashboard-grid.json +64 -16
- package/dist/docs/dashboard-grid.md +34 -152
- package/dist/docs/data-list.examples.md +1556 -0
- package/dist/docs/data-list.json +58 -18
- package/dist/docs/data-list.md +139 -224
- package/dist/docs/date-field.examples.md +543 -0
- package/dist/docs/date-field.json +64 -24
- package/dist/docs/date-field.md +22 -168
- package/dist/docs/datetime-field.examples.md +699 -0
- package/dist/docs/datetime-field.json +79 -31
- package/dist/docs/datetime-field.md +24 -269
- package/dist/docs/datetime-range-picker.examples.md +682 -0
- package/dist/docs/datetime-range-picker.json +117 -61
- package/dist/docs/datetime-range-picker.md +59 -224
- package/dist/docs/description-list.examples.md +652 -0
- package/dist/docs/description-list.json +49 -25
- package/dist/docs/description-list.md +33 -188
- package/dist/docs/detail-panel.examples.md +1177 -0
- package/dist/docs/detail-panel.json +69 -53
- package/dist/docs/detail-panel.md +114 -324
- package/dist/docs/entity-picker.examples.md +1037 -0
- package/dist/docs/entity-picker.json +66 -18
- package/dist/docs/entity-picker.md +56 -246
- package/dist/docs/event-calendar.examples.md +749 -49
- package/dist/docs/event-calendar.json +46 -22
- package/dist/docs/event-calendar.md +81 -11
- package/dist/docs/field-group.examples.md +554 -0
- package/dist/docs/field-group.json +98 -34
- package/dist/docs/field-group.md +55 -133
- package/dist/docs/filter-bar.examples.md +772 -0
- package/dist/docs/filter-bar.json +41 -25
- package/dist/docs/filter-bar.md +42 -246
- package/dist/docs/form.examples.md +579 -0
- package/dist/docs/form.json +87 -39
- package/dist/docs/form.md +53 -177
- package/dist/docs/fullscreen.examples.md +558 -0
- package/dist/docs/fullscreen.json +58 -18
- package/dist/docs/fullscreen.md +50 -169
- package/dist/docs/highlight.json +57 -25
- package/dist/docs/highlight.md +402 -50
- package/dist/docs/icon.json +85 -5
- package/dist/docs/icon.md +401 -10
- package/dist/docs/image.examples.md +670 -0
- package/dist/docs/image.json +44 -28
- package/dist/docs/image.md +24 -176
- package/dist/docs/import-export-center.examples.md +1280 -0
- package/dist/docs/import-export-center.json +67 -27
- package/dist/docs/import-export-center.md +121 -226
- package/dist/docs/list-item.examples.md +769 -0
- package/dist/docs/list-item.json +110 -38
- package/dist/docs/list-item.md +84 -201
- package/dist/docs/listbox.examples.md +858 -0
- package/dist/docs/listbox.json +76 -28
- package/dist/docs/listbox.md +41 -263
- package/dist/docs/markdown.json +79 -55
- package/dist/docs/markdown.md +581 -85
- package/dist/docs/media-viewer.examples.md +1038 -0
- package/dist/docs/media-viewer.json +70 -15
- package/dist/docs/media-viewer.md +84 -135
- package/dist/docs/message-scroller.examples.md +1193 -0
- package/dist/docs/message-scroller.json +41 -17
- package/dist/docs/message-scroller.md +80 -134
- package/dist/docs/message.examples.md +944 -0
- package/dist/docs/message.json +64 -16
- package/dist/docs/message.md +34 -326
- package/dist/docs/meter.json +58 -26
- package/dist/docs/meter.md +312 -32
- package/dist/docs/navigation-menu.examples.md +1107 -0
- package/dist/docs/navigation-menu.json +57 -41
- package/dist/docs/navigation-menu.md +105 -298
- package/dist/docs/notification-center.examples.md +1045 -0
- package/dist/docs/notification-center.json +71 -15
- package/dist/docs/notification-center.md +76 -266
- package/dist/docs/otp-input.examples.md +490 -0
- package/dist/docs/otp-input.json +65 -25
- package/dist/docs/otp-input.md +20 -191
- package/dist/docs/page-header.examples.md +1041 -0
- package/dist/docs/page-header.json +75 -43
- package/dist/docs/page-header.md +79 -291
- package/dist/docs/page.examples.md +633 -0
- package/dist/docs/page.json +48 -16
- package/dist/docs/page.md +62 -129
- package/dist/docs/prompt-composer.examples.md +630 -0
- package/dist/docs/prompt-composer.json +66 -18
- package/dist/docs/prompt-composer.md +35 -161
- package/dist/docs/prose.json +69 -37
- package/dist/docs/prose.md +393 -75
- package/dist/docs/rating.examples.md +525 -0
- package/dist/docs/rating.json +92 -28
- package/dist/docs/rating.md +27 -241
- package/dist/docs/saved-views.examples.md +1108 -0
- package/dist/docs/saved-views.json +53 -21
- package/dist/docs/saved-views.md +86 -171
- package/dist/docs/scroll-area.examples.md +837 -0
- package/dist/docs/scroll-area.json +64 -24
- package/dist/docs/scroll-area.md +57 -140
- package/dist/docs/section.examples.md +676 -0
- package/dist/docs/section.json +68 -20
- package/dist/docs/section.md +39 -162
- package/dist/docs/segmented-control.examples.md +480 -0
- package/dist/docs/segmented-control.json +76 -28
- package/dist/docs/segmented-control.md +20 -191
- package/dist/docs/side-navigation.examples.md +1468 -0
- package/dist/docs/side-navigation.json +53 -53
- package/dist/docs/side-navigation.md +79 -354
- package/dist/docs/slider.examples.md +505 -0
- package/dist/docs/slider.json +91 -51
- package/dist/docs/slider.md +47 -212
- package/dist/docs/sparkline.json +60 -36
- package/dist/docs/sparkline.md +447 -71
- package/dist/docs/split-button.examples.md +509 -0
- package/dist/docs/split-button.json +73 -41
- package/dist/docs/split-button.md +64 -194
- package/dist/docs/splitter.examples.md +921 -0
- package/dist/docs/splitter.json +94 -46
- package/dist/docs/splitter.md +75 -182
- package/dist/docs/stat-card.examples.md +725 -0
- package/dist/docs/stat-card.json +89 -41
- package/dist/docs/stat-card.md +55 -227
- package/dist/docs/status-indicator.json +80 -32
- package/dist/docs/status-indicator.md +409 -65
- package/dist/docs/stepper.json +53 -21
- package/dist/docs/stepper.md +369 -48
- package/dist/docs/table-of-contents.examples.md +550 -0
- package/dist/docs/table-of-contents.json +60 -28
- package/dist/docs/table-of-contents.md +70 -205
- package/dist/docs/tags-input.examples.md +541 -0
- package/dist/docs/tags-input.json +64 -16
- package/dist/docs/tags-input.md +15 -262
- package/dist/docs/time-field.examples.md +587 -0
- package/dist/docs/time-field.json +69 -29
- package/dist/docs/time-field.md +21 -223
- package/dist/docs/time-picker.json +117 -53
- package/dist/docs/time-picker.md +499 -54
- package/dist/docs/time-range-picker.examples.md +750 -0
- package/dist/docs/time-range-picker.json +139 -75
- package/dist/docs/time-range-picker.md +63 -225
- package/dist/docs/timeline.examples.md +617 -0
- package/dist/docs/timeline.json +44 -28
- package/dist/docs/timeline.md +34 -208
- package/dist/docs/toolbar.json +56 -16
- package/dist/docs/toolbar.md +357 -63
- package/dist/docs/top-navigation.examples.md +1206 -140
- package/dist/docs/top-navigation.json +49 -33
- package/dist/docs/top-navigation.md +87 -36
- package/dist/docs/tour.examples.md +960 -0
- package/dist/docs/tour.json +57 -25
- package/dist/docs/tour.md +60 -244
- package/dist/docs/transfer.examples.md +631 -0
- package/dist/docs/transfer.json +80 -16
- package/dist/docs/transfer.md +41 -170
- package/dist/docs/typography.json +96 -0
- package/dist/docs/typography.md +352 -4
- package/dist/docs/upload.examples.md +555 -53
- package/dist/docs/upload.json +62 -30
- package/dist/docs/upload.md +46 -11
- package/dist/docs/wizard.examples.md +1389 -0
- package/dist/docs/wizard.json +89 -49
- package/dist/docs/wizard.md +122 -263
- package/dist/{entity-picker-CC4VoC3p.js → entity-picker-C78f3Z0o.js} +9 -6
- package/dist/entity-picker.js +1 -1
- package/dist/{event-calendar-CjmF_e0H.js → event-calendar-DJPoCi-O.js} +1 -1
- package/dist/event-calendar.js +1 -1
- package/dist/{filter-bar-B3QJD7SZ.js → filter-bar-D61wiQFP.js} +1 -1
- package/dist/filter-bar.js +1 -1
- package/dist/{import-export-center-CW8YVZev.js → import-export-center-mqvmlzwB.js} +44 -36
- package/dist/import-export-center.js +1 -1
- package/dist/index.js +58 -58
- package/dist/{markdown-BdskE4-L.js → markdown-8CtV4k44.js} +2 -2
- package/dist/markdown.js +1 -1
- package/dist/{media-viewer-zEXcwfEY.js → media-viewer-C_cbuAq-.js} +64 -60
- package/dist/media-viewer.js +2 -2
- package/dist/message-P91bEGyV.js +455 -0
- package/dist/message.js +2 -2
- package/dist/{page-header-DmwBGwlm.js → page-header-jeAIQSZM.js} +103 -108
- package/dist/page-header.js +1 -1
- package/dist/section-CVTQdWBl.js +216 -0
- package/dist/section.js +2 -2
- package/dist/{segmented-control-CbK7SurB.js → segmented-control-BSMVjukr.js} +1 -1
- package/dist/segmented-control.js +1 -1
- package/dist/{side-navigation-CKRETc8E.js → side-navigation-BQzBxz2B.js} +179 -179
- package/dist/side-navigation.js +1 -1
- package/dist/{stat-card-CL3Xe6pV.js → stat-card-BpGZiFbG.js} +12 -14
- package/dist/stat-card.js +1 -1
- package/dist/{stepper-DHdrANZI.js → stepper-Cxb_tHnA.js} +130 -127
- package/dist/stepper.js +2 -2
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/{timeline-BiL2CXfn.js → timeline-ZngK6zLC.js} +9 -6
- package/dist/timeline.js +1 -1
- package/dist/top-navigation-YSEQzBhD.js +744 -0
- package/dist/top-navigation.js +2 -2
- package/dist/{transfer-sKUvmEKe.js → transfer-Cv5yQuTN.js} +1 -1
- package/dist/transfer.js +1 -1
- package/dist/types/attachment/attachment-parts.d.ts +24 -11
- package/dist/types/attachment/attachment-parts.d.ts.map +1 -1
- package/dist/types/attachment/attachment.d.ts +3 -3
- package/dist/types/attachment/attachment.d.ts.map +1 -1
- package/dist/types/avatar-group/avatar-group.d.ts.map +1 -1
- package/dist/types/carousel/carousel-parts.d.ts +2 -2
- package/dist/types/command-palette/command-palette.d.ts.map +1 -1
- package/dist/types/data-list/data-list.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel-parts.d.ts +10 -3
- package/dist/types/detail-panel/detail-panel-parts.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel.types.d.ts +7 -0
- package/dist/types/detail-panel/detail-panel.types.d.ts.map +1 -1
- package/dist/types/entity-picker/entity-picker.d.ts.map +1 -1
- package/dist/types/import-export-center/import-export-center.d.ts.map +1 -1
- package/dist/types/media-viewer/index.d.ts +2 -2
- package/dist/types/media-viewer/index.d.ts.map +1 -1
- package/dist/types/media-viewer/media-viewer-bar.d.ts +3 -1
- package/dist/types/media-viewer/media-viewer-bar.d.ts.map +1 -1
- package/dist/types/media-viewer/media-viewer.types.d.ts +1 -0
- package/dist/types/media-viewer/media-viewer.types.d.ts.map +1 -1
- package/dist/types/message/message-parts.d.ts +7 -0
- package/dist/types/message/message-parts.d.ts.map +1 -1
- package/dist/types/message/message.d.ts.map +1 -1
- package/dist/types/page-header/page-header-parts.d.ts.map +1 -1
- package/dist/types/section/section-parts.d.ts +16 -8
- package/dist/types/section/section-parts.d.ts.map +1 -1
- package/dist/types/section/section.d.ts.map +1 -1
- package/dist/types/segmented-control/segmented-control-parts.d.ts.map +1 -1
- package/dist/types/side-navigation/side-navigation-parts.d.ts.map +1 -1
- package/dist/types/stat-card/stat-card-delta.d.ts.map +1 -1
- package/dist/types/stat-card/stat-card-parts.d.ts +3 -3
- package/dist/types/stat-card/stat-card-parts.d.ts.map +1 -1
- package/dist/types/stepper/stepper-parts.d.ts +11 -2
- package/dist/types/stepper/stepper-parts.d.ts.map +1 -1
- package/dist/types/stepper/stepper.d.ts.map +1 -1
- package/dist/types/timeline/timeline-parts.d.ts.map +1 -1
- package/dist/types/top-navigation/top-navigation.d.ts.map +1 -1
- package/dist/{wizard-4c0X7Bx_.js → wizard-Dfryz1id.js} +214 -214
- package/dist/wizard.js +1 -1
- package/package.json +6 -6
- package/dist/attachment-MqczA38F.js +0 -292
- package/dist/detail-panel-EImAtksY.js +0 -327
- package/dist/message-D1Dd6Y2k.js +0 -452
- package/dist/section-D_qOfdxR.js +0 -213
- package/dist/top-navigation-D8IHPOmm.js +0 -744
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
<!-- index: ./index.md -->
|
|
2
|
+
# datetime-field
|
|
3
|
+
|
|
4
|
+
`data-ui="datetime-field"` · Typed date and time input in segments.
|
|
5
|
+
|
|
6
|
+
## Examples
|
|
7
|
+
|
|
8
|
+
### Playground
|
|
9
|
+
|
|
10
|
+
One control with every axis on it, driven by the controls below the canvas. Type into it: the run walks the whole row and crosses from the year into the hour without a key that moves focus, and pressing + turns it into a duration from now.
|
|
11
|
+
|
|
12
|
+
Excerpt — not a complete module
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
<Field>
|
|
16
|
+
<FieldLabel>Appointment start</FieldLabel>
|
|
17
|
+
<DateTimeField clearable locale="pt-BR" name="start" />
|
|
18
|
+
<FieldDescription>The appointment starts at this date and time.</FieldDescription>
|
|
19
|
+
</Field>;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### One pattern, both halves
|
|
23
|
+
|
|
24
|
+
The same component in four locales. Not a date format beside a time format: one Intl.DateTimeFormat over both halves, which is the only way to learn the order of the two, the literal between them, and where the day period lands. pt-BR and en-US write a comma there; fr-FR and ja-JP write a bare space and nothing is drawn.
|
|
25
|
+
|
|
26
|
+
Example
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { DateTimeField } from '@slotted/react/datetime-field';
|
|
30
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
31
|
+
import { Stack } from '@slotted/react/stack';
|
|
32
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
33
|
+
|
|
34
|
+
const SLOT = plainDateTime(plainDate(2026, 9, 30), plainTime(14, 30));
|
|
35
|
+
|
|
36
|
+
export default function DateTimeFieldLocale() {
|
|
37
|
+
return (
|
|
38
|
+
<Stack gap={4}>
|
|
39
|
+
<Field>
|
|
40
|
+
<FieldLabel>Brazil, pt-BR</FieldLabel>
|
|
41
|
+
<DateTimeField defaultValue={SLOT} locale="pt-BR" />
|
|
42
|
+
</Field>
|
|
43
|
+
<Field>
|
|
44
|
+
<FieldLabel>United States, en-US</FieldLabel>
|
|
45
|
+
<DateTimeField defaultValue={SLOT} locale="en-US" />
|
|
46
|
+
</Field>
|
|
47
|
+
<Field>
|
|
48
|
+
<FieldLabel>France, fr-FR</FieldLabel>
|
|
49
|
+
<DateTimeField defaultValue={SLOT} locale="fr-FR" />
|
|
50
|
+
</Field>
|
|
51
|
+
<Field>
|
|
52
|
+
<FieldLabel>Japan, ja-JP</FieldLabel>
|
|
53
|
+
<DateTimeField defaultValue={SLOT} locale="ja-JP" />
|
|
54
|
+
</Field>
|
|
55
|
+
</Stack>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Four hour cycles, not a boolean
|
|
61
|
+
|
|
62
|
+
Intl resolves h11, h12, h23 and h24, and a boolean can say two of them. Ask for 12 in ja-JP and the hour runs from zero with the day period written before it, because that is what the locale does. The public axis stays 12 | 24, because that is the question a consumer asks.
|
|
63
|
+
|
|
64
|
+
Example
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import { DateTimeField } from '@slotted/react/datetime-field';
|
|
68
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
69
|
+
import { Stack } from '@slotted/react/stack';
|
|
70
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
71
|
+
|
|
72
|
+
const SHIFT_START = plainDateTime(plainDate(2026, 10, 5), plainTime(0, 30));
|
|
73
|
+
|
|
74
|
+
export default function DateTimeFieldHourCycle() {
|
|
75
|
+
return (
|
|
76
|
+
<Stack gap={4}>
|
|
77
|
+
<Field>
|
|
78
|
+
<FieldLabel>12-hour clock, en-US</FieldLabel>
|
|
79
|
+
<DateTimeField defaultValue={SHIFT_START} hourCycle={12} locale="en-US" />
|
|
80
|
+
</Field>
|
|
81
|
+
<Field>
|
|
82
|
+
<FieldLabel>12-hour clock, ja-JP</FieldLabel>
|
|
83
|
+
<DateTimeField defaultValue={SHIFT_START} hourCycle={12} locale="ja-JP" />
|
|
84
|
+
</Field>
|
|
85
|
+
<Field>
|
|
86
|
+
<FieldLabel>24-hour clock, en-US</FieldLabel>
|
|
87
|
+
<DateTimeField defaultValue={SHIFT_START} hourCycle={24} locale="en-US" />
|
|
88
|
+
</Field>
|
|
89
|
+
</Stack>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Granularity governs the time half
|
|
95
|
+
|
|
96
|
+
How much of the time is drawn, and how much of it is typed. The date half is always whole. For a date with no time, use date-field. Seconds exist only when the value has them.
|
|
97
|
+
|
|
98
|
+
Example
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { DateTimeField } from '@slotted/react/datetime-field';
|
|
102
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
103
|
+
import { Stack } from '@slotted/react/stack';
|
|
104
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
105
|
+
|
|
106
|
+
const SCAN = plainDateTime(plainDate(2026, 9, 30), plainTime(14, 30, 45));
|
|
107
|
+
|
|
108
|
+
export default function DateTimeFieldGranularity() {
|
|
109
|
+
return (
|
|
110
|
+
<Stack gap={4}>
|
|
111
|
+
<Field>
|
|
112
|
+
<FieldLabel>Shift starts</FieldLabel>
|
|
113
|
+
<DateTimeField defaultValue={SCAN} granularity="hour" hourCycle={24} locale="en-US" />
|
|
114
|
+
</Field>
|
|
115
|
+
<Field>
|
|
116
|
+
<FieldLabel>Delivery window opens</FieldLabel>
|
|
117
|
+
<DateTimeField defaultValue={SCAN} granularity="minute" hourCycle={24} locale="en-US" />
|
|
118
|
+
</Field>
|
|
119
|
+
<Field>
|
|
120
|
+
<FieldLabel>Pallet scanned at</FieldLabel>
|
|
121
|
+
<DateTimeField defaultValue={SCAN} granularity="second" hourCycle={24} locale="en-US" />
|
|
122
|
+
</Field>
|
|
123
|
+
</Stack>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### The half that is missing
|
|
129
|
+
|
|
130
|
+
A reader who wrote a day and walked away is not an empty control. value is null, and the missing half is named in two places: it is on the root as data-incomplete and on the request as incomplete. The frame warns only once focus has left, because while a segment still holds it the reader is mid-entry.
|
|
131
|
+
|
|
132
|
+
Excerpt — not a complete module
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
<DateTimeField
|
|
136
|
+
locale="pt-BR"
|
|
137
|
+
onValueChange={(value, request) => {
|
|
138
|
+
if (value === null) saveDraft(request.segments, request.incomplete);
|
|
139
|
+
else commit(value);
|
|
140
|
+
}}
|
|
141
|
+
/>;
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### A datetime written as a duration
|
|
145
|
+
|
|
146
|
+
Press +, - or = on any segment and the field takes an expression instead: +40m, 1h30, +2d, +1w, -15, 0. The anchor is always now, never the value the field holds, and what it resolves to is drawn beside it before Enter commits anything. Escape puts the segments back untouched.
|
|
147
|
+
|
|
148
|
+
Example
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { DateTimeField } from '@slotted/react/datetime-field';
|
|
152
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
153
|
+
import { Stack } from '@slotted/react/stack';
|
|
154
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
155
|
+
|
|
156
|
+
const NOW = plainDateTime(plainDate(2026, 9, 30), plainTime(23, 0));
|
|
157
|
+
|
|
158
|
+
export default function DateTimeFieldRelative() {
|
|
159
|
+
return (
|
|
160
|
+
<Stack gap={4}>
|
|
161
|
+
<Field>
|
|
162
|
+
<FieldLabel>Driver arrives</FieldLabel>
|
|
163
|
+
<DateTimeField hourCycle={24} locale="en-US" referenceDateTime={NOW} />
|
|
164
|
+
<FieldDescription>
|
|
165
|
+
Press + on a segment and type 90m: the preview shows the new date and 00:30 before Enter
|
|
166
|
+
commits it.
|
|
167
|
+
</FieldDescription>
|
|
168
|
+
</Field>
|
|
169
|
+
<Field>
|
|
170
|
+
<FieldLabel>Cutoff for same-day dispatch</FieldLabel>
|
|
171
|
+
<DateTimeField hourCycle={24} locale="en-US" referenceDateTime={NOW} relative={false} />
|
|
172
|
+
<FieldDescription>Relative entry is off: +, - and = do nothing.</FieldDescription>
|
|
173
|
+
</Field>
|
|
174
|
+
</Stack>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### A duration that moves the day
|
|
180
|
+
|
|
181
|
+
This is where time-field’s crossesMidnight flag is spent. There, +90m at 23:00 can only raise a flag, because a PlainTime has no day beside it; here the day exists, so +2d simply moves it and the preview writes the new date out and lifts it from the time beside it. The request carries no crossing at all, because the crossing is already the value.
|
|
182
|
+
|
|
183
|
+
Excerpt — not a complete module
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
<DateTimeField
|
|
187
|
+
locale="pt-BR"
|
|
188
|
+
referenceDateTime={{
|
|
189
|
+
date: { year: 2026, month: 9, day: 30 },
|
|
190
|
+
time: { hour: 23, minute: 0, second: 0 },
|
|
191
|
+
}}
|
|
192
|
+
/>;
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Size
|
|
196
|
+
|
|
197
|
+
The three steps a field can be, each in a row of its own so the height and the type move together. A control inside a field takes the field’s step, so a form cannot end up with a small field holding a medium control on one row.
|
|
198
|
+
|
|
199
|
+
Excerpt — not a complete module
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
<>
|
|
203
|
+
<DateTimeField size="sm" />
|
|
204
|
+
<DateTimeField size="md" />
|
|
205
|
+
<DateTimeField size="lg" />
|
|
206
|
+
</>;
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Variant
|
|
210
|
+
|
|
211
|
+
How much frame the control shows. outline takes the ground it is on, subtle sinks into the page, and plain shows nothing until it is used — which is what a dense table of appointments needs, where a frame on every row would be a grid of boxes.
|
|
212
|
+
|
|
213
|
+
Excerpt — not a complete module
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
<>
|
|
217
|
+
<DateTimeField variant="outline" />
|
|
218
|
+
<DateTimeField variant="subtle" />
|
|
219
|
+
<DateTimeField variant="plain" />
|
|
220
|
+
</>;
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Two pairs of bounds, at the same time
|
|
224
|
+
|
|
225
|
+
min and max fence the whole value; minTime and maxTime fence every day inside the range. Both pairs apply at the same time. A booking flow says both: no earlier than tomorrow at 09:00, and never outside 09:00 to 18:00 on any day.
|
|
226
|
+
|
|
227
|
+
Excerpt — not a complete module
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
<DateTimeField
|
|
231
|
+
max={{ date: { year: 2026, month: 12, day: 20 }, time: { hour: 12, minute: 0, second: 0 } }}
|
|
232
|
+
maxTime={{ hour: 18, minute: 0, second: 0 }}
|
|
233
|
+
min={{ date: { year: 2026, month: 9, day: 11 }, time: { hour: 14, minute: 0, second: 0 } }}
|
|
234
|
+
minTime={{ hour: 9, minute: 0, second: 0 }}
|
|
235
|
+
/>;
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Two predicates, because a grid asks a different question
|
|
239
|
+
|
|
240
|
+
isDateUnavailable answers a whole day — a holiday, a closed clinic — and isTimeUnavailable answers one time on one day, taking the date so a Saturday can close earlier. A day-level answer cannot be derived from a datetime-level predicate without probing every step of that day, and a calendar needs one answer per cell.
|
|
241
|
+
|
|
242
|
+
Excerpt — not a complete module
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
<DateTimeField
|
|
246
|
+
isDateUnavailable={(date) => dayOfWeek(date) === 0}
|
|
247
|
+
isTimeUnavailable={(time, date) => date.day !== 24 && time.hour === 12}
|
|
248
|
+
locale="pt-BR"
|
|
249
|
+
/>;
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Seven fields in a narrow column
|
|
253
|
+
|
|
254
|
+
The row is one line at every width and is clipped at the frame. A control two lines tall would break every row it stands in. Nothing is removed — the value is whole in the field and in what a screen reader hears — and the half the reader steps into is scrolled into view.
|
|
255
|
+
|
|
256
|
+
Excerpt — not a complete module
|
|
257
|
+
|
|
258
|
+
```tsx
|
|
259
|
+
<DateTimeField granularity="second" locale="pt-BR" />;
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### States
|
|
263
|
+
|
|
264
|
+
Read-only stays focusable and copyable and never looks disabled; disabled answers no key and no pointer; invalid keeps its focus ring and retargets its color; and incomplete is its own quieter state, one tone short of the refused value. Tab through the row to see each one answer.
|
|
265
|
+
|
|
266
|
+
Example
|
|
267
|
+
|
|
268
|
+
```tsx
|
|
269
|
+
import { DateTimeField } from '@slotted/react/datetime-field';
|
|
270
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from '@slotted/react/field';
|
|
271
|
+
import { Stack } from '@slotted/react/stack';
|
|
272
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
273
|
+
|
|
274
|
+
export default function DateTimeFieldStates() {
|
|
275
|
+
return (
|
|
276
|
+
<Stack gap={5}>
|
|
277
|
+
<Field>
|
|
278
|
+
<FieldLabel>Delivery slot</FieldLabel>
|
|
279
|
+
<DateTimeField locale="en-US" required />
|
|
280
|
+
<FieldDescription>Required to book the carrier.</FieldDescription>
|
|
281
|
+
</Field>
|
|
282
|
+
<Field>
|
|
283
|
+
<FieldLabel>Invoice issued</FieldLabel>
|
|
284
|
+
<DateTimeField
|
|
285
|
+
defaultValue={plainDateTime(plainDate(2026, 9, 30), plainTime(17, 45))}
|
|
286
|
+
invalid
|
|
287
|
+
locale="en-US"
|
|
288
|
+
/>
|
|
289
|
+
<FieldError>The invoice is dated after the due date.</FieldError>
|
|
290
|
+
</Field>
|
|
291
|
+
<Field>
|
|
292
|
+
<FieldLabel>Order placed</FieldLabel>
|
|
293
|
+
<DateTimeField
|
|
294
|
+
defaultValue={plainDateTime(plainDate(2026, 9, 9), plainTime(8, 12))}
|
|
295
|
+
locale="en-US"
|
|
296
|
+
readOnly
|
|
297
|
+
/>
|
|
298
|
+
<FieldDescription>Set when the order was placed.</FieldDescription>
|
|
299
|
+
</Field>
|
|
300
|
+
<Field>
|
|
301
|
+
<FieldLabel>Return pickup</FieldLabel>
|
|
302
|
+
<DateTimeField
|
|
303
|
+
defaultValue={plainDateTime(plainDate(2026, 10, 9), plainTime(10, 0))}
|
|
304
|
+
disabled
|
|
305
|
+
locale="en-US"
|
|
306
|
+
/>
|
|
307
|
+
<FieldDescription>Returns open once the order is delivered.</FieldDescription>
|
|
308
|
+
</Field>
|
|
309
|
+
</Stack>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Clearing both halves
|
|
315
|
+
|
|
316
|
+
One button, and it empties the whole value — there is no control that clears one side, because a datetime with one half missing is not a value the field holds. It appears only when something is written and the control is editable, and focus goes back to the first segment so the reader can start again without reaching for the mouse.
|
|
317
|
+
|
|
318
|
+
Excerpt — not a complete module
|
|
319
|
+
|
|
320
|
+
```tsx
|
|
321
|
+
<DateTimeField clearable locale="pt-BR" messages={{ clear: 'Clear pickup slot' }} />;
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Adornments
|
|
325
|
+
|
|
326
|
+
The two slots are named for the reading direction rather than for a side, so the same markup puts the mark before the value in both directions. The end slot is where datetime-picker puts its trigger — which is how the picker composes DateTimeField without redrawing any of it.
|
|
327
|
+
|
|
328
|
+
Example
|
|
329
|
+
|
|
330
|
+
```tsx
|
|
331
|
+
import { DateTimeField } from '@slotted/react/datetime-field';
|
|
332
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
333
|
+
import { Glyph, Icon } from '@slotted/react/icon';
|
|
334
|
+
import { Stack } from '@slotted/react/stack';
|
|
335
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
336
|
+
|
|
337
|
+
export default function DateTimeFieldAdornments() {
|
|
338
|
+
return (
|
|
339
|
+
<Stack gap={4}>
|
|
340
|
+
<Field>
|
|
341
|
+
<FieldLabel>Cutoff</FieldLabel>
|
|
342
|
+
<DateTimeField
|
|
343
|
+
defaultValue={plainDateTime(plainDate(2026, 9, 30), plainTime(17, 0))}
|
|
344
|
+
locale="en-US"
|
|
345
|
+
start={
|
|
346
|
+
<Icon>
|
|
347
|
+
<Glyph name="calendar" />
|
|
348
|
+
</Icon>
|
|
349
|
+
}
|
|
350
|
+
/>
|
|
351
|
+
</Field>
|
|
352
|
+
<Field>
|
|
353
|
+
<FieldLabel>Pickup window opens</FieldLabel>
|
|
354
|
+
<DateTimeField
|
|
355
|
+
defaultValue={plainDateTime(plainDate(2026, 10, 5), plainTime(9, 0))}
|
|
356
|
+
end="Central time"
|
|
357
|
+
locale="en-US"
|
|
358
|
+
/>
|
|
359
|
+
</Field>
|
|
360
|
+
<Field>
|
|
361
|
+
<FieldLabel>Statement closes</FieldLabel>
|
|
362
|
+
<DateTimeField
|
|
363
|
+
defaultValue={plainDateTime(plainDate(2026, 10, 31), plainTime(23, 59))}
|
|
364
|
+
end="UTC-5"
|
|
365
|
+
locale="en-US"
|
|
366
|
+
start={
|
|
367
|
+
<Icon>
|
|
368
|
+
<Glyph name="calendar" />
|
|
369
|
+
</Icon>
|
|
370
|
+
}
|
|
371
|
+
/>
|
|
372
|
+
</Field>
|
|
373
|
+
</Stack>
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### In a form
|
|
379
|
+
|
|
380
|
+
The value reaches a plain form post as YYYY-MM-DDTHH:mm:ss, which is input[type=datetime-local]’s own value format — no adapter, no serializer, nothing reading the control. The field around it supplies the label, the description and the error, and the control takes its size, its disabled state and its validity from that field unless it states its own.
|
|
381
|
+
|
|
382
|
+
Excerpt — not a complete module
|
|
383
|
+
|
|
384
|
+
```tsx
|
|
385
|
+
<form action="/appointments" method="post">
|
|
386
|
+
<Field invalid>
|
|
387
|
+
<FieldLabel>Appointment start</FieldLabel>
|
|
388
|
+
<DateTimeField name="start" required />
|
|
389
|
+
<FieldError>Choose a time within business hours.</FieldError>
|
|
390
|
+
</Field>
|
|
391
|
+
</form>;
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Content the field does not choose
|
|
395
|
+
|
|
396
|
+
A long day-period name, a right-to-left document, and a locale whose numbering system is not Latin. Each half is its own bidi run, so the digits read left to right inside a mirrored page — the alternative was a right-to-left capture reading 30:14, a time nobody wrote.
|
|
397
|
+
|
|
398
|
+
Excerpt — not a complete module
|
|
399
|
+
|
|
400
|
+
```tsx
|
|
401
|
+
<>
|
|
402
|
+
<DateTimeField hourCycle={12} locale="es-MX" />
|
|
403
|
+
<DateTimeField locale="ar-EG" />
|
|
404
|
+
<DateTimeField granularity="second" locale="ja-JP" />
|
|
405
|
+
</>;
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### Composition and escape hatches
|
|
409
|
+
|
|
410
|
+
The provider sets the clock and the zone once for the whole application, SlottedProvider the language; render substitutes the frame’s element and hands the ref back; and the handle reaches focus(), clear() and the segment the reader is on. A control that states any default itself still wins over the provider.
|
|
411
|
+
|
|
412
|
+
Excerpt — not a complete module
|
|
413
|
+
|
|
414
|
+
```tsx
|
|
415
|
+
<DateTimeFieldDefaultsProvider hourCycle={24} timeZone="America/Sao_Paulo">
|
|
416
|
+
<DateTimeField ref={handle} />
|
|
417
|
+
</DateTimeFieldDefaultsProvider>;
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### The keyboard
|
|
421
|
+
|
|
422
|
+
Every key the spin-button pattern lists, and three it does not. The arrows across walk the whole row — from the year into the hour — which two nested fields could not do. A key the field acts on is stopped rather than only defaulted, because a div with role="spinbutton" is invisible to every "is the target editable" guard an application writes.
|
|
423
|
+
|
|
424
|
+
Excerpt — not a complete module
|
|
425
|
+
|
|
426
|
+
```tsx
|
|
427
|
+
<DateTimeField
|
|
428
|
+
locale="pt-BR"
|
|
429
|
+
onKeyDown={(event) => {
|
|
430
|
+
if (event.key === 'Enter') submit();
|
|
431
|
+
}}
|
|
432
|
+
/>;
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### appearance.tsx
|
|
436
|
+
|
|
437
|
+
Example
|
|
438
|
+
|
|
439
|
+
```tsx
|
|
440
|
+
import { DateTimeField } from '@slotted/react/datetime-field';
|
|
441
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
442
|
+
import { Stack } from '@slotted/react/stack';
|
|
443
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
444
|
+
|
|
445
|
+
const SLOT = plainDateTime(plainDate(2026, 9, 30), plainTime(14, 30));
|
|
446
|
+
|
|
447
|
+
export default function DateTimeFieldAppearance() {
|
|
448
|
+
return (
|
|
449
|
+
<Stack gap={4}>
|
|
450
|
+
<Field>
|
|
451
|
+
<FieldLabel>Small</FieldLabel>
|
|
452
|
+
<DateTimeField defaultValue={SLOT} locale="en-US" size="sm" />
|
|
453
|
+
</Field>
|
|
454
|
+
<Field>
|
|
455
|
+
<FieldLabel>Medium</FieldLabel>
|
|
456
|
+
<DateTimeField defaultValue={SLOT} locale="en-US" size="md" />
|
|
457
|
+
</Field>
|
|
458
|
+
<Field>
|
|
459
|
+
<FieldLabel>Large</FieldLabel>
|
|
460
|
+
<DateTimeField defaultValue={SLOT} locale="en-US" size="lg" />
|
|
461
|
+
</Field>
|
|
462
|
+
<Field>
|
|
463
|
+
<FieldLabel>Outline</FieldLabel>
|
|
464
|
+
<DateTimeField defaultValue={SLOT} locale="en-US" variant="outline" />
|
|
465
|
+
</Field>
|
|
466
|
+
<Field>
|
|
467
|
+
<FieldLabel>Subtle</FieldLabel>
|
|
468
|
+
<DateTimeField defaultValue={SLOT} locale="en-US" variant="subtle" />
|
|
469
|
+
</Field>
|
|
470
|
+
<Field>
|
|
471
|
+
<FieldLabel>Plain</FieldLabel>
|
|
472
|
+
<DateTimeField defaultValue={SLOT} locale="en-US" variant="plain" />
|
|
473
|
+
</Field>
|
|
474
|
+
</Stack>
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### controlled.tsx
|
|
480
|
+
|
|
481
|
+
Example
|
|
482
|
+
|
|
483
|
+
```tsx
|
|
484
|
+
import { useState } from 'react';
|
|
485
|
+
import { Button } from '@slotted/react/button';
|
|
486
|
+
import { DateTimeField, type DateTimeFieldChangeRequest } from '@slotted/react/datetime-field';
|
|
487
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
488
|
+
import { Inline } from '@slotted/react/inline';
|
|
489
|
+
import { Stack } from '@slotted/react/stack';
|
|
490
|
+
import {
|
|
491
|
+
plainDate,
|
|
492
|
+
plainDateTime,
|
|
493
|
+
plainTime,
|
|
494
|
+
toISODateTime,
|
|
495
|
+
type DateTimeHalf,
|
|
496
|
+
type PlainDateTime,
|
|
497
|
+
} from '@slotted/core/date';
|
|
498
|
+
|
|
499
|
+
const MORNING = plainDateTime(plainDate(2026, 10, 1), plainTime(9, 0));
|
|
500
|
+
const AFTERNOON = plainDateTime(plainDate(2026, 10, 2), plainTime(16, 0));
|
|
501
|
+
|
|
502
|
+
export default function DateTimeFieldControlled() {
|
|
503
|
+
const [dispatch, setDispatch] = useState<PlainDateTime | null>(MORNING);
|
|
504
|
+
const [missing, setMissing] = useState<DateTimeHalf | null>(null);
|
|
505
|
+
|
|
506
|
+
const summary = describe(dispatch, missing);
|
|
507
|
+
|
|
508
|
+
function handleChange(value: PlainDateTime | null, request: DateTimeFieldChangeRequest) {
|
|
509
|
+
setDispatch(value);
|
|
510
|
+
setMissing(request.incomplete);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function select(value: PlainDateTime | null) {
|
|
514
|
+
setDispatch(value);
|
|
515
|
+
setMissing(null);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
return (
|
|
519
|
+
<Stack gap={4}>
|
|
520
|
+
<Field>
|
|
521
|
+
<FieldLabel>Dispatch</FieldLabel>
|
|
522
|
+
<DateTimeField locale="en-US" onValueChange={handleChange} value={dispatch} />
|
|
523
|
+
<FieldDescription>{summary}</FieldDescription>
|
|
524
|
+
</Field>
|
|
525
|
+
<Inline gap={2}>
|
|
526
|
+
<Button onClick={() => select(MORNING)} size="sm" tone="secondary" variant="outline">
|
|
527
|
+
Thursday 09:00
|
|
528
|
+
</Button>
|
|
529
|
+
<Button onClick={() => select(AFTERNOON)} size="sm" tone="secondary" variant="outline">
|
|
530
|
+
Friday 16:00
|
|
531
|
+
</Button>
|
|
532
|
+
<Button onClick={() => select(null)} size="sm" tone="secondary" variant="ghost">
|
|
533
|
+
No dispatch
|
|
534
|
+
</Button>
|
|
535
|
+
</Inline>
|
|
536
|
+
</Stack>
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function describe(value: PlainDateTime | null, missing: DateTimeHalf | null): string {
|
|
541
|
+
if (value !== null) return `Dispatch set for ${toISODateTime(value)}.`;
|
|
542
|
+
if (missing !== null) return `The ${missing} is missing, so there is no dispatch yet.`;
|
|
543
|
+
|
|
544
|
+
return 'No dispatch scheduled.';
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### defaults.tsx
|
|
549
|
+
|
|
550
|
+
Example
|
|
551
|
+
|
|
552
|
+
```tsx
|
|
553
|
+
import { DateTimeField, DateTimeFieldDefaultsProvider } from '@slotted/react/datetime-field';
|
|
554
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
555
|
+
import { Stack } from '@slotted/react/stack';
|
|
556
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
557
|
+
|
|
558
|
+
export default function DateTimeFieldDefaultsExample() {
|
|
559
|
+
return (
|
|
560
|
+
<DateTimeFieldDefaultsProvider hourCycle={24} size="sm" variant="subtle">
|
|
561
|
+
<Stack gap={4}>
|
|
562
|
+
<Field>
|
|
563
|
+
<FieldLabel>Opened</FieldLabel>
|
|
564
|
+
<DateTimeField
|
|
565
|
+
defaultValue={plainDateTime(plainDate(2026, 8, 3), plainTime(8, 15))}
|
|
566
|
+
locale="en-US"
|
|
567
|
+
/>
|
|
568
|
+
</Field>
|
|
569
|
+
<Field>
|
|
570
|
+
<FieldLabel>Last updated</FieldLabel>
|
|
571
|
+
<DateTimeField
|
|
572
|
+
defaultValue={plainDateTime(plainDate(2026, 9, 18), plainTime(16, 40))}
|
|
573
|
+
locale="en-US"
|
|
574
|
+
/>
|
|
575
|
+
</Field>
|
|
576
|
+
<Field>
|
|
577
|
+
<FieldLabel>Closes, stated on the control</FieldLabel>
|
|
578
|
+
<DateTimeField
|
|
579
|
+
defaultValue={plainDateTime(plainDate(2026, 12, 1), plainTime(17, 0))}
|
|
580
|
+
hourCycle={12}
|
|
581
|
+
locale="en-US"
|
|
582
|
+
size="lg"
|
|
583
|
+
variant="outline"
|
|
584
|
+
/>
|
|
585
|
+
</Field>
|
|
586
|
+
</Stack>
|
|
587
|
+
</DateTimeFieldDefaultsProvider>
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### form.tsx
|
|
593
|
+
|
|
594
|
+
Example
|
|
595
|
+
|
|
596
|
+
```tsx
|
|
597
|
+
import { useState } from 'react';
|
|
598
|
+
import type { SubmitEvent } from 'react';
|
|
599
|
+
import { Button } from '@slotted/react/button';
|
|
600
|
+
import { DateTimeField } from '@slotted/react/datetime-field';
|
|
601
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
602
|
+
import { Inline } from '@slotted/react/inline';
|
|
603
|
+
import { Stack } from '@slotted/react/stack';
|
|
604
|
+
import { Text } from '@slotted/react/typography';
|
|
605
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
606
|
+
|
|
607
|
+
export default function DateTimeFieldForm() {
|
|
608
|
+
const [sent, setSent] = useState<string | null>(null);
|
|
609
|
+
|
|
610
|
+
function handleSubmit(event: SubmitEvent<HTMLFormElement>) {
|
|
611
|
+
event.preventDefault();
|
|
612
|
+
const data = new FormData(event.currentTarget);
|
|
613
|
+
setSent(`pickup=${String(data.get('pickup'))}`);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
return (
|
|
617
|
+
<form onSubmit={handleSubmit}>
|
|
618
|
+
<Stack gap={4}>
|
|
619
|
+
<Field>
|
|
620
|
+
<FieldLabel>Pickup slot</FieldLabel>
|
|
621
|
+
<DateTimeField
|
|
622
|
+
clearable
|
|
623
|
+
defaultValue={plainDateTime(plainDate(2026, 9, 30), plainTime(14, 30))}
|
|
624
|
+
locale="en-US"
|
|
625
|
+
name="pickup"
|
|
626
|
+
/>
|
|
627
|
+
</Field>
|
|
628
|
+
<Inline align="center" gap={3}>
|
|
629
|
+
<Button type="submit">Book pickup</Button>
|
|
630
|
+
{sent !== null && (
|
|
631
|
+
<Text size="sm" tone="muted">
|
|
632
|
+
Sent {sent}
|
|
633
|
+
</Text>
|
|
634
|
+
)}
|
|
635
|
+
</Inline>
|
|
636
|
+
</Stack>
|
|
637
|
+
</form>
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
### limits.tsx
|
|
643
|
+
|
|
644
|
+
Example
|
|
645
|
+
|
|
646
|
+
```tsx
|
|
647
|
+
import { DateTimeField } from '@slotted/react/datetime-field';
|
|
648
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
649
|
+
import { Stack } from '@slotted/react/stack';
|
|
650
|
+
import {
|
|
651
|
+
dayOfWeek,
|
|
652
|
+
plainDate,
|
|
653
|
+
plainDateTime,
|
|
654
|
+
plainTime,
|
|
655
|
+
type PlainDate,
|
|
656
|
+
type PlainTime,
|
|
657
|
+
} from '@slotted/core/date';
|
|
658
|
+
|
|
659
|
+
const EARLIEST = plainDateTime(plainDate(2026, 10, 5), plainTime(9, 0));
|
|
660
|
+
const LATEST = plainDateTime(plainDate(2026, 10, 30), plainTime(17, 0));
|
|
661
|
+
const OPENS = plainTime(9, 0);
|
|
662
|
+
const CLOSES = plainTime(17, 0);
|
|
663
|
+
|
|
664
|
+
const isSunday = (date: PlainDate) => dayOfWeek(date) === 0;
|
|
665
|
+
const isLunchHour = (time: PlainTime) => time.hour === 12;
|
|
666
|
+
|
|
667
|
+
export default function DateTimeFieldLimits() {
|
|
668
|
+
return (
|
|
669
|
+
<Stack gap={5}>
|
|
670
|
+
<Field>
|
|
671
|
+
<FieldLabel>Pickup slot</FieldLabel>
|
|
672
|
+
<DateTimeField
|
|
673
|
+
defaultValue={plainDateTime(plainDate(2026, 10, 12), plainTime(18, 30))}
|
|
674
|
+
hourCycle={24}
|
|
675
|
+
locale="en-US"
|
|
676
|
+
max={LATEST}
|
|
677
|
+
maxTime={CLOSES}
|
|
678
|
+
min={EARLIEST}
|
|
679
|
+
minTime={OPENS}
|
|
680
|
+
/>
|
|
681
|
+
<FieldDescription>
|
|
682
|
+
Pickups run from October 5 to October 30, between 09:00 and 17:00 on every day.
|
|
683
|
+
</FieldDescription>
|
|
684
|
+
</Field>
|
|
685
|
+
<Field>
|
|
686
|
+
<FieldLabel>Delivery slot</FieldLabel>
|
|
687
|
+
<DateTimeField
|
|
688
|
+
defaultValue={plainDateTime(plainDate(2026, 10, 13), plainTime(14, 0))}
|
|
689
|
+
hourCycle={24}
|
|
690
|
+
isDateUnavailable={isSunday}
|
|
691
|
+
isTimeUnavailable={isLunchHour}
|
|
692
|
+
locale="en-US"
|
|
693
|
+
/>
|
|
694
|
+
<FieldDescription>No deliveries on Sundays or between 12:00 and 12:59.</FieldDescription>
|
|
695
|
+
</Field>
|
|
696
|
+
</Stack>
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
```
|