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