@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,682 @@
|
|
|
1
|
+
<!-- index: ./index.md -->
|
|
2
|
+
# datetime-range-picker
|
|
3
|
+
|
|
4
|
+
`data-ui="datetime-range-picker"` · Start and end date-times with a picker.
|
|
5
|
+
|
|
6
|
+
## Examples
|
|
7
|
+
|
|
8
|
+
### Playground
|
|
9
|
+
|
|
10
|
+
Press a day, then its time, then the other day and its time. A press that leaves a half missing moves focus to the grid of that half, and Apply writes the run.
|
|
11
|
+
|
|
12
|
+
Excerpt — not a complete module
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
<DateTimeRangePicker defaultValue={RENTAL} />;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Two months and two clocks
|
|
19
|
+
|
|
20
|
+
The run is drawn over its months, both ends are typed or pressed, and each clock answers the day of its own end.
|
|
21
|
+
|
|
22
|
+
Excerpt — not a complete module
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
<DateTimeRangePicker {...BASE} defaultValue={RENTAL} defaultOpen />;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### The length
|
|
29
|
+
|
|
30
|
+
The length between the two ends, with a step of one day on the end either way. lengthLabel writes it in the product’s own words.
|
|
31
|
+
|
|
32
|
+
Excerpt — not a complete module
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
<DateTimeRangePicker {...BASE} defaultValue={RENTAL} />;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Durations
|
|
39
|
+
|
|
40
|
+
Lengths the run takes from its start. A length that a rule refuses is disabled, and an empty list draws none.
|
|
41
|
+
|
|
42
|
+
Excerpt — not a complete module
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
<DateTimeRangePicker {...BASE} defaultValue={RENTAL} durations={[43200, 86400, 604800]} />;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### The shortest and the longest run
|
|
49
|
+
|
|
50
|
+
The shortest and the longest run, in seconds. A run over a limit says by how much and marks its days, and Apply is disabled.
|
|
51
|
+
|
|
52
|
+
Example
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { DateTimeRangePicker } from '@slotted/react/datetime-range-picker';
|
|
56
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
57
|
+
import { Stack } from '@slotted/react/stack';
|
|
58
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
59
|
+
|
|
60
|
+
const at = (day: number, hour: number, minute = 0) =>
|
|
61
|
+
plainDateTime(plainDate(2026, 9, day), plainTime(hour, minute));
|
|
62
|
+
|
|
63
|
+
const billableDays = (seconds: number) => `${String(Math.ceil(seconds / 86_400))} billable days`;
|
|
64
|
+
|
|
65
|
+
const SHARED = {
|
|
66
|
+
hourCycle: 24,
|
|
67
|
+
lengthLabel: billableDays,
|
|
68
|
+
locale: 'en-US',
|
|
69
|
+
max: at(30, 18),
|
|
70
|
+
maxLength: 604800,
|
|
71
|
+
min: at(10, 8),
|
|
72
|
+
minLength: 86400,
|
|
73
|
+
today: plainDate(2026, 9, 10),
|
|
74
|
+
} as const;
|
|
75
|
+
|
|
76
|
+
export default function DateTimeRangePickerLimits() {
|
|
77
|
+
return (
|
|
78
|
+
<Stack gap={4}>
|
|
79
|
+
<Field>
|
|
80
|
+
<FieldLabel>Within the limits</FieldLabel>
|
|
81
|
+
<DateTimeRangePicker
|
|
82
|
+
{...SHARED}
|
|
83
|
+
defaultValue={{ start: at(14, 17), end: at(17, 10, 30) }}
|
|
84
|
+
/>
|
|
85
|
+
</Field>
|
|
86
|
+
<Field>
|
|
87
|
+
<FieldLabel>Over the longest run</FieldLabel>
|
|
88
|
+
<DateTimeRangePicker
|
|
89
|
+
{...SHARED}
|
|
90
|
+
defaultValue={{ start: at(14, 17), end: at(24, 10, 30) }}
|
|
91
|
+
/>
|
|
92
|
+
</Field>
|
|
93
|
+
</Stack>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### The hours of every day
|
|
99
|
+
|
|
100
|
+
min and max bound the whole run, and minTime and maxTime bound every day inside it. Each clock runs on the day of its own end.
|
|
101
|
+
|
|
102
|
+
Example
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import { DateTimeRangePicker } from '@slotted/react/datetime-range-picker';
|
|
106
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
107
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
108
|
+
|
|
109
|
+
export default function DateTimeRangePickerDayWindow() {
|
|
110
|
+
return (
|
|
111
|
+
<Field>
|
|
112
|
+
<FieldLabel>Warehouse visit</FieldLabel>
|
|
113
|
+
<DateTimeRangePicker
|
|
114
|
+
defaultValue={{
|
|
115
|
+
start: plainDateTime(plainDate(2026, 9, 14), plainTime(9)),
|
|
116
|
+
end: plainDateTime(plainDate(2026, 9, 16), plainTime(16, 30)),
|
|
117
|
+
}}
|
|
118
|
+
hourCycle={24}
|
|
119
|
+
locale="en-US"
|
|
120
|
+
maxTime={plainTime(18)}
|
|
121
|
+
minTime={plainTime(8)}
|
|
122
|
+
step={1800}
|
|
123
|
+
today={plainDate(2026, 9, 10)}
|
|
124
|
+
/>
|
|
125
|
+
<FieldDescription>Receiving is open from 08:00 to 18:00, in half hours.</FieldDescription>
|
|
126
|
+
</Field>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Days the product refuses
|
|
132
|
+
|
|
133
|
+
A run may not cross an unavailable day while contiguous holds, and the grid refuses the days beyond it.
|
|
134
|
+
|
|
135
|
+
Example
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import { DateTimeRangePicker } from '@slotted/react/datetime-range-picker';
|
|
139
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
140
|
+
import { Stack } from '@slotted/react/stack';
|
|
141
|
+
import { plainDate } from '@slotted/core/date';
|
|
142
|
+
import type { PlainDate, PlainTime } from '@slotted/core/date';
|
|
143
|
+
|
|
144
|
+
const isClosed = ({ day }: PlainDate) => day === 19;
|
|
145
|
+
const isAtLunch = ({ hour }: PlainTime, { day }: PlainDate) => day === 15 && hour === 12;
|
|
146
|
+
|
|
147
|
+
const SHARED = {
|
|
148
|
+
hourCycle: 24,
|
|
149
|
+
isDateUnavailable: isClosed,
|
|
150
|
+
isTimeUnavailable: isAtLunch,
|
|
151
|
+
locale: 'en-US',
|
|
152
|
+
today: plainDate(2026, 9, 10),
|
|
153
|
+
} as const;
|
|
154
|
+
|
|
155
|
+
export default function DateTimeRangePickerUnavailable() {
|
|
156
|
+
return (
|
|
157
|
+
<Stack gap={4}>
|
|
158
|
+
<Field>
|
|
159
|
+
<FieldLabel>Contiguous run</FieldLabel>
|
|
160
|
+
<DateTimeRangePicker {...SHARED} />
|
|
161
|
+
<FieldDescription>September 19 is a holiday closure.</FieldDescription>
|
|
162
|
+
</Field>
|
|
163
|
+
<Field>
|
|
164
|
+
<FieldLabel>Run that may cross the closure</FieldLabel>
|
|
165
|
+
<DateTimeRangePicker {...SHARED} contiguous={false} />
|
|
166
|
+
</Field>
|
|
167
|
+
</Stack>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Whole times
|
|
173
|
+
|
|
174
|
+
options states the times that exist, the same list for both ends.
|
|
175
|
+
|
|
176
|
+
Excerpt — not a complete module
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
<DateTimeRangePicker {...BASE} defaultValue={RENTAL} options={DESK} />;
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Months
|
|
183
|
+
|
|
184
|
+
Two months by default, over two clocks of the same module. One month suits a narrow column and a run inside one month.
|
|
185
|
+
|
|
186
|
+
Excerpt — not a complete module
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
<DateTimeRangePicker {...BASE} defaultValue={RENTAL} months={1} />;
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Shortcuts
|
|
193
|
+
|
|
194
|
+
A label and a run, or a function that resolves one. The panel writes the two days, and a run that the rules refuse is disabled.
|
|
195
|
+
|
|
196
|
+
Excerpt — not a complete module
|
|
197
|
+
|
|
198
|
+
```tsx
|
|
199
|
+
<DateTimeRangePicker {...BASE} defaultValue={RENTAL} presets={PRESETS} />;
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### With and without a confirmation
|
|
203
|
+
|
|
204
|
+
The panel keeps a draft until Apply. confirm={false} writes a whole run on every change, and closes on the press that completes it.
|
|
205
|
+
|
|
206
|
+
Example
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
import { DateTimeRangePicker } from '@slotted/react/datetime-range-picker';
|
|
210
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
211
|
+
import { Stack } from '@slotted/react/stack';
|
|
212
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
213
|
+
|
|
214
|
+
const RUN = {
|
|
215
|
+
start: plainDateTime(plainDate(2026, 9, 14), plainTime(17)),
|
|
216
|
+
end: plainDateTime(plainDate(2026, 9, 17), plainTime(10, 30)),
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export default function DateTimeRangePickerConfirm() {
|
|
220
|
+
return (
|
|
221
|
+
<Stack gap={4}>
|
|
222
|
+
<Field>
|
|
223
|
+
<FieldLabel>Applied with a button</FieldLabel>
|
|
224
|
+
<DateTimeRangePicker
|
|
225
|
+
defaultValue={RUN}
|
|
226
|
+
hourCycle={24}
|
|
227
|
+
locale="en-US"
|
|
228
|
+
today={plainDate(2026, 9, 10)}
|
|
229
|
+
/>
|
|
230
|
+
</Field>
|
|
231
|
+
<Field>
|
|
232
|
+
<FieldLabel>Written on every change</FieldLabel>
|
|
233
|
+
<DateTimeRangePicker
|
|
234
|
+
confirm={false}
|
|
235
|
+
defaultValue={RUN}
|
|
236
|
+
hourCycle={24}
|
|
237
|
+
locale="en-US"
|
|
238
|
+
today={plainDate(2026, 9, 10)}
|
|
239
|
+
/>
|
|
240
|
+
</Field>
|
|
241
|
+
</Stack>
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### An open end
|
|
247
|
+
|
|
248
|
+
A start with no end is a value, for example in a filter. The open end is written in the field.
|
|
249
|
+
|
|
250
|
+
Excerpt — not a complete module
|
|
251
|
+
|
|
252
|
+
```tsx
|
|
253
|
+
<DateTimeRangePicker {...BASE} defaultPosition="end" defaultValue={OPEN} />;
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Size
|
|
257
|
+
|
|
258
|
+
The three heights every control has. The panel keeps its own measures at each of them.
|
|
259
|
+
|
|
260
|
+
Excerpt — not a complete module
|
|
261
|
+
|
|
262
|
+
```tsx
|
|
263
|
+
<DateTimeRangePicker {...BASE} defaultValue={RENTAL} size="sm" />;
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Variant
|
|
267
|
+
|
|
268
|
+
The three frames every field has, so a picker stands beside a field of the same variant.
|
|
269
|
+
|
|
270
|
+
Excerpt — not a complete module
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
<DateTimeRangePicker {...BASE} defaultValue={RENTAL} variant="outline" />;
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### States
|
|
277
|
+
|
|
278
|
+
Each state belongs to the frame, and the trigger follows it.
|
|
279
|
+
|
|
280
|
+
Example
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
import { DateTimeRangePicker } from '@slotted/react/datetime-range-picker';
|
|
284
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from '@slotted/react/field';
|
|
285
|
+
import { Stack } from '@slotted/react/stack';
|
|
286
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
287
|
+
|
|
288
|
+
const SHARED = {
|
|
289
|
+
defaultValue: {
|
|
290
|
+
start: plainDateTime(plainDate(2026, 9, 14), plainTime(17)),
|
|
291
|
+
end: plainDateTime(plainDate(2026, 9, 17), plainTime(10, 30)),
|
|
292
|
+
},
|
|
293
|
+
hourCycle: 24,
|
|
294
|
+
locale: 'en-US',
|
|
295
|
+
today: plainDate(2026, 9, 10),
|
|
296
|
+
} as const;
|
|
297
|
+
|
|
298
|
+
export default function DateTimeRangePickerStates() {
|
|
299
|
+
return (
|
|
300
|
+
<Stack gap={5}>
|
|
301
|
+
<Field>
|
|
302
|
+
<FieldLabel>Delivery window</FieldLabel>
|
|
303
|
+
<DateTimeRangePicker hourCycle={24} locale="en-US" required today={SHARED.today} />
|
|
304
|
+
<FieldDescription>Required to book the carrier.</FieldDescription>
|
|
305
|
+
</Field>
|
|
306
|
+
<Field>
|
|
307
|
+
<FieldLabel>Billing period</FieldLabel>
|
|
308
|
+
<DateTimeRangePicker {...SHARED} invalid />
|
|
309
|
+
<FieldError>The period overlaps the previous invoice.</FieldError>
|
|
310
|
+
</Field>
|
|
311
|
+
<Field>
|
|
312
|
+
<FieldLabel>Order window</FieldLabel>
|
|
313
|
+
<DateTimeRangePicker {...SHARED} readOnly />
|
|
314
|
+
<FieldDescription>Set when the order was placed.</FieldDescription>
|
|
315
|
+
</Field>
|
|
316
|
+
<Field>
|
|
317
|
+
<FieldLabel>Return window</FieldLabel>
|
|
318
|
+
<DateTimeRangePicker {...SHARED} disabled />
|
|
319
|
+
<FieldDescription>Returns open once the order is delivered.</FieldDescription>
|
|
320
|
+
</Field>
|
|
321
|
+
</Stack>
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### In a form
|
|
327
|
+
|
|
328
|
+
startName and endName post the two ends, a form reset returns to the first run, and a Field names the frame, not the panel.
|
|
329
|
+
|
|
330
|
+
Excerpt — not a complete module
|
|
331
|
+
|
|
332
|
+
```tsx
|
|
333
|
+
<Field>
|
|
334
|
+
<FieldLabel>Rental</FieldLabel>
|
|
335
|
+
<DateTimeRangePicker endName="to" startName="from" />
|
|
336
|
+
</Field>;
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### One column
|
|
340
|
+
|
|
341
|
+
Below 760 pixels, each end is written as a day and a time in words, and a press on one brings its grid. Below 480 pixels on a coarse pointer, the panel is a sheet.
|
|
342
|
+
|
|
343
|
+
Excerpt — not a complete module
|
|
344
|
+
|
|
345
|
+
```tsx
|
|
346
|
+
<DateTimeRangePicker {...BASE} defaultValue={RENTAL} presets={PRESETS} />;
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Composition and escape hatches
|
|
350
|
+
|
|
351
|
+
The consumer owns the value, the open state and the end being edited through props, and a defaults provider sets the shape once.
|
|
352
|
+
|
|
353
|
+
Excerpt — not a complete module
|
|
354
|
+
|
|
355
|
+
```tsx
|
|
356
|
+
<DateTimeRangePicker footer="Keys at the desk" onValueChange={setRun} value={run} />;
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### The keyboard
|
|
360
|
+
|
|
361
|
+
The fields, the months and the clocks keep their keys.
|
|
362
|
+
|
|
363
|
+
Excerpt — not a complete module
|
|
364
|
+
|
|
365
|
+
```tsx
|
|
366
|
+
// Enter, Space, ArrowDown opens on the day of the current end
|
|
367
|
+
// Arrows, Home, End move in the months, and in a grid of a clock
|
|
368
|
+
// PageUp / PageDown turn the month, and with Shift the year
|
|
369
|
+
// Enter / Space chooses, and brings the half that is missing
|
|
370
|
+
// Ctrl + Enter applies
|
|
371
|
+
// Escape walks down a view, then discards and closes
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### appearance.tsx
|
|
375
|
+
|
|
376
|
+
Example
|
|
377
|
+
|
|
378
|
+
```tsx
|
|
379
|
+
import { DateTimeRangePicker } from '@slotted/react/datetime-range-picker';
|
|
380
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
381
|
+
import { Stack } from '@slotted/react/stack';
|
|
382
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
383
|
+
|
|
384
|
+
const SHARED = {
|
|
385
|
+
defaultValue: {
|
|
386
|
+
start: plainDateTime(plainDate(2026, 9, 14), plainTime(17)),
|
|
387
|
+
end: plainDateTime(plainDate(2026, 9, 17), plainTime(10, 30)),
|
|
388
|
+
},
|
|
389
|
+
hourCycle: 24,
|
|
390
|
+
locale: 'en-US',
|
|
391
|
+
today: plainDate(2026, 9, 10),
|
|
392
|
+
} as const;
|
|
393
|
+
|
|
394
|
+
export default function DateTimeRangePickerAppearance() {
|
|
395
|
+
return (
|
|
396
|
+
<Stack gap={4}>
|
|
397
|
+
<Field>
|
|
398
|
+
<FieldLabel>Small</FieldLabel>
|
|
399
|
+
<DateTimeRangePicker {...SHARED} size="sm" />
|
|
400
|
+
</Field>
|
|
401
|
+
<Field>
|
|
402
|
+
<FieldLabel>Medium</FieldLabel>
|
|
403
|
+
<DateTimeRangePicker {...SHARED} size="md" />
|
|
404
|
+
</Field>
|
|
405
|
+
<Field>
|
|
406
|
+
<FieldLabel>Large</FieldLabel>
|
|
407
|
+
<DateTimeRangePicker {...SHARED} size="lg" />
|
|
408
|
+
</Field>
|
|
409
|
+
<Field>
|
|
410
|
+
<FieldLabel>Subtle</FieldLabel>
|
|
411
|
+
<DateTimeRangePicker {...SHARED} variant="subtle" />
|
|
412
|
+
</Field>
|
|
413
|
+
<Field>
|
|
414
|
+
<FieldLabel>Plain</FieldLabel>
|
|
415
|
+
<DateTimeRangePicker {...SHARED} variant="plain" />
|
|
416
|
+
</Field>
|
|
417
|
+
</Stack>
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### controlled.tsx
|
|
423
|
+
|
|
424
|
+
Example
|
|
425
|
+
|
|
426
|
+
```tsx
|
|
427
|
+
import { useState } from 'react';
|
|
428
|
+
import { Button } from '@slotted/react/button';
|
|
429
|
+
import { DateTimeRangePicker } from '@slotted/react/datetime-range-picker';
|
|
430
|
+
import type {
|
|
431
|
+
DateTimeRange,
|
|
432
|
+
DateTimeRangePickerPosition,
|
|
433
|
+
} from '@slotted/react/datetime-range-picker';
|
|
434
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
435
|
+
import { Inline } from '@slotted/react/inline';
|
|
436
|
+
import { Stack } from '@slotted/react/stack';
|
|
437
|
+
import { plainDate, plainDateTime, plainTime, toISODateTime } from '@slotted/core/date';
|
|
438
|
+
import type { PlainDateTime } from '@slotted/core/date';
|
|
439
|
+
|
|
440
|
+
const at = (day: number, hour: number, minute = 0) =>
|
|
441
|
+
plainDateTime(plainDate(2026, 9, day), plainTime(hour, minute));
|
|
442
|
+
const OPEN_END: DateTimeRange = { start: at(14, 17), end: null };
|
|
443
|
+
const CLOSED: DateTimeRange = { start: at(14, 17), end: at(17, 10, 30) };
|
|
444
|
+
|
|
445
|
+
export default function DateTimeRangePickerControlled() {
|
|
446
|
+
const [run, setRun] = useState<DateTimeRange | null>(OPEN_END);
|
|
447
|
+
const [position, setPosition] = useState<DateTimeRangePickerPosition>('end');
|
|
448
|
+
|
|
449
|
+
const summary = `Start ${moment(run?.start)}, end ${moment(run?.end)}. Editing the ${position}.`;
|
|
450
|
+
|
|
451
|
+
function handleValueChange(value: DateTimeRange | null) {
|
|
452
|
+
setRun(value);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function handlePositionChange(next: DateTimeRangePickerPosition) {
|
|
456
|
+
setPosition(next);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return (
|
|
460
|
+
<Stack gap={4}>
|
|
461
|
+
<Field>
|
|
462
|
+
<FieldLabel>Loan period</FieldLabel>
|
|
463
|
+
<DateTimeRangePicker
|
|
464
|
+
hourCycle={24}
|
|
465
|
+
locale="en-US"
|
|
466
|
+
onPositionChange={handlePositionChange}
|
|
467
|
+
onValueChange={handleValueChange}
|
|
468
|
+
position={position}
|
|
469
|
+
today={plainDate(2026, 9, 10)}
|
|
470
|
+
value={run}
|
|
471
|
+
/>
|
|
472
|
+
<FieldDescription>{summary}</FieldDescription>
|
|
473
|
+
</Field>
|
|
474
|
+
<Inline gap={2}>
|
|
475
|
+
<Button onClick={() => setPosition('start')} size="sm" tone="secondary" variant="outline">
|
|
476
|
+
Edit start
|
|
477
|
+
</Button>
|
|
478
|
+
<Button onClick={() => setPosition('end')} size="sm" tone="secondary" variant="outline">
|
|
479
|
+
Edit end
|
|
480
|
+
</Button>
|
|
481
|
+
<Button onClick={() => setRun(CLOSED)} size="sm" tone="secondary" variant="outline">
|
|
482
|
+
Monday to Thursday
|
|
483
|
+
</Button>
|
|
484
|
+
<Button onClick={() => setRun(OPEN_END)} size="sm" tone="secondary" variant="ghost">
|
|
485
|
+
Open end
|
|
486
|
+
</Button>
|
|
487
|
+
</Inline>
|
|
488
|
+
</Stack>
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function moment(value: PlainDateTime | null | undefined): string {
|
|
493
|
+
return value == null ? 'open' : toISODateTime(value);
|
|
494
|
+
}
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### form.tsx
|
|
498
|
+
|
|
499
|
+
Example
|
|
500
|
+
|
|
501
|
+
```tsx
|
|
502
|
+
import { useState } from 'react';
|
|
503
|
+
import type { SubmitEvent } from 'react';
|
|
504
|
+
import { Button } from '@slotted/react/button';
|
|
505
|
+
import { DateTimeRangePicker } from '@slotted/react/datetime-range-picker';
|
|
506
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
507
|
+
import { Inline } from '@slotted/react/inline';
|
|
508
|
+
import { Stack } from '@slotted/react/stack';
|
|
509
|
+
import { Text } from '@slotted/react/typography';
|
|
510
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
511
|
+
|
|
512
|
+
const SCHEDULED = {
|
|
513
|
+
start: plainDateTime(plainDate(2026, 9, 14), plainTime(17)),
|
|
514
|
+
end: plainDateTime(plainDate(2026, 9, 17), plainTime(10, 30)),
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
export default function DateTimeRangePickerForm() {
|
|
518
|
+
const [sent, setSent] = useState<string | null>(null);
|
|
519
|
+
|
|
520
|
+
function handleSubmit(event: SubmitEvent<HTMLFormElement>) {
|
|
521
|
+
event.preventDefault();
|
|
522
|
+
const data = new FormData(event.currentTarget);
|
|
523
|
+
setSent(`from=${String(data.get('from'))} to=${String(data.get('to'))}`);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
return (
|
|
527
|
+
<form onSubmit={handleSubmit}>
|
|
528
|
+
<Stack gap={4}>
|
|
529
|
+
<Field>
|
|
530
|
+
<FieldLabel>Pickup window</FieldLabel>
|
|
531
|
+
<DateTimeRangePicker
|
|
532
|
+
clearable
|
|
533
|
+
defaultValue={SCHEDULED}
|
|
534
|
+
endName="to"
|
|
535
|
+
hourCycle={24}
|
|
536
|
+
locale="en-US"
|
|
537
|
+
startName="from"
|
|
538
|
+
today={plainDate(2026, 9, 10)}
|
|
539
|
+
/>
|
|
540
|
+
</Field>
|
|
541
|
+
<Inline align="center" gap={3}>
|
|
542
|
+
<Button type="submit">Book pickup</Button>
|
|
543
|
+
<Button tone="secondary" type="reset" variant="ghost">
|
|
544
|
+
Reset
|
|
545
|
+
</Button>
|
|
546
|
+
</Inline>
|
|
547
|
+
{sent !== null && (
|
|
548
|
+
<Text size="sm" tone="muted">
|
|
549
|
+
Sent {sent}
|
|
550
|
+
</Text>
|
|
551
|
+
)}
|
|
552
|
+
</Stack>
|
|
553
|
+
</form>
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
### format.tsx
|
|
559
|
+
|
|
560
|
+
Example
|
|
561
|
+
|
|
562
|
+
```tsx
|
|
563
|
+
import { DateTimeRangePicker } from '@slotted/react/datetime-range-picker';
|
|
564
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
565
|
+
import { Stack } from '@slotted/react/stack';
|
|
566
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
567
|
+
|
|
568
|
+
const TODAY = plainDate(2026, 9, 10);
|
|
569
|
+
const DAY = plainDate(2026, 9, 14);
|
|
570
|
+
const NEXT = plainDate(2026, 9, 17);
|
|
571
|
+
|
|
572
|
+
export default function DateTimeRangePickerFormat() {
|
|
573
|
+
return (
|
|
574
|
+
<Stack gap={4}>
|
|
575
|
+
<Field>
|
|
576
|
+
<FieldLabel>12-hour clock</FieldLabel>
|
|
577
|
+
<DateTimeRangePicker
|
|
578
|
+
defaultValue={{
|
|
579
|
+
start: plainDateTime(DAY, plainTime(17)),
|
|
580
|
+
end: plainDateTime(NEXT, plainTime(10, 30)),
|
|
581
|
+
}}
|
|
582
|
+
hourCycle={12}
|
|
583
|
+
locale="en-US"
|
|
584
|
+
today={TODAY}
|
|
585
|
+
/>
|
|
586
|
+
</Field>
|
|
587
|
+
<Field>
|
|
588
|
+
<FieldLabel>Whole hours</FieldLabel>
|
|
589
|
+
<DateTimeRangePicker
|
|
590
|
+
defaultValue={{
|
|
591
|
+
start: plainDateTime(DAY, plainTime(17)),
|
|
592
|
+
end: plainDateTime(NEXT, plainTime(10)),
|
|
593
|
+
}}
|
|
594
|
+
granularity="hour"
|
|
595
|
+
hourCycle={24}
|
|
596
|
+
locale="en-US"
|
|
597
|
+
today={TODAY}
|
|
598
|
+
/>
|
|
599
|
+
</Field>
|
|
600
|
+
<Field>
|
|
601
|
+
<FieldLabel>To the second</FieldLabel>
|
|
602
|
+
<DateTimeRangePicker
|
|
603
|
+
defaultValue={{
|
|
604
|
+
start: plainDateTime(DAY, plainTime(17, 0, 30)),
|
|
605
|
+
end: plainDateTime(NEXT, plainTime(10, 30, 45)),
|
|
606
|
+
}}
|
|
607
|
+
granularity="second"
|
|
608
|
+
hourCycle={24}
|
|
609
|
+
locale="en-US"
|
|
610
|
+
today={TODAY}
|
|
611
|
+
/>
|
|
612
|
+
</Field>
|
|
613
|
+
</Stack>
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
### shortcuts.tsx
|
|
619
|
+
|
|
620
|
+
Example
|
|
621
|
+
|
|
622
|
+
```tsx
|
|
623
|
+
import { DateTimeRangePicker } from '@slotted/react/datetime-range-picker';
|
|
624
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
625
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
626
|
+
|
|
627
|
+
const at = (day: number, hour: number, minute = 0) =>
|
|
628
|
+
plainDateTime(plainDate(2026, 9, day), plainTime(hour, minute));
|
|
629
|
+
|
|
630
|
+
const PRESETS = [
|
|
631
|
+
{ label: 'Weekend', value: { start: at(18, 18), end: at(20, 20) } },
|
|
632
|
+
{ label: 'Next 24 hours', value: () => ({ start: at(10, 12), end: at(11, 12) }) },
|
|
633
|
+
{ label: 'Next week', value: { start: at(21, 9), end: at(25, 17) } },
|
|
634
|
+
];
|
|
635
|
+
|
|
636
|
+
export default function DateTimeRangePickerShortcuts() {
|
|
637
|
+
return (
|
|
638
|
+
<Field>
|
|
639
|
+
<FieldLabel>Dock booking</FieldLabel>
|
|
640
|
+
<DateTimeRangePicker
|
|
641
|
+
defaultValue={{ start: at(14, 8), end: at(15, 8) }}
|
|
642
|
+
durations={[43200, 86400, 259200, 604800]}
|
|
643
|
+
hourCycle={24}
|
|
644
|
+
locale="en-US"
|
|
645
|
+
presets={PRESETS}
|
|
646
|
+
today={plainDate(2026, 9, 10)}
|
|
647
|
+
/>
|
|
648
|
+
</Field>
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### times.tsx
|
|
654
|
+
|
|
655
|
+
Example
|
|
656
|
+
|
|
657
|
+
```tsx
|
|
658
|
+
import { DateTimeRangePicker } from '@slotted/react/datetime-range-picker';
|
|
659
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
660
|
+
import { plainDate, plainDateTime, plainTime } from '@slotted/core/date';
|
|
661
|
+
|
|
662
|
+
const SLOTS = [plainTime(8), plainTime(10, 30), plainTime(14), plainTime(17)];
|
|
663
|
+
|
|
664
|
+
export default function DateTimeRangePickerTimes() {
|
|
665
|
+
return (
|
|
666
|
+
<Field>
|
|
667
|
+
<FieldLabel>Driver shift</FieldLabel>
|
|
668
|
+
<DateTimeRangePicker
|
|
669
|
+
defaultValue={{
|
|
670
|
+
start: plainDateTime(plainDate(2026, 9, 14), plainTime(8)),
|
|
671
|
+
end: plainDateTime(plainDate(2026, 9, 15), plainTime(14)),
|
|
672
|
+
}}
|
|
673
|
+
hourCycle={24}
|
|
674
|
+
locale="en-US"
|
|
675
|
+
options={SLOTS}
|
|
676
|
+
today={plainDate(2026, 9, 10)}
|
|
677
|
+
/>
|
|
678
|
+
<FieldDescription>Shifts start and end at 08:00, 10:30, 14:00 or 17:00.</FieldDescription>
|
|
679
|
+
</Field>
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
```
|