@redvars/peacock 4.0.0 → 4.1.0
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/dist/{BaseField-CAog9TIc.js → BaseField-BMumJpkW.js} +6 -3
- package/dist/BaseField-BMumJpkW.js.map +1 -0
- package/dist/{BaseInput-CcMfg1Y2.js → BaseInput-mWdyYv27.js} +6 -3
- package/dist/BaseInput-mWdyYv27.js.map +1 -0
- package/dist/accordion.js.map +1 -1
- package/dist/ai-badge.js +2 -2
- package/dist/ai-summary.js +2 -2
- package/dist/alert.js +2 -2
- package/dist/anchor-nav.js +2 -2
- package/dist/app-shell.js +2 -2
- package/dist/assistant-panel.js +2 -2
- package/dist/assistant-step.js +2 -2
- package/dist/assistant-steps.js +2 -2
- package/dist/avatar-group.js +2 -2
- package/dist/banner.js +2 -2
- package/dist/{base-button-Do2TUy8M.js → base-button-BJMGMcMv.js} +3 -1
- package/dist/base-button-BJMGMcMv.js.map +1 -0
- package/dist/{base-progress-BiLlZVHJ.js → base-progress-CvLVSjuy.js} +4 -2
- package/dist/base-progress-CvLVSjuy.js.map +1 -0
- package/dist/bottom-sheet.js +2 -2
- package/dist/breadcrumb.js +2 -2
- package/dist/button-group.js +4 -4
- package/dist/button.js +3 -3
- package/dist/calendar.js +2 -2
- package/dist/canvas-base-BTQMEVn_.js +788 -0
- package/dist/canvas-base-BTQMEVn_.js.map +1 -0
- package/dist/canvas-link-CtgsALq4.js +54 -0
- package/dist/canvas-link-CtgsALq4.js.map +1 -0
- package/dist/{cartesian-chart-C-f1frt0.js → cartesian-chart-DM1FC_XT.js} +3 -2
- package/dist/cartesian-chart-DM1FC_XT.js.map +1 -0
- package/dist/{cb-group-base-DeuCVx3a.js → cb-group-base-B6fa4Lll.js} +2 -2
- package/dist/{cb-group-base-DeuCVx3a.js.map → cb-group-base-B6fa4Lll.js.map} +1 -1
- package/dist/cb-group.js +3 -3
- package/dist/cb-rule.js +3 -3
- package/dist/chart-area.js +5 -4
- package/dist/chart-area.js.map +1 -1
- package/dist/chart-bar.js +5 -4
- package/dist/chart-bar.js.map +1 -1
- package/dist/chart-base-Dhxuw_Mw.js +833 -0
- package/dist/chart-base-Dhxuw_Mw.js.map +1 -0
- package/dist/chart-doughnut.js +4 -3
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-line.js +5 -4
- package/dist/chart-line.js.map +1 -1
- package/dist/chart-pie.js +4 -3
- package/dist/chart-pie.js.map +1 -1
- package/dist/chat-message.js +2 -2
- package/dist/chat-thread.js +2 -2
- package/dist/checkbox-group.js +4 -4
- package/dist/checkbox.js +4 -4
- package/dist/chip-set.js +3 -3
- package/dist/chip.js +4 -4
- package/dist/circular-progress.js +3 -3
- package/dist/citation.js +2 -2
- package/dist/code-editor.js +5 -4
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +2 -2
- package/dist/color-field.js +5 -5
- package/dist/color-picker.js +2 -2
- package/dist/command-palette.js +2 -2
- package/dist/comment-composer.js +5 -5
- package/dist/condition-builder.js +3 -3
- package/dist/confirm-dialog.js +2 -2
- package/dist/copy-button.js +2 -2
- package/dist/currency-field.js +5 -5
- package/dist/custom-elements-jsdocs.json +2115 -336
- package/dist/custom-elements.json +19483 -615
- package/dist/date-field.js +6 -6
- package/dist/date-picker.js +4 -2
- package/dist/date-picker.js.map +1 -1
- package/dist/date-range-field.js +6 -6
- package/dist/datetime-field.js +6 -6
- package/dist/dependency-map-layout-5KUueabk.js +1390 -0
- package/dist/dependency-map-layout-5KUueabk.js.map +1 -0
- package/dist/dependency-map.js +1605 -0
- package/dist/dependency-map.js.map +1 -0
- package/dist/description-item.js +2 -2
- package/dist/description-list.js +2 -2
- package/dist/diagram-2r11KySs.js +2029 -0
- package/dist/diagram-2r11KySs.js.map +1 -0
- package/dist/diagram-controls.js +345 -0
- package/dist/diagram-controls.js.map +1 -0
- package/dist/diagram-minimap.js +216 -0
- package/dist/diagram-minimap.js.map +1 -0
- package/dist/diagram.js +20 -0
- package/dist/diagram.js.map +1 -0
- package/dist/diff-viewer.js +2 -2
- package/dist/discussion-activity.js +2 -2
- package/dist/discussion-comment.js +2 -2
- package/dist/discussion.js +5 -5
- package/dist/{document-editor-BO7QPbO5.js → document-editor-BnEugM3E.js} +2 -2
- package/dist/{document-editor-BO7QPbO5.js.map → document-editor-BnEugM3E.js.map} +1 -1
- package/dist/document-editor.js +3 -3
- package/dist/draft-card.js +2 -2
- package/dist/erd.js +2021 -0
- package/dist/erd.js.map +1 -0
- package/dist/fab.js +4 -4
- package/dist/field.js +257 -43
- package/dist/field.js.map +1 -1
- package/dist/file-upload.js +37 -15
- package/dist/file-upload.js.map +1 -1
- package/dist/filter-bar.js +2 -2
- package/dist/flow.js +27 -970
- package/dist/flow.js.map +1 -1
- package/dist/focus-ring.js +2 -0
- package/dist/focus-ring.js.map +1 -1
- package/dist/{form-associated-D3Tn33s_.js → form-associated-BHbg72PG.js} +3 -1
- package/dist/{form-associated-D3Tn33s_.js.map → form-associated-BHbg72PG.js.map} +1 -1
- package/dist/{form-submitter-DWwv6K9-.js → form-submitter-beG1CXAn.js} +7 -1
- package/dist/{form-submitter-DWwv6K9-.js.map → form-submitter-beG1CXAn.js.map} +1 -1
- package/dist/form.js +2 -2
- package/dist/{generative-view-DmtpDobn.js → generative-view-BgOcLRXr.js} +13 -13
- package/dist/generative-view-BgOcLRXr.js.map +1 -0
- package/dist/generative-view.js +3 -3
- package/dist/geometry-INg82Lxq.js +305 -0
- package/dist/geometry-INg82Lxq.js.map +1 -0
- package/dist/history-YbTSQZHj.js +45 -0
- package/dist/history-YbTSQZHj.js.map +1 -0
- package/dist/host-CZK7xhzh.js +40 -0
- package/dist/host-CZK7xhzh.js.map +1 -0
- package/dist/html-editor.js +5 -5
- package/dist/{hyperlink-DhE9RlVS.js → hyperlink-DycWPKwU.js} +10 -1
- package/dist/hyperlink-DycWPKwU.js.map +1 -0
- package/dist/{i18n-controller-urcQKYGe.js → i18n-controller-Cp43HjJl.js} +2 -2
- package/dist/{i18n-controller-urcQKYGe.js.map → i18n-controller-Cp43HjJl.js.map} +1 -1
- package/dist/icon-button.js +4 -4
- package/dist/image.js +2 -2
- package/dist/index.js +37 -18
- package/dist/index.js.map +1 -1
- package/dist/inline-edit.js +2 -2
- package/dist/input.js +4 -4
- package/dist/json-viewer.js +2 -2
- package/dist/kanban.js +2 -2
- package/dist/kbd.js +2 -2
- package/dist/linear-progress.js +3 -3
- package/dist/link-button.js +2 -2
- package/dist/list-item.js +2 -2
- package/dist/list.js +2 -2
- package/dist/listbox.js +3 -3
- package/dist/loader-full.js +13 -13
- package/dist/loader.js +44 -15
- package/dist/loader.js.map +1 -1
- package/dist/markdown-editor.js +5 -5
- package/dist/markers-BFmh1OCz.js +46 -0
- package/dist/markers-BFmh1OCz.js.map +1 -0
- package/dist/measure-controller-Dmc5hZKg.js +89 -0
- package/dist/measure-controller-Dmc5hZKg.js.map +1 -0
- package/dist/mention-input.js +6 -5
- package/dist/mention-input.js.map +1 -1
- package/dist/menu-item.js +3 -2
- package/dist/menu-item.js.map +1 -1
- package/dist/menu.js +2 -2
- package/dist/modal.js +2 -2
- package/dist/navigation-bar.js +2 -2
- package/dist/navigation-drawer.js +2 -2
- package/dist/navigation-rail.js +2 -2
- package/dist/notification-center.js +2 -2
- package/dist/number-field.js +6 -5
- package/dist/number-field.js.map +1 -1
- package/dist/option.js +2 -2
- package/dist/page-header.js +2 -2
- package/dist/pagination.js +2 -2
- package/dist/password-field.js +5 -5
- package/dist/password-rules.js +2 -2
- package/dist/phone-field.js +5 -5
- package/dist/{picker-field-B4DtcJfL.js → picker-field-dTlIMAQn.js} +3 -3
- package/dist/{picker-field-B4DtcJfL.js.map → picker-field-dTlIMAQn.js.map} +1 -1
- package/dist/pin-input.js +5 -5
- package/dist/presence-indicator.js +2 -2
- package/dist/prompt-input.js +5 -5
- package/dist/radio-group.js +1 -0
- package/dist/radio-group.js.map +1 -1
- package/dist/radio.js +5 -5
- package/dist/radio.js.map +1 -1
- package/dist/rating.js +5 -4
- package/dist/rating.js.map +1 -1
- package/dist/redvars-loader.js +2 -2
- package/dist/relative-time.js +2 -2
- package/dist/resizable-panels.js +2 -2
- package/dist/{rich-text-input-DLICqof1.js → rich-text-input-DM_BOzgk.js} +3 -3
- package/dist/{rich-text-input-DLICqof1.js.map → rich-text-input-DM_BOzgk.js.map} +1 -1
- package/dist/ripple.js +2 -0
- package/dist/ripple.js.map +1 -1
- package/dist/{schema-hMt-NRLk.js → schema-B8g30A_n.js} +2 -2
- package/dist/{schema-hMt-NRLk.js.map → schema-B8g30A_n.js.map} +1 -1
- package/dist/search.js +4 -4
- package/dist/segmented-button-group.js +1 -1
- package/dist/select.js +7 -7
- package/dist/side-sheet.js +2 -2
- package/dist/signature-pad.js +5 -4
- package/dist/signature-pad.js.map +1 -1
- package/dist/slider.js +5 -4
- package/dist/slider.js.map +1 -1
- package/dist/snackbar.js +2 -2
- package/dist/sparkline.js +2 -2
- package/dist/split-button.js +2 -2
- package/dist/src/__internal/diagram/canvas-base.d.ts +105 -0
- package/dist/src/__internal/diagram/canvas-link.d.ts +21 -0
- package/dist/src/__internal/diagram/geometry.d.ts +49 -0
- package/dist/src/__internal/diagram/history.d.ts +17 -0
- package/dist/src/__internal/diagram/host.d.ts +45 -0
- package/dist/src/__internal/diagram/markers.d.ts +16 -0
- package/dist/src/__internal/diagram/measure-controller.d.ts +32 -0
- package/dist/src/__internal/diagram/motion.d.ts +22 -0
- package/dist/src/__internal/diagram/selection.d.ts +20 -0
- package/dist/src/__internal/diagram/types.d.ts +39 -0
- package/dist/src/__internal/diagram/viewport-controller.d.ts +89 -0
- package/dist/src/__internal/i18n/strings.d.ts +149 -0
- package/dist/src/__internal/toggle-base.d.ts +8 -0
- package/dist/src/__internal/utils/deprecate.d.ts +3 -3
- package/dist/src/accordion/accordion.d.ts +1 -0
- package/dist/src/code-editor/code-editor.d.ts +1 -0
- package/dist/src/date-picker/date-picker.d.ts +2 -0
- package/dist/src/dependency-map/dependency-map-layout.d.ts +48 -0
- package/dist/src/dependency-map/dependency-map.d.ts +241 -0
- package/dist/src/dependency-map/index.d.ts +2 -0
- package/dist/src/diagram/diagram.d.ts +300 -0
- package/dist/src/diagram/flow.d.ts +53 -0
- package/dist/src/diagram/index.d.ts +4 -0
- package/dist/src/diagram-controls/diagram-controls.d.ts +46 -0
- package/dist/src/diagram-controls/index.d.ts +1 -0
- package/dist/src/diagram-minimap/diagram-minimap.d.ts +39 -0
- package/dist/src/diagram-minimap/index.d.ts +1 -0
- package/dist/src/erd/erd-layout.d.ts +27 -0
- package/dist/src/erd/erd.d.ts +266 -0
- package/dist/src/erd/index.d.ts +2 -0
- package/dist/src/field/field.d.ts +38 -1
- package/dist/src/file-upload/file-upload.d.ts +3 -1
- package/dist/src/focus-ring/focus-ring.d.ts +2 -0
- package/dist/src/index.d.ts +15 -2
- package/dist/src/input/BaseField.d.ts +3 -0
- package/dist/src/input/BaseInput.d.ts +3 -0
- package/dist/src/menu/menu-item/menu-item.d.ts +1 -0
- package/dist/src/number-field/number-field.d.ts +4 -0
- package/dist/src/progress/base-progress.d.ts +3 -0
- package/dist/src/radio/radio-group.d.ts +1 -0
- package/dist/src/rating/rating.d.ts +1 -0
- package/dist/src/ripple/ripple.d.ts +2 -0
- package/dist/src/signature-pad/signature-pad.d.ts +1 -0
- package/dist/src/slider/slider.d.ts +1 -0
- package/dist/src/switch/switch.d.ts +1 -0
- package/dist/src/tabs/tab.d.ts +2 -0
- package/dist/src/tabs/tabs.d.ts +1 -0
- package/dist/src/textarea/textarea.d.ts +1 -0
- package/dist/src/time-picker/time-picker.d.ts +2 -0
- package/dist/src/transfer-list/transfer-list.d.ts +1 -0
- package/dist/src/tree-chart/index.d.ts +2 -0
- package/dist/src/tree-chart/tree-chart-layout.d.ts +49 -0
- package/dist/src/tree-chart/tree-chart.d.ts +221 -0
- package/dist/src/workflow/index.d.ts +2 -0
- package/dist/src/workflow/workflow-format.d.ts +5 -0
- package/dist/src/workflow/workflow-model.d.ts +194 -0
- package/dist/src/workflow/workflow.d.ts +313 -0
- package/dist/src/workflow-timeline/index.d.ts +1 -0
- package/dist/src/workflow-timeline/workflow-timeline.d.ts +41 -0
- package/dist/stat.js +2 -2
- package/dist/status-indicator.js +2 -2
- package/dist/step.js +2 -2
- package/dist/stepper.js +2 -2
- package/dist/{strings-DmbqMTfs.js → strings-BJPuhKJk.js} +163 -1
- package/dist/{strings-DmbqMTfs.js.map → strings-BJPuhKJk.js.map} +1 -1
- package/dist/sub-menu.js +2 -2
- package/dist/svg.js +2 -2
- package/dist/switch.js +5 -4
- package/dist/switch.js.map +1 -1
- package/dist/tab.js +1 -0
- package/dist/tab.js.map +1 -1
- package/dist/table.js +2 -2
- package/dist/tabs.js +1 -0
- package/dist/tabs.js.map +1 -1
- package/dist/test/diagram-controls.test.d.ts +1 -0
- package/dist/test/diagram-geometry.test.d.ts +1 -0
- package/dist/test/diagram.test.d.ts +1 -0
- package/dist/test/erd.test.d.ts +1 -0
- package/dist/test/toggle-label.test.d.ts +1 -0
- package/dist/test/tree-chart.test.d.ts +1 -0
- package/dist/test/workflow-debug.test.d.ts +1 -0
- package/dist/test/workflow.test.d.ts +1 -0
- package/dist/textarea.js +7 -5
- package/dist/textarea.js.map +1 -1
- package/dist/time-field.js +6 -6
- package/dist/time-picker.js +4 -2
- package/dist/time-picker.js.map +1 -1
- package/dist/timeline-item.js +2 -2
- package/dist/timeline.js +2 -2
- package/dist/{toggle-base-BQO5pjrU.js → toggle-base-BlaHalfS.js} +19 -3
- package/dist/toggle-base-BlaHalfS.js.map +1 -0
- package/dist/tour.js +2 -2
- package/dist/transfer-list.js +5 -4
- package/dist/transfer-list.js.map +1 -1
- package/dist/{chart-base-B-gOg2Di.js → transform-CxeQFXXB.js} +9 -839
- package/dist/transform-CxeQFXXB.js.map +1 -0
- package/dist/tree-chart.js +1986 -0
- package/dist/tree-chart.js.map +1 -0
- package/dist/tree-item.js +2 -2
- package/dist/tree.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing-indicator.js +2 -2
- package/dist/url-field.js +5 -5
- package/dist/user-menu.js +2 -2
- package/dist/virtual-list.js +2 -2
- package/dist/workflow-format-BsyveyeC.js +34 -0
- package/dist/workflow-format-BsyveyeC.js.map +1 -0
- package/dist/workflow-model-CauduOG2.js +330 -0
- package/dist/workflow-model-CauduOG2.js.map +1 -0
- package/dist/workflow-timeline.js +354 -0
- package/dist/workflow-timeline.js.map +1 -0
- package/dist/workflow.js +3337 -0
- package/dist/workflow.js.map +1 -0
- package/dist/workspace-switcher.js +2 -2
- package/package.json +1 -1
- package/readme.md +44 -2
- package/src/LoaderUtils.ts +9 -2
- package/src/__internal/diagram/canvas-base.ts +410 -0
- package/src/__internal/diagram/canvas-link.ts +66 -0
- package/src/__internal/diagram/geometry.ts +372 -0
- package/src/__internal/diagram/history.ts +49 -0
- package/src/__internal/diagram/host.ts +76 -0
- package/src/__internal/diagram/markers.ts +56 -0
- package/src/__internal/diagram/measure-controller.ts +104 -0
- package/src/__internal/diagram/motion.ts +89 -0
- package/src/__internal/diagram/selection.ts +69 -0
- package/src/__internal/diagram/types.ts +56 -0
- package/src/__internal/diagram/viewport-controller.ts +494 -0
- package/src/__internal/i18n/strings.ts +201 -0
- package/src/__internal/mixins/field.ts +3 -0
- package/src/__internal/mixins/form-associated.ts +2 -0
- package/src/__internal/mixins/form-submitter.ts +6 -0
- package/src/__internal/mixins/hyperlink.ts +10 -0
- package/src/__internal/toggle-base.ts +16 -0
- package/src/__internal/utils/deprecate.ts +5 -4
- package/src/accordion/accordion.ts +1 -0
- package/src/button/base-button/base-button.ts +2 -0
- package/src/code-editor/code-editor.ts +1 -0
- package/src/date-picker/date-picker.ts +2 -0
- package/src/dependency-map/dependency-map-layout.ts +505 -0
- package/src/dependency-map/dependency-map.scss +626 -0
- package/src/dependency-map/dependency-map.ts +1280 -0
- package/src/dependency-map/index.ts +16 -0
- package/src/diagram/diagram.scss +513 -0
- package/src/diagram/diagram.ts +1852 -0
- package/src/diagram/flow.ts +81 -0
- package/src/diagram/index.ts +44 -0
- package/src/diagram-controls/diagram-controls.scss +68 -0
- package/src/diagram-controls/diagram-controls.ts +255 -0
- package/src/diagram-controls/index.ts +1 -0
- package/src/diagram-minimap/diagram-minimap.scss +41 -0
- package/src/diagram-minimap/diagram-minimap.ts +149 -0
- package/src/diagram-minimap/index.ts +1 -0
- package/src/erd/erd-layout.ts +92 -0
- package/src/erd/erd.scss +636 -0
- package/src/erd/erd.ts +1728 -0
- package/src/erd/index.ts +17 -0
- package/src/field/field.scss +197 -23
- package/src/field/field.ts +109 -16
- package/src/file-upload/file-upload.scss +37 -10
- package/src/file-upload/file-upload.ts +3 -1
- package/src/focus-ring/focus-ring.ts +2 -0
- package/src/generative-view/catalog.generated.ts +12 -11
- package/src/index.ts +121 -2
- package/src/input/BaseField.ts +3 -0
- package/src/input/BaseInput.ts +3 -0
- package/src/loader.ts +25 -0
- package/src/mention-input/mention-input.scss +2 -0
- package/src/menu/menu-item/menu-item.ts +1 -0
- package/src/number-field/number-field.ts +4 -0
- package/src/progress/base-progress.ts +3 -0
- package/src/radio/radio-group.ts +1 -0
- package/src/radio/radio.ts +1 -1
- package/src/rating/rating.ts +1 -0
- package/src/ripple/ripple.ts +2 -0
- package/src/signature-pad/signature-pad.ts +1 -0
- package/src/slider/slider.ts +1 -0
- package/src/switch/switch.ts +1 -0
- package/src/tabs/tab.ts +2 -0
- package/src/tabs/tabs.ts +1 -0
- package/src/textarea/textarea.scss +2 -0
- package/src/textarea/textarea.ts +1 -0
- package/src/time-picker/time-picker.ts +2 -0
- package/src/transfer-list/transfer-list.ts +1 -0
- package/src/tree-chart/index.ts +13 -0
- package/src/tree-chart/tree-chart-layout.ts +185 -0
- package/src/tree-chart/tree-chart.scss +377 -0
- package/src/tree-chart/tree-chart.ts +1170 -0
- package/src/workflow/index.ts +35 -0
- package/src/workflow/workflow-format.ts +29 -0
- package/src/workflow/workflow-model.ts +583 -0
- package/src/workflow/workflow.scss +1164 -0
- package/src/workflow/workflow.ts +2674 -0
- package/src/workflow-timeline/index.ts +1 -0
- package/src/workflow-timeline/workflow-timeline.scss +128 -0
- package/src/workflow-timeline/workflow-timeline.ts +238 -0
- package/dist/BaseField-CAog9TIc.js.map +0 -1
- package/dist/BaseInput-CcMfg1Y2.js.map +0 -1
- package/dist/base-button-Do2TUy8M.js.map +0 -1
- package/dist/base-progress-BiLlZVHJ.js.map +0 -1
- package/dist/cartesian-chart-C-f1frt0.js.map +0 -1
- package/dist/chart-base-B-gOg2Di.js.map +0 -1
- package/dist/generative-view-DmtpDobn.js.map +0 -1
- package/dist/hyperlink-DhE9RlVS.js.map +0 -1
- package/dist/src/flow/flow.d.ts +0 -178
- package/dist/src/flow/index.d.ts +0 -2
- package/dist/toggle-base-BQO5pjrU.js.map +0 -1
- package/src/button/button-group/readme.md +0 -23
- package/src/flow/flow.scss +0 -215
- package/src/flow/flow.ts +0 -958
- package/src/flow/index.ts +0 -10
- /package/dist/test/{flow.test.d.ts → dependency-map.test.d.ts} +0 -0
|
@@ -0,0 +1,1986 @@
|
|
|
1
|
+
import { i, _ as __decorate, I as IndividualComponent, A, b, w } from './IndividualComponent-BK7XZjE2.js';
|
|
2
|
+
import { n } from './property-B2TG3KEE.js';
|
|
3
|
+
import { r } from './state-BCeDVCI9.js';
|
|
4
|
+
import { e } from './query-CHb9Ft_d.js';
|
|
5
|
+
import { e as e$1 } from './class-map-NDIkZErE.js';
|
|
6
|
+
import { c } from './repeat-D_ERDRYT.js';
|
|
7
|
+
import { D as DiagramCanvasElement, p as prefersReducedMotion, t as tween, b as easeOutCubic } from './canvas-base-BTQMEVn_.js';
|
|
8
|
+
import { M as MeasureController } from './measure-controller-Dmc5hZKg.js';
|
|
9
|
+
import { b as boundsOf, r as roundedPath } from './geometry-INg82Lxq.js';
|
|
10
|
+
import { H as History } from './history-YbTSQZHj.js';
|
|
11
|
+
import './transform-CxeQFXXB.js';
|
|
12
|
+
import './base-Cl6v8-BZ.js';
|
|
13
|
+
import './directive-ZPhl09Yt.js';
|
|
14
|
+
import './directive-helpers-Bx3mu42O.js';
|
|
15
|
+
import './i18n-controller-Cp43HjJl.js';
|
|
16
|
+
import './strings-BJPuhKJk.js';
|
|
17
|
+
import './locale-DEsJZCQG.js';
|
|
18
|
+
import './host-CZK7xhzh.js';
|
|
19
|
+
|
|
20
|
+
function count(node) {
|
|
21
|
+
var sum = 0,
|
|
22
|
+
children = node.children,
|
|
23
|
+
i = children && children.length;
|
|
24
|
+
if (!i) sum = 1;
|
|
25
|
+
else while (--i >= 0) sum += children[i].value;
|
|
26
|
+
node.value = sum;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function node_count() {
|
|
30
|
+
return this.eachAfter(count);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function node_each(callback, that) {
|
|
34
|
+
let index = -1;
|
|
35
|
+
for (const node of this) {
|
|
36
|
+
callback.call(that, node, ++index, this);
|
|
37
|
+
}
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function node_eachBefore(callback, that) {
|
|
42
|
+
var node = this, nodes = [node], children, i, index = -1;
|
|
43
|
+
while (node = nodes.pop()) {
|
|
44
|
+
callback.call(that, node, ++index, this);
|
|
45
|
+
if (children = node.children) {
|
|
46
|
+
for (i = children.length - 1; i >= 0; --i) {
|
|
47
|
+
nodes.push(children[i]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function node_eachAfter(callback, that) {
|
|
55
|
+
var node = this, nodes = [node], next = [], children, i, n, index = -1;
|
|
56
|
+
while (node = nodes.pop()) {
|
|
57
|
+
next.push(node);
|
|
58
|
+
if (children = node.children) {
|
|
59
|
+
for (i = 0, n = children.length; i < n; ++i) {
|
|
60
|
+
nodes.push(children[i]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
while (node = next.pop()) {
|
|
65
|
+
callback.call(that, node, ++index, this);
|
|
66
|
+
}
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function node_find(callback, that) {
|
|
71
|
+
let index = -1;
|
|
72
|
+
for (const node of this) {
|
|
73
|
+
if (callback.call(that, node, ++index, this)) {
|
|
74
|
+
return node;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function node_sum(value) {
|
|
80
|
+
return this.eachAfter(function(node) {
|
|
81
|
+
var sum = +value(node.data) || 0,
|
|
82
|
+
children = node.children,
|
|
83
|
+
i = children && children.length;
|
|
84
|
+
while (--i >= 0) sum += children[i].value;
|
|
85
|
+
node.value = sum;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function node_sort(compare) {
|
|
90
|
+
return this.eachBefore(function(node) {
|
|
91
|
+
if (node.children) {
|
|
92
|
+
node.children.sort(compare);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function node_path(end) {
|
|
98
|
+
var start = this,
|
|
99
|
+
ancestor = leastCommonAncestor(start, end),
|
|
100
|
+
nodes = [start];
|
|
101
|
+
while (start !== ancestor) {
|
|
102
|
+
start = start.parent;
|
|
103
|
+
nodes.push(start);
|
|
104
|
+
}
|
|
105
|
+
var k = nodes.length;
|
|
106
|
+
while (end !== ancestor) {
|
|
107
|
+
nodes.splice(k, 0, end);
|
|
108
|
+
end = end.parent;
|
|
109
|
+
}
|
|
110
|
+
return nodes;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function leastCommonAncestor(a, b) {
|
|
114
|
+
if (a === b) return a;
|
|
115
|
+
var aNodes = a.ancestors(),
|
|
116
|
+
bNodes = b.ancestors(),
|
|
117
|
+
c = null;
|
|
118
|
+
a = aNodes.pop();
|
|
119
|
+
b = bNodes.pop();
|
|
120
|
+
while (a === b) {
|
|
121
|
+
c = a;
|
|
122
|
+
a = aNodes.pop();
|
|
123
|
+
b = bNodes.pop();
|
|
124
|
+
}
|
|
125
|
+
return c;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function node_ancestors() {
|
|
129
|
+
var node = this, nodes = [node];
|
|
130
|
+
while (node = node.parent) {
|
|
131
|
+
nodes.push(node);
|
|
132
|
+
}
|
|
133
|
+
return nodes;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function node_descendants() {
|
|
137
|
+
return Array.from(this);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function node_leaves() {
|
|
141
|
+
var leaves = [];
|
|
142
|
+
this.eachBefore(function(node) {
|
|
143
|
+
if (!node.children) {
|
|
144
|
+
leaves.push(node);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return leaves;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function node_links() {
|
|
151
|
+
var root = this, links = [];
|
|
152
|
+
root.each(function(node) {
|
|
153
|
+
if (node !== root) { // Don’t include the root’s parent, if any.
|
|
154
|
+
links.push({source: node.parent, target: node});
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return links;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function* node_iterator() {
|
|
161
|
+
var node = this, current, next = [node], children, i, n;
|
|
162
|
+
do {
|
|
163
|
+
current = next.reverse(), next = [];
|
|
164
|
+
while (node = current.pop()) {
|
|
165
|
+
yield node;
|
|
166
|
+
if (children = node.children) {
|
|
167
|
+
for (i = 0, n = children.length; i < n; ++i) {
|
|
168
|
+
next.push(children[i]);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
} while (next.length);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function hierarchy(data, children) {
|
|
176
|
+
if (data instanceof Map) {
|
|
177
|
+
data = [undefined, data];
|
|
178
|
+
if (children === undefined) children = mapChildren;
|
|
179
|
+
} else if (children === undefined) {
|
|
180
|
+
children = objectChildren;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
var root = new Node(data),
|
|
184
|
+
node,
|
|
185
|
+
nodes = [root],
|
|
186
|
+
child,
|
|
187
|
+
childs,
|
|
188
|
+
i,
|
|
189
|
+
n;
|
|
190
|
+
|
|
191
|
+
while (node = nodes.pop()) {
|
|
192
|
+
if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) {
|
|
193
|
+
node.children = childs;
|
|
194
|
+
for (i = n - 1; i >= 0; --i) {
|
|
195
|
+
nodes.push(child = childs[i] = new Node(childs[i]));
|
|
196
|
+
child.parent = node;
|
|
197
|
+
child.depth = node.depth + 1;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return root.eachBefore(computeHeight);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function node_copy() {
|
|
206
|
+
return hierarchy(this).eachBefore(copyData);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function objectChildren(d) {
|
|
210
|
+
return d.children;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function mapChildren(d) {
|
|
214
|
+
return Array.isArray(d) ? d[1] : null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function copyData(node) {
|
|
218
|
+
if (node.data.value !== undefined) node.value = node.data.value;
|
|
219
|
+
node.data = node.data.data;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function computeHeight(node) {
|
|
223
|
+
var height = 0;
|
|
224
|
+
do node.height = height;
|
|
225
|
+
while ((node = node.parent) && (node.height < ++height));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function Node(data) {
|
|
229
|
+
this.data = data;
|
|
230
|
+
this.depth =
|
|
231
|
+
this.height = 0;
|
|
232
|
+
this.parent = null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
Node.prototype = hierarchy.prototype = {
|
|
236
|
+
constructor: Node,
|
|
237
|
+
count: node_count,
|
|
238
|
+
each: node_each,
|
|
239
|
+
eachAfter: node_eachAfter,
|
|
240
|
+
eachBefore: node_eachBefore,
|
|
241
|
+
find: node_find,
|
|
242
|
+
sum: node_sum,
|
|
243
|
+
sort: node_sort,
|
|
244
|
+
path: node_path,
|
|
245
|
+
ancestors: node_ancestors,
|
|
246
|
+
descendants: node_descendants,
|
|
247
|
+
leaves: node_leaves,
|
|
248
|
+
links: node_links,
|
|
249
|
+
copy: node_copy,
|
|
250
|
+
[Symbol.iterator]: node_iterator
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
function defaultSeparation(a, b) {
|
|
254
|
+
return a.parent === b.parent ? 1 : 2;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// function radialSeparation(a, b) {
|
|
258
|
+
// return (a.parent === b.parent ? 1 : 2) / a.depth;
|
|
259
|
+
// }
|
|
260
|
+
|
|
261
|
+
// This function is used to traverse the left contour of a subtree (or
|
|
262
|
+
// subforest). It returns the successor of v on this contour. This successor is
|
|
263
|
+
// either given by the leftmost child of v or by the thread of v. The function
|
|
264
|
+
// returns null if and only if v is on the highest level of its subtree.
|
|
265
|
+
function nextLeft(v) {
|
|
266
|
+
var children = v.children;
|
|
267
|
+
return children ? children[0] : v.t;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// This function works analogously to nextLeft.
|
|
271
|
+
function nextRight(v) {
|
|
272
|
+
var children = v.children;
|
|
273
|
+
return children ? children[children.length - 1] : v.t;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Shifts the current subtree rooted at w+. This is done by increasing
|
|
277
|
+
// prelim(w+) and mod(w+) by shift.
|
|
278
|
+
function moveSubtree(wm, wp, shift) {
|
|
279
|
+
var change = shift / (wp.i - wm.i);
|
|
280
|
+
wp.c -= change;
|
|
281
|
+
wp.s += shift;
|
|
282
|
+
wm.c += change;
|
|
283
|
+
wp.z += shift;
|
|
284
|
+
wp.m += shift;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// All other shifts, applied to the smaller subtrees between w- and w+, are
|
|
288
|
+
// performed by this function. To prepare the shifts, we have to adjust
|
|
289
|
+
// change(w+), shift(w+), and change(w-).
|
|
290
|
+
function executeShifts(v) {
|
|
291
|
+
var shift = 0,
|
|
292
|
+
change = 0,
|
|
293
|
+
children = v.children,
|
|
294
|
+
i = children.length,
|
|
295
|
+
w;
|
|
296
|
+
while (--i >= 0) {
|
|
297
|
+
w = children[i];
|
|
298
|
+
w.z += shift;
|
|
299
|
+
w.m += shift;
|
|
300
|
+
shift += w.s + (change += w.c);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// If vi-’s ancestor is a sibling of v, returns vi-’s ancestor. Otherwise,
|
|
305
|
+
// returns the specified (default) ancestor.
|
|
306
|
+
function nextAncestor(vim, v, ancestor) {
|
|
307
|
+
return vim.a.parent === v.parent ? vim.a : ancestor;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function TreeNode(node, i) {
|
|
311
|
+
this._ = node;
|
|
312
|
+
this.parent = null;
|
|
313
|
+
this.children = null;
|
|
314
|
+
this.A = null; // default ancestor
|
|
315
|
+
this.a = this; // ancestor
|
|
316
|
+
this.z = 0; // prelim
|
|
317
|
+
this.m = 0; // mod
|
|
318
|
+
this.c = 0; // change
|
|
319
|
+
this.s = 0; // shift
|
|
320
|
+
this.t = null; // thread
|
|
321
|
+
this.i = i; // number
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
TreeNode.prototype = Object.create(Node.prototype);
|
|
325
|
+
|
|
326
|
+
function treeRoot(root) {
|
|
327
|
+
var tree = new TreeNode(root, 0),
|
|
328
|
+
node,
|
|
329
|
+
nodes = [tree],
|
|
330
|
+
child,
|
|
331
|
+
children,
|
|
332
|
+
i,
|
|
333
|
+
n;
|
|
334
|
+
|
|
335
|
+
while (node = nodes.pop()) {
|
|
336
|
+
if (children = node._.children) {
|
|
337
|
+
node.children = new Array(n = children.length);
|
|
338
|
+
for (i = n - 1; i >= 0; --i) {
|
|
339
|
+
nodes.push(child = node.children[i] = new TreeNode(children[i], i));
|
|
340
|
+
child.parent = node;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
(tree.parent = new TreeNode(null, 0)).children = [tree];
|
|
346
|
+
return tree;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Node-link tree diagram using the Reingold-Tilford "tidy" algorithm
|
|
350
|
+
function tree() {
|
|
351
|
+
var separation = defaultSeparation,
|
|
352
|
+
dx = 1,
|
|
353
|
+
dy = 1,
|
|
354
|
+
nodeSize = null;
|
|
355
|
+
|
|
356
|
+
function tree(root) {
|
|
357
|
+
var t = treeRoot(root);
|
|
358
|
+
|
|
359
|
+
// Compute the layout using Buchheim et al.’s algorithm.
|
|
360
|
+
t.eachAfter(firstWalk), t.parent.m = -t.z;
|
|
361
|
+
t.eachBefore(secondWalk);
|
|
362
|
+
|
|
363
|
+
// If a fixed node size is specified, scale x and y.
|
|
364
|
+
if (nodeSize) root.eachBefore(sizeNode);
|
|
365
|
+
|
|
366
|
+
// If a fixed tree size is specified, scale x and y based on the extent.
|
|
367
|
+
// Compute the left-most, right-most, and depth-most nodes for extents.
|
|
368
|
+
else {
|
|
369
|
+
var left = root,
|
|
370
|
+
right = root,
|
|
371
|
+
bottom = root;
|
|
372
|
+
root.eachBefore(function(node) {
|
|
373
|
+
if (node.x < left.x) left = node;
|
|
374
|
+
if (node.x > right.x) right = node;
|
|
375
|
+
if (node.depth > bottom.depth) bottom = node;
|
|
376
|
+
});
|
|
377
|
+
var s = left === right ? 1 : separation(left, right) / 2,
|
|
378
|
+
tx = s - left.x,
|
|
379
|
+
kx = dx / (right.x + s + tx),
|
|
380
|
+
ky = dy / (bottom.depth || 1);
|
|
381
|
+
root.eachBefore(function(node) {
|
|
382
|
+
node.x = (node.x + tx) * kx;
|
|
383
|
+
node.y = node.depth * ky;
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
return root;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Computes a preliminary x-coordinate for v. Before that, FIRST WALK is
|
|
391
|
+
// applied recursively to the children of v, as well as the function
|
|
392
|
+
// APPORTION. After spacing out the children by calling EXECUTE SHIFTS, the
|
|
393
|
+
// node v is placed to the midpoint of its outermost children.
|
|
394
|
+
function firstWalk(v) {
|
|
395
|
+
var children = v.children,
|
|
396
|
+
siblings = v.parent.children,
|
|
397
|
+
w = v.i ? siblings[v.i - 1] : null;
|
|
398
|
+
if (children) {
|
|
399
|
+
executeShifts(v);
|
|
400
|
+
var midpoint = (children[0].z + children[children.length - 1].z) / 2;
|
|
401
|
+
if (w) {
|
|
402
|
+
v.z = w.z + separation(v._, w._);
|
|
403
|
+
v.m = v.z - midpoint;
|
|
404
|
+
} else {
|
|
405
|
+
v.z = midpoint;
|
|
406
|
+
}
|
|
407
|
+
} else if (w) {
|
|
408
|
+
v.z = w.z + separation(v._, w._);
|
|
409
|
+
}
|
|
410
|
+
v.parent.A = apportion(v, w, v.parent.A || siblings[0]);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Computes all real x-coordinates by summing up the modifiers recursively.
|
|
414
|
+
function secondWalk(v) {
|
|
415
|
+
v._.x = v.z + v.parent.m;
|
|
416
|
+
v.m += v.parent.m;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// The core of the algorithm. Here, a new subtree is combined with the
|
|
420
|
+
// previous subtrees. Threads are used to traverse the inside and outside
|
|
421
|
+
// contours of the left and right subtree up to the highest common level. The
|
|
422
|
+
// vertices used for the traversals are vi+, vi-, vo-, and vo+, where the
|
|
423
|
+
// superscript o means outside and i means inside, the subscript - means left
|
|
424
|
+
// subtree and + means right subtree. For summing up the modifiers along the
|
|
425
|
+
// contour, we use respective variables si+, si-, so-, and so+. Whenever two
|
|
426
|
+
// nodes of the inside contours conflict, we compute the left one of the
|
|
427
|
+
// greatest uncommon ancestors using the function ANCESTOR and call MOVE
|
|
428
|
+
// SUBTREE to shift the subtree and prepare the shifts of smaller subtrees.
|
|
429
|
+
// Finally, we add a new thread (if necessary).
|
|
430
|
+
function apportion(v, w, ancestor) {
|
|
431
|
+
if (w) {
|
|
432
|
+
var vip = v,
|
|
433
|
+
vop = v,
|
|
434
|
+
vim = w,
|
|
435
|
+
vom = vip.parent.children[0],
|
|
436
|
+
sip = vip.m,
|
|
437
|
+
sop = vop.m,
|
|
438
|
+
sim = vim.m,
|
|
439
|
+
som = vom.m,
|
|
440
|
+
shift;
|
|
441
|
+
while (vim = nextRight(vim), vip = nextLeft(vip), vim && vip) {
|
|
442
|
+
vom = nextLeft(vom);
|
|
443
|
+
vop = nextRight(vop);
|
|
444
|
+
vop.a = v;
|
|
445
|
+
shift = vim.z + sim - vip.z - sip + separation(vim._, vip._);
|
|
446
|
+
if (shift > 0) {
|
|
447
|
+
moveSubtree(nextAncestor(vim, v, ancestor), v, shift);
|
|
448
|
+
sip += shift;
|
|
449
|
+
sop += shift;
|
|
450
|
+
}
|
|
451
|
+
sim += vim.m;
|
|
452
|
+
sip += vip.m;
|
|
453
|
+
som += vom.m;
|
|
454
|
+
sop += vop.m;
|
|
455
|
+
}
|
|
456
|
+
if (vim && !nextRight(vop)) {
|
|
457
|
+
vop.t = vim;
|
|
458
|
+
vop.m += sim - sop;
|
|
459
|
+
}
|
|
460
|
+
if (vip && !nextLeft(vom)) {
|
|
461
|
+
vom.t = vip;
|
|
462
|
+
vom.m += sip - som;
|
|
463
|
+
ancestor = v;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return ancestor;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function sizeNode(node) {
|
|
470
|
+
node.x *= dx;
|
|
471
|
+
node.y = node.depth * dy;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
tree.separation = function(x) {
|
|
475
|
+
return arguments.length ? (separation = x, tree) : separation;
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
tree.size = function(x) {
|
|
479
|
+
return arguments.length ? (nodeSize = false, dx = +x[0], dy = +x[1], tree) : (nodeSize ? null : [dx, dy]);
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
tree.nodeSize = function(x) {
|
|
483
|
+
return arguments.length ? (nodeSize = true, dx = +x[0], dy = +x[1], tree) : (nodeSize ? [dx, dy] : null);
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
return tree;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* The corner points of the connector from a parent box to a child box: down to a fork halfway
|
|
491
|
+
* across the level gap, across, and down into the child. For a compact stack, across to a lane on
|
|
492
|
+
* the stack's left and into the child's side.
|
|
493
|
+
*/
|
|
494
|
+
function linkPoints(parent, child, options) {
|
|
495
|
+
if (options.orientation === 'horizontal') {
|
|
496
|
+
const start = {
|
|
497
|
+
x: parent.x + parent.width,
|
|
498
|
+
y: parent.y + parent.height / 2,
|
|
499
|
+
};
|
|
500
|
+
const end = { x: child.x, y: child.y + child.height / 2 };
|
|
501
|
+
const fork = start.x + options.levelGap / 2;
|
|
502
|
+
return [start, { x: fork, y: start.y }, { x: fork, y: end.y }, end];
|
|
503
|
+
}
|
|
504
|
+
const start = { x: parent.x + parent.width / 2, y: parent.y + parent.height };
|
|
505
|
+
const fork = start.y + options.levelGap / 2;
|
|
506
|
+
if (options.stacked) {
|
|
507
|
+
const lane = child.x - options.stackIndent;
|
|
508
|
+
const mid = child.y + child.height / 2;
|
|
509
|
+
return [
|
|
510
|
+
start,
|
|
511
|
+
{ x: start.x, y: fork },
|
|
512
|
+
{ x: lane, y: fork },
|
|
513
|
+
{ x: lane, y: mid },
|
|
514
|
+
{ x: child.x, y: mid },
|
|
515
|
+
];
|
|
516
|
+
}
|
|
517
|
+
const end = { x: child.x + child.width / 2, y: child.y };
|
|
518
|
+
return [start, { x: start.x, y: fork }, { x: end.x, y: fork }, end];
|
|
519
|
+
}
|
|
520
|
+
const VIRTUAL_ROOT = '\u0000root';
|
|
521
|
+
/**
|
|
522
|
+
* Lays out a forest as tidy trees (d3's Buchheim algorithm) with each node's real size. Roots sit
|
|
523
|
+
* side by side. With `compact`, a parent whose visible children are all leaves gets them as one
|
|
524
|
+
* column, which keeps wide teams narrow.
|
|
525
|
+
*/
|
|
526
|
+
function layoutTree(roots, nodes, size, options) {
|
|
527
|
+
const vertical = options.orientation === 'vertical';
|
|
528
|
+
const breadthOf = (s) => (vertical ? s.width : s.height);
|
|
529
|
+
const depthOf = (s) => (vertical ? s.height : s.width);
|
|
530
|
+
const stacked = new Set();
|
|
531
|
+
const build = (id) => {
|
|
532
|
+
const s = size(id);
|
|
533
|
+
const kids = nodes.get(id)?.children ?? [];
|
|
534
|
+
const allLeaves = kids.length > 1 &&
|
|
535
|
+
kids.every(k => (nodes.get(k)?.children.length ?? 0) === 0);
|
|
536
|
+
if (vertical && options.compact && allLeaves) {
|
|
537
|
+
stacked.add(id);
|
|
538
|
+
const widths = kids.map(k => size(k).width);
|
|
539
|
+
const heights = kids.map(k => size(k).height);
|
|
540
|
+
const stackBox = {
|
|
541
|
+
id: `${id}\u0000stack`,
|
|
542
|
+
breadth: Math.max(...widths) + options.stackIndent * 2,
|
|
543
|
+
depth: heights.reduce((a, b) => a + b, 0) +
|
|
544
|
+
options.stackGap * (kids.length - 1),
|
|
545
|
+
stack: kids,
|
|
546
|
+
children: [],
|
|
547
|
+
};
|
|
548
|
+
return {
|
|
549
|
+
id,
|
|
550
|
+
breadth: breadthOf(s),
|
|
551
|
+
depth: depthOf(s),
|
|
552
|
+
children: [stackBox],
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
return {
|
|
556
|
+
id,
|
|
557
|
+
breadth: breadthOf(s),
|
|
558
|
+
depth: depthOf(s),
|
|
559
|
+
children: kids.map(build),
|
|
560
|
+
};
|
|
561
|
+
};
|
|
562
|
+
const forest = {
|
|
563
|
+
id: VIRTUAL_ROOT,
|
|
564
|
+
breadth: 0,
|
|
565
|
+
depth: 0,
|
|
566
|
+
children: roots.map(build),
|
|
567
|
+
};
|
|
568
|
+
const root = hierarchy(forest, b => b.children);
|
|
569
|
+
// Depth extent per level, so levels line up even when cards differ in height. A compact stack
|
|
570
|
+
// has nothing below it, so its height does not push deeper levels down.
|
|
571
|
+
const levelDepth = [];
|
|
572
|
+
root.each(n => {
|
|
573
|
+
const extent = n.data.stack ? 0 : n.data.depth;
|
|
574
|
+
levelDepth[n.depth] = Math.max(levelDepth[n.depth] ?? 0, extent);
|
|
575
|
+
});
|
|
576
|
+
const levelStart = [];
|
|
577
|
+
let cursor = 0;
|
|
578
|
+
levelDepth.forEach((d, i) => {
|
|
579
|
+
levelStart[i] = cursor;
|
|
580
|
+
cursor += d + (i === 0 ? 0 : options.levelGap);
|
|
581
|
+
});
|
|
582
|
+
tree()
|
|
583
|
+
.nodeSize([1, 1])
|
|
584
|
+
.separation((a, b) => (a.data.breadth + b.data.breadth) / 2 +
|
|
585
|
+
options.siblingGap * (a.parent === b.parent ? 1 : 1.5))(root);
|
|
586
|
+
const positions = new Map();
|
|
587
|
+
root.each(node => {
|
|
588
|
+
const n = node;
|
|
589
|
+
if (n.data.id === VIRTUAL_ROOT)
|
|
590
|
+
return;
|
|
591
|
+
const start = levelStart[n.depth];
|
|
592
|
+
const center = n.x;
|
|
593
|
+
if (n.data.stack) {
|
|
594
|
+
// A compact stack: one column with its lane on the left, starting at this level.
|
|
595
|
+
const left = center - n.data.breadth / 2 + options.stackIndent * 2;
|
|
596
|
+
let y = start;
|
|
597
|
+
for (const leaf of n.data.stack) {
|
|
598
|
+
positions.set(leaf, { x: left, y });
|
|
599
|
+
y += size(leaf).height + options.stackGap;
|
|
600
|
+
}
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
const b = center - breadthOf(size(n.data.id)) / 2;
|
|
604
|
+
positions.set(n.data.id, vertical ? { x: b, y: start } : { x: start, y: b });
|
|
605
|
+
});
|
|
606
|
+
return { positions, stacked };
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
var css_248z = i`* {
|
|
610
|
+
box-sizing: border-box;
|
|
611
|
+
-webkit-tap-highlight-color: transparent;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
.screen-reader-only {
|
|
615
|
+
position: absolute !important;
|
|
616
|
+
inline-size: 1px !important;
|
|
617
|
+
block-size: 1px !important;
|
|
618
|
+
padding: 0 !important;
|
|
619
|
+
margin: -1px !important;
|
|
620
|
+
overflow: hidden !important;
|
|
621
|
+
clip-path: inset(50%) !important;
|
|
622
|
+
white-space: nowrap !important;
|
|
623
|
+
border: 0 !important;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
[hidden] {
|
|
627
|
+
display: none !important;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
@media (forced-colors: active) {
|
|
631
|
+
.selected,
|
|
632
|
+
[aria-selected=true],
|
|
633
|
+
[aria-pressed=true],
|
|
634
|
+
[aria-checked=true],
|
|
635
|
+
[aria-current]:not([aria-current=false]) {
|
|
636
|
+
outline: 2px solid Highlight;
|
|
637
|
+
outline-offset: -2px;
|
|
638
|
+
}
|
|
639
|
+
.disabled,
|
|
640
|
+
[aria-disabled=true] {
|
|
641
|
+
color: GrayText;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
:host {
|
|
645
|
+
display: block;
|
|
646
|
+
position: relative;
|
|
647
|
+
inline-size: 100%;
|
|
648
|
+
block-size: 100%;
|
|
649
|
+
min-block-size: 240px;
|
|
650
|
+
overflow: hidden;
|
|
651
|
+
--tree-chart-background: var(--color-surface-container-lowest, #fbfbfd);
|
|
652
|
+
--tree-chart-dot-color: var(--color-outline-variant, #c5c6cb);
|
|
653
|
+
--tree-chart-connector-color: color-mix(in srgb, var(--color-primary, #005faf) 40%, var(--color-outline-variant, #c5c6cb));
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/* Canvas coordinates are physical x/y and do not mirror in right-to-left layouts. */
|
|
657
|
+
/* stylelint-disable property-disallowed-list */
|
|
658
|
+
.tc-viewport {
|
|
659
|
+
position: absolute;
|
|
660
|
+
inset: 0;
|
|
661
|
+
overflow: hidden;
|
|
662
|
+
background-color: var(--tree-chart-background);
|
|
663
|
+
background-image: radial-gradient(var(--tree-chart-dot-color) 1px, transparent 1.2px);
|
|
664
|
+
border: 1px solid var(--color-outline-variant);
|
|
665
|
+
border-radius: var(--shape-corner-large);
|
|
666
|
+
touch-action: none;
|
|
667
|
+
outline: none;
|
|
668
|
+
container-type: inline-size;
|
|
669
|
+
container-name: diagram;
|
|
670
|
+
}
|
|
671
|
+
.tc-viewport:focus-visible {
|
|
672
|
+
box-shadow: inset 0 0 0 2px var(--color-primary);
|
|
673
|
+
}
|
|
674
|
+
.tc-viewport.is-space {
|
|
675
|
+
cursor: grab;
|
|
676
|
+
}
|
|
677
|
+
.tc-viewport.is-panning, .tc-viewport.is-dragging {
|
|
678
|
+
cursor: grabbing;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.tc-world {
|
|
682
|
+
position: absolute;
|
|
683
|
+
left: 0;
|
|
684
|
+
top: 0;
|
|
685
|
+
transform-origin: 0 0;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
.tc-links {
|
|
689
|
+
position: absolute;
|
|
690
|
+
left: 0;
|
|
691
|
+
top: 0;
|
|
692
|
+
overflow: visible;
|
|
693
|
+
pointer-events: none;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
.tc-node {
|
|
697
|
+
position: absolute;
|
|
698
|
+
min-inline-size: 220px;
|
|
699
|
+
max-inline-size: 300px;
|
|
700
|
+
background: var(--color-surface-container-lowest);
|
|
701
|
+
border: 1px solid var(--color-outline-variant);
|
|
702
|
+
border-radius: var(--shape-corner-large);
|
|
703
|
+
box-shadow: var(--elevation-level1);
|
|
704
|
+
cursor: pointer;
|
|
705
|
+
outline: none;
|
|
706
|
+
touch-action: none;
|
|
707
|
+
transition: box-shadow 150ms ease, border-color 150ms ease, opacity 150ms ease;
|
|
708
|
+
}
|
|
709
|
+
.tc-node:hover {
|
|
710
|
+
border-color: var(--color-outline);
|
|
711
|
+
}
|
|
712
|
+
.tc-node:focus-visible {
|
|
713
|
+
outline: 2px solid var(--color-primary);
|
|
714
|
+
outline-offset: 3px;
|
|
715
|
+
}
|
|
716
|
+
.tc-node.is-selected {
|
|
717
|
+
border-color: var(--color-primary);
|
|
718
|
+
box-shadow: 0 0 0 2px var(--color-primary), var(--elevation-level2);
|
|
719
|
+
}
|
|
720
|
+
.tc-node.is-match {
|
|
721
|
+
border-color: var(--color-primary);
|
|
722
|
+
box-shadow: 0 0 0 2px var(--color-primary), var(--elevation-level2);
|
|
723
|
+
}
|
|
724
|
+
.tc-node.is-dim {
|
|
725
|
+
opacity: 0.4;
|
|
726
|
+
}
|
|
727
|
+
.tc-node.is-dragging {
|
|
728
|
+
opacity: 0.4;
|
|
729
|
+
}
|
|
730
|
+
.tc-node.is-drop {
|
|
731
|
+
border-color: var(--color-primary);
|
|
732
|
+
background: var(--color-primary-container);
|
|
733
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 35%, transparent), var(--elevation-level2);
|
|
734
|
+
}
|
|
735
|
+
.tc-node:hover .tc-actions, .tc-node:focus-within .tc-actions, .tc-node.is-selected .tc-actions {
|
|
736
|
+
opacity: 1;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/* stylelint-enable property-disallowed-list */
|
|
740
|
+
.tc-card {
|
|
741
|
+
display: flex;
|
|
742
|
+
align-items: center;
|
|
743
|
+
gap: 12px;
|
|
744
|
+
padding: 12px 14px;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
.tc-tile {
|
|
748
|
+
display: inline-flex;
|
|
749
|
+
align-items: center;
|
|
750
|
+
justify-content: center;
|
|
751
|
+
flex: none;
|
|
752
|
+
inline-size: 36px;
|
|
753
|
+
block-size: 36px;
|
|
754
|
+
border-radius: var(--shape-corner-medium);
|
|
755
|
+
background: var(--_tile-bg, var(--color-primary-container));
|
|
756
|
+
--icon-color: var(--_tile-fg, var(--color-on-primary-container));
|
|
757
|
+
--icon-size: 1.25rem;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
.accent-tertiary {
|
|
761
|
+
--_tile-bg: var(--color-tertiary-container);
|
|
762
|
+
--_tile-fg: var(--color-on-tertiary-container);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
.accent-blue {
|
|
766
|
+
--_tile-bg: var(--color-blue-container);
|
|
767
|
+
--_tile-fg: var(--color-on-blue-container);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
.accent-green {
|
|
771
|
+
--_tile-bg: var(--color-green-container);
|
|
772
|
+
--_tile-fg: var(--color-on-green-container);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
.accent-orange {
|
|
776
|
+
--_tile-bg: var(--color-orange-container);
|
|
777
|
+
--_tile-fg: var(--color-on-orange-container);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
.accent-purple {
|
|
781
|
+
--_tile-bg: var(--color-purple-container);
|
|
782
|
+
--_tile-fg: var(--color-on-purple-container);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.accent-red {
|
|
786
|
+
--_tile-bg: var(--color-error-container);
|
|
787
|
+
--_tile-fg: var(--color-on-error-container);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
.accent-yellow {
|
|
791
|
+
--_tile-bg: var(--color-yellow-container);
|
|
792
|
+
--_tile-fg: var(--color-on-yellow-container);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
.accent-neutral {
|
|
796
|
+
--_tile-bg: var(--color-surface-container-high);
|
|
797
|
+
--_tile-fg: var(--color-on-surface-variant);
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
.tc-text {
|
|
801
|
+
display: flex;
|
|
802
|
+
flex-direction: column;
|
|
803
|
+
flex: 1;
|
|
804
|
+
min-inline-size: 0;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
.tc-headline {
|
|
808
|
+
font-size: 14px;
|
|
809
|
+
font-weight: 500;
|
|
810
|
+
color: var(--color-on-surface);
|
|
811
|
+
white-space: nowrap;
|
|
812
|
+
overflow: hidden;
|
|
813
|
+
text-overflow: ellipsis;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
.tc-sub {
|
|
817
|
+
font-size: 12px;
|
|
818
|
+
color: var(--color-on-surface-variant);
|
|
819
|
+
white-space: nowrap;
|
|
820
|
+
overflow: hidden;
|
|
821
|
+
text-overflow: ellipsis;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
.tc-badge {
|
|
825
|
+
flex: none;
|
|
826
|
+
padding: 2px 8px;
|
|
827
|
+
font-size: 11px;
|
|
828
|
+
font-weight: 500;
|
|
829
|
+
border-radius: var(--shape-corner-full);
|
|
830
|
+
background: var(--color-secondary-container);
|
|
831
|
+
color: var(--color-on-secondary-container);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
.tc-count {
|
|
835
|
+
background: transparent;
|
|
836
|
+
border: none;
|
|
837
|
+
appearance: none;
|
|
838
|
+
margin: 0;
|
|
839
|
+
outline: none;
|
|
840
|
+
padding: 0;
|
|
841
|
+
position: absolute;
|
|
842
|
+
inset-block-end: -12px;
|
|
843
|
+
inset-inline-start: 50%;
|
|
844
|
+
transform: translateX(-50%);
|
|
845
|
+
display: inline-flex;
|
|
846
|
+
align-items: center;
|
|
847
|
+
gap: 2px;
|
|
848
|
+
block-size: 24px;
|
|
849
|
+
padding: 0 6px 0 10px;
|
|
850
|
+
font-size: 12px;
|
|
851
|
+
font-weight: 500;
|
|
852
|
+
font-variant-numeric: tabular-nums;
|
|
853
|
+
color: var(--color-on-surface-variant);
|
|
854
|
+
background: var(--color-surface-container-lowest);
|
|
855
|
+
border: 1px solid var(--color-outline-variant);
|
|
856
|
+
border-radius: var(--shape-corner-full);
|
|
857
|
+
cursor: pointer;
|
|
858
|
+
z-index: 2;
|
|
859
|
+
--icon-size: 1rem;
|
|
860
|
+
}
|
|
861
|
+
.tc-count:hover {
|
|
862
|
+
border-color: var(--color-primary);
|
|
863
|
+
color: var(--color-primary);
|
|
864
|
+
--icon-color: var(--color-primary);
|
|
865
|
+
}
|
|
866
|
+
:host([orientation=horizontal]) .tc-count {
|
|
867
|
+
inset-block-end: auto;
|
|
868
|
+
inset-block-start: 50%;
|
|
869
|
+
inset-inline-start: auto;
|
|
870
|
+
inset-inline-end: -14px;
|
|
871
|
+
transform: translateY(-50%);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
.tc-spin {
|
|
875
|
+
animation: tc-spin 1s linear infinite;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
.tc-actions {
|
|
879
|
+
position: absolute;
|
|
880
|
+
inset-block-start: -14px;
|
|
881
|
+
inset-inline-end: 10px;
|
|
882
|
+
display: inline-flex;
|
|
883
|
+
gap: 4px;
|
|
884
|
+
opacity: 0;
|
|
885
|
+
transition: opacity 150ms ease;
|
|
886
|
+
}
|
|
887
|
+
.tc-actions button {
|
|
888
|
+
background: transparent;
|
|
889
|
+
border: none;
|
|
890
|
+
appearance: none;
|
|
891
|
+
margin: 0;
|
|
892
|
+
outline: none;
|
|
893
|
+
padding: 0;
|
|
894
|
+
display: inline-flex;
|
|
895
|
+
align-items: center;
|
|
896
|
+
justify-content: center;
|
|
897
|
+
inline-size: 26px;
|
|
898
|
+
block-size: 26px;
|
|
899
|
+
border-radius: 50%;
|
|
900
|
+
background: var(--color-primary);
|
|
901
|
+
color: var(--color-on-primary);
|
|
902
|
+
box-shadow: var(--elevation-level2);
|
|
903
|
+
cursor: pointer;
|
|
904
|
+
--icon-color: var(--color-on-primary);
|
|
905
|
+
--icon-size: 1rem;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
.tc-link {
|
|
909
|
+
fill: none;
|
|
910
|
+
stroke: var(--tree-chart-connector-color);
|
|
911
|
+
stroke-width: 2;
|
|
912
|
+
stroke-linecap: round;
|
|
913
|
+
stroke-linejoin: round;
|
|
914
|
+
transition: opacity 150ms ease;
|
|
915
|
+
}
|
|
916
|
+
.tc-link.is-path {
|
|
917
|
+
stroke: var(--color-primary);
|
|
918
|
+
stroke-width: 2.75;
|
|
919
|
+
}
|
|
920
|
+
.tc-link.is-dim {
|
|
921
|
+
opacity: 0.35;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
.tc-ghost {
|
|
925
|
+
position: absolute;
|
|
926
|
+
z-index: 40;
|
|
927
|
+
padding: 8px 14px;
|
|
928
|
+
font-size: 13px;
|
|
929
|
+
font-weight: 500;
|
|
930
|
+
pointer-events: none;
|
|
931
|
+
transform: translate(12px, 12px) rotate(-2deg);
|
|
932
|
+
background: var(--color-surface-container-lowest);
|
|
933
|
+
border: 1px solid var(--color-primary);
|
|
934
|
+
border-radius: var(--shape-corner-medium);
|
|
935
|
+
box-shadow: var(--elevation-level3);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
.back-to-content {
|
|
939
|
+
position: absolute;
|
|
940
|
+
inset-inline-start: 50%;
|
|
941
|
+
inset-block-end: 24px;
|
|
942
|
+
transform: translateX(-50%);
|
|
943
|
+
box-shadow: var(--elevation-level2);
|
|
944
|
+
border-radius: var(--shape-corner-full);
|
|
945
|
+
z-index: 20;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
.slot-controls,
|
|
949
|
+
.slot-minimap {
|
|
950
|
+
position: absolute;
|
|
951
|
+
inset-block-end: 16px;
|
|
952
|
+
z-index: 20;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
.slot-controls {
|
|
956
|
+
inset-inline-start: 16px;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
.slot-minimap {
|
|
960
|
+
inset-inline-end: 16px;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
@container diagram (max-width: 480px) {
|
|
964
|
+
.slot-minimap {
|
|
965
|
+
display: none;
|
|
966
|
+
}
|
|
967
|
+
.slot-controls {
|
|
968
|
+
inset-inline-start: 8px;
|
|
969
|
+
inset-block-end: 8px;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
.sr-only {
|
|
973
|
+
position: absolute;
|
|
974
|
+
inline-size: 1px;
|
|
975
|
+
block-size: 1px;
|
|
976
|
+
padding: 0;
|
|
977
|
+
margin: -1px;
|
|
978
|
+
overflow: hidden;
|
|
979
|
+
clip-path: inset(50%);
|
|
980
|
+
white-space: nowrap;
|
|
981
|
+
border: 0;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
@keyframes tc-spin {
|
|
985
|
+
to {
|
|
986
|
+
transform: rotate(360deg);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
@media (prefers-reduced-motion: reduce) {
|
|
990
|
+
.tc-node,
|
|
991
|
+
.tc-link,
|
|
992
|
+
.tc-actions {
|
|
993
|
+
transition: none;
|
|
994
|
+
}
|
|
995
|
+
.tc-spin {
|
|
996
|
+
animation: none;
|
|
997
|
+
}
|
|
998
|
+
}`;
|
|
999
|
+
|
|
1000
|
+
const DEFAULT_SIZE = { width: 240, height: 72 };
|
|
1001
|
+
/** Below this zoom a fitted tree is hard to read, so it starts at its root instead. */
|
|
1002
|
+
const MIN_FIT_ZOOM = 0.5;
|
|
1003
|
+
const DRAG_THRESHOLD = 5;
|
|
1004
|
+
const INTERACTIVE = 'button, a, input, wc-icon-button, wc-button';
|
|
1005
|
+
const LAYOUT = {
|
|
1006
|
+
siblingGap: 32,
|
|
1007
|
+
levelGap: 64,
|
|
1008
|
+
stackGap: 12,
|
|
1009
|
+
stackIndent: 20,
|
|
1010
|
+
};
|
|
1011
|
+
/**
|
|
1012
|
+
* @label Tree chart
|
|
1013
|
+
* @tag wc-tree-chart
|
|
1014
|
+
* @rawTag tree-chart
|
|
1015
|
+
* @summary A hierarchy laid out as a tidy tree on an infinite canvas: org charts, taxonomies, sitemaps, decision trees.
|
|
1016
|
+
*
|
|
1017
|
+
* @overview
|
|
1018
|
+
* <p>Set <code>items</code> to a flat list where each item names its <code>parentId</code>; the chart lays
|
|
1019
|
+
* the tree out with each card's real size. Top to bottom by default, or left to right with
|
|
1020
|
+
* <code>orientation="horizontal"</code>. <code>compact</code> stacks teams with no further levels in a
|
|
1021
|
+
* column under their manager, which keeps wide organisations narrow.</p>
|
|
1022
|
+
* <p>A card shows an avatar (or an <code>icon</code>), a headline, supporting text and a
|
|
1023
|
+
* <code>badge</code>. Put your own card in <code>slot="item:<id>"</code>. The chip under a card
|
|
1024
|
+
* shows how many items are below it and expands or collapses them (<code>expand</code> and
|
|
1025
|
+
* <code>collapse</code> fire). For lazy loading, give an item <code>hasChildren</code> and add its
|
|
1026
|
+
* children when it fires <code>expand</code>; it shows a spinner until they arrive.</p>
|
|
1027
|
+
* <p><code>search(text)</code> expands the way to every match, highlights the path from the root and
|
|
1028
|
+
* dims the rest, and zooms to the first match; <code>clearSearch()</code> undoes it.</p>
|
|
1029
|
+
* <p>With <code>editable</code>, drag a card onto another to change its parent (never into its own
|
|
1030
|
+
* branch), add an item below or beside with the buttons on a card, and delete with Delete, which
|
|
1031
|
+
* moves the item's children up to its parent. <code>reparent</code>, <code>add</code> and
|
|
1032
|
+
* <code>delete</code> fire first and can be canceled; every edit then fires <code>change</code> with the
|
|
1033
|
+
* new <code>items</code>. Undo with Ctrl+Z. Expanding, collapsing and edits glide.</p>
|
|
1034
|
+
* <p>The tree follows the WAI-ARIA tree pattern with one tab stop. In a vertical chart Up goes to the
|
|
1035
|
+
* parent, Down to the first child, Left and Right to siblings (mirrored in right-to-left); a
|
|
1036
|
+
* horizontal chart turns the keys. Home and End go to the first and last item, <code>*</code> expands
|
|
1037
|
+
* all siblings, Enter selects and Shift + Enter expands or collapses. The canvas is infinite like
|
|
1038
|
+
* <code>wc-diagram</code>, with the <code>controls</code> and <code>minimap</code> slots.</p>
|
|
1039
|
+
*
|
|
1040
|
+
* @example
|
|
1041
|
+
* ```html
|
|
1042
|
+
* <wc-tree-chart id="org" style="height: 500px"></wc-tree-chart>
|
|
1043
|
+
* <script>
|
|
1044
|
+
* document.getElementById('org').items = [
|
|
1045
|
+
* { id: 'ceo', headline: 'Sarah Jenkins', supportingText: 'CEO' },
|
|
1046
|
+
* { id: 'cto', parentId: 'ceo', headline: 'Michael Chen', supportingText: 'CTO', badge: 'Engineering' },
|
|
1047
|
+
* { id: 'cpo', parentId: 'ceo', headline: 'Elena Rostova', supportingText: 'CPO', badge: 'Product' }
|
|
1048
|
+
* ];
|
|
1049
|
+
* </script>
|
|
1050
|
+
* ```
|
|
1051
|
+
*
|
|
1052
|
+
* @slot controls - A `wc-diagram-controls`, shown at the bottom start corner.
|
|
1053
|
+
* @slot minimap - A `wc-diagram-minimap`, shown at the bottom end corner.
|
|
1054
|
+
* @slot item:<id> - Custom content for the item with that id, in place of the built-in card.
|
|
1055
|
+
*
|
|
1056
|
+
* @fires {CustomEvent<TreeChartItemDetail>} select - An item was chosen with a click, Enter or Space. Detail contains `{ id, item }`.
|
|
1057
|
+
* @fires {CustomEvent<TreeChartItemDetail>} expand - An item was expanded. Add its children now when they load lazily. Detail contains `{ id, item }`.
|
|
1058
|
+
* @fires {CustomEvent<TreeChartItemDetail>} collapse - An item was collapsed. Detail contains `{ id, item }`.
|
|
1059
|
+
* @fires {CustomEvent<TreeChartReparentDetail>} reparent - Before a dragged item gets a new parent. Cancel it to keep it where it was. Detail contains `{ id, parentId, previousParentId }`.
|
|
1060
|
+
* @fires {CustomEvent<TreeChartAddDetail>} add - Before a new item is added with a card's buttons. Cancel it to add the item your own way. Detail contains `{ parentId, position, of }`.
|
|
1061
|
+
* @fires {CustomEvent<TreeChartDeleteDetail>} delete - Before an item is removed. Cancel it to keep it. Detail contains `{ ids }`.
|
|
1062
|
+
* @fires {CustomEvent<TreeChartChangeDetail>} change - After every edit. Detail contains `{ items, reason }`.
|
|
1063
|
+
* @fires {CustomEvent<TreeChartViewportDetail>} viewport-change - Once per frame while the camera moves and once when it settles. Detail contains `{ x, y, zoom, settled }`.
|
|
1064
|
+
*
|
|
1065
|
+
* @cssprop --tree-chart-connector-color - Colour of connectors. Defaults to a mix of primary and outline-variant.
|
|
1066
|
+
* @cssprop --tree-chart-background - Canvas background. Defaults to surface-container-lowest.
|
|
1067
|
+
* @tags data
|
|
1068
|
+
*/
|
|
1069
|
+
let TreeChart = class TreeChart extends DiagramCanvasElement {
|
|
1070
|
+
constructor() {
|
|
1071
|
+
// ── Static
|
|
1072
|
+
super(...arguments);
|
|
1073
|
+
// ── Properties
|
|
1074
|
+
/** The items, each naming its parent. Replaced with a new array, never mutated, on every edit. */
|
|
1075
|
+
this.items = [];
|
|
1076
|
+
/** Lays the tree out top to bottom or left to right. */
|
|
1077
|
+
this.orientation = 'vertical';
|
|
1078
|
+
/** Stacks children that have no children of their own in a column (vertical charts). */
|
|
1079
|
+
this.compact = false;
|
|
1080
|
+
/** Id of the selected item. */
|
|
1081
|
+
this.selected = '';
|
|
1082
|
+
// ── State
|
|
1083
|
+
this._collapsed = new Set();
|
|
1084
|
+
this._loading = new Set();
|
|
1085
|
+
this._focusId = '';
|
|
1086
|
+
this._matches = new Set();
|
|
1087
|
+
this._path = new Set();
|
|
1088
|
+
this._announcement = '';
|
|
1089
|
+
this.measure = new MeasureController(this, {
|
|
1090
|
+
elements: () => this.nodeElements(),
|
|
1091
|
+
fallback: DEFAULT_SIZE,
|
|
1092
|
+
});
|
|
1093
|
+
this.history = new History();
|
|
1094
|
+
this.handledKeys = new WeakSet();
|
|
1095
|
+
this.byId = new Map();
|
|
1096
|
+
this.childMap = new Map();
|
|
1097
|
+
this.roots = [];
|
|
1098
|
+
this.seenCollapsed = new Set();
|
|
1099
|
+
/** Laid-out positions from the last render. */
|
|
1100
|
+
this.positions = new Map();
|
|
1101
|
+
this.stacked = new Set();
|
|
1102
|
+
this.overrides = new Map();
|
|
1103
|
+
this.onViewportKeyDown = (event) => {
|
|
1104
|
+
if (event.defaultPrevented || this.handledKeys.has(event))
|
|
1105
|
+
return;
|
|
1106
|
+
const mod = event.ctrlKey || event.metaKey;
|
|
1107
|
+
const key = event.key.toLowerCase();
|
|
1108
|
+
const editing = this.editable && !this.readonly;
|
|
1109
|
+
if (mod && key === 'z' && editing) {
|
|
1110
|
+
event.preventDefault();
|
|
1111
|
+
if (event.shiftKey)
|
|
1112
|
+
this.redo();
|
|
1113
|
+
else
|
|
1114
|
+
this.undo();
|
|
1115
|
+
}
|
|
1116
|
+
else if (mod && key === 'y' && editing) {
|
|
1117
|
+
event.preventDefault();
|
|
1118
|
+
this.redo();
|
|
1119
|
+
}
|
|
1120
|
+
else if (key === 'escape') {
|
|
1121
|
+
event.preventDefault();
|
|
1122
|
+
this.selected = '';
|
|
1123
|
+
this.clearSearch();
|
|
1124
|
+
}
|
|
1125
|
+
else
|
|
1126
|
+
this.handleCanvasKey(event);
|
|
1127
|
+
};
|
|
1128
|
+
this.onDragMove = (event) => {
|
|
1129
|
+
const drag = this.nodeDrag;
|
|
1130
|
+
if (!drag ||
|
|
1131
|
+
event.pointerId !== drag.pointerId ||
|
|
1132
|
+
!this.editable ||
|
|
1133
|
+
this.readonly)
|
|
1134
|
+
return;
|
|
1135
|
+
if (!drag.moved &&
|
|
1136
|
+
Math.hypot(event.clientX - drag.startX, event.clientY - drag.startY) <
|
|
1137
|
+
DRAG_THRESHOLD) {
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
drag.moved = true;
|
|
1141
|
+
const vr = this._viewportEl?.getBoundingClientRect();
|
|
1142
|
+
const point = this.viewport.toCanvas(event.clientX, event.clientY);
|
|
1143
|
+
let target;
|
|
1144
|
+
for (const id of this.positions.keys()) {
|
|
1145
|
+
const r = this.rectOf(id);
|
|
1146
|
+
if (id !== drag.id &&
|
|
1147
|
+
point.x >= r.x &&
|
|
1148
|
+
point.x <= r.x + r.width &&
|
|
1149
|
+
point.y >= r.y &&
|
|
1150
|
+
point.y <= r.y + r.height &&
|
|
1151
|
+
!this.isWithin(id, drag.id)) {
|
|
1152
|
+
target = id;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
this._drag = {
|
|
1156
|
+
id: drag.id,
|
|
1157
|
+
x: event.clientX - (vr?.left ?? 0),
|
|
1158
|
+
y: event.clientY - (vr?.top ?? 0),
|
|
1159
|
+
target,
|
|
1160
|
+
};
|
|
1161
|
+
};
|
|
1162
|
+
this.onDragUp = (event) => {
|
|
1163
|
+
if (!this.nodeDrag || event.pointerId !== this.nodeDrag.pointerId)
|
|
1164
|
+
return;
|
|
1165
|
+
this.endDrag(true);
|
|
1166
|
+
};
|
|
1167
|
+
this.onDragCancel = () => {
|
|
1168
|
+
this.endDrag(false);
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
// ── Lifecycle
|
|
1172
|
+
disconnectedCallback() {
|
|
1173
|
+
super.disconnectedCallback();
|
|
1174
|
+
this.stopGlide?.();
|
|
1175
|
+
this.endDrag(false);
|
|
1176
|
+
}
|
|
1177
|
+
willUpdate(changed) {
|
|
1178
|
+
super.willUpdate(changed);
|
|
1179
|
+
if (changed.has('items'))
|
|
1180
|
+
this.indexItems();
|
|
1181
|
+
}
|
|
1182
|
+
updated(changed) {
|
|
1183
|
+
this.playGlide();
|
|
1184
|
+
if (this.pendingZoom) {
|
|
1185
|
+
const id = this.pendingZoom;
|
|
1186
|
+
this.pendingZoom = undefined;
|
|
1187
|
+
this.zoomTo(id);
|
|
1188
|
+
}
|
|
1189
|
+
super.updated(changed);
|
|
1190
|
+
}
|
|
1191
|
+
// ── Public API
|
|
1192
|
+
/** Whether `undo()` has something to undo. */
|
|
1193
|
+
get canUndo() {
|
|
1194
|
+
return this.history.canUndo;
|
|
1195
|
+
}
|
|
1196
|
+
/** Whether `redo()` has something to redo. */
|
|
1197
|
+
get canRedo() {
|
|
1198
|
+
return this.history.canRedo;
|
|
1199
|
+
}
|
|
1200
|
+
undo() {
|
|
1201
|
+
const previous = this.history.undo(this.items);
|
|
1202
|
+
if (previous)
|
|
1203
|
+
this.commit(previous, 'undo', false);
|
|
1204
|
+
}
|
|
1205
|
+
redo() {
|
|
1206
|
+
const next = this.history.redo(this.items);
|
|
1207
|
+
if (next)
|
|
1208
|
+
this.commit(next, 'redo', false);
|
|
1209
|
+
}
|
|
1210
|
+
/** Forgets the undo and redo history. */
|
|
1211
|
+
clearHistory() {
|
|
1212
|
+
this.history.clear();
|
|
1213
|
+
this.listeners.notify();
|
|
1214
|
+
}
|
|
1215
|
+
expand(id) {
|
|
1216
|
+
const item = this.byId.get(id);
|
|
1217
|
+
if (!item || !this._collapsed.has(id)) {
|
|
1218
|
+
if (item?.hasChildren && !this.childMap.get(id)?.length)
|
|
1219
|
+
this.requestChildren(item);
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
this.glide(() => {
|
|
1223
|
+
const next = new Set(this._collapsed);
|
|
1224
|
+
next.delete(id);
|
|
1225
|
+
this._collapsed = next;
|
|
1226
|
+
}, id);
|
|
1227
|
+
if (item.hasChildren && !this.childMap.get(id)?.length)
|
|
1228
|
+
this.requestChildren(item);
|
|
1229
|
+
else
|
|
1230
|
+
this.emit('expand', { id, item });
|
|
1231
|
+
}
|
|
1232
|
+
collapse(id) {
|
|
1233
|
+
const item = this.byId.get(id);
|
|
1234
|
+
if (!item || this._collapsed.has(id) || !this.hasKids(id))
|
|
1235
|
+
return;
|
|
1236
|
+
this.glide(() => {
|
|
1237
|
+
const next = new Set(this._collapsed);
|
|
1238
|
+
next.add(id);
|
|
1239
|
+
this._collapsed = next;
|
|
1240
|
+
}, id);
|
|
1241
|
+
this.emit('collapse', { id, item });
|
|
1242
|
+
}
|
|
1243
|
+
/** Expands every item. */
|
|
1244
|
+
expandAll() {
|
|
1245
|
+
this.glide(() => {
|
|
1246
|
+
this._collapsed = new Set();
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Highlights the items whose headline, supporting text or badge contains `text`, expands the way
|
|
1251
|
+
* to them, dims the rest and zooms to the first. Returns the ids of the matches.
|
|
1252
|
+
*/
|
|
1253
|
+
search(text) {
|
|
1254
|
+
const needle = text.trim().toLowerCase();
|
|
1255
|
+
if (!needle) {
|
|
1256
|
+
this.clearSearch();
|
|
1257
|
+
return [];
|
|
1258
|
+
}
|
|
1259
|
+
const matches = this.items
|
|
1260
|
+
.filter(i => [i.headline, i.supportingText, i.badge].some(v => v?.toLowerCase().includes(needle)))
|
|
1261
|
+
.map(i => i.id);
|
|
1262
|
+
const path = new Set();
|
|
1263
|
+
const collapsed = new Set(this._collapsed);
|
|
1264
|
+
for (const id of matches) {
|
|
1265
|
+
let cursor = id;
|
|
1266
|
+
while (cursor) {
|
|
1267
|
+
path.add(cursor);
|
|
1268
|
+
const parent = this.parentOf(cursor);
|
|
1269
|
+
if (parent)
|
|
1270
|
+
collapsed.delete(parent);
|
|
1271
|
+
cursor = parent;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
this._collapsed = collapsed;
|
|
1275
|
+
this._matches = new Set(matches);
|
|
1276
|
+
this._path = path;
|
|
1277
|
+
this.announce(this.i18n.t('treeChartMatches')(matches.length));
|
|
1278
|
+
const [first] = matches;
|
|
1279
|
+
if (first)
|
|
1280
|
+
this.pendingZoom = first;
|
|
1281
|
+
return matches;
|
|
1282
|
+
}
|
|
1283
|
+
clearSearch() {
|
|
1284
|
+
this._matches = new Set();
|
|
1285
|
+
this._path = new Set();
|
|
1286
|
+
}
|
|
1287
|
+
/** Selects an item, fires `select`, and brings it into view. */
|
|
1288
|
+
selectItem(id) {
|
|
1289
|
+
const item = this.byId.get(id);
|
|
1290
|
+
if (!item)
|
|
1291
|
+
return;
|
|
1292
|
+
this.select(item);
|
|
1293
|
+
this.focusItem(id);
|
|
1294
|
+
}
|
|
1295
|
+
/** Moves keyboard focus to an item and pans it into view. */
|
|
1296
|
+
focusItem(id) {
|
|
1297
|
+
this._focusId = id;
|
|
1298
|
+
this.updateComplete.then(() => {
|
|
1299
|
+
this.nodeElement(id)?.focus({ preventScroll: true });
|
|
1300
|
+
this.keepInView(id);
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
// ── Canvas hooks
|
|
1304
|
+
viewportElement() {
|
|
1305
|
+
return this._viewportEl;
|
|
1306
|
+
}
|
|
1307
|
+
contentBounds() {
|
|
1308
|
+
return boundsOf([...this.positions.keys()].map(id => this.rectOf(id)));
|
|
1309
|
+
}
|
|
1310
|
+
selectionRects() {
|
|
1311
|
+
return this.selected && this.positions.has(this.selected)
|
|
1312
|
+
? [this.rectOf(this.selected)]
|
|
1313
|
+
: [];
|
|
1314
|
+
}
|
|
1315
|
+
itemRect(id) {
|
|
1316
|
+
return this.positions.has(id) ? this.rectOf(id) : undefined;
|
|
1317
|
+
}
|
|
1318
|
+
firstItemRect() {
|
|
1319
|
+
return this.roots[0] && this.positions.has(this.roots[0])
|
|
1320
|
+
? this.rectOf(this.roots[0])
|
|
1321
|
+
: undefined;
|
|
1322
|
+
}
|
|
1323
|
+
overviewItems() {
|
|
1324
|
+
return [...this.positions.keys()].map(id => ({
|
|
1325
|
+
...this.rectOf(id),
|
|
1326
|
+
selected: id === this.selected,
|
|
1327
|
+
}));
|
|
1328
|
+
}
|
|
1329
|
+
isBackground(target) {
|
|
1330
|
+
const el = target;
|
|
1331
|
+
if (!el)
|
|
1332
|
+
return false;
|
|
1333
|
+
return (el === this._viewportEl ||
|
|
1334
|
+
['tc-world', 'tc-links', 'tc-nodes'].some(c => el.classList?.contains(c)));
|
|
1335
|
+
}
|
|
1336
|
+
onBackgroundClick() {
|
|
1337
|
+
this.selected = '';
|
|
1338
|
+
}
|
|
1339
|
+
/** Fits the tree, or shows its root at 50% when fitting it all would be too small to read. */
|
|
1340
|
+
computeStartView() {
|
|
1341
|
+
if (this.startView || this.startPosition !== 'fit')
|
|
1342
|
+
return super.computeStartView();
|
|
1343
|
+
const bounds = this.contentBounds();
|
|
1344
|
+
const first = this.firstItemRect();
|
|
1345
|
+
if (!bounds || !first)
|
|
1346
|
+
return super.computeStartView();
|
|
1347
|
+
const fitted = this.viewport.viewForRect(bounds, this.padding);
|
|
1348
|
+
if (fitted.zoom >= MIN_FIT_ZOOM)
|
|
1349
|
+
return fitted;
|
|
1350
|
+
const zoom = MIN_FIT_ZOOM;
|
|
1351
|
+
const { width, height } = this.viewport.size();
|
|
1352
|
+
return this.orientation === 'vertical'
|
|
1353
|
+
? {
|
|
1354
|
+
zoom,
|
|
1355
|
+
x: width / 2 - (first.x + first.width / 2) * zoom,
|
|
1356
|
+
y: this.padding - first.y * zoom,
|
|
1357
|
+
}
|
|
1358
|
+
: {
|
|
1359
|
+
zoom,
|
|
1360
|
+
x: this.padding - first.x * zoom,
|
|
1361
|
+
y: height / 2 - (first.y + first.height / 2) * zoom,
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
// ── Private methods: data
|
|
1365
|
+
indexItems() {
|
|
1366
|
+
this.byId = new Map(this.items.map(i => [i.id, i]));
|
|
1367
|
+
this.childMap = new Map();
|
|
1368
|
+
this.roots = [];
|
|
1369
|
+
for (const item of this.items) {
|
|
1370
|
+
const parent = item.parentId && this.byId.has(item.parentId)
|
|
1371
|
+
? item.parentId
|
|
1372
|
+
: undefined;
|
|
1373
|
+
if (parent) {
|
|
1374
|
+
const list = this.childMap.get(parent) ?? [];
|
|
1375
|
+
list.push(item.id);
|
|
1376
|
+
this.childMap.set(parent, list);
|
|
1377
|
+
}
|
|
1378
|
+
else {
|
|
1379
|
+
this.roots.push(item.id);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
let collapsed;
|
|
1383
|
+
for (const item of this.items) {
|
|
1384
|
+
if (item.collapsed && !this.seenCollapsed.has(item.id)) {
|
|
1385
|
+
this.seenCollapsed.add(item.id);
|
|
1386
|
+
collapsed = collapsed ?? new Set(this._collapsed);
|
|
1387
|
+
collapsed.add(item.id);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
if (collapsed)
|
|
1391
|
+
this._collapsed = collapsed;
|
|
1392
|
+
if (this._loading.size) {
|
|
1393
|
+
const loading = new Set([...this._loading].filter(id => this.byId.get(id)?.hasChildren && !this.childMap.get(id)?.length));
|
|
1394
|
+
if (loading.size !== this._loading.size)
|
|
1395
|
+
this._loading = loading;
|
|
1396
|
+
}
|
|
1397
|
+
if (this.selected && !this.byId.has(this.selected))
|
|
1398
|
+
this.selected = '';
|
|
1399
|
+
this.measure.retain(new Set(this.byId.keys()));
|
|
1400
|
+
}
|
|
1401
|
+
parentOf(id) {
|
|
1402
|
+
const p = this.byId.get(id)?.parentId;
|
|
1403
|
+
return p && this.byId.has(p) ? p : undefined;
|
|
1404
|
+
}
|
|
1405
|
+
hasKids(id) {
|
|
1406
|
+
return !!this.childMap.get(id)?.length || !!this.byId.get(id)?.hasChildren;
|
|
1407
|
+
}
|
|
1408
|
+
/** Whether `id` is `ancestor` or below it. */
|
|
1409
|
+
isWithin(id, ancestor) {
|
|
1410
|
+
let cursor = id;
|
|
1411
|
+
while (cursor) {
|
|
1412
|
+
if (cursor === ancestor)
|
|
1413
|
+
return true;
|
|
1414
|
+
cursor = this.parentOf(cursor);
|
|
1415
|
+
}
|
|
1416
|
+
return false;
|
|
1417
|
+
}
|
|
1418
|
+
requestChildren(item) {
|
|
1419
|
+
const next = new Set(this._loading);
|
|
1420
|
+
next.add(item.id);
|
|
1421
|
+
this._loading = next;
|
|
1422
|
+
this.emit('expand', { id: item.id, item });
|
|
1423
|
+
}
|
|
1424
|
+
commit(next, reason, record = true) {
|
|
1425
|
+
if (record)
|
|
1426
|
+
this.history.push(this.items);
|
|
1427
|
+
this.glide(() => {
|
|
1428
|
+
this.items = next;
|
|
1429
|
+
});
|
|
1430
|
+
this.emit('change', { items: next, reason });
|
|
1431
|
+
this.listeners.notify();
|
|
1432
|
+
}
|
|
1433
|
+
announce(message) {
|
|
1434
|
+
this._announcement = '';
|
|
1435
|
+
requestAnimationFrame(() => {
|
|
1436
|
+
this._announcement = message;
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
select(item) {
|
|
1440
|
+
this.selected = item.id;
|
|
1441
|
+
this.emit('select', { id: item.id, item });
|
|
1442
|
+
}
|
|
1443
|
+
uniqueId(base) {
|
|
1444
|
+
if (!this.byId.has(base))
|
|
1445
|
+
return base;
|
|
1446
|
+
let i = 2;
|
|
1447
|
+
while (this.byId.has(`${base}-${i}`))
|
|
1448
|
+
i += 1;
|
|
1449
|
+
return `${base}-${i}`;
|
|
1450
|
+
}
|
|
1451
|
+
reparent(id, parentId) {
|
|
1452
|
+
const item = this.byId.get(id);
|
|
1453
|
+
if (!item || (parentId && this.isWithin(parentId, id)))
|
|
1454
|
+
return;
|
|
1455
|
+
const previousParentId = this.parentOf(id) ?? null;
|
|
1456
|
+
if (previousParentId === parentId)
|
|
1457
|
+
return;
|
|
1458
|
+
const allowed = this.emit('reparent', { id, parentId, previousParentId }, true);
|
|
1459
|
+
if (!allowed)
|
|
1460
|
+
return;
|
|
1461
|
+
if (parentId && this._collapsed.has(parentId)) {
|
|
1462
|
+
const next = new Set(this._collapsed);
|
|
1463
|
+
next.delete(parentId);
|
|
1464
|
+
this._collapsed = next;
|
|
1465
|
+
}
|
|
1466
|
+
this.commit(this.items.map(i => (i.id === id ? { ...i, parentId } : i)), 'move');
|
|
1467
|
+
const parent = parentId ? this.byId.get(parentId) : undefined;
|
|
1468
|
+
this.announce(this.i18n.t('treeChartMoved')(item.headline, parent?.headline ?? ''));
|
|
1469
|
+
}
|
|
1470
|
+
add(of, position) {
|
|
1471
|
+
const parentId = position === 'child' ? of : (this.parentOf(of) ?? null);
|
|
1472
|
+
const allowed = this.emit('add', { parentId, position, of }, true);
|
|
1473
|
+
if (!allowed)
|
|
1474
|
+
return;
|
|
1475
|
+
const item = {
|
|
1476
|
+
id: this.uniqueId('item'),
|
|
1477
|
+
parentId,
|
|
1478
|
+
headline: this.i18n.t('treeChartNewItem'),
|
|
1479
|
+
};
|
|
1480
|
+
const at = this.items.findIndex(i => i.id === of);
|
|
1481
|
+
const next = [
|
|
1482
|
+
...this.items.slice(0, at + 1),
|
|
1483
|
+
item,
|
|
1484
|
+
...this.items.slice(at + 1),
|
|
1485
|
+
];
|
|
1486
|
+
if (parentId && this._collapsed.has(parentId)) {
|
|
1487
|
+
const collapsed = new Set(this._collapsed);
|
|
1488
|
+
collapsed.delete(parentId);
|
|
1489
|
+
this._collapsed = collapsed;
|
|
1490
|
+
}
|
|
1491
|
+
this.commit(next, 'add');
|
|
1492
|
+
this.selected = item.id;
|
|
1493
|
+
this.emit('select', { id: item.id, item });
|
|
1494
|
+
this.focusItem(item.id);
|
|
1495
|
+
}
|
|
1496
|
+
/** Removes an item; its children move up to its parent. */
|
|
1497
|
+
removeItem(id) {
|
|
1498
|
+
const item = this.byId.get(id);
|
|
1499
|
+
if (!item)
|
|
1500
|
+
return;
|
|
1501
|
+
if (!this.emit('delete', { ids: [id] }, true))
|
|
1502
|
+
return;
|
|
1503
|
+
const parentId = this.parentOf(id) ?? null;
|
|
1504
|
+
const siblings = parentId
|
|
1505
|
+
? (this.childMap.get(parentId) ?? [])
|
|
1506
|
+
: this.roots;
|
|
1507
|
+
const neighbour = siblings[siblings.indexOf(id) + 1] ??
|
|
1508
|
+
siblings[siblings.indexOf(id) - 1] ??
|
|
1509
|
+
parentId;
|
|
1510
|
+
this.commit(this.items
|
|
1511
|
+
.filter(i => i.id !== id)
|
|
1512
|
+
.map(i => (i.parentId === id ? { ...i, parentId } : i)), 'remove');
|
|
1513
|
+
this.announce(this.i18n.t('treeChartRemoved')(item.headline));
|
|
1514
|
+
if (neighbour)
|
|
1515
|
+
this.focusItem(neighbour);
|
|
1516
|
+
}
|
|
1517
|
+
// ── Private methods: layout and motion
|
|
1518
|
+
layout() {
|
|
1519
|
+
const nodes = new Map();
|
|
1520
|
+
const visit = (id) => {
|
|
1521
|
+
const kids = this._collapsed.has(id) ? [] : (this.childMap.get(id) ?? []);
|
|
1522
|
+
nodes.set(id, { id, children: kids });
|
|
1523
|
+
kids.forEach(visit);
|
|
1524
|
+
};
|
|
1525
|
+
this.roots.forEach(visit);
|
|
1526
|
+
const result = layoutTree(this.roots, nodes, id => this.measure.size(id), {
|
|
1527
|
+
...LAYOUT,
|
|
1528
|
+
orientation: this.orientation,
|
|
1529
|
+
compact: this.compact,
|
|
1530
|
+
});
|
|
1531
|
+
this.positions = result.positions;
|
|
1532
|
+
this.stacked = result.stacked;
|
|
1533
|
+
}
|
|
1534
|
+
positionOf(id) {
|
|
1535
|
+
return this.overrides.get(id) ?? this.positions.get(id) ?? { x: 0, y: 0 };
|
|
1536
|
+
}
|
|
1537
|
+
rectOf(id) {
|
|
1538
|
+
const p = this.positionOf(id);
|
|
1539
|
+
const s = this.measure.size(id);
|
|
1540
|
+
return { x: p.x, y: p.y, width: s.width, height: s.height };
|
|
1541
|
+
}
|
|
1542
|
+
/** Runs a change and glides items from where they were; new items grow out of `anchor`. */
|
|
1543
|
+
glide(change, anchor) {
|
|
1544
|
+
if (!prefersReducedMotion() && this.positions.size) {
|
|
1545
|
+
this.glideFrom = { positions: new Map(this.positions), anchor };
|
|
1546
|
+
}
|
|
1547
|
+
change();
|
|
1548
|
+
}
|
|
1549
|
+
playGlide() {
|
|
1550
|
+
const from = this.glideFrom;
|
|
1551
|
+
this.glideFrom = undefined;
|
|
1552
|
+
if (!from)
|
|
1553
|
+
return;
|
|
1554
|
+
this.stopGlide?.();
|
|
1555
|
+
const to = new Map(this.positions);
|
|
1556
|
+
const start = new Map();
|
|
1557
|
+
for (const [id, target] of to) {
|
|
1558
|
+
let origin = from.positions.get(id);
|
|
1559
|
+
if (!origin) {
|
|
1560
|
+
// New items start at their nearest visible ancestor, or the anchor.
|
|
1561
|
+
let cursor = this.parentOf(id);
|
|
1562
|
+
while (cursor && !from.positions.has(cursor))
|
|
1563
|
+
cursor = this.parentOf(cursor);
|
|
1564
|
+
origin = from.positions.get(cursor ?? from.anchor ?? '') ?? target;
|
|
1565
|
+
}
|
|
1566
|
+
if (origin.x !== target.x || origin.y !== target.y)
|
|
1567
|
+
start.set(id, origin);
|
|
1568
|
+
}
|
|
1569
|
+
if (!start.size)
|
|
1570
|
+
return;
|
|
1571
|
+
this.stopGlide = tween({
|
|
1572
|
+
duration: 320,
|
|
1573
|
+
easing: easeOutCubic,
|
|
1574
|
+
onUpdate: p => {
|
|
1575
|
+
for (const [id, origin] of start) {
|
|
1576
|
+
const target = to.get(id) ?? origin;
|
|
1577
|
+
this.overrides.set(id, {
|
|
1578
|
+
x: origin.x + (target.x - origin.x) * p,
|
|
1579
|
+
y: origin.y + (target.y - origin.y) * p,
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
this.requestUpdate();
|
|
1583
|
+
},
|
|
1584
|
+
onDone: () => {
|
|
1585
|
+
this.overrides.clear();
|
|
1586
|
+
this.stopGlide = undefined;
|
|
1587
|
+
this.requestUpdate();
|
|
1588
|
+
},
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
keepInView(id) {
|
|
1592
|
+
const r = this.itemRect(id);
|
|
1593
|
+
if (!r)
|
|
1594
|
+
return;
|
|
1595
|
+
const v = this.viewport.visibleRect();
|
|
1596
|
+
const inside = r.x >= v.x &&
|
|
1597
|
+
r.y >= v.y &&
|
|
1598
|
+
r.x + r.width <= v.x + v.width &&
|
|
1599
|
+
r.y + r.height <= v.y + v.height;
|
|
1600
|
+
if (!inside)
|
|
1601
|
+
this.centerOn(r.x + r.width / 2, r.y + r.height / 2);
|
|
1602
|
+
}
|
|
1603
|
+
// ── Private methods: nodes
|
|
1604
|
+
nodeElements() {
|
|
1605
|
+
const out = [];
|
|
1606
|
+
this.renderRoot.querySelectorAll('.tc-node').forEach(el => {
|
|
1607
|
+
if (el.dataset.id)
|
|
1608
|
+
out.push([el.dataset.id, el]);
|
|
1609
|
+
});
|
|
1610
|
+
return out;
|
|
1611
|
+
}
|
|
1612
|
+
nodeElement(id) {
|
|
1613
|
+
return this.renderRoot.querySelector(`.tc-node[data-id="${CSS.escape(id)}"]`);
|
|
1614
|
+
}
|
|
1615
|
+
/** Visible items in reading order. */
|
|
1616
|
+
visibleOrder() {
|
|
1617
|
+
const out = [];
|
|
1618
|
+
const visit = (id) => {
|
|
1619
|
+
out.push(id);
|
|
1620
|
+
if (!this._collapsed.has(id))
|
|
1621
|
+
(this.childMap.get(id) ?? []).forEach(visit);
|
|
1622
|
+
};
|
|
1623
|
+
this.roots.forEach(visit);
|
|
1624
|
+
return out;
|
|
1625
|
+
}
|
|
1626
|
+
siblingsOf(id) {
|
|
1627
|
+
const parent = this.parentOf(id);
|
|
1628
|
+
return parent ? (this.childMap.get(parent) ?? []) : this.roots;
|
|
1629
|
+
}
|
|
1630
|
+
onNodeKeyDown(event, item) {
|
|
1631
|
+
if (event.target !== event.currentTarget)
|
|
1632
|
+
return;
|
|
1633
|
+
const handled = (fn) => {
|
|
1634
|
+
event.preventDefault();
|
|
1635
|
+
this.handledKeys.add(event);
|
|
1636
|
+
fn();
|
|
1637
|
+
};
|
|
1638
|
+
const { key } = event;
|
|
1639
|
+
const vertical = this.orientation === 'vertical';
|
|
1640
|
+
const rtl = getComputedStyle(this).direction === 'rtl';
|
|
1641
|
+
// The keys that point "back" and "forward" along a row, mirrored in right-to-left pages.
|
|
1642
|
+
const back = rtl ? 'ArrowRight' : 'ArrowLeft';
|
|
1643
|
+
const forward = rtl ? 'ArrowLeft' : 'ArrowRight';
|
|
1644
|
+
const toParent = vertical ? 'ArrowUp' : back;
|
|
1645
|
+
const toChild = vertical ? 'ArrowDown' : forward;
|
|
1646
|
+
const prevSibling = vertical ? back : 'ArrowUp';
|
|
1647
|
+
const nextSibling = vertical ? forward : 'ArrowDown';
|
|
1648
|
+
const siblings = this.siblingsOf(item.id);
|
|
1649
|
+
const at = siblings.indexOf(item.id);
|
|
1650
|
+
const order = this.visibleOrder();
|
|
1651
|
+
const firstChild = this._collapsed.has(item.id)
|
|
1652
|
+
? undefined
|
|
1653
|
+
: this.childMap.get(item.id)?.[0];
|
|
1654
|
+
if (key === 'Enter' && event.shiftKey) {
|
|
1655
|
+
handled(() => this._collapsed.has(item.id)
|
|
1656
|
+
? this.expand(item.id)
|
|
1657
|
+
: this.collapse(item.id));
|
|
1658
|
+
}
|
|
1659
|
+
else if (key === 'Enter' || key === ' ') {
|
|
1660
|
+
handled(() => this.select(item));
|
|
1661
|
+
}
|
|
1662
|
+
else if (key === toParent && this.parentOf(item.id)) {
|
|
1663
|
+
handled(() => this.focusItem(this.parentOf(item.id) ?? item.id));
|
|
1664
|
+
}
|
|
1665
|
+
else if (key === toChild && firstChild) {
|
|
1666
|
+
handled(() => this.focusItem(firstChild));
|
|
1667
|
+
}
|
|
1668
|
+
else if (key === toChild && this._collapsed.has(item.id)) {
|
|
1669
|
+
handled(() => this.expand(item.id));
|
|
1670
|
+
}
|
|
1671
|
+
else if (key === prevSibling && siblings[at - 1]) {
|
|
1672
|
+
handled(() => this.focusItem(siblings[at - 1]));
|
|
1673
|
+
}
|
|
1674
|
+
else if (key === nextSibling && siblings[at + 1]) {
|
|
1675
|
+
handled(() => this.focusItem(siblings[at + 1]));
|
|
1676
|
+
}
|
|
1677
|
+
else if (key === 'Home' && order[0]) {
|
|
1678
|
+
handled(() => this.focusItem(order[0]));
|
|
1679
|
+
}
|
|
1680
|
+
else if (key === 'End' && order.length) {
|
|
1681
|
+
handled(() => this.focusItem(order[order.length - 1]));
|
|
1682
|
+
}
|
|
1683
|
+
else if (key === '*') {
|
|
1684
|
+
handled(() => siblings.forEach(id => this.expand(id)));
|
|
1685
|
+
}
|
|
1686
|
+
else if ((key === 'Delete' || key === 'Backspace') &&
|
|
1687
|
+
this.editable &&
|
|
1688
|
+
!this.readonly) {
|
|
1689
|
+
handled(() => this.removeItem(item.id));
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
onNodePointerDown(event, item) {
|
|
1693
|
+
if (event.button !== 0 || this.viewport.spaceHeld)
|
|
1694
|
+
return;
|
|
1695
|
+
const origin = event.composedPath()[0];
|
|
1696
|
+
if (origin instanceof Element && origin.closest(INTERACTIVE))
|
|
1697
|
+
return;
|
|
1698
|
+
event.stopPropagation();
|
|
1699
|
+
const element = event.currentTarget;
|
|
1700
|
+
element.focus({ preventScroll: true });
|
|
1701
|
+
this._focusId = item.id;
|
|
1702
|
+
this.nodeDrag = {
|
|
1703
|
+
pointerId: event.pointerId,
|
|
1704
|
+
startX: event.clientX,
|
|
1705
|
+
startY: event.clientY,
|
|
1706
|
+
id: item.id,
|
|
1707
|
+
element,
|
|
1708
|
+
moved: false,
|
|
1709
|
+
};
|
|
1710
|
+
try {
|
|
1711
|
+
element.setPointerCapture(event.pointerId);
|
|
1712
|
+
}
|
|
1713
|
+
catch {
|
|
1714
|
+
// Synthetic pointers cannot be captured.
|
|
1715
|
+
}
|
|
1716
|
+
element.addEventListener('pointermove', this.onDragMove);
|
|
1717
|
+
element.addEventListener('pointerup', this.onDragUp);
|
|
1718
|
+
element.addEventListener('pointercancel', this.onDragCancel);
|
|
1719
|
+
}
|
|
1720
|
+
endDrag(commit) {
|
|
1721
|
+
const drag = this.nodeDrag;
|
|
1722
|
+
if (!drag)
|
|
1723
|
+
return;
|
|
1724
|
+
this.nodeDrag = undefined;
|
|
1725
|
+
const target = this._drag?.target;
|
|
1726
|
+
this._drag = undefined;
|
|
1727
|
+
drag.element.removeEventListener('pointermove', this.onDragMove);
|
|
1728
|
+
drag.element.removeEventListener('pointerup', this.onDragUp);
|
|
1729
|
+
drag.element.removeEventListener('pointercancel', this.onDragCancel);
|
|
1730
|
+
try {
|
|
1731
|
+
if (drag.element.hasPointerCapture(drag.pointerId)) {
|
|
1732
|
+
drag.element.releasePointerCapture(drag.pointerId);
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
catch {
|
|
1736
|
+
// The pointer is already gone.
|
|
1737
|
+
}
|
|
1738
|
+
if (!commit)
|
|
1739
|
+
return;
|
|
1740
|
+
const item = this.byId.get(drag.id);
|
|
1741
|
+
if (!item)
|
|
1742
|
+
return;
|
|
1743
|
+
if (!drag.moved)
|
|
1744
|
+
this.select(item);
|
|
1745
|
+
else if (target)
|
|
1746
|
+
this.reparent(drag.id, target);
|
|
1747
|
+
}
|
|
1748
|
+
// ── Render
|
|
1749
|
+
renderNode(id, focusId) {
|
|
1750
|
+
const item = this.byId.get(id);
|
|
1751
|
+
if (!item)
|
|
1752
|
+
return A;
|
|
1753
|
+
const p = this.positionOf(id);
|
|
1754
|
+
const kids = this.childMap.get(id) ?? [];
|
|
1755
|
+
const expandable = this.hasKids(id);
|
|
1756
|
+
const collapsed = this._collapsed.has(id) || (!!item.hasChildren && !kids.length);
|
|
1757
|
+
const loading = this._loading.has(id);
|
|
1758
|
+
const siblings = this.siblingsOf(id);
|
|
1759
|
+
let depth = 1;
|
|
1760
|
+
for (let c = this.parentOf(id); c; c = this.parentOf(c))
|
|
1761
|
+
depth += 1;
|
|
1762
|
+
const searching = this._path.size > 0;
|
|
1763
|
+
const editing = this.editable && !this.readonly;
|
|
1764
|
+
const avatar = item.icon
|
|
1765
|
+
? b `<span class=${`tc-tile accent-${item.accent ?? 'primary'}`}
|
|
1766
|
+
><wc-icon name=${item.icon}></wc-icon
|
|
1767
|
+
></span>`
|
|
1768
|
+
: b `<wc-avatar
|
|
1769
|
+
size="sm"
|
|
1770
|
+
name=${item.headline}
|
|
1771
|
+
src=${item.avatar ?? A}
|
|
1772
|
+
></wc-avatar>`;
|
|
1773
|
+
return b `<div
|
|
1774
|
+
class=${e$1({
|
|
1775
|
+
'tc-node': true,
|
|
1776
|
+
'is-selected': this.selected === id,
|
|
1777
|
+
'is-match': this._matches.has(id),
|
|
1778
|
+
'is-dim': searching && !this._path.has(id),
|
|
1779
|
+
'is-dragging': this._drag?.id === id,
|
|
1780
|
+
'is-drop': this._drag?.target === id,
|
|
1781
|
+
})}
|
|
1782
|
+
data-id=${id}
|
|
1783
|
+
role="treeitem"
|
|
1784
|
+
aria-level=${depth}
|
|
1785
|
+
aria-setsize=${siblings.length}
|
|
1786
|
+
aria-posinset=${siblings.indexOf(id) + 1}
|
|
1787
|
+
aria-expanded=${expandable ? String(!collapsed) : A}
|
|
1788
|
+
aria-selected=${this.selected === id ? 'true' : 'false'}
|
|
1789
|
+
aria-busy=${loading ? 'true' : A}
|
|
1790
|
+
aria-label=${[item.headline, item.supportingText, item.badge]
|
|
1791
|
+
.filter(Boolean)
|
|
1792
|
+
.join(', ')}
|
|
1793
|
+
tabindex=${focusId === id ? '0' : '-1'}
|
|
1794
|
+
style="left: ${p.x}px; top: ${p.y}px;"
|
|
1795
|
+
@pointerdown=${(e) => this.onNodePointerDown(e, item)}
|
|
1796
|
+
@keydown=${(e) => this.onNodeKeyDown(e, item)}
|
|
1797
|
+
@focus=${() => {
|
|
1798
|
+
this._focusId = id;
|
|
1799
|
+
}}
|
|
1800
|
+
>
|
|
1801
|
+
<slot name=${`item:${id}`}>
|
|
1802
|
+
<div class="tc-card">
|
|
1803
|
+
${avatar}
|
|
1804
|
+
<span class="tc-text">
|
|
1805
|
+
<span class="tc-headline">${item.headline}</span>
|
|
1806
|
+
${item.supportingText
|
|
1807
|
+
? b `<span class="tc-sub">${item.supportingText}</span>`
|
|
1808
|
+
: A}
|
|
1809
|
+
</span>
|
|
1810
|
+
${item.badge
|
|
1811
|
+
? b `<span class="tc-badge">${item.badge}</span>`
|
|
1812
|
+
: A}
|
|
1813
|
+
</div>
|
|
1814
|
+
</slot>
|
|
1815
|
+
${expandable
|
|
1816
|
+
? b `<button
|
|
1817
|
+
class="tc-count"
|
|
1818
|
+
type="button"
|
|
1819
|
+
tabindex="-1"
|
|
1820
|
+
aria-label=${collapsed
|
|
1821
|
+
? this.i18n.t('treeChartExpand')(item.headline, kids.length)
|
|
1822
|
+
: this.i18n.t('treeChartCollapse')(item.headline)}
|
|
1823
|
+
@click=${() => (collapsed ? this.expand(id) : this.collapse(id))}
|
|
1824
|
+
>
|
|
1825
|
+
${loading
|
|
1826
|
+
? b `<wc-icon
|
|
1827
|
+
class="tc-spin"
|
|
1828
|
+
name="progress_activity"
|
|
1829
|
+
></wc-icon>`
|
|
1830
|
+
: b `${kids.length ? kids.length : A}<wc-icon
|
|
1831
|
+
name=${collapsed
|
|
1832
|
+
? 'keyboard_arrow_down'
|
|
1833
|
+
: 'keyboard_arrow_up'}
|
|
1834
|
+
></wc-icon>`}
|
|
1835
|
+
</button>`
|
|
1836
|
+
: A}
|
|
1837
|
+
${editing
|
|
1838
|
+
? b `<span class="tc-actions">
|
|
1839
|
+
<button
|
|
1840
|
+
type="button"
|
|
1841
|
+
tabindex="-1"
|
|
1842
|
+
title=${this.i18n.t('treeChartAddChild')}
|
|
1843
|
+
aria-label=${this.i18n.t('treeChartAddChild')}
|
|
1844
|
+
@click=${() => this.add(id, 'child')}
|
|
1845
|
+
>
|
|
1846
|
+
<wc-icon name="subdirectory_arrow_right"></wc-icon>
|
|
1847
|
+
</button>
|
|
1848
|
+
${this.parentOf(id)
|
|
1849
|
+
? b `<button
|
|
1850
|
+
type="button"
|
|
1851
|
+
tabindex="-1"
|
|
1852
|
+
title=${this.i18n.t('treeChartAddSibling')}
|
|
1853
|
+
aria-label=${this.i18n.t('treeChartAddSibling')}
|
|
1854
|
+
@click=${() => this.add(id, 'sibling')}
|
|
1855
|
+
>
|
|
1856
|
+
<wc-icon name="add"></wc-icon>
|
|
1857
|
+
</button>`
|
|
1858
|
+
: A}
|
|
1859
|
+
</span>`
|
|
1860
|
+
: A}
|
|
1861
|
+
</div>`;
|
|
1862
|
+
}
|
|
1863
|
+
renderLinks(shown) {
|
|
1864
|
+
const searching = this._path.size > 0;
|
|
1865
|
+
const out = [];
|
|
1866
|
+
for (const id of this.positions.keys()) {
|
|
1867
|
+
const parent = this.parentOf(id);
|
|
1868
|
+
if (parent &&
|
|
1869
|
+
this.positions.has(parent) &&
|
|
1870
|
+
(shown.has(id) || shown.has(parent))) {
|
|
1871
|
+
const points = linkPoints(this.rectOf(parent), this.rectOf(id), {
|
|
1872
|
+
...LAYOUT,
|
|
1873
|
+
orientation: this.orientation,
|
|
1874
|
+
stacked: this.stacked.has(parent),
|
|
1875
|
+
});
|
|
1876
|
+
const onPath = this._path.has(id) && this._path.has(parent);
|
|
1877
|
+
out.push(w `<path class=${e$1({ 'tc-link': true, 'is-path': onPath, 'is-dim': searching && !onPath })} d=${roundedPath(points, 14)}></path>`);
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
return out;
|
|
1881
|
+
}
|
|
1882
|
+
render() {
|
|
1883
|
+
this.layout();
|
|
1884
|
+
const { x, y, zoom } = this.viewport.view;
|
|
1885
|
+
const order = this.visibleOrder();
|
|
1886
|
+
const focusId = this._focusId && this.positions.has(this._focusId)
|
|
1887
|
+
? this._focusId
|
|
1888
|
+
: order[0];
|
|
1889
|
+
const shown = new Set(order.filter(id => this.nearView(this.rectOf(id)) ||
|
|
1890
|
+
id === focusId ||
|
|
1891
|
+
id === this.selected));
|
|
1892
|
+
const dragged = this._drag ? this.byId.get(this._drag.id) : undefined;
|
|
1893
|
+
return b `
|
|
1894
|
+
<div
|
|
1895
|
+
class=${e$1({
|
|
1896
|
+
'tc-viewport': true,
|
|
1897
|
+
'is-panning': this.viewport.panning,
|
|
1898
|
+
'is-space': this.viewport.spaceHeld,
|
|
1899
|
+
'is-dragging': !!this._drag,
|
|
1900
|
+
})}
|
|
1901
|
+
tabindex="0"
|
|
1902
|
+
role="region"
|
|
1903
|
+
aria-label=${this.label || this.i18n.t('treeChartLabel')}
|
|
1904
|
+
aria-describedby="instructions"
|
|
1905
|
+
style=${this.gridStyle()}
|
|
1906
|
+
@keydown=${this.onViewportKeyDown}
|
|
1907
|
+
>
|
|
1908
|
+
<div
|
|
1909
|
+
class="tc-world"
|
|
1910
|
+
style="transform: translate(${x}px, ${y}px) scale(${zoom});"
|
|
1911
|
+
>
|
|
1912
|
+
<svg class="tc-links" width="1" height="1" aria-hidden="true">
|
|
1913
|
+
${this.renderLinks(shown)}
|
|
1914
|
+
</svg>
|
|
1915
|
+
<div
|
|
1916
|
+
class="tc-nodes"
|
|
1917
|
+
role="tree"
|
|
1918
|
+
aria-label=${this.label || this.i18n.t('treeChartLabel')}
|
|
1919
|
+
>
|
|
1920
|
+
${c(order.filter(id => shown.has(id)), id => id, id => this.renderNode(id, focusId))}
|
|
1921
|
+
</div>
|
|
1922
|
+
</div>
|
|
1923
|
+
${dragged && this._drag
|
|
1924
|
+
? b `<div
|
|
1925
|
+
class="tc-ghost"
|
|
1926
|
+
style="left: ${this._drag.x}px; top: ${this._drag.y}px;"
|
|
1927
|
+
>
|
|
1928
|
+
${dragged.headline}
|
|
1929
|
+
</div>`
|
|
1930
|
+
: A}
|
|
1931
|
+
${this.renderBackToContent()}
|
|
1932
|
+
<div class="slot-controls"><slot name="controls"></slot></div>
|
|
1933
|
+
<div class="slot-minimap"><slot name="minimap"></slot></div>
|
|
1934
|
+
<div id="instructions" hidden>
|
|
1935
|
+
${this.i18n.t('diagramInstructions')}
|
|
1936
|
+
</div>
|
|
1937
|
+
<div class="sr-only" aria-live="polite">${this._announcement}</div>
|
|
1938
|
+
</div>
|
|
1939
|
+
`;
|
|
1940
|
+
}
|
|
1941
|
+
};
|
|
1942
|
+
TreeChart.styles = [css_248z];
|
|
1943
|
+
__decorate([
|
|
1944
|
+
n({ attribute: false })
|
|
1945
|
+
], TreeChart.prototype, "items", void 0);
|
|
1946
|
+
__decorate([
|
|
1947
|
+
n({ type: String, reflect: true })
|
|
1948
|
+
], TreeChart.prototype, "orientation", void 0);
|
|
1949
|
+
__decorate([
|
|
1950
|
+
n({ type: Boolean, reflect: true })
|
|
1951
|
+
], TreeChart.prototype, "compact", void 0);
|
|
1952
|
+
__decorate([
|
|
1953
|
+
n({ type: String, reflect: true })
|
|
1954
|
+
], TreeChart.prototype, "selected", void 0);
|
|
1955
|
+
__decorate([
|
|
1956
|
+
r()
|
|
1957
|
+
], TreeChart.prototype, "_collapsed", void 0);
|
|
1958
|
+
__decorate([
|
|
1959
|
+
r()
|
|
1960
|
+
], TreeChart.prototype, "_loading", void 0);
|
|
1961
|
+
__decorate([
|
|
1962
|
+
r()
|
|
1963
|
+
], TreeChart.prototype, "_focusId", void 0);
|
|
1964
|
+
__decorate([
|
|
1965
|
+
r()
|
|
1966
|
+
], TreeChart.prototype, "_matches", void 0);
|
|
1967
|
+
__decorate([
|
|
1968
|
+
r()
|
|
1969
|
+
], TreeChart.prototype, "_path", void 0);
|
|
1970
|
+
__decorate([
|
|
1971
|
+
r()
|
|
1972
|
+
], TreeChart.prototype, "_drag", void 0);
|
|
1973
|
+
__decorate([
|
|
1974
|
+
r()
|
|
1975
|
+
], TreeChart.prototype, "_announcement", void 0);
|
|
1976
|
+
__decorate([
|
|
1977
|
+
e('.tc-viewport')
|
|
1978
|
+
], TreeChart.prototype, "_viewportEl", void 0);
|
|
1979
|
+
TreeChart = __decorate([
|
|
1980
|
+
IndividualComponent
|
|
1981
|
+
], TreeChart);
|
|
1982
|
+
// Cards are measured after they render and laid out from those sizes, so a second update is expected.
|
|
1983
|
+
TreeChart.disableWarning?.('change-in-update');
|
|
1984
|
+
|
|
1985
|
+
export { TreeChart };
|
|
1986
|
+
//# sourceMappingURL=tree-chart.js.map
|