@wordpress/components 23.8.0 → 24.0.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 (389) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/CONTRIBUTING.md +65 -1
  3. package/README.md +1 -3
  4. package/build/autocomplete/autocompleter-ui.js +0 -2
  5. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  6. package/build/autocomplete/index.js +2 -0
  7. package/build/autocomplete/index.js.map +1 -1
  8. package/build/button/index.js +2 -0
  9. package/build/button/index.js.map +1 -1
  10. package/build/card/card-media/component.js +2 -1
  11. package/build/card/card-media/component.js.map +1 -1
  12. package/build/checkbox-control/index.js +2 -2
  13. package/build/checkbox-control/index.js.map +1 -1
  14. package/build/color-palette/index.native.js +12 -0
  15. package/build/color-palette/index.native.js.map +1 -1
  16. package/build/combobox-control/index.js +7 -5
  17. package/build/combobox-control/index.js.map +1 -1
  18. package/build/combobox-control/styles.js +3 -3
  19. package/build/combobox-control/styles.js.map +1 -1
  20. package/build/custom-gradient-picker/index.native.js +3 -1
  21. package/build/custom-gradient-picker/index.native.js.map +1 -1
  22. package/build/dimension-control/index.js +1 -1
  23. package/build/dimension-control/index.js.map +1 -1
  24. package/build/draggable/index.js +8 -8
  25. package/build/draggable/index.js.map +1 -1
  26. package/build/form-token-field/index.js +5 -3
  27. package/build/form-token-field/index.js.map +1 -1
  28. package/build/form-token-field/styles.js +3 -3
  29. package/build/form-token-field/styles.js.map +1 -1
  30. package/build/index.js.map +1 -1
  31. package/build/mobile/bottom-sheet/cell.native.js +6 -6
  32. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  33. package/build/mobile/color-settings/palette.screen.native.js +0 -8
  34. package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
  35. package/build/mobile/global-styles-context/index.native.js +13 -1
  36. package/build/mobile/global-styles-context/index.native.js.map +1 -1
  37. package/build/mobile/global-styles-context/utils.native.js +21 -4
  38. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  39. package/build/mobile/link-picker/link-picker-results.native.js +3 -1
  40. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  41. package/build/mobile/segmented-control/index.native.js +4 -2
  42. package/build/mobile/segmented-control/index.native.js.map +1 -1
  43. package/build/modal/index.js +2 -1
  44. package/build/modal/index.js.map +1 -1
  45. package/build/navigable-container/container.js +39 -19
  46. package/build/navigable-container/container.js.map +1 -1
  47. package/build/navigable-container/index.js.map +1 -1
  48. package/build/navigable-container/menu.js +37 -5
  49. package/build/navigable-container/menu.js.map +1 -1
  50. package/build/navigable-container/tabbable.js +45 -4
  51. package/build/navigable-container/tabbable.js.map +1 -1
  52. package/build/navigable-container/types.js +6 -0
  53. package/build/navigable-container/types.js.map +1 -0
  54. package/build/navigator/navigator-screen/component.js +1 -1
  55. package/build/navigator/navigator-screen/component.js.map +1 -1
  56. package/build/palette-edit/index.js +34 -12
  57. package/build/palette-edit/index.js.map +1 -1
  58. package/build/popover/index.js +1 -8
  59. package/build/popover/index.js.map +1 -1
  60. package/build/private-apis.js +4 -1
  61. package/build/private-apis.js.map +1 -1
  62. package/build/sandbox/index.native.js +10 -3
  63. package/build/sandbox/index.native.js.map +1 -1
  64. package/build/slot-fill/bubbles-virtually/fill.js +2 -1
  65. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  66. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +45 -35
  67. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  68. package/build/slot-fill/bubbles-virtually/use-slot.js +11 -26
  69. package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  70. package/build/slot-fill/fill.js +7 -31
  71. package/build/slot-fill/fill.js.map +1 -1
  72. package/build/slot-fill/index.js +20 -7
  73. package/build/slot-fill/index.js.map +1 -1
  74. package/build/slot-fill/provider.js +0 -6
  75. package/build/slot-fill/provider.js.map +1 -1
  76. package/build/slot-fill/slot.js +0 -5
  77. package/build/slot-fill/slot.js.map +1 -1
  78. package/build/spinner/styles.js +4 -4
  79. package/build/spinner/styles.js.map +1 -1
  80. package/build/tab-panel/index.js.map +1 -1
  81. package/build/theme/color-algorithms.js +1 -1
  82. package/build/theme/color-algorithms.js.map +1 -1
  83. package/build/toolbar/toolbar-button/index.js +1 -2
  84. package/build/toolbar/toolbar-button/index.js.map +1 -1
  85. package/build/toolbar/toolbar-item/index.js +4 -2
  86. package/build/toolbar/toolbar-item/index.js.map +1 -1
  87. package/build/tree-grid/index.js +3 -3
  88. package/build/tree-grid/index.js.map +1 -1
  89. package/build/utils/colors-values.js +3 -3
  90. package/build/utils/colors-values.js.map +1 -1
  91. package/build/utils/use-deprecated-props.js +35 -0
  92. package/build/utils/use-deprecated-props.js.map +1 -0
  93. package/build/view/component.js +1 -2
  94. package/build/view/component.js.map +1 -1
  95. package/build-module/autocomplete/autocompleter-ui.js +1 -3
  96. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  97. package/build-module/autocomplete/index.js +3 -3
  98. package/build-module/autocomplete/index.js.map +1 -1
  99. package/build-module/button/index.js +2 -0
  100. package/build-module/button/index.js.map +1 -1
  101. package/build-module/card/card-media/component.js +2 -1
  102. package/build-module/card/card-media/component.js.map +1 -1
  103. package/build-module/checkbox-control/index.js +2 -2
  104. package/build-module/checkbox-control/index.js.map +1 -1
  105. package/build-module/color-palette/index.native.js +13 -1
  106. package/build-module/color-palette/index.native.js.map +1 -1
  107. package/build-module/combobox-control/index.js +6 -5
  108. package/build-module/combobox-control/index.js.map +1 -1
  109. package/build-module/combobox-control/styles.js +3 -3
  110. package/build-module/combobox-control/styles.js.map +1 -1
  111. package/build-module/custom-gradient-picker/index.native.js +3 -1
  112. package/build-module/custom-gradient-picker/index.native.js.map +1 -1
  113. package/build-module/dimension-control/index.js +1 -1
  114. package/build-module/dimension-control/index.js.map +1 -1
  115. package/build-module/draggable/index.js +8 -8
  116. package/build-module/draggable/index.js.map +1 -1
  117. package/build-module/form-token-field/index.js +4 -3
  118. package/build-module/form-token-field/index.js.map +1 -1
  119. package/build-module/form-token-field/styles.js +3 -3
  120. package/build-module/form-token-field/styles.js.map +1 -1
  121. package/build-module/index.js.map +1 -1
  122. package/build-module/mobile/bottom-sheet/cell.native.js +6 -5
  123. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  124. package/build-module/mobile/color-settings/palette.screen.native.js +0 -8
  125. package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
  126. package/build-module/mobile/global-styles-context/index.native.js +13 -1
  127. package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
  128. package/build-module/mobile/global-styles-context/utils.native.js +21 -3
  129. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  130. package/build-module/mobile/link-picker/link-picker-results.native.js +3 -1
  131. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  132. package/build-module/mobile/segmented-control/index.native.js +4 -2
  133. package/build-module/mobile/segmented-control/index.native.js.map +1 -1
  134. package/build-module/modal/index.js +2 -1
  135. package/build-module/modal/index.js.map +1 -1
  136. package/build-module/navigable-container/container.js +43 -19
  137. package/build-module/navigable-container/container.js.map +1 -1
  138. package/build-module/navigable-container/index.js +0 -2
  139. package/build-module/navigable-container/index.js.map +1 -1
  140. package/build-module/navigable-container/menu.js +36 -4
  141. package/build-module/navigable-container/menu.js.map +1 -1
  142. package/build-module/navigable-container/tabbable.js +44 -3
  143. package/build-module/navigable-container/tabbable.js.map +1 -1
  144. package/build-module/navigable-container/types.js +2 -0
  145. package/build-module/navigable-container/types.js.map +1 -0
  146. package/build-module/navigator/navigator-screen/component.js +1 -1
  147. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  148. package/build-module/palette-edit/index.js +34 -13
  149. package/build-module/palette-edit/index.js.map +1 -1
  150. package/build-module/popover/index.js +1 -8
  151. package/build-module/popover/index.js.map +1 -1
  152. package/build-module/private-apis.js +3 -1
  153. package/build-module/private-apis.js.map +1 -1
  154. package/build-module/sandbox/index.native.js +10 -3
  155. package/build-module/sandbox/index.native.js.map +1 -1
  156. package/build-module/slot-fill/bubbles-virtually/fill.js +2 -1
  157. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  158. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -36
  159. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  160. package/build-module/slot-fill/bubbles-virtually/use-slot.js +12 -27
  161. package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  162. package/build-module/slot-fill/fill.js +7 -31
  163. package/build-module/slot-fill/fill.js.map +1 -1
  164. package/build-module/slot-fill/index.js +17 -8
  165. package/build-module/slot-fill/index.js.map +1 -1
  166. package/build-module/slot-fill/provider.js +0 -6
  167. package/build-module/slot-fill/provider.js.map +1 -1
  168. package/build-module/slot-fill/slot.js +0 -5
  169. package/build-module/slot-fill/slot.js.map +1 -1
  170. package/build-module/spinner/styles.js +4 -4
  171. package/build-module/spinner/styles.js.map +1 -1
  172. package/build-module/tab-panel/index.js.map +1 -1
  173. package/build-module/theme/color-algorithms.js +1 -1
  174. package/build-module/theme/color-algorithms.js.map +1 -1
  175. package/build-module/toolbar/toolbar-button/index.js +1 -2
  176. package/build-module/toolbar/toolbar-button/index.js.map +1 -1
  177. package/build-module/toolbar/toolbar-item/index.js +5 -2
  178. package/build-module/toolbar/toolbar-item/index.js.map +1 -1
  179. package/build-module/tree-grid/index.js +3 -3
  180. package/build-module/tree-grid/index.js.map +1 -1
  181. package/build-module/utils/colors-values.js +3 -3
  182. package/build-module/utils/colors-values.js.map +1 -1
  183. package/build-module/utils/use-deprecated-props.js +25 -0
  184. package/build-module/utils/use-deprecated-props.js.map +1 -0
  185. package/build-module/view/component.js +1 -2
  186. package/build-module/view/component.js.map +1 -1
  187. package/build-style/style-rtl.css +83 -70
  188. package/build-style/style.css +83 -70
  189. package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
  190. package/build-types/autocomplete/index.d.ts.map +1 -1
  191. package/build-types/autocomplete/types.d.ts +2 -18
  192. package/build-types/autocomplete/types.d.ts.map +1 -1
  193. package/build-types/box-control/styles/box-control-styles.d.ts +1 -1
  194. package/build-types/button/deprecated.d.ts +12 -6
  195. package/build-types/button/deprecated.d.ts.map +1 -1
  196. package/build-types/button/index.d.ts.map +1 -1
  197. package/build-types/button/types.d.ts +7 -0
  198. package/build-types/button/types.d.ts.map +1 -1
  199. package/build-types/card/card-media/component.d.ts +2 -1
  200. package/build-types/card/card-media/component.d.ts.map +1 -1
  201. package/build-types/card/stories/index.d.ts +21 -1
  202. package/build-types/card/stories/index.d.ts.map +1 -1
  203. package/build-types/checkbox-control/index.d.ts.map +1 -1
  204. package/build-types/color-palette/styles.d.ts +1 -1
  205. package/build-types/color-picker/styles.d.ts +3 -3
  206. package/build-types/combobox-control/index.d.ts +1 -1
  207. package/build-types/combobox-control/index.d.ts.map +1 -1
  208. package/build-types/combobox-control/stories/index.d.ts.map +1 -1
  209. package/build-types/combobox-control/styles.d.ts +1 -1
  210. package/build-types/combobox-control/types.d.ts +8 -1
  211. package/build-types/combobox-control/types.d.ts.map +1 -1
  212. package/build-types/date-time/date/styles.d.ts +1 -1
  213. package/build-types/date-time/time/styles.d.ts +4 -4
  214. package/build-types/dimension-control/index.d.ts +1 -1
  215. package/build-types/draggable/index.d.ts +1 -1
  216. package/build-types/draggable/index.d.ts.map +1 -1
  217. package/build-types/draggable/stories/index.d.ts +8 -0
  218. package/build-types/draggable/stories/index.d.ts.map +1 -1
  219. package/build-types/draggable/types.d.ts +7 -0
  220. package/build-types/draggable/types.d.ts.map +1 -1
  221. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  222. package/build-types/form-token-field/index.d.ts.map +1 -1
  223. package/build-types/form-token-field/styles.d.ts +1 -1
  224. package/build-types/form-token-field/types.d.ts +8 -1
  225. package/build-types/form-token-field/types.d.ts.map +1 -1
  226. package/build-types/index.d.ts +1 -0
  227. package/build-types/index.d.ts.map +1 -1
  228. package/build-types/modal/index.d.ts.map +1 -1
  229. package/build-types/navigable-container/container.d.ts +20 -1
  230. package/build-types/navigable-container/container.d.ts.map +1 -1
  231. package/build-types/navigable-container/index.d.ts +5 -2
  232. package/build-types/navigable-container/index.d.ts.map +1 -1
  233. package/build-types/navigable-container/menu.d.ts +45 -11
  234. package/build-types/navigable-container/menu.d.ts.map +1 -1
  235. package/build-types/navigable-container/stories/navigable-menu.d.ts +12 -0
  236. package/build-types/navigable-container/stories/navigable-menu.d.ts.map +1 -0
  237. package/build-types/navigable-container/stories/tabbable-container.d.ts +12 -0
  238. package/build-types/navigable-container/stories/tabbable-container.d.ts.map +1 -0
  239. package/build-types/navigable-container/tabbable.d.ts +52 -9
  240. package/build-types/navigable-container/tabbable.d.ts.map +1 -1
  241. package/build-types/navigable-container/test/navigable-menu.d.ts +2 -0
  242. package/build-types/navigable-container/test/navigable-menu.d.ts.map +1 -0
  243. package/build-types/navigable-container/test/tababble-container.d.ts +2 -0
  244. package/build-types/navigable-container/test/tababble-container.d.ts.map +1 -0
  245. package/build-types/navigable-container/types.d.ts +61 -0
  246. package/build-types/navigable-container/types.d.ts.map +1 -0
  247. package/build-types/navigation/styles/navigation-styles.d.ts +1 -1
  248. package/build-types/navigator/navigator-back-button/component.d.ts +2 -1
  249. package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
  250. package/build-types/navigator/navigator-back-button/hook.d.ts +2 -1
  251. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  252. package/build-types/navigator/navigator-button/component.d.ts +2 -1
  253. package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
  254. package/build-types/navigator/navigator-button/hook.d.ts +2 -1
  255. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  256. package/build-types/navigator/navigator-screen/component.d.ts +1 -1
  257. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  258. package/build-types/navigator/navigator-to-parent-button/component.d.ts +2 -1
  259. package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
  260. package/build-types/number-control/index.d.ts +1 -1
  261. package/build-types/number-control/stories/index.d.ts +1 -1
  262. package/build-types/palette-edit/index.d.ts +1 -1
  263. package/build-types/palette-edit/index.d.ts.map +1 -1
  264. package/build-types/palette-edit/stories/index.d.ts.map +1 -1
  265. package/build-types/palette-edit/styles.d.ts +16 -10
  266. package/build-types/palette-edit/styles.d.ts.map +1 -1
  267. package/build-types/palette-edit/types.d.ts +8 -0
  268. package/build-types/palette-edit/types.d.ts.map +1 -1
  269. package/build-types/popover/index.d.ts +1 -1
  270. package/build-types/popover/index.d.ts.map +1 -1
  271. package/build-types/popover/stories/e2e/index.d.ts +1 -1
  272. package/build-types/private-apis.d.ts.map +1 -1
  273. package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
  274. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  275. package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
  276. package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
  277. package/build-types/slot-fill/fill.d.ts +4 -2
  278. package/build-types/slot-fill/fill.d.ts.map +1 -1
  279. package/build-types/slot-fill/index.d.ts +14 -3
  280. package/build-types/slot-fill/index.d.ts.map +1 -1
  281. package/build-types/slot-fill/provider.d.ts +0 -2
  282. package/build-types/slot-fill/provider.d.ts.map +1 -1
  283. package/build-types/slot-fill/slot.d.ts.map +1 -1
  284. package/build-types/spinner/styles.d.ts.map +1 -1
  285. package/build-types/toolbar/stories/index.d.ts.map +1 -1
  286. package/build-types/toolbar/toolbar-button/index.d.ts +12 -6
  287. package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
  288. package/build-types/toolbar/toolbar-item/index.d.ts +6 -4
  289. package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
  290. package/build-types/tree-grid/index.d.ts.map +1 -1
  291. package/build-types/tree-grid/types.d.ts +7 -0
  292. package/build-types/tree-grid/types.d.ts.map +1 -1
  293. package/build-types/ui/context/wordpress-component.d.ts +1 -1
  294. package/build-types/ui/context/wordpress-component.d.ts.map +1 -1
  295. package/build-types/unit-control/index.d.ts +1 -1
  296. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
  297. package/build-types/utils/use-deprecated-props.d.ts +9 -0
  298. package/build-types/utils/use-deprecated-props.d.ts.map +1 -0
  299. package/build-types/view/component.d.ts +1 -1
  300. package/build-types/view/component.d.ts.map +1 -1
  301. package/package.json +21 -22
  302. package/src/autocomplete/README.md +82 -54
  303. package/src/autocomplete/autocompleter-ui.tsx +0 -2
  304. package/src/autocomplete/index.tsx +1 -2
  305. package/src/autocomplete/types.ts +3 -19
  306. package/src/button/index.tsx +2 -0
  307. package/src/button/style.scss +13 -6
  308. package/src/button/types.ts +7 -0
  309. package/src/card/card-media/README.md +1 -1
  310. package/src/card/card-media/component.tsx +2 -1
  311. package/src/card/stories/index.tsx +47 -26
  312. package/src/checkbox-control/index.tsx +6 -2
  313. package/src/checkbox-control/style.scss +1 -4
  314. package/src/color-palette/index.native.js +20 -1
  315. package/src/color-picker/test/index.tsx +99 -99
  316. package/src/combobox-control/index.tsx +24 -18
  317. package/src/combobox-control/stories/index.tsx +0 -1
  318. package/src/combobox-control/styles.ts +4 -4
  319. package/src/combobox-control/types.ts +8 -1
  320. package/src/custom-gradient-picker/index.native.js +1 -1
  321. package/src/custom-gradient-picker/style.scss +2 -2
  322. package/src/dimension-control/README.md +1 -1
  323. package/src/dimension-control/index.tsx +1 -1
  324. package/src/draggable/README.md +8 -1
  325. package/src/draggable/index.tsx +7 -10
  326. package/src/draggable/stories/index.tsx +69 -33
  327. package/src/draggable/types.ts +7 -0
  328. package/src/form-toggle/style.scss +1 -5
  329. package/src/form-token-field/index.tsx +7 -3
  330. package/src/form-token-field/styles.ts +4 -4
  331. package/src/form-token-field/types.ts +8 -1
  332. package/src/index.ts +1 -0
  333. package/src/mobile/bottom-sheet/cell.native.js +4 -5
  334. package/src/mobile/color-settings/palette.screen.native.js +0 -7
  335. package/src/mobile/global-styles-context/index.native.js +12 -1
  336. package/src/mobile/global-styles-context/utils.native.js +18 -3
  337. package/src/mobile/link-picker/link-picker-results.native.js +3 -0
  338. package/src/mobile/segmented-control/index.native.js +2 -2
  339. package/src/modal/index.tsx +6 -1
  340. package/src/modal/style.scss +21 -13
  341. package/src/navigable-container/README.md +24 -13
  342. package/src/navigable-container/{container.js → container.tsx} +57 -27
  343. package/src/navigable-container/{index.js → index.tsx} +0 -1
  344. package/src/navigable-container/menu.tsx +100 -0
  345. package/src/navigable-container/stories/{navigable-menu.js → navigable-menu.tsx} +15 -10
  346. package/src/navigable-container/stories/{tabbable-container.js → tabbable-container.tsx} +15 -6
  347. package/src/navigable-container/tabbable.tsx +92 -0
  348. package/src/navigable-container/test/{navigable-menu.js → navigable-menu.tsx} +3 -1
  349. package/src/navigable-container/test/{tababble-container.js → tababble-container.tsx} +53 -24
  350. package/src/navigable-container/types.ts +76 -0
  351. package/src/navigator/navigator-screen/component.tsx +1 -1
  352. package/src/palette-edit/index.tsx +45 -7
  353. package/src/palette-edit/stories/index.tsx +4 -0
  354. package/src/palette-edit/types.ts +11 -0
  355. package/src/popover/index.tsx +2 -15
  356. package/src/private-apis.ts +2 -0
  357. package/src/sandbox/index.native.js +12 -1
  358. package/src/slot-fill/bubbles-virtually/fill.js +2 -1
  359. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -60
  360. package/src/slot-fill/bubbles-virtually/use-slot.js +14 -41
  361. package/src/slot-fill/fill.js +4 -26
  362. package/src/slot-fill/index.js +14 -8
  363. package/src/slot-fill/provider.js +0 -6
  364. package/src/slot-fill/slot.js +0 -5
  365. package/src/snackbar/style.scss +2 -1
  366. package/src/spinner/styles.ts +2 -0
  367. package/src/style.scss +6 -0
  368. package/src/tab-panel/index.tsx +1 -1
  369. package/src/theme/color-algorithms.ts +1 -1
  370. package/src/theme/stories/index.tsx +1 -1
  371. package/src/theme/test/color-algorithms.ts +2 -2
  372. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +4 -4
  373. package/src/toolbar/stories/index.tsx +26 -24
  374. package/src/toolbar/toolbar-button/index.tsx +10 -13
  375. package/src/toolbar/toolbar-item/{index.js → index.tsx} +12 -3
  376. package/src/tree-grid/README.md +18 -0
  377. package/src/tree-grid/index.tsx +7 -2
  378. package/src/tree-grid/types.ts +7 -0
  379. package/src/ui/context/wordpress-component.ts +1 -1
  380. package/src/utils/colors-values.js +3 -3
  381. package/src/utils/theme-variables.scss +4 -4
  382. package/src/utils/use-deprecated-props.ts +29 -0
  383. package/src/view/component.tsx +2 -2
  384. package/tsconfig.json +3 -2
  385. package/tsconfig.tsbuildinfo +1 -1
  386. package/src/CONTRIBUTING.md +0 -78
  387. package/src/README.md +0 -20
  388. package/src/navigable-container/menu.js +0 -62
  389. package/src/navigable-container/tabbable.js +0 -46
@@ -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","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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,MAAMS,OAAO,GAAGnK,UAAU,CAAEgD,kBAAF,CAA1B;;AAEP,SAASoH,WAAT,QAECF,GAFD,EAGE;AAAA,MAFD;AAAEzE,IAAAA,IAAI,GAAG5D;AAAT,GAEC;AACD,SACC,cAAC,IAAD,CACC;AADD;AAEC,IAAA,gBAAgB,MAFjB;AAGC,IAAA,IAAI,EAAG4D,IAHR;AAIC,IAAA,SAAS,EAAC,cAJX;AAKC,IAAA,GAAG,EAAGyE;AALP,IADD;AASA,C,CAED;;;AACAC,OAAO,CAAClJ,IAAR,GAAejB,UAAU,CAAEoK,WAAF,CAAzB,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"]}
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","shouldReduceMotion","motionInlineStyles","otherMotionProps","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;A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,SACC,cAAC,IAAD,CACC;AADD;AAEC,IAAA,gBAAgB,MAFjB;AAGC,IAAA,IAAI,EAAGyD,IAHR;AAIC,IAAA,SAAS,EAAC,cAJX;AAKC,IAAA,GAAG,EAAGyE;AALP,IADD;AASA,C,CAED;;;AACAC,OAAO,CAAC/I,IAAR,GAAejB,UAAU,CAAEiK,WAAF,CAAzB,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\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 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 }\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` and `children`, which are re-defined in `PopoverProps`).\n\t\tkeyof Omit< MotionProps, 'animate' | 'children' >\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"]}
@@ -8,6 +8,7 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri
8
8
 
9
9
  import { default as CustomSelectControl } from './custom-select-control';
10
10
  import { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';
11
+ import { createPrivateSlotFill } from './slot-fill';
11
12
  export const {
12
13
  lock,
13
14
  unlock
@@ -15,6 +16,7 @@ export const {
15
16
  export const privateApis = {};
16
17
  lock(privateApis, {
17
18
  CustomSelectControl,
18
- __experimentalPopoverLegacyPositionToPlacement
19
+ __experimentalPopoverLegacyPositionToPlacement,
20
+ createPrivateSlotFill
19
21
  });
20
22
  //# sourceMappingURL=private-apis.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/private-apis.ts"],"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","default","CustomSelectControl","positionToPlacement","__experimentalPopoverLegacyPositionToPlacement","lock","unlock","privateApis"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAT,QAAiE,yBAAjE;AAEA;AACA;AACA;;AACA,SAASC,OAAO,IAAIC,mBAApB,QAA+C,yBAA/C;AACA,SAASC,mBAAmB,IAAIC,8CAAhC,QAAsF,iBAAtF;AAEA,OAAO,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZN,gDAAgD,CAC/C,8GAD+C,EAE/C,uBAF+C,CAD1C;AAMP,OAAO,MAAMO,WAAW,GAAG,EAApB;AACPF,IAAI,CAAEE,WAAF,EAAe;AAClBL,EAAAA,mBADkB;AAElBE,EAAAA;AAFkB,CAAf,CAAJ","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\n/**\n * Internal dependencies\n */\nimport { default as CustomSelectControl } from './custom-select-control';\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/components'\n\t);\n\nexport const privateApis = {};\nlock( privateApis, {\n\tCustomSelectControl,\n\t__experimentalPopoverLegacyPositionToPlacement,\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/private-apis.ts"],"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","default","CustomSelectControl","positionToPlacement","__experimentalPopoverLegacyPositionToPlacement","createPrivateSlotFill","lock","unlock","privateApis"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gDAAT,QAAiE,yBAAjE;AAEA;AACA;AACA;;AACA,SAASC,OAAO,IAAIC,mBAApB,QAA+C,yBAA/C;AACA,SAASC,mBAAmB,IAAIC,8CAAhC,QAAsF,iBAAtF;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA,OAAO,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZP,gDAAgD,CAC/C,8GAD+C,EAE/C,uBAF+C,CAD1C;AAMP,OAAO,MAAMQ,WAAW,GAAG,EAApB;AACPF,IAAI,CAAEE,WAAF,EAAe;AAClBN,EAAAA,mBADkB;AAElBE,EAAAA,8CAFkB;AAGlBC,EAAAA;AAHkB,CAAf,CAAJ","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\n/**\n * Internal dependencies\n */\nimport { default as CustomSelectControl } from './custom-select-control';\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { createPrivateSlotFill } from './slot-fill';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/components'\n\t);\n\nexport const privateApis = {};\nlock( privateApis, {\n\tCustomSelectControl,\n\t__experimentalPopoverLegacyPositionToPlacement,\n\tcreatePrivateSlotFill,\n} );\n"]}
@@ -173,7 +173,10 @@ const Sandbox = forwardRef(function Sandbox(_ref, ref) {
173
173
  title = '',
174
174
  type,
175
175
  url,
176
- onWindowEvents = {}
176
+ onWindowEvents = {},
177
+ viewportProps = '',
178
+ onLoadEnd = () => {},
179
+ testID
177
180
  } = _ref;
178
181
  const colorScheme = usePreferredColorScheme();
179
182
  const [height, setHeight] = useState(0);
@@ -195,11 +198,13 @@ const Sandbox = forwardRef(function Sandbox(_ref, ref) {
195
198
  // we can use this in the future to inject custom styles or scripts.
196
199
  // Scripts go into the body rather than the head, to support embedded content such as Instagram
197
200
  // that expect the scripts to be part of the body.
201
+ // Avoid comma issues with props.viewportProps.
202
+ const addViewportProps = viewportProps.trim().replace(/(^[^,])/, ', $1');
198
203
  const htmlDoc = createElement("html", {
199
204
  lang: lang
200
205
  }, createElement("head", null, createElement("title", null, title), createElement("meta", {
201
206
  name: "viewport",
202
- content: "width=device-width, initial-scale=1"
207
+ content: `width=device-width, initial-scale=1${addViewportProps}`
203
208
  }), createElement("style", {
204
209
  dangerouslySetInnerHTML: {
205
210
  __html: style
@@ -332,7 +337,9 @@ const Sandbox = forwardRef(function Sandbox(_ref, ref) {
332
337
  setBuiltInZoomControls: false,
333
338
  showsHorizontalScrollIndicator: false,
334
339
  showsVerticalScrollIndicator: false,
335
- mediaPlaybackRequiresUserAction: false
340
+ mediaPlaybackRequiresUserAction: false,
341
+ onLoadEnd: onLoadEnd,
342
+ testID: testID
336
343
  });
337
344
  });
338
345
  const workaroundStyles = StyleSheet.create({
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/sandbox/index.native.js"],"names":["Dimensions","StyleSheet","WebView","Platform","renderToString","memo","useRef","useState","useEffect","forwardRef","useCallback","usePreferredColorScheme","sandboxStyles","observeAndResizeJS","style","EMPTY_ARRAY","Sandbox","ref","containerStyle","customJS","html","lang","providerUrl","scripts","styles","title","type","url","onWindowEvents","colorScheme","height","setHeight","contentHtml","setContentHtml","getHtmlDoc","windowSize","get","isLandscape","setIsLandscape","width","wasLandscape","key","select","android","ios","htmlDoc","__html","map","rules","i","src","getInjectedJavaScript","injectedJS","Object","keys","forEach","eventType","updateContentHtml","forceRerender","newContentHtml","setImmediate","getSizeStyle","contentHeight","Math","ceil","aspectRatio","onChangeDimensions","dimensions","window","onMessage","message","data","nativeEvent","JSON","parse","e","action","console","warn","dimensionsChangeSubscription","addEventListener","remove","current","baseUrl","isAndroid","workaroundStyles","webView","create","opacity"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,UAArB,QAAuC,cAAvC;AACA,SAASC,OAAT,QAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SACCC,QADD,EAECC,cAFD,EAGCC,IAHD,EAICC,MAJD,EAKCC,QALD,EAMCC,SAND,EAOCC,UAPD,EAQCC,WARD,QASO,oBATP;AAUA,SAASC,uBAAT,QAAwC,oBAAxC;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,cAA1B;AAEA,MAAMC,kBAAkB,GAAI;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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EAEhBM,cAFgB,CADlB;AAKC,IAAA,kBAAkB,EAAGiC,qBAAqB,EAL3C;AAMC,IAAA,GAAG,EAAGV,GANP;AAOC,IAAA,GAAG,EAAGxB,GAPP;AAQC,IAAA,MAAM,EAAG;AAAEkE,MAAAA,OAAO,EAAE7D,WAAX;AAAwBF,MAAAA,IAAI,EAAEY;AAA9B,KARV,CASC;AACA;AAVD;AAWC,IAAA,eAAe,EAAG,CAAE,GAAF,CAXnB;AAYC,IAAA,KAAK,EAAG,CACPpB,aAAa,CAAE,0BAAF,CADN,EAEPiD,YAAY,EAFL,EAGP1D,QAAQ,CAACiF,SAAT,IAAsBC,gBAAgB,CAACC,OAHhC,CAZT;AAiBC,IAAA,SAAS,EAAGjB,SAjBb;AAkBC,IAAA,aAAa,EAAG,KAlBjB;AAmBC,IAAA,sBAAsB,EAAG,KAnB1B;AAoBC,IAAA,8BAA8B,EAAG,KApBlC;AAqBC,IAAA,4BAA4B,EAAG,KArBhC;AAsBC,IAAA,+BAA+B,EAAG;AAtBnC,IADD;AA0BA,CAnMyB,CAA1B;AAqMA,MAAMgB,gBAAgB,GAAGpF,UAAU,CAACsF,MAAX,CAAmB;AAC3CD,EAAAA,OAAO,EAAE;AACR;AACF;AACA;AACA;AACA;AACEE,IAAAA,OAAO,EAAE;AAND;AADkC,CAAnB,CAAzB;AAWA,eAAenF,IAAI,CAAEW,OAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport { Dimensions, StyleSheet } from 'react-native';\nimport { WebView } from 'react-native-webview';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPlatform,\n\trenderToString,\n\tmemo,\n\tuseRef,\n\tuseState,\n\tuseEffect,\n\tforwardRef,\n\tuseCallback,\n} from '@wordpress/element';\nimport { usePreferredColorScheme } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport sandboxStyles from './style.scss';\n\nconst observeAndResizeJS = `\n\t(function() {\n\t\tconst { MutationObserver } = window;\n\n\t\tif ( ! MutationObserver || ! document.body || ! window.parent ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction sendResize() {\n\t\t\tconst clientBoundingRect = document.body.getBoundingClientRect();\n\n\t\t\t// The function postMessage is exposed by the react-native-webview library\n\t\t\t// to communicate between React Native and the WebView, in this case,\n\t\t\t// we use it for notifying resize changes.\n\t\t\twindow.ReactNativeWebView.postMessage(\n\t\t\t\tJSON.stringify( {\n\t\t\t\t\taction: 'resize',\n\t\t\t\t\twidth: clientBoundingRect.width,\n\t\t\t\t\theight: clientBoundingRect.height,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tconst observer = new MutationObserver( sendResize );\n\t\tobserver.observe( document.body, {\n\t\t\tattributes: true,\n\t\t\tattributeOldValue: false,\n\t\t\tcharacterData: true,\n\t\t\tcharacterDataOldValue: false,\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t} );\n\n\t\twindow.addEventListener( 'load', sendResize, true );\n\n\t\t// Hack: Remove viewport unit styles, as these are relative\n\t\t// the iframe root and interfere with our mechanism for\n\t\t// determining the unconstrained page bounds.\n\t\tfunction removeViewportStyles( ruleOrNode ) {\n\t\t\tif ( ruleOrNode.style ) {\n\t\t\t\t[ 'width', 'height', 'minHeight', 'maxHeight' ].forEach( function (\n\t\t\t\t\tstyle\n\t\t\t\t) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t/^\\\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )\n\t\t\t\t\t) {\n\t\t\t\t\t\truleOrNode.style[ style ] = '';\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\tArray.prototype.forEach.call(\n\t\t\tdocument.querySelectorAll( '[style]' ),\n\t\t\tremoveViewportStyles\n\t\t);\n\t\tArray.prototype.forEach.call(\n\t\t\tdocument.styleSheets,\n\t\t\tfunction ( stylesheet ) {\n\t\t\t\tArray.prototype.forEach.call(\n\t\t\t\t\tstylesheet.cssRules || stylesheet.rules,\n\t\t\t\t\tremoveViewportStyles\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tdocument.body.style.position = 'absolute';\n\t\tdocument.body.style.width = '100%';\n\t\tdocument.body.setAttribute( 'data-resizable-iframe-connected', '' );\n\n\t\tsendResize();\n\n\t\t// Resize events can change the width of elements with 100% width, but we don't\n\t\t// get an DOM mutations for that, so do the resize when the window is resized, too.\n\t\twindow.addEventListener( 'resize', sendResize, true );\n\t\twindow.addEventListener( 'orientationchange', sendResize, true );\n\t})();\n`;\n\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div,\n\tbody > div iframe {\n\t\twidth: 100%;\n\t}\n\tbody > div > * {\n\t\tmargin-top: 0 !important; /* Has to have !important to override inline styles. */\n\t\tmargin-bottom: 0 !important;\n\t}\n\n\t.wp-block-embed__wrapper {\n\t\tposition: relative;\n\t}\n\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\n\t}\n\n\t/**\n\t * Add responsiveness to embeds with aspect ratios.\n\t *\n\t * These styles have been copied from the web version (https://github.com/WordPress/gutenberg/blob/7901895ca20cf61e402925e31571d659dab64721/packages/block-library/src/embed/style.scss#L42-L89) and\n\t * adapted for the native version.\n\t */\n\t.wp-has-aspect-ratio.wp-block-embed__wrapper::before {\n\t\tcontent: \"\";\n\t\tdisplay: block;\n\t\tpadding-top: 50%; // Default to 2:1 aspect ratio.\n\t}\n\t.wp-has-aspect-ratio iframe {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tright: 0;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\theight: 100%;\n\t\twidth: 100%;\n\t}\n\t.wp-embed-aspect-21-9.wp-block-embed__wrapper::before {\n\t\tpadding-top: 42.85%; // 9 / 21 * 100\n\t}\n\t.wp-embed-aspect-18-9.wp-block-embed__wrapper::before {\n\t\tpadding-top: 50%; // 9 / 18 * 100\n\t}\n\t.wp-embed-aspect-16-9.wp-block-embed__wrapper::before {\n\t\tpadding-top: 56.25%; // 9 / 16 * 100\n\t}\n\t.wp-embed-aspect-4-3.wp-block-embed__wrapper::before {\n\t\tpadding-top: 75%; // 3 / 4 * 100\n\t}\n\t.wp-embed-aspect-1-1.wp-block-embed__wrapper::before {\n\t\tpadding-top: 100%; // 1 / 1 * 100\n\t}\n\t.wp-embed-aspect-9-16.wp-block-embed__wrapper::before {\n\t\tpadding-top: 177.77%; // 16 / 9 * 100\n\t}\n\t.wp-embed-aspect-1-2.wp-block-embed__wrapper::before {\n\t\tpadding-top: 200%; // 2 / 1 * 100\n\t}\n`;\n\nconst EMPTY_ARRAY = [];\n\nconst Sandbox = forwardRef( function Sandbox(\n\t{\n\t\tcontainerStyle,\n\t\tcustomJS,\n\t\thtml = '',\n\t\tlang = 'en',\n\t\tproviderUrl = '',\n\t\tscripts = EMPTY_ARRAY,\n\t\tstyles = EMPTY_ARRAY,\n\t\ttitle = '',\n\t\ttype,\n\t\turl,\n\t\tonWindowEvents = {},\n\t},\n\tref\n) {\n\tconst colorScheme = usePreferredColorScheme();\n\tconst [ height, setHeight ] = useState( 0 );\n\tconst [ contentHtml, setContentHtml ] = useState( getHtmlDoc() );\n\n\tconst windowSize = Dimensions.get( 'window' );\n\tconst [ isLandscape, setIsLandscape ] = useState(\n\t\twindowSize.width >= windowSize.height\n\t);\n\tconst wasLandscape = useRef( isLandscape );\n\t// On Android, we need to recreate the WebView on any of the following actions, otherwise it disappears:\n\t// - Device rotation\n\t// - Light/dark mode changes\n\t// For this purpose, the key prop used in the WebView will be updated with the value of the actions.\n\tconst key = Platform.select( {\n\t\tandroid: `${ url }-${\n\t\t\tisLandscape ? 'landscape' : 'portrait'\n\t\t}-${ colorScheme }`,\n\t\tios: url,\n\t} );\n\n\tfunction getHtmlDoc() {\n\t\t// Put the html snippet into a html document, and update the state to refresh the WebView,\n\t\t// we can use this in the future to inject custom styles or scripts.\n\t\t// Scripts go into the body rather than the head, to support embedded content such as Instagram\n\t\t// that expect the scripts to be part of the body.\n\t\tconst htmlDoc = (\n\t\t\t<html lang={ lang }>\n\t\t\t\t<head>\n\t\t\t\t\t<title>{ title }</title>\n\t\t\t\t\t<meta\n\t\t\t\t\t\tname=\"viewport\"\n\t\t\t\t\t\tcontent=\"width=device-width, initial-scale=1\"\n\t\t\t\t\t></meta>\n\t\t\t\t\t<style dangerouslySetInnerHTML={ { __html: style } } />\n\t\t\t\t\t{ styles.map( ( rules, i ) => (\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ { __html: rules } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</head>\n\t\t\t\t<body\n\t\t\t\t\tdata-resizable-iframe-connected=\"data-resizable-iframe-connected\"\n\t\t\t\t\tclassName={ type }\n\t\t\t\t>\n\t\t\t\t\t<div dangerouslySetInnerHTML={ { __html: html } } />\n\t\t\t\t\t{ scripts.map( ( src ) => (\n\t\t\t\t\t\t<script key={ src } src={ src } />\n\t\t\t\t\t) ) }\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t);\n\t\treturn '<!DOCTYPE html>' + renderToString( htmlDoc );\n\t}\n\n\tconst getInjectedJavaScript = useCallback( () => {\n\t\t// Allow parent to override the resize observers with prop.customJS (legacy support)\n\t\tlet injectedJS = customJS || observeAndResizeJS;\n\n\t\t// Add any event listeners that were passed in.\n\t\tObject.keys( onWindowEvents ).forEach( ( eventType ) => {\n\t\t\tinjectedJS += `\n\t\t\t\twindow.addEventListener( '${ eventType }', function( event ) {\n\t\t\t\t\twindow.ReactNativeWebView.postMessage( JSON.stringify( { type: '${ eventType }', ...event.data } ) );\n\t\t\t\t});`;\n\t\t} );\n\n\t\treturn injectedJS;\n\t}, [ customJS, onWindowEvents ] );\n\n\tfunction updateContentHtml( forceRerender = false ) {\n\t\tconst newContentHtml = getHtmlDoc();\n\n\t\tif ( forceRerender && contentHtml === newContentHtml ) {\n\t\t\t// The re-render is forced by updating the state with empty HTML,\n\t\t\t// waiting for the JS code to be executed with \"setImmediate\" and then\n\t\t\t// setting the content HTML again.\n\t\t\tsetContentHtml( '' );\n\t\t\tsetImmediate( () => setContentHtml( newContentHtml ) );\n\t\t} else {\n\t\t\tsetContentHtml( newContentHtml );\n\t\t}\n\t}\n\n\tfunction getSizeStyle() {\n\t\tconst contentHeight = Math.ceil( height );\n\n\t\treturn contentHeight ? { height: contentHeight } : { aspectRatio: 1 };\n\t}\n\n\tfunction onChangeDimensions( dimensions ) {\n\t\tsetIsLandscape( dimensions.window.width >= dimensions.window.height );\n\t}\n\n\tconst onMessage = useCallback(\n\t\t( message ) => {\n\t\t\tlet data = message?.nativeEvent?.data;\n\n\t\t\ttry {\n\t\t\t\tdata = JSON.parse( data );\n\t\t\t} catch ( e ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// check for resize event\n\t\t\tif ( 'resize' === data?.action ) {\n\t\t\t\tsetHeight( data.height );\n\t\t\t}\n\n\t\t\t// Forward the event to parent event listeners\n\t\t\tObject.keys( onWindowEvents ).forEach( ( eventType ) => {\n\t\t\t\tif ( data?.type === eventType ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tonWindowEvents[ eventType ]( data );\n\t\t\t\t\t} catch ( e ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`Error handling event ${ eventType }`,\n\t\t\t\t\t\t\te\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t},\n\t\t[ onWindowEvents ]\n\t);\n\n\tuseEffect( () => {\n\t\tconst dimensionsChangeSubscription = Dimensions.addEventListener(\n\t\t\t'change',\n\t\t\tonChangeDimensions\n\t\t);\n\t\treturn () => {\n\t\t\tdimensionsChangeSubscription.remove();\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tupdateContentHtml();\n\t\t// Disable reason: deferring this refactor to the native team.\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ html, title, type, styles, scripts ] );\n\n\tuseEffect( () => {\n\t\t// When device orientation changes we have to recalculate the size,\n\t\t// for this purpose we reset the current size value.\n\t\tif ( wasLandscape.current !== isLandscape ) {\n\t\t\tsetHeight( 0 );\n\t\t}\n\t\twasLandscape.current = isLandscape;\n\t}, [ isLandscape ] );\n\n\treturn (\n\t\t<WebView\n\t\t\tcontainerStyle={ [\n\t\t\t\tsandboxStyles[ 'sandbox-webview__container' ],\n\t\t\t\tcontainerStyle,\n\t\t\t] }\n\t\t\tinjectedJavaScript={ getInjectedJavaScript() }\n\t\t\tkey={ key }\n\t\t\tref={ ref }\n\t\t\tsource={ { baseUrl: providerUrl, html: contentHtml } }\n\t\t\t// Wildcard value is required for static HTML\n\t\t\t// Reference: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#source\n\t\t\toriginWhitelist={ [ '*' ] }\n\t\t\tstyle={ [\n\t\t\t\tsandboxStyles[ 'sandbox-webview__content' ],\n\t\t\t\tgetSizeStyle(),\n\t\t\t\tPlatform.isAndroid && workaroundStyles.webView,\n\t\t\t] }\n\t\t\tonMessage={ onMessage }\n\t\t\tscrollEnabled={ false }\n\t\t\tsetBuiltInZoomControls={ false }\n\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\tshowsVerticalScrollIndicator={ false }\n\t\t\tmediaPlaybackRequiresUserAction={ false }\n\t\t/>\n\t);\n} );\n\nconst workaroundStyles = StyleSheet.create( {\n\twebView: {\n\t\t/**\n\t\t * The slight opacity below is a workaround for an Android crash caused from combining Android\n\t\t * 12's new scroll overflow behavior and webviews.\n\t\t * https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-808869253\n\t\t */\n\t\topacity: 0.99,\n\t},\n} );\n\nexport default memo( Sandbox );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/sandbox/index.native.js"],"names":["Dimensions","StyleSheet","WebView","Platform","renderToString","memo","useRef","useState","useEffect","forwardRef","useCallback","usePreferredColorScheme","sandboxStyles","observeAndResizeJS","style","EMPTY_ARRAY","Sandbox","ref","containerStyle","customJS","html","lang","providerUrl","scripts","styles","title","type","url","onWindowEvents","viewportProps","onLoadEnd","testID","colorScheme","height","setHeight","contentHtml","setContentHtml","getHtmlDoc","windowSize","get","isLandscape","setIsLandscape","width","wasLandscape","key","select","android","ios","addViewportProps","trim","replace","htmlDoc","__html","map","rules","i","src","getInjectedJavaScript","injectedJS","Object","keys","forEach","eventType","updateContentHtml","forceRerender","newContentHtml","setImmediate","getSizeStyle","contentHeight","Math","ceil","aspectRatio","onChangeDimensions","dimensions","window","onMessage","message","data","nativeEvent","JSON","parse","e","action","console","warn","dimensionsChangeSubscription","addEventListener","remove","current","baseUrl","isAndroid","workaroundStyles","webView","create","opacity"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,UAArB,QAAuC,cAAvC;AACA,SAASC,OAAT,QAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SACCC,QADD,EAECC,cAFD,EAGCC,IAHD,EAICC,MAJD,EAKCC,QALD,EAMCC,SAND,EAOCC,UAPD,EAQCC,WARD,QASO,oBATP;AAUA,SAASC,uBAAT,QAAwC,oBAAxC;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,cAA1B;AAEA,MAAMC,kBAAkB,GAAI;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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ensions, StyleSheet } from 'react-native';\nimport { WebView } from 'react-native-webview';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPlatform,\n\trenderToString,\n\tmemo,\n\tuseRef,\n\tuseState,\n\tuseEffect,\n\tforwardRef,\n\tuseCallback,\n} from '@wordpress/element';\nimport { usePreferredColorScheme } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport sandboxStyles from './style.scss';\n\nconst observeAndResizeJS = `\n\t(function() {\n\t\tconst { MutationObserver } = window;\n\n\t\tif ( ! MutationObserver || ! document.body || ! window.parent ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction sendResize() {\n\t\t\tconst clientBoundingRect = document.body.getBoundingClientRect();\n\n\t\t\t// The function postMessage is exposed by the react-native-webview library\n\t\t\t// to communicate between React Native and the WebView, in this case,\n\t\t\t// we use it for notifying resize changes.\n\t\t\twindow.ReactNativeWebView.postMessage(\n\t\t\t\tJSON.stringify( {\n\t\t\t\t\taction: 'resize',\n\t\t\t\t\twidth: clientBoundingRect.width,\n\t\t\t\t\theight: clientBoundingRect.height,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tconst observer = new MutationObserver( sendResize );\n\t\tobserver.observe( document.body, {\n\t\t\tattributes: true,\n\t\t\tattributeOldValue: false,\n\t\t\tcharacterData: true,\n\t\t\tcharacterDataOldValue: false,\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t} );\n\n\t\twindow.addEventListener( 'load', sendResize, true );\n\n\t\t// Hack: Remove viewport unit styles, as these are relative\n\t\t// the iframe root and interfere with our mechanism for\n\t\t// determining the unconstrained page bounds.\n\t\tfunction removeViewportStyles( ruleOrNode ) {\n\t\t\tif ( ruleOrNode.style ) {\n\t\t\t\t[ 'width', 'height', 'minHeight', 'maxHeight' ].forEach( function (\n\t\t\t\t\tstyle\n\t\t\t\t) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t/^\\\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )\n\t\t\t\t\t) {\n\t\t\t\t\t\truleOrNode.style[ style ] = '';\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\tArray.prototype.forEach.call(\n\t\t\tdocument.querySelectorAll( '[style]' ),\n\t\t\tremoveViewportStyles\n\t\t);\n\t\tArray.prototype.forEach.call(\n\t\t\tdocument.styleSheets,\n\t\t\tfunction ( stylesheet ) {\n\t\t\t\tArray.prototype.forEach.call(\n\t\t\t\t\tstylesheet.cssRules || stylesheet.rules,\n\t\t\t\t\tremoveViewportStyles\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tdocument.body.style.position = 'absolute';\n\t\tdocument.body.style.width = '100%';\n\t\tdocument.body.setAttribute( 'data-resizable-iframe-connected', '' );\n\n\t\tsendResize();\n\n\t\t// Resize events can change the width of elements with 100% width, but we don't\n\t\t// get an DOM mutations for that, so do the resize when the window is resized, too.\n\t\twindow.addEventListener( 'resize', sendResize, true );\n\t\twindow.addEventListener( 'orientationchange', sendResize, true );\n\t})();\n`;\n\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div,\n\tbody > div iframe {\n\t\twidth: 100%;\n\t}\n\tbody > div > * {\n\t\tmargin-top: 0 !important; /* Has to have !important to override inline styles. */\n\t\tmargin-bottom: 0 !important;\n\t}\n\n\t.wp-block-embed__wrapper {\n\t\tposition: relative;\n\t}\n\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\n\t}\n\n\t/**\n\t * Add responsiveness to embeds with aspect ratios.\n\t *\n\t * These styles have been copied from the web version (https://github.com/WordPress/gutenberg/blob/7901895ca20cf61e402925e31571d659dab64721/packages/block-library/src/embed/style.scss#L42-L89) and\n\t * adapted for the native version.\n\t */\n\t.wp-has-aspect-ratio.wp-block-embed__wrapper::before {\n\t\tcontent: \"\";\n\t\tdisplay: block;\n\t\tpadding-top: 50%; // Default to 2:1 aspect ratio.\n\t}\n\t.wp-has-aspect-ratio iframe {\n\t\tposition: absolute;\n\t\ttop: 0;\n\t\tright: 0;\n\t\tbottom: 0;\n\t\tleft: 0;\n\t\theight: 100%;\n\t\twidth: 100%;\n\t}\n\t.wp-embed-aspect-21-9.wp-block-embed__wrapper::before {\n\t\tpadding-top: 42.85%; // 9 / 21 * 100\n\t}\n\t.wp-embed-aspect-18-9.wp-block-embed__wrapper::before {\n\t\tpadding-top: 50%; // 9 / 18 * 100\n\t}\n\t.wp-embed-aspect-16-9.wp-block-embed__wrapper::before {\n\t\tpadding-top: 56.25%; // 9 / 16 * 100\n\t}\n\t.wp-embed-aspect-4-3.wp-block-embed__wrapper::before {\n\t\tpadding-top: 75%; // 3 / 4 * 100\n\t}\n\t.wp-embed-aspect-1-1.wp-block-embed__wrapper::before {\n\t\tpadding-top: 100%; // 1 / 1 * 100\n\t}\n\t.wp-embed-aspect-9-16.wp-block-embed__wrapper::before {\n\t\tpadding-top: 177.77%; // 16 / 9 * 100\n\t}\n\t.wp-embed-aspect-1-2.wp-block-embed__wrapper::before {\n\t\tpadding-top: 200%; // 2 / 1 * 100\n\t}\n`;\n\nconst EMPTY_ARRAY = [];\n\nconst Sandbox = forwardRef( function Sandbox(\n\t{\n\t\tcontainerStyle,\n\t\tcustomJS,\n\t\thtml = '',\n\t\tlang = 'en',\n\t\tproviderUrl = '',\n\t\tscripts = EMPTY_ARRAY,\n\t\tstyles = EMPTY_ARRAY,\n\t\ttitle = '',\n\t\ttype,\n\t\turl,\n\t\tonWindowEvents = {},\n\t\tviewportProps = '',\n\t\tonLoadEnd = () => {},\n\t\ttestID,\n\t},\n\tref\n) {\n\tconst colorScheme = usePreferredColorScheme();\n\tconst [ height, setHeight ] = useState( 0 );\n\tconst [ contentHtml, setContentHtml ] = useState( getHtmlDoc() );\n\n\tconst windowSize = Dimensions.get( 'window' );\n\tconst [ isLandscape, setIsLandscape ] = useState(\n\t\twindowSize.width >= windowSize.height\n\t);\n\tconst wasLandscape = useRef( isLandscape );\n\t// On Android, we need to recreate the WebView on any of the following actions, otherwise it disappears:\n\t// - Device rotation\n\t// - Light/dark mode changes\n\t// For this purpose, the key prop used in the WebView will be updated with the value of the actions.\n\tconst key = Platform.select( {\n\t\tandroid: `${ url }-${\n\t\t\tisLandscape ? 'landscape' : 'portrait'\n\t\t}-${ colorScheme }`,\n\t\tios: url,\n\t} );\n\n\tfunction getHtmlDoc() {\n\t\t// Put the html snippet into a html document, and update the state to refresh the WebView,\n\t\t// we can use this in the future to inject custom styles or scripts.\n\t\t// Scripts go into the body rather than the head, to support embedded content such as Instagram\n\t\t// that expect the scripts to be part of the body.\n\n\t\t// Avoid comma issues with props.viewportProps.\n\t\tconst addViewportProps = viewportProps\n\t\t\t.trim()\n\t\t\t.replace( /(^[^,])/, ', $1' );\n\n\t\tconst htmlDoc = (\n\t\t\t<html lang={ lang }>\n\t\t\t\t<head>\n\t\t\t\t\t<title>{ title }</title>\n\t\t\t\t\t<meta\n\t\t\t\t\t\tname=\"viewport\"\n\t\t\t\t\t\tcontent={ `width=device-width, initial-scale=1${ addViewportProps }` }\n\t\t\t\t\t></meta>\n\t\t\t\t\t<style dangerouslySetInnerHTML={ { __html: style } } />\n\t\t\t\t\t{ styles.map( ( rules, i ) => (\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ { __html: rules } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</head>\n\t\t\t\t<body\n\t\t\t\t\tdata-resizable-iframe-connected=\"data-resizable-iframe-connected\"\n\t\t\t\t\tclassName={ type }\n\t\t\t\t>\n\t\t\t\t\t<div dangerouslySetInnerHTML={ { __html: html } } />\n\t\t\t\t\t{ scripts.map( ( src ) => (\n\t\t\t\t\t\t<script key={ src } src={ src } />\n\t\t\t\t\t) ) }\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t);\n\t\treturn '<!DOCTYPE html>' + renderToString( htmlDoc );\n\t}\n\n\tconst getInjectedJavaScript = useCallback( () => {\n\t\t// Allow parent to override the resize observers with prop.customJS (legacy support)\n\t\tlet injectedJS = customJS || observeAndResizeJS;\n\n\t\t// Add any event listeners that were passed in.\n\t\tObject.keys( onWindowEvents ).forEach( ( eventType ) => {\n\t\t\tinjectedJS += `\n\t\t\t\twindow.addEventListener( '${ eventType }', function( event ) {\n\t\t\t\t\twindow.ReactNativeWebView.postMessage( JSON.stringify( { type: '${ eventType }', ...event.data } ) );\n\t\t\t\t});`;\n\t\t} );\n\n\t\treturn injectedJS;\n\t}, [ customJS, onWindowEvents ] );\n\n\tfunction updateContentHtml( forceRerender = false ) {\n\t\tconst newContentHtml = getHtmlDoc();\n\n\t\tif ( forceRerender && contentHtml === newContentHtml ) {\n\t\t\t// The re-render is forced by updating the state with empty HTML,\n\t\t\t// waiting for the JS code to be executed with \"setImmediate\" and then\n\t\t\t// setting the content HTML again.\n\t\t\tsetContentHtml( '' );\n\t\t\tsetImmediate( () => setContentHtml( newContentHtml ) );\n\t\t} else {\n\t\t\tsetContentHtml( newContentHtml );\n\t\t}\n\t}\n\n\tfunction getSizeStyle() {\n\t\tconst contentHeight = Math.ceil( height );\n\n\t\treturn contentHeight ? { height: contentHeight } : { aspectRatio: 1 };\n\t}\n\n\tfunction onChangeDimensions( dimensions ) {\n\t\tsetIsLandscape( dimensions.window.width >= dimensions.window.height );\n\t}\n\n\tconst onMessage = useCallback(\n\t\t( message ) => {\n\t\t\tlet data = message?.nativeEvent?.data;\n\n\t\t\ttry {\n\t\t\t\tdata = JSON.parse( data );\n\t\t\t} catch ( e ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// check for resize event\n\t\t\tif ( 'resize' === data?.action ) {\n\t\t\t\tsetHeight( data.height );\n\t\t\t}\n\n\t\t\t// Forward the event to parent event listeners\n\t\t\tObject.keys( onWindowEvents ).forEach( ( eventType ) => {\n\t\t\t\tif ( data?.type === eventType ) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tonWindowEvents[ eventType ]( data );\n\t\t\t\t\t} catch ( e ) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`Error handling event ${ eventType }`,\n\t\t\t\t\t\t\te\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t},\n\t\t[ onWindowEvents ]\n\t);\n\n\tuseEffect( () => {\n\t\tconst dimensionsChangeSubscription = Dimensions.addEventListener(\n\t\t\t'change',\n\t\t\tonChangeDimensions\n\t\t);\n\t\treturn () => {\n\t\t\tdimensionsChangeSubscription.remove();\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tupdateContentHtml();\n\t\t// Disable reason: deferring this refactor to the native team.\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ html, title, type, styles, scripts ] );\n\n\tuseEffect( () => {\n\t\t// When device orientation changes we have to recalculate the size,\n\t\t// for this purpose we reset the current size value.\n\t\tif ( wasLandscape.current !== isLandscape ) {\n\t\t\tsetHeight( 0 );\n\t\t}\n\t\twasLandscape.current = isLandscape;\n\t}, [ isLandscape ] );\n\n\treturn (\n\t\t<WebView\n\t\t\tcontainerStyle={ [\n\t\t\t\tsandboxStyles[ 'sandbox-webview__container' ],\n\t\t\t\tcontainerStyle,\n\t\t\t] }\n\t\t\tinjectedJavaScript={ getInjectedJavaScript() }\n\t\t\tkey={ key }\n\t\t\tref={ ref }\n\t\t\tsource={ { baseUrl: providerUrl, html: contentHtml } }\n\t\t\t// Wildcard value is required for static HTML\n\t\t\t// Reference: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#source\n\t\t\toriginWhitelist={ [ '*' ] }\n\t\t\tstyle={ [\n\t\t\t\tsandboxStyles[ 'sandbox-webview__content' ],\n\t\t\t\tgetSizeStyle(),\n\t\t\t\tPlatform.isAndroid && workaroundStyles.webView,\n\t\t\t] }\n\t\t\tonMessage={ onMessage }\n\t\t\tscrollEnabled={ false }\n\t\t\tsetBuiltInZoomControls={ false }\n\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\tshowsVerticalScrollIndicator={ false }\n\t\t\tmediaPlaybackRequiresUserAction={ false }\n\t\t\tonLoadEnd={ onLoadEnd }\n\t\t\ttestID={ testID }\n\t\t/>\n\t);\n} );\n\nconst workaroundStyles = StyleSheet.create( {\n\twebView: {\n\t\t/**\n\t\t * The slight opacity below is a workaround for an Android crash caused from combining Android\n\t\t * 12's new scroll overflow behavior and webviews.\n\t\t * https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-808869253\n\t\t */\n\t\topacity: 0.99,\n\t},\n} );\n\nexport default memo( Sandbox );\n"]}
@@ -38,8 +38,9 @@ export default function Fill(_ref) {
38
38
  unregisterFill,
39
39
  ...slot
40
40
  } = useSlot(name);
41
+ const rerender = useForceUpdate();
41
42
  const ref = useRef({
42
- rerender: useForceUpdate()
43
+ rerender
43
44
  });
44
45
  useEffect(() => {
45
46
  // We register fills so we can keep track of their existence.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/fill.js"],"names":["useRef","useState","useEffect","createPortal","useSlot","StyleProvider","useForceUpdate","setState","mounted","current","Fill","name","children","registerFill","unregisterFill","slot","ref","rerender","fillProps","wrappedChildren","ownerDocument"],"mappings":";AAAA;;AACA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,EAAsCC,YAAtC,QAA0D,oBAA1D;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,OAAOC,aAAP,MAA0B,sBAA1B;;AAEA,SAASC,cAAT,GAA0B;AACzB,QAAM,GAAIC,QAAJ,IAAiBN,QAAQ,CAAE,EAAF,CAA/B;AACA,QAAMO,OAAO,GAAGR,MAAM,CAAE,IAAF,CAAtB;AAEAE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mBJ,IAAI,CAACC,GAAL,CAASP,OAA5B,CAAnB;AACA","sourcesContent":["// @ts-nocheck\n/**\n * WordPress dependencies\n */\nimport { useRef, useState, useEffect, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useSlot from './use-slot';\nimport StyleProvider from '../../style-provider';\n\nfunction useForceUpdate() {\n\tconst [ , setState ] = useState( {} );\n\tconst mounted = useRef( true );\n\n\tuseEffect( () => {\n\t\tmounted.current = true;\n\t\treturn () => {\n\t\t\tmounted.current = false;\n\t\t};\n\t}, [] );\n\n\treturn () => {\n\t\tif ( mounted.current ) {\n\t\t\tsetState( {} );\n\t\t}\n\t};\n}\n\nexport default function Fill( { name, children } ) {\n\tconst { registerFill, unregisterFill, ...slot } = useSlot( name );\n\tconst ref = useRef( { rerender: useForceUpdate() } );\n\n\tuseEffect( () => {\n\t\t// We register fills so we can keep track of their existence.\n\t\t// Some Slot implementations need to know if there're already fills\n\t\t// registered so they can choose to render themselves or not.\n\t\tregisterFill( ref );\n\t\treturn () => {\n\t\t\tunregisterFill( ref );\n\t\t};\n\t}, [ registerFill, unregisterFill ] );\n\n\tif ( ! slot.ref || ! slot.ref.current ) {\n\t\treturn null;\n\t}\n\n\tif ( typeof children === 'function' ) {\n\t\tchildren = children( slot.fillProps );\n\t}\n\n\t// When using a `Fill`, the `children` will be rendered in the document of the\n\t// `Slot`. This means that we need to wrap the `children` in a `StyleProvider`\n\t// to make sure we're referencing the right document/iframe (instead of the\n\t// context of the `Fill`'s parent).\n\tconst wrappedChildren = (\n\t\t<StyleProvider document={ slot.ref.current.ownerDocument }>\n\t\t\t{ children }\n\t\t</StyleProvider>\n\t);\n\n\treturn createPortal( wrappedChildren, slot.ref.current );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/fill.js"],"names":["useRef","useState","useEffect","createPortal","useSlot","StyleProvider","useForceUpdate","setState","mounted","current","Fill","name","children","registerFill","unregisterFill","slot","rerender","ref","fillProps","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I,CAACE,GAAL,CAASR,OAA9B,EAAwC;AACvC,WAAO,IAAP;AACA;;AAED,MAAK,OAAOG,QAAP,KAAoB,UAAzB,EAAsC;AACrCA,IAAAA,QAAQ,GAAGA,QAAQ,CAAEG,IAAI,CAACG,SAAP,CAAnB;AACA,GArBiD,CAuBlD;AACA;AACA;AACA;;;AACA,QAAMC,eAAe,GACpB,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGJ,IAAI,CAACE,GAAL,CAASR,OAAT,CAAiBW;AAA3C,KACGR,QADH,CADD;AAMA,SAAOT,YAAY,CAAEgB,eAAF,EAAmBJ,IAAI,CAACE,GAAL,CAASR,OAA5B,CAAnB;AACA","sourcesContent":["// @ts-nocheck\n/**\n * WordPress dependencies\n */\nimport { useRef, useState, useEffect, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useSlot from './use-slot';\nimport StyleProvider from '../../style-provider';\n\nfunction useForceUpdate() {\n\tconst [ , setState ] = useState( {} );\n\tconst mounted = useRef( true );\n\n\tuseEffect( () => {\n\t\tmounted.current = true;\n\t\treturn () => {\n\t\t\tmounted.current = false;\n\t\t};\n\t}, [] );\n\n\treturn () => {\n\t\tif ( mounted.current ) {\n\t\t\tsetState( {} );\n\t\t}\n\t};\n}\n\nexport default function Fill( { name, children } ) {\n\tconst { registerFill, unregisterFill, ...slot } = useSlot( name );\n\tconst rerender = useForceUpdate();\n\tconst ref = useRef( { rerender } );\n\n\tuseEffect( () => {\n\t\t// We register fills so we can keep track of their existence.\n\t\t// Some Slot implementations need to know if there're already fills\n\t\t// registered so they can choose to render themselves or not.\n\t\tregisterFill( ref );\n\t\treturn () => {\n\t\t\tunregisterFill( ref );\n\t\t};\n\t}, [ registerFill, unregisterFill ] );\n\n\tif ( ! slot.ref || ! slot.ref.current ) {\n\t\treturn null;\n\t}\n\n\tif ( typeof children === 'function' ) {\n\t\tchildren = children( slot.fillProps );\n\t}\n\n\t// When using a `Fill`, the `children` will be rendered in the document of the\n\t// `Slot`. This means that we need to wrap the `children` in a `StyleProvider`\n\t// to make sure we're referencing the right document/iframe (instead of the\n\t// context of the `Fill`'s parent).\n\tconst wrappedChildren = (\n\t\t<StyleProvider document={ slot.ref.current.ownerDocument }>\n\t\t\t{ children }\n\t\t</StyleProvider>\n\t);\n\n\treturn createPortal( wrappedChildren, slot.ref.current );\n}\n"]}
@@ -10,7 +10,7 @@ import { proxyMap } from 'valtio/utils';
10
10
  * WordPress dependencies
11
11
  */
12
12
 
13
- import { useMemo, useCallback, useRef } from '@wordpress/element';
13
+ import { useState } from '@wordpress/element';
14
14
  import isShallowEqual from '@wordpress/is-shallow-equal';
15
15
  /**
16
16
  * Internal dependencies
@@ -18,68 +18,78 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
18
18
 
19
19
  import SlotFillContext from './slot-fill-context';
20
20
 
21
- function useSlotRegistry() {
22
- const slots = useRef(proxyMap());
23
- const fills = useRef(proxyMap());
24
- const registerSlot = useCallback((name, ref, fillProps) => {
25
- const slot = slots.current.get(name) || {};
26
- slots.current.set(name, valRef({ ...slot,
21
+ function createSlotRegistry() {
22
+ const slots = proxyMap();
23
+ const fills = proxyMap();
24
+
25
+ function registerSlot(name, ref, fillProps) {
26
+ const slot = slots.get(name) || {};
27
+ slots.set(name, valRef({ ...slot,
27
28
  ref: ref || slot.ref,
28
29
  fillProps: fillProps || slot.fillProps || {}
29
30
  }));
30
- }, []);
31
- const unregisterSlot = useCallback((name, ref) => {
32
- var _slots$current$get;
31
+ }
32
+
33
+ function unregisterSlot(name, ref) {
34
+ var _slots$get;
33
35
 
34
36
  // Make sure we're not unregistering a slot registered by another element
35
37
  // See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412
36
- if (((_slots$current$get = slots.current.get(name)) === null || _slots$current$get === void 0 ? void 0 : _slots$current$get.ref) === ref) {
37
- slots.current.delete(name);
38
+ if (((_slots$get = slots.get(name)) === null || _slots$get === void 0 ? void 0 : _slots$get.ref) === ref) {
39
+ slots.delete(name);
38
40
  }
39
- }, []);
40
- const updateSlot = useCallback((name, fillProps) => {
41
- const slot = slots.current.get(name);
41
+ }
42
+
43
+ function updateSlot(name, fillProps) {
44
+ const slot = slots.get(name);
42
45
 
43
46
  if (!slot) {
44
47
  return;
45
48
  }
46
49
 
47
- if (!isShallowEqual(slot.fillProps, fillProps)) {
48
- slot.fillProps = fillProps;
49
- const slotFills = fills.current.get(name);
50
+ if (isShallowEqual(slot.fillProps, fillProps)) {
51
+ return;
52
+ }
53
+
54
+ slot.fillProps = fillProps;
55
+ const slotFills = fills.get(name);
50
56
 
51
- if (slotFills) {
52
- // Force update fills.
53
- slotFills.map(fill => fill.current.rerender());
54
- }
57
+ if (slotFills) {
58
+ // Force update fills.
59
+ slotFills.map(fill => fill.current.rerender());
55
60
  }
56
- }, []);
57
- const registerFill = useCallback((name, ref) => {
58
- fills.current.set(name, valRef([...(fills.current.get(name) || []), ref]));
59
- }, []);
60
- const unregisterFill = useCallback((name, ref) => {
61
- if (fills.current.get(name)) {
62
- fills.current.set(name, valRef(fills.current.get(name).filter(fillRef => fillRef !== ref)));
61
+ }
62
+
63
+ function registerFill(name, ref) {
64
+ fills.set(name, valRef([...(fills.get(name) || []), ref]));
65
+ }
66
+
67
+ function unregisterFill(name, ref) {
68
+ const fillsForName = fills.get(name);
69
+
70
+ if (!fillsForName) {
71
+ return;
63
72
  }
64
- }, []); // Memoizing the return value so it can be directly passed to Provider value
65
73
 
66
- const registry = useMemo(() => ({
67
- slots: slots.current,
68
- fills: fills.current,
74
+ fills.set(name, valRef(fillsForName.filter(fillRef => fillRef !== ref)));
75
+ }
76
+
77
+ return {
78
+ slots,
79
+ fills,
69
80
  registerSlot,
70
81
  updateSlot,
71
82
  unregisterSlot,
72
83
  registerFill,
73
84
  unregisterFill
74
- }), [registerSlot, updateSlot, unregisterSlot, registerFill, unregisterFill]);
75
- return registry;
85
+ };
76
86
  }
77
87
 
78
88
  export default function SlotFillProvider(_ref) {
79
89
  let {
80
90
  children
81
91
  } = _ref;
82
- const registry = useSlotRegistry();
92
+ const [registry] = useState(createSlotRegistry);
83
93
  return createElement(SlotFillContext.Provider, {
84
94
  value: registry
85
95
  }, children);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/slot-fill-provider.js"],"names":["ref","valRef","proxyMap","useMemo","useCallback","useRef","isShallowEqual","SlotFillContext","useSlotRegistry","slots","fills","registerSlot","name","fillProps","slot","current","get","set","unregisterSlot","delete","updateSlot","slotFills","map","fill","rerender","registerFill","unregisterFill","filter","fillRef","registry","SlotFillProvider","children"],"mappings":";AAAA;;AACA;AACA;AACA;AACA,SAASA,GAAG,IAAIC,MAAhB,QAA8B,QAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,EAAkBC,WAAlB,EAA+BC,MAA/B,QAA6C,oBAA7C;AACA,OAAOC,cAAP,MAA2B,6BAA3B;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,qBAA5B;;AAEA,SAASC,eAAT,GAA2B;AAC1B,QAAMC,KAAK,GAAGJ,MAAM,CAAEH,QAAQ,EAAV,CAApB;AACA,QAAMQ,KAAK,GAAGL,MAAM,CAAEH,QAAQ,EAAV,CAApB;AAEA,QAAMS,YAAY,GAAGP,WAAW,CAAE,CAAEQ,IAAF,EAAQZ,GAAR,EAAaa,SAAb,KAA4B;AAC7D,UAAMC,IAAI,GAAGL,KAAK,CAACM,OAAN,CAAcC,GAAd,CAAmBJ,IAAnB,KAA6B,EAA1C;AACAH,IAAAA,KAAK,CAACM,OAAN,CAAcE,GAAd,CACCL,IADD,EAECX,MAAM,CAAE,EACP,GAAGa,IADI;AAEPd,MAAAA,GAAG,EAAEA,GAAG,IAAIc,IAAI,CAACd,GAFV;AAGPa,MAAAA,SAAS,EAAEA,SAAS,IAAIC,IAAI,CAACD,SAAlB,IAA+B;AAHnC,KAAF,CAFP;AAQA,GAV+B,EAU7B,EAV6B,CAAh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AQZ,GAAR,KAAiB;AACpD,QAAKU,KAAK,CAACK,OAAN,CAAcC,GAAd,CAAmBJ,IAAnB,CAAL,EAAiC;AAChCF,MAAAA,KAAK,CAACK,OAAN,CAAcE,GAAd,CACCL,IADD,EAECX,MAAM,CACLS,KAAK,CAACK,OAAN,CACEC,GADF,CACOJ,IADP,EAEEe,MAFF,CAEYC,OAAF,IAAeA,OAAO,KAAK5B,GAFrC,CADK,CAFP;AAQA;AACD,GAXiC,EAW/B,EAX+B,CAAlC,CA/C0B,CA4D1B;;AACA,QAAM6B,QAAQ,GAAG1B,OAAO,CACvB,OAAQ;AACPM,IAAAA,KAAK,EAAEA,KAAK,CAACM,OADN;AAEPL,IAAAA,KAAK,EAAEA,KAAK,CAACK,OAFN;AAGPJ,IAAAA,YAHO;AAIPS,IAAAA,UAJO;AAKPF,IAAAA,cALO;AAMPO,IAAAA,YANO;AAOPC,IAAAA;AAPO,GAAR,CADuB,EAUvB,CACCf,YADD,EAECS,UAFD,EAGCF,cAHD,EAICO,YAJD,EAKCC,cALD,CAVuB,CAAxB;AAmBA,SAAOG,QAAP;AACA;;AAED,eAAe,SAASC,gBAAT,OAA0C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACxD,QAAMF,QAAQ,GAAGrB,eAAe,EAAhC;AACA,SACC,cAAC,eAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAGqB;AAAlC,KACGE,QADH,CADD;AAKA","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport { ref as valRef } from 'valtio';\nimport { proxyMap } from 'valtio/utils';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useCallback, useRef } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './slot-fill-context';\n\nfunction useSlotRegistry() {\n\tconst slots = useRef( proxyMap() );\n\tconst fills = useRef( proxyMap() );\n\n\tconst registerSlot = useCallback( ( name, ref, fillProps ) => {\n\t\tconst slot = slots.current.get( name ) || {};\n\t\tslots.current.set(\n\t\t\tname,\n\t\t\tvalRef( {\n\t\t\t\t...slot,\n\t\t\t\tref: ref || slot.ref,\n\t\t\t\tfillProps: fillProps || slot.fillProps || {},\n\t\t\t} )\n\t\t);\n\t}, [] );\n\n\tconst unregisterSlot = useCallback( ( name, ref ) => {\n\t\t// Make sure we're not unregistering a slot registered by another element\n\t\t// See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412\n\t\tif ( slots.current.get( name )?.ref === ref ) {\n\t\t\tslots.current.delete( name );\n\t\t}\n\t}, [] );\n\n\tconst updateSlot = useCallback( ( name, fillProps ) => {\n\t\tconst slot = slots.current.get( name );\n\t\tif ( ! slot ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! isShallowEqual( slot.fillProps, fillProps ) ) {\n\t\t\tslot.fillProps = fillProps;\n\t\t\tconst slotFills = fills.current.get( name );\n\t\t\tif ( slotFills ) {\n\t\t\t\t// Force update fills.\n\t\t\t\tslotFills.map( ( fill ) => fill.current.rerender() );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\tconst registerFill = useCallback( ( name, ref ) => {\n\t\tfills.current.set(\n\t\t\tname,\n\t\t\tvalRef( [ ...( fills.current.get( name ) || [] ), ref ] )\n\t\t);\n\t}, [] );\n\n\tconst unregisterFill = useCallback( ( name, ref ) => {\n\t\tif ( fills.current.get( name ) ) {\n\t\t\tfills.current.set(\n\t\t\t\tname,\n\t\t\t\tvalRef(\n\t\t\t\t\tfills.current\n\t\t\t\t\t\t.get( name )\n\t\t\t\t\t\t.filter( ( fillRef ) => fillRef !== ref )\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}, [] );\n\n\t// Memoizing the return value so it can be directly passed to Provider value\n\tconst registry = useMemo(\n\t\t() => ( {\n\t\t\tslots: slots.current,\n\t\t\tfills: fills.current,\n\t\t\tregisterSlot,\n\t\t\tupdateSlot,\n\t\t\tunregisterSlot,\n\t\t\tregisterFill,\n\t\t\tunregisterFill,\n\t\t} ),\n\t\t[\n\t\t\tregisterSlot,\n\t\t\tupdateSlot,\n\t\t\tunregisterSlot,\n\t\t\tregisterFill,\n\t\t\tunregisterFill,\n\t\t]\n\t);\n\n\treturn registry;\n}\n\nexport default function SlotFillProvider( { children } ) {\n\tconst registry = useSlotRegistry();\n\treturn (\n\t\t<SlotFillContext.Provider value={ registry }>\n\t\t\t{ children }\n\t\t</SlotFillContext.Provider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/slot-fill-provider.js"],"names":["ref","valRef","proxyMap","useState","isShallowEqual","SlotFillContext","createSlotRegistry","slots","fills","registerSlot","name","fillProps","slot","get","set","unregisterSlot","delete","updateSlot","slotFills","map","fill","current","rerender","registerFill","unregisterFill","fillsForName","filter","fillRef","SlotFillProvider","children","registry"],"mappings":";AAAA;;AACA;AACA;AACA;AACA,SAASA,GAAG,IAAIC,MAAhB,QAA8B,QAA9B;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,OAAOC,cAAP,MAA2B,6BAA3B;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,qBAA5B;;AAEA,SAASC,kBAAT,GAA8B;AAC7B,QAAMC,KAAK,GAAGL,QAAQ,EAAtB;AACA,QAAMM,KAAK,GAAGN,QAAQ,EAAtB;;AAEA,WAASO,YAAT,CAAuBC,IAAvB,EAA6BV,GAA7B,EAAkCW,SAAlC,EAA8C;AAC7C,UAAMC,IAAI,GAAGL,KAAK,CAACM,GAAN,CAAWH,IAAX,KAAqB,EAAlC;AACAH,IAAAA,KAAK,CAACO,GAAN,CACCJ,IADD,EAECT,MAAM,CAAE,EACP,GAAGW,IADI;AAEPZ,MAAAA,GAAG,EAAEA,GAAG,IAAIY,IAAI,CAACZ,GAFV;AAGPW,MAAAA,SAAS,EAAEA,SAAS,IAAIC,IAAI,CAACD,SAAl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,OAAF,IAAeA,OAAO,KAAK3B,GAAhD,CAAF,CAFP;AAIA;;AAED,SAAO;AACNO,IAAAA,KADM;AAENC,IAAAA,KAFM;AAGNC,IAAAA,YAHM;AAINQ,IAAAA,UAJM;AAKNF,IAAAA,cALM;AAMNQ,IAAAA,YANM;AAONC,IAAAA;AAPM,GAAP;AASA;;AAED,eAAe,SAASI,gBAAT,OAA0C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACxD,QAAM,CAAEC,QAAF,IAAe3B,QAAQ,CAAEG,kBAAF,CAA7B;AACA,SACC,cAAC,eAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAGwB;AAAlC,KACGD,QADH,CADD;AAKA","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport { ref as valRef } from 'valtio';\nimport { proxyMap } from 'valtio/utils';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './slot-fill-context';\n\nfunction createSlotRegistry() {\n\tconst slots = proxyMap();\n\tconst fills = proxyMap();\n\n\tfunction registerSlot( name, ref, fillProps ) {\n\t\tconst slot = slots.get( name ) || {};\n\t\tslots.set(\n\t\t\tname,\n\t\t\tvalRef( {\n\t\t\t\t...slot,\n\t\t\t\tref: ref || slot.ref,\n\t\t\t\tfillProps: fillProps || slot.fillProps || {},\n\t\t\t} )\n\t\t);\n\t}\n\n\tfunction unregisterSlot( name, ref ) {\n\t\t// Make sure we're not unregistering a slot registered by another element\n\t\t// See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412\n\t\tif ( slots.get( name )?.ref === ref ) {\n\t\t\tslots.delete( name );\n\t\t}\n\t}\n\n\tfunction updateSlot( name, fillProps ) {\n\t\tconst slot = slots.get( name );\n\t\tif ( ! slot ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isShallowEqual( slot.fillProps, fillProps ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tslot.fillProps = fillProps;\n\t\tconst slotFills = fills.get( name );\n\t\tif ( slotFills ) {\n\t\t\t// Force update fills.\n\t\t\tslotFills.map( ( fill ) => fill.current.rerender() );\n\t\t}\n\t}\n\n\tfunction registerFill( name, ref ) {\n\t\tfills.set( name, valRef( [ ...( fills.get( name ) || [] ), ref ] ) );\n\t}\n\n\tfunction unregisterFill( name, ref ) {\n\t\tconst fillsForName = fills.get( name );\n\t\tif ( ! fillsForName ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfills.set(\n\t\t\tname,\n\t\t\tvalRef( fillsForName.filter( ( fillRef ) => fillRef !== ref ) )\n\t\t);\n\t}\n\n\treturn {\n\t\tslots,\n\t\tfills,\n\t\tregisterSlot,\n\t\tupdateSlot,\n\t\tunregisterSlot,\n\t\tregisterFill,\n\t\tunregisterFill,\n\t};\n}\n\nexport default function SlotFillProvider( { children } ) {\n\tconst [ registry ] = useState( createSlotRegistry );\n\treturn (\n\t\t<SlotFillContext.Provider value={ registry }>\n\t\t\t{ children }\n\t\t</SlotFillContext.Provider>\n\t);\n}\n"]}
@@ -8,44 +8,29 @@ import { useSnapshot } from 'valtio';
8
8
  * WordPress dependencies
9
9
  */
10
10
 
11
- import { useCallback, useContext } from '@wordpress/element';
11
+ import { useMemo, useContext } from '@wordpress/element';
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
15
 
16
16
  import SlotFillContext from './slot-fill-context';
17
17
  export default function useSlot(name) {
18
- const {
19
- updateSlot: registryUpdateSlot,
20
- unregisterSlot: registryUnregisterSlot,
21
- registerFill: registryRegisterFill,
22
- unregisterFill: registryUnregisterFill,
23
- ...registry
24
- } = useContext(SlotFillContext);
18
+ const registry = useContext(SlotFillContext);
25
19
  const slots = useSnapshot(registry.slots, {
26
20
  sync: true
27
- }); // The important bit here is that this call ensures
28
- // the hook only causes a re-render if the slot
29
- // with the given name change, not any other slot.
21
+ }); // The important bit here is that the `useSnapshot` call ensures that the
22
+ // hook only causes a re-render if the slot with the given name changes,
23
+ // not any other slot.
30
24
 
31
25
  const slot = slots.get(name);
32
- const updateSlot = useCallback(fillProps => {
33
- registryUpdateSlot(name, fillProps);
34
- }, [name, registryUpdateSlot]);
35
- const unregisterSlot = useCallback(slotRef => {
36
- registryUnregisterSlot(name, slotRef);
37
- }, [name, registryUnregisterSlot]);
38
- const registerFill = useCallback(fillRef => {
39
- registryRegisterFill(name, fillRef);
40
- }, [name, registryRegisterFill]);
41
- const unregisterFill = useCallback(fillRef => {
42
- registryUnregisterFill(name, fillRef);
43
- }, [name, registryUnregisterFill]);
26
+ const api = useMemo(() => ({
27
+ updateSlot: fillProps => registry.updateSlot(name, fillProps),
28
+ unregisterSlot: ref => registry.unregisterSlot(name, ref),
29
+ registerFill: ref => registry.registerFill(name, ref),
30
+ unregisterFill: ref => registry.unregisterFill(name, ref)
31
+ }), [name, registry]);
44
32
  return { ...slot,
45
- updateSlot,
46
- unregisterSlot,
47
- registerFill,
48
- unregisterFill
33
+ ...api
49
34
  };
50
35
  }
51
36
  //# sourceMappingURL=use-slot.js.map