soma-kit 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/packs/ai/model-card.ts +3 -3
- package/packs/finance/reconcile-desk/compile.ts +1 -1
- package/packs/finance/reconcile-desk/shell.ts +1 -1
- package/packs/ops/error-budget-card.ts +3 -3
- package/packs/ops/release-readiness-card.ts +3 -3
- package/packs/security/control-evidence-card.ts +3 -3
- package/packs/security/finding-card.ts +3 -2
- package/packs/shared/card-util.ts +17 -0
- package/spec/generated/kit-app.schema.json +2148 -338
- package/spec/generated/kit-page.schema.json +1152 -87
- package/spec/kit-grammar.json +1084 -136
- package/spec/kit-grammar.schema.json +167 -26
- package/src/app/app-config.ts +220 -187
- package/src/app/component-gate.ts +2 -2
- package/src/app/compose-apps.ts +5 -2
- package/src/app/define-kit-actions.ts +200 -22
- package/src/app/define-kit-app.ts +54 -8
- package/src/app/define-kit-view.ts +1 -1
- package/src/app/index.ts +12 -7
- package/src/app/kit-view-context.ts +50 -3
- package/src/app/list-page-defaults.ts +14 -0
- package/src/app/server-pages.ts +239 -7
- package/src/app/server.ts +466 -25
- package/src/app/theme-endpoint.ts +68 -24
- package/src/app/theme-runtime.ts +421 -87
- package/src/app/theme-shards.ts +69 -0
- package/src/app/tier-compat.ts +107 -0
- package/src/base/action-busy.ts +215 -38
- package/src/base/affix.ts +137 -0
- package/src/base/alert.ts +107 -59
- package/src/base/anchored-layer.ts +8 -7
- package/src/base/avatar.ts +147 -61
- package/src/base/badge.ts +186 -0
- package/src/base/button-group.ts +227 -0
- package/src/base/button.ts +365 -53
- package/src/base/card.ts +233 -0
- package/src/base/cascader.ts +147 -32
- package/src/base/check-core.ts +196 -33
- package/src/base/checkbox.ts +67 -2
- package/src/base/choice.ts +132 -31
- package/src/base/collapse.ts +249 -0
- package/src/base/color-picker.ts +404 -28
- package/src/base/combobox.ts +6 -2
- package/src/base/command-palette.ts +155 -37
- package/src/base/context-menu.ts +26 -6
- package/src/base/countdown.ts +37 -15
- package/src/base/date-range.ts +115 -94
- package/src/base/date.ts +487 -76
- package/src/base/delta.ts +20 -11
- package/src/base/divider.ts +64 -97
- package/src/base/end-edge.ts +10 -4
- package/src/base/fab.ts +64 -23
- package/src/base/gap-value.ts +35 -16
- package/src/base/hint-tips.ts +100 -30
- package/src/base/identity-cells.ts +839 -0
- package/src/base/illustrations.ts +6 -4
- package/src/base/image.ts +40 -19
- package/src/base/index.ts +92 -24
- package/src/base/inline-error.ts +90 -0
- package/src/base/input.ts +174 -38
- package/src/base/kbd.ts +31 -17
- package/src/base/kit-contract.ts +400 -0
- package/src/base/link.ts +41 -20
- package/src/base/listbox-core.ts +324 -95
- package/src/base/loading-gate.ts +3 -0
- package/src/base/look.ts +197 -0
- package/src/base/mentions.ts +58 -22
- package/src/base/menu-button.ts +129 -42
- package/src/base/menu-core.ts +210 -26
- package/src/base/month-grid.ts +60 -3
- package/src/base/motion/aura.ts +52 -10
- package/src/base/motion/hover-3d.ts +10 -5
- package/src/base/motion/hover-gallery.ts +19 -12
- package/src/base/motion/limits.ts +10 -0
- package/src/base/motion/marquee.ts +18 -11
- package/src/base/motion/text-rotate.ts +34 -16
- package/src/base/notification.ts +292 -0
- package/src/base/number.ts +93 -12
- package/src/base/otp.ts +143 -27
- package/src/base/overlay-runtime.ts +32 -24
- package/src/base/overlay-shell.ts +186 -0
- package/src/base/period-picker.ts +868 -0
- package/src/base/popover.ts +625 -74
- package/src/base/popup.ts +219 -78
- package/src/base/portal-core.ts +99 -2
- package/src/base/price-text.ts +51 -17
- package/src/base/progress.ts +100 -18
- package/src/base/qr-code.ts +64 -17
- package/src/base/qty-stepper.ts +145 -21
- package/src/base/radio.ts +43 -2
- package/src/base/range.ts +194 -39
- package/src/base/rating.ts +117 -31
- package/src/base/reason-tip.ts +60 -18
- package/src/base/relation-cells.ts +541 -0
- package/src/{frames → base}/resize-handle.ts +6 -4
- package/src/base/row-fresh.ts +84 -0
- package/src/base/section-spy.ts +79 -0
- package/src/base/segmented.ts +99 -56
- package/src/base/select.ts +8 -2
- package/src/base/shared.ts +520 -73
- package/src/base/spinner.ts +107 -0
- package/src/base/state-panel.ts +77 -22
- package/src/base/status-tone.ts +1 -1
- package/src/base/sticky-edge.ts +96 -29
- package/src/base/swap.ts +39 -21
- package/src/base/switch.ts +158 -38
- package/src/base/tabs.ts +292 -0
- package/src/base/tag-input.ts +129 -55
- package/src/base/tag.ts +203 -91
- package/src/base/text.ts +491 -77
- package/src/base/textarea.ts +89 -40
- package/src/base/time-picker.ts +341 -57
- package/src/base/time-range.ts +846 -0
- package/src/base/tree-select.ts +346 -89
- package/src/base/upload.ts +612 -158
- package/src/base/view-transition.ts +7 -3
- package/src/base/virtual-list.ts +49 -14
- package/src/biz/approval-desk/compile.ts +98 -6
- package/src/biz/approval-desk/index.ts +2 -0
- package/src/biz/approval-desk/shell.ts +53 -13
- package/src/biz/auth-panel/compile.ts +14 -4
- package/src/biz/auth-panel/shell.ts +28 -8
- package/src/biz/category-crud/compile.ts +64 -13
- package/src/biz/category-crud/index.ts +2 -0
- package/src/biz/category-crud/shell.ts +30 -8
- package/src/biz/checkout-page/compile.ts +38 -4
- package/src/biz/checkout-page/index.ts +1 -0
- package/src/biz/checkout-page/shell.ts +28 -10
- package/src/biz/compose.ts +9 -4
- package/src/biz/data-components.ts +2 -0
- package/src/biz/define.ts +1 -1
- package/src/biz/import-wizard/compile.ts +5 -2
- package/src/biz/import-wizard/index.ts +1 -0
- package/src/biz/import-wizard/shell.ts +36 -20
- package/src/biz/index.ts +5 -4
- package/src/biz/landing-page/compile.ts +4 -3
- package/src/biz/landing-page/shell.ts +25 -5
- package/src/biz/layout-contracts.ts +918 -0
- package/src/biz/link/hub.ts +199 -8
- package/src/biz/link/shared.ts +62 -16
- package/src/biz/master-sub/compile.ts +318 -38
- package/src/biz/master-sub/detail-head.ts +145 -21
- package/src/biz/master-sub/index.ts +6 -3
- package/src/biz/master-sub/shell.ts +232 -66
- package/src/biz/multi-board/compile.ts +89 -38
- package/src/biz/multi-board/composition.ts +7 -20
- package/src/biz/multi-board/index.ts +25 -9
- package/src/biz/multi-board/prose-fold.ts +17 -13
- package/src/biz/multi-board/shell.ts +153 -38
- package/src/biz/names.ts +1 -0
- package/src/biz/notification-center/compile.ts +28 -7
- package/src/biz/notification-center/index.ts +2 -0
- package/src/biz/notification-center/shell.ts +51 -11
- package/src/biz/page-templates/domain-templates.ts +147 -20
- package/src/biz/page-templates/result-page/compile.ts +5 -2
- package/src/biz/page-templates/result-page/index.ts +1 -0
- package/src/biz/page-templates/result-page/shell.ts +20 -6
- package/src/biz/page-templates/shared.ts +1 -1
- package/src/biz/page-templates/sign-in-page/compile.ts +20 -9
- package/src/biz/page-templates/sign-in-page/index.ts +1 -0
- package/src/biz/page-templates/sign-in-page/shell.ts +30 -14
- package/src/biz/record-detail/compile.ts +43 -12
- package/src/biz/record-detail/index.ts +1 -0
- package/src/biz/record-detail/shell.ts +42 -11
- package/src/biz/settings-center/compile.ts +5 -2
- package/src/biz/settings-center/index.ts +1 -0
- package/src/biz/settings-center/shell.ts +33 -9
- package/src/biz/shared/action-host.ts +146 -48
- package/src/biz/shared/compile-helpers.ts +134 -32
- package/src/biz/shared/coordinator.ts +727 -163
- package/src/biz/shared/focus-return.ts +180 -0
- package/src/biz/shared/object-aliases.ts +7 -1
- package/src/biz/shared/overlay-compile.ts +102 -24
- package/src/biz/shared/overlay-shell.ts +97 -116
- package/src/biz/shared/page-form-actions.ts +151 -0
- package/src/biz/shared/page-form.ts +255 -0
- package/src/biz/shared/pipeline.ts +74 -0
- package/src/biz/shared/runtime-hub.ts +101 -8
- package/src/biz/shared/verbs.ts +129 -0
- package/src/biz/single-form/compile.ts +6 -4
- package/src/biz/single-form/index.ts +2 -0
- package/src/biz/single-form/shell.ts +22 -8
- package/src/biz/standard-crud/compile.ts +213 -38
- package/src/biz/standard-crud/index.ts +2 -1
- package/src/biz/standard-crud/shell.ts +90 -13
- package/src/biz/standard-crud/summary.ts +2 -35
- package/src/biz/step-form/compile.ts +13 -4
- package/src/biz/step-form/hub.ts +168 -49
- package/src/biz/step-form/index.ts +1 -0
- package/src/biz/step-form/shell.ts +35 -17
- package/src/biz/types.ts +49 -6
- package/src/cli/app-layer-check.ts +375 -0
- package/src/cli/kit-cli.ts +179 -33
- package/src/cli/kit-init.ts +152 -3
- package/src/cli/migrate/theme-map.ts +35 -28
- package/src/cli/migrate/ts-rules.ts +2 -2
- package/src/cli/migrate/types.ts +3 -3
- package/src/cli/migrate/yaml-rules.ts +11 -9
- package/src/cli/view-writes.ts +13 -0
- package/src/compile/access-gate-attach.ts +1 -1
- package/src/compile/action-host-attach.ts +1 -1
- package/src/compile/closed-set.ts +102 -6
- package/src/compile/compile-page.ts +461 -273
- package/src/compile/component-candidates.ts +58 -5
- package/src/compile/danger-tier.ts +65 -0
- package/src/compile/hints.ts +6 -59
- package/src/compile/index.ts +2 -2
- package/src/compile/info-structure.ts +155 -0
- package/src/compile/layout-lint/index.ts +4 -1
- package/src/compile/layout-lint/rules-composition.ts +44 -13
- package/src/compile/layout-lint/rules-table.ts +4 -19
- package/src/compile/look-page.ts +551 -0
- package/src/compile/look.ts +376 -0
- package/src/compile/page-composition.ts +405 -67
- package/src/compile/page-hierarchy.ts +131 -0
- package/src/compile/page-pipeline-look.ts +156 -0
- package/src/compile/page-pipeline.ts +200 -0
- package/src/compile/parse.ts +12 -11
- package/src/compile/redirect.ts +1 -1
- package/src/compile/relation-render.ts +120 -0
- package/src/compile/remove-guard.ts +115 -41
- package/src/compile/stages.ts +786 -0
- package/src/compile/styles.ts +286 -48
- package/src/compile/types.ts +63 -6
- package/src/compile/view-check.ts +190 -1
- package/src/data/access-gate.ts +17 -9
- package/src/data/amount-breakdown.ts +52 -23
- package/src/data/anchor-nav.ts +77 -16
- package/src/data/approval-flow.ts +217 -126
- package/src/data/assignment-picker.ts +182 -94
- package/src/data/async-result-panel.ts +114 -46
- package/src/data/audit-log.ts +461 -0
- package/src/data/breadcrumbs.ts +150 -24
- package/src/data/calendar.ts +436 -97
- package/src/data/card-grid.ts +319 -0
- package/src/data/carousel.ts +81 -41
- package/src/data/cell-value.ts +253 -0
- package/src/data/chart.ts +1053 -96
- package/src/data/checklist.ts +82 -38
- package/src/data/code-view.ts +296 -44
- package/src/data/comment-thread.ts +611 -86
- package/src/data/compare-view.ts +227 -0
- package/src/data/confirm-dialog.ts +250 -39
- package/src/data/context-menu.ts +95 -21
- package/src/data/d9-limits.ts +2 -0
- package/src/data/d9-util.ts +13 -5
- package/src/data/diff.ts +109 -49
- package/src/data/display-util.ts +9 -4
- package/src/data/dock.ts +38 -18
- package/src/data/embed.ts +143 -8
- package/src/data/engine-ports.ts +135 -0
- package/src/data/field-mapper.ts +116 -54
- package/src/data/file-list.ts +522 -0
- package/src/data/flow-editor.ts +695 -158
- package/src/data/flow-node-options.ts +24 -5
- package/src/data/flow-remote-options.ts +94 -19
- package/src/data/footer.ts +88 -26
- package/src/data/form-draft-registry.ts +183 -12
- package/src/data/gantt.ts +640 -117
- package/src/data/graph-view.ts +51 -0
- package/src/data/heat-calendar.ts +412 -0
- package/src/data/hero.ts +40 -13
- package/src/data/image-viewer.ts +265 -62
- package/src/data/index.ts +75 -6
- package/src/data/item-list.ts +219 -58
- package/src/data/json-view.ts +909 -0
- package/src/data/kanban.ts +346 -91
- package/src/data/kit-contract.ts +230 -0
- package/src/data/leaderboard.ts +343 -0
- package/src/data/level-class.ts +21 -0
- package/src/data/log-stream.ts +347 -0
- package/src/data/markdown-view.ts +597 -0
- package/src/data/matrix.ts +234 -120
- package/src/data/media-grid.ts +165 -38
- package/src/data/mega-menu.ts +43 -26
- package/src/data/menu-bar.ts +254 -0
- package/src/data/menu-dom.ts +55 -19
- package/src/data/menu.ts +138 -48
- package/src/data/mockup.ts +37 -25
- package/src/data/modal-dialog.ts +126 -98
- package/src/data/navbar.ts +152 -66
- package/src/data/notice-list.ts +101 -49
- package/src/data/notify-renderer.ts +80 -15
- package/src/data/object-form.ts +1504 -164
- package/src/data/org-chart.ts +544 -0
- package/src/data/outcome-watch.ts +90 -21
- package/src/data/pager.ts +129 -45
- package/src/data/panel-head.ts +238 -76
- package/src/data/permission-matrix.ts +379 -120
- package/src/data/permission-tree.ts +146 -78
- package/src/data/pricing-table.ts +112 -43
- package/src/data/prompt-dialog.ts +49 -21
- package/src/data/reaction-bar.ts +67 -32
- package/src/data/record-card.ts +245 -72
- package/src/data/record-picker.ts +61 -28
- package/src/data/redirect.ts +39 -15
- package/src/data/request-console.ts +141 -38
- package/src/data/resident.ts +11 -13
- package/src/data/result-panel.ts +65 -27
- package/src/data/rich-text.ts +260 -127
- package/src/data/row-confirm.ts +47 -0
- package/src/data/row-editor.ts +384 -105
- package/src/data/rule-builder.ts +136 -81
- package/src/data/schedule-grid.ts +238 -0
- package/src/data/segment-bar.ts +221 -0
- package/src/data/shape-util.ts +90 -36
- package/src/data/stage-flow.ts +244 -0
- package/src/data/staged-rows.ts +207 -24
- package/src/data/stat-group.ts +493 -100
- package/src/data/static-lazy.ts +21 -0
- package/src/data/static-registry.ts +46 -4
- package/src/data/status-strip.ts +171 -0
- package/src/data/steps.ts +69 -36
- package/src/data/summary-strip.ts +136 -0
- package/src/data/summary-util.ts +116 -0
- package/src/data/survey.ts +134 -47
- package/src/data/system-switcher.ts +53 -24
- package/src/data/target-progress.ts +208 -0
- package/src/data/text-action-button.ts +28 -7
- package/src/data/text-diff.ts +731 -0
- package/src/data/tile-grid.ts +343 -0
- package/src/data/timeline.ts +205 -36
- package/src/data/tour-guide.ts +113 -47
- package/src/data/transfer.ts +204 -47
- package/src/data/tree-table.ts +228 -81
- package/src/data/tree.ts +193 -69
- package/src/data/trend-line.ts +68 -12
- package/src/data/virtual-rows.ts +248 -98
- package/src/data/waterfall.ts +171 -0
- package/src/data/watermark.ts +35 -6
- package/src/data/wrap.ts +28 -6
- package/src/frames/blank-frame.ts +6 -4
- package/src/frames/index.ts +4 -4
- package/src/frames/inherited-shell.ts +219 -0
- package/src/frames/page-bar.ts +208 -28
- package/src/frames/page-status.ts +3 -2
- package/src/frames/resident-components.ts +18 -0
- package/src/frames/shared.ts +73 -26
- package/src/frames/single-frame.ts +20 -4
- package/src/frames/split-frame/shell.ts +27 -17
- package/src/frames/split-frame/wiring.ts +16 -12
- package/src/frames/tabs-frame/shell.ts +14 -7
- package/src/frames/tabs-frame/wiring.ts +2 -1
- package/src/frames/top-main-frame.ts +55 -3
- package/src/frames/types.ts +5 -2
- package/src/frames/workspace-frame/extras.ts +23 -7
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/pipeline-key.ts +6 -0
- package/src/frames/workspace-frame/shell.ts +24 -3
- package/src/frames/workspace-frame/state.ts +42 -8
- package/src/frames/workspace-frame/view.ts +773 -194
- package/src/generated/kit-grammar-runtime.ts +1061 -77
- package/src/generated/kit-page.ts +272 -0
- package/src/i18n/index.ts +2 -0
- package/src/i18n/kit-text.ts +210 -5
- package/src/i18n/resolve-text-refs.ts +1 -1
- package/src/object-renderer/action-group.ts +204 -22
- package/src/object-renderer/action-more.ts +66 -19
- package/src/object-renderer/arrange.ts +270 -28
- package/src/object-renderer/category-tone.ts +96 -0
- package/src/object-renderer/collapse-wiring.ts +19 -9
- package/src/object-renderer/collection-expand.ts +3 -3
- package/src/object-renderer/collection-parts.ts +459 -103
- package/src/object-renderer/collection-table.ts +406 -59
- package/src/object-renderer/collection.ts +333 -71
- package/src/object-renderer/compile-data.ts +13 -3
- package/src/object-renderer/defaults.ts +14 -5
- package/src/object-renderer/emit-events.ts +46 -20
- package/src/object-renderer/emit-object.ts +35 -6
- package/src/object-renderer/emit-static.ts +831 -153
- package/src/object-renderer/field-value.ts +12 -239
- package/src/object-renderer/filter-plan.ts +3 -3
- package/src/object-renderer/filter-toolbar.ts +190 -0
- package/src/object-renderer/form-detail.ts +87 -2
- package/src/{compile → object-renderer}/fragment.ts +2 -2
- package/src/object-renderer/index.ts +1 -1
- package/src/object-renderer/key-field.ts +21 -0
- package/src/object-renderer/layout-facts.ts +55 -7
- package/src/object-renderer/layout-plan.ts +6 -3
- package/src/object-renderer/overlay-decide.ts +124 -0
- package/src/object-renderer/pick-component.ts +8 -2
- package/src/object-renderer/pipeline-mode.ts +6 -0
- package/src/object-renderer/relation-field.ts +79 -0
- package/src/object-renderer/render-object.ts +72 -27
- package/src/object-renderer/request-actions.ts +119 -21
- package/src/object-renderer/table-actions.ts +479 -111
- package/src/object-renderer/table-gap.ts +2 -1
- package/src/object-renderer/table-reorder.ts +237 -0
- package/src/object-renderer/table-summary.ts +26 -12
- package/src/object-renderer/table-tools.ts +437 -130
- package/src/object-renderer/types.ts +100 -17
- package/src/object-renderer/value-present.ts +49 -0
- package/src/page-target/ai-surface.ts +15 -22
- package/src/page-target/compile.ts +5 -6
- package/src/page-target/drift.ts +0 -7
- package/src/page-target/intent-schema.ts +46 -43
- package/src/page-target/target.ts +4 -5
- package/src/page-target/writer-policy.ts +4 -5
- package/src/recipes/app-blocks.ts +66 -0
- package/src/recipes/chrome-surface.ts +20 -0
- package/src/recipes/code-view.ts +57 -0
- package/src/recipes/color-role.ts +442 -0
- package/src/recipes/compact-group.ts +32 -0
- package/src/recipes/composition-projector.ts +321 -0
- package/src/recipes/container.ts +93 -26
- package/src/recipes/control.ts +85 -8
- package/src/recipes/desc-list.ts +108 -0
- package/src/recipes/divider.ts +74 -0
- package/src/recipes/emphasis.ts +102 -13
- package/src/recipes/field-text.ts +72 -0
- package/src/recipes/form-section.ts +177 -0
- package/src/recipes/frame-bleed.ts +6 -5
- package/src/recipes/index.ts +39 -5
- package/src/recipes/inherited-shell.ts +43 -0
- package/src/recipes/json-view.ts +50 -0
- package/src/recipes/look.ts +56 -0
- package/src/recipes/mark.ts +138 -0
- package/src/recipes/markdown.ts +96 -0
- package/src/recipes/overlay.ts +151 -37
- package/src/recipes/page-width.ts +51 -0
- package/src/recipes/pipeline-runtime.ts +366 -0
- package/src/recipes/placeholder.ts +38 -20
- package/src/recipes/rail-grid.ts +6 -3
- package/src/recipes/self-owned.ts +59 -0
- package/src/recipes/slot-align.ts +5 -3
- package/src/recipes/stat-state.ts +6 -6
- package/src/recipes/state.ts +64 -11
- package/src/recipes/status.ts +21 -20
- package/src/recipes/strip.ts +114 -0
- package/src/recipes/surface-edge.ts +3 -1
- package/src/recipes/surface.ts +40 -7
- package/src/recipes/table-gap.ts +4 -3
- package/src/recipes/table-native-edit.ts +25 -12
- package/src/recipes/table-row.ts +56 -20
- package/src/recipes/tabs.ts +140 -31
- package/src/recipes/text-diff.ts +97 -0
- package/src/recipes/text-fit.ts +132 -0
- package/src/recipes/title-row.ts +72 -5
- package/src/recipes/typography.ts +2 -2
- package/src/shared/action-func.ts +106 -0
- package/src/shared/color-scheme.ts +127 -0
- package/src/shared/confirm-decl.ts +5 -2
- package/src/shared/danger-facts.ts +55 -0
- package/src/shared/diagnostics.ts +16 -0
- package/src/shared/dom-attrs-registry.ts +1009 -0
- package/src/shared/dom-attrs.ts +743 -0
- package/src/shared/envelope.ts +1 -1
- package/src/shared/field-kind.ts +49 -0
- package/src/shared/field-value-format.ts +292 -0
- package/src/shared/focus-ring.ts +8 -0
- package/src/shared/glyphs.ts +127 -0
- package/src/shared/hints.ts +56 -0
- package/src/{base → shared}/icons.ts +40 -1
- package/src/shared/identifier-field.ts +66 -0
- package/src/shared/kit-error.ts +1 -1
- package/src/shared/list-pager.ts +23 -0
- package/src/shared/list-title.ts +29 -0
- package/src/{object-renderer → shared}/merge-class.ts +3 -2
- package/src/shared/order-value.ts +15 -0
- package/src/shared/page-attrs-runtime.ts +327 -0
- package/src/shared/page-attrs.ts +262 -0
- package/src/shared/path-guard.ts +1 -1
- package/src/shared/pipeline-mode.ts +64 -0
- package/src/shared/primitives-types.ts +8 -0
- package/src/shared/row-key.ts +15 -0
- package/src/shared/theme-runtime-shared.ts +181 -21
- package/src/shared/theme-usage.ts +16 -0
- package/src/shared/value-table-contract.ts +68 -0
- package/src/spatial/action-func.ts +4 -0
- package/src/spatial/declared-actions.ts +116 -0
- package/src/spatial/emit.ts +660 -0
- package/src/spatial/expand.ts +1482 -0
- package/src/spatial/field-types.ts +48 -0
- package/src/spatial/index.ts +82 -0
- package/src/spatial/layout.ts +697 -0
- package/src/spatial/look-apply.ts +206 -0
- package/src/spatial/page-decl.ts +44 -0
- package/src/spatial/page-object.ts +349 -0
- package/src/spatial/recognize.ts +491 -0
- package/src/spatial/self-report.ts +571 -0
- package/src/spatial/shape.ts +205 -0
- package/src/spatial/spatial-map.ts +136 -0
- package/src/spatial/tone.ts +145 -0
- package/src/theme/index.ts +11 -2
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +563 -28
- package/src/theme/kit-theme.tpl +527 -28
- package/src/theme/look-carrier.ts +65 -0
- package/src/theme/nine-dim-structure.ts +538 -176
- package/src/theme/private-vars.ts +153 -0
- package/src/theme/surface-layers.ts +12 -3
- package/src/theme/theme-tokens.ts +1602 -90
- package/src/theme/theme-types.ts +38 -59
- package/src/theme/value-table.ts +2379 -0
- package/src/app/envelope.ts +0 -1
- package/src/app/notify-renderer.ts +0 -1
- package/src/app/paged-list-adapter.ts +0 -1
- package/src/app/theme-runtime-shared.ts +0 -1
- package/src/compile/kit-error.ts +0 -1
- package/src/frames/list-summary.ts +0 -100
- package/src/recipes/nowrap.ts +0 -16
- package/src/theme/block-theme.ts +0 -202
- /package/src/{base → shared}/class-candidates.ts +0 -0
package/src/data/gantt.ts
CHANGED
|
@@ -17,12 +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
|
-
import { mergeClass } from '../
|
|
49
|
+
import { mergeClass } from '../shared/merge-class';
|
|
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';
|
|
26
63
|
import {
|
|
27
64
|
GANTT_BAR_LABEL_MAX, GANTT_CHART_FALLBACK_PX, GANTT_LABEL_COLUMN_PX, GANTT_NOTE_MAX,
|
|
28
65
|
ganttBarLabelPlace, ganttBaselineBox, ganttIsNarrow, ganttTextWidthPx,
|
|
@@ -47,12 +84,14 @@ export interface KitGanttMap {
|
|
|
47
84
|
base_end: string;
|
|
48
85
|
/** 组标题行附注(取组内第一个非空值) */
|
|
49
86
|
group_note: string;
|
|
87
|
+
/** 显式延期标记(布尔);缺省按「今日已过结束日且进度未满」推断 */
|
|
88
|
+
delayed: string;
|
|
50
89
|
}
|
|
51
90
|
|
|
52
91
|
export const KIT_GANTT_DEFAULT_MAP: Readonly<KitGanttMap> = Object.freeze({
|
|
53
92
|
id: 'id', title: 'title', start: 'start', end: 'end', progress: 'progress',
|
|
54
93
|
group: 'group', deps: 'deps', tone: 'tone', owner: 'owner',
|
|
55
|
-
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',
|
|
56
95
|
});
|
|
57
96
|
|
|
58
97
|
export type KitGanttTone = 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
|
@@ -214,20 +253,67 @@ function fx(n: number): string {
|
|
|
214
253
|
}
|
|
215
254
|
|
|
216
255
|
interface Row {
|
|
217
|
-
kind: 'group' | 'task';
|
|
256
|
+
kind: 'group' | 'task' | 'invalid';
|
|
218
257
|
group: string;
|
|
219
258
|
task?: KitGanttTask;
|
|
259
|
+
/** invalid 行:日期无效的任务标题(无条,只在左栏标记) */
|
|
260
|
+
title?: string;
|
|
220
261
|
/** 组标题行附注(组内第一个非空 group_note) */
|
|
221
262
|
note?: string;
|
|
222
263
|
}
|
|
223
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
|
+
|
|
224
304
|
/** 行序:保持数据顺序;组名变化(非空)时在前面插一条分组行(附注取该组内第一个非空 group_note) */
|
|
225
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
|
+
}
|
|
226
312
|
const rows: Row[] = [];
|
|
227
313
|
let last = '';
|
|
228
314
|
for (const task of tasks) {
|
|
229
315
|
if (task.group !== '' && task.group !== last) {
|
|
230
|
-
const note =
|
|
316
|
+
const note = firstNoteByGroup.get(task.group) ?? '';
|
|
231
317
|
rows.push({ kind: 'group', group: task.group, ...(note !== '' ? { note } : {}) });
|
|
232
318
|
}
|
|
233
319
|
if (task.group !== '') last = task.group;
|
|
@@ -238,38 +324,86 @@ export function ganttRows(tasks: readonly KitGanttTask[]): Row[] {
|
|
|
238
324
|
|
|
239
325
|
// ── 类串常量与 Tailwind 候选清单 ──
|
|
240
326
|
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
//
|
|
245
|
-
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';
|
|
330
|
+
// 刻度头底线、刻度之间的竖线 = 分隔线出口(发丝宽、分隔灰,KT-B1 / KT-B5)
|
|
331
|
+
const TICK_LINE = kitDividerRecipe('start');
|
|
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');
|
|
246
344
|
const TICKS_CLASS = 'flex flex-1';
|
|
247
|
-
const TICK_CLASS = 'flex-1
|
|
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());
|
|
248
347
|
const BODY_CLASS = 'flex';
|
|
249
|
-
const LABELS_CLASS = 'flex w-
|
|
250
|
-
const
|
|
251
|
-
const
|
|
252
|
-
const
|
|
253
|
-
const
|
|
254
|
-
const
|
|
255
|
-
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);
|
|
256
365
|
const EMPTY_CLASS = 'px-3 py-6 text-center text-fg-muted';
|
|
257
366
|
|
|
258
|
-
// 任务条 =
|
|
259
|
-
const TRACK_CLASS: Record<
|
|
367
|
+
// 任务条 = 语义或分类浅色填充、无描边、胶囊圆角;进度段用同色系实心色
|
|
368
|
+
const TRACK_CLASS: Record<KitResolvedTone, string> = {
|
|
260
369
|
primary: 'fill-primary-soft',
|
|
261
370
|
success: 'fill-success-soft',
|
|
262
371
|
warning: 'fill-warning-soft',
|
|
263
372
|
danger: 'fill-danger-soft',
|
|
264
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',
|
|
265
385
|
};
|
|
266
|
-
const DONE_CLASS: Record<
|
|
386
|
+
const DONE_CLASS: Record<KitResolvedTone, string> = {
|
|
267
387
|
primary: 'fill-primary',
|
|
268
388
|
success: 'fill-success',
|
|
269
389
|
warning: 'fill-warning',
|
|
270
390
|
danger: 'fill-danger',
|
|
271
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',
|
|
272
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(' ');
|
|
273
407
|
const GROUP_BG_CLASS = 'fill-surface-band';
|
|
274
408
|
const GRID_LINE_CLASS = 'stroke-border-subtle';
|
|
275
409
|
const DEP_LINE_CLASS = 'fill-none stroke-fg-subtle';
|
|
@@ -277,22 +411,32 @@ const DEP_ARROW_CLASS = 'fill-fg-subtle';
|
|
|
277
411
|
const TODAY_CLASS = 'stroke-danger';
|
|
278
412
|
/** 休息日底纹 / 基线幽灵条 / 条上文字(条内 / 外置)/ 里程碑字形 / 组附注;文字叠加层是不带 viewBox 的第二张 SVG(文字不随非等比 viewBox 变形) */
|
|
279
413
|
// 颜色自带透明度(fill-x/50),不用 opacity-50:后者是 G101 disabledOpacity 类族(禁用态不透明度),这里是图形底纹
|
|
280
|
-
const REST_DAY_CLASS = 'fill-surface-
|
|
414
|
+
const REST_DAY_CLASS = 'fill-surface-band'; // 休息日带 = 节的淡底带(KT-HB-F),不是井
|
|
281
415
|
const BASELINE_CLASS = 'fill-fg-subtle/50';
|
|
282
416
|
// 条内文字压在进度实心色 / 浅轨两种底上:用面板色描边做光晕(paint-order 先描边后填充),任何底色上都可读
|
|
283
417
|
const LABEL_IN_CLASS = mergeClass('fill-fg stroke-surface stroke-2', kitTypographyRecipe('deltaSm'));
|
|
284
418
|
const LABEL_OUT_CLASS = mergeClass('fill-fg-muted', kitTypographyRecipe('captionPlain'));
|
|
285
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';
|
|
286
425
|
const OVERLAY_SVG_CLASS = 'pointer-events-none absolute inset-0 h-full w-full';
|
|
287
|
-
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';
|
|
288
427
|
const MILESTONE_GLYPH = '◆';
|
|
289
428
|
|
|
290
429
|
/** 本组件自带的全部类(供编译器并入候选类) */
|
|
291
430
|
export const KIT_GANTT_CLASS_CANDIDATES: readonly string[] = Object.freeze(
|
|
292
431
|
[...new Set([
|
|
293
432
|
ROOT_CLASS, INNER_CLASS, HEAD_CLASS, CORNER_CLASS, TICKS_CLASS, TICK_CLASS, BODY_CLASS, LABELS_CLASS, ROW_BTN_CLASS,
|
|
294
|
-
|
|
295
|
-
|
|
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,
|
|
296
440
|
...Object.values(TRACK_CLASS), ...Object.values(DONE_CLASS),
|
|
297
441
|
GROUP_BG_CLASS, GRID_LINE_CLASS, DEP_LINE_CLASS, DEP_ARROW_CLASS, TODAY_CLASS,
|
|
298
442
|
].flatMap((s) => s.split(/\s+/)).filter((c) => c !== ''))].sort(),
|
|
@@ -325,17 +469,54 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
325
469
|
tick_count: { type: 'number', default: DEFAULT_TICKS, desc: '表头刻度段数,2–10' },
|
|
326
470
|
show_progress: { type: 'boolean', default: true, desc: '是否画进度' },
|
|
327
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,
|
|
328
479
|
class: { type: 'string', default: '', desc: '外部传入的类,追加在根节点类串末尾' },
|
|
329
480
|
},
|
|
330
481
|
emits: {
|
|
331
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,
|
|
332
494
|
},
|
|
333
495
|
},
|
|
334
496
|
templateHtml: `<div data-soma-id="root" class="${ROOT_CLASS}"></div>`,
|
|
335
497
|
controllerFactory: createKitController((api) => {
|
|
336
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
|
+
}
|
|
337
513
|
let root: HTMLElement | null = null;
|
|
338
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;
|
|
339
520
|
|
|
340
521
|
const el = <K extends keyof HTMLElementTagNameMap>(tag: K, className: string, text?: string): HTMLElementTagNameMap[K] => {
|
|
341
522
|
const node = document.createElement(tag);
|
|
@@ -344,7 +525,53 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
344
525
|
return node;
|
|
345
526
|
};
|
|
346
527
|
|
|
347
|
-
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 => {
|
|
348
575
|
const n = rows.length;
|
|
349
576
|
const svg = svgEl('svg', { viewBox: `0 0 100 ${n}`, preserveAspectRatio: 'none', 'aria-hidden': 'true' }, SVG_CLASS);
|
|
350
577
|
const line = (x1: number, y1: number, x2: number, y2: number, cls: string): SVGElement =>
|
|
@@ -355,7 +582,7 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
355
582
|
});
|
|
356
583
|
// 休息日底纹:轴内的休息日连续合并成一块,铺满全部行(在分隔线与条之下)
|
|
357
584
|
for (const [a, b] of restRuns(p.rest_days, axis)) {
|
|
358
|
-
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));
|
|
359
586
|
}
|
|
360
587
|
for (let i = 1; i < n; i += 1) svg.appendChild(line(0, i, 100, i, GRID_LINE_CLASS));
|
|
361
588
|
// 刻度竖线(与表头的等分段对齐)
|
|
@@ -371,17 +598,31 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
371
598
|
index.set(t.id, { row: i, x, w });
|
|
372
599
|
// 里程碑没有条:菱形字形与标签画在文字叠加层,这里只登记位置(依赖线仍可接到它)
|
|
373
600
|
if (t.milestone) return;
|
|
374
|
-
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);
|
|
375
604
|
// 基线幽灵条:现计划条下方的细灰条(窄宽降级时不画)
|
|
376
605
|
if (t.base !== null && !narrow) {
|
|
377
606
|
const box = ganttBaselineBox(BAR_TOP, BAR_HEIGHT);
|
|
378
607
|
const bx = ((t.base.from - axis.from) / axis.span) * 100;
|
|
379
608
|
const bw = ((t.base.to - t.base.from + 1) / axis.span) * 100;
|
|
380
|
-
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));
|
|
381
610
|
}
|
|
382
|
-
|
|
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
|
+
));
|
|
383
619
|
if (showProgress && t.progress > 0) {
|
|
384
|
-
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));
|
|
385
626
|
}
|
|
386
627
|
svg.appendChild(g);
|
|
387
628
|
});
|
|
@@ -422,8 +663,21 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
422
663
|
* 文字叠加层:第二张不带 viewBox 的 SVG(坐标全用百分比 + 像素偏移,文字不随主图的非等比 viewBox 变形)。
|
|
423
664
|
* 里程碑 = 菱形字形 + 标题(始终显示);条上文字 = 条内放得下画在条内(嵌套 svg 裁切),放不下外置到条右侧(右侧也放不下则左侧);窄宽不画条上文字。
|
|
424
665
|
*/
|
|
425
|
-
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 => {
|
|
426
679
|
const mode = str(p.bar_label) === 'title' ? 'title' : str(p.bar_label) === 'owner' ? 'owner' : 'none';
|
|
680
|
+
const showProgress = p.show_progress !== false;
|
|
427
681
|
const n = rows.length;
|
|
428
682
|
const svg = svgEl('svg', { 'aria-hidden': 'true' }, OVERLAY_SVG_CLASS);
|
|
429
683
|
let any = false;
|
|
@@ -446,125 +700,388 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
446
700
|
const t = row.task;
|
|
447
701
|
const { x, w } = ganttBar(t, axis);
|
|
448
702
|
const y = ((i + 0.5) / n) * 100;
|
|
703
|
+
const draggingThis = activeDrag?.id === t.id;
|
|
449
704
|
if (t.milestone) {
|
|
450
705
|
const cx = x + w / 2;
|
|
451
|
-
|
|
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}`);
|
|
452
710
|
// 菱形字形占约一个字宽:左右各留半字
|
|
453
711
|
const half = (ganttTextWidthPx(MILESTONE_GLYPH) / 2 / Math.max(chartPx, 1)) * 100;
|
|
454
|
-
|
|
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);
|
|
455
714
|
return;
|
|
456
715
|
}
|
|
457
|
-
if (mode === 'none' || narrow) return;
|
|
458
|
-
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;
|
|
459
721
|
if (value === '') return;
|
|
460
722
|
if (ganttBarLabelPlace(value, (w / 100) * chartPx) === 'inside') {
|
|
461
723
|
const box = svgEl('svg', { x: pct(x), y: pct((i / n) * 100), width: pct(w), height: pct(100 / n), overflow: 'hidden' });
|
|
462
|
-
const node = svgEl('text', { x: '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);
|
|
463
725
|
node.textContent = value;
|
|
464
726
|
box.appendChild(node);
|
|
465
727
|
svg.appendChild(box);
|
|
466
728
|
any = true;
|
|
467
729
|
} else {
|
|
468
|
-
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 });
|
|
469
731
|
}
|
|
470
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
|
+
}
|
|
471
739
|
return any ? svg : null;
|
|
472
740
|
};
|
|
473
741
|
|
|
474
742
|
const paint = (): void => {
|
|
475
|
-
|
|
743
|
+
const rEl = root;
|
|
744
|
+
if (!rEl) return;
|
|
476
745
|
const p = P();
|
|
477
|
-
|
|
746
|
+
rEl.className = joinClass(ROOT_CLASS, p.class);
|
|
747
|
+
// 旧版:按祖先是不是面板决定画不画外框;新流水线下外观由取值表按层级角色给,组件不看祖先
|
|
748
|
+
if (!kitHasProps(p)) markKitEdge(rEl);
|
|
478
749
|
// 整块重建会丢焦点:记下聚焦的任务行,重建后还回去
|
|
479
|
-
const focused = document.activeElement instanceof HTMLElement &&
|
|
480
|
-
? document.activeElement.closest(
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
head.appendChild(el('div', CORNER_CLASS));
|
|
496
|
-
const ticks = el('div', TICKS_CLASS);
|
|
497
|
-
const tickCount = num(p.tick_count) ?? DEFAULT_TICKS;
|
|
498
|
-
for (const text of ganttTicks(axis, tickCount)) ticks.appendChild(el('div', TICK_CLASS, text));
|
|
499
|
-
head.appendChild(ticks);
|
|
500
|
-
inner.appendChild(head);
|
|
501
|
-
|
|
502
|
-
const body = el('div', BODY_CLASS);
|
|
503
|
-
const labels = el('div', LABELS_CLASS);
|
|
504
|
-
for (const row of rows) {
|
|
505
|
-
if (row.kind === 'group') {
|
|
506
|
-
const groupRow = el('div', GROUP_ROW_CLASS, row.group);
|
|
507
|
-
// 组标题行附注(如「共 8.5 人日 · 2 天超载」),取自数据
|
|
508
|
-
if (row.note !== undefined) groupRow.appendChild(el('span', GROUP_NOTE_CLASS, row.note));
|
|
509
|
-
labels.appendChild(groupRow);
|
|
510
|
-
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));
|
|
511
766
|
}
|
|
512
|
-
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
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;
|
|
529
792
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
const chartPx = rootPx > 0 ? Math.max(rootPx - GANTT_LABEL_COLUMN_PX, 0) : GANTT_CHART_FALLBACK_PX;
|
|
538
|
-
chart.appendChild(buildChart(rows, axis, p, narrow) as unknown as Node);
|
|
539
|
-
const overlay = buildOverlay(rows, axis, p, chartPx, narrow);
|
|
540
|
-
if (overlay !== null) chart.appendChild(overlay as unknown as Node);
|
|
541
|
-
body.appendChild(chart);
|
|
542
|
-
inner.appendChild(body);
|
|
543
|
-
root.appendChild(inner);
|
|
544
|
-
// 胶囊圆角:主图是非等比 viewBox(x 每单位 = 图宽 / 100,y 每单位 = 一行高),圆角的 rx / ry 按实测折算成同一物理半径(半个条高);无布局环境(测不到)不画圆角
|
|
545
|
-
const rowPx = labels.querySelector('button')?.getBoundingClientRect().height ?? 0;
|
|
546
|
-
const chartW = chart.getBoundingClientRect().width;
|
|
547
|
-
if (rowPx > 0 && chartW > 0) {
|
|
548
|
-
for (const r of chart.querySelectorAll('[data-kit-pill]')) {
|
|
549
|
-
r.setAttribute('ry', fx(BAR_HEIGHT / 2));
|
|
550
|
-
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);
|
|
551
800
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
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
|
+
});
|
|
556
948
|
};
|
|
557
949
|
|
|
558
950
|
return {
|
|
559
951
|
attach(rootEl) {
|
|
560
952
|
root = rootEl;
|
|
561
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);
|
|
562
1066
|
const onClick = (event: Event): void => {
|
|
563
|
-
|
|
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);
|
|
564
1076
|
if (!id) return;
|
|
565
|
-
const task =
|
|
1077
|
+
const task = taskById.get(id);
|
|
566
1078
|
if (task) api.emit('pick', { id: task.id, item: task.raw });
|
|
567
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);
|
|
568
1085
|
r.addEventListener('click', onClick);
|
|
569
1086
|
// 容器宽变化时重画(窄宽降级、条上文字放得下与否都依赖宽度);宽度变化不足 8px 不重画
|
|
570
1087
|
let lastWidth = r.clientWidth;
|
|
@@ -577,6 +1094,12 @@ export function createGantt(): SomaComponentDefinition {
|
|
|
577
1094
|
: null;
|
|
578
1095
|
obs?.observe(r);
|
|
579
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);
|
|
580
1103
|
r.removeEventListener('click', onClick);
|
|
581
1104
|
obs?.disconnect();
|
|
582
1105
|
root = null;
|