soma-kit 0.1.14 → 0.1.16
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 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
package/src/data/menu.ts
CHANGED
|
@@ -9,22 +9,39 @@
|
|
|
9
9
|
// 或一个短字符(emoji 或符号,原样画);缺省收起态取标签首字;badge 是徽标文字或数字。
|
|
10
10
|
// `map` 改写键名(组件期望的键 -> 数据里的键)。当前项由 `selected`(id)给出,祖先分支自动展开;
|
|
11
11
|
// `collapsed` 为真时收成仅图标窄栏:只画一级项,分支点击抛 toggle { rail: true } 交宿主决定(通常是展开侧栏)。
|
|
12
|
-
//
|
|
12
|
+
// 语义 = 导航(nav > ul > li > a / 披露按钮):叶子是链接(当前项 aria-current=page),分支是 button aria-expanded + aria-controls,不用 tree 角色。
|
|
13
|
+
// 项上 `actions: [{ key, label }]` 在项尾画悬停 / 聚焦才显示的动作位(触屏常显),点击抛 `action { item, key }`。
|
|
14
|
+
// 键盘:Tab 按文档序进出,Enter / Space 走原生链接 / 按钮(选中或切换分组);↑↓ 走可见项、→ 展开 / ← 折叠(core 键盘接线 layout: tree)是增强。
|
|
13
15
|
// 展开状态是组件内部状态;选中抛 `select { item }`,展开折叠抛 `toggle { item, open }`。
|
|
14
16
|
|
|
17
|
+
import { kitApplyLevelClass } from './level-class';
|
|
15
18
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
16
19
|
import { kitText } from '../i18n/kit-text';
|
|
17
20
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
18
21
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
19
22
|
import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
23
|
+
import { KIT_STRIP_MENU_ITEM_CLASS } from '../recipes/strip';
|
|
24
|
+
import { FOCUS_INSET } from '../shared/focus-ring';
|
|
25
|
+
import { kitSelectedRecipe } from '../recipes/state';
|
|
26
|
+
import { kitClosedValueRecipe, kitGroupLabelRecipe, kitIdentRecipe } from '../recipes/field-text';
|
|
27
|
+
import { kitDividerRecipe } from '../recipes/divider';
|
|
28
|
+
import { mergeClass } from '../shared/merge-class';
|
|
20
29
|
import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
|
|
21
|
-
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
22
|
-
import {
|
|
30
|
+
import { bool, createKitController, joinClass, nextUid, str } from '../base/shared';
|
|
31
|
+
import { safeHref } from '../base/link';
|
|
32
|
+
import { actionButton, actionsOf, BUTTON_CLASS_TOKENS } from './shape-util';
|
|
33
|
+
import { KIT_ICON_NAMES, kitIcon, type KitIconName } from '../shared/icons';
|
|
23
34
|
import { classSet, cssEscape, firstChar, h, isRec, textOf, type Rec } from './menu-dom';
|
|
24
35
|
import { mountKitMegaMenu } from './mega-menu';
|
|
36
|
+
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
|
|
37
|
+
import { buildSkeleton, KIT_SKELETON_CLASS_CANDIDATES } from '../object-renderer/skeleton';
|
|
38
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked } from './kit-contract';
|
|
39
|
+
import { KIT_ATTR_ACTION, KIT_ATTR_ACTION_OF, KIT_ATTR_BADGE, KIT_ATTR_KEY, KIT_ATTR_TIP, KIT_ATTR_TOGGLE, kitAttrSel } from '../shared/dom-attrs';
|
|
25
40
|
|
|
26
41
|
// ───────── 样式常量:类串与 Tailwind 候选清单 ─────────
|
|
27
42
|
|
|
43
|
+
/** 菜单项行高 = 通用条带高度 sizeSpec.strip.menuItemPx(密度无关的 px 条带) */
|
|
44
|
+
const ROW_H = KIT_STRIP_MENU_ITEM_CLASS;
|
|
28
45
|
const ROOT_CLASS = 'flex flex-col text-sm text-fg';
|
|
29
46
|
const LIST_CLASS = 'flex flex-col gap-1';
|
|
30
47
|
const LIST_RAIL_CLASS = 'flex flex-col items-center gap-1';
|
|
@@ -39,15 +56,30 @@ export function menuChildInsetUnits(parentHasIcon: boolean): number {
|
|
|
39
56
|
}
|
|
40
57
|
const PAD_TOP = `px-${MENU_INDENT.rowInsetUnits}`;
|
|
41
58
|
const padChild = (parentHasIcon: boolean): string => `ps-${menuChildInsetUnits(parentHasIcon)} pe-${MENU_INDENT.rowInsetUnits}`;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
59
|
+
// 侧栏项焦点 = 集合项焦点出口(KT-K0-3:2px 环内收,不被侧栏滚动区裁切)
|
|
60
|
+
// 焦点环画在可聚焦的链接 / 披露按钮上(FACE_CLASS),li 只是容器;li 相对定位以放悬停动作位
|
|
61
|
+
const ITEM_CLASS = 'group/item relative flex flex-col gap-1 rounded-item';
|
|
62
|
+
const ITEM_RAIL_CLASS = 'relative flex w-full flex-col rounded-item';
|
|
63
|
+
// 链接 / 披露按钮:铺满项宽,去掉按钮默认底边与内边距,文字起点与行一致
|
|
64
|
+
const FACE_CLASS = `block w-full rounded-item border-0 bg-transparent p-0 text-start ${FOCUS_INSET}`;
|
|
65
|
+
// 项尾悬停动作位:绝对定位在行尾,悬停 / 键盘聚焦该项时显示(触屏常显);按钮是 li 里与链接并列的兄弟,Tab 可达
|
|
66
|
+
const ACTIONS_CLASS = 'absolute inset-y-0 end-1 flex items-center gap-1 opacity-0 transition-opacity group-hover/item:opacity-100 group-focus-within/item:opacity-100 pointer-coarse:opacity-100';
|
|
67
|
+
const ACTION_CLASS = 'shrink-0';
|
|
68
|
+
const rowClass = (pad: string): string => `flex ${ROW_H} cursor-pointer items-center gap-2 rounded-item ${pad} text-sm text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg`;
|
|
69
|
+
// 选中项也有悬停 / 按下(同一档状态层,取 tonal 版:叠在主色浅底上),底色切换带过渡
|
|
70
|
+
const rowActiveClass = (pad: string): string => mergeClass(
|
|
71
|
+
kitSelectedRecipe(),
|
|
72
|
+
`flex ${ROW_H} cursor-pointer items-center gap-2 rounded-item ${pad} text-sm transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press`,
|
|
73
|
+
);
|
|
74
|
+
const rowDisabledClass = (pad: string): string => `flex ${ROW_H} cursor-not-allowed items-center gap-2 rounded-item ${pad} text-sm text-fg-disabled`;
|
|
47
75
|
const PADS: readonly string[] = [PAD_TOP, padChild(true), padChild(false)];
|
|
48
|
-
const ROW_RAIL_CLASS =
|
|
49
|
-
const ROW_RAIL_ACTIVE_CLASS =
|
|
50
|
-
|
|
76
|
+
const ROW_RAIL_CLASS = `flex ${ROW_H} w-full cursor-pointer items-center justify-center rounded-item text-sm text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg`;
|
|
77
|
+
const ROW_RAIL_ACTIVE_CLASS = mergeClass(
|
|
78
|
+
kitSelectedRecipe(),
|
|
79
|
+
`flex ${ROW_H} w-full cursor-pointer items-center justify-center rounded-item text-sm transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press`,
|
|
80
|
+
);
|
|
81
|
+
// 分组标题照 shadcn SidebarGroupLabel:高 32(h-8)、组间距 8(mt-2),字阶与墨色经 kitGroupLabelRecipe 统一出口
|
|
82
|
+
const HEADING_CLASS = mergeClass('mt-2 flex h-8 items-center px-3', kitGroupLabelRecipe());
|
|
51
83
|
const ICON_CLASS = 'w-5 shrink-0 text-center';
|
|
52
84
|
/** icon 写 kit 图标名时画 SVG:容器居中,不依赖字符基线 */
|
|
53
85
|
const ICON_SVG_CLASS = 'flex w-5 shrink-0 items-center justify-center';
|
|
@@ -67,18 +99,20 @@ function menuIconNode(icon: string): HTMLElement | null {
|
|
|
67
99
|
}
|
|
68
100
|
const LABEL_CLASS = 'min-w-0 flex-1 truncate';
|
|
69
101
|
const CARET_CLASS = 'w-4 shrink-0 text-center text-xs text-fg-subtle';
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
102
|
+
// 项尾徽标 = 数量 / 标记,必须有底(F7):补齐 tabular-nums 并锁定 rounded-item 统一几何(激活态不突变为圆胶囊)
|
|
103
|
+
const BADGE_GEOM = 'shrink-0 rounded-item tabular-nums';
|
|
104
|
+
const BADGE_CLASS = mergeClass(kitIdentRecipe(), BADGE_GEOM);
|
|
105
|
+
const BADGE_PRIMARY_CLASS = mergeClass(kitClosedValueRecipe('primary'), BADGE_GEOM);
|
|
106
|
+
const BADGE_DANGER_CLASS = mergeClass(kitClosedValueRecipe('danger'), BADGE_GEOM);
|
|
107
|
+
const BADGE_ACTIVE_CLASS = mergeClass(mergeClass(kitClosedValueRecipe('primary'), BADGE_GEOM), 'bg-surface text-primary-on-soft');
|
|
108
|
+
const SEP_CLASS = mergeClass(kitDividerRecipe('top', 'item'), 'my-1 w-full');
|
|
75
109
|
|
|
76
110
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
77
111
|
export const KIT_MENU_CLASS_CANDIDATES: readonly string[] = classSet(
|
|
78
|
-
ROOT_CLASS, LIST_CLASS, LIST_RAIL_CLASS, GROUP_CLASS, ITEM_CLASS, ITEM_RAIL_CLASS,
|
|
112
|
+
ROOT_CLASS, LIST_CLASS, LIST_RAIL_CLASS, GROUP_CLASS, ITEM_CLASS, ITEM_RAIL_CLASS, FACE_CLASS, ACTIONS_CLASS, ACTION_CLASS, BUTTON_CLASS_TOKENS,
|
|
79
113
|
PADS.flatMap((pad) => [rowClass(pad), rowActiveClass(pad), rowDisabledClass(pad)]),
|
|
80
114
|
ROW_RAIL_CLASS, ROW_RAIL_ACTIVE_CLASS, HEADING_CLASS, ICON_CLASS, LABEL_CLASS, CARET_CLASS, BADGE_CLASS, BADGE_PRIMARY_CLASS,
|
|
81
|
-
BADGE_DANGER_CLASS, BADGE_ACTIVE_CLASS, SEP_CLASS, ICON_SVG_CLASS,
|
|
115
|
+
BADGE_DANGER_CLASS, BADGE_ACTIVE_CLASS, SEP_CLASS, ICON_SVG_CLASS, KIT_SKELETON_CLASS_CANDIDATES,
|
|
82
116
|
);
|
|
83
117
|
|
|
84
118
|
// ───────── 数据规整纯函数:键名对照、节点树、祖先链、可见项 ─────────
|
|
@@ -273,7 +307,7 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
273
307
|
|
|
274
308
|
const focusCursor = (): void => {
|
|
275
309
|
if (cursor === null) return;
|
|
276
|
-
root.querySelector<HTMLElement>(`[
|
|
310
|
+
root.querySelector<HTMLElement>(`[${KIT_ATTR_KEY}="${cssEscape(cursor)}"]`)?.focus();
|
|
277
311
|
};
|
|
278
312
|
|
|
279
313
|
const setOpen = (key: string, on: boolean): void => {
|
|
@@ -319,7 +353,8 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
319
353
|
sig = `cyclic:${Math.random()}`;
|
|
320
354
|
}
|
|
321
355
|
const expandAll = bool(props.expand_all);
|
|
322
|
-
|
|
356
|
+
// 独立 Menu 缺省不手风琴(用户已验收:换分支不收起其它);工作台外壳经 sidebar.accordion 显式传 true(缺省开启在外壳那一层)
|
|
357
|
+
const accordion = props.accordion === true || props.accordion === 'true';
|
|
323
358
|
if (sig !== dataSig) {
|
|
324
359
|
dataSig = sig;
|
|
325
360
|
nodes = buildMenuNodes(props.data, map);
|
|
@@ -351,29 +386,45 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
351
386
|
rail = bool(props.collapsed);
|
|
352
387
|
};
|
|
353
388
|
|
|
354
|
-
|
|
389
|
+
// 导航 = nav > ul > li > 链接 / 披露按钮(WAI 导航写法,不用 tree / treeitem):
|
|
390
|
+
// 叶子 = <a href>(没有地址退为 button);分支 = <button aria-expanded aria-controls=子列表>;当前页 aria-current=page;
|
|
391
|
+
// 项上悬停动作位 = li 里与链接并列的按钮(不嵌进链接),Tab 可达;全部项按文档序 Tab 进出,↑↓ 在可见项间移动是增强
|
|
392
|
+
const menuUid = nextUid('kit-menu');
|
|
393
|
+
const subId = (key: string): string => `${menuUid}-${key.replace(/\s+/g, '_')}`;
|
|
394
|
+
const buildItem = (n: KitMenuNode): Node[] => {
|
|
355
395
|
if (n.divider) return [h('li', SEP_CLASS, { role: 'presentation' })];
|
|
356
396
|
if (n.group) {
|
|
357
|
-
if (rail) return [h('li', SEP_CLASS, { role: 'presentation' }), ...n.children.flatMap((c) => buildItem(c
|
|
358
|
-
const
|
|
359
|
-
|
|
397
|
+
if (rail) return [h('li', SEP_CLASS, { role: 'presentation' }), ...n.children.flatMap((c) => buildItem(c))];
|
|
398
|
+
const heading = h('li', HEADING_CLASS, { role: 'presentation' }, n.label);
|
|
399
|
+
// 分组名是块标题
|
|
400
|
+
kitMarkPart(heading, 'block-title');
|
|
401
|
+
const out: Node[] = [heading];
|
|
402
|
+
for (const c of n.children) out.push(...buildItem(c));
|
|
360
403
|
return out;
|
|
361
404
|
}
|
|
362
405
|
const branch = n.children.length > 0;
|
|
363
406
|
const isOpen = branch && open.has(n.key) && !rail;
|
|
364
407
|
const active = n.key === selected;
|
|
365
|
-
const li = h('li', rail ? ITEM_RAIL_CLASS : ITEM_CLASS
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
408
|
+
const li = h('li', rail ? ITEM_RAIL_CLASS : ITEM_CLASS);
|
|
409
|
+
const href = !branch && n.href !== '' && !n.disabled ? safeHref(n.href) : '';
|
|
410
|
+
const face = h(href !== '' ? 'a' : 'button', FACE_CLASS, {
|
|
411
|
+
type: href !== '' ? undefined : 'button',
|
|
412
|
+
href: href !== '' ? href : undefined,
|
|
413
|
+
// 当前页(卡 SidebarMenu:当前项 aria-current=page);分支不是页,不写
|
|
414
|
+
'aria-current': active && !branch ? 'page' : undefined,
|
|
369
415
|
'aria-expanded': branch && !rail ? (isOpen ? 'true' : 'false') : undefined,
|
|
416
|
+
'aria-controls': isOpen ? subId(n.key) : undefined,
|
|
370
417
|
'aria-disabled': n.disabled ? 'true' : undefined,
|
|
371
418
|
'aria-label': rail ? n.label : undefined,
|
|
372
419
|
// 收起态的悬停提示走 kit 气泡(hint-tips 委托,data-kit-tip),不用原生 title(原生提示延迟长、不随主题、截图 / 触屏都没有)
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
tabindex: n.key === tabbable ? '0' : '-1',
|
|
420
|
+
[KIT_ATTR_TIP]: rail ? n.label : undefined,
|
|
421
|
+
[KIT_ATTR_KEY]: n.key,
|
|
376
422
|
});
|
|
423
|
+
// 菜单项是条目,可点的项面是动作;当前页自报「当前」(aria-current=page 已在上面写,帮手不覆盖)
|
|
424
|
+
kitMarkLevel(li, 'item'); kitApplyLevelClass(li);
|
|
425
|
+
kitMarkPart(face, 'action');
|
|
426
|
+
kitMarkPicked(face, 'current', active && !branch, null);
|
|
427
|
+
li.append(face);
|
|
377
428
|
let row: HTMLElement;
|
|
378
429
|
if (rail) {
|
|
379
430
|
row = h('div', active ? ROW_RAIL_ACTIVE_CLASS : ROW_RAIL_CLASS, {},
|
|
@@ -387,13 +438,20 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
387
438
|
row = h('div', n.disabled ? rowDisabledClass(pad) : active ? rowActiveClass(pad) : rowClass(pad), {},
|
|
388
439
|
menuIconNode(n.icon),
|
|
389
440
|
h('span', LABEL_CLASS, { [KIT_TIPS_SCOPE_ATTR]: '' }, n.label),
|
|
390
|
-
n.badge !== '' ? h('span', badgeClass, {
|
|
391
|
-
branch ? h('span', CARET_CLASS, { 'aria-hidden': 'true',
|
|
441
|
+
n.badge !== '' ? h('span', badgeClass, { [KIT_ATTR_BADGE]: '' }, n.badge) : null,
|
|
442
|
+
branch ? h('span', CARET_CLASS, { 'aria-hidden': 'true', [KIT_ATTR_TOGGLE]: '' }, kitIcon(isOpen ? 'chevron-down' : 'chevron-right', 'sm', 'rtl:-scale-x-100')) : null);
|
|
443
|
+
}
|
|
444
|
+
face.append(row);
|
|
445
|
+
// 项尾悬停动作位:悬停 / 键盘聚焦该项时显示(触屏常显),与链接并列、Tab 可达
|
|
446
|
+
const acts = rail || n.disabled ? [] : actionsOf(isRec(n.raw) ? n.raw.actions : undefined);
|
|
447
|
+
if (acts.length > 0) {
|
|
448
|
+
const box = h('span', ACTIONS_CLASS, { [KIT_ATTR_ACTION_OF]: n.key });
|
|
449
|
+
for (const a of acts) box.append(actionButton(a, ACTION_CLASS));
|
|
450
|
+
li.append(box);
|
|
392
451
|
}
|
|
393
|
-
li.append(row);
|
|
394
452
|
if (isOpen) {
|
|
395
|
-
const group = h('ul', GROUP_CLASS, {
|
|
396
|
-
for (const child of n.children) for (const node of buildItem(child
|
|
453
|
+
const group = h('ul', GROUP_CLASS, { id: subId(n.key) });
|
|
454
|
+
for (const child of n.children) for (const node of buildItem(child)) group.append(node);
|
|
397
455
|
li.append(group);
|
|
398
456
|
}
|
|
399
457
|
return [li];
|
|
@@ -401,37 +459,65 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
401
459
|
|
|
402
460
|
function paint(): void {
|
|
403
461
|
if (destroyed) return;
|
|
404
|
-
const visible = menuVisible(nodes, open, rail);
|
|
405
|
-
const tabbable = cursor !== null && visible.some((n) => n.key === cursor)
|
|
406
|
-
? cursor
|
|
407
|
-
: (visible.find((n) => n.key === selected)?.key ?? visible[0]?.key ?? null);
|
|
408
462
|
const hadFocus = root.contains(root.ownerDocument.activeElement);
|
|
409
|
-
const list = h('ul', rail ? LIST_RAIL_CLASS : LIST_CLASS
|
|
410
|
-
for (const n of nodes) for (const el of buildItem(n
|
|
411
|
-
root.replaceChildren(list);
|
|
463
|
+
const list = h('ul', rail ? LIST_RAIL_CLASS : LIST_CLASS);
|
|
464
|
+
for (const n of nodes) for (const el of buildItem(n)) list.append(el);
|
|
412
465
|
root.className = joinClass(ROOT_CLASS, props.class);
|
|
413
466
|
const label = str(props.label, kitText('soma.kit.menu', undefined, root));
|
|
414
467
|
root.setAttribute('aria-label', label);
|
|
468
|
+
root.textContent = '';
|
|
469
|
+
// 数据状态自报(与读状态面板的 data-kit-state 并存)
|
|
470
|
+
kitMarkDataFacts(root, { error: str(props.error_text) !== '', loading: props.loading === true || props.loading === 'true', empty: nodes.length === 0 });
|
|
471
|
+
// 读状态(加载中 = 与项同结构的骨架行;读取失败 + 重试):同集合三态(base/state-panel.ts);没有读状态时不碰根
|
|
472
|
+
if (applyKitReadState(root, props, {
|
|
473
|
+
hasContent: nodes.length > 0,
|
|
474
|
+
onRetry: () => emit('retry', {}),
|
|
475
|
+
repaint: paint,
|
|
476
|
+
skeleton: () => buildSkeleton(root.ownerDocument, { kind: 'stack' }),
|
|
477
|
+
})) return;
|
|
478
|
+
root.appendChild(list);
|
|
415
479
|
if (hadFocus) focusCursor();
|
|
416
480
|
}
|
|
417
481
|
|
|
418
482
|
const onClick = (event: Event): void => {
|
|
419
483
|
const target = event.target as HTMLElement | null;
|
|
420
|
-
|
|
421
|
-
const
|
|
422
|
-
if (
|
|
484
|
+
// 悬停动作位:抛 action { item, key },不触发选中 / 展开
|
|
485
|
+
const actBtn = target?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION));
|
|
486
|
+
if (actBtn !== null && actBtn !== undefined) {
|
|
487
|
+
const owner = actBtn.closest<HTMLElement>(kitAttrSel(KIT_ATTR_ACTION_OF))?.getAttribute(KIT_ATTR_ACTION_OF);
|
|
488
|
+
const node = owner !== undefined && owner !== null ? byKey.get(owner) : undefined;
|
|
489
|
+
if (node !== undefined && !actBtn.disabled) emit('action', { item: node.raw, key: actBtn.getAttribute(KIT_ATTR_ACTION) ?? '' });
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
const face = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY));
|
|
493
|
+
const key = face?.getAttribute(KIT_ATTR_KEY);
|
|
494
|
+
if (!face || !key) return;
|
|
495
|
+
// 链接由宿主路由接管(select 事件):不触发浏览器跳转;带修饰键(新标签打开等)放行
|
|
496
|
+
const me = event as MouseEvent;
|
|
497
|
+
if (face instanceof HTMLAnchorElement && !(me.ctrlKey || me.metaKey || me.shiftKey || me.altKey)) event.preventDefault();
|
|
498
|
+
cursor = key;
|
|
423
499
|
activate(key);
|
|
424
500
|
};
|
|
425
501
|
const onKeydown = (event: Event): void => {
|
|
426
502
|
const e = event as KeyboardEvent;
|
|
503
|
+
const keyed = (e.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY));
|
|
504
|
+
if (!keyed) return;
|
|
505
|
+
// Enter / Space 交给原生链接 / 按钮(切换分组或选中走 click),不重复接管
|
|
506
|
+
if (e.key === 'Enter' || e.key === ' ') return;
|
|
427
507
|
if (cursor === null) {
|
|
428
|
-
const first =
|
|
508
|
+
const first = keyed.getAttribute(KIT_ATTR_KEY);
|
|
429
509
|
if (first) cursor = first;
|
|
430
510
|
}
|
|
431
511
|
if (wiring.onKeydown(e)) e.preventDefault();
|
|
432
512
|
};
|
|
513
|
+
// 焦点(Tab / 点击)到哪一项,方向键就从哪一项走
|
|
514
|
+
const onFocusin = (event: Event): void => {
|
|
515
|
+
const key = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY))?.getAttribute(KIT_ATTR_KEY);
|
|
516
|
+
if (key) cursor = key;
|
|
517
|
+
};
|
|
433
518
|
root.addEventListener('click', onClick);
|
|
434
519
|
root.addEventListener('keydown', onKeydown);
|
|
520
|
+
root.addEventListener('focusin', onFocusin);
|
|
435
521
|
|
|
436
522
|
return {
|
|
437
523
|
update(next) {
|
|
@@ -443,6 +529,7 @@ export function mountKitMenu(root: HTMLElement, emit: KitMenuEmit): KitMenuHandl
|
|
|
443
529
|
destroyed = true;
|
|
444
530
|
root.removeEventListener('click', onClick);
|
|
445
531
|
root.removeEventListener('keydown', onKeydown);
|
|
532
|
+
root.removeEventListener('focusin', onFocusin);
|
|
446
533
|
},
|
|
447
534
|
};
|
|
448
535
|
}
|
|
@@ -459,17 +546,20 @@ export function createMenu(): SomaComponentDefinition {
|
|
|
459
546
|
data: { type: 'array', default: [], desc: '菜单数据 [{ id, label, icon?, badge?, badge_tone?, href?, disabled?, openable?, group?, open?, children? }];group 为分组标题;icon 可写 kit 图标名(画 SVG)或短字符。layout=columns 时见 layout' },
|
|
460
547
|
map: { type: 'object', default: {}, desc: '键名对照 { id, label, children, icon, badge, href }:组件期望的键 -> 数据里的键' },
|
|
461
548
|
selected: { type: 'string', default: '', desc: '当前项 id;祖先分支自动展开' },
|
|
462
|
-
accordion: { type: 'boolean', default: false, desc: '
|
|
549
|
+
accordion: { type: 'boolean', default: false, desc: '手风琴(独立 Menu 缺省关闭;工作台外壳缺省开启):选中项变化时只展开其所在的一级分支(其余收起);用户手动展开的分支保留,直到选中项落进另一个一级分支。expand_all 初始全展开时不受影响;写 false 关闭。工作台侧栏同款(sidebar.accordion)' },
|
|
463
550
|
collapsed: { type: 'boolean', default: false, desc: '收起成仅图标窄栏(只画一级,分支点击抛 toggle { rail: true })' },
|
|
464
551
|
expand_all: { type: 'boolean', default: false, desc: '初始全部展开' },
|
|
465
552
|
label: { type: 'string', default: '', desc: '导航区域的可访问名;缺省取内置文案(按页面语言)' },
|
|
553
|
+
...KIT_READ_STATE_PROP_DEFS,
|
|
466
554
|
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
467
555
|
},
|
|
468
556
|
emits: {
|
|
469
557
|
select: { payload: { item: { type: 'object' } }, desc: '选中某项(点击、Enter、Space);item 是源数据里的原对象' },
|
|
470
558
|
toggle: { payload: { item: { type: 'object' }, open: { type: 'boolean' }, rail: { type: 'boolean' } }, desc: '分支展开 / 折叠;收起态点击分支时 rail 为真' },
|
|
559
|
+
action: { payload: { item: { type: 'object' }, key: { type: 'string' } }, desc: '点项尾悬停动作位(项上 actions [{ key, label, tone?, disabled? }]);item 是该项源对象,key 是动作键;只上抛意图' },
|
|
471
560
|
open: { payload: { id: { type: 'string' } }, desc: 'layout=columns:面板打开' },
|
|
472
561
|
close: { payload: { id: { type: 'string' } }, desc: 'layout=columns:面板关闭' },
|
|
562
|
+
...KIT_READ_STATE_EMIT_DEFS,
|
|
473
563
|
},
|
|
474
564
|
keyboard: { layout: 'tree', wrap: false, typeahead: false, focus_model: 'roving', space: 'activate' },
|
|
475
565
|
},
|
package/src/data/mockup.ts
CHANGED
|
@@ -11,8 +11,16 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
11
11
|
import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
|
|
12
12
|
import { createKitController, joinClass, num, str } from '../base/shared';
|
|
13
13
|
import { kitText } from '../i18n/kit-text';
|
|
14
|
-
import { classTokens, emptyNode, mk, shapeToneOf, textOf,
|
|
15
|
-
import {
|
|
14
|
+
import { classTokens, emptyNode, mk, shapeToneOf, textOf, TONE_TEXT, type Rec, type ShapeTone } from './shape-util';
|
|
15
|
+
import { imageUrlOf, singleOf } from './display-util';
|
|
16
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
17
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
18
|
+
import { KIT_FACE_EDGE_CLASS, kitWellRecipe } from '../recipes/surface';
|
|
19
|
+
import { KIT_DIVIDER_HEAD_CLASS } from '../recipes/divider';
|
|
20
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
21
|
+
import { mergeClass } from '../shared/merge-class';
|
|
22
|
+
import { kitHasProps } from './kit-contract';
|
|
23
|
+
import { KIT_ATTR_ADDRESS, KIT_ATTR_LINE, KIT_ATTR_VARIANT } from '../shared/dom-attrs';
|
|
16
24
|
|
|
17
25
|
export const KIT_MOCKUP_VARIANTS = ['browser', 'phone', 'window', 'code'] as const;
|
|
18
26
|
export type KitMockupVariant = (typeof KIT_MOCKUP_VARIANTS)[number];
|
|
@@ -20,35 +28,35 @@ export type KitMockupVariant = (typeof KIT_MOCKUP_VARIANTS)[number];
|
|
|
20
28
|
const KEYS = ['url', 'title', 'text', 'image', 'alt', 'lines'] as const;
|
|
21
29
|
|
|
22
30
|
const ROOT_CLASS = 'm-0 text-fg';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
31
|
+
// 示意框(浏览器 / 窗口 / 手机 / 代码)外缘 = 壳配方(容器边 + 容器阴影令牌,KT-B2);标题条只画朝内的一条分隔线(分隔线出口)
|
|
32
|
+
// 外框底 = 带色(surface-band);代码区 PRE_CLASS 才是井
|
|
33
|
+
const FRAME = `${KIT_FACE_EDGE_CLASS} bg-surface-band shadow-xs`;
|
|
34
|
+
const BROWSER_CLASS = `flex w-full flex-col overflow-hidden ${FRAME}`;
|
|
35
|
+
const WINDOW_CLASS = `flex w-full flex-col overflow-hidden ${FRAME}`;
|
|
36
|
+
const PHONE_CLASS = `mx-auto flex w-64 flex-col gap-2 ${FRAME} p-2 ring-2 ring-border-subtle`;
|
|
37
|
+
const CODE_CLASS = `flex w-full flex-col overflow-hidden ${FRAME}`;
|
|
38
|
+
const BAR_CLASS = `flex items-center gap-3 ${KIT_DIVIDER_HEAD_CLASS} px-3 py-2`;
|
|
28
39
|
const DOTS_CLASS = 'flex items-center gap-1.5';
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const
|
|
40
|
+
// 窗口三点 / 刘海是装饰轮廓:用线角色描边,不拿线令牌当填充
|
|
41
|
+
const DOT_CLASS = mergeClass('size-2.5 rounded-full', kitControlEdgeRecipe({ wrapper: true, hover: false }));
|
|
42
|
+
const ADDRESS_CLASS = mergeClass(mergeClass('min-w-0 flex-1 truncate rounded-item bg-surface px-3 py-1', kitTypographyRecipe('captionPlain')), 'text-fg-muted');
|
|
43
|
+
const TITLE_CLASS = mergeClass(mergeClass('min-w-0 flex-1 truncate text-center', kitTypographyRecipe('menuGroup')), 'text-fg-muted');
|
|
32
44
|
const SPACER_CLASS = 'w-10 shrink-0';
|
|
33
|
-
const NOTCH_CLASS = 'mx-auto h-1.5 w-16 rounded-full
|
|
34
|
-
const SCREEN_CLASS = 'flex h-96 flex-col overflow-hidden rounded-
|
|
45
|
+
const NOTCH_CLASS = mergeClass('mx-auto h-1.5 w-16 rounded-full', kitControlEdgeRecipe({ wrapper: true, hover: false }));
|
|
46
|
+
const SCREEN_CLASS = 'flex h-96 flex-col overflow-hidden rounded-item bg-surface';
|
|
35
47
|
const BODY_CLASS = 'flex min-h-40 flex-col bg-surface p-4 text-sm';
|
|
36
48
|
const IMG_CLASS = 'size-full object-cover';
|
|
37
|
-
const TEXT_CLASS = 'text
|
|
38
|
-
const PRE_CLASS = 'flex flex-col overflow-auto
|
|
49
|
+
const TEXT_CLASS = kitTypographyRecipe('text');
|
|
50
|
+
const PRE_CLASS = mergeClass(mergeClass('flex flex-col overflow-auto', kitWellRecipe()), 'p-4 font-mono text-sm');
|
|
39
51
|
const LINE_CLASS = 'flex gap-3';
|
|
40
|
-
const NUM_CLASS = 'w-8 shrink-0 select-none text-end text-fg-subtle';
|
|
52
|
+
const NUM_CLASS = 'w-8 shrink-0 select-none text-end tabular-nums text-fg-subtle';
|
|
41
53
|
const PREFIX_CLASS = 'shrink-0 select-none text-fg-subtle';
|
|
42
54
|
const LINE_TEXT_CLASS = 'min-w-0 flex-1 whitespace-pre-wrap break-all';
|
|
43
55
|
|
|
44
|
-
/**
|
|
56
|
+
/** 代码行的语气:只给文字着色(彩色走 -on-soft 令牌,常态行保持正文墨色) */
|
|
45
57
|
const LINE_TONE: Readonly<Record<ShapeTone, string>> = Object.freeze({
|
|
58
|
+
...TONE_TEXT,
|
|
46
59
|
neutral: 'text-fg',
|
|
47
|
-
primary: TONE_SOFT.primary,
|
|
48
|
-
info: TONE_SOFT.info,
|
|
49
|
-
success: TONE_SOFT.success,
|
|
50
|
-
warning: TONE_SOFT.warning,
|
|
51
|
-
danger: TONE_SOFT.danger,
|
|
52
60
|
});
|
|
53
61
|
|
|
54
62
|
export const KIT_MOCKUP_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
@@ -79,7 +87,7 @@ export function mockupLinesOf(raw: unknown, start = 1): KitMockupLine[] {
|
|
|
79
87
|
}
|
|
80
88
|
|
|
81
89
|
function content(src: Rec): HTMLElement | null {
|
|
82
|
-
const image =
|
|
90
|
+
const image = imageUrlOf(src.image);
|
|
83
91
|
if (image !== '') {
|
|
84
92
|
const img = mk('img', IMG_CLASS);
|
|
85
93
|
img.setAttribute('src', image);
|
|
@@ -118,11 +126,13 @@ export function createMockup(): SomaComponentDefinition {
|
|
|
118
126
|
root.textContent = '';
|
|
119
127
|
const variant = mockupVariantOf(p.variant);
|
|
120
128
|
const src = singleOf(p.data, p, KEYS);
|
|
121
|
-
root.setAttribute(
|
|
129
|
+
root.setAttribute(KIT_ATTR_VARIANT, variant);
|
|
122
130
|
if (variant === 'code') {
|
|
123
131
|
const lines = mockupLinesOf(src.lines, num(p.start) ?? 1);
|
|
124
132
|
if (lines.length === 0) { root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.no_content', undefined, root)))); return; }
|
|
125
133
|
const frame = mk('div', CODE_CLASS);
|
|
134
|
+
// C 项:外框去留原按祖先判断;新流水线下交取值表,组件不再标
|
|
135
|
+
if (!kitHasProps(p)) markKitEdge(frame);
|
|
126
136
|
const bar = mk('div', BAR_CLASS);
|
|
127
137
|
const dots = mk('div', DOTS_CLASS);
|
|
128
138
|
for (let i = 0; i < 3; i += 1) dots.appendChild(mk('span', DOT_CLASS));
|
|
@@ -133,7 +143,7 @@ export function createMockup(): SomaComponentDefinition {
|
|
|
133
143
|
pre.setAttribute('aria-label', kitText('soma.kit.mk_code', undefined, root));
|
|
134
144
|
for (const line of lines) {
|
|
135
145
|
const row = mk('div', LINE_CLASS);
|
|
136
|
-
row.setAttribute(
|
|
146
|
+
row.setAttribute(KIT_ATTR_LINE, String(line.no));
|
|
137
147
|
row.appendChild(mk('span', NUM_CLASS, String(line.no)));
|
|
138
148
|
if (line.prefix !== '') row.appendChild(mk('span', PREFIX_CLASS, line.prefix));
|
|
139
149
|
row.appendChild(mk('span', `${LINE_TEXT_CLASS} ${LINE_TONE[line.tone]}`, line.text));
|
|
@@ -146,6 +156,7 @@ export function createMockup(): SomaComponentDefinition {
|
|
|
146
156
|
const body = content(src);
|
|
147
157
|
if (variant === 'phone') {
|
|
148
158
|
const frame = mk('div', PHONE_CLASS);
|
|
159
|
+
if (!kitHasProps(p)) markKitEdge(frame);
|
|
149
160
|
frame.appendChild(mk('div', NOTCH_CLASS));
|
|
150
161
|
const screen = mk('div', SCREEN_CLASS);
|
|
151
162
|
if (body) screen.appendChild(body); else screen.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.no_content', undefined, root))));
|
|
@@ -154,13 +165,14 @@ export function createMockup(): SomaComponentDefinition {
|
|
|
154
165
|
return;
|
|
155
166
|
}
|
|
156
167
|
const frame = mk('div', variant === 'browser' ? BROWSER_CLASS : WINDOW_CLASS);
|
|
168
|
+
if (!kitHasProps(p)) markKitEdge(frame);
|
|
157
169
|
const bar = mk('div', BAR_CLASS);
|
|
158
170
|
const dots = mk('div', DOTS_CLASS);
|
|
159
171
|
for (let i = 0; i < 3; i += 1) dots.appendChild(mk('span', DOT_CLASS));
|
|
160
172
|
bar.appendChild(dots);
|
|
161
173
|
if (variant === 'browser') {
|
|
162
174
|
const address = mk('div', ADDRESS_CLASS, textOf(src.url));
|
|
163
|
-
address.setAttribute(
|
|
175
|
+
address.setAttribute(KIT_ATTR_ADDRESS, '');
|
|
164
176
|
address.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
|
|
165
177
|
bar.appendChild(address);
|
|
166
178
|
} else {
|