@techsio/ui-kit 0.57.0 → 0.59.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 (346) hide show
  1. package/README.md +128 -133
  2. package/dist/atoms/action-icon.js +9 -8
  3. package/dist/atoms/button.js +114 -18
  4. package/dist/atoms/checkbox.js +77 -17
  5. package/dist/atoms/hotkeys.js +26 -7
  6. package/dist/atoms/icon.js +5 -5
  7. package/dist/atoms/image.js +118 -3
  8. package/dist/atoms/input.js +57 -9
  9. package/dist/atoms/label.js +13 -4
  10. package/dist/atoms/link-button.js +15 -12
  11. package/dist/atoms/link.js +18 -4
  12. package/dist/atoms/numeric-input.js +362 -84
  13. package/dist/atoms/rating.js +306 -73
  14. package/dist/atoms/skeleton.js +18 -14
  15. package/dist/atoms/status-text.js +31 -18
  16. package/dist/atoms/textarea.js +59 -12
  17. package/dist/atoms/tooltip.js +64 -43
  18. package/dist/hotkeys.js +1 -0
  19. package/dist/internal/choice-control.js +173 -0
  20. package/dist/internal/combobox-query-sync.js +11 -0
  21. package/dist/internal/date-picker-coordinator.js +56 -40
  22. package/dist/internal/date-picker-dom.js +44 -0
  23. package/dist/internal/date-picker-input.js +30 -0
  24. package/dist/internal/described-by.js +23 -18
  25. package/dist/internal/form-control-lifecycle.js +122 -0
  26. package/dist/internal/molecules/command.context.js +1 -0
  27. package/dist/internal/molecules/drawer.context.js +1 -0
  28. package/dist/internal/molecules/vertical-navigation.context.js +1 -0
  29. package/dist/internal/molecules/vertical-navigation.styles.js +9 -2
  30. package/dist/internal/numeric-input-editing.js +87 -0
  31. package/dist/internal/organisms/sidebar.context.js +1 -0
  32. package/dist/internal/organisms/sidebar.focus.js +1 -0
  33. package/dist/internal/overlay-portal.js +72 -0
  34. package/dist/internal/reduced-motion.js +1 -0
  35. package/dist/internal/use-effective-disabled.js +8 -0
  36. package/dist/molecules/accordion.js +44 -30
  37. package/dist/molecules/availability-status.js +1 -0
  38. package/dist/molecules/breadcrumb.js +11 -11
  39. package/dist/molecules/carousel.js +279 -97
  40. package/dist/molecules/cascade-select.js +327 -81
  41. package/dist/molecules/chart.js +427 -78
  42. package/dist/molecules/color-select.js +181 -62
  43. package/dist/molecules/combobox.js +537 -182
  44. package/dist/molecules/command.js +2 -1
  45. package/dist/molecules/date-picker.js +629 -119
  46. package/dist/molecules/dialog.js +89 -48
  47. package/dist/molecules/drawer.js +63 -6
  48. package/dist/molecules/file-upload.js +373 -37
  49. package/dist/molecules/form-checkbox.js +65 -22
  50. package/dist/molecules/form-error-summary.js +29 -5
  51. package/dist/molecules/form-input.js +26 -30
  52. package/dist/molecules/form-numeric-input.js +11 -9
  53. package/dist/molecules/form-textarea.js +26 -23
  54. package/dist/molecules/menu.js +170 -47
  55. package/dist/molecules/pagination.js +100 -28
  56. package/dist/molecules/phone-input.js +172 -37
  57. package/dist/molecules/popover.js +53 -26
  58. package/dist/molecules/price-block.js +1 -0
  59. package/dist/molecules/product-card.js +85 -23
  60. package/dist/molecules/quantity-field.js +4 -2
  61. package/dist/molecules/radio-card.js +102 -30
  62. package/dist/molecules/radio-group.js +108 -31
  63. package/dist/molecules/search-form.js +116 -13
  64. package/dist/molecules/select.js +226 -81
  65. package/dist/molecules/slider.js +141 -30
  66. package/dist/molecules/steps.js +181 -50
  67. package/dist/molecules/switch.js +86 -20
  68. package/dist/molecules/tabs.js +227 -31
  69. package/dist/molecules/toast.js +155 -53
  70. package/dist/molecules/totals-summary.js +2 -1
  71. package/dist/molecules/tour.js +9 -5
  72. package/dist/molecules/tree-view.js +255 -109
  73. package/dist/molecules/vertical-navigation.js +8 -4
  74. package/dist/organisms/data-table.fields.js +26 -5
  75. package/dist/organisms/data-table.helpers.js +6 -2
  76. package/dist/organisms/data-table.js +587 -154
  77. package/dist/organisms/footer.js +18 -11
  78. package/dist/organisms/gallery.js +61 -24
  79. package/dist/organisms/header.js +106 -32
  80. package/dist/organisms/line-item.js +1 -0
  81. package/dist/organisms/sidebar.js +1 -0
  82. package/dist/organisms/table.js +22 -7
  83. package/dist/src/atoms/action-icon.d.ts +10 -10
  84. package/dist/src/atoms/action-icon.d.ts.map +1 -1
  85. package/dist/src/atoms/badge.d.ts +3 -3
  86. package/dist/src/atoms/badge.d.ts.map +1 -1
  87. package/dist/src/atoms/button.d.ts +47 -24
  88. package/dist/src/atoms/button.d.ts.map +1 -1
  89. package/dist/src/atoms/checkbox.d.ts +6 -5
  90. package/dist/src/atoms/checkbox.d.ts.map +1 -1
  91. package/dist/src/atoms/hotkeys.d.ts +3 -2
  92. package/dist/src/atoms/hotkeys.d.ts.map +1 -1
  93. package/dist/src/atoms/icon.d.ts +18 -17
  94. package/dist/src/atoms/icon.d.ts.map +1 -1
  95. package/dist/src/atoms/image.d.ts +38 -7
  96. package/dist/src/atoms/image.d.ts.map +1 -1
  97. package/dist/src/atoms/input.d.ts +23 -14
  98. package/dist/src/atoms/input.d.ts.map +1 -1
  99. package/dist/src/atoms/label.d.ts +4 -4
  100. package/dist/src/atoms/label.d.ts.map +1 -1
  101. package/dist/src/atoms/link-button.d.ts +78 -31
  102. package/dist/src/atoms/link-button.d.ts.map +1 -1
  103. package/dist/src/atoms/link.d.ts +30 -9
  104. package/dist/src/atoms/link.d.ts.map +1 -1
  105. package/dist/src/atoms/numeric-input.d.ts +24 -19
  106. package/dist/src/atoms/numeric-input.d.ts.map +1 -1
  107. package/dist/src/atoms/rating.d.ts +54 -26
  108. package/dist/src/atoms/rating.d.ts.map +1 -1
  109. package/dist/src/atoms/skeleton.d.ts +9 -9
  110. package/dist/src/atoms/skeleton.d.ts.map +1 -1
  111. package/dist/src/atoms/status-text.d.ts +21 -13
  112. package/dist/src/atoms/status-text.d.ts.map +1 -1
  113. package/dist/src/atoms/textarea.d.ts +22 -20
  114. package/dist/src/atoms/textarea.d.ts.map +1 -1
  115. package/dist/src/atoms/tooltip.d.ts +5 -5
  116. package/dist/src/atoms/tooltip.d.ts.map +1 -1
  117. package/dist/src/hotkeys.d.ts +1 -1
  118. package/dist/src/hotkeys.d.ts.map +1 -1
  119. package/dist/src/internal/choice-control.d.ts +18 -0
  120. package/dist/src/internal/choice-control.d.ts.map +1 -0
  121. package/dist/src/internal/combobox-query-sync.d.ts +4 -0
  122. package/dist/src/internal/combobox-query-sync.d.ts.map +1 -0
  123. package/dist/src/internal/date-picker-coordinator.d.ts +7 -1
  124. package/dist/src/internal/date-picker-coordinator.d.ts.map +1 -1
  125. package/dist/src/internal/date-picker-dom.d.ts +10 -0
  126. package/dist/src/internal/date-picker-dom.d.ts.map +1 -0
  127. package/dist/src/internal/date-picker-input.d.ts +7 -0
  128. package/dist/src/internal/date-picker-input.d.ts.map +1 -0
  129. package/dist/src/internal/described-by.d.ts +7 -1
  130. package/dist/src/internal/described-by.d.ts.map +1 -1
  131. package/dist/src/internal/form-control-lifecycle.d.ts +22 -0
  132. package/dist/src/internal/form-control-lifecycle.d.ts.map +1 -0
  133. package/dist/src/internal/molecules/vertical-navigation.context.d.ts +1 -1
  134. package/dist/src/internal/molecules/vertical-navigation.context.d.ts.map +1 -1
  135. package/dist/src/internal/molecules/vertical-navigation.styles.d.ts +21 -0
  136. package/dist/src/internal/molecules/vertical-navigation.styles.d.ts.map +1 -1
  137. package/dist/src/internal/numeric-input-editing.d.ts +13 -0
  138. package/dist/src/internal/numeric-input-editing.d.ts.map +1 -0
  139. package/dist/src/internal/overlay-portal.d.ts +18 -0
  140. package/dist/src/internal/overlay-portal.d.ts.map +1 -0
  141. package/dist/src/internal/use-effective-disabled.d.ts +4 -0
  142. package/dist/src/internal/use-effective-disabled.d.ts.map +1 -0
  143. package/dist/src/molecules/accordion.d.ts +25 -19
  144. package/dist/src/molecules/accordion.d.ts.map +1 -1
  145. package/dist/src/molecules/availability-status.d.ts +4 -1
  146. package/dist/src/molecules/availability-status.d.ts.map +1 -1
  147. package/dist/src/molecules/breadcrumb.d.ts +2 -2
  148. package/dist/src/molecules/breadcrumb.d.ts.map +1 -1
  149. package/dist/src/molecules/carousel.d.ts +51 -52
  150. package/dist/src/molecules/carousel.d.ts.map +1 -1
  151. package/dist/src/molecules/cascade-select.d.ts +23 -8
  152. package/dist/src/molecules/cascade-select.d.ts.map +1 -1
  153. package/dist/src/molecules/chart.d.ts +18 -1
  154. package/dist/src/molecules/chart.d.ts.map +1 -1
  155. package/dist/src/molecules/color-select.d.ts +19 -3
  156. package/dist/src/molecules/color-select.d.ts.map +1 -1
  157. package/dist/src/molecules/combobox.d.ts +27 -5
  158. package/dist/src/molecules/combobox.d.ts.map +1 -1
  159. package/dist/src/molecules/command.d.ts +1 -1
  160. package/dist/src/molecules/date-picker.d.ts +30 -4
  161. package/dist/src/molecules/date-picker.d.ts.map +1 -1
  162. package/dist/src/molecules/dialog.d.ts +17 -4
  163. package/dist/src/molecules/dialog.d.ts.map +1 -1
  164. package/dist/src/molecules/drawer.d.ts +4 -4
  165. package/dist/src/molecules/drawer.d.ts.map +1 -1
  166. package/dist/src/molecules/file-upload.d.ts +11 -6
  167. package/dist/src/molecules/file-upload.d.ts.map +1 -1
  168. package/dist/src/molecules/form-checkbox.d.ts +7 -2
  169. package/dist/src/molecules/form-checkbox.d.ts.map +1 -1
  170. package/dist/src/molecules/form-error-summary.d.ts +4 -3
  171. package/dist/src/molecules/form-error-summary.d.ts.map +1 -1
  172. package/dist/src/molecules/form-input.d.ts +5 -6
  173. package/dist/src/molecules/form-input.d.ts.map +1 -1
  174. package/dist/src/molecules/form-numeric-input.d.ts +5 -5
  175. package/dist/src/molecules/form-numeric-input.d.ts.map +1 -1
  176. package/dist/src/molecules/form-textarea.d.ts +5 -6
  177. package/dist/src/molecules/form-textarea.d.ts.map +1 -1
  178. package/dist/src/molecules/menu.d.ts +17 -3
  179. package/dist/src/molecules/menu.d.ts.map +1 -1
  180. package/dist/src/molecules/pagination.d.ts +1 -1
  181. package/dist/src/molecules/pagination.d.ts.map +1 -1
  182. package/dist/src/molecules/phone-input.d.ts +4 -1
  183. package/dist/src/molecules/phone-input.d.ts.map +1 -1
  184. package/dist/src/molecules/popover.d.ts +7 -1
  185. package/dist/src/molecules/popover.d.ts.map +1 -1
  186. package/dist/src/molecules/price-block.d.ts +1 -1
  187. package/dist/src/molecules/price-block.d.ts.map +1 -1
  188. package/dist/src/molecules/product-card.d.ts +127 -27
  189. package/dist/src/molecules/product-card.d.ts.map +1 -1
  190. package/dist/src/molecules/quantity-field.d.ts +1 -1
  191. package/dist/src/molecules/quantity-field.d.ts.map +1 -1
  192. package/dist/src/molecules/radio-card.d.ts +10 -3
  193. package/dist/src/molecules/radio-card.d.ts.map +1 -1
  194. package/dist/src/molecules/radio-group.d.ts +15 -6
  195. package/dist/src/molecules/radio-group.d.ts.map +1 -1
  196. package/dist/src/molecules/search-form.d.ts +37 -12
  197. package/dist/src/molecules/search-form.d.ts.map +1 -1
  198. package/dist/src/molecules/select.d.ts +34 -29
  199. package/dist/src/molecules/select.d.ts.map +1 -1
  200. package/dist/src/molecules/slider.d.ts +23 -2
  201. package/dist/src/molecules/slider.d.ts.map +1 -1
  202. package/dist/src/molecules/steps.d.ts +30 -10
  203. package/dist/src/molecules/steps.d.ts.map +1 -1
  204. package/dist/src/molecules/switch.d.ts +54 -33
  205. package/dist/src/molecules/switch.d.ts.map +1 -1
  206. package/dist/src/molecules/tabs.d.ts +11 -11
  207. package/dist/src/molecules/tabs.d.ts.map +1 -1
  208. package/dist/src/molecules/toast.d.ts +38 -14
  209. package/dist/src/molecules/toast.d.ts.map +1 -1
  210. package/dist/src/molecules/totals-summary.d.ts +1 -1
  211. package/dist/src/molecules/totals-summary.d.ts.map +1 -1
  212. package/dist/src/molecules/tour.d.ts +1 -1
  213. package/dist/src/molecules/tour.d.ts.map +1 -1
  214. package/dist/src/molecules/tree-view.d.ts +16 -20
  215. package/dist/src/molecules/tree-view.d.ts.map +1 -1
  216. package/dist/src/molecules/vertical-navigation.d.ts +2 -2
  217. package/dist/src/molecules/vertical-navigation.d.ts.map +1 -1
  218. package/dist/src/organisms/data-table.d.ts +28 -3
  219. package/dist/src/organisms/data-table.d.ts.map +1 -1
  220. package/dist/src/organisms/data-table.fields.d.ts +4 -1
  221. package/dist/src/organisms/data-table.fields.d.ts.map +1 -1
  222. package/dist/src/organisms/data-table.helpers.d.ts +5 -12
  223. package/dist/src/organisms/data-table.helpers.d.ts.map +1 -1
  224. package/dist/src/organisms/footer.d.ts +5 -5
  225. package/dist/src/organisms/footer.d.ts.map +1 -1
  226. package/dist/src/organisms/gallery.d.ts +11 -9
  227. package/dist/src/organisms/gallery.d.ts.map +1 -1
  228. package/dist/src/organisms/header.d.ts +24 -22
  229. package/dist/src/organisms/header.d.ts.map +1 -1
  230. package/dist/src/organisms/table.d.ts +14 -14
  231. package/dist/src/organisms/table.d.ts.map +1 -1
  232. package/dist/src/templates/accordion.d.ts +8 -6
  233. package/dist/src/templates/accordion.d.ts.map +1 -1
  234. package/dist/src/templates/breadcrumb.d.ts +1 -1
  235. package/dist/src/templates/breadcrumb.d.ts.map +1 -1
  236. package/dist/src/templates/carousel.d.ts +3 -3
  237. package/dist/src/templates/carousel.d.ts.map +1 -1
  238. package/dist/src/templates/facet-filter-panel.d.ts +9 -3
  239. package/dist/src/templates/facet-filter-panel.d.ts.map +1 -1
  240. package/dist/src/templates/gallery.d.ts +2 -2
  241. package/dist/src/templates/gallery.d.ts.map +1 -1
  242. package/dist/src/templates/numeric-input.d.ts +1 -1
  243. package/dist/src/templates/numeric-input.d.ts.map +1 -1
  244. package/dist/src/templates/popover.d.ts +4 -2
  245. package/dist/src/templates/popover.d.ts.map +1 -1
  246. package/dist/src/templates/product-card.d.ts +12 -4
  247. package/dist/src/templates/product-card.d.ts.map +1 -1
  248. package/dist/src/templates/search-suggestions.d.ts +1 -1
  249. package/dist/src/templates/select.d.ts +7 -2
  250. package/dist/src/templates/select.d.ts.map +1 -1
  251. package/dist/src/templates/tabs.d.ts +8 -7
  252. package/dist/src/templates/tabs.d.ts.map +1 -1
  253. package/dist/src/theme/theme-config.d.ts +9 -16
  254. package/dist/src/theme/theme-config.d.ts.map +1 -1
  255. package/dist/src/theme/theme-provider.d.ts +16 -21
  256. package/dist/src/theme/theme-provider.d.ts.map +1 -1
  257. package/dist/src/theme/theme-toggle.d.ts.map +1 -1
  258. package/dist/src/utils.d.ts.map +1 -1
  259. package/dist/templates/accordion.js +3 -1
  260. package/dist/templates/breadcrumb.js +11 -4
  261. package/dist/templates/carousel.js +3 -6
  262. package/dist/templates/facet-filter-panel.js +121 -52
  263. package/dist/templates/gallery.js +6 -2
  264. package/dist/templates/numeric-input.js +6 -1
  265. package/dist/templates/popover.js +6 -1
  266. package/dist/templates/product-card.js +52 -26
  267. package/dist/templates/select.js +6 -1
  268. package/dist/templates/tabs.js +4 -2
  269. package/dist/theme/theme-config.js +8 -16
  270. package/dist/theme/theme-provider.js +89 -63
  271. package/dist/theme/theme-toggle.js +17 -9
  272. package/dist/utils.js +11 -1
  273. package/package.json +9 -5
  274. package/src/tokens/_base.css +4 -3
  275. package/src/tokens/_business-atoms.css +96 -0
  276. package/src/tokens/_foundation-overrides.css +251 -0
  277. package/src/tokens/_reset.css +10 -10
  278. package/src/tokens/_scheme-scopes.css +4194 -0
  279. package/src/tokens/_semantic.css +1 -23
  280. package/src/tokens/_tokens-base.css +36 -32
  281. package/src/tokens/_typography.css +2 -1
  282. package/src/tokens/components/_form-control.css +149 -6
  283. package/src/tokens/components/_popup-surface.css +15 -29
  284. package/src/tokens/components/atoms/_action-icon.css +49 -0
  285. package/src/tokens/components/atoms/_button.css +77 -0
  286. package/src/tokens/components/atoms/_checkbox.css +47 -4
  287. package/src/tokens/components/atoms/_hotkeys.css +2 -0
  288. package/src/tokens/components/atoms/_icon.css +60 -7
  289. package/src/tokens/components/atoms/_image.css +18 -0
  290. package/src/tokens/components/atoms/_input.css +20 -0
  291. package/src/tokens/components/atoms/_label.css +3 -7
  292. package/src/tokens/components/atoms/_link.css +47 -5
  293. package/src/tokens/components/atoms/_numeric-input.css +121 -2
  294. package/src/tokens/components/atoms/_rating.css +55 -6
  295. package/src/tokens/components/atoms/_skeleton.css +12 -2
  296. package/src/tokens/components/atoms/_status-text.css +35 -5
  297. package/src/tokens/components/atoms/_textarea.css +32 -3
  298. package/src/tokens/components/atoms/_tooltip.css +25 -0
  299. package/src/tokens/components/molecules/_accordion.css +46 -5
  300. package/src/tokens/components/molecules/_breadcrumb.css +15 -4
  301. package/src/tokens/components/molecules/_carousel.css +67 -0
  302. package/src/tokens/components/molecules/_cascade-select.css +104 -0
  303. package/src/tokens/components/molecules/_chart.css +32 -16
  304. package/src/tokens/components/molecules/_color-select.css +21 -0
  305. package/src/tokens/components/molecules/_combobox.css +81 -0
  306. package/src/tokens/components/molecules/_command.css +1 -0
  307. package/src/tokens/components/molecules/_date-picker.css +66 -10
  308. package/src/tokens/components/molecules/_dialog.css +36 -4
  309. package/src/tokens/components/molecules/_drawer.css +39 -3
  310. package/src/tokens/components/molecules/_file-upload.css +16 -1
  311. package/src/tokens/components/molecules/_menu.css +17 -0
  312. package/src/tokens/components/molecules/_pagination.css +19 -0
  313. package/src/tokens/components/molecules/_phone-input.css +20 -5
  314. package/src/tokens/components/molecules/_popover.css +34 -0
  315. package/src/tokens/components/molecules/_product-card.css +70 -0
  316. package/src/tokens/components/molecules/_radio-card.css +35 -0
  317. package/src/tokens/components/molecules/_radio-group.css +8 -0
  318. package/src/tokens/components/molecules/_select.css +33 -0
  319. package/src/tokens/components/molecules/_slider.css +5 -0
  320. package/src/tokens/components/molecules/_steps.css +52 -0
  321. package/src/tokens/components/molecules/_switch.css +59 -10
  322. package/src/tokens/components/molecules/_tabs.css +61 -3
  323. package/src/tokens/components/molecules/_toast.css +60 -0
  324. package/src/tokens/components/molecules/_totals-summary.css +22 -22
  325. package/src/tokens/components/molecules/_tour.css +16 -1
  326. package/src/tokens/components/molecules/_tree-view.css +27 -3
  327. package/src/tokens/components/molecules/_vertical-navigation.css +21 -3
  328. package/src/tokens/components/organisms/_data-table.css +97 -0
  329. package/src/tokens/components/organisms/_footer.css +9 -0
  330. package/src/tokens/components/organisms/_gallery.css +11 -0
  331. package/src/tokens/components/organisms/_header.css +22 -0
  332. package/src/tokens/components/organisms/_sidebar.css +1 -1
  333. package/src/tokens/components/organisms/_table.css +31 -0
  334. package/src/tokens/components/templates/_facet-filter-panel.css +11 -1
  335. package/src/tokens/figma/akros/variables.css +15 -6
  336. package/src/tokens/figma/brand-overrides.css +171 -57
  337. package/src/tokens/figma/business/variables.css +15 -6
  338. package/src/tokens/figma/cyber/variables.css +115 -38
  339. package/src/tokens/figma/cyber-dark/variables.css +115 -38
  340. package/src/tokens/figma/dark/variables.css +13 -4
  341. package/src/tokens/figma/light/variables.css +62 -49
  342. package/src/tokens/figma/{neo → n1}/variables.css +123 -114
  343. package/src/tokens/figma/variables.css +658 -249
  344. package/src/tokens/theme.css +24 -4
  345. package/src/tokens/_colors.css +0 -5
  346. package/src/tokens/figma/neo-dark/variables.css +0 -457
@@ -1,12 +1,16 @@
1
+ "use client";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { AsYouType, formatIncompletePhoneNumber, getCountryCallingCode, isSupportedCountry, parseIncompletePhoneNumber, parsePhoneNumberFromString } from "libphonenumber-js/max";
3
- import { createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
4
+ import { createContext, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
4
5
  import { Input } from "../atoms/input.js";
5
6
  import { Label } from "../atoms/label.js";
6
7
  import { StatusText } from "../atoms/status-text.js";
7
8
  import { joinDescribedBy, useDescribedBy, useRegisterDescription } from "../internal/described-by.js";
9
+ import { subscribeOwnerFormReset } from "../internal/form-control-lifecycle.js";
8
10
  import { tv } from "../utils.js";
9
11
  import { Select } from "./select.js";
12
+ const phoneDigit = /\d/;
13
+ const phoneNonDigits = /\D/g;
10
14
  const defaultNativeValidationMessage = "Enter a valid phone number.";
11
15
  const defaultPhoneInputCountries = [
12
16
  {
@@ -54,24 +58,18 @@ const phoneInputVariants = tv({
54
58
  "form-control-base",
55
59
  "relative flex w-full min-w-0 items-center overflow-clip",
56
60
  "text-phone-input-fg",
57
- "hover:border-phone-input-border-hover hover:bg-phone-input-bg-hover",
61
+ "hover:border-phone-input-border-hover hover:bg-phone-input-bg-interaction",
58
62
  "phone-input-focus",
59
63
  "data-[disabled]:cursor-not-allowed",
60
64
  "data-[disabled]:border-phone-input-border-disabled",
61
65
  "data-[disabled]:bg-phone-input-bg-disabled",
62
66
  "data-[disabled]:text-phone-input-fg-disabled",
63
67
  "data-[validation=error]:border-(length:--border-width-validation)",
64
- "data-[validation=error]:border-phone-input-border-danger data-[validation=error]:outline-phone-input-border-danger",
65
- "data-[validation=error]:outline-(style:--default-ring-style) data-[validation=error]:outline-(length:--default-ring-width)",
66
- "data-[validation=error]:outline-offset-(length:--default-ring-offset)",
68
+ "data-[validation=error]:border-phone-input-border-danger",
67
69
  "data-[validation=success]:border-(length:--border-width-validation)",
68
- "data-[validation=success]:border-phone-input-border-success data-[validation=success]:outline-phone-input-border-success",
69
- "data-[validation=success]:outline-(style:--default-ring-style) data-[validation=success]:outline-(length:--default-ring-width)",
70
- "data-[validation=success]:outline-offset-(length:--default-ring-offset)",
70
+ "data-[validation=success]:border-phone-input-border-success",
71
71
  "data-[validation=warning]:border-(length:--border-width-validation)",
72
- "data-[validation=warning]:border-phone-input-border-warning data-[validation=warning]:outline-phone-input-border-warning",
73
- "data-[validation=warning]:outline-(style:--default-ring-style) data-[validation=warning]:outline-(length:--default-ring-width)",
74
- "data-[validation=warning]:outline-offset-(length:--default-ring-offset)",
72
+ "data-[validation=warning]:border-phone-input-border-warning",
75
73
  "transition-colors duration-200 motion-reduce:transition-none"
76
74
  ],
77
75
  countrySelectRoot: [
@@ -83,11 +81,11 @@ const phoneInputVariants = tv({
83
81
  countryTrigger: [
84
82
  "shrink-0",
85
83
  "bg-phone-input-trigger-bg-base",
86
- "hover:bg-phone-input-trigger-bg-hover",
84
+ "hover:bg-phone-input-bg-interaction",
87
85
  "border-(length:--border-phone-input-trigger)",
88
86
  "focus-visible:outline-hidden",
89
- "w-phone-input-trigger",
90
- "focus-visible:bg-phone-input-trigger-bg-hover",
87
+ "w-phone-input-trigger gap-phone-input-country-trigger px-phone-input-country-trigger",
88
+ "focus-visible:bg-phone-input-bg-interaction",
91
89
  "rounded-e-none"
92
90
  ],
93
91
  countryValue: [
@@ -102,7 +100,7 @@ const phoneInputVariants = tv({
102
100
  "font-medium text-phone-input-country-calling-code-fg"
103
101
  ],
104
102
  input: [
105
- "min-w-0 flex-1 border-0",
103
+ "min-w-0 flex-1 border-0 read-only:enabled:cursor-text!",
106
104
  "bg-phone-input-input-bg-base",
107
105
  "text-phone-input-fg",
108
106
  "placeholder:text-phone-input-fg-placeholder",
@@ -115,7 +113,7 @@ const phoneInputVariants = tv({
115
113
  "flex min-w-0 items-center gap-phone-input-item"
116
114
  ],
117
115
  itemMeta: [
118
- "shrink-0 text-phone-input-item-meta-fg"
116
+ "phone-input-item-meta shrink-0 text-phone-input-item-meta-fg"
119
117
  ]
120
118
  },
121
119
  variants: {
@@ -172,6 +170,15 @@ function PhoneInput({ countries: countriesProp = defaultPhoneInputCountries, val
172
170
  selectedCountry
173
171
  ]);
174
172
  const nativeFormValue = details.isValid ? details.e164 : inputValue;
173
+ const resetting = useRef(false);
174
+ const setResetting = (pendingReset)=>{
175
+ resetting.current = pendingReset;
176
+ };
177
+ const onFormReset = ()=>{
178
+ const resetCountry = resolveCountry(countries, country ?? getInitialCountry(value ?? defaultValue, defaultCountry, countries));
179
+ if (void 0 === country) setInternalCountry(resetCountry);
180
+ if (!isValueControlled) setInternalValue(formatPhoneInputValue(defaultValue, resetCountry));
181
+ };
175
182
  useEffect(()=>{
176
183
  if (!isValueControlled || country || value === previousControlledValueRef.current) return;
177
184
  previousControlledValueRef.current = value;
@@ -185,6 +192,7 @@ function PhoneInput({ countries: countriesProp = defaultPhoneInputCountries, val
185
192
  value
186
193
  ]);
187
194
  const setInputValue = (nextValue)=>{
195
+ if (disabled || readOnly) return;
188
196
  const nextDetails = getPhoneInputValueDetailsInternal(nextValue, selectedCountry, {
189
197
  countries,
190
198
  syncCountryFromValue: true
@@ -199,6 +207,7 @@ function PhoneInput({ countries: countriesProp = defaultPhoneInputCountries, val
199
207
  onValueChange?.(nextDetails);
200
208
  };
201
209
  const setCountryValue = (nextCountry)=>{
210
+ if (disabled || readOnly || resetting.current) return;
202
211
  const nextCountryItem = getCountryItem(countries, nextCountry);
203
212
  const nextDetails = getPhoneInputValueDetailsInternal(inputValue, nextCountry, {
204
213
  countries
@@ -215,6 +224,7 @@ function PhoneInput({ countries: countriesProp = defaultPhoneInputCountries, val
215
224
  size
216
225
  });
217
226
  const describedBy = useDescribedBy();
227
+ const errorDescriptions = useDescribedBy();
218
228
  return /*#__PURE__*/ jsxs(PhoneInputContext.Provider, {
219
229
  value: {
220
230
  countries,
@@ -227,6 +237,8 @@ function PhoneInput({ countries: countriesProp = defaultPhoneInputCountries, val
227
237
  inputId: `${id}-input`,
228
238
  inputValue,
229
239
  setInputValue,
240
+ onFormReset,
241
+ setResetting,
230
242
  details,
231
243
  disabled,
232
244
  nativeValidation,
@@ -235,7 +247,8 @@ function PhoneInput({ countries: countriesProp = defaultPhoneInputCountries, val
235
247
  required,
236
248
  validateStatus,
237
249
  statusTextId: `${id}-status`,
238
- ...describedBy
250
+ ...describedBy,
251
+ errorDescriptions
239
252
  },
240
253
  children: [
241
254
  name && /*#__PURE__*/ jsx("input", {
@@ -289,11 +302,11 @@ PhoneInput.Control = function({ children, className, ref, ...props }) {
289
302
  });
290
303
  };
291
304
  PhoneInput.CountrySelect = function({ children, className, closeOnSelect = true }) {
292
- const { countries, countryName, disabled, form, readOnly, selectedCountry, setCountryValue, size } = usePhoneInputContext();
305
+ const { countries, countryName, disabled, form, readOnly, selectedCountry, selectedCountryItem, setCountryValue, size } = usePhoneInputContext();
293
306
  const styles = phoneInputVariants({
294
307
  size
295
308
  });
296
- return /*#__PURE__*/ jsx(Select, {
309
+ return /*#__PURE__*/ jsxs(Select, {
297
310
  className: styles.countrySelectRoot({
298
311
  className
299
312
  }),
@@ -311,7 +324,18 @@ PhoneInput.CountrySelect = function({ children, className, closeOnSelect = true
311
324
  value: [
312
325
  selectedCountry
313
326
  ],
314
- children: children
327
+ children: [
328
+ /*#__PURE__*/ jsxs(Select.Label, {
329
+ className: "sr-only",
330
+ children: [
331
+ getCountryDisplayValue(selectedCountryItem),
332
+ " (+",
333
+ getPhoneCountryCallingCode(selectedCountryItem),
334
+ ")"
335
+ ]
336
+ }),
337
+ children
338
+ ]
315
339
  });
316
340
  };
317
341
  PhoneInput.CountryPicker = function({ className, selectProps, controlProps, triggerProps, positionerProps, contentProps }) {
@@ -427,17 +451,93 @@ PhoneInput.CountryCallingCode = function({ item, className, ref, ...props }) {
427
451
  });
428
452
  };
429
453
  PhoneInput.Input = function({ className, onChange, placeholder = "Phone number", ref, ...props }) {
430
- const { details, disabled, form, inputId, inputValue, nativeValidation, nativeValidationMessage, readOnly, required, setInputValue, size, describedById, validateStatus } = usePhoneInputContext();
454
+ const { details, disabled, form, inputId, inputValue, nativeValidation, nativeValidationMessage, onFormReset, setResetting, readOnly, required, setInputValue, size, describedById, errorDescriptions, validateStatus } = usePhoneInputContext();
431
455
  const styles = phoneInputVariants({
432
456
  size
433
457
  });
434
458
  const inputRef = useRef(null);
435
- const setInputRef = useCallback((node)=>{
436
- inputRef.current = node;
437
- assignRef(ref, node);
438
- }, [
459
+ const setInputRef = useMemo(()=>(node)=>{
460
+ inputRef.current = node;
461
+ const cleanup = "function" == typeof ref ? ref(node) : void 0;
462
+ if (ref && "function" != typeof ref) ref.current = node;
463
+ return ()=>{
464
+ inputRef.current = null;
465
+ if ("function" == typeof cleanup) cleanup();
466
+ else if ("function" == typeof ref) ref(null);
467
+ else if (ref) ref.current = null;
468
+ };
469
+ }, [
439
470
  ref
440
471
  ]);
472
+ const [compositionValue, setCompositionValue] = useState();
473
+ const [selection, setSelection] = useState();
474
+ const captureSelection = (input)=>{
475
+ setSelection({
476
+ value: input.value,
477
+ start: input.selectionStart ?? input.value.length,
478
+ end: input.selectionEnd ?? input.value.length,
479
+ direction: input.selectionDirection
480
+ });
481
+ };
482
+ useLayoutEffect(()=>{
483
+ const input = inputRef.current;
484
+ if (!(input && selection) || void 0 !== compositionValue || input.ownerDocument.activeElement !== input) return;
485
+ const digits = (text)=>text.replace(phoneNonDigits, "").length;
486
+ const dropped = selection.value.startsWith("+") ? Math.max(0, digits(selection.value) - digits(input.value)) : 0;
487
+ const map = (offset)=>{
488
+ const count = Math.max(0, digits(selection.value.slice(0, offset)) - dropped);
489
+ if (0 === count) return 0;
490
+ let seen = 0;
491
+ for(let i = 0; i < input.value.length; i++)if (phoneDigit.test(input.value[i] ?? "")) {
492
+ seen += 1;
493
+ if (seen === count) return i + 1;
494
+ }
495
+ return input.value.length;
496
+ };
497
+ input.setSelectionRange(map(selection.start), map(selection.end), selection.direction ?? void 0);
498
+ setSelection(void 0);
499
+ }, [
500
+ compositionValue,
501
+ selection
502
+ ]);
503
+ const resetHandlers = useRef({
504
+ onFormReset,
505
+ setResetting
506
+ });
507
+ useLayoutEffect(()=>{
508
+ resetHandlers.current = {
509
+ onFormReset,
510
+ setResetting
511
+ };
512
+ });
513
+ useEffect(()=>{
514
+ const input = inputRef.current;
515
+ if (!input) return;
516
+ return subscribeOwnerFormReset(input, ()=>resetHandlers.current.onFormReset(), {
517
+ onResetStart: ()=>resetHandlers.current.setResetting(true),
518
+ onResetEnd: ()=>resetHandlers.current.setResetting(false)
519
+ });
520
+ }, []);
521
+ useEffect(()=>{
522
+ const input = inputRef.current;
523
+ if (!input) return;
524
+ const beforeInput = (event)=>{
525
+ if (disabled || readOnly || event.isComposing || !event.cancelable || input.selectionStart !== input.selectionEnd) return;
526
+ const range = getSeparatorDeletionRange(input.value, input.selectionStart ?? 0, event.inputType);
527
+ if (!range) return;
528
+ const [start, end] = range;
529
+ event.preventDefault();
530
+ input.setRangeText("", start, end, "start");
531
+ input.dispatchEvent(new Event("input", {
532
+ bubbles: true
533
+ }));
534
+ };
535
+ input.addEventListener("beforeinput", beforeInput);
536
+ return ()=>input.removeEventListener("beforeinput", beforeInput);
537
+ }, [
538
+ disabled,
539
+ readOnly
540
+ ]);
441
541
  useEffect(()=>{
442
542
  const input = inputRef.current;
443
543
  if (!input) return;
@@ -454,7 +554,8 @@ PhoneInput.Input = function({ className, onChange, placeholder = "Phone number",
454
554
  return /*#__PURE__*/ jsx(Input, {
455
555
  ...props,
456
556
  "aria-describedby": joinDescribedBy(props["aria-describedby"], describedById),
457
- "aria-invalid": "error" === validateStatus || nativeValidation && "" !== inputValue.trim() && !details.isValid || void 0,
557
+ "aria-errormessage": "error" === validateStatus || errorDescriptions.describedById ? joinDescribedBy(props["aria-errormessage"], errorDescriptions.describedById) : void 0,
558
+ "aria-invalid": Boolean(errorDescriptions.describedById) || "error" === validateStatus || nativeValidation && "" !== inputValue.trim() && !details.isValid || void 0,
458
559
  className: styles.input({
459
560
  className
460
561
  }),
@@ -464,8 +565,26 @@ PhoneInput.Input = function({ className, onChange, placeholder = "Phone number",
464
565
  inputMode: "tel",
465
566
  name: void 0,
466
567
  onChange: (event)=>{
467
- setInputValue(event.target.value);
468
- onChange?.(event);
568
+ if (!(disabled || readOnly)) {
569
+ if (event.nativeEvent.isComposing || void 0 !== compositionValue) setCompositionValue(event.target.value);
570
+ else {
571
+ captureSelection(event.target);
572
+ setInputValue(event.target.value);
573
+ }
574
+ onChange?.(event);
575
+ }
576
+ },
577
+ onCompositionEnd: (event)=>{
578
+ setCompositionValue(void 0);
579
+ if (!(disabled || readOnly)) {
580
+ captureSelection(event.currentTarget);
581
+ setInputValue(event.currentTarget.value);
582
+ }
583
+ props.onCompositionEnd?.(event);
584
+ },
585
+ onCompositionStart: (event)=>{
586
+ setCompositionValue(event.currentTarget.value);
587
+ props.onCompositionStart?.(event);
469
588
  },
470
589
  placeholder: placeholder,
471
590
  readOnly: readOnly,
@@ -473,7 +592,7 @@ PhoneInput.Input = function({ className, onChange, placeholder = "Phone number",
473
592
  required: required,
474
593
  size: size,
475
594
  type: "tel",
476
- value: inputValue
595
+ value: compositionValue ?? inputValue
477
596
  });
478
597
  };
479
598
  PhoneInput.CountryPositioner = function({ children, ...props }) {
@@ -549,13 +668,16 @@ PhoneInput.ItemText = PhoneInput.CountryItemText;
549
668
  PhoneInput.ItemMeta = PhoneInput.CountryItemMeta;
550
669
  PhoneInput.ItemIndicator = PhoneInput.CountryItemIndicator;
551
670
  PhoneInput.StatusText = function({ status, showIcon, children, ...props }) {
552
- const { size, validateStatus, statusTextId, registerDescription } = usePhoneInputContext();
553
- const id = props.id ?? statusTextId;
671
+ const messageId = useId();
672
+ const { size, validateStatus, registerDescription, errorDescriptions } = usePhoneInputContext();
673
+ const id = props.id ?? messageId;
674
+ const resolvedStatus = status ?? validateStatus;
554
675
  useRegisterDescription(id, registerDescription);
676
+ useRegisterDescription(id, errorDescriptions.registerDescription, "error" === resolvedStatus);
555
677
  return /*#__PURE__*/ jsx(StatusText, {
556
- showIcon: showIcon,
678
+ showIcon: "default" === resolvedStatus ? showIcon : true,
557
679
  size: size,
558
- status: status ?? validateStatus,
680
+ status: resolvedStatus,
559
681
  ...props,
560
682
  id: id,
561
683
  children: children
@@ -647,10 +769,23 @@ function getCountryItem(countries, country) {
647
769
  name: country
648
770
  };
649
771
  }
650
- function assignRef(ref, value) {
651
- if (!ref) return;
652
- if ("function" == typeof ref) return void ref(value);
653
- ref.current = value;
772
+ function getSeparatorDeletionRange(value, caret, inputType) {
773
+ const backward = "deleteContentBackward" === inputType;
774
+ const forward = "deleteContentForward" === inputType;
775
+ if (!(backward || forward) || phoneDigit.test(value[backward ? caret - 1 : caret] ?? "")) return;
776
+ let start = caret;
777
+ let end = caret;
778
+ if (backward) {
779
+ while(start > 0 && !phoneDigit.test(value[start - 1] ?? ""))start -= 1;
780
+ start = Math.max(0, start - 1);
781
+ } else {
782
+ while(end < value.length && !phoneDigit.test(value[end] ?? ""))end += 1;
783
+ end = Math.min(value.length, end + 1);
784
+ }
785
+ return start === end ? void 0 : [
786
+ start,
787
+ end
788
+ ];
654
789
  }
655
790
  function getPhoneCountryCallingCode(country) {
656
791
  const countryCode = "string" == typeof country ? country : country.value;
@@ -1,9 +1,12 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { connect, machine } from "@zag-js/popover";
3
- import { Portal, mergeProps, normalizeProps, useMachine } from "@zag-js/react";
4
+ import { mergeProps, normalizeProps, useMachine } from "@zag-js/react";
4
5
  import { createContext, useContext, useId, useLayoutEffect, useState } from "react";
6
+ import { createPortal } from "react-dom";
5
7
  import { ActionIcon } from "../atoms/action-icon.js";
6
8
  import { Button } from "../atoms/button.js";
9
+ import { OverlayContainerProvider, OverlayPortal } from "../internal/overlay-portal.js";
7
10
  import { tv } from "../utils.js";
8
11
  const popoverVariants = tv({
9
12
  slots: {
@@ -14,16 +17,20 @@ const popoverVariants = tv({
14
17
  "data-[state=open]:rotate-180"
15
18
  ],
16
19
  positioner: [
17
- "absolute"
20
+ "absolute",
21
+ "popup-layer"
18
22
  ],
19
23
  content: [
20
24
  "bg-popover-bg",
21
25
  "text-popover-fg",
22
26
  "rounded-popover",
23
27
  "outline-hidden",
24
- "z-50",
25
- "relative"
28
+ "popup-layer",
29
+ "popover-viewport",
30
+ "relative flex flex-col"
26
31
  ],
32
+ scrollViewport: "popover-scroll-viewport",
33
+ chrome: "contents",
27
34
  arrow: "",
28
35
  arrowTip: "",
29
36
  title: [
@@ -36,7 +43,7 @@ const popoverVariants = tv({
36
43
  "leading-normal"
37
44
  ],
38
45
  closeTrigger: [
39
- "absolute end-2 top-2"
46
+ "absolute end-popover-close top-popover-close"
40
47
  ]
41
48
  },
42
49
  variants: {
@@ -53,15 +60,15 @@ const popoverVariants = tv({
53
60
  },
54
61
  size: {
55
62
  sm: {
56
- content: "p-popover-sm text-sm",
63
+ content: "p-popover-sm text-popover-body-sm",
57
64
  title: "text-popover-title-sm"
58
65
  },
59
66
  md: {
60
- content: "p-popover-md",
67
+ content: "p-popover-md text-popover-body-md",
61
68
  title: "text-popover-title-md"
62
69
  },
63
70
  lg: {
64
- content: "p-popover-lg text-lg",
71
+ content: "p-popover-lg text-popover-body-lg",
65
72
  title: "text-popover-title-lg"
66
73
  }
67
74
  }
@@ -73,6 +80,7 @@ const popoverVariants = tv({
73
80
  }
74
81
  });
75
82
  const PopoverContext = /*#__PURE__*/ createContext(null);
83
+ const PopoverChromeContext = /*#__PURE__*/ createContext(null);
76
84
  function usePopoverContext() {
77
85
  const context = useContext(PopoverContext);
78
86
  if (!context) throw new Error("Popover components must be used within Popover.Root");
@@ -184,12 +192,13 @@ Popover.Positioner = function({ children, className, forceMount = false, ref, ..
184
192
  ref: ref,
185
193
  children: children
186
194
  });
187
- return api.portalled ? /*#__PURE__*/ jsx(Portal, {
195
+ return api.portalled ? /*#__PURE__*/ jsx(OverlayPortal, {
188
196
  children: positionerNode
189
197
  }) : positionerNode;
190
198
  };
191
199
  Popover.Content = function({ children, className, ref, ...props }) {
192
200
  const { api, descriptionId, placement, styles, titleId } = usePopoverContext();
201
+ const [chromeContainer, setChromeContainer] = useState(null);
193
202
  const machineContentProps = api.getContentProps();
194
203
  const contentProps = mergeProps(props, machineContentProps);
195
204
  const fallbackTitleId = void 0 === titleId ? machineContentProps["aria-labelledby"] : titleId ?? void 0;
@@ -197,7 +206,7 @@ Popover.Content = function({ children, className, ref, ...props }) {
197
206
  contentProps["aria-describedby"] = props["aria-describedby"] ?? (void 0 === descriptionId ? machineContentProps["aria-describedby"] : descriptionId ?? void 0);
198
207
  const contentPlacement = contentProps["data-placement"];
199
208
  const contentSide = "string" == typeof contentPlacement ? contentPlacement.split("-")[0] : placement.split("-")[0];
200
- return /*#__PURE__*/ jsx("div", {
209
+ return /*#__PURE__*/ jsxs("div", {
201
210
  ...contentProps,
202
211
  className: styles.content({
203
212
  className
@@ -205,13 +214,29 @@ Popover.Content = function({ children, className, ref, ...props }) {
205
214
  "data-side": contentSide,
206
215
  "data-state": api.open ? "open" : "closed",
207
216
  ref: ref,
208
- children: children
217
+ children: [
218
+ /*#__PURE__*/ jsx(OverlayContainerProvider, {
219
+ container: (true === contentProps["aria-modal"] || "true" === contentProps["aria-modal"]) && api.open ? chromeContainer : null,
220
+ children: /*#__PURE__*/ jsx(PopoverChromeContext.Provider, {
221
+ value: chromeContainer,
222
+ children: /*#__PURE__*/ jsx("div", {
223
+ className: styles.scrollViewport(),
224
+ children: children
225
+ })
226
+ })
227
+ }),
228
+ /*#__PURE__*/ jsx("div", {
229
+ className: styles.chrome(),
230
+ ref: setChromeContainer
231
+ })
232
+ ]
209
233
  });
210
234
  };
211
235
  Popover.Arrow = function({ children, className, ref, ...props }) {
212
236
  const { api, styles } = usePopoverContext();
237
+ const chromeContainer = useContext(PopoverChromeContext);
213
238
  const arrowProps = mergeProps(props, api.getArrowProps());
214
- return /*#__PURE__*/ jsx("div", {
239
+ const arrow = /*#__PURE__*/ jsx("div", {
215
240
  ...arrowProps,
216
241
  className: styles.arrow({
217
242
  className
@@ -219,6 +244,7 @@ Popover.Arrow = function({ children, className, ref, ...props }) {
219
244
  ref: ref,
220
245
  children: children ?? /*#__PURE__*/ jsx(Popover.ArrowTip, {})
221
246
  });
247
+ return chromeContainer ? /*#__PURE__*/ createPortal(arrow, chromeContainer) : arrow;
222
248
  };
223
249
  Popover.ArrowTip = function({ className, ref, ...props }) {
224
250
  const { api, styles } = usePopoverContext();
@@ -271,38 +297,39 @@ Popover.Description = function({ className, ref, ...props }) {
271
297
  };
272
298
  Popover.CloseTrigger = function({ children, className, icon, onClick, ref, size = "current", theme = "unstyled", type = "button", ...props }) {
273
299
  const { api, styles } = usePopoverContext();
300
+ const chromeContainer = useContext(PopoverChromeContext);
274
301
  const { onClick: onMachineClick, ...machineCloseTriggerProps } = api.getCloseTriggerProps();
275
302
  const buttonProps = mergeProps(props, machineCloseTriggerProps);
276
303
  const handleClick = (event)=>{
277
304
  onClick?.(event);
278
305
  if (!event.defaultPrevented) onMachineClick?.(event);
279
306
  };
280
- if (!children) return /*#__PURE__*/ jsx(ActionIcon, {
307
+ const closeTrigger = children ? /*#__PURE__*/ jsx(Button, {
281
308
  ...buttonProps,
282
- "aria-label": "Close popover",
283
309
  className: styles.closeTrigger({
284
310
  className
285
311
  }),
286
- icon: icon ?? "token-icon-close",
312
+ icon: icon,
287
313
  onClick: handleClick,
288
314
  ref: ref,
289
- size: "md",
290
- tone: "neutral",
291
- type: type
292
- });
293
- return /*#__PURE__*/ jsx(Button, {
315
+ size: size,
316
+ theme: theme,
317
+ type: type,
318
+ children: children
319
+ }) : /*#__PURE__*/ jsx(ActionIcon, {
294
320
  ...buttonProps,
321
+ "aria-label": props["aria-label"] ?? "Close popover",
295
322
  className: styles.closeTrigger({
296
323
  className
297
324
  }),
298
- icon: icon,
325
+ icon: icon ?? "token-icon-close",
299
326
  onClick: handleClick,
300
327
  ref: ref,
301
- size: size,
302
- theme: theme,
303
- type: type,
304
- children: children
328
+ size: "current" === size ? "md" : size,
329
+ tone: "neutral",
330
+ type: type
305
331
  });
332
+ return chromeContainer ? /*#__PURE__*/ createPortal(closeTrigger, chromeContainer) : closeTrigger;
306
333
  };
307
334
  Popover.Context = function({ children }) {
308
335
  const { api } = usePopoverContext();
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
3
  import { Badge } from "../atoms/badge.js";
3
4
  import { Skeleton } from "../atoms/skeleton.js";