soma-kit 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -340
- package/spec/generated/kit-page.schema.json +1134 -139
- package/spec/kit-grammar.json +935 -93
- package/spec/kit-grammar.schema.json +167 -2
- package/src/app/app-config.ts +219 -186
- package/src/app/define-kit-actions.ts +126 -20
- package/src/app/define-kit-app.ts +49 -4
- package/src/app/index.ts +5 -0
- package/src/app/kit-view-context.ts +39 -1
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +67 -23
- package/src/app/theme-runtime.ts +414 -85
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +104 -59
- package/src/base/anchored-layer.ts +7 -6
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +347 -50
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +143 -32
- package/src/base/check-core.ts +193 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +399 -27
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +148 -36
- package/src/base/context-menu.ts +23 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +114 -96
- package/src/base/date.ts +481 -74
- package/src/base/delta.ts +16 -9
- package/src/base/divider.ts +51 -33
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +57 -21
- package/src/base/gap-value.ts +34 -15
- package/src/base/hint-tips.ts +99 -29
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +79 -22
- package/src/base/inline-error.ts +13 -7
- package/src/base/input.ts +135 -35
- package/src/base/kbd.ts +30 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +282 -101
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +55 -22
- package/src/base/menu-button.ts +73 -22
- package/src/base/menu-core.ts +201 -24
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +7 -5
- package/src/base/motion/hover-gallery.ts +16 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +139 -27
- package/src/base/overlay-runtime.ts +30 -23
- package/src/base/overlay-shell.ts +59 -14
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +624 -73
- package/src/base/popup.ts +187 -52
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +141 -22
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +58 -16
- package/src/base/relation-cells.ts +541 -0
- package/src/base/resize-handle.ts +5 -3
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +70 -26
- package/src/base/select.ts +8 -3
- package/src/base/shared.ts +482 -71
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +123 -54
- package/src/base/tag.ts +184 -66
- package/src/base/text.ts +461 -71
- package/src/base/textarea.ts +88 -39
- package/src/base/time-picker.ts +335 -55
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +342 -88
- package/src/base/upload.ts +604 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +70 -5
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +52 -12
- package/src/biz/auth-panel/compile.ts +13 -3
- package/src/biz/auth-panel/shell.ts +27 -7
- package/src/biz/category-crud/compile.ts +51 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +29 -9
- package/src/biz/checkout-page/compile.ts +37 -3
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +26 -9
- package/src/biz/compose.ts +6 -1
- package/src/biz/data-components.ts +2 -0
- package/src/biz/import-wizard/compile.ts +4 -1
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +32 -18
- package/src/biz/index.ts +1 -1
- package/src/biz/landing-page/compile.ts +3 -2
- package/src/biz/landing-page/shell.ts +22 -3
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +54 -15
- package/src/biz/master-sub/compile.ts +194 -57
- package/src/biz/master-sub/detail-head.ts +141 -18
- package/src/biz/master-sub/index.ts +3 -0
- package/src/biz/master-sub/shell.ts +188 -62
- package/src/biz/multi-board/compile.ts +87 -36
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +3 -2
- package/src/biz/multi-board/prose-fold.ts +15 -11
- package/src/biz/multi-board/shell.ts +148 -37
- package/src/biz/notification-center/compile.ts +20 -6
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +43 -10
- package/src/biz/page-templates/domain-templates.ts +145 -22
- package/src/biz/page-templates/result-page/compile.ts +4 -1
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +17 -4
- package/src/biz/page-templates/sign-in-page/compile.ts +19 -8
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +28 -12
- package/src/biz/record-detail/compile.ts +39 -11
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +41 -10
- package/src/biz/settings-center/compile.ts +4 -1
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +30 -9
- package/src/biz/shared/action-host.ts +137 -46
- package/src/biz/shared/compile-helpers.ts +152 -28
- package/src/biz/shared/coordinator.ts +628 -147
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +58 -10
- package/src/biz/shared/overlay-shell.ts +40 -10
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +4 -2
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +21 -11
- package/src/biz/standard-crud/compile.ts +206 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +82 -22
- package/src/biz/standard-crud/summary.ts +2 -37
- package/src/biz/step-form/compile.ts +12 -3
- package/src/biz/step-form/hub.ts +165 -50
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +31 -15
- package/src/biz/types.ts +40 -4
- package/src/cli/kit-cli.ts +145 -26
- package/src/cli/kit-init.ts +3 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +446 -53
- package/src/compile/component-candidates.ts +56 -4
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +1 -1
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/rules-composition.ts +2 -1
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +382 -46
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +645 -28
- package/src/compile/styles.ts +226 -26
- package/src/compile/types.ts +62 -5
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +49 -22
- package/src/data/anchor-nav.ts +73 -15
- package/src/data/approval-flow.ts +210 -124
- package/src/data/assignment-picker.ts +163 -85
- package/src/data/async-result-panel.ts +110 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +141 -19
- package/src/data/calendar.ts +434 -96
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +72 -38
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +904 -77
- package/src/data/checklist.ts +78 -35
- package/src/data/code-view.ts +106 -48
- package/src/data/comment-thread.ts +607 -87
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +198 -30
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +107 -50
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +33 -17
- package/src/data/embed.ts +142 -7
- package/src/data/engine-ports.ts +13 -4
- package/src/data/field-mapper.ts +104 -48
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +603 -142
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +85 -27
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +637 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +38 -15
- package/src/data/image-viewer.ts +261 -62
- package/src/data/index.ts +63 -1
- package/src/data/item-list.ts +217 -57
- package/src/data/json-view.ts +165 -100
- package/src/data/kanban.ts +339 -87
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +155 -45
- package/src/data/matrix.ts +217 -112
- package/src/data/media-grid.ts +162 -38
- package/src/data/mega-menu.ts +39 -23
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +50 -15
- package/src/data/menu.ts +131 -47
- package/src/data/mockup.ts +30 -22
- package/src/data/modal-dialog.ts +90 -13
- package/src/data/navbar.ts +143 -61
- package/src/data/notice-list.ts +100 -48
- package/src/data/notify-renderer.ts +61 -7
- package/src/data/object-form.ts +1389 -130
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +122 -42
- package/src/data/panel-head.ts +237 -75
- package/src/data/permission-matrix.ts +371 -119
- package/src/data/permission-tree.ts +135 -80
- package/src/data/pricing-table.ts +106 -42
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +63 -31
- package/src/data/record-card.ts +239 -70
- package/src/data/record-picker.ts +56 -27
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +131 -41
- package/src/data/resident.ts +11 -1
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +206 -35
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +376 -102
- package/src/data/rule-builder.ts +129 -80
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +86 -43
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +438 -86
- package/src/data/static-lazy.ts +18 -0
- package/src/data/static-registry.ts +38 -2
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +63 -34
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +128 -47
- package/src/data/system-switcher.ts +40 -20
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +99 -31
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +110 -47
- package/src/data/transfer.ts +195 -47
- package/src/data/tree-table.ts +194 -112
- package/src/data/tree.ts +191 -70
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +242 -102
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +26 -4
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +1 -2
- package/src/frames/inherited-shell.ts +54 -13
- package/src/frames/page-bar.ts +205 -27
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +0 -2
- package/src/frames/shared.ts +64 -21
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +11 -7
- package/src/frames/split-frame/wiring.ts +14 -10
- package/src/frames/tabs-frame/shell.ts +3 -2
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +2 -0
- package/src/frames/workspace-frame/extras.ts +5 -3
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +22 -2
- package/src/frames/workspace-frame/state.ts +42 -14
- package/src/frames/workspace-frame/view.ts +697 -167
- package/src/generated/kit-grammar-runtime.ts +1016 -54
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +96 -3
- package/src/object-renderer/action-group.ts +175 -23
- package/src/object-renderer/action-more.ts +48 -17
- package/src/object-renderer/arrange.ts +241 -29
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +432 -107
- package/src/object-renderer/collection-table.ts +347 -45
- package/src/object-renderer/collection.ts +291 -62
- package/src/object-renderer/compile-data.ts +12 -2
- package/src/object-renderer/defaults.ts +6 -5
- package/src/object-renderer/emit-events.ts +45 -19
- package/src/object-renderer/emit-object.ts +35 -9
- package/src/object-renderer/emit-static.ts +734 -159
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +105 -18
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +18 -2
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +44 -2
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +71 -26
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +423 -104
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +428 -128
- package/src/object-renderer/types.ts +91 -2
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +15 -14
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +3 -2
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +76 -19
- package/src/recipes/control.ts +64 -5
- package/src/recipes/desc-list.ts +101 -7
- package/src/recipes/divider.ts +30 -9
- package/src/recipes/emphasis.ts +90 -5
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +3 -2
- package/src/recipes/index.ts +28 -4
- package/src/recipes/inherited-shell.ts +21 -15
- package/src/recipes/json-view.ts +6 -5
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +16 -6
- package/src/recipes/overlay.ts +47 -19
- package/src/recipes/page-width.ts +31 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +37 -19
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +5 -5
- package/src/recipes/state.ts +54 -3
- package/src/recipes/status.ts +14 -14
- package/src/recipes/strip.ts +47 -5
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +33 -4
- package/src/recipes/table-gap.ts +3 -2
- package/src/recipes/table-native-edit.ts +22 -9
- package/src/recipes/table-row.ts +45 -12
- package/src/recipes/tabs.ts +54 -22
- package/src/recipes/text-diff.ts +15 -8
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +68 -3
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +58 -12
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/icons.ts +28 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +165 -24
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +527 -16
- package/src/theme/kit-theme.tpl +491 -16
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +522 -185
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +3 -2
- package/src/theme/theme-tokens.ts +1601 -93
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/frames/list-summary.ts +0 -123
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
|
@@ -6,62 +6,135 @@
|
|
|
6
6
|
// `sending` 为真时发布框禁用。点「回复」抛 `reply { id }`;`likable` 为真时每条有赞钮,抛 `like { id }`。
|
|
7
7
|
// `readonly` 为真时不出发布框。重绘只重画评论列表,不动发布框(保住草稿与焦点)。
|
|
8
8
|
|
|
9
|
+
import { kitApplyLevelClass } from './level-class';
|
|
9
10
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
10
11
|
import { matchSubmitKey } from 'soma-core/keyboard';
|
|
11
|
-
import { bool, createKitController, formatValue, joinClass, num, str } from '../base/shared';
|
|
12
|
+
import { bool, createKitController, formatValue, joinClass, num, str, toggleKitHidden } from '../base/shared';
|
|
12
13
|
import { kitText } from '../i18n/kit-text';
|
|
13
14
|
import { setKitFace } from '../recipes';
|
|
15
|
+
import { KIT_FOCUS_RING } from '../recipes/state';
|
|
14
16
|
import { kitControlEdgeRecipe } from '../recipes/control';
|
|
15
17
|
|
|
16
18
|
/** 回复框的边 = 控件轮廓出口(KT-B1 / §4 C6) */
|
|
17
19
|
const AREA_EDGE = kitControlEdgeRecipe();
|
|
18
|
-
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
20
|
+
import { kitActionRecipe, kitEmphasisButtonRecipe, kitPlainActionRecipe } from '../recipes/emphasis';
|
|
21
|
+
import { kitMarkRecipe } from '../recipes/mark';
|
|
22
|
+
import { kitTonalFillRecipe } from '../recipes/state';
|
|
23
|
+
import { kitWellRecipe } from '../recipes/surface';
|
|
24
|
+
import { kitTypographyRecipe } from '../recipes/typography';
|
|
25
|
+
import { KIT_SKELETON_BAR_LINE, KIT_SKELETON_BAR_TITLE_MAIN, KIT_SKELETON_BAR_TITLE_SUB } from '../recipes/placeholder';
|
|
26
|
+
import { kitRetryRecipe } from '../recipes/placeholder';
|
|
27
|
+
import { KIT_ICON_CLASS_CANDIDATES, kitIcon } from '../shared/icons';
|
|
28
|
+
import { mergeClass } from '../shared/merge-class';
|
|
29
|
+
import { wireMenu, type MenuItemSpec } from '../base/menu-core';
|
|
30
|
+
import { KIT_MENU_BUTTON_CLASS_CANDIDATES, KIT_MENU_ITEM_CLASSES, KIT_MENU_PANEL } from '../base/menu-button';
|
|
31
|
+
import { KIT_POPUP_PLACE_CLASS_CANDIDATES, type PopPlace } from '../base/popup';
|
|
32
|
+
import { createPanelPortal, KIT_PANEL_PORTAL_CLASS_CANDIDATES } from './overlay-portal';
|
|
33
|
+
import { actionButton, BUTTON_CLASS_TOKENS, classTokens, emptyNode, keyMap, mk, rowsOf, textOf } from './shape-util';
|
|
34
|
+
import { kitMarkDataFacts, kitMarkLevel, kitMarkPart } from './kit-contract';
|
|
35
|
+
import { attrEsc, AVATAR_CLASS_TOKENS, avatarNode } from './d9-util';
|
|
36
|
+
import { CHAT_FOLLOW_RATIO, CHAT_MAX_LENGTH, CHAT_MAX_MESSAGES, CHAT_STATUSES } from './d9-limits';
|
|
37
|
+
import { KIT_DATA_LIMITS } from 'soma-foundation/kit-limits';
|
|
38
|
+
import {
|
|
39
|
+
KIT_ATTR_ACTION, KIT_ATTR_ANCHOR, KIT_ATTR_ATTACH, KIT_ATTR_CANCEL, KIT_ATTR_COMMENT, KIT_ATTR_COMPOSER, KIT_ATTR_COMPOSER_AVATAR,
|
|
40
|
+
KIT_ATTR_CONTAINER, KIT_ATTR_COUNT, KIT_ATTR_DELETED, KIT_ATTR_EARLIER, KIT_ATTR_EDITED, KIT_ATTR_GROUP, KIT_ATTR_LIKE, KIT_ATTR_LIST,
|
|
41
|
+
KIT_ATTR_LOADING, KIT_ATTR_MENTION, KIT_ATTR_MORE, KIT_ATTR_NEW, KIT_ATTR_ORDER, KIT_ATTR_ORDER_GIVEN, KIT_ATTR_RELOAD, KIT_ATTR_REPLIES,
|
|
42
|
+
KIT_ATTR_REPLIES_KEY, KIT_ATTR_REPLIES_LABEL, KIT_ATTR_REPLIES_TOGGLE, KIT_ATTR_REPLY, KIT_ATTR_REPLY_OF, KIT_ATTR_RETRY, KIT_ATTR_SEND,
|
|
43
|
+
KIT_ATTR_SIDE, KIT_ATTR_SORT, KIT_ATTR_STAMP, KIT_ATTR_STATUS, KIT_ATTR_THREAD_HEAD, KIT_ATTR_UNREAD, kitAttrHtml, kitAttrSel,
|
|
44
|
+
} from '../shared/dom-attrs';
|
|
22
45
|
|
|
23
|
-
export const KIT_COMMENT_DEFAULT_MAP = Object.freeze({
|
|
46
|
+
export const KIT_COMMENT_DEFAULT_MAP = Object.freeze({
|
|
47
|
+
id: 'id', author: 'author', time: 'time', text: 'text', avatar: 'avatar', likes: 'likes', mine: 'mine', status: 'status',
|
|
48
|
+
parent: 'parent', replies: 'replies', edited: 'edited', deleted: 'deleted', role: 'role', can_edit: 'can_edit', can_delete: 'can_delete',
|
|
49
|
+
});
|
|
24
50
|
|
|
25
51
|
// variant: chat(对话气泡):同一份数据形状,评论项换成左右对齐的气泡,Enter 发送、Shift+Enter 换行,另有附件钮与失败重试
|
|
26
52
|
const CHAT_MSG = 'flex items-end gap-2';
|
|
27
53
|
const CHAT_MSG_MINE = 'flex-row-reverse';
|
|
28
54
|
const CHAT_COL = 'flex min-w-0 max-w-xl flex-col gap-1';
|
|
29
55
|
const CHAT_COL_MINE = 'items-end';
|
|
30
|
-
const CHAT_NAME = 'px-1
|
|
31
|
-
const CHAT_BUBBLE = 'whitespace-pre-wrap break-words rounded-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
56
|
+
const CHAT_NAME = mergeClass(mergeClass('px-1', kitTypographyRecipe('captionPlain')), 'text-fg-muted');
|
|
57
|
+
const CHAT_BUBBLE = 'whitespace-pre-wrap break-words rounded-card px-3 py-2';
|
|
58
|
+
// 对方气泡 = 子块底色令牌(--soma-layer-sub),不直写井色;子块工具类带同心圆角会盖掉气泡尾角,故只取其底色类
|
|
59
|
+
const CHAT_THEM = 'rounded-es-item bg-layer-sub text-fg';
|
|
60
|
+
// 自己的气泡 = 软主色底(主色淡底 + on-soft 字),不用实心主色大块
|
|
61
|
+
const CHAT_ME = mergeClass(mergeClass('rounded-ee-item', kitTonalFillRecipe()), 'text-primary-on-soft');
|
|
62
|
+
// 消息流:同发送者连续消息成组(组内紧凑、组间留白);时间戳按间隔居中出一行
|
|
63
|
+
const CHAT_GROUP = 'flex flex-col gap-1';
|
|
64
|
+
const CHAT_STAMP = mergeClass(mergeClass('self-center px-1', kitTypographyRecipe('captionPlain')), 'tabular-nums');
|
|
65
|
+
// 头像占位(连续消息只首条显头像:其余消息用等宽占位对齐)
|
|
66
|
+
const CHAT_AVATAR_GAP = 'size-8 shrink-0';
|
|
67
|
+
const CHAT_STATUS_ICON = 'inline-flex items-center';
|
|
68
|
+
const CHAT_META = mergeClass(mergeClass('flex items-center gap-2 px-1', kitTypographyRecipe('captionPlain')), 'tabular-nums');
|
|
69
|
+
const CHAT_META_FAILED = mergeClass(mergeClass('flex items-center gap-2 px-1', kitTypographyRecipe('captionPlain')), 'text-danger-on-soft');
|
|
70
|
+
const CHAT_RETRY = 'rounded-item text-danger-on-soft underline transition-colors hover:opacity-80 ' + KIT_FOCUS_RING.button;
|
|
37
71
|
const CHAT_LIST = 'flex flex-col gap-4 overflow-y-auto';
|
|
38
72
|
const CHAT_ATTACH = kitEmphasisButtonRecipe('button.toolbar');
|
|
73
|
+
// 「新消息」提示(流式追加):用户翻到上面读历史时新消息追加到底部、不抢滚动,列表下方居中出一枚胶囊钮(主色实心 + 悬浮阴影),点它回到底部;
|
|
74
|
+
// 抄 Slack / iMessage / shadcn chat 示例的「回到最新」钮写法
|
|
75
|
+
const CHAT_NEW = mergeClass(mergeClass('self-center rounded-full bg-primary px-3 py-1 text-primary-fg shadow-md transition-opacity hover:opacity-90', kitTypographyRecipe('deltaSm')), KIT_FOCUS_RING.button);
|
|
39
76
|
const CHAT_CLASS_TOKENS = classTokens(
|
|
40
77
|
CHAT_MSG, CHAT_MSG_MINE, CHAT_COL, CHAT_COL_MINE, CHAT_NAME, CHAT_BUBBLE, CHAT_THEM, CHAT_ME, CHAT_META, CHAT_META_FAILED, CHAT_RETRY,
|
|
41
|
-
CHAT_LIST, CHAT_ATTACH, AVATAR_CLASS_TOKENS,
|
|
78
|
+
CHAT_LIST, CHAT_ATTACH, CHAT_NEW, AVATAR_CLASS_TOKENS, CHAT_GROUP, CHAT_STAMP, CHAT_AVATAR_GAP, CHAT_STATUS_ICON,
|
|
42
79
|
);
|
|
43
80
|
|
|
44
|
-
const ROOT_CLASS = 'flex flex-col gap-4 text
|
|
45
|
-
|
|
81
|
+
const ROOT_CLASS = mergeClass('flex flex-col gap-4', kitTypographyRecipe('text'));
|
|
82
|
+
// 线程头「评论 (N)」+ 排序切换;回复缩进一级(头像宽 + 间距 = 44,回复头像 24);已删除占位、已编辑、提及、锚点高亮、加载 / 错误 / 加载更早
|
|
83
|
+
const THREAD_HEAD_CLASS = 'flex items-center justify-between gap-2';
|
|
84
|
+
const THREAD_TITLE_CLASS = mergeClass(kitTypographyRecipe('bodyStrong'), 'tabular-nums');
|
|
85
|
+
const SORT_BUTTON_CLASS = kitPlainActionRecipe('sort', { shape: 'button', tight: true });
|
|
86
|
+
// 回复缩进 = 头像列宽 + 列间距:取长度令牌对应的具名档(控件大高 control-lg),不写任意步数
|
|
87
|
+
const REPLIES_CLASS = 'mt-2 flex flex-col gap-3 ps-control-lg';
|
|
88
|
+
const REPLY_TOGGLE_CLASS = kitPlainActionRecipe('expand', { shape: 'button', tight: true });
|
|
89
|
+
const ROLE_TAG_CLASS = kitMarkRecipe('tone', 'neutral');
|
|
90
|
+
const EDITED_CLASS = kitTypographyRecipe('captionPlain');
|
|
91
|
+
const DELETED_CLASS = 'text-fg-subtle';
|
|
92
|
+
const MENTION_CLASS = kitMarkRecipe('tone', 'primary');
|
|
93
|
+
const ANCHOR_CLASS = mergeClass(mergeClass('rounded-item', kitTonalFillRecipe()), 'motion-safe:transition-colors');
|
|
94
|
+
const MORE_WRAP_CLASS = 'relative inline-block';
|
|
95
|
+
const MORE_TRIGGER_CLASS = kitActionRecipe('more', { size: 'sm', tight: true });
|
|
96
|
+
const MORE_PLACE: PopPlace = { side: 'bottom', align: 'start' };
|
|
97
|
+
const MORE_SHOWN = KIT_MENU_PANEL.classFor(MORE_PLACE);
|
|
98
|
+
const LOAD_EARLIER_CLASS = kitPlainActionRecipe('more-text', { shape: 'button', tight: true });
|
|
99
|
+
const LOAD_EARLIER_ROW_CLASS = 'flex justify-center';
|
|
100
|
+
const SKELETON_ROW_CLASS = 'flex gap-3';
|
|
101
|
+
const SKELETON_AVATAR_CLASS = mergeClass(mergeClass('size-8 shrink-0 rounded-full', kitWellRecipe()), 'motion-safe:animate-kit-pulse');
|
|
102
|
+
const SKELETON_LINES_CLASS = 'flex flex-1 flex-col gap-2';
|
|
103
|
+
const ERROR_BAR_CLASS = mergeClass(mergeClass('flex items-center justify-between gap-2 rounded-item bg-danger-soft px-3 py-2', kitTypographyRecipe('text')), 'text-danger-on-soft');
|
|
104
|
+
const ERROR_RETRY_CLASS = kitRetryRecipe('danger');
|
|
105
|
+
const COMPOSER_ROW_CLASS = 'flex gap-3';
|
|
106
|
+
const COMPOSER_MAIN_CLASS = 'flex min-w-0 flex-1 flex-col gap-2';
|
|
107
|
+
const COMPOSER_ACTIONS_CLASS = 'flex items-center gap-2';
|
|
108
|
+
const CANCEL_BUTTON_CLASS = kitActionRecipe('cancel', { size: 'sm' });
|
|
109
|
+
const THREAD_CLASS_TOKENS = classTokens(
|
|
110
|
+
THREAD_HEAD_CLASS, THREAD_TITLE_CLASS, SORT_BUTTON_CLASS, REPLIES_CLASS, REPLY_TOGGLE_CLASS, ROLE_TAG_CLASS, EDITED_CLASS, DELETED_CLASS,
|
|
111
|
+
MENTION_CLASS, ANCHOR_CLASS, MORE_WRAP_CLASS, MORE_TRIGGER_CLASS, MORE_SHOWN, 'hidden', LOAD_EARLIER_CLASS, LOAD_EARLIER_ROW_CLASS,
|
|
112
|
+
SKELETON_ROW_CLASS, SKELETON_AVATAR_CLASS, SKELETON_LINES_CLASS, KIT_SKELETON_BAR_LINE, KIT_SKELETON_BAR_TITLE_MAIN, KIT_SKELETON_BAR_TITLE_SUB,
|
|
113
|
+
ERROR_BAR_CLASS, ERROR_RETRY_CLASS, COMPOSER_ROW_CLASS, COMPOSER_MAIN_CLASS, COMPOSER_ACTIONS_CLASS, CANCEL_BUTTON_CLASS,
|
|
114
|
+
KIT_ICON_CLASS_CANDIDATES, Object.values(KIT_MENU_ITEM_CLASSES), KIT_MENU_BUTTON_CLASS_CANDIDATES, KIT_POPUP_PLACE_CLASS_CANDIDATES, KIT_PANEL_PORTAL_CLASS_CANDIDATES,
|
|
115
|
+
);
|
|
116
|
+
// 评论项间距 20、头像 32(取值表 06「评论列表」:Ant Comment / Arco / TDesign 头像 32、项距 16–24 取中)
|
|
117
|
+
const LIST_CLASS = 'flex flex-col gap-5';
|
|
46
118
|
const ITEM_CLASS = 'flex gap-3';
|
|
47
119
|
const AVATAR_CLASS = 'flex size-8 shrink-0 items-center justify-center rounded-full text-xs font-semibold';
|
|
48
120
|
const AVATAR_IMG = 'size-8 shrink-0 rounded-full';
|
|
49
|
-
const BODY_CLASS = 'flex flex-1 flex-col gap-1';
|
|
121
|
+
const BODY_CLASS = 'flex min-w-0 flex-1 flex-col gap-1';
|
|
50
122
|
const HEAD_CLASS = 'flex flex-wrap items-baseline gap-x-2';
|
|
51
|
-
const AUTHOR_CLASS = '
|
|
52
|
-
const TIME_CLASS = '
|
|
53
|
-
const TEXT_CLASS = 'whitespace-pre-wrap text-fg';
|
|
123
|
+
const AUTHOR_CLASS = kitTypographyRecipe('menuItem');
|
|
124
|
+
const TIME_CLASS = mergeClass(kitTypographyRecipe('captionPlain'), 'tabular-nums');
|
|
125
|
+
const TEXT_CLASS = 'whitespace-pre-wrap break-words text-fg';
|
|
54
126
|
const ROW_ACTIONS = 'flex items-center gap-3 text-xs';
|
|
55
|
-
const LINK_BUTTON = 'rounded-
|
|
127
|
+
const LINK_BUTTON = 'rounded-item text-fg-muted transition-colors hover:text-fg ' + KIT_FOCUS_RING.button;
|
|
128
|
+
const LIKE_BUTTON_CLASS = `${LINK_BUTTON} tabular-nums`;
|
|
56
129
|
const COMPOSER_CLASS = 'flex flex-col gap-2';
|
|
57
|
-
const INPUT_CLASS = 'w-full appearance-none autofill-clear resize-none rounded-
|
|
130
|
+
const INPUT_CLASS = mergeClass(mergeClass(mergeClass('w-full appearance-none autofill-clear resize-none rounded-control', AREA_EDGE), mergeClass('bg-surface px-3 py-2 transition-colors state-layer disabled:cursor-not-allowed disabled:bg-control-disabled disabled:text-fg-disabled', kitTypographyRecipe('text'))), KIT_FOCUS_RING.button);
|
|
58
131
|
const COMPOSER_FOOT = 'flex items-center justify-between gap-2';
|
|
59
|
-
const COUNTER_CLASS = '
|
|
132
|
+
const COUNTER_CLASS = mergeClass(kitTypographyRecipe('captionPlain'), 'tabular-nums');
|
|
60
133
|
|
|
61
134
|
export const KIT_COMMENT_THREAD_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
62
135
|
ROOT_CLASS, LIST_CLASS, ITEM_CLASS, AVATAR_CLASS, AVATAR_IMG, BODY_CLASS, HEAD_CLASS, AUTHOR_CLASS, TIME_CLASS, TEXT_CLASS,
|
|
63
|
-
ROW_ACTIONS, LINK_BUTTON, COMPOSER_CLASS, INPUT_CLASS, COMPOSER_FOOT, COUNTER_CLASS, BUTTON_CLASS_TOKENS,
|
|
64
|
-
CHAT_CLASS_TOKENS,
|
|
136
|
+
ROW_ACTIONS, LINK_BUTTON, LIKE_BUTTON_CLASS, COMPOSER_CLASS, INPUT_CLASS, COMPOSER_FOOT, COUNTER_CLASS, BUTTON_CLASS_TOKENS,
|
|
137
|
+
CHAT_CLASS_TOKENS, THREAD_CLASS_TOKENS,
|
|
65
138
|
);
|
|
66
139
|
|
|
67
140
|
export interface KitCommentEntry {
|
|
@@ -75,15 +148,81 @@ export interface KitCommentEntry {
|
|
|
75
148
|
mine: boolean;
|
|
76
149
|
/** chat 变体:sending / sent / failed(读 kit-grammar#dataLimits.chat.statuses),其余为空 */
|
|
77
150
|
status: string;
|
|
151
|
+
/** 上级评论 id(空 = 顶层);回复只嵌一级,更深的挂到顶层祖先 */
|
|
152
|
+
parent: string;
|
|
153
|
+
/** 作者角色标签(评论流 meta 行) */
|
|
154
|
+
role: string;
|
|
155
|
+
/** 已编辑:真值 = 画「已编辑」;字符串(编辑时间)同时作悬停提示 */
|
|
156
|
+
edited: string;
|
|
157
|
+
/** 已删除:画占位并保留回复结构,无正文无动作 */
|
|
158
|
+
deleted: boolean;
|
|
159
|
+
canEdit: boolean;
|
|
160
|
+
canDelete: boolean;
|
|
161
|
+
/** 原始 time 的机器可读值(<time datetime>)与毫秒(解析不了为 null) */
|
|
162
|
+
iso: string;
|
|
163
|
+
ms: number | null;
|
|
78
164
|
raw: unknown;
|
|
79
165
|
}
|
|
80
166
|
|
|
81
|
-
/**
|
|
167
|
+
/** 顶层评论 + 一级回复(纯函数):parent 指向的上级若自己也是回复,则挂到顶层祖先;上级不存在按顶层;数据里自带 replies 数组的并入该评论 */
|
|
168
|
+
export interface KitCommentNode { entry: KitCommentEntry; replies: KitCommentEntry[] }
|
|
169
|
+
export function commentTreeOf(entries: readonly KitCommentEntry[]): KitCommentNode[] {
|
|
170
|
+
const byKey = new Map(entries.map((e) => [e.key, e] as const));
|
|
171
|
+
const topOf = (e: KitCommentEntry): string => {
|
|
172
|
+
let cur = e;
|
|
173
|
+
const seen = new Set<string>();
|
|
174
|
+
while (cur.parent !== '' && byKey.has(cur.parent) && !seen.has(cur.key)) { seen.add(cur.key); cur = byKey.get(cur.parent)!; }
|
|
175
|
+
return cur.key;
|
|
176
|
+
};
|
|
177
|
+
const nodes: KitCommentNode[] = [];
|
|
178
|
+
const at = new Map<string, KitCommentNode>();
|
|
179
|
+
for (const e of entries) {
|
|
180
|
+
if (e.parent === '' || !byKey.has(e.parent)) { const n = { entry: e, replies: [] as KitCommentEntry[] }; nodes.push(n); at.set(e.key, n); }
|
|
181
|
+
}
|
|
182
|
+
for (const e of entries) {
|
|
183
|
+
if (e.parent === '' || !byKey.has(e.parent)) continue;
|
|
184
|
+
at.get(topOf(e))?.replies.push(e);
|
|
185
|
+
}
|
|
186
|
+
return nodes;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** 提及切段(纯函数):@名字(字母数字下划线连字符与汉字)切成 [文字, 是否提及] */
|
|
190
|
+
export function splitMentions(text: string): Array<[string, boolean]> {
|
|
191
|
+
const out: Array<[string, boolean]> = [];
|
|
192
|
+
const re = /@[\w\-一-龥]+/g;
|
|
193
|
+
let at = 0;
|
|
194
|
+
for (let hit = re.exec(text); hit !== null; hit = re.exec(text)) {
|
|
195
|
+
if (hit.index > at) out.push([text.slice(at, hit.index), false]);
|
|
196
|
+
out.push([hit[0], true]);
|
|
197
|
+
at = hit.index + hit[0].length;
|
|
198
|
+
}
|
|
199
|
+
if (at < text.length) out.push([text.slice(at), false]);
|
|
200
|
+
return out.length > 0 ? out : [[text, false]];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** 源数据 -> 评论(纯函数,便于单测);数据里自带 replies 数组的展开成带 parent 的平铺条目 */
|
|
82
204
|
export function commentEntriesOf(data: unknown, mapRaw: unknown, timeFormat = '', locale = '', me = ''): KitCommentEntry[] {
|
|
83
205
|
const m = keyMap(KIT_COMMENT_DEFAULT_MAP, mapRaw);
|
|
84
|
-
|
|
206
|
+
const flat: Array<{ raw: Record<string, unknown>; parent: string }> = [];
|
|
207
|
+
rowsOf(data).forEach((raw) => {
|
|
208
|
+
flat.push({ raw, parent: textOf(raw[m.parent]) });
|
|
209
|
+
const id = raw[m.id];
|
|
210
|
+
if (Array.isArray(raw[m.replies]) && id !== undefined && id !== null && id !== '') {
|
|
211
|
+
for (const r of rowsOf(raw[m.replies])) flat.push({ raw: r, parent: String(id) });
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
return flat.map(({ raw, parent }, i) => {
|
|
85
215
|
const time = raw[m.time];
|
|
216
|
+
const edited = raw[m.edited];
|
|
86
217
|
return {
|
|
218
|
+
parent,
|
|
219
|
+
role: textOf(raw[m.role]),
|
|
220
|
+
edited: edited === true || edited === 'true' ? '1' : typeof edited === 'string' || typeof edited === 'number' ? textOf(edited) : '',
|
|
221
|
+
deleted: raw[m.deleted] === true || raw[m.deleted] === 'true',
|
|
222
|
+
canEdit: raw[m.can_edit] === true || raw[m.can_edit] === 'true',
|
|
223
|
+
canDelete: raw[m.can_delete] === true || raw[m.can_delete] === 'true',
|
|
224
|
+
iso: typeof time === 'string' && time !== '' && Number.isFinite(Date.parse(time)) ? time : '',
|
|
225
|
+
ms: typeof time === 'number' ? time : typeof time === 'string' && Number.isFinite(Date.parse(time)) ? Date.parse(time) : null,
|
|
87
226
|
mine: raw[m.mine] === true || raw[m.mine] === 'true' || (me !== '' && textOf(raw[m.author]) === me),
|
|
88
227
|
status: CHAT_STATUSES.includes(textOf(raw[m.status])) ? textOf(raw[m.status]) : '',
|
|
89
228
|
raw,
|
|
@@ -109,10 +248,72 @@ interface Composer {
|
|
|
109
248
|
send: HTMLButtonElement;
|
|
110
249
|
counter: HTMLElement;
|
|
111
250
|
list: HTMLElement;
|
|
251
|
+
composer: HTMLElement;
|
|
252
|
+
avatarSlot: HTMLElement;
|
|
253
|
+
actions: HTMLElement;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** 输入框行数随内容长高:行数夹在真源 kit-limits#dataLimits.commentThread 的 composerMinRows 到 composerMaxRows,超出在框内滚动 */
|
|
257
|
+
const COMPOSER_MIN_ROWS = KIT_DATA_LIMITS.commentThread.composerMinRows;
|
|
258
|
+
const COMPOSER_MAX_ROWS = KIT_DATA_LIMITS.commentThread.composerMaxRows;
|
|
259
|
+
/** chat 变体相邻消息出时间戳的缺省间隔(分钟):真源 kit-limits#dataLimits.commentThread.timeGapMinutes */
|
|
260
|
+
const TIME_GAP_MINUTES = KIT_DATA_LIMITS.commentThread.timeGapMinutes;
|
|
261
|
+
export function composerRowsOf(value: string): number {
|
|
262
|
+
return Math.min(COMPOSER_MAX_ROWS, Math.max(COMPOSER_MIN_ROWS, value.split('\n').length));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** 每条评论的「更多」菜单(编辑 / 删除,删除置末):触发钮 + wireMenu 内核;销毁函数登记到 menus,随重绘清理 */
|
|
266
|
+
const menus = new WeakMap<HTMLElement, Array<() => void>>();
|
|
267
|
+
function moreMenu(root: HTMLElement, e: KitCommentEntry, p: Record<string, unknown>, emitKey: (key: 'edit' | 'delete') => void): HTMLElement {
|
|
268
|
+
const wrap = mk('span', MORE_WRAP_CLASS);
|
|
269
|
+
const trigger = mk('button', MORE_TRIGGER_CLASS);
|
|
270
|
+
trigger.type = 'button';
|
|
271
|
+
trigger.setAttribute('aria-haspopup', 'menu');
|
|
272
|
+
trigger.setAttribute('aria-label', kitText('soma.kit.more_actions', undefined, root));
|
|
273
|
+
trigger.setAttribute(KIT_ATTR_MORE, e.key);
|
|
274
|
+
trigger.appendChild(kitIcon('more', 'sm'));
|
|
275
|
+
kitMarkPart(trigger, 'action');
|
|
276
|
+
const menu = mk('div', 'hidden');
|
|
277
|
+
// 「更多」浮出菜单 = 浮起(菜单面板由 wireMenu 挂到浮出层,层级角色随节点走)
|
|
278
|
+
kitMarkLevel(menu, 'float'); kitApplyLevelClass(menu);
|
|
279
|
+
wrap.append(trigger, menu);
|
|
280
|
+
const items = (): MenuItemSpec[] => {
|
|
281
|
+
const list: MenuItemSpec[] = [];
|
|
282
|
+
if (e.canEdit) list.push({ key: 'edit', label: str(p.edit_text, kitText('soma.kit.ct_edit', undefined, root)), icon: '', disabled: false, danger: false, divider: false });
|
|
283
|
+
if (e.canDelete) list.push({ key: 'delete', label: str(p.delete_text, kitText('soma.kit.ct_delete', undefined, root)), icon: '', disabled: false, danger: true, divider: false });
|
|
284
|
+
return list;
|
|
285
|
+
};
|
|
286
|
+
const handle = wireMenu({
|
|
287
|
+
scope: wrap,
|
|
288
|
+
trigger,
|
|
289
|
+
menu,
|
|
290
|
+
shownClass: MORE_SHOWN,
|
|
291
|
+
hiddenClass: 'hidden',
|
|
292
|
+
portal: createPanelPortal(trigger),
|
|
293
|
+
fitted: () => ({ pref: MORE_PLACE, classFor: KIT_MENU_PANEL.classFor }),
|
|
294
|
+
classes: KIT_MENU_ITEM_CLASSES,
|
|
295
|
+
items,
|
|
296
|
+
locked: () => false,
|
|
297
|
+
onPick: (picked) => { if (picked.key === 'edit' || picked.key === 'delete') emitKey(picked.key); },
|
|
298
|
+
});
|
|
299
|
+
const list = menus.get(root) ?? [];
|
|
300
|
+
list.push(() => handle.destroy());
|
|
301
|
+
menus.set(root, list);
|
|
302
|
+
return wrap;
|
|
112
303
|
}
|
|
113
304
|
|
|
114
305
|
export function createCommentThread(): SomaComponentDefinition {
|
|
115
306
|
const parts = new WeakMap<HTMLElement, Composer>();
|
|
307
|
+
const collapsedReplies = new WeakMap<HTMLElement, Set<string>>();
|
|
308
|
+
const lastAnchors = new WeakMap<HTMLElement, string>();
|
|
309
|
+
const collapsedOf = (root: HTMLElement): Set<string> => {
|
|
310
|
+
let s = collapsedReplies.get(root);
|
|
311
|
+
if (!s) {
|
|
312
|
+
s = new Set<string>();
|
|
313
|
+
collapsedReplies.set(root, s);
|
|
314
|
+
}
|
|
315
|
+
return s;
|
|
316
|
+
};
|
|
116
317
|
|
|
117
318
|
return {
|
|
118
319
|
contract: {
|
|
@@ -133,6 +334,25 @@ export function createCommentThread(): SomaComponentDefinition {
|
|
|
133
334
|
sent_text: { type: 'string', default: '', desc: 'chat 变体:sent 状态文案' },
|
|
134
335
|
failed_text: { type: 'string', default: '', desc: 'chat 变体:failed 状态文案' },
|
|
135
336
|
retry_text: { type: 'string', default: '', desc: 'chat 变体:重试钮文案' },
|
|
337
|
+
loading: { type: 'boolean', default: false, desc: '加载中:没有评论时画骨架(头像圆 + 三行条),有评论时保留并标 aria-busy' },
|
|
338
|
+
error: { type: 'string', default: '', desc: '加载失败文案,非空即在列表上方画就地错误条(role=alert);retry_text 非空时带重试钮' },
|
|
339
|
+
has_earlier: { type: 'boolean', default: false, desc: '还有更早的:列表顶部画「加载更早」文字钮,点击抛 load_earlier' },
|
|
340
|
+
earlier_text: { type: 'string', default: '', desc: '加载更早钮文字,空取缺省文案' },
|
|
341
|
+
sortable: { type: 'boolean', default: false, desc: 'thread 变体:线程头出排序切换(最新 / 最早),按 time 在组件内排序,抛 sort { order }' },
|
|
342
|
+
order: { type: 'enum', values: ['asc', 'desc'], default: 'asc', desc: 'thread 变体:按 time 升序 / 降序(sortable 点击切换内部排序,外部变化时覆盖)' },
|
|
343
|
+
head: { type: 'boolean', default: false, desc: 'thread 变体:线程头「评论 (N)」(sortable 为真时自动出)' },
|
|
344
|
+
title: { type: 'string', default: '', desc: '线程头标题文案,空取缺省「评论」' },
|
|
345
|
+
aria_label: { type: 'string', default: '', desc: '线程 / 消息流的无障碍名称' },
|
|
346
|
+
anchor: { type: 'string', default: '', desc: '锚点评论 id:该评论画主色淡底并滚入视野' },
|
|
347
|
+
me_avatar: { type: 'string', default: '', desc: '发布框左侧头像(图片地址或首字母徽标文字;空时取 me 的首字母)' },
|
|
348
|
+
cancelable: { type: 'boolean', default: false, desc: '发布框底栏出「取消」钮(清空草稿并抛 cancel)' },
|
|
349
|
+
cancel_text: { type: 'string', default: '', desc: '取消钮文案' },
|
|
350
|
+
edit_text: { type: 'string', default: '', desc: '「更多」菜单的编辑项文案' },
|
|
351
|
+
delete_text: { type: 'string', default: '', desc: '「更多」菜单的删除项文案' },
|
|
352
|
+
deleted_text: { type: 'string', default: '', desc: '已删除评论的占位文案' },
|
|
353
|
+
edited_text: { type: 'string', default: '', desc: '已编辑标记文案' },
|
|
354
|
+
expand_replies_text: { type: 'string', default: '', desc: '展开回复钮文案(含 {n} 占位)' },
|
|
355
|
+
time_gap: { type: 'number', default: KIT_DATA_LIMITS.commentThread.timeGapMinutes, desc: 'chat 变体:相邻消息间隔超过该分钟数时出居中时间戳' },
|
|
136
356
|
max_length: { type: 'number', default: 500, desc: '发布框字数上限(不超过 kit-grammar#dataLimits.chat.maxLength)' },
|
|
137
357
|
placeholder: { type: 'string', default: '', desc: '发布框占位文案' },
|
|
138
358
|
send_text: { type: 'string', default: '', desc: '发表钮文案' },
|
|
@@ -148,10 +368,17 @@ export function createCommentThread(): SomaComponentDefinition {
|
|
|
148
368
|
reply: { payload: { id: { type: 'string' } }, desc: '点回复' },
|
|
149
369
|
like: { payload: { id: { type: 'string' } }, desc: '点赞(likable 时)' },
|
|
150
370
|
attach: { payload: {}, desc: '点附件钮(chat 变体且 attachable)' },
|
|
151
|
-
retry: { payload: { id: { type: 'string' }, item: { type: 'object' } }, desc: '点失败消息的重试(chat
|
|
371
|
+
retry: { payload: { id: { type: 'string' }, item: { type: 'object' } }, desc: '点失败消息的重试(chat 变体);错误条的重试(加载失败)抛 reload' },
|
|
372
|
+
reload: { payload: {}, desc: '加载失败错误条点重试' },
|
|
373
|
+
load_earlier: { payload: {}, desc: '点列表顶部「加载更早」' },
|
|
374
|
+
sort: { payload: { order: { type: 'string' } }, desc: '点线程头排序切换(asc / desc)' },
|
|
375
|
+
cancel: { payload: {}, desc: '点发布框「取消」' },
|
|
376
|
+
edit: { payload: { id: { type: 'string' } }, desc: '「更多」菜单选编辑' },
|
|
377
|
+
delete: { payload: { id: { type: 'string' } }, desc: '「更多」菜单选删除' },
|
|
152
378
|
},
|
|
153
379
|
},
|
|
154
|
-
|
|
380
|
+
// 评论属内容流:线程容器无框(plain),评论项靠间距分隔,不再卡中嵌卡
|
|
381
|
+
templateHtml: `<section${kitAttrHtml(KIT_ATTR_CONTAINER, 'plain')} data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
155
382
|
controllerFactory: createKitController(() => ({
|
|
156
383
|
attach(root, api) {
|
|
157
384
|
const submit = (): void => {
|
|
@@ -167,19 +394,57 @@ export function createCommentThread(): SomaComponentDefinition {
|
|
|
167
394
|
};
|
|
168
395
|
const onClick = (event: Event): void => {
|
|
169
396
|
const target = event.target as HTMLElement | null;
|
|
170
|
-
if (target?.closest(
|
|
171
|
-
if (target?.closest(
|
|
172
|
-
|
|
397
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_SEND))) { submit(); return; }
|
|
398
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_NEW))) {
|
|
399
|
+
const c = parts.get(root);
|
|
400
|
+
if (c) { c.list.scrollTop = c.list.scrollHeight; c.list.removeAttribute(KIT_ATTR_UNREAD); }
|
|
401
|
+
root.querySelector(kitAttrSel(KIT_ATTR_NEW))?.remove();
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_ATTACH))) { if (!bool(api.props().sending)) api.emit('attach', {}); return; }
|
|
405
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_RELOAD))) { api.emit('reload', {}); return; }
|
|
406
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_EARLIER))) { api.emit('load_earlier', {}); return; }
|
|
407
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_SORT))) {
|
|
408
|
+
const next = (root.getAttribute(KIT_ATTR_ORDER) ?? str(api.props().order, 'asc')) === 'asc' ? 'desc' : 'asc';
|
|
409
|
+
root.setAttribute(KIT_ATTR_ORDER, next);
|
|
410
|
+
api.emit('sort', { order: next });
|
|
411
|
+
api.refresh();
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (target?.closest(kitAttrSel(KIT_ATTR_CANCEL))) {
|
|
415
|
+
const c = parts.get(root);
|
|
416
|
+
if (c) { c.area.value = ''; syncComposer(c, api.props()); }
|
|
417
|
+
api.emit('cancel', {});
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
// 回复展开 / 收起:就地切 toggleKitHidden 与 aria-expanded,并跨重绘记住收起态
|
|
421
|
+
const fold = target?.closest<HTMLButtonElement>(kitAttrSel(KIT_ATTR_REPLIES_TOGGLE));
|
|
422
|
+
if (fold) {
|
|
423
|
+
// 面板 id 由回复键拼成(键来自业务数据,可含引号 / 反斜杠):转义后再进选择器;只在组件根内查
|
|
424
|
+
const panel = root.querySelector<HTMLElement>(`[id="${attrEsc(fold.getAttribute('aria-controls') ?? '')}"]`);
|
|
425
|
+
const open = fold.getAttribute('aria-expanded') !== 'true';
|
|
426
|
+
const replyKey = fold.getAttribute(KIT_ATTR_REPLIES_KEY) ?? '';
|
|
427
|
+
if (replyKey !== '') {
|
|
428
|
+
const set = collapsedOf(root);
|
|
429
|
+
if (open) set.delete(replyKey);
|
|
430
|
+
else set.add(replyKey);
|
|
431
|
+
}
|
|
432
|
+
fold.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
433
|
+
if (panel) toggleKitHidden(panel, !open);
|
|
434
|
+
fold.textContent = open ? kitText('soma.kit.collapse', undefined, root) : fold.getAttribute(KIT_ATTR_REPLIES_LABEL) ?? '';
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const retry = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_RETRY));
|
|
173
438
|
if (retry) {
|
|
174
439
|
const q = api.props();
|
|
175
|
-
const hit = commentEntriesOf(q.data, q.map, '', '', str(q.me)).find((x) => x.key === retry.getAttribute(
|
|
440
|
+
const hit = commentEntriesOf(q.data, q.map, '', '', str(q.me)).find((x) => x.key === retry.getAttribute(KIT_ATTR_RETRY));
|
|
176
441
|
if (hit) api.emit('retry', { id: hit.key, item: hit.raw });
|
|
177
442
|
return;
|
|
178
443
|
}
|
|
179
|
-
const reply = target?.closest<HTMLElement>(
|
|
180
|
-
if (reply) { api.emit('reply', { id: reply.getAttribute(
|
|
181
|
-
const like = target?.closest<HTMLElement>(
|
|
182
|
-
if (like) api.emit('like', { id: like.getAttribute(
|
|
444
|
+
const reply = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_REPLY));
|
|
445
|
+
if (reply) { api.emit('reply', { id: reply.getAttribute(KIT_ATTR_REPLY) ?? '' }); return; }
|
|
446
|
+
const like = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_LIKE));
|
|
447
|
+
if (like) api.emit('like', { id: like.getAttribute(KIT_ATTR_LIKE) ?? '' });
|
|
183
448
|
};
|
|
184
449
|
const onInput = (event: Event): void => {
|
|
185
450
|
const c = parts.get(root);
|
|
@@ -202,45 +467,160 @@ export function createCommentThread(): SomaComponentDefinition {
|
|
|
202
467
|
root.removeEventListener('click', onClick);
|
|
203
468
|
root.removeEventListener('input', onInput);
|
|
204
469
|
root.removeEventListener('keydown', onKey as EventListener);
|
|
470
|
+
for (const h of menus.get(root) ?? []) h();
|
|
471
|
+
menus.delete(root);
|
|
472
|
+
collapsedReplies.delete(root);
|
|
473
|
+
lastAnchors.delete(root);
|
|
205
474
|
parts.delete(root);
|
|
206
475
|
};
|
|
207
476
|
},
|
|
208
|
-
render(root, p) {
|
|
477
|
+
render(root, p, api) {
|
|
209
478
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
210
479
|
let c = parts.get(root);
|
|
211
480
|
if (!c) {
|
|
212
481
|
// 首绘:列表容器 + 发布框一次建好;之后只重画列表
|
|
213
482
|
const list = mk('div', LIST_CLASS);
|
|
214
|
-
list.setAttribute(
|
|
215
|
-
|
|
216
|
-
|
|
483
|
+
list.setAttribute(KIT_ATTR_LIST, '');
|
|
484
|
+
// 自己滚回底部附近 = 已读,清掉「新消息」钮
|
|
485
|
+
list.addEventListener('scroll', () => {
|
|
486
|
+
if (list.scrollHeight - list.scrollTop - list.clientHeight > list.clientHeight * CHAT_FOLLOW_RATIO) return;
|
|
487
|
+
list.removeAttribute(KIT_ATTR_UNREAD);
|
|
488
|
+
root.querySelector(kitAttrSel(KIT_ATTR_NEW))?.remove();
|
|
489
|
+
});
|
|
490
|
+
// 输入区 = 左头像 + 右(输入框 + 底栏):底栏左计数,右取消 + 发表(主钮最右);输入框随内容长高(行数随换行数增减)
|
|
491
|
+
const composer = mk('div', COMPOSER_ROW_CLASS);
|
|
492
|
+
composer.setAttribute(KIT_ATTR_COMPOSER, '');
|
|
493
|
+
const avatarSlot = mk('span', 'shrink-0');
|
|
494
|
+
avatarSlot.setAttribute(KIT_ATTR_COMPOSER_AVATAR, '');
|
|
495
|
+
const main = mk('div', COMPOSER_MAIN_CLASS);
|
|
217
496
|
const area = mk('textarea', INPUT_CLASS);
|
|
218
497
|
setKitFace(area, 'field');
|
|
219
|
-
area
|
|
498
|
+
kitMarkPart(area, 'control');
|
|
499
|
+
area.rows = COMPOSER_MIN_ROWS;
|
|
220
500
|
const foot = mk('div', COMPOSER_FOOT);
|
|
501
|
+
// 发布框底栏(计数 + 取消 / 发表)
|
|
502
|
+
kitMarkLevel(foot, 'foot'); kitApplyLevelClass(foot);
|
|
221
503
|
const counter = mk('span', COUNTER_CLASS);
|
|
222
|
-
const
|
|
223
|
-
send
|
|
224
|
-
send.
|
|
504
|
+
const actions = mk('div', COMPOSER_ACTIONS_CLASS);
|
|
505
|
+
const send = actionButton({ key: 'send', label: '', fn: 'submit', disabled: false, reason: '' });
|
|
506
|
+
send.removeAttribute(KIT_ATTR_ACTION);
|
|
507
|
+
send.setAttribute(KIT_ATTR_SEND, '');
|
|
508
|
+
actions.appendChild(send);
|
|
225
509
|
foot.appendChild(counter);
|
|
226
|
-
foot.appendChild(
|
|
227
|
-
|
|
228
|
-
|
|
510
|
+
foot.appendChild(actions);
|
|
511
|
+
main.appendChild(area);
|
|
512
|
+
main.appendChild(foot);
|
|
513
|
+
composer.appendChild(avatarSlot);
|
|
514
|
+
composer.appendChild(main);
|
|
229
515
|
root.textContent = '';
|
|
230
516
|
root.appendChild(list);
|
|
231
517
|
root.appendChild(composer);
|
|
232
|
-
c = { area, send, counter, list };
|
|
518
|
+
c = { area, send, counter, list, composer, avatarSlot, actions };
|
|
233
519
|
parts.set(root, c);
|
|
234
520
|
}
|
|
235
521
|
|
|
236
522
|
const chat = str(p.variant) === 'chat';
|
|
237
523
|
let entries = commentEntriesOf(p.data, p.map, str(p.time_format), str(p.locale), str(p.me));
|
|
524
|
+
// 数据状态:读失败(error 非空)> 加载 > 没有评论;只读(不画发布框)
|
|
525
|
+
kitMarkDataFacts(root, { error: str(p.error) !== '', loading: bool(p.loading), empty: entries.length === 0, readonly: bool(p.readonly) });
|
|
238
526
|
if (chat && entries.length > CHAT_MAX_MESSAGES) entries = entries.slice(entries.length - CHAT_MAX_MESSAGES);
|
|
239
527
|
const likable = bool(p.likable);
|
|
240
528
|
c.list.className = chat ? CHAT_LIST : LIST_CLASS;
|
|
241
529
|
if (p.show_list === false) c.list.remove(); else if (c.list.parentElement !== root) root.insertBefore(c.list, root.firstChild);
|
|
530
|
+
// 无障碍:消息流 = role=log + aria-live=polite(只播新增);评论流是列表;线程 / 消息流可命名
|
|
531
|
+
if (chat) {
|
|
532
|
+
c.list.setAttribute('role', 'log');
|
|
533
|
+
c.list.setAttribute('aria-live', 'polite');
|
|
534
|
+
c.list.setAttribute('aria-relevant', 'additions');
|
|
535
|
+
} else {
|
|
536
|
+
c.list.removeAttribute('role');
|
|
537
|
+
c.list.removeAttribute('aria-live');
|
|
538
|
+
c.list.removeAttribute('aria-relevant');
|
|
539
|
+
}
|
|
540
|
+
root.setAttribute('aria-label', str(p.aria_label, kitText('soma.kit.ct_thread', undefined, root)));
|
|
541
|
+
const prevScrollTop = c.list.scrollTop;
|
|
542
|
+
const prevScrollHeight = c.list.scrollHeight;
|
|
543
|
+
const prevClientHeight = c.list.clientHeight;
|
|
242
544
|
c.list.textContent = '';
|
|
243
|
-
|
|
545
|
+
// 菜单句柄随重绘销毁重建(不留悬挂的全局监听)
|
|
546
|
+
for (const h of menus.get(root) ?? []) h();
|
|
547
|
+
menus.set(root, []);
|
|
548
|
+
// 线程头(评论流):「评论 (N)」+ 排序切换;头在列表之前,随重绘重建
|
|
549
|
+
root.querySelector(kitAttrSel(KIT_ATTR_THREAD_HEAD))?.remove();
|
|
550
|
+
if (p.order !== root.getAttribute(KIT_ATTR_ORDER_GIVEN)) {
|
|
551
|
+
root.setAttribute(KIT_ATTR_ORDER_GIVEN, String(p.order ?? ''));
|
|
552
|
+
root.setAttribute(KIT_ATTR_ORDER, str(p.order, 'asc'));
|
|
553
|
+
}
|
|
554
|
+
const order = root.getAttribute(KIT_ATTR_ORDER) === 'desc' ? 'desc' : 'asc';
|
|
555
|
+
if (!chat) {
|
|
556
|
+
const sortable = bool(p.sortable);
|
|
557
|
+
if (sortable) {
|
|
558
|
+
entries = [...entries].sort((a, b) => ((a.ms ?? 0) - (b.ms ?? 0)) * (order === 'asc' ? 1 : -1));
|
|
559
|
+
}
|
|
560
|
+
if (bool(p.head) || sortable) {
|
|
561
|
+
const head = mk('div', THREAD_HEAD_CLASS);
|
|
562
|
+
head.setAttribute(KIT_ATTR_THREAD_HEAD, '');
|
|
563
|
+
// 线程头 = 面头,「评论 (N)」= 块标题
|
|
564
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
565
|
+
const headTitle = mk('span', THREAD_TITLE_CLASS, `${str(p.title, kitText('soma.kit.ct_title', undefined, root))} (${entries.length})`);
|
|
566
|
+
kitMarkPart(headTitle, 'block-title');
|
|
567
|
+
head.appendChild(headTitle);
|
|
568
|
+
if (sortable) {
|
|
569
|
+
const sort = mk('button', SORT_BUTTON_CLASS, kitText(order === 'asc' ? 'soma.kit.ct_oldest' : 'soma.kit.ct_newest', undefined, root));
|
|
570
|
+
sort.type = 'button';
|
|
571
|
+
sort.setAttribute(KIT_ATTR_SORT, order);
|
|
572
|
+
kitMarkPart(sort, 'action');
|
|
573
|
+
sort.prepend(kitIcon(order === 'asc' ? 'sort-asc' : 'sort-desc', 'xs'));
|
|
574
|
+
head.appendChild(sort);
|
|
575
|
+
}
|
|
576
|
+
root.insertBefore(head, c.list);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
// 加载 / 错误 / 加载更早
|
|
580
|
+
const reloading = bool(p.loading) && entries.length > 0;
|
|
581
|
+
if (reloading) c.list.setAttribute('aria-busy', 'true'); else c.list.removeAttribute('aria-busy');
|
|
582
|
+
if (str(p.error) !== '') {
|
|
583
|
+
const bar = mk('div', ERROR_BAR_CLASS);
|
|
584
|
+
bar.setAttribute('role', 'alert');
|
|
585
|
+
// 读失败提示块 = 子块
|
|
586
|
+
kitMarkLevel(bar, 'sub'); kitApplyLevelClass(bar);
|
|
587
|
+
bar.appendChild(mk('span', '', str(p.error)));
|
|
588
|
+
const retryText = str(p.retry_text);
|
|
589
|
+
if (retryText !== '') {
|
|
590
|
+
const rb = mk('button', ERROR_RETRY_CLASS, retryText);
|
|
591
|
+
rb.type = 'button';
|
|
592
|
+
rb.setAttribute(KIT_ATTR_RELOAD, '');
|
|
593
|
+
kitMarkPart(rb, 'action');
|
|
594
|
+
bar.appendChild(rb);
|
|
595
|
+
}
|
|
596
|
+
c.list.appendChild(bar);
|
|
597
|
+
}
|
|
598
|
+
if (bool(p.has_earlier) && entries.length > 0) {
|
|
599
|
+
const row = mk('div', LOAD_EARLIER_ROW_CLASS);
|
|
600
|
+
const eb = mk('button', LOAD_EARLIER_CLASS, str(p.earlier_text, kitText('soma.kit.ct_earlier', undefined, root)));
|
|
601
|
+
eb.type = 'button';
|
|
602
|
+
eb.setAttribute(KIT_ATTR_EARLIER, '');
|
|
603
|
+
kitMarkPart(eb, 'action');
|
|
604
|
+
row.appendChild(eb);
|
|
605
|
+
c.list.appendChild(row);
|
|
606
|
+
}
|
|
607
|
+
if (entries.length === 0 && bool(p.loading) && str(p.error) === '') {
|
|
608
|
+
// 加载骨架:头像圆 + 三行灰条,整体 role=status
|
|
609
|
+
const box = mk('div', LIST_CLASS);
|
|
610
|
+
box.setAttribute('role', 'status');
|
|
611
|
+
box.setAttribute('aria-busy', 'true');
|
|
612
|
+
box.setAttribute(KIT_ATTR_LOADING, '');
|
|
613
|
+
for (let i = 0; i < 2; i += 1) {
|
|
614
|
+
const row = mk('div', SKELETON_ROW_CLASS);
|
|
615
|
+
row.setAttribute('aria-hidden', 'true');
|
|
616
|
+
const lines = mk('div', SKELETON_LINES_CLASS);
|
|
617
|
+
lines.append(mk('div', KIT_SKELETON_BAR_TITLE_SUB), mk('div', KIT_SKELETON_BAR_LINE), mk('div', KIT_SKELETON_BAR_TITLE_MAIN));
|
|
618
|
+
row.append(mk('div', SKELETON_AVATAR_CLASS), lines);
|
|
619
|
+
box.appendChild(row);
|
|
620
|
+
}
|
|
621
|
+
box.prepend(mk('span', 'sr-only', kitText('soma.kit.processing', undefined, root)));
|
|
622
|
+
c.list.appendChild(box);
|
|
623
|
+
} else if (entries.length === 0) {
|
|
244
624
|
c.list.appendChild(emptyNode(str(p.empty_text, kitText(chat ? 'soma.kit.ct_empty_chat' : 'soma.kit.ct_empty_comment', undefined, root))));
|
|
245
625
|
}
|
|
246
626
|
if (chat) {
|
|
@@ -249,83 +629,222 @@ export function createCommentThread(): SomaComponentDefinition {
|
|
|
249
629
|
sent: str(p.sent_text, kitText('soma.kit.ct_sent', undefined, root)),
|
|
250
630
|
failed: str(p.failed_text, kitText('soma.kit.ct_failed', undefined, root)),
|
|
251
631
|
};
|
|
632
|
+
// 分组:同发送者连续消息成一组,只首条显头像与名;相邻消息间隔超过阈值才出居中时间戳
|
|
633
|
+
const gapMs = (num(p.time_gap) ?? TIME_GAP_MINUTES) * 60000;
|
|
634
|
+
let group: HTMLElement | null = null;
|
|
635
|
+
let prevEntry: KitCommentEntry | null = null;
|
|
252
636
|
for (const e of entries) {
|
|
637
|
+
const stamp = prevEntry === null || (e.ms !== null && prevEntry.ms !== null && e.ms - prevEntry.ms > gapMs);
|
|
638
|
+
if (stamp && e.time !== '') {
|
|
639
|
+
const st = mk('time', CHAT_STAMP, e.time);
|
|
640
|
+
st.setAttribute(KIT_ATTR_STAMP, '');
|
|
641
|
+
if (e.iso !== '') st.setAttribute('datetime', e.iso);
|
|
642
|
+
c.list.appendChild(st);
|
|
643
|
+
}
|
|
644
|
+
const sameSender = prevEntry !== null && !stamp && prevEntry.mine === e.mine && prevEntry.author === e.author;
|
|
645
|
+
if (group === null || !sameSender) {
|
|
646
|
+
group = mk('div', CHAT_GROUP);
|
|
647
|
+
group.setAttribute(KIT_ATTR_GROUP, '');
|
|
648
|
+
c.list.appendChild(group);
|
|
649
|
+
}
|
|
650
|
+
prevEntry = e;
|
|
253
651
|
const row = mk('div', e.mine ? `${CHAT_MSG} ${CHAT_MSG_MINE}` : CHAT_MSG);
|
|
254
|
-
row.setAttribute(
|
|
255
|
-
row.setAttribute(
|
|
256
|
-
|
|
652
|
+
row.setAttribute(KIT_ATTR_COMMENT, e.key);
|
|
653
|
+
row.setAttribute(KIT_ATTR_SIDE, e.mine ? 'me' : 'them');
|
|
654
|
+
// 每条消息 = 集合条目
|
|
655
|
+
kitMarkLevel(row, 'item', 'line'); kitApplyLevelClass(row);
|
|
656
|
+
if (!e.mine) row.appendChild(sameSender ? mk('span', CHAT_AVATAR_GAP) : avatarNode(e.author, e.avatar, 'md'));
|
|
257
657
|
const col = mk('div', e.mine ? `${CHAT_COL} ${CHAT_COL_MINE}` : CHAT_COL);
|
|
258
|
-
if (!e.mine && e.author !== '') col.appendChild(mk('span', CHAT_NAME, e.author));
|
|
658
|
+
if (!e.mine && !sameSender && e.author !== '') col.appendChild(mk('span', CHAT_NAME, e.author));
|
|
259
659
|
col.appendChild(mk('p', `${CHAT_BUBBLE} ${e.mine ? CHAT_ME : CHAT_THEM}`, e.text));
|
|
260
|
-
if (e.
|
|
660
|
+
if (e.status !== '') {
|
|
661
|
+
// 时间戳已按组出,消息自带的只有状态:发送中 = 转圈图标、已发送 / 已读 = 对勾、失败 = 文字 + 重试
|
|
261
662
|
const meta = mk('div', e.status === 'failed' ? CHAT_META_FAILED : CHAT_META);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
st.
|
|
663
|
+
{
|
|
664
|
+
const st = mk('span', CHAT_STATUS_ICON);
|
|
665
|
+
if (e.status !== 'failed') st.appendChild(kitIcon(e.status === 'sending' ? 'loading' : 'check', 'xs'));
|
|
666
|
+
st.appendChild(document.createTextNode(statusText[e.status] ?? ''));
|
|
667
|
+
st.setAttribute(KIT_ATTR_STATUS, e.status);
|
|
266
668
|
meta.appendChild(st);
|
|
267
669
|
}
|
|
268
670
|
if (e.status === 'failed') {
|
|
269
671
|
const retry = mk('button', CHAT_RETRY, str(p.retry_text, kitText('soma.kit.ct_retry', undefined, root)));
|
|
270
672
|
retry.type = 'button';
|
|
271
|
-
retry.setAttribute(
|
|
673
|
+
retry.setAttribute(KIT_ATTR_RETRY, e.key);
|
|
674
|
+
kitMarkPart(retry, 'action');
|
|
272
675
|
meta.appendChild(retry);
|
|
273
676
|
}
|
|
274
677
|
col.appendChild(meta);
|
|
275
678
|
}
|
|
276
679
|
row.appendChild(col);
|
|
277
|
-
|
|
680
|
+
group.appendChild(row);
|
|
681
|
+
}
|
|
682
|
+
// 流式追加:新消息只追加在底部。在底部附近(距底不超过半屏)、是自己发的、或首次有消息 → 跟到底;
|
|
683
|
+
// 否则不动滚动位置,累计未读数,出「N 条新消息」钮(点它或自己滚回底部即清)
|
|
684
|
+
const prev = Number(c.list.getAttribute(KIT_ATTR_COUNT) ?? '0');
|
|
685
|
+
const pill = (): HTMLButtonElement | null => root.querySelector<HTMLButtonElement>(kitAttrSel(KIT_ATTR_NEW));
|
|
686
|
+
if (entries.length > prev) {
|
|
687
|
+
const last = entries[entries.length - 1]!;
|
|
688
|
+
const gap = prev > 0 ? prevScrollHeight - prevScrollTop - prevClientHeight : 0;
|
|
689
|
+
if (prev === 0 || last.mine || gap <= prevClientHeight * CHAT_FOLLOW_RATIO) {
|
|
690
|
+
c.list.scrollTop = c.list.scrollHeight;
|
|
691
|
+
c.list.removeAttribute(KIT_ATTR_UNREAD);
|
|
692
|
+
pill()?.remove();
|
|
693
|
+
} else {
|
|
694
|
+
c.list.scrollTop = prevScrollTop;
|
|
695
|
+
const unread = Number(c.list.getAttribute(KIT_ATTR_UNREAD) ?? '0') + entries.length - prev;
|
|
696
|
+
c.list.setAttribute(KIT_ATTR_UNREAD, String(unread));
|
|
697
|
+
let btn = pill();
|
|
698
|
+
if (!btn) {
|
|
699
|
+
btn = mk('button', CHAT_NEW);
|
|
700
|
+
btn.type = 'button';
|
|
701
|
+
btn.setAttribute(KIT_ATTR_NEW, '');
|
|
702
|
+
c.list.insertAdjacentElement('afterend', btn);
|
|
703
|
+
}
|
|
704
|
+
btn.textContent = kitText('soma.kit.ct_new', { n: unread }, root);
|
|
705
|
+
}
|
|
706
|
+
} else {
|
|
707
|
+
c.list.scrollTop = prevScrollTop;
|
|
278
708
|
}
|
|
279
|
-
|
|
280
|
-
if (entries.length > prev) c.list.scrollTop = c.list.scrollHeight;
|
|
281
|
-
c.list.setAttribute('data-kit-count', String(entries.length));
|
|
709
|
+
c.list.setAttribute(KIT_ATTR_COUNT, String(entries.length));
|
|
282
710
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
item
|
|
287
|
-
|
|
288
|
-
item.
|
|
711
|
+
// 评论项(无框:内容流靠间距分隔,不嵌卡):meta 行(作者 / 角色标签 / 时间 / 已编辑)、正文(含 @提及)、动作行(回复 · 赞 · 更多)、一级回复
|
|
712
|
+
const anchorId = str(p.anchor);
|
|
713
|
+
const renderComment = (e: KitCommentEntry, nested: boolean): HTMLElement => {
|
|
714
|
+
const item = mk('article', anchorId === e.key ? `${ITEM_CLASS} ${ANCHOR_CLASS}` : ITEM_CLASS);
|
|
715
|
+
item.setAttribute(KIT_ATTR_CONTAINER, ''); // 评论项无框(内容流靠间距):显式声明无外观(D-08,容器外观只认声明,不按标签名画框)
|
|
716
|
+
item.setAttribute(KIT_ATTR_COMMENT, e.key);
|
|
717
|
+
// 每条评论(含一级回复)= 集合条目
|
|
718
|
+
kitMarkLevel(item, 'item', 'line'); kitApplyLevelClass(item);
|
|
719
|
+
if (nested) item.setAttribute(KIT_ATTR_REPLY_OF, e.parent);
|
|
720
|
+
if (anchorId === e.key) item.setAttribute(KIT_ATTR_ANCHOR, '');
|
|
721
|
+
// 头像与 chat 变体同一个 avatarNode:地址只认 http(s) / 站内相对 / data:image,其余退回首字母徽标(回复层 24)
|
|
722
|
+
item.appendChild(avatarNode(e.author, e.avatar, nested ? 'sm' : 'md'));
|
|
289
723
|
const body = mk('div', BODY_CLASS);
|
|
290
724
|
const head = mk('div', HEAD_CLASS);
|
|
291
|
-
|
|
292
|
-
|
|
725
|
+
const author = mk('span', AUTHOR_CLASS, e.author);
|
|
726
|
+
kitMarkPart(author, 'field-name');
|
|
727
|
+
head.appendChild(author);
|
|
728
|
+
if (e.role !== '') head.appendChild(mk('span', ROLE_TAG_CLASS, e.role));
|
|
729
|
+
if (e.time !== '') {
|
|
730
|
+
const t = mk('time', TIME_CLASS, e.time);
|
|
731
|
+
if (e.iso !== '') t.setAttribute('datetime', e.iso);
|
|
732
|
+
head.appendChild(t);
|
|
733
|
+
}
|
|
734
|
+
if (e.edited !== '' && !e.deleted) {
|
|
735
|
+
const ed = mk('span', EDITED_CLASS, str(p.edited_text, kitText('soma.kit.ct_edited', undefined, root)));
|
|
736
|
+
ed.setAttribute(KIT_ATTR_EDITED, '');
|
|
737
|
+
if (e.edited !== '1') ed.title = e.edited;
|
|
738
|
+
head.appendChild(ed);
|
|
739
|
+
}
|
|
293
740
|
body.appendChild(head);
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
741
|
+
if (e.deleted) {
|
|
742
|
+
// 已删除:弱化占位,保留回复结构,无正文无动作
|
|
743
|
+
const gone = mk('p', DELETED_CLASS, str(p.deleted_text, kitText('soma.kit.ct_deleted', undefined, root)));
|
|
744
|
+
gone.setAttribute(KIT_ATTR_DELETED, '');
|
|
745
|
+
body.appendChild(gone);
|
|
746
|
+
} else {
|
|
747
|
+
const text = mk('p', TEXT_CLASS);
|
|
748
|
+
kitMarkPart(text, 'value');
|
|
749
|
+
for (const [part, mention] of splitMentions(e.text)) {
|
|
750
|
+
if (mention) { const mn = mk('span', MENTION_CLASS, part); mn.setAttribute(KIT_ATTR_MENTION, part.slice(1)); text.appendChild(mn); }
|
|
751
|
+
else text.appendChild(document.createTextNode(part));
|
|
752
|
+
}
|
|
753
|
+
body.appendChild(text);
|
|
754
|
+
const acts = mk('div', ROW_ACTIONS);
|
|
755
|
+
const reply = mk('button', LINK_BUTTON, str(p.reply_text, kitText('soma.kit.ct_reply', undefined, root)));
|
|
756
|
+
reply.type = 'button';
|
|
757
|
+
reply.setAttribute(KIT_ATTR_REPLY, e.key);
|
|
758
|
+
kitMarkPart(reply, 'action');
|
|
759
|
+
acts.appendChild(reply);
|
|
760
|
+
if (likable) {
|
|
761
|
+
const like = mk('button', LIKE_BUTTON_CLASS, `${str(p.like_text, kitText('soma.kit.ct_like', undefined, root))}${e.likes !== null ? ` ${e.likes}` : ''}`);
|
|
762
|
+
like.type = 'button';
|
|
763
|
+
like.setAttribute(KIT_ATTR_LIKE, e.key);
|
|
764
|
+
kitMarkPart(like, 'action');
|
|
765
|
+
acts.appendChild(like);
|
|
766
|
+
}
|
|
767
|
+
// 编辑 / 删除收进「更多」菜单(删除置末,危险项)
|
|
768
|
+
if (e.canEdit || e.canDelete) acts.appendChild(moreMenu(root, e, p, (key) => api.emit(key, { id: e.key })));
|
|
769
|
+
body.appendChild(acts);
|
|
305
770
|
}
|
|
306
|
-
body.appendChild(acts);
|
|
307
771
|
item.appendChild(body);
|
|
772
|
+
return item;
|
|
773
|
+
};
|
|
774
|
+
const collapsed = collapsedOf(root);
|
|
775
|
+
for (const node of chat ? [] : commentTreeOf(entries)) {
|
|
776
|
+
const item = renderComment(node.entry, false);
|
|
777
|
+
if (node.replies.length > 0) {
|
|
778
|
+
// 回复嵌一级(缩进 = 头像宽 + 间距);「展开 N 条回复」可收起 / 展开,缺省展开,跨重绘保持收起态
|
|
779
|
+
const body = item.lastElementChild as HTMLElement;
|
|
780
|
+
const panelId = `soma-replies-${node.entry.key}`;
|
|
781
|
+
const open = !collapsed.has(node.entry.key);
|
|
782
|
+
const label = str(p.expand_replies_text, kitText('soma.kit.ct_replies_n', undefined, root)).replace('{n}', String(node.replies.length));
|
|
783
|
+
const toggle = mk('button', REPLY_TOGGLE_CLASS, open ? kitText('soma.kit.collapse', undefined, root) : label);
|
|
784
|
+
toggle.type = 'button';
|
|
785
|
+
toggle.setAttribute(KIT_ATTR_REPLIES_TOGGLE, '');
|
|
786
|
+
kitMarkPart(toggle, 'action');
|
|
787
|
+
toggle.setAttribute(KIT_ATTR_REPLIES_KEY, node.entry.key);
|
|
788
|
+
toggle.setAttribute(KIT_ATTR_REPLIES_LABEL, label);
|
|
789
|
+
toggle.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
790
|
+
toggle.setAttribute('aria-controls', panelId);
|
|
791
|
+
const replies = mk('div', REPLIES_CLASS);
|
|
792
|
+
replies.id = panelId;
|
|
793
|
+
replies.setAttribute(KIT_ATTR_REPLIES, '');
|
|
794
|
+
// 嵌在评论里的回复串 = 子块
|
|
795
|
+
kitMarkLevel(replies, 'sub'); kitApplyLevelClass(replies);
|
|
796
|
+
toggleKitHidden(replies, !open);
|
|
797
|
+
for (const r of node.replies) replies.appendChild(renderComment(r, true));
|
|
798
|
+
body.append(toggle, replies);
|
|
799
|
+
}
|
|
308
800
|
c.list.appendChild(item);
|
|
309
801
|
}
|
|
802
|
+
if (!chat) {
|
|
803
|
+
c.list.scrollTop = prevScrollTop;
|
|
804
|
+
}
|
|
805
|
+
if (anchorId === '') {
|
|
806
|
+
lastAnchors.delete(root);
|
|
807
|
+
} else if (lastAnchors.get(root) !== anchorId) {
|
|
808
|
+
const anchorEl = c.list.querySelector<HTMLElement>(kitAttrSel(KIT_ATTR_ANCHOR));
|
|
809
|
+
if (anchorEl) {
|
|
810
|
+
lastAnchors.set(root, anchorId);
|
|
811
|
+
anchorEl.scrollIntoView?.({ block: 'nearest' });
|
|
812
|
+
}
|
|
813
|
+
}
|
|
310
814
|
|
|
311
|
-
const composer = c.
|
|
815
|
+
const composer = c.composer;
|
|
312
816
|
if (bool(p.readonly)) {
|
|
313
817
|
composer.remove();
|
|
314
818
|
} else if (composer.parentElement !== root) {
|
|
315
819
|
root.appendChild(composer);
|
|
316
820
|
}
|
|
821
|
+
// 输入区头像:当前用户(me 名首字母 / me_avatar 图片)
|
|
822
|
+
c.avatarSlot.textContent = '';
|
|
823
|
+
c.avatarSlot.appendChild(avatarNode(str(p.me) !== '' ? str(p.me) : '?', str(p.me_avatar), 'md'));
|
|
824
|
+
// 取消钮:cancelable 才有,插在发表钮前(主钮最右)
|
|
825
|
+
let cancel = c.actions.querySelector<HTMLButtonElement>(kitAttrSel(KIT_ATTR_CANCEL));
|
|
826
|
+
if (bool(p.cancelable)) {
|
|
827
|
+
if (!cancel) {
|
|
828
|
+
cancel = mk('button', CANCEL_BUTTON_CLASS);
|
|
829
|
+
cancel.type = 'button';
|
|
830
|
+
cancel.setAttribute(KIT_ATTR_CANCEL, '');
|
|
831
|
+
kitMarkPart(cancel, 'action');
|
|
832
|
+
c.actions.insertBefore(cancel, c.actions.firstChild);
|
|
833
|
+
}
|
|
834
|
+
cancel.textContent = str(p.cancel_text, kitText('soma.kit.cancel', undefined, root));
|
|
835
|
+
} else if (cancel) cancel.remove();
|
|
317
836
|
c.area.placeholder = str(p.placeholder, kitText('soma.kit.ct_placeholder', undefined, root));
|
|
318
837
|
// maxLength 为 0 会让文本框一个字也输不进,负数直接抛 IndexSizeError:上限非正 = 不限;chat 受真源上限约束
|
|
319
838
|
const maxLen = num(p.max_length) ?? 500;
|
|
320
839
|
if (maxLen > 0) c.area.maxLength = Math.floor(Math.min(maxLen, CHAT_MAX_LENGTH)); else c.area.removeAttribute('maxlength');
|
|
321
840
|
// 附件钮:chat 变体且 attachable 才有,插在发送钮前
|
|
322
|
-
let attach = c.send.parentElement?.querySelector<HTMLButtonElement>(
|
|
841
|
+
let attach = c.send.parentElement?.querySelector<HTMLButtonElement>(kitAttrSel(KIT_ATTR_ATTACH)) ?? null;
|
|
323
842
|
if (chat && bool(p.attachable)) {
|
|
324
843
|
if (!attach) {
|
|
325
844
|
attach = mk('button', CHAT_ATTACH);
|
|
326
845
|
attach.type = 'button';
|
|
327
846
|
setKitFace(attach, 'raised');
|
|
328
|
-
attach.setAttribute(
|
|
847
|
+
attach.setAttribute(KIT_ATTR_ATTACH, '');
|
|
329
848
|
c.send.parentElement?.insertBefore(attach, c.send);
|
|
330
849
|
}
|
|
331
850
|
attach.textContent = str(p.attach_text, kitText('soma.kit.ct_attach', undefined, root));
|
|
@@ -340,6 +859,7 @@ export function createCommentThread(): SomaComponentDefinition {
|
|
|
340
859
|
}
|
|
341
860
|
|
|
342
861
|
function syncComposer(c: Composer, p: Record<string, unknown>): void {
|
|
862
|
+
c.area.rows = composerRowsOf(c.area.value);
|
|
343
863
|
const sending = bool(p.sending);
|
|
344
864
|
const max = num(p.max_length) ?? 500;
|
|
345
865
|
c.area.disabled = sending;
|