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
|
@@ -11,12 +11,17 @@
|
|
|
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
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';
|
|
@@ -24,6 +29,7 @@ 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';
|
|
26
31
|
import { kitShellRecipe } from '../recipes/container';
|
|
32
|
+
import { kitMarkLevel, kitMarkPart } from './kit-contract';
|
|
27
33
|
|
|
28
34
|
const KEYS = ['items', 'favorites', 'keyword', 'server_search', 'favorites_max', 'title', 'hint'] as const;
|
|
29
35
|
const FAV_LIMIT = KIT_WORKSPACE_FRAME_LIMITS.limits.systemFavorites;
|
|
@@ -40,19 +46,21 @@ const ROOT_CLASS = `@container flex flex-col gap-3 ${ROOT_EDGE} p-4`;
|
|
|
40
46
|
const HEAD_CLASS = 'flex flex-col';
|
|
41
47
|
const TITLE_CLASS = kitTypographyRecipe('dialogTitle');
|
|
42
48
|
const HINT_CLASS = 'text-xs text-fg-subtle';
|
|
43
|
-
|
|
49
|
+
// 收藏区 = 子块角色(--soma-layer-sub,KT-HB-F);芯片坐在子块上,取对象面底
|
|
50
|
+
const FAV_BOX_CLASS = 'flex flex-col gap-2 sub-block p-3';
|
|
44
51
|
const FAV_HEAD_CLASS = 'flex items-center justify-between gap-2 text-xs text-fg-muted';
|
|
52
|
+
const FAV_COUNT_CLASS = 'tabular-nums';
|
|
45
53
|
const CHIPS_CLASS = 'flex flex-wrap gap-2';
|
|
46
|
-
const CHIP_CLASS = 'inline-flex items-center gap-1 rounded-full bg-surface
|
|
47
|
-
const CHIP_OPEN_CLASS = 'cursor-pointer rounded-
|
|
48
|
-
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;
|
|
49
57
|
const SEARCH_ROW_CLASS = 'flex items-center gap-2';
|
|
50
58
|
const SEARCH_FIELD_CLASS = 'min-w-0 flex-1';
|
|
51
59
|
const LIST_CLASS = 'grid grid-cols-1 gap-2 @2xl:grid-cols-2';
|
|
52
60
|
const HIDDEN = 'hidden';
|
|
53
61
|
|
|
54
62
|
export const KIT_SYSTEM_SWITCHER_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
55
|
-
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,
|
|
56
64
|
CHIP_REMOVE_CLASS, SEARCH_ROW_CLASS, SEARCH_FIELD_CLASS, LIST_CLASS, HIDDEN,
|
|
57
65
|
KIT_ITEM_LIST_CLASS_CANDIDATES, KIT_INPUT_CLASS_CANDIDATES, KIT_BUTTON_CLASS_CANDIDATES,
|
|
58
66
|
);
|
|
@@ -96,7 +104,7 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
96
104
|
props: {
|
|
97
105
|
data: { type: 'object', default: {}, desc: '{ items[{ id, title, sub?, favorite?, disabled? }], keyword?, server_search?, favorites_max?, title?, hint? }' },
|
|
98
106
|
items: { type: 'array', default: [], desc: '系统列表' },
|
|
99
|
-
favorites: { type: 'array', default:
|
|
107
|
+
favorites: { type: 'array', default: null, desc: '常用 [{ id, title, sub? }](可选;不给取 items 里 favorite 为真的)' },
|
|
100
108
|
keyword: { type: 'string', default: '', desc: '搜索关键词(外部变化时覆盖输入框)' },
|
|
101
109
|
server_search: { type: 'boolean', default: false, desc: '真 = 不本地过滤,回车 / 点搜索钮抛 search,由宿主给回结果' },
|
|
102
110
|
favorites_max: { type: 'number', default: 0, desc: '常用上限;0 或缺省 = 真源上限' },
|
|
@@ -110,7 +118,7 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
110
118
|
search: { payload: { keyword: { type: 'string' } }, desc: 'server_search 为真时,回车或点搜索钮' },
|
|
111
119
|
},
|
|
112
120
|
},
|
|
113
|
-
templateHtml: `<section
|
|
121
|
+
templateHtml: `<section ${KIT_ATTR_CONTAINER}="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
114
122
|
controllerFactory: createKitController(() => ({
|
|
115
123
|
attach(root, api) {
|
|
116
124
|
const srcOf = (): Rec => singleOf(api.props().data, api.props(), KEYS);
|
|
@@ -119,14 +127,19 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
119
127
|
const title = mk('h2', TITLE_CLASS);
|
|
120
128
|
const hint = mk('p', HINT_CLASS);
|
|
121
129
|
head.append(title, hint);
|
|
122
|
-
|
|
130
|
+
// 抬头是面头(标题 + 引导句),标题是块标题;常用区是一节,节名是块标题
|
|
131
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
132
|
+
kitMarkPart(title, 'block-title');
|
|
133
|
+
const count = mk('span', FAV_COUNT_CLASS);
|
|
123
134
|
const chips = mk('div', CHIPS_CLASS);
|
|
124
135
|
const favBox = mk('div', FAV_BOX_CLASS);
|
|
125
136
|
const favHead = mk('div', FAV_HEAD_CLASS);
|
|
126
137
|
const favTitle = mk('span', '');
|
|
127
138
|
favHead.append(favTitle, count);
|
|
128
139
|
favBox.append(favHead, chips);
|
|
129
|
-
favBox.setAttribute(
|
|
140
|
+
favBox.setAttribute(KIT_ATTR_SW_FAVORITES, '');
|
|
141
|
+
kitMarkLevel(favBox, 'section'); kitApplyLevelClass(favBox);
|
|
142
|
+
kitMarkPart(favTitle, 'block-title');
|
|
130
143
|
const field = mk('div', SEARCH_FIELD_CLASS);
|
|
131
144
|
const searchBtnBox = mk('div', HIDDEN);
|
|
132
145
|
const searchRow = mk('div', SEARCH_ROW_CLASS);
|
|
@@ -149,9 +162,10 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
149
162
|
},
|
|
150
163
|
});
|
|
151
164
|
field.addEventListener('keydown', (e) => {
|
|
152
|
-
|
|
165
|
+
const ke = e as KeyboardEvent;
|
|
166
|
+
if (ke.key === 'Enter' && !isImeComposing(ke) && bool(srcOf().server_search)) runSearch();
|
|
153
167
|
});
|
|
154
|
-
self.searchBtn = mountKitComponent(createButton(), searchBtnBox, { label: '', variant: '
|
|
168
|
+
self.searchBtn = mountKitComponent(createButton(), searchBtnBox, { label: '', variant: kitActionButtonVariant('apply'), size: 'md' }, { click: runSearch });
|
|
155
169
|
self.list = mountKitComponent(createItemList(), listBox, { selectable: false }, {
|
|
156
170
|
action: (e: { key: string; id: string }) => {
|
|
157
171
|
const item = itemOf(e.id);
|
|
@@ -163,10 +177,10 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
163
177
|
parts.set(root, self);
|
|
164
178
|
const onChipClick = (event: Event): void => {
|
|
165
179
|
const t = event.target as HTMLElement | null;
|
|
166
|
-
const open = t?.closest<HTMLElement>(
|
|
167
|
-
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));
|
|
168
182
|
const hit = open ?? off;
|
|
169
|
-
const item = hit ? itemOf(hit.getAttribute(
|
|
183
|
+
const item = hit ? itemOf(hit.getAttribute(KIT_ATTR_SW_ID) ?? '') : undefined;
|
|
170
184
|
if (!hit || !item) return;
|
|
171
185
|
if (open) api.emit('open', { id: item.id, item: item.raw });
|
|
172
186
|
else api.emit('favorite', { id: item.id, on: false, item: item.raw });
|
|
@@ -197,7 +211,10 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
197
211
|
// 常用独立给出(favorites)时以它为准(搜索结果里可能不含全部常用);否则取 items 里 favorite 为真的
|
|
198
212
|
const favs = Array.isArray(src.favorites) ? systemItemsOf(src.favorites) : items.filter((i) => i.favorite);
|
|
199
213
|
self.title.textContent = textOf(src.title) || kitText('soma.kit.sw_title', undefined, root);
|
|
200
|
-
|
|
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 === '';
|
|
201
218
|
self.count.textContent = kitText('soma.kit.sw_fav_count', { n: favs.length, max }, root);
|
|
202
219
|
const favTitle = self.count.previousElementSibling;
|
|
203
220
|
if (favTitle) favTitle.textContent = kitText('soma.kit.sw_favorites', undefined, root);
|
|
@@ -205,14 +222,17 @@ export function createSystemSwitcher(): SomaComponentDefinition {
|
|
|
205
222
|
const chip = mk('span', CHIP_CLASS);
|
|
206
223
|
const open = mk('button', CHIP_OPEN_CLASS, f.title);
|
|
207
224
|
open.type = 'button';
|
|
208
|
-
open.setAttribute(
|
|
209
|
-
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');
|
|
210
229
|
const off = mk('button', CHIP_REMOVE_CLASS);
|
|
211
230
|
off.type = 'button';
|
|
212
|
-
off.setAttribute(
|
|
213
|
-
off.setAttribute(
|
|
231
|
+
off.setAttribute(KIT_ATTR_SW_UNFAV, '');
|
|
232
|
+
off.setAttribute(KIT_ATTR_SW_ID, f.id);
|
|
214
233
|
off.setAttribute('aria-label', `${kitText('soma.kit.sw_fav_remove', undefined, root)}:${f.title}`);
|
|
215
234
|
off.append(kitIcon('close', 'xs'));
|
|
235
|
+
kitMarkPart(off, 'action');
|
|
216
236
|
chip.append(open, off);
|
|
217
237
|
return chip;
|
|
218
238
|
}));
|
|
@@ -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
|
+
);
|