@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,168 @@
|
|
|
1
|
+
import { LeftIcon, RightIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import {
|
|
3
|
+
clock,
|
|
4
|
+
clockRange,
|
|
5
|
+
dateOf,
|
|
6
|
+
fmt,
|
|
7
|
+
longDuration,
|
|
8
|
+
moveSlots,
|
|
9
|
+
slotOf,
|
|
10
|
+
weekDates,
|
|
11
|
+
type CalEvent,
|
|
12
|
+
type Slot,
|
|
13
|
+
} from '@kerf-js/veneer-core'
|
|
14
|
+
import { derived, state, untrack, type State } from '@kerf-js/core'
|
|
15
|
+
import { Alert } from '../Alert'
|
|
16
|
+
import { Button } from '../Button'
|
|
17
|
+
import { Chip } from '../Chip'
|
|
18
|
+
import { Drawer } from '../Drawer'
|
|
19
|
+
import { SweepParts, confirmSweep } from './bits'
|
|
20
|
+
import '@kerf-js/veneer-core/styles/app/booking.css'
|
|
21
|
+
|
|
22
|
+
/** Props for MoveSheet. */
|
|
23
|
+
export type MoveSheetProps = {
|
|
24
|
+
open: State<boolean>
|
|
25
|
+
event: CalEvent | null
|
|
26
|
+
/** Everything else on the calendar: a start that collides is disabled. */
|
|
27
|
+
events: CalEvent[]
|
|
28
|
+
/** The day the week strip starts on, 0 for Sunday to 6. Default 1, Monday. */
|
|
29
|
+
firstDayOfWeek?: number | undefined
|
|
30
|
+
locale?: string | undefined
|
|
31
|
+
/** `h12` for AM and PM, `h23` for a 24-hour clock. The locale's otherwise. */
|
|
32
|
+
hourCycle?: string | undefined
|
|
33
|
+
step?: number | undefined
|
|
34
|
+
onMove: (e: CalEvent, to: Slot) => void
|
|
35
|
+
onClose?: (() => void) | undefined
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The move sheet (07 §2.2, `#move-sheet`): a bottom Sheet with day, start and duration, the touch path for a drag. */
|
|
39
|
+
export function MoveSheet(p: MoveSheetProps) {
|
|
40
|
+
const title = derived(() => (p.event ? `Move “${p.event.title}”` : 'Move event'))
|
|
41
|
+
const hold = state<(() => void) | null>(null)
|
|
42
|
+
const go = () => hold.value?.()
|
|
43
|
+
const cancel = () => {
|
|
44
|
+
p.open.value = false
|
|
45
|
+
p.onClose?.()
|
|
46
|
+
}
|
|
47
|
+
return (
|
|
48
|
+
<Drawer
|
|
49
|
+
open={p.open}
|
|
50
|
+
side="bottom"
|
|
51
|
+
title={title.value}
|
|
52
|
+
description={
|
|
53
|
+
p.event
|
|
54
|
+
? `${longDuration(slotOf(p.event).e - slotOf(p.event).s)} · now ${fmt(dateOf(p.event.start), { weekday: 'short' }, p.locale ?? 'en-US')} ${clockRange(slotOf(p.event).s, slotOf(p.event).e, p.locale ?? 'en-US', p.hourCycle)}`
|
|
55
|
+
: undefined
|
|
56
|
+
}
|
|
57
|
+
footer={
|
|
58
|
+
<>
|
|
59
|
+
<Button emphasis="outline" tone="neutral" onClick={cancel}>
|
|
60
|
+
Cancel
|
|
61
|
+
</Button>
|
|
62
|
+
<Button onClick={go}>Move event</Button>
|
|
63
|
+
</>
|
|
64
|
+
}
|
|
65
|
+
>
|
|
66
|
+
{p.event && p.open.value && (
|
|
67
|
+
<Body key={p.event.id} event={p.event} props={p} bind={(f) => (hold.value = f)} />
|
|
68
|
+
)}
|
|
69
|
+
</Drawer>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function bodyModel(event: CalEvent, p: MoveSheetProps, bind: (go: () => void) => void) {
|
|
74
|
+
const e = untrack(() => event)
|
|
75
|
+
const origin = slotOf(e)
|
|
76
|
+
const day = state<string>(origin.date)
|
|
77
|
+
const start = state(origin.s)
|
|
78
|
+
const len = state(origin.e - origin.s)
|
|
79
|
+
const locale = derived(() => p.locale ?? 'en-US')
|
|
80
|
+
const week = derived(() => weekDates(origin.date, p.firstDayOfWeek ?? 1))
|
|
81
|
+
const slots = derived(() => moveSlots(p.events, e, { date: day.value, len: len.value }))
|
|
82
|
+
const stepBy = untrack(() => p.step ?? 15)
|
|
83
|
+
const go = () => {
|
|
84
|
+
const to = {
|
|
85
|
+
date: day.value,
|
|
86
|
+
s: start.value,
|
|
87
|
+
e: start.value + len.value,
|
|
88
|
+
resource: origin.resource,
|
|
89
|
+
}
|
|
90
|
+
p.open.value = false
|
|
91
|
+
p.onMove(e, to)
|
|
92
|
+
p.onClose?.()
|
|
93
|
+
}
|
|
94
|
+
untrack(() => bind(go))
|
|
95
|
+
const pick = (s: number, ev: MouseEvent) => {
|
|
96
|
+
start.value = s
|
|
97
|
+
confirmSweep(ev.currentTarget as Element)
|
|
98
|
+
}
|
|
99
|
+
return { e, day, start, len, locale, week, slots, stepBy, pick }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function Body({
|
|
103
|
+
event,
|
|
104
|
+
props: p,
|
|
105
|
+
bind,
|
|
106
|
+
}: {
|
|
107
|
+
event: CalEvent
|
|
108
|
+
props: MoveSheetProps
|
|
109
|
+
bind: (go: () => void) => void
|
|
110
|
+
}) {
|
|
111
|
+
const { e, day, start, len, locale, week, slots, stepBy, pick } = untrack(() =>
|
|
112
|
+
bodyModel(event, p, bind),
|
|
113
|
+
)
|
|
114
|
+
return (
|
|
115
|
+
<div class="stack">
|
|
116
|
+
<div class="chips" role="group" aria-label="Day">
|
|
117
|
+
{week.value.map((d) => (
|
|
118
|
+
<Chip key={d} pressed={d === day.value} onClick={() => (day.value = d)}>
|
|
119
|
+
{fmt(d, { weekday: 'short', day: 'numeric' }, locale.value)}
|
|
120
|
+
</Chip>
|
|
121
|
+
))}
|
|
122
|
+
</div>
|
|
123
|
+
<div data-scope="booking" data-part="root">
|
|
124
|
+
<div data-part="slots" role="group" aria-label="Start time">
|
|
125
|
+
{slots.value.map((x) => (
|
|
126
|
+
<button
|
|
127
|
+
key={x.s}
|
|
128
|
+
type="button"
|
|
129
|
+
data-part="slot"
|
|
130
|
+
data-sweep=""
|
|
131
|
+
aria-pressed={x.s === start.value ? 'true' : 'false'}
|
|
132
|
+
disabled={x.busy}
|
|
133
|
+
onClick={(ev: MouseEvent) => pick(x.s, ev)}
|
|
134
|
+
>
|
|
135
|
+
<SweepParts />
|
|
136
|
+
{clock(x.s, locale.value, p.hourCycle)}
|
|
137
|
+
</button>
|
|
138
|
+
))}
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
<div class="row" role="group" aria-label="Duration">
|
|
142
|
+
<Button
|
|
143
|
+
emphasis="outline"
|
|
144
|
+
tone="neutral"
|
|
145
|
+
size="sm"
|
|
146
|
+
label="Shorter"
|
|
147
|
+
icon={LeftIcon}
|
|
148
|
+
disabled={len.value <= stepBy}
|
|
149
|
+
onClick={() => (len.value = Math.max(stepBy, len.value - stepBy))}
|
|
150
|
+
/>
|
|
151
|
+
<output aria-live="polite">{longDuration(len.value)}</output>
|
|
152
|
+
<Button
|
|
153
|
+
emphasis="outline"
|
|
154
|
+
tone="neutral"
|
|
155
|
+
size="sm"
|
|
156
|
+
label="Longer"
|
|
157
|
+
icon={RightIcon}
|
|
158
|
+
onClick={() => (len.value += stepBy)}
|
|
159
|
+
/>
|
|
160
|
+
</div>
|
|
161
|
+
{e.recurrence && (
|
|
162
|
+
<Alert tone="info" title="This event repeats">
|
|
163
|
+
Moving changes this one only. Use Edit for the series.
|
|
164
|
+
</Alert>
|
|
165
|
+
)}
|
|
166
|
+
</div>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import {
|
|
2
|
+
announce,
|
|
3
|
+
eventsOn,
|
|
4
|
+
fmt,
|
|
5
|
+
monthStart,
|
|
6
|
+
monthSummary,
|
|
7
|
+
monthWeeks,
|
|
8
|
+
motionOff,
|
|
9
|
+
uid,
|
|
10
|
+
weekStart,
|
|
11
|
+
weekdays,
|
|
12
|
+
ymd,
|
|
13
|
+
yearKey,
|
|
14
|
+
yearMonths,
|
|
15
|
+
yearTotal,
|
|
16
|
+
type IsoDate,
|
|
17
|
+
} from '@kerf-js/veneer-core'
|
|
18
|
+
import { derived, flush, state, untrack } from '@kerf-js/core'
|
|
19
|
+
import { usePickerEnv } from '../Picker'
|
|
20
|
+
import type { YearViewProps } from './YearView'
|
|
21
|
+
|
|
22
|
+
const events = (n: number) => (n ? `${n} event${n > 1 ? 's' : ''}` : 'no events')
|
|
23
|
+
|
|
24
|
+
export function yearData(p: YearViewProps) {
|
|
25
|
+
const id = uid('year')
|
|
26
|
+
const env = usePickerEnv(
|
|
27
|
+
() => p.locale,
|
|
28
|
+
() => p.today,
|
|
29
|
+
)
|
|
30
|
+
const first = derived(() => p.firstDayOfWeek ?? weekStart(env.locale.value))
|
|
31
|
+
const heads = derived(() => weekdays(first.value, env.locale.value))
|
|
32
|
+
const focus = state<string>(
|
|
33
|
+
untrack(() =>
|
|
34
|
+
p.year && p.year !== ymd(env.today.value)[0] ? `${p.year}-01-01` : env.today.value,
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
const year = derived(() => ymd(focus.value)[0])
|
|
38
|
+
const picked = state<{ iso: string; kind: 'day' | 'month' } | null>(null)
|
|
39
|
+
const swapping = state(false)
|
|
40
|
+
const list = derived(() =>
|
|
41
|
+
yearMonths(year.value).map((month) => {
|
|
42
|
+
const { total } = monthSummary(p.counts, month)
|
|
43
|
+
return {
|
|
44
|
+
month,
|
|
45
|
+
total,
|
|
46
|
+
name: fmt(month, { month: 'long' }, env.locale.value),
|
|
47
|
+
current: month === monthStart(env.today.value),
|
|
48
|
+
weeks: monthWeeks(month, first.value).map((days, r) => ({
|
|
49
|
+
key: `${month}-${r}`,
|
|
50
|
+
cells: days.map((iso, c) => ({
|
|
51
|
+
key: iso ?? `${month}-${r}-${c}`,
|
|
52
|
+
iso,
|
|
53
|
+
count: iso ? (p.counts[iso] ?? 0) : 0,
|
|
54
|
+
weekend: (first.value + c) % 7 === 0 || (first.value + c) % 7 === 6,
|
|
55
|
+
})),
|
|
56
|
+
})),
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
)
|
|
60
|
+
return { id, env, first, heads, focus, year, picked, swapping, list }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function yearDetail(
|
|
64
|
+
p: YearViewProps,
|
|
65
|
+
data: ReturnType<typeof yearData>,
|
|
66
|
+
long: (iso: string) => string,
|
|
67
|
+
) {
|
|
68
|
+
const { env, year, picked } = data
|
|
69
|
+
const detail = derived(() => {
|
|
70
|
+
const at = picked.value
|
|
71
|
+
if (!at || ymd(at.iso)[0] !== year.value) return null
|
|
72
|
+
if (at.kind === 'month') {
|
|
73
|
+
const s = monthSummary(p.counts, at.iso)
|
|
74
|
+
return {
|
|
75
|
+
kind: 'month' as const,
|
|
76
|
+
iso: at.iso,
|
|
77
|
+
head: `${fmt(at.iso, { month: 'long', year: 'numeric' }, env.locale.value)} · ${s.total} events`,
|
|
78
|
+
busiest: s.busiest ? `Busiest day: ${long(s.busiest)}, ${s.most} events.` : undefined,
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const n = p.counts[at.iso] ?? 0
|
|
82
|
+
const rows = p.events ? eventsOn(p.events, at.iso) : []
|
|
83
|
+
return {
|
|
84
|
+
kind: 'day' as const,
|
|
85
|
+
iso: at.iso,
|
|
86
|
+
head: `${long(at.iso)} · ${n ? events(n) : 'nothing booked'}`,
|
|
87
|
+
rows: rows.slice(0, 4),
|
|
88
|
+
more: Math.max(0, rows.length - 4),
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
return detail
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function yearNavigation(p: YearViewProps, data: ReturnType<typeof yearData>) {
|
|
95
|
+
const { env, first, focus, year, picked, swapping } = data
|
|
96
|
+
let months: HTMLDivElement | undefined
|
|
97
|
+
const say = (t: string) => months && announce(months.ownerDocument, t)
|
|
98
|
+
const long = (iso: string) =>
|
|
99
|
+
fmt(iso, { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' }, env.locale.value)
|
|
100
|
+
const toCell = () => {
|
|
101
|
+
flush()
|
|
102
|
+
months?.querySelector<HTMLElement>('[data-day][tabindex="0"]')?.focus()
|
|
103
|
+
}
|
|
104
|
+
const go = (iso: string, move = true) => {
|
|
105
|
+
const was = year.value
|
|
106
|
+
const swap = ymd(iso)[0] !== was
|
|
107
|
+
const apply = () => {
|
|
108
|
+
focus.value = iso
|
|
109
|
+
swapping.value = false
|
|
110
|
+
if (move) toCell()
|
|
111
|
+
if (swap) {
|
|
112
|
+
say(
|
|
113
|
+
`${ymd(iso)[0]}, ${yearTotal(p.counts, ymd(iso)[0]).toLocaleString(env.locale.value)} events`,
|
|
114
|
+
)
|
|
115
|
+
p.onYearChange?.(ymd(iso)[0])
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (!swap || !months || motionOff(months)) return apply()
|
|
119
|
+
swapping.value = true
|
|
120
|
+
setTimeout(apply, 140)
|
|
121
|
+
}
|
|
122
|
+
const dayName = (iso: string) => `${long(iso)}, ${events(p.counts[iso] ?? 0)}`
|
|
123
|
+
const day = (iso: string) => {
|
|
124
|
+
if (p.direct !== false && p.openDay?.(iso as IsoDate)) return say(`Day view, ${long(iso)}`)
|
|
125
|
+
focus.value = iso
|
|
126
|
+
picked.value = { iso, kind: 'day' }
|
|
127
|
+
say(dayName(iso))
|
|
128
|
+
}
|
|
129
|
+
const month = (iso: string) => {
|
|
130
|
+
const m = monthStart(iso)
|
|
131
|
+
if (p.direct !== false && p.openMonth?.(m))
|
|
132
|
+
return say(`Month view, ${fmt(m, { month: 'long', year: 'numeric' }, env.locale.value)}`)
|
|
133
|
+
focus.value = m
|
|
134
|
+
picked.value = { iso: m, kind: 'month' }
|
|
135
|
+
toCell()
|
|
136
|
+
const s = monthSummary(p.counts, m)
|
|
137
|
+
say(`${fmt(m, { month: 'long', year: 'numeric' }, env.locale.value)}, ${s.total} events`)
|
|
138
|
+
}
|
|
139
|
+
const onKey = (e: KeyboardEvent) => {
|
|
140
|
+
const c = (e.target as Element).closest?.<HTMLElement>('[data-day]')
|
|
141
|
+
if (!c || e.metaKey || e.ctrlKey) return
|
|
142
|
+
const to = yearKey(
|
|
143
|
+
e.key,
|
|
144
|
+
e.shiftKey,
|
|
145
|
+
c.dataset.day!,
|
|
146
|
+
first.value,
|
|
147
|
+
getComputedStyle(c).direction === 'rtl',
|
|
148
|
+
)
|
|
149
|
+
if (!to) return
|
|
150
|
+
e.preventDefault()
|
|
151
|
+
if (to === 'pick') day(c.dataset.day!)
|
|
152
|
+
else if (to === 'month') month(c.dataset.day!)
|
|
153
|
+
else if (to === 'today') go(env.today.value)
|
|
154
|
+
else go(to)
|
|
155
|
+
}
|
|
156
|
+
const onClick = (e: MouseEvent) => {
|
|
157
|
+
const t = e.target as Element
|
|
158
|
+
const title = t.closest?.<HTMLElement>('[data-part="month-title"]')
|
|
159
|
+
if (title) return month(title.dataset.month!)
|
|
160
|
+
const c = t.closest?.<HTMLElement>('[data-day]')
|
|
161
|
+
if (c) day(c.dataset.day!)
|
|
162
|
+
}
|
|
163
|
+
return { long, dayName, go, onKey, onClick, setMonths: (n: HTMLDivElement) => (months = n) }
|
|
164
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { clock, minuteOf, monthStart, ymd, yearLevel, type IsoDate } from '@kerf-js/veneer-core'
|
|
2
|
+
import { Button } from '../Button'
|
|
3
|
+
import type { YearViewProps } from './YearView'
|
|
4
|
+
import type { yearData, yearDetail, yearNavigation } from './YearView-model'
|
|
5
|
+
|
|
6
|
+
export function yearMonthsView(
|
|
7
|
+
data: ReturnType<typeof yearData>,
|
|
8
|
+
nav: ReturnType<typeof yearNavigation>,
|
|
9
|
+
) {
|
|
10
|
+
const { id, swapping, list, heads, focus, picked, env } = data
|
|
11
|
+
const { setMonths, onKey, onClick, dayName } = nav
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
ref={setMonths}
|
|
15
|
+
data-part="months"
|
|
16
|
+
role="group"
|
|
17
|
+
aria-labelledby={`${id}-t`}
|
|
18
|
+
aria-describedby={`${id}-h`}
|
|
19
|
+
data-swapping={swapping.value ? '' : undefined}
|
|
20
|
+
onKeyDown={onKey}
|
|
21
|
+
onClick={onClick}
|
|
22
|
+
>
|
|
23
|
+
{list.value.map((m) => (
|
|
24
|
+
<div key={m.month} data-part="year-month" data-current={m.current ? '' : undefined}>
|
|
25
|
+
<button
|
|
26
|
+
type="button"
|
|
27
|
+
data-part="month-title"
|
|
28
|
+
id={`${id}-${m.month}`}
|
|
29
|
+
data-month={m.month}
|
|
30
|
+
tabindex="-1"
|
|
31
|
+
>
|
|
32
|
+
{m.name}{' '}
|
|
33
|
+
<small>
|
|
34
|
+
{m.total}
|
|
35
|
+
<span class="sr"> events</span>
|
|
36
|
+
</small>
|
|
37
|
+
</button>
|
|
38
|
+
<div role="grid" aria-labelledby={`${id}-${m.month}`}>
|
|
39
|
+
<div role="row">
|
|
40
|
+
{heads.value.map((h) => (
|
|
41
|
+
<span key={h[0]} role="columnheader">
|
|
42
|
+
<span aria-hidden="true">{h[0][0]}</span>
|
|
43
|
+
<span class="sr">{h[0]}</span>
|
|
44
|
+
</span>
|
|
45
|
+
))}
|
|
46
|
+
</div>
|
|
47
|
+
{m.weeks.map((w) => (
|
|
48
|
+
<div key={w.key} role="row">
|
|
49
|
+
{w.cells.map((c) =>
|
|
50
|
+
c.iso ? (
|
|
51
|
+
<span
|
|
52
|
+
key={c.key}
|
|
53
|
+
role="gridcell"
|
|
54
|
+
data-day={c.iso}
|
|
55
|
+
tabindex={c.iso === focus.value ? '0' : '-1'}
|
|
56
|
+
aria-selected={
|
|
57
|
+
picked.value?.iso === c.iso && picked.value.kind === 'day'
|
|
58
|
+
? 'true'
|
|
59
|
+
: 'false'
|
|
60
|
+
}
|
|
61
|
+
aria-current={c.iso === env.today.value ? 'date' : undefined}
|
|
62
|
+
data-weekend={c.weekend ? '' : undefined}
|
|
63
|
+
aria-label={`${dayName(c.iso)}${c.iso === env.today.value ? ', today' : ''}`}
|
|
64
|
+
>
|
|
65
|
+
<span data-part="num" aria-hidden="true">
|
|
66
|
+
{ymd(c.iso)[2]}
|
|
67
|
+
</span>
|
|
68
|
+
<i
|
|
69
|
+
data-part="dots"
|
|
70
|
+
style={`--_n:${yearLevel(c.count)}`}
|
|
71
|
+
aria-hidden="true"
|
|
72
|
+
></i>
|
|
73
|
+
</span>
|
|
74
|
+
) : (
|
|
75
|
+
<span key={c.key} role="gridcell" data-outside="" aria-hidden="true"></span>
|
|
76
|
+
),
|
|
77
|
+
)}
|
|
78
|
+
</div>
|
|
79
|
+
))}
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
))}
|
|
83
|
+
</div>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function yearDetailView(
|
|
88
|
+
p: YearViewProps,
|
|
89
|
+
data: ReturnType<typeof yearData>,
|
|
90
|
+
detail: ReturnType<typeof yearDetail>,
|
|
91
|
+
) {
|
|
92
|
+
const { picked, env } = data
|
|
93
|
+
return (
|
|
94
|
+
<div data-part="detail" role="status" aria-live="polite">
|
|
95
|
+
{detail.value ? (
|
|
96
|
+
<>
|
|
97
|
+
<div class="row">
|
|
98
|
+
<b>{detail.value.head}</b>
|
|
99
|
+
{detail.value.kind === 'day' && p.openDay && (
|
|
100
|
+
<Button
|
|
101
|
+
emphasis="outline"
|
|
102
|
+
tone="neutral"
|
|
103
|
+
size="sm"
|
|
104
|
+
onClick={() => p.openDay!(picked.value!.iso as IsoDate)}
|
|
105
|
+
>
|
|
106
|
+
Open in Day view
|
|
107
|
+
</Button>
|
|
108
|
+
)}
|
|
109
|
+
{p.openMonth && (
|
|
110
|
+
<Button
|
|
111
|
+
emphasis="ghost"
|
|
112
|
+
tone="neutral"
|
|
113
|
+
size="sm"
|
|
114
|
+
onClick={() => p.openMonth!(monthStart(picked.value!.iso))}
|
|
115
|
+
>
|
|
116
|
+
Open in Month view
|
|
117
|
+
</Button>
|
|
118
|
+
)}
|
|
119
|
+
</div>
|
|
120
|
+
{detail.value.kind === 'month'
|
|
121
|
+
? detail.value.busiest && <span class="muted">{detail.value.busiest}</span>
|
|
122
|
+
: detail.value.rows.length > 0 && (
|
|
123
|
+
<ul>
|
|
124
|
+
{detail.value.rows.map((e) => (
|
|
125
|
+
<li key={e.id}>
|
|
126
|
+
<i data-cal={e.cal ?? 1}></i>
|
|
127
|
+
<span>
|
|
128
|
+
{e.allDay
|
|
129
|
+
? 'All day'
|
|
130
|
+
: clock(minuteOf(e.start), env.locale.value, p.hourCycle)}
|
|
131
|
+
</span>
|
|
132
|
+
{e.title}
|
|
133
|
+
</li>
|
|
134
|
+
))}
|
|
135
|
+
{detail.value.more > 0 && <li>+{detail.value.more} more</li>}
|
|
136
|
+
</ul>
|
|
137
|
+
)}
|
|
138
|
+
</>
|
|
139
|
+
) : (
|
|
140
|
+
<span class="muted">
|
|
141
|
+
Pick a day to see what's on it. More dots, busier day: one for 1–2 events, two for 3–4,
|
|
142
|
+
three for 5 or more.
|
|
143
|
+
</span>
|
|
144
|
+
)}
|
|
145
|
+
</div>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { LeftIcon, RightIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import { addMonths, type CalEvent, type IsoDate } from '@kerf-js/veneer-core'
|
|
3
|
+
import { untrack } from '@kerf-js/core'
|
|
4
|
+
import { Button } from '../Button'
|
|
5
|
+
import { yearData, yearDetail, yearNavigation } from './YearView-model'
|
|
6
|
+
import { yearMonthsView, yearDetailView } from './YearView-parts'
|
|
7
|
+
import './bits'
|
|
8
|
+
import '@kerf-js/veneer-core/styles/app/year.css'
|
|
9
|
+
|
|
10
|
+
/** Props for YearView. */
|
|
11
|
+
export type YearViewProps = {
|
|
12
|
+
/** `{ [isoDay]: n }`: a year's counts only (07 §2.7). */
|
|
13
|
+
counts: Record<string, number>
|
|
14
|
+
/** Names the section when the year alone won't do: two on a page. */
|
|
15
|
+
label?: string | undefined
|
|
16
|
+
/** Events for the picked day's detail: from `events`, or fetched by the app when it is picked. */
|
|
17
|
+
events?: CalEvent[] | undefined
|
|
18
|
+
year?: number | undefined
|
|
19
|
+
/** Pins today's date, for server rendering and tests. The browser's clock otherwise. */
|
|
20
|
+
today?: string | undefined
|
|
21
|
+
locale?: string | undefined
|
|
22
|
+
/** `h12` for AM and PM, `h23` for a 24-hour clock. The locale's otherwise. */
|
|
23
|
+
hourCycle?: string | undefined
|
|
24
|
+
/** The day each month's rows start on, 0 for Sunday to 6. The locale's otherwise. */
|
|
25
|
+
firstDayOfWeek?: number | undefined
|
|
26
|
+
/** Inside a Calendar: return true when the day or month opened there, and the picker stays out of the way. */
|
|
27
|
+
openDay?: ((iso: IsoDate) => boolean | void) | undefined
|
|
28
|
+
openMonth?: ((iso: IsoDate) => boolean | void) | undefined
|
|
29
|
+
/** Open straight away; off, a pick shows the detail and offers the jump. */
|
|
30
|
+
direct?: boolean | undefined
|
|
31
|
+
/** Called with the new year when you page. */
|
|
32
|
+
onYearChange?: ((y: number) => void) | undefined
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The year (07 §2.7): twelve mini months with density dots, one roving stop across all twelve grids, a polite detail
|
|
37
|
+
* for the picked day or month. Columns follow the container. Enter opens the day, `M` its month, `T` today.
|
|
38
|
+
*/
|
|
39
|
+
export function YearView(p: YearViewProps) {
|
|
40
|
+
const props = untrack(() => p)
|
|
41
|
+
const data = yearData(props)
|
|
42
|
+
const nav = yearNavigation(props, data)
|
|
43
|
+
const { id, env, focus, year } = data
|
|
44
|
+
const { go } = nav
|
|
45
|
+
const detail = yearDetail(props, data, nav.long)
|
|
46
|
+
return (
|
|
47
|
+
<section
|
|
48
|
+
data-scope="year"
|
|
49
|
+
aria-label={p.label}
|
|
50
|
+
aria-labelledby={p.label ? undefined : `${id}-t`}
|
|
51
|
+
>
|
|
52
|
+
<div data-part="toolbar">
|
|
53
|
+
<Button
|
|
54
|
+
emphasis="ghost"
|
|
55
|
+
tone="neutral"
|
|
56
|
+
size="sm"
|
|
57
|
+
icon={LeftIcon}
|
|
58
|
+
label="Previous year"
|
|
59
|
+
direction="back"
|
|
60
|
+
onClick={() => go(addMonths(focus.value, -12), false)}
|
|
61
|
+
/>
|
|
62
|
+
<h3 data-part="title" id={`${id}-t`} aria-live="polite">
|
|
63
|
+
{year.value}
|
|
64
|
+
</h3>
|
|
65
|
+
<Button
|
|
66
|
+
emphasis="ghost"
|
|
67
|
+
tone="neutral"
|
|
68
|
+
size="sm"
|
|
69
|
+
icon={RightIcon}
|
|
70
|
+
label="Next year"
|
|
71
|
+
onClick={() => go(addMonths(focus.value, 12), false)}
|
|
72
|
+
/>
|
|
73
|
+
<Button emphasis="outline" tone="neutral" size="sm" onClick={() => go(env.today.value)}>
|
|
74
|
+
Today
|
|
75
|
+
</Button>
|
|
76
|
+
<span data-part="legend" aria-hidden="true">
|
|
77
|
+
<span>
|
|
78
|
+
<i data-part="dots" data-zero=""></i>none
|
|
79
|
+
</span>
|
|
80
|
+
<span>
|
|
81
|
+
<i data-part="dots" style="--_n:1"></i>1–2
|
|
82
|
+
</span>
|
|
83
|
+
<span>
|
|
84
|
+
<i data-part="dots" style="--_n:2"></i>3–4
|
|
85
|
+
</span>
|
|
86
|
+
<span>
|
|
87
|
+
<i data-part="dots" style="--_n:3"></i>5+
|
|
88
|
+
</span>
|
|
89
|
+
</span>
|
|
90
|
+
</div>
|
|
91
|
+
{yearMonthsView(data, nav)}
|
|
92
|
+
<span class="sr" id={`${id}-h`}>
|
|
93
|
+
One stop for the whole year. Arrow keys move by day and week, Home and End to the week's
|
|
94
|
+
ends, Page Up and Page Down by month, with Shift by year. Enter opens the day, M opens its
|
|
95
|
+
month, T goes to today.
|
|
96
|
+
</span>
|
|
97
|
+
{yearDetailView(p, data, detail)}
|
|
98
|
+
</section>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// What the schedule pack's components share: sweep parts, glyphs, the clock.
|
|
2
|
+
import { RepeatIcon } from '@kerf-js/veneer-icons'
|
|
3
|
+
import { installSweep, nowIn } from '@kerf-js/veneer-core'
|
|
4
|
+
import { onCleanup, onMount, state, untrack, watch } from '@kerf-js/core'
|
|
5
|
+
import '../styles'
|
|
6
|
+
import '@kerf-js/veneer-core/styles/app/tokens.css'
|
|
7
|
+
import '@kerf-js/veneer-core/styles/app/base.css'
|
|
8
|
+
import '@kerf-js/veneer-core/styles/rich/helpers.css'
|
|
9
|
+
|
|
10
|
+
export const SweepParts = () => (
|
|
11
|
+
<>
|
|
12
|
+
<span data-part="sweep-base" aria-hidden="true"></span>
|
|
13
|
+
<span data-part="sweep" aria-hidden="true"></span>
|
|
14
|
+
</>
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
/** calendar.css and agenda.css default `--_c` on the same element as `data-cal`, so the source's colour is set inline too. */
|
|
18
|
+
export const tint = (cal?: number) => `--_c:var(--veneer-color-data-${cal ?? 1})`
|
|
19
|
+
export const RepeatGlyph = () => <RepeatIcon />
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The wall clock for the now line (07 §2.2): the prop when there is one, else null through hydration and the browser's
|
|
23
|
+
* clock a microtask after mount, then on each minute. It pauses while the page is hidden.
|
|
24
|
+
*/
|
|
25
|
+
export function useNow(now: () => string | undefined, zone: () => string | undefined) {
|
|
26
|
+
const value = state<string | null>(untrack(now) ?? null)
|
|
27
|
+
onMount(() => {
|
|
28
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
29
|
+
const tick = () => {
|
|
30
|
+
clearTimeout(timer)
|
|
31
|
+
if (untrack(now) || document.hidden) return
|
|
32
|
+
value.value = nowIn(untrack(zone))
|
|
33
|
+
timer = setTimeout(tick, 60000 - (Date.now() % 60000))
|
|
34
|
+
}
|
|
35
|
+
queueMicrotask(tick)
|
|
36
|
+
document.addEventListener('visibilitychange', tick)
|
|
37
|
+
watch(now, (n) => {
|
|
38
|
+
if (n) value.value = n
|
|
39
|
+
})
|
|
40
|
+
onCleanup(() => {
|
|
41
|
+
clearTimeout(timer)
|
|
42
|
+
document.removeEventListener('visibilitychange', tick)
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
return value
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The container's width, 0 until it has been measured after mount. */
|
|
49
|
+
export function useWidth(el: () => Element | undefined) {
|
|
50
|
+
const width = state(0)
|
|
51
|
+
onMount(() => {
|
|
52
|
+
const node = el()
|
|
53
|
+
if (!node || typeof ResizeObserver === 'undefined') return
|
|
54
|
+
const ro = new ResizeObserver((r) => {
|
|
55
|
+
width.value = r[0]!.contentRect.width
|
|
56
|
+
})
|
|
57
|
+
ro.observe(node)
|
|
58
|
+
onCleanup(() => ro.disconnect())
|
|
59
|
+
})
|
|
60
|
+
return width
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const confirmSweep = (el: Element | null | undefined) => {
|
|
64
|
+
if (el) installSweep(el.ownerDocument).confirm(el)
|
|
65
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// The schedule pack (07 §2, §6.4): calendar, agenda, year, booking, planner, availability. One file per family; each imports only its own CSS.
|
|
2
|
+
export {
|
|
3
|
+
Calendar,
|
|
4
|
+
type CalendarProps,
|
|
5
|
+
type EventChange,
|
|
6
|
+
type RecurrenceScope,
|
|
7
|
+
type Resource,
|
|
8
|
+
} from './Calendar'
|
|
9
|
+
export { EventPopover, type EventPopoverProps } from './EventPopover'
|
|
10
|
+
export { EventEditor, type EventEditorProps, type CalendarSource } from './EventEditor'
|
|
11
|
+
export { MoveSheet, type MoveSheetProps } from './MoveSheet'
|
|
12
|
+
export { Agenda, AgendaDay, type AgendaProps } from './Agenda'
|
|
13
|
+
export { YearView, type YearViewProps } from './YearView'
|
|
14
|
+
export {
|
|
15
|
+
BookingCalendar,
|
|
16
|
+
type BookingCalendarProps,
|
|
17
|
+
type BookingSlot,
|
|
18
|
+
type BookingDetails,
|
|
19
|
+
} from './BookingCalendar'
|
|
20
|
+
export { MeetingPlanner, type MeetingPlannerProps, type MeetingDetails } from './MeetingPlanner'
|
|
21
|
+
export {
|
|
22
|
+
AvailabilityEditor,
|
|
23
|
+
type AvailabilityEditorProps,
|
|
24
|
+
type Availability,
|
|
25
|
+
} from './AvailabilityEditor'
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// veneer's skeleton CSS for a page that uses `<Boundary pending="shape">` without a <Shape> or <Skeleton> (research 31 §5):
|
|
2
|
+
// `import '@kerf-js/veneer/skeleton'` once. A shape variant is core markup, so nothing else pulls the CSS in.
|
|
3
|
+
import './styles'
|
|
4
|
+
import '@kerf-js/veneer-core/styles/components/skeleton.css'
|
package/src/styles.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="@kerf-js/core/client" />
|
|
2
|
+
|
|
3
|
+
// The shared base every veneer component loads first: the spec tokens, base and signature layers (veneer-core/styles/
|
|
4
|
+
// veneer.css), an app's seed and field defaults from veneer() (kerf:tokens/veneer, empty without the plugin), and the
|
|
5
|
+
// components' plumbing (tone channels, icon strokes, kbd, panels), and the skeleton paint. `links.css` is veneer's colour for a bare `<a>`.
|
|
6
|
+
// CSS alone: code here would run as every component's module loads, and keep each island holding one from waiting
|
|
7
|
+
// (hydration.json H010). veneer.flow is the page's, so the app's client entry arms it (`flow()` from @kerf-js/veneer-core).
|
|
8
|
+
import '@kerf-js/veneer-core/styles/veneer.css'
|
|
9
|
+
import 'kerf:tokens/veneer'
|
|
10
|
+
import '@kerf-js/veneer-core/styles/components/base.css'
|
|
11
|
+
import './links.css'
|
|
12
|
+
// Every page can show a skeleton: navigation stands a route's generated shape in while it loads, whatever it imports.
|
|
13
|
+
import '@kerf-js/veneer-core/styles/components/skeleton.css'
|