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
|
@@ -9,17 +9,26 @@
|
|
|
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
19
|
import { kitIcon } from '../shared/icons';
|
|
15
|
-
import { kitText } from '../i18n/kit-text';
|
|
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';
|
|
22
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';
|
|
23
32
|
|
|
24
33
|
/** 价格卡外缘 = 壳配方(容器边,KT-B2) */
|
|
25
34
|
const CARD_EDGE = kitShellRecipe({ tone: 'base', shadow: false });
|
|
@@ -27,29 +36,30 @@ const CARD_EDGE = kitShellRecipe({ tone: 'base', shadow: false });
|
|
|
27
36
|
const KEYS = ['cycles', 'plans', 'current_key'] as const;
|
|
28
37
|
|
|
29
38
|
const ROOT_CLASS = '@container flex flex-col gap-5 text-fg';
|
|
30
|
-
const CYCLES_CLASS = 'mx-auto inline-flex items-center gap-1 rounded-
|
|
31
|
-
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';
|
|
32
41
|
const NOTE_CLASS = 'rounded-full bg-success-soft px-1.5 text-xs font-medium text-success-on-soft';
|
|
33
42
|
// 卡片三槽对齐(宽档间距 comfortable,真源 structure.slotAlign.slotGapTiers):卡片是父 grid 的直接子节点,显示方式(subgrid / 不支持时 flex 纵向)与槽间距由结构 CSS 给,
|
|
34
43
|
// 所以卡片类里不写 flex / gap,父 grid 的行距也交给结构 CSS(只写列距 gap-x-4);三槽 = 标题(名称 + 说明)/ 指标(价格)/ 操作(功能列表 + 按钮)
|
|
35
44
|
const GRID_CLASS = 'grid grid-cols-1 gap-x-4 @md:grid-cols-2 @xl:grid-cols-3';
|
|
36
45
|
const CARD_CLASS = `relative ${CARD_EDGE} p-5`;
|
|
37
|
-
const CARD_RECOMMENDED_CLASS = 'relative rounded-
|
|
46
|
+
const CARD_RECOMMENDED_CLASS = 'relative rounded-card border border-primary bg-surface p-5 shadow-md ring-1 ring-primary';
|
|
38
47
|
const SLOT_TITLE_CLASS = 'flex flex-col gap-4';
|
|
39
48
|
const SLOT_ACTION_CLASS = 'flex flex-1 flex-col gap-4';
|
|
40
|
-
|
|
49
|
+
// 推荐角标 = 闭集值标签(语气淡底,闭集值出口),只补落位
|
|
50
|
+
const BADGE_CLASS = mergeClass('absolute end-4 top-4', kitClosedValueRecipe('primary'));
|
|
41
51
|
const NAME_CLASS = 'text-lg font-semibold text-fg';
|
|
42
52
|
const DESC_CLASS = 'text-sm text-fg-muted';
|
|
43
53
|
const PRICE_ROW_CLASS = 'flex items-baseline gap-1';
|
|
44
|
-
const PRICE_CLASS = 'text-2xl font-semibold text-fg';
|
|
54
|
+
const PRICE_CLASS = 'text-2xl font-semibold tabular-nums text-fg';
|
|
45
55
|
const PERIOD_CLASS = 'text-sm text-fg-muted';
|
|
46
56
|
const FEATURES_CLASS = 'flex flex-1 flex-col gap-2 text-sm';
|
|
47
57
|
const FEATURE_CLASS = 'flex items-start gap-2 text-fg';
|
|
48
58
|
const FEATURE_OFF_CLASS = 'flex items-start gap-2 text-fg-subtle';
|
|
49
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';
|
|
50
|
-
const CROSS_CLASS = 'inline-flex size-5 shrink-0 items-center justify-center rounded-full
|
|
51
|
-
const VALUE_CLASS = 'ms-auto shrink-0 text-fg-muted';
|
|
52
|
-
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' });
|
|
53
63
|
const ACTION_PLAIN_CLASS = kitEmphasisButtonRecipe('button.toolbar', { size: 'lg' });
|
|
54
64
|
|
|
55
65
|
export const KIT_PRICING_TABLE_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
@@ -166,46 +176,66 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
166
176
|
select: { payload: { key: { type: 'string' }, cycle: { type: 'string' }, item: { type: 'object' } }, desc: '点方案动作钮;item 是方案源对象' },
|
|
167
177
|
},
|
|
168
178
|
},
|
|
169
|
-
templateHtml: `<section
|
|
179
|
+
templateHtml: `<section ${KIT_ATTR_CONTAINER}="plain" data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
170
180
|
controllerFactory: createKitController((api) => {
|
|
171
181
|
let self: KitView;
|
|
172
182
|
return (self = {
|
|
173
183
|
attach(root) {
|
|
174
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
|
+
};
|
|
175
199
|
const onClick = (event: Event): void => {
|
|
176
200
|
const t = event.target as HTMLElement | null;
|
|
177
|
-
const cyc = t?.closest<HTMLElement>(
|
|
201
|
+
const cyc = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_CYCLE));
|
|
178
202
|
if (cyc && root.contains(cyc)) {
|
|
179
|
-
|
|
180
|
-
if (key !== '' && key !== s.cycle) {
|
|
181
|
-
s.cycle = key;
|
|
182
|
-
api.emit('cycle_change', { key });
|
|
183
|
-
for (const el of Array.from(root.querySelectorAll<HTMLElement>('[data-kit-cycle]'))) {
|
|
184
|
-
const on = el.getAttribute('data-kit-cycle') === key;
|
|
185
|
-
if (on) el.setAttribute('data-kit-selected', ''); else el.removeAttribute('data-kit-selected');
|
|
186
|
-
setKitFace(el, on ? 'raised' : null);
|
|
187
|
-
el.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
188
|
-
}
|
|
189
|
-
// 价格文案随周期换:整体重绘(周期条与卡片都在 render 里画)
|
|
190
|
-
s.given = '\u0000repaint';
|
|
191
|
-
const hadFocus = root.contains(document.activeElement);
|
|
192
|
-
self.render(root, api.props(), api);
|
|
193
|
-
// 重绘会重建切换条,键盘用户的焦点要回到新的同周期按钮上
|
|
194
|
-
if (hadFocus) root.querySelector<HTMLElement>(`[data-kit-cycle="${attrEsc(key)}"]`)?.focus();
|
|
195
|
-
}
|
|
203
|
+
switchCycle(cyc.getAttribute(KIT_ATTR_CYCLE) ?? '', false);
|
|
196
204
|
return;
|
|
197
205
|
}
|
|
198
|
-
const act = t?.closest<HTMLElement>(
|
|
206
|
+
const act = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_PLAN_ACTION));
|
|
199
207
|
if (act && root.contains(act) && !act.hasAttribute('disabled')) {
|
|
200
|
-
const key = act.getAttribute(
|
|
208
|
+
const key = act.getAttribute(KIT_ATTR_PLAN_ACTION) ?? '';
|
|
201
209
|
const p = api.props();
|
|
202
210
|
const src = singleOf(p.data, p, KEYS);
|
|
203
211
|
const plan = pricingPlansOf(src.plans).find((x) => x.key === key);
|
|
204
212
|
if (plan) api.emit('select', { key, cycle: s.cycle, item: plan.raw });
|
|
205
213
|
}
|
|
206
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
|
+
};
|
|
207
232
|
root.addEventListener('click', onClick);
|
|
208
|
-
|
|
233
|
+
root.addEventListener('keydown', onKeydown);
|
|
234
|
+
return () => {
|
|
235
|
+
root.removeEventListener('click', onClick);
|
|
236
|
+
root.removeEventListener('keydown', onKeydown);
|
|
237
|
+
STATES.delete(root);
|
|
238
|
+
};
|
|
209
239
|
},
|
|
210
240
|
render(root, p) {
|
|
211
241
|
const s = stateOf(root);
|
|
@@ -218,7 +248,10 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
218
248
|
if (s.given !== givenCycle && s.given !== '\u0000repaint') { s.given = givenCycle; if (givenCycle !== '') s.cycle = givenCycle; }
|
|
219
249
|
if (s.given === '\u0000repaint') s.given = givenCycle;
|
|
220
250
|
if (!cycles.some((c) => c.key === s.cycle)) s.cycle = cycles[0]?.key ?? '';
|
|
251
|
+
// 数据状态自报:本组件只有空与常态
|
|
252
|
+
kitMarkDataFacts(root, { empty: plans.length === 0 });
|
|
221
253
|
if (plans.length === 0) {
|
|
254
|
+
kitApplyCols(root, null);
|
|
222
255
|
root.appendChild(emptyNode(str(p.empty_text, kitText('soma.kit.pt_empty', undefined, root))));
|
|
223
256
|
return;
|
|
224
257
|
}
|
|
@@ -229,10 +262,13 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
229
262
|
for (const c of cycles) {
|
|
230
263
|
const btn = mk('button', CYCLE_CLASS);
|
|
231
264
|
btn.type = 'button';
|
|
232
|
-
btn.setAttribute(
|
|
265
|
+
btn.setAttribute(KIT_ATTR_CYCLE, c.key);
|
|
233
266
|
const on = c.key === s.cycle;
|
|
234
267
|
btn.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
235
|
-
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');
|
|
236
272
|
setKitFace(btn, on ? 'raised' : null); // 选中的周期钮才有底色 + shadow-sm(分段滑块式),未选中透明无面
|
|
237
273
|
btn.appendChild(mk('span', '', c.label));
|
|
238
274
|
if (c.note !== '') btn.appendChild(mk('span', NOTE_CLASS, c.note));
|
|
@@ -243,21 +279,49 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
243
279
|
const current = textOf(src.current_key);
|
|
244
280
|
const grid = mk('div', GRID_CLASS);
|
|
245
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);
|
|
246
303
|
for (const plan of plans) {
|
|
247
304
|
const isCurrent = current !== '' && plan.key === current;
|
|
248
305
|
const card = mk('article', plan.recommended ? CARD_RECOMMENDED_CLASS : CARD_CLASS);
|
|
249
|
-
card.setAttribute(
|
|
250
|
-
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);
|
|
251
311
|
const badge = isCurrent ? str(p.current_text, kitText('soma.kit.pt_current', undefined, root)) : plan.badge;
|
|
252
|
-
if (badge !== '')
|
|
312
|
+
if (badge !== '') { const b = mk('span', BADGE_CLASS, badge); kitMarkPart(b, 'mark'); card.appendChild(b); }
|
|
253
313
|
const head = markKitSlot(mk('div', SLOT_TITLE_CLASS), 'title');
|
|
254
|
-
|
|
314
|
+
const nameEl = mk('h3', NAME_CLASS, plan.name);
|
|
315
|
+
kitMarkPart(nameEl, 'block-title');
|
|
316
|
+
head.appendChild(nameEl);
|
|
255
317
|
if (plan.desc !== '') head.appendChild(mk('p', DESC_CLASS, plan.desc));
|
|
256
318
|
card.appendChild(head);
|
|
257
319
|
const price = plan.prices ? pricingTextFor(plan.prices, s.cycle) : plan.price;
|
|
258
320
|
const period = plan.periods ? pricingTextFor(plan.periods, s.cycle) : plan.period;
|
|
259
321
|
const row = markKitSlot(mk('div', PRICE_ROW_CLASS), 'metric');
|
|
260
|
-
|
|
322
|
+
const priceEl = mk('span', PRICE_CLASS, price);
|
|
323
|
+
kitMarkPart(priceEl, 'metric');
|
|
324
|
+
row.appendChild(priceEl);
|
|
261
325
|
if (period !== '') row.appendChild(mk('span', PERIOD_CLASS, period));
|
|
262
326
|
card.appendChild(row);
|
|
263
327
|
const ul = mk('ul', FEATURES_CLASS);
|
|
@@ -274,16 +338,16 @@ export function createPricingTable(): SomaComponentDefinition {
|
|
|
274
338
|
}
|
|
275
339
|
const foot = markKitSlot(mk('div', SLOT_ACTION_CLASS), 'action');
|
|
276
340
|
foot.appendChild(ul);
|
|
277
|
-
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)));
|
|
278
342
|
btn.type = 'button';
|
|
279
343
|
setKitFace(btn, 'raised');
|
|
280
|
-
btn.setAttribute(
|
|
344
|
+
btn.setAttribute(KIT_ATTR_PLAN_ACTION, plan.key);
|
|
345
|
+
kitMarkPart(btn, 'action');
|
|
281
346
|
if (isCurrent || plan.disabled) { btn.disabled = true; btn.setAttribute('aria-disabled', 'true'); }
|
|
282
347
|
foot.appendChild(btn);
|
|
283
348
|
card.appendChild(foot);
|
|
284
349
|
grid.appendChild(card);
|
|
285
350
|
}
|
|
286
|
-
root.appendChild(grid);
|
|
287
351
|
},
|
|
288
352
|
});
|
|
289
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,30 +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';
|
|
19
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked } from './kit-contract';
|
|
16
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
23
|
import { kitButtonEdgeRecipe } from '../recipes/control';
|
|
19
|
-
import { KIT_DROPDOWN_CLASS_CANDIDATES, dropdownOwnerOf, queryWithDropdowns, releaseDropdownsIn, syncDropdown } from '../base/popup';
|
|
24
|
+
import { KIT_DROPDOWN_CLASS_CANDIDATES, dropdownOwnerOf, popPlaceClass, queryWithDropdowns, releaseDropdownsIn, syncDropdown } from '../base/popup';
|
|
20
25
|
|
|
21
26
|
const ROOT_CLASS = 'relative flex flex-wrap items-center gap-2 text-sm text-fg';
|
|
22
27
|
// 表情药丸 / 添加钮 = 带文字中性按钮描边(KT-B1)
|
|
23
28
|
const PILL_EDGE = kitButtonEdgeRecipe();
|
|
24
|
-
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
|
|
25
|
-
const PILL_MINE = 'inline-flex h-7 items-center gap-1 rounded-full border border-primary
|
|
26
|
-
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
|
|
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';
|
|
27
33
|
const PANEL_BASE_CLASS = mergeClass('absolute z-20 flex flex-wrap gap-1 p-2', kitSurfaceRecipe('raised'));
|
|
28
|
-
const PANEL_CLASS = `${PANEL_BASE_CLASS} start
|
|
29
|
-
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;
|
|
30
36
|
|
|
31
37
|
export const KIT_REACTION_BAR_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
32
|
-
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,
|
|
33
40
|
);
|
|
34
41
|
|
|
35
42
|
export interface KitReaction {
|
|
@@ -81,6 +88,15 @@ export function createEmojiReactionBar(): SomaComponentDefinition {
|
|
|
81
88
|
// 添加层挂到浮层端口后不再是 root 的后代,root 上的委托收不到它的事件:重画出的面板元素直接绑这两个处理函数
|
|
82
89
|
let panelClick: EventListener | null = null;
|
|
83
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
|
+
};
|
|
84
100
|
|
|
85
101
|
const view = (): KitReaction[] => reactionsOf(P().data).map((r) => {
|
|
86
102
|
const f = flipped.get(r.emoji);
|
|
@@ -108,7 +124,7 @@ export function createEmojiReactionBar(): SomaComponentDefinition {
|
|
|
108
124
|
if (!panelOpen) return;
|
|
109
125
|
panelOpen = false;
|
|
110
126
|
api.refresh();
|
|
111
|
-
if (focusAdd) root?.querySelector<HTMLElement>(
|
|
127
|
+
if (focusAdd) root?.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_ADD))?.focus();
|
|
112
128
|
};
|
|
113
129
|
|
|
114
130
|
return {
|
|
@@ -117,26 +133,26 @@ export function createEmojiReactionBar(): SomaComponentDefinition {
|
|
|
117
133
|
const r = root;
|
|
118
134
|
const onClick = (event: Event): void => {
|
|
119
135
|
const t = event.target as HTMLElement | null;
|
|
120
|
-
const pill = t?.closest<HTMLElement>(
|
|
121
|
-
if (pill) { toggle(pill.getAttribute(
|
|
122
|
-
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))) {
|
|
123
139
|
panelOpen = !panelOpen;
|
|
124
140
|
api.refresh();
|
|
125
|
-
if (panelOpen) queryWithDropdowns(r,
|
|
141
|
+
if (panelOpen) queryWithDropdowns(r, kitAttrSel(KIT_ATTR_CHOICE))?.focus();
|
|
126
142
|
return;
|
|
127
143
|
}
|
|
128
|
-
const choice = t?.closest<HTMLElement>(
|
|
144
|
+
const choice = t?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_CHOICE));
|
|
129
145
|
if (choice) {
|
|
130
|
-
const emoji = choice.getAttribute(
|
|
146
|
+
const emoji = choice.getAttribute(KIT_ATTR_CHOICE) ?? '';
|
|
131
147
|
panelOpen = false;
|
|
132
148
|
if (reactionsOf(P().data).some((x) => x.emoji === emoji)) toggle(emoji); else { api.refresh(); api.emit('add', { emoji }); }
|
|
133
|
-
r.querySelector<HTMLElement>(
|
|
149
|
+
r.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_ADD))?.focus();
|
|
134
150
|
}
|
|
135
151
|
};
|
|
136
152
|
const onKeydown = (event: KeyboardEvent): void => {
|
|
137
153
|
if (!panelOpen) return;
|
|
138
154
|
if (event.key === 'Escape') { event.preventDefault(); closePanel(true); return; }
|
|
139
|
-
const choices = [...(queryWithDropdowns(r,
|
|
155
|
+
const choices = [...(queryWithDropdowns(r, kitAttrSel(KIT_ATTR_PANEL)) ?? r).querySelectorAll<HTMLElement>(kitAttrSel(KIT_ATTR_CHOICE))];
|
|
140
156
|
const at = choices.indexOf(document.activeElement as HTMLElement);
|
|
141
157
|
if (at < 0) return;
|
|
142
158
|
const arrow = kitKey(event.key, r);
|
|
@@ -155,13 +171,15 @@ export function createEmojiReactionBar(): SomaComponentDefinition {
|
|
|
155
171
|
};
|
|
156
172
|
panelClick = onClick;
|
|
157
173
|
panelKeydown = onKeydown as EventListener;
|
|
174
|
+
docDownListener = onDocDown;
|
|
158
175
|
r.addEventListener('click', onClick);
|
|
159
176
|
r.addEventListener('keydown', onKeydown as EventListener);
|
|
160
|
-
|
|
177
|
+
syncDocDown(panelOpen);
|
|
161
178
|
return () => {
|
|
162
179
|
r.removeEventListener('click', onClick);
|
|
163
180
|
r.removeEventListener('keydown', onKeydown as EventListener);
|
|
164
|
-
|
|
181
|
+
syncDocDown(false);
|
|
182
|
+
docDownListener = null;
|
|
165
183
|
flipped.clear();
|
|
166
184
|
if (root) releaseDropdownsIn(root);
|
|
167
185
|
panelClick = null;
|
|
@@ -176,53 +194,67 @@ export function createEmojiReactionBar(): SomaComponentDefinition {
|
|
|
176
194
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
177
195
|
// 整条重建会丢焦点(键盘点药丸 / 「+」后):记下焦点所在,重绘后落回同一个
|
|
178
196
|
const focused = root.contains(document.activeElement) ? document.activeElement as HTMLElement : null;
|
|
179
|
-
const focusEmoji = focused?.closest(
|
|
180
|
-
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;
|
|
181
199
|
releaseDropdownsIn(root);
|
|
182
200
|
root.textContent = '';
|
|
183
201
|
const disabled = bool(p.disabled);
|
|
184
|
-
|
|
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) {
|
|
185
209
|
const b = mk('button', r.mine ? PILL_MINE : PILL_CLASS);
|
|
186
210
|
b.type = 'button';
|
|
187
211
|
setKitFace(b, 'raised');
|
|
188
|
-
b.setAttribute(
|
|
212
|
+
b.setAttribute(KIT_ATTR_REACTION, r.emoji);
|
|
189
213
|
b.setAttribute('aria-pressed', r.mine ? 'true' : 'false');
|
|
214
|
+
// 表态药丸是切换动作钮;「我已表态」= 选中(aria-pressed 上面已写)
|
|
215
|
+
kitMarkPart(b, 'action');
|
|
216
|
+
kitMarkPicked(b, 'selected', r.mine, null);
|
|
190
217
|
b.setAttribute('aria-label', `${r.label !== '' ? r.label : r.emoji} ${r.count}`);
|
|
191
218
|
if (disabled) { b.disabled = true; b.setAttribute('aria-disabled', 'true'); }
|
|
192
219
|
b.appendChild(mk('span', '', r.emoji));
|
|
193
|
-
b.appendChild(mk('span',
|
|
220
|
+
b.appendChild(mk('span', COUNT_CLASS, String(r.count)));
|
|
194
221
|
root.appendChild(b);
|
|
195
222
|
}
|
|
196
|
-
if (
|
|
197
|
-
const add = mk('button', ADD_CLASS
|
|
223
|
+
if (canAdd) {
|
|
224
|
+
const add = mk('button', ADD_CLASS);
|
|
198
225
|
add.type = 'button';
|
|
199
|
-
|
|
226
|
+
setKitFace(add, 'raised');
|
|
227
|
+
add.setAttribute(KIT_ATTR_ADD, '');
|
|
228
|
+
kitMarkPart(add, 'action');
|
|
200
229
|
add.setAttribute('aria-label', str(p.add_text, kitText('soma.kit.add_reaction', undefined, root)));
|
|
201
230
|
add.setAttribute('aria-haspopup', 'true');
|
|
202
231
|
add.setAttribute('aria-expanded', panelOpen ? 'true' : 'false');
|
|
232
|
+
add.appendChild(kitIcon('plus', 'xs'));
|
|
203
233
|
root.appendChild(add);
|
|
204
234
|
if (panelOpen) {
|
|
205
235
|
const panel = mk('div', PANEL_CLASS);
|
|
206
236
|
panel.setAttribute('role', 'group');
|
|
207
237
|
panel.setAttribute('aria-label', str(p.add_text, kitText('soma.kit.add_reaction', undefined, root)));
|
|
208
|
-
panel.setAttribute(
|
|
238
|
+
panel.setAttribute(KIT_ATTR_PANEL, '');
|
|
239
|
+
// 表情选择层是浮出的气泡(挂到浮层端口)= 浮起
|
|
240
|
+
kitMarkLevel(panel, 'float'); kitApplyLevelClass(panel);
|
|
209
241
|
palette().forEach((e, i) => {
|
|
210
242
|
const c = mk('button', CHOICE_CLASS, e);
|
|
211
243
|
c.type = 'button';
|
|
212
|
-
c.setAttribute(
|
|
244
|
+
c.setAttribute(KIT_ATTR_CHOICE, e);
|
|
213
245
|
c.tabIndex = i === 0 ? 0 : -1;
|
|
214
246
|
panel.appendChild(c);
|
|
215
247
|
});
|
|
216
248
|
root.appendChild(panel);
|
|
217
|
-
syncDropdown(panel, true, PANEL_BASE_CLASS,
|
|
249
|
+
syncDropdown(panel, true, PANEL_BASE_CLASS, add);
|
|
218
250
|
if (!root.contains(panel)) {
|
|
219
251
|
if (panelClick) panel.addEventListener('click', panelClick);
|
|
220
252
|
if (panelKeydown) panel.addEventListener('keydown', panelKeydown);
|
|
221
253
|
}
|
|
222
254
|
}
|
|
223
255
|
}
|
|
224
|
-
if (focusEmoji !== null) root.querySelector<HTMLElement>(`[
|
|
225
|
-
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();
|
|
226
258
|
},
|
|
227
259
|
};
|
|
228
260
|
}),
|