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
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// Waterfall:收支桥 / 瀑布图(layer: data,写死形状,accept: list)。起点 → 逐项增减 → 终点:浮动柱 + 连接线 + 涨跌色。
|
|
2
|
+
//
|
|
3
|
+
// 数据:`data` 是 [{ label, value, total? }];键名可由 `map` 改写。value 是增减量(正 = 增,负 = 减);
|
|
4
|
+
// `total` 为真的行把 value 当作绝对值(起点 / 小计 / 终点:柱从 0 起,累计值重置到它)。
|
|
5
|
+
// `show_total` 为真时在末尾自动补一根累计合计柱(名取 total_label)。
|
|
6
|
+
// 色:增 / 减 / 合计三种语义;`up_is` = good(缺省,增为 success、减为 danger)| bad(成本类:增为 danger、减为 success,即涨跌色反转开关);合计柱 primary。
|
|
7
|
+
// 结构:SVG 只画几何(柱 + 虚线连接 + 零线,宽度写成 viewBox 单位,preserveAspectRatio none,描边 non-scaling-stroke),
|
|
8
|
+
// 名与值是下方两行等宽 HTML 列(与 SVG 柱同列对齐);每列读屏名「label 值」,颜色之外值带正负号。
|
|
9
|
+
// 抄 AntV G2 / ECharts waterfall(Apache-2.0):柱宽占列 0.6,连接线细虚线,增减双色 + 合计色;柱宽比读 design kit-limits#dataLimits.summaryShapes.waterfall。
|
|
10
|
+
|
|
11
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
12
|
+
import { kitMarkDataFacts, kitMarkPart } from './kit-contract';
|
|
13
|
+
import { KIT_DATA_LIMITS } from 'soma-foundation/kit-limits';
|
|
14
|
+
import { createKitController, formatValue, joinClass, num, str, type KitProps } from '../base/shared';
|
|
15
|
+
import { KIT_TIP_ATTR, KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
|
|
16
|
+
import { releaseReasonTipsIn } from '../base/reason-tip';
|
|
17
|
+
import { kitText } from '../i18n/kit-text';
|
|
18
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
19
|
+
import { mergeClass } from '../shared/merge-class';
|
|
20
|
+
import { KIT_ATTR_STEP } from '../shared/dom-attrs';
|
|
21
|
+
import { classTokens, emptyNode, keyMap, mk, rowsOf, textOf } from './shape-util';
|
|
22
|
+
import {
|
|
23
|
+
plainNumber, SUMMARY_COLOR_CLASSES, svgEl, toneFill, WATERFALL_BAR_RATIO_PCT, WATERFALL_MAX_STEPS, WATERFALL_PLOT_HEIGHT, WATERFALL_PLOT_WIDTH,
|
|
24
|
+
} from './summary-util';
|
|
25
|
+
import type { ShapeTone } from './shape-util';
|
|
26
|
+
|
|
27
|
+
export const KIT_WATERFALL_DEFAULT_MAP = Object.freeze({ label: 'label', value: 'value', total: 'total' });
|
|
28
|
+
|
|
29
|
+
const ROOT_CLASS = 'flex w-full flex-col gap-1.5';
|
|
30
|
+
const PLOT_CLASS = 'block h-40 w-full';
|
|
31
|
+
const LINK_CLASS = 'stroke-border';
|
|
32
|
+
const ZERO_CLASS = 'stroke-border-subtle';
|
|
33
|
+
const ROW_CLASS = 'm-0 flex w-full list-none p-0';
|
|
34
|
+
const LABEL_CELL_CLASS = mergeClass('min-w-0 flex-1 truncate px-0.5 text-center text-fg-muted', kitTypographyRecipe('caption'));
|
|
35
|
+
const VALUE_CELL_CLASS = 'min-w-0 flex-1 truncate px-0.5 text-center text-xs font-medium tabular-nums';
|
|
36
|
+
const VALUE_TONE: Readonly<Record<ShapeTone, string>> = Object.freeze({
|
|
37
|
+
neutral: 'text-fg', primary: 'text-fg', info: 'text-info-on-soft', success: 'text-success-on-soft', warning: 'text-warning-on-soft', danger: 'text-danger-on-soft',
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const KIT_WATERFALL_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
41
|
+
ROOT_CLASS, PLOT_CLASS, LINK_CLASS, ZERO_CLASS, ROW_CLASS, LABEL_CELL_CLASS, VALUE_CELL_CLASS, Object.values(VALUE_TONE), SUMMARY_COLOR_CLASSES,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export interface KitWaterfallStep {
|
|
45
|
+
label: string;
|
|
46
|
+
/** 显示值:增减量,合计柱为绝对值 */
|
|
47
|
+
value: number;
|
|
48
|
+
total: boolean;
|
|
49
|
+
/** 柱的起止累计值(from <= to 不一定,减项 from > to) */
|
|
50
|
+
from: number;
|
|
51
|
+
to: number;
|
|
52
|
+
tone: ShapeTone;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 源数据 -> 步骤(纯函数):累计值逐项推进;total 行重置累计;show_total 补末尾合计 */
|
|
56
|
+
export function waterfallStepsOf(data: unknown, mapRaw: unknown, upIsGood: boolean, showTotal: boolean, totalLabel: string): KitWaterfallStep[] {
|
|
57
|
+
const m = keyMap(KIT_WATERFALL_DEFAULT_MAP, mapRaw);
|
|
58
|
+
const up: ShapeTone = upIsGood ? 'success' : 'danger';
|
|
59
|
+
const down: ShapeTone = upIsGood ? 'danger' : 'success';
|
|
60
|
+
const steps: KitWaterfallStep[] = [];
|
|
61
|
+
let acc = 0;
|
|
62
|
+
for (const r of rowsOf(data).slice(0, WATERFALL_MAX_STEPS)) {
|
|
63
|
+
const v = num(r[m.value]) ?? 0;
|
|
64
|
+
const isTotal = r[m.total] === true;
|
|
65
|
+
const from = isTotal ? 0 : acc;
|
|
66
|
+
const to = isTotal ? v : acc + v;
|
|
67
|
+
acc = to;
|
|
68
|
+
steps.push({ label: textOf(r[m.label]), value: v, total: isTotal, from, to, tone: isTotal ? 'primary' : v >= 0 ? up : down });
|
|
69
|
+
}
|
|
70
|
+
if (showTotal && steps.length > 0 && !steps[steps.length - 1]!.total) {
|
|
71
|
+
steps.push({ label: totalLabel, value: acc, total: true, from: 0, to: acc, tone: 'primary' });
|
|
72
|
+
}
|
|
73
|
+
return steps;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function createWaterfall(): SomaComponentDefinition {
|
|
77
|
+
return {
|
|
78
|
+
contract: {
|
|
79
|
+
name: 'Waterfall',
|
|
80
|
+
layer: 'data',
|
|
81
|
+
props: {
|
|
82
|
+
data: { type: 'array', default: [], desc: '步骤 [{ label, value, total? }];value 是增减量,total 为真时是绝对值(起点 / 小计 / 终点)' },
|
|
83
|
+
map: { type: 'object', default: {}, desc: '键名对照:组件期望的键 -> 数据里的键' },
|
|
84
|
+
up_is: { type: 'string', default: 'good', desc: '涨跌色:good(缺省,增 success / 减 danger)| bad(成本类反转:增 danger / 减 success)' },
|
|
85
|
+
show_total: { type: 'boolean', default: false, desc: '末尾自动补一根累计合计柱' },
|
|
86
|
+
total_label: { type: 'string', default: '', desc: '自动合计柱的名;缺省取内置「合计」' },
|
|
87
|
+
format: { type: 'string', default: '', desc: '值格式(soma-foundation/values 写法)' },
|
|
88
|
+
locale: { type: 'string', default: '', desc: '格式化语言' },
|
|
89
|
+
unit: { type: 'string', default: '', desc: '单位后缀(format 为空时追加)' },
|
|
90
|
+
label: { type: 'string', default: '', desc: '无障碍名称' },
|
|
91
|
+
empty_text: { type: 'string', default: '—', desc: '无数据时的文案' },
|
|
92
|
+
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
93
|
+
},
|
|
94
|
+
emits: {},
|
|
95
|
+
},
|
|
96
|
+
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
97
|
+
controllerFactory: createKitController((_api) => ({
|
|
98
|
+
render(root: HTMLElement, p: KitProps): void {
|
|
99
|
+
root.className = joinClass(ROOT_CLASS, p.class);
|
|
100
|
+
releaseReasonTipsIn(root);
|
|
101
|
+
root.textContent = '';
|
|
102
|
+
const totalLabel = str(p.total_label, kitText('soma.kit.total_label', undefined, root));
|
|
103
|
+
const steps = waterfallStepsOf(p.data, p.map, str(p.up_is, 'good') !== 'bad', p.show_total === true || p.show_total === 'true', totalLabel);
|
|
104
|
+
// 数据状态自报:本组件只有空与常态(没有加载 / 出错入参)
|
|
105
|
+
kitMarkDataFacts(root, { empty: steps.length === 0 });
|
|
106
|
+
if (steps.length === 0) { root.appendChild(emptyNode(str(p.empty_text, '—'))); return; }
|
|
107
|
+
const format = str(p.format);
|
|
108
|
+
const unit = str(p.unit);
|
|
109
|
+
const locale = str(p.locale);
|
|
110
|
+
const show = (n: number): string => (format === '' ? `${plainNumber(n)}${unit}` : formatValue(n, format, locale));
|
|
111
|
+
const signed = (s: KitWaterfallStep): string => (s.total || s.value < 0 ? show(s.value) : `+${show(s.value)}`);
|
|
112
|
+
|
|
113
|
+
const levels = steps.flatMap((s) => [s.from, s.to]);
|
|
114
|
+
const hi = Math.max(0, ...levels);
|
|
115
|
+
const lo = Math.min(0, ...levels);
|
|
116
|
+
const span = hi - lo > 0 ? hi - lo : 1;
|
|
117
|
+
const H = WATERFALL_PLOT_HEIGHT;
|
|
118
|
+
const W = WATERFALL_PLOT_WIDTH;
|
|
119
|
+
const padY = KIT_DATA_LIMITS.chart.style.lineWidth;
|
|
120
|
+
const innerH = H - padY * 2;
|
|
121
|
+
const y = (v: number): number => padY + ((hi - v) / span) * innerH;
|
|
122
|
+
const barW = (W * WATERFALL_BAR_RATIO_PCT) / 100;
|
|
123
|
+
const svg = svgEl('svg', {
|
|
124
|
+
viewBox: `0 0 ${W * steps.length} ${H}`, preserveAspectRatio: 'none', class: PLOT_CLASS, role: 'img',
|
|
125
|
+
'aria-label': `${str(p.label)} ${steps.map((s) => `${s.label} ${signed(s)}`).join(', ')}`.trim(),
|
|
126
|
+
});
|
|
127
|
+
svg.appendChild(svgEl('line', { x1: '0', x2: String(W * steps.length), y1: String(y(0)), y2: String(y(0)), class: ZERO_CLASS, 'stroke-width': '1', 'vector-effect': 'non-scaling-stroke' }));
|
|
128
|
+
steps.forEach((s, i) => {
|
|
129
|
+
const x = i * W + (W - barW) / 2;
|
|
130
|
+
const top = y(Math.max(s.from, s.to));
|
|
131
|
+
const h = Math.max(Math.abs(y(s.from) - y(s.to)), 1);
|
|
132
|
+
const name = s.label || String(i + 1);
|
|
133
|
+
const tip = `${name} / ${signed(s)} / ${totalLabel} ${show(s.to)}`;
|
|
134
|
+
svg.appendChild(svgEl('rect', {
|
|
135
|
+
x: String(x),
|
|
136
|
+
y: String(top),
|
|
137
|
+
width: String(barW),
|
|
138
|
+
height: String(h),
|
|
139
|
+
class: toneFill(s.tone),
|
|
140
|
+
[KIT_ATTR_STEP]: String(i),
|
|
141
|
+
[KIT_TIP_ATTR]: tip,
|
|
142
|
+
}));
|
|
143
|
+
const next = steps[i + 1];
|
|
144
|
+
if (next !== undefined) {
|
|
145
|
+
svg.appendChild(svgEl('line', {
|
|
146
|
+
x1: String(x + barW), x2: String((i + 1) * W + (W - barW) / 2), y1: String(y(s.to)), y2: String(y(s.to)),
|
|
147
|
+
class: LINK_CLASS, 'stroke-width': '1', 'stroke-dasharray': '3 3', 'vector-effect': 'non-scaling-stroke',
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
root.appendChild(svg);
|
|
152
|
+
const labels = mk('ul', ROW_CLASS);
|
|
153
|
+
const values = mk('ul', ROW_CLASS);
|
|
154
|
+
for (const s of steps) {
|
|
155
|
+
const lab = mk('li', LABEL_CELL_CLASS, s.label);
|
|
156
|
+
lab.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
|
|
157
|
+
kitMarkPart(lab, 'field-name');
|
|
158
|
+
labels.appendChild(lab);
|
|
159
|
+
const valText = signed(s);
|
|
160
|
+
const val = mk('li', `${VALUE_CELL_CLASS} ${VALUE_TONE[s.tone]}`, valText);
|
|
161
|
+
val.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
|
|
162
|
+
kitMarkPart(val, 'value');
|
|
163
|
+
values.appendChild(val);
|
|
164
|
+
}
|
|
165
|
+
labels.setAttribute('aria-hidden', 'true');
|
|
166
|
+
values.setAttribute('aria-hidden', 'true');
|
|
167
|
+
root.append(labels, values);
|
|
168
|
+
},
|
|
169
|
+
})),
|
|
170
|
+
};
|
|
171
|
+
}
|
package/src/data/watermark.ts
CHANGED
|
@@ -63,10 +63,14 @@ export function watermarkConfig(data: unknown, now: Date = new Date()): KitWater
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
/** 估算文字宽度:CJK 全角算 1em
|
|
66
|
+
/** 估算文字宽度:CJK 全角算 1em,大写拉丁字母与宽符号算 0.78em 防擦碰,其余约 0.6em */
|
|
67
67
|
function estimateWidth(text: string, fontSize: number): number {
|
|
68
68
|
let em = 0;
|
|
69
|
-
for (const ch of text)
|
|
69
|
+
for (const ch of text) {
|
|
70
|
+
if (/[⺀-鿿-]/.test(ch)) em += 1;
|
|
71
|
+
else if (/[A-Z@#%&]/.test(ch)) em += 0.78;
|
|
72
|
+
else em += 0.6;
|
|
73
|
+
}
|
|
70
74
|
return Math.ceil(em * fontSize);
|
|
71
75
|
}
|
|
72
76
|
|
|
@@ -80,21 +84,40 @@ export function watermarkTile(cfg: KitWatermarkConfig): KitWatermarkTile {
|
|
|
80
84
|
|
|
81
85
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
82
86
|
|
|
87
|
+
interface WatermarkCache {
|
|
88
|
+
mountedAt: Date;
|
|
89
|
+
sig: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const WM_CACHE = new WeakMap<HTMLElement, WatermarkCache>();
|
|
93
|
+
|
|
83
94
|
function svgEl(tag: string, attrs: Record<string, string>): SVGElement {
|
|
84
95
|
const el = document.createElementNS(SVG_NS, tag);
|
|
85
96
|
for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, v);
|
|
86
97
|
return el;
|
|
87
98
|
}
|
|
88
99
|
|
|
89
|
-
/** 把水印画进 root(组件本体与 workspace-frame
|
|
90
|
-
export function paintKitWatermark(root: HTMLElement, data: unknown, className: unknown, patternId: string, now
|
|
100
|
+
/** 把水印画进 root(组件本体与 workspace-frame 共用);配置签名未变时短路跳过重建 <svg>,没有文字时清空 */
|
|
101
|
+
export function paintKitWatermark(root: HTMLElement, data: unknown, className: unknown, patternId: string, now?: Date): void {
|
|
91
102
|
root.className = joinClass(ROOT_CLASS, className);
|
|
92
103
|
root.setAttribute('aria-hidden', 'true');
|
|
93
|
-
|
|
104
|
+
let cache = WM_CACHE.get(root);
|
|
105
|
+
if (cache === undefined) {
|
|
106
|
+
cache = { mountedAt: now ?? new Date(), sig: '' };
|
|
107
|
+
WM_CACHE.set(root, cache);
|
|
108
|
+
}
|
|
109
|
+
const effectiveNow = now ?? cache.mountedAt;
|
|
110
|
+
const cfg = watermarkConfig(data, effectiveNow);
|
|
94
111
|
if (cfg.lines.length === 0) {
|
|
95
|
-
|
|
112
|
+
cache.sig = '';
|
|
113
|
+
if (root.childNodes.length > 0) root.replaceChildren();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const sig = JSON.stringify([patternId, cfg.lines, cfg.rotate, cfg.opacity, cfg.fontSize, cfg.gapX, cfg.gapY]);
|
|
117
|
+
if (cache.sig === sig && root.querySelector('svg') !== null) {
|
|
96
118
|
return;
|
|
97
119
|
}
|
|
120
|
+
cache.sig = sig;
|
|
98
121
|
const tile = watermarkTile(cfg);
|
|
99
122
|
const svg = svgEl('svg', { class: SVG_CLASS, 'aria-hidden': 'true', focusable: 'false' });
|
|
100
123
|
const pattern = svgEl('pattern', {
|
|
@@ -130,6 +153,12 @@ export function createWatermark(): SomaComponentDefinition {
|
|
|
130
153
|
},
|
|
131
154
|
templateHtml: `<div data-soma-id="root" aria-hidden="true" class="${ROOT_CLASS}"></div>`,
|
|
132
155
|
controllerFactory: createKitController(() => ({
|
|
156
|
+
attach(root) {
|
|
157
|
+
return () => {
|
|
158
|
+
ids.delete(root);
|
|
159
|
+
WM_CACHE.delete(root);
|
|
160
|
+
};
|
|
161
|
+
},
|
|
133
162
|
render(root, p) {
|
|
134
163
|
let id = ids.get(root);
|
|
135
164
|
if (id === undefined) { id = nextUid('kit-wm'); ids.set(root, id); }
|
package/src/data/wrap.ts
CHANGED
|
@@ -9,10 +9,11 @@ import type {
|
|
|
9
9
|
} from 'soma-core';
|
|
10
10
|
import { createKitController, findRoot } from '../base/shared';
|
|
11
11
|
import { kitLocaleAt } from '../i18n/kit-text';
|
|
12
|
-
import { checkClasses, mergeClass } from '../
|
|
12
|
+
import { checkClasses, mergeClass } from '../shared/merge-class';
|
|
13
13
|
import { mountKitComponent, type KitMount } from './embed';
|
|
14
14
|
import { attachWrappedCandidates, splitClassTokens } from './wrapped-candidates';
|
|
15
|
-
import { kitFail } from '../
|
|
15
|
+
import { kitFail } from '../shared/kit-error';
|
|
16
|
+
import { KIT_ATTR_COMPOSE_SLOT } from '../shared/dom-attrs';
|
|
16
17
|
|
|
17
18
|
export type PackProps = Record<string, unknown>;
|
|
18
19
|
|
|
@@ -62,7 +63,14 @@ export function wrapKitDataComponent(inner: SomaComponentDefinition, options: Wr
|
|
|
62
63
|
const page = kitLocaleAt(api.host);
|
|
63
64
|
return page === '' ? props : { ...props, locale: page };
|
|
64
65
|
};
|
|
65
|
-
|
|
66
|
+
// 页面线写的判定(props.kit)属于这个组件实例,包装只是改名与翻译入参,判定要原样到达底层组件:
|
|
67
|
+
// adapt 是应用写的纯函数,常按白名单挑键而漏掉 kit,这里在它没显式给 kit 时补回(显式给了以应用为准)
|
|
68
|
+
const withKit = (raw: PackProps, adapted: PackProps): PackProps =>
|
|
69
|
+
raw.kit === undefined || 'kit' in adapted ? adapted : { ...adapted, kit: raw.kit };
|
|
70
|
+
const innerProps = (): PackProps => {
|
|
71
|
+
const raw = read();
|
|
72
|
+
return withKit(raw, options.adapt(withLocale(raw)));
|
|
73
|
+
};
|
|
66
74
|
const innerCtx: SomaComponentControllerContext = {
|
|
67
75
|
host: api.host,
|
|
68
76
|
props: innerProps(),
|
|
@@ -76,6 +84,7 @@ export function wrapKitDataComponent(inner: SomaComponentDefinition, options: Wr
|
|
|
76
84
|
|
|
77
85
|
return {
|
|
78
86
|
attach() {
|
|
87
|
+
innerCtx.props = innerProps();
|
|
79
88
|
innerCtrl.onMount?.();
|
|
80
89
|
return () => {
|
|
81
90
|
firstRender = true;
|
|
@@ -83,6 +92,7 @@ export function wrapKitDataComponent(inner: SomaComponentDefinition, options: Wr
|
|
|
83
92
|
};
|
|
84
93
|
},
|
|
85
94
|
render() {
|
|
95
|
+
innerCtx.props = innerProps();
|
|
86
96
|
if (firstRender) {
|
|
87
97
|
firstRender = false;
|
|
88
98
|
return;
|
|
@@ -102,7 +112,7 @@ export type ComposeEventForward =
|
|
|
102
112
|
export interface ComposeDataPart {
|
|
103
113
|
/** 子组件定义(如 createStatGroup() / createRecordCard() / createTimeline()) */
|
|
104
114
|
component: SomaComponentDefinition | (() => SomaComponentDefinition);
|
|
105
|
-
/** 默认布局下该子槽位容器的 Tailwind 类(如 'col-span-12 @md:col-span-6 rounded-
|
|
115
|
+
/** 默认布局下该子槽位容器的 Tailwind 类(如 'col-span-12 @md:col-span-6 rounded-card border border-border p-4') */
|
|
106
116
|
slotClass?: string;
|
|
107
117
|
/** 父组件 props -> 该子组件 props(纯函数) */
|
|
108
118
|
adaptProps(parentProps: PackProps): PackProps;
|
|
@@ -187,6 +197,8 @@ export function composeKitDataComponents(options: ComposeDataOptions): SomaCompo
|
|
|
187
197
|
const read = (): PackProps => (api.props() ?? {}) as PackProps;
|
|
188
198
|
let rootEl: HTMLElement | null = null;
|
|
189
199
|
let mounts: Array<{ key: string; spec: ComposeDataPart; mount: KitMount }> = [];
|
|
200
|
+
let firstRender = false;
|
|
201
|
+
let mountedPropsRef: unknown = undefined;
|
|
190
202
|
|
|
191
203
|
const applyRootClass = (p: PackProps): void => {
|
|
192
204
|
if (!rootEl) return;
|
|
@@ -200,7 +212,7 @@ export function composeKitDataComponents(options: ComposeDataOptions): SomaCompo
|
|
|
200
212
|
const map: Record<string, HTMLElement> = {};
|
|
201
213
|
for (const { key, spec } of resolvedParts) {
|
|
202
214
|
const slot = doc.createElement('div');
|
|
203
|
-
slot.setAttribute(
|
|
215
|
+
slot.setAttribute(KIT_ATTR_COMPOSE_SLOT, key);
|
|
204
216
|
if (spec.slotClass) slot.className = spec.slotClass;
|
|
205
217
|
target.appendChild(slot);
|
|
206
218
|
map[key] = slot;
|
|
@@ -212,7 +224,10 @@ export function composeKitDataComponents(options: ComposeDataOptions): SomaCompo
|
|
|
212
224
|
attach(root) {
|
|
213
225
|
rootEl = root;
|
|
214
226
|
rootEl.textContent = '';
|
|
215
|
-
const
|
|
227
|
+
const rawProps = api.props();
|
|
228
|
+
const p = (rawProps ?? {}) as PackProps;
|
|
229
|
+
mountedPropsRef = rawProps;
|
|
230
|
+
firstRender = true;
|
|
216
231
|
applyRootClass(p);
|
|
217
232
|
const slots = buildSlots(rootEl, p);
|
|
218
233
|
mounts = [];
|
|
@@ -242,12 +257,19 @@ export function composeKitDataComponents(options: ComposeDataOptions): SomaCompo
|
|
|
242
257
|
return () => {
|
|
243
258
|
for (const item of mounts) item.mount.destroy();
|
|
244
259
|
mounts = [];
|
|
260
|
+
firstRender = false;
|
|
261
|
+
mountedPropsRef = undefined;
|
|
245
262
|
rootEl = null;
|
|
246
263
|
};
|
|
247
264
|
},
|
|
248
265
|
render(root, p) {
|
|
249
266
|
rootEl = root;
|
|
250
267
|
applyRootClass(p as PackProps);
|
|
268
|
+
// 首次挂载时 attach 已用当前 props 完成子组件首次渲染,跳过首帧重复的全量 setProps 重绘
|
|
269
|
+
if (firstRender) {
|
|
270
|
+
firstRender = false;
|
|
271
|
+
if (p === mountedPropsRef) return;
|
|
272
|
+
}
|
|
251
273
|
for (const item of mounts) {
|
|
252
274
|
item.mount.setProps(item.spec.adaptProps(p as PackProps));
|
|
253
275
|
}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
// 页面标题仍进信封)。画布无内边距(N-2),给自带页头的整页产品用。
|
|
3
3
|
|
|
4
4
|
import type { KitFrameDefinition } from './types';
|
|
5
|
+
import { KIT_CANVAS_CLASS } from '../recipes/chrome-surface';
|
|
5
6
|
import { checkFrameClasses, checkNoHeaderExtras, checkSlots, classAttr, finishFrame, rootClass, slotFragment, slotWrapper } from './shared';
|
|
6
7
|
|
|
7
|
-
/** 画布无内边距(N-2
|
|
8
|
-
const BLANK_CANVAS_CLASS =
|
|
8
|
+
/** 画布无内边距(N-2):只有底色与满屏高度,纵向 flex 贯通供 ResultPage / SignInPage 居中与撑满视口;要内边距由 frame.class 自加 */
|
|
9
|
+
const BLANK_CANVAS_CLASS = `${KIT_CANVAS_CLASS} min-h-screen flex flex-col text-sm text-fg`;
|
|
10
|
+
const BLANK_MAIN_CLASS = 'flex flex-1 flex-col';
|
|
9
11
|
|
|
10
12
|
export const blankFrame: KitFrameDefinition = {
|
|
11
13
|
kind: 'blank-frame',
|
|
@@ -14,7 +16,7 @@ export const blankFrame: KitFrameDefinition = {
|
|
|
14
16
|
compile(input) {
|
|
15
17
|
const diagnostics = [...checkSlots('blank-frame', ['main'], ['main'], input), ...checkFrameClasses(input), ...checkNoHeaderExtras('blank-frame', input)];
|
|
16
18
|
const main = slotFragment(input.slots.main);
|
|
17
|
-
const html = `<div data-soma-id="frame__root"${classAttr(rootClass(input, BLANK_CANVAS_CLASS))}>${slotWrapper('main',
|
|
18
|
-
return finishFrame([main], html, [], diagnostics);
|
|
19
|
+
const html = `<div data-soma-id="frame__root"${classAttr(rootClass(input, BLANK_CANVAS_CLASS))}>${slotWrapper('main', BLANK_MAIN_CLASS, input, main.html)}</div>`;
|
|
20
|
+
return finishFrame([main], html, ['flex', 'flex-1', 'flex-col'], diagnostics);
|
|
19
21
|
},
|
|
20
22
|
};
|
package/src/frames/index.ts
CHANGED
|
@@ -14,11 +14,10 @@ export { blankFrame, singleFrame, splitFrame, tabsFrame, topMainFrame, workspace
|
|
|
14
14
|
export { checkWorkspaceConfig } from './workspace-frame';
|
|
15
15
|
export { createKitPageBar, KIT_PAGE_BAR_CLASS_CANDIDATES } from './page-bar';
|
|
16
16
|
export { createKitPageStatus, KIT_PAGE_STATUS_CLASS_CANDIDATES } from './page-status';
|
|
17
|
-
export { createKitListSummary, KIT_LIST_SUMMARY_CLASS_CANDIDATES } from './list-summary';
|
|
18
17
|
export { parsePageHeader } from './page-header';
|
|
19
18
|
export { headerFragment } from './shared';
|
|
20
19
|
export { createKitWorkspace, mountKitWorkspace, workspaceLabels, withFrameQuery, KIT_WORKSPACE_CLASS_CANDIDATES } from './workspace-frame/view';
|
|
21
|
-
export type { KitWorkspaceHandle, KitWorkspaceEmit } from './workspace-frame/view';
|
|
20
|
+
export type { KitWorkspaceHandle, KitWorkspaceEmit, KitWorkspaceDirtyConfirmReason, KitWorkspaceDirtyConfirmOptions } from './workspace-frame/view';
|
|
22
21
|
export {
|
|
23
22
|
createWorkspaceState, openTab as openWorkspaceTab, switchTab as switchWorkspaceTab, closeTab as closeWorkspaceTab,
|
|
24
23
|
closeOtherTabs as closeOtherWorkspaceTabs, closeAllTabs as closeAllWorkspaceTabs, closeTabsByKeys as closeWorkspaceTabsByKeys, refreshTab as refreshWorkspaceTab,
|
|
@@ -28,8 +27,9 @@ export type { WorkspaceState, WorkspaceTab, WorkspaceTabInput } from './workspac
|
|
|
28
27
|
|
|
29
28
|
export { createKitTabsWiring } from './tabs-frame/wiring';
|
|
30
29
|
export { createKitSplitWiring } from './split-frame/wiring';
|
|
31
|
-
export {
|
|
32
|
-
export
|
|
30
|
+
export { createKitFrameResidentComponents } from './resident-components';
|
|
31
|
+
export { attachResizeHandle, clampStep } from '../base/resize-handle';
|
|
32
|
+
export type { ResizeHandle, ResizeHandleOptions, ResizeAxis, ResizeSource } from '../base/resize-handle';
|
|
33
33
|
export { checkSplitConfig, splitSpanClass, splitSpanClasses, KIT_SPLIT_CLASS_CANDIDATES } from './split-frame';
|
|
34
34
|
export type { SplitConfig, SplitDirection, SplitSide } from './split-frame';
|
|
35
35
|
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// 应用级继承外壳(kit.app.yaml#layout 的 header / sidebar / footer)与产品旋钮(product.emphasis / product.surface)的渲染。
|
|
2
|
+
// 原住 compile/compile-page.ts(业务层不该持有类串);现在是页面框层的写死模板,类串在 recipes/inherited-shell,编译环节只调用。
|
|
3
|
+
import { escapeHtml } from '../shared/escape';
|
|
4
|
+
import {
|
|
5
|
+
KIT_ATTR_CONTAINER, KIT_ATTR_EMPHASIS, KIT_ATTR_INHERITED_LAYOUT, KIT_ATTR_LAYOUT_FOOTER, KIT_ATTR_LAYOUT_HEADER, KIT_ATTR_LAYOUT_SIDEBAR,
|
|
6
|
+
KIT_ATTR_SIDEBAR_WIDTH, KIT_ATTR_SURFACE,
|
|
7
|
+
} from '../shared/dom-attrs';
|
|
8
|
+
import { KIT_EMBED_ATTR, isEmbedQuery } from '../shared/theme-runtime-shared';
|
|
9
|
+
import { KIT_WORKSPACE_FRAME_LIMITS } from 'soma-foundation/kit-limits';
|
|
10
|
+
import type { KitFragment } from '../object-renderer/fragment';
|
|
11
|
+
import {
|
|
12
|
+
KIT_PRODUCT_EMPHASIS_CLASSES, KIT_PRODUCT_SURFACE_CLASSES,
|
|
13
|
+
KIT_SHELL_ACTIONS_CLASS, KIT_SHELL_ACTION_LINK_CLASS, KIT_SHELL_BODY_CLASS, KIT_SHELL_BRAND_LINK_CLASS, KIT_SHELL_BRAND_TEXT_CLASS,
|
|
14
|
+
KIT_SHELL_FOOTER_CLASS, KIT_SHELL_FOOTER_LINKS_CLASS, KIT_SHELL_FOOTER_LINK_CLASS, KIT_SHELL_HEADER_CLASS, KIT_SHELL_HEADER_LEFT_CLASS,
|
|
15
|
+
KIT_SHELL_MAIN_CLASS, KIT_SHELL_NAV_CLASS, KIT_SHELL_NAV_LINK_CLASS, KIT_SHELL_SIDEBAR_CLASS, KIT_SHELL_SIDEBAR_ITEM_CLASS,
|
|
16
|
+
KIT_SHELL_SIDEBAR_MENU_CLASS, KIT_SHELL_SIDEBAR_TITLE_CLASS,
|
|
17
|
+
} from '../recipes/inherited-shell';
|
|
18
|
+
import { KIT_SCOPE_ATTR, KIT_SCOPE_SHELL } from '../recipes/color-role';
|
|
19
|
+
import { kitNeutralClass } from '../biz/shared/pipeline';
|
|
20
|
+
import { KIT_REGION_ANCHORS, KIT_SHELL_FOOT_ANCHOR } from '../biz/layout-contracts';
|
|
21
|
+
import { kitSelfAttrs } from '../shared/page-attrs-runtime';
|
|
22
|
+
import { kitSingleValueClasses } from '../recipes/pipeline-runtime';
|
|
23
|
+
|
|
24
|
+
const SHELL_POLARITY_MODES = new Set(['navy', 'brand', 'graphite', 'dark', 'shell']);
|
|
25
|
+
const shellScopeAttrOf = (shell: string | undefined): string =>
|
|
26
|
+
shell !== undefined && SHELL_POLARITY_MODES.has(shell) ? ` ${KIT_SCOPE_ATTR}="${KIT_SCOPE_SHELL}"` : '';
|
|
27
|
+
|
|
28
|
+
export interface KitInheritedNavItem {
|
|
29
|
+
label: string;
|
|
30
|
+
href?: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** 继承外壳的输入形状(与 `kit.app.yaml#layout` 的 header / sidebar / footer 结构兼容) */
|
|
35
|
+
export interface KitInheritedLayout {
|
|
36
|
+
header?: {
|
|
37
|
+
brand?: { text: string; href?: string };
|
|
38
|
+
nav?: KitInheritedNavItem[];
|
|
39
|
+
actions?: KitInheritedNavItem[];
|
|
40
|
+
};
|
|
41
|
+
sidebar?: {
|
|
42
|
+
title?: string;
|
|
43
|
+
width?: number;
|
|
44
|
+
menu?: KitInheritedNavItem[];
|
|
45
|
+
};
|
|
46
|
+
footer?: {
|
|
47
|
+
text?: string;
|
|
48
|
+
links?: Array<{ label: string; href: string }>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function renderInheritedHeader(header: NonNullable<KitInheritedLayout['header']>, shellScopeAttr = ''): string {
|
|
53
|
+
let brandHtml = '';
|
|
54
|
+
if (header.brand?.text) {
|
|
55
|
+
const b = header.brand;
|
|
56
|
+
brandHtml = b.href
|
|
57
|
+
? `<a href="${escapeHtml(b.href)}" class="${KIT_SHELL_BRAND_LINK_CLASS}">${escapeHtml(b.text)}</a>`
|
|
58
|
+
: `<span class="${KIT_SHELL_BRAND_TEXT_CLASS}">${escapeHtml(b.text)}</span>`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let navHtml = '';
|
|
62
|
+
if (header.nav && header.nav.length > 0) {
|
|
63
|
+
const navItems = header.nav.map((it) => {
|
|
64
|
+
const target = it.url ?? it.href ?? '#';
|
|
65
|
+
return `<a href="${escapeHtml(target)}" class="${KIT_SHELL_NAV_LINK_CLASS}">${escapeHtml(it.label)}</a>`;
|
|
66
|
+
}).join('\n');
|
|
67
|
+
navHtml = `<nav class="${KIT_SHELL_NAV_CLASS}">\n${navItems}\n</nav>`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let actionsHtml = '';
|
|
71
|
+
if (header.actions && header.actions.length > 0) {
|
|
72
|
+
const actionItems = header.actions.map((it) => {
|
|
73
|
+
const target = it.url ?? it.href ?? "#";
|
|
74
|
+
return `<a href="${escapeHtml(target)}" class="${KIT_SHELL_ACTION_LINK_CLASS}">${escapeHtml(it.label)}</a>`;
|
|
75
|
+
}).join("\n");
|
|
76
|
+
actionsHtml = `<div class="${KIT_SHELL_ACTIONS_CLASS}">\n${actionItems}\n</div>`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const leftPart = [brandHtml, navHtml].filter(Boolean).join('\n');
|
|
80
|
+
return `<header ${KIT_ATTR_LAYOUT_HEADER}="true"${shellScopeAttr} class="${KIT_SHELL_HEADER_CLASS}">\n<div class="${KIT_SHELL_HEADER_LEFT_CLASS}">\n${leftPart}\n</div>\n${actionsHtml}\n</header>`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function renderInheritedSidebar(sidebar: NonNullable<KitInheritedLayout['sidebar']>): string {
|
|
84
|
+
let sidebarInner = '';
|
|
85
|
+
if (sidebar.title) {
|
|
86
|
+
sidebarInner += `<div class="${KIT_SHELL_SIDEBAR_TITLE_CLASS}">${escapeHtml(sidebar.title)}</div>\n`;
|
|
87
|
+
}
|
|
88
|
+
if (sidebar.menu && sidebar.menu.length > 0) {
|
|
89
|
+
const menuItems = sidebar.menu.map((it) => {
|
|
90
|
+
const target = it.url ?? it.href ?? "#";
|
|
91
|
+
return `<a href="${escapeHtml(target)}" class="${KIT_SHELL_SIDEBAR_ITEM_CLASS}">${escapeHtml(it.label)}</a>`;
|
|
92
|
+
}).join("\n");
|
|
93
|
+
sidebarInner += `<nav class="${KIT_SHELL_SIDEBAR_MENU_CLASS}">\n${menuItems}\n</nav>`;
|
|
94
|
+
}
|
|
95
|
+
return sidebarInner;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function renderInheritedFooter(footer: NonNullable<KitInheritedLayout['footer']>, next = false): string {
|
|
99
|
+
const textHtml = footer.text ? `<span>${escapeHtml(footer.text)}</span>` : '<span></span>';
|
|
100
|
+
let linksHtml = '';
|
|
101
|
+
if (footer.links && footer.links.length > 0) {
|
|
102
|
+
const linkItems = footer.links.map((link) => {
|
|
103
|
+
return `<a href="${escapeHtml(link.href)}" class="${KIT_SHELL_FOOTER_LINK_CLASS}">${escapeHtml(link.label)}</a>`;
|
|
104
|
+
}).join("\n");
|
|
105
|
+
linksHtml = `<div class="${KIT_SHELL_FOOTER_LINKS_CLASS}">\n${linkItems}\n</div>`;
|
|
106
|
+
}
|
|
107
|
+
// 新模式:补页脚锚点并自报层级角色「底栏」(foot),类按该角色剥掉取值表负责的底色、顶线与内边距(取值表按 data-kit-level="foot" 给);旧版原样
|
|
108
|
+
if (next) {
|
|
109
|
+
return `<footer data-soma-id="${KIT_SHELL_FOOT_ANCHOR}" ${KIT_ATTR_LAYOUT_FOOTER}="true"${kitSelfAttrs({ level: 'foot' })} class="${kitSingleValueClasses('foot', KIT_SHELL_FOOTER_CLASS)}">\n${textHtml}\n${linksHtml}\n</footer>`;
|
|
110
|
+
}
|
|
111
|
+
return `<footer ${KIT_ATTR_LAYOUT_FOOTER}="true" class="${KIT_SHELL_FOOTER_CLASS}">\n${textHtml}\n${linksHtml}\n</footer>`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 继承侧栏宽度类:宽度与密度无关,一律写任意值 px 类 `w-[Npx]`(--spacing 倍数类 w-44…w-80 会随密度缩放,不用)。
|
|
116
|
+
* 缺省取 design 真源 sidebarTiers 的默认档 px;有 width 时按原分档阈值归到标准密度下的精确 px(原 w-N 的 N×4),
|
|
117
|
+
* 其中 192..320 恰与真源档位 px 一致,176 无对应档位,仍按 176 输出。
|
|
118
|
+
*/
|
|
119
|
+
function sidebarWidthClass(width: number | undefined): string {
|
|
120
|
+
const tiers = KIT_WORKSPACE_FRAME_LIMITS.sidebarTiers;
|
|
121
|
+
const widthMap = tiers.widthPx as Record<string, number>;
|
|
122
|
+
if (width === undefined) return `w-[${widthMap[String(tiers.default)]}px]`;
|
|
123
|
+
const px = width <= 184 ? 176
|
|
124
|
+
: width <= 200 ? 192
|
|
125
|
+
: width <= 216 ? 208
|
|
126
|
+
: width <= 232 ? 224
|
|
127
|
+
: width <= 248 ? 240
|
|
128
|
+
: width <= 272 ? 256
|
|
129
|
+
: width <= 304 ? 288
|
|
130
|
+
: 320;
|
|
131
|
+
return `w-[${px}px]`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** 该应用布局是否真有外壳要渲染(header / sidebar / footer 任一) */
|
|
135
|
+
export function hasInheritedShell(layout: KitInheritedLayout | undefined): boolean {
|
|
136
|
+
return layout !== undefined && (layout.header !== undefined || layout.sidebar !== undefined || layout.footer !== undefined);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export { KIT_EMBED_ATTR, isEmbedQuery };
|
|
140
|
+
|
|
141
|
+
/** 同步嵌入模式标记(?embed=1 时在文档根写入 data-kit-embed="1" 以抑制继承的应用级顶栏) */
|
|
142
|
+
export function syncInheritedShellEmbed(doc?: Document, search?: string): boolean {
|
|
143
|
+
const embedded = isEmbedQuery(search);
|
|
144
|
+
const targetDoc = doc ?? (typeof document === 'undefined' ? undefined : document);
|
|
145
|
+
const el = targetDoc?.documentElement;
|
|
146
|
+
if (el !== undefined && el !== null && typeof el.setAttribute === 'function') {
|
|
147
|
+
if (embedded) el.setAttribute(KIT_EMBED_ATTR, '1');
|
|
148
|
+
else el.removeAttribute?.(KIT_EMBED_ATTR);
|
|
149
|
+
}
|
|
150
|
+
return embedded;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** 去掉页头的 nav(导航已由 top-nav 页面框的导航槽画成横向菜单,不另画一份文字链接) */
|
|
154
|
+
export function shellWithoutNav(layout: KitInheritedLayout): KitInheritedLayout {
|
|
155
|
+
if (layout.header === undefined) return layout;
|
|
156
|
+
const { nav: _nav, ...header } = layout.header;
|
|
157
|
+
return { ...layout, header };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function renderInheritedLayout(framedHtml: string, layout: KitInheritedLayout, options?: { embed?: boolean; shell?: string; pipeline?: 'legacy' | 'next' }): string {
|
|
161
|
+
// 新模式:区域作用域(外壳区)、容器外观由页面线的布局事件写到区域锚点上(外壳 frame__shell、顶栏 frame__top),这里不写
|
|
162
|
+
const next = options?.pipeline === 'next';
|
|
163
|
+
const shellScopeAttr = next ? '' : shellScopeAttrOf(options?.shell ?? (layout as { shell?: string }).shell);
|
|
164
|
+
const headerHtml = layout.header && options?.embed !== true
|
|
165
|
+
? (next ? nextHeader(renderInheritedHeader(layout.header, '')) : renderInheritedHeader(layout.header, shellScopeAttr))
|
|
166
|
+
: '';
|
|
167
|
+
let bodyHtml = framedHtml;
|
|
168
|
+
if (layout.sidebar !== undefined) {
|
|
169
|
+
const sidebarContent = renderInheritedSidebar(layout.sidebar);
|
|
170
|
+
const widthCls = sidebarWidthClass(layout.sidebar.width);
|
|
171
|
+
const widthAttr = layout.sidebar.width !== undefined ? ` ${KIT_ATTR_SIDEBAR_WIDTH}="${layout.sidebar.width}"` : "";
|
|
172
|
+
bodyHtml = next
|
|
173
|
+
? `<div class="${KIT_SHELL_BODY_CLASS}"><aside data-soma-id="${KIT_REGION_ANCHORS.shell}" ${KIT_ATTR_LAYOUT_SIDEBAR}="true"${widthAttr} class="${kitNeutralClass(`${widthCls} ${KIT_SHELL_SIDEBAR_CLASS}`)}">\n${sidebarContent}\n</aside><div class="${KIT_SHELL_MAIN_CLASS}">\n${framedHtml}\n</div></div>`
|
|
174
|
+
: `<div class="${KIT_SHELL_BODY_CLASS}"><aside ${KIT_ATTR_CONTAINER}="card" ${KIT_ATTR_LAYOUT_SIDEBAR}="true"${shellScopeAttr}${widthAttr} class="${widthCls} ${KIT_SHELL_SIDEBAR_CLASS}">\n${sidebarContent}\n</aside><div class="${KIT_SHELL_MAIN_CLASS}">\n${framedHtml}\n</div></div>`;
|
|
175
|
+
}
|
|
176
|
+
const footerHtml = layout.footer ? renderInheritedFooter(layout.footer, next) : '';
|
|
177
|
+
const parts = [headerHtml, bodyHtml, footerHtml].filter(Boolean);
|
|
178
|
+
return `<div ${KIT_ATTR_INHERITED_LAYOUT}="true">\n${parts.join('\n')}\n</div>`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** 新模式的顶栏:开标签补顶栏区域锚点、类换成中性结构类(顶栏外观由取值表按层级角色「顶栏」给) */
|
|
182
|
+
function nextHeader(html: string): string {
|
|
183
|
+
return html.replace(`<header ${KIT_ATTR_LAYOUT_HEADER}="true" class="${KIT_SHELL_HEADER_CLASS}">`, `<header data-soma-id="${KIT_REGION_ANCHORS.top}" ${KIT_ATTR_LAYOUT_HEADER}="true" class="${kitNeutralClass(KIT_SHELL_HEADER_CLASS)}">`);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// ---------------------------------------------------------------- 产品旋钮
|
|
187
|
+
|
|
188
|
+
export interface KitProductKnobs {
|
|
189
|
+
emphasis?: string;
|
|
190
|
+
surface?: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function applyProductKnobsToFragment(frag: KitFragment, product: KitProductKnobs, options?: { pipeline?: 'legacy' | 'next' }): KitFragment {
|
|
194
|
+
// 新模式:强调级是识别的结论(判定类属性),产品旋钮的强调级不写属性也不写强调类,只留表面旋钮
|
|
195
|
+
if (options?.pipeline === 'next' && product.emphasis !== undefined) {
|
|
196
|
+
const { emphasis: _emphasis, ...rest } = product;
|
|
197
|
+
return applyProductKnobsToFragment(frag, rest);
|
|
198
|
+
}
|
|
199
|
+
if (product.emphasis === undefined && product.surface === undefined) return frag;
|
|
200
|
+
const attrs: string[] = [];
|
|
201
|
+
const classes: string[] = [];
|
|
202
|
+
if (product.surface !== undefined && KIT_PRODUCT_SURFACE_CLASSES[product.surface] !== undefined) {
|
|
203
|
+
attrs.push(`${KIT_ATTR_SURFACE}="${product.surface}"`);
|
|
204
|
+
classes.push(KIT_PRODUCT_SURFACE_CLASSES[product.surface]!);
|
|
205
|
+
}
|
|
206
|
+
if (product.emphasis !== undefined && KIT_PRODUCT_EMPHASIS_CLASSES[product.emphasis] !== undefined) {
|
|
207
|
+
attrs.push(`${KIT_ATTR_EMPHASIS}="${product.emphasis}"`);
|
|
208
|
+
classes.push(KIT_PRODUCT_EMPHASIS_CLASSES[product.emphasis]!);
|
|
209
|
+
}
|
|
210
|
+
if (attrs.length === 0) return frag;
|
|
211
|
+
const clsStr = classes.join(' ');
|
|
212
|
+
const tokens = clsStr.split(/\s+/).filter(Boolean);
|
|
213
|
+
const candidates = [...new Set([...frag.candidates, ...tokens])].sort();
|
|
214
|
+
return {
|
|
215
|
+
...frag,
|
|
216
|
+
html: `<div ${attrs.join(' ')} class="${clsStr}">${frag.html}</div>`,
|
|
217
|
+
candidates,
|
|
218
|
+
};
|
|
219
|
+
}
|