soma-kit 0.1.15 → 0.1.17
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/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 -340
- package/spec/generated/kit-page.schema.json +1134 -139
- package/spec/kit-grammar.json +935 -93
- package/spec/kit-grammar.schema.json +167 -2
- package/src/app/app-config.ts +219 -186
- package/src/app/define-kit-actions.ts +126 -20
- package/src/app/define-kit-app.ts +49 -4
- package/src/app/index.ts +5 -0
- package/src/app/kit-view-context.ts +39 -1
- 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 +67 -23
- package/src/app/theme-runtime.ts +414 -85
- 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 +104 -59
- package/src/base/anchored-layer.ts +7 -6
- 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 +347 -50
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +143 -32
- package/src/base/check-core.ts +193 -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 +399 -27
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +148 -36
- package/src/base/context-menu.ts +23 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +114 -96
- package/src/base/date.ts +481 -74
- package/src/base/delta.ts +16 -9
- package/src/base/divider.ts +51 -33
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +57 -21
- package/src/base/gap-value.ts +34 -15
- package/src/base/hint-tips.ts +99 -29
- 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 +79 -22
- package/src/base/inline-error.ts +13 -7
- package/src/base/input.ts +135 -35
- package/src/base/kbd.ts +30 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +282 -101
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +55 -22
- package/src/base/menu-button.ts +73 -22
- package/src/base/menu-core.ts +201 -24
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +7 -5
- package/src/base/motion/hover-gallery.ts +16 -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 +139 -27
- package/src/base/overlay-runtime.ts +30 -23
- package/src/base/overlay-shell.ts +59 -14
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +624 -73
- package/src/base/popup.ts +187 -52
- 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 +141 -22
- 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 +58 -16
- package/src/base/relation-cells.ts +541 -0
- package/src/base/resize-handle.ts +5 -3
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +70 -26
- package/src/base/select.ts +8 -3
- package/src/base/shared.ts +482 -71
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- 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 +123 -54
- package/src/base/tag.ts +184 -66
- package/src/base/text.ts +461 -71
- package/src/base/textarea.ts +88 -39
- package/src/base/time-picker.ts +335 -55
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +342 -88
- package/src/base/upload.ts +604 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +70 -5
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +52 -12
- package/src/biz/auth-panel/compile.ts +13 -3
- package/src/biz/auth-panel/shell.ts +27 -7
- package/src/biz/category-crud/compile.ts +51 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +29 -9
- package/src/biz/checkout-page/compile.ts +37 -3
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +26 -9
- package/src/biz/compose.ts +6 -1
- package/src/biz/data-components.ts +2 -0
- package/src/biz/import-wizard/compile.ts +4 -1
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +32 -18
- package/src/biz/index.ts +1 -1
- package/src/biz/landing-page/compile.ts +3 -2
- package/src/biz/landing-page/shell.ts +22 -3
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +54 -15
- package/src/biz/master-sub/compile.ts +194 -57
- package/src/biz/master-sub/detail-head.ts +141 -18
- package/src/biz/master-sub/index.ts +3 -0
- package/src/biz/master-sub/shell.ts +188 -62
- package/src/biz/multi-board/compile.ts +87 -36
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +3 -2
- package/src/biz/multi-board/prose-fold.ts +15 -11
- package/src/biz/multi-board/shell.ts +148 -37
- package/src/biz/notification-center/compile.ts +20 -6
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +43 -10
- package/src/biz/page-templates/domain-templates.ts +145 -22
- package/src/biz/page-templates/result-page/compile.ts +4 -1
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +17 -4
- package/src/biz/page-templates/sign-in-page/compile.ts +19 -8
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +28 -12
- package/src/biz/record-detail/compile.ts +39 -11
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +41 -10
- package/src/biz/settings-center/compile.ts +4 -1
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +30 -9
- package/src/biz/shared/action-host.ts +137 -46
- package/src/biz/shared/compile-helpers.ts +152 -28
- package/src/biz/shared/coordinator.ts +628 -147
- 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 +58 -10
- package/src/biz/shared/overlay-shell.ts +40 -10
- 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 +4 -2
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +21 -11
- package/src/biz/standard-crud/compile.ts +206 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +82 -22
- package/src/biz/standard-crud/summary.ts +2 -37
- package/src/biz/step-form/compile.ts +12 -3
- package/src/biz/step-form/hub.ts +165 -50
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +31 -15
- package/src/biz/types.ts +40 -4
- package/src/cli/kit-cli.ts +145 -26
- package/src/cli/kit-init.ts +3 -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/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +446 -53
- package/src/compile/component-candidates.ts +56 -4
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +1 -1
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/rules-composition.ts +2 -1
- 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 +382 -46
- 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/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +645 -28
- package/src/compile/styles.ts +226 -26
- package/src/compile/types.ts +62 -5
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +49 -22
- package/src/data/anchor-nav.ts +73 -15
- package/src/data/approval-flow.ts +210 -124
- package/src/data/assignment-picker.ts +163 -85
- package/src/data/async-result-panel.ts +110 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +141 -19
- package/src/data/calendar.ts +434 -96
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +72 -38
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +904 -77
- package/src/data/checklist.ts +78 -35
- package/src/data/code-view.ts +106 -48
- package/src/data/comment-thread.ts +607 -87
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +198 -30
- 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 +107 -50
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +33 -17
- package/src/data/embed.ts +142 -7
- package/src/data/engine-ports.ts +13 -4
- package/src/data/field-mapper.ts +104 -48
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +603 -142
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +85 -27
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +637 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +38 -15
- package/src/data/image-viewer.ts +261 -62
- package/src/data/index.ts +63 -1
- package/src/data/item-list.ts +217 -57
- package/src/data/json-view.ts +165 -100
- package/src/data/kanban.ts +339 -87
- 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 +155 -45
- package/src/data/matrix.ts +217 -112
- package/src/data/media-grid.ts +162 -38
- package/src/data/mega-menu.ts +39 -23
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +50 -15
- package/src/data/menu.ts +131 -47
- package/src/data/mockup.ts +30 -22
- package/src/data/modal-dialog.ts +90 -13
- package/src/data/navbar.ts +143 -61
- package/src/data/notice-list.ts +100 -48
- package/src/data/notify-renderer.ts +61 -7
- package/src/data/object-form.ts +1389 -130
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +122 -42
- package/src/data/panel-head.ts +237 -75
- package/src/data/permission-matrix.ts +371 -119
- package/src/data/permission-tree.ts +135 -80
- package/src/data/pricing-table.ts +106 -42
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +63 -31
- package/src/data/record-card.ts +239 -70
- package/src/data/record-picker.ts +56 -27
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +131 -41
- package/src/data/resident.ts +11 -1
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +206 -35
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +376 -102
- package/src/data/rule-builder.ts +129 -80
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +86 -43
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +438 -86
- package/src/data/static-lazy.ts +18 -0
- package/src/data/static-registry.ts +38 -2
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +63 -34
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +128 -47
- package/src/data/system-switcher.ts +40 -20
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +99 -31
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +110 -47
- package/src/data/transfer.ts +195 -47
- package/src/data/tree-table.ts +194 -112
- package/src/data/tree.ts +191 -70
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +242 -102
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +26 -4
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +1 -2
- package/src/frames/inherited-shell.ts +54 -13
- package/src/frames/page-bar.ts +205 -27
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +0 -2
- package/src/frames/shared.ts +64 -21
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +11 -7
- package/src/frames/split-frame/wiring.ts +14 -10
- package/src/frames/tabs-frame/shell.ts +3 -2
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +2 -0
- package/src/frames/workspace-frame/extras.ts +5 -3
- 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 +22 -2
- package/src/frames/workspace-frame/state.ts +42 -14
- package/src/frames/workspace-frame/view.ts +697 -167
- package/src/generated/kit-grammar-runtime.ts +1016 -54
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +96 -3
- package/src/object-renderer/action-group.ts +175 -23
- package/src/object-renderer/action-more.ts +48 -17
- package/src/object-renderer/arrange.ts +241 -29
- 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 +432 -107
- package/src/object-renderer/collection-table.ts +347 -45
- package/src/object-renderer/collection.ts +291 -62
- package/src/object-renderer/compile-data.ts +12 -2
- package/src/object-renderer/defaults.ts +6 -5
- package/src/object-renderer/emit-events.ts +45 -19
- package/src/object-renderer/emit-object.ts +35 -9
- package/src/object-renderer/emit-static.ts +734 -159
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +105 -18
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +18 -2
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +44 -2
- 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 +71 -26
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +423 -104
- 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 +428 -128
- package/src/object-renderer/types.ts +91 -2
- 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/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +15 -14
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +3 -2
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +76 -19
- package/src/recipes/control.ts +64 -5
- package/src/recipes/desc-list.ts +101 -7
- package/src/recipes/divider.ts +30 -9
- package/src/recipes/emphasis.ts +90 -5
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +3 -2
- package/src/recipes/index.ts +28 -4
- package/src/recipes/inherited-shell.ts +21 -15
- package/src/recipes/json-view.ts +6 -5
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +16 -6
- package/src/recipes/overlay.ts +47 -19
- package/src/recipes/page-width.ts +31 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +37 -19
- 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 +5 -5
- package/src/recipes/state.ts +54 -3
- package/src/recipes/status.ts +14 -14
- package/src/recipes/strip.ts +47 -5
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +33 -4
- package/src/recipes/table-gap.ts +3 -2
- package/src/recipes/table-native-edit.ts +22 -9
- package/src/recipes/table-row.ts +45 -12
- package/src/recipes/tabs.ts +54 -22
- package/src/recipes/text-diff.ts +15 -8
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +68 -3
- 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/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +58 -12
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/icons.ts +28 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- 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/pipeline-mode.ts +64 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +165 -24
- 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 +527 -16
- package/src/theme/kit-theme.tpl +491 -16
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +522 -185
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +3 -2
- package/src/theme/theme-tokens.ts +1601 -93
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/frames/list-summary.ts +0 -123
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
|
@@ -5,8 +5,13 @@
|
|
|
5
5
|
// KIT-VIEW-004 view.form.onDraft 的方法没在展示对象 methods 里
|
|
6
6
|
// KIT-VIEW-007 绑定的成员性质不对:hidden / disabled / required / 动作 disabled 要标量,绑到数组 / 对象成员报;options 要数组、nodeOptions 要对象,绑到别的形状也报(形状来自 state 初值的扫描)
|
|
7
7
|
// 没写 page.view 的页面(含 AI 生成页)使用默认空展示对象,不允许带任何绑定。纯函数。
|
|
8
|
+
// 另有组件入参的声明名出口(SCON-175,resolveSourceObjectRefs):写死形状组件 props.source_object 写的对象名按对象名契约在编译期解析成运行期名,
|
|
9
|
+
// 写错报 KIT-VIEW-003(与 `soma kit check` 核展示对象 ctx.form / data … 的对象名同一个码、同一份契约 biz/shared/object-aliases.ts)。
|
|
8
10
|
|
|
9
11
|
import { checkBindingKind, type ViewBindingSite, type ViewShapeKind, type ViewStateShape } from 'soma-foundation/view-state';
|
|
12
|
+
import grammarJson from '../../spec/kit-grammar.json';
|
|
13
|
+
import { buildKitObjectNameMap, declaredObjectsOfPlan, isKitObjectDeclLike, qualifiedNamesOf, type KitObjectNameMap, type KitObjectPlan } from '../biz/shared/object-aliases';
|
|
14
|
+
import { KIT_VIEW_SLOTS } from '../object-renderer/defaults';
|
|
10
15
|
import { readKitViewInfo } from '../shared/view-info';
|
|
11
16
|
import { normalizeRef } from '../object-renderer/arrange';
|
|
12
17
|
import { classifyBindingValue, classifyEventBinding, classifyParamBinding, collectFieldState, isViewMethodName, isViewPath, viewPathMember, KIT_FIELD_STATE_KEYS } from '../object-renderer/view-binding';
|
|
@@ -76,7 +81,8 @@ interface Usage {
|
|
|
76
81
|
syntaxDiags: KitDiagnostic[];
|
|
77
82
|
}
|
|
78
83
|
|
|
79
|
-
|
|
84
|
+
/** 视图槽闭集(语法真源 viewSlots,object-renderer/defaults#KIT_VIEW_SLOTS),本文件不另抄 */
|
|
85
|
+
const VIEW_SLOTS = KIT_VIEW_SLOTS;
|
|
80
86
|
|
|
81
87
|
/** 一个视图槽位里全部字段项(fields / groups[].fields,已规范化) */
|
|
82
88
|
function fieldRefsOfSlot(slotView: Rec, at: string): Array<{ ref: Rec; at: string }> {
|
|
@@ -282,3 +288,186 @@ export function checkPageView(decl: KitPageDecl, app: KitAppContext): KitDiagnos
|
|
|
282
288
|
}
|
|
283
289
|
return diags;
|
|
284
290
|
}
|
|
291
|
+
|
|
292
|
+
// ---------------------------------------------------------------- 组件入参的声明名出口(SCON-175)
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* 组件入参里引用页面数据对象的键(kit 约定,语法真源 viewObject.objectNames.sourceObjectProp,即 source_object):写死形状组件(含应用组件 App*)的
|
|
296
|
+
* props.<这个键> 写一个或多个页面数据对象名(逗号分隔的字符串,或字符串数组),组件据它经 core 数据端口取对象、判已解析 / 重取。
|
|
297
|
+
*/
|
|
298
|
+
export const KIT_SOURCE_OBJECT_PROP: string = (grammarJson as unknown as { viewObject: { objectNames: { sourceObjectProp: string } } }).viewObject.objectNames.sourceObjectProp;
|
|
299
|
+
|
|
300
|
+
/** 一个槽 / 页签的产品计划:对象名契约的输入,另带产品在页面声明里的路径(诊断用) */
|
|
301
|
+
export interface KitObjectRefPlan extends KitObjectPlan {
|
|
302
|
+
readonly path: string;
|
|
303
|
+
readonly objects: Record<string, unknown>;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface KitObjectRefResolution {
|
|
307
|
+
/** 与输入计划一一对应:改写过的对象表;没有要改的为 undefined(原声明原样保留,产物逐字节不变) */
|
|
308
|
+
readonly objects: ReadonlyArray<Record<string, unknown> | undefined>;
|
|
309
|
+
/** 写错的对象名(KIT-VIEW-003):不是本页的对象,或声明名在本页有多个同名对象 */
|
|
310
|
+
readonly diagnostics: readonly KitDiagnostic[];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** 不是对象名的值:view.<成员> 绑定、page. / row. 前缀与 $ 路径(绑定成员由上面核 KIT-VIEW-003 / 011,原始运行期路径由渲染层核 KIT-VIEW-010) */
|
|
314
|
+
const NOT_OBJECT_NAME_RE = /^(?:view|page|row)\.|\$/;
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
interface ObjectRefCtx {
|
|
318
|
+
readonly map: KitObjectNameMap;
|
|
319
|
+
/** 本页全部对象的运行期名(运行期名原样放行) */
|
|
320
|
+
readonly runtime: ReadonlySet<string>;
|
|
321
|
+
/** 诊断里列给作者的可写名字:整页唯一的声明名;同名的写成「名(同名,须写 限定名…)」 */
|
|
322
|
+
readonly offer: string;
|
|
323
|
+
readonly diags: KitDiagnostic[];
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** 一个对象名 → 运行期名:声明名 / 限定名按契约解析,运行期名原样;写错(不是本页对象、同名歧义)记一条 KIT-VIEW-003 并返回 null */
|
|
327
|
+
function resolveObjectRefName(name: string, at: string, ctx: ObjectRefCtx): string | null {
|
|
328
|
+
const hit = ctx.map[name];
|
|
329
|
+
if (typeof hit === 'string') return hit;
|
|
330
|
+
if (Array.isArray(hit)) {
|
|
331
|
+
ctx.diags.push({
|
|
332
|
+
code: 'KIT-VIEW-003', path: at,
|
|
333
|
+
message: `组件入参 ${KIT_SOURCE_OBJECT_PROP} 的对象名「${name}」在本页有多个同名对象,歧义`,
|
|
334
|
+
hint: `改写成限定名 <页签 id 或槽名>.${name}:${qualifiedNamesOf(ctx.map, hit as readonly string[]).join(' / ')}`,
|
|
335
|
+
});
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
if (ctx.runtime.has(name)) return name;
|
|
339
|
+
ctx.diags.push({
|
|
340
|
+
code: 'KIT-VIEW-003', path: at,
|
|
341
|
+
message: `组件入参 ${KIT_SOURCE_OBJECT_PROP} 的对象名「${name}」不是本页的数据对象(可写:${ctx.offer})`,
|
|
342
|
+
hint: '写本页声明过的对象名(面板名 / 对象名;同名对象写 <页签 id 或槽名>.<声明名>),编译期解析成运行期名;运行期名照旧可用',
|
|
343
|
+
});
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** source_object 的值 → 解析后的值;不用改(全是运行期名、不是对象名写法、有写错)为 undefined。字符串按逗号分开逐个解析,数组逐项 */
|
|
348
|
+
function resolveSourceObjectValue(raw: unknown, at: string, ctx: ObjectRefCtx): unknown {
|
|
349
|
+
if (typeof raw === 'string') {
|
|
350
|
+
const out: string[] = [];
|
|
351
|
+
let changed = false;
|
|
352
|
+
let ok = true;
|
|
353
|
+
// 逐个名字判「是不是对象名写法」(与数组分支同口径):`head, $row.x` 照样改写 head、原样留下 $row.x;`head, view.extra` 不把 view.extra 当对象名报错
|
|
354
|
+
for (const name of raw.split(',').map((s) => s.trim()).filter((s) => s !== '')) {
|
|
355
|
+
if (NOT_OBJECT_NAME_RE.test(name)) {
|
|
356
|
+
out.push(name);
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
const r = resolveObjectRefName(name, at, ctx);
|
|
360
|
+
if (r === null) ok = false;
|
|
361
|
+
else if (r !== name) changed = true;
|
|
362
|
+
out.push(r ?? name);
|
|
363
|
+
}
|
|
364
|
+
return ok && changed ? out.join(',') : undefined;
|
|
365
|
+
}
|
|
366
|
+
if (Array.isArray(raw)) {
|
|
367
|
+
const items: readonly unknown[] = raw;
|
|
368
|
+
const out: unknown[] = [];
|
|
369
|
+
let changed = false;
|
|
370
|
+
let ok = true;
|
|
371
|
+
for (const [i, item] of items.entries()) {
|
|
372
|
+
const name = typeof item === 'string' ? item.trim() : '';
|
|
373
|
+
if (name === '' || NOT_OBJECT_NAME_RE.test(name)) {
|
|
374
|
+
out.push(item);
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
const r = resolveObjectRefName(name, `${at}[${i}]`, ctx);
|
|
378
|
+
if (r === null) ok = false;
|
|
379
|
+
else if (r !== item) changed = true;
|
|
380
|
+
out.push(r ?? item);
|
|
381
|
+
}
|
|
382
|
+
return ok && changed ? out : undefined;
|
|
383
|
+
}
|
|
384
|
+
return undefined;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const hasStaticComponent = (v: Rec): boolean => typeof v.staticComponent === 'string' && v.staticComponent !== '';
|
|
388
|
+
/** 视图槽里的写死形状组件:staticComponent,没写取 component(与 compile/stages.ts#staticComponentNamesOf、spatial/expand.ts 取槽组件同口径) */
|
|
389
|
+
const hasSlotComponent = (v: Rec): boolean => hasStaticComponent(v) || (typeof v.component === 'string' && v.component !== '');
|
|
390
|
+
|
|
391
|
+
/** 一个写死形状组件的位置(整视图或某个视图槽):改写 props.source_object;没有要改的为 undefined */
|
|
392
|
+
function patchSourceObjectProp(holder: Rec, at: string, ctx: ObjectRefCtx): Rec | undefined {
|
|
393
|
+
const props = holder.props;
|
|
394
|
+
if (!isRec(props) || !Object.hasOwn(props, KIT_SOURCE_OBJECT_PROP)) return undefined;
|
|
395
|
+
const next = resolveSourceObjectValue(props[KIT_SOURCE_OBJECT_PROP], `${at}.props.${KIT_SOURCE_OBJECT_PROP}`, ctx);
|
|
396
|
+
return next === undefined ? undefined : { ...holder, props: { ...props, [KIT_SOURCE_OBJECT_PROP]: next } };
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** 对象视图:view 下直接写的整视图件,或各视图槽里写的写死形状组件(与展开、版心事实取组件同口径) */
|
|
400
|
+
function patchSourceObjectView(view: Rec, at: string, ctx: ObjectRefCtx): Rec | undefined {
|
|
401
|
+
if (hasStaticComponent(view)) return patchSourceObjectProp(view, at, ctx);
|
|
402
|
+
let out: Rec | undefined;
|
|
403
|
+
for (const slot of VIEW_SLOTS) {
|
|
404
|
+
const sv = view[slot];
|
|
405
|
+
if (!isRec(sv) || !hasSlotComponent(sv)) continue;
|
|
406
|
+
const next = patchSourceObjectProp(sv, `${at}.${slot}`, ctx);
|
|
407
|
+
if (next !== undefined) out = { ...(out ?? view), [slot]: next };
|
|
408
|
+
}
|
|
409
|
+
return out;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* 一个对象声明(连同它的从属对象 subs):有改写返回新对象,否则 undefined。
|
|
414
|
+
* 从属对象 subs 里的组件同样可以引用本页对象(引用方);从属对象自己不进对象名契约(不是 source_object 的可写目标,declaredObjectsOfPlan 只登记产品对象表一层)
|
|
415
|
+
*/
|
|
416
|
+
function patchSourceObjectDecl(decl: Rec, at: string, ctx: ObjectRefCtx): Rec | undefined {
|
|
417
|
+
let out: Rec | undefined;
|
|
418
|
+
if (isRec(decl.view)) {
|
|
419
|
+
const view = patchSourceObjectView(decl.view, `${at}.view`, ctx);
|
|
420
|
+
if (view !== undefined) out = { ...decl, view };
|
|
421
|
+
}
|
|
422
|
+
if (isRec(decl.subs)) {
|
|
423
|
+
const subsDecl = decl.subs;
|
|
424
|
+
let subs: Rec | undefined;
|
|
425
|
+
for (const [name, sub] of Object.entries(subsDecl)) {
|
|
426
|
+
if (!isRec(sub)) continue;
|
|
427
|
+
const next = patchSourceObjectDecl(sub, `${at}.subs.${name}`, ctx);
|
|
428
|
+
if (next !== undefined) subs = { ...(subs ?? subsDecl), [name]: next };
|
|
429
|
+
}
|
|
430
|
+
if (subs !== undefined) out = { ...(out ?? decl), subs };
|
|
431
|
+
}
|
|
432
|
+
return out;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/** 产品的对象表:单个对象、分组表(panels / steps / subs / sections …)与浮层表的成员(与对象名契约认对象同一个走法) */
|
|
436
|
+
function patchSourceObjectObjects(objects: Record<string, unknown>, at: string, ctx: ObjectRefCtx): Record<string, unknown> | undefined {
|
|
437
|
+
let out: Record<string, unknown> | undefined;
|
|
438
|
+
for (const [key, val] of Object.entries(objects)) {
|
|
439
|
+
if (!isRec(val)) continue;
|
|
440
|
+
let next: Rec | undefined;
|
|
441
|
+
if (key !== 'overlays' && isKitObjectDeclLike(val)) {
|
|
442
|
+
next = patchSourceObjectDecl(val, `${at}.${key}`, ctx);
|
|
443
|
+
} else if (key === 'overlays' || (Object.keys(val).length > 0 && Object.values(val).every(isRec))) {
|
|
444
|
+
let group: Rec | undefined;
|
|
445
|
+
for (const [name, member] of Object.entries(val)) {
|
|
446
|
+
if (!isRec(member)) continue;
|
|
447
|
+
const m = patchSourceObjectDecl(member, `${at}.${key}.${name}`, ctx);
|
|
448
|
+
if (m !== undefined) group = { ...(group ?? val), [name]: m };
|
|
449
|
+
}
|
|
450
|
+
next = group;
|
|
451
|
+
}
|
|
452
|
+
if (next !== undefined) out = { ...(out ?? objects), [key]: next };
|
|
453
|
+
}
|
|
454
|
+
return out;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* 组件入参 source_object 的声明名出口(SCON-175):按对象名契约(biz/shared/object-aliases.ts,展示对象 ctx.form / data … 与 `soma kit check` 同一份)
|
|
459
|
+
* 把写死形状组件 props.source_object 里的声明名 / 限定名解析成运行期名——组件拿到的仍是 core 数据端口认的运行期名,组件代码不用改;
|
|
460
|
+
* 运行期名原样保留(向后兼容),全是运行期名的值不改写(产物逐字节不变);写错的(不是本页对象、同名歧义)报 KIT-VIEW-003 并给出可写的名字。
|
|
461
|
+
* 值是 view.<成员> 绑定或 page. / row. / $ 路径的不碰(绑定与原始运行期路径另有核对)。纯函数:不改入参,有改写的计划返回新的对象表
|
|
462
|
+
*/
|
|
463
|
+
export function resolveSourceObjectRefs(plans: readonly KitObjectRefPlan[]): KitObjectRefResolution {
|
|
464
|
+
const declared = plans.flatMap((p) => declaredObjectsOfPlan(p));
|
|
465
|
+
const countOf = new Map<string, number>();
|
|
466
|
+
for (const o of declared) countOf.set(o.declared, (countOf.get(o.declared) ?? 0) + 1);
|
|
467
|
+
const offer = [...new Set(declared.map((o) => o.declared))]
|
|
468
|
+
.map((n) => ((countOf.get(n) ?? 0) > 1 ? `${n}(同名,须写 ${declared.filter((o) => o.declared === n).map((o) => `${o.pageId}.${n}`).join(' / ')})` : n))
|
|
469
|
+
.join(' / ') || '无';
|
|
470
|
+
const ctx: ObjectRefCtx = { map: buildKitObjectNameMap(plans), runtime: new Set(declared.map((o) => o.runtime)), offer, diags: [] };
|
|
471
|
+
const objects = plans.map((p) => (isRec(p.objects) ? patchSourceObjectObjects(p.objects, `${p.path}.objects`, ctx) : undefined));
|
|
472
|
+
return { objects, diagnostics: ctx.diags };
|
|
473
|
+
}
|
package/src/data/access-gate.ts
CHANGED
|
@@ -11,9 +11,10 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
11
11
|
import { arrangeReadFailure } from 'soma-foundation/arrange/table';
|
|
12
12
|
import { KIT_ACCESS_STATE_LIMITS } from 'soma-foundation/kit-limits';
|
|
13
13
|
import { splitHttpErrorPrefix, kitStatePanel } from '../base/state-panel';
|
|
14
|
-
import { CLASS_PROP, createKitController } from '../base/shared';
|
|
14
|
+
import { CLASS_PROP, createKitController, joinClass, toggleKitHidden } from '../base/shared';
|
|
15
15
|
import { kitText } from '../i18n/kit-text';
|
|
16
16
|
import { KIT_STATE_DENIED_PAGE, KIT_STATE_DENIED_TITLE, KIT_STATE_DENIED_WRAP } from '../recipes/placeholder';
|
|
17
|
+
import { KIT_ATTR_ACCESS_DENIED } from '../shared/dom-attrs';
|
|
17
18
|
|
|
18
19
|
/** 状态码集合真源(kit-limits#accessState):这里再导出,供编译期 / 测试对账;判据本身在 foundation arrangeReadFailure */
|
|
19
20
|
export { KIT_ACCESS_STATE_LIMITS };
|
|
@@ -22,7 +23,7 @@ interface ReadMeta { readState?: unknown; errorStatus?: unknown; errorMessage?:
|
|
|
22
23
|
interface DataPortLike { getObject?: (name: string) => unknown }
|
|
23
24
|
|
|
24
25
|
const FRAME_SELECTOR = ':scope > [data-soma-id$="frame__root"]';
|
|
25
|
-
const SHOWN_ATTR =
|
|
26
|
+
const SHOWN_ATTR = KIT_ATTR_ACCESS_DENIED;
|
|
26
27
|
|
|
27
28
|
/** 数据对象上 core 挂的读状态(没有 = 还没落定) */
|
|
28
29
|
function metaOf(port: DataPortLike | undefined, name: string): ReadMeta | null {
|
|
@@ -63,9 +64,9 @@ export function createKitAccessGate(): SomaComponentDefinition {
|
|
|
63
64
|
const port = (): DataPortLike | undefined => (api.services as { data?: DataPortLike } | undefined)?.data;
|
|
64
65
|
|
|
65
66
|
const restore = (root: HTMLElement): void => {
|
|
66
|
-
if (hiddenFrame !== null) { hiddenFrame
|
|
67
|
-
root.
|
|
68
|
-
root
|
|
67
|
+
if (hiddenFrame !== null) { toggleKitHidden(hiddenFrame, false); hiddenFrame = null; }
|
|
68
|
+
root.className = joinClass('', api.props().class);
|
|
69
|
+
toggleKitHidden(root, true);
|
|
69
70
|
root.removeAttribute(SHOWN_ATTR);
|
|
70
71
|
root.textContent = '';
|
|
71
72
|
};
|
|
@@ -84,17 +85,24 @@ export function createKitAccessGate(): SomaComponentDefinition {
|
|
|
84
85
|
// 标题 + 说明两级字号(标题走区块标题字阶,说明沿用次要色小字),标题不带句号
|
|
85
86
|
const head = panel.firstElementChild;
|
|
86
87
|
if (head instanceof HTMLElement) { head.className = KIT_STATE_DENIED_TITLE; head.textContent = (head.textContent ?? '').replace(/[。.\s]+$/, ''); }
|
|
87
|
-
root.className = KIT_STATE_DENIED_WRAP;
|
|
88
|
+
root.className = joinClass(KIT_STATE_DENIED_WRAP, api.props().class);
|
|
88
89
|
root.replaceChildren(panel);
|
|
89
90
|
root.setAttribute(SHOWN_ATTR, '');
|
|
90
|
-
root
|
|
91
|
+
toggleKitHidden(root, false);
|
|
91
92
|
const frame = api.host.parentElement?.querySelector<HTMLElement>(FRAME_SELECTOR) ?? null;
|
|
92
|
-
if (frame !== null) { frame
|
|
93
|
+
if (frame !== null) { toggleKitHidden(frame, true); hiddenFrame = frame; }
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
96
|
if (verdict.message === null) {
|
|
96
97
|
if (!verdict.unsettled) armed = false;
|
|
97
98
|
if (root.hasAttribute(SHOWN_ATTR)) restore(root);
|
|
99
|
+
else {
|
|
100
|
+
root.className = joinClass('', api.props().class);
|
|
101
|
+
toggleKitHidden(root, true);
|
|
102
|
+
}
|
|
103
|
+
} else if (!root.hasAttribute(SHOWN_ATTR)) {
|
|
104
|
+
root.className = joinClass('', api.props().class);
|
|
105
|
+
toggleKitHidden(root, true);
|
|
98
106
|
}
|
|
99
107
|
};
|
|
100
108
|
|
|
@@ -102,7 +110,7 @@ export function createKitAccessGate(): SomaComponentDefinition {
|
|
|
102
110
|
attach(root) {
|
|
103
111
|
rootEl = root;
|
|
104
112
|
evaluate(root);
|
|
105
|
-
return () => { if (hiddenFrame !== null) hiddenFrame
|
|
113
|
+
return () => { if (hiddenFrame !== null) { toggleKitHidden(hiddenFrame, false); hiddenFrame = null; } rootEl = null; };
|
|
106
114
|
},
|
|
107
115
|
render(root) { evaluate(root); },
|
|
108
116
|
onDataObjectsChange() { if (rootEl !== null) evaluate(rootEl); },
|
|
@@ -5,42 +5,49 @@
|
|
|
5
5
|
// (soma-foundation/values 写法,如 currency:CNY)才格式化。末行 / 任一行 `total` 为真走合计样式(上分隔线、加粗)。
|
|
6
6
|
// `level`(0–3)决定缩进。`row_action` 配 { key, label } 时每行末尾出一个小按钮,点击抛 `action { key, id }`(如「异议」)。
|
|
7
7
|
|
|
8
|
+
import { kitApplyLevelClass } from './level-class';
|
|
8
9
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
10
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart } from './kit-contract';
|
|
9
11
|
import { kitText } from '../i18n/kit-text';
|
|
10
12
|
import { createKitController, formatValue, joinClass, num, str } from '../base/shared';
|
|
11
13
|
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
|
|
12
14
|
import { kitTypographyRecipe } from '../recipes/typography';
|
|
13
15
|
import { mergeClass } from '../shared/merge-class';
|
|
14
|
-
import { KIT_DIVIDER_FOOT_CLASS } from '../recipes/divider';
|
|
16
|
+
import { KIT_DIVIDER_FOOT_CLASS, kitDividerRecipe } from '../recipes/divider';
|
|
17
|
+
import { KIT_ATTR_ACTION, KIT_ATTR_ROW, kitAttrSel } from '../shared/dom-attrs';
|
|
15
18
|
import {
|
|
16
|
-
actionButton, BUTTON_CLASS_TOKENS, classTokens, emptyNode, keyMap, mk, recOf, rowsOf, shapeToneOf, textOf,
|
|
19
|
+
actionButton, BUTTON_CLASS_TOKENS, classTokens, emptyNode, keyMap, mk, recOf, rowsOf, shapeToneOf, textOf, TONE_TEXT,
|
|
17
20
|
type ShapeTone,
|
|
18
21
|
} from './shape-util';
|
|
19
22
|
|
|
20
23
|
export const KIT_AMOUNT_DEFAULT_MAP = Object.freeze({ id: 'id', label: 'label', amount: 'amount', level: 'level', tone: 'tone', note: 'note', total: 'total' });
|
|
21
24
|
|
|
22
25
|
const ROOT_CLASS = 'flex flex-col gap-1 text-sm text-fg';
|
|
26
|
+
const DL_CLASS = 'm-0 flex flex-col gap-1 p-0';
|
|
23
27
|
const TITLE_CLASS = mergeClass('pb-1', kitTypographyRecipe('sectionTitle'));
|
|
24
28
|
const ROW_CLASS = 'flex items-start justify-between gap-4 py-1';
|
|
25
29
|
// 合计行上方的线 = 分隔线出口(KT-B5)
|
|
26
30
|
const ROW_TOTAL = `flex items-start justify-between gap-4 ${KIT_DIVIDER_FOOT_CLASS} pt-2 text-base font-semibold`;
|
|
31
|
+
const DT_CLASS = 'min-w-0 flex-1';
|
|
27
32
|
const LEFT_CLASS = 'flex flex-col gap-0.5';
|
|
33
|
+
const CHILD_GUIDE_CLASS = mergeClass(LEFT_CLASS, mergeClass('ps-3', kitDividerRecipe('start')));
|
|
28
34
|
const INDENT: readonly string[] = Object.freeze(['ps-0', 'ps-4', 'ps-8', 'ps-12']);
|
|
29
35
|
const LABEL_CLASS = 'text-fg';
|
|
30
36
|
const NOTE_CLASS = 'text-xs text-fg-subtle';
|
|
31
|
-
const
|
|
37
|
+
const DD_CLASS = 'm-0 flex shrink-0 items-center gap-3 whitespace-nowrap tabular-nums';
|
|
32
38
|
const AMOUNT_CLASS = 'text-end tabular-nums text-fg';
|
|
39
|
+
// 自由数值不许有底(《Kit 主题公式》§7):纯文字色 TONE_TEXT,严禁 TONE_SOFT 带底色
|
|
33
40
|
const AMOUNT_TONE: Readonly<Record<ShapeTone, string>> = Object.freeze({
|
|
34
41
|
neutral: AMOUNT_CLASS,
|
|
35
|
-
primary: `text-end tabular-nums ${
|
|
36
|
-
info: `text-end tabular-nums ${
|
|
37
|
-
success: `text-end tabular-nums ${
|
|
38
|
-
warning: `text-end tabular-nums ${
|
|
39
|
-
danger: `text-end tabular-nums ${
|
|
42
|
+
primary: `text-end tabular-nums ${TONE_TEXT.primary}`,
|
|
43
|
+
info: `text-end tabular-nums ${TONE_TEXT.info}`,
|
|
44
|
+
success: `text-end tabular-nums ${TONE_TEXT.success}`,
|
|
45
|
+
warning: `text-end tabular-nums ${TONE_TEXT.warning}`,
|
|
46
|
+
danger: `text-end tabular-nums ${TONE_TEXT.danger}`,
|
|
40
47
|
});
|
|
41
48
|
|
|
42
49
|
export const KIT_AMOUNT_BREAKDOWN_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
43
|
-
ROOT_CLASS, TITLE_CLASS, ROW_CLASS, ROW_TOTAL, LEFT_CLASS, INDENT, LABEL_CLASS, NOTE_CLASS,
|
|
50
|
+
ROOT_CLASS, DL_CLASS, TITLE_CLASS, ROW_CLASS, ROW_TOTAL, DT_CLASS, LEFT_CLASS, CHILD_GUIDE_CLASS, INDENT, LABEL_CLASS, NOTE_CLASS, DD_CLASS,
|
|
44
51
|
Object.values(AMOUNT_TONE), BUTTON_CLASS_TOKENS,
|
|
45
52
|
);
|
|
46
53
|
|
|
@@ -98,21 +105,27 @@ export function createAmountBreakdown(): SomaComponentDefinition {
|
|
|
98
105
|
controllerFactory: createKitController(() => ({
|
|
99
106
|
attach(root, api) {
|
|
100
107
|
const onClick = (event: Event): void => {
|
|
101
|
-
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(
|
|
108
|
+
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION));
|
|
102
109
|
if (!btn || btn.disabled) return;
|
|
103
|
-
const row = btn.closest<HTMLElement>(
|
|
104
|
-
api.emit('action', { key: btn.getAttribute(
|
|
110
|
+
const row = btn.closest<HTMLElement>(kitAttrSel(KIT_ATTR_ROW));
|
|
111
|
+
api.emit('action', { key: btn.getAttribute(KIT_ATTR_ACTION) ?? '', id: row?.getAttribute(KIT_ATTR_ROW) ?? '' });
|
|
105
112
|
};
|
|
106
113
|
root.addEventListener('click', onClick);
|
|
107
114
|
return () => root.removeEventListener('click', onClick);
|
|
108
115
|
},
|
|
109
116
|
render(root, p, api) {
|
|
110
117
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
118
|
+
const active = root.ownerDocument.activeElement;
|
|
119
|
+
const focusedRowKey = active instanceof HTMLElement && root.contains(active) && active.hasAttribute(KIT_ATTR_ACTION)
|
|
120
|
+
? active.closest<HTMLElement>(kitAttrSel(KIT_ATTR_ROW))?.getAttribute(KIT_ATTR_ROW) ?? null
|
|
121
|
+
: null;
|
|
111
122
|
root.textContent = '';
|
|
112
123
|
const title = str(p.title);
|
|
113
|
-
if (title !== '')
|
|
124
|
+
if (title !== '') { const h = mk('h3', TITLE_CLASS, title); kitMarkPart(h, 'block-title'); root.appendChild(h); }
|
|
114
125
|
const rows = amountRowsOf(p.data, p.map, str(p.format), str(p.locale));
|
|
115
126
|
// 读状态(加载中 / 读取失败 + 重试):与集合三态同一画法(base/state-panel.ts)
|
|
127
|
+
// 数据状态自报(每次渲染都写):与读状态面板同一判据,出错 > 加载 > 空;data-kit-state 面板标记照旧
|
|
128
|
+
kitMarkDataFacts(root, { error: str(p.error_text) !== '', loading: p.loading === true || p.loading === 'true', empty: !(rows.length > 0) });
|
|
116
129
|
if (applyKitReadState(root, p, { hasContent: rows.length > 0, onRetry: () => api.emit('retry', {}), repaint: () => api.refresh() })) return;
|
|
117
130
|
if (rows.length === 0) {
|
|
118
131
|
root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.empty_detail', undefined, root))));
|
|
@@ -122,18 +135,32 @@ export function createAmountBreakdown(): SomaComponentDefinition {
|
|
|
122
135
|
const rowAction = textOf(ra.key) !== '' && textOf(ra.label) !== ''
|
|
123
136
|
? { key: textOf(ra.key), label: textOf(ra.label), tone: 'neutral' as const, disabled: false, reason: '' }
|
|
124
137
|
: null;
|
|
138
|
+
const dl = mk('dl', DL_CLASS);
|
|
125
139
|
for (const r of rows) {
|
|
126
140
|
const row = mk('div', r.total ? ROW_TOTAL : ROW_CLASS);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
141
|
+
// 明细行 = 描述项(条目);合计行 = 淡底带(汇总行,§8.2)
|
|
142
|
+
kitMarkLevel(row, r.total ? 'band' : 'item'); kitApplyLevelClass(row);
|
|
143
|
+
row.setAttribute(KIT_ATTR_ROW, r.key);
|
|
144
|
+
const dt = mk('dt', `${DT_CLASS} ${INDENT[r.level]}`);
|
|
145
|
+
const left = mk('span', r.level >= 1 ? CHILD_GUIDE_CLASS : LEFT_CLASS);
|
|
146
|
+
const labelEl = mk('span', LABEL_CLASS, r.label);
|
|
147
|
+
kitMarkPart(labelEl, 'field-name');
|
|
148
|
+
left.appendChild(labelEl);
|
|
130
149
|
if (r.note !== '') left.appendChild(mk('span', NOTE_CLASS, r.note));
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
150
|
+
dt.appendChild(left);
|
|
151
|
+
const dd = mk('dd', DD_CLASS);
|
|
152
|
+
const amountEl = mk('span', AMOUNT_TONE[r.tone], r.amount);
|
|
153
|
+
kitMarkPart(amountEl, 'value');
|
|
154
|
+
dd.appendChild(amountEl);
|
|
155
|
+
if (rowAction) dd.appendChild(actionButton(rowAction));
|
|
156
|
+
row.appendChild(dt);
|
|
157
|
+
row.appendChild(dd);
|
|
158
|
+
dl.appendChild(row);
|
|
159
|
+
}
|
|
160
|
+
root.appendChild(dl);
|
|
161
|
+
if (focusedRowKey !== null) {
|
|
162
|
+
const hitRow = Array.from(dl.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_ROW))).find((el) => el.getAttribute(KIT_ATTR_ROW) === focusedRowKey);
|
|
163
|
+
hitRow?.querySelector<HTMLButtonElement>(`${kitAttrSel(KIT_ATTR_ACTION)}:not(:disabled)`)?.focus({ preventScroll: true });
|
|
137
164
|
}
|
|
138
165
|
},
|
|
139
166
|
})),
|
package/src/data/anchor-nav.ts
CHANGED
|
@@ -8,20 +8,28 @@
|
|
|
8
8
|
|
|
9
9
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
10
10
|
import { KIT_STATIC_COMPONENT_LIMITS } from 'soma-foundation/kit-limits';
|
|
11
|
+
import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
|
|
11
12
|
import { kitText } from '../i18n/kit-text';
|
|
12
13
|
import { createKitController, joinClass, num, str } from '../base/shared';
|
|
13
14
|
import { classSet, FOCUS_INSET, h, recList, textOf, type Rec } from './menu-dom';
|
|
14
15
|
import { kitDividerRecipe } from '../recipes/divider';
|
|
16
|
+
import { kitGroupLabelRecipe } from '../recipes/field-text';
|
|
17
|
+
import { kitSelectedRecipe } from '../recipes/state';
|
|
18
|
+
import { mergeClass } from '../shared/merge-class';
|
|
19
|
+
import { kitMarkPart, kitMarkPicked } from './kit-contract';
|
|
20
|
+
import { KIT_ATTR_ANCHOR, KIT_ATTR_ANCHOR_LEVEL, kitAttrSel } from '../shared/dom-attrs';
|
|
15
21
|
|
|
16
22
|
const ROOT_CLASS = 'flex flex-col gap-2 text-sm';
|
|
17
|
-
|
|
23
|
+
// 目录标题是分组眉题:取唯一出口(主题公式 F7:S(−1)、500、更弱的墨、无底)
|
|
24
|
+
const TITLE_CLASS = kitGroupLabelRecipe();
|
|
18
25
|
// 锚点列表的导轨线 = 分隔线出口(发丝宽、分隔灰);当前项竖条是强调指示(border-primary)
|
|
19
26
|
const RAIL_LINE = kitDividerRecipe('start');
|
|
20
27
|
const LIST_CLASS = `flex flex-col ${RAIL_LINE}`;
|
|
21
28
|
const LINK_CLASS = `-ms-px block cursor-pointer truncate border-s-2 border-transparent py-1 ps-3 text-fg-muted transition-colors hover:text-fg ${FOCUS_INSET}`;
|
|
22
29
|
const LINK_L2_CLASS = `-ms-px block cursor-pointer truncate border-s-2 border-transparent py-1 ps-6 text-fg-muted transition-colors hover:text-fg ${FOCUS_INSET}`;
|
|
23
|
-
|
|
24
|
-
const
|
|
30
|
+
// 当前项 = 选中出口(kitSelectedRecipe:主色状态层 + 主色字)+ 起始侧强调竖条
|
|
31
|
+
const LINK_ACTIVE_CLASS = mergeClass(mergeClass('-ms-px block cursor-pointer truncate border-s-2 border-primary py-1 ps-3', kitSelectedRecipe()), FOCUS_INSET);
|
|
32
|
+
const LINK_L2_ACTIVE_CLASS = mergeClass(mergeClass('-ms-px block cursor-pointer truncate border-s-2 border-primary py-1 ps-6', kitSelectedRecipe()), FOCUS_INSET);
|
|
25
33
|
|
|
26
34
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
27
35
|
export const KIT_ANCHOR_NAV_CLASS_CANDIDATES: readonly string[] = classSet(
|
|
@@ -93,12 +101,36 @@ export function createAnchorNav(): SomaComponentDefinition {
|
|
|
93
101
|
let auto = '';
|
|
94
102
|
let scroller: Element | Window | null = null;
|
|
95
103
|
let frame = 0;
|
|
104
|
+
let lockedId = '';
|
|
105
|
+
let lockTimer: ReturnType<typeof setTimeout> | null = null;
|
|
106
|
+
|
|
107
|
+
const clearLock = (): void => {
|
|
108
|
+
lockedId = '';
|
|
109
|
+
if (lockTimer !== null) {
|
|
110
|
+
clearTimeout(lockTimer);
|
|
111
|
+
lockTimer = null;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
96
114
|
|
|
97
115
|
const offset = (): number => num(props.offset) ?? KIT_ANCHOR_DEFAULT_OFFSET;
|
|
98
116
|
const forced = (): string => str(props.active);
|
|
99
117
|
const current = (): string => (forced() !== '' ? forced() : auto);
|
|
100
118
|
const targetEl = (a: KitAnchorItem): HTMLElement | null => doc.getElementById(a.target);
|
|
101
119
|
|
|
120
|
+
const syncActiveDom = (): void => {
|
|
121
|
+
const cur = current();
|
|
122
|
+
for (const link of Array.from(root.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_ANCHOR)))) {
|
|
123
|
+
const id = link.getAttribute(KIT_ATTR_ANCHOR) ?? '';
|
|
124
|
+
const level = link.getAttribute(KIT_ATTR_ANCHOR_LEVEL) === '2' ? 2 : 1;
|
|
125
|
+
const on = id === cur;
|
|
126
|
+
link.className = level === 2 ? (on ? LINK_L2_ACTIVE_CLASS : LINK_L2_CLASS) : (on ? LINK_ACTIVE_CLASS : LINK_CLASS);
|
|
127
|
+
if (on) link.setAttribute('aria-current', 'location');
|
|
128
|
+
else link.removeAttribute('aria-current');
|
|
129
|
+
// 当前节自报「当前」(aria-current=location 已在上两行同步写,帮手不再碰无障碍属性)
|
|
130
|
+
kitMarkPicked(link, 'current', on, null);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
102
134
|
const resolveScroller = (): Element | Window | null => {
|
|
103
135
|
const sel = str(props.scroll_container);
|
|
104
136
|
if (sel !== '') return doc.querySelector(sel) ?? view;
|
|
@@ -118,7 +150,8 @@ export function createAnchorNav(): SomaComponentDefinition {
|
|
|
118
150
|
return { top: 0, atBottom: se.scrollTop + se.clientHeight >= se.scrollHeight - 2 };
|
|
119
151
|
};
|
|
120
152
|
|
|
121
|
-
const recompute = (): void => {
|
|
153
|
+
const recompute = (fromUpdate = false): void => {
|
|
154
|
+
if (lockedId !== '' && !items.some((a) => a.id === lockedId)) clearLock();
|
|
122
155
|
const { top, atBottom } = metrics();
|
|
123
156
|
const tops = items.map((a) => {
|
|
124
157
|
const t = targetEl(a);
|
|
@@ -126,7 +159,14 @@ export function createAnchorNav(): SomaComponentDefinition {
|
|
|
126
159
|
});
|
|
127
160
|
const at = pickActiveIndex(tops, offset(), atBottom);
|
|
128
161
|
const next = at >= 0 ? items[at]!.id : '';
|
|
129
|
-
if (
|
|
162
|
+
if (lockedId !== '') {
|
|
163
|
+
if (next === lockedId) clearLock();
|
|
164
|
+
else return;
|
|
165
|
+
}
|
|
166
|
+
if (next !== auto) {
|
|
167
|
+
auto = next;
|
|
168
|
+
if (!fromUpdate) syncActiveDom();
|
|
169
|
+
}
|
|
130
170
|
};
|
|
131
171
|
|
|
132
172
|
const schedule = (): void => {
|
|
@@ -153,7 +193,7 @@ export function createAnchorNav(): SomaComponentDefinition {
|
|
|
153
193
|
if (!resolvable()) return;
|
|
154
194
|
stopWatch();
|
|
155
195
|
bind();
|
|
156
|
-
if (forced() === '') recompute();
|
|
196
|
+
if (forced() === '') recompute(true);
|
|
157
197
|
paint();
|
|
158
198
|
});
|
|
159
199
|
watcher.observe(doc.body, { childList: true, subtree: true });
|
|
@@ -163,7 +203,7 @@ export function createAnchorNav(): SomaComponentDefinition {
|
|
|
163
203
|
const scrollTo = (a: KitAnchorItem): void => {
|
|
164
204
|
const t = targetEl(a);
|
|
165
205
|
if (!t) return;
|
|
166
|
-
const reduce = view?.matchMedia?.('(prefers-reduced-motion: reduce)')
|
|
206
|
+
const reduce = view?.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches === true;
|
|
167
207
|
const behavior: ScrollBehavior = reduce ? 'auto' : 'smooth';
|
|
168
208
|
if (scroller && scroller !== view) {
|
|
169
209
|
const el = scroller as Element;
|
|
@@ -184,21 +224,38 @@ export function createAnchorNav(): SomaComponentDefinition {
|
|
|
184
224
|
for (const a of items) {
|
|
185
225
|
const on = a.id === cur;
|
|
186
226
|
const cls = a.level === 2 ? (on ? LINK_L2_ACTIVE_CLASS : LINK_L2_CLASS) : (on ? LINK_ACTIVE_CLASS : LINK_CLASS);
|
|
187
|
-
const link = h('a', cls, {
|
|
227
|
+
const link = h('a', cls, {
|
|
228
|
+
href: `#${a.target}`,
|
|
229
|
+
'aria-current': on ? 'location' : undefined,
|
|
230
|
+
[KIT_ATTR_ANCHOR]: a.id,
|
|
231
|
+
[KIT_ATTR_ANCHOR_LEVEL]: String(a.level),
|
|
232
|
+
[KIT_TIPS_SCOPE_ATTR]: '',
|
|
233
|
+
}, a.label);
|
|
234
|
+
kitMarkPart(link, 'action');
|
|
235
|
+
kitMarkPicked(link, 'current', on, null);
|
|
188
236
|
link.addEventListener('click', (e) => {
|
|
189
237
|
e.preventDefault();
|
|
190
|
-
|
|
238
|
+
const reduce = view?.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches === true;
|
|
239
|
+
clearLock();
|
|
191
240
|
auto = a.id;
|
|
192
|
-
|
|
241
|
+
if (!reduce && targetEl(a) !== null) {
|
|
242
|
+
lockedId = a.id;
|
|
243
|
+
lockTimer = setTimeout(() => { lockedId = ''; lockTimer = null; }, 600);
|
|
244
|
+
}
|
|
245
|
+
syncActiveDom();
|
|
246
|
+
scrollTo(a);
|
|
193
247
|
api.emit('pick', { item: a.raw });
|
|
194
248
|
});
|
|
195
249
|
list.append(h('li', '', {}, link));
|
|
196
250
|
}
|
|
197
|
-
// 重画会换掉链接节点:键盘点链接 /
|
|
198
|
-
const focused = root.contains(doc.activeElement) ? (doc.activeElement as HTMLElement).getAttribute(
|
|
199
|
-
|
|
251
|
+
// 重画会换掉链接节点:键盘点链接 / 外部重绘时焦点要还给同一项
|
|
252
|
+
const focused = root.contains(doc.activeElement) ? (doc.activeElement as HTMLElement).getAttribute(KIT_ATTR_ANCHOR) : null;
|
|
253
|
+
const titleEl = title !== '' ? h('div', TITLE_CLASS, {}, title) : null;
|
|
254
|
+
// 目录标题是块标题
|
|
255
|
+
if (titleEl !== null) kitMarkPart(titleEl, 'block-title');
|
|
256
|
+
root.replaceChildren(...(titleEl !== null ? [titleEl] : []), list);
|
|
200
257
|
if (focused !== null) {
|
|
201
|
-
Array.from(root.querySelectorAll<HTMLElement>(
|
|
258
|
+
Array.from(root.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_ANCHOR))).find((el) => el.getAttribute(KIT_ATTR_ANCHOR) === focused)?.focus({ preventScroll: true });
|
|
202
259
|
}
|
|
203
260
|
}
|
|
204
261
|
|
|
@@ -207,10 +264,11 @@ export function createAnchorNav(): SomaComponentDefinition {
|
|
|
207
264
|
props = p;
|
|
208
265
|
items = anchorItemsOf(p.data);
|
|
209
266
|
bind();
|
|
210
|
-
if (forced() === '') recompute();
|
|
267
|
+
if (forced() === '') recompute(true);
|
|
211
268
|
paint();
|
|
212
269
|
},
|
|
213
270
|
destroy() {
|
|
271
|
+
clearLock();
|
|
214
272
|
stopWatch();
|
|
215
273
|
scroller?.removeEventListener('scroll', schedule);
|
|
216
274
|
scroller = null;
|