@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,59 @@
|
|
|
1
|
+
import { triState, type PrefEvent, type PrefRules, type PrefValues } from '@kerf-js/veneer-core'
|
|
2
|
+
import { derived, type State } from '@kerf-js/core'
|
|
3
|
+
import { Checkbox } from '../Choice'
|
|
4
|
+
import type { preferencesSave } from './NotificationPreferencesSave'
|
|
5
|
+
|
|
6
|
+
export function preferencesCells({
|
|
7
|
+
model,
|
|
8
|
+
fixed,
|
|
9
|
+
parent,
|
|
10
|
+
onNa,
|
|
11
|
+
}: {
|
|
12
|
+
model: State<PrefValues>
|
|
13
|
+
fixed: PrefRules
|
|
14
|
+
parent: ReturnType<typeof preferencesSave>['parent']
|
|
15
|
+
onNa: (e: KeyboardEvent) => void
|
|
16
|
+
}) {
|
|
17
|
+
const parentBox = ({
|
|
18
|
+
evs,
|
|
19
|
+
c,
|
|
20
|
+
nameText,
|
|
21
|
+
visible,
|
|
22
|
+
where,
|
|
23
|
+
first,
|
|
24
|
+
}: {
|
|
25
|
+
evs: PrefEvent[]
|
|
26
|
+
c: string
|
|
27
|
+
nameText: string
|
|
28
|
+
visible: string
|
|
29
|
+
where: string | undefined
|
|
30
|
+
first: boolean
|
|
31
|
+
}) => {
|
|
32
|
+
const tri = derived(() => triState(model.value, evs, fixed, c))
|
|
33
|
+
return (
|
|
34
|
+
<Checkbox
|
|
35
|
+
checked={tri.value === 'on'}
|
|
36
|
+
indeterminate={tri.value === 'mixed'}
|
|
37
|
+
tabindex={first ? '0' : '-1'}
|
|
38
|
+
onChange={() => parent(evs, c, where)}
|
|
39
|
+
>
|
|
40
|
+
<span data-part="sr-only">{nameText}</span>
|
|
41
|
+
<span data-part="ch-name" aria-hidden="true">
|
|
42
|
+
{visible}
|
|
43
|
+
</span>
|
|
44
|
+
</Checkbox>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
const na = (text: string, chName?: string) => (
|
|
48
|
+
<span data-part="na" tabindex="-1" onKeyDown={onNa}>
|
|
49
|
+
<span aria-hidden="true">—</span>
|
|
50
|
+
<span data-part="sr-only">{text}</span>
|
|
51
|
+
{chName && (
|
|
52
|
+
<span data-part="ch-name" aria-hidden="true">
|
|
53
|
+
{chName}
|
|
54
|
+
</span>
|
|
55
|
+
)}
|
|
56
|
+
</span>
|
|
57
|
+
)
|
|
58
|
+
return { parentBox, na }
|
|
59
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { prefCell, triState, type PrefGroup, type PrefEvent } from '@kerf-js/veneer-core'
|
|
2
|
+
import { Badge } from '../Badge'
|
|
3
|
+
import { Checkbox } from '../Choice'
|
|
4
|
+
import { G } from './shared'
|
|
5
|
+
import { EventCell } from './NotificationPreferencesCell'
|
|
6
|
+
import type { PrefChannel } from './NotificationPreferences'
|
|
7
|
+
import type { preferencesModel } from './NotificationPreferencesModel'
|
|
8
|
+
|
|
9
|
+
const lower = (s: string) => (s === 'SMS' ? s : s.toLowerCase())
|
|
10
|
+
|
|
11
|
+
type Model = ReturnType<typeof preferencesModel>
|
|
12
|
+
|
|
13
|
+
export function PreferencesHead({ channels, state }: { channels: PrefChannel[]; state: Model }) {
|
|
14
|
+
return (
|
|
15
|
+
<div role="row" data-part="head">
|
|
16
|
+
<div role="columnheader" data-part="corner">
|
|
17
|
+
Event
|
|
18
|
+
</div>
|
|
19
|
+
{channels.map((c, i) => (
|
|
20
|
+
<div key={c.id} role="columnheader">
|
|
21
|
+
<span data-part="ch-head" aria-hidden="true">
|
|
22
|
+
{c.label}
|
|
23
|
+
</span>
|
|
24
|
+
{state.parentBox({
|
|
25
|
+
evs: state.events.value,
|
|
26
|
+
c: c.id,
|
|
27
|
+
nameText: `${c.label}, all events`,
|
|
28
|
+
visible: `All ${lower(c.label)}`,
|
|
29
|
+
where: undefined,
|
|
30
|
+
first: i === 0,
|
|
31
|
+
})}
|
|
32
|
+
</div>
|
|
33
|
+
))}
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function PreferencesGroup({
|
|
39
|
+
g,
|
|
40
|
+
channels,
|
|
41
|
+
state,
|
|
42
|
+
}: {
|
|
43
|
+
g: PrefGroup
|
|
44
|
+
channels: PrefChannel[]
|
|
45
|
+
state: Model
|
|
46
|
+
}) {
|
|
47
|
+
return (
|
|
48
|
+
<div role="rowgroup" data-part="rows">
|
|
49
|
+
<div role="row" data-part="group">
|
|
50
|
+
<div role="rowheader">{g.label}</div>
|
|
51
|
+
{channels.map((c) => (
|
|
52
|
+
<div key={c.id} role="gridcell">
|
|
53
|
+
{triState({}, g.events, state.fixed, c.id) === null
|
|
54
|
+
? state.na(`${g.label}, ${lower(c.label)}, not offered`)
|
|
55
|
+
: state.parentBox({
|
|
56
|
+
evs: g.events,
|
|
57
|
+
c: c.id,
|
|
58
|
+
nameText: `${g.label}, all ${lower(c.label)}`,
|
|
59
|
+
visible: c.label,
|
|
60
|
+
where: g.label,
|
|
61
|
+
first: false,
|
|
62
|
+
})}
|
|
63
|
+
</div>
|
|
64
|
+
))}
|
|
65
|
+
</div>
|
|
66
|
+
{g.events.map((e) => (
|
|
67
|
+
<PreferencesEvent key={e.id} e={e} channels={channels} state={state} />
|
|
68
|
+
))}
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function PreferencesEvent({
|
|
74
|
+
e,
|
|
75
|
+
channels,
|
|
76
|
+
state,
|
|
77
|
+
}: {
|
|
78
|
+
e: PrefEvent
|
|
79
|
+
channels: PrefChannel[]
|
|
80
|
+
state: Model
|
|
81
|
+
}) {
|
|
82
|
+
return (
|
|
83
|
+
<div role="row" data-row={e.id}>
|
|
84
|
+
<div role="rowheader">
|
|
85
|
+
<b>{e.label}</b>
|
|
86
|
+
{e.hint && <small>{e.hint}</small>}
|
|
87
|
+
{e.instant && (
|
|
88
|
+
<Badge tone="info" hidden={state.mail.value === 'instant' || !state.emailOn.value}>
|
|
89
|
+
Always instant
|
|
90
|
+
</Badge>
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
{channels.map((c) => {
|
|
94
|
+
const kind = prefCell({}, state.fixed, e.id, c.id)
|
|
95
|
+
return (
|
|
96
|
+
<div key={c.id} role="gridcell">
|
|
97
|
+
{kind === 'na' ? (
|
|
98
|
+
state.na(`${e.label}, ${lower(c.label)}, not offered`, c.label)
|
|
99
|
+
) : kind === 'locked' ? (
|
|
100
|
+
<Checkbox
|
|
101
|
+
checked
|
|
102
|
+
aria-disabled="true"
|
|
103
|
+
aria-describedby={`${state.id}-lock`}
|
|
104
|
+
tabindex="-1"
|
|
105
|
+
id={`${state.id}-${e.id}-${c.id}`}
|
|
106
|
+
onClick={state.onLocked}
|
|
107
|
+
>
|
|
108
|
+
<span data-part="sr-only">
|
|
109
|
+
{e.label}, {lower(c.label)}
|
|
110
|
+
</span>
|
|
111
|
+
<span data-part="ch-name" aria-hidden="true">
|
|
112
|
+
{c.label}
|
|
113
|
+
</span>
|
|
114
|
+
<G name="lock" data-part="lock" />
|
|
115
|
+
</Checkbox>
|
|
116
|
+
) : (
|
|
117
|
+
<EventCell
|
|
118
|
+
on={prefCell(state.model.value, state.fixed, e.id, c.id) === 'on'}
|
|
119
|
+
text={`${e.label}, ${lower(c.label)}`}
|
|
120
|
+
ch={c.label}
|
|
121
|
+
onToggle={(v: boolean) => state.cell(e, c.id, v)}
|
|
122
|
+
/>
|
|
123
|
+
)}
|
|
124
|
+
</div>
|
|
125
|
+
)
|
|
126
|
+
})}
|
|
127
|
+
</div>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { prefCell, uid, type PrefRules, type PrefValues } from '@kerf-js/veneer-core'
|
|
2
|
+
import { derived, state, untrack } from '@kerf-js/core'
|
|
3
|
+
import { val } from './shared'
|
|
4
|
+
import { preferencesWatch } from './NotificationPreferencesWatch'
|
|
5
|
+
import { preferencesSave } from './NotificationPreferencesSave'
|
|
6
|
+
import { preferencesCells } from './NotificationPreferencesCells'
|
|
7
|
+
import { preferencesActions } from './NotificationPreferencesActions'
|
|
8
|
+
import type { NotificationPreferencesProps } from './NotificationPreferences'
|
|
9
|
+
|
|
10
|
+
export type Inputs = NotificationPreferencesProps
|
|
11
|
+
export type Save = 'idle' | 'saving' | 'saved' | 'error'
|
|
12
|
+
|
|
13
|
+
export function preferencesModel(p: () => Inputs) {
|
|
14
|
+
const id = uid('prefs')
|
|
15
|
+
const model = state<PrefValues>(untrack(() => val<PrefValues>(p().value)))
|
|
16
|
+
const mail = state(untrack(() => (p().digest === undefined ? 'instant' : p().digest!)))
|
|
17
|
+
const save = state<Save>('idle')
|
|
18
|
+
// what a cell is (a box, locked, not offered) never depends on the values: its node stays through every change
|
|
19
|
+
const fixed: PrefRules = untrack(() => ({ offered: p().offered, locked: p().locked }))
|
|
20
|
+
const events = derived(() => p().groups.flatMap((g) => g.events))
|
|
21
|
+
const reset = untrack(() => p().defaults)
|
|
22
|
+
let grid: HTMLDivElement | undefined
|
|
23
|
+
preferencesWatch(p, model, mail, save, () => grid)
|
|
24
|
+
|
|
25
|
+
const { commit, cell, parent, onLocked, onNa } = preferencesSave({
|
|
26
|
+
p,
|
|
27
|
+
model,
|
|
28
|
+
mail,
|
|
29
|
+
save,
|
|
30
|
+
fixed,
|
|
31
|
+
grid: () => grid,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const { parentBox, na } = preferencesCells({ model, fixed, parent, onNa })
|
|
35
|
+
const emailOn = derived(() =>
|
|
36
|
+
events.value.some(
|
|
37
|
+
(e) =>
|
|
38
|
+
prefCell(
|
|
39
|
+
model.value,
|
|
40
|
+
fixed,
|
|
41
|
+
e.id,
|
|
42
|
+
p().digestChannel === undefined ? 'email' : p().digestChannel!,
|
|
43
|
+
) === 'on',
|
|
44
|
+
),
|
|
45
|
+
)
|
|
46
|
+
const hint = derived(() =>
|
|
47
|
+
!emailOn.value
|
|
48
|
+
? 'Turn on an email event to choose a digest'
|
|
49
|
+
: mail.value === 'instant'
|
|
50
|
+
? 'Each email is sent as it happens'
|
|
51
|
+
: 'Batches email; security alerts skip the digest',
|
|
52
|
+
)
|
|
53
|
+
const statusText = derived(
|
|
54
|
+
() =>
|
|
55
|
+
({
|
|
56
|
+
idle: 'All changes saved',
|
|
57
|
+
saving: 'Saving…',
|
|
58
|
+
saved: 'Saved',
|
|
59
|
+
error: "Couldn't save. Your last change was undone.",
|
|
60
|
+
})[save.value],
|
|
61
|
+
)
|
|
62
|
+
const { doReset, pickDigest } = preferencesActions({
|
|
63
|
+
p,
|
|
64
|
+
model,
|
|
65
|
+
mail,
|
|
66
|
+
events,
|
|
67
|
+
reset,
|
|
68
|
+
fixed,
|
|
69
|
+
commit,
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
id,
|
|
74
|
+
model,
|
|
75
|
+
mail,
|
|
76
|
+
save,
|
|
77
|
+
fixed,
|
|
78
|
+
events,
|
|
79
|
+
reset,
|
|
80
|
+
onLocked,
|
|
81
|
+
parentBox,
|
|
82
|
+
na,
|
|
83
|
+
emailOn,
|
|
84
|
+
hint,
|
|
85
|
+
statusText,
|
|
86
|
+
doReset,
|
|
87
|
+
pickDigest,
|
|
88
|
+
cell,
|
|
89
|
+
setGrid: (n: HTMLDivElement) => (grid = n),
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
announce,
|
|
3
|
+
applyPrefs,
|
|
4
|
+
toggleChanges,
|
|
5
|
+
type PrefChange,
|
|
6
|
+
type PrefEvent,
|
|
7
|
+
type PrefRules,
|
|
8
|
+
type PrefValues,
|
|
9
|
+
} from '@kerf-js/veneer-core'
|
|
10
|
+
import type { State } from '@kerf-js/core'
|
|
11
|
+
import type { Inputs, Save } from './NotificationPreferencesModel'
|
|
12
|
+
|
|
13
|
+
export function preferencesSave({
|
|
14
|
+
p,
|
|
15
|
+
model,
|
|
16
|
+
mail,
|
|
17
|
+
save,
|
|
18
|
+
fixed,
|
|
19
|
+
grid,
|
|
20
|
+
}: {
|
|
21
|
+
p: () => Inputs
|
|
22
|
+
model: State<PrefValues>
|
|
23
|
+
mail: State<string>
|
|
24
|
+
save: State<Save>
|
|
25
|
+
fixed: PrefRules
|
|
26
|
+
grid: () => HTMLDivElement | undefined
|
|
27
|
+
}) {
|
|
28
|
+
let seq = 0
|
|
29
|
+
const say = (text: string, assertive = false) => announce(grid()!.ownerDocument, text, assertive)
|
|
30
|
+
/** Apply now, run the save, roll back on rejection. */
|
|
31
|
+
const commit = async (apply: () => void, run: () => void | Promise<unknown>, msg: string) => {
|
|
32
|
+
const snap = [model.value, mail.value] as const
|
|
33
|
+
const mine = ++seq
|
|
34
|
+
apply()
|
|
35
|
+
save.value = 'saving'
|
|
36
|
+
try {
|
|
37
|
+
await run()
|
|
38
|
+
if (mine !== seq) return
|
|
39
|
+
save.value = 'saved'
|
|
40
|
+
say(`${msg}. Saved.`)
|
|
41
|
+
} catch {
|
|
42
|
+
if (mine !== seq) return
|
|
43
|
+
model.value = snap[0]
|
|
44
|
+
mail.value = snap[1]
|
|
45
|
+
save.value = 'error'
|
|
46
|
+
say(`Couldn't save: ${msg}. Change undone.`, true)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const change = (changes: PrefChange[], msg: string) =>
|
|
50
|
+
commit(
|
|
51
|
+
() => (model.value = applyPrefs(model.value, changes)),
|
|
52
|
+
() => p().onChange?.(changes),
|
|
53
|
+
msg,
|
|
54
|
+
)
|
|
55
|
+
const name = (c: string) => p().channels.find((x) => x.id === c)!.label
|
|
56
|
+
const cell = (e: PrefEvent, c: string, on: boolean) =>
|
|
57
|
+
change([{ event: e.id, channel: c, on }], `${e.label}, ${name(c)} ${on ? 'on' : 'off'}`)
|
|
58
|
+
const parent = (evs: PrefEvent[], c: string, where?: string) => {
|
|
59
|
+
const ch = toggleChanges(model.value, evs, fixed, c)
|
|
60
|
+
if (ch.length)
|
|
61
|
+
void change(
|
|
62
|
+
ch,
|
|
63
|
+
`${name(c)} ${ch[0]!.on ? 'on' : 'off'} for ${ch.length} event${ch.length > 1 ? 's' : ''}${where ? ` in ${where}` : ''}`,
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
const onLocked = (e: Event) => {
|
|
67
|
+
e.preventDefault()
|
|
68
|
+
grid()!
|
|
69
|
+
.querySelector<HTMLElement>(`#${(e.currentTarget as HTMLElement).id}`)
|
|
70
|
+
?.focus()
|
|
71
|
+
say(
|
|
72
|
+
p().lockReason === undefined
|
|
73
|
+
? 'Required: this alert always goes to your account.'
|
|
74
|
+
: p().lockReason!,
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
const onNa = (e: KeyboardEvent) => {
|
|
78
|
+
if (e.key === ' ') {
|
|
79
|
+
e.preventDefault()
|
|
80
|
+
say('Not offered for this event')
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return { commit, cell, parent, onLocked, onNa }
|
|
85
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { gridNav, type PrefValues } from '@kerf-js/veneer-core'
|
|
2
|
+
import { onMount, watch, type State } from '@kerf-js/core'
|
|
3
|
+
import { use } from '@kerf-js/veneer-core/kerf'
|
|
4
|
+
import { val } from './shared'
|
|
5
|
+
import type { Inputs, Save } from './NotificationPreferencesModel'
|
|
6
|
+
|
|
7
|
+
const CELL = 'input[type="checkbox"], [data-part="na"]'
|
|
8
|
+
|
|
9
|
+
export function preferencesWatch(
|
|
10
|
+
p: () => Inputs,
|
|
11
|
+
model: State<PrefValues>,
|
|
12
|
+
mail: State<string>,
|
|
13
|
+
save: State<Save>,
|
|
14
|
+
grid: () => HTMLDivElement | undefined,
|
|
15
|
+
) {
|
|
16
|
+
onMount(() => {
|
|
17
|
+
watch(
|
|
18
|
+
() => val<PrefValues>(p().value),
|
|
19
|
+
(v) => {
|
|
20
|
+
if (save.value !== 'saving') model.value = v
|
|
21
|
+
},
|
|
22
|
+
)
|
|
23
|
+
watch(
|
|
24
|
+
() => (p().digest === undefined ? 'instant' : p().digest!),
|
|
25
|
+
(d) => {
|
|
26
|
+
if (save.value !== 'saving') mail.value = d
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
})
|
|
30
|
+
use(gridNav, grid, () => ({ targets: CELL }))
|
|
31
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { announce, countdownLabel, countdownParts, levelMeter, uid } from '@kerf-js/veneer-core'
|
|
2
|
+
import { derived, onCleanup, onMount, state, untrack } from '@kerf-js/core'
|
|
3
|
+
import { Button } from '../Button'
|
|
4
|
+
import { Card } from '../Card'
|
|
5
|
+
import { Input } from '../Field'
|
|
6
|
+
import { Select, type Option } from '../Select'
|
|
7
|
+
import { Spinner } from '../Spinner'
|
|
8
|
+
import { use } from '@kerf-js/veneer-core/kerf'
|
|
9
|
+
import { G, held } from './shared'
|
|
10
|
+
import { PrejoinPreview } from './PrejoinPreview'
|
|
11
|
+
import { PrejoinMeter } from './PrejoinMeter'
|
|
12
|
+
import '../fields'
|
|
13
|
+
import '@kerf-js/veneer-core/styles/app/base.css'
|
|
14
|
+
import '@kerf-js/veneer-core/styles/app/tile.css'
|
|
15
|
+
import '@kerf-js/veneer-core/styles/app/prejoin.css'
|
|
16
|
+
|
|
17
|
+
/** The devices to choose from before joining. */
|
|
18
|
+
export interface PrejoinDevices {
|
|
19
|
+
mics?: Option[]
|
|
20
|
+
cameras?: Option[]
|
|
21
|
+
speakers?: Option[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Props for Prejoin. */
|
|
25
|
+
export interface PrejoinProps {
|
|
26
|
+
name?: string | undefined
|
|
27
|
+
/** The preview: your own <video>. Media is the caller's; Veneer never touches getUserMedia. */
|
|
28
|
+
preview?: () => unknown
|
|
29
|
+
/** 0 to 1. For a 10 Hz level, set `--level` on [data-part="meter"] yourself: nothing re-renders either way. */
|
|
30
|
+
level?: number
|
|
31
|
+
/** Whether your mic starts on. */
|
|
32
|
+
mic?: boolean
|
|
33
|
+
/** Whether your camera starts on. */
|
|
34
|
+
camera?: boolean
|
|
35
|
+
/** Called with the mic toggle's new state. */
|
|
36
|
+
onMic?: (on: boolean) => void
|
|
37
|
+
/** Called with the camera toggle's new state. */
|
|
38
|
+
onCamera?: (on: boolean) => void
|
|
39
|
+
devices?: PrejoinDevices
|
|
40
|
+
onDevice?: (kind: 'mic' | 'camera' | 'speaker', id: string) => void
|
|
41
|
+
onTestSound?: (() => void) | undefined
|
|
42
|
+
joining?: boolean
|
|
43
|
+
/** The join button's words. Default "Join now". */
|
|
44
|
+
joinLabel?: string
|
|
45
|
+
onJoin?: ((name: string) => void) | undefined
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Prejoin (07 §3.2): preview, 16-bar mic meter, device Selects, Join with its loading state. */
|
|
49
|
+
export function Prejoin(props: PrejoinProps) {
|
|
50
|
+
const who = state(untrack(() => (props.name === undefined ? '' : props.name)))
|
|
51
|
+
const micOn = held<boolean>(
|
|
52
|
+
() => props.mic,
|
|
53
|
+
true,
|
|
54
|
+
() => props.onMic,
|
|
55
|
+
)
|
|
56
|
+
const camOn = held<boolean>(
|
|
57
|
+
() => props.camera,
|
|
58
|
+
true,
|
|
59
|
+
() => props.onCamera,
|
|
60
|
+
)
|
|
61
|
+
const list = untrack(() => props.devices) ?? {}
|
|
62
|
+
let meter: HTMLDivElement | undefined
|
|
63
|
+
use(
|
|
64
|
+
levelMeter,
|
|
65
|
+
() => meter,
|
|
66
|
+
() => props.level,
|
|
67
|
+
)
|
|
68
|
+
const pick = (kind: 'mic' | 'camera' | 'speaker', e: Event) =>
|
|
69
|
+
props.onDevice?.(kind, (e.target as HTMLSelectElement).value)
|
|
70
|
+
return (
|
|
71
|
+
<div data-scope="prejoin">
|
|
72
|
+
<div data-part="layout">
|
|
73
|
+
<div data-part="stack">
|
|
74
|
+
<PrejoinPreview who={who} micOn={micOn} camOn={camOn} source={() => props} />
|
|
75
|
+
<PrejoinMeter bind={(n) => (meter = n)} level={props.level} />
|
|
76
|
+
</div>
|
|
77
|
+
<div data-part="stack">
|
|
78
|
+
<Input
|
|
79
|
+
label="Your name"
|
|
80
|
+
value={who.value}
|
|
81
|
+
autocomplete="name"
|
|
82
|
+
onInput={(e) => (who.value = e.currentTarget.value)}
|
|
83
|
+
/>
|
|
84
|
+
{list.mics && (
|
|
85
|
+
<Select label="Microphone" options={list.mics} onChange={(e) => pick('mic', e)} />
|
|
86
|
+
)}
|
|
87
|
+
{list.cameras && (
|
|
88
|
+
<Select label="Camera" options={list.cameras} onChange={(e) => pick('camera', e)} />
|
|
89
|
+
)}
|
|
90
|
+
{list.speakers && (
|
|
91
|
+
<Select label="Speakers" options={list.speakers} onChange={(e) => pick('speaker', e)} />
|
|
92
|
+
)}
|
|
93
|
+
{props.onTestSound && (
|
|
94
|
+
<Button emphasis="link" size="sm" onClick={props.onTestSound}>
|
|
95
|
+
Play test sound
|
|
96
|
+
</Button>
|
|
97
|
+
)}
|
|
98
|
+
<Button
|
|
99
|
+
size="lg"
|
|
100
|
+
full
|
|
101
|
+
loading={!!props.joining}
|
|
102
|
+
onClick={() => props.onJoin?.(who.value)}
|
|
103
|
+
>
|
|
104
|
+
{props.joinLabel === undefined ? 'Join now' : props.joinLabel}
|
|
105
|
+
</Button>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Lobby (07 §3.2): waiting to be let in. A Spinner and "Asking to join…" as a status. */
|
|
113
|
+
export function Lobby({
|
|
114
|
+
title = 'Waiting for the host',
|
|
115
|
+
children = "We'll chime when it's your turn.",
|
|
116
|
+
onCancel,
|
|
117
|
+
}: {
|
|
118
|
+
title?: unknown
|
|
119
|
+
children?: unknown
|
|
120
|
+
onCancel?: () => void
|
|
121
|
+
}) {
|
|
122
|
+
return (
|
|
123
|
+
<Card eyebrow="Lobby" title={title} sweep={false}>
|
|
124
|
+
<p>{children}</p>
|
|
125
|
+
<p>
|
|
126
|
+
<Spinner size="sm" /> <span role="status">Asking to join…</span>
|
|
127
|
+
</p>
|
|
128
|
+
<Button emphasis="outline" tone="neutral" size="sm" onClick={() => onCancel?.()}>
|
|
129
|
+
Cancel request
|
|
130
|
+
</Button>
|
|
131
|
+
</Card>
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Countdown (07 §3.2): role=timer, aria-live off, announced once at one minute. `to` and `now` are epoch ms: pass
|
|
137
|
+
* `now` to render on the server; without it the digits fill in after mount.
|
|
138
|
+
*/
|
|
139
|
+
export function Countdown({
|
|
140
|
+
to,
|
|
141
|
+
now,
|
|
142
|
+
label = 'Starts in',
|
|
143
|
+
onDone,
|
|
144
|
+
}: {
|
|
145
|
+
to: number
|
|
146
|
+
now?: number | undefined
|
|
147
|
+
label?: string | undefined
|
|
148
|
+
onDone?: () => void
|
|
149
|
+
}) {
|
|
150
|
+
const left = state<number | null>(untrack(() => (now === undefined ? null : to - now)))
|
|
151
|
+
const parts = derived(() => countdownParts(left.value ?? 0))
|
|
152
|
+
const name = derived(() => (left.value === null ? label : countdownLabel(left.value)))
|
|
153
|
+
let root: HTMLDivElement | undefined
|
|
154
|
+
onMount(() => {
|
|
155
|
+
let warned = untrack(() => left.value !== null && left.value <= 60000)
|
|
156
|
+
let done = false
|
|
157
|
+
const beat = () => {
|
|
158
|
+
const ms = untrack(() => to) - Date.now()
|
|
159
|
+
left.value = ms
|
|
160
|
+
if (!warned && ms <= 60000) {
|
|
161
|
+
warned = true
|
|
162
|
+
if (root) announce(root.ownerDocument, 'Starts in 1 minute')
|
|
163
|
+
}
|
|
164
|
+
if (!done && ms <= 0) {
|
|
165
|
+
done = true
|
|
166
|
+
clearInterval(t)
|
|
167
|
+
onDone?.()
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const t = setInterval(beat, 1000)
|
|
171
|
+
onCleanup(() => clearInterval(t))
|
|
172
|
+
queueMicrotask(beat)
|
|
173
|
+
})
|
|
174
|
+
return (
|
|
175
|
+
<div
|
|
176
|
+
ref={(n) => (root = n)}
|
|
177
|
+
data-part="countdown"
|
|
178
|
+
role="timer"
|
|
179
|
+
aria-live="off"
|
|
180
|
+
aria-label={name.value}
|
|
181
|
+
>
|
|
182
|
+
{parts.value.map((p) => (
|
|
183
|
+
<span key={p.unit}>
|
|
184
|
+
<b>{p.value}</b>
|
|
185
|
+
<small>{p.unit}</small>
|
|
186
|
+
</span>
|
|
187
|
+
))}
|
|
188
|
+
</div>
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** ScheduledLobby (07 §3.1): Countdown, with Join disabled until `joinable` or the countdown ends. */
|
|
193
|
+
export function ScheduledLobby({
|
|
194
|
+
title,
|
|
195
|
+
children,
|
|
196
|
+
to,
|
|
197
|
+
now,
|
|
198
|
+
joinable,
|
|
199
|
+
opensAt,
|
|
200
|
+
onJoin,
|
|
201
|
+
onAddToCalendar,
|
|
202
|
+
}: {
|
|
203
|
+
title: unknown
|
|
204
|
+
children?: unknown
|
|
205
|
+
to: number
|
|
206
|
+
now?: number | undefined
|
|
207
|
+
joinable?: boolean
|
|
208
|
+
opensAt?: string
|
|
209
|
+
onJoin?: (() => void) | undefined
|
|
210
|
+
onAddToCalendar?: (() => void) | undefined
|
|
211
|
+
}) {
|
|
212
|
+
const ended = state(false)
|
|
213
|
+
const can = derived(() => !!joinable || ended.value)
|
|
214
|
+
const id = uid('sched')
|
|
215
|
+
return (
|
|
216
|
+
<Card eyebrow="Scheduled lobby" title={title} sweep={false} aria-labelledby={undefined}>
|
|
217
|
+
{children !== undefined && <p>{children}</p>}
|
|
218
|
+
<Countdown to={to} now={now} onDone={() => (ended.value = true)} />
|
|
219
|
+
<p>
|
|
220
|
+
<Button
|
|
221
|
+
size="sm"
|
|
222
|
+
disabled={!can.value}
|
|
223
|
+
aria-describedby={!can.value && opensAt ? id : undefined}
|
|
224
|
+
onClick={() => onJoin?.()}
|
|
225
|
+
>
|
|
226
|
+
Join
|
|
227
|
+
</Button>
|
|
228
|
+
{onAddToCalendar && (
|
|
229
|
+
<Button emphasis="outline" tone="neutral" size="sm" onClick={onAddToCalendar}>
|
|
230
|
+
<G name="cal" />
|
|
231
|
+
Add to calendar
|
|
232
|
+
</Button>
|
|
233
|
+
)}
|
|
234
|
+
</p>
|
|
235
|
+
{opensAt && !can.value && <small id={id}>Opens at {opensAt}</small>}
|
|
236
|
+
</Card>
|
|
237
|
+
)
|
|
238
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const BARS = Array.from({ length: 16 }, (_, i) => i)
|
|
2
|
+
|
|
3
|
+
export function PrejoinMeter({
|
|
4
|
+
bind,
|
|
5
|
+
level,
|
|
6
|
+
}: {
|
|
7
|
+
bind: (n: HTMLDivElement) => void
|
|
8
|
+
level: number | undefined
|
|
9
|
+
}) {
|
|
10
|
+
return (
|
|
11
|
+
<div
|
|
12
|
+
ref={bind}
|
|
13
|
+
data-part="meter"
|
|
14
|
+
role="meter"
|
|
15
|
+
aria-label="Microphone level"
|
|
16
|
+
aria-valuemin="0"
|
|
17
|
+
aria-valuemax="16"
|
|
18
|
+
aria-valuenow="0"
|
|
19
|
+
style={level === undefined ? undefined : `--level:${level}`}
|
|
20
|
+
>
|
|
21
|
+
{BARS.map((i) => (
|
|
22
|
+
<i key={i}></i>
|
|
23
|
+
))}
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|