@nectary/components 2.8.8 → 2.9.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 (447) hide show
  1. package/package.json +1 -1
  2. package/accordion/index.d.ts +0 -11
  3. package/accordion/index.js +0 -86
  4. package/accordion/types.d.ts +0 -21
  5. package/accordion/types.js +0 -1
  6. package/accordion-item/index.d.ts +0 -14
  7. package/accordion-item/index.js +0 -95
  8. package/accordion-item/types.d.ts +0 -36
  9. package/accordion-item/types.js +0 -1
  10. package/accordion-item/utils.d.ts +0 -2
  11. package/accordion-item/utils.js +0 -1
  12. package/action-menu/index.d.ts +0 -11
  13. package/action-menu/index.js +0 -195
  14. package/action-menu/types.d.ts +0 -13
  15. package/action-menu/types.js +0 -1
  16. package/action-menu-option/index.d.ts +0 -12
  17. package/action-menu-option/index.js +0 -82
  18. package/action-menu-option/types.d.ts +0 -23
  19. package/action-menu-option/types.js +0 -1
  20. package/action-menu-option/utils.d.ts +0 -2
  21. package/action-menu-option/utils.js +0 -3
  22. package/alert/index.d.ts +0 -14
  23. package/alert/index.js +0 -48
  24. package/alert/types.d.ts +0 -18
  25. package/alert/types.js +0 -1
  26. package/alert/utils.d.ts +0 -2
  27. package/alert/utils.js +0 -1
  28. package/avatar/index.d.ts +0 -11
  29. package/avatar/index.js +0 -94
  30. package/avatar/types.d.ts +0 -37
  31. package/avatar/types.js +0 -1
  32. package/avatar/utils.d.ts +0 -4
  33. package/avatar/utils.js +0 -7
  34. package/badge/index.d.ts +0 -11
  35. package/badge/index.js +0 -114
  36. package/badge/types.d.ts +0 -34
  37. package/badge/types.js +0 -1
  38. package/badge/utils.d.ts +0 -2
  39. package/badge/utils.js +0 -1
  40. package/button/index.d.ts +0 -11
  41. package/button/index.js +0 -182
  42. package/button/types.d.ts +0 -53
  43. package/button/types.js +0 -1
  44. package/button/utils.d.ts +0 -2
  45. package/button/utils.js +0 -1
  46. package/card/index.d.ts +0 -13
  47. package/card/index.js +0 -133
  48. package/card/types.d.ts +0 -28
  49. package/card/types.js +0 -1
  50. package/card-container/index.d.ts +0 -11
  51. package/card-container/index.js +0 -11
  52. package/card-container/types.d.ts +0 -3
  53. package/card-container/types.js +0 -1
  54. package/chat/index.d.ts +0 -11
  55. package/chat/index.js +0 -11
  56. package/chat/types.d.ts +0 -3
  57. package/chat/types.js +0 -1
  58. package/chat-block/index.d.ts +0 -11
  59. package/chat-block/index.js +0 -86
  60. package/chat-block/types.d.ts +0 -30
  61. package/chat-block/types.js +0 -1
  62. package/chat-bubble/index.d.ts +0 -11
  63. package/chat-bubble/index.js +0 -41
  64. package/chat-bubble/types.d.ts +0 -20
  65. package/chat-bubble/types.js +0 -1
  66. package/chat-bubble/utils.d.ts +0 -3
  67. package/chat-bubble/utils.js +0 -2
  68. package/checkbox/index.d.ts +0 -11
  69. package/checkbox/index.js +0 -126
  70. package/checkbox/types.d.ts +0 -49
  71. package/checkbox/types.js +0 -1
  72. package/chip/index.d.ts +0 -13
  73. package/chip/index.js +0 -144
  74. package/chip/types.d.ts +0 -37
  75. package/chip/types.js +0 -1
  76. package/chip/utils.d.ts +0 -2
  77. package/chip/utils.js +0 -6
  78. package/code-tag/index.d.ts +0 -11
  79. package/code-tag/index.js +0 -31
  80. package/code-tag/types.d.ts +0 -11
  81. package/code-tag/types.js +0 -1
  82. package/color-menu/index.d.ts +0 -11
  83. package/color-menu/index.js +0 -308
  84. package/color-menu/types.d.ts +0 -32
  85. package/color-menu/types.js +0 -1
  86. package/color-menu/utils.d.ts +0 -1
  87. package/color-menu/utils.js +0 -11
  88. package/color-menu-option/index.d.ts +0 -13
  89. package/color-menu-option/index.js +0 -48
  90. package/color-menu-option/types.d.ts +0 -11
  91. package/color-menu-option/types.js +0 -1
  92. package/color-menu-option/utils.d.ts +0 -1
  93. package/color-menu-option/utils.js +0 -11
  94. package/color-swatch/index.d.ts +0 -12
  95. package/color-swatch/index.js +0 -54
  96. package/color-swatch/types.d.ts +0 -11
  97. package/color-swatch/types.js +0 -1
  98. package/color-swatch/utils.d.ts +0 -2
  99. package/color-swatch/utils.js +0 -6
  100. package/date-picker/index.d.ts +0 -14
  101. package/date-picker/index.js +0 -381
  102. package/date-picker/types.d.ts +0 -70
  103. package/date-picker/types.js +0 -1
  104. package/date-picker/utils.d.ts +0 -28
  105. package/date-picker/utils.js +0 -142
  106. package/dialog/index.d.ts +0 -15
  107. package/dialog/index.js +0 -144
  108. package/dialog/types.d.ts +0 -28
  109. package/dialog/types.js +0 -1
  110. package/dialog/utils.d.ts +0 -2
  111. package/dialog/utils.js +0 -18
  112. package/emoji/index.d.ts +0 -11
  113. package/emoji/index.js +0 -46
  114. package/emoji/types.d.ts +0 -11
  115. package/emoji/types.js +0 -1
  116. package/emoji/utils.d.ts +0 -3
  117. package/emoji/utils.js +0 -47
  118. package/emoji-picker/index.d.ts +0 -22
  119. package/emoji-picker/index.js +0 -308
  120. package/emoji-picker/types.d.ts +0 -26
  121. package/emoji-picker/types.js +0 -1
  122. package/field/index.d.ts +0 -11
  123. package/field/index.js +0 -120
  124. package/field/types.d.ts +0 -35
  125. package/field/types.js +0 -1
  126. package/file-drop/index.d.ts +0 -13
  127. package/file-drop/index.js +0 -205
  128. package/file-drop/types.d.ts +0 -50
  129. package/file-drop/types.js +0 -1
  130. package/file-drop/utils.d.ts +0 -2
  131. package/file-drop/utils.js +0 -31
  132. package/file-picker/index.d.ts +0 -11
  133. package/file-picker/index.js +0 -103
  134. package/file-picker/types.d.ts +0 -32
  135. package/file-picker/types.js +0 -1
  136. package/file-picker/utils.d.ts +0 -1
  137. package/file-picker/utils.js +0 -8
  138. package/file-status/index.d.ts +0 -14
  139. package/file-status/index.js +0 -61
  140. package/file-status/types.d.ts +0 -18
  141. package/file-status/types.js +0 -1
  142. package/file-status/utils.d.ts +0 -2
  143. package/file-status/utils.js +0 -1
  144. package/flag/index.d.ts +0 -11
  145. package/flag/index.js +0 -46
  146. package/flag/types.d.ts +0 -11
  147. package/flag/types.js +0 -1
  148. package/flag/utils.d.ts +0 -1
  149. package/flag/utils.js +0 -17
  150. package/grid/index.d.ts +0 -11
  151. package/grid/index.js +0 -11
  152. package/grid/types.d.ts +0 -3
  153. package/grid/types.js +0 -1
  154. package/grid-item/index.d.ts +0 -11
  155. package/grid-item/index.js +0 -35
  156. package/grid-item/types.d.ts +0 -17
  157. package/grid-item/types.js +0 -1
  158. package/help-tooltip/index.d.ts +0 -13
  159. package/help-tooltip/index.js +0 -74
  160. package/help-tooltip/types.d.ts +0 -3
  161. package/help-tooltip/types.js +0 -1
  162. package/horizontal-stepper/index.d.ts +0 -11
  163. package/horizontal-stepper/index.js +0 -61
  164. package/horizontal-stepper/types.d.ts +0 -13
  165. package/horizontal-stepper/types.js +0 -1
  166. package/horizontal-stepper-item/index.d.ts +0 -14
  167. package/horizontal-stepper-item/index.js +0 -61
  168. package/horizontal-stepper-item/types.d.ts +0 -24
  169. package/horizontal-stepper-item/types.js +0 -1
  170. package/horizontal-stepper-item/utils.d.ts +0 -2
  171. package/horizontal-stepper-item/utils.js +0 -1
  172. package/icon/index.d.ts +0 -11
  173. package/icon/index.js +0 -32
  174. package/icon/types.d.ts +0 -11
  175. package/icon/types.js +0 -1
  176. package/icon-button/index.d.ts +0 -12
  177. package/icon-button/index.js +0 -175
  178. package/icon-button/types.d.ts +0 -44
  179. package/icon-button/types.js +0 -1
  180. package/icon-button/utils.d.ts +0 -2
  181. package/icon-button/utils.js +0 -1
  182. package/inline-alert/index.d.ts +0 -15
  183. package/inline-alert/index.js +0 -83
  184. package/inline-alert/types.d.ts +0 -15
  185. package/inline-alert/types.js +0 -1
  186. package/inline-alert/utils.d.ts +0 -2
  187. package/inline-alert/utils.js +0 -1
  188. package/input/index.d.ts +0 -11
  189. package/input/index.js +0 -637
  190. package/input/types.d.ts +0 -86
  191. package/input/types.js +0 -1
  192. package/input/utils.d.ts +0 -26
  193. package/input/utils.js +0 -302
  194. package/link/index.d.ts +0 -12
  195. package/link/index.js +0 -150
  196. package/link/types.d.ts +0 -59
  197. package/link/types.js +0 -1
  198. package/list/index.d.ts +0 -11
  199. package/list/index.js +0 -14
  200. package/list/types.d.ts +0 -3
  201. package/list/types.js +0 -1
  202. package/list-item/index.d.ts +0 -11
  203. package/list-item/index.js +0 -14
  204. package/list-item/types.d.ts +0 -3
  205. package/list-item/types.js +0 -1
  206. package/pagination/index.d.ts +0 -12
  207. package/pagination/index.js +0 -147
  208. package/pagination/types.d.ts +0 -16
  209. package/pagination/types.js +0 -1
  210. package/pop/index.d.ts +0 -11
  211. package/pop/index.js +0 -425
  212. package/pop/types.d.ts +0 -35
  213. package/pop/types.js +0 -1
  214. package/pop/utils.d.ts +0 -4
  215. package/pop/utils.js +0 -16
  216. package/popover/index.d.ts +0 -12
  217. package/popover/index.js +0 -146
  218. package/popover/types.d.ts +0 -40
  219. package/popover/types.js +0 -1
  220. package/popover/utils.d.ts +0 -4
  221. package/popover/utils.js +0 -10
  222. package/progress/index.d.ts +0 -12
  223. package/progress/index.js +0 -58
  224. package/progress/types.d.ts +0 -12
  225. package/progress/types.js +0 -1
  226. package/progress-stepper/index.d.ts +0 -11
  227. package/progress-stepper/index.js +0 -206
  228. package/progress-stepper/types.d.ts +0 -22
  229. package/progress-stepper/types.js +0 -1
  230. package/progress-stepper-item/index.d.ts +0 -12
  231. package/progress-stepper-item/index.js +0 -82
  232. package/progress-stepper-item/types.d.ts +0 -23
  233. package/progress-stepper-item/types.js +0 -1
  234. package/progress-stepper-item/utils.d.ts +0 -11
  235. package/progress-stepper-item/utils.js +0 -13
  236. package/radio/index.d.ts +0 -11
  237. package/radio/index.js +0 -154
  238. package/radio/types.d.ts +0 -14
  239. package/radio/types.js +0 -1
  240. package/radio-option/index.d.ts +0 -11
  241. package/radio-option/index.js +0 -79
  242. package/radio-option/types.d.ts +0 -18
  243. package/radio-option/types.js +0 -1
  244. package/rich-text/index.d.ts +0 -14
  245. package/rich-text/index.js +0 -75
  246. package/rich-text/types.d.ts +0 -12
  247. package/rich-text/types.js +0 -1
  248. package/rich-text/utils.d.ts +0 -7
  249. package/rich-text/utils.js +0 -107
  250. package/rich-textarea/index.d.ts +0 -11
  251. package/rich-textarea/index.js +0 -464
  252. package/rich-textarea/types.d.ts +0 -48
  253. package/rich-textarea/types.js +0 -1
  254. package/rich-textarea/utils.d.ts +0 -39
  255. package/rich-textarea/utils.js +0 -1730
  256. package/segment/index.d.ts +0 -12
  257. package/segment/index.js +0 -109
  258. package/segment/types.d.ts +0 -16
  259. package/segment/types.js +0 -1
  260. package/segment/utils.d.ts +0 -3
  261. package/segment/utils.js +0 -16
  262. package/segment-collapse/index.d.ts +0 -13
  263. package/segment-collapse/index.js +0 -60
  264. package/segment-collapse/types.d.ts +0 -11
  265. package/segment-collapse/types.js +0 -1
  266. package/segmented-control/index.d.ts +0 -11
  267. package/segmented-control/index.js +0 -85
  268. package/segmented-control/types.d.ts +0 -11
  269. package/segmented-control/types.js +0 -1
  270. package/segmented-control-option/index.d.ts +0 -11
  271. package/segmented-control-option/index.js +0 -95
  272. package/segmented-control-option/types.d.ts +0 -19
  273. package/segmented-control-option/types.js +0 -1
  274. package/segmented-icon-control/index.d.ts +0 -11
  275. package/segmented-icon-control/index.js +0 -101
  276. package/segmented-icon-control/types.d.ts +0 -14
  277. package/segmented-icon-control/types.js +0 -1
  278. package/segmented-icon-control-option/index.d.ts +0 -11
  279. package/segmented-icon-control-option/index.js +0 -82
  280. package/segmented-icon-control-option/types.d.ts +0 -16
  281. package/segmented-icon-control-option/types.js +0 -1
  282. package/select-button/index.d.ts +0 -13
  283. package/select-button/index.js +0 -202
  284. package/select-button/types.d.ts +0 -50
  285. package/select-button/types.js +0 -1
  286. package/select-menu/index.d.ts +0 -15
  287. package/select-menu/index.js +0 -339
  288. package/select-menu/types.d.ts +0 -41
  289. package/select-menu/types.js +0 -1
  290. package/select-menu-option/index.d.ts +0 -28
  291. package/select-menu-option/index.js +0 -65
  292. package/select-menu-option/types.d.ts +0 -26
  293. package/select-menu-option/types.js +0 -1
  294. package/skeleton/index.d.ts +0 -11
  295. package/skeleton/index.js +0 -108
  296. package/skeleton/types.d.ts +0 -9
  297. package/skeleton/types.js +0 -1
  298. package/skeleton-item/index.d.ts +0 -11
  299. package/skeleton-item/index.js +0 -11
  300. package/skeleton-item/types.d.ts +0 -13
  301. package/skeleton-item/types.js +0 -1
  302. package/spinner/index.d.ts +0 -11
  303. package/spinner/index.js +0 -58
  304. package/spinner/types.d.ts +0 -12
  305. package/spinner/types.js +0 -1
  306. package/standalone.d.ts +0 -85
  307. package/standalone.js +0 -87
  308. package/stop-events/index.d.ts +0 -1
  309. package/stop-events/index.js +0 -27
  310. package/table/index.d.ts +0 -11
  311. package/table/index.js +0 -14
  312. package/table/types.d.ts +0 -3
  313. package/table/types.js +0 -1
  314. package/table-body/index.d.ts +0 -11
  315. package/table-body/index.js +0 -14
  316. package/table-body/types.d.ts +0 -3
  317. package/table-body/types.js +0 -1
  318. package/table-cell/index.d.ts +0 -11
  319. package/table-cell/index.js +0 -21
  320. package/table-cell/types.d.ts +0 -9
  321. package/table-cell/types.js +0 -1
  322. package/table-cell/utils.d.ts +0 -2
  323. package/table-cell/utils.js +0 -1
  324. package/table-head/index.d.ts +0 -11
  325. package/table-head/index.js +0 -14
  326. package/table-head/types.d.ts +0 -3
  327. package/table-head/types.js +0 -1
  328. package/table-head-cell/index.d.ts +0 -12
  329. package/table-head-cell/index.js +0 -57
  330. package/table-head-cell/types.d.ts +0 -15
  331. package/table-head-cell/types.js +0 -1
  332. package/table-row/index.d.ts +0 -11
  333. package/table-row/index.js +0 -42
  334. package/table-row/types.d.ts +0 -11
  335. package/table-row/types.js +0 -1
  336. package/tabs/index.d.ts +0 -11
  337. package/tabs/index.js +0 -80
  338. package/tabs/types.d.ts +0 -18
  339. package/tabs/types.js +0 -1
  340. package/tabs-icon-option/index.d.ts +0 -11
  341. package/tabs-icon-option/index.js +0 -79
  342. package/tabs-icon-option/types.d.ts +0 -19
  343. package/tabs-icon-option/types.js +0 -1
  344. package/tabs-option/index.d.ts +0 -12
  345. package/tabs-option/index.js +0 -86
  346. package/tabs-option/types.d.ts +0 -25
  347. package/tabs-option/types.js +0 -1
  348. package/tag/index.d.ts +0 -12
  349. package/tag/index.js +0 -84
  350. package/tag/types.d.ts +0 -23
  351. package/tag/types.js +0 -1
  352. package/tag/utils.d.ts +0 -2
  353. package/tag/utils.js +0 -6
  354. package/text/index.d.ts +0 -11
  355. package/text/index.js +0 -64
  356. package/text/types.d.ts +0 -30
  357. package/text/types.js +0 -1
  358. package/text/utils.d.ts +0 -2
  359. package/text/utils.js +0 -1
  360. package/textarea/index.d.ts +0 -11
  361. package/textarea/index.js +0 -322
  362. package/textarea/types.d.ts +0 -60
  363. package/textarea/types.js +0 -1
  364. package/tile-control/index.d.ts +0 -11
  365. package/tile-control/index.js +0 -110
  366. package/tile-control/types.d.ts +0 -37
  367. package/tile-control/types.js +0 -1
  368. package/tile-control-option/index.d.ts +0 -11
  369. package/tile-control-option/index.js +0 -98
  370. package/tile-control-option/types.d.ts +0 -37
  371. package/tile-control-option/types.js +0 -1
  372. package/time-picker/index.d.ts +0 -15
  373. package/time-picker/index.js +0 -337
  374. package/time-picker/types.d.ts +0 -34
  375. package/time-picker/types.js +0 -1
  376. package/time-picker/utils.d.ts +0 -11
  377. package/time-picker/utils.js +0 -75
  378. package/title/index.d.ts +0 -11
  379. package/title/index.js +0 -60
  380. package/title/types.d.ts +0 -31
  381. package/title/types.js +0 -1
  382. package/title/utils.d.ts +0 -3
  383. package/title/utils.js +0 -17
  384. package/toast/index.d.ts +0 -13
  385. package/toast/index.js +0 -86
  386. package/toast/types.d.ts +0 -28
  387. package/toast/types.js +0 -1
  388. package/toast/utils.d.ts +0 -2
  389. package/toast/utils.js +0 -1
  390. package/toast-manager/index.d.ts +0 -13
  391. package/toast-manager/index.js +0 -170
  392. package/toast-manager/types.d.ts +0 -13
  393. package/toast-manager/types.js +0 -1
  394. package/toast-manager/utils.d.ts +0 -2
  395. package/toast-manager/utils.js +0 -1
  396. package/toggle/index.d.ts +0 -11
  397. package/toggle/index.js +0 -141
  398. package/toggle/types.d.ts +0 -23
  399. package/toggle/types.js +0 -1
  400. package/tooltip/index.d.ts +0 -13
  401. package/tooltip/index.js +0 -264
  402. package/tooltip/tooltip-state.d.ts +0 -19
  403. package/tooltip/tooltip-state.js +0 -126
  404. package/tooltip/types.d.ts +0 -35
  405. package/tooltip/types.js +0 -1
  406. package/tooltip/utils.d.ts +0 -5
  407. package/tooltip/utils.js +0 -17
  408. package/utils/context.d.ts +0 -20
  409. package/utils/context.js +0 -84
  410. package/utils/countries.d.ts +0 -6
  411. package/utils/countries.js +0 -2
  412. package/utils/csv.d.ts +0 -5
  413. package/utils/csv.js +0 -22
  414. package/utils/debounce.d.ts +0 -8
  415. package/utils/debounce.js +0 -22
  416. package/utils/dom.d.ts +0 -34
  417. package/utils/dom.js +0 -154
  418. package/utils/element.d.ts +0 -16
  419. package/utils/element.js +0 -48
  420. package/utils/event-target.d.ts +0 -4
  421. package/utils/event-target.js +0 -26
  422. package/utils/get-react-event-handler.d.ts +0 -1
  423. package/utils/get-react-event-handler.js +0 -8
  424. package/utils/index.d.ts +0 -12
  425. package/utils/index.js +0 -12
  426. package/utils/markdown.d.ts +0 -19
  427. package/utils/markdown.js +0 -143
  428. package/utils/rect.d.ts +0 -4
  429. package/utils/rect.js +0 -28
  430. package/utils/size.d.ts +0 -5
  431. package/utils/size.js +0 -3
  432. package/utils/slot.d.ts +0 -4
  433. package/utils/slot.js +0 -38
  434. package/utils/throttle.d.ts +0 -4
  435. package/utils/throttle.js +0 -20
  436. package/utils/uid.d.ts +0 -1
  437. package/utils/uid.js +0 -13
  438. package/vertical-stepper/index.d.ts +0 -11
  439. package/vertical-stepper/index.js +0 -57
  440. package/vertical-stepper/types.d.ts +0 -13
  441. package/vertical-stepper/types.js +0 -1
  442. package/vertical-stepper-item/index.d.ts +0 -14
  443. package/vertical-stepper-item/index.js +0 -61
  444. package/vertical-stepper-item/types.d.ts +0 -24
  445. package/vertical-stepper-item/types.js +0 -1
  446. package/vertical-stepper-item/utils.d.ts +0 -2
  447. package/vertical-stepper-item/utils.js +0 -1
package/alert/index.js DELETED
@@ -1,48 +0,0 @@
1
- import '../icon';
2
- import '../rich-text';
3
- import '../text';
4
- import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement } from '../utils';
5
- const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;gap:8px;align-items:center;padding:8px 16px;box-sizing:border-box;width:100%;min-height:48px}:host([type=warn]) #wrapper{background-color:var(--sinch-comp-alert-color-warning-default-background)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-alert-color-error-default-background)}:host([type=info]) #wrapper{background-color:var(--sinch-comp-alert-color-info-default-background)}#icon-error,#icon-info,#icon-warn{display:none}#icon-warn{--sinch-global-color-icon:var(--sinch-comp-alert-color-warning-default-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-alert-color-error-default-icon)}#icon-info{--sinch-global-color-icon:var(--sinch-comp-alert-color-info-default-icon)}:host([type=error]) #icon-error,:host([type=info]) #icon-info,:host([type=warn]) #icon-warn{display:block}#text{display:flex;flex-direction:column;gap:8px;flex:1;min-width:0;--sinch-comp-rich-text-font:var(--sinch-comp-alert-font-body)}:host([type=warn]) #text{--sinch-global-color-text:var(--sinch-comp-alert-color-warning-default-text)}:host([type=error]) #text{--sinch-global-color-text:var(--sinch-comp-alert-color-error-default-text)}:host([type=info]) #text{--sinch-global-color-text:var(--sinch-comp-alert-color-info-default-text)}</style><div id="wrapper"><sinch-icon id="icon-info" name="info"></sinch-icon><sinch-icon id="icon-warn" name="report_problem"></sinch-icon><sinch-icon id="icon-error" name="report"></sinch-icon><sinch-rich-text id="text"></sinch-rich-text><slot name="action"></slot><slot name="close"></slot></div>';
6
- import { typeValues } from './utils';
7
- const template = document.createElement('template');
8
- template.innerHTML = templateHTML;
9
- defineCustomElement('sinch-alert', class extends NectaryElement {
10
- #$text;
11
- constructor() {
12
- super();
13
- const shadowRoot = this.attachShadow();
14
- shadowRoot.appendChild(template.content.cloneNode(true));
15
- this.#$text = shadowRoot.querySelector('#text');
16
- }
17
- connectedCallback() {
18
- super.connectedCallback();
19
- this.setAttribute('role', 'alert');
20
- }
21
- disconnectedCallback() {
22
- super.disconnectedCallback();
23
- }
24
- static get observedAttributes() {
25
- return ['text'];
26
- }
27
- attributeChangedCallback(name, _, newVal) {
28
- switch (name) {
29
- case 'text':
30
- {
31
- updateAttribute(this.#$text, 'text', newVal);
32
- break;
33
- }
34
- }
35
- }
36
- get type() {
37
- return getLiteralAttribute(this, typeValues, 'type');
38
- }
39
- set type(value) {
40
- updateLiteralAttribute(this, typeValues, 'type', value);
41
- }
42
- get text() {
43
- return getAttribute(this, 'text', '');
44
- }
45
- set text(value) {
46
- updateAttribute(this, 'text', value);
47
- }
48
- });
package/alert/types.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { TSinchElementReact } from '../types';
2
- export type TSinchAlertType = 'info' | 'warn' | 'error';
3
- export type TSinchAlertElement = HTMLElement & {
4
- /** Type */
5
- type: TSinchAlertType;
6
- /** Text */
7
- text: string;
8
- /** Type */
9
- setAttribute(name: 'type', value: TSinchAlertType): void;
10
- /** Text */
11
- setAttribute(name: 'text', value: string): void;
12
- };
13
- export type TSinchAlertReact = TSinchElementReact<TSinchAlertElement> & {
14
- /** Type */
15
- type: TSinchAlertType;
16
- /** Text */
17
- text: string;
18
- };
package/alert/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/alert/utils.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { TSinchAlertType } from './types';
2
- export declare const typeValues: readonly TSinchAlertType[];
package/alert/utils.js DELETED
@@ -1 +0,0 @@
1
- export const typeValues = ['info', 'warn', 'error'];
package/avatar/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { TSinchAvatarElement, TSinchAvatarReact } from './types';
2
- declare global {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- 'sinch-avatar': TSinchAvatarReact;
6
- }
7
- }
8
- interface HTMLElementTagNameMap {
9
- 'sinch-avatar': TSinchAvatarElement;
10
- }
11
- }
package/avatar/index.js DELETED
@@ -1,94 +0,0 @@
1
- import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
2
- import { DEFAULT_SIZE, sizeValues } from '../utils/size';
3
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);background-color:var(--sinch-comp-avatar-border-color-default-initial);border-radius:var(--sinch-comp-avatar-shape-radius);--sinch-local-size:var(--sinch-comp-avatar-size-m)}:host([size="l"]) #wrapper{--sinch-local-size:var(--sinch-comp-avatar-size-l)}:host([size="s"]) #wrapper{--sinch-local-size:var(--sinch-comp-avatar-size-s)}#text{display:block;width:100%;height:100%;font:var(--sinch-comp-avatar-container-font-size-m-text);line-height:calc(var(--sinch-local-size) - 2px);text-transform:uppercase;text-align:center}:host([size="l"]) #text{font:var(--sinch-comp-avatar-container-font-size-l-text);line-height:calc(var(--sinch-local-size) - 2px)}:host([size="s"]) #text{font:var(--sinch-comp-avatar-container-font-size-s-text);line-height:calc(var(--sinch-local-size) - 2px)}#circle{position:relative;width:calc(100% - 2px);height:calc(100% - 2px);left:1px;top:1px;border-radius:50%;-webkit-mask:linear-gradient(#fff,#000);mask:linear-gradient(#fff,#000);background-color:var(--sinch-comp-avatar-container-color-default-background);color:var(--sinch-comp-avatar-container-color-default-foreground)}#image{display:none;position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain}:host([src]:not([src=""])) #image{display:block}#person{display:none;position:absolute;left:0;top:0;width:100%;height:100%;fill:var(--sinch-comp-avatar-container-color-default-foreground);opacity:.15}:host(:not([src]):is(:not([alt]),[alt=""])) #person{display:block}#status-wrapper{position:absolute;left:calc(85% - 5px);top:calc(85% - 5px);width:10px;height:10px;padding:1px;box-sizing:border-box;border-radius:50%;background-color:var(--sinch-comp-avatar-border-color-default-initial);display:none;pointer-events:none}#status{width:8px;height:8px;border-radius:50%}:host([status=away]) #status-wrapper,:host([status=busy]) #status-wrapper,:host([status=offline]) #status-wrapper,:host([status=online]) #status-wrapper{display:block}:host([status=online]) #status{background-color:var(--sinch-comp-avatar-status-color-online-default-background)}:host([status=away]) #status{background-color:var(--sinch-comp-avatar-status-color-away-default-background)}:host([status=busy]) #status{background-color:var(--sinch-comp-avatar-status-color-busy-default-background)}:host([status=offline]) #status{background-color:var(--sinch-comp-avatar-status-color-offline-default-background)}</style><div id="wrapper"><div id="circle"><span id="text"></span><img id="image" alt=""/><svg id="person" viewBox="0 0 40 40" fill="none"><path d="M29.451 15.785a9.451 9.451 0 1 1-18.902 0 9.452 9.452 0 0 1 18.902 0ZM4.734 40.5c.119-7.085 5.899-12.792 13.012-12.792h4.508c7.113 0 12.893 5.707 13.012 12.792H4.734Z"/></svg></div><div id="status-wrapper"><div id="status"></div></div></div>';
4
- import { getAvatarColorBg, getAvatarColorFg, statusValues } from './utils';
5
- const template = document.createElement('template');
6
- template.innerHTML = templateHTML;
7
- defineCustomElement('sinch-avatar', class extends NectaryElement {
8
- #$circle;
9
- #$text;
10
- #$image;
11
- constructor() {
12
- super();
13
- const shadowRoot = this.attachShadow();
14
- shadowRoot.appendChild(template.content.cloneNode(true));
15
- this.#$circle = shadowRoot.querySelector('#circle');
16
- this.#$text = shadowRoot.querySelector('#text');
17
- this.#$image = shadowRoot.querySelector('#image');
18
- }
19
- connectedCallback() {
20
- super.connectedCallback();
21
- this.#updateColor();
22
- }
23
- disconnectedCallback() {
24
- super.disconnectedCallback();
25
- }
26
- static get observedAttributes() {
27
- return ['alt', 'src', 'color'];
28
- }
29
- attributeChangedCallback(name, _, newVal) {
30
- switch (name) {
31
- case 'alt':
32
- {
33
- this.#$text.textContent = newVal;
34
- this.#$image.alt = newVal ?? '';
35
- break;
36
- }
37
- case 'src':
38
- {
39
- this.#$image.src = newVal ?? '';
40
- break;
41
- }
42
- case 'color':
43
- {
44
- this.#updateColor();
45
- break;
46
- }
47
- }
48
- }
49
- get src() {
50
- return getAttribute(this, 'src');
51
- }
52
- set src(value) {
53
- updateAttribute(this, 'src', value);
54
- }
55
- get alt() {
56
- return getAttribute(this, 'alt', '');
57
- }
58
- set alt(value) {
59
- updateAttribute(this, 'alt', value);
60
- }
61
- get color() {
62
- return getAttribute(this, 'color');
63
- }
64
- set color(value) {
65
- updateAttribute(this, 'color', value);
66
- }
67
- get size() {
68
- return getLiteralAttribute(this, sizeValues, 'size', DEFAULT_SIZE);
69
- }
70
- set size(value) {
71
- updateLiteralAttribute(this, sizeValues, 'size', value);
72
- }
73
- get status() {
74
- return getLiteralAttribute(this, statusValues, 'status', null);
75
- }
76
- set status(value) {
77
- updateLiteralAttribute(this, statusValues, 'status', value);
78
- }
79
- #updateColor() {
80
- if (!this.isDomConnected) {
81
- return;
82
- }
83
- const colorName = this.color;
84
- if (colorName !== null && colorName.length > 0) {
85
- const bg = getAvatarColorBg(colorName);
86
- const fg = getAvatarColorFg(colorName);
87
- this.#$circle.style.setProperty('background-color', bg);
88
- this.#$circle.style.setProperty('color', fg);
89
- } else {
90
- this.#$circle.style.removeProperty('background-color');
91
- this.#$circle.style.removeProperty('color');
92
- }
93
- }
94
- });
package/avatar/types.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import type { TSinchElementReact } from '../types';
2
- import type { TSinchSize } from '../utils/size';
3
- export type TSinchAvatarStatus = 'online' | 'busy' | 'away' | 'offline';
4
- export type TSinchAvatarElement = HTMLElement & {
5
- /** Image source */
6
- src: string | null;
7
- /** Alt text */
8
- alt: string;
9
- /** Background color */
10
- color: string | null;
11
- /** Status */
12
- status: TSinchAvatarStatus | null;
13
- /** Size, `m` by default */
14
- size: TSinchSize;
15
- /** Image source */
16
- setAttribute(name: 'src', value: string): void;
17
- /** Alt text */
18
- setAttribute(name: 'alt', value: string): void;
19
- /** Background color */
20
- setAttribute(name: 'color', value: string): void;
21
- /** Size, `m` by default */
22
- setAttribute(name: 'size', value: TSinchSize): void;
23
- /** Status */
24
- setAttribute(name: 'status', value: TSinchAvatarStatus): void;
25
- };
26
- export type TSinchAvatarReact = TSinchElementReact<TSinchAvatarElement> & {
27
- /** Image source */
28
- src?: string;
29
- /** Alt text */
30
- alt?: string;
31
- /** Background color */
32
- color?: string;
33
- /** Size, `m` by default */
34
- size?: TSinchSize;
35
- /** Status */
36
- status?: TSinchAvatarStatus;
37
- };
package/avatar/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/avatar/utils.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { TSinchAvatarStatus } from './types';
2
- export declare const statusValues: readonly TSinchAvatarStatus[];
3
- export declare const getAvatarColorBg: (id: string) => string;
4
- export declare const getAvatarColorFg: (id: string) => string;
package/avatar/utils.js DELETED
@@ -1,7 +0,0 @@
1
- export const statusValues = ['online', 'busy', 'away', 'offline'];
2
- export const getAvatarColorBg = id => {
3
- return `var(--sinch-comp-avatar-container-color-${id}-background)`;
4
- };
5
- export const getAvatarColorFg = id => {
6
- return `var(--sinch-comp-avatar-container-color-${id}-foreground)`;
7
- };
package/badge/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { TSinchBadgeElement, TSinchBadgeReact } from './types';
2
- declare global {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- 'sinch-badge': TSinchBadgeReact;
6
- }
7
- }
8
- interface HTMLElementTagNameMap {
9
- 'sinch-badge': TSinchBadgeElement;
10
- }
11
- }
package/badge/index.js DELETED
@@ -1,114 +0,0 @@
1
- import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrEqual, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
2
- import { DEFAULT_SIZE, sizeValues } from '../utils/size';
3
- const templateHTML = '<style>:host{display:inline-flex;flex-direction:column;position:relative}#badge-wrapper{position:absolute;left:0;top:0;width:fit-content;border-radius:var(--sinch-comp-badge-shape-radius);padding:1px;pointer-events:none;background-color:var(--sinch-comp-badge-color-border)}#badge{box-sizing:border-box;color:var(--sinch-comp-badge-color-text);background-color:var(--sinch-comp-badge-color-background);width:20px;height:20px;border-radius:var(--sinch-comp-badge-shape-radius)}#badge.long{width:fit-content;padding:0 5px}#text{display:block;width:100%;height:100%;text-align:center;font:var(--sinch-comp-badge-font-size-l);line-height:20px;text-rendering:optimizelegibility}:host([size="m"]) #badge-wrapper{left:calc(100% - 8px);top:-8px}:host([size="m"]) #badge{width:14px;height:14px}:host([size="m"]) #badge.long{width:fit-content;padding:0 3px}:host([size="m"]) #text{font:var(--sinch-comp-badge-font-size-m);line-height:14px}:host([size="s"]) #badge{width:8px;height:8px;padding:0}:host([size="s"]) #text{display:none}:host([hidden]) #badge-wrapper{display:none}</style><slot id="slot"></slot><div id="badge-wrapper"><div id="badge"><span id="text"></span></div></div>';
4
- import { modeValues } from './utils';
5
- const template = document.createElement('template');
6
- template.innerHTML = templateHTML;
7
- defineCustomElement('sinch-badge', class extends NectaryElement {
8
- #$badgeWrapper;
9
- #$badge;
10
- #$text;
11
- #observer;
12
- constructor() {
13
- super();
14
- const shadowRoot = this.attachShadow();
15
- shadowRoot.appendChild(template.content.cloneNode(true));
16
- this.#$badgeWrapper = shadowRoot.querySelector('#badge-wrapper');
17
- this.#$badge = shadowRoot.querySelector('#badge');
18
- this.#$text = shadowRoot.querySelector('#text');
19
- this.#observer = new ResizeObserver(this.#onResize);
20
- }
21
- connectedCallback() {
22
- super.connectedCallback();
23
- this.#observer.observe(this);
24
- }
25
- disconnectedCallback() {
26
- super.disconnectedCallback();
27
- this.#observer.unobserve(this);
28
- }
29
- static get observedAttributes() {
30
- return ['text', 'size', 'mode', 'hidden'];
31
- }
32
- attributeChangedCallback(name, oldVal, newVal) {
33
- if (isAttrEqual(oldVal, newVal)) {
34
- return;
35
- }
36
- switch (name) {
37
- case 'text':
38
- {
39
- this.#$text.textContent = newVal;
40
- setClass(this.#$badge, 'long', newVal !== null && newVal.length > 1);
41
- break;
42
- }
43
- case 'size':
44
- {
45
- this.#updatePosition();
46
- break;
47
- }
48
- case 'mode':
49
- {
50
- this.#updatePosition();
51
- break;
52
- }
53
- case 'hidden':
54
- {
55
- this.#updatePosition();
56
- updateBooleanAttribute(this, name, isAttrTrue(newVal));
57
- break;
58
- }
59
- }
60
- }
61
- get text() {
62
- return getAttribute(this, 'text', '');
63
- }
64
- set text(value) {
65
- updateAttribute(this, 'text', value);
66
- }
67
- get size() {
68
- return getLiteralAttribute(this, sizeValues, 'size', DEFAULT_SIZE);
69
- }
70
- set size(value) {
71
- updateLiteralAttribute(this, sizeValues, 'size', value);
72
- }
73
- get mode() {
74
- return getLiteralAttribute(this, modeValues, 'mode', 'square');
75
- }
76
- set mode(value) {
77
- updateLiteralAttribute(this, modeValues, 'mode', value);
78
- }
79
- get hidden() {
80
- return getBooleanAttribute(this, 'hidden');
81
- }
82
- set hidden(isHidden) {
83
- updateBooleanAttribute(this, 'hidden', isHidden);
84
- }
85
- get badgeRect() {
86
- if (this.hidden) {
87
- const selfRect = getRect(this);
88
- return {
89
- x: selfRect.x + selfRect.width,
90
- y: selfRect.y,
91
- width: 0,
92
- height: 0
93
- };
94
- }
95
- return getRect(this.#$badgeWrapper);
96
- }
97
- #updatePosition() {
98
- if (this.hidden) {
99
- return;
100
- }
101
- const mode = this.mode;
102
- const targetRect = this.getBoundingClientRect();
103
- const badgeRect = this.#$badgeWrapper.getBoundingClientRect();
104
- const offsetMultX = mode === 'circle' ? 0.85 : 1;
105
- const offsetMultY = mode === 'circle' ? 0.15 : 0;
106
- const posX = Math.round(targetRect.width * offsetMultX - badgeRect.height / 2);
107
- const posY = Math.round(targetRect.height * offsetMultY - badgeRect.height / 2);
108
- this.#$badgeWrapper.style.setProperty('left', `${posX}px`);
109
- this.#$badgeWrapper.style.setProperty('top', `${posY}px`);
110
- }
111
- #onResize = () => {
112
- this.#updatePosition();
113
- };
114
- });
package/badge/types.d.ts DELETED
@@ -1,34 +0,0 @@
1
- import type { TRect, TSinchElementReact } from '../types';
2
- import type { TSinchSize } from '../utils/size';
3
- export type TSinchBadgeMode = 'square' | 'circle';
4
- export type TSinchBadgeElement = HTMLElement & {
5
- /** Text */
6
- text: string;
7
- /** Size */
8
- size: TSinchSize;
9
- /** Mode, `square` by default */
10
- mode: TSinchBadgeMode;
11
- /** Hidden */
12
- hidden: boolean;
13
- readonly badgeRect: TRect;
14
- /** Text */
15
- setAttribute(name: 'text', value: string): void;
16
- /** Size */
17
- setAttribute(name: 'size', value: TSinchSize): void;
18
- /** Mode, `square` by default */
19
- setAttribute(name: 'mode', value: TSinchBadgeMode): void;
20
- /** Color */
21
- setAttribute(name: 'color', value: string): void;
22
- /** Hidden */
23
- setAttribute(name: 'hidden', value: ''): void;
24
- };
25
- export type TSinchBadgeReact = TSinchElementReact<TSinchBadgeElement> & {
26
- /** Text */
27
- text: string;
28
- /** Size */
29
- size?: TSinchSize;
30
- /** Mode, `square` by default */
31
- mode?: TSinchBadgeMode;
32
- /** Hidden */
33
- hidden?: boolean;
34
- };
package/badge/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/badge/utils.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { TSinchBadgeMode } from './types';
2
- export declare const modeValues: readonly TSinchBadgeMode[];
package/badge/utils.js DELETED
@@ -1 +0,0 @@
1
- export const modeValues = ['square', 'circle'];
package/button/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { TSinchButtonElement, TSinchButtonReact } from './types';
2
- declare global {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- 'sinch-button': TSinchButtonReact;
6
- }
7
- }
8
- interface HTMLElementTagNameMap {
9
- 'sinch-button': TSinchButtonElement;
10
- }
11
- }
package/button/index.js DELETED
@@ -1,182 +0,0 @@
1
- import { defineCustomElement, getBooleanAttribute, getAttribute, isAttrTrue, updateBooleanAttribute, updateAttribute, NectaryElement, getReactEventHandler, getLiteralAttribute, updateLiteralAttribute, Context, subscribeContext, isAttrEqual } from '../utils';
2
- import { DEFAULT_SIZE, sizeExValues } from '../utils/size';
3
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;cursor:pointer;user-select:none}:host([disabled]){cursor:initial}#button{all:initial;display:block;position:relative;width:100%;height:var(--sinch-local-size);user-select:none;--sinch-local-size:var(--sinch-comp-button-size-container-m);--sinch-local-padding:16px;--sinch-local-font:var(--sinch-comp-button-font-size-m-text);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-m);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-m);--sinch-global-color-icon:var(--sinch-local-color-icon)}:host([data-size="l"])>#button{--sinch-local-size:var(--sinch-comp-button-size-container-l);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-l);--sinch-local-font:var(--sinch-comp-button-font-size-l-text);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-l)}:host([data-size="m"])>#button{--sinch-local-size:var(--sinch-comp-button-size-container-m);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-m);--sinch-local-font:var(--sinch-comp-button-font-size-m-text);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-m)}:host([data-size="s"])>#button{--sinch-local-size:var(--sinch-comp-button-size-container-s);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-s);--sinch-local-font:var(--sinch-comp-button-font-size-s-text);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-s)}:host([data-size=xs])>#button{--sinch-local-size:var(--sinch-comp-button-size-container-xs);--sinch-local-padding:8px;--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-xs);--sinch-local-font:var(--sinch-comp-button-font-size-s-text);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-xs)}:host(:is([text=""],:not([text])))>#button{--sinch-local-padding:8px}:host([data-size="s"]:is([text=""],:not([text])))>#button{--sinch-local-padding:4px}:host([data-size=xs]:is([text=""],:not([text])))>#button{--sinch-local-padding:4px}:host([type=primary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-primary-default-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-primary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-primary-default-icon-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-primary-default-outline-focus);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-initial)}:host(:not([type]))>#button,:host([type=secondary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-secondary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-secondary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-secondary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-secondary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-initial)}:host([type=subtle-primary])>#button,:host([type=tertiary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-primary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-subtle-primary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-subtle-primary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-subtle-primary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-subtle-primary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-initial)}:host(:not([type]):is([text=""],:not([text])))>#button,:host([type=subtle-secondary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-secondary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-subtle-secondary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-subtle-secondary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-subtle-secondary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-subtle-secondary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-initial)}:host([type=cta-primary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-primary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-cta-primary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-cta-primary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-cta-primary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-initial)}:host([type=cta-secondary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-secondary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-cta-secondary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-cta-secondary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-cta-secondary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-initial)}:host([type=destructive])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-danger-default-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-danger-default-text-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-danger-default-icon-initial)}:host([type=primary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-focus)}:host(:not([type]):focus-visible)>#button,:host([type=secondary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-focus)}:host([type=subtle-primary]:focus-visible)>#button,:host([type=tertiary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-focus)}:host(:not([type]):is([text=""],:not([text])):focus-visible)>#button,:host([type=subtle-secondary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-focus)}:host([type=cta-primary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-focus)}:host([type=cta-secondary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-focus)}:host([type=destructive]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-focus)}:host([toggled]:not([disabled])[type=subtle-primary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-primary-toggled-background-initial)}:host([toggled]:not([disabled]):not([type]):is([text=""],:not([text])))>#button,:host([toggled]:not([disabled])[type=subtle-secondary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-secondary-toggled-background-initial)}:host([type=primary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-hover)}:host([type=primary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-active)}:host(:not([type]):hover)>#button,:host([type=secondary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-hover)}:host(:not([type]):active)>#button,:host([type=secondary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-active)}:host([type=subtle-primary]:hover)>#button,:host([type=tertiary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-primary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-hover)}:host([type=subtle-primary]:active)>#button,:host([type=tertiary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-primary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-active)}:host(:not([type]):is([text=""],:not([text])):hover)>#button,:host([type=subtle-secondary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-hover)}:host(:not([type]):is([text=""],:not([text])):active)>#button,:host([type=subtle-secondary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-active)}:host([type=cta-primary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-hover)}:host([type=cta-primary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-active)}:host([type=cta-secondary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-hover)}:host([type=cta-secondary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-active)}:host([type=destructive]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-hover)}:host([type=destructive]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-active)}:host([toggled]:not([disabled])[type=subtle-primary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-primary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-hover)}:host([toggled]:not([disabled])[type=subtle-primary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-primary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-active)}:host([toggled]:not([disabled]):not([type]):is([text=""],:not([text])):hover)>#button,:host([toggled]:not([disabled])[type=subtle-secondary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-hover)}:host([toggled]:not([disabled]):not([type]):is([text=""],:not([text])):active)>#button,:host([toggled]:not([disabled])[type=subtle-secondary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-active)}:host([type=primary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-primary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-primary-disabled-text-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-disabled);--sinch-global-color-icon:var(--sinch-comp-button-color-primary-disabled-icon-initial)}:host(:not([type])[disabled])>#button,:host([type=secondary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-secondary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-secondary-disabled-text-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-disabled);--sinch-global-color-icon:var(--sinch-comp-button-color-secondary-disabled-icon-initial)}:host([type=subtle-primary][disabled])>#button,:host([type=tertiary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-primary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-subtle-primary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-subtle-primary-disabled-text-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-disabled);--sinch-global-color-icon:var(--sinch-comp-button-color-subtle-primary-disabled-icon-initial)}:host(:not([type]):is([text=""],:not([text]))[disabled])>#button,:host([type=subtle-secondary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-subtle-secondary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-subtle-secondary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-subtle-secondary-disabled-text-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-subtle-disabled);--sinch-global-color-icon:var(--sinch-comp-button-color-subtle-secondary-disabled-icon-initial)}:host([type=cta-primary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-primary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-cta-primary-disabled-text-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-disabled);--sinch-global-color-icon:var(--sinch-comp-button-color-cta-primary-disabled-icon-initial)}:host([type=cta-secondary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-secondary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-cta-secondary-disabled-text-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-disabled);--sinch-global-color-icon:var(--sinch-comp-button-color-cta-secondary-disabled-icon-initial)}:host([type=destructive][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-danger-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-danger-disabled-text-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-disabled);--sinch-global-color-icon:var(--sinch-comp-button-color-danger-disabled-icon-initial)}#button::before{content:"";position:absolute;inset:0;background-color:var(--sinch-local-color-background);border:1px solid var(--sinch-local-color-border);border-radius:var(--sinch-local-shape-radius);box-shadow:var(--sinch-local-shadow);pointer-events:none}:host(:not([disabled]):active) #button::before{border-width:2px}:host(:focus-visible) #button::after{position:absolute;content:"";inset:-3px;border:2px solid var(--sinch-local-color-outline-focus);border-radius:calc(var(--sinch-local-shape-radius) + 3px);pointer-events:none}#content{position:relative;display:flex;align-items:center;justify-content:center;gap:12px;width:100%;height:100%;padding:0 var(--sinch-local-padding);box-sizing:border-box;pointer-events:none;overflow:hidden}#text{font:var(--sinch-local-font);color:var(--sinch-local-color-text);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex-shrink:1;min-width:0}:host(:is([text=""],:not([text]))) :is(#left-icon,#right-icon,#text){display:none}::slotted(*){display:block}</style><div id="button" inert><div id="content"><slot id="left-icon" name="left-icon"></slot><slot id="icon" name="icon"></slot><span id="text"></span><slot id="right-icon" name="right-icon"></slot></div></div>';
4
- import { typeValues } from './utils';
5
- const template = document.createElement('template');
6
- template.innerHTML = templateHTML;
7
- defineCustomElement('sinch-button', class extends NectaryElement {
8
- #$button;
9
- #$text;
10
- #controller = null;
11
- #sizeContext;
12
- constructor() {
13
- super();
14
- const shadowRoot = this.attachShadow();
15
- shadowRoot.appendChild(template.content.cloneNode(true));
16
- this.#$button = shadowRoot.querySelector('#button');
17
- this.#$text = shadowRoot.querySelector('#text');
18
- this.#sizeContext = new Context(this.#$button, 'size');
19
- }
20
- connectedCallback() {
21
- super.connectedCallback();
22
- this.#controller = new AbortController();
23
- const {
24
- signal
25
- } = this.#controller;
26
- this.role = 'button';
27
- this.tabIndex = 0;
28
- this.addEventListener('click', this.#onButtonClick, {
29
- signal
30
- });
31
- this.addEventListener('focus', this.#onButtonFocus, {
32
- signal
33
- });
34
- this.addEventListener('blur', this.#onButtonBlur, {
35
- signal
36
- });
37
- this.addEventListener('keydown', this.#onButtonKeydown, {
38
- signal
39
- });
40
- this.addEventListener('-click', this.#onClickReactHandler, {
41
- signal
42
- });
43
- this.addEventListener('-focus', this.#onFocusReactHandler, {
44
- signal
45
- });
46
- this.addEventListener('-blur', this.#onBlurReactHandler, {
47
- signal
48
- });
49
- subscribeContext(this, 'size', this.#onContextSize, signal);
50
- this.#sizeContext.listen(signal);
51
- this.#onSizeUpdate();
52
- }
53
- disconnectedCallback() {
54
- super.disconnectedCallback();
55
- this.#controller.abort();
56
- this.#controller = null;
57
- }
58
- static get observedAttributes() {
59
- return ['text', 'disabled', 'toggled', 'size', 'data-size'];
60
- }
61
- attributeChangedCallback(name, oldVal, newVal) {
62
- switch (name) {
63
- case 'text':
64
- {
65
- this.#$text.textContent = newVal;
66
- break;
67
- }
68
- case 'disabled':
69
- {
70
- if (!isAttrEqual(oldVal, newVal)) {
71
- updateBooleanAttribute(this, 'disabled', isAttrTrue(newVal));
72
- }
73
- this.ariaDisabled = isAttrTrue(newVal).toString();
74
- break;
75
- }
76
- case 'toggled':
77
- {
78
- if (!isAttrEqual(oldVal, newVal)) {
79
- updateBooleanAttribute(this, 'toggled', isAttrTrue(newVal));
80
- }
81
- this.ariaPressed = isAttrTrue(newVal).toString();
82
- break;
83
- }
84
- case 'size':
85
- {
86
- updateAttribute(this, 'data-size', newVal);
87
- break;
88
- }
89
- case 'data-size':
90
- {
91
- this.#onSizeUpdate();
92
- break;
93
- }
94
- }
95
- }
96
- set type(value) {
97
- updateLiteralAttribute(this, typeValues, 'type', value);
98
- }
99
- get type() {
100
- return getLiteralAttribute(this, typeValues, 'type', 'primary');
101
- }
102
- set text(value) {
103
- updateAttribute(this, 'text', value);
104
- }
105
- get text() {
106
- return getAttribute(this, 'text', '');
107
- }
108
- set disabled(isDisabled) {
109
- updateBooleanAttribute(this, 'disabled', isDisabled);
110
- }
111
- get disabled() {
112
- return getBooleanAttribute(this, 'disabled');
113
- }
114
- set toggled(isToggled) {
115
- updateBooleanAttribute(this, 'toggled', isToggled);
116
- }
117
- get toggled() {
118
- return getBooleanAttribute(this, 'toggled');
119
- }
120
- set size(size) {
121
- updateLiteralAttribute(this, sizeExValues, 'size', size);
122
- }
123
- get size() {
124
- return getLiteralAttribute(this, sizeExValues, 'size', DEFAULT_SIZE);
125
- }
126
- get focusable() {
127
- return true;
128
- }
129
- #onSizeUpdate() {
130
- if (!this.isDomConnected) {
131
- return;
132
- }
133
- const size = getAttribute(this, 'data-size', DEFAULT_SIZE);
134
- this.#sizeContext.dispatch(size);
135
- }
136
- #onContextSize = e => {
137
- if (this.hasAttribute('size')) {
138
- return;
139
- }
140
- switch (e.detail) {
141
- case 'l':
142
- {
143
- this.setAttribute('data-size', 'm');
144
- break;
145
- }
146
- default:
147
- {
148
- this.setAttribute('data-size', 's');
149
- }
150
- }
151
- };
152
- #onButtonKeydown = e => {
153
- switch (e.code) {
154
- case 'Space':
155
- case 'Enter':
156
- {
157
- e.preventDefault();
158
- this.click();
159
- }
160
- }
161
- };
162
- #onButtonClick = () => {
163
- if (!this.disabled) {
164
- this.dispatchEvent(new CustomEvent('-click'));
165
- }
166
- };
167
- #onButtonFocus = () => {
168
- this.dispatchEvent(new CustomEvent('-focus'));
169
- };
170
- #onButtonBlur = () => {
171
- this.dispatchEvent(new CustomEvent('-blur'));
172
- };
173
- #onFocusReactHandler = () => {
174
- getReactEventHandler(this, 'on-focus')?.();
175
- };
176
- #onBlurReactHandler = () => {
177
- getReactEventHandler(this, 'on-blur')?.();
178
- };
179
- #onClickReactHandler = e => {
180
- getReactEventHandler(this, 'on-click')?.(e);
181
- };
182
- });