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/checklist.ts
CHANGED
|
@@ -6,20 +6,31 @@
|
|
|
6
6
|
// 勾选:组件内先乐观翻转(同一份数据没变之前),并抛 `toggle { id, done }` 与 `change { value }`(value = 已完成条目 id 数组);
|
|
7
7
|
// 数据再次下行(签名变)即以数据为准。`readonly` 为真时只展示。底部动作抛 `action { key }`。
|
|
8
8
|
|
|
9
|
+
import { kitApplyLevelClass } from './level-class';
|
|
9
10
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
10
11
|
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
11
12
|
import { createCheck, markInput } from '../base/check-core';
|
|
12
13
|
import { kitIcon } from '../shared/icons';
|
|
13
14
|
import { mergeClass } from '../shared/merge-class';
|
|
14
15
|
import { kitStateMarkRecipe } from '../recipes/state';
|
|
16
|
+
import {
|
|
17
|
+
KIT_COLOR_ROLE_CLASS_CANDIDATES,
|
|
18
|
+
kitResolveStatusOrCategoryTone,
|
|
19
|
+
kitToneSoftBadgeClass,
|
|
20
|
+
} from '../recipes/color-role';
|
|
15
21
|
import { kitText } from '../i18n/kit-text';
|
|
16
22
|
import { markKitEdge } from '../recipes/surface-edge';
|
|
17
23
|
import { kitShellRecipe } from '../recipes/container';
|
|
18
24
|
import { kitTypographyRecipe } from '../recipes/typography';
|
|
19
25
|
import {
|
|
20
26
|
actionButton, actionsOf, BADGE_BASE, BUTTON_CLASS_TOKENS, classTokens, emptyNode, keyMap, mk, mkProgressBar, PROGRESS_BAR_CLASS_TOKENS, recOf, setProgressBar, rowsOf, shapeToneOf, textOf,
|
|
21
|
-
TONE_SOFT,
|
|
27
|
+
TONE_SOFT, type ProgressBarTone,
|
|
22
28
|
} from './shape-util';
|
|
29
|
+
import { kitHasProps, kitMarkDataFacts, kitMarkLevel, kitMarkPart } from './kit-contract';
|
|
30
|
+
import {
|
|
31
|
+
KIT_ATTR_ACTION, KIT_ATTR_CHECK, KIT_ATTR_CONTAINER, KIT_ATTR_COUNT, KIT_ATTR_ITEM, KIT_ATTR_ITEM_LABEL, KIT_ATTR_STATE_MARK, KIT_ATTR_STATUS,
|
|
32
|
+
kitAttrHtml, kitAttrSel,
|
|
33
|
+
} from '../shared/dom-attrs';
|
|
23
34
|
|
|
24
35
|
export const KIT_CHECKLIST_DEFAULT_MAP = Object.freeze({ title: 'title', status: 'status', tone: 'tone', items: 'items', actions: 'actions' });
|
|
25
36
|
export const KIT_CHECKLIST_ITEM_DEFAULT_MAP = Object.freeze({ id: 'id', label: 'label', done: 'done', status: 'status', note: 'note' });
|
|
@@ -32,21 +43,22 @@ const TITLE_CLASS = kitTypographyRecipe('sectionTitle');
|
|
|
32
43
|
const COUNT_CLASS = 'ms-auto text-xs text-fg-muted';
|
|
33
44
|
const PROGRESS_CLASS = 'block w-full';
|
|
34
45
|
const LIST_CLASS = 'flex flex-col gap-1';
|
|
35
|
-
const ITEM_CLASS = 'flex items-start gap-2 rounded-
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
46
|
+
const ITEM_CLASS = 'flex items-start gap-2 rounded-item px-2 py-1.5';
|
|
47
|
+
const ITEM_EDIT_LI_CLASS = 'flex';
|
|
48
|
+
const CHECK_ROW_CLASS = 'w-full px-2 py-1.5 hover:bg-state-layer-hover active:bg-state-layer-press';
|
|
49
|
+
const MARK_CLASS = 'mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-item text-xs font-semibold';
|
|
50
|
+
const BODY_CLASS = 'flex flex-1 flex-col gap-0.5 text-fg';
|
|
39
51
|
const LABEL_CLASS = 'text-fg';
|
|
40
52
|
// 只读态的状态标记(状态呈现表 readonly:不置灰、不画禁用控件、不加删除线):done = 成功软底 + 对勾,todo = 空心圆;类串取配方 kitStateMarkRecipe
|
|
41
53
|
const STATE_MARK_OFFSET = 'mt-0.5';
|
|
42
54
|
const NOTE_CLASS = 'text-xs text-fg-subtle';
|
|
43
|
-
const BLOCK_NOTE = 'rounded-
|
|
55
|
+
const BLOCK_NOTE = 'rounded-item px-2 py-0.5 text-xs';
|
|
44
56
|
const FOOT_CLASS = 'flex flex-wrap items-center justify-end gap-2';
|
|
45
57
|
|
|
46
58
|
export const KIT_CHECKLIST_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
47
|
-
ROOT_CLASS, HEAD_CLASS, TITLE_CLASS, COUNT_CLASS, PROGRESS_CLASS, LIST_CLASS, ITEM_CLASS,
|
|
59
|
+
ROOT_CLASS, HEAD_CLASS, TITLE_CLASS, COUNT_CLASS, PROGRESS_CLASS, LIST_CLASS, ITEM_CLASS, ITEM_EDIT_LI_CLASS, CHECK_ROW_CLASS, MARK_CLASS, BODY_CLASS,
|
|
48
60
|
LABEL_CLASS, STATE_MARK_OFFSET, kitStateMarkRecipe('done'), kitStateMarkRecipe('todo'), NOTE_CLASS, BLOCK_NOTE, FOOT_CLASS, BADGE_BASE, BUTTON_CLASS_TOKENS, TONE_SOFT.danger, TONE_SOFT.neutral,
|
|
49
|
-
Object.values(TONE_SOFT), PROGRESS_BAR_CLASS_TOKENS,
|
|
61
|
+
Object.values(TONE_SOFT), PROGRESS_BAR_CLASS_TOKENS, KIT_COLOR_ROLE_CLASS_CANDIDATES,
|
|
50
62
|
);
|
|
51
63
|
|
|
52
64
|
export interface KitCheckItem {
|
|
@@ -110,12 +122,12 @@ export function createChecklist(): SomaComponentDefinition {
|
|
|
110
122
|
action: { payload: { key: { type: 'string' } }, desc: '点底部动作' },
|
|
111
123
|
},
|
|
112
124
|
},
|
|
113
|
-
templateHtml: `<section
|
|
125
|
+
templateHtml: `<section${kitAttrHtml(KIT_ATTR_CONTAINER, 'card')} data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
114
126
|
controllerFactory: createKitController(() => ({
|
|
115
127
|
attach(root, api) {
|
|
116
128
|
const onChange = (event: Event): void => {
|
|
117
129
|
const box = event.target as HTMLInputElement | null;
|
|
118
|
-
const id = box?.getAttribute(
|
|
130
|
+
const id = box?.getAttribute(KIT_ATTR_CHECK);
|
|
119
131
|
if (!box || id === null || id === undefined) return;
|
|
120
132
|
const p = api.props();
|
|
121
133
|
if (bool(p.readonly)) { box.checked = !box.checked; return; }
|
|
@@ -128,13 +140,13 @@ export function createChecklist(): SomaComponentDefinition {
|
|
|
128
140
|
const hadFocus = root.contains(document.activeElement);
|
|
129
141
|
renderChecklist(root, api.props());
|
|
130
142
|
if (hadFocus) {
|
|
131
|
-
const again = Array.from(root.querySelectorAll<HTMLElement>(
|
|
143
|
+
const again = Array.from(root.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_CHECK))).find((el) => el.getAttribute(KIT_ATTR_CHECK) === id);
|
|
132
144
|
again?.focus();
|
|
133
145
|
}
|
|
134
146
|
};
|
|
135
147
|
const onClick = (event: Event): void => {
|
|
136
|
-
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(
|
|
137
|
-
if (btn && !btn.disabled) api.emit('action', { key: btn.getAttribute(
|
|
148
|
+
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION));
|
|
149
|
+
if (btn && !btn.disabled) api.emit('action', { key: btn.getAttribute(KIT_ATTR_ACTION) ?? '' });
|
|
138
150
|
};
|
|
139
151
|
root.addEventListener('change', onChange);
|
|
140
152
|
root.addEventListener('click', onClick);
|
|
@@ -161,62 +173,91 @@ export function createChecklist(): SomaComponentDefinition {
|
|
|
161
173
|
const items = checkItemsOf(data[m.items], p.item_map, noReason, st.overrides);
|
|
162
174
|
|
|
163
175
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
164
|
-
|
|
176
|
+
// 外框自报交给祖先样式判「在面板里去外圈」;入参里有页面线判定(新流水线)时由层级角色取值决定,不再自报
|
|
177
|
+
if (!kitHasProps(p)) markKitEdge(root);
|
|
165
178
|
root.textContent = '';
|
|
179
|
+
// 数据状态自报:只读 / 空(本组件没有读状态入参)
|
|
180
|
+
kitMarkDataFacts(root, { empty: items.length === 0, readonly });
|
|
166
181
|
|
|
167
182
|
const head = mk('div', HEAD_CLASS);
|
|
168
|
-
|
|
183
|
+
// 清单头(标题 + 状态 + 计数)= 面头
|
|
184
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
185
|
+
const titleEl = mk('h3', TITLE_CLASS, textOf(data[m.title]));
|
|
186
|
+
kitMarkPart(titleEl, 'block-title');
|
|
187
|
+
head.appendChild(titleEl);
|
|
188
|
+
const rawToneVal = data[m.tone];
|
|
189
|
+
const hasExplicitTone = rawToneVal !== undefined && rawToneVal !== null && textOf(rawToneVal).trim() !== '';
|
|
169
190
|
const status = textOf(data[m.status]);
|
|
170
|
-
if (status !== '')
|
|
191
|
+
if (status !== '') {
|
|
192
|
+
const badgeToneCls = hasExplicitTone
|
|
193
|
+
? TONE_SOFT[shapeToneOf(rawToneVal)]
|
|
194
|
+
: kitToneSoftBadgeClass(kitResolveStatusOrCategoryTone(status, undefined, { preferHash: true, host: root }));
|
|
195
|
+
const statusEl = mk('span', `${BADGE_BASE} ${badgeToneCls}`, status);
|
|
196
|
+
kitMarkPart(statusEl, 'status');
|
|
197
|
+
head.appendChild(statusEl);
|
|
198
|
+
}
|
|
171
199
|
const done = items.filter((i) => i.status === 'done').length;
|
|
172
200
|
const count = mk('span', COUNT_CLASS, `${done} / ${items.length}`);
|
|
173
|
-
count.setAttribute(
|
|
201
|
+
count.setAttribute(KIT_ATTR_COUNT, '');
|
|
202
|
+
kitMarkPart(count, 'metric');
|
|
174
203
|
head.appendChild(count);
|
|
175
204
|
root.appendChild(head);
|
|
176
205
|
|
|
177
206
|
if (items.length === 0) {
|
|
178
207
|
root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.cl_empty', undefined, root))));
|
|
179
208
|
} else {
|
|
209
|
+
const hasBlocked = items.some((i) => i.status === 'blocked');
|
|
210
|
+
const barTone: ProgressBarTone = hasExplicitTone
|
|
211
|
+
? (rawToneVal === 'success' || rawToneVal === 'warning' || rawToneVal === 'danger' || rawToneVal === 'info' ? rawToneVal : 'primary')
|
|
212
|
+
: hasBlocked
|
|
213
|
+
? 'warning'
|
|
214
|
+
: done === items.length && items.length > 0
|
|
215
|
+
? 'success'
|
|
216
|
+
: 'primary';
|
|
180
217
|
const bar = mkProgressBar(PROGRESS_CLASS);
|
|
181
|
-
setProgressBar(bar, done, items.length);
|
|
218
|
+
setProgressBar(bar, done, items.length, barTone);
|
|
182
219
|
bar.setAttribute('aria-label', `${done} / ${items.length}`);
|
|
183
220
|
root.appendChild(bar);
|
|
184
221
|
const ul = mk('ul', LIST_CLASS);
|
|
185
222
|
for (const it of items) {
|
|
186
|
-
const
|
|
187
|
-
li
|
|
188
|
-
li.setAttribute(
|
|
223
|
+
const editableItem = !readonly && it.status !== 'blocked';
|
|
224
|
+
const li = mk('li', editableItem ? ITEM_EDIT_LI_CLASS : ITEM_CLASS);
|
|
225
|
+
li.setAttribute(KIT_ATTR_ITEM, it.key);
|
|
226
|
+
li.setAttribute(KIT_ATTR_STATUS, it.status);
|
|
227
|
+
kitMarkLevel(li, 'item', 'line'); kitApplyLevelClass(li);
|
|
228
|
+
const body = mk('div', BODY_CLASS);
|
|
229
|
+
const label = mk('span', LABEL_CLASS, it.label);
|
|
230
|
+
label.setAttribute(KIT_ATTR_ITEM_LABEL, '');
|
|
231
|
+
body.appendChild(label);
|
|
232
|
+
if (it.status === 'blocked') {
|
|
233
|
+
body.appendChild(mk('span', `${BLOCK_NOTE} ${TONE_SOFT.danger}`, `${str(p.blocked_text, kitText('soma.kit.flowstat_blocked', undefined, root))}${kitText('soma.kit.colon', undefined, root)}${it.note}`));
|
|
234
|
+
} else if (it.note !== '') {
|
|
235
|
+
body.appendChild(mk('span', NOTE_CLASS, it.note));
|
|
236
|
+
}
|
|
189
237
|
if (it.status === 'blocked') {
|
|
190
238
|
const mark = mk('span', `${MARK_CLASS} ${TONE_SOFT.danger}`, '!');
|
|
191
239
|
mark.setAttribute('aria-hidden', 'true');
|
|
192
|
-
li.
|
|
240
|
+
li.append(mark, body);
|
|
193
241
|
} else if (readonly) {
|
|
194
242
|
// 只读:状态标记,不是禁用的复选框
|
|
195
243
|
const done = it.status === 'done';
|
|
196
244
|
const mark = mk('span', mergeClass(kitStateMarkRecipe(done ? 'done' : 'todo'), STATE_MARK_OFFSET));
|
|
197
245
|
mark.setAttribute('role', 'img');
|
|
198
|
-
mark.setAttribute(
|
|
246
|
+
mark.setAttribute(KIT_ATTR_STATE_MARK, done ? 'done' : 'todo');
|
|
199
247
|
mark.setAttribute('aria-label', kitText(done ? 'soma.kit.checklist_done' : 'soma.kit.checklist_todo', undefined, root));
|
|
200
248
|
if (done) mark.appendChild(kitIcon('check', 'xs'));
|
|
201
|
-
li.
|
|
249
|
+
li.append(mark, body);
|
|
202
250
|
} else {
|
|
203
|
-
// 自绘勾选标记(base/check-core.ts
|
|
204
|
-
const mark = createCheck(root.ownerDocument, 'checkbox', { checked: it.status === 'done', extra:
|
|
251
|
+
// 自绘勾选标记(base/check-core.ts):将文字 body 放进 <label> 内并设 w-full,使整行悬停高亮与点击热区 100% 一致
|
|
252
|
+
const mark = createCheck(root.ownerDocument, 'checkbox', { checked: it.status === 'done', extra: CHECK_ROW_CLASS });
|
|
205
253
|
const box = markInput(mark);
|
|
206
254
|
if (box) {
|
|
207
|
-
box.setAttribute(
|
|
255
|
+
box.setAttribute(KIT_ATTR_CHECK, it.key);
|
|
208
256
|
box.setAttribute('aria-label', it.label);
|
|
209
257
|
}
|
|
258
|
+
mark.appendChild(body);
|
|
210
259
|
li.appendChild(mark);
|
|
211
260
|
}
|
|
212
|
-
const body = mk('div', BODY_CLASS);
|
|
213
|
-
body.appendChild(mk('span', LABEL_CLASS, it.label));
|
|
214
|
-
if (it.status === 'blocked') {
|
|
215
|
-
body.appendChild(mk('span', `${BLOCK_NOTE} ${TONE_SOFT.danger}`, `${str(p.blocked_text, kitText('soma.kit.flowstat_blocked', undefined, root))}${kitText('soma.kit.colon', undefined, root)}${it.note}`));
|
|
216
|
-
} else if (it.note !== '') {
|
|
217
|
-
body.appendChild(mk('span', NOTE_CLASS, it.note));
|
|
218
|
-
}
|
|
219
|
-
li.appendChild(body);
|
|
220
261
|
ul.appendChild(li);
|
|
221
262
|
}
|
|
222
263
|
root.appendChild(ul);
|
|
@@ -225,6 +266,8 @@ export function createChecklist(): SomaComponentDefinition {
|
|
|
225
266
|
const actions = actionsOf(data[m.actions]);
|
|
226
267
|
if (actions.length > 0) {
|
|
227
268
|
const foot = mk('div', FOOT_CLASS);
|
|
269
|
+
// 底部动作行 = 底栏
|
|
270
|
+
kitMarkLevel(foot, 'foot'); kitApplyLevelClass(foot);
|
|
228
271
|
for (const a of actions) foot.appendChild(actionButton(a));
|
|
229
272
|
root.appendChild(foot);
|
|
230
273
|
}
|
package/src/data/code-view.ts
CHANGED
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
// 经剪贴板接口写入,成功把按钮文字短暂换成 copied_label,抛 `copy { ok }`(不带文本,避免凭据类文本再次上行)。
|
|
6
6
|
// 数据只经 textContent 写入。无文本显示 empty_text。
|
|
7
7
|
|
|
8
|
+
import { kitApplyLevelClass } from './level-class';
|
|
8
9
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
9
10
|
import { bool, createKitController, joinClass, str } from '../base/shared';
|
|
10
11
|
import { kitIcon } from '../shared/icons';
|
|
11
12
|
import { KIT_PART_ATTRIBUTE, KIT_PART_WELL } from '../recipes';
|
|
13
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
12
14
|
import { KIT_DIVIDER_HEAD_CLASS, kitDividerRecipe } from '../recipes/divider';
|
|
13
15
|
import { kitShellRecipe } from '../recipes/container';
|
|
14
16
|
import { kitText } from '../i18n/kit-text';
|
|
@@ -24,6 +26,11 @@ import {
|
|
|
24
26
|
} from '../recipes/code-view';
|
|
25
27
|
import { kitEnginePort, type KitCodeResult, type KitHighlightEnginePort } from './engine-ports';
|
|
26
28
|
import { textActionButton, TEXT_ACTION_CLASS_TOKENS } from './text-action-button';
|
|
29
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked } from './kit-contract';
|
|
30
|
+
import {
|
|
31
|
+
KIT_ATTR_ACTION, KIT_ATTR_CODE, KIT_ATTR_CODE_LINES, KIT_ATTR_CODE_LIVE, KIT_ATTR_CONTAINER, KIT_ATTR_EMPTY, KIT_ATTR_STREAM, KIT_ATTR_TREE,
|
|
32
|
+
KIT_ATTR_TREE_TOGGLE, KIT_ATTR_VARIANT, kitAttrHtml, kitAttrSel,
|
|
33
|
+
} from '../shared/dom-attrs';
|
|
27
34
|
|
|
28
35
|
const CL = KIT_CONTENT_LIMITS.codeView;
|
|
29
36
|
|
|
@@ -78,9 +85,48 @@ export interface KitCodeLinesOptions {
|
|
|
78
85
|
readonly current?: () => boolean;
|
|
79
86
|
}
|
|
80
87
|
|
|
88
|
+
const HIGHLIGHT_CACHE_MAX = 8;
|
|
89
|
+
const HIGHLIGHT_CACHE = new WeakMap<HTMLElement, Map<string, KitCodeResult>>();
|
|
90
|
+
|
|
91
|
+
function getCachedHighlight(root: HTMLElement, language: string, text: string): KitCodeResult | undefined {
|
|
92
|
+
return HIGHLIGHT_CACHE.get(root)?.get(`${language}\0${text}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function setCachedHighlight(root: HTMLElement, language: string, text: string, res: KitCodeResult): void {
|
|
96
|
+
let map = HIGHLIGHT_CACHE.get(root);
|
|
97
|
+
if (!map) {
|
|
98
|
+
map = new Map();
|
|
99
|
+
HIGHLIGHT_CACHE.set(root, map);
|
|
100
|
+
}
|
|
101
|
+
const key = `${language}\0${text}`;
|
|
102
|
+
if (map.has(key)) map.delete(key);
|
|
103
|
+
else if (map.size >= HIGHLIGHT_CACHE_MAX) {
|
|
104
|
+
const oldest = map.keys().next().value;
|
|
105
|
+
if (oldest !== undefined) map.delete(oldest);
|
|
106
|
+
}
|
|
107
|
+
map.set(key, res);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function applyHighlightTokens(host: HTMLElement, rows: readonly HTMLElement[], res: KitCodeResult, root: HTMLElement): void {
|
|
111
|
+
rows.forEach((row, i) => {
|
|
112
|
+
const toks = res.lines[i];
|
|
113
|
+
if (toks === undefined || toks.length === 0) return;
|
|
114
|
+
const body = row.lastElementChild as HTMLElement | null;
|
|
115
|
+
if (!body) return;
|
|
116
|
+
body.textContent = '';
|
|
117
|
+
for (const tok of toks) {
|
|
118
|
+
const cls = kitCodeTokenClass(tok.kind);
|
|
119
|
+
body.appendChild(cls === '' ? document.createTextNode(tok.text) : mk('span', cls, tok.text));
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
if (res.fallback === 'too-large' || res.fallback === 'timeout') {
|
|
123
|
+
host.appendChild(mk('p', KIT_CODE_NOTE_CLASS, kitText('soma.kit.code_partly_plain', undefined, root)));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
81
127
|
/**
|
|
82
128
|
* 按行画代码区(CodeView 高亮形态与 JsonView「原文」共用的唯一画法):先画纯文本行(行号槽、高亮行、双向字符警告),
|
|
83
|
-
*
|
|
129
|
+
* 命中最近一次 (text, language) 高亮缓存时同步上色消除重绘闪白,未命中再经 engines.highlight 异步取记号替换各行正文;超长 / 超时补一行说明。返回行容器。
|
|
84
130
|
*/
|
|
85
131
|
export function paintCodeLines(host: HTMLElement, text: string, o: KitCodeLinesOptions): HTMLElement {
|
|
86
132
|
const allLines = text.split('\n');
|
|
@@ -90,7 +136,7 @@ export function paintCodeLines(host: HTMLElement, text: string, o: KitCodeLinesO
|
|
|
90
136
|
const numbers = allLines.length >= CL.lineNumbersMin;
|
|
91
137
|
const root = o.root;
|
|
92
138
|
const box = mk('div', o.wrap ? KIT_CODE_LINES_WRAP_CLASS : KIT_CODE_LINES_SCROLL_CLASS);
|
|
93
|
-
box.setAttribute(
|
|
139
|
+
box.setAttribute(KIT_ATTR_CODE_LINES, '');
|
|
94
140
|
const rows: HTMLElement[] = shownLines.map((line, i) => {
|
|
95
141
|
const n = start + i;
|
|
96
142
|
const on = marked.has(n);
|
|
@@ -114,24 +160,17 @@ export function paintCodeLines(host: HTMLElement, text: string, o: KitCodeLinesO
|
|
|
114
160
|
});
|
|
115
161
|
host.appendChild(box);
|
|
116
162
|
if (o.port !== null && o.language !== 'text') {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (!
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
body.appendChild(cls === '' ? document.createTextNode(tok.text) : mk('span', cls, tok.text));
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
if (res.fallback === 'too-large' || res.fallback === 'timeout') {
|
|
132
|
-
host.appendChild(mk('p', KIT_CODE_NOTE_CLASS, kitText('soma.kit.code_partly_plain', undefined, root)));
|
|
133
|
-
}
|
|
134
|
-
}, () => { /* 端口不抛;保险起见吞掉,保留纯文本 */ });
|
|
163
|
+
const cached = getCachedHighlight(root, o.language, text);
|
|
164
|
+
if (cached !== undefined) {
|
|
165
|
+
applyHighlightTokens(host, rows, cached, root);
|
|
166
|
+
} else {
|
|
167
|
+
const current = o.current ?? ((): boolean => true);
|
|
168
|
+
void o.port.highlight(text, o.language).then((res: KitCodeResult) => {
|
|
169
|
+
setCachedHighlight(root, o.language, text, res);
|
|
170
|
+
if (!current() || !host.contains(box)) return;
|
|
171
|
+
applyHighlightTokens(host, rows, res, root);
|
|
172
|
+
}, () => { /* 端口不抛;保险起见吞掉,保留纯文本 */ });
|
|
173
|
+
}
|
|
135
174
|
}
|
|
136
175
|
return box;
|
|
137
176
|
}
|
|
@@ -145,7 +184,7 @@ const HEAD_TABS_CLASS = `flex items-center justify-between gap-2 ${KIT_DIVIDER_H
|
|
|
145
184
|
const TITLE_CLASS = 'text-sm font-medium text-fg';
|
|
146
185
|
const WELL_EDGE = kitShellRecipe({ tone: 'sunken', shadow: false });
|
|
147
186
|
const TREE_GUIDE = kitDividerRecipe('start');
|
|
148
|
-
export const KIT_CODE_PRE_CLASS = `m-0 whitespace-pre-wrap break-all ${WELL_EDGE} p-3 font-mono text-xs text-fg
|
|
187
|
+
export const KIT_CODE_PRE_CLASS = `m-0 whitespace-pre-wrap break-all ${WELL_EDGE} p-3 font-mono text-xs text-fg ${KIT_FOCUS_RING.button}`;
|
|
149
188
|
const PRE_HEIGHT: Readonly<Record<string, string>> = Object.freeze({
|
|
150
189
|
none: '',
|
|
151
190
|
sm: 'max-h-40 overflow-y-auto',
|
|
@@ -159,7 +198,7 @@ const CAPTION_CLASS = 'text-xs text-fg-subtle';
|
|
|
159
198
|
// 页签行单行不折行可横向滚动,底部分割线挂在整行 header 容器上贯通左右,右侧「复制」钮齐平不错位
|
|
160
199
|
const TABS_CLASS = '-mb-px flex min-w-0 flex-1 flex-nowrap items-center gap-1 overflow-x-auto';
|
|
161
200
|
const HEAD_END_BUTTON = 'shrink-0';
|
|
162
|
-
const TAB_CLASS = 'h-8 shrink-0 whitespace-nowrap border-b-2 border-transparent bg-transparent px-3 text-sm text-fg-muted hover:text-fg motion-safe:transition-colors
|
|
201
|
+
const TAB_CLASS = 'h-8 shrink-0 whitespace-nowrap border-b-2 border-transparent bg-transparent px-3 text-sm text-fg-muted hover:text-fg motion-safe:transition-colors ' + KIT_FOCUS_RING.button;
|
|
163
202
|
const TAB_ACTIVE_CLASS = 'border-primary font-medium text-fg';
|
|
164
203
|
|
|
165
204
|
export interface KitCodeVariant {
|
|
@@ -204,13 +243,13 @@ export function codeVariantsFromProps(p: Record<string, unknown>): KitCodeVarian
|
|
|
204
243
|
}
|
|
205
244
|
|
|
206
245
|
// tree:JSON 树(自绘 disclosure:标题 button + aria-expanded / aria-controls,Enter / Space 由 button 触发点击切换)
|
|
207
|
-
const TREE_CLASS = `m-0 ${WELL_EDGE} p-3 font-mono text-xs text-fg
|
|
208
|
-
const TREE_SUMMARY_CLASS = 'block w-full cursor-pointer select-none rounded-
|
|
246
|
+
const TREE_CLASS = `m-0 ${WELL_EDGE} p-3 font-mono text-xs text-fg ${KIT_FOCUS_RING.button}`;
|
|
247
|
+
const TREE_SUMMARY_CLASS = 'block w-full cursor-pointer select-none rounded-item bg-transparent p-0 text-start font-mono text-xs text-fg hover:bg-state-layer-hover active:bg-state-layer-press ' + KIT_FOCUS_RING.item;
|
|
209
248
|
const TREE_CHILDREN_CLASS = `ms-3 ${TREE_GUIDE} ps-3`;
|
|
210
249
|
const TREE_LEAF_CLASS = 'py-0.5 break-all';
|
|
211
250
|
const TREE_KEY_CLASS = 'text-fg-muted';
|
|
212
251
|
const TREE_VALUE_CLASS: Readonly<Record<'string' | 'number' | 'other', string>> = Object.freeze({
|
|
213
|
-
string: 'text-
|
|
252
|
+
string: 'text-syntax-string', number: 'text-syntax-number', other: 'text-syntax-keyword',
|
|
214
253
|
});
|
|
215
254
|
const TREE_MORE_CLASS = 'text-fg-subtle';
|
|
216
255
|
const TREE_MARK_CLASS = 'inline-block w-4 text-fg-muted';
|
|
@@ -273,7 +312,7 @@ export function treeNode(key: string, value: unknown, depth: number, budget: { l
|
|
|
273
312
|
const bodyId = `kit-code-tree-${(treeSeq += 1)}`;
|
|
274
313
|
const summary = mk('button', TREE_SUMMARY_CLASS) as HTMLButtonElement;
|
|
275
314
|
summary.type = 'button';
|
|
276
|
-
summary.setAttribute(
|
|
315
|
+
summary.setAttribute(KIT_ATTR_TREE_TOGGLE, '');
|
|
277
316
|
summary.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
278
317
|
summary.setAttribute('aria-controls', bodyId);
|
|
279
318
|
const mark = mk('span', TREE_MARK_CLASS, '');
|
|
@@ -353,11 +392,11 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
353
392
|
},
|
|
354
393
|
},
|
|
355
394
|
services: ['engines'],
|
|
356
|
-
templateHtml: `<section
|
|
395
|
+
templateHtml: `<section${kitAttrHtml(KIT_ATTR_CONTAINER, 'card')} data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
357
396
|
controllerFactory: createKitController(() => ({
|
|
358
397
|
attach(root, api) {
|
|
359
398
|
const onClick = (event: Event): void => {
|
|
360
|
-
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>('
|
|
399
|
+
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION, 'copy'));
|
|
361
400
|
if (!btn || btn.disabled) return;
|
|
362
401
|
const p = api.props();
|
|
363
402
|
const data = recOf(p.data);
|
|
@@ -377,7 +416,7 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
377
416
|
} catch { ok = false; }
|
|
378
417
|
if (ok) {
|
|
379
418
|
btn.textContent = str(p.copied_label, kitText('soma.kit.copied', undefined, root));
|
|
380
|
-
const live = root.querySelector<HTMLElement>(
|
|
419
|
+
const live = root.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_CODE_LIVE));
|
|
381
420
|
if (live) live.textContent = kitText('soma.kit.copied', undefined, root);
|
|
382
421
|
const prev = timers.get(root);
|
|
383
422
|
if (prev !== undefined) clearTimeout(prev);
|
|
@@ -393,7 +432,7 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
393
432
|
root.addEventListener('click', onClick);
|
|
394
433
|
// 长代码折叠条:展开全部(只展开不收起,与 Carbon 一致)
|
|
395
434
|
const onUnfold = (event: Event): void => {
|
|
396
|
-
const btn = (event.target as HTMLElement | null)?.closest<HTMLElement>('
|
|
435
|
+
const btn = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_ACTION, 'code-unfold'));
|
|
397
436
|
if (!btn || !root.contains(btn)) return;
|
|
398
437
|
unfolded.add(root);
|
|
399
438
|
renderCode(root, api.props(), api.services);
|
|
@@ -401,7 +440,7 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
401
440
|
root.addEventListener('click', onUnfold);
|
|
402
441
|
// 树节点折叠:button 的 Enter / Space 原生触发 click;这里切 aria-expanded、折叠体显隐与标记
|
|
403
442
|
const onToggle = (event: Event): void => {
|
|
404
|
-
const btn = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
443
|
+
const btn = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_TREE_TOGGLE));
|
|
405
444
|
if (!btn || !root.contains(btn)) return;
|
|
406
445
|
const id = btn.getAttribute('aria-controls') ?? '';
|
|
407
446
|
const body = id === '' ? null : Array.from(root.querySelectorAll<HTMLElement>('[id]')).find((e) => e.id === id) ?? null;
|
|
@@ -422,19 +461,19 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
422
461
|
st.index = index;
|
|
423
462
|
picked.set(root, st);
|
|
424
463
|
renderCode(root, p, api.services);
|
|
425
|
-
if (refocus) root.querySelector<HTMLElement>(
|
|
464
|
+
if (refocus) root.querySelector<HTMLElement>(`${kitAttrSel(KIT_ATTR_VARIANT)}[aria-selected="true"]`)?.focus();
|
|
426
465
|
api.emit('variant', { key: list[index]!.key, index });
|
|
427
466
|
};
|
|
428
467
|
const onTab = (event: Event): void => {
|
|
429
|
-
const tab = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
468
|
+
const tab = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_VARIANT));
|
|
430
469
|
if (!tab || !root.contains(tab)) return;
|
|
431
|
-
chooseVariant(Number(tab.getAttribute(
|
|
470
|
+
chooseVariant(Number(tab.getAttribute(KIT_ATTR_VARIANT)), false);
|
|
432
471
|
};
|
|
433
472
|
const onTabKey = (event: KeyboardEvent): void => {
|
|
434
|
-
const tab = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
473
|
+
const tab = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_VARIANT));
|
|
435
474
|
if (!tab || !root.contains(tab)) return;
|
|
436
475
|
const n = codeVariantsFromProps(api.props()).length;
|
|
437
|
-
const at = Number(tab.getAttribute(
|
|
476
|
+
const at = Number(tab.getAttribute(KIT_ATTR_VARIANT));
|
|
438
477
|
const rtl = getComputedStyle(root).direction === 'rtl';
|
|
439
478
|
const next = event.key === 'ArrowRight' ? at + (rtl ? -1 : 1) : event.key === 'ArrowLeft' ? at + (rtl ? 1 : -1)
|
|
440
479
|
: event.key === 'Home' ? 0 : event.key === 'End' ? n - 1 : -1;
|
|
@@ -447,7 +486,7 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
447
486
|
// scroll 不冒泡,捕获阶段挂在根上:记录内容区是否贴底(stream + follow 用)
|
|
448
487
|
const onScroll = (event: Event): void => {
|
|
449
488
|
const el = event.target as HTMLElement | null;
|
|
450
|
-
if (!el || el.getAttribute?.(
|
|
489
|
+
if (!el || el.getAttribute?.(KIT_ATTR_CODE) === null) return;
|
|
451
490
|
pinned.set(root, el.scrollHeight - el.scrollTop - el.clientHeight <= CODE_FOLLOW_SLACK_PX);
|
|
452
491
|
};
|
|
453
492
|
root.addEventListener('scroll', onScroll, true);
|
|
@@ -462,6 +501,7 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
462
501
|
root.removeEventListener('scroll', onScroll, true);
|
|
463
502
|
picked.delete(root);
|
|
464
503
|
pinned.delete(root);
|
|
504
|
+
HIGHLIGHT_CACHE.delete(root);
|
|
465
505
|
const t = timers.get(root);
|
|
466
506
|
if (t !== undefined) clearTimeout(t);
|
|
467
507
|
timers.delete(root);
|
|
@@ -502,8 +542,10 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
502
542
|
} catch { treeValue = null; }
|
|
503
543
|
}
|
|
504
544
|
}
|
|
505
|
-
const oldPre = root.querySelector<HTMLElement>(
|
|
545
|
+
const oldPre = root.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_CODE));
|
|
506
546
|
const prevTop = oldPre?.scrollTop ?? 0;
|
|
547
|
+
const prevLeft = oldPre?.scrollLeft ?? 0;
|
|
548
|
+
const prevLinesLeft = oldPre?.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_CODE_LINES))?.scrollLeft ?? 0;
|
|
507
549
|
|
|
508
550
|
// 内容变化时重置长代码展开状态,避免切换新代码后沿用旧代码的 unfolded 标记
|
|
509
551
|
if (renderedText.get(root) !== text) {
|
|
@@ -524,6 +566,8 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
524
566
|
root.textContent = '';
|
|
525
567
|
if (title !== '' || copyable || variants.length > 0 || langLabel !== '') {
|
|
526
568
|
const head = mk('div', variants.length > 0 ? HEAD_TABS_CLASS : HEAD_CLASS);
|
|
569
|
+
// 标题行(含页签行)= 面头;标题文字 = 块标题;复制钮经 actionButton 已自报「动作」
|
|
570
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
527
571
|
if (variants.length > 0) {
|
|
528
572
|
const tabs = mk('div', TABS_CLASS);
|
|
529
573
|
tabs.setAttribute('role', 'tablist');
|
|
@@ -533,14 +577,20 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
533
577
|
tab.type = 'button';
|
|
534
578
|
tab.setAttribute('role', 'tab');
|
|
535
579
|
tab.setAttribute('aria-selected', on ? 'true' : 'false');
|
|
580
|
+
// 当前页签自报选中(aria-selected 上一行已写)
|
|
581
|
+
kitMarkPicked(tab, 'selected', on, null);
|
|
536
582
|
tab.tabIndex = on ? 0 : -1;
|
|
537
|
-
tab.setAttribute(
|
|
583
|
+
tab.setAttribute(KIT_ATTR_VARIANT, String(i));
|
|
538
584
|
tabs.appendChild(tab);
|
|
539
585
|
});
|
|
540
586
|
head.appendChild(tabs);
|
|
541
587
|
} else if (title !== '' || langLabel !== '') {
|
|
542
588
|
const meta = mk('div', HEAD_META_CLASS);
|
|
543
|
-
if (title !== '')
|
|
589
|
+
if (title !== '') {
|
|
590
|
+
const titleEl = mk('span', TITLE_CLASS, title);
|
|
591
|
+
kitMarkPart(titleEl, 'block-title');
|
|
592
|
+
meta.appendChild(titleEl);
|
|
593
|
+
}
|
|
544
594
|
if (langLabel !== '') meta.appendChild(mk('span', KIT_CODE_LANG_CLASS, langLabel));
|
|
545
595
|
head.appendChild(meta);
|
|
546
596
|
}
|
|
@@ -559,27 +609,29 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
559
609
|
? mk('div', `${TREE_CLASS}${height !== '' ? ` ${height}` : ''}`)
|
|
560
610
|
: mk(lineMode ? 'div' : 'pre', `${KIT_CODE_PRE_CLASS}${height !== '' ? ` ${height}` : ''}`);
|
|
561
611
|
pre.tabIndex = 0;
|
|
562
|
-
pre.setAttribute(
|
|
612
|
+
pre.setAttribute(KIT_ATTR_CODE, '');
|
|
563
613
|
pre.setAttribute(KIT_PART_ATTRIBUTE, KIT_PART_WELL);
|
|
564
614
|
const label = str(p.aria_label) !== '' ? str(p.aria_label) : title;
|
|
565
615
|
if (label !== '') pre.setAttribute('aria-label', label);
|
|
566
616
|
if (stream) {
|
|
567
617
|
pre.setAttribute('role', 'log');
|
|
568
618
|
pre.setAttribute('aria-live', 'polite');
|
|
569
|
-
pre.setAttribute(
|
|
619
|
+
pre.setAttribute(KIT_ATTR_STREAM, '');
|
|
570
620
|
}
|
|
621
|
+
// 数据状态:无文本即内容全空(根每次重画,按本轮事实写)
|
|
622
|
+
kitMarkDataFacts(root, { empty: !asTree && text === '' });
|
|
571
623
|
if (asTree) {
|
|
572
|
-
pre.setAttribute(
|
|
624
|
+
pre.setAttribute(KIT_ATTR_TREE, '');
|
|
573
625
|
pre.appendChild(treeNode('', treeValue, 0, { left: CODE_TREE_MAX_NODES, truncated: kitText('soma.kit.code_truncated', undefined, root) }));
|
|
574
626
|
} else if (text === '') {
|
|
575
627
|
pre.appendChild(mk('span', EMPTY_CLASS, str(p.empty_text, kitText('soma.kit.empty_content', undefined, root))));
|
|
576
|
-
pre.setAttribute(
|
|
628
|
+
pre.setAttribute(KIT_ATTR_EMPTY, '');
|
|
577
629
|
} else if (stream) {
|
|
578
630
|
pre.textContent = text;
|
|
579
631
|
} else {
|
|
580
632
|
// 高亮形态:先画纯文本行(行号、折叠、换行、高亮行都在这一步定好),再异步取记号替换各行正文
|
|
581
633
|
pre.setAttribute('role', 'region');
|
|
582
|
-
pre.setAttribute(
|
|
634
|
+
pre.setAttribute(KIT_ATTR_CONTAINER, 'plain');
|
|
583
635
|
pre.setAttribute('aria-label', label !== '' ? label : kitText('soma.kit.code_region', { name: langLabel !== '' ? langLabel : kitText('soma.kit.code_plain', undefined, root) }, root));
|
|
584
636
|
const allLines = text.split('\n');
|
|
585
637
|
const folded = allLines.length > CL.foldAbove && !unfolded.has(root);
|
|
@@ -595,7 +647,7 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
595
647
|
shown: folded ? CL.foldTo : allLines.length,
|
|
596
648
|
current: () => hlSeq.get(root) === mine,
|
|
597
649
|
});
|
|
598
|
-
if (folded) pre.appendChild(textActionButton('code-unfold', kitText('soma.kit.code_unfold', { n: allLines.length }, root), '
|
|
650
|
+
if (folded) pre.appendChild(textActionButton('code-unfold', kitText('soma.kit.code_unfold', { n: allLines.length }, root), 'expand'));
|
|
599
651
|
if (unknownLang && port !== null) {
|
|
600
652
|
pre.appendChild(mk('p', KIT_CODE_NOTE_CLASS, kitText('soma.kit.code_unknown_language', undefined, root)));
|
|
601
653
|
}
|
|
@@ -603,12 +655,18 @@ export function createCodeView(): SomaComponentDefinition {
|
|
|
603
655
|
root.appendChild(pre);
|
|
604
656
|
const live = mk('span', 'sr-only');
|
|
605
657
|
live.setAttribute('aria-live', 'polite');
|
|
606
|
-
live.setAttribute(
|
|
658
|
+
live.setAttribute(KIT_ATTR_CODE_LIVE, '');
|
|
607
659
|
root.appendChild(live);
|
|
608
|
-
// 流式:贴底(或首次)且 follow
|
|
660
|
+
// 流式:贴底(或首次)且 follow 时滚到最新;用户翻上去过就保持原位置;非流式重绘同样恢复纵横滚动位置
|
|
609
661
|
if (stream) {
|
|
610
662
|
const wasPinned = pinned.get(root) ?? true;
|
|
611
663
|
pre.scrollTop = follow && wasPinned ? pre.scrollHeight : prevTop;
|
|
664
|
+
pre.scrollLeft = prevLeft;
|
|
665
|
+
} else {
|
|
666
|
+
pre.scrollTop = prevTop;
|
|
667
|
+
pre.scrollLeft = prevLeft;
|
|
668
|
+
const linesBox = pre.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_CODE_LINES));
|
|
669
|
+
if (linesBox && prevLinesLeft > 0) linesBox.scrollLeft = prevLinesLeft;
|
|
612
670
|
}
|
|
613
671
|
if (caption !== '') root.appendChild(mk('p', CAPTION_CLASS, caption));
|
|
614
672
|
}
|