@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,372 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DiagramConnector,
|
|
3
|
+
DiagramPoint,
|
|
4
|
+
DiagramRect,
|
|
5
|
+
DiagramSide,
|
|
6
|
+
} from './types.js';
|
|
7
|
+
|
|
8
|
+
/** Rounds to two decimals, to keep SVG path strings short. */
|
|
9
|
+
function round(n: number) {
|
|
10
|
+
return Math.round(n * 100) / 100;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Unit vector pointing out of each side. */
|
|
14
|
+
export const SIDE_NORMAL: Record<DiagramSide, DiagramPoint> = {
|
|
15
|
+
top: { x: 0, y: -1 },
|
|
16
|
+
right: { x: 1, y: 0 },
|
|
17
|
+
bottom: { x: 0, y: 1 },
|
|
18
|
+
left: { x: -1, y: 0 },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const OPPOSITE_SIDE: Record<DiagramSide, DiagramSide> = {
|
|
22
|
+
top: 'bottom',
|
|
23
|
+
right: 'left',
|
|
24
|
+
bottom: 'top',
|
|
25
|
+
left: 'right',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** Corner radius of elbow connectors, in canvas pixels. */
|
|
29
|
+
export const ELBOW_RADIUS = 32;
|
|
30
|
+
|
|
31
|
+
/** Straight run out of a port before an elbow turns back on itself. */
|
|
32
|
+
const STUB = 24;
|
|
33
|
+
|
|
34
|
+
const isHorizontal = (side: DiagramSide) => side === 'left' || side === 'right';
|
|
35
|
+
|
|
36
|
+
/** The point on `side` of `rect`, `offset` (0 to 1) of the way along it. */
|
|
37
|
+
export function anchorOnRect(
|
|
38
|
+
rect: DiagramRect,
|
|
39
|
+
side: DiagramSide,
|
|
40
|
+
offset = 0.5,
|
|
41
|
+
): DiagramPoint {
|
|
42
|
+
switch (side) {
|
|
43
|
+
case 'top':
|
|
44
|
+
return { x: rect.x + rect.width * offset, y: rect.y };
|
|
45
|
+
case 'bottom':
|
|
46
|
+
return { x: rect.x + rect.width * offset, y: rect.y + rect.height };
|
|
47
|
+
case 'left':
|
|
48
|
+
return { x: rect.x, y: rect.y + rect.height * offset };
|
|
49
|
+
case 'right':
|
|
50
|
+
default:
|
|
51
|
+
return { x: rect.x + rect.width, y: rect.y + rect.height * offset };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Drops repeated points and the middle point of three in a line. */
|
|
56
|
+
function simplify(points: DiagramPoint[]): DiagramPoint[] {
|
|
57
|
+
const out: DiagramPoint[] = [];
|
|
58
|
+
for (const p of points) {
|
|
59
|
+
const last = out[out.length - 1];
|
|
60
|
+
const repeated =
|
|
61
|
+
last && Math.abs(last.x - p.x) < 0.01 && Math.abs(last.y - p.y) < 0.01;
|
|
62
|
+
if (!repeated) out.push(p);
|
|
63
|
+
while (!repeated && out.length >= 3) {
|
|
64
|
+
const [a, b, c] = out.slice(-3);
|
|
65
|
+
const cross = (b.x - a.x) * (c.y - b.y) - (b.y - a.y) * (c.x - b.x);
|
|
66
|
+
if (Math.abs(cross) > 0.01) break;
|
|
67
|
+
out.splice(out.length - 2, 1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The corner points of an orthogonal route from `start` (leaving `startSide`) to `end` (entering
|
|
75
|
+
* `endSide`). Forward routes make one turn pair at the midpoint; routes that must turn back run
|
|
76
|
+
* out of each port first.
|
|
77
|
+
*/
|
|
78
|
+
export function elbowPoints(
|
|
79
|
+
start: DiagramPoint,
|
|
80
|
+
startSide: DiagramSide,
|
|
81
|
+
end: DiagramPoint,
|
|
82
|
+
endSide: DiagramSide,
|
|
83
|
+
): DiagramPoint[] {
|
|
84
|
+
const ns = SIDE_NORMAL[startSide];
|
|
85
|
+
const ne = SIDE_NORMAL[endSide];
|
|
86
|
+
const s1 = { x: start.x + ns.x * STUB, y: start.y + ns.y * STUB };
|
|
87
|
+
const e1 = { x: end.x + ne.x * STUB, y: end.y + ne.y * STUB };
|
|
88
|
+
|
|
89
|
+
if (isHorizontal(startSide) && isHorizontal(endSide)) {
|
|
90
|
+
const forward = (end.x - start.x) * ns.x > 0 && ns.x === -ne.x;
|
|
91
|
+
if (forward) {
|
|
92
|
+
const xm = (start.x + end.x) / 2;
|
|
93
|
+
return simplify([start, { x: xm, y: start.y }, { x: xm, y: end.y }, end]);
|
|
94
|
+
}
|
|
95
|
+
let ym = (start.y + end.y) / 2;
|
|
96
|
+
if (Math.abs(end.y - start.y) < 1) ym = start.y + 3 * STUB;
|
|
97
|
+
if (ns.x === ne.x) {
|
|
98
|
+
const x = ns.x > 0 ? Math.max(s1.x, e1.x) : Math.min(s1.x, e1.x);
|
|
99
|
+
return simplify([start, { x, y: start.y }, { x, y: end.y }, end]);
|
|
100
|
+
}
|
|
101
|
+
return simplify([
|
|
102
|
+
start,
|
|
103
|
+
s1,
|
|
104
|
+
{ x: s1.x, y: ym },
|
|
105
|
+
{ x: e1.x, y: ym },
|
|
106
|
+
e1,
|
|
107
|
+
end,
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!isHorizontal(startSide) && !isHorizontal(endSide)) {
|
|
112
|
+
const forward = (end.y - start.y) * ns.y > 0 && ns.y === -ne.y;
|
|
113
|
+
if (forward) {
|
|
114
|
+
const ym = (start.y + end.y) / 2;
|
|
115
|
+
return simplify([start, { x: start.x, y: ym }, { x: end.x, y: ym }, end]);
|
|
116
|
+
}
|
|
117
|
+
let xm = (start.x + end.x) / 2;
|
|
118
|
+
if (Math.abs(end.x - start.x) < 1) xm = start.x + 3 * STUB;
|
|
119
|
+
if (ns.y === ne.y) {
|
|
120
|
+
const y = ns.y > 0 ? Math.max(s1.y, e1.y) : Math.min(s1.y, e1.y);
|
|
121
|
+
return simplify([start, { x: start.x, y }, { x: end.x, y }, end]);
|
|
122
|
+
}
|
|
123
|
+
return simplify([
|
|
124
|
+
start,
|
|
125
|
+
s1,
|
|
126
|
+
{ x: xm, y: s1.y },
|
|
127
|
+
{ x: xm, y: e1.y },
|
|
128
|
+
e1,
|
|
129
|
+
end,
|
|
130
|
+
]);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// One horizontal side, one vertical: a single corner when both ports face it.
|
|
134
|
+
const corner = isHorizontal(startSide)
|
|
135
|
+
? { x: end.x, y: start.y }
|
|
136
|
+
: { x: start.x, y: end.y };
|
|
137
|
+
const leavesTowardCorner =
|
|
138
|
+
(corner.x - start.x) * ns.x + (corner.y - start.y) * ns.y > 0;
|
|
139
|
+
const entersFromCorner =
|
|
140
|
+
(corner.x - end.x) * ne.x + (corner.y - end.y) * ne.y > 0;
|
|
141
|
+
if (leavesTowardCorner && entersFromCorner) {
|
|
142
|
+
return simplify([start, corner, end]);
|
|
143
|
+
}
|
|
144
|
+
const mid = isHorizontal(startSide)
|
|
145
|
+
? { x: s1.x, y: e1.y }
|
|
146
|
+
: { x: e1.x, y: s1.y };
|
|
147
|
+
return simplify([start, s1, mid, e1, end]);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** An SVG path through `points` whose corners are true circular arcs of up to `radius`. */
|
|
151
|
+
export function roundedPath(points: DiagramPoint[], radius = ELBOW_RADIUS) {
|
|
152
|
+
if (points.length === 0) return '';
|
|
153
|
+
let d = `M ${round(points[0].x)} ${round(points[0].y)}`;
|
|
154
|
+
for (let i = 1; i < points.length - 1; i += 1) {
|
|
155
|
+
const prev = points[i - 1];
|
|
156
|
+
const curr = points[i];
|
|
157
|
+
const next = points[i + 1];
|
|
158
|
+
const lenIn = Math.hypot(curr.x - prev.x, curr.y - prev.y);
|
|
159
|
+
const lenOut = Math.hypot(next.x - curr.x, next.y - curr.y);
|
|
160
|
+
const r = Math.min(radius, lenIn / 2, lenOut / 2);
|
|
161
|
+
if (r < 0.5 || lenIn === 0 || lenOut === 0) {
|
|
162
|
+
d += ` L ${round(curr.x)} ${round(curr.y)}`;
|
|
163
|
+
} else {
|
|
164
|
+
const din = {
|
|
165
|
+
x: (curr.x - prev.x) / lenIn,
|
|
166
|
+
y: (curr.y - prev.y) / lenIn,
|
|
167
|
+
};
|
|
168
|
+
const dout = {
|
|
169
|
+
x: (next.x - curr.x) / lenOut,
|
|
170
|
+
y: (next.y - curr.y) / lenOut,
|
|
171
|
+
};
|
|
172
|
+
const sweep = din.x * dout.y - din.y * dout.x > 0 ? 1 : 0;
|
|
173
|
+
const a = { x: curr.x - din.x * r, y: curr.y - din.y * r };
|
|
174
|
+
const b = { x: curr.x + dout.x * r, y: curr.y + dout.y * r };
|
|
175
|
+
d += ` L ${round(a.x)} ${round(a.y)} A ${round(r)} ${round(r)} 0 0 ${sweep} ${round(b.x)} ${round(b.y)}`;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const last = points[points.length - 1];
|
|
179
|
+
d += ` L ${round(last.x)} ${round(last.y)}`;
|
|
180
|
+
return d;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** The point halfway along a polyline. */
|
|
184
|
+
export function polylineMidpoint(points: DiagramPoint[]): DiagramPoint {
|
|
185
|
+
if (points.length === 1) return { ...points[0] };
|
|
186
|
+
let total = 0;
|
|
187
|
+
for (let i = 1; i < points.length; i += 1) {
|
|
188
|
+
total += Math.hypot(
|
|
189
|
+
points[i].x - points[i - 1].x,
|
|
190
|
+
points[i].y - points[i - 1].y,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
let remaining = total / 2;
|
|
194
|
+
for (let i = 1; i < points.length; i += 1) {
|
|
195
|
+
const a = points[i - 1];
|
|
196
|
+
const b = points[i];
|
|
197
|
+
const len = Math.hypot(b.x - a.x, b.y - a.y);
|
|
198
|
+
if (remaining <= len && len > 0) {
|
|
199
|
+
const t = remaining / len;
|
|
200
|
+
return { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t };
|
|
201
|
+
}
|
|
202
|
+
remaining -= len;
|
|
203
|
+
}
|
|
204
|
+
return { ...points[points.length - 1] };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** A connector's drawn path, where its label goes, and the direction it arrives in (radians). */
|
|
208
|
+
export interface EdgeGeometry {
|
|
209
|
+
d: string;
|
|
210
|
+
mid: DiagramPoint;
|
|
211
|
+
/** Direction of travel at the end, for the end marker. */
|
|
212
|
+
endAngle: number;
|
|
213
|
+
/** Direction of travel away from the start, reversed, for the start marker. */
|
|
214
|
+
startAngle: number;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function cubicPoint(
|
|
218
|
+
p0: DiagramPoint,
|
|
219
|
+
p1: DiagramPoint,
|
|
220
|
+
p2: DiagramPoint,
|
|
221
|
+
p3: DiagramPoint,
|
|
222
|
+
t: number,
|
|
223
|
+
): DiagramPoint {
|
|
224
|
+
const u = 1 - t;
|
|
225
|
+
return {
|
|
226
|
+
x:
|
|
227
|
+
u ** 3 * p0.x +
|
|
228
|
+
3 * u * u * t * p1.x +
|
|
229
|
+
3 * u * t * t * p2.x +
|
|
230
|
+
t ** 3 * p3.x,
|
|
231
|
+
y:
|
|
232
|
+
u ** 3 * p0.y +
|
|
233
|
+
3 * u * u * t * p1.y +
|
|
234
|
+
3 * u * t * t * p2.y +
|
|
235
|
+
t ** 3 * p3.y,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Builds a connector between two ports. `startInset` and `endInset` shorten the line so markers
|
|
241
|
+
* sit on the port instead of under the line's end.
|
|
242
|
+
*/
|
|
243
|
+
export function edgeGeometry(
|
|
244
|
+
kind: DiagramConnector,
|
|
245
|
+
start: DiagramPoint,
|
|
246
|
+
startSide: DiagramSide,
|
|
247
|
+
end: DiagramPoint,
|
|
248
|
+
endSide: DiagramSide,
|
|
249
|
+
options: { radius?: number; startInset?: number; endInset?: number } = {},
|
|
250
|
+
): EdgeGeometry {
|
|
251
|
+
const { radius = ELBOW_RADIUS, startInset = 0, endInset = 0 } = options;
|
|
252
|
+
const ns = SIDE_NORMAL[startSide];
|
|
253
|
+
const ne = SIDE_NORMAL[endSide];
|
|
254
|
+
|
|
255
|
+
if (kind === 'straight') {
|
|
256
|
+
const angle = Math.atan2(end.y - start.y, end.x - start.x);
|
|
257
|
+
const s = {
|
|
258
|
+
x: start.x + Math.cos(angle) * startInset,
|
|
259
|
+
y: start.y + Math.sin(angle) * startInset,
|
|
260
|
+
};
|
|
261
|
+
const e = {
|
|
262
|
+
x: end.x - Math.cos(angle) * endInset,
|
|
263
|
+
y: end.y - Math.sin(angle) * endInset,
|
|
264
|
+
};
|
|
265
|
+
return {
|
|
266
|
+
d: `M ${round(s.x)} ${round(s.y)} L ${round(e.x)} ${round(e.y)}`,
|
|
267
|
+
mid: { x: (start.x + end.x) / 2, y: (start.y + end.y) / 2 },
|
|
268
|
+
endAngle: angle,
|
|
269
|
+
startAngle: angle + Math.PI,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const s = { x: start.x + ns.x * startInset, y: start.y + ns.y * startInset };
|
|
274
|
+
const e = { x: end.x + ne.x * endInset, y: end.y + ne.y * endInset };
|
|
275
|
+
const endAngle = Math.atan2(-ne.y, -ne.x);
|
|
276
|
+
const startAngle = Math.atan2(-ns.y, -ns.x);
|
|
277
|
+
|
|
278
|
+
if (kind === 'bezier') {
|
|
279
|
+
const dist = Math.hypot(e.x - s.x, e.y - s.y);
|
|
280
|
+
const offset = Math.max(dist / 2, 50);
|
|
281
|
+
const c1 = { x: s.x + ns.x * offset, y: s.y + ns.y * offset };
|
|
282
|
+
const c2 = { x: e.x + ne.x * offset, y: e.y + ne.y * offset };
|
|
283
|
+
return {
|
|
284
|
+
d: `M ${round(s.x)} ${round(s.y)} C ${round(c1.x)} ${round(c1.y)}, ${round(c2.x)} ${round(c2.y)}, ${round(e.x)} ${round(e.y)}`,
|
|
285
|
+
mid: cubicPoint(s, c1, c2, e, 0.5),
|
|
286
|
+
endAngle,
|
|
287
|
+
startAngle,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const points = elbowPoints(s, startSide, e, endSide);
|
|
292
|
+
return {
|
|
293
|
+
d: roundedPath(points, radius),
|
|
294
|
+
mid: polylineMidpoint(points),
|
|
295
|
+
endAngle,
|
|
296
|
+
startAngle,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** The smallest box around every rect, or `undefined` for none. */
|
|
301
|
+
export function boundsOf(rects: DiagramRect[]): DiagramRect | undefined {
|
|
302
|
+
if (rects.length === 0) return undefined;
|
|
303
|
+
let minX = Infinity;
|
|
304
|
+
let minY = Infinity;
|
|
305
|
+
let maxX = -Infinity;
|
|
306
|
+
let maxY = -Infinity;
|
|
307
|
+
for (const r of rects) {
|
|
308
|
+
minX = Math.min(minX, r.x);
|
|
309
|
+
minY = Math.min(minY, r.y);
|
|
310
|
+
maxX = Math.max(maxX, r.x + r.width);
|
|
311
|
+
maxY = Math.max(maxY, r.y + r.height);
|
|
312
|
+
}
|
|
313
|
+
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export function rectsIntersect(a: DiagramRect, b: DiagramRect): boolean {
|
|
317
|
+
return (
|
|
318
|
+
a.x < b.x + b.width &&
|
|
319
|
+
b.x < a.x + a.width &&
|
|
320
|
+
a.y < b.y + b.height &&
|
|
321
|
+
b.y < a.y + a.height
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export function inflateRect(r: DiagramRect, by: number): DiagramRect {
|
|
326
|
+
return {
|
|
327
|
+
x: r.x - by,
|
|
328
|
+
y: r.y - by,
|
|
329
|
+
width: r.width + 2 * by,
|
|
330
|
+
height: r.height + 2 * by,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** A rect from two corner points in any order. */
|
|
335
|
+
export function rectFromPoints(a: DiagramPoint, b: DiagramPoint): DiagramRect {
|
|
336
|
+
return {
|
|
337
|
+
x: Math.min(a.x, b.x),
|
|
338
|
+
y: Math.min(a.y, b.y),
|
|
339
|
+
width: Math.abs(a.x - b.x),
|
|
340
|
+
height: Math.abs(a.y - b.y),
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* The candidate nearest to `from` in a direction, for spatial keyboard navigation. Candidates
|
|
346
|
+
* mostly to the side count more than those ahead diagonally.
|
|
347
|
+
*/
|
|
348
|
+
export function nearestInDirection<T extends { rect: DiagramRect }>(
|
|
349
|
+
from: DiagramRect,
|
|
350
|
+
candidates: T[],
|
|
351
|
+
direction: 'up' | 'down' | 'left' | 'right',
|
|
352
|
+
): T | undefined {
|
|
353
|
+
const cx = from.x + from.width / 2;
|
|
354
|
+
const cy = from.y + from.height / 2;
|
|
355
|
+
let best: T | undefined;
|
|
356
|
+
let bestScore = Infinity;
|
|
357
|
+
for (const c of candidates) {
|
|
358
|
+
const x = c.rect.x + c.rect.width / 2;
|
|
359
|
+
const y = c.rect.y + c.rect.height / 2;
|
|
360
|
+
const dx = x - cx;
|
|
361
|
+
const dy = y - cy;
|
|
362
|
+
const along = { up: -dy, down: dy, left: -dx, right: dx }[direction];
|
|
363
|
+
const across =
|
|
364
|
+
direction === 'up' || direction === 'down' ? Math.abs(dx) : Math.abs(dy);
|
|
365
|
+
const score = along + across * 2;
|
|
366
|
+
if (along > 1 && score < bestScore) {
|
|
367
|
+
bestScore = score;
|
|
368
|
+
best = c;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return best;
|
|
372
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Undo and redo over immutable snapshots. Record the state before each committed change with
|
|
3
|
+
* `push`; `undo` and `redo` take the current state and return the one to restore.
|
|
4
|
+
*/
|
|
5
|
+
export class History<T> {
|
|
6
|
+
private past: T[] = [];
|
|
7
|
+
|
|
8
|
+
private future: T[] = [];
|
|
9
|
+
|
|
10
|
+
private readonly limit: number;
|
|
11
|
+
|
|
12
|
+
constructor(limit = 100) {
|
|
13
|
+
this.limit = limit;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get canUndo(): boolean {
|
|
17
|
+
return this.past.length > 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get canRedo(): boolean {
|
|
21
|
+
return this.future.length > 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Records `state` as the one before a change. Clears the redo stack. */
|
|
25
|
+
push(state: T) {
|
|
26
|
+
this.past.push(state);
|
|
27
|
+
if (this.past.length > this.limit) this.past.shift();
|
|
28
|
+
this.future = [];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
undo(current: T): T | undefined {
|
|
32
|
+
const previous = this.past.pop();
|
|
33
|
+
if (previous === undefined) return undefined;
|
|
34
|
+
this.future.push(current);
|
|
35
|
+
return previous;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
redo(current: T): T | undefined {
|
|
39
|
+
const next = this.future.pop();
|
|
40
|
+
if (next === undefined) return undefined;
|
|
41
|
+
this.past.push(current);
|
|
42
|
+
return next;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
clear() {
|
|
46
|
+
this.past = [];
|
|
47
|
+
this.future = [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { DiagramRect, DiagramView } from './types.js';
|
|
2
|
+
|
|
3
|
+
/** What the minimap draws: content boxes and the part of the canvas in view. */
|
|
4
|
+
export interface DiagramOverview {
|
|
5
|
+
items: (DiagramRect & { selected?: boolean })[];
|
|
6
|
+
visible: DiagramRect;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The contract between a canvas (`wc-diagram` and the later diagram components) and the shared chrome
|
|
11
|
+
* (`wc-diagram-controls`, `wc-diagram-minimap`). Members starting with `_` are internal.
|
|
12
|
+
*/
|
|
13
|
+
export interface DiagramCanvas extends HTMLElement {
|
|
14
|
+
readonly view: DiagramView;
|
|
15
|
+
minZoom: number;
|
|
16
|
+
maxZoom: number;
|
|
17
|
+
editable: boolean;
|
|
18
|
+
readonly canUndo: boolean;
|
|
19
|
+
readonly canRedo: boolean;
|
|
20
|
+
zoomIn(): void;
|
|
21
|
+
zoomOut(): void;
|
|
22
|
+
zoomTo(target: number | string): void;
|
|
23
|
+
fit(): void;
|
|
24
|
+
home(): void;
|
|
25
|
+
zoomToSelection(): void;
|
|
26
|
+
undo(): void;
|
|
27
|
+
redo(): void;
|
|
28
|
+
/** Moves the camera so canvas point `x, y` is centred; animated unless `instant`. */
|
|
29
|
+
centerOn(x: number, y: number, instant?: boolean): void;
|
|
30
|
+
/** Calls `listener` after every render and view change. Returns an unsubscribe function. */
|
|
31
|
+
_diagramSubscribe(listener: () => void): () => void;
|
|
32
|
+
_diagramOverview(): DiagramOverview;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isDiagramCanvas(el: unknown): el is DiagramCanvas {
|
|
36
|
+
return (
|
|
37
|
+
!!el &&
|
|
38
|
+
typeof (el as DiagramCanvas)._diagramSubscribe === 'function' &&
|
|
39
|
+
typeof (el as DiagramCanvas)._diagramOverview === 'function'
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Finds the canvas a control belongs to: the element with id `forId` in the same root, else the
|
|
45
|
+
* nearest canvas ancestor (a control slotted into a canvas).
|
|
46
|
+
*/
|
|
47
|
+
export function findDiagramCanvas(
|
|
48
|
+
el: HTMLElement,
|
|
49
|
+
forId: string,
|
|
50
|
+
): DiagramCanvas | null {
|
|
51
|
+
if (forId) {
|
|
52
|
+
const root = el.getRootNode() as Document | ShadowRoot;
|
|
53
|
+
const target = root.getElementById?.(forId) ?? null;
|
|
54
|
+
return isDiagramCanvas(target) ? target : null;
|
|
55
|
+
}
|
|
56
|
+
let node: Node | null = el.parentNode;
|
|
57
|
+
while (node) {
|
|
58
|
+
if (isDiagramCanvas(node)) return node;
|
|
59
|
+
node = node instanceof ShadowRoot ? node.host : node.parentNode;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** A small listener set for `_diagramSubscribe`. */
|
|
65
|
+
export class DiagramListeners {
|
|
66
|
+
private readonly listeners = new Set<() => void>();
|
|
67
|
+
|
|
68
|
+
add(listener: () => void): () => void {
|
|
69
|
+
this.listeners.add(listener);
|
|
70
|
+
return () => this.listeners.delete(listener);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
notify() {
|
|
74
|
+
for (const listener of this.listeners) listener();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { DiagramMarker, DiagramPoint } from './types.js';
|
|
2
|
+
|
|
3
|
+
/** How a marker shape is painted: in the line colour, in the canvas colour, or as a stroke only. */
|
|
4
|
+
export type MarkerFill = 'solid' | 'surface' | 'none';
|
|
5
|
+
|
|
6
|
+
export interface MarkerShape {
|
|
7
|
+
d: string;
|
|
8
|
+
fill: MarkerFill;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Every shape points along +x with its tip at 0,0 and its body behind the tip (negative x), so
|
|
13
|
+
* it can be placed with `translate(tip) rotate(direction)`. Drawing markers as geometry instead of
|
|
14
|
+
* SVG `<marker>` elements lets them take each edge's colour, hover and selection styles.
|
|
15
|
+
*/
|
|
16
|
+
const CIRCLE = (cx: number) => `M ${cx - 4} 0 a 4 4 0 1 0 8 0 a 4 4 0 1 0 -8 0`;
|
|
17
|
+
const CROW = 'M -14 0 L 0 -7 M -14 0 L 0 7 M -14 0 L 0 0';
|
|
18
|
+
const BAR = (x: number) => `M ${x} -7 L ${x} 7`;
|
|
19
|
+
|
|
20
|
+
const SHAPES: Record<Exclude<DiagramMarker, 'none'>, MarkerShape[]> = {
|
|
21
|
+
arrow: [{ d: 'M 0 0 L -10 -5 L -10 5 Z', fill: 'solid' }],
|
|
22
|
+
'arrow-open': [{ d: 'M -10 -5 L 0 0 L -10 5', fill: 'none' }],
|
|
23
|
+
circle: [{ d: CIRCLE(-4), fill: 'surface' }],
|
|
24
|
+
diamond: [{ d: 'M 0 0 L -7 -5 L -14 0 L -7 5 Z', fill: 'surface' }],
|
|
25
|
+
one: [{ d: `${BAR(-8)} ${BAR(-13)}`, fill: 'none' }],
|
|
26
|
+
'zero-or-one': [
|
|
27
|
+
{ d: BAR(-8), fill: 'none' },
|
|
28
|
+
{ d: CIRCLE(-17), fill: 'surface' },
|
|
29
|
+
],
|
|
30
|
+
many: [{ d: CROW, fill: 'none' }],
|
|
31
|
+
'one-or-many': [{ d: `${CROW} ${BAR(-18)}`, fill: 'none' }],
|
|
32
|
+
'zero-or-many': [
|
|
33
|
+
{ d: CROW, fill: 'none' },
|
|
34
|
+
{ d: CIRCLE(-22), fill: 'surface' },
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** The shapes that make up a marker; none for `none`. */
|
|
39
|
+
export function markerShapes(marker: DiagramMarker | undefined): MarkerShape[] {
|
|
40
|
+
if (!marker || marker === 'none') return [];
|
|
41
|
+
return SHAPES[marker] ?? [];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* How far the line stops short of the port, so a filled arrow's tip lands on the port instead of
|
|
46
|
+
* the line's square end poking past it. Crow's-foot markers sit on top of the line, so they need none.
|
|
47
|
+
*/
|
|
48
|
+
export function markerInset(marker: DiagramMarker | undefined): number {
|
|
49
|
+
return marker === 'arrow' ? 6 : 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The SVG transform that places a marker's tip at `at`, pointing along `angle` (radians). */
|
|
53
|
+
export function markerTransform(at: DiagramPoint, angle: number): string {
|
|
54
|
+
const deg = (angle * 180) / Math.PI;
|
|
55
|
+
return `translate(${Math.round(at.x * 100) / 100} ${Math.round(at.y * 100) / 100}) rotate(${Math.round(deg * 100) / 100})`;
|
|
56
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
import type { DiagramSize } from './types.js';
|
|
3
|
+
|
|
4
|
+
export interface MeasureOptions {
|
|
5
|
+
/** The rendered elements to measure, each with its key. */
|
|
6
|
+
elements: () => Iterable<[string, HTMLElement]>;
|
|
7
|
+
/** Size assumed for a key that has not been measured yet. */
|
|
8
|
+
fallback: DiagramSize;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Measures rendered nodes with a ResizeObserver and re-renders the host when a size changes.
|
|
13
|
+
* Sizes are layout sizes (`offsetWidth` / `offsetHeight`), so they ignore the canvas zoom, and
|
|
14
|
+
* they are kept when a node is culled out of view so content bounds stay right.
|
|
15
|
+
*/
|
|
16
|
+
export class MeasureController implements ReactiveController {
|
|
17
|
+
private readonly host: ReactiveControllerHost;
|
|
18
|
+
|
|
19
|
+
private readonly options: MeasureOptions;
|
|
20
|
+
|
|
21
|
+
private readonly sizes = new Map<string, DiagramSize>();
|
|
22
|
+
|
|
23
|
+
private readonly observed = new Map<string, HTMLElement>();
|
|
24
|
+
|
|
25
|
+
private readonly keys = new WeakMap<Element, string>();
|
|
26
|
+
|
|
27
|
+
private observer?: ResizeObserver;
|
|
28
|
+
|
|
29
|
+
constructor(host: ReactiveControllerHost, options: MeasureOptions) {
|
|
30
|
+
this.host = host;
|
|
31
|
+
this.options = options;
|
|
32
|
+
host.addController(this);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The measured size of `key`, or the fallback. */
|
|
36
|
+
size(key: string): DiagramSize {
|
|
37
|
+
return this.sizes.get(key) ?? this.options.fallback;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Whether `key` has been measured. */
|
|
41
|
+
has(key: string): boolean {
|
|
42
|
+
return this.sizes.has(key);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
hostConnected() {
|
|
46
|
+
if (typeof ResizeObserver === 'undefined') return;
|
|
47
|
+
this.observer = new ResizeObserver(entries => {
|
|
48
|
+
let changed = false;
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
const key = this.keys.get(entry.target);
|
|
51
|
+
if (key !== undefined && this.read(key, entry.target as HTMLElement))
|
|
52
|
+
changed = true;
|
|
53
|
+
}
|
|
54
|
+
if (changed) this.host.requestUpdate();
|
|
55
|
+
});
|
|
56
|
+
for (const el of this.observed.values()) this.observer.observe(el);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
hostDisconnected() {
|
|
60
|
+
this.observer?.disconnect();
|
|
61
|
+
this.observer = undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
hostUpdated() {
|
|
65
|
+
let changed = false;
|
|
66
|
+
const seen = new Set<string>();
|
|
67
|
+
for (const [key, el] of this.options.elements()) {
|
|
68
|
+
seen.add(key);
|
|
69
|
+
if (this.observed.get(key) !== el) {
|
|
70
|
+
const old = this.observed.get(key);
|
|
71
|
+
if (old) this.observer?.unobserve(old);
|
|
72
|
+
this.observed.set(key, el);
|
|
73
|
+
this.keys.set(el, key);
|
|
74
|
+
this.observer?.observe(el);
|
|
75
|
+
}
|
|
76
|
+
if (this.read(key, el)) changed = true;
|
|
77
|
+
}
|
|
78
|
+
for (const [key, el] of this.observed) {
|
|
79
|
+
if (!seen.has(key)) {
|
|
80
|
+
this.observer?.unobserve(el);
|
|
81
|
+
this.observed.delete(key);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (changed) this.host.requestUpdate();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Forgets keys that no longer exist. */
|
|
88
|
+
retain(existing: Set<string>) {
|
|
89
|
+
for (const key of this.sizes.keys()) {
|
|
90
|
+
if (!existing.has(key)) this.sizes.delete(key);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private read(key: string, el: HTMLElement): boolean {
|
|
95
|
+
const width = el.offsetWidth;
|
|
96
|
+
const height = el.offsetHeight;
|
|
97
|
+
if (width === 0 && height === 0) return false;
|
|
98
|
+
const current = this.sizes.get(key);
|
|
99
|
+
if (current && current.width === width && current.height === height)
|
|
100
|
+
return false;
|
|
101
|
+
this.sizes.set(key, { width, height });
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
}
|