soma-kit 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
package/src/data/tree.ts
CHANGED
|
@@ -13,11 +13,18 @@
|
|
|
13
13
|
// 页面重取数据把 children 补进该节点后自动结束加载态;已有的勾选会顺着级联落到新子项上。
|
|
14
14
|
// - `filter`:关键字(页面绑一个输入框的值),只留命中项 + 祖先 + 命中项的后代,祖先自动展开,命中文字高亮;无命中显示 filter_empty_text。
|
|
15
15
|
|
|
16
|
+
import { kitApplyLevelClass } from './level-class';
|
|
17
|
+
import { kitLevelClassFor } from '../recipes/pipeline-runtime';
|
|
16
18
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
19
|
+
import { KIT_FOCUS_RING, kitSelectedRecipe } from '../recipes/state';
|
|
20
|
+
import { mergeClass } from '../shared/merge-class';
|
|
21
|
+
import {
|
|
22
|
+
KIT_ATTR_CHECK, KIT_ATTR_ICON_CACHE, KIT_ATTR_KEY, KIT_ATTR_LSIG, KIT_ATTR_NODE_ICON, KIT_ATTR_TOGGLE, KIT_ATTR_TREE_LABEL, KIT_ATTR_TREE_ROW, kitAttrSel,
|
|
23
|
+
} from '../shared/dom-attrs';
|
|
17
24
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
18
25
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
19
|
-
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
20
|
-
import { kitIcon } from '../
|
|
26
|
+
import { bool, createKitController, joinClass, reconcileKeyedElements, str } from '../base/shared';
|
|
27
|
+
import { KIT_ICON_NAMES, kitIcon, setKitIconCached, type KitIconName } from '../shared/icons';
|
|
21
28
|
import { markCheckBox } from '../base/check-core';
|
|
22
29
|
import { kitText } from '../i18n/kit-text';
|
|
23
30
|
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS, KIT_STATE_PANEL_CLASS_CANDIDATES, kitEmptyPanel } from '../base/state-panel';
|
|
@@ -28,6 +35,8 @@ import {
|
|
|
28
35
|
import { classTokens } from './shape-util';
|
|
29
36
|
import { provideCtxRows } from './context-menu';
|
|
30
37
|
import { aggregateCheck, nextCheckTarget } from './tree-check';
|
|
38
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked } from './kit-contract';
|
|
39
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
31
40
|
|
|
32
41
|
export interface KitTreeMap {
|
|
33
42
|
id: string;
|
|
@@ -43,21 +52,29 @@ export const KIT_TREE_DEFAULT_MAP: Readonly<KitTreeMap> = Object.freeze({
|
|
|
43
52
|
});
|
|
44
53
|
|
|
45
54
|
const ROOT_CLASS = 'flex flex-col gap-0.5 text-sm text-fg';
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
55
|
+
// 每级缩进 24(6 个间距单位;Ant indentSize 24 / TDesign 24 / Arco 约 22,取 24,2026-11-26 裁决)
|
|
56
|
+
const GROUP_CLASS = 'ms-6 flex flex-col gap-0.5';
|
|
57
|
+
const ITEM_CLASS = 'flex flex-col gap-0.5 rounded-item ' + KIT_FOCUS_RING.item;
|
|
58
|
+
const ROW_CLASS = 'flex cursor-pointer items-center gap-2 rounded-item px-2 py-1.5 text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press';
|
|
59
|
+
// 选中只走 kitSelectedRecipe(KT-HB-F);选中项也有悬停 / 按下:叠第三级 tonal 状态层(卡 Tree:选中 + 悬停走 tonal,不被一级悬停层盖住)
|
|
60
|
+
// 选中不改字重(VA3-R1:避免选中时字宽跳动):选中配方自带 font-medium,这里同族覆写回常态字重
|
|
61
|
+
const ROW_SELECTED_CLASS = mergeClass(mergeClass(mergeClass('flex cursor-pointer items-center gap-2 rounded-item px-2 py-1.5', kitSelectedRecipe()), 'transition-colors hover:bg-state-layer-tonal-hover active:bg-state-layer-tonal-press'), 'font-normal');
|
|
62
|
+
// 节点图标位(node.icon 写 kit 图标名)与标题:标题单行省略(flex-1 min-w-0 truncate),图标不收缩
|
|
63
|
+
const NODE_ICON_CLASS = 'inline-flex shrink-0 text-fg-muted';
|
|
64
|
+
const NODE_TEXT_CLASS = 'min-w-0 flex-1 truncate';
|
|
65
|
+
const ROW_DISABLED_CLASS = 'flex cursor-not-allowed items-center gap-2 rounded-item px-2 py-1.5 text-fg-disabled **:text-fg-disabled'; // KT-K0-4
|
|
51
66
|
const TOGGLE_CLASS = 'w-4 shrink-0 text-fg-subtle';
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
const
|
|
67
|
+
// 勾选框外圈 = 控件轮廓出口(KT-B1);尺寸走 KT-D5 固定几何(不随密度漂移)
|
|
68
|
+
const CHECK_EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
69
|
+
const CHECK_CLASS = `inline-flex h-check-md w-check-md shrink-0 items-center justify-center rounded-item ${CHECK_EDGE} bg-surface`;
|
|
70
|
+
const CHECK_ON_CLASS = 'inline-flex h-check-md w-check-md shrink-0 items-center justify-center rounded-item border border-primary bg-primary text-primary-fg';
|
|
71
|
+
const HIT_CLASS = 'rounded-item bg-warning-soft px-0.5 text-warning-on-soft';
|
|
55
72
|
const EMPTY_CLASS = 'px-2 py-3 text-sm text-fg-muted';
|
|
56
73
|
|
|
57
74
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
58
|
-
/** virtual 下的扁平缩进(每层
|
|
75
|
+
/** virtual 下的扁平缩进(每层 6 个间距单位 = 24,最多 11 层,更深的层保持同一缩进):整串字面量,不拼接 */
|
|
59
76
|
const FLAT_INDENT: readonly string[] = [
|
|
60
|
-
'ms-0', 'ms-
|
|
77
|
+
'ms-0', 'ms-6', 'ms-12', 'ms-18', 'ms-24', 'ms-30', 'ms-36', 'ms-42', 'ms-48', 'ms-54', 'ms-60', 'ms-66',
|
|
61
78
|
];
|
|
62
79
|
const FLAT_ROW_FILL = 'h-full';
|
|
63
80
|
/** virtual 的根:列与列之间不留 gap(行距算进固定行高,估算才准) */
|
|
@@ -65,7 +82,7 @@ const VIRTUAL_ROOT_CLASS = 'flex flex-col text-sm text-fg';
|
|
|
65
82
|
|
|
66
83
|
export const KIT_TREE_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
67
84
|
...FLAT_INDENT, FLAT_ROW_FILL, VIRTUAL_ROOT_CLASS, KIT_VIRTUAL_VIEWPORT_BASE, ...Object.values(KIT_VIRTUAL_VIEWPORT_CLASS), ...KIT_VIRTUAL_CLASS_CANDIDATES,
|
|
68
|
-
ROOT_CLASS, GROUP_CLASS, ITEM_CLASS, ROW_CLASS, ROW_SELECTED_CLASS, ROW_DISABLED_CLASS, TOGGLE_CLASS, CHECK_CLASS, CHECK_ON_CLASS, HIT_CLASS, EMPTY_CLASS,
|
|
85
|
+
ROOT_CLASS, GROUP_CLASS, ITEM_CLASS, ROW_CLASS, ROW_SELECTED_CLASS, ROW_DISABLED_CLASS, NODE_ICON_CLASS, NODE_TEXT_CLASS, TOGGLE_CLASS, CHECK_CLASS, CHECK_ON_CLASS, HIT_CLASS, EMPTY_CLASS,
|
|
69
86
|
'py-1', KIT_STATE_PANEL_CLASS_CANDIDATES,
|
|
70
87
|
);
|
|
71
88
|
|
|
@@ -92,6 +109,8 @@ interface FlatNode {
|
|
|
92
109
|
/** 待加载(lazy 下才有意义):标了 has_children 而没有子项 */
|
|
93
110
|
pending: boolean;
|
|
94
111
|
disabled: boolean;
|
|
112
|
+
/** 节点图标(kit 图标名,数据里的 icon 键;不是图标名则不画) */
|
|
113
|
+
icon: string;
|
|
95
114
|
/** 先序下标(勾选状态数组的下标) */
|
|
96
115
|
index: number;
|
|
97
116
|
}
|
|
@@ -136,6 +155,7 @@ export function buildTreeNodes(data: unknown, mapIn: Pick<KitTreeMap, 'id' | 'la
|
|
|
136
155
|
children: [],
|
|
137
156
|
pending: false,
|
|
138
157
|
disabled: rec[map.disabled] === true || rec[map.disabled] === 'true',
|
|
158
|
+
icon: typeof rec.icon === 'string' && (KIT_ICON_NAMES as readonly string[]).includes(rec.icon) ? rec.icon : '',
|
|
139
159
|
index: counter,
|
|
140
160
|
};
|
|
141
161
|
counter += 1;
|
|
@@ -199,7 +219,7 @@ export function createTree(): SomaComponentDefinition {
|
|
|
199
219
|
name: 'Tree',
|
|
200
220
|
layer: 'data',
|
|
201
221
|
props: {
|
|
202
|
-
data: { type: 'array', default: [], desc: '树数据 [{ id, label, children?, has_children?, disabled? }]' },
|
|
222
|
+
data: { type: 'array', default: [], desc: '树数据 [{ id, label, icon?, children?, has_children?, disabled? }];icon 写 kit 图标名,画在标题前;标题单行省略' },
|
|
203
223
|
map: { type: 'object', default: {}, desc: '键名对照 { id, label, children, has_children, disabled }:组件期望的键 -> 数据里的键' },
|
|
204
224
|
selected: { type: 'string', default: '', desc: '当前选中项的 id' },
|
|
205
225
|
expand_all: { type: 'boolean', default: false, desc: '初始全部展开' },
|
|
@@ -295,7 +315,7 @@ export function createTree(): SomaComponentDefinition {
|
|
|
295
315
|
|
|
296
316
|
const focusCursor = (): void => {
|
|
297
317
|
if (!root || cursor === null) return;
|
|
298
|
-
const el = root.querySelector<HTMLElement>(`[
|
|
318
|
+
const el = root.querySelector<HTMLElement>(`[${KIT_ATTR_KEY}="${cssEscape(cursor)}"]`);
|
|
299
319
|
el?.focus();
|
|
300
320
|
};
|
|
301
321
|
|
|
@@ -434,24 +454,35 @@ export function createTree(): SomaComponentDefinition {
|
|
|
434
454
|
};
|
|
435
455
|
|
|
436
456
|
const labelNodes = (text: string, hit: boolean, keyword: string): Array<Node> => {
|
|
437
|
-
if (!hit) return [document.createTextNode(text)];
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
457
|
+
if (!hit || keyword === '') return [document.createTextNode(text)];
|
|
458
|
+
const lower = text.toLowerCase();
|
|
459
|
+
const out: Node[] = [];
|
|
460
|
+
let pos = 0;
|
|
461
|
+
for (;;) {
|
|
462
|
+
const at = lower.indexOf(keyword, pos);
|
|
463
|
+
if (at < 0) break;
|
|
464
|
+
if (at > pos) out.push(document.createTextNode(text.slice(pos, at)));
|
|
465
|
+
const mark = document.createElement('span');
|
|
466
|
+
mark.className = HIT_CLASS;
|
|
467
|
+
mark.textContent = text.slice(at, at + keyword.length);
|
|
468
|
+
out.push(mark);
|
|
469
|
+
pos = at + keyword.length;
|
|
470
|
+
}
|
|
471
|
+
if (out.length === 0) return [document.createTextNode(text)];
|
|
472
|
+
if (pos < text.length) out.push(document.createTextNode(text.slice(pos)));
|
|
473
|
+
return out;
|
|
444
474
|
};
|
|
445
475
|
|
|
446
|
-
const
|
|
476
|
+
const updateNodeDom = (
|
|
477
|
+
li: HTMLElement,
|
|
447
478
|
n: FlatNode,
|
|
448
479
|
tabbable: string | null,
|
|
449
480
|
flt: ReturnType<typeof filterTreeNodes>,
|
|
450
481
|
keyword: string,
|
|
451
482
|
box: boolean,
|
|
483
|
+
showToggleSlot: boolean,
|
|
452
484
|
flat?: { indent: string; liClass: string; total: number; pos: number },
|
|
453
|
-
):
|
|
454
|
-
const li = document.createElement('li');
|
|
485
|
+
): void => {
|
|
455
486
|
const branch = n.children.length > 0;
|
|
456
487
|
const lazyNode = bool(P().lazy) && n.pending;
|
|
457
488
|
const isOpen = (branch || lazyNode) && (open.has(n.key) || (branch && flt?.forced.has(n.key) === true));
|
|
@@ -459,64 +490,142 @@ export function createTree(): SomaComponentDefinition {
|
|
|
459
490
|
li.setAttribute('aria-level', String(n.level));
|
|
460
491
|
li.setAttribute('aria-selected', n.key === selected ? 'true' : 'false');
|
|
461
492
|
if (branch || lazyNode) li.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
|
|
493
|
+
else li.removeAttribute('aria-expanded');
|
|
462
494
|
if (loading.has(n.key)) li.setAttribute('aria-busy', 'true');
|
|
495
|
+
else li.removeAttribute('aria-busy');
|
|
463
496
|
if (n.disabled) li.setAttribute('aria-disabled', 'true');
|
|
497
|
+
else li.removeAttribute('aria-disabled');
|
|
464
498
|
if (box) {
|
|
465
499
|
const s = st[n.index] ?? 0;
|
|
466
500
|
li.setAttribute('aria-checked', s === 1 ? 'true' : s === 2 ? 'mixed' : 'false');
|
|
501
|
+
} else {
|
|
502
|
+
li.removeAttribute('aria-checked');
|
|
467
503
|
}
|
|
468
|
-
li.setAttribute(
|
|
504
|
+
li.setAttribute(KIT_ATTR_KEY, n.key);
|
|
505
|
+
// 树节点 = 集合的条目;选中节点自报交互状态(aria-selected 上面已按 treeitem 写好,这里不重复)
|
|
506
|
+
kitMarkLevel(li, 'item');
|
|
507
|
+
kitMarkPicked(li, 'selected', n.key === selected, null);
|
|
469
508
|
li.tabIndex = n.key === tabbable ? 0 : -1;
|
|
470
509
|
const rowCls = n.disabled ? ROW_DISABLED_CLASS : n.key === selected ? ROW_SELECTED_CLASS : ROW_CLASS;
|
|
471
|
-
|
|
510
|
+
let row = li.querySelector<HTMLElement>(`:scope > ${kitAttrSel(KIT_ATTR_TREE_ROW)}`);
|
|
511
|
+
if (!row) {
|
|
512
|
+
row = document.createElement('div');
|
|
513
|
+
row.setAttribute(KIT_ATTR_TREE_ROW, '');
|
|
514
|
+
// 节点的可见行:元素部件「行」
|
|
515
|
+
kitMarkPart(row, 'line');
|
|
516
|
+
li.prepend(row);
|
|
517
|
+
}
|
|
472
518
|
if (flat) {
|
|
473
|
-
|
|
474
|
-
li.className = `${ITEM_CLASS} ${flat.liClass}`;
|
|
519
|
+
li.className = kitLevelClassFor(li, `${ITEM_CLASS} ${flat.liClass}`);
|
|
475
520
|
li.setAttribute('aria-setsize', String(flat.total));
|
|
476
521
|
li.setAttribute('aria-posinset', String(flat.pos));
|
|
477
522
|
row.className = `${withoutPy(rowCls)} ${FLAT_ROW_FILL} ${flat.indent}`;
|
|
478
523
|
} else {
|
|
479
|
-
li.className = ITEM_CLASS;
|
|
524
|
+
li.className = kitLevelClassFor(li, ITEM_CLASS);
|
|
525
|
+
li.removeAttribute('aria-setsize');
|
|
526
|
+
li.removeAttribute('aria-posinset');
|
|
480
527
|
row.className = rowCls;
|
|
481
528
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
529
|
+
let toggle = row.querySelector<HTMLElement>(`:scope > ${kitAttrSel(KIT_ATTR_TOGGLE)}`);
|
|
530
|
+
if (showToggleSlot) {
|
|
531
|
+
if (!toggle) {
|
|
532
|
+
toggle = document.createElement('span');
|
|
533
|
+
toggle.className = TOGGLE_CLASS;
|
|
534
|
+
toggle.setAttribute('aria-hidden', 'true');
|
|
535
|
+
toggle.setAttribute(KIT_ATTR_TOGGLE, '');
|
|
536
|
+
row.prepend(toggle);
|
|
537
|
+
}
|
|
538
|
+
if (loading.has(n.key)) setKitIconCached(toggle, 'loading', 'sm');
|
|
539
|
+
else if (branch || lazyNode) setKitIconCached(toggle, isOpen ? 'chevron-down' : 'chevron-right', 'sm', 'rtl:-scale-x-100');
|
|
540
|
+
else { toggle.removeAttribute(KIT_ATTR_ICON_CACHE); toggle.textContent = ''; }
|
|
541
|
+
} else if (toggle) {
|
|
542
|
+
toggle.remove();
|
|
543
|
+
}
|
|
544
|
+
let cb = row.querySelector<HTMLElement>(`:scope > ${kitAttrSel(KIT_ATTR_CHECK)}`);
|
|
489
545
|
if (box) {
|
|
490
546
|
const s = st[n.index] ?? 0;
|
|
491
|
-
|
|
547
|
+
if (!cb) {
|
|
548
|
+
cb = document.createElement('span');
|
|
549
|
+
cb.setAttribute('aria-hidden', 'true');
|
|
550
|
+
markCheckBox(cb);
|
|
551
|
+
cb.setAttribute(KIT_ATTR_CHECK, '');
|
|
552
|
+
const afterToggle = row.querySelector(`:scope > ${kitAttrSel(KIT_ATTR_TOGGLE)}`);
|
|
553
|
+
if (afterToggle) afterToggle.after(cb);
|
|
554
|
+
else row.prepend(cb);
|
|
555
|
+
}
|
|
492
556
|
cb.className = s === 0 ? CHECK_CLASS : CHECK_ON_CLASS;
|
|
493
|
-
cb
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
557
|
+
if (s !== 0) setKitIconCached(cb, s === 1 ? 'check' : 'minus', 'xs');
|
|
558
|
+
else { cb.removeAttribute(KIT_ATTR_ICON_CACHE); cb.textContent = ''; }
|
|
559
|
+
} else if (cb) {
|
|
560
|
+
cb.remove();
|
|
561
|
+
}
|
|
562
|
+
let ico = row.querySelector<HTMLElement>(`:scope > ${kitAttrSel(KIT_ATTR_NODE_ICON)}`);
|
|
563
|
+
if (n.icon !== '') {
|
|
564
|
+
if (!ico) {
|
|
565
|
+
ico = document.createElement('span');
|
|
566
|
+
ico.className = NODE_ICON_CLASS;
|
|
567
|
+
ico.setAttribute('aria-hidden', 'true');
|
|
568
|
+
ico.setAttribute(KIT_ATTR_NODE_ICON, '');
|
|
569
|
+
const labelRef = row.querySelector(`:scope > ${kitAttrSel(KIT_ATTR_TREE_LABEL)}`);
|
|
570
|
+
if (labelRef) row.insertBefore(ico, labelRef);
|
|
571
|
+
else row.appendChild(ico);
|
|
572
|
+
}
|
|
573
|
+
setKitIconCached(ico, n.icon as KitIconName, 'md');
|
|
574
|
+
} else if (ico) {
|
|
575
|
+
ico.remove();
|
|
576
|
+
}
|
|
577
|
+
let label = row.querySelector<HTMLElement>(`:scope > ${kitAttrSel(KIT_ATTR_TREE_LABEL)}`);
|
|
578
|
+
if (!label) {
|
|
579
|
+
label = document.createElement('span');
|
|
580
|
+
label.className = NODE_TEXT_CLASS;
|
|
581
|
+
label.setAttribute(KIT_ATTR_TREE_LABEL, '');
|
|
582
|
+
row.appendChild(label);
|
|
498
583
|
}
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
584
|
+
const hit = flt?.hits.has(n.key) === true;
|
|
585
|
+
const labelSig = `${n.label}\0${hit ? keyword : ''}`;
|
|
586
|
+
if (label.getAttribute(KIT_ATTR_LSIG) !== labelSig) {
|
|
587
|
+
label.setAttribute(KIT_ATTR_LSIG, labelSig);
|
|
588
|
+
label.replaceChildren(...labelNodes(n.label, hit, keyword));
|
|
589
|
+
}
|
|
590
|
+
let group = li.querySelector<HTMLElement>(':scope > ul[role="group"]');
|
|
503
591
|
if (isOpen && branch && !flat) {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
group.appendChild(buildNode(child, tabbable, flt, keyword, box));
|
|
592
|
+
if (!group) {
|
|
593
|
+
group = document.createElement('ul');
|
|
594
|
+
group.setAttribute('role', 'group');
|
|
595
|
+
group.className = GROUP_CLASS;
|
|
596
|
+
li.appendChild(group);
|
|
510
597
|
}
|
|
511
|
-
|
|
598
|
+
const visibleChildren = flt === null ? n.children : n.children.filter((c) => flt.visible.has(c.key));
|
|
599
|
+
reconcileKeyedElements(
|
|
600
|
+
group,
|
|
601
|
+
visibleChildren,
|
|
602
|
+
(c) => c.key,
|
|
603
|
+
() => document.createElement('li'),
|
|
604
|
+
(childLi, c) => updateNodeDom(childLi, c, tabbable, flt, keyword, box, showToggleSlot),
|
|
605
|
+
);
|
|
606
|
+
} else if (group) {
|
|
607
|
+
group.remove();
|
|
512
608
|
}
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
const buildNode = (
|
|
612
|
+
n: FlatNode,
|
|
613
|
+
tabbable: string | null,
|
|
614
|
+
flt: ReturnType<typeof filterTreeNodes>,
|
|
615
|
+
keyword: string,
|
|
616
|
+
box: boolean,
|
|
617
|
+
showToggleSlot: boolean,
|
|
618
|
+
flat?: { indent: string; liClass: string; total: number; pos: number },
|
|
619
|
+
): HTMLElement => {
|
|
620
|
+
const li = document.createElement('li');
|
|
621
|
+
updateNodeDom(li, n, tabbable, flt, keyword, box, showToggleSlot, flat);
|
|
513
622
|
return li;
|
|
514
623
|
};
|
|
515
624
|
|
|
516
625
|
/** 虚拟滚动画法:可见节点拍平成一列,只画窗口内的行;游标变了才滚到游标行,游标行不在窗口时焦点退到根 */
|
|
517
626
|
const paintVirtual = (
|
|
518
627
|
p: Record<string, unknown>, flt: ReturnType<typeof filterTreeNodes>, keyword: string, visible: readonly FlatNode[],
|
|
519
|
-
tabbable: string | null, box: boolean, hadFocus: boolean,
|
|
628
|
+
tabbable: string | null, box: boolean, showToggleSlot: boolean, hadFocus: boolean,
|
|
520
629
|
): void => {
|
|
521
630
|
const r = root;
|
|
522
631
|
if (!r) return;
|
|
@@ -543,13 +652,13 @@ export function createTree(): SomaComponentDefinition {
|
|
|
543
652
|
const liClass = KIT_VIRTUAL_OPTION_ROW_CLASS[tier];
|
|
544
653
|
const painted = paintVirtualRows(r, virt, visible.length, (i) => {
|
|
545
654
|
const n = visible[i]!;
|
|
546
|
-
return buildNode(n, tabbable, flt, keyword, box, {
|
|
655
|
+
return buildNode(n, tabbable, flt, keyword, box, showToggleSlot, {
|
|
547
656
|
indent: FLAT_INDENT[Math.min(n.level - 1, FLAT_INDENT.length - 1)]!, liClass, total: visible.length, pos: i + 1,
|
|
548
657
|
});
|
|
549
658
|
}, 'li');
|
|
550
659
|
const keyEl = (key: string | null): HTMLElement | null => {
|
|
551
660
|
if (key === null) return null;
|
|
552
|
-
for (const el of painted.rows.values()) if (el.getAttribute(
|
|
661
|
+
for (const el of painted.rows.values()) if (el.getAttribute(KIT_ATTR_KEY) === key) return el;
|
|
553
662
|
return null;
|
|
554
663
|
};
|
|
555
664
|
r.tabIndex = keyEl(tabbable) === null ? 0 : -1;
|
|
@@ -566,6 +675,12 @@ export function createTree(): SomaComponentDefinition {
|
|
|
566
675
|
function paint(): void {
|
|
567
676
|
if (!root) return;
|
|
568
677
|
const p = P();
|
|
678
|
+
// 数据状态自报:与 applyKitReadState 读同两个入参(loading / error_text),外加有没有节点;每次重画都写,回常态即移除
|
|
679
|
+
kitMarkDataFacts(root, {
|
|
680
|
+
loading: p.loading === true || p.loading === 'true',
|
|
681
|
+
error: str(p.error_text) !== '',
|
|
682
|
+
empty: nodes.length === 0,
|
|
683
|
+
});
|
|
569
684
|
// 没有节点:读取中 / 读取失败 + 重试 / 空态,与集合三态同一画法(base/state-panel.ts;有读接口时编译器自动绑 loading / error_text)
|
|
570
685
|
if (nodes.length === 0) {
|
|
571
686
|
if (virt !== null) root.tabIndex = -1;
|
|
@@ -574,38 +689,47 @@ export function createTree(): SomaComponentDefinition {
|
|
|
574
689
|
root.removeAttribute('aria-multiselectable');
|
|
575
690
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
576
691
|
if (!applyKitReadState(root, p, { hasContent: false, onRetry: () => api.emit('retry', {}), repaint: () => api.refresh() })) {
|
|
577
|
-
|
|
692
|
+
const emptyPanel = kitEmptyPanel(document, str(p.empty_text, kitText('soma.kit.empty', undefined, api.host)));
|
|
693
|
+
// 空状态块 = 子块(不经 shape-util.emptyNode,在此单独自报)
|
|
694
|
+
kitMarkLevel(emptyPanel, 'sub'); kitApplyLevelClass(emptyPanel);
|
|
695
|
+
root.appendChild(emptyPanel);
|
|
578
696
|
}
|
|
579
697
|
return;
|
|
580
698
|
}
|
|
581
699
|
const flt = filterOf();
|
|
582
700
|
const keyword = str(p.filter).trim().toLowerCase();
|
|
583
701
|
const visible = visibleOf(nodes, open, flt);
|
|
702
|
+
// 纯平级无任何带子节点(或待懒加载)的叶子列表,省去左侧 24px 空白展开槽
|
|
703
|
+
const showToggleSlot = order.some((n) => expandable(n));
|
|
584
704
|
// 漫游 tabindex:游标项,没有游标时落首个可见项
|
|
585
705
|
const tabbable = cursor !== null && visible.some((n) => n.key === cursor) ? cursor : (visible[0]?.key ?? null);
|
|
586
706
|
const hadFocus = root.contains(document.activeElement);
|
|
587
707
|
const box = checkable();
|
|
588
708
|
if (bool(p.virtual) && !(flt !== null && visible.length === 0)) {
|
|
589
|
-
paintVirtual(p, flt, keyword, visible, tabbable, box, hadFocus);
|
|
709
|
+
paintVirtual(p, flt, keyword, visible, tabbable, box, showToggleSlot, hadFocus);
|
|
590
710
|
return;
|
|
591
711
|
}
|
|
592
712
|
if (virt !== null) root.tabIndex = -1;
|
|
593
713
|
disposeVirt();
|
|
594
|
-
root.textContent = '';
|
|
595
714
|
if (box) root.setAttribute('aria-multiselectable', 'true'); else root.removeAttribute('aria-multiselectable');
|
|
596
715
|
// 已有内容时的读状态:重取中根 aria-busy(内容保留);读取失败不往 role=tree 里塞面板(树结构不被破坏)
|
|
597
716
|
if (p.loading === true || p.loading === 'true') root.setAttribute('aria-busy', 'true'); else root.removeAttribute('aria-busy');
|
|
598
717
|
if (flt !== null && visible.length === 0) {
|
|
718
|
+
root.textContent = '';
|
|
599
719
|
const empty = document.createElement('li');
|
|
600
720
|
empty.setAttribute('role', 'none');
|
|
601
721
|
empty.className = EMPTY_CLASS;
|
|
602
722
|
empty.textContent = str(p.filter_empty_text, kitText('soma.kit.empty_node', undefined, api.host));
|
|
603
723
|
root.appendChild(empty);
|
|
604
724
|
} else {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
root
|
|
608
|
-
|
|
725
|
+
const topVisible = flt === null ? nodes : nodes.filter((n) => flt.visible.has(n.key));
|
|
726
|
+
reconcileKeyedElements(
|
|
727
|
+
root,
|
|
728
|
+
topVisible,
|
|
729
|
+
(n) => n.key,
|
|
730
|
+
() => document.createElement('li'),
|
|
731
|
+
(li, n) => updateNodeDom(li, n, tabbable, flt, keyword, box, showToggleSlot),
|
|
732
|
+
);
|
|
609
733
|
}
|
|
610
734
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
611
735
|
if (hadFocus) focusCursor();
|
|
@@ -616,14 +740,14 @@ export function createTree(): SomaComponentDefinition {
|
|
|
616
740
|
root = rootEl;
|
|
617
741
|
const onClick = (event: Event): void => {
|
|
618
742
|
const target = event.target as HTMLElement | null;
|
|
619
|
-
const li = target?.closest<HTMLElement>(
|
|
620
|
-
const key = li?.getAttribute(
|
|
743
|
+
const li = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY));
|
|
744
|
+
const key = li?.getAttribute(KIT_ATTR_KEY);
|
|
621
745
|
if (!li || !key) return;
|
|
622
|
-
if (target?.closest(
|
|
746
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_TOGGLE))) {
|
|
623
747
|
setOpen(key, !open.has(key));
|
|
624
748
|
return;
|
|
625
749
|
}
|
|
626
|
-
if (target?.closest(
|
|
750
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_CHECK))) {
|
|
627
751
|
cursor = key;
|
|
628
752
|
toggleCheck(key);
|
|
629
753
|
return;
|
|
@@ -634,7 +758,7 @@ export function createTree(): SomaComponentDefinition {
|
|
|
634
758
|
};
|
|
635
759
|
const onKeydown = (event: KeyboardEvent): void => {
|
|
636
760
|
if (cursor === null) {
|
|
637
|
-
const first = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
761
|
+
const first = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY))?.getAttribute(KIT_ATTR_KEY);
|
|
638
762
|
if (first) cursor = first;
|
|
639
763
|
}
|
|
640
764
|
if (wiring.onKeydown(event)) event.preventDefault();
|
package/src/data/trend-line.ts
CHANGED
|
@@ -7,25 +7,40 @@
|
|
|
7
7
|
// 同一份折线也被 StatGroup 的 `spark` 项复用(`sparklineSvg`)。
|
|
8
8
|
|
|
9
9
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
10
|
-
import {
|
|
10
|
+
import { kitMarkDataFacts } from './kit-contract';
|
|
11
|
+
import { KIT_DATA_LIMITS } from 'soma-foundation/kit-limits';
|
|
12
|
+
import { bool, createKitController, formatValue, joinClass, type KitProps, nextUid, num, str } from '../base/shared';
|
|
13
|
+
import { KIT_TIP_ATTR } from '../base/hint-tips';
|
|
14
|
+
import { releaseReasonTipsIn } from '../base/reason-tip';
|
|
15
|
+
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
|
|
16
|
+
import { kitWellRecipe } from '../recipes/surface';
|
|
17
|
+
import { mergeClass } from '../shared/merge-class';
|
|
18
|
+
import { KIT_ATTR_SKELETON } from '../shared/dom-attrs';
|
|
11
19
|
import { classTokens, mk, rowsOf, textOf } from './shape-util';
|
|
12
20
|
import { SPARKLINE_MAX_POINTS } from './d9-limits';
|
|
21
|
+
import { plainNumber } from './summary-util';
|
|
13
22
|
|
|
14
23
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
15
24
|
const ROOT_CLASS = 'block h-8 w-full';
|
|
16
25
|
const EMPTY_CLASS = 'text-xs text-fg-subtle';
|
|
26
|
+
const SKELETON_CLASS = mergeClass(mergeClass('block h-full w-full rounded-item', kitWellRecipe()), 'motion-safe:animate-kit-pulse');
|
|
27
|
+
const AREA_TOP_OPACITY = KIT_DATA_LIMITS.chart.style.areaTopOpacity;
|
|
28
|
+
const AREA_BOTTOM_OPACITY = KIT_DATA_LIMITS.chart.style.areaBottomOpacity;
|
|
17
29
|
|
|
18
30
|
export type KitTrendTone = 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'neutral';
|
|
19
31
|
const STROKE: Readonly<Record<KitTrendTone, string>> = Object.freeze({
|
|
20
32
|
primary: 'stroke-primary', success: 'stroke-success', warning: 'stroke-warning', danger: 'stroke-danger', info: 'stroke-info', neutral: 'stroke-fg-muted',
|
|
21
33
|
});
|
|
22
34
|
const FILL: Readonly<Record<KitTrendTone, string>> = Object.freeze({
|
|
23
|
-
primary: 'fill-primary-soft', success: 'fill-success-soft', warning: 'fill-warning-soft', danger: 'fill-danger-soft', info: 'fill-info-soft', neutral: 'fill
|
|
35
|
+
primary: 'fill-primary-soft', success: 'fill-success-soft', warning: 'fill-warning-soft', danger: 'fill-danger-soft', info: 'fill-info-soft', neutral: kitWellRecipe({ paint: 'fill' }),
|
|
36
|
+
});
|
|
37
|
+
const TEXT_TONE: Readonly<Record<KitTrendTone, string>> = Object.freeze({
|
|
38
|
+
primary: 'text-primary', success: 'text-success', warning: 'text-warning', danger: 'text-danger', info: 'text-info', neutral: 'text-fg-muted',
|
|
24
39
|
});
|
|
25
40
|
const LINE_CLASS = 'fill-none stroke-2';
|
|
26
41
|
|
|
27
42
|
export const KIT_TREND_LINE_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
28
|
-
ROOT_CLASS, EMPTY_CLASS, Object.values(STROKE), Object.values(FILL), LINE_CLASS, 'size-full',
|
|
43
|
+
ROOT_CLASS, EMPTY_CLASS, SKELETON_CLASS, Object.values(STROKE), Object.values(FILL), Object.values(TEXT_TONE), LINE_CLASS, 'size-full',
|
|
29
44
|
);
|
|
30
45
|
|
|
31
46
|
const TONES = Object.keys(STROKE) as KitTrendTone[];
|
|
@@ -64,7 +79,10 @@ export function trendPoints(values: readonly number[]): Array<[number, number]>
|
|
|
64
79
|
}
|
|
65
80
|
|
|
66
81
|
/** 画一条迷你折线的 SVG 节点(TrendLine 与 StatGroup 共用);点数不足 2 返回 null */
|
|
67
|
-
export function sparklineSvg(
|
|
82
|
+
export function sparklineSvg(
|
|
83
|
+
values: readonly number[],
|
|
84
|
+
opts: { tone?: KitTrendTone; area?: boolean; label?: string; className?: string; format?: string; locale?: string } = {},
|
|
85
|
+
): SVGSVGElement | null {
|
|
68
86
|
if (values.length < 2) return null;
|
|
69
87
|
const tone = opts.tone ?? 'primary';
|
|
70
88
|
const pts = trendPoints(values);
|
|
@@ -72,15 +90,39 @@ export function sparklineSvg(values: readonly number[], opts: { tone?: KitTrendT
|
|
|
72
90
|
svg.setAttribute('viewBox', '0 0 100 32');
|
|
73
91
|
svg.setAttribute('preserveAspectRatio', 'none');
|
|
74
92
|
svg.setAttribute('role', 'img');
|
|
75
|
-
svg.setAttribute('class', opts.className ?? ROOT_CLASS);
|
|
93
|
+
svg.setAttribute('class', `${opts.className ?? ROOT_CLASS} ${TEXT_TONE[tone]}`);
|
|
76
94
|
const min = Math.min(...values);
|
|
77
95
|
const max = Math.max(...values);
|
|
78
|
-
|
|
96
|
+
const fmt = opts.format ?? '';
|
|
97
|
+
const loc = opts.locale ?? '';
|
|
98
|
+
const show = (n: number): string => (fmt !== '' ? formatValue(n, fmt, loc) : formatValue(n, 'number', loc) || plainNumber(n));
|
|
99
|
+
const summary = `${opts.label ?? ''} ${show(values[values.length - 1]!)} (${show(min)} - ${show(max)})`.trim();
|
|
100
|
+
svg.setAttribute('aria-label', summary);
|
|
101
|
+
svg.setAttribute(KIT_TIP_ATTR, summary);
|
|
79
102
|
const d = pts.map(([x, y], i) => `${i === 0 ? 'M' : 'L'}${x} ${y}`).join(' ');
|
|
80
103
|
if (opts.area === true) {
|
|
104
|
+
const gradId = nextUid('kit-trend-grad');
|
|
105
|
+
const defs = document.createElementNS(SVG_NS, 'defs');
|
|
106
|
+
const grad = document.createElementNS(SVG_NS, 'linearGradient');
|
|
107
|
+
grad.setAttribute('id', gradId);
|
|
108
|
+
grad.setAttribute('x1', '0');
|
|
109
|
+
grad.setAttribute('y1', '0');
|
|
110
|
+
grad.setAttribute('x2', '0');
|
|
111
|
+
grad.setAttribute('y2', '1');
|
|
112
|
+
const stopTop = document.createElementNS(SVG_NS, 'stop');
|
|
113
|
+
stopTop.setAttribute('offset', '0%');
|
|
114
|
+
stopTop.setAttribute('stop-color', 'currentColor');
|
|
115
|
+
stopTop.setAttribute('stop-opacity', String(AREA_TOP_OPACITY));
|
|
116
|
+
const stopBottom = document.createElementNS(SVG_NS, 'stop');
|
|
117
|
+
stopBottom.setAttribute('offset', '100%');
|
|
118
|
+
stopBottom.setAttribute('stop-color', 'currentColor');
|
|
119
|
+
stopBottom.setAttribute('stop-opacity', String(AREA_BOTTOM_OPACITY));
|
|
120
|
+
grad.append(stopTop, stopBottom);
|
|
121
|
+
defs.appendChild(grad);
|
|
122
|
+
svg.appendChild(defs);
|
|
81
123
|
const area = document.createElementNS(SVG_NS, 'path');
|
|
82
124
|
area.setAttribute('d', `${d} L100 32 L0 32 Z`);
|
|
83
|
-
area.setAttribute('
|
|
125
|
+
area.setAttribute('fill', `url(#${gradId})`);
|
|
84
126
|
svg.appendChild(area);
|
|
85
127
|
}
|
|
86
128
|
const line = document.createElementNS(SVG_NS, 'path');
|
|
@@ -103,26 +145,40 @@ export function createTrendLine(): SomaComponentDefinition {
|
|
|
103
145
|
y: { type: 'string', default: 'value', desc: '行数组的取值键' },
|
|
104
146
|
tone: { type: 'string', default: 'primary', desc: '线色:primary | success | warning | danger | info | neutral | auto(按首末涨跌)' },
|
|
105
147
|
up_is: { type: 'string', default: 'good', desc: 'auto 时上涨是好事(good)还是坏事(bad)' },
|
|
106
|
-
area: { type: 'boolean', default: false, desc: '
|
|
148
|
+
area: { type: 'boolean', default: false, desc: '折线下填浅色面(顶→底柔和透明度渐变)' },
|
|
149
|
+
format: { type: 'string', default: '', desc: '数值格式(soma-foundation/values 写法)' },
|
|
150
|
+
locale: { type: 'string', default: '', desc: '格式化语言' },
|
|
107
151
|
label: { type: 'string', default: '', desc: '无障碍名称前缀(如「近 7 日订单」)' },
|
|
108
|
-
empty_text: { type: 'string', default: '
|
|
152
|
+
empty_text: { type: 'string', default: '—', desc: '点数不足时的占位文案' },
|
|
153
|
+
...KIT_READ_STATE_PROP_DEFS,
|
|
109
154
|
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾(宽度 / 高度类在这里给)' },
|
|
110
155
|
},
|
|
111
|
-
emits: {},
|
|
156
|
+
emits: { ...KIT_READ_STATE_EMIT_DEFS },
|
|
112
157
|
},
|
|
113
158
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
114
|
-
controllerFactory: createKitController((
|
|
159
|
+
controllerFactory: createKitController((api) => ({
|
|
115
160
|
render(root: HTMLElement, p: KitProps): void {
|
|
116
161
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
162
|
+
releaseReasonTipsIn(root);
|
|
117
163
|
root.textContent = '';
|
|
118
164
|
const values = trendValuesOf(p.data, str(p.y, 'value'));
|
|
165
|
+
const skeleton = (): HTMLElement => {
|
|
166
|
+
const sk = mk('span', SKELETON_CLASS);
|
|
167
|
+
sk.setAttribute(KIT_ATTR_SKELETON, '');
|
|
168
|
+
return sk;
|
|
169
|
+
};
|
|
170
|
+
// 数据状态自报(每次渲染都写):与读状态面板同一判据,出错 > 加载 > 空;data-kit-state 面板标记照旧
|
|
171
|
+
kitMarkDataFacts(root, { error: str(p.error_text) !== '', loading: p.loading === true || p.loading === 'true', empty: !(values.length >= 2) });
|
|
172
|
+
if (applyKitReadState(root, p, { hasContent: values.length >= 2, onRetry: () => api.emit('retry', {}), repaint: () => api.refresh(), skeleton })) return;
|
|
119
173
|
const svg = sparklineSvg(values, {
|
|
120
174
|
tone: trendToneOf(textOf(p.tone), values, p.up_is === 'bad' ? 'bad' : 'good'),
|
|
121
175
|
area: bool(p.area),
|
|
122
176
|
label: str(p.label),
|
|
177
|
+
format: str(p.format),
|
|
178
|
+
locale: str(p.locale),
|
|
123
179
|
className: 'size-full',
|
|
124
180
|
});
|
|
125
|
-
if (svg) root.appendChild(svg); else root.appendChild(mk('span', EMPTY_CLASS, str(p.empty_text, '
|
|
181
|
+
if (svg) root.appendChild(svg); else root.appendChild(mk('span', EMPTY_CLASS, str(p.empty_text, '—')));
|
|
126
182
|
},
|
|
127
183
|
})),
|
|
128
184
|
};
|