soma-kit 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -340
- package/spec/generated/kit-page.schema.json +1134 -139
- package/spec/kit-grammar.json +934 -92
- package/spec/kit-grammar.schema.json +167 -2
- package/src/app/app-config.ts +219 -186
- package/src/app/define-kit-actions.ts +126 -20
- package/src/app/define-kit-app.ts +49 -4
- package/src/app/index.ts +5 -0
- package/src/app/kit-view-context.ts +39 -1
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +67 -23
- package/src/app/theme-runtime.ts +414 -85
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +104 -59
- package/src/base/anchored-layer.ts +7 -6
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +347 -50
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +143 -32
- package/src/base/check-core.ts +193 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +399 -27
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +148 -36
- package/src/base/context-menu.ts +23 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +114 -96
- package/src/base/date.ts +481 -74
- package/src/base/delta.ts +16 -9
- package/src/base/divider.ts +51 -33
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +57 -21
- package/src/base/gap-value.ts +34 -15
- package/src/base/hint-tips.ts +99 -29
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +79 -22
- package/src/base/inline-error.ts +13 -7
- package/src/base/input.ts +135 -35
- package/src/base/kbd.ts +30 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +282 -101
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +55 -22
- package/src/base/menu-button.ts +73 -22
- package/src/base/menu-core.ts +201 -24
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +7 -5
- package/src/base/motion/hover-gallery.ts +16 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +139 -27
- package/src/base/overlay-runtime.ts +30 -23
- package/src/base/overlay-shell.ts +59 -14
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +624 -73
- package/src/base/popup.ts +187 -52
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +141 -22
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +58 -16
- package/src/base/relation-cells.ts +541 -0
- package/src/base/resize-handle.ts +5 -3
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +70 -26
- package/src/base/select.ts +8 -3
- package/src/base/shared.ts +482 -71
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +123 -54
- package/src/base/tag.ts +184 -66
- package/src/base/text.ts +461 -71
- package/src/base/textarea.ts +88 -39
- package/src/base/time-picker.ts +335 -55
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +342 -88
- package/src/base/upload.ts +604 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +70 -5
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +52 -12
- package/src/biz/auth-panel/compile.ts +13 -3
- package/src/biz/auth-panel/shell.ts +27 -7
- package/src/biz/category-crud/compile.ts +51 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +29 -9
- package/src/biz/checkout-page/compile.ts +37 -3
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +26 -9
- package/src/biz/compose.ts +6 -1
- package/src/biz/data-components.ts +2 -0
- package/src/biz/import-wizard/compile.ts +4 -1
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +32 -18
- package/src/biz/index.ts +1 -1
- package/src/biz/landing-page/compile.ts +3 -2
- package/src/biz/landing-page/shell.ts +22 -3
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +54 -15
- package/src/biz/master-sub/compile.ts +194 -57
- package/src/biz/master-sub/detail-head.ts +141 -18
- package/src/biz/master-sub/index.ts +3 -0
- package/src/biz/master-sub/shell.ts +186 -57
- package/src/biz/multi-board/compile.ts +87 -36
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +3 -2
- package/src/biz/multi-board/prose-fold.ts +15 -11
- package/src/biz/multi-board/shell.ts +148 -37
- package/src/biz/notification-center/compile.ts +20 -6
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +43 -10
- package/src/biz/page-templates/domain-templates.ts +145 -22
- package/src/biz/page-templates/result-page/compile.ts +4 -1
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +17 -4
- package/src/biz/page-templates/sign-in-page/compile.ts +19 -8
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +28 -12
- package/src/biz/record-detail/compile.ts +39 -11
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +41 -10
- package/src/biz/settings-center/compile.ts +4 -1
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +30 -9
- package/src/biz/shared/action-host.ts +137 -46
- package/src/biz/shared/compile-helpers.ts +130 -28
- package/src/biz/shared/coordinator.ts +628 -147
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +58 -10
- package/src/biz/shared/overlay-shell.ts +40 -10
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +4 -2
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +21 -11
- package/src/biz/standard-crud/compile.ts +206 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +82 -22
- package/src/biz/standard-crud/summary.ts +2 -37
- package/src/biz/step-form/compile.ts +12 -3
- package/src/biz/step-form/hub.ts +165 -50
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +31 -15
- package/src/biz/types.ts +40 -4
- package/src/cli/kit-cli.ts +145 -26
- package/src/cli/kit-init.ts +3 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +446 -53
- package/src/compile/component-candidates.ts +56 -4
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +1 -1
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/rules-composition.ts +2 -1
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +382 -46
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +645 -28
- package/src/compile/styles.ts +226 -26
- package/src/compile/types.ts +62 -5
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +49 -22
- package/src/data/anchor-nav.ts +73 -15
- package/src/data/approval-flow.ts +210 -124
- package/src/data/assignment-picker.ts +163 -85
- package/src/data/async-result-panel.ts +110 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +141 -19
- package/src/data/calendar.ts +434 -96
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +72 -38
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +904 -77
- package/src/data/checklist.ts +78 -35
- package/src/data/code-view.ts +106 -48
- package/src/data/comment-thread.ts +607 -87
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +198 -30
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +107 -50
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +33 -17
- package/src/data/embed.ts +142 -7
- package/src/data/engine-ports.ts +13 -4
- package/src/data/field-mapper.ts +104 -48
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +603 -142
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +85 -27
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +637 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +38 -15
- package/src/data/image-viewer.ts +261 -62
- package/src/data/index.ts +63 -1
- package/src/data/item-list.ts +217 -57
- package/src/data/json-view.ts +165 -100
- package/src/data/kanban.ts +339 -87
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +155 -45
- package/src/data/matrix.ts +217 -112
- package/src/data/media-grid.ts +162 -38
- package/src/data/mega-menu.ts +39 -23
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +50 -15
- package/src/data/menu.ts +131 -47
- package/src/data/mockup.ts +30 -22
- package/src/data/modal-dialog.ts +90 -13
- package/src/data/navbar.ts +143 -61
- package/src/data/notice-list.ts +100 -48
- package/src/data/notify-renderer.ts +61 -7
- package/src/data/object-form.ts +1389 -130
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +122 -42
- package/src/data/panel-head.ts +237 -75
- package/src/data/permission-matrix.ts +371 -119
- package/src/data/permission-tree.ts +135 -80
- package/src/data/pricing-table.ts +106 -42
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +63 -31
- package/src/data/record-card.ts +239 -70
- package/src/data/record-picker.ts +56 -27
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +131 -41
- package/src/data/resident.ts +11 -1
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +206 -35
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +376 -102
- package/src/data/rule-builder.ts +129 -80
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +86 -43
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +438 -86
- package/src/data/static-lazy.ts +18 -0
- package/src/data/static-registry.ts +38 -2
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +63 -34
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +128 -47
- package/src/data/system-switcher.ts +40 -20
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +99 -31
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +110 -47
- package/src/data/transfer.ts +195 -47
- package/src/data/tree-table.ts +194 -112
- package/src/data/tree.ts +191 -70
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +242 -102
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +26 -4
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +1 -2
- package/src/frames/inherited-shell.ts +54 -13
- package/src/frames/page-bar.ts +205 -27
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +0 -2
- package/src/frames/shared.ts +64 -21
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +11 -7
- package/src/frames/split-frame/wiring.ts +14 -10
- package/src/frames/tabs-frame/shell.ts +3 -2
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +2 -0
- package/src/frames/workspace-frame/extras.ts +5 -3
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +22 -2
- package/src/frames/workspace-frame/state.ts +42 -14
- package/src/frames/workspace-frame/view.ts +697 -167
- package/src/generated/kit-grammar-runtime.ts +1015 -53
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +96 -3
- package/src/object-renderer/action-group.ts +175 -23
- package/src/object-renderer/action-more.ts +48 -17
- package/src/object-renderer/arrange.ts +241 -29
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +432 -107
- package/src/object-renderer/collection-table.ts +347 -45
- package/src/object-renderer/collection.ts +291 -62
- package/src/object-renderer/compile-data.ts +12 -2
- package/src/object-renderer/defaults.ts +6 -5
- package/src/object-renderer/emit-events.ts +45 -19
- package/src/object-renderer/emit-object.ts +35 -9
- package/src/object-renderer/emit-static.ts +734 -159
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +105 -18
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +18 -2
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +44 -2
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +71 -26
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +424 -103
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +428 -128
- package/src/object-renderer/types.ts +91 -2
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +15 -14
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +3 -2
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +76 -19
- package/src/recipes/control.ts +64 -5
- package/src/recipes/desc-list.ts +101 -7
- package/src/recipes/divider.ts +30 -9
- package/src/recipes/emphasis.ts +90 -5
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +3 -2
- package/src/recipes/index.ts +28 -4
- package/src/recipes/inherited-shell.ts +21 -15
- package/src/recipes/json-view.ts +6 -5
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +16 -6
- package/src/recipes/overlay.ts +47 -19
- package/src/recipes/page-width.ts +31 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +37 -19
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +5 -5
- package/src/recipes/state.ts +54 -3
- package/src/recipes/status.ts +14 -14
- package/src/recipes/strip.ts +47 -5
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +33 -4
- package/src/recipes/table-gap.ts +3 -2
- package/src/recipes/table-native-edit.ts +22 -9
- package/src/recipes/table-row.ts +45 -12
- package/src/recipes/tabs.ts +54 -22
- package/src/recipes/text-diff.ts +15 -8
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +68 -3
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +58 -12
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/icons.ts +28 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +165 -24
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +527 -16
- package/src/theme/kit-theme.tpl +491 -16
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +522 -185
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +3 -2
- package/src/theme/theme-tokens.ts +1601 -93
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/frames/list-summary.ts +0 -123
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
package/src/base/loading-gate.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// 加载反馈时序:「延迟出现 + 最短显示」纯状态机 + 计时器外壳。
|
|
2
2
|
//
|
|
3
|
+
// 适用范围(B1-2):骨架 = 首次加载(区域还没有任何内容),立即出现,不走本延迟(base/state-panel.ts 给骨架打「已过首次延迟」标记);
|
|
4
|
+
// 局部刷新指示(区域已有内容、只是重取;按钮忙碌;小块文字盒)= 延迟 delayMs 才出现,即本状态机。
|
|
5
|
+
//
|
|
3
6
|
// 目的:
|
|
4
7
|
// 1. 快请求(在 delayMs 内完成)全程不进入 visible,不显示任何指示器(零闪屏);
|
|
5
8
|
// 2. 一旦进入 visible,即使请求随即完成也至少保持 minVisibleMs,防止一闪而过;
|
package/src/base/look.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// 界面规则(look,KT-LK)运行期:组件在每个部件元素上调同一个函数 applyLook——打 data-kit-tone 载体 + 合并配方类。
|
|
2
|
+
// 部件外观表由编译期规则引擎(compile/look.ts)解好,经组件保留 prop `look` 交入:{ <部件>: { <属性>: 取值 | { bind } } }。
|
|
3
|
+
// 绑定:值就是取值名(item.<键> 取项数据、row.<字段> 取行数据、view.<成员> 由 core 页面变量绑定后以静态值交入);闭集外的值按 neutral 渲染并开发态告警 KIT-LOOK-005。
|
|
4
|
+
|
|
5
|
+
import { KIT_GRAMMAR_RUNTIME as grammarJson } from '../generated/kit-grammar-runtime';
|
|
6
|
+
import { kitLookRecipe } from '../recipes/look';
|
|
7
|
+
import { mergeClass } from '../shared/merge-class';
|
|
8
|
+
import { KIT_ELEMENT_PARTS, type KitElementPart } from '../shared/page-attrs';
|
|
9
|
+
import { KIT_SELF_ATTR } from '../shared/page-attrs-runtime';
|
|
10
|
+
import { kitIsNextRuntime } from '../recipes/pipeline-runtime';
|
|
11
|
+
import { KIT_NINE_DIM } from 'soma-foundation/kit-nine-dim';
|
|
12
|
+
import { kitAutoCategorySequence } from '../recipes/color-role';
|
|
13
|
+
|
|
14
|
+
export type KitLookPartDecls = Readonly<Record<string, unknown>>;
|
|
15
|
+
export type KitLookProp = Readonly<Record<string, KitLookPartDecls>>;
|
|
16
|
+
|
|
17
|
+
const G = grammarJson as unknown as {
|
|
18
|
+
look: { carrier: { attr: string }; toneGroups: { decorative: readonly string[]; none: readonly string[]; decorativeTones: readonly string[]; categoricalAs: Readonly<Record<string, string>> } };
|
|
19
|
+
toneNames: { semantic: readonly string[]; categorical: readonly string[]; aliases: Readonly<Record<string, string>> };
|
|
20
|
+
};
|
|
21
|
+
const TONES = new Set<string>([...G.toneNames.semantic, ...G.toneNames.categorical]);
|
|
22
|
+
const CATEGORICAL = new Set<string>(G.toneNames.categorical);
|
|
23
|
+
const ATTR = G.look.carrier.attr;
|
|
24
|
+
const GROUPS = G.look.toneGroups;
|
|
25
|
+
|
|
26
|
+
let warnedDecor = false;
|
|
27
|
+
/**
|
|
28
|
+
* 色调适用部件(真源 look.toneGroups,工序 ⑤):角色 × 色名 → 生效色名。
|
|
29
|
+
* 说明文字角色不收;装饰性角色取到语义词按 neutral 画并开发态告警(KIT-LOOK-504,静态写法编译期已拦,这里只会遇到绑定值);
|
|
30
|
+
* 分类色落在纯文字值上不染(categoricalAs:只在值画成标签、以 mark 角色调用时生效)。
|
|
31
|
+
*/
|
|
32
|
+
function toneForRole(role: string, tone: string): string | undefined {
|
|
33
|
+
if (GROUPS.none.includes(role)) return undefined;
|
|
34
|
+
if (GROUPS.decorative.includes(role) && !GROUPS.decorativeTones.includes(tone)) {
|
|
35
|
+
if (!warnedDecor && typeof console !== 'undefined') {
|
|
36
|
+
warnedDecor = true;
|
|
37
|
+
console.warn(`[KIT-LOOK-504] 语义色不作装饰:装饰性部件(角色 ${role})绑定取到「${tone}」,按 neutral 渲染`);
|
|
38
|
+
}
|
|
39
|
+
return 'neutral';
|
|
40
|
+
}
|
|
41
|
+
if (CATEGORICAL.has(tone) && GROUPS.categoricalAs[role] !== undefined) return undefined;
|
|
42
|
+
return tone;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** 绑定上下文:item = 条目型组件的当前项、row = 集合当前行 */
|
|
46
|
+
export interface KitLookContext {
|
|
47
|
+
readonly item?: Readonly<Record<string, unknown>>;
|
|
48
|
+
readonly row?: Readonly<Record<string, unknown>>;
|
|
49
|
+
readonly view?: Readonly<Record<string, unknown>>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function pathValue(src: Readonly<Record<string, unknown>> | undefined, segs: readonly string[]): unknown {
|
|
53
|
+
let cur: unknown = src;
|
|
54
|
+
for (const s of segs) cur = cur !== null && typeof cur === 'object' ? (cur as Record<string, unknown>)[s] : undefined;
|
|
55
|
+
return cur;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** 取一条声明的生效值:静态值原样;{ bind: 'item.k' } 按上下文取 */
|
|
59
|
+
export function resolveLookValue(v: unknown, ctx: KitLookContext = {}): unknown {
|
|
60
|
+
if (v === null || typeof v !== 'object' || typeof (v as { bind?: unknown }).bind !== 'string') return v;
|
|
61
|
+
const [head, ...rest] = (v as { bind: string }).bind.split('.');
|
|
62
|
+
return pathValue(head === 'item' ? ctx.item : head === 'row' ? ctx.row : head === 'view' ? ctx.view : undefined, rest);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let warned = false;
|
|
66
|
+
function toneOf(raw: unknown): string | undefined {
|
|
67
|
+
if (raw === undefined || raw === null || raw === '') return undefined;
|
|
68
|
+
const s = String(raw);
|
|
69
|
+
const v = G.toneNames.aliases[s] ?? s;
|
|
70
|
+
if (TONES.has(v)) return v;
|
|
71
|
+
if (!warned && typeof console !== 'undefined') {
|
|
72
|
+
warned = true;
|
|
73
|
+
console.warn(`[KIT-LOOK-005] 色调绑定取到闭集外的值「${s}」,按 neutral 渲染(可用 ${[...TONES].join(' / ')})`);
|
|
74
|
+
}
|
|
75
|
+
return 'neutral';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 在一个部件元素上落外观:role = 该部件在契约里的角色;look = 组件的保留 prop look。
|
|
80
|
+
* 没有该部件的声明时什么都不做(不改类、不加属性:零规则的组件 DOM 不变)。
|
|
81
|
+
*/
|
|
82
|
+
export function applyLook(el: HTMLElement, look: KitLookProp | undefined, part: string, role: string, ctx: KitLookContext = {}): void {
|
|
83
|
+
const decls = look?.[part];
|
|
84
|
+
if (decls === undefined) return;
|
|
85
|
+
let cls = el.className;
|
|
86
|
+
for (const [prop, raw] of Object.entries(decls)) {
|
|
87
|
+
const v = resolveLookValue(raw, ctx);
|
|
88
|
+
if (prop === 'tone') {
|
|
89
|
+
const named = toneOf(v);
|
|
90
|
+
const tone = named === undefined ? undefined : toneForRole(role, named);
|
|
91
|
+
if (tone === undefined) {
|
|
92
|
+
el.removeAttribute(ATTR);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
el.setAttribute(ATTR, tone);
|
|
96
|
+
}
|
|
97
|
+
if (prop === 'show') continue;
|
|
98
|
+
const add = kitLookRecipe(role, prop, v);
|
|
99
|
+
if (add !== '') cls = mergeClass(cls, add);
|
|
100
|
+
if (prop === 'overflow' && (v === 'truncate' || v === 'clamp2') && el.title === '' && (el.textContent ?? '') !== '') el.title = el.textContent ?? '';
|
|
101
|
+
}
|
|
102
|
+
el.className = cls;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 部件的生效色名(闭集内;没写 / 空返回 undefined):给不能经 className 落类的部件(SVG 图形,如指标迷你条)用——
|
|
107
|
+
* 调用方自己在图形上打载体属性、换成 fill / stroke 的角色类。
|
|
108
|
+
*/
|
|
109
|
+
export function lookTone(look: KitLookProp | undefined, part: string, ctx: KitLookContext = {}): string | undefined {
|
|
110
|
+
const decls = look?.[part];
|
|
111
|
+
return decls === undefined ? undefined : toneOf(resolveLookValue(decls.tone, ctx));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** 部件是否被规则隐藏(show: false,只对契约里 optional 的部件生效) */
|
|
115
|
+
export function lookHides(look: KitLookProp | undefined, part: string): boolean {
|
|
116
|
+
return look?.[part]?.show === false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** 条目型组件:从组件级外观表取第 key 项的部件表(look.items.<key> 覆盖 look.item) */
|
|
120
|
+
export function lookOfItem(look: KitLookProp | undefined, key: string): KitLookProp | undefined {
|
|
121
|
+
if (look === undefined) return undefined;
|
|
122
|
+
const items = (look as unknown as { items?: Readonly<Record<string, KitLookProp>> }).items;
|
|
123
|
+
const all = (look as unknown as { item?: KitLookProp }).item;
|
|
124
|
+
const own = items?.[key];
|
|
125
|
+
if (own === undefined) return all;
|
|
126
|
+
if (all === undefined) return own;
|
|
127
|
+
const out: Record<string, KitLookPartDecls> = { ...all };
|
|
128
|
+
for (const [p, d] of Object.entries(own)) out[p] = { ...(all[p] ?? {}), ...d };
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ── 主题流水线:元素部件自报与分类色序号(展示类基础组件共用)────────────────
|
|
133
|
+
|
|
134
|
+
/** 元素部件闭集(与 shared/page-attrs 的 KIT_ELEMENT_PARTS 同源,这里只取来判断「节点上已有的值是不是本通道写的」) */
|
|
135
|
+
const ELEMENT_PARTS: ReadonlySet<string> = new Set<string>(KIT_ELEMENT_PARTS);
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 运行期按当轮内容自报元素部件(值 / 状态 / 标记 …会随形态变化,所以不能像根层级角色那样「只写一次」):
|
|
139
|
+
* 节点上已有的 data-kit-part 若不是 12 个元素部件之一(recipes 的部位标记,如 badge / title-page),保持原值不动;
|
|
140
|
+
* 是元素部件或没有时按当轮改写。传 null 清掉本通道写过的值。
|
|
141
|
+
*/
|
|
142
|
+
export function kitMarkElementPart(el: Element, part: KitElementPart | null): void {
|
|
143
|
+
// 旧版不写组件自报属性(见 base/kit-contract.ts 自报一节)
|
|
144
|
+
if (!kitIsNextRuntime()) return;
|
|
145
|
+
const now = el.getAttribute(KIT_SELF_ATTR.part);
|
|
146
|
+
if (now !== null && !ELEMENT_PARTS.has(now)) return;
|
|
147
|
+
if (part === null) el.removeAttribute(KIT_SELF_ATTR.part);
|
|
148
|
+
else if (now !== part) el.setAttribute(KIT_SELF_ATTR.part, part);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** 一个字段至多几个选项逐个着色(真源 kit-nine-dim#colorScheme.categorical.auto.maxColoredOptions;键缺席 = 0,一律中性) */
|
|
152
|
+
const AUTO = (KIT_NINE_DIM as unknown as { colorScheme: { categorical: { auto?: { maxColoredOptions: number; perContainerHues: number } } } }).colorScheme.categorical.auto;
|
|
153
|
+
const CATEGORY_MAX_OPTIONS: number = AUTO?.maxColoredOptions ?? 0;
|
|
154
|
+
/** 同一容器同时出现的分类色相上限:自动序列截到这个长度 */
|
|
155
|
+
const CATEGORY_PER_CONTAINER: number = AUTO?.perContainerHues ?? 0;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 分类色按选项声明顺序取(业务功能描述 §3.6「按色族的序列取色,超出序列长度退成中性」;设计规则 CS20 分类色缺省分配):
|
|
159
|
+
* 页面线给了 categoryIndex(> 0 = 启用)而编译期没给标签色表时,第 k 个选项(k 从 1 起)取「主题自动序列」的第 k 个色号。
|
|
160
|
+
* 自动序列由主题随整站样式下发到宿主 / 文档根的 --kit-cat-auto(recipes/color-role.ts#kitAutoCategorySequence,与编译期页尾一遍、
|
|
161
|
+
* 看板 / 时间线等运行期取色同一机制):它是 c2…c8 里亮色图表色相不落在任何语义窗内的序号(CS20;语义窗半宽 = CS13 的语义撞色窗 clashWindowDeg,
|
|
162
|
+
* 判定口径同 CS18 分类色名表),所以取到的色号不会与成功 / 警告 / 危险(及未并入强调色的信息色)同色相,c1(主色)也不进。
|
|
163
|
+
* 序列先截到同一容器的色相上限(perContainerHues);一个字段的选项数超过序列长度或超过 maxColoredOptions 时整字段退成中性(返回空表)。
|
|
164
|
+
* explicit = 编译期色表里显式写的条目(cN / neutral;E→D:next 下编译期把自动位剥掉,只剩显式条目时其余选项不能退中性):
|
|
165
|
+
* 显式条目原样保留且不占序号,其余选项按声明顺序接续取色——与编译期「显式色不占位、自动位接续」同一规则;
|
|
166
|
+
* 选项总数超过 maxColoredOptions、或要取色的选项数超过序列长度时只留显式条目。色表里的自动位('@k')不算显式。
|
|
167
|
+
* 返回与 tag_tones 同形的表,交给 kitCategoryToneFor 取色。host 缺省时读文档根。
|
|
168
|
+
*/
|
|
169
|
+
export function kitCategoryTonesByOrder(options: readonly { readonly value: unknown }[], host?: Element | null, explicit?: unknown): Readonly<Record<string, string>> {
|
|
170
|
+
// 先按值去重、保首次出现的顺序:同一选项全应用同一色(§3.6),重复出现不占序号、不计入长度,也不会被后一次覆盖
|
|
171
|
+
const keys = [...new Set(options.map((o) => String(o.value)))];
|
|
172
|
+
const out: Record<string, string> = {};
|
|
173
|
+
if (!kitIsEmptyToneMap(explicit)) {
|
|
174
|
+
for (const [k, v] of Object.entries(explicit as Record<string, unknown>)) {
|
|
175
|
+
if (typeof v === 'string' && (CATEGORICAL.has(v) || v === 'neutral')) out[k] = v;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const auto = keys.filter((k) => !Object.prototype.hasOwnProperty.call(out, k));
|
|
179
|
+
const seq = kitCategoryAutoSequence(host);
|
|
180
|
+
if (keys.length === 0 || keys.length > CATEGORY_MAX_OPTIONS || auto.length > seq.length) return out;
|
|
181
|
+
auto.forEach((k, i) => { out[k] = `c${seq[i]!}`; });
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 主题自动序列截到同一容器的色相上限(perContainerHues):运行期取分类色的唯一序列出处——按声明顺序取色(上面)
|
|
187
|
+
* 与 next 下未解析的自动位 '@k'(recipes/mark.ts#kitCategoryToneFor 的 auto 参数,E→D)都用它;host 缺省时读文档根。
|
|
188
|
+
* 与编译期页尾一遍(object-renderer/category-tone.ts#kitResolveCategoryTones)的序列同一出处(主题的 --kit-cat-auto)、同一截断。
|
|
189
|
+
*/
|
|
190
|
+
export function kitCategoryAutoSequence(host?: Element | null): readonly number[] {
|
|
191
|
+
return kitAutoCategorySequence(host).slice(0, CATEGORY_PER_CONTAINER);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** tag_tones 是否为空表(编译期没给色表时才按声明顺序补) */
|
|
195
|
+
export function kitIsEmptyToneMap(raw: unknown): boolean {
|
|
196
|
+
return raw === null || raw === undefined || typeof raw !== 'object' || Array.isArray(raw) || Object.keys(raw).length === 0;
|
|
197
|
+
}
|
package/src/base/mentions.ts
CHANGED
|
@@ -13,28 +13,32 @@ import type { SomaComponentDefinition } from 'soma-core';
|
|
|
13
13
|
import { kitText } from '../i18n/kit-text';
|
|
14
14
|
import type { CollectionItem } from 'soma-core/keyboard';
|
|
15
15
|
import {
|
|
16
|
-
EMPTY_ROW_CLASS, PANEL_HIDDEN_CLASS, PANEL_SHOWN_CLASS, KIT_DROPDOWN_CLASS_CANDIDATES, syncDropdown, releaseDropdown,
|
|
16
|
+
EMPTY_ROW_CLASS, PANEL_HIDDEN_CLASS, PANEL_SHOWN_CLASS, KIT_DROPDOWN_CLASS_CANDIDATES, isImeComposing, syncDropdown, releaseDropdown,
|
|
17
17
|
cssEscape, createListNav, onOutsidePress, optionClass, scrollIntoViewIfAny,
|
|
18
18
|
} from './popup';
|
|
19
19
|
import {
|
|
20
|
-
CLASS_PROP, ID_PROPS, INVALID_PROPS, OPTIONS_PROP, SIZE_PROP,
|
|
21
|
-
applyCommon, applyDisabled, bool, classCandidates, createKitController, joinClass, nextUid, num, optionsOf, setAttr, setBoolAttr,
|
|
20
|
+
CLASS_PROP, FIELD_INVALID_CLASS, ID_PROPS, INVALID_PROPS, OPTIONS_PROP, SIZE_PROP,
|
|
21
|
+
applyCommon, applyDisabled, bool, classCandidates, createKitController, joinClass, nextUid, num, optionsMapOf, optionsOf, setAttr, setBoolAttr, str, syncKitTextValue, withInvalid,
|
|
22
|
+
kitControlSizeOf, kitMarkDataState, kitMarkInteract, kitReadProps,
|
|
22
23
|
type KitOption, type KitProps, type KitSize,
|
|
23
24
|
} from './shared';
|
|
24
25
|
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
26
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
27
|
+
import { kitWellRecipe } from '../recipes/surface';
|
|
28
|
+
import { KIT_ATTR_FACE, KIT_ATTR_KEY } from '../shared/dom-attrs';
|
|
25
29
|
|
|
26
30
|
// 文本框的边 = 控件轮廓出口(KT-B1 / §4 C6)
|
|
27
31
|
const CONTROL_EDGE = kitControlEdgeRecipe();
|
|
28
32
|
const WRAP = 'relative block w-full';
|
|
29
33
|
const STATUS = 'sr-only';
|
|
30
34
|
const AREA: Record<KitSize, string> = {
|
|
31
|
-
sm: 'block w-full appearance-none autofill-clear resize-none rounded-
|
|
32
|
-
md: 'block w-full appearance-none autofill-clear resize-none rounded-
|
|
33
|
-
lg: 'block w-full appearance-none autofill-clear resize-none rounded-
|
|
35
|
+
sm: 'block w-full appearance-none autofill-clear resize-none rounded-card ' + CONTROL_EDGE + ' bg-surface px-2.5 py-1.5 text-xs text-fg transition-colors placeholder:text-fg-subtle ' + KIT_FOCUS_RING.control + ' disabled:cursor-not-allowed disabled:bg-control-disabled disabled:text-fg-disabled ' + kitWellRecipe('read-only') + '',
|
|
36
|
+
md: 'block w-full appearance-none autofill-clear resize-none rounded-card ' + CONTROL_EDGE + ' bg-surface px-3 py-2 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 ' + kitWellRecipe('read-only') + '',
|
|
37
|
+
lg: 'block w-full appearance-none autofill-clear resize-none rounded-card ' + CONTROL_EDGE + ' bg-surface px-4 py-2.5 text-base text-fg transition-colors placeholder:text-fg-subtle ' + KIT_FOCUS_RING.control + ' disabled:cursor-not-allowed disabled:bg-control-disabled disabled:text-fg-disabled ' + kitWellRecipe('read-only') + '',
|
|
34
38
|
};
|
|
35
39
|
|
|
36
40
|
export const KIT_MENTIONS_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
37
|
-
WRAP, STATUS, Object.values(AREA), PANEL_HIDDEN_CLASS, PANEL_SHOWN_CLASS, EMPTY_ROW_CLASS, KIT_DROPDOWN_CLASS_CANDIDATES,
|
|
41
|
+
WRAP, STATUS, Object.values(AREA), PANEL_HIDDEN_CLASS, PANEL_SHOWN_CLASS, EMPTY_ROW_CLASS, FIELD_INVALID_CLASS, KIT_DROPDOWN_CLASS_CANDIDATES,
|
|
38
42
|
optionClass(false, false, false), optionClass(false, true, false), optionClass(false, false, true),
|
|
39
43
|
);
|
|
40
44
|
|
|
@@ -74,10 +78,16 @@ export function insertMention(text: string, hit: MentionHit, caret: number, opti
|
|
|
74
78
|
|
|
75
79
|
export interface ParsedMention { trigger: string; label: string; value: string }
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
function escapeTriggerClass(raw: string): string {
|
|
82
|
+
return raw.replace(/[\\\]^-]/g, '\\$&');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** 解析 `markup: token` 的文本:`@[张三](u1)` -> { trigger: '@', label: '张三', value: 'u1' }(仅匹配配置的 triggers 字符,不误伤普通 Markdown 链接) */
|
|
86
|
+
export function parseMentions(text: string, triggers = '@'): ParsedMention[] {
|
|
87
|
+
const allowed = (triggers === '' ? '@' : triggers).replace(/\s+/g, '');
|
|
88
|
+
if (allowed === '') return [];
|
|
79
89
|
const out: ParsedMention[] = [];
|
|
80
|
-
const re =
|
|
90
|
+
const re = new RegExp(`([${escapeTriggerClass(allowed)}])\\[([^\\]\\n]+)\\]\\(([^)\\n]*)\\)`, 'gu');
|
|
81
91
|
for (let m = re.exec(text); m !== null; m = re.exec(text)) {
|
|
82
92
|
out.push({ trigger: m[1] ?? '', label: m[2] ?? '', value: m[3] ?? '' });
|
|
83
93
|
}
|
|
@@ -123,13 +133,14 @@ export function createMentions(): SomaComponentDefinition {
|
|
|
123
133
|
},
|
|
124
134
|
templateHtml:
|
|
125
135
|
`<div data-soma-id="root" class="${WRAP}">` +
|
|
126
|
-
`<textarea data-soma-id="area" rows="3" aria-haspopup="listbox"
|
|
136
|
+
`<textarea data-soma-id="area" rows="3" aria-haspopup="listbox" ${KIT_ATTR_FACE}="field" class="${AREA.md}"></textarea>` +
|
|
127
137
|
`<div data-soma-id="panel" role="listbox" class="${PANEL_HIDDEN_CLASS}"></div>` +
|
|
128
138
|
`<div data-soma-id="status" role="status" class="${STATUS}"></div></div>`,
|
|
129
|
-
controllerFactory: createKitController((
|
|
139
|
+
controllerFactory: createKitController((_api) => {
|
|
130
140
|
let hit: MentionHit | null = null;
|
|
131
141
|
let cursor: string | null = null;
|
|
132
142
|
let lastQuery: string | null = null;
|
|
143
|
+
let composing = false;
|
|
133
144
|
let paintFn: (() => void) | null = null;
|
|
134
145
|
|
|
135
146
|
return {
|
|
@@ -174,10 +185,12 @@ export function createMentions(): SomaComponentDefinition {
|
|
|
174
185
|
const active = cursor === String(o.value);
|
|
175
186
|
el.id = id;
|
|
176
187
|
el.setAttribute('role', 'option');
|
|
177
|
-
el.setAttribute(
|
|
188
|
+
el.setAttribute(KIT_ATTR_KEY, String(o.value));
|
|
178
189
|
el.setAttribute('aria-selected', active ? 'true' : 'false');
|
|
179
190
|
if (o.disabled) el.setAttribute('aria-disabled', 'true');
|
|
180
191
|
el.className = optionClass(false, active, o.disabled === true);
|
|
192
|
+
// 键盘活动项 = 激活(当前项);悬停 / 禁用不自报,走伪类与 aria-disabled
|
|
193
|
+
if (active) kitMarkInteract(el, 'current', true);
|
|
181
194
|
el.textContent = o.label;
|
|
182
195
|
if (active) activeId = id;
|
|
183
196
|
panel.appendChild(el);
|
|
@@ -229,7 +242,7 @@ export function createMentions(): SomaComponentDefinition {
|
|
|
229
242
|
const pick = (key: string): void => {
|
|
230
243
|
if (hit === null || locked()) return;
|
|
231
244
|
const p = api.props();
|
|
232
|
-
const option =
|
|
245
|
+
const option = optionsMapOf(p.options).get(key);
|
|
233
246
|
if (!option || option.disabled) return;
|
|
234
247
|
const caret = area.selectionStart ?? area.value.length;
|
|
235
248
|
const out = insertMention(area.value, hit, caret, option, p.markup === 'token' ? 'token' : 'plain');
|
|
@@ -254,11 +267,21 @@ export function createMentions(): SomaComponentDefinition {
|
|
|
254
267
|
onActivate: (key) => pick(key),
|
|
255
268
|
});
|
|
256
269
|
|
|
257
|
-
const
|
|
270
|
+
const onCompositionStart = (): void => {
|
|
271
|
+
composing = true;
|
|
272
|
+
};
|
|
273
|
+
const onCompositionEnd = (): void => {
|
|
274
|
+
composing = false;
|
|
275
|
+
if (!locked()) api.emit('change', { value: area.value });
|
|
276
|
+
refresh();
|
|
277
|
+
};
|
|
278
|
+
const onInput = (event: Event): void => {
|
|
279
|
+
if (composing || (event as InputEvent).isComposing) return;
|
|
258
280
|
if (!locked()) api.emit('change', { value: area.value });
|
|
259
281
|
refresh();
|
|
260
282
|
};
|
|
261
283
|
const onKeydown = (event: KeyboardEvent): void => {
|
|
284
|
+
if (isImeComposing(event) || composing) return;
|
|
262
285
|
if (hit === null) return;
|
|
263
286
|
if (event.key === 'Escape') {
|
|
264
287
|
event.preventDefault();
|
|
@@ -275,16 +298,22 @@ export function createMentions(): SomaComponentDefinition {
|
|
|
275
298
|
if (nav.handle(event)) event.preventDefault();
|
|
276
299
|
};
|
|
277
300
|
const onKeyup = (event: KeyboardEvent): void => {
|
|
301
|
+
if (isImeComposing(event) || composing) return;
|
|
278
302
|
// 光标左右移动 / Home / End 后重新判断是否还在提及里;上下键留给候选导航
|
|
279
303
|
if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) refresh();
|
|
280
304
|
};
|
|
281
|
-
const onBlur = (): void =>
|
|
305
|
+
const onBlur = (): void => {
|
|
306
|
+
composing = false;
|
|
307
|
+
closeList();
|
|
308
|
+
};
|
|
282
309
|
const onPanelMouseDown = (event: Event): void => { event.preventDefault(); };
|
|
283
310
|
const onPanelClick = (event: Event): void => {
|
|
284
|
-
const row = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
285
|
-
const key = row?.getAttribute(
|
|
311
|
+
const row = (event.target as HTMLElement | null)?.closest<HTMLElement>(`[${KIT_ATTR_KEY}]`);
|
|
312
|
+
const key = row?.getAttribute(KIT_ATTR_KEY);
|
|
286
313
|
if (key !== null && key !== undefined) pick(key);
|
|
287
314
|
};
|
|
315
|
+
area.addEventListener('compositionstart', onCompositionStart);
|
|
316
|
+
area.addEventListener('compositionend', onCompositionEnd);
|
|
288
317
|
area.addEventListener('input', onInput);
|
|
289
318
|
area.addEventListener('click', refresh);
|
|
290
319
|
area.addEventListener('keydown', onKeydown);
|
|
@@ -294,6 +323,8 @@ export function createMentions(): SomaComponentDefinition {
|
|
|
294
323
|
panel.addEventListener('click', onPanelClick);
|
|
295
324
|
const offOutside = onOutsidePress(root, () => hit !== null, closeList);
|
|
296
325
|
return () => {
|
|
326
|
+
area.removeEventListener('compositionstart', onCompositionStart);
|
|
327
|
+
area.removeEventListener('compositionend', onCompositionEnd);
|
|
297
328
|
area.removeEventListener('input', onInput);
|
|
298
329
|
area.removeEventListener('click', refresh);
|
|
299
330
|
area.removeEventListener('keydown', onKeydown);
|
|
@@ -305,23 +336,25 @@ export function createMentions(): SomaComponentDefinition {
|
|
|
305
336
|
releaseDropdown(panel, false);
|
|
306
337
|
paintFn = null;
|
|
307
338
|
hit = null;
|
|
339
|
+
composing = false;
|
|
308
340
|
};
|
|
309
341
|
},
|
|
310
342
|
render(root, p) {
|
|
311
343
|
const area = root.querySelector<HTMLTextAreaElement>('[data-soma-id="area"], [data-soma-scoped-id="area"]') as HTMLTextAreaElement;
|
|
312
|
-
|
|
313
|
-
if (area.value !== next) area.value = next;
|
|
344
|
+
syncKitTextValue(area, str(p.value), composing);
|
|
314
345
|
area.placeholder = str(p.placeholder);
|
|
315
346
|
const rows = num(p.rows);
|
|
316
347
|
area.rows = rows !== null && rows >= 1 ? Math.floor(rows) : 3;
|
|
317
348
|
setBoolAttr(area, 'readonly', bool(p.readonly));
|
|
318
349
|
applyDisabled(area, bool(p.disabled));
|
|
319
350
|
applyCommon(area, p);
|
|
320
|
-
|
|
351
|
+
// 高度档:组件自己非缺省的 size 优先,否则取页面线的 kit.controlSize
|
|
352
|
+
area.className = withInvalid(AREA[kitControlSizeOf(p, kitReadProps(p))], bool(p.invalid));
|
|
321
353
|
root.className = joinClass(WRAP, p.class);
|
|
354
|
+
kitMarkDataState(root, bool(p.readonly) ? 'readonly' : 'normal');
|
|
322
355
|
paintFn?.();
|
|
323
356
|
},
|
|
324
357
|
};
|
|
325
|
-
}),
|
|
358
|
+
}, { self: { level: 'control' } }),
|
|
326
359
|
};
|
|
327
360
|
}
|
package/src/base/menu-button.ts
CHANGED
|
@@ -5,15 +5,17 @@
|
|
|
5
5
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
6
6
|
import { kitText } from '../i18n/kit-text';
|
|
7
7
|
import { mergeClass } from '../shared/merge-class';
|
|
8
|
-
import { kitIconHtml } from '../shared/icons';
|
|
8
|
+
import { KIT_ICON_CLASS_CANDIDATES, kitIcon, kitIconHtml, resolveKitIconName } from '../shared/icons';
|
|
9
9
|
import {
|
|
10
10
|
CLASS_PROP, ID_PROPS, SIZE_PROP, TOOLTIP_PROP, BADGE_PROPS, KIT_BADGE_CLASS_CANDIDATES,
|
|
11
|
-
applyCommon, bool, classCandidates, createKitController, joinClass, paintBadge, setBoolAttr,
|
|
12
|
-
type KitSize, type KitView,
|
|
11
|
+
applyCommon, bool, classCandidates, createKitController, joinClass, paintBadge, setBoolAttr, str, withBadgeAnchor, withTooltip,
|
|
12
|
+
kitApplyStowable, kitControlSizeOf, kitReadProps, type KitRuntimeProps, type KitSize, type KitView,
|
|
13
13
|
} from './shared';
|
|
14
|
+
import { kitReportSelf } from './kit-contract';
|
|
14
15
|
import { kitControlRecipe, kitTypographyRecipe, setKitFace } from '../recipes';
|
|
15
16
|
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
16
|
-
import {
|
|
17
|
+
import { kitFocusRingRecipe } from '../recipes/state';
|
|
18
|
+
import { KIT_MENU_CORE_CLASS_CANDIDATES, menuItemsOf, wireMenu, type MenuClasses, type MenuHandle } from './menu-core';
|
|
17
19
|
import { KIT_DROPDOWN_PORTAL_CLASS_CANDIDATES, KIT_POPUP_PLACE_CLASS_CANDIDATES, popPlaceClass, type PopPlace } from './popup';
|
|
18
20
|
import { kitDividerRecipe } from '../recipes/divider';
|
|
19
21
|
import { KIT_COMPACT_GROUP_ATTR, kitCompactGroupRecipe, markKitCompactGroup } from '../recipes/compact-group';
|
|
@@ -40,7 +42,10 @@ const TRIGGER_CLASS: Record<MenuButtonVariant, Record<KitSize, string>> = {
|
|
|
40
42
|
ghost: triggerClassesOf('ghost'),
|
|
41
43
|
};
|
|
42
44
|
const MENU_HIDDEN = 'hidden';
|
|
43
|
-
|
|
45
|
+
// 非拆分形态下隐藏的主钮仍在 DOM 里:带焦点环出口(可点的块宿主),G121 ⑥
|
|
46
|
+
const MENU_HIDDEN_MAIN = mergeClass('hidden', kitFocusRingRecipe('button'));
|
|
47
|
+
const MENU_BASE = mergeClass('absolute z-10 flex w-max min-w-full max-w-xs flex-col p-1', kitSurfaceRecipe('raised'));
|
|
48
|
+
const TRIGGER_LABEL_WITH_ICON = 'inline-flex items-center gap-1.5';
|
|
44
49
|
/** 默认偏好:触发钮下方、左对齐;贴边时由 popup.ts 在闭集位置间翻转 */
|
|
45
50
|
const MENU_PREF: PopPlace = { side: 'bottom', align: 'start' };
|
|
46
51
|
const menuClass = (place: PopPlace): string => `${MENU_BASE} ${popPlaceClass(place)}`;
|
|
@@ -59,15 +64,20 @@ export const KIT_MENU_PANEL = {
|
|
|
59
64
|
} as const;
|
|
60
65
|
// 菜单项(KT-K-select-2 / 4):项高 = 条带阶梯的菜单项行高(sizeSpec.strip.menuItemPx,与下拉选项同一种);
|
|
61
66
|
// 键盘当前项与悬停同一层(focus-visible 叠悬停层),并画集合项焦点环(2px 内收,KT-K0-3),不只靠底色
|
|
67
|
+
// 圆角(主题公式 F2):面板取浮起档 rounded-float(r0 + 2)、内衬 p-1(4),项 = 条目档 rounded-item(max(r0 − 2, 0))= 浮起档 − 内衬,逐档同心
|
|
68
|
+
// (原写小号圆角刻度类:large 档下与浮起不同心,且带该类的按钮会被形状规则改成控件圆角)
|
|
62
69
|
const ITEM_ROW = KIT_STRIP_MENU_ITEM_CLASS;
|
|
63
70
|
export const KIT_MENU_ITEM_CLASSES: MenuClasses = {
|
|
64
|
-
idle: `flex cursor-pointer ${ITEM_ROW} items-center gap-2 whitespace-nowrap rounded-
|
|
65
|
-
danger: `flex cursor-pointer ${ITEM_ROW} items-center gap-2 whitespace-nowrap rounded-
|
|
66
|
-
disabled: `flex cursor-not-allowed ${ITEM_ROW} items-center gap-2 whitespace-nowrap rounded-
|
|
71
|
+
idle: `flex cursor-pointer ${ITEM_ROW} items-center gap-2 whitespace-nowrap rounded-item px-3 text-sm text-fg transition-colors hover:bg-state-layer-hover active:bg-state-layer-press focus-visible:bg-state-layer-hover ${FOCUS_INSET}`,
|
|
72
|
+
danger: `flex cursor-pointer ${ITEM_ROW} items-center gap-2 whitespace-nowrap rounded-item px-3 text-sm text-danger-on-soft transition-colors hover:bg-danger-soft focus-visible:bg-danger-soft ${FOCUS_INSET}`,
|
|
73
|
+
disabled: `flex cursor-not-allowed ${ITEM_ROW} items-center gap-2 whitespace-nowrap rounded-item px-3 text-sm text-fg-disabled`,
|
|
67
74
|
// 带原因描述的置灰项:两行结构(标签 / 描述各占一行),标签不折行、描述在面板宽度上限内折行
|
|
68
|
-
disabledDesc: 'flex cursor-not-allowed min-h-9 flex-wrap items-center gap-x-2 rounded-
|
|
69
|
-
|
|
75
|
+
disabledDesc: 'flex cursor-not-allowed min-h-9 flex-wrap items-center gap-x-2 rounded-item px-3 py-1.5 text-sm text-fg-disabled',
|
|
76
|
+
// 分隔线通栏:两侧 −4 抵消面板内衬 4(组件卡 DropdownMenu §7)
|
|
77
|
+
divider: 'my-1 -ms-1 -me-1 h-px bg-border-subtle',
|
|
70
78
|
icon: 'inline-block shrink-0',
|
|
79
|
+
// 子菜单面板(右侧弹出一层):与主面板同一份外观,位置由内核按 end 侧落位
|
|
80
|
+
subPanel: MENU_BASE,
|
|
71
81
|
// 置灰项的原因描述:独占第二行、弱色小字、可折行
|
|
72
82
|
desc: mergeClass(kitTypographyRecipe('caption'), 'basis-full whitespace-normal'),
|
|
73
83
|
};
|
|
@@ -89,8 +99,9 @@ const SPLIT_TRIGGER_CLASS: Record<MenuButtonVariant, string> = {
|
|
|
89
99
|
|
|
90
100
|
export const KIT_MENU_BUTTON_CLASS_CANDIDATES: readonly string[] = classCandidates(
|
|
91
101
|
ROOT_SPLIT_CLASS, PAIR_SPLIT_CLASS, PAIR_PLAIN_CLASS, Object.values(SPLIT_TRIGGER_CLASS), KIT_BADGE_CLASS_CANDIDATES,
|
|
92
|
-
ROOT_CLASS, Object.values(TRIGGER_CLASS).flatMap((m) => Object.values(m)), MENU_HIDDEN, MENU_BASE, TEXT_TRIGGER_SHIFT, KIT_POPUP_PLACE_CLASS_CANDIDATES, KIT_DROPDOWN_PORTAL_CLASS_CANDIDATES,
|
|
93
|
-
Object.values(MENU_CLASSES), CARET_CLASS, 'hidden', 'inline-block', ROOT_CONTEXT_CLASS, KIT_CONTEXT_MENU_CLASS_CANDIDATES,
|
|
102
|
+
ROOT_CLASS, Object.values(TRIGGER_CLASS).flatMap((m) => Object.values(m)), MENU_HIDDEN, MENU_HIDDEN_MAIN, MENU_BASE, TRIGGER_LABEL_WITH_ICON, TEXT_TRIGGER_SHIFT, KIT_POPUP_PLACE_CLASS_CANDIDATES, KIT_DROPDOWN_PORTAL_CLASS_CANDIDATES,
|
|
103
|
+
Object.values(MENU_CLASSES), CARET_CLASS, 'hidden', 'inline-block', ROOT_CONTEXT_CLASS, KIT_CONTEXT_MENU_CLASS_CANDIDATES, KIT_MENU_CORE_CLASS_CANDIDATES,
|
|
104
|
+
KIT_ICON_CLASS_CANDIDATES,
|
|
94
105
|
);
|
|
95
106
|
|
|
96
107
|
/** trigger: click(缺省,点按钮)或 contextmenu(右键 / 长按 / Shift+F10,触发区是虚线框) */
|
|
@@ -102,6 +113,18 @@ function variantOf(raw: unknown): MenuButtonVariant {
|
|
|
102
113
|
return raw === 'primary' || raw === 'ghost' ? raw : 'neutral';
|
|
103
114
|
}
|
|
104
115
|
|
|
116
|
+
/**
|
|
117
|
+
* 页面线判定的按钮形态 → 菜单钮变体:有 kit.variant 时以它为准(按钮形态由定形事件统一决定);
|
|
118
|
+
* 实心主色名额为否时实心退成描边;文字 / 图标形态都落到 ghost(菜单钮没有更轻的变体)。没有 kit.variant 时用组件自己的 variant。
|
|
119
|
+
*/
|
|
120
|
+
function kitMenuVariantOf(raw: unknown, kit: KitRuntimeProps): MenuButtonVariant {
|
|
121
|
+
const form = kit.variant === 'solid' && kit.solid === false ? 'outline' : kit.variant;
|
|
122
|
+
if (form === 'solid') return 'primary';
|
|
123
|
+
if (form === 'outline') return 'neutral';
|
|
124
|
+
if (form === 'text' || form === 'icon') return 'ghost';
|
|
125
|
+
return variantOf(raw);
|
|
126
|
+
}
|
|
127
|
+
|
|
105
128
|
/** 两钮的包层(根的第一个子元素):split 时是紧凑组合,否则 contents */
|
|
106
129
|
function pairOf(root: HTMLElement): HTMLElement {
|
|
107
130
|
return root.firstElementChild as HTMLElement;
|
|
@@ -129,6 +152,13 @@ function makeView(): KitView {
|
|
|
129
152
|
attach(root, api) {
|
|
130
153
|
const trigger = triggerOf(root);
|
|
131
154
|
const menu = root.children[1] as HTMLElement;
|
|
155
|
+
// 自报(主钮与下拉钮 = 控件、下拉箭头 = 图标、菜单面板 = 浮起):挂载时按组件自己持有的节点引用写,不按子路径选择器找
|
|
156
|
+
// (菜单打开后挂到浮层端口、不在根下,子路径会落空);旧版只写区域作用域(kitReportSelf)
|
|
157
|
+
const main = mainOf(root);
|
|
158
|
+
if (main !== undefined) kitReportSelf(main, { level: 'control' });
|
|
159
|
+
kitReportSelf(trigger, { level: 'control' });
|
|
160
|
+
kitReportSelf(trigger.children[1] ?? null, { part: 'icon' });
|
|
161
|
+
kitReportSelf(menu, { level: 'float' });
|
|
132
162
|
let corner: Corner = 'tl';
|
|
133
163
|
let at: { x: number; y: number } | null = null;
|
|
134
164
|
const h = wireMenu({
|
|
@@ -149,13 +179,12 @@ function makeView(): KitView {
|
|
|
149
179
|
onToggle: (open) => trigger.setAttribute('aria-expanded', open ? 'true' : 'false'),
|
|
150
180
|
});
|
|
151
181
|
handle = h;
|
|
152
|
-
const main = mainOf(root) as HTMLElement;
|
|
153
182
|
const onMain = (): void => {
|
|
154
183
|
const p = api.props();
|
|
155
184
|
if (!bool(p.split) || bool(p.disabled)) return;
|
|
156
185
|
api.emit('click', {});
|
|
157
186
|
};
|
|
158
|
-
main.addEventListener('click', onMain);
|
|
187
|
+
if (main !== undefined) main.addEventListener('click', onMain);
|
|
159
188
|
const offContext = wireContextTrigger({
|
|
160
189
|
area: trigger,
|
|
161
190
|
active: () => contextMode(api.props()) && !bool(api.props().disabled),
|
|
@@ -169,7 +198,7 @@ function makeView(): KitView {
|
|
|
169
198
|
},
|
|
170
199
|
});
|
|
171
200
|
return () => {
|
|
172
|
-
main.removeEventListener('click', onMain);
|
|
201
|
+
if (main !== undefined) main.removeEventListener('click', onMain);
|
|
173
202
|
offContext();
|
|
174
203
|
h.destroy();
|
|
175
204
|
handle = null;
|
|
@@ -179,21 +208,35 @@ function makeView(): KitView {
|
|
|
179
208
|
const btn = triggerOf(root) as HTMLElement | null;
|
|
180
209
|
const main = mainOf(root);
|
|
181
210
|
const pair = pairOf(root);
|
|
182
|
-
const
|
|
211
|
+
const kit = kitReadProps(p);
|
|
212
|
+
const size = kitControlSizeOf(p, kit);
|
|
183
213
|
const ctx = contextMode(p);
|
|
184
214
|
const split = bool(p.split) && !ctx;
|
|
185
|
-
const variant =
|
|
215
|
+
const variant = kitMenuVariantOf(p.variant, kit);
|
|
216
|
+
kitApplyStowable(root, kit);
|
|
186
217
|
const off = bool(p.disabled);
|
|
187
218
|
const icon = str(p.icon);
|
|
188
|
-
const
|
|
219
|
+
const resolvedIcon = resolveKitIconName(icon);
|
|
220
|
+
const textLabel = str(p.label);
|
|
221
|
+
const fallbackLabelText = `${icon !== '' ? `${icon} ` : ''}${textLabel}`;
|
|
189
222
|
let badgeHost: HTMLElement | null = btn;
|
|
190
223
|
if (btn) {
|
|
191
224
|
const label = btn.firstElementChild as HTMLElement | null;
|
|
192
225
|
const caret = btn.children[1] as HTMLElement | null;
|
|
193
226
|
// split 时文字归主钮,触发钮只留箭头
|
|
194
227
|
if (label) {
|
|
195
|
-
|
|
196
|
-
|
|
228
|
+
if (split) {
|
|
229
|
+
label.replaceChildren();
|
|
230
|
+
label.className = MENU_HIDDEN;
|
|
231
|
+
} else if (resolvedIcon !== null) {
|
|
232
|
+
const nodes: Node[] = [kitIcon(resolvedIcon, 'sm')];
|
|
233
|
+
if (textLabel !== '') nodes.push(document.createTextNode(textLabel));
|
|
234
|
+
label.replaceChildren(...nodes);
|
|
235
|
+
label.className = TRIGGER_LABEL_WITH_ICON;
|
|
236
|
+
} else {
|
|
237
|
+
label.textContent = fallbackLabelText;
|
|
238
|
+
label.className = '';
|
|
239
|
+
}
|
|
197
240
|
}
|
|
198
241
|
if (caret) caret.className = ctx ? MENU_HIDDEN : CARET_CLASS;
|
|
199
242
|
if (ctx) btn.setAttribute('aria-keyshortcuts', 'Shift+F10');
|
|
@@ -209,7 +252,13 @@ function makeView(): KitView {
|
|
|
209
252
|
}
|
|
210
253
|
if (main) {
|
|
211
254
|
if (split) {
|
|
212
|
-
|
|
255
|
+
if (resolvedIcon !== null) {
|
|
256
|
+
const nodes: Node[] = [kitIcon(resolvedIcon, 'sm')];
|
|
257
|
+
if (textLabel !== '') nodes.push(document.createTextNode(textLabel));
|
|
258
|
+
main.replaceChildren(...nodes);
|
|
259
|
+
} else {
|
|
260
|
+
main.textContent = fallbackLabelText;
|
|
261
|
+
}
|
|
213
262
|
setBoolAttr(main, 'disabled', off);
|
|
214
263
|
if (off) main.setAttribute('aria-disabled', 'true');
|
|
215
264
|
else main.removeAttribute('aria-disabled');
|
|
@@ -219,7 +268,7 @@ function makeView(): KitView {
|
|
|
219
268
|
} else {
|
|
220
269
|
setKitFace(main, null);
|
|
221
270
|
main.textContent = '';
|
|
222
|
-
main.className =
|
|
271
|
+
main.className = MENU_HIDDEN_MAIN;
|
|
223
272
|
}
|
|
224
273
|
}
|
|
225
274
|
// 角标只落在一处:split 时挂在组外缘(根 = 组容器,ROOT_SPLIT_CLASS 自带 relative,角标在组末端上角、不压两钮接缝,
|
|
@@ -273,7 +322,9 @@ export function createMenuButton(): SomaComponentDefinition {
|
|
|
273
322
|
click: { payload: {}, desc: 'split 时点主钮;disabled 时不抛' },
|
|
274
323
|
},
|
|
275
324
|
},
|
|
325
|
+
// 根与两钮的包层都是纯包装不设层级角色;主钮、箭头钮是控件,箭头是图标,菜单面板是浮起
|
|
276
326
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"><span class="${PAIR_PLAIN_CLASS}"><button type="button" class="${MENU_HIDDEN}"></button><button type="button" class="${TRIGGER_CLASS.neutral.md}"><span></span><span aria-hidden="true" class="${CARET_CLASS}">${kitIconHtml('chevron-down', 'sm')}</span></button></span><div class="${MENU_HIDDEN}"></div></div>`,
|
|
327
|
+
// 自报不拼进静态模板:在 makeView 的 attach 里按节点引用写(见那里)
|
|
277
328
|
controllerFactory: createKitController(() => withTooltip(makeView(), tooltipTarget)),
|
|
278
329
|
};
|
|
279
330
|
}
|