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