@wordpress/components 21.1.2-next.4d3b314fd5.0 → 21.3.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 (401) hide show
  1. package/CHANGELOG.md +48 -3
  2. package/CONTRIBUTING.md +20 -0
  3. package/build/border-box-control/border-box-control/component.js +2 -0
  4. package/build/border-box-control/border-box-control/component.js.map +1 -1
  5. package/build/border-box-control/border-box-control/hook.js +4 -1
  6. package/build/border-box-control/border-box-control/hook.js.map +1 -1
  7. package/build/border-box-control/utils.js +42 -2
  8. package/build/border-box-control/utils.js.map +1 -1
  9. package/build/border-control/border-control/component.js +2 -0
  10. package/build/border-control/border-control/component.js.map +1 -1
  11. package/build/combobox-control/index.js +0 -1
  12. package/build/combobox-control/index.js.map +1 -1
  13. package/build/custom-select-control/index.js +4 -2
  14. package/build/custom-select-control/index.js.map +1 -1
  15. package/build/disabled/index.js +6 -26
  16. package/build/disabled/index.js.map +1 -1
  17. package/build/font-size-picker/index.js +47 -56
  18. package/build/font-size-picker/index.js.map +1 -1
  19. package/build/font-size-picker/styles.js +65 -0
  20. package/build/font-size-picker/styles.js.map +1 -0
  21. package/build/font-size-picker/types.js +6 -0
  22. package/build/font-size-picker/types.js.map +1 -0
  23. package/build/font-size-picker/utils.js +18 -16
  24. package/build/font-size-picker/utils.js.map +1 -1
  25. package/build/form-token-field/suggestions-list.js +5 -5
  26. package/build/form-token-field/suggestions-list.js.map +1 -1
  27. package/build/form-token-field/token-input.js +20 -1
  28. package/build/form-token-field/token-input.js.map +1 -1
  29. package/build/higher-order/with-fallback-styles/index.js +1 -1
  30. package/build/higher-order/with-fallback-styles/index.js.map +1 -1
  31. package/build/index.js +14 -6
  32. package/build/index.js.map +1 -1
  33. package/build/modal/aria-helper.js +2 -3
  34. package/build/modal/aria-helper.js.map +1 -1
  35. package/build/modal/index.js +42 -11
  36. package/build/modal/index.js.map +1 -1
  37. package/build/modal/types.js +6 -0
  38. package/build/modal/types.js.map +1 -0
  39. package/build/navigator/index.js +8 -8
  40. package/build/navigator/index.js.map +1 -1
  41. package/build/navigator/navigator-back-button/component.js +5 -4
  42. package/build/navigator/navigator-back-button/component.js.map +1 -1
  43. package/build/navigator/navigator-back-button/index.js +1 -1
  44. package/build/navigator/navigator-back-button/index.js.map +1 -1
  45. package/build/navigator/navigator-button/component.js +5 -4
  46. package/build/navigator/navigator-button/component.js.map +1 -1
  47. package/build/navigator/navigator-button/index.js +1 -1
  48. package/build/navigator/navigator-button/index.js.map +1 -1
  49. package/build/navigator/navigator-provider/component.js +10 -7
  50. package/build/navigator/navigator-provider/component.js.map +1 -1
  51. package/build/navigator/navigator-provider/index.js +1 -1
  52. package/build/navigator/navigator-provider/index.js.map +1 -1
  53. package/build/navigator/navigator-screen/component.js +30 -26
  54. package/build/navigator/navigator-screen/component.js.map +1 -1
  55. package/build/navigator/navigator-screen/index.js +1 -1
  56. package/build/navigator/navigator-screen/index.js.map +1 -1
  57. package/build/resizable-box/resize-tooltip/utils.js +12 -14
  58. package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
  59. package/build/sandbox/index.js +68 -67
  60. package/build/sandbox/index.js.map +1 -1
  61. package/build/sandbox/index.native.js +66 -63
  62. package/build/sandbox/index.native.js.map +1 -1
  63. package/build/search-control/index.native.js +6 -2
  64. package/build/search-control/index.native.js.map +1 -1
  65. package/build/slot-fill/bubbles-virtually/slot-fill-context.js +8 -2
  66. package/build/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
  67. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +31 -41
  68. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  69. package/build/slot-fill/bubbles-virtually/use-slot-fills.js +39 -0
  70. package/build/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -0
  71. package/build/slot-fill/bubbles-virtually/use-slot.js +13 -4
  72. package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  73. package/build/slot-fill/index.js +8 -0
  74. package/build/slot-fill/index.js.map +1 -1
  75. package/build/tab-panel/index.js +4 -4
  76. package/build/tab-panel/index.js.map +1 -1
  77. package/build/theme/index.js +62 -0
  78. package/build/theme/index.js.map +1 -0
  79. package/build/theme/styles.js +33 -0
  80. package/build/theme/styles.js.map +1 -0
  81. package/build/theme/types.js +6 -0
  82. package/build/theme/types.js.map +1 -0
  83. package/build/toggle-group-control/toggle-group-control-option-base/styles.js +8 -8
  84. package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  85. package/build/tools-panel/tools-panel/hook.js +3 -3
  86. package/build/tools-panel/tools-panel/hook.js.map +1 -1
  87. package/build/tools-panel/tools-panel-item/hook.js +6 -6
  88. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  89. package/build/tooltip/index.js +4 -1
  90. package/build/tooltip/index.js.map +1 -1
  91. package/build/tooltip/index.native.js +17 -4
  92. package/build/tooltip/index.native.js.map +1 -1
  93. package/build-module/border-box-control/border-box-control/component.js +2 -0
  94. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  95. package/build-module/border-box-control/border-box-control/hook.js +4 -1
  96. package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
  97. package/build-module/border-box-control/utils.js +36 -1
  98. package/build-module/border-box-control/utils.js.map +1 -1
  99. package/build-module/border-control/border-control/component.js +2 -0
  100. package/build-module/border-control/border-control/component.js.map +1 -1
  101. package/build-module/combobox-control/index.js +0 -1
  102. package/build-module/combobox-control/index.js.map +1 -1
  103. package/build-module/custom-select-control/index.js +2 -1
  104. package/build-module/custom-select-control/index.js.map +1 -1
  105. package/build-module/disabled/index.js +7 -26
  106. package/build-module/disabled/index.js.map +1 -1
  107. package/build-module/font-size-picker/index.js +46 -54
  108. package/build-module/font-size-picker/index.js.map +1 -1
  109. package/build-module/font-size-picker/styles.js +54 -0
  110. package/build-module/font-size-picker/styles.js.map +1 -0
  111. package/build-module/font-size-picker/types.js +2 -0
  112. package/build-module/font-size-picker/types.js.map +1 -0
  113. package/build-module/font-size-picker/utils.js +22 -16
  114. package/build-module/font-size-picker/utils.js.map +1 -1
  115. package/build-module/form-token-field/suggestions-list.js +5 -5
  116. package/build-module/form-token-field/suggestions-list.js.map +1 -1
  117. package/build-module/form-token-field/token-input.js +21 -2
  118. package/build-module/form-token-field/token-input.js.map +1 -1
  119. package/build-module/higher-order/with-fallback-styles/index.js +2 -2
  120. package/build-module/higher-order/with-fallback-styles/index.js.map +1 -1
  121. package/build-module/index.js +3 -2
  122. package/build-module/index.js.map +1 -1
  123. package/build-module/modal/aria-helper.js +2 -3
  124. package/build-module/modal/aria-helper.js.map +1 -1
  125. package/build-module/modal/index.js +44 -12
  126. package/build-module/modal/index.js.map +1 -1
  127. package/build-module/modal/types.js +2 -0
  128. package/build-module/modal/types.js.map +1 -0
  129. package/build-module/navigator/index.js +4 -4
  130. package/build-module/navigator/index.js.map +1 -1
  131. package/build-module/navigator/navigator-back-button/component.js +3 -3
  132. package/build-module/navigator/navigator-back-button/component.js.map +1 -1
  133. package/build-module/navigator/navigator-back-button/index.js +1 -1
  134. package/build-module/navigator/navigator-back-button/index.js.map +1 -1
  135. package/build-module/navigator/navigator-button/component.js +3 -3
  136. package/build-module/navigator/navigator-button/component.js.map +1 -1
  137. package/build-module/navigator/navigator-button/index.js +1 -1
  138. package/build-module/navigator/navigator-button/index.js.map +1 -1
  139. package/build-module/navigator/navigator-provider/component.js +8 -6
  140. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  141. package/build-module/navigator/navigator-provider/index.js +1 -1
  142. package/build-module/navigator/navigator-provider/index.js.map +1 -1
  143. package/build-module/navigator/navigator-screen/component.js +18 -25
  144. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  145. package/build-module/navigator/navigator-screen/index.js +1 -1
  146. package/build-module/navigator/navigator-screen/index.js.map +1 -1
  147. package/build-module/resizable-box/resize-tooltip/utils.js +13 -15
  148. package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
  149. package/build-module/sandbox/index.js +69 -67
  150. package/build-module/sandbox/index.js.map +1 -1
  151. package/build-module/sandbox/index.native.js +57 -53
  152. package/build-module/sandbox/index.native.js.map +1 -1
  153. package/build-module/search-control/index.native.js +6 -2
  154. package/build-module/search-control/index.native.js.map +1 -1
  155. package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js +7 -2
  156. package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
  157. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +30 -42
  158. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  159. package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js +27 -0
  160. package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -0
  161. package/build-module/slot-fill/bubbles-virtually/use-slot.js +13 -5
  162. package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  163. package/build-module/slot-fill/index.js +1 -0
  164. package/build-module/slot-fill/index.js.map +1 -1
  165. package/build-module/tab-panel/index.js +4 -4
  166. package/build-module/tab-panel/index.js.map +1 -1
  167. package/build-module/theme/index.js +52 -0
  168. package/build-module/theme/index.js.map +1 -0
  169. package/build-module/theme/styles.js +25 -0
  170. package/build-module/theme/styles.js.map +1 -0
  171. package/build-module/theme/types.js +2 -0
  172. package/build-module/theme/types.js.map +1 -0
  173. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +7 -7
  174. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  175. package/build-module/tools-panel/tools-panel/hook.js +3 -3
  176. package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
  177. package/build-module/tools-panel/tools-panel-item/hook.js +6 -6
  178. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  179. package/build-module/tooltip/index.js +4 -1
  180. package/build-module/tooltip/index.js.map +1 -1
  181. package/build-module/tooltip/index.native.js +17 -4
  182. package/build-module/tooltip/index.native.js.map +1 -1
  183. package/build-style/style-rtl.css +27 -120
  184. package/build-style/style.css +27 -120
  185. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  186. package/build-types/border-box-control/border-box-control/hook.d.ts +1 -0
  187. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  188. package/build-types/border-box-control/utils.d.ts +1 -3
  189. package/build-types/border-box-control/utils.d.ts.map +1 -1
  190. package/build-types/border-control/border-control/component.d.ts +1 -0
  191. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  192. package/build-types/border-control/border-control/hook.d.ts +1 -0
  193. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  194. package/build-types/border-control/stories/index.d.ts +6 -0
  195. package/build-types/border-control/stories/index.d.ts.map +1 -1
  196. package/build-types/border-control/types.d.ts +4 -0
  197. package/build-types/border-control/types.d.ts.map +1 -1
  198. package/build-types/confirm-dialog/types.d.ts +5 -1
  199. package/build-types/confirm-dialog/types.d.ts.map +1 -1
  200. package/build-types/custom-select-control/index.d.ts +13 -0
  201. package/build-types/custom-select-control/index.d.ts.map +1 -0
  202. package/build-types/custom-select-control/styles.d.ts +9 -0
  203. package/build-types/custom-select-control/styles.d.ts.map +1 -0
  204. package/build-types/disabled/index.d.ts.map +1 -1
  205. package/build-types/font-size-picker/index.d.ts +5 -0
  206. package/build-types/font-size-picker/index.d.ts.map +1 -0
  207. package/build-types/font-size-picker/stories/e2e/index.d.ts +16 -0
  208. package/build-types/font-size-picker/stories/e2e/index.d.ts.map +1 -0
  209. package/build-types/font-size-picker/stories/index.d.ts +31 -0
  210. package/build-types/font-size-picker/stories/index.d.ts.map +1 -0
  211. package/build-types/font-size-picker/styles.d.ts +27 -0
  212. package/build-types/font-size-picker/styles.d.ts.map +1 -0
  213. package/build-types/font-size-picker/test/index.d.ts +2 -0
  214. package/build-types/font-size-picker/test/index.d.ts.map +1 -0
  215. package/build-types/font-size-picker/test/utils.d.ts +2 -0
  216. package/build-types/font-size-picker/test/utils.d.ts.map +1 -0
  217. package/build-types/font-size-picker/types.d.ts +93 -0
  218. package/build-types/font-size-picker/types.d.ts.map +1 -0
  219. package/build-types/font-size-picker/utils.d.ts +41 -0
  220. package/build-types/font-size-picker/utils.d.ts.map +1 -0
  221. package/build-types/form-token-field/token-input.d.ts.map +1 -1
  222. package/build-types/modal/aria-helper.d.ts +4 -4
  223. package/build-types/modal/aria-helper.d.ts.map +1 -1
  224. package/build-types/modal/index.d.ts +35 -2
  225. package/build-types/modal/index.d.ts.map +1 -1
  226. package/build-types/modal/stories/index.d.ts +9 -0
  227. package/build-types/modal/stories/index.d.ts.map +1 -0
  228. package/build-types/modal/test/aria-helper.d.ts +2 -0
  229. package/build-types/modal/test/aria-helper.d.ts.map +1 -0
  230. package/build-types/modal/test/index.d.ts +2 -0
  231. package/build-types/modal/test/index.d.ts.map +1 -0
  232. package/build-types/modal/types.d.ts +134 -0
  233. package/build-types/modal/types.d.ts.map +1 -0
  234. package/build-types/navigator/index.d.ts +4 -4
  235. package/build-types/navigator/index.d.ts.map +1 -1
  236. package/build-types/navigator/navigator-back-button/component.d.ts +4 -2
  237. package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
  238. package/build-types/navigator/navigator-back-button/hook.d.ts +1 -0
  239. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  240. package/build-types/navigator/navigator-back-button/index.d.ts +1 -1
  241. package/build-types/navigator/navigator-back-button/index.d.ts.map +1 -1
  242. package/build-types/navigator/navigator-button/component.d.ts +4 -2
  243. package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
  244. package/build-types/navigator/navigator-button/hook.d.ts +1 -0
  245. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  246. package/build-types/navigator/navigator-button/index.d.ts +1 -1
  247. package/build-types/navigator/navigator-button/index.d.ts.map +1 -1
  248. package/build-types/navigator/navigator-provider/component.d.ts +2 -2
  249. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  250. package/build-types/navigator/navigator-provider/index.d.ts +1 -1
  251. package/build-types/navigator/navigator-provider/index.d.ts.map +1 -1
  252. package/build-types/navigator/navigator-screen/component.d.ts +2 -2
  253. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  254. package/build-types/navigator/navigator-screen/index.d.ts +1 -1
  255. package/build-types/navigator/navigator-screen/index.d.ts.map +1 -1
  256. package/build-types/navigator/stories/index.d.ts +9 -0
  257. package/build-types/navigator/stories/index.d.ts.map +1 -0
  258. package/build-types/navigator/test/index.d.ts +2 -0
  259. package/build-types/navigator/test/index.d.ts.map +1 -0
  260. package/build-types/navigator/types.d.ts +4 -1
  261. package/build-types/navigator/types.d.ts.map +1 -1
  262. package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts +2 -2
  263. package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts.map +1 -1
  264. package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
  265. package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts +2 -0
  266. package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts.map +1 -0
  267. package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
  268. package/build-types/slot-fill/index.d.ts +1 -0
  269. package/build-types/slot-fill/index.d.ts.map +1 -1
  270. package/build-types/tab-panel/index.d.ts.map +1 -1
  271. package/build-types/theme/index.d.ts +31 -0
  272. package/build-types/theme/index.d.ts.map +1 -0
  273. package/build-types/theme/stories/index.d.ts +13 -0
  274. package/build-types/theme/stories/index.d.ts.map +1 -0
  275. package/build-types/theme/styles.d.ts +10 -0
  276. package/build-types/theme/styles.d.ts.map +1 -0
  277. package/build-types/theme/test/index.d.ts +2 -0
  278. package/build-types/theme/test/index.d.ts.map +1 -0
  279. package/build-types/theme/types.d.ts +21 -0
  280. package/build-types/theme/types.d.ts.map +1 -0
  281. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts +1 -1
  282. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
  283. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  284. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  285. package/build-types/tooltip/index.d.ts.map +1 -1
  286. package/package.json +19 -18
  287. package/src/alignment-matrix-control/test/index.js +17 -62
  288. package/src/base-field/test/index.js +4 -6
  289. package/src/border-box-control/border-box-control/component.tsx +2 -0
  290. package/src/border-box-control/border-box-control/hook.ts +4 -0
  291. package/src/border-box-control/test/index.js +7 -2
  292. package/src/border-box-control/test/utils.js +48 -0
  293. package/src/border-box-control/utils.ts +44 -1
  294. package/src/border-control/border-control/README.md +6 -0
  295. package/src/border-control/border-control/component.tsx +2 -0
  296. package/src/border-control/types.ts +4 -0
  297. package/src/button/style.scss +25 -25
  298. package/src/button/test/index.js +3 -5
  299. package/src/combobox-control/index.js +0 -5
  300. package/src/combobox-control/test/index.js +1 -1
  301. package/src/confirm-dialog/types.ts +6 -0
  302. package/src/custom-select-control/index.js +2 -1
  303. package/src/date-time/time/test/index.tsx +2 -6
  304. package/src/disabled/index.tsx +11 -33
  305. package/src/disabled/test/index.tsx +14 -82
  306. package/src/dropdown/test/index.js +4 -3
  307. package/src/font-size-picker/{index.js → index.tsx} +114 -80
  308. package/src/font-size-picker/stories/e2e/{index.js → index.tsx} +13 -4
  309. package/src/font-size-picker/stories/{index.js → index.tsx} +42 -36
  310. package/src/font-size-picker/styles.ts +46 -0
  311. package/src/font-size-picker/test/{index.js → index.tsx} +3 -3
  312. package/src/font-size-picker/test/{utils.js → utils.ts} +11 -7
  313. package/src/font-size-picker/types.ts +98 -0
  314. package/src/font-size-picker/{utils.js → utils.ts} +52 -28
  315. package/src/form-file-upload/test/index.tsx +1 -1
  316. package/src/form-token-field/suggestions-list.tsx +5 -5
  317. package/src/form-token-field/test/index.tsx +22 -1
  318. package/src/form-token-field/token-input.tsx +25 -3
  319. package/src/higher-order/with-fallback-styles/index.js +6 -2
  320. package/src/higher-order/with-focus-outside/test/index.js +44 -45
  321. package/src/higher-order/with-focus-return/test/index.js +34 -30
  322. package/src/higher-order/with-notices/test/index.js +1 -1
  323. package/src/index.js +3 -1
  324. package/src/input-control/test/index.js +2 -2
  325. package/src/item-group/test/index.js +2 -2
  326. package/src/menu-item/test/index.js +0 -3
  327. package/src/mobile/bottom-sheet/test/range-cell.native.js +16 -14
  328. package/src/modal/README.md +53 -54
  329. package/src/modal/{aria-helper.js → aria-helper.ts} +5 -7
  330. package/src/modal/{index.js → index.tsx} +48 -12
  331. package/src/modal/stories/{index.js → index.tsx} +47 -42
  332. package/src/modal/test/{aria-helper.js → aria-helper.ts} +0 -0
  333. package/src/modal/test/{index.js → index.tsx} +13 -3
  334. package/src/modal/types.ts +144 -0
  335. package/src/navigation/test/index.js +1 -1
  336. package/src/navigator/index.ts +4 -4
  337. package/src/navigator/navigator-back-button/component.tsx +4 -4
  338. package/src/navigator/navigator-back-button/index.ts +1 -1
  339. package/src/navigator/navigator-button/component.tsx +4 -4
  340. package/src/navigator/navigator-button/index.ts +1 -1
  341. package/src/navigator/navigator-provider/component.tsx +6 -4
  342. package/src/navigator/navigator-provider/index.ts +1 -1
  343. package/src/navigator/navigator-screen/component.tsx +27 -26
  344. package/src/navigator/navigator-screen/index.ts +1 -1
  345. package/src/navigator/stories/index.tsx +210 -0
  346. package/src/navigator/test/index.tsx +509 -0
  347. package/src/navigator/types.ts +2 -0
  348. package/src/notice/test/__snapshots__/index.js.snap +39 -38
  349. package/src/notice/test/index.js +15 -36
  350. package/src/notice/test/list.js +6 -14
  351. package/src/number-control/test/index.js +3 -2
  352. package/src/panel/test/body.js +2 -2
  353. package/src/placeholder/style.scss +7 -2
  354. package/src/resizable-box/resize-tooltip/utils.ts +13 -13
  355. package/src/sandbox/index.js +75 -54
  356. package/src/sandbox/index.native.js +75 -52
  357. package/src/sandbox/test/index.js +7 -10
  358. package/src/search-control/index.native.js +6 -0
  359. package/src/shortcut/test/index.tsx +1 -1
  360. package/src/slot-fill/bubbles-virtually/slot-fill-context.js +6 -2
  361. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +53 -58
  362. package/src/slot-fill/bubbles-virtually/use-slot-fills.js +24 -0
  363. package/src/slot-fill/bubbles-virtually/use-slot.js +11 -6
  364. package/src/slot-fill/index.js +1 -0
  365. package/src/style.scss +4 -1
  366. package/src/tab-panel/index.tsx +4 -7
  367. package/src/text-highlight/test/index.tsx +1 -3
  368. package/src/theme/README.md +34 -0
  369. package/src/theme/index.tsx +51 -0
  370. package/src/theme/stories/index.tsx +47 -0
  371. package/src/theme/styles.ts +28 -0
  372. package/src/theme/test/index.tsx +101 -0
  373. package/src/theme/types.ts +21 -0
  374. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +1 -0
  375. package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +9 -7
  376. package/src/toolbar/test/index.js +2 -2
  377. package/src/toolbar-group/test/index.js +6 -10
  378. package/src/tools-panel/test/index.js +4 -6
  379. package/src/tools-panel/tools-panel/hook.ts +2 -9
  380. package/src/tools-panel/tools-panel-item/hook.ts +17 -3
  381. package/src/tooltip/index.js +3 -0
  382. package/src/tooltip/index.native.js +15 -0
  383. package/src/tooltip/test/index.native.js +1 -2
  384. package/src/tree-grid/test/__snapshots__/cell.js.snap +1 -3
  385. package/src/tree-grid/test/__snapshots__/roving-tab-index-item.js.snap +17 -15
  386. package/src/tree-grid/test/__snapshots__/row.js.snap +25 -21
  387. package/src/tree-grid/test/cell.js +4 -4
  388. package/src/tree-grid/test/roving-tab-index-item.js +8 -8
  389. package/src/tree-grid/test/roving-tab-index.js +3 -3
  390. package/src/tree-grid/test/row.js +20 -16
  391. package/src/truncate/test/index.tsx +4 -4
  392. package/src/ui/shortcut/test/index.js +2 -1
  393. package/src/ui/spinner/test/index.js +14 -13
  394. package/src/ui/tooltip/test/index.js +16 -14
  395. package/src/utils/theme-variables.scss +8 -0
  396. package/src/visually-hidden/README.md +4 -0
  397. package/tsconfig.json +0 -2
  398. package/tsconfig.tsbuildinfo +1 -1
  399. package/src/font-size-picker/style.scss +0 -78
  400. package/src/navigator/stories/index.js +0 -194
  401. package/src/navigator/test/index.js +0 -407
@@ -1,13 +1,11 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import ShallowRenderer from 'react-test-renderer/shallow';
5
- import { create } from 'react-test-renderer';
4
+ import { render } from '@testing-library/react';
6
5
 
7
6
  /**
8
7
  * WordPress dependencies
9
8
  */
10
- import TokenList from '@wordpress/token-list';
11
9
  import { speak } from '@wordpress/a11y';
12
10
 
13
11
  /**
@@ -23,9 +21,7 @@ describe( 'Notice', () => {
23
21
  } );
24
22
 
25
23
  it( 'should match snapshot', () => {
26
- const renderer = new ShallowRenderer();
27
-
28
- renderer.render(
24
+ const { container } = render(
29
25
  <Notice
30
26
  status="success"
31
27
  actions={ [
@@ -38,63 +34,47 @@ describe( 'Notice', () => {
38
34
  </Notice>
39
35
  );
40
36
 
41
- expect( renderer.getRenderOutput() ).toMatchSnapshot();
37
+ expect( container ).toMatchSnapshot();
42
38
  } );
43
39
 
44
40
  it( 'should not have is-dismissible class when isDismissible prop is false', () => {
45
- const renderer = new ShallowRenderer();
46
-
47
- renderer.render( <Notice isDismissible={ false } /> );
41
+ const { container } = render( <Notice isDismissible={ false } /> );
48
42
 
49
- const classes = new TokenList(
50
- renderer.getRenderOutput().props.className
51
- );
52
- expect( classes.contains( 'components-notice' ) ).toBe( true );
53
- expect( classes.contains( 'is-dismissible' ) ).toBe( false );
43
+ expect( container.firstChild ).toHaveClass( 'components-notice' );
44
+ expect( container.firstChild ).not.toHaveClass( 'is-dismissible' );
54
45
  } );
55
46
 
56
47
  it( 'should default to info status', () => {
57
- const renderer = new ShallowRenderer();
48
+ const { container } = render( <Notice /> );
58
49
 
59
- renderer.render( <Notice /> );
60
-
61
- const classes = new TokenList(
62
- renderer.getRenderOutput().props.className
63
- );
64
- expect( classes.contains( 'is-info' ) ).toBe( true );
50
+ expect( container.firstChild ).toHaveClass( 'is-info' );
65
51
  } );
66
52
 
67
53
  describe( 'useSpokenMessage', () => {
68
54
  it( 'should speak the given message', () => {
69
- const tree = create( <Notice>FYI</Notice> );
70
- tree.update();
55
+ render( <Notice>FYI</Notice> );
71
56
 
72
57
  expect( speak ).toHaveBeenCalledWith( 'FYI', 'polite' );
73
58
  } );
74
59
 
75
60
  it( 'should speak the given message by explicit politeness', () => {
76
- const tree = create(
77
- <Notice politeness="assertive">Uh oh!</Notice>
78
- );
79
- tree.update();
61
+ render( <Notice politeness="assertive">Uh oh!</Notice> );
80
62
 
81
63
  expect( speak ).toHaveBeenCalledWith( 'Uh oh!', 'assertive' );
82
64
  } );
83
65
 
84
66
  it( 'should speak the given message by implicit politeness by status', () => {
85
- const tree = create( <Notice status="error">Uh oh!</Notice> );
86
- tree.update();
67
+ render( <Notice status="error">Uh oh!</Notice> );
87
68
 
88
69
  expect( speak ).toHaveBeenCalledWith( 'Uh oh!', 'assertive' );
89
70
  } );
90
71
 
91
72
  it( 'should speak the given message, preferring explicit to implicit politeness', () => {
92
- const tree = create(
73
+ render(
93
74
  <Notice politeness="polite" status="error">
94
75
  No need to panic
95
76
  </Notice>
96
77
  );
97
- tree.update();
98
78
 
99
79
  expect( speak ).toHaveBeenCalledWith(
100
80
  'No need to panic',
@@ -105,12 +85,11 @@ describe( 'Notice', () => {
105
85
  it( 'should coerce a message to a string', () => {
106
86
  // This test assumes that `@wordpress/a11y` is capable of handling
107
87
  // markup strings appropriately.
108
- const tree = create(
88
+ render(
109
89
  <Notice>
110
90
  With <em>emphasis</em> this time.
111
91
  </Notice>
112
92
  );
113
- tree.update();
114
93
 
115
94
  expect( speak ).toHaveBeenCalledWith(
116
95
  'With <em>emphasis</em> this time.',
@@ -119,12 +98,12 @@ describe( 'Notice', () => {
119
98
  } );
120
99
 
121
100
  it( 'should not re-speak an effectively equivalent element message', () => {
122
- const tree = create(
101
+ const { rerender } = render(
123
102
  <Notice>
124
103
  With <em>emphasis</em> this time.
125
104
  </Notice>
126
105
  );
127
- tree.update(
106
+ rerender(
128
107
  <Notice>
129
108
  With <em>emphasis</em> this time.
130
109
  </Notice>
@@ -1,12 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import ShallowRenderer from 'react-test-renderer/shallow';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import TokenList from '@wordpress/token-list';
4
+ import { render } from '@testing-library/react';
10
5
 
11
6
  /**
12
7
  * Internal dependencies
@@ -15,14 +10,11 @@ import NoticeList from '../list';
15
10
 
16
11
  describe( 'NoticeList', () => {
17
12
  it( 'should merge className', () => {
18
- const renderer = new ShallowRenderer();
19
-
20
- renderer.render( <NoticeList notices={ [] } className="is-ok" /> );
21
-
22
- const classes = new TokenList(
23
- renderer.getRenderOutput().props.className
13
+ const { container } = render(
14
+ <NoticeList notices={ [] } className="is-ok" />
24
15
  );
25
- expect( classes.contains( 'is-ok' ) ).toBe( true );
26
- expect( classes.contains( 'components-notice-list' ) ).toBe( true );
16
+
17
+ expect( container.firstChild ).toHaveClass( 'is-ok' );
18
+ expect( container.firstChild ).toHaveClass( 'components-notice-list' );
27
19
  } );
28
20
  } );
@@ -90,9 +90,10 @@ describe( 'NumberControl', () => {
90
90
  // After the blur, the `onChange` callback fires asynchronously.
91
91
  await waitFor( () => {
92
92
  expect( spy ).toHaveBeenCalledTimes( 2 );
93
- expect( spy ).toHaveBeenNthCalledWith( 1, '1' );
94
- expect( spy ).toHaveBeenNthCalledWith( 2, 4 );
95
93
  } );
94
+
95
+ expect( spy ).toHaveBeenNthCalledWith( 1, '1' );
96
+ expect( spy ).toHaveBeenNthCalledWith( 2, 4 );
96
97
  } );
97
98
 
98
99
  it( 'should call onChange callback when value is not valid', () => {
@@ -67,7 +67,7 @@ describe( 'PanelBody', () => {
67
67
  let panelContent = getPanelBodyContent( container );
68
68
 
69
69
  expect( panelContent ).toBeTruthy();
70
- expect( panelContent.getAttribute( 'hidden' ) ).toBe( '' );
70
+ expect( panelContent ).toHaveAttribute( 'hidden', '' );
71
71
 
72
72
  rerender(
73
73
  <PanelBody opened={ false }>
@@ -77,7 +77,7 @@ describe( 'PanelBody', () => {
77
77
  panelContent = getPanelBodyContent( container );
78
78
 
79
79
  expect( panelContent ).toBeTruthy();
80
- expect( panelContent.getAttribute( 'hidden' ) ).toBeNull();
80
+ expect( panelContent ).not.toHaveAttribute( 'hidden' );
81
81
  } );
82
82
  } );
83
83
 
@@ -178,9 +178,12 @@
178
178
  min-width: 100px;
179
179
 
180
180
  // Blur the background so layered dashed placeholders are still visually separate.
181
- // We also provide a semitransparent background so as to allow duotones to sheen through.
181
+ // Make the background transparent to not interfere with the background overlay in placeholder-style() pseudo element
182
182
  backdrop-filter: blur(100px);
183
- background-color: rgba($white, 0.1);
183
+ background-color: transparent;
184
+
185
+ // This appears to fix an occasional Chrome bug where the blurred background would have an incorrect color.
186
+ backface-visibility: hidden;
184
187
 
185
188
  // Invert the colors in themes deemed dark.
186
189
  .is-dark-theme & {
@@ -201,6 +204,7 @@
201
204
  .components-placeholder__instructions,
202
205
  .components-button {
203
206
  opacity: 0;
207
+ pointer-events: none;
204
208
  transition: opacity 0.1s linear;
205
209
  @include reduce-motion("transition");
206
210
  }
@@ -210,6 +214,7 @@
210
214
  .components-placeholder__instructions,
211
215
  .components-button {
212
216
  opacity: 1;
217
+ pointer-events: auto;
213
218
  }
214
219
  }
215
220
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useEffect, useRef, useState } from '@wordpress/element';
4
+ import { useCallback, useEffect, useRef, useState } from '@wordpress/element';
5
5
  import { useResizeObserver } from '@wordpress/compose';
6
6
 
7
7
  const noop = () => {};
@@ -84,23 +84,23 @@ export function useResizeLabel( {
84
84
  */
85
85
  const moveTimeoutRef = useRef< number >();
86
86
 
87
- const unsetMoveXY = () => {
88
- /*
89
- * If axis is controlled, we will avoid resetting the moveX and moveY values.
90
- * This will allow for the preferred axis values to persist in the label.
91
- */
92
- if ( isAxisControlled ) return;
93
- setMoveX( false );
94
- setMoveY( false );
95
- };
87
+ const debounceUnsetMoveXY = useCallback( () => {
88
+ const unsetMoveXY = () => {
89
+ /*
90
+ * If axis is controlled, we will avoid resetting the moveX and moveY values.
91
+ * This will allow for the preferred axis values to persist in the label.
92
+ */
93
+ if ( isAxisControlled ) return;
94
+ setMoveX( false );
95
+ setMoveY( false );
96
+ };
96
97
 
97
- const debounceUnsetMoveXY = () => {
98
98
  if ( moveTimeoutRef.current ) {
99
99
  window.clearTimeout( moveTimeoutRef.current );
100
100
  }
101
101
 
102
102
  moveTimeoutRef.current = window.setTimeout( unsetMoveXY, fadeTimeout );
103
- };
103
+ }, [ fadeTimeout, isAxisControlled ] );
104
104
 
105
105
  useEffect( () => {
106
106
  /*
@@ -143,7 +143,7 @@ export function useResizeLabel( {
143
143
 
144
144
  onResize( { width, height } );
145
145
  debounceUnsetMoveXY();
146
- }, [ width, height ] );
146
+ }, [ width, height, onResize, debounceUnsetMoveXY ] );
147
147
 
148
148
  const label = getSizeLabel( {
149
149
  axis,
@@ -9,64 +9,79 @@ import {
9
9
  } from '@wordpress/element';
10
10
  import { useFocusableIframe, useMergeRefs } from '@wordpress/compose';
11
11
 
12
- const observeAndResizeJS = `
13
- ( function() {
14
- var observer;
12
+ const observeAndResizeJS = function () {
13
+ const { MutationObserver } = window;
15
14
 
16
- if ( ! window.MutationObserver || ! document.body || ! window.parent ) {
17
- return;
18
- }
15
+ if ( ! MutationObserver || ! document.body || ! window.parent ) {
16
+ return;
17
+ }
19
18
 
20
- function sendResize() {
21
- var clientBoundingRect = document.body.getBoundingClientRect();
19
+ function sendResize() {
20
+ const clientBoundingRect = document.body.getBoundingClientRect();
22
21
 
23
- window.parent.postMessage( {
22
+ window.parent.postMessage(
23
+ {
24
24
  action: 'resize',
25
25
  width: clientBoundingRect.width,
26
26
  height: clientBoundingRect.height,
27
- }, '*' );
28
- }
27
+ },
28
+ '*'
29
+ );
30
+ }
29
31
 
30
- observer = new MutationObserver( sendResize );
31
- observer.observe( document.body, {
32
- attributes: true,
33
- attributeOldValue: false,
34
- characterData: true,
35
- characterDataOldValue: false,
36
- childList: true,
37
- subtree: true
38
- } );
39
-
40
- window.addEventListener( 'load', sendResize, true );
41
-
42
- // Hack: Remove viewport unit styles, as these are relative
43
- // the iframe root and interfere with our mechanism for
44
- // determining the unconstrained page bounds.
45
- function removeViewportStyles( ruleOrNode ) {
46
- if( ruleOrNode.style ) {
47
- [ 'width', 'height', 'minHeight', 'maxHeight' ].forEach( function( style ) {
48
- if ( /^\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] ) ) {
49
- ruleOrNode.style[ style ] = '';
50
- }
51
- } );
52
- }
32
+ const observer = new MutationObserver( sendResize );
33
+ observer.observe( document.body, {
34
+ attributes: true,
35
+ attributeOldValue: false,
36
+ characterData: true,
37
+ characterDataOldValue: false,
38
+ childList: true,
39
+ subtree: true,
40
+ } );
41
+
42
+ window.addEventListener( 'load', sendResize, true );
43
+
44
+ // Hack: Remove viewport unit styles, as these are relative
45
+ // the iframe root and interfere with our mechanism for
46
+ // determining the unconstrained page bounds.
47
+ function removeViewportStyles( ruleOrNode ) {
48
+ if ( ruleOrNode.style ) {
49
+ [ 'width', 'height', 'minHeight', 'maxHeight' ].forEach( function (
50
+ style
51
+ ) {
52
+ if (
53
+ /^\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )
54
+ ) {
55
+ ruleOrNode.style[ style ] = '';
56
+ }
57
+ } );
53
58
  }
59
+ }
54
60
 
55
- Array.prototype.forEach.call( document.querySelectorAll( '[style]' ), removeViewportStyles );
56
- Array.prototype.forEach.call( document.styleSheets, function( stylesheet ) {
57
- Array.prototype.forEach.call( stylesheet.cssRules || stylesheet.rules, removeViewportStyles );
58
- } );
61
+ Array.prototype.forEach.call(
62
+ document.querySelectorAll( '[style]' ),
63
+ removeViewportStyles
64
+ );
65
+ Array.prototype.forEach.call(
66
+ document.styleSheets,
67
+ function ( stylesheet ) {
68
+ Array.prototype.forEach.call(
69
+ stylesheet.cssRules || stylesheet.rules,
70
+ removeViewportStyles
71
+ );
72
+ }
73
+ );
59
74
 
60
- document.body.style.position = 'absolute';
61
- document.body.style.width = '100%';
62
- document.body.setAttribute( 'data-resizable-iframe-connected', '' );
75
+ document.body.style.position = 'absolute';
76
+ document.body.style.width = '100%';
77
+ document.body.setAttribute( 'data-resizable-iframe-connected', '' );
63
78
 
64
- sendResize();
79
+ sendResize();
65
80
 
66
- // Resize events can change the width of elements with 100% width, but we don't
67
- // get an DOM mutations for that, so do the resize when the window is resized, too.
68
- window.addEventListener( 'resize', sendResize, true );
69
- } )();`;
81
+ // Resize events can change the width of elements with 100% width, but we don't
82
+ // get an DOM mutations for that, so do the resize when the window is resized, too.
83
+ window.addEventListener( 'resize', sendResize, true );
84
+ };
70
85
 
71
86
  const style = `
72
87
  body {
@@ -153,7 +168,7 @@ export default function Sandbox( {
153
168
  <script
154
169
  type="text/javascript"
155
170
  dangerouslySetInnerHTML={ {
156
- __html: observeAndResizeJS,
171
+ __html: `(${ observeAndResizeJS.toString() })();`,
157
172
  } }
158
173
  />
159
174
  { scripts.map( ( src ) => (
@@ -205,32 +220,38 @@ export default function Sandbox( {
205
220
  setHeight( data.height );
206
221
  }
207
222
 
208
- const { ownerDocument } = ref.current;
223
+ const iframe = ref.current;
224
+ const { ownerDocument } = iframe;
209
225
  const { defaultView } = ownerDocument;
210
226
 
211
227
  // This used to be registered using <iframe onLoad={} />, but it made the iframe blank
212
228
  // after reordering the containing block. See these two issues for more details:
213
229
  // https://github.com/WordPress/gutenberg/issues/6146
214
230
  // https://github.com/facebook/react/issues/18752
215
- ref.current.addEventListener( 'load', tryNoForceSandbox, false );
231
+ iframe.addEventListener( 'load', tryNoForceSandbox, false );
216
232
  defaultView.addEventListener( 'message', checkMessageForResize );
217
233
 
218
234
  return () => {
219
- ref.current?.removeEventListener(
220
- 'load',
221
- tryNoForceSandbox,
222
- false
223
- );
235
+ iframe?.removeEventListener( 'load', tryNoForceSandbox, false );
224
236
  defaultView.addEventListener( 'message', checkMessageForResize );
225
237
  };
238
+ // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
239
+ // See https://github.com/WordPress/gutenberg/pull/44378
240
+ // eslint-disable-next-line react-hooks/exhaustive-deps
226
241
  }, [] );
227
242
 
228
243
  useEffect( () => {
229
244
  trySandbox();
245
+ // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
246
+ // See https://github.com/WordPress/gutenberg/pull/44378
247
+ // eslint-disable-next-line react-hooks/exhaustive-deps
230
248
  }, [ title, styles, scripts ] );
231
249
 
232
250
  useEffect( () => {
233
251
  trySandbox( true );
252
+ // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
253
+ // See https://github.com/WordPress/gutenberg/pull/44378
254
+ // eslint-disable-next-line react-hooks/exhaustive-deps
234
255
  }, [ html, type ] );
235
256
 
236
257
  return (
@@ -22,67 +22,85 @@ import { usePreferredColorScheme } from '@wordpress/compose';
22
22
  */
23
23
  import sandboxStyles from './style.scss';
24
24
 
25
- const observeAndResizeJS = `
26
- ( function() {
27
- var observer;
28
-
29
- if ( ! window.MutationObserver || ! document.body || ! window.parent ) {
30
- return;
31
- }
25
+ const observeAndResizeJS = function () {
26
+ // Hermes requires a special directive to preserve the original source code
27
+ // when using `Function.prototype.toString()` below.
28
+ // https://github.com/facebook/hermes/issues/114#issuecomment-887106990
29
+ 'show source';
30
+ const { MutationObserver } = window;
31
+
32
+ if ( ! MutationObserver || ! document.body || ! window.parent ) {
33
+ return;
34
+ }
32
35
 
33
- function sendResize() {
34
- var clientBoundingRect = document.body.getBoundingClientRect();
36
+ function sendResize() {
37
+ const clientBoundingRect = document.body.getBoundingClientRect();
35
38
 
36
- // The function postMessage is exposed by the react-native-webview library
37
- // to communicate between React Native and the WebView, in this case,
38
- // we use it for notifying resize changes.
39
- window.ReactNativeWebView.postMessage(JSON.stringify( {
40
- action: 'resize',
39
+ // The function postMessage is exposed by the react-native-webview library
40
+ // to communicate between React Native and the WebView, in this case,
41
+ // we use it for notifying resize changes.
42
+ window.ReactNativeWebView.postMessage(
43
+ JSON.stringify( {
44
+ action: 'resize',
41
45
  width: clientBoundingRect.width,
42
46
  height: clientBoundingRect.height,
43
- }));
44
- }
47
+ } )
48
+ );
49
+ }
45
50
 
46
- observer = new MutationObserver( sendResize );
47
- observer.observe( document.body, {
48
- attributes: true,
49
- attributeOldValue: false,
50
- characterData: true,
51
- characterDataOldValue: false,
52
- childList: true,
53
- subtree: true
54
- } );
55
-
56
- window.addEventListener( 'load', sendResize, true );
57
-
58
- // Hack: Remove viewport unit styles, as these are relative
59
- // the iframe root and interfere with our mechanism for
60
- // determining the unconstrained page bounds.
61
- function removeViewportStyles( ruleOrNode ) {
62
- if( ruleOrNode.style ) {
63
- [ 'width', 'height', 'minHeight', 'maxHeight' ].forEach( function( style ) {
64
- if ( /^\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] ) ) {
65
- ruleOrNode.style[ style ] = '';
66
- }
67
- } );
68
- }
51
+ const observer = new MutationObserver( sendResize );
52
+ observer.observe( document.body, {
53
+ attributes: true,
54
+ attributeOldValue: false,
55
+ characterData: true,
56
+ characterDataOldValue: false,
57
+ childList: true,
58
+ subtree: true,
59
+ } );
60
+
61
+ window.addEventListener( 'load', sendResize, true );
62
+
63
+ // Hack: Remove viewport unit styles, as these are relative
64
+ // the iframe root and interfere with our mechanism for
65
+ // determining the unconstrained page bounds.
66
+ function removeViewportStyles( ruleOrNode ) {
67
+ if ( ruleOrNode.style ) {
68
+ [ 'width', 'height', 'minHeight', 'maxHeight' ].forEach( function (
69
+ style
70
+ ) {
71
+ if (
72
+ /^\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )
73
+ ) {
74
+ ruleOrNode.style[ style ] = '';
75
+ }
76
+ } );
69
77
  }
78
+ }
70
79
 
71
- Array.prototype.forEach.call( document.querySelectorAll( '[style]' ), removeViewportStyles );
72
- Array.prototype.forEach.call( document.styleSheets, function( stylesheet ) {
73
- Array.prototype.forEach.call( stylesheet.cssRules || stylesheet.rules, removeViewportStyles );
74
- } );
80
+ Array.prototype.forEach.call(
81
+ document.querySelectorAll( '[style]' ),
82
+ removeViewportStyles
83
+ );
84
+ Array.prototype.forEach.call(
85
+ document.styleSheets,
86
+ function ( stylesheet ) {
87
+ Array.prototype.forEach.call(
88
+ stylesheet.cssRules || stylesheet.rules,
89
+ removeViewportStyles
90
+ );
91
+ }
92
+ );
75
93
 
76
- document.body.style.position = 'absolute';
77
- document.body.style.width = '100%';
78
- document.body.setAttribute( 'data-resizable-iframe-connected', '' );
94
+ document.body.style.position = 'absolute';
95
+ document.body.style.width = '100%';
96
+ document.body.setAttribute( 'data-resizable-iframe-connected', '' );
79
97
 
80
- sendResize();
98
+ sendResize();
81
99
 
82
- // Resize events can change the width of elements with 100% width, but we don't
83
- // get an DOM mutations for that, so do the resize when the window is resized, too.
84
- window.addEventListener( 'resize', sendResize, true );
85
- } )();`;
100
+ // Resize events can change the width of elements with 100% width, but we don't
101
+ // get an DOM mutations for that, so do the resize when the window is resized, too.
102
+ window.addEventListener( 'resize', sendResize, true );
103
+ };
86
104
 
87
105
  const style = `
88
106
  body {
@@ -215,7 +233,9 @@ function Sandbox( {
215
233
  <script
216
234
  type="text/javascript"
217
235
  dangerouslySetInnerHTML={ {
218
- __html: customJS || observeAndResizeJS,
236
+ __html:
237
+ customJS ||
238
+ `(${ observeAndResizeJS.toString() })();`,
219
239
  } }
220
240
  />
221
241
  { scripts.map( ( src ) => (
@@ -282,6 +302,9 @@ function Sandbox( {
282
302
 
283
303
  useEffect( () => {
284
304
  updateContentHtml();
305
+ // Disable reason: deferring this refactor to the native team.
306
+ // see https://github.com/WordPress/gutenberg/pull/41166
307
+ // eslint-disable-next-line react-hooks/exhaustive-deps
285
308
  }, [ html, title, type, styles, scripts ] );
286
309
 
287
310
  useEffect( () => {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { act, fireEvent, render } from '@testing-library/react';
4
+ import { fireEvent, render, screen } from '@testing-library/react';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -39,28 +39,25 @@ describe( 'Sandbox', () => {
39
39
  };
40
40
 
41
41
  it( 'should rerender with new emdeded content if html prop changes', () => {
42
- let result;
43
- act( () => {
44
- result = render( <TestWrapper /> );
45
- } );
42
+ const result = render( <TestWrapper /> );
46
43
 
47
44
  const iframe = result.container.querySelector( '.components-sandbox' );
48
45
 
49
46
  let sandboxedIframe =
50
47
  iframe.contentWindow.document.body.querySelector( '.mock-iframe' );
51
48
 
52
- expect( sandboxedIframe.getAttribute( 'src' ) ).toBe(
49
+ expect( sandboxedIframe ).toHaveAttribute(
50
+ 'src',
53
51
  'https://super.embed'
54
52
  );
55
53
 
56
- act( () => {
57
- fireEvent.click( result.getByRole( 'button' ) );
58
- } );
54
+ fireEvent.click( screen.getByRole( 'button' ) );
59
55
 
60
56
  sandboxedIframe =
61
57
  iframe.contentWindow.document.body.querySelector( '.mock-iframe' );
62
58
 
63
- expect( sandboxedIframe.getAttribute( 'src' ) ).toBe(
59
+ expect( sandboxedIframe ).toHaveAttribute(
60
+ 'src',
64
61
  'https://another.super.embed'
65
62
  );
66
63
  } );