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
|
@@ -11,39 +11,56 @@
|
|
|
11
11
|
// 写失败宿主不回传即保持原状(失败回滚由 write 的结果决定,组件不猜)。点「打开」抛 open { id, item }。
|
|
12
12
|
// 数据只经 textContent 写入;无匹配显示空态文案。
|
|
13
13
|
|
|
14
|
+
import { kitApplyLevelClass } from './level-class';
|
|
14
15
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
16
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
15
17
|
import { KIT_WORKSPACE_FRAME_LIMITS } from 'soma-foundation/kit-limits';
|
|
16
18
|
import { bool, createKitController, joinClass } from '../base/shared';
|
|
17
|
-
import {
|
|
19
|
+
import { KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
|
|
20
|
+
import { isImeComposing } from '../base/popup';
|
|
21
|
+
import { createButton, kitActionButtonVariant, KIT_BUTTON_CLASS_CANDIDATES } from '../base/button';
|
|
18
22
|
import { createInput, KIT_INPUT_CLASS_CANDIDATES } from '../base/input';
|
|
19
|
-
import { kitIcon } from '../
|
|
23
|
+
import { kitIcon } from '../shared/icons';
|
|
24
|
+
import { KIT_ATTR_CONTAINER, KIT_ATTR_SW_FAVORITES, KIT_ATTR_SW_ID, KIT_ATTR_SW_OPEN, KIT_ATTR_SW_UNFAV, kitAttrSel } from '../shared/dom-attrs';
|
|
20
25
|
import { kitText } from '../i18n/kit-text';
|
|
21
26
|
import { mountKitComponent, type KitMount } from './embed';
|
|
22
27
|
import { singleOf, clampInt } from './display-util';
|
|
23
28
|
import { createItemList, KIT_ITEM_LIST_CLASS_CANDIDATES } from './item-list';
|
|
24
29
|
import { classTokens, mk, rowsOf, textOf, type Rec } from './shape-util';
|
|
25
30
|
import { kitTypographyRecipe } from '../recipes/typography';
|
|
31
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
32
|
+
import { kitMarkLevel, kitMarkPart } from './kit-contract';
|
|
26
33
|
|
|
27
34
|
const KEYS = ['items', 'favorites', 'keyword', 'server_search', 'favorites_max', 'title', 'hint'] as const;
|
|
28
35
|
const FAV_LIMIT = KIT_WORKSPACE_FRAME_LIMITS.limits.systemFavorites;
|
|
36
|
+
/** 常用上限:0 / 负数 / 缺省一律回退真源上限 FAV_LIMIT,正整数钳在 1..FAV_LIMIT */
|
|
37
|
+
export function favMaxOf(raw: unknown): number {
|
|
38
|
+
const n = typeof raw === 'number' ? raw : typeof raw === 'string' && raw.trim() !== '' ? Number(raw) : NaN;
|
|
39
|
+
if (!Number.isFinite(n) || Math.trunc(n) <= 0) return FAV_LIMIT;
|
|
40
|
+
return clampInt(n, 1, FAV_LIMIT, FAV_LIMIT);
|
|
41
|
+
}
|
|
29
42
|
|
|
30
|
-
|
|
43
|
+
// 外缘 = 壳配方(容器边 + 容器阴影令牌,KT-B2);已选芯片浅底无描边
|
|
44
|
+
const ROOT_EDGE = kitShellRecipe();
|
|
45
|
+
const ROOT_CLASS = `@container flex flex-col gap-3 ${ROOT_EDGE} p-4`;
|
|
31
46
|
const HEAD_CLASS = 'flex flex-col';
|
|
32
47
|
const TITLE_CLASS = kitTypographyRecipe('dialogTitle');
|
|
33
48
|
const HINT_CLASS = 'text-xs text-fg-subtle';
|
|
34
|
-
|
|
49
|
+
// 收藏区 = 子块角色(--soma-layer-sub,KT-HB-F);芯片坐在子块上,取对象面底
|
|
50
|
+
const FAV_BOX_CLASS = 'flex flex-col gap-2 sub-block p-3';
|
|
35
51
|
const FAV_HEAD_CLASS = 'flex items-center justify-between gap-2 text-xs text-fg-muted';
|
|
52
|
+
const FAV_COUNT_CLASS = 'tabular-nums';
|
|
36
53
|
const CHIPS_CLASS = 'flex flex-wrap gap-2';
|
|
37
|
-
const CHIP_CLASS = 'inline-flex items-center gap-1 rounded-full
|
|
38
|
-
const CHIP_OPEN_CLASS = 'cursor-pointer rounded-
|
|
39
|
-
const CHIP_REMOVE_CLASS = 'inline-flex size-6 p-0 cursor-pointer items-center justify-center rounded-full text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg
|
|
54
|
+
const CHIP_CLASS = 'inline-flex max-w-full items-center gap-1 rounded-full bg-surface ps-3 pe-1 text-sm text-fg';
|
|
55
|
+
const CHIP_OPEN_CLASS = 'max-w-48 cursor-pointer truncate rounded-item text-sm text-fg ' + KIT_FOCUS_RING.button;
|
|
56
|
+
const CHIP_REMOVE_CLASS = 'inline-flex size-6 p-0 cursor-pointer items-center justify-center rounded-full text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg ' + KIT_FOCUS_RING.button;
|
|
40
57
|
const SEARCH_ROW_CLASS = 'flex items-center gap-2';
|
|
41
58
|
const SEARCH_FIELD_CLASS = 'min-w-0 flex-1';
|
|
42
59
|
const LIST_CLASS = 'grid grid-cols-1 gap-2 @2xl:grid-cols-2';
|
|
43
60
|
const HIDDEN = 'hidden';
|
|
44
61
|
|
|
45
62
|
export const KIT_SYSTEM_SWITCHER_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
46
|
-
ROOT_CLASS, HEAD_CLASS, TITLE_CLASS, HINT_CLASS, FAV_BOX_CLASS, FAV_HEAD_CLASS, CHIPS_CLASS, CHIP_CLASS, CHIP_OPEN_CLASS,
|
|
63
|
+
ROOT_CLASS, HEAD_CLASS, TITLE_CLASS, HINT_CLASS, FAV_BOX_CLASS, FAV_HEAD_CLASS, FAV_COUNT_CLASS, CHIPS_CLASS, CHIP_CLASS, CHIP_OPEN_CLASS,
|
|
47
64
|
CHIP_REMOVE_CLASS, SEARCH_ROW_CLASS, SEARCH_FIELD_CLASS, LIST_CLASS, HIDDEN,
|
|
48
65
|
KIT_ITEM_LIST_CLASS_CANDIDATES, KIT_INPUT_CLASS_CANDIDATES, KIT_BUTTON_CLASS_CANDIDATES,
|
|
49
66
|
);
|
|
@@ -87,7 +104,7 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
87
104
|
props: {
|
|
88
105
|
data: { type: 'object', default: {}, desc: '{ items[{ id, title, sub?, favorite?, disabled? }], keyword?, server_search?, favorites_max?, title?, hint? }' },
|
|
89
106
|
items: { type: 'array', default: [], desc: '系统列表' },
|
|
90
|
-
favorites: { type: 'array', default:
|
|
107
|
+
favorites: { type: 'array', default: null, desc: '常用 [{ id, title, sub? }](可选;不给取 items 里 favorite 为真的)' },
|
|
91
108
|
keyword: { type: 'string', default: '', desc: '搜索关键词(外部变化时覆盖输入框)' },
|
|
92
109
|
server_search: { type: 'boolean', default: false, desc: '真 = 不本地过滤,回车 / 点搜索钮抛 search,由宿主给回结果' },
|
|
93
110
|
favorites_max: { type: 'number', default: 0, desc: '常用上限;0 或缺省 = 真源上限' },
|
|
@@ -101,7 +118,7 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
101
118
|
search: { payload: { keyword: { type: 'string' } }, desc: 'server_search 为真时,回车或点搜索钮' },
|
|
102
119
|
},
|
|
103
120
|
},
|
|
104
|
-
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
121
|
+
templateHtml: `<section ${KIT_ATTR_CONTAINER}="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
105
122
|
controllerFactory: createKitController(() => ({
|
|
106
123
|
attach(root, api) {
|
|
107
124
|
const srcOf = (): Rec => singleOf(api.props().data, api.props(), KEYS);
|
|
@@ -110,14 +127,19 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
110
127
|
const title = mk('h2', TITLE_CLASS);
|
|
111
128
|
const hint = mk('p', HINT_CLASS);
|
|
112
129
|
head.append(title, hint);
|
|
113
|
-
|
|
130
|
+
// 抬头是面头(标题 + 引导句),标题是块标题;常用区是一节,节名是块标题
|
|
131
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
132
|
+
kitMarkPart(title, 'block-title');
|
|
133
|
+
const count = mk('span', FAV_COUNT_CLASS);
|
|
114
134
|
const chips = mk('div', CHIPS_CLASS);
|
|
115
135
|
const favBox = mk('div', FAV_BOX_CLASS);
|
|
116
136
|
const favHead = mk('div', FAV_HEAD_CLASS);
|
|
117
137
|
const favTitle = mk('span', '');
|
|
118
138
|
favHead.append(favTitle, count);
|
|
119
139
|
favBox.append(favHead, chips);
|
|
120
|
-
favBox.setAttribute(
|
|
140
|
+
favBox.setAttribute(KIT_ATTR_SW_FAVORITES, '');
|
|
141
|
+
kitMarkLevel(favBox, 'section'); kitApplyLevelClass(favBox);
|
|
142
|
+
kitMarkPart(favTitle, 'block-title');
|
|
121
143
|
const field = mk('div', SEARCH_FIELD_CLASS);
|
|
122
144
|
const searchBtnBox = mk('div', HIDDEN);
|
|
123
145
|
const searchRow = mk('div', SEARCH_ROW_CLASS);
|
|
@@ -140,9 +162,10 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
140
162
|
},
|
|
141
163
|
});
|
|
142
164
|
field.addEventListener('keydown', (e) => {
|
|
143
|
-
|
|
165
|
+
const ke = e as KeyboardEvent;
|
|
166
|
+
if (ke.key === 'Enter' && !isImeComposing(ke) && bool(srcOf().server_search)) runSearch();
|
|
144
167
|
});
|
|
145
|
-
self.searchBtn = mountKitComponent(createButton(), searchBtnBox, { label: '', variant: '
|
|
168
|
+
self.searchBtn = mountKitComponent(createButton(), searchBtnBox, { label: '', variant: kitActionButtonVariant('apply'), size: 'md' }, { click: runSearch });
|
|
146
169
|
self.list = mountKitComponent(createItemList(), listBox, { selectable: false }, {
|
|
147
170
|
action: (e: { key: string; id: string }) => {
|
|
148
171
|
const item = itemOf(e.id);
|
|
@@ -154,10 +177,10 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
154
177
|
parts.set(root, self);
|
|
155
178
|
const onChipClick = (event: Event): void => {
|
|
156
179
|
const t = event.target as HTMLElement | null;
|
|
157
|
-
const open = t?.closest<HTMLElement>(
|
|
158
|
-
const off = t?.closest<HTMLElement>(
|
|
180
|
+
const open = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_SW_OPEN));
|
|
181
|
+
const off = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_SW_UNFAV));
|
|
159
182
|
const hit = open ?? off;
|
|
160
|
-
const item = hit ? itemOf(hit.getAttribute(
|
|
183
|
+
const item = hit ? itemOf(hit.getAttribute(KIT_ATTR_SW_ID) ?? '') : undefined;
|
|
161
184
|
if (!hit || !item) return;
|
|
162
185
|
if (open) api.emit('open', { id: item.id, item: item.raw });
|
|
163
186
|
else api.emit('favorite', { id: item.id, on: false, item: item.raw });
|
|
@@ -184,11 +207,14 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
184
207
|
self.input.setProps({ value: keyword });
|
|
185
208
|
}
|
|
186
209
|
const items = systemItemsOf(src.items);
|
|
187
|
-
const max =
|
|
210
|
+
const max = favMaxOf(src.favorites_max);
|
|
188
211
|
// 常用独立给出(favorites)时以它为准(搜索结果里可能不含全部常用);否则取 items 里 favorite 为真的
|
|
189
212
|
const favs = Array.isArray(src.favorites) ? systemItemsOf(src.favorites) : items.filter((i) => i.favorite);
|
|
190
213
|
self.title.textContent = textOf(src.title) || kitText('soma.kit.sw_title', undefined, root);
|
|
191
|
-
|
|
214
|
+
// 缺省引导句只在收藏为空时出现(它是收藏区的空态提示;有收藏后不再占一行,非内容项 N09);页面给了副标题照常显示
|
|
215
|
+
const hintText = textOf(src.hint) || (favs.length === 0 ? kitText('soma.kit.sw_hint', undefined, root) : '');
|
|
216
|
+
self.hint.textContent = hintText;
|
|
217
|
+
self.hint.hidden = hintText === '';
|
|
192
218
|
self.count.textContent = kitText('soma.kit.sw_fav_count', { n: favs.length, max }, root);
|
|
193
219
|
const favTitle = self.count.previousElementSibling;
|
|
194
220
|
if (favTitle) favTitle.textContent = kitText('soma.kit.sw_favorites', undefined, root);
|
|
@@ -196,14 +222,17 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
196
222
|
const chip = mk('span', CHIP_CLASS);
|
|
197
223
|
const open = mk('button', CHIP_OPEN_CLASS, f.title);
|
|
198
224
|
open.type = 'button';
|
|
199
|
-
open.setAttribute(
|
|
200
|
-
open.setAttribute(
|
|
225
|
+
open.setAttribute(KIT_ATTR_SW_OPEN, '');
|
|
226
|
+
open.setAttribute(KIT_ATTR_SW_ID, f.id);
|
|
227
|
+
open.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
|
|
228
|
+
kitMarkPart(open, 'action');
|
|
201
229
|
const off = mk('button', CHIP_REMOVE_CLASS);
|
|
202
230
|
off.type = 'button';
|
|
203
|
-
off.setAttribute(
|
|
204
|
-
off.setAttribute(
|
|
231
|
+
off.setAttribute(KIT_ATTR_SW_UNFAV, '');
|
|
232
|
+
off.setAttribute(KIT_ATTR_SW_ID, f.id);
|
|
205
233
|
off.setAttribute('aria-label', `${kitText('soma.kit.sw_fav_remove', undefined, root)}:${f.title}`);
|
|
206
234
|
off.append(kitIcon('close', 'xs'));
|
|
235
|
+
kitMarkPart(off, 'action');
|
|
207
236
|
chip.append(open, off);
|
|
208
237
|
return chip;
|
|
209
238
|
}));
|
|
@@ -221,7 +250,7 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
221
250
|
if (!self) return;
|
|
222
251
|
const src = singleOf(p.data, p, KEYS);
|
|
223
252
|
const items = systemItemsOf(src.items);
|
|
224
|
-
const max =
|
|
253
|
+
const max = favMaxOf(src.favorites_max);
|
|
225
254
|
const favCount = Array.isArray(src.favorites) ? src.favorites.length : items.filter((i) => i.favorite).length;
|
|
226
255
|
const full = favCount >= max;
|
|
227
256
|
const shown = bool(src.server_search) ? items : filterSystems(items, self.typed);
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// TargetProgress:目标达成(layer: data,写死形状,accept: single)。
|
|
2
|
+
//
|
|
3
|
+
// 数据:`data` 是对象 { value, target, forecast?, label? }(也可由同名 prop 直接给,prop 非空优先)。
|
|
4
|
+
// 结构:标题行(名 + 「值 / 目标」+ 达成百分数)、进度条(轨道 + 预测段淡一档 + 实际段 + 目标刻度线)、底行(目标 · 预测 · 差额)。
|
|
5
|
+
// 色:tone 缺省 auto —— 已达成 success,预测低于目标 warning,其余 primary;也可显式指定语义色。
|
|
6
|
+
// 轴上限取 value / target / forecast 的最大者,目标刻度画在 target 处,超额时刻度落在条内(不被裁)。
|
|
7
|
+
// 抄 Tremor(Apache-2.0)ProgressBar + DashboardProgressBarCard 的「值 / 目标」文案与刻度;预测段抄 KitProgress 缓冲段(同色淡一档)。
|
|
8
|
+
// 无障碍:条是 role=progressbar(aria-valuenow = 达成百分数,不含预测),刻度与预测在底行以文字给出。
|
|
9
|
+
|
|
10
|
+
import type { SomaComponentDefinition } from 'soma-core';
|
|
11
|
+
import { kitMarkDataFacts, kitMarkPart } from './kit-contract';
|
|
12
|
+
import { createKitController, formatValue, joinClass, num, str, type KitProps } from '../base/shared';
|
|
13
|
+
import { KIT_TIP_ATTR } from '../base/hint-tips';
|
|
14
|
+
import { releaseReasonTipsIn } from '../base/reason-tip';
|
|
15
|
+
import { kitText } from '../i18n/kit-text';
|
|
16
|
+
import { kitWellRecipe } from '../recipes/surface';
|
|
17
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
18
|
+
import { KIT_SKELETON_BAR_MID } from '../recipes/placeholder';
|
|
19
|
+
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
|
|
20
|
+
import { mergeClass } from '../shared/merge-class';
|
|
21
|
+
import { KIT_ATTR_FORECAST, KIT_ATTR_SKELETON, KIT_ATTR_TARGET } from '../shared/dom-attrs';
|
|
22
|
+
import { classTokens, emptyNode, mk, recOf, shapeToneOf, textOf, TONE_TEXT, type ShapeTone } from './shape-util';
|
|
23
|
+
import { pctText, plainNumber, SUMMARY_COLOR_CLASSES, svgEl, toneFill, toneFillSoft } from './summary-util';
|
|
24
|
+
|
|
25
|
+
const ROOT_CLASS = 'flex w-full flex-col gap-2';
|
|
26
|
+
const HEAD_CLASS = 'flex items-baseline justify-between gap-3';
|
|
27
|
+
const LABEL_CLASS = kitTypographyRecipe('text');
|
|
28
|
+
const READ_CLASS = 'flex items-baseline gap-2 tabular-nums';
|
|
29
|
+
const VALUE_CLASS = 'font-medium text-fg';
|
|
30
|
+
const TARGET_CLASS = 'text-fg-subtle';
|
|
31
|
+
const BAR_SIZE: Readonly<Record<string, string>> = Object.freeze({
|
|
32
|
+
sm: 'block h-2.5 w-full overflow-visible',
|
|
33
|
+
md: 'block h-3 w-full overflow-visible',
|
|
34
|
+
lg: 'block h-4 w-full overflow-visible',
|
|
35
|
+
});
|
|
36
|
+
// 加载骨架:标题行一条短条 + 同尺寸(条高同 BAR_SIZE)的轨色条,shimmer;不逐段闪
|
|
37
|
+
const SKELETON_BOX_CLASS = 'flex w-full flex-col gap-2';
|
|
38
|
+
const SKELETON_TITLE_CLASS = KIT_SKELETON_BAR_MID;
|
|
39
|
+
const SKELETON_FILL_CLASS = mergeClass(kitWellRecipe(), 'motion-safe:animate-kit-pulse');
|
|
40
|
+
const BAR_SKELETON: Readonly<Record<string, string>> = Object.freeze({
|
|
41
|
+
sm: 'block h-2.5 w-full rounded-full',
|
|
42
|
+
md: 'block h-3 w-full rounded-full',
|
|
43
|
+
lg: 'block h-4 w-full rounded-full',
|
|
44
|
+
});
|
|
45
|
+
// 组件卡 ProgressBars §6:轨 = 凹槽面(中性轨);目标刻度 = 4 宽(Tremor CategoryBar 标记 h-4 w-1)
|
|
46
|
+
const TRACK_CLASS = kitWellRecipe({ paint: 'fill' });
|
|
47
|
+
const MARK_CLASS = 'stroke-fg';
|
|
48
|
+
const FOOT_CLASS = mergeClass('flex flex-wrap items-center gap-x-4 gap-y-1 tabular-nums', kitTypographyRecipe('caption'));
|
|
49
|
+
const FOOT_ITEM_CLASS = 'text-fg-subtle';
|
|
50
|
+
|
|
51
|
+
export const KIT_TARGET_PROGRESS_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
52
|
+
ROOT_CLASS, HEAD_CLASS, LABEL_CLASS, READ_CLASS, VALUE_CLASS, TARGET_CLASS, Object.values(BAR_SIZE), TRACK_CLASS, MARK_CLASS,
|
|
53
|
+
FOOT_CLASS, FOOT_ITEM_CLASS, Object.values(TONE_TEXT), SUMMARY_COLOR_CLASSES,
|
|
54
|
+
SKELETON_BOX_CLASS, SKELETON_TITLE_CLASS, SKELETON_FILL_CLASS, Object.values(BAR_SKELETON),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
export interface KitTargetModel {
|
|
58
|
+
value: number;
|
|
59
|
+
target: number;
|
|
60
|
+
forecast: number | null;
|
|
61
|
+
/** 轴上限 */
|
|
62
|
+
axis: number;
|
|
63
|
+
/** 达成百分数(不夹上限,超额 > 100) */
|
|
64
|
+
reached: number;
|
|
65
|
+
tone: ShapeTone;
|
|
66
|
+
gap: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 数据 -> 模型(纯函数):target <= 0 或缺失返回 null;tone auto 按达成 / 预测决定 */
|
|
70
|
+
export function targetModelOf(valueRaw: unknown, targetRaw: unknown, forecastRaw: unknown, toneRaw: unknown): KitTargetModel | null {
|
|
71
|
+
const value = num(valueRaw);
|
|
72
|
+
const target = num(targetRaw);
|
|
73
|
+
if (value === null || target === null || target <= 0) return null;
|
|
74
|
+
const forecast = num(forecastRaw);
|
|
75
|
+
const axis = Math.max(value, target, forecast ?? 0);
|
|
76
|
+
const tone: ShapeTone = toneRaw === undefined || toneRaw === '' || toneRaw === 'auto'
|
|
77
|
+
? (value >= target ? 'success' : forecast !== null && forecast < target ? 'warning' : 'primary')
|
|
78
|
+
: shapeToneOf(toneRaw, 'primary');
|
|
79
|
+
return { value, target, forecast, axis, reached: (value / target) * 100, tone, gap: target - value };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const sizeOf = (raw: unknown): string => (raw === 'sm' || raw === 'lg' ? raw : 'md');
|
|
83
|
+
|
|
84
|
+
export function createTargetProgress(): SomaComponentDefinition {
|
|
85
|
+
return {
|
|
86
|
+
contract: {
|
|
87
|
+
name: 'TargetProgress',
|
|
88
|
+
layer: 'data',
|
|
89
|
+
props: {
|
|
90
|
+
data: { type: 'object', default: {}, desc: '{ value, target, forecast?, label? };同名 prop 非空时优先' },
|
|
91
|
+
value: { type: 'string', default: '', desc: '实际值' },
|
|
92
|
+
target: { type: 'string', default: '', desc: '目标值(> 0)' },
|
|
93
|
+
forecast: { type: 'string', default: '', desc: '预测值(可选):画成实际段之后的淡一档段' },
|
|
94
|
+
label: { type: 'string', default: '', desc: '名称' },
|
|
95
|
+
format: { type: 'string', default: '', desc: '值格式(soma-foundation/values 写法)' },
|
|
96
|
+
locale: { type: 'string', default: '', desc: '格式化语言' },
|
|
97
|
+
unit: { type: 'string', default: '', desc: '单位后缀(format 为空时追加)' },
|
|
98
|
+
tone: { type: 'string', default: 'auto', desc: 'auto(缺省:达成 success / 预测不足 warning / 其余 primary)| primary | info | success | warning | danger' },
|
|
99
|
+
size: { type: 'string', default: 'md', desc: '条高:sm | md | lg' },
|
|
100
|
+
target_label: { type: 'string', default: '', desc: '底行「目标」文案;缺省按页面语言取内置文案' },
|
|
101
|
+
forecast_label: { type: 'string', default: '', desc: '底行「预测」文案;缺省按页面语言取内置文案' },
|
|
102
|
+
gap_label: { type: 'string', default: '', desc: '底行「差额/缺口」文案(未达成显示还差多少,超额显示超出多少);缺省按页面语言取内置文案' },
|
|
103
|
+
empty_text: { type: 'string', default: '—', desc: '缺值时的占位' },
|
|
104
|
+
...KIT_READ_STATE_PROP_DEFS,
|
|
105
|
+
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
106
|
+
},
|
|
107
|
+
emits: { ...KIT_READ_STATE_EMIT_DEFS },
|
|
108
|
+
},
|
|
109
|
+
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
110
|
+
controllerFactory: createKitController((api) => ({
|
|
111
|
+
render(root: HTMLElement, p: KitProps): void {
|
|
112
|
+
root.className = joinClass(ROOT_CLASS, p.class);
|
|
113
|
+
releaseReasonTipsIn(root);
|
|
114
|
+
root.textContent = '';
|
|
115
|
+
const d = recOf(p.data);
|
|
116
|
+
const pick = (key: string): unknown => (p[key] !== undefined && p[key] !== '' ? p[key] : d[key]);
|
|
117
|
+
const m = targetModelOf(pick('value'), pick('target'), pick('forecast'), p.tone);
|
|
118
|
+
// 读状态(错误 > 加载 > 内容):加载骨架 = 标题行占位 + 同尺寸的轨色条;错误面板带重试
|
|
119
|
+
const skeleton = (): HTMLElement => {
|
|
120
|
+
const box = mk('div', SKELETON_BOX_CLASS);
|
|
121
|
+
box.setAttribute(KIT_ATTR_SKELETON, '');
|
|
122
|
+
box.append(mk('div', SKELETON_TITLE_CLASS), mk('div', `${BAR_SKELETON[sizeOf(p.size)]!} ${SKELETON_FILL_CLASS}`));
|
|
123
|
+
return box;
|
|
124
|
+
};
|
|
125
|
+
// 数据状态自报(每次渲染都写):与读状态面板同一判据,出错 > 加载 > 空;data-kit-state 面板标记照旧
|
|
126
|
+
kitMarkDataFacts(root, { error: str(p.error_text) !== '', loading: p.loading === true || p.loading === 'true', empty: !(m !== null) });
|
|
127
|
+
if (applyKitReadState(root, p, { hasContent: m !== null, onRetry: () => api.emit('retry', {}), repaint: () => api.refresh(), skeleton })) return;
|
|
128
|
+
if (m === null) { root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.chart_readout_empty', undefined, root)))); return; }
|
|
129
|
+
const format = str(p.format);
|
|
130
|
+
const unit = str(p.unit);
|
|
131
|
+
const locale = str(p.locale);
|
|
132
|
+
const show = (n: number): string => (format === '' ? `${plainNumber(n)}${unit}` : formatValue(n, format, locale));
|
|
133
|
+
const label = textOf(pick('label'));
|
|
134
|
+
const defaultTargetLabel = kitText('soma.kit.rc_target', undefined, root);
|
|
135
|
+
const rawProj = kitText('soma.kit.chart_projection', { name: '' }, root).replace(/^[((\s]+|[))\s]+$/g, '');
|
|
136
|
+
const defaultForecastLabel = rawProj !== '' ? rawProj.charAt(0).toUpperCase() + rawProj.slice(1) : defaultTargetLabel;
|
|
137
|
+
const defaultGapLabel = kitText('soma.kit.gap_marker', undefined, root);
|
|
138
|
+
const targetLabel = str(p.target_label, defaultTargetLabel);
|
|
139
|
+
const forecastLabel = str(p.forecast_label, defaultForecastLabel);
|
|
140
|
+
const gapLabel = str(p.gap_label, defaultGapLabel);
|
|
141
|
+
const head = mk('div', HEAD_CLASS);
|
|
142
|
+
const labelEl = mk('span', LABEL_CLASS, label);
|
|
143
|
+
// 标题行:名称 = 字段名,读数 = 指标,达成率 = 状态(语气色)
|
|
144
|
+
kitMarkPart(labelEl, 'field-name');
|
|
145
|
+
head.appendChild(labelEl);
|
|
146
|
+
const read = mk('span', READ_CLASS);
|
|
147
|
+
const reachedPct = pctText(Math.round(m.reached));
|
|
148
|
+
const valueEl = mk('span', VALUE_CLASS, show(m.value));
|
|
149
|
+
const reachedEl = mk('span', TONE_TEXT[m.tone], reachedPct);
|
|
150
|
+
kitMarkPart(valueEl, 'metric');
|
|
151
|
+
kitMarkPart(reachedEl, 'status');
|
|
152
|
+
read.append(valueEl, mk('span', TARGET_CLASS, `/ ${show(m.target)}`), reachedEl);
|
|
153
|
+
head.appendChild(read);
|
|
154
|
+
root.appendChild(head);
|
|
155
|
+
|
|
156
|
+
const at = (n: number): number => (Math.max(0, n) / m.axis) * 100;
|
|
157
|
+
const barTip = `${label !== '' ? `${label}:` : ''}${show(m.value)} / ${show(m.target)}(${reachedPct})`;
|
|
158
|
+
const svg = svgEl('svg', {
|
|
159
|
+
role: 'progressbar',
|
|
160
|
+
class: BAR_SIZE[sizeOf(p.size)]!,
|
|
161
|
+
'aria-valuemin': '0',
|
|
162
|
+
'aria-valuemax': '100',
|
|
163
|
+
'aria-valuenow': String(Math.round(Math.max(0, Math.min(m.reached, 100)))),
|
|
164
|
+
'aria-label': label !== '' ? label : kitText('soma.kit.progress', undefined, root),
|
|
165
|
+
[KIT_TIP_ATTR]: barTip,
|
|
166
|
+
});
|
|
167
|
+
const bar = { y: '25%', height: '50%', ry: '50%' };
|
|
168
|
+
svg.appendChild(svgEl('rect', { x: '0', width: '100%', class: TRACK_CLASS, ...bar }));
|
|
169
|
+
if (m.forecast !== null && m.forecast > Math.max(0, m.value)) {
|
|
170
|
+
svg.appendChild(svgEl('rect', {
|
|
171
|
+
x: '0',
|
|
172
|
+
width: pctText(at(Math.max(0, m.forecast))),
|
|
173
|
+
class: toneFillSoft(m.tone),
|
|
174
|
+
[KIT_ATTR_FORECAST]: '',
|
|
175
|
+
[KIT_TIP_ATTR]: `${forecastLabel} ${show(m.forecast)}`,
|
|
176
|
+
...bar,
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
svg.appendChild(svgEl('rect', {
|
|
180
|
+
x: '0',
|
|
181
|
+
width: pctText(at(Math.max(0, m.value))),
|
|
182
|
+
class: toneFill(m.tone),
|
|
183
|
+
[KIT_TIP_ATTR]: barTip,
|
|
184
|
+
...bar,
|
|
185
|
+
}));
|
|
186
|
+
svg.appendChild(svgEl('line', {
|
|
187
|
+
x1: pctText(at(m.target)),
|
|
188
|
+
x2: pctText(at(m.target)),
|
|
189
|
+
y1: '0',
|
|
190
|
+
y2: '100%',
|
|
191
|
+
class: MARK_CLASS,
|
|
192
|
+
'stroke-width': '4',
|
|
193
|
+
'stroke-linecap': 'round',
|
|
194
|
+
[KIT_ATTR_TARGET]: '',
|
|
195
|
+
[KIT_TIP_ATTR]: `${targetLabel} ${show(m.target)}`,
|
|
196
|
+
}));
|
|
197
|
+
root.appendChild(svg);
|
|
198
|
+
|
|
199
|
+
const foot = mk('div', FOOT_CLASS);
|
|
200
|
+
foot.appendChild(mk('span', FOOT_ITEM_CLASS, `${targetLabel} ${show(m.target)}`));
|
|
201
|
+
if (m.forecast !== null) foot.appendChild(mk('span', FOOT_ITEM_CLASS, `${forecastLabel} ${show(m.forecast)}`));
|
|
202
|
+
const gap = Math.abs(m.gap);
|
|
203
|
+
foot.appendChild(mk('span', m.gap > 0 ? FOOT_ITEM_CLASS : TONE_TEXT.success, `${gapLabel} ${m.gap > 0 ? '' : '+'}${show(gap)}`));
|
|
204
|
+
root.appendChild(foot);
|
|
205
|
+
},
|
|
206
|
+
})),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
@@ -1,17 +1,38 @@
|
|
|
1
|
-
//
|
|
1
|
+
// 无意义交互的文字链接式动作钮(展开 / 收起 / 复制文本 / 切换视图 …):配方出口 kitPlainActionRecipe(只收「无意义交互」类功能名,
|
|
2
|
+
// SCON-116:有后果的动作一律是按钮,走 kitActionRecipe / actionButton,不在此处)。
|
|
2
3
|
// 带 data-kit-action,供各组件的点击委托识别(与 actionButton 同一约定)。
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
+
import { kitPlainActionRecipe, type KitPlainActionFunction } from '../recipes/emphasis';
|
|
5
6
|
import { classTokens } from './shape-util';
|
|
7
|
+
import { kitMarkPart } from './kit-contract';
|
|
8
|
+
import { KIT_ATTR_ACTION } from '../shared/dom-attrs';
|
|
6
9
|
|
|
7
|
-
export function textActionButton(key: string, label: string,
|
|
10
|
+
export function textActionButton(key: string, label: string, fn: KitPlainActionFunction): HTMLButtonElement {
|
|
8
11
|
const btn = document.createElement('button');
|
|
9
12
|
btn.type = 'button';
|
|
10
|
-
btn.className =
|
|
13
|
+
btn.className = kitPlainActionRecipe(fn);
|
|
11
14
|
btn.textContent = label;
|
|
12
|
-
btn.setAttribute(
|
|
15
|
+
btn.setAttribute(KIT_ATTR_ACTION, key);
|
|
16
|
+
// 文字链接式动作同样是「动作」元素部件(与 actionButton 同一单点)
|
|
17
|
+
kitMarkPart(btn, 'action');
|
|
13
18
|
return btn;
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
/**
|
|
17
|
-
|
|
21
|
+
/** 全量枚举 KitPlainActionFunction,编译期穷尽校验,确保候选类采样零遗漏 */
|
|
22
|
+
const PLAIN_ACTION_FNS_EXHAUSTIVE: Readonly<Record<KitPlainActionFunction, true>> = {
|
|
23
|
+
page: true,
|
|
24
|
+
sort: true,
|
|
25
|
+
clear: true,
|
|
26
|
+
expand: true,
|
|
27
|
+
collapse: true,
|
|
28
|
+
'more-text': true,
|
|
29
|
+
'copy-text': true,
|
|
30
|
+
toggle: true,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const PLAIN_ACTION_FNS = Object.keys(PLAIN_ACTION_FNS_EXHAUSTIVE) as KitPlainActionFunction[];
|
|
34
|
+
|
|
35
|
+
/** 候选类(全量采样所有 KitPlainActionFunction 分支,用到 textActionButton 的组件并入) */
|
|
36
|
+
export const TEXT_ACTION_CLASS_TOKENS: readonly string[] = classTokens(
|
|
37
|
+
PLAIN_ACTION_FNS.map((fn) => kitPlainActionRecipe(fn)),
|
|
38
|
+
);
|