@krizaka/ui 3.71.0 → 3.73.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/blocks.css +26 -0
- package/dist/chunk-M3T5RQYV.js +34 -0
- package/dist/chunk-M3T5RQYV.js.map +1 -0
- package/dist/chunk-ZFR6ZNXD.js +203 -0
- package/dist/chunk-ZFR6ZNXD.js.map +1 -0
- package/dist/filter-bar.d.ts +3 -3
- package/dist/{frame-D6Xv83t8.d.ts → frame-CNZ5VgDD.d.ts} +11 -4
- package/dist/retro-tv-playlist.d.ts +148 -0
- package/dist/retro-tv-playlist.js +234 -0
- package/dist/retro-tv-playlist.js.map +1 -0
- package/dist/retro-tv.js +4 -160
- package/dist/retro-tv.js.map +1 -1
- package/dist/schema-DgjBz7-8.d.ts +242 -0
- package/dist/shop/booking.d.ts +2 -2
- package/dist/shop/booking.js +1 -1
- package/dist/shop/booking.js.map +1 -1
- package/dist/shop/bulletin.js +1 -1
- package/dist/shop/faq.d.ts +2 -1
- package/dist/shop/faq.js +1 -1
- package/dist/shop/faq.js.map +1 -1
- package/dist/shop/gallery.js +1 -1
- package/dist/shop/look.d.ts +43 -0
- package/dist/shop/look.js +52 -0
- package/dist/shop/look.js.map +1 -0
- package/dist/shop/policies.d.ts +2 -1
- package/dist/shop/policies.js +1 -1
- package/dist/shop/policies.js.map +1 -1
- package/dist/shop/reviews.d.ts +2 -1
- package/dist/shop/reviews.js +1 -1
- package/dist/shop/reviews.js.map +1 -1
- package/dist/shop/services.js +1 -1
- package/dist/shop/social.js +1 -1
- package/dist/shop/story.d.ts +2 -1
- package/dist/shop/story.js +1 -1
- package/dist/shop/story.js.map +1 -1
- package/dist/shop/team.js +1 -1
- package/dist/shop/video.js +1 -1
- package/dist/shop/visit.js +1 -1
- package/dist/shop-composer.d.ts +29 -0
- package/dist/shop-composer.js +156 -89
- package/dist/shop-composer.js.map +1 -1
- package/dist/shop.d.ts +6 -240
- package/dist/shop.js +24 -212
- package/dist/shop.js.map +1 -1
- package/package.json +37 -7
- package/registry/account-menu.json +4 -2
- package/registry/account-settings.json +4 -2
- package/registry/achievement.json +4 -2
- package/registry/action-bar.json +4 -2
- package/registry/action-sheet.json +2 -0
- package/registry/activity-feed.json +4 -2
- package/registry/agenda.json +4 -2
- package/registry/alert.json +4 -2
- package/registry/analysis-report.json +4 -2
- package/registry/anatomy-plate.json +4 -2
- package/registry/app-frame.json +5 -3
- package/registry/app-header.json +4 -2
- package/registry/app-shell.json +4 -2
- package/registry/argument-card.json +4 -2
- package/registry/audio-player.json +4 -2
- package/registry/auth-layout.json +4 -2
- package/registry/avatar.json +4 -2
- package/registry/badge.json +4 -2
- package/registry/bird-plate.json +4 -2
- package/registry/button.json +4 -2
- package/registry/captcha.json +4 -2
- package/registry/card-grid.json +4 -2
- package/registry/card.json +4 -2
- package/registry/catalogue-page.json +4 -2
- package/registry/changelog-page.json +4 -2
- package/registry/chapter.json +4 -2
- package/registry/chat.json +4 -2
- package/registry/checkbox.json +4 -2
- package/registry/chip-link.json +4 -2
- package/registry/chip-row.json +4 -2
- package/registry/chip.json +4 -2
- package/registry/choice-grid.json +4 -2
- package/registry/cn.json +2 -0
- package/registry/code-block.json +4 -2
- package/registry/collection-switcher.json +4 -2
- package/registry/combobox.json +4 -2
- package/registry/command.json +4 -2
- package/registry/comparison-table.json +4 -2
- package/registry/component-page.json +4 -2
- package/registry/confirm-button.json +4 -2
- package/registry/contact-page.json +4 -2
- package/registry/continue-prompt.json +4 -2
- package/registry/copy-button.json +4 -2
- package/registry/countdown.json +4 -2
- package/registry/cover-hero.json +4 -2
- package/registry/cta-panel.json +4 -2
- package/registry/dashboard-layout.json +4 -2
- package/registry/data-table.json +4 -2
- package/registry/date-picker.json +4 -2
- package/registry/decision-list.json +4 -2
- package/registry/description-list.json +4 -2
- package/registry/desktop-window.json +5 -3
- package/registry/detail-layout.json +4 -2
- package/registry/dialog.json +4 -2
- package/registry/docs-article-page.json +4 -2
- package/registry/docs-hub-page.json +4 -2
- package/registry/docs-layout.json +4 -2
- package/registry/docs-nav.json +4 -2
- package/registry/document-viewer.json +4 -2
- package/registry/doodle.json +4 -2
- package/registry/drop-overlay.json +4 -2
- package/registry/dropdown-menu.json +4 -2
- package/registry/elephant.json +5 -3
- package/registry/embed-facade.json +4 -2
- package/registry/empty-state.json +4 -2
- package/registry/engine-flow.json +4 -2
- package/registry/entity-header.json +4 -2
- package/registry/environment-notice.json +4 -2
- package/registry/error-page.json +4 -2
- package/registry/fab.json +2 -0
- package/registry/field.json +4 -2
- package/registry/file-upload.json +4 -2
- package/registry/filter-bar.json +4 -2
- package/registry/flock.json +4 -2
- package/registry/footnote.json +4 -2
- package/registry/force-update-screen.json +4 -2
- package/registry/form-flow.json +3 -1
- package/registry/form.json +4 -2
- package/registry/gallery-page.json +4 -2
- package/registry/genui.json +4 -2
- package/registry/glossary-term.json +4 -2
- package/registry/glossary.json +4 -2
- package/registry/glow-card.json +4 -2
- package/registry/goal-gauge.json +4 -2
- package/registry/grade-stamp.json +4 -2
- package/registry/grid.json +2 -0
- package/registry/header.json +2 -0
- package/registry/how-it-works-page.json +4 -2
- package/registry/image-cropper.json +4 -2
- package/registry/image-viewer.json +2 -0
- package/registry/index.json +19 -18
- package/registry/iso.json +4 -2
- package/registry/kanban.json +4 -2
- package/registry/kbd.json +4 -2
- package/registry/kind-config-editor.json +4 -2
- package/registry/kpi-explained.json +4 -2
- package/registry/landing-page.json +4 -2
- package/registry/landscape.json +4 -2
- package/registry/language-switch.json +4 -2
- package/registry/legal-page.json +4 -2
- package/registry/link-card.json +4 -2
- package/registry/list-detail.json +2 -0
- package/registry/list.json +4 -2
- package/registry/loader.json +4 -2
- package/registry/longform-page.json +4 -2
- package/registry/maintenance-screen.json +4 -2
- package/registry/map.json +5 -3
- package/registry/margin-layout.json +4 -2
- package/registry/markdown.json +4 -2
- package/registry/marketing-layout.json +4 -2
- package/registry/marquee.json +4 -2
- package/registry/mascot-quote.json +4 -2
- package/registry/mascot-state.json +4 -2
- package/registry/mascots.json +4 -2
- package/registry/match-dialog.json +4 -2
- package/registry/media-capture.json +4 -2
- package/registry/media-gallery.json +4 -2
- package/registry/media-grid.json +4 -2
- package/registry/media-picker.json +2 -0
- package/registry/meta-row.json +4 -2
- package/registry/meter.json +4 -2
- package/registry/money-input.json +5 -3
- package/registry/nav-bar.json +5 -3
- package/registry/next-actions.json +4 -2
- package/registry/notification-preferences.json +4 -2
- package/registry/number-ticker.json +4 -2
- package/registry/onboarding.json +2 -0
- package/registry/opening-hours.json +4 -2
- package/registry/otp-input.json +2 -0
- package/registry/page-header.json +4 -2
- package/registry/page-hero.json +4 -2
- package/registry/page-index.json +4 -2
- package/registry/page.json +4 -2
- package/registry/pagination.json +4 -2
- package/registry/permission-prompt.json +2 -0
- package/registry/photo-grid.json +4 -2
- package/registry/pointer-light.json +4 -2
- package/registry/popover.json +4 -2
- package/registry/price-catalogue-editor.json +5 -3
- package/registry/pricing-page.json +4 -2
- package/registry/product-page.json +4 -2
- package/registry/profile-card.json +4 -2
- package/registry/progress.json +4 -2
- package/registry/promise-card.json +4 -2
- package/registry/promo-code-field.json +5 -3
- package/registry/proposal.json +5 -3
- package/registry/pull-to-refresh.json +2 -0
- package/registry/qr-code.json +4 -2
- package/registry/quota-meter.json +4 -2
- package/registry/radio-group.json +4 -2
- package/registry/rail-nav.json +5 -3
- package/registry/recipes.json +4 -2
- package/registry/retro-tv.json +9 -3
- package/registry/reviews.json +4 -2
- package/registry/router.json +4 -2
- package/registry/schema-form.json +5 -3
- package/registry/screen.json +2 -0
- package/registry/scroll-stage.json +4 -2
- package/registry/search-field.json +4 -2
- package/registry/section-backdrop.json +4 -2
- package/registry/segmented.json +2 -0
- package/registry/separator.json +4 -2
- package/registry/service-card.json +4 -2
- package/registry/settings-layout.json +4 -2
- package/registry/shop-composer.json +13 -7
- package/registry/shop-gallery.json +5 -3
- package/registry/shop.json +54 -11
- package/registry/showcase.json +4 -2
- package/registry/signature.json +4 -2
- package/registry/site-cahier.json +4 -2
- package/registry/site-footer.json +5 -3
- package/registry/sites.json +4 -2
- package/registry/skeleton.json +4 -2
- package/registry/skip-link.json +4 -2
- package/registry/slider.json +4 -2
- package/registry/slot-picker.json +4 -2
- package/registry/slot.json +4 -2
- package/registry/specimen-tag.json +4 -2
- package/registry/speed-lines.json +4 -2
- package/registry/spinner.json +4 -2
- package/registry/splash-handoff.json +2 -0
- package/registry/split-view.json +4 -2
- package/registry/stage-banner.json +4 -2
- package/registry/stat.json +4 -2
- package/registry/state-screen.json +3 -1
- package/registry/status-chip.json +4 -2
- package/registry/status-page.json +4 -2
- package/registry/step-progress.json +4 -2
- package/registry/step-showcase.json +4 -2
- package/registry/stepper.json +4 -2
- package/registry/sticky-action.json +4 -2
- package/registry/stuck.json +4 -2
- package/registry/swipe-deck.json +4 -2
- package/registry/swipeable-row.json +2 -0
- package/registry/switch.json +4 -2
- package/registry/tab-bar.json +2 -0
- package/registry/tabs.json +4 -2
- package/registry/tag-input.json +4 -2
- package/registry/tag-selector.json +4 -2
- package/registry/taped-photo.json +4 -2
- package/registry/terminal-replay.json +4 -2
- package/registry/text-style.json +4 -2
- package/registry/theme.json +4 -2
- package/registry/toast.json +4 -2
- package/registry/toc.json +4 -2
- package/registry/tooltip.json +4 -2
- package/registry/tree-view.json +4 -2
- package/registry/txt.json +2 -0
- package/registry/update-prompt.json +4 -2
- package/registry/upload-queue.json +4 -2
- package/registry/usage.json +5 -3
- package/registry/verified-badge.json +4 -2
- package/registry/versus-card.json +4 -2
- package/registry/vertical-video.json +4 -2
- package/registry/video-player.json +4 -2
- package/registry/video-trimmer.json +4 -2
- package/registry/virtual.json +4 -2
- package/registry/wall.json +4 -2
- package/registry/waveform.json +4 -2
- package/dist/chunk-A7MQPIEG.js +0 -31
- package/dist/chunk-A7MQPIEG.js.map +0 -1
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
"status": "beta",
|
|
8
8
|
"deprecated": null,
|
|
9
9
|
"category": "layouts",
|
|
10
|
+
"domain": "navigation-shell",
|
|
11
|
+
"adoption": null,
|
|
10
12
|
"platforms": "both",
|
|
11
13
|
"parity": {
|
|
12
14
|
"web": {
|
|
@@ -348,7 +350,7 @@
|
|
|
348
350
|
"files": [
|
|
349
351
|
{
|
|
350
352
|
"path": "meta.ts",
|
|
351
|
-
"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 | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\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 | \"proposal\"\n | \"qr-code\"\n | \"entity-header\"\n | \"collection-switcher\"\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 | \"shop-gallery\"\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 | \"schema-form\"\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"
|
|
353
|
+
"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 | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\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 | \"proposal\"\n | \"qr-code\"\n | \"entity-header\"\n | \"collection-switcher\"\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 | \"shop-gallery\"\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 | \"schema-form\"\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 * `experimental`: created for a filed need (ADR-008 §4), it may change or go in any minor until its first consumer imports it; `adoption`\n * names that consumer's issue. `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 = \"experimental\" | \"stable\" | \"beta\" | \"deprecated\";\n\n/**\n * What a component is for (ADR-008 §3): the twelve domains the documentation, the size budgets and the guards are\n * organised by. The domain is metadata: the entries stay flat (`@krizaka/ui/<name>`). `cahier` is the sites' register\n * (ADR-004): a product never imports it.\n */\nexport type Domain =\n | \"foundations\"\n | \"forms\"\n | \"data-display\"\n | \"navigation-shell\"\n | \"feedback\"\n | \"maps\"\n | \"media\"\n | \"commerce\"\n | \"identity\"\n | \"conversation\"\n | \"page-blocks\"\n | \"cahier\";\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 /** What it is for: one of the twelve domains (ADR-008 §3). */\n readonly domain: Domain;\n /** The `<repo>#<n>` issue of its first consumer: required for, and only for, an `experimental` component. */\n readonly adoption?: string;\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"
|
|
352
354
|
},
|
|
353
355
|
{
|
|
354
356
|
"path": "settings-layout/index.ts",
|
|
@@ -356,7 +358,7 @@
|
|
|
356
358
|
},
|
|
357
359
|
{
|
|
358
360
|
"path": "settings-layout/meta.ts",
|
|
359
|
-
"content": "import type { ComponentMeta } from \"../meta\";\n\nexport const meta = {\n title: \"Settings layout\",\n summary: \"Settings: the sections on the side, alone or in titled groups (a row of chips on a phone, one menu past five), an optional identity header and the current section's forms, as titled cards with their own save or, flat, as hairline-divided rows (`SettingsRow`).\",\n status: \"beta\",\n category: \"layouts\",\n platforms: \"both\",\n parity: { desktop: \"web\" },\n whenToUse: [\"Account, workspace and administration settings.\", \"Any long form that splits into independent groups.\"],\n whenNotToUse: [\n { when: \"For a step-by-step setup the user follows once.\", use: \"stepper\" },\n { when: \"For one small form.\", use: \"field\" },\n ],\n bestPractices: [\"Past five sections, group them (`nav` as `SettingsNavGroup[]`): the sidebar shows the group titles and a phone gets one menu, never a scrolling strip of chips.\", \"Prefer `variant=\\\"flat\\\"` and `SettingsRow` for a product's settings: a label and its help on the left, the control on the right, no card.\", \"Keep support-only facts (an account id) in a last `Advanced` section, small and mono, never in the first screen.\", \"One save per section, at its foot: a change never waits for another.\", \"Sections as pages (`/settings/billing`) or as anchors of one long page (`#billing`).\", \"Say in the description what the section changes for the user.\"],\n accessibility: {\n keyboard: [],\n notes: [\"The sections are a `nav` named by `navLabel`; the current one has `aria-current` (page or location).\", \"Each section is a `section` named by its `h2`.\"],\n },\n related: [\"field\", \"switch\", \"app-shell\"],\n native: {\n imports: [\"SettingsGroup\", \"SettingsRow\"],\n differences: [\n \"Only the rows: `SettingsGroup` (a titled card of hairline-divided rows) and `SettingsRow` (icon tile, label, help, value or control, a chevron when `onPress` opens something). The sections-on-the-side layout is a web idea; on a phone each section is a screen.\",\n \"A row with `onPress` is a button named by its visible words; a row with a `trailing` control (a `Switch`) leaves the control as the thing to press.\",\n ],\n examples: [{ name: \"account\", title: \"Account settings\", description: \"A group of rows: a value, a link that opens a screen, a switch, a destructive action.\", template: true, purpose: \"operate\", why: \"A person reviews their account and changes one thing, with the dangerous action set apart at the end.\" }],\n },\n web: {\n imports: [\"SettingsLayout\", \"SettingsSection\", \"SettingsRow\"],\n examples: [\n { name: \"account\", title: \"Account settings\", description: \"Profile and notifications, each with its own save; the sections as chips on a phone.\", template: true, purpose: \"operate\", why: \"A person changes one setting at a time, saves it at once and knows where each lives.\" },\n { name: \"flat\", title: \"Calm settings\", description: \"The flat variant: one column of at most 45rem, each setting a row (label and help left, control right) divided by hairlines.\", template: true, purpose: \"operate\", why: \"A person scans the settings, finds the one to change and changes it in place, without cards competing for attention.\" },\n { name: \"grouped\", title: \"A private space\", description: \"Who you are on top, eight sections in three groups with counts; one menu on a phone.\", template: true, purpose: \"operate\", why: \"A person with many places to go finds each under its group, and never meets a strip of chips that hides half of them.\" },\n { name: \"sections\", title: \"One section per page\", description: \"A workspace's settings, the current section marked.\" },\n ],\n },\n} satisfies ComponentMeta;\n"
|
|
361
|
+
"content": "import type { ComponentMeta } from \"../meta\";\n\nexport const meta = {\n title: \"Settings layout\",\n summary: \"Settings: the sections on the side, alone or in titled groups (a row of chips on a phone, one menu past five), an optional identity header and the current section's forms, as titled cards with their own save or, flat, as hairline-divided rows (`SettingsRow`).\",\n status: \"beta\",\n category: \"layouts\",\n domain: \"navigation-shell\",\n platforms: \"both\",\n parity: { desktop: \"web\" },\n whenToUse: [\"Account, workspace and administration settings.\", \"Any long form that splits into independent groups.\"],\n whenNotToUse: [\n { when: \"For a step-by-step setup the user follows once.\", use: \"stepper\" },\n { when: \"For one small form.\", use: \"field\" },\n ],\n bestPractices: [\"Past five sections, group them (`nav` as `SettingsNavGroup[]`): the sidebar shows the group titles and a phone gets one menu, never a scrolling strip of chips.\", \"Prefer `variant=\\\"flat\\\"` and `SettingsRow` for a product's settings: a label and its help on the left, the control on the right, no card.\", \"Keep support-only facts (an account id) in a last `Advanced` section, small and mono, never in the first screen.\", \"One save per section, at its foot: a change never waits for another.\", \"Sections as pages (`/settings/billing`) or as anchors of one long page (`#billing`).\", \"Say in the description what the section changes for the user.\"],\n accessibility: {\n keyboard: [],\n notes: [\"The sections are a `nav` named by `navLabel`; the current one has `aria-current` (page or location).\", \"Each section is a `section` named by its `h2`.\"],\n },\n related: [\"field\", \"switch\", \"app-shell\"],\n native: {\n imports: [\"SettingsGroup\", \"SettingsRow\"],\n differences: [\n \"Only the rows: `SettingsGroup` (a titled card of hairline-divided rows) and `SettingsRow` (icon tile, label, help, value or control, a chevron when `onPress` opens something). The sections-on-the-side layout is a web idea; on a phone each section is a screen.\",\n \"A row with `onPress` is a button named by its visible words; a row with a `trailing` control (a `Switch`) leaves the control as the thing to press.\",\n ],\n examples: [{ name: \"account\", title: \"Account settings\", description: \"A group of rows: a value, a link that opens a screen, a switch, a destructive action.\", template: true, purpose: \"operate\", why: \"A person reviews their account and changes one thing, with the dangerous action set apart at the end.\" }],\n },\n web: {\n imports: [\"SettingsLayout\", \"SettingsSection\", \"SettingsRow\"],\n examples: [\n { name: \"account\", title: \"Account settings\", description: \"Profile and notifications, each with its own save; the sections as chips on a phone.\", template: true, purpose: \"operate\", why: \"A person changes one setting at a time, saves it at once and knows where each lives.\" },\n { name: \"flat\", title: \"Calm settings\", description: \"The flat variant: one column of at most 45rem, each setting a row (label and help left, control right) divided by hairlines.\", template: true, purpose: \"operate\", why: \"A person scans the settings, finds the one to change and changes it in place, without cards competing for attention.\" },\n { name: \"grouped\", title: \"A private space\", description: \"Who you are on top, eight sections in three groups with counts; one menu on a phone.\", template: true, purpose: \"operate\", why: \"A person with many places to go finds each under its group, and never meets a strip of chips that hides half of them.\" },\n { name: \"sections\", title: \"One section per page\", description: \"A workspace's settings, the current section marked.\" },\n ],\n },\n} satisfies ComponentMeta;\n"
|
|
360
362
|
},
|
|
361
363
|
{
|
|
362
364
|
"path": "settings-layout/save-status.ts",
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
"status": "beta",
|
|
8
8
|
"deprecated": null,
|
|
9
9
|
"category": "blocks",
|
|
10
|
+
"domain": "commerce",
|
|
11
|
+
"adoption": null,
|
|
10
12
|
"platforms": "web",
|
|
11
13
|
"parity": {
|
|
12
14
|
"web": {
|
|
@@ -131,7 +133,7 @@
|
|
|
131
133
|
{
|
|
132
134
|
"name": "messages",
|
|
133
135
|
"type": "ShopComposerMessages",
|
|
134
|
-
"default": "{\n title: \"Shop page\",\n sections: \"Sections\",\n addSection: \"Add a section\",\n addSectionHint: \"Choose what to add to your page.\",\n toggleVisible: \"Show {name}\",\n sectionMenu: \"Actions for {name}\",\n moveUp: \"Move up\",\n moveDown: \"Move down\",\n moveTop: \"Move to top\",\n remove: \"Remove\",\n announceMoved: \"{name} moved to position {n} of {total}\",\n announceCannotMove: \"{name} cannot move further\",\n announceAdded: \"{name} added at position {n}\",\n announceRemoved: \"{name} removed\",\n announceShown: \"{name} is shown\",\n announceHidden: \"{name} is hidden\",\n announceUndone: \"Undone\",\n announceRedone: \"Redone\",\n hiddenNote: \"hidden\",\n inspector: \"Section\",\n noSelection: \"Choose a section to change how it is drawn.\",\n backToSections: \"Back to sections\",\n variant: \"How it is drawn\",\n settings: \"Settings\",\n words: \"Your words\",\n titleField: \"Title\",\n leadField: \"Line under the title\",\n french: \"French\",\n english: \"English\",\n blocks: \"Items\",\n addBlock: \"Add\",\n removeBlock: \"Remove {name}\",\n look: \"Look\",\n preset: \"Style\",\n density: \"Spacing\",\n densityCompact: \"Compact\",\n densityAiry: \"Airy\",\n undo: \"Undo\",\n redo: \"Redo\",\n saved: \"Saved\",\n saving: \"Saving…\",\n saveFailed: \"Not saved\",\n publish: \"Publish\",\n discard: \"Discard the draft\",\n preview: \"Preview\",\n previewTitle: \"Live preview of your page\",\n phone: \"Phone\",\n desktop: \"Desktop\",\n viewPreview: \"View\",\n closePreview: \"Close\",\n publishTitle: \"Publish this page\",\n publishWhat: \"What changes\",\n publishNothing: \"Nothing has changed since the last publication.\",\n publishConfirm: \"Publish\",\n cancel: \"Cancel\",\n problemsTitle: \"Fix {n} problem before publishing\",\n problemIn: \"{name}\",\n sectionNames,\n variantNames,\n blockNames: { fact: \"Fact\", service: \"Service\", photo: \"Photo\", note: \"Note\", sign: \"Sign\", reel: \"Reel\", flyer: \"Flyer\", member: \"Member\", link: \"Link\", question: \"Question\" },\n settingNames: { media: \"Photo\", focus: \"Crop\", source: \"Source\", groupBy: \"Group by\", columns: \"Columns\", aside: \"Beside the list\", serviceId: \"Service\", count: \"How many\", texture: \"Wall\", cabinet: \"Cabinet\", channel: \"Channel\", rule: \"Which reviews\", showPhone: \"Show the phone number\", body: \"Text\", show: \"Show\" },\n optionNames: { center: \"Centre\", top: \"Top\", bottom: \"Bottom\", all: \"All\", pick: \"Pick\", category: \"Category\", none: \"None\", hours: \"Hours\", plaster: \"Plaster\", brick: \"Brick\", ridge: \"Ridge\", zellige: \"Zellige\", cabinet: \"Cabinet\", portable: \"Portable\", best: \"Best\", latest: \"Latest\", cancellation: \"Cancellation\", prices: \"Prices\", \"booking-window\": \"Booking window\" },\n diff: {\n added: \"{name} added\",\n removed: \"{name} removed\",\n moved: \"{name} moved from {from} to {to}\",\n variant: \"{name} drawn as {to} (was {from})\",\n settings: \"{name}: settings changed\",\n blocks: \"{name}: items changed\",\n text: \"{name}: words changed\",\n disabled: \"{name} hidden\",\n enabled: \"{name} shown\",\n preset: \"Style changed to {to} (was {from})\",\n density: \"Spacing changed to {to} (was {from})\",\n },\n}",
|
|
136
|
+
"default": "{\n title: \"Shop page\",\n sections: \"Sections\",\n addSection: \"Add a section\",\n addSectionHint: \"Choose what to add to your page.\",\n toggleVisible: \"Show {name}\",\n sectionMenu: \"Actions for {name}\",\n moveUp: \"Move up\",\n moveDown: \"Move down\",\n moveTop: \"Move to top\",\n remove: \"Remove\",\n announceMoved: \"{name} moved to position {n} of {total}\",\n announceCannotMove: \"{name} cannot move further\",\n announceAdded: \"{name} added at position {n}\",\n announceRemoved: \"{name} removed\",\n announceShown: \"{name} is shown\",\n announceHidden: \"{name} is hidden\",\n announceUndone: \"Undone\",\n announceRedone: \"Redone\",\n hiddenNote: \"hidden\",\n inspector: \"Section\",\n noSelection: \"Choose a section to change how it is drawn.\",\n backToSections: \"Back to sections\",\n variant: \"How it is drawn\",\n settings: \"Settings\",\n words: \"Your words\",\n titleField: \"Title\",\n leadField: \"Line under the title\",\n french: \"French\",\n english: \"English\",\n blocks: \"Items\",\n addBlock: \"Add\",\n removeBlock: \"Remove {name}\",\n look: \"Look\",\n lookChoice: \"Look of the page\",\n lookApplied: \"Look: {name}\",\n accentChoice: \"Accent\",\n accentNames: { krizaka: \"Krizaka blue\", akinaza: \"Akinaza green\", \"akinaza:accent-2\": \"Copper\", yomizaka: \"Indigo\", orazaka: \"Orange\" },\n preset: \"Style\",\n density: \"Spacing\",\n densityCompact: \"Compact\",\n densityAiry: \"Airy\",\n undo: \"Undo\",\n redo: \"Redo\",\n saved: \"Saved\",\n saving: \"Saving…\",\n saveFailed: \"Not saved\",\n publish: \"Publish\",\n discard: \"Discard the draft\",\n preview: \"Preview\",\n previewTitle: \"Live preview of your page\",\n phone: \"Phone\",\n desktop: \"Desktop\",\n viewPreview: \"View\",\n closePreview: \"Close\",\n publishTitle: \"Publish this page\",\n publishWhat: \"What changes\",\n publishNothing: \"Nothing has changed since the last publication.\",\n publishConfirm: \"Publish\",\n cancel: \"Cancel\",\n problemsTitle: \"Fix {n} problem before publishing\",\n problemIn: \"{name}\",\n sectionNames,\n variantNames,\n blockNames: { fact: \"Fact\", service: \"Service\", photo: \"Photo\", note: \"Note\", sign: \"Sign\", reel: \"Reel\", flyer: \"Flyer\", member: \"Member\", link: \"Link\", question: \"Question\" },\n settingNames: { media: \"Photo\", focus: \"Crop\", source: \"Source\", groupBy: \"Group by\", columns: \"Columns\", aside: \"Beside the list\", serviceId: \"Service\", count: \"How many\", texture: \"Wall\", cabinet: \"Cabinet\", channel: \"Channel\", rule: \"Which reviews\", showPhone: \"Show the phone number\", body: \"Text\", show: \"Show\" },\n optionNames: { center: \"Centre\", top: \"Top\", bottom: \"Bottom\", all: \"All\", pick: \"Pick\", category: \"Category\", none: \"None\", hours: \"Hours\", plaster: \"Plaster\", brick: \"Brick\", ridge: \"Ridge\", zellige: \"Zellige\", cabinet: \"Cabinet\", portable: \"Portable\", best: \"Best\", latest: \"Latest\", cancellation: \"Cancellation\", prices: \"Prices\", \"booking-window\": \"Booking window\" },\n diff: {\n added: \"{name} added\",\n removed: \"{name} removed\",\n moved: \"{name} moved from {from} to {to}\",\n variant: \"{name} drawn as {to} (was {from})\",\n settings: \"{name}: settings changed\",\n blocks: \"{name}: items changed\",\n text: \"{name}: words changed\",\n disabled: \"{name} hidden\",\n enabled: \"{name} shown\",\n preset: \"Style changed to {to} (was {from})\",\n density: \"Spacing changed to {to} (was {from})\",\n },\n}",
|
|
135
137
|
"description": "The words, translated. Default: English.",
|
|
136
138
|
"required": false
|
|
137
139
|
},
|
|
@@ -220,15 +222,15 @@
|
|
|
220
222
|
"files": [
|
|
221
223
|
{
|
|
222
224
|
"path": "meta.ts",
|
|
223
|
-
"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 | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\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 | \"proposal\"\n | \"qr-code\"\n | \"entity-header\"\n | \"collection-switcher\"\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 | \"shop-gallery\"\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 | \"schema-form\"\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"
|
|
225
|
+
"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 | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\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 | \"proposal\"\n | \"qr-code\"\n | \"entity-header\"\n | \"collection-switcher\"\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 | \"shop-gallery\"\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 | \"schema-form\"\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 * `experimental`: created for a filed need (ADR-008 §4), it may change or go in any minor until its first consumer imports it; `adoption`\n * names that consumer's issue. `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 = \"experimental\" | \"stable\" | \"beta\" | \"deprecated\";\n\n/**\n * What a component is for (ADR-008 §3): the twelve domains the documentation, the size budgets and the guards are\n * organised by. The domain is metadata: the entries stay flat (`@krizaka/ui/<name>`). `cahier` is the sites' register\n * (ADR-004): a product never imports it.\n */\nexport type Domain =\n | \"foundations\"\n | \"forms\"\n | \"data-display\"\n | \"navigation-shell\"\n | \"feedback\"\n | \"maps\"\n | \"media\"\n | \"commerce\"\n | \"identity\"\n | \"conversation\"\n | \"page-blocks\"\n | \"cahier\";\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 /** What it is for: one of the twelve domains (ADR-008 §3). */\n readonly domain: Domain;\n /** The `<repo>#<n>` issue of its first consumer: required for, and only for, an `experimental` component. */\n readonly adoption?: string;\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"
|
|
224
226
|
},
|
|
225
227
|
{
|
|
226
228
|
"path": "shop-composer/commands.ts",
|
|
227
|
-
"content": "// The composer's commands (ADR-007 §5): every change of the document is a pure command on a reducer — never a mutation —\n// so undo / redo restore the exact document, and the rules of the document (a hero first, 16 sections, 24 blocks, the variants\n// of a type) hold after every step. A command that would break a rule is a no-op: the page stays valid, always.\nimport { SECTION_DEFINITIONS, sectionDefinition,type SectionType } from \"../shop/catalogue\";\nimport { SHOP_LIMITS } from \"../shop/limits\";\nimport type { Section, ShopPage } from \"../shop/schema\";\nimport type { LocalizedText } from \"../shop/text\";\n\ntype Rec = Record<string, unknown>;\n\nexport type Command =\n /** Adds a section (its type's default settings, the given or the default variant) at an index; a hero goes first. */\n | { type: \"addSection\"; sectionType: SectionType; key: string; variant?: string; at?: number; settings?: Rec }\n | { type: \"removeSection\"; key: string }\n /** Moves a section to an absolute index (the hero stays first: nothing goes above it). */\n | { type: \"moveSection\"; key: string; to: number }\n | { type: \"setVariant\"; key: string; variant: string }\n /** Merges into the settings. */\n | { type: \"patchSettings\"; key: string; patch: Rec }\n | { type: \"setText\"; key: string; field: \"title\" | \"lead\"; value: LocalizedText | undefined }\n | { type: \"toggleDisabled\"; key: string }\n | { type: \"setPreset\"; preset: { id: string; version: number }; density?: \"compact\" | \"airy\" | null }\n | { type: \"setDensity\"; density: \"compact\" | \"airy\" | undefined }\n | { type: \"addBlock\"; key: string; blockKey: string; blockType: string; settings?: Rec; at?: number }\n | { type: \"removeBlock\"; key: string; blockKey: string }\n | { type: \"moveBlock\"; key: string; blockKey: string; to: number }\n | { type: \"patchBlock\"; key: string; blockKey: string; patch: Rec };\n\nconst clamp = (n: number, lo: number, hi: number) => Math.min(Math.max(n, lo), hi);\nconst indexOfKey = (page: ShopPage, key: string) => page.sections.findIndex((s) => s.key === key);\n\n/** The array with an item moved to an index. */\nexport function moved<T>(list: readonly T[], from: number, to: number): T[] {\n const next = [...list];\n const [item] = next.splice(from, 1);\n next.splice(clamp(to, 0, next.length), 0, item as T);\n return next;\n}\n\nfunction withSection(page: ShopPage, key: string, change: (s: Section) => Section): ShopPage {\n const i = indexOfKey(page, key);\n if (i < 0) return page;\n const next = change(page.sections[i]!);\n if (next === page.sections[i]) return page;\n const sections = [...page.sections];\n sections[i] = next;\n return { ...page, sections };\n}\n\ntype Handler<T extends Command[\"type\"]> = (page: ShopPage, cmd: Extract<Command, { type: T }>) => ShopPage;\n\nconst addSection: Handler<\"addSection\"> = (page, cmd) => {\n const def = SECTION_DEFINITIONS.find((d) => d.type === cmd.sectionType);\n if (!def || page.sections.length >= SHOP_LIMITS.sections || page.sections.some((s) => s.key === cmd.key)) return page;\n const variant = cmd.variant ?? def.defaultVariant;\n if (!(def.variants as readonly string[]).includes(variant)) return page;\n const isHero = def.type === \"hero\";\n if (isHero && page.sections.some((s) => s.type === \"hero\")) return page;\n const heroFirst = page.sections[0]?.type === \"hero\";\n const at = isHero ? 0 : clamp(cmd.at ?? page.sections.length, heroFirst ? 1 : 0, page.sections.length);\n const section = { key: cmd.key, type: def.type, variant, settings: { ...(def.settingsDefault as Rec), ...cmd.settings } } as unknown as Section;\n const sections = [...page.sections];\n sections.splice(at, 0, section);\n return { ...page, sections };\n};\n\nconst removeSection: Handler<\"removeSection\"> = (page, cmd) => {\n if (indexOfKey(page, cmd.key) < 0 || page.sections.length <= 1) return page;\n return { ...page, sections: page.sections.filter((s) => s.key !== cmd.key) };\n};\n\nconst moveSection: Handler<\"moveSection\"> = (page, cmd) => {\n const from = indexOfKey(page, cmd.key);\n if (from < 0 || page.sections[from]!.type === \"hero\") return page;\n const lo = page.sections[0]?.type === \"hero\" ? 1 : 0;\n const to = clamp(cmd.to, lo, page.sections.length - 1);\n return to === from ? page : { ...page, sections: moved(page.sections, from, to) };\n};\n\nconst setVariant: Handler<\"setVariant\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const def = sectionDefinition(s.type);\n if (s.variant === cmd.variant || !(def.variants as readonly string[]).includes(cmd.variant)) return s;\n return { ...s, variant: cmd.variant } as Section;\n });\n\n/** Whether every value of a patch is already the one the object holds. */\nconst saysNothingNew = (current: Rec, patch: Rec) => Object.entries(patch).every(([k, v]) => JSON.stringify(current[k]) === JSON.stringify(v));\n\nconst patchSettings: Handler<\"patchSettings\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const current = s.settings as Rec;\n // Nothing to say when every value is already the document's (a form that reports its first values after an undo).\n return saysNothingNew(current, cmd.patch) ? s : ({ ...s, settings: { ...current, ...cmd.patch } } as Section);\n });\n\nconst setText: Handler<\"setText\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const text = { ...(s.text ?? {}) } as Rec;\n if (cmd.value === undefined) delete text[cmd.field];\n else text[cmd.field] = cmd.value;\n const next = { ...s } as Rec;\n if (Object.keys(text).length === 0) delete next.text;\n else next.text = text;\n return next as unknown as Section;\n });\n\nconst toggleDisabled: Handler<\"toggleDisabled\"> = (page, cmd) => withSection(page, cmd.key, (s) => ({ ...s, disabled: s.disabled ? undefined : true }) as Section);\n\nconst setPreset: Handler<\"setPreset\"> = (page, cmd) => {\n if (page.preset.id === cmd.preset.id && page.preset.version === cmd.preset.version && cmd.density === undefined) return page;\n let density: Partial<Pick<ShopPage, \"density\">> = {};\n if (cmd.density === null) density = { density: undefined };\n else if (cmd.density) density = { density: cmd.density };\n return { ...page, preset: { ...cmd.preset }, ...density };\n};\n\nconst setDensity: Handler<\"setDensity\"> = (page, cmd) => (page.density === cmd.density ? page : { ...page, density: cmd.density });\n\ntype Keyed = { key: string; type?: string; settings?: Rec };\n\nconst addBlock: Handler<\"addBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const def = sectionDefinition(s.type);\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n if (!(def.blockTypes as readonly string[]).includes(cmd.blockType) || blocks.length >= SHOP_LIMITS.blocks || blocks.some((b) => b.key === cmd.blockKey)) return s;\n const next = [...blocks];\n next.splice(clamp(cmd.at ?? blocks.length, 0, blocks.length), 0, { key: cmd.blockKey, type: cmd.blockType, settings: { ...cmd.settings } });\n return { ...s, blocks: next } as unknown as Section;\n });\n\nconst removeBlock: Handler<\"removeBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n if (!blocks.some((b) => b.key === cmd.blockKey)) return s;\n const next = blocks.filter((b) => b.key !== cmd.blockKey);\n return { ...s, blocks: next.length > 0 ? next : undefined } as unknown as Section;\n });\n\nconst moveBlock: Handler<\"moveBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n const from = blocks.findIndex((b) => b.key === cmd.blockKey);\n const to = clamp(cmd.to, 0, blocks.length - 1);\n return from < 0 || from === to ? s : ({ ...s, blocks: moved(blocks, from, to) } as unknown as Section);\n });\n\nconst patchBlock: Handler<\"patchBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n const block = blocks.find((b) => b.key === cmd.blockKey);\n if (!block || saysNothingNew(block.settings ?? {}, cmd.patch)) return s;\n return { ...s, blocks: blocks.map((b) => (b === block ? { ...b, settings: { ...b.settings, ...cmd.patch } } : b)) } as unknown as Section;\n });\n\nconst handlers: { [T in Command[\"type\"]]: Handler<T> } = {\n addSection, removeSection, moveSection, setVariant, patchSettings, setText, toggleDisabled, setPreset, setDensity, addBlock, removeBlock, moveBlock, patchBlock,\n};\n\n/** Applies a command to a document; returns the same object when nothing changes. */\nexport function applyCommand(page: ShopPage, cmd: Command): ShopPage {\n return (handlers[cmd.type] as (page: ShopPage, cmd: Command) => ShopPage)(page, cmd);\n}\n"
|
|
229
|
+
"content": "// The composer's commands (ADR-007 §5): every change of the document is a pure command on a reducer — never a mutation —\n// so undo / redo restore the exact document, and the rules of the document (a hero first, 16 sections, 24 blocks, the variants\n// of a type) hold after every step. A command that would break a rule is a no-op: the page stays valid, always.\nimport { SECTION_DEFINITIONS, sectionDefinition,type SectionType } from \"../shop/catalogue\";\nimport { SHOP_LIMITS } from \"../shop/limits\";\nimport { applyLook, type ShopLookLike } from \"../shop/look/apply-look\";\nimport type { Section, ShopPage } from \"../shop/schema\";\nimport type { LocalizedText } from \"../shop/text\";\n\ntype Rec = Record<string, unknown>;\n\nexport type Command =\n /** Adds a section (its type's default settings, the given or the default variant) at an index; a hero goes first. */\n | { type: \"addSection\"; sectionType: SectionType; key: string; variant?: string; at?: number; settings?: Rec }\n | { type: \"removeSection\"; key: string }\n /** Moves a section to an absolute index (the hero stays first: nothing goes above it). */\n | { type: \"moveSection\"; key: string; to: number }\n | { type: \"setVariant\"; key: string; variant: string }\n /** Merges into the settings. */\n | { type: \"patchSettings\"; key: string; patch: Rec }\n | { type: \"setText\"; key: string; field: \"title\" | \"lead\"; value: LocalizedText | undefined }\n | { type: \"toggleDisabled\"; key: string }\n | { type: \"setPreset\"; preset: { id: string; version: number }; density?: \"compact\" | \"airy\" | null }\n | { type: \"setDensity\"; density: \"compact\" | \"airy\" | undefined }\n /** A whole look (`look-*`): the variants of the sections, nothing of their content (`applyLook`). */\n | { type: \"applyLook\"; look: ShopLookLike }\n /** The accent within the look's tested list. */\n | { type: \"setAccent\"; accent: string | undefined }\n | { type: \"addBlock\"; key: string; blockKey: string; blockType: string; settings?: Rec; at?: number }\n | { type: \"removeBlock\"; key: string; blockKey: string }\n | { type: \"moveBlock\"; key: string; blockKey: string; to: number }\n | { type: \"patchBlock\"; key: string; blockKey: string; patch: Rec };\n\nconst clamp = (n: number, lo: number, hi: number) => Math.min(Math.max(n, lo), hi);\nconst indexOfKey = (page: ShopPage, key: string) => page.sections.findIndex((s) => s.key === key);\n\n/** The array with an item moved to an index. */\nexport function moved<T>(list: readonly T[], from: number, to: number): T[] {\n const next = [...list];\n const [item] = next.splice(from, 1);\n next.splice(clamp(to, 0, next.length), 0, item as T);\n return next;\n}\n\nfunction withSection(page: ShopPage, key: string, change: (s: Section) => Section): ShopPage {\n const i = indexOfKey(page, key);\n if (i < 0) return page;\n const next = change(page.sections[i]!);\n if (next === page.sections[i]) return page;\n const sections = [...page.sections];\n sections[i] = next;\n return { ...page, sections };\n}\n\ntype Handler<T extends Command[\"type\"]> = (page: ShopPage, cmd: Extract<Command, { type: T }>) => ShopPage;\n\nconst addSection: Handler<\"addSection\"> = (page, cmd) => {\n const def = SECTION_DEFINITIONS.find((d) => d.type === cmd.sectionType);\n if (!def || page.sections.length >= SHOP_LIMITS.sections || page.sections.some((s) => s.key === cmd.key)) return page;\n const variant = cmd.variant ?? def.defaultVariant;\n if (!(def.variants as readonly string[]).includes(variant)) return page;\n const isHero = def.type === \"hero\";\n if (isHero && page.sections.some((s) => s.type === \"hero\")) return page;\n const heroFirst = page.sections[0]?.type === \"hero\";\n const at = isHero ? 0 : clamp(cmd.at ?? page.sections.length, heroFirst ? 1 : 0, page.sections.length);\n const section = { key: cmd.key, type: def.type, variant, settings: { ...(def.settingsDefault as Rec), ...cmd.settings } } as unknown as Section;\n const sections = [...page.sections];\n sections.splice(at, 0, section);\n return { ...page, sections };\n};\n\nconst removeSection: Handler<\"removeSection\"> = (page, cmd) => {\n if (indexOfKey(page, cmd.key) < 0 || page.sections.length <= 1) return page;\n return { ...page, sections: page.sections.filter((s) => s.key !== cmd.key) };\n};\n\nconst moveSection: Handler<\"moveSection\"> = (page, cmd) => {\n const from = indexOfKey(page, cmd.key);\n if (from < 0 || page.sections[from]!.type === \"hero\") return page;\n const lo = page.sections[0]?.type === \"hero\" ? 1 : 0;\n const to = clamp(cmd.to, lo, page.sections.length - 1);\n return to === from ? page : { ...page, sections: moved(page.sections, from, to) };\n};\n\nconst setVariant: Handler<\"setVariant\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const def = sectionDefinition(s.type);\n if (s.variant === cmd.variant || !(def.variants as readonly string[]).includes(cmd.variant)) return s;\n return { ...s, variant: cmd.variant } as Section;\n });\n\n/** Whether every value of a patch is already the one the object holds. */\nconst saysNothingNew = (current: Rec, patch: Rec) => Object.entries(patch).every(([k, v]) => JSON.stringify(current[k]) === JSON.stringify(v));\n\nconst patchSettings: Handler<\"patchSettings\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const current = s.settings as Rec;\n // Nothing to say when every value is already the document's (a form that reports its first values after an undo).\n return saysNothingNew(current, cmd.patch) ? s : ({ ...s, settings: { ...current, ...cmd.patch } } as Section);\n });\n\nconst setText: Handler<\"setText\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const text = { ...(s.text ?? {}) } as Rec;\n if (cmd.value === undefined) delete text[cmd.field];\n else text[cmd.field] = cmd.value;\n const next = { ...s } as Rec;\n if (Object.keys(text).length === 0) delete next.text;\n else next.text = text;\n return next as unknown as Section;\n });\n\nconst toggleDisabled: Handler<\"toggleDisabled\"> = (page, cmd) => withSection(page, cmd.key, (s) => ({ ...s, disabled: s.disabled ? undefined : true }) as Section);\n\nconst setPreset: Handler<\"setPreset\"> = (page, cmd) => {\n if (page.preset.id === cmd.preset.id && page.preset.version === cmd.preset.version && cmd.density === undefined) return page;\n let density: Partial<Pick<ShopPage, \"density\">> = {};\n if (cmd.density === null) density = { density: undefined };\n else if (cmd.density) density = { density: cmd.density };\n return { ...page, preset: { ...cmd.preset }, ...density };\n};\n\nconst setDensity: Handler<\"setDensity\"> = (page, cmd) => (page.density === cmd.density ? page : { ...page, density: cmd.density });\n\nconst applyLookCmd: Handler<\"applyLook\"> = (page, cmd) => applyLook(page, cmd.look);\n\nconst setAccent: Handler<\"setAccent\"> = (page, cmd) => (page.accent === cmd.accent ? page : { ...page, accent: cmd.accent });\n\ntype Keyed = { key: string; type?: string; settings?: Rec };\n\nconst addBlock: Handler<\"addBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const def = sectionDefinition(s.type);\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n if (!(def.blockTypes as readonly string[]).includes(cmd.blockType) || blocks.length >= SHOP_LIMITS.blocks || blocks.some((b) => b.key === cmd.blockKey)) return s;\n const next = [...blocks];\n next.splice(clamp(cmd.at ?? blocks.length, 0, blocks.length), 0, { key: cmd.blockKey, type: cmd.blockType, settings: { ...cmd.settings } });\n return { ...s, blocks: next } as unknown as Section;\n });\n\nconst removeBlock: Handler<\"removeBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n if (!blocks.some((b) => b.key === cmd.blockKey)) return s;\n const next = blocks.filter((b) => b.key !== cmd.blockKey);\n return { ...s, blocks: next.length > 0 ? next : undefined } as unknown as Section;\n });\n\nconst moveBlock: Handler<\"moveBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n const from = blocks.findIndex((b) => b.key === cmd.blockKey);\n const to = clamp(cmd.to, 0, blocks.length - 1);\n return from < 0 || from === to ? s : ({ ...s, blocks: moved(blocks, from, to) } as unknown as Section);\n });\n\nconst patchBlock: Handler<\"patchBlock\"> = (page, cmd) =>\n withSection(page, cmd.key, (s) => {\n const blocks = (s.blocks ?? []) as readonly Keyed[];\n const block = blocks.find((b) => b.key === cmd.blockKey);\n if (!block || saysNothingNew(block.settings ?? {}, cmd.patch)) return s;\n return { ...s, blocks: blocks.map((b) => (b === block ? { ...b, settings: { ...b.settings, ...cmd.patch } } : b)) } as unknown as Section;\n });\n\nconst handlers: { [T in Command[\"type\"]]: Handler<T> } = {\n addSection, removeSection, moveSection, setVariant, patchSettings, setText, toggleDisabled, setPreset, setDensity, applyLook: applyLookCmd, setAccent, addBlock, removeBlock, moveBlock, patchBlock,\n};\n\n/** Applies a command to a document; returns the same object when nothing changes. */\nexport function applyCommand(page: ShopPage, cmd: Command): ShopPage {\n return (handlers[cmd.type] as (page: ShopPage, cmd: Command) => ShopPage)(page, cmd);\n}\n"
|
|
228
230
|
},
|
|
229
231
|
{
|
|
230
232
|
"path": "shop-composer/composer.tsx",
|
|
231
|
-
"content": "\"use client\";\n\n// Our own shop composer (ADR-007 §5): three panes on a laptop — the outline of the sections, the live preview of the product's own\n// public page, the inspector of the selected section — and two steps on a phone (the list, then the section; the preview behind a\n// « View » button). Every change is a command on a reducer (⌘Z / ⇧⌘Z, 100 steps), saved to the draft after 800 ms of calm; « Publish »\n// shows what changes and refuses while a setting is invalid. Every action has a keyboard path. No third-party editor: Puck was weighed\n// and not adopted (the model is a list, not a canvas).\nimport { Button } from \"@krizaka/ui/button\";\nimport { Dialog } from \"@krizaka/ui/dialog\";\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { SECTION_DEFINITIONS, type SectionType } from \"../shop/catalogue\";\nimport { postToPreview } from \"../shop/preview\";\nimport { parseShopPage, type ShopPage } from \"../shop/schema\";\nimport { type Command } from \"./commands\";\nimport { type DiffEntry, diffPages } from \"./diff\";\nimport { canRedo, canUndo, createHistory, type History, redo, run, undo } from \"./history\";\nimport { Inspector } from \"./inspector\";\nimport { newKey } from \"./keys\";\nimport { defaultShopComposerMessages, fill, type ShopComposerMessages } from \"./messages\";\nimport { Outline, sectionLabel } from \"./outline\";\n\n/** How long the draft waits for calm before it is saved. */\n// @fixed: ADR-007 §5 — the autosave debounce of the editor, 800 ms; not a shop setting.\nexport const AUTOSAVE_MS = 800;\n\nexport type ShopComposerPreset = { id: string; version: number; name: string; density: \"compact\" | \"airy\"; variants: Readonly<Record<string, string>> };\n\nexport type ShopComposerProps = {\n /** The draft to edit. The composer keeps its own history from it. */\n value: ShopPage;\n /** Change it to load another document (another draft): the history and the selection start again. */\n resetKey?: string | number;\n /** Called with a valid draft after 800 ms without a change: save it. A rejection says « Not saved ». */\n onChange?: (page: ShopPage) => void | Promise<void>;\n /** Called with the draft once the person confirmed the diff. */\n onPublish: (page: ShopPage) => void | Promise<void>;\n /** The discard of the draft (the product asks first, in its own dialog). Absent: no such button. */\n onDiscard?: () => void;\n /** What is live now, for the diff of « Publish ». Absent: the document the composer was opened with. */\n published?: ShopPage;\n /** The page of the product, in an iframe: its own route with `?draft=<id>`. Its origin is the bridge's. */\n previewUrl: string;\n /** The look presets of the shop's trade. */\n presets: readonly ShopComposerPreset[];\n /** The section types the trade does not use: folded under « … » in the catalogue. */\n foldedTypes?: readonly SectionType[];\n /** The words, translated. Default: English. */\n messages?: ShopComposerMessages;\n /** Classes merged on the root (its height: `h-[100dvh]`). */\n className?: string;\n};\n\ntype State = { history: History; epoch: number };\ntype Action = { type: \"run\"; cmd: Command; merge?: string } | { type: \"undo\" } | { type: \"redo\" } | { type: \"reset\"; page: ShopPage };\n\nfunction reducer(state: State, a: Action): State {\n switch (a.type) {\n case \"run\": {\n const history = run(state.history, a.cmd, a.merge);\n return history === state.history ? state : { ...state, history };\n }\n case \"undo\": {\n const history = undo(state.history);\n return history === state.history ? state : { history, epoch: state.epoch + 1 };\n }\n case \"redo\": {\n const history = redo(state.history);\n return history === state.history ? state : { history, epoch: state.epoch + 1 };\n }\n case \"reset\":\n return { history: createHistory(a.page), epoch: state.epoch + 1 };\n }\n}\n\nfunction PreviewFrame({ src, title, phone, frame }: { src: string; title: string; phone: boolean; frame: React.Ref<HTMLIFrameElement> }) {\n return (\n <div className=\"flex h-full min-h-0 justify-center overflow-auto bg-surface-2 p-3\">\n <iframe ref={frame} src={src || undefined} title={title} data-device={phone ? \"phone\" : \"desktop\"} className={phone ? \"h-full min-h-[34rem] w-[390px] max-w-full rounded-xl border border-border-default bg-surface-0\" : \"h-full min-h-[34rem] w-full rounded-xl border border-border-default bg-surface-0\"} />\n </div>\n );\n}\n\n/** The shop composer. */\nexport function ShopComposer({ value, resetKey, onChange, onPublish, onDiscard, published, previewUrl, presets, foldedTypes = [], messages = defaultShopComposerMessages, className }: ShopComposerProps) {\n const m = messages;\n const [{ history, epoch }, dispatch] = React.useReducer(reducer, value, (v): State => ({ history: createHistory(v), epoch: 0 }));\n const page = history.present;\n const [baseline, setBaseline] = React.useState(published ?? value);\n const [selected, setSelected] = React.useState<string | null>(page.sections[0]?.key ?? null);\n const [step, setStep] = React.useState<\"list\" | \"section\">(\"list\");\n const [live, setLive] = React.useState(\"\");\n const [status, setStatus] = React.useState<\"idle\" | \"saving\" | \"saved\" | \"error\">(\"idle\");\n const [adding, setAdding] = React.useState(false);\n const [publishing, setPublishing] = React.useState(false);\n const [device, setDevice] = React.useState<\"phone\" | \"desktop\">(\"desktop\");\n const [previewOpen, setPreviewOpen] = React.useState(false);\n const [invalid, setInvalid] = React.useState<ReadonlySet<string>>(new Set());\n const [focusRequest, setFocusRequest] = React.useState<{ key: string } | null>(null);\n const frame = React.useRef<HTMLIFrameElement | null>(null);\n const origin = React.useMemo(() => {\n try {\n return new URL(previewUrl, typeof location === \"undefined\" ? undefined : location.href).origin;\n } catch {\n return \"\";\n }\n }, [previewUrl]);\n\n // A `data:` or `about:` preview has an opaque origin (« null »): nothing can be addressed to it.\n const hasOrigin = origin !== \"\" && origin !== \"null\";\n\n // A new document from outside (another draft): history and selection start again.\n const first = React.useRef(true);\n const saved = React.useRef(page);\n React.useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n saved.current = value;\n dispatch({ type: \"reset\", page: value });\n setInvalid(new Set());\n setBaseline(published ?? value);\n setSelected(value.sections[0]?.key ?? null);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only a new `resetKey` reloads the document\n }, [resetKey]);\n\n const parsed = React.useMemo(() => parseShopPage(page), [page]);\n const announce = React.useCallback((message: string) => setLive((prev) => (prev === message ? message + String.fromCodePoint(0x200b) : message)), []);\n const exec = React.useCallback((cmd: Command, merge?: string) => dispatch({ type: \"run\", cmd, merge }), []);\n const selectedSection = page.sections.find((s) => s.key === selected) ?? null;\n const selectedIndex = selectedSection ? page.sections.indexOf(selectedSection) : -1;\n\n // Autosave to the draft: a valid document, after a calm of 800 ms; the preview refreshes once it is saved.\n React.useEffect(() => {\n if (page === saved.current || !parsed.ok || !onChange) return;\n const timer = setTimeout(async () => {\n setStatus(\"saving\");\n try {\n await onChange(page);\n saved.current = page;\n setStatus(\"saved\");\n if (hasOrigin) postToPreview(frame.current?.contentWindow, origin, { source: \"krizaka-shop-composer\", type: \"refresh\" });\n } catch {\n setStatus(\"error\");\n }\n }, AUTOSAVE_MS);\n return () => clearTimeout(timer);\n }, [page, parsed.ok, onChange, origin, hasOrigin]);\n\n // The preview follows the selection: outline and scroll.\n React.useEffect(() => {\n if (selected && hasOrigin) postToPreview(frame.current?.contentWindow, origin, { source: \"krizaka-shop-composer\", type: \"scroll\", key: selected });\n }, [selected, origin, hasOrigin]);\n\n const select = (key: string) => {\n setSelected(key);\n setStep(\"section\");\n };\n\n const addSection = (type: SectionType) => {\n const def = SECTION_DEFINITIONS.find((d) => d.type === type)!;\n const preferred = presets.find((p) => p.id === page.preset.id)?.variants[type];\n const variant = preferred && (def.variants as readonly string[]).includes(preferred) ? preferred : undefined;\n const key = newKey(\"s\");\n const at = type === \"hero\" ? 0 : page.sections.length;\n exec({ type: \"addSection\", sectionType: type, key, variant, at });\n setAdding(false);\n setSelected(key);\n setFocusRequest({ key });\n announce(fill(m.announceAdded, { name: m.sectionNames[type], n: at + 1 }));\n };\n\n // Undo and redo hand the form a document it did not write: what it said was invalid is no longer true.\n const step_ = (direction: \"undo\" | \"redo\") => {\n dispatch({ type: direction });\n setInvalid(new Set());\n announce(direction === \"undo\" ? m.announceUndone : m.announceRedone);\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (!(e.metaKey || e.ctrlKey) || e.key.toLowerCase() !== \"z\") return;\n const el = e.target as HTMLElement;\n if (el.closest(\"input, textarea, select, [contenteditable=true]\")) return;\n e.preventDefault();\n step_(e.shiftKey ? \"redo\" : \"undo\");\n };\n\n const changes: DiffEntry[] = publishing ? diffPages(baseline, page) : [];\n const nameOfKey = (key: string) => {\n const i = page.sections.findIndex((s) => s.key === key);\n if (i >= 0) return sectionLabel(page.sections, i, m);\n const was = baseline.sections.findIndex((s) => s.key === key);\n return was >= 0 ? sectionLabel(baseline.sections, was, m) : key;\n };\n const problems = [\n ...[...invalid].filter((key) => page.sections.some((s) => s.key === key)).map((key) => ({ key, text: fill(m.problemIn, { name: nameOfKey(key) }) })),\n ...(!parsed.ok ? parsed.issues.map((i) => ({ key: i.path, text: `${i.path}: ${i.message}` })) : []),\n ];\n const describe = (d: DiffEntry): string => {\n const name = \"key\" in d ? nameOfKey(d.key) : \"\";\n const t = m.diff[d.kind];\n switch (d.kind) {\n case \"moved\": return fill(t, { name, from: d.from + 1, to: d.to + 1 });\n case \"variant\": return fill(t, { name, from: m.variantNames[`${d.type}.${d.from}`] ?? d.from, to: m.variantNames[`${d.type}.${d.to}`] ?? d.to });\n case \"preset\": return fill(t, { from: presets.find((p) => p.id === d.from)?.name ?? d.from, to: presets.find((p) => p.id === d.to)?.name ?? d.to });\n case \"density\": return fill(t, { from: d.from ?? \"—\", to: d.to ?? \"—\" });\n default: return fill(t, { name });\n }\n };\n\n const status_ = status === \"saving\" ? m.saving : status === \"saved\" ? m.saved : status === \"error\" ? m.saveFailed : \"\";\n\n return (\n <div className={cn(\"kz-composer flex min-h-0 flex-col gap-3\", className)} onKeyDown={onKeyDown} data-step={step}>\n <header className=\"flex flex-wrap items-center gap-2 border-b border-border-subtle pb-2\">\n <h2 className=\"m-0 me-auto text-base font-semibold text-fg\">{m.title}</h2>\n <span role=\"status\" aria-live=\"polite\" className=\"text-xs text-fg-secondary\">{status_}</span>\n <Button variant=\"ghost\" size=\"sm\" disabled={!canUndo(history)} onClick={() => step_(\"undo\")} aria-keyshortcuts=\"Control+Z Meta+Z\">{m.undo}</Button>\n <Button variant=\"ghost\" size=\"sm\" disabled={!canRedo(history)} onClick={() => step_(\"redo\")} aria-keyshortcuts=\"Control+Shift+Z Meta+Shift+Z\">{m.redo}</Button>\n {onDiscard && <Button variant=\"ghost\" size=\"sm\" onClick={onDiscard}>{m.discard}</Button>}\n <Button variant=\"secondary\" size=\"sm\" className=\"lg:hidden\" onClick={() => setPreviewOpen(true)}>{m.viewPreview}</Button>\n <Button variant=\"primary\" size=\"sm\" onClick={() => setPublishing(true)}>{m.publish}</Button>\n </header>\n {/* One polite live region says every move, add, remove, undo. */}\n <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">{live}</p>\n\n <div className=\"grid min-h-0 flex-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)_24rem]\">\n <aside aria-label={m.sections} className={cn(\"flex min-h-0 flex-col gap-4 overflow-y-auto\", step === \"section\" && \"hidden lg:flex\")}>\n <Outline sections={page.sections} selected={selected} onSelect={select} run={exec} messages={m} announce={announce} onAdd={() => setAdding(true)} focusRequest={focusRequest} />\n <details className=\"rounded-lg border border-border-default p-3\" open>\n <summary className=\"min-h-9 cursor-pointer text-sm font-semibold text-fg\">{m.look}</summary>\n <div className=\"mt-2 grid gap-3\">\n <label className=\"grid gap-1 text-xs font-semibold text-fg-secondary\">\n {m.preset}\n <select\n className=\"min-h-10 rounded-md border border-border-control bg-surface-1 px-2 text-sm font-normal text-fg\"\n value={page.preset.id}\n onChange={(e) => {\n const p = presets.find((x) => x.id === e.target.value);\n if (p) exec({ type: \"setPreset\", preset: { id: p.id, version: p.version }, density: null });\n }}\n >\n {presets.map((p) => <option key={p.id} value={p.id}>{p.name}</option>)}\n </select>\n </label>\n <RadioGroup.Root label={m.density} variant=\"segmented\" value={page.density ?? presets.find((p) => p.id === page.preset.id)?.density ?? \"compact\"} onValueChange={(d) => exec({ type: \"setDensity\", density: d as \"compact\" | \"airy\" })}>\n <RadioGroup.Segment value=\"compact\">{m.densityCompact}</RadioGroup.Segment>\n <RadioGroup.Segment value=\"airy\">{m.densityAiry}</RadioGroup.Segment>\n </RadioGroup.Root>\n </div>\n </details>\n </aside>\n\n <section aria-label={m.preview} className=\"hidden min-h-0 flex-col gap-2 lg:flex\">\n <RadioGroup.Root label={m.preview} variant=\"segmented\" value={device} onValueChange={(d) => setDevice(d as \"phone\" | \"desktop\")} className=\"self-start\">\n <RadioGroup.Segment value=\"desktop\">{m.desktop}</RadioGroup.Segment>\n <RadioGroup.Segment value=\"phone\">{m.phone}</RadioGroup.Segment>\n </RadioGroup.Root>\n <PreviewFrame src={previewUrl} title={m.previewTitle} phone={device === \"phone\"} frame={frame} />\n </section>\n\n <aside aria-label={m.inspector} className={cn(\"flex min-h-0 flex-col gap-4 overflow-y-auto\", step === \"list\" && \"hidden lg:flex\")}>\n <Button variant=\"ghost\" size=\"sm\" className=\"self-start lg:hidden\" onClick={() => setStep(\"list\")}>← {m.backToSections}</Button>\n {selectedSection ? (\n <Inspector\n section={selectedSection}\n name={sectionLabel(page.sections, selectedIndex, m)}\n messages={m}\n run={exec}\n epoch={epoch}\n announce={announce}\n onInvalid={(key, bad) => setInvalid((prev) => { const next = new Set(prev); if (bad) next.add(key); else next.delete(key); return next.size === prev.size && next.has(key) === prev.has(key) ? prev : next; })}\n preset={page.preset.id}\n density={page.density}\n />\n ) : (\n <p className=\"m-0 text-sm text-fg-secondary\">{m.noSelection}</p>\n )}\n </aside>\n </div>\n\n <Dialog.Root open={adding} onOpenChange={setAdding}>\n <Dialog.Content closeLabel={m.cancel}>\n <Dialog.Header>\n <Dialog.Title>{m.addSection}</Dialog.Title>\n <Dialog.Description>{m.addSectionHint}</Dialog.Description>\n </Dialog.Header>\n <Dialog.Body>\n {[SECTION_DEFINITIONS.filter((d) => !foldedTypes.includes(d.type)), SECTION_DEFINITIONS.filter((d) => foldedTypes.includes(d.type))].map((group, g) => {\n const list = (\n <ul className=\"m-0 grid list-none gap-1 p-0\">\n {group.map((d) => (\n <li key={d.type}>\n <Button variant=\"ghost\" className=\"w-full justify-start\" disabled={d.type === \"hero\" && page.sections.some((s) => s.type === \"hero\")} onClick={() => addSection(d.type)}>\n {m.sectionNames[d.type]}\n </Button>\n </li>\n ))}\n </ul>\n );\n return group.length === 0 ? null : g === 0 ? <React.Fragment key={g}>{list}</React.Fragment> : <details key={g} className=\"mt-3\"><summary className=\"min-h-9 cursor-pointer text-sm text-fg-secondary\">…</summary>{list}</details>;\n })}\n </Dialog.Body>\n </Dialog.Content>\n </Dialog.Root>\n\n <Dialog.Root open={publishing} onOpenChange={setPublishing}>\n <Dialog.Content closeLabel={m.cancel}>\n <Dialog.Header>\n <Dialog.Title>{m.publishTitle}</Dialog.Title>\n <Dialog.Description>{m.publishWhat}</Dialog.Description>\n </Dialog.Header>\n <Dialog.Body>\n {problems.length > 0 && (\n <div role=\"alert\" className=\"mb-3 rounded-md border border-border-control bg-surface-2 p-3\">\n <p className=\"m-0 text-sm font-semibold text-fg\">{fill(m.problemsTitle, { n: problems.length })}</p>\n <ul className=\"m-0 mt-1 list-disc ps-5 text-sm text-fg-secondary\">{problems.map((p) => <li key={p.key}>{p.text}</li>)}</ul>\n </div>\n )}\n {changes.length === 0 ? (\n <p className=\"m-0 text-sm text-fg-secondary\">{m.publishNothing}</p>\n ) : (\n <ul className=\"m-0 list-disc ps-5 text-sm text-fg\">{changes.map((d, i) => <li key={i}>{describe(d)}</li>)}</ul>\n )}\n </Dialog.Body>\n <Dialog.Footer>\n <Dialog.Close asChild><Button variant=\"ghost\">{m.cancel}</Button></Dialog.Close>\n <Button variant=\"primary\" disabled={problems.length > 0 || !parsed.ok} onClick={async () => { await onPublish(page); setBaseline(page); setPublishing(false); }}>{m.publishConfirm}</Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog.Root>\n\n <Dialog.Root open={previewOpen} onOpenChange={setPreviewOpen}>\n <Dialog.Content closeLabel={m.closePreview} size=\"lg\">\n <Dialog.Header><Dialog.Title>{m.preview}</Dialog.Title></Dialog.Header>\n <Dialog.Body className=\"p-0\">\n {previewOpen && <PreviewFrame src={previewUrl} title={m.previewTitle} phone frame={frame} />}\n </Dialog.Body>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n );\n}\n"
|
|
233
|
+
"content": "\"use client\";\n\n// Our own shop composer (ADR-007 §5): three panes on a laptop — the outline of the sections, the live preview of the product's own\n// public page, the inspector of the selected section — and two steps on a phone (the list, then the section; the preview behind a\n// « View » button). Every change is a command on a reducer (⌘Z / ⇧⌘Z, 100 steps), saved to the draft after 800 ms of calm; « Publish »\n// shows what changes and refuses while a setting is invalid. Every action has a keyboard path. No third-party editor: Puck was weighed\n// and not adopted (the model is a list, not a canvas).\nimport { Button } from \"@krizaka/ui/button\";\nimport { Dialog } from \"@krizaka/ui/dialog\";\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { SECTION_DEFINITIONS, type SectionType } from \"../shop/catalogue\";\nimport { postToPreview } from \"../shop/preview\";\nimport { parseShopPage, type ShopPage } from \"../shop/schema\";\nimport { type Command } from \"./commands\";\nimport { type DiffEntry, diffPages } from \"./diff\";\nimport { canRedo, canUndo, createHistory, type History, redo, run, undo } from \"./history\";\nimport { Inspector } from \"./inspector\";\nimport { newKey } from \"./keys\";\nimport { LookPicker } from \"./look-picker\";\nimport { defaultShopComposerMessages, fill, type ShopComposerMessages } from \"./messages\";\nimport { Outline, sectionLabel } from \"./outline\";\n\n/** How long the draft waits for calm before it is saved. */\n// @fixed: ADR-007 §5 — the autosave debounce of the editor, 800 ms; not a shop setting.\nexport const AUTOSAVE_MS = 800;\n\nexport type ShopComposerPreset = {\n id: string;\n version: number;\n name: string;\n density: \"compact\" | \"airy\";\n variants: Readonly<Record<string, string>>;\n /** A look's (`look-*`): the accent it starts with and the tested list the owner chooses from. Presets without a list are trade presets (the « Style » select). */\n accent?: string;\n accents?: readonly string[];\n};\n\nexport type ShopComposerProps = {\n /** The draft to edit. The composer keeps its own history from it. */\n value: ShopPage;\n /** Change it to load another document (another draft): the history and the selection start again. */\n resetKey?: string | number;\n /** Called with a valid draft after 800 ms without a change: save it. A rejection says « Not saved ». */\n onChange?: (page: ShopPage) => void | Promise<void>;\n /** Called with the draft once the person confirmed the diff. */\n onPublish: (page: ShopPage) => void | Promise<void>;\n /** The discard of the draft (the product asks first, in its own dialog). Absent: no such button. */\n onDiscard?: () => void;\n /** What is live now, for the diff of « Publish ». Absent: the document the composer was opened with. */\n published?: ShopPage;\n /** The page of the product, in an iframe: its own route with `?draft=<id>`. Its origin is the bridge's. */\n previewUrl: string;\n /** The look presets of the shop's trade. */\n presets: readonly ShopComposerPreset[];\n /** The section types the trade does not use: folded under « … » in the catalogue. */\n foldedTypes?: readonly SectionType[];\n /** The words, translated. Default: English. */\n messages?: ShopComposerMessages;\n /** Classes merged on the root (its height: `h-[100dvh]`). */\n className?: string;\n};\n\ntype State = { history: History; epoch: number };\ntype Action = { type: \"run\"; cmd: Command; merge?: string } | { type: \"undo\" } | { type: \"redo\" } | { type: \"reset\"; page: ShopPage };\n\nfunction reducer(state: State, a: Action): State {\n switch (a.type) {\n case \"run\": {\n const history = run(state.history, a.cmd, a.merge);\n return history === state.history ? state : { ...state, history };\n }\n case \"undo\": {\n const history = undo(state.history);\n return history === state.history ? state : { history, epoch: state.epoch + 1 };\n }\n case \"redo\": {\n const history = redo(state.history);\n return history === state.history ? state : { history, epoch: state.epoch + 1 };\n }\n case \"reset\":\n return { history: createHistory(a.page), epoch: state.epoch + 1 };\n }\n}\n\nfunction PreviewFrame({ src, title, phone, frame }: { src: string; title: string; phone: boolean; frame: React.Ref<HTMLIFrameElement> }) {\n return (\n <div className=\"flex h-full min-h-0 justify-center overflow-auto bg-surface-2 p-3\">\n <iframe ref={frame} src={src || undefined} title={title} data-device={phone ? \"phone\" : \"desktop\"} className={phone ? \"h-full min-h-[34rem] w-[390px] max-w-full rounded-xl border border-border-default bg-surface-0\" : \"h-full min-h-[34rem] w-full rounded-xl border border-border-default bg-surface-0\"} />\n </div>\n );\n}\n\n/** The shop composer. */\nexport function ShopComposer({ value, resetKey, onChange, onPublish, onDiscard, published, previewUrl, presets, foldedTypes = [], messages = defaultShopComposerMessages, className }: ShopComposerProps) {\n const m = messages;\n const [{ history, epoch }, dispatch] = React.useReducer(reducer, value, (v): State => ({ history: createHistory(v), epoch: 0 }));\n const page = history.present;\n const [baseline, setBaseline] = React.useState(published ?? value);\n const [selected, setSelected] = React.useState<string | null>(page.sections[0]?.key ?? null);\n const [step, setStep] = React.useState<\"list\" | \"section\">(\"list\");\n const [live, setLive] = React.useState(\"\");\n const [status, setStatus] = React.useState<\"idle\" | \"saving\" | \"saved\" | \"error\">(\"idle\");\n const [adding, setAdding] = React.useState(false);\n const [publishing, setPublishing] = React.useState(false);\n const [device, setDevice] = React.useState<\"phone\" | \"desktop\">(\"desktop\");\n const [previewOpen, setPreviewOpen] = React.useState(false);\n const [invalid, setInvalid] = React.useState<ReadonlySet<string>>(new Set());\n const [focusRequest, setFocusRequest] = React.useState<{ key: string } | null>(null);\n const frame = React.useRef<HTMLIFrameElement | null>(null);\n const origin = React.useMemo(() => {\n try {\n return new URL(previewUrl, typeof location === \"undefined\" ? undefined : location.href).origin;\n } catch {\n return \"\";\n }\n }, [previewUrl]);\n\n // A `data:` or `about:` preview has an opaque origin (« null »): nothing can be addressed to it.\n const hasOrigin = origin !== \"\" && origin !== \"null\";\n\n // A new document from outside (another draft): history and selection start again.\n const first = React.useRef(true);\n const saved = React.useRef(page);\n React.useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n saved.current = value;\n dispatch({ type: \"reset\", page: value });\n setInvalid(new Set());\n setBaseline(published ?? value);\n setSelected(value.sections[0]?.key ?? null);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only a new `resetKey` reloads the document\n }, [resetKey]);\n\n const parsed = React.useMemo(() => parseShopPage(page), [page]);\n const looks = React.useMemo(() => presets.filter((p) => p.id.startsWith(\"look-\")), [presets]);\n const styles = React.useMemo(() => presets.filter((p) => !p.id.startsWith(\"look-\")), [presets]);\n const announce = React.useCallback((message: string) => setLive((prev) => (prev === message ? message + String.fromCodePoint(0x200b) : message)), []);\n const exec = React.useCallback((cmd: Command, merge?: string) => dispatch({ type: \"run\", cmd, merge }), []);\n const selectedSection = page.sections.find((s) => s.key === selected) ?? null;\n const selectedIndex = selectedSection ? page.sections.indexOf(selectedSection) : -1;\n\n // Autosave to the draft: a valid document, after a calm of 800 ms; the preview refreshes once it is saved.\n React.useEffect(() => {\n if (page === saved.current || !parsed.ok || !onChange) return;\n const timer = setTimeout(async () => {\n setStatus(\"saving\");\n try {\n await onChange(page);\n saved.current = page;\n setStatus(\"saved\");\n if (hasOrigin) postToPreview(frame.current?.contentWindow, origin, { source: \"krizaka-shop-composer\", type: \"refresh\" });\n } catch {\n setStatus(\"error\");\n }\n }, AUTOSAVE_MS);\n return () => clearTimeout(timer);\n }, [page, parsed.ok, onChange, origin, hasOrigin]);\n\n // The preview follows the selection: outline and scroll.\n React.useEffect(() => {\n if (selected && hasOrigin) postToPreview(frame.current?.contentWindow, origin, { source: \"krizaka-shop-composer\", type: \"scroll\", key: selected });\n }, [selected, origin, hasOrigin]);\n\n const select = (key: string) => {\n setSelected(key);\n setStep(\"section\");\n };\n\n const addSection = (type: SectionType) => {\n const def = SECTION_DEFINITIONS.find((d) => d.type === type)!;\n const preferred = presets.find((p) => p.id === page.preset.id)?.variants[type];\n const variant = preferred && (def.variants as readonly string[]).includes(preferred) ? preferred : undefined;\n const key = newKey(\"s\");\n const at = type === \"hero\" ? 0 : page.sections.length;\n exec({ type: \"addSection\", sectionType: type, key, variant, at });\n setAdding(false);\n setSelected(key);\n setFocusRequest({ key });\n announce(fill(m.announceAdded, { name: m.sectionNames[type], n: at + 1 }));\n };\n\n // Undo and redo hand the form a document it did not write: what it said was invalid is no longer true.\n const step_ = (direction: \"undo\" | \"redo\") => {\n dispatch({ type: direction });\n setInvalid(new Set());\n announce(direction === \"undo\" ? m.announceUndone : m.announceRedone);\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (!(e.metaKey || e.ctrlKey) || e.key.toLowerCase() !== \"z\") return;\n const el = e.target as HTMLElement;\n if (el.closest(\"input, textarea, select, [contenteditable=true]\")) return;\n e.preventDefault();\n step_(e.shiftKey ? \"redo\" : \"undo\");\n };\n\n const changes: DiffEntry[] = publishing ? diffPages(baseline, page) : [];\n const nameOfKey = (key: string) => {\n const i = page.sections.findIndex((s) => s.key === key);\n if (i >= 0) return sectionLabel(page.sections, i, m);\n const was = baseline.sections.findIndex((s) => s.key === key);\n return was >= 0 ? sectionLabel(baseline.sections, was, m) : key;\n };\n const problems = [\n ...[...invalid].filter((key) => page.sections.some((s) => s.key === key)).map((key) => ({ key, text: fill(m.problemIn, { name: nameOfKey(key) }) })),\n ...(!parsed.ok ? parsed.issues.map((i) => ({ key: i.path, text: `${i.path}: ${i.message}` })) : []),\n ];\n const describe = (d: DiffEntry): string => {\n const name = \"key\" in d ? nameOfKey(d.key) : \"\";\n const t = m.diff[d.kind];\n switch (d.kind) {\n case \"moved\": return fill(t, { name, from: d.from + 1, to: d.to + 1 });\n case \"variant\": return fill(t, { name, from: m.variantNames[`${d.type}.${d.from}`] ?? d.from, to: m.variantNames[`${d.type}.${d.to}`] ?? d.to });\n case \"preset\": return fill(t, { from: presets.find((p) => p.id === d.from)?.name ?? d.from, to: presets.find((p) => p.id === d.to)?.name ?? d.to });\n case \"density\": return fill(t, { from: d.from ?? \"—\", to: d.to ?? \"—\" });\n default: return fill(t, { name });\n }\n };\n\n const status_ = status === \"saving\" ? m.saving : status === \"saved\" ? m.saved : status === \"error\" ? m.saveFailed : \"\";\n\n return (\n <div className={cn(\"kz-composer flex min-h-0 flex-col gap-3\", className)} onKeyDown={onKeyDown} data-step={step}>\n <header className=\"flex flex-wrap items-center gap-2 border-b border-border-subtle pb-2\">\n <h2 className=\"m-0 me-auto text-base font-semibold text-fg\">{m.title}</h2>\n <span role=\"status\" aria-live=\"polite\" className=\"text-xs text-fg-secondary\">{status_}</span>\n <Button variant=\"ghost\" size=\"sm\" disabled={!canUndo(history)} onClick={() => step_(\"undo\")} aria-keyshortcuts=\"Control+Z Meta+Z\">{m.undo}</Button>\n <Button variant=\"ghost\" size=\"sm\" disabled={!canRedo(history)} onClick={() => step_(\"redo\")} aria-keyshortcuts=\"Control+Shift+Z Meta+Shift+Z\">{m.redo}</Button>\n {onDiscard && <Button variant=\"ghost\" size=\"sm\" onClick={onDiscard}>{m.discard}</Button>}\n <Button variant=\"secondary\" size=\"sm\" className=\"lg:hidden\" onClick={() => setPreviewOpen(true)}>{m.viewPreview}</Button>\n <Button variant=\"primary\" size=\"sm\" onClick={() => setPublishing(true)}>{m.publish}</Button>\n </header>\n {/* One polite live region says every move, add, remove, undo. */}\n <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">{live}</p>\n\n <div className=\"grid min-h-0 flex-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)_24rem]\">\n <aside aria-label={m.sections} className={cn(\"flex min-h-0 flex-col gap-4 overflow-y-auto\", step === \"section\" && \"hidden lg:flex\")}>\n <Outline sections={page.sections} selected={selected} onSelect={select} run={exec} messages={m} announce={announce} onAdd={() => setAdding(true)} focusRequest={focusRequest} />\n <details className=\"rounded-lg border border-border-default p-3\" open>\n <summary className=\"min-h-9 cursor-pointer text-sm font-semibold text-fg\">{m.look}</summary>\n <div className=\"mt-2 grid gap-3\">\n {looks.length > 0 && <LookPicker looks={looks} page={page} messages={m} run={exec} announce={announce} />}\n {styles.length > 0 && <label className=\"grid gap-1 text-xs font-semibold text-fg-secondary\">\n {m.preset}\n <select\n className=\"min-h-10 rounded-md border border-border-control bg-surface-1 px-2 text-sm font-normal text-fg\"\n value={page.preset.id}\n onChange={(e) => {\n const p = presets.find((x) => x.id === e.target.value);\n if (p) exec({ type: \"setPreset\", preset: { id: p.id, version: p.version }, density: null });\n }}\n >\n {styles.map((p) => <option key={p.id} value={p.id}>{p.name}</option>)}\n </select>\n </label>}\n <RadioGroup.Root label={m.density} variant=\"segmented\" value={page.density ?? presets.find((p) => p.id === page.preset.id)?.density ?? \"compact\"} onValueChange={(d) => exec({ type: \"setDensity\", density: d as \"compact\" | \"airy\" })}>\n <RadioGroup.Segment value=\"compact\">{m.densityCompact}</RadioGroup.Segment>\n <RadioGroup.Segment value=\"airy\">{m.densityAiry}</RadioGroup.Segment>\n </RadioGroup.Root>\n </div>\n </details>\n </aside>\n\n <section aria-label={m.preview} className=\"hidden min-h-0 flex-col gap-2 lg:flex\">\n <RadioGroup.Root label={m.preview} variant=\"segmented\" value={device} onValueChange={(d) => setDevice(d as \"phone\" | \"desktop\")} className=\"self-start\">\n <RadioGroup.Segment value=\"desktop\">{m.desktop}</RadioGroup.Segment>\n <RadioGroup.Segment value=\"phone\">{m.phone}</RadioGroup.Segment>\n </RadioGroup.Root>\n <PreviewFrame src={previewUrl} title={m.previewTitle} phone={device === \"phone\"} frame={frame} />\n </section>\n\n <aside aria-label={m.inspector} className={cn(\"flex min-h-0 flex-col gap-4 overflow-y-auto\", step === \"list\" && \"hidden lg:flex\")}>\n <Button variant=\"ghost\" size=\"sm\" className=\"self-start lg:hidden\" onClick={() => setStep(\"list\")}>← {m.backToSections}</Button>\n {selectedSection ? (\n <Inspector\n section={selectedSection}\n name={sectionLabel(page.sections, selectedIndex, m)}\n messages={m}\n run={exec}\n epoch={epoch}\n announce={announce}\n onInvalid={(key, bad) => setInvalid((prev) => { const next = new Set(prev); if (bad) next.add(key); else next.delete(key); return next.size === prev.size && next.has(key) === prev.has(key) ? prev : next; })}\n preset={page.preset.id}\n density={page.density}\n />\n ) : (\n <p className=\"m-0 text-sm text-fg-secondary\">{m.noSelection}</p>\n )}\n </aside>\n </div>\n\n <Dialog.Root open={adding} onOpenChange={setAdding}>\n <Dialog.Content closeLabel={m.cancel}>\n <Dialog.Header>\n <Dialog.Title>{m.addSection}</Dialog.Title>\n <Dialog.Description>{m.addSectionHint}</Dialog.Description>\n </Dialog.Header>\n <Dialog.Body>\n {[SECTION_DEFINITIONS.filter((d) => !foldedTypes.includes(d.type)), SECTION_DEFINITIONS.filter((d) => foldedTypes.includes(d.type))].map((group, g) => {\n const list = (\n <ul className=\"m-0 grid list-none gap-1 p-0\">\n {group.map((d) => (\n <li key={d.type}>\n <Button variant=\"ghost\" className=\"w-full justify-start\" disabled={d.type === \"hero\" && page.sections.some((s) => s.type === \"hero\")} onClick={() => addSection(d.type)}>\n {m.sectionNames[d.type]}\n </Button>\n </li>\n ))}\n </ul>\n );\n return group.length === 0 ? null : g === 0 ? <React.Fragment key={g}>{list}</React.Fragment> : <details key={g} className=\"mt-3\"><summary className=\"min-h-9 cursor-pointer text-sm text-fg-secondary\">…</summary>{list}</details>;\n })}\n </Dialog.Body>\n </Dialog.Content>\n </Dialog.Root>\n\n <Dialog.Root open={publishing} onOpenChange={setPublishing}>\n <Dialog.Content closeLabel={m.cancel}>\n <Dialog.Header>\n <Dialog.Title>{m.publishTitle}</Dialog.Title>\n <Dialog.Description>{m.publishWhat}</Dialog.Description>\n </Dialog.Header>\n <Dialog.Body>\n {problems.length > 0 && (\n <div role=\"alert\" className=\"mb-3 rounded-md border border-border-control bg-surface-2 p-3\">\n <p className=\"m-0 text-sm font-semibold text-fg\">{fill(m.problemsTitle, { n: problems.length })}</p>\n <ul className=\"m-0 mt-1 list-disc ps-5 text-sm text-fg-secondary\">{problems.map((p) => <li key={p.key}>{p.text}</li>)}</ul>\n </div>\n )}\n {changes.length === 0 ? (\n <p className=\"m-0 text-sm text-fg-secondary\">{m.publishNothing}</p>\n ) : (\n <ul className=\"m-0 list-disc ps-5 text-sm text-fg\">{changes.map((d, i) => <li key={i}>{describe(d)}</li>)}</ul>\n )}\n </Dialog.Body>\n <Dialog.Footer>\n <Dialog.Close asChild><Button variant=\"ghost\">{m.cancel}</Button></Dialog.Close>\n <Button variant=\"primary\" disabled={problems.length > 0 || !parsed.ok} onClick={async () => { await onPublish(page); setBaseline(page); setPublishing(false); }}>{m.publishConfirm}</Button>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog.Root>\n\n <Dialog.Root open={previewOpen} onOpenChange={setPreviewOpen}>\n <Dialog.Content closeLabel={m.closePreview} size=\"lg\">\n <Dialog.Header><Dialog.Title>{m.preview}</Dialog.Title></Dialog.Header>\n <Dialog.Body className=\"p-0\">\n {previewOpen && <PreviewFrame src={previewUrl} title={m.previewTitle} phone frame={frame} />}\n </Dialog.Body>\n </Dialog.Content>\n </Dialog.Root>\n </div>\n );\n}\n"
|
|
232
234
|
},
|
|
233
235
|
{
|
|
234
236
|
"path": "shop-composer/diff.ts",
|
|
@@ -254,13 +256,17 @@
|
|
|
254
256
|
"path": "shop-composer/keys.ts",
|
|
255
257
|
"content": "// Stable keys (ADR-007 §1): « s_8f2c » for a section, « b_3a91 » for a block — generated once, they survive every reorder and\n// anchor the audit. Generated by the composer, never by the reducer (which stays pure).\nconst alphabet = \"0123456789abcdef\";\n\n/** A short random key with a prefix; `random` is injectable so a test is deterministic. */\nexport function newKey(prefix: \"s\" | \"b\", random: () => number = Math.random): string {\n let out = \"\";\n for (let i = 0; i < 6; i++) out += alphabet[Math.floor(random() * 16)];\n return `${prefix}_${out}`;\n}\n"
|
|
256
258
|
},
|
|
259
|
+
{
|
|
260
|
+
"path": "shop-composer/look-picker.tsx",
|
|
261
|
+
"content": "// The look of the page (akinaza#478): a radio group of the six looks as swatches (name, the look's own surface and its accent\n// chips), then the accent within the chosen look's tested list. It applies to the draft only; publishing goes through the diff.\nimport { RadioGroup } from \"@krizaka/ui/radio-group\";\n\nimport { cn } from \"../cn\";\nimport type { ShopPage } from \"../shop/schema\";\nimport type { Command } from \"./commands\";\nimport type { ShopComposerPreset } from \"./composer\";\nimport { fill, type ShopComposerMessages } from \"./messages\";\n\nexport type LookPickerProps = {\n looks: readonly ShopComposerPreset[];\n page: ShopPage;\n messages: ShopComposerMessages;\n run: (cmd: Command) => void;\n announce: (message: string) => void;\n};\n\n/** The accent chips of a look, drawn by its own tokens. */\nfunction Chips({ look }: { look: ShopComposerPreset }) {\n return (\n <span aria-hidden className=\"inline-flex gap-1\">\n {(look.accents ?? [look.accent ?? \"krizaka\"]).map((a) => (\n <span key={a} data-shop-preset={look.id} data-shop-accent={a} className=\"kz-look-chip\">\n <i />\n </span>\n ))}\n </span>\n );\n}\n\nexport function LookPicker({ looks, page, messages: m, run, announce }: LookPickerProps) {\n const current = looks.find((l) => l.id === page.preset.id);\n const accents = current?.accents ?? [];\n return (\n <div className=\"grid gap-3\">\n <RadioGroup.Root\n label={m.lookChoice}\n variant=\"cards\"\n value={current?.id ?? \"\"}\n onValueChange={(id) => {\n const look = looks.find((l) => l.id === id);\n if (!look) return;\n run({ type: \"applyLook\", look });\n announce(fill(m.lookApplied, { name: look.name }));\n }}\n className=\"grid-cols-2\"\n >\n {looks.map((l) => (\n <RadioGroup.Card key={l.id} value={l.id}>\n <span data-shop-preset={l.id} className={cn(\"kz-look-swatch\", \"w-full justify-between\")}>\n <span className=\"text-sm font-semibold\">{l.name}</span>\n <Chips look={l} />\n </span>\n </RadioGroup.Card>\n ))}\n </RadioGroup.Root>\n {accents.length > 1 && (\n <RadioGroup.Root label={m.accentChoice} variant=\"buttons\" value={page.accent ?? current?.accent ?? accents[0]} onValueChange={(a) => run({ type: \"setAccent\", accent: a === current?.accent ? undefined : a })}>\n {accents.map((a) => (\n <RadioGroup.Button key={a} value={a}>\n {m.accentNames[a] ?? a}\n </RadioGroup.Button>\n ))}\n </RadioGroup.Root>\n )}\n </div>\n );\n}\n"
|
|
262
|
+
},
|
|
257
263
|
{
|
|
258
264
|
"path": "shop-composer/messages.ts",
|
|
259
|
-
"content": "// The composer's words (ADR-007 §5): every string is a prop — the product passes its translated copy. English is the default, so\n// a story or a first integration works without a catalogue; `{name}`, `{n}`, `{total}` are replaced by `fill`.\nimport type { SectionType } from \"../shop/catalogue\";\nimport type { DiffEntry } from \"./diff\";\n\nexport type ShopComposerMessages = {\n title: string;\n /** The outline's name. */\n sections: string;\n addSection: string;\n addSectionHint: string;\n /** « Show {name} » / the switch's accessible name. */\n toggleVisible: string;\n sectionMenu: string;\n moveUp: string;\n moveDown: string;\n moveTop: string;\n remove: string;\n /** Announcements. */\n announceMoved: string;\n announceCannotMove: string;\n announceAdded: string;\n announceRemoved: string;\n announceShown: string;\n announceHidden: string;\n announceUndone: string;\n announceRedone: string;\n hiddenNote: string;\n /** The inspector. */\n inspector: string;\n noSelection: string;\n backToSections: string;\n variant: string;\n settings: string;\n words: string;\n titleField: string;\n leadField: string;\n french: string;\n english: string;\n blocks: string;\n addBlock: string;\n removeBlock: string;\n /** The look. */\n look: string;\n preset: string;\n density: string;\n densityCompact: string;\n densityAiry: string;\n /** The toolbar. */\n undo: string;\n redo: string;\n saved: string;\n saving: string;\n saveFailed: string;\n publish: string;\n discard: string;\n /** The preview. */\n preview: string;\n previewTitle: string;\n phone: string;\n desktop: string;\n viewPreview: string;\n closePreview: string;\n /** The publish dialog. */\n publishTitle: string;\n publishWhat: string;\n publishNothing: string;\n publishConfirm: string;\n cancel: string;\n problemsTitle: string;\n problemIn: string;\n /** The names. */\n sectionNames: Record<SectionType, string>;\n /** `type.variant` → « Poster ». */\n variantNames: Record<string, string>;\n blockNames: Record<string, string>;\n settingNames: Record<string, string>;\n optionNames: Record<string, string>;\n /** One line per kind of change, with `{name}` (the section) and `{from}` / `{to}` / `{n}`. */\n diff: Record<DiffEntry[\"kind\"], string>;\n};\n\n/** `fill(\"Moved to {n}\", { n: 2 })`. */\nexport const fill = (message: string, vars: Record<string, string | number>) => message.replace(/\\{(\\w+)\\}/g, (_, k: string) => String(vars[k] ?? `{${k}}`));\n\nconst sectionNames: Record<SectionType, string> = {\n hero: \"Hero\", services: \"Services\", booking: \"Booking\", gallery: \"Photos\", video: \"Video\", reviews: \"Reviews\", bulletin: \"News\",\n team: \"Team\", visit: \"Visit\", story: \"Story\", social: \"Social\", faq: \"Questions\", policies: \"Policies\",\n};\n\nconst variantNames: Record<string, string> = {\n \"hero.poster\": \"Poster\", \"hero.split\": \"Split\", \"hero.banner\": \"Banner\", \"hero.tv\": \"Television\",\n \"services.menu\": \"Menu\", \"services.cards\": \"Cards\", \"services.index\": \"Index cards\", \"services.carousel\": \"Carousel\",\n \"booking.strip\": \"Next times\", \"booking.panel\": \"Closing call\", \"booking.sticky\": \"Phone bar\",\n \"gallery.mosaic\": \"Mosaic\", \"gallery.filmstrip\": \"Filmstrip\", \"gallery.wall\": \"Wall\", \"gallery.grid\": \"Grid\",\n \"video.tv\": \"Television\", \"video.shorts\": \"Reels\",\n \"reviews.summary-cards\": \"Score and reviews\", \"reviews.quote\": \"One quote\", \"reviews.strip\": \"Score line\",\n \"bulletin.board\": \"Board\", \"bulletin.banner\": \"Banner line\",\n \"team.row\": \"Row\", \"team.cards\": \"Cards\",\n \"visit.card\": \"Card\", \"visit.map\": \"Map\", \"visit.split\": \"Hours and map\",\n \"story.quote\": \"Quote\", \"story.owner\": \"Owner\",\n \"social.links\": \"Links\", \"social.facade\": \"Latest reel\",\n \"faq.list\": \"List\", \"policies.inline\": \"Inline\",\n};\n\nexport const defaultShopComposerMessages: ShopComposerMessages = {\n title: \"Shop page\",\n sections: \"Sections\",\n addSection: \"Add a section\",\n addSectionHint: \"Choose what to add to your page.\",\n toggleVisible: \"Show {name}\",\n sectionMenu: \"Actions for {name}\",\n moveUp: \"Move up\",\n moveDown: \"Move down\",\n moveTop: \"Move to top\",\n remove: \"Remove\",\n announceMoved: \"{name} moved to position {n} of {total}\",\n announceCannotMove: \"{name} cannot move further\",\n announceAdded: \"{name} added at position {n}\",\n announceRemoved: \"{name} removed\",\n announceShown: \"{name} is shown\",\n announceHidden: \"{name} is hidden\",\n announceUndone: \"Undone\",\n announceRedone: \"Redone\",\n hiddenNote: \"hidden\",\n inspector: \"Section\",\n noSelection: \"Choose a section to change how it is drawn.\",\n backToSections: \"Back to sections\",\n variant: \"How it is drawn\",\n settings: \"Settings\",\n words: \"Your words\",\n titleField: \"Title\",\n leadField: \"Line under the title\",\n french: \"French\",\n english: \"English\",\n blocks: \"Items\",\n addBlock: \"Add\",\n removeBlock: \"Remove {name}\",\n look: \"Look\",\n preset: \"Style\",\n density: \"Spacing\",\n densityCompact: \"Compact\",\n densityAiry: \"Airy\",\n undo: \"Undo\",\n redo: \"Redo\",\n saved: \"Saved\",\n saving: \"Saving…\",\n saveFailed: \"Not saved\",\n publish: \"Publish\",\n discard: \"Discard the draft\",\n preview: \"Preview\",\n previewTitle: \"Live preview of your page\",\n phone: \"Phone\",\n desktop: \"Desktop\",\n viewPreview: \"View\",\n closePreview: \"Close\",\n publishTitle: \"Publish this page\",\n publishWhat: \"What changes\",\n publishNothing: \"Nothing has changed since the last publication.\",\n publishConfirm: \"Publish\",\n cancel: \"Cancel\",\n problemsTitle: \"Fix {n} problem before publishing\",\n problemIn: \"{name}\",\n sectionNames,\n variantNames,\n blockNames: { fact: \"Fact\", service: \"Service\", photo: \"Photo\", note: \"Note\", sign: \"Sign\", reel: \"Reel\", flyer: \"Flyer\", member: \"Member\", link: \"Link\", question: \"Question\" },\n settingNames: { media: \"Photo\", focus: \"Crop\", source: \"Source\", groupBy: \"Group by\", columns: \"Columns\", aside: \"Beside the list\", serviceId: \"Service\", count: \"How many\", texture: \"Wall\", cabinet: \"Cabinet\", channel: \"Channel\", rule: \"Which reviews\", showPhone: \"Show the phone number\", body: \"Text\", show: \"Show\" },\n optionNames: { center: \"Centre\", top: \"Top\", bottom: \"Bottom\", all: \"All\", pick: \"Pick\", category: \"Category\", none: \"None\", hours: \"Hours\", plaster: \"Plaster\", brick: \"Brick\", ridge: \"Ridge\", zellige: \"Zellige\", cabinet: \"Cabinet\", portable: \"Portable\", best: \"Best\", latest: \"Latest\", cancellation: \"Cancellation\", prices: \"Prices\", \"booking-window\": \"Booking window\" },\n diff: {\n added: \"{name} added\",\n removed: \"{name} removed\",\n moved: \"{name} moved from {from} to {to}\",\n variant: \"{name} drawn as {to} (was {from})\",\n settings: \"{name}: settings changed\",\n blocks: \"{name}: items changed\",\n text: \"{name}: words changed\",\n disabled: \"{name} hidden\",\n enabled: \"{name} shown\",\n preset: \"Style changed to {to} (was {from})\",\n density: \"Spacing changed to {to} (was {from})\",\n },\n};\n"
|
|
265
|
+
"content": "// The composer's words (ADR-007 §5): every string is a prop — the product passes its translated copy. English is the default, so\n// a story or a first integration works without a catalogue; `{name}`, `{n}`, `{total}` are replaced by `fill`.\nimport type { SectionType } from \"../shop/catalogue\";\nimport type { DiffEntry } from \"./diff\";\n\nexport type ShopComposerMessages = {\n title: string;\n /** The outline's name. */\n sections: string;\n addSection: string;\n addSectionHint: string;\n /** « Show {name} » / the switch's accessible name. */\n toggleVisible: string;\n sectionMenu: string;\n moveUp: string;\n moveDown: string;\n moveTop: string;\n remove: string;\n /** Announcements. */\n announceMoved: string;\n announceCannotMove: string;\n announceAdded: string;\n announceRemoved: string;\n announceShown: string;\n announceHidden: string;\n announceUndone: string;\n announceRedone: string;\n hiddenNote: string;\n /** The inspector. */\n inspector: string;\n noSelection: string;\n backToSections: string;\n variant: string;\n settings: string;\n words: string;\n titleField: string;\n leadField: string;\n french: string;\n english: string;\n blocks: string;\n addBlock: string;\n removeBlock: string;\n /** The look. */\n look: string;\n /** The six looks, as a group of swatches. */\n lookChoice: string;\n /** Said when a look is applied (`{name}`). */\n lookApplied: string;\n /** The accent within the chosen look. */\n accentChoice: string;\n /** The names of the accents a look lists (`krizaka`, `akinaza:accent-2`…); an unknown one reads as its id. */\n accentNames: Readonly<Record<string, string>>;\n preset: string;\n density: string;\n densityCompact: string;\n densityAiry: string;\n /** The toolbar. */\n undo: string;\n redo: string;\n saved: string;\n saving: string;\n saveFailed: string;\n publish: string;\n discard: string;\n /** The preview. */\n preview: string;\n previewTitle: string;\n phone: string;\n desktop: string;\n viewPreview: string;\n closePreview: string;\n /** The publish dialog. */\n publishTitle: string;\n publishWhat: string;\n publishNothing: string;\n publishConfirm: string;\n cancel: string;\n problemsTitle: string;\n problemIn: string;\n /** The names. */\n sectionNames: Record<SectionType, string>;\n /** `type.variant` → « Poster ». */\n variantNames: Record<string, string>;\n blockNames: Record<string, string>;\n settingNames: Record<string, string>;\n optionNames: Record<string, string>;\n /** One line per kind of change, with `{name}` (the section) and `{from}` / `{to}` / `{n}`. */\n diff: Record<DiffEntry[\"kind\"], string>;\n};\n\n/** `fill(\"Moved to {n}\", { n: 2 })`. */\nexport const fill = (message: string, vars: Record<string, string | number>) => message.replace(/\\{(\\w+)\\}/g, (_, k: string) => String(vars[k] ?? `{${k}}`));\n\nconst sectionNames: Record<SectionType, string> = {\n hero: \"Hero\", services: \"Services\", booking: \"Booking\", gallery: \"Photos\", video: \"Video\", reviews: \"Reviews\", bulletin: \"News\",\n team: \"Team\", visit: \"Visit\", story: \"Story\", social: \"Social\", faq: \"Questions\", policies: \"Policies\",\n};\n\nconst variantNames: Record<string, string> = {\n \"hero.poster\": \"Poster\", \"hero.split\": \"Split\", \"hero.banner\": \"Banner\", \"hero.tv\": \"Television\",\n \"services.menu\": \"Menu\", \"services.cards\": \"Cards\", \"services.index\": \"Index cards\", \"services.carousel\": \"Carousel\",\n \"booking.strip\": \"Next times\", \"booking.panel\": \"Closing call\", \"booking.sticky\": \"Phone bar\",\n \"gallery.mosaic\": \"Mosaic\", \"gallery.filmstrip\": \"Filmstrip\", \"gallery.wall\": \"Wall\", \"gallery.grid\": \"Grid\",\n \"video.tv\": \"Television\", \"video.shorts\": \"Reels\",\n \"reviews.summary-cards\": \"Score and reviews\", \"reviews.quote\": \"One quote\", \"reviews.strip\": \"Score line\",\n \"bulletin.board\": \"Board\", \"bulletin.banner\": \"Banner line\",\n \"team.row\": \"Row\", \"team.cards\": \"Cards\",\n \"visit.card\": \"Card\", \"visit.map\": \"Map\", \"visit.split\": \"Hours and map\",\n \"story.quote\": \"Quote\", \"story.owner\": \"Owner\",\n \"social.links\": \"Links\", \"social.facade\": \"Latest reel\",\n \"faq.list\": \"List\", \"policies.inline\": \"Inline\",\n};\n\nexport const defaultShopComposerMessages: ShopComposerMessages = {\n title: \"Shop page\",\n sections: \"Sections\",\n addSection: \"Add a section\",\n addSectionHint: \"Choose what to add to your page.\",\n toggleVisible: \"Show {name}\",\n sectionMenu: \"Actions for {name}\",\n moveUp: \"Move up\",\n moveDown: \"Move down\",\n moveTop: \"Move to top\",\n remove: \"Remove\",\n announceMoved: \"{name} moved to position {n} of {total}\",\n announceCannotMove: \"{name} cannot move further\",\n announceAdded: \"{name} added at position {n}\",\n announceRemoved: \"{name} removed\",\n announceShown: \"{name} is shown\",\n announceHidden: \"{name} is hidden\",\n announceUndone: \"Undone\",\n announceRedone: \"Redone\",\n hiddenNote: \"hidden\",\n inspector: \"Section\",\n noSelection: \"Choose a section to change how it is drawn.\",\n backToSections: \"Back to sections\",\n variant: \"How it is drawn\",\n settings: \"Settings\",\n words: \"Your words\",\n titleField: \"Title\",\n leadField: \"Line under the title\",\n french: \"French\",\n english: \"English\",\n blocks: \"Items\",\n addBlock: \"Add\",\n removeBlock: \"Remove {name}\",\n look: \"Look\",\n lookChoice: \"Look of the page\",\n lookApplied: \"Look: {name}\",\n accentChoice: \"Accent\",\n accentNames: { krizaka: \"Krizaka blue\", akinaza: \"Akinaza green\", \"akinaza:accent-2\": \"Copper\", yomizaka: \"Indigo\", orazaka: \"Orange\" },\n preset: \"Style\",\n density: \"Spacing\",\n densityCompact: \"Compact\",\n densityAiry: \"Airy\",\n undo: \"Undo\",\n redo: \"Redo\",\n saved: \"Saved\",\n saving: \"Saving…\",\n saveFailed: \"Not saved\",\n publish: \"Publish\",\n discard: \"Discard the draft\",\n preview: \"Preview\",\n previewTitle: \"Live preview of your page\",\n phone: \"Phone\",\n desktop: \"Desktop\",\n viewPreview: \"View\",\n closePreview: \"Close\",\n publishTitle: \"Publish this page\",\n publishWhat: \"What changes\",\n publishNothing: \"Nothing has changed since the last publication.\",\n publishConfirm: \"Publish\",\n cancel: \"Cancel\",\n problemsTitle: \"Fix {n} problem before publishing\",\n problemIn: \"{name}\",\n sectionNames,\n variantNames,\n blockNames: { fact: \"Fact\", service: \"Service\", photo: \"Photo\", note: \"Note\", sign: \"Sign\", reel: \"Reel\", flyer: \"Flyer\", member: \"Member\", link: \"Link\", question: \"Question\" },\n settingNames: { media: \"Photo\", focus: \"Crop\", source: \"Source\", groupBy: \"Group by\", columns: \"Columns\", aside: \"Beside the list\", serviceId: \"Service\", count: \"How many\", texture: \"Wall\", cabinet: \"Cabinet\", channel: \"Channel\", rule: \"Which reviews\", showPhone: \"Show the phone number\", body: \"Text\", show: \"Show\" },\n optionNames: { center: \"Centre\", top: \"Top\", bottom: \"Bottom\", all: \"All\", pick: \"Pick\", category: \"Category\", none: \"None\", hours: \"Hours\", plaster: \"Plaster\", brick: \"Brick\", ridge: \"Ridge\", zellige: \"Zellige\", cabinet: \"Cabinet\", portable: \"Portable\", best: \"Best\", latest: \"Latest\", cancellation: \"Cancellation\", prices: \"Prices\", \"booking-window\": \"Booking window\" },\n diff: {\n added: \"{name} added\",\n removed: \"{name} removed\",\n moved: \"{name} moved from {from} to {to}\",\n variant: \"{name} drawn as {to} (was {from})\",\n settings: \"{name}: settings changed\",\n blocks: \"{name}: items changed\",\n text: \"{name}: words changed\",\n disabled: \"{name} hidden\",\n enabled: \"{name} shown\",\n preset: \"Style changed to {to} (was {from})\",\n density: \"Spacing changed to {to} (was {from})\",\n },\n};\n"
|
|
260
266
|
},
|
|
261
267
|
{
|
|
262
268
|
"path": "shop-composer/meta.ts",
|
|
263
|
-
"content": "import type { ComponentMeta } from \"../meta\";\n\nexport const meta = {\n title: \"Shop composer\",\n summary: \"Our own editor for a shop's page document (ADR-007): the outline of the sections, the live preview of the product's page and the inspector of the selected section — variant as live thumbnails, settings as a form generated from the zod schema, words, blocks — with undo and redo, a saved draft and a publish step that shows what changes. First consumer: Akinaza's studio (akinaza#402).\",\n status: \"beta\",\n category: \"blocks\",\n platforms: \"web\",\n parity: { native: { status: \"n/a\", reason: \"The composer is the studio of the web console; a shop's page is a web page.\", use: \"shop\" }, desktop: \"web\" },\n whenToUse: [\n \"The studio of a product whose public page is a `ShopPage` document: the owner chooses sections, their order and how each one is drawn, within a bounded catalogue.\",\n ],\n whenNotToUse: [\n { when: \"A free-form page builder with a canvas, nested columns and any component anywhere: the model here is a list of sections, deliberately.\", use: \"shop\" },\n { when: \"A single form of settings.\", use: \"form\" },\n ],\n bestPractices: [\n \"The product saves the draft in `onChange` (a valid document, after 800 ms of calm) and serves its own public route with `?draft=<id>` for the preview; the composer talks to it by `postMessage` (`connectShopPreview` in `@krizaka/ui/shop` is the page's half).\",\n \"Pass the presets of the shop's trade and the section types the trade does not use (`foldedTypes`): they are folded away, not removed.\",\n \"Pass translated `messages`; English is the default.\",\n \"Publish only what the composer hands to `onPublish`: it is parsed (`parseShopPage`) and the product parses it again on write.\",\n ],\n accessibility: {\n keyboard: [\n { keys: \"↑ ↓\", action: \"Moves between the rows of the outline.\" },\n { keys: \"Alt+↑ / Alt+↓\", action: \"Moves the focused section up or down; the move is announced and focus stays on its row.\" },\n { keys: \"Ctrl/⌘ Z, Shift+Ctrl/⌘ Z\", action: \"Undoes and redoes (100 steps), except inside a text field.\" },\n { keys: \"Enter, Space\", action: \"Selects a section, toggles its visibility, chooses a variant.\" },\n ],\n notes: [\n \"One polite live region says every move, addition, removal and undo; « Saved » is its own status.\",\n \"The preview `iframe` is titled; the variant picker is a radio group; an invalid setting is said next to its field and the publish dialog lists every problem and stays closed to confirmation until they are fixed.\",\n \"On a phone the composer has two steps (the list, then the section) and the preview behind a « View » button.\",\n ],\n },\n related: [\"shop\", \"form\", \"radio-group\", \"dialog\", \"dropdown-menu\", \"switch\"],\n web: {\n imports: [\"ShopComposer\", \"defaultShopComposerMessages\", \"applyCommand\", \"createHistory\", \"diffPages\", \"describeSettings\", \"SectionThumbnail\"],\n examples: [{ name: \"composer\", title: \"Composer\", description: \"The salon's compact page in the composer: outline, preview, inspector.\" }],\n },\n} satisfies ComponentMeta;\n"
|
|
269
|
+
"content": "import type { ComponentMeta } from \"../meta\";\n\nexport const meta = {\n title: \"Shop composer\",\n summary: \"Our own editor for a shop's page document (ADR-007): the outline of the sections, the live preview of the product's page and the inspector of the selected section — variant as live thumbnails, settings as a form generated from the zod schema, words, blocks — with undo and redo, a saved draft and a publish step that shows what changes. First consumer: Akinaza's studio (akinaza#402).\",\n status: \"beta\",\n category: \"blocks\",\n domain: \"commerce\",\n platforms: \"web\",\n parity: { native: { status: \"n/a\", reason: \"The composer is the studio of the web console; a shop's page is a web page.\", use: \"shop\" }, desktop: \"web\" },\n whenToUse: [\n \"The studio of a product whose public page is a `ShopPage` document: the owner chooses sections, their order and how each one is drawn, within a bounded catalogue.\",\n ],\n whenNotToUse: [\n { when: \"A free-form page builder with a canvas, nested columns and any component anywhere: the model here is a list of sections, deliberately.\", use: \"shop\" },\n { when: \"A single form of settings.\", use: \"form\" },\n ],\n bestPractices: [\n \"The product saves the draft in `onChange` (a valid document, after 800 ms of calm) and serves its own public route with `?draft=<id>` for the preview; the composer talks to it by `postMessage` (`connectShopPreview` in `@krizaka/ui/shop` is the page's half).\",\n \"Pass the presets of the shop's trade and the section types the trade does not use (`foldedTypes`): they are folded away, not removed.\",\n \"Pass translated `messages`; English is the default.\",\n \"Publish only what the composer hands to `onPublish`: it is parsed (`parseShopPage`) and the product parses it again on write.\",\n ],\n accessibility: {\n keyboard: [\n { keys: \"↑ ↓\", action: \"Moves between the rows of the outline.\" },\n { keys: \"Alt+↑ / Alt+↓\", action: \"Moves the focused section up or down; the move is announced and focus stays on its row.\" },\n { keys: \"Ctrl/⌘ Z, Shift+Ctrl/⌘ Z\", action: \"Undoes and redoes (100 steps), except inside a text field.\" },\n { keys: \"Enter, Space\", action: \"Selects a section, toggles its visibility, chooses a variant.\" },\n ],\n notes: [\n \"One polite live region says every move, addition, removal and undo; « Saved » is its own status.\",\n \"The preview `iframe` is titled; the variant picker is a radio group; an invalid setting is said next to its field and the publish dialog lists every problem and stays closed to confirmation until they are fixed.\",\n \"On a phone the composer has two steps (the list, then the section) and the preview behind a « View » button.\",\n ],\n },\n related: [\"shop\", \"form\", \"radio-group\", \"dialog\", \"dropdown-menu\", \"switch\"],\n web: {\n imports: [\"ShopComposer\", \"defaultShopComposerMessages\", \"applyCommand\", \"createHistory\", \"diffPages\", \"describeSettings\", \"SectionThumbnail\"],\n examples: [{ name: \"composer\", title: \"Composer\", description: \"The salon's compact page in the composer: outline, preview, inspector.\" }],\n },\n} satisfies ComponentMeta;\n"
|
|
264
270
|
},
|
|
265
271
|
{
|
|
266
272
|
"path": "shop-composer/outline.tsx",
|
|
@@ -347,7 +353,7 @@
|
|
|
347
353
|
{
|
|
348
354
|
"name": "messages",
|
|
349
355
|
"type": "ShopComposerMessages",
|
|
350
|
-
"default": "{\n title: \"Shop page\",\n sections: \"Sections\",\n addSection: \"Add a section\",\n addSectionHint: \"Choose what to add to your page.\",\n toggleVisible: \"Show {name}\",\n sectionMenu: \"Actions for {name}\",\n moveUp: \"Move up\",\n moveDown: \"Move down\",\n moveTop: \"Move to top\",\n remove: \"Remove\",\n announceMoved: \"{name} moved to position {n} of {total}\",\n announceCannotMove: \"{name} cannot move further\",\n announceAdded: \"{name} added at position {n}\",\n announceRemoved: \"{name} removed\",\n announceShown: \"{name} is shown\",\n announceHidden: \"{name} is hidden\",\n announceUndone: \"Undone\",\n announceRedone: \"Redone\",\n hiddenNote: \"hidden\",\n inspector: \"Section\",\n noSelection: \"Choose a section to change how it is drawn.\",\n backToSections: \"Back to sections\",\n variant: \"How it is drawn\",\n settings: \"Settings\",\n words: \"Your words\",\n titleField: \"Title\",\n leadField: \"Line under the title\",\n french: \"French\",\n english: \"English\",\n blocks: \"Items\",\n addBlock: \"Add\",\n removeBlock: \"Remove {name}\",\n look: \"Look\",\n preset: \"Style\",\n density: \"Spacing\",\n densityCompact: \"Compact\",\n densityAiry: \"Airy\",\n undo: \"Undo\",\n redo: \"Redo\",\n saved: \"Saved\",\n saving: \"Saving…\",\n saveFailed: \"Not saved\",\n publish: \"Publish\",\n discard: \"Discard the draft\",\n preview: \"Preview\",\n previewTitle: \"Live preview of your page\",\n phone: \"Phone\",\n desktop: \"Desktop\",\n viewPreview: \"View\",\n closePreview: \"Close\",\n publishTitle: \"Publish this page\",\n publishWhat: \"What changes\",\n publishNothing: \"Nothing has changed since the last publication.\",\n publishConfirm: \"Publish\",\n cancel: \"Cancel\",\n problemsTitle: \"Fix {n} problem before publishing\",\n problemIn: \"{name}\",\n sectionNames,\n variantNames,\n blockNames: { fact: \"Fact\", service: \"Service\", photo: \"Photo\", note: \"Note\", sign: \"Sign\", reel: \"Reel\", flyer: \"Flyer\", member: \"Member\", link: \"Link\", question: \"Question\" },\n settingNames: { media: \"Photo\", focus: \"Crop\", source: \"Source\", groupBy: \"Group by\", columns: \"Columns\", aside: \"Beside the list\", serviceId: \"Service\", count: \"How many\", texture: \"Wall\", cabinet: \"Cabinet\", channel: \"Channel\", rule: \"Which reviews\", showPhone: \"Show the phone number\", body: \"Text\", show: \"Show\" },\n optionNames: { center: \"Centre\", top: \"Top\", bottom: \"Bottom\", all: \"All\", pick: \"Pick\", category: \"Category\", none: \"None\", hours: \"Hours\", plaster: \"Plaster\", brick: \"Brick\", ridge: \"Ridge\", zellige: \"Zellige\", cabinet: \"Cabinet\", portable: \"Portable\", best: \"Best\", latest: \"Latest\", cancellation: \"Cancellation\", prices: \"Prices\", \"booking-window\": \"Booking window\" },\n diff: {\n added: \"{name} added\",\n removed: \"{name} removed\",\n moved: \"{name} moved from {from} to {to}\",\n variant: \"{name} drawn as {to} (was {from})\",\n settings: \"{name}: settings changed\",\n blocks: \"{name}: items changed\",\n text: \"{name}: words changed\",\n disabled: \"{name} hidden\",\n enabled: \"{name} shown\",\n preset: \"Style changed to {to} (was {from})\",\n density: \"Spacing changed to {to} (was {from})\",\n },\n}",
|
|
356
|
+
"default": "{\n title: \"Shop page\",\n sections: \"Sections\",\n addSection: \"Add a section\",\n addSectionHint: \"Choose what to add to your page.\",\n toggleVisible: \"Show {name}\",\n sectionMenu: \"Actions for {name}\",\n moveUp: \"Move up\",\n moveDown: \"Move down\",\n moveTop: \"Move to top\",\n remove: \"Remove\",\n announceMoved: \"{name} moved to position {n} of {total}\",\n announceCannotMove: \"{name} cannot move further\",\n announceAdded: \"{name} added at position {n}\",\n announceRemoved: \"{name} removed\",\n announceShown: \"{name} is shown\",\n announceHidden: \"{name} is hidden\",\n announceUndone: \"Undone\",\n announceRedone: \"Redone\",\n hiddenNote: \"hidden\",\n inspector: \"Section\",\n noSelection: \"Choose a section to change how it is drawn.\",\n backToSections: \"Back to sections\",\n variant: \"How it is drawn\",\n settings: \"Settings\",\n words: \"Your words\",\n titleField: \"Title\",\n leadField: \"Line under the title\",\n french: \"French\",\n english: \"English\",\n blocks: \"Items\",\n addBlock: \"Add\",\n removeBlock: \"Remove {name}\",\n look: \"Look\",\n lookChoice: \"Look of the page\",\n lookApplied: \"Look: {name}\",\n accentChoice: \"Accent\",\n accentNames: { krizaka: \"Krizaka blue\", akinaza: \"Akinaza green\", \"akinaza:accent-2\": \"Copper\", yomizaka: \"Indigo\", orazaka: \"Orange\" },\n preset: \"Style\",\n density: \"Spacing\",\n densityCompact: \"Compact\",\n densityAiry: \"Airy\",\n undo: \"Undo\",\n redo: \"Redo\",\n saved: \"Saved\",\n saving: \"Saving…\",\n saveFailed: \"Not saved\",\n publish: \"Publish\",\n discard: \"Discard the draft\",\n preview: \"Preview\",\n previewTitle: \"Live preview of your page\",\n phone: \"Phone\",\n desktop: \"Desktop\",\n viewPreview: \"View\",\n closePreview: \"Close\",\n publishTitle: \"Publish this page\",\n publishWhat: \"What changes\",\n publishNothing: \"Nothing has changed since the last publication.\",\n publishConfirm: \"Publish\",\n cancel: \"Cancel\",\n problemsTitle: \"Fix {n} problem before publishing\",\n problemIn: \"{name}\",\n sectionNames,\n variantNames,\n blockNames: { fact: \"Fact\", service: \"Service\", photo: \"Photo\", note: \"Note\", sign: \"Sign\", reel: \"Reel\", flyer: \"Flyer\", member: \"Member\", link: \"Link\", question: \"Question\" },\n settingNames: { media: \"Photo\", focus: \"Crop\", source: \"Source\", groupBy: \"Group by\", columns: \"Columns\", aside: \"Beside the list\", serviceId: \"Service\", count: \"How many\", texture: \"Wall\", cabinet: \"Cabinet\", channel: \"Channel\", rule: \"Which reviews\", showPhone: \"Show the phone number\", body: \"Text\", show: \"Show\" },\n optionNames: { center: \"Centre\", top: \"Top\", bottom: \"Bottom\", all: \"All\", pick: \"Pick\", category: \"Category\", none: \"None\", hours: \"Hours\", plaster: \"Plaster\", brick: \"Brick\", ridge: \"Ridge\", zellige: \"Zellige\", cabinet: \"Cabinet\", portable: \"Portable\", best: \"Best\", latest: \"Latest\", cancellation: \"Cancellation\", prices: \"Prices\", \"booking-window\": \"Booking window\" },\n diff: {\n added: \"{name} added\",\n removed: \"{name} removed\",\n moved: \"{name} moved from {from} to {to}\",\n variant: \"{name} drawn as {to} (was {from})\",\n settings: \"{name}: settings changed\",\n blocks: \"{name}: items changed\",\n text: \"{name}: words changed\",\n disabled: \"{name} hidden\",\n enabled: \"{name} shown\",\n preset: \"Style changed to {to} (was {from})\",\n density: \"Spacing changed to {to} (was {from})\",\n },\n}",
|
|
351
357
|
"description": "The words, translated. Default: English.",
|
|
352
358
|
"required": false
|
|
353
359
|
},
|