soma-kit 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
package/src/data/row-editor.ts
CHANGED
|
@@ -12,25 +12,40 @@
|
|
|
12
12
|
// 假则组件不改行,由页面改 data.rows(受控,页面可在 add 里再做业务校验并写 data.error)。
|
|
13
13
|
// 录入草稿在组件内,重画与 columns 选项变化都不丢;数据只经 textContent / value 写入。
|
|
14
14
|
|
|
15
|
-
import
|
|
15
|
+
import { kitApplyLevelClass } from './level-class';
|
|
16
|
+
import type { SomaComponentDefinition, SomaDataPort } from 'soma-core';
|
|
16
17
|
import { applyCommon, bool, createKitController, FIELD_CLASS, formatValue, ID_PROPS, INVALID_PROPS, joinClass, nextUid, num, str, type KitApi } from '../base/shared';
|
|
17
18
|
import { kitText, type KitTextKey } from '../i18n/kit-text';
|
|
18
19
|
import { setKitFace } from '../recipes';
|
|
20
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
21
|
+
import { kitActionRecipe } from '../recipes/emphasis';
|
|
22
|
+
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
23
|
+
import { KIT_DIVIDER_FOOT_CLASS, KIT_DIVIDER_HEAD_CLASS, kitDividerRecipe } from '../recipes/divider';
|
|
19
24
|
import { KIT_BUSY_PROP_DEFS, kitBusyOf } from '../base/action-busy';
|
|
20
25
|
import { KIT_DATE_CLASS_CANDIDATES, mountKitDateField } from '../base/date';
|
|
21
26
|
import { KIT_LISTBOX_CLASS_CANDIDATES } from '../base/listbox-core';
|
|
22
|
-
import {
|
|
27
|
+
import { createSelect } from '../base/select';
|
|
28
|
+
import { createKitEmbedBag, mountKitComponent, type KitEmbedBag } from './embed';
|
|
23
29
|
import { fetchRemoteOptionRows } from './remote-options';
|
|
24
30
|
import { actionButton, BUTTON_CLASS_TOKENS, classTokens, emptyNode, mk, recOf, retryButton, rowsOf, textOf, TONE_SOFT } from './shape-util';
|
|
25
|
-
import { TEXT_ACTION_CLASS_TOKENS
|
|
26
|
-
import
|
|
31
|
+
import { TEXT_ACTION_CLASS_TOKENS } from './text-action-button';
|
|
32
|
+
import { KIT_ALIGN_CLASS, kitFieldPropsOf, kitHasOwnAlign, kitMarkDataFacts, kitMarkLevel, kitMarkPart } from './kit-contract';
|
|
33
|
+
import { kitApplyCols, kitColsGrid, kitStripGridCols } from '../base/kit-contract';
|
|
34
|
+
import { kitIsNextRuntime } from '../recipes/pipeline-runtime';
|
|
27
35
|
import { askKitConfirm } from './confirm-dialog';
|
|
28
36
|
import { watchKitOutcome } from './outcome-watch';
|
|
29
37
|
import { stagedDiff, stagedHeadKeys, stagedMarks, stagedModel } from './staged-rows';
|
|
30
38
|
import { testRegexGuarded } from 'soma-foundation/predicates';
|
|
39
|
+
import { kitWellRecipe } from '../recipes/surface';
|
|
40
|
+
import { mergeClass } from '../shared/merge-class';
|
|
41
|
+
import {
|
|
42
|
+
KIT_ATTR_ACTION, KIT_ATTR_BUSY, KIT_ATTR_CELL, KIT_ATTR_CELL_ERROR, KIT_ATTR_COLLAPSE, KIT_ATTR_CONTAINER, KIT_ATTR_FIELD, KIT_ATTR_FOOTER, KIT_ATTR_INDEX,
|
|
43
|
+
KIT_ATTR_OPTION_KEY, KIT_ATTR_REMOTE_WRAP, KIT_ATTR_RO_INDEX, KIT_ATTR_RO_SELECT, KIT_ATTR_ROW, KIT_ATTR_SELECT_HOST, KIT_ATTR_STAGE,
|
|
44
|
+
KIT_ATTR_STAGE_MARK, KIT_ATTR_TOTAL, KIT_ATTR_VALUE, kitAttrSel,
|
|
45
|
+
} from '../shared/dom-attrs';
|
|
31
46
|
|
|
32
47
|
// 集合本地草稿(staged):未同步条与行小标的类串(条与小标的语气取 warning-soft)
|
|
33
|
-
const STAGE_BAR_CLASS = `flex flex-wrap items-center justify-between gap-2 rounded-
|
|
48
|
+
const STAGE_BAR_CLASS = `flex flex-wrap items-center justify-between gap-2 rounded-item px-3 py-2 text-sm ${TONE_SOFT.warning}`;
|
|
34
49
|
const STAGE_BTNS_CLASS = 'flex items-center gap-2';
|
|
35
50
|
const STAGE_MARK_CLASS = `ms-2 rounded-full px-2 py-0.5 text-xs font-medium ${TONE_SOFT.warning}`;
|
|
36
51
|
const STAGE_NOTE_CLASS = 'w-full text-xs';
|
|
@@ -46,11 +61,15 @@ const FORM_COLS: Readonly<Record<number, string>> = Object.freeze({
|
|
|
46
61
|
5: 'grid-cols-1 @md:grid-cols-3 @2xl:grid-cols-5', 6: 'grid-cols-1 @md:grid-cols-3 @2xl:grid-cols-6',
|
|
47
62
|
});
|
|
48
63
|
|
|
49
|
-
|
|
64
|
+
// 子表 = 子块(层级策略 sub:纸面 N1 凹槽、细线档上下两线、扁平档起始边线;2026-11-25 第 4 关),里面的输入框保持白底 + 控件轮廓
|
|
65
|
+
const ROOT_CLASS = 'sub-block flex flex-col gap-3 p-3';
|
|
50
66
|
const TITLE_CLASS = 'text-sm font-semibold text-fg';
|
|
51
67
|
const HINT_CLASS = 'text-xs text-fg-subtle';
|
|
52
|
-
|
|
53
|
-
const
|
|
68
|
+
// 表头 / 行 / 合计行的线只经分隔线出口(发丝宽、分隔灰,KT-B1 / KT-B5)
|
|
69
|
+
const HEAD_CLASS = `grid grid-cols-12 items-center gap-2 ${KIT_DIVIDER_HEAD_CLASS} px-2 py-2 text-xs font-medium text-fg-muted`;
|
|
70
|
+
const ROW_LINE = kitDividerRecipe('bottom');
|
|
71
|
+
const DATE_EDGE = kitControlEdgeRecipe();
|
|
72
|
+
const ROW_CLASS = `grid grid-cols-12 items-center gap-2 ${ROW_LINE} px-2 py-2`;
|
|
54
73
|
const CELL_CLASS = 'min-w-0 break-all text-sm text-fg';
|
|
55
74
|
const CELL_MONO = 'min-w-0 break-all font-mono text-xs text-fg-muted';
|
|
56
75
|
const CELL_MUTED = 'min-w-0 break-all text-sm text-fg-muted';
|
|
@@ -69,28 +88,49 @@ const LABEL_CLASS = 'text-xs font-medium text-fg-muted';
|
|
|
69
88
|
const REQUIRED_MARK = 'text-danger-on-soft';
|
|
70
89
|
const TEXTAREA_LIKE = 'font-mono';
|
|
71
90
|
const ERROR_CLASS = 'text-sm text-danger-on-soft';
|
|
72
|
-
const LIST_WRAP = 'flex flex-col';
|
|
91
|
+
const LIST_WRAP = 'flex flex-col overflow-x-auto';
|
|
73
92
|
const NUM_ALIGN = 'text-end tabular-nums';
|
|
74
|
-
const FOOTER_ROW_CLASS =
|
|
93
|
+
const FOOTER_ROW_CLASS = `grid grid-cols-12 items-center gap-2 ${KIT_DIVIDER_FOOT_CLASS} px-2 py-2 text-sm font-semibold text-fg`;
|
|
75
94
|
const HEAD_END_CLASS = toFlexRow(HEAD_CLASS);
|
|
76
95
|
const ROW_END_CLASS = toFlexRow(ROW_CLASS);
|
|
77
96
|
const FOOTER_END_CLASS = toFlexRow(FOOTER_ROW_CLASS);
|
|
97
|
+
const colMinWidth = (c: KitRowColumn): string => (c.kind === 'bool' ? 'min-w-20' : c.kind === 'number' ? 'min-w-24' : 'min-w-28');
|
|
78
98
|
const COUNT_CLASS = 'text-xs text-fg-subtle';
|
|
79
|
-
/**
|
|
80
|
-
const CELL_ERROR_CLASS = 'ring-1 ring-danger';
|
|
81
|
-
const DATE_FIELD_CLASS =
|
|
99
|
+
/** 出错单元格的外框(令牌色环 + 控件圆角消除直角刺眼,不撑行高) */
|
|
100
|
+
const CELL_ERROR_CLASS = 'ring-1 ring-danger rounded-control';
|
|
101
|
+
const DATE_FIELD_CLASS = mergeClass(
|
|
102
|
+
`block h-control w-full rounded-control ${DATE_EDGE} bg-surface ps-3 pe-8 text-sm text-fg transition-colors placeholder:text-fg-subtle ${KIT_FOCUS_RING.control} aria-invalid:border-danger disabled:cursor-not-allowed disabled:bg-control-disabled disabled:text-fg-disabled`,
|
|
103
|
+
kitWellRecipe('read-only'),
|
|
104
|
+
);
|
|
105
|
+
/** 行内删除:成行的按钮是轻按钮,危险语气只在决策点(确认框)取实底 —— 行区(region: row)的删除走 dangerSoft(设计稿 3.1″) */
|
|
106
|
+
const ROW_REMOVE_CLASS = kitActionRecipe('delete', { region: 'row' });
|
|
82
107
|
|
|
83
108
|
export const KIT_ROW_EDITOR_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
84
109
|
ROOT_CLASS, TITLE_CLASS, HINT_CLASS, HEAD_CLASS, ROW_CLASS, CELL_CLASS, CELL_MONO, CELL_MUTED, END_CLASS, FORM_CLASS, FIELD_WRAP,
|
|
85
110
|
LABEL_CLASS, REQUIRED_MARK, TEXTAREA_LIKE, ERROR_CLASS, LIST_WRAP, Object.values(SPAN_CLASS), Object.values(FORM_COLS),
|
|
86
|
-
FIELD_CLASS.md, BUTTON_CLASS_TOKENS, TEXT_ACTION_CLASS_TOKENS, 'self-end', '@container', NUM_ALIGN, FOOTER_ROW_CLASS,
|
|
111
|
+
FIELD_CLASS.md, BUTTON_CLASS_TOKENS, ROW_REMOVE_CLASS, TEXT_ACTION_CLASS_TOKENS, 'self-end', '@container', NUM_ALIGN, FOOTER_ROW_CLASS,
|
|
112
|
+
HEAD_END_CLASS, ROW_END_CLASS, FOOTER_END_CLASS, END_FLEX_CLASS, Object.values(FLEX_SPAN).join(' '), COUNT_CLASS, CELL_ERROR_CLASS, DATE_FIELD_CLASS,
|
|
113
|
+
KIT_DATE_CLASS_CANDIDATES, KIT_LISTBOX_CLASS_CANDIDATES,
|
|
87
114
|
STAGE_BAR_CLASS, STAGE_BTNS_CLASS, STAGE_MARK_CLASS, STAGE_NOTE_CLASS, 'sr-only',
|
|
115
|
+
'min-w-20', 'min-w-24', 'min-w-28', 'min-w-120',
|
|
88
116
|
);
|
|
89
117
|
|
|
90
118
|
// ── 数据规整纯函数:列声明、单元格文字、录入校验、草稿转行 ──
|
|
91
119
|
|
|
92
120
|
export type KitRowColumnKind = 'text' | 'select' | 'bool' | 'json' | 'number' | 'money' | 'date';
|
|
93
121
|
|
|
122
|
+
/**
|
|
123
|
+
* 列对齐类:页面线给了字段级逻辑对齐(props.kit.fields[列键].align)时按它,表头、单元格、合计格同一个值;
|
|
124
|
+
* 没给时保持原缺省(数值列止对齐 + 等宽数字,其余不加类)。数值列不论对齐方向都保留等宽数字,数字才对得齐。
|
|
125
|
+
*/
|
|
126
|
+
function columnAlignClass(p: Record<string, unknown>, c: KitRowColumn, base = ''): string {
|
|
127
|
+
const align = kitFieldPropsOf(p, c.key).align;
|
|
128
|
+
const numeric = isNumericRowKind(c.kind);
|
|
129
|
+
if (align === undefined) return numeric ? ` ${NUM_ALIGN}` : '';
|
|
130
|
+
// 自己已有的优先(与 base/kit-contract.ts#kitMergeAlignOverflow 同一条):格类串里已有文本对齐时页面线的逻辑对齐不再叠加
|
|
131
|
+
return `${kitHasOwnAlign(base) ? '' : ` ${KIT_ALIGN_CLASS[align]}`}${numeric ? ' tabular-nums' : ''}`;
|
|
132
|
+
}
|
|
133
|
+
|
|
94
134
|
/** 数值列(右对齐、可合计) */
|
|
95
135
|
export function isNumericRowKind(kind: KitRowColumnKind): boolean {
|
|
96
136
|
return kind === 'number' || kind === 'money';
|
|
@@ -394,6 +434,61 @@ export function validateInlineRows(
|
|
|
394
434
|
|
|
395
435
|
// ── 组件 ──
|
|
396
436
|
|
|
437
|
+
interface RowSelectHandle {
|
|
438
|
+
el: HTMLElement;
|
|
439
|
+
input: HTMLInputElement;
|
|
440
|
+
field: HTMLElement;
|
|
441
|
+
setOptions(options: ReadonlyArray<{ value: string; label: string }>): void;
|
|
442
|
+
setProps(patch: Record<string, unknown>): void;
|
|
443
|
+
dispose(): void;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function mountRowSelect(opts: {
|
|
447
|
+
options: ReadonlyArray<{ value: string; label: string }>;
|
|
448
|
+
value: string;
|
|
449
|
+
placeholder: string;
|
|
450
|
+
ariaLabel: string;
|
|
451
|
+
doc?: Document;
|
|
452
|
+
}): RowSelectHandle {
|
|
453
|
+
const ownerDoc = opts.doc ?? document;
|
|
454
|
+
const stage = ownerDoc.createElement('div');
|
|
455
|
+
let input: HTMLInputElement | null = null;
|
|
456
|
+
const mount = mountKitComponent(createSelect(), stage, {
|
|
457
|
+
options: opts.options.map((o) => ({ ...o })),
|
|
458
|
+
value: opts.value,
|
|
459
|
+
placeholder: opts.placeholder,
|
|
460
|
+
size: 'md',
|
|
461
|
+
aria_label: opts.ariaLabel,
|
|
462
|
+
}, {
|
|
463
|
+
change: (payload: { value?: unknown }) => {
|
|
464
|
+
const next = payload?.value === undefined || payload.value === null ? '' : String(payload.value);
|
|
465
|
+
mount.setProps({ value: next });
|
|
466
|
+
if (input) {
|
|
467
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
468
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
});
|
|
472
|
+
const el = mount.host;
|
|
473
|
+
el.remove();
|
|
474
|
+
const field = el.querySelector<HTMLElement>('[role="combobox"]') ?? el;
|
|
475
|
+
input = el.querySelector<HTMLInputElement>(`input${kitAttrSel(KIT_ATTR_VALUE)}`);
|
|
476
|
+
if (input === null) {
|
|
477
|
+
input = ownerDoc.createElement('input');
|
|
478
|
+
input.type = 'hidden';
|
|
479
|
+
input.setAttribute(KIT_ATTR_VALUE, '');
|
|
480
|
+
el.appendChild(input);
|
|
481
|
+
}
|
|
482
|
+
return {
|
|
483
|
+
el,
|
|
484
|
+
input,
|
|
485
|
+
field,
|
|
486
|
+
setOptions: (options) => mount.setProps({ options: options.map((o) => ({ ...o })) }),
|
|
487
|
+
setProps: (patch) => mount.setProps(patch),
|
|
488
|
+
dispose: () => mount.destroy(),
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
|
|
397
492
|
interface EditorState {
|
|
398
493
|
columnsSig: string;
|
|
399
494
|
draft: Record<string, string>;
|
|
@@ -410,6 +505,10 @@ interface EditorState {
|
|
|
410
505
|
emittedSnapshots: string[];
|
|
411
506
|
/** 行内编辑的单元格控件(自绘下拉 / 日期框):行表重建前统一释放 */
|
|
412
507
|
cellEmbeds: KitEmbedBag;
|
|
508
|
+
/** 录入区已挂载的远程候选 Select 实例(供异步选项返回时原地 setOptions 更新,不打断其它框焦点) */
|
|
509
|
+
entrySelects: Map<string, { handle: RowSelectHandle; wrap: HTMLElement }>;
|
|
510
|
+
/** 行内编辑区已挂载的远程候选 Select 实例 */
|
|
511
|
+
inlineSelects: Array<{ handle: RowSelectHandle; colKey: string; rowIndex: number; wrap: HTMLElement }>;
|
|
413
512
|
nodes: { list: HTMLElement; form: HTMLElement; err: HTMLElement; title: HTMLElement; hint: HTMLElement; count: HTMLElement } | null;
|
|
414
513
|
/** 录入区命令式嵌入的自绘下拉 / 日期框:录入区重建与卸载前统一释放(含已展开的浮层) */
|
|
415
514
|
embeds: KitEmbedBag;
|
|
@@ -419,7 +518,14 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
419
518
|
const states = new WeakMap<HTMLElement, EditorState>();
|
|
420
519
|
const stateOf = (root: HTMLElement): EditorState => {
|
|
421
520
|
let s = states.get(root);
|
|
422
|
-
if (!s) {
|
|
521
|
+
if (!s) {
|
|
522
|
+
s = {
|
|
523
|
+
columnsSig: '', draft: {}, rows: [], rowsSig: '', localError: '', cellErrors: [], cellErrSig: '',
|
|
524
|
+
pendingClear: false, listSig: '', emittedSnapshots: [], cellEmbeds: createKitEmbedBag(),
|
|
525
|
+
entrySelects: new Map(), inlineSelects: [], nodes: null, embeds: createKitEmbedBag(),
|
|
526
|
+
};
|
|
527
|
+
states.set(root, s);
|
|
528
|
+
}
|
|
423
529
|
return s;
|
|
424
530
|
};
|
|
425
531
|
const recordSnapshot = (st: EditorState): void => {
|
|
@@ -461,15 +567,38 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
461
567
|
interface RemoteSlot { state: 'loading' | 'ok' | 'failed'; options: Array<{ value: string; label: string }> }
|
|
462
568
|
const remotes = new WeakMap<HTMLElement, Map<string, RemoteSlot>>();
|
|
463
569
|
const optionsKeyOf = (of: KitRowOptionsFrom): string => JSON.stringify([of.from, of.params, of.rowsPath, of.valueKey, of.labelKey]);
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
570
|
+
const colsStructOf = (cols: readonly KitRowColumn[]): unknown[] => cols.map((c) => (
|
|
571
|
+
c.optionsFrom === null
|
|
572
|
+
? c
|
|
573
|
+
: { ...c, options: [], optionsError: false, optionsRetryState: undefined, optionsRetryLabel: undefined, placeholder: '' }
|
|
574
|
+
));
|
|
575
|
+
const syncOptionsRetryDom = (box: HTMLElement, column: KitRowColumn): void => {
|
|
576
|
+
const existing = box.querySelector<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION, 'options_retry'));
|
|
577
|
+
const need = (column.optionsRetryState === 'failed' || column.optionsRetryState === 'loading') && column.optionsKey !== undefined;
|
|
578
|
+
if (!need) {
|
|
579
|
+
existing?.remove();
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
468
582
|
const loading = column.optionsRetryState === 'loading';
|
|
469
|
-
const
|
|
470
|
-
|
|
583
|
+
const label = column.optionsRetryLabel ?? kitText(loading ? 'soma.kit.rows_options_loading' : 'soma.kit.ct_retry');
|
|
584
|
+
if (existing) {
|
|
585
|
+
existing.textContent = label;
|
|
586
|
+
existing.setAttribute(KIT_ATTR_OPTION_KEY, column.optionsKey!);
|
|
587
|
+
if (loading) existing.setAttribute('aria-disabled', 'true');
|
|
588
|
+
else existing.removeAttribute('aria-disabled');
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
const retry = retryButton('options_retry', label);
|
|
592
|
+
retry.setAttribute(KIT_ATTR_OPTION_KEY, column.optionsKey!);
|
|
471
593
|
if (loading) retry.setAttribute('aria-disabled', 'true');
|
|
472
594
|
box.appendChild(retry);
|
|
595
|
+
};
|
|
596
|
+
const withOptionsRetry = (holder: HTMLElement, column: KitRowColumn): HTMLElement => {
|
|
597
|
+
if (column.optionsKey === undefined) return holder;
|
|
598
|
+
const box = mk('span', FIELD_WRAP);
|
|
599
|
+
box.setAttribute(KIT_ATTR_REMOTE_WRAP, column.optionsKey);
|
|
600
|
+
box.appendChild(holder);
|
|
601
|
+
syncOptionsRetryDom(box, column);
|
|
473
602
|
return box;
|
|
474
603
|
};
|
|
475
604
|
/** 把远程选项叠到列声明上(纯叠加;取数在这里发起,回来后整体重绘) */
|
|
@@ -582,7 +711,7 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
582
711
|
stg.bar = mk('div', '');
|
|
583
712
|
stg.bar.setAttribute('role', 'status');
|
|
584
713
|
stg.bar.setAttribute('aria-live', 'polite');
|
|
585
|
-
stg.bar.setAttribute(
|
|
714
|
+
stg.bar.setAttribute(KIT_ATTR_STAGE, '');
|
|
586
715
|
root.insertBefore(stg.bar, nodes.list);
|
|
587
716
|
}
|
|
588
717
|
const keys = stagedHeadKeys(diff);
|
|
@@ -597,7 +726,7 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
597
726
|
inner.appendChild(mk('span', '', `${kitText('soma.kit.stage_unsynced', { n: diff.count, added: diff.added.length, changed: diff.changed.length, removed: diff.removed.length }, root)}${keys.length > 0 ? `(${keys.join(kitText('soma.kit.list_sep', undefined, root))}${more})` : ''}`));
|
|
598
727
|
const btns = mk('div', STAGE_BTNS_CLASS);
|
|
599
728
|
btns.appendChild(actionButton({ key: 'stage_discard', label: kitText('soma.kit.stage_discard', undefined, root), tone: 'neutral', disabled: stg.syncing, reason: '' }));
|
|
600
|
-
btns.appendChild(actionButton({ key: 'stage_sync', label: kitText(stg.syncing ? 'soma.kit.stage_syncing' : 'soma.kit.stage_sync', undefined, root),
|
|
729
|
+
btns.appendChild(actionButton({ key: 'stage_sync', label: kitText(stg.syncing ? 'soma.kit.stage_syncing' : 'soma.kit.stage_sync', undefined, root), fn: 'apply', disabled: stg.syncing, reason: '' }));
|
|
601
730
|
inner.appendChild(btns);
|
|
602
731
|
if (stg.failMsg !== '') inner.appendChild(mk('p', STAGE_NOTE_CLASS, kitText('soma.kit.stage_failed', { message: stg.failMsg }, root)));
|
|
603
732
|
if (stg.stale) inner.appendChild(mk('p', STAGE_NOTE_CLASS, kitText('soma.kit.stage_stale', undefined, root)));
|
|
@@ -606,13 +735,13 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
606
735
|
}
|
|
607
736
|
// 行小标:工作副本第 i 行 <-> 行表第 i 个 [data-kit-row](表头与合计行没有该属性)
|
|
608
737
|
const marks = stagedMarks(stg.base ?? st.rows, st.rows, key);
|
|
609
|
-
nodes.list.querySelectorAll<HTMLElement>(
|
|
610
|
-
tr.querySelector(
|
|
738
|
+
nodes.list.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_ROW)).forEach((tr, i) => {
|
|
739
|
+
tr.querySelector(kitAttrSel(KIT_ATTR_STAGE_MARK))?.remove();
|
|
611
740
|
const m = marks[i];
|
|
612
741
|
const host = tr.firstElementChild;
|
|
613
742
|
if (!m || !host) return;
|
|
614
743
|
const tag = mk('span', STAGE_MARK_CLASS, kitText(m === 'new' ? 'soma.kit.stage_new' : 'soma.kit.stage_edited', undefined, root));
|
|
615
|
-
tag.setAttribute(
|
|
744
|
+
tag.setAttribute(KIT_ATTR_STAGE_MARK, m);
|
|
616
745
|
host.appendChild(tag);
|
|
617
746
|
});
|
|
618
747
|
if (diff.count !== stg.lastCount) {
|
|
@@ -711,7 +840,7 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
711
840
|
},
|
|
712
841
|
},
|
|
713
842
|
services: ['data', 'http'],
|
|
714
|
-
templateHtml: `<section data-soma-id="root" class="@container ${ROOT_CLASS}"></section>`,
|
|
843
|
+
templateHtml: `<section ${KIT_ATTR_CONTAINER}="inset" data-soma-id="root" class="@container ${ROOT_CLASS}"></section>`,
|
|
715
844
|
controllerFactory: createKitController(() => ({
|
|
716
845
|
busyAware: true,
|
|
717
846
|
attach(root, api) {
|
|
@@ -725,12 +854,12 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
725
854
|
const el = event.target as HTMLInputElement | null;
|
|
726
855
|
if (!el) return;
|
|
727
856
|
// 行内多行编辑:单格改动写回行副本并抛 change(值没变不抛:文本框的 input 与 change 都会来)
|
|
728
|
-
const cell = el.getAttribute(
|
|
857
|
+
const cell = el.getAttribute(KIT_ATTR_CELL);
|
|
729
858
|
if (cell !== null) {
|
|
730
859
|
const p = api.props();
|
|
731
860
|
if (bool(p.readonly) || bool(p.disabled)) return;
|
|
732
861
|
const st = stateOf(root);
|
|
733
|
-
const index = Number(el.getAttribute(
|
|
862
|
+
const index = Number(el.getAttribute(KIT_ATTR_INDEX));
|
|
734
863
|
const col = rowColumnsOf(p.columns, root).find((c) => c.key === cell);
|
|
735
864
|
const row = st.rows[index];
|
|
736
865
|
if (!col || !row) return;
|
|
@@ -751,20 +880,20 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
751
880
|
if (bool(p.staged)) refreshStage(root, p);
|
|
752
881
|
return;
|
|
753
882
|
}
|
|
754
|
-
const k = el.getAttribute(
|
|
883
|
+
const k = el.getAttribute(KIT_ATTR_FIELD);
|
|
755
884
|
if (k === null || k === undefined) return;
|
|
756
885
|
stateOf(root).draft[k] = el.value;
|
|
757
886
|
};
|
|
758
887
|
const onClick = (event: Event): void => {
|
|
759
|
-
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(
|
|
888
|
+
const btn = (event.target as HTMLElement | null)?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION));
|
|
760
889
|
if (!btn || btn.disabled) return;
|
|
761
890
|
const p = api.props();
|
|
762
891
|
const st = stateOf(root);
|
|
763
892
|
const cols = rowColumnsOf(p.columns, root);
|
|
764
893
|
const key = keyOf();
|
|
765
|
-
const act = btn.getAttribute(
|
|
894
|
+
const act = btn.getAttribute(KIT_ATTR_ACTION);
|
|
766
895
|
if (act === 'options_retry') {
|
|
767
|
-
const optionKey = btn.getAttribute(
|
|
896
|
+
const optionKey = btn.getAttribute(KIT_ATTR_OPTION_KEY);
|
|
768
897
|
if (optionKey !== null && btn.getAttribute('aria-disabled') !== 'true') retryRemoteOptions(root, optionKey);
|
|
769
898
|
return;
|
|
770
899
|
}
|
|
@@ -787,12 +916,12 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
787
916
|
recordSnapshot(st);
|
|
788
917
|
api.emit('change', { value: st.rows, totals: rowTotals(cols, st.rows) });
|
|
789
918
|
paint(root, api.props());
|
|
790
|
-
const last = root.querySelectorAll<HTMLElement>(`[
|
|
791
|
-
(last[0] ?? root.querySelector<HTMLElement>('
|
|
919
|
+
const last = root.querySelectorAll<HTMLElement>(`[${KIT_ATTR_INDEX}="${st.rows.length - 1}"]${kitAttrSel(KIT_ATTR_CELL)}`);
|
|
920
|
+
(last[0] ?? root.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_ACTION, 'add_row')))?.focus();
|
|
792
921
|
return;
|
|
793
922
|
}
|
|
794
923
|
if (act === 'remove') {
|
|
795
|
-
const index = Number(btn.getAttribute(
|
|
924
|
+
const index = Number(btn.getAttribute(KIT_ATTR_INDEX));
|
|
796
925
|
const row = st.rows[index];
|
|
797
926
|
if (!row) return;
|
|
798
927
|
const minRows = Math.max(0, Math.floor(num(p.min_rows) ?? 0));
|
|
@@ -828,8 +957,8 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
828
957
|
api.emit('change', { value: st.rows, totals: rowTotals(cols, st.rows) });
|
|
829
958
|
paint(root, live);
|
|
830
959
|
// 行表重绘后焦点会丢:落到同位置(或最后一行)的删除钮,没有行了就落到录入区第一格
|
|
831
|
-
const removes = root.querySelectorAll<HTMLElement>('
|
|
832
|
-
(removes[Math.min(at, removes.length - 1)] ?? root.querySelector<HTMLElement>(
|
|
960
|
+
const removes = root.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_ACTION, 'remove'));
|
|
961
|
+
(removes[Math.min(at, removes.length - 1)] ?? root.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_FIELD)))?.focus();
|
|
833
962
|
}
|
|
834
963
|
};
|
|
835
964
|
// 有内容的行先自绘确认(danger),空行直接删;确认弹出期间重复点击不叠加
|
|
@@ -881,8 +1010,8 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
881
1010
|
// 文本框里按 Enter 等于点「添加」(输入法组合中不算)
|
|
882
1011
|
const onKeydown = (event: KeyboardEvent): void => {
|
|
883
1012
|
const el = event.target as HTMLElement | null;
|
|
884
|
-
if (event.key !== 'Enter' || event.isComposing || !(el instanceof HTMLInputElement) || !el.hasAttribute(
|
|
885
|
-
const add = root.querySelector<HTMLButtonElement>('
|
|
1013
|
+
if (event.key !== 'Enter' || event.isComposing || !(el instanceof HTMLInputElement) || !el.hasAttribute(KIT_ATTR_FIELD)) return;
|
|
1014
|
+
const add = root.querySelector<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION, 'add'));
|
|
886
1015
|
if (!add) return;
|
|
887
1016
|
event.preventDefault();
|
|
888
1017
|
add.click();
|
|
@@ -890,7 +1019,7 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
890
1019
|
// 表单把 aria-invalid 也标在组件根上(文档顺序里先于单元格):根被聚焦时转交给首个出错单元格
|
|
891
1020
|
const onRootFocus = (event: Event): void => {
|
|
892
1021
|
if (event.target !== root) return;
|
|
893
|
-
root.querySelector<HTMLElement>(
|
|
1022
|
+
root.querySelector<HTMLElement>(`${kitAttrSel(KIT_ATTR_ROW)} [aria-invalid="true"]`)?.focus({ preventScroll: true });
|
|
894
1023
|
};
|
|
895
1024
|
root.addEventListener('focus', onRootFocus);
|
|
896
1025
|
root.addEventListener('input', onInput);
|
|
@@ -905,6 +1034,8 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
905
1034
|
root.removeEventListener('keydown', onKeydown);
|
|
906
1035
|
states.get(root)?.embeds.release(root);
|
|
907
1036
|
states.get(root)?.cellEmbeds.release(root);
|
|
1037
|
+
states.get(root)?.entrySelects.clear();
|
|
1038
|
+
if (states.get(root)) states.get(root)!.inlineSelects = [];
|
|
908
1039
|
states.delete(root);
|
|
909
1040
|
remotes.delete(root);
|
|
910
1041
|
stages.get(root)?.off?.();
|
|
@@ -934,18 +1065,18 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
934
1065
|
st.cellErrors = list;
|
|
935
1066
|
}
|
|
936
1067
|
|
|
937
|
-
/** 把 st.cellErrors 画到单元格:控件 aria-invalid
|
|
1068
|
+
/** 把 st.cellErrors 画到单元格:控件 aria-invalid、外层 wrap 恢复圆角令牌色环(ring-1 ring-danger rounded-control)与 title 消息,无错的格还原 */
|
|
938
1069
|
function applyCellErrors(root: HTMLElement, st: EditorState): void {
|
|
939
1070
|
const bad = new Map<string, string>();
|
|
940
1071
|
for (const e of st.cellErrors) bad.set(`${e.row}\u0000${e.col}`, e.message);
|
|
941
1072
|
const tokens = CELL_ERROR_CLASS.split(' ');
|
|
942
|
-
root.querySelectorAll<HTMLElement>(
|
|
943
|
-
const message = bad.get(`${control.getAttribute(
|
|
1073
|
+
root.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_CELL)).forEach((control) => {
|
|
1074
|
+
const message = bad.get(`${control.getAttribute(KIT_ATTR_INDEX)}\u0000${control.getAttribute(KIT_ATTR_CELL)}`);
|
|
944
1075
|
// 自绘下拉的载体是 hidden input,可见且可聚焦的是同壳的 combobox
|
|
945
|
-
const visible = control.closest<HTMLElement>(
|
|
946
|
-
const wrap = control.closest<HTMLElement>(
|
|
1076
|
+
const visible = control.closest<HTMLElement>(kitAttrSel(KIT_ATTR_SELECT_HOST))?.querySelector<HTMLElement>('[role="combobox"]') ?? control;
|
|
1077
|
+
const wrap = control.closest<HTMLElement>(`${kitAttrSel(KIT_ATTR_ROW)} > span`);
|
|
947
1078
|
// 错误文字节点(仅读屏可见,不加行高):控件 aria-describedby 指向它,title 只作鼠标悬停的补充
|
|
948
|
-
const errNode = wrap?.querySelector<HTMLElement>(
|
|
1079
|
+
const errNode = wrap?.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_CELL_ERROR)) ?? null;
|
|
949
1080
|
const describedTokens = (visible.getAttribute('aria-describedby') ?? '').split(/\s+/).filter((t) => t !== '');
|
|
950
1081
|
if (message !== undefined) {
|
|
951
1082
|
visible.setAttribute('aria-invalid', 'true');
|
|
@@ -954,7 +1085,7 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
954
1085
|
if (wrap) {
|
|
955
1086
|
const node = errNode ?? mk('span', 'sr-only');
|
|
956
1087
|
if (!errNode) {
|
|
957
|
-
node.setAttribute(
|
|
1088
|
+
node.setAttribute(KIT_ATTR_CELL_ERROR, '');
|
|
958
1089
|
node.id = nextUid('kit-cell-err');
|
|
959
1090
|
wrap.appendChild(node);
|
|
960
1091
|
}
|
|
@@ -995,22 +1126,31 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
995
1126
|
}
|
|
996
1127
|
|
|
997
1128
|
/** 行内编辑:一个单元格的控件(文本框 / 自绘下拉 / 自绘日期框),带 data-kit-cell 与行号,由根上的 input / change 监听收值 */
|
|
998
|
-
function inlineControl(st: EditorState, c: KitRowColumn, value: unknown, index: number): HTMLElement {
|
|
1129
|
+
function inlineControl(root: HTMLElement, st: EditorState, p: Record<string, unknown>, c: KitRowColumn, value: unknown, index: number): HTMLElement {
|
|
999
1130
|
const text = inlineText(c, value);
|
|
1000
1131
|
let control: HTMLInputElement;
|
|
1001
1132
|
let holder: HTMLElement;
|
|
1133
|
+
let selectHandle: RowSelectHandle | null = null;
|
|
1002
1134
|
if (c.kind === 'select' || c.kind === 'bool') {
|
|
1003
1135
|
const opts = c.kind === 'bool' ? [{ value: 'false', label: c.falseLabel }, { value: 'true', label: c.trueLabel }] : c.options;
|
|
1004
|
-
const field = st.cellEmbeds.add(
|
|
1005
|
-
|
|
1136
|
+
const field = st.cellEmbeds.add(mountRowSelect({
|
|
1137
|
+
options: opts,
|
|
1138
|
+
value: opts.some((o) => o.value === text) ? text : '',
|
|
1139
|
+
placeholder: c.placeholder,
|
|
1140
|
+
ariaLabel: c.label,
|
|
1141
|
+
doc: root.ownerDocument,
|
|
1142
|
+
}));
|
|
1143
|
+
field.el.setAttribute(KIT_ATTR_SELECT_HOST, '');
|
|
1006
1144
|
control = field.input;
|
|
1007
1145
|
holder = field.el;
|
|
1146
|
+
selectHandle = field;
|
|
1008
1147
|
} else if (c.kind === 'date') {
|
|
1009
1148
|
const field = st.cellEmbeds.add(mountKitDateField({ value: text, placeholder: c.placeholder, fieldClass: DATE_FIELD_CLASS }));
|
|
1010
1149
|
control = field.input;
|
|
1011
1150
|
holder = field.el;
|
|
1012
1151
|
} else {
|
|
1013
|
-
const
|
|
1152
|
+
const baseInputClass = c.mono || c.kind === 'json' ? `${FIELD_CLASS.md} ${TEXTAREA_LIKE}` : FIELD_CLASS.md;
|
|
1153
|
+
const input = mk('input', `${baseInputClass}${columnAlignClass(p, c)}`);
|
|
1014
1154
|
setKitFace(input, 'field');
|
|
1015
1155
|
input.type = 'text';
|
|
1016
1156
|
if (isNumericRowKind(c.kind)) input.inputMode = 'decimal';
|
|
@@ -1021,16 +1161,20 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1021
1161
|
control = input;
|
|
1022
1162
|
holder = input;
|
|
1023
1163
|
}
|
|
1024
|
-
control.setAttribute(
|
|
1025
|
-
control.setAttribute(
|
|
1026
|
-
|
|
1164
|
+
control.setAttribute(KIT_ATTR_CELL, c.key);
|
|
1165
|
+
control.setAttribute(KIT_ATTR_INDEX, String(index));
|
|
1166
|
+
const wrapped = withOptionsRetry(holder, c);
|
|
1167
|
+
if (selectHandle !== null && c.optionsKey !== undefined) {
|
|
1168
|
+
st.inlineSelects.push({ handle: selectHandle, colKey: c.key, rowIndex: index, wrap: wrapped });
|
|
1169
|
+
}
|
|
1170
|
+
return wrapped;
|
|
1027
1171
|
}
|
|
1028
1172
|
|
|
1029
1173
|
/** 行内编辑的合计行:随单格改动就地刷新数字(不重建行表,输入焦点不丢) */
|
|
1030
1174
|
function refreshTotals(root: HTMLElement, cols: readonly KitRowColumn[], rows: ReadonlyArray<Record<string, unknown>>, locale: string): void {
|
|
1031
1175
|
const totals = rowTotals(cols, rows);
|
|
1032
|
-
root.querySelectorAll<HTMLElement>(
|
|
1033
|
-
const c = cols.find((x) => x.key === el.getAttribute(
|
|
1176
|
+
root.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_TOTAL)).forEach((el) => {
|
|
1177
|
+
const c = cols.find((x) => x.key === el.getAttribute(KIT_ATTR_TOTAL));
|
|
1034
1178
|
const v = c ? totals[c.key] : undefined;
|
|
1035
1179
|
if (c && v !== undefined) el.textContent = rowCellText(c, v, locale);
|
|
1036
1180
|
});
|
|
@@ -1038,52 +1182,73 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1038
1182
|
|
|
1039
1183
|
/** 行内多行编辑的行表:每行每格就地可改;readonly / disabled 时退回纯文字;fixed_rows 时没有添加 / 删除 */
|
|
1040
1184
|
function paintInlineList(root: HTMLElement, st: EditorState, p: Record<string, unknown>, list: HTMLElement, cols: readonly KitRowColumn[], readonly: boolean, fixedRows: boolean): void {
|
|
1041
|
-
let focusRestore: { index: string; cell: string; start: number | null; end: number | null } | null = null;
|
|
1042
|
-
const active = typeof document !== 'undefined' ? document.activeElement : null;
|
|
1043
|
-
if (active
|
|
1044
|
-
const
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1047
|
-
|
|
1185
|
+
let focusRestore: { index: string; cell: string; isCombo: boolean; start: number | null; end: number | null } | null = null;
|
|
1186
|
+
const active = typeof document !== 'undefined' ? document.activeElement as HTMLElement | null : null;
|
|
1187
|
+
if (active && list.contains(active)) {
|
|
1188
|
+
const tagged = active.closest<HTMLElement>(kitAttrSel(KIT_ATTR_SELECT_HOST))?.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_CELL)) ?? active;
|
|
1189
|
+
const idx = tagged.getAttribute(KIT_ATTR_INDEX);
|
|
1190
|
+
const cell = tagged.getAttribute(KIT_ATTR_CELL);
|
|
1191
|
+
if (idx !== null && cell !== null) {
|
|
1192
|
+
let start: number | null = null;
|
|
1193
|
+
let end: number | null = null;
|
|
1194
|
+
if (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement) {
|
|
1195
|
+
try { start = active.selectionStart; end = active.selectionEnd; } catch {}
|
|
1196
|
+
}
|
|
1197
|
+
focusRestore = { index: idx, cell, isCombo: active.getAttribute('role') === 'combobox', start, end };
|
|
1048
1198
|
}
|
|
1049
1199
|
}
|
|
1050
1200
|
st.cellEmbeds.release(list);
|
|
1201
|
+
st.inlineSelects = [];
|
|
1051
1202
|
list.textContent = '';
|
|
1052
1203
|
const shown = cols.filter((c) => c.list);
|
|
1053
1204
|
const structural = !readonly && !fixedRows;
|
|
1054
|
-
const
|
|
1205
|
+
const gridMin = !structural && shown.length >= 4 ? ' min-w-120' : '';
|
|
1206
|
+
const spanOf = (c: KitRowColumn): string => {
|
|
1207
|
+
const own = structural ? `${FLEX_SPAN[c.span] ?? 'flex-2'} ${colMinWidth(c)}` : `${SPAN_CLASS[c.span] ?? 'col-span-2'} ${colMinWidth(c)}`;
|
|
1208
|
+
return `${own}${columnAlignClass(p, c, own)}`;
|
|
1209
|
+
};
|
|
1055
1210
|
if (st.rows.length === 0) {
|
|
1056
1211
|
list.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.empty', undefined, root))));
|
|
1057
1212
|
} else {
|
|
1058
|
-
const head = mk('div', structural ? HEAD_END_CLASS : HEAD_CLASS);
|
|
1213
|
+
const head = mk('div', structural ? HEAD_END_CLASS : `${HEAD_CLASS}${gridMin}`);
|
|
1214
|
+
// 表头带 = 面头;表头格 = 字段名
|
|
1215
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
1059
1216
|
for (const c of shown) {
|
|
1060
1217
|
const cell = mk('span', spanOf(c), c.label);
|
|
1218
|
+
kitMarkPart(cell, 'field-name');
|
|
1061
1219
|
if (c.required && c.editable && !readonly) cell.appendChild(mk('span', REQUIRED_MARK, ' *'));
|
|
1062
1220
|
head.appendChild(cell);
|
|
1063
1221
|
}
|
|
1064
1222
|
if (structural) head.appendChild(mk('span', END_FLEX_CLASS, str(p.action_label)));
|
|
1065
1223
|
list.appendChild(head);
|
|
1066
1224
|
st.rows.forEach((row, index) => {
|
|
1067
|
-
const tr = mk('div', structural ? ROW_END_CLASS : ROW_CLASS);
|
|
1068
|
-
tr.setAttribute(
|
|
1225
|
+
const tr = mk('div', structural ? ROW_END_CLASS : `${ROW_CLASS}${gridMin}`);
|
|
1226
|
+
tr.setAttribute(KIT_ATTR_ROW, String(index));
|
|
1227
|
+
kitMarkLevel(tr, 'item', 'line'); kitApplyLevelClass(tr);
|
|
1069
1228
|
const rowName = kitText('soma.kit.rows_row_n', { n: index + 1 }, root);
|
|
1070
1229
|
tr.setAttribute('role', 'group');
|
|
1071
1230
|
tr.setAttribute('aria-label', rowName);
|
|
1072
1231
|
for (const c of shown) {
|
|
1073
|
-
const wrap = mk('span',
|
|
1232
|
+
const wrap = mk('span', spanOf(c));
|
|
1233
|
+
kitMarkPart(wrap, 'cell');
|
|
1074
1234
|
if (readonly || !c.editable || (str(p.locked_key) !== '' && row[str(p.locked_key)] === true)) {
|
|
1075
1235
|
const cls = c.mono || c.kind === 'json' ? CELL_MONO : c.key === shown[0]?.key ? CELL_CLASS : CELL_MUTED;
|
|
1076
1236
|
wrap.className = `${spanOf(c)} ${cls}`;
|
|
1077
1237
|
wrap.textContent = rowCellText(c, row[c.key], str(p.locale));
|
|
1238
|
+
if (c.optionsFrom !== null) {
|
|
1239
|
+
wrap.setAttribute(KIT_ATTR_RO_SELECT, c.key);
|
|
1240
|
+
wrap.setAttribute(KIT_ATTR_RO_INDEX, String(index));
|
|
1241
|
+
}
|
|
1078
1242
|
} else {
|
|
1079
|
-
wrap.appendChild(inlineControl(st, c, row[c.key], index));
|
|
1243
|
+
wrap.appendChild(inlineControl(root, st, p, c, row[c.key], index));
|
|
1080
1244
|
}
|
|
1081
1245
|
tr.appendChild(wrap);
|
|
1082
1246
|
}
|
|
1083
1247
|
if (structural) {
|
|
1084
1248
|
const cell = mk('span', END_FLEX_CLASS);
|
|
1085
|
-
const btn =
|
|
1086
|
-
btn.
|
|
1249
|
+
const btn = actionButton({ key: 'remove', label: str(p.remove_label, kitText('soma.kit.delete', undefined, root)), fn: 'remove', disabled: false, reason: '' });
|
|
1250
|
+
btn.className = ROW_REMOVE_CLASS;
|
|
1251
|
+
btn.setAttribute(KIT_ATTR_INDEX, String(index));
|
|
1087
1252
|
btn.setAttribute('aria-label', `${str(p.remove_label, kitText('soma.kit.delete', undefined, root))} ${rowName}`);
|
|
1088
1253
|
cell.appendChild(btn);
|
|
1089
1254
|
tr.appendChild(cell);
|
|
@@ -1093,13 +1258,16 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1093
1258
|
if (str(p.footer, 'none') === 'sum') {
|
|
1094
1259
|
const totals = rowTotals(shown, st.rows);
|
|
1095
1260
|
const labelCol = shown.find((c) => totals[c.key] === undefined);
|
|
1096
|
-
const foot = mk('div', structural ? FOOTER_END_CLASS : FOOTER_ROW_CLASS);
|
|
1097
|
-
foot.setAttribute(
|
|
1261
|
+
const foot = mk('div', structural ? FOOTER_END_CLASS : `${FOOTER_ROW_CLASS}${gridMin}`);
|
|
1262
|
+
foot.setAttribute(KIT_ATTR_FOOTER, 'sum');
|
|
1263
|
+
// 合计行 = 淡底带
|
|
1264
|
+
kitMarkLevel(foot, 'band'); kitApplyLevelClass(foot);
|
|
1098
1265
|
for (const c of shown) {
|
|
1099
1266
|
const total = totals[c.key];
|
|
1100
1267
|
const text = total !== undefined ? rowCellText(c, total, str(p.locale)) : c === labelCol ? str(p.total_label, kitText('soma.kit.total_label', undefined, root)) : '';
|
|
1101
1268
|
const cell = mk('span', spanOf(c), text);
|
|
1102
|
-
|
|
1269
|
+
kitMarkPart(cell, 'cell');
|
|
1270
|
+
if (total !== undefined) cell.setAttribute(KIT_ATTR_TOTAL, c.key);
|
|
1103
1271
|
foot.appendChild(cell);
|
|
1104
1272
|
}
|
|
1105
1273
|
if (structural) foot.appendChild(mk('span', END_FLEX_CLASS));
|
|
@@ -1108,16 +1276,21 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1108
1276
|
}
|
|
1109
1277
|
if (structural) {
|
|
1110
1278
|
const bar = mk('div', 'flex px-2 py-2');
|
|
1279
|
+
// 「添加一行」所在的底部工具行 = 底栏
|
|
1280
|
+
kitMarkLevel(bar, 'foot'); kitApplyLevelClass(bar);
|
|
1111
1281
|
bar.appendChild(actionButton({ key: 'add_row', label: str(p.add_label, kitText('soma.kit.rows_add_row', undefined, root)), tone: 'neutral', disabled: false, reason: '' }));
|
|
1112
1282
|
list.appendChild(bar);
|
|
1113
1283
|
}
|
|
1114
1284
|
if (focusRestore !== null) {
|
|
1115
|
-
const
|
|
1116
|
-
`[
|
|
1285
|
+
const rawTarget = list.querySelector<HTMLElement>(
|
|
1286
|
+
`[${KIT_ATTR_INDEX}="${focusRestore.index}"][${KIT_ATTR_CELL}="${focusRestore.cell}"]`,
|
|
1117
1287
|
);
|
|
1288
|
+
const target = focusRestore.isCombo
|
|
1289
|
+
? rawTarget?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_SELECT_HOST))?.querySelector<HTMLElement>('[role="combobox"]') ?? rawTarget
|
|
1290
|
+
: rawTarget;
|
|
1118
1291
|
if (target) {
|
|
1119
1292
|
target.focus();
|
|
1120
|
-
if (focusRestore.start !== null && focusRestore.end !== null) {
|
|
1293
|
+
if (focusRestore.start !== null && focusRestore.end !== null && (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement)) {
|
|
1121
1294
|
try { target.setSelectionRange(focusRestore.start, focusRestore.end); } catch {}
|
|
1122
1295
|
}
|
|
1123
1296
|
}
|
|
@@ -1181,6 +1354,8 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1181
1354
|
});
|
|
1182
1355
|
const shown = cols.filter((c) => c.list);
|
|
1183
1356
|
root.className = joinClass(`@container ${ROOT_CLASS}`, p.class);
|
|
1357
|
+
// 数据状态:没有行为空;只读 / 禁用为只读(录入区与删除钮都不画)
|
|
1358
|
+
kitMarkDataFacts(root, { empty: st.rows.length === 0, readonly });
|
|
1184
1359
|
|
|
1185
1360
|
if (!st.nodes) {
|
|
1186
1361
|
root.textContent = '';
|
|
@@ -1206,11 +1381,27 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1206
1381
|
// 行表
|
|
1207
1382
|
const key = str(p.row_key) !== '' ? str(p.row_key) : (cols[0]?.key ?? '');
|
|
1208
1383
|
if (inline) {
|
|
1209
|
-
//
|
|
1210
|
-
const listSig = JSON.stringify([cols, readonly, fixedRows, st.rows.length, str(p.locked_key), str(p.remove_label), str(p.action_label), str(p.footer), str(p.empty_text), str(p.add_label), str(p.locale)]);
|
|
1384
|
+
// 行内多行编辑:结构不变(列结构、行数、锁定态)就不重建,远程选项返回时原地调 setOptions 更新,输入框焦点与光标绝不丢失
|
|
1385
|
+
const listSig = JSON.stringify([colsStructOf(cols), readonly, fixedRows, st.rows.length, str(p.locked_key), str(p.remove_label), str(p.action_label), str(p.footer), str(p.empty_text), str(p.add_label), str(p.locale), cols.map((c) => kitFieldPropsOf(p, c.key).align ?? '')]);
|
|
1211
1386
|
if (listSig !== st.listSig) {
|
|
1212
1387
|
st.listSig = listSig;
|
|
1213
1388
|
paintInlineList(root, st, p, list, cols, readonly, fixedRows);
|
|
1389
|
+
} else {
|
|
1390
|
+
for (const item of st.inlineSelects) {
|
|
1391
|
+
const c = cols.find((x) => x.key === item.colKey);
|
|
1392
|
+
if (!c) continue;
|
|
1393
|
+
const curText = inlineText(c, st.rows[item.rowIndex]?.[c.key]);
|
|
1394
|
+
item.handle.setOptions(c.options);
|
|
1395
|
+
item.handle.setProps({ placeholder: c.placeholder, value: c.options.some((o) => o.value === curText) ? curText : '' });
|
|
1396
|
+
syncOptionsRetryDom(item.wrap, c);
|
|
1397
|
+
}
|
|
1398
|
+
list.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_RO_SELECT)).forEach((roEl) => {
|
|
1399
|
+
const colKey = roEl.getAttribute(KIT_ATTR_RO_SELECT) ?? '';
|
|
1400
|
+
const rIdx = Number(roEl.getAttribute(KIT_ATTR_RO_INDEX));
|
|
1401
|
+
const c = cols.find((x) => x.key === colKey);
|
|
1402
|
+
const row = st.rows[rIdx];
|
|
1403
|
+
if (c && row) roEl.textContent = rowCellText(c, row[colKey], str(p.locale));
|
|
1404
|
+
});
|
|
1214
1405
|
}
|
|
1215
1406
|
} else if (st.rows.length === 0) {
|
|
1216
1407
|
list.textContent = '';
|
|
@@ -1218,25 +1409,38 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1218
1409
|
} else {
|
|
1219
1410
|
list.textContent = '';
|
|
1220
1411
|
const structural = !readonly && !fixedRows;
|
|
1221
|
-
const
|
|
1222
|
-
const
|
|
1223
|
-
|
|
1412
|
+
const gridMin = !structural && shown.length >= 4 ? ' min-w-120' : '';
|
|
1413
|
+
const head = mk('div', structural ? HEAD_END_CLASS : `${HEAD_CLASS}${gridMin}`);
|
|
1414
|
+
const spanOf = (c: KitRowColumn): string => {
|
|
1415
|
+
const own = structural ? `${FLEX_SPAN[c.span] ?? 'flex-2'} ${colMinWidth(c)}` : `${SPAN_CLASS[c.span] ?? 'col-span-2'} ${colMinWidth(c)}`;
|
|
1416
|
+
return `${own}${columnAlignClass(p, c, own)}`;
|
|
1417
|
+
};
|
|
1418
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
1419
|
+
for (const c of shown) {
|
|
1420
|
+
const hc = mk('span', spanOf(c), c.label);
|
|
1421
|
+
kitMarkPart(hc, 'field-name');
|
|
1422
|
+
head.appendChild(hc);
|
|
1423
|
+
}
|
|
1224
1424
|
if (structural) head.appendChild(mk('span', END_FLEX_CLASS, str(p.action_label)));
|
|
1225
1425
|
list.appendChild(head);
|
|
1226
1426
|
st.rows.forEach((row, index) => {
|
|
1227
|
-
const tr = mk('div', structural ? ROW_END_CLASS : ROW_CLASS);
|
|
1228
|
-
tr.setAttribute(
|
|
1427
|
+
const tr = mk('div', structural ? ROW_END_CLASS : `${ROW_CLASS}${gridMin}`);
|
|
1428
|
+
tr.setAttribute(KIT_ATTR_ROW, textOf(row[key]));
|
|
1429
|
+
kitMarkLevel(tr, 'item', 'line'); kitApplyLevelClass(tr);
|
|
1229
1430
|
const rowName = kitText('soma.kit.rows_row_n', { n: index + 1 }, root);
|
|
1230
1431
|
tr.setAttribute('role', 'group');
|
|
1231
1432
|
tr.setAttribute('aria-label', rowName);
|
|
1232
1433
|
for (const c of shown) {
|
|
1233
1434
|
const cls = c.mono || c.kind === 'json' ? CELL_MONO : c.key === shown[0]?.key ? CELL_CLASS : CELL_MUTED;
|
|
1234
|
-
|
|
1435
|
+
const td = mk('span', `${spanOf(c)} ${cls}`, rowCellText(c, row[c.key], str(p.locale)));
|
|
1436
|
+
kitMarkPart(td, 'cell');
|
|
1437
|
+
tr.appendChild(td);
|
|
1235
1438
|
}
|
|
1236
1439
|
if (structural) {
|
|
1237
1440
|
const cell = mk('span', END_FLEX_CLASS);
|
|
1238
|
-
const btn =
|
|
1239
|
-
btn.
|
|
1441
|
+
const btn = actionButton({ key: 'remove', label: str(p.remove_label, kitText('soma.kit.delete', undefined, root)), fn: 'remove', disabled: false, reason: '' });
|
|
1442
|
+
btn.className = ROW_REMOVE_CLASS;
|
|
1443
|
+
btn.setAttribute(KIT_ATTR_INDEX, String(index));
|
|
1240
1444
|
btn.setAttribute('aria-label', `${str(p.remove_label, kitText('soma.kit.delete', undefined, root))} ${rowName}`);
|
|
1241
1445
|
cell.appendChild(btn);
|
|
1242
1446
|
tr.appendChild(cell);
|
|
@@ -1246,12 +1450,15 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1246
1450
|
if (str(p.footer, 'none') === 'sum') {
|
|
1247
1451
|
const totals = rowTotals(shown, st.rows);
|
|
1248
1452
|
const labelCol = shown.find((c) => totals[c.key] === undefined);
|
|
1249
|
-
const foot = mk('div', structural ? FOOTER_END_CLASS : FOOTER_ROW_CLASS);
|
|
1250
|
-
foot.setAttribute(
|
|
1453
|
+
const foot = mk('div', structural ? FOOTER_END_CLASS : `${FOOTER_ROW_CLASS}${gridMin}`);
|
|
1454
|
+
foot.setAttribute(KIT_ATTR_FOOTER, 'sum');
|
|
1455
|
+
kitMarkLevel(foot, 'band'); kitApplyLevelClass(foot);
|
|
1251
1456
|
for (const c of shown) {
|
|
1252
1457
|
const total = totals[c.key];
|
|
1253
1458
|
const text = total !== undefined ? rowCellText(c, total, str(p.locale)) : c === labelCol ? str(p.total_label, kitText('soma.kit.total_label', undefined, root)) : '';
|
|
1254
|
-
|
|
1459
|
+
const fc = mk('span', spanOf(c), text);
|
|
1460
|
+
kitMarkPart(fc, 'cell');
|
|
1461
|
+
foot.appendChild(fc);
|
|
1255
1462
|
}
|
|
1256
1463
|
if (structural) foot.appendChild(mk('span', END_FLEX_CLASS));
|
|
1257
1464
|
list.appendChild(foot);
|
|
@@ -1269,18 +1476,55 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1269
1476
|
count.textContent = parts.join(' ');
|
|
1270
1477
|
}
|
|
1271
1478
|
|
|
1272
|
-
//
|
|
1479
|
+
// 录入区:列结构变化才重建(远程选项返回时原地 setOptions 更新;即使重建也记录并恢复当前聚焦字段与光标偏移)
|
|
1273
1480
|
const noEntry = readonly || inline || fixedRows;
|
|
1274
|
-
const colsSig = JSON.stringify([cols, noEntry, str(p.add_label)]);
|
|
1481
|
+
const colsSig = JSON.stringify([colsStructOf(cols), noEntry, str(p.add_label), kitIsNextRuntime(), cols.map((c) => kitFieldPropsOf(p, c.key).align ?? '')]);
|
|
1275
1482
|
if (colsSig !== st.columnsSig) {
|
|
1483
|
+
let formFocus: { field: string; isCombo: boolean; start: number | null; end: number | null } | null = null;
|
|
1484
|
+
const activeInForm = typeof document !== 'undefined' && form.contains(document.activeElement) ? document.activeElement as HTMLElement : null;
|
|
1485
|
+
if (activeInForm) {
|
|
1486
|
+
const hostField = activeInForm.closest<HTMLElement>(kitAttrSel(KIT_ATTR_SELECT_HOST))?.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_FIELD)) ?? activeInForm;
|
|
1487
|
+
const fKey = hostField.getAttribute(KIT_ATTR_FIELD);
|
|
1488
|
+
if (fKey) {
|
|
1489
|
+
let start: number | null = null;
|
|
1490
|
+
let end: number | null = null;
|
|
1491
|
+
if (activeInForm instanceof HTMLInputElement || activeInForm instanceof HTMLTextAreaElement) {
|
|
1492
|
+
try { start = activeInForm.selectionStart; end = activeInForm.selectionEnd; } catch {}
|
|
1493
|
+
}
|
|
1494
|
+
formFocus = { field: fKey, isCombo: activeInForm.getAttribute('role') === 'combobox', start, end };
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1276
1497
|
st.columnsSig = colsSig;
|
|
1277
1498
|
st.embeds.release(form);
|
|
1499
|
+
st.entrySelects.clear();
|
|
1278
1500
|
form.textContent = '';
|
|
1279
1501
|
const editable = cols.filter((c) => c.editable);
|
|
1280
1502
|
form.hidden = noEntry || editable.length === 0;
|
|
1281
|
-
if (
|
|
1282
|
-
|
|
1503
|
+
if (noEntry) {
|
|
1504
|
+
kitApplyCols(form, null);
|
|
1505
|
+
} else {
|
|
1506
|
+
const entryCols = Math.min(editable.length + 1, 6);
|
|
1507
|
+
const rawGridClass = `${FORM_CLASS} ${FORM_COLS[entryCols] ?? FORM_COLS[3]}`;
|
|
1508
|
+
const grid = mk('div', rawGridClass);
|
|
1283
1509
|
form.appendChild(grid);
|
|
1510
|
+
const nextCols = kitIsNextRuntime() && editable.length > 0 && entryCols >= 2 ? entryCols : null;
|
|
1511
|
+
let externalCollapse: string | null = null;
|
|
1512
|
+
for (let el: HTMLElement | null = grid.parentElement; el !== null; el = el.parentElement) {
|
|
1513
|
+
const val = el.getAttribute(KIT_ATTR_COLLAPSE);
|
|
1514
|
+
if (val !== null) { externalCollapse = val; break; }
|
|
1515
|
+
if (el.hasAttribute('data-soma-component')) break;
|
|
1516
|
+
}
|
|
1517
|
+
let varTracks = false;
|
|
1518
|
+
if (externalCollapse !== null) {
|
|
1519
|
+
varTracks = externalCollapse === 'to-single' ? kitApplyCols(grid, nextCols) : kitApplyCols(grid, null);
|
|
1520
|
+
} else if (nextCols !== null) {
|
|
1521
|
+
grid.setAttribute(KIT_ATTR_COLLAPSE, 'to-single');
|
|
1522
|
+
varTracks = kitApplyCols(grid, nextCols);
|
|
1523
|
+
} else {
|
|
1524
|
+
kitApplyCols(grid, null);
|
|
1525
|
+
}
|
|
1526
|
+
if (varTracks) grid.className = kitStripGridCols(rawGridClass);
|
|
1527
|
+
kitColsGrid(grid, varTracks);
|
|
1284
1528
|
for (const c of editable) {
|
|
1285
1529
|
if (st.draft[c.key] === undefined) st.draft[c.key] = c.kind === 'bool' ? (c.dflt === 'true' ? 'true' : 'false') : c.dflt;
|
|
1286
1530
|
const wrap = mk('label', FIELD_WRAP);
|
|
@@ -1289,6 +1533,7 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1289
1533
|
wrap.appendChild(lab);
|
|
1290
1534
|
let control: HTMLInputElement;
|
|
1291
1535
|
let holder: HTMLElement | null = null;
|
|
1536
|
+
let selectHandle: RowSelectHandle | null = null;
|
|
1292
1537
|
if (c.kind === 'select' || c.kind === 'bool') {
|
|
1293
1538
|
// 自绘下拉(没有原生 <select>):control 是它的 hidden 载体(带 data-kit-field,value 即选中项),holder 是外壳
|
|
1294
1539
|
const opts = c.kind === 'bool'
|
|
@@ -1296,17 +1541,25 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1296
1541
|
: c.options;
|
|
1297
1542
|
// 草稿值不在选项里时落到第一项(和原来原生下拉的表现一致)
|
|
1298
1543
|
if (!opts.some((o) => o.value === (st.draft[c.key] ?? '')) && opts[0]) st.draft[c.key] = opts[0].value;
|
|
1299
|
-
const field = st.embeds.add(
|
|
1300
|
-
|
|
1544
|
+
const field = st.embeds.add(mountRowSelect({
|
|
1545
|
+
options: opts,
|
|
1546
|
+
value: st.draft[c.key] ?? '',
|
|
1547
|
+
placeholder: c.placeholder,
|
|
1548
|
+
ariaLabel: c.label,
|
|
1549
|
+
doc: root.ownerDocument,
|
|
1550
|
+
}));
|
|
1551
|
+
field.el.setAttribute(KIT_ATTR_SELECT_HOST, '');
|
|
1301
1552
|
control = field.input;
|
|
1302
1553
|
holder = field.el;
|
|
1554
|
+
selectHandle = field;
|
|
1303
1555
|
} else if (c.kind === 'date') {
|
|
1304
1556
|
// 日期列:自绘日历框,控件是它的文本框(value 即日期文本)
|
|
1305
1557
|
const field = st.embeds.add(mountKitDateField({ value: st.draft[c.key] ?? '', placeholder: c.placeholder, fieldClass: DATE_FIELD_CLASS }));
|
|
1306
1558
|
control = field.input;
|
|
1307
1559
|
holder = field.el;
|
|
1308
1560
|
} else {
|
|
1309
|
-
const
|
|
1561
|
+
const baseInputClass = c.mono || c.kind === 'json' ? `${FIELD_CLASS.md} ${TEXTAREA_LIKE}` : FIELD_CLASS.md;
|
|
1562
|
+
const input = mk('input', `${baseInputClass}${columnAlignClass(p, c)}`);
|
|
1310
1563
|
setKitFace(input, 'field');
|
|
1311
1564
|
input.type = 'text';
|
|
1312
1565
|
if (isNumericRowKind(c.kind)) input.inputMode = 'decimal';
|
|
@@ -1315,16 +1568,42 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1315
1568
|
input.value = st.draft[c.key] ?? '';
|
|
1316
1569
|
control = input;
|
|
1317
1570
|
}
|
|
1318
|
-
control.setAttribute(
|
|
1319
|
-
|
|
1571
|
+
control.setAttribute(KIT_ATTR_FIELD, c.key);
|
|
1572
|
+
const wrapped = withOptionsRetry(holder ?? control, c);
|
|
1573
|
+
if (selectHandle !== null && c.optionsKey !== undefined) {
|
|
1574
|
+
st.entrySelects.set(c.key, { handle: selectHandle, wrap: wrapped });
|
|
1575
|
+
}
|
|
1576
|
+
wrap.appendChild(wrapped);
|
|
1320
1577
|
grid.appendChild(wrap);
|
|
1321
1578
|
}
|
|
1322
1579
|
const last = mk('div', `${FIELD_WRAP} self-end`);
|
|
1323
1580
|
last.appendChild(actionButton({ key: 'add', label: str(p.add_label, kitText('soma.kit.add', undefined, root)), tone: 'neutral', disabled: false, reason: '' }));
|
|
1324
1581
|
grid.appendChild(last);
|
|
1582
|
+
if (formFocus !== null) {
|
|
1583
|
+
const rawTarget = form.querySelector<HTMLElement>(`[${KIT_ATTR_FIELD}="${formFocus.field}"]`);
|
|
1584
|
+
const target = formFocus.isCombo
|
|
1585
|
+
? rawTarget?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_SELECT_HOST))?.querySelector<HTMLElement>('[role="combobox"]') ?? rawTarget
|
|
1586
|
+
: rawTarget;
|
|
1587
|
+
if (target) {
|
|
1588
|
+
target.focus();
|
|
1589
|
+
if (formFocus.start !== null && formFocus.end !== null && (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement)) {
|
|
1590
|
+
try { target.setSelectionRange(formFocus.start, formFocus.end); } catch {}
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1325
1594
|
}
|
|
1326
1595
|
} else {
|
|
1327
1596
|
form.hidden = noEntry || !cols.some((c) => c.editable);
|
|
1597
|
+
for (const [colKey, entry] of st.entrySelects) {
|
|
1598
|
+
const c = cols.find((x) => x.key === colKey);
|
|
1599
|
+
if (!c) continue;
|
|
1600
|
+
if (!c.options.some((o) => o.value === (st.draft[c.key] ?? '')) && c.options[0]) {
|
|
1601
|
+
st.draft[c.key] = c.options[0].value;
|
|
1602
|
+
}
|
|
1603
|
+
entry.handle.setOptions(c.options);
|
|
1604
|
+
entry.handle.setProps({ placeholder: c.placeholder, value: st.draft[c.key] ?? '' });
|
|
1605
|
+
syncOptionsRetryDom(entry.wrap, c);
|
|
1606
|
+
}
|
|
1328
1607
|
}
|
|
1329
1608
|
showError(root, st, textOf(data.error));
|
|
1330
1609
|
adoptCellErrors(st, p.cell_errors);
|
|
@@ -1333,20 +1612,20 @@ export function createRowEditor(): SomaComponentDefinition {
|
|
|
1333
1612
|
refreshStage(root, p);
|
|
1334
1613
|
// 忙闲通道:所接动作(add / remove / change)在进行中时添加、删除钮禁用并挂 aria-busy,结束后恢复(只还原自己置的禁用)
|
|
1335
1614
|
const busy = kitBusyOf(p);
|
|
1336
|
-
root.querySelectorAll<HTMLButtonElement>(
|
|
1615
|
+
root.querySelectorAll<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION)).forEach((b) => {
|
|
1337
1616
|
if (busy) {
|
|
1338
1617
|
b.disabled = true;
|
|
1339
1618
|
b.setAttribute('aria-busy', 'true');
|
|
1340
|
-
b.setAttribute(
|
|
1341
|
-
} else if (b.hasAttribute(
|
|
1619
|
+
b.setAttribute(KIT_ATTR_BUSY, '');
|
|
1620
|
+
} else if (b.hasAttribute(KIT_ATTR_BUSY)) {
|
|
1342
1621
|
b.disabled = false;
|
|
1343
1622
|
b.removeAttribute('aria-busy');
|
|
1344
|
-
b.removeAttribute(
|
|
1623
|
+
b.removeAttribute(KIT_ATTR_BUSY);
|
|
1345
1624
|
}
|
|
1346
1625
|
});
|
|
1347
1626
|
// 行数到下限:删除钮禁用(忙闲还原之后再压一次,保证两个来源都不被对方冲掉)
|
|
1348
1627
|
if (minRows > 0 && st.rows.length <= minRows) {
|
|
1349
|
-
root.querySelectorAll<HTMLButtonElement>('
|
|
1628
|
+
root.querySelectorAll<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ACTION, 'remove')).forEach((b) => { b.disabled = true; });
|
|
1350
1629
|
}
|
|
1351
1630
|
}
|
|
1352
1631
|
}
|