@nectary/components 2.9.0 → 2.11.0

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