@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,750 @@
|
|
|
1
|
+
<!-- index: ./index.md -->
|
|
2
|
+
# time-range-picker
|
|
3
|
+
|
|
4
|
+
`data-ui="time-range-picker"` · Start and end times with a picker.
|
|
5
|
+
|
|
6
|
+
## Examples
|
|
7
|
+
|
|
8
|
+
### Playground
|
|
9
|
+
|
|
10
|
+
Both ends, the length between them and the day are on screen. Press a time, type an end, drag a handle or step the length; Apply writes the run.
|
|
11
|
+
|
|
12
|
+
Excerpt — not a complete module
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
<TimeRangePicker defaultValue={BOOKING} />;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### The day and two clocks
|
|
19
|
+
|
|
20
|
+
The clock of the end refuses what the chosen start rules out, as soon as the start is chosen.
|
|
21
|
+
|
|
22
|
+
Excerpt — not a complete module
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
<TimeRangePicker {...BASE} defaultValue={BOOKING} defaultOpen />;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### The length
|
|
29
|
+
|
|
30
|
+
The length sits between the two ends and moves by one step of the clock either way. lengthLabel writes it in the product’s own words.
|
|
31
|
+
|
|
32
|
+
Excerpt — not a complete module
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
<TimeRangePicker {...BASE} defaultValue={BOOKING} />;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Durations
|
|
39
|
+
|
|
40
|
+
Lengths the run takes from its start. A length that passes midnight or breaks a rule is disabled, and an empty list draws none.
|
|
41
|
+
|
|
42
|
+
Excerpt — not a complete module
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
<TimeRangePicker {...BASE} defaultValue={BOOKING} durations={[1800, 3600, 14400]} />;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### The shortest and the longest run
|
|
49
|
+
|
|
50
|
+
minLength and maxLength are in seconds. A run outside a limit says by how much, and Apply is off.
|
|
51
|
+
|
|
52
|
+
Example
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
56
|
+
import { Stack } from '@slotted/react/stack';
|
|
57
|
+
import { TimeRangePicker } from '@slotted/react/time-range-picker';
|
|
58
|
+
import { plainTime } from '@slotted/core/date';
|
|
59
|
+
import type { PlainTime } from '@slotted/core/date';
|
|
60
|
+
|
|
61
|
+
const NOW = plainTime(8, 20);
|
|
62
|
+
const BOOKING = { start: plainTime(9), end: plainTime(11, 45) };
|
|
63
|
+
const isLunch = (time: PlainTime) => time.hour === 12;
|
|
64
|
+
|
|
65
|
+
export default function TimeRangePickerLimits() {
|
|
66
|
+
return (
|
|
67
|
+
<Stack gap={5}>
|
|
68
|
+
<Field>
|
|
69
|
+
<FieldLabel>Receiving window</FieldLabel>
|
|
70
|
+
<TimeRangePicker
|
|
71
|
+
defaultValue={{ start: plainTime(5, 30), end: plainTime(9) }}
|
|
72
|
+
hourCycle={24}
|
|
73
|
+
max={plainTime(20)}
|
|
74
|
+
min={plainTime(6)}
|
|
75
|
+
referenceTime={NOW}
|
|
76
|
+
/>
|
|
77
|
+
<FieldDescription>
|
|
78
|
+
The dock opens at 06:00, so 05:30 is outside the bounds.
|
|
79
|
+
</FieldDescription>
|
|
80
|
+
</Field>
|
|
81
|
+
<Field>
|
|
82
|
+
<FieldLabel>Cycle count slot</FieldLabel>
|
|
83
|
+
<TimeRangePicker
|
|
84
|
+
defaultValue={{ start: plainTime(9), end: plainTime(9, 15) }}
|
|
85
|
+
hourCycle={24}
|
|
86
|
+
maxLength={14400}
|
|
87
|
+
minLength={1800}
|
|
88
|
+
referenceTime={NOW}
|
|
89
|
+
/>
|
|
90
|
+
<FieldDescription>A slot lasts 30 minutes to 4 hours.</FieldDescription>
|
|
91
|
+
</Field>
|
|
92
|
+
<Field>
|
|
93
|
+
<FieldLabel>Pickup window</FieldLabel>
|
|
94
|
+
<TimeRangePicker
|
|
95
|
+
defaultValue={BOOKING}
|
|
96
|
+
hourCycle={24}
|
|
97
|
+
isTimeUnavailable={isLunch}
|
|
98
|
+
referenceTime={NOW}
|
|
99
|
+
/>
|
|
100
|
+
<FieldDescription>
|
|
101
|
+
The dock is closed from 12:00 to 12:59, so the clock offers no end after it.
|
|
102
|
+
</FieldDescription>
|
|
103
|
+
</Field>
|
|
104
|
+
<Field>
|
|
105
|
+
<FieldLabel>Staged pickup</FieldLabel>
|
|
106
|
+
<TimeRangePicker
|
|
107
|
+
contiguous={false}
|
|
108
|
+
defaultValue={BOOKING}
|
|
109
|
+
hourCycle={24}
|
|
110
|
+
isTimeUnavailable={isLunch}
|
|
111
|
+
referenceTime={NOW}
|
|
112
|
+
/>
|
|
113
|
+
<FieldDescription>A run may span the closure.</FieldDescription>
|
|
114
|
+
</Field>
|
|
115
|
+
</Stack>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Times the product refuses
|
|
121
|
+
|
|
122
|
+
While contiguous is true, a run may not cross an unavailable time.
|
|
123
|
+
|
|
124
|
+
Excerpt — not a complete module
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
<TimeRangePicker {...BASE} defaultValue={BOOKING} isTimeUnavailable={isNoon} />;
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Step
|
|
131
|
+
|
|
132
|
+
Seconds between two offered times, in both clocks, on the day and in the step of the length.
|
|
133
|
+
|
|
134
|
+
Excerpt — not a complete module
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
<TimeRangePicker {...BASE} defaultValue={BOOKING} step={300} />;
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Whole times
|
|
141
|
+
|
|
142
|
+
options states the times that exist, for both ends, under the part of the day each one falls in.
|
|
143
|
+
|
|
144
|
+
Excerpt — not a complete module
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
<TimeRangePicker {...BASE} options={CHANGES} />;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Shortcuts
|
|
151
|
+
|
|
152
|
+
A label and a run, or a function that returns one. The panel writes both ends, and a shortcut the rules refuse is disabled.
|
|
153
|
+
|
|
154
|
+
Excerpt — not a complete module
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
<TimeRangePicker {...BASE} defaultValue={BOOKING} presets={PRESETS} />;
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### With and without a confirmation
|
|
161
|
+
|
|
162
|
+
The panel keeps a draft until Apply. With confirm={false}, each change that completes a valid run is written, and the press that completes it closes the panel.
|
|
163
|
+
|
|
164
|
+
Example
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import { useState } from 'react';
|
|
168
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
169
|
+
import { Stack } from '@slotted/react/stack';
|
|
170
|
+
import { TimeRangePicker } from '@slotted/react/time-range-picker';
|
|
171
|
+
import type { TimeRange } from '@slotted/react/time-range-picker';
|
|
172
|
+
import { plainTime, toISOTime } from '@slotted/core/date';
|
|
173
|
+
|
|
174
|
+
const NOW = plainTime(8, 20);
|
|
175
|
+
const BOOKING = { start: plainTime(9), end: plainTime(11, 45) };
|
|
176
|
+
|
|
177
|
+
export default function TimeRangePickerConfirm() {
|
|
178
|
+
const [confirmed, setConfirmed] = useState<TimeRange | null>(BOOKING);
|
|
179
|
+
const [immediate, setImmediate] = useState<TimeRange | null>(BOOKING);
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<Stack gap={5}>
|
|
183
|
+
<Field>
|
|
184
|
+
<FieldLabel>With Apply</FieldLabel>
|
|
185
|
+
<TimeRangePicker
|
|
186
|
+
defaultValue={BOOKING}
|
|
187
|
+
hourCycle={24}
|
|
188
|
+
onValueChange={(value) => setConfirmed(value)}
|
|
189
|
+
referenceTime={NOW}
|
|
190
|
+
/>
|
|
191
|
+
<FieldDescription>{describe(confirmed)}</FieldDescription>
|
|
192
|
+
</Field>
|
|
193
|
+
<Field>
|
|
194
|
+
<FieldLabel>Without Apply</FieldLabel>
|
|
195
|
+
<TimeRangePicker
|
|
196
|
+
confirm={false}
|
|
197
|
+
defaultValue={BOOKING}
|
|
198
|
+
hourCycle={24}
|
|
199
|
+
onValueChange={(value) => setImmediate(value)}
|
|
200
|
+
referenceTime={NOW}
|
|
201
|
+
/>
|
|
202
|
+
<FieldDescription>{describe(immediate)}</FieldDescription>
|
|
203
|
+
</Field>
|
|
204
|
+
</Stack>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function describe(range: TimeRange | null): string {
|
|
209
|
+
if (range === null) return 'Nothing written.';
|
|
210
|
+
|
|
211
|
+
const [start, end] = [range.start, range.end].map((time) =>
|
|
212
|
+
time === null ? 'open' : toISOTime(time, 'minute'),
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
return `Written: ${start} to ${end}.`;
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### An open end
|
|
220
|
+
|
|
221
|
+
A start with no end is a value a filter can hold, and the dash in the summary shows it.
|
|
222
|
+
|
|
223
|
+
Example
|
|
224
|
+
|
|
225
|
+
```tsx
|
|
226
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
227
|
+
import { Stack } from '@slotted/react/stack';
|
|
228
|
+
import { TimeRangePicker } from '@slotted/react/time-range-picker';
|
|
229
|
+
import { plainTime } from '@slotted/core/date';
|
|
230
|
+
|
|
231
|
+
const NOW = plainTime(8, 20);
|
|
232
|
+
|
|
233
|
+
export default function TimeRangePickerOpenEnd() {
|
|
234
|
+
return (
|
|
235
|
+
<Stack gap={5}>
|
|
236
|
+
<Field>
|
|
237
|
+
<FieldLabel>Shift starting at 09:00</FieldLabel>
|
|
238
|
+
<TimeRangePicker
|
|
239
|
+
defaultPosition="end"
|
|
240
|
+
defaultValue={{ start: plainTime(9), end: null }}
|
|
241
|
+
hourCycle={24}
|
|
242
|
+
referenceTime={NOW}
|
|
243
|
+
/>
|
|
244
|
+
<FieldDescription>The panel opens on the end, which completes the run.</FieldDescription>
|
|
245
|
+
</Field>
|
|
246
|
+
<Field>
|
|
247
|
+
<FieldLabel>Deliveries until 17:00</FieldLabel>
|
|
248
|
+
<TimeRangePicker
|
|
249
|
+
defaultValue={{ start: null, end: plainTime(17) }}
|
|
250
|
+
hourCycle={24}
|
|
251
|
+
referenceTime={NOW}
|
|
252
|
+
/>
|
|
253
|
+
</Field>
|
|
254
|
+
</Stack>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Size
|
|
260
|
+
|
|
261
|
+
The three control heights. The panel keeps its own measures at each of them.
|
|
262
|
+
|
|
263
|
+
Excerpt — not a complete module
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
<TimeRangePicker {...BASE} defaultValue={BOOKING} size="sm" />;
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Variant
|
|
270
|
+
|
|
271
|
+
The three frames every field has, so a picker can stand beside a field of its own variant.
|
|
272
|
+
|
|
273
|
+
Excerpt — not a complete module
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
<TimeRangePicker {...BASE} defaultValue={BOOKING} variant="outline" />;
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### States
|
|
280
|
+
|
|
281
|
+
Each state belongs to the frame, and the trigger answers it.
|
|
282
|
+
|
|
283
|
+
Example
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
287
|
+
import { Stack } from '@slotted/react/stack';
|
|
288
|
+
import { TimeRangePicker } from '@slotted/react/time-range-picker';
|
|
289
|
+
import { plainTime } from '@slotted/core/date';
|
|
290
|
+
|
|
291
|
+
const NOW = plainTime(8, 20);
|
|
292
|
+
const BOOKING = { start: plainTime(9), end: plainTime(11, 45) };
|
|
293
|
+
|
|
294
|
+
export default function TimeRangePickerStates() {
|
|
295
|
+
return (
|
|
296
|
+
<Stack gap={5}>
|
|
297
|
+
<Field>
|
|
298
|
+
<FieldLabel>Disabled</FieldLabel>
|
|
299
|
+
<TimeRangePicker defaultValue={BOOKING} disabled hourCycle={24} referenceTime={NOW} />
|
|
300
|
+
</Field>
|
|
301
|
+
<Field>
|
|
302
|
+
<FieldLabel>Read only</FieldLabel>
|
|
303
|
+
<TimeRangePicker defaultValue={BOOKING} hourCycle={24} readOnly referenceTime={NOW} />
|
|
304
|
+
</Field>
|
|
305
|
+
<Field>
|
|
306
|
+
<FieldLabel>Invalid</FieldLabel>
|
|
307
|
+
<TimeRangePicker defaultValue={BOOKING} hourCycle={24} invalid referenceTime={NOW} />
|
|
308
|
+
</Field>
|
|
309
|
+
<Field>
|
|
310
|
+
<FieldLabel>Reversed</FieldLabel>
|
|
311
|
+
<TimeRangePicker
|
|
312
|
+
defaultValue={{ start: plainTime(14), end: plainTime(9) }}
|
|
313
|
+
hourCycle={24}
|
|
314
|
+
referenceTime={NOW}
|
|
315
|
+
/>
|
|
316
|
+
<FieldDescription>The end is before the start, so the picker is invalid.</FieldDescription>
|
|
317
|
+
</Field>
|
|
318
|
+
<Field>
|
|
319
|
+
<FieldLabel>Required</FieldLabel>
|
|
320
|
+
<TimeRangePicker hourCycle={24} referenceTime={NOW} required />
|
|
321
|
+
</Field>
|
|
322
|
+
<Field>
|
|
323
|
+
<FieldLabel>Clearable</FieldLabel>
|
|
324
|
+
<TimeRangePicker clearable defaultValue={BOOKING} hourCycle={24} referenceTime={NOW} />
|
|
325
|
+
</Field>
|
|
326
|
+
</Stack>
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### In a form
|
|
332
|
+
|
|
333
|
+
startName and endName post the two times, a form reset returns the picker to its first run, and a Field names the frame, not the panel.
|
|
334
|
+
|
|
335
|
+
Excerpt — not a complete module
|
|
336
|
+
|
|
337
|
+
```tsx
|
|
338
|
+
<Field>
|
|
339
|
+
<FieldLabel>Booking</FieldLabel>
|
|
340
|
+
<TimeRangePicker endName="to" startName="from" />
|
|
341
|
+
</Field>;
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### One column
|
|
345
|
+
|
|
346
|
+
Below 760 px the two ends are buttons and the panel shows the clock of one end. On a coarse pointer below 480 px the panel is a sheet.
|
|
347
|
+
|
|
348
|
+
Excerpt — not a complete module
|
|
349
|
+
|
|
350
|
+
```tsx
|
|
351
|
+
<TimeRangePicker {...BASE} defaultValue={BOOKING} presets={PRESETS} />;
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Composition and escape hatches
|
|
355
|
+
|
|
356
|
+
The consumer can own the value, the open state and the end being edited. A provider sets the shape once.
|
|
357
|
+
|
|
358
|
+
Excerpt — not a complete module
|
|
359
|
+
|
|
360
|
+
```tsx
|
|
361
|
+
<TimeRangePicker footer="The room closes at 6" onValueChange={setRun} value={run} />;
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### The keyboard
|
|
365
|
+
|
|
366
|
+
The trigger, the grids of the clocks and the handles of the day each have their own keys.
|
|
367
|
+
|
|
368
|
+
Excerpt — not a complete module
|
|
369
|
+
|
|
370
|
+
```tsx
|
|
371
|
+
// Enter, Space, ArrowDown opens on the clock of the current end
|
|
372
|
+
// Arrows, Home, End move in a grid of a clock
|
|
373
|
+
// Enter / Space chooses the hour or the minute
|
|
374
|
+
// Arrows on a handle move the end one step
|
|
375
|
+
// PageUp / PageDown on a handle, move it one hour
|
|
376
|
+
// Ctrl + Enter applies
|
|
377
|
+
// Escape discards and closes
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### appearance.tsx
|
|
381
|
+
|
|
382
|
+
Example
|
|
383
|
+
|
|
384
|
+
```tsx
|
|
385
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
386
|
+
import { Stack } from '@slotted/react/stack';
|
|
387
|
+
import { TimeRangePicker } from '@slotted/react/time-range-picker';
|
|
388
|
+
import { plainTime } from '@slotted/core/date';
|
|
389
|
+
|
|
390
|
+
const NOW = plainTime(8, 20);
|
|
391
|
+
const BOOKING = { start: plainTime(9), end: plainTime(11, 45) };
|
|
392
|
+
|
|
393
|
+
export default function TimeRangePickerAppearance() {
|
|
394
|
+
return (
|
|
395
|
+
<Stack gap={5}>
|
|
396
|
+
<Field>
|
|
397
|
+
<FieldLabel>Small, outline</FieldLabel>
|
|
398
|
+
<TimeRangePicker
|
|
399
|
+
defaultValue={BOOKING}
|
|
400
|
+
hourCycle={24}
|
|
401
|
+
referenceTime={NOW}
|
|
402
|
+
size="sm"
|
|
403
|
+
variant="outline"
|
|
404
|
+
/>
|
|
405
|
+
</Field>
|
|
406
|
+
<Field>
|
|
407
|
+
<FieldLabel>Medium, subtle</FieldLabel>
|
|
408
|
+
<TimeRangePicker
|
|
409
|
+
defaultValue={BOOKING}
|
|
410
|
+
hourCycle={24}
|
|
411
|
+
referenceTime={NOW}
|
|
412
|
+
size="md"
|
|
413
|
+
variant="subtle"
|
|
414
|
+
/>
|
|
415
|
+
</Field>
|
|
416
|
+
<Field>
|
|
417
|
+
<FieldLabel>Large, plain</FieldLabel>
|
|
418
|
+
<TimeRangePicker
|
|
419
|
+
defaultValue={BOOKING}
|
|
420
|
+
hourCycle={24}
|
|
421
|
+
referenceTime={NOW}
|
|
422
|
+
size="lg"
|
|
423
|
+
variant="plain"
|
|
424
|
+
/>
|
|
425
|
+
</Field>
|
|
426
|
+
</Stack>
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### controlled.tsx
|
|
432
|
+
|
|
433
|
+
Example
|
|
434
|
+
|
|
435
|
+
```tsx
|
|
436
|
+
import { useState } from 'react';
|
|
437
|
+
import { Button } from '@slotted/react/button';
|
|
438
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
439
|
+
import { Inline } from '@slotted/react/inline';
|
|
440
|
+
import { Stack } from '@slotted/react/stack';
|
|
441
|
+
import { TimeRangePicker } from '@slotted/react/time-range-picker';
|
|
442
|
+
import type { TimeRange, TimeRangePickerPosition } from '@slotted/react/time-range-picker';
|
|
443
|
+
import { plainTime, toISOTime } from '@slotted/core/date';
|
|
444
|
+
|
|
445
|
+
const NOW = plainTime(8, 20);
|
|
446
|
+
|
|
447
|
+
export default function TimeRangePickerControlled() {
|
|
448
|
+
const [run, setRun] = useState<TimeRange | null>({ start: plainTime(9), end: plainTime(11, 45) });
|
|
449
|
+
const [open, setOpen] = useState(false);
|
|
450
|
+
const [position, setPosition] = useState<TimeRangePickerPosition>('start');
|
|
451
|
+
|
|
452
|
+
return (
|
|
453
|
+
<Stack gap={4}>
|
|
454
|
+
<Field>
|
|
455
|
+
<FieldLabel>Dock appointment</FieldLabel>
|
|
456
|
+
<TimeRangePicker
|
|
457
|
+
clearable
|
|
458
|
+
hourCycle={24}
|
|
459
|
+
onOpenChange={(next) => setOpen(next)}
|
|
460
|
+
onPositionChange={(next) => setPosition(next)}
|
|
461
|
+
onValueChange={(next) => setRun(next)}
|
|
462
|
+
open={open}
|
|
463
|
+
position={position}
|
|
464
|
+
referenceTime={NOW}
|
|
465
|
+
value={run}
|
|
466
|
+
/>
|
|
467
|
+
<FieldDescription>
|
|
468
|
+
{describe(run)} Editing the {position}.
|
|
469
|
+
</FieldDescription>
|
|
470
|
+
</Field>
|
|
471
|
+
<Inline gap={2}>
|
|
472
|
+
<Button
|
|
473
|
+
size="sm"
|
|
474
|
+
tone="secondary"
|
|
475
|
+
variant="outline"
|
|
476
|
+
onClick={() => setRun({ start: plainTime(8), end: plainTime(12) })}
|
|
477
|
+
>
|
|
478
|
+
Morning
|
|
479
|
+
</Button>
|
|
480
|
+
<Button size="sm" tone="secondary" variant="outline" onClick={() => setRun(null)}>
|
|
481
|
+
Clear
|
|
482
|
+
</Button>
|
|
483
|
+
<Button
|
|
484
|
+
size="sm"
|
|
485
|
+
tone="secondary"
|
|
486
|
+
variant="ghost"
|
|
487
|
+
onClick={() => {
|
|
488
|
+
setPosition('end');
|
|
489
|
+
setOpen(true);
|
|
490
|
+
}}
|
|
491
|
+
>
|
|
492
|
+
Adjust the end
|
|
493
|
+
</Button>
|
|
494
|
+
</Inline>
|
|
495
|
+
</Stack>
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function describe(range: TimeRange | null): string {
|
|
500
|
+
if (range === null) return 'No appointment.';
|
|
501
|
+
|
|
502
|
+
const [start, end] = [range.start, range.end].map((time) =>
|
|
503
|
+
time === null ? 'open' : toISOTime(time, 'minute'),
|
|
504
|
+
);
|
|
505
|
+
|
|
506
|
+
return `Booked ${start} to ${end}.`;
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
### form.tsx
|
|
511
|
+
|
|
512
|
+
Example
|
|
513
|
+
|
|
514
|
+
```tsx
|
|
515
|
+
import { useState } from 'react';
|
|
516
|
+
import type { SubmitEvent } from 'react';
|
|
517
|
+
import { Button } from '@slotted/react/button';
|
|
518
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
519
|
+
import { Inline } from '@slotted/react/inline';
|
|
520
|
+
import { Stack } from '@slotted/react/stack';
|
|
521
|
+
import { TimeRangePicker } from '@slotted/react/time-range-picker';
|
|
522
|
+
import { Text } from '@slotted/react/typography';
|
|
523
|
+
import { plainTime } from '@slotted/core/date';
|
|
524
|
+
|
|
525
|
+
export default function TimeRangePickerForm() {
|
|
526
|
+
const [saved, setSaved] = useState<string | null>(null);
|
|
527
|
+
|
|
528
|
+
const submit = (event: SubmitEvent<HTMLFormElement>) => {
|
|
529
|
+
event.preventDefault();
|
|
530
|
+
const data = new FormData(event.currentTarget);
|
|
531
|
+
const [from, to] = [data.get('from'), data.get('to')];
|
|
532
|
+
setSaved(
|
|
533
|
+
typeof from === 'string' && typeof to === 'string' && from !== '' && to !== ''
|
|
534
|
+
? `Posted ${from} and ${to}.`
|
|
535
|
+
: 'Choose a window.',
|
|
536
|
+
);
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
return (
|
|
540
|
+
<form onReset={() => setSaved(null)} onSubmit={submit}>
|
|
541
|
+
<Stack gap={5}>
|
|
542
|
+
<Field required>
|
|
543
|
+
<FieldLabel>Delivery window</FieldLabel>
|
|
544
|
+
<TimeRangePicker
|
|
545
|
+
defaultValue={{ start: plainTime(9), end: plainTime(11, 45) }}
|
|
546
|
+
endName="to"
|
|
547
|
+
hourCycle={24}
|
|
548
|
+
referenceTime={plainTime(8, 20)}
|
|
549
|
+
startName="from"
|
|
550
|
+
/>
|
|
551
|
+
</Field>
|
|
552
|
+
<Inline gap={3} align="center">
|
|
553
|
+
<Button type="submit">Book window</Button>
|
|
554
|
+
<Button type="reset" tone="secondary" variant="outline">
|
|
555
|
+
Reset
|
|
556
|
+
</Button>
|
|
557
|
+
{saved && (
|
|
558
|
+
<Text size="sm" tone="muted">
|
|
559
|
+
{saved}
|
|
560
|
+
</Text>
|
|
561
|
+
)}
|
|
562
|
+
</Inline>
|
|
563
|
+
</Stack>
|
|
564
|
+
</form>
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
### format.tsx
|
|
570
|
+
|
|
571
|
+
Example
|
|
572
|
+
|
|
573
|
+
```tsx
|
|
574
|
+
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';
|
|
575
|
+
import { Stack } from '@slotted/react/stack';
|
|
576
|
+
import { TimeRangePicker } from '@slotted/react/time-range-picker';
|
|
577
|
+
import { plainTime } from '@slotted/core/date';
|
|
578
|
+
|
|
579
|
+
const NOW = plainTime(8, 20);
|
|
580
|
+
const BOOKING = { start: plainTime(9), end: plainTime(11, 45) };
|
|
581
|
+
const inSlots = (seconds: number) => `${String(Math.round(seconds / 900))} slots`;
|
|
582
|
+
|
|
583
|
+
export default function TimeRangePickerFormat() {
|
|
584
|
+
return (
|
|
585
|
+
<Stack gap={5}>
|
|
586
|
+
<Field>
|
|
587
|
+
<FieldLabel>12-hour clock</FieldLabel>
|
|
588
|
+
<TimeRangePicker defaultValue={BOOKING} hourCycle={12} locale="en-US" referenceTime={NOW} />
|
|
589
|
+
</Field>
|
|
590
|
+
<Field>
|
|
591
|
+
<FieldLabel>Hours only</FieldLabel>
|
|
592
|
+
<TimeRangePicker
|
|
593
|
+
defaultValue={{ start: plainTime(9), end: plainTime(12) }}
|
|
594
|
+
granularity="hour"
|
|
595
|
+
hourCycle={24}
|
|
596
|
+
referenceTime={NOW}
|
|
597
|
+
step={3600}
|
|
598
|
+
/>
|
|
599
|
+
</Field>
|
|
600
|
+
<Field>
|
|
601
|
+
<FieldLabel>With seconds</FieldLabel>
|
|
602
|
+
<TimeRangePicker
|
|
603
|
+
defaultValue={{ start: plainTime(9, 0, 30), end: plainTime(9, 45, 15) }}
|
|
604
|
+
granularity="second"
|
|
605
|
+
hourCycle={24}
|
|
606
|
+
referenceTime={NOW}
|
|
607
|
+
step={60}
|
|
608
|
+
/>
|
|
609
|
+
</Field>
|
|
610
|
+
<Field>
|
|
611
|
+
<FieldLabel>Length in slots</FieldLabel>
|
|
612
|
+
<TimeRangePicker
|
|
613
|
+
defaultValue={BOOKING}
|
|
614
|
+
hourCycle={24}
|
|
615
|
+
lengthLabel={inSlots}
|
|
616
|
+
referenceTime={NOW}
|
|
617
|
+
/>
|
|
618
|
+
<FieldDescription>
|
|
619
|
+
The panel and the trigger name write the run from 09:00 to 11:45 as 11 slots.
|
|
620
|
+
</FieldDescription>
|
|
621
|
+
</Field>
|
|
622
|
+
</Stack>
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
### placement.tsx
|
|
628
|
+
|
|
629
|
+
Example
|
|
630
|
+
|
|
631
|
+
```tsx
|
|
632
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
633
|
+
import { Grid } from '@slotted/react/grid';
|
|
634
|
+
import { TimeRangePicker } from '@slotted/react/time-range-picker';
|
|
635
|
+
import { plainTime } from '@slotted/core/date';
|
|
636
|
+
|
|
637
|
+
const NOW = plainTime(8, 20);
|
|
638
|
+
const BOOKING = { start: plainTime(9), end: plainTime(11, 45) };
|
|
639
|
+
const PLACEMENTS = ['bottom-start', 'bottom', 'bottom-end', 'top-start', 'top', 'top-end'] as const;
|
|
640
|
+
|
|
641
|
+
export default function TimeRangePickerPlacement() {
|
|
642
|
+
return (
|
|
643
|
+
<Grid columns={2} gap={4} minItemWidth="xs">
|
|
644
|
+
{PLACEMENTS.map((placement) => (
|
|
645
|
+
<Field key={placement}>
|
|
646
|
+
<FieldLabel>{placement}</FieldLabel>
|
|
647
|
+
<TimeRangePicker
|
|
648
|
+
defaultValue={BOOKING}
|
|
649
|
+
hourCycle={24}
|
|
650
|
+
placement={placement}
|
|
651
|
+
referenceTime={NOW}
|
|
652
|
+
/>
|
|
653
|
+
</Field>
|
|
654
|
+
))}
|
|
655
|
+
</Grid>
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
### shortcuts.tsx
|
|
661
|
+
|
|
662
|
+
Example
|
|
663
|
+
|
|
664
|
+
```tsx
|
|
665
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
666
|
+
import { Stack } from '@slotted/react/stack';
|
|
667
|
+
import { TimeRangePicker } from '@slotted/react/time-range-picker';
|
|
668
|
+
import { plainTime } from '@slotted/core/date';
|
|
669
|
+
|
|
670
|
+
const NOW = plainTime(8, 20);
|
|
671
|
+
const BOOKING = { start: plainTime(9), end: plainTime(11, 45) };
|
|
672
|
+
const PRESETS = [
|
|
673
|
+
{ label: 'Morning', value: { start: plainTime(8), end: plainTime(12) } },
|
|
674
|
+
{ label: 'Afternoon', value: { start: plainTime(13), end: plainTime(18) } },
|
|
675
|
+
{ label: 'Full day', value: { start: plainTime(8), end: plainTime(18) } },
|
|
676
|
+
];
|
|
677
|
+
|
|
678
|
+
export default function TimeRangePickerShortcuts() {
|
|
679
|
+
return (
|
|
680
|
+
<Stack gap={5}>
|
|
681
|
+
<Field>
|
|
682
|
+
<FieldLabel>Dock appointment</FieldLabel>
|
|
683
|
+
<TimeRangePicker
|
|
684
|
+
defaultValue={BOOKING}
|
|
685
|
+
hourCycle={24}
|
|
686
|
+
presets={PRESETS}
|
|
687
|
+
referenceTime={NOW}
|
|
688
|
+
/>
|
|
689
|
+
</Field>
|
|
690
|
+
<Field>
|
|
691
|
+
<FieldLabel>Cycle count slot</FieldLabel>
|
|
692
|
+
<TimeRangePicker
|
|
693
|
+
defaultValue={BOOKING}
|
|
694
|
+
durations={[1800, 3600, 14400]}
|
|
695
|
+
hourCycle={24}
|
|
696
|
+
referenceTime={NOW}
|
|
697
|
+
/>
|
|
698
|
+
</Field>
|
|
699
|
+
</Stack>
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
### times.tsx
|
|
705
|
+
|
|
706
|
+
Example
|
|
707
|
+
|
|
708
|
+
```tsx
|
|
709
|
+
import { Field, FieldLabel } from '@slotted/react/field';
|
|
710
|
+
import { Stack } from '@slotted/react/stack';
|
|
711
|
+
import { TimeRangePicker } from '@slotted/react/time-range-picker';
|
|
712
|
+
import { plainTime } from '@slotted/core/date';
|
|
713
|
+
|
|
714
|
+
const NOW = plainTime(8, 20);
|
|
715
|
+
const SHIFT_CHANGES = [6, 9, 12, 14, 18, 22].map((hour) => plainTime(hour));
|
|
716
|
+
|
|
717
|
+
export default function TimeRangePickerTimes() {
|
|
718
|
+
return (
|
|
719
|
+
<Stack gap={5}>
|
|
720
|
+
<Field>
|
|
721
|
+
<FieldLabel>Five-minute slots</FieldLabel>
|
|
722
|
+
<TimeRangePicker
|
|
723
|
+
defaultValue={{ start: plainTime(9), end: plainTime(9, 45) }}
|
|
724
|
+
hourCycle={24}
|
|
725
|
+
referenceTime={NOW}
|
|
726
|
+
step={300}
|
|
727
|
+
/>
|
|
728
|
+
</Field>
|
|
729
|
+
<Field>
|
|
730
|
+
<FieldLabel>Hourly slots</FieldLabel>
|
|
731
|
+
<TimeRangePicker
|
|
732
|
+
defaultValue={{ start: plainTime(9), end: plainTime(12) }}
|
|
733
|
+
hourCycle={24}
|
|
734
|
+
referenceTime={NOW}
|
|
735
|
+
step={3600}
|
|
736
|
+
/>
|
|
737
|
+
</Field>
|
|
738
|
+
<Field>
|
|
739
|
+
<FieldLabel>Shift change</FieldLabel>
|
|
740
|
+
<TimeRangePicker
|
|
741
|
+
defaultValue={{ start: plainTime(6), end: plainTime(14) }}
|
|
742
|
+
hourCycle={24}
|
|
743
|
+
options={SHIFT_CHANGES}
|
|
744
|
+
referenceTime={NOW}
|
|
745
|
+
/>
|
|
746
|
+
</Field>
|
|
747
|
+
</Stack>
|
|
748
|
+
);
|
|
749
|
+
}
|
|
750
|
+
```
|