soma-kit 0.1.15 → 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/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 +934 -92
- 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 +186 -57
- 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 +130 -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 +1015 -53
- 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 +424 -103
- 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
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 '../shared/icons';
|
|
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,7 @@ 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';
|
|
31
39
|
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
32
40
|
|
|
33
41
|
export interface KitTreeMap {
|
|
@@ -44,23 +52,29 @@ export const KIT_TREE_DEFAULT_MAP: Readonly<KitTreeMap> = Object.freeze({
|
|
|
44
52
|
});
|
|
45
53
|
|
|
46
54
|
const ROOT_CLASS = 'flex flex-col gap-0.5 text-sm text-fg';
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
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
|
|
52
66
|
const TOGGLE_CLASS = 'w-4 shrink-0 text-fg-subtle';
|
|
53
|
-
// 勾选框外圈 = 控件轮廓出口(KT-B1
|
|
67
|
+
// 勾选框外圈 = 控件轮廓出口(KT-B1);尺寸走 KT-D5 固定几何(不随密度漂移)
|
|
54
68
|
const CHECK_EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
55
|
-
const CHECK_CLASS = `inline-flex
|
|
56
|
-
const CHECK_ON_CLASS = 'inline-flex
|
|
57
|
-
const HIT_CLASS = 'rounded-
|
|
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';
|
|
58
72
|
const EMPTY_CLASS = 'px-2 py-3 text-sm text-fg-muted';
|
|
59
73
|
|
|
60
74
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
61
|
-
/** virtual 下的扁平缩进(每层
|
|
75
|
+
/** virtual 下的扁平缩进(每层 6 个间距单位 = 24,最多 11 层,更深的层保持同一缩进):整串字面量,不拼接 */
|
|
62
76
|
const FLAT_INDENT: readonly string[] = [
|
|
63
|
-
'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',
|
|
64
78
|
];
|
|
65
79
|
const FLAT_ROW_FILL = 'h-full';
|
|
66
80
|
/** virtual 的根:列与列之间不留 gap(行距算进固定行高,估算才准) */
|
|
@@ -68,7 +82,7 @@ const VIRTUAL_ROOT_CLASS = 'flex flex-col text-sm text-fg';
|
|
|
68
82
|
|
|
69
83
|
export const KIT_TREE_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
70
84
|
...FLAT_INDENT, FLAT_ROW_FILL, VIRTUAL_ROOT_CLASS, KIT_VIRTUAL_VIEWPORT_BASE, ...Object.values(KIT_VIRTUAL_VIEWPORT_CLASS), ...KIT_VIRTUAL_CLASS_CANDIDATES,
|
|
71
|
-
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,
|
|
72
86
|
'py-1', KIT_STATE_PANEL_CLASS_CANDIDATES,
|
|
73
87
|
);
|
|
74
88
|
|
|
@@ -95,6 +109,8 @@ interface FlatNode {
|
|
|
95
109
|
/** 待加载(lazy 下才有意义):标了 has_children 而没有子项 */
|
|
96
110
|
pending: boolean;
|
|
97
111
|
disabled: boolean;
|
|
112
|
+
/** 节点图标(kit 图标名,数据里的 icon 键;不是图标名则不画) */
|
|
113
|
+
icon: string;
|
|
98
114
|
/** 先序下标(勾选状态数组的下标) */
|
|
99
115
|
index: number;
|
|
100
116
|
}
|
|
@@ -139,6 +155,7 @@ export function buildTreeNodes(data: unknown, mapIn: Pick<KitTreeMap, 'id' | 'la
|
|
|
139
155
|
children: [],
|
|
140
156
|
pending: false,
|
|
141
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 : '',
|
|
142
159
|
index: counter,
|
|
143
160
|
};
|
|
144
161
|
counter += 1;
|
|
@@ -202,7 +219,7 @@ export function createTree(): SomaComponentDefinition {
|
|
|
202
219
|
name: 'Tree',
|
|
203
220
|
layer: 'data',
|
|
204
221
|
props: {
|
|
205
|
-
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 图标名,画在标题前;标题单行省略' },
|
|
206
223
|
map: { type: 'object', default: {}, desc: '键名对照 { id, label, children, has_children, disabled }:组件期望的键 -> 数据里的键' },
|
|
207
224
|
selected: { type: 'string', default: '', desc: '当前选中项的 id' },
|
|
208
225
|
expand_all: { type: 'boolean', default: false, desc: '初始全部展开' },
|
|
@@ -298,7 +315,7 @@ export function createTree(): SomaComponentDefinition {
|
|
|
298
315
|
|
|
299
316
|
const focusCursor = (): void => {
|
|
300
317
|
if (!root || cursor === null) return;
|
|
301
|
-
const el = root.querySelector<HTMLElement>(`[
|
|
318
|
+
const el = root.querySelector<HTMLElement>(`[${KIT_ATTR_KEY}="${cssEscape(cursor)}"]`);
|
|
302
319
|
el?.focus();
|
|
303
320
|
};
|
|
304
321
|
|
|
@@ -437,24 +454,35 @@ export function createTree(): SomaComponentDefinition {
|
|
|
437
454
|
};
|
|
438
455
|
|
|
439
456
|
const labelNodes = (text: string, hit: boolean, keyword: string): Array<Node> => {
|
|
440
|
-
if (!hit) return [document.createTextNode(text)];
|
|
441
|
-
const
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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;
|
|
447
474
|
};
|
|
448
475
|
|
|
449
|
-
const
|
|
476
|
+
const updateNodeDom = (
|
|
477
|
+
li: HTMLElement,
|
|
450
478
|
n: FlatNode,
|
|
451
479
|
tabbable: string | null,
|
|
452
480
|
flt: ReturnType<typeof filterTreeNodes>,
|
|
453
481
|
keyword: string,
|
|
454
482
|
box: boolean,
|
|
483
|
+
showToggleSlot: boolean,
|
|
455
484
|
flat?: { indent: string; liClass: string; total: number; pos: number },
|
|
456
|
-
):
|
|
457
|
-
const li = document.createElement('li');
|
|
485
|
+
): void => {
|
|
458
486
|
const branch = n.children.length > 0;
|
|
459
487
|
const lazyNode = bool(P().lazy) && n.pending;
|
|
460
488
|
const isOpen = (branch || lazyNode) && (open.has(n.key) || (branch && flt?.forced.has(n.key) === true));
|
|
@@ -462,64 +490,142 @@ export function createTree(): SomaComponentDefinition {
|
|
|
462
490
|
li.setAttribute('aria-level', String(n.level));
|
|
463
491
|
li.setAttribute('aria-selected', n.key === selected ? 'true' : 'false');
|
|
464
492
|
if (branch || lazyNode) li.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
|
|
493
|
+
else li.removeAttribute('aria-expanded');
|
|
465
494
|
if (loading.has(n.key)) li.setAttribute('aria-busy', 'true');
|
|
495
|
+
else li.removeAttribute('aria-busy');
|
|
466
496
|
if (n.disabled) li.setAttribute('aria-disabled', 'true');
|
|
497
|
+
else li.removeAttribute('aria-disabled');
|
|
467
498
|
if (box) {
|
|
468
499
|
const s = st[n.index] ?? 0;
|
|
469
500
|
li.setAttribute('aria-checked', s === 1 ? 'true' : s === 2 ? 'mixed' : 'false');
|
|
501
|
+
} else {
|
|
502
|
+
li.removeAttribute('aria-checked');
|
|
470
503
|
}
|
|
471
|
-
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);
|
|
472
508
|
li.tabIndex = n.key === tabbable ? 0 : -1;
|
|
473
509
|
const rowCls = n.disabled ? ROW_DISABLED_CLASS : n.key === selected ? ROW_SELECTED_CLASS : ROW_CLASS;
|
|
474
|
-
|
|
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
|
+
}
|
|
475
518
|
if (flat) {
|
|
476
|
-
|
|
477
|
-
li.className = `${ITEM_CLASS} ${flat.liClass}`;
|
|
519
|
+
li.className = kitLevelClassFor(li, `${ITEM_CLASS} ${flat.liClass}`);
|
|
478
520
|
li.setAttribute('aria-setsize', String(flat.total));
|
|
479
521
|
li.setAttribute('aria-posinset', String(flat.pos));
|
|
480
522
|
row.className = `${withoutPy(rowCls)} ${FLAT_ROW_FILL} ${flat.indent}`;
|
|
481
523
|
} else {
|
|
482
|
-
li.className = ITEM_CLASS;
|
|
524
|
+
li.className = kitLevelClassFor(li, ITEM_CLASS);
|
|
525
|
+
li.removeAttribute('aria-setsize');
|
|
526
|
+
li.removeAttribute('aria-posinset');
|
|
483
527
|
row.className = rowCls;
|
|
484
528
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
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)}`);
|
|
492
545
|
if (box) {
|
|
493
546
|
const s = st[n.index] ?? 0;
|
|
494
|
-
|
|
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
|
+
}
|
|
495
556
|
cb.className = s === 0 ? CHECK_CLASS : CHECK_ON_CLASS;
|
|
496
|
-
cb
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
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);
|
|
501
583
|
}
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
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"]');
|
|
506
591
|
if (isOpen && branch && !flat) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
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);
|
|
513
597
|
}
|
|
514
|
-
|
|
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();
|
|
515
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);
|
|
516
622
|
return li;
|
|
517
623
|
};
|
|
518
624
|
|
|
519
625
|
/** 虚拟滚动画法:可见节点拍平成一列,只画窗口内的行;游标变了才滚到游标行,游标行不在窗口时焦点退到根 */
|
|
520
626
|
const paintVirtual = (
|
|
521
627
|
p: Record<string, unknown>, flt: ReturnType<typeof filterTreeNodes>, keyword: string, visible: readonly FlatNode[],
|
|
522
|
-
tabbable: string | null, box: boolean, hadFocus: boolean,
|
|
628
|
+
tabbable: string | null, box: boolean, showToggleSlot: boolean, hadFocus: boolean,
|
|
523
629
|
): void => {
|
|
524
630
|
const r = root;
|
|
525
631
|
if (!r) return;
|
|
@@ -546,13 +652,13 @@ export function createTree(): SomaComponentDefinition {
|
|
|
546
652
|
const liClass = KIT_VIRTUAL_OPTION_ROW_CLASS[tier];
|
|
547
653
|
const painted = paintVirtualRows(r, virt, visible.length, (i) => {
|
|
548
654
|
const n = visible[i]!;
|
|
549
|
-
return buildNode(n, tabbable, flt, keyword, box, {
|
|
655
|
+
return buildNode(n, tabbable, flt, keyword, box, showToggleSlot, {
|
|
550
656
|
indent: FLAT_INDENT[Math.min(n.level - 1, FLAT_INDENT.length - 1)]!, liClass, total: visible.length, pos: i + 1,
|
|
551
657
|
});
|
|
552
658
|
}, 'li');
|
|
553
659
|
const keyEl = (key: string | null): HTMLElement | null => {
|
|
554
660
|
if (key === null) return null;
|
|
555
|
-
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;
|
|
556
662
|
return null;
|
|
557
663
|
};
|
|
558
664
|
r.tabIndex = keyEl(tabbable) === null ? 0 : -1;
|
|
@@ -569,6 +675,12 @@ export function createTree(): SomaComponentDefinition {
|
|
|
569
675
|
function paint(): void {
|
|
570
676
|
if (!root) return;
|
|
571
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
|
+
});
|
|
572
684
|
// 没有节点:读取中 / 读取失败 + 重试 / 空态,与集合三态同一画法(base/state-panel.ts;有读接口时编译器自动绑 loading / error_text)
|
|
573
685
|
if (nodes.length === 0) {
|
|
574
686
|
if (virt !== null) root.tabIndex = -1;
|
|
@@ -577,38 +689,47 @@ export function createTree(): SomaComponentDefinition {
|
|
|
577
689
|
root.removeAttribute('aria-multiselectable');
|
|
578
690
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
579
691
|
if (!applyKitReadState(root, p, { hasContent: false, onRetry: () => api.emit('retry', {}), repaint: () => api.refresh() })) {
|
|
580
|
-
|
|
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);
|
|
581
696
|
}
|
|
582
697
|
return;
|
|
583
698
|
}
|
|
584
699
|
const flt = filterOf();
|
|
585
700
|
const keyword = str(p.filter).trim().toLowerCase();
|
|
586
701
|
const visible = visibleOf(nodes, open, flt);
|
|
702
|
+
// 纯平级无任何带子节点(或待懒加载)的叶子列表,省去左侧 24px 空白展开槽
|
|
703
|
+
const showToggleSlot = order.some((n) => expandable(n));
|
|
587
704
|
// 漫游 tabindex:游标项,没有游标时落首个可见项
|
|
588
705
|
const tabbable = cursor !== null && visible.some((n) => n.key === cursor) ? cursor : (visible[0]?.key ?? null);
|
|
589
706
|
const hadFocus = root.contains(document.activeElement);
|
|
590
707
|
const box = checkable();
|
|
591
708
|
if (bool(p.virtual) && !(flt !== null && visible.length === 0)) {
|
|
592
|
-
paintVirtual(p, flt, keyword, visible, tabbable, box, hadFocus);
|
|
709
|
+
paintVirtual(p, flt, keyword, visible, tabbable, box, showToggleSlot, hadFocus);
|
|
593
710
|
return;
|
|
594
711
|
}
|
|
595
712
|
if (virt !== null) root.tabIndex = -1;
|
|
596
713
|
disposeVirt();
|
|
597
|
-
root.textContent = '';
|
|
598
714
|
if (box) root.setAttribute('aria-multiselectable', 'true'); else root.removeAttribute('aria-multiselectable');
|
|
599
715
|
// 已有内容时的读状态:重取中根 aria-busy(内容保留);读取失败不往 role=tree 里塞面板(树结构不被破坏)
|
|
600
716
|
if (p.loading === true || p.loading === 'true') root.setAttribute('aria-busy', 'true'); else root.removeAttribute('aria-busy');
|
|
601
717
|
if (flt !== null && visible.length === 0) {
|
|
718
|
+
root.textContent = '';
|
|
602
719
|
const empty = document.createElement('li');
|
|
603
720
|
empty.setAttribute('role', 'none');
|
|
604
721
|
empty.className = EMPTY_CLASS;
|
|
605
722
|
empty.textContent = str(p.filter_empty_text, kitText('soma.kit.empty_node', undefined, api.host));
|
|
606
723
|
root.appendChild(empty);
|
|
607
724
|
} else {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
root
|
|
611
|
-
|
|
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
|
+
);
|
|
612
733
|
}
|
|
613
734
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
614
735
|
if (hadFocus) focusCursor();
|
|
@@ -619,14 +740,14 @@ export function createTree(): SomaComponentDefinition {
|
|
|
619
740
|
root = rootEl;
|
|
620
741
|
const onClick = (event: Event): void => {
|
|
621
742
|
const target = event.target as HTMLElement | null;
|
|
622
|
-
const li = target?.closest<HTMLElement>(
|
|
623
|
-
const key = li?.getAttribute(
|
|
743
|
+
const li = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY));
|
|
744
|
+
const key = li?.getAttribute(KIT_ATTR_KEY);
|
|
624
745
|
if (!li || !key) return;
|
|
625
|
-
if (target?.closest(
|
|
746
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_TOGGLE))) {
|
|
626
747
|
setOpen(key, !open.has(key));
|
|
627
748
|
return;
|
|
628
749
|
}
|
|
629
|
-
if (target?.closest(
|
|
750
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_CHECK))) {
|
|
630
751
|
cursor = key;
|
|
631
752
|
toggleCheck(key);
|
|
632
753
|
return;
|
|
@@ -637,7 +758,7 @@ export function createTree(): SomaComponentDefinition {
|
|
|
637
758
|
};
|
|
638
759
|
const onKeydown = (event: KeyboardEvent): void => {
|
|
639
760
|
if (cursor === null) {
|
|
640
|
-
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);
|
|
641
762
|
if (first) cursor = first;
|
|
642
763
|
}
|
|
643
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
|
};
|