@wordpress/components 23.3.5 → 23.5.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 (777) hide show
  1. package/CHANGELOG.md +35 -5
  2. package/build/alignment-matrix-control/utils.js +4 -4
  3. package/build/alignment-matrix-control/utils.js.map +1 -1
  4. package/build/angle-picker-control/angle-circle.js +37 -29
  5. package/build/angle-picker-control/angle-circle.js.map +1 -1
  6. package/build/angle-picker-control/index.js +44 -9
  7. package/build/angle-picker-control/index.js.map +1 -1
  8. package/build/angle-picker-control/styles/angle-picker-control-styles.js +13 -13
  9. package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
  10. package/build/angle-picker-control/types.js.map +1 -0
  11. package/build/autocomplete/autocompleter-ui.js +41 -17
  12. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  13. package/build/autocomplete/autocompleter-ui.native.js +1 -0
  14. package/build/autocomplete/autocompleter-ui.native.js.map +1 -1
  15. package/build/autocomplete/index.js +31 -33
  16. package/build/autocomplete/index.js.map +1 -1
  17. package/build/base-control/hooks.js +1 -1
  18. package/build/base-control/hooks.js.map +1 -1
  19. package/build/border-box-control/utils.js +1 -1
  20. package/build/border-box-control/utils.js.map +1 -1
  21. package/build/box-control/all-input-control.js +2 -2
  22. package/build/box-control/all-input-control.js.map +1 -1
  23. package/build/box-control/axial-input-controls.js +1 -1
  24. package/build/box-control/axial-input-controls.js.map +1 -1
  25. package/build/box-control/icon.js.map +1 -1
  26. package/build/box-control/index.js +32 -3
  27. package/build/box-control/index.js.map +1 -1
  28. package/build/box-control/input-controls.js +5 -5
  29. package/build/box-control/input-controls.js.map +1 -1
  30. package/build/box-control/linked-button.js.map +1 -1
  31. package/build/box-control/styles/box-control-icon-styles.js +28 -28
  32. package/build/box-control/styles/box-control-icon-styles.js.map +1 -1
  33. package/build/box-control/styles/box-control-styles.js +23 -23
  34. package/build/box-control/styles/box-control-styles.js.map +1 -1
  35. package/build/box-control/styles/box-control-visualizer-styles.js +19 -19
  36. package/build/box-control/styles/box-control-visualizer-styles.js.map +1 -1
  37. package/build/box-control/types.js +6 -0
  38. package/build/box-control/types.js.map +1 -0
  39. package/build/box-control/unit-control.js.map +1 -1
  40. package/build/box-control/utils.js +23 -23
  41. package/build/box-control/utils.js.map +1 -1
  42. package/build/circular-option-picker/index.js +63 -14
  43. package/build/circular-option-picker/index.js.map +1 -1
  44. package/build/circular-option-picker/types.js +6 -0
  45. package/build/circular-option-picker/types.js.map +1 -0
  46. package/build/color-palette/index.js +8 -3
  47. package/build/color-palette/index.js.map +1 -1
  48. package/build/combobox-control/index.js +68 -12
  49. package/build/combobox-control/index.js.map +1 -1
  50. package/build/combobox-control/styles.js +2 -2
  51. package/build/combobox-control/styles.js.map +1 -1
  52. package/build/combobox-control/types.js +6 -0
  53. package/build/combobox-control/types.js.map +1 -0
  54. package/build/custom-gradient-picker/index.js +0 -1
  55. package/build/custom-gradient-picker/index.js.map +1 -1
  56. package/build/date-time/time/index.js +1 -1
  57. package/build/date-time/time/index.js.map +1 -1
  58. package/build/date-time/utils.js +1 -1
  59. package/build/date-time/utils.js.map +1 -1
  60. package/build/draggable/index.js +2 -2
  61. package/build/draggable/index.js.map +1 -1
  62. package/build/focal-point-picker/utils.js +3 -3
  63. package/build/focal-point-picker/utils.js.map +1 -1
  64. package/build/font-size-picker/utils.js +2 -2
  65. package/build/font-size-picker/utils.js.map +1 -1
  66. package/build/gradient-picker/index.js +9 -4
  67. package/build/gradient-picker/index.js.map +1 -1
  68. package/build/higher-order/with-constrained-tabbing/index.js +9 -0
  69. package/build/higher-order/with-constrained-tabbing/index.js.map +1 -1
  70. package/build/input-control/reducer/reducer.js +5 -5
  71. package/build/input-control/reducer/reducer.js.map +1 -1
  72. package/build/input-control/utils.js +1 -1
  73. package/build/input-control/utils.js.map +1 -1
  74. package/build/menu-items-choice/index.js +40 -3
  75. package/build/menu-items-choice/index.js.map +1 -1
  76. package/build/menu-items-choice/types.js +6 -0
  77. package/build/menu-items-choice/types.js.map +1 -0
  78. package/build/mobile/global-styles-context/utils.native.js +2 -1
  79. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  80. package/build/modal/index.js +41 -3
  81. package/build/modal/index.js.map +1 -1
  82. package/build/palette-edit/index.js +4 -1
  83. package/build/palette-edit/index.js.map +1 -1
  84. package/build/panel/header.js +9 -0
  85. package/build/panel/header.js.map +1 -1
  86. package/build/panel/index.js +21 -3
  87. package/build/panel/index.js.map +1 -1
  88. package/build/panel/row.js +10 -4
  89. package/build/panel/row.js.map +1 -1
  90. package/build/panel/types.js +6 -0
  91. package/build/panel/types.js.map +1 -0
  92. package/build/popover/index.js +15 -3
  93. package/build/popover/index.js.map +1 -1
  94. package/build/popover/overlay-middlewares.js +46 -0
  95. package/build/popover/overlay-middlewares.js.map +1 -0
  96. package/build/popover/utils.js +45 -6
  97. package/build/popover/utils.js.map +1 -1
  98. package/build/query-controls/terms.js +1 -1
  99. package/build/query-controls/terms.js.map +1 -1
  100. package/build/range-control/utils.js +4 -4
  101. package/build/range-control/utils.js.map +1 -1
  102. package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +12 -12
  103. package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
  104. package/build/resizable-box/resize-tooltip/utils.js +14 -14
  105. package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
  106. package/build/snackbar/index.js +2 -2
  107. package/build/snackbar/index.js.map +1 -1
  108. package/build/toolbar/toolbar/index.js +25 -14
  109. package/build/toolbar/toolbar/index.js.map +1 -1
  110. package/build/toolbar/toolbar/toolbar-container.js +5 -4
  111. package/build/toolbar/toolbar/toolbar-container.js.map +1 -1
  112. package/build/toolbar/toolbar/types.js +6 -0
  113. package/build/toolbar/toolbar/types.js.map +1 -0
  114. package/build/toolbar/toolbar-button/index.js +2 -0
  115. package/build/toolbar/toolbar-button/index.js.map +1 -1
  116. package/build/toolbar/toolbar-button/toolbar-button-container.js +1 -0
  117. package/build/toolbar/toolbar-button/toolbar-button-container.js.map +1 -1
  118. package/build/toolbar/toolbar-context/index.js +2 -0
  119. package/build/toolbar/toolbar-context/index.js.map +1 -1
  120. package/build/toolbar/toolbar-dropdown-menu/index.js +2 -0
  121. package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -1
  122. package/build/toolbar/toolbar-group/index.js +2 -0
  123. package/build/toolbar/toolbar-group/index.js.map +1 -1
  124. package/build/toolbar/toolbar-group/toolbar-group-collapsed.js +2 -0
  125. package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -1
  126. package/build/toolbar/toolbar-group/toolbar-group-container.js +1 -0
  127. package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -1
  128. package/build/toolbar/toolbar-item/index.js +2 -0
  129. package/build/toolbar/toolbar-item/index.js.map +1 -1
  130. package/build/tools-panel/context.js +2 -0
  131. package/build/tools-panel/context.js.map +1 -1
  132. package/build/tools-panel/tools-panel/component.js +61 -5
  133. package/build/tools-panel/tools-panel/component.js.map +1 -1
  134. package/build/tools-panel/tools-panel/hook.js +22 -14
  135. package/build/tools-panel/tools-panel/hook.js.map +1 -1
  136. package/build/tools-panel/tools-panel-header/component.js +2 -1
  137. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  138. package/build/tools-panel/tools-panel-header/hook.js +2 -0
  139. package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
  140. package/build/tools-panel/tools-panel-item/component.js +5 -4
  141. package/build/tools-panel/tools-panel-item/component.js.map +1 -1
  142. package/build/tools-panel/tools-panel-item/hook.js +18 -4
  143. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  144. package/build/tree-grid/cell.js +15 -4
  145. package/build/tree-grid/cell.js.map +1 -1
  146. package/build/tree-grid/index.js +81 -19
  147. package/build/tree-grid/index.js.map +1 -1
  148. package/build/tree-grid/item.js +14 -3
  149. package/build/tree-grid/item.js.map +1 -1
  150. package/build/tree-grid/roving-tab-index-context.js +1 -1
  151. package/build/tree-grid/roving-tab-index-context.js.map +1 -1
  152. package/build/tree-grid/roving-tab-index-item.js +13 -6
  153. package/build/tree-grid/roving-tab-index-item.js.map +1 -1
  154. package/build/tree-grid/roving-tab-index.js +0 -3
  155. package/build/tree-grid/roving-tab-index.js.map +1 -1
  156. package/build/tree-grid/row.js +20 -18
  157. package/build/tree-grid/row.js.map +1 -1
  158. package/build/tree-grid/types.js +6 -0
  159. package/build/tree-grid/types.js.map +1 -0
  160. package/build/ui/context/context-connect.js +7 -7
  161. package/build/ui/context/context-connect.js.map +1 -1
  162. package/build/ui/context/context-system-provider.js +8 -4
  163. package/build/ui/context/context-system-provider.js.map +1 -1
  164. package/build/ui/context/get-styled-class-name-from-key.js +1 -1
  165. package/build/ui/context/get-styled-class-name-from-key.js.map +1 -1
  166. package/build/ui/utils/get-valid-children.js +1 -1
  167. package/build/ui/utils/get-valid-children.js.map +1 -1
  168. package/build/ui/utils/space.js +1 -1
  169. package/build/ui/utils/space.js.map +1 -1
  170. package/build/unit-control/index.js +2 -2
  171. package/build/unit-control/index.js.map +1 -1
  172. package/build/unit-control/utils.js +20 -20
  173. package/build/unit-control/utils.js.map +1 -1
  174. package/build/utils/events.js +4 -4
  175. package/build/utils/events.js.map +1 -1
  176. package/build/utils/hooks/use-controlled-state.js +2 -2
  177. package/build/utils/hooks/use-controlled-state.js.map +1 -1
  178. package/build/utils/hooks/use-controlled-value.js +4 -4
  179. package/build/utils/hooks/use-controlled-value.js.map +1 -1
  180. package/build/utils/hooks/use-latest-ref.js +1 -1
  181. package/build/utils/hooks/use-latest-ref.js.map +1 -1
  182. package/build/utils/unit-values.js +3 -3
  183. package/build/utils/unit-values.js.map +1 -1
  184. package/build-module/alignment-matrix-control/utils.js +4 -4
  185. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  186. package/build-module/angle-picker-control/angle-circle.js +37 -29
  187. package/build-module/angle-picker-control/angle-circle.js.map +1 -1
  188. package/build-module/angle-picker-control/index.js +42 -8
  189. package/build-module/angle-picker-control/index.js.map +1 -1
  190. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +13 -13
  191. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
  192. package/build-module/autocomplete/autocompleter-ui.js +40 -19
  193. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  194. package/build-module/autocomplete/autocompleter-ui.native.js +1 -0
  195. package/build-module/autocomplete/autocompleter-ui.native.js.map +1 -1
  196. package/build-module/autocomplete/index.js +30 -32
  197. package/build-module/autocomplete/index.js.map +1 -1
  198. package/build-module/base-control/hooks.js +1 -1
  199. package/build-module/base-control/hooks.js.map +1 -1
  200. package/build-module/border-box-control/utils.js +1 -1
  201. package/build-module/border-box-control/utils.js.map +1 -1
  202. package/build-module/box-control/all-input-control.js +2 -2
  203. package/build-module/box-control/all-input-control.js.map +1 -1
  204. package/build-module/box-control/axial-input-controls.js +1 -1
  205. package/build-module/box-control/axial-input-controls.js.map +1 -1
  206. package/build-module/box-control/icon.js.map +1 -1
  207. package/build-module/box-control/index.js +31 -3
  208. package/build-module/box-control/index.js.map +1 -1
  209. package/build-module/box-control/input-controls.js +5 -5
  210. package/build-module/box-control/input-controls.js.map +1 -1
  211. package/build-module/box-control/linked-button.js.map +1 -1
  212. package/build-module/box-control/styles/box-control-icon-styles.js +28 -28
  213. package/build-module/box-control/styles/box-control-icon-styles.js.map +1 -1
  214. package/build-module/box-control/styles/box-control-styles.js +23 -23
  215. package/build-module/box-control/styles/box-control-styles.js.map +1 -1
  216. package/build-module/box-control/styles/box-control-visualizer-styles.js +19 -19
  217. package/build-module/box-control/styles/box-control-visualizer-styles.js.map +1 -1
  218. package/build-module/box-control/types.js +2 -0
  219. package/build-module/box-control/unit-control.js.map +1 -1
  220. package/build-module/box-control/utils.js +23 -23
  221. package/build-module/box-control/utils.js.map +1 -1
  222. package/build-module/circular-option-picker/index.js +59 -16
  223. package/build-module/circular-option-picker/index.js.map +1 -1
  224. package/build-module/circular-option-picker/types.js +2 -0
  225. package/build-module/color-palette/index.js +8 -3
  226. package/build-module/color-palette/index.js.map +1 -1
  227. package/build-module/combobox-control/index.js +68 -12
  228. package/build-module/combobox-control/index.js.map +1 -1
  229. package/build-module/combobox-control/styles.js +2 -2
  230. package/build-module/combobox-control/styles.js.map +1 -1
  231. package/build-module/combobox-control/types.js +2 -0
  232. package/build-module/custom-gradient-picker/index.js +0 -1
  233. package/build-module/custom-gradient-picker/index.js.map +1 -1
  234. package/build-module/date-time/time/index.js +1 -1
  235. package/build-module/date-time/time/index.js.map +1 -1
  236. package/build-module/date-time/utils.js +1 -1
  237. package/build-module/date-time/utils.js.map +1 -1
  238. package/build-module/draggable/index.js +2 -2
  239. package/build-module/draggable/index.js.map +1 -1
  240. package/build-module/focal-point-picker/utils.js +3 -3
  241. package/build-module/focal-point-picker/utils.js.map +1 -1
  242. package/build-module/font-size-picker/utils.js +2 -2
  243. package/build-module/font-size-picker/utils.js.map +1 -1
  244. package/build-module/gradient-picker/index.js +9 -4
  245. package/build-module/gradient-picker/index.js.map +1 -1
  246. package/build-module/higher-order/with-constrained-tabbing/index.js +9 -0
  247. package/build-module/higher-order/with-constrained-tabbing/index.js.map +1 -1
  248. package/build-module/input-control/reducer/reducer.js +5 -5
  249. package/build-module/input-control/reducer/reducer.js.map +1 -1
  250. package/build-module/input-control/utils.js +1 -1
  251. package/build-module/input-control/utils.js.map +1 -1
  252. package/build-module/menu-items-choice/index.js +40 -4
  253. package/build-module/menu-items-choice/index.js.map +1 -1
  254. package/build-module/menu-items-choice/types.js +2 -0
  255. package/build-module/menu-items-choice/types.js.map +1 -0
  256. package/build-module/mobile/global-styles-context/utils.native.js +2 -1
  257. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  258. package/build-module/modal/index.js +41 -4
  259. package/build-module/modal/index.js.map +1 -1
  260. package/build-module/palette-edit/index.js +4 -1
  261. package/build-module/palette-edit/index.js.map +1 -1
  262. package/build-module/panel/header.js +9 -0
  263. package/build-module/panel/header.js.map +1 -1
  264. package/build-module/panel/index.js +20 -2
  265. package/build-module/panel/index.js.map +1 -1
  266. package/build-module/panel/row.js +9 -3
  267. package/build-module/panel/row.js.map +1 -1
  268. package/build-module/panel/types.js +2 -0
  269. package/build-module/panel/types.js.map +1 -0
  270. package/build-module/popover/index.js +14 -4
  271. package/build-module/popover/index.js.map +1 -1
  272. package/build-module/popover/overlay-middlewares.js +38 -0
  273. package/build-module/popover/overlay-middlewares.js.map +1 -0
  274. package/build-module/popover/utils.js +41 -5
  275. package/build-module/popover/utils.js.map +1 -1
  276. package/build-module/query-controls/terms.js +1 -1
  277. package/build-module/query-controls/terms.js.map +1 -1
  278. package/build-module/range-control/utils.js +4 -4
  279. package/build-module/range-control/utils.js.map +1 -1
  280. package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +12 -12
  281. package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
  282. package/build-module/resizable-box/resize-tooltip/utils.js +14 -14
  283. package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
  284. package/build-module/snackbar/index.js +2 -2
  285. package/build-module/snackbar/index.js.map +1 -1
  286. package/build-module/toolbar/toolbar/index.js +25 -13
  287. package/build-module/toolbar/toolbar/index.js.map +1 -1
  288. package/build-module/toolbar/toolbar/toolbar-container.js +4 -3
  289. package/build-module/toolbar/toolbar/toolbar-container.js.map +1 -1
  290. package/build-module/toolbar/toolbar/types.js +2 -0
  291. package/build-module/toolbar/toolbar/types.js.map +1 -0
  292. package/build-module/toolbar/toolbar-button/index.js +1 -0
  293. package/build-module/toolbar/toolbar-button/index.js.map +1 -1
  294. package/build-module/toolbar/toolbar-button/toolbar-button-container.js +1 -0
  295. package/build-module/toolbar/toolbar-button/toolbar-button-container.js.map +1 -1
  296. package/build-module/toolbar/toolbar-context/index.js +2 -0
  297. package/build-module/toolbar/toolbar-context/index.js.map +1 -1
  298. package/build-module/toolbar/toolbar-dropdown-menu/index.js +1 -0
  299. package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -1
  300. package/build-module/toolbar/toolbar-group/index.js +1 -0
  301. package/build-module/toolbar/toolbar-group/index.js.map +1 -1
  302. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js +1 -0
  303. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -1
  304. package/build-module/toolbar/toolbar-group/toolbar-group-container.js +1 -0
  305. package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -1
  306. package/build-module/toolbar/toolbar-item/index.js +1 -0
  307. package/build-module/toolbar/toolbar-item/index.js.map +1 -1
  308. package/build-module/tools-panel/context.js +2 -0
  309. package/build-module/tools-panel/context.js.map +1 -1
  310. package/build-module/tools-panel/tools-panel/component.js +59 -4
  311. package/build-module/tools-panel/tools-panel/component.js.map +1 -1
  312. package/build-module/tools-panel/tools-panel/hook.js +22 -14
  313. package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
  314. package/build-module/tools-panel/tools-panel-header/component.js +2 -1
  315. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  316. package/build-module/tools-panel/tools-panel-header/hook.js +2 -0
  317. package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
  318. package/build-module/tools-panel/tools-panel-item/component.js +3 -3
  319. package/build-module/tools-panel/tools-panel-item/component.js.map +1 -1
  320. package/build-module/tools-panel/tools-panel-item/hook.js +19 -4
  321. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  322. package/build-module/tree-grid/cell.js +16 -4
  323. package/build-module/tree-grid/cell.js.map +1 -1
  324. package/build-module/tree-grid/index.js +81 -21
  325. package/build-module/tree-grid/index.js.map +1 -1
  326. package/build-module/tree-grid/item.js +14 -2
  327. package/build-module/tree-grid/item.js.map +1 -1
  328. package/build-module/tree-grid/roving-tab-index-context.js +1 -1
  329. package/build-module/tree-grid/roving-tab-index-context.js.map +1 -1
  330. package/build-module/tree-grid/roving-tab-index-item.js +11 -4
  331. package/build-module/tree-grid/roving-tab-index-item.js.map +1 -1
  332. package/build-module/tree-grid/roving-tab-index.js +0 -3
  333. package/build-module/tree-grid/roving-tab-index.js.map +1 -1
  334. package/build-module/tree-grid/row.js +22 -17
  335. package/build-module/tree-grid/row.js.map +1 -1
  336. package/build-module/tree-grid/types.js +2 -0
  337. package/build-module/tree-grid/types.js.map +1 -0
  338. package/build-module/ui/context/context-connect.js +7 -7
  339. package/build-module/ui/context/context-connect.js.map +1 -1
  340. package/build-module/ui/context/context-system-provider.js +7 -4
  341. package/build-module/ui/context/context-system-provider.js.map +1 -1
  342. package/build-module/ui/context/get-styled-class-name-from-key.js +1 -1
  343. package/build-module/ui/context/get-styled-class-name-from-key.js.map +1 -1
  344. package/build-module/ui/utils/get-valid-children.js +1 -1
  345. package/build-module/ui/utils/get-valid-children.js.map +1 -1
  346. package/build-module/ui/utils/space.js +1 -1
  347. package/build-module/ui/utils/space.js.map +1 -1
  348. package/build-module/unit-control/index.js +2 -2
  349. package/build-module/unit-control/index.js.map +1 -1
  350. package/build-module/unit-control/utils.js +20 -20
  351. package/build-module/unit-control/utils.js.map +1 -1
  352. package/build-module/utils/events.js +4 -4
  353. package/build-module/utils/events.js.map +1 -1
  354. package/build-module/utils/hooks/use-controlled-state.js +2 -2
  355. package/build-module/utils/hooks/use-controlled-state.js.map +1 -1
  356. package/build-module/utils/hooks/use-controlled-value.js +4 -4
  357. package/build-module/utils/hooks/use-controlled-value.js.map +1 -1
  358. package/build-module/utils/hooks/use-latest-ref.js +1 -1
  359. package/build-module/utils/hooks/use-latest-ref.js.map +1 -1
  360. package/build-module/utils/unit-values.js +3 -3
  361. package/build-module/utils/unit-values.js.map +1 -1
  362. package/build-style/style-rtl.css +5 -0
  363. package/build-style/style.css +5 -0
  364. package/build-types/alignment-matrix-control/utils.d.ts +4 -4
  365. package/build-types/angle-picker-control/angle-circle.d.ts +6 -0
  366. package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -0
  367. package/build-types/angle-picker-control/index.d.ts +29 -0
  368. package/build-types/angle-picker-control/index.d.ts.map +1 -0
  369. package/build-types/angle-picker-control/stories/index.d.ts +15 -0
  370. package/build-types/angle-picker-control/stories/index.d.ts.map +1 -0
  371. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +20 -0
  372. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +1 -0
  373. package/build-types/angle-picker-control/types.d.ts +26 -0
  374. package/build-types/angle-picker-control/types.d.ts.map +1 -0
  375. package/build-types/base-control/hooks.d.ts +1 -1
  376. package/build-types/border-box-control/border-box-control/component.d.ts +1 -1
  377. package/build-types/border-box-control/border-box-control/hook.d.ts +1 -1
  378. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +1 -1
  379. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -1
  380. package/build-types/border-box-control/stories/index.d.ts +1 -1
  381. package/build-types/border-box-control/test/index.d.ts.map +1 -0
  382. package/build-types/border-box-control/test/utils.d.ts +2 -0
  383. package/build-types/border-box-control/test/utils.d.ts.map +1 -0
  384. package/build-types/box-control/all-input-control.d.ts +4 -0
  385. package/build-types/box-control/all-input-control.d.ts.map +1 -0
  386. package/build-types/box-control/axial-input-controls.d.ts +4 -0
  387. package/build-types/box-control/axial-input-controls.d.ts.map +1 -0
  388. package/build-types/box-control/icon.d.ts +8 -0
  389. package/build-types/box-control/icon.d.ts.map +1 -0
  390. package/build-types/box-control/index.d.ts +31 -0
  391. package/build-types/box-control/index.d.ts.map +1 -0
  392. package/build-types/box-control/input-controls.d.ts +4 -0
  393. package/build-types/box-control/input-controls.d.ts.map +1 -0
  394. package/build-types/box-control/linked-button.d.ts +9 -0
  395. package/build-types/box-control/linked-button.d.ts.map +1 -0
  396. package/build-types/box-control/styles/box-control-icon-styles.d.ts +42 -0
  397. package/build-types/box-control/styles/box-control-icon-styles.d.ts.map +1 -0
  398. package/build-types/box-control/styles/box-control-styles.d.ts +42 -0
  399. package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -0
  400. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts +46 -0
  401. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts.map +1 -0
  402. package/build-types/box-control/test/index.d.ts +2 -0
  403. package/build-types/box-control/test/index.d.ts.map +1 -0
  404. package/build-types/box-control/types.d.ts +99 -0
  405. package/build-types/box-control/types.d.ts.map +1 -0
  406. package/build-types/box-control/unit-control.d.ts +4 -0
  407. package/build-types/box-control/unit-control.d.ts.map +1 -0
  408. package/build-types/box-control/utils.d.ts +84 -0
  409. package/build-types/box-control/utils.d.ts.map +1 -0
  410. package/build-types/circular-option-picker/index.d.ts +56 -7
  411. package/build-types/circular-option-picker/index.d.ts.map +1 -1
  412. package/build-types/circular-option-picker/stories/index.d.ts +14 -0
  413. package/build-types/circular-option-picker/stories/index.d.ts.map +1 -0
  414. package/build-types/circular-option-picker/types.d.ts +49 -0
  415. package/build-types/circular-option-picker/types.d.ts.map +1 -0
  416. package/build-types/color-palette/index.d.ts +3 -1
  417. package/build-types/color-palette/index.d.ts.map +1 -1
  418. package/build-types/color-palette/stories/index.d.ts +6 -2
  419. package/build-types/color-palette/stories/index.d.ts.map +1 -1
  420. package/build-types/color-palette/types.d.ts +8 -0
  421. package/build-types/color-palette/types.d.ts.map +1 -1
  422. package/build-types/combobox-control/index.d.ts +51 -0
  423. package/build-types/combobox-control/index.d.ts.map +1 -0
  424. package/build-types/combobox-control/stories/index.d.ts +18 -0
  425. package/build-types/combobox-control/stories/index.d.ts.map +1 -0
  426. package/build-types/combobox-control/styles.d.ts +8 -0
  427. package/build-types/combobox-control/styles.d.ts.map +1 -0
  428. package/build-types/combobox-control/test/index.d.ts +2 -0
  429. package/build-types/combobox-control/test/index.d.ts.map +1 -0
  430. package/build-types/combobox-control/types.d.ts +62 -0
  431. package/build-types/combobox-control/types.d.ts.map +1 -0
  432. package/build-types/date-time/utils.d.ts +1 -1
  433. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  434. package/build-types/focal-point-picker/utils.d.ts +3 -3
  435. package/build-types/font-size-picker/utils.d.ts +2 -2
  436. package/build-types/h-stack/stories/e2e/index.d.ts +9 -0
  437. package/build-types/h-stack/stories/e2e/index.d.ts.map +1 -0
  438. package/build-types/higher-order/with-constrained-tabbing/index.d.ts +10 -1
  439. package/build-types/higher-order/with-constrained-tabbing/index.d.ts.map +1 -1
  440. package/build-types/input-control/reducer/reducer.d.ts +3 -3
  441. package/build-types/input-control/utils.d.ts +1 -1
  442. package/build-types/menu-items-choice/index.d.ts +38 -0
  443. package/build-types/menu-items-choice/index.d.ts.map +1 -0
  444. package/build-types/menu-items-choice/stories/index.d.ts +12 -0
  445. package/build-types/menu-items-choice/stories/index.d.ts.map +1 -0
  446. package/build-types/menu-items-choice/types.d.ts +53 -0
  447. package/build-types/menu-items-choice/types.d.ts.map +1 -0
  448. package/build-types/modal/index.d.ts.map +1 -1
  449. package/build-types/modal/types.d.ts +2 -0
  450. package/build-types/modal/types.d.ts.map +1 -1
  451. package/build-types/panel/header.d.ts +13 -0
  452. package/build-types/panel/header.d.ts.map +1 -0
  453. package/build-types/panel/index.d.ts +21 -0
  454. package/build-types/panel/index.d.ts.map +1 -0
  455. package/build-types/panel/row.d.ts +12 -0
  456. package/build-types/panel/row.d.ts.map +1 -0
  457. package/build-types/panel/test/header.d.ts +2 -0
  458. package/build-types/panel/test/header.d.ts.map +1 -0
  459. package/build-types/panel/test/index.d.ts +2 -0
  460. package/build-types/{base-field → panel}/test/index.d.ts.map +1 -1
  461. package/build-types/panel/test/row.d.ts +2 -0
  462. package/build-types/panel/test/row.d.ts.map +1 -0
  463. package/build-types/panel/types.d.ts +38 -0
  464. package/build-types/panel/types.d.ts.map +1 -0
  465. package/build-types/popover/index.d.ts.map +1 -1
  466. package/build-types/popover/overlay-middlewares.d.ts +9 -0
  467. package/build-types/popover/overlay-middlewares.d.ts.map +1 -0
  468. package/build-types/popover/stories/index.d.ts.map +1 -1
  469. package/build-types/popover/types.d.ts +3 -2
  470. package/build-types/popover/types.d.ts.map +1 -1
  471. package/build-types/popover/utils.d.ts +12 -4
  472. package/build-types/popover/utils.d.ts.map +1 -1
  473. package/build-types/query-controls/terms.d.ts +1 -1
  474. package/build-types/range-control/utils.d.ts +4 -4
  475. package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts +5 -4
  476. package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts.map +1 -1
  477. package/build-types/resizable-box/resize-tooltip/utils.d.ts +6 -6
  478. package/build-types/tab-panel/stories/index.d.ts +1 -0
  479. package/build-types/tab-panel/stories/index.d.ts.map +1 -1
  480. package/build-types/toolbar/index.d.ts +7 -0
  481. package/build-types/toolbar/index.d.ts.map +1 -0
  482. package/build-types/toolbar/stories/index.d.ts +14 -0
  483. package/build-types/toolbar/stories/index.d.ts.map +1 -0
  484. package/build-types/toolbar/test/index.d.ts +2 -0
  485. package/build-types/toolbar/test/index.d.ts.map +1 -0
  486. package/build-types/toolbar/test/toolbar-group.d.ts +2 -0
  487. package/build-types/toolbar/test/toolbar-group.d.ts.map +1 -0
  488. package/build-types/toolbar/toolbar/index.d.ts +25 -0
  489. package/build-types/toolbar/toolbar/index.d.ts.map +1 -0
  490. package/build-types/toolbar/toolbar/toolbar-container.d.ts +5 -0
  491. package/build-types/toolbar/toolbar/toolbar-container.d.ts.map +1 -0
  492. package/build-types/toolbar/toolbar/types.d.ts +15 -0
  493. package/build-types/toolbar/toolbar/types.d.ts.map +1 -0
  494. package/build-types/toolbar/toolbar-button/index.d.ts +12 -0
  495. package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -0
  496. package/build-types/toolbar/toolbar-button/toolbar-button-container.d.ts +3 -0
  497. package/build-types/toolbar/toolbar-button/toolbar-button-container.d.ts.map +1 -0
  498. package/build-types/toolbar/toolbar-context/index.d.ts +3 -0
  499. package/build-types/toolbar/toolbar-context/index.d.ts.map +1 -0
  500. package/build-types/toolbar/toolbar-dropdown-menu/index.d.ts +3 -0
  501. package/build-types/toolbar/toolbar-dropdown-menu/index.d.ts.map +1 -0
  502. package/build-types/toolbar/toolbar-group/index.d.ts +39 -0
  503. package/build-types/toolbar/toolbar-group/index.d.ts.map +1 -0
  504. package/build-types/toolbar/toolbar-group/toolbar-group-collapsed.d.ts +7 -0
  505. package/build-types/toolbar/toolbar-group/toolbar-group-collapsed.d.ts.map +1 -0
  506. package/build-types/toolbar/toolbar-group/toolbar-group-container.d.ts +7 -0
  507. package/build-types/toolbar/toolbar-group/toolbar-group-container.d.ts.map +1 -0
  508. package/build-types/toolbar/toolbar-item/index.d.ts +7 -0
  509. package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -0
  510. package/build-types/tools-panel/context.d.ts.map +1 -1
  511. package/build-types/tools-panel/stories/index.d.ts +17 -0
  512. package/build-types/tools-panel/stories/index.d.ts.map +1 -0
  513. package/build-types/tools-panel/test/index.d.ts +2 -0
  514. package/build-types/tools-panel/test/index.d.ts.map +1 -0
  515. package/build-types/tools-panel/tools-panel/component.d.ts +54 -2
  516. package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
  517. package/build-types/tools-panel/tools-panel/hook.d.ts +5 -2
  518. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  519. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  520. package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -1
  521. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  522. package/build-types/tools-panel/tools-panel-item/component.d.ts +3 -2
  523. package/build-types/tools-panel/tools-panel-item/component.d.ts.map +1 -1
  524. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  525. package/build-types/tools-panel/types.d.ts +49 -20
  526. package/build-types/tools-panel/types.d.ts.map +1 -1
  527. package/build-types/tree-grid/cell.d.ts +13 -0
  528. package/build-types/tree-grid/cell.d.ts.map +1 -0
  529. package/build-types/tree-grid/index.d.ts +70 -0
  530. package/build-types/tree-grid/index.d.ts.map +1 -0
  531. package/build-types/tree-grid/item.d.ts +12 -0
  532. package/build-types/tree-grid/item.d.ts.map +1 -0
  533. package/build-types/tree-grid/roving-tab-index-context.d.ts +10 -0
  534. package/build-types/tree-grid/roving-tab-index-context.d.ts.map +1 -0
  535. package/build-types/tree-grid/roving-tab-index-item.d.ts +5 -0
  536. package/build-types/tree-grid/roving-tab-index-item.d.ts.map +1 -0
  537. package/build-types/tree-grid/roving-tab-index.d.ts +10 -0
  538. package/build-types/tree-grid/roving-tab-index.d.ts.map +1 -0
  539. package/build-types/tree-grid/row.d.ts +12 -0
  540. package/build-types/tree-grid/row.d.ts.map +1 -0
  541. package/build-types/tree-grid/stories/index.d.ts +13 -0
  542. package/build-types/tree-grid/stories/index.d.ts.map +1 -0
  543. package/build-types/tree-grid/test/cell.d.ts +2 -0
  544. package/build-types/tree-grid/test/cell.d.ts.map +1 -0
  545. package/build-types/tree-grid/test/index.d.ts +2 -0
  546. package/build-types/tree-grid/test/index.d.ts.map +1 -0
  547. package/build-types/tree-grid/test/roving-tab-index-item.d.ts +2 -0
  548. package/build-types/tree-grid/test/roving-tab-index-item.d.ts.map +1 -0
  549. package/build-types/tree-grid/test/roving-tab-index.d.ts +2 -0
  550. package/build-types/tree-grid/test/roving-tab-index.d.ts.map +1 -0
  551. package/build-types/tree-grid/test/row.d.ts +2 -0
  552. package/build-types/tree-grid/test/row.d.ts.map +1 -0
  553. package/build-types/tree-grid/types.d.ts +109 -0
  554. package/build-types/tree-grid/types.d.ts.map +1 -0
  555. package/build-types/ui/context/context-connect.d.ts +7 -7
  556. package/build-types/ui/context/context-system-provider.d.ts.map +1 -1
  557. package/build-types/ui/context/get-styled-class-name-from-key.d.ts +1 -1
  558. package/build-types/ui/utils/get-valid-children.d.ts +1 -1
  559. package/build-types/ui/utils/space.d.ts +1 -1
  560. package/build-types/unit-control/index.d.ts +1 -1
  561. package/build-types/unit-control/utils.d.ts +20 -20
  562. package/build-types/utils/events.d.ts +2 -2
  563. package/build-types/utils/hooks/use-controlled-state.d.ts +1 -1
  564. package/build-types/utils/hooks/use-controlled-state.d.ts.map +1 -1
  565. package/build-types/utils/hooks/use-controlled-value.d.ts +4 -4
  566. package/build-types/utils/hooks/use-latest-ref.d.ts +1 -1
  567. package/build-types/utils/unit-values.d.ts +3 -3
  568. package/build-types/v-stack/stories/e2e/index.d.ts +9 -0
  569. package/build-types/v-stack/stories/e2e/index.d.ts.map +1 -0
  570. package/package.json +21 -19
  571. package/src/alignment-matrix-control/utils.tsx +4 -4
  572. package/src/angle-picker-control/README.md +17 -14
  573. package/src/angle-picker-control/{angle-circle.js → angle-circle.tsx} +44 -12
  574. package/src/angle-picker-control/{index.js → index.tsx} +54 -10
  575. package/src/angle-picker-control/stories/index.tsx +57 -0
  576. package/src/angle-picker-control/styles/{angle-picker-control-styles.js → angle-picker-control-styles.tsx} +5 -1
  577. package/src/angle-picker-control/types.ts +29 -0
  578. package/src/autocomplete/autocompleter-ui.js +72 -34
  579. package/src/autocomplete/autocompleter-ui.native.js +1 -0
  580. package/src/autocomplete/index.js +36 -36
  581. package/src/base-control/hooks.ts +1 -1
  582. package/src/border-box-control/test/{index.js → index.tsx} +76 -102
  583. package/src/border-box-control/test/{utils.js → utils.ts} +20 -0
  584. package/src/border-box-control/utils.ts +1 -1
  585. package/src/box-control/README.md +17 -26
  586. package/src/box-control/{all-input-control.js → all-input-control.tsx} +10 -6
  587. package/src/box-control/{axial-input-controls.js → axial-input-controls.tsx} +29 -24
  588. package/src/box-control/{icon.js → icon.tsx} +9 -4
  589. package/src/box-control/{index.js → index.tsx} +43 -8
  590. package/src/box-control/{input-controls.js → input-controls.tsx} +26 -16
  591. package/src/box-control/{linked-button.js → linked-button.tsx} +4 -1
  592. package/src/box-control/styles/{box-control-icon-styles.js → box-control-icon-styles.ts} +1 -1
  593. package/src/box-control/styles/{box-control-styles.js → box-control-styles.ts} +10 -2
  594. package/src/box-control/styles/{box-control-visualizer-styles.js → box-control-visualizer-styles.ts} +6 -2
  595. package/src/box-control/test/{index.js → index.tsx} +12 -9
  596. package/src/box-control/types.ts +121 -0
  597. package/src/box-control/{unit-control.js → unit-control.tsx} +9 -2
  598. package/src/box-control/{utils.js → utils.ts} +47 -38
  599. package/src/button/test/index.tsx +38 -30
  600. package/src/circular-option-picker/README.md +141 -0
  601. package/src/circular-option-picker/{index.js → index.tsx} +74 -14
  602. package/src/circular-option-picker/stories/index.tsx +134 -0
  603. package/src/circular-option-picker/types.ts +69 -0
  604. package/src/color-palette/README.md +7 -0
  605. package/src/color-palette/index.tsx +6 -1
  606. package/src/color-palette/test/__snapshots__/index.tsx.snap +1 -1
  607. package/src/color-palette/types.ts +8 -0
  608. package/src/combobox-control/README.md +8 -15
  609. package/src/combobox-control/{index.js → index.tsx} +91 -19
  610. package/src/combobox-control/stories/index.tsx +114 -0
  611. package/src/combobox-control/styles.ts +4 -1
  612. package/src/combobox-control/test/{index.js → index.tsx} +9 -7
  613. package/src/combobox-control/types.ts +69 -0
  614. package/src/custom-gradient-picker/index.js +0 -1
  615. package/src/custom-select-control/stories/index.js +1 -1
  616. package/src/date-time/time/index.tsx +1 -1
  617. package/src/date-time/utils.ts +1 -1
  618. package/src/draggable/index.tsx +2 -2
  619. package/src/dropdown-menu/test/index.js +3 -11
  620. package/src/focal-point-picker/utils.ts +3 -3
  621. package/src/font-size-picker/utils.ts +2 -2
  622. package/src/gradient-picker/README.md +8 -0
  623. package/src/gradient-picker/index.js +6 -1
  624. package/src/h-stack/stories/e2e/index.tsx +36 -0
  625. package/src/higher-order/with-constrained-tabbing/index.tsx +30 -0
  626. package/src/input-control/reducer/reducer.ts +5 -5
  627. package/src/input-control/utils.ts +1 -1
  628. package/src/menu-items-choice/index.tsx +83 -0
  629. package/src/menu-items-choice/stories/index.tsx +79 -0
  630. package/src/menu-items-choice/types.ts +54 -0
  631. package/src/mobile/global-styles-context/utils.native.js +1 -0
  632. package/src/modal/index.tsx +45 -1
  633. package/src/modal/style.scss +8 -0
  634. package/src/modal/types.ts +2 -0
  635. package/src/palette-edit/index.js +4 -1
  636. package/src/panel/README.md +2 -2
  637. package/src/panel/header.tsx +20 -0
  638. package/src/panel/index.tsx +48 -0
  639. package/src/panel/row.tsx +37 -0
  640. package/src/panel/stories/index.js +22 -0
  641. package/src/panel/test/{header.js → header.tsx} +1 -1
  642. package/src/panel/test/{index.js → index.tsx} +6 -4
  643. package/src/panel/test/{row.js → row.tsx} +4 -2
  644. package/src/panel/types.ts +38 -0
  645. package/src/popover/README.md +4 -1
  646. package/src/popover/index.tsx +17 -1
  647. package/src/popover/overlay-middlewares.tsx +29 -0
  648. package/src/popover/stories/index.tsx +7 -1
  649. package/src/popover/test/index.tsx +29 -21
  650. package/src/popover/types.ts +4 -2
  651. package/src/popover/utils.ts +39 -3
  652. package/src/query-controls/terms.ts +1 -1
  653. package/src/range-control/utils.ts +4 -4
  654. package/src/resizable-box/resize-tooltip/utils.ts +14 -14
  655. package/src/snackbar/index.tsx +2 -2
  656. package/src/tab-panel/stories/index.tsx +41 -0
  657. package/src/tab-panel/test/index.tsx +794 -262
  658. package/src/toolbar/stories/{index.js → index.tsx} +39 -26
  659. package/src/toolbar/test/{toolbar-group.js → toolbar-group.tsx} +2 -2
  660. package/src/toolbar/toolbar/README.md +7 -2
  661. package/src/toolbar/toolbar/{index.js → index.tsx} +33 -12
  662. package/src/toolbar/toolbar/{toolbar-container.js → toolbar-container.tsx} +9 -2
  663. package/src/toolbar/toolbar/types.ts +15 -0
  664. package/src/toolbar/toolbar-button/index.js +2 -0
  665. package/src/toolbar/toolbar-button/toolbar-button-container.js +2 -0
  666. package/src/toolbar/toolbar-context/index.js +2 -0
  667. package/src/toolbar/toolbar-dropdown-menu/index.js +2 -0
  668. package/src/toolbar/toolbar-group/index.js +2 -0
  669. package/src/toolbar/toolbar-group/toolbar-group-collapsed.js +2 -0
  670. package/src/toolbar/toolbar-group/toolbar-group-container.js +2 -0
  671. package/src/toolbar/toolbar-item/index.js +2 -0
  672. package/src/tools-panel/context.ts +2 -0
  673. package/src/tools-panel/stories/{index.js → index.tsx} +196 -95
  674. package/src/tools-panel/test/{index.js → index.tsx} +177 -67
  675. package/src/tools-panel/tools-panel/README.md +12 -4
  676. package/src/tools-panel/tools-panel/component.tsx +57 -3
  677. package/src/tools-panel/tools-panel/hook.ts +34 -13
  678. package/src/tools-panel/tools-panel-header/README.md +7 -0
  679. package/src/tools-panel/tools-panel-header/component.tsx +2 -1
  680. package/src/tools-panel/tools-panel-header/hook.ts +6 -4
  681. package/src/tools-panel/tools-panel-item/README.md +6 -4
  682. package/src/tools-panel/tools-panel-item/component.tsx +4 -4
  683. package/src/tools-panel/tools-panel-item/hook.ts +22 -4
  684. package/src/tools-panel/types.ts +51 -20
  685. package/src/tree-grid/README.md +18 -58
  686. package/src/tree-grid/cell.tsx +41 -0
  687. package/src/tree-grid/{index.js → index.tsx} +111 -35
  688. package/src/tree-grid/item.tsx +32 -0
  689. package/src/tree-grid/{roving-tab-index-context.js → roving-tab-index-context.ts} +9 -1
  690. package/src/tree-grid/roving-tab-index-item.tsx +50 -0
  691. package/src/tree-grid/{roving-tab-index.js → roving-tab-index.tsx} +7 -5
  692. package/src/tree-grid/row.tsx +47 -0
  693. package/src/tree-grid/stories/index.tsx +144 -0
  694. package/src/tree-grid/test/__snapshots__/index.tsx.snap +3 -0
  695. package/src/tree-grid/test/{cell.js → cell.tsx} +7 -4
  696. package/src/tree-grid/test/{index.js → index.tsx} +13 -5
  697. package/src/tree-grid/test/{roving-tab-index-item.js → roving-tab-index-item.tsx} +7 -4
  698. package/src/tree-grid/test/{row.js → row.tsx} +4 -4
  699. package/src/tree-grid/types.ts +116 -0
  700. package/src/ui/context/context-connect.ts +7 -7
  701. package/src/ui/context/context-system-provider.js +7 -4
  702. package/src/ui/context/get-styled-class-name-from-key.ts +1 -1
  703. package/src/ui/utils/get-valid-children.ts +1 -1
  704. package/src/ui/utils/space.ts +1 -1
  705. package/src/unit-control/index.tsx +2 -2
  706. package/src/unit-control/utils.ts +20 -20
  707. package/src/utils/events.ts +4 -4
  708. package/src/utils/hooks/use-controlled-state.js +2 -2
  709. package/src/utils/hooks/use-controlled-value.ts +4 -4
  710. package/src/utils/hooks/use-latest-ref.ts +1 -1
  711. package/src/utils/unit-values.ts +3 -3
  712. package/src/v-stack/stories/e2e/index.tsx +36 -0
  713. package/tsconfig.json +1 -7
  714. package/tsconfig.tsbuildinfo +1 -1
  715. package/build/base-field/hook.js +0 -54
  716. package/build/base-field/hook.js.map +0 -1
  717. package/build/base-field/index.js +0 -14
  718. package/build/base-field/index.js.map +0 -1
  719. package/build/base-field/styles.js +0 -33
  720. package/build/base-field/styles.js.map +0 -1
  721. package/build/resizable-box/styles/resizable-box.styles.js +0 -2
  722. package/build-module/base-field/hook.js +0 -37
  723. package/build-module/base-field/hook.js.map +0 -1
  724. package/build-module/base-field/index.js +0 -2
  725. package/build-module/base-field/index.js.map +0 -1
  726. package/build-module/base-field/styles.js +0 -18
  727. package/build-module/base-field/styles.js.map +0 -1
  728. package/build-module/resizable-box/styles/resizable-box.styles.js +0 -2
  729. package/build-types/base-field/hook.d.ts +0 -270
  730. package/build-types/base-field/hook.d.ts.map +0 -1
  731. package/build-types/base-field/index.d.ts +0 -2
  732. package/build-types/base-field/index.d.ts.map +0 -1
  733. package/build-types/base-field/styles.d.ts +0 -6
  734. package/build-types/base-field/styles.d.ts.map +0 -1
  735. package/build-types/base-field/types.d.ts +0 -29
  736. package/build-types/base-field/types.d.ts.map +0 -1
  737. package/build-types/resizable-box/styles/resizable-box.styles.d.ts +0 -1
  738. package/build-types/resizable-box/styles/resizable-box.styles.d.ts.map +0 -1
  739. package/src/angle-picker-control/stories/index.js +0 -29
  740. package/src/base-field/README.md +0 -66
  741. package/src/base-field/hook.ts +0 -51
  742. package/src/base-field/index.ts +0 -1
  743. package/src/base-field/styles.ts +0 -86
  744. package/src/base-field/test/__snapshots__/index.tsx.snap +0 -141
  745. package/src/base-field/test/index.tsx +0 -84
  746. package/src/base-field/types.ts +0 -29
  747. package/src/combobox-control/stories/index.js +0 -339
  748. package/src/higher-order/with-constrained-tabbing/index.js +0 -22
  749. package/src/menu-items-choice/index.js +0 -43
  750. package/src/panel/header.js +0 -10
  751. package/src/panel/index.js +0 -26
  752. package/src/panel/row.js +0 -20
  753. package/src/resizable-box/styles/resizable-box.styles.js +0 -0
  754. package/src/tools-panel/stories/utils/tools-panel-with-item-group-slot.js +0 -246
  755. package/src/tree-grid/cell.js +0 -24
  756. package/src/tree-grid/item.js +0 -20
  757. package/src/tree-grid/roving-tab-index-item.js +0 -33
  758. package/src/tree-grid/row.js +0 -31
  759. package/src/tree-grid/stories/index.js +0 -106
  760. package/src/tree-grid/test/__snapshots__/index.js.snap +0 -3
  761. /package/build/{base-field → angle-picker-control}/types.js +0 -0
  762. /package/build-module/{base-field → angle-picker-control}/types.js +0 -0
  763. /package/build-module/{base-field → angle-picker-control}/types.js.map +0 -0
  764. /package/{build/base-field → build-module/box-control}/types.js.map +0 -0
  765. /package/build-module/{resizable-box/styles/resizable-box.styles.js.map → circular-option-picker/types.js.map} +0 -0
  766. /package/{build/resizable-box/styles/resizable-box.styles.js.map → build-module/combobox-control/types.js.map} +0 -0
  767. /package/build-types/{base-field → border-box-control}/test/index.d.ts +0 -0
  768. /package/src/panel/test/__snapshots__/{header.js.snap → header.tsx.snap} +0 -0
  769. /package/src/panel/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
  770. /package/src/panel/test/__snapshots__/{row.js.snap → row.tsx.snap} +0 -0
  771. /package/src/resizable-box/resize-tooltip/styles/{resize-tooltip.styles.js → resize-tooltip.styles.ts} +0 -0
  772. /package/src/toolbar/test/{index.js → index.tsx} +0 -0
  773. /package/src/tree-grid/test/__snapshots__/{cell.js.snap → cell.tsx.snap} +0 -0
  774. /package/src/tree-grid/test/__snapshots__/{roving-tab-index-item.js.snap → roving-tab-index-item.tsx.snap} +0 -0
  775. /package/src/tree-grid/test/__snapshots__/{roving-tab-index.js.snap → roving-tab-index.tsx.snap} +0 -0
  776. /package/src/tree-grid/test/__snapshots__/{row.js.snap → row.tsx.snap} +0 -0
  777. /package/src/tree-grid/test/{roving-tab-index.js → roving-tab-index.tsx} +0 -0
@@ -17,6 +17,7 @@ import { useViewportMatch, useMergeRefs, __experimentalUseDialog as useDialog }
17
17
  import { close } from '@wordpress/icons';
18
18
  import deprecated from '@wordpress/deprecated';
19
19
  import { Path, SVG } from '@wordpress/primitives';
20
+ import { getScrollContainer } from '@wordpress/dom';
20
21
  /**
21
22
  * Internal dependencies
22
23
  */
@@ -24,8 +25,9 @@ import { Path, SVG } from '@wordpress/primitives';
24
25
  import Button from '../button';
25
26
  import ScrollLock from '../scroll-lock';
26
27
  import { Slot, Fill, useSlot } from '../slot-fill';
27
- import { getFrameOffset, positionToPlacement, placementToMotionAnimationProps, getReferenceOwnerDocument, getReferenceElement } from './utils';
28
+ import { getFrameOffset, getFrameScale, positionToPlacement, placementToMotionAnimationProps, getReferenceOwnerDocument, getReferenceElement } from './utils';
28
29
  import { limitShift as customLimitShift } from './limit-shift';
30
+ import { overlayMiddlewares } from './overlay-middlewares';
29
31
  /**
30
32
  * Name of slot in which popover should fill.
31
33
  *
@@ -179,7 +181,7 @@ const UnforwardedPopover = (props, forwardedRef) => {
179
181
  */
180
182
 
181
183
  const frameOffsetRef = useRef(getFrameOffset(referenceOwnerDocument));
182
- const middleware = [// Custom middleware which adjusts the popover's position by taking into
184
+ const middleware = [...(placementProp === 'overlay' ? overlayMiddlewares() : []), // Custom middleware which adjusts the popover's position by taking into
183
185
  // account the offset of the anchor's iframe (if any) compared to the page.
184
186
  {
185
187
  name: 'frameOffset',
@@ -273,7 +275,7 @@ const UnforwardedPopover = (props, forwardedRef) => {
273
275
  arrow: arrowData
274
276
  }
275
277
  } = useFloating({
276
- placement: normalizedPlacementFromProps,
278
+ placement: normalizedPlacementFromProps === 'overlay' ? undefined : normalizedPlacementFromProps,
277
279
  middleware,
278
280
  whileElementsMounted: (referenceParam, floatingParam, updateParam) => autoUpdate(referenceParam, floatingParam, updateParam, {
279
281
  animationFrame: true
@@ -298,12 +300,14 @@ const UnforwardedPopover = (props, forwardedRef) => {
298
300
  fallbackReferenceElement,
299
301
  fallbackDocument: document
300
302
  });
303
+ const scale = getFrameScale(resultingReferenceOwnerDoc);
301
304
  const resultingReferenceElement = getReferenceElement({
302
305
  anchor,
303
306
  anchorRef,
304
307
  anchorRect,
305
308
  getAnchorRect,
306
- fallbackReferenceElement
309
+ fallbackReferenceElement,
310
+ scale
307
311
  });
308
312
  referenceCallbackRef(resultingReferenceElement);
309
313
  setReferenceOwnerDocument(resultingReferenceOwnerDoc);
@@ -326,6 +330,10 @@ const UnforwardedPopover = (props, forwardedRef) => {
326
330
  const {
327
331
  defaultView
328
332
  } = referenceOwnerDocument;
333
+ const {
334
+ frameElement
335
+ } = defaultView;
336
+ const scrollContainer = frameElement ? getScrollContainer(frameElement) : null;
329
337
 
330
338
  const updateFrameOffset = () => {
331
339
  frameOffsetRef.current = getFrameOffset(referenceOwnerDocument);
@@ -333,9 +341,11 @@ const UnforwardedPopover = (props, forwardedRef) => {
333
341
  };
334
342
 
335
343
  defaultView.addEventListener('resize', updateFrameOffset);
344
+ scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.addEventListener('scroll', updateFrameOffset);
336
345
  updateFrameOffset();
337
346
  return () => {
338
347
  defaultView.removeEventListener('resize', updateFrameOffset);
348
+ scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.removeEventListener('scroll', updateFrameOffset);
339
349
  };
340
350
  }, [referenceOwnerDocument, update, refs.floating]);
341
351
  const mergedFloatingRef = useMergeRefs([floating, dialogRef, forwardedRef]); // Disable reason: We care to capture the _bubbled_ events from inputs
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/popover/index.tsx"],"names":["classnames","useFloating","flip","flipMiddleware","shift","shiftMiddleware","autoUpdate","arrow","offset","offsetMiddleware","size","motion","useReducedMotion","useRef","useLayoutEffect","forwardRef","createContext","useContext","useMemo","useState","useCallback","useViewportMatch","useMergeRefs","__experimentalUseDialog","useDialog","close","deprecated","Path","SVG","Button","ScrollLock","Slot","Fill","useSlot","getFrameOffset","positionToPlacement","placementToMotionAnimationProps","getReferenceOwnerDocument","getReferenceElement","limitShift","customLimitShift","SLOT_NAME","ArrowTriangle","AnimatedWrapper","forwardedRef","style","receivedInlineStyles","placement","shouldAnimate","props","hasAnimatedOnce","setHasAnimatedOnce","shouldReduceMotion","motionInlineStyles","otherMotionProps","onAnimationComplete","computedAnimationProps","animate","slotNameContext","undefined","UnforwardedPopover","headerTitle","onClose","children","className","noArrow","position","placementProp","offsetProp","focusOnMount","anchor","expandOnMobile","onFocusOutside","__unstableSlotName","resize","variant","__unstableForcePosition","anchorRef","anchorRect","getAnchorRect","isAlternate","contentProps","computedFlipProp","computedResizeProp","since","version","alternative","computedVariant","arrowRef","fallbackReferenceElement","setFallbackReferenceElement","referenceOwnerDocument","setReferenceOwnerDocument","anchorRefFallback","node","isMobileViewport","isExpanded","hasArrow","normalizedPlacementFromProps","frameOffsetRef","middleware","name","fn","x","y","current","data","amount","apply","sizeProps","firstElementChild","refs","floating","HTMLElement","Object","assign","maxHeight","availableHeight","overflow","crossAxis","limiter","padding","element","filter","m","slotName","slot","onDialogClose","type","event","dialogRef","dialogProps","__unstableOnClose","reference","referenceCallbackRef","strategy","update","computedPlacement","middlewareData","arrowData","whileElementsMounted","referenceParam","floatingParam","updateParam","animationFrame","arrowCallbackRef","anchorRefTop","top","anchorRefBottom","bottom","anchorRefStartContainer","startContainer","anchorRefCurrent","resultingReferenceOwnerDoc","fallbackDocument","document","resultingReferenceElement","ownerDocument","defaultView","frameElement","updateFrameOffset","addEventListener","removeEventListener","mergedFloatingRef","content","left","Math","round","split","join","Number","isFinite","ref","Popover","PopoverSlot","__unstableSlotNameProvider","Provider"],"mappings":";;;AAAA;AACA;AACA;AAEA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SACCC,WADD,EAECC,IAAI,IAAIC,cAFT,EAGCC,KAAK,IAAIC,eAHV,EAICC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,SACC,cAAC,IAAD,CACC;AADD;AAEC,IAAA,gBAAgB,MAFjB;AAGC,IAAA,IAAI,EAAG4D,IAHR;AAIC,IAAA,SAAS,EAAC,cAJX;AAKC,IAAA,GAAG,EAAGuE;AALP,IADD;AASA,C,CAED;;;AACAC,OAAO,CAAC9I,IAAR,GAAehB,UAAU,CAAE+J,WAAF,CAAzB,C,CACA;;AACAD,OAAO,CAACE,0BAAR,GAAqCrH,eAAe,CAACsH,QAArD;AAEA,eAAeH,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, SyntheticEvent, RefCallback } from 'react';\nimport classnames from 'classnames';\nimport {\n\tuseFloating,\n\tflip as flipMiddleware,\n\tshift as shiftMiddleware,\n\tautoUpdate,\n\tarrow,\n\toffset as offsetMiddleware,\n\tsize,\n\tMiddleware,\n\tMiddlewareArguments,\n} from '@floating-ui/react-dom';\n// eslint-disable-next-line no-restricted-imports\nimport {\n\tmotion,\n\tuseReducedMotion,\n\tHTMLMotionProps,\n\tMotionProps,\n} from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseLayoutEffect,\n\tforwardRef,\n\tcreateContext,\n\tuseContext,\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n} from '@wordpress/element';\nimport {\n\tuseViewportMatch,\n\tuseMergeRefs,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\nimport { Path, SVG } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport {\n\tgetFrameOffset,\n\tpositionToPlacement,\n\tplacementToMotionAnimationProps,\n\tgetReferenceOwnerDocument,\n\tgetReferenceElement,\n} from './utils';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type {\n\tPopoverProps,\n\tAnimatedWrapperProps,\n\tPopoverAnchorRefReference,\n\tPopoverAnchorRefTopBottom,\n} from './types';\nimport { limitShift as customLimitShift } from './limit-shift';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nconst SLOT_NAME = 'Popover';\n\n// An SVG displaying a triangle facing down, filled with a solid\n// color and bordered in such a way to create an arrow-like effect.\n// Keeping the SVG's viewbox squared simplify the arrow positioning\n// calculations.\nconst ArrowTriangle = () => (\n\t<SVG\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\tviewBox={ `0 0 100 100` }\n\t\tclassName=\"components-popover__triangle\"\n\t\trole=\"presentation\"\n\t>\n\t\t<Path\n\t\t\tclassName=\"components-popover__triangle-bg\"\n\t\t\td=\"M 0 0 L 50 50 L 100 0\"\n\t\t/>\n\t\t<Path\n\t\t\tclassName=\"components-popover__triangle-border\"\n\t\t\td=\"M 0 0 L 50 50 L 100 0\"\n\t\t\tvectorEffect=\"non-scaling-stroke\"\n\t\t/>\n\t</SVG>\n);\n\nconst AnimatedWrapper = forwardRef(\n\t(\n\t\t{\n\t\t\tstyle: receivedInlineStyles,\n\t\t\tplacement,\n\t\t\tshouldAnimate = false,\n\t\t\t...props\n\t\t}: HTMLMotionProps< 'div' > & AnimatedWrapperProps,\n\t\tforwardedRef: ForwardedRef< any >\n\t) => {\n\t\t// When animating, animate only once (i.e. when the popover is opened), and\n\t\t// do not animate on subsequent prop changes (as it conflicts with\n\t\t// floating-ui's positioning updates).\n\t\tconst [ hasAnimatedOnce, setHasAnimatedOnce ] = useState( false );\n\t\tconst shouldReduceMotion = useReducedMotion();\n\n\t\tconst { style: motionInlineStyles, ...otherMotionProps } = useMemo(\n\t\t\t() => placementToMotionAnimationProps( placement ),\n\t\t\t[ placement ]\n\t\t);\n\n\t\tconst onAnimationComplete = useCallback(\n\t\t\t() => setHasAnimatedOnce( true ),\n\t\t\t[]\n\t\t);\n\n\t\tconst computedAnimationProps: HTMLMotionProps< 'div' > =\n\t\t\tshouldAnimate && ! shouldReduceMotion\n\t\t\t\t? {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...motionInlineStyles,\n\t\t\t\t\t\t\t...receivedInlineStyles,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...otherMotionProps,\n\t\t\t\t\t\tonAnimationComplete,\n\t\t\t\t\t\tanimate: hasAnimatedOnce\n\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t: otherMotionProps.animate,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tanimate: false,\n\t\t\t\t\t\tstyle: receivedInlineStyles,\n\t\t\t\t };\n\n\t\treturn (\n\t\t\t<motion.div\n\t\t\t\t{ ...computedAnimationProps }\n\t\t\t\t{ ...props }\n\t\t\t\tref={ forwardedRef }\n\t\t\t/>\n\t\t);\n\t}\n);\n\nconst slotNameContext = createContext< string | undefined >( undefined );\n\nconst UnforwardedPopover = (\n\tprops: Omit<\n\t\tWordPressComponentProps< PopoverProps, 'div', false >,\n\t\t// To avoid overlaps between the standard HTML attributes and the props\n\t\t// expected by `framer-motion`, omit all framer motion props from popover\n\t\t// props (except for `animate`, which is re-defined in `PopoverProps`).\n\t\tkeyof Omit< MotionProps, 'animate' >\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tanimate = true,\n\t\theaderTitle,\n\t\tonClose,\n\t\tchildren,\n\t\tclassName,\n\t\tnoArrow = true,\n\t\tposition,\n\t\tplacement: placementProp = 'bottom-start',\n\t\toffset: offsetProp = 0,\n\t\tfocusOnMount = 'firstElement',\n\t\tanchor,\n\t\texpandOnMobile,\n\t\tonFocusOutside,\n\t\t__unstableSlotName = SLOT_NAME,\n\t\tflip = true,\n\t\tresize = true,\n\t\tshift = false,\n\t\tvariant,\n\n\t\t// Deprecated props\n\t\t__unstableForcePosition,\n\t\tanchorRef,\n\t\tanchorRect,\n\t\tgetAnchorRect,\n\t\tisAlternate,\n\n\t\t// Rest\n\t\t...contentProps\n\t} = props;\n\n\tlet computedFlipProp = flip;\n\tlet computedResizeProp = resize;\n\tif ( __unstableForcePosition !== undefined ) {\n\t\tdeprecated( '`__unstableForcePosition` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`flip={ false }` and `resize={ false }`',\n\t\t} );\n\n\t\t// Back-compat, set the `flip` and `resize` props\n\t\t// to `false` to replicate `__unstableForcePosition`.\n\t\tcomputedFlipProp = ! __unstableForcePosition;\n\t\tcomputedResizeProp = ! __unstableForcePosition;\n\t}\n\n\tif ( anchorRef !== undefined ) {\n\t\tdeprecated( '`anchorRef` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tif ( anchorRect !== undefined ) {\n\t\tdeprecated( '`anchorRect` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tif ( getAnchorRect !== undefined ) {\n\t\tdeprecated( '`getAnchorRect` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tconst computedVariant = isAlternate ? 'toolbar' : variant;\n\tif ( isAlternate !== undefined ) {\n\t\tdeprecated( '`isAlternate` prop in wp.components.Popover', {\n\t\t\tsince: '6.2',\n\t\t\talternative: \"`variant` prop with the `'toolbar'` value\",\n\t\t} );\n\t}\n\n\tconst arrowRef = useRef< HTMLElement | null >( null );\n\n\tconst [ fallbackReferenceElement, setFallbackReferenceElement ] =\n\t\tuseState< HTMLSpanElement | null >( null );\n\tconst [ referenceOwnerDocument, setReferenceOwnerDocument ] = useState<\n\t\tDocument | undefined\n\t>();\n\n\tconst anchorRefFallback: RefCallback< HTMLSpanElement > = useCallback(\n\t\t( node ) => {\n\t\t\tsetFallbackReferenceElement( node );\n\t\t},\n\t\t[]\n\t);\n\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isExpanded = expandOnMobile && isMobileViewport;\n\tconst hasArrow = ! isExpanded && ! noArrow;\n\tconst normalizedPlacementFromProps = position\n\t\t? positionToPlacement( position )\n\t\t: placementProp;\n\n\t/**\n\t * Offsets the position of the popover when the anchor is inside an iframe.\n\t *\n\t * Store the offset in a ref, due to constraints with floating-ui:\n\t * https://floating-ui.com/docs/react-dom#variables-inside-middleware-functions.\n\t */\n\tconst frameOffsetRef = useRef( getFrameOffset( referenceOwnerDocument ) );\n\n\tconst middleware = [\n\t\t// Custom middleware which adjusts the popover's position by taking into\n\t\t// account the offset of the anchor's iframe (if any) compared to the page.\n\t\t{\n\t\t\tname: 'frameOffset',\n\t\t\tfn( { x, y }: MiddlewareArguments ) {\n\t\t\t\tif ( ! frameOffsetRef.current ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tx: x + frameOffsetRef.current.x,\n\t\t\t\t\ty: y + frameOffsetRef.current.y,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t// This will be used in the customLimitShift() function.\n\t\t\t\t\t\tamount: frameOffsetRef.current,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\toffsetMiddleware( offsetProp ),\n\t\tcomputedFlipProp ? flipMiddleware() : undefined,\n\t\tcomputedResizeProp\n\t\t\t? size( {\n\t\t\t\t\tapply( sizeProps ) {\n\t\t\t\t\t\tconst { firstElementChild } =\n\t\t\t\t\t\t\trefs.floating.current ?? {};\n\n\t\t\t\t\t\t// Only HTMLElement instances have the `style` property.\n\t\t\t\t\t\tif ( ! ( firstElementChild instanceof HTMLElement ) )\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t// Reduce the height of the popover to the available space.\n\t\t\t\t\t\tObject.assign( firstElementChild.style, {\n\t\t\t\t\t\t\tmaxHeight: `${ sizeProps.availableHeight }px`,\n\t\t\t\t\t\t\toverflow: 'auto',\n\t\t\t\t\t\t} );\n\t\t\t\t\t},\n\t\t\t } )\n\t\t\t: undefined,\n\t\tshift\n\t\t\t? shiftMiddleware( {\n\t\t\t\t\tcrossAxis: true,\n\t\t\t\t\tlimiter: customLimitShift(),\n\t\t\t\t\tpadding: 1, // Necessary to avoid flickering at the edge of the viewport.\n\t\t\t } )\n\t\t\t: undefined,\n\t\tarrow( { element: arrowRef } ),\n\t].filter(\n\t\t( m: Middleware | undefined ): m is Middleware => m !== undefined\n\t);\n\tconst slotName = useContext( slotNameContext ) || __unstableSlotName;\n\tconst slot = useSlot( slotName );\n\n\tlet onDialogClose;\n\n\tif ( onClose || onFocusOutside ) {\n\t\tonDialogClose = ( type: string | undefined, event: SyntheticEvent ) => {\n\t\t\t// Ideally the popover should have just a single onClose prop and\n\t\t\t// not three props that potentially do the same thing.\n\t\t\tif ( type === 'focus-outside' && onFocusOutside ) {\n\t\t\t\tonFocusOutside( event );\n\t\t\t} else if ( onClose ) {\n\t\t\t\tonClose();\n\t\t\t}\n\t\t};\n\t}\n\n\tconst [ dialogRef, dialogProps ] = useDialog( {\n\t\tfocusOnMount,\n\t\t__unstableOnClose: onDialogClose,\n\t\t// @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)\n\t\tonClose: onDialogClose,\n\t} );\n\n\tconst {\n\t\t// Positioning coordinates\n\t\tx,\n\t\ty,\n\t\t// Callback refs (not regular refs). This allows the position to be updated.\n\t\t// when either elements change.\n\t\treference: referenceCallbackRef,\n\t\tfloating,\n\t\t// Object with \"regular\" refs to both \"reference\" and \"floating\"\n\t\trefs,\n\t\t// Type of CSS position property to use (absolute or fixed)\n\t\tstrategy,\n\t\tupdate,\n\t\tplacement: computedPlacement,\n\t\tmiddlewareData: { arrow: arrowData },\n\t} = useFloating( {\n\t\tplacement: normalizedPlacementFromProps,\n\t\tmiddleware,\n\t\twhileElementsMounted: ( referenceParam, floatingParam, updateParam ) =>\n\t\t\tautoUpdate( referenceParam, floatingParam, updateParam, {\n\t\t\t\tanimationFrame: true,\n\t\t\t} ),\n\t} );\n\n\tconst arrowCallbackRef = useCallback(\n\t\t( node: HTMLElement | null ) => {\n\t\t\tarrowRef.current = node;\n\t\t\tupdate();\n\t\t},\n\t\t[ update ]\n\t);\n\n\t// When any of the possible anchor \"sources\" change,\n\t// recompute the reference element (real or virtual) and its owner document.\n\n\tconst anchorRefTop = ( anchorRef as PopoverAnchorRefTopBottom | undefined )\n\t\t?.top;\n\tconst anchorRefBottom = (\n\t\tanchorRef as PopoverAnchorRefTopBottom | undefined\n\t )?.bottom;\n\tconst anchorRefStartContainer = ( anchorRef as Range | undefined )\n\t\t?.startContainer;\n\tconst anchorRefCurrent = ( anchorRef as PopoverAnchorRefReference )\n\t\t?.current;\n\n\tuseLayoutEffect( () => {\n\t\tconst resultingReferenceOwnerDoc = getReferenceOwnerDocument( {\n\t\t\tanchor,\n\t\t\tanchorRef,\n\t\t\tanchorRect,\n\t\t\tgetAnchorRect,\n\t\t\tfallbackReferenceElement,\n\t\t\tfallbackDocument: document,\n\t\t} );\n\t\tconst resultingReferenceElement = getReferenceElement( {\n\t\t\tanchor,\n\t\t\tanchorRef,\n\t\t\tanchorRect,\n\t\t\tgetAnchorRect,\n\t\t\tfallbackReferenceElement,\n\t\t} );\n\n\t\treferenceCallbackRef( resultingReferenceElement );\n\n\t\tsetReferenceOwnerDocument( resultingReferenceOwnerDoc );\n\t}, [\n\t\tanchor,\n\t\tanchorRef,\n\t\tanchorRefTop,\n\t\tanchorRefBottom,\n\t\tanchorRefStartContainer,\n\t\tanchorRefCurrent,\n\t\tanchorRect,\n\t\tgetAnchorRect,\n\t\tfallbackReferenceElement,\n\t\treferenceCallbackRef,\n\t] );\n\n\t// If the reference element is in a different ownerDocument (e.g. iFrame),\n\t// we need to manually update the floating's position as the reference's owner\n\t// document scrolls. Also update the frame offset if the view resizes.\n\tuseLayoutEffect( () => {\n\t\tif (\n\t\t\t// Reference and root documents are the same.\n\t\t\treferenceOwnerDocument === document ||\n\t\t\t// Reference and floating are in the same document.\n\t\t\treferenceOwnerDocument === refs.floating.current?.ownerDocument ||\n\t\t\t// The reference's document has no view (i.e. window)\n\t\t\t// or frame element (ie. it's not an iframe).\n\t\t\t! referenceOwnerDocument?.defaultView?.frameElement\n\t\t) {\n\t\t\tframeOffsetRef.current = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tconst { defaultView } = referenceOwnerDocument;\n\n\t\tconst updateFrameOffset = () => {\n\t\t\tframeOffsetRef.current = getFrameOffset( referenceOwnerDocument );\n\t\t\tupdate();\n\t\t};\n\t\tdefaultView.addEventListener( 'resize', updateFrameOffset );\n\n\t\tupdateFrameOffset();\n\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'resize', updateFrameOffset );\n\t\t};\n\t}, [ referenceOwnerDocument, update, refs.floating ] );\n\n\tconst mergedFloatingRef = useMergeRefs( [\n\t\tfloating,\n\t\tdialogRef,\n\t\tforwardedRef,\n\t] );\n\n\t// Disable reason: We care to capture the _bubbled_ events from inputs\n\t// within popover as inferring close intent.\n\n\tlet content = (\n\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<AnimatedWrapper\n\t\t\tshouldAnimate={ animate && ! isExpanded }\n\t\t\tplacement={ computedPlacement }\n\t\t\tclassName={ classnames( 'components-popover', className, {\n\t\t\t\t'is-expanded': isExpanded,\n\t\t\t\t'is-positioned': x !== null && y !== null,\n\t\t\t\t// Use the 'alternate' classname for 'toolbar' variant for back compat.\n\t\t\t\t[ `is-${\n\t\t\t\t\tcomputedVariant === 'toolbar'\n\t\t\t\t\t\t? 'alternate'\n\t\t\t\t\t\t: computedVariant\n\t\t\t\t}` ]: computedVariant,\n\t\t\t} ) }\n\t\t\t{ ...contentProps }\n\t\t\tref={ mergedFloatingRef }\n\t\t\t{ ...dialogProps }\n\t\t\ttabIndex={ -1 }\n\t\t\tstyle={\n\t\t\t\tisExpanded\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tposition: strategy,\n\t\t\t\t\t\t\ttop: 0,\n\t\t\t\t\t\t\tleft: 0,\n\t\t\t\t\t\t\t// `x` and `y` are framer-motion specific props and are shorthands\n\t\t\t\t\t\t\t// for `translateX` and `translateY`. Currently it is not possible\n\t\t\t\t\t\t\t// to use `translateX` and `translateY` because those values would\n\t\t\t\t\t\t\t// be overridden by the return value of the\n\t\t\t\t\t\t\t// `placementToMotionAnimationProps` function in `AnimatedWrapper`\n\t\t\t\t\t\t\tx: Math.round( x ?? 0 ) || undefined,\n\t\t\t\t\t\t\ty: Math.round( y ?? 0 ) || undefined,\n\t\t\t\t\t }\n\t\t\t}\n\t\t>\n\t\t\t{ /* Prevents scroll on the document */ }\n\t\t\t{ isExpanded && <ScrollLock /> }\n\t\t\t{ isExpanded && (\n\t\t\t\t<div className=\"components-popover__header\">\n\t\t\t\t\t<span className=\"components-popover__header-title\">\n\t\t\t\t\t\t{ headerTitle }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"components-popover__close\"\n\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"components-popover__content\">{ children }</div>\n\t\t\t{ hasArrow && (\n\t\t\t\t<div\n\t\t\t\t\tref={ arrowCallbackRef }\n\t\t\t\t\tclassName={ [\n\t\t\t\t\t\t'components-popover__arrow',\n\t\t\t\t\t\t`is-${ computedPlacement.split( '-' )[ 0 ] }`,\n\t\t\t\t\t].join( ' ' ) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tleft:\n\t\t\t\t\t\t\ttypeof arrowData?.x !== 'undefined' &&\n\t\t\t\t\t\t\tNumber.isFinite( arrowData.x )\n\t\t\t\t\t\t\t\t? `${\n\t\t\t\t\t\t\t\t\t\tarrowData.x +\n\t\t\t\t\t\t\t\t\t\t( frameOffsetRef.current?.x ?? 0 )\n\t\t\t\t\t\t\t\t }px`\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t\ttop:\n\t\t\t\t\t\t\ttypeof arrowData?.y !== 'undefined' &&\n\t\t\t\t\t\t\tNumber.isFinite( arrowData.y )\n\t\t\t\t\t\t\t\t? `${\n\t\t\t\t\t\t\t\t\t\tarrowData.y +\n\t\t\t\t\t\t\t\t\t\t( frameOffsetRef.current?.y ?? 0 )\n\t\t\t\t\t\t\t\t }px`\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<ArrowTriangle />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</AnimatedWrapper>\n\t);\n\n\tif ( slot.ref ) {\n\t\tcontent = <Fill name={ slotName }>{ content }</Fill>;\n\t}\n\n\tif ( anchorRef || anchorRect || anchor ) {\n\t\treturn content;\n\t}\n\n\treturn <span ref={ anchorRefFallback }>{ content }</span>;\n};\n\n/**\n * `Popover` renders its content in a floating modal. If no explicit anchor is passed via props, it anchors to its parent element by default.\n *\n * ```jsx\n * import { Button, Popover } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyPopover = () => {\n * \tconst [ isVisible, setIsVisible ] = useState( false );\n * \tconst toggleVisible = () => {\n * \t\tsetIsVisible( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<Button variant=\"secondary\" onClick={ toggleVisible }>\n * \t\t\tToggle Popover!\n * \t\t\t{ isVisible && <Popover>Popover is toggled!</Popover> }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n */\nexport const Popover = forwardRef( UnforwardedPopover );\n\nfunction PopoverSlot(\n\t{ name = SLOT_NAME }: { name?: string },\n\tref: ForwardedRef< any >\n) {\n\treturn (\n\t\t<Slot\n\t\t\t// @ts-expect-error Need to type `SlotFill`\n\t\t\tbubblesVirtually\n\t\t\tname={ name }\n\t\t\tclassName=\"popover-slot\"\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\n// @ts-expect-error For Legacy Reasons\nPopover.Slot = forwardRef( PopoverSlot );\n// @ts-expect-error For Legacy Reasons\nPopover.__unstableSlotNameProvider = slotNameContext.Provider;\n\nexport default Popover;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/popover/index.tsx"],"names":["classnames","useFloating","flip","flipMiddleware","shift","shiftMiddleware","autoUpdate","arrow","offset","offsetMiddleware","size","motion","useReducedMotion","useRef","useLayoutEffect","forwardRef","createContext","useContext","useMemo","useState","useCallback","useViewportMatch","useMergeRefs","__experimentalUseDialog","useDialog","close","deprecated","Path","SVG","getScrollContainer","Button","ScrollLock","Slot","Fill","useSlot","getFrameOffset","getFrameScale","positionToPlacement","placementToMotionAnimationProps","getReferenceOwnerDocument","getReferenceElement","limitShift","customLimitShift","overlayMiddlewares","SLOT_NAME","ArrowTriangle","AnimatedWrapper","forwardedRef","style","receivedInlineStyles","placement","shouldAnimate","props","hasAnimatedOnce","setHasAnimatedOnce","shouldReduceMotion","motionInlineStyles","otherMotionProps","onAnimationComplete","computedAnimationProps","animate","slotNameContext","undefined","UnforwardedPopover","headerTitle","onClose","children","className","noArrow","position","placementProp","offsetProp","focusOnMount","anchor","expandOnMobile","onFocusOutside","__unstableSlotName","resize","variant","__unstableForcePosition","anchorRef","anchorRect","getAnchorRect","isAlternate","contentProps","computedFlipProp","computedResizeProp","since","version","alternative","computedVariant","arrowRef","fallbackReferenceElement","setFallbackReferenceElement","referenceOwnerDocument","setReferenceOwnerDocument","anchorRefFallback","node","isMobileViewport","isExpanded","hasArrow","normalizedPlacementFromProps","frameOffsetRef","middleware","name","fn","x","y","current","data","amount","apply","sizeProps","firstElementChild","refs","floating","HTMLElement","Object","assign","maxHeight","availableHeight","overflow","crossAxis","limiter","padding","element","filter","m","slotName","slot","onDialogClose","type","event","dialogRef","dialogProps","__unstableOnClose","reference","referenceCallbackRef","strategy","update","computedPlacement","middlewareData","arrowData","whileElementsMounted","referenceParam","floatingParam","updateParam","animationFrame","arrowCallbackRef","anchorRefTop","top","anchorRefBottom","bottom","anchorRefStartContainer","startContainer","anchorRefCurrent","resultingReferenceOwnerDoc","fallbackDocument","document","scale","resultingReferenceElement","ownerDocument","defaultView","frameElement","scrollContainer","updateFrameOffset","addEventListener","removeEventListener","mergedFloatingRef","content","left","Math","round","split","join","Number","isFinite","ref","Popover","PopoverSlot","__unstableSlotNameProvider","Provider"],"mappings":";;;AAAA;AACA;AACA;AAEA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SACCC,WADD,EAECC,IAAI,IAAIC,cAFT,EAGCC,KAAK,IAAIC,eAHV,EAICC,UAJD,EAKCC,KALD,EAMCC,MAAM,IAAIC,gBANX,EAOCC,IAPD,QAUO,wBAVP,C,CAWA;;AACA,SACCC,MADD,EAECC,gBAFD,QAKO,eALP;AAOA;AACA;AACA;;AACA,SACCC,MADD,EAECC,eAFD,EAGCC,UAHD,EAICC,aAJD,EAKCC,UALD,EAMCC,OAND,EAOCC,QAPD,EAQCC,WARD,QASO,oBATP;AAUA,SACCC,gBADD,EAECC,YAFD,EAGCC,uBAAuB,IAAIC,SAH5B,QAIO,oBAJP;AAKA,SAASC,KAAT,QAAsB,kBAAtB;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,IAAT,EAAeC,GAAf,QAA0B,uBAA1B;AACA,SAASC,kBAAT,QAAmC,gBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,SAASC,IAAT,EAAeC,IAAf,EAAqBC,OAArB,QAAoC,cAApC;AACA,SACCC,cADD,EAECC,aAFD,EAGCC,mBAHD,EAICC,+BAJD,EAKCC,yBALD,EAMCC,mBAND,QAOO,SAPP;AAeA,SAASC,UAAU,IAAIC,gBAAvB,QAA+C,eAA/C;AACA,SAASC,kBAAT,QAAmC,uBAAnC;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,SAAS,GAAG,SAAlB,C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,C,CACA;;AACAD,OAAO,CAACE,0BAAR,GAAqCvH,eAAe,CAACwH,QAArD;AAEA,eAAeH,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, SyntheticEvent, RefCallback } from 'react';\nimport classnames from 'classnames';\nimport {\n\tuseFloating,\n\tflip as flipMiddleware,\n\tshift as shiftMiddleware,\n\tautoUpdate,\n\tarrow,\n\toffset as offsetMiddleware,\n\tsize,\n\tMiddleware,\n\tMiddlewareArguments,\n} from '@floating-ui/react-dom';\n// eslint-disable-next-line no-restricted-imports\nimport {\n\tmotion,\n\tuseReducedMotion,\n\tHTMLMotionProps,\n\tMotionProps,\n} from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseLayoutEffect,\n\tforwardRef,\n\tcreateContext,\n\tuseContext,\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n} from '@wordpress/element';\nimport {\n\tuseViewportMatch,\n\tuseMergeRefs,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\nimport { Path, SVG } from '@wordpress/primitives';\nimport { getScrollContainer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport {\n\tgetFrameOffset,\n\tgetFrameScale,\n\tpositionToPlacement,\n\tplacementToMotionAnimationProps,\n\tgetReferenceOwnerDocument,\n\tgetReferenceElement,\n} from './utils';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type {\n\tPopoverProps,\n\tAnimatedWrapperProps,\n\tPopoverAnchorRefReference,\n\tPopoverAnchorRefTopBottom,\n} from './types';\nimport { limitShift as customLimitShift } from './limit-shift';\nimport { overlayMiddlewares } from './overlay-middlewares';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nconst SLOT_NAME = 'Popover';\n\n// An SVG displaying a triangle facing down, filled with a solid\n// color and bordered in such a way to create an arrow-like effect.\n// Keeping the SVG's viewbox squared simplify the arrow positioning\n// calculations.\nconst ArrowTriangle = () => (\n\t<SVG\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\tviewBox={ `0 0 100 100` }\n\t\tclassName=\"components-popover__triangle\"\n\t\trole=\"presentation\"\n\t>\n\t\t<Path\n\t\t\tclassName=\"components-popover__triangle-bg\"\n\t\t\td=\"M 0 0 L 50 50 L 100 0\"\n\t\t/>\n\t\t<Path\n\t\t\tclassName=\"components-popover__triangle-border\"\n\t\t\td=\"M 0 0 L 50 50 L 100 0\"\n\t\t\tvectorEffect=\"non-scaling-stroke\"\n\t\t/>\n\t</SVG>\n);\n\nconst AnimatedWrapper = forwardRef(\n\t(\n\t\t{\n\t\t\tstyle: receivedInlineStyles,\n\t\t\tplacement,\n\t\t\tshouldAnimate = false,\n\t\t\t...props\n\t\t}: HTMLMotionProps< 'div' > & AnimatedWrapperProps,\n\t\tforwardedRef: ForwardedRef< any >\n\t) => {\n\t\t// When animating, animate only once (i.e. when the popover is opened), and\n\t\t// do not animate on subsequent prop changes (as it conflicts with\n\t\t// floating-ui's positioning updates).\n\t\tconst [ hasAnimatedOnce, setHasAnimatedOnce ] = useState( false );\n\t\tconst shouldReduceMotion = useReducedMotion();\n\n\t\tconst { style: motionInlineStyles, ...otherMotionProps } = useMemo(\n\t\t\t() => placementToMotionAnimationProps( placement ),\n\t\t\t[ placement ]\n\t\t);\n\n\t\tconst onAnimationComplete = useCallback(\n\t\t\t() => setHasAnimatedOnce( true ),\n\t\t\t[]\n\t\t);\n\n\t\tconst computedAnimationProps: HTMLMotionProps< 'div' > =\n\t\t\tshouldAnimate && ! shouldReduceMotion\n\t\t\t\t? {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...motionInlineStyles,\n\t\t\t\t\t\t\t...receivedInlineStyles,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...otherMotionProps,\n\t\t\t\t\t\tonAnimationComplete,\n\t\t\t\t\t\tanimate: hasAnimatedOnce\n\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t: otherMotionProps.animate,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tanimate: false,\n\t\t\t\t\t\tstyle: receivedInlineStyles,\n\t\t\t\t };\n\n\t\treturn (\n\t\t\t<motion.div\n\t\t\t\t{ ...computedAnimationProps }\n\t\t\t\t{ ...props }\n\t\t\t\tref={ forwardedRef }\n\t\t\t/>\n\t\t);\n\t}\n);\n\nconst slotNameContext = createContext< string | undefined >( undefined );\n\nconst UnforwardedPopover = (\n\tprops: Omit<\n\t\tWordPressComponentProps< PopoverProps, 'div', false >,\n\t\t// To avoid overlaps between the standard HTML attributes and the props\n\t\t// expected by `framer-motion`, omit all framer motion props from popover\n\t\t// props (except for `animate`, which is re-defined in `PopoverProps`).\n\t\tkeyof Omit< MotionProps, 'animate' >\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tanimate = true,\n\t\theaderTitle,\n\t\tonClose,\n\t\tchildren,\n\t\tclassName,\n\t\tnoArrow = true,\n\t\tposition,\n\t\tplacement: placementProp = 'bottom-start',\n\t\toffset: offsetProp = 0,\n\t\tfocusOnMount = 'firstElement',\n\t\tanchor,\n\t\texpandOnMobile,\n\t\tonFocusOutside,\n\t\t__unstableSlotName = SLOT_NAME,\n\t\tflip = true,\n\t\tresize = true,\n\t\tshift = false,\n\t\tvariant,\n\n\t\t// Deprecated props\n\t\t__unstableForcePosition,\n\t\tanchorRef,\n\t\tanchorRect,\n\t\tgetAnchorRect,\n\t\tisAlternate,\n\n\t\t// Rest\n\t\t...contentProps\n\t} = props;\n\n\tlet computedFlipProp = flip;\n\tlet computedResizeProp = resize;\n\tif ( __unstableForcePosition !== undefined ) {\n\t\tdeprecated( '`__unstableForcePosition` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: '`flip={ false }` and `resize={ false }`',\n\t\t} );\n\n\t\t// Back-compat, set the `flip` and `resize` props\n\t\t// to `false` to replicate `__unstableForcePosition`.\n\t\tcomputedFlipProp = ! __unstableForcePosition;\n\t\tcomputedResizeProp = ! __unstableForcePosition;\n\t}\n\n\tif ( anchorRef !== undefined ) {\n\t\tdeprecated( '`anchorRef` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tif ( anchorRect !== undefined ) {\n\t\tdeprecated( '`anchorRect` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tif ( getAnchorRect !== undefined ) {\n\t\tdeprecated( '`getAnchorRect` prop in wp.components.Popover', {\n\t\t\tsince: '6.1',\n\t\t\talternative: '`anchor` prop',\n\t\t} );\n\t}\n\n\tconst computedVariant = isAlternate ? 'toolbar' : variant;\n\tif ( isAlternate !== undefined ) {\n\t\tdeprecated( '`isAlternate` prop in wp.components.Popover', {\n\t\t\tsince: '6.2',\n\t\t\talternative: \"`variant` prop with the `'toolbar'` value\",\n\t\t} );\n\t}\n\n\tconst arrowRef = useRef< HTMLElement | null >( null );\n\n\tconst [ fallbackReferenceElement, setFallbackReferenceElement ] =\n\t\tuseState< HTMLSpanElement | null >( null );\n\tconst [ referenceOwnerDocument, setReferenceOwnerDocument ] = useState<\n\t\tDocument | undefined\n\t>();\n\n\tconst anchorRefFallback: RefCallback< HTMLSpanElement > = useCallback(\n\t\t( node ) => {\n\t\t\tsetFallbackReferenceElement( node );\n\t\t},\n\t\t[]\n\t);\n\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isExpanded = expandOnMobile && isMobileViewport;\n\tconst hasArrow = ! isExpanded && ! noArrow;\n\tconst normalizedPlacementFromProps = position\n\t\t? positionToPlacement( position )\n\t\t: placementProp;\n\n\t/**\n\t * Offsets the position of the popover when the anchor is inside an iframe.\n\t *\n\t * Store the offset in a ref, due to constraints with floating-ui:\n\t * https://floating-ui.com/docs/react-dom#variables-inside-middleware-functions.\n\t */\n\tconst frameOffsetRef = useRef( getFrameOffset( referenceOwnerDocument ) );\n\n\tconst middleware = [\n\t\t...( placementProp === 'overlay' ? overlayMiddlewares() : [] ),\n\t\t// Custom middleware which adjusts the popover's position by taking into\n\t\t// account the offset of the anchor's iframe (if any) compared to the page.\n\t\t{\n\t\t\tname: 'frameOffset',\n\t\t\tfn( { x, y }: MiddlewareArguments ) {\n\t\t\t\tif ( ! frameOffsetRef.current ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tx: x + frameOffsetRef.current.x,\n\t\t\t\t\ty: y + frameOffsetRef.current.y,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t// This will be used in the customLimitShift() function.\n\t\t\t\t\t\tamount: frameOffsetRef.current,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\toffsetMiddleware( offsetProp ),\n\t\tcomputedFlipProp ? flipMiddleware() : undefined,\n\t\tcomputedResizeProp\n\t\t\t? size( {\n\t\t\t\t\tapply( sizeProps ) {\n\t\t\t\t\t\tconst { firstElementChild } =\n\t\t\t\t\t\t\trefs.floating.current ?? {};\n\n\t\t\t\t\t\t// Only HTMLElement instances have the `style` property.\n\t\t\t\t\t\tif ( ! ( firstElementChild instanceof HTMLElement ) )\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t// Reduce the height of the popover to the available space.\n\t\t\t\t\t\tObject.assign( firstElementChild.style, {\n\t\t\t\t\t\t\tmaxHeight: `${ sizeProps.availableHeight }px`,\n\t\t\t\t\t\t\toverflow: 'auto',\n\t\t\t\t\t\t} );\n\t\t\t\t\t},\n\t\t\t } )\n\t\t\t: undefined,\n\t\tshift\n\t\t\t? shiftMiddleware( {\n\t\t\t\t\tcrossAxis: true,\n\t\t\t\t\tlimiter: customLimitShift(),\n\t\t\t\t\tpadding: 1, // Necessary to avoid flickering at the edge of the viewport.\n\t\t\t } )\n\t\t\t: undefined,\n\t\tarrow( { element: arrowRef } ),\n\t].filter(\n\t\t( m: Middleware | undefined ): m is Middleware => m !== undefined\n\t);\n\tconst slotName = useContext( slotNameContext ) || __unstableSlotName;\n\tconst slot = useSlot( slotName );\n\n\tlet onDialogClose;\n\n\tif ( onClose || onFocusOutside ) {\n\t\tonDialogClose = ( type: string | undefined, event: SyntheticEvent ) => {\n\t\t\t// Ideally the popover should have just a single onClose prop and\n\t\t\t// not three props that potentially do the same thing.\n\t\t\tif ( type === 'focus-outside' && onFocusOutside ) {\n\t\t\t\tonFocusOutside( event );\n\t\t\t} else if ( onClose ) {\n\t\t\t\tonClose();\n\t\t\t}\n\t\t};\n\t}\n\n\tconst [ dialogRef, dialogProps ] = useDialog( {\n\t\tfocusOnMount,\n\t\t__unstableOnClose: onDialogClose,\n\t\t// @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)\n\t\tonClose: onDialogClose,\n\t} );\n\n\tconst {\n\t\t// Positioning coordinates\n\t\tx,\n\t\ty,\n\t\t// Callback refs (not regular refs). This allows the position to be updated.\n\t\t// when either elements change.\n\t\treference: referenceCallbackRef,\n\t\tfloating,\n\t\t// Object with \"regular\" refs to both \"reference\" and \"floating\"\n\t\trefs,\n\t\t// Type of CSS position property to use (absolute or fixed)\n\t\tstrategy,\n\t\tupdate,\n\t\tplacement: computedPlacement,\n\t\tmiddlewareData: { arrow: arrowData },\n\t} = useFloating( {\n\t\tplacement:\n\t\t\tnormalizedPlacementFromProps === 'overlay'\n\t\t\t\t? undefined\n\t\t\t\t: normalizedPlacementFromProps,\n\t\tmiddleware,\n\t\twhileElementsMounted: ( referenceParam, floatingParam, updateParam ) =>\n\t\t\tautoUpdate( referenceParam, floatingParam, updateParam, {\n\t\t\t\tanimationFrame: true,\n\t\t\t} ),\n\t} );\n\n\tconst arrowCallbackRef = useCallback(\n\t\t( node: HTMLElement | null ) => {\n\t\t\tarrowRef.current = node;\n\t\t\tupdate();\n\t\t},\n\t\t[ update ]\n\t);\n\n\t// When any of the possible anchor \"sources\" change,\n\t// recompute the reference element (real or virtual) and its owner document.\n\n\tconst anchorRefTop = ( anchorRef as PopoverAnchorRefTopBottom | undefined )\n\t\t?.top;\n\tconst anchorRefBottom = (\n\t\tanchorRef as PopoverAnchorRefTopBottom | undefined\n\t )?.bottom;\n\tconst anchorRefStartContainer = ( anchorRef as Range | undefined )\n\t\t?.startContainer;\n\tconst anchorRefCurrent = ( anchorRef as PopoverAnchorRefReference )\n\t\t?.current;\n\n\tuseLayoutEffect( () => {\n\t\tconst resultingReferenceOwnerDoc = getReferenceOwnerDocument( {\n\t\t\tanchor,\n\t\t\tanchorRef,\n\t\t\tanchorRect,\n\t\t\tgetAnchorRect,\n\t\t\tfallbackReferenceElement,\n\t\t\tfallbackDocument: document,\n\t\t} );\n\t\tconst scale = getFrameScale( resultingReferenceOwnerDoc );\n\t\tconst resultingReferenceElement = getReferenceElement( {\n\t\t\tanchor,\n\t\t\tanchorRef,\n\t\t\tanchorRect,\n\t\t\tgetAnchorRect,\n\t\t\tfallbackReferenceElement,\n\t\t\tscale,\n\t\t} );\n\n\t\treferenceCallbackRef( resultingReferenceElement );\n\n\t\tsetReferenceOwnerDocument( resultingReferenceOwnerDoc );\n\t}, [\n\t\tanchor,\n\t\tanchorRef,\n\t\tanchorRefTop,\n\t\tanchorRefBottom,\n\t\tanchorRefStartContainer,\n\t\tanchorRefCurrent,\n\t\tanchorRect,\n\t\tgetAnchorRect,\n\t\tfallbackReferenceElement,\n\t\treferenceCallbackRef,\n\t] );\n\n\t// If the reference element is in a different ownerDocument (e.g. iFrame),\n\t// we need to manually update the floating's position as the reference's owner\n\t// document scrolls. Also update the frame offset if the view resizes.\n\tuseLayoutEffect( () => {\n\t\tif (\n\t\t\t// Reference and root documents are the same.\n\t\t\treferenceOwnerDocument === document ||\n\t\t\t// Reference and floating are in the same document.\n\t\t\treferenceOwnerDocument === refs.floating.current?.ownerDocument ||\n\t\t\t// The reference's document has no view (i.e. window)\n\t\t\t// or frame element (ie. it's not an iframe).\n\t\t\t! referenceOwnerDocument?.defaultView?.frameElement\n\t\t) {\n\t\t\tframeOffsetRef.current = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\tconst { defaultView } = referenceOwnerDocument;\n\t\tconst { frameElement } = defaultView;\n\n\t\tconst scrollContainer = frameElement\n\t\t\t? getScrollContainer( frameElement )\n\t\t\t: null;\n\n\t\tconst updateFrameOffset = () => {\n\t\t\tframeOffsetRef.current = getFrameOffset( referenceOwnerDocument );\n\t\t\tupdate();\n\t\t};\n\t\tdefaultView.addEventListener( 'resize', updateFrameOffset );\n\t\tscrollContainer?.addEventListener( 'scroll', updateFrameOffset );\n\n\t\tupdateFrameOffset();\n\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'resize', updateFrameOffset );\n\t\t\tscrollContainer?.removeEventListener( 'scroll', updateFrameOffset );\n\t\t};\n\t}, [ referenceOwnerDocument, update, refs.floating ] );\n\n\tconst mergedFloatingRef = useMergeRefs( [\n\t\tfloating,\n\t\tdialogRef,\n\t\tforwardedRef,\n\t] );\n\n\t// Disable reason: We care to capture the _bubbled_ events from inputs\n\t// within popover as inferring close intent.\n\n\tlet content = (\n\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<AnimatedWrapper\n\t\t\tshouldAnimate={ animate && ! isExpanded }\n\t\t\tplacement={ computedPlacement }\n\t\t\tclassName={ classnames( 'components-popover', className, {\n\t\t\t\t'is-expanded': isExpanded,\n\t\t\t\t'is-positioned': x !== null && y !== null,\n\t\t\t\t// Use the 'alternate' classname for 'toolbar' variant for back compat.\n\t\t\t\t[ `is-${\n\t\t\t\t\tcomputedVariant === 'toolbar'\n\t\t\t\t\t\t? 'alternate'\n\t\t\t\t\t\t: computedVariant\n\t\t\t\t}` ]: computedVariant,\n\t\t\t} ) }\n\t\t\t{ ...contentProps }\n\t\t\tref={ mergedFloatingRef }\n\t\t\t{ ...dialogProps }\n\t\t\ttabIndex={ -1 }\n\t\t\tstyle={\n\t\t\t\tisExpanded\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tposition: strategy,\n\t\t\t\t\t\t\ttop: 0,\n\t\t\t\t\t\t\tleft: 0,\n\t\t\t\t\t\t\t// `x` and `y` are framer-motion specific props and are shorthands\n\t\t\t\t\t\t\t// for `translateX` and `translateY`. Currently it is not possible\n\t\t\t\t\t\t\t// to use `translateX` and `translateY` because those values would\n\t\t\t\t\t\t\t// be overridden by the return value of the\n\t\t\t\t\t\t\t// `placementToMotionAnimationProps` function in `AnimatedWrapper`\n\t\t\t\t\t\t\tx: Math.round( x ?? 0 ) || undefined,\n\t\t\t\t\t\t\ty: Math.round( y ?? 0 ) || undefined,\n\t\t\t\t\t }\n\t\t\t}\n\t\t>\n\t\t\t{ /* Prevents scroll on the document */ }\n\t\t\t{ isExpanded && <ScrollLock /> }\n\t\t\t{ isExpanded && (\n\t\t\t\t<div className=\"components-popover__header\">\n\t\t\t\t\t<span className=\"components-popover__header-title\">\n\t\t\t\t\t\t{ headerTitle }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"components-popover__close\"\n\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"components-popover__content\">{ children }</div>\n\t\t\t{ hasArrow && (\n\t\t\t\t<div\n\t\t\t\t\tref={ arrowCallbackRef }\n\t\t\t\t\tclassName={ [\n\t\t\t\t\t\t'components-popover__arrow',\n\t\t\t\t\t\t`is-${ computedPlacement.split( '-' )[ 0 ] }`,\n\t\t\t\t\t].join( ' ' ) }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tleft:\n\t\t\t\t\t\t\ttypeof arrowData?.x !== 'undefined' &&\n\t\t\t\t\t\t\tNumber.isFinite( arrowData.x )\n\t\t\t\t\t\t\t\t? `${\n\t\t\t\t\t\t\t\t\t\tarrowData.x +\n\t\t\t\t\t\t\t\t\t\t( frameOffsetRef.current?.x ?? 0 )\n\t\t\t\t\t\t\t\t }px`\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t\ttop:\n\t\t\t\t\t\t\ttypeof arrowData?.y !== 'undefined' &&\n\t\t\t\t\t\t\tNumber.isFinite( arrowData.y )\n\t\t\t\t\t\t\t\t? `${\n\t\t\t\t\t\t\t\t\t\tarrowData.y +\n\t\t\t\t\t\t\t\t\t\t( frameOffsetRef.current?.y ?? 0 )\n\t\t\t\t\t\t\t\t }px`\n\t\t\t\t\t\t\t\t: '',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<ArrowTriangle />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</AnimatedWrapper>\n\t);\n\n\tif ( slot.ref ) {\n\t\tcontent = <Fill name={ slotName }>{ content }</Fill>;\n\t}\n\n\tif ( anchorRef || anchorRect || anchor ) {\n\t\treturn content;\n\t}\n\n\treturn <span ref={ anchorRefFallback }>{ content }</span>;\n};\n\n/**\n * `Popover` renders its content in a floating modal. If no explicit anchor is passed via props, it anchors to its parent element by default.\n *\n * ```jsx\n * import { Button, Popover } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyPopover = () => {\n * \tconst [ isVisible, setIsVisible ] = useState( false );\n * \tconst toggleVisible = () => {\n * \t\tsetIsVisible( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<Button variant=\"secondary\" onClick={ toggleVisible }>\n * \t\t\tToggle Popover!\n * \t\t\t{ isVisible && <Popover>Popover is toggled!</Popover> }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n */\nexport const Popover = forwardRef( UnforwardedPopover );\n\nfunction PopoverSlot(\n\t{ name = SLOT_NAME }: { name?: string },\n\tref: ForwardedRef< any >\n) {\n\treturn (\n\t\t<Slot\n\t\t\t// @ts-expect-error Need to type `SlotFill`\n\t\t\tbubblesVirtually\n\t\t\tname={ name }\n\t\t\tclassName=\"popover-slot\"\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\n// @ts-expect-error For Legacy Reasons\nPopover.Slot = forwardRef( PopoverSlot );\n// @ts-expect-error For Legacy Reasons\nPopover.__unstableSlotNameProvider = slotNameContext.Provider;\n\nexport default Popover;\n"]}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { size } from '@floating-ui/react-dom';
5
+ export function overlayMiddlewares() {
6
+ return [{
7
+ name: 'overlay',
8
+
9
+ fn(_ref) {
10
+ let {
11
+ rects
12
+ } = _ref;
13
+ return rects.reference;
14
+ }
15
+
16
+ }, size({
17
+ apply(_ref2) {
18
+ var _elements$floating;
19
+
20
+ let {
21
+ rects,
22
+ elements
23
+ } = _ref2;
24
+ const {
25
+ firstElementChild
26
+ } = (_elements$floating = elements.floating) !== null && _elements$floating !== void 0 ? _elements$floating : {}; // Only HTMLElement instances have the `style` property.
27
+
28
+ if (!(firstElementChild instanceof HTMLElement)) return; // Reduce the height of the popover to the available space.
29
+
30
+ Object.assign(firstElementChild.style, {
31
+ width: `${rects.reference.width}px`,
32
+ height: `${rects.reference.height}px`
33
+ });
34
+ }
35
+
36
+ })];
37
+ }
38
+ //# sourceMappingURL=overlay-middlewares.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/popover/overlay-middlewares.tsx"],"names":["size","overlayMiddlewares","name","fn","rects","reference","apply","elements","firstElementChild","floating","HTMLElement","Object","assign","style","width","height"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAA0C,wBAA1C;AAEA,OAAO,SAASC,kBAAT,GAA8B;AACpC,SAAO,CACN;AACCC,IAAAA,IAAI,EAAE,SADP;;AAECC,IAAAA,EAAE,OAAmC;AAAA,UAAjC;AAAEC,QAAAA;AAAF,OAAiC;AACpC,aAAOA,KAAK,CAACC,SAAb;AACA;;AAJF,GADM,EAONL,IAAI,CAAE;AACLM,IAAAA,KAAK,QAAwB;AAAA;;AAAA,UAAtB;AAAEF,QAAAA,KAAF;AAASG,QAAAA;AAAT,OAAsB;AAC5B,YAAM;AAAEC,QAAAA;AAAF,gCAAwBD,QAAQ,CAACE,QAAjC,mEAA6C,EAAnD,CAD4B,CAG5B;;AACA,UAAK,EAAID,iBAAiB,YAAYE,WAAjC,CAAL,EAAsD,OAJ1B,CAM5B;;AACAC,MAAAA,MAAM,CAACC,MAAP,CAAeJ,iBAAiB,CAACK,KAAjC,EAAwC;AACvCC,QAAAA,KAAK,EAAG,GAAGV,KAAK,CAACC,SAAN,CAAgBS,KAAO,IADK;AAEvCC,QAAAA,MAAM,EAAG,GAAGX,KAAK,CAACC,SAAN,CAAgBU,MAAQ;AAFG,OAAxC;AAIA;;AAZI,GAAF,CAPE,CAAP;AAsBA","sourcesContent":["/**\n * External dependencies\n */\nimport { size, MiddlewareArguments } from '@floating-ui/react-dom';\n\nexport function overlayMiddlewares() {\n\treturn [\n\t\t{\n\t\t\tname: 'overlay',\n\t\t\tfn( { rects }: MiddlewareArguments ) {\n\t\t\t\treturn rects.reference;\n\t\t\t},\n\t\t},\n\t\tsize( {\n\t\t\tapply( { rects, elements } ) {\n\t\t\t\tconst { firstElementChild } = elements.floating ?? {};\n\n\t\t\t\t// Only HTMLElement instances have the `style` property.\n\t\t\t\tif ( ! ( firstElementChild instanceof HTMLElement ) ) return;\n\n\t\t\t\t// Reduce the height of the popover to the available space.\n\t\t\t\tObject.assign( firstElementChild.style, {\n\t\t\t\t\twidth: `${ rects.reference.width }px`,\n\t\t\t\t\theight: `${ rects.reference.height }px`,\n\t\t\t\t} );\n\t\t\t},\n\t\t} ),\n\t];\n}\n"]}
@@ -62,7 +62,7 @@ const POSITION_TO_PLACEMENT = {
62
62
  * Converts the `Popover`'s legacy "position" prop to the new "placement" prop
63
63
  * (used by `floating-ui`).
64
64
  *
65
- * @param position The legacy position
65
+ * @param position The legacy position
66
66
  * @return The corresponding placement
67
67
  */
68
68
 
@@ -137,14 +137,19 @@ const PLACEMENT_TO_ANIMATION_ORIGIN = {
137
137
  'left-end': {
138
138
  originX: 1,
139
139
  originY: 1
140
- } // open from bottom, right
140
+ },
141
+ // open from bottom, right
142
+ overlay: {
143
+ originX: 0.5,
144
+ originY: 0.5
145
+ } // open from center, center
141
146
 
142
147
  };
143
148
  /**
144
149
  * Given the floating-ui `placement`, compute the framer-motion props for the
145
150
  * popover's entry animation.
146
151
  *
147
- * @param placement A placement string from floating ui
152
+ * @param placement A placement string from floating ui
148
153
  * @return The object containing the motion props
149
154
  */
150
155
 
@@ -172,7 +177,7 @@ export const placementToMotionAnimationProps = placement => {
172
177
  /**
173
178
  * Returns the offset of a document's frame element.
174
179
  *
175
- * @param document The iframe's owner document.
180
+ * @param document The iframe's owner document.
176
181
  *
177
182
  * @return The offset of the document's frame element, or undefined if the
178
183
  * document has no frame element.
@@ -193,6 +198,24 @@ export const getFrameOffset = document => {
193
198
  y: iframeRect.top
194
199
  };
195
200
  };
201
+ export const getFrameScale = document => {
202
+ var _document$defaultView2;
203
+
204
+ const frameElement = document === null || document === void 0 ? void 0 : (_document$defaultView2 = document.defaultView) === null || _document$defaultView2 === void 0 ? void 0 : _document$defaultView2.frameElement;
205
+
206
+ if (!frameElement) {
207
+ return {
208
+ x: 1,
209
+ y: 1
210
+ };
211
+ }
212
+
213
+ const rect = frameElement.getBoundingClientRect();
214
+ return {
215
+ x: rect.width / frameElement.offsetWidth,
216
+ y: rect.height / frameElement.offsetHeight
217
+ };
218
+ };
196
219
  export const getReferenceOwnerDocument = _ref => {
197
220
  var _resultingReferenceOw;
198
221
 
@@ -242,7 +265,8 @@ export const getReferenceElement = _ref2 => {
242
265
  anchorRef,
243
266
  anchorRect,
244
267
  getAnchorRect,
245
- fallbackReferenceElement
268
+ fallbackReferenceElement,
269
+ scale
246
270
  } = _ref2;
247
271
  let referenceElement = null;
248
272
 
@@ -291,6 +315,18 @@ export const getReferenceElement = _ref2 => {
291
315
  // If no explicit ref is passed via props, fall back to
292
316
  // anchoring to the popover's parent node.
293
317
  referenceElement = fallbackReferenceElement.parentElement;
318
+ }
319
+
320
+ if (referenceElement && (scale.x !== 1 || scale.y !== 1)) {
321
+ // If the popover is inside an iframe, the coordinates of the
322
+ // reference element need to be scaled to match the iframe's scale.
323
+ const rect = referenceElement.getBoundingClientRect();
324
+ referenceElement = {
325
+ getBoundingClientRect() {
326
+ return new window.DOMRect(rect.x * scale.x, rect.y * scale.y, rect.width * scale.x, rect.height * scale.y);
327
+ }
328
+
329
+ };
294
330
  } // Convert any `undefined` value to `null`.
295
331
 
296
332
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/popover/utils.ts"],"names":["POSITION_TO_PLACEMENT","bottom","top","middle","positionToPlacement","position","PLACEMENT_TO_ANIMATION_ORIGIN","originX","originY","right","left","placementToMotionAnimationProps","placement","translateProp","startsWith","translateDirection","style","initial","opacity","scale","animate","transition","duration","ease","getFrameOffset","document","frameElement","defaultView","iframeRect","getBoundingClientRect","x","y","getReferenceOwnerDocument","anchor","anchorRef","anchorRect","getAnchorRect","fallbackReferenceElement","fallbackDocument","resultingReferenceOwnerDoc","ownerDocument","startContainer","current","getReferenceElement","referenceElement","topRect","bottomRect","window","DOMRect","width","rect","height","parentElement"],"mappings":"AAAA;AACA;AACA;AACA;;AAIA;AACA;AACA;AAOA,MAAMA,qBAGL,GAAG;AACHC,EAAAA,MAAM,EAAE,QADL;AAEHC,EAAAA,GAAG,EAAE,KAFF;AAGH,iBAAe,MAHZ;AAIH,kBAAgB,OAJb;AAKH,iBAAe,YALZ;AAMH,mBAAiB,QANd;AAOH,kBAAgB,cAPb;AAQH,cAAY,SART;AASH,gBAAc,KATX;AAUH,eAAa,WAVV;AAWH,sBAAoB,MAXjB;AAYH,uBAAqB,MAZlB;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C,6CAEImB,IAAI,CAAChD,GAFT,iBAGNgD,IAAI,CAACD,KAHC,qDAGQC,IAAI,CAACzC,KAAL,GAAayC,IAAI,CAACxC,IAH1B,kBAINwC,IAAI,CAACC,MAJC,uDAISD,IAAI,CAACjD,MAAL,GAAciD,IAAI,CAAChD,GAJ5B,CAAP;AAMA;;AATiB,KAAnB;AAWA,GAbM,MAaA,IAAKmC,wBAAL,EAAgC;AACtC;AACA;AACAO,IAAAA,gBAAgB,GAAGP,wBAAwB,CAACe,aAA5C;AACA,GA3D2B,CA6D5B;;;AACA,8BAAOR,gBAAP,iEAA2B,IAA3B;AACA,CA1EM","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { MotionProps } from 'framer-motion';\nimport type { ReferenceType } from '@floating-ui/react-dom';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tPopoverProps,\n\tPopoverAnchorRefReference,\n\tPopoverAnchorRefTopBottom,\n} from './types';\n\nconst POSITION_TO_PLACEMENT: Record<\n\tNonNullable< PopoverProps[ 'position' ] >,\n\tNonNullable< PopoverProps[ 'placement' ] >\n> = {\n\tbottom: 'bottom',\n\ttop: 'top',\n\t'middle left': 'left',\n\t'middle right': 'right',\n\t'bottom left': 'bottom-end',\n\t'bottom center': 'bottom',\n\t'bottom right': 'bottom-start',\n\t'top left': 'top-end',\n\t'top center': 'top',\n\t'top right': 'top-start',\n\t'middle left left': 'left',\n\t'middle left right': 'left',\n\t'middle left bottom': 'left-end',\n\t'middle left top': 'left-start',\n\t'middle right left': 'right',\n\t'middle right right': 'right',\n\t'middle right bottom': 'right-end',\n\t'middle right top': 'right-start',\n\t'bottom left left': 'bottom-end',\n\t'bottom left right': 'bottom-end',\n\t'bottom left bottom': 'bottom-end',\n\t'bottom left top': 'bottom-end',\n\t'bottom center left': 'bottom',\n\t'bottom center right': 'bottom',\n\t'bottom center bottom': 'bottom',\n\t'bottom center top': 'bottom',\n\t'bottom right left': 'bottom-start',\n\t'bottom right right': 'bottom-start',\n\t'bottom right bottom': 'bottom-start',\n\t'bottom right top': 'bottom-start',\n\t'top left left': 'top-end',\n\t'top left right': 'top-end',\n\t'top left bottom': 'top-end',\n\t'top left top': 'top-end',\n\t'top center left': 'top',\n\t'top center right': 'top',\n\t'top center bottom': 'top',\n\t'top center top': 'top',\n\t'top right left': 'top-start',\n\t'top right right': 'top-start',\n\t'top right bottom': 'top-start',\n\t'top right top': 'top-start',\n\t// `middle`/`middle center [corner?]` positions are associated to a fallback\n\t// `bottom` placement because there aren't any corresponding placement values.\n\tmiddle: 'bottom',\n\t'middle center': 'bottom',\n\t'middle center bottom': 'bottom',\n\t'middle center left': 'bottom',\n\t'middle center right': 'bottom',\n\t'middle center top': 'bottom',\n};\n\n/**\n * Converts the `Popover`'s legacy \"position\" prop to the new \"placement\" prop\n * (used by `floating-ui`).\n *\n * @param position The legacy position\n * @return The corresponding placement\n */\nexport const positionToPlacement = (\n\tposition: NonNullable< PopoverProps[ 'position' ] >\n): NonNullable< PopoverProps[ 'placement' ] > =>\n\tPOSITION_TO_PLACEMENT[ position ] ?? 'bottom';\n\n/**\n * @typedef AnimationOrigin\n * @type {Object}\n * @property {number} originX A number between 0 and 1 (in CSS logical properties jargon, 0 is \"start\", 0.5 is \"center\", and 1 is \"end\")\n * @property {number} originY A number between 0 and 1 (0 is top, 0.5 is center, and 1 is bottom)\n */\n\nconst PLACEMENT_TO_ANIMATION_ORIGIN: Record<\n\tNonNullable< PopoverProps[ 'placement' ] >,\n\t{ originX: number; originY: number }\n> = {\n\ttop: { originX: 0.5, originY: 1 }, // open from bottom, center\n\t'top-start': { originX: 0, originY: 1 }, // open from bottom, left\n\t'top-end': { originX: 1, originY: 1 }, // open from bottom, right\n\tright: { originX: 0, originY: 0.5 }, // open from middle, left\n\t'right-start': { originX: 0, originY: 0 }, // open from top, left\n\t'right-end': { originX: 0, originY: 1 }, // open from bottom, left\n\tbottom: { originX: 0.5, originY: 0 }, // open from top, center\n\t'bottom-start': { originX: 0, originY: 0 }, // open from top, left\n\t'bottom-end': { originX: 1, originY: 0 }, // open from top, right\n\tleft: { originX: 1, originY: 0.5 }, // open from middle, right\n\t'left-start': { originX: 1, originY: 0 }, // open from top, right\n\t'left-end': { originX: 1, originY: 1 }, // open from bottom, right\n};\n\n/**\n * Given the floating-ui `placement`, compute the framer-motion props for the\n * popover's entry animation.\n *\n * @param placement A placement string from floating ui\n * @return The object containing the motion props\n */\nexport const placementToMotionAnimationProps = (\n\tplacement: NonNullable< PopoverProps[ 'placement' ] >\n): MotionProps => {\n\tconst translateProp =\n\t\tplacement.startsWith( 'top' ) || placement.startsWith( 'bottom' )\n\t\t\t? 'translateY'\n\t\t\t: 'translateX';\n\tconst translateDirection =\n\t\tplacement.startsWith( 'top' ) || placement.startsWith( 'left' )\n\t\t\t? 1\n\t\t\t: -1;\n\n\treturn {\n\t\tstyle: PLACEMENT_TO_ANIMATION_ORIGIN[ placement ],\n\t\tinitial: {\n\t\t\topacity: 0,\n\t\t\tscale: 0,\n\t\t\t[ translateProp ]: `${ 2 * translateDirection }em`,\n\t\t},\n\t\tanimate: { opacity: 1, scale: 1, [ translateProp ]: 0 },\n\t\ttransition: { duration: 0.1, ease: [ 0, 0, 0.2, 1 ] },\n\t};\n};\n\n/**\n * Returns the offset of a document's frame element.\n *\n * @param document The iframe's owner document.\n *\n * @return The offset of the document's frame element, or undefined if the\n * document has no frame element.\n */\nexport const getFrameOffset = (\n\tdocument?: Document\n): { x: number; y: number } | undefined => {\n\tconst frameElement = document?.defaultView?.frameElement;\n\tif ( ! frameElement ) {\n\t\treturn;\n\t}\n\tconst iframeRect = frameElement.getBoundingClientRect();\n\treturn { x: iframeRect.left, y: iframeRect.top };\n};\n\nexport const getReferenceOwnerDocument = ( {\n\tanchor,\n\tanchorRef,\n\tanchorRect,\n\tgetAnchorRect,\n\tfallbackReferenceElement,\n\tfallbackDocument,\n}: Pick<\n\tPopoverProps,\n\t'anchorRef' | 'anchorRect' | 'getAnchorRect' | 'anchor'\n> & {\n\tfallbackReferenceElement: Element | null;\n\tfallbackDocument: Document;\n} ): Document => {\n\t// In floating-ui's terms:\n\t// - \"reference\" refers to the popover's anchor element.\n\t// - \"floating\" refers the floating popover's element.\n\t// A floating element can also be positioned relative to a virtual element,\n\t// instead of a real one. A virtual element is represented by an object\n\t// with the `getBoundingClientRect()` function (like real elements).\n\t// See https://floating-ui.com/docs/virtual-elements for more info.\n\tlet resultingReferenceOwnerDoc;\n\tif ( anchor ) {\n\t\tresultingReferenceOwnerDoc = anchor.ownerDocument;\n\t} else if ( ( anchorRef as PopoverAnchorRefTopBottom | undefined )?.top ) {\n\t\tresultingReferenceOwnerDoc = ( anchorRef as PopoverAnchorRefTopBottom )\n\t\t\t?.top.ownerDocument;\n\t} else if ( ( anchorRef as Range | undefined )?.startContainer ) {\n\t\tresultingReferenceOwnerDoc = ( anchorRef as Range ).startContainer\n\t\t\t.ownerDocument;\n\t} else if (\n\t\t( anchorRef as PopoverAnchorRefReference | undefined )?.current\n\t) {\n\t\tresultingReferenceOwnerDoc = (\n\t\t\t( anchorRef as PopoverAnchorRefReference ).current as Element\n\t\t ).ownerDocument;\n\t} else if ( anchorRef as Element | undefined ) {\n\t\t// This one should be deprecated.\n\t\tresultingReferenceOwnerDoc = ( anchorRef as Element ).ownerDocument;\n\t} else if ( anchorRect && anchorRect?.ownerDocument ) {\n\t\tresultingReferenceOwnerDoc = anchorRect.ownerDocument;\n\t} else if ( getAnchorRect ) {\n\t\tresultingReferenceOwnerDoc = getAnchorRect(\n\t\t\tfallbackReferenceElement\n\t\t)?.ownerDocument;\n\t}\n\n\treturn resultingReferenceOwnerDoc ?? fallbackDocument;\n};\n\nexport const getReferenceElement = ( {\n\tanchor,\n\tanchorRef,\n\tanchorRect,\n\tgetAnchorRect,\n\tfallbackReferenceElement,\n}: Pick<\n\tPopoverProps,\n\t'anchorRef' | 'anchorRect' | 'getAnchorRect' | 'anchor'\n> & {\n\tfallbackReferenceElement: Element | null;\n} ): ReferenceType | null => {\n\tlet referenceElement = null;\n\n\tif ( anchor ) {\n\t\treferenceElement = anchor;\n\t} else if ( ( anchorRef as PopoverAnchorRefTopBottom | undefined )?.top ) {\n\t\t// Create a virtual element for the ref. The expectation is that\n\t\t// if anchorRef.top is defined, then anchorRef.bottom is defined too.\n\t\t// Seems to be used by the block toolbar, when multiple blocks are selected\n\t\t// (top and bottom blocks are used to calculate the resulting rect).\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst topRect = (\n\t\t\t\t\tanchorRef as PopoverAnchorRefTopBottom\n\t\t\t\t ).top.getBoundingClientRect();\n\t\t\t\tconst bottomRect = (\n\t\t\t\t\tanchorRef as PopoverAnchorRefTopBottom\n\t\t\t\t ).bottom.getBoundingClientRect();\n\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\ttopRect.x,\n\t\t\t\t\ttopRect.y,\n\t\t\t\t\ttopRect.width,\n\t\t\t\t\tbottomRect.bottom - topRect.top\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t} else if (\n\t\t( anchorRef as PopoverAnchorRefReference | undefined )?.current\n\t) {\n\t\t// Standard React ref.\n\t\treferenceElement = ( anchorRef as PopoverAnchorRefReference ).current;\n\t} else if ( anchorRef as Element | undefined ) {\n\t\t// If `anchorRef` holds directly the element's value (no `current` key)\n\t\t// This is a weird scenario and should be deprecated.\n\t\treferenceElement = anchorRef as Element;\n\t} else if ( anchorRect ) {\n\t\t// Create a virtual element for the ref.\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn anchorRect;\n\t\t\t},\n\t\t};\n\t} else if ( getAnchorRect ) {\n\t\t// Create a virtual element for the ref.\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst rect = getAnchorRect( fallbackReferenceElement );\n\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\trect.x ?? rect.left,\n\t\t\t\t\trect.y ?? rect.top,\n\t\t\t\t\trect.width ?? rect.right - rect.left,\n\t\t\t\t\trect.height ?? rect.bottom - rect.top\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t} else if ( fallbackReferenceElement ) {\n\t\t// If no explicit ref is passed via props, fall back to\n\t\t// anchoring to the popover's parent node.\n\t\treferenceElement = fallbackReferenceElement.parentElement;\n\t}\n\n\t// Convert any `undefined` value to `null`.\n\treturn referenceElement ?? null;\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/popover/utils.ts"],"names":["POSITION_TO_PLACEMENT","bottom","top","middle","positionToPlacement","position","PLACEMENT_TO_ANIMATION_ORIGIN","originX","originY","right","left","overlay","placementToMotionAnimationProps","placement","translateProp","startsWith","translateDirection","style","initial","opacity","scale","animate","transition","duration","ease","getFrameOffset","document","frameElement","defaultView","iframeRect","getBoundingClientRect","x","y","getFrameScale","rect","width","offsetWidth","height","offsetHeight","getReferenceOwnerDocument","anchor","anchorRef","anchorRect","getAnchorRect","fallbackReferenceElement","fallbackDocument","resultingReferenceOwnerDoc","ownerDocument","startContainer","current","getReferenceElement","referenceElement","topRect","bottomRect","window","DOMRect","parentElement"],"mappings":"AAAA;AACA;AACA;AACA;;AAIA;AACA;AACA;AAOA,MAAMA,qBAGL,GAAG;AACHC,EAAAA,MAAM,EAAE,QADL;AAEHC,EAAAA,GAAG,EAAE,KAFF;AAGH,iBAAe,MAHZ;AAIH,kBAAgB,OAJb;AAKH,iBAAe,YALZ;AAMH,mBAAiB,QANd;AAOH,kBAAgB,cAPb;AAQH,cAAY,SART;AASH,gBAAc,KATX;AAUH,eAAa,WAVV;AAWH,sBAAoB,MAXjB;AAYH,uBAAqB,MAZlB;AAaH,wBAAsB,UAbnB;AAcH,qBAAmB,YAdhB;AAeH,uBAAqB,OAflB;AAgBH,wBAAsB,OAhBnB;AAiBH,yBAAuB,WAjBpB;AAkBH,sBAAoB,aAlBjB;AAmBH,sBAAoB,YAnBjB;AAoBH,uBAAqB,YApBlB;AAqBH,wBAAsB,YArBnB;AAsBH,qBAAmB,Y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B,KAAnB;AAUA,GA3E2B,CA6E5B;;;AACA,8BAAOmB,gBAAP,iEAA2B,IAA3B;AACA,CA5FM","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { MotionProps } from 'framer-motion';\nimport type { ReferenceType } from '@floating-ui/react-dom';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tPopoverProps,\n\tPopoverAnchorRefReference,\n\tPopoverAnchorRefTopBottom,\n} from './types';\n\nconst POSITION_TO_PLACEMENT: Record<\n\tNonNullable< PopoverProps[ 'position' ] >,\n\tNonNullable< PopoverProps[ 'placement' ] >\n> = {\n\tbottom: 'bottom',\n\ttop: 'top',\n\t'middle left': 'left',\n\t'middle right': 'right',\n\t'bottom left': 'bottom-end',\n\t'bottom center': 'bottom',\n\t'bottom right': 'bottom-start',\n\t'top left': 'top-end',\n\t'top center': 'top',\n\t'top right': 'top-start',\n\t'middle left left': 'left',\n\t'middle left right': 'left',\n\t'middle left bottom': 'left-end',\n\t'middle left top': 'left-start',\n\t'middle right left': 'right',\n\t'middle right right': 'right',\n\t'middle right bottom': 'right-end',\n\t'middle right top': 'right-start',\n\t'bottom left left': 'bottom-end',\n\t'bottom left right': 'bottom-end',\n\t'bottom left bottom': 'bottom-end',\n\t'bottom left top': 'bottom-end',\n\t'bottom center left': 'bottom',\n\t'bottom center right': 'bottom',\n\t'bottom center bottom': 'bottom',\n\t'bottom center top': 'bottom',\n\t'bottom right left': 'bottom-start',\n\t'bottom right right': 'bottom-start',\n\t'bottom right bottom': 'bottom-start',\n\t'bottom right top': 'bottom-start',\n\t'top left left': 'top-end',\n\t'top left right': 'top-end',\n\t'top left bottom': 'top-end',\n\t'top left top': 'top-end',\n\t'top center left': 'top',\n\t'top center right': 'top',\n\t'top center bottom': 'top',\n\t'top center top': 'top',\n\t'top right left': 'top-start',\n\t'top right right': 'top-start',\n\t'top right bottom': 'top-start',\n\t'top right top': 'top-start',\n\t// `middle`/`middle center [corner?]` positions are associated to a fallback\n\t// `bottom` placement because there aren't any corresponding placement values.\n\tmiddle: 'bottom',\n\t'middle center': 'bottom',\n\t'middle center bottom': 'bottom',\n\t'middle center left': 'bottom',\n\t'middle center right': 'bottom',\n\t'middle center top': 'bottom',\n};\n\n/**\n * Converts the `Popover`'s legacy \"position\" prop to the new \"placement\" prop\n * (used by `floating-ui`).\n *\n * @param position The legacy position\n * @return The corresponding placement\n */\nexport const positionToPlacement = (\n\tposition: NonNullable< PopoverProps[ 'position' ] >\n): NonNullable< PopoverProps[ 'placement' ] > =>\n\tPOSITION_TO_PLACEMENT[ position ] ?? 'bottom';\n\n/**\n * @typedef AnimationOrigin\n * @type {Object}\n * @property {number} originX A number between 0 and 1 (in CSS logical properties jargon, 0 is \"start\", 0.5 is \"center\", and 1 is \"end\")\n * @property {number} originY A number between 0 and 1 (0 is top, 0.5 is center, and 1 is bottom)\n */\n\nconst PLACEMENT_TO_ANIMATION_ORIGIN: Record<\n\tNonNullable< PopoverProps[ 'placement' ] >,\n\t{ originX: number; originY: number }\n> = {\n\ttop: { originX: 0.5, originY: 1 }, // open from bottom, center\n\t'top-start': { originX: 0, originY: 1 }, // open from bottom, left\n\t'top-end': { originX: 1, originY: 1 }, // open from bottom, right\n\tright: { originX: 0, originY: 0.5 }, // open from middle, left\n\t'right-start': { originX: 0, originY: 0 }, // open from top, left\n\t'right-end': { originX: 0, originY: 1 }, // open from bottom, left\n\tbottom: { originX: 0.5, originY: 0 }, // open from top, center\n\t'bottom-start': { originX: 0, originY: 0 }, // open from top, left\n\t'bottom-end': { originX: 1, originY: 0 }, // open from top, right\n\tleft: { originX: 1, originY: 0.5 }, // open from middle, right\n\t'left-start': { originX: 1, originY: 0 }, // open from top, right\n\t'left-end': { originX: 1, originY: 1 }, // open from bottom, right\n\toverlay: { originX: 0.5, originY: 0.5 }, // open from center, center\n};\n\n/**\n * Given the floating-ui `placement`, compute the framer-motion props for the\n * popover's entry animation.\n *\n * @param placement A placement string from floating ui\n * @return The object containing the motion props\n */\nexport const placementToMotionAnimationProps = (\n\tplacement: NonNullable< PopoverProps[ 'placement' ] >\n): MotionProps => {\n\tconst translateProp =\n\t\tplacement.startsWith( 'top' ) || placement.startsWith( 'bottom' )\n\t\t\t? 'translateY'\n\t\t\t: 'translateX';\n\tconst translateDirection =\n\t\tplacement.startsWith( 'top' ) || placement.startsWith( 'left' )\n\t\t\t? 1\n\t\t\t: -1;\n\n\treturn {\n\t\tstyle: PLACEMENT_TO_ANIMATION_ORIGIN[ placement ],\n\t\tinitial: {\n\t\t\topacity: 0,\n\t\t\tscale: 0,\n\t\t\t[ translateProp ]: `${ 2 * translateDirection }em`,\n\t\t},\n\t\tanimate: { opacity: 1, scale: 1, [ translateProp ]: 0 },\n\t\ttransition: { duration: 0.1, ease: [ 0, 0, 0.2, 1 ] },\n\t};\n};\n\n/**\n * Returns the offset of a document's frame element.\n *\n * @param document The iframe's owner document.\n *\n * @return The offset of the document's frame element, or undefined if the\n * document has no frame element.\n */\nexport const getFrameOffset = (\n\tdocument?: Document\n): { x: number; y: number } | undefined => {\n\tconst frameElement = document?.defaultView?.frameElement;\n\tif ( ! frameElement ) {\n\t\treturn;\n\t}\n\tconst iframeRect = frameElement.getBoundingClientRect();\n\treturn { x: iframeRect.left, y: iframeRect.top };\n};\n\nexport const getFrameScale = (\n\tdocument?: Document\n): {\n\tx: number;\n\ty: number;\n} => {\n\tconst frameElement = document?.defaultView?.frameElement as HTMLElement;\n\tif ( ! frameElement ) {\n\t\treturn { x: 1, y: 1 };\n\t}\n\tconst rect = frameElement.getBoundingClientRect();\n\treturn {\n\t\tx: rect.width / frameElement.offsetWidth,\n\t\ty: rect.height / frameElement.offsetHeight,\n\t};\n};\n\nexport const getReferenceOwnerDocument = ( {\n\tanchor,\n\tanchorRef,\n\tanchorRect,\n\tgetAnchorRect,\n\tfallbackReferenceElement,\n\tfallbackDocument,\n}: Pick<\n\tPopoverProps,\n\t'anchorRef' | 'anchorRect' | 'getAnchorRect' | 'anchor'\n> & {\n\tfallbackReferenceElement: Element | null;\n\tfallbackDocument: Document;\n} ): Document => {\n\t// In floating-ui's terms:\n\t// - \"reference\" refers to the popover's anchor element.\n\t// - \"floating\" refers the floating popover's element.\n\t// A floating element can also be positioned relative to a virtual element,\n\t// instead of a real one. A virtual element is represented by an object\n\t// with the `getBoundingClientRect()` function (like real elements).\n\t// See https://floating-ui.com/docs/virtual-elements for more info.\n\tlet resultingReferenceOwnerDoc;\n\tif ( anchor ) {\n\t\tresultingReferenceOwnerDoc = anchor.ownerDocument;\n\t} else if ( ( anchorRef as PopoverAnchorRefTopBottom | undefined )?.top ) {\n\t\tresultingReferenceOwnerDoc = ( anchorRef as PopoverAnchorRefTopBottom )\n\t\t\t?.top.ownerDocument;\n\t} else if ( ( anchorRef as Range | undefined )?.startContainer ) {\n\t\tresultingReferenceOwnerDoc = ( anchorRef as Range ).startContainer\n\t\t\t.ownerDocument;\n\t} else if (\n\t\t( anchorRef as PopoverAnchorRefReference | undefined )?.current\n\t) {\n\t\tresultingReferenceOwnerDoc = (\n\t\t\t( anchorRef as PopoverAnchorRefReference ).current as Element\n\t\t ).ownerDocument;\n\t} else if ( anchorRef as Element | undefined ) {\n\t\t// This one should be deprecated.\n\t\tresultingReferenceOwnerDoc = ( anchorRef as Element ).ownerDocument;\n\t} else if ( anchorRect && anchorRect?.ownerDocument ) {\n\t\tresultingReferenceOwnerDoc = anchorRect.ownerDocument;\n\t} else if ( getAnchorRect ) {\n\t\tresultingReferenceOwnerDoc = getAnchorRect(\n\t\t\tfallbackReferenceElement\n\t\t)?.ownerDocument;\n\t}\n\n\treturn resultingReferenceOwnerDoc ?? fallbackDocument;\n};\n\nexport const getReferenceElement = ( {\n\tanchor,\n\tanchorRef,\n\tanchorRect,\n\tgetAnchorRect,\n\tfallbackReferenceElement,\n\tscale,\n}: Pick<\n\tPopoverProps,\n\t'anchorRef' | 'anchorRect' | 'getAnchorRect' | 'anchor'\n> & {\n\tfallbackReferenceElement: Element | null;\n\tscale: { x: number; y: number };\n} ): ReferenceType | null => {\n\tlet referenceElement = null;\n\n\tif ( anchor ) {\n\t\treferenceElement = anchor;\n\t} else if ( ( anchorRef as PopoverAnchorRefTopBottom | undefined )?.top ) {\n\t\t// Create a virtual element for the ref. The expectation is that\n\t\t// if anchorRef.top is defined, then anchorRef.bottom is defined too.\n\t\t// Seems to be used by the block toolbar, when multiple blocks are selected\n\t\t// (top and bottom blocks are used to calculate the resulting rect).\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst topRect = (\n\t\t\t\t\tanchorRef as PopoverAnchorRefTopBottom\n\t\t\t\t ).top.getBoundingClientRect();\n\t\t\t\tconst bottomRect = (\n\t\t\t\t\tanchorRef as PopoverAnchorRefTopBottom\n\t\t\t\t ).bottom.getBoundingClientRect();\n\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\ttopRect.x,\n\t\t\t\t\ttopRect.y,\n\t\t\t\t\ttopRect.width,\n\t\t\t\t\tbottomRect.bottom - topRect.top\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t} else if (\n\t\t( anchorRef as PopoverAnchorRefReference | undefined )?.current\n\t) {\n\t\t// Standard React ref.\n\t\treferenceElement = ( anchorRef as PopoverAnchorRefReference ).current;\n\t} else if ( anchorRef as Element | undefined ) {\n\t\t// If `anchorRef` holds directly the element's value (no `current` key)\n\t\t// This is a weird scenario and should be deprecated.\n\t\treferenceElement = anchorRef as Element;\n\t} else if ( anchorRect ) {\n\t\t// Create a virtual element for the ref.\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn anchorRect;\n\t\t\t},\n\t\t};\n\t} else if ( getAnchorRect ) {\n\t\t// Create a virtual element for the ref.\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst rect = getAnchorRect( fallbackReferenceElement );\n\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\trect.x ?? rect.left,\n\t\t\t\t\trect.y ?? rect.top,\n\t\t\t\t\trect.width ?? rect.right - rect.left,\n\t\t\t\t\trect.height ?? rect.bottom - rect.top\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t} else if ( fallbackReferenceElement ) {\n\t\t// If no explicit ref is passed via props, fall back to\n\t\t// anchoring to the popover's parent node.\n\t\treferenceElement = fallbackReferenceElement.parentElement;\n\t}\n\n\tif ( referenceElement && ( scale.x !== 1 || scale.y !== 1 ) ) {\n\t\t// If the popover is inside an iframe, the coordinates of the\n\t\t// reference element need to be scaled to match the iframe's scale.\n\t\tconst rect = referenceElement.getBoundingClientRect();\n\t\treferenceElement = {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\trect.x * scale.x,\n\t\t\t\t\trect.y * scale.y,\n\t\t\t\t\trect.width * scale.x,\n\t\t\t\t\trect.height * scale.y\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n\n\t// Convert any `undefined` value to `null`.\n\treturn referenceElement ?? null;\n};\n"]}
@@ -9,7 +9,7 @@ import { groupBy } from 'lodash';
9
9
  /**
10
10
  * Returns terms in a tree form.
11
11
  *
12
- * @param flatTerms Array of terms in flat format.
12
+ * @param flatTerms Array of terms in flat format.
13
13
  *
14
14
  * @return Terms in tree format.
15
15
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/query-controls/terms.ts"],"names":["groupBy","buildTermsTree","flatTerms","flatTermsWithParentAndChildren","map","term","children","parent","id","String","termsByParent","null","length","fillWithChildren","terms"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAT,CAAyBC,SAAzB,EAAuE;AAC7E,QAAMC,8BAA2D,GAChED,SAAS,CAACE,GAAV,CAAiBC,IAAF,IAAY;AAC1B,WAAO;AACNC,MAAAA,QAAQ,EAAE,EADJ;AAENC,MAAAA,MAAM,EAAE,IAFF;AAGN,SAAGF,IAHG;AAING,MAAAA,EAAE,EAAEC,MAAM,CAAEJ,IAAI,CAACG,EAAP;AAJJ,KAAP;AAMA,GAPD,CADD;AAUA,QAAME,aAA4B,GAAGV,OAAO,CAC3CG,8BAD2C,EAE3C,QAF2C,CAA5C;;AAIA,MAAKO,aAAa,CAACC,IAAd,IAAsBD,aAAa,CAACC,IAAd,CAAmBC,MAA9C,EAAuD;AACtD,WAAOT,8BAAP;AACA;;AACD,QAAMU,gBAAgB,GACrBC,KADwB,IAES;AACjC,WAAOA,KAAK,CAACV,GAAN,CAAaC,IAAF,IAAY;AAC7B,YAAMC,QAAQ,GAAGI,aAAa,CAAEL,IAAI,CAACG,EAAP,CAA9B;AACA,aAAO,EACN,GAAGH,IADG;AAENC,QAAAA,QAAQ,EACPA,QAAQ,IAAIA,QAAQ,CAACM,MAArB,GACGC,gBAAgB,CAAEP,QAAF,CADnB,GAEG;AALE,OAAP;AAOA,KATM,CAAP;AAUA,GAbD;;AAeA,SAAOO,gBAAgB,CAAEH,aAAa,CAAE,GAAF,CAAb,IAAwB,EAA1B,CAAvB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { groupBy } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tAuthor,\n\tCategory,\n\tTermWithParentAndChildren,\n\tTermsByParent,\n} from './types';\n\n/**\n * Returns terms in a tree form.\n *\n * @param flatTerms Array of terms in flat format.\n *\n * @return Terms in tree format.\n */\nexport function buildTermsTree( flatTerms: readonly ( Author | Category )[] ) {\n\tconst flatTermsWithParentAndChildren: TermWithParentAndChildren[] =\n\t\tflatTerms.map( ( term ) => {\n\t\t\treturn {\n\t\t\t\tchildren: [],\n\t\t\t\tparent: null,\n\t\t\t\t...term,\n\t\t\t\tid: String( term.id ),\n\t\t\t};\n\t\t} );\n\n\tconst termsByParent: TermsByParent = groupBy(\n\t\tflatTermsWithParentAndChildren,\n\t\t'parent'\n\t);\n\tif ( termsByParent.null && termsByParent.null.length ) {\n\t\treturn flatTermsWithParentAndChildren;\n\t}\n\tconst fillWithChildren = (\n\t\tterms: TermWithParentAndChildren[]\n\t): TermWithParentAndChildren[] => {\n\t\treturn terms.map( ( term ) => {\n\t\t\tconst children = termsByParent[ term.id ];\n\t\t\treturn {\n\t\t\t\t...term,\n\t\t\t\tchildren:\n\t\t\t\t\tchildren && children.length\n\t\t\t\t\t\t? fillWithChildren( children )\n\t\t\t\t\t\t: [],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn fillWithChildren( termsByParent[ '0' ] || [] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/query-controls/terms.ts"],"names":["groupBy","buildTermsTree","flatTerms","flatTermsWithParentAndChildren","map","term","children","parent","id","String","termsByParent","null","length","fillWithChildren","terms"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAT,CAAyBC,SAAzB,EAAuE;AAC7E,QAAMC,8BAA2D,GAChED,SAAS,CAACE,GAAV,CAAiBC,IAAF,IAAY;AAC1B,WAAO;AACNC,MAAAA,QAAQ,EAAE,EADJ;AAENC,MAAAA,MAAM,EAAE,IAFF;AAGN,SAAGF,IAHG;AAING,MAAAA,EAAE,EAAEC,MAAM,CAAEJ,IAAI,CAACG,EAAP;AAJJ,KAAP;AAMA,GAPD,CADD;AAUA,QAAME,aAA4B,GAAGV,OAAO,CAC3CG,8BAD2C,EAE3C,QAF2C,CAA5C;;AAIA,MAAKO,aAAa,CAACC,IAAd,IAAsBD,aAAa,CAACC,IAAd,CAAmBC,MAA9C,EAAuD;AACtD,WAAOT,8BAAP;AACA;;AACD,QAAMU,gBAAgB,GACrBC,KADwB,IAES;AACjC,WAAOA,KAAK,CAACV,GAAN,CAAaC,IAAF,IAAY;AAC7B,YAAMC,QAAQ,GAAGI,aAAa,CAAEL,IAAI,CAACG,EAAP,CAA9B;AACA,aAAO,EACN,GAAGH,IADG;AAENC,QAAAA,QAAQ,EACPA,QAAQ,IAAIA,QAAQ,CAACM,MAArB,GACGC,gBAAgB,CAAEP,QAAF,CADnB,GAEG;AALE,OAAP;AAOA,KATM,CAAP;AAUA,GAbD;;AAeA,SAAOO,gBAAgB,CAAEH,aAAa,CAAE,GAAF,CAAb,IAAwB,EAA1B,CAAvB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { groupBy } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tAuthor,\n\tCategory,\n\tTermWithParentAndChildren,\n\tTermsByParent,\n} from './types';\n\n/**\n * Returns terms in a tree form.\n *\n * @param flatTerms Array of terms in flat format.\n *\n * @return Terms in tree format.\n */\nexport function buildTermsTree( flatTerms: readonly ( Author | Category )[] ) {\n\tconst flatTermsWithParentAndChildren: TermWithParentAndChildren[] =\n\t\tflatTerms.map( ( term ) => {\n\t\t\treturn {\n\t\t\t\tchildren: [],\n\t\t\t\tparent: null,\n\t\t\t\t...term,\n\t\t\t\tid: String( term.id ),\n\t\t\t};\n\t\t} );\n\n\tconst termsByParent: TermsByParent = groupBy(\n\t\tflatTermsWithParentAndChildren,\n\t\t'parent'\n\t);\n\tif ( termsByParent.null && termsByParent.null.length ) {\n\t\treturn flatTermsWithParentAndChildren;\n\t}\n\tconst fillWithChildren = (\n\t\tterms: TermWithParentAndChildren[]\n\t): TermWithParentAndChildren[] => {\n\t\treturn terms.map( ( term ) => {\n\t\t\tconst children = termsByParent[ term.id ];\n\t\t\treturn {\n\t\t\t\t...term,\n\t\t\t\tchildren:\n\t\t\t\t\tchildren && children.length\n\t\t\t\t\t\t? fillWithChildren( children )\n\t\t\t\t\t\t: [],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn fillWithChildren( termsByParent[ '0' ] || [] );\n}\n"]}
@@ -12,9 +12,9 @@ import { clamp } from '../utils/math';
12
12
  /**
13
13
  * A float supported clamp function for a specific value.
14
14
  *
15
- * @param value The value to clamp.
16
- * @param min The minimum value.
17
- * @param max The maximum value.
15
+ * @param value The value to clamp.
16
+ * @param min The minimum value.
17
+ * @param max The maximum value.
18
18
  *
19
19
  * @return A (float) number
20
20
  */
@@ -28,7 +28,7 @@ export function floatClamp(value, min, max) {
28
28
  /**
29
29
  * Hook to store a clamped value, derived from props.
30
30
  *
31
- * @param settings
31
+ * @param settings
32
32
  * @return The controlled value and the value setter.
33
33
  */
34
34
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/range-control/utils.ts"],"names":["useCallback","useControlledState","clamp","floatClamp","value","min","max","parseFloat","useControlledRangeValue","settings","valueProp","initial","state","setInternalState","fallback","setState","nextValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,SAASC,kBAAT,QAAmC,gBAAnC;AACA,SAASC,KAAT,QAAsB,eAAtB;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAT,CAAqBC,KAArB,EAA2CC,GAA3C,EAAwDC,GAAxD,EAAsE;AAC5E,MAAK,OAAOF,KAAP,KAAiB,QAAtB,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,SAAOG,UAAU,CAAG,GAAGL,KAAK,CAAEE,KAAF,EAASC,GAAT,EAAcC,GAAd,CAAqB,EAAhC,CAAjB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,uBAAT,CACNC,QADM,EAEL;AACD,QAAM;AAAEJ,IAAAA,GAAF;AAAOC,IAAAA,GAAP;AAAYF,IAAAA,KAAK,EAAEM,SAAnB;AAA8BC,IAAAA;AAA9B,MAA0CF,QAAhD;AACA,QAAM,CAAEG,KAAF,EAASC,gBAAT,IAA8BZ,kBAAkB,CACrDE,UAAU,CAAEO,SAAF,EAAaL,GAAb,EAAkBC,GAAlB,CAD2C,EAErD;AACCK,IAAAA,OAAO,EAAER,UAAU,CAAEQ,OAAF,aAAEA,OAAF,cAAEA,OAAF,GAAa,IAAb,EAAmBN,GAAnB,EAAwBC,GAAxB,CADpB;AAECQ,IAAAA,QAAQ,EAAE;AAFX,GAFqD,CAAtD;AAQA,QAAMC,QAAQ,GAAGf,WAAW,CACzBgB,SAAF,IAAgC;AAC/B,QAAKA,SAAS,KAAK,IAAnB,EAA0B;AACzBH,MAAAA,gBAAgB,CAAE,IAAF,CAAhB;AACA,KAFD,MAEO;AACNA,MAAAA,gBAAgB,CAAEV,UAAU,CAAEa,SAAF,EAAaX,GAAb,EAAkBC,GAAlB,CAAZ,CAAhB;AACA;AACD,GAP0B,EAQ3B,CAAED,GAAF,EAAOC,GAAP,EAAYO,gBAAZ,CAR2B,CAA5B,CAVC,CAqBD;AACA;;AACA,SAAO,CAAED,KAAF,EAAwCG,QAAxC,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useControlledState } from '../utils/hooks';\nimport { clamp } from '../utils/math';\n\nimport type { UseControlledRangeValueArgs } from './types';\n\n/**\n * A float supported clamp function for a specific value.\n *\n * @param value The value to clamp.\n * @param min The minimum value.\n * @param max The maximum value.\n *\n * @return A (float) number\n */\nexport function floatClamp( value: number | null, min: number, max: number ) {\n\tif ( typeof value !== 'number' ) {\n\t\treturn null;\n\t}\n\n\treturn parseFloat( `${ clamp( value, min, max ) }` );\n}\n\n/**\n * Hook to store a clamped value, derived from props.\n *\n * @param settings\n * @return The controlled value and the value setter.\n */\nexport function useControlledRangeValue(\n\tsettings: UseControlledRangeValueArgs\n) {\n\tconst { min, max, value: valueProp, initial } = settings;\n\tconst [ state, setInternalState ] = useControlledState(\n\t\tfloatClamp( valueProp, min, max ),\n\t\t{\n\t\t\tinitial: floatClamp( initial ?? null, min, max ),\n\t\t\tfallback: null,\n\t\t}\n\t);\n\n\tconst setState = useCallback(\n\t\t( nextValue: number | null ) => {\n\t\t\tif ( nextValue === null ) {\n\t\t\t\tsetInternalState( null );\n\t\t\t} else {\n\t\t\t\tsetInternalState( floatClamp( nextValue, min, max ) );\n\t\t\t}\n\t\t},\n\t\t[ min, max, setInternalState ]\n\t);\n\n\t// `state` can't be an empty string because we specified a fallback value of\n\t// `null` in `useControlledState`\n\treturn [ state as Exclude< typeof state, '' >, setState ] as const;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/range-control/utils.ts"],"names":["useCallback","useControlledState","clamp","floatClamp","value","min","max","parseFloat","useControlledRangeValue","settings","valueProp","initial","state","setInternalState","fallback","setState","nextValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,SAASC,kBAAT,QAAmC,gBAAnC;AACA,SAASC,KAAT,QAAsB,eAAtB;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAT,CAAqBC,KAArB,EAA2CC,GAA3C,EAAwDC,GAAxD,EAAsE;AAC5E,MAAK,OAAOF,KAAP,KAAiB,QAAtB,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,SAAOG,UAAU,CAAG,GAAGL,KAAK,CAAEE,KAAF,EAASC,GAAT,EAAcC,GAAd,CAAqB,EAAhC,CAAjB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,uBAAT,CACNC,QADM,EAEL;AACD,QAAM;AAAEJ,IAAAA,GAAF;AAAOC,IAAAA,GAAP;AAAYF,IAAAA,KAAK,EAAEM,SAAnB;AAA8BC,IAAAA;AAA9B,MAA0CF,QAAhD;AACA,QAAM,CAAEG,KAAF,EAASC,gBAAT,IAA8BZ,kBAAkB,CACrDE,UAAU,CAAEO,SAAF,EAAaL,GAAb,EAAkBC,GAAlB,CAD2C,EAErD;AACCK,IAAAA,OAAO,EAAER,UAAU,CAAEQ,OAAF,aAAEA,OAAF,cAAEA,OAAF,GAAa,IAAb,EAAmBN,GAAnB,EAAwBC,GAAxB,CADpB;AAECQ,IAAAA,QAAQ,EAAE;AAFX,GAFqD,CAAtD;AAQA,QAAMC,QAAQ,GAAGf,WAAW,CACzBgB,SAAF,IAAgC;AAC/B,QAAKA,SAAS,KAAK,IAAnB,EAA0B;AACzBH,MAAAA,gBAAgB,CAAE,IAAF,CAAhB;AACA,KAFD,MAEO;AACNA,MAAAA,gBAAgB,CAAEV,UAAU,CAAEa,SAAF,EAAaX,GAAb,EAAkBC,GAAlB,CAAZ,CAAhB;AACA;AACD,GAP0B,EAQ3B,CAAED,GAAF,EAAOC,GAAP,EAAYO,gBAAZ,CAR2B,CAA5B,CAVC,CAqBD;AACA;;AACA,SAAO,CAAED,KAAF,EAAwCG,QAAxC,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useControlledState } from '../utils/hooks';\nimport { clamp } from '../utils/math';\n\nimport type { UseControlledRangeValueArgs } from './types';\n\n/**\n * A float supported clamp function for a specific value.\n *\n * @param value The value to clamp.\n * @param min The minimum value.\n * @param max The maximum value.\n *\n * @return A (float) number\n */\nexport function floatClamp( value: number | null, min: number, max: number ) {\n\tif ( typeof value !== 'number' ) {\n\t\treturn null;\n\t}\n\n\treturn parseFloat( `${ clamp( value, min, max ) }` );\n}\n\n/**\n * Hook to store a clamped value, derived from props.\n *\n * @param settings\n * @return The controlled value and the value setter.\n */\nexport function useControlledRangeValue(\n\tsettings: UseControlledRangeValueArgs\n) {\n\tconst { min, max, value: valueProp, initial } = settings;\n\tconst [ state, setInternalState ] = useControlledState(\n\t\tfloatClamp( valueProp, min, max ),\n\t\t{\n\t\t\tinitial: floatClamp( initial ?? null, min, max ),\n\t\t\tfallback: null,\n\t\t}\n\t);\n\n\tconst setState = useCallback(\n\t\t( nextValue: number | null ) => {\n\t\t\tif ( nextValue === null ) {\n\t\t\t\tsetInternalState( null );\n\t\t\t} else {\n\t\t\t\tsetInternalState( floatClamp( nextValue, min, max ) );\n\t\t\t}\n\t\t},\n\t\t[ min, max, setInternalState ]\n\t);\n\n\t// `state` can't be an empty string because we specified a fallback value of\n\t// `null` in `useControlledState`\n\treturn [ state as Exclude< typeof state, '' >, setState ] as const;\n}\n"]}