@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,98 @@
|
|
|
1
|
+
import { DownIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
import { nextIndex, uid } from '@kerf-js/veneer-core'
|
|
3
|
+
import { state, untrack } from '@kerf-js/core'
|
|
4
|
+
import './styles'
|
|
5
|
+
import '@kerf-js/veneer-core/styles/components/accordion.css'
|
|
6
|
+
|
|
7
|
+
/** One disclosure: its header, its panel and the value that names it. */
|
|
8
|
+
export type AccordionItem = {
|
|
9
|
+
value: string
|
|
10
|
+
title: unknown
|
|
11
|
+
content: unknown
|
|
12
|
+
disabled?: boolean | undefined
|
|
13
|
+
}
|
|
14
|
+
/** Props for Accordion. */
|
|
15
|
+
export interface AccordionProps {
|
|
16
|
+
items: AccordionItem[]
|
|
17
|
+
variant?: 'boxed' | 'line' | undefined
|
|
18
|
+
/** More than one open at once. */
|
|
19
|
+
multiple?: boolean
|
|
20
|
+
/** What starts open. */
|
|
21
|
+
defaultOpen?: string[]
|
|
22
|
+
onChange?: ((open: string[]) => void) | undefined
|
|
23
|
+
/** The heading level of each title: one below the heading the accordion sits under. Default 3, in a page section. */
|
|
24
|
+
level?: 2 | 3 | 4 | 5 | 6
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An accordion (05 §4; APG): each header a real button in a heading, ↑/↓/Home/End between headers. The sweep runs on
|
|
29
|
+
* hover and holds while an item is open; the height moves with grid rows, so nothing is measured.
|
|
30
|
+
*/
|
|
31
|
+
export function Accordion({
|
|
32
|
+
items,
|
|
33
|
+
variant = 'boxed',
|
|
34
|
+
multiple,
|
|
35
|
+
defaultOpen = [],
|
|
36
|
+
onChange,
|
|
37
|
+
level = 3,
|
|
38
|
+
}: AccordionProps) {
|
|
39
|
+
const base = uid('acc')
|
|
40
|
+
const open = state<string[]>(untrack(() => defaultOpen))
|
|
41
|
+
const toggle = (v: string) => {
|
|
42
|
+
const on = open.value.includes(v)
|
|
43
|
+
open.value = on ? open.value.filter((x) => x !== v) : multiple ? [...open.value, v] : [v]
|
|
44
|
+
onChange?.(open.value)
|
|
45
|
+
}
|
|
46
|
+
const onKey = (e: KeyboardEvent) => {
|
|
47
|
+
const list = [
|
|
48
|
+
...(e.currentTarget as HTMLElement).querySelectorAll<HTMLElement>(
|
|
49
|
+
'[data-part="trigger"]:not(:disabled)',
|
|
50
|
+
),
|
|
51
|
+
]
|
|
52
|
+
const at = list.indexOf(e.target as HTMLElement)
|
|
53
|
+
if (at < 0) return
|
|
54
|
+
const to = nextIndex(e.key, at, list.length, { orientation: 'vertical' })
|
|
55
|
+
if (to < 0) return
|
|
56
|
+
e.preventDefault()
|
|
57
|
+
list[to]!.focus()
|
|
58
|
+
}
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
data-scope="accordion"
|
|
62
|
+
data-part="root"
|
|
63
|
+
data-variant={variant === 'line' ? 'line' : undefined}
|
|
64
|
+
onKeyDown={onKey}
|
|
65
|
+
>
|
|
66
|
+
{items.map((it, i) => (
|
|
67
|
+
<div key={it.value} data-part="item" data-sweep="">
|
|
68
|
+
<div data-part="heading" role="heading" aria-level={level}>
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
data-part="trigger"
|
|
72
|
+
id={`${base}-h${i}`}
|
|
73
|
+
aria-expanded={open.value.includes(it.value) ? 'true' : 'false'}
|
|
74
|
+
aria-controls={`${base}-c${i}`}
|
|
75
|
+
disabled={it.disabled}
|
|
76
|
+
onClick={() => toggle(it.value)}
|
|
77
|
+
>
|
|
78
|
+
{it.title}
|
|
79
|
+
<DownIcon data-part="chevron" />
|
|
80
|
+
</button>
|
|
81
|
+
</div>
|
|
82
|
+
<div
|
|
83
|
+
data-part="content"
|
|
84
|
+
role="region"
|
|
85
|
+
id={`${base}-c${i}`}
|
|
86
|
+
aria-labelledby={`${base}-h${i}`}
|
|
87
|
+
data-state={open.value.includes(it.value) ? 'open' : undefined}
|
|
88
|
+
>
|
|
89
|
+
<div>
|
|
90
|
+
<div>{it.content}</div>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
<span data-part="sweep" aria-hidden="true"></span>
|
|
94
|
+
</div>
|
|
95
|
+
))}
|
|
96
|
+
</div>
|
|
97
|
+
)
|
|
98
|
+
}
|
package/src/Alert.tsx
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CloseX } from './CloseX'
|
|
2
|
+
import { derived } from '@kerf-js/core'
|
|
3
|
+
import type { Tone } from './Button'
|
|
4
|
+
import { Icon, toneIcon } from './Icon'
|
|
5
|
+
import './styles'
|
|
6
|
+
import '@kerf-js/veneer-core/styles/components/button.css' // the close button's markup
|
|
7
|
+
import '@kerf-js/veneer-core/styles/components/alert.css'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* An inline alert (05 §5): icon, title, description, actions, close. Status is never colour alone: the icon and the
|
|
11
|
+
* words carry it. `live` makes it role="alert" (only for a NEW error the user must hear).
|
|
12
|
+
*/
|
|
13
|
+
export function Alert({
|
|
14
|
+
tone = 'info',
|
|
15
|
+
title,
|
|
16
|
+
live,
|
|
17
|
+
actions,
|
|
18
|
+
onDismiss,
|
|
19
|
+
children,
|
|
20
|
+
}: {
|
|
21
|
+
tone?: Tone | undefined
|
|
22
|
+
title?: unknown
|
|
23
|
+
live?: boolean | undefined
|
|
24
|
+
actions?: unknown
|
|
25
|
+
onDismiss?: () => void
|
|
26
|
+
children?: unknown
|
|
27
|
+
}) {
|
|
28
|
+
// a colour named in veneer({ colors }) takes the neutral icon
|
|
29
|
+
const icon = derived(() => toneIcon[tone as keyof typeof toneIcon] ?? toneIcon.neutral)
|
|
30
|
+
return (
|
|
31
|
+
<div data-scope="alert" data-tone={tone} role={live ? 'alert' : undefined}>
|
|
32
|
+
<Icon name={icon.value} data-part="icon" />
|
|
33
|
+
{title !== undefined && <div data-part="title">{title}</div>}
|
|
34
|
+
{children !== undefined && <div data-part="description">{children}</div>}
|
|
35
|
+
{actions !== undefined && <div data-part="actions">{actions}</div>}
|
|
36
|
+
{/* <Button emphasis="ghost" tone="neutral" size="sm" icon={XIcon} label="Dismiss"> as its markup: a ghost button needs no JS */}
|
|
37
|
+
{onDismiss && (
|
|
38
|
+
<button
|
|
39
|
+
type="button"
|
|
40
|
+
data-scope="button"
|
|
41
|
+
data-emphasis="ghost"
|
|
42
|
+
data-tone="neutral"
|
|
43
|
+
data-size="sm"
|
|
44
|
+
data-icon-only=""
|
|
45
|
+
aria-label="Dismiss"
|
|
46
|
+
data-part="close"
|
|
47
|
+
data-dismiss=""
|
|
48
|
+
onClick={onDismiss}
|
|
49
|
+
>
|
|
50
|
+
<CloseX />
|
|
51
|
+
</button>
|
|
52
|
+
)}
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
55
|
+
}
|
package/src/Badge.tsx
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Tone } from './Button'
|
|
2
|
+
import './styles'
|
|
3
|
+
import '@kerf-js/veneer-core/styles/components/badge.css'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A status or count badge (05 §5). `dot` adds a status dot; a count badge says its unit to screen readers in
|
|
7
|
+
* `srText` (never an aria-label on a span, review 03 m2).
|
|
8
|
+
*/
|
|
9
|
+
export function Badge({
|
|
10
|
+
tone,
|
|
11
|
+
emphasis,
|
|
12
|
+
count,
|
|
13
|
+
dot,
|
|
14
|
+
srText,
|
|
15
|
+
children,
|
|
16
|
+
...rest
|
|
17
|
+
}: {
|
|
18
|
+
tone?: Tone | undefined
|
|
19
|
+
emphasis?: 'soft' | 'solid' | 'outline'
|
|
20
|
+
count?: boolean | undefined
|
|
21
|
+
dot?: boolean
|
|
22
|
+
srText?: string
|
|
23
|
+
children?: unknown
|
|
24
|
+
[attr: string]: unknown
|
|
25
|
+
}) {
|
|
26
|
+
return (
|
|
27
|
+
<span
|
|
28
|
+
data-scope="badge"
|
|
29
|
+
data-tone={tone}
|
|
30
|
+
data-emphasis={emphasis === 'soft' ? undefined : emphasis}
|
|
31
|
+
data-count={count ? '' : undefined}
|
|
32
|
+
{...rest}
|
|
33
|
+
>
|
|
34
|
+
{dot && <span data-scope="status-dot" data-tone={tone}></span>}
|
|
35
|
+
{children}
|
|
36
|
+
{srText && <span data-part="sr-only"> {srText}</span>}
|
|
37
|
+
</span>
|
|
38
|
+
)
|
|
39
|
+
}
|
package/src/Button.tsx
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { derived } from '@kerf-js/core'
|
|
2
|
+
import type { Interaction } from '@kerf-js/core/interaction'
|
|
3
|
+
import { pressOrigin } from '@kerf-js/veneer-core'
|
|
4
|
+
import { Icon, type IconRef } from './Icon'
|
|
5
|
+
import { useUi } from './use-ui'
|
|
6
|
+
import './styles'
|
|
7
|
+
import '@kerf-js/veneer-core/styles/components/button.css'
|
|
8
|
+
import '@kerf-js/veneer-core/styles/components/spinner.css'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The colour role a control speaks in: one of the six, or a colour named in `veneer({ colors })` (`tone="brand"`).
|
|
12
|
+
*/
|
|
13
|
+
export type Tone =
|
|
14
|
+
| 'neutral'
|
|
15
|
+
| 'accent'
|
|
16
|
+
| 'positive'
|
|
17
|
+
| 'caution'
|
|
18
|
+
| 'critical'
|
|
19
|
+
| 'info'
|
|
20
|
+
| (string & {})
|
|
21
|
+
/** How much weight a control carries, from solid down to a plain link. */
|
|
22
|
+
export type Emphasis = 'solid' | 'soft' | 'outline' | 'ghost' | 'frame' | 'link'
|
|
23
|
+
|
|
24
|
+
/** Props for Button; anything else lands on the <button>. */
|
|
25
|
+
export interface ButtonProps {
|
|
26
|
+
/** solid (default) · soft · outline · ghost · frame (the signature) · link. Fixed at creation: it picks the anatomy. */
|
|
27
|
+
emphasis?: Emphasis | undefined
|
|
28
|
+
tone?: Tone | undefined
|
|
29
|
+
size?: 'sm' | 'md' | 'lg' | undefined
|
|
30
|
+
/** A frame button with the solid fill sweeping in. */
|
|
31
|
+
fill?: boolean
|
|
32
|
+
/** At vivid the fill spreads from where the pointer arrives and parts back out, instead of wiping in from the left. Not on frame or link. */
|
|
33
|
+
follow?: boolean
|
|
34
|
+
/** Which way the fill wipes: `back` comes in from the end edge and leaves by the start, for Prev, minus and undo. */
|
|
35
|
+
direction?: 'forward' | 'back' | undefined
|
|
36
|
+
full?: boolean
|
|
37
|
+
/** Icon only: `label` is then required (it is the accessible name). */
|
|
38
|
+
icon?: IconRef | undefined
|
|
39
|
+
/** With `icon` and text: on a phone (or a tablet and a phone) only the icon shows, and the text stays the accessible name. */
|
|
40
|
+
collapse?: 'phone' | 'tablet' | undefined
|
|
41
|
+
ref?: ((el: HTMLButtonElement) => unknown) | undefined
|
|
42
|
+
onClick?: ((e: MouseEvent) => unknown) | undefined
|
|
43
|
+
label?: string | undefined
|
|
44
|
+
/** Busy: the label stays the accessible name (hidden by opacity), presses are swallowed, focus stays. */
|
|
45
|
+
loading?: boolean | undefined
|
|
46
|
+
/** `interaction()`'s row: real events fill it, and it draws whoever set it. */
|
|
47
|
+
ui?: Interaction
|
|
48
|
+
children?: unknown
|
|
49
|
+
[attr: string]: unknown
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const swept = (e: Emphasis) => e !== 'link'
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A native button (05 §2): all but link and frame append one [data-part="sweep"], and ::before paints the fill (the wipe,
|
|
56
|
+
* or with `follow` at vivid the two blobs that close on where the hand arrived); frame carries the six-part signature anatomy (SIGNATURE §1b).
|
|
57
|
+
*/
|
|
58
|
+
export function Button({
|
|
59
|
+
emphasis = 'solid',
|
|
60
|
+
tone,
|
|
61
|
+
size,
|
|
62
|
+
fill,
|
|
63
|
+
follow,
|
|
64
|
+
direction,
|
|
65
|
+
full,
|
|
66
|
+
icon,
|
|
67
|
+
collapse,
|
|
68
|
+
label,
|
|
69
|
+
loading,
|
|
70
|
+
type = 'button',
|
|
71
|
+
onClick,
|
|
72
|
+
ui,
|
|
73
|
+
ref,
|
|
74
|
+
children,
|
|
75
|
+
...rest
|
|
76
|
+
}: ButtonProps) {
|
|
77
|
+
pressOrigin() // one listener for the page; it only moves buttons that ask to follow
|
|
78
|
+
let host: HTMLButtonElement | undefined
|
|
79
|
+
useUi(
|
|
80
|
+
() => ui,
|
|
81
|
+
() => host,
|
|
82
|
+
)
|
|
83
|
+
const canLoad = derived(() => loading !== undefined)
|
|
84
|
+
const glyph = derived(() => icon)
|
|
85
|
+
// a loading or aria-disabled button swallows presses (components.html guard())
|
|
86
|
+
const press = (e: MouseEvent) => pressButton(e, (event) => onClick?.(event))
|
|
87
|
+
const content = () => (
|
|
88
|
+
<>
|
|
89
|
+
{glyph.value && <Icon name={glyph.value} />}
|
|
90
|
+
{collapse && glyph.value && children ? (
|
|
91
|
+
<span data-part="collapse">{children}</span>
|
|
92
|
+
) : (
|
|
93
|
+
children
|
|
94
|
+
)}
|
|
95
|
+
</>
|
|
96
|
+
)
|
|
97
|
+
return (
|
|
98
|
+
<button
|
|
99
|
+
type={type}
|
|
100
|
+
data-scope="button"
|
|
101
|
+
data-emphasis={emphasis === 'solid' ? undefined : emphasis}
|
|
102
|
+
data-tone={tone}
|
|
103
|
+
data-size={size === 'md' ? undefined : size}
|
|
104
|
+
data-fill={emphasis === 'frame' && fill ? '' : undefined}
|
|
105
|
+
data-follow={follow && emphasis !== 'frame' && emphasis !== 'link' ? '' : undefined}
|
|
106
|
+
data-wipe={direction === 'back' ? 'back' : undefined}
|
|
107
|
+
data-full={full ? '' : undefined}
|
|
108
|
+
data-icon-only={glyph.value && !children ? '' : undefined}
|
|
109
|
+
data-collapse={glyph.value && children ? collapse : undefined}
|
|
110
|
+
aria-label={label}
|
|
111
|
+
data-sweep={swept(emphasis) ? '' : undefined}
|
|
112
|
+
|
|
113
|
+
data-loading={loading ? '' : undefined}
|
|
114
|
+
aria-busy={loading ? 'true' : undefined}
|
|
115
|
+
aria-disabled={loading ? 'true' : undefined}
|
|
116
|
+
onClick={press}
|
|
117
|
+
{...rest}
|
|
118
|
+
ref={(n) => {
|
|
119
|
+
host = n
|
|
120
|
+
ref?.(n)
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
{emphasis === 'frame' ? (
|
|
124
|
+
frameContent(() => fill, content)
|
|
125
|
+
) : canLoad.value ? (
|
|
126
|
+
<span data-part="label">{content()}</span>
|
|
127
|
+
) : (
|
|
128
|
+
content()
|
|
129
|
+
)}
|
|
130
|
+
{loading && <span data-scope="spinner" data-part="spinner" aria-hidden="true"></span>}
|
|
131
|
+
{emphasis !== 'frame' && emphasis !== 'link' && (
|
|
132
|
+
<span data-part="sweep" aria-hidden="true"></span>
|
|
133
|
+
)}
|
|
134
|
+
</button>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function frameContent(fill: () => boolean | undefined, content: () => unknown) {
|
|
139
|
+
return (
|
|
140
|
+
<>
|
|
141
|
+
{fill() && <span data-part="sweep-fill" aria-hidden="true"></span>}
|
|
142
|
+
<span data-part="frame-corners" aria-hidden="true">
|
|
143
|
+
<i></i>
|
|
144
|
+
<i></i>
|
|
145
|
+
<i></i>
|
|
146
|
+
<i></i>
|
|
147
|
+
</span>
|
|
148
|
+
<span data-part="sweep-corners" aria-hidden="true">
|
|
149
|
+
<i></i>
|
|
150
|
+
<i></i>
|
|
151
|
+
<i></i>
|
|
152
|
+
<i></i>
|
|
153
|
+
</span>
|
|
154
|
+
<span data-part="sweep-outline" aria-hidden="true">
|
|
155
|
+
<i></i>
|
|
156
|
+
<i></i>
|
|
157
|
+
<i></i>
|
|
158
|
+
<i></i>
|
|
159
|
+
<i></i>
|
|
160
|
+
<i></i>
|
|
161
|
+
</span>
|
|
162
|
+
<span data-part="sweep-label">{content()}</span>
|
|
163
|
+
<span data-part="sweep-content" aria-hidden="true">
|
|
164
|
+
{content()}
|
|
165
|
+
</span>
|
|
166
|
+
</>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function pressButton(e: MouseEvent, onClick: ButtonProps['onClick']) {
|
|
171
|
+
const el = e.currentTarget as HTMLElement
|
|
172
|
+
if (el.hasAttribute('data-loading') || el.getAttribute('aria-disabled') === 'true')
|
|
173
|
+
return e.preventDefault()
|
|
174
|
+
onClick?.(e)
|
|
175
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Month and day rendering for the calendar grid.
|
|
2
|
+
import {
|
|
3
|
+
dayState,
|
|
4
|
+
fmt,
|
|
5
|
+
isoWeek,
|
|
6
|
+
isWeekend,
|
|
7
|
+
messages,
|
|
8
|
+
monthWeeks,
|
|
9
|
+
ymd,
|
|
10
|
+
type CalendarContext,
|
|
11
|
+
type IsoDate,
|
|
12
|
+
} from '@kerf-js/veneer-core'
|
|
13
|
+
import { derived } from '@kerf-js/core'
|
|
14
|
+
import { uid } from './Picker'
|
|
15
|
+
|
|
16
|
+
export function Month({
|
|
17
|
+
month,
|
|
18
|
+
heads,
|
|
19
|
+
first,
|
|
20
|
+
weekNumbers,
|
|
21
|
+
locale,
|
|
22
|
+
wholeWeek,
|
|
23
|
+
ctx,
|
|
24
|
+
cursor,
|
|
25
|
+
initial,
|
|
26
|
+
}: {
|
|
27
|
+
month: string
|
|
28
|
+
heads: readonly (readonly [string, string, number])[]
|
|
29
|
+
first: number
|
|
30
|
+
weekNumbers?: boolean | undefined
|
|
31
|
+
locale: string
|
|
32
|
+
wholeWeek: boolean
|
|
33
|
+
ctx: () => CalendarContext
|
|
34
|
+
cursor: string
|
|
35
|
+
initial?: boolean | undefined
|
|
36
|
+
}) {
|
|
37
|
+
const cap = uid('cap')
|
|
38
|
+
const weeks = derived(() =>
|
|
39
|
+
monthWeeks(month, first).map((days) => ({
|
|
40
|
+
days: days.map((iso, c) => ({ iso, k: iso ?? `b${c}`, weekday: (first + c) % 7 })),
|
|
41
|
+
k: days.find(Boolean)!,
|
|
42
|
+
week: isoWeek(days.find(Boolean)!).week,
|
|
43
|
+
})),
|
|
44
|
+
)
|
|
45
|
+
return (
|
|
46
|
+
<div data-part="month">
|
|
47
|
+
<div data-part="caption" id={cap} aria-live="polite">
|
|
48
|
+
{fmt(month, { month: 'long', year: 'numeric' }, locale)}
|
|
49
|
+
</div>
|
|
50
|
+
<table role="grid" aria-labelledby={cap}>
|
|
51
|
+
<thead>
|
|
52
|
+
<tr>
|
|
53
|
+
{weekNumbers && (
|
|
54
|
+
<th scope="col" abbr={messages(locale).week}>
|
|
55
|
+
<span class="sr">{messages(locale).week}</span>
|
|
56
|
+
</th>
|
|
57
|
+
)}
|
|
58
|
+
{heads.map((h) => (
|
|
59
|
+
<th key={h[0]} scope="col" abbr={h[0]}>
|
|
60
|
+
{h[1]}
|
|
61
|
+
</th>
|
|
62
|
+
))}
|
|
63
|
+
</tr>
|
|
64
|
+
</thead>
|
|
65
|
+
<tbody>
|
|
66
|
+
{weeks.value.map((w) => (
|
|
67
|
+
<tr key={w.k}>
|
|
68
|
+
{weekNumbers && (
|
|
69
|
+
<th scope="row" data-part="week">
|
|
70
|
+
{w.week}
|
|
71
|
+
</th>
|
|
72
|
+
)}
|
|
73
|
+
{w.days.map((d) =>
|
|
74
|
+
d.iso ? (
|
|
75
|
+
<Day
|
|
76
|
+
key={d.k}
|
|
77
|
+
iso={d.iso}
|
|
78
|
+
weekend={isWeekend(d.weekday, locale)}
|
|
79
|
+
locale={locale}
|
|
80
|
+
wholeWeek={wholeWeek}
|
|
81
|
+
ctx={ctx}
|
|
82
|
+
cursor={cursor}
|
|
83
|
+
initial={initial}
|
|
84
|
+
/>
|
|
85
|
+
) : (
|
|
86
|
+
<td key={d.k} role="gridcell"></td>
|
|
87
|
+
),
|
|
88
|
+
)}
|
|
89
|
+
</tr>
|
|
90
|
+
))}
|
|
91
|
+
</tbody>
|
|
92
|
+
</table>
|
|
93
|
+
</div>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function Day({
|
|
98
|
+
iso,
|
|
99
|
+
weekend,
|
|
100
|
+
locale,
|
|
101
|
+
ctx,
|
|
102
|
+
cursor,
|
|
103
|
+
initial,
|
|
104
|
+
}: {
|
|
105
|
+
iso: IsoDate
|
|
106
|
+
weekend: boolean
|
|
107
|
+
locale: string
|
|
108
|
+
wholeWeek: boolean
|
|
109
|
+
ctx: () => CalendarContext
|
|
110
|
+
cursor: string
|
|
111
|
+
initial?: boolean | undefined
|
|
112
|
+
}) {
|
|
113
|
+
const s = derived(() => dayState(iso, ctx()))
|
|
114
|
+
const n = derived(() => new Intl.NumberFormat(locale).format(ymd(iso)[2]))
|
|
115
|
+
return (
|
|
116
|
+
<td
|
|
117
|
+
role="gridcell"
|
|
118
|
+
aria-selected={s.value.cellSelected ? 'true' : 'false'}
|
|
119
|
+
data-range={s.value.range}
|
|
120
|
+
data-preview={s.value.preview ? '' : undefined}
|
|
121
|
+
data-compare={s.value.compare ? '' : undefined}
|
|
122
|
+
>
|
|
123
|
+
<button
|
|
124
|
+
type="button"
|
|
125
|
+
data-part="day"
|
|
126
|
+
data-date={iso}
|
|
127
|
+
tabindex={iso === cursor ? '0' : '-1'}
|
|
128
|
+
data-initial={initial && iso === cursor ? '' : undefined}
|
|
129
|
+
data-weekend={weekend ? '' : undefined}
|
|
130
|
+
data-selected={s.value.selected ? '' : undefined}
|
|
131
|
+
data-booked={s.value.unavailable && s.value.booked ? '' : undefined}
|
|
132
|
+
aria-current={s.value.today ? 'date' : undefined}
|
|
133
|
+
aria-disabled={s.value.unavailable ? 'true' : undefined}
|
|
134
|
+
aria-label={s.value.name}
|
|
135
|
+
>
|
|
136
|
+
{n.value}
|
|
137
|
+
</button>
|
|
138
|
+
</td>
|
|
139
|
+
)
|
|
140
|
+
}
|