@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
|
@@ -5,9 +5,26 @@
|
|
|
5
5
|
|
|
6
6
|
## Examples
|
|
7
7
|
|
|
8
|
+
### The studio’s calendar
|
|
9
|
+
|
|
10
|
+
Every model uncontrolled: switch views, page, filter the calendars, press an event to open its detail and drag across empty hours to choose a stretch. The line under it says what the calendar asked for.
|
|
11
|
+
|
|
12
|
+
Excerpt — not a complete module
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
<EventCalendar
|
|
16
|
+
calendars={calendars}
|
|
17
|
+
events={events}
|
|
18
|
+
onRangeChange={fetchRange}
|
|
19
|
+
renderEventDetail={(occurrence) => <EventSummary occurrence={occurrence} />}
|
|
20
|
+
selectionMode="range"
|
|
21
|
+
timeZone="America/Sao_Paulo"
|
|
22
|
+
/>;
|
|
23
|
+
```
|
|
24
|
+
|
|
8
25
|
### Which views, in what order
|
|
9
26
|
|
|
10
|
-
views sets the switcher and its order; the first is the one an uncontrolled calendar opens on. A booking page that only lists and a planner without a list are the same
|
|
27
|
+
views sets the switcher and its order; the first is the one an uncontrolled calendar opens on. A booking page that only lists and a planner without a list are the same component.
|
|
11
28
|
|
|
12
29
|
Excerpt — not a complete module
|
|
13
30
|
|
|
@@ -19,20 +36,192 @@ Excerpt — not a complete module
|
|
|
19
36
|
|
|
20
37
|
All-day and multi-day events are bars; a meeting of one day is a dot, a time and a title. A bar running into next week stops in its cell with a chevron; the week number, the outside days and the continuous run of chosen days all show here.
|
|
21
38
|
|
|
22
|
-
|
|
39
|
+
Example
|
|
23
40
|
|
|
24
41
|
```tsx
|
|
25
|
-
|
|
42
|
+
import {
|
|
43
|
+
EventCalendar,
|
|
44
|
+
type CalendarEvent,
|
|
45
|
+
type EventCalendarCalendar,
|
|
46
|
+
} from '@slotted/react/event-calendar';
|
|
47
|
+
import { plainDate, plainDateTime } from '@slotted/core/date';
|
|
48
|
+
|
|
49
|
+
const NOW = plainDateTime(plainDate(2026, 10, 14), { hour: 10, minute: 15, second: 0 });
|
|
50
|
+
const ZONE = 'America/New_York';
|
|
51
|
+
const DATE = plainDate(2026, 10, 14);
|
|
52
|
+
|
|
53
|
+
const at = (month: number, day: number, hour: number, minute = 0) =>
|
|
54
|
+
plainDateTime(plainDate(2026, month, day), { hour, minute, second: 0 });
|
|
55
|
+
|
|
56
|
+
const CALENDARS: EventCalendarCalendar[] = [
|
|
57
|
+
{ key: 'receiving', label: 'Receiving', color: 1 },
|
|
58
|
+
{ key: 'shipping', label: 'Shipping', color: 2 },
|
|
59
|
+
{ key: 'finance', label: 'Finance', color: 3 },
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
const EVENTS: CalendarEvent[] = [
|
|
63
|
+
{
|
|
64
|
+
id: 'ocean-freight',
|
|
65
|
+
title: 'Ocean freight arrival',
|
|
66
|
+
calendar: 'receiving',
|
|
67
|
+
start: plainDate(2026, 10, 6),
|
|
68
|
+
end: plainDate(2026, 10, 8),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'dock-1',
|
|
72
|
+
title: 'Inbound, dock 1',
|
|
73
|
+
calendar: 'receiving',
|
|
74
|
+
start: at(10, 20, 8),
|
|
75
|
+
end: at(10, 20, 9),
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'dock-2',
|
|
79
|
+
title: 'Inbound, dock 2',
|
|
80
|
+
calendar: 'receiving',
|
|
81
|
+
start: at(10, 20, 9),
|
|
82
|
+
end: at(10, 20, 10),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'returns',
|
|
86
|
+
title: 'Returns triage',
|
|
87
|
+
calendar: 'shipping',
|
|
88
|
+
start: at(10, 20, 11),
|
|
89
|
+
end: at(10, 20, 12),
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'payroll',
|
|
93
|
+
title: 'Payroll cut-off',
|
|
94
|
+
calendar: 'finance',
|
|
95
|
+
start: at(10, 20, 15),
|
|
96
|
+
end: at(10, 20, 16),
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 'carrier-pickup',
|
|
100
|
+
title: 'Carrier pickup',
|
|
101
|
+
calendar: 'shipping',
|
|
102
|
+
start: at(10, 14, 15),
|
|
103
|
+
end: at(10, 14, 16),
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
export default function EventCalendarMonthExample() {
|
|
108
|
+
return (
|
|
109
|
+
<EventCalendar
|
|
110
|
+
defaultDate={DATE}
|
|
111
|
+
calendars={CALENDARS}
|
|
112
|
+
events={EVENTS}
|
|
113
|
+
firstDayOfWeek={1}
|
|
114
|
+
fixedWeeks
|
|
115
|
+
maxEvents={2}
|
|
116
|
+
now={NOW}
|
|
117
|
+
timeZone={ZONE}
|
|
118
|
+
weekNumbers
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
26
122
|
```
|
|
27
123
|
|
|
28
124
|
### The week
|
|
29
125
|
|
|
30
126
|
Blocks stand off the rules and off each other. The all-day lane holds bars across days, today’s column carries the now line, and the hours open on scrollTime. Hide the weekend for a working week.
|
|
31
127
|
|
|
32
|
-
|
|
128
|
+
Example
|
|
33
129
|
|
|
34
130
|
```tsx
|
|
35
|
-
|
|
131
|
+
import {
|
|
132
|
+
EventCalendar,
|
|
133
|
+
type CalendarEvent,
|
|
134
|
+
type EventCalendarCalendar,
|
|
135
|
+
type WorkingHours,
|
|
136
|
+
} from '@slotted/react/event-calendar';
|
|
137
|
+
import { plainDate, plainDateTime } from '@slotted/core/date';
|
|
138
|
+
|
|
139
|
+
const NOW = plainDateTime(plainDate(2026, 10, 14), { hour: 10, minute: 15, second: 0 });
|
|
140
|
+
const ZONE = 'America/New_York';
|
|
141
|
+
const DATE = plainDate(2026, 10, 14);
|
|
142
|
+
|
|
143
|
+
const at = (month: number, day: number, hour: number, minute = 0) =>
|
|
144
|
+
plainDateTime(plainDate(2026, month, day), { hour, minute, second: 0 });
|
|
145
|
+
|
|
146
|
+
const CALENDARS: EventCalendarCalendar[] = [
|
|
147
|
+
{ key: 'receiving', label: 'Receiving', color: 1 },
|
|
148
|
+
{ key: 'shipping', label: 'Shipping', color: 2 },
|
|
149
|
+
{ key: 'finance', label: 'Finance', color: 3 },
|
|
150
|
+
];
|
|
151
|
+
|
|
152
|
+
const WORKING_HOURS: WorkingHours[] = [
|
|
153
|
+
{
|
|
154
|
+
days: [1, 2, 3, 4, 5],
|
|
155
|
+
start: { hour: 8, minute: 0, second: 0 },
|
|
156
|
+
end: { hour: 12, minute: 0, second: 0 },
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
days: [1, 2, 3, 4, 5],
|
|
160
|
+
start: { hour: 14, minute: 0, second: 0 },
|
|
161
|
+
end: { hour: 18, minute: 0, second: 0 },
|
|
162
|
+
},
|
|
163
|
+
];
|
|
164
|
+
|
|
165
|
+
const EVENTS: CalendarEvent[] = [
|
|
166
|
+
{
|
|
167
|
+
id: 'freeze',
|
|
168
|
+
title: 'Peak season freeze',
|
|
169
|
+
calendar: 'finance',
|
|
170
|
+
start: plainDate(2026, 10, 13),
|
|
171
|
+
end: plainDate(2026, 10, 14),
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
id: 'inbound-planning',
|
|
175
|
+
title: 'Inbound planning',
|
|
176
|
+
calendar: 'receiving',
|
|
177
|
+
start: at(10, 12, 8, 30),
|
|
178
|
+
end: at(10, 12, 9, 30),
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
id: 'cycle-count',
|
|
182
|
+
title: 'Cycle count, aisle 12',
|
|
183
|
+
calendar: 'receiving',
|
|
184
|
+
start: at(10, 14, 9),
|
|
185
|
+
end: at(10, 14, 11),
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
id: 'carrier-pickup',
|
|
189
|
+
title: 'Carrier pickup',
|
|
190
|
+
calendar: 'shipping',
|
|
191
|
+
start: at(10, 14, 10),
|
|
192
|
+
end: at(10, 14, 11, 30),
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: 'dock-inspection',
|
|
196
|
+
title: 'Dock 3 inspection',
|
|
197
|
+
calendar: 'receiving',
|
|
198
|
+
start: at(10, 14, 10, 30),
|
|
199
|
+
end: at(10, 14, 12),
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: 'customs-review',
|
|
203
|
+
title: 'Customs hold review',
|
|
204
|
+
calendar: 'finance',
|
|
205
|
+
start: at(10, 15, 14),
|
|
206
|
+
end: at(10, 15, 15),
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
|
|
210
|
+
export default function EventCalendarWeekExample() {
|
|
211
|
+
return (
|
|
212
|
+
<EventCalendar
|
|
213
|
+
defaultDate={DATE}
|
|
214
|
+
calendars={CALENDARS}
|
|
215
|
+
dayHours={[7, 19]}
|
|
216
|
+
defaultView="week"
|
|
217
|
+
events={EVENTS}
|
|
218
|
+
now={NOW}
|
|
219
|
+
timeZone={ZONE}
|
|
220
|
+
weekends="hidden"
|
|
221
|
+
workingHours={WORKING_HOURS}
|
|
222
|
+
/>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
36
225
|
```
|
|
37
226
|
|
|
38
227
|
### The day
|
|
@@ -49,10 +238,93 @@ Excerpt — not a complete module
|
|
|
49
238
|
|
|
50
239
|
A heading per day that holds an event and nothing for the days that hold none. Every event is in the tab order; the time has a column of its own so the titles align down the page.
|
|
51
240
|
|
|
52
|
-
|
|
241
|
+
Example
|
|
53
242
|
|
|
54
243
|
```tsx
|
|
55
|
-
|
|
244
|
+
import {
|
|
245
|
+
EventCalendar,
|
|
246
|
+
type CalendarEvent,
|
|
247
|
+
type EventCalendarCalendar,
|
|
248
|
+
} from '@slotted/react/event-calendar';
|
|
249
|
+
import { plainDate, plainDateTime } from '@slotted/core/date';
|
|
250
|
+
|
|
251
|
+
const NOW = plainDateTime(plainDate(2026, 10, 14), { hour: 10, minute: 15, second: 0 });
|
|
252
|
+
const ZONE = 'America/New_York';
|
|
253
|
+
const DATE = plainDate(2026, 10, 14);
|
|
254
|
+
|
|
255
|
+
const at = (month: number, day: number, hour: number, minute = 0) =>
|
|
256
|
+
plainDateTime(plainDate(2026, month, day), { hour, minute, second: 0 });
|
|
257
|
+
|
|
258
|
+
const CALENDARS: EventCalendarCalendar[] = [
|
|
259
|
+
{ key: 'receiving', label: 'Receiving', color: 1 },
|
|
260
|
+
{ key: 'shipping', label: 'Shipping', color: 2 },
|
|
261
|
+
{ key: 'finance', label: 'Finance', color: 3 },
|
|
262
|
+
];
|
|
263
|
+
|
|
264
|
+
const EVENTS: CalendarEvent[] = [
|
|
265
|
+
{
|
|
266
|
+
id: 'ocean-freight',
|
|
267
|
+
title: 'Ocean freight arrival',
|
|
268
|
+
calendar: 'receiving',
|
|
269
|
+
location: 'Port of Newark',
|
|
270
|
+
start: plainDate(2026, 10, 6),
|
|
271
|
+
end: plainDate(2026, 10, 8),
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
id: 'cycle-count',
|
|
275
|
+
title: 'Cycle count, aisle 12',
|
|
276
|
+
calendar: 'receiving',
|
|
277
|
+
location: 'Warehouse A',
|
|
278
|
+
start: at(10, 14, 9),
|
|
279
|
+
end: at(10, 14, 11),
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
id: 'carrier-pickup',
|
|
283
|
+
title: 'Carrier pickup',
|
|
284
|
+
calendar: 'shipping',
|
|
285
|
+
location: 'Dock 4',
|
|
286
|
+
start: at(10, 14, 15),
|
|
287
|
+
end: at(10, 14, 16),
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
id: 'pallet-recall',
|
|
291
|
+
title: 'Pallet recall call',
|
|
292
|
+
calendar: 'shipping',
|
|
293
|
+
status: 'cancelled',
|
|
294
|
+
start: at(10, 16, 13),
|
|
295
|
+
end: at(10, 16, 14),
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: 'vendor-review',
|
|
299
|
+
title: 'Vendor review',
|
|
300
|
+
calendar: 'finance',
|
|
301
|
+
status: 'tentative',
|
|
302
|
+
location: 'Room 2B',
|
|
303
|
+
start: at(10, 21, 10),
|
|
304
|
+
end: at(10, 21, 11),
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
id: 'month-end-close',
|
|
308
|
+
title: 'Month-end close',
|
|
309
|
+
calendar: 'finance',
|
|
310
|
+
start: plainDate(2026, 10, 30),
|
|
311
|
+
end: plainDate(2026, 10, 30),
|
|
312
|
+
},
|
|
313
|
+
];
|
|
314
|
+
|
|
315
|
+
export default function EventCalendarListExample() {
|
|
316
|
+
return (
|
|
317
|
+
<EventCalendar
|
|
318
|
+
defaultDate={DATE}
|
|
319
|
+
calendars={CALENDARS}
|
|
320
|
+
defaultView="list"
|
|
321
|
+
events={EVENTS}
|
|
322
|
+
listRange="month"
|
|
323
|
+
now={NOW}
|
|
324
|
+
timeZone={ZONE}
|
|
325
|
+
/>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
56
328
|
```
|
|
57
329
|
|
|
58
330
|
### All-day, multi-day and past midnight
|
|
@@ -87,44 +359,113 @@ Excerpt — not a complete module
|
|
|
87
359
|
|
|
88
360
|
The standup repeats every weekday and skips Labor Day; planning repeats every other Monday, and the one on the 21st was moved to Tuesday afternoon. A rule outside the subset degrades to a single occurrence.
|
|
89
361
|
|
|
90
|
-
|
|
362
|
+
Example
|
|
91
363
|
|
|
92
364
|
```tsx
|
|
93
|
-
|
|
365
|
+
import { EventCalendar, type CalendarEvent } from '@slotted/react/event-calendar';
|
|
366
|
+
import { plainDate, plainDateTime } from '@slotted/core/date';
|
|
367
|
+
|
|
368
|
+
const NOW = plainDateTime(plainDate(2026, 10, 14), { hour: 10, minute: 15, second: 0 });
|
|
369
|
+
const ZONE = 'America/New_York';
|
|
370
|
+
const DATE = plainDate(2026, 10, 14);
|
|
371
|
+
|
|
372
|
+
const at = (month: number, day: number, hour: number, minute = 0) =>
|
|
373
|
+
plainDateTime(plainDate(2026, month, day), { hour, minute, second: 0 });
|
|
374
|
+
|
|
375
|
+
const EVENTS: CalendarEvent[] = [
|
|
94
376
|
{
|
|
95
377
|
id: 'standup',
|
|
96
|
-
title: '
|
|
97
|
-
start: at(
|
|
98
|
-
end: at(
|
|
378
|
+
title: 'Dock standup',
|
|
379
|
+
start: at(10, 5, 8, 30),
|
|
380
|
+
end: at(10, 5, 8, 45),
|
|
99
381
|
recurrence: 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR',
|
|
100
|
-
exceptions: [plainDate(2026,
|
|
382
|
+
exceptions: [plainDate(2026, 10, 15)],
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
id: 'planning',
|
|
386
|
+
title: 'Planning review',
|
|
387
|
+
start: at(9, 28, 14),
|
|
388
|
+
end: at(9, 28, 15),
|
|
389
|
+
recurrence: 'FREQ=WEEKLY;INTERVAL=2;BYDAY=MO',
|
|
101
390
|
},
|
|
102
391
|
{
|
|
103
|
-
id: 'moved',
|
|
104
|
-
title: 'Planning (moved)',
|
|
105
|
-
start: at(
|
|
106
|
-
end: at(
|
|
392
|
+
id: 'planning-moved',
|
|
393
|
+
title: 'Planning review (moved)',
|
|
394
|
+
start: at(10, 13, 16),
|
|
395
|
+
end: at(10, 13, 17),
|
|
107
396
|
recurrenceOf: 'planning',
|
|
108
|
-
occurrence: plainDate(2026,
|
|
397
|
+
occurrence: plainDate(2026, 10, 12),
|
|
109
398
|
},
|
|
110
399
|
];
|
|
400
|
+
|
|
401
|
+
export default function EventCalendarRecurrenceExample() {
|
|
402
|
+
return (
|
|
403
|
+
<EventCalendar
|
|
404
|
+
defaultDate={DATE}
|
|
405
|
+
defaultView="week"
|
|
406
|
+
events={EVENTS}
|
|
407
|
+
now={NOW}
|
|
408
|
+
timeZone={ZONE}
|
|
409
|
+
weekends="hidden"
|
|
410
|
+
/>
|
|
411
|
+
);
|
|
412
|
+
}
|
|
111
413
|
```
|
|
112
414
|
|
|
113
415
|
### Time zones and the day the clocks change
|
|
114
416
|
|
|
115
417
|
The calendar draws wall-clock time. The application converts its instants once with wallClockIn; timeZone decides today, the now line and the gutter’s label. On 1 November in New York the header says the clocks go back at 2 AM and the column marks the minute.
|
|
116
418
|
|
|
117
|
-
|
|
419
|
+
Example
|
|
118
420
|
|
|
119
421
|
```tsx
|
|
120
|
-
|
|
422
|
+
import { EventCalendar, type CalendarEvent } from '@slotted/react/event-calendar';
|
|
423
|
+
import { plainDate, plainDateTime, wallClockIn } from '@slotted/core/date';
|
|
424
|
+
|
|
425
|
+
const ZONE = 'America/New_York';
|
|
426
|
+
const NOW = plainDateTime(plainDate(2026, 11, 1), { hour: 9, minute: 0, second: 0 });
|
|
427
|
+
const MIDNIGHT = { hour: 0, minute: 0, second: 0 };
|
|
428
|
+
|
|
429
|
+
const ROWS = [
|
|
430
|
+
{
|
|
431
|
+
id: 'night-count',
|
|
432
|
+
title: 'Overnight count',
|
|
433
|
+
startsAt: Date.UTC(2026, 10, 1, 5, 0),
|
|
434
|
+
endsAt: Date.UTC(2026, 10, 1, 7, 0),
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
id: 'gate-receiving',
|
|
438
|
+
title: 'Gate receiving',
|
|
439
|
+
startsAt: Date.UTC(2026, 10, 1, 13, 0),
|
|
440
|
+
endsAt: Date.UTC(2026, 10, 1, 15, 0),
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
id: 'carrier-pickup',
|
|
444
|
+
title: 'Carrier pickup',
|
|
445
|
+
startsAt: Date.UTC(2026, 10, 1, 17, 30),
|
|
446
|
+
endsAt: Date.UTC(2026, 10, 1, 18, 30),
|
|
447
|
+
},
|
|
448
|
+
];
|
|
449
|
+
|
|
450
|
+
const EVENTS: CalendarEvent[] = ROWS.map((row) => ({
|
|
121
451
|
id: row.id,
|
|
122
452
|
title: row.title,
|
|
123
|
-
start: wallClockIn(row.startsAt,
|
|
124
|
-
end: wallClockIn(row.endsAt,
|
|
453
|
+
start: wallClockIn(row.startsAt, ZONE),
|
|
454
|
+
end: wallClockIn(row.endsAt, ZONE),
|
|
125
455
|
}));
|
|
126
456
|
|
|
127
|
-
|
|
457
|
+
export default function EventCalendarTimeZoneExample() {
|
|
458
|
+
return (
|
|
459
|
+
<EventCalendar
|
|
460
|
+
defaultDate={plainDate(2026, 11, 1)}
|
|
461
|
+
defaultView="day"
|
|
462
|
+
events={EVENTS}
|
|
463
|
+
now={NOW}
|
|
464
|
+
scrollTime={MIDNIGHT}
|
|
465
|
+
timeZone={ZONE}
|
|
466
|
+
/>
|
|
467
|
+
);
|
|
468
|
+
}
|
|
128
469
|
```
|
|
129
470
|
|
|
130
471
|
### Calendars and their colors
|
|
@@ -172,29 +513,149 @@ Excerpt — not a complete module
|
|
|
172
513
|
|
|
173
514
|
renderDayContent writes into every day header: who is on call here, a nightly price on a booking page, free slots in a clinic. It sits at the end of the header line in the month and under the date in the week.
|
|
174
515
|
|
|
175
|
-
|
|
516
|
+
Example
|
|
176
517
|
|
|
177
518
|
```tsx
|
|
178
|
-
|
|
519
|
+
import { EventCalendar, type CalendarEvent } from '@slotted/react/event-calendar';
|
|
520
|
+
import { dayOfWeek, plainDate, plainDateTime, type PlainDate } from '@slotted/core/date';
|
|
521
|
+
|
|
522
|
+
const NOW = plainDateTime(plainDate(2026, 10, 14), { hour: 10, minute: 15, second: 0 });
|
|
523
|
+
const ZONE = 'America/New_York';
|
|
524
|
+
const DATE = plainDate(2026, 10, 14);
|
|
525
|
+
|
|
526
|
+
const at = (month: number, day: number, hour: number, minute = 0) =>
|
|
527
|
+
plainDateTime(plainDate(2026, month, day), { hour, minute, second: 0 });
|
|
528
|
+
|
|
529
|
+
const ON_CALL = ['Dara', 'Priya', 'Marcus', 'Elena', 'Omar', 'Chen', 'Noor'];
|
|
530
|
+
|
|
531
|
+
const EVENTS: CalendarEvent[] = [
|
|
532
|
+
{ id: 'cycle-count', title: 'Cycle count, aisle 12', start: at(10, 14, 9), end: at(10, 14, 11) },
|
|
533
|
+
{ id: 'carrier-pickup', title: 'Carrier pickup', start: at(10, 14, 15), end: at(10, 14, 16) },
|
|
534
|
+
{
|
|
535
|
+
id: 'month-end-close',
|
|
536
|
+
title: 'Month-end close',
|
|
537
|
+
start: plainDate(2026, 10, 30),
|
|
538
|
+
end: plainDate(2026, 10, 30),
|
|
539
|
+
},
|
|
540
|
+
];
|
|
541
|
+
|
|
542
|
+
function onCall(date: PlainDate): string {
|
|
543
|
+
return ON_CALL[dayOfWeek(date)] ?? '';
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
export default function EventCalendarDayContentExample() {
|
|
547
|
+
return (
|
|
548
|
+
<EventCalendar
|
|
549
|
+
defaultDate={DATE}
|
|
550
|
+
events={EVENTS}
|
|
551
|
+
now={NOW}
|
|
552
|
+
renderDayContent={onCall}
|
|
553
|
+
timeZone={ZONE}
|
|
554
|
+
/>
|
|
555
|
+
);
|
|
556
|
+
}
|
|
179
557
|
```
|
|
180
558
|
|
|
181
559
|
### Opening an event
|
|
182
560
|
|
|
183
|
-
With renderEventDetail the
|
|
561
|
+
With renderEventDetail the calendar opens a popover anchored to the event and gives it back focus on close. Without it, onOpenEventChange asks and the application opens its own drawer; the open event keeps aria-expanded either way.
|
|
184
562
|
|
|
185
|
-
|
|
563
|
+
Example
|
|
186
564
|
|
|
187
565
|
```tsx
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
566
|
+
import { useState } from 'react';
|
|
567
|
+
import { Button } from '@slotted/react/button';
|
|
568
|
+
import { EventCalendar, type CalendarEvent } from '@slotted/react/event-calendar';
|
|
569
|
+
import { Inline } from '@slotted/react/inline';
|
|
570
|
+
import { MenuItem, MenuSeparator } from '@slotted/react/menu';
|
|
571
|
+
import { Stack } from '@slotted/react/stack';
|
|
572
|
+
import { Heading, Text } from '@slotted/react/typography';
|
|
573
|
+
import { plainDate, plainDateTime } from '@slotted/core/date';
|
|
574
|
+
|
|
575
|
+
const NOW = plainDateTime(plainDate(2026, 10, 14), { hour: 10, minute: 15, second: 0 });
|
|
576
|
+
const ZONE = 'America/New_York';
|
|
577
|
+
const DATE = plainDate(2026, 10, 14);
|
|
578
|
+
|
|
579
|
+
const at = (day: number, hour: number, minute = 0) =>
|
|
580
|
+
plainDateTime(plainDate(2026, 10, day), { hour, minute, second: 0 });
|
|
581
|
+
|
|
582
|
+
const EVENTS: CalendarEvent[] = [
|
|
583
|
+
{
|
|
584
|
+
id: 'cycle-count',
|
|
585
|
+
title: 'Cycle count, aisle 12',
|
|
586
|
+
location: 'Warehouse A',
|
|
587
|
+
start: at(14, 9),
|
|
588
|
+
end: at(14, 11),
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
id: 'carrier-pickup',
|
|
592
|
+
title: 'Carrier pickup',
|
|
593
|
+
location: 'Dock 4',
|
|
594
|
+
start: at(14, 15),
|
|
595
|
+
end: at(14, 16),
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
id: 'dock-inspection',
|
|
599
|
+
title: 'Dock 3 inspection',
|
|
600
|
+
location: 'Dock 3',
|
|
601
|
+
start: at(15, 10),
|
|
602
|
+
end: at(15, 12),
|
|
603
|
+
},
|
|
604
|
+
];
|
|
605
|
+
|
|
606
|
+
export default function EventCalendarDetailExample() {
|
|
607
|
+
const [note, setNote] = useState(
|
|
608
|
+
'Press an event for its detail, or open the menu with a right click.',
|
|
609
|
+
);
|
|
610
|
+
|
|
611
|
+
return (
|
|
612
|
+
<Stack gap={3}>
|
|
613
|
+
<EventCalendar
|
|
614
|
+
defaultDate={DATE}
|
|
615
|
+
defaultView="week"
|
|
616
|
+
events={EVENTS}
|
|
617
|
+
now={NOW}
|
|
618
|
+
renderContextMenu={(target) =>
|
|
619
|
+
target.kind === 'event' ? (
|
|
620
|
+
<>
|
|
621
|
+
<MenuItem onSelect={() => setNote(`Duplicated ${target.occurrence.event.title}.`)}>
|
|
622
|
+
Duplicate
|
|
623
|
+
</MenuItem>
|
|
624
|
+
<MenuSeparator />
|
|
625
|
+
<MenuItem
|
|
626
|
+
onSelect={() => setNote(`Cancelled ${target.occurrence.event.title}.`)}
|
|
627
|
+
tone="danger"
|
|
628
|
+
>
|
|
629
|
+
Cancel event
|
|
630
|
+
</MenuItem>
|
|
631
|
+
</>
|
|
632
|
+
) : (
|
|
633
|
+
<MenuItem onSelect={() => setNote('New event.')}>New event</MenuItem>
|
|
634
|
+
)
|
|
635
|
+
}
|
|
636
|
+
renderEventDetail={(occurrence, { close }) => (
|
|
637
|
+
<Stack gap={2}>
|
|
638
|
+
<Heading level={3} size="sm">
|
|
639
|
+
{occurrence.event.title}
|
|
640
|
+
</Heading>
|
|
641
|
+
<Text size="sm" tone="muted">
|
|
642
|
+
{occurrence.event.location}
|
|
643
|
+
</Text>
|
|
644
|
+
<Inline gap={2}>
|
|
645
|
+
<Button onClick={close} size="sm" variant="outline">
|
|
646
|
+
Done
|
|
647
|
+
</Button>
|
|
648
|
+
</Inline>
|
|
649
|
+
</Stack>
|
|
650
|
+
)}
|
|
651
|
+
timeZone={ZONE}
|
|
652
|
+
/>
|
|
653
|
+
<Text size="sm" tone="muted">
|
|
654
|
+
{note}
|
|
655
|
+
</Text>
|
|
656
|
+
</Stack>
|
|
657
|
+
);
|
|
658
|
+
}
|
|
198
659
|
```
|
|
199
660
|
|
|
200
661
|
### Commands on a right click
|
|
@@ -244,23 +705,68 @@ Excerpt — not a complete module
|
|
|
244
705
|
|
|
245
706
|
With editable, a press that travels four pixels picks an event up and lays it out where it would land; its end pulls to resize. Release asks with onEventChange; Escape puts it back. Alt with the arrows does the same from the keyboard. A series asks with the occurrence’s own date. canDrop is asked about every destination with the same change: a refused one is drawn with a dashed danger edge, letting go there asks nothing, and Alt with an arrow passes over it to the next allowed one.
|
|
246
707
|
|
|
247
|
-
|
|
708
|
+
Example
|
|
248
709
|
|
|
249
710
|
```tsx
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
711
|
+
import { useState } from 'react';
|
|
712
|
+
import {
|
|
713
|
+
EventCalendar,
|
|
714
|
+
type CalendarEvent,
|
|
715
|
+
type EventCalendarEventChange,
|
|
716
|
+
} from '@slotted/react/event-calendar';
|
|
717
|
+
import { Stack } from '@slotted/react/stack';
|
|
718
|
+
import { Text } from '@slotted/react/typography';
|
|
719
|
+
import { dayOfWeek, isPlainDateTime, plainDate, plainDateTime } from '@slotted/core/date';
|
|
720
|
+
|
|
721
|
+
const NOW = plainDateTime(plainDate(2026, 10, 14), { hour: 10, minute: 15, second: 0 });
|
|
722
|
+
const ZONE = 'America/New_York';
|
|
723
|
+
const DATE = plainDate(2026, 10, 14);
|
|
724
|
+
|
|
725
|
+
const at = (day: number, hour: number, minute = 0) =>
|
|
726
|
+
plainDateTime(plainDate(2026, 10, day), { hour, minute, second: 0 });
|
|
727
|
+
|
|
728
|
+
const EVENTS: CalendarEvent[] = [
|
|
729
|
+
{ id: 'cycle-count', title: 'Cycle count, aisle 12', start: at(14, 9), end: at(14, 11) },
|
|
730
|
+
{ id: 'carrier-pickup', title: 'Carrier pickup', start: at(14, 15), end: at(14, 16) },
|
|
731
|
+
{ id: 'dock-inspection', title: 'Dock 3 inspection', start: at(15, 10), end: at(15, 12) },
|
|
732
|
+
];
|
|
733
|
+
|
|
734
|
+
export default function EventCalendarEditingExample() {
|
|
735
|
+
const [events, setEvents] = useState(EVENTS);
|
|
736
|
+
const [note, setNote] = useState('Drag an event, or press Alt with an arrow on a focused one.');
|
|
737
|
+
|
|
738
|
+
function handleChange(change: EventCalendarEventChange) {
|
|
257
739
|
setEvents((held) =>
|
|
258
740
|
held.map((event) =>
|
|
259
741
|
event.id === change.event.id ? { ...event, start: change.start, end: change.end } : event,
|
|
260
742
|
),
|
|
261
|
-
)
|
|
743
|
+
);
|
|
744
|
+
setNote(`${change.event.title}: ${change.kind === 'move' ? 'moved' : 'resized'}.`);
|
|
262
745
|
}
|
|
263
|
-
|
|
746
|
+
|
|
747
|
+
return (
|
|
748
|
+
<Stack gap={3}>
|
|
749
|
+
<EventCalendar
|
|
750
|
+
defaultDate={DATE}
|
|
751
|
+
canDrop={allowsWeekday}
|
|
752
|
+
defaultView="week"
|
|
753
|
+
editable
|
|
754
|
+
events={events}
|
|
755
|
+
now={NOW}
|
|
756
|
+
onEventChange={handleChange}
|
|
757
|
+
timeZone={ZONE}
|
|
758
|
+
/>
|
|
759
|
+
<Text size="sm" tone="muted">
|
|
760
|
+
{note}
|
|
761
|
+
</Text>
|
|
762
|
+
</Stack>
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
function allowsWeekday(change: EventCalendarEventChange): boolean {
|
|
767
|
+
const date = isPlainDateTime(change.start) ? change.start.date : change.start;
|
|
768
|
+
return dayOfWeek(date) % 6 !== 0;
|
|
769
|
+
}
|
|
264
770
|
```
|
|
265
771
|
|
|
266
772
|
### Loading a new range
|
|
@@ -306,10 +812,65 @@ Excerpt — not a complete module
|
|
|
306
812
|
|
|
307
813
|
Below 600 pixels the month and the week draw as a list of the same days and the view does not change. With compact="keep" the grid stays: events become marks of color, the day is the target, and each keeps its name. At that width the “+N” panel and the detail are sheets from the bottom edge rather than popovers.
|
|
308
814
|
|
|
309
|
-
|
|
815
|
+
Example
|
|
310
816
|
|
|
311
817
|
```tsx
|
|
312
|
-
|
|
818
|
+
import {
|
|
819
|
+
EventCalendar,
|
|
820
|
+
type CalendarEvent,
|
|
821
|
+
type EventCalendarCalendar,
|
|
822
|
+
} from '@slotted/react/event-calendar';
|
|
823
|
+
import { plainDate, plainDateTime } from '@slotted/core/date';
|
|
824
|
+
|
|
825
|
+
const NOW = plainDateTime(plainDate(2026, 10, 14), { hour: 10, minute: 15, second: 0 });
|
|
826
|
+
const ZONE = 'America/New_York';
|
|
827
|
+
const DATE = plainDate(2026, 10, 14);
|
|
828
|
+
|
|
829
|
+
const at = (month: number, day: number, hour: number, minute = 0) =>
|
|
830
|
+
plainDateTime(plainDate(2026, month, day), { hour, minute, second: 0 });
|
|
831
|
+
|
|
832
|
+
const CALENDARS: EventCalendarCalendar[] = [
|
|
833
|
+
{ key: 'receiving', label: 'Receiving', color: 1 },
|
|
834
|
+
{ key: 'shipping', label: 'Shipping', color: 2 },
|
|
835
|
+
{ key: 'finance', label: 'Finance', color: 3 },
|
|
836
|
+
];
|
|
837
|
+
|
|
838
|
+
const EVENTS: CalendarEvent[] = [
|
|
839
|
+
{
|
|
840
|
+
id: 'cycle-count',
|
|
841
|
+
title: 'Cycle count, aisle 12',
|
|
842
|
+
calendar: 'receiving',
|
|
843
|
+
start: at(10, 14, 9),
|
|
844
|
+
end: at(10, 14, 11),
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
id: 'carrier-pickup',
|
|
848
|
+
title: 'Carrier pickup',
|
|
849
|
+
calendar: 'shipping',
|
|
850
|
+
start: at(10, 14, 15),
|
|
851
|
+
end: at(10, 14, 16),
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
id: 'vendor-review',
|
|
855
|
+
title: 'Vendor review',
|
|
856
|
+
calendar: 'finance',
|
|
857
|
+
start: at(10, 21, 10),
|
|
858
|
+
end: at(10, 21, 11),
|
|
859
|
+
},
|
|
860
|
+
];
|
|
861
|
+
|
|
862
|
+
export default function EventCalendarCompactExample() {
|
|
863
|
+
return (
|
|
864
|
+
<EventCalendar
|
|
865
|
+
defaultDate={DATE}
|
|
866
|
+
calendars={CALENDARS}
|
|
867
|
+
compact="keep"
|
|
868
|
+
events={EVENTS}
|
|
869
|
+
now={NOW}
|
|
870
|
+
timeZone={ZONE}
|
|
871
|
+
/>
|
|
872
|
+
);
|
|
873
|
+
}
|
|
313
874
|
```
|
|
314
875
|
|
|
315
876
|
### Drawing the inside of an event
|
|
@@ -372,3 +933,142 @@ const calendar = useRef<EventCalendarHandle>(null);
|
|
|
372
933
|
calendar.current?.focusDate(plainDate(2026, 10, 1));
|
|
373
934
|
calendar.current?.focusEvent('standup@2026-09-24');
|
|
374
935
|
```
|
|
936
|
+
|
|
937
|
+
### controlled.tsx
|
|
938
|
+
|
|
939
|
+
Example
|
|
940
|
+
|
|
941
|
+
```tsx
|
|
942
|
+
import { useState } from 'react';
|
|
943
|
+
import {
|
|
944
|
+
EventCalendar,
|
|
945
|
+
type CalendarEvent,
|
|
946
|
+
type EventCalendarSelection,
|
|
947
|
+
type EventCalendarView,
|
|
948
|
+
} from '@slotted/react/event-calendar';
|
|
949
|
+
import { Stack } from '@slotted/react/stack';
|
|
950
|
+
import { Text } from '@slotted/react/typography';
|
|
951
|
+
import {
|
|
952
|
+
isPlainDateTime,
|
|
953
|
+
plainDate,
|
|
954
|
+
plainDateTime,
|
|
955
|
+
toISODate,
|
|
956
|
+
toISODateTime,
|
|
957
|
+
type PlainDate,
|
|
958
|
+
} from '@slotted/core/date';
|
|
959
|
+
|
|
960
|
+
const NOW = plainDateTime(plainDate(2026, 10, 14), { hour: 10, minute: 15, second: 0 });
|
|
961
|
+
const ZONE = 'America/New_York';
|
|
962
|
+
|
|
963
|
+
const at = (day: number, hour: number, minute = 0) =>
|
|
964
|
+
plainDateTime(plainDate(2026, 10, day), { hour, minute, second: 0 });
|
|
965
|
+
|
|
966
|
+
const EVENTS: CalendarEvent[] = [
|
|
967
|
+
{ id: 'cycle-count', title: 'Cycle count, aisle 12', start: at(14, 9), end: at(14, 11) },
|
|
968
|
+
{ id: 'carrier-pickup', title: 'Carrier pickup', start: at(14, 15), end: at(14, 16) },
|
|
969
|
+
{ id: 'vendor-review', title: 'Vendor review', start: at(21, 10), end: at(21, 11) },
|
|
970
|
+
];
|
|
971
|
+
|
|
972
|
+
export default function EventCalendarControlledExample() {
|
|
973
|
+
const [date, setDate] = useState<PlainDate>(plainDate(2026, 10, 14));
|
|
974
|
+
const [view, setView] = useState<EventCalendarView>('week');
|
|
975
|
+
const [selection, setSelection] = useState<EventCalendarSelection | null>(null);
|
|
976
|
+
|
|
977
|
+
return (
|
|
978
|
+
<Stack gap={3}>
|
|
979
|
+
<EventCalendar
|
|
980
|
+
date={date}
|
|
981
|
+
events={EVENTS}
|
|
982
|
+
now={NOW}
|
|
983
|
+
onDateChange={setDate}
|
|
984
|
+
onSelectionChange={setSelection}
|
|
985
|
+
onViewChange={setView}
|
|
986
|
+
selection={selection}
|
|
987
|
+
selectionMode="range"
|
|
988
|
+
timeZone={ZONE}
|
|
989
|
+
view={view}
|
|
990
|
+
/>
|
|
991
|
+
<Text size="sm" tone="muted">
|
|
992
|
+
{`Date ${toISODate(date)}, ${view} view.`}
|
|
993
|
+
</Text>
|
|
994
|
+
<Text size="sm" tone="muted">
|
|
995
|
+
{describe(selection)}
|
|
996
|
+
</Text>
|
|
997
|
+
</Stack>
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
function describe(selection: EventCalendarSelection | null): string {
|
|
1002
|
+
if (selection === null) return 'Nothing selected.';
|
|
1003
|
+
const { start, end } = selection;
|
|
1004
|
+
if (isPlainDateTime(start) && isPlainDateTime(end)) {
|
|
1005
|
+
return `Selected ${toISODateTime(start)} to ${toISODateTime(end)}.`;
|
|
1006
|
+
}
|
|
1007
|
+
if (!isPlainDateTime(start) && !isPlainDateTime(end)) {
|
|
1008
|
+
return `Selected ${toISODate(start)} to ${toISODate(end)}.`;
|
|
1009
|
+
}
|
|
1010
|
+
return 'Nothing selected.';
|
|
1011
|
+
}
|
|
1012
|
+
```
|
|
1013
|
+
|
|
1014
|
+
### states.tsx
|
|
1015
|
+
|
|
1016
|
+
Example
|
|
1017
|
+
|
|
1018
|
+
```tsx
|
|
1019
|
+
import { useState } from 'react';
|
|
1020
|
+
import { Alert, AlertActions, AlertContent, AlertDescription } from '@slotted/react/alert';
|
|
1021
|
+
import { Button } from '@slotted/react/button';
|
|
1022
|
+
import { EventCalendar } from '@slotted/react/event-calendar';
|
|
1023
|
+
import { Inline } from '@slotted/react/inline';
|
|
1024
|
+
import { Stack } from '@slotted/react/stack';
|
|
1025
|
+
import { Switch } from '@slotted/react/switch';
|
|
1026
|
+
import { plainDate, plainDateTime } from '@slotted/core/date';
|
|
1027
|
+
|
|
1028
|
+
const NOW = plainDateTime(plainDate(2026, 10, 14), { hour: 10, minute: 15, second: 0 });
|
|
1029
|
+
const ZONE = 'America/New_York';
|
|
1030
|
+
const DATE = plainDate(2026, 10, 14);
|
|
1031
|
+
|
|
1032
|
+
export default function EventCalendarStatesExample() {
|
|
1033
|
+
const [loading, setLoading] = useState(false);
|
|
1034
|
+
const [failed, setFailed] = useState(false);
|
|
1035
|
+
|
|
1036
|
+
return (
|
|
1037
|
+
<Stack gap={3}>
|
|
1038
|
+
<Inline gap={4}>
|
|
1039
|
+
<Switch checked={loading} onCheckedChange={setLoading}>
|
|
1040
|
+
Loading
|
|
1041
|
+
</Switch>
|
|
1042
|
+
<Switch checked={failed} onCheckedChange={setFailed}>
|
|
1043
|
+
Failed
|
|
1044
|
+
</Switch>
|
|
1045
|
+
</Inline>
|
|
1046
|
+
<EventCalendar
|
|
1047
|
+
defaultDate={DATE}
|
|
1048
|
+
defaultView="list"
|
|
1049
|
+
empty={<Button size="sm">New event</Button>}
|
|
1050
|
+
error={
|
|
1051
|
+
failed ? (
|
|
1052
|
+
<Alert tone="danger">
|
|
1053
|
+
<AlertContent>
|
|
1054
|
+
<AlertDescription>The events for this week could not be loaded.</AlertDescription>
|
|
1055
|
+
</AlertContent>
|
|
1056
|
+
<AlertActions>
|
|
1057
|
+
<Button onClick={() => setFailed(false)} size="sm">
|
|
1058
|
+
Retry
|
|
1059
|
+
</Button>
|
|
1060
|
+
</AlertActions>
|
|
1061
|
+
</Alert>
|
|
1062
|
+
) : null
|
|
1063
|
+
}
|
|
1064
|
+
events={[]}
|
|
1065
|
+
loading={loading}
|
|
1066
|
+
loadingDelay={0}
|
|
1067
|
+
loadingMinDuration={0}
|
|
1068
|
+
now={NOW}
|
|
1069
|
+
timeZone={ZONE}
|
|
1070
|
+
/>
|
|
1071
|
+
</Stack>
|
|
1072
|
+
);
|
|
1073
|
+
}
|
|
1074
|
+
```
|