@vonage/vivid 4.13.0 → 4.14.0

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