@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
@@ -1,37 +0,0 @@
1
- import type { TSinchElementReact } from '../types';
2
- export type TSinchTileControlOptionElement = HTMLElement & {
3
- /** Value */
4
- value: string;
5
- /** Text content */
6
- text: string;
7
- /** Disabled */
8
- disabled: boolean;
9
- /** Small */
10
- small: boolean;
11
- /** Focus event */
12
- addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
13
- /** Blur event */
14
- addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
15
- /** Value */
16
- setAttribute(name: 'value', value: string): void;
17
- /** Text content */
18
- setAttribute(attr: 'text', value: string): void;
19
- /** Disabled */
20
- setAttribute(name: 'disabled', value: ''): void;
21
- /** Small */
22
- setAttribute(name: 'small', value: ''): void;
23
- };
24
- export type TSinchTileControlOptionReact = TSinchElementReact<TSinchTileControlOptionElement> & {
25
- /** Value */
26
- value: string;
27
- /** Text content */
28
- text: string;
29
- /** Label that is used for a11y */
30
- 'aria-label': string;
31
- /** Disabled */
32
- disabled?: boolean;
33
- /** Focus handler */
34
- 'on-focus'?: (e: CustomEvent<void>) => void;
35
- /** Blur handler */
36
- 'on-blur'?: (e: CustomEvent<void>) => void;
37
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- import '../icon-button';
2
- import '../icon';
3
- import '../segmented-control';
4
- import '../segmented-control-option';
5
- import type { TSinchTimePickerElement, TSinchTimePickerReact } from './types';
6
- declare global {
7
- namespace JSX {
8
- interface IntrinsicElements {
9
- 'sinch-time-picker': TSinchTimePickerReact;
10
- }
11
- }
12
- interface HTMLElementTagNameMap {
13
- 'sinch-time-picker': TSinchTimePickerElement;
14
- }
15
- }
@@ -1,337 +0,0 @@
1
- import '../icon-button';
2
- import '../icon';
3
- import '../segmented-control';
4
- import '../segmented-control-option';
5
- import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getRect, isAttrEqual, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
6
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;width:248px;padding:16px;box-sizing:border-box;gap:16px}#header{position:relative;width:100%;height:48px;font:var(--sinch-comp-time-picker-header-font);line-height:48px;user-select:none;color:var(--sinch-comp-time-picker-header-color-default-text-initial)}#footer{display:flex;justify-content:center;width:100%;height:32px}#picker{position:relative;width:216px;height:216px;border-radius:50%;box-sizing:border-box;border:1px solid var(--sinch-comp-time-picker-watch-face-color-default-border-initial);background-color:var(--sinch-comp-time-picker-watch-face-color-default-background-initial)}#picker-hours,#picker-minutes{position:absolute;left:0;top:0;width:100%;height:100%;border-radius:50%;pointer-events:none;user-select:none}.digit-hour-12,.digit-hour-24,.digit-minute{position:absolute;width:28px;height:28px;text-align:center;top:calc(50% - 14px);left:calc(50% - 14px);z-index:1;cursor:pointer}.digit-hour-12{font:var(--sinch-comp-time-picker-digit-font-default-h12);color:var(--sinch-comp-time-picker-digit-color-default-h12-initial);line-height:28px}.digit-hour-12.selected{font:var(--sinch-comp-time-picker-digit-font-checked-h12);color:var(--sinch-comp-time-picker-digit-color-checked-h12-default)}.digit-hour-24{font:var(--sinch-comp-time-picker-digit-font-default-h24);color:var(--sinch-comp-time-picker-digit-color-default-h24-initial);line-height:28px}.digit-hour-24.selected{font:var(--sinch-comp-time-picker-digit-font-checked-h24);color:var(--sinch-comp-time-picker-digit-color-checked-h24-initial)}.digit-minute{font:var(--sinch-comp-time-picker-digit-font-default-minutes);color:var(--sinch-comp-time-picker-digit-color-default-minute-initial);line-height:28px}.digit-minute.selected{font:var(--sinch-comp-time-picker-digit-font-checked-minutes);color:var(--sinch-comp-time-picker-digit-color-checked-minute-initial)}#picker-touch{position:absolute;left:0;top:0;width:100%;height:100%;cursor:pointer;border-radius:50%}#needle-hour,#needle-minute,#picker-touch::after{background-color:var(--sinch-comp-time-picker-needle-color-default-background-initial)}#needle-hour,#needle-minute{position:absolute;transform-origin:bottom center;transform:rotate(0);bottom:50%;height:50px;transition-duration:.25s;transition-timing-function:ease-in-out;transition-property:transform height;z-index:2;outline:0}@media (prefers-reduced-motion){#needle-hour,#needle-minute{transition:none}}#needle-hour{width:4px;left:calc(50% - 2px);border-radius:2px}#needle-minute{width:2px;left:calc(50% - 1px);border-radius:1px}#needle-hour:focus-visible,#needle-minute:focus-visible{background-color:var(--sinch-comp-time-picker-needle-color-default-background-focus)}#needle-minute:not(.selected)::after{content:"";position:absolute;transform:translateX(-50%);left:0;top:-16px;width:4px;height:4px;border-radius:50%;background-color:var(--sinch-comp-time-picker-digit-color-checked-minute-initial)}#picker-touch::after{content:"";position:absolute;top:50%;left:50%;width:12px;height:12px;border-radius:50%;transform:translate(-50%,-50%)}#header-hours,#header-minutes{position:absolute;padding:0 4px;width:50px;outline:0}#header-hours{right:calc(50% + 8px);text-align:right}#header-minutes{left:calc(50% + 8px)}#header-colon{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}#submit{position:absolute;right:0;top:50%;transform:translateY(-50%)}#submit-icon{--sinch-global-color-icon:var(--sinch-comp-time-picker-header-color-default-icon-initial)}:host([ampm]) .digit-hour-24{display:none}:host(:not([ampm])) #footer{display:none}</style><div id="wrapper"><div id="header"><div id="header-hours" role="meter" aria-valuemin="0" aria-valuemax="23" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><div id="header-colon">&colon;</div><div id="header-minutes" role="meter" aria-valuemin="0" aria-valuemax="59" aria-valuenow="0" aria-valuetext="0"><span>00</span></div><sinch-icon-button id="submit" size="s" aria-label="Submit"><sinch-icon id="icon-submit" slot="icon" name="done"></sinch-icon></sinch-icon-button></div><div id="picker" aria-hidden="true"><div id="picker-hours"></div><div id="picker-minutes"></div><div id="picker-touch"><div id="needle-hour" tabindex="0"></div><div id="needle-minute" tabindex="0"></div></div></div><div id="footer"><sinch-segmented-control id="ampm"><sinch-segmented-control-option value="am" text="AM" aria-label="AM"></sinch-segmented-control-option><sinch-segmented-control-option value="pm" text="PM" aria-label="PM"></sinch-segmented-control-option></sinch-segmented-control></div></div>';
7
- import { getNeedleRotationDeg, getShortestCssDeg, hourToIndex, parseTime, stringifyHour, stringifyHourFace, stringifyMinute, stringifyTime } from './utils';
8
- const template = document.createElement('template');
9
- template.innerHTML = templateHTML;
10
- const PICKER_RADIUS = 216 / 2;
11
- const MINUTE_DIGIT_SIZE = 30;
12
- const HOUR_12_DIGIT_SIZE = 26;
13
- const HOUR_24_DIGIT_SIZE = 26;
14
- const MINUTE_RADIUS = PICKER_RADIUS - MINUTE_DIGIT_SIZE;
15
- const HOUR_12_RADIUS = MINUTE_RADIUS - HOUR_12_DIGIT_SIZE;
16
- const HOUR_24_RADIUS = HOUR_12_RADIUS - HOUR_24_DIGIT_SIZE;
17
- const NEEDLE_HOUR_12_LENGTH = HOUR_12_RADIUS;
18
- const NEEDLE_HOUR_24_LENGTH = HOUR_24_RADIUS;
19
- const NEEDLE_MINUTE_LENGTH = MINUTE_RADIUS;
20
- defineCustomElement('sinch-time-picker', class extends NectaryElement {
21
- #$pickerHours;
22
- #$pickerMinutes;
23
- #$pickerTouch;
24
- #$needleHour;
25
- #$needleMinute;
26
- #$headerHours;
27
- #$headerHoursText;
28
- #$headerMinutes;
29
- #$headerMinutesText;
30
- #$ampm;
31
- #$submitButton;
32
- #hour = 0;
33
- #minute = 0;
34
- #controller = null;
35
- constructor() {
36
- super();
37
- const shadowRoot = this.attachShadow();
38
- shadowRoot.appendChild(template.content.cloneNode(true));
39
- this.#$pickerHours = shadowRoot.querySelector('#picker-hours');
40
- this.#$pickerMinutes = shadowRoot.querySelector('#picker-minutes');
41
- this.#$pickerTouch = shadowRoot.querySelector('#picker');
42
- this.#$needleHour = shadowRoot.querySelector('#needle-hour');
43
- this.#$needleMinute = shadowRoot.querySelector('#needle-minute');
44
- this.#$headerHours = shadowRoot.querySelector('#header-hours');
45
- this.#$headerMinutes = shadowRoot.querySelector('#header-minutes');
46
- this.#$headerHoursText = shadowRoot.querySelector('#header-hours > span');
47
- this.#$headerMinutesText = shadowRoot.querySelector('#header-minutes > span');
48
- this.#$ampm = shadowRoot.querySelector('#ampm');
49
- this.#$submitButton = shadowRoot.querySelector('#submit');
50
- this.#$needleMinute.style.height = `${NEEDLE_MINUTE_LENGTH}px`;
51
- this.#$needleHour.style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
52
- const MINUTE_DIGIT_RADIUS = MINUTE_RADIUS + MINUTE_DIGIT_SIZE / 2;
53
- const HOUR_12_DIGIT_RADIUS = HOUR_12_RADIUS + HOUR_12_DIGIT_SIZE / 2;
54
- const HOUR_24_DIGIT_RADIUS = HOUR_24_RADIUS + HOUR_24_DIGIT_SIZE / 2;
55
- const hours12Frag = document.createDocumentFragment();
56
- for (let i = 0; i < 12; i++) {
57
- const rad = Math.PI / 6 * (i - 3);
58
- const el = document.createElement('div');
59
- const x = Math.cos(rad) * HOUR_12_DIGIT_RADIUS;
60
- const y = Math.sin(rad) * HOUR_12_DIGIT_RADIUS;
61
- const hourDisplayValue = stringifyHourFace(i);
62
- el.className = 'digit-hour-12';
63
- el.style.transform = `translate(${x}px, ${y}px)`;
64
- el.textContent = hourDisplayValue;
65
- hours12Frag.appendChild(el);
66
- }
67
- this.#$pickerHours.appendChild(hours12Frag);
68
- const hours24Frag = document.createDocumentFragment();
69
- for (let i = 12; i < 24; i++) {
70
- const rad = Math.PI / 6 * (i - 3);
71
- const el = document.createElement('div');
72
- const x = Math.cos(rad) * HOUR_24_DIGIT_RADIUS;
73
- const y = Math.sin(rad) * HOUR_24_DIGIT_RADIUS;
74
- const hourDisplayValue = stringifyHourFace(i);
75
- el.className = 'digit-hour-24';
76
- el.style.transform = `translate(${x}px, ${y}px)`;
77
- el.textContent = hourDisplayValue;
78
- hours24Frag.appendChild(el);
79
- }
80
- this.#$pickerHours.appendChild(hours24Frag);
81
- const minutesFrag = document.createDocumentFragment();
82
- for (let i = 0; i < 60; i += 5) {
83
- const rad = Math.PI / 30 * (i - 15);
84
- const el = document.createElement('div');
85
- const x = Math.cos(rad) * MINUTE_DIGIT_RADIUS;
86
- const y = Math.sin(rad) * MINUTE_DIGIT_RADIUS;
87
- el.className = 'digit-minute';
88
- el.style.transform = `translate(${x}px, ${y}px)`;
89
- el.textContent = stringifyMinute(i);
90
- minutesFrag.appendChild(el);
91
- }
92
- this.#$pickerMinutes.appendChild(minutesFrag);
93
- }
94
- connectedCallback() {
95
- this.#controller = new AbortController();
96
- const options = {
97
- signal: this.#controller.signal
98
- };
99
- this.#$pickerTouch.addEventListener('click', this.#onPickerClick, options);
100
- this.#$ampm.addEventListener('-change', this.#onAmPmChange, options);
101
- this.#$submitButton.addEventListener('click', this.#onSubmitButtonClick, options);
102
- this.#$needleHour.addEventListener('keydown', this.#onHoursKeydown, options);
103
- this.#$needleMinute.addEventListener('keydown', this.#onMinutesKeydown, options);
104
- this.addEventListener('-change', this.#onChangeReactHandler, options);
105
- }
106
- disconnectedCallback() {
107
- this.#controller.abort();
108
- this.#controller = null;
109
- }
110
- static get observedAttributes() {
111
- return ['value', 'ampm', 'submit-aria-label'];
112
- }
113
- attributeChangedCallback(name, prevValue, newVal) {
114
- if (isAttrEqual(prevValue, newVal)) {
115
- return;
116
- }
117
- switch (name) {
118
- case 'value':
119
- {
120
- const {
121
- hours,
122
- minutes
123
- } = parseTime(newVal);
124
- this.#hour = hours;
125
- this.#minute = minutes;
126
- this.#render();
127
- break;
128
- }
129
- case 'ampm':
130
- {
131
- this.#render();
132
- updateBooleanAttribute(this, 'ampm', isAttrTrue(newVal));
133
- break;
134
- }
135
- case 'submit-aria-label':
136
- {
137
- updateAttribute(this.#$submitButton, 'aria-label', newVal);
138
- break;
139
- }
140
- }
141
- }
142
- set value(value) {
143
- updateAttribute(this, 'value', value);
144
- }
145
- get value() {
146
- return getAttribute(this, 'value', '');
147
- }
148
- set ampm(value) {
149
- updateBooleanAttribute(this, 'ampm', value);
150
- }
151
- get ampm() {
152
- return getBooleanAttribute(this, 'ampm');
153
- }
154
- set submitAriaLabel(value) {
155
- updateAttribute(this, 'submit-aria-label', value);
156
- }
157
- get submitAriaLabel() {
158
- return getAttribute(this, 'submit-aria-label', '');
159
- }
160
- get submitButtonRect() {
161
- return getRect(this.#$submitButton);
162
- }
163
- get amButtonRect() {
164
- if (!this.ampm) {
165
- return null;
166
- }
167
- const $am = this.#$ampm.querySelector('[value="am"]');
168
- return $am != null ? getRect($am) : null;
169
- }
170
- get pmButtonRect() {
171
- if (!this.ampm) {
172
- return null;
173
- }
174
- const $pm = this.#$ampm.querySelector('[value="pm"]');
175
- return $pm != null ? getRect($pm) : null;
176
- }
177
- hourDigitRect(hour) {
178
- const $digit = this.#$pickerHours.children[hourToIndex(hour, !this.ampm)];
179
- return $digit != null ? getRect($digit) : null;
180
- }
181
- minuteDigitRect(minute) {
182
- const $digit = this.#$pickerMinutes.children[Math.round(minute / 5)];
183
- return $digit != null ? getRect($digit) : null;
184
- }
185
- #getClickDegree(x, y) {
186
- const touchRect = this.#$pickerTouch.getBoundingClientRect();
187
- const cx = touchRect.width / 2;
188
- const cy = touchRect.height / 2;
189
- const px = x - touchRect.x;
190
- const py = touchRect.height - y + touchRect.y;
191
- const dx = px - cx;
192
- const dy = py - cy;
193
- const len = Math.sqrt(dx * dx + dy * dy);
194
- const cosRad = dx / len;
195
- const rad = Math.acos(cosRad * (dy < 0 ? -1 : 1));
196
- const deg = rad * (180 / Math.PI);
197
- let cssDeg = (deg - 90 - 360) % 360 * -1;
198
- if (dy < 0) {
199
- cssDeg += 180;
200
- }
201
- const rowIndex = len > MINUTE_RADIUS ? 0 : len > HOUR_12_RADIUS ? 1 : 2;
202
- return [cssDeg, rowIndex];
203
- }
204
- #onPickerClick = e => {
205
- const [cssDeg, rowIndex] = this.#getClickDegree(e.x, e.y);
206
- const isHourRowClick = rowIndex > 0;
207
- const isHour24RowClick = rowIndex > 1;
208
- if (isHourRowClick) {
209
- const digitIndex = Math.round(cssDeg / 30) % 12;
210
- const is24 = getBooleanAttribute(this, 'ampm') === false;
211
- if (is24) {
212
- if (isHour24RowClick) {
213
- this.#hour = digitIndex === 0 ? 0 : digitIndex + 12;
214
- } else {
215
- this.#hour = digitIndex === 0 ? 12 : digitIndex;
216
- }
217
- } else {
218
- this.#hour = digitIndex + (this.#$ampm.value === 'pm' ? 12 : 0);
219
- }
220
- this.#$headerHours.focus();
221
- } else {
222
- this.#minute = Math.round(cssDeg / 6) % 60;
223
- this.#$headerMinutes.focus();
224
- }
225
- this.#render();
226
- };
227
- #render() {
228
- const is24 = getBooleanAttribute(this, 'ampm') === false;
229
- this.#selectHour(is24);
230
- this.#selectMinute();
231
- this.#$headerHoursText.textContent = stringifyHour(this.#hour, is24);
232
- this.#$headerMinutesText.textContent = stringifyMinute(this.#minute);
233
- updateAttribute(this.#$headerHours, 'aria-valuenow', this.#hour);
234
- updateAttribute(this.#$headerHours, 'aria-valuetext', this.#hour);
235
- updateAttribute(this.#$headerMinutes, 'aria-valuenow', this.#minute);
236
- updateAttribute(this.#$headerMinutes, 'aria-valuetext', this.#minute);
237
- }
238
- #selectHour(is24) {
239
- const $hours = this.#$pickerHours.children;
240
- const hourDigitIndex = this.#hour % 12;
241
- const selectedIndex = hourToIndex(this.#hour, is24);
242
- const currentCssDeg = getNeedleRotationDeg(this.#$needleHour);
243
- const hourCssDeg = getShortestCssDeg(currentCssDeg, hourDigitIndex * 30);
244
- for (let i = 0; i < $hours.length; i++) {
245
- setClass($hours[i], 'selected', i === selectedIndex);
246
- }
247
- this.#$needleHour.style.transform = `rotate(${hourCssDeg}deg)`;
248
- if (is24) {
249
- if (this.#hour > 0 && this.#hour <= 12) {
250
- this.#$needleHour.style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
251
- } else {
252
- this.#$needleHour.style.height = `${NEEDLE_HOUR_24_LENGTH}px`;
253
- }
254
- } else {
255
- this.#$needleHour.style.height = `${NEEDLE_HOUR_12_LENGTH}px`;
256
- }
257
- this.#$ampm.setAttribute('value', this.#hour >= 0 && this.#hour < 12 ? 'am' : 'pm');
258
- }
259
- #selectMinute() {
260
- const $minutes = this.#$pickerMinutes.children;
261
- const isNeedleSelected = this.#minute % 5 === 0;
262
- const selectedIndex = this.#minute / 5;
263
- const currentCssDeg = getNeedleRotationDeg(this.#$needleMinute);
264
- const minuteCssDeg = getShortestCssDeg(currentCssDeg, this.#minute * 6);
265
- for (let i = 0; i < $minutes.length; i++) {
266
- setClass($minutes[i], 'selected', selectedIndex === i);
267
- }
268
- setClass(this.#$needleMinute, 'selected', isNeedleSelected);
269
- this.#$needleMinute.style.transform = `rotate(${minuteCssDeg}deg)`;
270
- }
271
- #onAmPmChange = e => {
272
- const value = e.detail;
273
- switch (value) {
274
- case 'am':
275
- {
276
- if (this.#hour >= 12) {
277
- this.#hour -= 12;
278
- this.#render();
279
- }
280
- break;
281
- }
282
- case 'pm':
283
- {
284
- if (this.#hour < 12) {
285
- this.#hour += 12;
286
- this.#render();
287
- }
288
- break;
289
- }
290
- }
291
- };
292
- #onSubmitButtonClick = () => {
293
- const value = stringifyTime(this.#hour, this.#minute);
294
- this.dispatchEvent(new CustomEvent('-change', {
295
- detail: value
296
- }));
297
- };
298
- #onHoursKeydown = e => {
299
- switch (e.key) {
300
- case 'ArrowUp':
301
- {
302
- e.preventDefault();
303
- this.#hour = (this.#hour + 1) % 24;
304
- this.#render();
305
- break;
306
- }
307
- case 'ArrowDown':
308
- {
309
- e.preventDefault();
310
- this.#hour = (this.#hour + 23) % 24;
311
- this.#render();
312
- break;
313
- }
314
- }
315
- };
316
- #onMinutesKeydown = e => {
317
- switch (e.key) {
318
- case 'ArrowUp':
319
- {
320
- e.preventDefault();
321
- this.#minute = (this.#minute + 1) % 60;
322
- this.#render();
323
- break;
324
- }
325
- case 'ArrowDown':
326
- {
327
- e.preventDefault();
328
- this.#minute = (this.#minute + 59) % 60;
329
- this.#render();
330
- break;
331
- }
332
- }
333
- };
334
- #onChangeReactHandler = e => {
335
- getReactEventHandler(this, 'on-change')?.(e);
336
- };
337
- });
@@ -1,34 +0,0 @@
1
- import type { TRect, TSinchElementReact } from '../types';
2
- export type TSinchTimePickerElement = HTMLElement & {
3
- /** Time value in ISO 8601 format */
4
- value: string;
5
- /** AM/PM 12-hour clock system, `false` by default */
6
- ampm: boolean;
7
- /** Submit button label that is used for a11y */
8
- submitAriaLabel: string;
9
- readonly submitButtonRect: TRect;
10
- readonly amButtonRect: TRect | null;
11
- readonly pmButtonRect: TRect | null;
12
- hourDigitRect(hour: number): TRect | null;
13
- minuteDigitRect(minute: number): TRect | null;
14
- /** Change value handler, return time in ISO 8601 format */
15
- addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
16
- /** Time value in ISO 8601 format */
17
- setAttribute(name: 'value', value: string): void;
18
- /** AM/PM 12-hour clock system, `false` by default */
19
- setAttribute(name: 'ampm', value: boolean): void;
20
- /** Submit button label that is used for a11y */
21
- setAttribute(name: 'submit-aria-label', value: string): void;
22
- };
23
- export type TSinchTimePickerReact = TSinchElementReact<TSinchTimePickerElement> & {
24
- /** Time value in ISO 8601 format */
25
- value: string;
26
- /** AM/PM 12-hour clock system, `false` by default */
27
- ampm?: boolean;
28
- /** Label that is used for a11y */
29
- 'aria-label': string;
30
- /** Submit button label that is used for a11y */
31
- 'submit-aria-label': string;
32
- /** Change value handler, return time in ISO 8601 format */
33
- 'on-change'?: (e: CustomEvent<string>) => void;
34
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- export declare const parseTime: (value: string | null) => {
2
- hours: number;
3
- minutes: number;
4
- };
5
- export declare const stringifyTime: (hour: number, minute: number) => string;
6
- export declare const stringifyHour: (hour: number, is24: boolean) => string;
7
- export declare const stringifyHourFace: (hour: number) => string;
8
- export declare const stringifyMinute: (minute: number) => string;
9
- export declare const hourToIndex: (hour: number, is24: boolean) => number;
10
- export declare const getNeedleRotationDeg: (elem: HTMLElement) => number;
11
- export declare const getShortestCssDeg: (currentDeg: number, nextDeg: number) => number;
@@ -1,75 +0,0 @@
1
- export const parseTime = value => {
2
- if (value === '' || value === null) {
3
- return {
4
- hours: 0,
5
- minutes: 0
6
- };
7
- }
8
- const timeParts = value.split(':');
9
- const hours = parseInt(timeParts[0] ?? '00');
10
- const minutes = parseInt(timeParts[1] ?? '00');
11
- if (isNaN(hours) || hours > 23 || hours < 0) {
12
- return {
13
- hours: 0,
14
- minutes: 0
15
- };
16
- }
17
- if (isNaN(minutes) || minutes > 59 || minutes < 0) {
18
- return {
19
- hours: 0,
20
- minutes: 0
21
- };
22
- }
23
- return {
24
- hours,
25
- minutes
26
- };
27
- };
28
- const pad = value => {
29
- return value.toString().padStart(2, '0');
30
- };
31
- export const stringifyTime = (hour, minute) => {
32
- return `${pad(hour)}:${pad(minute)}:00`;
33
- };
34
- export const stringifyHour = (hour, is24) => {
35
- if (is24) {
36
- return pad(hour);
37
- }
38
- if (hour === 0 || hour === 12) {
39
- return '12';
40
- }
41
- return pad(hour % 12);
42
- };
43
- export const stringifyHourFace = hour => {
44
- return hour === 0 ? '12' : hour === 12 ? '24' : String(hour);
45
- };
46
- export const stringifyMinute = minute => {
47
- return pad(minute);
48
- };
49
- export const hourToIndex = (hour, is24) => {
50
- if (is24) {
51
- if (hour === 0) {
52
- return 12;
53
- }
54
- if (hour === 12) {
55
- return 0;
56
- }
57
- return hour;
58
- }
59
- return hour % 12;
60
- };
61
- export const getNeedleRotationDeg = elem => {
62
- const match = elem.style.transform.match(/^rotate\((-?\d+)deg\)$/);
63
- if (match === null) {
64
- return 0;
65
- }
66
- return Number(match[1]);
67
- };
68
- export const getShortestCssDeg = (currentDeg, nextDeg) => {
69
- const angle = currentDeg % 360;
70
- const diff = (360 - (angle - nextDeg)) % 360;
71
- if (diff > 180) {
72
- return currentDeg - 360 + diff;
73
- }
74
- return currentDeg + diff;
75
- };
package/title/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { TSinchTitleElement, TSinchTitleReact } from './types';
2
- declare global {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- 'sinch-title': TSinchTitleReact;
6
- }
7
- }
8
- interface HTMLElementTagNameMap {
9
- 'sinch-title': TSinchTitleElement;
10
- }
11
- }
package/title/index.js DELETED
@@ -1,60 +0,0 @@
1
- import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute, isAttrTrue, isAttrEqual } from '../utils';
2
- const templateHTML = '<style>:host{display:block;--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-m)}:host([type=xl]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-xl)}:host([type="l"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-l)}:host([type="m"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-m)}:host([type="s"]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-s)}:host([type=xs]){--sinch-comp-title-font:var(--sinch-sys-font-desktop-title-xs)}#text{letter-spacing:-2%;color:var(--sinch-global-color-text,var(--sinch-sys-color-text-default));font:var(--sinch-comp-title-font)}:host([ellipsis]) #text{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}</style><span id="text"></span>';
3
- import { typeValues } from './utils';
4
- const template = document.createElement('template');
5
- template.innerHTML = templateHTML;
6
- defineCustomElement('sinch-title', class extends NectaryElement {
7
- #$text;
8
- constructor() {
9
- super();
10
- const shadowRoot = this.attachShadow();
11
- shadowRoot.appendChild(template.content.cloneNode(true));
12
- this.#$text = shadowRoot.querySelector('#text');
13
- }
14
- connectedCallback() {
15
- this.setAttribute('role', 'heading');
16
- }
17
- static get observedAttributes() {
18
- return ['text', 'level', 'ellipsis'];
19
- }
20
- attributeChangedCallback(name, oldVal, newVal) {
21
- switch (name) {
22
- case 'text':
23
- {
24
- this.#$text.textContent = newVal;
25
- break;
26
- }
27
- case 'level':
28
- {
29
- updateAttribute(this, 'aria-level', newVal);
30
- break;
31
- }
32
- case 'ellipsis':
33
- {
34
- if (isAttrEqual(oldVal, newVal)) {
35
- break;
36
- }
37
- updateBooleanAttribute(this, 'ellipsis', isAttrTrue(newVal));
38
- break;
39
- }
40
- }
41
- }
42
- get text() {
43
- return getAttribute(this, 'text', '');
44
- }
45
- set text(value) {
46
- updateAttribute(this, 'text', value);
47
- }
48
- set type(value) {
49
- updateLiteralAttribute(this, typeValues, 'type', value);
50
- }
51
- get type() {
52
- return getLiteralAttribute(this, typeValues, 'type');
53
- }
54
- set ellipsis(isEllipsis) {
55
- updateBooleanAttribute(this, 'ellipsis', isEllipsis);
56
- }
57
- get ellipsis() {
58
- return getBooleanAttribute(this, 'ellipsis');
59
- }
60
- });
package/title/types.d.ts DELETED
@@ -1,31 +0,0 @@
1
- import type { TSinchElementReact } from '../types';
2
- export type TSinchTitleType = 'xl' | 'l' | 'm' | 's' | 'xs';
3
- export type TSinchTitleLevel = '1' | '2' | '3' | '4' | '5' | '6';
4
- export type TSinchTitleElement = HTMLElement & {
5
- /** Text */
6
- text: string;
7
- /** Type */
8
- type: TSinchTitleType;
9
- /** Semantical level */
10
- level: TSinchTitleLevel;
11
- /** Cuts the long title with “…” ellipsis */
12
- ellipsis: boolean;
13
- /** Text */
14
- setAttribute(name: 'text', value: string): void;
15
- /** Type */
16
- setAttribute(name: 'type', value: TSinchTitleType): void;
17
- /** Semantical level */
18
- setAttribute(name: 'level', value: TSinchTitleLevel): void;
19
- /** Cuts the long title with “…” ellipsis */
20
- setAttribute(name: 'ellipsis', value: ''): void;
21
- };
22
- export type TSinchTitleReact = TSinchElementReact<TSinchTitleElement> & {
23
- /** Text */
24
- text: string;
25
- /** Type */
26
- type: TSinchTitleType;
27
- /** Semantical level */
28
- level: TSinchTitleLevel;
29
- /** Cuts the long title with “…” ellipsis */
30
- ellipsis?: boolean;
31
- };
package/title/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/title/utils.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { TSinchTitleLevel, TSinchTitleType } from './types';
2
- export declare const typeValues: readonly TSinchTitleType[];
3
- export declare const getTitleLevelFromType: (type: TSinchTitleType) => TSinchTitleLevel;
package/title/utils.js DELETED
@@ -1,17 +0,0 @@
1
- export const typeValues = ['xl', 'l', 'm', 's', 'xs'];
2
- export const getTitleLevelFromType = type => {
3
- switch (type) {
4
- case 'xl':
5
- return '1';
6
- case 'l':
7
- return '2';
8
- case 'm':
9
- return '3';
10
- case 's':
11
- return '4';
12
- case 'xs':
13
- return '5';
14
- default:
15
- return '';
16
- }
17
- };
package/toast/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import '../icon';
2
- import '../rich-text';
3
- import type { TSinchToastElement, TSinchToastReact } from './types';
4
- declare global {
5
- namespace JSX {
6
- interface IntrinsicElements {
7
- 'sinch-toast': TSinchToastReact;
8
- }
9
- }
10
- interface HTMLElementTagNameMap {
11
- 'sinch-toast': TSinchToastElement;
12
- }
13
- }