soma-kit 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -340
- package/spec/generated/kit-page.schema.json +1134 -139
- package/spec/kit-grammar.json +935 -93
- package/spec/kit-grammar.schema.json +167 -2
- package/src/app/app-config.ts +219 -186
- package/src/app/define-kit-actions.ts +126 -20
- package/src/app/define-kit-app.ts +49 -4
- package/src/app/index.ts +5 -0
- package/src/app/kit-view-context.ts +39 -1
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +67 -23
- package/src/app/theme-runtime.ts +414 -85
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +104 -59
- package/src/base/anchored-layer.ts +7 -6
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +347 -50
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +143 -32
- package/src/base/check-core.ts +193 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +399 -27
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +148 -36
- package/src/base/context-menu.ts +23 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +114 -96
- package/src/base/date.ts +481 -74
- package/src/base/delta.ts +16 -9
- package/src/base/divider.ts +51 -33
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +57 -21
- package/src/base/gap-value.ts +34 -15
- package/src/base/hint-tips.ts +99 -29
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +79 -22
- package/src/base/inline-error.ts +13 -7
- package/src/base/input.ts +135 -35
- package/src/base/kbd.ts +30 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +282 -101
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +55 -22
- package/src/base/menu-button.ts +73 -22
- package/src/base/menu-core.ts +201 -24
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +7 -5
- package/src/base/motion/hover-gallery.ts +16 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +139 -27
- package/src/base/overlay-runtime.ts +30 -23
- package/src/base/overlay-shell.ts +59 -14
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +624 -73
- package/src/base/popup.ts +187 -52
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +141 -22
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +58 -16
- package/src/base/relation-cells.ts +541 -0
- package/src/base/resize-handle.ts +5 -3
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +70 -26
- package/src/base/select.ts +8 -3
- package/src/base/shared.ts +482 -71
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +123 -54
- package/src/base/tag.ts +184 -66
- package/src/base/text.ts +461 -71
- package/src/base/textarea.ts +88 -39
- package/src/base/time-picker.ts +335 -55
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +342 -88
- package/src/base/upload.ts +604 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +70 -5
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +52 -12
- package/src/biz/auth-panel/compile.ts +13 -3
- package/src/biz/auth-panel/shell.ts +27 -7
- package/src/biz/category-crud/compile.ts +51 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +29 -9
- package/src/biz/checkout-page/compile.ts +37 -3
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +26 -9
- package/src/biz/compose.ts +6 -1
- package/src/biz/data-components.ts +2 -0
- package/src/biz/import-wizard/compile.ts +4 -1
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +32 -18
- package/src/biz/index.ts +1 -1
- package/src/biz/landing-page/compile.ts +3 -2
- package/src/biz/landing-page/shell.ts +22 -3
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +54 -15
- package/src/biz/master-sub/compile.ts +194 -57
- package/src/biz/master-sub/detail-head.ts +141 -18
- package/src/biz/master-sub/index.ts +3 -0
- package/src/biz/master-sub/shell.ts +188 -62
- package/src/biz/multi-board/compile.ts +87 -36
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +3 -2
- package/src/biz/multi-board/prose-fold.ts +15 -11
- package/src/biz/multi-board/shell.ts +148 -37
- package/src/biz/notification-center/compile.ts +20 -6
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +43 -10
- package/src/biz/page-templates/domain-templates.ts +145 -22
- package/src/biz/page-templates/result-page/compile.ts +4 -1
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +17 -4
- package/src/biz/page-templates/sign-in-page/compile.ts +19 -8
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +28 -12
- package/src/biz/record-detail/compile.ts +39 -11
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +41 -10
- package/src/biz/settings-center/compile.ts +4 -1
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +30 -9
- package/src/biz/shared/action-host.ts +137 -46
- package/src/biz/shared/compile-helpers.ts +152 -28
- package/src/biz/shared/coordinator.ts +628 -147
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +58 -10
- package/src/biz/shared/overlay-shell.ts +40 -10
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +4 -2
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +21 -11
- package/src/biz/standard-crud/compile.ts +206 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +82 -22
- package/src/biz/standard-crud/summary.ts +2 -37
- package/src/biz/step-form/compile.ts +12 -3
- package/src/biz/step-form/hub.ts +165 -50
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +31 -15
- package/src/biz/types.ts +40 -4
- package/src/cli/kit-cli.ts +145 -26
- package/src/cli/kit-init.ts +3 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +446 -53
- package/src/compile/component-candidates.ts +56 -4
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +1 -1
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/rules-composition.ts +2 -1
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +382 -46
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +645 -28
- package/src/compile/styles.ts +226 -26
- package/src/compile/types.ts +62 -5
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +49 -22
- package/src/data/anchor-nav.ts +73 -15
- package/src/data/approval-flow.ts +210 -124
- package/src/data/assignment-picker.ts +163 -85
- package/src/data/async-result-panel.ts +110 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +141 -19
- package/src/data/calendar.ts +434 -96
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +72 -38
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +904 -77
- package/src/data/checklist.ts +78 -35
- package/src/data/code-view.ts +106 -48
- package/src/data/comment-thread.ts +607 -87
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +198 -30
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +107 -50
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +33 -17
- package/src/data/embed.ts +142 -7
- package/src/data/engine-ports.ts +13 -4
- package/src/data/field-mapper.ts +104 -48
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +603 -142
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +85 -27
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +637 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +38 -15
- package/src/data/image-viewer.ts +261 -62
- package/src/data/index.ts +63 -1
- package/src/data/item-list.ts +217 -57
- package/src/data/json-view.ts +165 -100
- package/src/data/kanban.ts +339 -87
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +155 -45
- package/src/data/matrix.ts +217 -112
- package/src/data/media-grid.ts +162 -38
- package/src/data/mega-menu.ts +39 -23
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +50 -15
- package/src/data/menu.ts +131 -47
- package/src/data/mockup.ts +30 -22
- package/src/data/modal-dialog.ts +90 -13
- package/src/data/navbar.ts +143 -61
- package/src/data/notice-list.ts +100 -48
- package/src/data/notify-renderer.ts +61 -7
- package/src/data/object-form.ts +1389 -130
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +122 -42
- package/src/data/panel-head.ts +237 -75
- package/src/data/permission-matrix.ts +371 -119
- package/src/data/permission-tree.ts +135 -80
- package/src/data/pricing-table.ts +106 -42
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +63 -31
- package/src/data/record-card.ts +239 -70
- package/src/data/record-picker.ts +56 -27
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +131 -41
- package/src/data/resident.ts +11 -1
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +206 -35
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +376 -102
- package/src/data/rule-builder.ts +129 -80
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +86 -43
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +438 -86
- package/src/data/static-lazy.ts +18 -0
- package/src/data/static-registry.ts +38 -2
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +63 -34
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +128 -47
- package/src/data/system-switcher.ts +40 -20
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +99 -31
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +110 -47
- package/src/data/transfer.ts +195 -47
- package/src/data/tree-table.ts +194 -112
- package/src/data/tree.ts +191 -70
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +242 -102
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +26 -4
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +1 -2
- package/src/frames/inherited-shell.ts +54 -13
- package/src/frames/page-bar.ts +205 -27
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +0 -2
- package/src/frames/shared.ts +64 -21
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +11 -7
- package/src/frames/split-frame/wiring.ts +14 -10
- package/src/frames/tabs-frame/shell.ts +3 -2
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +2 -0
- package/src/frames/workspace-frame/extras.ts +5 -3
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +22 -2
- package/src/frames/workspace-frame/state.ts +42 -14
- package/src/frames/workspace-frame/view.ts +697 -167
- package/src/generated/kit-grammar-runtime.ts +1016 -54
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +96 -3
- package/src/object-renderer/action-group.ts +175 -23
- package/src/object-renderer/action-more.ts +48 -17
- package/src/object-renderer/arrange.ts +241 -29
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +432 -107
- package/src/object-renderer/collection-table.ts +347 -45
- package/src/object-renderer/collection.ts +291 -62
- package/src/object-renderer/compile-data.ts +12 -2
- package/src/object-renderer/defaults.ts +6 -5
- package/src/object-renderer/emit-events.ts +45 -19
- package/src/object-renderer/emit-object.ts +35 -9
- package/src/object-renderer/emit-static.ts +734 -159
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +105 -18
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +18 -2
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +44 -2
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +71 -26
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +423 -104
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +428 -128
- package/src/object-renderer/types.ts +91 -2
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +15 -14
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +3 -2
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +76 -19
- package/src/recipes/control.ts +64 -5
- package/src/recipes/desc-list.ts +101 -7
- package/src/recipes/divider.ts +30 -9
- package/src/recipes/emphasis.ts +90 -5
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +3 -2
- package/src/recipes/index.ts +28 -4
- package/src/recipes/inherited-shell.ts +21 -15
- package/src/recipes/json-view.ts +6 -5
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +16 -6
- package/src/recipes/overlay.ts +47 -19
- package/src/recipes/page-width.ts +31 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +37 -19
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +5 -5
- package/src/recipes/state.ts +54 -3
- package/src/recipes/status.ts +14 -14
- package/src/recipes/strip.ts +47 -5
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +33 -4
- package/src/recipes/table-gap.ts +3 -2
- package/src/recipes/table-native-edit.ts +22 -9
- package/src/recipes/table-row.ts +45 -12
- package/src/recipes/tabs.ts +54 -22
- package/src/recipes/text-diff.ts +15 -8
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +68 -3
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +58 -12
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/icons.ts +28 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +165 -24
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +527 -16
- package/src/theme/kit-theme.tpl +491 -16
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +522 -185
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +3 -2
- package/src/theme/theme-tokens.ts +1601 -93
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/frames/list-summary.ts +0 -123
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
package/src/data/rule-builder.ts
CHANGED
|
@@ -12,22 +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';
|
|
26
27
|
import { kitButtonEdgeRecipe, kitControlEdgeRecipe } from '../recipes/control';
|
|
27
28
|
import { kitShellRecipe } from '../recipes/container';
|
|
29
|
+
import { kitDividerRecipe } from '../recipes/divider';
|
|
28
30
|
import { KIT_STATE_EMPTY_BOX } from '../recipes/placeholder';
|
|
29
|
-
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
31
|
+
import { kitActionRecipe, kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
30
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';
|
|
31
41
|
|
|
32
42
|
// ════════════════════════════════════════════════════════════════
|
|
33
43
|
// 单条条件模块(纯函数 + 值控件构造):运算符表、按字段类型取运算符、值形状归一、校验文字、值控件(复用 kit 基础文本类控件的
|
|
@@ -246,20 +256,22 @@ const CONTROL = `${FIELD_CLASS.md} data-kit-invalid:border-danger`;
|
|
|
246
256
|
const DATE_EDGE = kitControlEdgeRecipe();
|
|
247
257
|
const PILL_EDGE = kitButtonEdgeRecipe();
|
|
248
258
|
const MODE_EDGE = kitControlEdgeRecipe({ wrapper: true, hover: false });
|
|
249
|
-
const DATE_CONTROL =
|
|
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
|
+
);
|
|
250
263
|
const RANGE_SEP = 'text-fg-subtle';
|
|
251
264
|
const PILLS = 'flex flex-wrap gap-1.5';
|
|
252
|
-
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
|
+
);
|
|
253
269
|
const HALF = 'min-w-28 flex-1';
|
|
254
270
|
|
|
255
271
|
export const KIT_RULE_CONDITION_CLASS_CANDIDATES: readonly string[] = Object.freeze(
|
|
256
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(),
|
|
257
273
|
);
|
|
258
274
|
|
|
259
|
-
function inputType(type: RuleFieldType): string {
|
|
260
|
-
return type === 'number' ? 'number' : 'text';
|
|
261
|
-
}
|
|
262
|
-
|
|
263
275
|
/**
|
|
264
276
|
* 自绘下拉(没有原生 <select>):返回挂进行里的外壳;读值的载体是外壳里的 hidden input,带 data-kit-part,
|
|
265
277
|
* 选中后派发冒泡的 input / change(委托监听按 event.target.value 读);可聚焦字段是外壳里的 role=combobox。
|
|
@@ -268,14 +280,14 @@ function inputType(type: RuleFieldType): string {
|
|
|
268
280
|
function selectFieldOf(part: string, label: string, opts: ReadonlyArray<{ value: string; label: string }>, value: string, embeds?: KitEmbedBag): HTMLElement {
|
|
269
281
|
const field = mountKitSelectField({ options: opts, value, ariaLabel: label });
|
|
270
282
|
embeds?.add(field);
|
|
271
|
-
field.input.setAttribute(
|
|
272
|
-
field.el.setAttribute(
|
|
283
|
+
field.input.setAttribute(KIT_ATTR_PART, part);
|
|
284
|
+
field.el.setAttribute(KIT_ATTR_SELECT_HOST, '');
|
|
273
285
|
return field.el;
|
|
274
286
|
}
|
|
275
287
|
|
|
276
288
|
/** 控件上要被聚焦 / 标 aria-invalid 的可见元素:自绘下拉的载体是 hidden input,可见处是同壳的 combobox 字段 */
|
|
277
289
|
function visibleOf(c: HTMLElement): HTMLElement {
|
|
278
|
-
return c.closest<HTMLElement>(
|
|
290
|
+
return c.closest<HTMLElement>(kitAttrSel(KIT_ATTR_SELECT_HOST))?.querySelector<HTMLElement>('[role="combobox"]') ?? c;
|
|
279
291
|
}
|
|
280
292
|
|
|
281
293
|
function valueSelectOf(part: string, label: string, opts: readonly RuleOption[], value: string, placeholder: string, embeds?: KitEmbedBag): HTMLElement {
|
|
@@ -286,9 +298,10 @@ function valueSelectOf(part: string, label: string, opts: readonly RuleOption[],
|
|
|
286
298
|
function inputOf(part: string, label: string, type: RuleFieldType, value: unknown): HTMLInputElement {
|
|
287
299
|
const el = mk('input', CONTROL);
|
|
288
300
|
setKitFace(el, 'field');
|
|
289
|
-
el.type =
|
|
301
|
+
el.type = 'text';
|
|
302
|
+
if (type === 'number') el.inputMode = 'decimal';
|
|
290
303
|
el.autocomplete = 'off';
|
|
291
|
-
el.setAttribute(
|
|
304
|
+
el.setAttribute(KIT_ATTR_PART, part);
|
|
292
305
|
el.setAttribute('aria-label', label);
|
|
293
306
|
el.value = textOf(value);
|
|
294
307
|
return el;
|
|
@@ -298,7 +311,7 @@ function inputOf(part: string, label: string, type: RuleFieldType, value: unknow
|
|
|
298
311
|
function dateOf(part: string, label: string, value: unknown, embeds?: KitEmbedBag): HTMLElement {
|
|
299
312
|
const field = mountKitDateField({ value: textOf(value), fieldClass: DATE_CONTROL });
|
|
300
313
|
embeds?.add(field);
|
|
301
|
-
field.input.setAttribute(
|
|
314
|
+
field.input.setAttribute(KIT_ATTR_PART, part);
|
|
302
315
|
field.input.setAttribute('aria-label', label);
|
|
303
316
|
return field.el;
|
|
304
317
|
}
|
|
@@ -338,16 +351,16 @@ export function buildValueControl(cond: RuleCondition, field: RuleField | undefi
|
|
|
338
351
|
const pills = mk('div', PILLS);
|
|
339
352
|
pills.setAttribute('role', 'group');
|
|
340
353
|
pills.setAttribute('aria-label', aria);
|
|
341
|
-
pills.setAttribute(
|
|
354
|
+
pills.setAttribute(KIT_ATTR_PART, 'value-pills');
|
|
342
355
|
const chosen = new Set((Array.isArray(cond.value) ? cond.value : []).map(textOf));
|
|
343
356
|
for (const o of field?.options ?? []) {
|
|
344
357
|
const b = mk('button', PILL, o.label);
|
|
345
358
|
b.type = 'button';
|
|
346
359
|
setKitFace(b, 'raised');
|
|
347
|
-
b.setAttribute(
|
|
348
|
-
b.setAttribute(
|
|
360
|
+
b.setAttribute(KIT_ATTR_PART, 'value-opt');
|
|
361
|
+
b.setAttribute(KIT_ATTR_OPT, o.value);
|
|
349
362
|
b.setAttribute('aria-pressed', chosen.has(o.value) ? 'true' : 'false');
|
|
350
|
-
if (chosen.has(o.value)) b.setAttribute(
|
|
363
|
+
if (chosen.has(o.value)) b.setAttribute(KIT_ATTR_SELECTED, '');
|
|
351
364
|
pills.appendChild(b);
|
|
352
365
|
}
|
|
353
366
|
wrap.appendChild(pills);
|
|
@@ -364,7 +377,7 @@ export function buildValueControl(cond: RuleCondition, field: RuleField | undefi
|
|
|
364
377
|
* 数字框清空为 '',非法数字为 '';列表文本按中英文逗号切分;药丸点击切换并同步 aria-pressed。
|
|
365
378
|
*/
|
|
366
379
|
export function applyValueEdit(cond: RuleCondition, field: RuleField | undefined, el: HTMLElement): boolean {
|
|
367
|
-
const part = el.getAttribute(
|
|
380
|
+
const part = el.getAttribute(KIT_ATTR_PART) ?? '';
|
|
368
381
|
const type = field?.type ?? 'text';
|
|
369
382
|
const raw = (el as HTMLInputElement).value ?? '';
|
|
370
383
|
if (part === 'value') {
|
|
@@ -382,14 +395,14 @@ export function applyValueEdit(cond: RuleCondition, field: RuleField | undefined
|
|
|
382
395
|
return true;
|
|
383
396
|
}
|
|
384
397
|
if (part === 'value-opt') {
|
|
385
|
-
const opt = el.getAttribute(
|
|
398
|
+
const opt = el.getAttribute(KIT_ATTR_OPT) ?? '';
|
|
386
399
|
const cur = (Array.isArray(cond.value) ? cond.value : []).map(textOf);
|
|
387
400
|
const next = cur.includes(opt) ? cur.filter((x) => x !== opt) : [...cur, opt];
|
|
388
401
|
cond.value = (field?.options ?? []).map((o) => o.value).filter((v) => next.includes(v));
|
|
389
402
|
const on = (cond.value as string[]).includes(opt);
|
|
390
403
|
el.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
391
|
-
if (on) el.setAttribute(
|
|
392
|
-
else el.removeAttribute(
|
|
404
|
+
if (on) el.setAttribute(KIT_ATTR_SELECTED, '');
|
|
405
|
+
else el.removeAttribute(KIT_ATTR_SELECTED);
|
|
393
406
|
return true;
|
|
394
407
|
}
|
|
395
408
|
return false;
|
|
@@ -593,36 +606,36 @@ export const parsePathKey = (key: string): number[] => key.split('.').slice(1).m
|
|
|
593
606
|
// RuleBuilder 样式常量:Tailwind 类串与候选类清单
|
|
594
607
|
// ════════════════════════════════════════════════════════════════
|
|
595
608
|
|
|
596
|
-
const ROOT_CLASS = 'flex flex-col gap-3 text-sm text-fg';
|
|
597
|
-
const GROUP_CLASS =
|
|
598
|
-
const GROUP_NESTED_CLASS = mergeClass('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'));
|
|
599
612
|
const HEAD_CLASS = 'flex flex-wrap items-center gap-2';
|
|
600
|
-
const MODE_WRAP_CLASS = `inline-flex rounded-
|
|
601
|
-
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';
|
|
602
615
|
// 「非」开关:未选 = 色调按钮(次级),选中 = 实心主色(态差靠填充,不靠描边)
|
|
603
616
|
const NOT_BTN_CLASS = mergeClass(kitEmphasisButtonRecipe('button.toolbar'), 'data-kit-selected:bg-primary data-kit-selected:text-primary-fg');
|
|
604
617
|
const SPACER_CLASS = 'flex-1';
|
|
605
618
|
const TOOL_BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
606
|
-
const ACT_BTN_CLASS = 'inline-flex
|
|
607
|
-
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');
|
|
608
621
|
const ACTIONS_CLASS = 'inline-flex items-center gap-0.5';
|
|
609
622
|
const BODY_CLASS = 'flex flex-col gap-2';
|
|
610
|
-
const COND_CLASS =
|
|
623
|
+
const COND_CLASS = 'flex flex-col gap-1 py-0.5';
|
|
611
624
|
const COND_ROW_CLASS = 'flex flex-wrap items-center gap-2';
|
|
612
625
|
const CELL_CLASS = 'min-w-28 flex-1';
|
|
613
626
|
const ERR_CLASS = 'text-xs text-danger-on-soft';
|
|
614
627
|
// 空态:与全 kit 同一口径(一行标题,无虚线框)
|
|
615
628
|
const EMPTY_CLASS = KIT_STATE_EMPTY_BOX;
|
|
616
|
-
const SUMMARY_CLASS = '
|
|
629
|
+
const SUMMARY_CLASS = 'sub-block px-3 py-2 text-sm text-fg-muted'; // 摘要块 = 子块(KT-HB-F),不是井
|
|
617
630
|
const READONLY_CLASS = 'text-sm text-fg';
|
|
618
631
|
const FOOT_CLASS = 'flex items-center justify-end gap-2';
|
|
619
|
-
const SAVE_CLASS = '
|
|
632
|
+
const SAVE_CLASS = kitActionRecipe('save', { region: 'form', rankInRegion: 0 });
|
|
620
633
|
const CANCEL_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
621
634
|
|
|
622
635
|
export const KIT_RULE_BUILDER_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
623
636
|
ROOT_CLASS, GROUP_CLASS, GROUP_NESTED_CLASS, HEAD_CLASS, MODE_WRAP_CLASS, MODE_BTN_CLASS, NOT_BTN_CLASS, SPACER_CLASS, TOOL_BTN_CLASS,
|
|
624
637
|
ACT_BTN_CLASS, DEL_BTN_CLASS, ACTIONS_CLASS, BODY_CLASS, COND_CLASS, COND_ROW_CLASS, CELL_CLASS, ERR_CLASS, EMPTY_CLASS, SUMMARY_CLASS,
|
|
625
|
-
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,
|
|
626
639
|
);
|
|
627
640
|
|
|
628
641
|
// ════════════════════════════════════════════════════════════════
|
|
@@ -650,6 +663,7 @@ interface Ctx {
|
|
|
650
663
|
|
|
651
664
|
interface State {
|
|
652
665
|
tree: RuleGroup;
|
|
666
|
+
origin: RuleGroup;
|
|
653
667
|
incomingSig: string;
|
|
654
668
|
renderSig: string;
|
|
655
669
|
touched: Set<string>;
|
|
@@ -692,22 +706,31 @@ function button(cls: string, text: string, part: string, aria?: string, surface:
|
|
|
692
706
|
const b = mk('button', cls, text);
|
|
693
707
|
b.type = 'button';
|
|
694
708
|
setKitFace(b, surface);
|
|
695
|
-
b.setAttribute(
|
|
709
|
+
b.setAttribute(KIT_ATTR_PART, part);
|
|
696
710
|
if (aria !== undefined) b.setAttribute('aria-label', aria);
|
|
697
711
|
return b;
|
|
698
712
|
}
|
|
699
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
|
+
|
|
700
723
|
function buildActions(path: readonly number[], index: number, count: number, ctx: Ctx, isGroup: boolean, atLimit: boolean): HTMLElement {
|
|
701
724
|
const l = ctx.labels;
|
|
702
725
|
const kind = `${isGroup ? l.group : l.condition} ${numLabel(path)}`;
|
|
703
726
|
const box = mk('div', ACTIONS_CLASS);
|
|
704
|
-
const up =
|
|
727
|
+
const up = iconButton(ACT_BTN_CLASS, 'arrow-up', 'up', `${l.move_up} ${kind}`);
|
|
705
728
|
up.disabled = index <= 0;
|
|
706
|
-
const down =
|
|
729
|
+
const down = iconButton(ACT_BTN_CLASS, 'arrow-down', 'down', `${l.move_down} ${kind}`);
|
|
707
730
|
down.disabled = index >= count - 1;
|
|
708
|
-
const dup =
|
|
731
|
+
const dup = iconButton(ACT_BTN_CLASS, 'copy', 'dup', `${l.duplicate} ${kind}`);
|
|
709
732
|
if (atLimit) { dup.disabled = true; dup.title = l.node_limit ?? ''; }
|
|
710
|
-
const del =
|
|
733
|
+
const del = iconButton(DEL_BTN_CLASS, 'close', 'del', `${l.remove} ${kind}`);
|
|
711
734
|
box.append(up, down, dup, del);
|
|
712
735
|
return box;
|
|
713
736
|
}
|
|
@@ -718,8 +741,10 @@ function buildCondition(cond: RuleCondition, path: number[], index: number, coun
|
|
|
718
741
|
const row = mk('div', COND_CLASS);
|
|
719
742
|
row.setAttribute('role', 'group');
|
|
720
743
|
row.setAttribute('aria-label', `${l.condition} ${numLabel(path)}`);
|
|
721
|
-
row.setAttribute(
|
|
722
|
-
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);
|
|
723
748
|
const line = mk('div', COND_ROW_CLASS);
|
|
724
749
|
const field = ctx.fmap.get(cond.field);
|
|
725
750
|
|
|
@@ -741,7 +766,7 @@ function buildCondition(cond: RuleCondition, path: number[], index: number, coun
|
|
|
741
766
|
|
|
742
767
|
const err = mk('p', ERR_CLASS);
|
|
743
768
|
err.id = `${st.uid}-${key}`;
|
|
744
|
-
err.setAttribute(
|
|
769
|
+
err.setAttribute(KIT_ATTR_ERROR, '');
|
|
745
770
|
err.hidden = true;
|
|
746
771
|
row.append(line, err);
|
|
747
772
|
return row;
|
|
@@ -756,10 +781,13 @@ function buildGroup(g: RuleGroup, path: number[], index: number, count: number,
|
|
|
756
781
|
const el = mk('div', nested ? GROUP_NESTED_CLASS : GROUP_CLASS);
|
|
757
782
|
el.setAttribute('role', 'group');
|
|
758
783
|
el.setAttribute('aria-label', nested ? `${l.group} ${numLabel(path)}` : l.group ?? '');
|
|
759
|
-
el.setAttribute(
|
|
760
|
-
el.setAttribute(
|
|
784
|
+
el.setAttribute(KIT_ATTR_PATH, key);
|
|
785
|
+
el.setAttribute(KIT_ATTR_GROUP, '');
|
|
786
|
+
// 顶层组 = 节,嵌套组 = 节里成块的子内容(子块);组头(且 / 或、加条件)= 面头
|
|
787
|
+
kitMarkLevel(el, nested ? 'sub' : 'section'); kitApplyLevelClass(el);
|
|
761
788
|
|
|
762
789
|
const head = mk('div', HEAD_CLASS);
|
|
790
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
763
791
|
const modes = mk('div', MODE_WRAP_CLASS);
|
|
764
792
|
modes.setAttribute('role', 'radiogroup');
|
|
765
793
|
modes.setAttribute('aria-label', l.mode ?? '');
|
|
@@ -768,16 +796,19 @@ function buildGroup(g: RuleGroup, path: number[], index: number, count: number,
|
|
|
768
796
|
const b = button(MODE_BTN_CLASS, (op === 'or' ? l.or : l.and) ?? '', 'mode');
|
|
769
797
|
b.setAttribute('role', 'radio');
|
|
770
798
|
b.setAttribute('aria-checked', on ? 'true' : 'false');
|
|
771
|
-
b.setAttribute(
|
|
799
|
+
b.setAttribute(KIT_ATTR_MODE, op);
|
|
772
800
|
b.tabIndex = on ? 0 : -1;
|
|
773
|
-
if (on) b.setAttribute(
|
|
801
|
+
if (on) b.setAttribute(KIT_ATTR_SELECTED, '');
|
|
802
|
+
// 选中的组合方式同写交互状态(aria-checked 上面已写)
|
|
803
|
+
kitMarkPicked(b, 'selected', on, null);
|
|
774
804
|
modes.appendChild(b);
|
|
775
805
|
}
|
|
776
806
|
head.appendChild(modes);
|
|
777
807
|
if (ctx.allowNot) {
|
|
778
808
|
const nb = button(NOT_BTN_CLASS, l.not ?? '', 'not', undefined, 'raised');
|
|
779
809
|
nb.setAttribute('aria-pressed', g.not === true ? 'true' : 'false');
|
|
780
|
-
if (g.not === true) nb.setAttribute(
|
|
810
|
+
if (g.not === true) nb.setAttribute(KIT_ATTR_SELECTED, '');
|
|
811
|
+
kitMarkPicked(nb, 'selected', g.not === true, null);
|
|
781
812
|
head.appendChild(nb);
|
|
782
813
|
}
|
|
783
814
|
head.appendChild(mk('span', SPACER_CLASS));
|
|
@@ -796,7 +827,8 @@ function buildGroup(g: RuleGroup, path: number[], index: number, count: number,
|
|
|
796
827
|
const body = mk('div', BODY_CLASS);
|
|
797
828
|
if (g.rules.length === 0) {
|
|
798
829
|
const empty = mk('p', EMPTY_CLASS, l.empty ?? '');
|
|
799
|
-
empty.setAttribute(
|
|
830
|
+
empty.setAttribute(KIT_ATTR_EMPTY, '');
|
|
831
|
+
kitMarkLevel(empty, 'sub'); kitApplyLevelClass(empty);
|
|
800
832
|
body.appendChild(empty);
|
|
801
833
|
}
|
|
802
834
|
g.rules.forEach((n: RuleNode, i) => {
|
|
@@ -811,9 +843,9 @@ function buildGroup(g: RuleGroup, path: number[], index: number, count: number,
|
|
|
811
843
|
|
|
812
844
|
function applyFocus(root: HTMLElement, cands: readonly FocusCand[]): void {
|
|
813
845
|
for (const [key, part] of cands) {
|
|
814
|
-
const node = root.querySelector(`[
|
|
846
|
+
const node = root.querySelector(`[${KIT_ATTR_PATH}="${key}"]`);
|
|
815
847
|
if (!node) continue;
|
|
816
|
-
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}"]`;
|
|
817
849
|
const el = node.querySelector<HTMLElement & { disabled?: boolean }>(sel);
|
|
818
850
|
if (el && el.disabled !== true) { visibleOf(el).focus(); return; }
|
|
819
851
|
}
|
|
@@ -824,7 +856,7 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
824
856
|
const stateOf = (root: HTMLElement): State => {
|
|
825
857
|
let s = states.get(root);
|
|
826
858
|
if (!s) {
|
|
827
|
-
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() };
|
|
828
860
|
states.set(root, s);
|
|
829
861
|
}
|
|
830
862
|
return s;
|
|
@@ -838,22 +870,22 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
838
870
|
if (!ctx) return [];
|
|
839
871
|
const issues = issuesOf(st);
|
|
840
872
|
const byKey = new Map(issues.map((i) => [pathKey(i.path), i]));
|
|
841
|
-
for (const row of Array.from(root.querySelectorAll<HTMLElement>(
|
|
842
|
-
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) ?? '';
|
|
843
875
|
const issue = byKey.get(key);
|
|
844
876
|
const show = issue !== undefined && (st.showAll || st.touched.has(key));
|
|
845
|
-
const err = row.querySelector<HTMLElement>(
|
|
877
|
+
const err = row.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_ERROR));
|
|
846
878
|
if (err) { err.textContent = show ? issue.message : ''; err.hidden = !show; }
|
|
847
|
-
for (const hit of Array.from(row.querySelectorAll<HTMLElement>(
|
|
879
|
+
for (const hit of Array.from(row.querySelectorAll<HTMLElement>(`input${kitAttrSel(KIT_ATTR_PART)}`))) {
|
|
848
880
|
const c = visibleOf(hit);
|
|
849
|
-
const part = hit.getAttribute(
|
|
881
|
+
const part = hit.getAttribute(KIT_ATTR_PART) ?? '';
|
|
850
882
|
const target = issue?.code === 'field' ? part === 'field' : part.startsWith('value');
|
|
851
883
|
const bad = show && target;
|
|
852
|
-
if (bad) { c.setAttribute(
|
|
853
|
-
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'); }
|
|
854
886
|
}
|
|
855
887
|
}
|
|
856
|
-
const sum = root.querySelector<HTMLElement>(
|
|
888
|
+
const sum = root.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_RULE_SUMMARY));
|
|
857
889
|
if (sum) sum.textContent = describeTree(st.tree, ctx.fmap, ctx.labels);
|
|
858
890
|
return issues;
|
|
859
891
|
}
|
|
@@ -882,6 +914,7 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
882
914
|
layer: 'data',
|
|
883
915
|
props: {
|
|
884
916
|
data: { type: 'object', default: {}, desc: '{ fields?, value? }:value 为条件树 { op, not?, rules[] }' },
|
|
917
|
+
value: { type: 'object', default: null, desc: '条件树 { op, not?, rules[] }(顶层受控值,非空对象时优先于 data.value)' },
|
|
885
918
|
fields: { type: 'array', default: [], desc: '字段 [{ name, label?, type?: text|number|date|enum|boolean, options? }],非空时优先于 data.fields' },
|
|
886
919
|
readonly: { type: 'boolean', default: false, desc: '只读:只渲染可读摘要文字' },
|
|
887
920
|
max_depth: { type: 'number', default: RULE_MAX_DEPTH, desc: `组的最大嵌套层数(含根组),不超过 ${RULE_MAX_DEPTH}` },
|
|
@@ -901,13 +934,13 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
901
934
|
cancel: { payload: {}, desc: '点取消' },
|
|
902
935
|
},
|
|
903
936
|
},
|
|
904
|
-
templateHtml: `<section
|
|
937
|
+
templateHtml: `<section ${KIT_ATTR_CONTAINER}="card" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
905
938
|
controllerFactory: createKitController(() => ({
|
|
906
939
|
busyAware: true,
|
|
907
940
|
attach(root, api) {
|
|
908
941
|
const nodeOf = (el: Element | null): { key: string; path: number[] } | null => {
|
|
909
|
-
const n = el?.closest<HTMLElement>(
|
|
910
|
-
const key = n?.getAttribute(
|
|
942
|
+
const n = el?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_PATH));
|
|
943
|
+
const key = n?.getAttribute(KIT_ATTR_PATH);
|
|
911
944
|
return key ? { key, path: parsePathKey(key) } : null;
|
|
912
945
|
};
|
|
913
946
|
const sibling = (path: number[], i: number): string => pathKey([...path.slice(0, -1), i]);
|
|
@@ -918,19 +951,19 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
918
951
|
};
|
|
919
952
|
|
|
920
953
|
const onClick = (event: Event): void => {
|
|
921
|
-
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));
|
|
922
955
|
if (!t || !root.contains(t) || t.disabled === true) return;
|
|
923
956
|
const st = stateOf(root);
|
|
924
957
|
const ctx = st.ctx;
|
|
925
958
|
if (!ctx) return;
|
|
926
|
-
const part = t.getAttribute(
|
|
959
|
+
const part = t.getAttribute(KIT_ATTR_PART);
|
|
927
960
|
const at = nodeOf(t);
|
|
928
961
|
const path = at?.path ?? [];
|
|
929
962
|
const key = at?.key ?? 'r';
|
|
930
963
|
switch (part) {
|
|
931
964
|
case 'mode': {
|
|
932
965
|
const g = groupAt(st.tree, path);
|
|
933
|
-
const op = t.getAttribute(
|
|
966
|
+
const op = t.getAttribute(KIT_ATTR_MODE) === 'or' ? 'or' : 'and';
|
|
934
967
|
if (g && g.op !== op) { g.op = op; commit(root, st, api, [[key, 'mode']], false); }
|
|
935
968
|
return;
|
|
936
969
|
}
|
|
@@ -981,8 +1014,8 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
981
1014
|
const issues = refreshIssues(root, st);
|
|
982
1015
|
if (issues.length > 0) {
|
|
983
1016
|
const first = issues[0] as RuleIssue;
|
|
984
|
-
const row = root.querySelector(`[
|
|
985
|
-
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"]`);
|
|
986
1019
|
if (ctl) visibleOf(ctl).focus();
|
|
987
1020
|
api.emit('invalid', { issues: issues.map((i) => ({ path: i.path.join('.'), code: i.code, message: i.message })) });
|
|
988
1021
|
return;
|
|
@@ -990,14 +1023,22 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
990
1023
|
api.emit('saved', { value: exportTree(st.tree) });
|
|
991
1024
|
return;
|
|
992
1025
|
}
|
|
993
|
-
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
|
+
}
|
|
994
1035
|
default:
|
|
995
1036
|
}
|
|
996
1037
|
};
|
|
997
1038
|
|
|
998
1039
|
const onChange = (event: Event): void => {
|
|
999
1040
|
const el = event.target as HTMLInputElement | null;
|
|
1000
|
-
const part = el?.getAttribute?.(
|
|
1041
|
+
const part = el?.getAttribute?.(KIT_ATTR_PART);
|
|
1001
1042
|
if (!el || !part) return;
|
|
1002
1043
|
const st = stateOf(root);
|
|
1003
1044
|
const ctx = st.ctx;
|
|
@@ -1030,7 +1071,7 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
1030
1071
|
const el = event.target as HTMLElement | null;
|
|
1031
1072
|
if (!el || !root.contains(el)) return;
|
|
1032
1073
|
const st = stateOf(root);
|
|
1033
|
-
const part = el.getAttribute(
|
|
1074
|
+
const part = el.getAttribute(KIT_ATTR_PART);
|
|
1034
1075
|
if (part === 'mode' && ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(event.key)) {
|
|
1035
1076
|
event.preventDefault();
|
|
1036
1077
|
const at = nodeOf(el);
|
|
@@ -1052,11 +1093,11 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
1052
1093
|
const onFocusOut = (event: FocusEvent): void => {
|
|
1053
1094
|
const st = stateOf(root);
|
|
1054
1095
|
if (st.rebuilding) return;
|
|
1055
|
-
const row = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
1096
|
+
const row = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_COND));
|
|
1056
1097
|
if (!row) return;
|
|
1057
1098
|
const to = event.relatedTarget as Node | null;
|
|
1058
1099
|
if (to && row.contains(to)) return;
|
|
1059
|
-
const key = row.getAttribute(
|
|
1100
|
+
const key = row.getAttribute(KIT_ATTR_PATH);
|
|
1060
1101
|
if (!key || st.touched.has(key)) return;
|
|
1061
1102
|
st.touched.add(key);
|
|
1062
1103
|
refreshIssues(root, st);
|
|
@@ -1088,14 +1129,17 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
1088
1129
|
const ctx = ctxOf(p);
|
|
1089
1130
|
st.ctx = ctx;
|
|
1090
1131
|
|
|
1091
|
-
//
|
|
1092
|
-
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;
|
|
1093
1135
|
const inSig = JSON.stringify([incoming ?? null, ctx.fields, ctx.maxDepth]);
|
|
1094
1136
|
if (inSig !== st.incomingSig) {
|
|
1137
|
+
const firstLoad = st.incomingSig === '\u0000';
|
|
1095
1138
|
st.incomingSig = inSig;
|
|
1096
1139
|
const next = normalizeTree(incoming, ctx.fmap, ctx.maxDepth);
|
|
1097
|
-
if (JSON.stringify(exportTree(next)) !== JSON.stringify(exportTree(st.tree))) {
|
|
1140
|
+
if (firstLoad || JSON.stringify(exportTree(next)) !== JSON.stringify(exportTree(st.tree))) {
|
|
1098
1141
|
st.tree = next;
|
|
1142
|
+
st.origin = exportTree(next);
|
|
1099
1143
|
st.touched.clear();
|
|
1100
1144
|
st.showAll = false;
|
|
1101
1145
|
}
|
|
@@ -1108,20 +1152,24 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
1108
1152
|
if (!restore) {
|
|
1109
1153
|
const active = root.ownerDocument.activeElement as HTMLElement | null;
|
|
1110
1154
|
if (active && active !== root && root.contains(active)) {
|
|
1111
|
-
const tagged = active.closest<HTMLElement>(
|
|
1112
|
-
const key = active.closest(
|
|
1113
|
-
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);
|
|
1114
1158
|
if (key && part && part !== 'value-opt') restore = [[key, part]];
|
|
1115
1159
|
}
|
|
1116
1160
|
}
|
|
1117
1161
|
|
|
1118
1162
|
st.rebuilding = true;
|
|
1119
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 });
|
|
1120
1168
|
st.embeds.release(root);
|
|
1121
1169
|
root.textContent = '';
|
|
1122
1170
|
if (ctx.readonly) {
|
|
1123
1171
|
const text = mk('p', READONLY_CLASS, describeTree(st.tree, ctx.fmap, ctx.labels));
|
|
1124
|
-
text.setAttribute(
|
|
1172
|
+
text.setAttribute(KIT_ATTR_RULE_SUMMARY, '');
|
|
1125
1173
|
root.appendChild(text);
|
|
1126
1174
|
st.renderSig = sig;
|
|
1127
1175
|
st.rebuilding = false;
|
|
@@ -1130,12 +1178,13 @@ export function createRuleBuilder(): SomaComponentDefinition {
|
|
|
1130
1178
|
root.appendChild(buildGroup(st.tree, [], 0, 1, ctx, st));
|
|
1131
1179
|
if (ctx.showSummary) {
|
|
1132
1180
|
const sum = mk('p', SUMMARY_CLASS);
|
|
1133
|
-
sum.setAttribute(
|
|
1181
|
+
sum.setAttribute(KIT_ATTR_RULE_SUMMARY, '');
|
|
1134
1182
|
sum.setAttribute('aria-live', 'polite');
|
|
1135
1183
|
root.appendChild(sum);
|
|
1136
1184
|
}
|
|
1137
1185
|
if (ctx.saveLabel !== '' || ctx.cancelLabel !== '') {
|
|
1138
1186
|
const foot = mk('div', FOOT_CLASS);
|
|
1187
|
+
kitMarkLevel(foot, 'foot'); kitApplyLevelClass(foot);
|
|
1139
1188
|
if (ctx.cancelLabel !== '') foot.appendChild(button(CANCEL_CLASS, ctx.cancelLabel, 'cancel', undefined, 'raised'));
|
|
1140
1189
|
if (ctx.saveLabel !== '') {
|
|
1141
1190
|
const saveBtn = button(SAVE_CLASS, ctx.saveLabel, 'save', undefined, 'raised');
|