@krizaka/ui 4.4.0 → 4.5.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/README.md +1 -0
- package/dist/account-menu.d.ts +1 -1
- package/dist/account-menu.js +1 -1
- package/dist/account-menu.js.map +1 -1
- package/dist/account-settings.d.ts +1 -1
- package/dist/account-settings.js +13 -6
- package/dist/account-settings.js.map +1 -1
- package/dist/agenda.d.ts +1 -1
- package/dist/agenda.js +2 -1
- package/dist/agenda.js.map +1 -1
- package/dist/analysis-report.js +19 -11
- package/dist/analysis-report.js.map +1 -1
- package/dist/app-frame.d.ts +1 -1
- package/dist/app-frame.js.map +1 -1
- package/dist/app-header/search.js +2 -2
- package/dist/app-header/search.js.map +1 -1
- package/dist/avatar/defaults.js +3 -1
- package/dist/avatar/defaults.js.map +1 -1
- package/dist/avatar.js +3 -1
- package/dist/avatar.js.map +1 -1
- package/dist/bird-plate.js +8 -2
- package/dist/bird-plate.js.map +1 -1
- package/dist/chapter.js +7 -4
- package/dist/chapter.js.map +1 -1
- package/dist/chat.js +1 -1
- package/dist/chip.d.ts +1 -1
- package/dist/chip.js +1 -1
- package/dist/{chunk-SNSQLGGS.js → chunk-5VZ37TY3.js} +1 -1
- package/dist/{chunk-XWJDBQU7.js.map → chunk-5VZ37TY3.js.map} +1 -1
- package/dist/{chunk-MTVX4RRF.js → chunk-HP7BDMVK.js} +11 -3
- package/dist/chunk-HP7BDMVK.js.map +1 -0
- package/dist/{chunk-PK3L6WQT.js → chunk-LNAAWT4Y.js} +4 -2
- package/dist/{chunk-PK3L6WQT.js.map → chunk-LNAAWT4Y.js.map} +1 -1
- package/dist/{chunk-UIP3WX5O.js → chunk-MDSP7DJR.js} +2 -2
- package/dist/chunk-MDSP7DJR.js.map +1 -0
- package/dist/{chunk-IEGTRCDI.js → chunk-NQENOT6L.js} +2 -2
- package/dist/{chunk-IEGTRCDI.js.map → chunk-NQENOT6L.js.map} +1 -1
- package/dist/{chunk-FM42KOAU.js → chunk-P7AFIKWG.js} +5 -3
- package/dist/chunk-P7AFIKWG.js.map +1 -0
- package/dist/{chunk-BCD2CRFG.js → chunk-PJNR4NTS.js} +2 -2
- package/dist/chunk-PJNR4NTS.js.map +1 -0
- package/dist/{chunk-ZFR6ZNXD.js → chunk-PVQ2KKPZ.js} +1 -1
- package/dist/chunk-PVQ2KKPZ.js.map +1 -0
- package/dist/{chunk-U4XTZMB7.js → chunk-QA3WETWT.js} +1 -1
- package/dist/{chunk-U4XTZMB7.js.map → chunk-QA3WETWT.js.map} +1 -1
- package/dist/{chunk-YXETEQQJ.js → chunk-SG2RKUVJ.js} +2 -2
- package/dist/{chunk-EOWV6BNQ.js → chunk-TXFX4PMN.js} +4 -2
- package/dist/{chunk-EOWV6BNQ.js.map → chunk-TXFX4PMN.js.map} +1 -1
- package/dist/{chunk-XWJDBQU7.js → chunk-V5RO6JYI.js} +1 -1
- package/dist/{chunk-SNSQLGGS.js.map → chunk-V5RO6JYI.js.map} +1 -1
- package/dist/{chunk-VUD4IEVJ.js → chunk-VZ6ZALIJ.js} +1 -1
- package/dist/chunk-VZ6ZALIJ.js.map +1 -0
- package/dist/{chunk-2DHL7NJW.js → chunk-XVRKKYWU.js} +5 -3
- package/dist/{chunk-2DHL7NJW.js.map → chunk-XVRKKYWU.js.map} +1 -1
- package/dist/{chunk-CDNOT2KR.js → chunk-YTYNKMNS.js} +1 -1
- package/dist/chunk-YTYNKMNS.js.map +1 -0
- package/dist/code-block.js.map +1 -1
- package/dist/columns.d.ts +132 -0
- package/dist/columns.js +89 -0
- package/dist/columns.js.map +1 -0
- package/dist/combobox.js +2 -2
- package/dist/copy-button.js +2 -2
- package/dist/copy-button.js.map +1 -1
- package/dist/data-table.js +3 -3
- package/dist/desktop-window.d.ts +1 -1
- package/dist/desktop-window.js +3 -1
- package/dist/desktop-window.js.map +1 -1
- package/dist/drop-overlay.js +8 -8
- package/dist/drop-overlay.js.map +1 -1
- package/dist/elephant.d.ts +1 -1
- package/dist/elephant.js.map +1 -1
- package/dist/embed-facade.d.ts +1 -1
- package/dist/embed-facade.js +3 -1
- package/dist/embed-facade.js.map +1 -1
- package/dist/engine-flow.js +7 -2
- package/dist/engine-flow.js.map +1 -1
- package/dist/entity-header.js +9 -3
- package/dist/entity-header.js.map +1 -1
- package/dist/file-upload.d.ts +1 -1
- package/dist/file-upload.js.map +1 -1
- package/dist/filter-bar.d.ts +4 -4
- package/dist/filter-bar.js +2 -2
- package/dist/flock.js +9 -6
- package/dist/flock.js.map +1 -1
- package/dist/form.d.ts +3 -3
- package/dist/form.js.map +1 -1
- package/dist/genui.js +3 -3
- package/dist/glossary-term.d.ts +1 -1
- package/dist/glossary-term.js.map +1 -1
- package/dist/glossary.d.ts +1 -1
- package/dist/glossary.js.map +1 -1
- package/dist/identity-card.js +1 -1
- package/dist/index.js +1 -1
- package/dist/kind-config-editor.d.ts +2 -2
- package/dist/kind-config-editor.js +1 -1
- package/dist/kind-config-editor.js.map +1 -1
- package/dist/kpi-explained.d.ts +1 -1
- package/dist/kpi-explained.js +4 -4
- package/dist/kpi-explained.js.map +1 -1
- package/dist/landing-page.js +1 -1
- package/dist/{lightbox-Q45BZ3HW.js → lightbox-MRB2YZEP.js} +1 -1
- package/dist/lightbox-MRB2YZEP.js.map +1 -0
- package/dist/map/cards.js +4 -2
- package/dist/map/cards.js.map +1 -1
- package/dist/map/pin.js +2 -1
- package/dist/map/pin.js.map +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/map.js.map +1 -1
- package/dist/mascot-quote.js +1 -1
- package/dist/mascot-state.js +1 -1
- package/dist/mascots.js +1 -1
- package/dist/match-dialog.js +1 -1
- package/dist/motion.d.ts +1 -1
- package/dist/motion.js.map +1 -1
- package/dist/native/form.d.ts +3 -3
- package/dist/native/form.js.map +1 -1
- package/dist/native/markdown.d.ts +1 -1
- package/dist/native/markdown.js.map +1 -1
- package/dist/native/vertical-video.js.map +1 -1
- package/dist/native.d.ts +12 -12
- package/dist/native.js +12 -7
- package/dist/native.js.map +1 -1
- package/dist/nav-bar.d.ts +2 -2
- package/dist/nav-bar.js +1 -1
- package/dist/nav-bar.js.map +1 -1
- package/dist/next-actions.d.ts +1 -1
- package/dist/next-actions.js.map +1 -1
- package/dist/notification-preferences.d.ts +1 -1
- package/dist/notification-preferences.js +5 -2
- package/dist/notification-preferences.js.map +1 -1
- package/dist/page-index.js +2 -2
- package/dist/page-index.js.map +1 -1
- package/dist/product-page.js +1 -1
- package/dist/promo-code-field.d.ts +1 -1
- package/dist/promo-code-field.js.map +1 -1
- package/dist/qr-code.d.ts +1 -1
- package/dist/qr-code.js +1 -1
- package/dist/rail-nav.js +3 -3
- package/dist/rail-nav.js.map +1 -1
- package/dist/retro-tv.d.ts +1 -1
- package/dist/retro-tv.js.map +1 -1
- package/dist/reviews.d.ts +2 -2
- package/dist/reviews.js.map +1 -1
- package/dist/router.d.ts +1 -1
- package/dist/router.js +8 -8
- package/dist/router.js.map +1 -1
- package/dist/{schema-CL7t7xqb.d.ts → schema-Dd05m48Q.d.ts} +9 -9
- package/dist/service-card.js +22 -13
- package/dist/service-card.js.map +1 -1
- package/dist/settings-layout.js +1 -1
- package/dist/shop/booking.js.map +1 -1
- package/dist/shop/gallery.js +7 -6
- package/dist/shop/gallery.js.map +1 -1
- package/dist/shop/hero.js.map +1 -1
- package/dist/shop/look.d.ts +2 -2
- package/dist/shop/look.js +1 -1
- package/dist/shop/look.js.map +1 -1
- package/dist/shop/map-gate.d.ts +1 -1
- package/dist/shop/map-gate.js +2 -2
- package/dist/shop/map-gate.js.map +1 -1
- package/dist/shop/services.js.map +1 -1
- package/dist/shop-composer.d.ts +10 -10
- package/dist/shop-composer.js +27 -14
- package/dist/shop-composer.js.map +1 -1
- package/dist/shop-gallery.js +1 -1
- package/dist/shop.d.ts +2 -2
- package/dist/shop.js +2 -2
- package/dist/shop.js.map +1 -1
- package/dist/signature.js +2 -1
- package/dist/signature.js.map +1 -1
- package/dist/site-cahier.js +7 -3
- package/dist/site-cahier.js.map +1 -1
- package/dist/site-footer.js +6 -2
- package/dist/site-footer.js.map +1 -1
- package/dist/slot-picker.js +5 -2
- package/dist/slot-picker.js.map +1 -1
- package/dist/stat.js +1 -1
- package/dist/status-chip.d.ts +1 -1
- package/dist/status-chip.js.map +1 -1
- package/dist/tabs.js.map +1 -1
- package/dist/tag-input.js +2 -2
- package/dist/tag-selector.js +1 -1
- package/dist/text-style.js +4 -3
- package/dist/text-style.js.map +1 -1
- package/dist/usage.js +8 -3
- package/dist/usage.js.map +1 -1
- package/dist/versus-card.js +1 -1
- package/dist/versus-card.js.map +1 -1
- package/dist/vertical-video.js +1 -1
- package/dist/vertical-video.js.map +1 -1
- package/dist/virtual.d.ts +3 -3
- package/dist/wall.d.ts +4 -4
- package/dist/wall.js +1 -1
- package/dist/wall.js.map +1 -1
- package/package.json +20 -6
- package/registry/account-menu.json +2 -2
- package/registry/account-settings.json +3 -3
- package/registry/achievement.json +1 -1
- package/registry/action-bar.json +1 -1
- package/registry/activity-feed.json +1 -1
- package/registry/agenda.json +2 -2
- package/registry/alert.json +1 -1
- package/registry/analysis-report.json +3 -3
- package/registry/anatomy-plate.json +1 -1
- package/registry/app-frame.json +4 -4
- package/registry/app-header.json +2 -2
- package/registry/app-shell.json +1 -1
- package/registry/argument-card.json +1 -1
- package/registry/auth-layout.json +1 -1
- package/registry/avatar.json +2 -2
- package/registry/badge.json +3 -3
- package/registry/bird-plate.json +2 -2
- package/registry/button.json +1 -1
- package/registry/captcha.json +1 -1
- package/registry/card-grid.json +1 -1
- package/registry/card.json +1 -1
- package/registry/catalogue-page.json +1 -1
- package/registry/changelog-page.json +1 -1
- package/registry/chapter.json +2 -2
- package/registry/chat.json +1 -1
- package/registry/checkbox.json +1 -1
- package/registry/chip-link.json +1 -1
- package/registry/chip-row.json +1 -1
- package/registry/chip.json +2 -2
- package/registry/choice-grid.json +1 -1
- package/registry/code-block.json +1 -1
- package/registry/collection-switcher.json +1 -1
- package/registry/columns.json +319 -0
- package/registry/combobox.json +1 -1
- package/registry/command.json +1 -1
- package/registry/comparison-table.json +1 -1
- package/registry/component-page.json +1 -1
- package/registry/confirm-button.json +1 -1
- package/registry/contact-page.json +1 -1
- package/registry/continue-prompt.json +1 -1
- package/registry/copy-button.json +2 -2
- package/registry/countdown.json +1 -1
- package/registry/cover-hero.json +1 -1
- package/registry/cta-panel.json +1 -1
- package/registry/dashboard-layout.json +1 -1
- package/registry/data-table.json +2 -2
- package/registry/date-picker.json +1 -1
- package/registry/decision-list.json +1 -1
- package/registry/description-list.json +1 -1
- package/registry/desktop-window.json +2 -2
- package/registry/detail-layout.json +1 -1
- package/registry/dialog.json +1 -1
- package/registry/docs-article-page.json +1 -1
- package/registry/docs-hub-page.json +1 -1
- package/registry/docs-layout.json +1 -1
- package/registry/docs-nav.json +1 -1
- package/registry/document-viewer.json +1 -1
- package/registry/doodle.json +1 -1
- package/registry/drop-overlay.json +2 -2
- package/registry/dropdown-menu.json +1 -1
- package/registry/elephant.json +2 -2
- package/registry/embed-facade.json +3 -3
- package/registry/empty-state.json +1 -1
- package/registry/engine-flow.json +3 -3
- package/registry/entity-header.json +2 -2
- package/registry/environment-notice.json +1 -1
- package/registry/error-page.json +1 -1
- package/registry/examples/columns/columns.d.ts +4 -0
- package/registry/examples/columns/columns.js +21 -0
- package/registry/examples/columns/columns.tsx +18 -0
- package/registry/examples/columns/photos.d.ts +4 -0
- package/registry/examples/columns/photos.js +12 -0
- package/registry/examples/columns/photos.tsx +16 -0
- package/registry/examples/columns/stats.d.ts +4 -0
- package/registry/examples/columns/stats.js +20 -0
- package/registry/examples/columns/stats.tsx +22 -0
- package/registry/field.json +1 -1
- package/registry/file-upload.json +2 -2
- package/registry/filter-bar.json +2 -2
- package/registry/flock.json +3 -3
- package/registry/footnote.json +1 -1
- package/registry/force-update-screen.json +1 -1
- package/registry/form.json +8 -8
- package/registry/gallery-page.json +1 -1
- package/registry/genui.json +1 -1
- package/registry/glossary-term.json +2 -2
- package/registry/glossary.json +2 -2
- package/registry/glow-card.json +1 -1
- package/registry/goal-gauge.json +1 -1
- package/registry/grade-stamp.json +1 -1
- package/registry/grid.json +4 -3
- package/registry/identity-card.json +1 -1
- package/registry/image-cropper.json +1 -1
- package/registry/index.json +40 -9
- package/registry/kanban.json +1 -1
- package/registry/kbd.json +1 -1
- package/registry/kind-config-editor.json +2 -2
- package/registry/kpi-explained.json +2 -2
- package/registry/landing-page.json +1 -1
- package/registry/landscape.json +1 -1
- package/registry/language-switch.json +1 -1
- package/registry/legal-page.json +1 -1
- package/registry/link-card.json +1 -1
- package/registry/list.json +1 -1
- package/registry/loader.json +1 -1
- package/registry/longform-page.json +1 -1
- package/registry/maintenance-screen.json +1 -1
- package/registry/map.json +5 -5
- package/registry/margin-layout.json +1 -1
- package/registry/markdown.json +1 -1
- package/registry/marketing-layout.json +1 -1
- package/registry/mascot-quote.json +1 -1
- package/registry/mascot-state.json +2 -2
- package/registry/mascots.json +3 -3
- package/registry/match-dialog.json +1 -1
- package/registry/media-capture.json +1 -1
- package/registry/media-gallery.json +1 -1
- package/registry/meter.json +1 -1
- package/registry/money-input.json +1 -1
- package/registry/nav-bar.json +5 -5
- package/registry/next-actions.json +2 -2
- package/registry/notification-preferences.json +2 -2
- package/registry/number-ticker.json +1 -1
- package/registry/opening-hours.json +1 -1
- package/registry/page-header.json +1 -1
- package/registry/page-hero.json +1 -1
- package/registry/page-index.json +2 -2
- package/registry/page.json +2 -2
- package/registry/pagination.json +1 -1
- package/registry/pointer-light.json +1 -1
- package/registry/popover.json +1 -1
- package/registry/price-catalogue-editor.json +1 -1
- package/registry/pricing-page.json +1 -1
- package/registry/product-page.json +1 -1
- package/registry/profile-card.json +1 -1
- package/registry/progress.json +1 -1
- package/registry/promise-card.json +1 -1
- package/registry/promo-code-field.json +2 -2
- package/registry/proposal.json +1 -1
- package/registry/qr-code.json +3 -3
- package/registry/quota-meter.json +1 -1
- package/registry/radio-group.json +1 -1
- package/registry/rail-nav.json +4 -4
- package/registry/recipes.json +1 -1
- package/registry/retro-tv.json +2 -2
- package/registry/reviews.json +2 -2
- package/registry/router.json +2 -2
- package/registry/schema-form.json +1 -1
- package/registry/scroll-stage.json +1 -1
- package/registry/search-field.json +1 -1
- package/registry/section-backdrop.json +1 -1
- package/registry/separator.json +1 -1
- package/registry/service-card.json +2 -2
- package/registry/settings-layout.json +2 -2
- package/registry/shop-composer.json +8 -8
- package/registry/shop-gallery.json +2 -2
- package/registry/shop.json +12 -12
- package/registry/showcase.json +1 -1
- package/registry/signature.json +2 -2
- package/registry/site-cahier.json +2 -2
- package/registry/site-footer.json +4 -4
- package/registry/sites.json +1 -1
- package/registry/skeleton.json +1 -1
- package/registry/skip-link.json +1 -1
- package/registry/slider.json +1 -1
- package/registry/slot-picker.json +2 -2
- package/registry/slot.json +1 -1
- package/registry/specimen-tag.json +1 -1
- package/registry/speed-lines.json +1 -1
- package/registry/spinner.json +1 -1
- package/registry/split-view.json +1 -1
- package/registry/stage-banner.json +1 -1
- package/registry/stat.json +2 -2
- package/registry/status-chip.json +2 -2
- package/registry/status-page.json +1 -1
- package/registry/step-progress.json +1 -1
- package/registry/step-showcase.json +1 -1
- package/registry/stepper.json +1 -1
- package/registry/sticky-action.json +1 -1
- package/registry/stuck.json +1 -1
- package/registry/swipe-deck.json +1 -1
- package/registry/switch.json +1 -1
- package/registry/tabs.json +2 -2
- package/registry/tag-input.json +1 -1
- package/registry/tag-selector.json +1 -1
- package/registry/taped-photo.json +1 -1
- package/registry/terminal-replay.json +1 -1
- package/registry/text-style.json +2 -2
- package/registry/theme.json +1 -1
- package/registry/toast.json +1 -1
- package/registry/toc.json +1 -1
- package/registry/tooltip.json +1 -1
- package/registry/tree-view.json +1 -1
- package/registry/update-prompt.json +1 -1
- package/registry/upload-queue.json +1 -1
- package/registry/usage.json +3 -3
- package/registry/verified-badge.json +1 -1
- package/registry/versus-card.json +2 -2
- package/registry/vertical-video.json +2 -2
- package/registry/video-player.json +1 -1
- package/registry/video-trimmer.json +1 -1
- package/registry/virtual.json +1 -1
- package/registry/wall.json +6 -6
- package/registry/waveform.json +3 -3
- package/dist/chunk-BCD2CRFG.js.map +0 -1
- package/dist/chunk-CDNOT2KR.js.map +0 -1
- package/dist/chunk-FM42KOAU.js.map +0 -1
- package/dist/chunk-MTVX4RRF.js.map +0 -1
- package/dist/chunk-UIP3WX5O.js.map +0 -1
- package/dist/chunk-VUD4IEVJ.js.map +0 -1
- package/dist/chunk-ZFR6ZNXD.js.map +0 -1
- package/dist/lightbox-Q45BZ3HW.js.map +0 -1
- /package/dist/{chunk-YXETEQQJ.js.map → chunk-SG2RKUVJ.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/app-shell/shortcuts.ts","../src/desktop-window/commands.ts","../src/desktop-window/desktop-window.tsx","../src/desktop-window/panes.ts"],"sourcesContent":["// Keyboard shortcuts for an application: a combination (`mod+k`, `shift+/`, `alt+arrowup`) or a sequence (`g d`: press G,\n// then D). `mod` is ⌘ on Apple devices and Ctrl elsewhere. Plain keys and sequences stay out of text fields; a combination\n// with `mod` works in an input (not in a rich-text editor, where ⌘B is bold). Nothing is decided here about the words.\nimport * as React from \"react\";\n\nimport { useLatest } from \"../media\";\n\nexport type ShortcutMap = Readonly<Record<string, ((event: KeyboardEvent) => void) | undefined>>;\n\nconst isApple = () => typeof navigator !== \"undefined\" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);\n\nconst ALIASES: Record<string, string> = { esc: \"escape\", return: \"enter\", space: \" \", spacebar: \" \", up: \"arrowup\", down: \"arrowdown\", left: \"arrowleft\", right: \"arrowright\", del: \"delete\", plus: \"+\" };\ntype Modifier = \"mod\" | \"ctrl\" | \"alt\" | \"shift\" | \"meta\";\n\ntype Combo = { key: string; mod: boolean; ctrl: boolean; alt: boolean; shift: boolean; meta: boolean };\n\n/** `\"mod+shift+k\"` → its parts. A lone `+` key is written `plus`. */\nexport function parseCombo(combo: string): Combo {\n const parts = combo.toLowerCase().split(\"+\").filter(Boolean);\n const key = ALIASES[parts.at(-1) ?? \"\"] ?? parts.at(-1) ?? \"\";\n const has = (name: Modifier) => parts.slice(0, -1).includes(name);\n return { key, mod: has(\"mod\"), ctrl: has(\"ctrl\"), alt: has(\"alt\"), shift: has(\"shift\"), meta: has(\"meta\") };\n}\n\n/** Whether a key event is this combination: its modifiers exactly (`mod` is ⌘ or Ctrl by platform), then its key. */\nexport function matchesCombo(event: Pick<KeyboardEvent, \"key\" | \"metaKey\" | \"ctrlKey\" | \"altKey\" | \"shiftKey\">, combo: string, apple = isApple()): boolean {\n const want = parseCombo(combo);\n const meta = want.meta || (want.mod && apple);\n const ctrl = want.ctrl || (want.mod && !apple);\n if (event.metaKey !== meta || event.ctrlKey !== ctrl || event.altKey !== want.alt) return false;\n // Shift is only checked when the binding names it: `?` and `/` need it on most layouts.\n if (want.shift && !event.shiftKey) return false;\n return event.key.toLowerCase() === want.key;\n}\n\n/** The keys of a shortcut to show on a keycap: `[\"⌘\", \"K\"]` on a Mac, `[\"Ctrl\", \"K\"]` elsewhere; a sequence `g d` is `[\"G\", \"D\"]`. */\nexport function formatShortcut(shortcut: string, apple = isApple()): string[] {\n if (shortcut.includes(\" \")) return shortcut.split(/\\s+/).map((key) => key.toUpperCase());\n const parts = shortcut.split(\"+\").filter(Boolean);\n const key = parts.at(-1) ?? \"\";\n const names: Record<string, [string, string]> = { mod: [\"⌘\", \"Ctrl\"], meta: [\"⌘\", \"Win\"], ctrl: [\"⌃\", \"Ctrl\"], alt: [\"⌥\", \"Alt\"], shift: [\"⇧\", \"Shift\"] };\n const shown = parts.slice(0, -1).map((part) => names[part.toLowerCase()]?.[apple ? 0 : 1] ?? part);\n const glyph: Record<string, string> = { escape: \"Esc\", enter: \"↵\", arrowup: \"↑\", arrowdown: \"↓\", arrowleft: \"←\", arrowright: \"→\", \" \": \"Space\" };\n const last = glyph[ALIASES[key.toLowerCase()] ?? key.toLowerCase()] ?? key.toUpperCase();\n return [...shown, last];\n}\n\n/**\n * The accelerator of a combination for a desktop app's native menu bar (Tauri's `MenuItem`, Electron's — ADR-002):\n * `mod+k` → `CmdOrCtrl+K`, `shift+mod+/` → `Shift+CmdOrCtrl+/`. The menu and the shell then answer the same keys, and the\n * menu shows them. A sequence (`g d`) has none: a menu item takes one chord.\n */\nexport function acceleratorOf(shortcut: string): string | undefined {\n if (shortcut.trim().includes(\" \")) return undefined;\n const parts = shortcut.split(\"+\").filter(Boolean);\n const names: Record<string, string> = { mod: \"CmdOrCtrl\", meta: \"Super\", ctrl: \"Ctrl\", alt: \"Alt\", shift: \"Shift\" };\n const raw = (parts.at(-1) ?? \"\").toLowerCase();\n const key = ALIASES[raw] ?? raw;\n const keys: Record<string, string> = { escape: \"Escape\", enter: \"Enter\", \" \": \"Space\", arrowup: \"Up\", arrowdown: \"Down\", arrowleft: \"Left\", arrowright: \"Right\", delete: \"Delete\", backspace: \"Backspace\", tab: \"Tab\", \"+\": \"Plus\" };\n const last = keys[key] ?? (key.length === 1 ? key.toUpperCase() : key.charAt(0).toUpperCase() + key.slice(1));\n return [...parts.slice(0, -1).map((part) => names[part.toLowerCase()] ?? part), last].join(\"+\");\n}\n\nconst noop = () => () => undefined;\n\n/** Whether the person is on an Apple device — `false` on the server and in the first client render (no mismatch), then right. */\nexport function useApple(): boolean {\n return React.useSyncExternalStore(noop, isApple, () => false);\n}\n\n/** The `aria-keyshortcuts` of a combination (`Control+K`, `Meta+K` on a Mac); a sequence has none (it is not a chord). */\nexport function ariaKeyShortcuts(shortcut: string, apple = isApple()): string | undefined {\n if (shortcut.includes(\" \")) return undefined;\n const parts = shortcut.split(\"+\").filter(Boolean);\n const names: Record<string, string> = { mod: apple ? \"Meta\" : \"Control\", meta: \"Meta\", ctrl: \"Control\", alt: \"Alt\", shift: \"Shift\" };\n const key = parts.at(-1) ?? \"\";\n return [...parts.slice(0, -1).map((part) => names[part.toLowerCase()] ?? part), key.length === 1 ? key.toUpperCase() : key.charAt(0).toUpperCase() + key.slice(1)].join(\"+\");\n}\n\n/** Whether a key press happens in something you type in. */\nfunction isEditable(target: EventTarget | null): { field: boolean; rich: boolean } {\n const element = target instanceof HTMLElement ? target : null;\n if (!element) return { field: false, rich: false };\n const rich = element.isContentEditable;\n return { field: rich || /^(input|textarea|select)$/i.test(element.tagName), rich };\n}\n\n/**\n * Binds shortcuts for as long as the component lives (`enabled` turns them off). Each key is a combination or a sequence,\n * each value runs when it is pressed; the handler may change on every render. A shortcut that fires is `preventDefault`ed.\n * A sequence waits `timeout` ms for its next key.\n */\nexport function useShortcuts(map: ShortcutMap, { enabled = true, timeout = 900 }: { enabled?: boolean; timeout?: number } = {}) {\n const latest = useLatest(map);\n const names = Object.keys(map).sort((a, b) => a.localeCompare(b)).join(\"\\n\");\n React.useEffect(() => {\n if (!enabled) return;\n const bindings = names.split(\"\\n\").filter(Boolean);\n let buffer: { key: string; at: number }[] = [];\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.defaultPrevented || event.isComposing || event.repeat || !event.key) return;\n const editing = isEditable(event.target);\n const chord = event.metaKey || event.ctrlKey || event.altKey;\n const now = Date.now();\n buffer = [...buffer.filter((entry) => now - entry.at <= timeout), { key: event.key.toLowerCase(), at: now }].slice(-4);\n for (const binding of bindings) {\n const handler = latest.current[binding];\n if (!handler) continue;\n const keys = binding.toLowerCase().split(/\\s+/).map((key) => ALIASES[key] ?? key);\n const fired =\n keys.length > 1\n ? !chord && !editing.field && buffer.length >= keys.length && keys.every((key, i) => buffer[buffer.length - keys.length + i]?.key === key)\n : matchesCombo(event, binding) && (chord ? !editing.rich : !editing.field);\n if (!fired) continue;\n event.preventDefault();\n buffer = [];\n handler(event);\n return;\n }\n };\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [enabled, names, latest, timeout]);\n}\n","// Pure: the commands of a desktop window, written once and read by three things — the native menu bar (through\n// `setNativeMenu` of @krizaka/app-desktop), the in-page shortcuts (`useShortcuts`, also the browser's), and the palette.\nimport { acceleratorOf } from \"../app-shell/shortcuts\";\n\nexport interface DesktopCommand {\n /** Sent back by the menu when chosen: lowercase letters, digits, `.` and `-` (`view.sidebar`). */\n id: string;\n /** The menu item's words, passed translated (`Hide sidebar`). */\n label: string;\n /** The menu it belongs to (`View`, `File`), passed translated: the product's menus sit between Edit and Window. */\n menu: string;\n /** A chord (`mod+b`): the menu shows it and the page answers it. A sequence (`g d`) is the page's only. */\n shortcut?: string;\n /** Runs the command. */\n run: () => void;\n /** A separator before it in its menu. */\n separated?: boolean;\n /** Dimmed in the menu while false (default true). */\n enabled?: boolean;\n}\n\n/** The shape `setNativeMenu` takes for its `menus` (structurally the same as `MenuSpec[\"menus\"]` of @krizaka/app-desktop). */\nexport interface DesktopMenu {\n title: string;\n items: { id: string; label: string; accelerator?: string; enabled?: boolean; separated?: boolean }[];\n}\n\nconst ID = /^[a-z0-9][a-z0-9.-]*$/;\n\nexport interface DesktopMenus {\n /** For `setNativeMenu(bridge, { labels, menus }, handlers)`. */\n menus: DesktopMenu[];\n /** For its `handlers`: the id of the chosen item → what it does. */\n handlers: Record<string, () => void>;\n /** For `useShortcuts`: the chords of the commands, answered in the page. */\n shortcuts: Record<string, () => void>;\n}\n\n/** Refuses an id the native side would refuse, or one already declared. */\nfunction checkId(out: DesktopMenus, id: string): void {\n if (!ID.test(id)) throw new Error(`desktopMenus: \"${id}\" is not a menu id (lowercase letters, digits, \".\" and \"-\").`);\n if (out.handlers[id]) throw new Error(`desktopMenus: \"${id}\" is declared twice.`);\n}\n\n/** Records the chord of a command for the page, refusing one given to two commands. */\nfunction addShortcut(out: DesktopMenus, shortcut: string, run: () => void): void {\n const key = shortcut.toLowerCase();\n if (out.shortcuts[key]) throw new Error(`desktopMenus: \"${shortcut}\" is the shortcut of two commands.`);\n out.shortcuts[key] = run;\n}\n\n/** The menu item of a command: its accelerator, and only the flags it sets. */\nfunction itemOf(command: DesktopCommand): DesktopMenu[\"items\"][number] {\n const accelerator = command.shortcut ? acceleratorOf(command.shortcut) : undefined;\n return {\n id: command.id,\n label: command.label,\n ...(accelerator ? { accelerator } : {}),\n ...(command.enabled === false ? { enabled: false } : {}),\n ...(command.separated ? { separated: true } : {}),\n };\n}\n\n/** Turns the commands into the menu bar's menus, its handlers and the page's shortcuts — one source for the three. Throws on a bad or repeated id, or a shortcut given twice. */\nexport function desktopMenus(commands: readonly DesktopCommand[]): DesktopMenus {\n const out: DesktopMenus = { menus: [], handlers: {}, shortcuts: {} };\n for (const command of commands) {\n checkId(out, command.id);\n out.handlers[command.id] = command.run;\n if (command.shortcut) addShortcut(out, command.shortcut, command.run);\n let menu = out.menus.find((m) => m.title === command.menu);\n if (!menu) out.menus.push((menu = { title: command.menu, items: [] }));\n menu.items.push(itemOf(command));\n }\n return out;\n}\n","// Client (the panes' sizes, the pointer, the shortcuts). The window of a Mac app (Tauri 2 on the system WebView, ADR-002):\n// a sidebar, the content and an inspector in a three-pane split — resizable by pointer and keyboard, collapsible — under a\n// toolbar that moves the window and clears the traffic lights, at the desktop's density with a native-feeling focus ring.\n// The commands (`desktopMenus`) are written once for the native menu bar, the page's shortcuts and the palette.\nimport { type ShortcutMap, useShortcuts } from \"@krizaka/ui/app-shell\";\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { type DesktopCommand, type DesktopMenus, desktopMenus } from \"./commands\";\nimport { clamp, dragged, keyed, paneMax } from \"./panes\";\n\nexport const desktopWindow = tv({\n slots: {\n root:\n \"kz-desktop-window flex h-[var(--kz-window-height,100dvh)] min-w-0 select-none overflow-hidden bg-surface-0 text-[13px] text-fg \" +\n // The macOS focus ring: a 3 px halo of the accent, over a 1 px accent edge, only for the keyboard.\n \"[&_:focus-visible]:outline-hidden [&_:focus-visible]:ring-[3px]! [&_:focus-visible]:ring-ring/50! [&_:focus-visible]:ring-offset-0!\",\n pane: \"relative flex min-h-0 shrink-0 flex-col overflow-hidden data-[collapsed]:hidden\",\n sidebar: \"border-e border-border-subtle bg-surface-1\",\n titlebar: \"h-[var(--kz-titlebar-inset,1.75rem)] shrink-0\",\n scroll: \"min-h-0 flex-1 overflow-y-auto\",\n middle: \"flex min-h-0 min-w-0 flex-1 flex-col\",\n inspector: \"border-s border-border-subtle bg-surface-1\",\n separator:\n \"group/sep relative z-10 -mx-[3px] w-[6px] shrink-0 cursor-col-resize touch-none data-[collapsed]:hidden \" +\n \"after:absolute after:inset-y-0 after:left-[2px] after:w-px after:bg-transparent hover:after:bg-border-strong data-[active]:after:bg-accent focus-visible:after:bg-accent\",\n content: \"min-h-0 min-w-0 flex-1 overflow-y-auto select-text\",\n toolbar:\n \"flex h-[var(--kz-toolbar-height,3rem)] shrink-0 items-center gap-2 border-b border-border-subtle bg-surface-0 px-3 \" +\n // With the sidebar folded the traffic lights sit over the toolbar: its first control starts after them.\n \"[[data-sidebar=closed]_&]:ps-[var(--kz-traffic-lights-inset,4.75rem)]\",\n toolbarTitle: \"min-w-0 flex-1 truncate text-[13px] font-semibold\",\n toolbarGroup: \"flex shrink-0 items-center gap-1\",\n toggle:\n \"inline-flex h-7 w-7 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-surface-2 hover:text-fg cursor-default aria-pressed:text-fg-accent\",\n },\n});\nconst s = desktopWindow();\n\nexport interface DesktopWindowLabels {\n /** The sidebar's accessible name (`Library`). */\n sidebar: string;\n /** The inspector's accessible name (`Details`). */\n inspector: string;\n /** The separators' names (`Resize the sidebar`, `Resize the inspector`). */\n resizeSidebar: string;\n resizeInspector: string;\n /** The toolbar buttons that fold the panes (`Show or hide the sidebar`). */\n toggleSidebar: string;\n toggleInspector: string;\n}\n\nexport interface DesktopWindowProps {\n /** The sidebar's content: a list of places, a `Tree`. It scrolls by itself. */\n sidebar: React.ReactNode;\n /** The main content under the toolbar. */\n children: React.ReactNode;\n /** The inspector's content: the selected item's details. Without it, a two-pane window. */\n inspector?: React.ReactNode;\n /** The toolbar's title, centred in the drag region. */\n title?: React.ReactNode;\n /** After the sidebar's toggle, at the start of the toolbar (back, forward). */\n toolbarStart?: React.ReactNode;\n /** Before the inspector's toggle, at the end of the toolbar (actions, search). */\n toolbarEnd?: React.ReactNode;\n /** The words of the panes, the dividers and the toggles — passed translated. */\n labels: DesktopWindowLabels;\n /** The sidebar is open (controlled). Pair with `onSidebarOpenChange`: the menu bar's command toggles it too. */\n sidebarOpen?: boolean;\n /** The sidebar starts open (default true) when uncontrolled. */\n defaultSidebarOpen?: boolean;\n /** Called when the sidebar folds or unfolds (the toolbar, a divider, the shortcut). */\n onSidebarOpenChange?: (open: boolean) => void;\n /** The inspector is open (controlled). */\n inspectorOpen?: boolean;\n /** The inspector starts open (default true) when uncontrolled. */\n defaultInspectorOpen?: boolean;\n /** Called when the inspector folds or unfolds. */\n onInspectorOpenChange?: (open: boolean) => void;\n /** The sizes in px: the sidebar's, the inspector's. Persist them with `onSizesChange`. */\n defaultSizes?: { sidebar?: number; inspector?: number };\n /** Called with the sizes in px after a drag or a key: persist them. */\n onSizesChange?: (sizes: { sidebar: number; inspector: number }) => void;\n /** The least the content keeps when the window is narrow (default 360). */\n contentMin?: number;\n /** The keys that fold the panes (a chord, or `false` for none): ⌘B and ⌘I by default. Pass `false` when the menu bar's commands (`useDesktopCommands`) own them. */\n shortcuts?: { sidebar?: string | false; inspector?: string | false };\n /** Classes for the window (`[--kz-window-height:34rem]` to size it inside a page). */\n className?: string;\n}\n\nconst SIDEBAR: { min: number; max: number } = { min: 180, max: 360 };\nconst INSPECTOR: { min: number; max: number } = { min: 240, max: 480 };\n\nconst glyph = (d: string) => (\n <svg viewBox=\"0 0 24 24\" className=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d={d} />\n </svg>\n);\n\nfunction useOpen(controlled: boolean | undefined, initial: boolean, onChange?: (open: boolean) => void) {\n const [own, setOwn] = React.useState(initial);\n const open = controlled ?? own;\n const set = React.useCallback(\n (next: boolean) => {\n if (controlled === undefined) setOwn(next);\n onChange?.(next);\n },\n [controlled, onChange],\n );\n return [open, set] as const;\n}\n\ntype Edge = \"sidebar\" | \"inspector\";\n\n/** The window of a Mac app: sidebar · content · inspector, a toolbar that moves the window, the desktop's density. */\nexport function DesktopWindow({\n sidebar, children, inspector, title, toolbarStart, toolbarEnd, labels, sidebarOpen, defaultSidebarOpen = true, onSidebarOpenChange, inspectorOpen, defaultInspectorOpen = true, onInspectorOpenChange, defaultSizes, onSizesChange, contentMin = 360, shortcuts, className,\n}: DesktopWindowProps) {\n const [sideOpen, setSideOpen] = useOpen(sidebarOpen, defaultSidebarOpen, onSidebarOpenChange);\n const [inspOpen, setInspOpen] = useOpen(inspectorOpen, defaultInspectorOpen, onInspectorOpenChange);\n const [sizes, setSizes] = React.useState({ sidebar: clamp(defaultSizes?.sidebar ?? 240, SIDEBAR.min, SIDEBAR.max), inspector: clamp(defaultSizes?.inspector ?? 300, INSPECTOR.min, INSPECTOR.max) });\n const [active, setActive] = React.useState<Edge | null>(null);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n const toggles = React.useRef<Record<Edge, HTMLButtonElement | null>>({ sidebar: null, inspector: null });\n const sidebarId = React.useId();\n const inspectorId = React.useId();\n const hasInspector = inspector != null;\n const sideShown = sideOpen;\n const inspShown = hasInspector && inspOpen;\n\n const keys = { sidebar: shortcuts?.sidebar === undefined ? \"mod+b\" : shortcuts.sidebar, inspector: shortcuts?.inspector === undefined ? \"mod+i\" : shortcuts.inspector };\n const map: Record<string, () => void> = {};\n if (keys.sidebar) map[keys.sidebar] = () => setSideOpen(!sideOpen);\n if (keys.inspector && hasInspector) map[keys.inspector] = () => setInspOpen(!inspOpen);\n useShortcuts(map as ShortcutMap);\n\n const commit = (edge: Edge, size: number) => {\n const next = { ...sizes, [edge]: size };\n setSizes(next);\n onSizesChange?.(next);\n };\n // The window's width, to keep the content its room: measured, and followed while the window is resized.\n React.useLayoutEffect(() => {\n const element = root.current;\n if (!element) return;\n const measure = () => setWidth(element.getBoundingClientRect().width);\n measure();\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, []);\n const ceiling = (edge: Edge) => {\n const other = edge === \"sidebar\" ? (inspShown ? sizes.inspector : 0) : sideShown ? sizes.sidebar : 0;\n const limits = edge === \"sidebar\" ? SIDEBAR : INSPECTOR;\n // The separators overlap the panes (negative margins): they take no width of their own.\n return paneMax(limits, width || Number.POSITIVE_INFINITY, other, contentMin, 0);\n };\n const direction = (): 1 | -1 => (root.current && getComputedStyle(root.current).direction === \"rtl\" ? -1 : 1);\n const sideOf = (edge: Edge): 1 | -1 => (edge === \"sidebar\" ? 1 : -1);\n const limitsOf = (edge: Edge) => (edge === \"sidebar\" ? SIDEBAR : INSPECTOR);\n\n const onPointerDown = (edge: Edge) => (event: React.PointerEvent<HTMLDivElement>) => {\n if (event.button !== 0) return;\n event.currentTarget.setPointerCapture(event.pointerId);\n const startX = event.clientX;\n const start = sizes[edge];\n const max = ceiling(edge);\n const dir = direction();\n setActive(edge);\n const target = event.currentTarget;\n const move = (e: PointerEvent) => commit(edge, dragged(start, e.clientX - startX, dir, sideOf(edge), limitsOf(edge), max));\n const stop = () => {\n setActive(null);\n target.removeEventListener(\"pointermove\", move);\n target.removeEventListener(\"pointerup\", stop);\n target.removeEventListener(\"pointercancel\", stop);\n };\n target.addEventListener(\"pointermove\", move);\n target.addEventListener(\"pointerup\", stop);\n target.addEventListener(\"pointercancel\", stop);\n };\n const onKeyDown = (edge: Edge) => (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n (edge === \"sidebar\" ? setSideOpen : setInspOpen)(false);\n // The separator goes with the pane: the focus goes to the button that brings it back.\n queueMicrotask(() => toggles.current[edge]?.focus());\n return;\n }\n const next = keyed(event.key, sizes[edge], direction(), sideOf(edge), limitsOf(edge), event.shiftKey, ceiling(edge));\n if (next === null) return;\n event.preventDefault();\n commit(edge, next);\n };\n\n const separator = (edge: Edge, controls: string, label: string) => (\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-controls={controls}\n aria-valuemin={limitsOf(edge).min}\n aria-valuemax={ceiling(edge)}\n aria-valuenow={sizes[edge]}\n tabIndex={0}\n data-edge={edge}\n data-active={active === edge ? \"\" : undefined}\n className={s.separator()}\n onPointerDown={onPointerDown(edge)}\n onKeyDown={onKeyDown(edge)}\n onDoubleClick={() => (edge === \"sidebar\" ? setSideOpen(false) : setInspOpen(false))}\n />\n );\n const toggle = (edge: Edge, label: string, pressed: boolean, onClick: () => void, d: string) => (\n <button type=\"button\" ref={(el) => { toggles.current[edge] = el; }} className={s.toggle()} aria-label={label} aria-pressed={pressed} onClick={onClick}>\n {glyph(d)}\n </button>\n );\n\n return (\n <div ref={root} data-desktop=\"\" data-sidebar={sideShown ? \"open\" : \"closed\"} className={s.root({ className })}>\n <aside id={sidebarId} aria-label={labels.sidebar} data-collapsed={sideShown ? undefined : \"\"} className={s.pane({ className: s.sidebar() })} style={{ width: sizes.sidebar }}>\n <div aria-hidden data-tauri-drag-region=\"\" className={s.titlebar()} />\n <div className={s.scroll()}>{sidebar}</div>\n </aside>\n {sideShown && separator(\"sidebar\", sidebarId, labels.resizeSidebar)}\n <div className={s.middle()}>\n <header data-tauri-drag-region=\"\" className={s.toolbar()}>\n <div className={s.toolbarGroup()}>\n {toggle(\"sidebar\", labels.toggleSidebar, sideShown, () => setSideOpen(!sideOpen), \"M4 5h16v14H4zM9 5v14\")}\n {toolbarStart}\n </div>\n <div data-tauri-drag-region=\"\" className={s.toolbarTitle()}>\n {title}\n </div>\n <div className={s.toolbarGroup()}>\n {toolbarEnd}\n {hasInspector && toggle(\"inspector\", labels.toggleInspector, inspShown, () => setInspOpen(!inspOpen), \"M4 5h16v14H4zM15 5v14\")}\n </div>\n </header>\n <main id=\"content\" tabIndex={-1} className={s.content()}>\n {children}\n </main>\n </div>\n {inspShown && separator(\"inspector\", inspectorId, labels.resizeInspector)}\n {hasInspector && (\n <aside id={inspectorId} aria-label={labels.inspector} data-collapsed={inspShown ? undefined : \"\"} className={s.pane({ className: s.inspector() })} style={{ width: sizes.inspector }}>\n <div className={s.scroll()}>{inspector}</div>\n </aside>\n )}\n </div>\n );\n}\n\n/**\n * The window's commands as one source: registers their chords in the page (`useShortcuts`, the browser's too) and returns\n * the native menu bar's data — `menus` and `handlers` for `setNativeMenu(bridge, { labels, menus }, handlers)` of\n * `@krizaka/app-desktop` — so the menu shows the keys the page answers.\n */\nexport function useDesktopCommands(commands: readonly DesktopCommand[]): DesktopMenus {\n const menus = React.useMemo(() => desktopMenus(commands), [commands]);\n useShortcuts(menus.shortcuts as ShortcutMap);\n return menus;\n}\n","// Pure: the arithmetic of the resizable panes, so it is tested without a pointer.\n\nexport interface PaneLimits {\n min: number;\n max: number;\n}\n\nexport const clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), Math.max(min, max));\n\n/**\n * The most a pane may take: its own maximum, and what leaves the content its minimum beside the other open pane and the\n * two separators. A window that is too small for both gives the content priority, down to the pane's own minimum.\n */\nexport function paneMax(limits: PaneLimits, windowWidth: number, otherOpenWidth: number, contentMin: number, separators: number): number {\n return Math.max(limits.min, Math.min(limits.max, windowWidth - otherOpenWidth - contentMin - separators));\n}\n\n/** The size after a drag of `delta` px along the reading direction (`direction` 1 in LTR, -1 in RTL; `side` 1 for the start pane, -1 for the end one). */\nexport function dragged(start: number, delta: number, direction: 1 | -1, side: 1 | -1, limits: PaneLimits, ceiling = limits.max): number {\n return clamp(start + delta * direction * side, limits.min, ceiling);\n}\n\n/** The size after an arrow key: the arrow that points away from the pane's edge grows it (→ for the start pane in LTR). `null` for another key. */\nexport function keyed(key: string, current: number, direction: 1 | -1, side: 1 | -1, limits: PaneLimits, shift: boolean, ceiling = limits.max): number | null {\n const step = shift ? 64 : 16;\n if (key === \"Home\") return limits.min;\n if (key === \"End\") return Math.max(limits.min, ceiling);\n if (key !== \"ArrowLeft\" && key !== \"ArrowRight\") return null;\n const toward = key === \"ArrowRight\" ? 1 : -1;\n return clamp(current + step * toward * direction * side, limits.min, ceiling);\n}\n"],"mappings":";;;AAGA,YAAY,WAAW;AAQvB,IAAM,UAAkC,EAAE,KAAK,UAAU,QAAQ,SAAS,OAAO,KAAK,UAAU,KAAK,IAAI,WAAW,MAAM,aAAa,MAAM,aAAa,OAAO,cAAc,KAAK,UAAU,MAAM,IAAI;AAyCjM,SAAS,cAAc,UAAsC;AAClE,MAAI,SAAS,KAAK,EAAE,SAAS,GAAG,EAAG,QAAO;AAC1C,QAAM,QAAQ,SAAS,MAAM,GAAG,EAAE,OAAO,OAAO;AAChD,QAAM,QAAgC,EAAE,KAAK,aAAa,MAAM,SAAS,MAAM,QAAQ,KAAK,OAAO,OAAO,QAAQ;AAClH,QAAM,OAAO,MAAM,GAAG,EAAE,KAAK,IAAI,YAAY;AAC7C,QAAM,MAAM,QAAQ,GAAG,KAAK;AAC5B,QAAM,OAA+B,EAAE,QAAQ,UAAU,OAAO,SAAS,KAAK,SAAS,SAAS,MAAM,WAAW,QAAQ,WAAW,QAAQ,YAAY,SAAS,QAAQ,UAAU,WAAW,aAAa,KAAK,OAAO,KAAK,OAAO;AACnO,QAAM,OAAO,KAAK,GAAG,MAAM,IAAI,WAAW,IAAI,IAAI,YAAY,IAAI,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AAC3G,SAAO,CAAC,GAAG,MAAM,MAAM,GAAG,EAAE,EAAE,IAAI,CAAC,SAAS,MAAM,KAAK,YAAY,CAAC,KAAK,IAAI,GAAG,IAAI,EAAE,KAAK,GAAG;AAChG;;;AClCA,IAAM,KAAK;AAYX,SAAS,QAAQ,KAAmB,IAAkB;AACpD,MAAI,CAAC,GAAG,KAAK,EAAE,EAAG,OAAM,IAAI,MAAM,kBAAkB,EAAE,8DAA8D;AACpH,MAAI,IAAI,SAAS,EAAE,EAAG,OAAM,IAAI,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sB;AAAA,UACvG;AAAA,WACH;AAAA,QACA,oBAAC,SAAI,0BAAuB,IAAG,WAAW,EAAE,aAAa,GACtD,iBACH;AAAA,QACA,qBAAC,SAAI,WAAW,EAAE,aAAa,GAC5B;AAAA;AAAA,UACA,gBAAgB,OAAO,aAAa,OAAO,iBAAiB,WAAW,MAAM,YAAY,CAAC,QAAQ,GAAG,uBAAuB;AAAA,WAC/H;AAAA,SACF;AAAA,MACA,oBAAC,UAAK,IAAG,WAAU,UAAU,IAAI,WAAW,EAAE,QAAQ,GACnD,UACH;AAAA,OACF;AAAA,IACC,aAAa,UAAU,aAAa,aAAa,OAAO,eAAe;AAAA,IACvE,gBACC,oBAAC,WAAM,IAAI,aAAa,cAAY,OAAO,WAAW,kBAAgB,YAAY,SAAY,IAAI,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO,EAAE,OAAO,MAAM,UAAU,GACjL,8BAAC,SAAI,WAAW,EAAE,OAAO,GAAI,qBAAU,GACzC;AAAA,KAEJ;AAEJ;AAOO,SAAS,mBAAmB,UAAmD;AACpF,QAAM,QAAc,eAAQ,MAAM,aAAa,QAAQ,GAAG,CAAC,QAAQ,CAAC;AACpE,eAAa,MAAM,SAAwB;AAC3C,SAAO;AACT;","names":["React"]}
|
|
1
|
+
{"version":3,"sources":["../src/app-shell/shortcuts.ts","../src/desktop-window/commands.ts","../src/desktop-window/desktop-window.tsx","../src/desktop-window/panes.ts"],"sourcesContent":["// Keyboard shortcuts for an application: a combination (`mod+k`, `shift+/`, `alt+arrowup`) or a sequence (`g d`: press G,\n// then D). `mod` is ⌘ on Apple devices and Ctrl elsewhere. Plain keys and sequences stay out of text fields; a combination\n// with `mod` works in an input (not in a rich-text editor, where ⌘B is bold). Nothing is decided here about the words.\nimport * as React from \"react\";\n\nimport { useLatest } from \"../media\";\n\nexport type ShortcutMap = Readonly<Record<string, ((event: KeyboardEvent) => void) | undefined>>;\n\nconst isApple = () => typeof navigator !== \"undefined\" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);\n\nconst ALIASES: Record<string, string> = { esc: \"escape\", return: \"enter\", space: \" \", spacebar: \" \", up: \"arrowup\", down: \"arrowdown\", left: \"arrowleft\", right: \"arrowright\", del: \"delete\", plus: \"+\" };\ntype Modifier = \"mod\" | \"ctrl\" | \"alt\" | \"shift\" | \"meta\";\n\ntype Combo = { key: string; mod: boolean; ctrl: boolean; alt: boolean; shift: boolean; meta: boolean };\n\n/** `\"mod+shift+k\"` → its parts. A lone `+` key is written `plus`. */\nexport function parseCombo(combo: string): Combo {\n const parts = combo.toLowerCase().split(\"+\").filter(Boolean);\n const key = ALIASES[parts.at(-1) ?? \"\"] ?? parts.at(-1) ?? \"\";\n const has = (name: Modifier) => parts.slice(0, -1).includes(name);\n return { key, mod: has(\"mod\"), ctrl: has(\"ctrl\"), alt: has(\"alt\"), shift: has(\"shift\"), meta: has(\"meta\") };\n}\n\n/** Whether a key event is this combination: its modifiers exactly (`mod` is ⌘ or Ctrl by platform), then its key. */\nexport function matchesCombo(event: Pick<KeyboardEvent, \"key\" | \"metaKey\" | \"ctrlKey\" | \"altKey\" | \"shiftKey\">, combo: string, apple = isApple()): boolean {\n const want = parseCombo(combo);\n const meta = want.meta || (want.mod && apple);\n const ctrl = want.ctrl || (want.mod && !apple);\n if (event.metaKey !== meta || event.ctrlKey !== ctrl || event.altKey !== want.alt) return false;\n // Shift is only checked when the binding names it: `?` and `/` need it on most layouts.\n if (want.shift && !event.shiftKey) return false;\n return event.key.toLowerCase() === want.key;\n}\n\n/** The keys of a shortcut to show on a keycap: `[\"⌘\", \"K\"]` on a Mac, `[\"Ctrl\", \"K\"]` elsewhere; a sequence `g d` is `[\"G\", \"D\"]`. */\nexport function formatShortcut(shortcut: string, apple = isApple()): string[] {\n if (shortcut.includes(\" \")) return shortcut.split(/\\s+/).map((key) => key.toUpperCase());\n const parts = shortcut.split(\"+\").filter(Boolean);\n const key = parts.at(-1) ?? \"\";\n const names: Record<string, [string, string]> = { mod: [\"⌘\", \"Ctrl\"], meta: [\"⌘\", \"Win\"], ctrl: [\"⌃\", \"Ctrl\"], alt: [\"⌥\", \"Alt\"], shift: [\"⇧\", \"Shift\"] };\n const shown = parts.slice(0, -1).map((part) => names[part.toLowerCase()]?.[apple ? 0 : 1] ?? part);\n const glyph: Record<string, string> = { escape: \"Esc\", enter: \"↵\", arrowup: \"↑\", arrowdown: \"↓\", arrowleft: \"←\", arrowright: \"→\", \" \": \"Space\" };\n const last = glyph[ALIASES[key.toLowerCase()] ?? key.toLowerCase()] ?? key.toUpperCase();\n return [...shown, last];\n}\n\n/**\n * The accelerator of a combination for a desktop app's native menu bar (Tauri's `MenuItem`, Electron's — ADR-002):\n * `mod+k` → `CmdOrCtrl+K`, `shift+mod+/` → `Shift+CmdOrCtrl+/`. The menu and the shell then answer the same keys, and the\n * menu shows them. A sequence (`g d`) has none: a menu item takes one chord.\n */\nexport function acceleratorOf(shortcut: string): string | undefined {\n if (shortcut.trim().includes(\" \")) return undefined;\n const parts = shortcut.split(\"+\").filter(Boolean);\n const names: Record<string, string> = { mod: \"CmdOrCtrl\", meta: \"Super\", ctrl: \"Ctrl\", alt: \"Alt\", shift: \"Shift\" };\n const raw = (parts.at(-1) ?? \"\").toLowerCase();\n const key = ALIASES[raw] ?? raw;\n const keys: Record<string, string> = { escape: \"Escape\", enter: \"Enter\", \" \": \"Space\", arrowup: \"Up\", arrowdown: \"Down\", arrowleft: \"Left\", arrowright: \"Right\", delete: \"Delete\", backspace: \"Backspace\", tab: \"Tab\", \"+\": \"Plus\" };\n const last = keys[key] ?? (key.length === 1 ? key.toUpperCase() : key.charAt(0).toUpperCase() + key.slice(1));\n return [...parts.slice(0, -1).map((part) => names[part.toLowerCase()] ?? part), last].join(\"+\");\n}\n\nconst noop = () => () => undefined;\n\n/** Whether the person is on an Apple device — `false` on the server and in the first client render (no mismatch), then right. */\nexport function useApple(): boolean {\n return React.useSyncExternalStore(noop, isApple, () => false);\n}\n\n/** The `aria-keyshortcuts` of a combination (`Control+K`, `Meta+K` on a Mac); a sequence has none (it is not a chord). */\nexport function ariaKeyShortcuts(shortcut: string, apple = isApple()): string | undefined {\n if (shortcut.includes(\" \")) return undefined;\n const parts = shortcut.split(\"+\").filter(Boolean);\n const names: Record<string, string> = { mod: apple ? \"Meta\" : \"Control\", meta: \"Meta\", ctrl: \"Control\", alt: \"Alt\", shift: \"Shift\" };\n const key = parts.at(-1) ?? \"\";\n return [...parts.slice(0, -1).map((part) => names[part.toLowerCase()] ?? part), key.length === 1 ? key.toUpperCase() : key.charAt(0).toUpperCase() + key.slice(1)].join(\"+\");\n}\n\n/** Whether a key press happens in something you type in. */\nfunction isEditable(target: EventTarget | null): { field: boolean; rich: boolean } {\n const element = target instanceof HTMLElement ? target : null;\n if (!element) return { field: false, rich: false };\n const rich = element.isContentEditable;\n return { field: rich || /^(input|textarea|select)$/i.test(element.tagName), rich };\n}\n\n/**\n * Binds shortcuts for as long as the component lives (`enabled` turns them off). Each key is a combination or a sequence,\n * each value runs when it is pressed; the handler may change on every render. A shortcut that fires is `preventDefault`ed.\n * A sequence waits `timeout` ms for its next key.\n */\nexport function useShortcuts(map: ShortcutMap, { enabled = true, timeout = 900 }: { enabled?: boolean; timeout?: number } = {}) {\n const latest = useLatest(map);\n const names = Object.keys(map).sort((a, b) => a.localeCompare(b)).join(\"\\n\");\n React.useEffect(() => {\n if (!enabled) return;\n const bindings = names.split(\"\\n\").filter(Boolean);\n let buffer: { key: string; at: number }[] = [];\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.defaultPrevented || event.isComposing || event.repeat || !event.key) return;\n const editing = isEditable(event.target);\n const chord = event.metaKey || event.ctrlKey || event.altKey;\n const now = Date.now();\n buffer = [...buffer.filter((entry) => now - entry.at <= timeout), { key: event.key.toLowerCase(), at: now }].slice(-4);\n for (const binding of bindings) {\n const handler = latest.current[binding];\n if (!handler) continue;\n const keys = binding.toLowerCase().split(/\\s+/).map((key) => ALIASES[key] ?? key);\n const fired =\n keys.length > 1\n ? !chord && !editing.field && buffer.length >= keys.length && keys.every((key, i) => buffer[buffer.length - keys.length + i]?.key === key)\n : matchesCombo(event, binding) && (chord ? !editing.rich : !editing.field);\n if (!fired) continue;\n event.preventDefault();\n buffer = [];\n handler(event);\n return;\n }\n };\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [enabled, names, latest, timeout]);\n}\n","// Pure: the commands of a desktop window, written once and read by three things — the native menu bar (through\n// `setNativeMenu` of @krizaka/app-desktop), the in-page shortcuts (`useShortcuts`, also the browser's), and the palette.\nimport { acceleratorOf } from \"../app-shell/shortcuts\";\n\nexport interface DesktopCommand {\n /** Sent back by the menu when chosen: lowercase letters, digits, `.` and `-` (`view.sidebar`). */\n id: string;\n /** The menu item's words, passed translated (`Hide sidebar`). */\n label: string;\n /** The menu it belongs to (`View`, `File`), passed translated: the product's menus sit between Edit and Window. */\n menu: string;\n /** A chord (`mod+b`): the menu shows it and the page answers it. A sequence (`g d`) is the page's only. */\n shortcut?: string;\n /** Runs the command. */\n run: () => void;\n /** A separator before it in its menu. */\n separated?: boolean;\n /** Dimmed in the menu while false (default true). */\n enabled?: boolean;\n}\n\n/** The shape `setNativeMenu` takes for its `menus` (structurally the same as `MenuSpec[\"menus\"]` of @krizaka/app-desktop). */\nexport interface DesktopMenu {\n title: string;\n items: { id: string; label: string; accelerator?: string; enabled?: boolean; separated?: boolean }[];\n}\n\nconst ID = /^[a-z0-9][a-z0-9.-]*$/;\n\nexport interface DesktopMenus {\n /** For `setNativeMenu(bridge, { labels, menus }, handlers)`. */\n menus: DesktopMenu[];\n /** For its `handlers`: the id of the chosen item → what it does. */\n handlers: Record<string, () => void>;\n /** For `useShortcuts`: the chords of the commands, answered in the page. */\n shortcuts: Record<string, () => void>;\n}\n\n/** Refuses an id the native side would refuse, or one already declared. */\nfunction checkId(out: DesktopMenus, id: string): void {\n if (!ID.test(id)) throw new Error(`desktopMenus: \"${id}\" is not a menu id (lowercase letters, digits, \".\" and \"-\").`);\n if (out.handlers[id]) throw new Error(`desktopMenus: \"${id}\" is declared twice.`);\n}\n\n/** Records the chord of a command for the page, refusing one given to two commands. */\nfunction addShortcut(out: DesktopMenus, shortcut: string, run: () => void): void {\n const key = shortcut.toLowerCase();\n if (out.shortcuts[key]) throw new Error(`desktopMenus: \"${shortcut}\" is the shortcut of two commands.`);\n out.shortcuts[key] = run;\n}\n\n/** The menu item of a command: its accelerator, and only the flags it sets. */\nfunction itemOf(command: DesktopCommand): DesktopMenu[\"items\"][number] {\n const accelerator = command.shortcut ? acceleratorOf(command.shortcut) : undefined;\n return {\n id: command.id,\n label: command.label,\n ...(accelerator ? { accelerator } : {}),\n ...(command.enabled === false ? { enabled: false } : {}),\n ...(command.separated ? { separated: true } : {}),\n };\n}\n\n/** Turns the commands into the menu bar's menus, its handlers and the page's shortcuts — one source for the three. Throws on a bad or repeated id, or a shortcut given twice. */\nexport function desktopMenus(commands: readonly DesktopCommand[]): DesktopMenus {\n const out: DesktopMenus = { menus: [], handlers: {}, shortcuts: {} };\n for (const command of commands) {\n checkId(out, command.id);\n out.handlers[command.id] = command.run;\n if (command.shortcut) addShortcut(out, command.shortcut, command.run);\n let menu = out.menus.find((m) => m.title === command.menu);\n if (!menu) out.menus.push((menu = { title: command.menu, items: [] }));\n menu.items.push(itemOf(command));\n }\n return out;\n}\n","// Client (the panes' sizes, the pointer, the shortcuts). The window of a Mac app (Tauri 2 on the system WebView, ADR-002):\n// a sidebar, the content and an inspector in a three-pane split — resizable by pointer and keyboard, collapsible — under a\n// toolbar that moves the window and clears the traffic lights, at the desktop's density with a native-feeling focus ring.\n// The commands (`desktopMenus`) are written once for the native menu bar, the page's shortcuts and the palette.\nimport { type ShortcutMap, useShortcuts } from \"@krizaka/ui/app-shell\";\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { type DesktopCommand, type DesktopMenus, desktopMenus } from \"./commands\";\nimport { clamp, dragged, keyed, paneMax } from \"./panes\";\n\nexport const desktopWindow = tv({\n slots: {\n root:\n \"kz-desktop-window flex h-[var(--kz-window-height,100dvh)] min-w-0 select-none overflow-hidden bg-surface-0 text-[13px] text-fg \" +\n // The macOS focus ring: a 3 px halo of the accent, over a 1 px accent edge, only for the keyboard.\n \"[&_:focus-visible]:outline-hidden [&_:focus-visible]:ring-[3px]! [&_:focus-visible]:ring-ring/50! [&_:focus-visible]:ring-offset-0!\",\n pane: \"relative flex min-h-0 shrink-0 flex-col overflow-hidden data-[collapsed]:hidden\",\n sidebar: \"border-e border-border-subtle bg-surface-1\",\n titlebar: \"h-[var(--kz-titlebar-inset,1.75rem)] shrink-0\",\n scroll: \"min-h-0 flex-1 overflow-y-auto\",\n middle: \"flex min-h-0 min-w-0 flex-1 flex-col\",\n inspector: \"border-s border-border-subtle bg-surface-1\",\n separator:\n \"group/sep relative z-10 -mx-[3px] w-[6px] shrink-0 cursor-col-resize touch-none data-[collapsed]:hidden \" +\n \"after:absolute after:inset-y-0 after:left-[2px] after:w-px after:bg-transparent hover:after:bg-border-strong data-[active]:after:bg-accent focus-visible:after:bg-accent\",\n content: \"min-h-0 min-w-0 flex-1 overflow-y-auto select-text\",\n toolbar:\n \"flex h-[var(--kz-toolbar-height,3rem)] shrink-0 items-center gap-2 border-b border-border-subtle bg-surface-0 px-3 \" +\n // With the sidebar folded the traffic lights sit over the toolbar: its first control starts after them.\n \"[[data-sidebar=closed]_&]:ps-[var(--kz-traffic-lights-inset,4.75rem)]\",\n toolbarTitle: \"min-w-0 flex-1 truncate text-[13px] font-semibold\",\n toolbarGroup: \"flex shrink-0 items-center gap-1\",\n toggle:\n \"inline-flex h-7 w-7 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-surface-2 hover:text-fg cursor-default aria-pressed:text-fg-accent\",\n },\n});\nconst s = desktopWindow();\n\nexport interface DesktopWindowLabels {\n /** The sidebar's accessible name (`Library`). */\n sidebar: string;\n /** The inspector's accessible name (`Details`). */\n inspector: string;\n /** The separators' names (`Resize the sidebar`, `Resize the inspector`). */\n resizeSidebar: string;\n resizeInspector: string;\n /** The toolbar buttons that fold the panes (`Show or hide the sidebar`). */\n toggleSidebar: string;\n toggleInspector: string;\n}\n\nexport interface DesktopWindowProps {\n /** The sidebar's content: a list of places, a `Tree`. It scrolls by itself. */\n sidebar: React.ReactNode;\n /** The main content under the toolbar. */\n children: React.ReactNode;\n /** The inspector's content: the selected item's details. Without it, a two-pane window. */\n inspector?: React.ReactNode;\n /** The toolbar's title, centred in the drag region. */\n title?: React.ReactNode;\n /** After the sidebar's toggle, at the start of the toolbar (back, forward). */\n toolbarStart?: React.ReactNode;\n /** Before the inspector's toggle, at the end of the toolbar (actions, search). */\n toolbarEnd?: React.ReactNode;\n /** The words of the panes, the dividers and the toggles — passed translated. */\n labels: DesktopWindowLabels;\n /** The sidebar is open (controlled). Pair with `onSidebarOpenChange`: the menu bar's command toggles it too. */\n sidebarOpen?: boolean;\n /** The sidebar starts open (default true) when uncontrolled. */\n defaultSidebarOpen?: boolean;\n /** Called when the sidebar folds or unfolds (the toolbar, a divider, the shortcut). */\n onSidebarOpenChange?: (open: boolean) => void;\n /** The inspector is open (controlled). */\n inspectorOpen?: boolean;\n /** The inspector starts open (default true) when uncontrolled. */\n defaultInspectorOpen?: boolean;\n /** Called when the inspector folds or unfolds. */\n onInspectorOpenChange?: (open: boolean) => void;\n /** The sizes in px: the sidebar's, the inspector's. Persist them with `onSizesChange`. */\n defaultSizes?: { sidebar?: number; inspector?: number };\n /** Called with the sizes in px after a drag or a key: persist them. */\n onSizesChange?: (sizes: { sidebar: number; inspector: number }) => void;\n /** The least the content keeps when the window is narrow (default 360). */\n contentMin?: number;\n /** The keys that fold the panes (a chord, or `false` for none): ⌘B and ⌘I by default. Pass `false` when the menu bar's commands (`useDesktopCommands`) own them. */\n shortcuts?: { sidebar?: string | false; inspector?: string | false };\n /** Classes for the window (`[--kz-window-height:34rem]` to size it inside a page). */\n className?: string;\n}\n\nconst SIDEBAR: { min: number; max: number } = { min: 180, max: 360 };\nconst INSPECTOR: { min: number; max: number } = { min: 240, max: 480 };\n\nconst glyph = (d: string) => (\n <svg viewBox=\"0 0 24 24\" className=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n <path d={d} />\n </svg>\n);\n\nfunction useOpen(controlled: boolean | undefined, initial: boolean, onChange?: (open: boolean) => void) {\n const [own, setOwn] = React.useState(initial);\n const open = controlled ?? own;\n const set = React.useCallback(\n (next: boolean) => {\n if (controlled === undefined) setOwn(next);\n onChange?.(next);\n },\n [controlled, onChange],\n );\n return [open, set] as const;\n}\n\ntype Edge = \"sidebar\" | \"inspector\";\n\n/** The window of a Mac app: sidebar · content · inspector, a toolbar that moves the window, the desktop's density. */\nexport function DesktopWindow({\n sidebar, children, inspector, title, toolbarStart, toolbarEnd, labels, sidebarOpen, defaultSidebarOpen = true, onSidebarOpenChange, inspectorOpen, defaultInspectorOpen = true, onInspectorOpenChange, defaultSizes, onSizesChange, contentMin = 360, shortcuts, className,\n}: Readonly<DesktopWindowProps>) {\n const [sideOpen, setSideOpen] = useOpen(sidebarOpen, defaultSidebarOpen, onSidebarOpenChange);\n const [inspOpen, setInspOpen] = useOpen(inspectorOpen, defaultInspectorOpen, onInspectorOpenChange);\n const [sizes, setSizes] = React.useState({ sidebar: clamp(defaultSizes?.sidebar ?? 240, SIDEBAR.min, SIDEBAR.max), inspector: clamp(defaultSizes?.inspector ?? 300, INSPECTOR.min, INSPECTOR.max) });\n const [active, setActive] = React.useState<Edge | null>(null);\n const root = React.useRef<HTMLDivElement>(null);\n const [width, setWidth] = React.useState(0);\n const toggles = React.useRef<Record<Edge, HTMLButtonElement | null>>({ sidebar: null, inspector: null });\n const sidebarId = React.useId();\n const inspectorId = React.useId();\n const hasInspector = inspector != null;\n const sideShown = sideOpen;\n const inspShown = hasInspector && inspOpen;\n\n const keys = { sidebar: shortcuts?.sidebar === undefined ? \"mod+b\" : shortcuts.sidebar, inspector: shortcuts?.inspector === undefined ? \"mod+i\" : shortcuts.inspector };\n const map: Record<string, () => void> = {};\n if (keys.sidebar) map[keys.sidebar] = () => setSideOpen(!sideOpen);\n if (keys.inspector && hasInspector) map[keys.inspector] = () => setInspOpen(!inspOpen);\n useShortcuts(map as ShortcutMap);\n\n const commit = (edge: Edge, size: number) => {\n const next = { ...sizes, [edge]: size };\n setSizes(next);\n onSizesChange?.(next);\n };\n // The window's width, to keep the content its room: measured, and followed while the window is resized.\n React.useLayoutEffect(() => {\n const element = root.current;\n if (!element) return;\n const measure = () => setWidth(element.getBoundingClientRect().width);\n measure();\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, []);\n const ceiling = (edge: Edge) => {\n let other: number;\n if (edge === \"sidebar\") other = inspShown ? sizes.inspector : 0;\n else other = sideShown ? sizes.sidebar : 0;\n const limits = edge === \"sidebar\" ? SIDEBAR : INSPECTOR;\n // The separators overlap the panes (negative margins): they take no width of their own.\n return paneMax(limits, width || Number.POSITIVE_INFINITY, other, contentMin, 0);\n };\n const direction = (): 1 | -1 => (root.current && getComputedStyle(root.current).direction === \"rtl\" ? -1 : 1);\n const sideOf = (edge: Edge): 1 | -1 => (edge === \"sidebar\" ? 1 : -1);\n const limitsOf = (edge: Edge) => (edge === \"sidebar\" ? SIDEBAR : INSPECTOR);\n\n const onPointerDown = (edge: Edge) => (event: React.PointerEvent<HTMLDivElement>) => {\n if (event.button !== 0) return;\n event.currentTarget.setPointerCapture(event.pointerId);\n const startX = event.clientX;\n const start = sizes[edge];\n const max = ceiling(edge);\n const dir = direction();\n setActive(edge);\n const target = event.currentTarget;\n const move = (e: PointerEvent) => commit(edge, dragged(start, e.clientX - startX, dir, sideOf(edge), limitsOf(edge), max));\n const stop = () => {\n setActive(null);\n target.removeEventListener(\"pointermove\", move);\n target.removeEventListener(\"pointerup\", stop);\n target.removeEventListener(\"pointercancel\", stop);\n };\n target.addEventListener(\"pointermove\", move);\n target.addEventListener(\"pointerup\", stop);\n target.addEventListener(\"pointercancel\", stop);\n };\n const onKeyDown = (edge: Edge) => (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n (edge === \"sidebar\" ? setSideOpen : setInspOpen)(false);\n // The separator goes with the pane: the focus goes to the button that brings it back.\n queueMicrotask(() => toggles.current[edge]?.focus());\n return;\n }\n const next = keyed(event.key, sizes[edge], direction(), sideOf(edge), limitsOf(edge), event.shiftKey, ceiling(edge));\n if (next === null) return;\n event.preventDefault();\n commit(edge, next);\n };\n\n const separator = (edge: Edge, controls: string, label: string) => (\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-controls={controls}\n aria-valuemin={limitsOf(edge).min}\n aria-valuemax={ceiling(edge)}\n aria-valuenow={sizes[edge]}\n tabIndex={0}\n data-edge={edge}\n data-active={active === edge ? \"\" : undefined}\n className={s.separator()}\n onPointerDown={onPointerDown(edge)}\n onKeyDown={onKeyDown(edge)}\n onDoubleClick={() => (edge === \"sidebar\" ? setSideOpen(false) : setInspOpen(false))}\n />\n );\n const toggle = (edge: Edge, label: string, pressed: boolean, onClick: () => void, d: string) => (\n <button type=\"button\" ref={(el) => { toggles.current[edge] = el; }} className={s.toggle()} aria-label={label} aria-pressed={pressed} onClick={onClick}>\n {glyph(d)}\n </button>\n );\n\n return (\n <div ref={root} data-desktop=\"\" data-sidebar={sideShown ? \"open\" : \"closed\"} className={s.root({ className })}>\n <aside id={sidebarId} aria-label={labels.sidebar} data-collapsed={sideShown ? undefined : \"\"} className={s.pane({ className: s.sidebar() })} style={{ width: sizes.sidebar }}>\n <div aria-hidden data-tauri-drag-region=\"\" className={s.titlebar()} />\n <div className={s.scroll()}>{sidebar}</div>\n </aside>\n {sideShown && separator(\"sidebar\", sidebarId, labels.resizeSidebar)}\n <div className={s.middle()}>\n <header data-tauri-drag-region=\"\" className={s.toolbar()}>\n <div className={s.toolbarGroup()}>\n {toggle(\"sidebar\", labels.toggleSidebar, sideShown, () => setSideOpen(!sideOpen), \"M4 5h16v14H4zM9 5v14\")}\n {toolbarStart}\n </div>\n <div data-tauri-drag-region=\"\" className={s.toolbarTitle()}>\n {title}\n </div>\n <div className={s.toolbarGroup()}>\n {toolbarEnd}\n {hasInspector && toggle(\"inspector\", labels.toggleInspector, inspShown, () => setInspOpen(!inspOpen), \"M4 5h16v14H4zM15 5v14\")}\n </div>\n </header>\n <main id=\"content\" tabIndex={-1} className={s.content()}>\n {children}\n </main>\n </div>\n {inspShown && separator(\"inspector\", inspectorId, labels.resizeInspector)}\n {hasInspector && (\n <aside id={inspectorId} aria-label={labels.inspector} data-collapsed={inspShown ? undefined : \"\"} className={s.pane({ className: s.inspector() })} style={{ width: sizes.inspector }}>\n <div className={s.scroll()}>{inspector}</div>\n </aside>\n )}\n </div>\n );\n}\n\n/**\n * The window's commands as one source: registers their chords in the page (`useShortcuts`, the browser's too) and returns\n * the native menu bar's data — `menus` and `handlers` for `setNativeMenu(bridge, { labels, menus }, handlers)` of\n * `@krizaka/app-desktop` — so the menu shows the keys the page answers.\n */\nexport function useDesktopCommands(commands: readonly DesktopCommand[]): DesktopMenus {\n const menus = React.useMemo(() => desktopMenus(commands), [commands]);\n useShortcuts(menus.shortcuts as ShortcutMap);\n return menus;\n}\n","// Pure: the arithmetic of the resizable panes, so it is tested without a pointer.\n\nexport interface PaneLimits {\n min: number;\n max: number;\n}\n\nexport const clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), Math.max(min, max));\n\n/**\n * The most a pane may take: its own maximum, and what leaves the content its minimum beside the other open pane and the\n * two separators. A window that is too small for both gives the content priority, down to the pane's own minimum.\n */\nexport function paneMax(limits: PaneLimits, windowWidth: number, otherOpenWidth: number, contentMin: number, separators: number): number {\n return Math.max(limits.min, Math.min(limits.max, windowWidth - otherOpenWidth - contentMin - separators));\n}\n\n/** The size after a drag of `delta` px along the reading direction (`direction` 1 in LTR, -1 in RTL; `side` 1 for the start pane, -1 for the end one). */\nexport function dragged(start: number, delta: number, direction: 1 | -1, side: 1 | -1, limits: PaneLimits, ceiling = limits.max): number {\n return clamp(start + delta * direction * side, limits.min, ceiling);\n}\n\n/** The size after an arrow key: the arrow that points away from the pane's edge grows it (→ for the start pane in LTR). `null` for another key. */\nexport function keyed(key: string, current: number, direction: 1 | -1, side: 1 | -1, limits: PaneLimits, shift: boolean, ceiling = limits.max): number | null {\n const step = shift ? 64 : 16;\n if (key === \"Home\") return limits.min;\n if (key === \"End\") return Math.max(limits.min, ceiling);\n if (key !== \"ArrowLeft\" && key !== \"ArrowRight\") return null;\n const toward = key === \"ArrowRight\" ? 1 : -1;\n return clamp(current + step * toward * direction * side, limits.min, ceiling);\n}\n"],"mappings":";;;AAGA,YAAY,WAAW;AAQvB,IAAM,UAAkC,EAAE,KAAK,UAAU,QAAQ,SAAS,OAAO,KAAK,UAAU,KAAK,IAAI,WAAW,MAAM,aAAa,MAAM,aAAa,OAAO,cAAc,KAAK,UAAU,MAAM,IAAI;AAyCjM,SAAS,cAAc,UAAsC;AAClE,MAAI,SAAS,KAAK,EAAE,SAAS,GAAG,EAAG,QAAO;AAC1C,QAAM,QAAQ,SAAS,MAAM,GAAG,EAAE,OAAO,OAAO;AAChD,QAAM,QAAgC,EAAE,KAAK,aAAa,MAAM,SAAS,MAAM,QAAQ,KAAK,OAAO,OAAO,QAAQ;AAClH,QAAM,OAAO,MAAM,GAAG,EAAE,KAAK,IAAI,YAAY;AAC7C,QAAM,MAAM,QAAQ,GAAG,KAAK;AAC5B,QAAM,OAA+B,EAAE,QAAQ,UAAU,OAAO,SAAS,KAAK,SAAS,SAAS,MAAM,WAAW,QAAQ,WAAW,QAAQ,YAAY,SAAS,QAAQ,UAAU,WAAW,aAAa,KAAK,OAAO,KAAK,OAAO;AACnO,QAAM,OAAO,KAAK,GAAG,MAAM,IAAI,WAAW,IAAI,I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"]}
|
package/dist/drop-overlay.js
CHANGED
|
@@ -70,15 +70,15 @@ function DropOverlay({
|
|
|
70
70
|
const { accepted, rejected } = splitDropped(files, latest.current.accept);
|
|
71
71
|
latest.current.onFiles?.(accepted, rejected);
|
|
72
72
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
globalThis.addEventListener("dragenter", enter);
|
|
74
|
+
globalThis.addEventListener("dragover", over);
|
|
75
|
+
globalThis.addEventListener("dragleave", leave);
|
|
76
|
+
globalThis.addEventListener("drop", drop);
|
|
77
77
|
return () => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
globalThis.removeEventListener("dragenter", enter);
|
|
79
|
+
globalThis.removeEventListener("dragover", over);
|
|
80
|
+
globalThis.removeEventListener("dragleave", leave);
|
|
81
|
+
globalThis.removeEventListener("drop", drop);
|
|
82
82
|
reset();
|
|
83
83
|
};
|
|
84
84
|
}, [disabled, isControlled]);
|
package/dist/drop-overlay.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/drop-overlay/drop-overlay.tsx","../src/drop-overlay/files.ts"],"sourcesContent":["// Client (window listeners). The whole window is the drop target: while files are dragged over the page a full-window overlay\n// says so, and the dropped files go to `onFiles` (accepted, rejected). No dashed box in the page; the product keeps a real\n// file input behind its primary action for the keyboard and for phones. Motion: motion.css (« DROP OVERLAY »).\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { type AcceptRule, dragHasFiles, splitDropped } from \"./files\";\n\nexport type DropOverlayProps = Omit<React.ComponentProps<\"div\">, \"children\" | \"onDrop\"> & {\n /** What the overlay says (“Drop to check”) — passed translated. */\n label: string;\n /** One line under it (“PDF or text”). */\n hint?: string;\n /** What is accepted: MIME types, families (`image/*`) or extensions (`.pdf`). */\n accept?: readonly AcceptRule[];\n /** Turns the window back into a plain page (while a modal is open, signed out). */\n disabled?: boolean;\n} & (\n | {\n /** Controlled form (a desktop app's native drops, which arrive as paths): shown while true, the DOM listeners are off. */\n active: boolean;\n /** Not called in the controlled form. */\n onFiles?: (accepted: File[], rejected: File[]) => void;\n }\n | {\n /** Leave undefined to handle DOM drops. */\n active?: undefined;\n /** The files dropped: the accepted ones, then the ones `accept` refused. */\n onFiles: (accepted: File[], rejected: File[]) => void;\n }\n);\n\n/** Drag a file anywhere on the page: a full-window overlay accepts it. */\nexport function DropOverlay({\n label,\n hint,\n onFiles,\n accept,\n disabled,\n active: controlled,\n className,\n ...props\n}: DropOverlayProps) {\n const isControlled = controlled !== undefined;\n const [dragging, setActive] = React.useState(false);\n const depth = React.useRef(0);\n const latest = React.useRef({ onFiles, accept });\n React.useEffect(() => {\n latest.current = { onFiles, accept };\n });\n\n React.useEffect(() => {\n if (disabled || isControlled) return;\n const reset = () => {\n depth.current = 0;\n setActive(false);\n };\n const carrying = (event: Event) => dragHasFiles((event as DragEvent).dataTransfer);\n const enter = (event: Event) => {\n if (!carrying(event)) return;\n depth.current += 1;\n setActive(true);\n };\n const over = (event: Event) => {\n if (carrying(event)) event.preventDefault();\n };\n const leave = (event: Event) => {\n if (!carrying(event)) return;\n depth.current = Math.max(0, depth.current - 1);\n if (depth.current === 0) setActive(false);\n };\n const drop = (event: Event) => {\n if (!carrying(event)) return;\n event.preventDefault();\n const files = Array.from((event as DragEvent).dataTransfer?.files ?? []);\n reset();\n const { accepted, rejected } = splitDropped(files, latest.current.accept);\n latest.current.onFiles?.(accepted, rejected);\n };\n
|
|
1
|
+
{"version":3,"sources":["../src/drop-overlay/drop-overlay.tsx","../src/drop-overlay/files.ts"],"sourcesContent":["// Client (window listeners). The whole window is the drop target: while files are dragged over the page a full-window overlay\n// says so, and the dropped files go to `onFiles` (accepted, rejected). No dashed box in the page; the product keeps a real\n// file input behind its primary action for the keyboard and for phones. Motion: motion.css (« DROP OVERLAY »).\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { type AcceptRule, dragHasFiles, splitDropped } from \"./files\";\n\nexport type DropOverlayProps = Omit<React.ComponentProps<\"div\">, \"children\" | \"onDrop\"> & {\n /** What the overlay says (“Drop to check”) — passed translated. */\n label: string;\n /** One line under it (“PDF or text”). */\n hint?: string;\n /** What is accepted: MIME types, families (`image/*`) or extensions (`.pdf`). */\n accept?: readonly AcceptRule[];\n /** Turns the window back into a plain page (while a modal is open, signed out). */\n disabled?: boolean;\n} & (\n | {\n /** Controlled form (a desktop app's native drops, which arrive as paths): shown while true, the DOM listeners are off. */\n active: boolean;\n /** Not called in the controlled form. */\n onFiles?: (accepted: File[], rejected: File[]) => void;\n }\n | {\n /** Leave undefined to handle DOM drops. */\n active?: undefined;\n /** The files dropped: the accepted ones, then the ones `accept` refused. */\n onFiles: (accepted: File[], rejected: File[]) => void;\n }\n);\n\n/** Drag a file anywhere on the page: a full-window overlay accepts it. */\nexport function DropOverlay({\n label,\n hint,\n onFiles,\n accept,\n disabled,\n active: controlled,\n className,\n ...props\n}: DropOverlayProps) {\n const isControlled = controlled !== undefined;\n const [dragging, setActive] = React.useState(false);\n const depth = React.useRef(0);\n const latest = React.useRef({ onFiles, accept });\n React.useEffect(() => {\n latest.current = { onFiles, accept };\n });\n\n React.useEffect(() => {\n if (disabled || isControlled) return;\n const reset = () => {\n depth.current = 0;\n setActive(false);\n };\n const carrying = (event: Event) => dragHasFiles((event as DragEvent).dataTransfer);\n const enter = (event: Event) => {\n if (!carrying(event)) return;\n depth.current += 1;\n setActive(true);\n };\n const over = (event: Event) => {\n if (carrying(event)) event.preventDefault();\n };\n const leave = (event: Event) => {\n if (!carrying(event)) return;\n depth.current = Math.max(0, depth.current - 1);\n if (depth.current === 0) setActive(false);\n };\n const drop = (event: Event) => {\n if (!carrying(event)) return;\n event.preventDefault();\n const files = Array.from((event as DragEvent).dataTransfer?.files ?? []);\n reset();\n const { accepted, rejected } = splitDropped(files, latest.current.accept);\n latest.current.onFiles?.(accepted, rejected);\n };\n globalThis.addEventListener(\"dragenter\", enter);\n globalThis.addEventListener(\"dragover\", over);\n globalThis.addEventListener(\"dragleave\", leave);\n globalThis.addEventListener(\"drop\", drop);\n return () => {\n globalThis.removeEventListener(\"dragenter\", enter);\n globalThis.removeEventListener(\"dragover\", over);\n globalThis.removeEventListener(\"dragleave\", leave);\n globalThis.removeEventListener(\"drop\", drop);\n reset();\n };\n }, [disabled, isControlled]);\n\n if (!(isControlled ? controlled && !disabled : dragging)) return null;\n return (\n <div role=\"status\" data-state=\"open\" className={cn(\"kz-drop-overlay\", className)} {...props}>\n <div className=\"kz-drop-overlay-card\">\n <span className=\"text-lg font-semibold text-fg\">{label}</span>\n {hint ? <span className=\"text-sm text-fg-secondary\">{hint}</span> : null}\n </div>\n </div>\n );\n}\n","// Headless: what a drag carries and which of the dropped files a product accepts.\n\n/** True while the drag carries files (not text or a link): the only drag that should raise the overlay. */\nexport function dragHasFiles(transfer: { types?: readonly string[] | DOMStringList } | null | undefined): boolean {\n return Array.from(transfer?.types ?? []).includes(\"Files\");\n}\n\n/** One accepted kind: a MIME type (`application/pdf`), a family (`image/*`) or an extension (`.pdf`). */\nexport type AcceptRule = string;\n\nfunction matches(file: Pick<File, \"name\" | \"type\">, rule: AcceptRule): boolean {\n const wanted = rule.trim().toLowerCase();\n if (wanted.startsWith(\".\")) return file.name.toLowerCase().endsWith(wanted);\n if (wanted.endsWith(\"/*\")) return file.type.toLowerCase().startsWith(wanted.slice(0, -1));\n return file.type.toLowerCase() === wanted;\n}\n\nexport interface DropSplit<F> {\n accepted: F[];\n rejected: F[];\n}\n\n/** Splits dropped files by `accept` (no rule: everything is accepted). */\nexport function splitDropped<F extends Pick<File, \"name\" | \"type\">>(files: readonly F[], accept?: readonly AcceptRule[]): DropSplit<F> {\n if (!accept || accept.length === 0) return { accepted: [...files], rejected: [] };\n const accepted: F[] = [];\n const rejected: F[] = [];\n for (const file of files) (accept.some((rule) => matches(file, rule)) ? accepted : rejected).push(file);\n return { accepted, rejected };\n}\n"],"mappings":";;;;;AAGA,YAAY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F,+BAAC,SAAI,WAAU,wBACb;AAAA,wBAAC,UAAK,WAAU,iCAAiC,iBAAM;AAAA,IACtD,OAAO,oBAAC,UAAK,WAAU,6BAA6B,gBAAK,IAAU;AAAA,KACtE,GACF;AAEJ;","names":[]}
|
package/dist/elephant.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ interface ElephantProps extends Omit<SVGProps<SVGSVGElement>, "width" | "height"
|
|
|
17
17
|
* both themes; decorative by default.
|
|
18
18
|
* @deprecated Since 3.55 (ADR-006, krizaka-ui#674): no product uses it. Removed in 4.0.
|
|
19
19
|
*/
|
|
20
|
-
declare function Elephant({ pose, size, animated, title, className, ...rest }: ElephantProps): React.JSX.Element;
|
|
20
|
+
declare function Elephant({ pose, size, animated, title, className, ...rest }: Readonly<ElephantProps>): React.JSX.Element;
|
|
21
21
|
|
|
22
22
|
/** @deprecated Since 3.55 (ADR-006, krizaka-ui#674): no product uses it. Removed in 4.0. */
|
|
23
23
|
declare const ELEPHANT: {
|
package/dist/elephant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/elephant/geometry.ts","../src/elephant/elephant.tsx"],"sourcesContent":["/**\n * The elephant's geometry (200 × 200 view box, a pen line of 8, square caps, mitred joins — the Cahier grammar of the\n * marks and of @krizaka/icons: straight runs and 45° cuts, no rounded outline). It faces right. Two poses of one\n * animal: `standing`, the ear folded down beside the head, and `flying`, the ear spread up like a wing (the darija\n * joke: « l'éléphant avec ses oreilles, il peut voler »), the legs tucked, three lines of wind behind.\n *\n * The body and the trunk are sage, the ear and the wing sand: the two stops of a sand → sage gradient, each ≥ 3:1 on the page surfaces of both themes. Flat colours: no glow, no gradient.\n */\nexport const SAND = \"#a4773d\";\nexport const SAGE = \"#5d894d\";\n\n/** @deprecated Since 3.55 (ADR-006, krizaka-ui#674): no product uses it. Removed in 4.0. */\nexport const ELEPHANT = {\n viewBox: \"0 0 200 200\",\n stroke: 8,\n sand: SAND,\n sage: SAGE,\n /** The eye: one node, a filled dot. */\n eye: { cx: 154, cy: 66, r: 5 },\n standing: {\n /** Body, head and the two legs, one closed outline: straight runs and 45° cuts. */\n body: \"M30 88 L44 74 H112 V54 L126 40 H158 L176 56 V100 L168 108 H132 V168 H108 V138 H62 V168 H38 V138 H30 Z\",\n /** The trunk: down from the head's front, curling up at its tip. */\n trunk: \"M164 108 V146 L172 158 H184 V144\",\n /** The ear, folded down over the shoulder. */\n ear: \"M116 52 L92 56 L84 100 L104 124 L128 112 Z\",\n tail: \"M30 90 L20 108 V118\",\n },\n flying: {\n body: \"M30 88 L44 74 H112 V54 L126 40 H158 L176 56 V100 L168 108 H132 V140 H108 V128 H62 V140 H38 V128 H30 Z\",\n trunk: \"M164 108 V142 L172 154 H184 V140\",\n /** The ear, spread up and back: the wing. */\n ear: \"M116 78 L120 30 L90 10 L78 34 L52 24 L56 52 L30 60 L66 84 Z\",\n tail: \"M30 90 L18 102 V112\",\n wind: \"M22 150 H50 M12 166 H44 M32 180 H58\",\n },\n /** The flap: a few degrees around the shoulder, 1.6 s. */\n motion: { flap: 1.6, origin: \"114px 80px\", angle: 7 },\n} as const;\n","import type { SVGProps } from \"react\";\n\nimport { warnDeprecated } from \"../deprecated\";\nimport { ELEPHANT as G } from \"./geometry\";\n\nexport interface ElephantProps extends Omit<SVGProps<SVGSVGElement>, \"width\" | \"height\" | \"title\"> {\n /** `standing` with the ear folded down, or `flying` with the ear spread like a wing. */\n pose?: \"standing\" | \"flying\";\n /** Width and height in pixels. */\n size?: number;\n /** The wing flaps gently (a flying elephant only). Off with `false`; always off under prefers-reduced-motion. */\n animated?: boolean;\n /** An accessible name (the mark becomes an image); without it the mark is decorative. */\n title?: string;\n}\n\nconst CSS = `\n.kz-elephant-flap { transform-box: view-box; transform-origin: ${G.motion.origin}; animation: kz-elephant-flap ${G.motion.flap}s ease-in-out infinite; }\n@keyframes kz-elephant-flap { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-${G.motion.angle}deg); } }\n@media (prefers-reduced-motion: reduce) { .kz-elephant-flap { animation: none; } }\n`;\n\nconst line = { strokeWidth: G.stroke, strokeLinecap: \"square\", strokeLinejoin: \"miter\", fill: \"none\" } as const;\n\n/**\n * The elephant: a small, playful mark from the neighbour joke — « the elephant with those ears can fly ». Not a product\n * logo: a quiet figure for the hero of a page or the closing of a chat. Sage body, sand ear, flat colours that read on\n * both themes; decorative by default.\n * @deprecated Since 3.55 (ADR-006, krizaka-ui#674): no product uses it. Removed in 4.0.\n */\nexport function Elephant({ pose = \"standing\", size = 64, animated = true, title, className, ...rest }: ElephantProps) {\n warnDeprecated(\"elephant\");\n const flying = pose === \"flying\";\n const p = flying ? G.flying : G.standing;\n const a11y = title ? { role: \"img\" as const, \"aria-label\": title } : { \"aria-hidden\": true as const };\n return (\n <svg width={size} height={size} viewBox={G.viewBox} xmlns=\"http://www.w3.org/2000/svg\" className={className} data-pose={pose} {...a11y} {...rest}>\n {flying && animated ? <style>{CSS}</style> : null}\n {flying ? <path d={G.flying.wind} stroke={G.sage} opacity=\".45\" {...line} /> : null}\n <path d={p.body} stroke={G.sage} {...line} />\n <path d={p.trunk} stroke={G.sage} {...line} />\n <path d={p.tail} stroke={G.sage} {...line} />\n <g className={flying && animated ? \"kz-elephant-flap\" : undefined}>\n <path d={p.ear} stroke={G.sand} {...line} />\n </g>\n <circle cx={G.eye.cx} cy={G.eye.cy} r={G.eye.r} fill={G.sage} />\n </svg>\n );\n}\n"],"mappings":";;;;;;AAQO,IAAM,OAAO;AACb,IAAM,OAAO;AAGb,IAAM,WAAW;AAAA,EACtB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA;AAAA,EAEN,KAAK,EAAE,IAAI,KAAK,IAAI,IAAI,GAAG,EAAE;AAAA,EAC7B,UAAU;AAAA;AAAA,IAER,MAAM;AAAA;AAAA,IAEN,OAAO;AAAA;AAAA,IAEP,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA;AAAA,IAEP,KAAK;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,QAAQ,EAAE,MAAM,KAAK,QAAQ,cAAc,OAAO,EAAE;AACtD;;;ACFI,SACwB,KADxB;AApBJ,IAAM,MAAM;AAAA,iEACqD,SAAE,OAAO,MAAM,iCAAiC,SAAE,OAAO,IAAI;AAAA,+FAC/B,SAAE,OAAO,KAAK;AAAA;AAAA;AAI7G,IAAM,OAAO,EAAE,aAAa,SAAE,QAAQ,eAAe,UAAU,gBAAgB,SAAS,MAAM,OAAO;AAQ9F,SAAS,SAAS,EAAE,OAAO,YAAY,OAAO,IAAI,WAAW,MAAM,OAAO,WAAW,GAAG,KAAK,
|
|
1
|
+
{"version":3,"sources":["../src/elephant/geometry.ts","../src/elephant/elephant.tsx"],"sourcesContent":["/**\n * The elephant's geometry (200 × 200 view box, a pen line of 8, square caps, mitred joins — the Cahier grammar of the\n * marks and of @krizaka/icons: straight runs and 45° cuts, no rounded outline). It faces right. Two poses of one\n * animal: `standing`, the ear folded down beside the head, and `flying`, the ear spread up like a wing (the darija\n * joke: « l'éléphant avec ses oreilles, il peut voler »), the legs tucked, three lines of wind behind.\n *\n * The body and the trunk are sage, the ear and the wing sand: the two stops of a sand → sage gradient, each ≥ 3:1 on the page surfaces of both themes. Flat colours: no glow, no gradient.\n */\nexport const SAND = \"#a4773d\";\nexport const SAGE = \"#5d894d\";\n\n/** @deprecated Since 3.55 (ADR-006, krizaka-ui#674): no product uses it. Removed in 4.0. */\nexport const ELEPHANT = {\n viewBox: \"0 0 200 200\",\n stroke: 8,\n sand: SAND,\n sage: SAGE,\n /** The eye: one node, a filled dot. */\n eye: { cx: 154, cy: 66, r: 5 },\n standing: {\n /** Body, head and the two legs, one closed outline: straight runs and 45° cuts. */\n body: \"M30 88 L44 74 H112 V54 L126 40 H158 L176 56 V100 L168 108 H132 V168 H108 V138 H62 V168 H38 V138 H30 Z\",\n /** The trunk: down from the head's front, curling up at its tip. */\n trunk: \"M164 108 V146 L172 158 H184 V144\",\n /** The ear, folded down over the shoulder. */\n ear: \"M116 52 L92 56 L84 100 L104 124 L128 112 Z\",\n tail: \"M30 90 L20 108 V118\",\n },\n flying: {\n body: \"M30 88 L44 74 H112 V54 L126 40 H158 L176 56 V100 L168 108 H132 V140 H108 V128 H62 V140 H38 V128 H30 Z\",\n trunk: \"M164 108 V142 L172 154 H184 V140\",\n /** The ear, spread up and back: the wing. */\n ear: \"M116 78 L120 30 L90 10 L78 34 L52 24 L56 52 L30 60 L66 84 Z\",\n tail: \"M30 90 L18 102 V112\",\n wind: \"M22 150 H50 M12 166 H44 M32 180 H58\",\n },\n /** The flap: a few degrees around the shoulder, 1.6 s. */\n motion: { flap: 1.6, origin: \"114px 80px\", angle: 7 },\n} as const;\n","import type { SVGProps } from \"react\";\n\nimport { warnDeprecated } from \"../deprecated\";\nimport { ELEPHANT as G } from \"./geometry\";\n\nexport interface ElephantProps extends Omit<SVGProps<SVGSVGElement>, \"width\" | \"height\" | \"title\"> {\n /** `standing` with the ear folded down, or `flying` with the ear spread like a wing. */\n pose?: \"standing\" | \"flying\";\n /** Width and height in pixels. */\n size?: number;\n /** The wing flaps gently (a flying elephant only). Off with `false`; always off under prefers-reduced-motion. */\n animated?: boolean;\n /** An accessible name (the mark becomes an image); without it the mark is decorative. */\n title?: string;\n}\n\nconst CSS = `\n.kz-elephant-flap { transform-box: view-box; transform-origin: ${G.motion.origin}; animation: kz-elephant-flap ${G.motion.flap}s ease-in-out infinite; }\n@keyframes kz-elephant-flap { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-${G.motion.angle}deg); } }\n@media (prefers-reduced-motion: reduce) { .kz-elephant-flap { animation: none; } }\n`;\n\nconst line = { strokeWidth: G.stroke, strokeLinecap: \"square\", strokeLinejoin: \"miter\", fill: \"none\" } as const;\n\n/**\n * The elephant: a small, playful mark from the neighbour joke — « the elephant with those ears can fly ». Not a product\n * logo: a quiet figure for the hero of a page or the closing of a chat. Sage body, sand ear, flat colours that read on\n * both themes; decorative by default.\n * @deprecated Since 3.55 (ADR-006, krizaka-ui#674): no product uses it. Removed in 4.0.\n */\nexport function Elephant({ pose = \"standing\", size = 64, animated = true, title, className, ...rest }: Readonly<ElephantProps>) {\n warnDeprecated(\"elephant\");\n const flying = pose === \"flying\";\n const p = flying ? G.flying : G.standing;\n const a11y = title ? { role: \"img\" as const, \"aria-label\": title } : { \"aria-hidden\": true as const };\n return (\n <svg width={size} height={size} viewBox={G.viewBox} xmlns=\"http://www.w3.org/2000/svg\" className={className} data-pose={pose} {...a11y} {...rest}>\n {flying && animated ? <style>{CSS}</style> : null}\n {flying ? <path d={G.flying.wind} stroke={G.sage} opacity=\".45\" {...line} /> : null}\n <path d={p.body} stroke={G.sage} {...line} />\n <path d={p.trunk} stroke={G.sage} {...line} />\n <path d={p.tail} stroke={G.sage} {...line} />\n <g className={flying && animated ? \"kz-elephant-flap\" : undefined}>\n <path d={p.ear} stroke={G.sand} {...line} />\n </g>\n <circle cx={G.eye.cx} cy={G.eye.cy} r={G.eye.r} fill={G.sage} />\n </svg>\n );\n}\n"],"mappings":";;;;;;AAQO,IAAM,OAAO;AACb,IAAM,OAAO;AAGb,IAAM,WAAW;AAAA,EACtB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA;AAAA,EAEN,KAAK,EAAE,IAAI,KAAK,IAAI,IAAI,GAAG,EAAE;AAAA,EAC7B,UAAU;AAAA;AAAA,IAER,MAAM;AAAA;AAAA,IAEN,OAAO;AAAA;AAAA,IAEP,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA;AAAA,IAEP,KAAK;AAAA,IACL,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,QAAQ,EAAE,MAAM,KAAK,QAAQ,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AG,MAAM,SAAE,MAAM;AAAA,KAChE;AAEJ;","names":[]}
|
package/dist/embed-facade.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ interface EmbedFacadeProps extends Omit<React.ComponentProps<"div">, "title" | "
|
|
|
31
31
|
onLoad?: () => void;
|
|
32
32
|
}
|
|
33
33
|
/** A short video from a platform, behind a button: the frame exists only after the click. */
|
|
34
|
-
declare function EmbedFacade({ platform, url, title, playLabel, poster, notice, aspectRatio, onLoad, className, style, ...props }: EmbedFacadeProps): React.JSX.Element | null;
|
|
34
|
+
declare function EmbedFacade({ platform, url, title, playLabel, poster, notice, aspectRatio, onLoad, className, style, ...props }: Readonly<EmbedFacadeProps>): React.JSX.Element | null;
|
|
35
35
|
|
|
36
36
|
export { EMBED_PLATFORMS, EmbedFacade, embedUrl, isOwnPoster };
|
|
37
37
|
export type { EmbedFacadeProps, EmbedPlatform };
|
package/dist/embed-facade.js
CHANGED
|
@@ -33,7 +33,9 @@ var youtube = (host, path) => {
|
|
|
33
33
|
};
|
|
34
34
|
var instagram = (host, path) => {
|
|
35
35
|
const match = INSTAGRAM_HOSTS.has(host) ? /^\/(?:[\w.]{1,30}\/)?(p|reel|reels|tv)\/([\w-]{5,40})\/?$/.exec(path) : null;
|
|
36
|
-
|
|
36
|
+
if (!match) return null;
|
|
37
|
+
const kind = match[1] === "reels" ? "reel" : match[1];
|
|
38
|
+
return `https://www.instagram.com/${kind}/${match[2]}/embed`;
|
|
37
39
|
};
|
|
38
40
|
var PARSERS = { tiktok, "youtube-shorts": youtube, instagram };
|
|
39
41
|
function embedUrl(platform, url) {
|
package/dist/embed-facade.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/embed-facade/embed-facade.tsx","../src/embed-facade/embed-url.ts"],"sourcesContent":["\"use client\";\n\n// A click-to-load facade for a platform's short video (krizaka-ui#605, the lite-youtube-embed pattern). Until the visitor\n// asks, nothing is requested from TikTok, YouTube or Instagram: no frame, no script, no platform picture. The poster is the\n// host's own copy. After the click: one frame, a minimal sandbox and permissions. Loi 25: no third-party tracker without consent.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { EMBED_PLATFORMS, type EmbedPlatform, embedUrl, isOwnPoster } from \"./embed-url\";\n\nexport interface EmbedFacadeProps extends Omit<React.ComponentProps<\"div\">, \"title\" | \"children\" | \"onLoad\"> {\n /** Which platform's frame to load. */\n platform: EmbedPlatform;\n /** The public address of the post (`embedUrl` validates it; anything else renders nothing). */\n url: string;\n /** The accessible name of the video (\"Latest reel\"), passed translated: it names the frame once loaded. */\n title: string;\n /** The button: what it does and which platform it loads (\"Load TikTok and play\"), passed translated. */\n playLabel: string;\n /** The host's own copy of the picture (never an address on the platform: those are refused, they would be a request). */\n poster?: string;\n /** A line under the button, for what the platform will receive on the click (translated). */\n notice?: React.ReactNode;\n /** The ratio of the box when it stands alone; inside a television's screen it fills its parent. @default \"9 / 16\" */\n aspectRatio?: string;\n /** Called once, when the visitor has asked and the frame is added. */\n onLoad?: () => void;\n}\n\nconst SANDBOX = \"allow-scripts allow-same-origin allow-presentation allow-popups allow-popups-to-escape-sandbox\";\n\n/** A short video from a platform, behind a button: the frame exists only after the click. */\nexport function EmbedFacade({ platform, url, title, playLabel, poster, notice, aspectRatio = \"9 / 16\", onLoad, className, style, ...props }: EmbedFacadeProps) {\n const frame = embedUrl(platform, url);\n const [loaded, setLoaded] = React.useState(false);\n const ref = React.useRef<HTMLIFrameElement>(null);\n React.useEffect(() => {\n if (loaded) ref.current?.focus();\n }, [loaded]);\n if (!frame) return null;\n const load = () => {\n setLoaded(true);\n onLoad?.();\n };\n return (\n <div\n role=\"group\"\n aria-label={title}\n className={cn(\"kz-embed\", className)}\n data-platform={platform}\n data-loaded={loaded ? \"\" : undefined}\n style={{ ...style, [\"--kz-embed-ratio\" as string]: aspectRatio }}\n {...props}\n >\n {loaded ? (\n <iframe ref={ref} src={frame} title={title} sandbox={SANDBOX} allow=\"fullscreen; encrypted-media\" allowFullScreen referrerPolicy=\"strict-origin-when-cross-origin\" className=\"kz-embed-frame\" />\n ) : (\n <>\n {poster && isOwnPoster(poster) && <img src={poster} alt=\"\" loading=\"lazy\" decoding=\"async\" referrerPolicy=\"no-referrer\" className=\"kz-embed-poster\" />}\n <div className=\"kz-embed-gate\">\n <button type=\"button\" onClick={load} className=\"kz-embed-play\" data-platform-name={EMBED_PLATFORMS[platform]}>\n <svg aria-hidden=\"true\" focusable=\"false\" viewBox=\"0 0 16 16\" width=\"16\" height=\"16\"><path d=\"M4 2.5v11l9-5.5Z\" fill=\"currentColor\" /></svg>\n <span>{playLabel}</span>\n </button>\n {notice && <p className=\"kz-embed-notice\">{notice}</p>}\n </div>\n </>\n )}\n </div>\n );\n}\n","// The pure part of the facade (krizaka-ui#605): which addresses may ever be embedded, and what the frame's address is.\n// Nothing here touches the network or the DOM, so a server (the shop's editor) can validate with the same function the page uses.\n\n/** The platforms a facade can load after a click. */\nexport type EmbedPlatform = \"tiktok\" | \"youtube-shorts\" | \"instagram\";\n\n/** The platforms' names, as proper nouns (they are not translated). */\nexport const EMBED_PLATFORMS: Readonly<Record<EmbedPlatform, string>> = Object.freeze({ tiktok: \"TikTok\", \"youtube-shorts\": \"YouTube Shorts\", instagram: \"Instagram\" });\n\nconst TIKTOK_HOSTS = new Set([\"tiktok.com\", \"www.tiktok.com\"]);\nconst YOUTUBE_HOSTS = new Set([\"youtube.com\", \"www.youtube.com\", \"m.youtube.com\"]);\nconst INSTAGRAM_HOSTS = new Set([\"instagram.com\", \"www.instagram.com\"]);\n\n/** Every host a platform's frame or picture lives on: a poster served from one of them would be a request before the click. */\nconst PLATFORM_DOMAINS = [\"tiktok.com\", \"tiktokcdn.com\", \"tiktokcdn-us.com\", \"youtube.com\", \"youtu.be\", \"youtube-nocookie.com\", \"ytimg.com\", \"googlevideo.com\", \"instagram.com\", \"cdninstagram.com\", \"fbcdn.net\", \"facebook.com\"];\n\nfunction parse(url: string): URL | null {\n try {\n const u = new URL(url);\n // https only, no credentials, no port: the address is a public post, nothing else.\n if (u.protocol !== \"https:\" || u.username || u.password || u.port) return null;\n return u;\n } catch {\n return null;\n }\n}\n\nconst tiktok = (host: string, path: string): string | null => {\n const id = TIKTOK_HOSTS.has(host) ? /^\\/@[\\w.-]{1,64}\\/video\\/(\\d{8,25})\\/?$/.exec(path)?.[1] : undefined;\n return id ? `https://www.tiktok.com/embed/v2/${id}` : null;\n};\n\nconst youtube = (host: string, path: string): string | null => {\n let id: string | undefined;\n if (YOUTUBE_HOSTS.has(host)) id = /^\\/shorts\\/([\\w-]{11})\\/?$/.exec(path)?.[1];\n else if (host === \"youtu.be\") id = /^\\/([\\w-]{11})\\/?$/.exec(path)?.[1];\n return id ? `https://www.youtube-nocookie.com/embed/${id}` : null;\n};\n\nconst instagram = (host: string, path: string): string | null => {\n const match = INSTAGRAM_HOSTS.has(host) ? /^\\/(?:[\\w.]{1,30}\\/)?(p|reel|reels|tv)\\/([\\w-]{5,40})\\/?$/.exec(path) : null;\n return match ? `https://www.instagram.com/${match[1] === \"reels\" ? \"reel\" : match[1]}/${match[2]}/embed` : null;\n};\n\nconst PARSERS: Readonly<Record<EmbedPlatform, (host: string, path: string) => string | null>> = { tiktok, \"youtube-shorts\": youtube, instagram };\n\n/**\n * The address of the platform's frame for a public post, or `null` for anything else: another host, `http:`, a short\n * link we cannot resolve without asking the platform, a profile page. Exact hosts, exact paths.\n */\nexport function embedUrl(platform: EmbedPlatform, url: string): string | null {\n const u = parse(url);\n return u ? PARSERS[platform](u.hostname.toLowerCase(), u.pathname) : null;\n}\n\n/** Whether a poster may be drawn before the click: a path of the host's own origin, or an https picture that is not on a platform's domain (the host copies it to its own storage). */\nexport function isOwnPoster(poster: string): boolean {\n if (poster.startsWith(\"/\") && !poster.startsWith(\"//\")) return true;\n // An inline picture is no request at all.\n if (/^data:image\\/(?:png|jpeg|webp|gif|svg\\+xml)[;,]/i.test(poster)) return true;\n const u = parse(poster);\n if (!u) return false;\n const host = u.hostname.toL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,eAAa,SAAS,KAAK;AAAA,MAC3B,OAAO,EAAE,GAAG,OAAO,CAAC,kBAA4B,GAAG,YAAY;AAAA,MAC9D,GAAG;AAAA,MAEH,mBACC,oBAAC,YAAO,KAAU,KAAK,OAAO,OAAc,SAAS,SAAS,OAAM,+BAA8B,iBAAe,MAAC,gBAAe,mCAAkC,WAAU,kBAAiB,IAE9L,iCACG;AAAA,kBAAU,YAAY,MAAM,KAAK,oBAAC,SAAI,KAAK,QAAQ,KAAI,IAAG,SAAQ,QAAO,UAAS,SAAQ,gBAAe,eAAc,WAAU,mBAAkB;AAAA,QACpJ,qBAAC,SAAI,WAAU,iBACb;AAAA,+BAAC,YAAO,MAAK,UAAS,SAAS,MAAM,WAAU,iBAAgB,sBAAoB,gBAAgB,QAAQ,GACzG;AAAA,gCAAC,SAAI,eAAY,QAAO,WAAU,SAAQ,SAAQ,aAAY,OAAM,MAAK,QAAO,MAAK,8BAAC,UAAK,GAAE,oBAAmB,MAAK,gBAAe,GAAE;AAAA,YACtI,oBAAC,UAAM,qBAAU;AAAA,aACnB;AAAA,UACC,UAAU,oBAAC,OAAE,WAAU,mBAAmB,kBAAO;AAAA,WACpD;AAAA,SACF;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/embed-facade/embed-facade.tsx","../src/embed-facade/embed-url.ts"],"sourcesContent":["\"use client\";\n\n// A click-to-load facade for a platform's short video (krizaka-ui#605, the lite-youtube-embed pattern). Until the visitor\n// asks, nothing is requested from TikTok, YouTube or Instagram: no frame, no script, no platform picture. The poster is the\n// host's own copy. After the click: one frame, a minimal sandbox and permissions. Loi 25: no third-party tracker without consent.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { EMBED_PLATFORMS, type EmbedPlatform, embedUrl, isOwnPoster } from \"./embed-url\";\n\nexport interface EmbedFacadeProps extends Omit<React.ComponentProps<\"div\">, \"title\" | \"children\" | \"onLoad\"> {\n /** Which platform's frame to load. */\n platform: EmbedPlatform;\n /** The public address of the post (`embedUrl` validates it; anything else renders nothing). */\n url: string;\n /** The accessible name of the video (\"Latest reel\"), passed translated: it names the frame once loaded. */\n title: string;\n /** The button: what it does and which platform it loads (\"Load TikTok and play\"), passed translated. */\n playLabel: string;\n /** The host's own copy of the picture (never an address on the platform: those are refused, they would be a request). */\n poster?: string;\n /** A line under the button, for what the platform will receive on the click (translated). */\n notice?: React.ReactNode;\n /** The ratio of the box when it stands alone; inside a television's screen it fills its parent. @default \"9 / 16\" */\n aspectRatio?: string;\n /** Called once, when the visitor has asked and the frame is added. */\n onLoad?: () => void;\n}\n\nconst SANDBOX = \"allow-scripts allow-same-origin allow-presentation allow-popups allow-popups-to-escape-sandbox\";\n\n/** A short video from a platform, behind a button: the frame exists only after the click. */\nexport function EmbedFacade({ platform, url, title, playLabel, poster, notice, aspectRatio = \"9 / 16\", onLoad, className, style, ...props }: Readonly<EmbedFacadeProps>) {\n const frame = embedUrl(platform, url);\n const [loaded, setLoaded] = React.useState(false);\n const ref = React.useRef<HTMLIFrameElement>(null);\n React.useEffect(() => {\n if (loaded) ref.current?.focus();\n }, [loaded]);\n if (!frame) return null;\n const load = () => {\n setLoaded(true);\n onLoad?.();\n };\n return (\n <div\n role=\"group\"\n aria-label={title}\n className={cn(\"kz-embed\", className)}\n data-platform={platform}\n data-loaded={loaded ? \"\" : undefined}\n style={{ ...style, [\"--kz-embed-ratio\" as string]: aspectRatio }}\n {...props}\n >\n {loaded ? (\n <iframe ref={ref} src={frame} title={title} sandbox={SANDBOX} allow=\"fullscreen; encrypted-media\" allowFullScreen referrerPolicy=\"strict-origin-when-cross-origin\" className=\"kz-embed-frame\" />\n ) : (\n <>\n {poster && isOwnPoster(poster) && <img src={poster} alt=\"\" loading=\"lazy\" decoding=\"async\" referrerPolicy=\"no-referrer\" className=\"kz-embed-poster\" />}\n <div className=\"kz-embed-gate\">\n <button type=\"button\" onClick={load} className=\"kz-embed-play\" data-platform-name={EMBED_PLATFORMS[platform]}>\n <svg aria-hidden=\"true\" focusable=\"false\" viewBox=\"0 0 16 16\" width=\"16\" height=\"16\"><path d=\"M4 2.5v11l9-5.5Z\" fill=\"currentColor\" /></svg>\n <span>{playLabel}</span>\n </button>\n {notice && <p className=\"kz-embed-notice\">{notice}</p>}\n </div>\n </>\n )}\n </div>\n );\n}\n","// The pure part of the facade (krizaka-ui#605): which addresses may ever be embedded, and what the frame's address is.\n// Nothing here touches the network or the DOM, so a server (the shop's editor) can validate with the same function the page uses.\n\n/** The platforms a facade can load after a click. */\nexport type EmbedPlatform = \"tiktok\" | \"youtube-shorts\" | \"instagram\";\n\n/** The platforms' names, as proper nouns (they are not translated). */\nexport const EMBED_PLATFORMS: Readonly<Record<EmbedPlatform, string>> = Object.freeze({ tiktok: \"TikTok\", \"youtube-shorts\": \"YouTube Shorts\", instagram: \"Instagram\" });\n\nconst TIKTOK_HOSTS = new Set([\"tiktok.com\", \"www.tiktok.com\"]);\nconst YOUTUBE_HOSTS = new Set([\"youtube.com\", \"www.youtube.com\", \"m.youtube.com\"]);\nconst INSTAGRAM_HOSTS = new Set([\"instagram.com\", \"www.instagram.com\"]);\n\n/** Every host a platform's frame or picture lives on: a poster served from one of them would be a request before the click. */\nconst PLATFORM_DOMAINS = [\"tiktok.com\", \"tiktokcdn.com\", \"tiktokcdn-us.com\", \"youtube.com\", \"youtu.be\", \"youtube-nocookie.com\", \"ytimg.com\", \"googlevideo.com\", \"instagram.com\", \"cdninstagram.com\", \"fbcdn.net\", \"facebook.com\"];\n\nfunction parse(url: string): URL | null {\n try {\n const u = new URL(url);\n // https only, no credentials, no port: the address is a public post, nothing else.\n if (u.protocol !== \"https:\" || u.username || u.password || u.port) return null;\n return u;\n } catch {\n return null;\n }\n}\n\nconst tiktok = (host: string, path: string): string | null => {\n const id = TIKTOK_HOSTS.has(host) ? /^\\/@[\\w.-]{1,64}\\/video\\/(\\d{8,25})\\/?$/.exec(path)?.[1] : undefined;\n return id ? `https://www.tiktok.com/embed/v2/${id}` : null;\n};\n\nconst youtube = (host: string, path: string): string | null => {\n let id: string | undefined;\n if (YOUTUBE_HOSTS.has(host)) id = /^\\/shorts\\/([\\w-]{11})\\/?$/.exec(path)?.[1];\n else if (host === \"youtu.be\") id = /^\\/([\\w-]{11})\\/?$/.exec(path)?.[1];\n return id ? `https://www.youtube-nocookie.com/embed/${id}` : null;\n};\n\nconst instagram = (host: string, path: string): string | null => {\n const match = INSTAGRAM_HOSTS.has(host) ? /^\\/(?:[\\w.]{1,30}\\/)?(p|reel|reels|tv)\\/([\\w-]{5,40})\\/?$/.exec(path) : null;\n if (!match) return null;\n const kind = match[1] === \"reels\" ? \"reel\" : match[1];\n return `https://www.instagram.com/${kind}/${match[2]}/embed`;\n};\n\nconst PARSERS: Readonly<Record<EmbedPlatform, (host: string, path: string) => string | null>> = { tiktok, \"youtube-shorts\": youtube, instagram };\n\n/**\n * The address of the platform's frame for a public post, or `null` for anything else: another host, `http:`, a short\n * link we cannot resolve without asking the platform, a profile page. Exact hosts, exact paths.\n */\nexport function embedUrl(platform: EmbedPlatform, url: string): string | null {\n const u = parse(url);\n return u ? PARSERS[platform](u.hostname.toLowerCase(), u.pathname) : null;\n}\n\n/** Whether a poster may be drawn before the click: a path of the host's own origin, or an https picture that is not on a platform's domain (the host copies it to its own storage). */\nexport function isOwnPoster(poster: string): boolean {\n if (poster.startsWith(\"/\") && !poster.startsWith(\"//\")) return true;\n // An inline picture is no request at all.\n if (/^data:image\\/(?:png|jpeg|webp|gif|svg\\+xml)[;,]/i.test(poster)) return true;\n const u = parse(poster);\n if (!u) return false;\n const host = u.hostname.toLowerCase();\n return !PLATFORM_DOMAINS.some((domain) => host === domain || host.endsWith(`.${domain}`));\n}\n"],"mappings":";;;;;;AAKA,YAAY,WAAW;;;ACEhB,IAAM,kBAA2D,OAAO,OAAO,EAAE,QAAQ,UAAU,kBAAkB,kBAAkB,WAAW,YAAY,CAAC;AAEtK,IAAM,eAAe,oBAAI,IAAI,CAAC,cAAc,gBAA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CAAkC,WAAU,kBAAiB,IAE9L,iCACG;AAAA,kBAAU,YAAY,MAAM,KAAK,oBAAC,SAAI,KAAK,QAAQ,KAAI,IAAG,SAAQ,QAAO,UAAS,SAAQ,gBAAe,eAAc,WAAU,mBAAkB;AAAA,QACpJ,qBAAC,SAAI,WAAU,iBACb;AAAA,+BAAC,YAAO,MAAK,UAAS,SAAS,MAAM,WAAU,iBAAgB,sBAAoB,gBAAgB,QAAQ,GACzG;AAAA,gCAAC,SAAI,eAAY,QAAO,WAAU,SAAQ,SAAQ,aAAY,OAAM,MAAK,QAAO,MAAK,8BAAC,UAAK,GAAE,oBAAmB,MAAK,gBAAe,GAAE;AAAA,YACtI,oBAAC,UAAM,qBAAU;AAAA,aACnB;AAAA,UACC,UAAU,oBAAC,OAAE,WAAU,mBAAmB,kBAAO;AAAA,WACpD;AAAA,SACF;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
package/dist/engine-flow.js
CHANGED
|
@@ -50,7 +50,10 @@ function flowGeometry(layout, count, conduit = "bezier") {
|
|
|
50
50
|
const paths = [];
|
|
51
51
|
const lengths = [];
|
|
52
52
|
for (const p of nodes) {
|
|
53
|
-
|
|
53
|
+
let end;
|
|
54
|
+
if (layout === "top-to-bottom") end = { x: hub.x + (p.x - hub.x) * FLOW_FAN, y: hub.y };
|
|
55
|
+
else if (layout === "left-to-right") end = { x: hub.x, y: hub.y + (p.y - hub.y) * FLOW_FAN };
|
|
56
|
+
else end = hub;
|
|
54
57
|
if (conduit === "straight") {
|
|
55
58
|
paths.push(`M${pt(p)} L${pt(end)}`);
|
|
56
59
|
lengths.push(Math.hypot(end.x - p.x, end.y - p.y));
|
|
@@ -179,12 +182,14 @@ function Stage({
|
|
|
179
182
|
] });
|
|
180
183
|
}
|
|
181
184
|
function flowData({ chosen, calm, saveData, trigger, density, compact }) {
|
|
185
|
+
let dataDensity = density === "normal" ? void 0 : density;
|
|
186
|
+
if (calm) dataDensity = "sparse";
|
|
182
187
|
return {
|
|
183
188
|
"data-active": chosen ? "" : void 0,
|
|
184
189
|
"data-calm": calm ? "" : void 0,
|
|
185
190
|
"data-still": saveData ? "" : void 0,
|
|
186
191
|
"data-trigger": calm || trigger === "always" ? void 0 : trigger,
|
|
187
|
-
"data-density":
|
|
192
|
+
"data-density": dataDensity,
|
|
188
193
|
"data-compact": compact ? "" : void 0
|
|
189
194
|
};
|
|
190
195
|
}
|
package/dist/engine-flow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/engine-flow/engine-flow.tsx","../src/engine-flow/geometry.ts"],"sourcesContent":["// Client (the node a visitor points at or focuses). An engine at the hub and the apps it serves around it: one conduit\n// per app, and photons that travel it — towards the hub (`in`: requests), back (`out`: results) or both — in the app's\n// brand colour going in and the hub's coming back. A planned app is drawn dim, its conduit dashed and still.\n//\n// Motion is the Krizaka signature's (motion.css): CSS animations of `stroke-dashoffset`, no animation frame, no canvas;\n// paused off screen (`data-motion-scope` → MotionObserver's `data-offscreen`), held while the page settles (`kz-loop`),\n// a still frame under reduced motion and Save-Data (the photons rest along their conduit). The stage keeps its aspect ratio and the\n// detail line its height: no layout shift.\n//\n// Anchoring: a conduit runs between the centres of the node's circle and of the hub's ring (the label and the caption hang\n// below them, out of the box), and both circles are opaque and drawn over it — so every conduit meets the circle at the point\n// facing the other end, whatever the layout and the number of nodes.\n//\n// Accessible: the drawing is hidden from assistive technology; every node is a real button named by its label, and the\n// detail line (polite live region) says the chosen node's description with its link. Pair it with a text version (a\n// list) in the page: the figure is a picture of it.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { type FlowConduit, flowGeometry, type FlowLayout } from \"./geometry\";\n\nexport interface EngineFlowNode {\n /** A stable id (`verikora`). */\n id: string;\n /** Its name, the button's accessible name (\"Verikora\"). */\n label: string;\n /** Its mark (a `ProductLogo`), decorative. */\n mark?: React.ReactNode;\n /** One line: what it uses the engine for — shown when the node is pointed at or focused. */\n description?: React.ReactNode;\n /** Where it lives (its site). */\n href?: string;\n /** The link's words (\"Visit dev.verikora.com\"); defaults to the label. */\n linkLabel?: React.ReactNode;\n /** Opens the link in a new tab. */\n external?: boolean;\n /** What travels: `in` towards the hub, `out` back from it, `both`.\n * @default \"in\" */\n flow?: \"in\" | \"out\" | \"both\";\n /** Not wired yet: drawn dim, its conduit dashed and still, no photon. */\n planned?: boolean;\n /** A word beside the name in the detail line (\"planned\"), passed translated. */\n status?: React.ReactNode;\n /** Its brand scope (`brand-verikora`): its conduit, photons and ring take its `--kz-accent`. */\n className?: string;\n}\n\nexport interface EngineFlowHub {\n /** The engine's name (\"Sovkora\"). */\n label: string;\n /** Its mark, decorative. */\n mark?: React.ReactNode;\n /** A line under the name (\"the engine\"). */\n caption?: React.ReactNode;\n /** Its brand scope; the photons coming back take its accent. */\n className?: string;\n}\n\nexport type EngineFlowProps = Omit<React.ComponentProps<\"figure\">, \"children\"> & {\n /** What the figure shows (\"Sovkora and the products it powers\"), passed translated. */\n label: string;\n /** The engine, at the hub. */\n hub: EngineFlowHub;\n /** The apps around it. */\n nodes: readonly EngineFlowNode[];\n /** How the nodes sit around the hub.\n * @default \"radial\" */\n layout?: FlowLayout;\n /** The layout under a 560 px wide container (a phone); `false` keeps `layout` everywhere.\n * @default \"top-to-bottom\" */\n compactLayout?: FlowLayout | false;\n /** `photons` travel the conduits; `none` draws them still.\n * @default \"photons\" */\n particles?: \"photons\" | \"none\";\n /** The conduits' shape.\n * @default \"bezier\" */\n conduit?: FlowConduit;\n /** The detail line before a node is chosen (\"Point at a product\"). */\n hint?: React.ReactNode;\n /** The node shown in the detail line at first. */\n defaultActive?: string;\n /** Photon speed, in units per second (the stage is 100 units wide).\n * @default 16 */\n speed?: number;\n /** How many photons share a conduit: `sparse` one or two, `normal` two to four, `dense` four to eight.\n * @default \"normal\" */\n density?: FlowDensity;\n /** When the photons travel: `always`; `hover` only while the pointer or focus is on the figure (they rest along the\n * conduits otherwise); `active` only on the conduit of the chosen node (the others show nothing). Off screen they\n * are always paused, and still under reduced motion.\n * @default \"always\" */\n trigger?: FlowTrigger;\n /** The photons' timing function: `linear` (a steady stream), `ease-in-out` (a pulse that swells and settles), or any\n * CSS `<easing-function>` (`cubic-bezier(.2,0,0,1)`, `steps(6)`).\n * @default \"linear\" */\n easing?: FlowEasing;\n /** Milliseconds between one conduit's photons and the next's: 0 sends them all together.\n * @default 300 */\n stagger?: number;\n /** The engine's mark swells slowly (a loop, still under reduced motion).\n * @default true */\n breathe?: boolean;\n /** The calm level, for a small frame (a tile of a home page): sparse photons at a low rate, a slow breath, no hint and\n * no detail line, nothing to tune. It plays only on screen and once the page has settled, and stays still under\n * reduced motion and Save-Data. Overrides `speed`, `density`, `stagger` and `trigger`.\n * @default false */\n calm?: boolean;\n};\n\n/** The calm level's pace: units per second, photons per conduit, milliseconds between conduits. */\nexport const CALM_FLOW = { speed: 4, density: \"sparse\", stagger: 1200 } as const satisfies { speed: number; density: FlowDensity; stagger: number };\n\nconst subscribeSaveData = (onChange: () => void) => {\n const c = (navigator as Navigator & { connection?: EventTarget }).connection;\n c?.addEventListener?.(\"change\", onChange);\n return () => c?.removeEventListener?.(\"change\", onChange);\n};\nconst readSaveData = () => (navigator as Navigator & { connection?: { saveData?: boolean } }).connection?.saveData === true;\n\n\nexport type FlowDensity = \"sparse\" | \"normal\" | \"dense\";\nexport type FlowTrigger = \"always\" | \"hover\" | \"active\";\nexport type FlowEasing = \"linear\" | \"ease-in-out\" | (string & {});\n\n/** How many photons a conduit of this length carries (evenly spaced, so the gap is `length / count`). */\nexport function photonCount(length: number, density: FlowDensity = \"normal\"): number {\n const base = Math.round(length / 16);\n if (density === \"sparse\") return Math.min(2, Math.max(1, Math.round(base / 2)));\n if (density === \"dense\") return Math.min(8, Math.max(4, base * 2));\n return Math.min(4, Math.max(2, base));\n}\n\nfunction Stage({\n layout,\n variant,\n nodes,\n hub,\n conduit,\n particles,\n speed,\n density,\n easing,\n stagger,\n breathe,\n active,\n onActive,\n detailId,\n}: {\n layout: FlowLayout;\n variant: \"wide\" | \"compact\";\n nodes: readonly EngineFlowNode[];\n hub: EngineFlowHub;\n conduit: FlowConduit;\n particles: \"photons\" | \"none\";\n speed: number;\n density: FlowDensity;\n easing: FlowEasing;\n stagger: number;\n breathe: boolean;\n active: string | undefined;\n onActive: (id: string) => void;\n detailId: string | undefined;\n}) {\n const g = flowGeometry(layout, nodes.length, conduit);\n const pct = (v: number, of: number) => `${((v / of) * 100).toFixed(3)}%`;\n return (\n <div className=\"kz-flow-stage\" data-variant={variant} data-layout={layout} style={{ aspectRatio: `${g.width} / ${g.height}` }}>\n <svg viewBox={`0 0 ${g.width} ${g.height}`} aria-hidden=\"true\" focusable=\"false\">\n {nodes.map((node, i) => {\n const flow = node.flow ?? \"in\";\n const length = g.lengths[i] ?? 0;\n // Photons per conduit (`density`), evenly spaced; the same speed on every conduit.\n const gap = length / photonCount(length, density);\n const period = gap / speed;\n const timing = (dir: \"in\" | \"out\") =>\n ({\n \"--kz-flow-gap\": gap.toFixed(3),\n animationDuration: `${period.toFixed(2)}s`,\n // Each conduit starts `stagger` ms after the previous (a negative delay: already under way); the way back is half a period behind.\n animationDelay: `${(-(((i * stagger) / 1000 + (dir === \"out\" ? period / 2 : 0)) % period)).toFixed(2)}s`,\n ...(easing !== \"linear\" ? { animationTimingFunction: easing } : {}),\n }) as React.CSSProperties;\n const lanes = node.planned || particles === \"none\" ? [] : flow === \"both\" ? ([\"in\", \"out\"] as const) : [flow];\n return (\n <g\n key={node.id}\n className={cn(\"kz-flow-link\", node.className)}\n data-flow={flow}\n data-planned={node.planned ? \"\" : undefined}\n data-active={active === node.id ? \"\" : undefined}\n >\n <path className=\"kz-flow-wire\" d={g.paths[i]} />\n {lanes.map((dir) => (\n <React.Fragment key={dir}>\n <path className=\"kz-flow-photon kz-loop\" data-dir={dir} data-halo=\"\" d={g.paths[i]} style={timing(dir)} />\n <path className=\"kz-flow-photon kz-loop\" data-dir={dir} d={g.paths[i]} style={timing(dir)} />\n </React.Fragment>\n ))}\n </g>\n );\n })}\n </svg>\n <div className={cn(\"kz-flow-hub\", hub.className)} style={{ left: pct(g.hub.x, g.width), top: pct(g.hub.y, g.height) }}>\n {hub.mark ? <span className={cn(\"kz-flow-hub-mark\", breathe && \"kz-loop\")}>{hub.mark}</span> : null}\n <span className=\"kz-flow-hub-text\">\n <span className=\"kz-flow-hub-label\">{hub.label}</span>\n {hub.caption ? <span className=\"kz-flow-hub-caption\">{hub.caption}</span> : null}\n </span>\n </div>\n <ul className=\"kz-flow-nodes\">\n {nodes.map((node, i) => {\n const p = g.nodes[i]!;\n const on = active === node.id;\n return (\n <li key={node.id} style={{ left: pct(p.x, g.width), top: pct(p.y, g.height) }}>\n <button\n type=\"button\"\n className={cn(\"kz-flow-node\", node.className)}\n data-active={on ? \"\" : undefined}\n data-planned={node.planned ? \"\" : undefined}\n aria-pressed={on}\n aria-controls={detailId}\n onPointerEnter={() => onActive(node.id)}\n onFocus={() => onActive(node.id)}\n onClick={() => onActive(node.id)}\n >\n {node.mark ? (\n <span className=\"kz-flow-node-mark\" aria-hidden=\"true\">\n {node.mark}\n </span>\n ) : null}\n <span className=\"kz-flow-node-label\">{node.label}</span>\n </button>\n </li>\n );\n })}\n </ul>\n </div>\n );\n}\n\ntype FlowDataInput = { chosen: boolean; calm: boolean; saveData: boolean; trigger: string; density: string; compact: boolean };\n\n/** The figure's data attributes: the CSS reads the state from them. */\nfunction flowData({ chosen, calm, saveData, trigger, density, compact }: FlowDataInput) {\n return {\n \"data-active\": chosen ? \"\" : undefined,\n \"data-calm\": calm ? \"\" : undefined,\n \"data-still\": saveData ? \"\" : undefined,\n \"data-trigger\": calm || trigger === \"always\" ? undefined : trigger,\n \"data-density\": calm ? \"sparse\" : density === \"normal\" ? undefined : density,\n \"data-compact\": compact ? \"\" : undefined,\n };\n}\n\n/** What the chosen node says, or the hint when none is chosen. */\nfunction FlowDetail({ id, chosen, hint }: { id: string; chosen: EngineFlowNode | undefined; hint: React.ReactNode }) {\n return (\n <figcaption id={id} className={cn(\"kz-flow-detail\", chosen?.className)} aria-live=\"polite\">\n {chosen ? (\n <>\n <strong>{chosen.label}</strong>\n {chosen.status ? <span className=\"kz-flow-status\">{chosen.status}</span> : null}\n {chosen.description ? <span> {chosen.description}</span> : null}\n {chosen.href ? (\n <>\n {\" \"}\n <a href={chosen.href} {...(chosen.external ? { target: \"_blank\", rel: \"noopener\" } : {})}>\n {chosen.linkLabel ?? chosen.label}\n <span aria-hidden=\"true\"> →</span>\n </a>\n </>\n ) : null}\n </>\n ) : (\n hint\n )}\n </figcaption>\n );\n}\n\n/** An engine at the hub and the apps it serves, with what travels between them. */\nexport function EngineFlow({\n label,\n hub,\n nodes,\n layout = \"radial\",\n compactLayout = \"top-to-bottom\",\n particles = \"photons\",\n conduit = \"bezier\",\n hint,\n defaultActive,\n speed = 16,\n density = \"normal\",\n trigger = \"always\",\n easing = \"linear\",\n stagger = 300,\n breathe = true,\n calm = false,\n className,\n ...props\n}: EngineFlowProps) {\n const [active, setActive] = React.useState<string | undefined>(defaultActive);\n const detailId = `${React.useId()}-detail`;\n const chosen = nodes.find((n) => n.id === active);\n const compact = compactLayout && compactLayout !== layout ? compactLayout : undefined;\n // Save-Data: the calm and the full levels both rest (a still frame, like reduced motion).\n const saveData = React.useSyncExternalStore(subscribeSaveData, readSaveData, () => false);\n const pace = calm ? CALM_FLOW : { speed: Math.max(1, speed), density, stagger: Math.max(0, stagger) };\n const stage = { nodes, hub, conduit, particles, ...pace, easing, breathe, active, onActive: setActive, detailId: calm ? undefined : detailId };\n return (\n <figure\n aria-label={label}\n className={cn(\"kz-flow\", className)}\n data-motion-scope=\"\"\n {...flowData({ chosen: Boolean(chosen), calm, saveData, trigger, density, compact: Boolean(compact) })}\n {...props}\n >\n <Stage layout={layout} variant=\"wide\" {...stage} />\n {compact ? <Stage layout={compact} variant=\"compact\" {...stage} /> : null}\n {calm ? null : <FlowDetail id={detailId} chosen={chosen} hint={hint} />}\n </figure>\n );\n}\n","// Server-safe, pure. The geometry of EngineFlow: where the hub and the nodes sit in a box 100 units wide, and the\n// conduit from each node to the hub (an SVG path drawn node → hub, and its length, so photons travel at one speed on\n// every conduit). No DOM: the same numbers on the server and in the browser.\n\n/** How the nodes are placed around the hub. */\nexport type FlowLayout = \"radial\" | \"top-to-bottom\" | \"left-to-right\";\n/** The shape of a conduit: an S-shaped cubic Bézier, or a straight line. */\nexport type FlowConduit = \"bezier\" | \"straight\";\n\nexport interface FlowPoint {\n x: number;\n y: number;\n}\n\nexport interface FlowGeometry {\n /** The box: 100 units wide, `height` units high (the stage keeps this aspect ratio, so nothing is distorted). */\n width: number;\n height: number;\n hub: FlowPoint;\n nodes: FlowPoint[];\n /** One path per node, from the node to the hub. */\n paths: string[];\n /** The length of each path, in units. */\n lengths: number[];\n}\n\n/** The box height per layout (the width is always 100). */\nexport const FLOW_HEIGHT: Record<FlowLayout, number> = { radial: 60, \"top-to-bottom\": 92, \"left-to-right\": 56 };\n\n/** How far a conduit lands from the hub's centre along the row, as a share of its node's offset: a small fan, kept inside the ring. */\nexport const FLOW_FAN = 0.1;\n\nconst r2 = (n: number) => Math.round(n * 100) / 100;\nconst pt = (p: FlowPoint) => `${r2(p.x)} ${r2(p.y)}`;\n\nfunction cubicLength(a: FlowPoint, b: FlowPoint, c: FlowPoint, d: FlowPoint): number {\n let length = 0;\n let prev = a;\n for (let i = 1; i <= 32; i++) {\n const t = i / 32;\n const u = 1 - t;\n const p = {\n x: u * u * u * a.x + 3 * u * u * t * b.x + 3 * u * t * t * c.x + t * t * t * d.x,\n y: u * u * u * a.y + 3 * u * u * t * b.y + 3 * u * t * t * c.y + t * t * t * d.y,\n };\n length += Math.hypot(p.x - prev.x, p.y - prev.y);\n prev = p;\n }\n return length;\n}\n\n/** The positions of `count` nodes around the hub. */\nexport function flowPositions(layout: FlowLayout, count: number): { hub: FlowPoint; nodes: FlowPoint[] } {\n const height = FLOW_HEIGHT[layout];\n const n = Math.max(0, count);\n if (layout === \"top-to-bottom\") {\n return { hub: { x: 50, y: 72 }, nodes: Array.from({ length: n }, (_, i) => ({ x: ((i + 0.5) * 100) / n, y: 13 })) };\n }\n if (layout === \"left-to-right\") {\n return { hub: { x: 80, y: height / 2 }, nodes: Array.from({ length: n }, (_, i) => ({ x: 12, y: ((i + 0.5) * height) / n })) };\n }\n // Radial: on an ellipse around the centre; an even count puts two nodes level with the hub (more room for labels).\n const hub = { x: 50, y: height / 2 };\n const start = n % 2 === 0 ? -90 + 180 / Math.max(n, 1) : -90;\n return {\n hub,\n nodes: Array.from({ length: n }, (_, i) => {\n const a = ((start + (360 / n) * i) * Math.PI) / 180;\n return { x: hub.x + 37 * Math.cos(a), y: hub.y + 20 * Math.sin(a) };\n }),\n };\n}\n\n/** The whole geometry of a flow: positions, conduits (node → hub) and their lengths. */\nexport function flowGeometry(layout: FlowLayout, count: number, conduit: FlowConduit = \"bezier\"): FlowGeometry {\n const { hub, nodes } = flowPositions(layout, count);\n const paths: string[] = [];\n const lengths: number[] = [];\n for (const p of nodes) {\n // Each conduit lands on its own point of the hub (a fan), so the lines stay apart where they meet.\n const end =\n layout === \"top-to-bottom\"\n ? { x: hub.x + (p.x - hub.x) * FLOW_FAN, y: hub.y }\n : layout === \"left-to-right\"\n ? { x: hub.x, y: hub.y + (p.y - hub.y) * FLOW_FAN }\n : hub;\n if (conduit === \"straight\") {\n paths.push(`M${pt(p)} L${pt(end)}`);\n lengths.push(Math.hypot(end.x - p.x, end.y - p.y));\n continue;\n }\n let c1: FlowPoint;\n let c2: FlowPoint;\n if (layout === \"top-to-bottom\") {\n const mid = (p.y + end.y) / 2;\n c1 = { x: p.x, y: mid };\n c2 = { x: end.x, y: mid };\n } else if (layout === \"left-to-right\") {\n const mid = (p.x + end.x) / 2;\n c1 = { x: mid, y: p.y };\n c2 = { x: mid, y: end.y };\n } else {\n // An S: leave the node bending one way, reach the hub bending the other.\n const dx = end.x - p.x;\n const dy = end.y - p.y;\n const len = Math.hypot(dx, dy) || 1;\n const k = 0.14 * len;\n const nx = -dy / len;\n const ny = dx / len;\n c1 = { x: p.x + dx * 0.35 + nx * k, y: p.y + dy * 0.35 + ny * k };\n c2 = { x: p.x + dx * 0.65 - nx * k, y: p.y + dy * 0.65 - ny * k };\n }\n paths.push(`M${pt(p)} C${pt(c1)} ${pt(c2)} ${pt(end)}`);\n lengths.push(cubicLength(p, c1, c2, end));\n }\n return { width: 100, height: FLOW_HEIGHT[layout], hub, nodes, paths, lengths };\n}\n"],"mappings":";;;;;;AAgBA,YAAY,WAAW;;;ACWhB,IAAM,cAA0C,EAAE,QAAQ,IAAI,iBAAiB,IAAI,iBAAiB,GAAG;AAGvG,IAAM,WAAW;AAExB,IAAM,KAAK,CAAC,MAAc,KAAK,MAAM,IAAI,GAAG,IAAI;AAChD,IAAM,KAAK,CAAC,MAAiB,GAAG,GAAG,EAAE,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;AAElD,SAAS,YAAY,GAAc,GAAc,GAAc,GAAsB;AACnF,MAAI,SAAS;AACb,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,KAAK,IAAI,KAAK;AAC5B,UAAM,IAAI,IAAI;AACd,UAAM,IAAI,IAAI;AACd,UAAM,IAAI;AAAA,MACR,GAAG,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,EAAE;AAAA,MAC/E,GAAG,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,EAAE;AAAA,IACjF;AACA,cAAU,KAAK,MAAM,EAAE,IAAI,KAAK,GAAG,EAAE,IAAI,KAAK,CAAC;AAC/C,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAGO,SAAS,cAAc,QAAoB,OAAuD;AACvG,QAAM,SAAS,YAAY,MAAM;AACjC,Q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OAAO;AAAA,EACP;AAAA,EACA,GAAG;AACL,GAAoB;AAClB,QAAM,CAAC,QAAQ,SAAS,IAAU,eAA6B,aAAa;AAC5E,QAAM,WAAW,GAAS,YAAM,CAAC;AACjC,QAAM,SAAS,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM;AAChD,QAAM,UAAU,iBAAiB,kBAAkB,SAAS,gBAAgB;AAE5E,QAAM,WAAiB,2BAAqB,mBAAmB,cAAc,MAAM,KAAK;AACxF,QAAM,OAAO,OAAO,YAAY,EAAE,OAAO,KAAK,IAAI,GAAG,KAAK,GAAG,SAAS,SAAS,KAAK,IAAI,GAAG,OAAO,EAAE;AACpG,QAAM,QAAQ,EAAE,OAAO,KAAK,SAAS,WAAW,GAAG,MAAM,QAAQ,SAAS,QAAQ,UAAU,WAAW,UAAU,OAAO,SAAY,SAAS;AAC7I,SACE;AAAA,IAAC;AAAA;AAAA,MACC,cAAY;AAAA,MACZ,WAAW,GAAG,WAAW,SAAS;AAAA,MAClC,qBAAkB;AAAA,MACjB,GAAG,SAAS,EAAE,QAAQ,QAAQ,MAAM,GAAG,MAAM,UAAU,SAAS,SAAS,SAAS,QAAQ,OAAO,EAAE,CAAC;AAAA,MACpG,GAAG;AAAA,MAEJ;AAAA,4BAAC,SAAM,QAAgB,SAAQ,QAAQ,GAAG,OAAO;AAAA,QAChD,UAAU,oBAAC,SAAM,QAAQ,SAAS,SAAQ,WAAW,GAAG,OAAO,IAAK;AAAA,QACpE,OAAO,OAAO,oBAAC,cAAW,IAAI,UAAU,QAAgB,MAAY;AAAA;AAAA;AAAA,EACvE;AAEJ;","names":["Fragment"]}
|
|
1
|
+
{"version":3,"sources":["../src/engine-flow/engine-flow.tsx","../src/engine-flow/geometry.ts"],"sourcesContent":["// Client (the node a visitor points at or focuses). An engine at the hub and the apps it serves around it: one conduit\n// per app, and photons that travel it — towards the hub (`in`: requests), back (`out`: results) or both — in the app's\n// brand colour going in and the hub's coming back. A planned app is drawn dim, its conduit dashed and still.\n//\n// Motion is the Krizaka signature's (motion.css): CSS animations of `stroke-dashoffset`, no animation frame, no canvas;\n// paused off screen (`data-motion-scope` → MotionObserver's `data-offscreen`), held while the page settles (`kz-loop`),\n// a still frame under reduced motion and Save-Data (the photons rest along their conduit). The stage keeps its aspect ratio and the\n// detail line its height: no layout shift.\n//\n// Anchoring: a conduit runs between the centres of the node's circle and of the hub's ring (the label and the caption hang\n// below them, out of the box), and both circles are opaque and drawn over it — so every conduit meets the circle at the point\n// facing the other end, whatever the layout and the number of nodes.\n//\n// Accessible: the drawing is hidden from assistive technology; every node is a real button named by its label, and the\n// detail line (polite live region) says the chosen node's description with its link. Pair it with a text version (a\n// list) in the page: the figure is a picture of it.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\nimport { type FlowConduit, flowGeometry, type FlowLayout } from \"./geometry\";\n\nexport interface EngineFlowNode {\n /** A stable id (`verikora`). */\n id: string;\n /** Its name, the button's accessible name (\"Verikora\"). */\n label: string;\n /** Its mark (a `ProductLogo`), decorative. */\n mark?: React.ReactNode;\n /** One line: what it uses the engine for — shown when the node is pointed at or focused. */\n description?: React.ReactNode;\n /** Where it lives (its site). */\n href?: string;\n /** The link's words (\"Visit dev.verikora.com\"); defaults to the label. */\n linkLabel?: React.ReactNode;\n /** Opens the link in a new tab. */\n external?: boolean;\n /** What travels: `in` towards the hub, `out` back from it, `both`.\n * @default \"in\" */\n flow?: \"in\" | \"out\" | \"both\";\n /** Not wired yet: drawn dim, its conduit dashed and still, no photon. */\n planned?: boolean;\n /** A word beside the name in the detail line (\"planned\"), passed translated. */\n status?: React.ReactNode;\n /** Its brand scope (`brand-verikora`): its conduit, photons and ring take its `--kz-accent`. */\n className?: string;\n}\n\nexport interface EngineFlowHub {\n /** The engine's name (\"Sovkora\"). */\n label: string;\n /** Its mark, decorative. */\n mark?: React.ReactNode;\n /** A line under the name (\"the engine\"). */\n caption?: React.ReactNode;\n /** Its brand scope; the photons coming back take its accent. */\n className?: string;\n}\n\nexport type EngineFlowProps = Omit<React.ComponentProps<\"figure\">, \"children\"> & {\n /** What the figure shows (\"Sovkora and the products it powers\"), passed translated. */\n label: string;\n /** The engine, at the hub. */\n hub: EngineFlowHub;\n /** The apps around it. */\n nodes: readonly EngineFlowNode[];\n /** How the nodes sit around the hub.\n * @default \"radial\" */\n layout?: FlowLayout;\n /** The layout under a 560 px wide container (a phone); `false` keeps `layout` everywhere.\n * @default \"top-to-bottom\" */\n compactLayout?: FlowLayout | false;\n /** `photons` travel the conduits; `none` draws them still.\n * @default \"photons\" */\n particles?: \"photons\" | \"none\";\n /** The conduits' shape.\n * @default \"bezier\" */\n conduit?: FlowConduit;\n /** The detail line before a node is chosen (\"Point at a product\"). */\n hint?: React.ReactNode;\n /** The node shown in the detail line at first. */\n defaultActive?: string;\n /** Photon speed, in units per second (the stage is 100 units wide).\n * @default 16 */\n speed?: number;\n /** How many photons share a conduit: `sparse` one or two, `normal` two to four, `dense` four to eight.\n * @default \"normal\" */\n density?: FlowDensity;\n /** When the photons travel: `always`; `hover` only while the pointer or focus is on the figure (they rest along the\n * conduits otherwise); `active` only on the conduit of the chosen node (the others show nothing). Off screen they\n * are always paused, and still under reduced motion.\n * @default \"always\" */\n trigger?: FlowTrigger;\n /** The photons' timing function: `linear` (a steady stream), `ease-in-out` (a pulse that swells and settles), or any\n * CSS `<easing-function>` (`cubic-bezier(.2,0,0,1)`, `steps(6)`).\n * @default \"linear\" */\n easing?: FlowEasing;\n /** Milliseconds between one conduit's photons and the next's: 0 sends them all together.\n * @default 300 */\n stagger?: number;\n /** The engine's mark swells slowly (a loop, still under reduced motion).\n * @default true */\n breathe?: boolean;\n /** The calm level, for a small frame (a tile of a home page): sparse photons at a low rate, a slow breath, no hint and\n * no detail line, nothing to tune. It plays only on screen and once the page has settled, and stays still under\n * reduced motion and Save-Data. Overrides `speed`, `density`, `stagger` and `trigger`.\n * @default false */\n calm?: boolean;\n};\n\n/** The calm level's pace: units per second, photons per conduit, milliseconds between conduits. */\nexport const CALM_FLOW = { speed: 4, density: \"sparse\", stagger: 1200 } as const satisfies { speed: number; density: FlowDensity; stagger: number };\n\nconst subscribeSaveData = (onChange: () => void) => {\n const c = (navigator as Navigator & { connection?: EventTarget }).connection;\n c?.addEventListener?.(\"change\", onChange);\n return () => c?.removeEventListener?.(\"change\", onChange);\n};\nconst readSaveData = () => (navigator as Navigator & { connection?: { saveData?: boolean } }).connection?.saveData === true;\n\n\nexport type FlowDensity = \"sparse\" | \"normal\" | \"dense\";\nexport type FlowTrigger = \"always\" | \"hover\" | \"active\";\nexport type FlowEasing = \"linear\" | \"ease-in-out\" | (string & {});\n\n/** How many photons a conduit of this length carries (evenly spaced, so the gap is `length / count`). */\nexport function photonCount(length: number, density: FlowDensity = \"normal\"): number {\n const base = Math.round(length / 16);\n if (density === \"sparse\") return Math.min(2, Math.max(1, Math.round(base / 2)));\n if (density === \"dense\") return Math.min(8, Math.max(4, base * 2));\n return Math.min(4, Math.max(2, base));\n}\n\nfunction Stage({\n layout,\n variant,\n nodes,\n hub,\n conduit,\n particles,\n speed,\n density,\n easing,\n stagger,\n breathe,\n active,\n onActive,\n detailId,\n}: Readonly<{\n layout: FlowLayout;\n variant: \"wide\" | \"compact\";\n nodes: readonly EngineFlowNode[];\n hub: EngineFlowHub;\n conduit: FlowConduit;\n particles: \"photons\" | \"none\";\n speed: number;\n density: FlowDensity;\n easing: FlowEasing;\n stagger: number;\n breathe: boolean;\n active: string | undefined;\n onActive: (id: string) => void;\n detailId: string | undefined;\n}>) {\n const g = flowGeometry(layout, nodes.length, conduit);\n const pct = (v: number, of: number) => `${((v / of) * 100).toFixed(3)}%`;\n return (\n <div className=\"kz-flow-stage\" data-variant={variant} data-layout={layout} style={{ aspectRatio: `${g.width} / ${g.height}` }}>\n <svg viewBox={`0 0 ${g.width} ${g.height}`} aria-hidden=\"true\" focusable=\"false\">\n {nodes.map((node, i) => {\n const flow = node.flow ?? \"in\";\n const length = g.lengths[i] ?? 0;\n // Photons per conduit (`density`), evenly spaced; the same speed on every conduit.\n const gap = length / photonCount(length, density);\n const period = gap / speed;\n const timing = (dir: \"in\" | \"out\") =>\n ({\n \"--kz-flow-gap\": gap.toFixed(3),\n animationDuration: `${period.toFixed(2)}s`,\n // Each conduit starts `stagger` ms after the previous (a negative delay: already under way); the way back is half a period behind.\n animationDelay: `${(-(((i * stagger) / 1000 + (dir === \"out\" ? period / 2 : 0)) % period)).toFixed(2)}s`,\n ...(easing !== \"linear\" ? { animationTimingFunction: easing } : {}),\n }) as React.CSSProperties;\n const lanes = node.planned || particles === \"none\" ? [] : flow === \"both\" ? ([\"in\", \"out\"] as const) : [flow];\n return (\n <g\n key={node.id}\n className={cn(\"kz-flow-link\", node.className)}\n data-flow={flow}\n data-planned={node.planned ? \"\" : undefined}\n data-active={active === node.id ? \"\" : undefined}\n >\n <path className=\"kz-flow-wire\" d={g.paths[i]} />\n {lanes.map((dir) => (\n <React.Fragment key={dir}>\n <path className=\"kz-flow-photon kz-loop\" data-dir={dir} data-halo=\"\" d={g.paths[i]} style={timing(dir)} />\n <path className=\"kz-flow-photon kz-loop\" data-dir={dir} d={g.paths[i]} style={timing(dir)} />\n </React.Fragment>\n ))}\n </g>\n );\n })}\n </svg>\n <div className={cn(\"kz-flow-hub\", hub.className)} style={{ left: pct(g.hub.x, g.width), top: pct(g.hub.y, g.height) }}>\n {hub.mark ? <span className={cn(\"kz-flow-hub-mark\", breathe && \"kz-loop\")}>{hub.mark}</span> : null}\n <span className=\"kz-flow-hub-text\">\n <span className=\"kz-flow-hub-label\">{hub.label}</span>\n {hub.caption ? <span className=\"kz-flow-hub-caption\">{hub.caption}</span> : null}\n </span>\n </div>\n <ul className=\"kz-flow-nodes\">\n {nodes.map((node, i) => {\n const p = g.nodes[i]!;\n const on = active === node.id;\n return (\n <li key={node.id} style={{ left: pct(p.x, g.width), top: pct(p.y, g.height) }}>\n <button\n type=\"button\"\n className={cn(\"kz-flow-node\", node.className)}\n data-active={on ? \"\" : undefined}\n data-planned={node.planned ? \"\" : undefined}\n aria-pressed={on}\n aria-controls={detailId}\n onPointerEnter={() => onActive(node.id)}\n onFocus={() => onActive(node.id)}\n onClick={() => onActive(node.id)}\n >\n {node.mark ? (\n <span className=\"kz-flow-node-mark\" aria-hidden=\"true\">\n {node.mark}\n </span>\n ) : null}\n <span className=\"kz-flow-node-label\">{node.label}</span>\n </button>\n </li>\n );\n })}\n </ul>\n </div>\n );\n}\n\ntype FlowDataInput = { chosen: boolean; calm: boolean; saveData: boolean; trigger: string; density: string; compact: boolean };\n\n/** The figure's data attributes: the CSS reads the state from them. */\nfunction flowData({ chosen, calm, saveData, trigger, density, compact }: FlowDataInput) {\n let dataDensity: string | undefined = density === \"normal\" ? undefined : density;\n if (calm) dataDensity = \"sparse\";\n return {\n \"data-active\": chosen ? \"\" : undefined,\n \"data-calm\": calm ? \"\" : undefined,\n \"data-still\": saveData ? \"\" : undefined,\n \"data-trigger\": calm || trigger === \"always\" ? undefined : trigger,\n \"data-density\": dataDensity,\n \"data-compact\": compact ? \"\" : undefined,\n };\n}\n\n/** What the chosen node says, or the hint when none is chosen. */\nfunction FlowDetail({ id, chosen, hint }: Readonly<{ id: string; chosen: EngineFlowNode | undefined; hint: React.ReactNode }>) {\n return (\n <figcaption id={id} className={cn(\"kz-flow-detail\", chosen?.className)} aria-live=\"polite\">\n {chosen ? (\n <>\n <strong>{chosen.label}</strong>\n {chosen.status ? <span className=\"kz-flow-status\">{chosen.status}</span> : null}\n {chosen.description ? <span> {chosen.description}</span> : null}\n {chosen.href ? (\n <>\n {\" \"}\n <a href={chosen.href} {...(chosen.external ? { target: \"_blank\", rel: \"noopener\" } : {})}>\n {chosen.linkLabel ?? chosen.label}\n <span aria-hidden=\"true\"> →</span>\n </a>\n </>\n ) : null}\n </>\n ) : (\n hint\n )}\n </figcaption>\n );\n}\n\n/** An engine at the hub and the apps it serves, with what travels between them. */\nexport function EngineFlow({\n label,\n hub,\n nodes,\n layout = \"radial\",\n compactLayout = \"top-to-bottom\",\n particles = \"photons\",\n conduit = \"bezier\",\n hint,\n defaultActive,\n speed = 16,\n density = \"normal\",\n trigger = \"always\",\n easing = \"linear\",\n stagger = 300,\n breathe = true,\n calm = false,\n className,\n ...props\n}: EngineFlowProps) {\n const [active, setActive] = React.useState<string | undefined>(defaultActive);\n const detailId = `${React.useId()}-detail`;\n const chosen = nodes.find((n) => n.id === active);\n const compact = compactLayout && compactLayout !== layout ? compactLayout : undefined;\n // Save-Data: the calm and the full levels both rest (a still frame, like reduced motion).\n const saveData = React.useSyncExternalStore(subscribeSaveData, readSaveData, () => false);\n const pace = calm ? CALM_FLOW : { speed: Math.max(1, speed), density, stagger: Math.max(0, stagger) };\n const stage = { nodes, hub, conduit, particles, ...pace, easing, breathe, active, onActive: setActive, detailId: calm ? undefined : detailId };\n return (\n <figure\n aria-label={label}\n className={cn(\"kz-flow\", className)}\n data-motion-scope=\"\"\n {...flowData({ chosen: Boolean(chosen), calm, saveData, trigger, density, compact: Boolean(compact) })}\n {...props}\n >\n <Stage layout={layout} variant=\"wide\" {...stage} />\n {compact ? <Stage layout={compact} variant=\"compact\" {...stage} /> : null}\n {calm ? null : <FlowDetail id={detailId} chosen={chosen} hint={hint} />}\n </figure>\n );\n}\n","// Server-safe, pure. The geometry of EngineFlow: where the hub and the nodes sit in a box 100 units wide, and the\n// conduit from each node to the hub (an SVG path drawn node → hub, and its length, so photons travel at one speed on\n// every conduit). No DOM: the same numbers on the server and in the browser.\n\n/** How the nodes are placed around the hub. */\nexport type FlowLayout = \"radial\" | \"top-to-bottom\" | \"left-to-right\";\n/** The shape of a conduit: an S-shaped cubic Bézier, or a straight line. */\nexport type FlowConduit = \"bezier\" | \"straight\";\n\nexport interface FlowPoint {\n x: number;\n y: number;\n}\n\nexport interface FlowGeometry {\n /** The box: 100 units wide, `height` units high (the stage keeps this aspect ratio, so nothing is distorted). */\n width: number;\n height: number;\n hub: FlowPoint;\n nodes: FlowPoint[];\n /** One path per node, from the node to the hub. */\n paths: string[];\n /** The length of each path, in units. */\n lengths: number[];\n}\n\n/** The box height per layout (the width is always 100). */\nexport const FLOW_HEIGHT: Record<FlowLayout, number> = { radial: 60, \"top-to-bottom\": 92, \"left-to-right\": 56 };\n\n/** How far a conduit lands from the hub's centre along the row, as a share of its node's offset: a small fan, kept inside the ring. */\nexport const FLOW_FAN = 0.1;\n\nconst r2 = (n: number) => Math.round(n * 100) / 100;\nconst pt = (p: FlowPoint) => `${r2(p.x)} ${r2(p.y)}`;\n\nfunction cubicLength(a: FlowPoint, b: FlowPoint, c: FlowPoint, d: FlowPoint): number {\n let length = 0;\n let prev = a;\n for (let i = 1; i <= 32; i++) {\n const t = i / 32;\n const u = 1 - t;\n const p = {\n x: u * u * u * a.x + 3 * u * u * t * b.x + 3 * u * t * t * c.x + t * t * t * d.x,\n y: u * u * u * a.y + 3 * u * u * t * b.y + 3 * u * t * t * c.y + t * t * t * d.y,\n };\n length += Math.hypot(p.x - prev.x, p.y - prev.y);\n prev = p;\n }\n return length;\n}\n\n/** The positions of `count` nodes around the hub. */\nexport function flowPositions(layout: FlowLayout, count: number): { hub: FlowPoint; nodes: FlowPoint[] } {\n const height = FLOW_HEIGHT[layout];\n const n = Math.max(0, count);\n if (layout === \"top-to-bottom\") {\n return { hub: { x: 50, y: 72 }, nodes: Array.from({ length: n }, (_, i) => ({ x: ((i + 0.5) * 100) / n, y: 13 })) };\n }\n if (layout === \"left-to-right\") {\n return { hub: { x: 80, y: height / 2 }, nodes: Array.from({ length: n }, (_, i) => ({ x: 12, y: ((i + 0.5) * height) / n })) };\n }\n // Radial: on an ellipse around the centre; an even count puts two nodes level with the hub (more room for labels).\n const hub = { x: 50, y: height / 2 };\n const start = n % 2 === 0 ? -90 + 180 / Math.max(n, 1) : -90;\n return {\n hub,\n nodes: Array.from({ length: n }, (_, i) => {\n const a = ((start + (360 / n) * i) * Math.PI) / 180;\n return { x: hub.x + 37 * Math.cos(a), y: hub.y + 20 * Math.sin(a) };\n }),\n };\n}\n\n/** The whole geometry of a flow: positions, conduits (node → hub) and their lengths. */\nexport function flowGeometry(layout: FlowLayout, count: number, conduit: FlowConduit = \"bezier\"): FlowGeometry {\n const { hub, nodes } = flowPositions(layout, count);\n const paths: string[] = [];\n const lengths: number[] = [];\n for (const p of nodes) {\n // Each conduit lands on its own point of the hub (a fan), so the lines stay apart where they meet.\n let end: FlowPoint;\n if (layout === \"top-to-bottom\") end = { x: hub.x + (p.x - hub.x) * FLOW_FAN, y: hub.y };\n else if (layout === \"left-to-right\") end = { x: hub.x, y: hub.y + (p.y - hub.y) * FLOW_FAN };\n else end = hub;\n if (conduit === \"straight\") {\n paths.push(`M${pt(p)} L${pt(end)}`);\n lengths.push(Math.hypot(end.x - p.x, end.y - p.y));\n continue;\n }\n let c1: FlowPoint;\n let c2: FlowPoint;\n if (layout === \"top-to-bottom\") {\n const mid = (p.y + end.y) / 2;\n c1 = { x: p.x, y: mid };\n c2 = { x: end.x, y: mid };\n } else if (layout === \"left-to-right\") {\n const mid = (p.x + end.x) / 2;\n c1 = { x: mid, y: p.y };\n c2 = { x: mid, y: end.y };\n } else {\n // An S: leave the node bending one way, reach the hub bending the other.\n const dx = end.x - p.x;\n const dy = end.y - p.y;\n const len = Math.hypot(dx, dy) || 1;\n const k = 0.14 * len;\n const nx = -dy / len;\n const ny = dx / len;\n c1 = { x: p.x + dx * 0.35 + nx * k, y: p.y + dy * 0.35 + ny * k };\n c2 = { x: p.x + dx * 0.65 - nx * k, y: p.y + dy * 0.65 - ny * k };\n }\n paths.push(`M${pt(p)} C${pt(c1)} ${pt(c2)} ${pt(end)}`);\n lengths.push(cubicLength(p, c1, c2, end));\n }\n return { width: 100, height: FLOW_HEIGHT[layout], hub, nodes, paths, lengths };\n}\n"],"mappings":";;;;;;AAgBA,YAAY,WAAW;;;ACWhB,IAAM,cAA0C,EAAE,QAAQ,IAAI,iBAAiB,IAAI,iBAAiB,GAAG;AAGvG,IAAM,WAAW;AAExB,IAAM,KAAK,CAAC,MAAc,KAAK,M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AAS,KAAK,IAAI,GAAG,OAAO,EAAE;AACpG,QAAM,QAAQ,EAAE,OAAO,KAAK,SAAS,WAAW,GAAG,MAAM,QAAQ,SAAS,QAAQ,UAAU,WAAW,UAAU,OAAO,SAAY,SAAS;AAC7I,SACE;AAAA,IAAC;AAAA;AAAA,MACC,cAAY;AAAA,MACZ,WAAW,GAAG,WAAW,SAAS;AAAA,MAClC,qBAAkB;AAAA,MACjB,GAAG,SAAS,EAAE,QAAQ,QAAQ,MAAM,GAAG,MAAM,UAAU,SAAS,SAAS,SAAS,QAAQ,OAAO,EAAE,CAAC;AAAA,MACpG,GAAG;AAAA,MAEJ;AAAA,4BAAC,SAAM,QAAgB,SAAQ,QAAQ,GAAG,OAAO;AAAA,QAChD,UAAU,oBAAC,SAAM,QAAQ,SAAS,SAAQ,WAAW,GAAG,OAAO,IAAK;AAAA,QACpE,OAAO,OAAO,oBAAC,cAAW,IAAI,UAAU,QAAgB,MAAY;AAAA;AAAA;AAAA,EACvE;AAEJ;","names":["Fragment"]}
|
package/dist/entity-header.js
CHANGED
|
@@ -119,11 +119,17 @@ function EntityHeader({
|
|
|
119
119
|
const { message, setLocal } = useRefusal(refusal, refusals);
|
|
120
120
|
const picture = /* @__PURE__ */ jsx(Avatar, { size: "xl", alt: "", ...avatar });
|
|
121
121
|
const errorId = React2.useId();
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
let avatarSlot = null;
|
|
123
|
+
if (avatarPicker) {
|
|
124
|
+
avatarSlot = /* @__PURE__ */ jsxs(Popover.Root, { children: [
|
|
124
125
|
/* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx("button", { type: "button", "aria-label": avatarPicker.triggerLabel, className: "shrink-0 rounded-full focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", children: picture }) }),
|
|
125
126
|
/* @__PURE__ */ jsx(Popover.Content, { className: "w-80", align: "start", children: /* @__PURE__ */ jsx(AvatarPicker, { ...avatarPicker, dense: true }) })
|
|
126
|
-
] })
|
|
127
|
+
] });
|
|
128
|
+
} else if (avatar) {
|
|
129
|
+
avatarSlot = /* @__PURE__ */ jsx("span", { className: "shrink-0", children: picture });
|
|
130
|
+
}
|
|
131
|
+
return /* @__PURE__ */ jsxs("header", { className: cn("flex flex-wrap items-start gap-4", className), "data-entity-header": true, children: [
|
|
132
|
+
avatarSlot,
|
|
127
133
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
128
134
|
/* @__PURE__ */ jsx("h1", { className: "m-0 min-w-0 text-xl font-semibold text-fg-title", children: /* @__PURE__ */ jsx(
|
|
129
135
|
Editable,
|