@wordpress/components 37.0.0 → 38.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 (483) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +46 -0
  3. package/build/autocomplete/index.cjs +3 -1
  4. package/build/autocomplete/index.cjs.map +2 -2
  5. package/build/color-picker/component.cjs +14 -5
  6. package/build/color-picker/component.cjs.map +2 -2
  7. package/build/color-picker/picker.cjs +95 -23
  8. package/build/color-picker/picker.cjs.map +2 -2
  9. package/build/confirm-dialog/component.cjs +86 -4
  10. package/build/confirm-dialog/component.cjs.map +3 -3
  11. package/build/content-editable-control/index.cjs +19 -9
  12. package/build/content-editable-control/index.cjs.map +3 -3
  13. package/build/custom-select-control/index.cjs +1 -2
  14. package/build/custom-select-control/index.cjs.map +2 -2
  15. package/build/disabled/index.cjs +87 -4
  16. package/build/disabled/index.cjs.map +4 -4
  17. package/build/form-token-field/index.cjs +87 -2
  18. package/build/form-token-field/index.cjs.map +3 -3
  19. package/build/gradient-picker/index.cjs +26 -20
  20. package/build/gradient-picker/index.cjs.map +2 -2
  21. package/build/input-control/index.cjs +0 -1
  22. package/build/input-control/index.cjs.map +2 -2
  23. package/build/input-control/styles/input-control-styles.cjs +23 -31
  24. package/build/input-control/styles/input-control-styles.cjs.map +2 -2
  25. package/build/private-apis.cjs +0 -2
  26. package/build/private-apis.cjs.map +3 -3
  27. package/build/range-control/index.cjs +0 -1
  28. package/build/range-control/index.cjs.map +2 -2
  29. package/build/sandbox/index.cjs +23 -4
  30. package/build/sandbox/index.cjs.map +3 -3
  31. package/build/search-control/index.cjs +93 -10
  32. package/build/search-control/index.cjs.map +4 -4
  33. package/build/select-control/index.cjs +0 -1
  34. package/build/select-control/index.cjs.map +2 -2
  35. package/build/select-control/styles/select-control-styles.cjs +9 -16
  36. package/build/select-control/styles/select-control-styles.cjs.map +2 -2
  37. package/build/slot-fill/fill.cjs.map +2 -2
  38. package/build/toggle-group-control/toggle-group-control/component.cjs +91 -8
  39. package/build/toggle-group-control/toggle-group-control/component.cjs.map +4 -4
  40. package/build/toggle-group-control/toggle-group-control-option-base/component.cjs +98 -17
  41. package/build/toggle-group-control/toggle-group-control-option-base/component.cjs.map +4 -4
  42. package/build/tools-panel/tools-panel/component.cjs +6 -0
  43. package/build/tools-panel/tools-panel/component.cjs.map +2 -2
  44. package/build/tools-panel/tools-panel/hook.cjs +87 -11
  45. package/build/tools-panel/tools-panel/hook.cjs.map +4 -4
  46. package/build/tools-panel/tools-panel-header/component.cjs +87 -2
  47. package/build/tools-panel/tools-panel-header/component.cjs.map +3 -3
  48. package/build/tools-panel/tools-panel-header/hook.cjs +90 -20
  49. package/build/tools-panel/tools-panel-header/hook.cjs.map +4 -4
  50. package/build/tools-panel/tools-panel-item/hook.cjs +88 -9
  51. package/build/tools-panel/tools-panel-item/hook.cjs.map +4 -4
  52. package/build/validated-form-controls/control-with-error.cjs +3 -0
  53. package/build/validated-form-controls/control-with-error.cjs.map +2 -2
  54. package/build-module/autocomplete/index.mjs +3 -1
  55. package/build-module/autocomplete/index.mjs.map +2 -2
  56. package/build-module/color-picker/component.mjs +14 -5
  57. package/build-module/color-picker/component.mjs.map +2 -2
  58. package/build-module/color-picker/picker.mjs +96 -24
  59. package/build-module/color-picker/picker.mjs.map +2 -2
  60. package/build-module/confirm-dialog/component.mjs +86 -4
  61. package/build-module/confirm-dialog/component.mjs.map +3 -3
  62. package/build-module/content-editable-control/index.mjs +21 -11
  63. package/build-module/content-editable-control/index.mjs.map +2 -2
  64. package/build-module/custom-select-control/index.mjs +1 -2
  65. package/build-module/custom-select-control/index.mjs.map +2 -2
  66. package/build-module/disabled/index.mjs +87 -4
  67. package/build-module/disabled/index.mjs.map +3 -3
  68. package/build-module/form-token-field/index.mjs +88 -3
  69. package/build-module/form-token-field/index.mjs.map +3 -3
  70. package/build-module/gradient-picker/index.mjs +26 -20
  71. package/build-module/gradient-picker/index.mjs.map +2 -2
  72. package/build-module/input-control/index.mjs +0 -1
  73. package/build-module/input-control/index.mjs.map +2 -2
  74. package/build-module/input-control/styles/input-control-styles.mjs +23 -31
  75. package/build-module/input-control/styles/input-control-styles.mjs.map +2 -2
  76. package/build-module/private-apis.mjs +0 -2
  77. package/build-module/private-apis.mjs.map +2 -2
  78. package/build-module/range-control/index.mjs +0 -1
  79. package/build-module/range-control/index.mjs.map +2 -2
  80. package/build-module/sandbox/index.mjs +13 -4
  81. package/build-module/sandbox/index.mjs.map +2 -2
  82. package/build-module/search-control/index.mjs +93 -10
  83. package/build-module/search-control/index.mjs.map +3 -3
  84. package/build-module/select-control/index.mjs +0 -1
  85. package/build-module/select-control/index.mjs.map +2 -2
  86. package/build-module/select-control/styles/select-control-styles.mjs +9 -16
  87. package/build-module/select-control/styles/select-control-styles.mjs.map +2 -2
  88. package/build-module/slot-fill/fill.mjs.map +2 -2
  89. package/build-module/toggle-group-control/toggle-group-control/component.mjs +92 -9
  90. package/build-module/toggle-group-control/toggle-group-control/component.mjs.map +3 -3
  91. package/build-module/toggle-group-control/toggle-group-control-option-base/component.mjs +99 -18
  92. package/build-module/toggle-group-control/toggle-group-control-option-base/component.mjs.map +3 -3
  93. package/build-module/tools-panel/tools-panel/component.mjs +6 -0
  94. package/build-module/tools-panel/tools-panel/component.mjs.map +2 -2
  95. package/build-module/tools-panel/tools-panel/hook.mjs +87 -11
  96. package/build-module/tools-panel/tools-panel/hook.mjs.map +3 -3
  97. package/build-module/tools-panel/tools-panel-header/component.mjs +87 -2
  98. package/build-module/tools-panel/tools-panel-header/component.mjs.map +3 -3
  99. package/build-module/tools-panel/tools-panel-header/hook.mjs +90 -20
  100. package/build-module/tools-panel/tools-panel-header/hook.mjs.map +3 -3
  101. package/build-module/tools-panel/tools-panel-item/hook.mjs +89 -10
  102. package/build-module/tools-panel/tools-panel-item/hook.mjs.map +3 -3
  103. package/build-module/validated-form-controls/control-with-error.mjs +3 -0
  104. package/build-module/validated-form-controls/control-with-error.mjs.map +2 -2
  105. package/build-style/style-rtl.css +20 -24
  106. package/build-style/style.css +20 -24
  107. package/build-types/autocomplete/index.d.ts +7 -3
  108. package/build-types/autocomplete/index.d.ts.map +1 -1
  109. package/build-types/border-box-control/border-box-control/component.d.ts +1 -3
  110. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  111. package/build-types/border-box-control/stories/index.story.d.ts +1 -3
  112. package/build-types/border-box-control/stories/index.story.d.ts.map +1 -1
  113. package/build-types/border-box-control/types.d.ts +1 -15
  114. package/build-types/border-box-control/types.d.ts.map +1 -1
  115. package/build-types/box-control/input-control.d.ts +3 -0
  116. package/build-types/box-control/input-control.d.ts.map +1 -0
  117. package/build-types/box-control/styles/box-control-styles.d.ts +4 -8
  118. package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
  119. package/build-types/box-control/types.d.ts +1 -8
  120. package/build-types/box-control/types.d.ts.map +1 -1
  121. package/build-types/card/context.d.ts +3 -0
  122. package/build-types/card/context.d.ts.map +1 -0
  123. package/build-types/color-picker/component.d.ts.map +1 -1
  124. package/build-types/color-picker/picker.d.ts +17 -1
  125. package/build-types/color-picker/picker.d.ts.map +1 -1
  126. package/build-types/color-picker/styles.d.ts +4 -8
  127. package/build-types/color-picker/styles.d.ts.map +1 -1
  128. package/build-types/color-picker/types.d.ts +2 -0
  129. package/build-types/color-picker/types.d.ts.map +1 -1
  130. package/build-types/confirm-dialog/component.d.ts.map +1 -1
  131. package/build-types/content-editable-control/index.d.ts.map +1 -1
  132. package/build-types/context/wordpress-component.d.ts +2 -1
  133. package/build-types/context/wordpress-component.d.ts.map +1 -1
  134. package/build-types/custom-select-control/index.d.ts.map +1 -1
  135. package/build-types/custom-select-control/types.d.ts +1 -8
  136. package/build-types/custom-select-control/types.d.ts.map +1 -1
  137. package/build-types/date-time/date/index.d.ts +23 -0
  138. package/build-types/date-time/date/index.d.ts.map +1 -0
  139. package/build-types/date-time/date/styles.d.ts +45 -0
  140. package/build-types/date-time/date/styles.d.ts.map +1 -0
  141. package/build-types/date-time/date/test/index.d.ts +2 -0
  142. package/build-types/date-time/date/test/index.d.ts.map +1 -0
  143. package/build-types/date-time/date/test/use-lilius.d.ts +2 -0
  144. package/build-types/date-time/date/test/use-lilius.d.ts.map +1 -0
  145. package/build-types/date-time/date/use-lilius/index.d.ts +169 -0
  146. package/build-types/date-time/date/use-lilius/index.d.ts.map +1 -0
  147. package/build-types/date-time/time/index.d.ts +27 -0
  148. package/build-types/date-time/time/index.d.ts.map +1 -0
  149. package/build-types/date-time/time/styles.d.ts +93 -0
  150. package/build-types/date-time/time/styles.d.ts.map +1 -0
  151. package/build-types/date-time/time/test/index.d.ts +2 -0
  152. package/build-types/date-time/time/test/index.d.ts.map +1 -0
  153. package/build-types/date-time/time/time-input/index.d.ts +4 -0
  154. package/build-types/date-time/time/time-input/index.d.ts.map +1 -0
  155. package/build-types/date-time/time/time-input/test/index.d.ts +2 -0
  156. package/build-types/date-time/time/time-input/test/index.d.ts.map +1 -0
  157. package/build-types/date-time/time/timezone.d.ts +7 -0
  158. package/build-types/date-time/time/timezone.d.ts.map +1 -0
  159. package/build-types/date-time/time-picker/styles.d.ts +8 -16
  160. package/build-types/date-time/time-picker/styles.d.ts.map +1 -1
  161. package/build-types/disabled/index.d.ts.map +1 -1
  162. package/build-types/divider/styles.d.ts +10 -0
  163. package/build-types/divider/styles.d.ts.map +1 -0
  164. package/build-types/flex/styles.d.ts +17 -0
  165. package/build-types/flex/styles.d.ts.map +1 -0
  166. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +2 -4
  167. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts.map +1 -1
  168. package/build-types/font-size-picker/index.d.ts +12 -2
  169. package/build-types/font-size-picker/index.d.ts.map +1 -1
  170. package/build-types/font-size-picker/stories/e2e/index.story.d.ts +12 -1
  171. package/build-types/font-size-picker/stories/e2e/index.story.d.ts.map +1 -1
  172. package/build-types/font-size-picker/types.d.ts +2 -15
  173. package/build-types/font-size-picker/types.d.ts.map +1 -1
  174. package/build-types/form-token-field/index.d.ts.map +1 -1
  175. package/build-types/gradient-picker/index.d.ts.map +1 -1
  176. package/build-types/gradient-picker/stories/index.story.d.ts +1 -0
  177. package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
  178. package/build-types/gradient-picker/test/index.d.ts +2 -0
  179. package/build-types/gradient-picker/test/index.d.ts.map +1 -0
  180. package/build-types/gradient-picker/types.d.ts +19 -4
  181. package/build-types/gradient-picker/types.d.ts.map +1 -1
  182. package/build-types/input-control/index.d.ts.map +1 -1
  183. package/build-types/input-control/styles/input-control-styles.d.ts +0 -6
  184. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  185. package/build-types/input-control/types.d.ts +1 -8
  186. package/build-types/input-control/types.d.ts.map +1 -1
  187. package/build-types/mobile/image/constants.d.ts +5 -0
  188. package/build-types/mobile/image/constants.d.ts.map +1 -0
  189. package/build-types/navigation/back-button/index.d.ts +7 -0
  190. package/build-types/navigation/back-button/index.d.ts.map +1 -0
  191. package/build-types/navigation/constants.d.ts +3 -0
  192. package/build-types/navigation/constants.d.ts.map +1 -0
  193. package/build-types/navigation/context.d.ts +4 -0
  194. package/build-types/navigation/context.d.ts.map +1 -0
  195. package/build-types/navigation/group/context.d.ts +7 -0
  196. package/build-types/navigation/group/context.d.ts.map +1 -0
  197. package/build-types/navigation/group/index.d.ts +7 -0
  198. package/build-types/navigation/group/index.d.ts.map +1 -0
  199. package/build-types/navigation/index.d.ts +46 -0
  200. package/build-types/navigation/index.d.ts.map +1 -0
  201. package/build-types/navigation/item/base-content.d.ts +3 -0
  202. package/build-types/navigation/item/base-content.d.ts.map +1 -0
  203. package/build-types/navigation/item/base.d.ts +3 -0
  204. package/build-types/navigation/item/base.d.ts.map +1 -0
  205. package/build-types/navigation/item/index.d.ts +7 -0
  206. package/build-types/navigation/item/index.d.ts.map +1 -0
  207. package/build-types/navigation/item/use-navigation-tree-item.d.ts +3 -0
  208. package/build-types/navigation/item/use-navigation-tree-item.d.ts.map +1 -0
  209. package/build-types/navigation/menu/context.d.ts +7 -0
  210. package/build-types/navigation/menu/context.d.ts.map +1 -0
  211. package/build-types/navigation/menu/index.d.ts +7 -0
  212. package/build-types/navigation/menu/index.d.ts.map +1 -0
  213. package/build-types/navigation/menu/menu-title-search.d.ts +3 -0
  214. package/build-types/navigation/menu/menu-title-search.d.ts.map +1 -0
  215. package/build-types/navigation/menu/menu-title.d.ts +3 -0
  216. package/build-types/navigation/menu/menu-title.d.ts.map +1 -0
  217. package/build-types/navigation/menu/search-no-results-found.d.ts +3 -0
  218. package/build-types/navigation/menu/search-no-results-found.d.ts.map +1 -0
  219. package/build-types/navigation/menu/use-navigation-tree-menu.d.ts +3 -0
  220. package/build-types/navigation/menu/use-navigation-tree-menu.d.ts.map +1 -0
  221. package/build-types/navigation/stories/index.story.d.ts +23 -0
  222. package/build-types/navigation/stories/index.story.d.ts.map +1 -0
  223. package/build-types/navigation/stories/utils/controlled-state.d.ts +7 -0
  224. package/build-types/navigation/stories/utils/controlled-state.d.ts.map +1 -0
  225. package/build-types/navigation/stories/utils/default.d.ts +10 -0
  226. package/build-types/navigation/stories/utils/default.d.ts.map +1 -0
  227. package/build-types/navigation/stories/utils/group.d.ts +10 -0
  228. package/build-types/navigation/stories/utils/group.d.ts.map +1 -0
  229. package/build-types/navigation/stories/utils/hide-if-empty.d.ts +10 -0
  230. package/build-types/navigation/stories/utils/hide-if-empty.d.ts.map +1 -0
  231. package/build-types/navigation/stories/utils/more-examples.d.ts +10 -0
  232. package/build-types/navigation/stories/utils/more-examples.d.ts.map +1 -0
  233. package/build-types/navigation/stories/utils/search.d.ts +10 -0
  234. package/build-types/navigation/stories/utils/search.d.ts.map +1 -0
  235. package/build-types/navigation/styles/navigation-styles.d.ts +55 -0
  236. package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -0
  237. package/build-types/navigation/test/index.d.ts +2 -0
  238. package/build-types/navigation/test/index.d.ts.map +1 -0
  239. package/build-types/navigation/types.d.ts +266 -0
  240. package/build-types/navigation/types.d.ts.map +1 -0
  241. package/build-types/navigation/use-create-navigation-tree.d.ts +15 -0
  242. package/build-types/navigation/use-create-navigation-tree.d.ts.map +1 -0
  243. package/build-types/navigation/use-navigation-tree-nodes.d.ts +10 -0
  244. package/build-types/navigation/use-navigation-tree-nodes.d.ts.map +1 -0
  245. package/build-types/navigation/utils.d.ts +3 -0
  246. package/build-types/navigation/utils.d.ts.map +1 -0
  247. package/build-types/number-control/index.d.ts +2 -4
  248. package/build-types/number-control/index.d.ts.map +1 -1
  249. package/build-types/number-control/stories/index.story.d.ts +2 -4
  250. package/build-types/number-control/stories/index.story.d.ts.map +1 -1
  251. package/build-types/number-control/types.d.ts +1 -15
  252. package/build-types/number-control/types.d.ts.map +1 -1
  253. package/build-types/private-apis.d.ts.map +1 -1
  254. package/build-types/range-control/index.d.ts +2 -4
  255. package/build-types/range-control/index.d.ts.map +1 -1
  256. package/build-types/range-control/styles/range-control-styles.d.ts +2 -4
  257. package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
  258. package/build-types/range-control/types.d.ts +2 -16
  259. package/build-types/range-control/types.d.ts.map +1 -1
  260. package/build-types/sandbox/index.d.ts.map +1 -1
  261. package/build-types/sandbox/types.d.ts +11 -0
  262. package/build-types/sandbox/types.d.ts.map +1 -1
  263. package/build-types/search-control/index.d.ts.map +1 -1
  264. package/build-types/search-control/types.d.ts +1 -1
  265. package/build-types/search-control/types.d.ts.map +1 -1
  266. package/build-types/select-control/index.d.ts.map +1 -1
  267. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  268. package/build-types/select-control/types.d.ts +0 -7
  269. package/build-types/select-control/types.d.ts.map +1 -1
  270. package/build-types/slot-fill/fill.d.ts.map +1 -1
  271. package/build-types/slot-fill/stories/index.story.d.ts +1 -6
  272. package/build-types/slot-fill/stories/index.story.d.ts.map +1 -1
  273. package/build-types/surface/styles.d.ts +11 -0
  274. package/build-types/surface/styles.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/toggle-group-control/toggle-group-control/component.d.ts +0 -1
  278. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  279. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  280. package/build-types/toggle-group-control/types.d.ts +0 -7
  281. package/build-types/toggle-group-control/types.d.ts.map +1 -1
  282. package/build-types/tools-panel/tools-panel/component.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-header/component.d.ts.map +1 -1
  285. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  286. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  287. package/build-types/tree-select/types.d.ts +1 -8
  288. package/build-types/tree-select/types.d.ts.map +1 -1
  289. package/build-types/truncate/styles.d.ts +2 -0
  290. package/build-types/truncate/styles.d.ts.map +1 -0
  291. package/build-types/unit-control/index.d.ts +2 -4
  292. package/build-types/unit-control/index.d.ts.map +1 -1
  293. package/build-types/unit-control/styles/unit-control-styles.d.ts +2 -4
  294. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  295. package/build-types/unit-control/types.d.ts +1 -15
  296. package/build-types/unit-control/types.d.ts.map +1 -1
  297. package/build-types/utils/deprecated-36px-size.d.ts +7 -0
  298. package/build-types/utils/deprecated-36px-size.d.ts.map +1 -0
  299. package/build-types/validated-form-controls/components/number-control.d.ts +2 -4
  300. package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
  301. package/build-types/validated-form-controls/components/range-control.d.ts +2 -4
  302. package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
  303. package/build-types/validated-form-controls/components/stories/overview.story.d.ts +5 -0
  304. package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -1
  305. package/build-types/validated-form-controls/components/toggle-group-control.d.ts +1 -2
  306. package/build-types/validated-form-controls/components/toggle-group-control.d.ts.map +1 -1
  307. package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
  308. package/build-types/visually-hidden/test/index.d.ts +2 -0
  309. package/build-types/visually-hidden/test/index.d.ts.map +1 -0
  310. package/package.json +27 -27
  311. package/src/autocomplete/index.tsx +16 -3
  312. package/src/base-control/README.md +2 -2
  313. package/src/border-box-control/types.ts +4 -15
  314. package/src/box-control/types.ts +4 -8
  315. package/src/card/test/__snapshots__/index.tsx.snap +1 -1
  316. package/src/checkbox-control/test/__snapshots__/index.tsx.snap +1 -1
  317. package/src/color-indicator/test/__snapshots__/index.tsx.snap +1 -1
  318. package/src/color-picker/component.tsx +23 -19
  319. package/src/color-picker/picker.tsx +144 -21
  320. package/src/color-picker/test/index.tsx +502 -0
  321. package/src/color-picker/types.ts +2 -0
  322. package/src/combobox-control/style.scss +2 -2
  323. package/src/confirm-dialog/component.tsx +2 -4
  324. package/src/confirm-dialog/style.module.scss +7 -0
  325. package/src/confirm-dialog/test/index.tsx +5 -0
  326. package/src/content-editable-control/index.tsx +24 -5
  327. package/src/content-editable-control/style.module.scss +1 -1
  328. package/src/content-editable-control/test/index.tsx +20 -8
  329. package/src/context/test/__snapshots__/context-system-provider.js.snap +1 -1
  330. package/src/context/wordpress-component.ts +7 -2
  331. package/src/custom-gradient-picker/test/index.tsx +111 -1
  332. package/src/custom-select-control/index.tsx +1 -2
  333. package/src/custom-select-control/test/__snapshots__/index.tsx.snap +6 -0
  334. package/src/custom-select-control/test/index.tsx +23 -0
  335. package/src/custom-select-control/types.ts +1 -8
  336. package/src/disabled/index.tsx +7 -5
  337. package/src/disabled/style.module.scss +15 -0
  338. package/src/disabled/test/index.tsx +6 -4
  339. package/src/elevation/test/__snapshots__/index.tsx.snap +1 -1
  340. package/src/external-link/style.scss +6 -12
  341. package/src/flex/test/__snapshots__/index.tsx.snap +1 -1
  342. package/src/font-size-picker/types.ts +6 -15
  343. package/src/form-toggle/test/__snapshots__/index.tsx.snap +1 -1
  344. package/src/form-token-field/index.tsx +5 -4
  345. package/src/form-token-field/style.module.scss +6 -0
  346. package/src/form-token-field/style.scss +2 -2
  347. package/src/gradient-picker/README.md +21 -3
  348. package/src/gradient-picker/index.tsx +43 -28
  349. package/src/gradient-picker/stories/index.story.tsx +41 -5
  350. package/src/gradient-picker/test/index.tsx +148 -0
  351. package/src/gradient-picker/types.ts +24 -4
  352. package/src/h-stack/test/__snapshots__/index.tsx.snap +1 -1
  353. package/src/heading/test/__snapshots__/index.tsx.snap +1 -1
  354. package/src/higher-order/with-filters/test/__snapshots__/index.tsx.snap +1 -1
  355. package/src/input-control/index.tsx +0 -1
  356. package/src/input-control/styles/input-control-styles.tsx +0 -8
  357. package/src/input-control/test/__snapshots__/index.js.snap +11 -0
  358. package/src/input-control/test/index.js +28 -0
  359. package/src/input-control/types.ts +1 -8
  360. package/src/item-group/test/__snapshots__/index.js.snap +1 -1
  361. package/src/menu/README.md +2 -2
  362. package/src/menu-item/test/__snapshots__/index.js.snap +1 -1
  363. package/src/modal/test/index.tsx +42 -0
  364. package/src/notice/test/__snapshots__/index.tsx.snap +1 -1
  365. package/src/number-control/types.ts +1 -22
  366. package/src/panel/test/__snapshots__/body.tsx.snap +1 -1
  367. package/src/panel/test/__snapshots__/header.tsx.snap +1 -1
  368. package/src/panel/test/__snapshots__/index.tsx.snap +1 -1
  369. package/src/panel/test/__snapshots__/row.tsx.snap +1 -1
  370. package/src/private-apis.ts +0 -2
  371. package/src/range-control/index.tsx +0 -1
  372. package/src/range-control/types.ts +2 -15
  373. package/src/sandbox/index.tsx +22 -2
  374. package/src/sandbox/test/index.tsx +21 -0
  375. package/src/sandbox/types.ts +11 -0
  376. package/src/scrollable/test/__snapshots__/index.tsx.snap +1 -1
  377. package/src/search-control/index.tsx +23 -20
  378. package/src/search-control/style.module.scss +16 -0
  379. package/src/search-control/test/index.tsx +8 -0
  380. package/src/search-control/types.ts +1 -1
  381. package/src/select-control/index.tsx +0 -1
  382. package/src/select-control/styles/select-control-styles.ts +0 -7
  383. package/src/select-control/test/__snapshots__/select-control.tsx.snap +11 -0
  384. package/src/select-control/test/select-control.tsx +37 -0
  385. package/src/select-control/types.ts +0 -7
  386. package/src/shortcut/test/__snapshots__/index.tsx.snap +1 -1
  387. package/src/slot-fill/fill.tsx +3 -9
  388. package/src/slot-fill/stories/index.story.tsx +52 -10
  389. package/src/slot-fill/test/__snapshots__/slot.js.snap +1 -1
  390. package/src/slot-fill/test/slot.js +53 -11
  391. package/src/spacer/test/__snapshots__/index.tsx.snap +1 -1
  392. package/src/text/test/__snapshots__/index.tsx.snap +1 -1
  393. package/src/text-control/style.scss +1 -1
  394. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +29 -707
  395. package/src/toggle-group-control/test/index.tsx +33 -3
  396. package/src/toggle-group-control/toggle-group-control/component.tsx +11 -16
  397. package/src/toggle-group-control/toggle-group-control/style.module.scss +63 -0
  398. package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +22 -24
  399. package/src/toggle-group-control/toggle-group-control-option-base/style.module.scss +88 -0
  400. package/src/toggle-group-control/types.ts +0 -7
  401. package/src/tools-panel/style.module.scss +117 -0
  402. package/src/tools-panel/test/index.tsx +105 -39
  403. package/src/tools-panel/tools-panel/component.tsx +12 -1
  404. package/src/tools-panel/tools-panel/hook.ts +13 -15
  405. package/src/tools-panel/tools-panel-header/component.tsx +6 -2
  406. package/src/tools-panel/tools-panel-header/hook.ts +7 -25
  407. package/src/tools-panel/tools-panel-item/hook.ts +16 -34
  408. package/src/tooltip/test/index.tsx +1 -1
  409. package/src/tree-grid/test/__snapshots__/cell.tsx.snap +1 -1
  410. package/src/tree-grid/test/__snapshots__/index.tsx.snap +1 -1
  411. package/src/tree-grid/test/__snapshots__/roving-tab-index-item.tsx.snap +1 -1
  412. package/src/tree-grid/test/__snapshots__/roving-tab-index.tsx.snap +1 -1
  413. package/src/tree-grid/test/__snapshots__/row.tsx.snap +1 -1
  414. package/src/tree-select/README.md +1 -1
  415. package/src/tree-select/types.ts +1 -8
  416. package/src/unit-control/types.ts +1 -18
  417. package/src/utils/theme-variables.scss +1 -0
  418. package/src/v-stack/test/__snapshots__/index.tsx.snap +1 -1
  419. package/src/validated-form-controls/components/stories/overview.story.tsx +51 -0
  420. package/src/validated-form-controls/control-with-error.tsx +9 -0
  421. package/src/validated-form-controls/style.scss +3 -3
  422. package/src/validated-form-controls/test/control-with-error.tsx +42 -0
  423. package/src/view/test/__snapshots__/index.js.snap +1 -1
  424. package/build/confirm-dialog/styles.cjs +0 -42
  425. package/build/confirm-dialog/styles.cjs.map +0 -7
  426. package/build/disabled/styles/disabled-styles.cjs +0 -42
  427. package/build/disabled/styles/disabled-styles.cjs.map +0 -7
  428. package/build/form-token-field/styles.cjs +0 -49
  429. package/build/form-token-field/styles.cjs.map +0 -7
  430. package/build/search-control/styles.cjs +0 -74
  431. package/build/search-control/styles.cjs.map +0 -7
  432. package/build/theme/color-algorithms.cjs +0 -131
  433. package/build/theme/color-algorithms.cjs.map +0 -7
  434. package/build/theme/index.cjs +0 -160
  435. package/build/theme/index.cjs.map +0 -7
  436. package/build/theme/types.cjs +0 -19
  437. package/build/theme/types.cjs.map +0 -7
  438. package/build/toggle-group-control/toggle-group-control/styles.cjs +0 -53
  439. package/build/toggle-group-control/toggle-group-control/styles.cjs.map +0 -7
  440. package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs +0 -94
  441. package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs.map +0 -7
  442. package/build/tools-panel/styles.cjs +0 -129
  443. package/build/tools-panel/styles.cjs.map +0 -7
  444. package/build/utils/use-deprecated-props.cjs +0 -41
  445. package/build/utils/use-deprecated-props.cjs.map +0 -7
  446. package/build-module/confirm-dialog/styles.mjs +0 -17
  447. package/build-module/confirm-dialog/styles.mjs.map +0 -7
  448. package/build-module/disabled/styles/disabled-styles.mjs +0 -17
  449. package/build-module/disabled/styles/disabled-styles.mjs.map +0 -7
  450. package/build-module/form-token-field/styles.mjs +0 -14
  451. package/build-module/form-token-field/styles.mjs.map +0 -7
  452. package/build-module/search-control/styles.mjs +0 -38
  453. package/build-module/search-control/styles.mjs.map +0 -7
  454. package/build-module/theme/color-algorithms.mjs +0 -94
  455. package/build-module/theme/color-algorithms.mjs.map +0 -7
  456. package/build-module/theme/index.mjs +0 -129
  457. package/build-module/theme/index.mjs.map +0 -7
  458. package/build-module/theme/types.mjs +0 -1
  459. package/build-module/theme/types.mjs.map +0 -7
  460. package/build-module/toggle-group-control/toggle-group-control/styles.mjs +0 -27
  461. package/build-module/toggle-group-control/toggle-group-control/styles.mjs.map +0 -7
  462. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs +0 -56
  463. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs.map +0 -7
  464. package/build-module/tools-panel/styles.mjs +0 -84
  465. package/build-module/tools-panel/styles.mjs.map +0 -7
  466. package/build-module/utils/use-deprecated-props.mjs +0 -16
  467. package/build-module/utils/use-deprecated-props.mjs.map +0 -7
  468. package/src/confirm-dialog/styles.ts +0 -18
  469. package/src/disabled/styles/disabled-styles.tsx +0 -23
  470. package/src/form-token-field/styles.ts +0 -15
  471. package/src/search-control/styles.ts +0 -27
  472. package/src/theme/README.md +0 -47
  473. package/src/theme/color-algorithms.ts +0 -142
  474. package/src/theme/index.tsx +0 -80
  475. package/src/theme/stories/index.story.tsx +0 -127
  476. package/src/theme/style.module.scss +0 -4
  477. package/src/theme/test/color-algorithms.ts +0 -100
  478. package/src/theme/test/index.tsx +0 -151
  479. package/src/theme/types.ts +0 -61
  480. package/src/toggle-group-control/toggle-group-control/styles.ts +0 -84
  481. package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +0 -109
  482. package/src/tools-panel/styles.ts +0 -176
  483. package/src/utils/use-deprecated-props.ts +0 -14
@@ -3,7 +3,6 @@ import { useDrag } from "@use-gesture/react";
3
3
  import { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from "./popover/utils.mjs";
4
4
  import { Menu } from "./menu/index.mjs";
5
5
  import { ComponentsContext } from "./context/context-system-provider.mjs";
6
- import Theme from "./theme/index.mjs";
7
6
  import { Tabs } from "./tabs/index.mjs";
8
7
  import { kebabCase, normalizeTextString } from "./utils/strings.mjs";
9
8
  import { withIgnoreIMEEvents } from "./utils/with-ignore-ime-events.mjs";
@@ -19,7 +18,6 @@ lock(privateApis, {
19
18
  __experimentalPopoverLegacyPositionToPlacement,
20
19
  ComponentsContext,
21
20
  Tabs,
22
- Theme,
23
21
  Menu,
24
22
  kebabCase,
25
23
  withIgnoreIMEEvents,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/private-apis.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { useDrag } from '@use-gesture/react';\n\n/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport Theme from './theme';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport { ValidatedCheckboxControl, ValidatedComboboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedSelectControl, ValidatedRadioControl, ValidatedContentEditableControl, ValidatedTextControl, ValidatedTextareaControl, ValidatedToggleControl, ValidatedToggleGroupControl } from './validated-form-controls';\nimport { ValidatedFormTokenField } from './validated-form-controls/components/form-token-field';\nimport ContentEditableControl from './content-editable-control';\nexport const privateApis = {};\nlock(privateApis, {\n ContentEditableControl,\n __experimentalPopoverLegacyPositionToPlacement,\n ComponentsContext,\n Tabs,\n Theme,\n Menu,\n kebabCase,\n withIgnoreIMEEvents,\n Badge,\n normalizeTextString,\n DateCalendar,\n DateRangeCalendar,\n TZDate,\n useDrag,\n ValidatedInputControl,\n ValidatedCheckboxControl,\n ValidatedComboboxControl,\n ValidatedNumberControl,\n ValidatedSelectControl,\n ValidatedRadioControl,\n ValidatedContentEditableControl,\n ValidatedTextControl,\n ValidatedTextareaControl,\n ValidatedToggleControl,\n ValidatedToggleGroupControl,\n ValidatedFormTokenField\n});"],
5
- "mappings": ";AAGA,SAAS,eAAe;AAKxB,SAAS,uBAAuB,sDAAsD;AACtF,SAAS,YAAY;AACrB,SAAS,yBAAyB;AAClC,OAAO,WAAW;AAClB,SAAS,YAAY;AACrB,SAAS,WAAW,2BAA2B;AAC/C,SAAS,2BAA2B;AACpC,SAAS,YAAY;AACrB,OAAO,WAAW;AAClB,SAAS,cAAc,mBAAmB,cAAc;AACxD,SAAS,0BAA0B,0BAA0B,uBAAuB,wBAAwB,wBAAwB,uBAAuB,iCAAiC,sBAAsB,0BAA0B,wBAAwB,mCAAmC;AACvS,SAAS,+BAA+B;AACxC,OAAO,4BAA4B;AAC5B,IAAM,cAAc,CAAC;AAC5B,KAAK,aAAa;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { useDrag } from '@use-gesture/react';\n\n/**\n * Internal dependencies\n */\nimport { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';\nimport { Menu } from './menu';\nimport { ComponentsContext } from './context/context-system-provider';\nimport { Tabs } from './tabs';\nimport { kebabCase, normalizeTextString } from './utils/strings';\nimport { withIgnoreIMEEvents } from './utils/with-ignore-ime-events';\nimport { lock } from './lock-unlock';\nimport Badge from './badge';\nimport { DateCalendar, DateRangeCalendar, TZDate } from './calendar';\nimport { ValidatedCheckboxControl, ValidatedComboboxControl, ValidatedInputControl, ValidatedNumberControl, ValidatedSelectControl, ValidatedRadioControl, ValidatedContentEditableControl, ValidatedTextControl, ValidatedTextareaControl, ValidatedToggleControl, ValidatedToggleGroupControl } from './validated-form-controls';\nimport { ValidatedFormTokenField } from './validated-form-controls/components/form-token-field';\nimport ContentEditableControl from './content-editable-control';\nexport const privateApis = {};\nlock(privateApis, {\n ContentEditableControl,\n __experimentalPopoverLegacyPositionToPlacement,\n ComponentsContext,\n Tabs,\n Menu,\n kebabCase,\n withIgnoreIMEEvents,\n Badge,\n normalizeTextString,\n DateCalendar,\n DateRangeCalendar,\n TZDate,\n useDrag,\n ValidatedInputControl,\n ValidatedCheckboxControl,\n ValidatedComboboxControl,\n ValidatedNumberControl,\n ValidatedSelectControl,\n ValidatedRadioControl,\n ValidatedContentEditableControl,\n ValidatedTextControl,\n ValidatedTextareaControl,\n ValidatedToggleControl,\n ValidatedToggleGroupControl,\n ValidatedFormTokenField\n});"],
5
+ "mappings": ";AAGA,SAAS,eAAe;AAKxB,SAAS,uBAAuB,sDAAsD;AACtF,SAAS,YAAY;AACrB,SAAS,yBAAyB;AAClC,SAAS,YAAY;AACrB,SAAS,WAAW,2BAA2B;AAC/C,SAAS,2BAA2B;AACpC,SAAS,YAAY;AACrB,OAAO,WAAW;AAClB,SAAS,cAAc,mBAAmB,cAAc;AACxD,SAAS,0BAA0B,0BAA0B,uBAAuB,wBAAwB,wBAAwB,uBAAuB,iCAAiC,sBAAsB,0BAA0B,wBAAwB,mCAAmC;AACvS,SAAS,+BAA+B;AACxC,OAAO,4BAA4B;AAC5B,IAAM,cAAc,CAAC;AAC5B,KAAK,aAAa;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;",
6
6
  "names": []
7
7
  }
@@ -34,7 +34,6 @@ function UnforwardedRangeControl(props, forwardedRef) {
34
34
  // Prevent passing legacy props to internal component.
35
35
  __nextHasNoMarginBottom: _,
36
36
  __next40pxDefaultSize: _next40pxDefaultSize,
37
- __shouldNotWarnDeprecated36pxSize: _shouldNotWarnDeprecated36pxSize,
38
37
  afterIcon,
39
38
  allowReset = false,
40
39
  beforeIcon,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/range-control/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport { ActionRightWrapper, AfterIconWrapper, BeforeIconWrapper, InputNumber, Root, Track, ThumbWrapper, Thumb, Wrapper } from './styles/range-control-styles';\nimport { space } from '../utils/space';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Computes the value that `RangeControl` should reset to when pressing\n * the reset button.\n */\nfunction computeResetValue({\n resetFallbackValue,\n initialPosition\n}) {\n if (resetFallbackValue !== undefined) {\n return !Number.isNaN(resetFallbackValue) ? resetFallbackValue : null;\n }\n if (initialPosition !== undefined) {\n return !Number.isNaN(initialPosition) ? initialPosition : null;\n }\n return null;\n}\nfunction UnforwardedRangeControl(props, forwardedRef) {\n const {\n // Prevent passing legacy props to internal component.\n __nextHasNoMarginBottom: _,\n __next40pxDefaultSize: _next40pxDefaultSize,\n __shouldNotWarnDeprecated36pxSize: _shouldNotWarnDeprecated36pxSize,\n afterIcon,\n allowReset = false,\n beforeIcon,\n className,\n color: colorProp = COLORS.theme.accent,\n currentInput,\n disabled = false,\n help,\n hideLabelFromVision = false,\n initialPosition,\n isShiftStepEnabled = true,\n label,\n marks = false,\n max = 100,\n min = 0,\n onBlur = noop,\n onChange = noop,\n onFocus = noop,\n onMouseLeave = noop,\n onMouseMove = noop,\n railColor,\n renderTooltipContent = v => v,\n resetFallbackValue,\n shiftStep = 10,\n showTooltip: showTooltipProp,\n step = 1,\n trackColor,\n value: valueProp,\n withInputField = true,\n ...otherProps\n } = props;\n const [value, setValue] = useControlledRangeValue({\n min,\n max,\n value: valueProp ?? null,\n initial: initialPosition\n });\n const isResetPendent = useRef(false);\n let hasTooltip = showTooltipProp;\n let hasInputField = withInputField;\n if (step === 'any') {\n // The tooltip and number input field are hidden when the step is \"any\"\n // because the decimals get too lengthy to fit well.\n hasTooltip = false;\n hasInputField = false;\n }\n const [showTooltip, setShowTooltip] = useState(hasTooltip);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef(null);\n const isCurrentlyFocused = inputRef.current?.matches(':focus');\n const isThumbFocused = !disabled && isFocused;\n const isValueReset = value === null;\n const currentValue = value !== undefined ? value : currentInput;\n const inputSliderValue = isValueReset ? '' : currentValue;\n const rangeFillValue = isValueReset ? (max - min) / 2 + min : value;\n const fillValue = isValueReset ? 50 : (value - min) / (max - min) * 100;\n const fillValueOffset = `${clamp(fillValue, 0, 100)}%`;\n const classes = clsx('components-range-control', className);\n const wrapperClasses = clsx('components-range-control__wrapper', !!marks && 'is-marked');\n const id = useInstanceId(UnforwardedRangeControl, 'inspector-range-control');\n const describedBy = !!help ? `${id}__help` : undefined;\n const enableTooltip = hasTooltip !== false && Number.isFinite(value);\n const handleOnRangeChange = event => {\n const nextValue = parseFloat(event.target.value);\n setValue(nextValue);\n onChange(nextValue);\n };\n const handleOnChange = next => {\n // @ts-expect-error TODO: Investigate if it's problematic for setValue() to\n // potentially receive a NaN when next is undefined.\n let nextValue = parseFloat(next);\n setValue(nextValue);\n\n /*\n * Calls onChange only when nextValue is numeric\n * otherwise may queue a reset for the blur event.\n */\n if (!isNaN(nextValue)) {\n if (nextValue < min || nextValue > max) {\n nextValue = floatClamp(nextValue, min, max);\n }\n onChange(nextValue);\n isResetPendent.current = false;\n } else if (allowReset) {\n isResetPendent.current = true;\n }\n };\n const handleOnInputNumberBlur = () => {\n if (isResetPendent.current) {\n handleOnReset();\n isResetPendent.current = false;\n }\n };\n const handleOnReset = () => {\n // Reset to `resetFallbackValue` if defined, otherwise set internal value\n // to `null` — which, if propagated to the `value` prop, will cause\n // the value to be reset to the `initialPosition` prop if defined.\n const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue ?? null;\n setValue(resetValue);\n\n /**\n * Previously, this callback would always receive undefined as\n * an argument. This behavior is unexpected, specifically\n * when resetFallbackValue is defined.\n *\n * The value of undefined is not ideal. Passing it through\n * to internal <input /> elements would change it from a\n * controlled component to an uncontrolled component.\n *\n * For now, to minimize unexpected regressions, we're going to\n * preserve the undefined callback argument, except when a\n * resetFallbackValue is defined.\n */\n onChange(resetValue ?? undefined);\n };\n const handleShowTooltip = () => setShowTooltip(true);\n const handleHideTooltip = () => setShowTooltip(false);\n const handleOnBlur = event => {\n onBlur(event);\n setIsFocused(false);\n handleHideTooltip();\n };\n const handleOnFocus = event => {\n onFocus(event);\n setIsFocused(true);\n handleShowTooltip();\n };\n const offsetStyle = {\n [isRTL() ? 'right' : 'left']: fillValueOffset\n };\n return /*#__PURE__*/_jsx(BaseControl, {\n className: classes,\n label: label,\n hideLabelFromVision: hideLabelFromVision,\n id: `${id}`,\n help: help,\n children: /*#__PURE__*/_jsxs(Root, {\n className: \"components-range-control__root\",\n children: [beforeIcon && /*#__PURE__*/_jsx(BeforeIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: beforeIcon\n })\n }), /*#__PURE__*/_jsxs(Wrapper, {\n className: wrapperClasses,\n color: colorProp,\n marks: !!marks,\n children: [/*#__PURE__*/_jsx(InputRange, {\n ...otherProps,\n className: \"components-range-control__slider\",\n describedBy: describedBy,\n disabled: disabled,\n id: `${id}`,\n label: label,\n max: max,\n min: min,\n onBlur: handleOnBlur,\n onChange: handleOnRangeChange,\n onFocus: handleOnFocus,\n onMouseMove: onMouseMove,\n onMouseLeave: onMouseLeave,\n ref: useMergeRefs([inputRef, forwardedRef]),\n step: step,\n value: inputSliderValue ?? undefined\n }), /*#__PURE__*/_jsx(RangeRail, {\n \"aria-hidden\": true,\n disabled: disabled,\n marks: marks,\n max: max,\n min: min,\n railColor: railColor,\n step: step,\n value: rangeFillValue\n }), /*#__PURE__*/_jsx(Track, {\n \"aria-hidden\": true,\n className: \"components-range-control__track\",\n disabled: disabled,\n style: {\n width: fillValueOffset\n },\n trackColor: trackColor\n }), /*#__PURE__*/_jsx(ThumbWrapper, {\n className: \"components-range-control__thumb-wrapper\",\n style: offsetStyle,\n disabled: disabled,\n children: /*#__PURE__*/_jsx(Thumb, {\n \"aria-hidden\": true,\n isFocused: isThumbFocused,\n disabled: disabled\n })\n }), enableTooltip && /*#__PURE__*/_jsx(SimpleTooltip, {\n className: \"components-range-control__tooltip\",\n inputRef: inputRef,\n tooltipPlacement: \"bottom\",\n renderTooltipContent: renderTooltipContent,\n show: isCurrentlyFocused || showTooltip,\n style: offsetStyle,\n value: value\n })]\n }), afterIcon && /*#__PURE__*/_jsx(AfterIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: afterIcon\n })\n }), hasInputField && /*#__PURE__*/_jsx(InputNumber, {\n \"aria-label\": label,\n className: \"components-range-control__number\",\n disabled: disabled,\n inputMode: \"decimal\",\n isShiftStepEnabled: isShiftStepEnabled,\n max: max,\n min: min,\n onBlur: handleOnInputNumberBlur,\n onChange: handleOnChange,\n shiftStep: shiftStep,\n __unstableInputWidth: space(20),\n step: step\n // @ts-expect-error TODO: Investigate if the `null` value is necessary\n ,\n value: inputSliderValue\n }), allowReset && /*#__PURE__*/_jsx(ActionRightWrapper, {\n children: /*#__PURE__*/_jsx(Button, {\n className: \"components-range-control__reset\"\n // If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.\n ,\n accessibleWhenDisabled: !disabled\n // The reset button should be disabled if RangeControl itself is disabled,\n // or if the current `value` is equal to the value that would be currently\n // assigned when clicking the button.\n ,\n disabled: disabled || value === computeResetValue({\n resetFallbackValue,\n initialPosition\n }),\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n children: __('Reset')\n })\n })]\n })\n });\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ value, setValue ] = useState();\n * return (\n * <RangeControl\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={ 50 }\n * label=\"Opacity\"\n * max={ 100 }\n * min={ 0 }\n * value={ value }\n * onChange={ setValue }\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef(UnforwardedRangeControl);\nRangeControl.displayName = 'RangeControl';\nexport default RangeControl;"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,IAAI,aAAa;AAC1B,SAAS,QAAQ,UAAU,kBAAkB;AAC7C,SAAS,eAAe,oBAAoB;AAK5C,OAAO,iBAAiB;AACxB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,SAAS,cAAc;AACvB,SAAS,YAAY,+BAA+B;AACpD,SAAS,aAAa;AACtB,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAC1B,SAAS,oBAAoB,kBAAkB,mBAAmB,aAAa,MAAM,OAAO,cAAc,OAAO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AAA,MACH,CAAC,CAAC;AAAA,IACJ,CAAC;AAAA,EACH,CAAC;AACH;AAyBO,IAAM,eAAe,WAAW,uBAAuB;AAC9D,aAAa,cAAc;AAC3B,IAAO,wBAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport { ActionRightWrapper, AfterIconWrapper, BeforeIconWrapper, InputNumber, Root, Track, ThumbWrapper, Thumb, Wrapper } from './styles/range-control-styles';\nimport { space } from '../utils/space';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Computes the value that `RangeControl` should reset to when pressing\n * the reset button.\n */\nfunction computeResetValue({\n resetFallbackValue,\n initialPosition\n}) {\n if (resetFallbackValue !== undefined) {\n return !Number.isNaN(resetFallbackValue) ? resetFallbackValue : null;\n }\n if (initialPosition !== undefined) {\n return !Number.isNaN(initialPosition) ? initialPosition : null;\n }\n return null;\n}\nfunction UnforwardedRangeControl(props, forwardedRef) {\n const {\n // Prevent passing legacy props to internal component.\n __nextHasNoMarginBottom: _,\n __next40pxDefaultSize: _next40pxDefaultSize,\n afterIcon,\n allowReset = false,\n beforeIcon,\n className,\n color: colorProp = COLORS.theme.accent,\n currentInput,\n disabled = false,\n help,\n hideLabelFromVision = false,\n initialPosition,\n isShiftStepEnabled = true,\n label,\n marks = false,\n max = 100,\n min = 0,\n onBlur = noop,\n onChange = noop,\n onFocus = noop,\n onMouseLeave = noop,\n onMouseMove = noop,\n railColor,\n renderTooltipContent = v => v,\n resetFallbackValue,\n shiftStep = 10,\n showTooltip: showTooltipProp,\n step = 1,\n trackColor,\n value: valueProp,\n withInputField = true,\n ...otherProps\n } = props;\n const [value, setValue] = useControlledRangeValue({\n min,\n max,\n value: valueProp ?? null,\n initial: initialPosition\n });\n const isResetPendent = useRef(false);\n let hasTooltip = showTooltipProp;\n let hasInputField = withInputField;\n if (step === 'any') {\n // The tooltip and number input field are hidden when the step is \"any\"\n // because the decimals get too lengthy to fit well.\n hasTooltip = false;\n hasInputField = false;\n }\n const [showTooltip, setShowTooltip] = useState(hasTooltip);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef(null);\n const isCurrentlyFocused = inputRef.current?.matches(':focus');\n const isThumbFocused = !disabled && isFocused;\n const isValueReset = value === null;\n const currentValue = value !== undefined ? value : currentInput;\n const inputSliderValue = isValueReset ? '' : currentValue;\n const rangeFillValue = isValueReset ? (max - min) / 2 + min : value;\n const fillValue = isValueReset ? 50 : (value - min) / (max - min) * 100;\n const fillValueOffset = `${clamp(fillValue, 0, 100)}%`;\n const classes = clsx('components-range-control', className);\n const wrapperClasses = clsx('components-range-control__wrapper', !!marks && 'is-marked');\n const id = useInstanceId(UnforwardedRangeControl, 'inspector-range-control');\n const describedBy = !!help ? `${id}__help` : undefined;\n const enableTooltip = hasTooltip !== false && Number.isFinite(value);\n const handleOnRangeChange = event => {\n const nextValue = parseFloat(event.target.value);\n setValue(nextValue);\n onChange(nextValue);\n };\n const handleOnChange = next => {\n // @ts-expect-error TODO: Investigate if it's problematic for setValue() to\n // potentially receive a NaN when next is undefined.\n let nextValue = parseFloat(next);\n setValue(nextValue);\n\n /*\n * Calls onChange only when nextValue is numeric\n * otherwise may queue a reset for the blur event.\n */\n if (!isNaN(nextValue)) {\n if (nextValue < min || nextValue > max) {\n nextValue = floatClamp(nextValue, min, max);\n }\n onChange(nextValue);\n isResetPendent.current = false;\n } else if (allowReset) {\n isResetPendent.current = true;\n }\n };\n const handleOnInputNumberBlur = () => {\n if (isResetPendent.current) {\n handleOnReset();\n isResetPendent.current = false;\n }\n };\n const handleOnReset = () => {\n // Reset to `resetFallbackValue` if defined, otherwise set internal value\n // to `null` — which, if propagated to the `value` prop, will cause\n // the value to be reset to the `initialPosition` prop if defined.\n const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue ?? null;\n setValue(resetValue);\n\n /**\n * Previously, this callback would always receive undefined as\n * an argument. This behavior is unexpected, specifically\n * when resetFallbackValue is defined.\n *\n * The value of undefined is not ideal. Passing it through\n * to internal <input /> elements would change it from a\n * controlled component to an uncontrolled component.\n *\n * For now, to minimize unexpected regressions, we're going to\n * preserve the undefined callback argument, except when a\n * resetFallbackValue is defined.\n */\n onChange(resetValue ?? undefined);\n };\n const handleShowTooltip = () => setShowTooltip(true);\n const handleHideTooltip = () => setShowTooltip(false);\n const handleOnBlur = event => {\n onBlur(event);\n setIsFocused(false);\n handleHideTooltip();\n };\n const handleOnFocus = event => {\n onFocus(event);\n setIsFocused(true);\n handleShowTooltip();\n };\n const offsetStyle = {\n [isRTL() ? 'right' : 'left']: fillValueOffset\n };\n return /*#__PURE__*/_jsx(BaseControl, {\n className: classes,\n label: label,\n hideLabelFromVision: hideLabelFromVision,\n id: `${id}`,\n help: help,\n children: /*#__PURE__*/_jsxs(Root, {\n className: \"components-range-control__root\",\n children: [beforeIcon && /*#__PURE__*/_jsx(BeforeIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: beforeIcon\n })\n }), /*#__PURE__*/_jsxs(Wrapper, {\n className: wrapperClasses,\n color: colorProp,\n marks: !!marks,\n children: [/*#__PURE__*/_jsx(InputRange, {\n ...otherProps,\n className: \"components-range-control__slider\",\n describedBy: describedBy,\n disabled: disabled,\n id: `${id}`,\n label: label,\n max: max,\n min: min,\n onBlur: handleOnBlur,\n onChange: handleOnRangeChange,\n onFocus: handleOnFocus,\n onMouseMove: onMouseMove,\n onMouseLeave: onMouseLeave,\n ref: useMergeRefs([inputRef, forwardedRef]),\n step: step,\n value: inputSliderValue ?? undefined\n }), /*#__PURE__*/_jsx(RangeRail, {\n \"aria-hidden\": true,\n disabled: disabled,\n marks: marks,\n max: max,\n min: min,\n railColor: railColor,\n step: step,\n value: rangeFillValue\n }), /*#__PURE__*/_jsx(Track, {\n \"aria-hidden\": true,\n className: \"components-range-control__track\",\n disabled: disabled,\n style: {\n width: fillValueOffset\n },\n trackColor: trackColor\n }), /*#__PURE__*/_jsx(ThumbWrapper, {\n className: \"components-range-control__thumb-wrapper\",\n style: offsetStyle,\n disabled: disabled,\n children: /*#__PURE__*/_jsx(Thumb, {\n \"aria-hidden\": true,\n isFocused: isThumbFocused,\n disabled: disabled\n })\n }), enableTooltip && /*#__PURE__*/_jsx(SimpleTooltip, {\n className: \"components-range-control__tooltip\",\n inputRef: inputRef,\n tooltipPlacement: \"bottom\",\n renderTooltipContent: renderTooltipContent,\n show: isCurrentlyFocused || showTooltip,\n style: offsetStyle,\n value: value\n })]\n }), afterIcon && /*#__PURE__*/_jsx(AfterIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: afterIcon\n })\n }), hasInputField && /*#__PURE__*/_jsx(InputNumber, {\n \"aria-label\": label,\n className: \"components-range-control__number\",\n disabled: disabled,\n inputMode: \"decimal\",\n isShiftStepEnabled: isShiftStepEnabled,\n max: max,\n min: min,\n onBlur: handleOnInputNumberBlur,\n onChange: handleOnChange,\n shiftStep: shiftStep,\n __unstableInputWidth: space(20),\n step: step\n // @ts-expect-error TODO: Investigate if the `null` value is necessary\n ,\n value: inputSliderValue\n }), allowReset && /*#__PURE__*/_jsx(ActionRightWrapper, {\n children: /*#__PURE__*/_jsx(Button, {\n className: \"components-range-control__reset\"\n // If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.\n ,\n accessibleWhenDisabled: !disabled\n // The reset button should be disabled if RangeControl itself is disabled,\n // or if the current `value` is equal to the value that would be currently\n // assigned when clicking the button.\n ,\n disabled: disabled || value === computeResetValue({\n resetFallbackValue,\n initialPosition\n }),\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n children: __('Reset')\n })\n })]\n })\n });\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ value, setValue ] = useState();\n * return (\n * <RangeControl\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={ 50 }\n * label=\"Opacity\"\n * max={ 100 }\n * min={ 0 }\n * value={ value }\n * onChange={ setValue }\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef(UnforwardedRangeControl);\nRangeControl.displayName = 'RangeControl';\nexport default RangeControl;"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,IAAI,aAAa;AAC1B,SAAS,QAAQ,UAAU,kBAAkB;AAC7C,SAAS,eAAe,oBAAoB;AAK5C,OAAO,iBAAiB;AACxB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,SAAS,cAAc;AACvB,SAAS,YAAY,+BAA+B;AACpD,SAAS,aAAa;AACtB,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAC1B,SAAS,oBAAoB,kBAAkB,mBAAmB,aAAa,MAAM,OAAO,cAAc,OAAO,eAAe;AAChI,SAAS,aAAa;AACtB,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,OAAO,MAAM;AAAC;AAMpB,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA;AACF,GAAG;AACD,MAAI,uBAAuB,QAAW;AACpC,WAAO,CAAC,OAAO,MAAM,kBAAkB,IAAI,qBAAqB;AAAA,EAClE;AACA,MAAI,oBAAoB,QAAW;AACjC,WAAO,CAAC,OAAO,MAAM,eAAe,IAAI,kBAAkB;AAAA,EAC5D;AACA,SAAO;AACT;AACA,SAAS,wBAAwB,OAAO,cAAc;AACpD,QAAM;AAA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A8B,qBAAK,eAAe;AAAA,UACpD,WAAW;AAAA,UACX;AAAA,UACA,kBAAkB;AAAA,UAClB;AAAA,UACA,MAAM,sBAAsB;AAAA,UAC5B,OAAO;AAAA,UACP;AAAA,QACF,CAAC,CAAC;AAAA,MACJ,CAAC,GAAG,aAA0B,qBAAK,kBAAkB;AAAA,QACnD,UAAuB,qBAAK,MAAM;AAAA,UAChC,MAAM;AAAA,QACR,CAAC;AAAA,MACH,CAAC,GAAG,iBAA8B,qBAAK,aAAa;AAAA,QAClD,cAAc;AAAA,QACd,WAAW;AAAA,QACX;AAAA,QACA,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR,UAAU;AAAA,QACV;AAAA,QACA,sBAAsB,MAAM,EAAE;AAAA,QAC9B;AAAA,QAGA,OAAO;AAAA,MACT,CAAC,GAAG,cAA2B,qBAAK,oBAAoB;AAAA,QACtD,UAAuB,qBAAK,QAAQ;AAAA,UAClC,WAAW;AAAA,UAGX,wBAAwB,CAAC;AAAA,UAKzB,UAAU,YAAY,UAAU,kBAAkB;AAAA,YAChD;AAAA,YACA;AAAA,UACF,CAAC;AAAA,UACD,SAAS;AAAA,UACT,MAAM;AAAA,UACN,SAAS;AAAA,UACT,UAAU,GAAG,OAAO;AAAA,QACtB,CAAC;AAAA,MACH,CAAC,CAAC;AAAA,IACJ,CAAC;AAAA,EACH,CAAC;AACH;AAyBO,IAAM,eAAe,WAAW,uBAAuB;AAC9D,aAAa,cAAc;AAC3B,IAAO,wBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,5 @@
1
1
  // packages/components/src/sandbox/index.tsx
2
+ import clsx from "clsx";
2
3
  import { renderToString, useRef, useState, useEffect, useMemo } from "@wordpress/element";
3
4
  import { useFocusableIframe, useMergeRefs } from "@wordpress/compose";
4
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -140,11 +141,15 @@ function IsolatedSandBox({
140
141
  styles = [],
141
142
  scripts = [],
142
143
  onFocus,
143
- tabIndex
144
+ tabIndex,
145
+ allowPopups = false
144
146
  }) {
145
147
  const ref = useRef(null);
146
148
  const [width, setWidth] = useState(0);
147
149
  const [height, setHeight] = useState(0);
150
+ const sandbox = clsx("allow-scripts", "allow-presentation", {
151
+ "allow-popups": allowPopups
152
+ });
148
153
  const srcDoc = useMemo(() => buildSandBoxDocument({
149
154
  html,
150
155
  title,
@@ -200,7 +205,7 @@ function IsolatedSandBox({
200
205
  title,
201
206
  tabIndex,
202
207
  className: "components-sandbox",
203
- sandbox: "allow-scripts allow-presentation",
208
+ sandbox,
204
209
  srcDoc,
205
210
  onFocus,
206
211
  width: Math.ceil(width),
@@ -214,11 +219,15 @@ function SameOriginSandBox({
214
219
  styles = [],
215
220
  scripts = [],
216
221
  onFocus,
217
- tabIndex
222
+ tabIndex,
223
+ allowPopups = false
218
224
  }) {
219
225
  const ref = useRef(null);
220
226
  const [width, setWidth] = useState(0);
221
227
  const [height, setHeight] = useState(0);
228
+ const sandbox = clsx("allow-scripts", "allow-same-origin", "allow-presentation", {
229
+ "allow-popups": allowPopups
230
+ });
222
231
  function isFrameAccessible() {
223
232
  try {
224
233
  return !!ref.current?.contentDocument?.body;
@@ -291,7 +300,7 @@ function SameOriginSandBox({
291
300
  title,
292
301
  tabIndex,
293
302
  className: "components-sandbox",
294
- sandbox: "allow-scripts allow-same-origin allow-presentation",
303
+ sandbox,
295
304
  onFocus,
296
305
  width: Math.ceil(width),
297
306
  height: Math.ceil(height)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/sandbox/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { renderToString, useRef, useState, useEffect, useMemo } from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\n/**\n * Matches CSS viewport-relative length values such as `100vh`, `50.5vw`,\n * and `.5dvh`. Used to strip viewport units from user-supplied HTML inside\n * the sandbox iframe, because those units are relative to the iframe's\n * own size and would create a measurement feedback loop with the\n * resize observer.\n *\n * Exported for tests. NOTE: an identical regex literal is duplicated\n * inside `observeAndResizeJS` below because that function is serialized\n * via `.toString()` and embedded into the iframe's `srcdoc` — it has no\n * access to this module's scope at runtime. If you change one, change\n * the other; the \"is embedded in the sandbox iframe srcdoc\" test\n * guards against drift.\n */\nexport const VIEWPORT_UNIT_VALUE_REGEX = /^\\d*\\.?\\d+(?:vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/;\nconst observeAndResizeJS = function () {\n const {\n MutationObserver\n } = window;\n if (!MutationObserver || !window.parent) {\n return;\n }\n function sendResize() {\n // This runs in the document <head>, and as a `load`/`resize` listener,\n // so the body may not exist yet. Bail rather than throw on a null body.\n if (!document.body) {\n return;\n }\n const clientBoundingRect = document.body.getBoundingClientRect();\n window.parent.postMessage({\n action: 'resize',\n width: clientBoundingRect.width,\n height: clientBoundingRect.height\n }, '*');\n }\n\n // Runs the body-dependent setup once the document body is available. Reads\n // `document.body` into a local so the null check narrows it for the rest of\n // the function: this runs in <head> and via DOMContentLoaded, so the body\n // isn't guaranteed to exist yet.\n function connect() {\n const {\n body\n } = document;\n if (!body) {\n return;\n }\n const observer = new MutationObserver(sendResize);\n observer.observe(body, {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n });\n\n // Hack: Remove viewport unit styles, as these are relative\n // the iframe root and interfere with our mechanism for\n // determining the unconstrained page bounds.\n function removeViewportStyles(ruleOrNode) {\n if (ruleOrNode.style) {\n ['width', 'height', 'minHeight', 'maxHeight'].forEach(function (style) {\n if (/^\\d*\\.?\\d+(?:vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/.test(ruleOrNode.style[style])) {\n ruleOrNode.style[style] = '';\n }\n });\n }\n }\n Array.prototype.forEach.call(document.querySelectorAll('[style]'), removeViewportStyles);\n Array.prototype.forEach.call(document.styleSheets, function (stylesheet) {\n let rules;\n try {\n rules = stylesheet.cssRules || stylesheet.rules;\n } catch {\n // Reading `cssRules` throws a SecurityError for a\n // cross-origin stylesheet (e.g. a remote <link> in the\n // user's HTML). Skip those rather than aborting the setup.\n return;\n }\n Array.prototype.forEach.call(rules, removeViewportStyles);\n });\n body.style.position = 'absolute';\n body.style.width = '100%';\n body.setAttribute('data-resizable-iframe-connected', '');\n sendResize();\n }\n window.addEventListener('load', sendResize, true);\n\n // Resize events can change the width of elements with 100% width, but we don't\n // get an DOM mutations for that, so do the resize when the window is resized, too.\n window.addEventListener('resize', sendResize, true);\n\n // This script is injected into the document <head> so it parses before the\n // (possibly malformed) user content in <body>: an unclosed attribute quote\n // in that content can't then swallow this <script> tag and dump its source\n // into the preview as visible text. Because <head> runs before <body>\n // exists, defer the body-dependent setup until the DOM is ready.\n if (document.body) {\n connect();\n } else {\n document.addEventListener('DOMContentLoaded', connect);\n }\n};\n\n// TODO: These styles shouldn't be coupled with WordPress.\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div {\n\t\twidth: 100%;\n\t}\n\thtml.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio > div,\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\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\n/**\n * Builds the full HTML document string for the sandbox iframe content. Shared\n * by both the isolated (`srcdoc`) and same-origin (`contentDocument.write`)\n * sandboxes so the two paths always emit the same markup — notably keeping the\n * resize script in `<head>`, ahead of the user content, on both. A single\n * builder means the write path cannot drift back to putting the script in\n * `<body>` while the `srcdoc` path keeps it in `<head>`.\n *\n * `lang` is passed in rather than read here because the two callers source it\n * from different documents: the isolated sandbox uses the module's `document`,\n * while the same-origin sandbox uses the iframe's `ownerDocument`. They are\n * normally the same document, but keeping the argument preserves each path's\n * exact prior behavior.\n *\n * Exported for tests.\n *\n * @param props\n * @param props.html User-supplied HTML for the iframe body.\n * @param props.title Document title.\n * @param props.type Optional class name for the `<html>`/`<body>` elements.\n * @param props.styles CSS rule strings, injected as `<style>` tags in the head.\n * @param props.scripts External script URLs, injected as `<script src>` in the\n * body (embeds expect their scripts there).\n * @param props.lang Language for the `<html lang>` attribute.\n * @return The full `<!DOCTYPE html>…` document string.\n */\nexport function buildSandBoxDocument({\n html,\n title,\n type,\n styles,\n scripts,\n lang\n}) {\n const htmlDoc = /*#__PURE__*/_jsxs(\"html\", {\n lang: lang,\n className: type,\n children: [/*#__PURE__*/_jsxs(\"head\", {\n children: [/*#__PURE__*/_jsx(\"title\", {\n children: title\n }), /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: style\n }\n }), styles.map((rules, i) => /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: rules\n }\n }, i)), /*#__PURE__*/_jsx(\"script\", {\n type: \"text/javascript\",\n dangerouslySetInnerHTML: {\n __html: `(${observeAndResizeJS.toString()})();`\n }\n })]\n }), /*#__PURE__*/_jsxs(\"body\", {\n \"data-resizable-iframe-connected\": \"data-resizable-iframe-connected\",\n className: type,\n children: [/*#__PURE__*/_jsx(\"div\", {\n dangerouslySetInnerHTML: {\n __html: html\n }\n }), scripts.map(src => /*#__PURE__*/_jsx(\"script\", {\n src: src\n }, src))]\n })]\n });\n return '<!DOCTYPE html>' + renderToString(htmlDoc);\n}\n\n/**\n * Isolated sandbox that uses the `srcdoc` attribute to render content\n * without `allow-same-origin`. This is the default for user-controlled\n * content (e.g., the HTML block) where same-origin access would be a\n * security risk.\n *\n * Because `srcdoc` is a declarative attribute, the browser automatically\n * re-renders the content when the iframe is moved in the DOM (e.g.,\n * block reordering), so no `load` event listener is needed.\n * The `message` listener is re-synced on every `load` so\n * it follows the iframe if it's reparented into a different document.\n */\nfunction IsolatedSandBox({\n html = '',\n title = '',\n type,\n styles = [],\n scripts = [],\n onFocus,\n tabIndex\n}) {\n const ref = useRef(null);\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n const srcDoc = useMemo(() => buildSandBoxDocument({\n html,\n title,\n type,\n styles,\n scripts,\n // Read inside the memo: the `no-dom-globals-in-react-fc` lint\n // rule forbids DOM globals in the render body. `lang` rarely\n // changes after load, so leaving it out of the deps is fine.\n lang: document.documentElement.lang\n }), [html, title, type, styles, scripts]);\n useEffect(() => {\n const iframe = ref.current;\n if (!iframe) {\n return;\n }\n function checkMessageForResize(event) {\n // Verify that the mounted element is the source of the message.\n // iframe.contentWindow is accessible cross-origin as a\n // WindowProxy reference, so this check still works without\n // allow-same-origin.\n if (!iframe || iframe.contentWindow !== event.source) {\n return;\n }\n\n // Attempt to parse the message data as JSON if passed as string.\n let data = event.data || {};\n if ('string' === typeof data) {\n try {\n data = JSON.parse(data);\n } catch {}\n }\n\n // Update the state only if the message is formatted as we expect,\n // i.e. as an object with a 'resize' action.\n if ('resize' !== data.action) {\n return;\n }\n setWidth(data.width);\n setHeight(data.height);\n }\n let currentView = null;\n function syncListener() {\n const view = iframe?.ownerDocument?.defaultView ?? null;\n if (view === currentView) {\n return;\n }\n currentView?.removeEventListener('message', checkMessageForResize);\n currentView = view;\n currentView?.addEventListener('message', checkMessageForResize);\n }\n syncListener();\n iframe.addEventListener('load', syncListener);\n return () => {\n iframe.removeEventListener('load', syncListener);\n currentView?.removeEventListener('message', checkMessageForResize);\n };\n }, []);\n return /*#__PURE__*/_jsx(\"iframe\", {\n ref: useMergeRefs([ref, useFocusableIframe()]),\n title: title,\n tabIndex: tabIndex,\n className: \"components-sandbox\",\n sandbox: \"allow-scripts allow-presentation\",\n srcDoc: srcDoc,\n onFocus: onFocus,\n width: Math.ceil(width),\n height: Math.ceil(height)\n });\n}\n\n/**\n * Same-origin sandbox that writes to `contentDocument` directly. This\n * preserves the parent page's URL as the iframe's document URL, which\n * provides a valid Referer header for nested iframes (required by\n * providers like YouTube).\n *\n * Only used when `allowSameOrigin` is true — i.e., for server-fetched\n * oEmbed previews that are not directly user-controlled.\n *\n * This implementation is intentionally kept close to the original\n * pre-refactor code to preserve past bugfixes:\n * - load listener for iframe re-initialization after DOM moves (#21916)\n * - forceRerender guard to avoid unnecessary full rewrites (#20176)\n */\nfunction SameOriginSandBox({\n html = '',\n title = '',\n type,\n styles = [],\n scripts = [],\n onFocus,\n tabIndex\n}) {\n const ref = useRef(null);\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n function isFrameAccessible() {\n try {\n return !!ref.current?.contentDocument?.body;\n } catch {\n return false;\n }\n }\n function trySandBox(forceRerender = false) {\n if (!isFrameAccessible()) {\n return;\n }\n const {\n contentDocument,\n ownerDocument\n } = ref.current;\n if (!forceRerender && null !== contentDocument?.body.getAttribute('data-resizable-iframe-connected')) {\n return;\n }\n\n // Put the html snippet into a html document, and then write it to the\n // iframe's document. The external `scripts` still go into the body to\n // support embedded content such as Instagram that expects them there;\n // only the resize helper lives in the head.\n //\n // Writing the document like this makes it act in the same way as if it\n // was loaded over the network, so DOM creation and mutation, script\n // execution, etc. all work as expected.\n contentDocument.open();\n contentDocument.write(buildSandBoxDocument({\n html,\n title,\n type,\n styles,\n scripts,\n lang: ownerDocument.documentElement.lang\n }));\n contentDocument.close();\n }\n useEffect(() => {\n trySandBox();\n function tryNoForceSandBox() {\n trySandBox(false);\n }\n function checkMessageForResize(event) {\n const iframe = ref.current;\n\n // Verify that the mounted element is the source of the message.\n if (!iframe || iframe.contentWindow !== event.source) {\n return;\n }\n\n // Attempt to parse the message data as JSON if passed as string.\n let data = event.data || {};\n if ('string' === typeof data) {\n try {\n data = JSON.parse(data);\n } catch {}\n }\n\n // Update the state only if the message is formatted as we expect,\n // i.e. as an object with a 'resize' action.\n if ('resize' !== data.action) {\n return;\n }\n setWidth(data.width);\n setHeight(data.height);\n }\n const iframe = ref.current;\n const defaultView = iframe?.ownerDocument?.defaultView;\n\n // This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n // after reordering the containing block. See these two issues for more details:\n // https://github.com/WordPress/gutenberg/issues/6146\n // https://github.com/facebook/react/issues/18752\n iframe?.addEventListener('load', tryNoForceSandBox, false);\n defaultView?.addEventListener('message', checkMessageForResize);\n return () => {\n iframe?.removeEventListener('load', tryNoForceSandBox, false);\n defaultView?.removeEventListener('message', checkMessageForResize);\n };\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, []);\n useEffect(() => {\n trySandBox();\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, [title, styles, scripts]);\n useEffect(() => {\n trySandBox(true);\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, [html, type]);\n return /*#__PURE__*/_jsx(\"iframe\", {\n ref: useMergeRefs([ref, useFocusableIframe()]),\n title: title,\n tabIndex: tabIndex,\n className: \"components-sandbox\",\n sandbox: \"allow-scripts allow-same-origin allow-presentation\",\n onFocus: onFocus,\n width: Math.ceil(width),\n height: Math.ceil(height)\n });\n}\n\n/**\n * This component provides an isolated environment for arbitrary HTML via iframes.\n *\n * ```jsx\n * import { SandBox } from '@wordpress/components';\n *\n * const MySandBox = () => (\n * \t<SandBox html=\"<p>Content</p>\" title=\"SandBox\" type=\"embed\" />\n * );\n * ```\n */\nfunction SandBox({\n allowSameOrigin = false,\n ...contentProps\n}) {\n if (allowSameOrigin) {\n return /*#__PURE__*/_jsx(SameOriginSand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a,CAAC,KAAK,mBAAmB,CAAC,CAAC;AAAA,IAC7C;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,SAAS;AAAA,IACT;AAAA,IACA,OAAO,KAAK,KAAK,KAAK;AAAA,IACtB,QAAQ,KAAK,KAAK,MAAM;AAAA,EAC1B,CAAC;AACH;AAaA,SAAS,QAAQ;AAAA,EACf,kBAAkB;AAAA,EAClB,GAAG;AACL,GAAG;AACD,MAAI,iBAAiB;AACnB,WAAoB,qBAAK,mBAAmB;AAAA,MAC1C,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACA,SAAoB,qBAAK,iBAAiB;AAAA,IACxC,GAAG;AAAA,EACL,CAAC;AACH;AACA,IAAO,kBAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { renderToString, useRef, useState, useEffect, useMemo } from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\n/**\n * Matches CSS viewport-relative length values such as `100vh`, `50.5vw`,\n * and `.5dvh`. Used to strip viewport units from user-supplied HTML inside\n * the sandbox iframe, because those units are relative to the iframe's\n * own size and would create a measurement feedback loop with the\n * resize observer.\n *\n * Exported for tests. NOTE: an identical regex literal is duplicated\n * inside `observeAndResizeJS` below because that function is serialized\n * via `.toString()` and embedded into the iframe's `srcdoc` — it has no\n * access to this module's scope at runtime. If you change one, change\n * the other; the \"is embedded in the sandbox iframe srcdoc\" test\n * guards against drift.\n */\nexport const VIEWPORT_UNIT_VALUE_REGEX = /^\\d*\\.?\\d+(?:vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/;\nconst observeAndResizeJS = function () {\n const {\n MutationObserver\n } = window;\n if (!MutationObserver || !window.parent) {\n return;\n }\n function sendResize() {\n // This runs in the document <head>, and as a `load`/`resize` listener,\n // so the body may not exist yet. Bail rather than throw on a null body.\n if (!document.body) {\n return;\n }\n const clientBoundingRect = document.body.getBoundingClientRect();\n window.parent.postMessage({\n action: 'resize',\n width: clientBoundingRect.width,\n height: clientBoundingRect.height\n }, '*');\n }\n\n // Runs the body-dependent setup once the document body is available. Reads\n // `document.body` into a local so the null check narrows it for the rest of\n // the function: this runs in <head> and via DOMContentLoaded, so the body\n // isn't guaranteed to exist yet.\n function connect() {\n const {\n body\n } = document;\n if (!body) {\n return;\n }\n const observer = new MutationObserver(sendResize);\n observer.observe(body, {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n });\n\n // Hack: Remove viewport unit styles, as these are relative\n // the iframe root and interfere with our mechanism for\n // determining the unconstrained page bounds.\n function removeViewportStyles(ruleOrNode) {\n if (ruleOrNode.style) {\n ['width', 'height', 'minHeight', 'maxHeight'].forEach(function (style) {\n if (/^\\d*\\.?\\d+(?:vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/.test(ruleOrNode.style[style])) {\n ruleOrNode.style[style] = '';\n }\n });\n }\n }\n Array.prototype.forEach.call(document.querySelectorAll('[style]'), removeViewportStyles);\n Array.prototype.forEach.call(document.styleSheets, function (stylesheet) {\n let rules;\n try {\n rules = stylesheet.cssRules || stylesheet.rules;\n } catch {\n // Reading `cssRules` throws a SecurityError for a\n // cross-origin stylesheet (e.g. a remote <link> in the\n // user's HTML). Skip those rather than aborting the setup.\n return;\n }\n Array.prototype.forEach.call(rules, removeViewportStyles);\n });\n body.style.position = 'absolute';\n body.style.width = '100%';\n body.setAttribute('data-resizable-iframe-connected', '');\n sendResize();\n }\n window.addEventListener('load', sendResize, true);\n\n // Resize events can change the width of elements with 100% width, but we don't\n // get an DOM mutations for that, so do the resize when the window is resized, too.\n window.addEventListener('resize', sendResize, true);\n\n // This script is injected into the document <head> so it parses before the\n // (possibly malformed) user content in <body>: an unclosed attribute quote\n // in that content can't then swallow this <script> tag and dump its source\n // into the preview as visible text. Because <head> runs before <body>\n // exists, defer the body-dependent setup until the DOM is ready.\n if (document.body) {\n connect();\n } else {\n document.addEventListener('DOMContentLoaded', connect);\n }\n};\n\n// TODO: These styles shouldn't be coupled with WordPress.\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div {\n\t\twidth: 100%;\n\t}\n\thtml.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio > div,\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\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\n/**\n * Builds the full HTML document string for the sandbox iframe content. Shared\n * by both the isolated (`srcdoc`) and same-origin (`contentDocument.write`)\n * sandboxes so the two paths always emit the same markup — notably keeping the\n * resize script in `<head>`, ahead of the user content, on both. A single\n * builder means the write path cannot drift back to putting the script in\n * `<body>` while the `srcdoc` path keeps it in `<head>`.\n *\n * `lang` is passed in rather than read here because the two callers source it\n * from different documents: the isolated sandbox uses the module's `document`,\n * while the same-origin sandbox uses the iframe's `ownerDocument`. They are\n * normally the same document, but keeping the argument preserves each path's\n * exact prior behavior.\n *\n * Exported for tests.\n *\n * @param props\n * @param props.html User-supplied HTML for the iframe body.\n * @param props.title Document title.\n * @param props.type Optional class name for the `<html>`/`<body>` elements.\n * @param props.styles CSS rule strings, injected as `<style>` tags in the head.\n * @param props.scripts External script URLs, injected as `<script src>` in the\n * body (embeds expect their scripts there).\n * @param props.lang Language for the `<html lang>` attribute.\n * @return The full `<!DOCTYPE html>…` document string.\n */\nexport function buildSandBoxDocument({\n html,\n title,\n type,\n styles,\n scripts,\n lang\n}) {\n const htmlDoc = /*#__PURE__*/_jsxs(\"html\", {\n lang: lang,\n className: type,\n children: [/*#__PURE__*/_jsxs(\"head\", {\n children: [/*#__PURE__*/_jsx(\"title\", {\n children: title\n }), /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: style\n }\n }), styles.map((rules, i) => /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: rules\n }\n }, i)), /*#__PURE__*/_jsx(\"script\", {\n type: \"text/javascript\",\n dangerouslySetInnerHTML: {\n __html: `(${observeAndResizeJS.toString()})();`\n }\n })]\n }), /*#__PURE__*/_jsxs(\"body\", {\n \"data-resizable-iframe-connected\": \"data-resizable-iframe-connected\",\n className: type,\n children: [/*#__PURE__*/_jsx(\"div\", {\n dangerouslySetInnerHTML: {\n __html: html\n }\n }), scripts.map(src => /*#__PURE__*/_jsx(\"script\", {\n src: src\n }, src))]\n })]\n });\n return '<!DOCTYPE html>' + renderToString(htmlDoc);\n}\n\n/**\n * Isolated sandbox that uses the `srcdoc` attribute to render content\n * without `allow-same-origin`. This is the default for user-controlled\n * content (e.g., the HTML block) where same-origin access would be a\n * security risk.\n *\n * Because `srcdoc` is a declarative attribute, the browser automatically\n * re-renders the content when the iframe is moved in the DOM (e.g.,\n * block reordering), so no `load` event listener is needed.\n * The `message` listener is re-synced on every `load` so\n * it follows the iframe if it's reparented into a different document.\n */\nfunction IsolatedSandBox({\n html = '',\n title = '',\n type,\n styles = [],\n scripts = [],\n onFocus,\n tabIndex,\n allowPopups = false\n}) {\n const ref = useRef(null);\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n const sandbox = clsx('allow-scripts', 'allow-presentation', {\n 'allow-popups': allowPopups\n });\n const srcDoc = useMemo(() => buildSandBoxDocument({\n html,\n title,\n type,\n styles,\n scripts,\n // Read inside the memo: the `no-dom-globals-in-react-fc` lint\n // rule forbids DOM globals in the render body. `lang` rarely\n // changes after load, so leaving it out of the deps is fine.\n lang: document.documentElement.lang\n }), [html, title, type, styles, scripts]);\n useEffect(() => {\n const iframe = ref.current;\n if (!iframe) {\n return;\n }\n function checkMessageForResize(event) {\n // Verify that the mounted element is the source of the message.\n // iframe.contentWindow is accessible cross-origin as a\n // WindowProxy reference, so this check still works without\n // allow-same-origin.\n if (!iframe || iframe.contentWindow !== event.source) {\n return;\n }\n\n // Attempt to parse the message data as JSON if passed as string.\n let data = event.data || {};\n if ('string' === typeof data) {\n try {\n data = JSON.parse(data);\n } catch {}\n }\n\n // Update the state only if the message is formatted as we expect,\n // i.e. as an object with a 'resize' action.\n if ('resize' !== data.action) {\n return;\n }\n setWidth(data.width);\n setHeight(data.height);\n }\n let currentView = null;\n function syncListener() {\n const view = iframe?.ownerDocument?.defaultView ?? null;\n if (view === currentView) {\n return;\n }\n currentView?.removeEventListener('message', checkMessageForResize);\n currentView = view;\n currentView?.addEventListener('message', checkMessageForResize);\n }\n syncListener();\n iframe.addEventListener('load', syncListener);\n return () => {\n iframe.removeEventListener('load', syncListener);\n currentView?.removeEventListener('message', checkMessageForResize);\n };\n }, []);\n return /*#__PURE__*/_jsx(\"iframe\", {\n ref: useMergeRefs([ref, useFocusableIframe()]),\n title: title,\n tabIndex: tabIndex,\n className: \"components-sandbox\",\n sandbox: sandbox,\n srcDoc: srcDoc,\n onFocus: onFocus,\n width: Math.ceil(width),\n height: Math.ceil(height)\n });\n}\n\n/**\n * Same-origin sandbox that writes to `contentDocument` directly. This\n * preserves the parent page's URL as the iframe's document URL, which\n * provides a valid Referer header for nested iframes (required by\n * providers like YouTube).\n *\n * Only used when `allowSameOrigin` is true — i.e., for server-fetched\n * oEmbed previews that are not directly user-controlled.\n *\n * This implementation is intentionally kept close to the original\n * pre-refactor code to preserve past bugfixes:\n * - load listener for iframe re-initialization after DOM moves (#21916)\n * - forceRerender guard to avoid unnecessary full rewrites (#20176)\n */\nfunction SameOriginSandBox({\n html = '',\n title = '',\n type,\n styles = [],\n scripts = [],\n onFocus,\n tabIndex,\n allowPopups = false\n}) {\n const ref = useRef(null);\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n const sandbox = clsx('allow-scripts', 'allow-same-origin', 'allow-presentation', {\n 'allow-popups': allowPopups\n });\n function isFrameAccessible() {\n try {\n return !!ref.current?.contentDocument?.body;\n } catch {\n return false;\n }\n }\n function trySandBox(forceRerender = false) {\n if (!isFrameAccessible()) {\n return;\n }\n const {\n contentDocument,\n ownerDocument\n } = ref.current;\n if (!forceRerender && null !== contentDocument?.body.getAttribute('data-resizable-iframe-connected')) {\n return;\n }\n\n // Put the html snippet into a html document, and then write it to the\n // iframe's document. The external `scripts` still go into the body to\n // support embedded content such as Instagram that expects them there;\n // only the resize helper lives in the head.\n //\n // Writing the document like this makes it act in the same way as if it\n // was loaded over the network, so DOM creation and mutation, script\n // execution, etc. all work as expected.\n contentDocument.open();\n contentDocument.write(buildSandBoxDocument({\n html,\n title,\n type,\n styles,\n scripts,\n lang: ownerDocument.documentElement.lang\n }));\n contentDocument.close();\n }\n useEffect(() => {\n trySandBox();\n function tryNoForceSandBox() {\n trySandBox(false);\n }\n function checkMessageForResize(event) {\n const iframe = ref.current;\n\n // Verify that the mounted element is the source of the message.\n if (!iframe || iframe.contentWindow !== event.source) {\n return;\n }\n\n // Attempt to parse the message data as JSON if passed as string.\n let data = event.data || {};\n if ('string' === typeof data) {\n try {\n data = JSON.parse(data);\n } catch {}\n }\n\n // Update the state only if the message is formatted as we expect,\n // i.e. as an object with a 'resize' action.\n if ('resize' !== data.action) {\n return;\n }\n setWidth(data.width);\n setHeight(data.height);\n }\n const iframe = ref.current;\n const defaultView = iframe?.ownerDocument?.defaultView;\n\n // This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n // after reordering the containing block. See these two issues for more details:\n // https://github.com/WordPress/gutenberg/issues/6146\n // https://github.com/facebook/react/issues/18752\n iframe?.addEventListener('load', tryNoForceSandBox, false);\n defaultView?.addEventListener('message', checkMessageForResize);\n return () => {\n iframe?.removeEventListener('load', tryNoForceSandBox, false);\n defaultView?.removeEventListener('message', checkMessageForResize);\n };\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, []);\n useEffect(() => {\n trySandBox();\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, [title, styles, scripts]);\n useEffect(() => {\n trySandBox(true);\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, [html, type]);\n return /*#__PURE__*/_jsx(\"iframe\", {\n ref: useMergeRefs([ref, useFocusableIframe()]),\n title: title,\n tabIndex: tabIndex,\n className: \"components-sandbox\",\n sandbox: sandbox,\n onFocus: onFocus,\n width: Math.ceil(width),\n height: Math.ceil(height)\n });\n}\n\n/**\n * This component provides an isolated environment for arbitrary HTML via iframes.\n *\n * ```jsx\n * import { SandBox } from '@wordpress/components';\n *\n * const MySandBox = () => (\n * \t<SandBox html=\"<p>Content</p>\" title=\"SandBox\" type=\"embed\" />\n * );\n * ```\n */\nfunction SandBox({\n allowSameOrigin = false,\n ...contentProps\n}) {\n if (allowSameOrigin) {\n return /*#__PURE__*/_jsx(SameOriginSandBox, {\n ...contentProps\n });\n }\n return /*#__PURE__*/_jsx(IsolatedSandBox, {\n ...contentProps\n });\n}\nexport default SandBox;"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,gBAAgB,QAAQ,UAAU,WAAW,eAAe;AACrE,SAAS,oBAAoB,oBAAoB;AAKjD,SAAS,OAAO,MAAM,QAAQ,aAAa;AAepC,IAAM,4BAA4B;AACzC,IAAM,qBAAqB,WAAY;AACrC,QAAM;AAAA,IACJ;AAAA,EACF,IAAI;AACJ,MAAI,CAAC,oBAAoB,CAAC,OAAO,QAAQ;AACvC;AAAA,EACF;AACA,WAAS,aAAa;AAGpB,QAA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AaA,SAAS,QAAQ;AAAA,EACf,kBAAkB;AAAA,EAClB,GAAG;AACL,GAAG;AACD,MAAI,iBAAiB;AACnB,WAAoB,qBAAK,mBAAmB;AAAA,MAC1C,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACA,SAAoB,qBAAK,iBAAiB;AAAA,IACxC,GAAG;AAAA,EACL,CAAC;AACH;AACA,IAAO,kBAAQ;",
6
6
  "names": ["style", "iframe"]
7
7
  }
@@ -6,19 +6,101 @@ import { search, closeSmall } from "@wordpress/icons";
6
6
  import { forwardRef, useRef } from "@wordpress/element";
7
7
  import deprecated from "@wordpress/deprecated";
8
8
  import Button from "../button/index.mjs";
9
+ import InputControl from "../input-control/index.mjs";
10
+ import Icon from "../icon/index.mjs";
9
11
  import { InputControlPrefixWrapper } from "../input-control/input-prefix-wrapper.mjs";
10
12
  import { InputControlSuffixWrapper } from "../input-control/input-suffix-wrapper.mjs";
11
- import { StyledInputControl, StyledIcon } from "./styles.mjs";
13
+
14
+ // packages/style-runtime/src/index.ts
15
+ var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
16
+ function getRuntime() {
17
+ const globalScope = globalThis;
18
+ if (globalScope.__wpStyleRuntime) {
19
+ return globalScope.__wpStyleRuntime;
20
+ }
21
+ globalScope.__wpStyleRuntime = {
22
+ documents: /* @__PURE__ */ new Map(),
23
+ styles: /* @__PURE__ */ new Map(),
24
+ injectedStyles: /* @__PURE__ */ new WeakMap()
25
+ };
26
+ if (typeof document !== "undefined") {
27
+ registerDocument(document);
28
+ }
29
+ return globalScope.__wpStyleRuntime;
30
+ }
31
+ function documentContainsStyleHash(targetDocument, hash) {
32
+ if (!targetDocument.head) {
33
+ return false;
34
+ }
35
+ for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {
36
+ if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
37
+ return true;
38
+ }
39
+ }
40
+ return false;
41
+ }
42
+ function injectStyle(targetDocument, hash, css) {
43
+ if (!targetDocument.head) {
44
+ return;
45
+ }
46
+ const runtime = getRuntime();
47
+ let injectedStyles = runtime.injectedStyles.get(targetDocument);
48
+ if (!injectedStyles) {
49
+ injectedStyles = /* @__PURE__ */ new Set();
50
+ runtime.injectedStyles.set(targetDocument, injectedStyles);
51
+ }
52
+ if (injectedStyles.has(hash)) {
53
+ return;
54
+ }
55
+ if (documentContainsStyleHash(targetDocument, hash)) {
56
+ injectedStyles.add(hash);
57
+ return;
58
+ }
59
+ const style = targetDocument.createElement("style");
60
+ style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
61
+ style.appendChild(targetDocument.createTextNode(css));
62
+ targetDocument.head.appendChild(style);
63
+ injectedStyles.add(hash);
64
+ }
65
+ function registerDocument(targetDocument) {
66
+ const runtime = getRuntime();
67
+ runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
68
+ for (const [hash, css] of runtime.styles) {
69
+ injectStyle(targetDocument, hash, css);
70
+ }
71
+ return () => {
72
+ const count = runtime.documents.get(targetDocument);
73
+ if (count === void 0) {
74
+ return;
75
+ }
76
+ if (count <= 1) {
77
+ runtime.documents.delete(targetDocument);
78
+ return;
79
+ }
80
+ runtime.documents.set(targetDocument, count - 1);
81
+ };
82
+ }
83
+ function registerStyle(hash, css) {
84
+ const runtime = getRuntime();
85
+ runtime.styles.set(hash, css);
86
+ for (const targetDocument of runtime.documents.keys()) {
87
+ injectStyle(targetDocument, hash, css);
88
+ }
89
+ }
90
+
91
+ // packages/components/src/search-control/style.module.scss
92
+ if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
93
+ registerStyle("77f847972d", "._5e6152f7430df331__input input[type=search]::-webkit-search-cancel-button,._5e6152f7430df331__input input[type=search]::-webkit-search-decoration,._5e6152f7430df331__input input[type=search]::-webkit-search-results-button,._5e6152f7430df331__input input[type=search]::-webkit-search-results-decoration{-webkit-appearance:none}._9a856163f1b1aaae__icon:dir(ltr){transform:scaleX(-1)}");
94
+ }
95
+ var style_module_default = { "input": "_5e6152f7430df331__input", "icon": "_9a856163f1b1aaae__icon" };
96
+
97
+ // packages/components/src/search-control/index.tsx
12
98
  import { jsx as _jsx } from "react/jsx-runtime";
13
99
  function SuffixItem({
14
100
  searchRef,
15
- value,
16
101
  onChange,
17
102
  onClose
18
103
  }) {
19
- if (!onClose && !value) {
20
- return null;
21
- }
22
104
  if (onClose) {
23
105
  deprecated("`onClose` prop in wp.components.SearchControl", {
24
106
  since: "6.8"
@@ -58,28 +140,29 @@ function UnforwardedSearchControl({
58
140
  } = restProps;
59
141
  const searchRef = useRef(null);
60
142
  const instanceId = useInstanceId(SearchControl, "components-search-control");
61
- return /* @__PURE__ */ _jsx(StyledInputControl, {
143
+ const hasSuffix = !!onClose || !!value;
144
+ return /* @__PURE__ */ _jsx(InputControl, {
62
145
  id: instanceId,
63
146
  hideLabelFromVision,
64
147
  label,
65
148
  ref: useMergeRefs([searchRef, forwardedRef]),
66
149
  type: "search",
67
150
  size,
68
- className: clsx("components-search-control", className),
151
+ className: clsx(style_module_default.input, "components-search-control", className),
69
152
  onChange: (nextValue) => onChange(nextValue ?? ""),
70
153
  autoComplete: "off",
71
154
  placeholder,
72
155
  value: value ?? "",
73
156
  prefix: /* @__PURE__ */ _jsx(InputControlPrefixWrapper, {
74
157
  variant: "icon",
75
- children: /* @__PURE__ */ _jsx(StyledIcon, {
158
+ children: /* @__PURE__ */ _jsx(Icon, {
159
+ className: style_module_default.icon,
76
160
  icon: search,
77
161
  fill: "currentColor"
78
162
  })
79
163
  }),
80
- suffix: /* @__PURE__ */ _jsx(SuffixItem, {
164
+ suffix: hasSuffix && /* @__PURE__ */ _jsx(SuffixItem, {
81
165
  searchRef,
82
- value,
83
166
  onChange,
84
167
  onClose
85
168
  }),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/search-control/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { search, closeSmall } from '@wordpress/icons';\nimport { forwardRef, useRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { InputControlPrefixWrapper } from '../input-control/input-prefix-wrapper';\nimport { InputControlSuffixWrapper } from '../input-control/input-suffix-wrapper';\nimport { StyledInputControl, StyledIcon } from './styles';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction SuffixItem({\n searchRef,\n value,\n onChange,\n onClose\n}) {\n if (!onClose && !value) {\n return null;\n }\n if (onClose) {\n deprecated('`onClose` prop in wp.components.SearchControl', {\n since: '6.8'\n });\n }\n const onReset = () => {\n onChange('');\n searchRef.current?.focus();\n };\n return /*#__PURE__*/_jsx(InputControlSuffixWrapper, {\n variant: \"control\",\n children: /*#__PURE__*/_jsx(Button, {\n size: \"small\",\n icon: closeSmall,\n label: onClose ? __('Close search') : __('Reset search'),\n onClick: onClose ?? onReset\n })\n });\n}\nfunction UnforwardedSearchControl({\n // Prevent passing legacy props to internal component.\n __nextHasNoMarginBottom: _,\n __next40pxDefaultSize: _next40pxDefaultSize,\n className,\n onChange,\n value,\n label = __('Search'),\n placeholder = __('Search'),\n hideLabelFromVision = true,\n onClose,\n size = 'default',\n ...restProps\n}, forwardedRef) {\n // @ts-expect-error The `disabled` prop is not yet supported in the SearchControl component.\n // Work with the design team (@WordPress/gutenberg-design) if you need this feature.\n const {\n disabled,\n ...filteredRestProps\n } = restProps;\n const searchRef = useRef(null);\n const instanceId = useInstanceId(SearchControl, 'components-search-control');\n return /*#__PURE__*/_jsx(StyledInputControl, {\n id: instanceId,\n hideLabelFromVision: hideLabelFromVision,\n label: label,\n ref: useMergeRefs([searchRef, forwardedRef]),\n type: \"search\",\n size: size,\n className: clsx('components-search-control', className),\n onChange: nextValue => onChange(nextValue ?? ''),\n autoComplete: \"off\",\n placeholder: placeholder,\n value: value ?? '',\n prefix: /*#__PURE__*/_jsx(InputControlPrefixWrapper, {\n variant: \"icon\",\n children: /*#__PURE__*/_jsx(StyledIcon, {\n icon: search,\n fill: \"currentColor\"\n })\n }),\n suffix: /*#__PURE__*/_jsx(SuffixItem, {\n searchRef: searchRef,\n value: value,\n onChange: onChange,\n onClose: onClose\n }),\n ...filteredRestProps\n });\n}\n\n/**\n * SearchControl components let users display a search control.\n *\n * ```jsx\n * import { SearchControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * function MySearchControl( { className, setState } ) {\n * const [ searchInput, setSearchInput ] = useState( '' );\n *\n * return (\n * <SearchControl\n * value={ searchInput }\n * onChange={ setSearchInput }\n * />\n * );\n * }\n * ```\n */\nexport const SearchControl = forwardRef(UnforwardedSearchControl);\nSearchControl.displayName = 'SearchControl';\nexport default SearchControl;"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,eAAe,oBAAoB;AAC5C,SAAS,UAAU;AACnB,SAAS,QAAQ,kBAAkB;AACnC,SAAS,YAAY,cAAc;AACnC,OAAO,gBAAgB;AAKvB,OAAO,YAAY;AACnB,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC;AAC1C,SAAS,oBAAoB,kBAAkB;AAC/C,SAAS,OAAO,YAAY;AAC5B,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAG;AACD,MAAI,CAAC,WAAW,CAAC,OAAO;AACtB,WAAO;AAAA,EACT;AACA,MAAI,SAAS;AACX,eAAW,iDAAiD;AAAA,MAC1D,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACA,QAAM,UAAU,MAAM;AACpB,aAAS,EAAE;AACX,cAAU,SAAS,MAAM;AAAA,EAC3B;AACA,SAAoB,qBAAK,2BAA2B;AAAA,IAClD,SAAS;AAAA,IACT,UAAuB,qBAAK,QAAQ;AAAA,MAClC,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,UAAU,GAAG,cAAc,IAAI,GAAG,cAAc;AAAA,MACvD,SAAS,WAAW;AAAA,IACtB,CAAC;AAAA,EACH,CAAC;AACH;AACA,SAAS,yBAAyB;AAAA;AAAA,EAEhC,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,GAAG,QAAQ;AAAA,EACnB,cAAc,GAAG,QAAQ;AAAA,EACzB,sBAAsB;AAAA,EACtB;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,GAAG,cAAc;AAGf,QAAM;AAAA,IACJ;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,YAAY,OAAO,IAAI;AAC7B,QAAM,aAAa,cAAc,eAAe,2BAA2B;AAC3E,SAAoB,qBAAK,oBAAoB;AAAA,IAC3C,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA,KAAK,aAAa,CAAC,WAAW,YAAY,CAAC;AAAA,IAC3C,MAAM;AAAA,IACN;AAAA,IACA,WAAW,KAAK,6BAA6B,SAAS;AAAA,IACtD,UAAU,eAAa,SAAS,aAAa,EAAE;AAAA,IAC/C,cAAc;AAAA,IACd;AAAA,IACA,OAAO,SAAS;AAAA,IAChB,QAAqB,qBAAK,2BAA2B;AAAA,MACnD,SAAS;AAAA,MACT,UAAuB,qBAAK,YAAY;AAAA,QACtC,MAAM;AAAA,QACN,MAAM;AAAA,MACR,CAAC;AAAA,IACH,CAAC;AAAA,IACD,QAAqB,qBAAK,YAAY;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACD,GAAG;AAAA,EACL,CAAC;AACH;AAqBO,IAAM,gBAAgB,WAAW,wBAAwB;AAChE,cAAc,cAAc;AAC5B,IAAO,yBAAQ;",
3
+ "sources": ["../../src/search-control/index.tsx", "../../../style-runtime/src/index.ts", "../../src/search-control/style.module.scss"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { search, closeSmall } from '@wordpress/icons';\nimport { forwardRef, useRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport InputControl from '../input-control';\nimport Icon from '../icon';\nimport { InputControlPrefixWrapper } from '../input-control/input-prefix-wrapper';\nimport { InputControlSuffixWrapper } from '../input-control/input-suffix-wrapper';\nimport styles from './style.module.scss';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction SuffixItem({\n searchRef,\n onChange,\n onClose\n}) {\n if (onClose) {\n deprecated('`onClose` prop in wp.components.SearchControl', {\n since: '6.8'\n });\n }\n const onReset = () => {\n onChange('');\n searchRef.current?.focus();\n };\n return /*#__PURE__*/_jsx(InputControlSuffixWrapper, {\n variant: \"control\",\n children: /*#__PURE__*/_jsx(Button, {\n size: \"small\",\n icon: closeSmall,\n label: onClose ? __('Close search') : __('Reset search'),\n onClick: onClose ?? onReset\n })\n });\n}\nfunction UnforwardedSearchControl({\n // Prevent passing legacy props to internal component.\n __nextHasNoMarginBottom: _,\n __next40pxDefaultSize: _next40pxDefaultSize,\n className,\n onChange,\n value,\n label = __('Search'),\n placeholder = __('Search'),\n hideLabelFromVision = true,\n onClose,\n size = 'default',\n ...restProps\n}, forwardedRef) {\n // @ts-expect-error The `disabled` prop is not yet supported in the SearchControl component.\n // Work with the design team (@WordPress/gutenberg-design) if you need this feature.\n const {\n disabled,\n ...filteredRestProps\n } = restProps;\n const searchRef = useRef(null);\n const instanceId = useInstanceId(SearchControl, 'components-search-control');\n const hasSuffix = !!onClose || !!value;\n return /*#__PURE__*/_jsx(InputControl, {\n id: instanceId,\n hideLabelFromVision: hideLabelFromVision,\n label: label,\n ref: useMergeRefs([searchRef, forwardedRef]),\n type: \"search\",\n size: size,\n className: clsx(styles.input, 'components-search-control', className),\n onChange: nextValue => onChange(nextValue ?? ''),\n autoComplete: \"off\",\n placeholder: placeholder,\n value: value ?? '',\n prefix: /*#__PURE__*/_jsx(InputControlPrefixWrapper, {\n variant: \"icon\",\n children: /*#__PURE__*/_jsx(Icon, {\n className: styles.icon,\n icon: search,\n fill: \"currentColor\"\n })\n }),\n suffix: hasSuffix && /*#__PURE__*/_jsx(SuffixItem, {\n searchRef: searchRef,\n onChange: onChange,\n onClose: onClose\n }),\n ...filteredRestProps\n });\n}\n\n/**\n * SearchControl components let users display a search control.\n *\n * ```jsx\n * import { SearchControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * function MySearchControl( { className, setState } ) {\n * const [ searchInput, setSearchInput ] = useState( '' );\n *\n * return (\n * <SearchControl\n * value={ searchInput }\n * onChange={ setSearchInput }\n * />\n * );\n * }\n * ```\n */\nexport const SearchControl = forwardRef(UnforwardedSearchControl);\nSearchControl.displayName = 'SearchControl';\nexport default SearchControl;", "const STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n const globalScope = globalThis;\n if (globalScope.__wpStyleRuntime) {\n return globalScope.__wpStyleRuntime;\n }\n globalScope.__wpStyleRuntime = {\n documents: new Map(),\n styles: new Map(),\n injectedStyles: new WeakMap()\n };\n if (typeof document !== 'undefined') {\n registerDocument(document);\n }\n return globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(targetDocument, hash) {\n if (!targetDocument.head) {\n return false;\n }\n for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {\n if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle(targetDocument, hash, css) {\n if (!targetDocument.head) {\n return;\n }\n const runtime = getRuntime();\n let injectedStyles = runtime.injectedStyles.get(targetDocument);\n if (!injectedStyles) {\n injectedStyles = new Set();\n runtime.injectedStyles.set(targetDocument, injectedStyles);\n }\n if (injectedStyles.has(hash)) {\n return;\n }\n\n // Older generated CSS module output can still inject matching style tags\n // after this document's cache is created, so keep the DOM as the fallback\n // source of truth on cache misses.\n if (documentContainsStyleHash(targetDocument, hash)) {\n injectedStyles.add(hash);\n return;\n }\n const style = targetDocument.createElement('style');\n style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);\n style.appendChild(targetDocument.createTextNode(css));\n targetDocument.head.appendChild(style);\n injectedStyles.add(hash);\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument(targetDocument) {\n const runtime = getRuntime();\n runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);\n for (const [hash, css] of runtime.styles) {\n injectStyle(targetDocument, hash, css);\n }\n return () => {\n const count = runtime.documents.get(targetDocument);\n if (count === undefined) {\n return;\n }\n if (count <= 1) {\n runtime.documents.delete(targetDocument);\n return;\n }\n runtime.documents.set(targetDocument, count - 1);\n };\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle(hash, css) {\n const runtime = getRuntime();\n runtime.styles.set(hash, css);\n for (const targetDocument of runtime.documents.keys()) {\n injectStyle(targetDocument, hash, css);\n }\n}", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"77f847972d\", \"._5e6152f7430df331__input input[type=search]::-webkit-search-cancel-button,._5e6152f7430df331__input input[type=search]::-webkit-search-decoration,._5e6152f7430df331__input input[type=search]::-webkit-search-results-button,._5e6152f7430df331__input input[type=search]::-webkit-search-results-decoration{-webkit-appearance:none}._9a856163f1b1aaae__icon:dir(ltr){transform:scaleX(-1)}\");\n}\nexport default {\"input\":\"_5e6152f7430df331__input\",\"icon\":\"_9a856163f1b1aaae__icon\"};\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,eAAe,oBAAoB;AAC5C,SAAS,UAAU;AACnB,SAAS,QAAQ,kBAAkB;AACnC,SAAS,YAAY,cAAc;AACnC,OAAO,gBAAgB;AAKvB,OAAO,YAAY;AACnB,OAAO,kBAAkB;AACzB,OAAO,UAAU;AACjB,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC;;;ACpB1C,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACpB,QAAM,cAAc;AACpB,MAAI,YAAY,kBAAkB;AAChC,WAAO,YAAY;AAAA,EACrB;AACA,cAAY,mBAAmB;AAAA,IAC7B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC9B;AACA,MAAI,OAAO,aAAa,aAAa;AACnC,qBAAiB,QAAQ;AAAA,EAC3B;AACA,SAAO,YAAY;AACrB;AAUA,SAAS,0BAA0B,gBAAgB,MAAM;AACvD,MAAI,CAAC,eAAe,MAAM;AACxB,WAAO;AAAA,EACT;AACA,aAAW,SAAS,eAAe,KAAK,iBAAiB,SAAS,oBAAoB,GAAG,GAAG;AAC1F,QAAI,MAAM,aAA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CAAC;AAAA,IAC3C,MAAM;AAAA,IACN;AAAA,IACA,WAAW,KAAK,qBAAO,OAAO,6BAA6B,SAAS;AAAA,IACpE,UAAU,eAAa,SAAS,aAAa,EAAE;AAAA,IAC/C,cAAc;AAAA,IACd;AAAA,IACA,OAAO,SAAS;AAAA,IAChB,QAAqB,qBAAK,2BAA2B;AAAA,MACnD,SAAS;AAAA,MACT,UAAuB,qBAAK,MAAM;AAAA,QAChC,WAAW,qBAAO;AAAA,QAClB,MAAM;AAAA,QACN,MAAM;AAAA,MACR,CAAC;AAAA,IACH,CAAC;AAAA,IACD,QAAQ,aAA0B,qBAAK,YAAY;AAAA,MACjD;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACD,GAAG;AAAA,EACL,CAAC;AACH;AAqBO,IAAM,gBAAgB,WAAW,wBAAwB;AAChE,cAAc,cAAc;AAC5B,IAAO,yBAAQ;",
6
6
  "names": []
7
7
  }
@@ -34,7 +34,6 @@ function UnforwardedSelectControl(props, ref) {
34
34
  __nextHasNoMarginBottom: _,
35
35
  __next40pxDefaultSize: _next40pxDefaultSize,
36
36
  __next36pxDefaultSize: _next36pxDefaultSize,
37
- __shouldNotWarnDeprecated36pxSize: _shouldNotWarnDeprecated36pxSize,
38
37
  className,
39
38
  disabled = false,
40
39
  help,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/select-control/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport { Select, StyledInputBase } from './styles/select-control-styles';\nimport SelectControlChevronDown from './chevron-down';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction useUniqueId(idProp) {\n const instanceId = useInstanceId(SelectControl);\n const id = `inspector-select-control-${instanceId}`;\n return idProp || id;\n}\nfunction SelectOptions({\n options\n}) {\n return options.map(({\n id,\n label,\n value,\n ...optionProps\n }, index) => {\n const key = id || `${label}-${value}-${index}`;\n return /*#__PURE__*/_jsx(\"option\", {\n value: value,\n ...optionProps,\n children: label\n }, key);\n });\n}\nfunction UnforwardedSelectControl(props, ref) {\n const {\n // Prevent passing legacy props to internal components.\n __nextHasNoMarginBottom: _,\n __next40pxDefaultSize: _next40pxDefaultSize,\n __next36pxDefaultSize: _next36pxDefaultSize,\n __shouldNotWarnDeprecated36pxSize: _shouldNotWarnDeprecated36pxSize,\n className,\n disabled = false,\n help,\n hideLabelFromVision,\n id: idProp,\n label,\n multiple = false,\n onChange,\n options = [],\n size = 'default',\n value: valueProp,\n labelPosition = 'top',\n children,\n prefix,\n suffix,\n variant = 'default',\n ...restProps\n } = props;\n const id = useUniqueId(idProp);\n const helpId = help ? `${id}__help` : undefined;\n if (!options?.length && !children) {\n return null;\n }\n const handleOnChange = event => {\n if (props.multiple) {\n const selectedOptions = Array.from(event.target.options).filter(({\n selected\n }) => selected);\n const newValues = selectedOptions.map(({\n value\n }) => value);\n props.onChange?.(newValues, {\n event\n });\n return;\n }\n props.onChange?.(event.target.value, {\n event\n });\n };\n const classes = clsx('components-select-control', className);\n return /*#__PURE__*/_jsx(BaseControl, {\n help: help,\n id: id,\n className: classes,\n children: /*#__PURE__*/_jsx(StyledInputBase, {\n disabled: disabled,\n hideLabelFromVision: hideLabelFromVision,\n id: id,\n isBorderless: variant === 'minimal',\n label: label,\n size: size,\n suffix: suffix || !multiple && /*#__PURE__*/_jsx(SelectControlChevronDown, {}),\n prefix: prefix,\n labelPosition: labelPosition,\n __unstableInputWidth: variant === 'minimal' ? 'auto' : undefined,\n variant: variant,\n children: /*#__PURE__*/_jsx(Select, {\n ...restProps,\n \"aria-describedby\": helpId,\n className: \"components-select-control__input\",\n disabled: disabled,\n id: id,\n multiple: multiple,\n onChange: handleOnChange,\n ref: ref,\n selectSize: size,\n value: valueProp,\n variant: variant,\n children: children || /*#__PURE__*/_jsx(SelectOptions, {\n options: options\n })\n })\n })\n });\n}\n\n/**\n * `SelectControl` allows users to select from a single or multiple option menu.\n * It functions as a wrapper around the browser's native `<select>` element.\n *\n * ```jsx\n * import { SelectControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MySelectControl = () => {\n * const [ size, setSize ] = useState( '50%' );\n *\n * return (\n * <SelectControl\n * label=\"Size\"\n * value={ size }\n * options={ [\n * { label: 'Big', value: '100%' },\n * { label: 'Medium', value: '50%' },\n * { label: 'Small', value: '25%' },\n * ] }\n * onChange={ setSize }\n * />\n * );\n * };\n * ```\n */\nexport const SelectControl = forwardRef(UnforwardedSelectControl);\n\n// @ts-expect-error TS says: \"Property 'displayName' does not exist on type ...\"\nSelectControl.displayName = 'SelectControl';\nexport default SelectControl;"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAK3B,OAAO,iBAAiB;AACxB,SAAS,QAAQ,uBAAuB;AACxC,OAAO,8BAA8B;AACrC,SAAS,OAAO,YAAY;AAC5B,SAAS,YAAY,QAAQ;AAC3B,QAAM,aAAa,cAAc,aAAa;AAC9C,QAAM,KAAK,4BAA4B,UAAU;AACjD,SAAO,UAAU;AACnB;AACA,SAAS,cAAc;AAAA,EACrB;AACF,GAAG;AACD,SAAO,QAAQ,IAAI,CAAC;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAAG,UAAU;AACX,UAAM,MAAM,MAAM,GAAG,KAAK,IAAI,KAAK,IAAI,KAAK;AAC5C,WAAoB,qBAAK,UAAU;AAAA,MACjC;AAAA,MACA,GAAG;AAAA,MACH,UAAU;AAAA,IACZ,GAAG,GAAG;AAAA,EACR,CAAC;AACH;AACA,SAAS,yBAAyB,OAAO,KAAK;AAC5C,QAAM;AAAA;AAAA,IAEJ,yBAAyB;AAAA,IACzB,uBAAuB;AAAA,IACvB,uBAA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AA,QACpB,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAU;AAAA,QACV;AAAA,QACA,YAAY;AAAA,QACZ,OAAO;AAAA,QACP;AAAA,QACA,UAAU,YAAyB,qBAAK,eAAe;AAAA,UACrD;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH;AA4BO,IAAM,gBAAgB,WAAW,wBAAwB;AAGhE,cAAc,cAAc;AAC5B,IAAO,yBAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport { Select, StyledInputBase } from './styles/select-control-styles';\nimport SelectControlChevronDown from './chevron-down';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction useUniqueId(idProp) {\n const instanceId = useInstanceId(SelectControl);\n const id = `inspector-select-control-${instanceId}`;\n return idProp || id;\n}\nfunction SelectOptions({\n options\n}) {\n return options.map(({\n id,\n label,\n value,\n ...optionProps\n }, index) => {\n const key = id || `${label}-${value}-${index}`;\n return /*#__PURE__*/_jsx(\"option\", {\n value: value,\n ...optionProps,\n children: label\n }, key);\n });\n}\nfunction UnforwardedSelectControl(props, ref) {\n const {\n // Prevent passing legacy props to internal components.\n __nextHasNoMarginBottom: _,\n __next40pxDefaultSize: _next40pxDefaultSize,\n __next36pxDefaultSize: _next36pxDefaultSize,\n className,\n disabled = false,\n help,\n hideLabelFromVision,\n id: idProp,\n label,\n multiple = false,\n onChange,\n options = [],\n size = 'default',\n value: valueProp,\n labelPosition = 'top',\n children,\n prefix,\n suffix,\n variant = 'default',\n ...restProps\n } = props;\n const id = useUniqueId(idProp);\n const helpId = help ? `${id}__help` : undefined;\n if (!options?.length && !children) {\n return null;\n }\n const handleOnChange = event => {\n if (props.multiple) {\n const selectedOptions = Array.from(event.target.options).filter(({\n selected\n }) => selected);\n const newValues = selectedOptions.map(({\n value\n }) => value);\n props.onChange?.(newValues, {\n event\n });\n return;\n }\n props.onChange?.(event.target.value, {\n event\n });\n };\n const classes = clsx('components-select-control', className);\n return /*#__PURE__*/_jsx(BaseControl, {\n help: help,\n id: id,\n className: classes,\n children: /*#__PURE__*/_jsx(StyledInputBase, {\n disabled: disabled,\n hideLabelFromVision: hideLabelFromVision,\n id: id,\n isBorderless: variant === 'minimal',\n label: label,\n size: size,\n suffix: suffix || !multiple && /*#__PURE__*/_jsx(SelectControlChevronDown, {}),\n prefix: prefix,\n labelPosition: labelPosition,\n __unstableInputWidth: variant === 'minimal' ? 'auto' : undefined,\n variant: variant,\n children: /*#__PURE__*/_jsx(Select, {\n ...restProps,\n \"aria-describedby\": helpId,\n className: \"components-select-control__input\",\n disabled: disabled,\n id: id,\n multiple: multiple,\n onChange: handleOnChange,\n ref: ref,\n selectSize: size,\n value: valueProp,\n variant: variant,\n children: children || /*#__PURE__*/_jsx(SelectOptions, {\n options: options\n })\n })\n })\n });\n}\n\n/**\n * `SelectControl` allows users to select from a single or multiple option menu.\n * It functions as a wrapper around the browser's native `<select>` element.\n *\n * ```jsx\n * import { SelectControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MySelectControl = () => {\n * const [ size, setSize ] = useState( '50%' );\n *\n * return (\n * <SelectControl\n * label=\"Size\"\n * value={ size }\n * options={ [\n * { label: 'Big', value: '100%' },\n * { label: 'Medium', value: '50%' },\n * { label: 'Small', value: '25%' },\n * ] }\n * onChange={ setSize }\n * />\n * );\n * };\n * ```\n */\nexport const SelectControl = forwardRef(UnforwardedSelectControl);\n\n// @ts-expect-error TS says: \"Property 'displayName' does not exist on type ...\"\nSelectControl.displayName = 'SelectControl';\nexport default SelectControl;"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAK3B,OAAO,iBAAiB;A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