soma-kit 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
package/src/data/calendar.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Calendar:月 /
|
|
1
|
+
// Calendar:月 / 周 / 日视图日程(disabled_dates 置灰不可选,loading 保留格线换骨架)(layer: data,写死形状,accept: list)。
|
|
2
2
|
//
|
|
3
3
|
// 数据:`data` 是事件行 [{ id, title, date, end?, time?, tone? }];`end` 非空时跨天(含首尾日)。键名可由 `map` 改写。
|
|
4
4
|
// 视图(month / week)、锚点月 / 周、选中日是组件内状态(只在一个组件内流转),`view` / `month` / `selected` prop 只在自己变化时覆盖内部值。
|
|
@@ -6,53 +6,199 @@
|
|
|
6
6
|
// 网格键盘走 core 键盘接线的日期网格:方向键逐日 / 逐周,Home / End 本周首末,PageUp / PageDown 翻月,Shift+PageUp / PageDown 翻年,Enter / Space 选中该日。
|
|
7
7
|
// 事件:点日期格(或 Enter)抛 `date { date, events }`;点事件块抛 `event { id, item }`;翻页 / 切视图抛 `navigate { view, anchor, from, to }`(from / to = 可见区间首末日,页面据此取数)。
|
|
8
8
|
|
|
9
|
+
import { kitApplyLevelClass } from './level-class';
|
|
9
10
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
11
|
+
import { kitHasProps, kitMarkDataFacts, kitMarkLevel, kitMarkPart, kitMarkPicked } from './kit-contract';
|
|
10
12
|
import { createKeyboardWiring, type CollectionItem } from 'soma-core/keyboard';
|
|
11
13
|
import { SOMA_SIZE_UNITS } from 'soma-foundation/theme';
|
|
12
|
-
import { createKitController, joinClass, num, str } from '../base/shared';
|
|
14
|
+
import { bool, createKitController, joinClass, num, reconcileKeyedElements, str } from '../base/shared';
|
|
15
|
+
import { disabledRulesOf, isDateDisabled } from '../base/date';
|
|
16
|
+
import {
|
|
17
|
+
handoffTab, KIT_DROPDOWN_CLASS_CANDIDATES, KIT_DROPDOWN_PORTAL_CLASS_CANDIDATES,
|
|
18
|
+
onOutsidePress, PANEL_BASE_CLASS, PANEL_HIDDEN_CLASS, releaseDropdown, syncDropdown,
|
|
19
|
+
} from '../base/popup';
|
|
20
|
+
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS, KIT_STATE_PANEL_CLASS_CANDIDATES } from '../base/state-panel';
|
|
21
|
+
import { KIT_SKELETON_BAR_LINE } from '../recipes/placeholder';
|
|
13
22
|
import { kitText } from '../i18n/kit-text';
|
|
14
23
|
import { setKitFace } from '../recipes';
|
|
24
|
+
import { KIT_FOCUS_RING, kitSelectedRecipe, kitTonalFillRecipe } from '../recipes/state';
|
|
25
|
+
import { kitFieldNameRecipe } from '../recipes/field-text';
|
|
15
26
|
import { classTokens, keyMap, mk, rowsOf, shapeToneOf, textOf, TONE_SOFT, type Rec } from './shape-util';
|
|
16
|
-
import { monthGridCells, monthGridRange, monthGridStep, weekdayHeads, type MonthGridRange } from '../base/month-grid';
|
|
27
|
+
import { monthGridCells, monthGridRange, monthGridStep, weekdayHeads, ymdOfDayNum, type MonthGridRange } from '../base/month-grid';
|
|
17
28
|
import { markKitEdge } from '../recipes/surface-edge';
|
|
18
29
|
import { kitEmphasisButtonRecipe } from '../recipes/emphasis';
|
|
19
30
|
import { kitTypographyRecipe } from '../recipes/typography';
|
|
20
|
-
import { mergeClass } from '../
|
|
31
|
+
import { mergeClass } from '../shared/merge-class';
|
|
32
|
+
import { KIT_COLOR_ROLE_CLASS_CANDIDATES, kitReadHostAutoSequence, kitResolveStatusOrCategoryTone, kitToneSoftBadgeClass } from '../recipes/color-role';
|
|
33
|
+
import { kitShellRecipe } from '../recipes/container';
|
|
34
|
+
import { kitDividerRecipe } from '../recipes/divider';
|
|
35
|
+
import { kitWellRecipe } from '../recipes/surface';
|
|
36
|
+
import {
|
|
37
|
+
KIT_ATTR_CAL_SPAN, KIT_ATTR_CALENDAR_POPOVER, KIT_ATTR_CONTAINER, KIT_ATTR_DATE, KIT_ATTR_EVENT, KIT_ATTR_MORE, KIT_ATTR_NAV, KIT_ATTR_SELECTED,
|
|
38
|
+
KIT_ATTR_SLOT_SPACER, KIT_ATTR_VIEW, kitAttrHtml, kitAttrSel,
|
|
39
|
+
} from '../shared/dom-attrs';
|
|
21
40
|
import {
|
|
22
41
|
addMonths, anchorOf, attrEsc, dayNumOf, monthTitle, rowKey, textOfDayNum, timeTail, weekdayOfDayNum,
|
|
23
42
|
} from './d9-util';
|
|
24
43
|
|
|
25
44
|
export const KIT_CALENDAR_DEFAULT_MAP = Object.freeze({ id: 'id', title: 'title', date: 'date', end: 'end', time: 'time', tone: 'tone' });
|
|
26
45
|
|
|
27
|
-
export type KitCalendarView = 'month' | 'week';
|
|
46
|
+
export type KitCalendarView = 'month' | 'week' | 'day';
|
|
47
|
+
const CALENDAR_VIEWS: readonly KitCalendarView[] = Object.freeze(['month', 'week', 'day']);
|
|
48
|
+
|
|
49
|
+
/** 可见区间:月 / 周走共享月格,日视图只有锚点当天一格 */
|
|
50
|
+
function viewRangeOf(view: KitCalendarView, anchor: number, weekStart: number): MonthGridRange {
|
|
51
|
+
return view === 'day' ? { from: anchor, to: anchor, weeks: [[anchor]] } : monthGridRange(view, anchor, weekStart);
|
|
52
|
+
}
|
|
28
53
|
|
|
29
|
-
const ROOT_CLASS = 'flex flex-col gap-3 text
|
|
30
|
-
const HEAD_CLASS = 'flex flex-wrap items-center gap-2';
|
|
31
|
-
const
|
|
54
|
+
const ROOT_CLASS = mergeClass('flex w-full min-w-0 flex-col gap-3', kitTypographyRecipe('text'));
|
|
55
|
+
const HEAD_CLASS = 'flex min-w-0 flex-wrap items-center gap-2 px-4';
|
|
56
|
+
const VIEW_GROUP_CLASS = 'inline-flex items-center gap-1';
|
|
57
|
+
const TITLE_CLASS = mergeClass('min-w-24 tabular-nums tracking-tight', kitTypographyRecipe('sectionTitle'));
|
|
32
58
|
const SPACER_CLASS = 'flex-1';
|
|
59
|
+
const ROUND_ITEM = 'rounded-item';
|
|
60
|
+
const BORDER_PRIMARY = 'border border-primary';
|
|
33
61
|
const BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
34
|
-
const BTN_ON_CLASS =
|
|
35
|
-
const GRID_CLASS = 'flex flex-col overflow-hidden
|
|
36
|
-
const ROW_CLASS = 'grid grid-cols-7
|
|
37
|
-
const
|
|
38
|
-
const
|
|
62
|
+
const BTN_ON_CLASS = mergeClass(mergeClass(BTN_CLASS, BORDER_PRIMARY), kitSelectedRecipe());
|
|
63
|
+
const GRID_CLASS = mergeClass('flex w-full min-w-0 flex-col overflow-hidden', kitShellRecipe({ tone: 'base', shadow: false }));
|
|
64
|
+
const ROW_CLASS = 'grid grid-cols-7';
|
|
65
|
+
const ROW_DAY_CLASS = 'grid grid-cols-1';
|
|
66
|
+
const ROW_BORDER = kitDividerRecipe('top');
|
|
67
|
+
// 禁用日:禁用令牌字色 + 禁用光标,不可选
|
|
68
|
+
const CELL_DISABLED = 'cursor-not-allowed text-fg-disabled';
|
|
69
|
+
// 周头 = 列头 = 字段名出口(F7:弱化墨 14 / 500,无底)
|
|
70
|
+
const HEADCELL_CLASS = mergeClass('px-2 py-1.5 text-center', kitFieldNameRecipe());
|
|
39
71
|
// 网格外层 overflow-hidden 会把外扩的焦点环切掉,格子与事件块的焦点环一律画在里面(ring-inset)
|
|
40
|
-
const CELL_CLASS =
|
|
72
|
+
const CELL_CLASS = mergeClass(
|
|
73
|
+
'flex min-w-0 min-h-22 flex-col gap-1 p-1.5 text-start transition-colors hover:bg-state-layer-hover active:bg-state-layer-press',
|
|
74
|
+
KIT_FOCUS_RING.item,
|
|
75
|
+
);
|
|
41
76
|
const CELL_WEEK = 'min-h-48';
|
|
42
|
-
const CELL_BORDER = '
|
|
43
|
-
const CELL_OUT = '
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
77
|
+
const CELL_BORDER = kitDividerRecipe('start');
|
|
78
|
+
const CELL_OUT = mergeClass('text-fg-subtle', kitWellRecipe());
|
|
79
|
+
// 日号在格内右上;选中日 = 日号块走选中出口(条目圆角),今天 = 主色细描边环 + 柔和主色淡底(与选中不冲突)
|
|
80
|
+
const DAYHEAD_CLASS = 'flex justify-end';
|
|
81
|
+
const DAYNUM_CLASS = mergeClass('inline-flex size-6 items-center justify-center tabular-nums text-sm font-medium transition-colors', ROUND_ITEM);
|
|
82
|
+
const DAYNUM_TODAY = mergeClass(mergeClass(BORDER_PRIMARY, kitTonalFillRecipe()), 'text-primary-on-soft');
|
|
83
|
+
const DAYNUM_SELECTED = kitSelectedRecipe();
|
|
84
|
+
// 跨天连续横条与单日胶囊:单日完整圆角 w-full;跨天首日左圆右平外延右内边距,中间日左右平直贯通,末日左平右圆外延左内边距
|
|
85
|
+
const EVENT_BASE_CLASS = mergeClass('block min-w-0 truncate px-1.5 py-0.5 text-start text-xs tabular-nums transition-colors hover:opacity-80', KIT_FOCUS_RING.item);
|
|
86
|
+
const EVENT_CLASS = mergeClass(mergeClass('w-full', EVENT_BASE_CLASS), ROUND_ITEM);
|
|
87
|
+
const EVENT_SPAN_START = 'rounded-s-item -me-1.5';
|
|
88
|
+
const EVENT_SPAN_MID = '-mx-1.5';
|
|
89
|
+
const EVENT_SPAN_END = 'rounded-e-item -ms-1.5';
|
|
90
|
+
const SLOT_SPACER_CLASS = 'pointer-events-none invisible block min-h-5';
|
|
91
|
+
const MORE_CLASS = mergeClass('px-1.5', kitTypographyRecipe('captionPlain'));
|
|
92
|
+
const MORE_BTN_CLASS = mergeClass(mergeClass(mergeClass('inline-flex items-center self-start py-0.5 text-start transition-colors hover:bg-state-layer-hover hover:text-fg', MORE_CLASS), ROUND_ITEM), KIT_FOCUS_RING.item);
|
|
93
|
+
const AGENDA_POP_CLASS = mergeClass(PANEL_BASE_CLASS, 'flex max-h-64 min-w-48 max-w-72 flex-col gap-1 overflow-y-auto p-2');
|
|
94
|
+
const AGENDA_HEAD_CLASS = mergeClass('flex items-center justify-between gap-2 px-1 pb-1 tabular-nums', kitFieldNameRecipe());
|
|
95
|
+
|
|
96
|
+
const CALENDAR_AUTO_TONE_CANDIDATES: string = (
|
|
97
|
+
['neutral', 'primary', 'info', 'success', 'warning', 'danger', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8'] as const
|
|
98
|
+
).map((t) => kitToneSoftBadgeClass(t)).join(' ');
|
|
50
99
|
|
|
51
100
|
export const KIT_CALENDAR_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
52
|
-
ROOT_CLASS, HEAD_CLASS, TITLE_CLASS, SPACER_CLASS, BTN_CLASS, BTN_ON_CLASS, GRID_CLASS, ROW_CLASS, ROW_BORDER, HEADCELL_CLASS,
|
|
53
|
-
CELL_CLASS, CELL_WEEK, CELL_BORDER, CELL_OUT,
|
|
101
|
+
ROOT_CLASS, HEAD_CLASS, VIEW_GROUP_CLASS, TITLE_CLASS, SPACER_CLASS, BTN_CLASS, BTN_ON_CLASS, GRID_CLASS, ROW_CLASS, ROW_BORDER, HEADCELL_CLASS,
|
|
102
|
+
ROW_DAY_CLASS, CELL_DISABLED, KIT_SKELETON_BAR_LINE, CELL_CLASS, CELL_WEEK, CELL_BORDER, CELL_OUT, DAYHEAD_CLASS, DAYNUM_CLASS, DAYNUM_TODAY, DAYNUM_SELECTED,
|
|
103
|
+
EVENT_BASE_CLASS, EVENT_CLASS, EVENT_SPAN_START, EVENT_SPAN_MID, EVENT_SPAN_END, SLOT_SPACER_CLASS,
|
|
104
|
+
MORE_CLASS, MORE_BTN_CLASS, AGENDA_POP_CLASS, AGENDA_HEAD_CLASS, PANEL_HIDDEN_CLASS,
|
|
105
|
+
Object.values(TONE_SOFT), CALENDAR_AUTO_TONE_CANDIDATES, KIT_COLOR_ROLE_CLASS_CANDIDATES,
|
|
106
|
+
KIT_DROPDOWN_CLASS_CANDIDATES, KIT_DROPDOWN_PORTAL_CLASS_CANDIDATES, KIT_STATE_PANEL_CLASS_CANDIDATES,
|
|
54
107
|
);
|
|
55
108
|
|
|
109
|
+
/** 挂载「+N」当日议程弹出浮层(关闭态不驻留格内 DOM 以免污染格内 textContent 与 [data-kit-event] 计数;展开态经 syncDropdown 门户定位) */
|
|
110
|
+
function wirePopLayer(trigger: HTMLButtonElement, panel: HTMLElement): { close: (restoreFocus?: boolean) => void; destroy: () => void } {
|
|
111
|
+
let open = false;
|
|
112
|
+
panel.className = PANEL_HIDDEN_CLASS;
|
|
113
|
+
trigger.setAttribute('aria-haspopup', 'dialog');
|
|
114
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
115
|
+
const setOpen = (next: boolean, restoreFocus = false): void => {
|
|
116
|
+
if (open === next) return;
|
|
117
|
+
open = next;
|
|
118
|
+
trigger.setAttribute('aria-expanded', open ? 'true' : 'false');
|
|
119
|
+
if (open) {
|
|
120
|
+
if (!panel.isConnected) trigger.ownerDocument.body.appendChild(panel);
|
|
121
|
+
syncDropdown(panel, true, AGENDA_POP_CLASS, trigger, 'start');
|
|
122
|
+
} else {
|
|
123
|
+
syncDropdown(panel, false, AGENDA_POP_CLASS, trigger, 'start');
|
|
124
|
+
releaseDropdown(panel);
|
|
125
|
+
panel.remove();
|
|
126
|
+
if (restoreFocus) trigger.focus();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const offOutside = onOutsidePress(trigger, () => open, () => setOpen(false), (node) => panel.contains(node));
|
|
130
|
+
const onTriggerClick = (ev: Event): void => {
|
|
131
|
+
ev.stopPropagation();
|
|
132
|
+
setOpen(!open);
|
|
133
|
+
};
|
|
134
|
+
const onTriggerKeydown = (ev: KeyboardEvent): void => {
|
|
135
|
+
if (ev.key === 'Escape' && open) {
|
|
136
|
+
ev.preventDefault();
|
|
137
|
+
ev.stopPropagation();
|
|
138
|
+
setOpen(false, true);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const onPanelKeydown = (ev: KeyboardEvent): void => {
|
|
142
|
+
if (ev.key === 'Escape' && open) {
|
|
143
|
+
ev.preventDefault();
|
|
144
|
+
ev.stopPropagation();
|
|
145
|
+
setOpen(false, true);
|
|
146
|
+
} else if (open) {
|
|
147
|
+
handoffTab(ev, panel, trigger);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
trigger.addEventListener('click', onTriggerClick);
|
|
151
|
+
trigger.addEventListener('keydown', onTriggerKeydown);
|
|
152
|
+
panel.addEventListener('keydown', onPanelKeydown);
|
|
153
|
+
return {
|
|
154
|
+
close: (restoreFocus = false) => setOpen(false, restoreFocus),
|
|
155
|
+
destroy: () => {
|
|
156
|
+
offOutside();
|
|
157
|
+
trigger.removeEventListener('click', onTriggerClick);
|
|
158
|
+
trigger.removeEventListener('keydown', onTriggerKeydown);
|
|
159
|
+
panel.removeEventListener('keydown', onPanelKeydown);
|
|
160
|
+
releaseDropdown(panel);
|
|
161
|
+
panel.remove();
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface WeekTrackSegment {
|
|
167
|
+
segFrom: number;
|
|
168
|
+
segTo: number;
|
|
169
|
+
event: KitCalendarEvent;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** 同一周内为日程分配稳定横向行槽:优先按周内起点升序、跨度降序排入最低不重叠轨道,防止跨天日程隔天上下跳变 */
|
|
173
|
+
function allocateWeekTracks(events: readonly KitCalendarEvent[], weekFrom: number, weekTo: number): WeekTrackSegment[][] {
|
|
174
|
+
const overlapping = events
|
|
175
|
+
.filter((e) => e.to >= weekFrom && e.from <= weekTo)
|
|
176
|
+
.sort((a, b) => {
|
|
177
|
+
const aStart = Math.max(a.from, weekFrom);
|
|
178
|
+
const bStart = Math.max(b.from, weekFrom);
|
|
179
|
+
if (aStart !== bStart) return aStart - bStart;
|
|
180
|
+
const aSpan = Math.min(a.to, weekTo) - aStart;
|
|
181
|
+
const bSpan = Math.min(b.to, weekTo) - bStart;
|
|
182
|
+
if (bSpan !== aSpan) return bSpan - aSpan;
|
|
183
|
+
return a.from - b.from || a.time.localeCompare(b.time);
|
|
184
|
+
});
|
|
185
|
+
const tracks: WeekTrackSegment[][] = [];
|
|
186
|
+
for (const event of overlapping) {
|
|
187
|
+
const segFrom = Math.max(event.from, weekFrom);
|
|
188
|
+
const segTo = Math.min(event.to, weekTo);
|
|
189
|
+
let placed = false;
|
|
190
|
+
for (const track of tracks) {
|
|
191
|
+
if (track.every((seg) => seg.segTo < segFrom || seg.segFrom > segTo)) {
|
|
192
|
+
track.push({ segFrom, segTo, event });
|
|
193
|
+
placed = true;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (!placed) tracks.push([{ segFrom, segTo, event }]);
|
|
198
|
+
}
|
|
199
|
+
return tracks;
|
|
200
|
+
}
|
|
201
|
+
|
|
56
202
|
export interface KitCalendarEvent {
|
|
57
203
|
key: string;
|
|
58
204
|
title: string;
|
|
@@ -99,7 +245,12 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
99
245
|
props: {
|
|
100
246
|
data: { type: 'array', default: [], desc: '事件 [{ id, title, date, end?, time?, tone? }];end 非空跨天' },
|
|
101
247
|
map: { type: 'object', default: {}, desc: '键名对照:id / title / date / end / time / tone -> 数据里的键' },
|
|
102
|
-
view: { type: 'string', default: 'month', desc: '视图:month | week(只在它自己变化时覆盖内部视图)' },
|
|
248
|
+
view: { type: 'string', default: 'month', desc: '视图:month | week | day(只在它自己变化时覆盖内部视图)' },
|
|
249
|
+
disabled_dates: { type: 'array', default: [], desc: '不可选的日期规则(闭集,同 Date):weekends / past / future / "YYYY-MM-DD" / { from?, to? };命中的日期格置灰、不可选中' },
|
|
250
|
+
...KIT_READ_STATE_PROP_DEFS,
|
|
251
|
+
loading: { type: 'boolean', default: false, desc: '加载中:保留格线,事件位换成骨架条' },
|
|
252
|
+
error: { type: 'string', default: '', desc: '错误提示文案(与 error_text 等价兼容)' },
|
|
253
|
+
day_text: { type: 'string', default: '', desc: '日视图按钮文案' },
|
|
103
254
|
month: { type: 'string', default: '', desc: '锚点:YYYY-MM 或 YYYY-MM-DD;空则取 today 所在月' },
|
|
104
255
|
selected: { type: 'string', default: '', desc: '选中日 YYYY-MM-DD' },
|
|
105
256
|
today: { type: 'string', default: '', desc: '今天 YYYY-MM-DD;空则取本机当天' },
|
|
@@ -115,22 +266,37 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
115
266
|
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
116
267
|
},
|
|
117
268
|
emits: {
|
|
269
|
+
...KIT_READ_STATE_EMIT_DEFS,
|
|
118
270
|
date: { payload: { date: { type: 'string' }, events: { type: 'array' } }, desc: '点某日(或 Enter / Space);events = 当日事件源行' },
|
|
119
271
|
event: { payload: { id: { type: 'string' }, item: { type: 'object' } }, desc: '点事件块;item 是源数据行' },
|
|
120
272
|
navigate: { payload: { view: { type: 'string' }, anchor: { type: 'string' }, from: { type: 'string' }, to: { type: 'string' } }, desc: '翻页或切视图;from / to = 可见区间首末日' },
|
|
121
273
|
},
|
|
122
274
|
keyboard: { layout: 'grid', date_grid: true, wrap: false, typeahead: false, focus_model: 'roving', space: 'activate' },
|
|
123
275
|
},
|
|
124
|
-
templateHtml: `<section data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
276
|
+
templateHtml: `<section${kitAttrHtml(KIT_ATTR_CONTAINER, 'card')} data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
125
277
|
controllerFactory: createKitController((api) => {
|
|
126
278
|
const P = (): Record<string, unknown> => api.props();
|
|
127
279
|
let root: HTMLElement | null = null;
|
|
280
|
+
let headHost: HTMLElement | null = null;
|
|
281
|
+
let headEl: HTMLElement | null = null;
|
|
282
|
+
let prevBtnEl: HTMLButtonElement | null = null;
|
|
283
|
+
let nextBtnEl: HTMLButtonElement | null = null;
|
|
284
|
+
let todayBtnEl: HTMLButtonElement | null = null;
|
|
285
|
+
let titleEl: HTMLElement | null = null;
|
|
286
|
+
let viewGroupEl: HTMLElement | null = null;
|
|
287
|
+
let stateHostEl: HTMLElement | null = null;
|
|
288
|
+
let gridEl: HTMLElement | null = null;
|
|
289
|
+
const popHandles: Array<{ destroy: () => void }> = [];
|
|
128
290
|
let view: KitCalendarView = 'month';
|
|
129
291
|
let anchor = 0;
|
|
130
292
|
let cursor = 0;
|
|
131
293
|
let selected: number | null = null;
|
|
132
294
|
let last = { view: '', month: '', selected: '' };
|
|
133
295
|
|
|
296
|
+
const clearPopovers = (): void => {
|
|
297
|
+
while (popHandles.length > 0) popHandles.pop()!.destroy();
|
|
298
|
+
};
|
|
299
|
+
|
|
134
300
|
const todayNum = (): number => {
|
|
135
301
|
const given = dayNumOf(str(P().today));
|
|
136
302
|
if (given !== null) return given;
|
|
@@ -138,7 +304,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
138
304
|
return Math.round(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) / 86_400_000);
|
|
139
305
|
};
|
|
140
306
|
const weekStart = (): number => (num(P().week_start) === 0 ? 0 : 1);
|
|
141
|
-
const range = (): KitCalendarRange =>
|
|
307
|
+
const range = (): KitCalendarRange => viewRangeOf(view, anchor, weekStart());
|
|
142
308
|
|
|
143
309
|
const announce = (): void => {
|
|
144
310
|
const r = range();
|
|
@@ -150,7 +316,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
150
316
|
const viewGiven = str(p.view, 'month');
|
|
151
317
|
const monthGiven = str(p.month);
|
|
152
318
|
const selGiven = str(p.selected);
|
|
153
|
-
if (viewGiven !== last.view) { last.view = viewGiven; view = viewGiven === 'week' ? 'week' : 'month'; }
|
|
319
|
+
if (viewGiven !== last.view) { last.view = viewGiven; view = viewGiven === 'week' ? 'week' : viewGiven === 'day' ? 'day' : 'month'; }
|
|
154
320
|
if (monthGiven !== last.month || anchor === 0) {
|
|
155
321
|
last.month = monthGiven;
|
|
156
322
|
anchor = anchorOf(monthGiven) ?? todayNum();
|
|
@@ -162,7 +328,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
162
328
|
const visibleKeys = (): CollectionItem[] => range().weeks.flat().map((n) => ({ key: textOfDayNum(n), text: textOfDayNum(n) }));
|
|
163
329
|
|
|
164
330
|
const focusCursor = (): void => {
|
|
165
|
-
root?.querySelector<HTMLElement>(`[
|
|
331
|
+
root?.querySelector<HTMLElement>(`[${KIT_ATTR_DATE}="${attrEsc(textOfDayNum(cursor))}"]`)?.focus();
|
|
166
332
|
};
|
|
167
333
|
|
|
168
334
|
const moveCursor = (n: number): void => {
|
|
@@ -173,7 +339,10 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
173
339
|
focusCursor();
|
|
174
340
|
};
|
|
175
341
|
|
|
342
|
+
const disabledDay = (n: number): boolean => isDateDisabled(textOfDayNum(n), disabledRulesOf(P().disabled_dates));
|
|
343
|
+
|
|
176
344
|
const pick = (n: number): void => {
|
|
345
|
+
if (disabledDay(n)) return;
|
|
177
346
|
selected = n;
|
|
178
347
|
cursor = n;
|
|
179
348
|
paint();
|
|
@@ -183,7 +352,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
183
352
|
};
|
|
184
353
|
|
|
185
354
|
const pageBy = (dir: number): void => {
|
|
186
|
-
anchor = view === 'week' ? anchor + 7 * dir : addMonths(anchor, dir);
|
|
355
|
+
anchor = view === 'day' ? anchor + dir : view === 'week' ? anchor + 7 * dir : addMonths(anchor, dir);
|
|
187
356
|
cursor = anchor;
|
|
188
357
|
paint();
|
|
189
358
|
announce();
|
|
@@ -202,17 +371,42 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
202
371
|
onDateStep: (step) => { moveCursor(calendarStepDate(cursor, step, weekStart())); return true; },
|
|
203
372
|
});
|
|
204
373
|
|
|
374
|
+
function ensureHead(host: HTMLElement): void {
|
|
375
|
+
if (headHost === host && headEl && headEl.parentNode === host) return;
|
|
376
|
+
headHost = host;
|
|
377
|
+
headEl = mk('div', HEAD_CLASS);
|
|
378
|
+
// 日历顶部导航条 = 面头(标题行 + 工具条)
|
|
379
|
+
kitMarkLevel(headEl, 'head'); kitApplyLevelClass(headEl);
|
|
380
|
+
prevBtnEl = mk('button', BTN_CLASS) as HTMLButtonElement;
|
|
381
|
+
prevBtnEl.type = 'button';
|
|
382
|
+
setKitFace(prevBtnEl, 'raised');
|
|
383
|
+
prevBtnEl.setAttribute(KIT_ATTR_NAV, 'prev');
|
|
384
|
+
nextBtnEl = mk('button', BTN_CLASS) as HTMLButtonElement;
|
|
385
|
+
nextBtnEl.type = 'button';
|
|
386
|
+
setKitFace(nextBtnEl, 'raised');
|
|
387
|
+
nextBtnEl.setAttribute(KIT_ATTR_NAV, 'next');
|
|
388
|
+
todayBtnEl = mk('button', BTN_CLASS) as HTMLButtonElement;
|
|
389
|
+
todayBtnEl.type = 'button';
|
|
390
|
+
setKitFace(todayBtnEl, 'raised');
|
|
391
|
+
todayBtnEl.setAttribute(KIT_ATTR_NAV, 'today');
|
|
392
|
+
titleEl = mk('h2', TITLE_CLASS);
|
|
393
|
+
kitMarkPart(titleEl, 'block-title');
|
|
394
|
+
titleEl.setAttribute('aria-live', 'polite');
|
|
395
|
+
viewGroupEl = mk('div', VIEW_GROUP_CLASS);
|
|
396
|
+
headEl.append(prevBtnEl, nextBtnEl, todayBtnEl, titleEl, mk('span', SPACER_CLASS), viewGroupEl);
|
|
397
|
+
stateHostEl = null;
|
|
398
|
+
gridEl = null;
|
|
399
|
+
host.textContent = '';
|
|
400
|
+
host.appendChild(headEl);
|
|
401
|
+
}
|
|
402
|
+
|
|
205
403
|
function paint(): void {
|
|
206
404
|
if (!root) return;
|
|
207
405
|
const p = P();
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const focusedCtl = hadFocus ? (document.activeElement as HTMLElement | null)?.closest<HTMLElement>('[data-kit-nav],[data-kit-view]') ?? null : null;
|
|
211
|
-
const ctlSelector = focusedCtl === null ? ''
|
|
212
|
-
: focusedCtl.hasAttribute('data-kit-nav') ? `[data-kit-nav="${attrEsc(focusedCtl.getAttribute('data-kit-nav') ?? '')}"]`
|
|
213
|
-
: `[data-kit-view="${attrEsc(focusedCtl.getAttribute('data-kit-view') ?? '')}"]`;
|
|
406
|
+
clearPopovers();
|
|
407
|
+
const hadGridFocus = gridEl !== null && gridEl.contains(document.activeElement);
|
|
214
408
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
215
|
-
root
|
|
409
|
+
ensureHead(root);
|
|
216
410
|
const locale = str(p.locale);
|
|
217
411
|
const today = todayNum();
|
|
218
412
|
const ws = weekStart();
|
|
@@ -220,86 +414,219 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
220
414
|
const events = calendarEventsOf(p.data, p.map);
|
|
221
415
|
const maxPer = Math.max(1, Math.floor(num(p.max_per_day) ?? 3));
|
|
222
416
|
|
|
223
|
-
//
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
prev.setAttribute('data-kit-nav', 'prev');
|
|
229
|
-
const next = mk('button', BTN_CLASS, str(p.next_text, kitText('soma.kit.next_page', undefined, root)));
|
|
230
|
-
next.type = 'button';
|
|
231
|
-
setKitFace(next, 'raised');
|
|
232
|
-
next.setAttribute('data-kit-nav', 'next');
|
|
233
|
-
const todayBtn = mk('button', BTN_CLASS, str(p.today_text, kitText('soma.kit.cal_today', undefined, root)));
|
|
234
|
-
todayBtn.type = 'button';
|
|
235
|
-
setKitFace(todayBtn, 'raised');
|
|
236
|
-
todayBtn.setAttribute('data-kit-nav', 'today');
|
|
237
|
-
const title = mk('h2', TITLE_CLASS, view === 'week'
|
|
417
|
+
// 头部:原地更新导航钮与标题,视图切换钮经 reconcileKeyedElements 原地对账以保留键盘焦点
|
|
418
|
+
prevBtnEl!.textContent = str(p.prev_text, kitText('soma.kit.prev_page', undefined, root));
|
|
419
|
+
nextBtnEl!.textContent = str(p.next_text, kitText('soma.kit.next_page', undefined, root));
|
|
420
|
+
todayBtnEl!.textContent = str(p.today_text, kitText('soma.kit.cal_today', undefined, root));
|
|
421
|
+
titleEl!.textContent = view === 'day' ? textOfDayNum(anchor) : view === 'week'
|
|
238
422
|
? `${textOfDayNum(r.from)} ~ ${textOfDayNum(r.to)}`
|
|
239
|
-
: monthTitle(anchor, locale, root)
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
423
|
+
: monthTitle(anchor, locale, root);
|
|
424
|
+
reconcileKeyedElements(
|
|
425
|
+
viewGroupEl!,
|
|
426
|
+
CALENDAR_VIEWS,
|
|
427
|
+
(v) => v,
|
|
428
|
+
(v) => {
|
|
429
|
+
const b = mk('button', BTN_CLASS) as HTMLButtonElement;
|
|
430
|
+
b.type = 'button';
|
|
431
|
+
setKitFace(b, 'raised');
|
|
432
|
+
b.setAttribute(KIT_ATTR_VIEW, v);
|
|
433
|
+
return b;
|
|
434
|
+
},
|
|
435
|
+
(el, v) => {
|
|
436
|
+
el.className = v === view ? BTN_ON_CLASS : BTN_CLASS;
|
|
437
|
+
el.textContent = str(p[`${v}_text`], kitText(v === 'month' ? 'soma.kit.cal_month' : v === 'week' ? 'soma.kit.cal_week' : 'soma.kit.cal_day', undefined, root!));
|
|
438
|
+
el.setAttribute('aria-pressed', v === view ? 'true' : 'false');
|
|
439
|
+
},
|
|
440
|
+
);
|
|
441
|
+
|
|
442
|
+
// 读错误态兼容 error_text 与 error(loading 仍走日历格内骨架条,不吞格线)
|
|
443
|
+
const errMsg = str(p.error_text) || str(p.error);
|
|
444
|
+
// 数据状态自报(每次绘制都写):出错 > 加载 > 空;日历的加载走格内骨架条,判据同下面的 loading
|
|
445
|
+
kitMarkDataFacts(root, { error: errMsg !== '', loading: bool(p.loading), empty: events.length === 0 });
|
|
446
|
+
if (errMsg !== '') {
|
|
447
|
+
if (!stateHostEl) stateHostEl = mk('div', '');
|
|
448
|
+
if (stateHostEl.parentNode !== root) headEl!.after(stateHostEl);
|
|
449
|
+
const blocked = applyKitReadState(
|
|
450
|
+
stateHostEl,
|
|
451
|
+
{ ...p, loading: false, error_text: errMsg },
|
|
452
|
+
{ hasContent: events.length > 0, onRetry: () => api.emit('retry', {}), repaint: () => paint() },
|
|
453
|
+
);
|
|
454
|
+
if (blocked) {
|
|
455
|
+
if (gridEl?.parentNode === root) root.removeChild(gridEl);
|
|
456
|
+
gridEl = null;
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
} else if (stateHostEl?.parentNode === root) {
|
|
460
|
+
root.removeChild(stateHostEl);
|
|
461
|
+
stateHostEl = null;
|
|
249
462
|
}
|
|
250
|
-
|
|
463
|
+
|
|
464
|
+
const mapKeys = keyMap(KIT_CALENDAR_DEFAULT_MAP, p.map);
|
|
465
|
+
const autoSeq = kitReadHostAutoSequence(root);
|
|
466
|
+
const badgeByKey = new Map<string, string>();
|
|
467
|
+
events.forEach((e, evIdx) => {
|
|
468
|
+
const rawTone = textOf(e.raw[mapKeys.tone]);
|
|
469
|
+
const groupKey = textOf(e.raw.category ?? e.raw.group ?? e.raw.type) || e.title || e.key;
|
|
470
|
+
const resolvedTone = kitResolveStatusOrCategoryTone(
|
|
471
|
+
groupKey,
|
|
472
|
+
evIdx,
|
|
473
|
+
{
|
|
474
|
+
...(rawTone !== '' ? { explicitTone: rawTone } : {}),
|
|
475
|
+
preferHash: true,
|
|
476
|
+
...(autoSeq !== undefined ? { autoSequence: autoSeq } : { host: root }),
|
|
477
|
+
},
|
|
478
|
+
);
|
|
479
|
+
badgeByKey.set(e.key, kitToneSoftBadgeClass(resolvedTone));
|
|
480
|
+
});
|
|
251
481
|
|
|
252
482
|
// 网格
|
|
253
483
|
const grid = mk('div', GRID_CLASS);
|
|
254
|
-
|
|
484
|
+
// 旧版:按祖先是不是面板决定画不画外框;新流水线下外观由取值表按层级角色给,组件不看祖先
|
|
485
|
+
if (!kitHasProps(p)) markKitEdge(grid);
|
|
255
486
|
grid.setAttribute('role', 'grid');
|
|
256
|
-
grid.setAttribute('aria-label',
|
|
257
|
-
const
|
|
487
|
+
grid.setAttribute('aria-label', titleEl!.textContent ?? '');
|
|
488
|
+
const rowCls = view === 'day' ? ROW_DAY_CLASS : ROW_CLASS;
|
|
489
|
+
const hr = mk('div', rowCls);
|
|
258
490
|
hr.setAttribute('role', 'row');
|
|
259
|
-
|
|
491
|
+
// 星期表头行 = 面头(表头带)
|
|
492
|
+
kitMarkLevel(hr, 'head'); kitApplyLevelClass(hr);
|
|
493
|
+
const heads = weekdayHeads(ws, locale, root);
|
|
494
|
+
for (const wdHead of view === 'day' ? heads.filter((h) => h.wd === weekdayOfDayNum(anchor)) : heads) {
|
|
260
495
|
const c = mk('div', HEADCELL_CLASS, wdHead.name);
|
|
261
496
|
c.setAttribute('role', 'columnheader');
|
|
262
497
|
hr.appendChild(c);
|
|
263
498
|
}
|
|
264
499
|
grid.appendChild(hr);
|
|
265
500
|
const tabbable = r.weeks.flat().includes(cursor) ? cursor : r.from;
|
|
266
|
-
|
|
267
|
-
|
|
501
|
+
const loading = bool(p.loading);
|
|
502
|
+
if (loading) grid.setAttribute('aria-busy', 'true');
|
|
503
|
+
const gridRows: Array<Array<{ n: number; day: number; col: number; inMonth: boolean }>> = view === 'day'
|
|
504
|
+
? [[{ n: anchor, day: ymdOfDayNum(anchor).d, col: 0, inMonth: true }]]
|
|
505
|
+
: monthGridCells(view, anchor, ws).rows;
|
|
506
|
+
for (const cells of gridRows) {
|
|
507
|
+
const row = mk('div', `${rowCls} ${ROW_BORDER}`);
|
|
268
508
|
row.setAttribute('role', 'row');
|
|
509
|
+
const weekFrom = cells[0]!.n;
|
|
510
|
+
const weekTo = cells[cells.length - 1]!.n;
|
|
511
|
+
const tracks = loading ? [] : allocateWeekTracks(events, weekFrom, weekTo);
|
|
269
512
|
cells.forEach(({ n, day, col, inMonth }) => {
|
|
270
513
|
const out = !inMonth;
|
|
514
|
+
const off = disabledDay(n);
|
|
271
515
|
const cell = mk('div', [
|
|
272
|
-
CELL_CLASS, view
|
|
516
|
+
CELL_CLASS, view !== 'month' ? CELL_WEEK : '', col > 0 ? CELL_BORDER : '', out || off ? CELL_OUT : '', off ? CELL_DISABLED : '',
|
|
273
517
|
].filter((s) => s !== '').join(' '));
|
|
518
|
+
if (off) cell.setAttribute('aria-disabled', 'true');
|
|
274
519
|
cell.setAttribute('role', 'gridcell');
|
|
275
|
-
cell.setAttribute(
|
|
520
|
+
cell.setAttribute(KIT_ATTR_DATE, textOfDayNum(n));
|
|
276
521
|
cell.tabIndex = n === tabbable ? 0 : -1;
|
|
277
522
|
cell.setAttribute('aria-selected', n === selected ? 'true' : 'false');
|
|
278
|
-
if (n === selected) cell.setAttribute(
|
|
523
|
+
if (n === selected) cell.setAttribute(KIT_ATTR_SELECTED, '');
|
|
279
524
|
if (n === today) cell.setAttribute('aria-current', 'date');
|
|
280
|
-
|
|
281
|
-
|
|
525
|
+
// 日期格 = 格;选中日 = 选中(aria-selected 上面已写),今天 = 当前(aria-current="date" 上面已写,不覆盖)
|
|
526
|
+
kitMarkPart(cell, 'cell');
|
|
527
|
+
kitMarkPicked(cell, 'selected', n === selected, null);
|
|
528
|
+
kitMarkPicked(cell, 'current', n === today, null);
|
|
529
|
+
const dayHead = mk('div', DAYHEAD_CLASS);
|
|
530
|
+
dayHead.appendChild(mk('span', n === selected
|
|
531
|
+
? mergeClass(mergeClass(DAYNUM_CLASS, DAYNUM_SELECTED), n === today ? BORDER_PRIMARY : '')
|
|
532
|
+
: n === today ? mergeClass(DAYNUM_CLASS, DAYNUM_TODAY) : DAYNUM_CLASS, String(day)));
|
|
282
533
|
cell.appendChild(dayHead);
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
|
|
534
|
+
// 加载:格线保留,事件位换成骨架条
|
|
535
|
+
const list = loading ? [] : events.filter((e) => e.from <= n && n <= e.to);
|
|
536
|
+
if (loading) cell.appendChild(mk('span', KIT_SKELETON_BAR_LINE));
|
|
537
|
+
const trackCap = view === 'month' ? maxPer : tracks.length;
|
|
538
|
+
const slotEvents: Array<KitCalendarEvent | null> = Array.from({ length: trackCap }, (_, t) => {
|
|
539
|
+
const hit = tracks[t]?.find((seg) => seg.segFrom <= n && n <= seg.segTo);
|
|
540
|
+
return hit ? hit.event : null;
|
|
541
|
+
});
|
|
542
|
+
if (view === 'month' && list.length > 0) {
|
|
543
|
+
const placedKeys = new Set(slotEvents.filter((x): x is KitCalendarEvent => x !== null).map((x) => x.key));
|
|
544
|
+
for (const extra of list) {
|
|
545
|
+
if (placedKeys.size >= Math.min(list.length, maxPer)) break;
|
|
546
|
+
if (placedKeys.has(extra.key)) continue;
|
|
547
|
+
const freeIdx = slotEvents.indexOf(null);
|
|
548
|
+
if (freeIdx < 0) break;
|
|
549
|
+
slotEvents[freeIdx] = extra;
|
|
550
|
+
placedKeys.add(extra.key);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
let highestUsed = -1;
|
|
554
|
+
for (let t = slotEvents.length - 1; t >= 0; t -= 1) {
|
|
555
|
+
if (slotEvents[t] !== null) { highestUsed = t; break; }
|
|
556
|
+
}
|
|
557
|
+
let renderedCount = 0;
|
|
558
|
+
for (let t = 0; t <= highestUsed; t += 1) {
|
|
559
|
+
const e = slotEvents[t] ?? null;
|
|
560
|
+
if (e === null) {
|
|
561
|
+
const hasMultiDayBelow = slotEvents.slice(t + 1, highestUsed + 1).some((below) => below !== null && below.to > below.from);
|
|
562
|
+
if (hasMultiDayBelow) {
|
|
563
|
+
const spacer = mk('span', SLOT_SPACER_CLASS);
|
|
564
|
+
spacer.setAttribute('aria-hidden', 'true');
|
|
565
|
+
spacer.setAttribute(KIT_ATTR_SLOT_SPACER, '');
|
|
566
|
+
cell.appendChild(spacer);
|
|
567
|
+
}
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
renderedCount += 1;
|
|
286
571
|
const evText = `${e.time !== '' && n === e.from ? `${e.time} ` : ''}${e.title}`;
|
|
287
|
-
const
|
|
572
|
+
const badgeCls = badgeByKey.get(e.key) ?? kitToneSoftBadgeClass('primary');
|
|
573
|
+
const isMulti = view !== 'day' && e.to > e.from;
|
|
574
|
+
const spanKind = !isMulti ? 'single' : n === e.from ? 'start' : n === e.to ? 'end' : 'mid';
|
|
575
|
+
const spanCls = spanKind === 'single'
|
|
576
|
+
? EVENT_CLASS
|
|
577
|
+
: spanKind === 'start'
|
|
578
|
+
? mergeClass(EVENT_BASE_CLASS, EVENT_SPAN_START)
|
|
579
|
+
: spanKind === 'end'
|
|
580
|
+
? mergeClass(EVENT_BASE_CLASS, EVENT_SPAN_END)
|
|
581
|
+
: mergeClass(EVENT_BASE_CLASS, EVENT_SPAN_MID);
|
|
582
|
+
const btn = mk('button', mergeClass(spanCls, badgeCls), evText) as HTMLButtonElement;
|
|
288
583
|
btn.type = 'button';
|
|
289
|
-
btn.setAttribute(
|
|
584
|
+
btn.setAttribute(KIT_ATTR_EVENT, e.key);
|
|
585
|
+
// 跨日事件条的段位用专名:data-kit-span 已是对象宽度档的结构属性名(页面线写),同名会被宽度档取值误命中
|
|
586
|
+
btn.setAttribute(KIT_ATTR_CAL_SPAN, spanKind);
|
|
587
|
+
// 事件条 = 行内条目(格里的一行)
|
|
588
|
+
kitMarkPart(btn, 'line');
|
|
290
589
|
cell.appendChild(btn);
|
|
291
590
|
}
|
|
292
|
-
if (list.length >
|
|
293
|
-
|
|
591
|
+
if (list.length > renderedCount) {
|
|
592
|
+
const dayStr = textOfDayNum(n);
|
|
593
|
+
const moreLabel = str(p.more_text, kitText('soma.kit.cal_more', undefined, root)).replace('{n}', String(list.length - renderedCount));
|
|
594
|
+
const moreBtn = mk('button', MORE_BTN_CLASS, moreLabel) as HTMLButtonElement;
|
|
595
|
+
moreBtn.type = 'button';
|
|
596
|
+
moreBtn.setAttribute(KIT_ATTR_MORE, dayStr);
|
|
597
|
+
const popPanel = mk('div', PANEL_HIDDEN_CLASS);
|
|
598
|
+
popPanel.setAttribute('role', 'dialog');
|
|
599
|
+
popPanel.setAttribute('aria-label', dayStr);
|
|
600
|
+
popPanel.setAttribute(KIT_ATTR_CALENDAR_POPOVER, dayStr);
|
|
601
|
+
// 「更多」浮出的当日议程 = 浮起(气泡)
|
|
602
|
+
kitMarkLevel(popPanel, 'float'); kitApplyLevelClass(popPanel);
|
|
603
|
+
popPanel.appendChild(mk('div', AGENDA_HEAD_CLASS, dayStr));
|
|
604
|
+
const handle = wirePopLayer(moreBtn, popPanel);
|
|
605
|
+
popHandles.push(handle);
|
|
606
|
+
for (const item of list) {
|
|
607
|
+
const itemText = `${item.time !== '' ? `${item.time} ` : ''}${item.title}`;
|
|
608
|
+
const itemBadge = badgeByKey.get(item.key) ?? kitToneSoftBadgeClass('primary');
|
|
609
|
+
const itemBtn = mk('button', mergeClass(EVENT_CLASS, itemBadge), itemText) as HTMLButtonElement;
|
|
610
|
+
itemBtn.type = 'button';
|
|
611
|
+
itemBtn.setAttribute(KIT_ATTR_EVENT, item.key);
|
|
612
|
+
itemBtn.addEventListener('click', (ev) => {
|
|
613
|
+
ev.stopPropagation();
|
|
614
|
+
handle.close(true);
|
|
615
|
+
api.emit('event', { id: item.key, item: item.raw });
|
|
616
|
+
});
|
|
617
|
+
popPanel.appendChild(itemBtn);
|
|
618
|
+
}
|
|
619
|
+
cell.appendChild(moreBtn);
|
|
294
620
|
}
|
|
295
621
|
row.appendChild(cell);
|
|
296
622
|
});
|
|
297
623
|
grid.appendChild(row);
|
|
298
624
|
}
|
|
299
|
-
root.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
625
|
+
if (gridEl?.parentNode === root) root.replaceChild(grid, gridEl);
|
|
626
|
+
else root.appendChild(grid);
|
|
627
|
+
gridEl = grid;
|
|
628
|
+
if (hadGridFocus && !root.contains(document.activeElement)) {
|
|
629
|
+
focusCursor();
|
|
303
630
|
}
|
|
304
631
|
}
|
|
305
632
|
|
|
@@ -309,42 +636,54 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
309
636
|
const r = root;
|
|
310
637
|
const onClick = (event: Event): void => {
|
|
311
638
|
const target = event.target as HTMLElement | null;
|
|
312
|
-
const nav = target?.closest<HTMLElement>(
|
|
639
|
+
const nav = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_NAV));
|
|
313
640
|
if (nav) {
|
|
314
|
-
const kind = nav.getAttribute(
|
|
641
|
+
const kind = nav.getAttribute(KIT_ATTR_NAV);
|
|
315
642
|
if (kind === 'today') { anchor = todayNum(); cursor = anchor; paint(); announce(); } else pageBy(kind === 'next' ? 1 : -1);
|
|
316
643
|
return;
|
|
317
644
|
}
|
|
318
|
-
const v = target?.closest<HTMLElement>(
|
|
645
|
+
const v = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_VIEW));
|
|
319
646
|
if (v) {
|
|
320
|
-
const
|
|
647
|
+
const asked = v.getAttribute(KIT_ATTR_VIEW);
|
|
648
|
+
const next: KitCalendarView = asked === 'week' ? 'week' : asked === 'day' ? 'day' : 'month';
|
|
321
649
|
if (next !== view) { view = next; paint(); announce(); }
|
|
322
650
|
return;
|
|
323
651
|
}
|
|
324
|
-
|
|
652
|
+
if (target?.closest(`${kitAttrSel(KIT_ATTR_MORE)},${kitAttrSel(KIT_ATTR_CALENDAR_POPOVER)}`)) return;
|
|
653
|
+
const ev = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_EVENT));
|
|
325
654
|
if (ev) {
|
|
326
|
-
const key = ev.getAttribute(
|
|
655
|
+
const key = ev.getAttribute(KIT_ATTR_EVENT);
|
|
327
656
|
const hit = calendarEventsOf(P().data, P().map).find((e) => e.key === key);
|
|
328
657
|
if (hit) api.emit('event', { id: hit.key, item: hit.raw });
|
|
329
658
|
return;
|
|
330
659
|
}
|
|
331
|
-
const cell = target?.closest<HTMLElement>(
|
|
332
|
-
const n = cell ? dayNumOf(cell.getAttribute(
|
|
660
|
+
const cell = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_DATE));
|
|
661
|
+
const n = cell ? dayNumOf(cell.getAttribute(KIT_ATTR_DATE)) : null;
|
|
333
662
|
if (n !== null) pick(n);
|
|
334
663
|
};
|
|
335
664
|
const onKeydown = (event: KeyboardEvent): void => {
|
|
336
|
-
const cell = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
337
|
-
//
|
|
338
|
-
if (!cell || (event.target as HTMLElement).closest(
|
|
339
|
-
const n = dayNumOf(cell.getAttribute(
|
|
665
|
+
const cell = (event.target as HTMLElement | null)?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_DATE));
|
|
666
|
+
// 事件按钮与 +N 浮层触发钮上的 Enter / Space 归按钮自己的点击
|
|
667
|
+
if (!cell || (event.target as HTMLElement).closest(`${kitAttrSel(KIT_ATTR_EVENT)},${kitAttrSel(KIT_ATTR_MORE)},${kitAttrSel(KIT_ATTR_CALENDAR_POPOVER)}`)) return;
|
|
668
|
+
const n = dayNumOf(cell.getAttribute(KIT_ATTR_DATE));
|
|
340
669
|
if (n !== null) cursor = n;
|
|
341
670
|
if (wiring.onKeydown(event)) event.preventDefault();
|
|
342
671
|
};
|
|
343
672
|
r.addEventListener('click', onClick);
|
|
344
673
|
r.addEventListener('keydown', onKeydown as EventListener);
|
|
345
674
|
return () => {
|
|
675
|
+
clearPopovers();
|
|
346
676
|
r.removeEventListener('click', onClick);
|
|
347
677
|
r.removeEventListener('keydown', onKeydown as EventListener);
|
|
678
|
+
headHost = null;
|
|
679
|
+
headEl = null;
|
|
680
|
+
prevBtnEl = null;
|
|
681
|
+
nextBtnEl = null;
|
|
682
|
+
todayBtnEl = null;
|
|
683
|
+
titleEl = null;
|
|
684
|
+
viewGroupEl = null;
|
|
685
|
+
stateHostEl = null;
|
|
686
|
+
gridEl = null;
|
|
348
687
|
root = null;
|
|
349
688
|
};
|
|
350
689
|
},
|