@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,110 @@
|
|
|
1
|
+
// What the live pack's components share: glyphs from the specimen's 24 grid, and reading a prop that may be a plain
|
|
2
|
+
// value, a kerf State or Signal, or a getter (07 §4.5: `count={() => …}`, `items={inbox}`).
|
|
3
|
+
import {
|
|
4
|
+
AlertIcon,
|
|
5
|
+
AtIcon,
|
|
6
|
+
BellIcon,
|
|
7
|
+
BoardIcon,
|
|
8
|
+
BoltIcon,
|
|
9
|
+
CalendarIcon,
|
|
10
|
+
CamIcon,
|
|
11
|
+
CamOffIcon,
|
|
12
|
+
ChatIcon,
|
|
13
|
+
CheckIcon,
|
|
14
|
+
CommentIcon,
|
|
15
|
+
FlagIcon,
|
|
16
|
+
GridIcon,
|
|
17
|
+
HandIcon,
|
|
18
|
+
LeaveIcon,
|
|
19
|
+
LockIcon,
|
|
20
|
+
MicIcon,
|
|
21
|
+
MicOffIcon,
|
|
22
|
+
MoreIcon,
|
|
23
|
+
PlusIcon,
|
|
24
|
+
PresentIcon,
|
|
25
|
+
RefreshIcon,
|
|
26
|
+
ScreenIcon,
|
|
27
|
+
SignalIcon,
|
|
28
|
+
SmileIcon,
|
|
29
|
+
SpeakerIcon,
|
|
30
|
+
UsersIcon,
|
|
31
|
+
XIcon,
|
|
32
|
+
iconSet,
|
|
33
|
+
} from '@kerf-js/veneer-icons'
|
|
34
|
+
import { hueOf } from '@kerf-js/veneer-core'
|
|
35
|
+
import { Box } from '@kerf-js/core/internal'
|
|
36
|
+
import { state, untrack, type State } from '@kerf-js/core'
|
|
37
|
+
|
|
38
|
+
const GLYPHS = {
|
|
39
|
+
bell: BellIcon,
|
|
40
|
+
at: AtIcon,
|
|
41
|
+
comment: CommentIcon,
|
|
42
|
+
flag: FlagIcon,
|
|
43
|
+
check: CheckIcon,
|
|
44
|
+
alert: AlertIcon,
|
|
45
|
+
cal: CalendarIcon,
|
|
46
|
+
more: MoreIcon,
|
|
47
|
+
x: XIcon,
|
|
48
|
+
plus: PlusIcon,
|
|
49
|
+
lock: LockIcon,
|
|
50
|
+
refresh: RefreshIcon,
|
|
51
|
+
bolt: BoltIcon,
|
|
52
|
+
mic: MicIcon,
|
|
53
|
+
micoff: MicOffIcon,
|
|
54
|
+
cam: CamIcon,
|
|
55
|
+
camoff: CamOffIcon,
|
|
56
|
+
screen: ScreenIcon,
|
|
57
|
+
hand: HandIcon,
|
|
58
|
+
smile: SmileIcon,
|
|
59
|
+
chat: ChatIcon,
|
|
60
|
+
users: UsersIcon,
|
|
61
|
+
leave: LeaveIcon,
|
|
62
|
+
signal: SignalIcon,
|
|
63
|
+
grid: GridIcon,
|
|
64
|
+
speaker: SpeakerIcon,
|
|
65
|
+
present: PresentIcon,
|
|
66
|
+
board: BoardIcon,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type GlyphName = keyof typeof GLYPHS
|
|
70
|
+
export const G = iconSet(GLYPHS)
|
|
71
|
+
|
|
72
|
+
/** A prop that may be a value, a box with `.value` (State, Signal, Resource) or a getter. */
|
|
73
|
+
export function val<T>(v: T | { value: T } | (() => T)): T {
|
|
74
|
+
if (typeof v === 'function') return (v as () => T)()
|
|
75
|
+
if (v !== null && typeof v === 'object' && !Array.isArray(v) && 'value' in (v as object))
|
|
76
|
+
return (v as { value: T }).value
|
|
77
|
+
return v as T
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const isState = (v: unknown): v is State<unknown> => v instanceof Box
|
|
81
|
+
|
|
82
|
+
/** One read and write over a bound State, a controlled value and a default (the Picker `bindable`, without its CSS). */
|
|
83
|
+
export function held<T>(
|
|
84
|
+
value: () => State<T> | T | undefined,
|
|
85
|
+
fallback: T,
|
|
86
|
+
on?: () => ((v: T) => void) | undefined,
|
|
87
|
+
) {
|
|
88
|
+
const own = state<T>(
|
|
89
|
+
untrack(() => {
|
|
90
|
+
const v = value()
|
|
91
|
+
return isState(v) ? fallback : (v ?? fallback)
|
|
92
|
+
}),
|
|
93
|
+
)
|
|
94
|
+
return {
|
|
95
|
+
get value(): T {
|
|
96
|
+
const v = value()
|
|
97
|
+
return isState(v) ? v.value : v !== undefined ? v : own.value
|
|
98
|
+
},
|
|
99
|
+
set(next: T) {
|
|
100
|
+
const v = untrack(value)
|
|
101
|
+
if (isState(v)) v.value = next
|
|
102
|
+
else own.value = next
|
|
103
|
+
untrack(() => on?.())?.(next)
|
|
104
|
+
},
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** The avatar and tile tint for a person: the data palette, never a status colour (07 §0). */
|
|
109
|
+
export const avatarTint = (id: string) =>
|
|
110
|
+
`--_bg:color-mix(in oklab,var(--veneer-color-data-${hueOf(id)}) 26%,var(--veneer-color-surface-raised))`
|
package/src/parts.tsx
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { CheckIcon } from '@kerf-js/veneer-icons'
|
|
2
|
+
// Small 05 and 02 atoms the app patterns and flows share, each the specimen markup. Internal: not exported from the
|
|
3
|
+
// index, so a pack that needs one pays only for its own CSS.
|
|
4
|
+
import { derived } from '@kerf-js/core'
|
|
5
|
+
import type { Tone } from './Button'
|
|
6
|
+
import { Icon, toneIcon } from './Icon'
|
|
7
|
+
import './styles'
|
|
8
|
+
import '@kerf-js/veneer-core/styles/app/tokens.css'
|
|
9
|
+
import '@kerf-js/veneer-core/styles/app/avatar.css'
|
|
10
|
+
import '@kerf-js/veneer-core/styles/components/badge.css' // the status dot
|
|
11
|
+
import '@kerf-js/veneer-core/styles/components/empty-state.css'
|
|
12
|
+
import '@kerf-js/veneer-core/styles/components/live-status.css'
|
|
13
|
+
import '@kerf-js/veneer-core/styles/components/spinner.css'
|
|
14
|
+
import '@kerf-js/veneer-core/styles/components/steps.css'
|
|
15
|
+
import '@kerf-js/veneer-core/styles/layout/tokens.css'
|
|
16
|
+
import '@kerf-js/veneer-core/styles/layout/banner.css'
|
|
17
|
+
|
|
18
|
+
/** One path on the 24 grid, for a glyph the shared Icon set doesn't carry. */
|
|
19
|
+
export const Glyph = ({ d, ...rest }: { d: string; [attr: string]: unknown }) => (
|
|
20
|
+
<svg data-icon viewBox="0 0 24 24" aria-hidden="true" focusable="false" {...rest}>
|
|
21
|
+
<path d={d} />
|
|
22
|
+
</svg>
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
export const initials = (name: string) =>
|
|
26
|
+
name
|
|
27
|
+
.split(/\s+/)
|
|
28
|
+
.filter(Boolean)
|
|
29
|
+
.slice(0, 2)
|
|
30
|
+
.map((w) => w[0])
|
|
31
|
+
.join('')
|
|
32
|
+
.toUpperCase()
|
|
33
|
+
|
|
34
|
+
/** Avatar with initials (07 §0); `name` is real text for the row around it, so the circle itself is aria-hidden. */
|
|
35
|
+
export function Avatar({
|
|
36
|
+
name,
|
|
37
|
+
size,
|
|
38
|
+
status,
|
|
39
|
+
presence,
|
|
40
|
+
...rest
|
|
41
|
+
}: {
|
|
42
|
+
name: string
|
|
43
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | undefined
|
|
44
|
+
status?: Tone | undefined
|
|
45
|
+
presence?: number | undefined
|
|
46
|
+
[attr: string]: unknown
|
|
47
|
+
}) {
|
|
48
|
+
return (
|
|
49
|
+
<span
|
|
50
|
+
data-scope="avatar"
|
|
51
|
+
data-size={size === 'md' ? undefined : size}
|
|
52
|
+
data-presence={presence}
|
|
53
|
+
aria-hidden="true"
|
|
54
|
+
{...rest}
|
|
55
|
+
>
|
|
56
|
+
{initials(name)}
|
|
57
|
+
{status && <span data-scope="status-dot" data-tone={status}></span>}
|
|
58
|
+
</span>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Where a live connection stands. */
|
|
63
|
+
export type LiveState = 'connecting' | 'live' | 'reconnecting' | 'offline'
|
|
64
|
+
const LIVE: Record<LiveState, string> = {
|
|
65
|
+
connecting: 'Connecting',
|
|
66
|
+
live: 'Live',
|
|
67
|
+
reconnecting: 'Reconnecting',
|
|
68
|
+
offline: 'Offline',
|
|
69
|
+
}
|
|
70
|
+
const DOT: Partial<Record<LiveState, Tone>> = { live: 'positive', offline: 'critical' }
|
|
71
|
+
|
|
72
|
+
/** The one realtime pill (07 §4.4): quiet while live, loud only in trouble. */
|
|
73
|
+
export function LiveStatus({
|
|
74
|
+
state,
|
|
75
|
+
label,
|
|
76
|
+
children,
|
|
77
|
+
}: {
|
|
78
|
+
state: LiveState
|
|
79
|
+
label?: string | undefined
|
|
80
|
+
children?: unknown
|
|
81
|
+
}) {
|
|
82
|
+
const dot = derived(() => DOT[state])
|
|
83
|
+
return (
|
|
84
|
+
<span
|
|
85
|
+
data-scope="live-status"
|
|
86
|
+
data-state={state}
|
|
87
|
+
role="status"
|
|
88
|
+
aria-label={label ? `${label}: ${LIVE[state].toLowerCase()}` : undefined}
|
|
89
|
+
>
|
|
90
|
+
{dot.value ? (
|
|
91
|
+
<span data-scope="status-dot" data-tone={dot.value}></span>
|
|
92
|
+
) : (
|
|
93
|
+
<span data-scope="spinner" aria-hidden="true"></span>
|
|
94
|
+
)}
|
|
95
|
+
{children ?? LIVE[state]}
|
|
96
|
+
</span>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Page-level message inside main (02 §5). `live` announces it; a Banner that was there on load stays role=note. */
|
|
101
|
+
export function Banner({
|
|
102
|
+
tone = 'info',
|
|
103
|
+
live,
|
|
104
|
+
actions,
|
|
105
|
+
children,
|
|
106
|
+
...rest
|
|
107
|
+
}: {
|
|
108
|
+
tone?: Tone | undefined
|
|
109
|
+
live?: 'polite' | 'assertive' | undefined
|
|
110
|
+
actions?: unknown
|
|
111
|
+
children?: unknown
|
|
112
|
+
[attr: string]: unknown
|
|
113
|
+
}) {
|
|
114
|
+
// a colour named in veneer({ colors }) takes the neutral icon
|
|
115
|
+
const icon = derived(() => toneIcon[tone as keyof typeof toneIcon] ?? toneIcon.neutral)
|
|
116
|
+
const acts = derived(() => actions) // one build, however often it is read
|
|
117
|
+
return (
|
|
118
|
+
<div
|
|
119
|
+
data-scope="banner"
|
|
120
|
+
data-tone={tone === 'info' ? undefined : tone}
|
|
121
|
+
role={live === 'assertive' ? 'alert' : live ? 'status' : 'note'}
|
|
122
|
+
{...rest}
|
|
123
|
+
>
|
|
124
|
+
<span data-part="icon">
|
|
125
|
+
<Icon name={icon.value} />
|
|
126
|
+
</span>
|
|
127
|
+
<div data-part="body">{children}</div>
|
|
128
|
+
{acts.value !== undefined && <div data-part="actions">{acts.value}</div>}
|
|
129
|
+
</div>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type Step = { id: string; title: unknown; description?: unknown; error?: boolean }
|
|
134
|
+
|
|
135
|
+
/** Steps (05 §4): full labels, the compact count from the CSS. `current` is an index. */
|
|
136
|
+
export function Steps({
|
|
137
|
+
label,
|
|
138
|
+
steps,
|
|
139
|
+
current,
|
|
140
|
+
}: {
|
|
141
|
+
label: string
|
|
142
|
+
steps: Step[]
|
|
143
|
+
current: number
|
|
144
|
+
}) {
|
|
145
|
+
return (
|
|
146
|
+
<div data-scope="steps">
|
|
147
|
+
<ol aria-label={label}>
|
|
148
|
+
{steps.map((s, i) => (
|
|
149
|
+
<li
|
|
150
|
+
key={s.id}
|
|
151
|
+
data-part="item"
|
|
152
|
+
data-state={
|
|
153
|
+
s.error ? 'error' : i < current ? 'complete' : i === current ? 'current' : undefined
|
|
154
|
+
}
|
|
155
|
+
aria-current={i === current ? 'step' : undefined}
|
|
156
|
+
>
|
|
157
|
+
<span data-part="indicator">
|
|
158
|
+
<CheckIcon />
|
|
159
|
+
</span>
|
|
160
|
+
<span data-part="title">{s.title}</span>
|
|
161
|
+
{s.description !== undefined && <span data-part="description">{s.description}</span>}
|
|
162
|
+
</li>
|
|
163
|
+
))}
|
|
164
|
+
</ol>
|
|
165
|
+
</div>
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Empty or error state (05 §5): the weave art, a title, one sentence, actions. */
|
|
170
|
+
export function EmptyState({
|
|
171
|
+
title,
|
|
172
|
+
tone,
|
|
173
|
+
actions,
|
|
174
|
+
children,
|
|
175
|
+
...rest
|
|
176
|
+
}: {
|
|
177
|
+
title: unknown
|
|
178
|
+
tone?: Tone | undefined
|
|
179
|
+
actions?: unknown
|
|
180
|
+
children?: unknown
|
|
181
|
+
[attr: string]: unknown
|
|
182
|
+
}) {
|
|
183
|
+
const acts = derived(() => actions)
|
|
184
|
+
const body = derived(() => children)
|
|
185
|
+
return (
|
|
186
|
+
<div data-scope="empty-state" data-tone={tone} {...rest}>
|
|
187
|
+
<svg data-part="art" viewBox="0 0 96 64" aria-hidden="true">
|
|
188
|
+
<g class="w">
|
|
189
|
+
<path d="M12 4v56M28 4v56M44 4v56M60 4v56M76 4v56" />
|
|
190
|
+
</g>
|
|
191
|
+
<path class="f" d="M4 24H92" />
|
|
192
|
+
<path class="f" d="M4 40H92" style="stroke:var(--veneer-color-border-strong)" />
|
|
193
|
+
</svg>
|
|
194
|
+
<h2 data-part="title">{title}</h2>
|
|
195
|
+
{body.value !== undefined && <p data-part="description">{body.value}</p>}
|
|
196
|
+
{acts.value !== undefined && <div data-part="actions">{acts.value}</div>}
|
|
197
|
+
</div>
|
|
198
|
+
)
|
|
199
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// The components and summaries contributed by the veneer plugin.
|
|
2
|
+
const components = [
|
|
3
|
+
['Stack', 'Vertical flow; `gap` is the relationship'],
|
|
4
|
+
['Row', 'Horizontal cluster that wraps; `justify`, `reflow` to stack below a step'],
|
|
5
|
+
['Grid', 'Intrinsic columns by `min`, capped by `cols`'],
|
|
6
|
+
['Split', 'Fixed side and fluid main, stacked below its step'],
|
|
7
|
+
['Center', 'Measured column, centred; `max`, `gutter`'],
|
|
8
|
+
['Cover', 'Fills the screen with one centred child (auth, errors)'],
|
|
9
|
+
['Frame', 'Fixed-ratio media box'],
|
|
10
|
+
['Spacer', 'Takes the free space in a Row or Stack'],
|
|
11
|
+
['Inset', 'Sunken padded region'],
|
|
12
|
+
['Heading', 'Real heading: `level` is the outline and picks the look; `role` overrides it'],
|
|
13
|
+
['Text', 'Text in a role: `role`, `tone`, `subtle`, `faint`'],
|
|
14
|
+
['Link', "A link: `href`, `subtle`, `external`; a bare `<a>` still gets veneer's colour"],
|
|
15
|
+
['VirtualList', 'A long list with exact text heights: rows render only in view'],
|
|
16
|
+
['Thread', 'A chat log on a window: stick to end, older messages, unread divider'],
|
|
17
|
+
['Feed', 'APG feed on a window with Page Up/Down between articles'],
|
|
18
|
+
['Kanban', 'A board whose columns are windows; drag, menu and Alt + arrows'],
|
|
19
|
+
['ScrollGrid', 'Read-only two-axis grid, both axes virtual, wrapped columns optional'],
|
|
20
|
+
['DateField', 'Typed date segments with a calendar; ISO value'],
|
|
21
|
+
['DateRangeField', 'Two date segments, range calendar, presets, compare'],
|
|
22
|
+
['TimeField', 'Typed time with a slot list or wheels'],
|
|
23
|
+
['DateTimeField', 'Date and time in one field; value is a plain date-time'],
|
|
24
|
+
['InlineCalendar', 'The calendar grid in the page: single, multiple, range'],
|
|
25
|
+
['MonthPicker', 'Month grid in a field'],
|
|
26
|
+
['WeekPicker', 'Week selection with week numbers'],
|
|
27
|
+
['PeriodPicker', 'Year, quarter, month or week in one trigger'],
|
|
28
|
+
['TimeZoneSelect', 'Searchable IANA zones with offsets'],
|
|
29
|
+
['CountrySelect', 'Searchable countries, names from Intl'],
|
|
30
|
+
['LanguageSelect', 'Searchable languages with endonyms'],
|
|
31
|
+
['CurrencySelect', 'Searchable currencies with symbols'],
|
|
32
|
+
['PhoneField', 'Country button and tel input; E.164 value'],
|
|
33
|
+
['DurationField', 'Spinbuttons per unit; ISO duration, balanced'],
|
|
34
|
+
['RecurrenceField', 'RRULE builder in plain language with next dates'],
|
|
35
|
+
['PlaceLookupInput', 'Place combobox over your search()'],
|
|
36
|
+
['AddressField', 'Country-first address, optional provider, manual fallback'],
|
|
37
|
+
['PaymentCardInput', "Field shell around the provider's hosted card field"],
|
|
38
|
+
['CardNumberText', 'Saved card display'],
|
|
39
|
+
['SignaturePad', 'Draw or type a signature'],
|
|
40
|
+
[
|
|
41
|
+
'Button',
|
|
42
|
+
'Native button: tone, emphasis (solid soft outline ghost frame link), size, loading, icon-only; `collapse` shows only the icon on a phone or tablet and keeps the text as its name',
|
|
43
|
+
],
|
|
44
|
+
['Toggle', 'Button with aria-pressed'],
|
|
45
|
+
['Input', 'Text field: floating border label (or classic), hint, error, prefix, suffix, clear'],
|
|
46
|
+
['Search', 'Search field with icon and clear'],
|
|
47
|
+
['Textarea', 'Multi-line field that grows 3 to 10 lines; Cmd/Ctrl+Enter submits'],
|
|
48
|
+
['Select', 'Native select in the field shell'],
|
|
49
|
+
['Checkbox', 'Native checkbox; indeterminate'],
|
|
50
|
+
['Switch', 'Checkbox with role switch; the rail fills with the sweep'],
|
|
51
|
+
['Segmented', 'Radio group with a sliding face'],
|
|
52
|
+
['Chip', 'Filter chip (aria-pressed)'],
|
|
53
|
+
['Tabs', 'Tablist (line, pill, enclosed) with panels'],
|
|
54
|
+
['Card', 'Surface: eyebrow, title, body; sweeps only with the sweep prop'],
|
|
55
|
+
['Badge', 'Status or count; status dot'],
|
|
56
|
+
['Tag', 'User label, removable'],
|
|
57
|
+
['Kbd', 'One keyboard key'],
|
|
58
|
+
['Alert', 'Inline message with icon, title, description, actions'],
|
|
59
|
+
['Progress', 'Linear or circular progress; indeterminate'],
|
|
60
|
+
['Spinner', 'Busy indicator'],
|
|
61
|
+
['Skeleton', 'Loading placeholder: text, circle, block'],
|
|
62
|
+
['Tooltip', 'Hint on hover and keyboard focus (never essential)'],
|
|
63
|
+
['Popover', 'Button that opens a non-modal dialog panel'],
|
|
64
|
+
['Modal', 'Native modal dialog; alert dialog'],
|
|
65
|
+
['Drawer', 'Sheet: side on wide screens, bottom on phones'],
|
|
66
|
+
[
|
|
67
|
+
'HamburgerMenu',
|
|
68
|
+
"Main navigation on phones: the site's top links only, full-screen. Never a section's pages (that is SideNav)",
|
|
69
|
+
],
|
|
70
|
+
['Toaster', 'Toast region; toast.show() from anywhere'],
|
|
71
|
+
[
|
|
72
|
+
'Table',
|
|
73
|
+
'Data table: sort, filter, Columns, resize, pin, selection, bulk bar, details, inline edit, live cells, phone cards',
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
'LineChart',
|
|
77
|
+
'Line or area chart: multi-series, crosshair, annotations, reference lines, live tween',
|
|
78
|
+
],
|
|
79
|
+
['BarChart', 'Bars: grouped, stacked or percent (`layout`)'],
|
|
80
|
+
['ComboChart', 'Bars plus a moving average on one axis'],
|
|
81
|
+
['DonutChart', 'Donut or `pie`, centre readout'],
|
|
82
|
+
['RadialChart', '270° radial bars'],
|
|
83
|
+
['FunnelChart', 'Step bars with % of previous'],
|
|
84
|
+
['ScatterChart', 'Points, shape per group'],
|
|
85
|
+
['BubbleChart', 'Points sized by value'],
|
|
86
|
+
['Histogram', 'Bins with p50 and p95'],
|
|
87
|
+
['HeatGrid', 'Week by day heatmap; calendar at 52 weeks'],
|
|
88
|
+
['RadarChart', 'Polygons on up to 3 series'],
|
|
89
|
+
['Treemap', 'Squarified areas'],
|
|
90
|
+
['Sunburst', 'Two-ring part to whole'],
|
|
91
|
+
['SankeyChart', 'Flows between columns'],
|
|
92
|
+
['CandlestickChart', 'Candles or `variant="ohlc"`'],
|
|
93
|
+
['BoxPlot', 'Quartiles, whiskers, outliers'],
|
|
94
|
+
['WaterfallChart', 'Bridge with totals'],
|
|
95
|
+
['StreamChart', 'Rolling window on a fixed domain, Pause'],
|
|
96
|
+
['BrushChart', 'Overview and brush window'],
|
|
97
|
+
['TileMap', 'Tile-grid choropleth'],
|
|
98
|
+
['GaugeChart', 'Banded gauge with a needle'],
|
|
99
|
+
['Sparkline', 'Inline trend, aria-hidden inside a labelled parent'],
|
|
100
|
+
[
|
|
101
|
+
'Shell',
|
|
102
|
+
'App shell: bottom bar, rail or sidebar by its own width; header, account menu, More sheet, focus variant',
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
'ScrollRail',
|
|
106
|
+
'The page scrollbar drawn from below a sticky header (--veneer-scroll-rail-top); fine pointers only, touch keeps native',
|
|
107
|
+
],
|
|
108
|
+
[
|
|
109
|
+
'ScrollView',
|
|
110
|
+
'Scrolling run in JavaScript (@kerf-js/scroll): native-feeling wheel, touch, keys and focus, bars drawn in the DOM or on a canvas, fixed-size thumb, snap points',
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
'Presence',
|
|
114
|
+
'Show and hide with an entrance and an exit (collapse, fade, rise, pop, slide-*); no-JS form: hidden + data-collapse / data-presence',
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
'SideNavTitle',
|
|
118
|
+
'Header brand that slides to the open SideNav\'s title on phones; pair with SideNav overlay="under"',
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
'SideNav',
|
|
122
|
+
'Side navigation: the pages inside one section, on every screen size; folds when docked, a bar that opens over the page on phones. overlay cover|under. Never the site top links (that is HamburgerMenu)',
|
|
123
|
+
],
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
/** Build the component catalog contributed by veneer. */
|
|
127
|
+
export function componentCatalog() {
|
|
128
|
+
return components.map(([name, summary]) => ({ name, import: '@kerf-js/veneer', summary }))
|
|
129
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Export resolved veneer tokens in the DTCG format.
|
|
2
|
+
import { execFileSync } from 'node:child_process'
|
|
3
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
4
|
+
import { tmpdir } from 'node:os'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
|
|
8
|
+
/** The resolved tokens as DTCG 2025.10: one token file per theme × expression and a resolver over them. `css`: the app's seed and overrides. */
|
|
9
|
+
export function dtcgTokens(css, core) {
|
|
10
|
+
const dir = mkdtempSync(join(tmpdir(), 'veneer-seed-'))
|
|
11
|
+
let resolved
|
|
12
|
+
try {
|
|
13
|
+
const file = join(dir, 'veneer.css')
|
|
14
|
+
writeFileSync(
|
|
15
|
+
file,
|
|
16
|
+
readFileSync(new URL('styles/veneer.css', core), 'utf8') +
|
|
17
|
+
`\n${css.replace(/@layer veneer\.\w+\{([\s\S]*)\}\n?$/gm, '$1')}\n`,
|
|
18
|
+
)
|
|
19
|
+
let out
|
|
20
|
+
try {
|
|
21
|
+
out = execFileSync(
|
|
22
|
+
process.execPath,
|
|
23
|
+
[fileURLToPath(new URL('scripts/contrast-check.mjs', core)), file, '--json'],
|
|
24
|
+
{ encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] },
|
|
25
|
+
)
|
|
26
|
+
} catch (e) {
|
|
27
|
+
out = e.stdout
|
|
28
|
+
}
|
|
29
|
+
resolved = JSON.parse(out).resolved
|
|
30
|
+
} finally {
|
|
31
|
+
rmSync(dir, { recursive: true, force: true })
|
|
32
|
+
}
|
|
33
|
+
const px = (value) => ({ $value: { value, unit: 'px' } })
|
|
34
|
+
const SPACE = { hair: 2, tight: 4, related: 8, group: 16 }
|
|
35
|
+
const X = { quiet: 0, balanced: 0.5, vivid: 1 }
|
|
36
|
+
const files = {}
|
|
37
|
+
for (const [combo, colours] of Object.entries(resolved)) {
|
|
38
|
+
const [theme, expression] = combo.split('/')
|
|
39
|
+
const x = X[expression]
|
|
40
|
+
const color = Object.fromEntries(
|
|
41
|
+
Object.entries(colours)
|
|
42
|
+
.filter(([, v]) => /^#[0-9a-f]{6}$/i.test(v))
|
|
43
|
+
.map(([name, code]) => [
|
|
44
|
+
name,
|
|
45
|
+
{
|
|
46
|
+
$value: {
|
|
47
|
+
colorSpace: 'srgb',
|
|
48
|
+
components: [1, 3, 5].map((i) => parseInt(code.slice(i, i + 2), 16) / 255),
|
|
49
|
+
hex: code,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
]),
|
|
53
|
+
)
|
|
54
|
+
files[`veneer.${theme}.${expression}.tokens.json`] = {
|
|
55
|
+
color: { $type: 'color', ...color },
|
|
56
|
+
space: {
|
|
57
|
+
$type: 'dimension',
|
|
58
|
+
...Object.fromEntries(Object.entries(SPACE).map(([k, v]) => [k, px(v)])),
|
|
59
|
+
},
|
|
60
|
+
radius: {
|
|
61
|
+
$type: 'dimension',
|
|
62
|
+
mark: px(Math.round(4 - 2 * x)),
|
|
63
|
+
control: px(Math.round(8 - 6 * x)),
|
|
64
|
+
surface: px(Math.round(12 - 10 * x)),
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Each file is whole, so one modifier picks one file: the dials don't layer in DTCG terms.
|
|
69
|
+
const contexts = Object.fromEntries(
|
|
70
|
+
Object.keys(files).map((f) => [f.split('.').slice(1, 3).join('-'), [{ $ref: f }]]),
|
|
71
|
+
)
|
|
72
|
+
files['veneer.resolver.json'] = {
|
|
73
|
+
name: 'veneer',
|
|
74
|
+
version: '2025.10',
|
|
75
|
+
modifiers: { mode: { contexts, default: 'light-balanced' } },
|
|
76
|
+
resolutionOrder: [{ $ref: '#/modifiers/mode' }],
|
|
77
|
+
}
|
|
78
|
+
return files
|
|
79
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// The icon tier each expression stop draws (veneer.css §2: --veneer-icon-*). `veneer({ icons })` pins one whatever the
|
|
2
|
+
// expression, the way `radius` replaces the corners each stop sets.
|
|
3
|
+
export const ICONS = {
|
|
4
|
+
quiet: { o: 'inline', q: 'inline', b: 'none', v: 'none', fine: 'none', kerf: 1.5 },
|
|
5
|
+
balanced: { o: 'inline', q: 'none', b: 'inline', v: 'none', fine: 'inline', kerf: 2 },
|
|
6
|
+
vivid: { o: 'none', q: 'none', b: 'none', v: 'inline', fine: 'inline', kerf: 2 },
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// A seed: the accent (and optionally neutral) hue and chroma the palette grows from, given as OKLCH or as #rrggbb.
|
|
2
|
+
import { fromHex } from '../../tokens/color.mjs'
|
|
3
|
+
|
|
4
|
+
/** kerf's own accent, the green every untouched app starts from. */
|
|
5
|
+
export const DEFAULT = { hue: 152, chroma: 0.115 }
|
|
6
|
+
|
|
7
|
+
function hueOf(value, name) {
|
|
8
|
+
if (typeof value === 'string') {
|
|
9
|
+
if (!/^#[0-9a-f]{6}$/i.test(value)) throw new Error(`${name} must be #rrggbb`)
|
|
10
|
+
const { C, H } = fromHex(value)
|
|
11
|
+
return { hue: Math.round(H * 10) / 10, chroma: Math.round(C * 1000) / 1000 }
|
|
12
|
+
}
|
|
13
|
+
const { hue, chroma } = value ?? {}
|
|
14
|
+
if (!(hue >= 0 && hue < 360) || !(chroma >= 0 && chroma <= 0.37))
|
|
15
|
+
throw new Error(
|
|
16
|
+
`${name === 'accent' ? 'seed' : name} is { hue: 0–360, chroma: 0–0.37 } or ${name === 'accent' ? '{ accent: "#rrggbb" }' : '"#rrggbb"'}`,
|
|
17
|
+
) // kerf reports it as P115
|
|
18
|
+
return { hue, chroma }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** `seed` as `{ hue, chroma, neutral? }`; throws (P115) on a value out of range. */
|
|
22
|
+
export function normalizeSeed(seed) {
|
|
23
|
+
const { accent, neutral, ...rest } = seed ?? {}
|
|
24
|
+
const out = hueOf(
|
|
25
|
+
accent ?? (Object.keys(rest).length || neutral === undefined ? rest : DEFAULT),
|
|
26
|
+
'accent',
|
|
27
|
+
)
|
|
28
|
+
return neutral === undefined ? out : { ...out, neutral: hueOf(neutral, 'neutral') }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** `seed` with a colour name from `colors` (`{ accent: 'brand' }`) swapped for the colour it names. */
|
|
32
|
+
export function seedByName(seed, colors = {}) {
|
|
33
|
+
if (!seed || typeof seed !== 'object') return seed
|
|
34
|
+
const swap = (v) => (typeof v === 'string' && typeof colors[v] === 'string' ? colors[v] : v)
|
|
35
|
+
return {
|
|
36
|
+
...seed,
|
|
37
|
+
...(seed.accent !== undefined && { accent: swap(seed.accent) }),
|
|
38
|
+
...(seed.neutral !== undefined && { neutral: swap(seed.neutral) }),
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The stylesheet facts the theming CSS needs, read from veneer-core's veneer.css. Node only; theme.mjs takes the result.
|
|
2
|
+
import { readFileSync } from 'node:fs'
|
|
3
|
+
|
|
4
|
+
let context
|
|
5
|
+
/** Facts read once from veneer-core's stylesheet: sub-layer order, scope roots, token names and the accent formulas. */
|
|
6
|
+
export function themeContext(core) {
|
|
7
|
+
if (context) return context
|
|
8
|
+
const css = readFileSync(new URL('styles/veneer.css', core), 'utf8').replace(
|
|
9
|
+
/\/\*[\s\S]*?\*\//g,
|
|
10
|
+
'',
|
|
11
|
+
)
|
|
12
|
+
const layers = /@layer (veneer\.tokens[^;]*);/
|
|
13
|
+
.exec(css)[1]
|
|
14
|
+
.split(',')
|
|
15
|
+
.map((l) => l.trim().slice('veneer.'.length))
|
|
16
|
+
const scopes = /\n(:root, \[data-expression\][^{]*)\{/.exec(css)[1].replace(/\s+/g, ' ').trim()
|
|
17
|
+
const tokenNames = new Set(css.match(/--veneer-[a-z0-9-]+(?=\s*:)/g))
|
|
18
|
+
const formula = (name) =>
|
|
19
|
+
new RegExp(`--veneer-color-accent-${name}:\\s*([^;]+);`).exec(css)[1].replace(/\s+/g, ' ')
|
|
20
|
+
const formulas = {
|
|
21
|
+
'--_solid': formula('solid'),
|
|
22
|
+
'--_solid-hover': formula('solid-hover'),
|
|
23
|
+
'--_ink-on': formula('on-solid'),
|
|
24
|
+
'--_soft': formula('soft'),
|
|
25
|
+
'--_text': formula('text'),
|
|
26
|
+
'--_border': formula('border'),
|
|
27
|
+
}
|
|
28
|
+
// An expression stop picks some refs by colour token (the primary is the accent, or ink at quiet). Those resolve where
|
|
29
|
+
// the stop is declared, so a palette set below it needs them declared again, per stop (themeCss).
|
|
30
|
+
const stopRefs = (sel) => {
|
|
31
|
+
const at = css.indexOf(`\n${sel} {`)
|
|
32
|
+
const body = css.slice(css.indexOf('{', at) + 1, css.indexOf('\n}', at))
|
|
33
|
+
return (body.match(/--veneer-ref-[a-z0-9-]+:\s*[^;]*var\(--veneer-color-[^;]+;/g) ?? [])
|
|
34
|
+
.map((d) => d.replace(/\s+/g, ' '))
|
|
35
|
+
.join('')
|
|
36
|
+
}
|
|
37
|
+
const stops = {
|
|
38
|
+
balanced: stopRefs(':root, [data-expression="balanced"]'),
|
|
39
|
+
quiet: stopRefs('[data-expression="quiet"]'),
|
|
40
|
+
vivid: stopRefs('[data-expression="vivid"]'),
|
|
41
|
+
}
|
|
42
|
+
context = { layers, scopes, tokenNames, formulas, stops }
|
|
43
|
+
return context
|
|
44
|
+
}
|