soma-kit 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
|
@@ -9,43 +9,57 @@
|
|
|
9
9
|
// 周期由组件内部持有(`cycle` prop 变化时覆盖),切换抛 `cycle_change { key }`;点动作钮抛 `select { key, cycle, item }`。
|
|
10
10
|
// 推荐方案(recommended)加主色描边与「推荐」角标;窄容器 1 列,md 档 2 列,xl 档 3 列(容器查询)。
|
|
11
11
|
|
|
12
|
+
import { kitApplyLevelClass } from './level-class';
|
|
12
13
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
14
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked, kitReadProps } from './kit-contract';
|
|
15
|
+
import { kitApplyCols, kitColsGrid, kitStripGridCols } from '../base/kit-contract';
|
|
16
|
+
import { kitIsNextRuntime } from '../recipes/pipeline-runtime';
|
|
17
|
+
import { KIT_ATTR_COLLAPSE, KIT_ATTR_CONTAINER, KIT_ATTR_CYCLE, KIT_ATTR_PLAN, KIT_ATTR_PLAN_ACTION, KIT_ATTR_SELECTED, kitAttrSel } from '../shared/dom-attrs';
|
|
13
18
|
import { createKitController, joinClass, str, type KitView } from '../base/shared';
|
|
14
|
-
import { kitIcon } from '../
|
|
15
|
-
import { kitText } from '../i18n/kit-text';
|
|
19
|
+
import { kitIcon } from '../shared/icons';
|
|
20
|
+
import { kitKey, kitText } from '../i18n/kit-text';
|
|
16
21
|
import { setKitFace } from '../recipes';
|
|
17
|
-
import {
|
|
22
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
23
|
+
import { kitActionRecipe, kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
18
24
|
import { markKitSlot, markKitSlotGrid } from '../recipes/slot-align';
|
|
19
25
|
import { classTokens, emptyNode, mk, recOf, rowsOf, textOf, type Rec } from './shape-util';
|
|
20
26
|
import { singleOf } from './display-util';
|
|
21
27
|
import { attrEsc } from './d9-util';
|
|
28
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
29
|
+
import { kitWellRecipe } from '../recipes/surface';
|
|
30
|
+
import { kitClosedValueRecipe, kitClosedValueTone } from '../recipes/field-text';
|
|
31
|
+
import { mergeClass } from '../shared/merge-class';
|
|
32
|
+
|
|
33
|
+
/** 价格卡外缘 = 壳配方(容器边,KT-B2) */
|
|
34
|
+
const CARD_EDGE = kitShellRecipe({ tone: 'base', shadow: false });
|
|
22
35
|
|
|
23
36
|
const KEYS = ['cycles', 'plans', 'current_key'] as const;
|
|
24
37
|
|
|
25
38
|
const ROOT_CLASS = '@container flex flex-col gap-5 text-fg';
|
|
26
|
-
const CYCLES_CLASS = 'mx-auto inline-flex items-center gap-1 rounded-
|
|
27
|
-
const CYCLE_CLASS = 'inline-flex h-8 items-center gap-1 rounded-
|
|
39
|
+
const CYCLES_CLASS = mergeClass(mergeClass('mx-auto inline-flex items-center gap-1 rounded-control', kitWellRecipe()), 'p-1');
|
|
40
|
+
const CYCLE_CLASS = 'inline-flex h-8 items-center gap-1 rounded-item px-3 text-sm font-medium text-fg-muted transition-colors hover:text-fg ' + KIT_FOCUS_RING.button + ' data-kit-selected:bg-surface data-kit-selected:text-fg data-kit-selected:shadow-sm';
|
|
28
41
|
const NOTE_CLASS = 'rounded-full bg-success-soft px-1.5 text-xs font-medium text-success-on-soft';
|
|
29
42
|
// 卡片三槽对齐(宽档间距 comfortable,真源 structure.slotAlign.slotGapTiers):卡片是父 grid 的直接子节点,显示方式(subgrid / 不支持时 flex 纵向)与槽间距由结构 CSS 给,
|
|
30
43
|
// 所以卡片类里不写 flex / gap,父 grid 的行距也交给结构 CSS(只写列距 gap-x-4);三槽 = 标题(名称 + 说明)/ 指标(价格)/ 操作(功能列表 + 按钮)
|
|
31
44
|
const GRID_CLASS = 'grid grid-cols-1 gap-x-4 @md:grid-cols-2 @xl:grid-cols-3';
|
|
32
|
-
const CARD_CLASS =
|
|
33
|
-
const CARD_RECOMMENDED_CLASS = 'relative rounded-
|
|
45
|
+
const CARD_CLASS = `relative ${CARD_EDGE} p-5`;
|
|
46
|
+
const CARD_RECOMMENDED_CLASS = 'relative rounded-card border border-primary bg-surface p-5 shadow-md ring-1 ring-primary';
|
|
34
47
|
const SLOT_TITLE_CLASS = 'flex flex-col gap-4';
|
|
35
48
|
const SLOT_ACTION_CLASS = 'flex flex-1 flex-col gap-4';
|
|
36
|
-
|
|
49
|
+
// 推荐角标 = 闭集值标签(语气淡底,闭集值出口),只补落位
|
|
50
|
+
const BADGE_CLASS = mergeClass('absolute end-4 top-4', kitClosedValueRecipe('primary'));
|
|
37
51
|
const NAME_CLASS = 'text-lg font-semibold text-fg';
|
|
38
52
|
const DESC_CLASS = 'text-sm text-fg-muted';
|
|
39
53
|
const PRICE_ROW_CLASS = 'flex items-baseline gap-1';
|
|
40
|
-
const PRICE_CLASS = 'text-2xl font-semibold text-fg';
|
|
54
|
+
const PRICE_CLASS = 'text-2xl font-semibold tabular-nums text-fg';
|
|
41
55
|
const PERIOD_CLASS = 'text-sm text-fg-muted';
|
|
42
56
|
const FEATURES_CLASS = 'flex flex-1 flex-col gap-2 text-sm';
|
|
43
57
|
const FEATURE_CLASS = 'flex items-start gap-2 text-fg';
|
|
44
58
|
const FEATURE_OFF_CLASS = 'flex items-start gap-2 text-fg-subtle';
|
|
45
59
|
const TICK_CLASS = 'inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-success-soft text-xs text-success-on-soft';
|
|
46
|
-
const CROSS_CLASS = 'inline-flex size-5 shrink-0 items-center justify-center rounded-full
|
|
47
|
-
const VALUE_CLASS = 'ms-auto shrink-0 text-fg-muted';
|
|
48
|
-
const ACTION_CLASS = '
|
|
60
|
+
const CROSS_CLASS = 'inline-flex size-5 shrink-0 items-center justify-center rounded-full text-xs ' + kitClosedValueTone('neutral');
|
|
61
|
+
const VALUE_CLASS = 'ms-auto shrink-0 tabular-nums text-fg-muted';
|
|
62
|
+
const ACTION_CLASS = kitActionRecipe('confirm', { size: 'lg' });
|
|
49
63
|
const ACTION_PLAIN_CLASS = kitEmphasisButtonRecipe('button.toolbar', { size: 'lg' });
|
|
50
64
|
|
|
51
65
|
export const KIT_PRICING_TABLE_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
@@ -162,46 +176,66 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
162
176
|
select: { payload: { key: { type: 'string' }, cycle: { type: 'string' }, item: { type: 'object' } }, desc: '点方案动作钮;item 是方案源对象' },
|
|
163
177
|
},
|
|
164
178
|
},
|
|
165
|
-
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
179
|
+
templateHtml: `<section ${KIT_ATTR_CONTAINER}="plain" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
166
180
|
controllerFactory: createKitController((api) => {
|
|
167
181
|
let self: KitView;
|
|
168
182
|
return (self = {
|
|
169
183
|
attach(root) {
|
|
170
184
|
const s = stateOf(root);
|
|
185
|
+
const switchCycle = (key: string, forceFocus: boolean): void => {
|
|
186
|
+
if (key === '' || key === s.cycle) {
|
|
187
|
+
if (forceFocus) root.querySelector<HTMLElement>(`[${KIT_ATTR_CYCLE}="${attrEsc(key)}"]`)?.focus();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
s.cycle = key;
|
|
191
|
+
api.emit('cycle_change', { key });
|
|
192
|
+
// 价格文案随周期换:整体重绘(周期条与卡片都在 render 里画)
|
|
193
|
+
s.given = '\u0000repaint';
|
|
194
|
+
const hadFocus = forceFocus || root.contains(document.activeElement);
|
|
195
|
+
self.render(root, api.props(), api);
|
|
196
|
+
// 重绘会重建切换条,键盘用户的焦点要回到新的同周期按钮上
|
|
197
|
+
if (hadFocus) root.querySelector<HTMLElement>(`[${KIT_ATTR_CYCLE}="${attrEsc(key)}"]`)?.focus();
|
|
198
|
+
};
|
|
171
199
|
const onClick = (event: Event): void => {
|
|
172
200
|
const t = event.target as HTMLElement | null;
|
|
173
|
-
const cyc = t?.closest<HTMLElement>(
|
|
201
|
+
const cyc = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_CYCLE));
|
|
174
202
|
if (cyc && root.contains(cyc)) {
|
|
175
|
-
|
|
176
|
-
if (key !== '' && key !== s.cycle) {
|
|
177
|
-
s.cycle = key;
|
|
178
|
-
api.emit('cycle_change', { key });
|
|
179
|
-
for (const el of Array.from(root.querySelectorAll<HTMLElement>('[data-kit-cycle]'))) {
|
|
180
|
-
const on = el.getAttribute('data-kit-cycle') === key;
|
|
181
|
-
if (on) el.setAttribute('data-kit-selected', ''); else el.removeAttribute('data-kit-selected');
|
|
182
|
-
setKitFace(el, on ? 'raised' : null);
|
|
183
|
-
el.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
184
|
-
}
|
|
185
|
-
// 价格文案随周期换:整体重绘(周期条与卡片都在 render 里画)
|
|
186
|
-
s.given = '\u0000repaint';
|
|
187
|
-
const hadFocus = root.contains(document.activeElement);
|
|
188
|
-
self.render(root, api.props(), api);
|
|
189
|
-
// 重绘会重建切换条,键盘用户的焦点要回到新的同周期按钮上
|
|
190
|
-
if (hadFocus) root.querySelector<HTMLElement>(`[data-kit-cycle="${attrEsc(key)}"]`)?.focus();
|
|
191
|
-
}
|
|
203
|
+
switchCycle(cyc.getAttribute(KIT_ATTR_CYCLE) ?? '', false);
|
|
192
204
|
return;
|
|
193
205
|
}
|
|
194
|
-
const act = t?.closest<HTMLElement>(
|
|
206
|
+
const act = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_PLAN_ACTION));
|
|
195
207
|
if (act && root.contains(act) && !act.hasAttribute('disabled')) {
|
|
196
|
-
const key = act.getAttribute(
|
|
208
|
+
const key = act.getAttribute(KIT_ATTR_PLAN_ACTION) ?? '';
|
|
197
209
|
const p = api.props();
|
|
198
210
|
const src = singleOf(p.data, p, KEYS);
|
|
199
211
|
const plan = pricingPlansOf(src.plans).find((x) => x.key === key);
|
|
200
212
|
if (plan) api.emit('select', { key, cycle: s.cycle, item: plan.raw });
|
|
201
213
|
}
|
|
202
214
|
};
|
|
215
|
+
const onKeydown = (event: KeyboardEvent): void => {
|
|
216
|
+
const cyc = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_CYCLE));
|
|
217
|
+
if (!cyc || !root.contains(cyc)) return;
|
|
218
|
+
const btns = Array.from(root.querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_CYCLE)));
|
|
219
|
+
if (btns.length < 2) return;
|
|
220
|
+
const idx = btns.indexOf(cyc);
|
|
221
|
+
if (idx < 0) return;
|
|
222
|
+
const arrow = kitKey(event.key, root);
|
|
223
|
+
let nextIdx = -1;
|
|
224
|
+
if (arrow === 'ArrowLeft') nextIdx = (idx - 1 + btns.length) % btns.length;
|
|
225
|
+
else if (arrow === 'ArrowRight') nextIdx = (idx + 1) % btns.length;
|
|
226
|
+
else if (event.key === 'Home') nextIdx = 0;
|
|
227
|
+
else if (event.key === 'End') nextIdx = btns.length - 1;
|
|
228
|
+
if (nextIdx < 0) return;
|
|
229
|
+
event.preventDefault();
|
|
230
|
+
switchCycle(btns[nextIdx]?.getAttribute(KIT_ATTR_CYCLE) ?? '', true);
|
|
231
|
+
};
|
|
203
232
|
root.addEventListener('click', onClick);
|
|
204
|
-
|
|
233
|
+
root.addEventListener('keydown', onKeydown);
|
|
234
|
+
return () => {
|
|
235
|
+
root.removeEventListener('click', onClick);
|
|
236
|
+
root.removeEventListener('keydown', onKeydown);
|
|
237
|
+
STATES.delete(root);
|
|
238
|
+
};
|
|
205
239
|
},
|
|
206
240
|
render(root, p) {
|
|
207
241
|
const s = stateOf(root);
|
|
@@ -214,7 +248,10 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
214
248
|
if (s.given !== givenCycle && s.given !== '\u0000repaint') { s.given = givenCycle; if (givenCycle !== '') s.cycle = givenCycle; }
|
|
215
249
|
if (s.given === '\u0000repaint') s.given = givenCycle;
|
|
216
250
|
if (!cycles.some((c) => c.key === s.cycle)) s.cycle = cycles[0]?.key ?? '';
|
|
251
|
+
// 数据状态自报:本组件只有空与常态
|
|
252
|
+
kitMarkDataFacts(root, { empty: plans.length === 0 });
|
|
217
253
|
if (plans.length === 0) {
|
|
254
|
+
kitApplyCols(root, null);
|
|
218
255
|
root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.pt_empty', undefined, root))));
|
|
219
256
|
return;
|
|
220
257
|
}
|
|
@@ -225,10 +262,13 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
225
262
|
for (const c of cycles) {
|
|
226
263
|
const btn = mk('button', CYCLE_CLASS);
|
|
227
264
|
btn.type = 'button';
|
|
228
|
-
btn.setAttribute(
|
|
265
|
+
btn.setAttribute(KIT_ATTR_CYCLE, c.key);
|
|
229
266
|
const on = c.key === s.cycle;
|
|
230
267
|
btn.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
231
|
-
if (on) btn.setAttribute(
|
|
268
|
+
if (on) btn.setAttribute(KIT_ATTR_SELECTED, '');
|
|
269
|
+
// 当前周期 = 选中;无障碍已按切换钮写 aria-pressed,这里只写自报
|
|
270
|
+
kitMarkPicked(btn, 'selected', on, null);
|
|
271
|
+
kitMarkPart(btn, 'control');
|
|
232
272
|
setKitFace(btn, on ? 'raised' : null); // 选中的周期钮才有底色 + shadow-sm(分段滑块式),未选中透明无面
|
|
233
273
|
btn.appendChild(mk('span', '', c.label));
|
|
234
274
|
if (c.note !== '') btn.appendChild(mk('span', NOTE_CLASS, c.note));
|
|
@@ -239,20 +279,49 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
239
279
|
const current = textOf(src.current_key);
|
|
240
280
|
const grid = mk('div', GRID_CLASS);
|
|
241
281
|
markKitSlotGrid(grid, 3, 'comfortable');
|
|
282
|
+
root.appendChild(grid);
|
|
283
|
+
const kitCols = kitReadProps(p).columns;
|
|
284
|
+
const desktopCols = kitCols !== undefined && kitCols >= 2 ? Math.min(kitCols, 4) : Math.min(3, plans.length);
|
|
285
|
+
const nextCols = kitIsNextRuntime() && desktopCols >= 2 ? desktopCols : null;
|
|
286
|
+
let externalCollapse: string | null = null;
|
|
287
|
+
for (let el: HTMLElement | null = grid.parentElement; el !== null; el = el.parentElement) {
|
|
288
|
+
const val = el.getAttribute(KIT_ATTR_COLLAPSE);
|
|
289
|
+
if (val !== null) { externalCollapse = val; break; }
|
|
290
|
+
if (el.hasAttribute('data-soma-component')) break;
|
|
291
|
+
}
|
|
292
|
+
let varTracks = false;
|
|
293
|
+
if (externalCollapse !== null) {
|
|
294
|
+
varTracks = externalCollapse === 'to-single' ? kitApplyCols(grid, nextCols) : kitApplyCols(grid, null);
|
|
295
|
+
} else if (nextCols !== null) {
|
|
296
|
+
grid.setAttribute(KIT_ATTR_COLLAPSE, 'to-single');
|
|
297
|
+
varTracks = kitApplyCols(grid, nextCols);
|
|
298
|
+
} else {
|
|
299
|
+
kitApplyCols(grid, null);
|
|
300
|
+
}
|
|
301
|
+
if (varTracks) grid.className = kitStripGridCols(GRID_CLASS);
|
|
302
|
+
kitColsGrid(grid, varTracks);
|
|
242
303
|
for (const plan of plans) {
|
|
243
304
|
const isCurrent = current !== '' && plan.key === current;
|
|
244
305
|
const card = mk('article', plan.recommended ? CARD_RECOMMENDED_CLASS : CARD_CLASS);
|
|
245
|
-
card.setAttribute('
|
|
306
|
+
card.setAttribute(KIT_ATTR_CONTAINER, 'card');
|
|
307
|
+
card.setAttribute(KIT_ATTR_PLAN, plan.key);
|
|
308
|
+
// 每张方案卡是一张对象面(卡片类,§8.2);当前方案自报当前项
|
|
309
|
+
kitMarkLevel(card, 'face'); kitApplyLevelClass(card);
|
|
310
|
+
if (isCurrent) kitMarkPicked(card, 'current', true);
|
|
246
311
|
const badge = isCurrent ? str(p.current_text, kitText('soma.kit.pt_current', undefined, root)) : plan.badge;
|
|
247
|
-
if (badge !== '')
|
|
312
|
+
if (badge !== '') { const b = mk('span', BADGE_CLASS, badge); kitMarkPart(b, 'mark'); card.appendChild(b); }
|
|
248
313
|
const head = markKitSlot(mk('div', SLOT_TITLE_CLASS), 'title');
|
|
249
|
-
|
|
314
|
+
const nameEl = mk('h3', NAME_CLASS, plan.name);
|
|
315
|
+
kitMarkPart(nameEl, 'block-title');
|
|
316
|
+
head.appendChild(nameEl);
|
|
250
317
|
if (plan.desc !== '') head.appendChild(mk('p', DESC_CLASS, plan.desc));
|
|
251
318
|
card.appendChild(head);
|
|
252
319
|
const price = plan.prices ? pricingTextFor(plan.prices, s.cycle) : plan.price;
|
|
253
320
|
const period = plan.periods ? pricingTextFor(plan.periods, s.cycle) : plan.period;
|
|
254
321
|
const row = markKitSlot(mk('div', PRICE_ROW_CLASS), 'metric');
|
|
255
|
-
|
|
322
|
+
const priceEl = mk('span', PRICE_CLASS, price);
|
|
323
|
+
kitMarkPart(priceEl, 'metric');
|
|
324
|
+
row.appendChild(priceEl);
|
|
256
325
|
if (period !== '') row.appendChild(mk('span', PERIOD_CLASS, period));
|
|
257
326
|
card.appendChild(row);
|
|
258
327
|
const ul = mk('ul', FEATURES_CLASS);
|
|
@@ -269,16 +338,16 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
269
338
|
}
|
|
270
339
|
const foot = markKitSlot(mk('div', SLOT_ACTION_CLASS), 'action');
|
|
271
340
|
foot.appendChild(ul);
|
|
272
|
-
const btn =mk('button', plan.recommended ? ACTION_CLASS : ACTION_PLAIN_CLASS, plan.actionText || str(p.action_text, kitText('soma.kit.pt_choose', undefined, root)));
|
|
341
|
+
const btn = mk('button', plan.recommended ? ACTION_CLASS : ACTION_PLAIN_CLASS, plan.actionText || str(p.action_text, kitText('soma.kit.pt_choose', undefined, root)));
|
|
273
342
|
btn.type = 'button';
|
|
274
343
|
setKitFace(btn, 'raised');
|
|
275
|
-
btn.setAttribute(
|
|
344
|
+
btn.setAttribute(KIT_ATTR_PLAN_ACTION, plan.key);
|
|
345
|
+
kitMarkPart(btn, 'action');
|
|
276
346
|
if (isCurrent || plan.disabled) { btn.disabled = true; btn.setAttribute('aria-disabled', 'true'); }
|
|
277
347
|
foot.appendChild(btn);
|
|
278
348
|
card.appendChild(foot);
|
|
279
349
|
grid.appendChild(card);
|
|
280
350
|
}
|
|
281
|
-
root.appendChild(grid);
|
|
282
351
|
},
|
|
283
352
|
});
|
|
284
353
|
}),
|
|
@@ -8,20 +8,27 @@
|
|
|
8
8
|
// - 无 DOM 环境(SSR / 测试)时不弹,直接 resolve whenNoDom(缺省 null)。
|
|
9
9
|
// 页面里的 request.prompt(点动作先问再发请求)由页面级 KitActionHost 调本函数;展示对象里用 ctx.prompt。
|
|
10
10
|
|
|
11
|
+
import { kitApplyLevelClass } from './level-class';
|
|
12
|
+
import { nextUid } from '../base/shared';
|
|
11
13
|
import { kitText } from '../i18n/kit-text';
|
|
12
14
|
import { kitControlRecipe, kitTypographyRecipe, setKitFace } from '../recipes';
|
|
13
15
|
import { KIT_ERROR_TEXT } from '../recipes/typography';
|
|
14
|
-
import { KIT_MODAL_CLASS_CANDIDATES, mountKitModal } from './modal-dialog';
|
|
15
|
-
import { KIT_DIALOG_HINT_CLASS, KIT_DIALOG_INPUT_CLASS, KIT_DIALOG_MESSAGE_CLASS, kitDialogButton } from './confirm-dialog';
|
|
16
|
+
import { KIT_MODAL_CLASS_CANDIDATES, mountKitModal, watchKitModalDetached } from './modal-dialog';
|
|
17
|
+
import { closeAndDestroyKitModal, KIT_DIALOG_HINT_CLASS, KIT_DIALOG_INPUT_CLASS, KIT_DIALOG_MESSAGE_CLASS, kitDialogButton } from './confirm-dialog';
|
|
16
18
|
import { classTokens } from './shape-util';
|
|
19
|
+
import { kitMarkLevel, kitMarkPart } from './kit-contract';
|
|
20
|
+
import { mergeClass } from '../shared/merge-class';
|
|
17
21
|
|
|
18
|
-
const FIELD_CLASS = 'flex flex-col gap-1';
|
|
19
|
-
const LABEL_CLASS = kitTypographyRecipe('
|
|
20
|
-
const TEXTAREA_CLASS = kitControlRecipe({ multiline: true });
|
|
22
|
+
const FIELD_CLASS = 'flex min-w-0 flex-col gap-1.5';
|
|
23
|
+
const LABEL_CLASS = mergeClass('min-w-0', kitTypographyRecipe('formLabel'));
|
|
24
|
+
const TEXTAREA_CLASS = mergeClass(kitControlRecipe({ multiline: true }), 'w-full min-w-0');
|
|
21
25
|
const ERROR_CLASS = KIT_ERROR_TEXT;
|
|
26
|
+
const DIALOG_TITLE_TIGHT = 'tracking-tight';
|
|
27
|
+
const PROMPT_BODY_CLASS = 'p-card gap-4';
|
|
22
28
|
|
|
23
29
|
export const KIT_PROMPT_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
24
|
-
FIELD_CLASS, LABEL_CLASS, TEXTAREA_CLASS, ERROR_CLASS,
|
|
30
|
+
FIELD_CLASS, LABEL_CLASS, TEXTAREA_CLASS, ERROR_CLASS, DIALOG_TITLE_TIGHT, PROMPT_BODY_CLASS,
|
|
31
|
+
KIT_DIALOG_INPUT_CLASS, KIT_DIALOG_MESSAGE_CLASS, KIT_DIALOG_HINT_CLASS, KIT_MODAL_CLASS_CANDIDATES,
|
|
25
32
|
);
|
|
26
33
|
|
|
27
34
|
export interface KitPromptField {
|
|
@@ -70,19 +77,22 @@ export function askKitPrompt(opts: KitPromptOptions): Promise<Record<string, str
|
|
|
70
77
|
dismissOnScrim: false,
|
|
71
78
|
onClose: () => finish(null),
|
|
72
79
|
}, doc);
|
|
73
|
-
let
|
|
80
|
+
let stopWatch: () => void = () => {};
|
|
74
81
|
const finish = (value: Record<string, string> | null): void => {
|
|
75
82
|
if (settled) return;
|
|
76
83
|
settled = true;
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
stopWatch();
|
|
85
|
+
stopWatch = () => {};
|
|
79
86
|
opts.signal?.removeEventListener('abort', onAbort);
|
|
80
|
-
modal
|
|
81
|
-
modal.destroy();
|
|
87
|
+
closeAndDestroyKitModal(modal, doc);
|
|
82
88
|
resolve(value);
|
|
83
89
|
};
|
|
84
90
|
const onAbort = (): void => finish(null);
|
|
85
91
|
|
|
92
|
+
const heading = modal.lead.querySelector('h2');
|
|
93
|
+
if (heading !== null) heading.className = mergeClass(heading.className, DIALOG_TITLE_TIGHT);
|
|
94
|
+
modal.body.className = mergeClass(modal.body.className, PROMPT_BODY_CLASS);
|
|
95
|
+
|
|
86
96
|
if (opts.message !== undefined && opts.message !== '') {
|
|
87
97
|
const msg = doc.createElement('p');
|
|
88
98
|
msg.className = KIT_DIALOG_MESSAGE_CLASS;
|
|
@@ -90,15 +100,25 @@ export function askKitPrompt(opts: KitPromptOptions): Promise<Record<string, str
|
|
|
90
100
|
modal.body.appendChild(msg);
|
|
91
101
|
}
|
|
92
102
|
|
|
93
|
-
const controls: Array<{ field: KitPromptField; control: Control; error: HTMLElement }> = [];
|
|
94
|
-
|
|
103
|
+
const controls: Array<{ field: KitPromptField; control: Control; error: HTMLElement; helpId: string }> = [];
|
|
104
|
+
const syncValidityA11y = (control: Control, errorId: string, helpId: string, invalid: boolean): void => {
|
|
105
|
+
if (invalid) control.setAttribute('aria-invalid', 'true');
|
|
106
|
+
else control.removeAttribute('aria-invalid');
|
|
107
|
+
const ids = [...(invalid ? [errorId] : []), ...(helpId !== '' ? [helpId] : [])];
|
|
108
|
+
if (ids.length > 0) control.setAttribute('aria-describedby', ids.join(' '));
|
|
109
|
+
else control.removeAttribute('aria-describedby');
|
|
110
|
+
};
|
|
111
|
+
opts.fields.forEach((field) => {
|
|
95
112
|
const wrap = doc.createElement('div');
|
|
96
113
|
wrap.className = FIELD_CLASS;
|
|
97
|
-
|
|
114
|
+
// 每个输入项是窗口里的一个字段(层级角色「条目」),标签是字段名、输入框是控件
|
|
115
|
+
kitMarkLevel(wrap, 'item'); kitApplyLevelClass(wrap);
|
|
116
|
+
const id = nextUid('kit-prompt');
|
|
98
117
|
if (field.label !== undefined && field.label !== '') {
|
|
99
118
|
const label = doc.createElement('label');
|
|
100
119
|
label.className = LABEL_CLASS;
|
|
101
120
|
label.htmlFor = id;
|
|
121
|
+
kitMarkPart(label, 'field-name');
|
|
102
122
|
label.textContent = field.required === true ? `${field.label} *` : field.label;
|
|
103
123
|
wrap.appendChild(label);
|
|
104
124
|
}
|
|
@@ -108,36 +128,47 @@ export function askKitPrompt(opts: KitPromptOptions): Promise<Record<string, str
|
|
|
108
128
|
control.id = id;
|
|
109
129
|
control.className = multi ? TEXTAREA_CLASS : KIT_DIALOG_INPUT_CLASS;
|
|
110
130
|
setKitFace(control, 'field');
|
|
131
|
+
kitMarkPart(control, 'control');
|
|
111
132
|
control.value = field.initial ?? '';
|
|
112
133
|
if (field.placeholder !== undefined) control.placeholder = field.placeholder;
|
|
113
134
|
wrap.appendChild(control);
|
|
114
135
|
const error = doc.createElement('p');
|
|
136
|
+
error.id = `${id}-err`;
|
|
115
137
|
error.className = ERROR_CLASS;
|
|
116
138
|
error.hidden = true;
|
|
117
139
|
error.setAttribute('role', 'alert');
|
|
118
140
|
wrap.appendChild(error);
|
|
141
|
+
let helpId = '';
|
|
119
142
|
if (field.help !== undefined && field.help !== '') {
|
|
120
143
|
const help = doc.createElement('p');
|
|
144
|
+
help.id = `${id}-help`;
|
|
145
|
+
helpId = help.id;
|
|
121
146
|
help.className = KIT_DIALOG_HINT_CLASS;
|
|
122
147
|
help.textContent = field.help;
|
|
123
148
|
wrap.appendChild(help);
|
|
124
149
|
}
|
|
125
|
-
control
|
|
150
|
+
syncValidityA11y(control, error.id, helpId, false);
|
|
151
|
+
control.addEventListener('input', () => {
|
|
152
|
+
error.hidden = true;
|
|
153
|
+
error.textContent = '';
|
|
154
|
+
syncValidityA11y(control, error.id, helpId, false);
|
|
155
|
+
});
|
|
126
156
|
control.addEventListener('keydown', (event: Event) => {
|
|
127
157
|
const e = event as KeyboardEvent;
|
|
128
158
|
if (e.key !== 'Enter') return;
|
|
129
159
|
if (multi ? (e.ctrlKey || e.metaKey) : !e.isComposing) { e.preventDefault(); submit(); }
|
|
130
160
|
});
|
|
131
161
|
modal.body.appendChild(wrap);
|
|
132
|
-
controls.push({ field, control, error });
|
|
162
|
+
controls.push({ field, control, error, helpId });
|
|
133
163
|
});
|
|
134
164
|
|
|
135
165
|
const submit = (): void => {
|
|
136
166
|
let first: Control | null = null;
|
|
137
|
-
for (const { field, control, error } of controls) {
|
|
167
|
+
for (const { field, control, error, helpId } of controls) {
|
|
138
168
|
if (field.required === true && control.value.trim() === '') {
|
|
139
169
|
error.textContent = field.requiredMessage ?? kitText('soma.kit.field_required', undefined, opts.at);
|
|
140
170
|
error.hidden = false;
|
|
171
|
+
syncValidityA11y(control, error.id, helpId, true);
|
|
141
172
|
first ??= control;
|
|
142
173
|
}
|
|
143
174
|
}
|
|
@@ -155,10 +186,7 @@ export function askKitPrompt(opts: KitPromptOptions): Promise<Record<string, str
|
|
|
155
186
|
|
|
156
187
|
(opts.at?.isConnected === true ? opts.at.parentNode ?? doc.body : doc.body).appendChild(modal.layer);
|
|
157
188
|
modal.open();
|
|
158
|
-
|
|
159
|
-
watch = new MutationObserver(() => { if (!modal.layer.isConnected) finish(null); });
|
|
160
|
-
watch.observe(doc.body, { childList: true, subtree: true });
|
|
161
|
-
}
|
|
189
|
+
stopWatch = watchKitModalDetached(modal.layer, doc, () => finish(null));
|
|
162
190
|
opts.signal?.addEventListener('abort', onAbort, { once: true });
|
|
163
191
|
(controls[0]?.control ?? ok).focus();
|
|
164
192
|
});
|
package/src/data/reaction-bar.ts
CHANGED
|
@@ -6,27 +6,37 @@
|
|
|
6
6
|
// 选一个抛 `add { emoji }`(已存在的表情等同点它的药丸)。选择层 Esc 关闭并回焦「+」,点外面关闭,方向键在候选间移动。
|
|
7
7
|
// 表情种类上限同真源 maxKinds。
|
|
8
8
|
|
|
9
|
+
import { kitApplyLevelClass } from './level-class';
|
|
9
10
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
10
11
|
import { bool, createKitController, joinClass, num, str } from '../base/shared';
|
|
12
|
+
import { KIT_ICON_CLASS_CANDIDATES, kitIcon } from '../shared/icons';
|
|
11
13
|
import { kitKey, kitText } from '../i18n/kit-text';
|
|
12
14
|
import { setKitFace } from '../recipes';
|
|
15
|
+
import { KIT_FOCUS_RING, kitSelectedRecipe } from '../recipes/state';
|
|
13
16
|
import { classTokens, mk, rowsOf, textOf } from './shape-util';
|
|
14
17
|
import { REACTION_MAX_KINDS, REACTION_PALETTE } from './d9-limits';
|
|
15
18
|
import { attrEsc } from './d9-util';
|
|
16
|
-
import {
|
|
19
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked } from './kit-contract';
|
|
20
|
+
import { mergeClass } from '../shared/merge-class';
|
|
21
|
+
import { KIT_ATTR_ADD, KIT_ATTR_CHOICE, KIT_ATTR_PANEL, KIT_ATTR_REACTION, kitAttrSel } from '../shared/dom-attrs';
|
|
17
22
|
import { kitSurfaceRecipe } from '../recipes/surface';
|
|
18
|
-
import {
|
|
23
|
+
import { kitButtonEdgeRecipe } from '../recipes/control';
|
|
24
|
+
import { KIT_DROPDOWN_CLASS_CANDIDATES, dropdownOwnerOf, popPlaceClass, queryWithDropdowns, releaseDropdownsIn, syncDropdown } from '../base/popup';
|
|
19
25
|
|
|
20
26
|
const ROOT_CLASS = 'relative flex flex-wrap items-center gap-2 text-sm text-fg';
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
27
|
+
// 表情药丸 / 添加钮 = 带文字中性按钮描边(KT-B1)
|
|
28
|
+
const PILL_EDGE = kitButtonEdgeRecipe();
|
|
29
|
+
const PILL_CLASS = 'inline-flex h-7 items-center gap-1 rounded-full ' + PILL_EDGE + ' bg-surface px-2.5 text-xs text-fg transition-colors state-layer active:opacity-80 ' + KIT_FOCUS_RING.button;
|
|
30
|
+
const PILL_MINE = 'inline-flex h-7 items-center gap-1 rounded-full border border-primary ' + kitSelectedRecipe() + ' px-2.5 text-xs transition-colors hover:opacity-80 ' + KIT_FOCUS_RING.button;
|
|
31
|
+
const ADD_CLASS = 'inline-flex size-7 p-0 items-center justify-center rounded-full ' + PILL_EDGE + ' border-dashed bg-surface text-sm text-fg-muted transition-colors state-layer ' + KIT_FOCUS_RING.button;
|
|
32
|
+
const COUNT_CLASS = 'tabular-nums';
|
|
24
33
|
const PANEL_BASE_CLASS = mergeClass('absolute z-20 flex flex-wrap gap-1 p-2', kitSurfaceRecipe('raised'));
|
|
25
|
-
const PANEL_CLASS = `${PANEL_BASE_CLASS} start
|
|
26
|
-
const CHOICE_CLASS = 'inline-flex size-8 p-0 items-center justify-center rounded-
|
|
34
|
+
const PANEL_CLASS = `${PANEL_BASE_CLASS} ${popPlaceClass({ side: 'bottom', align: 'start' })}`;
|
|
35
|
+
const CHOICE_CLASS = 'inline-flex size-8 p-0 items-center justify-center rounded-control text-base transition-colors hover:bg-state-layer-hover active:bg-state-layer-press ' + KIT_FOCUS_RING.button;
|
|
27
36
|
|
|
28
37
|
export const KIT_REACTION_BAR_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
29
|
-
ROOT_CLASS, PILL_CLASS, PILL_MINE, ADD_CLASS, PANEL_BASE_CLASS, PANEL_CLASS, CHOICE_CLASS,
|
|
38
|
+
ROOT_CLASS, PILL_CLASS, PILL_MINE, ADD_CLASS, COUNT_CLASS, PANEL_BASE_CLASS, PANEL_CLASS, CHOICE_CLASS,
|
|
39
|
+
KIT_DROPDOWN_CLASS_CANDIDATES, KIT_ICON_CLASS_CANDIDATES,
|
|
30
40
|
);
|
|
31
41
|
|
|
32
42
|
export interface KitReaction {
|
|
@@ -78,6 +88,15 @@ export function createEmojiReactionBar(): SomaComponentDefinition {
|
|
|
78
88
|
// 添加层挂到浮层端口后不再是 root 的后代,root 上的委托收不到它的事件:重画出的面板元素直接绑这两个处理函数
|
|
79
89
|
let panelClick: EventListener | null = null;
|
|
80
90
|
let panelKeydown: EventListener | null = null;
|
|
91
|
+
let docDownListener: EventListener | null = null;
|
|
92
|
+
let docDownBound = false;
|
|
93
|
+
|
|
94
|
+
const syncDocDown = (want: boolean): void => {
|
|
95
|
+
if (want === docDownBound || !docDownListener) return;
|
|
96
|
+
if (want) document.addEventListener('pointerdown', docDownListener);
|
|
97
|
+
else document.removeEventListener('pointerdown', docDownListener);
|
|
98
|
+
docDownBound = want;
|
|
99
|
+
};
|
|
81
100
|
|
|
82
101
|
const view = (): KitReaction[] => reactionsOf(P().data).map((r) => {
|
|
83
102
|
const f = flipped.get(r.emoji);
|
|
@@ -105,7 +124,7 @@ export function createEmojiReactionBar(): SomaComponentDefinition {
|
|
|
105
124
|
if (!panelOpen) return;
|
|
106
125
|
panelOpen = false;
|
|
107
126
|
api.refresh();
|
|
108
|
-
if (focusAdd) root?.querySelector<HTMLElement>(
|
|
127
|
+
if (focusAdd) root?.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_ADD))?.focus();
|
|
109
128
|
};
|
|
110
129
|
|
|
111
130
|
return {
|
|
@@ -114,26 +133,26 @@ export function createEmojiReactionBar(): SomaComponentDefinition {
|
|
|
114
133
|
const r = root;
|
|
115
134
|
const onClick = (event: Event): void => {
|
|
116
135
|
const t = event.target as HTMLElement | null;
|
|
117
|
-
const pill = t?.closest<HTMLElement>(
|
|
118
|
-
if (pill) { toggle(pill.getAttribute(
|
|
119
|
-
if (t?.closest(
|
|
136
|
+
const pill = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_REACTION));
|
|
137
|
+
if (pill) { toggle(pill.getAttribute(KIT_ATTR_REACTION) ?? ''); return; }
|
|
138
|
+
if (t?.closest(kitAttrSel(KIT_ATTR_ADD))) {
|
|
120
139
|
panelOpen = !panelOpen;
|
|
121
140
|
api.refresh();
|
|
122
|
-
if (panelOpen) queryWithDropdowns(r,
|
|
141
|
+
if (panelOpen) queryWithDropdowns(r, kitAttrSel(KIT_ATTR_CHOICE))?.focus();
|
|
123
142
|
return;
|
|
124
143
|
}
|
|
125
|
-
const choice = t?.closest<HTMLElement>(
|
|
144
|
+
const choice = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_CHOICE));
|
|
126
145
|
if (choice) {
|
|
127
|
-
const emoji = choice.getAttribute(
|
|
146
|
+
const emoji = choice.getAttribute(KIT_ATTR_CHOICE) ?? '';
|
|
128
147
|
panelOpen = false;
|
|
129
148
|
if (reactionsOf(P().data).some((x) => x.emoji === emoji)) toggle(emoji); else { api.refresh(); api.emit('add', { emoji }); }
|
|
130
|
-
r.querySelector<HTMLElement>(
|
|
149
|
+
r.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_ADD))?.focus();
|
|
131
150
|
}
|
|
132
151
|
};
|
|
133
152
|
const onKeydown = (event: KeyboardEvent): void => {
|
|
134
153
|
if (!panelOpen) return;
|
|
135
154
|
if (event.key === 'Escape') { event.preventDefault(); closePanel(true); return; }
|
|
136
|
-
const choices = [...(queryWithDropdowns(r,
|
|
155
|
+
const choices = [...(queryWithDropdowns(r, kitAttrSel(KIT_ATTR_PANEL)) ?? r).querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_CHOICE))];
|
|
137
156
|
const at = choices.indexOf(document.activeElement as HTMLElement);
|
|
138
157
|
if (at < 0) return;
|
|
139
158
|
const arrow = kitKey(event.key, r);
|
|
@@ -152,13 +171,15 @@ export function createEmojiReactionBar(): SomaComponentDefinition {
|
|
|
152
171
|
};
|
|
153
172
|
panelClick = onClick;
|
|
154
173
|
panelKeydown = onKeydown as EventListener;
|
|
174
|
+
docDownListener = onDocDown;
|
|
155
175
|
r.addEventListener('click', onClick);
|
|
156
176
|
r.addEventListener('keydown', onKeydown as EventListener);
|
|
157
|
-
|
|
177
|
+
syncDocDown(panelOpen);
|
|
158
178
|
return () => {
|
|
159
179
|
r.removeEventListener('click', onClick);
|
|
160
180
|
r.removeEventListener('keydown', onKeydown as EventListener);
|
|
161
|
-
|
|
181
|
+
syncDocDown(false);
|
|
182
|
+
docDownListener = null;
|
|
162
183
|
flipped.clear();
|
|
163
184
|
if (root) releaseDropdownsIn(root);
|
|
164
185
|
panelClick = null;
|
|
@@ -173,53 +194,67 @@ export function createEmojiReactionBar(): SomaComponentDefinition {
|
|
|
173
194
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
174
195
|
// 整条重建会丢焦点(键盘点药丸 / 「+」后):记下焦点所在,重绘后落回同一个
|
|
175
196
|
const focused = root.contains(document.activeElement) ? document.activeElement as HTMLElement : null;
|
|
176
|
-
const focusEmoji = focused?.closest(
|
|
177
|
-
const focusAdd = focused?.closest(
|
|
197
|
+
const focusEmoji = focused?.closest(kitAttrSel(KIT_ATTR_REACTION))?.getAttribute(KIT_ATTR_REACTION) ?? null;
|
|
198
|
+
const focusAdd = focused?.closest(kitAttrSel(KIT_ATTR_ADD)) != null;
|
|
178
199
|
releaseDropdownsIn(root);
|
|
179
200
|
root.textContent = '';
|
|
180
201
|
const disabled = bool(p.disabled);
|
|
181
|
-
|
|
202
|
+
const list = view();
|
|
203
|
+
const canAdd = bool(p.addable) && !disabled && list.length < REACTION_MAX_KINDS;
|
|
204
|
+
// 数据状态:没有任何表态为空;禁用为只读
|
|
205
|
+
kitMarkDataFacts(root, { empty: list.length === 0, readonly: disabled });
|
|
206
|
+
if (!canAdd && panelOpen) panelOpen = false;
|
|
207
|
+
syncDocDown(panelOpen && canAdd);
|
|
208
|
+
for (const r of list) {
|
|
182
209
|
const b = mk('button', r.mine ? PILL_MINE : PILL_CLASS);
|
|
183
210
|
b.type = 'button';
|
|
184
211
|
setKitFace(b, 'raised');
|
|
185
|
-
b.setAttribute(
|
|
212
|
+
b.setAttribute(KIT_ATTR_REACTION, r.emoji);
|
|
186
213
|
b.setAttribute('aria-pressed', r.mine ? 'true' : 'false');
|
|
214
|
+
// 表态药丸是切换动作钮;「我已表态」= 选中(aria-pressed 上面已写)
|
|
215
|
+
kitMarkPart(b, 'action');
|
|
216
|
+
kitMarkPicked(b, 'selected', r.mine, null);
|
|
187
217
|
b.setAttribute('aria-label', `${r.label !== '' ? r.label : r.emoji} ${r.count}`);
|
|
188
218
|
if (disabled) { b.disabled = true; b.setAttribute('aria-disabled', 'true'); }
|
|
189
219
|
b.appendChild(mk('span', '', r.emoji));
|
|
190
|
-
b.appendChild(mk('span',
|
|
220
|
+
b.appendChild(mk('span', COUNT_CLASS, String(r.count)));
|
|
191
221
|
root.appendChild(b);
|
|
192
222
|
}
|
|
193
|
-
if (
|
|
194
|
-
const add = mk('button', ADD_CLASS
|
|
223
|
+
if (canAdd) {
|
|
224
|
+
const add = mk('button', ADD_CLASS);
|
|
195
225
|
add.type = 'button';
|
|
196
|
-
|
|
226
|
+
setKitFace(add, 'raised');
|
|
227
|
+
add.setAttribute(KIT_ATTR_ADD, '');
|
|
228
|
+
kitMarkPart(add, 'action');
|
|
197
229
|
add.setAttribute('aria-label', str(p.add_text, kitText('soma.kit.add_reaction', undefined, root)));
|
|
198
230
|
add.setAttribute('aria-haspopup', 'true');
|
|
199
231
|
add.setAttribute('aria-expanded', panelOpen ? 'true' : 'false');
|
|
232
|
+
add.appendChild(kitIcon('plus', 'xs'));
|
|
200
233
|
root.appendChild(add);
|
|
201
234
|
if (panelOpen) {
|
|
202
235
|
const panel = mk('div', PANEL_CLASS);
|
|
203
236
|
panel.setAttribute('role', 'group');
|
|
204
237
|
panel.setAttribute('aria-label', str(p.add_text, kitText('soma.kit.add_reaction', undefined, root)));
|
|
205
|
-
panel.setAttribute(
|
|
238
|
+
panel.setAttribute(KIT_ATTR_PANEL, '');
|
|
239
|
+
// 表情选择层是浮出的气泡(挂到浮层端口)= 浮起
|
|
240
|
+
kitMarkLevel(panel, 'float'); kitApplyLevelClass(panel);
|
|
206
241
|
palette().forEach((e, i) => {
|
|
207
242
|
const c = mk('button', CHOICE_CLASS, e);
|
|
208
243
|
c.type = 'button';
|
|
209
|
-
c.setAttribute(
|
|
244
|
+
c.setAttribute(KIT_ATTR_CHOICE, e);
|
|
210
245
|
c.tabIndex = i === 0 ? 0 : -1;
|
|
211
246
|
panel.appendChild(c);
|
|
212
247
|
});
|
|
213
248
|
root.appendChild(panel);
|
|
214
|
-
syncDropdown(panel, true, PANEL_BASE_CLASS,
|
|
249
|
+
syncDropdown(panel, true, PANEL_BASE_CLASS, add);
|
|
215
250
|
if (!root.contains(panel)) {
|
|
216
251
|
if (panelClick) panel.addEventListener('click', panelClick);
|
|
217
252
|
if (panelKeydown) panel.addEventListener('keydown', panelKeydown);
|
|
218
253
|
}
|
|
219
254
|
}
|
|
220
255
|
}
|
|
221
|
-
if (focusEmoji !== null) root.querySelector<HTMLElement>(`[
|
|
222
|
-
else if (focusAdd) root.querySelector<HTMLElement>(
|
|
256
|
+
if (focusEmoji !== null) root.querySelector<HTMLElement>(`[${KIT_ATTR_REACTION}="${attrEsc(focusEmoji)}"]`)?.focus();
|
|
257
|
+
else if (focusAdd) root.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_ADD))?.focus();
|
|
223
258
|
},
|
|
224
259
|
};
|
|
225
260
|
}),
|