@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,136 @@
|
|
|
1
|
+
import { emailError, uid } from '@kerf-js/veneer-core'
|
|
2
|
+
import { derived, untrack } from '@kerf-js/core'
|
|
3
|
+
import { Input } from '../Field'
|
|
4
|
+
import { Switch } from '../Choice'
|
|
5
|
+
import { AuthLogo } from './AuthScreen'
|
|
6
|
+
import { FormError, StepFrame, Submit, TextLink, Title, useStepForm, type FlowForm } from './kit'
|
|
7
|
+
import { PasskeyButton, SsoButtons, type SsoProvider } from './Sso'
|
|
8
|
+
import '../styles'
|
|
9
|
+
import '@kerf-js/veneer-core/styles/flows/auth.css'
|
|
10
|
+
import '@kerf-js/veneer-core/styles/flows/sso.css'
|
|
11
|
+
|
|
12
|
+
/** What the sign-in form submits. */
|
|
13
|
+
export interface SignInValues {
|
|
14
|
+
email: string
|
|
15
|
+
password: string
|
|
16
|
+
remember?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Props for SignIn. */
|
|
20
|
+
export interface SignInProps extends FlowForm<SignInValues> {
|
|
21
|
+
title?: unknown
|
|
22
|
+
lede?: unknown
|
|
23
|
+
logo?: unknown
|
|
24
|
+
name?: unknown
|
|
25
|
+
submitLabel?: unknown
|
|
26
|
+
providers?: SsoProvider[]
|
|
27
|
+
onProvider?: ((id: string) => unknown) | undefined
|
|
28
|
+
/** Shows the passkey button; run WebAuthn here. */
|
|
29
|
+
onPasskey?: () => unknown
|
|
30
|
+
onForgot?: () => void
|
|
31
|
+
/** Called with the typed email; asks for one first. */
|
|
32
|
+
onMagicLink?: (email: string) => void
|
|
33
|
+
onSignUp?: () => void
|
|
34
|
+
onInvite?: () => void
|
|
35
|
+
/** The "Keep me signed in" switch (default on). */
|
|
36
|
+
remember?: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Sign in (09 §2.1): passkey and SSO frames, the divider, email and password, remember and Forgot, the one solid.
|
|
41
|
+
* The email carries `username webauthn`, so conditional UI offers passkeys from first focus. A wrong password and an
|
|
42
|
+
* unknown email read the same (§2.3).
|
|
43
|
+
*/
|
|
44
|
+
export function SignIn(p: SignInProps) {
|
|
45
|
+
const id = uid('signin')
|
|
46
|
+
const ctl = useStepForm<SignInValues>(
|
|
47
|
+
untrack(() => p),
|
|
48
|
+
(v) => ({
|
|
49
|
+
email: v.email ? emailError(v.email) : 'Enter your work email.',
|
|
50
|
+
password: v.password ? undefined : 'Enter your password.',
|
|
51
|
+
}),
|
|
52
|
+
)
|
|
53
|
+
const hasSso = derived(() => !!(p.onPasskey || p.providers?.length))
|
|
54
|
+
const ask = magicLink(ctl, (email) => p.onMagicLink?.(email))
|
|
55
|
+
return (
|
|
56
|
+
<StepFrame ctl={ctl} embedded={!!p.form} labelledby={`${id}-t`}>
|
|
57
|
+
{(p.logo !== undefined || p.name !== undefined) && (
|
|
58
|
+
<div>
|
|
59
|
+
<AuthLogo logo={p.logo} name={p.name} />
|
|
60
|
+
</div>
|
|
61
|
+
)}
|
|
62
|
+
<div>
|
|
63
|
+
<Title as={p.heading} id={`${id}-t`}>
|
|
64
|
+
{p.title ?? 'Sign in'}
|
|
65
|
+
</Title>
|
|
66
|
+
{p.lede !== undefined && <p data-part="lede">{p.lede}</p>}
|
|
67
|
+
</div>
|
|
68
|
+
{hasSso.value && (
|
|
69
|
+
<div data-scope="sso">
|
|
70
|
+
{p.onPasskey && <PasskeyButton onPasskey={p.onPasskey} />}
|
|
71
|
+
{!!p.providers?.length && (
|
|
72
|
+
<SsoButtons providers={p.providers} onProvider={p.onProvider} />
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
{hasSso.value && <div data-part="divider">or with email</div>}
|
|
77
|
+
<FormError
|
|
78
|
+
ctl={ctl}
|
|
79
|
+
actions={p.onForgot && <TextLink onClick={p.onForgot}>Reset your password</TextLink>}
|
|
80
|
+
/>
|
|
81
|
+
<Input
|
|
82
|
+
label="Work email"
|
|
83
|
+
name="email"
|
|
84
|
+
type="email"
|
|
85
|
+
autocomplete="username webauthn"
|
|
86
|
+
inputmode="email"
|
|
87
|
+
value={p.form?.value?.('email') as string | undefined}
|
|
88
|
+
hint=""
|
|
89
|
+
error={ctl.errors.value.email}
|
|
90
|
+
onBlur={(e: FocusEvent) =>
|
|
91
|
+
ctl.flag('email', emailError((e.target as HTMLInputElement).value))
|
|
92
|
+
}
|
|
93
|
+
/>
|
|
94
|
+
<Input
|
|
95
|
+
label="Password"
|
|
96
|
+
name="password"
|
|
97
|
+
type="password"
|
|
98
|
+
autocomplete="current-password"
|
|
99
|
+
hint=""
|
|
100
|
+
error={ctl.errors.value.password}
|
|
101
|
+
/>
|
|
102
|
+
<div data-part="row">
|
|
103
|
+
<Switch size="sm" name="remember" checked={p.remember ?? true}>
|
|
104
|
+
Keep me signed in
|
|
105
|
+
</Switch>
|
|
106
|
+
{p.onForgot && <TextLink onClick={p.onForgot}>Forgot password?</TextLink>}
|
|
107
|
+
</div>
|
|
108
|
+
<Submit ctl={ctl}>{p.submitLabel ?? 'Sign in'}</Submit>
|
|
109
|
+
{p.onMagicLink && (
|
|
110
|
+
<p data-part="fine">
|
|
111
|
+
<TextLink onClick={ask}>Email me a sign-in link instead</TextLink>
|
|
112
|
+
</p>
|
|
113
|
+
)}
|
|
114
|
+
{(p.onSignUp || p.onInvite) && (
|
|
115
|
+
<p data-part="fine">
|
|
116
|
+
{p.onSignUp && <TextLink onClick={p.onSignUp}>Create an account</TextLink>}
|
|
117
|
+
{p.onSignUp && p.onInvite && ' · '}
|
|
118
|
+
{p.onInvite && <TextLink onClick={p.onInvite}>Have an invite?</TextLink>}
|
|
119
|
+
</p>
|
|
120
|
+
)}
|
|
121
|
+
</StepFrame>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function magicLink(
|
|
126
|
+
ctl: ReturnType<typeof useStepForm<SignInValues>>,
|
|
127
|
+
onMagicLink: (email: string) => void,
|
|
128
|
+
) {
|
|
129
|
+
return (e: MouseEvent) => {
|
|
130
|
+
const scope = (e.currentTarget as HTMLElement).closest('form, [role="group"]')
|
|
131
|
+
const email = scope?.querySelector<HTMLInputElement>('input[name="email"]')?.value ?? ''
|
|
132
|
+
const bad = email ? emailError(email) : "Enter your email first; we'll send the link there."
|
|
133
|
+
ctl.flag('email', bad)
|
|
134
|
+
if (!bad) onMagicLink(email)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { emailError, passwordRules, passwordStrength, uid } from '@kerf-js/veneer-core'
|
|
2
|
+
import { derived, state, untrack } from '@kerf-js/core'
|
|
3
|
+
import { Checkbox } from '../Choice'
|
|
4
|
+
import { Input } from '../Field'
|
|
5
|
+
import { FormError, StepFrame, Submit, TextLink, Title, useStepForm, type FlowForm } from './kit'
|
|
6
|
+
import { SsoButtons, type SsoProvider } from './Sso'
|
|
7
|
+
import '../styles'
|
|
8
|
+
import '@kerf-js/veneer-core/styles/flows/auth.css'
|
|
9
|
+
import '@kerf-js/veneer-core/styles/components/meter.css'
|
|
10
|
+
import '@kerf-js/veneer-core/styles/inputs/pickers.css' // the rules list
|
|
11
|
+
|
|
12
|
+
/** Strength Meter (05) and the rules list (03) under a new password. Each rule says itself: the colour is never alone. */
|
|
13
|
+
export function PasswordMeter({ value }: { value: string }) {
|
|
14
|
+
const s = derived(() => passwordStrength(value))
|
|
15
|
+
const rules = derived(() => passwordRules(value))
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<div
|
|
19
|
+
data-scope="meter"
|
|
20
|
+
data-level={
|
|
21
|
+
s.value.tone === 'critical' ? 'full' : s.value.tone === 'caution' ? 'high' : undefined
|
|
22
|
+
}
|
|
23
|
+
role="meter"
|
|
24
|
+
aria-label="Password strength"
|
|
25
|
+
aria-valuemin="0"
|
|
26
|
+
aria-valuemax="4"
|
|
27
|
+
aria-valuenow={s.value.score}
|
|
28
|
+
aria-valuetext={s.value.label}
|
|
29
|
+
style={`--_v:${s.value.score / 4}`}
|
|
30
|
+
>
|
|
31
|
+
<div data-part="label-row">
|
|
32
|
+
<span>Password strength</span>
|
|
33
|
+
<span>{value ? s.value.label : ''}</span>
|
|
34
|
+
</div>
|
|
35
|
+
<div data-part="track">
|
|
36
|
+
<div data-part="range"></div>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<ul data-scope="rules">
|
|
40
|
+
{rules.value.map((r) => (
|
|
41
|
+
<li key={r.id} data-met={r.met ? '' : undefined}>
|
|
42
|
+
<svg viewBox="0 0 12 12" aria-hidden="true">
|
|
43
|
+
<path pathLength="1" d="M2 6.5 5 9.5 10 3" />
|
|
44
|
+
</svg>
|
|
45
|
+
{r.label}
|
|
46
|
+
<span data-part="sr-only">{r.met ? ', met' : ', not met'}</span>
|
|
47
|
+
</li>
|
|
48
|
+
))}
|
|
49
|
+
</ul>
|
|
50
|
+
</>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** What the sign-up form submits. */
|
|
55
|
+
export interface SignUpValues {
|
|
56
|
+
name: string
|
|
57
|
+
email: string
|
|
58
|
+
password: string
|
|
59
|
+
terms?: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Props for SignUp. */
|
|
63
|
+
export interface SignUpProps extends FlowForm<SignUpValues> {
|
|
64
|
+
title?: unknown
|
|
65
|
+
lede?: unknown
|
|
66
|
+
submitLabel?: unknown
|
|
67
|
+
/** The terms checkbox's text, links included. */
|
|
68
|
+
terms?: unknown
|
|
69
|
+
providers?: SsoProvider[]
|
|
70
|
+
onProvider?: ((id: string) => unknown) | undefined
|
|
71
|
+
onSignIn?: () => void
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Sign up (09 §2.1): name, email, password with strength and rules, terms; Create account is the one solid. */
|
|
75
|
+
export function SignUp(p: SignUpProps) {
|
|
76
|
+
const id = uid('signup')
|
|
77
|
+
const password = state('')
|
|
78
|
+
const ctl = useStepForm<SignUpValues>(
|
|
79
|
+
untrack(() => p),
|
|
80
|
+
(v) => ({
|
|
81
|
+
name: v.name ? undefined : 'Enter your name.',
|
|
82
|
+
email: v.email ? emailError(v.email) : 'Enter your work email.',
|
|
83
|
+
password: passwordRules(v.password!).every((r) => r.met)
|
|
84
|
+
? undefined
|
|
85
|
+
: 'Use at least 8 characters, with a letter and a number.',
|
|
86
|
+
terms: p.terms === undefined || v.terms ? undefined : 'Accept the terms to continue.',
|
|
87
|
+
}),
|
|
88
|
+
)
|
|
89
|
+
return (
|
|
90
|
+
<StepFrame ctl={ctl} embedded={!!p.form} labelledby={`${id}-t`}>
|
|
91
|
+
<div>
|
|
92
|
+
<Title as={p.heading} id={`${id}-t`}>
|
|
93
|
+
{p.title ?? 'Create your account'}
|
|
94
|
+
</Title>
|
|
95
|
+
{p.lede !== undefined && <p data-part="lede">{p.lede}</p>}
|
|
96
|
+
</div>
|
|
97
|
+
{!!p.providers?.length && <SsoButtons providers={p.providers} onProvider={p.onProvider} />}
|
|
98
|
+
{!!p.providers?.length && <div data-part="divider">or with email</div>}
|
|
99
|
+
<FormError ctl={ctl} />
|
|
100
|
+
<Input
|
|
101
|
+
label="Your name"
|
|
102
|
+
name="name"
|
|
103
|
+
autocomplete="name"
|
|
104
|
+
hint=""
|
|
105
|
+
error={ctl.errors.value.name}
|
|
106
|
+
/>
|
|
107
|
+
<Input
|
|
108
|
+
label="Work email"
|
|
109
|
+
name="email"
|
|
110
|
+
type="email"
|
|
111
|
+
inputmode="email"
|
|
112
|
+
autocomplete="email"
|
|
113
|
+
hint=""
|
|
114
|
+
error={ctl.errors.value.email}
|
|
115
|
+
onBlur={(e: FocusEvent) =>
|
|
116
|
+
ctl.flag('email', emailError((e.target as HTMLInputElement).value))
|
|
117
|
+
}
|
|
118
|
+
/>
|
|
119
|
+
<div>
|
|
120
|
+
<Input
|
|
121
|
+
label="Password"
|
|
122
|
+
name="password"
|
|
123
|
+
type="password"
|
|
124
|
+
autocomplete="new-password"
|
|
125
|
+
hint=""
|
|
126
|
+
error={ctl.errors.value.password}
|
|
127
|
+
onInput={(e) => (password.value = e.currentTarget.value)}
|
|
128
|
+
/>
|
|
129
|
+
<PasswordMeter value={password.value} />
|
|
130
|
+
</div>
|
|
131
|
+
{p.terms !== undefined && (
|
|
132
|
+
<Checkbox
|
|
133
|
+
name="terms"
|
|
134
|
+
value="yes"
|
|
135
|
+
hint={ctl.errors.value.terms ?? ''}
|
|
136
|
+
error={ctl.errors.value.terms}
|
|
137
|
+
>
|
|
138
|
+
{p.terms}
|
|
139
|
+
</Checkbox>
|
|
140
|
+
)}
|
|
141
|
+
<Submit ctl={ctl}>{p.submitLabel ?? 'Create account'}</Submit>
|
|
142
|
+
{p.onSignIn && (
|
|
143
|
+
<p data-part="fine">
|
|
144
|
+
<TextLink onClick={p.onSignIn}>I already have an account</TextLink>
|
|
145
|
+
</p>
|
|
146
|
+
)}
|
|
147
|
+
</StepFrame>
|
|
148
|
+
)
|
|
149
|
+
}
|
package/src/flow/Sso.tsx
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { KeyIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import { isPasskeyCancel } from '@kerf-js/veneer-core'
|
|
3
|
+
import { derived, state } from '@kerf-js/core'
|
|
4
|
+
import { Button } from '../Button'
|
|
5
|
+
import { Glyph } from '../parts'
|
|
6
|
+
import '../styles'
|
|
7
|
+
import '@kerf-js/veneer-core/styles/flows/sso.css'
|
|
8
|
+
import '@kerf-js/veneer-core/styles/layout/grid.css'
|
|
9
|
+
|
|
10
|
+
// a frame draws its content twice: a function child builds each copy (an element would move from one to the other)
|
|
11
|
+
|
|
12
|
+
/** Sign in with a passkey (09 §2.1): a frame button. WebAuthn is the app's; a cancelled OS sheet shows nothing. */
|
|
13
|
+
export function PasskeyButton({
|
|
14
|
+
onPasskey,
|
|
15
|
+
onError,
|
|
16
|
+
children,
|
|
17
|
+
...rest
|
|
18
|
+
}: {
|
|
19
|
+
onPasskey?: () => unknown
|
|
20
|
+
onError?: (e: unknown) => void
|
|
21
|
+
children?: unknown
|
|
22
|
+
[attr: string]: unknown
|
|
23
|
+
}) {
|
|
24
|
+
const busy = state(false)
|
|
25
|
+
const press = async () => {
|
|
26
|
+
busy.value = true
|
|
27
|
+
try {
|
|
28
|
+
await onPasskey?.()
|
|
29
|
+
} catch (e) {
|
|
30
|
+
if (!isPasskeyCancel(e)) onError?.(e)
|
|
31
|
+
} finally {
|
|
32
|
+
busy.value = false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return (
|
|
36
|
+
<Button emphasis="frame" full loading={busy.value} onClick={press} {...rest}>
|
|
37
|
+
{() => (
|
|
38
|
+
<>
|
|
39
|
+
<KeyIcon />
|
|
40
|
+
{children ?? 'Continue with passkey'}
|
|
41
|
+
</>
|
|
42
|
+
)}
|
|
43
|
+
</Button>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** One identity provider on offer. */
|
|
48
|
+
export interface SsoProvider {
|
|
49
|
+
id: string
|
|
50
|
+
label: string
|
|
51
|
+
/** One path on the 24 grid: monochrome, never the provider's colours. */ glyph?: string
|
|
52
|
+
/** More words for assistive tech, after a short label: the label stays part of the name. */ name?:
|
|
53
|
+
| string
|
|
54
|
+
| undefined
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Provider buttons (09 §2.1, §2.2): frame buttons in a row; each stays pending until the app redirects. */
|
|
58
|
+
export function SsoButtons({
|
|
59
|
+
providers,
|
|
60
|
+
onProvider,
|
|
61
|
+
}: {
|
|
62
|
+
providers: SsoProvider[]
|
|
63
|
+
onProvider?: ((id: string) => unknown) | undefined
|
|
64
|
+
}) {
|
|
65
|
+
const list = derived(() => providers)
|
|
66
|
+
const busy = state<string | undefined>(undefined)
|
|
67
|
+
const press = async (id: string) => {
|
|
68
|
+
busy.value = id
|
|
69
|
+
try {
|
|
70
|
+
await onProvider?.(id)
|
|
71
|
+
} finally {
|
|
72
|
+
busy.value = undefined
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return (
|
|
76
|
+
<div data-scope="grid" data-min="xs" data-cols="3">
|
|
77
|
+
{list.value.map((p) => (
|
|
78
|
+
<Button
|
|
79
|
+
key={p.id}
|
|
80
|
+
emphasis="frame"
|
|
81
|
+
full
|
|
82
|
+
loading={busy.value === p.id}
|
|
83
|
+
onClick={() => press(p.id)}
|
|
84
|
+
>
|
|
85
|
+
{() => (
|
|
86
|
+
<>
|
|
87
|
+
{p.glyph && <Glyph d={p.glyph} />}
|
|
88
|
+
{p.label}
|
|
89
|
+
{p.name && <span data-part="sr-only"> {p.name}</span>}
|
|
90
|
+
</>
|
|
91
|
+
)}
|
|
92
|
+
</Button>
|
|
93
|
+
))}
|
|
94
|
+
</div>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { PlusIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import { menu, uid } from '@kerf-js/veneer-core'
|
|
3
|
+
import { state } from '@kerf-js/core'
|
|
4
|
+
import { use } from '@kerf-js/veneer-core/kerf'
|
|
5
|
+
import { Avatar } from '../../parts'
|
|
6
|
+
import { Badge } from '../../Badge'
|
|
7
|
+
import type { SwitchAccount } from '../SystemPage'
|
|
8
|
+
|
|
9
|
+
export function AccountMenu({
|
|
10
|
+
accounts,
|
|
11
|
+
onSwitch,
|
|
12
|
+
}: {
|
|
13
|
+
accounts: SwitchAccount[]
|
|
14
|
+
onSwitch?: (id: string | undefined) => void
|
|
15
|
+
}) {
|
|
16
|
+
const id = uid('accounts')
|
|
17
|
+
const open = state(false)
|
|
18
|
+
let list: HTMLElement | undefined
|
|
19
|
+
use(
|
|
20
|
+
menu,
|
|
21
|
+
() => list,
|
|
22
|
+
() => ({
|
|
23
|
+
open: open.value,
|
|
24
|
+
trigger: () => list?.parentElement?.querySelector<HTMLElement>('[data-switch]'),
|
|
25
|
+
onClose: () => (open.value = false),
|
|
26
|
+
}),
|
|
27
|
+
)
|
|
28
|
+
const pick = (a: string | undefined) => {
|
|
29
|
+
open.value = false
|
|
30
|
+
list?.parentElement?.querySelector<HTMLElement>('[data-switch]')?.focus()
|
|
31
|
+
onSwitch?.(a)
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
open,
|
|
35
|
+
id,
|
|
36
|
+
press: () => (open.value = !open.value),
|
|
37
|
+
menu: () => (
|
|
38
|
+
<ul
|
|
39
|
+
ref={(n) => (list = n)}
|
|
40
|
+
data-part="accounts"
|
|
41
|
+
role="menu"
|
|
42
|
+
id={id}
|
|
43
|
+
aria-label="Switch account"
|
|
44
|
+
hidden={!open.value || undefined}
|
|
45
|
+
>
|
|
46
|
+
{accounts.map((a) => (
|
|
47
|
+
<li key={a.id} role="none">
|
|
48
|
+
<button type="button" role="menuitem" tabindex="-1" onClick={() => pick(a.id)}>
|
|
49
|
+
<Avatar name={a.email} size="sm" />
|
|
50
|
+
<span>
|
|
51
|
+
{a.email}
|
|
52
|
+
{a.detail && <small>{a.detail}</small>}
|
|
53
|
+
</span>
|
|
54
|
+
{a.hasAccess ? (
|
|
55
|
+
<Badge tone="positive">Has access</Badge>
|
|
56
|
+
) : a.current ? (
|
|
57
|
+
<small>Current</small>
|
|
58
|
+
) : (
|
|
59
|
+
<span></span>
|
|
60
|
+
)}
|
|
61
|
+
</button>
|
|
62
|
+
</li>
|
|
63
|
+
))}
|
|
64
|
+
<li role="none">
|
|
65
|
+
<button type="button" role="menuitem" tabindex="-1" onClick={() => pick(undefined)}>
|
|
66
|
+
<PlusIcon />
|
|
67
|
+
<span>Use another account</span>
|
|
68
|
+
<span></span>
|
|
69
|
+
</button>
|
|
70
|
+
</li>
|
|
71
|
+
</ul>
|
|
72
|
+
),
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { CopyIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import { announce, copyText } from '@kerf-js/veneer-core'
|
|
3
|
+
import { Button } from '../../Button'
|
|
4
|
+
import { derived, untrack } from '@kerf-js/core'
|
|
5
|
+
import { use } from '@kerf-js/veneer-core/kerf'
|
|
6
|
+
|
|
7
|
+
const X = [8, 27.5, 47, 66.5, 86, 105.5, 125].map((x) => ({ x }))
|
|
8
|
+
const Threads = ({ y2 = 84 }: { y2?: number }) => (
|
|
9
|
+
<>
|
|
10
|
+
{X.map((t) => (
|
|
11
|
+
<line key={t.x} x1={t.x} y1="0" x2={t.x} y2={y2} />
|
|
12
|
+
))}
|
|
13
|
+
</>
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
/** 404 and 500: a kerf thread broken in two. */
|
|
17
|
+
export const Broken = () => (
|
|
18
|
+
<svg data-part="weave" viewBox="0 0 132 84" preserveAspectRatio="none" aria-hidden="true">
|
|
19
|
+
<Threads />
|
|
20
|
+
<path pathLength="1" style="--i:0" d="M0 22H132" />
|
|
21
|
+
<path pathLength="1" style="--i:1" d="M0 44H70" data-broken="" />
|
|
22
|
+
<path pathLength="1" style="--i:2" d="M86 44H132" opacity=".35" />
|
|
23
|
+
<path pathLength="1" style="--i:3" d="M0 64H132" />
|
|
24
|
+
</svg>
|
|
25
|
+
)
|
|
26
|
+
/** First run: whole threads. */
|
|
27
|
+
export const Whole = () => (
|
|
28
|
+
<svg data-part="weave" viewBox="0 0 132 84" preserveAspectRatio="none" aria-hidden="true">
|
|
29
|
+
<Threads />
|
|
30
|
+
<path pathLength="1" style="--i:0" d="M0 22H132" />
|
|
31
|
+
<path pathLength="1" style="--i:1" d="M0 44H132" />
|
|
32
|
+
<path pathLength="1" style="--i:2" d="M0 64H132" />
|
|
33
|
+
</svg>
|
|
34
|
+
)
|
|
35
|
+
/** 403: a thread stops at a padlock on the crossing, in ink: nothing broke (07 §6.5). */
|
|
36
|
+
export const Locked = () => (
|
|
37
|
+
<svg
|
|
38
|
+
data-part="weave"
|
|
39
|
+
viewBox="0 0 132 84"
|
|
40
|
+
preserveAspectRatio="xMidYMid meet"
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
>
|
|
43
|
+
{[16, 36, 56, 76, 96, 116].map((x) => (
|
|
44
|
+
<line key={x} x1={x} y1="4" x2={x} y2="80" />
|
|
45
|
+
))}
|
|
46
|
+
<path pathLength="1" style="--i:0" d="M4 22 C 30 18, 40 26, 66 22 S 102 18, 128 22" />
|
|
47
|
+
<path pathLength="1" style="--i:1" d="M4 62 C 30 58, 40 66, 66 62 S 102 58, 128 62" />
|
|
48
|
+
<path pathLength="1" style="--i:2" d="M4 42 C 20 40, 34 44, 52 42" />
|
|
49
|
+
<path data-part="shackle" d="M58 40 v-7 a8 8 0 0 1 16 0 v7" />
|
|
50
|
+
<rect data-part="lock" x="54" y="39" width="24" height="19" rx="4" />
|
|
51
|
+
<path data-part="keyhole" d="M66 46 v5" />
|
|
52
|
+
</svg>
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
const focusTitle = (el: HTMLElement) => {
|
|
56
|
+
el.focus({ preventScroll: true })
|
|
57
|
+
return { update() {}, destroy() {} }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The title and code: every result page's top. */
|
|
61
|
+
export function Head({
|
|
62
|
+
art,
|
|
63
|
+
code,
|
|
64
|
+
title,
|
|
65
|
+
focus,
|
|
66
|
+
as,
|
|
67
|
+
}: {
|
|
68
|
+
art: unknown
|
|
69
|
+
code: unknown
|
|
70
|
+
title: unknown
|
|
71
|
+
focus?: boolean | undefined
|
|
72
|
+
as?: 'h2' | 'h3' | undefined
|
|
73
|
+
}) {
|
|
74
|
+
const h3 = derived(() => as === 'h3')
|
|
75
|
+
let el: HTMLElement | undefined
|
|
76
|
+
if (untrack(() => focus)) use(focusTitle, () => el)
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
<span data-part="art">{art}</span>
|
|
80
|
+
<span data-part="code">{code}</span>
|
|
81
|
+
{h3.value ? (
|
|
82
|
+
<h3 ref={(n) => (el = n)} data-part="title" tabindex="-1">
|
|
83
|
+
{title}
|
|
84
|
+
</h3>
|
|
85
|
+
) : (
|
|
86
|
+
<h2 ref={(n) => (el = n)} data-part="title" tabindex="-1">
|
|
87
|
+
{title}
|
|
88
|
+
</h2>
|
|
89
|
+
)}
|
|
90
|
+
</>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function RequestId({ id }: { id: string }) {
|
|
95
|
+
return (
|
|
96
|
+
<span data-part="meta">
|
|
97
|
+
Request ID <code>{id}</code>
|
|
98
|
+
<Button
|
|
99
|
+
emphasis="ghost"
|
|
100
|
+
tone="neutral"
|
|
101
|
+
size="sm"
|
|
102
|
+
data-icon-only=""
|
|
103
|
+
label="Copy request ID"
|
|
104
|
+
onClick={async () => {
|
|
105
|
+
await copyText(document, id)
|
|
106
|
+
announce(document, 'Copied')
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
<CopyIcon />
|
|
110
|
+
</Button>
|
|
111
|
+
</span>
|
|
112
|
+
)
|
|
113
|
+
}
|