@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,11 +0,0 @@
1
- import type { TSinchListItemElement, TSinchListItemReact } from './types';
2
- declare global {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- 'sinch-list-item': TSinchListItemReact;
6
- }
7
- }
8
- interface HTMLElementTagNameMap {
9
- 'sinch-list-item': TSinchListItemElement;
10
- }
11
- }
@@ -1,14 +0,0 @@
1
- import { defineCustomElement, NectaryElement } from '../utils';
2
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:100%;height:100%;box-sizing:border-box;overflow:hidden;padding:8px 0;background-color:var(--sinch-comp-list-color-default-background-initial);border-bottom:1px solid var(--sinch-comp-list-color-default-border-initial)}:host(:last-child)>#wrapper{border-bottom:none}:host(:hover)>#wrapper{background-color:var(--sinch-comp-list-color-default-background-hover)}</style><div id="wrapper"><slot name="content"></slot></div>';
3
- const template = document.createElement('template');
4
- template.innerHTML = templateHTML;
5
- defineCustomElement('sinch-list-item', class extends NectaryElement {
6
- constructor() {
7
- super();
8
- const shadowRoot = this.attachShadow();
9
- shadowRoot.appendChild(template.content.cloneNode(true));
10
- }
11
- connectedCallback() {
12
- this.setAttribute('role', 'listitem');
13
- }
14
- });
@@ -1,3 +0,0 @@
1
- import type { TSinchElementReact } from '../types';
2
- export type TSinchListItemElement = HTMLElement;
3
- export type TSinchListItemReact = TSinchElementReact<TSinchListItemElement>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- import '../icon';
2
- import type { TSinchPaginationElement, TSinchPaginationReact } from './types';
3
- declare global {
4
- namespace JSX {
5
- interface IntrinsicElements {
6
- 'sinch-pagination': TSinchPaginationReact;
7
- }
8
- }
9
- interface HTMLElementTagNameMap {
10
- 'sinch-pagination': TSinchPaginationElement;
11
- }
12
- }
@@ -1,147 +0,0 @@
1
- import '../icon';
2
- import { defineCustomElement, updateAttribute, getIntegerAttribute, setClass, NectaryElement, getRect, getReactEventHandler, isTargetEqual, getTargetIndexInParent } from '../utils';
3
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;justify-content:center;gap:8px;width:100%;height:var(--sinch-local-size);--sinch-local-size:24px}button{all:initial;position:relative;display:flex;justify-content:center;align-items:center;min-width:var(--sinch-local-size);height:var(--sinch-local-size);cursor:pointer;border-radius:var(--sinch-comp-pagination-shape-radius);user-select:none;--sinch-global-color-icon:var(--sinch-comp-pagination-color-default-icon-default)}button:focus-visible::before{content:"";position:absolute;inset:-3px;border:2px solid var(--sinch-comp-pagination-color-default-outline-focus);border-radius:calc(var(--sinch-comp-pagination-shape-radius) + 3px);pointer-events:none}button:disabled{--sinch-global-color-icon:var(--sinch-comp-pagination-color-disabled-icon-initial);cursor:initial}button:enabled:hover{background-color:var(--sinch-comp-pagination-color-default-background-hover)}button>*{display:block;overflow:hidden;pointer-events:none}.page{font:var(--sinch-comp-pagination-font-default-page-number);color:var(--sinch-comp-pagination-color-default-text-initial);background-color:var(--sinch-comp-pagination-color-default-background-initial);padding:0 4px;box-sizing:border-box}.page.dots>span{display:none}.page.dots::after{content:"..."}.page.active{font:var(--sinch-comp-pagination-font-checked-page-number);background-color:var(--sinch-comp-pagination-color-checked-background-initial);pointer-events:none;cursor:initial}.page.active:hover{background-color:var(--sinch-comp-pagination-color-checked-background-hover)}.page.hidden{display:none}#left,#right{--sinch-icon-size:24px}</style><div id="wrapper"><button id="left"><sinch-icon id="icon-left" name="keyboard_arrow_left"></sinch-icon></button><button class="page"><span>1</span></button><button class="page active"><span>2</span></button><button class="page"><span>3</span></button><button class="page"><span>4</span></button><button class="page"><span>5</span></button><button class="page dots"><span>6</span></button><button class="page"><span>20</span></button><button id="right"><sinch-icon id="icon-right" name="keyboard_arrow_right"></sinch-icon></button></div>';
4
- const NUM_BUTTONS = 7;
5
- const MIDDLE_BTN_INDEX = Math.floor(NUM_BUTTONS / 2);
6
- const FIRST_BTN_INDEX = 0;
7
- const LAST_BTN_INDEX = NUM_BUTTONS - 1;
8
- const DOTS_LEFT_INDEX = 1;
9
- const DOTS_RIGHT_INDEX = LAST_BTN_INDEX - 1;
10
- const template = document.createElement('template');
11
- template.innerHTML = templateHTML;
12
- defineCustomElement('sinch-pagination', class extends NectaryElement {
13
- #$left;
14
- #$right;
15
- #$buttons;
16
- #$wrapper;
17
- constructor() {
18
- super();
19
- const shadowRoot = this.attachShadow();
20
- shadowRoot.appendChild(template.content.cloneNode(true));
21
- this.#$left = shadowRoot.querySelector('#left');
22
- this.#$right = shadowRoot.querySelector('#right');
23
- this.#$buttons = shadowRoot.querySelectorAll('.page');
24
- this.#$wrapper = shadowRoot.querySelector('#wrapper');
25
- }
26
- connectedCallback() {
27
- this.#onValueChange();
28
- this.#$wrapper.addEventListener('click', this.#onButtonClick);
29
- this.addEventListener('-change', this.#onChangeReactHandler);
30
- }
31
- disconnectedCallback() {
32
- this.#$wrapper.removeEventListener('click', this.#onButtonClick);
33
- this.removeEventListener('-change', this.#onChangeReactHandler);
34
- }
35
- static get observedAttributes() {
36
- return ['max', 'value'];
37
- }
38
- attributeChangedCallback(name) {
39
- switch (name) {
40
- case 'value':
41
- case 'max':
42
- {
43
- this.#onValueChange();
44
- break;
45
- }
46
- }
47
- }
48
- set value(val) {
49
- updateAttribute(this, 'value', val);
50
- }
51
- get value() {
52
- return getIntegerAttribute(this, 'value', 0);
53
- }
54
- set max(val) {
55
- updateAttribute(this, 'max', val);
56
- }
57
- get max() {
58
- return getIntegerAttribute(this, 'value', 0);
59
- }
60
- #onValueChange() {
61
- const value = getIntegerAttribute(this, 'value', 0) - 1;
62
- const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
63
- const valueOffset = Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS));
64
- for (let i = 0; i < this.#$buttons.length; i++) {
65
- const $b = this.#$buttons[i];
66
- if (value < 3) {
67
- setClass($b, 'active', value === i);
68
- } else if (value >= max - MIDDLE_BTN_INDEX) {
69
- setClass($b, 'active', i + valueOffset === value);
70
- } else {
71
- setClass($b, 'active', i === MIDDLE_BTN_INDEX);
72
- }
73
- if (max > NUM_BUTTONS) {
74
- setClass($b, 'dots', i === DOTS_LEFT_INDEX && value > MIDDLE_BTN_INDEX || i === DOTS_RIGHT_INDEX && value <= max - DOTS_RIGHT_INDEX);
75
- }
76
- setClass($b, 'hidden', i >= max);
77
- const btnText = $b.firstElementChild;
78
- if (btnText != null) {
79
- btnText.textContent = i === FIRST_BTN_INDEX ? '1' : i === LAST_BTN_INDEX ? String(max) : String(i + 1 + valueOffset);
80
- }
81
- }
82
- const isValueBad = value < 0 || value >= max;
83
- this.#$left.disabled = isValueBad || value === 0;
84
- this.#$right.disabled = isValueBad || value === max - 1;
85
- }
86
- #onButtonClick = e => {
87
- e.stopPropagation();
88
- const value = Math.max(getIntegerAttribute(this, 'value', 0) - 1);
89
- const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
90
- if (isTargetEqual(e, this.#$left)) {
91
- return this.#dispatchChangeEvent(Math.max(value - 1, 0));
92
- }
93
- if (isTargetEqual(e, this.#$right)) {
94
- return this.#dispatchChangeEvent(Math.min(value + 1, max));
95
- }
96
- const btnIndex = getTargetIndexInParent(e, this.#$wrapper) - 1;
97
- if (btnIndex >= FIRST_BTN_INDEX && btnIndex <= LAST_BTN_INDEX) {
98
- if (btnIndex === FIRST_BTN_INDEX) {
99
- return this.#dispatchChangeEvent(0);
100
- }
101
- if (btnIndex === LAST_BTN_INDEX) {
102
- return this.#dispatchChangeEvent(max);
103
- }
104
- if (btnIndex === DOTS_LEFT_INDEX && max > NUM_BUTTONS && value > MIDDLE_BTN_INDEX) {
105
- return this.#dispatchChangeEvent(Math.floor(value / 2));
106
- }
107
- if (btnIndex === DOTS_RIGHT_INDEX && max > NUM_BUTTONS && value <= max - DOTS_RIGHT_INDEX) {
108
- return this.#dispatchChangeEvent(Math.floor((max - value) / 2 + value));
109
- }
110
- return this.#dispatchChangeEvent(btnIndex + Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS)));
111
- }
112
- };
113
- #clamp(value) {
114
- const max = getIntegerAttribute(this, 'max', 0);
115
- return Math.max(0, Math.min(max - 1, value)) + 1;
116
- }
117
- #dispatchChangeEvent(value) {
118
- const detail = this.#clamp(value);
119
- this.dispatchEvent(new CustomEvent('-change', {
120
- detail
121
- }));
122
- }
123
- #onChangeReactHandler = e => {
124
- getReactEventHandler(this, 'on-change')?.(e);
125
- };
126
- get focusable() {
127
- return true;
128
- }
129
- focus() {
130
- this.#$left.focus();
131
- }
132
- blur() {
133
- this.#$left.blur();
134
- this.#$right.blur();
135
- this.#$buttons.forEach($b => $b.blur());
136
- }
137
- get prevButtonRect() {
138
- return getRect(this.#$left);
139
- }
140
- get nextButtonRect() {
141
- return getRect(this.#$right);
142
- }
143
- nthButtonRect(index) {
144
- const btn = this.#$buttons[index];
145
- return btn == null ? null : getRect(btn);
146
- }
147
- });
@@ -1,16 +0,0 @@
1
- import type { TRect, TSinchElementReact } from '../types';
2
- export type TSinchPaginationElement = HTMLElement & {
3
- value: number;
4
- max: number;
5
- readonly prevButtonRect: TRect;
6
- readonly nextButtonRect: TRect;
7
- nthButtonRect(index: number): TRect | null;
8
- addEventListener(type: '-change', listener: (e: CustomEvent<number>) => void): void;
9
- setAttribute(name: 'value', value: string): void;
10
- setAttribute(name: 'max', value: string): void;
11
- };
12
- export type TSinchPaginationReact = TSinchElementReact<TSinchPaginationElement> & {
13
- value: number;
14
- max: number;
15
- 'on-change': (e: CustomEvent<number>) => void;
16
- };
@@ -1 +0,0 @@
1
- export {};
package/pop/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { TSinchPopElement, TSinchPopReact } from './types';
2
- declare global {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- 'sinch-pop': TSinchPopReact;
6
- }
7
- }
8
- interface HTMLElementTagNameMap {
9
- 'sinch-pop': TSinchPopElement;
10
- }
11
- }
package/pop/index.js DELETED
@@ -1,425 +0,0 @@
1
- import { defineCustomElement, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, updateLiteralAttribute, getReactEventHandler, updateBooleanAttribute, NectaryElement, throttleAnimationFrame, isElementFocused, updateIntegerAttribute, getIntegerAttribute, getFirstFocusableElement, getFirstSlotElement, Context, subscribeContext, isTargetEqual, isAttrEqual } from '../utils';
2
- const templateHTML = '<style>:host{display:contents;position:relative}dialog{position:fixed;left:0;top:0;margin:0;outline:0;padding:0;border:none;box-sizing:border-box;max-width:unset;max-height:unset;z-index:1;background:0 0;overflow:visible}dialog:not([open]){display:none}dialog::backdrop{background-color:transparent}#content{position:relative;z-index:1}#target-open{display:flex;flex-direction:column;position:absolute;left:0;top:0}#focus{display:none;position:absolute;width:0;height:0}</style><slot id="target" name="target" aria-haspopup="dialog" aria-expanded="false"></slot><div id="focus"></div><dialog id="dialog"><div id="target-open"><slot name="target-open"></slot></div><div id="content"><slot name="content"></slot></div></dialog>';
3
- import { disableOverscroll, enableOverscroll, orientationValues } from './utils';
4
- const template = document.createElement('template');
5
- template.innerHTML = templateHTML;
6
- defineCustomElement('sinch-pop', class extends NectaryElement {
7
- #$targetWrapper;
8
- #$focus;
9
- #$dialog;
10
- #resizeThrottle;
11
- #$targetSlot;
12
- #$targetOpenSlot;
13
- #$contentSlot;
14
- #$targetOpenWrapper;
15
- #targetActiveElement = null;
16
- #controller;
17
- #keydownContext;
18
- #visibilityContext;
19
- #targetStyleValue = null;
20
- #modalWidth = 0;
21
- #modalHeight = 0;
22
- constructor() {
23
- super();
24
- const shadowRoot = this.attachShadow();
25
- shadowRoot.appendChild(template.content.cloneNode(true));
26
- this.#$targetWrapper = shadowRoot.querySelector('#target');
27
- this.#$focus = shadowRoot.querySelector('#focus');
28
- this.#$dialog = shadowRoot.querySelector('#dialog');
29
- this.#$targetSlot = shadowRoot.querySelector('slot[name="target"]');
30
- this.#$targetOpenSlot = shadowRoot.querySelector('slot[name="target-open"]');
31
- this.#$contentSlot = shadowRoot.querySelector('slot[name="content"]');
32
- this.#$targetOpenWrapper = shadowRoot.querySelector('#target-open');
33
- this.#resizeThrottle = throttleAnimationFrame(this.#updateOrientation);
34
- this.#keydownContext = new Context(this.#$contentSlot, 'keydown');
35
- this.#visibilityContext = new Context(this.#$contentSlot, 'visibility');
36
- this.#controller = new AbortController();
37
- }
38
- connectedCallback() {
39
- super.connectedCallback();
40
- if (this.#controller === null) {
41
- this.#controller = new AbortController();
42
- }
43
- const {
44
- signal
45
- } = this.#controller;
46
- this.#keydownContext.listen(signal);
47
- this.#visibilityContext.listen(signal);
48
- this.role = 'dialog';
49
- this.#$dialog.addEventListener('cancel', this.#onCancel, {
50
- signal
51
- });
52
- this.#$dialog.addEventListener('mousedown', this.#onBackdropMouseDown, {
53
- signal
54
- });
55
- this.addEventListener('-close', this.#onCloseReactHandler, {
56
- signal
57
- });
58
- subscribeContext(this, 'visibility', this.#onContextVisibility, signal);
59
- if (getBooleanAttribute(this, 'open')) {
60
- this.#onExpand();
61
- }
62
- }
63
- disconnectedCallback() {
64
- super.disconnectedCallback();
65
- this.#controller.abort();
66
- this.#controller = null;
67
- this.#resizeThrottle.cancel();
68
- this.#onCollapse();
69
- }
70
- static get observedAttributes() {
71
- return ['orientation', 'open'];
72
- }
73
- set modal(isModal) {
74
- updateBooleanAttribute(this, 'modal', isModal);
75
- }
76
- get modal() {
77
- return getBooleanAttribute(this, 'modal');
78
- }
79
- set open(isOpen) {
80
- updateBooleanAttribute(this, 'open', isOpen);
81
- }
82
- get open() {
83
- return getBooleanAttribute(this, 'open');
84
- }
85
- get orientation() {
86
- return getLiteralAttribute(this, orientationValues, 'orientation');
87
- }
88
- set orientation(value) {
89
- updateLiteralAttribute(this, orientationValues, 'orientation', value);
90
- }
91
- set inset(inset) {
92
- updateIntegerAttribute(this, 'inset', inset);
93
- }
94
- get inset() {
95
- return getIntegerAttribute(this, 'inset', 0);
96
- }
97
- get footprintRect() {
98
- return this.#getTargetRect();
99
- }
100
- get popoverRect() {
101
- return getRect(this.#$dialog);
102
- }
103
- attributeChangedCallback(name, oldVal, newVal) {
104
- if (isAttrEqual(oldVal, newVal)) {
105
- return;
106
- }
107
- switch (name) {
108
- case 'open':
109
- {
110
- const shouldOpen = isAttrTrue(newVal);
111
- if (shouldOpen) {
112
- requestAnimationFrame(() => {
113
- if (this.isDomConnected && getBooleanAttribute(this, 'open')) {
114
- this.#onExpand();
115
- }
116
- });
117
- } else {
118
- this.#onCollapse();
119
- }
120
- updateBooleanAttribute(this, 'open', shouldOpen);
121
- break;
122
- }
123
- case 'orientation':
124
- {
125
- if (this.#$dialog.open) {
126
- this.#updateOrientation();
127
- }
128
- break;
129
- }
130
- }
131
- }
132
- #getTargetRect() {
133
- let item = getFirstSlotElement(this.#$targetSlot, true);
134
- if (item === null && this.#$dialog.open) {
135
- item = getFirstSlotElement(this.#$targetOpenSlot, true);
136
- }
137
- if (item === null) {
138
- return getRect(this.#$targetWrapper);
139
- }
140
- if (Reflect.has(item, 'footprintRect')) {
141
- return item.footprintRect;
142
- }
143
- return getRect(item);
144
- }
145
- #getFirstTargetElement(slot) {
146
- const item = getFirstSlotElement(slot, true);
147
- if (item === null) {
148
- return this.#$targetWrapper;
149
- }
150
- return item;
151
- }
152
- #onExpand() {
153
- if (!this.isDomConnected || this.#$dialog.open) {
154
- return;
155
- }
156
- this.#$targetSlot.addEventListener('blur', this.#stopEventPropagation, true);
157
- this.#$focus.setAttribute('tabindex', '-1');
158
- this.#$focus.style.display = 'block';
159
- this.#$focus.addEventListener('focus', this.#captureRelatedActiveElement);
160
- this.#$focus.focus();
161
- this.#$focus.removeEventListener('focus', this.#captureRelatedActiveElement);
162
- this.#$targetSlot.removeEventListener('blur', this.#stopEventPropagation, true);
163
- this.#$focus.removeAttribute('tabindex');
164
- this.#$focus.removeAttribute('style');
165
- this.#$dialog.showModal();
166
- this.#$targetWrapper.setAttribute('aria-expanded', 'true');
167
- this.#updateOrientation();
168
- if (this.modal) {
169
- getFirstFocusableElement(this.#$contentSlot)?.focus();
170
- } else {
171
- const $targetEl = this.#getFirstTargetElement(this.#$targetSlot);
172
- const targetElComputedStyle = getComputedStyle($targetEl);
173
- const marginLeft = parseInt(targetElComputedStyle.marginLeft);
174
- const marginRight = parseInt(targetElComputedStyle.marginRight);
175
- const marginTop = parseInt(targetElComputedStyle.marginTop);
176
- const marginBottom = parseInt(targetElComputedStyle.marginBottom);
177
- const targetRect = this.#getTargetRect();
178
- this.#$targetWrapper.style.setProperty('display', 'block');
179
- this.#$targetWrapper.style.setProperty('width', `${targetRect.width + marginLeft + marginRight}px`);
180
- this.#$targetWrapper.style.setProperty('height', `${targetRect.height + marginTop + marginBottom}px`);
181
- this.#$targetOpenWrapper.style.setProperty('width', `${targetRect.width}px`);
182
- this.#$targetOpenWrapper.style.setProperty('height', `${targetRect.height}px`);
183
- this.#targetStyleValue = $targetEl.getAttribute('style');
184
- $targetEl.style.setProperty('margin', '0');
185
- $targetEl.style.setProperty('position', 'static');
186
- if (targetElComputedStyle.transform !== 'none') {
187
- const matrix = new DOMMatrixReadOnly(targetElComputedStyle.transform);
188
- $targetEl.style.setProperty('transform', matrix.translate(-matrix.e, -matrix.f).toString());
189
- }
190
- getFirstSlotElement(this.#$targetSlot)?.setAttribute('slot', 'target-open');
191
- this.#$targetOpenSlot.addEventListener('keydown', this.#onTargetKeydown);
192
- if (this.#targetActiveElement !== null) {
193
- this.#$targetOpenSlot.addEventListener('focus', this.#stopEventPropagation, true);
194
- this.#targetActiveElement.focus();
195
- this.#$targetOpenSlot.removeEventListener('focus', this.#stopEventPropagation, true);
196
- if (!isElementFocused(this.#targetActiveElement)) {
197
- requestAnimationFrame(() => {
198
- if (this.isDomConnected && this.#$dialog.open) {
199
- this.#$targetOpenSlot.addEventListener('focus', this.#stopEventPropagation, true);
200
- this.#targetActiveElement.focus();
201
- this.#$targetOpenSlot.removeEventListener('focus', this.#stopEventPropagation, true);
202
- }
203
- });
204
- }
205
- }
206
- }
207
- disableOverscroll();
208
- window.addEventListener('scroll', this.#updatePosition, {
209
- passive: false
210
- });
211
- window.addEventListener('resize', this.#onResize);
212
- requestAnimationFrame(() => {
213
- if (this.isDomConnected && this.#$dialog.open) {
214
- this.#$contentSlot.addEventListener('slotchange', this.#onContentSlotChange);
215
- }
216
- });
217
- this.#dispatchContentVisibility(true);
218
- }
219
- #onCollapse() {
220
- if (!this.#$dialog.open) {
221
- return;
222
- }
223
- const isNonModal = !this.modal;
224
- this.#dispatchContentVisibility(false);
225
- this.#$targetOpenSlot.removeEventListener('keydown', this.#onTargetKeydown);
226
- if (isNonModal) {
227
- this.#$targetOpenSlot.addEventListener('blur', this.#captureActiveElement, true);
228
- }
229
- this.#$dialog.close();
230
- this.#$targetWrapper.setAttribute('aria-expanded', 'false');
231
- if (isNonModal) {
232
- this.#$targetOpenSlot.removeEventListener('blur', this.#captureActiveElement, true);
233
- }
234
- if (isNonModal) {
235
- const targetEl = this.#getFirstTargetElement(this.#$targetOpenSlot);
236
- targetEl.style.removeProperty('margin');
237
- targetEl.style.removeProperty('position');
238
- targetEl.style.removeProperty('transform');
239
- if (this.#targetStyleValue !== null) {
240
- targetEl.setAttribute('style', this.#targetStyleValue);
241
- this.#targetStyleValue = null;
242
- }
243
- getFirstSlotElement(this.#$targetOpenSlot)?.setAttribute('slot', 'target');
244
- this.#$targetWrapper.style.removeProperty('display');
245
- this.#$targetWrapper.style.removeProperty('width');
246
- this.#$targetWrapper.style.removeProperty('height');
247
- }
248
- if (this.#targetActiveElement !== null) {
249
- if (!isElementFocused(this.#targetActiveElement)) {
250
- this.#$targetSlot.addEventListener('focus', this.#stopEventPropagation, true);
251
- this.#targetActiveElement.focus({
252
- preventScroll: true
253
- });
254
- this.#$targetSlot.removeEventListener('focus', this.#stopEventPropagation, true);
255
- if (!isElementFocused(this.#targetActiveElement)) {
256
- const $targetEl = this.#targetActiveElement;
257
- requestAnimationFrame(() => {
258
- if (this.isDomConnected && !this.#$dialog.open) {
259
- this.#$targetSlot.addEventListener('focus', this.#stopEventPropagation, true);
260
- $targetEl.focus({
261
- preventScroll: true
262
- });
263
- this.#$targetSlot.removeEventListener('focus', this.#stopEventPropagation, true);
264
- }
265
- });
266
- }
267
- this.#targetActiveElement = null;
268
- }
269
- }
270
- enableOverscroll();
271
- this.#resizeThrottle.cancel();
272
- window.removeEventListener('resize', this.#onResize);
273
- window.removeEventListener('scroll', this.#updatePosition);
274
- this.#$contentSlot.removeEventListener('slotchange', this.#onContentSlotChange);
275
- }
276
- #onResize = () => {
277
- this.#resizeThrottle.fn();
278
- };
279
- #updatePosition = () => {
280
- const targetRect = this.modal ? this.#getTargetRect() : this.#$targetWrapper.getBoundingClientRect();
281
- const orient = this.orientation;
282
- const modalWidth = this.#modalWidth;
283
- const modalHeight = this.#modalHeight;
284
- const inset = this.inset;
285
- let xPos = 0;
286
- let yPos = 0;
287
- if (orient === 'bottom-right' || orient === 'top-right' || orient === 'top-stretch' || orient === 'bottom-stretch') {
288
- xPos = targetRect.x;
289
- }
290
- if (orient === 'bottom-left' || orient === 'top-left') {
291
- xPos = targetRect.x + targetRect.width - modalWidth;
292
- }
293
- if (orient === 'bottom-center' || orient === 'top-center') {
294
- xPos = targetRect.x + targetRect.width / 2 - modalWidth / 2;
295
- }
296
- if (orient === 'center-right') {
297
- xPos = targetRect.x + targetRect.width;
298
- }
299
- if (orient === 'center-left') {
300
- xPos = targetRect.x - modalWidth;
301
- }
302
- if (orient === 'bottom-left' || orient === 'bottom-right' || orient === 'bottom-stretch' || orient === 'bottom-center') {
303
- yPos = targetRect.y + targetRect.height;
304
- }
305
- if (orient === 'top-left' || orient === 'top-right' || orient === 'top-stretch' || orient === 'top-center') {
306
- yPos = targetRect.y - modalHeight;
307
- }
308
- if (orient === 'center-left' || orient === 'center-right') {
309
- yPos = targetRect.y + targetRect.height / 2 - modalHeight / 2;
310
- }
311
- const clampedXPos = Math.max(inset, Math.min(xPos, window.innerWidth - modalWidth - inset));
312
- const clampedYPos = Math.max(inset, Math.min(yPos, window.innerHeight - modalHeight - inset));
313
- this.#$dialog.style.setProperty('left', `${clampedXPos}px`);
314
- this.#$dialog.style.setProperty('top', `${clampedYPos}px`);
315
- if (!this.modal) {
316
- const targetLeftPos = targetRect.x - clampedXPos;
317
- const targetTopPos = targetRect.y - clampedYPos;
318
- this.#$targetOpenWrapper.style.setProperty('left', `${targetLeftPos}px`);
319
- this.#$targetOpenWrapper.style.setProperty('top', `${targetTopPos}px`);
320
- }
321
- };
322
- #updateOrientation = () => {
323
- this.#$dialog.style.setProperty('width', 'max-content');
324
- const targetRect = this.#getTargetRect();
325
- const modalRect = this.#$dialog.getBoundingClientRect();
326
- const orient = this.orientation;
327
- const shouldSetWidthToTarget = orient === 'top-stretch' || orient === 'bottom-stretch';
328
- const modalHeight = modalRect.height;
329
- const modalWidth = shouldSetWidthToTarget ? targetRect.width : modalRect.width;
330
- const inset = this.inset;
331
- let xPos = 0;
332
- let yPos = 0;
333
- this.#modalHeight = modalHeight;
334
- this.#modalWidth = modalWidth;
335
- if (orient === 'bottom-right' || orient === 'top-right' || orient === 'top-stretch' || orient === 'bottom-stretch') {
336
- xPos = targetRect.x;
337
- }
338
- if (orient === 'bottom-left' || orient === 'top-left') {
339
- xPos = targetRect.x + targetRect.width - modalWidth;
340
- }
341
- if (orient === 'bottom-center' || orient === 'top-center') {
342
- xPos = targetRect.x + targetRect.width / 2 - modalWidth / 2;
343
- }
344
- if (orient === 'center-right') {
345
- xPos = targetRect.x + targetRect.width;
346
- }
347
- if (orient === 'center-left') {
348
- xPos = targetRect.x - modalWidth;
349
- }
350
- if (orient === 'bottom-left' || orient === 'bottom-right' || orient === 'bottom-stretch' || orient === 'bottom-center') {
351
- yPos = targetRect.y + targetRect.height;
352
- }
353
- if (orient === 'top-left' || orient === 'top-right' || orient === 'top-stretch' || orient === 'top-center') {
354
- yPos = targetRect.y - modalHeight;
355
- }
356
- if (orient === 'center-left' || orient === 'center-right') {
357
- yPos = targetRect.y + targetRect.height / 2 - modalHeight / 2;
358
- }
359
- xPos = Math.round(Math.max(inset, Math.min(xPos, window.innerWidth - modalWidth - inset)));
360
- yPos = Math.round(Math.max(inset, Math.min(yPos, window.innerHeight - modalHeight - inset)));
361
- this.#$dialog.style.setProperty('left', `${xPos}px`);
362
- this.#$dialog.style.setProperty('top', `${yPos}px`);
363
- this.#$dialog.style.setProperty('width', `${modalWidth}px`);
364
- if (!this.modal) {
365
- const targetLeftPos = targetRect.x - xPos;
366
- const targetTopPos = targetRect.y - yPos;
367
- this.#$targetOpenWrapper.style.setProperty('left', `${targetLeftPos}px`);
368
- this.#$targetOpenWrapper.style.setProperty('top', `${targetTopPos}px`);
369
- }
370
- };
371
- #onBackdropMouseDown = e => {
372
- if (isTargetEqual(e, this.#$dialog)) {
373
- const rect = this.popoverRect;
374
- const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
375
- if (!isInside) {
376
- e.stopPropagation();
377
- this.#dispatchCloseEvent();
378
- }
379
- }
380
- };
381
- #onCancel = e => {
382
- e.preventDefault();
383
- e.stopPropagation();
384
- this.#dispatchCloseEvent();
385
- };
386
- #onCloseReactHandler = e => {
387
- getReactEventHandler(this, 'on-close')?.(e);
388
- };
389
- #dispatchCloseEvent() {
390
- this.dispatchEvent(new CustomEvent('-close'));
391
- }
392
- #captureRelatedActiveElement = e => {
393
- e.stopPropagation();
394
- this.#targetActiveElement = e.relatedTarget;
395
- };
396
- #captureActiveElement = e => {
397
- e.stopPropagation();
398
- this.#targetActiveElement = e.target;
399
- };
400
- #stopEventPropagation = e => {
401
- e.stopPropagation();
402
- };
403
- #dispatchContentVisibility(isVisible) {
404
- this.#visibilityContext.dispatch(isVisible);
405
- }
406
- #onTargetKeydown = e => {
407
- this.#keydownContext.dispatch({
408
- code: e.code,
409
- preventDefault: () => {
410
- e.preventDefault();
411
- }
412
- });
413
- };
414
- #onContextVisibility = e => {
415
- if (!e.detail) {
416
- this.#dispatchCloseEvent();
417
- }
418
- };
419
- #onContentSlotChange = e => {
420
- e.stopPropagation();
421
- if (this.#$dialog.open) {
422
- this.#updateOrientation();
423
- }
424
- };
425
- });