soma-kit 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
|
@@ -19,17 +19,24 @@
|
|
|
19
19
|
// 远程状态:页面把读状态绑到 `loading`(进行中)与 `error_text`(失败消息,空串无错误);组件只画,不取数。
|
|
20
20
|
// 组件不改数据。
|
|
21
21
|
|
|
22
|
+
import { kitApplyLevelClass } from './level-class';
|
|
22
23
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
23
24
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
24
25
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
25
26
|
import { KIT_DATA_LIMITS } from 'soma-foundation/kit-limits';
|
|
26
27
|
import { KIT_GRAMMAR_RUNTIME as grammarJson } from '../generated/kit-grammar-runtime';
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
28
|
+
import { KIT_CHECK_CLASS_CANDIDATES, createCheckVisual, paintCheckVisual } from '../base/check-core';
|
|
29
|
+
import { applyCompositeField, bool, createKitController, ID_PROPS, INVALID_PROPS, joinClass, num, setAttr, sizeOf, str, type KitSize } from '../base/shared';
|
|
30
|
+
import { kitIcon } from '../shared/icons';
|
|
29
31
|
import { kitLocaleAt, kitText } from '../i18n/kit-text';
|
|
30
|
-
import { setKitFace } from '../recipes';
|
|
32
|
+
import { kitControlRecipe, setKitFace } from '../recipes';
|
|
33
|
+
import { KIT_FOCUS_RING, kitSelectedRecipe } from '../recipes/state';
|
|
34
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
35
|
+
import { mergeClass } from '../shared/merge-class';
|
|
36
|
+
import { KIT_ATTR_ACTION, KIT_ATTR_KEY, kitAttrSel } from '../shared/dom-attrs';
|
|
31
37
|
import { actionButton, BUTTON_CLASS_TOKENS, classTokens, keyMap, mk, retryButton, rowsOf, textOf } from './shape-util';
|
|
32
38
|
import { KIT_MODAL_CLASS_CANDIDATES, mountKitModal, type KitModalHandle, type KitModalSize } from './modal-dialog';
|
|
39
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked, kitReadProps } from './kit-contract';
|
|
33
40
|
|
|
34
41
|
// 尺寸闭集读语法,行数 / 选择数上限读 design 的 kit-limits
|
|
35
42
|
const LIMITS = {
|
|
@@ -43,29 +50,37 @@ export const KIT_RECORD_PICKER_DEFAULT_MAP = Object.freeze({ id: 'id', title: 't
|
|
|
43
50
|
// ───────── 样式常量 ─────────
|
|
44
51
|
|
|
45
52
|
const ROOT_CLASS = 'flex items-center gap-2';
|
|
46
|
-
|
|
53
|
+
// 触发框跟同行表单尺寸档对齐(kitControlRecipe trigger 模式去掉 read-only:*,不再写死 h-8)
|
|
54
|
+
const TRIGGER_EXTRA = 'inline-flex min-w-0 flex-1 items-center justify-between gap-2 text-start state-layer aria-invalid:border-danger';
|
|
55
|
+
const TRIGGER_BY_SIZE: Readonly<Record<KitSize, string>> = Object.freeze({
|
|
56
|
+
sm: mergeClass(kitControlRecipe({ trigger: true, size: 'sm' }), TRIGGER_EXTRA),
|
|
57
|
+
md: mergeClass(kitControlRecipe({ trigger: true, size: 'md' }), TRIGGER_EXTRA),
|
|
58
|
+
lg: mergeClass(kitControlRecipe({ trigger: true, size: 'lg' }), TRIGGER_EXTRA),
|
|
59
|
+
});
|
|
60
|
+
const TRIGGER_CLASS = TRIGGER_BY_SIZE.md;
|
|
61
|
+
const FIELD_EDGE = kitControlEdgeRecipe();
|
|
47
62
|
const TRIGGER_TEXT = 'min-w-0 truncate text-start';
|
|
48
63
|
const TRIGGER_PLACEHOLDER = 'min-w-0 truncate text-start text-fg-subtle';
|
|
49
64
|
const TRIGGER_CARET = 'shrink-0 text-fg-subtle';
|
|
50
|
-
const CLEAR_CLASS = 'inline-flex h-8 shrink-0 items-center justify-center rounded-
|
|
65
|
+
const CLEAR_CLASS = 'inline-flex h-8 shrink-0 items-center justify-center rounded-control px-2 text-xs text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg ' + KIT_FOCUS_RING.item + '';
|
|
51
66
|
const SEARCH_ROW = 'flex items-center gap-2';
|
|
52
|
-
const SEARCH_CLASS = 'block h-8 min-w-0 flex-1 appearance-none autofill-clear rounded-
|
|
53
|
-
const LIST_CLASS = 'flex max-h-80 min-h-24 flex-col gap-1 overflow-y-auto rounded-
|
|
54
|
-
const ITEM_CLASS = 'flex cursor-pointer items-center gap-2 rounded-
|
|
55
|
-
const ITEM_ON_CLASS = 'flex cursor-pointer items-center gap-2 rounded-
|
|
56
|
-
const ITEM_OFF_CLASS = 'flex cursor-not-allowed items-center gap-2 rounded-
|
|
67
|
+
const SEARCH_CLASS = 'block h-8 min-w-0 flex-1 appearance-none autofill-clear rounded-control ' + FIELD_EDGE + ' bg-surface px-2 text-sm text-fg placeholder:text-fg-subtle ' + KIT_FOCUS_RING.item + '';
|
|
68
|
+
const LIST_CLASS = 'flex max-h-80 min-h-24 flex-col gap-1 overflow-y-auto rounded-item ' + KIT_FOCUS_RING.item + '';
|
|
69
|
+
const ITEM_CLASS = 'group flex cursor-pointer items-center gap-2 rounded-item px-2 py-1.5 text-sm text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press';
|
|
70
|
+
const ITEM_ON_CLASS = 'group flex cursor-pointer items-center gap-2 rounded-item px-2 py-1.5 text-sm ' + kitSelectedRecipe();
|
|
71
|
+
const ITEM_OFF_CLASS = 'flex cursor-not-allowed items-center gap-2 rounded-item px-2 py-1.5 text-sm text-fg-disabled'; // KT-K0-4
|
|
57
72
|
const CURSOR_CLASS = 'ring-2 ring-ring';
|
|
58
73
|
const MARK_CLASS = 'w-4 shrink-0 text-primary-on-soft';
|
|
59
74
|
const TEXT_CLASS = 'flex min-w-0 flex-1 flex-col';
|
|
60
75
|
const SUB_CLASS = 'truncate text-xs text-fg-muted';
|
|
61
76
|
const EMPTY_CLASS = 'px-2 py-3 text-sm text-fg-muted';
|
|
62
|
-
const COUNT_CLASS = 'text-xs text-fg-subtle';
|
|
63
|
-
const LIMIT_CLASS = 'text-xs text-warning-on-soft';
|
|
77
|
+
const COUNT_CLASS = 'text-xs tabular-nums text-fg-subtle';
|
|
78
|
+
const LIMIT_CLASS = 'text-xs tabular-nums text-warning-on-soft';
|
|
64
79
|
|
|
65
80
|
export const KIT_RECORD_PICKER_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
66
|
-
ROOT_CLASS,
|
|
81
|
+
ROOT_CLASS, Object.values(TRIGGER_BY_SIZE), TRIGGER_TEXT, TRIGGER_PLACEHOLDER, TRIGGER_CARET, CLEAR_CLASS, SEARCH_ROW, SEARCH_CLASS, LIST_CLASS,
|
|
67
82
|
ITEM_CLASS, ITEM_ON_CLASS, ITEM_OFF_CLASS, CURSOR_CLASS, MARK_CLASS, TEXT_CLASS, SUB_CLASS, EMPTY_CLASS, COUNT_CLASS, LIMIT_CLASS,
|
|
68
|
-
BUTTON_CLASS_TOKENS, KIT_MODAL_CLASS_CANDIDATES,
|
|
83
|
+
BUTTON_CLASS_TOKENS, KIT_MODAL_CLASS_CANDIDATES, KIT_CHECK_CLASS_CANDIDATES,
|
|
69
84
|
);
|
|
70
85
|
|
|
71
86
|
// ───────── 数据规整(纯函数) ─────────
|
|
@@ -230,6 +245,8 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
230
245
|
if (!root || !trigger || !triggerText || !clearBox) return;
|
|
231
246
|
const p = P();
|
|
232
247
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
248
|
+
// 控件高度档:页面自己写了 size 以它为准;没写时读页面线布局写的 controlSize(同一条带里控件同高),都没有取中
|
|
249
|
+
trigger.className = TRIGGER_BY_SIZE[sizeOf(p.size ?? kitReadProps(p).controlSize)];
|
|
233
250
|
const text = summary();
|
|
234
251
|
triggerText.textContent = text === '' ? str(p.placeholder, kitText('soma.kit.please_select', undefined, root)) : text;
|
|
235
252
|
triggerText.className = text === '' ? TRIGGER_PLACEHOLDER : TRIGGER_TEXT;
|
|
@@ -238,7 +255,7 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
238
255
|
else trigger.removeAttribute('aria-label');
|
|
239
256
|
// 作表单字段:触发钮接 id(label for / 点标签聚焦),根承载字段名 / 说明 / 错误关联与无效标记
|
|
240
257
|
setAttr(trigger, 'id', str(p.id));
|
|
241
|
-
applyCompositeField(root, p);
|
|
258
|
+
applyCompositeField(root, p, [trigger]);
|
|
242
259
|
const clearBtn = clearBox.firstElementChild as HTMLButtonElement | null;
|
|
243
260
|
if (clearBtn) clearBtn.textContent = str(p.clear_text, kitText('soma.kit.clear', undefined, root));
|
|
244
261
|
clearBox.hidden = !(bool(p.clearable) && committed.length > 0 && !bool(p.disabled));
|
|
@@ -295,15 +312,25 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
295
312
|
if (cursor === r.id) row.className = `${row.className} ${CURSOR_CLASS}`;
|
|
296
313
|
row.id = optionId(r.id);
|
|
297
314
|
row.setAttribute('role', 'option');
|
|
298
|
-
row.setAttribute(
|
|
299
|
-
|
|
315
|
+
row.setAttribute(KIT_ATTR_KEY, r.id);
|
|
316
|
+
// 候选项是集合条目;选中自报与 aria-selected(listbox 的 option 角色)同写
|
|
317
|
+
kitMarkLevel(row, 'item', 'line'); kitApplyLevelClass(row);
|
|
318
|
+
kitMarkPicked(row, 'selected', on);
|
|
300
319
|
if (r.disabled) row.setAttribute('aria-disabled', 'true');
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
320
|
+
if (multiple()) {
|
|
321
|
+
const checkEl = createCheckVisual(row.ownerDocument, 'checkbox', 'md');
|
|
322
|
+
paintCheckVisual(checkEl, 'checkbox', on, { disabled: r.disabled, size: 'md' });
|
|
323
|
+
row.appendChild(checkEl);
|
|
324
|
+
} else {
|
|
325
|
+
const mark = mk('span', MARK_CLASS, '');
|
|
326
|
+
if (on) mark.appendChild(kitIcon('check', 'sm'));
|
|
327
|
+
mark.setAttribute('aria-hidden', 'true');
|
|
328
|
+
row.appendChild(mark);
|
|
329
|
+
}
|
|
305
330
|
const text = mk('span', TEXT_CLASS);
|
|
306
|
-
|
|
331
|
+
const title = mk('span', '', r.title);
|
|
332
|
+
kitMarkPart(title, 'value');
|
|
333
|
+
text.appendChild(title);
|
|
307
334
|
if (r.sub !== '' && r.sub !== r.title) text.appendChild(mk('span', SUB_CLASS, r.sub));
|
|
308
335
|
if (r.facts.length > 0) text.appendChild(mk('span', SUB_CLASS, r.facts.map((f) => `${f.label}:${f.value}`).join(' ')));
|
|
309
336
|
row.appendChild(text);
|
|
@@ -316,13 +343,15 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
316
343
|
const shown = view();
|
|
317
344
|
if (cursor !== null && !shown.some((r) => r.id === cursor)) cursor = null;
|
|
318
345
|
// 键盘点「重试」后列表整体重画、重试钮被销毁,焦点会掉到 body(Tab 陷阱挂在遮罩上,从 body 发出的 Tab 拦不住):重画前记下
|
|
319
|
-
const retryHadFocus = list.contains(list.ownerDocument.activeElement) && list.ownerDocument.activeElement?.closest('
|
|
346
|
+
const retryHadFocus = list.contains(list.ownerDocument.activeElement) && list.ownerDocument.activeElement?.closest(kitAttrSel(KIT_ATTR_ACTION, 'retry')) != null;
|
|
320
347
|
list.textContent = '';
|
|
321
348
|
list.setAttribute('aria-multiselectable', multiple() ? 'true' : 'false');
|
|
322
349
|
list.setAttribute('aria-label', str(p.title, kitText('soma.kit.select_record', undefined, root)));
|
|
323
350
|
const loading = bool(p.loading);
|
|
324
351
|
const failure = loading ? '' : str(p.error_text);
|
|
325
352
|
list.setAttribute('aria-busy', loading ? 'true' : 'false');
|
|
353
|
+
// 数据状态自报在候选列表框上(组件根只是触发器,列表在弹窗里)
|
|
354
|
+
kitMarkDataFacts(list, { error: failure !== '', loading, empty: shown.length === 0 });
|
|
326
355
|
if (failure !== '') {
|
|
327
356
|
const alert = mk('div', EMPTY_CLASS, failure);
|
|
328
357
|
alert.setAttribute('role', 'alert');
|
|
@@ -333,6 +362,8 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
333
362
|
if (loading || failure === '') {
|
|
334
363
|
const empty = mk('div', EMPTY_CLASS, loading ? kitText('soma.kit.loading', undefined, root) : str(p.empty_text, kitText('soma.kit.empty_match', undefined, root)));
|
|
335
364
|
empty.setAttribute('role', 'status');
|
|
365
|
+
// 空 / 加载提示块 = 子块(与 emptyNode 同口径)
|
|
366
|
+
kitMarkLevel(empty, 'sub'); kitApplyLevelClass(empty);
|
|
336
367
|
list.appendChild(empty);
|
|
337
368
|
}
|
|
338
369
|
} else {
|
|
@@ -343,7 +374,7 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
343
374
|
// 重试后的焦点归还:只在焦点落在 body / null / 列表框本身时发生,不抢走用户当前的焦点
|
|
344
375
|
const doc = list.ownerDocument;
|
|
345
376
|
const idle = doc.activeElement === null || doc.activeElement === doc.body || doc.activeElement === list;
|
|
346
|
-
const retryBtn = list.querySelector<HTMLElement>('
|
|
377
|
+
const retryBtn = list.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_ACTION, 'retry'));
|
|
347
378
|
if (retryBtn !== null && (retryHadFocus || (retryFocusPending && idle))) {
|
|
348
379
|
retryBtn.focus({ preventScroll: true });
|
|
349
380
|
retryFocusPending = false;
|
|
@@ -396,7 +427,8 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
396
427
|
closeLabel: str(p.cancel_text, kitText('soma.kit.cancel', undefined, root)),
|
|
397
428
|
at: root,
|
|
398
429
|
onClose: () => { m.close(); },
|
|
399
|
-
|
|
430
|
+
// 选择窗口带搜索输入:不因点击遮罩关闭(KT-K-overlay-2)
|
|
431
|
+
dismissOnScrim: false,
|
|
400
432
|
footer: true,
|
|
401
433
|
});
|
|
402
434
|
const row = mk('div', SEARCH_ROW);
|
|
@@ -420,7 +452,7 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
420
452
|
m.body.append(row, box, count);
|
|
421
453
|
m.footer.append(
|
|
422
454
|
actionButton({ key: 'cancel', label: str(p.cancel_text, kitText('soma.kit.cancel', undefined, root)), tone: 'neutral', disabled: false, reason: '' }),
|
|
423
|
-
actionButton({ key: 'confirm', label: str(p.confirm_text, kitText('soma.kit.ok', undefined, root)),
|
|
455
|
+
actionButton({ key: 'confirm', label: str(p.confirm_text, kitText('soma.kit.ok', undefined, root)), fn: 'confirm', disabled: false, reason: '' }),
|
|
424
456
|
);
|
|
425
457
|
|
|
426
458
|
let lastKeyword = '';
|
|
@@ -442,12 +474,12 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
442
474
|
};
|
|
443
475
|
const onClick = (event: Event): void => {
|
|
444
476
|
const t = event.target as HTMLElement | null;
|
|
445
|
-
const act = t?.closest<HTMLElement>(
|
|
477
|
+
const act = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_ACTION))?.getAttribute(KIT_ATTR_ACTION);
|
|
446
478
|
if (act === 'confirm') { confirm(); return; }
|
|
447
479
|
if (act === 'cancel') { closeModal(); return; }
|
|
448
480
|
if (act === 'search') { emitSearch(); return; }
|
|
449
481
|
if (act === 'retry') { api.emit('search', { keyword: lastKeyword }); return; }
|
|
450
|
-
const key = t?.closest<HTMLElement>(
|
|
482
|
+
const key = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY))?.getAttribute(KIT_ATTR_KEY);
|
|
451
483
|
if (key) toggle(key);
|
|
452
484
|
};
|
|
453
485
|
input.addEventListener('input', onInput);
|
|
@@ -489,6 +521,7 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
489
521
|
trigger.type = 'button';
|
|
490
522
|
// 带边框的选择触发器,读起来是输入框(同 Select 触发器),标 field
|
|
491
523
|
setKitFace(trigger, 'field');
|
|
524
|
+
kitMarkPart(trigger, 'control');
|
|
492
525
|
trigger.setAttribute('aria-haspopup', 'dialog');
|
|
493
526
|
triggerText = mk('span', TRIGGER_TEXT);
|
|
494
527
|
const caret = mk('span', TRIGGER_CARET, '');
|
package/src/data/redirect.ts
CHANGED
|
@@ -8,13 +8,21 @@
|
|
|
8
8
|
// 参考 web-admin-shell 的 AppRouteRedirect(替换它)。
|
|
9
9
|
|
|
10
10
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
11
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
12
|
+
import { kitLocaleAt } from '../i18n/kit-text';
|
|
13
|
+
import { mergeClass } from '../shared/merge-class';
|
|
14
|
+
import { KIT_ATTR_CONTAINER, KIT_ATTR_REDIRECT_BLOCKED } from '../shared/dom-attrs';
|
|
11
15
|
import { CLASS_PROP, createKitController, joinClass, str } from '../base/shared';
|
|
12
16
|
|
|
13
|
-
const ROOT_CLASS = 'flex flex-col gap-2 text-sm text-fg-muted';
|
|
14
|
-
const LINK_CLASS =
|
|
17
|
+
const ROOT_CLASS = 'flex flex-col gap-2 p-card text-sm text-fg-muted';
|
|
18
|
+
const LINK_CLASS = mergeClass(
|
|
19
|
+
'w-fit rounded-control text-sm text-primary-on-soft underline underline-offset-2 transition-opacity hover:opacity-80 active:opacity-70',
|
|
20
|
+
KIT_FOCUS_RING.button,
|
|
21
|
+
);
|
|
22
|
+
const BLOCKED_CLASS = 'rounded-item bg-danger-soft px-3 py-2 text-danger-on-soft';
|
|
15
23
|
|
|
16
24
|
export const KIT_REDIRECT_CLASS_CANDIDATES: readonly string[] = Object.freeze([...new Set([
|
|
17
|
-
ROOT_CLASS, LINK_CLASS,
|
|
25
|
+
ROOT_CLASS, LINK_CLASS, BLOCKED_CLASS,
|
|
18
26
|
].flatMap((s) => s.split(/\s+/).filter((c) => c !== '')))].sort());
|
|
19
27
|
|
|
20
28
|
/** 只收站内绝对路径(单个 / 开头,不是 // 、不含反斜杠 / 控制字符);其余返回 ''(纯函数,便于单测) */
|
|
@@ -71,28 +79,43 @@ export function createKitRedirect(): SomaComponentDefinition {
|
|
|
71
79
|
class: CLASS_PROP,
|
|
72
80
|
},
|
|
73
81
|
},
|
|
74
|
-
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}" aria-live="polite"></section>`,
|
|
82
|
+
templateHtml: `<section ${KIT_ATTR_CONTAINER}="card" data-soma-id="root" class="${ROOT_CLASS}" aria-live="polite"></section>`,
|
|
75
83
|
controllerFactory: createKitController((api) => {
|
|
76
|
-
//
|
|
77
|
-
let
|
|
84
|
+
// 同一实例内对同一合法最终目标幂等跳转一次,同时支持异步晚到的 to 属性
|
|
85
|
+
let lastRedirectedTarget = '';
|
|
86
|
+
const tryRedirect = (rootEl: HTMLElement, p: Record<string, unknown>): void => {
|
|
87
|
+
const win = rootEl.ownerDocument.defaultView;
|
|
88
|
+
if (!win) return;
|
|
89
|
+
const target = redirectHref(str(p.to), queryOf(p), win.location.search ?? '', win.location.hash ?? '');
|
|
90
|
+
if (target === '' || target === lastRedirectedTarget) return;
|
|
91
|
+
lastRedirectedTarget = target;
|
|
92
|
+
if (p.replace === false || p.replace === 'false') win.location.assign(target);
|
|
93
|
+
else win.location.replace(target);
|
|
94
|
+
};
|
|
78
95
|
return {
|
|
79
|
-
attach(
|
|
80
|
-
|
|
81
|
-
const p = api.props();
|
|
82
|
-
const target = redirectHref(str(p.to), queryOf(p), win?.location.search ?? '', win?.location.hash ?? '');
|
|
83
|
-
if (!win || done || target === '') return;
|
|
84
|
-
done = true;
|
|
85
|
-
if (p.replace === false || p.replace === 'false') win.location.assign(target);
|
|
86
|
-
else win.location.replace(target);
|
|
96
|
+
attach(root) {
|
|
97
|
+
tryRedirect(root, api.props());
|
|
87
98
|
},
|
|
88
99
|
render(root, p) {
|
|
89
100
|
const doc = root.ownerDocument;
|
|
90
101
|
const win = doc.defaultView;
|
|
91
|
-
const
|
|
102
|
+
const rawTo = str(p.to).trim();
|
|
103
|
+
const safe = safeRedirectTarget(rawTo);
|
|
104
|
+
const blocked = rawTo !== '' && safe === '';
|
|
92
105
|
// 兜底链接带上运行期透传的 query(脚本跳转前可见,也是点击兜底)
|
|
93
106
|
const href = safe === '' ? '' : redirectHref(safe, queryOf(p), win?.location.search ?? '', win?.location.hash ?? '') || safe;
|
|
94
107
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
95
108
|
const msg = doc.createElement('p');
|
|
109
|
+
if (blocked) {
|
|
110
|
+
msg.className = BLOCKED_CLASS;
|
|
111
|
+
msg.setAttribute(KIT_ATTR_REDIRECT_BLOCKED, '');
|
|
112
|
+
const defaultBlockedText = kitLocaleAt(root).startsWith('en')
|
|
113
|
+
? 'Redirect blocked: invalid or external target path.'
|
|
114
|
+
: '跳转已阻断:目标地址不合法,仅允许站内路径。';
|
|
115
|
+
msg.textContent = str(p.message) || defaultBlockedText;
|
|
116
|
+
root.replaceChildren(msg);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
96
119
|
msg.textContent = str(p.message);
|
|
97
120
|
root.replaceChildren(msg);
|
|
98
121
|
if (href !== '') {
|
|
@@ -102,6 +125,7 @@ export function createKitRedirect(): SomaComponentDefinition {
|
|
|
102
125
|
a.textContent = str(p.linkLabel) || href; // 链接不能没有可访问名
|
|
103
126
|
root.appendChild(a);
|
|
104
127
|
}
|
|
128
|
+
tryRedirect(root, p);
|
|
105
129
|
},
|
|
106
130
|
};
|
|
107
131
|
}),
|
|
@@ -10,36 +10,55 @@
|
|
|
10
10
|
// 事件:`change { method, target, params }`(切方法 / 选目标 / 参数框 change),`run { method, target, params }`(params 已解析成对象;
|
|
11
11
|
// 不是合法 JSON 对象则不抛 run,改抛 `invalid { message }`)。组件不发请求,结果由页面下行。
|
|
12
12
|
|
|
13
|
+
import { kitApplyLevelClass } from './level-class';
|
|
13
14
|
import type { SomaComponentDefinition, SomaDataPort } from 'soma-core';
|
|
14
15
|
import { KIT_DATA_LIMITS } from 'soma-foundation/kit-limits';
|
|
15
16
|
import { kitText } from '../i18n/kit-text';
|
|
16
17
|
import { setKitFace } from '../recipes';
|
|
18
|
+
import { kitFieldNameRecipe } from '../recipes/field-text';
|
|
19
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
20
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
21
|
+
import { mergeClass } from '../shared/merge-class';
|
|
22
|
+
|
|
23
|
+
/** 多行输入的边 = 控件轮廓出口(KT-B1 / §4 C6) */
|
|
24
|
+
const AREA_EDGE = kitControlEdgeRecipe();
|
|
25
|
+
import { kitTabRecipe } from '../recipes/tabs';
|
|
17
26
|
import { pickPath } from '../object-renderer/path-pick';
|
|
18
27
|
import { watchKitOutcome, type KitOutcome } from './outcome-watch';
|
|
19
|
-
import { bool, createKitController, FIELD_CLASS, joinClass, str } from '../base/shared';
|
|
28
|
+
import { bool, createKitController, FIELD_CLASS, joinClass, nextUid, reconcileKeyedElements, str } from '../base/shared';
|
|
20
29
|
import {
|
|
21
30
|
actionButton, BADGE_BASE, BUTTON_CLASS_TOKENS, classTokens, mk, recOf, rowsOf, shapeToneOf, textOf, TONE_SOFT,
|
|
22
31
|
} from './shape-util';
|
|
23
32
|
import { codeTextOf, KIT_CODE_PRE_CLASS } from './code-view';
|
|
24
|
-
import { attrEsc } from './d9-util';
|
|
25
33
|
import { KIT_BUSY_PROP_DEFS, kitBusyOf } from '../base/action-busy';
|
|
26
34
|
import { mountKitSelectField, type KitSelectField } from './embed';
|
|
35
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked } from './kit-contract';
|
|
36
|
+
import { KIT_ATTR_ACTION, KIT_ATTR_CONTAINER, KIT_ATTR_INVALID_MSG, KIT_ATTR_PARAMS, KIT_ATTR_RESULT, KIT_ATTR_TARGET, KIT_ATTR_VALUE, kitAttrSel } from '../shared/dom-attrs';
|
|
27
37
|
|
|
28
38
|
const ROOT_CLASS = 'flex flex-col gap-3';
|
|
29
39
|
const TITLE_CLASS = 'text-sm font-semibold text-fg';
|
|
30
40
|
const HINT_CLASS = 'text-xs text-fg-subtle';
|
|
31
41
|
const ROW_CLASS = 'flex flex-wrap items-center gap-2';
|
|
42
|
+
// 方法切换器采用分段控件样式(中性浮起选中态),避免与下方主操作按钮堆叠多枚实心蓝底按钮
|
|
43
|
+
const METHOD_TAB = kitTabRecipe();
|
|
44
|
+
const METHOD_GROUP_CLASS = METHOD_TAB.segRoot;
|
|
45
|
+
const METHOD_ITEM_ON = METHOD_TAB.segItem.md.on;
|
|
46
|
+
const METHOD_ITEM_IDLE = METHOD_TAB.segItem.md.idle;
|
|
32
47
|
const FIELD_WRAP = 'flex flex-col gap-1';
|
|
33
|
-
const LABEL_CLASS =
|
|
34
|
-
const AREA_CLASS = 'block w-full appearance-none autofill-clear resize-none rounded-
|
|
48
|
+
const LABEL_CLASS = kitFieldNameRecipe();
|
|
49
|
+
const AREA_CLASS = 'block w-full appearance-none autofill-clear resize-none rounded-control ' + AREA_EDGE + ' bg-surface px-3 py-2 font-mono text-sm text-fg transition-colors placeholder:text-fg-subtle ' + KIT_FOCUS_RING.control + ' disabled:cursor-not-allowed disabled:bg-control-disabled disabled:text-fg-disabled aria-invalid:border-danger';
|
|
35
50
|
const RESULT_CLASS = 'flex flex-col gap-2';
|
|
36
|
-
const
|
|
51
|
+
const RESULT_BAR_CLASS = 'flex flex-wrap items-center justify-between gap-2';
|
|
52
|
+
const RESULT_BADGE_CLASS = mergeClass(BADGE_BASE, 'tabular-nums');
|
|
53
|
+
const COPY_AUTO_CLASS = 'ms-auto';
|
|
54
|
+
const ERROR_CLASS = 'rounded-item bg-danger-soft px-3 py-2 text-sm text-danger-on-soft';
|
|
37
55
|
// 响应体与 CodeView 同一块基准样式,只多一个高度档
|
|
38
56
|
const BODY_CLASS = `${KIT_CODE_PRE_CLASS} max-h-80 overflow-y-auto`;
|
|
39
57
|
const NOTE_CLASS = 'break-all font-mono text-xs text-fg-muted';
|
|
40
58
|
|
|
41
59
|
export const KIT_REQUEST_CONSOLE_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
42
|
-
ROOT_CLASS, TITLE_CLASS, HINT_CLASS, ROW_CLASS,
|
|
60
|
+
ROOT_CLASS, TITLE_CLASS, HINT_CLASS, ROW_CLASS, METHOD_GROUP_CLASS, METHOD_ITEM_ON, METHOD_ITEM_IDLE, FIELD_WRAP, LABEL_CLASS, AREA_CLASS,
|
|
61
|
+
RESULT_CLASS, RESULT_BAR_CLASS, RESULT_BADGE_CLASS, COPY_AUTO_CLASS, ERROR_CLASS, BODY_CLASS, NOTE_CLASS,
|
|
43
62
|
BADGE_BASE, Object.values(TONE_SOFT), BUTTON_CLASS_TOKENS, FIELD_CLASS.md,
|
|
44
63
|
);
|
|
45
64
|
|
|
@@ -117,6 +136,9 @@ interface ConsoleState {
|
|
|
117
136
|
given: { method: string; target: string; params: string };
|
|
118
137
|
nodes: { head: HTMLElement; seg: HTMLElement; targetWrap: HTMLElement; paramsWrap: HTMLElement; run: HTMLElement; result: HTMLElement } | null;
|
|
119
138
|
invalid: string;
|
|
139
|
+
errId: string;
|
|
140
|
+
lastBody: string;
|
|
141
|
+
copyTimer: ReturnType<typeof setTimeout> | null;
|
|
120
142
|
/** targets_from.outcome:订阅的范围名、退订、最近一次结果 */
|
|
121
143
|
outName: string;
|
|
122
144
|
offOutcome: (() => void) | null;
|
|
@@ -128,7 +150,12 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
128
150
|
const stateOf = (root: HTMLElement): ConsoleState => {
|
|
129
151
|
let s = states.get(root);
|
|
130
152
|
if (!s) {
|
|
131
|
-
s = {
|
|
153
|
+
s = {
|
|
154
|
+
method: '', target: '', area: null, select: null, selectSig: '',
|
|
155
|
+
given: { method: '\u0000', target: '\u0000', params: '\u0000' },
|
|
156
|
+
nodes: null, invalid: '', errId: nextUid('kit-rc-err'), lastBody: '', copyTimer: null,
|
|
157
|
+
outName: '', offOutcome: null, outcome: null,
|
|
158
|
+
};
|
|
132
159
|
states.set(root, s);
|
|
133
160
|
}
|
|
134
161
|
return s;
|
|
@@ -164,7 +191,7 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
164
191
|
},
|
|
165
192
|
},
|
|
166
193
|
services: ['data'],
|
|
167
|
-
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
194
|
+
templateHtml: `<section ${KIT_ATTR_CONTAINER}="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
168
195
|
controllerFactory: createKitController(() => ({
|
|
169
196
|
busyAware: true,
|
|
170
197
|
attach(root, api) {
|
|
@@ -173,17 +200,28 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
173
200
|
return { method: st.method, target: st.target, params: st.area?.value ?? '' };
|
|
174
201
|
};
|
|
175
202
|
const onClick = (event: Event): void => {
|
|
176
|
-
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(
|
|
203
|
+
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION));
|
|
177
204
|
if (!btn || btn.disabled) return;
|
|
178
205
|
const st = stateOf(root);
|
|
179
|
-
const key = btn.getAttribute(
|
|
206
|
+
const key = btn.getAttribute(KIT_ATTR_ACTION);
|
|
180
207
|
if (key === 'method') {
|
|
181
|
-
st.method = btn.getAttribute(
|
|
208
|
+
st.method = btn.getAttribute(KIT_ATTR_VALUE) ?? '';
|
|
182
209
|
st.invalid = '';
|
|
183
210
|
paint(root, api.props());
|
|
184
|
-
// 切换条整排重建,焦点回到同一个方法钮上
|
|
185
|
-
root.querySelector<HTMLElement>(`[data-kit-action="method"][data-kit-value="${attrEsc(st.method)}"]`)?.focus();
|
|
186
211
|
api.emit('change', snapshot());
|
|
212
|
+
} else if (key === 'copy') {
|
|
213
|
+
const clip = typeof navigator !== 'undefined' ? navigator.clipboard : undefined;
|
|
214
|
+
if (clip && typeof clip.writeText === 'function' && st.lastBody !== '') {
|
|
215
|
+
void clip.writeText(st.lastBody).then(() => {
|
|
216
|
+
if (!btn.isConnected) return;
|
|
217
|
+
btn.textContent = kitText('soma.kit.copied', undefined, root);
|
|
218
|
+
if (st.copyTimer !== null) clearTimeout(st.copyTimer);
|
|
219
|
+
st.copyTimer = setTimeout(() => {
|
|
220
|
+
st.copyTimer = null;
|
|
221
|
+
if (btn.isConnected) btn.textContent = kitText('soma.kit.copy', undefined, root);
|
|
222
|
+
}, 1500);
|
|
223
|
+
}, () => undefined);
|
|
224
|
+
}
|
|
187
225
|
} else if (key === 'run') {
|
|
188
226
|
const s = snapshot();
|
|
189
227
|
const params = parseConsoleParams(s.params);
|
|
@@ -200,21 +238,34 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
200
238
|
api.emit('run', { method: s.method, target: s.target, params });
|
|
201
239
|
}
|
|
202
240
|
};
|
|
241
|
+
const onInput = (event: Event): void => {
|
|
242
|
+
const el = event.target as HTMLElement | null;
|
|
243
|
+
const st = stateOf(root);
|
|
244
|
+
if (!el || !el.hasAttribute(KIT_ATTR_PARAMS) || st.invalid === '') return;
|
|
245
|
+
st.invalid = '';
|
|
246
|
+
st.area?.removeAttribute('aria-invalid');
|
|
247
|
+
st.area?.removeAttribute('aria-describedby');
|
|
248
|
+
st.nodes?.run.querySelector(kitAttrSel(KIT_ATTR_INVALID_MSG))?.remove();
|
|
249
|
+
};
|
|
203
250
|
const onChange = (event: Event): void => {
|
|
204
251
|
const el = event.target as (HTMLInputElement | HTMLTextAreaElement) | null;
|
|
205
252
|
const st = stateOf(root);
|
|
206
253
|
if (!el) return;
|
|
207
|
-
if (el.hasAttribute(
|
|
208
|
-
else if (!el.hasAttribute(
|
|
254
|
+
if (el.hasAttribute(KIT_ATTR_TARGET)) st.target = el.value;
|
|
255
|
+
else if (!el.hasAttribute(KIT_ATTR_PARAMS)) return;
|
|
209
256
|
api.emit('change', snapshot());
|
|
210
257
|
};
|
|
211
258
|
root.addEventListener('click', onClick);
|
|
259
|
+
root.addEventListener('input', onInput);
|
|
212
260
|
root.addEventListener('change', onChange);
|
|
213
261
|
return () => {
|
|
214
262
|
root.removeEventListener('click', onClick);
|
|
263
|
+
root.removeEventListener('input', onInput);
|
|
215
264
|
root.removeEventListener('change', onChange);
|
|
216
|
-
states.get(root)
|
|
217
|
-
|
|
265
|
+
const st = states.get(root);
|
|
266
|
+
if (st?.copyTimer !== null && st?.copyTimer !== undefined) clearTimeout(st.copyTimer);
|
|
267
|
+
st?.select?.dispose();
|
|
268
|
+
st?.offOutcome?.();
|
|
218
269
|
states.delete(root);
|
|
219
270
|
};
|
|
220
271
|
},
|
|
@@ -271,6 +322,8 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
271
322
|
const paramsWrap = mk('div', '');
|
|
272
323
|
const run = mk('div', '');
|
|
273
324
|
const result = mk('div', '');
|
|
325
|
+
// 一级结构:标题区 = 面头;方法切换、目标、参数、运行行都是面里的控件区,不另设层级;结果框 = 子块(见下)
|
|
326
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
274
327
|
root.append(head, seg, targetWrap, paramsWrap, run, result);
|
|
275
328
|
st.nodes = { head, seg, targetWrap, paramsWrap, run, result };
|
|
276
329
|
}
|
|
@@ -288,23 +341,47 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
288
341
|
|
|
289
342
|
// 标题 / 提示
|
|
290
343
|
n.head.textContent = '';
|
|
291
|
-
if (textOf(data.title) !== '')
|
|
344
|
+
if (textOf(data.title) !== '') {
|
|
345
|
+
const titleEl = mk('h3', TITLE_CLASS, textOf(data.title));
|
|
346
|
+
kitMarkPart(titleEl, 'block-title');
|
|
347
|
+
n.head.appendChild(titleEl);
|
|
348
|
+
}
|
|
292
349
|
if (textOf(data.hint) !== '') n.head.appendChild(mk('p', HINT_CLASS, textOf(data.hint)));
|
|
293
350
|
n.head.hidden = n.head.childNodes.length === 0;
|
|
294
351
|
|
|
295
|
-
//
|
|
296
|
-
n.seg.textContent = '';
|
|
352
|
+
// 方法切换(分段样式 / 原地更新类名保焦点)
|
|
297
353
|
n.seg.hidden = methods.length === 0;
|
|
298
|
-
if (methods.length
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
354
|
+
if (methods.length === 0) {
|
|
355
|
+
n.seg.textContent = '';
|
|
356
|
+
} else {
|
|
357
|
+
let row = n.seg.firstElementChild as HTMLElement | null;
|
|
358
|
+
if (!row || row.className !== METHOD_GROUP_CLASS) {
|
|
359
|
+
row = mk('div', METHOD_GROUP_CLASS);
|
|
360
|
+
row.setAttribute('role', 'group');
|
|
361
|
+
n.seg.replaceChildren(row);
|
|
306
362
|
}
|
|
307
|
-
|
|
363
|
+
reconcileKeyedElements(
|
|
364
|
+
row,
|
|
365
|
+
methods,
|
|
366
|
+
(m) => m.value,
|
|
367
|
+
(m) => {
|
|
368
|
+
const btn = mk('button', METHOD_ITEM_IDLE, m.label);
|
|
369
|
+
btn.type = 'button';
|
|
370
|
+
btn.setAttribute(KIT_ATTR_ACTION, 'method');
|
|
371
|
+
btn.setAttribute(KIT_ATTR_VALUE, m.value);
|
|
372
|
+
kitMarkPart(btn, 'control');
|
|
373
|
+
return btn;
|
|
374
|
+
},
|
|
375
|
+
(el, m) => {
|
|
376
|
+
const active = m.value === st.method;
|
|
377
|
+
const cls = active ? METHOD_ITEM_ON : METHOD_ITEM_IDLE;
|
|
378
|
+
if (el.className !== cls) el.className = cls;
|
|
379
|
+
if (el.textContent !== m.label) el.textContent = m.label;
|
|
380
|
+
el.setAttribute('aria-pressed', active ? 'true' : 'false');
|
|
381
|
+
// 当前方法自报选中(切换按钮的无障碍属性仍是上一行的 aria-pressed)
|
|
382
|
+
kitMarkPicked(el, 'selected', active, null);
|
|
383
|
+
},
|
|
384
|
+
);
|
|
308
385
|
}
|
|
309
386
|
|
|
310
387
|
// 目标下拉(持久)
|
|
@@ -318,10 +395,9 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
318
395
|
const wrap = mk('div', FIELD_WRAP);
|
|
319
396
|
wrap.appendChild(mk('span', LABEL_CLASS, str(p.target_label, kitText('soma.kit.rc_target', undefined, root))));
|
|
320
397
|
// 自绘下拉(没有原生 <select>):hidden 载体带 data-kit-target,选中后派发冒泡的 change
|
|
321
|
-
st.select?.dispose();
|
|
322
398
|
const opts = targets.length === 0 ? [{ value: '', label: emptyText }] : targets;
|
|
323
399
|
const sel = mountKitSelectField({ options: opts, value: st.target, ariaLabel: str(p.target_label, kitText('soma.kit.rc_target', undefined, root)) });
|
|
324
|
-
sel.input.setAttribute(
|
|
400
|
+
sel.input.setAttribute(KIT_ATTR_TARGET, '');
|
|
325
401
|
wrap.appendChild(sel.el);
|
|
326
402
|
n.targetWrap.appendChild(wrap);
|
|
327
403
|
st.select = sel;
|
|
@@ -339,7 +415,7 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
339
415
|
wrap.appendChild(mk('span', LABEL_CLASS, str(p.params_label, kitText('soma.kit.rc_params', undefined, root))));
|
|
340
416
|
const area = mk('textarea', AREA_CLASS);
|
|
341
417
|
setKitFace(area, 'field');
|
|
342
|
-
area.setAttribute(
|
|
418
|
+
area.setAttribute(KIT_ATTR_PARAMS, '');
|
|
343
419
|
wrap.appendChild(area);
|
|
344
420
|
n.paramsWrap.appendChild(wrap);
|
|
345
421
|
st.area = area;
|
|
@@ -349,16 +425,25 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
349
425
|
st.area.rows = Math.max(1, Math.floor(Number(p.params_rows) || 5));
|
|
350
426
|
st.area.placeholder = str(p.params_placeholder);
|
|
351
427
|
if (paramsChanged) st.area.value = gParams;
|
|
428
|
+
if (st.invalid !== '') {
|
|
429
|
+
st.area.setAttribute('aria-invalid', 'true');
|
|
430
|
+
st.area.setAttribute('aria-describedby', st.errId);
|
|
431
|
+
} else {
|
|
432
|
+
st.area.removeAttribute('aria-invalid');
|
|
433
|
+
st.area.removeAttribute('aria-describedby');
|
|
434
|
+
}
|
|
352
435
|
|
|
353
436
|
// 执行钮 + 校验提示
|
|
354
437
|
n.run.textContent = '';
|
|
355
438
|
const actionBusy = kitBusyOf(p);
|
|
356
439
|
const running = bool(data.running) || actionBusy;
|
|
440
|
+
// 数据状态自报到根:请求在途 = 加载中,回包带错误 = 出错
|
|
441
|
+
kitMarkDataFacts(root, { loading: running, error: (consoleResultOf(data.result)?.error ?? '') !== '' });
|
|
357
442
|
const runRow = mk('div', ROW_CLASS);
|
|
358
443
|
const runBtn = actionButton({
|
|
359
444
|
key: 'run',
|
|
360
445
|
label: running ? str(p.running_label, kitText('soma.kit.rc_running', undefined, root)) : str(p.run_label, kitText('soma.kit.rc_run', undefined, root)),
|
|
361
|
-
|
|
446
|
+
fn: 'apply',
|
|
362
447
|
disabled: running || bool(p.run_disabled),
|
|
363
448
|
reason: '',
|
|
364
449
|
});
|
|
@@ -367,6 +452,8 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
367
452
|
n.run.appendChild(runRow);
|
|
368
453
|
if (st.invalid !== '') {
|
|
369
454
|
const inv = mk('p', ERROR_CLASS, st.invalid);
|
|
455
|
+
inv.id = st.errId;
|
|
456
|
+
inv.setAttribute(KIT_ATTR_INVALID_MSG, '');
|
|
370
457
|
inv.setAttribute('role', 'alert');
|
|
371
458
|
n.run.appendChild(inv);
|
|
372
459
|
}
|
|
@@ -374,14 +461,30 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
374
461
|
// 结果
|
|
375
462
|
n.result.textContent = '';
|
|
376
463
|
const result = consoleResultOf(data.result);
|
|
464
|
+
st.lastBody = result?.body ?? '';
|
|
377
465
|
n.result.hidden = result === null;
|
|
378
466
|
if (result) {
|
|
379
467
|
const box = mk('div', RESULT_CLASS);
|
|
380
|
-
box.setAttribute(
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
468
|
+
box.setAttribute(KIT_ATTR_RESULT, '');
|
|
469
|
+
kitMarkLevel(box, 'sub'); kitApplyLevelClass(box);
|
|
470
|
+
if (result.badges.length > 0 || result.body !== '') {
|
|
471
|
+
const bar = mk('div', RESULT_BAR_CLASS);
|
|
472
|
+
if (result.badges.length > 0) {
|
|
473
|
+
const row = mk('div', ROW_CLASS);
|
|
474
|
+
for (const b of result.badges) row.appendChild(mk('span', `${RESULT_BADGE_CLASS} ${TONE_SOFT[b.tone]}`, b.label));
|
|
475
|
+
bar.appendChild(row);
|
|
476
|
+
}
|
|
477
|
+
if (result.body !== '') {
|
|
478
|
+
const copyBtn = actionButton({
|
|
479
|
+
key: 'copy',
|
|
480
|
+
label: kitText('soma.kit.copy', undefined, root),
|
|
481
|
+
tone: 'neutral',
|
|
482
|
+
disabled: false,
|
|
483
|
+
reason: '',
|
|
484
|
+
}, COPY_AUTO_CLASS);
|
|
485
|
+
bar.appendChild(copyBtn);
|
|
486
|
+
}
|
|
487
|
+
box.appendChild(bar);
|
|
385
488
|
}
|
|
386
489
|
if (result.error !== '') {
|
|
387
490
|
const err = mk('p', ERROR_CLASS, result.error);
|