@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,189 @@
|
|
|
1
|
+
import { flush } from '@kerf-js/core'
|
|
2
|
+
import {
|
|
3
|
+
at,
|
|
4
|
+
clock,
|
|
5
|
+
conflicts,
|
|
6
|
+
fmt,
|
|
7
|
+
slotOf,
|
|
8
|
+
slotTimes,
|
|
9
|
+
toZone,
|
|
10
|
+
uid,
|
|
11
|
+
type CalEvent,
|
|
12
|
+
type DragPreview,
|
|
13
|
+
type Slot,
|
|
14
|
+
} from '@kerf-js/veneer-core'
|
|
15
|
+
import { confirmSweep } from '../bits'
|
|
16
|
+
|
|
17
|
+
import type { useBase, useDialogs, useEvents, useFocus } from './state-base'
|
|
18
|
+
import type { RecurrenceScope } from '../Calendar'
|
|
19
|
+
type Reason = 'pointer' | 'keyboard' | 'touch'
|
|
20
|
+
|
|
21
|
+
type Base = ReturnType<typeof useBase> &
|
|
22
|
+
ReturnType<typeof useEvents> &
|
|
23
|
+
ReturnType<typeof useFocus> &
|
|
24
|
+
ReturnType<typeof useDialogs>
|
|
25
|
+
|
|
26
|
+
export function useChange({
|
|
27
|
+
p,
|
|
28
|
+
tz,
|
|
29
|
+
overlay,
|
|
30
|
+
waiting,
|
|
31
|
+
say,
|
|
32
|
+
all,
|
|
33
|
+
env,
|
|
34
|
+
focusEvent,
|
|
35
|
+
nodeOf,
|
|
36
|
+
raw,
|
|
37
|
+
askScope,
|
|
38
|
+
}: Base) {
|
|
39
|
+
const settle = (
|
|
40
|
+
e: CalEvent,
|
|
41
|
+
slot: Slot,
|
|
42
|
+
verb: 'move' | 'resize',
|
|
43
|
+
reason: Reason,
|
|
44
|
+
chosen?: RecurrenceScope,
|
|
45
|
+
) => {
|
|
46
|
+
const from =
|
|
47
|
+
e.tz && tz() && e.tz !== tz()
|
|
48
|
+
? {
|
|
49
|
+
start: toZone(at(slot.date, slot.s), tz()!, e.tz),
|
|
50
|
+
end: toZone(at(slot.date, slot.e), tz()!, e.tz),
|
|
51
|
+
}
|
|
52
|
+
: slotTimes(slot)
|
|
53
|
+
overlay.value = { ...overlay.value, [e.id]: slot }
|
|
54
|
+
waiting.add(e.id)
|
|
55
|
+
const put = () => {
|
|
56
|
+
waiting.delete(e.id)
|
|
57
|
+
}
|
|
58
|
+
const back = (err: unknown) => {
|
|
59
|
+
put()
|
|
60
|
+
const { [e.id]: _, ...rest } = overlay.value
|
|
61
|
+
overlay.value = rest
|
|
62
|
+
say(
|
|
63
|
+
`Couldn't ${verb} ${e.title}: ${(err as Error | undefined)?.message ?? 'try again'}`,
|
|
64
|
+
true,
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
let r: PromiseLike<unknown> | undefined
|
|
68
|
+
try {
|
|
69
|
+
r = (verb === 'move' ? p.onMove : p.onResize)?.(
|
|
70
|
+
e,
|
|
71
|
+
{ ...from, resource: slot.resource, scope: chosen },
|
|
72
|
+
reason,
|
|
73
|
+
) as PromiseLike<unknown> | undefined
|
|
74
|
+
} catch (err) {
|
|
75
|
+
back(err)
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
if (r?.then) r.then(put, back)
|
|
79
|
+
else put()
|
|
80
|
+
const hit = conflicts(all.value, e, slot)
|
|
81
|
+
const day = fmt(slot.date, { weekday: 'long' }, env.locale.value)
|
|
82
|
+
say(
|
|
83
|
+
`${verb === 'move' ? `Moved ${e.title} to ${day} ${clock(slot.s, env.locale.value, p.hourCycle)}` : `${e.title} now ends at ${clock(slot.e, env.locale.value, p.hourCycle)}`}${hit.length ? `. Overlaps ${hit.map((x) => x.title).join(', ')}` : ''}`,
|
|
84
|
+
)
|
|
85
|
+
flush()
|
|
86
|
+
focusEvent(e.id)
|
|
87
|
+
confirmSweep(nodeOf(e.id))
|
|
88
|
+
}
|
|
89
|
+
const change = (id: string, slot: Slot, verb: 'move' | 'resize', reason: Reason) => {
|
|
90
|
+
const e = raw(id)
|
|
91
|
+
if (!e) return
|
|
92
|
+
if (!e.recurrence) return settle(e, slot, verb, reason)
|
|
93
|
+
overlay.value = { ...overlay.value, [e.id]: slot }
|
|
94
|
+
askScope(
|
|
95
|
+
verb === 'move' ? 'Move' : 'Change',
|
|
96
|
+
(s) => settle(e, slot, verb, reason, s),
|
|
97
|
+
() => {
|
|
98
|
+
const { [e.id]: _, ...rest } = overlay.value
|
|
99
|
+
overlay.value = rest
|
|
100
|
+
},
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
return { settle, change }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function useEditing({
|
|
107
|
+
p,
|
|
108
|
+
draft,
|
|
109
|
+
editing,
|
|
110
|
+
stop,
|
|
111
|
+
anchor,
|
|
112
|
+
popped,
|
|
113
|
+
popOpen,
|
|
114
|
+
raw,
|
|
115
|
+
shown,
|
|
116
|
+
doomed,
|
|
117
|
+
askScope,
|
|
118
|
+
say,
|
|
119
|
+
askDelete,
|
|
120
|
+
sheetFor,
|
|
121
|
+
sheet,
|
|
122
|
+
}: Base) {
|
|
123
|
+
const newEvent = (start: string, end: string, resource?: string) => {
|
|
124
|
+
draft.value = {
|
|
125
|
+
event: { id: uid('new'), title: '', start, end, cal: p.calendars?.[0]?.id ?? 1, resource },
|
|
126
|
+
isNew: true,
|
|
127
|
+
}
|
|
128
|
+
editing.value = true
|
|
129
|
+
}
|
|
130
|
+
const openPopover = (id: string, el: HTMLElement) => {
|
|
131
|
+
stop.value = id
|
|
132
|
+
anchor.value = el
|
|
133
|
+
popped.value = id
|
|
134
|
+
popOpen.value = true
|
|
135
|
+
const e = raw(id)
|
|
136
|
+
if (e) p.onOpen?.(e)
|
|
137
|
+
}
|
|
138
|
+
const edit = (e: CalEvent) => {
|
|
139
|
+
draft.value = { event: shown(e.id) ?? e, isNew: false }
|
|
140
|
+
editing.value = true
|
|
141
|
+
}
|
|
142
|
+
const remove = (e: CalEvent) => {
|
|
143
|
+
doomed.value = e
|
|
144
|
+
if (e.recurrence)
|
|
145
|
+
return askScope('Delete', (s) => {
|
|
146
|
+
p.onDelete?.(e, s)
|
|
147
|
+
say(`Deleted ${e.title}`)
|
|
148
|
+
})
|
|
149
|
+
askDelete.value = true
|
|
150
|
+
}
|
|
151
|
+
const openSheet = (id: string) => {
|
|
152
|
+
const e = shown(id)
|
|
153
|
+
if (e && !e.locked) {
|
|
154
|
+
sheetFor.value = e
|
|
155
|
+
sheet.value = true
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return { newEvent, openPopover, edit, remove, openSheet }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function useDrag(
|
|
162
|
+
{ p, shown, drag, date }: Base,
|
|
163
|
+
{ change }: ReturnType<typeof useChange>,
|
|
164
|
+
{ newEvent, openPopover, openSheet }: ReturnType<typeof useEditing>,
|
|
165
|
+
) {
|
|
166
|
+
const dragOpts = () => ({
|
|
167
|
+
step: p.snap ?? 15,
|
|
168
|
+
readOnly: p.readOnly,
|
|
169
|
+
slot: (id: string) => {
|
|
170
|
+
const e = shown(id)
|
|
171
|
+
return e && !e.locked ? slotOf(e) : null
|
|
172
|
+
},
|
|
173
|
+
onPreview: (v: DragPreview | null) => (drag.value = v),
|
|
174
|
+
onDrop: (v: DragPreview) => {
|
|
175
|
+
if (v.mode === 'create') return newEvent(at(v.date, v.s), at(v.date, v.e), v.resource)
|
|
176
|
+
change(
|
|
177
|
+
v.id!,
|
|
178
|
+
{ date: v.date, s: v.s, e: v.e, resource: v.resource },
|
|
179
|
+
v.mode === 'move' ? 'move' : 'resize',
|
|
180
|
+
'pointer',
|
|
181
|
+
)
|
|
182
|
+
},
|
|
183
|
+
onPress: openPopover,
|
|
184
|
+
onLongPress: p.readOnly ? undefined : openSheet,
|
|
185
|
+
onSlot: (d: string, m: number, r?: string) =>
|
|
186
|
+
newEvent(at(d || date.value, m), at(d || date.value, m + 30), r),
|
|
187
|
+
})
|
|
188
|
+
return dragOpts
|
|
189
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { derived, flush, state, untrack, watch } from '@kerf-js/core'
|
|
2
|
+
import {
|
|
3
|
+
announce,
|
|
4
|
+
countByDay,
|
|
5
|
+
shownIn,
|
|
6
|
+
slotTimes,
|
|
7
|
+
weekStart,
|
|
8
|
+
zoneCity,
|
|
9
|
+
type CalEvent,
|
|
10
|
+
type CalView,
|
|
11
|
+
type DragPreview,
|
|
12
|
+
type Slot,
|
|
13
|
+
} from '@kerf-js/veneer-core'
|
|
14
|
+
import { bindable, usePickerEnv } from '../../Picker'
|
|
15
|
+
import { useNow } from '../bits'
|
|
16
|
+
|
|
17
|
+
import type { CalendarProps, RecurrenceScope } from '../Calendar'
|
|
18
|
+
|
|
19
|
+
export function useBase(p: CalendarProps) {
|
|
20
|
+
const env = usePickerEnv(
|
|
21
|
+
() => p.locale,
|
|
22
|
+
() => p.today,
|
|
23
|
+
)
|
|
24
|
+
const view = bindable<CalView>(
|
|
25
|
+
() => p.view,
|
|
26
|
+
() => p.defaultView,
|
|
27
|
+
'week',
|
|
28
|
+
() => p.onViewChange,
|
|
29
|
+
)
|
|
30
|
+
const date = bindable<string>(
|
|
31
|
+
() => p.date,
|
|
32
|
+
() => p.defaultDate,
|
|
33
|
+
untrack(() => env.today.value),
|
|
34
|
+
() => p.onDateChange,
|
|
35
|
+
)
|
|
36
|
+
const zone = bindable<string | null>(
|
|
37
|
+
() => p.timeZone,
|
|
38
|
+
() => null,
|
|
39
|
+
null,
|
|
40
|
+
() => p.onTimeZoneChange,
|
|
41
|
+
)
|
|
42
|
+
const tz = () => zone.value ?? undefined
|
|
43
|
+
const now = useNow(() => p.now, tz)
|
|
44
|
+
const first = derived(() => p.firstDayOfWeek ?? weekStart(env.locale.value))
|
|
45
|
+
return { p, env, view, date, zone, tz, now, first }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function useEvents({ p, tz }: ReturnType<typeof useBase>) {
|
|
49
|
+
const off = state<number[]>([])
|
|
50
|
+
const overlay = state<Record<string, Slot>>({})
|
|
51
|
+
const waiting = new Set<string>()
|
|
52
|
+
const drag = state<DragPreview | null>(null)
|
|
53
|
+
const moving = state<{ id: string; origin: Slot; slot: Slot } | null>(null)
|
|
54
|
+
const stop = state<string | null>(null)
|
|
55
|
+
watch(
|
|
56
|
+
() => p.events,
|
|
57
|
+
() => {
|
|
58
|
+
const keep: Record<string, Slot> = {}
|
|
59
|
+
for (const id of waiting) if (overlay.value[id]) keep[id] = overlay.value[id]
|
|
60
|
+
overlay.value = keep
|
|
61
|
+
},
|
|
62
|
+
)
|
|
63
|
+
const all = derived(() =>
|
|
64
|
+
p.events.map((e) => {
|
|
65
|
+
const v = shownIn(e, tz()),
|
|
66
|
+
o = overlay.value[e.id]
|
|
67
|
+
return o ? { ...v, ...slotTimes(o), resource: o.resource ?? v.resource } : v
|
|
68
|
+
}),
|
|
69
|
+
)
|
|
70
|
+
const visible = derived(() => all.value.filter((e) => !off.value.includes(e.cal ?? 1)))
|
|
71
|
+
const preview = derived<DragPreview | null>(() => {
|
|
72
|
+
const m = moving.value
|
|
73
|
+
return m ? { ...m.slot, mode: 'move', id: m.id, origin: m.origin } : drag.value
|
|
74
|
+
})
|
|
75
|
+
const counts = derived(() => p.counts ?? countByDay(all.value))
|
|
76
|
+
const raw = (id: string) => p.events.find((e) => e.id === id)
|
|
77
|
+
const shown = (id: string) => all.value.find((e) => e.id === id)
|
|
78
|
+
return { off, overlay, waiting, drag, moving, stop, all, visible, preview, counts, raw, shown }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function useFocus({
|
|
82
|
+
stop,
|
|
83
|
+
zone,
|
|
84
|
+
env,
|
|
85
|
+
date,
|
|
86
|
+
}: ReturnType<typeof useBase> & ReturnType<typeof useEvents>) {
|
|
87
|
+
let root: HTMLElement | undefined
|
|
88
|
+
const say = (t: string, loud = false) => root && announce(root.ownerDocument, t, loud)
|
|
89
|
+
const zoneLabel = derived(() => {
|
|
90
|
+
const z = zone.value
|
|
91
|
+
if (!z) return undefined
|
|
92
|
+
const short = new Intl.DateTimeFormat(env.locale.value, { timeZone: z, timeZoneName: 'short' })
|
|
93
|
+
.formatToParts(new Date(`${date.value}T12:00:00Z`))
|
|
94
|
+
.find((x) => x.type === 'timeZoneName')?.value
|
|
95
|
+
return `${zoneCity(z)} · ${short}`
|
|
96
|
+
})
|
|
97
|
+
const nodeOf = (id: string) => root?.querySelector<HTMLElement>(`[data-id="${CSS.escape(id)}"]`)
|
|
98
|
+
const focusEvent = (id: string) => {
|
|
99
|
+
stop.value = id
|
|
100
|
+
flush()
|
|
101
|
+
nodeOf(id)?.focus({ preventScroll: false })
|
|
102
|
+
}
|
|
103
|
+
return { say, zoneLabel, nodeOf, focusEvent, bindRoot: (n: HTMLElement) => (root = n) }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function useDialogs() {
|
|
107
|
+
const anchor = state<HTMLElement | undefined>(undefined)
|
|
108
|
+
const popped = state<string | null>(null)
|
|
109
|
+
const popOpen = state(false)
|
|
110
|
+
const editing = state(false)
|
|
111
|
+
const draft = state<{ event: CalEvent; isNew: boolean } | null>(null)
|
|
112
|
+
const sheet = state(false)
|
|
113
|
+
const sheetFor = state<CalEvent | null>(null)
|
|
114
|
+
const doomed = state<CalEvent | null>(null)
|
|
115
|
+
const askDelete = state(false)
|
|
116
|
+
const scopeOpen = state(false)
|
|
117
|
+
const scope = state<RecurrenceScope>('this')
|
|
118
|
+
const pendingScope = state<{
|
|
119
|
+
run: (s: RecurrenceScope) => void
|
|
120
|
+
undo?: (() => void) | undefined
|
|
121
|
+
verb: string
|
|
122
|
+
} | null>(null)
|
|
123
|
+
const askScope = (verb: string, run: (s: RecurrenceScope) => void, undo?: () => void) => {
|
|
124
|
+
pendingScope.value = { run, undo, verb }
|
|
125
|
+
scope.value = 'this'
|
|
126
|
+
scopeOpen.value = true
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
anchor,
|
|
130
|
+
popped,
|
|
131
|
+
popOpen,
|
|
132
|
+
editing,
|
|
133
|
+
draft,
|
|
134
|
+
sheet,
|
|
135
|
+
sheetFor,
|
|
136
|
+
doomed,
|
|
137
|
+
askDelete,
|
|
138
|
+
scopeOpen,
|
|
139
|
+
scope,
|
|
140
|
+
pendingScope,
|
|
141
|
+
askScope,
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { clockRange, fmt, moveKey, slotOf } from '@kerf-js/veneer-core'
|
|
2
|
+
|
|
3
|
+
import type { useChange, useEditing } from './state-actions'
|
|
4
|
+
import type { useBase, useDialogs, useEvents, useFocus } from './state-base'
|
|
5
|
+
type Base = ReturnType<typeof useBase> &
|
|
6
|
+
ReturnType<typeof useEvents> &
|
|
7
|
+
ReturnType<typeof useFocus> &
|
|
8
|
+
ReturnType<typeof useDialogs>
|
|
9
|
+
type Change = ReturnType<typeof useChange>
|
|
10
|
+
type Editing = ReturnType<typeof useEditing>
|
|
11
|
+
type Options = {
|
|
12
|
+
days?: string[]
|
|
13
|
+
resources?: string[]
|
|
14
|
+
next: (key: string, id: string) => string | null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function movingKey({
|
|
18
|
+
e,
|
|
19
|
+
opts,
|
|
20
|
+
id,
|
|
21
|
+
rtl,
|
|
22
|
+
m,
|
|
23
|
+
base: { p, moving, say, focusEvent, env },
|
|
24
|
+
actions: { change },
|
|
25
|
+
}: {
|
|
26
|
+
e: KeyboardEvent
|
|
27
|
+
opts: Options
|
|
28
|
+
id: string
|
|
29
|
+
rtl: boolean
|
|
30
|
+
m: NonNullable<Base['moving']['value']>
|
|
31
|
+
base: Base
|
|
32
|
+
actions: Change
|
|
33
|
+
}) {
|
|
34
|
+
if (e.key === 'Tab') {
|
|
35
|
+
moving.value = null
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
const to = moveKey(e.key, e.shiftKey, m.slot, {
|
|
39
|
+
step: p.snap ?? 15,
|
|
40
|
+
days: opts.days,
|
|
41
|
+
rtl,
|
|
42
|
+
resources: opts.resources,
|
|
43
|
+
})
|
|
44
|
+
if (to === null) return
|
|
45
|
+
e.preventDefault()
|
|
46
|
+
if (to === 'cancel') {
|
|
47
|
+
moving.value = null
|
|
48
|
+
say('Move cancelled')
|
|
49
|
+
focusEvent(id)
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
if (to === 'drop') {
|
|
53
|
+
const changed = m.slot
|
|
54
|
+
moving.value = null
|
|
55
|
+
if (
|
|
56
|
+
changed.date === m.origin.date &&
|
|
57
|
+
changed.s === m.origin.s &&
|
|
58
|
+
changed.e === m.origin.e &&
|
|
59
|
+
changed.resource === m.origin.resource
|
|
60
|
+
)
|
|
61
|
+
return focusEvent(id)
|
|
62
|
+
return change(
|
|
63
|
+
id,
|
|
64
|
+
changed,
|
|
65
|
+
changed.e - changed.s === m.origin.e - m.origin.s ? 'move' : 'resize',
|
|
66
|
+
'keyboard',
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
moving.value = { ...m, slot: to }
|
|
70
|
+
say(
|
|
71
|
+
`${fmt(to.date, { weekday: 'short' }, env.locale.value)} ${clockRange(to.s, to.e, env.locale.value, p.hourCycle)}`,
|
|
72
|
+
)
|
|
73
|
+
focusEvent(id)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function useKeys(base: Base, actions: Change, editing: Editing) {
|
|
77
|
+
const { p, moving, say, focusEvent, raw, shown } = base
|
|
78
|
+
const { change } = actions
|
|
79
|
+
const { openPopover, remove } = editing
|
|
80
|
+
return (e: KeyboardEvent, opts: Options) => {
|
|
81
|
+
const el = (e.target as Element).closest?.<HTMLElement>('[data-id]')
|
|
82
|
+
if (!el) return
|
|
83
|
+
const id = el.dataset.id!
|
|
84
|
+
const rtl = getComputedStyle(el).direction === 'rtl'
|
|
85
|
+
const m = moving.value
|
|
86
|
+
if (m && m.id === id) return movingKey({ e, opts, id, rtl, m, base, actions })
|
|
87
|
+
const ev = shown(id)
|
|
88
|
+
if (!ev) return
|
|
89
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
90
|
+
e.preventDefault()
|
|
91
|
+
openPopover(id, el)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
const editable = !p.readOnly && !ev.locked
|
|
95
|
+
if ((e.key === 'm' || e.key === 'M') && !e.metaKey && !e.ctrlKey && editable && !ev.allDay) {
|
|
96
|
+
e.preventDefault()
|
|
97
|
+
const slot = slotOf(ev)
|
|
98
|
+
moving.value = { id, origin: slot, slot }
|
|
99
|
+
say(
|
|
100
|
+
`Moving ${ev.title}. Arrows move by ${p.snap ?? 15} minutes or a day, Shift with arrows resizes, Enter drops, Escape cancels.`,
|
|
101
|
+
true,
|
|
102
|
+
)
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
if (
|
|
106
|
+
e.shiftKey &&
|
|
107
|
+
(e.key === 'ArrowUp' || e.key === 'ArrowDown') &&
|
|
108
|
+
editable &&
|
|
109
|
+
!ev.allDay &&
|
|
110
|
+
!opts.resources
|
|
111
|
+
) {
|
|
112
|
+
e.preventDefault()
|
|
113
|
+
const to = moveKey(e.key, true, slotOf(ev), { step: p.snap ?? 15 })
|
|
114
|
+
if (to && typeof to === 'object') change(id, to, 'resize', 'keyboard')
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
if ((e.key === 'Delete' || e.key === 'Backspace') && editable && p.onDelete) {
|
|
118
|
+
e.preventDefault()
|
|
119
|
+
remove(raw(id)!)
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
const to = opts.next(e.key, id)
|
|
123
|
+
if (to) {
|
|
124
|
+
e.preventDefault()
|
|
125
|
+
focusEvent(to)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { untrack } from '@kerf-js/core'
|
|
2
|
+
import type { Ctx } from './calendar-state'
|
|
3
|
+
import { DAY_FIT } from './shared'
|
|
4
|
+
|
|
5
|
+
// Every name reads whole (calendar.css breaks it only between words). A day needs room for its longest word in each lane
|
|
6
|
+
// it shares (a short event's whole name, on its one line). When every day's need fits the box, the week shows all its
|
|
7
|
+
// days and spreads them over the room; when it can't (a phone), each day keeps --veneer-cal-day-min too and the week
|
|
8
|
+
// scrolls sideways. Then the hours lengthen until no name runs past the bottom of its event.
|
|
9
|
+
export function fitTimeGrid(
|
|
10
|
+
c: Ctx,
|
|
11
|
+
scroller: HTMLDivElement | undefined,
|
|
12
|
+
cols: HTMLDivElement | undefined,
|
|
13
|
+
widths: { value: number[] },
|
|
14
|
+
) {
|
|
15
|
+
const s = scroller,
|
|
16
|
+
box = cols
|
|
17
|
+
if (!s || !box || untrack(() => c.drag.value || c.moving.value)) return
|
|
18
|
+
const scrolled = s.scrollTop / Math.max(1, box.offsetHeight)
|
|
19
|
+
for (const v of ['--_tracks', '--_week-w', '--veneer-cal-hour']) s.style.removeProperty(v)
|
|
20
|
+
const gutter = box.querySelector<HTMLElement>('[data-part="gutter"]')?.offsetWidth ?? 52
|
|
21
|
+
const floor = parseFloat(getComputedStyle(s).getPropertyValue('--veneer-cal-day-min')) || 128
|
|
22
|
+
const need = [...box.querySelectorAll<HTMLElement>(':scope > [data-part="col"]')].map((col) =>
|
|
23
|
+
Math.max(
|
|
24
|
+
DAY_FIT,
|
|
25
|
+
...[...col.querySelectorAll<HTMLElement>(':scope > [data-part="event"]')].map((ev) => {
|
|
26
|
+
const title = ev.querySelector<HTMLElement>('[data-part="event-title"]')
|
|
27
|
+
if (!title) return 0
|
|
28
|
+
const probe = title.cloneNode(true) as HTMLElement
|
|
29
|
+
probe.style.cssText = `position:absolute;visibility:hidden;inline-size:${ev.hasAttribute('data-short') ? 'max-content' : 'min-content'}`
|
|
30
|
+
ev.append(probe)
|
|
31
|
+
const word = probe.getBoundingClientRect().width
|
|
32
|
+
probe.remove()
|
|
33
|
+
const cs = getComputedStyle(ev)
|
|
34
|
+
const lanes =
|
|
35
|
+
(+ev.style.getPropertyValue('--_cols') || 1) /
|
|
36
|
+
(+ev.style.getPropertyValue('--_span') || 1)
|
|
37
|
+
// an event is (day - 6px) / lanes - 2px wide (calendar.css)
|
|
38
|
+
return Math.ceil(
|
|
39
|
+
(word + parseFloat(cs.paddingInlineStart) + parseFloat(cs.paddingInlineEnd) + 2) * lanes +
|
|
40
|
+
6 +
|
|
41
|
+
0.5,
|
|
42
|
+
)
|
|
43
|
+
}),
|
|
44
|
+
),
|
|
45
|
+
)
|
|
46
|
+
// an all-day event's longest word, shared by the days it spans
|
|
47
|
+
for (const chip of s.querySelectorAll<HTMLElement>('[data-part="allday"] > [data-part="chip"]')) {
|
|
48
|
+
const [, col, span] = /(\d+)\s*\/\s*span\s+(\d+)/.exec(chip.style.gridColumn) ?? []
|
|
49
|
+
if (!col || !span) continue
|
|
50
|
+
const probe = chip.cloneNode(true) as HTMLElement
|
|
51
|
+
probe.style.cssText = 'position:absolute;visibility:hidden;inline-size:min-content'
|
|
52
|
+
chip.parentElement!.append(probe)
|
|
53
|
+
const each = Math.ceil(probe.getBoundingClientRect().width / +span)
|
|
54
|
+
probe.remove()
|
|
55
|
+
for (let i = +col - 2; i < +col - 2 + +span && i < need.length; i++)
|
|
56
|
+
need[i] = Math.max(need[i] ?? 0, each)
|
|
57
|
+
}
|
|
58
|
+
const room = s.clientWidth - gutter
|
|
59
|
+
const fits = need.reduce((a, b) => a + b, 0) <= room
|
|
60
|
+
const f = untrack(() => widths.value)
|
|
61
|
+
const least = need.map((n, i) => (fits ? n : Math.max(n, Math.ceil(floor * (f[i] ?? 1)))))
|
|
62
|
+
s.style.setProperty(
|
|
63
|
+
'--_tracks',
|
|
64
|
+
`${gutter}px ${least.map((n) => `minmax(${n}px, 1fr)`).join(' ')}`,
|
|
65
|
+
)
|
|
66
|
+
s.style.setProperty('--_week-w', fits ? '0px' : `${gutter + least.reduce((a, b) => a + b, 0)}px`)
|
|
67
|
+
const doc = s.ownerDocument
|
|
68
|
+
const cut = () =>
|
|
69
|
+
[
|
|
70
|
+
...box.querySelectorAll<HTMLElement>(
|
|
71
|
+
'[data-part="col"] > [data-part="event"] [data-part="event-title"]',
|
|
72
|
+
),
|
|
73
|
+
].some((t) => {
|
|
74
|
+
const r = doc.createRange()
|
|
75
|
+
r.selectNodeContents(t)
|
|
76
|
+
const w = r.getBoundingClientRect(),
|
|
77
|
+
b = t.closest('[data-part="event"]')!.getBoundingClientRect()
|
|
78
|
+
return w.width > 0 && (w.bottom > b.bottom + 0.5 || w.right > b.right + 0.5)
|
|
79
|
+
})
|
|
80
|
+
const base = box.offsetHeight / 24
|
|
81
|
+
for (let hour = base, i = 0; i < 40 && hour < base * 3 && cut(); i++)
|
|
82
|
+
s.style.setProperty('--veneer-cal-hour', `${(hour += 4)}px`)
|
|
83
|
+
s.scrollTop = scrolled * box.offsetHeight
|
|
84
|
+
}
|