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
|
@@ -19,18 +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 { 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';
|
|
28
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';
|
|
31
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';
|
|
32
37
|
import { actionButton, BUTTON_CLASS_TOKENS, classTokens, keyMap, mk, retryButton, rowsOf, textOf } from './shape-util';
|
|
33
38
|
import { KIT_MODAL_CLASS_CANDIDATES, mountKitModal, type KitModalHandle, type KitModalSize } from './modal-dialog';
|
|
39
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked, kitReadProps } from './kit-contract';
|
|
34
40
|
|
|
35
41
|
// 尺寸闭集读语法,行数 / 选择数上限读 design 的 kit-limits
|
|
36
42
|
const LIMITS = {
|
|
@@ -44,31 +50,37 @@ export const KIT_RECORD_PICKER_DEFAULT_MAP = Object.freeze({ id: 'id', title: 't
|
|
|
44
50
|
// ───────── 样式常量 ─────────
|
|
45
51
|
|
|
46
52
|
const ROOT_CLASS = 'flex items-center gap-2';
|
|
47
|
-
//
|
|
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;
|
|
48
61
|
const FIELD_EDGE = kitControlEdgeRecipe();
|
|
49
|
-
const TRIGGER_CLASS = 'inline-flex h-8 min-w-0 flex-1 items-center justify-between gap-2 rounded-md ' + FIELD_EDGE + ' bg-surface px-3 text-sm text-fg transition-colors state-layer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50';
|
|
50
62
|
const TRIGGER_TEXT = 'min-w-0 truncate text-start';
|
|
51
63
|
const TRIGGER_PLACEHOLDER = 'min-w-0 truncate text-start text-fg-subtle';
|
|
52
64
|
const TRIGGER_CARET = 'shrink-0 text-fg-subtle';
|
|
53
|
-
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 + '';
|
|
54
66
|
const SEARCH_ROW = 'flex items-center gap-2';
|
|
55
|
-
const SEARCH_CLASS = 'block h-8 min-w-0 flex-1 appearance-none autofill-clear rounded-
|
|
56
|
-
const LIST_CLASS = 'flex max-h-80 min-h-24 flex-col gap-1 overflow-y-auto rounded-
|
|
57
|
-
const ITEM_CLASS = 'flex cursor-pointer items-center gap-2 rounded-
|
|
58
|
-
const ITEM_ON_CLASS = 'flex cursor-pointer items-center gap-2 rounded-
|
|
59
|
-
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
|
|
60
72
|
const CURSOR_CLASS = 'ring-2 ring-ring';
|
|
61
73
|
const MARK_CLASS = 'w-4 shrink-0 text-primary-on-soft';
|
|
62
74
|
const TEXT_CLASS = 'flex min-w-0 flex-1 flex-col';
|
|
63
75
|
const SUB_CLASS = 'truncate text-xs text-fg-muted';
|
|
64
76
|
const EMPTY_CLASS = 'px-2 py-3 text-sm text-fg-muted';
|
|
65
|
-
const COUNT_CLASS = 'text-xs text-fg-subtle';
|
|
66
|
-
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';
|
|
67
79
|
|
|
68
80
|
export const KIT_RECORD_PICKER_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
69
|
-
ROOT_CLASS,
|
|
81
|
+
ROOT_CLASS, Object.values(TRIGGER_BY_SIZE), TRIGGER_TEXT, TRIGGER_PLACEHOLDER, TRIGGER_CARET, CLEAR_CLASS, SEARCH_ROW, SEARCH_CLASS, LIST_CLASS,
|
|
70
82
|
ITEM_CLASS, ITEM_ON_CLASS, ITEM_OFF_CLASS, CURSOR_CLASS, MARK_CLASS, TEXT_CLASS, SUB_CLASS, EMPTY_CLASS, COUNT_CLASS, LIMIT_CLASS,
|
|
71
|
-
BUTTON_CLASS_TOKENS, KIT_MODAL_CLASS_CANDIDATES,
|
|
83
|
+
BUTTON_CLASS_TOKENS, KIT_MODAL_CLASS_CANDIDATES, KIT_CHECK_CLASS_CANDIDATES,
|
|
72
84
|
);
|
|
73
85
|
|
|
74
86
|
// ───────── 数据规整(纯函数) ─────────
|
|
@@ -233,6 +245,8 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
233
245
|
if (!root || !trigger || !triggerText || !clearBox) return;
|
|
234
246
|
const p = P();
|
|
235
247
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
248
|
+
// 控件高度档:页面自己写了 size 以它为准;没写时读页面线布局写的 controlSize(同一条带里控件同高),都没有取中
|
|
249
|
+
trigger.className = TRIGGER_BY_SIZE[sizeOf(p.size ?? kitReadProps(p).controlSize)];
|
|
236
250
|
const text = summary();
|
|
237
251
|
triggerText.textContent = text === '' ? str(p.placeholder, kitText('soma.kit.please_select', undefined, root)) : text;
|
|
238
252
|
triggerText.className = text === '' ? TRIGGER_PLACEHOLDER : TRIGGER_TEXT;
|
|
@@ -241,7 +255,7 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
241
255
|
else trigger.removeAttribute('aria-label');
|
|
242
256
|
// 作表单字段:触发钮接 id(label for / 点标签聚焦),根承载字段名 / 说明 / 错误关联与无效标记
|
|
243
257
|
setAttr(trigger, 'id', str(p.id));
|
|
244
|
-
applyCompositeField(root, p);
|
|
258
|
+
applyCompositeField(root, p, [trigger]);
|
|
245
259
|
const clearBtn = clearBox.firstElementChild as HTMLButtonElement | null;
|
|
246
260
|
if (clearBtn) clearBtn.textContent = str(p.clear_text, kitText('soma.kit.clear', undefined, root));
|
|
247
261
|
clearBox.hidden = !(bool(p.clearable) && committed.length > 0 && !bool(p.disabled));
|
|
@@ -298,15 +312,25 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
298
312
|
if (cursor === r.id) row.className = `${row.className} ${CURSOR_CLASS}`;
|
|
299
313
|
row.id = optionId(r.id);
|
|
300
314
|
row.setAttribute('role', 'option');
|
|
301
|
-
row.setAttribute(
|
|
302
|
-
|
|
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);
|
|
303
319
|
if (r.disabled) row.setAttribute('aria-disabled', 'true');
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
+
}
|
|
308
330
|
const text = mk('span', TEXT_CLASS);
|
|
309
|
-
|
|
331
|
+
const title = mk('span', '', r.title);
|
|
332
|
+
kitMarkPart(title, 'value');
|
|
333
|
+
text.appendChild(title);
|
|
310
334
|
if (r.sub !== '' && r.sub !== r.title) text.appendChild(mk('span', SUB_CLASS, r.sub));
|
|
311
335
|
if (r.facts.length > 0) text.appendChild(mk('span', SUB_CLASS, r.facts.map((f) => `${f.label}:${f.value}`).join(' ')));
|
|
312
336
|
row.appendChild(text);
|
|
@@ -319,13 +343,15 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
319
343
|
const shown = view();
|
|
320
344
|
if (cursor !== null && !shown.some((r) => r.id === cursor)) cursor = null;
|
|
321
345
|
// 键盘点「重试」后列表整体重画、重试钮被销毁,焦点会掉到 body(Tab 陷阱挂在遮罩上,从 body 发出的 Tab 拦不住):重画前记下
|
|
322
|
-
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;
|
|
323
347
|
list.textContent = '';
|
|
324
348
|
list.setAttribute('aria-multiselectable', multiple() ? 'true' : 'false');
|
|
325
349
|
list.setAttribute('aria-label', str(p.title, kitText('soma.kit.select_record', undefined, root)));
|
|
326
350
|
const loading = bool(p.loading);
|
|
327
351
|
const failure = loading ? '' : str(p.error_text);
|
|
328
352
|
list.setAttribute('aria-busy', loading ? 'true' : 'false');
|
|
353
|
+
// 数据状态自报在候选列表框上(组件根只是触发器,列表在弹窗里)
|
|
354
|
+
kitMarkDataFacts(list, { error: failure !== '', loading, empty: shown.length === 0 });
|
|
329
355
|
if (failure !== '') {
|
|
330
356
|
const alert = mk('div', EMPTY_CLASS, failure);
|
|
331
357
|
alert.setAttribute('role', 'alert');
|
|
@@ -336,6 +362,8 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
336
362
|
if (loading || failure === '') {
|
|
337
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)));
|
|
338
364
|
empty.setAttribute('role', 'status');
|
|
365
|
+
// 空 / 加载提示块 = 子块(与 emptyNode 同口径)
|
|
366
|
+
kitMarkLevel(empty, 'sub'); kitApplyLevelClass(empty);
|
|
339
367
|
list.appendChild(empty);
|
|
340
368
|
}
|
|
341
369
|
} else {
|
|
@@ -346,7 +374,7 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
346
374
|
// 重试后的焦点归还:只在焦点落在 body / null / 列表框本身时发生,不抢走用户当前的焦点
|
|
347
375
|
const doc = list.ownerDocument;
|
|
348
376
|
const idle = doc.activeElement === null || doc.activeElement === doc.body || doc.activeElement === list;
|
|
349
|
-
const retryBtn = list.querySelector<HTMLElement>('
|
|
377
|
+
const retryBtn = list.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_ACTION, 'retry'));
|
|
350
378
|
if (retryBtn !== null && (retryHadFocus || (retryFocusPending && idle))) {
|
|
351
379
|
retryBtn.focus({ preventScroll: true });
|
|
352
380
|
retryFocusPending = false;
|
|
@@ -424,7 +452,7 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
424
452
|
m.body.append(row, box, count);
|
|
425
453
|
m.footer.append(
|
|
426
454
|
actionButton({ key: 'cancel', label: str(p.cancel_text, kitText('soma.kit.cancel', undefined, root)), tone: 'neutral', disabled: false, reason: '' }),
|
|
427
|
-
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: '' }),
|
|
428
456
|
);
|
|
429
457
|
|
|
430
458
|
let lastKeyword = '';
|
|
@@ -446,12 +474,12 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
446
474
|
};
|
|
447
475
|
const onClick = (event: Event): void => {
|
|
448
476
|
const t = event.target as HTMLElement | null;
|
|
449
|
-
const act = t?.closest<HTMLElement>(
|
|
477
|
+
const act = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_ACTION))?.getAttribute(KIT_ATTR_ACTION);
|
|
450
478
|
if (act === 'confirm') { confirm(); return; }
|
|
451
479
|
if (act === 'cancel') { closeModal(); return; }
|
|
452
480
|
if (act === 'search') { emitSearch(); return; }
|
|
453
481
|
if (act === 'retry') { api.emit('search', { keyword: lastKeyword }); return; }
|
|
454
|
-
const key = t?.closest<HTMLElement>(
|
|
482
|
+
const key = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_KEY))?.getAttribute(KIT_ATTR_KEY);
|
|
455
483
|
if (key) toggle(key);
|
|
456
484
|
};
|
|
457
485
|
input.addEventListener('input', onInput);
|
|
@@ -493,6 +521,7 @@ export function createRecordPicker(): SomaComponentDefinition {
|
|
|
493
521
|
trigger.type = 'button';
|
|
494
522
|
// 带边框的选择触发器,读起来是输入框(同 Select 触发器),标 field
|
|
495
523
|
setKitFace(trigger, 'field');
|
|
524
|
+
kitMarkPart(trigger, 'control');
|
|
496
525
|
trigger.setAttribute('aria-haspopup', 'dialog');
|
|
497
526
|
triggerText = mk('span', TRIGGER_TEXT);
|
|
498
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
|
|
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,25 +10,30 @@
|
|
|
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';
|
|
17
20
|
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
21
|
+
import { mergeClass } from '../shared/merge-class';
|
|
18
22
|
|
|
19
23
|
/** 多行输入的边 = 控件轮廓出口(KT-B1 / §4 C6) */
|
|
20
24
|
const AREA_EDGE = kitControlEdgeRecipe();
|
|
21
25
|
import { kitTabRecipe } from '../recipes/tabs';
|
|
22
26
|
import { pickPath } from '../object-renderer/path-pick';
|
|
23
27
|
import { watchKitOutcome, type KitOutcome } from './outcome-watch';
|
|
24
|
-
import { bool, createKitController, FIELD_CLASS, joinClass, str } from '../base/shared';
|
|
28
|
+
import { bool, createKitController, FIELD_CLASS, joinClass, nextUid, reconcileKeyedElements, str } from '../base/shared';
|
|
25
29
|
import {
|
|
26
30
|
actionButton, BADGE_BASE, BUTTON_CLASS_TOKENS, classTokens, mk, recOf, rowsOf, shapeToneOf, textOf, TONE_SOFT,
|
|
27
31
|
} from './shape-util';
|
|
28
32
|
import { codeTextOf, KIT_CODE_PRE_CLASS } from './code-view';
|
|
29
|
-
import { attrEsc } from './d9-util';
|
|
30
33
|
import { KIT_BUSY_PROP_DEFS, kitBusyOf } from '../base/action-busy';
|
|
31
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';
|
|
32
37
|
|
|
33
38
|
const ROOT_CLASS = 'flex flex-col gap-3';
|
|
34
39
|
const TITLE_CLASS = 'text-sm font-semibold text-fg';
|
|
@@ -40,16 +45,20 @@ const METHOD_GROUP_CLASS = METHOD_TAB.segRoot;
|
|
|
40
45
|
const METHOD_ITEM_ON = METHOD_TAB.segItem.md.on;
|
|
41
46
|
const METHOD_ITEM_IDLE = METHOD_TAB.segItem.md.idle;
|
|
42
47
|
const FIELD_WRAP = 'flex flex-col gap-1';
|
|
43
|
-
const LABEL_CLASS =
|
|
44
|
-
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';
|
|
45
50
|
const RESULT_CLASS = 'flex flex-col gap-2';
|
|
46
|
-
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';
|
|
47
55
|
// 响应体与 CodeView 同一块基准样式,只多一个高度档
|
|
48
56
|
const BODY_CLASS = `${KIT_CODE_PRE_CLASS} max-h-80 overflow-y-auto`;
|
|
49
57
|
const NOTE_CLASS = 'break-all font-mono text-xs text-fg-muted';
|
|
50
58
|
|
|
51
59
|
export const KIT_REQUEST_CONSOLE_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
52
|
-
ROOT_CLASS, TITLE_CLASS, HINT_CLASS, ROW_CLASS, METHOD_GROUP_CLASS, METHOD_ITEM_ON, METHOD_ITEM_IDLE, FIELD_WRAP, LABEL_CLASS, AREA_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,
|
|
53
62
|
BADGE_BASE, Object.values(TONE_SOFT), BUTTON_CLASS_TOKENS, FIELD_CLASS.md,
|
|
54
63
|
);
|
|
55
64
|
|
|
@@ -127,6 +136,9 @@ interface ConsoleState {
|
|
|
127
136
|
given: { method: string; target: string; params: string };
|
|
128
137
|
nodes: { head: HTMLElement; seg: HTMLElement; targetWrap: HTMLElement; paramsWrap: HTMLElement; run: HTMLElement; result: HTMLElement } | null;
|
|
129
138
|
invalid: string;
|
|
139
|
+
errId: string;
|
|
140
|
+
lastBody: string;
|
|
141
|
+
copyTimer: ReturnType<typeof setTimeout> | null;
|
|
130
142
|
/** targets_from.outcome:订阅的范围名、退订、最近一次结果 */
|
|
131
143
|
outName: string;
|
|
132
144
|
offOutcome: (() => void) | null;
|
|
@@ -138,7 +150,12 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
138
150
|
const stateOf = (root: HTMLElement): ConsoleState => {
|
|
139
151
|
let s = states.get(root);
|
|
140
152
|
if (!s) {
|
|
141
|
-
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
|
+
};
|
|
142
159
|
states.set(root, s);
|
|
143
160
|
}
|
|
144
161
|
return s;
|
|
@@ -174,7 +191,7 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
174
191
|
},
|
|
175
192
|
},
|
|
176
193
|
services: ['data'],
|
|
177
|
-
templateHtml: `<section
|
|
194
|
+
templateHtml: `<section ${KIT_ATTR_CONTAINER}="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
178
195
|
controllerFactory: createKitController(() => ({
|
|
179
196
|
busyAware: true,
|
|
180
197
|
attach(root, api) {
|
|
@@ -183,17 +200,28 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
183
200
|
return { method: st.method, target: st.target, params: st.area?.value ?? '' };
|
|
184
201
|
};
|
|
185
202
|
const onClick = (event: Event): void => {
|
|
186
|
-
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(
|
|
203
|
+
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION));
|
|
187
204
|
if (!btn || btn.disabled) return;
|
|
188
205
|
const st = stateOf(root);
|
|
189
|
-
const key = btn.getAttribute(
|
|
206
|
+
const key = btn.getAttribute(KIT_ATTR_ACTION);
|
|
190
207
|
if (key === 'method') {
|
|
191
|
-
st.method = btn.getAttribute(
|
|
208
|
+
st.method = btn.getAttribute(KIT_ATTR_VALUE) ?? '';
|
|
192
209
|
st.invalid = '';
|
|
193
210
|
paint(root, api.props());
|
|
194
|
-
// 切换条整排重建,焦点回到同一个方法钮上
|
|
195
|
-
root.querySelector<HTMLElement>(`[data-kit-action="method"][data-kit-value="${attrEsc(st.method)}"]`)?.focus();
|
|
196
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
|
+
}
|
|
197
225
|
} else if (key === 'run') {
|
|
198
226
|
const s = snapshot();
|
|
199
227
|
const params = parseConsoleParams(s.params);
|
|
@@ -210,21 +238,34 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
210
238
|
api.emit('run', { method: s.method, target: s.target, params });
|
|
211
239
|
}
|
|
212
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
|
+
};
|
|
213
250
|
const onChange = (event: Event): void => {
|
|
214
251
|
const el = event.target as (HTMLInputElement | HTMLTextAreaElement) | null;
|
|
215
252
|
const st = stateOf(root);
|
|
216
253
|
if (!el) return;
|
|
217
|
-
if (el.hasAttribute(
|
|
218
|
-
else if (!el.hasAttribute(
|
|
254
|
+
if (el.hasAttribute(KIT_ATTR_TARGET)) st.target = el.value;
|
|
255
|
+
else if (!el.hasAttribute(KIT_ATTR_PARAMS)) return;
|
|
219
256
|
api.emit('change', snapshot());
|
|
220
257
|
};
|
|
221
258
|
root.addEventListener('click', onClick);
|
|
259
|
+
root.addEventListener('input', onInput);
|
|
222
260
|
root.addEventListener('change', onChange);
|
|
223
261
|
return () => {
|
|
224
262
|
root.removeEventListener('click', onClick);
|
|
263
|
+
root.removeEventListener('input', onInput);
|
|
225
264
|
root.removeEventListener('change', onChange);
|
|
226
|
-
states.get(root)
|
|
227
|
-
|
|
265
|
+
const st = states.get(root);
|
|
266
|
+
if (st?.copyTimer !== null && st?.copyTimer !== undefined) clearTimeout(st.copyTimer);
|
|
267
|
+
st?.select?.dispose();
|
|
268
|
+
st?.offOutcome?.();
|
|
228
269
|
states.delete(root);
|
|
229
270
|
};
|
|
230
271
|
},
|
|
@@ -281,6 +322,8 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
281
322
|
const paramsWrap = mk('div', '');
|
|
282
323
|
const run = mk('div', '');
|
|
283
324
|
const result = mk('div', '');
|
|
325
|
+
// 一级结构:标题区 = 面头;方法切换、目标、参数、运行行都是面里的控件区,不另设层级;结果框 = 子块(见下)
|
|
326
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
284
327
|
root.append(head, seg, targetWrap, paramsWrap, run, result);
|
|
285
328
|
st.nodes = { head, seg, targetWrap, paramsWrap, run, result };
|
|
286
329
|
}
|
|
@@ -298,26 +341,47 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
298
341
|
|
|
299
342
|
// 标题 / 提示
|
|
300
343
|
n.head.textContent = '';
|
|
301
|
-
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
|
+
}
|
|
302
349
|
if (textOf(data.hint) !== '') n.head.appendChild(mk('p', HINT_CLASS, textOf(data.hint)));
|
|
303
350
|
n.head.hidden = n.head.childNodes.length === 0;
|
|
304
351
|
|
|
305
|
-
// 方法切换(分段样式 /
|
|
306
|
-
n.seg.textContent = '';
|
|
352
|
+
// 方法切换(分段样式 / 原地更新类名保焦点)
|
|
307
353
|
n.seg.hidden = methods.length === 0;
|
|
308
|
-
if (methods.length
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
btn.setAttribute('data-kit-value', m.value);
|
|
317
|
-
btn.setAttribute('aria-pressed', active ? 'true' : 'false');
|
|
318
|
-
row.appendChild(btn);
|
|
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);
|
|
319
362
|
}
|
|
320
|
-
|
|
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
|
+
);
|
|
321
385
|
}
|
|
322
386
|
|
|
323
387
|
// 目标下拉(持久)
|
|
@@ -331,10 +395,9 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
331
395
|
const wrap = mk('div', FIELD_WRAP);
|
|
332
396
|
wrap.appendChild(mk('span', LABEL_CLASS, str(p.target_label, kitText('soma.kit.rc_target', undefined, root))));
|
|
333
397
|
// 自绘下拉(没有原生 <select>):hidden 载体带 data-kit-target,选中后派发冒泡的 change
|
|
334
|
-
st.select?.dispose();
|
|
335
398
|
const opts = targets.length === 0 ? [{ value: '', label: emptyText }] : targets;
|
|
336
399
|
const sel = mountKitSelectField({ options: opts, value: st.target, ariaLabel: str(p.target_label, kitText('soma.kit.rc_target', undefined, root)) });
|
|
337
|
-
sel.input.setAttribute(
|
|
400
|
+
sel.input.setAttribute(KIT_ATTR_TARGET, '');
|
|
338
401
|
wrap.appendChild(sel.el);
|
|
339
402
|
n.targetWrap.appendChild(wrap);
|
|
340
403
|
st.select = sel;
|
|
@@ -352,7 +415,7 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
352
415
|
wrap.appendChild(mk('span', LABEL_CLASS, str(p.params_label, kitText('soma.kit.rc_params', undefined, root))));
|
|
353
416
|
const area = mk('textarea', AREA_CLASS);
|
|
354
417
|
setKitFace(area, 'field');
|
|
355
|
-
area.setAttribute(
|
|
418
|
+
area.setAttribute(KIT_ATTR_PARAMS, '');
|
|
356
419
|
wrap.appendChild(area);
|
|
357
420
|
n.paramsWrap.appendChild(wrap);
|
|
358
421
|
st.area = area;
|
|
@@ -362,16 +425,25 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
362
425
|
st.area.rows = Math.max(1, Math.floor(Number(p.params_rows) || 5));
|
|
363
426
|
st.area.placeholder = str(p.params_placeholder);
|
|
364
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
|
+
}
|
|
365
435
|
|
|
366
436
|
// 执行钮 + 校验提示
|
|
367
437
|
n.run.textContent = '';
|
|
368
438
|
const actionBusy = kitBusyOf(p);
|
|
369
439
|
const running = bool(data.running) || actionBusy;
|
|
440
|
+
// 数据状态自报到根:请求在途 = 加载中,回包带错误 = 出错
|
|
441
|
+
kitMarkDataFacts(root, { loading: running, error: (consoleResultOf(data.result)?.error ?? '') !== '' });
|
|
370
442
|
const runRow = mk('div', ROW_CLASS);
|
|
371
443
|
const runBtn = actionButton({
|
|
372
444
|
key: 'run',
|
|
373
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)),
|
|
374
|
-
|
|
446
|
+
fn: 'apply',
|
|
375
447
|
disabled: running || bool(p.run_disabled),
|
|
376
448
|
reason: '',
|
|
377
449
|
});
|
|
@@ -380,6 +452,8 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
380
452
|
n.run.appendChild(runRow);
|
|
381
453
|
if (st.invalid !== '') {
|
|
382
454
|
const inv = mk('p', ERROR_CLASS, st.invalid);
|
|
455
|
+
inv.id = st.errId;
|
|
456
|
+
inv.setAttribute(KIT_ATTR_INVALID_MSG, '');
|
|
383
457
|
inv.setAttribute('role', 'alert');
|
|
384
458
|
n.run.appendChild(inv);
|
|
385
459
|
}
|
|
@@ -387,14 +461,30 @@ export function createRequestConsole(): SomaComponentDefinition {
|
|
|
387
461
|
// 结果
|
|
388
462
|
n.result.textContent = '';
|
|
389
463
|
const result = consoleResultOf(data.result);
|
|
464
|
+
st.lastBody = result?.body ?? '';
|
|
390
465
|
n.result.hidden = result === null;
|
|
391
466
|
if (result) {
|
|
392
467
|
const box = mk('div', RESULT_CLASS);
|
|
393
|
-
box.setAttribute(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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);
|
|
398
488
|
}
|
|
399
489
|
if (result.error !== '') {
|
|
400
490
|
const err = mk('p', ERROR_CLASS, result.error);
|
package/src/data/resident.ts
CHANGED
|
@@ -19,12 +19,22 @@ import { createKitContextMenu } from './context-menu';
|
|
|
19
19
|
import { createKitRedirect } from './redirect';
|
|
20
20
|
import { createKitAccessGate } from './access-gate';
|
|
21
21
|
|
|
22
|
+
let sharedRowEditor: SomaComponentDefinition | null = null;
|
|
23
|
+
|
|
24
|
+
/** RowEditor 单例定义:常驻数据组件表(含 KitObjectForm 子表字段)与写死形状登记表共用同一份定义,消除重复工厂实例化 */
|
|
25
|
+
export function getSharedRowEditor(): SomaComponentDefinition {
|
|
26
|
+
if (sharedRowEditor === null) {
|
|
27
|
+
sharedRowEditor = createRowEditor();
|
|
28
|
+
}
|
|
29
|
+
return sharedRowEditor;
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
/** 常驻数据组件表(KitObjectForm 的行模板按基础组件表生成) */
|
|
23
33
|
export function createKitResidentDataComponents(
|
|
24
34
|
baseComponents: Readonly<Record<string, SomaComponentDefinition>>,
|
|
25
35
|
): Record<string, SomaComponentDefinition> {
|
|
26
36
|
// RowEditor 是可作表单字段控件的数据组件(对象数组子表字段,kit-grammar#formFieldDataComponents),常驻并登记进表单的行模板
|
|
27
|
-
const rowEditor =
|
|
37
|
+
const rowEditor = getSharedRowEditor();
|
|
28
38
|
// FlowEditor(GB4:流程画布作表单字段,edit: FlowEditor):画布实现 2000+ 行,不进首屏包。
|
|
29
39
|
// 表单只需要它的契约(props / emits)来生成行模板,所以这里给一个只有契约的占位登记;
|
|
30
40
|
// 常驻表里不放 FlowEditor——真正的定义走 static-lazy 的动态 import,由 core 补载:
|