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/rule-builder.ts
CHANGED
|
@@ -12,20 +12,32 @@
|
|
|
12
12
|
// readonly:只渲染可读摘要文字(「状态 属于 已付款、已发货 且 金额 > 100」)。
|
|
13
13
|
// 本文件依次是:单条条件模块(运算符表 + 值控件,「字段 + 运算符 + 值」这一行的共享件)、条件树运算、类常量、内部状态、组件。
|
|
14
14
|
|
|
15
|
+
import { kitApplyLevelClass } from './level-class';
|
|
15
16
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
16
17
|
import { KIT_RULE_BUILDER_LIMITS } from 'soma-foundation/kit-limits';
|
|
17
18
|
import { KIT_GRAMMAR_RUNTIME as grammarJson } from '../generated/kit-grammar-runtime';
|
|
18
|
-
import { FIELD_CLASS, createKitController, joinClass, nextUid, type KitApi, type KitProps } from '../base/shared';
|
|
19
|
+
import { FIELD_CLASS, bool, createKitController, joinClass, nextUid, num, str, type KitApi, type KitProps } from '../base/shared';
|
|
19
20
|
import { classTokens, mk, recOf } from './shape-util';
|
|
20
21
|
import { KIT_BUSY_PROP_DEFS, kitBusyOf } from '../base/action-busy';
|
|
21
22
|
import { KIT_DATE_CLASS_CANDIDATES, mountKitDateField } from '../base/date';
|
|
22
23
|
import { KIT_LISTBOX_CLASS_CANDIDATES } from '../base/listbox-core';
|
|
23
24
|
import { createKitEmbedBag, mountKitSelectField, type KitEmbedBag } from './embed';
|
|
24
|
-
import { bool, num, str } from '../base/shared';
|
|
25
25
|
import { setKitFace, type KitFaceKind } from '../recipes';
|
|
26
|
+
import { KIT_FOCUS_RING, kitSelectedVariantRecipe } from '../recipes/state';
|
|
27
|
+
import { kitButtonEdgeRecipe, kitControlEdgeRecipe } from '../recipes/control';
|
|
28
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
29
|
+
import { kitDividerRecipe } from '../recipes/divider';
|
|
26
30
|
import { KIT_STATE_EMPTY_BOX } from '../recipes/placeholder';
|
|
27
|
-
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
28
|
-
import { mergeClass } from '../
|
|
31
|
+
import { kitActionRecipe, kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
32
|
+
import { mergeClass } from '../shared/merge-class';
|
|
33
|
+
import {
|
|
34
|
+
KIT_ATTR_COND, KIT_ATTR_CONTAINER, KIT_ATTR_EMPTY, KIT_ATTR_ERROR, KIT_ATTR_GROUP, KIT_ATTR_INVALID, KIT_ATTR_MODE, KIT_ATTR_OPT, KIT_ATTR_PART,
|
|
35
|
+
KIT_ATTR_PATH, KIT_ATTR_RULE_SUMMARY, KIT_ATTR_SELECT_HOST, KIT_ATTR_SELECTED, kitAttrSel,
|
|
36
|
+
} from '../shared/dom-attrs';
|
|
37
|
+
import { kitWellRecipe } from '../recipes/surface';
|
|
38
|
+
import { KIT_ICON_CLASS_CANDIDATES, kitIcon, type KitIconName } from '../shared/icons';
|
|
39
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
40
|
+
import { kitHasProps, kitMarkDataFacts, kitMarkLevel, kitMarkPicked } from './kit-contract';
|
|
29
41
|
|
|
30
42
|
// ════════════════════════════════════════════════════════════════
|
|
31
43
|
// 单条条件模块(纯函数 + 值控件构造):运算符表、按字段类型取运算符、值形状归一、校验文字、值控件(复用 kit 基础文本类控件的
|
|
@@ -240,20 +252,26 @@ export function describeCondition(cond: RuleCondition, field: RuleField | undefi
|
|
|
240
252
|
|
|
241
253
|
const VALUE_WRAP = 'flex min-w-40 flex-1 flex-wrap items-center gap-2';
|
|
242
254
|
const CONTROL = `${FIELD_CLASS.md} data-kit-invalid:border-danger`;
|
|
243
|
-
|
|
255
|
+
// 日期框的边 = 控件轮廓出口(KT-B1 / §4 C6);条件药丸 = 带文字中性按钮描边;组 / 条件框 = 壳配方(容器边,KT-B2)
|
|
256
|
+
const DATE_EDGE = kitControlEdgeRecipe();
|
|
257
|
+
const PILL_EDGE = kitButtonEdgeRecipe();
|
|
258
|
+
const MODE_EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
259
|
+
const DATE_CONTROL = mergeClass(
|
|
260
|
+
`block h-8 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} disabled:cursor-not-allowed disabled:bg-control-disabled disabled:text-fg-disabled data-kit-invalid:border-danger`,
|
|
261
|
+
kitWellRecipe('read-only'),
|
|
262
|
+
);
|
|
244
263
|
const RANGE_SEP = 'text-fg-subtle';
|
|
245
264
|
const PILLS = 'flex flex-wrap gap-1.5';
|
|
246
|
-
const PILL =
|
|
265
|
+
const PILL = mergeClass(
|
|
266
|
+
`inline-flex h-8 items-center rounded-full ${PILL_EDGE} bg-surface px-3 text-xs text-fg transition-colors state-layer ${KIT_FOCUS_RING.button} data-kit-selected:border-primary`,
|
|
267
|
+
kitSelectedVariantRecipe(KIT_ATTR_SELECTED),
|
|
268
|
+
);
|
|
247
269
|
const HALF = 'min-w-28 flex-1';
|
|
248
270
|
|
|
249
271
|
export const KIT_RULE_CONDITION_CLASS_CANDIDATES: readonly string[] = Object.freeze(
|
|
250
272
|
[...new Set([VALUE_WRAP, CONTROL, DATE_CONTROL, RANGE_SEP, PILLS, PILL, HALF, ...KIT_DATE_CLASS_CANDIDATES].flatMap((s) => s.split(/\s+/)).filter((c) => c !== ''))].sort(),
|
|
251
273
|
);
|
|
252
274
|
|
|
253
|
-
function inputType(type: RuleFieldType): string {
|
|
254
|
-
return type === 'number' ? 'number' : 'text';
|
|
255
|
-
}
|
|
256
|
-
|
|
257
275
|
/**
|
|
258
276
|
* 自绘下拉(没有原生 <select>):返回挂进行里的外壳;读值的载体是外壳里的 hidden input,带 data-kit-part,
|
|
259
277
|
* 选中后派发冒泡的 input / change(委托监听按 event.target.value 读);可聚焦字段是外壳里的 role=combobox。
|
|
@@ -262,14 +280,14 @@ function inputType(type: RuleFieldType): string {
|
|
|
262
280
|
function selectFieldOf(part: string, label: string, opts: ReadonlyArray<{ value: string; label: string }>, value: string, embeds?: KitEmbedBag): HTMLElement {
|
|
263
281
|
const field = mountKitSelectField({ options: opts, value, ariaLabel: label });
|
|
264
282
|
embeds?.add(field);
|
|
265
|
-
field.input.setAttribute(
|
|
266
|
-
field.el.setAttribute(
|
|
283
|
+
field.input.setAttribute(KIT_ATTR_PART, part);
|
|
284
|
+
field.el.setAttribute(KIT_ATTR_SELECT_HOST, '');
|
|
267
285
|
return field.el;
|
|
268
286
|
}
|
|
269
287
|
|
|
270
288
|
/** 控件上要被聚焦 / 标 aria-invalid 的可见元素:自绘下拉的载体是 hidden input,可见处是同壳的 combobox 字段 */
|
|
271
289
|
function visibleOf(c: HTMLElement): HTMLElement {
|
|
272
|
-
return c.closest<HTMLElement>(
|
|
290
|
+
return c.closest<HTMLElement>(kitAttrSel(KIT_ATTR_SELECT_HOST))?.querySelector<HTMLElement>('[role="combobox"]') ?? c;
|
|
273
291
|
}
|
|
274
292
|
|
|
275
293
|
function valueSelectOf(part: string, label: string, opts: readonly RuleOption[], value: string, placeholder: string, embeds?: KitEmbedBag): HTMLElement {
|
|
@@ -280,9 +298,10 @@ function valueSelectOf(part: string, label: string, opts: readonly RuleOption[],
|
|
|
280
298
|
function inputOf(part: string, label: string, type: RuleFieldType, value: unknown): HTMLInputElement {
|
|
281
299
|
const el = mk('input', CONTROL);
|
|
282
300
|
setKitFace(el, 'field');
|
|
283
|
-
el.type =
|
|
301
|
+
el.type = 'text';
|
|
302
|
+
if (type === 'number') el.inputMode = 'decimal';
|
|
284
303
|
el.autocomplete = 'off';
|
|
285
|
-
el.setAttribute(
|
|
304
|
+
el.setAttribute(KIT_ATTR_PART, part);
|
|
286
305
|
el.setAttribute('aria-label', label);
|
|
287
306
|
el.value = textOf(value);
|
|
288
307
|
return el;
|
|
@@ -292,7 +311,7 @@ function inputOf(part: string, label: string, type: RuleFieldType, value: unknow
|
|
|
292
311
|
function dateOf(part: string, label: string, value: unknown, embeds?: KitEmbedBag): HTMLElement {
|
|
293
312
|
const field = mountKitDateField({ value: textOf(value), fieldClass: DATE_CONTROL });
|
|
294
313
|
embeds?.add(field);
|
|
295
|
-
field.input.setAttribute(
|
|
314
|
+
field.input.setAttribute(KIT_ATTR_PART, part);
|
|
296
315
|
field.input.setAttribute('aria-label', label);
|
|
297
316
|
return field.el;
|
|
298
317
|
}
|
|
@@ -332,16 +351,16 @@ export function buildValueControl(cond: RuleCondition, field: RuleField | undefi
|
|
|
332
351
|
const pills = mk('div', PILLS);
|
|
333
352
|
pills.setAttribute('role', 'group');
|
|
334
353
|
pills.setAttribute('aria-label', aria);
|
|
335
|
-
pills.setAttribute(
|
|
354
|
+
pills.setAttribute(KIT_ATTR_PART, 'value-pills');
|
|
336
355
|
const chosen = new Set((Array.isArray(cond.value) ? cond.value : []).map(textOf));
|
|
337
356
|
for (const o of field?.options ?? []) {
|
|
338
357
|
const b = mk('button', PILL, o.label);
|
|
339
358
|
b.type = 'button';
|
|
340
359
|
setKitFace(b, 'raised');
|
|
341
|
-
b.setAttribute(
|
|
342
|
-
b.setAttribute(
|
|
360
|
+
b.setAttribute(KIT_ATTR_PART, 'value-opt');
|
|
361
|
+
b.setAttribute(KIT_ATTR_OPT, o.value);
|
|
343
362
|
b.setAttribute('aria-pressed', chosen.has(o.value) ? 'true' : 'false');
|
|
344
|
-
if (chosen.has(o.value)) b.setAttribute(
|
|
363
|
+
if (chosen.has(o.value)) b.setAttribute(KIT_ATTR_SELECTED, '');
|
|
345
364
|
pills.appendChild(b);
|
|
346
365
|
}
|
|
347
366
|
wrap.appendChild(pills);
|
|
@@ -358,7 +377,7 @@ export function buildValueControl(cond: RuleCondition, field: RuleField | undefi
|
|
|
358
377
|
* 数字框清空为 '',非法数字为 '';列表文本按中英文逗号切分;药丸点击切换并同步 aria-pressed。
|
|
359
378
|
*/
|
|
360
379
|
export function applyValueEdit(cond: RuleCondition, field: RuleField | undefined, el: HTMLElement): boolean {
|
|
361
|
-
const part = el.getAttribute(
|
|
380
|
+
const part = el.getAttribute(KIT_ATTR_PART) ?? '';
|
|
362
381
|
const type = field?.type ?? 'text';
|
|
363
382
|
const raw = (el as HTMLInputElement).value ?? '';
|
|
364
383
|
if (part === 'value') {
|
|
@@ -376,14 +395,14 @@ export function applyValueEdit(cond: RuleCondition, field: RuleField | undefined
|
|
|
376
395
|
return true;
|
|
377
396
|
}
|
|
378
397
|
if (part === 'value-opt') {
|
|
379
|
-
const opt = el.getAttribute(
|
|
398
|
+
const opt = el.getAttribute(KIT_ATTR_OPT) ?? '';
|
|
380
399
|
const cur = (Array.isArray(cond.value) ? cond.value : []).map(textOf);
|
|
381
400
|
const next = cur.includes(opt) ? cur.filter((x) => x !== opt) : [...cur, opt];
|
|
382
401
|
cond.value = (field?.options ?? []).map((o) => o.value).filter((v) => next.includes(v));
|
|
383
402
|
const on = (cond.value as string[]).includes(opt);
|
|
384
403
|
el.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
385
|
-
if (on) el.setAttribute(
|
|
386
|
-
else el.removeAttribute(
|
|
404
|
+
if (on) el.setAttribute(KIT_ATTR_SELECTED, '');
|
|
405
|
+
else el.removeAttribute(KIT_ATTR_SELECTED);
|
|
387
406
|
return true;
|
|
388
407
|
}
|
|
389
408
|
return false;
|
|
@@ -587,36 +606,36 @@ export const parsePathKey = (key: string): number[] => key.split('.').slice(1).m
|
|
|
587
606
|
// RuleBuilder 样式常量:Tailwind 类串与候选类清单
|
|
588
607
|
// ════════════════════════════════════════════════════════════════
|
|
589
608
|
|
|
590
|
-
const ROOT_CLASS = 'flex flex-col gap-3 text-sm text-fg';
|
|
591
|
-
const GROUP_CLASS = 'flex flex-col gap-2
|
|
592
|
-
const GROUP_NESTED_CLASS = 'flex flex-col gap-2
|
|
609
|
+
const ROOT_CLASS = mergeClass('flex flex-col gap-3 p-4 text-sm text-fg', kitShellRecipe({ tone: 'base', shadow: false }));
|
|
610
|
+
const GROUP_CLASS = 'flex flex-col gap-2.5';
|
|
611
|
+
const GROUP_NESTED_CLASS = mergeClass('flex flex-col gap-2 ps-3 py-1', kitDividerRecipe('start'));
|
|
593
612
|
const HEAD_CLASS = 'flex flex-wrap items-center gap-2';
|
|
594
|
-
const MODE_WRAP_CLASS =
|
|
595
|
-
const MODE_BTN_CLASS = 'inline-flex h-7 items-center justify-center rounded-
|
|
613
|
+
const MODE_WRAP_CLASS = `inline-flex rounded-control ${MODE_EDGE} bg-surface p-0.5`;
|
|
614
|
+
const MODE_BTN_CLASS = 'inline-flex h-7 items-center justify-center rounded-item px-3 text-xs font-medium text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press ' + KIT_FOCUS_RING.button + ' data-kit-selected:bg-primary data-kit-selected:text-primary-fg data-kit-selected:hover:bg-primary-hover';
|
|
596
615
|
// 「非」开关:未选 = 色调按钮(次级),选中 = 实心主色(态差靠填充,不靠描边)
|
|
597
616
|
const NOT_BTN_CLASS = mergeClass(kitEmphasisButtonRecipe('button.toolbar'), 'data-kit-selected:bg-primary data-kit-selected:text-primary-fg');
|
|
598
617
|
const SPACER_CLASS = 'flex-1';
|
|
599
618
|
const TOOL_BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
600
|
-
const ACT_BTN_CLASS = 'inline-flex
|
|
601
|
-
const DEL_BTN_CLASS = '
|
|
619
|
+
const ACT_BTN_CLASS = 'inline-flex size-8 items-center justify-center rounded-control p-0 text-xs text-fg-muted transition-colors hover:bg-state-layer-hover active:bg-state-layer-press hover:text-fg ' + KIT_FOCUS_RING.button + ' disabled:cursor-not-allowed disabled:text-fg-disabled';
|
|
620
|
+
const DEL_BTN_CLASS = mergeClass(kitActionRecipe('delete', { region: 'row' }), 'w-8 px-0');
|
|
602
621
|
const ACTIONS_CLASS = 'inline-flex items-center gap-0.5';
|
|
603
622
|
const BODY_CLASS = 'flex flex-col gap-2';
|
|
604
|
-
const COND_CLASS = 'flex flex-col gap-1
|
|
623
|
+
const COND_CLASS = 'flex flex-col gap-1 py-0.5';
|
|
605
624
|
const COND_ROW_CLASS = 'flex flex-wrap items-center gap-2';
|
|
606
625
|
const CELL_CLASS = 'min-w-28 flex-1';
|
|
607
626
|
const ERR_CLASS = 'text-xs text-danger-on-soft';
|
|
608
627
|
// 空态:与全 kit 同一口径(一行标题,无虚线框)
|
|
609
628
|
const EMPTY_CLASS = KIT_STATE_EMPTY_BOX;
|
|
610
|
-
const SUMMARY_CLASS = '
|
|
629
|
+
const SUMMARY_CLASS = 'sub-block px-3 py-2 text-sm text-fg-muted'; // 摘要块 = 子块(KT-HB-F),不是井
|
|
611
630
|
const READONLY_CLASS = 'text-sm text-fg';
|
|
612
631
|
const FOOT_CLASS = 'flex items-center justify-end gap-2';
|
|
613
|
-
const SAVE_CLASS = '
|
|
632
|
+
const SAVE_CLASS = kitActionRecipe('save', { region: 'form', rankInRegion: 0 });
|
|
614
633
|
const CANCEL_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
615
634
|
|
|
616
635
|
export const KIT_RULE_BUILDER_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
617
636
|
ROOT_CLASS, GROUP_CLASS, GROUP_NESTED_CLASS, HEAD_CLASS, MODE_WRAP_CLASS, MODE_BTN_CLASS, NOT_BTN_CLASS, SPACER_CLASS, TOOL_BTN_CLASS,
|
|
618
637
|
ACT_BTN_CLASS, DEL_BTN_CLASS, ACTIONS_CLASS, BODY_CLASS, COND_CLASS, COND_ROW_CLASS, CELL_CLASS, ERR_CLASS, EMPTY_CLASS, SUMMARY_CLASS,
|
|
619
|
-
READONLY_CLASS, FOOT_CLASS, SAVE_CLASS, CANCEL_CLASS, KIT_RULE_CONDITION_CLASS_CANDIDATES, ...KIT_LISTBOX_CLASS_CANDIDATES,
|
|
638
|
+
READONLY_CLASS, FOOT_CLASS, SAVE_CLASS, CANCEL_CLASS, KIT_RULE_CONDITION_CLASS_CANDIDATES, ...KIT_LISTBOX_CLASS_CANDIDATES, ...KIT_ICON_CLASS_CANDIDATES,
|
|
620
639
|
);
|
|
621
640
|
|
|
622
641
|
// ════════════════════════════════════════════════════════════════
|
|
@@ -644,6 +663,7 @@ interface Ctx {
|
|
|
644
663
|
|
|
645
664
|
interface State {
|
|
646
665
|
tree: RuleGroup;
|
|
666
|
+
origin: RuleGroup;
|
|
647
667
|
incomingSig: string;
|
|
648
668
|
renderSig: string;
|
|
649
669
|
touched: Set<string>;
|
|
@@ -686,22 +706,31 @@ function button(cls: string, text: string, part: string, aria?: string, surface:
|
|
|
686
706
|
const b = mk('button', cls, text);
|
|
687
707
|
b.type = 'button';
|
|
688
708
|
setKitFace(b, surface);
|
|
689
|
-
b.setAttribute(
|
|
709
|
+
b.setAttribute(KIT_ATTR_PART, part);
|
|
690
710
|
if (aria !== undefined) b.setAttribute('aria-label', aria);
|
|
691
711
|
return b;
|
|
692
712
|
}
|
|
693
713
|
|
|
714
|
+
function iconButton(cls: string, icon: KitIconName, part: string, aria: string): HTMLButtonElement {
|
|
715
|
+
const b = mk('button', cls);
|
|
716
|
+
b.type = 'button';
|
|
717
|
+
b.setAttribute(KIT_ATTR_PART, part);
|
|
718
|
+
b.setAttribute('aria-label', aria);
|
|
719
|
+
b.appendChild(kitIcon(icon, 'sm'));
|
|
720
|
+
return b;
|
|
721
|
+
}
|
|
722
|
+
|
|
694
723
|
function buildActions(path: readonly number[], index: number, count: number, ctx: Ctx, isGroup: boolean, atLimit: boolean): HTMLElement {
|
|
695
724
|
const l = ctx.labels;
|
|
696
725
|
const kind = `${isGroup ? l.group : l.condition} ${numLabel(path)}`;
|
|
697
726
|
const box = mk('div', ACTIONS_CLASS);
|
|
698
|
-
const up =
|
|
727
|
+
const up = iconButton(ACT_BTN_CLASS, 'arrow-up', 'up', `${l.move_up} ${kind}`);
|
|
699
728
|
up.disabled = index <= 0;
|
|
700
|
-
const down =
|
|
729
|
+
const down = iconButton(ACT_BTN_CLASS, 'arrow-down', 'down', `${l.move_down} ${kind}`);
|
|
701
730
|
down.disabled = index >= count - 1;
|
|
702
|
-
const dup =
|
|
731
|
+
const dup = iconButton(ACT_BTN_CLASS, 'copy', 'dup', `${l.duplicate} ${kind}`);
|
|
703
732
|
if (atLimit) { dup.disabled = true; dup.title = l.node_limit ?? ''; }
|
|
704
|
-
const del =
|
|
733
|
+
const del = iconButton(DEL_BTN_CLASS, 'close', 'del', `${l.remove} ${kind}`);
|
|
705
734
|
box.append(up, down, dup, del);
|
|
706
735
|
return box;
|
|
707
736
|
}
|
|
@@ -712,8 +741,10 @@ function buildCondition(cond: RuleCondition, path: number[], index: number, coun
|
|
|
712
741
|
const row = mk('div', COND_CLASS);
|
|
713
742
|
row.setAttribute('role', 'group');
|
|
714
743
|
row.setAttribute('aria-label', `${l.condition} ${numLabel(path)}`);
|
|
715
|
-
row.setAttribute(
|
|
716
|
-
row.setAttribute(
|
|
744
|
+
row.setAttribute(KIT_ATTR_PATH, key);
|
|
745
|
+
row.setAttribute(KIT_ATTR_COND, '');
|
|
746
|
+
// 组件契约自报:一条条件 = 条目(按钮与输入上的 data-kit-part 是本组件的回读钩子,不在元素部件闭集内,保持原值)
|
|
747
|
+
kitMarkLevel(row, 'item'); kitApplyLevelClass(row);
|
|
717
748
|
const line = mk('div', COND_ROW_CLASS);
|
|
718
749
|
const field = ctx.fmap.get(cond.field);
|
|
719
750
|
|
|
@@ -735,7 +766,7 @@ function buildCondition(cond: RuleCondition, path: number[], index: number, coun
|
|
|
735
766
|
|
|
736
767
|
const err = mk('p', ERR_CLASS);
|
|
737
768
|
err.id = `${st.uid}-${key}`;
|
|
738
|
-
err.setAttribute(
|
|
769
|
+
err.setAttribute(KIT_ATTR_ERROR, '');
|
|
739
770
|
err.hidden = true;
|
|
740
771
|
row.append(line, err);
|
|
741
772
|
return row;
|
|
@@ -750,10 +781,13 @@ function buildGroup(g: RuleGroup, path: number[], index: number, count: number,
|
|
|
750
781
|
const el = mk('div', nested ? GROUP_NESTED_CLASS : GROUP_CLASS);
|
|
751
782
|
el.setAttribute('role', 'group');
|
|
752
783
|
el.setAttribute('aria-label', nested ? `${l.group} ${numLabel(path)}` : l.group ?? '');
|
|
753
|
-
el.setAttribute(
|
|
754
|
-
el.setAttribute(
|
|
784
|
+
el.setAttribute(KIT_ATTR_PATH, key);
|
|
785
|
+
el.setAttribute(KIT_ATTR_GROUP, '');
|
|
786
|
+
// 顶层组 = 节,嵌套组 = 节里成块的子内容(子块);组头(且 / 或、加条件)= 面头
|
|
787
|
+
kitMarkLevel(el, nested ? 'sub' : 'section'); kitApplyLevelClass(el);
|
|
755
788
|
|
|
756
789
|
const head = mk('div', HEAD_CLASS);
|
|
790
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
757
791
|
const modes = mk('div', MODE_WRAP_CLASS);
|
|
758
792
|
modes.setAttribute('role', 'radiogroup');
|
|
759
793
|
modes.setAttribute('aria-label', l.mode ?? '');
|
|
@@ -762,16 +796,19 @@ function buildGroup(g: RuleGroup, path: number[], index: number, count: number,
|
|
|
762
796
|
const b = button(MODE_BTN_CLASS, (op === 'or' ? l.or : l.and) ?? '', 'mode');
|
|
763
797
|
b.setAttribute('role', 'radio');
|
|
764
798
|
b.setAttribute('aria-checked', on ? 'true' : 'false');
|
|
765
|
-
b.setAttribute(
|
|
799
|
+
b.setAttribute(KIT_ATTR_MODE, op);
|
|
766
800
|
b.tabIndex = on ? 0 : -1;
|
|
767
|
-
if (on) b.setAttribute(
|
|
801
|
+
if (on) b.setAttribute(KIT_ATTR_SELECTED, '');
|
|
802
|
+
// 选中的组合方式同写交互状态(aria-checked 上面已写)
|
|
803
|
+
kitMarkPicked(b, 'selected', on, null);
|
|
768
804
|
modes.appendChild(b);
|
|
769
805
|
}
|
|
770
806
|
head.appendChild(modes);
|
|
771
807
|
if (ctx.allowNot) {
|
|
772
808
|
const nb = button(NOT_BTN_CLASS, l.not ?? '', 'not', undefined, 'raised');
|
|
773
809
|
nb.setAttribute('aria-pressed', g.not === true ? 'true' : 'false');
|
|
774
|
-
if (g.not === true) nb.setAttribute(
|
|
810
|
+
if (g.not === true) nb.setAttribute(KIT_ATTR_SELECTED, '');
|
|
811
|
+
kitMarkPicked(nb, 'selected', g.not === true, null);
|
|
775
812
|
head.appendChild(nb);
|
|
776
813
|
}
|
|
777
814
|
head.appendChild(mk('span', SPACER_CLASS));
|
|
@@ -790,7 +827,8 @@ function buildGroup(g: RuleGroup, path: number[], index: number, count: number,
|
|
|
790
827
|
const body = mk('div', BODY_CLASS);
|
|
791
828
|
if (g.rules.length === 0) {
|
|
792
829
|
const empty = mk('p', EMPTY_CLASS, l.empty ?? '');
|
|
793
|
-
empty.setAttribute(
|
|
830
|
+
empty.setAttribute(KIT_ATTR_EMPTY, '');
|
|
831
|
+
kitMarkLevel(empty, 'sub'); kitApplyLevelClass(empty);
|
|
794
832
|
body.appendChild(empty);
|
|
795
833
|
}
|
|
796
834
|
g.rules.forEach((n: RuleNode, i) => {
|
|
@@ -805,9 +843,9 @@ function buildGroup(g: RuleGroup, path: number[], index: number, count: number,
|
|
|
805
843
|
|
|
806
844
|
function applyFocus(root: HTMLElement, cands: readonly FocusCand[]): void {
|
|
807
845
|
for (const [key, part] of cands) {
|
|
808
|
-
const node = root.querySelector(`[
|
|
846
|
+
const node = root.querySelector(`[${KIT_ATTR_PATH}="${key}"]`);
|
|
809
847
|
if (!node) continue;
|
|
810
|
-
const sel = part === 'first' ? '[role="combobox"], input:not([type="hidden"]), button' : part === 'mode' ? '
|
|
848
|
+
const sel = part === 'first' ? '[role="combobox"], input:not([type="hidden"]), button' : part === 'mode' ? `${kitAttrSel(KIT_ATTR_PART, 'mode')}${kitAttrSel(KIT_ATTR_SELECTED)}` : `[${KIT_ATTR_PART}="${part}"]`;
|
|
811
849
|
const el = node.querySelector<HTMLElement & { disabled?: boolean }>(sel);
|
|
812
850
|
if (el && el.disabled !== true) { visibleOf(el).focus(); return; }
|
|
813
851
|
}
|
|
@@ -818,7 +856,7 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
818
856
|
const stateOf = (root: HTMLElement): State => {
|
|
819
857
|
let s = states.get(root);
|
|
820
858
|
if (!s) {
|
|
821
|
-
s = { tree: emptyGroup(), incomingSig: '\u0000', renderSig: '', touched: new Set(), showAll: false, focus: null, rebuilding: false, uid: nextUid('kit-rule'), ctx: null, embeds: createKitEmbedBag() };
|
|
859
|
+
s = { tree: emptyGroup(), origin: emptyGroup(), incomingSig: '\u0000', renderSig: '', touched: new Set(), showAll: false, focus: null, rebuilding: false, uid: nextUid('kit-rule'), ctx: null, embeds: createKitEmbedBag() };
|
|
822
860
|
states.set(root, s);
|
|
823
861
|
}
|
|
824
862
|
return s;
|
|
@@ -832,22 +870,22 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
832
870
|
if (!ctx) return [];
|
|
833
871
|
const issues = issuesOf(st);
|
|
834
872
|
const byKey = new Map(issues.map((i) => [pathKey(i.path), i]));
|
|
835
|
-
for (const row of Array.from(root.querySelectorAll<HTMLElement>(
|
|
836
|
-
const key = row.getAttribute(
|
|
873
|
+
for (const row of Array.from(root.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_COND)))) {
|
|
874
|
+
const key = row.getAttribute(KIT_ATTR_PATH) ?? '';
|
|
837
875
|
const issue = byKey.get(key);
|
|
838
876
|
const show = issue !== undefined && (st.showAll || st.touched.has(key));
|
|
839
|
-
const err = row.querySelector<HTMLElement>(
|
|
877
|
+
const err = row.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_ERROR));
|
|
840
878
|
if (err) { err.textContent = show ? issue.message : ''; err.hidden = !show; }
|
|
841
|
-
for (const hit of Array.from(row.querySelectorAll<HTMLElement>(
|
|
879
|
+
for (const hit of Array.from(row.querySelectorAll<HTMLElement>(`input${kitAttrSel(KIT_ATTR_PART)}`))) {
|
|
842
880
|
const c = visibleOf(hit);
|
|
843
|
-
const part = hit.getAttribute(
|
|
881
|
+
const part = hit.getAttribute(KIT_ATTR_PART) ?? '';
|
|
844
882
|
const target = issue?.code === 'field' ? part === 'field' : part.startsWith('value');
|
|
845
883
|
const bad = show && target;
|
|
846
|
-
if (bad) { c.setAttribute(
|
|
847
|
-
else { c.removeAttribute(
|
|
884
|
+
if (bad) { c.setAttribute(KIT_ATTR_INVALID, ''); c.setAttribute('aria-invalid', 'true'); if (err) c.setAttribute('aria-describedby', err.id); }
|
|
885
|
+
else { c.removeAttribute(KIT_ATTR_INVALID); c.removeAttribute('aria-invalid'); c.removeAttribute('aria-describedby'); }
|
|
848
886
|
}
|
|
849
887
|
}
|
|
850
|
-
const sum = root.querySelector<HTMLElement>(
|
|
888
|
+
const sum = root.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_RULE_SUMMARY));
|
|
851
889
|
if (sum) sum.textContent = describeTree(st.tree, ctx.fmap, ctx.labels);
|
|
852
890
|
return issues;
|
|
853
891
|
}
|
|
@@ -876,6 +914,7 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
876
914
|
layer: 'data',
|
|
877
915
|
props: {
|
|
878
916
|
data: { type: 'object', default: {}, desc: '{ fields?, value? }:value 为条件树 { op, not?, rules[] }' },
|
|
917
|
+
value: { type: 'object', default: null, desc: '条件树 { op, not?, rules[] }(顶层受控值,非空对象时优先于 data.value)' },
|
|
879
918
|
fields: { type: 'array', default: [], desc: '字段 [{ name, label?, type?: text|number|date|enum|boolean, options? }],非空时优先于 data.fields' },
|
|
880
919
|
readonly: { type: 'boolean', default: false, desc: '只读:只渲染可读摘要文字' },
|
|
881
920
|
max_depth: { type: 'number', default: RULE_MAX_DEPTH, desc: `组的最大嵌套层数(含根组),不超过 ${RULE_MAX_DEPTH}` },
|
|
@@ -895,13 +934,13 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
895
934
|
cancel: { payload: {}, desc: '点取消' },
|
|
896
935
|
},
|
|
897
936
|
},
|
|
898
|
-
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
937
|
+
templateHtml: `<section ${KIT_ATTR_CONTAINER}="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
899
938
|
controllerFactory: createKitController(() => ({
|
|
900
939
|
busyAware: true,
|
|
901
940
|
attach(root, api) {
|
|
902
941
|
const nodeOf = (el: Element | null): { key: string; path: number[] } | null => {
|
|
903
|
-
const n = el?.closest<HTMLElement>(
|
|
904
|
-
const key = n?.getAttribute(
|
|
942
|
+
const n = el?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_PATH));
|
|
943
|
+
const key = n?.getAttribute(KIT_ATTR_PATH);
|
|
905
944
|
return key ? { key, path: parsePathKey(key) } : null;
|
|
906
945
|
};
|
|
907
946
|
const sibling = (path: number[], i: number): string => pathKey([...path.slice(0, -1), i]);
|
|
@@ -912,19 +951,19 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
912
951
|
};
|
|
913
952
|
|
|
914
953
|
const onClick = (event: Event): void => {
|
|
915
|
-
const t = (event.target as HTMLElement | null)?.closest<HTMLElement & { disabled?: boolean }>(
|
|
954
|
+
const t = (event.target as HTMLElement | null)?.closest<HTMLElement & { disabled?: boolean }>(kitAttrSel(KIT_ATTR_PART));
|
|
916
955
|
if (!t || !root.contains(t) || t.disabled === true) return;
|
|
917
956
|
const st = stateOf(root);
|
|
918
957
|
const ctx = st.ctx;
|
|
919
958
|
if (!ctx) return;
|
|
920
|
-
const part = t.getAttribute(
|
|
959
|
+
const part = t.getAttribute(KIT_ATTR_PART);
|
|
921
960
|
const at = nodeOf(t);
|
|
922
961
|
const path = at?.path ?? [];
|
|
923
962
|
const key = at?.key ?? 'r';
|
|
924
963
|
switch (part) {
|
|
925
964
|
case 'mode': {
|
|
926
965
|
const g = groupAt(st.tree, path);
|
|
927
|
-
const op = t.getAttribute(
|
|
966
|
+
const op = t.getAttribute(KIT_ATTR_MODE) === 'or' ? 'or' : 'and';
|
|
928
967
|
if (g && g.op !== op) { g.op = op; commit(root, st, api, [[key, 'mode']], false); }
|
|
929
968
|
return;
|
|
930
969
|
}
|
|
@@ -975,8 +1014,8 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
975
1014
|
const issues = refreshIssues(root, st);
|
|
976
1015
|
if (issues.length > 0) {
|
|
977
1016
|
const first = issues[0] as RuleIssue;
|
|
978
|
-
const row = root.querySelector(`[
|
|
979
|
-
const ctl = row?.querySelector<HTMLElement>(first.code === 'field' ? '
|
|
1017
|
+
const row = root.querySelector(`[${KIT_ATTR_PATH}="${pathKey(first.path)}"]`);
|
|
1018
|
+
const ctl = row?.querySelector<HTMLElement>(first.code === 'field' ? kitAttrSel(KIT_ATTR_PART, 'field') : `[${KIT_ATTR_PART}^="value"]`);
|
|
980
1019
|
if (ctl) visibleOf(ctl).focus();
|
|
981
1020
|
api.emit('invalid', { issues: issues.map((i) => ({ path: i.path.join('.'), code: i.code, message: i.message })) });
|
|
982
1021
|
return;
|
|
@@ -984,14 +1023,22 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
984
1023
|
api.emit('saved', { value: exportTree(st.tree) });
|
|
985
1024
|
return;
|
|
986
1025
|
}
|
|
987
|
-
case 'cancel':
|
|
1026
|
+
case 'cancel': {
|
|
1027
|
+
st.tree = exportTree(st.origin);
|
|
1028
|
+
st.touched.clear();
|
|
1029
|
+
st.showAll = false;
|
|
1030
|
+
st.renderSig = '';
|
|
1031
|
+
paint(root, api.props());
|
|
1032
|
+
api.emit('cancel', {});
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
988
1035
|
default:
|
|
989
1036
|
}
|
|
990
1037
|
};
|
|
991
1038
|
|
|
992
1039
|
const onChange = (event: Event): void => {
|
|
993
1040
|
const el = event.target as HTMLInputElement | null;
|
|
994
|
-
const part = el?.getAttribute?.(
|
|
1041
|
+
const part = el?.getAttribute?.(KIT_ATTR_PART);
|
|
995
1042
|
if (!el || !part) return;
|
|
996
1043
|
const st = stateOf(root);
|
|
997
1044
|
const ctx = st.ctx;
|
|
@@ -1024,7 +1071,7 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
1024
1071
|
const el = event.target as HTMLElement | null;
|
|
1025
1072
|
if (!el || !root.contains(el)) return;
|
|
1026
1073
|
const st = stateOf(root);
|
|
1027
|
-
const part = el.getAttribute(
|
|
1074
|
+
const part = el.getAttribute(KIT_ATTR_PART);
|
|
1028
1075
|
if (part === 'mode' && ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(event.key)) {
|
|
1029
1076
|
event.preventDefault();
|
|
1030
1077
|
const at = nodeOf(el);
|
|
@@ -1046,11 +1093,11 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
1046
1093
|
const onFocusOut = (event: FocusEvent): void => {
|
|
1047
1094
|
const st = stateOf(root);
|
|
1048
1095
|
if (st.rebuilding) return;
|
|
1049
|
-
const row = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
1096
|
+
const row = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_COND));
|
|
1050
1097
|
if (!row) return;
|
|
1051
1098
|
const to = event.relatedTarget as Node | null;
|
|
1052
1099
|
if (to && row.contains(to)) return;
|
|
1053
|
-
const key = row.getAttribute(
|
|
1100
|
+
const key = row.getAttribute(KIT_ATTR_PATH);
|
|
1054
1101
|
if (!key || st.touched.has(key)) return;
|
|
1055
1102
|
st.touched.add(key);
|
|
1056
1103
|
refreshIssues(root, st);
|
|
@@ -1082,14 +1129,17 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
1082
1129
|
const ctx = ctxOf(p);
|
|
1083
1130
|
st.ctx = ctx;
|
|
1084
1131
|
|
|
1085
|
-
//
|
|
1086
|
-
const
|
|
1132
|
+
// 受控:入参树(优先顶层 value,其次 data.value)变了才重置内部树,页面把 change 的 value 写回时不会打断编辑
|
|
1133
|
+
const hasTopValue = p.value !== undefined && p.value !== null && typeof p.value === 'object' && !Array.isArray(p.value);
|
|
1134
|
+
const incoming = hasTopValue ? p.value : recOf(p.data).value;
|
|
1087
1135
|
const inSig = JSON.stringify([incoming ?? null, ctx.fields, ctx.maxDepth]);
|
|
1088
1136
|
if (inSig !== st.incomingSig) {
|
|
1137
|
+
const firstLoad = st.incomingSig === '\u0000';
|
|
1089
1138
|
st.incomingSig = inSig;
|
|
1090
1139
|
const next = normalizeTree(incoming, ctx.fmap, ctx.maxDepth);
|
|
1091
|
-
if (JSON.stringify(exportTree(next)) !== JSON.stringify(exportTree(st.tree))) {
|
|
1140
|
+
if (firstLoad || JSON.stringify(exportTree(next)) !== JSON.stringify(exportTree(st.tree))) {
|
|
1092
1141
|
st.tree = next;
|
|
1142
|
+
st.origin = exportTree(next);
|
|
1093
1143
|
st.touched.clear();
|
|
1094
1144
|
st.showAll = false;
|
|
1095
1145
|
}
|
|
@@ -1102,20 +1152,24 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
1102
1152
|
if (!restore) {
|
|
1103
1153
|
const active = root.ownerDocument.activeElement as HTMLElement | null;
|
|
1104
1154
|
if (active && active !== root && root.contains(active)) {
|
|
1105
|
-
const tagged = active.closest<HTMLElement>(
|
|
1106
|
-
const key = active.closest(
|
|
1107
|
-
const part = tagged.getAttribute(
|
|
1155
|
+
const tagged = active.closest<HTMLElement>(kitAttrSel(KIT_ATTR_SELECT_HOST))?.querySelector<HTMLElement>(`input${kitAttrSel(KIT_ATTR_PART)}`) ?? active;
|
|
1156
|
+
const key = active.closest(kitAttrSel(KIT_ATTR_PATH))?.getAttribute(KIT_ATTR_PATH);
|
|
1157
|
+
const part = tagged.getAttribute(KIT_ATTR_PART);
|
|
1108
1158
|
if (key && part && part !== 'value-opt') restore = [[key, part]];
|
|
1109
1159
|
}
|
|
1110
1160
|
}
|
|
1111
1161
|
|
|
1112
1162
|
st.rebuilding = true;
|
|
1113
1163
|
root.className = joinClass(ROOT_CLASS, ctx.cls);
|
|
1164
|
+
// 外框去留原先看祖先(surface-edge:祖先是面板时去第二圈);页面线写了入参时外框由取值表按层级邻接给,不再自报 edge
|
|
1165
|
+
if (!kitHasProps(p)) markKitEdge(root);
|
|
1166
|
+
// 只读时整块是只读数据状态
|
|
1167
|
+
kitMarkDataFacts(root, { readonly: ctx.readonly });
|
|
1114
1168
|
st.embeds.release(root);
|
|
1115
1169
|
root.textContent = '';
|
|
1116
1170
|
if (ctx.readonly) {
|
|
1117
1171
|
const text = mk('p', READONLY_CLASS, describeTree(st.tree, ctx.fmap, ctx.labels));
|
|
1118
|
-
text.setAttribute(
|
|
1172
|
+
text.setAttribute(KIT_ATTR_RULE_SUMMARY, '');
|
|
1119
1173
|
root.appendChild(text);
|
|
1120
1174
|
st.renderSig = sig;
|
|
1121
1175
|
st.rebuilding = false;
|
|
@@ -1124,12 +1178,13 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
1124
1178
|
root.appendChild(buildGroup(st.tree, [], 0, 1, ctx, st));
|
|
1125
1179
|
if (ctx.showSummary) {
|
|
1126
1180
|
const sum = mk('p', SUMMARY_CLASS);
|
|
1127
|
-
sum.setAttribute(
|
|
1181
|
+
sum.setAttribute(KIT_ATTR_RULE_SUMMARY, '');
|
|
1128
1182
|
sum.setAttribute('aria-live', 'polite');
|
|
1129
1183
|
root.appendChild(sum);
|
|
1130
1184
|
}
|
|
1131
1185
|
if (ctx.saveLabel !== '' || ctx.cancelLabel !== '') {
|
|
1132
1186
|
const foot = mk('div', FOOT_CLASS);
|
|
1187
|
+
kitMarkLevel(foot, 'foot'); kitApplyLevelClass(foot);
|
|
1133
1188
|
if (ctx.cancelLabel !== '') foot.appendChild(button(CANCEL_CLASS, ctx.cancelLabel, 'cancel', undefined, 'raised'));
|
|
1134
1189
|
if (ctx.saveLabel !== '') {
|
|
1135
1190
|
const saveBtn = button(SAVE_CLASS, ctx.saveLabel, 'save', undefined, 'raised');
|