soma-kit 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -340
- package/spec/generated/kit-page.schema.json +1134 -139
- package/spec/kit-grammar.json +935 -93
- package/spec/kit-grammar.schema.json +167 -2
- package/src/app/app-config.ts +219 -186
- package/src/app/define-kit-actions.ts +126 -20
- package/src/app/define-kit-app.ts +49 -4
- package/src/app/index.ts +5 -0
- package/src/app/kit-view-context.ts +39 -1
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +67 -23
- package/src/app/theme-runtime.ts +414 -85
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +104 -59
- package/src/base/anchored-layer.ts +7 -6
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +347 -50
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +143 -32
- package/src/base/check-core.ts +193 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +399 -27
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +148 -36
- package/src/base/context-menu.ts +23 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +114 -96
- package/src/base/date.ts +481 -74
- package/src/base/delta.ts +16 -9
- package/src/base/divider.ts +51 -33
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +57 -21
- package/src/base/gap-value.ts +34 -15
- package/src/base/hint-tips.ts +99 -29
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +79 -22
- package/src/base/inline-error.ts +13 -7
- package/src/base/input.ts +135 -35
- package/src/base/kbd.ts +30 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +282 -101
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +55 -22
- package/src/base/menu-button.ts +73 -22
- package/src/base/menu-core.ts +201 -24
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +7 -5
- package/src/base/motion/hover-gallery.ts +16 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +139 -27
- package/src/base/overlay-runtime.ts +30 -23
- package/src/base/overlay-shell.ts +59 -14
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +624 -73
- package/src/base/popup.ts +187 -52
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +141 -22
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +58 -16
- package/src/base/relation-cells.ts +541 -0
- package/src/base/resize-handle.ts +5 -3
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +70 -26
- package/src/base/select.ts +8 -3
- package/src/base/shared.ts +482 -71
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +123 -54
- package/src/base/tag.ts +184 -66
- package/src/base/text.ts +461 -71
- package/src/base/textarea.ts +88 -39
- package/src/base/time-picker.ts +335 -55
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +342 -88
- package/src/base/upload.ts +604 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +70 -5
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +52 -12
- package/src/biz/auth-panel/compile.ts +13 -3
- package/src/biz/auth-panel/shell.ts +27 -7
- package/src/biz/category-crud/compile.ts +51 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +29 -9
- package/src/biz/checkout-page/compile.ts +37 -3
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +26 -9
- package/src/biz/compose.ts +6 -1
- package/src/biz/data-components.ts +2 -0
- package/src/biz/import-wizard/compile.ts +4 -1
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +32 -18
- package/src/biz/index.ts +1 -1
- package/src/biz/landing-page/compile.ts +3 -2
- package/src/biz/landing-page/shell.ts +22 -3
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +54 -15
- package/src/biz/master-sub/compile.ts +194 -57
- package/src/biz/master-sub/detail-head.ts +141 -18
- package/src/biz/master-sub/index.ts +3 -0
- package/src/biz/master-sub/shell.ts +188 -62
- package/src/biz/multi-board/compile.ts +87 -36
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +3 -2
- package/src/biz/multi-board/prose-fold.ts +15 -11
- package/src/biz/multi-board/shell.ts +148 -37
- package/src/biz/notification-center/compile.ts +20 -6
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +43 -10
- package/src/biz/page-templates/domain-templates.ts +145 -22
- package/src/biz/page-templates/result-page/compile.ts +4 -1
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +17 -4
- package/src/biz/page-templates/sign-in-page/compile.ts +19 -8
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +28 -12
- package/src/biz/record-detail/compile.ts +39 -11
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +41 -10
- package/src/biz/settings-center/compile.ts +4 -1
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +30 -9
- package/src/biz/shared/action-host.ts +137 -46
- package/src/biz/shared/compile-helpers.ts +152 -28
- package/src/biz/shared/coordinator.ts +628 -147
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +58 -10
- package/src/biz/shared/overlay-shell.ts +40 -10
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +4 -2
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +21 -11
- package/src/biz/standard-crud/compile.ts +206 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +82 -22
- package/src/biz/standard-crud/summary.ts +2 -37
- package/src/biz/step-form/compile.ts +12 -3
- package/src/biz/step-form/hub.ts +165 -50
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +31 -15
- package/src/biz/types.ts +40 -4
- package/src/cli/kit-cli.ts +145 -26
- package/src/cli/kit-init.ts +3 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +446 -53
- package/src/compile/component-candidates.ts +56 -4
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +1 -1
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/rules-composition.ts +2 -1
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +382 -46
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +645 -28
- package/src/compile/styles.ts +226 -26
- package/src/compile/types.ts +62 -5
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +49 -22
- package/src/data/anchor-nav.ts +73 -15
- package/src/data/approval-flow.ts +210 -124
- package/src/data/assignment-picker.ts +163 -85
- package/src/data/async-result-panel.ts +110 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +141 -19
- package/src/data/calendar.ts +434 -96
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +72 -38
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +904 -77
- package/src/data/checklist.ts +78 -35
- package/src/data/code-view.ts +106 -48
- package/src/data/comment-thread.ts +607 -87
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +198 -30
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +107 -50
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +33 -17
- package/src/data/embed.ts +142 -7
- package/src/data/engine-ports.ts +13 -4
- package/src/data/field-mapper.ts +104 -48
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +603 -142
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +85 -27
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +637 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +38 -15
- package/src/data/image-viewer.ts +261 -62
- package/src/data/index.ts +63 -1
- package/src/data/item-list.ts +217 -57
- package/src/data/json-view.ts +165 -100
- package/src/data/kanban.ts +339 -87
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +155 -45
- package/src/data/matrix.ts +217 -112
- package/src/data/media-grid.ts +162 -38
- package/src/data/mega-menu.ts +39 -23
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +50 -15
- package/src/data/menu.ts +131 -47
- package/src/data/mockup.ts +30 -22
- package/src/data/modal-dialog.ts +90 -13
- package/src/data/navbar.ts +143 -61
- package/src/data/notice-list.ts +100 -48
- package/src/data/notify-renderer.ts +61 -7
- package/src/data/object-form.ts +1389 -130
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +122 -42
- package/src/data/panel-head.ts +237 -75
- package/src/data/permission-matrix.ts +371 -119
- package/src/data/permission-tree.ts +135 -80
- package/src/data/pricing-table.ts +106 -42
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +63 -31
- package/src/data/record-card.ts +239 -70
- package/src/data/record-picker.ts +56 -27
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +131 -41
- package/src/data/resident.ts +11 -1
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +206 -35
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +376 -102
- package/src/data/rule-builder.ts +129 -80
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +86 -43
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +438 -86
- package/src/data/static-lazy.ts +18 -0
- package/src/data/static-registry.ts +38 -2
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +63 -34
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +128 -47
- package/src/data/system-switcher.ts +40 -20
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +99 -31
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +110 -47
- package/src/data/transfer.ts +195 -47
- package/src/data/tree-table.ts +194 -112
- package/src/data/tree.ts +191 -70
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +242 -102
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +26 -4
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +1 -2
- package/src/frames/inherited-shell.ts +54 -13
- package/src/frames/page-bar.ts +205 -27
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +0 -2
- package/src/frames/shared.ts +64 -21
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +11 -7
- package/src/frames/split-frame/wiring.ts +14 -10
- package/src/frames/tabs-frame/shell.ts +3 -2
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +2 -0
- package/src/frames/workspace-frame/extras.ts +5 -3
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +22 -2
- package/src/frames/workspace-frame/state.ts +42 -14
- package/src/frames/workspace-frame/view.ts +697 -167
- package/src/generated/kit-grammar-runtime.ts +1016 -54
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +96 -3
- package/src/object-renderer/action-group.ts +175 -23
- package/src/object-renderer/action-more.ts +48 -17
- package/src/object-renderer/arrange.ts +241 -29
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +432 -107
- package/src/object-renderer/collection-table.ts +347 -45
- package/src/object-renderer/collection.ts +291 -62
- package/src/object-renderer/compile-data.ts +12 -2
- package/src/object-renderer/defaults.ts +6 -5
- package/src/object-renderer/emit-events.ts +45 -19
- package/src/object-renderer/emit-object.ts +35 -9
- package/src/object-renderer/emit-static.ts +734 -159
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +105 -18
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +18 -2
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +44 -2
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +71 -26
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +423 -104
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +428 -128
- package/src/object-renderer/types.ts +91 -2
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +15 -14
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +3 -2
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +76 -19
- package/src/recipes/control.ts +64 -5
- package/src/recipes/desc-list.ts +101 -7
- package/src/recipes/divider.ts +30 -9
- package/src/recipes/emphasis.ts +90 -5
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +3 -2
- package/src/recipes/index.ts +28 -4
- package/src/recipes/inherited-shell.ts +21 -15
- package/src/recipes/json-view.ts +6 -5
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +16 -6
- package/src/recipes/overlay.ts +47 -19
- package/src/recipes/page-width.ts +31 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +37 -19
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +5 -5
- package/src/recipes/state.ts +54 -3
- package/src/recipes/status.ts +14 -14
- package/src/recipes/strip.ts +47 -5
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +33 -4
- package/src/recipes/table-gap.ts +3 -2
- package/src/recipes/table-native-edit.ts +22 -9
- package/src/recipes/table-row.ts +45 -12
- package/src/recipes/tabs.ts +54 -22
- package/src/recipes/text-diff.ts +15 -8
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +68 -3
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +58 -12
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/icons.ts +28 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +165 -24
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +527 -16
- package/src/theme/kit-theme.tpl +491 -16
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +522 -185
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +3 -2
- package/src/theme/theme-tokens.ts +1601 -93
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/frames/list-summary.ts +0 -123
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
package/src/data/gantt.ts
CHANGED
|
@@ -17,13 +17,49 @@
|
|
|
17
17
|
//(item 是源数据里的原对象),键盘用 Tab 走行、Enter / Space 触发。
|
|
18
18
|
// 画面用一张 SVG(任务条、进度、刻度线、今日线、依赖线),左栏与表头是 HTML;SVG 只用语义色名类与属性,无内联样式。
|
|
19
19
|
|
|
20
|
+
import { kitApplyLevelClass } from './level-class';
|
|
20
21
|
import type { SomaComponentDefinition } from 'soma-core';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
22
|
+
import { kitHasProps, kitMarkDataFacts, kitMarkDragging, kitMarkLevel } from './kit-contract';
|
|
23
|
+
import {
|
|
24
|
+
KIT_ATTR_BAR,
|
|
25
|
+
KIT_ATTR_BAR_LABEL,
|
|
26
|
+
KIT_ATTR_BASELINE,
|
|
27
|
+
KIT_ATTR_DELAYED,
|
|
28
|
+
KIT_ATTR_GANTT_CHART,
|
|
29
|
+
KIT_ATTR_GANTT_HANDLE,
|
|
30
|
+
KIT_ATTR_INVALID,
|
|
31
|
+
KIT_ATTR_MILESTONE,
|
|
32
|
+
KIT_ATTR_PILL,
|
|
33
|
+
KIT_ATTR_REST,
|
|
34
|
+
KIT_ATTR_TASK,
|
|
35
|
+
KIT_ATTR_TODAY,
|
|
36
|
+
KIT_ATTR_TODAY_DOT,
|
|
37
|
+
KIT_ATTR_TODAY_TICK,
|
|
38
|
+
KIT_ATTR_VIEW,
|
|
39
|
+
kitAttrSel,
|
|
40
|
+
} from '../shared/dom-attrs';
|
|
41
|
+
import { KIT_FOCUS_RING, kitSelectedRecipe } from '../recipes/state';
|
|
42
|
+
import { KIT_TIP_ATTR, KIT_TIPS_SCOPE_ATTR } from '../base/hint-tips';
|
|
43
|
+
import { releaseReasonTipsIn } from '../base/reason-tip';
|
|
44
|
+
import { bool, createKitController, joinClass, num, preserveKitScroll, str } from '../base/shared';
|
|
23
45
|
import { kitText } from '../i18n/kit-text';
|
|
46
|
+
import { setKitFace } from '../recipes';
|
|
47
|
+
import { markKitEdge } from '../recipes/surface-edge';
|
|
24
48
|
import { kitTypographyRecipe } from '../recipes/typography';
|
|
25
49
|
import { mergeClass } from '../shared/merge-class';
|
|
26
|
-
import {
|
|
50
|
+
import { kitSegmentRecipe } from '../recipes/control';
|
|
51
|
+
import { kitActionRecipe } from '../recipes/emphasis';
|
|
52
|
+
import {
|
|
53
|
+
KIT_COLOR_ROLE_CLASS_CANDIDATES,
|
|
54
|
+
kitReadHostAutoSequence,
|
|
55
|
+
kitResolveStatusOrCategoryTone,
|
|
56
|
+
kitToneDotClass,
|
|
57
|
+
type KitResolvedTone,
|
|
58
|
+
} from '../recipes/color-role';
|
|
59
|
+
import { KIT_SKELETON_BAR_LINE, KIT_SKELETON_BAR_SHORT } from '../recipes/placeholder';
|
|
60
|
+
import { kitIcon } from '../shared/icons';
|
|
61
|
+
import { applyKitReadState, KIT_READ_STATE_EMIT_DEFS, KIT_READ_STATE_PROP_DEFS } from '../base/state-panel';
|
|
62
|
+
import { KIT_DIVIDER_HEAD_CLASS, kitDashedEdgeRecipe, kitDividerRecipe } from '../recipes/divider';
|
|
27
63
|
import {
|
|
28
64
|
GANTT_BAR_LABEL_MAX, GANTT_CHART_FALLBACK_PX, GANTT_LABEL_COLUMN_PX, GANTT_NOTE_MAX,
|
|
29
65
|
ganttBarLabelPlace, ganttBaselineBox, ganttIsNarrow, ganttTextWidthPx,
|
|
@@ -48,12 +84,14 @@ export interface KitGanttMap {
|
|
|
48
84
|
base_end: string;
|
|
49
85
|
/** 组标题行附注(取组内第一个非空值) */
|
|
50
86
|
group_note: string;
|
|
87
|
+
/** 显式延期标记(布尔);缺省按「今日已过结束日且进度未满」推断 */
|
|
88
|
+
delayed: string;
|
|
51
89
|
}
|
|
52
90
|
|
|
53
91
|
export const KIT_GANTT_DEFAULT_MAP: Readonly<KitGanttMap> = Object.freeze({
|
|
54
92
|
id: 'id', title: 'title', start: 'start', end: 'end', progress: 'progress',
|
|
55
93
|
group: 'group', deps: 'deps', tone: 'tone', owner: 'owner',
|
|
56
|
-
kind: 'kind', base_start: 'base_start', base_end: 'base_end', group_note: 'group_note',
|
|
94
|
+
kind: 'kind', base_start: 'base_start', base_end: 'base_end', group_note: 'group_note', delayed: 'delayed',
|
|
57
95
|
});
|
|
58
96
|
|
|
59
97
|
export type KitGanttTone = 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
|
@@ -215,20 +253,67 @@ function fx(n: number): string {
|
|
|
215
253
|
}
|
|
216
254
|
|
|
217
255
|
interface Row {
|
|
218
|
-
kind: 'group' | 'task';
|
|
256
|
+
kind: 'group' | 'task' | 'invalid';
|
|
219
257
|
group: string;
|
|
220
258
|
task?: KitGanttTask;
|
|
259
|
+
/** invalid 行:日期无效的任务标题(无条,只在左栏标记) */
|
|
260
|
+
title?: string;
|
|
221
261
|
/** 组标题行附注(组内第一个非空 group_note) */
|
|
222
262
|
note?: string;
|
|
223
263
|
}
|
|
224
264
|
|
|
265
|
+
/** 起止日期无效而被 parseGanttTasks 丢弃的任务标题(纯函数,供左栏用虚线空心标记列出;里程碑只看开始日) */
|
|
266
|
+
export function ganttInvalidTitles(data: unknown, map: KitGanttMap): string[] {
|
|
267
|
+
const out: string[] = [];
|
|
268
|
+
(Array.isArray(data) ? data : []).forEach((raw, index) => {
|
|
269
|
+
if (raw === null || typeof raw !== 'object') return;
|
|
270
|
+
const r = raw as Record<string, unknown>;
|
|
271
|
+
const milestone = str(r[map.kind]).trim() === 'milestone';
|
|
272
|
+
const ok = Number.isFinite(ganttDayIndex(r[map.start])) && (milestone || Number.isFinite(ganttDayIndex(r[map.end])));
|
|
273
|
+
if (!ok) out.push(str(r[map.title]).trim() || str(r[map.id]).trim() || `t${index}`);
|
|
274
|
+
});
|
|
275
|
+
return out;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** 延期:显式 delayed 为真,或今日已过结束日且进度未满(里程碑不算)。纯函数 */
|
|
279
|
+
export function ganttDelayed(task: KitGanttTask, delayedFlag: unknown, today: number): boolean {
|
|
280
|
+
if (task.milestone) return false;
|
|
281
|
+
if (delayedFlag === true) return true;
|
|
282
|
+
return Number.isFinite(today) && task.to < today && task.progress < 100;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** 上层刻度文字(与下层刻度逐段对齐):每段起点所在的「年-月」,与前一段相同则为空(月份换了才出) */
|
|
286
|
+
export function ganttUpperTicks(axis: KitGanttAxis, count: number): string[] {
|
|
287
|
+
const lower = ganttTicks(axis, count);
|
|
288
|
+
let last = '';
|
|
289
|
+
return lower.map((day) => {
|
|
290
|
+
const month = day.slice(0, 7);
|
|
291
|
+
if (month === last) return '';
|
|
292
|
+
last = month;
|
|
293
|
+
return month;
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** 今日落在第几段刻度(0 起);不在轴内为 -1 */
|
|
298
|
+
export function ganttTodayTick(axis: KitGanttAxis, count: number, today: number): number {
|
|
299
|
+
if (!Number.isFinite(today) || today < axis.from || today > axis.to) return -1;
|
|
300
|
+
const n = Math.min(10, Math.max(2, Math.floor(count)));
|
|
301
|
+
return Math.min(n - 1, Math.floor(((today - axis.from) / axis.span) * n));
|
|
302
|
+
}
|
|
303
|
+
|
|
225
304
|
/** 行序:保持数据顺序;组名变化(非空)时在前面插一条分组行(附注取该组内第一个非空 group_note) */
|
|
226
305
|
export function ganttRows(tasks: readonly KitGanttTask[]): Row[] {
|
|
306
|
+
const firstNoteByGroup = new Map<string, string>();
|
|
307
|
+
for (const t of tasks) {
|
|
308
|
+
if (t.group !== '' && t.groupNote !== '' && !firstNoteByGroup.has(t.group)) {
|
|
309
|
+
firstNoteByGroup.set(t.group, t.groupNote);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
227
312
|
const rows: Row[] = [];
|
|
228
313
|
let last = '';
|
|
229
314
|
for (const task of tasks) {
|
|
230
315
|
if (task.group !== '' && task.group !== last) {
|
|
231
|
-
const note =
|
|
316
|
+
const note = firstNoteByGroup.get(task.group) ?? '';
|
|
232
317
|
rows.push({ kind: 'group', group: task.group, ...(note !== '' ? { note } : {}) });
|
|
233
318
|
}
|
|
234
319
|
if (task.group !== '') last = task.group;
|
|
@@ -239,40 +324,86 @@ export function ganttRows(tasks: readonly KitGanttTask[]): Row[] {
|
|
|
239
324
|
|
|
240
325
|
// ── 类串常量与 Tailwind 候选清单 ──
|
|
241
326
|
|
|
242
|
-
|
|
243
|
-
const
|
|
327
|
+
// 横向在根里滚(不写硬 max-h-128 免得底行被裁半),表头贴顶(sticky top)、左栏任务名列贴边(sticky start),与 ScheduleGrid 的 sticky 表头 / 首列同一做法
|
|
328
|
+
const ROOT_CLASS = mergeClass('@container flex w-full min-w-0 flex-col overflow-auto', kitTypographyRecipe('text'));
|
|
329
|
+
const INNER_CLASS = 'flex min-w-full w-max flex-col';
|
|
244
330
|
// 刻度头底线、刻度之间的竖线 = 分隔线出口(发丝宽、分隔灰,KT-B1 / KT-B5)
|
|
245
331
|
const TICK_LINE = kitDividerRecipe('start');
|
|
246
|
-
const HEAD_CLASS = `flex ${KIT_DIVIDER_HEAD_CLASS}`;
|
|
247
|
-
// 左栏宽:在紧凑密度下保持充裕宽度(w-64
|
|
248
|
-
|
|
332
|
+
const HEAD_CLASS = `sticky top-0 z-20 flex bg-surface ${KIT_DIVIDER_HEAD_CLASS}`;
|
|
333
|
+
// 左栏宽:在紧凑密度下保持充裕宽度(w-64),窄屏(@max-sm)收窄为 w-44 留出时间轴视口;行头任务名有最小宽,状态 / 负责人附注截断在自己的上限内
|
|
334
|
+
// 侧头 = 视图切换(日 / 周 / 月)+「今天」钮;与左栏同宽、贴边
|
|
335
|
+
const CORNER_CLASS = mergeClass(mergeClass(mergeClass('sticky start-0 z-10 flex w-64 @max-sm:w-44 shrink-0 flex-wrap items-center gap-2 bg-surface px-3 py-1', kitDividerRecipe('end')), kitTypographyRecipe('menuGroup')), 'text-fg-muted');
|
|
336
|
+
const VIEWS_CLASS = 'inline-flex items-center gap-1';
|
|
337
|
+
const VIEW_BTN_OFF = kitSegmentRecipe(false);
|
|
338
|
+
const VIEW_BTN_ON = kitSegmentRecipe(true);
|
|
339
|
+
const TODAY_BTN_CLASS = kitActionRecipe('more', { tight: true, size: 'sm', region: 'toolbar' });
|
|
340
|
+
// 两层刻度:上层 = 月(换月才出字)、下层 = 刻度日;单格保最小宽 + 不折行,防止窄屏下日期刻度被挤断成两行
|
|
341
|
+
const TIERS_CLASS = 'flex min-w-0 flex-1 flex-col';
|
|
342
|
+
const UPPER_CLASS = 'flex';
|
|
343
|
+
const UPPER_CELL_CLASS = mergeClass(mergeClass('min-w-28 flex-1 truncate whitespace-nowrap px-2 pt-1.5 tabular-nums', kitTypographyRecipe('menuGroup')), 'text-fg');
|
|
249
344
|
const TICKS_CLASS = 'flex flex-1';
|
|
250
|
-
const TICK_CLASS =
|
|
345
|
+
const TICK_CLASS = mergeClass(mergeClass('min-w-28 flex-1 whitespace-nowrap px-2 py-1 tabular-nums', TICK_LINE), kitTypographyRecipe('captionPlain'));
|
|
346
|
+
const TICK_TODAY_CLASS = mergeClass(TICK_CLASS, kitSelectedRecipe());
|
|
251
347
|
const BODY_CLASS = 'flex';
|
|
252
|
-
const LABELS_CLASS = 'flex w-64 shrink-0 flex-col';
|
|
253
|
-
const
|
|
254
|
-
const
|
|
255
|
-
const
|
|
256
|
-
const
|
|
257
|
-
const
|
|
258
|
-
const
|
|
348
|
+
const LABELS_CLASS = mergeClass('sticky start-0 z-10 flex w-64 @max-sm:w-44 shrink-0 flex-col bg-surface', kitDividerRecipe('end'));
|
|
349
|
+
const DELAY_ICON_CLASS = 'shrink-0 text-danger-on-soft';
|
|
350
|
+
const GROUP_DOT_BASE = 'size-status-dot shrink-0 rounded-full';
|
|
351
|
+
const INVALID_ROW_CLASS = mergeClass('flex h-8 items-center gap-2 px-3', kitTypographyRecipe('textMuted'));
|
|
352
|
+
const INVALID_TITLE_CLASS = 'min-w-0 flex-1 truncate';
|
|
353
|
+
const INVALID_PILL_CLASS = mergeClass(mergeClass(mergeClass('shrink-0 px-2', kitDashedEdgeRecipe()), mergeClass(kitTypographyRecipe('captionPlain'), 'text-fg-muted')), GROUP_DOT_BASE).replace('size-status-dot ', '');
|
|
354
|
+
const SKELETON_ROWS_CLASS = 'flex flex-col gap-2 p-2';
|
|
355
|
+
const SKELETON_ROW_CLASS = 'flex items-center gap-2';
|
|
356
|
+
const TODAY_DOT_CLASS = 'fill-danger';
|
|
357
|
+
const DELAY_BAR_CLASS = 'stroke-danger';
|
|
358
|
+
const ROW_BTN_CLASS = mergeClass(mergeClass('flex h-8 w-full items-center gap-2 px-3 text-start transition-colors hover:bg-state-layer-hover active:bg-state-layer-press', kitTypographyRecipe('text')), KIT_FOCUS_RING.item);
|
|
359
|
+
const ROW_TITLE_CLASS = 'min-w-28 @max-sm:min-w-20 flex-1 truncate';
|
|
360
|
+
const ROW_OWNER_CLASS = mergeClass('min-w-0 max-w-20 truncate', kitTypographyRecipe('captionPlain'));
|
|
361
|
+
const GROUP_ROW_CLASS = mergeClass(mergeClass('flex h-8 items-center gap-2 overflow-hidden whitespace-nowrap bg-surface-band px-3', kitTypographyRecipe('menuGroup')), 'text-fg-muted');
|
|
362
|
+
const CHART_CLASS = 'relative min-w-0 flex-1';
|
|
363
|
+
const CHART_EDIT_CLASS = 'relative min-w-0 flex-1 select-none touch-none';
|
|
364
|
+
const SVG_CLASS = mergeClass('absolute inset-0 h-full w-full', KIT_FOCUS_RING.item);
|
|
259
365
|
const EMPTY_CLASS = 'px-3 py-6 text-center text-fg-muted';
|
|
260
366
|
|
|
261
|
-
// 任务条 =
|
|
262
|
-
const TRACK_CLASS: Record<
|
|
367
|
+
// 任务条 = 语义或分类浅色填充、无描边、胶囊圆角;进度段用同色系实心色
|
|
368
|
+
const TRACK_CLASS: Record<KitResolvedTone, string> = {
|
|
263
369
|
primary: 'fill-primary-soft',
|
|
264
370
|
success: 'fill-success-soft',
|
|
265
371
|
warning: 'fill-warning-soft',
|
|
266
372
|
danger: 'fill-danger-soft',
|
|
267
373
|
info: 'fill-info-soft',
|
|
374
|
+
tertiary: 'fill-tertiary-soft',
|
|
375
|
+
second: 'fill-second-soft',
|
|
376
|
+
neutral: 'fill-fg-subtle/20',
|
|
377
|
+
c1: 'fill-chart-1/20',
|
|
378
|
+
c2: 'fill-chart-2/20',
|
|
379
|
+
c3: 'fill-chart-3/20',
|
|
380
|
+
c4: 'fill-chart-4/20',
|
|
381
|
+
c5: 'fill-chart-5/20',
|
|
382
|
+
c6: 'fill-chart-6/20',
|
|
383
|
+
c7: 'fill-chart-7/20',
|
|
384
|
+
c8: 'fill-chart-8/20',
|
|
268
385
|
};
|
|
269
|
-
const DONE_CLASS: Record<
|
|
386
|
+
const DONE_CLASS: Record<KitResolvedTone, string> = {
|
|
270
387
|
primary: 'fill-primary',
|
|
271
388
|
success: 'fill-success',
|
|
272
389
|
warning: 'fill-warning',
|
|
273
390
|
danger: 'fill-danger',
|
|
274
391
|
info: 'fill-info',
|
|
392
|
+
tertiary: 'fill-tertiary',
|
|
393
|
+
second: 'fill-second',
|
|
394
|
+
neutral: 'fill-fg-muted',
|
|
395
|
+
c1: 'fill-chart-1',
|
|
396
|
+
c2: 'fill-chart-2',
|
|
397
|
+
c3: 'fill-chart-3',
|
|
398
|
+
c4: 'fill-chart-4',
|
|
399
|
+
c5: 'fill-chart-5',
|
|
400
|
+
c6: 'fill-chart-6',
|
|
401
|
+
c7: 'fill-chart-7',
|
|
402
|
+
c8: 'fill-chart-8',
|
|
275
403
|
};
|
|
404
|
+
const GANTT_DOT_CANDIDATES: string = (
|
|
405
|
+
['neutral', 'primary', 'info', 'success', 'warning', 'danger', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8'] as const
|
|
406
|
+
).map((t) => kitToneDotClass(t)).join(' ');
|
|
276
407
|
const GROUP_BG_CLASS = 'fill-surface-band';
|
|
277
408
|
const GRID_LINE_CLASS = 'stroke-border-subtle';
|
|
278
409
|
const DEP_LINE_CLASS = 'fill-none stroke-fg-subtle';
|
|
@@ -280,22 +411,32 @@ const DEP_ARROW_CLASS = 'fill-fg-subtle';
|
|
|
280
411
|
const TODAY_CLASS = 'stroke-danger';
|
|
281
412
|
/** 休息日底纹 / 基线幽灵条 / 条上文字(条内 / 外置)/ 里程碑字形 / 组附注;文字叠加层是不带 viewBox 的第二张 SVG(文字不随非等比 viewBox 变形) */
|
|
282
413
|
// 颜色自带透明度(fill-x/50),不用 opacity-50:后者是 G101 disabledOpacity 类族(禁用态不透明度),这里是图形底纹
|
|
283
|
-
const REST_DAY_CLASS = 'fill-surface-
|
|
414
|
+
const REST_DAY_CLASS = 'fill-surface-band'; // 休息日带 = 节的淡底带(KT-HB-F),不是井
|
|
284
415
|
const BASELINE_CLASS = 'fill-fg-subtle/50';
|
|
285
416
|
// 条内文字压在进度实心色 / 浅轨两种底上:用面板色描边做光晕(paint-order 先描边后填充),任何底色上都可读
|
|
286
417
|
const LABEL_IN_CLASS = mergeClass('fill-fg stroke-surface stroke-2', kitTypographyRecipe('deltaSm'));
|
|
287
418
|
const LABEL_OUT_CLASS = mergeClass('fill-fg-muted', kitTypographyRecipe('captionPlain'));
|
|
288
419
|
const MILESTONE_GLYPH_CLASS = kitTypographyRecipe('text');
|
|
420
|
+
const TASK_BAR_CLASS = mergeClass('cursor-pointer', KIT_FOCUS_RING.item);
|
|
421
|
+
const TASK_BAR_EDIT_CLASS = mergeClass('cursor-grab active:cursor-grabbing', KIT_FOCUS_RING.item);
|
|
422
|
+
const MILESTONE_HIT_CLASS = mergeClass('pointer-events-auto cursor-pointer', KIT_FOCUS_RING.item);
|
|
423
|
+
const MILESTONE_EDIT_HIT_CLASS = mergeClass('pointer-events-auto cursor-grab active:cursor-grabbing', KIT_FOCUS_RING.item);
|
|
424
|
+
const HANDLE_CLASS = 'cursor-ew-resize fill-transparent hover:fill-fg/15';
|
|
289
425
|
const OVERLAY_SVG_CLASS = 'pointer-events-none absolute inset-0 h-full w-full';
|
|
290
|
-
const GROUP_NOTE_CLASS = 'ms-auto min-w-0 truncate font-normal text-fg-subtle';
|
|
426
|
+
const GROUP_NOTE_CLASS = 'ms-auto min-w-0 truncate font-normal tabular-nums text-fg-subtle';
|
|
291
427
|
const MILESTONE_GLYPH = '◆';
|
|
292
428
|
|
|
293
429
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
294
430
|
export const KIT_GANTT_CLASS_CANDIDATES: readonly string[] = Object.freeze(
|
|
295
431
|
[...new Set([
|
|
296
432
|
ROOT_CLASS, INNER_CLASS, HEAD_CLASS, CORNER_CLASS, TICKS_CLASS, TICK_CLASS, BODY_CLASS, LABELS_CLASS, ROW_BTN_CLASS,
|
|
297
|
-
|
|
298
|
-
|
|
433
|
+
VIEWS_CLASS, VIEW_BTN_OFF, VIEW_BTN_ON, TODAY_BTN_CLASS, TIERS_CLASS, UPPER_CLASS, UPPER_CELL_CLASS, TICK_TODAY_CLASS, DELAY_ICON_CLASS,
|
|
434
|
+
INVALID_ROW_CLASS, INVALID_TITLE_CLASS, INVALID_PILL_CLASS, SKELETON_ROWS_CLASS, SKELETON_ROW_CLASS, KIT_SKELETON_BAR_LINE, KIT_SKELETON_BAR_SHORT, TODAY_DOT_CLASS, DELAY_BAR_CLASS,
|
|
435
|
+
ROW_TITLE_CLASS, ROW_OWNER_CLASS, GROUP_ROW_CLASS, CHART_CLASS, CHART_EDIT_CLASS, SVG_CLASS, EMPTY_CLASS,
|
|
436
|
+
REST_DAY_CLASS, BASELINE_CLASS, LABEL_IN_CLASS, LABEL_OUT_CLASS, MILESTONE_GLYPH_CLASS,
|
|
437
|
+
TASK_BAR_CLASS, TASK_BAR_EDIT_CLASS, MILESTONE_HIT_CLASS, MILESTONE_EDIT_HIT_CLASS, HANDLE_CLASS,
|
|
438
|
+
OVERLAY_SVG_CLASS, GROUP_NOTE_CLASS,
|
|
439
|
+
GROUP_DOT_BASE, GANTT_DOT_CANDIDATES, ...KIT_COLOR_ROLE_CLASS_CANDIDATES,
|
|
299
440
|
...Object.values(TRACK_CLASS), ...Object.values(DONE_CLASS),
|
|
300
441
|
GROUP_BG_CLASS, GRID_LINE_CLASS, DEP_LINE_CLASS, DEP_ARROW_CLASS, TODAY_CLASS,
|
|
301
442
|
].flatMap((s) => s.split(/\s+/)).filter((c) => c !== ''))].sort(),
|
|
@@ -328,17 +469,54 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
328
469
|
tick_count: { type: 'number', default: DEFAULT_TICKS, desc: '表头刻度段数,2–10' },
|
|
329
470
|
show_progress: { type: 'boolean', default: true, desc: '是否画进度' },
|
|
330
471
|
empty_text: { type: 'string', default: '', desc: '无任务时的空态文案;缺省取内置文案(按页面语言)' },
|
|
472
|
+
views: { type: 'array', default: [], desc: '侧头的视图粒度切换项 [value | { value, label }](如 day / week / month);空则不画切换。组件只抛 view_change,粒度换算由页面决定' },
|
|
473
|
+
view: { type: 'string', default: '', desc: '当前视图粒度(views 里的 value,选中态)' },
|
|
474
|
+
today_button: { type: 'boolean', default: false, desc: '侧头出「今天」钮,点击抛 today(页面决定滚动 / 换轴)' },
|
|
475
|
+
editable: { type: 'boolean', default: false, desc: '允许拖拽任务条整体平移或拖左右两端调整起止日期,松手抛 reschedule 与 change' },
|
|
476
|
+
delay_label: { type: 'string', default: '', desc: '延期标记文案(缺省取内置「已逾期」,写了则覆盖):延期任务(map.delayed 为真,或今日已过结束日且进度未满)在左栏行加警示图标并把文案写进读屏名与悬停提示,条加描边;延期不单靠颜色表达' },
|
|
477
|
+
invalid_label: { type: 'string', default: '', desc: '日期无效任务的标记文案(缺省取内置「日期无效」,写了则覆盖):在列表末尾以虚线胶囊标出这些任务(它们没有条)' },
|
|
478
|
+
...KIT_READ_STATE_PROP_DEFS,
|
|
331
479
|
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
332
480
|
},
|
|
333
481
|
emits: {
|
|
334
482
|
pick: { payload: { id: { type: 'string' }, item: { type: 'object' } }, desc: '点某一行任务;item 是源数据里的原对象' },
|
|
483
|
+
reschedule: {
|
|
484
|
+
payload: { id: { type: 'string' }, start: { type: 'string' }, end: { type: 'string' }, item: { type: 'object' } },
|
|
485
|
+
desc: 'editable 为真时拖拽调整某一行排期后抛出(item 为更新起止日期后的行对象)',
|
|
486
|
+
},
|
|
487
|
+
change: {
|
|
488
|
+
payload: { value: { type: 'array' }, data: { type: 'array' }, id: { type: 'string' }, start: { type: 'string' }, end: { type: 'string' } },
|
|
489
|
+
desc: 'editable 为真时拖拽改期后抛出的更新后完整任务列表与当前变更项',
|
|
490
|
+
},
|
|
491
|
+
view_change: { payload: { view: { type: 'string' } }, desc: '点侧头的视图粒度切换项(views 非空时)' },
|
|
492
|
+
today: { payload: {}, desc: '点侧头的「今天」钮(today_button 为真时)' },
|
|
493
|
+
...KIT_READ_STATE_EMIT_DEFS,
|
|
335
494
|
},
|
|
336
495
|
},
|
|
337
496
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
338
497
|
controllerFactory: createKitController((api) => {
|
|
339
498
|
const P = (): Record<string, unknown> => api.props();
|
|
499
|
+
interface DragSession {
|
|
500
|
+
pointerId: number;
|
|
501
|
+
id: string;
|
|
502
|
+
mode: 'move' | 'start' | 'end';
|
|
503
|
+
milestone: boolean;
|
|
504
|
+
origFrom: number;
|
|
505
|
+
origTo: number;
|
|
506
|
+
curFrom: number;
|
|
507
|
+
curTo: number;
|
|
508
|
+
startX: number;
|
|
509
|
+
chartWidth: number;
|
|
510
|
+
axis: KitGanttAxis;
|
|
511
|
+
moved: boolean;
|
|
512
|
+
}
|
|
340
513
|
let root: HTMLElement | null = null;
|
|
341
514
|
let tasks: KitGanttTask[] = [];
|
|
515
|
+
let taskById = new Map<string, KitGanttTask>();
|
|
516
|
+
let activeDrag: DragSession | null = null;
|
|
517
|
+
let lastAxis: KitGanttAxis | null = null;
|
|
518
|
+
let lastChartEl: HTMLElement | null = null;
|
|
519
|
+
let suppressNextClick = false;
|
|
342
520
|
|
|
343
521
|
const el = <K extends keyof HTMLElementTagNameMap>(tag: K, className: string, text?: string): HTMLElementTagNameMap[K] => {
|
|
344
522
|
const node = document.createElement(tag);
|
|
@@ -347,7 +525,53 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
347
525
|
return node;
|
|
348
526
|
};
|
|
349
527
|
|
|
350
|
-
const
|
|
528
|
+
const taskLabelOf = (t: KitGanttTask, showProgress: boolean, delayed: ReadonlySet<string>, delayLabel: string, at: Element | null): string => {
|
|
529
|
+
const pct = showProgress && !t.milestone ? kitText('soma.kit.gantt_done', { n: Math.round(t.progress) }, at) : '';
|
|
530
|
+
const ownerPart = t.owner !== '' ? ` ${t.owner}` : '';
|
|
531
|
+
const baseText = t.base !== null ? kitText('soma.kit.gantt_baseline', { start: ganttDayText(t.base.from), end: ganttDayText(t.base.to) }, at) : '';
|
|
532
|
+
const late = delayed.has(t.id);
|
|
533
|
+
return `${t.milestone
|
|
534
|
+
? `${kitText('soma.kit.gantt_milestone', { title: t.title, date: t.startText }, at)}${ownerPart}`
|
|
535
|
+
: `${kitText('soma.kit.gantt_range', { title: t.title, owner: ownerPart, start: t.startText, end: t.endText, pct }, at)}${baseText}`}${late ? `,${delayLabel}` : ''}`;
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
const resolveGanttTaskTone = (
|
|
539
|
+
t: KitGanttTask,
|
|
540
|
+
map: KitGanttMap,
|
|
541
|
+
groupOrder: ReadonlyMap<string, number>,
|
|
542
|
+
rowIdx: number,
|
|
543
|
+
autoSeq: readonly number[] | undefined,
|
|
544
|
+
): KitResolvedTone => {
|
|
545
|
+
const seqOpt = autoSeq !== undefined ? { autoSequence: autoSeq } : { host: root };
|
|
546
|
+
const rawObj = (t.raw !== null && typeof t.raw === 'object' ? t.raw : {}) as Record<string, unknown>;
|
|
547
|
+
const explicitRaw = str(rawObj[map.tone]).trim();
|
|
548
|
+
if (explicitRaw !== '') {
|
|
549
|
+
return kitResolveStatusOrCategoryTone(t.title, rowIdx, { explicitTone: explicitRaw, ...seqOpt });
|
|
550
|
+
}
|
|
551
|
+
if (t.progress >= 100) return 'success';
|
|
552
|
+
const statusText = str(rawObj.status ?? rawObj.state).trim();
|
|
553
|
+
if (statusText !== '' || t.milestone) {
|
|
554
|
+
const hit = kitResolveStatusOrCategoryTone(statusText || t.title, groupOrder.get(t.group) ?? rowIdx, seqOpt);
|
|
555
|
+
if (hit === 'success' || hit === 'warning' || hit === 'danger' || hit === 'info') return hit;
|
|
556
|
+
if (t.milestone) return hit;
|
|
557
|
+
}
|
|
558
|
+
const gIdx = t.group !== '' ? (groupOrder.get(t.group) ?? 0) : rowIdx;
|
|
559
|
+
return kitResolveStatusOrCategoryTone(t.group || t.title, gIdx, { preferHash: true, ...seqOpt });
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
const buildChart = (
|
|
563
|
+
rows: readonly Row[],
|
|
564
|
+
axis: KitGanttAxis,
|
|
565
|
+
p: Record<string, unknown>,
|
|
566
|
+
narrow: boolean,
|
|
567
|
+
delayed: ReadonlySet<string>,
|
|
568
|
+
delayLabel: string,
|
|
569
|
+
map: KitGanttMap,
|
|
570
|
+
groupOrder: ReadonlyMap<string, number>,
|
|
571
|
+
autoSeq: readonly number[] | undefined,
|
|
572
|
+
editable: boolean,
|
|
573
|
+
chartPx: number,
|
|
574
|
+
): SVGElement => {
|
|
351
575
|
const n = rows.length;
|
|
352
576
|
const svg = svgEl('svg', { viewBox: `0 0 100 ${n}`, preserveAspectRatio: 'none', 'aria-hidden': 'true' }, SVG_CLASS);
|
|
353
577
|
const line = (x1: number, y1: number, x2: number, y2: number, cls: string): SVGElement =>
|
|
@@ -358,7 +582,7 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
358
582
|
});
|
|
359
583
|
// 休息日底纹:轴内的休息日连续合并成一块,铺满全部行(在分隔线与条之下)
|
|
360
584
|
for (const [a, b] of restRuns(p.rest_days, axis)) {
|
|
361
|
-
svg.appendChild(svgEl('rect', { x: fx(((a - axis.from) / axis.span) * 100), y: '0', width: fx(((b - a + 1) / axis.span) * 100), height: fx(n),
|
|
585
|
+
svg.appendChild(svgEl('rect', { x: fx(((a - axis.from) / axis.span) * 100), y: '0', width: fx(((b - a + 1) / axis.span) * 100), height: fx(n), [KIT_ATTR_REST]: '' }, REST_DAY_CLASS));
|
|
362
586
|
}
|
|
363
587
|
for (let i = 1; i < n; i += 1) svg.appendChild(line(0, i, 100, i, GRID_LINE_CLASS));
|
|
364
588
|
// 刻度竖线(与表头的等分段对齐)
|
|
@@ -374,17 +598,31 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
374
598
|
index.set(t.id, { row: i, x, w });
|
|
375
599
|
// 里程碑没有条:菱形字形与标签画在文字叠加层,这里只登记位置(依赖线仍可接到它)
|
|
376
600
|
if (t.milestone) return;
|
|
377
|
-
const
|
|
601
|
+
const tip = taskLabelOf(t, showProgress, delayed, delayLabel, root);
|
|
602
|
+
const g = svgEl('g', { [KIT_ATTR_BAR]: t.id, [KIT_ATTR_TASK]: t.id, [KIT_TIP_ATTR]: tip }, editable ? TASK_BAR_EDIT_CLASS : TASK_BAR_CLASS);
|
|
603
|
+
kitMarkDragging(g, activeDrag !== null && activeDrag.id === t.id);
|
|
378
604
|
// 基线幽灵条:现计划条下方的细灰条(窄宽降级时不画)
|
|
379
605
|
if (t.base !== null && !narrow) {
|
|
380
606
|
const box = ganttBaselineBox(BAR_TOP, BAR_HEIGHT);
|
|
381
607
|
const bx = ((t.base.from - axis.from) / axis.span) * 100;
|
|
382
608
|
const bw = ((t.base.to - t.base.from + 1) / axis.span) * 100;
|
|
383
|
-
g.appendChild(svgEl('rect', { x: fx(bx), y: fx(i + box.y), width: fx(bw), height: fx(box.h),
|
|
609
|
+
g.appendChild(svgEl('rect', { x: fx(bx), y: fx(i + box.y), width: fx(bw), height: fx(box.h), [KIT_ATTR_BASELINE]: t.id }, BASELINE_CLASS));
|
|
384
610
|
}
|
|
385
|
-
|
|
611
|
+
// 延期不单靠颜色:条另加虚线描边(图标与文案在左栏行上)
|
|
612
|
+
const late = delayed.has(t.id);
|
|
613
|
+
const resolvedTone = resolveGanttTaskTone(t, map, groupOrder, i, autoSeq);
|
|
614
|
+
g.appendChild(svgEl(
|
|
615
|
+
'rect',
|
|
616
|
+
{ x: fx(x), y: fx(i + BAR_TOP), width: fx(w), height: fx(BAR_HEIGHT), [KIT_ATTR_PILL]: '', ...(late ? { [KIT_ATTR_DELAYED]: '', 'stroke-width': '1', 'stroke-dasharray': '3 2', 'vector-effect': 'non-scaling-stroke' } : {}) },
|
|
617
|
+
late ? `${TRACK_CLASS[resolvedTone]} ${DELAY_BAR_CLASS}` : TRACK_CLASS[resolvedTone],
|
|
618
|
+
));
|
|
386
619
|
if (showProgress && t.progress > 0) {
|
|
387
|
-
g.appendChild(svgEl('rect', { x: fx(x), y: fx(i + BAR_TOP), width: fx((w * t.progress) / 100), height: fx(BAR_HEIGHT),
|
|
620
|
+
g.appendChild(svgEl('rect', { x: fx(x), y: fx(i + BAR_TOP), width: fx((w * t.progress) / 100), height: fx(BAR_HEIGHT), [KIT_ATTR_PILL]: '' }, DONE_CLASS[resolvedTone]));
|
|
621
|
+
}
|
|
622
|
+
if (editable) {
|
|
623
|
+
const hw = Math.min(Math.max((10 / Math.max(chartPx, 1)) * 100, 0.8), Math.max(w * 0.28, 0.8));
|
|
624
|
+
g.appendChild(svgEl('rect', { x: fx(x), y: fx(i + BAR_TOP), width: fx(hw), height: fx(BAR_HEIGHT), [KIT_ATTR_GANTT_HANDLE]: 'start', [KIT_ATTR_TASK]: t.id }, HANDLE_CLASS));
|
|
625
|
+
g.appendChild(svgEl('rect', { x: fx(Math.max(x, x + w - hw)), y: fx(i + BAR_TOP), width: fx(hw), height: fx(BAR_HEIGHT), [KIT_ATTR_GANTT_HANDLE]: 'end', [KIT_ATTR_TASK]: t.id }, HANDLE_CLASS));
|
|
388
626
|
}
|
|
389
627
|
svg.appendChild(g);
|
|
390
628
|
});
|
|
@@ -425,8 +663,21 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
425
663
|
* 文字叠加层:第二张不带 viewBox 的 SVG(坐标全用百分比 + 像素偏移,文字不随主图的非等比 viewBox 变形)。
|
|
426
664
|
* 里程碑 = 菱形字形 + 标题(始终显示);条上文字 = 条内放得下画在条内(嵌套 svg 裁切),放不下外置到条右侧(右侧也放不下则左侧);窄宽不画条上文字。
|
|
427
665
|
*/
|
|
428
|
-
const buildOverlay = (
|
|
666
|
+
const buildOverlay = (
|
|
667
|
+
rows: readonly Row[],
|
|
668
|
+
axis: KitGanttAxis,
|
|
669
|
+
p: Record<string, unknown>,
|
|
670
|
+
chartPx: number,
|
|
671
|
+
narrow: boolean,
|
|
672
|
+
delayed: ReadonlySet<string>,
|
|
673
|
+
delayLabel: string,
|
|
674
|
+
map: KitGanttMap,
|
|
675
|
+
groupOrder: ReadonlyMap<string, number>,
|
|
676
|
+
autoSeq: readonly number[] | undefined,
|
|
677
|
+
editable: boolean,
|
|
678
|
+
): SVGElement | null => {
|
|
429
679
|
const mode = str(p.bar_label) === 'title' ? 'title' : str(p.bar_label) === 'owner' ? 'owner' : 'none';
|
|
680
|
+
const showProgress = p.show_progress !== false;
|
|
430
681
|
const n = rows.length;
|
|
431
682
|
const svg = svgEl('svg', { 'aria-hidden': 'true' }, OVERLAY_SVG_CLASS);
|
|
432
683
|
let any = false;
|
|
@@ -449,125 +700,388 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
449
700
|
const t = row.task;
|
|
450
701
|
const { x, w } = ganttBar(t, axis);
|
|
451
702
|
const y = ((i + 0.5) / n) * 100;
|
|
703
|
+
const draggingThis = activeDrag?.id === t.id;
|
|
452
704
|
if (t.milestone) {
|
|
453
705
|
const cx = x + w / 2;
|
|
454
|
-
|
|
706
|
+
const resolvedTone = resolveGanttTaskTone(t, map, groupOrder, i, autoSeq);
|
|
707
|
+
const tip = taskLabelOf(t, showProgress, delayed, delayLabel, root);
|
|
708
|
+
const hitCls = editable ? MILESTONE_EDIT_HIT_CLASS : MILESTONE_HIT_CLASS;
|
|
709
|
+
text(MILESTONE_GLYPH, { x: pct(cx), y: pct(y), 'text-anchor': 'middle', [KIT_ATTR_MILESTONE]: t.id, [KIT_ATTR_TASK]: t.id, [KIT_TIP_ATTR]: tip }, `${DONE_CLASS[resolvedTone]} ${MILESTONE_GLYPH_CLASS} ${hitCls}`);
|
|
455
710
|
// 菱形字形占约一个字宽:左右各留半字
|
|
456
711
|
const half = (ganttTextWidthPx(MILESTONE_GLYPH) / 2 / Math.max(chartPx, 1)) * 100;
|
|
457
|
-
|
|
712
|
+
const mileLabel = draggingThis ? `${t.title.slice(0, GANTT_BAR_LABEL_MAX)} · ${t.startText.slice(5)}` : t.title.slice(0, GANTT_BAR_LABEL_MAX);
|
|
713
|
+
beside(mileLabel, cx - half, cx + half, y, LABEL_OUT_CLASS);
|
|
458
714
|
return;
|
|
459
715
|
}
|
|
460
|
-
if (mode === 'none' || narrow) return;
|
|
461
|
-
const
|
|
716
|
+
if ((mode === 'none' && !draggingThis) || narrow) return;
|
|
717
|
+
const baseVal = mode === 'none' ? '' : (mode === 'owner' ? t.owner : t.title).slice(0, GANTT_BAR_LABEL_MAX);
|
|
718
|
+
const value = draggingThis
|
|
719
|
+
? `${baseVal !== '' ? `${baseVal} · ` : ''}${t.startText.slice(5)}~${t.endText.slice(5)}`
|
|
720
|
+
: baseVal;
|
|
462
721
|
if (value === '') return;
|
|
463
722
|
if (ganttBarLabelPlace(value, (w / 100) * chartPx) === 'inside') {
|
|
464
723
|
const box = svgEl('svg', { x: pct(x), y: pct((i / n) * 100), width: pct(w), height: pct(100 / n), overflow: 'hidden' });
|
|
465
|
-
const node = svgEl('text', { x: '6', dx: '6', y: '50%', 'dominant-baseline': 'central', 'paint-order': 'stroke', 'stroke-linejoin': 'round',
|
|
724
|
+
const node = svgEl('text', { x: '6', dx: '6', y: '50%', 'dominant-baseline': 'central', 'paint-order': 'stroke', 'stroke-linejoin': 'round', [KIT_ATTR_BAR_LABEL]: t.id }, LABEL_IN_CLASS);
|
|
466
725
|
node.textContent = value;
|
|
467
726
|
box.appendChild(node);
|
|
468
727
|
svg.appendChild(box);
|
|
469
728
|
any = true;
|
|
470
729
|
} else {
|
|
471
|
-
beside(value, x, x + w, y, LABEL_OUT_CLASS, {
|
|
730
|
+
beside(value, x, x + w, y, LABEL_OUT_CLASS, { [KIT_ATTR_BAR_LABEL]: t.id });
|
|
472
731
|
}
|
|
473
732
|
});
|
|
733
|
+
// 今日线顶端圆点(线在主图里;点在叠加层,半径用像素,不随非等比 viewBox 变椭圆)
|
|
734
|
+
const today = ganttDayIndex(p.today);
|
|
735
|
+
if (Number.isFinite(today) && today >= axis.from && today <= axis.to) {
|
|
736
|
+
svg.appendChild(svgEl('circle', { cx: pct(((today - axis.from + 0.5) / axis.span) * 100), cy: '4', r: '4', [KIT_ATTR_TODAY_DOT]: '' }, TODAY_DOT_CLASS));
|
|
737
|
+
any = true;
|
|
738
|
+
}
|
|
474
739
|
return any ? svg : null;
|
|
475
740
|
};
|
|
476
741
|
|
|
477
742
|
const paint = (): void => {
|
|
478
|
-
|
|
743
|
+
const rEl = root;
|
|
744
|
+
if (!rEl) return;
|
|
479
745
|
const p = P();
|
|
480
|
-
|
|
746
|
+
rEl.className = joinClass(ROOT_CLASS, p.class);
|
|
747
|
+
// 旧版:按祖先是不是面板决定画不画外框;新流水线下外观由取值表按层级角色给,组件不看祖先
|
|
748
|
+
if (!kitHasProps(p)) markKitEdge(rEl);
|
|
481
749
|
// 整块重建会丢焦点:记下聚焦的任务行,重建后还回去
|
|
482
|
-
const focused = document.activeElement instanceof HTMLElement &&
|
|
483
|
-
? document.activeElement.closest(
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
head.appendChild(el('div', CORNER_CLASS));
|
|
499
|
-
const ticks = el('div', TICKS_CLASS);
|
|
500
|
-
const tickCount = num(p.tick_count) ?? DEFAULT_TICKS;
|
|
501
|
-
for (const text of ganttTicks(axis, tickCount)) ticks.appendChild(el('div', TICK_CLASS, text));
|
|
502
|
-
head.appendChild(ticks);
|
|
503
|
-
inner.appendChild(head);
|
|
504
|
-
|
|
505
|
-
const body = el('div', BODY_CLASS);
|
|
506
|
-
const labels = el('div', LABELS_CLASS);
|
|
507
|
-
for (const row of rows) {
|
|
508
|
-
if (row.kind === 'group') {
|
|
509
|
-
const groupRow = el('div', GROUP_ROW_CLASS, row.group);
|
|
510
|
-
// 组标题行附注(如「共 8.5 人日 · 2 天超载」),取自数据
|
|
511
|
-
if (row.note !== undefined) groupRow.appendChild(el('span', GROUP_NOTE_CLASS, row.note));
|
|
512
|
-
labels.appendChild(groupRow);
|
|
513
|
-
continue;
|
|
750
|
+
const focused = document.activeElement instanceof HTMLElement && rEl.contains(document.activeElement)
|
|
751
|
+
? document.activeElement.closest(`button${kitAttrSel(KIT_ATTR_TASK)}`)?.getAttribute(KIT_ATTR_TASK) ?? null : null;
|
|
752
|
+
preserveKitScroll(rEl, () => {
|
|
753
|
+
releaseReasonTipsIn(rEl);
|
|
754
|
+
rEl.textContent = '';
|
|
755
|
+
const map = mapOf(p.map);
|
|
756
|
+
const editable = bool(p.editable);
|
|
757
|
+
tasks = parseGanttTasks(p.data, map);
|
|
758
|
+
if (activeDrag !== null) {
|
|
759
|
+
tasks = tasks.map((t) => (t.id === activeDrag!.id ? {
|
|
760
|
+
...t,
|
|
761
|
+
from: activeDrag!.curFrom,
|
|
762
|
+
to: activeDrag!.curTo,
|
|
763
|
+
startText: ganttDayText(activeDrag!.curFrom),
|
|
764
|
+
endText: ganttDayText(activeDrag!.curTo),
|
|
765
|
+
} : t));
|
|
514
766
|
}
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
767
|
+
taskById = new Map(tasks.map((t) => [t.id, t]));
|
|
768
|
+
const axis = activeDrag !== null ? activeDrag.axis : ganttAxis(tasks, p.start_date, p.end_date);
|
|
769
|
+
lastAxis = axis;
|
|
770
|
+
lastChartEl = null;
|
|
771
|
+
const hasContent = tasks.length > 0 && axis !== null;
|
|
772
|
+
// 读状态(错误 > 加载 > 内容):加载骨架 = 表头条 + 若干行灰条;错误态带重试
|
|
773
|
+
const skeleton = (): Node => {
|
|
774
|
+
const box = el('div', SKELETON_ROWS_CLASS);
|
|
775
|
+
box.appendChild(el('span', KIT_SKELETON_BAR_SHORT));
|
|
776
|
+
for (let i = 0; i < 4; i += 1) {
|
|
777
|
+
const line = el('div', SKELETON_ROW_CLASS);
|
|
778
|
+
line.appendChild(el('span', KIT_SKELETON_BAR_SHORT));
|
|
779
|
+
line.appendChild(el('span', KIT_SKELETON_BAR_LINE));
|
|
780
|
+
box.appendChild(line);
|
|
781
|
+
}
|
|
782
|
+
return box;
|
|
783
|
+
};
|
|
784
|
+
// 数据状态自报(每次渲染都写):与读状态面板同一判据,出错 > 加载 > 空;data-kit-state 面板标记照旧
|
|
785
|
+
kitMarkDataFacts(rEl, { error: str(p.error_text) !== '', loading: p.loading === true || p.loading === 'true', empty: !(hasContent) });
|
|
786
|
+
if (applyKitReadState(rEl, p, { hasContent, onRetry: () => api.emit('retry', {}), skeleton, repaint: () => api.refresh() })) return;
|
|
787
|
+
if (!hasContent || axis === null) {
|
|
788
|
+
const empty = el('div', EMPTY_CLASS, str(p.empty_text, kitText('soma.kit.empty_schedule', undefined, rEl)));
|
|
789
|
+
empty.setAttribute('role', 'status');
|
|
790
|
+
rEl.appendChild(empty);
|
|
791
|
+
return;
|
|
532
792
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
const chartPx = rootPx > 0 ? Math.max(rootPx - GANTT_LABEL_COLUMN_PX, 0) : GANTT_CHART_FALLBACK_PX;
|
|
541
|
-
chart.appendChild(buildChart(rows, axis, p, narrow) as unknown as Node);
|
|
542
|
-
const overlay = buildOverlay(rows, axis, p, chartPx, narrow);
|
|
543
|
-
if (overlay !== null) chart.appendChild(overlay as unknown as Node);
|
|
544
|
-
body.appendChild(chart);
|
|
545
|
-
inner.appendChild(body);
|
|
546
|
-
root.appendChild(inner);
|
|
547
|
-
// 胶囊圆角:主图是非等比 viewBox(x 每单位 = 图宽 / 100,y 每单位 = 一行高),圆角的 rx / ry 按实测折算成同一物理半径(半个条高);无布局环境(测不到)不画圆角
|
|
548
|
-
const rowPx = labels.querySelector('button')?.getBoundingClientRect().height ?? 0;
|
|
549
|
-
const chartW = chart.getBoundingClientRect().width;
|
|
550
|
-
if (rowPx > 0 && chartW > 0) {
|
|
551
|
-
for (const r of chart.querySelectorAll('[data-kit-pill]')) {
|
|
552
|
-
r.setAttribute('ry', fx(BAR_HEIGHT / 2));
|
|
553
|
-
r.setAttribute('rx', fx(((BAR_HEIGHT / 2) * rowPx) / (chartW / 100)));
|
|
793
|
+
const rows = ganttRows(tasks);
|
|
794
|
+
const showProgress = p.show_progress !== false;
|
|
795
|
+
const todayIdx = ganttDayIndex(p.today);
|
|
796
|
+
const delayLabel = str(p.delay_label, kitText('soma.kit.gantt_delayed', undefined, rEl));
|
|
797
|
+
const delayed = new Set<string>();
|
|
798
|
+
if (delayLabel !== '') {
|
|
799
|
+
for (const t of tasks) if (ganttDelayed(t, (t.raw as Record<string, unknown>)[map.delayed], todayIdx)) delayed.add(t.id);
|
|
554
800
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
801
|
+
const invalidLabel = str(p.invalid_label, kitText('soma.kit.gantt_invalid_date', undefined, rEl));
|
|
802
|
+
const invalid = invalidLabel !== '' ? ganttInvalidTitles(p.data, map) : [];
|
|
803
|
+
for (const title of invalid) rows.push({ kind: 'invalid', group: '', title });
|
|
804
|
+
const inner = el('div', INNER_CLASS);
|
|
805
|
+
|
|
806
|
+
const head = el('div', HEAD_CLASS);
|
|
807
|
+
const corner = el('div', CORNER_CLASS);
|
|
808
|
+
// 视图粒度缺省文案:day / week / month 取内置词条,其余用 value 本身;views 里写了 label 的优先
|
|
809
|
+
const builtinView = (value: string): string => {
|
|
810
|
+
if (value === 'day') return kitText('soma.kit.cal_day', undefined, rEl);
|
|
811
|
+
if (value === 'week') return kitText('soma.kit.cal_week', undefined, rEl);
|
|
812
|
+
if (value === 'month') return kitText('soma.kit.cal_month', undefined, rEl);
|
|
813
|
+
return value;
|
|
814
|
+
};
|
|
815
|
+
const viewItems = (Array.isArray(p.views) ? p.views : [])
|
|
816
|
+
.map((v) => (typeof v === 'string' ? { value: v, label: v } : { value: str((v as Record<string, unknown> | null)?.value), label: str((v as Record<string, unknown> | null)?.label) }))
|
|
817
|
+
.filter((v) => v.value !== '')
|
|
818
|
+
.map((v) => ({ value: v.value, label: v.label || builtinView(v.value) }));
|
|
819
|
+
if (viewItems.length > 0) {
|
|
820
|
+
const group = el('div', VIEWS_CLASS);
|
|
821
|
+
group.setAttribute('role', 'group');
|
|
822
|
+
const current = str(p.view);
|
|
823
|
+
for (const v of viewItems) {
|
|
824
|
+
const on = v.value === current;
|
|
825
|
+
const b = el('button', on ? VIEW_BTN_ON : VIEW_BTN_OFF, v.label);
|
|
826
|
+
b.type = 'button';
|
|
827
|
+
setKitFace(b, 'raised');
|
|
828
|
+
b.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
829
|
+
b.setAttribute(KIT_ATTR_VIEW, v.value);
|
|
830
|
+
group.appendChild(b);
|
|
831
|
+
}
|
|
832
|
+
corner.appendChild(group);
|
|
833
|
+
}
|
|
834
|
+
if (bool(p.today_button)) {
|
|
835
|
+
const b = el('button', TODAY_BTN_CLASS, kitText('soma.kit.cal_today', undefined, rEl));
|
|
836
|
+
b.type = 'button';
|
|
837
|
+
setKitFace(b, 'raised');
|
|
838
|
+
b.setAttribute(KIT_ATTR_TODAY, '');
|
|
839
|
+
corner.appendChild(b);
|
|
840
|
+
}
|
|
841
|
+
head.appendChild(corner);
|
|
842
|
+
// 时间轴表头带 = 面头(甘特自管布局,只自报到一级结构)
|
|
843
|
+
kitMarkLevel(head, 'head'); kitApplyLevelClass(head);
|
|
844
|
+
const tiers = el('div', TIERS_CLASS);
|
|
845
|
+
const tickCount = num(p.tick_count) ?? DEFAULT_TICKS;
|
|
846
|
+
const upper = el('div', UPPER_CLASS);
|
|
847
|
+
for (const text of ganttUpperTicks(axis, tickCount)) upper.appendChild(el('div', UPPER_CELL_CLASS, text));
|
|
848
|
+
tiers.appendChild(upper);
|
|
849
|
+
const ticks = el('div', TICKS_CLASS);
|
|
850
|
+
const todayTick = ganttTodayTick(axis, tickCount, todayIdx);
|
|
851
|
+
ganttTicks(axis, tickCount).forEach((text, i) => {
|
|
852
|
+
const cell = el('div', i === todayTick ? TICK_TODAY_CLASS : TICK_CLASS, text);
|
|
853
|
+
if (i === todayTick) cell.setAttribute(KIT_ATTR_TODAY_TICK, '');
|
|
854
|
+
ticks.appendChild(cell);
|
|
855
|
+
});
|
|
856
|
+
tiers.appendChild(ticks);
|
|
857
|
+
head.appendChild(tiers);
|
|
858
|
+
inner.appendChild(head);
|
|
859
|
+
|
|
860
|
+
const groupOrder = new Map<string, number>();
|
|
861
|
+
for (const row of rows) {
|
|
862
|
+
if (row.kind === 'group' && !groupOrder.has(row.group)) groupOrder.set(row.group, groupOrder.size);
|
|
863
|
+
}
|
|
864
|
+
const autoSeq = kitReadHostAutoSequence(rEl);
|
|
865
|
+
const body = el('div', BODY_CLASS);
|
|
866
|
+
const labels = el('div', LABELS_CLASS);
|
|
867
|
+
for (const row of rows) {
|
|
868
|
+
if (row.kind === 'group') {
|
|
869
|
+
const gTone = kitResolveStatusOrCategoryTone(row.group, groupOrder.get(row.group) ?? 0, {
|
|
870
|
+
preferHash: true,
|
|
871
|
+
...(autoSeq !== undefined ? { autoSequence: autoSeq } : { host: rEl }),
|
|
872
|
+
});
|
|
873
|
+
const groupRow = el('div', GROUP_ROW_CLASS);
|
|
874
|
+
// 分组行 = 淡底带
|
|
875
|
+
kitMarkLevel(groupRow, 'band'); kitApplyLevelClass(groupRow);
|
|
876
|
+
const gDot = el('span', mergeClass(GROUP_DOT_BASE, kitToneDotClass(gTone)));
|
|
877
|
+
gDot.setAttribute('aria-hidden', 'true');
|
|
878
|
+
groupRow.appendChild(gDot);
|
|
879
|
+
groupRow.appendChild(document.createTextNode(row.group));
|
|
880
|
+
// 组标题行附注(如「共 8.5 人日 · 2 天超载」),取自数据
|
|
881
|
+
if (row.note !== undefined) groupRow.appendChild(el('span', GROUP_NOTE_CLASS, row.note));
|
|
882
|
+
labels.appendChild(groupRow);
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
if (row.kind === 'invalid') {
|
|
886
|
+
// 日期无效:没有条,只在左栏用虚线胶囊标出(不静默丢弃)
|
|
887
|
+
const bad = el('div', INVALID_ROW_CLASS);
|
|
888
|
+
bad.setAttribute(KIT_ATTR_INVALID, '');
|
|
889
|
+
bad.appendChild(el('span', INVALID_TITLE_CLASS, row.title ?? ''));
|
|
890
|
+
bad.appendChild(el('span', INVALID_PILL_CLASS, invalidLabel));
|
|
891
|
+
labels.appendChild(bad);
|
|
892
|
+
continue;
|
|
893
|
+
}
|
|
894
|
+
const t = row.task!;
|
|
895
|
+
const btn = el('button', ROW_BTN_CLASS);
|
|
896
|
+
btn.type = 'button';
|
|
897
|
+
btn.setAttribute(KIT_ATTR_TASK, t.id);
|
|
898
|
+
// 任务行 = 集合条目;拖拽中的任务(拖动时整块重绘,按 activeDrag 重新自报)
|
|
899
|
+
kitMarkLevel(btn, 'item', 'line'); kitApplyLevelClass(btn);
|
|
900
|
+
kitMarkDragging(btn, activeDrag !== null && activeDrag.id === t.id);
|
|
901
|
+
const late = delayed.has(t.id);
|
|
902
|
+
const label = taskLabelOf(t, showProgress, delayed, delayLabel, rEl);
|
|
903
|
+
btn.setAttribute('aria-label', label);
|
|
904
|
+
// 悬停详情:同读屏名的一行(标题 / 起止 / 进度 / 延期)
|
|
905
|
+
btn.setAttribute(KIT_TIP_ATTR, label);
|
|
906
|
+
if (late) {
|
|
907
|
+
const icon = kitIcon('warning', 'xs', DELAY_ICON_CLASS);
|
|
908
|
+
icon.setAttribute(KIT_ATTR_DELAYED, '');
|
|
909
|
+
btn.appendChild(icon);
|
|
910
|
+
}
|
|
911
|
+
const rowTitle = el('span', ROW_TITLE_CLASS, t.title);
|
|
912
|
+
rowTitle.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
|
|
913
|
+
btn.appendChild(rowTitle);
|
|
914
|
+
if (t.owner !== '') {
|
|
915
|
+
const ownerNote = el('span', ROW_OWNER_CLASS, t.owner);
|
|
916
|
+
ownerNote.setAttribute(KIT_TIPS_SCOPE_ATTR, '');
|
|
917
|
+
btn.appendChild(ownerNote);
|
|
918
|
+
}
|
|
919
|
+
labels.appendChild(btn);
|
|
920
|
+
}
|
|
921
|
+
body.appendChild(labels);
|
|
922
|
+
const chart = el('div', editable ? CHART_EDIT_CLASS : CHART_CLASS);
|
|
923
|
+
if (editable) chart.setAttribute(KIT_ATTR_GANTT_CHART, '');
|
|
924
|
+
lastChartEl = chart;
|
|
925
|
+
// 容器宽:窄宽降级(不画条上文字与基线)与条上文字放得下与否的判定都用它;无布局环境(测不到)时用回落宽度
|
|
926
|
+
const rootPx = rEl.clientWidth;
|
|
927
|
+
const narrow = ganttIsNarrow(rootPx);
|
|
928
|
+
const chartPx = rootPx > 0 ? Math.max(rootPx - GANTT_LABEL_COLUMN_PX, 0) : GANTT_CHART_FALLBACK_PX;
|
|
929
|
+
chart.appendChild(buildChart(rows, axis, p, narrow, delayed, delayLabel, map, groupOrder, autoSeq, editable, chartPx) as unknown as Node);
|
|
930
|
+
const overlay = buildOverlay(rows, axis, p, chartPx, narrow, delayed, delayLabel, map, groupOrder, autoSeq, editable);
|
|
931
|
+
if (overlay !== null) chart.appendChild(overlay as unknown as Node);
|
|
932
|
+
body.appendChild(chart);
|
|
933
|
+
inner.appendChild(body);
|
|
934
|
+
rEl.appendChild(inner);
|
|
935
|
+
// 胶囊圆角:主图是非等比 viewBox(x 每单位 = 图宽 / 100,y 每单位 = 一行高),圆角的 rx / ry 按实测折算成同一物理半径(半个条高);无布局环境(测不到)不画圆角
|
|
936
|
+
const rowPx = labels.querySelector('button')?.getBoundingClientRect().height ?? 0;
|
|
937
|
+
const chartW = chart.getBoundingClientRect().width;
|
|
938
|
+
if (rowPx > 0 && chartW > 0) {
|
|
939
|
+
for (const r of chart.querySelectorAll(kitAttrSel(KIT_ATTR_PILL))) {
|
|
940
|
+
r.setAttribute('ry', fx(BAR_HEIGHT / 2));
|
|
941
|
+
r.setAttribute('rx', fx(((BAR_HEIGHT / 2) * rowPx) / (chartW / 100)));
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
if (focused !== null) {
|
|
945
|
+
[...labels.querySelectorAll<HTMLButtonElement>(`button${kitAttrSel(KIT_ATTR_TASK)}`)].find((b) => b.getAttribute(KIT_ATTR_TASK) === focused)?.focus({ preventScroll: true });
|
|
946
|
+
}
|
|
947
|
+
});
|
|
559
948
|
};
|
|
560
949
|
|
|
561
950
|
return {
|
|
562
951
|
attach(rootEl) {
|
|
563
952
|
root = rootEl;
|
|
564
953
|
const r = root;
|
|
954
|
+
const onMouseDown = (event: MouseEvent): void => {
|
|
955
|
+
if ((event.target as Element | null)?.closest('svg')) event.preventDefault();
|
|
956
|
+
};
|
|
957
|
+
const onPointerDown = (event: PointerEvent): void => {
|
|
958
|
+
if (!bool(P().editable)) return;
|
|
959
|
+
if (typeof event.button === 'number' && event.button !== 0) return;
|
|
960
|
+
const hit = event.target as Element | null;
|
|
961
|
+
if (!hit || !lastChartEl || !lastChartEl.contains(hit) || !lastAxis) return;
|
|
962
|
+
const handleEl = hit.closest(kitAttrSel(KIT_ATTR_GANTT_HANDLE));
|
|
963
|
+
const barEl = hit.closest(kitAttrSel(KIT_ATTR_BAR));
|
|
964
|
+
const mileEl = hit.closest(kitAttrSel(KIT_ATTR_MILESTONE));
|
|
965
|
+
const id = handleEl?.getAttribute(KIT_ATTR_TASK)
|
|
966
|
+
?? barEl?.getAttribute(KIT_ATTR_BAR)
|
|
967
|
+
?? mileEl?.getAttribute(KIT_ATTR_MILESTONE)
|
|
968
|
+
?? null;
|
|
969
|
+
if (!id) return;
|
|
970
|
+
const task = taskById.get(id);
|
|
971
|
+
if (!task) return;
|
|
972
|
+
const handleKind = handleEl?.getAttribute(KIT_ATTR_GANTT_HANDLE);
|
|
973
|
+
const mode: 'move' | 'start' | 'end' = task.milestone
|
|
974
|
+
? 'move'
|
|
975
|
+
: handleKind === 'start'
|
|
976
|
+
? 'start'
|
|
977
|
+
: handleKind === 'end'
|
|
978
|
+
? 'end'
|
|
979
|
+
: 'move';
|
|
980
|
+
const rect = lastChartEl.getBoundingClientRect();
|
|
981
|
+
const chartWidth = rect.width > 0 ? rect.width : GANTT_CHART_FALLBACK_PX;
|
|
982
|
+
activeDrag = {
|
|
983
|
+
pointerId: event.pointerId,
|
|
984
|
+
id: task.id,
|
|
985
|
+
mode,
|
|
986
|
+
milestone: task.milestone,
|
|
987
|
+
origFrom: task.from,
|
|
988
|
+
origTo: task.to,
|
|
989
|
+
curFrom: task.from,
|
|
990
|
+
curTo: task.to,
|
|
991
|
+
startX: event.clientX,
|
|
992
|
+
chartWidth,
|
|
993
|
+
axis: lastAxis,
|
|
994
|
+
moved: false,
|
|
995
|
+
};
|
|
996
|
+
event.preventDefault();
|
|
997
|
+
try { r.setPointerCapture?.(event.pointerId); } catch { /* ignore in synthetic env */ }
|
|
998
|
+
};
|
|
999
|
+
const onPointerMove = (event: PointerEvent): void => {
|
|
1000
|
+
if (!activeDrag || event.pointerId !== activeDrag.pointerId) return;
|
|
1001
|
+
const dx = event.clientX - activeDrag.startX;
|
|
1002
|
+
if (Math.abs(dx) >= 3) activeDrag.moved = true;
|
|
1003
|
+
const deltaDays = Math.round((dx / Math.max(activeDrag.chartWidth, 1)) * activeDrag.axis.span);
|
|
1004
|
+
let nextFrom = activeDrag.origFrom;
|
|
1005
|
+
let nextTo = activeDrag.origTo;
|
|
1006
|
+
if (activeDrag.mode === 'move') {
|
|
1007
|
+
nextFrom = activeDrag.origFrom + deltaDays;
|
|
1008
|
+
nextTo = activeDrag.origTo + deltaDays;
|
|
1009
|
+
} else if (activeDrag.mode === 'start') {
|
|
1010
|
+
nextFrom = Math.min(activeDrag.origTo, activeDrag.origFrom + deltaDays);
|
|
1011
|
+
} else {
|
|
1012
|
+
nextTo = Math.max(activeDrag.origFrom, activeDrag.origTo + deltaDays);
|
|
1013
|
+
}
|
|
1014
|
+
if (nextFrom !== activeDrag.curFrom || nextTo !== activeDrag.curTo) {
|
|
1015
|
+
activeDrag.curFrom = nextFrom;
|
|
1016
|
+
activeDrag.curTo = nextTo;
|
|
1017
|
+
paint();
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
const finishDrag = (event: PointerEvent, cancelled: boolean): void => {
|
|
1021
|
+
if (!activeDrag || event.pointerId !== activeDrag.pointerId) return;
|
|
1022
|
+
const d = activeDrag;
|
|
1023
|
+
activeDrag = null;
|
|
1024
|
+
try { r.releasePointerCapture?.(event.pointerId); } catch { /* ignore in synthetic env */ }
|
|
1025
|
+
if (d.moved || d.curFrom !== d.origFrom || d.curTo !== d.origTo) {
|
|
1026
|
+
suppressNextClick = true;
|
|
1027
|
+
setTimeout(() => { suppressNextClick = false; }, 0);
|
|
1028
|
+
}
|
|
1029
|
+
if (cancelled || (d.curFrom === d.origFrom && d.curTo === d.origTo)) {
|
|
1030
|
+
paint();
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
const p = P();
|
|
1034
|
+
const map = mapOf(p.map);
|
|
1035
|
+
const task = taskById.get(d.id);
|
|
1036
|
+
const newStart = ganttDayText(d.curFrom);
|
|
1037
|
+
const newEnd = ganttDayText(d.curTo);
|
|
1038
|
+
const rawList = Array.isArray(p.data) ? p.data : [];
|
|
1039
|
+
let updatedItem: Record<string, unknown> = {};
|
|
1040
|
+
const nextData = rawList.map((entry) => {
|
|
1041
|
+
if (task && entry === task.raw && entry !== null && typeof entry === 'object') {
|
|
1042
|
+
const baseObj = entry as Record<string, unknown>;
|
|
1043
|
+
const nextObj: Record<string, unknown> = {
|
|
1044
|
+
...baseObj,
|
|
1045
|
+
[map.start]: newStart,
|
|
1046
|
+
...(d.milestone && !(map.end in baseObj) ? {} : { [map.end]: newEnd }),
|
|
1047
|
+
};
|
|
1048
|
+
updatedItem = nextObj;
|
|
1049
|
+
return nextObj;
|
|
1050
|
+
}
|
|
1051
|
+
return entry;
|
|
1052
|
+
});
|
|
1053
|
+
if (Object.keys(updatedItem).length === 0 && task && task.raw !== null && typeof task.raw === 'object') {
|
|
1054
|
+
updatedItem = {
|
|
1055
|
+
...(task.raw as Record<string, unknown>),
|
|
1056
|
+
[map.start]: newStart,
|
|
1057
|
+
...(d.milestone ? {} : { [map.end]: newEnd }),
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
api.emit('reschedule', { id: d.id, start: newStart, end: newEnd, item: updatedItem });
|
|
1061
|
+
api.emit('change', { value: nextData, data: nextData, id: d.id, start: newStart, end: newEnd });
|
|
1062
|
+
paint();
|
|
1063
|
+
};
|
|
1064
|
+
const onPointerUp = (event: PointerEvent): void => finishDrag(event, false);
|
|
1065
|
+
const onPointerCancel = (event: PointerEvent): void => finishDrag(event, true);
|
|
565
1066
|
const onClick = (event: Event): void => {
|
|
566
|
-
|
|
1067
|
+
if (suppressNextClick) {
|
|
1068
|
+
suppressNextClick = false;
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
const hit = event.target as Element | null;
|
|
1072
|
+
const viewBtn = hit?.closest<HTMLElement>(kitAttrSel(KIT_ATTR_VIEW));
|
|
1073
|
+
if (viewBtn) { api.emit('view_change', { view: viewBtn.getAttribute(KIT_ATTR_VIEW)! }); return; }
|
|
1074
|
+
if (hit?.closest(kitAttrSel(KIT_ATTR_TODAY))) { api.emit('today', {}); return; }
|
|
1075
|
+
const id = hit?.closest(kitAttrSel(KIT_ATTR_TASK))?.getAttribute(KIT_ATTR_TASK);
|
|
567
1076
|
if (!id) return;
|
|
568
|
-
const task =
|
|
1077
|
+
const task = taskById.get(id);
|
|
569
1078
|
if (task) api.emit('pick', { id: task.id, item: task.raw });
|
|
570
1079
|
};
|
|
1080
|
+
r.addEventListener('mousedown', onMouseDown);
|
|
1081
|
+
r.addEventListener('pointerdown', onPointerDown);
|
|
1082
|
+
r.addEventListener('pointermove', onPointerMove);
|
|
1083
|
+
r.addEventListener('pointerup', onPointerUp);
|
|
1084
|
+
r.addEventListener('pointercancel', onPointerCancel);
|
|
571
1085
|
r.addEventListener('click', onClick);
|
|
572
1086
|
// 容器宽变化时重画(窄宽降级、条上文字放得下与否都依赖宽度);宽度变化不足 8px 不重画
|
|
573
1087
|
let lastWidth = r.clientWidth;
|
|
@@ -580,6 +1094,12 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
580
1094
|
: null;
|
|
581
1095
|
obs?.observe(r);
|
|
582
1096
|
return () => {
|
|
1097
|
+
activeDrag = null;
|
|
1098
|
+
r.removeEventListener('mousedown', onMouseDown);
|
|
1099
|
+
r.removeEventListener('pointerdown', onPointerDown);
|
|
1100
|
+
r.removeEventListener('pointermove', onPointerMove);
|
|
1101
|
+
r.removeEventListener('pointerup', onPointerUp);
|
|
1102
|
+
r.removeEventListener('pointercancel', onPointerCancel);
|
|
583
1103
|
r.removeEventListener('click', onClick);
|
|
584
1104
|
obs?.disconnect();
|
|
585
1105
|
root = null;
|