@krizaka/ui 3.64.1 → 3.65.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/dist/account-menu.d.ts +7 -3
- package/dist/account-menu.js +14 -10
- package/dist/account-menu.js.map +1 -1
- package/dist/app-frame/server.d.ts +123 -0
- package/dist/app-frame/server.js +109 -0
- package/dist/app-frame/server.js.map +1 -0
- package/dist/app-frame.d.ts +210 -0
- package/dist/app-frame.js +220 -0
- package/dist/app-frame.js.map +1 -0
- package/dist/desktop-window.d.ts +223 -0
- package/dist/desktop-window.js +261 -0
- package/dist/desktop-window.js.map +1 -0
- package/dist/file-upload.d.ts +2 -2
- package/dist/filter-bar.d.ts +3 -3
- package/dist/language-switch.d.ts +9 -9
- package/dist/native.d.ts +218 -3
- package/dist/native.js +1638 -1450
- package/dist/native.js.map +1 -1
- package/dist/theme.d.ts +3 -1
- package/dist/theme.js +4 -0
- package/dist/theme.js.map +1 -1
- package/package.json +47 -5
- package/registry/account-menu.json +22 -8
- package/registry/account-settings.json +1 -1
- package/registry/achievement.json +1 -1
- package/registry/action-bar.json +1 -1
- package/registry/activity-feed.json +1 -1
- package/registry/agenda.json +1 -1
- package/registry/alert.json +1 -1
- package/registry/analysis-report.json +1 -1
- package/registry/anatomy-plate.json +1 -1
- package/registry/app-frame.json +564 -0
- package/registry/app-header.json +1 -1
- package/registry/app-shell.json +1 -1
- package/registry/argument-card.json +1 -1
- package/registry/audio-player.json +1 -1
- package/registry/auth-layout.json +1 -1
- package/registry/avatar.json +1 -1
- package/registry/badge.json +1 -1
- package/registry/bird-plate.json +1 -1
- package/registry/button.json +1 -1
- package/registry/captcha.json +1 -1
- package/registry/card-grid.json +1 -1
- package/registry/card.json +1 -1
- package/registry/catalogue-page.json +1 -1
- package/registry/changelog-page.json +1 -1
- package/registry/chapter.json +1 -1
- package/registry/chat.json +1 -1
- package/registry/checkbox.json +1 -1
- package/registry/chip-link.json +1 -1
- package/registry/chip-row.json +1 -1
- package/registry/chip.json +1 -1
- package/registry/choice-grid.json +1 -1
- package/registry/code-block.json +1 -1
- package/registry/combobox.json +1 -1
- package/registry/command.json +1 -1
- package/registry/comparison-table.json +1 -1
- package/registry/component-page.json +1 -1
- package/registry/confirm-button.json +1 -1
- package/registry/contact-page.json +1 -1
- package/registry/continue-prompt.json +1 -1
- package/registry/countdown.json +1 -1
- package/registry/cover-hero.json +1 -1
- package/registry/cta-panel.json +1 -1
- package/registry/dashboard-layout.json +1 -1
- package/registry/data-table.json +1 -1
- package/registry/date-picker.json +3 -3
- package/registry/decision-list.json +1 -1
- package/registry/description-list.json +1 -1
- package/registry/desktop-window.json +407 -0
- package/registry/detail-layout.json +1 -1
- package/registry/dialog.json +1 -1
- package/registry/docs-article-page.json +1 -1
- package/registry/docs-hub-page.json +1 -1
- package/registry/docs-layout.json +1 -1
- package/registry/docs-nav.json +1 -1
- package/registry/document-viewer.json +1 -1
- package/registry/doodle.json +1 -1
- package/registry/drop-overlay.json +1 -1
- package/registry/dropdown-menu.json +1 -1
- package/registry/elephant.json +2 -2
- package/registry/embed-facade.json +1 -1
- package/registry/empty-state.json +1 -1
- package/registry/engine-flow.json +1 -1
- package/registry/environment-notice.json +1 -1
- package/registry/error-page.json +1 -1
- package/registry/examples/app-frame/admin.d.ts +4 -0
- package/registry/examples/app-frame/admin.js +32 -0
- package/registry/examples/app-frame/admin.tsx +33 -0
- package/registry/examples/app-frame/app.d.ts +4 -0
- package/registry/examples/app-frame/app.js +53 -0
- package/registry/examples/app-frame/app.tsx +56 -0
- package/registry/examples/desktop-window/library.d.ts +4 -0
- package/registry/examples/desktop-window/library.js +49 -0
- package/registry/examples/desktop-window/library.tsx +58 -0
- package/registry/examples/form-flow/native/signup.d.ts +4 -0
- package/registry/examples/form-flow/native/signup.dark.png +0 -0
- package/registry/examples/form-flow/native/signup.js +26 -0
- package/registry/examples/form-flow/native/signup.light.png +0 -0
- package/registry/examples/form-flow/native/signup.tsx +23 -0
- package/registry/examples/grid/native/columns.d.ts +4 -0
- package/registry/examples/grid/native/columns.dark.png +0 -0
- package/registry/examples/grid/native/columns.js +23 -0
- package/registry/examples/grid/native/columns.light.png +0 -0
- package/registry/examples/grid/native/columns.tsx +20 -0
- package/registry/examples/grid/native/photos.d.ts +4 -0
- package/registry/examples/grid/native/photos.dark.png +0 -0
- package/registry/examples/grid/native/photos.js +14 -0
- package/registry/examples/grid/native/photos.light.png +0 -0
- package/registry/examples/grid/native/photos.tsx +18 -0
- package/registry/examples/grid/native/stats.d.ts +4 -0
- package/registry/examples/grid/native/stats.dark.png +0 -0
- package/registry/examples/grid/native/stats.js +22 -0
- package/registry/examples/grid/native/stats.light.png +0 -0
- package/registry/examples/grid/native/stats.tsx +24 -0
- package/registry/examples/list-detail/native/inbox.d.ts +4 -0
- package/registry/examples/list-detail/native/inbox.dark.png +0 -0
- package/registry/examples/list-detail/native/inbox.js +35 -0
- package/registry/examples/list-detail/native/inbox.light.png +0 -0
- package/registry/examples/list-detail/native/inbox.tsx +35 -0
- package/registry/examples/screen/native/dashboard.d.ts +4 -0
- package/registry/examples/screen/native/dashboard.dark.png +0 -0
- package/registry/examples/screen/native/dashboard.js +48 -0
- package/registry/examples/screen/native/dashboard.light.png +0 -0
- package/registry/examples/screen/native/dashboard.tsx +52 -0
- package/registry/examples/screen/native/settings-home.d.ts +4 -0
- package/registry/examples/screen/native/settings-home.dark.png +0 -0
- package/registry/examples/screen/native/settings-home.js +26 -0
- package/registry/examples/screen/native/settings-home.light.png +0 -0
- package/registry/examples/screen/native/settings-home.tsx +25 -0
- package/registry/examples/shop/hero-tv.js +1 -1
- package/registry/examples/shop/hero-tv.tsx +1 -1
- package/registry/examples/state-screen/native/empty.d.ts +4 -0
- package/registry/examples/state-screen/native/empty.dark.png +0 -0
- package/registry/examples/state-screen/native/empty.js +12 -0
- package/registry/examples/state-screen/native/empty.light.png +0 -0
- package/registry/examples/state-screen/native/empty.tsx +11 -0
- package/registry/examples/state-screen/native/error.d.ts +4 -0
- package/registry/examples/state-screen/native/error.dark.png +0 -0
- package/registry/examples/state-screen/native/error.js +21 -0
- package/registry/examples/state-screen/native/error.light.png +0 -0
- package/registry/examples/state-screen/native/error.tsx +17 -0
- package/registry/examples/state-screen/native/offline.d.ts +4 -0
- package/registry/examples/state-screen/native/offline.dark.png +0 -0
- package/registry/examples/state-screen/native/offline.js +15 -0
- package/registry/examples/state-screen/native/offline.light.png +0 -0
- package/registry/examples/state-screen/native/offline.tsx +12 -0
- package/registry/field.json +1 -1
- package/registry/file-upload.json +1 -1
- package/registry/filter-bar.json +1 -1
- package/registry/flock.json +1 -1
- package/registry/footnote.json +1 -1
- package/registry/force-update-screen.json +1 -1
- package/registry/form-flow.json +152 -0
- package/registry/form.json +1 -1
- package/registry/gallery-page.json +1 -1
- package/registry/genui.json +1 -1
- package/registry/glossary-term.json +1 -1
- package/registry/glossary.json +1 -1
- package/registry/glow-card.json +1 -1
- package/registry/goal-gauge.json +1 -1
- package/registry/grade-stamp.json +1 -1
- package/registry/grid.json +262 -0
- package/registry/how-it-works-page.json +1 -1
- package/registry/image-cropper.json +1 -1
- package/registry/index.json +314 -12
- package/registry/iso.json +1 -1
- package/registry/kanban.json +1 -1
- package/registry/kbd.json +1 -1
- package/registry/kind-config-editor.json +1 -1
- package/registry/kpi-explained.json +1 -1
- package/registry/landing-page.json +1 -1
- package/registry/landscape.json +1 -1
- package/registry/language-switch.json +1 -1
- package/registry/legal-page.json +1 -1
- package/registry/link-card.json +1 -1
- package/registry/list-detail.json +188 -0
- package/registry/list.json +1 -1
- package/registry/loader.json +1 -1
- package/registry/longform-page.json +1 -1
- package/registry/maintenance-screen.json +1 -1
- package/registry/map.json +2 -2
- package/registry/margin-layout.json +1 -1
- package/registry/markdown.json +1 -1
- package/registry/marketing-layout.json +1 -1
- package/registry/marquee.json +1 -1
- package/registry/mascot-quote.json +1 -1
- package/registry/mascot-state.json +1 -1
- package/registry/mascots.json +1 -1
- package/registry/match-dialog.json +1 -1
- package/registry/media-capture.json +1 -1
- package/registry/media-gallery.json +1 -1
- package/registry/media-grid.json +1 -1
- package/registry/meta-row.json +1 -1
- package/registry/meter.json +1 -1
- package/registry/nav-bar.json +2 -2
- package/registry/next-actions.json +1 -1
- package/registry/notification-preferences.json +1 -1
- package/registry/number-ticker.json +1 -1
- package/registry/onboarding.json +3 -0
- package/registry/opening-hours.json +1 -1
- package/registry/page-header.json +1 -1
- package/registry/page-hero.json +1 -1
- package/registry/page-index.json +1 -1
- package/registry/page.json +1 -1
- package/registry/pagination.json +1 -1
- package/registry/photo-grid.json +1 -1
- package/registry/pointer-light.json +1 -1
- package/registry/popover.json +1 -1
- package/registry/pricing-page.json +1 -1
- package/registry/product-page.json +1 -1
- package/registry/profile-card.json +1 -1
- package/registry/progress.json +1 -1
- package/registry/promise-card.json +1 -1
- package/registry/quota-meter.json +1 -1
- package/registry/radio-group.json +1 -1
- package/registry/rail-nav.json +2 -2
- package/registry/recipes.json +1 -1
- package/registry/retro-tv.json +1 -1
- package/registry/reviews.json +1 -1
- package/registry/router.json +1 -1
- package/registry/screen.json +68 -4
- package/registry/scroll-stage.json +1 -1
- package/registry/search-field.json +1 -1
- package/registry/section-backdrop.json +1 -1
- package/registry/separator.json +1 -1
- package/registry/service-card.json +1 -1
- package/registry/settings-layout.json +5 -2
- package/registry/shop-composer.json +1 -1
- package/registry/shop.json +3 -3
- package/registry/showcase.json +1 -1
- package/registry/signature.json +1 -1
- package/registry/site-cahier.json +1 -1
- package/registry/site-footer.json +4 -4
- package/registry/sites.json +1 -1
- package/registry/skeleton.json +1 -1
- package/registry/skip-link.json +1 -1
- package/registry/slider.json +1 -1
- package/registry/slot-picker.json +1 -1
- package/registry/slot.json +1 -1
- package/registry/specimen-tag.json +1 -1
- package/registry/speed-lines.json +1 -1
- package/registry/spinner.json +1 -1
- package/registry/split-view.json +1 -1
- package/registry/stage-banner.json +1 -1
- package/registry/stat.json +1 -1
- package/registry/state-screen.json +224 -0
- package/registry/status-chip.json +1 -1
- package/registry/status-page.json +1 -1
- package/registry/step-progress.json +1 -1
- package/registry/step-showcase.json +1 -1
- package/registry/stepper.json +1 -1
- package/registry/sticky-action.json +1 -1
- package/registry/stuck.json +1 -1
- package/registry/swipe-deck.json +1 -1
- package/registry/switch.json +1 -1
- package/registry/tabs.json +1 -1
- package/registry/tag-input.json +1 -1
- package/registry/tag-selector.json +1 -1
- package/registry/taped-photo.json +1 -1
- package/registry/terminal-replay.json +1 -1
- package/registry/text-style.json +1 -1
- package/registry/theme.json +3 -3
- package/registry/toast.json +1 -1
- package/registry/toc.json +1 -1
- package/registry/tooltip.json +1 -1
- package/registry/tree-view.json +1 -1
- package/registry/update-prompt.json +1 -1
- package/registry/upload-queue.json +1 -1
- package/registry/usage.json +1 -1
- package/registry/verified-badge.json +1 -1
- package/registry/versus-card.json +1 -1
- package/registry/vertical-video.json +1 -1
- package/registry/video-player.json +1 -1
- package/registry/video-trimmer.json +1 -1
- package/registry/virtual.json +1 -1
- package/registry/wall.json +1 -1
- package/registry/waveform.json +1 -1
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
},
|
|
190
190
|
{
|
|
191
191
|
"path": "meta.ts",
|
|
192
|
-
"content": "// The documentation of a component, carried by its code: each primitive has a `meta.ts` beside its source\n// (`src/<name>/meta.ts`; a component that exists only in React Native: `src/native/meta/<name>.ts`). Never built into\n// the package: `scripts/build-registry.mjs` reads them into `registry/<name>.json`, which ui.krizaka.com (apps/site) renders as\n// ui.krizaka.com/components/<name>, and `scripts/registry.test.mjs` fails when one is missing or incomplete.\n//\n// Why a typed module and not JSDoc tags: the fields are lists and links (`related`, `whenNotToUse[].use`, examples),\n// which a type checks and a comment does not; the file is plain data (erasable TypeScript), so Node reads it without a\n// compiler, and an editor completes it.\n\n/** Every documented component: the web primitives (one entry of the package each) and the native-only ones. */\nexport type ComponentName =\n | \"notification-preferences\"\n | \"quota-meter\"\n | \"environment-notice\"\n | \"embed-facade\"\n | \"reviews\"\n | \"margin-layout\"\n | \"analysis-report\"\n | \"status-chip\"\n | \"kind-config-editor\"\n | \"agenda\"\n | \"account-settings\"\n | \"drop-overlay\"\n | \"upload-queue\"\n | \"achievement\"\n | \"anatomy-plate\"\n | \"bird-plate\"\n | \"taped-photo\"\n | \"stuck\"\n | \"doodle\"\n | \"signature\"\n | \"grade-stamp\"\n | \"versus-card\"\n | \"speed-lines\"\n | \"site-cahier\"\n | \"text-style\"\n | \"flock\"\n | \"elephant\"\n | \"footnote\"\n | \"page-index\"\n | \"chapter\"\n | \"specimen-tag\"\n | \"action-bar\"\n | \"action-sheet\"\n | \"activity-feed\"\n | \"alert\"\n | \"app-header\"\n | \"app-shell\"\n | \"argument-card\"\n | \"audio-player\"\n | \"auth-layout\"\n | \"avatar\"\n | \"badge\"\n | \"button\"\n | \"captcha\"\n | \"card\"\n | \"card-grid\"\n | \"catalogue-page\"\n | \"changelog-page\"\n | \"chat\"\n | \"checkbox\"\n | \"chip\"\n | \"chip-link\"\n | \"chip-row\"\n | \"choice-grid\"\n | \"cn\"\n | \"code-block\"\n | \"combobox\"\n | \"comparison-table\"\n | \"command\"\n | \"component-page\"\n | \"confirm-button\"\n | \"contact-page\"\n | \"continue-prompt\"\n | \"countdown\"\n | \"cover-hero\"\n | \"cta-panel\"\n | \"dashboard-layout\"\n | \"data-table\"\n | \"date-picker\"\n | \"decision-list\"\n | \"description-list\"\n | \"detail-layout\"\n | \"dialog\"\n | \"docs-article-page\"\n | \"docs-hub-page\"\n | \"docs-layout\"\n | \"docs-nav\"\n | \"document-viewer\"\n | \"dropdown-menu\"\n | \"empty-state\"\n | \"engine-flow\"\n | \"error-page\"\n | \"fab\"\n | \"field\"\n | \"file-upload\"\n | \"filter-bar\"\n | \"force-update-screen\"\n | \"form\"\n | \"gallery-page\"\n | \"genui\"\n | \"glossary\"\n | \"glossary-term\"\n | \"glow-card\"\n | \"goal-gauge\"\n | \"header\"\n | \"how-it-works-page\"\n | \"image-cropper\"\n | \"image-viewer\"\n | \"iso\"\n | \"kanban\"\n | \"kbd\"\n | \"kpi-explained\"\n | \"landing-page\"\n | \"landscape\"\n | \"legal-page\"\n | \"link-card\"\n | \"list\"\n | \"loader\"\n | \"longform-page\"\n | \"maintenance-screen\"\n | \"map\"\n | \"markdown\"\n | \"meta-row\"\n | \"waveform\"\n | \"marketing-layout\"\n | \"marquee\"\n | \"mascot-quote\"\n | \"mascot-state\"\n | \"mascots\"\n | \"match-dialog\"\n | \"media-capture\"\n | \"media-grid\"\n | \"language-switch\"\n | \"media-gallery\"\n | \"media-picker\"\n | \"meter\"\n | \"nav-bar\"\n | \"number-ticker\"\n | \"onboarding\"\n | \"opening-hours\"\n | \"otp-input\"\n | \"page\"\n | \"page-header\"\n | \"page-hero\"\n | \"pagination\"\n | \"permission-prompt\"\n | \"photo-grid\"\n | \"pointer-light\"\n | \"popover\"\n | \"pricing-page\"\n | \"product-page\"\n | \"profile-card\"\n | \"progress\"\n | \"promise-card\"\n | \"pull-to-refresh\"\n | \"retro-tv\"\n | \"radio-group\"\n | \"router\"\n | \"rail-nav\"\n | \"recipes\"\n | \"screen\"\n | \"scroll-stage\"\n | \"search-field\"\n | \"section-backdrop\"\n | \"segmented\"\n | \"separator\"\n | \"service-card\"\n | \"shop\"\n | \"shop-composer\"\n | \"settings-layout\"\n | \"account-menu\"\n | \"showcase\"\n | \"step-showcase\"\n | \"site-footer\"\n | \"sites\"\n | \"skeleton\"\n | \"skip-link\"\n | \"slider\"\n | \"slot-picker\"\n | \"slot\"\n | \"spinner\"\n | \"sticky-action\"\n | \"splash-handoff\"\n | \"split-view\"\n | \"stage-banner\"\n | \"stat\"\n | \"usage\"\n | \"status-page\"\n | \"step-progress\"\n | \"stepper\"\n | \"swipe-deck\"\n | \"swipeable-row\"\n | \"switch\"\n | \"tab-bar\"\n | \"tabs\"\n | \"tag-input\"\n | \"tag-selector\"\n | \"terminal-replay\"\n | \"theme\"\n | \"toast\"\n | \"toc\"\n | \"tooltip\"\n | \"tree-view\"\n | \"txt\"\n | \"update-prompt\"\n | \"verified-badge\"\n | \"vertical-video\"\n | \"video-player\"\n | \"video-trimmer\"\n | \"virtual\"\n | \"wall\";\n\n/** Where a component exists: `@krizaka/ui/<name>` (web), `@krizaka/ui/native` (React Native), or both. */\nexport type Platform = \"web\" | \"native\" | \"both\";\n\n/**\n * Why a component is not on a platform — a decision, never a silence (the parity matrix of ui.krizaka.com/platforms):\n * - `gap` (✗): it belongs there and is not built yet; `issue` is the issue that tracks it (`krizaka/krizaka-ui#275`);\n * - `n/a`: it is not meant for that platform (a site's page block on a phone, a swipe on a desktop); `use` names the\n * component that answers there, when one does.\n */\nexport type Absence =\n | { readonly status: \"gap\"; readonly issue: string; readonly reason: string; readonly use?: undefined }\n | { readonly status: \"n/a\"; readonly reason: string; readonly use?: ComponentName; readonly issue?: undefined };\n\n/**\n * Desktop is the Orazaka Mac app (Tauri 2: the system WebView renders the web components — ADR-002). `web`: the web\n * component runs there as it is; `desktop`: it also has a desktop form (a window's title bar, a denser layout…), said in\n * its documentation; otherwise the absence and why.\n */\nexport type DesktopSupport = \"web\" | \"desktop\" | Absence;\n\n/**\n * The three platforms of Krizaka UI — web · native (React Native, Expo) · desktop — for one component. The side a\n * component has is `platforms`; the side it lacks says why here: `native` is required for (and only for) a web-only\n * component, `web` for a native-only one; `desktop` always. `scripts/registry.test.mjs` fails on a missing decision.\n */\nexport interface Parity {\n readonly web?: Absence;\n readonly native?: Absence;\n readonly desktop: DesktopSupport;\n}\n\n/**\n * `stable`: its API only changes in a major. `beta`: it may still change in a minor. `deprecated`: no product uses it and\n * no work plans to — it still works, says what replaces it, and goes in the major named by `deprecated.removedIn`.\n */\nexport type Status = \"stable\" | \"beta\" | \"deprecated\";\n\n/** What a deprecated component says (required when `status` is `deprecated`, absent otherwise). */\nexport interface Deprecation {\n /** The version that deprecated it (`3.6.0`). */\n readonly since: string;\n /** The major that removes it (`4.0.0`). */\n readonly removedIn: string;\n /** What replaces it, when a component does. */\n readonly use?: ComponentName;\n /** Why it goes: no product uses it, no planned work needs it. */\n readonly reason: string;\n}\n\n/**\n * The group of the catalogue. `media`: video, sound, camera, files, cropping. `blocks`: the page blocks — the frame,\n * the hero, sections, cards that lead or argue, decisions, code, calls to act — that every page of a site is made of.\n * `layouts`: the shells of whole screens — an application, a dashboard, settings, sign-in, an object, a list and its\n * item, a site's page, a documentation page — each with its screens. `templates`: the page templates — whole pages of a\n * site (a landing, a product, a docs hub, a long read, a changelog, pricing, status, an error…), each a distinct\n * composition of the blocks, words and content as props.\n */\nexport type Category = \"actions\" | \"forms\" | \"navigation\" | \"overlays\" | \"feedback\" | \"data-display\" | \"media\" | \"blocks\" | \"layouts\" | \"templates\" | \"layout\" | \"foundations\";\n\n/** Why a reader needs a template: the seven intents the templates are grouped by (sidebar sub-headings, catalogue filter). */\nexport type TemplatePurpose = \"convince\" | \"explain\" | \"show\" | \"act\" | \"operate\" | \"converse\" | \"recover\";\n\n/** The groups of templates, in reading order: the title, and the one line that says when to come to that group. */\nexport const templatePurposes = {\n convince: { title: \"Convince\", useWhen: \"You come here when a visitor must decide: a landing, a product, a price, a comparison, a proof.\" },\n explain: { title: \"Explain\", useWhen: \"You come here when a reader must understand: how it works, a documentation hub or article, a changelog, a FAQ, a policy.\" },\n show: { title: \"Show\", useWhen: \"You come here when the work itself is the argument: a gallery, a story, a case study, an object and its details.\" },\n act: { title: \"Act\", useWhen: \"You come here when a person must do something once: reach the team, sign in or up, set up, pay.\" },\n operate: { title: \"Operate\", useWhen: \"You come here when a person works every day: a dashboard, a console with a table, settings, an app shell.\" },\n converse: { title: \"Converse\", useWhen: \"You come here when people talk: an inbox, a chat, comments, a notifications centre.\" },\n recover: { title: \"Recover\", useWhen: \"You come here when the way is blocked: an empty list, an error, a missing page, maintenance, a product still being built.\" },\n} as const satisfies Record<TemplatePurpose, { readonly title: string; readonly useWhen: string }>;\n\n/**\n * A named example: the file `registry/examples/<component>/<name>.tsx` (web) or\n * `registry/examples/<component>/native/<name>.tsx` (React Native) — at most 40 lines, imported by the stories and\n * shown (live, with its code) by the documentation.\n */\ninterface ExampleBase {\n /** The file name, kebab-case (`primary`, `icon-button`). */\n readonly name: string;\n /** A short title (`Primary`, `Icon button`). */\n readonly title: string;\n /** One or two sentences: when this variant is the right one. */\n readonly description: string;\n}\n\n/** A plain example, or a template: a whole screen with its intent (`purpose`) and the user goal its layout serves (`why`). */\nexport type Example =\n | (ExampleBase & { readonly template?: false; readonly purpose?: undefined; readonly why?: undefined })\n | (ExampleBase & {\n /**\n * A template: a whole screen of a product composed from the platform (a layout and its blocks, real words, its\n * phone version thought out), copied as a starting point — at most 160 lines, listed on ui.krizaka.com/templates.\n */\n readonly template: true;\n /** The intent that groups it: why you need this block. */\n readonly purpose: TemplatePurpose;\n /** Why this layout: the user goal it serves, in one sentence. */\n readonly why: string;\n });\n\n/** One platform's side of a component. */\nexport interface PlatformDocs {\n /** The names to import (`[\"Button\", \"IconButton\"]`): from `@krizaka/ui/<name>` on the web, `@krizaka/ui/native` in React Native. */\n readonly imports: readonly string[];\n /** The examples, in reading order; the first one is the component's preview. */\n readonly examples: readonly Example[];\n}\n\n/** The React Native side: the same concept, and what differs from the web API. */\nexport interface NativeDocs extends PlatformDocs {\n /**\n * The entry to import from when it is not `@krizaka/ui/native`: a component that needs an Expo module (an optional\n * peer) has its own, `@krizaka/ui/native/<name>`, so an app that does not use it never installs the module.\n */\n readonly entry?: string;\n /** What differs from the web API (`label` instead of children…); empty for a native-only component. */\n readonly differences: readonly string[];\n /** The React Native entry alone is deprecated while the web one stays (ADR-006 §7); a deprecated component says it once, above. */\n readonly deprecated?: Deprecation;\n}\n\nexport interface KeyboardInteraction {\n /** The keys, as written on a keyboard: `Space`, `Enter`, `Arrow keys`, `Esc`, `Tab`. */\n readonly keys: string;\n /** What they do. */\n readonly action: string;\n}\n\nexport interface ComponentMeta {\n /** The display name: `Button`, `Dropdown menu`. */\n readonly title: string;\n /** One sentence: what it is. */\n readonly summary: string;\n readonly status: Status;\n /** Required for, and only for, a `deprecated` component. */\n readonly deprecated?: Deprecation;\n readonly category: Category;\n /** Must match the sides below: `both` ⇔ `web` and `native`. */\n readonly platforms: Platform;\n /** The platforms it is not on, and why; and its desktop form (see `Parity`). */\n readonly parity: Parity;\n /** When to reach for it: concrete situations, one per item. */\n readonly whenToUse: readonly string[];\n /** When not to — and what to use instead (`use`), when another component is the answer. */\n readonly whenNotToUse: readonly { readonly when: string; readonly use?: ComponentName }[];\n /** How to use it well: wording, placement, composition. */\n readonly bestPractices: readonly string[];\n readonly accessibility: {\n /** The keyboard, when it does more than Tab and Enter. */\n readonly keyboard: readonly KeyboardInteraction[];\n /** Roles, names and announcements: what the component does, what the app must provide. */\n readonly notes: readonly string[];\n };\n /** The components a reader of this page should know about. */\n readonly related: readonly ComponentName[];\n readonly web?: PlatformDocs;\n readonly native?: NativeDocs;\n}\n"
|
|
192
|
+
"content": "// The documentation of a component, carried by its code: each primitive has a `meta.ts` beside its source\n// (`src/<name>/meta.ts`; a component that exists only in React Native: `src/native/meta/<name>.ts`). Never built into\n// the package: `scripts/build-registry.mjs` reads them into `registry/<name>.json`, which ui.krizaka.com (apps/site) renders as\n// ui.krizaka.com/components/<name>, and `scripts/registry.test.mjs` fails when one is missing or incomplete.\n//\n// Why a typed module and not JSDoc tags: the fields are lists and links (`related`, `whenNotToUse[].use`, examples),\n// which a type checks and a comment does not; the file is plain data (erasable TypeScript), so Node reads it without a\n// compiler, and an editor completes it.\n\n/** Every documented component: the web primitives (one entry of the package each) and the native-only ones. */\nexport type ComponentName =\n | \"notification-preferences\"\n | \"quota-meter\"\n | \"environment-notice\"\n | \"embed-facade\"\n | \"reviews\"\n | \"margin-layout\"\n | \"analysis-report\"\n | \"status-chip\"\n | \"kind-config-editor\"\n | \"agenda\"\n | \"account-settings\"\n | \"drop-overlay\"\n | \"upload-queue\"\n | \"achievement\"\n | \"anatomy-plate\"\n | \"bird-plate\"\n | \"taped-photo\"\n | \"stuck\"\n | \"doodle\"\n | \"signature\"\n | \"grade-stamp\"\n | \"versus-card\"\n | \"speed-lines\"\n | \"site-cahier\"\n | \"text-style\"\n | \"flock\"\n | \"elephant\"\n | \"footnote\"\n | \"page-index\"\n | \"chapter\"\n | \"specimen-tag\"\n | \"action-bar\"\n | \"action-sheet\"\n | \"activity-feed\"\n | \"alert\"\n | \"app-frame\"\n | \"desktop-window\"\n | \"form-flow\"\n | \"grid\"\n | \"list-detail\"\n | \"state-screen\"\n | \"app-header\"\n | \"app-shell\"\n | \"argument-card\"\n | \"audio-player\"\n | \"auth-layout\"\n | \"avatar\"\n | \"badge\"\n | \"button\"\n | \"captcha\"\n | \"card\"\n | \"card-grid\"\n | \"catalogue-page\"\n | \"changelog-page\"\n | \"chat\"\n | \"checkbox\"\n | \"chip\"\n | \"chip-link\"\n | \"chip-row\"\n | \"choice-grid\"\n | \"cn\"\n | \"code-block\"\n | \"combobox\"\n | \"comparison-table\"\n | \"command\"\n | \"component-page\"\n | \"confirm-button\"\n | \"contact-page\"\n | \"continue-prompt\"\n | \"countdown\"\n | \"cover-hero\"\n | \"cta-panel\"\n | \"dashboard-layout\"\n | \"data-table\"\n | \"date-picker\"\n | \"decision-list\"\n | \"description-list\"\n | \"detail-layout\"\n | \"dialog\"\n | \"docs-article-page\"\n | \"docs-hub-page\"\n | \"docs-layout\"\n | \"docs-nav\"\n | \"document-viewer\"\n | \"dropdown-menu\"\n | \"empty-state\"\n | \"engine-flow\"\n | \"error-page\"\n | \"fab\"\n | \"field\"\n | \"file-upload\"\n | \"filter-bar\"\n | \"force-update-screen\"\n | \"form\"\n | \"gallery-page\"\n | \"genui\"\n | \"glossary\"\n | \"glossary-term\"\n | \"glow-card\"\n | \"goal-gauge\"\n | \"header\"\n | \"how-it-works-page\"\n | \"image-cropper\"\n | \"image-viewer\"\n | \"iso\"\n | \"kanban\"\n | \"kbd\"\n | \"kpi-explained\"\n | \"landing-page\"\n | \"landscape\"\n | \"legal-page\"\n | \"link-card\"\n | \"list\"\n | \"loader\"\n | \"longform-page\"\n | \"maintenance-screen\"\n | \"map\"\n | \"markdown\"\n | \"meta-row\"\n | \"waveform\"\n | \"marketing-layout\"\n | \"marquee\"\n | \"mascot-quote\"\n | \"mascot-state\"\n | \"mascots\"\n | \"match-dialog\"\n | \"media-capture\"\n | \"media-grid\"\n | \"language-switch\"\n | \"media-gallery\"\n | \"media-picker\"\n | \"meter\"\n | \"nav-bar\"\n | \"number-ticker\"\n | \"onboarding\"\n | \"opening-hours\"\n | \"otp-input\"\n | \"page\"\n | \"page-header\"\n | \"page-hero\"\n | \"pagination\"\n | \"permission-prompt\"\n | \"photo-grid\"\n | \"pointer-light\"\n | \"popover\"\n | \"pricing-page\"\n | \"product-page\"\n | \"profile-card\"\n | \"progress\"\n | \"promise-card\"\n | \"pull-to-refresh\"\n | \"retro-tv\"\n | \"radio-group\"\n | \"router\"\n | \"rail-nav\"\n | \"recipes\"\n | \"screen\"\n | \"scroll-stage\"\n | \"search-field\"\n | \"section-backdrop\"\n | \"segmented\"\n | \"separator\"\n | \"service-card\"\n | \"shop\"\n | \"shop-composer\"\n | \"settings-layout\"\n | \"account-menu\"\n | \"showcase\"\n | \"step-showcase\"\n | \"site-footer\"\n | \"sites\"\n | \"skeleton\"\n | \"skip-link\"\n | \"slider\"\n | \"slot-picker\"\n | \"slot\"\n | \"spinner\"\n | \"sticky-action\"\n | \"splash-handoff\"\n | \"split-view\"\n | \"stage-banner\"\n | \"stat\"\n | \"usage\"\n | \"status-page\"\n | \"step-progress\"\n | \"stepper\"\n | \"swipe-deck\"\n | \"swipeable-row\"\n | \"switch\"\n | \"tab-bar\"\n | \"tabs\"\n | \"tag-input\"\n | \"tag-selector\"\n | \"terminal-replay\"\n | \"theme\"\n | \"toast\"\n | \"toc\"\n | \"tooltip\"\n | \"tree-view\"\n | \"txt\"\n | \"update-prompt\"\n | \"verified-badge\"\n | \"vertical-video\"\n | \"video-player\"\n | \"video-trimmer\"\n | \"virtual\"\n | \"wall\";\n\n/** Where a component exists: `@krizaka/ui/<name>` (web), `@krizaka/ui/native` (React Native), or both. */\nexport type Platform = \"web\" | \"native\" | \"both\";\n\n/**\n * Why a component is not on a platform — a decision, never a silence (the parity matrix of ui.krizaka.com/platforms):\n * - `gap` (✗): it belongs there and is not built yet; `issue` is the issue that tracks it (`krizaka/krizaka-ui#275`);\n * - `n/a`: it is not meant for that platform (a site's page block on a phone, a swipe on a desktop); `use` names the\n * component that answers there, when one does.\n */\nexport type Absence =\n | { readonly status: \"gap\"; readonly issue: string; readonly reason: string; readonly use?: undefined }\n | { readonly status: \"n/a\"; readonly reason: string; readonly use?: ComponentName; readonly issue?: undefined };\n\n/**\n * Desktop is the Orazaka Mac app (Tauri 2: the system WebView renders the web components — ADR-002). `web`: the web\n * component runs there as it is; `desktop`: it also has a desktop form (a window's title bar, a denser layout…), said in\n * its documentation; otherwise the absence and why.\n */\nexport type DesktopSupport = \"web\" | \"desktop\" | Absence;\n\n/**\n * The three platforms of Krizaka UI — web · native (React Native, Expo) · desktop — for one component. The side a\n * component has is `platforms`; the side it lacks says why here: `native` is required for (and only for) a web-only\n * component, `web` for a native-only one; `desktop` always. `scripts/registry.test.mjs` fails on a missing decision.\n */\nexport interface Parity {\n readonly web?: Absence;\n readonly native?: Absence;\n readonly desktop: DesktopSupport;\n}\n\n/**\n * `stable`: its API only changes in a major. `beta`: it may still change in a minor. `deprecated`: no product uses it and\n * no work plans to — it still works, says what replaces it, and goes in the major named by `deprecated.removedIn`.\n */\nexport type Status = \"stable\" | \"beta\" | \"deprecated\";\n\n/** What a deprecated component says (required when `status` is `deprecated`, absent otherwise). */\nexport interface Deprecation {\n /** The version that deprecated it (`3.6.0`). */\n readonly since: string;\n /** The major that removes it (`4.0.0`). */\n readonly removedIn: string;\n /** What replaces it, when a component does. */\n readonly use?: ComponentName;\n /** Why it goes: no product uses it, no planned work needs it. */\n readonly reason: string;\n}\n\n/**\n * The group of the catalogue. `media`: video, sound, camera, files, cropping. `blocks`: the page blocks — the frame,\n * the hero, sections, cards that lead or argue, decisions, code, calls to act — that every page of a site is made of.\n * `layouts`: the shells of whole screens — an application, a dashboard, settings, sign-in, an object, a list and its\n * item, a site's page, a documentation page — each with its screens. `templates`: the page templates — whole pages of a\n * site (a landing, a product, a docs hub, a long read, a changelog, pricing, status, an error…), each a distinct\n * composition of the blocks, words and content as props.\n */\nexport type Category = \"actions\" | \"forms\" | \"navigation\" | \"overlays\" | \"feedback\" | \"data-display\" | \"media\" | \"blocks\" | \"layouts\" | \"templates\" | \"layout\" | \"foundations\";\n\n/** Why a reader needs a template: the seven intents the templates are grouped by (sidebar sub-headings, catalogue filter). */\nexport type TemplatePurpose = \"convince\" | \"explain\" | \"show\" | \"act\" | \"operate\" | \"converse\" | \"recover\";\n\n/** The groups of templates, in reading order: the title, and the one line that says when to come to that group. */\nexport const templatePurposes = {\n convince: { title: \"Convince\", useWhen: \"You come here when a visitor must decide: a landing, a product, a price, a comparison, a proof.\" },\n explain: { title: \"Explain\", useWhen: \"You come here when a reader must understand: how it works, a documentation hub or article, a changelog, a FAQ, a policy.\" },\n show: { title: \"Show\", useWhen: \"You come here when the work itself is the argument: a gallery, a story, a case study, an object and its details.\" },\n act: { title: \"Act\", useWhen: \"You come here when a person must do something once: reach the team, sign in or up, set up, pay.\" },\n operate: { title: \"Operate\", useWhen: \"You come here when a person works every day: a dashboard, a console with a table, settings, an app shell.\" },\n converse: { title: \"Converse\", useWhen: \"You come here when people talk: an inbox, a chat, comments, a notifications centre.\" },\n recover: { title: \"Recover\", useWhen: \"You come here when the way is blocked: an empty list, an error, a missing page, maintenance, a product still being built.\" },\n} as const satisfies Record<TemplatePurpose, { readonly title: string; readonly useWhen: string }>;\n\n/**\n * A named example: the file `registry/examples/<component>/<name>.tsx` (web) or\n * `registry/examples/<component>/native/<name>.tsx` (React Native) — at most 40 lines, imported by the stories and\n * shown (live, with its code) by the documentation.\n */\ninterface ExampleBase {\n /** The file name, kebab-case (`primary`, `icon-button`). */\n readonly name: string;\n /** A short title (`Primary`, `Icon button`). */\n readonly title: string;\n /** One or two sentences: when this variant is the right one. */\n readonly description: string;\n}\n\n/** A plain example, or a template: a whole screen with its intent (`purpose`) and the user goal its layout serves (`why`). */\nexport type Example =\n | (ExampleBase & { readonly template?: false; readonly purpose?: undefined; readonly why?: undefined })\n | (ExampleBase & {\n /**\n * A template: a whole screen of a product composed from the platform (a layout and its blocks, real words, its\n * phone version thought out), copied as a starting point — at most 160 lines, listed on ui.krizaka.com/templates.\n */\n readonly template: true;\n /** The intent that groups it: why you need this block. */\n readonly purpose: TemplatePurpose;\n /** Why this layout: the user goal it serves, in one sentence. */\n readonly why: string;\n });\n\n/** One platform's side of a component. */\nexport interface PlatformDocs {\n /** The names to import (`[\"Button\", \"IconButton\"]`): from `@krizaka/ui/<name>` on the web, `@krizaka/ui/native` in React Native. */\n readonly imports: readonly string[];\n /** The examples, in reading order; the first one is the component's preview. */\n readonly examples: readonly Example[];\n}\n\n/** The React Native side: the same concept, and what differs from the web API. */\nexport interface NativeDocs extends PlatformDocs {\n /**\n * The entry to import from when it is not `@krizaka/ui/native`: a component that needs an Expo module (an optional\n * peer) has its own, `@krizaka/ui/native/<name>`, so an app that does not use it never installs the module.\n */\n readonly entry?: string;\n /** What differs from the web API (`label` instead of children…); empty for a native-only component. */\n readonly differences: readonly string[];\n /** The React Native entry alone is deprecated while the web one stays (ADR-006 §7); a deprecated component says it once, above. */\n readonly deprecated?: Deprecation;\n}\n\nexport interface KeyboardInteraction {\n /** The keys, as written on a keyboard: `Space`, `Enter`, `Arrow keys`, `Esc`, `Tab`. */\n readonly keys: string;\n /** What they do. */\n readonly action: string;\n}\n\nexport interface ComponentMeta {\n /** The display name: `Button`, `Dropdown menu`. */\n readonly title: string;\n /** One sentence: what it is. */\n readonly summary: string;\n readonly status: Status;\n /** Required for, and only for, a `deprecated` component. */\n readonly deprecated?: Deprecation;\n readonly category: Category;\n /** Must match the sides below: `both` ⇔ `web` and `native`. */\n readonly platforms: Platform;\n /** The platforms it is not on, and why; and its desktop form (see `Parity`). */\n readonly parity: Parity;\n /** When to reach for it: concrete situations, one per item. */\n readonly whenToUse: readonly string[];\n /** When not to — and what to use instead (`use`), when another component is the answer. */\n readonly whenNotToUse: readonly { readonly when: string; readonly use?: ComponentName }[];\n /** How to use it well: wording, placement, composition. */\n readonly bestPractices: readonly string[];\n readonly accessibility: {\n /** The keyboard, when it does more than Tab and Enter. */\n readonly keyboard: readonly KeyboardInteraction[];\n /** Roles, names and announcements: what the component does, what the app must provide. */\n readonly notes: readonly string[];\n };\n /** The components a reader of this page should know about. */\n readonly related: readonly ComponentName[];\n readonly web?: PlatformDocs;\n readonly native?: NativeDocs;\n}\n"
|
|
193
193
|
}
|
|
194
194
|
],
|
|
195
195
|
"dependencies": [
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "desktop-window",
|
|
3
|
+
"type": "primitive",
|
|
4
|
+
"title": "Desktop window",
|
|
5
|
+
"summary": "The window of a Mac app (Tauri 2 on the system WebView): a sidebar, the content and an inspector in a three-pane split — resizable by pointer and keyboard, collapsible — under a toolbar that moves the window and clears the traffic lights, at the desktop's density with a native-feeling focus ring. Its commands are written once for the menu bar, the page's shortcuts and the palette.",
|
|
6
|
+
"description": "The window of a Mac app (Tauri 2 on the system WebView): a sidebar, the content and an inspector in a three-pane split — resizable by pointer and keyboard, collapsible — under a toolbar that moves the window and clears the traffic lights, at the desktop's density with a native-feeling focus ring. Its commands are written once for the menu bar, the page's shortcuts and the palette.",
|
|
7
|
+
"status": "beta",
|
|
8
|
+
"deprecated": null,
|
|
9
|
+
"category": "layouts",
|
|
10
|
+
"platforms": "web",
|
|
11
|
+
"parity": {
|
|
12
|
+
"web": {
|
|
13
|
+
"state": "yes"
|
|
14
|
+
},
|
|
15
|
+
"native": {
|
|
16
|
+
"state": "n/a",
|
|
17
|
+
"reason": "A phone has no windows: its screens are the list and detail, the tabs and the sheets.",
|
|
18
|
+
"use": "list-detail"
|
|
19
|
+
},
|
|
20
|
+
"desktop": {
|
|
21
|
+
"state": "desktop"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"whenToUse": [
|
|
25
|
+
"The main window of a Tauri Mac app with a source list, a main view and the details of the selection (Finder, Mail, Xcode).",
|
|
26
|
+
"A two-pane window: omit `inspector`."
|
|
27
|
+
],
|
|
28
|
+
"whenNotToUse": [
|
|
29
|
+
{
|
|
30
|
+
"when": "A console with grouped sections and a collapsing sidebar of words.",
|
|
31
|
+
"use": "app-shell"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"when": "The signed-in web app in a browser.",
|
|
35
|
+
"use": "app-frame"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"when": "A phone or a tablet.",
|
|
39
|
+
"use": "list-detail"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"bestPractices": [
|
|
43
|
+
"Use it at a window width of 900 pt or more (Tauri's minimum width): the content keeps 360 pt, and the panes give way to it when the window is narrower.",
|
|
44
|
+
"Write the commands once with `useDesktopCommands`: it registers the chords in the page and returns the `menus` and `handlers` for `setNativeMenu` of `@krizaka/app-desktop`. Then pass `shortcuts={{ sidebar: false, inspector: false }}` to the window so ⌘B and ⌘I are not answered twice.",
|
|
45
|
+
"Keep the sizes: persist `onSizesChange` (a preference of the window) and give them back as `defaultSizes`.",
|
|
46
|
+
"Fold with the controlled `sidebarOpen` / `inspectorOpen`, so the menu's « Hide sidebar » and the toolbar's button are one state.",
|
|
47
|
+
"Put only what moves the window's content in the toolbar (back, search, the main action); never a form.",
|
|
48
|
+
"Controls inside use the desktop's density (32 px rows, 13 px text); do not enlarge them for touch."
|
|
49
|
+
],
|
|
50
|
+
"accessibility": {
|
|
51
|
+
"keyboard": [
|
|
52
|
+
{
|
|
53
|
+
"keys": "Tab to a divider",
|
|
54
|
+
"action": "Focuses it; it is a separator (WAI-ARIA window splitter) with its size as `aria-valuenow`."
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"keys": "← →",
|
|
58
|
+
"action": "Resizes the pane by 16 px (64 with Shift); the arrow pointing away from the pane's edge grows it, mirrored in right-to-left."
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"keys": "Home / End",
|
|
62
|
+
"action": "The smallest or the largest size."
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"keys": "Enter on a divider",
|
|
66
|
+
"action": "Folds its pane; the focus goes to the toolbar's button that brings it back."
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"keys": "⌘B / ⌘I",
|
|
70
|
+
"action": "Fold the sidebar and the inspector."
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"notes": [
|
|
74
|
+
"The panes are `aside` landmarks named by `labels`; the toolbar is the window's `header`, the content its `main`.",
|
|
75
|
+
"The dividers are the only draggable things; the toolbar's drag region is the bar, its title and the gaps — never a control, so every button keeps its click and its focus.",
|
|
76
|
+
"The focus ring is the macOS one (a 3 px halo of the accent) and shows for the keyboard only."
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"related": [
|
|
80
|
+
"app-shell",
|
|
81
|
+
"split-view",
|
|
82
|
+
"app-frame",
|
|
83
|
+
"kbd"
|
|
84
|
+
],
|
|
85
|
+
"web": {
|
|
86
|
+
"entry": "@krizaka/ui/desktop-window",
|
|
87
|
+
"import": "import { DesktopWindow, useDesktopCommands, desktopMenus } from \"@krizaka/ui/desktop-window\";",
|
|
88
|
+
"props": [
|
|
89
|
+
{
|
|
90
|
+
"component": "DesktopWindow",
|
|
91
|
+
"description": "The window of a Mac app: sidebar · content · inspector, a toolbar that moves the window, the desktop's density.",
|
|
92
|
+
"props": [
|
|
93
|
+
{
|
|
94
|
+
"name": "children",
|
|
95
|
+
"type": "ReactNode",
|
|
96
|
+
"default": null,
|
|
97
|
+
"description": "The main content under the toolbar.",
|
|
98
|
+
"required": true
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "labels",
|
|
102
|
+
"type": "DesktopWindowLabels",
|
|
103
|
+
"default": null,
|
|
104
|
+
"description": "The words of the panes, the dividers and the toggles — passed translated.",
|
|
105
|
+
"required": true
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "sidebar",
|
|
109
|
+
"type": "ReactNode",
|
|
110
|
+
"default": null,
|
|
111
|
+
"description": "The sidebar's content: a list of places, a `Tree`. It scrolls by itself.",
|
|
112
|
+
"required": true
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "className",
|
|
116
|
+
"type": "string",
|
|
117
|
+
"default": null,
|
|
118
|
+
"description": "Classes for the window (`[--kz-window-height:34rem]` to size it inside a page).",
|
|
119
|
+
"required": false
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "contentMin",
|
|
123
|
+
"type": "number",
|
|
124
|
+
"default": "360",
|
|
125
|
+
"description": "The least the content keeps when the window is narrow (default 360).",
|
|
126
|
+
"required": false
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "defaultInspectorOpen",
|
|
130
|
+
"type": "boolean",
|
|
131
|
+
"default": "true",
|
|
132
|
+
"description": "The inspector starts open (default true) when uncontrolled.",
|
|
133
|
+
"required": false
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "defaultSidebarOpen",
|
|
137
|
+
"type": "boolean",
|
|
138
|
+
"default": "true",
|
|
139
|
+
"description": "The sidebar starts open (default true) when uncontrolled.",
|
|
140
|
+
"required": false
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "defaultSizes",
|
|
144
|
+
"type": "{ sidebar?: number; inspector?: number; } | undefined",
|
|
145
|
+
"default": null,
|
|
146
|
+
"description": "The sizes in px: the sidebar's, the inspector's. Persist them with `onSizesChange`.",
|
|
147
|
+
"required": false
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "inspector",
|
|
151
|
+
"type": "ReactNode",
|
|
152
|
+
"default": null,
|
|
153
|
+
"description": "The inspector's content: the selected item's details. Without it, a two-pane window.",
|
|
154
|
+
"required": false
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "inspectorOpen",
|
|
158
|
+
"type": "boolean",
|
|
159
|
+
"default": null,
|
|
160
|
+
"description": "The inspector is open (controlled).",
|
|
161
|
+
"required": false
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "onInspectorOpenChange",
|
|
165
|
+
"type": "((open: boolean) => void)",
|
|
166
|
+
"default": null,
|
|
167
|
+
"description": "Called when the inspector folds or unfolds.",
|
|
168
|
+
"required": false
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "onSidebarOpenChange",
|
|
172
|
+
"type": "((open: boolean) => void)",
|
|
173
|
+
"default": null,
|
|
174
|
+
"description": "Called when the sidebar folds or unfolds (the toolbar, a divider, the shortcut).",
|
|
175
|
+
"required": false
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"name": "onSizesChange",
|
|
179
|
+
"type": "((sizes: { sidebar: number; inspector: number; }) => void)",
|
|
180
|
+
"default": null,
|
|
181
|
+
"description": "Called with the sizes in px after a drag or a key: persist them.",
|
|
182
|
+
"required": false
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"name": "shortcuts",
|
|
186
|
+
"type": "{ sidebar?: string | false; inspector?: string | false; } | undefined",
|
|
187
|
+
"default": null,
|
|
188
|
+
"description": "The keys that fold the panes (a chord, or `false` for none): ⌘B and ⌘I by default. Pass `false` when the menu bar's commands (`useDesktopCommands`) own them.",
|
|
189
|
+
"required": false
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "sidebarOpen",
|
|
193
|
+
"type": "boolean",
|
|
194
|
+
"default": null,
|
|
195
|
+
"description": "The sidebar is open (controlled). Pair with `onSidebarOpenChange`: the menu bar's command toggles it too.",
|
|
196
|
+
"required": false
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "title",
|
|
200
|
+
"type": "ReactNode",
|
|
201
|
+
"default": null,
|
|
202
|
+
"description": "The toolbar's title, centred in the drag region.",
|
|
203
|
+
"required": false
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"name": "toolbarEnd",
|
|
207
|
+
"type": "ReactNode",
|
|
208
|
+
"default": null,
|
|
209
|
+
"description": "Before the inspector's toggle, at the end of the toolbar (actions, search).",
|
|
210
|
+
"required": false
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"name": "toolbarStart",
|
|
214
|
+
"type": "ReactNode",
|
|
215
|
+
"default": null,
|
|
216
|
+
"description": "After the sidebar's toggle, at the start of the toolbar (back, forward).",
|
|
217
|
+
"required": false
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
"examples": [
|
|
223
|
+
{
|
|
224
|
+
"name": "library",
|
|
225
|
+
"title": "A library window",
|
|
226
|
+
"description": "A source list, a list of files and the details of the selected one; ⌘B and ⌘I fold the panes, the menu bar gets the same commands.",
|
|
227
|
+
"template": true,
|
|
228
|
+
"purpose": "operate",
|
|
229
|
+
"why": "A person on a Mac works with a list and the details of what they select, with the keys and the menus of a Mac app.",
|
|
230
|
+
"path": "examples/desktop-window/library.tsx",
|
|
231
|
+
"module": "@krizaka/ui/registry/examples/desktop-window/library",
|
|
232
|
+
"code": "\"use client\";\n\nimport { ProductLogo } from \"@krizaka/ui\";\nimport { Badge } from \"@krizaka/ui/badge\";\nimport { Button } from \"@krizaka/ui/button\";\nimport { DesktopWindow, useDesktopCommands } from \"@krizaka/ui/desktop-window\";\nimport { useState } from \"react\";\n\nconst FILES = [\"Lease — 12 rue Fleury\", \"Payslips — Ada Roy\", \"ID — Noor Khan\", \"Lease — 8 av. du Parc\"];\n\n// TEMPLATE — The window of a Mac app: sidebar · content · inspector, resizable (drag a divider, or focus it and use the\n// arrows) and collapsible (⌘B, ⌘I, the toolbar). The commands are written once: the menu bar gets them from `menus` and\n// `handlers` (`setNativeMenu(bridge, { labels, menus }, handlers)` of @krizaka/app-desktop), the page answers the same keys.\nexport default function DesktopWindowLibrary() {\n const [sidebar, setSidebar] = useState(true);\n const [inspector, setInspector] = useState(true);\n const [current, setCurrent] = useState(0);\n useDesktopCommands([\n { id: \"view.sidebar\", menu: \"View\", label: sidebar ? \"Hide sidebar\" : \"Show sidebar\", shortcut: \"mod+b\", run: () => setSidebar(!sidebar) },\n { id: \"view.inspector\", menu: \"View\", label: inspector ? \"Hide inspector\" : \"Show inspector\", shortcut: \"mod+i\", run: () => setInspector(!inspector) },\n ]);\n return (\n <DesktopWindow\n className=\"[--kz-window-height:34rem]\"\n shortcuts={{ sidebar: false, inspector: false }}\n sidebarOpen={sidebar}\n onSidebarOpenChange={setSidebar}\n inspectorOpen={inspector}\n onInspectorOpenChange={setInspector}\n labels={{ sidebar: \"Library\", inspector: \"Details\", resizeSidebar: \"Resize the sidebar\", resizeInspector: \"Resize the inspector\", toggleSidebar: \"Show or hide the sidebar\", toggleInspector: \"Show or hide the inspector\" }}\n title=\"Applicant files\"\n toolbarEnd={<Button size=\"sm\" variant=\"primary\">New file</Button>}\n sidebar={\n <div className=\"flex flex-col gap-0.5 p-2\">\n <div className=\"flex items-center gap-2 px-2 py-1.5 font-semibold\"><ProductLogo id=\"yomizaka\" size={18} animated={false} /> Yomizaka</div>\n {[\"All files\", \"To decide\", \"Verified\"].map((name, i) => (\n <button key={name} type=\"button\" aria-current={i === 0 ? \"page\" : undefined} className=\"h-8 cursor-default rounded-md px-2 text-start hover:bg-surface-2 aria-[current=page]:bg-accent-soft\">{name}</button>\n ))}\n </div>\n }\n inspector={\n <div className=\"space-y-2 p-4\">\n <p className=\"text-xs font-semibold text-fg-secondary\">Details</p>\n <p className=\"font-semibold\">{FILES[current]}</p>\n <Badge tone=\"success\" dot>Verified</Badge>\n </div>\n }\n >\n <ul className=\"divide-y divide-border-subtle\">\n {FILES.map((file, i) => (\n <li key={file}>\n <button type=\"button\" aria-pressed={i === current} onClick={() => setCurrent(i)} className=\"block h-9 w-full cursor-default truncate px-4 text-start hover:bg-surface-2 aria-pressed:bg-accent-soft\">{file}</button>\n </li>\n ))}\n </ul>\n </DesktopWindow>\n );\n}\n"
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
"native": null,
|
|
237
|
+
"files": [
|
|
238
|
+
{
|
|
239
|
+
"path": "desktop-window/commands.ts",
|
|
240
|
+
"content": "// Pure: the commands of a desktop window, written once and read by three things — the native menu bar (through\n// `setNativeMenu` of @krizaka/app-desktop), the in-page shortcuts (`useShortcuts`, also the browser's), and the palette.\nimport { acceleratorOf } from \"../app-shell/shortcuts\";\n\nexport interface DesktopCommand {\n /** Sent back by the menu when chosen: lowercase letters, digits, `.` and `-` (`view.sidebar`). */\n id: string;\n /** The menu item's words, passed translated (`Hide sidebar`). */\n label: string;\n /** The menu it belongs to (`View`, `File`), passed translated: the product's menus sit between Edit and Window. */\n menu: string;\n /** A chord (`mod+b`): the menu shows it and the page answers it. A sequence (`g d`) is the page's only. */\n shortcut?: string;\n /** Runs the command. */\n run: () => void;\n /** A separator before it in its menu. */\n separated?: boolean;\n /** Dimmed in the menu while false (default true). */\n enabled?: boolean;\n}\n\n/** The shape `setNativeMenu` takes for its `menus` (structurally the same as `MenuSpec[\"menus\"]` of @krizaka/app-desktop). */\nexport interface DesktopMenu {\n title: string;\n items: { id: string; label: string; accelerator?: string; enabled?: boolean; separated?: boolean }[];\n}\n\nconst ID = /^[a-z0-9][a-z0-9.-]*$/;\n\nexport interface DesktopMenus {\n /** For `setNativeMenu(bridge, { labels, menus }, handlers)`. */\n menus: DesktopMenu[];\n /** For its `handlers`: the id of the chosen item → what it does. */\n handlers: Record<string, () => void>;\n /** For `useShortcuts`: the chords of the commands, answered in the page. */\n shortcuts: Record<string, () => void>;\n}\n\n/** Refuses an id the native side would refuse, or one already declared. */\nfunction checkId(out: DesktopMenus, id: string): void {\n if (!ID.test(id)) throw new Error(`desktopMenus: \"${id}\" is not a menu id (lowercase letters, digits, \".\" and \"-\").`);\n if (out.handlers[id]) throw new Error(`desktopMenus: \"${id}\" is declared twice.`);\n}\n\n/** Records the chord of a command for the page, refusing one given to two commands. */\nfunction addShortcut(out: DesktopMenus, shortcut: string, run: () => void): void {\n const key = shortcut.toLowerCase();\n if (out.shortcuts[key]) throw new Error(`desktopMenus: \"${shortcut}\" is the shortcut of two commands.`);\n out.shortcuts[key] = run;\n}\n\n/** The menu item of a command: its accelerator, and only the flags it sets. */\nfunction itemOf(command: DesktopCommand): DesktopMenu[\"items\"][number] {\n const accelerator = command.shortcut ? acceleratorOf(command.shortcut) : undefined;\n return {\n id: command.id,\n label: command.label,\n ...(accelerator ? { accelerator } : {}),\n ...(command.enabled === false ? { enabled: false } : {}),\n ...(command.separated ? { separated: true } : {}),\n };\n}\n\n/** Turns the commands into the menu bar's menus, its handlers and the page's shortcuts — one source for the three. Throws on a bad or repeated id, or a shortcut given twice. */\nexport function desktopMenus(commands: readonly DesktopCommand[]): DesktopMenus {\n const out: DesktopMenus = { menus: [], handlers: {}, shortcuts: {} };\n for (const command of commands) {\n checkId(out, command.id);\n out.handlers[command.id] = command.run;\n if (command.shortcut) addShortcut(out, command.shortcut, command.run);\n let menu = out.menus.find((m) => m.title === command.menu);\n if (!menu) out.menus.push((menu = { title: command.menu, items: [] }));\n menu.items.push(itemOf(command));\n }\n return out;\n}\n"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"path": "desktop-window/desktop-window.tsx",
|
|
244
|
+
"content": "// Client (the panes' sizes, the pointer, the shortcuts). The window of a Mac app (Tauri 2 on the system WebView, ADR-002):\n// a sidebar, the content and an inspector in a three-pane split — resizable by pointer and keyboard, collapsible — under a\n// toolbar that moves the window and clears the traffic lights, at the desktop's density with a native-feeling focus ring.\n// The commands (`desktopMenus`) are written once for the native menu bar, the page's shortcuts and the palette.\nimport { type ShortcutMap, useShortcuts } from \"@krizaka/ui/app-shell\";\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { type DesktopCommand, type DesktopMenus, desktopMenus } from \"./commands\";\nimport { clamp, dragged, keyed, paneMax } from \"./panes\";\n\nexport const desktopWindow = tv({\n slots: {\n root:\n \"kz-desktop-window flex h-[var(--kz-window-height,100dvh)] min-w-0 select-none overflow-hidden bg-surface-0 text-[13px] text-fg \" +\n // The macOS focus ring: a 3 px halo of the accent, over a 1 px accent edge, only for the keyboard.\n \"[&_:focus-visible]:outline-hidden [&_:focus-visible]:ring-[3px]! [&_:focus-visible]:ring-ring/50! [&_:focus-visible]:ring-offset-0!\",\n pane: \"relative flex min-h-0 shrink-0 flex-col overflow-hidden data-[collapsed]:hidden\",\n sidebar: \"border-e border-border-subtle bg-surface-1\",\n titlebar: \"h-[var(--kz-titlebar-inset,1.75rem)] shrink-0\",\n scroll: \"min-h-0 flex-1 overflow-y-auto\",\n middle: \"flex min-h-0 min-w-0 flex-1 flex-col\",\n inspector: \"border-s border-border-subtle bg-surface-1\",\n separator:\n \"group/sep relative z-10 -mx-[3px] w-[6px] shrink-0 cursor-col-resize touch-none data-[collapsed]:hidden \" +\n \"after:absolute after:inset-y-0 after:left-[2px] after:w-px after:bg-transparent hover:after:bg-border-strong data-[active]:after:bg-accent focus-visible:after:bg-accent\",\n content: \"min-h-0 min-w-0 flex-1 overflow-y-auto select-text\",\n toolbar:\n \"flex h-[var(--kz-toolbar-height,3rem)] shrink-0 items-center gap-2 border-b border-border-subtle bg-surface-0 px-3 \" +\n // With the sidebar folded the traffic lights sit over the toolbar: its first control starts after them.\n \"[[data-sidebar=closed]_&]:ps-[var(--kz-traffic-lights-inset,4.75rem)]\",\n toolbarTitle: \"min-w-0 flex-1 truncate text-[13px] font-semibold\",\n toolbarGroup: \"flex shrink-0 items-center gap-1\",\n toggle:\n \"inline-flex h-7 w-7 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-surface-2 hover:text-fg cursor-default aria-pressed:text-fg-accent\",\n },\n});\nconst s = desktopWindow();\n\nexport interface DesktopWindowLabels {\n /** The sidebar's accessible name (`Library`). */\n sidebar: string;\n /** The inspector's accessible name (`Details`). */\n inspector: string;\n /** The separators' names (`Resize the sidebar`, `Resize the inspector`). */\n resizeSidebar: string;\n resizeInspector: string;\n /** The toolbar buttons that fold the panes (`Show or hide the sidebar`). */\n toggleSidebar: string;\n toggleInspector: string;\n}\n\nexport interface DesktopWindowProps {\n /** The sidebar's content: a list of places, a `Tree`. It scrolls by itself. */\n sidebar: React.ReactNode;\n /** The main content under the toolbar. */\n children: React.ReactNode;\n /** The inspector's content: the selected item's details. Without it, a two-pane window. */\n inspector?: React.ReactNode;\n /** The toolbar's title, centred in the drag region. */\n title?: React.ReactNode;\n /** After the sidebar's toggle, at the start of the toolbar (back, forward). */\n toolbarStart?: React.ReactNode;\n /** Before the inspector's toggle, at the end of the toolbar (actions, search). */\n toolbarEnd?: React.ReactNode;\n /** The words of the panes, the dividers and the toggles — passed translated. */\n labels: DesktopWindowLabels;\n /** The sidebar is open (controlled). Pair with `onSidebarOpenChange`: the menu bar's command toggles it too. */\n sidebarOpen?: boolean;\n /** The sidebar starts open (default true) when uncontrolled. */\n defaultSidebarOpen?: boolean;\n /** Called when the sidebar folds or unfolds (the toolbar, a divider, the shortcut). */\n onSidebarOpenChange?: (open: boolean) => void;\n /** The inspector is open (controlled). */\n inspectorOpen?: boolean;\n /** The inspector starts open (default true) when uncontrolled. */\n defaultInspectorOpen?: boolean;\n /** Called when the inspector folds or unfolds. */\n onInspectorOpenChange?: (open: boolean) => void;\n /** The sizes in px: the sidebar's, the inspector's. Persist them with `onSizesChange`. */\n defaultSizes?: { sidebar?: number; inspector?: number };\n /** Called with the sizes in px after a drag or a key: persist them. */\n onSizesChange?: (sizes: { sidebar: number; inspector: number }) => void;\n /** The least the content keeps when the window is narrow (default 360). */\n contentMin?: number;\n /** The keys that fold the panes (a chord, or `false` for none): ⌘B and ⌘I by default. Pass `false` when the menu bar's commands (`useDesktopCommands`) own them. */\n shortcuts?: { sidebar?: string | false; inspector?: string | false };\n /** Classes for the window (`[--kz-window-height:34rem]` to size it inside a page). */\n className?: string;\n}\n\nconst SIDEBAR: { min: number; max: number } = { min: 180, max: 360 };\nconst INSPECTOR: { min: number; max: number } = { min: 240, max: 480 };\n\nconst glyph = (d: string) => (\n <svg viewBox=\"0 0 24 24\" className=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d={d} />\n </svg>\n);\n\nfunction useOpen(controlled: boolean | undefined, initial: boolean, onChange?: (open: boolean) => void) {\n const [own, setOwn] = React.useState(initial);\n const open = controlled ?? own;\n const set = React.useCallback(\n (next: boolean) => {\n if (controlled === undefined) setOwn(next);\n onChange?.(next);\n },\n [controlled, onChange],\n );\n return [open, set] as const;\n}\n\ntype Edge = \"sidebar\" | \"inspector\";\n\n/** The window of a Mac app: sidebar · content · inspector, a toolbar that moves the window, the desktop's density. */\nexport function DesktopWindow({\n sidebar, children, inspector, title, toolbarStart, toolbarEnd, labels, sidebarOpen, defaultSidebarOpen = true, onSidebarOpenChange, inspectorOpen, defaultInspectorOpen = true, onInspectorOpenChange, defaultSizes, onSizesChange, contentMin = 360, shortcuts, className,\n}: DesktopWindowProps) {\n const [sideOpen, setSideOpen] = useOpen(sidebarOpen, defaultSidebarOpen, onSidebarOpenChange);\n const [inspOpen, setInspOpen] = useOpen(inspectorOpen, defaultInspectorOpen, onInspectorOpenChange);\n const [sizes, setSizes] = React.useState({ sidebar: clamp(defaultSizes?.sidebar ?? 240, SIDEBAR.min, SIDEBAR.max), inspector: clamp(defaultSizes?.inspector ?? 300, INSPECTOR.min, INSPECTOR.max) });\n const [active, setActive] = React.useState<Edge | null>(null);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n const toggles = React.useRef<Record<Edge, HTMLButtonElement | null>>({ sidebar: null, inspector: null });\n const sidebarId = React.useId();\n const inspectorId = React.useId();\n const hasInspector = inspector != null;\n const sideShown = sideOpen;\n const inspShown = hasInspector && inspOpen;\n\n const keys = { sidebar: shortcuts?.sidebar === undefined ? \"mod+b\" : shortcuts.sidebar, inspector: shortcuts?.inspector === undefined ? \"mod+i\" : shortcuts.inspector };\n const map: Record<string, () => void> = {};\n if (keys.sidebar) map[keys.sidebar] = () => setSideOpen(!sideOpen);\n if (keys.inspector && hasInspector) map[keys.inspector] = () => setInspOpen(!inspOpen);\n useShortcuts(map as ShortcutMap);\n\n const commit = (edge: Edge, size: number) => {\n const next = { ...sizes, [edge]: size };\n setSizes(next);\n onSizesChange?.(next);\n };\n // The window's width, to keep the content its room: measured, and followed while the window is resized.\n React.useLayoutEffect(() => {\n const element = root.current;\n if (!element) return;\n const measure = () => setWidth(element.getBoundingClientRect().width);\n measure();\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, []);\n const ceiling = (edge: Edge) => {\n const other = edge === \"sidebar\" ? (inspShown ? sizes.inspector : 0) : sideShown ? sizes.sidebar : 0;\n const limits = edge === \"sidebar\" ? SIDEBAR : INSPECTOR;\n // The separators overlap the panes (negative margins): they take no width of their own.\n return paneMax(limits, width || Number.POSITIVE_INFINITY, other, contentMin, 0);\n };\n const direction = (): 1 | -1 => (root.current && getComputedStyle(root.current).direction === \"rtl\" ? -1 : 1);\n const sideOf = (edge: Edge): 1 | -1 => (edge === \"sidebar\" ? 1 : -1);\n const limitsOf = (edge: Edge) => (edge === \"sidebar\" ? SIDEBAR : INSPECTOR);\n\n const onPointerDown = (edge: Edge) => (event: React.PointerEvent<HTMLDivElement>) => {\n if (event.button !== 0) return;\n event.currentTarget.setPointerCapture(event.pointerId);\n const startX = event.clientX;\n const start = sizes[edge];\n const max = ceiling(edge);\n const dir = direction();\n setActive(edge);\n const target = event.currentTarget;\n const move = (e: PointerEvent) => commit(edge, dragged(start, e.clientX - startX, dir, sideOf(edge), limitsOf(edge), max));\n const stop = () => {\n setActive(null);\n target.removeEventListener(\"pointermove\", move);\n target.removeEventListener(\"pointerup\", stop);\n target.removeEventListener(\"pointercancel\", stop);\n };\n target.addEventListener(\"pointermove\", move);\n target.addEventListener(\"pointerup\", stop);\n target.addEventListener(\"pointercancel\", stop);\n };\n const onKeyDown = (edge: Edge) => (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n (edge === \"sidebar\" ? setSideOpen : setInspOpen)(false);\n // The separator goes with the pane: the focus goes to the button that brings it back.\n queueMicrotask(() => toggles.current[edge]?.focus());\n return;\n }\n const next = keyed(event.key, sizes[edge], direction(), sideOf(edge), limitsOf(edge), event.shiftKey, ceiling(edge));\n if (next === null) return;\n event.preventDefault();\n commit(edge, next);\n };\n\n const separator = (edge: Edge, controls: string, label: string) => (\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-controls={controls}\n aria-valuemin={limitsOf(edge).min}\n aria-valuemax={ceiling(edge)}\n aria-valuenow={sizes[edge]}\n tabIndex={0}\n data-edge={edge}\n data-active={active === edge ? \"\" : undefined}\n className={s.separator()}\n onPointerDown={onPointerDown(edge)}\n onKeyDown={onKeyDown(edge)}\n onDoubleClick={() => (edge === \"sidebar\" ? setSideOpen(false) : setInspOpen(false))}\n />\n );\n const toggle = (edge: Edge, label: string, pressed: boolean, onClick: () => void, d: string) => (\n <button type=\"button\" ref={(el) => { toggles.current[edge] = el; }} className={s.toggle()} aria-label={label} aria-pressed={pressed} onClick={onClick}>\n {glyph(d)}\n </button>\n );\n\n return (\n <div ref={root} data-desktop=\"\" data-sidebar={sideShown ? \"open\" : \"closed\"} className={s.root({ className })}>\n <aside id={sidebarId} aria-label={labels.sidebar} data-collapsed={sideShown ? undefined : \"\"} className={s.pane({ className: s.sidebar() })} style={{ width: sizes.sidebar }}>\n <div aria-hidden data-tauri-drag-region=\"\" className={s.titlebar()} />\n <div className={s.scroll()}>{sidebar}</div>\n </aside>\n {sideShown && separator(\"sidebar\", sidebarId, labels.resizeSidebar)}\n <div className={s.middle()}>\n <header data-tauri-drag-region=\"\" className={s.toolbar()}>\n <div className={s.toolbarGroup()}>\n {toggle(\"sidebar\", labels.toggleSidebar, sideShown, () => setSideOpen(!sideOpen), \"M4 5h16v14H4zM9 5v14\")}\n {toolbarStart}\n </div>\n <div data-tauri-drag-region=\"\" className={s.toolbarTitle()}>\n {title}\n </div>\n <div className={s.toolbarGroup()}>\n {toolbarEnd}\n {hasInspector && toggle(\"inspector\", labels.toggleInspector, inspShown, () => setInspOpen(!inspOpen), \"M4 5h16v14H4zM15 5v14\")}\n </div>\n </header>\n <main id=\"content\" tabIndex={-1} className={s.content()}>\n {children}\n </main>\n </div>\n {inspShown && separator(\"inspector\", inspectorId, labels.resizeInspector)}\n {hasInspector && (\n <aside id={inspectorId} aria-label={labels.inspector} data-collapsed={inspShown ? undefined : \"\"} className={s.pane({ className: s.inspector() })} style={{ width: sizes.inspector }}>\n <div className={s.scroll()}>{inspector}</div>\n </aside>\n )}\n </div>\n );\n}\n\n/**\n * The window's commands as one source: registers their chords in the page (`useShortcuts`, the browser's too) and returns\n * the native menu bar's data — `menus` and `handlers` for `setNativeMenu(bridge, { labels, menus }, handlers)` of\n * `@krizaka/app-desktop` — so the menu shows the keys the page answers.\n */\nexport function useDesktopCommands(commands: readonly DesktopCommand[]): DesktopMenus {\n const menus = React.useMemo(() => desktopMenus(commands), [commands]);\n useShortcuts(menus.shortcuts as ShortcutMap);\n return menus;\n}\n"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"path": "desktop-window/index.ts",
|
|
248
|
+
"content": "/**\n * @krizaka/ui/desktop-window — `DesktopWindow`: the window of a Mac app (Tauri, ADR-002) as a three-pane split —\n * sidebar · content · inspector, resizable by pointer and keyboard, collapsible — under a toolbar that moves the window and\n * clears the traffic lights, with the desktop's density and a native-feeling focus ring. `desktopMenus` turns the window's\n * commands into the native menu bar's menus (`setNativeMenu` of `@krizaka/app-desktop`), its handlers and the page's\n * shortcuts. Client.\n */\nexport { type DesktopCommand, type DesktopMenu, type DesktopMenus, desktopMenus } from \"./commands\";\nexport { DesktopWindow, desktopWindow, type DesktopWindowLabels, type DesktopWindowProps, useDesktopCommands } from \"./desktop-window\";\nexport { clamp, dragged, keyed, type PaneLimits, paneMax } from \"./panes\";\n"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"path": "desktop-window/meta.ts",
|
|
252
|
+
"content": "import type { ComponentMeta } from \"../meta\";\n\nexport const meta = {\n title: \"Desktop window\",\n summary: \"The window of a Mac app (Tauri 2 on the system WebView): a sidebar, the content and an inspector in a three-pane split — resizable by pointer and keyboard, collapsible — under a toolbar that moves the window and clears the traffic lights, at the desktop's density with a native-feeling focus ring. Its commands are written once for the menu bar, the page's shortcuts and the palette.\",\n status: \"beta\",\n category: \"layouts\",\n platforms: \"web\",\n parity: { native: { status: \"n/a\", reason: \"A phone has no windows: its screens are the list and detail, the tabs and the sheets.\", use: \"list-detail\" }, desktop: \"desktop\" },\n whenToUse: [\n \"The main window of a Tauri Mac app with a source list, a main view and the details of the selection (Finder, Mail, Xcode).\",\n \"A two-pane window: omit `inspector`.\",\n ],\n whenNotToUse: [\n { when: \"A console with grouped sections and a collapsing sidebar of words.\", use: \"app-shell\" },\n { when: \"The signed-in web app in a browser.\", use: \"app-frame\" },\n { when: \"A phone or a tablet.\", use: \"list-detail\" },\n ],\n bestPractices: [\n \"Use it at a window width of 900 pt or more (Tauri's minimum width): the content keeps 360 pt, and the panes give way to it when the window is narrower.\",\n \"Write the commands once with `useDesktopCommands`: it registers the chords in the page and returns the `menus` and `handlers` for `setNativeMenu` of `@krizaka/app-desktop`. Then pass `shortcuts={{ sidebar: false, inspector: false }}` to the window so ⌘B and ⌘I are not answered twice.\",\n \"Keep the sizes: persist `onSizesChange` (a preference of the window) and give them back as `defaultSizes`.\",\n \"Fold with the controlled `sidebarOpen` / `inspectorOpen`, so the menu's « Hide sidebar » and the toolbar's button are one state.\",\n \"Put only what moves the window's content in the toolbar (back, search, the main action); never a form.\",\n \"Controls inside use the desktop's density (32 px rows, 13 px text); do not enlarge them for touch.\",\n ],\n accessibility: {\n keyboard: [\n { keys: \"Tab to a divider\", action: \"Focuses it; it is a separator (WAI-ARIA window splitter) with its size as `aria-valuenow`.\" },\n { keys: \"← →\", action: \"Resizes the pane by 16 px (64 with Shift); the arrow pointing away from the pane's edge grows it, mirrored in right-to-left.\" },\n { keys: \"Home / End\", action: \"The smallest or the largest size.\" },\n { keys: \"Enter on a divider\", action: \"Folds its pane; the focus goes to the toolbar's button that brings it back.\" },\n { keys: \"⌘B / ⌘I\", action: \"Fold the sidebar and the inspector.\" },\n ],\n notes: [\n \"The panes are `aside` landmarks named by `labels`; the toolbar is the window's `header`, the content its `main`.\",\n \"The dividers are the only draggable things; the toolbar's drag region is the bar, its title and the gaps — never a control, so every button keeps its click and its focus.\",\n \"The focus ring is the macOS one (a 3 px halo of the accent) and shows for the keyboard only.\",\n ],\n },\n related: [\"app-shell\", \"split-view\", \"app-frame\", \"kbd\"],\n web: {\n imports: [\"DesktopWindow\", \"useDesktopCommands\", \"desktopMenus\"],\n examples: [\n { name: \"library\", title: \"A library window\", description: \"A source list, a list of files and the details of the selected one; ⌘B and ⌘I fold the panes, the menu bar gets the same commands.\", template: true, purpose: \"operate\", why: \"A person on a Mac works with a list and the details of what they select, with the keys and the menus of a Mac app.\" },\n ],\n },\n} satisfies ComponentMeta;\n"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"path": "desktop-window/panes.ts",
|
|
256
|
+
"content": "// Pure: the arithmetic of the resizable panes, so it is tested without a pointer.\n\nexport interface PaneLimits {\n min: number;\n max: number;\n}\n\nexport const clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), Math.max(min, max));\n\n/**\n * The most a pane may take: its own maximum, and what leaves the content its minimum beside the other open pane and the\n * two separators. A window that is too small for both gives the content priority, down to the pane's own minimum.\n */\nexport function paneMax(limits: PaneLimits, windowWidth: number, otherOpenWidth: number, contentMin: number, separators: number): number {\n return Math.max(limits.min, Math.min(limits.max, windowWidth - otherOpenWidth - contentMin - separators));\n}\n\n/** The size after a drag of `delta` px along the reading direction (`direction` 1 in LTR, -1 in RTL; `side` 1 for the start pane, -1 for the end one). */\nexport function dragged(start: number, delta: number, direction: 1 | -1, side: 1 | -1, limits: PaneLimits, ceiling = limits.max): number {\n return clamp(start + delta * direction * side, limits.min, ceiling);\n}\n\n/** The size after an arrow key: the arrow that points away from the pane's edge grows it (→ for the start pane in LTR). `null` for another key. */\nexport function keyed(key: string, current: number, direction: 1 | -1, side: 1 | -1, limits: PaneLimits, shift: boolean, ceiling = limits.max): number | null {\n const step = shift ? 64 : 16;\n if (key === \"Home\") return limits.min;\n if (key === \"End\") return Math.max(limits.min, ceiling);\n if (key !== \"ArrowLeft\" && key !== \"ArrowRight\") return null;\n const toward = key === \"ArrowRight\" ? 1 : -1;\n return clamp(current + step * toward * direction * side, limits.min, ceiling);\n}\n"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"path": "meta.ts",
|
|
260
|
+
"content": "// The documentation of a component, carried by its code: each primitive has a `meta.ts` beside its source\n// (`src/<name>/meta.ts`; a component that exists only in React Native: `src/native/meta/<name>.ts`). Never built into\n// the package: `scripts/build-registry.mjs` reads them into `registry/<name>.json`, which ui.krizaka.com (apps/site) renders as\n// ui.krizaka.com/components/<name>, and `scripts/registry.test.mjs` fails when one is missing or incomplete.\n//\n// Why a typed module and not JSDoc tags: the fields are lists and links (`related`, `whenNotToUse[].use`, examples),\n// which a type checks and a comment does not; the file is plain data (erasable TypeScript), so Node reads it without a\n// compiler, and an editor completes it.\n\n/** Every documented component: the web primitives (one entry of the package each) and the native-only ones. */\nexport type ComponentName =\n | \"notification-preferences\"\n | \"quota-meter\"\n | \"environment-notice\"\n | \"embed-facade\"\n | \"reviews\"\n | \"margin-layout\"\n | \"analysis-report\"\n | \"status-chip\"\n | \"kind-config-editor\"\n | \"agenda\"\n | \"account-settings\"\n | \"drop-overlay\"\n | \"upload-queue\"\n | \"achievement\"\n | \"anatomy-plate\"\n | \"bird-plate\"\n | \"taped-photo\"\n | \"stuck\"\n | \"doodle\"\n | \"signature\"\n | \"grade-stamp\"\n | \"versus-card\"\n | \"speed-lines\"\n | \"site-cahier\"\n | \"text-style\"\n | \"flock\"\n | \"elephant\"\n | \"footnote\"\n | \"page-index\"\n | \"chapter\"\n | \"specimen-tag\"\n | \"action-bar\"\n | \"action-sheet\"\n | \"activity-feed\"\n | \"alert\"\n | \"app-frame\"\n | \"desktop-window\"\n | \"form-flow\"\n | \"grid\"\n | \"list-detail\"\n | \"state-screen\"\n | \"app-header\"\n | \"app-shell\"\n | \"argument-card\"\n | \"audio-player\"\n | \"auth-layout\"\n | \"avatar\"\n | \"badge\"\n | \"button\"\n | \"captcha\"\n | \"card\"\n | \"card-grid\"\n | \"catalogue-page\"\n | \"changelog-page\"\n | \"chat\"\n | \"checkbox\"\n | \"chip\"\n | \"chip-link\"\n | \"chip-row\"\n | \"choice-grid\"\n | \"cn\"\n | \"code-block\"\n | \"combobox\"\n | \"comparison-table\"\n | \"command\"\n | \"component-page\"\n | \"confirm-button\"\n | \"contact-page\"\n | \"continue-prompt\"\n | \"countdown\"\n | \"cover-hero\"\n | \"cta-panel\"\n | \"dashboard-layout\"\n | \"data-table\"\n | \"date-picker\"\n | \"decision-list\"\n | \"description-list\"\n | \"detail-layout\"\n | \"dialog\"\n | \"docs-article-page\"\n | \"docs-hub-page\"\n | \"docs-layout\"\n | \"docs-nav\"\n | \"document-viewer\"\n | \"dropdown-menu\"\n | \"empty-state\"\n | \"engine-flow\"\n | \"error-page\"\n | \"fab\"\n | \"field\"\n | \"file-upload\"\n | \"filter-bar\"\n | \"force-update-screen\"\n | \"form\"\n | \"gallery-page\"\n | \"genui\"\n | \"glossary\"\n | \"glossary-term\"\n | \"glow-card\"\n | \"goal-gauge\"\n | \"header\"\n | \"how-it-works-page\"\n | \"image-cropper\"\n | \"image-viewer\"\n | \"iso\"\n | \"kanban\"\n | \"kbd\"\n | \"kpi-explained\"\n | \"landing-page\"\n | \"landscape\"\n | \"legal-page\"\n | \"link-card\"\n | \"list\"\n | \"loader\"\n | \"longform-page\"\n | \"maintenance-screen\"\n | \"map\"\n | \"markdown\"\n | \"meta-row\"\n | \"waveform\"\n | \"marketing-layout\"\n | \"marquee\"\n | \"mascot-quote\"\n | \"mascot-state\"\n | \"mascots\"\n | \"match-dialog\"\n | \"media-capture\"\n | \"media-grid\"\n | \"language-switch\"\n | \"media-gallery\"\n | \"media-picker\"\n | \"meter\"\n | \"nav-bar\"\n | \"number-ticker\"\n | \"onboarding\"\n | \"opening-hours\"\n | \"otp-input\"\n | \"page\"\n | \"page-header\"\n | \"page-hero\"\n | \"pagination\"\n | \"permission-prompt\"\n | \"photo-grid\"\n | \"pointer-light\"\n | \"popover\"\n | \"pricing-page\"\n | \"product-page\"\n | \"profile-card\"\n | \"progress\"\n | \"promise-card\"\n | \"pull-to-refresh\"\n | \"retro-tv\"\n | \"radio-group\"\n | \"router\"\n | \"rail-nav\"\n | \"recipes\"\n | \"screen\"\n | \"scroll-stage\"\n | \"search-field\"\n | \"section-backdrop\"\n | \"segmented\"\n | \"separator\"\n | \"service-card\"\n | \"shop\"\n | \"shop-composer\"\n | \"settings-layout\"\n | \"account-menu\"\n | \"showcase\"\n | \"step-showcase\"\n | \"site-footer\"\n | \"sites\"\n | \"skeleton\"\n | \"skip-link\"\n | \"slider\"\n | \"slot-picker\"\n | \"slot\"\n | \"spinner\"\n | \"sticky-action\"\n | \"splash-handoff\"\n | \"split-view\"\n | \"stage-banner\"\n | \"stat\"\n | \"usage\"\n | \"status-page\"\n | \"step-progress\"\n | \"stepper\"\n | \"swipe-deck\"\n | \"swipeable-row\"\n | \"switch\"\n | \"tab-bar\"\n | \"tabs\"\n | \"tag-input\"\n | \"tag-selector\"\n | \"terminal-replay\"\n | \"theme\"\n | \"toast\"\n | \"toc\"\n | \"tooltip\"\n | \"tree-view\"\n | \"txt\"\n | \"update-prompt\"\n | \"verified-badge\"\n | \"vertical-video\"\n | \"video-player\"\n | \"video-trimmer\"\n | \"virtual\"\n | \"wall\";\n\n/** Where a component exists: `@krizaka/ui/<name>` (web), `@krizaka/ui/native` (React Native), or both. */\nexport type Platform = \"web\" | \"native\" | \"both\";\n\n/**\n * Why a component is not on a platform — a decision, never a silence (the parity matrix of ui.krizaka.com/platforms):\n * - `gap` (✗): it belongs there and is not built yet; `issue` is the issue that tracks it (`krizaka/krizaka-ui#275`);\n * - `n/a`: it is not meant for that platform (a site's page block on a phone, a swipe on a desktop); `use` names the\n * component that answers there, when one does.\n */\nexport type Absence =\n | { readonly status: \"gap\"; readonly issue: string; readonly reason: string; readonly use?: undefined }\n | { readonly status: \"n/a\"; readonly reason: string; readonly use?: ComponentName; readonly issue?: undefined };\n\n/**\n * Desktop is the Orazaka Mac app (Tauri 2: the system WebView renders the web components — ADR-002). `web`: the web\n * component runs there as it is; `desktop`: it also has a desktop form (a window's title bar, a denser layout…), said in\n * its documentation; otherwise the absence and why.\n */\nexport type DesktopSupport = \"web\" | \"desktop\" | Absence;\n\n/**\n * The three platforms of Krizaka UI — web · native (React Native, Expo) · desktop — for one component. The side a\n * component has is `platforms`; the side it lacks says why here: `native` is required for (and only for) a web-only\n * component, `web` for a native-only one; `desktop` always. `scripts/registry.test.mjs` fails on a missing decision.\n */\nexport interface Parity {\n readonly web?: Absence;\n readonly native?: Absence;\n readonly desktop: DesktopSupport;\n}\n\n/**\n * `stable`: its API only changes in a major. `beta`: it may still change in a minor. `deprecated`: no product uses it and\n * no work plans to — it still works, says what replaces it, and goes in the major named by `deprecated.removedIn`.\n */\nexport type Status = \"stable\" | \"beta\" | \"deprecated\";\n\n/** What a deprecated component says (required when `status` is `deprecated`, absent otherwise). */\nexport interface Deprecation {\n /** The version that deprecated it (`3.6.0`). */\n readonly since: string;\n /** The major that removes it (`4.0.0`). */\n readonly removedIn: string;\n /** What replaces it, when a component does. */\n readonly use?: ComponentName;\n /** Why it goes: no product uses it, no planned work needs it. */\n readonly reason: string;\n}\n\n/**\n * The group of the catalogue. `media`: video, sound, camera, files, cropping. `blocks`: the page blocks — the frame,\n * the hero, sections, cards that lead or argue, decisions, code, calls to act — that every page of a site is made of.\n * `layouts`: the shells of whole screens — an application, a dashboard, settings, sign-in, an object, a list and its\n * item, a site's page, a documentation page — each with its screens. `templates`: the page templates — whole pages of a\n * site (a landing, a product, a docs hub, a long read, a changelog, pricing, status, an error…), each a distinct\n * composition of the blocks, words and content as props.\n */\nexport type Category = \"actions\" | \"forms\" | \"navigation\" | \"overlays\" | \"feedback\" | \"data-display\" | \"media\" | \"blocks\" | \"layouts\" | \"templates\" | \"layout\" | \"foundations\";\n\n/** Why a reader needs a template: the seven intents the templates are grouped by (sidebar sub-headings, catalogue filter). */\nexport type TemplatePurpose = \"convince\" | \"explain\" | \"show\" | \"act\" | \"operate\" | \"converse\" | \"recover\";\n\n/** The groups of templates, in reading order: the title, and the one line that says when to come to that group. */\nexport const templatePurposes = {\n convince: { title: \"Convince\", useWhen: \"You come here when a visitor must decide: a landing, a product, a price, a comparison, a proof.\" },\n explain: { title: \"Explain\", useWhen: \"You come here when a reader must understand: how it works, a documentation hub or article, a changelog, a FAQ, a policy.\" },\n show: { title: \"Show\", useWhen: \"You come here when the work itself is the argument: a gallery, a story, a case study, an object and its details.\" },\n act: { title: \"Act\", useWhen: \"You come here when a person must do something once: reach the team, sign in or up, set up, pay.\" },\n operate: { title: \"Operate\", useWhen: \"You come here when a person works every day: a dashboard, a console with a table, settings, an app shell.\" },\n converse: { title: \"Converse\", useWhen: \"You come here when people talk: an inbox, a chat, comments, a notifications centre.\" },\n recover: { title: \"Recover\", useWhen: \"You come here when the way is blocked: an empty list, an error, a missing page, maintenance, a product still being built.\" },\n} as const satisfies Record<TemplatePurpose, { readonly title: string; readonly useWhen: string }>;\n\n/**\n * A named example: the file `registry/examples/<component>/<name>.tsx` (web) or\n * `registry/examples/<component>/native/<name>.tsx` (React Native) — at most 40 lines, imported by the stories and\n * shown (live, with its code) by the documentation.\n */\ninterface ExampleBase {\n /** The file name, kebab-case (`primary`, `icon-button`). */\n readonly name: string;\n /** A short title (`Primary`, `Icon button`). */\n readonly title: string;\n /** One or two sentences: when this variant is the right one. */\n readonly description: string;\n}\n\n/** A plain example, or a template: a whole screen with its intent (`purpose`) and the user goal its layout serves (`why`). */\nexport type Example =\n | (ExampleBase & { readonly template?: false; readonly purpose?: undefined; readonly why?: undefined })\n | (ExampleBase & {\n /**\n * A template: a whole screen of a product composed from the platform (a layout and its blocks, real words, its\n * phone version thought out), copied as a starting point — at most 160 lines, listed on ui.krizaka.com/templates.\n */\n readonly template: true;\n /** The intent that groups it: why you need this block. */\n readonly purpose: TemplatePurpose;\n /** Why this layout: the user goal it serves, in one sentence. */\n readonly why: string;\n });\n\n/** One platform's side of a component. */\nexport interface PlatformDocs {\n /** The names to import (`[\"Button\", \"IconButton\"]`): from `@krizaka/ui/<name>` on the web, `@krizaka/ui/native` in React Native. */\n readonly imports: readonly string[];\n /** The examples, in reading order; the first one is the component's preview. */\n readonly examples: readonly Example[];\n}\n\n/** The React Native side: the same concept, and what differs from the web API. */\nexport interface NativeDocs extends PlatformDocs {\n /**\n * The entry to import from when it is not `@krizaka/ui/native`: a component that needs an Expo module (an optional\n * peer) has its own, `@krizaka/ui/native/<name>`, so an app that does not use it never installs the module.\n */\n readonly entry?: string;\n /** What differs from the web API (`label` instead of children…); empty for a native-only component. */\n readonly differences: readonly string[];\n /** The React Native entry alone is deprecated while the web one stays (ADR-006 §7); a deprecated component says it once, above. */\n readonly deprecated?: Deprecation;\n}\n\nexport interface KeyboardInteraction {\n /** The keys, as written on a keyboard: `Space`, `Enter`, `Arrow keys`, `Esc`, `Tab`. */\n readonly keys: string;\n /** What they do. */\n readonly action: string;\n}\n\nexport interface ComponentMeta {\n /** The display name: `Button`, `Dropdown menu`. */\n readonly title: string;\n /** One sentence: what it is. */\n readonly summary: string;\n readonly status: Status;\n /** Required for, and only for, a `deprecated` component. */\n readonly deprecated?: Deprecation;\n readonly category: Category;\n /** Must match the sides below: `both` ⇔ `web` and `native`. */\n readonly platforms: Platform;\n /** The platforms it is not on, and why; and its desktop form (see `Parity`). */\n readonly parity: Parity;\n /** When to reach for it: concrete situations, one per item. */\n readonly whenToUse: readonly string[];\n /** When not to — and what to use instead (`use`), when another component is the answer. */\n readonly whenNotToUse: readonly { readonly when: string; readonly use?: ComponentName }[];\n /** How to use it well: wording, placement, composition. */\n readonly bestPractices: readonly string[];\n readonly accessibility: {\n /** The keyboard, when it does more than Tab and Enter. */\n readonly keyboard: readonly KeyboardInteraction[];\n /** Roles, names and announcements: what the component does, what the app must provide. */\n readonly notes: readonly string[];\n };\n /** The components a reader of this page should know about. */\n readonly related: readonly ComponentName[];\n readonly web?: PlatformDocs;\n readonly native?: NativeDocs;\n}\n"
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
"dependencies": [
|
|
264
|
+
"tailwind-variants@^3.3.1"
|
|
265
|
+
],
|
|
266
|
+
"registryDependencies": [
|
|
267
|
+
"app-shell"
|
|
268
|
+
],
|
|
269
|
+
"demo": {
|
|
270
|
+
"path": "examples/desktop-window/library.tsx",
|
|
271
|
+
"content": "\"use client\";\n\nimport { ProductLogo } from \"@krizaka/ui\";\nimport { Badge } from \"@krizaka/ui/badge\";\nimport { Button } from \"@krizaka/ui/button\";\nimport { DesktopWindow, useDesktopCommands } from \"@krizaka/ui/desktop-window\";\nimport { useState } from \"react\";\n\nconst FILES = [\"Lease — 12 rue Fleury\", \"Payslips — Ada Roy\", \"ID — Noor Khan\", \"Lease — 8 av. du Parc\"];\n\n// TEMPLATE — The window of a Mac app: sidebar · content · inspector, resizable (drag a divider, or focus it and use the\n// arrows) and collapsible (⌘B, ⌘I, the toolbar). The commands are written once: the menu bar gets them from `menus` and\n// `handlers` (`setNativeMenu(bridge, { labels, menus }, handlers)` of @krizaka/app-desktop), the page answers the same keys.\nexport default function DesktopWindowLibrary() {\n const [sidebar, setSidebar] = useState(true);\n const [inspector, setInspector] = useState(true);\n const [current, setCurrent] = useState(0);\n useDesktopCommands([\n { id: \"view.sidebar\", menu: \"View\", label: sidebar ? \"Hide sidebar\" : \"Show sidebar\", shortcut: \"mod+b\", run: () => setSidebar(!sidebar) },\n { id: \"view.inspector\", menu: \"View\", label: inspector ? \"Hide inspector\" : \"Show inspector\", shortcut: \"mod+i\", run: () => setInspector(!inspector) },\n ]);\n return (\n <DesktopWindow\n className=\"[--kz-window-height:34rem]\"\n shortcuts={{ sidebar: false, inspector: false }}\n sidebarOpen={sidebar}\n onSidebarOpenChange={setSidebar}\n inspectorOpen={inspector}\n onInspectorOpenChange={setInspector}\n labels={{ sidebar: \"Library\", inspector: \"Details\", resizeSidebar: \"Resize the sidebar\", resizeInspector: \"Resize the inspector\", toggleSidebar: \"Show or hide the sidebar\", toggleInspector: \"Show or hide the inspector\" }}\n title=\"Applicant files\"\n toolbarEnd={<Button size=\"sm\" variant=\"primary\">New file</Button>}\n sidebar={\n <div className=\"flex flex-col gap-0.5 p-2\">\n <div className=\"flex items-center gap-2 px-2 py-1.5 font-semibold\"><ProductLogo id=\"yomizaka\" size={18} animated={false} /> Yomizaka</div>\n {[\"All files\", \"To decide\", \"Verified\"].map((name, i) => (\n <button key={name} type=\"button\" aria-current={i === 0 ? \"page\" : undefined} className=\"h-8 cursor-default rounded-md px-2 text-start hover:bg-surface-2 aria-[current=page]:bg-accent-soft\">{name}</button>\n ))}\n </div>\n }\n inspector={\n <div className=\"space-y-2 p-4\">\n <p className=\"text-xs font-semibold text-fg-secondary\">Details</p>\n <p className=\"font-semibold\">{FILES[current]}</p>\n <Badge tone=\"success\" dot>Verified</Badge>\n </div>\n }\n >\n <ul className=\"divide-y divide-border-subtle\">\n {FILES.map((file, i) => (\n <li key={file}>\n <button type=\"button\" aria-pressed={i === current} onClick={() => setCurrent(i)} className=\"block h-9 w-full cursor-default truncate px-4 text-start hover:bg-surface-2 aria-pressed:bg-accent-soft\">{file}</button>\n </li>\n ))}\n </ul>\n </DesktopWindow>\n );\n}\n"
|
|
272
|
+
},
|
|
273
|
+
"props": [
|
|
274
|
+
{
|
|
275
|
+
"component": "DesktopWindow",
|
|
276
|
+
"description": "The window of a Mac app: sidebar · content · inspector, a toolbar that moves the window, the desktop's density.",
|
|
277
|
+
"props": [
|
|
278
|
+
{
|
|
279
|
+
"name": "children",
|
|
280
|
+
"type": "ReactNode",
|
|
281
|
+
"default": null,
|
|
282
|
+
"description": "The main content under the toolbar.",
|
|
283
|
+
"required": true
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"name": "labels",
|
|
287
|
+
"type": "DesktopWindowLabels",
|
|
288
|
+
"default": null,
|
|
289
|
+
"description": "The words of the panes, the dividers and the toggles — passed translated.",
|
|
290
|
+
"required": true
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"name": "sidebar",
|
|
294
|
+
"type": "ReactNode",
|
|
295
|
+
"default": null,
|
|
296
|
+
"description": "The sidebar's content: a list of places, a `Tree`. It scrolls by itself.",
|
|
297
|
+
"required": true
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
"name": "className",
|
|
301
|
+
"type": "string",
|
|
302
|
+
"default": null,
|
|
303
|
+
"description": "Classes for the window (`[--kz-window-height:34rem]` to size it inside a page).",
|
|
304
|
+
"required": false
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"name": "contentMin",
|
|
308
|
+
"type": "number",
|
|
309
|
+
"default": "360",
|
|
310
|
+
"description": "The least the content keeps when the window is narrow (default 360).",
|
|
311
|
+
"required": false
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
"name": "defaultInspectorOpen",
|
|
315
|
+
"type": "boolean",
|
|
316
|
+
"default": "true",
|
|
317
|
+
"description": "The inspector starts open (default true) when uncontrolled.",
|
|
318
|
+
"required": false
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"name": "defaultSidebarOpen",
|
|
322
|
+
"type": "boolean",
|
|
323
|
+
"default": "true",
|
|
324
|
+
"description": "The sidebar starts open (default true) when uncontrolled.",
|
|
325
|
+
"required": false
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"name": "defaultSizes",
|
|
329
|
+
"type": "{ sidebar?: number; inspector?: number; } | undefined",
|
|
330
|
+
"default": null,
|
|
331
|
+
"description": "The sizes in px: the sidebar's, the inspector's. Persist them with `onSizesChange`.",
|
|
332
|
+
"required": false
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"name": "inspector",
|
|
336
|
+
"type": "ReactNode",
|
|
337
|
+
"default": null,
|
|
338
|
+
"description": "The inspector's content: the selected item's details. Without it, a two-pane window.",
|
|
339
|
+
"required": false
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"name": "inspectorOpen",
|
|
343
|
+
"type": "boolean",
|
|
344
|
+
"default": null,
|
|
345
|
+
"description": "The inspector is open (controlled).",
|
|
346
|
+
"required": false
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"name": "onInspectorOpenChange",
|
|
350
|
+
"type": "((open: boolean) => void)",
|
|
351
|
+
"default": null,
|
|
352
|
+
"description": "Called when the inspector folds or unfolds.",
|
|
353
|
+
"required": false
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"name": "onSidebarOpenChange",
|
|
357
|
+
"type": "((open: boolean) => void)",
|
|
358
|
+
"default": null,
|
|
359
|
+
"description": "Called when the sidebar folds or unfolds (the toolbar, a divider, the shortcut).",
|
|
360
|
+
"required": false
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
"name": "onSizesChange",
|
|
364
|
+
"type": "((sizes: { sidebar: number; inspector: number; }) => void)",
|
|
365
|
+
"default": null,
|
|
366
|
+
"description": "Called with the sizes in px after a drag or a key: persist them.",
|
|
367
|
+
"required": false
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
"name": "shortcuts",
|
|
371
|
+
"type": "{ sidebar?: string | false; inspector?: string | false; } | undefined",
|
|
372
|
+
"default": null,
|
|
373
|
+
"description": "The keys that fold the panes (a chord, or `false` for none): ⌘B and ⌘I by default. Pass `false` when the menu bar's commands (`useDesktopCommands`) own them.",
|
|
374
|
+
"required": false
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"name": "sidebarOpen",
|
|
378
|
+
"type": "boolean",
|
|
379
|
+
"default": null,
|
|
380
|
+
"description": "The sidebar is open (controlled). Pair with `onSidebarOpenChange`: the menu bar's command toggles it too.",
|
|
381
|
+
"required": false
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
"name": "title",
|
|
385
|
+
"type": "ReactNode",
|
|
386
|
+
"default": null,
|
|
387
|
+
"description": "The toolbar's title, centred in the drag region.",
|
|
388
|
+
"required": false
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
"name": "toolbarEnd",
|
|
392
|
+
"type": "ReactNode",
|
|
393
|
+
"default": null,
|
|
394
|
+
"description": "Before the inspector's toggle, at the end of the toolbar (actions, search).",
|
|
395
|
+
"required": false
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
"name": "toolbarStart",
|
|
399
|
+
"type": "ReactNode",
|
|
400
|
+
"default": null,
|
|
401
|
+
"description": "After the sidebar's toggle, at the start of the toolbar (back, forward).",
|
|
402
|
+
"required": false
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
]
|
|
407
|
+
}
|