@wordpress/components 23.9.0 → 25.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 (423) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/CONTRIBUTING.md +75 -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/color-picker/styles.js +8 -8
  13. package/build/color-picker/styles.js.map +1 -1
  14. package/build/combobox-control/index.js +7 -5
  15. package/build/combobox-control/index.js.map +1 -1
  16. package/build/combobox-control/styles.js +3 -3
  17. package/build/combobox-control/styles.js.map +1 -1
  18. package/build/date-time/date-time/index.js +3 -84
  19. package/build/date-time/date-time/index.js.map +1 -1
  20. package/build/date-time/date-time/styles.js +4 -19
  21. package/build/date-time/date-time/styles.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 +2 -7
  25. package/build/draggable/index.js.map +1 -1
  26. package/build/dropdown-menu/index.js +87 -11
  27. package/build/dropdown-menu/index.js.map +1 -1
  28. package/build/dropdown-menu/types.js +6 -0
  29. package/build/dropdown-menu/types.js.map +1 -0
  30. package/build/dropdown-menu-v2/index.js +195 -0
  31. package/build/dropdown-menu-v2/index.js.map +1 -0
  32. package/build/dropdown-menu-v2/styles.js +176 -0
  33. package/build/dropdown-menu-v2/styles.js.map +1 -0
  34. package/build/dropdown-menu-v2/types.js +6 -0
  35. package/build/dropdown-menu-v2/types.js.map +1 -0
  36. package/build/form-token-field/index.js +5 -3
  37. package/build/form-token-field/index.js.map +1 -1
  38. package/build/form-token-field/styles.js +3 -3
  39. package/build/form-token-field/styles.js.map +1 -1
  40. package/build/index.native.js +0 -9
  41. package/build/index.native.js.map +1 -1
  42. package/build/input-control/styles/input-control-styles.js +30 -23
  43. package/build/input-control/styles/input-control-styles.js.map +1 -1
  44. package/build/mobile/bottom-sheet/cell.native.js +16 -8
  45. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  46. package/build/mobile/bottom-sheet/range-cell.native.js +3 -2
  47. package/build/mobile/bottom-sheet/range-cell.native.js.map +1 -1
  48. package/build/mobile/bottom-sheet/stepper-cell/index.native.js +4 -2
  49. package/build/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  50. package/build/mobile/bottom-sheet/switch-cell.native.js +8 -2
  51. package/build/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
  52. package/build/mobile/bottom-sheet-select-control/index.native.js +4 -2
  53. package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  54. package/build/mobile/bottom-sheet-text-control/index.native.js +4 -2
  55. package/build/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
  56. package/build/mobile/global-styles-context/index.native.js +13 -1
  57. package/build/mobile/global-styles-context/index.native.js.map +1 -1
  58. package/build/mobile/link-picker/link-picker-results.native.js +3 -1
  59. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  60. package/build/navigable-container/container.js +39 -19
  61. package/build/navigable-container/container.js.map +1 -1
  62. package/build/navigable-container/index.js.map +1 -1
  63. package/build/navigable-container/menu.js +37 -5
  64. package/build/navigable-container/menu.js.map +1 -1
  65. package/build/navigable-container/tabbable.js +45 -4
  66. package/build/navigable-container/tabbable.js.map +1 -1
  67. package/build/navigable-container/types.js +6 -0
  68. package/build/navigable-container/types.js.map +1 -0
  69. package/build/palette-edit/index.js +34 -12
  70. package/build/palette-edit/index.js.map +1 -1
  71. package/build/private-apis.js +13 -1
  72. package/build/private-apis.js.map +1 -1
  73. package/build/range-control/index.native.js +5 -2
  74. package/build/range-control/index.native.js.map +1 -1
  75. package/build/sandbox/index.native.js +6 -2
  76. package/build/sandbox/index.native.js.map +1 -1
  77. package/build/slot-fill/bubbles-virtually/fill.js +2 -1
  78. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  79. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +45 -35
  80. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  81. package/build/slot-fill/bubbles-virtually/use-slot.js +11 -26
  82. package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  83. package/build/slot-fill/fill.js +7 -31
  84. package/build/slot-fill/fill.js.map +1 -1
  85. package/build/slot-fill/index.js.map +1 -1
  86. package/build/slot-fill/provider.js +0 -6
  87. package/build/slot-fill/provider.js.map +1 -1
  88. package/build/slot-fill/slot.js +0 -5
  89. package/build/slot-fill/slot.js.map +1 -1
  90. package/build/snackbar/list.js +0 -2
  91. package/build/snackbar/list.js.map +1 -1
  92. package/build/tab-panel/index.js.map +1 -1
  93. package/build/theme/color-algorithms.js +1 -1
  94. package/build/theme/color-algorithms.js.map +1 -1
  95. package/build/toggle-group-control/toggle-group-control/styles.js +7 -7
  96. package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  97. package/build/toolbar/toolbar-button/index.js +1 -2
  98. package/build/toolbar/toolbar-button/index.js.map +1 -1
  99. package/build/toolbar/toolbar-item/index.js +4 -2
  100. package/build/toolbar/toolbar-item/index.js.map +1 -1
  101. package/build/utils/colors-values.js +3 -3
  102. package/build/utils/colors-values.js.map +1 -1
  103. package/build/utils/use-deprecated-props.js +35 -0
  104. package/build/utils/use-deprecated-props.js.map +1 -0
  105. package/build-module/autocomplete/autocompleter-ui.js +1 -3
  106. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  107. package/build-module/autocomplete/index.js +3 -3
  108. package/build-module/autocomplete/index.js.map +1 -1
  109. package/build-module/button/index.js +2 -0
  110. package/build-module/button/index.js.map +1 -1
  111. package/build-module/card/card-media/component.js +2 -1
  112. package/build-module/card/card-media/component.js.map +1 -1
  113. package/build-module/color-picker/styles.js +8 -8
  114. package/build-module/color-picker/styles.js.map +1 -1
  115. package/build-module/combobox-control/index.js +6 -5
  116. package/build-module/combobox-control/index.js.map +1 -1
  117. package/build-module/combobox-control/styles.js +3 -3
  118. package/build-module/combobox-control/styles.js.map +1 -1
  119. package/build-module/date-time/date-time/index.js +6 -81
  120. package/build-module/date-time/date-time/index.js.map +1 -1
  121. package/build-module/date-time/date-time/styles.js +3 -17
  122. package/build-module/date-time/date-time/styles.js.map +1 -1
  123. package/build-module/dimension-control/index.js +1 -1
  124. package/build-module/dimension-control/index.js.map +1 -1
  125. package/build-module/draggable/index.js +2 -7
  126. package/build-module/draggable/index.js.map +1 -1
  127. package/build-module/dropdown-menu/index.js +87 -10
  128. package/build-module/dropdown-menu/index.js.map +1 -1
  129. package/build-module/dropdown-menu/types.js +2 -0
  130. package/build-module/dropdown-menu/types.js.map +1 -0
  131. package/build-module/dropdown-menu-v2/index.js +149 -0
  132. package/build-module/dropdown-menu-v2/index.js.map +1 -0
  133. package/build-module/dropdown-menu-v2/styles.js +153 -0
  134. package/build-module/dropdown-menu-v2/styles.js.map +1 -0
  135. package/build-module/dropdown-menu-v2/types.js +2 -0
  136. package/build-module/dropdown-menu-v2/types.js.map +1 -0
  137. package/build-module/form-token-field/index.js +4 -3
  138. package/build-module/form-token-field/index.js.map +1 -1
  139. package/build-module/form-token-field/styles.js +3 -3
  140. package/build-module/form-token-field/styles.js.map +1 -1
  141. package/build-module/index.native.js +0 -1
  142. package/build-module/index.native.js.map +1 -1
  143. package/build-module/input-control/styles/input-control-styles.js +30 -23
  144. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  145. package/build-module/mobile/bottom-sheet/cell.native.js +16 -8
  146. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  147. package/build-module/mobile/bottom-sheet/range-cell.native.js +3 -2
  148. package/build-module/mobile/bottom-sheet/range-cell.native.js.map +1 -1
  149. package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js +4 -2
  150. package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
  151. package/build-module/mobile/bottom-sheet/switch-cell.native.js +7 -2
  152. package/build-module/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
  153. package/build-module/mobile/bottom-sheet-select-control/index.native.js +4 -2
  154. package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
  155. package/build-module/mobile/bottom-sheet-text-control/index.native.js +4 -2
  156. package/build-module/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
  157. package/build-module/mobile/global-styles-context/index.native.js +13 -1
  158. package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
  159. package/build-module/mobile/link-picker/link-picker-results.native.js +3 -1
  160. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  161. package/build-module/navigable-container/container.js +43 -19
  162. package/build-module/navigable-container/container.js.map +1 -1
  163. package/build-module/navigable-container/index.js +0 -2
  164. package/build-module/navigable-container/index.js.map +1 -1
  165. package/build-module/navigable-container/menu.js +36 -4
  166. package/build-module/navigable-container/menu.js.map +1 -1
  167. package/build-module/navigable-container/tabbable.js +44 -3
  168. package/build-module/navigable-container/tabbable.js.map +1 -1
  169. package/build-module/navigable-container/types.js +2 -0
  170. package/build-module/navigable-container/types.js.map +1 -0
  171. package/build-module/palette-edit/index.js +34 -13
  172. package/build-module/palette-edit/index.js.map +1 -1
  173. package/build-module/private-apis.js +12 -1
  174. package/build-module/private-apis.js.map +1 -1
  175. package/build-module/range-control/index.native.js +5 -2
  176. package/build-module/range-control/index.native.js.map +1 -1
  177. package/build-module/sandbox/index.native.js +6 -2
  178. package/build-module/sandbox/index.native.js.map +1 -1
  179. package/build-module/slot-fill/bubbles-virtually/fill.js +2 -1
  180. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  181. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -36
  182. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  183. package/build-module/slot-fill/bubbles-virtually/use-slot.js +12 -27
  184. package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  185. package/build-module/slot-fill/fill.js +7 -31
  186. package/build-module/slot-fill/fill.js.map +1 -1
  187. package/build-module/slot-fill/index.js +1 -2
  188. package/build-module/slot-fill/index.js.map +1 -1
  189. package/build-module/slot-fill/provider.js +0 -6
  190. package/build-module/slot-fill/provider.js.map +1 -1
  191. package/build-module/slot-fill/slot.js +0 -5
  192. package/build-module/slot-fill/slot.js.map +1 -1
  193. package/build-module/snackbar/list.js +0 -2
  194. package/build-module/snackbar/list.js.map +1 -1
  195. package/build-module/tab-panel/index.js.map +1 -1
  196. package/build-module/theme/color-algorithms.js +1 -1
  197. package/build-module/theme/color-algorithms.js.map +1 -1
  198. package/build-module/toggle-group-control/toggle-group-control/styles.js +7 -7
  199. package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  200. package/build-module/toolbar/toolbar-button/index.js +1 -2
  201. package/build-module/toolbar/toolbar-button/index.js.map +1 -1
  202. package/build-module/toolbar/toolbar-item/index.js +5 -2
  203. package/build-module/toolbar/toolbar-item/index.js.map +1 -1
  204. package/build-module/utils/colors-values.js +3 -3
  205. package/build-module/utils/colors-values.js.map +1 -1
  206. package/build-module/utils/use-deprecated-props.js +25 -0
  207. package/build-module/utils/use-deprecated-props.js.map +1 -0
  208. package/build-style/style-rtl.css +67 -67
  209. package/build-style/style.css +67 -67
  210. package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
  211. package/build-types/autocomplete/index.d.ts.map +1 -1
  212. package/build-types/autocomplete/types.d.ts +2 -18
  213. package/build-types/autocomplete/types.d.ts.map +1 -1
  214. package/build-types/button/deprecated.d.ts +6 -0
  215. package/build-types/button/deprecated.d.ts.map +1 -1
  216. package/build-types/button/index.d.ts.map +1 -1
  217. package/build-types/button/types.d.ts +7 -0
  218. package/build-types/button/types.d.ts.map +1 -1
  219. package/build-types/card/card-media/component.d.ts +2 -1
  220. package/build-types/card/card-media/component.d.ts.map +1 -1
  221. package/build-types/card/stories/index.d.ts +21 -1
  222. package/build-types/card/stories/index.d.ts.map +1 -1
  223. package/build-types/color-picker/styles.d.ts.map +1 -1
  224. package/build-types/combobox-control/index.d.ts +1 -1
  225. package/build-types/combobox-control/index.d.ts.map +1 -1
  226. package/build-types/combobox-control/stories/index.d.ts.map +1 -1
  227. package/build-types/combobox-control/styles.d.ts +1 -1
  228. package/build-types/combobox-control/types.d.ts +8 -1
  229. package/build-types/combobox-control/types.d.ts.map +1 -1
  230. package/build-types/date-time/date-time/index.d.ts +3 -4
  231. package/build-types/date-time/date-time/index.d.ts.map +1 -1
  232. package/build-types/date-time/date-time/styles.d.ts +0 -4
  233. package/build-types/date-time/date-time/styles.d.ts.map +1 -1
  234. package/build-types/date-time/stories/date-time.d.ts.map +1 -1
  235. package/build-types/date-time/types.d.ts +0 -14
  236. package/build-types/date-time/types.d.ts.map +1 -1
  237. package/build-types/dimension-control/index.d.ts +1 -1
  238. package/build-types/draggable/index.d.ts.map +1 -1
  239. package/build-types/dropdown-menu/index.d.ts +83 -1
  240. package/build-types/dropdown-menu/index.d.ts.map +1 -1
  241. package/build-types/dropdown-menu/stories/index.d.ts +13 -0
  242. package/build-types/dropdown-menu/stories/index.d.ts.map +1 -0
  243. package/build-types/dropdown-menu/test/index.d.ts +2 -0
  244. package/build-types/dropdown-menu/test/index.d.ts.map +1 -0
  245. package/build-types/dropdown-menu/types.d.ts +134 -0
  246. package/build-types/dropdown-menu/types.d.ts.map +1 -0
  247. package/build-types/dropdown-menu-v2/index.d.ts +17 -0
  248. package/build-types/dropdown-menu-v2/index.d.ts.map +1 -0
  249. package/build-types/dropdown-menu-v2/stories/index.d.ts +13 -0
  250. package/build-types/dropdown-menu-v2/stories/index.d.ts.map +1 -0
  251. package/build-types/dropdown-menu-v2/styles.d.ts +41 -0
  252. package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -0
  253. package/build-types/dropdown-menu-v2/test/index.d.ts +2 -0
  254. package/build-types/dropdown-menu-v2/test/index.d.ts.map +1 -0
  255. package/build-types/dropdown-menu-v2/types.d.ts +242 -0
  256. package/build-types/dropdown-menu-v2/types.d.ts.map +1 -0
  257. package/build-types/form-token-field/index.d.ts.map +1 -1
  258. package/build-types/form-token-field/styles.d.ts +1 -1
  259. package/build-types/form-token-field/types.d.ts +8 -1
  260. package/build-types/form-token-field/types.d.ts.map +1 -1
  261. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  262. package/build-types/navigable-container/container.d.ts +20 -1
  263. package/build-types/navigable-container/container.d.ts.map +1 -1
  264. package/build-types/navigable-container/index.d.ts +5 -2
  265. package/build-types/navigable-container/index.d.ts.map +1 -1
  266. package/build-types/navigable-container/menu.d.ts +45 -11
  267. package/build-types/navigable-container/menu.d.ts.map +1 -1
  268. package/build-types/navigable-container/stories/navigable-menu.d.ts +12 -0
  269. package/build-types/navigable-container/stories/navigable-menu.d.ts.map +1 -0
  270. package/build-types/navigable-container/stories/tabbable-container.d.ts +12 -0
  271. package/build-types/navigable-container/stories/tabbable-container.d.ts.map +1 -0
  272. package/build-types/navigable-container/tabbable.d.ts +52 -9
  273. package/build-types/navigable-container/tabbable.d.ts.map +1 -1
  274. package/build-types/navigable-container/test/navigable-menu.d.ts +2 -0
  275. package/build-types/navigable-container/test/navigable-menu.d.ts.map +1 -0
  276. package/build-types/navigable-container/test/tababble-container.d.ts +2 -0
  277. package/build-types/navigable-container/test/tababble-container.d.ts.map +1 -0
  278. package/build-types/navigable-container/types.d.ts +61 -0
  279. package/build-types/navigable-container/types.d.ts.map +1 -0
  280. package/build-types/navigator/navigator-back-button/component.d.ts +1 -0
  281. package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
  282. package/build-types/navigator/navigator-back-button/hook.d.ts +1 -0
  283. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  284. package/build-types/navigator/navigator-button/component.d.ts +1 -0
  285. package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
  286. package/build-types/navigator/navigator-button/hook.d.ts +1 -0
  287. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  288. package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -0
  289. package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
  290. package/build-types/palette-edit/index.d.ts +1 -1
  291. package/build-types/palette-edit/index.d.ts.map +1 -1
  292. package/build-types/palette-edit/stories/index.d.ts.map +1 -1
  293. package/build-types/palette-edit/types.d.ts +8 -0
  294. package/build-types/palette-edit/types.d.ts.map +1 -1
  295. package/build-types/private-apis.d.ts.map +1 -1
  296. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  297. package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
  298. package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
  299. package/build-types/slot-fill/fill.d.ts +4 -2
  300. package/build-types/slot-fill/fill.d.ts.map +1 -1
  301. package/build-types/slot-fill/index.d.ts +1 -2
  302. package/build-types/slot-fill/index.d.ts.map +1 -1
  303. package/build-types/slot-fill/provider.d.ts +0 -2
  304. package/build-types/slot-fill/provider.d.ts.map +1 -1
  305. package/build-types/slot-fill/slot.d.ts.map +1 -1
  306. package/build-types/snackbar/list.d.ts.map +1 -1
  307. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
  308. package/build-types/toolbar/stories/index.d.ts.map +1 -1
  309. package/build-types/toolbar/toolbar-button/index.d.ts +6 -0
  310. package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
  311. package/build-types/toolbar/toolbar-item/index.d.ts +6 -4
  312. package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
  313. package/build-types/tree-grid/types.d.ts +7 -0
  314. package/build-types/tree-grid/types.d.ts.map +1 -1
  315. package/build-types/ui/context/get-styled-class-name-from-key.d.ts +1 -10
  316. package/build-types/ui/context/get-styled-class-name-from-key.d.ts.map +1 -1
  317. package/build-types/utils/use-deprecated-props.d.ts +9 -0
  318. package/build-types/utils/use-deprecated-props.d.ts.map +1 -0
  319. package/package.json +21 -20
  320. package/src/autocomplete/README.md +78 -52
  321. package/src/autocomplete/autocompleter-ui.tsx +0 -2
  322. package/src/autocomplete/index.tsx +1 -2
  323. package/src/autocomplete/types.ts +3 -19
  324. package/src/button/index.tsx +2 -0
  325. package/src/button/style.scss +18 -18
  326. package/src/button/types.ts +7 -0
  327. package/src/card/card-media/README.md +1 -1
  328. package/src/card/card-media/component.tsx +2 -1
  329. package/src/card/stories/index.tsx +47 -26
  330. package/src/checkbox-control/style.scss +1 -4
  331. package/src/color-picker/styles.ts +7 -2
  332. package/src/combobox-control/index.tsx +24 -18
  333. package/src/combobox-control/stories/index.tsx +0 -1
  334. package/src/combobox-control/styles.ts +4 -4
  335. package/src/combobox-control/types.ts +8 -1
  336. package/src/custom-gradient-picker/style.scss +2 -2
  337. package/src/date-time/README.md +0 -16
  338. package/src/date-time/date-time/index.tsx +17 -155
  339. package/src/date-time/date-time/styles.ts +0 -4
  340. package/src/date-time/stories/date-time.tsx +0 -4
  341. package/src/date-time/types.ts +0 -16
  342. package/src/dimension-control/index.tsx +1 -1
  343. package/src/draggable/index.tsx +1 -9
  344. package/src/dropdown-menu/README.md +12 -22
  345. package/src/dropdown-menu/{index.js → index.tsx} +111 -25
  346. package/src/dropdown-menu/stories/{index.js → index.tsx} +14 -22
  347. package/src/dropdown-menu/test/{index.js → index.tsx} +6 -5
  348. package/src/dropdown-menu/types.ts +143 -0
  349. package/src/dropdown-menu-v2/README.md +392 -0
  350. package/src/dropdown-menu-v2/index.tsx +241 -0
  351. package/src/dropdown-menu-v2/stories/index.tsx +193 -0
  352. package/src/dropdown-menu-v2/styles.ts +263 -0
  353. package/src/dropdown-menu-v2/test/index.tsx +816 -0
  354. package/src/dropdown-menu-v2/types.ts +250 -0
  355. package/src/form-toggle/style.scss +1 -5
  356. package/src/form-token-field/index.tsx +7 -3
  357. package/src/form-token-field/styles.ts +4 -4
  358. package/src/form-token-field/types.ts +8 -1
  359. package/src/index.native.js +0 -1
  360. package/src/input-control/styles/input-control-styles.tsx +7 -0
  361. package/src/mobile/bottom-sheet/cell.native.js +26 -5
  362. package/src/mobile/bottom-sheet/range-cell.native.js +2 -1
  363. package/src/mobile/bottom-sheet/stepper-cell/index.native.js +2 -0
  364. package/src/mobile/bottom-sheet/styles.native.scss +13 -1
  365. package/src/mobile/bottom-sheet/switch-cell.native.js +10 -2
  366. package/src/mobile/bottom-sheet-select-control/index.native.js +2 -0
  367. package/src/mobile/bottom-sheet-text-control/index.native.js +2 -0
  368. package/src/mobile/global-styles-context/index.native.js +12 -1
  369. package/src/mobile/link-picker/link-picker-results.native.js +3 -0
  370. package/src/modal/style.scss +1 -1
  371. package/src/navigable-container/README.md +24 -13
  372. package/src/navigable-container/{container.js → container.tsx} +57 -27
  373. package/src/navigable-container/{index.js → index.tsx} +0 -1
  374. package/src/navigable-container/menu.tsx +100 -0
  375. package/src/navigable-container/stories/{navigable-menu.js → navigable-menu.tsx} +15 -10
  376. package/src/navigable-container/stories/{tabbable-container.js → tabbable-container.tsx} +15 -6
  377. package/src/navigable-container/tabbable.tsx +92 -0
  378. package/src/navigable-container/test/{navigable-menu.js → navigable-menu.tsx} +3 -1
  379. package/src/navigable-container/test/{tababble-container.js → tababble-container.tsx} +53 -24
  380. package/src/navigable-container/types.ts +76 -0
  381. package/src/palette-edit/index.tsx +45 -7
  382. package/src/palette-edit/stories/index.tsx +4 -0
  383. package/src/palette-edit/types.ts +11 -0
  384. package/src/private-apis.ts +22 -0
  385. package/src/range-control/index.native.js +3 -0
  386. package/src/sandbox/index.native.js +4 -0
  387. package/src/search-control/style.scss +2 -0
  388. package/src/slot-fill/bubbles-virtually/fill.js +2 -1
  389. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -60
  390. package/src/slot-fill/bubbles-virtually/use-slot.js +14 -41
  391. package/src/slot-fill/fill.js +4 -26
  392. package/src/slot-fill/index.js +1 -3
  393. package/src/slot-fill/provider.js +0 -6
  394. package/src/slot-fill/slot.js +0 -5
  395. package/src/snackbar/list.tsx +0 -1
  396. package/src/style.scss +6 -0
  397. package/src/tab-panel/index.tsx +1 -1
  398. package/src/theme/color-algorithms.ts +1 -1
  399. package/src/theme/stories/index.tsx +1 -1
  400. package/src/theme/test/color-algorithms.ts +2 -2
  401. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +10 -6
  402. package/src/toggle-group-control/toggle-group-control/styles.ts +6 -1
  403. package/src/toolbar/stories/index.tsx +25 -26
  404. package/src/toolbar/toolbar-button/index.tsx +10 -13
  405. package/src/toolbar/toolbar-item/{index.js → index.tsx} +12 -3
  406. package/src/tooltip/style.scss +2 -2
  407. package/src/tree-grid/README.md +18 -0
  408. package/src/tree-grid/types.ts +7 -0
  409. package/src/utils/colors-values.js +3 -3
  410. package/src/utils/theme-variables.scss +4 -4
  411. package/src/utils/use-deprecated-props.ts +29 -0
  412. package/tsconfig.json +1 -0
  413. package/tsconfig.tsbuildinfo +1 -1
  414. package/build/mobile/readable-content-view/index.native.js +0 -97
  415. package/build/mobile/readable-content-view/index.native.js.map +0 -1
  416. package/build-module/mobile/readable-content-view/index.native.js +0 -81
  417. package/build-module/mobile/readable-content-view/index.native.js.map +0 -1
  418. package/src/CONTRIBUTING.md +0 -78
  419. package/src/README.md +0 -20
  420. package/src/mobile/readable-content-view/index.native.js +0 -85
  421. package/src/mobile/readable-content-view/style.native.scss +0 -30
  422. package/src/navigable-container/menu.js +0 -62
  423. package/src/navigable-container/tabbable.js +0 -46
@@ -4,12 +4,13 @@ import { createElement, Fragment } from "@wordpress/element";
4
4
  /**
5
5
  * External dependencies
6
6
  */
7
+ import classnames from 'classnames';
7
8
  import { paramCase as kebabCase } from 'change-case';
8
9
  /**
9
10
  * WordPress dependencies
10
11
  */
11
12
 
12
- import { useState, useRef, useEffect, useCallback } from '@wordpress/element';
13
+ import { useState, useRef, useEffect, useCallback, useMemo } from '@wordpress/element';
13
14
  import { __, sprintf } from '@wordpress/i18n';
14
15
  import { lineSolid, moreVertical, plus } from '@wordpress/icons';
15
16
  import { __experimentalUseFocusOutside as useFocusOutside, useDebounce } from '@wordpress/compose';
@@ -86,14 +87,19 @@ function ColorPickerPopover(_ref2) {
86
87
  isGradient,
87
88
  element,
88
89
  onChange,
90
+ popoverProps: receivedPopoverProps,
89
91
  onClose = () => {}
90
92
  } = _ref2;
91
- return createElement(Popover, {
92
- placement: "left-start",
93
+ const popoverProps = useMemo(() => ({
94
+ shift: true,
93
95
  offset: 20,
94
- className: "components-palette-edit__popover",
96
+ placement: 'left-start',
97
+ ...receivedPopoverProps,
98
+ className: classnames('components-palette-edit__popover', receivedPopoverProps === null || receivedPopoverProps === void 0 ? void 0 : receivedPopoverProps.className)
99
+ }), [receivedPopoverProps]);
100
+ return createElement(Popover, _extends({}, popoverProps, {
95
101
  onClose: onClose
96
- }, !isGradient && createElement(ColorPicker, {
102
+ }), !isGradient && createElement(ColorPicker, {
97
103
  color: element.color,
98
104
  enableAlpha: true,
99
105
  onChange: newColor => {
@@ -124,15 +130,24 @@ function Option(_ref3) {
124
130
  onStartEditing,
125
131
  onRemove,
126
132
  onStopEditing,
133
+ popoverProps: receivedPopoverProps,
127
134
  slugPrefix,
128
135
  isGradient
129
136
  } = _ref3;
130
137
  const focusOutsideProps = useFocusOutside(onStopEditing);
131
- const value = isGradient ? element.gradient : element.color;
138
+ const value = isGradient ? element.gradient : element.color; // Use internal state instead of a ref to make sure that the component
139
+ // re-renders when the popover's anchor updates.
140
+
141
+ const [popoverAnchor, setPopoverAnchor] = useState(null);
142
+ const popoverProps = useMemo(() => ({ ...receivedPopoverProps,
143
+ // Use the custom palette color item as the popover anchor.
144
+ anchor: popoverAnchor
145
+ }), [popoverAnchor, receivedPopoverProps]);
132
146
  return createElement(PaletteItem, _extends({
133
147
  className: isEditing ? 'is-selected' : undefined,
134
148
  as: "div",
135
- onClick: onStartEditing
149
+ onClick: onStartEditing,
150
+ ref: setPopoverAnchor
136
151
  }, isEditing ? { ...focusOutsideProps
137
152
  } : {
138
153
  style: {
@@ -160,7 +175,8 @@ function Option(_ref3) {
160
175
  }))), isEditing && createElement(ColorPickerPopover, {
161
176
  isGradient: isGradient,
162
177
  onChange: onChange,
163
- element: element
178
+ element: element,
179
+ popoverProps: popoverProps
164
180
  }));
165
181
  }
166
182
 
@@ -182,7 +198,8 @@ function PaletteEditListView(_ref5) {
182
198
  setEditingElement,
183
199
  canOnlyChangeValues,
184
200
  slugPrefix,
185
- isGradient
201
+ isGradient,
202
+ popoverProps
186
203
  } = _ref5;
187
204
  // When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.
188
205
  const elementsReference = useRef();
@@ -242,7 +259,8 @@ function PaletteEditListView(_ref5) {
242
259
  setEditingElement(null);
243
260
  }
244
261
  },
245
- slugPrefix: slugPrefix
262
+ slugPrefix: slugPrefix,
263
+ popoverProps: popoverProps
246
264
  }))));
247
265
  }
248
266
 
@@ -278,7 +296,8 @@ export function PaletteEdit(_ref6) {
278
296
  emptyMessage,
279
297
  canOnlyChangeValues,
280
298
  canReset,
281
- slugPrefix = ''
299
+ slugPrefix = '',
300
+ popoverProps
282
301
  } = _ref6;
283
302
  const isGradient = !!gradients;
284
303
  const elements = isGradient ? gradients : colors;
@@ -375,7 +394,8 @@ export function PaletteEdit(_ref6) {
375
394
  editingElement: editingElement,
376
395
  setEditingElement: setEditingElement,
377
396
  slugPrefix: slugPrefix,
378
- isGradient: isGradient
397
+ isGradient: isGradient,
398
+ popoverProps: popoverProps
379
399
  }), !isEditing && editingElement !== null && createElement(ColorPickerPopover, {
380
400
  isGradient: isGradient,
381
401
  onClose: () => setEditingElement(null),
@@ -389,7 +409,8 @@ export function PaletteEdit(_ref6) {
389
409
  return currentElement;
390
410
  }));
391
411
  },
392
- element: elements[editingElement !== null && editingElement !== void 0 ? editingElement : -1]
412
+ element: elements[editingElement !== null && editingElement !== void 0 ? editingElement : -1],
413
+ popoverProps: popoverProps
393
414
  }), !isEditing && (isGradient ? createElement(GradientPicker, {
394
415
  __nextHasNoMargin: true,
395
416
  gradients: gradients,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/palette-edit/index.tsx"],"names":["paramCase","kebabCase","useState","useRef","useEffect","useCallback","__","sprintf","lineSolid","moreVertical","plus","__experimentalUseFocusOutside","useFocusOutside","useDebounce","Button","ColorPicker","FlexItem","HStack","ItemGroup","VStack","GradientPicker","ColorPalette","DropdownMenu","Popover","PaletteActionsContainer","PaletteEditStyles","PaletteHeading","PaletteHStackHeader","IndicatorStyled","PaletteItem","NameContainer","NameInputControl","DoneButton","RemoveButton","NavigableMenu","DEFAULT_GRADIENT","CustomGradientPicker","DEFAULT_COLOR","NameInput","value","onChange","label","getNameForPosition","elements","slugPrefix","temporaryNameRegex","RegExp","position","reduce","previousValue","currentValue","slug","matches","match","id","parseInt","ColorPickerPopover","isGradient","element","onClose","color","newColor","gradient","newGradient","Option","canOnlyChangeValues","isEditing","onStartEditing","onRemove","onStopEditing","focusOutsideProps","undefined","style","cursor","background","name","nextName","isTemporaryElement","regex","test","PaletteEditListView","editingElement","setEditingElement","elementsReference","current","some","newElements","filter","length","debounceOnChange","map","index","newElement","currentElement","currentIndex","_currentElement","EMPTY_ARRAY","PaletteEdit","gradients","colors","paletteLabel","paletteLabelHeadingLevel","emptyMessage","canReset","setIsEditing","isAdding","elementsLength","hasElements","onSelectPaletteItem","newEditingElementIndex","selectedElement","key","tempOptionName","isSmall"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAtB,QAAuC,aAAvC;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,SAA3B,EAAsCC,WAAtC,QAAyD,oBAAzD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,EAAoBC,YAApB,EAAkCC,IAAlC,QAA8C,kBAA9C;AACA,SACCC,6BAA6B,IAAIC,eADlC,EAECC,WAFD,QAGO,oBAH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;AAHD;AAIC,IAAA,QAAQ,EAAGH,QAJZ;AAKC,IAAA,cAAc,EAAGyC,cALlB;AAMC,IAAA,iBAAiB,EAAGC,iBANrB;AAOC,IAAA,UAAU,EAAGtC,UAPd;AAQC,IAAA,UAAU,EAAGa;AARd,IAFF,EAaG,CAAES,SAAF,IAAee,cAAc,KAAK,IAAlC,IACD,cAAC,kBAAD;AACC,IAAA,UAAU,EAAGxB,UADd;AAEC,IAAA,OAAO,EAAG,MAAMyB,iBAAiB,CAAE,IAAF,CAFlC;AAGC,IAAA,QAAQ,EACPU,UADU,IAEN;AACJH,MAAAA,gBAAgB,EACf;AACA9C,MAAAA,QAAQ,CAAC+C,GAAT,CACC,CACCG,cADD,EAECC,YAFD,KAGK;AACJ,YACCA,YAAY,KAAKb,cADlB,EAEE;AACD,iBAAOW,UAAP;AACA;;AACD,eAAOC,cAAP;AACA,OAXF,CAFe,CAAhB;AAgBA,KAtBF;AAuBC,IAAA,OAAO,EAAGlD,QAAQ,CAAEsC,cAAF,aAAEA,cAAF,cAAEA,cAAF,GAAoB,CAAC,CAArB;AAvBnB,IAdF,EAwCG,CAAEf,SAAF,KACCT,UAAU,GACX,cAAC,cAAD;AACC,IAAA,iBAAiB,MADlB;AAEC,IAAA,SAAS,EAAGyC,SAFb;AAGC,IAAA,QAAQ,EAAGU,mBAHZ;AAIC,IAAA,SAAS,EAAG,KAJb;AAKC,IAAA,sBAAsB,EAAG;AAL1B,IADW,GASX,cAAC,YAAD;AACC,IAAA,MAAM,EAAGT,MADV;AAEC,IAAA,QAAQ,EAAGS,mBAFZ;AAGC,IAAA,SAAS,EAAG,KAHb;AAIC,IAAA,mBAAmB,EAAG;AAJvB,IAVA,CAxCH,CA1IF,EAqMG,CAAED,WAAF,IAAiBL,YArMpB,CADD;AAyMA;AAED,eAAeL,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect, useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { lineSolid, moreVertical, plus } from '@wordpress/icons';\nimport {\n\t__experimentalUseFocusOutside as useFocusOutside,\n\tuseDebounce,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { ColorPicker } from '../color-picker';\nimport { FlexItem } from '../flex';\nimport { HStack } from '../h-stack';\nimport { ItemGroup } from '../item-group';\nimport { VStack } from '../v-stack';\nimport GradientPicker from '../gradient-picker';\nimport ColorPalette from '../color-palette';\nimport DropdownMenu from '../dropdown-menu';\nimport Popover from '../popover';\nimport {\n\tPaletteActionsContainer,\n\tPaletteEditStyles,\n\tPaletteHeading,\n\tPaletteHStackHeader,\n\tIndicatorStyled,\n\tPaletteItem,\n\tNameContainer,\n\tNameInputControl,\n\tDoneButton,\n\tRemoveButton,\n} from './styles';\nimport { NavigableMenu } from '../navigable-container';\nimport { DEFAULT_GRADIENT } from '../custom-gradient-picker/constants';\nimport CustomGradientPicker from '../custom-gradient-picker';\nimport type {\n\tColor,\n\tColorPickerPopoverProps,\n\tGradient,\n\tNameInputProps,\n\tOptionProps,\n\tPaletteEditListViewProps,\n\tPaletteEditProps,\n\tPaletteElement,\n} from './types';\n\nconst DEFAULT_COLOR = '#000';\n\nfunction NameInput( { value, onChange, label }: NameInputProps ) {\n\treturn (\n\t\t<NameInputControl\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Returns a temporary name for a palette item in the format \"Color + id\".\n * To ensure there are no duplicate ids, this function checks all slugs for temporary names.\n * It expects slugs to be in the format: slugPrefix + color- + number.\n * It then sets the id component of the new name based on the incremented id of the highest existing slug id.\n *\n * @param elements An array of color palette items.\n * @param slugPrefix The slug prefix used to match the element slug.\n *\n * @return A unique name for a palette item.\n */\nexport function getNameForPosition(\n\telements: PaletteElement[],\n\tslugPrefix: string\n) {\n\tconst temporaryNameRegex = new RegExp( `^${ slugPrefix }color-([\\\\d]+)$` );\n\tconst position = elements.reduce( ( previousValue, currentValue ) => {\n\t\tif ( typeof currentValue?.slug === 'string' ) {\n\t\t\tconst matches = currentValue?.slug.match( temporaryNameRegex );\n\t\t\tif ( matches ) {\n\t\t\t\tconst id = parseInt( matches[ 1 ], 10 );\n\t\t\t\tif ( id >= previousValue ) {\n\t\t\t\t\treturn id + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn previousValue;\n\t}, 1 );\n\n\treturn sprintf(\n\t\t/* translators: %s: is a temporary id for a custom color */\n\t\t__( 'Color %s' ),\n\t\tposition\n\t);\n}\n\nfunction ColorPickerPopover< T extends Color | Gradient >( {\n\tisGradient,\n\telement,\n\tonChange,\n\tonClose = () => {},\n}: ColorPickerPopoverProps< T > ) {\n\treturn (\n\t\t<Popover\n\t\t\tplacement=\"left-start\"\n\t\t\toffset={ 20 }\n\t\t\tclassName=\"components-palette-edit__popover\"\n\t\t\tonClose={ onClose }\n\t\t>\n\t\t\t{ ! isGradient && (\n\t\t\t\t<ColorPicker\n\t\t\t\t\tcolor={ element.color }\n\t\t\t\t\tenableAlpha\n\t\t\t\t\tonChange={ ( newColor ) => {\n\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\tcolor: newColor,\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\t{ isGradient && (\n\t\t\t\t<div className=\"components-palette-edit__popover-gradient-picker\">\n\t\t\t\t\t<CustomGradientPicker\n\t\t\t\t\t\t__nextHasNoMargin\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\tvalue={ element.gradient }\n\t\t\t\t\t\tonChange={ ( newGradient ) => {\n\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\t\tgradient: newGradient,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nfunction Option< T extends Color | Gradient >( {\n\tcanOnlyChangeValues,\n\telement,\n\tonChange,\n\tisEditing,\n\tonStartEditing,\n\tonRemove,\n\tonStopEditing,\n\tslugPrefix,\n\tisGradient,\n}: OptionProps< T > ) {\n\tconst focusOutsideProps = useFocusOutside( onStopEditing );\n\tconst value = isGradient ? element.gradient : element.color;\n\n\treturn (\n\t\t<PaletteItem\n\t\t\tclassName={ isEditing ? 'is-selected' : undefined }\n\t\t\tas=\"div\"\n\t\t\tonClick={ onStartEditing }\n\t\t\t{ ...( isEditing\n\t\t\t\t? { ...focusOutsideProps }\n\t\t\t\t: {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\t},\n\t\t\t\t } ) }\n\t\t>\n\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<IndicatorStyled\n\t\t\t\t\t\tstyle={ { background: value, color: 'transparent' } }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t{ isEditing && ! canOnlyChangeValues ? (\n\t\t\t\t\t\t<NameInput\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t? __( 'Gradient name' )\n\t\t\t\t\t\t\t\t\t: __( 'Color name' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvalue={ element.name }\n\t\t\t\t\t\t\tonChange={ ( nextName?: string ) =>\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\t\t\tname: nextName,\n\t\t\t\t\t\t\t\t\tslug:\n\t\t\t\t\t\t\t\t\t\tslugPrefix +\n\t\t\t\t\t\t\t\t\t\tkebabCase( nextName ?? '' ),\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<NameContainer>{ element.name }</NameContainer>\n\t\t\t\t\t) }\n\t\t\t\t</FlexItem>\n\t\t\t\t{ isEditing && ! canOnlyChangeValues && (\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<RemoveButton\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\tlabel={ __( 'Remove color' ) }\n\t\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ isEditing && (\n\t\t\t\t<ColorPickerPopover\n\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\telement={ element }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</PaletteItem>\n\t);\n}\n\nfunction isTemporaryElement(\n\tslugPrefix: string,\n\t{ slug, color, gradient }: Color | Gradient\n) {\n\tconst regex = new RegExp( `^${ slugPrefix }color-([\\\\d]+)$` );\n\treturn (\n\t\tregex.test( slug ) &&\n\t\t( ( !! color && color === DEFAULT_COLOR ) ||\n\t\t\t( !! gradient && gradient === DEFAULT_GRADIENT ) )\n\t);\n}\n\nfunction PaletteEditListView< T extends Color | Gradient >( {\n\telements,\n\tonChange,\n\teditingElement,\n\tsetEditingElement,\n\tcanOnlyChangeValues,\n\tslugPrefix,\n\tisGradient,\n}: PaletteEditListViewProps< T > ) {\n\t// When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.\n\tconst elementsReference = useRef< typeof elements >();\n\tuseEffect( () => {\n\t\telementsReference.current = elements;\n\t}, [ elements ] );\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif (\n\t\t\t\telementsReference.current?.some( ( element ) =>\n\t\t\t\t\tisTemporaryElement( slugPrefix, element )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tconst newElements = elementsReference.current.filter(\n\t\t\t\t\t( element ) => ! isTemporaryElement( slugPrefix, element )\n\t\t\t\t);\n\t\t\t\tonChange( newElements.length ? newElements : undefined );\n\t\t\t}\n\t\t};\n\t\t// Disable reason: adding the missing dependency here would cause breaking changes that will require\n\t\t// a heavier refactor to avoid. See https://github.com/WordPress/gutenberg/pull/43911\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tconst debounceOnChange = useDebounce( onChange, 100 );\n\n\treturn (\n\t\t<VStack spacing={ 3 }>\n\t\t\t<ItemGroup isRounded>\n\t\t\t\t{ elements.map( ( element, index ) => (\n\t\t\t\t\t<Option\n\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\tcanOnlyChangeValues={ canOnlyChangeValues }\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\telement={ element }\n\t\t\t\t\t\tonStartEditing={ () => {\n\t\t\t\t\t\t\tif ( editingElement !== index ) {\n\t\t\t\t\t\t\t\tsetEditingElement( index );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( newElement ) => {\n\t\t\t\t\t\t\tdebounceOnChange(\n\t\t\t\t\t\t\t\telements.map(\n\t\t\t\t\t\t\t\t\t( currentElement, currentIndex ) => {\n\t\t\t\t\t\t\t\t\t\tif ( currentIndex === index ) {\n\t\t\t\t\t\t\t\t\t\t\treturn newElement;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn currentElement;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tsetEditingElement( null );\n\t\t\t\t\t\t\tconst newElements = elements.filter(\n\t\t\t\t\t\t\t\t( _currentElement, currentIndex ) => {\n\t\t\t\t\t\t\t\t\tif ( currentIndex === index ) {\n\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tnewElements.length ? newElements : undefined\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisEditing={ index === editingElement }\n\t\t\t\t\t\tonStopEditing={ () => {\n\t\t\t\t\t\t\tif ( index === editingElement ) {\n\t\t\t\t\t\t\t\tsetEditingElement( null );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tslugPrefix={ slugPrefix }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ItemGroup>\n\t\t</VStack>\n\t);\n}\n\nconst EMPTY_ARRAY: Color[] = [];\n\n/**\n * Allows editing a palette of colors or gradients.\n *\n * ```jsx\n * import { PaletteEdit } from '@wordpress/components';\n * const MyPaletteEdit = () => {\n * const [ controlledColors, setControlledColors ] = useState( colors );\n *\n * return (\n * <PaletteEdit\n * colors={ controlledColors }\n * onChange={ ( newColors?: Color[] ) => {\n * setControlledColors( newColors );\n * } }\n * paletteLabel=\"Here is a label\"\n * />\n * );\n * };\n * ```\n */\nexport function PaletteEdit( {\n\tgradients,\n\tcolors = EMPTY_ARRAY,\n\tonChange,\n\tpaletteLabel,\n\tpaletteLabelHeadingLevel = 2,\n\temptyMessage,\n\tcanOnlyChangeValues,\n\tcanReset,\n\tslugPrefix = '',\n}: PaletteEditProps ) {\n\tconst isGradient = !! gradients;\n\tconst elements = isGradient ? gradients : colors;\n\tconst [ isEditing, setIsEditing ] = useState( false );\n\tconst [ editingElement, setEditingElement ] = useState<\n\t\tnumber | null | undefined\n\t>( null );\n\tconst isAdding =\n\t\tisEditing &&\n\t\t!! editingElement &&\n\t\telements[ editingElement ] &&\n\t\t! elements[ editingElement ].slug;\n\tconst elementsLength = elements.length;\n\tconst hasElements = elementsLength > 0;\n\tconst debounceOnChange = useDebounce( onChange, 100 );\n\tconst onSelectPaletteItem = useCallback(\n\t\t(\n\t\t\tvalue?: PaletteElement[ keyof PaletteElement ],\n\t\t\tnewEditingElementIndex?: number\n\t\t) => {\n\t\t\tconst selectedElement =\n\t\t\t\tnewEditingElementIndex === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: elements[ newEditingElementIndex ];\n\t\t\tconst key = isGradient ? 'gradient' : 'color';\n\t\t\t// Ensures that the index returned matches a known element value.\n\t\t\tif ( !! selectedElement && selectedElement[ key ] === value ) {\n\t\t\t\tsetEditingElement( newEditingElementIndex );\n\t\t\t} else {\n\t\t\t\tsetIsEditing( true );\n\t\t\t}\n\t\t},\n\t\t[ isGradient, elements ]\n\t);\n\n\treturn (\n\t\t<PaletteEditStyles>\n\t\t\t<PaletteHStackHeader>\n\t\t\t\t<PaletteHeading level={ paletteLabelHeadingLevel }>\n\t\t\t\t\t{ paletteLabel }\n\t\t\t\t</PaletteHeading>\n\t\t\t\t<PaletteActionsContainer>\n\t\t\t\t\t{ hasElements && isEditing && (\n\t\t\t\t\t\t<DoneButton\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetIsEditing( false );\n\t\t\t\t\t\t\t\tsetEditingElement( null );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t\t\t</DoneButton>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! canOnlyChangeValues && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\tisPressed={ isAdding }\n\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t? __( 'Add gradient' )\n\t\t\t\t\t\t\t\t\t: __( 'Add color' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst tempOptionName = getNameForPosition(\n\t\t\t\t\t\t\t\t\telements,\n\t\t\t\t\t\t\t\t\tslugPrefix\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif ( !! gradients ) {\n\t\t\t\t\t\t\t\t\tonChange( [\n\t\t\t\t\t\t\t\t\t\t...gradients,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tgradient: DEFAULT_GRADIENT,\n\t\t\t\t\t\t\t\t\t\t\tname: tempOptionName,\n\t\t\t\t\t\t\t\t\t\t\tslug:\n\t\t\t\t\t\t\t\t\t\t\t\tslugPrefix +\n\t\t\t\t\t\t\t\t\t\t\t\tkebabCase( tempOptionName ),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonChange( [\n\t\t\t\t\t\t\t\t\t\t...colors,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcolor: DEFAULT_COLOR,\n\t\t\t\t\t\t\t\t\t\t\tname: tempOptionName,\n\t\t\t\t\t\t\t\t\t\t\tslug:\n\t\t\t\t\t\t\t\t\t\t\t\tslugPrefix +\n\t\t\t\t\t\t\t\t\t\t\t\tkebabCase( tempOptionName ),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetIsEditing( true );\n\t\t\t\t\t\t\t\tsetEditingElement( elements.length );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ hasElements &&\n\t\t\t\t\t\t( ! isEditing ||\n\t\t\t\t\t\t\t! canOnlyChangeValues ||\n\t\t\t\t\t\t\tcanReset ) && (\n\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t\t? __( 'Gradient options' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Color options' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\t\tisSmall: true,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ ( { onClose }: { onClose: () => void } ) => (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<NavigableMenu role=\"menu\">\n\t\t\t\t\t\t\t\t\t\t\t{ ! isEditing && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsEditing( true );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-palette-edit__menu-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Show details' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t{ ! canOnlyChangeValues && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetEditingElement(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsEditing( false );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-palette-edit__menu-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ isGradient\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Remove all gradients'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Remove all colors'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t{ canReset && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetEditingElement(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ isGradient\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? __( 'Reset gradient' )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: __( 'Reset colors' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t) }\n\t\t\t\t</PaletteActionsContainer>\n\t\t\t</PaletteHStackHeader>\n\t\t\t{ hasElements && (\n\t\t\t\t<>\n\t\t\t\t\t{ isEditing && (\n\t\t\t\t\t\t<PaletteEditListView< ( typeof elements )[ number ] >\n\t\t\t\t\t\t\tcanOnlyChangeValues={ canOnlyChangeValues }\n\t\t\t\t\t\t\telements={ elements }\n\t\t\t\t\t\t\t// @ts-expect-error TODO: Don't know how to resolve\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\teditingElement={ editingElement }\n\t\t\t\t\t\t\tsetEditingElement={ setEditingElement }\n\t\t\t\t\t\t\tslugPrefix={ slugPrefix }\n\t\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isEditing && editingElement !== null && (\n\t\t\t\t\t\t<ColorPickerPopover\n\t\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\t\tonClose={ () => setEditingElement( null ) }\n\t\t\t\t\t\t\tonChange={ (\n\t\t\t\t\t\t\t\tnewElement: ( typeof elements )[ number ]\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tdebounceOnChange(\n\t\t\t\t\t\t\t\t\t// @ts-expect-error TODO: Don't know how to resolve\n\t\t\t\t\t\t\t\t\telements.map(\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\tcurrentElement: ( typeof elements )[ number ],\n\t\t\t\t\t\t\t\t\t\t\tcurrentIndex: number\n\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentIndex === editingElement\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn newElement;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn currentElement;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\telement={ elements[ editingElement ?? -1 ] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isEditing &&\n\t\t\t\t\t\t( isGradient ? (\n\t\t\t\t\t\t\t<GradientPicker\n\t\t\t\t\t\t\t\t__nextHasNoMargin\n\t\t\t\t\t\t\t\tgradients={ gradients }\n\t\t\t\t\t\t\t\tonChange={ onSelectPaletteItem }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t\tdisableCustomGradients={ true }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\t\t\tonChange={ onSelectPaletteItem }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t\tdisableCustomColors={ true }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) ) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ ! hasElements && emptyMessage }\n\t\t</PaletteEditStyles>\n\t);\n}\n\nexport default PaletteEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/palette-edit/index.tsx"],"names":["classnames","paramCase","kebabCase","useState","useRef","useEffect","useCallback","useMemo","__","sprintf","lineSolid","moreVertical","plus","__experimentalUseFocusOutside","useFocusOutside","useDebounce","Button","ColorPicker","FlexItem","HStack","ItemGroup","VStack","GradientPicker","ColorPalette","DropdownMenu","Popover","PaletteActionsContainer","PaletteEditStyles","PaletteHeading","PaletteHStackHeader","IndicatorStyled","PaletteItem","NameContainer","NameInputControl","DoneButton","RemoveButton","NavigableMenu","DEFAULT_GRADIENT","CustomGradientPicker","DEFAULT_COLOR","NameInput","value","onChange","label","getNameForPosition","elements","slugPrefix","temporaryNameRegex","RegExp","position","reduce","previousValue","currentValue","slug","matches","match","id","parseInt","ColorPickerPopover","isGradient","element","popoverProps","receivedPopoverProps","onClose","shift","offset","placement","className","color","newColor","gradient","newGradient","Option","canOnlyChangeValues","isEditing","onStartEditing","onRemove","onStopEditing","focusOutsideProps","popoverAnchor","setPopoverAnchor","anchor","undefined","style","cursor","background","name","nextName","isTemporaryElement","regex","test","PaletteEditListView","editingElement","setEditingElement","elementsReference","current","some","newElements","filter","length","debounceOnChange","map","index","newElement","currentElement","currentIndex","_currentElement","EMPTY_ARRAY","PaletteEdit","gradients","colors","paletteLabel","paletteLabelHeadingLevel","emptyMessage","canReset","setIsEditing","isAdding","elementsLength","hasElements","onSelectPaletteItem","newEditingElementIndex","selectedElement","key","tempOptionName","isSmall"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,SAAS,IAAIC,SAAtB,QAAuC,aAAvC;AAEA;AACA;AACA;;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,SAHD,EAICC,WAJD,EAKCC,OALD,QAMO,oBANP;AAOA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,EAAoBC,YAApB,EAAkCC,IAAlC,QAA8C,kBAA9C;AACA,SACCC,6BAA6B,IAAIC,eADlC,EAECC,WAFD,QAGO,oBAHP;AAKA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,QAAT,QAAyB,SAAzB;AACA,SAASC,MAAT,QAAuB,YAAvB;AACA,SAASC,SAAT,QAA0B,eAA1B;AACA,SAASC,MAAT,QAAuB,YAAvB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AAC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AAD;AACC,IAAA,iBAAiB,MADlB;AAEC,IAAA,SAAS,EAAGkD,SAFb;AAGC,IAAA,QAAQ,EAAGU,mBAHZ;AAIC,IAAA,SAAS,EAAG,KAJb;AAKC,IAAA,sBAAsB,EAAG;AAL1B,IADW,GASX,cAAC,YAAD;AACC,IAAA,MAAM,EAAGT,MADV;AAEC,IAAA,QAAQ,EAAGS,mBAFZ;AAGC,IAAA,SAAS,EAAG,KAHb;AAIC,IAAA,mBAAmB,EAAG;AAJvB,IAVA,CA1CH,CA1IF,EAuMG,CAAED,WAAF,IAAiBL,YAvMpB,CADD;AA2MA;AAED,eAAeL,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { lineSolid, moreVertical, plus } from '@wordpress/icons';\nimport {\n\t__experimentalUseFocusOutside as useFocusOutside,\n\tuseDebounce,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { ColorPicker } from '../color-picker';\nimport { FlexItem } from '../flex';\nimport { HStack } from '../h-stack';\nimport { ItemGroup } from '../item-group';\nimport { VStack } from '../v-stack';\nimport GradientPicker from '../gradient-picker';\nimport ColorPalette from '../color-palette';\nimport DropdownMenu from '../dropdown-menu';\nimport Popover from '../popover';\nimport {\n\tPaletteActionsContainer,\n\tPaletteEditStyles,\n\tPaletteHeading,\n\tPaletteHStackHeader,\n\tIndicatorStyled,\n\tPaletteItem,\n\tNameContainer,\n\tNameInputControl,\n\tDoneButton,\n\tRemoveButton,\n} from './styles';\nimport { NavigableMenu } from '../navigable-container';\nimport { DEFAULT_GRADIENT } from '../custom-gradient-picker/constants';\nimport CustomGradientPicker from '../custom-gradient-picker';\nimport type {\n\tColor,\n\tColorPickerPopoverProps,\n\tGradient,\n\tNameInputProps,\n\tOptionProps,\n\tPaletteEditListViewProps,\n\tPaletteEditProps,\n\tPaletteElement,\n} from './types';\n\nconst DEFAULT_COLOR = '#000';\n\nfunction NameInput( { value, onChange, label }: NameInputProps ) {\n\treturn (\n\t\t<NameInputControl\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\n/**\n * Returns a temporary name for a palette item in the format \"Color + id\".\n * To ensure there are no duplicate ids, this function checks all slugs for temporary names.\n * It expects slugs to be in the format: slugPrefix + color- + number.\n * It then sets the id component of the new name based on the incremented id of the highest existing slug id.\n *\n * @param elements An array of color palette items.\n * @param slugPrefix The slug prefix used to match the element slug.\n *\n * @return A unique name for a palette item.\n */\nexport function getNameForPosition(\n\telements: PaletteElement[],\n\tslugPrefix: string\n) {\n\tconst temporaryNameRegex = new RegExp( `^${ slugPrefix }color-([\\\\d]+)$` );\n\tconst position = elements.reduce( ( previousValue, currentValue ) => {\n\t\tif ( typeof currentValue?.slug === 'string' ) {\n\t\t\tconst matches = currentValue?.slug.match( temporaryNameRegex );\n\t\t\tif ( matches ) {\n\t\t\t\tconst id = parseInt( matches[ 1 ], 10 );\n\t\t\t\tif ( id >= previousValue ) {\n\t\t\t\t\treturn id + 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn previousValue;\n\t}, 1 );\n\n\treturn sprintf(\n\t\t/* translators: %s: is a temporary id for a custom color */\n\t\t__( 'Color %s' ),\n\t\tposition\n\t);\n}\n\nfunction ColorPickerPopover< T extends Color | Gradient >( {\n\tisGradient,\n\telement,\n\tonChange,\n\tpopoverProps: receivedPopoverProps,\n\tonClose = () => {},\n}: ColorPickerPopoverProps< T > ) {\n\tconst popoverProps: ColorPickerPopoverProps< T >[ 'popoverProps' ] =\n\t\tuseMemo(\n\t\t\t() => ( {\n\t\t\t\tshift: true,\n\t\t\t\toffset: 20,\n\t\t\t\tplacement: 'left-start',\n\t\t\t\t...receivedPopoverProps,\n\t\t\t\tclassName: classnames(\n\t\t\t\t\t'components-palette-edit__popover',\n\t\t\t\t\treceivedPopoverProps?.className\n\t\t\t\t),\n\t\t\t} ),\n\t\t\t[ receivedPopoverProps ]\n\t\t);\n\n\treturn (\n\t\t<Popover { ...popoverProps } onClose={ onClose }>\n\t\t\t{ ! isGradient && (\n\t\t\t\t<ColorPicker\n\t\t\t\t\tcolor={ element.color }\n\t\t\t\t\tenableAlpha\n\t\t\t\t\tonChange={ ( newColor ) => {\n\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\tcolor: newColor,\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\t{ isGradient && (\n\t\t\t\t<div className=\"components-palette-edit__popover-gradient-picker\">\n\t\t\t\t\t<CustomGradientPicker\n\t\t\t\t\t\t__nextHasNoMargin\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\tvalue={ element.gradient }\n\t\t\t\t\t\tonChange={ ( newGradient ) => {\n\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\t\tgradient: newGradient,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nfunction Option< T extends Color | Gradient >( {\n\tcanOnlyChangeValues,\n\telement,\n\tonChange,\n\tisEditing,\n\tonStartEditing,\n\tonRemove,\n\tonStopEditing,\n\tpopoverProps: receivedPopoverProps,\n\tslugPrefix,\n\tisGradient,\n}: OptionProps< T > ) {\n\tconst focusOutsideProps = useFocusOutside( onStopEditing );\n\tconst value = isGradient ? element.gradient : element.color;\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst popoverProps = useMemo(\n\t\t() => ( {\n\t\t\t...receivedPopoverProps,\n\t\t\t// Use the custom palette color item as the popover anchor.\n\t\t\tanchor: popoverAnchor,\n\t\t} ),\n\t\t[ popoverAnchor, receivedPopoverProps ]\n\t);\n\n\treturn (\n\t\t<PaletteItem\n\t\t\tclassName={ isEditing ? 'is-selected' : undefined }\n\t\t\tas=\"div\"\n\t\t\tonClick={ onStartEditing }\n\t\t\tref={ setPopoverAnchor }\n\t\t\t{ ...( isEditing\n\t\t\t\t? { ...focusOutsideProps }\n\t\t\t\t: {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\t},\n\t\t\t\t } ) }\n\t\t>\n\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<IndicatorStyled\n\t\t\t\t\t\tstyle={ { background: value, color: 'transparent' } }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t{ isEditing && ! canOnlyChangeValues ? (\n\t\t\t\t\t\t<NameInput\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t? __( 'Gradient name' )\n\t\t\t\t\t\t\t\t\t: __( 'Color name' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvalue={ element.name }\n\t\t\t\t\t\t\tonChange={ ( nextName?: string ) =>\n\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t...element,\n\t\t\t\t\t\t\t\t\tname: nextName,\n\t\t\t\t\t\t\t\t\tslug:\n\t\t\t\t\t\t\t\t\t\tslugPrefix +\n\t\t\t\t\t\t\t\t\t\tkebabCase( nextName ?? '' ),\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<NameContainer>{ element.name }</NameContainer>\n\t\t\t\t\t) }\n\t\t\t\t</FlexItem>\n\t\t\t\t{ isEditing && ! canOnlyChangeValues && (\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<RemoveButton\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\tlabel={ __( 'Remove color' ) }\n\t\t\t\t\t\t\tonClick={ onRemove }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t{ isEditing && (\n\t\t\t\t<ColorPickerPopover\n\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\telement={ element }\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</PaletteItem>\n\t);\n}\n\nfunction isTemporaryElement(\n\tslugPrefix: string,\n\t{ slug, color, gradient }: Color | Gradient\n) {\n\tconst regex = new RegExp( `^${ slugPrefix }color-([\\\\d]+)$` );\n\treturn (\n\t\tregex.test( slug ) &&\n\t\t( ( !! color && color === DEFAULT_COLOR ) ||\n\t\t\t( !! gradient && gradient === DEFAULT_GRADIENT ) )\n\t);\n}\n\nfunction PaletteEditListView< T extends Color | Gradient >( {\n\telements,\n\tonChange,\n\teditingElement,\n\tsetEditingElement,\n\tcanOnlyChangeValues,\n\tslugPrefix,\n\tisGradient,\n\tpopoverProps,\n}: PaletteEditListViewProps< T > ) {\n\t// When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.\n\tconst elementsReference = useRef< typeof elements >();\n\tuseEffect( () => {\n\t\telementsReference.current = elements;\n\t}, [ elements ] );\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif (\n\t\t\t\telementsReference.current?.some( ( element ) =>\n\t\t\t\t\tisTemporaryElement( slugPrefix, element )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tconst newElements = elementsReference.current.filter(\n\t\t\t\t\t( element ) => ! isTemporaryElement( slugPrefix, element )\n\t\t\t\t);\n\t\t\t\tonChange( newElements.length ? newElements : undefined );\n\t\t\t}\n\t\t};\n\t\t// Disable reason: adding the missing dependency here would cause breaking changes that will require\n\t\t// a heavier refactor to avoid. See https://github.com/WordPress/gutenberg/pull/43911\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tconst debounceOnChange = useDebounce( onChange, 100 );\n\n\treturn (\n\t\t<VStack spacing={ 3 }>\n\t\t\t<ItemGroup isRounded>\n\t\t\t\t{ elements.map( ( element, index ) => (\n\t\t\t\t\t<Option\n\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\tcanOnlyChangeValues={ canOnlyChangeValues }\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\telement={ element }\n\t\t\t\t\t\tonStartEditing={ () => {\n\t\t\t\t\t\t\tif ( editingElement !== index ) {\n\t\t\t\t\t\t\t\tsetEditingElement( index );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ ( newElement ) => {\n\t\t\t\t\t\t\tdebounceOnChange(\n\t\t\t\t\t\t\t\telements.map(\n\t\t\t\t\t\t\t\t\t( currentElement, currentIndex ) => {\n\t\t\t\t\t\t\t\t\t\tif ( currentIndex === index ) {\n\t\t\t\t\t\t\t\t\t\t\treturn newElement;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn currentElement;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\tsetEditingElement( null );\n\t\t\t\t\t\t\tconst newElements = elements.filter(\n\t\t\t\t\t\t\t\t( _currentElement, currentIndex ) => {\n\t\t\t\t\t\t\t\t\tif ( currentIndex === index ) {\n\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tnewElements.length ? newElements : undefined\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tisEditing={ index === editingElement }\n\t\t\t\t\t\tonStopEditing={ () => {\n\t\t\t\t\t\t\tif ( index === editingElement ) {\n\t\t\t\t\t\t\t\tsetEditingElement( null );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tslugPrefix={ slugPrefix }\n\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ItemGroup>\n\t\t</VStack>\n\t);\n}\n\nconst EMPTY_ARRAY: Color[] = [];\n\n/**\n * Allows editing a palette of colors or gradients.\n *\n * ```jsx\n * import { PaletteEdit } from '@wordpress/components';\n * const MyPaletteEdit = () => {\n * const [ controlledColors, setControlledColors ] = useState( colors );\n *\n * return (\n * <PaletteEdit\n * colors={ controlledColors }\n * onChange={ ( newColors?: Color[] ) => {\n * setControlledColors( newColors );\n * } }\n * paletteLabel=\"Here is a label\"\n * />\n * );\n * };\n * ```\n */\nexport function PaletteEdit( {\n\tgradients,\n\tcolors = EMPTY_ARRAY,\n\tonChange,\n\tpaletteLabel,\n\tpaletteLabelHeadingLevel = 2,\n\temptyMessage,\n\tcanOnlyChangeValues,\n\tcanReset,\n\tslugPrefix = '',\n\tpopoverProps,\n}: PaletteEditProps ) {\n\tconst isGradient = !! gradients;\n\tconst elements = isGradient ? gradients : colors;\n\tconst [ isEditing, setIsEditing ] = useState( false );\n\tconst [ editingElement, setEditingElement ] = useState<\n\t\tnumber | null | undefined\n\t>( null );\n\tconst isAdding =\n\t\tisEditing &&\n\t\t!! editingElement &&\n\t\telements[ editingElement ] &&\n\t\t! elements[ editingElement ].slug;\n\tconst elementsLength = elements.length;\n\tconst hasElements = elementsLength > 0;\n\tconst debounceOnChange = useDebounce( onChange, 100 );\n\tconst onSelectPaletteItem = useCallback(\n\t\t(\n\t\t\tvalue?: PaletteElement[ keyof PaletteElement ],\n\t\t\tnewEditingElementIndex?: number\n\t\t) => {\n\t\t\tconst selectedElement =\n\t\t\t\tnewEditingElementIndex === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: elements[ newEditingElementIndex ];\n\t\t\tconst key = isGradient ? 'gradient' : 'color';\n\t\t\t// Ensures that the index returned matches a known element value.\n\t\t\tif ( !! selectedElement && selectedElement[ key ] === value ) {\n\t\t\t\tsetEditingElement( newEditingElementIndex );\n\t\t\t} else {\n\t\t\t\tsetIsEditing( true );\n\t\t\t}\n\t\t},\n\t\t[ isGradient, elements ]\n\t);\n\n\treturn (\n\t\t<PaletteEditStyles>\n\t\t\t<PaletteHStackHeader>\n\t\t\t\t<PaletteHeading level={ paletteLabelHeadingLevel }>\n\t\t\t\t\t{ paletteLabel }\n\t\t\t\t</PaletteHeading>\n\t\t\t\t<PaletteActionsContainer>\n\t\t\t\t\t{ hasElements && isEditing && (\n\t\t\t\t\t\t<DoneButton\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetIsEditing( false );\n\t\t\t\t\t\t\t\tsetEditingElement( null );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t\t\t</DoneButton>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! canOnlyChangeValues && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\tisPressed={ isAdding }\n\t\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t? __( 'Add gradient' )\n\t\t\t\t\t\t\t\t\t: __( 'Add color' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst tempOptionName = getNameForPosition(\n\t\t\t\t\t\t\t\t\telements,\n\t\t\t\t\t\t\t\t\tslugPrefix\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif ( !! gradients ) {\n\t\t\t\t\t\t\t\t\tonChange( [\n\t\t\t\t\t\t\t\t\t\t...gradients,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tgradient: DEFAULT_GRADIENT,\n\t\t\t\t\t\t\t\t\t\t\tname: tempOptionName,\n\t\t\t\t\t\t\t\t\t\t\tslug:\n\t\t\t\t\t\t\t\t\t\t\t\tslugPrefix +\n\t\t\t\t\t\t\t\t\t\t\t\tkebabCase( tempOptionName ),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tonChange( [\n\t\t\t\t\t\t\t\t\t\t...colors,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tcolor: DEFAULT_COLOR,\n\t\t\t\t\t\t\t\t\t\t\tname: tempOptionName,\n\t\t\t\t\t\t\t\t\t\t\tslug:\n\t\t\t\t\t\t\t\t\t\t\t\tslugPrefix +\n\t\t\t\t\t\t\t\t\t\t\t\tkebabCase( tempOptionName ),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetIsEditing( true );\n\t\t\t\t\t\t\t\tsetEditingElement( elements.length );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ hasElements &&\n\t\t\t\t\t\t( ! isEditing ||\n\t\t\t\t\t\t\t! canOnlyChangeValues ||\n\t\t\t\t\t\t\tcanReset ) && (\n\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\tisGradient\n\t\t\t\t\t\t\t\t\t\t? __( 'Gradient options' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Color options' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\t\tisSmall: true,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ ( { onClose }: { onClose: () => void } ) => (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<NavigableMenu role=\"menu\">\n\t\t\t\t\t\t\t\t\t\t\t{ ! isEditing && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsEditing( true );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-palette-edit__menu-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Show details' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t{ ! canOnlyChangeValues && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetEditingElement(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetIsEditing( false );\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-palette-edit__menu-button\"\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ isGradient\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Remove all gradients'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Remove all colors'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t{ canReset && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsetEditingElement(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonChange();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ isGradient\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? __( 'Reset gradient' )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: __( 'Reset colors' ) }\n\t\t\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t) }\n\t\t\t\t</PaletteActionsContainer>\n\t\t\t</PaletteHStackHeader>\n\t\t\t{ hasElements && (\n\t\t\t\t<>\n\t\t\t\t\t{ isEditing && (\n\t\t\t\t\t\t<PaletteEditListView< ( typeof elements )[ number ] >\n\t\t\t\t\t\t\tcanOnlyChangeValues={ canOnlyChangeValues }\n\t\t\t\t\t\t\telements={ elements }\n\t\t\t\t\t\t\t// @ts-expect-error TODO: Don't know how to resolve\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\teditingElement={ editingElement }\n\t\t\t\t\t\t\tsetEditingElement={ setEditingElement }\n\t\t\t\t\t\t\tslugPrefix={ slugPrefix }\n\t\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isEditing && editingElement !== null && (\n\t\t\t\t\t\t<ColorPickerPopover\n\t\t\t\t\t\t\tisGradient={ isGradient }\n\t\t\t\t\t\t\tonClose={ () => setEditingElement( null ) }\n\t\t\t\t\t\t\tonChange={ (\n\t\t\t\t\t\t\t\tnewElement: ( typeof elements )[ number ]\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tdebounceOnChange(\n\t\t\t\t\t\t\t\t\t// @ts-expect-error TODO: Don't know how to resolve\n\t\t\t\t\t\t\t\t\telements.map(\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\tcurrentElement: ( typeof elements )[ number ],\n\t\t\t\t\t\t\t\t\t\t\tcurrentIndex: number\n\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentIndex === editingElement\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\treturn newElement;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn currentElement;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\telement={ elements[ editingElement ?? -1 ] }\n\t\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isEditing &&\n\t\t\t\t\t\t( isGradient ? (\n\t\t\t\t\t\t\t<GradientPicker\n\t\t\t\t\t\t\t\t__nextHasNoMargin\n\t\t\t\t\t\t\t\tgradients={ gradients }\n\t\t\t\t\t\t\t\tonChange={ onSelectPaletteItem }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t\tdisableCustomGradients={ true }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<ColorPalette\n\t\t\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\t\t\tonChange={ onSelectPaletteItem }\n\t\t\t\t\t\t\t\tclearable={ false }\n\t\t\t\t\t\t\t\tdisableCustomColors={ true }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) ) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ ! hasElements && emptyMessage }\n\t\t</PaletteEditStyles>\n\t);\n}\n\nexport default PaletteEdit;\n"]}
@@ -9,6 +9,7 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri
9
9
  import { default as CustomSelectControl } from './custom-select-control';
10
10
  import { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';
11
11
  import { createPrivateSlotFill } from './slot-fill';
12
+ import { DropdownMenu as DropdownMenuV2, DropdownMenuCheckboxItem as DropdownMenuCheckboxItemV2, DropdownMenuGroup as DropdownMenuGroupV2, DropdownMenuItem as DropdownMenuItemV2, DropdownMenuLabel as DropdownMenuLabelV2, DropdownMenuRadioGroup as DropdownMenuRadioGroupV2, DropdownMenuRadioItem as DropdownMenuRadioItemV2, DropdownMenuSeparator as DropdownMenuSeparatorV2, DropdownSubMenu as DropdownSubMenuV2, DropdownSubMenuTrigger as DropdownSubMenuTriggerV2 } from './dropdown-menu-v2';
12
13
  export const {
13
14
  lock,
14
15
  unlock
@@ -17,6 +18,16 @@ export const privateApis = {};
17
18
  lock(privateApis, {
18
19
  CustomSelectControl,
19
20
  __experimentalPopoverLegacyPositionToPlacement,
20
- createPrivateSlotFill
21
+ createPrivateSlotFill,
22
+ DropdownMenuV2,
23
+ DropdownMenuCheckboxItemV2,
24
+ DropdownMenuGroupV2,
25
+ DropdownMenuItemV2,
26
+ DropdownMenuLabelV2,
27
+ DropdownMenuRadioGroupV2,
28
+ DropdownMenuRadioItemV2,
29
+ DropdownMenuSeparatorV2,
30
+ DropdownSubMenuV2,
31
+ DropdownSubMenuTriggerV2
21
32
  });
22
33
  //# sourceMappingURL=private-apis.js.map
@@ -1 +1 @@
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"]}
1
+ {"version":3,"sources":["@wordpress/components/src/private-apis.ts"],"names":["__dangerousOptInToUnstableAPIsOnlyForCoreModules","default","CustomSelectControl","positionToPlacement","__experimentalPopoverLegacyPositionToPlacement","createPrivateSlotFill","DropdownMenu","DropdownMenuV2","DropdownMenuCheckboxItem","DropdownMenuCheckboxItemV2","DropdownMenuGroup","DropdownMenuGroupV2","DropdownMenuItem","DropdownMenuItemV2","DropdownMenuLabel","DropdownMenuLabelV2","DropdownMenuRadioGroup","DropdownMenuRadioGroupV2","DropdownMenuRadioItem","DropdownMenuRadioItemV2","DropdownMenuSeparator","DropdownMenuSeparatorV2","DropdownSubMenu","DropdownSubMenuV2","DropdownSubMenuTrigger","DropdownSubMenuTriggerV2","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;AACA,SACCC,YAAY,IAAIC,cADjB,EAECC,wBAAwB,IAAIC,0BAF7B,EAGCC,iBAAiB,IAAIC,mBAHtB,EAICC,gBAAgB,IAAIC,kBAJrB,EAKCC,iBAAiB,IAAIC,mBALtB,EAMCC,sBAAsB,IAAIC,wBAN3B,EAOCC,qBAAqB,IAAIC,uBAP1B,EAQCC,qBAAqB,IAAIC,uBAR1B,EASCC,eAAe,IAAIC,iBATpB,EAUCC,sBAAsB,IAAIC,wBAV3B,QAWO,oBAXP;AAaA,OAAO,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZ3B,gDAAgD,CAC/C,8GAD+C,EAE/C,uBAF+C,CAD1C;AAMP,OAAO,MAAM4B,WAAW,GAAG,EAApB;AACPF,IAAI,CAAEE,WAAF,EAAe;AAClB1B,EAAAA,mBADkB;AAElBE,EAAAA,8CAFkB;AAGlBC,EAAAA,qBAHkB;AAIlBE,EAAAA,cAJkB;AAKlBE,EAAAA,0BALkB;AAMlBE,EAAAA,mBANkB;AAOlBE,EAAAA,kBAPkB;AAQlBE,EAAAA,mBARkB;AASlBE,EAAAA,wBATkB;AAUlBE,EAAAA,uBAVkB;AAWlBE,EAAAA,uBAXkB;AAYlBE,EAAAA,iBAZkB;AAalBE,EAAAA;AAbkB,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';\nimport {\n\tDropdownMenu as DropdownMenuV2,\n\tDropdownMenuCheckboxItem as DropdownMenuCheckboxItemV2,\n\tDropdownMenuGroup as DropdownMenuGroupV2,\n\tDropdownMenuItem as DropdownMenuItemV2,\n\tDropdownMenuLabel as DropdownMenuLabelV2,\n\tDropdownMenuRadioGroup as DropdownMenuRadioGroupV2,\n\tDropdownMenuRadioItem as DropdownMenuRadioItemV2,\n\tDropdownMenuSeparator as DropdownMenuSeparatorV2,\n\tDropdownSubMenu as DropdownSubMenuV2,\n\tDropdownSubMenuTrigger as DropdownSubMenuTriggerV2,\n} from './dropdown-menu-v2';\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\tDropdownMenuV2,\n\tDropdownMenuCheckboxItemV2,\n\tDropdownMenuGroupV2,\n\tDropdownMenuItemV2,\n\tDropdownMenuLabelV2,\n\tDropdownMenuRadioGroupV2,\n\tDropdownMenuRadioItemV2,\n\tDropdownMenuSeparatorV2,\n\tDropdownSubMenuV2,\n\tDropdownSubMenuTriggerV2,\n} );\n"]}
@@ -28,6 +28,7 @@ const RangeControl = memo(_ref => {
28
28
  max,
29
29
  type,
30
30
  separatorType,
31
+ disabled,
31
32
  ...props
32
33
  } = _ref;
33
34
 
@@ -38,7 +39,8 @@ const RangeControl = memo(_ref => {
38
39
  min: min,
39
40
  onChange: onChange,
40
41
  separatorType: separatorType,
41
- value: value
42
+ value: value,
43
+ disabled: disabled
42
44
  });
43
45
  }
44
46
 
@@ -59,7 +61,8 @@ const RangeControl = memo(_ref => {
59
61
  afterIcon: afterIcon,
60
62
  allowReset: allowReset,
61
63
  defaultValue: initialSliderValue,
62
- separatorType: separatorType
64
+ separatorType: separatorType,
65
+ disabled: disabled
63
66
  }, props));
64
67
  });
65
68
  export default RangeControl;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/range-control/index.native.js"],"names":["memo","RangeCell","StepperCell","RangeControl","className","currentInput","label","value","instanceId","onChange","beforeIcon","afterIcon","help","allowReset","initialPosition","min","max","type","separatorType","props","id","currentInputValue","initialSliderValue","isFinite","undefined"],"m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,GAA4BI,SANhD;AAOC,IAAA,YAAY,EAAGT,GAPhB;AAQC,IAAA,YAAY,EAAGC,GARhB;AASC,IAAA,KAAK,EAAGT,KATT;AAUC,IAAA,UAAU,EAAGG,UAVd;AAWC,IAAA,SAAS,EAAGC,SAXb;AAYC,IAAA,UAAU,EAAGE,UAZd;AAaC,IAAA,YAAY,EAAGS,kBAbhB;AAcC,IAAA,aAAa,EAAGJ;AAdjB,KAeMC,KAfN,EADD;AAmBA,CAxDuB,CAAzB;AA2DA,eAAehB,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport RangeCell from '../mobile/bottom-sheet/range-cell';\nimport StepperCell from '../mobile/bottom-sheet/stepper-cell';\n\nconst RangeControl = memo(\n\t( {\n\t\tclassName,\n\t\tcurrentInput,\n\t\tlabel,\n\t\tvalue,\n\t\tinstanceId,\n\t\tonChange,\n\t\tbeforeIcon,\n\t\tafterIcon,\n\t\thelp,\n\t\tallowReset,\n\t\tinitialPosition,\n\t\tmin,\n\t\tmax,\n\t\ttype,\n\t\tseparatorType,\n\t\t...props\n\t} ) => {\n\t\tif ( type === 'stepper' ) {\n\t\t\treturn (\n\t\t\t\t<StepperCell\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tmin={ min }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tseparatorType={ separatorType }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\t\tconst id = `inspector-range-control-${ instanceId }`;\n\t\tconst currentInputValue = currentInput === null ? value : currentInput;\n\t\tconst initialSliderValue = isFinite( currentInputValue )\n\t\t\t? currentInputValue\n\t\t\t: initialPosition;\n\n\t\treturn (\n\t\t\t<RangeCell\n\t\t\t\tlabel={ label }\n\t\t\t\tid={ id }\n\t\t\t\thelp={ help }\n\t\t\t\tclassName={ className }\n\t\t\t\tonChange={ onChange }\n\t\t\t\taria-describedby={ !! help ? `${ id }__help` : undefined }\n\t\t\t\tminimumValue={ min }\n\t\t\t\tmaximumValue={ max }\n\t\t\t\tvalue={ value }\n\t\t\t\tbeforeIcon={ beforeIcon }\n\t\t\t\tafterIcon={ afterIcon }\n\t\t\t\tallowReset={ allowReset }\n\t\t\t\tdefaultValue={ initialSliderValue }\n\t\t\t\tseparatorType={ separatorType }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t}\n);\n\nexport default RangeControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/range-control/index.native.js"],"names":["memo","RangeCell","StepperCell","RangeControl","className","currentInput","label","value","instanceId","onChange","beforeIcon","afterIcon","help","allowReset","initialPosition","min","max","type","separatorType","disabled","props","id","currentInputValue","initialSliderValue","isFinite","undefined"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,oBAArB;AACA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,mCAAtB;AACA,OAAOC,WAAP,MAAwB,qCAAxB;AAEA,MAAMC,YAAY,GAAGH,IAAI,CACxB,QAkBO;AAAA,MAlBL;AACDI,IAAAA,SADC;AAEDC,IAAAA,YAFC;AAGDC,IAAAA,KAHC;AAIDC,IAAAA,KAJC;AAKDC,IAAAA,UALC;AAMDC,IAAAA,QANC;AAODC,IAAAA,UAPC;AAQDC,IAAAA,SARC;AASDC,IAAAA,IATC;AAUDC,IAAAA,UAVC;AAWDC,IAAAA,eAXC;AAYDC,IAAAA,GAZC;AAaDC,IAAAA,GAbC;AAcDC,IAAAA,IAdC;AAeDC,IAAAA,aAfC;AAgBDC,IAAAA,QAhBC;AAiBD,OAAGC;AAjBF,GAkBK;;AACN,MAAKH,IAAI,KAAK,SAAd,EAA0B;AACzB,WACC,cAAC,WAAD;AACC,MAAA,KAAK,EAAGX,KADT;AAEC,MAAA,GAAG,EAAGU,GAFP;AAGC,MAAA,GAAG,EAAGD,GAHP;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,aAAa,EAAGS,aALjB;AAMC,MAAA,KAAK,EAAGX,KANT;AAOC,MAAA,QAAQ,EAAGY;AAPZ,MADD;AAWA;;AACD,QAAME,EAAE,GAAI,2BAA2Bb,UAAY,EAAnD;AACA,QAAMc,iBAAiB,GAAGjB,YAAY,KAAK,IAAjB,GAAwBE,KAAxB,GAAgCF,YAA1D;AACA,QAAMkB,kBAAkB,GAAGC,QAAQ,CAAEF,iBAAF,CAAR,GACxBA,iBADwB,GAExBR,eAFH;AAIA,SACC,cAAC,SAAD;AACC,IAAA,KAAK,EAAGR,KADT;AAEC,IAAA,EAAE,EAAGe,EAFN;AAGC,IAAA,IAAI,EAAGT,IAHR;AAIC,IAAA,SAAS,EAAGR,SAJb;AAKC,IAAA,QAAQ,EAAGK,QALZ;AAMC,wBAAmB,CAAC,CAAEG,IAAH,GAAW,GAAGS,EAAI,QAAlB,GAA4BI,SANhD;AAOC,IAAA,YAAY,EAAGV,GAPhB;AAQC,IAAA,YAAY,EAAGC,GARhB;AASC,IAAA,KAAK,EAAGT,KATT;AAUC,IAAA,UAAU,EAAGG,UAVd;AAWC,IAAA,SAAS,EAAGC,SAXb;AAYC,IAAA,UAAU,EAAGE,UAZd;AAaC,IAAA,YAAY,EAAGU,kBAbhB;AAcC,IAAA,aAAa,EAAGL,aAdjB;AAeC,IAAA,QAAQ,EAAGC;AAfZ,KAgBMC,KAhBN,EADD;AAoBA,CA3DuB,CAAzB;AA8DA,eAAejB,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport RangeCell from '../mobile/bottom-sheet/range-cell';\nimport StepperCell from '../mobile/bottom-sheet/stepper-cell';\n\nconst RangeControl = memo(\n\t( {\n\t\tclassName,\n\t\tcurrentInput,\n\t\tlabel,\n\t\tvalue,\n\t\tinstanceId,\n\t\tonChange,\n\t\tbeforeIcon,\n\t\tafterIcon,\n\t\thelp,\n\t\tallowReset,\n\t\tinitialPosition,\n\t\tmin,\n\t\tmax,\n\t\ttype,\n\t\tseparatorType,\n\t\tdisabled,\n\t\t...props\n\t} ) => {\n\t\tif ( type === 'stepper' ) {\n\t\t\treturn (\n\t\t\t\t<StepperCell\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tmin={ min }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tseparatorType={ separatorType }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\t\tconst id = `inspector-range-control-${ instanceId }`;\n\t\tconst currentInputValue = currentInput === null ? value : currentInput;\n\t\tconst initialSliderValue = isFinite( currentInputValue )\n\t\t\t? currentInputValue\n\t\t\t: initialPosition;\n\n\t\treturn (\n\t\t\t<RangeCell\n\t\t\t\tlabel={ label }\n\t\t\t\tid={ id }\n\t\t\t\thelp={ help }\n\t\t\t\tclassName={ className }\n\t\t\t\tonChange={ onChange }\n\t\t\t\taria-describedby={ !! help ? `${ id }__help` : undefined }\n\t\t\t\tminimumValue={ min }\n\t\t\t\tmaximumValue={ max }\n\t\t\t\tvalue={ value }\n\t\t\t\tbeforeIcon={ beforeIcon }\n\t\t\t\tafterIcon={ afterIcon }\n\t\t\t\tallowReset={ allowReset }\n\t\t\t\tdefaultValue={ initialSliderValue }\n\t\t\t\tseparatorType={ separatorType }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t}\n);\n\nexport default RangeControl;\n"]}
@@ -174,7 +174,9 @@ const Sandbox = forwardRef(function Sandbox(_ref, ref) {
174
174
  type,
175
175
  url,
176
176
  onWindowEvents = {},
177
- viewportProps = ''
177
+ viewportProps = '',
178
+ onLoadEnd = () => {},
179
+ testID
178
180
  } = _ref;
179
181
  const colorScheme = usePreferredColorScheme();
180
182
  const [height, setHeight] = useState(0);
@@ -335,7 +337,9 @@ const Sandbox = forwardRef(function Sandbox(_ref, ref) {
335
337
  setBuiltInZoomControls: false,
336
338
  showsHorizontalScrollIndicator: false,
337
339
  showsVerticalScrollIndicator: false,
338
- mediaPlaybackRequiresUserAction: false
340
+ mediaPlaybackRequiresUserAction: false,
341
+ onLoadEnd: onLoadEnd,
342
+ testID: testID
339
343
  });
340
344
  });
341
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","viewportProps","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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CA7EA;AA+EA,MAAMC,KAAK,GAAI;AACf;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,CAjEA;AAmEA,MAAMC,WAAW,GAAG,EAApB;AAEA,MAAMC,OAAO,GAAGP,UAAU,CAAE,SAASO,OAAT,OAe3BC,GAf2B,EAgB1B;AAAA,MAfD;AACCC,IAAAA,cADD;AAECC,IAAAA,QAFD;AAGCC,IAAAA,IAAI,GAAG,EAHR;AAICC,IAAAA,IAAI,GAAG,IAJR;AAKCC,IAAAA,WAAW,GAAG,EALf;AAMCC,IAAAA,OAAO,GAAGR,WANX;AAOCS,IAAAA,MAAM,GAAGT,WAPV;AAQCU,IAAAA,KAAK,GAAG,EART;AASCC,IAAAA,IATD;AAUCC,IAAAA,GAVD;AAWCC,IAAAA,cAAc,GAAG,EAXlB;AAYCC,IAAAA,aAAa,GAAG;AAZjB,GAeC;AACD,QAAMC,WAAW,GAAGnB,uBAAuB,EAA3C;AACA,QAAM,CAAEoB,MAAF,EAAUC,SAAV,IAAwBzB,QAAQ,CAAE,CAAF,CAAtC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AA,OAAO,EAAE;AAND;AADkC,CAAnB,CAAzB;AAWA,eAAevF,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\tviewportProps = '',\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/>\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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CA7EA;AA+EA,MAAMC,KAAK,GAAI;AACf;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,CAjEA;AAmEA,MAAMC,WAAW,GAAG,EAApB;AAEA,MAAMC,OAAO,GAAGP,UAAU,CAAE,SAASO,OAAT,OAiB3BC,GAjB2B,EAkB1B;AAAA,MAjBD;AACCC,IAAAA,cADD;AAECC,IAAAA,QAFD;AAGCC,IAAAA,IAAI,GAAG,EAHR;AAICC,IAAAA,IAAI,GAAG,IAJR;AAKCC,IAAAA,WAAW,GAAG,EALf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sBC,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,KAtBnC;AAuBC,IAAA,SAAS,EAAG7C,SAvBb;AAwBC,IAAA,MAAM,EAAGC;AAxBV,IADD;AA4BA,CA9MyB,CAA1B;AAgNA,MAAM4D,gBAAgB,GAAG1F,UAAU,CAAC4F,MAAX,CAAmB;AAC3CD,EAAAA,OAAO,EAAE;AACR;AACF;AACA;AACA;AACA;AACEE,IAAAA,OAAO,EAAE;AAND;AADkC,CAAnB,CAAzB;AAWA,eAAezF,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\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,EAAAA,SAAS,CAAE,MAAM;AAChBM,IAAAA,OAAO,CAACC,OAAR,GAAkB,IAAlB;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACC,OAAR,GAAkB,KAAlB;AACA,KAFD;AAGA,GALQ,EAKN,EALM,CAAT;AAOA,SAAO,MAAM;AACZ,QAAKD,OAAO,CAACC,OAAb,EAAuB;AACtBF,MAAAA,QAAQ,CAAE,EAAF,CAAR;AACA;AACD,GAJD;AAKA;;AAED,eAAe,SAASG,IAAT,OAAoC;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAqB;AAClD,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,cAAhB;AAAgC,OAAGC;AAAnC,MAA4CX,OAAO,CAAEO,IAAF,CAAzD;AACA,QAAMK,GAAG,GAAGhB,MAAM,CAAE;AAAEiB,IAAAA,QAAQ,EAAEX,cAAc;AAA1B,GAAF,CAAlB;AAEAJ,EAAAA,SAAS,CAAE,MAAM;AAChB;AACA;AACA;AACAW,IAAAA,YAAY,CAAEG,GAAF,CAAZ;AACA,WAAO,MAAM;AACZF,MAAAA,cAAc,CAAEE,GAAF,CAAd;AACA,KAFD;AAGA,GARQ,EAQN,CAAEH,YAAF,EAAgBC,cAAhB,CARM,CAAT;;AAUA,MAAK,CAAEC,IAAI,CAACC,GAAP,IAAc,CAAED,IAAI,CAACC,GAAL,CAASP,OAA9B,EAAwC;AACvC,WAAO,IAAP;AACA;;AAED,MAAK,OAAOG,QAAP,KAAoB,UAAzB,EAAsC;AACrCA,IAAAA,QAAQ,GAAGA,QAAQ,CAAEG,IAAI,CAACG,SAAP,CAAnB;AACA,GApBiD,CAsBlD;AACA;AACA;AACA;;;AACA,QAAMC,eAAe,GACpB,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGJ,IAAI,CAACC,GAAL,CAASP,OAAT,CAAiBW;AAA3C,KACGR,QADH,CADD;AAMA,SAAOT,YAAY,CAAEgB,eAAF,EAAmBJ,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","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,EAAAA,SAAS,CAAE,MAAM;AAChBM,IAAAA,OAAO,CAACC,OAAR,GAAkB,IAAlB;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACC,OAAR,GAAkB,KAAlB;AACA,KAFD;AAGA,GALQ,EAKN,EALM,CAAT;AAOA,SAAO,MAAM;AACZ,QAAKD,OAAO,CAACC,OAAb,EAAuB;AACtBF,MAAAA,QAAQ,CAAE,EAAF,CAAR;AACA;AACD,GAJD;AAKA;;AAED,eAAe,SAASG,IAAT,OAAoC;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAqB;AAClD,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,cAAhB;AAAgC,OAAGC;AAAnC,MAA4CX,OAAO,CAAEO,IAAF,CAAzD;AACA,QAAMK,QAAQ,GAAGV,cAAc,EAA/B;AACA,QAAMW,GAAG,GAAGjB,MAAM,CAAE;AAAEgB,IAAAA;AAAF,GAAF,CAAlB;AAEAd,EAAAA,SAAS,CAAE,MAAM;AAChB;AACA;AACA;AACAW,IAAAA,YAAY,CAAEI,GAAF,CAAZ;AACA,WAAO,MAAM;AACZH,MAAAA,cAAc,CAAEG,GAAF,CAAd;AACA,KAFD;AAGA,GARQ,EAQN,CAAEJ,YAAF,EAAgBC,cAAhB,CARM,CAAT;;AAUA,MAAK,CAAEC,IAAI,CAACE,GAAP,IAAc,CAAEF,IAAI,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"]}