soma-kit 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -340
- package/spec/generated/kit-page.schema.json +1134 -139
- package/spec/kit-grammar.json +934 -92
- package/spec/kit-grammar.schema.json +167 -2
- package/src/app/app-config.ts +219 -186
- package/src/app/define-kit-actions.ts +126 -20
- package/src/app/define-kit-app.ts +49 -4
- package/src/app/index.ts +5 -0
- package/src/app/kit-view-context.ts +39 -1
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +67 -23
- package/src/app/theme-runtime.ts +414 -85
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +104 -59
- package/src/base/anchored-layer.ts +7 -6
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +347 -50
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +143 -32
- package/src/base/check-core.ts +193 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +399 -27
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +148 -36
- package/src/base/context-menu.ts +23 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +114 -96
- package/src/base/date.ts +481 -74
- package/src/base/delta.ts +16 -9
- package/src/base/divider.ts +51 -33
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +57 -21
- package/src/base/gap-value.ts +34 -15
- package/src/base/hint-tips.ts +99 -29
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +79 -22
- package/src/base/inline-error.ts +13 -7
- package/src/base/input.ts +135 -35
- package/src/base/kbd.ts +30 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +282 -101
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +55 -22
- package/src/base/menu-button.ts +73 -22
- package/src/base/menu-core.ts +201 -24
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +7 -5
- package/src/base/motion/hover-gallery.ts +16 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +139 -27
- package/src/base/overlay-runtime.ts +30 -23
- package/src/base/overlay-shell.ts +59 -14
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +624 -73
- package/src/base/popup.ts +187 -52
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +141 -22
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +58 -16
- package/src/base/relation-cells.ts +541 -0
- package/src/base/resize-handle.ts +5 -3
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +70 -26
- package/src/base/select.ts +8 -3
- package/src/base/shared.ts +482 -71
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +123 -54
- package/src/base/tag.ts +184 -66
- package/src/base/text.ts +461 -71
- package/src/base/textarea.ts +88 -39
- package/src/base/time-picker.ts +335 -55
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +342 -88
- package/src/base/upload.ts +604 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +70 -5
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +52 -12
- package/src/biz/auth-panel/compile.ts +13 -3
- package/src/biz/auth-panel/shell.ts +27 -7
- package/src/biz/category-crud/compile.ts +51 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +29 -9
- package/src/biz/checkout-page/compile.ts +37 -3
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +26 -9
- package/src/biz/compose.ts +6 -1
- package/src/biz/data-components.ts +2 -0
- package/src/biz/import-wizard/compile.ts +4 -1
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +32 -18
- package/src/biz/index.ts +1 -1
- package/src/biz/landing-page/compile.ts +3 -2
- package/src/biz/landing-page/shell.ts +22 -3
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +54 -15
- package/src/biz/master-sub/compile.ts +194 -57
- package/src/biz/master-sub/detail-head.ts +141 -18
- package/src/biz/master-sub/index.ts +3 -0
- package/src/biz/master-sub/shell.ts +186 -57
- package/src/biz/multi-board/compile.ts +87 -36
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +3 -2
- package/src/biz/multi-board/prose-fold.ts +15 -11
- package/src/biz/multi-board/shell.ts +148 -37
- package/src/biz/notification-center/compile.ts +20 -6
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +43 -10
- package/src/biz/page-templates/domain-templates.ts +145 -22
- package/src/biz/page-templates/result-page/compile.ts +4 -1
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +17 -4
- package/src/biz/page-templates/sign-in-page/compile.ts +19 -8
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +28 -12
- package/src/biz/record-detail/compile.ts +39 -11
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +41 -10
- package/src/biz/settings-center/compile.ts +4 -1
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +30 -9
- package/src/biz/shared/action-host.ts +137 -46
- package/src/biz/shared/compile-helpers.ts +130 -28
- package/src/biz/shared/coordinator.ts +628 -147
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +58 -10
- package/src/biz/shared/overlay-shell.ts +40 -10
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +4 -2
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +21 -11
- package/src/biz/standard-crud/compile.ts +206 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +82 -22
- package/src/biz/standard-crud/summary.ts +2 -37
- package/src/biz/step-form/compile.ts +12 -3
- package/src/biz/step-form/hub.ts +165 -50
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +31 -15
- package/src/biz/types.ts +40 -4
- package/src/cli/kit-cli.ts +145 -26
- package/src/cli/kit-init.ts +3 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +446 -53
- package/src/compile/component-candidates.ts +56 -4
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +1 -1
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/rules-composition.ts +2 -1
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +382 -46
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +645 -28
- package/src/compile/styles.ts +226 -26
- package/src/compile/types.ts +62 -5
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +49 -22
- package/src/data/anchor-nav.ts +73 -15
- package/src/data/approval-flow.ts +210 -124
- package/src/data/assignment-picker.ts +163 -85
- package/src/data/async-result-panel.ts +110 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +141 -19
- package/src/data/calendar.ts +434 -96
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +72 -38
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +904 -77
- package/src/data/checklist.ts +78 -35
- package/src/data/code-view.ts +106 -48
- package/src/data/comment-thread.ts +607 -87
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +198 -30
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +107 -50
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +33 -17
- package/src/data/embed.ts +142 -7
- package/src/data/engine-ports.ts +13 -4
- package/src/data/field-mapper.ts +104 -48
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +603 -142
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +85 -27
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +637 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +38 -15
- package/src/data/image-viewer.ts +261 -62
- package/src/data/index.ts +63 -1
- package/src/data/item-list.ts +217 -57
- package/src/data/json-view.ts +165 -100
- package/src/data/kanban.ts +339 -87
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +155 -45
- package/src/data/matrix.ts +217 -112
- package/src/data/media-grid.ts +162 -38
- package/src/data/mega-menu.ts +39 -23
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +50 -15
- package/src/data/menu.ts +131 -47
- package/src/data/mockup.ts +30 -22
- package/src/data/modal-dialog.ts +90 -13
- package/src/data/navbar.ts +143 -61
- package/src/data/notice-list.ts +100 -48
- package/src/data/notify-renderer.ts +61 -7
- package/src/data/object-form.ts +1389 -130
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +122 -42
- package/src/data/panel-head.ts +237 -75
- package/src/data/permission-matrix.ts +371 -119
- package/src/data/permission-tree.ts +135 -80
- package/src/data/pricing-table.ts +106 -42
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +63 -31
- package/src/data/record-card.ts +239 -70
- package/src/data/record-picker.ts +56 -27
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +131 -41
- package/src/data/resident.ts +11 -1
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +206 -35
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +376 -102
- package/src/data/rule-builder.ts +129 -80
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +86 -43
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +438 -86
- package/src/data/static-lazy.ts +18 -0
- package/src/data/static-registry.ts +38 -2
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +63 -34
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +128 -47
- package/src/data/system-switcher.ts +40 -20
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +99 -31
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +110 -47
- package/src/data/transfer.ts +195 -47
- package/src/data/tree-table.ts +194 -112
- package/src/data/tree.ts +191 -70
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +242 -102
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +26 -4
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +1 -2
- package/src/frames/inherited-shell.ts +54 -13
- package/src/frames/page-bar.ts +205 -27
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +0 -2
- package/src/frames/shared.ts +64 -21
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +11 -7
- package/src/frames/split-frame/wiring.ts +14 -10
- package/src/frames/tabs-frame/shell.ts +3 -2
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +2 -0
- package/src/frames/workspace-frame/extras.ts +5 -3
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +22 -2
- package/src/frames/workspace-frame/state.ts +42 -14
- package/src/frames/workspace-frame/view.ts +697 -167
- package/src/generated/kit-grammar-runtime.ts +1015 -53
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +96 -3
- package/src/object-renderer/action-group.ts +175 -23
- package/src/object-renderer/action-more.ts +48 -17
- package/src/object-renderer/arrange.ts +241 -29
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +432 -107
- package/src/object-renderer/collection-table.ts +347 -45
- package/src/object-renderer/collection.ts +291 -62
- package/src/object-renderer/compile-data.ts +12 -2
- package/src/object-renderer/defaults.ts +6 -5
- package/src/object-renderer/emit-events.ts +45 -19
- package/src/object-renderer/emit-object.ts +35 -9
- package/src/object-renderer/emit-static.ts +734 -159
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +105 -18
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +18 -2
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +44 -2
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +71 -26
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +424 -103
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +428 -128
- package/src/object-renderer/types.ts +91 -2
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +15 -14
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +3 -2
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +76 -19
- package/src/recipes/control.ts +64 -5
- package/src/recipes/desc-list.ts +101 -7
- package/src/recipes/divider.ts +30 -9
- package/src/recipes/emphasis.ts +90 -5
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +3 -2
- package/src/recipes/index.ts +28 -4
- package/src/recipes/inherited-shell.ts +21 -15
- package/src/recipes/json-view.ts +6 -5
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +16 -6
- package/src/recipes/overlay.ts +47 -19
- package/src/recipes/page-width.ts +31 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +37 -19
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +5 -5
- package/src/recipes/state.ts +54 -3
- package/src/recipes/status.ts +14 -14
- package/src/recipes/strip.ts +47 -5
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +33 -4
- package/src/recipes/table-gap.ts +3 -2
- package/src/recipes/table-native-edit.ts +22 -9
- package/src/recipes/table-row.ts +45 -12
- package/src/recipes/tabs.ts +54 -22
- package/src/recipes/text-diff.ts +15 -8
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +68 -3
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +58 -12
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/icons.ts +28 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +165 -24
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +527 -16
- package/src/theme/kit-theme.tpl +491 -16
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +522 -185
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +3 -2
- package/src/theme/theme-tokens.ts +1601 -93
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/frames/list-summary.ts +0 -123
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
package/src/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,54 +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
31
|
import { mergeClass } from '../shared/merge-class';
|
|
32
|
+
import { KIT_COLOR_ROLE_CLASS_CANDIDATES, kitReadHostAutoSequence, kitResolveStatusOrCategoryTone, kitToneSoftBadgeClass } from '../recipes/color-role';
|
|
21
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';
|
|
22
40
|
import {
|
|
23
41
|
addMonths, anchorOf, attrEsc, dayNumOf, monthTitle, rowKey, textOfDayNum, timeTail, weekdayOfDayNum,
|
|
24
42
|
} from './d9-util';
|
|
25
43
|
|
|
26
44
|
export const KIT_CALENDAR_DEFAULT_MAP = Object.freeze({ id: 'id', title: 'title', date: 'date', end: 'end', time: 'time', tone: 'tone' });
|
|
27
45
|
|
|
28
|
-
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
|
+
}
|
|
29
53
|
|
|
30
|
-
const ROOT_CLASS = 'flex flex-col gap-3 text
|
|
31
|
-
const HEAD_CLASS = 'flex flex-wrap items-center gap-2';
|
|
32
|
-
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'));
|
|
33
58
|
const SPACER_CLASS = 'flex-1';
|
|
59
|
+
const ROUND_ITEM = 'rounded-item';
|
|
60
|
+
const BORDER_PRIMARY = 'border border-primary';
|
|
34
61
|
const BTN_CLASS = kitEmphasisButtonRecipe('button.toolbar');
|
|
35
|
-
const BTN_ON_CLASS =
|
|
36
|
-
const GRID_CLASS = mergeClass('flex flex-col overflow-hidden', kitShellRecipe({ tone: 'base', shadow: false }));
|
|
37
|
-
const ROW_CLASS = 'grid grid-cols-7
|
|
38
|
-
const
|
|
39
|
-
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());
|
|
40
71
|
// 网格外层 overflow-hidden 会把外扩的焦点环切掉,格子与事件块的焦点环一律画在里面(ring-inset)
|
|
41
|
-
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
|
+
);
|
|
42
76
|
const CELL_WEEK = 'min-h-48';
|
|
43
|
-
const CELL_BORDER = '
|
|
44
|
-
const CELL_OUT = '
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
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(' ');
|
|
51
99
|
|
|
52
100
|
export const KIT_CALENDAR_CLASS_CANDIDATES: readonly string[] = classTokens(
|
|
53
|
-
ROOT_CLASS, HEAD_CLASS, TITLE_CLASS, SPACER_CLASS, BTN_CLASS, BTN_ON_CLASS, GRID_CLASS, ROW_CLASS, ROW_BORDER, HEADCELL_CLASS,
|
|
54
|
-
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,
|
|
55
107
|
);
|
|
56
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
|
+
|
|
57
202
|
export interface KitCalendarEvent {
|
|
58
203
|
key: string;
|
|
59
204
|
title: string;
|
|
@@ -100,7 +245,12 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
100
245
|
props: {
|
|
101
246
|
data: { type: 'array', default: [], desc: '事件 [{ id, title, date, end?, time?, tone? }];end 非空跨天' },
|
|
102
247
|
map: { type: 'object', default: {}, desc: '键名对照:id / title / date / end / time / tone -> 数据里的键' },
|
|
103
|
-
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: '日视图按钮文案' },
|
|
104
254
|
month: { type: 'string', default: '', desc: '锚点:YYYY-MM 或 YYYY-MM-DD;空则取 today 所在月' },
|
|
105
255
|
selected: { type: 'string', default: '', desc: '选中日 YYYY-MM-DD' },
|
|
106
256
|
today: { type: 'string', default: '', desc: '今天 YYYY-MM-DD;空则取本机当天' },
|
|
@@ -116,22 +266,37 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
116
266
|
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
117
267
|
},
|
|
118
268
|
emits: {
|
|
269
|
+
...KIT_READ_STATE_EMIT_DEFS,
|
|
119
270
|
date: { payload: { date: { type: 'string' }, events: { type: 'array' } }, desc: '点某日(或 Enter / Space);events = 当日事件源行' },
|
|
120
271
|
event: { payload: { id: { type: 'string' }, item: { type: 'object' } }, desc: '点事件块;item 是源数据行' },
|
|
121
272
|
navigate: { payload: { view: { type: 'string' }, anchor: { type: 'string' }, from: { type: 'string' }, to: { type: 'string' } }, desc: '翻页或切视图;from / to = 可见区间首末日' },
|
|
122
273
|
},
|
|
123
274
|
keyboard: { layout: 'grid', date_grid: true, wrap: false, typeahead: false, focus_model: 'roving', space: 'activate' },
|
|
124
275
|
},
|
|
125
|
-
templateHtml: `<section
|
|
276
|
+
templateHtml: `<section${kitAttrHtml(KIT_ATTR_CONTAINER, 'card')} data-soma-id="root" class="${ROOT_CLASS}"></section>`,
|
|
126
277
|
controllerFactory: createKitController((api) => {
|
|
127
278
|
const P = (): Record<string, unknown> => api.props();
|
|
128
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 }> = [];
|
|
129
290
|
let view: KitCalendarView = 'month';
|
|
130
291
|
let anchor = 0;
|
|
131
292
|
let cursor = 0;
|
|
132
293
|
let selected: number | null = null;
|
|
133
294
|
let last = { view: '', month: '', selected: '' };
|
|
134
295
|
|
|
296
|
+
const clearPopovers = (): void => {
|
|
297
|
+
while (popHandles.length > 0) popHandles.pop()!.destroy();
|
|
298
|
+
};
|
|
299
|
+
|
|
135
300
|
const todayNum = (): number => {
|
|
136
301
|
const given = dayNumOf(str(P().today));
|
|
137
302
|
if (given !== null) return given;
|
|
@@ -139,7 +304,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
139
304
|
return Math.round(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) / 86_400_000);
|
|
140
305
|
};
|
|
141
306
|
const weekStart = (): number => (num(P().week_start) === 0 ? 0 : 1);
|
|
142
|
-
const range = (): KitCalendarRange =>
|
|
307
|
+
const range = (): KitCalendarRange => viewRangeOf(view, anchor, weekStart());
|
|
143
308
|
|
|
144
309
|
const announce = (): void => {
|
|
145
310
|
const r = range();
|
|
@@ -151,7 +316,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
151
316
|
const viewGiven = str(p.view, 'month');
|
|
152
317
|
const monthGiven = str(p.month);
|
|
153
318
|
const selGiven = str(p.selected);
|
|
154
|
-
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'; }
|
|
155
320
|
if (monthGiven !== last.month || anchor === 0) {
|
|
156
321
|
last.month = monthGiven;
|
|
157
322
|
anchor = anchorOf(monthGiven) ?? todayNum();
|
|
@@ -163,7 +328,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
163
328
|
const visibleKeys = (): CollectionItem[] => range().weeks.flat().map((n) => ({ key: textOfDayNum(n), text: textOfDayNum(n) }));
|
|
164
329
|
|
|
165
330
|
const focusCursor = (): void => {
|
|
166
|
-
root?.querySelector<HTMLElement>(`[
|
|
331
|
+
root?.querySelector<HTMLElement>(`[${KIT_ATTR_DATE}="${attrEsc(textOfDayNum(cursor))}"]`)?.focus();
|
|
167
332
|
};
|
|
168
333
|
|
|
169
334
|
const moveCursor = (n: number): void => {
|
|
@@ -174,7 +339,10 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
174
339
|
focusCursor();
|
|
175
340
|
};
|
|
176
341
|
|
|
342
|
+
const disabledDay = (n: number): boolean => isDateDisabled(textOfDayNum(n), disabledRulesOf(P().disabled_dates));
|
|
343
|
+
|
|
177
344
|
const pick = (n: number): void => {
|
|
345
|
+
if (disabledDay(n)) return;
|
|
178
346
|
selected = n;
|
|
179
347
|
cursor = n;
|
|
180
348
|
paint();
|
|
@@ -184,7 +352,7 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
184
352
|
};
|
|
185
353
|
|
|
186
354
|
const pageBy = (dir: number): void => {
|
|
187
|
-
anchor = view === 'week' ? anchor + 7 * dir : addMonths(anchor, dir);
|
|
355
|
+
anchor = view === 'day' ? anchor + dir : view === 'week' ? anchor + 7 * dir : addMonths(anchor, dir);
|
|
188
356
|
cursor = anchor;
|
|
189
357
|
paint();
|
|
190
358
|
announce();
|
|
@@ -203,17 +371,42 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
203
371
|
onDateStep: (step) => { moveCursor(calendarStepDate(cursor, step, weekStart())); return true; },
|
|
204
372
|
});
|
|
205
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
|
+
|
|
206
403
|
function paint(): void {
|
|
207
404
|
if (!root) return;
|
|
208
405
|
const p = P();
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const focusedCtl = hadFocus ? (document.activeElement as HTMLElement | null)?.closest<HTMLElement>('[data-kit-nav],[data-kit-view]') ?? null : null;
|
|
212
|
-
const ctlSelector = focusedCtl === null ? ''
|
|
213
|
-
: focusedCtl.hasAttribute('data-kit-nav') ? `[data-kit-nav="${attrEsc(focusedCtl.getAttribute('data-kit-nav') ?? '')}"]`
|
|
214
|
-
: `[data-kit-view="${attrEsc(focusedCtl.getAttribute('data-kit-view') ?? '')}"]`;
|
|
406
|
+
clearPopovers();
|
|
407
|
+
const hadGridFocus = gridEl !== null && gridEl.contains(document.activeElement);
|
|
215
408
|
root.className = joinClass(ROOT_CLASS, p.class);
|
|
216
|
-
root
|
|
409
|
+
ensureHead(root);
|
|
217
410
|
const locale = str(p.locale);
|
|
218
411
|
const today = todayNum();
|
|
219
412
|
const ws = weekStart();
|
|
@@ -221,86 +414,219 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
221
414
|
const events = calendarEventsOf(p.data, p.map);
|
|
222
415
|
const maxPer = Math.max(1, Math.floor(num(p.max_per_day) ?? 3));
|
|
223
416
|
|
|
224
|
-
//
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
prev.setAttribute('data-kit-nav', 'prev');
|
|
230
|
-
const next = mk('button', BTN_CLASS, str(p.next_text, kitText('soma.kit.next_page', undefined, root)));
|
|
231
|
-
next.type = 'button';
|
|
232
|
-
setKitFace(next, 'raised');
|
|
233
|
-
next.setAttribute('data-kit-nav', 'next');
|
|
234
|
-
const todayBtn = mk('button', BTN_CLASS, str(p.today_text, kitText('soma.kit.cal_today', undefined, root)));
|
|
235
|
-
todayBtn.type = 'button';
|
|
236
|
-
setKitFace(todayBtn, 'raised');
|
|
237
|
-
todayBtn.setAttribute('data-kit-nav', 'today');
|
|
238
|
-
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'
|
|
239
422
|
? `${textOfDayNum(r.from)} ~ ${textOfDayNum(r.to)}`
|
|
240
|
-
: monthTitle(anchor, locale, root)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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;
|
|
250
462
|
}
|
|
251
|
-
|
|
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
|
+
});
|
|
252
481
|
|
|
253
482
|
// 网格
|
|
254
483
|
const grid = mk('div', GRID_CLASS);
|
|
255
|
-
|
|
484
|
+
// 旧版:按祖先是不是面板决定画不画外框;新流水线下外观由取值表按层级角色给,组件不看祖先
|
|
485
|
+
if (!kitHasProps(p)) markKitEdge(grid);
|
|
256
486
|
grid.setAttribute('role', 'grid');
|
|
257
|
-
grid.setAttribute('aria-label',
|
|
258
|
-
const
|
|
487
|
+
grid.setAttribute('aria-label', titleEl!.textContent ?? '');
|
|
488
|
+
const rowCls = view === 'day' ? ROW_DAY_CLASS : ROW_CLASS;
|
|
489
|
+
const hr = mk('div', rowCls);
|
|
259
490
|
hr.setAttribute('role', 'row');
|
|
260
|
-
|
|
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) {
|
|
261
495
|
const c = mk('div', HEADCELL_CLASS, wdHead.name);
|
|
262
496
|
c.setAttribute('role', 'columnheader');
|
|
263
497
|
hr.appendChild(c);
|
|
264
498
|
}
|
|
265
499
|
grid.appendChild(hr);
|
|
266
500
|
const tabbable = r.weeks.flat().includes(cursor) ? cursor : r.from;
|
|
267
|
-
|
|
268
|
-
|
|
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}`);
|
|
269
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);
|
|
270
512
|
cells.forEach(({ n, day, col, inMonth }) => {
|
|
271
513
|
const out = !inMonth;
|
|
514
|
+
const off = disabledDay(n);
|
|
272
515
|
const cell = mk('div', [
|
|
273
|
-
CELL_CLASS, view
|
|
516
|
+
CELL_CLASS, view !== 'month' ? CELL_WEEK : '', col > 0 ? CELL_BORDER : '', out || off ? CELL_OUT : '', off ? CELL_DISABLED : '',
|
|
274
517
|
].filter((s) => s !== '').join(' '));
|
|
518
|
+
if (off) cell.setAttribute('aria-disabled', 'true');
|
|
275
519
|
cell.setAttribute('role', 'gridcell');
|
|
276
|
-
cell.setAttribute(
|
|
520
|
+
cell.setAttribute(KIT_ATTR_DATE, textOfDayNum(n));
|
|
277
521
|
cell.tabIndex = n === tabbable ? 0 : -1;
|
|
278
522
|
cell.setAttribute('aria-selected', n === selected ? 'true' : 'false');
|
|
279
|
-
if (n === selected) cell.setAttribute(
|
|
523
|
+
if (n === selected) cell.setAttribute(KIT_ATTR_SELECTED, '');
|
|
280
524
|
if (n === today) cell.setAttribute('aria-current', 'date');
|
|
281
|
-
|
|
282
|
-
|
|
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)));
|
|
283
533
|
cell.appendChild(dayHead);
|
|
284
|
-
|
|
285
|
-
const
|
|
286
|
-
|
|
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;
|
|
287
571
|
const evText = `${e.time !== '' && n === e.from ? `${e.time} ` : ''}${e.title}`;
|
|
288
|
-
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;
|
|
289
583
|
btn.type = 'button';
|
|
290
|
-
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');
|
|
291
589
|
cell.appendChild(btn);
|
|
292
590
|
}
|
|
293
|
-
if (list.length >
|
|
294
|
-
|
|
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);
|
|
295
620
|
}
|
|
296
621
|
row.appendChild(cell);
|
|
297
622
|
});
|
|
298
623
|
grid.appendChild(row);
|
|
299
624
|
}
|
|
300
|
-
root.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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();
|
|
304
630
|
}
|
|
305
631
|
}
|
|
306
632
|
|
|
@@ -310,42 +636,54 @@ export function createCalendar(): SomaComponentDefinition {
|
|
|
310
636
|
const r = root;
|
|
311
637
|
const onClick = (event: Event): void => {
|
|
312
638
|
const target = event.target as HTMLElement | null;
|
|
313
|
-
const nav = target?.closest<HTMLElement>(
|
|
639
|
+
const nav = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_NAV));
|
|
314
640
|
if (nav) {
|
|
315
|
-
const kind = nav.getAttribute(
|
|
641
|
+
const kind = nav.getAttribute(KIT_ATTR_NAV);
|
|
316
642
|
if (kind === 'today') { anchor = todayNum(); cursor = anchor; paint(); announce(); } else pageBy(kind === 'next' ? 1 : -1);
|
|
317
643
|
return;
|
|
318
644
|
}
|
|
319
|
-
const v = target?.closest<HTMLElement>(
|
|
645
|
+
const v = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_VIEW));
|
|
320
646
|
if (v) {
|
|
321
|
-
const
|
|
647
|
+
const asked = v.getAttribute(KIT_ATTR_VIEW);
|
|
648
|
+
const next: KitCalendarView = asked === 'week' ? 'week' : asked === 'day' ? 'day' : 'month';
|
|
322
649
|
if (next !== view) { view = next; paint(); announce(); }
|
|
323
650
|
return;
|
|
324
651
|
}
|
|
325
|
-
|
|
652
|
+
if (target?.closest(`${kitAttrSel(KIT_ATTR_MORE)},${kitAttrSel(KIT_ATTR_CALENDAR_POPOVER)}`)) return;
|
|
653
|
+
const ev = target?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_EVENT));
|
|
326
654
|
if (ev) {
|
|
327
|
-
const key = ev.getAttribute(
|
|
655
|
+
const key = ev.getAttribute(KIT_ATTR_EVENT);
|
|
328
656
|
const hit = calendarEventsOf(P().data, P().map).find((e) => e.key === key);
|
|
329
657
|
if (hit) api.emit('event', { id: hit.key, item: hit.raw });
|
|
330
658
|
return;
|
|
331
659
|
}
|
|
332
|
-
const cell = target?.closest<HTMLElement>(
|
|
333
|
-
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;
|
|
334
662
|
if (n !== null) pick(n);
|
|
335
663
|
};
|
|
336
664
|
const onKeydown = (event: KeyboardEvent): void => {
|
|
337
|
-
const cell = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
338
|
-
//
|
|
339
|
-
if (!cell || (event.target as HTMLElement).closest(
|
|
340
|
-
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));
|
|
341
669
|
if (n !== null) cursor = n;
|
|
342
670
|
if (wiring.onKeydown(event)) event.preventDefault();
|
|
343
671
|
};
|
|
344
672
|
r.addEventListener('click', onClick);
|
|
345
673
|
r.addEventListener('keydown', onKeydown as EventListener);
|
|
346
674
|
return () => {
|
|
675
|
+
clearPopovers();
|
|
347
676
|
r.removeEventListener('click', onClick);
|
|
348
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;
|
|
349
687
|
root = null;
|
|
350
688
|
};
|
|
351
689
|
},
|