@vonage/vivid 4.13.0 → 4.14.1

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 (512) hide show
  1. package/custom-elements.json +3088 -1610
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +70 -136
  5. package/index.d.ts +0 -1
  6. package/index.js +60 -62
  7. package/lib/accordion/accordion.d.ts +2 -2
  8. package/lib/accordion/accordion.template.d.ts +1 -2
  9. package/lib/accordion/definition.d.ts +1 -1
  10. package/lib/accordion-item/accordion-item.d.ts +2 -2
  11. package/lib/accordion-item/accordion-item.template.d.ts +2 -3
  12. package/lib/accordion-item/definition.d.ts +1 -1
  13. package/lib/action-group/action-group.d.ts +2 -2
  14. package/lib/action-group/action-group.template.d.ts +1 -3
  15. package/lib/action-group/definition.d.ts +1 -1
  16. package/lib/alert/alert.d.ts +2 -2
  17. package/lib/alert/alert.template.d.ts +2 -3
  18. package/lib/alert/definition.d.ts +1 -1
  19. package/lib/audio-player/audio-player.d.ts +2 -2
  20. package/lib/audio-player/audio-player.template.d.ts +2 -3
  21. package/lib/audio-player/definition.d.ts +1 -3
  22. package/lib/avatar/avatar.d.ts +2 -2
  23. package/lib/avatar/avatar.template.d.ts +2 -3
  24. package/lib/avatar/definition.d.ts +1 -1
  25. package/lib/badge/badge.d.ts +2 -2
  26. package/lib/badge/badge.template.d.ts +2 -3
  27. package/lib/badge/definition.d.ts +1 -3
  28. package/lib/banner/banner.d.ts +2 -2
  29. package/lib/banner/banner.template.d.ts +2 -3
  30. package/lib/banner/definition.d.ts +1 -1
  31. package/lib/breadcrumb/breadcrumb.d.ts +2 -2
  32. package/lib/breadcrumb/breadcrumb.template.d.ts +3 -4
  33. package/lib/breadcrumb/definition.d.ts +1 -1
  34. package/lib/breadcrumb-item/breadcrumb-item.d.ts +2 -2
  35. package/lib/breadcrumb-item/breadcrumb-item.template.d.ts +2 -3
  36. package/lib/breadcrumb-item/definition.d.ts +1 -1
  37. package/lib/button/button.d.ts +2 -2
  38. package/lib/button/button.template.d.ts +2 -4
  39. package/lib/button/definition.d.ts +1 -1
  40. package/lib/calendar/calendar.d.ts +2 -2
  41. package/lib/calendar/calendar.template.d.ts +1 -3
  42. package/lib/calendar/definition.d.ts +1 -1
  43. package/lib/calendar-event/calendar-event.d.ts +2 -2
  44. package/lib/calendar-event/calendar-event.template.d.ts +1 -3
  45. package/lib/calendar-event/definition.d.ts +1 -1
  46. package/lib/card/card.d.ts +2 -2
  47. package/lib/card/card.template.d.ts +2 -3
  48. package/lib/card/definition.d.ts +1 -1
  49. package/lib/checkbox/checkbox.form-associated.d.ts +3 -2
  50. package/lib/checkbox/checkbox.template.d.ts +2 -3
  51. package/lib/checkbox/definition.d.ts +1 -1
  52. package/lib/combobox/combobox.d.ts +17 -2
  53. package/lib/combobox/combobox.options.d.ts +7 -0
  54. package/lib/combobox/combobox.template.d.ts +2 -3
  55. package/lib/combobox/definition.d.ts +1 -2
  56. package/lib/data-grid/data-grid-cell.d.ts +16 -13
  57. package/lib/data-grid/data-grid-cell.template.d.ts +2 -3
  58. package/lib/data-grid/data-grid-row.d.ts +19 -2
  59. package/lib/data-grid/data-grid-row.template.d.ts +2 -2
  60. package/lib/data-grid/data-grid.d.ts +45 -4
  61. package/lib/data-grid/data-grid.template.d.ts +2 -2
  62. package/lib/data-grid/definition.d.ts +1 -6
  63. package/lib/date-picker/definition.d.ts +1 -3
  64. package/lib/date-range-picker/definition.d.ts +1 -3
  65. package/lib/dial-pad/definition.d.ts +1 -3
  66. package/lib/dial-pad/dial-pad.d.ts +2 -2
  67. package/lib/dial-pad/dial-pad.template.d.ts +2 -3
  68. package/lib/dialog/definition.d.ts +1 -1
  69. package/lib/dialog/dialog.d.ts +2 -2
  70. package/lib/dialog/dialog.template.d.ts +2 -3
  71. package/lib/divider/definition.d.ts +1 -1
  72. package/lib/divider/divider.d.ts +2 -2
  73. package/lib/divider/divider.template.d.ts +1 -3
  74. package/lib/elevation/definition.d.ts +1 -1
  75. package/lib/elevation/elevation.d.ts +3 -2
  76. package/lib/elevation/elevation.template.d.ts +1 -3
  77. package/lib/empty-state/definition.d.ts +1 -3
  78. package/lib/empty-state/empty-state.d.ts +2 -2
  79. package/lib/empty-state/empty-state.template.d.ts +2 -3
  80. package/lib/fab/definition.d.ts +1 -3
  81. package/lib/fab/fab.template.d.ts +2 -3
  82. package/lib/file-picker/definition.d.ts +1 -3
  83. package/lib/file-picker/file-picker.form-associated.d.ts +3 -2
  84. package/lib/file-picker/file-picker.template.d.ts +2 -3
  85. package/lib/header/definition.d.ts +1 -3
  86. package/lib/header/header.d.ts +2 -2
  87. package/lib/header/header.template.d.ts +2 -3
  88. package/lib/icon/definition.d.ts +1 -3
  89. package/lib/icon/icon.d.ts +2 -2
  90. package/lib/icon/icon.template.d.ts +1 -3
  91. package/lib/layout/definition.d.ts +1 -3
  92. package/lib/layout/layout.d.ts +2 -2
  93. package/lib/layout/layout.template.d.ts +1 -3
  94. package/lib/listbox/definition.d.ts +1 -3
  95. package/lib/listbox/listbox.template.d.ts +1 -3
  96. package/lib/menu/definition.d.ts +1 -11
  97. package/lib/menu/menu.d.ts +2 -2
  98. package/lib/menu/menu.template.d.ts +3 -3
  99. package/lib/menu-item/definition.d.ts +1 -3
  100. package/lib/menu-item/menu-item.d.ts +2 -2
  101. package/lib/menu-item/menu-item.template.d.ts +2 -3
  102. package/lib/nav/definition.d.ts +1 -3
  103. package/lib/nav/nav.d.ts +2 -2
  104. package/lib/nav/nav.template.d.ts +1 -3
  105. package/lib/nav-disclosure/definition.d.ts +1 -3
  106. package/lib/nav-disclosure/nav-disclosure.d.ts +2 -2
  107. package/lib/nav-disclosure/nav-disclosure.template.d.ts +2 -3
  108. package/lib/nav-item/definition.d.ts +1 -3
  109. package/lib/nav-item/nav-item.template.d.ts +2 -3
  110. package/lib/note/definition.d.ts +1 -3
  111. package/lib/note/note.d.ts +2 -2
  112. package/lib/note/note.template.d.ts +2 -3
  113. package/lib/number-field/definition.d.ts +1 -4
  114. package/lib/number-field/number-field.form-associated.d.ts +3 -2
  115. package/lib/number-field/number-field.template.d.ts +2 -3
  116. package/lib/option/definition.d.ts +1 -3
  117. package/lib/option/option.d.ts +3 -2
  118. package/lib/option/option.template.d.ts +2 -3
  119. package/lib/pagination/definition.d.ts +1 -3
  120. package/lib/pagination/pagination.d.ts +2 -2
  121. package/lib/pagination/pagination.template.d.ts +2 -3
  122. package/lib/popup/definition.d.ts +1 -3
  123. package/lib/popup/popup.template.d.ts +2 -3
  124. package/lib/progress/definition.d.ts +1 -3
  125. package/lib/progress/progress.d.ts +1 -1
  126. package/lib/progress/progress.template.d.ts +1 -4
  127. package/lib/progress-ring/definition.d.ts +1 -3
  128. package/lib/progress-ring/progress-ring.d.ts +1 -1
  129. package/lib/progress-ring/progress-ring.template.d.ts +1 -3
  130. package/lib/radio/definition.d.ts +1 -3
  131. package/lib/radio/radio.form-associated.d.ts +5 -2
  132. package/lib/radio/radio.template.d.ts +1 -3
  133. package/lib/radio-group/definition.d.ts +1 -11
  134. package/lib/radio-group/radio-group.d.ts +2 -2
  135. package/lib/radio-group/radio-group.template.d.ts +2 -3
  136. package/lib/range-slider/definition.d.ts +1 -3
  137. package/lib/range-slider/range-slider.form-associated.d.ts +3 -2
  138. package/lib/range-slider/range-slider.template.d.ts +2 -3
  139. package/lib/searchable-select/definition.d.ts +1 -4
  140. package/lib/searchable-select/option-tag.template.d.ts +2 -3
  141. package/lib/searchable-select/searchable-select.form-associated.d.ts +3 -2
  142. package/lib/searchable-select/searchable-select.template.d.ts +2 -3
  143. package/lib/select/definition.d.ts +1 -3
  144. package/lib/select/select.d.ts +14 -4
  145. package/lib/select/select.form-associated.d.ts +11 -0
  146. package/lib/select/select.template.d.ts +2 -3
  147. package/lib/selectable-box/definition.d.ts +1 -3
  148. package/lib/selectable-box/selectable-box.d.ts +2 -2
  149. package/lib/selectable-box/selectable-box.template.d.ts +2 -3
  150. package/lib/side-drawer/definition.d.ts +1 -3
  151. package/lib/side-drawer/side-drawer.d.ts +2 -2
  152. package/lib/side-drawer/side-drawer.template.d.ts +1 -3
  153. package/lib/slider/definition.d.ts +1 -3
  154. package/lib/slider/slider.form-associated.d.ts +3 -2
  155. package/lib/slider/slider.template.d.ts +3 -4
  156. package/lib/split-button/definition.d.ts +1 -1
  157. package/lib/split-button/split-button.d.ts +2 -2
  158. package/lib/split-button/split-button.template.d.ts +2 -3
  159. package/lib/switch/definition.d.ts +1 -3
  160. package/lib/switch/switch.form-associated.d.ts +3 -2
  161. package/lib/switch/switch.template.d.ts +1 -3
  162. package/lib/tab/definition.d.ts +1 -3
  163. package/lib/tab/tab.d.ts +2 -2
  164. package/lib/tab/tab.template.d.ts +2 -2
  165. package/lib/tab-panel/definition.d.ts +1 -3
  166. package/lib/tab-panel/tab-panel.d.ts +2 -2
  167. package/lib/tab-panel/tab-panel.template.d.ts +1 -1
  168. package/lib/tabs/definition.d.ts +1 -3
  169. package/lib/tabs/tabs.d.ts +3 -7
  170. package/lib/tabs/tabs.template.d.ts +1 -1
  171. package/lib/tag/definition.d.ts +1 -4
  172. package/lib/tag/tag.d.ts +2 -2
  173. package/lib/tag/tag.template.d.ts +2 -3
  174. package/lib/tag-group/definition.d.ts +1 -3
  175. package/lib/tag-group/tag-group.d.ts +2 -2
  176. package/lib/tag-group/tag-group.template.d.ts +1 -3
  177. package/lib/text-anchor/definition.d.ts +1 -3
  178. package/lib/text-anchor/text-anchor.d.ts +4 -3
  179. package/lib/text-anchor/text-anchor.template.d.ts +2 -3
  180. package/lib/text-area/definition.d.ts +1 -3
  181. package/lib/text-area/text-area.d.ts +1 -1
  182. package/lib/text-area/{text-field.form-associated.d.ts → text-area.form-associated.d.ts} +3 -2
  183. package/lib/text-area/text-area.template.d.ts +2 -3
  184. package/lib/text-field/definition.d.ts +1 -3
  185. package/lib/text-field/text-field.form-associated.d.ts +3 -2
  186. package/lib/text-field/text-field.template.d.ts +2 -3
  187. package/lib/time-picker/definition.d.ts +1 -3
  188. package/lib/time-picker/time-picker.form-associated.d.ts +3 -2
  189. package/lib/time-picker/time-picker.template.d.ts +2 -2
  190. package/lib/toggletip/definition.d.ts +1 -3
  191. package/lib/toggletip/toggletip.d.ts +2 -2
  192. package/lib/toggletip/toggletip.template.d.ts +2 -3
  193. package/lib/tooltip/definition.d.ts +1 -3
  194. package/lib/tooltip/tooltip.d.ts +2 -2
  195. package/lib/tooltip/tooltip.template.d.ts +2 -3
  196. package/lib/tree-item/definition.d.ts +1 -3
  197. package/lib/tree-item/tree-item.d.ts +11 -2
  198. package/lib/tree-item/tree-item.template.d.ts +3 -3
  199. package/lib/tree-view/definition.d.ts +1 -3
  200. package/lib/tree-view/tree-view.d.ts +16 -2
  201. package/lib/tree-view/tree-view.template.d.ts +1 -1
  202. package/lib/video-player/definition.d.ts +1 -3
  203. package/lib/video-player/video-player.d.ts +2 -2
  204. package/lib/video-player/video-player.template.d.ts +1 -3
  205. package/listbox/index.cjs +37 -39
  206. package/listbox/index.js +37 -39
  207. package/menu/index.cjs +1 -1
  208. package/menu/index.js +1 -1
  209. package/nav/index.cjs +1 -1
  210. package/nav/index.js +1 -1
  211. package/nav-disclosure/index.cjs +1 -1
  212. package/nav-disclosure/index.js +1 -1
  213. package/nav-item/index.cjs +1 -1
  214. package/nav-item/index.js +1 -1
  215. package/note/index.cjs +1 -1
  216. package/note/index.js +1 -1
  217. package/number-field/index.cjs +1 -1
  218. package/number-field/index.js +1 -1
  219. package/option/index.cjs +1 -1
  220. package/option/index.js +1 -1
  221. package/package.json +1 -1
  222. package/pagination/index.cjs +1 -1
  223. package/pagination/index.js +1 -1
  224. package/popup/index.cjs +1 -1
  225. package/popup/index.js +1 -1
  226. package/progress/index.cjs +1 -1
  227. package/progress/index.js +1 -1
  228. package/progress-ring/index.cjs +1 -1
  229. package/progress-ring/index.js +1 -1
  230. package/radio/index.cjs +1 -1
  231. package/radio/index.js +1 -1
  232. package/radio-group/index.cjs +1 -1
  233. package/radio-group/index.js +1 -1
  234. package/range-slider/index.cjs +1 -1
  235. package/range-slider/index.js +1 -1
  236. package/searchable-select/index.cjs +1 -1
  237. package/searchable-select/index.js +1 -1
  238. package/select/index.cjs +1 -1
  239. package/select/index.js +1 -1
  240. package/selectable-box/index.cjs +1 -1
  241. package/selectable-box/index.js +1 -1
  242. package/shared/affix.cjs +10 -10
  243. package/shared/affix.js +2 -2
  244. package/shared/anchor.cjs +59 -0
  245. package/shared/anchor.js +57 -0
  246. package/shared/anchored.cjs +6 -6
  247. package/shared/anchored.js +2 -2
  248. package/shared/apply-mixins.cjs +15 -17
  249. package/shared/apply-mixins.js +15 -17
  250. package/shared/apply-mixins2.cjs +25 -0
  251. package/shared/apply-mixins2.js +23 -0
  252. package/shared/applyMixinsWithObservables.cjs +4 -4
  253. package/shared/applyMixinsWithObservables.js +2 -2
  254. package/shared/aria-global.cjs +86 -67
  255. package/shared/aria-global.js +86 -67
  256. package/shared/aria-global2.cjs +68 -86
  257. package/shared/aria-global2.js +68 -86
  258. package/shared/base-progress.cjs +69 -63
  259. package/shared/base-progress.js +69 -63
  260. package/shared/breadcrumb-item.cjs +6 -58
  261. package/shared/breadcrumb-item.js +3 -55
  262. package/shared/button.cjs +177 -0
  263. package/shared/button.js +175 -0
  264. package/shared/calendar-event.cjs +9 -9
  265. package/shared/calendar-event.js +2 -2
  266. package/shared/children.cjs +2 -2
  267. package/shared/children.js +1 -1
  268. package/shared/date-picker/date-picker-base.form-associated.d.ts +3 -2
  269. package/shared/date-picker/date-picker-base.template.d.ts +2 -3
  270. package/shared/definition.cjs +25 -24
  271. package/shared/definition.js +16 -14
  272. package/shared/definition10.cjs +14 -12
  273. package/shared/definition10.js +14 -11
  274. package/shared/definition11.cjs +52 -248
  275. package/shared/definition11.js +24 -218
  276. package/shared/definition12.cjs +18 -14
  277. package/shared/definition12.js +17 -12
  278. package/shared/definition13.cjs +19 -19
  279. package/shared/definition13.js +10 -9
  280. package/shared/definition14.cjs +35 -38
  281. package/shared/definition14.js +15 -17
  282. package/shared/definition15.cjs +27 -26
  283. package/shared/definition15.js +16 -14
  284. package/shared/definition16.cjs +480 -612
  285. package/shared/definition16.js +473 -604
  286. package/shared/definition17.cjs +933 -1113
  287. package/shared/definition17.js +911 -1090
  288. package/shared/definition18.cjs +16 -20
  289. package/shared/definition18.js +19 -22
  290. package/shared/definition19.cjs +26 -30
  291. package/shared/definition19.js +21 -24
  292. package/shared/definition2.cjs +19 -22
  293. package/shared/definition2.js +20 -22
  294. package/shared/definition20.cjs +50 -52
  295. package/shared/definition20.js +34 -35
  296. package/shared/definition21.cjs +43 -47
  297. package/shared/definition21.js +19 -22
  298. package/shared/definition22.cjs +15 -13
  299. package/shared/definition22.js +14 -11
  300. package/shared/definition23.cjs +21 -20
  301. package/shared/definition23.js +14 -12
  302. package/shared/definition24.cjs +21 -173
  303. package/shared/definition24.js +18 -169
  304. package/shared/definition25.cjs +26 -28
  305. package/shared/definition25.js +18 -19
  306. package/shared/definition26.cjs +16 -14
  307. package/shared/definition26.js +14 -11
  308. package/shared/definition27.cjs +264 -12
  309. package/shared/definition27.js +261 -10
  310. package/shared/definition28.cjs +19 -17
  311. package/shared/definition28.js +15 -12
  312. package/shared/definition29.cjs +142 -68
  313. package/shared/definition29.js +101 -29
  314. package/shared/definition3.cjs +20 -16
  315. package/shared/definition3.js +16 -11
  316. package/shared/definition30.cjs +98 -76
  317. package/shared/definition30.js +97 -74
  318. package/shared/definition31.cjs +24 -97
  319. package/shared/definition31.js +25 -97
  320. package/shared/definition32.cjs +9 -25
  321. package/shared/definition32.js +8 -23
  322. package/shared/definition33.cjs +52 -14
  323. package/shared/definition33.js +51 -12
  324. package/shared/definition34.cjs +639 -34
  325. package/shared/definition34.js +636 -30
  326. package/shared/definition35.cjs +203 -596
  327. package/shared/definition35.js +197 -591
  328. package/shared/definition36.cjs +197 -233
  329. package/shared/definition36.js +192 -226
  330. package/shared/definition37.cjs +79 -206
  331. package/shared/definition37.js +75 -202
  332. package/shared/definition38.cjs +50 -56
  333. package/shared/definition38.js +48 -52
  334. package/shared/definition39.cjs +259 -56
  335. package/shared/definition39.js +258 -54
  336. package/shared/definition4.cjs +32 -35
  337. package/shared/definition4.js +19 -21
  338. package/shared/definition40.cjs +156 -225
  339. package/shared/definition40.js +152 -221
  340. package/shared/definition41.cjs +626 -36
  341. package/shared/definition41.js +625 -34
  342. package/shared/definition42.cjs +974 -487
  343. package/shared/definition42.js +971 -482
  344. package/shared/definition43.cjs +725 -932
  345. package/shared/definition43.js +713 -918
  346. package/shared/definition44.cjs +115 -734
  347. package/shared/definition44.js +113 -731
  348. package/shared/definition45.cjs +92 -116
  349. package/shared/definition45.js +92 -115
  350. package/shared/definition46.cjs +468 -89
  351. package/shared/definition46.js +465 -86
  352. package/shared/definition47.cjs +118 -470
  353. package/shared/definition47.js +115 -465
  354. package/shared/definition48.cjs +113 -120
  355. package/shared/definition48.js +111 -117
  356. package/shared/definition49.cjs +16 -134
  357. package/shared/definition49.js +15 -132
  358. package/shared/definition5.cjs +47 -49
  359. package/shared/definition5.js +18 -19
  360. package/shared/definition50.cjs +111 -15
  361. package/shared/definition50.js +109 -12
  362. package/shared/definition51.cjs +862 -84
  363. package/shared/definition51.js +858 -79
  364. package/shared/definition52.cjs +30 -873
  365. package/shared/definition52.js +28 -870
  366. package/shared/definition53.cjs +125 -28
  367. package/shared/definition53.js +123 -25
  368. package/shared/definition54.cjs +267 -107
  369. package/shared/definition54.js +261 -100
  370. package/shared/definition55.cjs +63 -278
  371. package/shared/definition55.js +61 -275
  372. package/shared/definition56.cjs +867 -76
  373. package/shared/definition56.js +866 -74
  374. package/shared/definition57.cjs +107 -826
  375. package/shared/definition57.js +105 -823
  376. package/shared/definition58.cjs +73 -100
  377. package/shared/definition58.js +69 -95
  378. package/shared/definition59.cjs +180 -106
  379. package/shared/definition59.js +174 -101
  380. package/shared/definition6.cjs +22 -21
  381. package/shared/definition6.js +14 -12
  382. package/shared/definition60.cjs +272 -70
  383. package/shared/definition60.js +272 -69
  384. package/shared/definition61.cjs +66154 -271
  385. package/shared/definition61.js +66153 -269
  386. package/shared/definition62.cjs +38 -66173
  387. package/shared/definition62.js +35 -66170
  388. package/shared/definition63.cjs +2153 -27
  389. package/shared/definition63.js +2150 -25
  390. package/shared/definition7.cjs +18 -15
  391. package/shared/definition7.js +13 -10
  392. package/shared/definition8.cjs +25 -27
  393. package/shared/definition8.js +16 -17
  394. package/shared/definition9.cjs +21 -21
  395. package/shared/definition9.js +18 -17
  396. package/shared/design-system/createRegisterFunction.d.ts +2 -0
  397. package/shared/design-system/defineVividComponent.d.ts +15 -0
  398. package/shared/{localization.js → direction.js} +11 -11
  399. package/shared/dom.cjs +0 -13
  400. package/shared/dom.js +1 -13
  401. package/shared/form-associated.cjs +422 -457
  402. package/shared/form-associated.js +422 -457
  403. package/shared/form-associated2.cjs +383 -0
  404. package/shared/form-associated2.js +381 -0
  405. package/shared/form-elements.cjs +15 -42
  406. package/shared/form-elements.js +2 -29
  407. package/shared/foundation/anchor/anchor.d.ts +1 -0
  408. package/shared/foundation/button/button.d.ts +3 -2
  409. package/shared/foundation/button/button.template.d.ts +2 -4
  410. package/shared/foundation/form-associated/form-associated.d.ts +51 -0
  411. package/shared/foundation/listbox/listbox.d.ts +22 -0
  412. package/shared/foundation/progress/base-progress.d.ts +9 -0
  413. package/shared/foundation/utilities/apply-mixins.d.ts +1 -0
  414. package/shared/foundation/vivid-element/vivid-element.d.ts +3 -0
  415. package/shared/index.cjs +7 -5097
  416. package/shared/index.js +7 -5079
  417. package/shared/key-codes.cjs +10 -0
  418. package/shared/key-codes.js +6 -1
  419. package/shared/key-codes2.cjs +1463 -6
  420. package/shared/key-codes2.js +1461 -4
  421. package/shared/listbox.cjs +427 -1195
  422. package/shared/listbox.js +411 -1176
  423. package/shared/listbox2.cjs +1267 -0
  424. package/shared/listbox2.js +1264 -0
  425. package/shared/localized.cjs +2 -2
  426. package/shared/localized.js +1 -1
  427. package/shared/numbers.cjs +12 -0
  428. package/shared/numbers.js +12 -1
  429. package/shared/patterns/affix.d.ts +2 -2
  430. package/shared/patterns/chevron.d.ts +2 -2
  431. package/shared/patterns/form-elements/form-elements.d.ts +2 -2
  432. package/shared/presentationDate.cjs +49 -49
  433. package/shared/presentationDate.js +6 -6
  434. package/shared/ref.cjs +2 -2
  435. package/shared/ref.js +1 -1
  436. package/shared/repeat.cjs +22 -22
  437. package/shared/repeat.js +1 -1
  438. package/shared/slider.template.cjs +5 -5
  439. package/shared/slider.template.js +2 -2
  440. package/shared/slotted.cjs +4 -4
  441. package/shared/slotted.js +1 -1
  442. package/shared/strings.cjs +0 -26
  443. package/shared/strings.js +1 -25
  444. package/shared/strings2.cjs +37 -0
  445. package/shared/strings2.js +33 -0
  446. package/shared/text-anchor.cjs +7 -89
  447. package/shared/text-anchor.js +4 -86
  448. package/shared/text-anchor.template.cjs +2 -2
  449. package/shared/text-anchor.template.js +1 -1
  450. package/shared/text-field2.cjs +28 -28
  451. package/shared/text-field2.js +5 -5
  452. package/shared/vivid-element.cjs +2616 -0
  453. package/shared/vivid-element.js +2595 -0
  454. package/side-drawer/index.cjs +1 -1
  455. package/side-drawer/index.js +1 -1
  456. package/slider/index.cjs +1 -1
  457. package/slider/index.js +1 -1
  458. package/split-button/index.cjs +1 -1
  459. package/split-button/index.js +1 -1
  460. package/styles/core/all.css +40 -1
  461. package/styles/core/theme.css +40 -1
  462. package/styles/core/typography.css +1 -1
  463. package/styles/tokens/theme-dark.css +25 -4
  464. package/styles/tokens/theme-light.css +25 -4
  465. package/styles/tokens/vivid-2-compat.css +1 -1
  466. package/switch/index.cjs +1 -1
  467. package/switch/index.js +1 -1
  468. package/tab/index.cjs +1 -1
  469. package/tab/index.js +1 -1
  470. package/tab-panel/index.cjs +1 -1
  471. package/tab-panel/index.js +1 -1
  472. package/tabs/index.cjs +1 -1
  473. package/tabs/index.js +1 -1
  474. package/tag/index.cjs +1 -1
  475. package/tag/index.js +1 -1
  476. package/tag-group/index.cjs +1 -1
  477. package/tag-group/index.js +1 -1
  478. package/text-anchor/index.cjs +10 -7
  479. package/text-anchor/index.js +10 -7
  480. package/text-area/index.cjs +1 -1
  481. package/text-area/index.js +1 -1
  482. package/text-field/index.cjs +1 -1
  483. package/text-field/index.js +1 -1
  484. package/time-picker/index.cjs +1 -1
  485. package/time-picker/index.js +1 -1
  486. package/toggletip/index.cjs +1 -1
  487. package/toggletip/index.js +1 -1
  488. package/tooltip/index.cjs +1 -1
  489. package/tooltip/index.js +1 -1
  490. package/tree-item/index.cjs +1 -1
  491. package/tree-item/index.js +1 -1
  492. package/tree-view/index.cjs +1 -1
  493. package/tree-view/index.js +1 -1
  494. package/video-player/index.cjs +1 -1
  495. package/video-player/index.js +1 -1
  496. package/vivid.api.json +2846 -7860
  497. package/shared/definition64.cjs +0 -2175
  498. package/shared/definition64.js +0 -2170
  499. package/shared/design-system/index.d.ts +0 -3
  500. package/shared/icon.cjs +0 -261
  501. package/shared/icon.js +0 -258
  502. package/shared/index2.cjs +0 -11
  503. package/shared/index2.js +0 -9
  504. package/shared/radio.cjs +0 -126
  505. package/shared/radio.js +0 -124
  506. package/shared/select.options.cjs +0 -12
  507. package/shared/select.options.js +0 -10
  508. package/shared/start-end.cjs +0 -52
  509. package/shared/start-end.js +0 -50
  510. package/shared/tree-item.cjs +0 -154
  511. package/shared/tree-item.js +0 -151
  512. package/shared/{localization.cjs → direction.cjs} +9 -9
@@ -1,12 +1,10 @@
1
- import { a as iconRegistries } from './definition27.js';
2
- import { F as FoundationElement, _ as __decorate, a as attr, o as observable, D as DOM, h as html, O as Observable, r as registerFactory } from './index.js';
3
- import { d as keyEnd, g as keyHome, h as keyArrowRight, i as keyArrowLeft, j as keyPageDown, l as keyPageUp, f as keyArrowDown, e as keyArrowUp, b as keyEscape, m as keyFunction2, k as keyEnter } from './key-codes2.js';
1
+ import { I as Icon, i as iconDefinition } from './definition27.js';
2
+ import { a as attr, o as observable, V as VividElement, D as DOM, O as Observable, h as html, d as defineVividComponent, f as createRegisterFunction } from './vivid-element.js';
3
+ import { d as keyEnd, g as keyHome, j as keyPageDown, l as keyPageUp, f as keyArrowDown, e as keyArrowUp, i as keyArrowRight, h as keyArrowLeft, b as keyEscape, m as keyFunction2, k as keyEnter, a as keySpace } from './key-codes.js';
4
4
  import { R as RepeatDirective } from './repeat.js';
5
5
  import { s as slotted, e as elements } from './slotted.js';
6
6
  import { c as children } from './children.js';
7
- import { I as Icon } from './icon.js';
8
7
  import { w as when } from './when.js';
9
- import { g as keyEnter$1, k as keySpace } from './key-codes.js';
10
8
 
11
9
  /**
12
10
  * This set of exported strings reference https://developer.mozilla.org/en-US/docs/Web/Events
@@ -17,896 +15,6 @@ const eventFocusIn = "focusin";
17
15
  const eventFocusOut = "focusout";
18
16
  const eventKeyDown = "keydown";
19
17
 
20
- /**
21
- * Enumerates the data grid auto generated header options
22
- * default option generates a non-sticky header row
23
- *
24
- * @public
25
- */
26
- const GenerateHeaderOptions$1 = {
27
- none: "none",
28
- default: "default",
29
- sticky: "sticky",
30
- };
31
- /**
32
- * Enumerates possible data grid cell types.
33
- *
34
- * @public
35
- */
36
- const DataGridCellTypes = {
37
- default: "default",
38
- columnHeader: "columnheader",
39
- rowHeader: "rowheader",
40
- };
41
- /**
42
- * Enumerates possible data grid row types
43
- *
44
- * @public
45
- */
46
- const DataGridRowTypes$1 = {
47
- default: "default",
48
- header: "header",
49
- stickyHeader: "sticky-header",
50
- };
51
-
52
- /**
53
- * A Data Grid Row Custom HTML Element.
54
- *
55
- * @fires row-focused - Fires a custom 'row-focused' event when focus is on an element (usually a cell or its contents) in the row
56
- * @slot - The default slot for custom cell elements
57
- * @public
58
- */
59
- let DataGridRow$1 = class DataGridRow extends FoundationElement {
60
- constructor() {
61
- super(...arguments);
62
- /**
63
- * The type of row
64
- *
65
- * @public
66
- * @remarks
67
- * HTML Attribute: row-type
68
- */
69
- this.rowType = DataGridRowTypes$1.default;
70
- /**
71
- * The base data for this row
72
- *
73
- * @public
74
- */
75
- this.rowData = null;
76
- /**
77
- * The column definitions of the row
78
- *
79
- * @public
80
- */
81
- this.columnDefinitions = null;
82
- /**
83
- * Whether focus is on/in a cell within this row.
84
- *
85
- * @internal
86
- */
87
- this.isActiveRow = false;
88
- this.cellsRepeatBehavior = null;
89
- this.cellsPlaceholder = null;
90
- /**
91
- * @internal
92
- */
93
- this.focusColumnIndex = 0;
94
- this.refocusOnLoad = false;
95
- this.updateRowStyle = () => {
96
- this.style.gridTemplateColumns = this.gridTemplateColumns;
97
- };
98
- }
99
- gridTemplateColumnsChanged() {
100
- if (this.$fastController.isConnected) {
101
- this.updateRowStyle();
102
- }
103
- }
104
- rowTypeChanged() {
105
- if (this.$fastController.isConnected) {
106
- this.updateItemTemplate();
107
- }
108
- }
109
- rowDataChanged() {
110
- if (this.rowData !== null && this.isActiveRow) {
111
- this.refocusOnLoad = true;
112
- return;
113
- }
114
- }
115
- cellItemTemplateChanged() {
116
- this.updateItemTemplate();
117
- }
118
- headerCellItemTemplateChanged() {
119
- this.updateItemTemplate();
120
- }
121
- /**
122
- * @internal
123
- */
124
- connectedCallback() {
125
- super.connectedCallback();
126
- // note that row elements can be reused with a different data object
127
- // as the parent grid's repeat behavior reacts to changes in the data set.
128
- if (this.cellsRepeatBehavior === null) {
129
- this.cellsPlaceholder = document.createComment("");
130
- this.appendChild(this.cellsPlaceholder);
131
- this.updateItemTemplate();
132
- this.cellsRepeatBehavior = new RepeatDirective(x => x.columnDefinitions, x => x.activeCellItemTemplate, { positioning: true }).createBehavior(this.cellsPlaceholder);
133
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
134
- this.$fastController.addBehaviors([this.cellsRepeatBehavior]);
135
- }
136
- this.addEventListener("cell-focused", this.handleCellFocus);
137
- this.addEventListener(eventFocusOut, this.handleFocusout);
138
- this.addEventListener(eventKeyDown, this.handleKeydown);
139
- this.updateRowStyle();
140
- if (this.refocusOnLoad) {
141
- // if focus was on the row when data changed try to refocus on same cell
142
- this.refocusOnLoad = false;
143
- if (this.cellElements.length > this.focusColumnIndex) {
144
- this.cellElements[this.focusColumnIndex].focus();
145
- }
146
- }
147
- }
148
- /**
149
- * @internal
150
- */
151
- disconnectedCallback() {
152
- super.disconnectedCallback();
153
- this.removeEventListener("cell-focused", this.handleCellFocus);
154
- this.removeEventListener(eventFocusOut, this.handleFocusout);
155
- this.removeEventListener(eventKeyDown, this.handleKeydown);
156
- }
157
- handleFocusout(e) {
158
- if (!this.contains(e.target)) {
159
- this.isActiveRow = false;
160
- this.focusColumnIndex = 0;
161
- }
162
- }
163
- handleCellFocus(e) {
164
- this.isActiveRow = true;
165
- this.focusColumnIndex = this.cellElements.indexOf(e.target);
166
- this.$emit("row-focused", this);
167
- }
168
- handleKeydown(e) {
169
- if (e.defaultPrevented) {
170
- return;
171
- }
172
- let newFocusColumnIndex = 0;
173
- switch (e.key) {
174
- case keyArrowLeft:
175
- // focus left one cell
176
- newFocusColumnIndex = Math.max(0, this.focusColumnIndex - 1);
177
- this.cellElements[newFocusColumnIndex].focus();
178
- e.preventDefault();
179
- break;
180
- case keyArrowRight:
181
- // focus right one cell
182
- newFocusColumnIndex = Math.min(this.cellElements.length - 1, this.focusColumnIndex + 1);
183
- this.cellElements[newFocusColumnIndex].focus();
184
- e.preventDefault();
185
- break;
186
- case keyHome:
187
- if (!e.ctrlKey) {
188
- this.cellElements[0].focus();
189
- e.preventDefault();
190
- }
191
- break;
192
- case keyEnd:
193
- if (!e.ctrlKey) {
194
- // focus last cell of the row
195
- this.cellElements[this.cellElements.length - 1].focus();
196
- e.preventDefault();
197
- }
198
- break;
199
- }
200
- }
201
- updateItemTemplate() {
202
- this.activeCellItemTemplate =
203
- this.rowType === DataGridRowTypes$1.default &&
204
- this.cellItemTemplate !== undefined
205
- ? this.cellItemTemplate
206
- : this.rowType === DataGridRowTypes$1.default &&
207
- this.cellItemTemplate === undefined
208
- ? this.defaultCellItemTemplate
209
- : this.headerCellItemTemplate !== undefined
210
- ? this.headerCellItemTemplate
211
- : this.defaultHeaderCellItemTemplate;
212
- }
213
- };
214
- __decorate([
215
- attr({ attribute: "grid-template-columns" })
216
- ], DataGridRow$1.prototype, "gridTemplateColumns", void 0);
217
- __decorate([
218
- attr({ attribute: "row-type" })
219
- ], DataGridRow$1.prototype, "rowType", void 0);
220
- __decorate([
221
- observable
222
- ], DataGridRow$1.prototype, "rowData", void 0);
223
- __decorate([
224
- observable
225
- ], DataGridRow$1.prototype, "columnDefinitions", void 0);
226
- __decorate([
227
- observable
228
- ], DataGridRow$1.prototype, "cellItemTemplate", void 0);
229
- __decorate([
230
- observable
231
- ], DataGridRow$1.prototype, "headerCellItemTemplate", void 0);
232
- __decorate([
233
- observable
234
- ], DataGridRow$1.prototype, "rowIndex", void 0);
235
- __decorate([
236
- observable
237
- ], DataGridRow$1.prototype, "isActiveRow", void 0);
238
- __decorate([
239
- observable
240
- ], DataGridRow$1.prototype, "activeCellItemTemplate", void 0);
241
- __decorate([
242
- observable
243
- ], DataGridRow$1.prototype, "defaultCellItemTemplate", void 0);
244
- __decorate([
245
- observable
246
- ], DataGridRow$1.prototype, "defaultHeaderCellItemTemplate", void 0);
247
- __decorate([
248
- observable
249
- ], DataGridRow$1.prototype, "cellElements", void 0);
250
-
251
- /**
252
- * A Data Grid Custom HTML Element.
253
- *
254
- * @slot - The default slot for custom row elements
255
- * @public
256
- */
257
- let DataGrid$1 = class DataGrid extends FoundationElement {
258
- constructor() {
259
- super();
260
- /**
261
- * When true the component will not add itself to the tab queue.
262
- * Default is false.
263
- *
264
- * @public
265
- * @remarks
266
- * HTML Attribute: no-tabbing
267
- */
268
- this.noTabbing = false;
269
- /**
270
- * Whether the grid should automatically generate a header row and its type
271
- *
272
- * @public
273
- * @remarks
274
- * HTML Attribute: generate-header
275
- */
276
- this.generateHeader = GenerateHeaderOptions$1.default;
277
- /**
278
- * The data being displayed in the grid
279
- *
280
- * @public
281
- */
282
- this.rowsData = [];
283
- /**
284
- * The column definitions of the grid
285
- *
286
- * @public
287
- */
288
- this.columnDefinitions = null;
289
- /**
290
- * The index of the row that will receive focus the next time the
291
- * grid is focused. This value changes as focus moves to different
292
- * rows within the grid. Changing this value when focus is already
293
- * within the grid moves focus to the specified row.
294
- *
295
- * @public
296
- */
297
- this.focusRowIndex = 0;
298
- /**
299
- * The index of the column that will receive focus the next time the
300
- * grid is focused. This value changes as focus moves to different rows
301
- * within the grid. Changing this value when focus is already within
302
- * the grid moves focus to the specified column.
303
- *
304
- * @public
305
- */
306
- this.focusColumnIndex = 0;
307
- this.rowsPlaceholder = null;
308
- this.generatedHeader = null;
309
- this.isUpdatingFocus = false;
310
- this.pendingFocusUpdate = false;
311
- this.rowindexUpdateQueued = false;
312
- this.columnDefinitionsStale = true;
313
- this.generatedGridTemplateColumns = "";
314
- this.focusOnCell = (rowIndex, columnIndex, scrollIntoView) => {
315
- if (this.rowElements.length === 0) {
316
- this.focusRowIndex = 0;
317
- this.focusColumnIndex = 0;
318
- return;
319
- }
320
- const focusRowIndex = Math.max(0, Math.min(this.rowElements.length - 1, rowIndex));
321
- const focusRow = this.rowElements[focusRowIndex];
322
- const cells = focusRow.querySelectorAll('[role="cell"], [role="gridcell"], [role="columnheader"], [role="rowheader"]');
323
- const focusColumnIndex = Math.max(0, Math.min(cells.length - 1, columnIndex));
324
- const focusTarget = cells[focusColumnIndex];
325
- if (scrollIntoView &&
326
- this.scrollHeight !== this.clientHeight &&
327
- ((focusRowIndex < this.focusRowIndex && this.scrollTop > 0) ||
328
- (focusRowIndex > this.focusRowIndex &&
329
- this.scrollTop < this.scrollHeight - this.clientHeight))) {
330
- focusTarget.scrollIntoView({ block: "center", inline: "center" });
331
- }
332
- focusTarget.focus();
333
- };
334
- this.onChildListChange = (mutations,
335
- /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
336
- observer) => {
337
- if (mutations && mutations.length) {
338
- mutations.forEach((mutation) => {
339
- mutation.addedNodes.forEach((newNode) => {
340
- if (newNode.nodeType === 1 &&
341
- newNode.getAttribute("role") === "row") {
342
- newNode.columnDefinitions = this.columnDefinitions;
343
- }
344
- });
345
- });
346
- this.queueRowIndexUpdate();
347
- }
348
- };
349
- this.queueRowIndexUpdate = () => {
350
- if (!this.rowindexUpdateQueued) {
351
- this.rowindexUpdateQueued = true;
352
- DOM.queueUpdate(this.updateRowIndexes);
353
- }
354
- };
355
- this.updateRowIndexes = () => {
356
- let newGridTemplateColumns = this.gridTemplateColumns;
357
- if (newGridTemplateColumns === undefined) {
358
- // try to generate columns based on manual rows
359
- if (this.generatedGridTemplateColumns === "" && this.rowElements.length > 0) {
360
- const firstRow = this.rowElements[0];
361
- this.generatedGridTemplateColumns = new Array(firstRow.cellElements.length)
362
- .fill("1fr")
363
- .join(" ");
364
- }
365
- newGridTemplateColumns = this.generatedGridTemplateColumns;
366
- }
367
- this.rowElements.forEach((element, index) => {
368
- const thisRow = element;
369
- thisRow.rowIndex = index;
370
- thisRow.gridTemplateColumns = newGridTemplateColumns;
371
- if (this.columnDefinitionsStale) {
372
- thisRow.columnDefinitions = this.columnDefinitions;
373
- }
374
- });
375
- this.rowindexUpdateQueued = false;
376
- this.columnDefinitionsStale = false;
377
- };
378
- }
379
- /**
380
- * generates a gridTemplateColumns based on columndata array
381
- */
382
- static generateTemplateColumns(columnDefinitions) {
383
- let templateColumns = "";
384
- columnDefinitions.forEach((column) => {
385
- templateColumns = `${templateColumns}${templateColumns === "" ? "" : " "}${"1fr"}`;
386
- });
387
- return templateColumns;
388
- }
389
- noTabbingChanged() {
390
- if (this.$fastController.isConnected) {
391
- if (this.noTabbing) {
392
- this.setAttribute("tabIndex", "-1");
393
- }
394
- else {
395
- this.setAttribute("tabIndex", this.contains(document.activeElement) ||
396
- this === document.activeElement
397
- ? "-1"
398
- : "0");
399
- }
400
- }
401
- }
402
- generateHeaderChanged() {
403
- if (this.$fastController.isConnected) {
404
- this.toggleGeneratedHeader();
405
- }
406
- }
407
- gridTemplateColumnsChanged() {
408
- if (this.$fastController.isConnected) {
409
- this.updateRowIndexes();
410
- }
411
- }
412
- rowsDataChanged() {
413
- if (this.columnDefinitions === null && this.rowsData.length > 0) {
414
- this.columnDefinitions = DataGrid.generateColumns(this.rowsData[0]);
415
- }
416
- if (this.$fastController.isConnected) {
417
- this.toggleGeneratedHeader();
418
- }
419
- }
420
- columnDefinitionsChanged() {
421
- if (this.columnDefinitions === null) {
422
- this.generatedGridTemplateColumns = "";
423
- return;
424
- }
425
- this.generatedGridTemplateColumns = DataGrid.generateTemplateColumns(this.columnDefinitions);
426
- if (this.$fastController.isConnected) {
427
- this.columnDefinitionsStale = true;
428
- this.queueRowIndexUpdate();
429
- }
430
- }
431
- headerCellItemTemplateChanged() {
432
- if (this.$fastController.isConnected) {
433
- if (this.generatedHeader !== null) {
434
- this.generatedHeader.headerCellItemTemplate = this.headerCellItemTemplate;
435
- }
436
- }
437
- }
438
- focusRowIndexChanged() {
439
- if (this.$fastController.isConnected) {
440
- this.queueFocusUpdate();
441
- }
442
- }
443
- focusColumnIndexChanged() {
444
- if (this.$fastController.isConnected) {
445
- this.queueFocusUpdate();
446
- }
447
- }
448
- /**
449
- * @internal
450
- */
451
- connectedCallback() {
452
- super.connectedCallback();
453
- if (this.rowItemTemplate === undefined) {
454
- this.rowItemTemplate = this.defaultRowItemTemplate;
455
- }
456
- this.rowsPlaceholder = document.createComment("");
457
- this.appendChild(this.rowsPlaceholder);
458
- this.toggleGeneratedHeader();
459
- this.rowsRepeatBehavior = new RepeatDirective(x => x.rowsData, x => x.rowItemTemplate, { positioning: true }).createBehavior(this.rowsPlaceholder);
460
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
461
- this.$fastController.addBehaviors([this.rowsRepeatBehavior]);
462
- this.addEventListener("row-focused", this.handleRowFocus);
463
- this.addEventListener(eventFocus, this.handleFocus);
464
- this.addEventListener(eventKeyDown, this.handleKeydown);
465
- this.addEventListener(eventFocusOut, this.handleFocusOut);
466
- this.observer = new MutationObserver(this.onChildListChange);
467
- // only observe if nodes are added or removed
468
- this.observer.observe(this, { childList: true });
469
- if (this.noTabbing) {
470
- this.setAttribute("tabindex", "-1");
471
- }
472
- DOM.queueUpdate(this.queueRowIndexUpdate);
473
- }
474
- /**
475
- * @internal
476
- */
477
- disconnectedCallback() {
478
- super.disconnectedCallback();
479
- this.removeEventListener("row-focused", this.handleRowFocus);
480
- this.removeEventListener(eventFocus, this.handleFocus);
481
- this.removeEventListener(eventKeyDown, this.handleKeydown);
482
- this.removeEventListener(eventFocusOut, this.handleFocusOut);
483
- // disconnect observer
484
- this.observer.disconnect();
485
- this.rowsPlaceholder = null;
486
- this.generatedHeader = null;
487
- }
488
- /**
489
- * @internal
490
- */
491
- handleRowFocus(e) {
492
- this.isUpdatingFocus = true;
493
- const focusRow = e.target;
494
- this.focusRowIndex = this.rowElements.indexOf(focusRow);
495
- this.focusColumnIndex = focusRow.focusColumnIndex;
496
- this.setAttribute("tabIndex", "-1");
497
- this.isUpdatingFocus = false;
498
- }
499
- /**
500
- * @internal
501
- */
502
- handleFocus(e) {
503
- this.focusOnCell(this.focusRowIndex, this.focusColumnIndex, true);
504
- }
505
- /**
506
- * @internal
507
- */
508
- handleFocusOut(e) {
509
- if (e.relatedTarget === null || !this.contains(e.relatedTarget)) {
510
- this.setAttribute("tabIndex", this.noTabbing ? "-1" : "0");
511
- }
512
- }
513
- /**
514
- * @internal
515
- */
516
- handleKeydown(e) {
517
- if (e.defaultPrevented) {
518
- return;
519
- }
520
- let newFocusRowIndex;
521
- const maxIndex = this.rowElements.length - 1;
522
- const currentGridBottom = this.offsetHeight + this.scrollTop;
523
- const lastRow = this.rowElements[maxIndex];
524
- switch (e.key) {
525
- case keyArrowUp:
526
- e.preventDefault();
527
- // focus up one row
528
- this.focusOnCell(this.focusRowIndex - 1, this.focusColumnIndex, true);
529
- break;
530
- case keyArrowDown:
531
- e.preventDefault();
532
- // focus down one row
533
- this.focusOnCell(this.focusRowIndex + 1, this.focusColumnIndex, true);
534
- break;
535
- case keyPageUp:
536
- e.preventDefault();
537
- if (this.rowElements.length === 0) {
538
- this.focusOnCell(0, 0, false);
539
- break;
540
- }
541
- if (this.focusRowIndex === 0) {
542
- this.focusOnCell(0, this.focusColumnIndex, false);
543
- return;
544
- }
545
- newFocusRowIndex = this.focusRowIndex - 1;
546
- for (newFocusRowIndex; newFocusRowIndex >= 0; newFocusRowIndex--) {
547
- const thisRow = this.rowElements[newFocusRowIndex];
548
- if (thisRow.offsetTop < this.scrollTop) {
549
- this.scrollTop =
550
- thisRow.offsetTop + thisRow.clientHeight - this.clientHeight;
551
- break;
552
- }
553
- }
554
- this.focusOnCell(newFocusRowIndex, this.focusColumnIndex, false);
555
- break;
556
- case keyPageDown:
557
- e.preventDefault();
558
- if (this.rowElements.length === 0) {
559
- this.focusOnCell(0, 0, false);
560
- break;
561
- }
562
- // focus down one "page"
563
- if (this.focusRowIndex >= maxIndex ||
564
- lastRow.offsetTop + lastRow.offsetHeight <= currentGridBottom) {
565
- this.focusOnCell(maxIndex, this.focusColumnIndex, false);
566
- return;
567
- }
568
- newFocusRowIndex = this.focusRowIndex + 1;
569
- for (newFocusRowIndex; newFocusRowIndex <= maxIndex; newFocusRowIndex++) {
570
- const thisRow = this.rowElements[newFocusRowIndex];
571
- if (thisRow.offsetTop + thisRow.offsetHeight > currentGridBottom) {
572
- let stickyHeaderOffset = 0;
573
- if (this.generateHeader === GenerateHeaderOptions$1.sticky &&
574
- this.generatedHeader !== null) {
575
- stickyHeaderOffset = this.generatedHeader.clientHeight;
576
- }
577
- this.scrollTop = thisRow.offsetTop - stickyHeaderOffset;
578
- break;
579
- }
580
- }
581
- this.focusOnCell(newFocusRowIndex, this.focusColumnIndex, false);
582
- break;
583
- case keyHome:
584
- if (e.ctrlKey) {
585
- e.preventDefault();
586
- // focus first cell of first row
587
- this.focusOnCell(0, 0, true);
588
- }
589
- break;
590
- case keyEnd:
591
- if (e.ctrlKey && this.columnDefinitions !== null) {
592
- e.preventDefault();
593
- // focus last cell of last row
594
- this.focusOnCell(this.rowElements.length - 1, this.columnDefinitions.length - 1, true);
595
- }
596
- break;
597
- }
598
- }
599
- queueFocusUpdate() {
600
- if (this.isUpdatingFocus &&
601
- (this.contains(document.activeElement) || this === document.activeElement)) {
602
- return;
603
- }
604
- if (this.pendingFocusUpdate === false) {
605
- this.pendingFocusUpdate = true;
606
- DOM.queueUpdate(() => this.updateFocus());
607
- }
608
- }
609
- updateFocus() {
610
- this.pendingFocusUpdate = false;
611
- this.focusOnCell(this.focusRowIndex, this.focusColumnIndex, true);
612
- }
613
- toggleGeneratedHeader() {
614
- if (this.generatedHeader !== null) {
615
- this.removeChild(this.generatedHeader);
616
- this.generatedHeader = null;
617
- }
618
- if (this.generateHeader !== GenerateHeaderOptions$1.none &&
619
- this.rowsData.length > 0) {
620
- const generatedHeaderElement = document.createElement(this.rowElementTag);
621
- this.generatedHeader = generatedHeaderElement;
622
- this.generatedHeader.columnDefinitions = this.columnDefinitions;
623
- this.generatedHeader.gridTemplateColumns = this.gridTemplateColumns;
624
- this.generatedHeader.rowType =
625
- this.generateHeader === GenerateHeaderOptions$1.sticky
626
- ? DataGridRowTypes$1.stickyHeader
627
- : DataGridRowTypes$1.header;
628
- if (this.firstChild !== null || this.rowsPlaceholder !== null) {
629
- this.insertBefore(generatedHeaderElement, this.firstChild !== null ? this.firstChild : this.rowsPlaceholder);
630
- }
631
- return;
632
- }
633
- }
634
- };
635
- /**
636
- * generates a basic column definition by examining sample row data
637
- */
638
- DataGrid$1.generateColumns = (row) => {
639
- return Object.getOwnPropertyNames(row).map((property, index) => {
640
- return {
641
- columnDataKey: property,
642
- gridColumn: `${index}`,
643
- };
644
- });
645
- };
646
- __decorate([
647
- attr({ attribute: "no-tabbing", mode: "boolean" })
648
- ], DataGrid$1.prototype, "noTabbing", void 0);
649
- __decorate([
650
- attr({ attribute: "generate-header" })
651
- ], DataGrid$1.prototype, "generateHeader", void 0);
652
- __decorate([
653
- attr({ attribute: "grid-template-columns" })
654
- ], DataGrid$1.prototype, "gridTemplateColumns", void 0);
655
- __decorate([
656
- observable
657
- ], DataGrid$1.prototype, "rowsData", void 0);
658
- __decorate([
659
- observable
660
- ], DataGrid$1.prototype, "columnDefinitions", void 0);
661
- __decorate([
662
- observable
663
- ], DataGrid$1.prototype, "rowItemTemplate", void 0);
664
- __decorate([
665
- observable
666
- ], DataGrid$1.prototype, "cellItemTemplate", void 0);
667
- __decorate([
668
- observable
669
- ], DataGrid$1.prototype, "headerCellItemTemplate", void 0);
670
- __decorate([
671
- observable
672
- ], DataGrid$1.prototype, "focusRowIndex", void 0);
673
- __decorate([
674
- observable
675
- ], DataGrid$1.prototype, "focusColumnIndex", void 0);
676
- __decorate([
677
- observable
678
- ], DataGrid$1.prototype, "defaultRowItemTemplate", void 0);
679
- __decorate([
680
- observable
681
- ], DataGrid$1.prototype, "rowElementTag", void 0);
682
- __decorate([
683
- observable
684
- ], DataGrid$1.prototype, "rowElements", void 0);
685
-
686
- const defaultCellContentsTemplate = html `
687
- <template>
688
- ${x => x.rowData === null ||
689
- x.columnDefinition === null ||
690
- x.columnDefinition.columnDataKey === null
691
- ? null
692
- : x.rowData[x.columnDefinition.columnDataKey]}
693
- </template>
694
- `;
695
- const defaultHeaderCellContentsTemplate = html `
696
- <template>
697
- ${x => x.columnDefinition === null
698
- ? null
699
- : x.columnDefinition.title === undefined
700
- ? x.columnDefinition.columnDataKey
701
- : x.columnDefinition.title}
702
- </template>
703
- `;
704
- /**
705
- * A Data Grid Cell Custom HTML Element.
706
- *
707
- * @fires cell-focused - Fires a custom 'cell-focused' event when focus is on the cell or its contents
708
- * @slot - The default slot for cell contents. The "cell contents template" renders here.
709
- * @public
710
- */
711
- let DataGridCell$1 = class DataGridCell extends FoundationElement {
712
- constructor() {
713
- super(...arguments);
714
- /**
715
- * The type of cell
716
- *
717
- * @public
718
- * @remarks
719
- * HTML Attribute: cell-type
720
- */
721
- this.cellType = DataGridCellTypes.default;
722
- /**
723
- * The base data for the parent row
724
- *
725
- * @public
726
- */
727
- this.rowData = null;
728
- /**
729
- * The base data for the column
730
- *
731
- * @public
732
- */
733
- this.columnDefinition = null;
734
- this.isActiveCell = false;
735
- this.customCellView = null;
736
- this.updateCellStyle = () => {
737
- this.style.gridColumn = this.gridColumn;
738
- };
739
- }
740
- cellTypeChanged() {
741
- if (this.$fastController.isConnected) {
742
- this.updateCellView();
743
- }
744
- }
745
- gridColumnChanged() {
746
- if (this.$fastController.isConnected) {
747
- this.updateCellStyle();
748
- }
749
- }
750
- columnDefinitionChanged(oldValue, newValue) {
751
- if (this.$fastController.isConnected) {
752
- this.updateCellView();
753
- }
754
- }
755
- /**
756
- * @internal
757
- */
758
- connectedCallback() {
759
- var _a;
760
- super.connectedCallback();
761
- this.addEventListener(eventFocusIn, this.handleFocusin);
762
- this.addEventListener(eventFocusOut, this.handleFocusout);
763
- this.addEventListener(eventKeyDown, this.handleKeydown);
764
- this.style.gridColumn = `${((_a = this.columnDefinition) === null || _a === void 0 ? void 0 : _a.gridColumn) === undefined
765
- ? 0
766
- : this.columnDefinition.gridColumn}`;
767
- this.updateCellView();
768
- this.updateCellStyle();
769
- }
770
- /**
771
- * @internal
772
- */
773
- disconnectedCallback() {
774
- super.disconnectedCallback();
775
- this.removeEventListener(eventFocusIn, this.handleFocusin);
776
- this.removeEventListener(eventFocusOut, this.handleFocusout);
777
- this.removeEventListener(eventKeyDown, this.handleKeydown);
778
- this.disconnectCellView();
779
- }
780
- handleFocusin(e) {
781
- if (this.isActiveCell) {
782
- return;
783
- }
784
- this.isActiveCell = true;
785
- switch (this.cellType) {
786
- case DataGridCellTypes.columnHeader:
787
- if (this.columnDefinition !== null &&
788
- this.columnDefinition.headerCellInternalFocusQueue !== true &&
789
- typeof this.columnDefinition.headerCellFocusTargetCallback ===
790
- "function") {
791
- // move focus to the focus target
792
- const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
793
- if (focusTarget !== null) {
794
- focusTarget.focus();
795
- }
796
- }
797
- break;
798
- default:
799
- if (this.columnDefinition !== null &&
800
- this.columnDefinition.cellInternalFocusQueue !== true &&
801
- typeof this.columnDefinition.cellFocusTargetCallback === "function") {
802
- // move focus to the focus target
803
- const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
804
- if (focusTarget !== null) {
805
- focusTarget.focus();
806
- }
807
- }
808
- break;
809
- }
810
- this.$emit("cell-focused", this);
811
- }
812
- handleFocusout(e) {
813
- if (this !== document.activeElement && !this.contains(document.activeElement)) {
814
- this.isActiveCell = false;
815
- }
816
- }
817
- handleKeydown(e) {
818
- if (e.defaultPrevented ||
819
- this.columnDefinition === null ||
820
- (this.cellType === DataGridCellTypes.default &&
821
- this.columnDefinition.cellInternalFocusQueue !== true) ||
822
- (this.cellType === DataGridCellTypes.columnHeader &&
823
- this.columnDefinition.headerCellInternalFocusQueue !== true)) {
824
- return;
825
- }
826
- switch (e.key) {
827
- case keyEnter:
828
- case keyFunction2:
829
- if (this.contains(document.activeElement) &&
830
- document.activeElement !== this) {
831
- return;
832
- }
833
- switch (this.cellType) {
834
- case DataGridCellTypes.columnHeader:
835
- if (this.columnDefinition.headerCellFocusTargetCallback !==
836
- undefined) {
837
- const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
838
- if (focusTarget !== null) {
839
- focusTarget.focus();
840
- }
841
- e.preventDefault();
842
- }
843
- break;
844
- default:
845
- if (this.columnDefinition.cellFocusTargetCallback !== undefined) {
846
- const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
847
- if (focusTarget !== null) {
848
- focusTarget.focus();
849
- }
850
- e.preventDefault();
851
- }
852
- break;
853
- }
854
- break;
855
- case keyEscape:
856
- if (this.contains(document.activeElement) &&
857
- document.activeElement !== this) {
858
- this.focus();
859
- e.preventDefault();
860
- }
861
- break;
862
- }
863
- }
864
- updateCellView() {
865
- this.disconnectCellView();
866
- if (this.columnDefinition === null) {
867
- return;
868
- }
869
- switch (this.cellType) {
870
- case DataGridCellTypes.columnHeader:
871
- if (this.columnDefinition.headerCellTemplate !== undefined) {
872
- this.customCellView = this.columnDefinition.headerCellTemplate.render(this, this);
873
- }
874
- else {
875
- this.customCellView = defaultHeaderCellContentsTemplate.render(this, this);
876
- }
877
- break;
878
- case undefined:
879
- case DataGridCellTypes.rowHeader:
880
- case DataGridCellTypes.default:
881
- if (this.columnDefinition.cellTemplate !== undefined) {
882
- this.customCellView = this.columnDefinition.cellTemplate.render(this, this);
883
- }
884
- else {
885
- this.customCellView = defaultCellContentsTemplate.render(this, this);
886
- }
887
- break;
888
- }
889
- }
890
- disconnectCellView() {
891
- if (this.customCellView !== null) {
892
- this.customCellView.dispose();
893
- this.customCellView = null;
894
- }
895
- }
896
- };
897
- __decorate([
898
- attr({ attribute: "cell-type" })
899
- ], DataGridCell$1.prototype, "cellType", void 0);
900
- __decorate([
901
- attr({ attribute: "grid-column" })
902
- ], DataGridCell$1.prototype, "gridColumn", void 0);
903
- __decorate([
904
- observable
905
- ], DataGridCell$1.prototype, "rowData", void 0);
906
- __decorate([
907
- observable
908
- ], DataGridCell$1.prototype, "columnDefinition", void 0);
909
-
910
18
  const dataGridStyles = ":host{display:block}:host([generate-header=sticky]){max-block-size:400px}.base{--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.base{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.base ::-webkit-scrollbar{width:4px}.base ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.base ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-thumb-color)}.base{position:relative;overflow:auto;block-size:inherit;inline-size:100%;max-block-size:inherit}";
911
19
 
912
20
  const dataGridRowStyles = ".base.connotation-cta{--_connotation-color-primary: var(--vvd-data-grid-row-cta-primary, var(--vvd-color-cta-500));--_connotation-color-primary-text: var(--vvd-data-grid-row-cta-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-data-grid-row-cta-primary-increment, var(--vvd-color-cta-600));--_connotation-color-firm: var(--vvd-data-grid-row-cta-firm, var(--vvd-color-cta-600));--_connotation-color-faint: var(--vvd-data-grid-row-cta-faint, var(--vvd-color-cta-50));--_connotation-color-soft: var(--vvd-data-grid-row-cta-soft, var(--vvd-color-cta-100));--_connotation-color-pale: var(--vvd-data-grid-row-cta-pale, var(--vvd-color-cta-300));--_connotation-color-dim: var(--vvd-data-grid-row-cta-dim, var(--vvd-color-cta-200))}.base:not(.connotation-cta){--_connotation-color-primary: var(--vvd-data-grid-row-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-data-grid-row-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-data-grid-row-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-firm: var(--vvd-data-grid-row-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-faint: var(--vvd-data-grid-row-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-data-grid-row-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-pale: var(--vvd-data-grid-row-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-dim: var(--vvd-data-grid-row-accent-dim, var(--vvd-color-neutral-200))}.base{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.base{display:grid;width:100%;box-sizing:border-box;color:var(--vvd-color-canvas-text)}:host([row-type=sticky-header]) .base{position:sticky;z-index:9;top:0;background:var(--data-grid-row-background, var(--vvd-color-canvas))}:host([row-type=hidden-header]) .base{display:none}:host(:is([aria-selected]):not([row-type*=header])) .base{background-color:var(--_appearance-color-fill)}";
@@ -924,6 +32,11 @@ const GenerateHeaderOptions = {
924
32
  default: "default",
925
33
  sticky: "sticky"
926
34
  };
35
+ const DataGridCellTypes = {
36
+ default: "default",
37
+ columnHeader: "columnheader",
38
+ rowHeader: "rowheader"
39
+ };
927
40
  const DataGridRowTypes = {
928
41
  default: "default",
929
42
  header: "header",
@@ -951,7 +64,483 @@ const DataGridSelectionMode = {
951
64
  singleCell: "single-cell",
952
65
  multiCell: "multi-cell"
953
66
  };
954
- class DataGrid extends DataGrid$1 {
67
+ const _DataGrid = class _DataGrid extends VividElement {
68
+ constructor() {
69
+ super();
70
+ this.noTabbing = false;
71
+ // eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
72
+ this.generateHeader = GenerateHeaderOptions.default;
73
+ this.rowsData = [];
74
+ this.columnDefinitions = null;
75
+ this.focusRowIndex = 0;
76
+ this.focusColumnIndex = 0;
77
+ this.rowsRepeatBehavior = null;
78
+ this.rowsPlaceholder = null;
79
+ this.generatedHeader = null;
80
+ this.isUpdatingFocus = false;
81
+ this.pendingFocusUpdate = false;
82
+ this.rowindexUpdateQueued = false;
83
+ this.columnDefinitionsStale = true;
84
+ this.generatedGridTemplateColumns = "";
85
+ this.focusOnCell = (rowIndex, columnIndex, scrollIntoView) => {
86
+ if (this.rowElements.length === 0) {
87
+ this.focusRowIndex = 0;
88
+ this.focusColumnIndex = 0;
89
+ return;
90
+ }
91
+ const focusRowIndex = Math.max(
92
+ 0,
93
+ Math.min(this.rowElements.length - 1, rowIndex)
94
+ );
95
+ const focusRow = this.rowElements[focusRowIndex];
96
+ const cells = focusRow.querySelectorAll(
97
+ '[role="cell"], [role="gridcell"], [role="columnheader"], [role="rowheader"]'
98
+ );
99
+ const focusColumnIndex = Math.max(
100
+ 0,
101
+ Math.min(cells.length - 1, columnIndex)
102
+ );
103
+ const focusTarget = cells[focusColumnIndex];
104
+ if (scrollIntoView && this.scrollHeight !== this.clientHeight && (focusRowIndex < this.focusRowIndex && this.scrollTop > 0 || focusRowIndex > this.focusRowIndex && this.scrollTop < this.scrollHeight - this.clientHeight)) {
105
+ focusTarget.scrollIntoView({ block: "center", inline: "center" });
106
+ }
107
+ focusTarget.focus();
108
+ };
109
+ this.onChildListChange = (mutations, _) => {
110
+ if (mutations && mutations.length) {
111
+ mutations.forEach((mutation) => {
112
+ mutation.addedNodes.forEach((newNode) => {
113
+ if (newNode.nodeType === 1 && newNode.getAttribute("role") === "row") {
114
+ newNode.columnDefinitions = this.columnDefinitions;
115
+ }
116
+ });
117
+ });
118
+ this.queueRowIndexUpdate();
119
+ }
120
+ };
121
+ this.queueRowIndexUpdate = () => {
122
+ if (!this.rowindexUpdateQueued) {
123
+ this.rowindexUpdateQueued = true;
124
+ DOM.queueUpdate(this.updateRowIndexes);
125
+ }
126
+ };
127
+ this.updateRowIndexes = () => {
128
+ let newGridTemplateColumns = this.gridTemplateColumns;
129
+ if (newGridTemplateColumns === void 0) {
130
+ if (this.generatedGridTemplateColumns === "" && this.rowElements.length > 0) {
131
+ const firstRow = this.rowElements[0];
132
+ this.generatedGridTemplateColumns = new Array(
133
+ firstRow.cellElements.length
134
+ ).fill("1fr").join(" ");
135
+ }
136
+ newGridTemplateColumns = this.generatedGridTemplateColumns;
137
+ }
138
+ this.rowElements.forEach((element, index) => {
139
+ const thisRow = element;
140
+ thisRow.rowIndex = index;
141
+ thisRow.gridTemplateColumns = newGridTemplateColumns;
142
+ if (this.columnDefinitionsStale) {
143
+ thisRow.columnDefinitions = this.columnDefinitions;
144
+ }
145
+ });
146
+ this.rowindexUpdateQueued = false;
147
+ this.columnDefinitionsStale = false;
148
+ };
149
+ this.#handleKeypress = (e) => {
150
+ if (e.key === "Enter" || e.key === " ") {
151
+ this.#handleClick(e);
152
+ }
153
+ };
154
+ this.#handleClick = ({ target, ctrlKey, shiftKey, metaKey }) => {
155
+ if (target.getAttribute("role") !== "gridcell") return;
156
+ if (this.selectionMode === DataGridSelectionMode.singleCell || this.selectionMode === DataGridSelectionMode.multiCell) {
157
+ this.#handleCellSelection({ target, ctrlKey, shiftKey, metaKey });
158
+ return;
159
+ }
160
+ if (this.selectionMode === DataGridSelectionMode.singleRow || this.selectionMode === DataGridSelectionMode.multiRow) {
161
+ this.#handleRowSelection({ target, ctrlKey, shiftKey, metaKey });
162
+ }
163
+ };
164
+ this.#handleCellSelection = ({
165
+ target,
166
+ ctrlKey,
167
+ shiftKey,
168
+ metaKey
169
+ }) => {
170
+ const cell = target;
171
+ if (this.selectionMode === DataGridSelectionMode.multiCell && (ctrlKey || shiftKey || metaKey)) {
172
+ this.#setSelectedState(cell, !this.#selectedCells.includes(cell));
173
+ } else {
174
+ const cacheTargetSelection = cell.getAttribute("aria-selected") === "true";
175
+ this.#resetSelection();
176
+ this.#setSelectedState(cell, !cacheTargetSelection);
177
+ }
178
+ };
179
+ this.#handleRowSelection = ({
180
+ target,
181
+ ctrlKey,
182
+ shiftKey,
183
+ metaKey
184
+ }) => {
185
+ const row = target.parentNode;
186
+ if (this.selectionMode === DataGridSelectionMode.multiRow && (ctrlKey || shiftKey || metaKey)) {
187
+ this.#setSelectedState(row, !this.#selectedRows.includes(row));
188
+ } else {
189
+ const cacheTargetSelection = row.getAttribute("aria-selected") === "true";
190
+ this.#resetSelection();
191
+ this.#setSelectedState(row, !cacheTargetSelection);
192
+ }
193
+ };
194
+ this.#changeHandler = {
195
+ handleChange(dataGrid, propertyName) {
196
+ if (propertyName === "columnDefinitions") {
197
+ if (dataGrid.$fastController.isConnected) {
198
+ dataGrid.toggleGeneratedHeader();
199
+ }
200
+ }
201
+ }
202
+ };
203
+ this.#setSelectedState = (cell, selectedState) => {
204
+ cell.setAttribute("aria-selected", selectedState.toString());
205
+ };
206
+ this.#resetSelection = () => {
207
+ if (this.selectionMode === DataGridSelectionMode.singleCell || this.selectionMode === DataGridSelectionMode.multiCell) {
208
+ Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
209
+ (cell) => this.#setSelectedState(cell, false)
210
+ );
211
+ Array.from(this.querySelectorAll('[role="row"]')).forEach(
212
+ (row) => row.removeAttribute("aria-selected")
213
+ );
214
+ }
215
+ if (this.selectionMode === DataGridSelectionMode.none) {
216
+ Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
217
+ (cell) => cell.removeAttribute("aria-selected")
218
+ );
219
+ Array.from(this.querySelectorAll('[role="row"]')).forEach(
220
+ (row) => row.removeAttribute("aria-selected")
221
+ );
222
+ }
223
+ if (this.selectionMode === DataGridSelectionMode.singleRow || this.selectionMode === DataGridSelectionMode.multiRow) {
224
+ Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
225
+ (cell) => cell.removeAttribute("aria-selected")
226
+ );
227
+ Array.from(this.querySelectorAll('[role="row"]')).forEach(
228
+ (row) => row.setAttribute("aria-selected", "false")
229
+ );
230
+ }
231
+ };
232
+ this.#initSelections = () => {
233
+ if (this.selectionMode === DataGridSelectionMode.singleCell || this.selectionMode === DataGridSelectionMode.multiCell) {
234
+ Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
235
+ (cell) => !cell.hasAttribute("aria-selected") && this.#setSelectedState(cell, false)
236
+ );
237
+ Array.from(this.querySelectorAll('[role="row"]')).forEach(
238
+ (row) => row.removeAttribute("aria-selected")
239
+ );
240
+ }
241
+ if (this.selectionMode === DataGridSelectionMode.none) {
242
+ Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
243
+ (cell) => cell.removeAttribute("aria-selected")
244
+ );
245
+ Array.from(this.querySelectorAll('[role="row"]')).forEach(
246
+ (row) => row.removeAttribute("aria-selected")
247
+ );
248
+ }
249
+ if (this.selectionMode === DataGridSelectionMode.singleRow || this.selectionMode === DataGridSelectionMode.multiRow) {
250
+ Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
251
+ (cell) => cell.removeAttribute("aria-selected")
252
+ );
253
+ Array.from(this.querySelectorAll('[role="row"]')).forEach(
254
+ (row) => !row.hasAttribute("aria-selected") && row.setAttribute("aria-selected", "false")
255
+ );
256
+ }
257
+ };
258
+ this.addEventListener("click", this.#handleClick);
259
+ this.addEventListener("keydown", this.#handleKeypress);
260
+ }
261
+ /**
262
+ * generates a gridTemplateColumns based on columndata array
263
+ */
264
+ static generateTemplateColumns(columnDefinitions) {
265
+ let templateColumns = "";
266
+ columnDefinitions.forEach((_) => {
267
+ templateColumns = `${templateColumns}${templateColumns === "" ? "" : " "}${"1fr"}`;
268
+ });
269
+ return templateColumns;
270
+ }
271
+ /**
272
+ * @internal
273
+ */
274
+ noTabbingChanged() {
275
+ if (this.noTabbing) {
276
+ this.setAttribute("tabIndex", "-1");
277
+ } else {
278
+ this.setAttribute(
279
+ "tabIndex",
280
+ this.contains(document.activeElement) ? "-1" : "0"
281
+ );
282
+ }
283
+ }
284
+ /**
285
+ * @internal
286
+ */
287
+ generateHeaderChanged() {
288
+ if (this.$fastController.isConnected) {
289
+ this.toggleGeneratedHeader();
290
+ }
291
+ }
292
+ /**
293
+ * @internal
294
+ */
295
+ gridTemplateColumnsChanged() {
296
+ if (this.$fastController.isConnected) {
297
+ this.updateRowIndexes();
298
+ }
299
+ }
300
+ /**
301
+ * @internal
302
+ */
303
+ rowsDataChanged() {
304
+ if (this.columnDefinitions === null && this.rowsData.length > 0) {
305
+ this.columnDefinitions = _DataGrid.generateColumns(this.rowsData[0]);
306
+ }
307
+ if (this.$fastController.isConnected) {
308
+ this.toggleGeneratedHeader();
309
+ }
310
+ }
311
+ /**
312
+ * @internal
313
+ */
314
+ columnDefinitionsChanged() {
315
+ if (this.columnDefinitions === null) {
316
+ this.generatedGridTemplateColumns = "";
317
+ return;
318
+ }
319
+ this.generatedGridTemplateColumns = _DataGrid.generateTemplateColumns(
320
+ this.columnDefinitions
321
+ );
322
+ if (this.$fastController.isConnected) {
323
+ this.columnDefinitionsStale = true;
324
+ this.queueRowIndexUpdate();
325
+ }
326
+ }
327
+ /**
328
+ * @internal
329
+ */
330
+ headerCellItemTemplateChanged() {
331
+ if (this.$fastController.isConnected) {
332
+ if (this.generatedHeader !== null) {
333
+ this.generatedHeader.headerCellItemTemplate = this.headerCellItemTemplate;
334
+ }
335
+ }
336
+ }
337
+ /**
338
+ * @internal
339
+ */
340
+ focusRowIndexChanged() {
341
+ if (this.$fastController.isConnected) {
342
+ this.queueFocusUpdate();
343
+ }
344
+ }
345
+ /**
346
+ * @internal
347
+ */
348
+ focusColumnIndexChanged() {
349
+ if (this.$fastController.isConnected) {
350
+ this.queueFocusUpdate();
351
+ }
352
+ }
353
+ /**
354
+ * @internal
355
+ */
356
+ connectedCallback() {
357
+ super.connectedCallback();
358
+ if (this.rowItemTemplate === void 0) {
359
+ this.rowItemTemplate = this.defaultRowItemTemplate;
360
+ }
361
+ this.rowsPlaceholder = document.createComment("");
362
+ this.appendChild(this.rowsPlaceholder);
363
+ this.toggleGeneratedHeader();
364
+ this.rowsRepeatBehavior = new RepeatDirective(
365
+ (x) => x.rowsData,
366
+ (x) => x.rowItemTemplate,
367
+ { positioning: true }
368
+ ).createBehavior(this.rowsPlaceholder);
369
+ this.$fastController.addBehaviors([this.rowsRepeatBehavior]);
370
+ this.addEventListener("row-focused", this.handleRowFocus);
371
+ this.addEventListener(eventFocus, this.handleFocus);
372
+ this.addEventListener(eventKeyDown, this.handleKeydown);
373
+ this.addEventListener(eventFocusOut, this.handleFocusOut);
374
+ this.observer = new MutationObserver(this.onChildListChange);
375
+ this.observer.observe(this, { childList: true });
376
+ DOM.queueUpdate(this.queueRowIndexUpdate);
377
+ Observable.getNotifier(this).subscribe(
378
+ this.#changeHandler,
379
+ "columnDefinitions"
380
+ );
381
+ }
382
+ /**
383
+ * @internal
384
+ */
385
+ disconnectedCallback() {
386
+ super.disconnectedCallback();
387
+ this.removeEventListener("row-focused", this.handleRowFocus);
388
+ this.removeEventListener(eventFocus, this.handleFocus);
389
+ this.removeEventListener(eventKeyDown, this.handleKeydown);
390
+ this.removeEventListener(
391
+ eventFocusOut,
392
+ this.handleFocusOut
393
+ );
394
+ this.observer.disconnect();
395
+ this.rowsPlaceholder = null;
396
+ this.generatedHeader = null;
397
+ Observable.getNotifier(this).unsubscribe(
398
+ this.#changeHandler,
399
+ "columnDefinitions"
400
+ );
401
+ }
402
+ /**
403
+ * @internal
404
+ */
405
+ handleRowFocus(e) {
406
+ this.isUpdatingFocus = true;
407
+ const focusRow = e.target;
408
+ this.focusRowIndex = this.rowElements.indexOf(focusRow);
409
+ this.focusColumnIndex = focusRow.focusColumnIndex;
410
+ this.setAttribute("tabIndex", "-1");
411
+ this.isUpdatingFocus = false;
412
+ }
413
+ /**
414
+ * @internal
415
+ */
416
+ handleFocus(_) {
417
+ this.focusOnCell(this.focusRowIndex, this.focusColumnIndex, true);
418
+ }
419
+ /**
420
+ * @internal
421
+ */
422
+ handleFocusOut(e) {
423
+ if (e.relatedTarget === null || !this.contains(e.relatedTarget)) {
424
+ this.setAttribute("tabIndex", this.noTabbing ? "-1" : "0");
425
+ }
426
+ }
427
+ /**
428
+ * @internal
429
+ */
430
+ handleKeydown(e) {
431
+ if (e.defaultPrevented) {
432
+ return;
433
+ }
434
+ let newFocusRowIndex;
435
+ const maxIndex = this.rowElements.length - 1;
436
+ const currentGridBottom = this.offsetHeight + this.scrollTop;
437
+ const lastRow = this.rowElements[maxIndex];
438
+ switch (e.key) {
439
+ case keyArrowUp:
440
+ e.preventDefault();
441
+ this.focusOnCell(this.focusRowIndex - 1, this.focusColumnIndex, true);
442
+ break;
443
+ case keyArrowDown:
444
+ e.preventDefault();
445
+ this.focusOnCell(this.focusRowIndex + 1, this.focusColumnIndex, true);
446
+ break;
447
+ case keyPageUp:
448
+ e.preventDefault();
449
+ if (this.rowElements.length === 0) {
450
+ this.focusOnCell(0, 0, false);
451
+ break;
452
+ }
453
+ if (this.focusRowIndex === 0) {
454
+ this.focusOnCell(0, this.focusColumnIndex, false);
455
+ return;
456
+ }
457
+ newFocusRowIndex = this.focusRowIndex - 1;
458
+ for (newFocusRowIndex; newFocusRowIndex >= 0; newFocusRowIndex--) {
459
+ const thisRow = this.rowElements[newFocusRowIndex];
460
+ if (thisRow.offsetTop < this.scrollTop) {
461
+ this.scrollTop = thisRow.offsetTop + thisRow.clientHeight - this.clientHeight;
462
+ break;
463
+ }
464
+ }
465
+ this.focusOnCell(newFocusRowIndex, this.focusColumnIndex, false);
466
+ break;
467
+ case keyPageDown:
468
+ e.preventDefault();
469
+ if (this.rowElements.length === 0) {
470
+ this.focusOnCell(0, 0, false);
471
+ break;
472
+ }
473
+ if (this.focusRowIndex >= maxIndex || lastRow.offsetTop + lastRow.offsetHeight <= currentGridBottom) {
474
+ this.focusOnCell(maxIndex, this.focusColumnIndex, false);
475
+ return;
476
+ }
477
+ newFocusRowIndex = this.focusRowIndex + 1;
478
+ for (newFocusRowIndex; newFocusRowIndex <= maxIndex; newFocusRowIndex++) {
479
+ const thisRow = this.rowElements[newFocusRowIndex];
480
+ if (thisRow.offsetTop + thisRow.offsetHeight > currentGridBottom) {
481
+ let stickyHeaderOffset = 0;
482
+ if (this.generateHeader === GenerateHeaderOptions.sticky && this.generatedHeader !== null) {
483
+ stickyHeaderOffset = this.generatedHeader.clientHeight;
484
+ }
485
+ this.scrollTop = thisRow.offsetTop - stickyHeaderOffset;
486
+ break;
487
+ }
488
+ }
489
+ this.focusOnCell(newFocusRowIndex, this.focusColumnIndex, false);
490
+ break;
491
+ case keyHome:
492
+ if (e.ctrlKey) {
493
+ e.preventDefault();
494
+ this.focusOnCell(0, 0, true);
495
+ }
496
+ break;
497
+ case keyEnd:
498
+ if (e.ctrlKey && this.columnDefinitions !== null) {
499
+ e.preventDefault();
500
+ this.focusOnCell(
501
+ this.rowElements.length - 1,
502
+ this.columnDefinitions.length - 1,
503
+ true
504
+ );
505
+ }
506
+ break;
507
+ }
508
+ }
509
+ queueFocusUpdate() {
510
+ if (this.isUpdatingFocus && this.contains(document.activeElement)) {
511
+ return;
512
+ }
513
+ if (this.pendingFocusUpdate === false) {
514
+ this.pendingFocusUpdate = true;
515
+ DOM.queueUpdate(() => this.updateFocus());
516
+ }
517
+ }
518
+ updateFocus() {
519
+ this.pendingFocusUpdate = false;
520
+ this.focusOnCell(this.focusRowIndex, this.focusColumnIndex, true);
521
+ }
522
+ toggleGeneratedHeader() {
523
+ if (this.generatedHeader !== null) {
524
+ this.removeChild(this.generatedHeader);
525
+ this.generatedHeader = null;
526
+ }
527
+ if (this.generateHeader !== GenerateHeaderOptions.none && this.columnDefinitions !== null) {
528
+ const generatedHeaderElement = document.createElement(
529
+ this.rowElementTag
530
+ );
531
+ this.generatedHeader = generatedHeaderElement;
532
+ this.generatedHeader.columnDefinitions = this.columnDefinitions;
533
+ this.generatedHeader.gridTemplateColumns = this.gridTemplateColumns;
534
+ this.generatedHeader.rowType = this.generateHeader === GenerateHeaderOptions.sticky ? DataGridRowTypes.stickyHeader : DataGridRowTypes.header;
535
+ if (this.firstChild !== null || this.rowsPlaceholder !== null) {
536
+ this.insertBefore(
537
+ generatedHeaderElement,
538
+ this.firstChild !== null ? this.firstChild : this.rowsPlaceholder
539
+ );
540
+ }
541
+ return;
542
+ }
543
+ }
955
544
  /**
956
545
  *
957
546
  *
@@ -981,157 +570,14 @@ class DataGrid extends DataGrid$1 {
981
570
  }
982
571
  this.#resetSelection();
983
572
  }
984
- #handleKeypress = (e) => {
985
- if (e.key === "Enter" || e.key === " ") {
986
- this.#handleClick(e);
987
- }
988
- };
989
- #handleClick = ({ target, ctrlKey, shiftKey, metaKey }) => {
990
- if (target.getAttribute("role") !== "gridcell") return;
991
- if (this.selectionMode === DataGridSelectionMode.singleCell || this.selectionMode === DataGridSelectionMode.multiCell) {
992
- this.#handleCellSelection({ target, ctrlKey, shiftKey, metaKey });
993
- return;
994
- }
995
- if (this.selectionMode === DataGridSelectionMode.singleRow || this.selectionMode === DataGridSelectionMode.multiRow) {
996
- this.#handleRowSelection({ target, ctrlKey, shiftKey, metaKey });
997
- }
998
- };
999
- #handleCellSelection = ({
1000
- target,
1001
- ctrlKey,
1002
- shiftKey,
1003
- metaKey
1004
- }) => {
1005
- const cell = target;
1006
- if (this.selectionMode === DataGridSelectionMode.multiCell && (ctrlKey || shiftKey || metaKey)) {
1007
- this.#setSelectedState(cell, !this.#selectedCells.includes(cell));
1008
- } else {
1009
- const cacheTargetSelection = cell.getAttribute("aria-selected") === "true";
1010
- this.#resetSelection();
1011
- this.#setSelectedState(cell, !cacheTargetSelection);
1012
- }
1013
- };
1014
- #handleRowSelection = ({
1015
- target,
1016
- ctrlKey,
1017
- shiftKey,
1018
- metaKey
1019
- }) => {
1020
- const row = target.parentNode;
1021
- if (this.selectionMode === DataGridSelectionMode.multiRow && (ctrlKey || shiftKey || metaKey)) {
1022
- this.#setSelectedState(row, !this.#selectedRows.includes(row));
1023
- } else {
1024
- const cacheTargetSelection = row.getAttribute("aria-selected") === "true";
1025
- this.#resetSelection();
1026
- this.#setSelectedState(row, !cacheTargetSelection);
1027
- }
1028
- };
1029
- constructor() {
1030
- super();
1031
- this.addEventListener("click", this.#handleClick);
1032
- this.addEventListener("keydown", this.#handleKeypress);
1033
- const privates = this;
1034
- privates.toggleGeneratedHeader = () => {
1035
- if (privates.generatedHeader !== null) {
1036
- this.removeChild(privates.generatedHeader);
1037
- privates.generatedHeader = null;
1038
- }
1039
- if (this.generateHeader !== GenerateHeaderOptions.none && this.columnDefinitions !== null) {
1040
- const generatedHeaderElement = document.createElement(
1041
- this.rowElementTag
1042
- );
1043
- privates.generatedHeader = generatedHeaderElement;
1044
- privates.generatedHeader.columnDefinitions = this.columnDefinitions;
1045
- privates.generatedHeader.gridTemplateColumns = this.gridTemplateColumns;
1046
- privates.generatedHeader.rowType = this.generateHeader === GenerateHeaderOptions.sticky ? DataGridRowTypes.stickyHeader : DataGridRowTypes.header;
1047
- if (this.firstChild !== null || privates.rowsPlaceholder !== null) {
1048
- this.insertBefore(
1049
- generatedHeaderElement,
1050
- this.firstChild !== null ? this.firstChild : privates.rowsPlaceholder
1051
- );
1052
- }
1053
- return;
1054
- }
1055
- };
1056
- }
1057
- #changeHandler = {
1058
- handleChange(dataGrid, propertyName) {
1059
- if (propertyName === "columnDefinitions") {
1060
- if (dataGrid.$fastController.isConnected) {
1061
- dataGrid.toggleGeneratedHeader();
1062
- }
1063
- }
1064
- }
1065
- };
1066
- connectedCallback() {
1067
- super.connectedCallback();
1068
- Observable.getNotifier(this).subscribe(
1069
- this.#changeHandler,
1070
- "columnDefinitions"
1071
- );
1072
- }
1073
- disconnectedCallback() {
1074
- super.disconnectedCallback();
1075
- Observable.getNotifier(this).unsubscribe(
1076
- this.#changeHandler,
1077
- "columnDefinitions"
1078
- );
1079
- }
1080
- #setSelectedState = (cell, selectedState) => {
1081
- cell.setAttribute("aria-selected", selectedState.toString());
1082
- };
1083
- #resetSelection = () => {
1084
- if (this.selectionMode === DataGridSelectionMode.singleCell || this.selectionMode === DataGridSelectionMode.multiCell) {
1085
- Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
1086
- (cell) => this.#setSelectedState(cell, false)
1087
- );
1088
- Array.from(this.querySelectorAll('[role="row"]')).forEach(
1089
- (row) => row.removeAttribute("aria-selected")
1090
- );
1091
- }
1092
- if (this.selectionMode === DataGridSelectionMode.none) {
1093
- Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
1094
- (cell) => cell.removeAttribute("aria-selected")
1095
- );
1096
- Array.from(this.querySelectorAll('[role="row"]')).forEach(
1097
- (row) => row.removeAttribute("aria-selected")
1098
- );
1099
- }
1100
- if (this.selectionMode === DataGridSelectionMode.singleRow || this.selectionMode === DataGridSelectionMode.multiRow) {
1101
- Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
1102
- (cell) => cell.removeAttribute("aria-selected")
1103
- );
1104
- Array.from(this.querySelectorAll('[role="row"]')).forEach(
1105
- (row) => row.setAttribute("aria-selected", "false")
1106
- );
1107
- }
1108
- };
1109
- #initSelections = () => {
1110
- if (this.selectionMode === DataGridSelectionMode.singleCell || this.selectionMode === DataGridSelectionMode.multiCell) {
1111
- Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
1112
- (cell) => !cell.hasAttribute("aria-selected") && this.#setSelectedState(cell, false)
1113
- );
1114
- Array.from(this.querySelectorAll('[role="row"]')).forEach(
1115
- (row) => row.removeAttribute("aria-selected")
1116
- );
1117
- }
1118
- if (this.selectionMode === DataGridSelectionMode.none) {
1119
- Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
1120
- (cell) => cell.removeAttribute("aria-selected")
1121
- );
1122
- Array.from(this.querySelectorAll('[role="row"]')).forEach(
1123
- (row) => row.removeAttribute("aria-selected")
1124
- );
1125
- }
1126
- if (this.selectionMode === DataGridSelectionMode.singleRow || this.selectionMode === DataGridSelectionMode.multiRow) {
1127
- Array.from(this.querySelectorAll('[role="gridcell"]')).forEach(
1128
- (cell) => cell.removeAttribute("aria-selected")
1129
- );
1130
- Array.from(this.querySelectorAll('[role="row"]')).forEach(
1131
- (row) => !row.hasAttribute("aria-selected") && row.setAttribute("aria-selected", "false")
1132
- );
1133
- }
1134
- };
573
+ #handleKeypress;
574
+ #handleClick;
575
+ #handleCellSelection;
576
+ #handleRowSelection;
577
+ #changeHandler;
578
+ #setSelectedState;
579
+ #resetSelection;
580
+ #initSelections;
1135
581
  static generateColumns(rowData) {
1136
582
  return Object.keys(rowData).map((property, index) => {
1137
583
  return {
@@ -1140,13 +586,54 @@ class DataGrid extends DataGrid$1 {
1140
586
  };
1141
587
  });
1142
588
  }
1143
- }
589
+ };
590
+ __decorateClass$2([
591
+ attr({ attribute: "no-tabbing", mode: "boolean" })
592
+ ], _DataGrid.prototype, "noTabbing");
593
+ __decorateClass$2([
594
+ attr({ attribute: "generate-header" })
595
+ ], _DataGrid.prototype, "generateHeader");
596
+ // @ts-expect-error Type is incorrectly non-optional
597
+ __decorateClass$2([
598
+ attr({ attribute: "grid-template-columns" })
599
+ ], _DataGrid.prototype, "gridTemplateColumns");
600
+ __decorateClass$2([
601
+ observable
602
+ ], _DataGrid.prototype, "rowsData");
603
+ __decorateClass$2([
604
+ observable
605
+ ], _DataGrid.prototype, "columnDefinitions");
606
+ __decorateClass$2([
607
+ observable
608
+ ], _DataGrid.prototype, "rowItemTemplate");
609
+ __decorateClass$2([
610
+ observable
611
+ ], _DataGrid.prototype, "cellItemTemplate");
612
+ __decorateClass$2([
613
+ observable
614
+ ], _DataGrid.prototype, "headerCellItemTemplate");
1144
615
  __decorateClass$2([
1145
616
  observable
1146
- ], DataGrid.prototype, "slottedRowElements");
617
+ ], _DataGrid.prototype, "focusRowIndex");
618
+ __decorateClass$2([
619
+ observable
620
+ ], _DataGrid.prototype, "focusColumnIndex");
621
+ __decorateClass$2([
622
+ observable
623
+ ], _DataGrid.prototype, "defaultRowItemTemplate");
624
+ __decorateClass$2([
625
+ observable
626
+ ], _DataGrid.prototype, "rowElementTag");
627
+ __decorateClass$2([
628
+ observable
629
+ ], _DataGrid.prototype, "rowElements");
630
+ __decorateClass$2([
631
+ observable
632
+ ], _DataGrid.prototype, "slottedRowElements");
1147
633
  __decorateClass$2([
1148
634
  attr({ attribute: "selection-mode" })
1149
- ], DataGrid.prototype, "selectionMode");
635
+ ], _DataGrid.prototype, "selectionMode");
636
+ let DataGrid = _DataGrid;
1150
637
 
1151
638
  var __defProp$1 = Object.defineProperty;
1152
639
  var __decorateClass$1 = (decorators, target, key, kind) => {
@@ -1157,12 +644,165 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
1157
644
  if (result) __defProp$1(target, key, result);
1158
645
  return result;
1159
646
  };
1160
- class DataGridRow extends DataGridRow$1 {
647
+ class DataGridRow extends VividElement {
1161
648
  constructor() {
1162
649
  super(...arguments);
650
+ // eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
651
+ this.rowType = DataGridRowTypes.default;
652
+ this.rowData = null;
653
+ this.columnDefinitions = null;
654
+ this.cellsRepeatBehavior = null;
655
+ this.cellsPlaceholder = null;
656
+ /**
657
+ * @internal
658
+ */
659
+ this.focusColumnIndex = 0;
660
+ this.updateRowStyle = () => {
661
+ this.style.gridTemplateColumns = this.gridTemplateColumns;
662
+ };
1163
663
  this.ariaSelected = null;
1164
664
  }
665
+ /**
666
+ * @internal
667
+ */
668
+ gridTemplateColumnsChanged() {
669
+ if (this.$fastController.isConnected) {
670
+ this.updateRowStyle();
671
+ }
672
+ }
673
+ /**
674
+ * @internal
675
+ */
676
+ rowTypeChanged() {
677
+ if (this.$fastController.isConnected) {
678
+ this.updateItemTemplate();
679
+ }
680
+ }
681
+ /**
682
+ * @internal
683
+ */
684
+ cellItemTemplateChanged() {
685
+ this.updateItemTemplate();
686
+ }
687
+ /**
688
+ * @internal
689
+ */
690
+ headerCellItemTemplateChanged() {
691
+ this.updateItemTemplate();
692
+ }
693
+ /**
694
+ * @internal
695
+ */
696
+ connectedCallback() {
697
+ super.connectedCallback();
698
+ if (this.cellsRepeatBehavior === null) {
699
+ this.cellsPlaceholder = document.createComment("");
700
+ this.appendChild(this.cellsPlaceholder);
701
+ this.updateItemTemplate();
702
+ this.cellsRepeatBehavior = new RepeatDirective(
703
+ (x) => x.columnDefinitions,
704
+ (x) => x.activeCellItemTemplate,
705
+ { positioning: true }
706
+ ).createBehavior(this.cellsPlaceholder);
707
+ this.$fastController.addBehaviors([this.cellsRepeatBehavior]);
708
+ }
709
+ this.addEventListener("cell-focused", this.handleCellFocus);
710
+ this.addEventListener(eventFocusOut, this.handleFocusout);
711
+ this.addEventListener(eventKeyDown, this.handleKeydown);
712
+ this.updateRowStyle();
713
+ }
714
+ /**
715
+ * @internal
716
+ */
717
+ disconnectedCallback() {
718
+ super.disconnectedCallback();
719
+ this.removeEventListener("cell-focused", this.handleCellFocus);
720
+ this.removeEventListener(
721
+ eventFocusOut,
722
+ this.handleFocusout
723
+ );
724
+ this.removeEventListener(eventKeyDown, this.handleKeydown);
725
+ }
726
+ handleFocusout(_) {
727
+ if (!this.contains(document.activeElement)) {
728
+ this.focusColumnIndex = 0;
729
+ }
730
+ }
731
+ handleCellFocus(e) {
732
+ this.focusColumnIndex = this.cellElements.indexOf(e.target);
733
+ this.$emit("row-focused", this);
734
+ }
735
+ handleKeydown(e) {
736
+ if (e.defaultPrevented) {
737
+ return;
738
+ }
739
+ let newFocusColumnIndex = 0;
740
+ switch (e.key) {
741
+ case keyArrowLeft:
742
+ newFocusColumnIndex = Math.max(0, this.focusColumnIndex - 1);
743
+ this.cellElements[newFocusColumnIndex].focus();
744
+ e.preventDefault();
745
+ break;
746
+ case keyArrowRight:
747
+ newFocusColumnIndex = Math.min(
748
+ this.cellElements.length - 1,
749
+ this.focusColumnIndex + 1
750
+ );
751
+ this.cellElements[newFocusColumnIndex].focus();
752
+ e.preventDefault();
753
+ break;
754
+ case keyHome:
755
+ if (!e.ctrlKey) {
756
+ this.cellElements[0].focus();
757
+ e.preventDefault();
758
+ }
759
+ break;
760
+ case keyEnd:
761
+ if (!e.ctrlKey) {
762
+ this.cellElements[this.cellElements.length - 1].focus();
763
+ e.preventDefault();
764
+ }
765
+ break;
766
+ }
767
+ }
768
+ updateItemTemplate() {
769
+ this.activeCellItemTemplate = this.rowType === DataGridRowTypes.default && this.cellItemTemplate !== void 0 ? this.cellItemTemplate : this.rowType === DataGridRowTypes.default && this.cellItemTemplate === void 0 ? this.defaultCellItemTemplate : this.headerCellItemTemplate !== void 0 ? this.headerCellItemTemplate : this.defaultHeaderCellItemTemplate;
770
+ }
1165
771
  }
772
+ // @ts-expect-error Type is incorrectly non-optional
773
+ __decorateClass$1([
774
+ attr({ attribute: "grid-template-columns" })
775
+ ], DataGridRow.prototype, "gridTemplateColumns");
776
+ __decorateClass$1([
777
+ attr({ attribute: "row-type" })
778
+ ], DataGridRow.prototype, "rowType");
779
+ __decorateClass$1([
780
+ observable
781
+ ], DataGridRow.prototype, "rowData");
782
+ __decorateClass$1([
783
+ observable
784
+ ], DataGridRow.prototype, "columnDefinitions");
785
+ __decorateClass$1([
786
+ observable
787
+ ], DataGridRow.prototype, "cellItemTemplate");
788
+ __decorateClass$1([
789
+ observable
790
+ ], DataGridRow.prototype, "headerCellItemTemplate");
791
+ __decorateClass$1([
792
+ observable
793
+ ], DataGridRow.prototype, "rowIndex");
794
+ __decorateClass$1([
795
+ observable
796
+ ], DataGridRow.prototype, "activeCellItemTemplate");
797
+ __decorateClass$1([
798
+ observable
799
+ ], DataGridRow.prototype, "defaultCellItemTemplate");
800
+ __decorateClass$1([
801
+ observable
802
+ ], DataGridRow.prototype, "defaultHeaderCellItemTemplate");
803
+ __decorateClass$1([
804
+ observable
805
+ ], DataGridRow.prototype, "cellElements");
1166
806
  __decorateClass$1([
1167
807
  attr({ attribute: "aria-selected" })
1168
808
  ], DataGridRow.prototype, "ariaSelected");
@@ -1227,11 +867,25 @@ var __decorateClass = (decorators, target, key, kind) => {
1227
867
  if (result) __defProp(target, key, result);
1228
868
  return result;
1229
869
  };
1230
- class DataGridCell extends DataGridCell$1 {
870
+ const defaultCellContentsTemplate = html`
871
+ <template>
872
+ ${(x) => x.rowData === null || x.columnDefinition === null || x.columnDefinition.columnDataKey === null ? null : x.rowData[x.columnDefinition.columnDataKey]}
873
+ </template>
874
+ `;
875
+ const defaultHeaderCellContentsTemplate = html`
876
+ <template>
877
+ ${(x) => x.columnDefinition.title === void 0 ? x.columnDefinition.columnDataKey : x.columnDefinition.title}
878
+ </template>
879
+ `;
880
+ class DataGridCell extends VividElement {
1231
881
  constructor() {
1232
- super();
1233
- this.ariaSelected = null;
1234
- this.ariaSort = null;
882
+ super(...arguments);
883
+ // eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
884
+ this.cellType = DataGridCellTypes.default;
885
+ this.rowData = null;
886
+ this.columnDefinition = null;
887
+ this.isActiveCell = false;
888
+ this.customCellView = null;
1235
889
  this.updateCellStyle = () => {
1236
890
  if (this.gridColumn && !this.gridColumn.includes("undefined")) {
1237
891
  this.style.gridColumn = this.gridColumn;
@@ -1239,24 +893,173 @@ class DataGridCell extends DataGridCell$1 {
1239
893
  this.style.removeProperty("grid-column");
1240
894
  }
1241
895
  };
896
+ this.ariaSelected = null;
897
+ this.ariaSort = null;
1242
898
  }
1243
- ariaSelectedChanged(_, selectedState) {
1244
- this.shadowRoot.querySelector(".base")?.classList.toggle(
1245
- "selected",
1246
- selectedState === "true"
1247
- );
899
+ /**
900
+ * @internal
901
+ */
902
+ cellTypeChanged() {
903
+ if (this.$fastController.isConnected) {
904
+ this.updateCellView();
905
+ }
906
+ }
907
+ /**
908
+ * @internal
909
+ */
910
+ gridColumnChanged() {
911
+ if (this.$fastController.isConnected) {
912
+ this.updateCellStyle();
913
+ }
914
+ }
915
+ /**
916
+ * @internal
917
+ */
918
+ columnDefinitionChanged(_oldValue, _newValue) {
919
+ if (this.$fastController.isConnected) {
920
+ this.updateCellView();
921
+ }
1248
922
  }
923
+ /**
924
+ * @internal
925
+ */
1249
926
  connectedCallback() {
1250
927
  super.connectedCallback();
928
+ this.addEventListener(eventFocusIn, this.handleFocusin);
929
+ this.addEventListener(eventFocusOut, this.handleFocusout);
930
+ this.addEventListener(eventKeyDown, this.handleKeydown);
931
+ this.style.gridColumn = `${this.columnDefinition?.gridColumn === void 0 ? 0 : this.columnDefinition.gridColumn}`;
932
+ this.updateCellView();
933
+ this.updateCellStyle();
1251
934
  this.ariaSelectedChanged(null, this.ariaSelected);
1252
935
  }
1253
- handleFocusin(e) {
1254
- super.handleFocusin(e);
936
+ /**
937
+ * @internal
938
+ */
939
+ disconnectedCallback() {
940
+ super.disconnectedCallback();
941
+ this.removeEventListener(eventFocusIn, this.handleFocusin);
942
+ this.removeEventListener(
943
+ eventFocusOut,
944
+ this.handleFocusout
945
+ );
946
+ this.removeEventListener(eventKeyDown, this.handleKeydown);
947
+ this.disconnectCellView();
948
+ }
949
+ handleFocusin(_) {
1255
950
  this.shadowRoot.querySelector(".base").classList.add("active");
951
+ if (this.isActiveCell) {
952
+ return;
953
+ }
954
+ this.isActiveCell = true;
955
+ switch (this.cellType) {
956
+ case DataGridCellTypes.columnHeader:
957
+ if (this.columnDefinition !== null && this.columnDefinition.headerCellInternalFocusQueue !== true && typeof this.columnDefinition.headerCellFocusTargetCallback === "function") {
958
+ const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
959
+ if (focusTarget !== null) {
960
+ focusTarget.focus();
961
+ }
962
+ }
963
+ break;
964
+ default:
965
+ if (this.columnDefinition !== null && this.columnDefinition.cellInternalFocusQueue !== true && typeof this.columnDefinition.cellFocusTargetCallback === "function") {
966
+ const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
967
+ if (focusTarget !== null) {
968
+ focusTarget.focus();
969
+ }
970
+ }
971
+ break;
972
+ }
973
+ this.$emit("cell-focused", this);
1256
974
  }
1257
- handleFocusout(e) {
1258
- super.handleFocusout(e);
975
+ handleFocusout(_) {
1259
976
  this.shadowRoot.querySelector(".base").classList.remove("active");
977
+ if (this !== document.activeElement && !this.contains(document.activeElement)) {
978
+ this.isActiveCell = false;
979
+ }
980
+ }
981
+ handleKeydown(e) {
982
+ if (e.defaultPrevented || this.columnDefinition === null || this.cellType === DataGridCellTypes.default && this.columnDefinition.cellInternalFocusQueue !== true || this.cellType === DataGridCellTypes.columnHeader && this.columnDefinition.headerCellInternalFocusQueue !== true) {
983
+ return;
984
+ }
985
+ switch (e.key) {
986
+ case keyEnter:
987
+ case keyFunction2:
988
+ if (this.contains(document.activeElement) && document.activeElement !== this) {
989
+ return;
990
+ }
991
+ switch (this.cellType) {
992
+ case DataGridCellTypes.columnHeader:
993
+ if (this.columnDefinition.headerCellFocusTargetCallback !== void 0) {
994
+ const focusTarget = this.columnDefinition.headerCellFocusTargetCallback(this);
995
+ if (focusTarget !== null) {
996
+ focusTarget.focus();
997
+ }
998
+ e.preventDefault();
999
+ }
1000
+ break;
1001
+ default:
1002
+ if (this.columnDefinition.cellFocusTargetCallback !== void 0) {
1003
+ const focusTarget = this.columnDefinition.cellFocusTargetCallback(this);
1004
+ if (focusTarget !== null) {
1005
+ focusTarget.focus();
1006
+ }
1007
+ e.preventDefault();
1008
+ }
1009
+ break;
1010
+ }
1011
+ break;
1012
+ case keyEscape:
1013
+ if (this.contains(document.activeElement) && document.activeElement !== this) {
1014
+ this.focus();
1015
+ e.preventDefault();
1016
+ }
1017
+ break;
1018
+ }
1019
+ }
1020
+ updateCellView() {
1021
+ this.disconnectCellView();
1022
+ if (this.columnDefinition === null) {
1023
+ return;
1024
+ }
1025
+ switch (this.cellType) {
1026
+ case DataGridCellTypes.columnHeader:
1027
+ if (this.columnDefinition.headerCellTemplate !== void 0) {
1028
+ this.customCellView = this.columnDefinition.headerCellTemplate.render(
1029
+ this,
1030
+ this
1031
+ );
1032
+ } else {
1033
+ this.customCellView = defaultHeaderCellContentsTemplate.render(
1034
+ this,
1035
+ this
1036
+ );
1037
+ }
1038
+ break;
1039
+ case DataGridCellTypes.rowHeader:
1040
+ case DataGridCellTypes.default:
1041
+ if (this.columnDefinition.cellTemplate !== void 0) {
1042
+ this.customCellView = this.columnDefinition.cellTemplate.render(
1043
+ this,
1044
+ this
1045
+ );
1046
+ } else {
1047
+ this.customCellView = defaultCellContentsTemplate.render(this, this);
1048
+ }
1049
+ break;
1050
+ }
1051
+ }
1052
+ disconnectCellView() {
1053
+ if (this.customCellView !== null) {
1054
+ this.customCellView.dispose();
1055
+ this.customCellView = null;
1056
+ }
1057
+ }
1058
+ ariaSelectedChanged(_, selectedState) {
1059
+ this.shadowRoot.querySelector(".base")?.classList.toggle(
1060
+ "selected",
1061
+ selectedState === "true"
1062
+ );
1260
1063
  }
1261
1064
  #getColumnDataKey() {
1262
1065
  return this.columnDefinition && this.columnDefinition.columnDataKey ? this.columnDefinition.columnDataKey : this.textContent.trim();
@@ -1285,6 +1088,18 @@ class DataGridCell extends DataGridCell$1 {
1285
1088
  return true;
1286
1089
  }
1287
1090
  }
1091
+ __decorateClass([
1092
+ attr({ attribute: "cell-type" })
1093
+ ], DataGridCell.prototype, "cellType");
1094
+ __decorateClass([
1095
+ attr({ attribute: "grid-column" })
1096
+ ], DataGridCell.prototype, "gridColumn");
1097
+ __decorateClass([
1098
+ observable
1099
+ ], DataGridCell.prototype, "rowData");
1100
+ __decorateClass([
1101
+ observable
1102
+ ], DataGridCell.prototype, "columnDefinition");
1288
1103
  __decorateClass([
1289
1104
  attr({ attribute: "aria-selected", mode: "fromView" })
1290
1105
  ], DataGridCell.prototype, "ariaSelected");
@@ -1361,12 +1176,12 @@ function renderSortIcons(c) {
1361
1176
  `;
1362
1177
  }
1363
1178
  function handleKeyDown(x, e) {
1364
- if (e.key === keyEnter$1 || e.key === keySpace) {
1179
+ if (e.key === keyEnter || e.key === keySpace) {
1365
1180
  x._handleInteraction();
1366
1181
  }
1367
1182
  return true;
1368
1183
  }
1369
- function DataGridCellTemplate(context) {
1184
+ const DataGridCellTemplate = (context) => {
1370
1185
  return html`
1371
1186
  <template
1372
1187
  tabindex="-1"
@@ -1380,29 +1195,35 @@ function DataGridCellTemplate(context) {
1380
1195
  </div>
1381
1196
  </template>
1382
1197
  `;
1383
- }
1198
+ };
1384
1199
 
1385
- const dataGrid = DataGrid.compose({
1386
- baseName: "data-grid",
1387
- template: DataGridTemplate,
1388
- styles: dataGridStyles
1389
- })();
1390
- const dataGridRow = DataGridRow.compose({
1391
- baseName: "data-grid-row",
1392
- template: DataGridRowTemplate,
1393
- styles: dataGridRowStyles
1394
- })();
1395
- const dataGridCell = DataGridCell.compose({
1396
- baseName: "data-grid-cell",
1397
- template: DataGridCellTemplate,
1398
- styles: dataGridCellStyles
1399
- })();
1400
- const dataGridElements = [
1401
- dataGridCell,
1402
- dataGridRow,
1403
- dataGrid,
1404
- ...iconRegistries
1405
- ];
1406
- const registerDataGrid = registerFactory(dataGridElements);
1200
+ const dataGridCellDefinition = defineVividComponent(
1201
+ "data-grid-cell",
1202
+ DataGridCell,
1203
+ DataGridCellTemplate,
1204
+ [iconDefinition],
1205
+ {
1206
+ styles: dataGridCellStyles
1207
+ }
1208
+ );
1209
+ const dataGridRowDefinition = defineVividComponent(
1210
+ "data-grid-row",
1211
+ DataGridRow,
1212
+ DataGridRowTemplate,
1213
+ [dataGridCellDefinition],
1214
+ {
1215
+ styles: dataGridRowStyles
1216
+ }
1217
+ );
1218
+ const dataGridDefinition = defineVividComponent(
1219
+ "data-grid",
1220
+ DataGrid,
1221
+ DataGridTemplate,
1222
+ [dataGridRowDefinition],
1223
+ {
1224
+ styles: dataGridStyles
1225
+ }
1226
+ );
1227
+ const registerDataGrid = createRegisterFunction(dataGridDefinition);
1407
1228
 
1408
- export { dataGridRow as a, dataGridCell as b, dataGridElements as c, dataGrid as d, registerDataGrid as r };
1229
+ export { dataGridRowDefinition as a, dataGridDefinition as b, dataGridCellDefinition as d, registerDataGrid as r };