@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.
Files changed (389) hide show
  1. package/LICENSE +16 -0
  2. package/README.md +1338 -2
  3. package/package.json +56 -3
  4. package/plugin.d.mts +187 -0
  5. package/plugin.mjs +399 -0
  6. package/src/Accordion.tsx +98 -0
  7. package/src/Alert.tsx +55 -0
  8. package/src/Badge.tsx +39 -0
  9. package/src/Button.tsx +175 -0
  10. package/src/Calendar-month.tsx +140 -0
  11. package/src/Calendar.tsx +335 -0
  12. package/src/Canvas.tsx +221 -0
  13. package/src/Card.tsx +85 -0
  14. package/src/Chart.tsx +278 -0
  15. package/src/Charts.tsx +158 -0
  16. package/src/Chip.tsx +61 -0
  17. package/src/Choice-checkbox.tsx +53 -0
  18. package/src/Choice-parts.tsx +7 -0
  19. package/src/Choice-radio.tsx +78 -0
  20. package/src/Choice-segmented.tsx +76 -0
  21. package/src/Choice-switch.tsx +51 -0
  22. package/src/Choice.tsx +4 -0
  23. package/src/CloseX.tsx +14 -0
  24. package/src/CodeBlock.tsx +81 -0
  25. package/src/CodeInput.tsx +256 -0
  26. package/src/Combobox.tsx +281 -0
  27. package/src/CommandPalette-controller.ts +314 -0
  28. package/src/CommandPalette-rows.tsx +137 -0
  29. package/src/CommandPalette.tsx +196 -0
  30. package/src/DataGrid-actions.ts +119 -0
  31. package/src/DataGrid-body.tsx +58 -0
  32. package/src/DataGrid-controller.ts +145 -0
  33. package/src/DataGrid-header.tsx +108 -0
  34. package/src/DataGrid-model.ts +248 -0
  35. package/src/DataGrid-pivot.tsx +108 -0
  36. package/src/DataGrid-rows.tsx +296 -0
  37. package/src/DataGrid-toolbar.tsx +127 -0
  38. package/src/DataGrid-tree.ts +149 -0
  39. package/src/DataGrid-viewport.tsx +37 -0
  40. package/src/DataGrid.tsx +145 -0
  41. package/src/DateField-presets.tsx +27 -0
  42. package/src/DateField-range.tsx +370 -0
  43. package/src/DateField.tsx +295 -0
  44. package/src/Dither.tsx +313 -0
  45. package/src/Drawer.tsx +123 -0
  46. package/src/DurationField.tsx +227 -0
  47. package/src/Feed.tsx +78 -0
  48. package/src/Field/view.tsx +147 -0
  49. package/src/Field.tsx +238 -0
  50. package/src/HamburgerMenu.tsx +119 -0
  51. package/src/Icon.tsx +15 -0
  52. package/src/Kbd.tsx +6 -0
  53. package/src/KeyValueEditor/actions.ts +75 -0
  54. package/src/KeyValueEditor/rows.tsx +104 -0
  55. package/src/KeyValueEditor.tsx +112 -0
  56. package/src/Layout.tsx +221 -0
  57. package/src/Markdown.tsx +127 -0
  58. package/src/MentionsInput/actions.ts +161 -0
  59. package/src/MentionsInput/end.tsx +82 -0
  60. package/src/MentionsInput.tsx +103 -0
  61. package/src/Menu.tsx +221 -0
  62. package/src/Modal.tsx +109 -0
  63. package/src/MonthPicker/month.tsx +117 -0
  64. package/src/MonthPicker/period.tsx +197 -0
  65. package/src/MonthPicker/shared.tsx +272 -0
  66. package/src/MonthPicker/week.tsx +103 -0
  67. package/src/MonthPicker.tsx +11 -0
  68. package/src/MultiSelect.tsx +139 -0
  69. package/src/Nav.tsx +36 -0
  70. package/src/NumberField.tsx +156 -0
  71. package/src/Pagination.tsx +335 -0
  72. package/src/PaymentCard.tsx +111 -0
  73. package/src/Picker.tsx +228 -0
  74. package/src/PlaceField.tsx +285 -0
  75. package/src/Popover.tsx +88 -0
  76. package/src/Presence.tsx +37 -0
  77. package/src/Progress.tsx +71 -0
  78. package/src/RecurrenceField.tsx +372 -0
  79. package/src/RichSelect/codes.tsx +94 -0
  80. package/src/RichSelect/list.tsx +380 -0
  81. package/src/RichSelect/phone-view.tsx +114 -0
  82. package/src/RichSelect/phone.tsx +305 -0
  83. package/src/RichSelect/search-keys.ts +28 -0
  84. package/src/RichSelect/timezone.tsx +53 -0
  85. package/src/RichSelect.tsx +13 -0
  86. package/src/RichTextEditor/controller.tsx +305 -0
  87. package/src/RichTextEditor/editor.tsx +61 -0
  88. package/src/RichTextEditor/tools.tsx +132 -0
  89. package/src/RichTextEditor/view.tsx +210 -0
  90. package/src/RichTextEditor.tsx +9 -0
  91. package/src/ScrollGrid/measure.ts +39 -0
  92. package/src/ScrollGrid/parts.tsx +112 -0
  93. package/src/ScrollGrid.tsx +375 -0
  94. package/src/ScrollRail.tsx +114 -0
  95. package/src/ScrollView.tsx +57 -0
  96. package/src/Segments/controller.tsx +148 -0
  97. package/src/Segments/events.ts +99 -0
  98. package/src/Segments/view.tsx +77 -0
  99. package/src/Segments.tsx +2 -0
  100. package/src/Select.tsx +343 -0
  101. package/src/Shape.tsx +41 -0
  102. package/src/Shell/branches.tsx +108 -0
  103. package/src/Shell/button.tsx +33 -0
  104. package/src/Shell/shared.tsx +220 -0
  105. package/src/Shell/shell.tsx +25 -0
  106. package/src/Shell/state.ts +138 -0
  107. package/src/Shell/view.tsx +280 -0
  108. package/src/Shell.tsx +17 -0
  109. package/src/SideNav/sections.tsx +50 -0
  110. package/src/SideNav/state.ts +140 -0
  111. package/src/SideNav.tsx +130 -0
  112. package/src/SideNavTitle.tsx +25 -0
  113. package/src/SignaturePad/state.ts +172 -0
  114. package/src/SignaturePad/view.tsx +69 -0
  115. package/src/SignaturePad.tsx +76 -0
  116. package/src/Skeleton.tsx +46 -0
  117. package/src/Slider.tsx +81 -0
  118. package/src/Spinner.tsx +21 -0
  119. package/src/Stage-director.ts +361 -0
  120. package/src/Stage-look.ts +75 -0
  121. package/src/Stage-poster.tsx +62 -0
  122. package/src/Stage-types.ts +206 -0
  123. package/src/Stage.tsx +147 -0
  124. package/src/TabBar.tsx +114 -0
  125. package/src/Table-actions.tsx +51 -0
  126. package/src/Table-base.ts +70 -0
  127. package/src/Table-body.tsx +84 -0
  128. package/src/Table-columns.tsx +58 -0
  129. package/src/Table-details.tsx +66 -0
  130. package/src/Table-editor.tsx +66 -0
  131. package/src/Table-head.tsx +52 -0
  132. package/src/Table-model.ts +82 -0
  133. package/src/Table-notice.ts +39 -0
  134. package/src/Table-paging.ts +50 -0
  135. package/src/Table-rows.tsx +308 -0
  136. package/src/Table-selection.ts +63 -0
  137. package/src/Table-sortbar.tsx +41 -0
  138. package/src/Table-source.ts +66 -0
  139. package/src/Table-toolbar.tsx +71 -0
  140. package/src/Table-types.ts +115 -0
  141. package/src/Table-view.tsx +87 -0
  142. package/src/Table.tsx +31 -0
  143. package/src/Tabs.tsx +129 -0
  144. package/src/Tag.tsx +40 -0
  145. package/src/Ticker.tsx +42 -0
  146. package/src/TimeField-date-model.ts +77 -0
  147. package/src/TimeField-date-view.tsx +152 -0
  148. package/src/TimeField-model.ts +80 -0
  149. package/src/TimeField-options.tsx +224 -0
  150. package/src/TimeField-slots.tsx +32 -0
  151. package/src/TimeField-types.ts +33 -0
  152. package/src/TimeField-view.tsx +124 -0
  153. package/src/TimeField.tsx +126 -0
  154. package/src/Toast.tsx +143 -0
  155. package/src/Toggle.tsx +75 -0
  156. package/src/Tooltip.tsx +69 -0
  157. package/src/Type.tsx +136 -0
  158. package/src/VirtualList-controls.ts +105 -0
  159. package/src/VirtualList-data.ts +43 -0
  160. package/src/VirtualList-measure.ts +169 -0
  161. package/src/VirtualList-metrics.ts +41 -0
  162. package/src/VirtualList-mount.ts +145 -0
  163. package/src/VirtualList-rows.tsx +91 -0
  164. package/src/VirtualList-types.ts +76 -0
  165. package/src/VirtualList-view.tsx +123 -0
  166. package/src/VirtualList.tsx +81 -0
  167. package/src/admin/ApiKeys-actions.ts +124 -0
  168. package/src/admin/ApiKeys-form.tsx +64 -0
  169. package/src/admin/ApiKeys-view.tsx +101 -0
  170. package/src/admin/ApiKeys.tsx +224 -0
  171. package/src/admin/Audit.tsx +246 -0
  172. package/src/admin/Billing.tsx +307 -0
  173. package/src/admin/Cart.tsx +177 -0
  174. package/src/admin/Checkout-address.tsx +125 -0
  175. package/src/admin/Checkout-cart.tsx +78 -0
  176. package/src/admin/Checkout-coupon.ts +34 -0
  177. package/src/admin/Checkout-done.tsx +31 -0
  178. package/src/admin/Checkout-model.ts +33 -0
  179. package/src/admin/Checkout-navigation.ts +76 -0
  180. package/src/admin/Checkout-payment-view.tsx +49 -0
  181. package/src/admin/Checkout-payment.ts +80 -0
  182. package/src/admin/Checkout-review.tsx +60 -0
  183. package/src/admin/Checkout-shipping.tsx +47 -0
  184. package/src/admin/Checkout-state.ts +122 -0
  185. package/src/admin/Checkout-steps.ts +10 -0
  186. package/src/admin/Checkout-summary.tsx +97 -0
  187. package/src/admin/Checkout-types.ts +60 -0
  188. package/src/admin/Checkout-view.tsx +51 -0
  189. package/src/admin/Checkout.tsx +72 -0
  190. package/src/admin/CsvImport-actions.ts +131 -0
  191. package/src/admin/CsvImport.tsx +379 -0
  192. package/src/admin/Danger.tsx +240 -0
  193. package/src/admin/Integrations/Card.tsx +82 -0
  194. package/src/admin/Integrations/Webhooks.tsx +341 -0
  195. package/src/admin/Integrations.tsx +169 -0
  196. package/src/admin/InviteDialog.tsx +153 -0
  197. package/src/admin/Members/columns.tsx +181 -0
  198. package/src/admin/Members.tsx +316 -0
  199. package/src/admin/Order.tsx +115 -0
  200. package/src/admin/PlainTable.tsx +34 -0
  201. package/src/admin/Plans.tsx +375 -0
  202. package/src/admin/SaveBar/actions.ts +86 -0
  203. package/src/admin/SaveBar.tsx +153 -0
  204. package/src/admin/Secret.tsx +74 -0
  205. package/src/admin/Settings.tsx +145 -0
  206. package/src/admin/StepBar.tsx +66 -0
  207. package/src/admin/TagsInput/actions.ts +60 -0
  208. package/src/admin/TagsInput.tsx +95 -0
  209. package/src/admin/atoms.tsx +73 -0
  210. package/src/admin/index.ts +67 -0
  211. package/src/agent/Actions/reasons.tsx +38 -0
  212. package/src/agent/Actions.tsx +166 -0
  213. package/src/agent/AgentPlan.tsx +86 -0
  214. package/src/agent/ArtifactPanel.tsx +299 -0
  215. package/src/agent/Assistant.tsx +168 -0
  216. package/src/agent/Checkpoint.tsx +19 -0
  217. package/src/agent/Cite.tsx +70 -0
  218. package/src/agent/ContextMeter.tsx +70 -0
  219. package/src/agent/Conversation.tsx +70 -0
  220. package/src/agent/Message.tsx +92 -0
  221. package/src/agent/ModelPicker.tsx +167 -0
  222. package/src/agent/Prompt-model.ts +118 -0
  223. package/src/agent/Prompt-view.tsx +246 -0
  224. package/src/agent/Prompt.tsx +128 -0
  225. package/src/agent/Prose.tsx +118 -0
  226. package/src/agent/Question.tsx +137 -0
  227. package/src/agent/Reasoning.tsx +31 -0
  228. package/src/agent/Shimmer.tsx +11 -0
  229. package/src/agent/Sources.tsx +23 -0
  230. package/src/agent/SpeechInput.tsx +243 -0
  231. package/src/agent/Suggestions.tsx +36 -0
  232. package/src/agent/ToolCall.tsx +219 -0
  233. package/src/agent/TraceViewer.tsx +96 -0
  234. package/src/agent/bits.tsx +88 -0
  235. package/src/agent/index.ts +38 -0
  236. package/src/bind.ts +57 -0
  237. package/src/collab/AutoTrack.tsx +91 -0
  238. package/src/collab/Comments.tsx +204 -0
  239. package/src/collab/Composer/state.ts +125 -0
  240. package/src/collab/Composer/view.tsx +155 -0
  241. package/src/collab/Composer.tsx +141 -0
  242. package/src/collab/ConversationList.tsx +120 -0
  243. package/src/collab/Cursors.tsx +71 -0
  244. package/src/collab/DataIntegrity.tsx +103 -0
  245. package/src/collab/Kanban-card.ts +74 -0
  246. package/src/collab/Kanban.tsx +368 -0
  247. package/src/collab/Lock.tsx +36 -0
  248. package/src/collab/PresenceStack.tsx +176 -0
  249. package/src/collab/ShareDialog.tsx +273 -0
  250. package/src/collab/Status.tsx +101 -0
  251. package/src/collab/SyncedForm.tsx +42 -0
  252. package/src/collab/Thread/Message.tsx +265 -0
  253. package/src/collab/Thread/rows.tsx +56 -0
  254. package/src/collab/Thread.tsx +323 -0
  255. package/src/collab/VersionHistory.tsx +173 -0
  256. package/src/collab/ViewportRail.tsx +73 -0
  257. package/src/collab/index.ts +37 -0
  258. package/src/collab/peer.tsx +42 -0
  259. package/src/fields.ts +5 -0
  260. package/src/flow/AuthScreen.tsx +81 -0
  261. package/src/flow/AuthSteps.tsx +296 -0
  262. package/src/flow/Checklist.tsx +211 -0
  263. package/src/flow/ConnBanner.tsx +304 -0
  264. package/src/flow/Flow.tsx +97 -0
  265. package/src/flow/MfaSetup.tsx +244 -0
  266. package/src/flow/Otp.tsx +243 -0
  267. package/src/flow/ReauthDialog.tsx +79 -0
  268. package/src/flow/ShortcutsOverlay.tsx +121 -0
  269. package/src/flow/SignGate.tsx +184 -0
  270. package/src/flow/SignIn.tsx +136 -0
  271. package/src/flow/SignUp.tsx +149 -0
  272. package/src/flow/Sso.tsx +96 -0
  273. package/src/flow/SystemPage/accounts.tsx +74 -0
  274. package/src/flow/SystemPage/art.tsx +113 -0
  275. package/src/flow/SystemPage.tsx +395 -0
  276. package/src/flow/Tour.tsx +207 -0
  277. package/src/flow/index.ts +29 -0
  278. package/src/flow/kit.tsx +334 -0
  279. package/src/index.ts +237 -0
  280. package/src/layout.css +4 -0
  281. package/src/links.css +4 -0
  282. package/src/live/ActivityFeed.tsx +88 -0
  283. package/src/live/Bell.tsx +108 -0
  284. package/src/live/Connection.tsx +113 -0
  285. package/src/live/Inbox.tsx +113 -0
  286. package/src/live/InboxFeed.tsx +67 -0
  287. package/src/live/InboxGestures.ts +41 -0
  288. package/src/live/InboxHandlers.ts +102 -0
  289. package/src/live/InboxHeader.tsx +81 -0
  290. package/src/live/InboxModel.ts +81 -0
  291. package/src/live/InboxRow.tsx +125 -0
  292. package/src/live/MeetingRoom.tsx +22 -0
  293. package/src/live/MeetingRoomControlBar.tsx +197 -0
  294. package/src/live/MeetingRoomHandlers.ts +53 -0
  295. package/src/live/MeetingRoomLayout.tsx +27 -0
  296. package/src/live/MeetingRoomModel.ts +49 -0
  297. package/src/live/MeetingRoomMount.ts +49 -0
  298. package/src/live/MeetingRoomParts.tsx +178 -0
  299. package/src/live/MeetingRoomPerson.tsx +21 -0
  300. package/src/live/MeetingRoomState.ts +88 -0
  301. package/src/live/MeetingRoomTile.tsx +84 -0
  302. package/src/live/MeetingRoomTypes.ts +68 -0
  303. package/src/live/MeetingRoomView.tsx +36 -0
  304. package/src/live/NotificationPreferences.tsx +99 -0
  305. package/src/live/NotificationPreferencesActions.ts +55 -0
  306. package/src/live/NotificationPreferencesCell.tsx +26 -0
  307. package/src/live/NotificationPreferencesCells.tsx +59 -0
  308. package/src/live/NotificationPreferencesGrid.tsx +129 -0
  309. package/src/live/NotificationPreferencesModel.tsx +91 -0
  310. package/src/live/NotificationPreferencesSave.ts +85 -0
  311. package/src/live/NotificationPreferencesWatch.ts +31 -0
  312. package/src/live/Prejoin.tsx +238 -0
  313. package/src/live/PrejoinMeter.tsx +26 -0
  314. package/src/live/PrejoinPreview.tsx +53 -0
  315. package/src/live/PushSoftAsk.tsx +63 -0
  316. package/src/live/TransportPicker.tsx +341 -0
  317. package/src/live/TransportPickerDetails.tsx +130 -0
  318. package/src/live/index.ts +31 -0
  319. package/src/live/notify.tsx +22 -0
  320. package/src/live/shared.tsx +110 -0
  321. package/src/parts.tsx +199 -0
  322. package/src/plugin/catalog.mjs +129 -0
  323. package/src/plugin/dtcg.mjs +79 -0
  324. package/src/plugin/icons.mjs +7 -0
  325. package/src/plugin/seed.mjs +40 -0
  326. package/src/plugin/theme-context.mjs +44 -0
  327. package/src/plugin/theme-css.mjs +143 -0
  328. package/src/plugin/theme-motion.mjs +43 -0
  329. package/src/plugin/theme-parts.d.mts +41 -0
  330. package/src/plugin/theme-parts.mjs +224 -0
  331. package/src/plugin/theme-text.mjs +93 -0
  332. package/src/plugin/theme-values.mjs +15 -0
  333. package/src/plugin/theme.d.mts +82 -0
  334. package/src/plugin/theme.mjs +316 -0
  335. package/src/schedule/Agenda.tsx +124 -0
  336. package/src/schedule/AgendaActions.ts +31 -0
  337. package/src/schedule/AgendaDay.tsx +124 -0
  338. package/src/schedule/AgendaGestures.ts +27 -0
  339. package/src/schedule/AgendaKeys.ts +52 -0
  340. package/src/schedule/AgendaModel.ts +82 -0
  341. package/src/schedule/AgendaNavigation.ts +38 -0
  342. package/src/schedule/AgendaPage.tsx +39 -0
  343. package/src/schedule/AgendaStrip.tsx +55 -0
  344. package/src/schedule/AvailabilityEditor-actions.ts +146 -0
  345. package/src/schedule/AvailabilityEditor-day.tsx +119 -0
  346. package/src/schedule/AvailabilityEditor-view.tsx +205 -0
  347. package/src/schedule/AvailabilityEditor.tsx +113 -0
  348. package/src/schedule/BookingCalendar.tsx +121 -0
  349. package/src/schedule/BookingCalendarActions.ts +85 -0
  350. package/src/schedule/BookingCalendarModel.ts +86 -0
  351. package/src/schedule/BookingCalendarParts.tsx +87 -0
  352. package/src/schedule/Calendar/AgendaView.tsx +45 -0
  353. package/src/schedule/Calendar/CalendarDialogs.tsx +105 -0
  354. package/src/schedule/Calendar/CalendarMain.tsx +47 -0
  355. package/src/schedule/Calendar/CalendarToolbar.tsx +106 -0
  356. package/src/schedule/Calendar/Column.tsx +129 -0
  357. package/src/schedule/Calendar/EventBlock.tsx +71 -0
  358. package/src/schedule/Calendar/MiniMonth.tsx +169 -0
  359. package/src/schedule/Calendar/MonthGrid.tsx +296 -0
  360. package/src/schedule/Calendar/TimeGrid.tsx +252 -0
  361. package/src/schedule/Calendar/Timeline.tsx +287 -0
  362. package/src/schedule/Calendar/ZoneChip.tsx +73 -0
  363. package/src/schedule/Calendar/calendar-shell.ts +160 -0
  364. package/src/schedule/Calendar/calendar-state.ts +30 -0
  365. package/src/schedule/Calendar/now-spans.tsx +33 -0
  366. package/src/schedule/Calendar/shared.ts +3 -0
  367. package/src/schedule/Calendar/state-actions.ts +189 -0
  368. package/src/schedule/Calendar/state-base.ts +143 -0
  369. package/src/schedule/Calendar/state-keys.ts +128 -0
  370. package/src/schedule/Calendar/time-fit.ts +84 -0
  371. package/src/schedule/Calendar.tsx +182 -0
  372. package/src/schedule/EventEditor.tsx +267 -0
  373. package/src/schedule/EventPopover.tsx +190 -0
  374. package/src/schedule/MeetingPlanner-model.ts +222 -0
  375. package/src/schedule/MeetingPlanner-view.tsx +310 -0
  376. package/src/schedule/MeetingPlanner.tsx +122 -0
  377. package/src/schedule/MoveSheet.tsx +168 -0
  378. package/src/schedule/YearView-model.ts +164 -0
  379. package/src/schedule/YearView-parts.tsx +147 -0
  380. package/src/schedule/YearView.tsx +100 -0
  381. package/src/schedule/bits.tsx +65 -0
  382. package/src/schedule/index.ts +25 -0
  383. package/src/skeleton-css.ts +4 -0
  384. package/src/styles.ts +13 -0
  385. package/src/type.css +15 -0
  386. package/src/ui.ts +41 -0
  387. package/src/use-ui.ts +10 -0
  388. package/tailwind.css +38 -0
  389. package/tokens/color.mjs +87 -0
@@ -0,0 +1,222 @@
1
+ import {
2
+ clock,
3
+ clockRange,
4
+ fmt,
5
+ minutes,
6
+ sharedFree,
7
+ suggestSlots,
8
+ withinHours,
9
+ zoneCity,
10
+ zoneMinute,
11
+ type Attendee,
12
+ type IsoTime,
13
+ } from '@kerf-js/veneer-core'
14
+ import { derived, flush, state, untrack, watch, type State } from '@kerf-js/core'
15
+ import type { MeetingPlannerProps } from './MeetingPlanner'
16
+ import { confirmSweep } from './bits'
17
+
18
+ type Env = { locale: State<string> }
19
+
20
+ export function plannerInputs(p: MeetingPlannerProps, env: Env) {
21
+ const people = state<Attendee[]>(untrack(() => p.attendees ?? []))
22
+ const len = state(untrack(() => p.duration ?? 30))
23
+ const lens = derived(() =>
24
+ (p.durations ?? [15, 30, 45, 60]).map((m) => ({ value: String(m), label: `${m} min` })),
25
+ )
26
+ const title = state(untrack(() => p.title ?? ''))
27
+ const link = state(untrack(() => p.link ?? ''))
28
+ const query = state('')
29
+ const manual = state(false)
30
+ const typed = state<IsoTime | null>(null)
31
+ const sent = state(false)
32
+ const busy = state(false)
33
+ const failed = state<string | null>(null)
34
+ const remote = state<number[] | null>(null)
35
+ const from = derived(() => p.from ?? 480)
36
+ const to = derived(() => p.to ?? 1080)
37
+ const width = derived(() => to.value - from.value)
38
+ const ticks = derived(() =>
39
+ Array.from({ length: Math.round(width.value / 60) }, (_, i) => from.value + i * 60),
40
+ )
41
+ const busyLists = derived(() => people.value.map((a) => a.busy ?? []))
42
+ const slots = derived(
43
+ () =>
44
+ remote.value ??
45
+ suggestSlots(people.value, p.date, {
46
+ len: len.value,
47
+ from: from.value,
48
+ to: to.value,
49
+ zone: p.timeZone,
50
+ }),
51
+ )
52
+ const shared = derived(() => sharedFree(busyLists.value, from.value, to.value))
53
+ const pick = state<number | null>(null)
54
+ const chosen = derived(() =>
55
+ manual.value
56
+ ? typed.value
57
+ ? minutes(typed.value)
58
+ : null
59
+ : pick.value !== null && slots.value.includes(pick.value)
60
+ ? pick.value
61
+ : (slots.value[0] ?? null),
62
+ )
63
+ const time = (m: number) => clock(m, env.locale.value, p.hourCycle)
64
+ const span = (a: number, b: number) => clockRange(a, b, env.locale.value, p.hourCycle)
65
+ const left = (m: number) => ((m - from.value) / width.value) * 100
66
+ const size = (m: number) => (m / width.value) * 100
67
+ return {
68
+ people,
69
+ len,
70
+ lens,
71
+ title,
72
+ link,
73
+ query,
74
+ manual,
75
+ typed,
76
+ sent,
77
+ busy,
78
+ failed,
79
+ remote,
80
+ ticks,
81
+ slots,
82
+ shared,
83
+ pick,
84
+ chosen,
85
+ time,
86
+ span,
87
+ left,
88
+ size,
89
+ }
90
+ }
91
+
92
+ type Inputs = ReturnType<typeof plannerInputs>
93
+
94
+ export function watchSlots(p: MeetingPlannerProps, { people, len, remote }: Inputs) {
95
+ watch(
96
+ () => [people.value, len.value] as const,
97
+ ([a, l]) => {
98
+ if (!p.loadSlots) return
99
+ const r = p.loadSlots({ attendees: a, date: p.date, duration: l })
100
+ if (Array.isArray(r)) remote.value = r
101
+ else void r.then((v) => (remote.value = v))
102
+ },
103
+ )
104
+ }
105
+
106
+ export function plannerComputed(
107
+ p: MeetingPlannerProps,
108
+ env: Env,
109
+ { chosen, people, len, span, time }: Inputs,
110
+ ) {
111
+ const fit = derived(() => {
112
+ const s = chosen.value
113
+ return s === null ? 0 : withinHours(people.value, p.date, s, len.value, p.timeZone)
114
+ })
115
+ const elsewhere = derived(() => {
116
+ const s = chosen.value
117
+ if (s === null) return []
118
+ return [...new Set(people.value.map((a) => a.zone).filter((z) => z && z !== p.timeZone))]
119
+ .slice(0, 2)
120
+ .map((z) => `${zoneCity(z!)} ${time(zoneMinute(p.date, s, p.timeZone, z))}`)
121
+ })
122
+ const summary = derived(() =>
123
+ chosen.value === null
124
+ ? 'No common time today'
125
+ : `${fmt(p.date, { weekday: 'short', month: 'short', day: 'numeric' }, env.locale.value)} · ${span(chosen.value, chosen.value + len.value)}`,
126
+ )
127
+ return { fit, elsewhere, summary }
128
+ }
129
+
130
+ type Computed = ReturnType<typeof plannerComputed>
131
+
132
+ type Context = Inputs &
133
+ Computed & {
134
+ p: MeetingPlannerProps
135
+ say: (message: string, loud?: boolean) => unknown
136
+ getRoot: () => HTMLDivElement | undefined
137
+ getGroup: () => HTMLDivElement | undefined
138
+ }
139
+
140
+ export function peopleActions({ people, query, slots, len, say }: Context) {
141
+ const add = (a: Attendee) => {
142
+ if (!people.value.some((x) => x.id === a.id)) people.value = [...people.value, a]
143
+ query.value = ''
144
+ say(`${a.name} added. ${slots.value.length} times work for everyone.`)
145
+ }
146
+ const drop = (a: Attendee) => {
147
+ people.value = people.value.filter((x) => x.id !== a.id)
148
+ say(`${a.name} removed`)
149
+ }
150
+ const setLen = (v: string) => {
151
+ len.value = +v
152
+ flush()
153
+ say(`${v} minutes. ${slots.value.length} times work for everyone.`)
154
+ }
155
+ return { add, drop, setLen }
156
+ }
157
+
158
+ export function radioAction({ slots, chosen, pick, getGroup }: Context) {
159
+ const onRadio = (e: KeyboardEvent) => {
160
+ const d = (
161
+ { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 } as Record<string, number>
162
+ )[e.key]
163
+ const list = slots.value
164
+ const i = list.indexOf(chosen.value!)
165
+ const n = d
166
+ ? (i + d + list.length) % list.length
167
+ : e.key === 'Home'
168
+ ? 0
169
+ : e.key === 'End'
170
+ ? list.length - 1
171
+ : -1
172
+ if (n < 0) return
173
+ e.preventDefault()
174
+ pick.value = list[n]!
175
+ flush()
176
+ getGroup()?.querySelector<HTMLElement>('[aria-checked="true"]')?.focus()
177
+ }
178
+ return onRadio
179
+ }
180
+
181
+ export function sendAction({
182
+ chosen,
183
+ busy,
184
+ failed,
185
+ p,
186
+ people,
187
+ title,
188
+ link,
189
+ len,
190
+ sent,
191
+ say,
192
+ summary,
193
+ getRoot,
194
+ }: Context) {
195
+ const send = async () => {
196
+ const s = chosen.value
197
+ if (s === null || busy.value) return
198
+ busy.value = true
199
+ failed.value = null
200
+ try {
201
+ await p.onSubmit({
202
+ attendees: people.value,
203
+ title: title.value,
204
+ link: link.value,
205
+ tags: p.tags ?? [],
206
+ date: p.date,
207
+ s,
208
+ e: s + len.value,
209
+ })
210
+ sent.value = true
211
+ say(`Invite sent for ${summary.value}`)
212
+ flush()
213
+ confirmSweep(getRoot()?.querySelector('[data-arrive]'))
214
+ } catch (err) {
215
+ failed.value = (err as Error | undefined)?.message ?? 'Try again.'
216
+ say(`Couldn't send the invite: ${failed.value}`, true)
217
+ } finally {
218
+ busy.value = false
219
+ }
220
+ }
221
+ return send
222
+ }
@@ -0,0 +1,310 @@
1
+ import { ClockIcon, SendIcon, XIcon } from '@kerf-js/veneer-icons'
2
+ import { asTime, fmt, zoneCity, type Attendee, type Range } from '@kerf-js/veneer-core'
3
+ import { untrack, type State } from '@kerf-js/core'
4
+ import { Badge } from '../Badge'
5
+ import { Button } from '../Button'
6
+ import { Card } from '../Card'
7
+ import { ComboField } from '../Combobox'
8
+ import { Input } from '../Field'
9
+ import { Avatar } from '../parts'
10
+ import { TimeField } from '../TimeField'
11
+ import { SweepParts } from './bits'
12
+ import type { MeetingPlannerProps } from './MeetingPlanner'
13
+ import type { plannerInputs, plannerComputed, peopleActions } from './MeetingPlanner-model'
14
+
15
+ type View = ReturnType<typeof plannerInputs> &
16
+ ReturnType<typeof plannerComputed> &
17
+ ReturnType<typeof peopleActions> & {
18
+ p: MeetingPlannerProps
19
+ id: string
20
+ env: { locale: State<string> }
21
+ setGroup: (el: HTMLDivElement) => void
22
+ onRadio: (event: KeyboardEvent) => void
23
+ send: () => Promise<void>
24
+ }
25
+
26
+ const BUSY_BAR =
27
+ 'position:absolute;inset-block:7px;border-radius:3px;background:color-mix(in oklab,var(--veneer-color-text) 22%,transparent)'
28
+ const FREE_BAR =
29
+ 'position:absolute;inset-block:6px;background:var(--veneer-color-positive-soft);border-block:1px solid var(--veneer-color-positive-border)'
30
+ const PICK_BAR =
31
+ 'position:absolute;inset-block:0;background:color-mix(in oklab,var(--veneer-color-sweep) 18%,transparent);border-inline:var(--veneer-border-emphasis) solid var(--veneer-color-sweep)'
32
+
33
+ function attendeesCard({ p, query, id, people, add, drop }: View) {
34
+ return (
35
+ <Card sweep={false}>
36
+ <div class="stack">
37
+ <h4 id={`${id}-att`}>
38
+ Attendees <span class="muted">{people.value.length}</span>
39
+ </h4>
40
+ {p.loadAttendees && (
41
+ <ComboField
42
+ label="Add people"
43
+ text={() => query.value}
44
+ onText={(t) => (query.value = t)}
45
+ find={p.loadAttendees}
46
+ row={(a: Attendee) => ({ main: a.name, sub: a.zone && zoneCity(a.zone) })}
47
+ onPick={add}
48
+ />
49
+ )}
50
+ <ul class="stack" aria-labelledby={`${id}-att`}>
51
+ {people.value.map((a) => (
52
+ <li key={a.id} class="row">
53
+ <Avatar name={a.name} size="sm" />
54
+ <span>
55
+ {a.name}
56
+ {a.organizer && <span class="muted"> (organizer)</span>}
57
+ </span>
58
+ <span style="flex:1"></span>
59
+ <span class="muted">{a.zone ? zoneCity(a.zone) : ''}</span>
60
+ {!a.organizer && (
61
+ <Button
62
+ emphasis="ghost"
63
+ tone="neutral"
64
+ size="sm"
65
+ icon={XIcon}
66
+ label={`Remove ${a.name}`}
67
+ onClick={() => drop(a)}
68
+ />
69
+ )}
70
+ </li>
71
+ ))}
72
+ </ul>
73
+ </div>
74
+ </Card>
75
+ )
76
+ }
77
+
78
+ function detailsCard({ title, link, p }: View) {
79
+ return (
80
+ <Card sweep={false}>
81
+ <div class="stack">
82
+ <h4>Details</h4>
83
+ <Input
84
+ label="Title"
85
+ value={title.value}
86
+ onInput={(e) => (title.value = e.currentTarget.value)}
87
+ />
88
+ <Input
89
+ label="Video link"
90
+ value={link.value}
91
+ onInput={(e) => (link.value = e.currentTarget.value)}
92
+ />
93
+ {p.tags && (
94
+ <div class="row">
95
+ {p.tags.map((t) => (
96
+ <Badge key={t} tone="neutral">
97
+ {t}
98
+ </Badge>
99
+ ))}
100
+ </div>
101
+ )}
102
+ </div>
103
+ </Card>
104
+ )
105
+ }
106
+
107
+ export function peopleLanes({ people, span, ticks, left, size, chosen, len }: View) {
108
+ return (
109
+ <>
110
+ {people.value.map((a) => (
111
+ <div key={a.id} role="row">
112
+ <div data-part="lane-label" role="rowheader">
113
+ <Avatar name={a.name} size="sm" />
114
+ <span>{a.name.split(' ')[0]}</span>
115
+ </div>
116
+ <div data-part="lane" role="cell" style={`--_slots:${ticks.value.length}`}>
117
+ <span class="sr">
118
+ {(a.busy ?? []).length
119
+ ? `Busy ${(a.busy as Range[]).map((r) => span(r[0], r[1])).join(', ')}`
120
+ : 'Free all day'}
121
+ </span>
122
+ {(a.busy ?? []).map((r) => (
123
+ <span
124
+ key={r[0]}
125
+ aria-hidden="true"
126
+ style={`${BUSY_BAR};inset-inline-start:${left(r[0])}%;inline-size:${size(r[1] - r[0])}%`}
127
+ ></span>
128
+ ))}
129
+ {chosen.value !== null && (
130
+ <span
131
+ aria-hidden="true"
132
+ style={`${PICK_BAR};inset-inline-start:${left(chosen.value)}%;inline-size:${size(len.value)}%`}
133
+ ></span>
134
+ )}
135
+ </div>
136
+ </div>
137
+ ))}
138
+ </>
139
+ )
140
+ }
141
+
142
+ export function TimelineCard({ view }: { view: View }) {
143
+ const src = untrack(() => view)
144
+ const { p, id, env, ticks, time, shared, span, left, size } = src
145
+ return (
146
+ <Card sweep={false}>
147
+ <div class="stack">
148
+ <h4 id={`${id}-grid`}>
149
+ {fmt(p.date, { weekday: 'long', month: 'short', day: 'numeric' }, env.locale.value)}{' '}
150
+ {p.timeZone && <span class="muted">· {zoneCity(p.timeZone)}</span>}
151
+ </h4>
152
+ <div data-scope="calendar">
153
+ <div data-part="timeline" role="table" aria-labelledby={`${id}-grid`}>
154
+ <span aria-hidden="true"></span>
155
+ <div
156
+ class="muted"
157
+ aria-hidden="true"
158
+ style={`display:grid;grid-template-columns:repeat(${ticks.value.length},1fr)`}
159
+ >
160
+ {ticks.value.map((m, n) => (
161
+ <span key={m}>{n % 2 ? '' : time(m)}</span>
162
+ ))}
163
+ </div>
164
+ {peopleLanes(src)}
165
+ <div role="row">
166
+ <div data-part="lane-label" role="rowheader">
167
+ Everyone
168
+ </div>
169
+ <div data-part="lane" role="cell" style={`--_slots:${ticks.value.length}`}>
170
+ <span class="sr">
171
+ Everyone free:{' '}
172
+ {shared.value.map((r) => span(r[0], r[1])).join(', ') || 'no shared time'}
173
+ </span>
174
+ {shared.value.map((r) => (
175
+ <span
176
+ key={r[0]}
177
+ aria-hidden="true"
178
+ style={`${FREE_BAR};inset-inline-start:${left(r[0])}%;inline-size:${size(r[1] - r[0])}%`}
179
+ ></span>
180
+ ))}
181
+ </div>
182
+ </div>
183
+ </div>
184
+ </div>
185
+ </div>
186
+ </Card>
187
+ )
188
+ }
189
+
190
+ export function sentView({ summary, people, p, sent }: View) {
191
+ return (
192
+ <div data-arrive="" data-sweep="" class="row" role="status">
193
+ <div>
194
+ <b>Invite sent · {summary.value}</b>
195
+ <p class="muted">
196
+ {people.value.length} people · added to your calendar · we'll tell you when they answer.
197
+ </p>
198
+ </div>
199
+ {p.onUndo && (
200
+ <Button
201
+ emphasis="ghost"
202
+ tone="neutral"
203
+ size="sm"
204
+ onClick={() => {
205
+ sent.value = false
206
+ p.onUndo?.()
207
+ }}
208
+ >
209
+ Undo
210
+ </Button>
211
+ )}
212
+ </div>
213
+ )
214
+ }
215
+
216
+ function slotPicker({ setGroup, id, onRadio, slots, chosen, pick, time }: View) {
217
+ return (
218
+ <div data-scope="booking" data-part="root">
219
+ <div
220
+ ref={(n) => setGroup(n)}
221
+ data-part="slots"
222
+ role="radiogroup"
223
+ aria-labelledby={`${id}-slots`}
224
+ onKeyDown={onRadio}
225
+ >
226
+ {slots.value.map((m) => (
227
+ <button
228
+ key={m}
229
+ type="button"
230
+ data-part="slot"
231
+ data-sweep=""
232
+ role="radio"
233
+ aria-checked={m === chosen.value ? 'true' : 'false'}
234
+ data-hold={m === chosen.value ? '' : undefined}
235
+ tabindex={m === chosen.value ? '0' : '-1'}
236
+ onClick={() => (pick.value = m)}
237
+ >
238
+ <SweepParts />
239
+ {time(m)}
240
+ </button>
241
+ ))}
242
+ </div>
243
+ </div>
244
+ )
245
+ }
246
+
247
+ export function inviteForm(view: View) {
248
+ const { id, slots, fit, people, failed, manual, typed, env } = view
249
+ const { summary, elsewhere, chosen, busy, send } = view
250
+ return (
251
+ <div class="stack">
252
+ <div class="row">
253
+ <h4 id={`${id}-slots`}>Suggested times</h4>
254
+ <span style="flex:1"></span>
255
+ <span class="muted">
256
+ {slots.value.length
257
+ ? `Everyone is free · within working hours for ${fit.value} of ${people.value.length}`
258
+ : 'No time works for everyone'}
259
+ </span>
260
+ </div>
261
+ {manual.value ? (
262
+ <TimeField label="Start" value={typed} locale={env.locale.value} hourCycle="h23" />
263
+ ) : (
264
+ slotPicker(view)
265
+ )}
266
+ <div class="row">
267
+ <span>
268
+ <b>{summary.value}</b>{' '}
269
+ {elsewhere.value.length > 0 && <span class="muted">· {elsewhere.value.join(' · ')}</span>}
270
+ </span>
271
+ <span style="flex:1"></span>
272
+ <Button
273
+ emphasis="outline"
274
+ tone="neutral"
275
+ size="sm"
276
+ icon={ClockIcon}
277
+ onClick={() => {
278
+ typed.value = chosen.value !== null ? asTime(chosen.value) : null
279
+ manual.value = !manual.value
280
+ }}
281
+ >
282
+ {manual.value ? 'Suggested times' : 'Pick manually'}
283
+ </Button>
284
+ <Button loading={busy.value} disabled={chosen.value === null} onClick={send}>
285
+ <SendIcon />
286
+ Send invite
287
+ </Button>
288
+ </div>
289
+ {failed.value && (
290
+ <p role="alert" class="muted">
291
+ Couldn't send the invite: {failed.value}
292
+ </p>
293
+ )}
294
+ </div>
295
+ )
296
+ }
297
+
298
+ export function InviteCard({ view }: { view: View }) {
299
+ const src = untrack(() => view)
300
+ const { sent } = src
301
+ return <Card sweep={false}>{sent.value ? sentView(src) : inviteForm(src)}</Card>
302
+ }
303
+
304
+ export function AttendeesCard({ view }: { view: View }) {
305
+ return attendeesCard(untrack(() => view))
306
+ }
307
+
308
+ export function DetailsCard({ view }: { view: View }) {
309
+ return detailsCard(untrack(() => view))
310
+ }
@@ -0,0 +1,122 @@
1
+ import { announce, uid, type Attendee } from '@kerf-js/veneer-core'
2
+ import { untrack } from '@kerf-js/core'
3
+ import { usePickerEnv } from '../Picker'
4
+ import { Segmented } from '../Choice'
5
+ import { AttendeesCard, DetailsCard, TimelineCard, InviteCard } from './MeetingPlanner-view'
6
+ import {
7
+ plannerInputs,
8
+ watchSlots,
9
+ plannerComputed,
10
+ peopleActions,
11
+ radioAction,
12
+ sendAction,
13
+ } from './MeetingPlanner-model'
14
+ import '@kerf-js/veneer-core/styles/app/booking.css'
15
+ import '@kerf-js/veneer-core/styles/app/calendar.css'
16
+
17
+ /** What the planner sends: who, when and about what. */
18
+ export type MeetingDetails = {
19
+ attendees: Attendee[]
20
+ title: string
21
+ link: string
22
+ tags: string[]
23
+ date: string
24
+ s: number
25
+ e: number
26
+ }
27
+ /** Props for MeetingPlanner. */
28
+ export type MeetingPlannerProps = {
29
+ date: string
30
+ attendees?: Attendee[] | undefined
31
+ /** Search for people to add. */
32
+ loadAttendees?: ((q: string, signal: AbortSignal) => Promise<Attendee[]>) | undefined
33
+ /** The app's own suggestions; else they come from everyone's `busy`. */
34
+ loadSlots?:
35
+ | ((input: {
36
+ attendees: Attendee[]
37
+ date: string
38
+ duration: number
39
+ }) => number[] | Promise<number[]>)
40
+ | undefined
41
+ /** The meeting's starting length, in minutes. Default 30. */
42
+ duration?: number | undefined
43
+ durations?: number[] | undefined
44
+ title?: string | undefined
45
+ /** The meeting link the form starts with, such as a video call URL. */
46
+ link?: string | undefined
47
+ tags?: string[] | undefined
48
+ /** The strip's hours, minutes since midnight. */
49
+ from?: number | undefined
50
+ /** Where the strip's hours end, in minutes since midnight. */
51
+ to?: number | undefined
52
+ /** The IANA zone times are shown in, such as `Europe/Berlin`. */
53
+ timeZone?: string | undefined
54
+ /** Pins today's date, for server rendering and tests. The browser's clock otherwise. */
55
+ today?: string | undefined
56
+ locale?: string | undefined
57
+ /** `h12` for AM and PM, `h23` for a 24-hour clock. The locale's otherwise. */
58
+ hourCycle?: string | undefined
59
+ onSubmit: (m: MeetingDetails) => void | Promise<unknown>
60
+ onUndo?: (() => void) | undefined
61
+ }
62
+
63
+ /**
64
+ * MeetingPlanner (07 §2.2, `#planner`): attendees, details, an availability table with an Everyone row, three suggested
65
+ * times as a radiogroup, a manual time, Send. Everything is drawn from `busy`, so it works from a query or a signal.
66
+ */
67
+ export function MeetingPlanner(p: MeetingPlannerProps) {
68
+ const id = uid('plan')
69
+ const env = usePickerEnv(
70
+ () => p.locale,
71
+ () => p.today,
72
+ )
73
+ const props = untrack(() => p)
74
+ const input = plannerInputs(props, env)
75
+ let root: HTMLDivElement | undefined
76
+ let group: HTMLDivElement | undefined
77
+ const say = (t: string, loud = false) => root && announce(root.ownerDocument, t, loud)
78
+ watchSlots(props, input)
79
+ const computed = plannerComputed(props, env, input)
80
+ const context = {
81
+ ...input,
82
+ ...computed,
83
+ p: props,
84
+ say,
85
+ getRoot: () => root,
86
+ getGroup: () => group,
87
+ }
88
+ const onRadio = radioAction(context)
89
+ const send = sendAction(context)
90
+ const view = {
91
+ ...context,
92
+ ...peopleActions(context),
93
+ id,
94
+ env,
95
+ onRadio,
96
+ send,
97
+ setGroup: (n: HTMLDivElement) => (group = n),
98
+ }
99
+ const { len, lens, setLen } = view
100
+ return (
101
+ <div ref={(n) => (root = n)} class="stack">
102
+ <div class="row">
103
+ <div>
104
+ <span data-part="eyebrow">MeetingPlanner</span>
105
+ <h3>Find a time</h3>
106
+ </div>
107
+ <span style="flex:1"></span>
108
+ <Segmented
109
+ label="Duration"
110
+ size="sm"
111
+ value={String(len.value)}
112
+ onChange={setLen}
113
+ options={lens.value}
114
+ />
115
+ </div>
116
+ <AttendeesCard view={view} />
117
+ <DetailsCard view={view} />
118
+ <TimelineCard view={view} />
119
+ <InviteCard view={view} />
120
+ </div>
121
+ )
122
+ }