@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.
Files changed (467) hide show
  1. package/dist/{BaseField-CAog9TIc.js → BaseField-_unSNU5x.js} +43 -4
  2. package/dist/BaseField-_unSNU5x.js.map +1 -0
  3. package/dist/{BaseInput-CcMfg1Y2.js → BaseInput-DtZH0fPJ.js} +7 -4
  4. package/dist/BaseInput-DtZH0fPJ.js.map +1 -0
  5. package/dist/accordion.js.map +1 -1
  6. package/dist/ai-badge.js +32 -6
  7. package/dist/ai-badge.js.map +1 -1
  8. package/dist/ai-summary.js +2 -2
  9. package/dist/alert.js +2 -2
  10. package/dist/anchor-nav.js +2 -2
  11. package/dist/app-shell.js +2 -2
  12. package/dist/assistant-panel.js +2 -2
  13. package/dist/assistant-step.js +2 -2
  14. package/dist/assistant-steps.js +2 -2
  15. package/dist/avatar-group.js +2 -2
  16. package/dist/banner.js +2 -2
  17. package/dist/{base-button-Do2TUy8M.js → base-button-BJMGMcMv.js} +3 -1
  18. package/dist/base-button-BJMGMcMv.js.map +1 -0
  19. package/dist/{base-progress-BiLlZVHJ.js → base-progress-D7Nmfh1s.js} +4 -2
  20. package/dist/base-progress-D7Nmfh1s.js.map +1 -0
  21. package/dist/bottom-sheet.js +2 -2
  22. package/dist/breadcrumb.js +2 -2
  23. package/dist/button-group.js +4 -4
  24. package/dist/button.js +14 -8
  25. package/dist/button.js.map +1 -1
  26. package/dist/calendar.js +2 -2
  27. package/dist/canvas-base-CWQ4rQ2s.js +788 -0
  28. package/dist/canvas-base-CWQ4rQ2s.js.map +1 -0
  29. package/dist/canvas-link-CtgsALq4.js +54 -0
  30. package/dist/canvas-link-CtgsALq4.js.map +1 -0
  31. package/dist/{cartesian-chart-C-f1frt0.js → cartesian-chart-CS5yRLfE.js} +3 -2
  32. package/dist/cartesian-chart-CS5yRLfE.js.map +1 -0
  33. package/dist/{cb-group-base-DeuCVx3a.js → cb-group-base-CO30uFQZ.js} +2 -2
  34. package/dist/{cb-group-base-DeuCVx3a.js.map → cb-group-base-CO30uFQZ.js.map} +1 -1
  35. package/dist/cb-group.js +3 -3
  36. package/dist/cb-rule.js +3 -3
  37. package/dist/chart-area.js +5 -4
  38. package/dist/chart-area.js.map +1 -1
  39. package/dist/chart-bar.js +5 -4
  40. package/dist/chart-bar.js.map +1 -1
  41. package/dist/chart-base-C_XKVyhf.js +833 -0
  42. package/dist/chart-base-C_XKVyhf.js.map +1 -0
  43. package/dist/chart-doughnut.js +4 -3
  44. package/dist/chart-doughnut.js.map +1 -1
  45. package/dist/chart-line.js +5 -4
  46. package/dist/chart-line.js.map +1 -1
  47. package/dist/chart-pie.js +4 -3
  48. package/dist/chart-pie.js.map +1 -1
  49. package/dist/chat-event.js +152 -0
  50. package/dist/chat-event.js.map +1 -0
  51. package/dist/chat-message.js +195 -19
  52. package/dist/chat-message.js.map +1 -1
  53. package/dist/chat-thread.js +26 -9
  54. package/dist/chat-thread.js.map +1 -1
  55. package/dist/checkbox-group.js +5 -5
  56. package/dist/checkbox.js +5 -5
  57. package/dist/chip-set.js +4 -4
  58. package/dist/chip.js +4 -4
  59. package/dist/circular-progress.js +3 -3
  60. package/dist/citation.js +2 -2
  61. package/dist/code-editor.js +6 -5
  62. package/dist/code-editor.js.map +1 -1
  63. package/dist/code-highlighter.js +2 -2
  64. package/dist/color-field.js +6 -6
  65. package/dist/color-picker.js +2 -2
  66. package/dist/command-palette.js +2 -2
  67. package/dist/comment-composer.js +6 -6
  68. package/dist/condition-builder.js +3 -3
  69. package/dist/confirm-dialog.js +2 -2
  70. package/dist/copy-button.js +2 -2
  71. package/dist/currency-field.js +6 -6
  72. package/dist/custom-elements-jsdocs.json +2330 -397
  73. package/dist/custom-elements.json +20464 -542
  74. package/dist/date-field.js +7 -7
  75. package/dist/date-picker.js +4 -2
  76. package/dist/date-picker.js.map +1 -1
  77. package/dist/date-range-field.js +7 -7
  78. package/dist/datetime-field.js +7 -7
  79. package/dist/dependency-map-layout-5KUueabk.js +1390 -0
  80. package/dist/dependency-map-layout-5KUueabk.js.map +1 -0
  81. package/dist/dependency-map.js +1605 -0
  82. package/dist/dependency-map.js.map +1 -0
  83. package/dist/description-item.js +2 -2
  84. package/dist/description-list.js +2 -2
  85. package/dist/diagram-Va096vj9.js +2029 -0
  86. package/dist/diagram-Va096vj9.js.map +1 -0
  87. package/dist/diagram-controls.js +345 -0
  88. package/dist/diagram-controls.js.map +1 -0
  89. package/dist/diagram-minimap.js +216 -0
  90. package/dist/diagram-minimap.js.map +1 -0
  91. package/dist/diagram.js +20 -0
  92. package/dist/diagram.js.map +1 -0
  93. package/dist/diff-viewer.js +2 -2
  94. package/dist/discussion-activity.js +4 -4
  95. package/dist/discussion-comment.js +4 -4
  96. package/dist/{discussion-time-BegaYfhf.js → discussion-time-DqykqvNy.js} +2 -2
  97. package/dist/{discussion-time-BegaYfhf.js.map → discussion-time-DqykqvNy.js.map} +1 -1
  98. package/dist/discussion.js +8 -8
  99. package/dist/{document-editor-BO7QPbO5.js → document-editor-Dc8JeFVB.js} +2 -2
  100. package/dist/{document-editor-BO7QPbO5.js.map → document-editor-Dc8JeFVB.js.map} +1 -1
  101. package/dist/document-editor.js +3 -3
  102. package/dist/draft-card.js +14 -4
  103. package/dist/draft-card.js.map +1 -1
  104. package/dist/dropdown-button.js +3 -2
  105. package/dist/dropdown-button.js.map +1 -1
  106. package/dist/erd.js +2021 -0
  107. package/dist/erd.js.map +1 -0
  108. package/dist/fab.js +4 -4
  109. package/dist/field.js +257 -43
  110. package/dist/field.js.map +1 -1
  111. package/dist/file-upload.js +38 -16
  112. package/dist/file-upload.js.map +1 -1
  113. package/dist/filter-bar.js +2 -2
  114. package/dist/flow.js +27 -970
  115. package/dist/flow.js.map +1 -1
  116. package/dist/focus-ring.js +2 -0
  117. package/dist/focus-ring.js.map +1 -1
  118. package/dist/{form-associated-D3Tn33s_.js → form-associated-BHbg72PG.js} +3 -1
  119. package/dist/{form-associated-D3Tn33s_.js.map → form-associated-BHbg72PG.js.map} +1 -1
  120. package/dist/{form-submitter-DWwv6K9-.js → form-submitter-beG1CXAn.js} +7 -1
  121. package/dist/{form-submitter-DWwv6K9-.js.map → form-submitter-beG1CXAn.js.map} +1 -1
  122. package/dist/form.js +3 -3
  123. package/dist/{generative-view-DmtpDobn.js → generative-view-BKlcuujw.js} +13 -13
  124. package/dist/generative-view-BKlcuujw.js.map +1 -0
  125. package/dist/generative-view.js +3 -3
  126. package/dist/geometry-INg82Lxq.js +305 -0
  127. package/dist/geometry-INg82Lxq.js.map +1 -0
  128. package/dist/history-YbTSQZHj.js +45 -0
  129. package/dist/history-YbTSQZHj.js.map +1 -0
  130. package/dist/host-CZK7xhzh.js +40 -0
  131. package/dist/host-CZK7xhzh.js.map +1 -0
  132. package/dist/html-editor.js +6 -6
  133. package/dist/{hyperlink-DhE9RlVS.js → hyperlink-DycWPKwU.js} +10 -1
  134. package/dist/hyperlink-DycWPKwU.js.map +1 -0
  135. package/dist/{i18n-controller-urcQKYGe.js → i18n-controller-DJHsE1YH.js} +2 -2
  136. package/dist/{i18n-controller-urcQKYGe.js.map → i18n-controller-DJHsE1YH.js.map} +1 -1
  137. package/dist/icon-button.js +11 -9
  138. package/dist/icon-button.js.map +1 -1
  139. package/dist/image.js +2 -2
  140. package/dist/index.js +42 -22
  141. package/dist/index.js.map +1 -1
  142. package/dist/inline-edit.js +2 -2
  143. package/dist/input.js +5 -5
  144. package/dist/json-viewer.js +2 -2
  145. package/dist/kanban.js +2 -2
  146. package/dist/kbd.js +2 -2
  147. package/dist/linear-progress.js +3 -3
  148. package/dist/link-button.js +9 -7
  149. package/dist/link-button.js.map +1 -1
  150. package/dist/list-item.js +2 -2
  151. package/dist/list.js +2 -2
  152. package/dist/listbox.js +4 -4
  153. package/dist/loader-full.js +17 -16
  154. package/dist/loader-full.js.map +1 -1
  155. package/dist/loader.js +51 -18
  156. package/dist/loader.js.map +1 -1
  157. package/dist/markdown-editor.js +6 -6
  158. package/dist/markers-BFmh1OCz.js +46 -0
  159. package/dist/markers-BFmh1OCz.js.map +1 -0
  160. package/dist/measure-controller-Dmc5hZKg.js +89 -0
  161. package/dist/measure-controller-Dmc5hZKg.js.map +1 -0
  162. package/dist/mention-input.js +7 -6
  163. package/dist/mention-input.js.map +1 -1
  164. package/dist/menu-item.js +3 -2
  165. package/dist/menu-item.js.map +1 -1
  166. package/dist/{menu-trigger-controller-DyLpTxM7.js → menu-trigger-controller-CEJq1ugC.js} +11 -14
  167. package/dist/menu-trigger-controller-CEJq1ugC.js.map +1 -0
  168. package/dist/menu.js +2 -2
  169. package/dist/modal.js +2 -2
  170. package/dist/navigation-bar.js +2 -2
  171. package/dist/navigation-drawer.js +2 -2
  172. package/dist/navigation-rail.js +2 -2
  173. package/dist/notification-center.js +3 -3
  174. package/dist/number-field.js +7 -6
  175. package/dist/number-field.js.map +1 -1
  176. package/dist/option.js +2 -2
  177. package/dist/page-header.js +2 -2
  178. package/dist/pagination.js +2 -2
  179. package/dist/password-field.js +6 -6
  180. package/dist/password-rules.js +2 -2
  181. package/dist/phone-field.js +6 -6
  182. package/dist/{picker-field-B4DtcJfL.js → picker-field-CUI05sWc.js} +3 -3
  183. package/dist/{picker-field-B4DtcJfL.js.map → picker-field-CUI05sWc.js.map} +1 -1
  184. package/dist/pin-input.js +6 -6
  185. package/dist/presence-indicator.js +2 -2
  186. package/dist/prompt-input.js +6 -6
  187. package/dist/radio-group.js +2 -1
  188. package/dist/radio-group.js.map +1 -1
  189. package/dist/radio.js +6 -6
  190. package/dist/radio.js.map +1 -1
  191. package/dist/rating.js +6 -5
  192. package/dist/rating.js.map +1 -1
  193. package/dist/redvars-loader.js +2 -2
  194. package/dist/{relative-time-BVQXLuHm.js → relative-time-BNxqvEbg.js} +13 -2
  195. package/dist/relative-time-BNxqvEbg.js.map +1 -0
  196. package/dist/relative-time.js +3 -3
  197. package/dist/resizable-panels.js +2 -2
  198. package/dist/{rich-text-input-DLICqof1.js → rich-text-input-N_hqnXej.js} +3 -3
  199. package/dist/{rich-text-input-DLICqof1.js.map → rich-text-input-N_hqnXej.js.map} +1 -1
  200. package/dist/ripple.js +2 -0
  201. package/dist/ripple.js.map +1 -1
  202. package/dist/{schema-hMt-NRLk.js → schema-Dy0z-80u.js} +2 -2
  203. package/dist/{schema-hMt-NRLk.js.map → schema-Dy0z-80u.js.map} +1 -1
  204. package/dist/search.js +5 -5
  205. package/dist/segmented-button-group.js +1 -1
  206. package/dist/select.js +8 -8
  207. package/dist/side-sheet.js +2 -2
  208. package/dist/signature-pad.js +6 -5
  209. package/dist/signature-pad.js.map +1 -1
  210. package/dist/slider.js +6 -5
  211. package/dist/slider.js.map +1 -1
  212. package/dist/snackbar.js +2 -2
  213. package/dist/sparkline.js +2 -2
  214. package/dist/split-button.js +109 -21
  215. package/dist/split-button.js.map +1 -1
  216. package/dist/src/__internal/ai/suggestion-controller.d.ts +2 -0
  217. package/dist/src/__internal/diagram/canvas-base.d.ts +105 -0
  218. package/dist/src/__internal/diagram/canvas-link.d.ts +21 -0
  219. package/dist/src/__internal/diagram/geometry.d.ts +49 -0
  220. package/dist/src/__internal/diagram/history.d.ts +17 -0
  221. package/dist/src/__internal/diagram/host.d.ts +45 -0
  222. package/dist/src/__internal/diagram/markers.d.ts +16 -0
  223. package/dist/src/__internal/diagram/measure-controller.d.ts +32 -0
  224. package/dist/src/__internal/diagram/motion.d.ts +22 -0
  225. package/dist/src/__internal/diagram/selection.d.ts +20 -0
  226. package/dist/src/__internal/diagram/types.d.ts +39 -0
  227. package/dist/src/__internal/diagram/viewport-controller.d.ts +89 -0
  228. package/dist/src/__internal/i18n/strings.d.ts +155 -0
  229. package/dist/src/__internal/menu-trigger-controller.d.ts +11 -8
  230. package/dist/src/__internal/toggle-base.d.ts +8 -0
  231. package/dist/src/__internal/utils/deprecate.d.ts +3 -3
  232. package/dist/src/__internal/utils/relative-time.d.ts +5 -0
  233. package/dist/src/accordion/accordion.d.ts +1 -0
  234. package/dist/src/ai-badge/ai-badge.d.ts +8 -0
  235. package/dist/src/button/button/button.d.ts +4 -0
  236. package/dist/src/chat-message/chat-message.d.ts +51 -10
  237. package/dist/src/chat-message/index.d.ts +1 -1
  238. package/dist/src/chat-thread/chat-event.d.ts +37 -0
  239. package/dist/src/chat-thread/chat-thread.d.ts +7 -4
  240. package/dist/src/chat-thread/index.d.ts +1 -0
  241. package/dist/src/code-editor/code-editor.d.ts +1 -0
  242. package/dist/src/date-picker/date-picker.d.ts +2 -0
  243. package/dist/src/dependency-map/dependency-map-layout.d.ts +48 -0
  244. package/dist/src/dependency-map/dependency-map.d.ts +241 -0
  245. package/dist/src/dependency-map/index.d.ts +2 -0
  246. package/dist/src/diagram/diagram.d.ts +300 -0
  247. package/dist/src/diagram/flow.d.ts +53 -0
  248. package/dist/src/diagram/index.d.ts +4 -0
  249. package/dist/src/diagram-controls/diagram-controls.d.ts +46 -0
  250. package/dist/src/diagram-controls/index.d.ts +1 -0
  251. package/dist/src/diagram-minimap/diagram-minimap.d.ts +39 -0
  252. package/dist/src/diagram-minimap/index.d.ts +1 -0
  253. package/dist/src/erd/erd-layout.d.ts +27 -0
  254. package/dist/src/erd/erd.d.ts +266 -0
  255. package/dist/src/erd/index.d.ts +2 -0
  256. package/dist/src/field/field.d.ts +38 -1
  257. package/dist/src/file-upload/file-upload.d.ts +3 -1
  258. package/dist/src/focus-ring/focus-ring.d.ts +2 -0
  259. package/dist/src/index.d.ts +17 -4
  260. package/dist/src/input/BaseField.d.ts +15 -1
  261. package/dist/src/input/BaseInput.d.ts +4 -0
  262. package/dist/src/menu/menu-item/menu-item.d.ts +1 -0
  263. package/dist/src/number-field/number-field.d.ts +4 -0
  264. package/dist/src/progress/base-progress.d.ts +3 -0
  265. package/dist/src/radio/radio-group.d.ts +1 -0
  266. package/dist/src/rating/rating.d.ts +1 -0
  267. package/dist/src/ripple/ripple.d.ts +2 -0
  268. package/dist/src/signature-pad/signature-pad.d.ts +1 -0
  269. package/dist/src/slider/slider.d.ts +1 -0
  270. package/dist/src/split-button/split-button.d.ts +7 -2
  271. package/dist/src/switch/switch.d.ts +1 -0
  272. package/dist/src/tabs/tab.d.ts +2 -0
  273. package/dist/src/tabs/tabs.d.ts +1 -0
  274. package/dist/src/textarea/textarea.d.ts +3 -0
  275. package/dist/src/time-picker/time-picker.d.ts +2 -0
  276. package/dist/src/transfer-list/transfer-list.d.ts +1 -0
  277. package/dist/src/tree-chart/index.d.ts +2 -0
  278. package/dist/src/tree-chart/tree-chart-layout.d.ts +49 -0
  279. package/dist/src/tree-chart/tree-chart.d.ts +221 -0
  280. package/dist/src/workflow/index.d.ts +2 -0
  281. package/dist/src/workflow/workflow-format.d.ts +5 -0
  282. package/dist/src/workflow/workflow-model.d.ts +194 -0
  283. package/dist/src/workflow/workflow.d.ts +313 -0
  284. package/dist/src/workflow-timeline/index.d.ts +1 -0
  285. package/dist/src/workflow-timeline/workflow-timeline.d.ts +41 -0
  286. package/dist/stat.js +2 -2
  287. package/dist/status-indicator.js +2 -2
  288. package/dist/step.js +2 -2
  289. package/dist/stepper.js +2 -2
  290. package/dist/{strings-DmbqMTfs.js → strings-DnYjGbbc.js} +169 -1
  291. package/dist/{strings-DmbqMTfs.js.map → strings-DnYjGbbc.js.map} +1 -1
  292. package/dist/sub-menu.js +2 -2
  293. package/dist/{suggestion-controller-CW17adxd.js → suggestion-controller-7YRQqkaI.js} +3 -1
  294. package/dist/{suggestion-controller-CW17adxd.js.map → suggestion-controller-7YRQqkaI.js.map} +1 -1
  295. package/dist/svg.js +2 -2
  296. package/dist/switch.js +6 -5
  297. package/dist/switch.js.map +1 -1
  298. package/dist/tab.js +1 -0
  299. package/dist/tab.js.map +1 -1
  300. package/dist/table.js +50 -11
  301. package/dist/table.js.map +1 -1
  302. package/dist/tabs.js +1 -0
  303. package/dist/tabs.js.map +1 -1
  304. package/dist/test/diagram-controls.test.d.ts +1 -0
  305. package/dist/test/diagram-geometry.test.d.ts +1 -0
  306. package/dist/test/diagram.test.d.ts +1 -0
  307. package/dist/test/erd.test.d.ts +1 -0
  308. package/dist/test/toggle-label.test.d.ts +1 -0
  309. package/dist/test/tree-chart.test.d.ts +1 -0
  310. package/dist/test/workflow-debug.test.d.ts +1 -0
  311. package/dist/test/workflow.test.d.ts +1 -0
  312. package/dist/textarea.js +13 -6
  313. package/dist/textarea.js.map +1 -1
  314. package/dist/time-field.js +7 -7
  315. package/dist/time-picker.js +4 -2
  316. package/dist/time-picker.js.map +1 -1
  317. package/dist/timeline-item.js +2 -2
  318. package/dist/timeline.js +2 -2
  319. package/dist/{toggle-base-BQO5pjrU.js → toggle-base-CXmFSp3b.js} +19 -3
  320. package/dist/toggle-base-CXmFSp3b.js.map +1 -0
  321. package/dist/tour.js +2 -2
  322. package/dist/transfer-list.js +6 -5
  323. package/dist/transfer-list.js.map +1 -1
  324. package/dist/{chart-base-B-gOg2Di.js → transform-CxeQFXXB.js} +9 -839
  325. package/dist/transform-CxeQFXXB.js.map +1 -0
  326. package/dist/tree-chart.js +1986 -0
  327. package/dist/tree-chart.js.map +1 -0
  328. package/dist/tree-item.js +2 -2
  329. package/dist/tree.js +2 -2
  330. package/dist/tsconfig.tsbuildinfo +1 -1
  331. package/dist/typing-indicator.js +2 -2
  332. package/dist/url-field.js +6 -6
  333. package/dist/user-menu.js +3 -3
  334. package/dist/virtual-list.js +2 -2
  335. package/dist/workflow-format-BsyveyeC.js +34 -0
  336. package/dist/workflow-format-BsyveyeC.js.map +1 -0
  337. package/dist/workflow-model-CauduOG2.js +330 -0
  338. package/dist/workflow-model-CauduOG2.js.map +1 -0
  339. package/dist/workflow-timeline.js +354 -0
  340. package/dist/workflow-timeline.js.map +1 -0
  341. package/dist/workflow.js +3337 -0
  342. package/dist/workflow.js.map +1 -0
  343. package/dist/workspace-switcher.js +3 -3
  344. package/package.json +1 -1
  345. package/readme.md +44 -2
  346. package/src/LoaderUtils.ts +9 -2
  347. package/src/__internal/ai/suggestion-controller.ts +3 -1
  348. package/src/__internal/diagram/canvas-base.ts +410 -0
  349. package/src/__internal/diagram/canvas-link.ts +66 -0
  350. package/src/__internal/diagram/geometry.ts +372 -0
  351. package/src/__internal/diagram/history.ts +49 -0
  352. package/src/__internal/diagram/host.ts +76 -0
  353. package/src/__internal/diagram/markers.ts +56 -0
  354. package/src/__internal/diagram/measure-controller.ts +104 -0
  355. package/src/__internal/diagram/motion.ts +89 -0
  356. package/src/__internal/diagram/selection.ts +69 -0
  357. package/src/__internal/diagram/types.ts +56 -0
  358. package/src/__internal/diagram/viewport-controller.ts +494 -0
  359. package/src/__internal/i18n/strings.ts +207 -0
  360. package/src/__internal/menu-trigger-controller.ts +11 -15
  361. package/src/__internal/mixins/field.ts +3 -0
  362. package/src/__internal/mixins/form-associated.ts +2 -0
  363. package/src/__internal/mixins/form-submitter.ts +6 -0
  364. package/src/__internal/mixins/hyperlink.ts +10 -0
  365. package/src/__internal/toggle-base.ts +16 -0
  366. package/src/__internal/utils/deprecate.ts +5 -4
  367. package/src/__internal/utils/relative-time.ts +20 -0
  368. package/src/accordion/accordion.ts +1 -0
  369. package/src/ai-badge/ai-badge.scss +8 -0
  370. package/src/ai-badge/ai-badge.ts +21 -4
  371. package/src/button/base-button/base-button.ts +2 -0
  372. package/src/button/button/button-base.scss +9 -2
  373. package/src/button/button/button-layers.scss +3 -1
  374. package/src/button/button/button.ts +4 -0
  375. package/src/chat-message/chat-message.scss +72 -0
  376. package/src/chat-message/chat-message.ts +137 -18
  377. package/src/chat-message/index.ts +1 -0
  378. package/src/chat-thread/chat-event.scss +36 -0
  379. package/src/chat-thread/chat-event.ts +79 -0
  380. package/src/chat-thread/chat-thread.scss +4 -1
  381. package/src/chat-thread/chat-thread.ts +22 -6
  382. package/src/chat-thread/index.ts +1 -0
  383. package/src/code-editor/code-editor.ts +1 -0
  384. package/src/date-picker/date-picker.ts +2 -0
  385. package/src/dependency-map/dependency-map-layout.ts +505 -0
  386. package/src/dependency-map/dependency-map.scss +626 -0
  387. package/src/dependency-map/dependency-map.ts +1280 -0
  388. package/src/dependency-map/index.ts +16 -0
  389. package/src/diagram/diagram.scss +513 -0
  390. package/src/diagram/diagram.ts +1852 -0
  391. package/src/diagram/flow.ts +81 -0
  392. package/src/diagram/index.ts +44 -0
  393. package/src/diagram-controls/diagram-controls.scss +68 -0
  394. package/src/diagram-controls/diagram-controls.ts +255 -0
  395. package/src/diagram-controls/index.ts +1 -0
  396. package/src/diagram-minimap/diagram-minimap.scss +41 -0
  397. package/src/diagram-minimap/diagram-minimap.ts +149 -0
  398. package/src/diagram-minimap/index.ts +1 -0
  399. package/src/draft-card/draft-card.scss +16 -2
  400. package/src/dropdown-button/dropdown-button.ts +2 -1
  401. package/src/erd/erd-layout.ts +92 -0
  402. package/src/erd/erd.scss +636 -0
  403. package/src/erd/erd.ts +1728 -0
  404. package/src/erd/index.ts +17 -0
  405. package/src/field/field.scss +197 -23
  406. package/src/field/field.ts +109 -16
  407. package/src/file-upload/file-upload.scss +37 -10
  408. package/src/file-upload/file-upload.ts +3 -1
  409. package/src/focus-ring/focus-ring.ts +2 -0
  410. package/src/generative-view/catalog.generated.ts +12 -11
  411. package/src/index.ts +123 -3
  412. package/src/input/BaseField.ts +45 -2
  413. package/src/input/BaseInput.ts +4 -1
  414. package/src/loader.ts +29 -0
  415. package/src/mention-input/mention-input.scss +2 -0
  416. package/src/menu/menu-item/menu-item.ts +1 -0
  417. package/src/number-field/number-field.ts +4 -0
  418. package/src/progress/base-progress.ts +3 -0
  419. package/src/radio/radio-group.ts +1 -0
  420. package/src/radio/radio.ts +1 -1
  421. package/src/rating/rating.ts +1 -0
  422. package/src/ripple/ripple.ts +2 -0
  423. package/src/signature-pad/signature-pad.ts +1 -0
  424. package/src/slider/slider.ts +1 -0
  425. package/src/split-button/split-button-colors.scss +9 -0
  426. package/src/split-button/split-button-sizes.scss +32 -5
  427. package/src/split-button/split-button.scss +61 -8
  428. package/src/split-button/split-button.ts +15 -8
  429. package/src/switch/switch.ts +1 -0
  430. package/src/table/table.scss +57 -9
  431. package/src/table/table.ts +3 -1
  432. package/src/tabs/tab.ts +2 -0
  433. package/src/tabs/tabs.ts +1 -0
  434. package/src/textarea/textarea.scss +2 -0
  435. package/src/textarea/textarea.ts +8 -0
  436. package/src/time-picker/time-picker.ts +2 -0
  437. package/src/transfer-list/transfer-list.ts +1 -0
  438. package/src/tree-chart/index.ts +13 -0
  439. package/src/tree-chart/tree-chart-layout.ts +185 -0
  440. package/src/tree-chart/tree-chart.scss +377 -0
  441. package/src/tree-chart/tree-chart.ts +1170 -0
  442. package/src/workflow/index.ts +35 -0
  443. package/src/workflow/workflow-format.ts +29 -0
  444. package/src/workflow/workflow-model.ts +583 -0
  445. package/src/workflow/workflow.scss +1164 -0
  446. package/src/workflow/workflow.ts +2674 -0
  447. package/src/workflow-timeline/index.ts +1 -0
  448. package/src/workflow-timeline/workflow-timeline.scss +128 -0
  449. package/src/workflow-timeline/workflow-timeline.ts +238 -0
  450. package/dist/BaseField-CAog9TIc.js.map +0 -1
  451. package/dist/BaseInput-CcMfg1Y2.js.map +0 -1
  452. package/dist/base-button-Do2TUy8M.js.map +0 -1
  453. package/dist/base-progress-BiLlZVHJ.js.map +0 -1
  454. package/dist/cartesian-chart-C-f1frt0.js.map +0 -1
  455. package/dist/chart-base-B-gOg2Di.js.map +0 -1
  456. package/dist/generative-view-DmtpDobn.js.map +0 -1
  457. package/dist/hyperlink-DhE9RlVS.js.map +0 -1
  458. package/dist/menu-trigger-controller-DyLpTxM7.js.map +0 -1
  459. package/dist/relative-time-BVQXLuHm.js.map +0 -1
  460. package/dist/src/flow/flow.d.ts +0 -178
  461. package/dist/src/flow/index.d.ts +0 -2
  462. package/dist/toggle-base-BQO5pjrU.js.map +0 -1
  463. package/src/button/button-group/readme.md +0 -23
  464. package/src/flow/flow.scss +0 -215
  465. package/src/flow/flow.ts +0 -958
  466. package/src/flow/index.ts +0 -10
  467. /package/dist/test/{flow.test.d.ts → dependency-map.test.d.ts} +0 -0
@@ -0,0 +1,89 @@
1
+ /** Whether the person asked for less motion. Diagram animations jump to their end state when true. */
2
+ export function prefersReducedMotion(): boolean {
3
+ return (
4
+ typeof matchMedia === 'function' &&
5
+ matchMedia('(prefers-reduced-motion: reduce)').matches
6
+ );
7
+ }
8
+
9
+ export const easeInOutCubic = (p: number) =>
10
+ p < 0.5 ? 4 * p ** 3 : 1 - (-2 * p + 2) ** 3 / 2;
11
+
12
+ export const easeOutCubic = (p: number) => 1 - (1 - p) ** 3;
13
+
14
+ export interface TweenOptions {
15
+ duration: number;
16
+ easing?: (p: number) => number;
17
+ /** Called every frame with the eased progress, 0 to 1. */
18
+ onUpdate: (p: number) => void;
19
+ onDone?: () => void;
20
+ }
21
+
22
+ /**
23
+ * Runs `onUpdate` every animation frame for `duration` milliseconds. Under reduced motion it
24
+ * calls `onUpdate(1)` and `onDone` straight away. Returns a function that stops the tween without
25
+ * calling `onDone`.
26
+ */
27
+ export function tween({
28
+ duration,
29
+ easing = easeInOutCubic,
30
+ onUpdate,
31
+ onDone,
32
+ }: TweenOptions): () => void {
33
+ if (duration <= 0 || prefersReducedMotion()) {
34
+ onUpdate(1);
35
+ onDone?.();
36
+ return () => {};
37
+ }
38
+ let frame = 0;
39
+ let stopped = false;
40
+ const start = performance.now();
41
+ const step = (now: number) => {
42
+ if (stopped) return;
43
+ const p = Math.min(1, (now - start) / duration);
44
+ onUpdate(easing(p));
45
+ if (p < 1) {
46
+ frame = requestAnimationFrame(step);
47
+ } else {
48
+ onDone?.();
49
+ }
50
+ };
51
+ frame = requestAnimationFrame(step);
52
+ return () => {
53
+ stopped = true;
54
+ cancelAnimationFrame(frame);
55
+ };
56
+ }
57
+
58
+ /**
59
+ * Fades and shrinks elements before they are removed, then calls `done`. Resolves at once under
60
+ * reduced motion or when the Web Animations API is missing.
61
+ */
62
+ export function animateOut(
63
+ elements: Element[],
64
+ done: () => void,
65
+ duration = 160,
66
+ ) {
67
+ if (elements.length === 0 || prefersReducedMotion()) {
68
+ done();
69
+ return;
70
+ }
71
+ const animations = elements
72
+ .filter(el => typeof (el as HTMLElement).animate === 'function')
73
+ .map(el =>
74
+ (el as HTMLElement).animate(
75
+ [
76
+ { opacity: 1, transform: 'scale(1)' },
77
+ { opacity: 0, transform: 'scale(0.95)' },
78
+ ],
79
+ { duration, easing: 'ease-in', fill: 'forwards' },
80
+ ),
81
+ );
82
+ if (animations.length === 0) {
83
+ done();
84
+ return;
85
+ }
86
+ Promise.all(animations.map(a => a.finished.catch(() => undefined))).then(
87
+ done,
88
+ );
89
+ }
@@ -0,0 +1,69 @@
1
+ export type SelectionKind = 'node' | 'edge';
2
+
3
+ /** A set of selected nodes and edges, kept apart by kind so ids may repeat across kinds. */
4
+ export class DiagramSelection {
5
+ private keys = new Set<string>();
6
+
7
+ private readonly onChange: () => void;
8
+
9
+ constructor(onChange: () => void = () => undefined) {
10
+ this.onChange = onChange;
11
+ }
12
+
13
+ private static key(kind: SelectionKind, id: string) {
14
+ return `${kind}:${id}`;
15
+ }
16
+
17
+ get size(): number {
18
+ return this.keys.size;
19
+ }
20
+
21
+ has(kind: SelectionKind, id: string): boolean {
22
+ return this.keys.has(DiagramSelection.key(kind, id));
23
+ }
24
+
25
+ ids(kind: SelectionKind): string[] {
26
+ const prefix = `${kind}:`;
27
+ return [...this.keys]
28
+ .filter(k => k.startsWith(prefix))
29
+ .map(k => k.slice(prefix.length));
30
+ }
31
+
32
+ /** Replaces the selection. */
33
+ set(items: { kind: SelectionKind; id: string }[]) {
34
+ const next = new Set(items.map(i => DiagramSelection.key(i.kind, i.id)));
35
+ if (
36
+ next.size === this.keys.size &&
37
+ [...next].every(k => this.keys.has(k))
38
+ ) {
39
+ return;
40
+ }
41
+ this.keys = next;
42
+ this.onChange();
43
+ }
44
+
45
+ toggle(kind: SelectionKind, id: string) {
46
+ const key = DiagramSelection.key(kind, id);
47
+ if (this.keys.has(key)) this.keys.delete(key);
48
+ else this.keys.add(key);
49
+ this.onChange();
50
+ }
51
+
52
+ /** Drops ids that no longer exist. */
53
+ retain(kind: SelectionKind, existing: Set<string>) {
54
+ let changed = false;
55
+ for (const id of this.ids(kind)) {
56
+ if (!existing.has(id)) {
57
+ this.keys.delete(DiagramSelection.key(kind, id));
58
+ changed = true;
59
+ }
60
+ }
61
+ if (changed) this.onChange();
62
+ }
63
+
64
+ clear() {
65
+ if (this.keys.size === 0) return;
66
+ this.keys.clear();
67
+ this.onChange();
68
+ }
69
+ }
@@ -0,0 +1,56 @@
1
+ /** A point in canvas or screen coordinates. */
2
+ export interface DiagramPoint {
3
+ x: number;
4
+ y: number;
5
+ }
6
+
7
+ export interface DiagramSize {
8
+ width: number;
9
+ height: number;
10
+ }
11
+
12
+ /** A box in canvas coordinates: top-left corner plus size. */
13
+ export interface DiagramRect extends DiagramPoint, DiagramSize {}
14
+
15
+ /** A side of a node, where a port sits and where a connector leaves or enters. */
16
+ export type DiagramSide = 'top' | 'right' | 'bottom' | 'left';
17
+
18
+ /** How a connector is drawn between two ports. */
19
+ export type DiagramConnector = 'elbow' | 'bezier' | 'straight';
20
+
21
+ /**
22
+ * The symbol drawn at the end of a connector. The crow's-foot set (`one`, `zero-or-one`, `many`,
23
+ * `one-or-many`, `zero-or-many`) marks cardinality in entity diagrams.
24
+ */
25
+ export type DiagramMarker =
26
+ | 'none'
27
+ | 'arrow'
28
+ | 'arrow-open'
29
+ | 'circle'
30
+ | 'diamond'
31
+ | 'one'
32
+ | 'zero-or-one'
33
+ | 'many'
34
+ | 'one-or-many'
35
+ | 'zero-or-many';
36
+
37
+ /**
38
+ * Where the camera is: a canvas point `c` is drawn on screen at `c * zoom + (x, y)`, relative to
39
+ * the canvas's top-left corner.
40
+ */
41
+ export interface DiagramView {
42
+ x: number;
43
+ y: number;
44
+ zoom: number;
45
+ }
46
+
47
+ /**
48
+ * Where the camera starts: `fit` fits all content, `origin` puts canvas point 0,0 at the top-left
49
+ * corner at 100%, `first` centres the first node at 100%.
50
+ */
51
+ export type DiagramStartPosition = 'fit' | 'origin' | 'first';
52
+
53
+ /** Detail of `viewport-change`. `settled` is true once a pan, zoom or animation has finished. */
54
+ export interface DiagramViewportDetail extends DiagramView {
55
+ settled: boolean;
56
+ }
@@ -0,0 +1,494 @@
1
+ import type { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ import type { DiagramPoint, DiagramRect, DiagramView } from './types.js';
3
+ import { prefersReducedMotion, tween } from './motion.js';
4
+
5
+ export interface ViewportOptions {
6
+ /** The element that shows the canvas and receives pan and zoom input. */
7
+ element: () => HTMLElement | null | undefined;
8
+ minZoom: () => number;
9
+ maxZoom: () => number;
10
+ /** Called on every view change; `settled` is true once a gesture or animation has finished. */
11
+ onChange: (view: DiagramView, settled: boolean) => void;
12
+ /** Whether a press on `target` is on the empty canvas (pans) rather than on content. */
13
+ isBackground: (target: EventTarget | null) => boolean;
14
+ /**
15
+ * Called for a primary-button press on the background before panning starts. Return true to
16
+ * handle the press yourself, for example to draw a marquee.
17
+ */
18
+ onBackgroundPointerDown?: (event: PointerEvent) => boolean;
19
+ /** Called when a background press is released without moving. */
20
+ onBackgroundClick?: (event: PointerEvent) => void;
21
+ }
22
+
23
+ /** Pointer travel, in screen pixels, before a press becomes a pan. */
24
+ const PAN_THRESHOLD = 3;
25
+
26
+ /** Milliseconds without wheel input before a wheel gesture counts as settled. */
27
+ const WHEEL_SETTLE_MS = 150;
28
+
29
+ const clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v));
30
+
31
+ /**
32
+ * The camera of an infinite canvas: pans with a background drag, Space + drag, the middle button,
33
+ * a trackpad or the wheel, and zooms around the pointer with Ctrl/⌘ + wheel or a pinch. There are
34
+ * no bounds, so content can sit anywhere, including at negative coordinates.
35
+ *
36
+ * A canvas point `c` is drawn at `c * zoom + (x, y)` relative to the element's top-left corner.
37
+ */
38
+ export class ViewportController implements ReactiveController {
39
+ view: DiagramView = { x: 0, y: 0, zoom: 1 };
40
+
41
+ /** Whether Space is held, so any drag pans. */
42
+ spaceHeld = false;
43
+
44
+ /** Whether a pan gesture is moving the view. */
45
+ panning = false;
46
+
47
+ private readonly host: ReactiveControllerHost;
48
+
49
+ private readonly options: ViewportOptions;
50
+
51
+ private attachedTo?: HTMLElement;
52
+
53
+ private pan?: {
54
+ pointerId: number;
55
+ startX: number;
56
+ startY: number;
57
+ origin: DiagramView;
58
+ moved: boolean;
59
+ background: boolean;
60
+ element: HTMLElement;
61
+ };
62
+
63
+ private touches = new Map<number, DiagramPoint>();
64
+
65
+ private pinch?: { distance: number; zoom: number; anchor: DiagramPoint };
66
+
67
+ private wheelTimer?: ReturnType<typeof setTimeout>;
68
+
69
+ private stopAnimation?: () => void;
70
+
71
+ constructor(host: ReactiveControllerHost, options: ViewportOptions) {
72
+ this.host = host;
73
+ this.options = options;
74
+ host.addController(this);
75
+ }
76
+
77
+ hostUpdated() {
78
+ const element = this.options.element();
79
+ if (element && element !== this.attachedTo) {
80
+ this.detach();
81
+ this.attach(element);
82
+ }
83
+ }
84
+
85
+ hostDisconnected() {
86
+ this.detach();
87
+ this.cancelAnimation();
88
+ clearTimeout(this.wheelTimer);
89
+ }
90
+
91
+ // ── Geometry
92
+
93
+ /** The element's size in screen pixels. */
94
+ size(): { width: number; height: number } {
95
+ const el = this.options.element();
96
+ return { width: el?.clientWidth ?? 0, height: el?.clientHeight ?? 0 };
97
+ }
98
+
99
+ /** The part of the canvas in view, in canvas coordinates. */
100
+ visibleRect(): DiagramRect {
101
+ const { width, height } = this.size();
102
+ const { x, y, zoom } = this.view;
103
+ return {
104
+ x: -x / zoom,
105
+ y: -y / zoom,
106
+ width: width / zoom,
107
+ height: height / zoom,
108
+ };
109
+ }
110
+
111
+ /** Converts client (page viewport) coordinates to canvas coordinates. */
112
+ toCanvas(clientX: number, clientY: number): DiagramPoint {
113
+ const rect = this.options.element()?.getBoundingClientRect();
114
+ const left = rect?.left ?? 0;
115
+ const top = rect?.top ?? 0;
116
+ return {
117
+ x: (clientX - left - this.view.x) / this.view.zoom,
118
+ y: (clientY - top - this.view.y) / this.view.zoom,
119
+ };
120
+ }
121
+
122
+ clampZoom(zoom: number): number {
123
+ return clamp(zoom, this.options.minZoom(), this.options.maxZoom());
124
+ }
125
+
126
+ /** The view that fits `rect` with `padding` screen pixels around it, never above `maxZoom`. */
127
+ viewForRect(rect: DiagramRect, padding: number, maxZoom = 1): DiagramView {
128
+ const { width, height } = this.size();
129
+ const fitW = (width - 2 * padding) / Math.max(rect.width, 1);
130
+ const fitH = (height - 2 * padding) / Math.max(rect.height, 1);
131
+ const zoom = this.clampZoom(
132
+ Math.min(fitW, fitH, maxZoom, this.options.maxZoom()),
133
+ );
134
+ return {
135
+ zoom,
136
+ x: width / 2 - (rect.x + rect.width / 2) * zoom,
137
+ y: height / 2 - (rect.y + rect.height / 2) * zoom,
138
+ };
139
+ }
140
+
141
+ /** The view that centres canvas `point` at `zoom`. */
142
+ viewCentering(point: DiagramPoint, zoom = this.view.zoom): DiagramView {
143
+ const { width, height } = this.size();
144
+ const z = this.clampZoom(zoom);
145
+ return { zoom: z, x: width / 2 - point.x * z, y: height / 2 - point.y * z };
146
+ }
147
+
148
+ // ── Moving the camera
149
+
150
+ /** Moves the camera at once. */
151
+ setView(view: DiagramView, settled = true) {
152
+ this.cancelAnimation();
153
+ this.apply(view, settled);
154
+ }
155
+
156
+ panBy(dx: number, dy: number, settled = true) {
157
+ this.setView(
158
+ { ...this.view, x: this.view.x + dx, y: this.view.y + dy },
159
+ settled,
160
+ );
161
+ }
162
+
163
+ /** Zooms by `factor` around a client point, or around the centre. */
164
+ zoomBy(factor: number, clientX?: number, clientY?: number, settled = true) {
165
+ this.zoomToValue(this.view.zoom * factor, clientX, clientY, settled);
166
+ }
167
+
168
+ zoomToValue(
169
+ zoom: number,
170
+ clientX?: number,
171
+ clientY?: number,
172
+ settled = true,
173
+ ) {
174
+ const el = this.options.element();
175
+ const rect = el?.getBoundingClientRect();
176
+ const { width, height } = this.size();
177
+ const px = clientX !== undefined && rect ? clientX - rect.left : width / 2;
178
+ const py = clientY !== undefined && rect ? clientY - rect.top : height / 2;
179
+ const next = this.clampZoom(zoom);
180
+ const cx = (px - this.view.x) / this.view.zoom;
181
+ const cy = (py - this.view.y) / this.view.zoom;
182
+ this.setView({ zoom: next, x: px - cx * next, y: py - cy * next }, settled);
183
+ }
184
+
185
+ /**
186
+ * Flies the camera to `target`. Long trips zoom out on the way, like a map. Jumps at once under
187
+ * reduced motion.
188
+ */
189
+ animateTo(target: DiagramView, duration = 500) {
190
+ this.cancelAnimation();
191
+ const goal = { ...target, zoom: this.clampZoom(target.zoom) };
192
+ const { width, height } = this.size();
193
+ if (prefersReducedMotion() || width === 0 || height === 0) {
194
+ this.apply(goal, true);
195
+ return;
196
+ }
197
+ const from = { ...this.view };
198
+ const c0 = {
199
+ x: (width / 2 - from.x) / from.zoom,
200
+ y: (height / 2 - from.y) / from.zoom,
201
+ };
202
+ const c1 = {
203
+ x: (width / 2 - goal.x) / goal.zoom,
204
+ y: (height / 2 - goal.y) / goal.zoom,
205
+ };
206
+ const travel =
207
+ Math.hypot(c1.x - c0.x, c1.y - c0.y) * Math.min(from.zoom, goal.zoom);
208
+ const far = travel > Math.max(width, height);
209
+ const lz0 = Math.log(from.zoom);
210
+ const lz1 = Math.log(goal.zoom);
211
+ this.stopAnimation = tween({
212
+ duration,
213
+ onUpdate: p => {
214
+ const dip = far ? 1 - 0.4 * Math.sin(Math.PI * p) : 1;
215
+ const zoom = Math.exp(lz0 + (lz1 - lz0) * p) * dip;
216
+ const cx = c0.x + (c1.x - c0.x) * p;
217
+ const cy = c0.y + (c1.y - c0.y) * p;
218
+ const view =
219
+ p >= 1
220
+ ? goal
221
+ : { zoom, x: width / 2 - cx * zoom, y: height / 2 - cy * zoom };
222
+ this.apply(view, false);
223
+ },
224
+ onDone: () => {
225
+ this.stopAnimation = undefined;
226
+ this.apply(goal, true);
227
+ },
228
+ });
229
+ }
230
+
231
+ cancelAnimation() {
232
+ this.stopAnimation?.();
233
+ this.stopAnimation = undefined;
234
+ }
235
+
236
+ private apply(view: DiagramView, settled: boolean) {
237
+ this.view = { x: view.x, y: view.y, zoom: view.zoom };
238
+ this.options.onChange(this.view, settled);
239
+ }
240
+
241
+ /** Starts a pan from a pointer press anywhere, for Space + drag over content. */
242
+ beginPan(event: PointerEvent, background = false) {
243
+ const element = this.options.element();
244
+ if (!element) return;
245
+ this.cancelAnimation();
246
+ event.preventDefault();
247
+ this.pan = {
248
+ pointerId: event.pointerId,
249
+ startX: event.clientX,
250
+ startY: event.clientY,
251
+ origin: { ...this.view },
252
+ moved: false,
253
+ background,
254
+ element,
255
+ };
256
+ try {
257
+ element.setPointerCapture(event.pointerId);
258
+ } catch {
259
+ // Synthetic pointers cannot be captured.
260
+ }
261
+ }
262
+
263
+ // ── Input
264
+
265
+ private attach(element: HTMLElement) {
266
+ this.attachedTo = element;
267
+ element.addEventListener('wheel', this.onWheel, { passive: false });
268
+ element.addEventListener('pointerdown', this.onPointerDown);
269
+ element.addEventListener('pointermove', this.onPointerMove);
270
+ element.addEventListener('pointerup', this.onPointerUp);
271
+ element.addEventListener('pointercancel', this.onPointerUp);
272
+ element.addEventListener('keydown', this.onKeyDown);
273
+ element.addEventListener('keyup', this.onKeyUp);
274
+ element.addEventListener('blur', this.onBlur);
275
+ }
276
+
277
+ private detach() {
278
+ const element = this.attachedTo;
279
+ if (!element) return;
280
+ element.removeEventListener('wheel', this.onWheel);
281
+ element.removeEventListener('pointerdown', this.onPointerDown);
282
+ element.removeEventListener('pointermove', this.onPointerMove);
283
+ element.removeEventListener('pointerup', this.onPointerUp);
284
+ element.removeEventListener('pointercancel', this.onPointerUp);
285
+ element.removeEventListener('keydown', this.onKeyDown);
286
+ element.removeEventListener('keyup', this.onKeyUp);
287
+ element.removeEventListener('blur', this.onBlur);
288
+ this.attachedTo = undefined;
289
+ }
290
+
291
+ /**
292
+ * Whether a wheel event belongs to something inside the canvas: an overlay marked
293
+ * `data-diagram-overlay` (a palette, a popover), or an element that can scroll that way.
294
+ */
295
+ private wheelBelongsInside(
296
+ event: WheelEvent,
297
+ ): 'overlay' | 'scroll' | undefined {
298
+ for (const node of event.composedPath()) {
299
+ if (node === this.attachedTo) break;
300
+ if (node instanceof HTMLElement) {
301
+ if (node.hasAttribute('data-diagram-overlay')) return 'overlay';
302
+ const style = getComputedStyle(node);
303
+ const scrollsY =
304
+ event.deltaY !== 0 &&
305
+ /(auto|scroll)/.test(style.overflowY) &&
306
+ node.scrollHeight > node.clientHeight;
307
+ const scrollsX =
308
+ event.deltaX !== 0 &&
309
+ /(auto|scroll)/.test(style.overflowX) &&
310
+ node.scrollWidth > node.clientWidth;
311
+ if (scrollsY || scrollsX) return 'scroll';
312
+ }
313
+ }
314
+ return undefined;
315
+ }
316
+
317
+ private onWheel = (event: WheelEvent) => {
318
+ const zooming = event.ctrlKey || event.metaKey;
319
+ const inside = this.wheelBelongsInside(event);
320
+ if (inside === 'overlay' || (inside === 'scroll' && !zooming)) {
321
+ // Let the overlay or scroller have it; only stop the browser zooming the page.
322
+ if (zooming) event.preventDefault();
323
+ return;
324
+ }
325
+ event.preventDefault();
326
+ this.cancelAnimation();
327
+ let dx = event.deltaX;
328
+ let dy = event.deltaY;
329
+ if (event.deltaMode === 1) {
330
+ dx *= 16;
331
+ dy *= 16;
332
+ } else if (event.deltaMode === 2) {
333
+ dx *= this.size().width;
334
+ dy *= this.size().height;
335
+ }
336
+ if (event.ctrlKey || event.metaKey) {
337
+ this.zoomBy(
338
+ Math.exp(-clamp(dy, -60, 60) * 0.0125),
339
+ event.clientX,
340
+ event.clientY,
341
+ false,
342
+ );
343
+ } else {
344
+ if (event.shiftKey && dx === 0) {
345
+ dx = dy;
346
+ dy = 0;
347
+ }
348
+ this.panBy(-dx, -dy, false);
349
+ }
350
+ clearTimeout(this.wheelTimer);
351
+ this.wheelTimer = setTimeout(
352
+ () => this.options.onChange(this.view, true),
353
+ WHEEL_SETTLE_MS,
354
+ );
355
+ };
356
+
357
+ private onPointerDown = (event: PointerEvent) => {
358
+ if (event.pointerType === 'touch') {
359
+ this.touches.set(event.pointerId, { x: event.clientX, y: event.clientY });
360
+ if (this.touches.size === 2) {
361
+ this.startPinch();
362
+ return;
363
+ }
364
+ }
365
+ const primary = event.button === 0;
366
+ const middle = event.button === 1;
367
+ if (!primary && !middle) return;
368
+ const background = this.options.isBackground(
369
+ event.composedPath()[0] ?? event.target,
370
+ );
371
+ if (!middle && !this.spaceHeld && !background) return;
372
+ if (
373
+ primary &&
374
+ background &&
375
+ !this.spaceHeld &&
376
+ this.options.onBackgroundPointerDown?.(event)
377
+ ) {
378
+ return;
379
+ }
380
+ if (background) {
381
+ this.options.element()?.focus({ preventScroll: true });
382
+ }
383
+ this.beginPan(event, background && primary);
384
+ };
385
+
386
+ private onPointerMove = (event: PointerEvent) => {
387
+ if (this.touches.has(event.pointerId)) {
388
+ this.touches.set(event.pointerId, { x: event.clientX, y: event.clientY });
389
+ if (this.pinch) {
390
+ this.movePinch();
391
+ return;
392
+ }
393
+ }
394
+ const { pan } = this;
395
+ if (!pan || event.pointerId !== pan.pointerId) return;
396
+ const dx = event.clientX - pan.startX;
397
+ const dy = event.clientY - pan.startY;
398
+ if (!pan.moved && Math.hypot(dx, dy) < PAN_THRESHOLD) return;
399
+ if (!pan.moved) {
400
+ pan.moved = true;
401
+ this.panning = true;
402
+ this.host.requestUpdate();
403
+ }
404
+ this.apply(
405
+ { ...pan.origin, x: pan.origin.x + dx, y: pan.origin.y + dy },
406
+ false,
407
+ );
408
+ };
409
+
410
+ private onPointerUp = (event: PointerEvent) => {
411
+ this.touches.delete(event.pointerId);
412
+ if (this.pinch && this.touches.size < 2) {
413
+ this.pinch = undefined;
414
+ this.options.onChange(this.view, true);
415
+ }
416
+ const { pan } = this;
417
+ if (!pan || event.pointerId !== pan.pointerId) return;
418
+ this.pan = undefined;
419
+ try {
420
+ if (pan.element.hasPointerCapture(event.pointerId)) {
421
+ pan.element.releasePointerCapture(event.pointerId);
422
+ }
423
+ } catch {
424
+ // The pointer is already gone.
425
+ }
426
+ if (pan.moved) {
427
+ this.panning = false;
428
+ this.host.requestUpdate();
429
+ this.options.onChange(this.view, true);
430
+ } else if (pan.background && event.type === 'pointerup') {
431
+ this.options.onBackgroundClick?.(event);
432
+ }
433
+ };
434
+
435
+ private startPinch() {
436
+ const [a, b] = [...this.touches.values()];
437
+ if (this.pan) {
438
+ this.pan = undefined;
439
+ this.panning = false;
440
+ }
441
+ const mid = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
442
+ this.pinch = {
443
+ distance: Math.max(Math.hypot(a.x - b.x, a.y - b.y), 1),
444
+ zoom: this.view.zoom,
445
+ anchor: this.toCanvas(mid.x, mid.y),
446
+ };
447
+ }
448
+
449
+ private movePinch() {
450
+ const { pinch } = this;
451
+ if (!pinch) return;
452
+ const [a, b] = [...this.touches.values()];
453
+ const rect = this.options.element()?.getBoundingClientRect();
454
+ const mid = {
455
+ x: (a.x + b.x) / 2 - (rect?.left ?? 0),
456
+ y: (a.y + b.y) / 2 - (rect?.top ?? 0),
457
+ };
458
+ const zoom = this.clampZoom(
459
+ pinch.zoom * (Math.hypot(a.x - b.x, a.y - b.y) / pinch.distance),
460
+ );
461
+ this.apply(
462
+ {
463
+ zoom,
464
+ x: mid.x - pinch.anchor.x * zoom,
465
+ y: mid.y - pinch.anchor.y * zoom,
466
+ },
467
+ false,
468
+ );
469
+ }
470
+
471
+ private onKeyDown = (event: KeyboardEvent) => {
472
+ if (event.key === ' ' && event.target === this.attachedTo) {
473
+ event.preventDefault();
474
+ if (!this.spaceHeld) {
475
+ this.spaceHeld = true;
476
+ this.host.requestUpdate();
477
+ }
478
+ }
479
+ };
480
+
481
+ private onKeyUp = (event: KeyboardEvent) => {
482
+ if (event.key === ' ' && this.spaceHeld) {
483
+ this.spaceHeld = false;
484
+ this.host.requestUpdate();
485
+ }
486
+ };
487
+
488
+ private onBlur = () => {
489
+ if (this.spaceHeld) {
490
+ this.spaceHeld = false;
491
+ this.host.requestUpdate();
492
+ }
493
+ };
494
+ }