@redvars/peacock 4.0.0 → 4.2.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-_unSNU5x.js} +43 -4
- package/dist/BaseField-_unSNU5x.js.map +1 -0
- package/dist/{BaseInput-CcMfg1Y2.js → BaseInput-DtZH0fPJ.js} +7 -4
- package/dist/BaseInput-DtZH0fPJ.js.map +1 -0
- package/dist/accordion.js.map +1 -1
- package/dist/ai-badge.js +32 -6
- package/dist/ai-badge.js.map +1 -1
- 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-D7Nmfh1s.js} +4 -2
- package/dist/base-progress-D7Nmfh1s.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 +14 -8
- package/dist/button.js.map +1 -1
- package/dist/calendar.js +2 -2
- package/dist/canvas-base-CWQ4rQ2s.js +788 -0
- package/dist/canvas-base-CWQ4rQ2s.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-CS5yRLfE.js} +3 -2
- package/dist/cartesian-chart-CS5yRLfE.js.map +1 -0
- package/dist/{cb-group-base-DeuCVx3a.js → cb-group-base-CO30uFQZ.js} +2 -2
- package/dist/{cb-group-base-DeuCVx3a.js.map → cb-group-base-CO30uFQZ.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-C_XKVyhf.js +833 -0
- package/dist/chart-base-C_XKVyhf.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-event.js +152 -0
- package/dist/chat-event.js.map +1 -0
- package/dist/chat-message.js +195 -19
- package/dist/chat-message.js.map +1 -1
- package/dist/chat-thread.js +26 -9
- package/dist/chat-thread.js.map +1 -1
- package/dist/checkbox-group.js +5 -5
- package/dist/checkbox.js +5 -5
- package/dist/chip-set.js +4 -4
- package/dist/chip.js +4 -4
- package/dist/circular-progress.js +3 -3
- package/dist/citation.js +2 -2
- package/dist/code-editor.js +6 -5
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +2 -2
- package/dist/color-field.js +6 -6
- package/dist/color-picker.js +2 -2
- package/dist/command-palette.js +2 -2
- package/dist/comment-composer.js +6 -6
- 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 +6 -6
- package/dist/custom-elements-jsdocs.json +2330 -397
- package/dist/custom-elements.json +20464 -542
- package/dist/date-field.js +7 -7
- package/dist/date-picker.js +4 -2
- package/dist/date-picker.js.map +1 -1
- package/dist/date-range-field.js +7 -7
- package/dist/datetime-field.js +7 -7
- 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-Va096vj9.js +2029 -0
- package/dist/diagram-Va096vj9.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 +4 -4
- package/dist/discussion-comment.js +4 -4
- package/dist/{discussion-time-BegaYfhf.js → discussion-time-DqykqvNy.js} +2 -2
- package/dist/{discussion-time-BegaYfhf.js.map → discussion-time-DqykqvNy.js.map} +1 -1
- package/dist/discussion.js +8 -8
- package/dist/{document-editor-BO7QPbO5.js → document-editor-Dc8JeFVB.js} +2 -2
- package/dist/{document-editor-BO7QPbO5.js.map → document-editor-Dc8JeFVB.js.map} +1 -1
- package/dist/document-editor.js +3 -3
- package/dist/draft-card.js +14 -4
- package/dist/draft-card.js.map +1 -1
- package/dist/dropdown-button.js +3 -2
- package/dist/dropdown-button.js.map +1 -1
- 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 +38 -16
- 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 +3 -3
- package/dist/{generative-view-DmtpDobn.js → generative-view-BKlcuujw.js} +13 -13
- package/dist/generative-view-BKlcuujw.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 +6 -6
- 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-DJHsE1YH.js} +2 -2
- package/dist/{i18n-controller-urcQKYGe.js.map → i18n-controller-DJHsE1YH.js.map} +1 -1
- package/dist/icon-button.js +11 -9
- package/dist/icon-button.js.map +1 -1
- package/dist/image.js +2 -2
- package/dist/index.js +42 -22
- package/dist/index.js.map +1 -1
- package/dist/inline-edit.js +2 -2
- package/dist/input.js +5 -5
- 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 +9 -7
- package/dist/link-button.js.map +1 -1
- package/dist/list-item.js +2 -2
- package/dist/list.js +2 -2
- package/dist/listbox.js +4 -4
- package/dist/loader-full.js +17 -16
- package/dist/loader-full.js.map +1 -1
- package/dist/loader.js +51 -18
- package/dist/loader.js.map +1 -1
- package/dist/markdown-editor.js +6 -6
- 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 +7 -6
- 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-trigger-controller-DyLpTxM7.js → menu-trigger-controller-CEJq1ugC.js} +11 -14
- package/dist/menu-trigger-controller-CEJq1ugC.js.map +1 -0
- 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 +3 -3
- package/dist/number-field.js +7 -6
- 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 +6 -6
- package/dist/password-rules.js +2 -2
- package/dist/phone-field.js +6 -6
- package/dist/{picker-field-B4DtcJfL.js → picker-field-CUI05sWc.js} +3 -3
- package/dist/{picker-field-B4DtcJfL.js.map → picker-field-CUI05sWc.js.map} +1 -1
- package/dist/pin-input.js +6 -6
- package/dist/presence-indicator.js +2 -2
- package/dist/prompt-input.js +6 -6
- package/dist/radio-group.js +2 -1
- package/dist/radio-group.js.map +1 -1
- package/dist/radio.js +6 -6
- package/dist/radio.js.map +1 -1
- package/dist/rating.js +6 -5
- package/dist/rating.js.map +1 -1
- package/dist/redvars-loader.js +2 -2
- package/dist/{relative-time-BVQXLuHm.js → relative-time-BNxqvEbg.js} +13 -2
- package/dist/relative-time-BNxqvEbg.js.map +1 -0
- package/dist/relative-time.js +3 -3
- package/dist/resizable-panels.js +2 -2
- package/dist/{rich-text-input-DLICqof1.js → rich-text-input-N_hqnXej.js} +3 -3
- package/dist/{rich-text-input-DLICqof1.js.map → rich-text-input-N_hqnXej.js.map} +1 -1
- package/dist/ripple.js +2 -0
- package/dist/ripple.js.map +1 -1
- package/dist/{schema-hMt-NRLk.js → schema-Dy0z-80u.js} +2 -2
- package/dist/{schema-hMt-NRLk.js.map → schema-Dy0z-80u.js.map} +1 -1
- package/dist/search.js +5 -5
- package/dist/segmented-button-group.js +1 -1
- package/dist/select.js +8 -8
- package/dist/side-sheet.js +2 -2
- package/dist/signature-pad.js +6 -5
- package/dist/signature-pad.js.map +1 -1
- package/dist/slider.js +6 -5
- package/dist/slider.js.map +1 -1
- package/dist/snackbar.js +2 -2
- package/dist/sparkline.js +2 -2
- package/dist/split-button.js +109 -21
- package/dist/split-button.js.map +1 -1
- package/dist/src/__internal/ai/suggestion-controller.d.ts +2 -0
- 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 +155 -0
- package/dist/src/__internal/menu-trigger-controller.d.ts +11 -8
- package/dist/src/__internal/toggle-base.d.ts +8 -0
- package/dist/src/__internal/utils/deprecate.d.ts +3 -3
- package/dist/src/__internal/utils/relative-time.d.ts +5 -0
- package/dist/src/accordion/accordion.d.ts +1 -0
- package/dist/src/ai-badge/ai-badge.d.ts +8 -0
- package/dist/src/button/button/button.d.ts +4 -0
- package/dist/src/chat-message/chat-message.d.ts +51 -10
- package/dist/src/chat-message/index.d.ts +1 -1
- package/dist/src/chat-thread/chat-event.d.ts +37 -0
- package/dist/src/chat-thread/chat-thread.d.ts +7 -4
- package/dist/src/chat-thread/index.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 +17 -4
- package/dist/src/input/BaseField.d.ts +15 -1
- package/dist/src/input/BaseInput.d.ts +4 -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/split-button/split-button.d.ts +7 -2
- 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 +3 -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-DnYjGbbc.js} +169 -1
- package/dist/{strings-DmbqMTfs.js.map → strings-DnYjGbbc.js.map} +1 -1
- package/dist/sub-menu.js +2 -2
- package/dist/{suggestion-controller-CW17adxd.js → suggestion-controller-7YRQqkaI.js} +3 -1
- package/dist/{suggestion-controller-CW17adxd.js.map → suggestion-controller-7YRQqkaI.js.map} +1 -1
- package/dist/svg.js +2 -2
- package/dist/switch.js +6 -5
- package/dist/switch.js.map +1 -1
- package/dist/tab.js +1 -0
- package/dist/tab.js.map +1 -1
- package/dist/table.js +50 -11
- package/dist/table.js.map +1 -1
- 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 +13 -6
- package/dist/textarea.js.map +1 -1
- package/dist/time-field.js +7 -7
- 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-CXmFSp3b.js} +19 -3
- package/dist/toggle-base-CXmFSp3b.js.map +1 -0
- package/dist/tour.js +2 -2
- package/dist/transfer-list.js +6 -5
- 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 +6 -6
- package/dist/user-menu.js +3 -3
- 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 +3 -3
- package/package.json +1 -1
- package/readme.md +44 -2
- package/src/LoaderUtils.ts +9 -2
- package/src/__internal/ai/suggestion-controller.ts +3 -1
- 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 +207 -0
- package/src/__internal/menu-trigger-controller.ts +11 -15
- 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/__internal/utils/relative-time.ts +20 -0
- package/src/accordion/accordion.ts +1 -0
- package/src/ai-badge/ai-badge.scss +8 -0
- package/src/ai-badge/ai-badge.ts +21 -4
- package/src/button/base-button/base-button.ts +2 -0
- package/src/button/button/button-base.scss +9 -2
- package/src/button/button/button-layers.scss +3 -1
- package/src/button/button/button.ts +4 -0
- package/src/chat-message/chat-message.scss +72 -0
- package/src/chat-message/chat-message.ts +137 -18
- package/src/chat-message/index.ts +1 -0
- package/src/chat-thread/chat-event.scss +36 -0
- package/src/chat-thread/chat-event.ts +79 -0
- package/src/chat-thread/chat-thread.scss +4 -1
- package/src/chat-thread/chat-thread.ts +22 -6
- package/src/chat-thread/index.ts +1 -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/draft-card/draft-card.scss +16 -2
- package/src/dropdown-button/dropdown-button.ts +2 -1
- 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 +123 -3
- package/src/input/BaseField.ts +45 -2
- package/src/input/BaseInput.ts +4 -1
- package/src/loader.ts +29 -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/split-button/split-button-colors.scss +9 -0
- package/src/split-button/split-button-sizes.scss +32 -5
- package/src/split-button/split-button.scss +61 -8
- package/src/split-button/split-button.ts +15 -8
- package/src/switch/switch.ts +1 -0
- package/src/table/table.scss +57 -9
- package/src/table/table.ts +3 -1
- 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 +8 -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/menu-trigger-controller-DyLpTxM7.js.map +0 -1
- package/dist/relative-time-BVQXLuHm.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,410 @@
|
|
|
1
|
+
import { html, LitElement, nothing, type PropertyValues } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { I18nController } from '@/__internal/i18n/i18n-controller.js';
|
|
4
|
+
import { ViewportController } from './viewport-controller.js';
|
|
5
|
+
import { inflateRect, rectsIntersect, boundsOf } from './geometry.js';
|
|
6
|
+
import {
|
|
7
|
+
DiagramListeners,
|
|
8
|
+
type DiagramCanvas,
|
|
9
|
+
type DiagramOverview,
|
|
10
|
+
} from './host.js';
|
|
11
|
+
import type {
|
|
12
|
+
DiagramRect,
|
|
13
|
+
DiagramStartPosition,
|
|
14
|
+
DiagramView,
|
|
15
|
+
DiagramViewportDetail,
|
|
16
|
+
} from './types.js';
|
|
17
|
+
|
|
18
|
+
/** Screen pixels arrow keys pan the empty canvas. */
|
|
19
|
+
const PAN_STEP = 60;
|
|
20
|
+
|
|
21
|
+
const ZOOM_STEP = 1.25;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The camera, start position and chrome hooks every diagram canvas shares: `wc-diagram`,
|
|
25
|
+
* `wc-workflow` and the later diagram components. Subclasses render their content inside the
|
|
26
|
+
* element returned by `viewportElement()` and describe it through the abstract hooks.
|
|
27
|
+
*/
|
|
28
|
+
export abstract class DiagramCanvasElement
|
|
29
|
+
extends LitElement
|
|
30
|
+
implements DiagramCanvas
|
|
31
|
+
{
|
|
32
|
+
// ── Properties
|
|
33
|
+
|
|
34
|
+
/** The camera's scale. Follows wheel and pinch zooming; set it to zoom around the centre. */
|
|
35
|
+
@property({ type: Number, reflect: true })
|
|
36
|
+
zoom: number = 1;
|
|
37
|
+
|
|
38
|
+
/** Screen pixels kept around content when fitting it. */
|
|
39
|
+
@property({ type: Number, reflect: true })
|
|
40
|
+
padding: number = 50;
|
|
41
|
+
|
|
42
|
+
/** Where the camera starts: fit all content, the canvas origin at 100%, or the first item at 100%. */
|
|
43
|
+
@property({ type: String, attribute: 'start-position' })
|
|
44
|
+
startPosition: DiagramStartPosition = 'fit';
|
|
45
|
+
|
|
46
|
+
/** An exact starting camera, `{ x, y, zoom }`, for example one saved from `viewport-change`. Wins over `start-position`. */
|
|
47
|
+
@property({ type: Object, attribute: 'start-view' })
|
|
48
|
+
startView?: DiagramView;
|
|
49
|
+
|
|
50
|
+
/** Smallest zoom. */
|
|
51
|
+
@property({ type: Number, attribute: 'min-zoom' })
|
|
52
|
+
minZoom = 0.1;
|
|
53
|
+
|
|
54
|
+
/** Largest zoom. */
|
|
55
|
+
@property({ type: Number, attribute: 'max-zoom' })
|
|
56
|
+
maxZoom = 4;
|
|
57
|
+
|
|
58
|
+
/** Spacing of the background dots, in canvas pixels. */
|
|
59
|
+
@property({ type: Number, attribute: 'grid-size' })
|
|
60
|
+
gridSize = 20;
|
|
61
|
+
|
|
62
|
+
/** Turns on editing. */
|
|
63
|
+
@property({ type: Boolean, reflect: true })
|
|
64
|
+
editable = false;
|
|
65
|
+
|
|
66
|
+
/** Keeps content in place; the person can still pan, zoom and select. */
|
|
67
|
+
@property({ type: Boolean, reflect: true })
|
|
68
|
+
readonly = false;
|
|
69
|
+
|
|
70
|
+
/** The canvas's accessible name. */
|
|
71
|
+
@property({ type: String })
|
|
72
|
+
label = '';
|
|
73
|
+
|
|
74
|
+
// ── Protected fields
|
|
75
|
+
|
|
76
|
+
protected readonly i18n = new I18nController(this);
|
|
77
|
+
|
|
78
|
+
protected readonly listeners = new DiagramListeners();
|
|
79
|
+
|
|
80
|
+
protected readonly viewport = new ViewportController(this, {
|
|
81
|
+
element: () => this.viewportElement(),
|
|
82
|
+
minZoom: () => this.minZoom,
|
|
83
|
+
maxZoom: () => this.maxZoom,
|
|
84
|
+
onChange: (view, settled) => this.onViewChange(view, settled),
|
|
85
|
+
isBackground: target => this.isBackground(target),
|
|
86
|
+
onBackgroundPointerDown: event => this.onBackgroundPointerDown(event),
|
|
87
|
+
onBackgroundClick: event => this.onBackgroundClick(event),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/** Whether the camera has been placed at the start position. */
|
|
91
|
+
protected startApplied = false;
|
|
92
|
+
|
|
93
|
+
protected homeView?: DiagramView;
|
|
94
|
+
|
|
95
|
+
private viewportFrame = 0;
|
|
96
|
+
|
|
97
|
+
private pendingViewport?: DiagramViewportDetail;
|
|
98
|
+
|
|
99
|
+
private resizeObserver?: ResizeObserver;
|
|
100
|
+
|
|
101
|
+
// ── Hooks for subclasses
|
|
102
|
+
|
|
103
|
+
/** The element that shows the canvas and takes pan and zoom input. */
|
|
104
|
+
protected abstract viewportElement(): HTMLElement | null | undefined;
|
|
105
|
+
|
|
106
|
+
/** The box around all content, in canvas coordinates. */
|
|
107
|
+
protected abstract contentBounds(): DiagramRect | undefined;
|
|
108
|
+
|
|
109
|
+
/** Boxes of the selected items, in canvas coordinates. */
|
|
110
|
+
protected abstract selectionRects(): DiagramRect[];
|
|
111
|
+
|
|
112
|
+
/** The box of the item with this id, for `zoomTo(id)`. */
|
|
113
|
+
protected abstract itemRect(id: string): DiagramRect | undefined;
|
|
114
|
+
|
|
115
|
+
/** The box of the first item, for `start-position="first"`. */
|
|
116
|
+
protected abstract firstItemRect(): DiagramRect | undefined;
|
|
117
|
+
|
|
118
|
+
/** Boxes the minimap draws. */
|
|
119
|
+
protected abstract overviewItems(): DiagramOverview['items'];
|
|
120
|
+
|
|
121
|
+
/** Whether a press on `target` is on the empty canvas. */
|
|
122
|
+
protected abstract isBackground(target: EventTarget | null): boolean;
|
|
123
|
+
|
|
124
|
+
abstract get canUndo(): boolean;
|
|
125
|
+
|
|
126
|
+
abstract get canRedo(): boolean;
|
|
127
|
+
|
|
128
|
+
abstract undo(): void;
|
|
129
|
+
|
|
130
|
+
abstract redo(): void;
|
|
131
|
+
|
|
132
|
+
/** Return true to take over a primary press on the background, for example for a marquee. */
|
|
133
|
+
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
134
|
+
protected onBackgroundPointerDown(_event: PointerEvent): boolean {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** A background press released without moving. */
|
|
139
|
+
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
140
|
+
protected onBackgroundClick(_event: PointerEvent): void {
|
|
141
|
+
// Nothing by default.
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ── Lifecycle
|
|
145
|
+
|
|
146
|
+
connectedCallback() {
|
|
147
|
+
super.connectedCallback();
|
|
148
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
149
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
150
|
+
this.requestUpdate();
|
|
151
|
+
this.maybeApplyStart();
|
|
152
|
+
});
|
|
153
|
+
this.resizeObserver.observe(this);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
disconnectedCallback() {
|
|
158
|
+
super.disconnectedCallback();
|
|
159
|
+
this.resizeObserver?.disconnect();
|
|
160
|
+
cancelAnimationFrame(this.viewportFrame);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
protected willUpdate(changed: PropertyValues<this>) {
|
|
164
|
+
if (
|
|
165
|
+
changed.has('zoom') &&
|
|
166
|
+
Math.abs(this.zoom - this.viewport.view.zoom) > 1e-6
|
|
167
|
+
) {
|
|
168
|
+
this.viewport.zoomToValue(this.zoom);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
protected updated(changed: PropertyValues<this>) {
|
|
173
|
+
super.updated(changed);
|
|
174
|
+
this.maybeApplyStart();
|
|
175
|
+
this.listeners.notify();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ── Public API
|
|
179
|
+
|
|
180
|
+
/** The camera: canvas point `c` is drawn at `c * zoom + (x, y)`. Setting it moves the camera at once. */
|
|
181
|
+
get view(): DiagramView {
|
|
182
|
+
return { ...this.viewport.view };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
set view(value: DiagramView) {
|
|
186
|
+
this.viewport.setView(value);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Fits all content in view, never zooming past 100%. */
|
|
190
|
+
fit() {
|
|
191
|
+
const bounds = this.contentBounds();
|
|
192
|
+
if (!bounds) return;
|
|
193
|
+
this.viewport.animateTo(this.viewport.viewForRect(bounds, this.padding));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Flies back to the start position. */
|
|
197
|
+
home() {
|
|
198
|
+
this.viewport.animateTo(this.homeView ?? this.computeStartView());
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
zoomIn() {
|
|
202
|
+
this.animateZoom(this.viewport.view.zoom * ZOOM_STEP);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
zoomOut() {
|
|
206
|
+
this.animateZoom(this.viewport.view.zoom / ZOOM_STEP);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** Zooms to a level (`1` is 100%), or centres the item with that id at 100%. */
|
|
210
|
+
zoomTo(target: number | string) {
|
|
211
|
+
if (typeof target === 'number') {
|
|
212
|
+
this.animateZoom(target);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const r = this.itemRect(target);
|
|
216
|
+
if (!r) return;
|
|
217
|
+
this.viewport.animateTo(
|
|
218
|
+
this.viewport.viewCentering(
|
|
219
|
+
{ x: r.x + r.width / 2, y: r.y + r.height / 2 },
|
|
220
|
+
1,
|
|
221
|
+
),
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Fits the selection in view. */
|
|
226
|
+
zoomToSelection() {
|
|
227
|
+
const bounds = boundsOf(this.selectionRects());
|
|
228
|
+
if (!bounds) return;
|
|
229
|
+
this.viewport.animateTo(this.viewport.viewForRect(bounds, this.padding));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** Centres canvas point `x, y`; animated unless `instant`. */
|
|
233
|
+
centerOn(x: number, y: number, instant = false) {
|
|
234
|
+
const view = this.viewport.viewCentering({ x, y });
|
|
235
|
+
if (instant) this.viewport.setView(view);
|
|
236
|
+
else this.viewport.animateTo(view, 300);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
_diagramSubscribe(listener: () => void): () => void {
|
|
240
|
+
return this.listeners.add(listener);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
_diagramOverview(): DiagramOverview {
|
|
244
|
+
return {
|
|
245
|
+
items: this.overviewItems(),
|
|
246
|
+
visible: this.viewport.visibleRect(),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// ── Protected methods
|
|
251
|
+
|
|
252
|
+
protected emit<T>(type: string, detail: T, cancelable = false): boolean {
|
|
253
|
+
return this.dispatchEvent(
|
|
254
|
+
new CustomEvent<T>(type, {
|
|
255
|
+
detail,
|
|
256
|
+
bubbles: true,
|
|
257
|
+
composed: true,
|
|
258
|
+
cancelable,
|
|
259
|
+
}),
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** The start view for the current `start-position`; subclasses may adjust `fit`. */
|
|
264
|
+
protected computeStartView(): DiagramView {
|
|
265
|
+
if (this.startView) {
|
|
266
|
+
return {
|
|
267
|
+
...this.startView,
|
|
268
|
+
zoom: this.viewport.clampZoom(this.startView.zoom),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const { zoom } = this.viewport.view;
|
|
272
|
+
if (this.startPosition === 'origin') return { x: 0, y: 0, zoom };
|
|
273
|
+
const first = this.firstItemRect();
|
|
274
|
+
if (this.startPosition === 'first' && first) {
|
|
275
|
+
return this.viewport.viewCentering(
|
|
276
|
+
{ x: first.x + first.width / 2, y: first.y + first.height / 2 },
|
|
277
|
+
1,
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
const bounds = this.contentBounds();
|
|
281
|
+
return bounds
|
|
282
|
+
? this.viewport.viewForRect(bounds, this.padding)
|
|
283
|
+
: { x: 0, y: 0, zoom };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Whether there is anything to place the camera on yet. */
|
|
287
|
+
protected hasContent(): boolean {
|
|
288
|
+
return !!this.contentBounds();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Places the camera once, when the canvas has a size and something to show. */
|
|
292
|
+
protected maybeApplyStart() {
|
|
293
|
+
if (this.startApplied || !this.hasUpdated) return;
|
|
294
|
+
const { width, height } = this.viewport.size();
|
|
295
|
+
if (!width || !height) return;
|
|
296
|
+
if (
|
|
297
|
+
!this.hasContent() &&
|
|
298
|
+
!this.startView &&
|
|
299
|
+
this.startPosition !== 'origin'
|
|
300
|
+
) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this.startApplied = true;
|
|
304
|
+
this.homeView = this.computeStartView();
|
|
305
|
+
this.viewport.setView(this.homeView);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Canvas-wide shortcuts: zoom (+, -, Ctrl/⌘+0), fit (Shift+1), selection (Shift+2), back to start
|
|
310
|
+
* (Home) and arrow keys on the empty canvas. Returns whether the key was handled.
|
|
311
|
+
*/
|
|
312
|
+
protected handleCanvasKey(event: KeyboardEvent): boolean {
|
|
313
|
+
const mod = event.ctrlKey || event.metaKey;
|
|
314
|
+
const key = event.key.toLowerCase();
|
|
315
|
+
const origin = event.composedPath()[0];
|
|
316
|
+
let action: (() => void) | undefined;
|
|
317
|
+
if (mod && key === '0') action = () => this.zoomTo(1);
|
|
318
|
+
else if (!mod && (key === '+' || key === '=')) action = () => this.zoomIn();
|
|
319
|
+
else if (!mod && key === '-') action = () => this.zoomOut();
|
|
320
|
+
else if (event.shiftKey && event.code === 'Digit1')
|
|
321
|
+
action = () => this.fit();
|
|
322
|
+
else if (event.shiftKey && event.code === 'Digit2') {
|
|
323
|
+
action = () => this.zoomToSelection();
|
|
324
|
+
} else if (key === 'home') action = () => this.home();
|
|
325
|
+
else if (origin === this.viewportElement() && key.startsWith('arrow')) {
|
|
326
|
+
const d = {
|
|
327
|
+
arrowleft: [PAN_STEP, 0],
|
|
328
|
+
arrowright: [-PAN_STEP, 0],
|
|
329
|
+
arrowup: [0, PAN_STEP],
|
|
330
|
+
arrowdown: [0, -PAN_STEP],
|
|
331
|
+
}[key];
|
|
332
|
+
if (d) action = () => this.viewport.panBy(d[0], d[1]);
|
|
333
|
+
}
|
|
334
|
+
if (!action) return false;
|
|
335
|
+
event.preventDefault();
|
|
336
|
+
action();
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Inline style that scrolls and scales the background dots with the camera. */
|
|
341
|
+
protected gridStyle(): string {
|
|
342
|
+
const { x, y, zoom } = this.viewport.view;
|
|
343
|
+
let dot = this.gridSize * zoom;
|
|
344
|
+
while (dot < 12) dot *= 2;
|
|
345
|
+
return `background-size: ${dot}px ${dot}px; background-position: ${x}px ${y}px;`;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** Whether `rect` is near the view, for rendering only what can be seen. */
|
|
349
|
+
protected nearView(rect: DiagramRect, margin = 200): boolean {
|
|
350
|
+
const { width, height } = this.viewport.size();
|
|
351
|
+
if (!this.startApplied || !width || !height) return true;
|
|
352
|
+
const visible = inflateRect(
|
|
353
|
+
this.viewport.visibleRect(),
|
|
354
|
+
margin / this.viewport.view.zoom,
|
|
355
|
+
);
|
|
356
|
+
return rectsIntersect(rect, visible);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** The "Back to content" button, shown when nothing is in view. */
|
|
360
|
+
protected renderBackToContent() {
|
|
361
|
+
const bounds = this.contentBounds();
|
|
362
|
+
if (!this.startApplied || !bounds) return nothing;
|
|
363
|
+
if (rectsIntersect(bounds, this.viewport.visibleRect())) return nothing;
|
|
364
|
+
return html`<wc-button
|
|
365
|
+
class="back-to-content"
|
|
366
|
+
level="secondary"
|
|
367
|
+
size="sm"
|
|
368
|
+
@click=${() => this.fit()}
|
|
369
|
+
><wc-icon slot="icon" name="center_focus_strong"></wc-icon>${this.i18n.t(
|
|
370
|
+
'diagramBackToContent',
|
|
371
|
+
)}</wc-button
|
|
372
|
+
>`;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// ── Private methods
|
|
376
|
+
|
|
377
|
+
private onViewChange(view: DiagramView, settled: boolean) {
|
|
378
|
+
if (this.zoom !== view.zoom) this.zoom = view.zoom;
|
|
379
|
+
this.requestUpdate();
|
|
380
|
+
this.pendingViewport = { ...view, settled };
|
|
381
|
+
if (settled) {
|
|
382
|
+
cancelAnimationFrame(this.viewportFrame);
|
|
383
|
+
this.viewportFrame = 0;
|
|
384
|
+
this.flushViewport();
|
|
385
|
+
} else if (!this.viewportFrame) {
|
|
386
|
+
this.viewportFrame = requestAnimationFrame(() => {
|
|
387
|
+
this.viewportFrame = 0;
|
|
388
|
+
this.flushViewport();
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
private flushViewport() {
|
|
394
|
+
const detail = this.pendingViewport;
|
|
395
|
+
this.pendingViewport = undefined;
|
|
396
|
+
if (detail) this.emit<DiagramViewportDetail>('viewport-change', detail);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
private animateZoom(zoom: number) {
|
|
400
|
+
const { width, height } = this.viewport.size();
|
|
401
|
+
const { x, y, zoom: current } = this.viewport.view;
|
|
402
|
+
const next = this.viewport.clampZoom(zoom);
|
|
403
|
+
const cx = (width / 2 - x) / current;
|
|
404
|
+
const cy = (height / 2 - y) / current;
|
|
405
|
+
this.viewport.animateTo(
|
|
406
|
+
{ zoom: next, x: width / 2 - cx * next, y: height / 2 - cy * next },
|
|
407
|
+
200,
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
import { findDiagramCanvas, type DiagramCanvas } from './host.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Links a control (`wc-diagram-controls`, `wc-diagram-minimap`) to its canvas: finds it, waits for
|
|
6
|
+
* it to be defined when it is lazy-loaded, subscribes to its updates and calls `onSync` after each.
|
|
7
|
+
*/
|
|
8
|
+
export class DiagramCanvasLink implements ReactiveController {
|
|
9
|
+
canvas: DiagramCanvas | null = null;
|
|
10
|
+
|
|
11
|
+
private readonly host: ReactiveControllerHost & HTMLElement;
|
|
12
|
+
|
|
13
|
+
private readonly options: { forId: () => string; onSync: () => void };
|
|
14
|
+
|
|
15
|
+
private unsubscribe?: () => void;
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
host: ReactiveControllerHost & HTMLElement,
|
|
19
|
+
options: { forId: () => string; onSync: () => void },
|
|
20
|
+
) {
|
|
21
|
+
this.host = host;
|
|
22
|
+
this.options = options;
|
|
23
|
+
host.addController(this);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
hostConnected() {
|
|
27
|
+
this.attach();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
hostDisconnected() {
|
|
31
|
+
this.detach();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Looks for the canvas again, for example after `for` changed. */
|
|
35
|
+
attach() {
|
|
36
|
+
this.detach();
|
|
37
|
+
const forId = this.options.forId();
|
|
38
|
+
const canvas = findDiagramCanvas(this.host, forId);
|
|
39
|
+
if (canvas) {
|
|
40
|
+
this.canvas = canvas;
|
|
41
|
+
this.unsubscribe = canvas._diagramSubscribe(() => this.options.onSync());
|
|
42
|
+
this.options.onSync();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const candidate = forId
|
|
46
|
+
? (this.host.getRootNode() as Document | ShadowRoot).getElementById?.(
|
|
47
|
+
forId,
|
|
48
|
+
)
|
|
49
|
+
: this.host.parentElement;
|
|
50
|
+
const tag = candidate?.localName;
|
|
51
|
+
const retry = () => {
|
|
52
|
+
if (this.host.isConnected && !this.canvas) this.attach();
|
|
53
|
+
};
|
|
54
|
+
if (tag?.includes('-') && !customElements.get(tag)) {
|
|
55
|
+
customElements.whenDefined(tag).then(retry);
|
|
56
|
+
} else if (forId && !candidate) {
|
|
57
|
+
requestAnimationFrame(retry);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private detach() {
|
|
62
|
+
this.unsubscribe?.();
|
|
63
|
+
this.unsubscribe = undefined;
|
|
64
|
+
this.canvas = null;
|
|
65
|
+
}
|
|
66
|
+
}
|