@kerf-js/veneer 0.0.0-stage → 0.1.0
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/LICENSE +16 -0
- package/README.md +1338 -2
- package/package.json +56 -3
- package/plugin.d.mts +187 -0
- package/plugin.mjs +399 -0
- package/src/Accordion.tsx +98 -0
- package/src/Alert.tsx +55 -0
- package/src/Badge.tsx +39 -0
- package/src/Button.tsx +175 -0
- package/src/Calendar-month.tsx +140 -0
- package/src/Calendar.tsx +335 -0
- package/src/Canvas.tsx +221 -0
- package/src/Card.tsx +85 -0
- package/src/Chart.tsx +278 -0
- package/src/Charts.tsx +158 -0
- package/src/Chip.tsx +61 -0
- package/src/Choice-checkbox.tsx +53 -0
- package/src/Choice-parts.tsx +7 -0
- package/src/Choice-radio.tsx +78 -0
- package/src/Choice-segmented.tsx +76 -0
- package/src/Choice-switch.tsx +51 -0
- package/src/Choice.tsx +4 -0
- package/src/CloseX.tsx +14 -0
- package/src/CodeBlock.tsx +81 -0
- package/src/CodeInput.tsx +256 -0
- package/src/Combobox.tsx +281 -0
- package/src/CommandPalette-controller.ts +314 -0
- package/src/CommandPalette-rows.tsx +137 -0
- package/src/CommandPalette.tsx +196 -0
- package/src/DataGrid-actions.ts +119 -0
- package/src/DataGrid-body.tsx +58 -0
- package/src/DataGrid-controller.ts +145 -0
- package/src/DataGrid-header.tsx +108 -0
- package/src/DataGrid-model.ts +248 -0
- package/src/DataGrid-pivot.tsx +108 -0
- package/src/DataGrid-rows.tsx +296 -0
- package/src/DataGrid-toolbar.tsx +127 -0
- package/src/DataGrid-tree.ts +149 -0
- package/src/DataGrid-viewport.tsx +37 -0
- package/src/DataGrid.tsx +145 -0
- package/src/DateField-presets.tsx +27 -0
- package/src/DateField-range.tsx +370 -0
- package/src/DateField.tsx +295 -0
- package/src/Dither.tsx +313 -0
- package/src/Drawer.tsx +123 -0
- package/src/DurationField.tsx +227 -0
- package/src/Feed.tsx +78 -0
- package/src/Field/view.tsx +147 -0
- package/src/Field.tsx +238 -0
- package/src/HamburgerMenu.tsx +119 -0
- package/src/Icon.tsx +15 -0
- package/src/Kbd.tsx +6 -0
- package/src/KeyValueEditor/actions.ts +75 -0
- package/src/KeyValueEditor/rows.tsx +104 -0
- package/src/KeyValueEditor.tsx +112 -0
- package/src/Layout.tsx +221 -0
- package/src/Markdown.tsx +127 -0
- package/src/MentionsInput/actions.ts +161 -0
- package/src/MentionsInput/end.tsx +82 -0
- package/src/MentionsInput.tsx +103 -0
- package/src/Menu.tsx +221 -0
- package/src/Modal.tsx +109 -0
- package/src/MonthPicker/month.tsx +117 -0
- package/src/MonthPicker/period.tsx +197 -0
- package/src/MonthPicker/shared.tsx +272 -0
- package/src/MonthPicker/week.tsx +103 -0
- package/src/MonthPicker.tsx +11 -0
- package/src/MultiSelect.tsx +139 -0
- package/src/Nav.tsx +36 -0
- package/src/NumberField.tsx +156 -0
- package/src/Pagination.tsx +335 -0
- package/src/PaymentCard.tsx +111 -0
- package/src/Picker.tsx +228 -0
- package/src/PlaceField.tsx +285 -0
- package/src/Popover.tsx +88 -0
- package/src/Presence.tsx +37 -0
- package/src/Progress.tsx +71 -0
- package/src/RecurrenceField.tsx +372 -0
- package/src/RichSelect/codes.tsx +94 -0
- package/src/RichSelect/list.tsx +380 -0
- package/src/RichSelect/phone-view.tsx +114 -0
- package/src/RichSelect/phone.tsx +305 -0
- package/src/RichSelect/search-keys.ts +28 -0
- package/src/RichSelect/timezone.tsx +53 -0
- package/src/RichSelect.tsx +13 -0
- package/src/RichTextEditor/controller.tsx +305 -0
- package/src/RichTextEditor/editor.tsx +61 -0
- package/src/RichTextEditor/tools.tsx +132 -0
- package/src/RichTextEditor/view.tsx +210 -0
- package/src/RichTextEditor.tsx +9 -0
- package/src/ScrollGrid/measure.ts +39 -0
- package/src/ScrollGrid/parts.tsx +112 -0
- package/src/ScrollGrid.tsx +375 -0
- package/src/ScrollRail.tsx +114 -0
- package/src/ScrollView.tsx +57 -0
- package/src/Segments/controller.tsx +148 -0
- package/src/Segments/events.ts +99 -0
- package/src/Segments/view.tsx +77 -0
- package/src/Segments.tsx +2 -0
- package/src/Select.tsx +343 -0
- package/src/Shape.tsx +41 -0
- package/src/Shell/branches.tsx +108 -0
- package/src/Shell/button.tsx +33 -0
- package/src/Shell/shared.tsx +220 -0
- package/src/Shell/shell.tsx +25 -0
- package/src/Shell/state.ts +138 -0
- package/src/Shell/view.tsx +280 -0
- package/src/Shell.tsx +17 -0
- package/src/SideNav/sections.tsx +50 -0
- package/src/SideNav/state.ts +140 -0
- package/src/SideNav.tsx +130 -0
- package/src/SideNavTitle.tsx +25 -0
- package/src/SignaturePad/state.ts +172 -0
- package/src/SignaturePad/view.tsx +69 -0
- package/src/SignaturePad.tsx +76 -0
- package/src/Skeleton.tsx +46 -0
- package/src/Slider.tsx +81 -0
- package/src/Spinner.tsx +21 -0
- package/src/Stage-director.ts +361 -0
- package/src/Stage-look.ts +75 -0
- package/src/Stage-poster.tsx +62 -0
- package/src/Stage-types.ts +206 -0
- package/src/Stage.tsx +147 -0
- package/src/TabBar.tsx +114 -0
- package/src/Table-actions.tsx +51 -0
- package/src/Table-base.ts +70 -0
- package/src/Table-body.tsx +84 -0
- package/src/Table-columns.tsx +58 -0
- package/src/Table-details.tsx +66 -0
- package/src/Table-editor.tsx +66 -0
- package/src/Table-head.tsx +52 -0
- package/src/Table-model.ts +82 -0
- package/src/Table-notice.ts +39 -0
- package/src/Table-paging.ts +50 -0
- package/src/Table-rows.tsx +308 -0
- package/src/Table-selection.ts +63 -0
- package/src/Table-sortbar.tsx +41 -0
- package/src/Table-source.ts +66 -0
- package/src/Table-toolbar.tsx +71 -0
- package/src/Table-types.ts +115 -0
- package/src/Table-view.tsx +87 -0
- package/src/Table.tsx +31 -0
- package/src/Tabs.tsx +129 -0
- package/src/Tag.tsx +40 -0
- package/src/Ticker.tsx +42 -0
- package/src/TimeField-date-model.ts +77 -0
- package/src/TimeField-date-view.tsx +152 -0
- package/src/TimeField-model.ts +80 -0
- package/src/TimeField-options.tsx +224 -0
- package/src/TimeField-slots.tsx +32 -0
- package/src/TimeField-types.ts +33 -0
- package/src/TimeField-view.tsx +124 -0
- package/src/TimeField.tsx +126 -0
- package/src/Toast.tsx +143 -0
- package/src/Toggle.tsx +75 -0
- package/src/Tooltip.tsx +69 -0
- package/src/Type.tsx +136 -0
- package/src/VirtualList-controls.ts +105 -0
- package/src/VirtualList-data.ts +43 -0
- package/src/VirtualList-measure.ts +169 -0
- package/src/VirtualList-metrics.ts +41 -0
- package/src/VirtualList-mount.ts +145 -0
- package/src/VirtualList-rows.tsx +91 -0
- package/src/VirtualList-types.ts +76 -0
- package/src/VirtualList-view.tsx +123 -0
- package/src/VirtualList.tsx +81 -0
- package/src/admin/ApiKeys-actions.ts +124 -0
- package/src/admin/ApiKeys-form.tsx +64 -0
- package/src/admin/ApiKeys-view.tsx +101 -0
- package/src/admin/ApiKeys.tsx +224 -0
- package/src/admin/Audit.tsx +246 -0
- package/src/admin/Billing.tsx +307 -0
- package/src/admin/Cart.tsx +177 -0
- package/src/admin/Checkout-address.tsx +125 -0
- package/src/admin/Checkout-cart.tsx +78 -0
- package/src/admin/Checkout-coupon.ts +34 -0
- package/src/admin/Checkout-done.tsx +31 -0
- package/src/admin/Checkout-model.ts +33 -0
- package/src/admin/Checkout-navigation.ts +76 -0
- package/src/admin/Checkout-payment-view.tsx +49 -0
- package/src/admin/Checkout-payment.ts +80 -0
- package/src/admin/Checkout-review.tsx +60 -0
- package/src/admin/Checkout-shipping.tsx +47 -0
- package/src/admin/Checkout-state.ts +122 -0
- package/src/admin/Checkout-steps.ts +10 -0
- package/src/admin/Checkout-summary.tsx +97 -0
- package/src/admin/Checkout-types.ts +60 -0
- package/src/admin/Checkout-view.tsx +51 -0
- package/src/admin/Checkout.tsx +72 -0
- package/src/admin/CsvImport-actions.ts +131 -0
- package/src/admin/CsvImport.tsx +379 -0
- package/src/admin/Danger.tsx +240 -0
- package/src/admin/Integrations/Card.tsx +82 -0
- package/src/admin/Integrations/Webhooks.tsx +341 -0
- package/src/admin/Integrations.tsx +169 -0
- package/src/admin/InviteDialog.tsx +153 -0
- package/src/admin/Members/columns.tsx +181 -0
- package/src/admin/Members.tsx +316 -0
- package/src/admin/Order.tsx +115 -0
- package/src/admin/PlainTable.tsx +34 -0
- package/src/admin/Plans.tsx +375 -0
- package/src/admin/SaveBar/actions.ts +86 -0
- package/src/admin/SaveBar.tsx +153 -0
- package/src/admin/Secret.tsx +74 -0
- package/src/admin/Settings.tsx +145 -0
- package/src/admin/StepBar.tsx +66 -0
- package/src/admin/TagsInput/actions.ts +60 -0
- package/src/admin/TagsInput.tsx +95 -0
- package/src/admin/atoms.tsx +73 -0
- package/src/admin/index.ts +67 -0
- package/src/agent/Actions/reasons.tsx +38 -0
- package/src/agent/Actions.tsx +166 -0
- package/src/agent/AgentPlan.tsx +86 -0
- package/src/agent/ArtifactPanel.tsx +299 -0
- package/src/agent/Assistant.tsx +168 -0
- package/src/agent/Checkpoint.tsx +19 -0
- package/src/agent/Cite.tsx +70 -0
- package/src/agent/ContextMeter.tsx +70 -0
- package/src/agent/Conversation.tsx +70 -0
- package/src/agent/Message.tsx +92 -0
- package/src/agent/ModelPicker.tsx +167 -0
- package/src/agent/Prompt-model.ts +118 -0
- package/src/agent/Prompt-view.tsx +246 -0
- package/src/agent/Prompt.tsx +128 -0
- package/src/agent/Prose.tsx +118 -0
- package/src/agent/Question.tsx +137 -0
- package/src/agent/Reasoning.tsx +31 -0
- package/src/agent/Shimmer.tsx +11 -0
- package/src/agent/Sources.tsx +23 -0
- package/src/agent/SpeechInput.tsx +243 -0
- package/src/agent/Suggestions.tsx +36 -0
- package/src/agent/ToolCall.tsx +219 -0
- package/src/agent/TraceViewer.tsx +96 -0
- package/src/agent/bits.tsx +88 -0
- package/src/agent/index.ts +38 -0
- package/src/bind.ts +57 -0
- package/src/collab/AutoTrack.tsx +91 -0
- package/src/collab/Comments.tsx +204 -0
- package/src/collab/Composer/state.ts +125 -0
- package/src/collab/Composer/view.tsx +155 -0
- package/src/collab/Composer.tsx +141 -0
- package/src/collab/ConversationList.tsx +120 -0
- package/src/collab/Cursors.tsx +71 -0
- package/src/collab/DataIntegrity.tsx +103 -0
- package/src/collab/Kanban-card.ts +74 -0
- package/src/collab/Kanban.tsx +368 -0
- package/src/collab/Lock.tsx +36 -0
- package/src/collab/PresenceStack.tsx +176 -0
- package/src/collab/ShareDialog.tsx +273 -0
- package/src/collab/Status.tsx +101 -0
- package/src/collab/SyncedForm.tsx +42 -0
- package/src/collab/Thread/Message.tsx +265 -0
- package/src/collab/Thread/rows.tsx +56 -0
- package/src/collab/Thread.tsx +323 -0
- package/src/collab/VersionHistory.tsx +173 -0
- package/src/collab/ViewportRail.tsx +73 -0
- package/src/collab/index.ts +37 -0
- package/src/collab/peer.tsx +42 -0
- package/src/fields.ts +5 -0
- package/src/flow/AuthScreen.tsx +81 -0
- package/src/flow/AuthSteps.tsx +296 -0
- package/src/flow/Checklist.tsx +211 -0
- package/src/flow/ConnBanner.tsx +304 -0
- package/src/flow/Flow.tsx +97 -0
- package/src/flow/MfaSetup.tsx +244 -0
- package/src/flow/Otp.tsx +243 -0
- package/src/flow/ReauthDialog.tsx +79 -0
- package/src/flow/ShortcutsOverlay.tsx +121 -0
- package/src/flow/SignGate.tsx +184 -0
- package/src/flow/SignIn.tsx +136 -0
- package/src/flow/SignUp.tsx +149 -0
- package/src/flow/Sso.tsx +96 -0
- package/src/flow/SystemPage/accounts.tsx +74 -0
- package/src/flow/SystemPage/art.tsx +113 -0
- package/src/flow/SystemPage.tsx +395 -0
- package/src/flow/Tour.tsx +207 -0
- package/src/flow/index.ts +29 -0
- package/src/flow/kit.tsx +334 -0
- package/src/index.ts +237 -0
- package/src/layout.css +4 -0
- package/src/links.css +4 -0
- package/src/live/ActivityFeed.tsx +88 -0
- package/src/live/Bell.tsx +108 -0
- package/src/live/Connection.tsx +113 -0
- package/src/live/Inbox.tsx +113 -0
- package/src/live/InboxFeed.tsx +67 -0
- package/src/live/InboxGestures.ts +41 -0
- package/src/live/InboxHandlers.ts +102 -0
- package/src/live/InboxHeader.tsx +81 -0
- package/src/live/InboxModel.ts +81 -0
- package/src/live/InboxRow.tsx +125 -0
- package/src/live/MeetingRoom.tsx +22 -0
- package/src/live/MeetingRoomControlBar.tsx +197 -0
- package/src/live/MeetingRoomHandlers.ts +53 -0
- package/src/live/MeetingRoomLayout.tsx +27 -0
- package/src/live/MeetingRoomModel.ts +49 -0
- package/src/live/MeetingRoomMount.ts +49 -0
- package/src/live/MeetingRoomParts.tsx +178 -0
- package/src/live/MeetingRoomPerson.tsx +21 -0
- package/src/live/MeetingRoomState.ts +88 -0
- package/src/live/MeetingRoomTile.tsx +84 -0
- package/src/live/MeetingRoomTypes.ts +68 -0
- package/src/live/MeetingRoomView.tsx +36 -0
- package/src/live/NotificationPreferences.tsx +99 -0
- package/src/live/NotificationPreferencesActions.ts +55 -0
- package/src/live/NotificationPreferencesCell.tsx +26 -0
- package/src/live/NotificationPreferencesCells.tsx +59 -0
- package/src/live/NotificationPreferencesGrid.tsx +129 -0
- package/src/live/NotificationPreferencesModel.tsx +91 -0
- package/src/live/NotificationPreferencesSave.ts +85 -0
- package/src/live/NotificationPreferencesWatch.ts +31 -0
- package/src/live/Prejoin.tsx +238 -0
- package/src/live/PrejoinMeter.tsx +26 -0
- package/src/live/PrejoinPreview.tsx +53 -0
- package/src/live/PushSoftAsk.tsx +63 -0
- package/src/live/TransportPicker.tsx +341 -0
- package/src/live/TransportPickerDetails.tsx +130 -0
- package/src/live/index.ts +31 -0
- package/src/live/notify.tsx +22 -0
- package/src/live/shared.tsx +110 -0
- package/src/parts.tsx +199 -0
- package/src/plugin/catalog.mjs +129 -0
- package/src/plugin/dtcg.mjs +79 -0
- package/src/plugin/icons.mjs +7 -0
- package/src/plugin/seed.mjs +40 -0
- package/src/plugin/theme-context.mjs +44 -0
- package/src/plugin/theme-css.mjs +143 -0
- package/src/plugin/theme-motion.mjs +43 -0
- package/src/plugin/theme-parts.d.mts +41 -0
- package/src/plugin/theme-parts.mjs +224 -0
- package/src/plugin/theme-text.mjs +93 -0
- package/src/plugin/theme-values.mjs +15 -0
- package/src/plugin/theme.d.mts +82 -0
- package/src/plugin/theme.mjs +316 -0
- package/src/schedule/Agenda.tsx +124 -0
- package/src/schedule/AgendaActions.ts +31 -0
- package/src/schedule/AgendaDay.tsx +124 -0
- package/src/schedule/AgendaGestures.ts +27 -0
- package/src/schedule/AgendaKeys.ts +52 -0
- package/src/schedule/AgendaModel.ts +82 -0
- package/src/schedule/AgendaNavigation.ts +38 -0
- package/src/schedule/AgendaPage.tsx +39 -0
- package/src/schedule/AgendaStrip.tsx +55 -0
- package/src/schedule/AvailabilityEditor-actions.ts +146 -0
- package/src/schedule/AvailabilityEditor-day.tsx +119 -0
- package/src/schedule/AvailabilityEditor-view.tsx +205 -0
- package/src/schedule/AvailabilityEditor.tsx +113 -0
- package/src/schedule/BookingCalendar.tsx +121 -0
- package/src/schedule/BookingCalendarActions.ts +85 -0
- package/src/schedule/BookingCalendarModel.ts +86 -0
- package/src/schedule/BookingCalendarParts.tsx +87 -0
- package/src/schedule/Calendar/AgendaView.tsx +45 -0
- package/src/schedule/Calendar/CalendarDialogs.tsx +105 -0
- package/src/schedule/Calendar/CalendarMain.tsx +47 -0
- package/src/schedule/Calendar/CalendarToolbar.tsx +106 -0
- package/src/schedule/Calendar/Column.tsx +129 -0
- package/src/schedule/Calendar/EventBlock.tsx +71 -0
- package/src/schedule/Calendar/MiniMonth.tsx +169 -0
- package/src/schedule/Calendar/MonthGrid.tsx +296 -0
- package/src/schedule/Calendar/TimeGrid.tsx +252 -0
- package/src/schedule/Calendar/Timeline.tsx +287 -0
- package/src/schedule/Calendar/ZoneChip.tsx +73 -0
- package/src/schedule/Calendar/calendar-shell.ts +160 -0
- package/src/schedule/Calendar/calendar-state.ts +30 -0
- package/src/schedule/Calendar/now-spans.tsx +33 -0
- package/src/schedule/Calendar/shared.ts +3 -0
- package/src/schedule/Calendar/state-actions.ts +189 -0
- package/src/schedule/Calendar/state-base.ts +143 -0
- package/src/schedule/Calendar/state-keys.ts +128 -0
- package/src/schedule/Calendar/time-fit.ts +84 -0
- package/src/schedule/Calendar.tsx +182 -0
- package/src/schedule/EventEditor.tsx +267 -0
- package/src/schedule/EventPopover.tsx +190 -0
- package/src/schedule/MeetingPlanner-model.ts +222 -0
- package/src/schedule/MeetingPlanner-view.tsx +310 -0
- package/src/schedule/MeetingPlanner.tsx +122 -0
- package/src/schedule/MoveSheet.tsx +168 -0
- package/src/schedule/YearView-model.ts +164 -0
- package/src/schedule/YearView-parts.tsx +147 -0
- package/src/schedule/YearView.tsx +100 -0
- package/src/schedule/bits.tsx +65 -0
- package/src/schedule/index.ts +25 -0
- package/src/skeleton-css.ts +4 -0
- package/src/styles.ts +13 -0
- package/src/type.css +15 -0
- package/src/ui.ts +41 -0
- package/src/use-ui.ts +10 -0
- package/tailwind.css +38 -0
- package/tokens/color.mjs +87 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
announce,
|
|
3
|
+
fmt,
|
|
4
|
+
hhmm,
|
|
5
|
+
timeOptions,
|
|
6
|
+
uid,
|
|
7
|
+
type IsoDate,
|
|
8
|
+
type Override,
|
|
9
|
+
type Range,
|
|
10
|
+
type WeekDay,
|
|
11
|
+
} from '@kerf-js/veneer-core'
|
|
12
|
+
import { derived, flush, state, untrack } from '@kerf-js/core'
|
|
13
|
+
import { usePickerEnv } from '../Picker'
|
|
14
|
+
import { weekActions, overrideActions, saveAction } from './AvailabilityEditor-actions'
|
|
15
|
+
import { availabilityView } from './AvailabilityEditor-view'
|
|
16
|
+
import '@kerf-js/veneer-core/styles/app/availability.css'
|
|
17
|
+
|
|
18
|
+
/** A person's bookable hours: the usual week and its exceptions. */
|
|
19
|
+
export type Availability = { week: WeekDay[]; overrides: Override[] }
|
|
20
|
+
/** Props for AvailabilityEditor. */
|
|
21
|
+
export type AvailabilityEditorProps = {
|
|
22
|
+
defaultValue: Availability
|
|
23
|
+
/** "New York (EDT)". */
|
|
24
|
+
zoneLabel?: string | undefined
|
|
25
|
+
/** Pins today's date, for server rendering and tests. The browser's clock otherwise. */
|
|
26
|
+
today?: string | undefined
|
|
27
|
+
locale?: string | undefined
|
|
28
|
+
/** Times on offer, minutes. */
|
|
29
|
+
from?: number | undefined
|
|
30
|
+
to?: number | undefined
|
|
31
|
+
step?: number | undefined
|
|
32
|
+
/** Rejecting says so and keeps the changes. */
|
|
33
|
+
onSave: (v: Availability) => void | Promise<unknown>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const optionsOf = (from?: number, to?: number, step?: number) =>
|
|
37
|
+
timeOptions(from, to, step).map((m) => ({ value: String(m), label: hhmm(m) }))
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* AvailabilityEditor (07 §6.4): a Switch and From/To ranges per weekday, "Copy Monday to weekdays", date overrides. Ranges
|
|
41
|
+
* validate on change; Save stays blocked with focus on the first invalid time. Saves nothing until Save.
|
|
42
|
+
*/
|
|
43
|
+
export function AvailabilityEditor(p: AvailabilityEditorProps) {
|
|
44
|
+
const id = uid('avail')
|
|
45
|
+
const env = usePickerEnv(
|
|
46
|
+
() => p.locale,
|
|
47
|
+
() => p.today,
|
|
48
|
+
)
|
|
49
|
+
const seed = untrack(() => p.defaultValue)
|
|
50
|
+
const week = state<WeekDay[]>(
|
|
51
|
+
seed.week.map((d) => ({ ...d, ranges: d.ranges.map((r) => [...r] as Range) })),
|
|
52
|
+
)
|
|
53
|
+
const overrides = state<Override[]>(seed.overrides.map((o) => ({ ...o })))
|
|
54
|
+
const status = state('No unsaved changes')
|
|
55
|
+
const busy = state(false)
|
|
56
|
+
const adding = state(false)
|
|
57
|
+
const newDate = state<IsoDate | null>(null)
|
|
58
|
+
const newNote = state('')
|
|
59
|
+
const off = state(true)
|
|
60
|
+
const newFrom = state('540')
|
|
61
|
+
const newTo = state('780')
|
|
62
|
+
const options = derived(() => optionsOf(p.from, p.to, p.step))
|
|
63
|
+
const dayName = (d: number) =>
|
|
64
|
+
fmt(`2024-01-${String(7 + d).padStart(2, '0')}`, { weekday: 'long' }, env.locale.value)
|
|
65
|
+
let root: HTMLDivElement | undefined
|
|
66
|
+
let saveBtn: HTMLElement | undefined
|
|
67
|
+
const say = (t: string, loud = false) => root && announce(root.ownerDocument, t, loud)
|
|
68
|
+
const dirty = () => (status.value = 'Unsaved changes')
|
|
69
|
+
const focus = (sel: string) => {
|
|
70
|
+
flush()
|
|
71
|
+
root?.querySelector<HTMLElement>(sel)?.focus()
|
|
72
|
+
}
|
|
73
|
+
const actionContext = {
|
|
74
|
+
p: untrack(() => p),
|
|
75
|
+
week,
|
|
76
|
+
overrides,
|
|
77
|
+
status,
|
|
78
|
+
busy,
|
|
79
|
+
adding,
|
|
80
|
+
newDate,
|
|
81
|
+
newNote,
|
|
82
|
+
off,
|
|
83
|
+
newFrom,
|
|
84
|
+
newTo,
|
|
85
|
+
env,
|
|
86
|
+
dayName,
|
|
87
|
+
say,
|
|
88
|
+
dirty,
|
|
89
|
+
focus,
|
|
90
|
+
getRoot: () => root,
|
|
91
|
+
getSaveBtn: () => saveBtn,
|
|
92
|
+
}
|
|
93
|
+
const { patch, setTime, addRange, removeRange, copyMonday } = weekActions(actionContext)
|
|
94
|
+
const { addOverride, removeOverride } = overrideActions(actionContext)
|
|
95
|
+
const save = saveAction(actionContext)
|
|
96
|
+
const view = {
|
|
97
|
+
...actionContext,
|
|
98
|
+
env,
|
|
99
|
+
id,
|
|
100
|
+
options,
|
|
101
|
+
patch,
|
|
102
|
+
setTime,
|
|
103
|
+
addRange,
|
|
104
|
+
removeRange,
|
|
105
|
+
copyMonday,
|
|
106
|
+
addOverride,
|
|
107
|
+
removeOverride,
|
|
108
|
+
save,
|
|
109
|
+
setSaveBtn: (n: HTMLElement) => (saveBtn = n),
|
|
110
|
+
setRoot: (n: HTMLDivElement) => (root = n),
|
|
111
|
+
}
|
|
112
|
+
return availabilityView(view)
|
|
113
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { IsoDate } from '@kerf-js/veneer-core'
|
|
2
|
+
import type { State } from '@kerf-js/core'
|
|
3
|
+
import { Button } from '../Button'
|
|
4
|
+
import { InlineCalendar } from '../Calendar'
|
|
5
|
+
import { Alert } from '../Alert'
|
|
6
|
+
import { Skeleton } from '../Skeleton'
|
|
7
|
+
import { TimeField } from '../TimeField'
|
|
8
|
+
import { bookingModel } from './BookingCalendarModel'
|
|
9
|
+
import { BookingSlots, BookingDone, BookingConfirm } from './BookingCalendarParts'
|
|
10
|
+
import '@kerf-js/veneer-core/styles/app/booking.css'
|
|
11
|
+
import '@kerf-js/veneer-core/styles/rich/calendar-grid.css'
|
|
12
|
+
|
|
13
|
+
/** A start in minutes; `disabled` shows it taken rather than hiding it. */
|
|
14
|
+
export type BookingSlot = { s: number; disabled?: boolean | undefined }
|
|
15
|
+
/** The slot being booked, in minutes from midnight; manual when typed rather than picked. */
|
|
16
|
+
export type BookingDetails = { date: string; s: number; e: number; manual: boolean }
|
|
17
|
+
/** Props for BookingCalendar. */
|
|
18
|
+
export type BookingCalendarProps = {
|
|
19
|
+
/** The times for a day: a list, or read from the date. */
|
|
20
|
+
slots: BookingSlot[] | ((date: string) => BookingSlot[])
|
|
21
|
+
/** The picked day: a state it writes, or a plain value with `onDateChange`. */
|
|
22
|
+
date?: State<IsoDate | null> | IsoDate | undefined
|
|
23
|
+
/** The day picked at the start, when the calendar keeps its own state. */
|
|
24
|
+
defaultDate?: IsoDate | undefined
|
|
25
|
+
/** Called with the day picked. Load that day's slots here. */
|
|
26
|
+
onDateChange?: ((d: IsoDate) => void) | undefined
|
|
27
|
+
duration?: number | undefined
|
|
28
|
+
min?: string | undefined
|
|
29
|
+
max?: string | undefined
|
|
30
|
+
isDateUnavailable?: ((d: IsoDate) => boolean) | undefined
|
|
31
|
+
loading?: boolean | undefined
|
|
32
|
+
error?: unknown
|
|
33
|
+
/** Pins today's date, for server rendering and tests. The browser's clock otherwise. */
|
|
34
|
+
today?: string | undefined
|
|
35
|
+
locale?: string | undefined
|
|
36
|
+
/** `h12` for AM and PM, `h23` for a 24-hour clock. The locale's otherwise. */
|
|
37
|
+
hourCycle?: string | undefined
|
|
38
|
+
/** Rejecting keeps the confirm step and says why. */
|
|
39
|
+
onBook: (b: BookingDetails) => void | Promise<unknown>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* BookingCalendar (07 §2.2): InlineCalendar plus slot buttons (`aria-pressed`), a confirm step with a manual time as the
|
|
44
|
+
* fallback field path, and the arrival sweep on the confirmation card.
|
|
45
|
+
*/
|
|
46
|
+
export function BookingCalendar(p: BookingCalendarProps) {
|
|
47
|
+
const model = bookingModel(() => p)
|
|
48
|
+
return (
|
|
49
|
+
<div ref={model.setRoot} data-scope="booking" data-part="root">
|
|
50
|
+
<InlineCalendar
|
|
51
|
+
aria-label="Choose a date"
|
|
52
|
+
value={model.date.value}
|
|
53
|
+
onValueChange={(d) => model.setDate(d as IsoDate)}
|
|
54
|
+
today={model.env.today.value}
|
|
55
|
+
locale={model.env.locale.value}
|
|
56
|
+
min={p.min}
|
|
57
|
+
max={p.max}
|
|
58
|
+
isDateUnavailable={p.isDateUnavailable}
|
|
59
|
+
/>
|
|
60
|
+
{model.stage.value === 'done' ? (
|
|
61
|
+
<BookingDone model={model} />
|
|
62
|
+
) : (
|
|
63
|
+
<>
|
|
64
|
+
{!model.date.value && <p class="muted">Pick a date to see the times.</p>}
|
|
65
|
+
{model.date.value && p.loading && (
|
|
66
|
+
<div data-part="slots" aria-busy="true">
|
|
67
|
+
<Skeleton />
|
|
68
|
+
<Skeleton />
|
|
69
|
+
<Skeleton />
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
{model.date.value && !p.loading && p.error && (
|
|
73
|
+
<Alert tone="critical" title="Couldn't load the times" live>
|
|
74
|
+
{p.error}
|
|
75
|
+
</Alert>
|
|
76
|
+
)}
|
|
77
|
+
{model.date.value && !p.loading && !p.error && !model.manual.value && (
|
|
78
|
+
<BookingSlots model={model} hourCycle={p.hourCycle} />
|
|
79
|
+
)}
|
|
80
|
+
{model.date.value && model.manual.value && (
|
|
81
|
+
<TimeField
|
|
82
|
+
id={`${model.id}-t`}
|
|
83
|
+
label="Time"
|
|
84
|
+
value={model.typed}
|
|
85
|
+
locale={model.env.locale.value}
|
|
86
|
+
hourCycle="h23"
|
|
87
|
+
hint="Type any time."
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
{model.date.value && !p.error && (
|
|
91
|
+
<div class="row">
|
|
92
|
+
<Button
|
|
93
|
+
emphasis="ghost"
|
|
94
|
+
tone="neutral"
|
|
95
|
+
size="sm"
|
|
96
|
+
onClick={() => {
|
|
97
|
+
model.manual.value = !model.manual.value
|
|
98
|
+
model.stage.value = 'pick'
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
{model.manual.value ? 'Show suggested times' : 'Enter a time'}
|
|
102
|
+
</Button>
|
|
103
|
+
<span style="flex:1"></span>
|
|
104
|
+
{model.stage.value === 'pick' && (
|
|
105
|
+
<Button disabled={model.chosen.value === null} onClick={model.toConfirm}>
|
|
106
|
+
Continue
|
|
107
|
+
</Button>
|
|
108
|
+
)}
|
|
109
|
+
</div>
|
|
110
|
+
)}
|
|
111
|
+
{model.stage.value === 'confirm' && <BookingConfirm model={model} />}
|
|
112
|
+
{model.failed.value && (
|
|
113
|
+
<Alert tone="critical" title="Couldn't book" live>
|
|
114
|
+
{model.failed.value}
|
|
115
|
+
</Alert>
|
|
116
|
+
)}
|
|
117
|
+
</>
|
|
118
|
+
)}
|
|
119
|
+
</div>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { announce, type IsoDate } from '@kerf-js/veneer-core'
|
|
2
|
+
import { flush, type State } from '@kerf-js/core'
|
|
3
|
+
import { confirmSweep } from './bits'
|
|
4
|
+
import type { BookingCalendarProps } from './BookingCalendar'
|
|
5
|
+
|
|
6
|
+
export function bookingActions({
|
|
7
|
+
p,
|
|
8
|
+
own,
|
|
9
|
+
date,
|
|
10
|
+
pick,
|
|
11
|
+
manual,
|
|
12
|
+
stage,
|
|
13
|
+
busy,
|
|
14
|
+
failed,
|
|
15
|
+
len,
|
|
16
|
+
chosen,
|
|
17
|
+
when,
|
|
18
|
+
root,
|
|
19
|
+
}: {
|
|
20
|
+
p: () => BookingCalendarProps
|
|
21
|
+
own: State<IsoDate | null>
|
|
22
|
+
date: { readonly value: IsoDate | null }
|
|
23
|
+
pick: State<number | null>
|
|
24
|
+
manual: State<boolean>
|
|
25
|
+
stage: State<'pick' | 'confirm' | 'done'>
|
|
26
|
+
busy: State<boolean>
|
|
27
|
+
failed: State<string | null>
|
|
28
|
+
len: { readonly value: number }
|
|
29
|
+
chosen: { readonly value: number | null }
|
|
30
|
+
when: { readonly value: string }
|
|
31
|
+
root: () => HTMLDivElement | undefined
|
|
32
|
+
}) {
|
|
33
|
+
const setDate = (d: IsoDate) => {
|
|
34
|
+
if (p().date && typeof p().date === 'object') (p().date as State<IsoDate | null>).value = d
|
|
35
|
+
else own.value = d
|
|
36
|
+
p().onDateChange?.(d)
|
|
37
|
+
pick.value = null
|
|
38
|
+
stage.value = 'pick'
|
|
39
|
+
}
|
|
40
|
+
const toConfirm = () => {
|
|
41
|
+
stage.value = 'confirm'
|
|
42
|
+
flush()
|
|
43
|
+
root()?.querySelector<HTMLElement>('[data-confirm-step] button:last-child')?.focus()
|
|
44
|
+
}
|
|
45
|
+
const book = async () => {
|
|
46
|
+
const d = date.value,
|
|
47
|
+
s = chosen.value
|
|
48
|
+
if (!d || s === null || busy.value) return
|
|
49
|
+
busy.value = true
|
|
50
|
+
failed.value = null
|
|
51
|
+
try {
|
|
52
|
+
await p().onBook({ date: d, s, e: s + len.value, manual: manual.value })
|
|
53
|
+
stage.value = 'done'
|
|
54
|
+
flush()
|
|
55
|
+
if (root()) {
|
|
56
|
+
confirmSweep(root()!.querySelector('[data-part="slot"][aria-pressed="true"]'))
|
|
57
|
+
announce(root()!.ownerDocument, `Booked ${when.value}`)
|
|
58
|
+
}
|
|
59
|
+
} catch (err) {
|
|
60
|
+
failed.value = (err as Error | undefined)?.message ?? 'That time was just taken.'
|
|
61
|
+
if (root()) announce(root()!.ownerDocument, `Couldn't book: ${failed.value}`, true)
|
|
62
|
+
} finally {
|
|
63
|
+
busy.value = false
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { setDate, toConfirm, book }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function bookingSlots() {
|
|
70
|
+
return (e: KeyboardEvent) => {
|
|
71
|
+
const d = (
|
|
72
|
+
{ ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 } as Record<string, number>
|
|
73
|
+
)[e.key]
|
|
74
|
+
const on = [
|
|
75
|
+
...(e.currentTarget as HTMLElement).querySelectorAll<HTMLButtonElement>(
|
|
76
|
+
'button:not(:disabled)',
|
|
77
|
+
),
|
|
78
|
+
]
|
|
79
|
+
const i = on.indexOf(e.target as HTMLButtonElement)
|
|
80
|
+
if (d && i >= 0) {
|
|
81
|
+
e.preventDefault()
|
|
82
|
+
on[(i + d + on.length) % on.length]!.focus()
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { clock, fmt, minutes, uid, type IsoDate, type IsoTime } from '@kerf-js/veneer-core'
|
|
2
|
+
import { derived, state, untrack, type State } from '@kerf-js/core'
|
|
3
|
+
import { usePickerEnv } from '../Picker'
|
|
4
|
+
import { bookingActions, bookingSlots } from './BookingCalendarActions'
|
|
5
|
+
import type { BookingCalendarProps, BookingSlot } from './BookingCalendar'
|
|
6
|
+
|
|
7
|
+
export function bookingModel(p: () => BookingCalendarProps) {
|
|
8
|
+
const id = uid('book')
|
|
9
|
+
const env = usePickerEnv(
|
|
10
|
+
() => p().locale,
|
|
11
|
+
() => p().today,
|
|
12
|
+
)
|
|
13
|
+
const own = state<IsoDate | null>(
|
|
14
|
+
untrack(() => (typeof p().date === 'string' ? (p().date as IsoDate) : p().defaultDate) ?? null),
|
|
15
|
+
)
|
|
16
|
+
const date = derived(() =>
|
|
17
|
+
p().date && typeof p().date === 'object'
|
|
18
|
+
? (p().date as State<IsoDate | null>).value
|
|
19
|
+
: typeof p().date === 'string'
|
|
20
|
+
? (p().date as IsoDate)
|
|
21
|
+
: own.value,
|
|
22
|
+
)
|
|
23
|
+
const pick = state<number | null>(null)
|
|
24
|
+
const manual = state(false)
|
|
25
|
+
const typed = state<IsoTime | null>(null)
|
|
26
|
+
const stage = state<'pick' | 'confirm' | 'done'>('pick')
|
|
27
|
+
const busy = state(false)
|
|
28
|
+
const failed = state<string | null>(null)
|
|
29
|
+
const len = derived(() => p().duration ?? 30)
|
|
30
|
+
const list = derived(() => {
|
|
31
|
+
const d = date.value
|
|
32
|
+
if (!d) return []
|
|
33
|
+
return typeof p().slots === 'function'
|
|
34
|
+
? (p().slots as (date: string) => BookingSlot[])(d)
|
|
35
|
+
: (p().slots as BookingSlot[])
|
|
36
|
+
})
|
|
37
|
+
const chosen = derived(() =>
|
|
38
|
+
manual.value ? (typed.value ? minutes(typed.value) : null) : pick.value,
|
|
39
|
+
)
|
|
40
|
+
const when = derived(() => {
|
|
41
|
+
const d = date.value,
|
|
42
|
+
s = chosen.value
|
|
43
|
+
return d && s !== null
|
|
44
|
+
? `${fmt(d, { weekday: 'short', month: 'short', day: 'numeric' }, env.locale.value)} · ${clock(s, env.locale.value, p().hourCycle)}–${clock(s + len.value, env.locale.value, p().hourCycle)}`
|
|
45
|
+
: ''
|
|
46
|
+
})
|
|
47
|
+
let root: HTMLDivElement | undefined
|
|
48
|
+
const { setDate, toConfirm, book } = bookingActions({
|
|
49
|
+
p,
|
|
50
|
+
own,
|
|
51
|
+
date,
|
|
52
|
+
pick,
|
|
53
|
+
manual,
|
|
54
|
+
stage,
|
|
55
|
+
busy,
|
|
56
|
+
failed,
|
|
57
|
+
len,
|
|
58
|
+
chosen,
|
|
59
|
+
when,
|
|
60
|
+
root: () => root,
|
|
61
|
+
})
|
|
62
|
+
const onSlots = bookingSlots()
|
|
63
|
+
const empty = derived(() => !list.value.some((s) => !s.disabled))
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
id,
|
|
67
|
+
env,
|
|
68
|
+
date,
|
|
69
|
+
pick,
|
|
70
|
+
manual,
|
|
71
|
+
typed,
|
|
72
|
+
stage,
|
|
73
|
+
busy,
|
|
74
|
+
failed,
|
|
75
|
+
len,
|
|
76
|
+
list,
|
|
77
|
+
chosen,
|
|
78
|
+
when,
|
|
79
|
+
setDate,
|
|
80
|
+
onSlots,
|
|
81
|
+
toConfirm,
|
|
82
|
+
book,
|
|
83
|
+
empty,
|
|
84
|
+
setRoot: (n: HTMLDivElement) => (root = n),
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { clock, fmt, longDuration } from '@kerf-js/veneer-core'
|
|
2
|
+
import { Button } from '../Button'
|
|
3
|
+
import { SweepParts } from './bits'
|
|
4
|
+
import type { bookingModel } from './BookingCalendarModel'
|
|
5
|
+
|
|
6
|
+
type Model = ReturnType<typeof bookingModel>
|
|
7
|
+
|
|
8
|
+
export function BookingSlots({
|
|
9
|
+
model,
|
|
10
|
+
hourCycle,
|
|
11
|
+
}: {
|
|
12
|
+
model: Model
|
|
13
|
+
hourCycle: string | undefined
|
|
14
|
+
}) {
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<div
|
|
18
|
+
data-part="slots"
|
|
19
|
+
role="group"
|
|
20
|
+
aria-label={`Times on ${fmt(model.date.value!, { dateStyle: 'full' }, model.env.locale.value)}`}
|
|
21
|
+
onKeyDown={model.onSlots}
|
|
22
|
+
>
|
|
23
|
+
{model.list.value.map((x) => (
|
|
24
|
+
<button
|
|
25
|
+
key={x.s}
|
|
26
|
+
type="button"
|
|
27
|
+
data-part="slot"
|
|
28
|
+
data-sweep=""
|
|
29
|
+
aria-pressed={x.s === model.pick.value ? 'true' : 'false'}
|
|
30
|
+
disabled={x.disabled}
|
|
31
|
+
onClick={() => {
|
|
32
|
+
model.pick.value = x.s
|
|
33
|
+
model.stage.value = 'pick'
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<SweepParts />
|
|
37
|
+
{clock(x.s, model.env.locale.value, hourCycle)}
|
|
38
|
+
</button>
|
|
39
|
+
))}
|
|
40
|
+
</div>
|
|
41
|
+
{model.empty.value && <p class="muted">No times left on this day.</p>}
|
|
42
|
+
</>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function BookingDone({ model }: { model: Model }) {
|
|
47
|
+
return (
|
|
48
|
+
<div data-arrive="" class="row" role="status">
|
|
49
|
+
<div>
|
|
50
|
+
<b>Booked · {model.when.value}</b>
|
|
51
|
+
<p class="muted">{longDuration(model.len.value)}. We've sent the details.</p>
|
|
52
|
+
</div>
|
|
53
|
+
<Button
|
|
54
|
+
emphasis="ghost"
|
|
55
|
+
tone="neutral"
|
|
56
|
+
size="sm"
|
|
57
|
+
onClick={() => {
|
|
58
|
+
model.stage.value = 'pick'
|
|
59
|
+
model.pick.value = null
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
Book another
|
|
63
|
+
</Button>
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function BookingConfirm({ model }: { model: Model }) {
|
|
69
|
+
return (
|
|
70
|
+
<div class="row" data-confirm-step="">
|
|
71
|
+
<span>
|
|
72
|
+
<b>{model.when.value}</b> <span class="muted">{longDuration(model.len.value)}</span>
|
|
73
|
+
</span>
|
|
74
|
+
<Button
|
|
75
|
+
emphasis="outline"
|
|
76
|
+
tone="neutral"
|
|
77
|
+
size="sm"
|
|
78
|
+
onClick={() => (model.stage.value = 'pick')}
|
|
79
|
+
>
|
|
80
|
+
Back
|
|
81
|
+
</Button>
|
|
82
|
+
<Button size="sm" loading={model.busy.value} onClick={model.book}>
|
|
83
|
+
Confirm
|
|
84
|
+
</Button>
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { derived } from '@kerf-js/core'
|
|
2
|
+
import { fmt, viewDays } from '@kerf-js/veneer-core'
|
|
3
|
+
import { AgendaDay } from '../Agenda'
|
|
4
|
+
|
|
5
|
+
import type { Ctx } from './calendar-state'
|
|
6
|
+
|
|
7
|
+
export function AgendaView({ c }: { c: Ctx }) {
|
|
8
|
+
const days = derived(() => viewDays('week', c.date.value, c.first.value))
|
|
9
|
+
return (
|
|
10
|
+
<div data-part="scroller">
|
|
11
|
+
<div data-scope="agenda">
|
|
12
|
+
<div
|
|
13
|
+
data-part="page"
|
|
14
|
+
onClick={(e: MouseEvent) => {
|
|
15
|
+
const el = (e.target as Element).closest?.<HTMLElement>('[data-id]')
|
|
16
|
+
if (el) c.openPopover(el.dataset.id!, el)
|
|
17
|
+
}}
|
|
18
|
+
onKeyDown={(e: KeyboardEvent) => {
|
|
19
|
+
const el = (e.target as Element).closest?.<HTMLElement>('[data-id]')
|
|
20
|
+
if (el && e.key === 'Enter') c.openPopover(el.dataset.id!, el)
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
{days.value.map((d) => (
|
|
24
|
+
<section key={d}>
|
|
25
|
+
<div data-part="day-title">
|
|
26
|
+
<h4>{fmt(d, { weekday: 'long' }, c.env.locale.value)}</h4>
|
|
27
|
+
<span class="muted">
|
|
28
|
+
{fmt(d, { month: 'short', day: 'numeric' }, c.env.locale.value)}
|
|
29
|
+
</span>
|
|
30
|
+
</div>
|
|
31
|
+
<AgendaDay
|
|
32
|
+
events={c.visible.value}
|
|
33
|
+
day={d}
|
|
34
|
+
now={c.now.value}
|
|
35
|
+
locale={c.env.locale.value}
|
|
36
|
+
hourCycle={c.p.hourCycle}
|
|
37
|
+
label={fmt(d, { weekday: 'long' }, c.env.locale.value)}
|
|
38
|
+
/>
|
|
39
|
+
</section>
|
|
40
|
+
))}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Button } from '../../Button'
|
|
2
|
+
import { Segmented } from '../../Choice'
|
|
3
|
+
import { Modal } from '../../Modal'
|
|
4
|
+
import { EventEditor } from '../EventEditor'
|
|
5
|
+
import { EventPopover } from '../EventPopover'
|
|
6
|
+
import { MoveSheet } from '../MoveSheet'
|
|
7
|
+
|
|
8
|
+
import type { CalendarProps } from '../Calendar'
|
|
9
|
+
import { type useCalendarActions, type useCalendarNav } from './calendar-shell'
|
|
10
|
+
import type { Ctx } from './calendar-state'
|
|
11
|
+
type Nav = ReturnType<typeof useCalendarNav>
|
|
12
|
+
type Actions = ReturnType<typeof useCalendarActions>
|
|
13
|
+
type Props = { p: CalendarProps; c: Ctx; nav: Nav; actions: Actions; id: string }
|
|
14
|
+
export function CalendarModals({ c, actions }: Props) {
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<Modal
|
|
18
|
+
open={c.askDelete}
|
|
19
|
+
alert
|
|
20
|
+
size="sm"
|
|
21
|
+
tone="critical"
|
|
22
|
+
title={`Delete ${c.doomed.value?.title ?? 'event'}?`}
|
|
23
|
+
description="It's removed for everyone on it."
|
|
24
|
+
footer={
|
|
25
|
+
<>
|
|
26
|
+
<Button
|
|
27
|
+
emphasis="outline"
|
|
28
|
+
tone="neutral"
|
|
29
|
+
autofocus
|
|
30
|
+
onClick={() => (c.askDelete.value = false)}
|
|
31
|
+
>
|
|
32
|
+
Cancel
|
|
33
|
+
</Button>
|
|
34
|
+
<Button tone="critical" onClick={actions.confirmDelete}>
|
|
35
|
+
Delete
|
|
36
|
+
</Button>
|
|
37
|
+
</>
|
|
38
|
+
}
|
|
39
|
+
></Modal>
|
|
40
|
+
<Modal
|
|
41
|
+
open={c.scopeOpen}
|
|
42
|
+
size="sm"
|
|
43
|
+
title={`${c.pendingScope.value?.verb ?? 'Change'} repeating event`}
|
|
44
|
+
footer={
|
|
45
|
+
<>
|
|
46
|
+
<Button emphasis="outline" tone="neutral" onClick={actions.dropScope}>
|
|
47
|
+
Cancel
|
|
48
|
+
</Button>
|
|
49
|
+
<Button onClick={actions.applyScope}>{c.pendingScope.value?.verb ?? 'Apply'}</Button>
|
|
50
|
+
</>
|
|
51
|
+
}
|
|
52
|
+
>
|
|
53
|
+
<Segmented
|
|
54
|
+
label="Apply to"
|
|
55
|
+
value={c.scope.value}
|
|
56
|
+
onChange={(v) => (c.scope.value = v)}
|
|
57
|
+
options={[
|
|
58
|
+
{ value: 'this', label: 'This event' },
|
|
59
|
+
{ value: 'following', label: 'This and following' },
|
|
60
|
+
{ value: 'all', label: 'All' },
|
|
61
|
+
]}
|
|
62
|
+
/>
|
|
63
|
+
</Modal>
|
|
64
|
+
</>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function CalendarDialogs({ p, c, nav, actions, id }: Props) {
|
|
69
|
+
return (
|
|
70
|
+
<>
|
|
71
|
+
<EventPopover
|
|
72
|
+
open={c.popOpen}
|
|
73
|
+
event={c.popped.value ? (c.shown(c.popped.value) ?? null) : null}
|
|
74
|
+
anchor={() => c.anchor.value}
|
|
75
|
+
zoneLabel={c.zoneLabel.value}
|
|
76
|
+
locale={c.env.locale.value}
|
|
77
|
+
hourCycle={p.hourCycle}
|
|
78
|
+
side={c.view.value === 'agenda' ? 'bottom' : 'right'}
|
|
79
|
+
onEdit={p.onEdit && !p.readOnly ? c.edit : undefined}
|
|
80
|
+
onDelete={p.onDelete && !p.readOnly ? c.remove : undefined}
|
|
81
|
+
onJoin={p.onJoin}
|
|
82
|
+
/>
|
|
83
|
+
<EventEditor
|
|
84
|
+
open={c.editing}
|
|
85
|
+
event={c.draft.value?.event ?? null}
|
|
86
|
+
isNew={c.draft.value?.isNew}
|
|
87
|
+
calendars={p.calendars}
|
|
88
|
+
timeZone={c.zone.value ?? undefined}
|
|
89
|
+
locale={c.env.locale.value}
|
|
90
|
+
today={c.env.today.value}
|
|
91
|
+
onSave={actions.saved}
|
|
92
|
+
/>
|
|
93
|
+
<MoveSheet
|
|
94
|
+
open={c.sheet}
|
|
95
|
+
event={c.sheetFor.value}
|
|
96
|
+
events={c.all.value}
|
|
97
|
+
firstDayOfWeek={c.first.value}
|
|
98
|
+
locale={c.env.locale.value}
|
|
99
|
+
hourCycle={p.hourCycle}
|
|
100
|
+
onMove={(e, to) => c.change(e.id, to, 'move', 'touch')}
|
|
101
|
+
/>
|
|
102
|
+
<CalendarModals p={p} c={c} nav={nav} actions={actions} id={id} />
|
|
103
|
+
</>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { YearView } from '../YearView'
|
|
2
|
+
|
|
3
|
+
import type { CalendarProps } from '../Calendar'
|
|
4
|
+
import { AgendaView } from './AgendaView'
|
|
5
|
+
import { type useCalendarActions, type useCalendarNav } from './calendar-shell'
|
|
6
|
+
import type { Ctx } from './calendar-state'
|
|
7
|
+
import { MonthGrid } from './MonthGrid'
|
|
8
|
+
import { TimeGrid } from './TimeGrid'
|
|
9
|
+
import { Timeline } from './Timeline'
|
|
10
|
+
type Nav = ReturnType<typeof useCalendarNav>
|
|
11
|
+
type Actions = ReturnType<typeof useCalendarActions>
|
|
12
|
+
type Props = { p: CalendarProps; c: Ctx; nav: Nav; actions: Actions; id: string }
|
|
13
|
+
export function CalendarMain({ p, c, actions, id }: Props) {
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
data-part="main"
|
|
17
|
+
id={`${id}-main`}
|
|
18
|
+
role="tabpanel"
|
|
19
|
+
aria-labelledby={`${id}-${c.view.value}`}
|
|
20
|
+
style="min-block-size:0;min-inline-size:0;display:grid;position:relative"
|
|
21
|
+
>
|
|
22
|
+
{c.view.value === 'week' || c.view.value === 'day' ? (
|
|
23
|
+
<TimeGrid c={c} count={7} />
|
|
24
|
+
) : c.view.value === 'month' ? (
|
|
25
|
+
<MonthGrid c={c} />
|
|
26
|
+
) : c.view.value === 'agenda' ? (
|
|
27
|
+
<AgendaView c={c} />
|
|
28
|
+
) : c.view.value === 'timeline' ? (
|
|
29
|
+
<Timeline c={c} />
|
|
30
|
+
) : (
|
|
31
|
+
<div data-part="year-wrap">
|
|
32
|
+
<YearView
|
|
33
|
+
label="Year view"
|
|
34
|
+
counts={c.counts.value}
|
|
35
|
+
events={c.all.value}
|
|
36
|
+
today={c.env.today.value}
|
|
37
|
+
locale={c.env.locale.value}
|
|
38
|
+
hourCycle={p.hourCycle}
|
|
39
|
+
firstDayOfWeek={c.first.value}
|
|
40
|
+
openDay={actions.openDay}
|
|
41
|
+
openMonth={actions.openMonth}
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
}
|