@nectary/components 4.12.1 → 5.0.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 (585) hide show
  1. package/accordion/global/index.d.ts +1 -0
  2. package/accordion/global/index.js +2 -0
  3. package/accordion/index.d.ts +1 -22
  4. package/accordion/index.js +41 -39
  5. package/accordion/types.d.ts +21 -1
  6. package/accordion/types.js +1 -1
  7. package/accordion-item/global/index.d.ts +1 -0
  8. package/accordion-item/global/index.js +2 -0
  9. package/accordion-item/index.d.ts +2 -22
  10. package/accordion-item/index.js +53 -49
  11. package/accordion-item/types.d.ts +21 -1
  12. package/accordion-item/types.js +1 -1
  13. package/accordion-item/utils.js +4 -1
  14. package/action-menu/global/index.d.ts +1 -0
  15. package/action-menu/global/index.js +2 -0
  16. package/action-menu/index.d.ts +1 -22
  17. package/action-menu/index.js +62 -77
  18. package/action-menu/types.d.ts +21 -1
  19. package/action-menu/types.js +1 -1
  20. package/action-menu-option/global/index.d.ts +1 -0
  21. package/action-menu-option/global/index.js +2 -0
  22. package/action-menu-option/index.d.ts +1 -22
  23. package/action-menu-option/index.js +39 -41
  24. package/action-menu-option/types.d.ts +21 -1
  25. package/action-menu-option/types.js +1 -1
  26. package/action-menu-option/utils.js +6 -3
  27. package/alert/global/index.d.ts +1 -0
  28. package/alert/global/index.js +2 -0
  29. package/alert/index.d.ts +2 -22
  30. package/alert/index.js +24 -21
  31. package/alert/types.d.ts +21 -1
  32. package/alert/types.js +1 -1
  33. package/alert/utils.js +4 -1
  34. package/avatar/colors.js +1 -1
  35. package/avatar/global/index.d.ts +1 -0
  36. package/avatar/global/index.js +2 -0
  37. package/avatar/index.d.ts +2 -22
  38. package/avatar/index.js +42 -41
  39. package/avatar/types.d.ts +21 -1
  40. package/avatar/types.js +1 -1
  41. package/avatar/utils.js +9 -4
  42. package/badge/global/index.d.ts +1 -0
  43. package/badge/global/index.js +2 -0
  44. package/badge/index.d.ts +3 -22
  45. package/badge/index.js +52 -51
  46. package/badge/types.d.ts +21 -1
  47. package/badge/types.js +1 -1
  48. package/badge/utils.js +4 -1
  49. package/bundle.d.ts +78 -0
  50. package/bundle.js +13033 -0
  51. package/bundle.ts +80 -0
  52. package/button/global/index.d.ts +1 -0
  53. package/button/global/index.js +2 -0
  54. package/button/index.d.ts +2 -22
  55. package/button/index.js +101 -111
  56. package/button/types.d.ts +21 -1
  57. package/button/types.js +1 -1
  58. package/button/utils.js +18 -2
  59. package/button-group/global/index.d.ts +1 -0
  60. package/button-group/global/index.js +2 -0
  61. package/button-group/index.d.ts +1 -22
  62. package/button-group/index.js +20 -18
  63. package/button-group/types.d.ts +22 -3
  64. package/button-group/types.js +1 -1
  65. package/button-group-item/global/index.d.ts +1 -0
  66. package/button-group-item/global/index.js +2 -0
  67. package/button-group-item/index.d.ts +2 -22
  68. package/button-group-item/index.js +31 -42
  69. package/button-group-item/types.d.ts +22 -3
  70. package/button-group-item/types.js +1 -1
  71. package/card-container/global/index.d.ts +1 -0
  72. package/card-container/global/index.js +2 -0
  73. package/card-container/index.d.ts +1 -21
  74. package/card-container/index.js +8 -5
  75. package/card-container/types.d.ts +21 -1
  76. package/card-container/types.js +1 -1
  77. package/card-v2/global/index.d.ts +1 -0
  78. package/card-v2/global/index.js +2 -0
  79. package/card-v2/index.d.ts +1 -22
  80. package/card-v2/index.js +59 -57
  81. package/card-v2/types.d.ts +21 -1
  82. package/card-v2/types.js +1 -1
  83. package/card-v2-title/global/index.d.ts +1 -0
  84. package/card-v2-title/global/index.js +2 -0
  85. package/card-v2-title/index.d.ts +2 -22
  86. package/card-v2-title/index.js +28 -26
  87. package/card-v2-title/types.d.ts +21 -1
  88. package/card-v2-title/types.js +1 -1
  89. package/checkbox/global/index.d.ts +1 -0
  90. package/checkbox/global/index.js +2 -0
  91. package/checkbox/index.d.ts +1 -22
  92. package/checkbox/index.js +88 -81
  93. package/checkbox/types.d.ts +21 -1
  94. package/checkbox/types.js +1 -1
  95. package/chip/colors.js +1 -1
  96. package/chip/global/index.d.ts +1 -0
  97. package/chip/global/index.js +2 -0
  98. package/chip/index.d.ts +1 -22
  99. package/chip/index.js +62 -75
  100. package/chip/types.d.ts +21 -1
  101. package/chip/types.js +1 -1
  102. package/chip/utils.js +7 -3
  103. package/code-tag/global/index.d.ts +1 -0
  104. package/code-tag/global/index.js +2 -0
  105. package/code-tag/index.d.ts +1 -22
  106. package/code-tag/index.js +17 -14
  107. package/code-tag/types.d.ts +21 -1
  108. package/code-tag/types.js +1 -1
  109. package/color-menu/global/index.d.ts +1 -0
  110. package/color-menu/global/index.js +2 -0
  111. package/color-menu/index.d.ts +2 -22
  112. package/color-menu/index.js +115 -115
  113. package/color-menu/types.d.ts +21 -1
  114. package/color-menu/types.js +1 -1
  115. package/color-menu/utils.js +6 -3
  116. package/color-menu-option/global/index.d.ts +1 -0
  117. package/color-menu-option/global/index.js +2 -0
  118. package/color-menu-option/index.d.ts +1 -22
  119. package/color-menu-option/index.js +30 -26
  120. package/color-menu-option/types.d.ts +21 -1
  121. package/color-menu-option/types.js +1 -1
  122. package/color-menu-option/utils.js +6 -3
  123. package/color-swatch/global/index.d.ts +1 -0
  124. package/color-swatch/global/index.js +2 -0
  125. package/color-swatch/index.d.ts +1 -22
  126. package/color-swatch/index.js +23 -20
  127. package/color-swatch/types.d.ts +21 -1
  128. package/color-swatch/types.js +1 -1
  129. package/color-swatch/utils.js +7 -3
  130. package/date-picker/global/index.d.ts +1 -0
  131. package/date-picker/global/index.js +2 -0
  132. package/date-picker/index.d.ts +2 -22
  133. package/date-picker/index.js +157 -150
  134. package/date-picker/types.d.ts +21 -1
  135. package/date-picker/types.js +1 -1
  136. package/date-picker/utils.js +59 -42
  137. package/dialog/global/index.d.ts +1 -0
  138. package/dialog/global/index.js +2 -0
  139. package/dialog/index.d.ts +1 -22
  140. package/dialog/index.js +71 -58
  141. package/dialog/types.d.ts +21 -1
  142. package/dialog/types.js +1 -1
  143. package/dialog/utils.js +11 -7
  144. package/emoji/global/index.d.ts +1 -0
  145. package/emoji/global/index.js +2 -0
  146. package/emoji/index.d.ts +1 -22
  147. package/emoji/index.js +19 -16
  148. package/emoji/types.d.ts +21 -1
  149. package/emoji/types.js +1 -1
  150. package/emoji/utils.js +22 -17
  151. package/emoji-picker/global/index.d.ts +1 -0
  152. package/emoji-picker/global/index.js +2 -0
  153. package/emoji-picker/index.d.ts +2 -22
  154. package/emoji-picker/index.js +138 -118
  155. package/emoji-picker/types.d.ts +21 -1
  156. package/emoji-picker/types.js +1 -1
  157. package/field/global/index.d.ts +1 -0
  158. package/field/global/index.js +2 -0
  159. package/field/index.d.ts +1 -22
  160. package/field/index.js +63 -60
  161. package/field/types.d.ts +21 -1
  162. package/field/types.js +1 -1
  163. package/file-drop/global/index.d.ts +1 -0
  164. package/file-drop/global/index.js +2 -0
  165. package/file-drop/index.d.ts +1 -22
  166. package/file-drop/index.js +103 -98
  167. package/file-drop/types.d.ts +21 -1
  168. package/file-drop/types.js +1 -1
  169. package/file-drop/utils.js +27 -22
  170. package/file-picker/global/index.d.ts +1 -0
  171. package/file-picker/global/index.js +2 -0
  172. package/file-picker/index.d.ts +1 -22
  173. package/file-picker/index.js +53 -48
  174. package/file-picker/types.d.ts +21 -1
  175. package/file-picker/types.js +1 -1
  176. package/file-picker/utils.js +6 -3
  177. package/file-status/global/index.d.ts +1 -0
  178. package/file-status/global/index.js +2 -0
  179. package/file-status/index.d.ts +2 -22
  180. package/file-status/index.js +33 -22
  181. package/file-status/types.d.ts +21 -1
  182. package/file-status/types.js +1 -1
  183. package/file-status/utils.js +4 -1
  184. package/flag/global/index.d.ts +1 -0
  185. package/flag/global/index.js +2 -0
  186. package/flag/index.d.ts +1 -22
  187. package/flag/index.js +19 -16
  188. package/flag/types.d.ts +21 -1
  189. package/flag/types.js +1 -1
  190. package/flag/utils.js +11 -8
  191. package/grid/global/index.d.ts +1 -0
  192. package/grid/global/index.js +2 -0
  193. package/grid/index.d.ts +1 -22
  194. package/grid/index.js +8 -5
  195. package/grid/types.d.ts +21 -1
  196. package/grid/types.js +1 -1
  197. package/grid-item/global/index.d.ts +1 -0
  198. package/grid-item/global/index.js +2 -0
  199. package/grid-item/index.d.ts +1 -22
  200. package/grid-item/index.js +17 -13
  201. package/grid-item/types.d.ts +21 -1
  202. package/grid-item/types.js +1 -1
  203. package/help-tooltip/global/index.d.ts +1 -0
  204. package/help-tooltip/global/index.js +2 -0
  205. package/help-tooltip/index.d.ts +1 -22
  206. package/help-tooltip/index.js +29 -26
  207. package/help-tooltip/types.d.ts +21 -1
  208. package/help-tooltip/types.js +1 -1
  209. package/icon/generated-icon-type.js +1 -1
  210. package/icon/global/index.d.ts +1 -0
  211. package/icon/global/index.js +2 -0
  212. package/icon/index.d.ts +1 -22
  213. package/icon/index.js +30 -28
  214. package/icon/types.d.ts +21 -1
  215. package/icon/types.js +1 -1
  216. package/inline-alert/global/index.d.ts +1 -0
  217. package/inline-alert/global/index.js +2 -0
  218. package/inline-alert/index.d.ts +2 -22
  219. package/inline-alert/index.js +58 -39
  220. package/inline-alert/types.d.ts +21 -1
  221. package/inline-alert/types.js +1 -1
  222. package/inline-alert/utils.js +4 -1
  223. package/input/global/index.d.ts +1 -0
  224. package/input/global/index.js +2 -0
  225. package/input/index.d.ts +2 -22
  226. package/input/index.js +295 -317
  227. package/input/types.d.ts +21 -1
  228. package/input/types.js +1 -1
  229. package/input/utils.js +56 -46
  230. package/link/global/index.d.ts +1 -0
  231. package/link/global/index.js +2 -0
  232. package/link/index.d.ts +1 -22
  233. package/link/index.js +88 -79
  234. package/link/types.d.ts +21 -1
  235. package/link/types.js +1 -1
  236. package/list/global/index.d.ts +1 -0
  237. package/list/global/index.js +2 -0
  238. package/list/index.d.ts +1 -21
  239. package/list/index.js +9 -6
  240. package/list/types.d.ts +21 -1
  241. package/list/types.js +1 -1
  242. package/list-item/global/index.d.ts +1 -0
  243. package/list-item/global/index.js +2 -0
  244. package/list-item/index.d.ts +1 -22
  245. package/list-item/index.js +9 -6
  246. package/list-item/types.d.ts +21 -1
  247. package/list-item/types.js +1 -1
  248. package/package.json +12 -6
  249. package/pagination/global/index.d.ts +1 -0
  250. package/pagination/global/index.js +2 -0
  251. package/pagination/index.d.ts +2 -22
  252. package/pagination/index.js +64 -46
  253. package/pagination/types.d.ts +21 -1
  254. package/pagination/types.js +1 -1
  255. package/persistent-overlay/global/index.d.ts +1 -0
  256. package/persistent-overlay/global/index.js +2 -0
  257. package/persistent-overlay/index.d.ts +1 -22
  258. package/persistent-overlay/index.js +42 -44
  259. package/persistent-overlay/types.d.ts +21 -1
  260. package/persistent-overlay/types.js +1 -1
  261. package/pop/global/index.d.ts +1 -0
  262. package/pop/global/index.js +2 -0
  263. package/pop/index.d.ts +3 -22
  264. package/pop/index.js +149 -150
  265. package/pop/types.d.ts +21 -1
  266. package/pop/types.js +1 -1
  267. package/pop/utils.js +24 -8
  268. package/popover/global/index.d.ts +1 -0
  269. package/popover/global/index.js +2 -0
  270. package/popover/index.d.ts +2 -22
  271. package/popover/index.js +75 -68
  272. package/popover/types.d.ts +21 -1
  273. package/popover/types.js +1 -1
  274. package/popover/utils.js +18 -7
  275. package/progress/global/index.d.ts +1 -0
  276. package/progress/global/index.js +2 -0
  277. package/progress/index.d.ts +1 -22
  278. package/progress/index.js +30 -33
  279. package/progress/types.d.ts +21 -1
  280. package/progress/types.js +1 -1
  281. package/progress-stepper/global/index.d.ts +1 -0
  282. package/progress-stepper/global/index.js +2 -0
  283. package/progress-stepper/index.d.ts +2 -22
  284. package/progress-stepper/index.js +64 -66
  285. package/progress-stepper/types.d.ts +21 -1
  286. package/progress-stepper/types.js +1 -1
  287. package/progress-stepper-item/global/index.d.ts +1 -0
  288. package/progress-stepper-item/global/index.js +2 -0
  289. package/progress-stepper-item/index.d.ts +1 -22
  290. package/progress-stepper-item/index.js +58 -50
  291. package/progress-stepper-item/types.d.ts +21 -1
  292. package/progress-stepper-item/types.js +1 -1
  293. package/progress-stepper-item/utils.js +22 -11
  294. package/radio/global/index.d.ts +1 -0
  295. package/radio/global/index.js +2 -0
  296. package/radio/index.d.ts +1 -22
  297. package/radio/index.js +79 -83
  298. package/radio/types.d.ts +21 -1
  299. package/radio/types.js +1 -1
  300. package/radio-option/global/index.d.ts +1 -0
  301. package/radio-option/global/index.js +2 -0
  302. package/radio-option/index.d.ts +1 -22
  303. package/radio-option/index.js +47 -41
  304. package/radio-option/types.d.ts +21 -1
  305. package/radio-option/types.js +1 -1
  306. package/rich-text/global/index.d.ts +1 -0
  307. package/rich-text/global/index.js +2 -0
  308. package/rich-text/index.d.ts +1 -22
  309. package/rich-text/index.js +45 -46
  310. package/rich-text/types.d.ts +21 -1
  311. package/rich-text/types.js +1 -1
  312. package/rich-text/utils.js +31 -33
  313. package/rich-textarea/global/index.d.ts +1 -0
  314. package/rich-textarea/global/index.js +2 -0
  315. package/rich-textarea/index.d.ts +1 -22
  316. package/rich-textarea/index.js +201 -194
  317. package/rich-textarea/types.d.ts +21 -1
  318. package/rich-textarea/types.js +1 -1
  319. package/rich-textarea/utils.js +313 -340
  320. package/segment-collapse/global/index.d.ts +1 -0
  321. package/segment-collapse/global/index.js +2 -0
  322. package/segment-collapse/index.d.ts +1 -22
  323. package/segment-collapse/index.js +31 -25
  324. package/segment-collapse/types.d.ts +21 -1
  325. package/segment-collapse/types.js +1 -1
  326. package/segmented-control/global/index.d.ts +1 -0
  327. package/segmented-control/global/index.js +2 -0
  328. package/segmented-control/index.d.ts +1 -22
  329. package/segmented-control/index.js +45 -45
  330. package/segmented-control/types.d.ts +21 -1
  331. package/segmented-control/types.js +1 -1
  332. package/segmented-control-option/global/index.d.ts +1 -0
  333. package/segmented-control-option/global/index.js +2 -0
  334. package/segmented-control-option/index.d.ts +1 -22
  335. package/segmented-control-option/index.js +44 -46
  336. package/segmented-control-option/types.d.ts +21 -1
  337. package/segmented-control-option/types.js +1 -1
  338. package/segmented-icon-control/global/index.d.ts +1 -0
  339. package/segmented-icon-control/global/index.js +2 -0
  340. package/segmented-icon-control/index.d.ts +1 -22
  341. package/segmented-icon-control/index.js +51 -50
  342. package/segmented-icon-control/types.d.ts +21 -1
  343. package/segmented-icon-control/types.js +1 -1
  344. package/segmented-icon-control-option/global/index.d.ts +1 -0
  345. package/segmented-icon-control-option/global/index.js +2 -0
  346. package/segmented-icon-control-option/index.d.ts +1 -22
  347. package/segmented-icon-control-option/index.js +36 -37
  348. package/segmented-icon-control-option/types.d.ts +21 -1
  349. package/segmented-icon-control-option/types.js +1 -1
  350. package/select-button/global/index.d.ts +1 -0
  351. package/select-button/global/index.js +2 -0
  352. package/select-button/index.d.ts +1 -26
  353. package/select-button/index.js +104 -112
  354. package/select-button/types.d.ts +25 -1
  355. package/select-button/types.js +1 -1
  356. package/select-menu/global/index.d.ts +1 -0
  357. package/select-menu/global/index.js +2 -0
  358. package/select-menu/index.d.ts +1 -22
  359. package/select-menu/index.js +201 -164
  360. package/select-menu/types.d.ts +21 -1
  361. package/select-menu/types.js +1 -1
  362. package/select-menu-option/global/index.d.ts +1 -0
  363. package/select-menu-option/global/index.js +2 -0
  364. package/select-menu-option/index.d.ts +1 -22
  365. package/select-menu-option/index.js +41 -33
  366. package/select-menu-option/types.d.ts +21 -1
  367. package/select-menu-option/types.js +1 -1
  368. package/select-menu-option/utils.js +4 -1
  369. package/skeleton/global/index.d.ts +1 -0
  370. package/skeleton/global/index.js +2 -0
  371. package/skeleton/index.d.ts +1 -22
  372. package/skeleton/index.js +35 -38
  373. package/skeleton/types.d.ts +21 -1
  374. package/skeleton/types.js +1 -1
  375. package/skeleton-item/global/index.d.ts +1 -0
  376. package/skeleton-item/global/index.js +2 -0
  377. package/skeleton-item/index.d.ts +1 -22
  378. package/skeleton-item/index.js +8 -5
  379. package/skeleton-item/types.d.ts +21 -1
  380. package/skeleton-item/types.js +1 -1
  381. package/spinner/global/index.d.ts +1 -0
  382. package/spinner/global/index.js +2 -0
  383. package/spinner/index.d.ts +1 -22
  384. package/spinner/index.js +31 -29
  385. package/spinner/types.d.ts +21 -1
  386. package/spinner/types.js +1 -1
  387. package/standalone.d.ts +0 -8
  388. package/standalone.js +79 -87
  389. package/standalone.ts +0 -8
  390. package/stop-events/index.js +12 -12
  391. package/table/global/index.d.ts +1 -0
  392. package/table/global/index.js +2 -0
  393. package/table/index.d.ts +1 -21
  394. package/table/index.js +9 -6
  395. package/table/types.d.ts +21 -1
  396. package/table/types.js +1 -1
  397. package/table-body/global/index.d.ts +1 -0
  398. package/table-body/global/index.js +2 -0
  399. package/table-body/index.d.ts +1 -21
  400. package/table-body/index.js +9 -6
  401. package/table-body/types.d.ts +21 -1
  402. package/table-body/types.js +1 -1
  403. package/table-cell/global/index.d.ts +1 -0
  404. package/table-cell/global/index.js +2 -0
  405. package/table-cell/index.d.ts +2 -22
  406. package/table-cell/index.js +13 -9
  407. package/table-cell/types.d.ts +21 -1
  408. package/table-cell/types.js +1 -1
  409. package/table-cell/utils.js +4 -1
  410. package/table-head/global/index.d.ts +1 -0
  411. package/table-head/global/index.js +2 -0
  412. package/table-head/index.d.ts +1 -21
  413. package/table-head/index.js +9 -6
  414. package/table-head/types.d.ts +21 -1
  415. package/table-head/types.js +1 -1
  416. package/table-head-cell/global/index.d.ts +1 -0
  417. package/table-head-cell/global/index.js +2 -0
  418. package/table-head-cell/index.d.ts +1 -22
  419. package/table-head-cell/index.js +29 -27
  420. package/table-head-cell/types.d.ts +21 -1
  421. package/table-head-cell/types.js +1 -1
  422. package/table-row/global/index.d.ts +1 -0
  423. package/table-row/global/index.js +2 -0
  424. package/table-row/index.d.ts +1 -22
  425. package/table-row/index.js +20 -17
  426. package/table-row/types.d.ts +21 -1
  427. package/table-row/types.js +1 -1
  428. package/tabs/global/index.d.ts +1 -0
  429. package/tabs/global/index.js +2 -0
  430. package/tabs/index.d.ts +2 -22
  431. package/tabs/index.js +32 -35
  432. package/tabs/types.d.ts +21 -1
  433. package/tabs/types.js +1 -1
  434. package/tabs-icon-option/global/index.d.ts +1 -0
  435. package/tabs-icon-option/global/index.js +2 -0
  436. package/tabs-icon-option/index.d.ts +1 -22
  437. package/tabs-icon-option/index.js +38 -40
  438. package/tabs-icon-option/types.d.ts +21 -1
  439. package/tabs-icon-option/types.js +1 -1
  440. package/tabs-option/global/index.d.ts +1 -0
  441. package/tabs-option/global/index.js +2 -0
  442. package/tabs-option/index.d.ts +1 -22
  443. package/tabs-option/index.js +41 -43
  444. package/tabs-option/types.d.ts +21 -1
  445. package/tabs-option/types.js +1 -1
  446. package/tag/colors.js +1 -1
  447. package/tag/global/index.d.ts +1 -0
  448. package/tag/global/index.js +2 -0
  449. package/tag/index.d.ts +1 -22
  450. package/tag/index.js +45 -44
  451. package/tag/types.d.ts +21 -1
  452. package/tag/types.js +1 -1
  453. package/tag/utils.js +7 -3
  454. package/text/global/index.d.ts +1 -0
  455. package/text/global/index.js +2 -0
  456. package/text/index.d.ts +2 -22
  457. package/text/index.js +33 -28
  458. package/text/types.d.ts +21 -1
  459. package/text/types.js +1 -1
  460. package/text/utils.js +4 -1
  461. package/textarea/global/index.d.ts +1 -0
  462. package/textarea/global/index.js +2 -0
  463. package/textarea/index.d.ts +1 -22
  464. package/textarea/index.js +147 -152
  465. package/textarea/types.d.ts +21 -1
  466. package/textarea/types.js +1 -1
  467. package/time-picker/global/index.d.ts +1 -0
  468. package/time-picker/global/index.js +2 -0
  469. package/time-picker/index.d.ts +2 -22
  470. package/time-picker/index.js +119 -123
  471. package/time-picker/types.d.ts +21 -1
  472. package/time-picker/types.js +1 -1
  473. package/time-picker/utils.js +31 -33
  474. package/title/global/index.d.ts +1 -0
  475. package/title/global/index.js +2 -0
  476. package/title/index.d.ts +2 -22
  477. package/title/index.js +32 -31
  478. package/title/types.d.ts +21 -1
  479. package/title/types.js +1 -1
  480. package/title/utils.js +18 -14
  481. package/toast/global/index.d.ts +1 -0
  482. package/toast/global/index.js +2 -0
  483. package/toast/index.d.ts +2 -22
  484. package/toast/index.js +37 -34
  485. package/toast/types.d.ts +21 -1
  486. package/toast/types.js +1 -1
  487. package/toast/utils.js +4 -1
  488. package/toast-manager/global/index.d.ts +1 -0
  489. package/toast-manager/global/index.js +2 -0
  490. package/toast-manager/index.d.ts +3 -22
  491. package/toast-manager/index.js +77 -63
  492. package/toast-manager/types.d.ts +21 -1
  493. package/toast-manager/types.js +1 -1
  494. package/toast-manager/utils.js +4 -1
  495. package/toggle/global/index.d.ts +1 -0
  496. package/toggle/global/index.js +2 -0
  497. package/toggle/index.d.ts +1 -22
  498. package/toggle/index.js +81 -75
  499. package/toggle/types.d.ts +21 -1
  500. package/toggle/types.js +1 -1
  501. package/tooltip/global/index.d.ts +1 -0
  502. package/tooltip/global/index.js +2 -0
  503. package/tooltip/index.d.ts +3 -22
  504. package/tooltip/index.js +105 -93
  505. package/tooltip/tooltip-state.js +56 -64
  506. package/tooltip/types.d.ts +21 -1
  507. package/tooltip/types.js +1 -1
  508. package/tooltip/utils.js +32 -13
  509. package/types.d.ts +12 -29
  510. package/utils/adapters.js +1 -1
  511. package/utils/component-names.d.ts +3 -0
  512. package/utils/component-names.js +85 -0
  513. package/utils/context.js +32 -42
  514. package/utils/countries.js +490 -2
  515. package/utils/csv.js +13 -6
  516. package/utils/debounce.js +10 -3
  517. package/utils/dom.js +60 -53
  518. package/utils/element.d.ts +107 -15
  519. package/utils/element.js +100 -19
  520. package/utils/event-target.js +11 -5
  521. package/utils/form.js +17 -12
  522. package/utils/get-react-event-handler.js +6 -3
  523. package/utils/global-components-constants.d.ts +3 -0
  524. package/utils/global-components-constants.js +8 -0
  525. package/utils/global-components-manager.d.ts +71 -0
  526. package/utils/global-components-manager.js +24 -0
  527. package/utils/index.js +65 -12
  528. package/utils/markdown.js +56 -43
  529. package/utils/rect.js +13 -18
  530. package/utils/shared/global-elements-manager.d.js +1 -0
  531. package/utils/shared/global-elements-manager.d.ts +62 -0
  532. package/utils/shared/global-elements-manager.js +163 -0
  533. package/utils/shared/global-elements-store.d.js +1 -0
  534. package/utils/shared/global-elements-store.d.ts +12 -0
  535. package/utils/shared/global-elements-store.js +31 -0
  536. package/utils/shared/index.d.js +11 -0
  537. package/utils/shared/index.d.ts +3 -0
  538. package/utils/shared/index.js +11 -0
  539. package/utils/shared/nectary-element-base.d.js +1 -0
  540. package/utils/shared/nectary-element-base.d.ts +9 -0
  541. package/utils/shared/nectary-element-base.js +25 -0
  542. package/utils/shared/package.json +9 -0
  543. package/utils/shared/tsconfig.json +20 -0
  544. package/utils/size.js +8 -3
  545. package/utils/slot.js +13 -9
  546. package/utils/throttle.js +5 -2
  547. package/utils/uid.js +5 -2
  548. package/card/index.d.ts +0 -40
  549. package/card/index.js +0 -134
  550. package/card/types.d.ts +0 -17
  551. package/card/types.js +0 -1
  552. package/horizontal-stepper/index.d.ts +0 -33
  553. package/horizontal-stepper/index.js +0 -62
  554. package/horizontal-stepper/types.d.ts +0 -42
  555. package/horizontal-stepper/types.js +0 -1
  556. package/horizontal-stepper-item/index.d.ts +0 -38
  557. package/horizontal-stepper-item/index.js +0 -62
  558. package/horizontal-stepper-item/types.d.ts +0 -38
  559. package/horizontal-stepper-item/types.js +0 -1
  560. package/horizontal-stepper-item/utils.d.ts +0 -2
  561. package/horizontal-stepper-item/utils.js +0 -1
  562. package/segment/index.d.ts +0 -40
  563. package/segment/index.js +0 -110
  564. package/segment/types.d.ts +0 -23
  565. package/segment/types.js +0 -1
  566. package/segment/utils.d.ts +0 -3
  567. package/segment/utils.js +0 -16
  568. package/tile-control/index.d.ts +0 -39
  569. package/tile-control/index.js +0 -111
  570. package/tile-control/types.d.ts +0 -29
  571. package/tile-control/types.js +0 -1
  572. package/tile-control-option/index.d.ts +0 -40
  573. package/tile-control-option/index.js +0 -99
  574. package/tile-control-option/types.d.ts +0 -52
  575. package/tile-control-option/types.js +0 -1
  576. package/vertical-stepper/index.d.ts +0 -33
  577. package/vertical-stepper/index.js +0 -58
  578. package/vertical-stepper/types.d.ts +0 -34
  579. package/vertical-stepper/types.js +0 -1
  580. package/vertical-stepper-item/index.d.ts +0 -38
  581. package/vertical-stepper-item/index.js +0 -62
  582. package/vertical-stepper-item/types.d.ts +0 -42
  583. package/vertical-stepper-item/types.js +0 -1
  584. package/vertical-stepper-item/utils.d.ts +0 -2
  585. package/vertical-stepper-item/utils.js +0 -1
@@ -0,0 +1,24 @@
1
+ import { GlobalElementsManager } from "./shared/global-elements-manager.js";
2
+ import { BASE_COMPONENT_NAMES } from "./component-names.js";
3
+ import { COMPONENTS_CDN_URL, COMPONENTS_REGISTRY_URL, COMPONENTS_STORE_KEY } from "./global-components-constants.js";
4
+ class GlobalComponentsManagerImpl extends GlobalElementsManager {
5
+ static instance = null;
6
+ constructor() {
7
+ super({
8
+ storeKey: COMPONENTS_STORE_KEY,
9
+ registryUrl: COMPONENTS_REGISTRY_URL,
10
+ cdnUrl: COMPONENTS_CDN_URL,
11
+ baseElementNames: BASE_COMPONENT_NAMES
12
+ });
13
+ }
14
+ static getInstance() {
15
+ if (GlobalComponentsManagerImpl.instance == null) {
16
+ GlobalComponentsManagerImpl.instance = new GlobalComponentsManagerImpl();
17
+ }
18
+ return GlobalComponentsManagerImpl.instance;
19
+ }
20
+ }
21
+ const GlobalComponentsManager = new GlobalComponentsManagerImpl();
22
+ export {
23
+ GlobalComponentsManager
24
+ };
package/utils/index.js CHANGED
@@ -1,12 +1,65 @@
1
- export * from './context';
2
- export * from './csv';
3
- export * from './dom';
4
- export * from './element';
5
- export * from './rect';
6
- export * from './slot';
7
- export * from './throttle';
8
- export * from './debounce';
9
- export * from './get-react-event-handler';
10
- export * from './markdown';
11
- export * from './event-target';
12
- export * from './uid';
1
+ import { Context, subscribeContext } from "./context.js";
2
+ import { CSV_DELIMITER, getFirstCsvValue, packCsv, unpackCsv, updateCsv } from "./csv.js";
3
+ import { attrValueToInteger, attrValueToPixels, clampNumber, cloneNode, getAttribute, getBooleanAttribute, getCssVar, getCssVars, getIntegerAttribute, getLiteralAttribute, hasClass, isAttrEqual, isAttrTrue, isLiteralValue, setClass, shouldReduceMotion, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute, updateLiteralAttribute } from "./dom.js";
4
+ import { NectaryElement, defineCustomElement, pascalToKebabCase, registerComponent, resetNectaryRegistry, setNectaryRegistry } from "./element.js";
5
+ import { getRect, getTargetRect, rectOverlap } from "./rect.js";
6
+ import { getFirstFocusableElement, getFirstSlotElement, isElementFocused } from "./slot.js";
7
+ import { throttleAnimationFrame } from "./throttle.js";
8
+ import { debounceAnimationFrame, debounceTimeout } from "./debounce.js";
9
+ import { getReactEventHandler } from "./get-react-event-handler.js";
10
+ import { isEmojiString, parseMarkdown } from "./markdown.js";
11
+ import { getTargetAttribute, getTargetByAttribute, getTargetIndexInParent, isTargetEqual } from "./event-target.js";
12
+ import { getUid } from "./uid.js";
13
+ export {
14
+ CSV_DELIMITER,
15
+ Context,
16
+ NectaryElement,
17
+ attrValueToInteger,
18
+ attrValueToPixels,
19
+ clampNumber,
20
+ cloneNode,
21
+ debounceAnimationFrame,
22
+ debounceTimeout,
23
+ defineCustomElement,
24
+ getAttribute,
25
+ getBooleanAttribute,
26
+ getCssVar,
27
+ getCssVars,
28
+ getFirstCsvValue,
29
+ getFirstFocusableElement,
30
+ getFirstSlotElement,
31
+ getIntegerAttribute,
32
+ getLiteralAttribute,
33
+ getReactEventHandler,
34
+ getRect,
35
+ getTargetAttribute,
36
+ getTargetByAttribute,
37
+ getTargetIndexInParent,
38
+ getTargetRect,
39
+ getUid,
40
+ hasClass,
41
+ isAttrEqual,
42
+ isAttrTrue,
43
+ isElementFocused,
44
+ isEmojiString,
45
+ isLiteralValue,
46
+ isTargetEqual,
47
+ packCsv,
48
+ parseMarkdown,
49
+ pascalToKebabCase,
50
+ rectOverlap,
51
+ registerComponent,
52
+ resetNectaryRegistry,
53
+ setClass,
54
+ setNectaryRegistry,
55
+ shouldReduceMotion,
56
+ subscribeContext,
57
+ throttleAnimationFrame,
58
+ unpackCsv,
59
+ updateAttribute,
60
+ updateBooleanAttribute,
61
+ updateCsv,
62
+ updateExplicitBooleanAttribute,
63
+ updateIntegerAttribute,
64
+ updateLiteralAttribute
65
+ };
package/utils/markdown.js CHANGED
@@ -1,28 +1,35 @@
1
1
  const regLinebreak = /(?:<br>\n|<br>|\n)/;
2
2
  const regParagraph = /\n{2,}/;
3
- const regEm3Star = /(?<!\\)\*\*\*(?<em3>.+?)(?<!\\)\*\*\*/;
4
- const regEm2Star = /(?<!\\)\*\*(?<em2>.+?)(?<!\\)\*\*/;
5
- const regEm1Star = /(?<!\\)\*(?<em1>.+?)(?<!\\)\*/;
6
- const regEm3Underscore = /(?<!\\)___(?<em3>.+?)(?<!\\)___/;
7
- const regEm2Underscore = /(?<!\\)__(?<em2>.+?)(?<!\\)__/;
8
- const regEm1Underscore = /(?<!\\)_(?<em1>.+?)(?<!\\)_/;
9
- const regCodeTag = /(?<!\\)`(?<code>.+?)(?<!\\)`/;
10
- const regStrikethrough = /(?<!\\)~~(?<strike>.+?)(?<!\\)~~/;
11
- const regLink = /(?<!\\)!?\[(?<linktext>[^\]]*?)\]\((?<linkhref>[^)]+?)\)(\{(?<linkattrs>[^)]+?)\})?/;
12
- const regEmoji = /(?<emoji>(?![0-9*#])\p{Emoji})/u;
3
+ const regEm3Star = new RegExp("(?<!\\\\)\\*\\*\\*(?<em3>.+?)(?<!\\\\)\\*\\*\\*");
4
+ const regEm2Star = new RegExp("(?<!\\\\)\\*\\*(?<em2>.+?)(?<!\\\\)\\*\\*");
5
+ const regEm1Star = new RegExp("(?<!\\\\)\\*(?<em1>.+?)(?<!\\\\)\\*");
6
+ const regEm3Underscore = new RegExp("(?<!\\\\)___(?<em3>.+?)(?<!\\\\)___");
7
+ const regEm2Underscore = new RegExp("(?<!\\\\)__(?<em2>.+?)(?<!\\\\)__");
8
+ const regEm1Underscore = new RegExp("(?<!\\\\)_(?<em1>.+?)(?<!\\\\)_");
9
+ const regCodeTag = new RegExp("(?<!\\\\)`(?<code>.+?)(?<!\\\\)`");
10
+ const regStrikethrough = new RegExp("(?<!\\\\)~~(?<strike>.+?)(?<!\\\\)~~");
11
+ const regLink = new RegExp("(?<!\\\\)!?\\[(?<linktext>[^\\]]*?)\\]\\((?<linkhref>[^)]+?)\\)(\\{(?<linkattrs>[^)]+?)\\})?");
12
+ const regEmoji = new RegExp("(?<emoji>(?![0-9*#])\\p{Emoji})", "u");
13
13
  const regUList = /^(?<indent>[\t ]*?)[*+-][\t ]+(?<ultext>.*?)[\t ]*?$/;
14
14
  const regOList = /^(?<indent>[\t ]*?)\d+\.[\t ]+(?<oltext>.*?)[\t ]*?$/;
15
15
  const regEscapedChars = /\\(?<escaped>[\\\*_\[\]`~])/;
16
- const allRegs = [regEscapedChars, regCodeTag, regLink, regEm3Star, regEm2Star, regEm1Star, regEm3Underscore, regEm2Underscore, regEm1Underscore, regStrikethrough, regEmoji];
17
- export const isEmojiString = data => regEmoji.test(data);
18
- const excludeRegs = function (regs) {
19
- for (var _len = arguments.length, excluding = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
20
- excluding[_key - 1] = arguments[_key];
21
- }
22
- return regs.filter(r => !excluding.includes(r));
23
- };
16
+ const allRegs = [
17
+ regEscapedChars,
18
+ regCodeTag,
19
+ regLink,
20
+ regEm3Star,
21
+ regEm2Star,
22
+ regEm1Star,
23
+ regEm3Underscore,
24
+ regEm2Underscore,
25
+ regEm1Underscore,
26
+ regStrikethrough,
27
+ regEmoji
28
+ ];
29
+ const isEmojiString = (data) => regEmoji.test(data);
30
+ const excludeRegs = (regs, ...excluding) => regs.filter((r) => !excluding.includes(r));
24
31
  const matchClosest = (regs, line) => {
25
- return regs.map(reg => reg.exec(line)).reduce((res, match) => {
32
+ return regs.map((reg) => reg.exec(line)).reduce((res, match) => {
26
33
  if (match === null) {
27
34
  return res;
28
35
  }
@@ -37,8 +44,7 @@ const INITIAL_CONTEXT = {
37
44
  isItalic: false,
38
45
  isStrikethrough: false
39
46
  };
40
- const createLineParser = visitor => function parseLine(regs, md) {
41
- let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : INITIAL_CONTEXT;
47
+ const createLineParser = (visitor) => function parseLine(regs, md, context = INITIAL_CONTEXT) {
42
48
  let line = md;
43
49
  let match = null;
44
50
  while ((match = matchClosest(regs, line)) !== null) {
@@ -53,7 +59,7 @@ const createLineParser = visitor => function parseLine(regs, md) {
53
59
  continue;
54
60
  }
55
61
  if (groups?.linkhref != null) {
56
- visitor.link(groups.linktext, groups.linkhref, groups.linkattrs?.split(' '));
62
+ visitor.link(groups.linktext, groups.linkhref, groups.linkattrs?.split(" "));
57
63
  }
58
64
  if (groups?.code != null) {
59
65
  visitor.codetag(groups.code);
@@ -62,39 +68,42 @@ const createLineParser = visitor => function parseLine(regs, md) {
62
68
  visitor.emoji(groups.emoji);
63
69
  }
64
70
  if (groups?.em1 != null) {
65
- parseLine(excludeRegs(regs, regEm1Star, regEm1Underscore), groups.em1, {
66
- ...context,
67
- isItalic: true
68
- });
71
+ parseLine(
72
+ excludeRegs(regs, regEm1Star, regEm1Underscore),
73
+ groups.em1,
74
+ { ...context, isItalic: true }
75
+ );
69
76
  }
70
77
  if (groups?.em2 != null) {
71
- parseLine(excludeRegs(regs, regEm2Star, regEm2Underscore), groups.em2, {
72
- ...context,
73
- isBold: true
74
- });
78
+ parseLine(
79
+ excludeRegs(regs, regEm2Star, regEm2Underscore),
80
+ groups.em2,
81
+ { ...context, isBold: true }
82
+ );
75
83
  }
76
84
  if (groups?.em3 != null) {
77
- parseLine(excludeRegs(regs, regEm3Star, regEm3Underscore, regEm2Star, regEm2Underscore, regEm1Star, regEm1Underscore), groups.em3, {
78
- ...context,
79
- isBold: true,
80
- isItalic: true
81
- });
85
+ parseLine(
86
+ excludeRegs(regs, regEm3Star, regEm3Underscore, regEm2Star, regEm2Underscore, regEm1Star, regEm1Underscore),
87
+ groups.em3,
88
+ { ...context, isBold: true, isItalic: true }
89
+ );
82
90
  }
83
91
  if (groups?.strike != null) {
84
- parseLine(excludeRegs(regs, regStrikethrough), groups.strike, {
85
- ...context,
86
- isStrikethrough: true
87
- });
92
+ parseLine(
93
+ excludeRegs(regs, regStrikethrough),
94
+ groups.strike,
95
+ { ...context, isStrikethrough: true }
96
+ );
88
97
  }
89
98
  }
90
99
  if (line.length > 0) {
91
100
  visitor.inline(line, context);
92
101
  }
93
102
  };
94
- const createBlockParser = visitor => {
103
+ const createBlockParser = (visitor) => {
95
104
  const parseLine = createLineParser(visitor);
96
105
  const listRegs = [regUList, regOList];
97
- const getListItemText = match => {
106
+ const getListItemText = (match) => {
98
107
  return match.groups.ultext ?? match.groups.oltext;
99
108
  };
100
109
  const BLOCK_MODE_PARAGRAPH = 1;
@@ -139,10 +148,14 @@ const createBlockParser = visitor => {
139
148
  }
140
149
  };
141
150
  };
142
- export const parseMarkdown = (md, visitor) => {
151
+ const parseMarkdown = (md, visitor) => {
143
152
  const parseBlock = createBlockParser(visitor);
144
153
  for (const block of md.trim().split(regParagraph)) {
145
154
  parseBlock(block.trim().split(regLinebreak));
146
155
  }
147
156
  return visitor.end();
148
- };
157
+ };
158
+ export {
159
+ isEmojiString,
160
+ parseMarkdown
161
+ };
package/utils/rect.js CHANGED
@@ -1,28 +1,23 @@
1
- import { getFirstSlotElement } from './slot';
2
- export const getRect = el => {
3
- const {
4
- x,
5
- y,
6
- width,
7
- height
8
- } = el.getBoundingClientRect();
9
- return {
10
- x,
11
- y,
12
- width,
13
- height
14
- };
1
+ import { getFirstSlotElement } from "./slot.js";
2
+ const getRect = (el) => {
3
+ const { x, y, width, height } = el.getBoundingClientRect();
4
+ return { x, y, width, height };
15
5
  };
16
- export const rectOverlap = (targetRect, contentRect) => {
6
+ const rectOverlap = (targetRect, contentRect) => {
17
7
  return targetRect.x < contentRect.x + contentRect.width && targetRect.x + targetRect.width > contentRect.x && targetRect.y < contentRect.y + contentRect.height && targetRect.y + targetRect.height > contentRect.y;
18
8
  };
19
- export const getTargetRect = slot => {
9
+ const getTargetRect = (slot) => {
20
10
  const item = getFirstSlotElement(slot, true);
21
11
  if (item === null) {
22
12
  return null;
23
13
  }
24
- if (Reflect.has(item, 'footprintRect')) {
14
+ if (Reflect.has(item, "footprintRect")) {
25
15
  return item.footprintRect;
26
16
  }
27
17
  return getRect(item);
28
- };
18
+ };
19
+ export {
20
+ getRect,
21
+ getTargetRect,
22
+ rectOverlap
23
+ };
@@ -0,0 +1,62 @@
1
+ import type { SinchElementName } from './nectary-element-base';
2
+ interface GlobalManagerConfig {
3
+ storeKey: symbol;
4
+ registryUrl: string;
5
+ cdnUrl: string;
6
+ baseElementNames: Set<string>;
7
+ nameToPathMap?: Map<string, string>;
8
+ }
9
+ interface GlobalManagerInitOptions {
10
+ /**
11
+ * If components should be preloaded from the bundle module (nectary/components/bundle) (Not supported for nectary/assets).
12
+ *
13
+ * When preload is true:
14
+ *
15
+ * targetlibVersion will only work since v5 of nectary/components and v3 of nectary/assets.
16
+ *
17
+ * parchPreviousVersions will have no effect since its not needed.
18
+ *
19
+ * fallbackLoaderBundle will be used instead of fallbackLoader
20
+ */
21
+ preload?: boolean;
22
+ /**
23
+ * Target version of the library to resolve the constructor from the CDN.
24
+ *
25
+ * If left unspecified, it will resolve to the latest version.
26
+ */
27
+ targetlibVersion?: string;
28
+ /**
29
+ * If previous versions of Nectary should opt in to using Global Components.
30
+ *
31
+ * @default true
32
+ */
33
+ patchPerviousVersions?: boolean;
34
+ /**
35
+ * Fallback loader if the CDN fails.
36
+ */
37
+ fallbackLoader?: (name: string) => Promise<any>;
38
+ /**
39
+ * Should be used like this:
40
+ *
41
+ * fallbackLoaderBundle: () => import("@nectary/components/bundle")
42
+ */
43
+ fallbackLoaderBundle?: () => Promise<any>;
44
+ /**
45
+ * Constructors will be resolved from fallback directly and CDN will not be used.
46
+ */
47
+ useFallbackExclusively?: boolean;
48
+ }
49
+ export declare abstract class GlobalElementsManager {
50
+ private config;
51
+ constructor(config: GlobalManagerConfig);
52
+ getConstructor(name: SinchElementName): Promise<CustomElementConstructor> | null;
53
+ private patchCustomElements;
54
+ private toClassName;
55
+ private loadModuleWithFallback;
56
+ private createLoader;
57
+ private preloadBundle;
58
+ init(options?: GlobalManagerInitOptions): Promise<void>;
59
+ private getImportPathFromName;
60
+ preload(name: SinchElementName | SinchElementName[] | 'all'): Promise<void>;
61
+ }
62
+ export {};
@@ -0,0 +1,163 @@
1
+ import { isSinchElementName, sinchElementNameToBase } from "./nectary-element-base.js";
2
+ import { getConstructor, getStore } from "./global-elements-store.js";
3
+ class GlobalElementsManager {
4
+ config;
5
+ constructor(config) {
6
+ this.config = config;
7
+ }
8
+ getConstructor(name) {
9
+ return getConstructor(this.config.storeKey, name);
10
+ }
11
+ // This patch is made so that older Nectary versions automatically gets opted in to global components
12
+ patchCustomElements() {
13
+ const originalDefine = window.customElements.define.bind(window.customElements);
14
+ window.customElements.define = (name, constructor, options) => {
15
+ if (isSinchElementName(name) && this.config.baseElementNames.has(sinchElementNameToBase(name))) {
16
+ const nectaryConstructor = constructor;
17
+ if (nectaryConstructor.isGlobal) {
18
+ return originalDefine(name, constructor, options);
19
+ }
20
+ (async () => {
21
+ try {
22
+ const globalConstructor = await this.getConstructor(name);
23
+ if (globalConstructor !== null) {
24
+ originalDefine(name, globalConstructor, options);
25
+ } else {
26
+ console.error(`Nectary element ${name} not found, falling back to local constructor`);
27
+ originalDefine(name, constructor, options);
28
+ }
29
+ } catch (error) {
30
+ console.error(`Failed to get global constructor for ${name}:`, error);
31
+ originalDefine(name, constructor, options);
32
+ }
33
+ })();
34
+ } else {
35
+ return originalDefine(name, constructor, options);
36
+ }
37
+ };
38
+ }
39
+ toClassName(itemName) {
40
+ return itemName.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
41
+ }
42
+ async loadModuleWithFallback(importPath, fallbackThunk, useFallbackExclusively = false) {
43
+ if (useFallbackExclusively && fallbackThunk != null) {
44
+ return fallbackThunk();
45
+ }
46
+ try {
47
+ const module = await import(
48
+ /* webpackIgnore: true */
49
+ importPath
50
+ );
51
+ return module;
52
+ } catch (error) {
53
+ if (fallbackThunk != null) {
54
+ try {
55
+ return fallbackThunk();
56
+ } catch (fallbackError) {
57
+ console.error(`Nectary Primary load failed: ${importPath}`, error);
58
+ console.error(`Nectary fallback load failed:`, fallbackError);
59
+ throw fallbackError;
60
+ }
61
+ }
62
+ console.error(`Nectary failed to load module: ${importPath}`, error);
63
+ throw error;
64
+ }
65
+ }
66
+ createLoader(importPath, itemName, fallbackLoader, useFallbackExclusively = false) {
67
+ return async () => {
68
+ const module = await this.loadModuleWithFallback(
69
+ importPath,
70
+ fallbackLoader != null ? () => fallbackLoader(itemName) : null,
71
+ useFallbackExclusively
72
+ );
73
+ const className = this.toClassName(itemName);
74
+ const globalConstructor = module[className];
75
+ if (globalConstructor == null) {
76
+ throw new Error(`Nectary element ${className} not found in module: ${importPath}`);
77
+ }
78
+ globalConstructor.isGlobal = true;
79
+ return globalConstructor;
80
+ };
81
+ }
82
+ async preloadBundle(importPath, fallbackLoaderBundle, useFallbackExclusively = false) {
83
+ const store = getStore(this.config.storeKey);
84
+ const module = await this.loadModuleWithFallback(
85
+ importPath,
86
+ fallbackLoaderBundle,
87
+ useFallbackExclusively
88
+ );
89
+ for (const itemName of this.config.baseElementNames) {
90
+ const className = this.toClassName(itemName);
91
+ const globalConstructor = module[className];
92
+ if (globalConstructor == null) {
93
+ console.error(`Nectary element ${className} not found in module: ${importPath}`);
94
+ continue;
95
+ }
96
+ globalConstructor.isGlobal = true;
97
+ const sinchName = `sinch-${itemName}`;
98
+ store.definitions.set(sinchName, () => Promise.resolve(globalConstructor));
99
+ window.customElements.define(sinchName, globalConstructor);
100
+ }
101
+ }
102
+ async init(options = {}) {
103
+ const store = getStore(this.config.storeKey);
104
+ if (store.hasInitialized) {
105
+ console.warn(`${this.constructor.name} has already been initialized`);
106
+ return;
107
+ }
108
+ store.hasInitialized = true;
109
+ store.preload = options.preload ?? false;
110
+ store.patchPerviousVersions = options.patchPerviousVersions ?? true;
111
+ store.useFallbackExclusively = options.useFallbackExclusively ?? false;
112
+ if (store.preload) {
113
+ const version = options.targetlibVersion;
114
+ store.targetlibVersion = version ?? store.targetlibVersion;
115
+ const importPath = version != null ? `${this.config.cdnUrl}@${version}/es2022/bundle.mjs` : `${this.config.cdnUrl}/bundle`;
116
+ await this.preloadBundle(importPath, options.fallbackLoaderBundle, store.useFallbackExclusively);
117
+ return;
118
+ }
119
+ if (store.patchPerviousVersions) {
120
+ this.patchCustomElements();
121
+ }
122
+ this.config.baseElementNames.forEach((name) => {
123
+ const importPath = `${this.config.cdnUrl}/${this.getImportPathFromName(name)}`;
124
+ store.definitions.set(`sinch-${name}`, this.createLoader(importPath, name, options.fallbackLoader, store.useFallbackExclusively));
125
+ });
126
+ if (options.targetlibVersion != null) {
127
+ store.targetlibVersion = options.targetlibVersion;
128
+ } else {
129
+ const registry = await fetch(`${this.config.registryUrl}/latest`);
130
+ const registryData = await registry.json();
131
+ store.targetlibVersion = registryData.version;
132
+ }
133
+ this.config.baseElementNames.forEach((name) => {
134
+ const importPath = `${this.config.cdnUrl}@${store.targetlibVersion}/es2022/${this.getImportPathFromName(name)}.mjs`;
135
+ store.definitions.set(`sinch-${name}`, this.createLoader(importPath, name, options.fallbackLoader, store.useFallbackExclusively));
136
+ });
137
+ }
138
+ getImportPathFromName(name) {
139
+ for (const [key, value] of this.config.nameToPathMap ?? []) {
140
+ const splittedName = name.startsWith(key) ? name.split(key) : [name];
141
+ if (splittedName.length > 1) {
142
+ const restOfName = splittedName.slice(1).join(key);
143
+ return value + restOfName;
144
+ }
145
+ }
146
+ return name;
147
+ }
148
+ async preload(name) {
149
+ const store = getStore(this.config.storeKey);
150
+ if (name === "all") {
151
+ await Promise.all(Array.from(store.definitions.keys()).map((n) => store.definitions.get(n)?.()));
152
+ return;
153
+ }
154
+ if (Array.isArray(name)) {
155
+ await Promise.all(name.map((n) => store.definitions.get(n)?.()));
156
+ return;
157
+ }
158
+ await store.definitions.get(name)?.();
159
+ }
160
+ }
161
+ export {
162
+ GlobalElementsManager
163
+ };
@@ -0,0 +1,12 @@
1
+ import type { SinchElementName } from './nectary-element-base';
2
+ interface GlobalStore {
3
+ hasInitialized: boolean;
4
+ targetlibVersion: string;
5
+ patchPerviousVersions: boolean;
6
+ useFallbackExclusively: boolean;
7
+ preload: boolean;
8
+ definitions: Map<SinchElementName, () => Promise<any>>;
9
+ }
10
+ export declare const getStore: (storeKey: symbol) => GlobalStore;
11
+ export declare const getConstructor: (storeKey: symbol, name: SinchElementName) => Promise<CustomElementConstructor> | null;
12
+ export {};
@@ -0,0 +1,31 @@
1
+ const getStore = (storeKey) => {
2
+ if (window[storeKey] != null) {
3
+ return window[storeKey];
4
+ }
5
+ const store = {
6
+ hasInitialized: false,
7
+ targetlibVersion: "",
8
+ patchPerviousVersions: false,
9
+ useFallbackExclusively: false,
10
+ preload: false,
11
+ definitions: /* @__PURE__ */ new Map()
12
+ };
13
+ Object.defineProperty(window, storeKey, {
14
+ value: store,
15
+ enumerable: false,
16
+ writable: false,
17
+ configurable: false
18
+ });
19
+ return store;
20
+ };
21
+ const getConstructor = (storeKey, name) => {
22
+ const definitionLoader = getStore(storeKey).definitions.get(name);
23
+ if (definitionLoader == null) {
24
+ return null;
25
+ }
26
+ return definitionLoader();
27
+ };
28
+ export {
29
+ getConstructor,
30
+ getStore
31
+ };
@@ -0,0 +1,11 @@
1
+ import { NectaryElementBase, isSinchElementName, sinchElementNameToBase } from "./nectary-element-base.js";
2
+ import { getConstructor, getStore } from "./global-elements-store.js";
3
+ import { GlobalElementsManager } from "./global-elements-manager.js";
4
+ export {
5
+ GlobalElementsManager,
6
+ NectaryElementBase,
7
+ getConstructor,
8
+ getStore,
9
+ isSinchElementName,
10
+ sinchElementNameToBase
11
+ };
@@ -0,0 +1,3 @@
1
+ export * from './nectary-element-base';
2
+ export * from './global-elements-store';
3
+ export * from './global-elements-manager';
@@ -0,0 +1,11 @@
1
+ import { NectaryElementBase, isSinchElementName, sinchElementNameToBase } from "./nectary-element-base.js";
2
+ import { getConstructor, getStore } from "./global-elements-store.js";
3
+ import { GlobalElementsManager } from "./global-elements-manager.js";
4
+ export {
5
+ GlobalElementsManager,
6
+ NectaryElementBase,
7
+ getConstructor,
8
+ getStore,
9
+ isSinchElementName,
10
+ sinchElementNameToBase
11
+ };
@@ -0,0 +1,9 @@
1
+ export type SinchElementName = `sinch-${string}`;
2
+ export declare const isSinchElementName: (value: string) => value is SinchElementName;
3
+ export declare const sinchElementNameToBase: (value: SinchElementName) => string;
4
+ export declare class NectaryElementBase extends HTMLElement {
5
+ private static _isGlobal;
6
+ static get elementName(): SinchElementName;
7
+ static get isGlobal(): boolean;
8
+ static set isGlobal(value: boolean);
9
+ }
@@ -0,0 +1,25 @@
1
+ const isSinchElementName = (value) => {
2
+ return value.startsWith("sinch-");
3
+ };
4
+ const sinchElementNameToBase = (value) => {
5
+ return value.split("sinch-")[1];
6
+ };
7
+ class NectaryElementBase extends HTMLElement {
8
+ static _isGlobal = false;
9
+ static get elementName() {
10
+ throw new Error(
11
+ `Class ${this.name} must implement static getter 'elementName'`
12
+ );
13
+ }
14
+ static get isGlobal() {
15
+ return this._isGlobal;
16
+ }
17
+ static set isGlobal(value) {
18
+ this._isGlobal = value;
19
+ }
20
+ }
21
+ export {
22
+ NectaryElementBase,
23
+ isSinchElementName,
24
+ sinchElementNameToBase
25
+ };
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@nectary/shared",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "main": "index.ts",
6
+ "scripts": {
7
+ "build": "npx tsc --declaration --emitDeclarationOnly"
8
+ }
9
+ }