@vonage/vivid 4.13.0 → 4.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (512) hide show
  1. package/custom-elements.json +3088 -1610
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +70 -136
  5. package/index.d.ts +0 -1
  6. package/index.js +60 -62
  7. package/lib/accordion/accordion.d.ts +2 -2
  8. package/lib/accordion/accordion.template.d.ts +1 -2
  9. package/lib/accordion/definition.d.ts +1 -1
  10. package/lib/accordion-item/accordion-item.d.ts +2 -2
  11. package/lib/accordion-item/accordion-item.template.d.ts +2 -3
  12. package/lib/accordion-item/definition.d.ts +1 -1
  13. package/lib/action-group/action-group.d.ts +2 -2
  14. package/lib/action-group/action-group.template.d.ts +1 -3
  15. package/lib/action-group/definition.d.ts +1 -1
  16. package/lib/alert/alert.d.ts +2 -2
  17. package/lib/alert/alert.template.d.ts +2 -3
  18. package/lib/alert/definition.d.ts +1 -1
  19. package/lib/audio-player/audio-player.d.ts +2 -2
  20. package/lib/audio-player/audio-player.template.d.ts +2 -3
  21. package/lib/audio-player/definition.d.ts +1 -3
  22. package/lib/avatar/avatar.d.ts +2 -2
  23. package/lib/avatar/avatar.template.d.ts +2 -3
  24. package/lib/avatar/definition.d.ts +1 -1
  25. package/lib/badge/badge.d.ts +2 -2
  26. package/lib/badge/badge.template.d.ts +2 -3
  27. package/lib/badge/definition.d.ts +1 -3
  28. package/lib/banner/banner.d.ts +2 -2
  29. package/lib/banner/banner.template.d.ts +2 -3
  30. package/lib/banner/definition.d.ts +1 -1
  31. package/lib/breadcrumb/breadcrumb.d.ts +2 -2
  32. package/lib/breadcrumb/breadcrumb.template.d.ts +3 -4
  33. package/lib/breadcrumb/definition.d.ts +1 -1
  34. package/lib/breadcrumb-item/breadcrumb-item.d.ts +2 -2
  35. package/lib/breadcrumb-item/breadcrumb-item.template.d.ts +2 -3
  36. package/lib/breadcrumb-item/definition.d.ts +1 -1
  37. package/lib/button/button.d.ts +2 -2
  38. package/lib/button/button.template.d.ts +2 -4
  39. package/lib/button/definition.d.ts +1 -1
  40. package/lib/calendar/calendar.d.ts +2 -2
  41. package/lib/calendar/calendar.template.d.ts +1 -3
  42. package/lib/calendar/definition.d.ts +1 -1
  43. package/lib/calendar-event/calendar-event.d.ts +2 -2
  44. package/lib/calendar-event/calendar-event.template.d.ts +1 -3
  45. package/lib/calendar-event/definition.d.ts +1 -1
  46. package/lib/card/card.d.ts +2 -2
  47. package/lib/card/card.template.d.ts +2 -3
  48. package/lib/card/definition.d.ts +1 -1
  49. package/lib/checkbox/checkbox.form-associated.d.ts +3 -2
  50. package/lib/checkbox/checkbox.template.d.ts +2 -3
  51. package/lib/checkbox/definition.d.ts +1 -1
  52. package/lib/combobox/combobox.d.ts +17 -2
  53. package/lib/combobox/combobox.options.d.ts +7 -0
  54. package/lib/combobox/combobox.template.d.ts +2 -3
  55. package/lib/combobox/definition.d.ts +1 -2
  56. package/lib/data-grid/data-grid-cell.d.ts +16 -13
  57. package/lib/data-grid/data-grid-cell.template.d.ts +2 -3
  58. package/lib/data-grid/data-grid-row.d.ts +19 -2
  59. package/lib/data-grid/data-grid-row.template.d.ts +2 -2
  60. package/lib/data-grid/data-grid.d.ts +45 -4
  61. package/lib/data-grid/data-grid.template.d.ts +2 -2
  62. package/lib/data-grid/definition.d.ts +1 -6
  63. package/lib/date-picker/definition.d.ts +1 -3
  64. package/lib/date-range-picker/definition.d.ts +1 -3
  65. package/lib/dial-pad/definition.d.ts +1 -3
  66. package/lib/dial-pad/dial-pad.d.ts +2 -2
  67. package/lib/dial-pad/dial-pad.template.d.ts +2 -3
  68. package/lib/dialog/definition.d.ts +1 -1
  69. package/lib/dialog/dialog.d.ts +2 -2
  70. package/lib/dialog/dialog.template.d.ts +2 -3
  71. package/lib/divider/definition.d.ts +1 -1
  72. package/lib/divider/divider.d.ts +2 -2
  73. package/lib/divider/divider.template.d.ts +1 -3
  74. package/lib/elevation/definition.d.ts +1 -1
  75. package/lib/elevation/elevation.d.ts +3 -2
  76. package/lib/elevation/elevation.template.d.ts +1 -3
  77. package/lib/empty-state/definition.d.ts +1 -3
  78. package/lib/empty-state/empty-state.d.ts +2 -2
  79. package/lib/empty-state/empty-state.template.d.ts +2 -3
  80. package/lib/fab/definition.d.ts +1 -3
  81. package/lib/fab/fab.template.d.ts +2 -3
  82. package/lib/file-picker/definition.d.ts +1 -3
  83. package/lib/file-picker/file-picker.form-associated.d.ts +3 -2
  84. package/lib/file-picker/file-picker.template.d.ts +2 -3
  85. package/lib/header/definition.d.ts +1 -3
  86. package/lib/header/header.d.ts +2 -2
  87. package/lib/header/header.template.d.ts +2 -3
  88. package/lib/icon/definition.d.ts +1 -3
  89. package/lib/icon/icon.d.ts +2 -2
  90. package/lib/icon/icon.template.d.ts +1 -3
  91. package/lib/layout/definition.d.ts +1 -3
  92. package/lib/layout/layout.d.ts +2 -2
  93. package/lib/layout/layout.template.d.ts +1 -3
  94. package/lib/listbox/definition.d.ts +1 -3
  95. package/lib/listbox/listbox.template.d.ts +1 -3
  96. package/lib/menu/definition.d.ts +1 -11
  97. package/lib/menu/menu.d.ts +2 -2
  98. package/lib/menu/menu.template.d.ts +3 -3
  99. package/lib/menu-item/definition.d.ts +1 -3
  100. package/lib/menu-item/menu-item.d.ts +2 -2
  101. package/lib/menu-item/menu-item.template.d.ts +2 -3
  102. package/lib/nav/definition.d.ts +1 -3
  103. package/lib/nav/nav.d.ts +2 -2
  104. package/lib/nav/nav.template.d.ts +1 -3
  105. package/lib/nav-disclosure/definition.d.ts +1 -3
  106. package/lib/nav-disclosure/nav-disclosure.d.ts +2 -2
  107. package/lib/nav-disclosure/nav-disclosure.template.d.ts +2 -3
  108. package/lib/nav-item/definition.d.ts +1 -3
  109. package/lib/nav-item/nav-item.template.d.ts +2 -3
  110. package/lib/note/definition.d.ts +1 -3
  111. package/lib/note/note.d.ts +2 -2
  112. package/lib/note/note.template.d.ts +2 -3
  113. package/lib/number-field/definition.d.ts +1 -4
  114. package/lib/number-field/number-field.form-associated.d.ts +3 -2
  115. package/lib/number-field/number-field.template.d.ts +2 -3
  116. package/lib/option/definition.d.ts +1 -3
  117. package/lib/option/option.d.ts +3 -2
  118. package/lib/option/option.template.d.ts +2 -3
  119. package/lib/pagination/definition.d.ts +1 -3
  120. package/lib/pagination/pagination.d.ts +2 -2
  121. package/lib/pagination/pagination.template.d.ts +2 -3
  122. package/lib/popup/definition.d.ts +1 -3
  123. package/lib/popup/popup.template.d.ts +2 -3
  124. package/lib/progress/definition.d.ts +1 -3
  125. package/lib/progress/progress.d.ts +1 -1
  126. package/lib/progress/progress.template.d.ts +1 -4
  127. package/lib/progress-ring/definition.d.ts +1 -3
  128. package/lib/progress-ring/progress-ring.d.ts +1 -1
  129. package/lib/progress-ring/progress-ring.template.d.ts +1 -3
  130. package/lib/radio/definition.d.ts +1 -3
  131. package/lib/radio/radio.form-associated.d.ts +5 -2
  132. package/lib/radio/radio.template.d.ts +1 -3
  133. package/lib/radio-group/definition.d.ts +1 -11
  134. package/lib/radio-group/radio-group.d.ts +2 -2
  135. package/lib/radio-group/radio-group.template.d.ts +2 -3
  136. package/lib/range-slider/definition.d.ts +1 -3
  137. package/lib/range-slider/range-slider.form-associated.d.ts +3 -2
  138. package/lib/range-slider/range-slider.template.d.ts +2 -3
  139. package/lib/searchable-select/definition.d.ts +1 -4
  140. package/lib/searchable-select/option-tag.template.d.ts +2 -3
  141. package/lib/searchable-select/searchable-select.form-associated.d.ts +3 -2
  142. package/lib/searchable-select/searchable-select.template.d.ts +2 -3
  143. package/lib/select/definition.d.ts +1 -3
  144. package/lib/select/select.d.ts +14 -4
  145. package/lib/select/select.form-associated.d.ts +11 -0
  146. package/lib/select/select.template.d.ts +2 -3
  147. package/lib/selectable-box/definition.d.ts +1 -3
  148. package/lib/selectable-box/selectable-box.d.ts +2 -2
  149. package/lib/selectable-box/selectable-box.template.d.ts +2 -3
  150. package/lib/side-drawer/definition.d.ts +1 -3
  151. package/lib/side-drawer/side-drawer.d.ts +2 -2
  152. package/lib/side-drawer/side-drawer.template.d.ts +1 -3
  153. package/lib/slider/definition.d.ts +1 -3
  154. package/lib/slider/slider.form-associated.d.ts +3 -2
  155. package/lib/slider/slider.template.d.ts +3 -4
  156. package/lib/split-button/definition.d.ts +1 -1
  157. package/lib/split-button/split-button.d.ts +2 -2
  158. package/lib/split-button/split-button.template.d.ts +2 -3
  159. package/lib/switch/definition.d.ts +1 -3
  160. package/lib/switch/switch.form-associated.d.ts +3 -2
  161. package/lib/switch/switch.template.d.ts +1 -3
  162. package/lib/tab/definition.d.ts +1 -3
  163. package/lib/tab/tab.d.ts +2 -2
  164. package/lib/tab/tab.template.d.ts +2 -2
  165. package/lib/tab-panel/definition.d.ts +1 -3
  166. package/lib/tab-panel/tab-panel.d.ts +2 -2
  167. package/lib/tab-panel/tab-panel.template.d.ts +1 -1
  168. package/lib/tabs/definition.d.ts +1 -3
  169. package/lib/tabs/tabs.d.ts +3 -7
  170. package/lib/tabs/tabs.template.d.ts +1 -1
  171. package/lib/tag/definition.d.ts +1 -4
  172. package/lib/tag/tag.d.ts +2 -2
  173. package/lib/tag/tag.template.d.ts +2 -3
  174. package/lib/tag-group/definition.d.ts +1 -3
  175. package/lib/tag-group/tag-group.d.ts +2 -2
  176. package/lib/tag-group/tag-group.template.d.ts +1 -3
  177. package/lib/text-anchor/definition.d.ts +1 -3
  178. package/lib/text-anchor/text-anchor.d.ts +4 -3
  179. package/lib/text-anchor/text-anchor.template.d.ts +2 -3
  180. package/lib/text-area/definition.d.ts +1 -3
  181. package/lib/text-area/text-area.d.ts +1 -1
  182. package/lib/text-area/{text-field.form-associated.d.ts → text-area.form-associated.d.ts} +3 -2
  183. package/lib/text-area/text-area.template.d.ts +2 -3
  184. package/lib/text-field/definition.d.ts +1 -3
  185. package/lib/text-field/text-field.form-associated.d.ts +3 -2
  186. package/lib/text-field/text-field.template.d.ts +2 -3
  187. package/lib/time-picker/definition.d.ts +1 -3
  188. package/lib/time-picker/time-picker.form-associated.d.ts +3 -2
  189. package/lib/time-picker/time-picker.template.d.ts +2 -2
  190. package/lib/toggletip/definition.d.ts +1 -3
  191. package/lib/toggletip/toggletip.d.ts +2 -2
  192. package/lib/toggletip/toggletip.template.d.ts +2 -3
  193. package/lib/tooltip/definition.d.ts +1 -3
  194. package/lib/tooltip/tooltip.d.ts +2 -2
  195. package/lib/tooltip/tooltip.template.d.ts +2 -3
  196. package/lib/tree-item/definition.d.ts +1 -3
  197. package/lib/tree-item/tree-item.d.ts +11 -2
  198. package/lib/tree-item/tree-item.template.d.ts +3 -3
  199. package/lib/tree-view/definition.d.ts +1 -3
  200. package/lib/tree-view/tree-view.d.ts +16 -2
  201. package/lib/tree-view/tree-view.template.d.ts +1 -1
  202. package/lib/video-player/definition.d.ts +1 -3
  203. package/lib/video-player/video-player.d.ts +2 -2
  204. package/lib/video-player/video-player.template.d.ts +1 -3
  205. package/listbox/index.cjs +37 -39
  206. package/listbox/index.js +37 -39
  207. package/menu/index.cjs +1 -1
  208. package/menu/index.js +1 -1
  209. package/nav/index.cjs +1 -1
  210. package/nav/index.js +1 -1
  211. package/nav-disclosure/index.cjs +1 -1
  212. package/nav-disclosure/index.js +1 -1
  213. package/nav-item/index.cjs +1 -1
  214. package/nav-item/index.js +1 -1
  215. package/note/index.cjs +1 -1
  216. package/note/index.js +1 -1
  217. package/number-field/index.cjs +1 -1
  218. package/number-field/index.js +1 -1
  219. package/option/index.cjs +1 -1
  220. package/option/index.js +1 -1
  221. package/package.json +1 -1
  222. package/pagination/index.cjs +1 -1
  223. package/pagination/index.js +1 -1
  224. package/popup/index.cjs +1 -1
  225. package/popup/index.js +1 -1
  226. package/progress/index.cjs +1 -1
  227. package/progress/index.js +1 -1
  228. package/progress-ring/index.cjs +1 -1
  229. package/progress-ring/index.js +1 -1
  230. package/radio/index.cjs +1 -1
  231. package/radio/index.js +1 -1
  232. package/radio-group/index.cjs +1 -1
  233. package/radio-group/index.js +1 -1
  234. package/range-slider/index.cjs +1 -1
  235. package/range-slider/index.js +1 -1
  236. package/searchable-select/index.cjs +1 -1
  237. package/searchable-select/index.js +1 -1
  238. package/select/index.cjs +1 -1
  239. package/select/index.js +1 -1
  240. package/selectable-box/index.cjs +1 -1
  241. package/selectable-box/index.js +1 -1
  242. package/shared/affix.cjs +10 -10
  243. package/shared/affix.js +2 -2
  244. package/shared/anchor.cjs +59 -0
  245. package/shared/anchor.js +57 -0
  246. package/shared/anchored.cjs +6 -6
  247. package/shared/anchored.js +2 -2
  248. package/shared/apply-mixins.cjs +15 -17
  249. package/shared/apply-mixins.js +15 -17
  250. package/shared/apply-mixins2.cjs +25 -0
  251. package/shared/apply-mixins2.js +23 -0
  252. package/shared/applyMixinsWithObservables.cjs +4 -4
  253. package/shared/applyMixinsWithObservables.js +2 -2
  254. package/shared/aria-global.cjs +86 -67
  255. package/shared/aria-global.js +86 -67
  256. package/shared/aria-global2.cjs +68 -86
  257. package/shared/aria-global2.js +68 -86
  258. package/shared/base-progress.cjs +69 -63
  259. package/shared/base-progress.js +69 -63
  260. package/shared/breadcrumb-item.cjs +6 -58
  261. package/shared/breadcrumb-item.js +3 -55
  262. package/shared/button.cjs +177 -0
  263. package/shared/button.js +175 -0
  264. package/shared/calendar-event.cjs +9 -9
  265. package/shared/calendar-event.js +2 -2
  266. package/shared/children.cjs +2 -2
  267. package/shared/children.js +1 -1
  268. package/shared/date-picker/date-picker-base.form-associated.d.ts +3 -2
  269. package/shared/date-picker/date-picker-base.template.d.ts +2 -3
  270. package/shared/definition.cjs +25 -24
  271. package/shared/definition.js +16 -14
  272. package/shared/definition10.cjs +14 -12
  273. package/shared/definition10.js +14 -11
  274. package/shared/definition11.cjs +52 -248
  275. package/shared/definition11.js +24 -218
  276. package/shared/definition12.cjs +18 -14
  277. package/shared/definition12.js +17 -12
  278. package/shared/definition13.cjs +19 -19
  279. package/shared/definition13.js +10 -9
  280. package/shared/definition14.cjs +35 -38
  281. package/shared/definition14.js +15 -17
  282. package/shared/definition15.cjs +27 -26
  283. package/shared/definition15.js +16 -14
  284. package/shared/definition16.cjs +480 -612
  285. package/shared/definition16.js +473 -604
  286. package/shared/definition17.cjs +933 -1113
  287. package/shared/definition17.js +911 -1090
  288. package/shared/definition18.cjs +16 -20
  289. package/shared/definition18.js +19 -22
  290. package/shared/definition19.cjs +26 -30
  291. package/shared/definition19.js +21 -24
  292. package/shared/definition2.cjs +19 -22
  293. package/shared/definition2.js +20 -22
  294. package/shared/definition20.cjs +50 -52
  295. package/shared/definition20.js +34 -35
  296. package/shared/definition21.cjs +43 -47
  297. package/shared/definition21.js +19 -22
  298. package/shared/definition22.cjs +15 -13
  299. package/shared/definition22.js +14 -11
  300. package/shared/definition23.cjs +21 -20
  301. package/shared/definition23.js +14 -12
  302. package/shared/definition24.cjs +21 -173
  303. package/shared/definition24.js +18 -169
  304. package/shared/definition25.cjs +26 -28
  305. package/shared/definition25.js +18 -19
  306. package/shared/definition26.cjs +16 -14
  307. package/shared/definition26.js +14 -11
  308. package/shared/definition27.cjs +264 -12
  309. package/shared/definition27.js +261 -10
  310. package/shared/definition28.cjs +19 -17
  311. package/shared/definition28.js +15 -12
  312. package/shared/definition29.cjs +142 -68
  313. package/shared/definition29.js +101 -29
  314. package/shared/definition3.cjs +20 -16
  315. package/shared/definition3.js +16 -11
  316. package/shared/definition30.cjs +98 -76
  317. package/shared/definition30.js +97 -74
  318. package/shared/definition31.cjs +24 -97
  319. package/shared/definition31.js +25 -97
  320. package/shared/definition32.cjs +9 -25
  321. package/shared/definition32.js +8 -23
  322. package/shared/definition33.cjs +52 -14
  323. package/shared/definition33.js +51 -12
  324. package/shared/definition34.cjs +639 -34
  325. package/shared/definition34.js +636 -30
  326. package/shared/definition35.cjs +203 -596
  327. package/shared/definition35.js +197 -591
  328. package/shared/definition36.cjs +197 -233
  329. package/shared/definition36.js +192 -226
  330. package/shared/definition37.cjs +79 -206
  331. package/shared/definition37.js +75 -202
  332. package/shared/definition38.cjs +50 -56
  333. package/shared/definition38.js +48 -52
  334. package/shared/definition39.cjs +259 -56
  335. package/shared/definition39.js +258 -54
  336. package/shared/definition4.cjs +32 -35
  337. package/shared/definition4.js +19 -21
  338. package/shared/definition40.cjs +156 -225
  339. package/shared/definition40.js +152 -221
  340. package/shared/definition41.cjs +626 -36
  341. package/shared/definition41.js +625 -34
  342. package/shared/definition42.cjs +974 -487
  343. package/shared/definition42.js +971 -482
  344. package/shared/definition43.cjs +725 -932
  345. package/shared/definition43.js +713 -918
  346. package/shared/definition44.cjs +115 -734
  347. package/shared/definition44.js +113 -731
  348. package/shared/definition45.cjs +92 -116
  349. package/shared/definition45.js +92 -115
  350. package/shared/definition46.cjs +468 -89
  351. package/shared/definition46.js +465 -86
  352. package/shared/definition47.cjs +118 -470
  353. package/shared/definition47.js +115 -465
  354. package/shared/definition48.cjs +113 -120
  355. package/shared/definition48.js +111 -117
  356. package/shared/definition49.cjs +16 -134
  357. package/shared/definition49.js +15 -132
  358. package/shared/definition5.cjs +47 -49
  359. package/shared/definition5.js +18 -19
  360. package/shared/definition50.cjs +111 -15
  361. package/shared/definition50.js +109 -12
  362. package/shared/definition51.cjs +862 -84
  363. package/shared/definition51.js +858 -79
  364. package/shared/definition52.cjs +30 -873
  365. package/shared/definition52.js +28 -870
  366. package/shared/definition53.cjs +125 -28
  367. package/shared/definition53.js +123 -25
  368. package/shared/definition54.cjs +267 -107
  369. package/shared/definition54.js +261 -100
  370. package/shared/definition55.cjs +63 -278
  371. package/shared/definition55.js +61 -275
  372. package/shared/definition56.cjs +867 -76
  373. package/shared/definition56.js +866 -74
  374. package/shared/definition57.cjs +107 -826
  375. package/shared/definition57.js +105 -823
  376. package/shared/definition58.cjs +73 -100
  377. package/shared/definition58.js +69 -95
  378. package/shared/definition59.cjs +180 -106
  379. package/shared/definition59.js +174 -101
  380. package/shared/definition6.cjs +22 -21
  381. package/shared/definition6.js +14 -12
  382. package/shared/definition60.cjs +272 -70
  383. package/shared/definition60.js +272 -69
  384. package/shared/definition61.cjs +66154 -271
  385. package/shared/definition61.js +66153 -269
  386. package/shared/definition62.cjs +38 -66173
  387. package/shared/definition62.js +35 -66170
  388. package/shared/definition63.cjs +2153 -27
  389. package/shared/definition63.js +2150 -25
  390. package/shared/definition7.cjs +18 -15
  391. package/shared/definition7.js +13 -10
  392. package/shared/definition8.cjs +25 -27
  393. package/shared/definition8.js +16 -17
  394. package/shared/definition9.cjs +21 -21
  395. package/shared/definition9.js +18 -17
  396. package/shared/design-system/createRegisterFunction.d.ts +2 -0
  397. package/shared/design-system/defineVividComponent.d.ts +15 -0
  398. package/shared/{localization.js → direction.js} +11 -11
  399. package/shared/dom.cjs +0 -13
  400. package/shared/dom.js +1 -13
  401. package/shared/form-associated.cjs +422 -457
  402. package/shared/form-associated.js +422 -457
  403. package/shared/form-associated2.cjs +383 -0
  404. package/shared/form-associated2.js +381 -0
  405. package/shared/form-elements.cjs +15 -42
  406. package/shared/form-elements.js +2 -29
  407. package/shared/foundation/anchor/anchor.d.ts +1 -0
  408. package/shared/foundation/button/button.d.ts +3 -2
  409. package/shared/foundation/button/button.template.d.ts +2 -4
  410. package/shared/foundation/form-associated/form-associated.d.ts +51 -0
  411. package/shared/foundation/listbox/listbox.d.ts +22 -0
  412. package/shared/foundation/progress/base-progress.d.ts +9 -0
  413. package/shared/foundation/utilities/apply-mixins.d.ts +1 -0
  414. package/shared/foundation/vivid-element/vivid-element.d.ts +3 -0
  415. package/shared/index.cjs +7 -5097
  416. package/shared/index.js +7 -5079
  417. package/shared/key-codes.cjs +10 -0
  418. package/shared/key-codes.js +6 -1
  419. package/shared/key-codes2.cjs +1463 -6
  420. package/shared/key-codes2.js +1461 -4
  421. package/shared/listbox.cjs +427 -1195
  422. package/shared/listbox.js +411 -1176
  423. package/shared/listbox2.cjs +1267 -0
  424. package/shared/listbox2.js +1264 -0
  425. package/shared/localized.cjs +2 -2
  426. package/shared/localized.js +1 -1
  427. package/shared/numbers.cjs +12 -0
  428. package/shared/numbers.js +12 -1
  429. package/shared/patterns/affix.d.ts +2 -2
  430. package/shared/patterns/chevron.d.ts +2 -2
  431. package/shared/patterns/form-elements/form-elements.d.ts +2 -2
  432. package/shared/presentationDate.cjs +49 -49
  433. package/shared/presentationDate.js +6 -6
  434. package/shared/ref.cjs +2 -2
  435. package/shared/ref.js +1 -1
  436. package/shared/repeat.cjs +22 -22
  437. package/shared/repeat.js +1 -1
  438. package/shared/slider.template.cjs +5 -5
  439. package/shared/slider.template.js +2 -2
  440. package/shared/slotted.cjs +4 -4
  441. package/shared/slotted.js +1 -1
  442. package/shared/strings.cjs +0 -26
  443. package/shared/strings.js +1 -25
  444. package/shared/strings2.cjs +37 -0
  445. package/shared/strings2.js +33 -0
  446. package/shared/text-anchor.cjs +7 -89
  447. package/shared/text-anchor.js +4 -86
  448. package/shared/text-anchor.template.cjs +2 -2
  449. package/shared/text-anchor.template.js +1 -1
  450. package/shared/text-field2.cjs +28 -28
  451. package/shared/text-field2.js +5 -5
  452. package/shared/vivid-element.cjs +2616 -0
  453. package/shared/vivid-element.js +2595 -0
  454. package/side-drawer/index.cjs +1 -1
  455. package/side-drawer/index.js +1 -1
  456. package/slider/index.cjs +1 -1
  457. package/slider/index.js +1 -1
  458. package/split-button/index.cjs +1 -1
  459. package/split-button/index.js +1 -1
  460. package/styles/core/all.css +40 -1
  461. package/styles/core/theme.css +40 -1
  462. package/styles/core/typography.css +1 -1
  463. package/styles/tokens/theme-dark.css +25 -4
  464. package/styles/tokens/theme-light.css +25 -4
  465. package/styles/tokens/vivid-2-compat.css +1 -1
  466. package/switch/index.cjs +1 -1
  467. package/switch/index.js +1 -1
  468. package/tab/index.cjs +1 -1
  469. package/tab/index.js +1 -1
  470. package/tab-panel/index.cjs +1 -1
  471. package/tab-panel/index.js +1 -1
  472. package/tabs/index.cjs +1 -1
  473. package/tabs/index.js +1 -1
  474. package/tag/index.cjs +1 -1
  475. package/tag/index.js +1 -1
  476. package/tag-group/index.cjs +1 -1
  477. package/tag-group/index.js +1 -1
  478. package/text-anchor/index.cjs +10 -7
  479. package/text-anchor/index.js +10 -7
  480. package/text-area/index.cjs +1 -1
  481. package/text-area/index.js +1 -1
  482. package/text-field/index.cjs +1 -1
  483. package/text-field/index.js +1 -1
  484. package/time-picker/index.cjs +1 -1
  485. package/time-picker/index.js +1 -1
  486. package/toggletip/index.cjs +1 -1
  487. package/toggletip/index.js +1 -1
  488. package/tooltip/index.cjs +1 -1
  489. package/tooltip/index.js +1 -1
  490. package/tree-item/index.cjs +1 -1
  491. package/tree-item/index.js +1 -1
  492. package/tree-view/index.cjs +1 -1
  493. package/tree-view/index.js +1 -1
  494. package/video-player/index.cjs +1 -1
  495. package/video-player/index.js +1 -1
  496. package/vivid.api.json +2846 -7860
  497. package/shared/definition64.cjs +0 -2175
  498. package/shared/definition64.js +0 -2170
  499. package/shared/design-system/index.d.ts +0 -3
  500. package/shared/icon.cjs +0 -261
  501. package/shared/icon.js +0 -258
  502. package/shared/index2.cjs +0 -11
  503. package/shared/index2.js +0 -9
  504. package/shared/radio.cjs +0 -126
  505. package/shared/radio.js +0 -124
  506. package/shared/select.options.cjs +0 -12
  507. package/shared/select.options.js +0 -10
  508. package/shared/start-end.cjs +0 -52
  509. package/shared/start-end.js +0 -50
  510. package/shared/tree-item.cjs +0 -154
  511. package/shared/tree-item.js +0 -151
  512. package/shared/{localization.cjs → direction.cjs} +9 -9
@@ -1,5 +1,1465 @@
1
1
  'use strict';
2
2
 
3
+ const vividElement = require('./vivid-element.cjs');
4
+ const ref = require('./ref.cjs');
5
+
6
+ /**
7
+ * A mixin class implementing start and end elements.
8
+ * These are generally used to decorate text elements with icons or other visual indicators.
9
+ * @public
10
+ */
11
+ class StartEnd {
12
+ handleStartContentChange() {
13
+ this.startContainer.classList.toggle("start", this.start.assignedNodes().length > 0);
14
+ }
15
+ handleEndContentChange() {
16
+ this.endContainer.classList.toggle("end", this.end.assignedNodes().length > 0);
17
+ }
18
+ }
19
+ /**
20
+ * The template for the end element.
21
+ * For use with {@link StartEnd}
22
+ *
23
+ * @public
24
+ * @deprecated - use endSlotTemplate
25
+ */
26
+ vividElement.html `
27
+ <span part="end" ${ref.ref("endContainer")}>
28
+ <slot
29
+ name="end"
30
+ ${ref.ref("end")}
31
+ @slotchange="${x => x.handleEndContentChange()}"
32
+ ></slot>
33
+ </span>
34
+ `;
35
+ /**
36
+ * The template for the start element.
37
+ * For use with {@link StartEnd}
38
+ *
39
+ * @public
40
+ * @deprecated - use startSlotTemplate
41
+ */
42
+ vividElement.html `
43
+ <span part="start" ${ref.ref("startContainer")}>
44
+ <slot
45
+ name="start"
46
+ ${ref.ref("start")}
47
+ @slotchange="${x => x.handleStartContentChange()}"
48
+ ></slot>
49
+ </span>
50
+ `;
51
+
52
+ /*! *****************************************************************************
53
+ Copyright (c) Microsoft Corporation.
54
+
55
+ Permission to use, copy, modify, and/or distribute this software for any
56
+ purpose with or without fee is hereby granted.
57
+
58
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
59
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
60
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
61
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
62
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
63
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
64
+ PERFORMANCE OF THIS SOFTWARE.
65
+ ***************************************************************************** */
66
+ /* global Reflect, Promise */
67
+
68
+
69
+ function __decorate(decorators, target, key, desc) {
70
+ var c = arguments.length, r = c < 3 ? target : desc, d;
71
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
72
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
73
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
74
+ }
75
+
76
+ /**
77
+ * Big thanks to https://github.com/fkleuver and the https://github.com/aurelia/aurelia project
78
+ * for the bulk of this code and many of the associated tests.
79
+ */
80
+ // Tiny polyfill for TypeScript's Reflect metadata API.
81
+ const metadataByTarget = new Map();
82
+ if (!("metadata" in Reflect)) {
83
+ Reflect.metadata = function (key, value) {
84
+ return function (target) {
85
+ Reflect.defineMetadata(key, value, target);
86
+ };
87
+ };
88
+ Reflect.defineMetadata = function (key, value, target) {
89
+ let metadata = metadataByTarget.get(target);
90
+ if (metadata === void 0) {
91
+ metadataByTarget.set(target, (metadata = new Map()));
92
+ }
93
+ metadata.set(key, value);
94
+ };
95
+ Reflect.getOwnMetadata = function (key, target) {
96
+ const metadata = metadataByTarget.get(target);
97
+ if (metadata !== void 0) {
98
+ return metadata.get(key);
99
+ }
100
+ return void 0;
101
+ };
102
+ }
103
+ /**
104
+ * A utility class used that constructs and registers resolvers for a dependency
105
+ * injection container. Supports a standard set of object lifetimes.
106
+ * @public
107
+ */
108
+ class ResolverBuilder {
109
+ /**
110
+ *
111
+ * @param container - The container to create resolvers for.
112
+ * @param key - The key to register resolvers under.
113
+ */
114
+ constructor(container, key) {
115
+ this.container = container;
116
+ this.key = key;
117
+ }
118
+ /**
119
+ * Creates a resolver for an existing object instance.
120
+ * @param value - The instance to resolve.
121
+ * @returns The resolver.
122
+ */
123
+ instance(value) {
124
+ return this.registerResolver(0 /* instance */, value);
125
+ }
126
+ /**
127
+ * Creates a resolver that enforces a singleton lifetime.
128
+ * @param value - The type to create and cache the singleton for.
129
+ * @returns The resolver.
130
+ */
131
+ singleton(value) {
132
+ return this.registerResolver(1 /* singleton */, value);
133
+ }
134
+ /**
135
+ * Creates a resolver that creates a new instance for every dependency request.
136
+ * @param value - The type to create instances of.
137
+ * @returns - The resolver.
138
+ */
139
+ transient(value) {
140
+ return this.registerResolver(2 /* transient */, value);
141
+ }
142
+ /**
143
+ * Creates a resolver that invokes a callback function for every dependency resolution
144
+ * request, allowing custom logic to return the dependency.
145
+ * @param value - The callback to call during resolution.
146
+ * @returns The resolver.
147
+ */
148
+ callback(value) {
149
+ return this.registerResolver(3 /* callback */, value);
150
+ }
151
+ /**
152
+ * Creates a resolver that invokes a callback function the first time that a dependency
153
+ * resolution is requested. The returned value is then cached and provided for all
154
+ * subsequent requests.
155
+ * @param value - The callback to call during the first resolution.
156
+ * @returns The resolver.
157
+ */
158
+ cachedCallback(value) {
159
+ return this.registerResolver(3 /* callback */, cacheCallbackResult(value));
160
+ }
161
+ /**
162
+ * Aliases the current key to a different key.
163
+ * @param destinationKey - The key to point the alias to.
164
+ * @returns The resolver.
165
+ */
166
+ aliasTo(destinationKey) {
167
+ return this.registerResolver(5 /* alias */, destinationKey);
168
+ }
169
+ registerResolver(strategy, state) {
170
+ const { container, key } = this;
171
+ /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
172
+ this.container = this.key = (void 0);
173
+ return container.registerResolver(key, new ResolverImpl(key, strategy, state));
174
+ }
175
+ }
176
+ function cloneArrayWithPossibleProps(source) {
177
+ const clone = source.slice();
178
+ const keys = Object.keys(source);
179
+ const len = keys.length;
180
+ let key;
181
+ for (let i = 0; i < len; ++i) {
182
+ key = keys[i];
183
+ if (!isArrayIndex(key)) {
184
+ clone[key] = source[key];
185
+ }
186
+ }
187
+ return clone;
188
+ }
189
+ /**
190
+ * A set of default resolvers useful in configuring a container.
191
+ * @public
192
+ */
193
+ const DefaultResolver = Object.freeze({
194
+ /**
195
+ * Disables auto-registration and throws for all un-registered dependencies.
196
+ * @param key - The key to create the resolver for.
197
+ */
198
+ none(key) {
199
+ throw Error(`${key.toString()} not registered, did you forget to add @singleton()?`);
200
+ },
201
+ /**
202
+ * Provides default singleton resolution behavior during auto-registration.
203
+ * @param key - The key to create the resolver for.
204
+ * @returns The resolver.
205
+ */
206
+ singleton(key) {
207
+ return new ResolverImpl(key, 1 /* singleton */, key);
208
+ },
209
+ /**
210
+ * Provides default transient resolution behavior during auto-registration.
211
+ * @param key - The key to create the resolver for.
212
+ * @returns The resolver.
213
+ */
214
+ transient(key) {
215
+ return new ResolverImpl(key, 2 /* transient */, key);
216
+ },
217
+ });
218
+ /**
219
+ * Configuration for a dependency injection container.
220
+ * @public
221
+ */
222
+ const ContainerConfiguration = Object.freeze({
223
+ /**
224
+ * The default configuration used when creating a DOM-disconnected container.
225
+ * @remarks
226
+ * The default creates a root container, with no parent container. It does not handle
227
+ * owner requests and it uses singleton resolution behavior for auto-registration.
228
+ */
229
+ default: Object.freeze({
230
+ parentLocator: () => null,
231
+ responsibleForOwnerRequests: false,
232
+ defaultResolver: DefaultResolver.singleton,
233
+ }),
234
+ });
235
+ const dependencyLookup = new Map();
236
+ function getParamTypes(key) {
237
+ return (Type) => {
238
+ return Reflect.getOwnMetadata(key, Type);
239
+ };
240
+ }
241
+ let rootDOMContainer = null;
242
+ /**
243
+ * The gateway to dependency injection APIs.
244
+ * @public
245
+ */
246
+ const DI = Object.freeze({
247
+ /**
248
+ * Creates a new dependency injection container.
249
+ * @param config - The configuration for the container.
250
+ * @returns A newly created dependency injection container.
251
+ */
252
+ createContainer(config) {
253
+ return new ContainerImpl(null, Object.assign({}, ContainerConfiguration.default, config));
254
+ },
255
+ /**
256
+ * Finds the dependency injection container responsible for providing dependencies
257
+ * to the specified node.
258
+ * @param node - The node to find the responsible container for.
259
+ * @returns The container responsible for providing dependencies to the node.
260
+ * @remarks
261
+ * This will be the same as the parent container if the specified node
262
+ * does not itself host a container configured with responsibleForOwnerRequests.
263
+ */
264
+ findResponsibleContainer(node) {
265
+ const owned = node.$$container$$;
266
+ if (owned && owned.responsibleForOwnerRequests) {
267
+ return owned;
268
+ }
269
+ return DI.findParentContainer(node);
270
+ },
271
+ /**
272
+ * Find the dependency injection container up the DOM tree from this node.
273
+ * @param node - The node to find the parent container for.
274
+ * @returns The parent container of this node.
275
+ * @remarks
276
+ * This will be the same as the responsible container if the specified node
277
+ * does not itself host a container configured with responsibleForOwnerRequests.
278
+ */
279
+ findParentContainer(node) {
280
+ const event = new CustomEvent(DILocateParentEventType, {
281
+ bubbles: true,
282
+ composed: true,
283
+ cancelable: true,
284
+ detail: { container: void 0 },
285
+ });
286
+ node.dispatchEvent(event);
287
+ return event.detail.container || DI.getOrCreateDOMContainer();
288
+ },
289
+ /**
290
+ * Returns a dependency injection container if one is explicitly owned by the specified
291
+ * node. If one is not owned, then a new container is created and assigned to the node.
292
+ * @param node - The node to find or create the container for.
293
+ * @param config - The configuration for the container if one needs to be created.
294
+ * @returns The located or created container.
295
+ * @remarks
296
+ * This API does not search for a responsible or parent container. It looks only for a container
297
+ * directly defined on the specified node and creates one at that location if one does not
298
+ * already exist.
299
+ */
300
+ getOrCreateDOMContainer(node, config) {
301
+ if (!node) {
302
+ return (rootDOMContainer ||
303
+ (rootDOMContainer = new ContainerImpl(null, Object.assign({}, ContainerConfiguration.default, config, {
304
+ parentLocator: () => null,
305
+ }))));
306
+ }
307
+ return (node.$$container$$ ||
308
+ new ContainerImpl(node, Object.assign({}, ContainerConfiguration.default, config, {
309
+ parentLocator: DI.findParentContainer,
310
+ })));
311
+ },
312
+ /**
313
+ * Gets the "design:paramtypes" metadata for the specified type.
314
+ * @param Type - The type to get the metadata for.
315
+ * @returns The metadata array or undefined if no metadata is found.
316
+ */
317
+ getDesignParamtypes: getParamTypes("design:paramtypes"),
318
+ /**
319
+ * Gets the "di:paramtypes" metadata for the specified type.
320
+ * @param Type - The type to get the metadata for.
321
+ * @returns The metadata array or undefined if no metadata is found.
322
+ */
323
+ getAnnotationParamtypes: getParamTypes("di:paramtypes"),
324
+ /**
325
+ *
326
+ * @param Type - Gets the "di:paramtypes" metadata for the specified type. If none is found,
327
+ * an empty metadata array is created and added.
328
+ * @returns The metadata array.
329
+ */
330
+ getOrCreateAnnotationParamTypes(Type) {
331
+ let annotationParamtypes = this.getAnnotationParamtypes(Type);
332
+ if (annotationParamtypes === void 0) {
333
+ Reflect.defineMetadata("di:paramtypes", (annotationParamtypes = []), Type);
334
+ }
335
+ return annotationParamtypes;
336
+ },
337
+ /**
338
+ * Gets the dependency keys representing what is needed to instantiate the specified type.
339
+ * @param Type - The type to get the dependencies for.
340
+ * @returns An array of dependency keys.
341
+ */
342
+ getDependencies(Type) {
343
+ // Note: Every detail of this getDependencies method is pretty deliberate at the moment, and probably not yet 100% tested from every possible angle,
344
+ // so be careful with making changes here as it can have a huge impact on complex end user apps.
345
+ // Preferably, only make changes to the dependency resolution process via a RFC.
346
+ let dependencies = dependencyLookup.get(Type);
347
+ if (dependencies === void 0) {
348
+ // Type.length is the number of constructor parameters. If this is 0, it could mean the class has an empty constructor
349
+ // but it could also mean the class has no constructor at all (in which case it inherits the constructor from the prototype).
350
+ // Non-zero constructor length + no paramtypes means emitDecoratorMetadata is off, or the class has no decorator.
351
+ // We're not doing anything with the above right now, but it's good to keep in mind for any future issues.
352
+ const inject = Type.inject;
353
+ if (inject === void 0) {
354
+ // design:paramtypes is set by tsc when emitDecoratorMetadata is enabled.
355
+ const designParamtypes = DI.getDesignParamtypes(Type);
356
+ // di:paramtypes is set by the parameter decorator from DI.createInterface or by @inject
357
+ const annotationParamtypes = DI.getAnnotationParamtypes(Type);
358
+ if (designParamtypes === void 0) {
359
+ if (annotationParamtypes === void 0) {
360
+ // Only go up the prototype if neither static inject nor any of the paramtypes is defined, as
361
+ // there is no sound way to merge a type's deps with its prototype's deps
362
+ const Proto = Object.getPrototypeOf(Type);
363
+ if (typeof Proto === "function" && Proto !== Function.prototype) {
364
+ dependencies = cloneArrayWithPossibleProps(DI.getDependencies(Proto));
365
+ }
366
+ else {
367
+ dependencies = [];
368
+ }
369
+ }
370
+ else {
371
+ // No design:paramtypes so just use the di:paramtypes
372
+ dependencies = cloneArrayWithPossibleProps(annotationParamtypes);
373
+ }
374
+ }
375
+ else if (annotationParamtypes === void 0) {
376
+ // No di:paramtypes so just use the design:paramtypes
377
+ dependencies = cloneArrayWithPossibleProps(designParamtypes);
378
+ }
379
+ else {
380
+ // We've got both, so merge them (in case of conflict on same index, di:paramtypes take precedence)
381
+ dependencies = cloneArrayWithPossibleProps(designParamtypes);
382
+ let len = annotationParamtypes.length;
383
+ let auAnnotationParamtype;
384
+ for (let i = 0; i < len; ++i) {
385
+ auAnnotationParamtype = annotationParamtypes[i];
386
+ if (auAnnotationParamtype !== void 0) {
387
+ dependencies[i] = auAnnotationParamtype;
388
+ }
389
+ }
390
+ const keys = Object.keys(annotationParamtypes);
391
+ len = keys.length;
392
+ let key;
393
+ for (let i = 0; i < len; ++i) {
394
+ key = keys[i];
395
+ if (!isArrayIndex(key)) {
396
+ dependencies[key] = annotationParamtypes[key];
397
+ }
398
+ }
399
+ }
400
+ }
401
+ else {
402
+ // Ignore paramtypes if we have static inject
403
+ dependencies = cloneArrayWithPossibleProps(inject);
404
+ }
405
+ dependencyLookup.set(Type, dependencies);
406
+ }
407
+ return dependencies;
408
+ },
409
+ /**
410
+ * Defines a property on a web component class. The value of this property will
411
+ * be resolved from the dependency injection container responsible for the element
412
+ * instance, based on where it is connected in the DOM.
413
+ * @param target - The target to define the property on.
414
+ * @param propertyName - The name of the property to define.
415
+ * @param key - The dependency injection key.
416
+ * @param respectConnection - Indicates whether or not to update the property value if the
417
+ * hosting component is disconnected and then re-connected at a different location in the DOM.
418
+ * @remarks
419
+ * The respectConnection option is only applicable to elements that descend from FASTElement.
420
+ */
421
+ defineProperty(target, propertyName, key, respectConnection = false) {
422
+ const diPropertyKey = `$di_${propertyName}`;
423
+ Reflect.defineProperty(target, propertyName, {
424
+ get: function () {
425
+ let value = this[diPropertyKey];
426
+ if (value === void 0) {
427
+ const container = this instanceof HTMLElement
428
+ ? DI.findResponsibleContainer(this)
429
+ : DI.getOrCreateDOMContainer();
430
+ value = container.get(key);
431
+ this[diPropertyKey] = value;
432
+ if (respectConnection && this instanceof vividElement.FASTElement) {
433
+ const notifier = this.$fastController;
434
+ const handleChange = () => {
435
+ const newContainer = DI.findResponsibleContainer(this);
436
+ const newValue = newContainer.get(key);
437
+ const oldValue = this[diPropertyKey];
438
+ if (newValue !== oldValue) {
439
+ this[diPropertyKey] = value;
440
+ notifier.notify(propertyName);
441
+ }
442
+ };
443
+ notifier.subscribe({ handleChange }, "isConnected");
444
+ }
445
+ }
446
+ return value;
447
+ },
448
+ });
449
+ },
450
+ /**
451
+ * Creates a dependency injection key.
452
+ * @param nameConfigOrCallback - A friendly name for the key or a lambda that configures a
453
+ * default resolution for the dependency.
454
+ * @param configuror - If a friendly name was provided for the first parameter, then an optional
455
+ * lambda that configures a default resolution for the dependency can be provided second.
456
+ * @returns The created key.
457
+ * @remarks
458
+ * The created key can be used as a property decorator or constructor parameter decorator,
459
+ * in addition to its standard use in an inject array or through direct container APIs.
460
+ */
461
+ createInterface(nameConfigOrCallback, configuror) {
462
+ const configure = typeof nameConfigOrCallback === "function"
463
+ ? nameConfigOrCallback
464
+ : configuror;
465
+ const friendlyName = typeof nameConfigOrCallback === "string"
466
+ ? nameConfigOrCallback
467
+ : nameConfigOrCallback && "friendlyName" in nameConfigOrCallback
468
+ ? nameConfigOrCallback.friendlyName || defaultFriendlyName
469
+ : defaultFriendlyName;
470
+ const respectConnection = typeof nameConfigOrCallback === "string"
471
+ ? false
472
+ : nameConfigOrCallback && "respectConnection" in nameConfigOrCallback
473
+ ? nameConfigOrCallback.respectConnection || false
474
+ : false;
475
+ const Interface = function (target, property, index) {
476
+ if (target == null || new.target !== undefined) {
477
+ throw new Error(`No registration for interface: '${Interface.friendlyName}'`);
478
+ }
479
+ if (property) {
480
+ DI.defineProperty(target, property, Interface, respectConnection);
481
+ }
482
+ else {
483
+ const annotationParamtypes = DI.getOrCreateAnnotationParamTypes(target);
484
+ annotationParamtypes[index] = Interface;
485
+ }
486
+ };
487
+ Interface.$isInterface = true;
488
+ Interface.friendlyName = friendlyName == null ? "(anonymous)" : friendlyName;
489
+ if (configure != null) {
490
+ Interface.register = function (container, key) {
491
+ return configure(new ResolverBuilder(container, key !== null && key !== void 0 ? key : Interface));
492
+ };
493
+ }
494
+ Interface.toString = function toString() {
495
+ return `InterfaceSymbol<${Interface.friendlyName}>`;
496
+ };
497
+ return Interface;
498
+ },
499
+ /**
500
+ * A decorator that specifies what to inject into its target.
501
+ * @param dependencies - The dependencies to inject.
502
+ * @returns The decorator to be applied to the target class.
503
+ * @remarks
504
+ * The decorator can be used to decorate a class, listing all of the classes dependencies.
505
+ * Or it can be used to decorate a constructor paramter, indicating what to inject for that
506
+ * parameter.
507
+ * Or it can be used for a web component property, indicating what that property should resolve to.
508
+ */
509
+ inject(...dependencies) {
510
+ return function (target, key, descriptor) {
511
+ if (typeof descriptor === "number") {
512
+ // It's a parameter decorator.
513
+ const annotationParamtypes = DI.getOrCreateAnnotationParamTypes(target);
514
+ const dep = dependencies[0];
515
+ if (dep !== void 0) {
516
+ annotationParamtypes[descriptor] = dep;
517
+ }
518
+ }
519
+ else if (key) {
520
+ DI.defineProperty(target, key, dependencies[0]);
521
+ }
522
+ else {
523
+ const annotationParamtypes = descriptor
524
+ ? DI.getOrCreateAnnotationParamTypes(descriptor.value)
525
+ : DI.getOrCreateAnnotationParamTypes(target);
526
+ let dep;
527
+ for (let i = 0; i < dependencies.length; ++i) {
528
+ dep = dependencies[i];
529
+ if (dep !== void 0) {
530
+ annotationParamtypes[i] = dep;
531
+ }
532
+ }
533
+ }
534
+ };
535
+ },
536
+ /**
537
+ * Registers the `target` class as a transient dependency; each time the dependency is resolved
538
+ * a new instance will be created.
539
+ *
540
+ * @param target - The class / constructor function to register as transient.
541
+ * @returns The same class, with a static `register` method that takes a container and returns the appropriate resolver.
542
+ *
543
+ * @example
544
+ * On an existing class
545
+ * ```ts
546
+ * class Foo { }
547
+ * DI.transient(Foo);
548
+ * ```
549
+ *
550
+ * @example
551
+ * Inline declaration
552
+ *
553
+ * ```ts
554
+ * const Foo = DI.transient(class { });
555
+ * // Foo is now strongly typed with register
556
+ * Foo.register(container);
557
+ * ```
558
+ *
559
+ * @public
560
+ */
561
+ transient(target) {
562
+ target.register = function register(container) {
563
+ const registration = Registration.transient(target, target);
564
+ return registration.register(container);
565
+ };
566
+ target.registerInRequestor = false;
567
+ return target;
568
+ },
569
+ /**
570
+ * Registers the `target` class as a singleton dependency; the class will only be created once. Each
571
+ * consecutive time the dependency is resolved, the same instance will be returned.
572
+ *
573
+ * @param target - The class / constructor function to register as a singleton.
574
+ * @returns The same class, with a static `register` method that takes a container and returns the appropriate resolver.
575
+ * @example
576
+ * On an existing class
577
+ * ```ts
578
+ * class Foo { }
579
+ * DI.singleton(Foo);
580
+ * ```
581
+ *
582
+ * @example
583
+ * Inline declaration
584
+ * ```ts
585
+ * const Foo = DI.singleton(class { });
586
+ * // Foo is now strongly typed with register
587
+ * Foo.register(container);
588
+ * ```
589
+ *
590
+ * @public
591
+ */
592
+ singleton(target, options = defaultSingletonOptions) {
593
+ target.register = function register(container) {
594
+ const registration = Registration.singleton(target, target);
595
+ return registration.register(container);
596
+ };
597
+ target.registerInRequestor = options.scoped;
598
+ return target;
599
+ },
600
+ });
601
+ /**
602
+ * The interface key that resolves the dependency injection container itself.
603
+ * @public
604
+ */
605
+ const Container = DI.createInterface("Container");
606
+ /**
607
+ * A decorator that specifies what to inject into its target.
608
+ * @param dependencies - The dependencies to inject.
609
+ * @returns The decorator to be applied to the target class.
610
+ * @remarks
611
+ * The decorator can be used to decorate a class, listing all of the classes dependencies.
612
+ * Or it can be used to decorate a constructor paramter, indicating what to inject for that
613
+ * parameter.
614
+ * Or it can be used for a web component property, indicating what that property should resolve to.
615
+ *
616
+ * @public
617
+ */
618
+ DI.inject;
619
+ const defaultSingletonOptions = { scoped: false };
620
+ /** @internal */
621
+ class ResolverImpl {
622
+ constructor(key, strategy, state) {
623
+ this.key = key;
624
+ this.strategy = strategy;
625
+ this.state = state;
626
+ this.resolving = false;
627
+ }
628
+ get $isResolver() {
629
+ return true;
630
+ }
631
+ register(container) {
632
+ return container.registerResolver(this.key, this);
633
+ }
634
+ resolve(handler, requestor) {
635
+ switch (this.strategy) {
636
+ case 0 /* instance */:
637
+ return this.state;
638
+ case 1 /* singleton */: {
639
+ if (this.resolving) {
640
+ throw new Error(`Cyclic dependency found: ${this.state.name}`);
641
+ }
642
+ this.resolving = true;
643
+ this.state = handler
644
+ .getFactory(this.state)
645
+ .construct(requestor);
646
+ this.strategy = 0 /* instance */;
647
+ this.resolving = false;
648
+ return this.state;
649
+ }
650
+ case 2 /* transient */: {
651
+ // Always create transients from the requesting container
652
+ const factory = handler.getFactory(this.state);
653
+ if (factory === null) {
654
+ throw new Error(`Resolver for ${String(this.key)} returned a null factory`);
655
+ }
656
+ return factory.construct(requestor);
657
+ }
658
+ case 3 /* callback */:
659
+ return this.state(handler, requestor, this);
660
+ case 4 /* array */:
661
+ return this.state[0].resolve(handler, requestor);
662
+ case 5 /* alias */:
663
+ return requestor.get(this.state);
664
+ default:
665
+ throw new Error(`Invalid resolver strategy specified: ${this.strategy}.`);
666
+ }
667
+ }
668
+ getFactory(container) {
669
+ var _a, _b, _c;
670
+ switch (this.strategy) {
671
+ case 1 /* singleton */:
672
+ case 2 /* transient */:
673
+ return container.getFactory(this.state);
674
+ case 5 /* alias */:
675
+ return (_c = (_b = (_a = container.getResolver(this.state)) === null || _a === void 0 ? void 0 : _a.getFactory) === null || _b === void 0 ? void 0 : _b.call(_a, container)) !== null && _c !== void 0 ? _c : null;
676
+ default:
677
+ return null;
678
+ }
679
+ }
680
+ }
681
+ function containerGetKey(d) {
682
+ return this.get(d);
683
+ }
684
+ function transformInstance(inst, transform) {
685
+ return transform(inst);
686
+ }
687
+ /** @internal */
688
+ class FactoryImpl {
689
+ constructor(Type, dependencies) {
690
+ this.Type = Type;
691
+ this.dependencies = dependencies;
692
+ this.transformers = null;
693
+ }
694
+ construct(container, dynamicDependencies) {
695
+ let instance;
696
+ if (dynamicDependencies === void 0) {
697
+ instance = new this.Type(...this.dependencies.map(containerGetKey, container));
698
+ }
699
+ else {
700
+ instance = new this.Type(...this.dependencies.map(containerGetKey, container), ...dynamicDependencies);
701
+ }
702
+ if (this.transformers == null) {
703
+ return instance;
704
+ }
705
+ return this.transformers.reduce(transformInstance, instance);
706
+ }
707
+ registerTransformer(transformer) {
708
+ (this.transformers || (this.transformers = [])).push(transformer);
709
+ }
710
+ }
711
+ const containerResolver = {
712
+ $isResolver: true,
713
+ resolve(handler, requestor) {
714
+ return requestor;
715
+ },
716
+ };
717
+ function isRegistry(obj) {
718
+ return typeof obj.register === "function";
719
+ }
720
+ function isSelfRegistry(obj) {
721
+ return isRegistry(obj) && typeof obj.registerInRequestor === "boolean";
722
+ }
723
+ function isRegisterInRequester(obj) {
724
+ return isSelfRegistry(obj) && obj.registerInRequestor;
725
+ }
726
+ function isClass(obj) {
727
+ return obj.prototype !== void 0;
728
+ }
729
+ const InstrinsicTypeNames = new Set([
730
+ "Array",
731
+ "ArrayBuffer",
732
+ "Boolean",
733
+ "DataView",
734
+ "Date",
735
+ "Error",
736
+ "EvalError",
737
+ "Float32Array",
738
+ "Float64Array",
739
+ "Function",
740
+ "Int8Array",
741
+ "Int16Array",
742
+ "Int32Array",
743
+ "Map",
744
+ "Number",
745
+ "Object",
746
+ "Promise",
747
+ "RangeError",
748
+ "ReferenceError",
749
+ "RegExp",
750
+ "Set",
751
+ "SharedArrayBuffer",
752
+ "String",
753
+ "SyntaxError",
754
+ "TypeError",
755
+ "Uint8Array",
756
+ "Uint8ClampedArray",
757
+ "Uint16Array",
758
+ "Uint32Array",
759
+ "URIError",
760
+ "WeakMap",
761
+ "WeakSet",
762
+ ]);
763
+ const DILocateParentEventType = "__DI_LOCATE_PARENT__";
764
+ const factories = new Map();
765
+ /**
766
+ * @internal
767
+ */
768
+ class ContainerImpl {
769
+ constructor(owner, config) {
770
+ this.owner = owner;
771
+ this.config = config;
772
+ this._parent = void 0;
773
+ this.registerDepth = 0;
774
+ this.context = null;
775
+ if (owner !== null) {
776
+ owner.$$container$$ = this;
777
+ }
778
+ this.resolvers = new Map();
779
+ this.resolvers.set(Container, containerResolver);
780
+ if (owner instanceof Node) {
781
+ owner.addEventListener(DILocateParentEventType, (e) => {
782
+ if (e.composedPath()[0] !== this.owner) {
783
+ e.detail.container = this;
784
+ e.stopImmediatePropagation();
785
+ }
786
+ });
787
+ }
788
+ }
789
+ get parent() {
790
+ if (this._parent === void 0) {
791
+ this._parent = this.config.parentLocator(this.owner);
792
+ }
793
+ return this._parent;
794
+ }
795
+ get depth() {
796
+ return this.parent === null ? 0 : this.parent.depth + 1;
797
+ }
798
+ get responsibleForOwnerRequests() {
799
+ return this.config.responsibleForOwnerRequests;
800
+ }
801
+ registerWithContext(context, ...params) {
802
+ this.context = context;
803
+ this.register(...params);
804
+ this.context = null;
805
+ return this;
806
+ }
807
+ register(...params) {
808
+ if (++this.registerDepth === 100) {
809
+ throw new Error("Unable to autoregister dependency");
810
+ // Most likely cause is trying to register a plain object that does not have a
811
+ // register method and is not a class constructor
812
+ }
813
+ let current;
814
+ let keys;
815
+ let value;
816
+ let j;
817
+ let jj;
818
+ const context = this.context;
819
+ for (let i = 0, ii = params.length; i < ii; ++i) {
820
+ current = params[i];
821
+ if (!isObject(current)) {
822
+ continue;
823
+ }
824
+ if (isRegistry(current)) {
825
+ current.register(this, context);
826
+ }
827
+ else if (isClass(current)) {
828
+ Registration.singleton(current, current).register(this);
829
+ }
830
+ else {
831
+ keys = Object.keys(current);
832
+ j = 0;
833
+ jj = keys.length;
834
+ for (; j < jj; ++j) {
835
+ value = current[keys[j]];
836
+ if (!isObject(value)) {
837
+ continue;
838
+ }
839
+ // note: we could remove this if-branch and call this.register directly
840
+ // - the extra check is just a perf tweak to create fewer unnecessary arrays by the spread operator
841
+ if (isRegistry(value)) {
842
+ value.register(this, context);
843
+ }
844
+ else {
845
+ this.register(value);
846
+ }
847
+ }
848
+ }
849
+ }
850
+ --this.registerDepth;
851
+ return this;
852
+ }
853
+ registerResolver(key, resolver) {
854
+ validateKey(key);
855
+ const resolvers = this.resolvers;
856
+ const result = resolvers.get(key);
857
+ if (result == null) {
858
+ resolvers.set(key, resolver);
859
+ }
860
+ else if (result instanceof ResolverImpl &&
861
+ result.strategy === 4 /* array */) {
862
+ result.state.push(resolver);
863
+ }
864
+ else {
865
+ resolvers.set(key, new ResolverImpl(key, 4 /* array */, [result, resolver]));
866
+ }
867
+ return resolver;
868
+ }
869
+ registerTransformer(key, transformer) {
870
+ const resolver = this.getResolver(key);
871
+ if (resolver == null) {
872
+ return false;
873
+ }
874
+ if (resolver.getFactory) {
875
+ const factory = resolver.getFactory(this);
876
+ if (factory == null) {
877
+ return false;
878
+ }
879
+ // This type cast is a bit of a hacky one, necessary due to the duplicity of IResolverLike.
880
+ // Problem is that that interface's type arg can be of type Key, but the getFactory method only works on
881
+ // type Constructable. So the return type of that optional method has this additional constraint, which
882
+ // seems to confuse the type checker.
883
+ factory.registerTransformer(transformer);
884
+ return true;
885
+ }
886
+ return false;
887
+ }
888
+ getResolver(key, autoRegister = true) {
889
+ validateKey(key);
890
+ if (key.resolve !== void 0) {
891
+ return key;
892
+ }
893
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias */
894
+ let current = this;
895
+ let resolver;
896
+ while (current != null) {
897
+ resolver = current.resolvers.get(key);
898
+ if (resolver == null) {
899
+ if (current.parent == null) {
900
+ const handler = isRegisterInRequester(key)
901
+ ? this
902
+ : current;
903
+ return autoRegister ? this.jitRegister(key, handler) : null;
904
+ }
905
+ current = current.parent;
906
+ }
907
+ else {
908
+ return resolver;
909
+ }
910
+ }
911
+ return null;
912
+ }
913
+ has(key, searchAncestors = false) {
914
+ return this.resolvers.has(key)
915
+ ? true
916
+ : searchAncestors && this.parent != null
917
+ ? this.parent.has(key, true)
918
+ : false;
919
+ }
920
+ get(key) {
921
+ validateKey(key);
922
+ if (key.$isResolver) {
923
+ return key.resolve(this, this);
924
+ }
925
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias */
926
+ let current = this;
927
+ let resolver;
928
+ while (current != null) {
929
+ resolver = current.resolvers.get(key);
930
+ if (resolver == null) {
931
+ if (current.parent == null) {
932
+ const handler = isRegisterInRequester(key)
933
+ ? this
934
+ : current;
935
+ resolver = this.jitRegister(key, handler);
936
+ return resolver.resolve(current, this);
937
+ }
938
+ current = current.parent;
939
+ }
940
+ else {
941
+ return resolver.resolve(current, this);
942
+ }
943
+ }
944
+ throw new Error(`Unable to resolve key: ${String(key)}`);
945
+ }
946
+ getAll(key, searchAncestors = false) {
947
+ validateKey(key);
948
+ /* eslint-disable-next-line @typescript-eslint/no-this-alias */
949
+ const requestor = this;
950
+ let current = requestor;
951
+ let resolver;
952
+ if (searchAncestors) {
953
+ let resolutions = vividElement.emptyArray;
954
+ while (current != null) {
955
+ resolver = current.resolvers.get(key);
956
+ if (resolver != null) {
957
+ resolutions = resolutions.concat(
958
+ /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
959
+ buildAllResponse(resolver, current, requestor));
960
+ }
961
+ current = current.parent;
962
+ }
963
+ return resolutions;
964
+ }
965
+ else {
966
+ while (current != null) {
967
+ resolver = current.resolvers.get(key);
968
+ if (resolver == null) {
969
+ current = current.parent;
970
+ if (current == null) {
971
+ return vividElement.emptyArray;
972
+ }
973
+ }
974
+ else {
975
+ return buildAllResponse(resolver, current, requestor);
976
+ }
977
+ }
978
+ }
979
+ return vividElement.emptyArray;
980
+ }
981
+ getFactory(Type) {
982
+ let factory = factories.get(Type);
983
+ if (factory === void 0) {
984
+ if (isNativeFunction(Type)) {
985
+ throw new Error(`${Type.name} is a native function and therefore cannot be safely constructed by DI. If this is intentional, please use a callback or cachedCallback resolver.`);
986
+ }
987
+ factories.set(Type, (factory = new FactoryImpl(Type, DI.getDependencies(Type))));
988
+ }
989
+ return factory;
990
+ }
991
+ registerFactory(key, factory) {
992
+ factories.set(key, factory);
993
+ }
994
+ createChild(config) {
995
+ return new ContainerImpl(null, Object.assign({}, this.config, config, { parentLocator: () => this }));
996
+ }
997
+ jitRegister(keyAsValue, handler) {
998
+ if (typeof keyAsValue !== "function") {
999
+ throw new Error(`Attempted to jitRegister something that is not a constructor: '${keyAsValue}'. Did you forget to register this dependency?`);
1000
+ }
1001
+ if (InstrinsicTypeNames.has(keyAsValue.name)) {
1002
+ throw new Error(`Attempted to jitRegister an intrinsic type: ${keyAsValue.name}. Did you forget to add @inject(Key)`);
1003
+ }
1004
+ if (isRegistry(keyAsValue)) {
1005
+ const registrationResolver = keyAsValue.register(handler);
1006
+ if (!(registrationResolver instanceof Object) ||
1007
+ registrationResolver.resolve == null) {
1008
+ const newResolver = handler.resolvers.get(keyAsValue);
1009
+ if (newResolver != void 0) {
1010
+ return newResolver;
1011
+ }
1012
+ throw new Error("A valid resolver was not returned from the static register method");
1013
+ }
1014
+ return registrationResolver;
1015
+ }
1016
+ else if (keyAsValue.$isInterface) {
1017
+ throw new Error(`Attempted to jitRegister an interface: ${keyAsValue.friendlyName}`);
1018
+ }
1019
+ else {
1020
+ const resolver = this.config.defaultResolver(keyAsValue, handler);
1021
+ handler.resolvers.set(keyAsValue, resolver);
1022
+ return resolver;
1023
+ }
1024
+ }
1025
+ }
1026
+ const cache = new WeakMap();
1027
+ function cacheCallbackResult(fun) {
1028
+ return function (handler, requestor, resolver) {
1029
+ if (cache.has(resolver)) {
1030
+ return cache.get(resolver);
1031
+ }
1032
+ const t = fun(handler, requestor, resolver);
1033
+ cache.set(resolver, t);
1034
+ return t;
1035
+ };
1036
+ }
1037
+ /**
1038
+ * You can use the resulting Registration of any of the factory methods
1039
+ * to register with the container.
1040
+ *
1041
+ * @example
1042
+ * ```
1043
+ * class Foo {}
1044
+ * const container = DI.createContainer();
1045
+ * container.register(Registration.instance(Foo, new Foo()));
1046
+ * container.get(Foo);
1047
+ * ```
1048
+ *
1049
+ * @public
1050
+ */
1051
+ const Registration = Object.freeze({
1052
+ /**
1053
+ * Allows you to pass an instance.
1054
+ * Every time you request this {@link Key} you will get this instance back.
1055
+ *
1056
+ * @example
1057
+ * ```
1058
+ * Registration.instance(Foo, new Foo()));
1059
+ * ```
1060
+ *
1061
+ * @param key - The key to register the instance under.
1062
+ * @param value - The instance to return when the key is requested.
1063
+ */
1064
+ instance(key, value) {
1065
+ return new ResolverImpl(key, 0 /* instance */, value);
1066
+ },
1067
+ /**
1068
+ * Creates an instance from the class.
1069
+ * Every time you request this {@link Key} you will get the same one back.
1070
+ *
1071
+ * @example
1072
+ * ```
1073
+ * Registration.singleton(Foo, Foo);
1074
+ * ```
1075
+ *
1076
+ * @param key - The key to register the singleton under.
1077
+ * @param value - The class to instantiate as a singleton when first requested.
1078
+ */
1079
+ singleton(key, value) {
1080
+ return new ResolverImpl(key, 1 /* singleton */, value);
1081
+ },
1082
+ /**
1083
+ * Creates an instance from a class.
1084
+ * Every time you request this {@link Key} you will get a new instance.
1085
+ *
1086
+ * @example
1087
+ * ```
1088
+ * Registration.instance(Foo, Foo);
1089
+ * ```
1090
+ *
1091
+ * @param key - The key to register the instance type under.
1092
+ * @param value - The class to instantiate each time the key is requested.
1093
+ */
1094
+ transient(key, value) {
1095
+ return new ResolverImpl(key, 2 /* transient */, value);
1096
+ },
1097
+ /**
1098
+ * Delegates to a callback function to provide the dependency.
1099
+ * Every time you request this {@link Key} the callback will be invoked to provide
1100
+ * the dependency.
1101
+ *
1102
+ * @example
1103
+ * ```
1104
+ * Registration.callback(Foo, () => new Foo());
1105
+ * Registration.callback(Bar, (c: Container) => new Bar(c.get(Foo)));
1106
+ * ```
1107
+ *
1108
+ * @param key - The key to register the callback for.
1109
+ * @param callback - The function that is expected to return the dependency.
1110
+ */
1111
+ callback(key, callback) {
1112
+ return new ResolverImpl(key, 3 /* callback */, callback);
1113
+ },
1114
+ /**
1115
+ * Delegates to a callback function to provide the dependency and then caches the
1116
+ * dependency for future requests.
1117
+ *
1118
+ * @example
1119
+ * ```
1120
+ * Registration.cachedCallback(Foo, () => new Foo());
1121
+ * Registration.cachedCallback(Bar, (c: Container) => new Bar(c.get(Foo)));
1122
+ * ```
1123
+ *
1124
+ * @param key - The key to register the callback for.
1125
+ * @param callback - The function that is expected to return the dependency.
1126
+ * @remarks
1127
+ * If you pass the same Registration to another container, the same cached value will be used.
1128
+ * Should all references to the resolver returned be removed, the cache will expire.
1129
+ */
1130
+ cachedCallback(key, callback) {
1131
+ return new ResolverImpl(key, 3 /* callback */, cacheCallbackResult(callback));
1132
+ },
1133
+ /**
1134
+ * Creates an alternate {@link Key} to retrieve an instance by.
1135
+ *
1136
+ * @example
1137
+ * ```
1138
+ * Register.singleton(Foo, Foo)
1139
+ * Register.aliasTo(Foo, MyFoos);
1140
+ *
1141
+ * container.getAll(MyFoos) // contains an instance of Foo
1142
+ * ```
1143
+ *
1144
+ * @param originalKey - The original key that has been registered.
1145
+ * @param aliasKey - The alias to the original key.
1146
+ */
1147
+ aliasTo(originalKey, aliasKey) {
1148
+ return new ResolverImpl(aliasKey, 5 /* alias */, originalKey);
1149
+ },
1150
+ });
1151
+ /** @internal */
1152
+ function validateKey(key) {
1153
+ if (key === null || key === void 0) {
1154
+ throw new Error("key/value cannot be null or undefined. Are you trying to inject/register something that doesn't exist with DI?");
1155
+ }
1156
+ }
1157
+ function buildAllResponse(resolver, handler, requestor) {
1158
+ if (resolver instanceof ResolverImpl &&
1159
+ resolver.strategy === 4 /* array */) {
1160
+ const state = resolver.state;
1161
+ let i = state.length;
1162
+ const results = new Array(i);
1163
+ while (i--) {
1164
+ results[i] = state[i].resolve(handler, requestor);
1165
+ }
1166
+ return results;
1167
+ }
1168
+ return [resolver.resolve(handler, requestor)];
1169
+ }
1170
+ const defaultFriendlyName = "(anonymous)";
1171
+ function isObject(value) {
1172
+ return (typeof value === "object" && value !== null) || typeof value === "function";
1173
+ }
1174
+ /**
1175
+ * Determine whether the value is a native function.
1176
+ *
1177
+ * @param fn - The function to check.
1178
+ * @returns `true` is the function is a native function, otherwise `false`
1179
+ */
1180
+ const isNativeFunction = (function () {
1181
+ const lookup = new WeakMap();
1182
+ let isNative = false;
1183
+ let sourceText = "";
1184
+ let i = 0;
1185
+ return function (fn) {
1186
+ isNative = lookup.get(fn);
1187
+ if (isNative === void 0) {
1188
+ sourceText = fn.toString();
1189
+ i = sourceText.length;
1190
+ // http://www.ecma-international.org/ecma-262/#prod-NativeFunction
1191
+ isNative =
1192
+ // 29 is the length of 'function () { [native code] }' which is the smallest length of a native function string
1193
+ i >= 29 &&
1194
+ // 100 seems to be a safe upper bound of the max length of a native function. In Chrome and FF it's 56, in Edge it's 61.
1195
+ i <= 100 &&
1196
+ // This whole heuristic *could* be tricked by a comment. Do we need to care about that?
1197
+ sourceText.charCodeAt(i - 1) === 0x7d && // }
1198
+ // TODO: the spec is a little vague about the precise constraints, so we do need to test this across various browsers to make sure just one whitespace is a safe assumption.
1199
+ sourceText.charCodeAt(i - 2) <= 0x20 && // whitespace
1200
+ sourceText.charCodeAt(i - 3) === 0x5d && // ]
1201
+ sourceText.charCodeAt(i - 4) === 0x65 && // e
1202
+ sourceText.charCodeAt(i - 5) === 0x64 && // d
1203
+ sourceText.charCodeAt(i - 6) === 0x6f && // o
1204
+ sourceText.charCodeAt(i - 7) === 0x63 && // c
1205
+ sourceText.charCodeAt(i - 8) === 0x20 && //
1206
+ sourceText.charCodeAt(i - 9) === 0x65 && // e
1207
+ sourceText.charCodeAt(i - 10) === 0x76 && // v
1208
+ sourceText.charCodeAt(i - 11) === 0x69 && // i
1209
+ sourceText.charCodeAt(i - 12) === 0x74 && // t
1210
+ sourceText.charCodeAt(i - 13) === 0x61 && // a
1211
+ sourceText.charCodeAt(i - 14) === 0x6e && // n
1212
+ sourceText.charCodeAt(i - 15) === 0x58; // [
1213
+ lookup.set(fn, isNative);
1214
+ }
1215
+ return isNative;
1216
+ };
1217
+ })();
1218
+ const isNumericLookup = {};
1219
+ function isArrayIndex(value) {
1220
+ switch (typeof value) {
1221
+ case "number":
1222
+ return value >= 0 && (value | 0) === value;
1223
+ case "string": {
1224
+ const result = isNumericLookup[value];
1225
+ if (result !== void 0) {
1226
+ return result;
1227
+ }
1228
+ const length = value.length;
1229
+ if (length === 0) {
1230
+ return (isNumericLookup[value] = false);
1231
+ }
1232
+ let ch = 0;
1233
+ for (let i = 0; i < length; ++i) {
1234
+ ch = value.charCodeAt(i);
1235
+ if ((i === 0 && ch === 0x30 && length > 1) /* must not start with 0 */ ||
1236
+ ch < 0x30 /* 0 */ ||
1237
+ ch > 0x39 /* 9 */) {
1238
+ return (isNumericLookup[value] = false);
1239
+ }
1240
+ }
1241
+ return (isNumericLookup[value] = true);
1242
+ }
1243
+ default:
1244
+ return false;
1245
+ }
1246
+ }
1247
+
1248
+ function presentationKeyFromTag(tagName) {
1249
+ return `${tagName.toLowerCase()}:presentation`;
1250
+ }
1251
+ const presentationRegistry = new Map();
1252
+ /**
1253
+ * An API gateway to component presentation features.
1254
+ * @public
1255
+ */
1256
+ const ComponentPresentation = Object.freeze({
1257
+ /**
1258
+ * Defines a component presentation for an element.
1259
+ * @param tagName - The element name to define the presentation for.
1260
+ * @param presentation - The presentation that will be applied to matching elements.
1261
+ * @param container - The dependency injection container to register the configuration in.
1262
+ * @public
1263
+ */
1264
+ define(tagName, presentation, container) {
1265
+ const key = presentationKeyFromTag(tagName);
1266
+ const existing = presentationRegistry.get(key);
1267
+ if (existing === void 0) {
1268
+ presentationRegistry.set(key, presentation);
1269
+ }
1270
+ else {
1271
+ // false indicates that we have more than one presentation
1272
+ // registered for a tagName and we must resolve through DI
1273
+ presentationRegistry.set(key, false);
1274
+ }
1275
+ container.register(Registration.instance(key, presentation));
1276
+ },
1277
+ /**
1278
+ * Finds a component presentation for the specified element name,
1279
+ * searching the DOM hierarchy starting from the provided element.
1280
+ * @param tagName - The name of the element to locate the presentation for.
1281
+ * @param element - The element to begin the search from.
1282
+ * @returns The component presentation or null if none is found.
1283
+ * @public
1284
+ */
1285
+ forTag(tagName, element) {
1286
+ const key = presentationKeyFromTag(tagName);
1287
+ const existing = presentationRegistry.get(key);
1288
+ if (existing === false) {
1289
+ const container = DI.findResponsibleContainer(element);
1290
+ return container.get(key);
1291
+ }
1292
+ return existing || null;
1293
+ },
1294
+ });
1295
+ /**
1296
+ * The default implementation of ComponentPresentation, used by FoundationElement.
1297
+ * @public
1298
+ */
1299
+ class DefaultComponentPresentation {
1300
+ /**
1301
+ * Creates an instance of DefaultComponentPresentation.
1302
+ * @param template - The template to apply to the element.
1303
+ * @param styles - The styles to apply to the element.
1304
+ * @public
1305
+ */
1306
+ constructor(template, styles) {
1307
+ this.template = template || null;
1308
+ this.styles =
1309
+ styles === void 0
1310
+ ? null
1311
+ : Array.isArray(styles)
1312
+ ? vividElement.ElementStyles.create(styles)
1313
+ : styles instanceof vividElement.ElementStyles
1314
+ ? styles
1315
+ : vividElement.ElementStyles.create([styles]);
1316
+ }
1317
+ /**
1318
+ * Applies the presentation details to the specified element.
1319
+ * @param element - The element to apply the presentation details to.
1320
+ * @public
1321
+ */
1322
+ applyTo(element) {
1323
+ const controller = element.$fastController;
1324
+ if (controller.template === null) {
1325
+ controller.template = this.template;
1326
+ }
1327
+ if (controller.styles === null) {
1328
+ controller.styles = this.styles;
1329
+ }
1330
+ }
1331
+ }
1332
+
1333
+ /**
1334
+ * Defines a foundation element class that:
1335
+ * 1. Connects the element to its ComponentPresentation
1336
+ * 2. Allows resolving the element template from the instance or ComponentPresentation
1337
+ * 3. Allows resolving the element styles from the instance or ComponentPresentation
1338
+ *
1339
+ * @public
1340
+ */
1341
+ class FoundationElement extends vividElement.FASTElement {
1342
+ constructor() {
1343
+ super(...arguments);
1344
+ this._presentation = void 0;
1345
+ }
1346
+ /**
1347
+ * A property which resolves the ComponentPresentation instance
1348
+ * for the current component.
1349
+ * @public
1350
+ */
1351
+ get $presentation() {
1352
+ if (this._presentation === void 0) {
1353
+ this._presentation = ComponentPresentation.forTag(this.tagName, this);
1354
+ }
1355
+ return this._presentation;
1356
+ }
1357
+ templateChanged() {
1358
+ if (this.template !== undefined) {
1359
+ this.$fastController.template = this.template;
1360
+ }
1361
+ }
1362
+ stylesChanged() {
1363
+ if (this.styles !== undefined) {
1364
+ this.$fastController.styles = this.styles;
1365
+ }
1366
+ }
1367
+ /**
1368
+ * The connected callback for this FASTElement.
1369
+ * @remarks
1370
+ * This method is invoked by the platform whenever this FoundationElement
1371
+ * becomes connected to the document.
1372
+ * @public
1373
+ */
1374
+ connectedCallback() {
1375
+ if (this.$presentation !== null) {
1376
+ this.$presentation.applyTo(this);
1377
+ }
1378
+ super.connectedCallback();
1379
+ }
1380
+ /**
1381
+ * Defines an element registry function with a set of element definition defaults.
1382
+ * @param elementDefinition - The definition of the element to create the registry
1383
+ * function for.
1384
+ * @public
1385
+ */
1386
+ static compose(elementDefinition) {
1387
+ return (overrideDefinition = {}) => new FoundationElementRegistry(this === FoundationElement
1388
+ ? class extends FoundationElement {
1389
+ }
1390
+ : this, elementDefinition, overrideDefinition);
1391
+ }
1392
+ }
1393
+ __decorate([
1394
+ vividElement.observable
1395
+ ], FoundationElement.prototype, "template", void 0);
1396
+ __decorate([
1397
+ vividElement.observable
1398
+ ], FoundationElement.prototype, "styles", void 0);
1399
+ function resolveOption(option, context, definition) {
1400
+ if (typeof option === "function") {
1401
+ return option(context, definition);
1402
+ }
1403
+ return option;
1404
+ }
1405
+ /**
1406
+ * Registry capable of defining presentation properties for a DOM Container hierarchy.
1407
+ *
1408
+ * @internal
1409
+ */
1410
+ /* eslint-disable @typescript-eslint/no-unused-vars */
1411
+ class FoundationElementRegistry {
1412
+ constructor(type, elementDefinition, overrideDefinition) {
1413
+ this.type = type;
1414
+ this.elementDefinition = elementDefinition;
1415
+ this.overrideDefinition = overrideDefinition;
1416
+ this.definition = Object.assign(Object.assign({}, this.elementDefinition), this.overrideDefinition);
1417
+ }
1418
+ register(container, context) {
1419
+ const definition = this.definition;
1420
+ const overrideDefinition = this.overrideDefinition;
1421
+ const prefix = definition.prefix || context.elementPrefix;
1422
+ const name = `${prefix}-${definition.baseName}`;
1423
+ context.tryDefineElement({
1424
+ name,
1425
+ type: this.type,
1426
+ baseClass: this.elementDefinition.baseClass,
1427
+ callback: x => {
1428
+ const presentation = new DefaultComponentPresentation(resolveOption(definition.template, x, definition), resolveOption(definition.styles, x, definition));
1429
+ x.definePresentation(presentation);
1430
+ let shadowOptions = resolveOption(definition.shadowOptions, x, definition);
1431
+ if (x.shadowRootMode) {
1432
+ // If the design system has overridden the shadow root mode, we need special handling.
1433
+ if (shadowOptions) {
1434
+ // If there are shadow options present in the definition, then
1435
+ // either the component itself has specified an option or the
1436
+ // registry function has overridden it.
1437
+ if (!overrideDefinition.shadowOptions) {
1438
+ // There were shadow options provided by the component and not overridden by
1439
+ // the registry.
1440
+ shadowOptions.mode = x.shadowRootMode;
1441
+ }
1442
+ }
1443
+ else if (shadowOptions !== null) {
1444
+ // If the component author did not provide shadow options,
1445
+ // and did not null them out (light dom opt-in) then they
1446
+ // were relying on the FASTElement default. So, if the
1447
+ // design system provides a mode, we need to create the options
1448
+ // to override the default.
1449
+ shadowOptions = { mode: x.shadowRootMode };
1450
+ }
1451
+ }
1452
+ x.defineElement({
1453
+ elementOptions: resolveOption(definition.elementOptions, x, definition),
1454
+ shadowOptions,
1455
+ attributes: resolveOption(definition.attributes, x, definition),
1456
+ });
1457
+ },
1458
+ });
1459
+ }
1460
+ }
1461
+ /* eslint-enable @typescript-eslint/no-unused-vars */
1462
+
3
1463
  /**
4
1464
  * Key Code values
5
1465
  * @deprecated - KeyCodes are deprecated, use individual string key exports
@@ -87,12 +1547,12 @@ const keyEnter = "Enter";
87
1547
  const keyEscape = "Escape";
88
1548
  const keyHome = "Home";
89
1549
  const keyEnd = "End";
90
- const keyFunction2 = "F2";
91
- const keyPageDown = "PageDown";
92
- const keyPageUp = "PageUp";
93
1550
  const keySpace = " ";
94
1551
  const keyTab = "Tab";
95
1552
 
1553
+ exports.FoundationElement = FoundationElement;
1554
+ exports.StartEnd = StartEnd;
1555
+ exports.__decorate = __decorate;
96
1556
  exports.keyArrowDown = keyArrowDown;
97
1557
  exports.keyArrowLeft = keyArrowLeft;
98
1558
  exports.keyArrowRight = keyArrowRight;
@@ -100,9 +1560,6 @@ exports.keyArrowUp = keyArrowUp;
100
1560
  exports.keyEnd = keyEnd;
101
1561
  exports.keyEnter = keyEnter;
102
1562
  exports.keyEscape = keyEscape;
103
- exports.keyFunction2 = keyFunction2;
104
1563
  exports.keyHome = keyHome;
105
- exports.keyPageDown = keyPageDown;
106
- exports.keyPageUp = keyPageUp;
107
1564
  exports.keySpace = keySpace;
108
1565
  exports.keyTab = keyTab;