@nectary/components 2.8.7 → 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 (448) hide show
  1. package/package.json +1 -1
  2. package/types.d.ts +1 -1
  3. package/accordion/index.d.ts +0 -11
  4. package/accordion/index.js +0 -86
  5. package/accordion/types.d.ts +0 -21
  6. package/accordion/types.js +0 -1
  7. package/accordion-item/index.d.ts +0 -14
  8. package/accordion-item/index.js +0 -95
  9. package/accordion-item/types.d.ts +0 -36
  10. package/accordion-item/types.js +0 -1
  11. package/accordion-item/utils.d.ts +0 -2
  12. package/accordion-item/utils.js +0 -1
  13. package/action-menu/index.d.ts +0 -11
  14. package/action-menu/index.js +0 -195
  15. package/action-menu/types.d.ts +0 -13
  16. package/action-menu/types.js +0 -1
  17. package/action-menu-option/index.d.ts +0 -12
  18. package/action-menu-option/index.js +0 -82
  19. package/action-menu-option/types.d.ts +0 -23
  20. package/action-menu-option/types.js +0 -1
  21. package/action-menu-option/utils.d.ts +0 -2
  22. package/action-menu-option/utils.js +0 -3
  23. package/alert/index.d.ts +0 -14
  24. package/alert/index.js +0 -48
  25. package/alert/types.d.ts +0 -18
  26. package/alert/types.js +0 -1
  27. package/alert/utils.d.ts +0 -2
  28. package/alert/utils.js +0 -1
  29. package/avatar/index.d.ts +0 -11
  30. package/avatar/index.js +0 -94
  31. package/avatar/types.d.ts +0 -37
  32. package/avatar/types.js +0 -1
  33. package/avatar/utils.d.ts +0 -4
  34. package/avatar/utils.js +0 -7
  35. package/badge/index.d.ts +0 -11
  36. package/badge/index.js +0 -114
  37. package/badge/types.d.ts +0 -34
  38. package/badge/types.js +0 -1
  39. package/badge/utils.d.ts +0 -2
  40. package/badge/utils.js +0 -1
  41. package/button/index.d.ts +0 -11
  42. package/button/index.js +0 -182
  43. package/button/types.d.ts +0 -53
  44. package/button/types.js +0 -1
  45. package/button/utils.d.ts +0 -2
  46. package/button/utils.js +0 -1
  47. package/card/index.d.ts +0 -13
  48. package/card/index.js +0 -133
  49. package/card/types.d.ts +0 -28
  50. package/card/types.js +0 -1
  51. package/card-container/index.d.ts +0 -11
  52. package/card-container/index.js +0 -11
  53. package/card-container/types.d.ts +0 -3
  54. package/card-container/types.js +0 -1
  55. package/chat/index.d.ts +0 -11
  56. package/chat/index.js +0 -11
  57. package/chat/types.d.ts +0 -3
  58. package/chat/types.js +0 -1
  59. package/chat-block/index.d.ts +0 -11
  60. package/chat-block/index.js +0 -86
  61. package/chat-block/types.d.ts +0 -30
  62. package/chat-block/types.js +0 -1
  63. package/chat-bubble/index.d.ts +0 -11
  64. package/chat-bubble/index.js +0 -41
  65. package/chat-bubble/types.d.ts +0 -20
  66. package/chat-bubble/types.js +0 -1
  67. package/chat-bubble/utils.d.ts +0 -3
  68. package/chat-bubble/utils.js +0 -2
  69. package/checkbox/index.d.ts +0 -11
  70. package/checkbox/index.js +0 -126
  71. package/checkbox/types.d.ts +0 -49
  72. package/checkbox/types.js +0 -1
  73. package/chip/index.d.ts +0 -13
  74. package/chip/index.js +0 -144
  75. package/chip/types.d.ts +0 -37
  76. package/chip/types.js +0 -1
  77. package/chip/utils.d.ts +0 -2
  78. package/chip/utils.js +0 -6
  79. package/code-tag/index.d.ts +0 -11
  80. package/code-tag/index.js +0 -31
  81. package/code-tag/types.d.ts +0 -11
  82. package/code-tag/types.js +0 -1
  83. package/color-menu/index.d.ts +0 -11
  84. package/color-menu/index.js +0 -308
  85. package/color-menu/types.d.ts +0 -32
  86. package/color-menu/types.js +0 -1
  87. package/color-menu/utils.d.ts +0 -1
  88. package/color-menu/utils.js +0 -11
  89. package/color-menu-option/index.d.ts +0 -13
  90. package/color-menu-option/index.js +0 -48
  91. package/color-menu-option/types.d.ts +0 -11
  92. package/color-menu-option/types.js +0 -1
  93. package/color-menu-option/utils.d.ts +0 -1
  94. package/color-menu-option/utils.js +0 -11
  95. package/color-swatch/index.d.ts +0 -12
  96. package/color-swatch/index.js +0 -54
  97. package/color-swatch/types.d.ts +0 -11
  98. package/color-swatch/types.js +0 -1
  99. package/color-swatch/utils.d.ts +0 -2
  100. package/color-swatch/utils.js +0 -6
  101. package/date-picker/index.d.ts +0 -14
  102. package/date-picker/index.js +0 -381
  103. package/date-picker/types.d.ts +0 -70
  104. package/date-picker/types.js +0 -1
  105. package/date-picker/utils.d.ts +0 -28
  106. package/date-picker/utils.js +0 -142
  107. package/dialog/index.d.ts +0 -15
  108. package/dialog/index.js +0 -144
  109. package/dialog/types.d.ts +0 -28
  110. package/dialog/types.js +0 -1
  111. package/dialog/utils.d.ts +0 -2
  112. package/dialog/utils.js +0 -18
  113. package/emoji/index.d.ts +0 -11
  114. package/emoji/index.js +0 -46
  115. package/emoji/types.d.ts +0 -11
  116. package/emoji/types.js +0 -1
  117. package/emoji/utils.d.ts +0 -3
  118. package/emoji/utils.js +0 -47
  119. package/emoji-picker/index.d.ts +0 -22
  120. package/emoji-picker/index.js +0 -308
  121. package/emoji-picker/types.d.ts +0 -26
  122. package/emoji-picker/types.js +0 -1
  123. package/field/index.d.ts +0 -11
  124. package/field/index.js +0 -120
  125. package/field/types.d.ts +0 -35
  126. package/field/types.js +0 -1
  127. package/file-drop/index.d.ts +0 -13
  128. package/file-drop/index.js +0 -205
  129. package/file-drop/types.d.ts +0 -50
  130. package/file-drop/types.js +0 -1
  131. package/file-drop/utils.d.ts +0 -2
  132. package/file-drop/utils.js +0 -31
  133. package/file-picker/index.d.ts +0 -11
  134. package/file-picker/index.js +0 -103
  135. package/file-picker/types.d.ts +0 -32
  136. package/file-picker/types.js +0 -1
  137. package/file-picker/utils.d.ts +0 -1
  138. package/file-picker/utils.js +0 -8
  139. package/file-status/index.d.ts +0 -14
  140. package/file-status/index.js +0 -61
  141. package/file-status/types.d.ts +0 -18
  142. package/file-status/types.js +0 -1
  143. package/file-status/utils.d.ts +0 -2
  144. package/file-status/utils.js +0 -1
  145. package/flag/index.d.ts +0 -11
  146. package/flag/index.js +0 -46
  147. package/flag/types.d.ts +0 -11
  148. package/flag/types.js +0 -1
  149. package/flag/utils.d.ts +0 -1
  150. package/flag/utils.js +0 -17
  151. package/grid/index.d.ts +0 -11
  152. package/grid/index.js +0 -11
  153. package/grid/types.d.ts +0 -3
  154. package/grid/types.js +0 -1
  155. package/grid-item/index.d.ts +0 -11
  156. package/grid-item/index.js +0 -35
  157. package/grid-item/types.d.ts +0 -17
  158. package/grid-item/types.js +0 -1
  159. package/help-tooltip/index.d.ts +0 -13
  160. package/help-tooltip/index.js +0 -74
  161. package/help-tooltip/types.d.ts +0 -3
  162. package/help-tooltip/types.js +0 -1
  163. package/horizontal-stepper/index.d.ts +0 -11
  164. package/horizontal-stepper/index.js +0 -61
  165. package/horizontal-stepper/types.d.ts +0 -13
  166. package/horizontal-stepper/types.js +0 -1
  167. package/horizontal-stepper-item/index.d.ts +0 -14
  168. package/horizontal-stepper-item/index.js +0 -61
  169. package/horizontal-stepper-item/types.d.ts +0 -24
  170. package/horizontal-stepper-item/types.js +0 -1
  171. package/horizontal-stepper-item/utils.d.ts +0 -2
  172. package/horizontal-stepper-item/utils.js +0 -1
  173. package/icon/index.d.ts +0 -11
  174. package/icon/index.js +0 -32
  175. package/icon/types.d.ts +0 -11
  176. package/icon/types.js +0 -1
  177. package/icon-button/index.d.ts +0 -12
  178. package/icon-button/index.js +0 -175
  179. package/icon-button/types.d.ts +0 -44
  180. package/icon-button/types.js +0 -1
  181. package/icon-button/utils.d.ts +0 -2
  182. package/icon-button/utils.js +0 -1
  183. package/inline-alert/index.d.ts +0 -15
  184. package/inline-alert/index.js +0 -83
  185. package/inline-alert/types.d.ts +0 -15
  186. package/inline-alert/types.js +0 -1
  187. package/inline-alert/utils.d.ts +0 -2
  188. package/inline-alert/utils.js +0 -1
  189. package/input/index.d.ts +0 -11
  190. package/input/index.js +0 -637
  191. package/input/types.d.ts +0 -86
  192. package/input/types.js +0 -1
  193. package/input/utils.d.ts +0 -26
  194. package/input/utils.js +0 -302
  195. package/link/index.d.ts +0 -12
  196. package/link/index.js +0 -150
  197. package/link/types.d.ts +0 -59
  198. package/link/types.js +0 -1
  199. package/list/index.d.ts +0 -11
  200. package/list/index.js +0 -14
  201. package/list/types.d.ts +0 -3
  202. package/list/types.js +0 -1
  203. package/list-item/index.d.ts +0 -11
  204. package/list-item/index.js +0 -14
  205. package/list-item/types.d.ts +0 -3
  206. package/list-item/types.js +0 -1
  207. package/pagination/index.d.ts +0 -12
  208. package/pagination/index.js +0 -147
  209. package/pagination/types.d.ts +0 -16
  210. package/pagination/types.js +0 -1
  211. package/pop/index.d.ts +0 -11
  212. package/pop/index.js +0 -425
  213. package/pop/types.d.ts +0 -35
  214. package/pop/types.js +0 -1
  215. package/pop/utils.d.ts +0 -4
  216. package/pop/utils.js +0 -16
  217. package/popover/index.d.ts +0 -12
  218. package/popover/index.js +0 -146
  219. package/popover/types.d.ts +0 -40
  220. package/popover/types.js +0 -1
  221. package/popover/utils.d.ts +0 -4
  222. package/popover/utils.js +0 -10
  223. package/progress/index.d.ts +0 -12
  224. package/progress/index.js +0 -58
  225. package/progress/types.d.ts +0 -12
  226. package/progress/types.js +0 -1
  227. package/progress-stepper/index.d.ts +0 -11
  228. package/progress-stepper/index.js +0 -206
  229. package/progress-stepper/types.d.ts +0 -22
  230. package/progress-stepper/types.js +0 -1
  231. package/progress-stepper-item/index.d.ts +0 -12
  232. package/progress-stepper-item/index.js +0 -82
  233. package/progress-stepper-item/types.d.ts +0 -23
  234. package/progress-stepper-item/types.js +0 -1
  235. package/progress-stepper-item/utils.d.ts +0 -11
  236. package/progress-stepper-item/utils.js +0 -13
  237. package/radio/index.d.ts +0 -11
  238. package/radio/index.js +0 -154
  239. package/radio/types.d.ts +0 -14
  240. package/radio/types.js +0 -1
  241. package/radio-option/index.d.ts +0 -11
  242. package/radio-option/index.js +0 -79
  243. package/radio-option/types.d.ts +0 -18
  244. package/radio-option/types.js +0 -1
  245. package/rich-text/index.d.ts +0 -14
  246. package/rich-text/index.js +0 -75
  247. package/rich-text/types.d.ts +0 -12
  248. package/rich-text/types.js +0 -1
  249. package/rich-text/utils.d.ts +0 -7
  250. package/rich-text/utils.js +0 -107
  251. package/rich-textarea/index.d.ts +0 -11
  252. package/rich-textarea/index.js +0 -464
  253. package/rich-textarea/types.d.ts +0 -48
  254. package/rich-textarea/types.js +0 -1
  255. package/rich-textarea/utils.d.ts +0 -39
  256. package/rich-textarea/utils.js +0 -1730
  257. package/segment/index.d.ts +0 -12
  258. package/segment/index.js +0 -109
  259. package/segment/types.d.ts +0 -16
  260. package/segment/types.js +0 -1
  261. package/segment/utils.d.ts +0 -3
  262. package/segment/utils.js +0 -16
  263. package/segment-collapse/index.d.ts +0 -13
  264. package/segment-collapse/index.js +0 -60
  265. package/segment-collapse/types.d.ts +0 -11
  266. package/segment-collapse/types.js +0 -1
  267. package/segmented-control/index.d.ts +0 -11
  268. package/segmented-control/index.js +0 -85
  269. package/segmented-control/types.d.ts +0 -11
  270. package/segmented-control/types.js +0 -1
  271. package/segmented-control-option/index.d.ts +0 -11
  272. package/segmented-control-option/index.js +0 -95
  273. package/segmented-control-option/types.d.ts +0 -19
  274. package/segmented-control-option/types.js +0 -1
  275. package/segmented-icon-control/index.d.ts +0 -11
  276. package/segmented-icon-control/index.js +0 -101
  277. package/segmented-icon-control/types.d.ts +0 -14
  278. package/segmented-icon-control/types.js +0 -1
  279. package/segmented-icon-control-option/index.d.ts +0 -11
  280. package/segmented-icon-control-option/index.js +0 -82
  281. package/segmented-icon-control-option/types.d.ts +0 -16
  282. package/segmented-icon-control-option/types.js +0 -1
  283. package/select-button/index.d.ts +0 -13
  284. package/select-button/index.js +0 -202
  285. package/select-button/types.d.ts +0 -50
  286. package/select-button/types.js +0 -1
  287. package/select-menu/index.d.ts +0 -15
  288. package/select-menu/index.js +0 -332
  289. package/select-menu/types.d.ts +0 -41
  290. package/select-menu/types.js +0 -1
  291. package/select-menu-option/index.d.ts +0 -28
  292. package/select-menu-option/index.js +0 -65
  293. package/select-menu-option/types.d.ts +0 -26
  294. package/select-menu-option/types.js +0 -1
  295. package/skeleton/index.d.ts +0 -11
  296. package/skeleton/index.js +0 -108
  297. package/skeleton/types.d.ts +0 -9
  298. package/skeleton/types.js +0 -1
  299. package/skeleton-item/index.d.ts +0 -11
  300. package/skeleton-item/index.js +0 -11
  301. package/skeleton-item/types.d.ts +0 -13
  302. package/skeleton-item/types.js +0 -1
  303. package/spinner/index.d.ts +0 -11
  304. package/spinner/index.js +0 -58
  305. package/spinner/types.d.ts +0 -12
  306. package/spinner/types.js +0 -1
  307. package/standalone.d.ts +0 -85
  308. package/standalone.js +0 -87
  309. package/stop-events/index.d.ts +0 -1
  310. package/stop-events/index.js +0 -27
  311. package/table/index.d.ts +0 -11
  312. package/table/index.js +0 -14
  313. package/table/types.d.ts +0 -3
  314. package/table/types.js +0 -1
  315. package/table-body/index.d.ts +0 -11
  316. package/table-body/index.js +0 -14
  317. package/table-body/types.d.ts +0 -3
  318. package/table-body/types.js +0 -1
  319. package/table-cell/index.d.ts +0 -11
  320. package/table-cell/index.js +0 -21
  321. package/table-cell/types.d.ts +0 -9
  322. package/table-cell/types.js +0 -1
  323. package/table-cell/utils.d.ts +0 -2
  324. package/table-cell/utils.js +0 -1
  325. package/table-head/index.d.ts +0 -11
  326. package/table-head/index.js +0 -14
  327. package/table-head/types.d.ts +0 -3
  328. package/table-head/types.js +0 -1
  329. package/table-head-cell/index.d.ts +0 -12
  330. package/table-head-cell/index.js +0 -57
  331. package/table-head-cell/types.d.ts +0 -15
  332. package/table-head-cell/types.js +0 -1
  333. package/table-row/index.d.ts +0 -11
  334. package/table-row/index.js +0 -42
  335. package/table-row/types.d.ts +0 -11
  336. package/table-row/types.js +0 -1
  337. package/tabs/index.d.ts +0 -11
  338. package/tabs/index.js +0 -80
  339. package/tabs/types.d.ts +0 -18
  340. package/tabs/types.js +0 -1
  341. package/tabs-icon-option/index.d.ts +0 -11
  342. package/tabs-icon-option/index.js +0 -79
  343. package/tabs-icon-option/types.d.ts +0 -19
  344. package/tabs-icon-option/types.js +0 -1
  345. package/tabs-option/index.d.ts +0 -12
  346. package/tabs-option/index.js +0 -86
  347. package/tabs-option/types.d.ts +0 -25
  348. package/tabs-option/types.js +0 -1
  349. package/tag/index.d.ts +0 -12
  350. package/tag/index.js +0 -84
  351. package/tag/types.d.ts +0 -23
  352. package/tag/types.js +0 -1
  353. package/tag/utils.d.ts +0 -2
  354. package/tag/utils.js +0 -6
  355. package/text/index.d.ts +0 -11
  356. package/text/index.js +0 -64
  357. package/text/types.d.ts +0 -30
  358. package/text/types.js +0 -1
  359. package/text/utils.d.ts +0 -2
  360. package/text/utils.js +0 -1
  361. package/textarea/index.d.ts +0 -11
  362. package/textarea/index.js +0 -322
  363. package/textarea/types.d.ts +0 -60
  364. package/textarea/types.js +0 -1
  365. package/tile-control/index.d.ts +0 -11
  366. package/tile-control/index.js +0 -110
  367. package/tile-control/types.d.ts +0 -37
  368. package/tile-control/types.js +0 -1
  369. package/tile-control-option/index.d.ts +0 -11
  370. package/tile-control-option/index.js +0 -98
  371. package/tile-control-option/types.d.ts +0 -37
  372. package/tile-control-option/types.js +0 -1
  373. package/time-picker/index.d.ts +0 -15
  374. package/time-picker/index.js +0 -337
  375. package/time-picker/types.d.ts +0 -34
  376. package/time-picker/types.js +0 -1
  377. package/time-picker/utils.d.ts +0 -11
  378. package/time-picker/utils.js +0 -75
  379. package/title/index.d.ts +0 -11
  380. package/title/index.js +0 -60
  381. package/title/types.d.ts +0 -31
  382. package/title/types.js +0 -1
  383. package/title/utils.d.ts +0 -3
  384. package/title/utils.js +0 -17
  385. package/toast/index.d.ts +0 -13
  386. package/toast/index.js +0 -86
  387. package/toast/types.d.ts +0 -28
  388. package/toast/types.js +0 -1
  389. package/toast/utils.d.ts +0 -2
  390. package/toast/utils.js +0 -1
  391. package/toast-manager/index.d.ts +0 -13
  392. package/toast-manager/index.js +0 -170
  393. package/toast-manager/types.d.ts +0 -13
  394. package/toast-manager/types.js +0 -1
  395. package/toast-manager/utils.d.ts +0 -2
  396. package/toast-manager/utils.js +0 -1
  397. package/toggle/index.d.ts +0 -11
  398. package/toggle/index.js +0 -141
  399. package/toggle/types.d.ts +0 -23
  400. package/toggle/types.js +0 -1
  401. package/tooltip/index.d.ts +0 -13
  402. package/tooltip/index.js +0 -264
  403. package/tooltip/tooltip-state.d.ts +0 -19
  404. package/tooltip/tooltip-state.js +0 -126
  405. package/tooltip/types.d.ts +0 -35
  406. package/tooltip/types.js +0 -1
  407. package/tooltip/utils.d.ts +0 -5
  408. package/tooltip/utils.js +0 -17
  409. package/utils/context.d.ts +0 -20
  410. package/utils/context.js +0 -84
  411. package/utils/countries.d.ts +0 -6
  412. package/utils/countries.js +0 -2
  413. package/utils/csv.d.ts +0 -5
  414. package/utils/csv.js +0 -22
  415. package/utils/debounce.d.ts +0 -8
  416. package/utils/debounce.js +0 -22
  417. package/utils/dom.d.ts +0 -34
  418. package/utils/dom.js +0 -154
  419. package/utils/element.d.ts +0 -16
  420. package/utils/element.js +0 -48
  421. package/utils/event-target.d.ts +0 -4
  422. package/utils/event-target.js +0 -26
  423. package/utils/get-react-event-handler.d.ts +0 -1
  424. package/utils/get-react-event-handler.js +0 -8
  425. package/utils/index.d.ts +0 -12
  426. package/utils/index.js +0 -12
  427. package/utils/markdown.d.ts +0 -19
  428. package/utils/markdown.js +0 -143
  429. package/utils/rect.d.ts +0 -4
  430. package/utils/rect.js +0 -28
  431. package/utils/size.d.ts +0 -5
  432. package/utils/size.js +0 -3
  433. package/utils/slot.d.ts +0 -4
  434. package/utils/slot.js +0 -38
  435. package/utils/throttle.d.ts +0 -4
  436. package/utils/throttle.js +0 -20
  437. package/utils/uid.d.ts +0 -1
  438. package/utils/uid.js +0 -13
  439. package/vertical-stepper/index.d.ts +0 -11
  440. package/vertical-stepper/index.js +0 -57
  441. package/vertical-stepper/types.d.ts +0 -13
  442. package/vertical-stepper/types.js +0 -1
  443. package/vertical-stepper-item/index.d.ts +0 -14
  444. package/vertical-stepper-item/index.js +0 -61
  445. package/vertical-stepper-item/types.d.ts +0 -24
  446. package/vertical-stepper-item/types.js +0 -1
  447. package/vertical-stepper-item/utils.d.ts +0 -2
  448. 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
- }