@wordpress/components 25.6.0 → 25.6.1

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 (438) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/CONTRIBUTING.md +1 -1
  3. package/build/color-palette/utils.js +2 -9
  4. package/build/color-palette/utils.js.map +1 -1
  5. package/build/sandbox/index.js +1 -1
  6. package/build/sandbox/index.js.map +1 -1
  7. package/build/slot-fill/bubbles-virtually/slot-fill-context.js +1 -1
  8. package/build/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
  9. package/build/snackbar/index.js +1 -1
  10. package/build/snackbar/index.js.map +1 -1
  11. package/build/theme/color-algorithms.js +2 -2
  12. package/build/theme/color-algorithms.js.map +1 -1
  13. package/build/toolbar/toolbar-item/index.js +1 -1
  14. package/build/toolbar/toolbar-item/index.js.map +1 -1
  15. package/build/toolbar/toolbar-item/index.native.js +1 -1
  16. package/build/toolbar/toolbar-item/index.native.js.map +1 -1
  17. package/build/ui/context/constants.js +2 -6
  18. package/build/ui/context/constants.js.map +1 -1
  19. package/build/ui/context/context-connect.js +1 -1
  20. package/build/ui/context/context-connect.js.map +1 -1
  21. package/build/ui/context/context-system-provider.js +1 -1
  22. package/build/ui/context/context-system-provider.js.map +1 -1
  23. package/build/ui/context/use-context-system.js +1 -1
  24. package/build/ui/context/use-context-system.js.map +1 -1
  25. package/build/utils/math.js +0 -12
  26. package/build/utils/math.js.map +1 -1
  27. package/build/utils/values.js +3 -66
  28. package/build/utils/values.js.map +1 -1
  29. package/build-module/color-palette/utils.js +0 -6
  30. package/build-module/color-palette/utils.js.map +1 -1
  31. package/build-module/sandbox/index.js +1 -1
  32. package/build-module/sandbox/index.js.map +1 -1
  33. package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js +1 -1
  34. package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
  35. package/build-module/snackbar/index.js +1 -1
  36. package/build-module/snackbar/index.js.map +1 -1
  37. package/build-module/theme/color-algorithms.js +2 -2
  38. package/build-module/theme/color-algorithms.js.map +1 -1
  39. package/build-module/toolbar/toolbar-item/index.js +1 -1
  40. package/build-module/toolbar/toolbar-item/index.js.map +1 -1
  41. package/build-module/toolbar/toolbar-item/index.native.js +1 -1
  42. package/build-module/toolbar/toolbar-item/index.native.js.map +1 -1
  43. package/build-module/ui/context/constants.js +0 -2
  44. package/build-module/ui/context/constants.js.map +1 -1
  45. package/build-module/ui/context/context-connect.js +1 -1
  46. package/build-module/ui/context/context-connect.js.map +1 -1
  47. package/build-module/ui/context/context-system-provider.js +1 -1
  48. package/build-module/ui/context/context-system-provider.js.map +1 -1
  49. package/build-module/ui/context/use-context-system.js +1 -1
  50. package/build-module/ui/context/use-context-system.js.map +1 -1
  51. package/build-module/utils/math.js +0 -11
  52. package/build-module/utils/math.js.map +1 -1
  53. package/build-module/utils/values.js +0 -60
  54. package/build-module/utils/values.js.map +1 -1
  55. package/build-types/circular-option-picker/stories/index.story.d.ts.map +1 -1
  56. package/build-types/color-palette/utils.d.ts +0 -1
  57. package/build-types/color-palette/utils.d.ts.map +1 -1
  58. package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
  59. package/build-types/item-group/item/hook.d.ts +1 -1
  60. package/build-types/sandbox/index.d.ts.map +1 -1
  61. package/build-types/search-control/stories/index.story.d.ts +0 -14
  62. package/build-types/search-control/stories/index.story.d.ts.map +1 -1
  63. package/build-types/ui/context/constants.d.ts +0 -2
  64. package/build-types/ui/context/constants.d.ts.map +1 -1
  65. package/build-types/utils/math.d.ts +0 -8
  66. package/build-types/utils/math.d.ts.map +1 -1
  67. package/build-types/utils/values.d.ts +0 -13
  68. package/build-types/utils/values.d.ts.map +1 -1
  69. package/package.json +19 -19
  70. package/src/alignment-matrix-control/stories/index.story.tsx +1 -1
  71. package/src/alignment-matrix-control/test/index.tsx +6 -2
  72. package/src/angle-picker-control/stories/index.story.tsx +1 -1
  73. package/src/animate/stories/index.story.tsx +1 -1
  74. package/src/base-control/stories/index.story.tsx +1 -1
  75. package/src/border-box-control/stories/index.story.tsx +1 -1
  76. package/src/border-control/stories/index.story.tsx +1 -1
  77. package/src/button/stories/index.story.tsx +1 -1
  78. package/src/button-group/stories/index.story.tsx +1 -1
  79. package/src/card/stories/index.story.tsx +1 -1
  80. package/src/checkbox-control/stories/index.story.tsx +1 -1
  81. package/src/circular-option-picker/stories/index.story.tsx +4 -1
  82. package/src/color-indicator/stories/index.story.tsx +1 -1
  83. package/src/color-palette/stories/index.story.tsx +1 -1
  84. package/src/color-palette/test/index.tsx +15 -9
  85. package/src/color-palette/test/utils.ts +0 -15
  86. package/src/color-palette/utils.ts +0 -7
  87. package/src/color-picker/stories/index.story.tsx +1 -1
  88. package/src/combobox-control/stories/index.story.tsx +1 -1
  89. package/src/confirm-dialog/stories/index.story.js +1 -1
  90. package/src/custom-gradient-picker/stories/index.story.tsx +1 -1
  91. package/src/date-time/stories/date-time.story.tsx +1 -1
  92. package/src/date-time/stories/date.story.tsx +1 -1
  93. package/src/date-time/stories/time.story.tsx +1 -1
  94. package/src/dimension-control/stories/index.story.tsx +1 -1
  95. package/src/disabled/stories/index.story.tsx +1 -1
  96. package/src/divider/stories/index.story.tsx +1 -1
  97. package/src/drop-zone/stories/index.story.tsx +1 -1
  98. package/src/dropdown-menu/stories/index.story.tsx +1 -1
  99. package/src/dropdown-menu-v2/stories/index.story.tsx +4 -1
  100. package/src/duotone-picker/stories/duotone-picker.story.tsx +1 -1
  101. package/src/duotone-picker/stories/duotone-swatch.story.tsx +1 -1
  102. package/src/elevation/stories/index.story.tsx +1 -1
  103. package/src/external-link/stories/index.story.tsx +1 -1
  104. package/src/flex/stories/index.story.tsx +1 -1
  105. package/src/focal-point-picker/stories/index.story.tsx +1 -1
  106. package/src/font-size-picker/stories/index.story.tsx +1 -1
  107. package/src/form-file-upload/stories/index.story.tsx +1 -1
  108. package/src/form-toggle/stories/index.story.tsx +1 -1
  109. package/src/form-token-field/stories/index.story.tsx +1 -1
  110. package/src/gradient-picker/stories/index.story.tsx +1 -1
  111. package/src/grid/stories/index.story.tsx +1 -1
  112. package/src/h-stack/stories/index.story.tsx +1 -1
  113. package/src/heading/stories/index.story.tsx +1 -1
  114. package/src/icon/stories/index.story.tsx +1 -1
  115. package/src/input-control/stories/index.story.tsx +1 -1
  116. package/src/item-group/stories/index.story.tsx +1 -1
  117. package/src/keyboard-shortcuts/stories/index.story.tsx +1 -1
  118. package/src/menu-group/stories/index.story.tsx +1 -1
  119. package/src/menu-items-choice/stories/index.story.tsx +1 -1
  120. package/src/navigable-container/stories/navigable-menu.story.tsx +1 -1
  121. package/src/navigable-container/stories/tabbable-container.story.tsx +1 -1
  122. package/src/navigation/stories/index.story.tsx +1 -1
  123. package/src/navigator/stories/index.story.tsx +1 -1
  124. package/src/notice/stories/index.story.tsx +1 -1
  125. package/src/number-control/stories/index.story.tsx +1 -1
  126. package/src/palette-edit/stories/index.story.tsx +1 -1
  127. package/src/panel/stories/index.story.tsx +1 -1
  128. package/src/placeholder/stories/index.story.tsx +1 -1
  129. package/src/progress-bar/stories/index.story.tsx +1 -1
  130. package/src/query-controls/stories/index.story.tsx +1 -1
  131. package/src/radio-control/stories/index.story.tsx +1 -1
  132. package/src/range-control/stories/index.story.tsx +1 -1
  133. package/src/resizable-box/stories/index.story.tsx +1 -1
  134. package/src/responsive-wrapper/stories/index.story.tsx +1 -1
  135. package/src/sandbox/index.tsx +4 -1
  136. package/src/sandbox/stories/index.story.tsx +1 -1
  137. package/src/scroll-lock/stories/index.story.tsx +1 -1
  138. package/src/scrollable/stories/index.story.tsx +1 -1
  139. package/src/search-control/stories/index.story.tsx +1 -1
  140. package/src/select-control/stories/index.story.tsx +1 -1
  141. package/src/slot-fill/stories/index.story.js +1 -1
  142. package/src/snackbar/stories/index.story.tsx +1 -1
  143. package/src/snackbar/stories/list.story.tsx +1 -1
  144. package/src/spacer/stories/index.story.tsx +1 -1
  145. package/src/spinner/stories/index.story.tsx +1 -1
  146. package/src/surface/stories/index.story.tsx +1 -1
  147. package/src/tab-panel/stories/index.story.tsx +1 -1
  148. package/src/text/test/index.tsx +1 -1
  149. package/src/text-control/stories/index.story.tsx +1 -1
  150. package/src/text-highlight/stories/index.story.tsx +1 -1
  151. package/src/textarea-control/stories/index.story.tsx +1 -1
  152. package/src/theme/stories/index.story.tsx +2 -2
  153. package/src/tip/stories/index.story.tsx +1 -1
  154. package/src/toggle-control/stories/index.story.tsx +1 -1
  155. package/src/toggle-group-control/stories/index.story.tsx +1 -1
  156. package/src/toolbar/stories/index.story.tsx +1 -1
  157. package/src/tools-panel/stories/index.story.tsx +1 -1
  158. package/src/tooltip/stories/index.story.js +1 -1
  159. package/src/tree-select/stories/index.story.tsx +1 -1
  160. package/src/truncate/stories/index.story.tsx +1 -1
  161. package/src/ui/context/constants.js +0 -2
  162. package/src/unit-control/stories/index.story.tsx +1 -1
  163. package/src/utils/math.js +0 -11
  164. package/src/utils/values.js +0 -81
  165. package/src/v-stack/stories/index.story.tsx +1 -1
  166. package/src/view/stories/index.story.tsx +1 -1
  167. package/src/visually-hidden/stories/index.story.tsx +1 -1
  168. package/src/z-stack/stories/index.story.tsx +1 -1
  169. package/tsconfig.tsbuildinfo +1 -1
  170. package/build/ui/utils/get-high-dpi.js +0 -16
  171. package/build/ui/utils/get-high-dpi.js.map +0 -1
  172. package/build/utils/browsers.js +0 -32
  173. package/build/utils/browsers.js.map +0 -1
  174. package/build/utils/events.js +0 -43
  175. package/build/utils/events.js.map +0 -1
  176. package/build-module/ui/utils/get-high-dpi.js +0 -11
  177. package/build-module/ui/utils/get-high-dpi.js.map +0 -1
  178. package/build-module/utils/browsers.js +0 -25
  179. package/build-module/utils/browsers.js.map +0 -1
  180. package/build-module/utils/events.js +0 -37
  181. package/build-module/utils/events.js.map +0 -1
  182. package/build-types/alignment-matrix-control/stories/index.d.ts +0 -14
  183. package/build-types/alignment-matrix-control/stories/index.d.ts.map +0 -1
  184. package/build-types/angle-picker-control/stories/index.d.ts +0 -15
  185. package/build-types/angle-picker-control/stories/index.d.ts.map +0 -1
  186. package/build-types/animate/stories/index.d.ts +0 -18
  187. package/build-types/animate/stories/index.d.ts.map +0 -1
  188. package/build-types/base-control/stories/index.d.ts +0 -25
  189. package/build-types/base-control/stories/index.d.ts.map +0 -1
  190. package/build-types/border-box-control/stories/index.d.ts +0 -17
  191. package/build-types/border-box-control/stories/index.d.ts.map +0 -1
  192. package/build-types/border-control/stories/index.d.ts +0 -119
  193. package/build-types/border-control/stories/index.d.ts.map +0 -1
  194. package/build-types/button/stories/e2e/index.d.ts +0 -15
  195. package/build-types/button/stories/e2e/index.d.ts.map +0 -1
  196. package/build-types/button/stories/index.d.ts +0 -20
  197. package/build-types/button/stories/index.d.ts.map +0 -1
  198. package/build-types/button-group/stories/index.d.ts +0 -12
  199. package/build-types/button-group/stories/index.d.ts.map +0 -1
  200. package/build-types/card/stories/index.d.ts +0 -32
  201. package/build-types/card/stories/index.d.ts.map +0 -1
  202. package/build-types/checkbox-control/stories/index.d.ts +0 -13
  203. package/build-types/checkbox-control/stories/index.d.ts.map +0 -1
  204. package/build-types/circular-option-picker/stories/index.d.ts +0 -14
  205. package/build-types/circular-option-picker/stories/index.d.ts.map +0 -1
  206. package/build-types/color-indicator/stories/index.d.ts +0 -12
  207. package/build-types/color-indicator/stories/index.d.ts.map +0 -1
  208. package/build-types/color-palette/stories/index.d.ts +0 -46
  209. package/build-types/color-palette/stories/index.d.ts.map +0 -1
  210. package/build-types/color-picker/stories/index.d.ts +0 -19
  211. package/build-types/color-picker/stories/index.d.ts.map +0 -1
  212. package/build-types/combobox-control/stories/index.d.ts +0 -18
  213. package/build-types/combobox-control/stories/index.d.ts.map +0 -1
  214. package/build-types/custom-gradient-picker/stories/index.d.ts +0 -12
  215. package/build-types/custom-gradient-picker/stories/index.d.ts.map +0 -1
  216. package/build-types/date-time/stories/date-time.d.ts +0 -14
  217. package/build-types/date-time/stories/date-time.d.ts.map +0 -1
  218. package/build-types/date-time/stories/date.d.ts +0 -14
  219. package/build-types/date-time/stories/date.d.ts.map +0 -1
  220. package/build-types/date-time/stories/time.d.ts +0 -12
  221. package/build-types/date-time/stories/time.d.ts.map +0 -1
  222. package/build-types/dimension-control/stories/index.d.ts +0 -12
  223. package/build-types/dimension-control/stories/index.d.ts.map +0 -1
  224. package/build-types/disabled/stories/index.d.ts +0 -13
  225. package/build-types/disabled/stories/index.d.ts.map +0 -1
  226. package/build-types/divider/stories/index.d.ts +0 -11
  227. package/build-types/divider/stories/index.d.ts.map +0 -1
  228. package/build-types/draggable/stories/index.d.ts +0 -20
  229. package/build-types/draggable/stories/index.d.ts.map +0 -1
  230. package/build-types/drop-zone/stories/index.d.ts +0 -12
  231. package/build-types/drop-zone/stories/index.d.ts.map +0 -1
  232. package/build-types/dropdown/stories/index.d.ts +0 -23
  233. package/build-types/dropdown/stories/index.d.ts.map +0 -1
  234. package/build-types/dropdown-menu/stories/index.d.ts +0 -14
  235. package/build-types/dropdown-menu/stories/index.d.ts.map +0 -1
  236. package/build-types/dropdown-menu-v2/stories/index.d.ts +0 -11
  237. package/build-types/dropdown-menu-v2/stories/index.d.ts.map +0 -1
  238. package/build-types/duotone-picker/stories/duotone-picker.d.ts +0 -12
  239. package/build-types/duotone-picker/stories/duotone-picker.d.ts.map +0 -1
  240. package/build-types/duotone-picker/stories/duotone-swatch.d.ts +0 -14
  241. package/build-types/duotone-picker/stories/duotone-swatch.d.ts.map +0 -1
  242. package/build-types/elevation/stories/index.d.ts +0 -22
  243. package/build-types/elevation/stories/index.d.ts.map +0 -1
  244. package/build-types/external-link/stories/index.d.ts +0 -12
  245. package/build-types/external-link/stories/index.d.ts.map +0 -1
  246. package/build-types/flex/stories/index.d.ts +0 -13
  247. package/build-types/flex/stories/index.d.ts.map +0 -1
  248. package/build-types/focal-point-picker/stories/index.d.ts +0 -15
  249. package/build-types/focal-point-picker/stories/index.d.ts.map +0 -1
  250. package/build-types/font-size-picker/stories/e2e/index.d.ts +0 -16
  251. package/build-types/font-size-picker/stories/e2e/index.d.ts.map +0 -1
  252. package/build-types/font-size-picker/stories/index.d.ts +0 -31
  253. package/build-types/font-size-picker/stories/index.d.ts.map +0 -1
  254. package/build-types/form-file-upload/stories/index.d.ts +0 -23
  255. package/build-types/form-file-upload/stories/index.d.ts.map +0 -1
  256. package/build-types/form-toggle/stories/index.d.ts +0 -12
  257. package/build-types/form-toggle/stories/index.d.ts.map +0 -1
  258. package/build-types/form-token-field/stories/index.d.ts +0 -26
  259. package/build-types/form-token-field/stories/index.d.ts.map +0 -1
  260. package/build-types/gradient-picker/stories/index.d.ts +0 -14
  261. package/build-types/gradient-picker/stories/index.d.ts.map +0 -1
  262. package/build-types/grid/stories/index.d.ts +0 -9
  263. package/build-types/grid/stories/index.d.ts.map +0 -1
  264. package/build-types/guide/stories/index.d.ts +0 -9
  265. package/build-types/guide/stories/index.d.ts.map +0 -1
  266. package/build-types/h-stack/stories/e2e/index.d.ts +0 -9
  267. package/build-types/h-stack/stories/e2e/index.d.ts.map +0 -1
  268. package/build-types/h-stack/stories/index.d.ts +0 -9
  269. package/build-types/h-stack/stories/index.d.ts.map +0 -1
  270. package/build-types/heading/stories/index.d.ts +0 -12
  271. package/build-types/heading/stories/index.d.ts.map +0 -1
  272. package/build-types/icon/stories/index.d.ts +0 -22
  273. package/build-types/icon/stories/index.d.ts.map +0 -1
  274. package/build-types/input-control/stories/index.d.ts +0 -28
  275. package/build-types/input-control/stories/index.d.ts.map +0 -1
  276. package/build-types/item-group/stories/index.d.ts +0 -15
  277. package/build-types/item-group/stories/index.d.ts.map +0 -1
  278. package/build-types/keyboard-shortcuts/stories/index.d.ts +0 -12
  279. package/build-types/keyboard-shortcuts/stories/index.d.ts.map +0 -1
  280. package/build-types/menu-group/stories/index.d.ts +0 -17
  281. package/build-types/menu-group/stories/index.d.ts.map +0 -1
  282. package/build-types/menu-items-choice/stories/index.d.ts +0 -12
  283. package/build-types/menu-items-choice/stories/index.d.ts.map +0 -1
  284. package/build-types/modal/stories/index.d.ts +0 -10
  285. package/build-types/modal/stories/index.d.ts.map +0 -1
  286. package/build-types/navigable-container/stories/navigable-menu.d.ts +0 -12
  287. package/build-types/navigable-container/stories/navigable-menu.d.ts.map +0 -1
  288. package/build-types/navigable-container/stories/tabbable-container.d.ts +0 -12
  289. package/build-types/navigable-container/stories/tabbable-container.d.ts.map +0 -1
  290. package/build-types/navigation/stories/index.d.ts +0 -18
  291. package/build-types/navigation/stories/index.d.ts.map +0 -1
  292. package/build-types/navigator/stories/index.d.ts +0 -11
  293. package/build-types/navigator/stories/index.d.ts.map +0 -1
  294. package/build-types/notice/stories/index.d.ts +0 -17
  295. package/build-types/notice/stories/index.d.ts.map +0 -1
  296. package/build-types/number-control/stories/index.d.ts +0 -25
  297. package/build-types/number-control/stories/index.d.ts.map +0 -1
  298. package/build-types/palette-edit/stories/index.d.ts +0 -13
  299. package/build-types/palette-edit/stories/index.d.ts.map +0 -1
  300. package/build-types/panel/stories/index.d.ts +0 -19
  301. package/build-types/panel/stories/index.d.ts.map +0 -1
  302. package/build-types/placeholder/stories/index.d.ts +0 -12
  303. package/build-types/placeholder/stories/index.d.ts.map +0 -1
  304. package/build-types/popover/stories/e2e/index.d.ts +0 -8
  305. package/build-types/popover/stories/e2e/index.d.ts.map +0 -1
  306. package/build-types/popover/stories/index.d.ts +0 -13
  307. package/build-types/popover/stories/index.d.ts.map +0 -1
  308. package/build-types/progress-bar/stories/index.d.ts +0 -12
  309. package/build-types/progress-bar/stories/index.d.ts.map +0 -1
  310. package/build-types/query-controls/stories/index.d.ts +0 -13
  311. package/build-types/query-controls/stories/index.d.ts.map +0 -1
  312. package/build-types/radio-control/stories/index.d.ts +0 -12
  313. package/build-types/radio-control/stories/index.d.ts.map +0 -1
  314. package/build-types/range-control/stories/index.d.ts +0 -48
  315. package/build-types/range-control/stories/index.d.ts.map +0 -1
  316. package/build-types/resizable-box/stories/index.d.ts +0 -61
  317. package/build-types/resizable-box/stories/index.d.ts.map +0 -1
  318. package/build-types/responsive-wrapper/stories/index.d.ts +0 -22
  319. package/build-types/responsive-wrapper/stories/index.d.ts.map +0 -1
  320. package/build-types/sandbox/stories/index.d.ts +0 -12
  321. package/build-types/sandbox/stories/index.d.ts.map +0 -1
  322. package/build-types/scroll-lock/stories/index.d.ts +0 -9
  323. package/build-types/scroll-lock/stories/index.d.ts.map +0 -1
  324. package/build-types/scrollable/stories/index.d.ts +0 -9
  325. package/build-types/scrollable/stories/index.d.ts.map +0 -1
  326. package/build-types/search-control/stories/index.d.ts +0 -47
  327. package/build-types/search-control/stories/index.d.ts.map +0 -1
  328. package/build-types/select-control/stories/index.d.ts +0 -19
  329. package/build-types/select-control/stories/index.d.ts.map +0 -1
  330. package/build-types/snackbar/stories/index.d.ts +0 -16
  331. package/build-types/snackbar/stories/index.d.ts.map +0 -1
  332. package/build-types/snackbar/stories/list.d.ts +0 -12
  333. package/build-types/snackbar/stories/list.d.ts.map +0 -1
  334. package/build-types/spacer/stories/index.d.ts +0 -12
  335. package/build-types/spacer/stories/index.d.ts.map +0 -1
  336. package/build-types/spinner/stories/index.d.ts +0 -13
  337. package/build-types/spinner/stories/index.d.ts.map +0 -1
  338. package/build-types/surface/stories/index.d.ts +0 -12
  339. package/build-types/surface/stories/index.d.ts.map +0 -1
  340. package/build-types/tab-panel/stories/index.d.ts +0 -16
  341. package/build-types/tab-panel/stories/index.d.ts.map +0 -1
  342. package/build-types/text-control/stories/index.d.ts +0 -13
  343. package/build-types/text-control/stories/index.d.ts.map +0 -1
  344. package/build-types/text-highlight/stories/index.d.ts +0 -12
  345. package/build-types/text-highlight/stories/index.d.ts.map +0 -1
  346. package/build-types/textarea-control/stories/index.d.ts +0 -12
  347. package/build-types/textarea-control/stories/index.d.ts.map +0 -1
  348. package/build-types/theme/stories/index.d.ts +0 -17
  349. package/build-types/theme/stories/index.d.ts.map +0 -1
  350. package/build-types/tip/stories/index.d.ts +0 -12
  351. package/build-types/tip/stories/index.d.ts.map +0 -1
  352. package/build-types/toggle-control/stories/index.d.ts +0 -13
  353. package/build-types/toggle-control/stories/index.d.ts.map +0 -1
  354. package/build-types/toggle-group-control/stories/index.d.ts +0 -27
  355. package/build-types/toggle-group-control/stories/index.d.ts.map +0 -1
  356. package/build-types/toolbar/stories/index.d.ts +0 -14
  357. package/build-types/toolbar/stories/index.d.ts.map +0 -1
  358. package/build-types/tools-panel/stories/index.d.ts +0 -17
  359. package/build-types/tools-panel/stories/index.d.ts.map +0 -1
  360. package/build-types/tree-grid/stories/index.d.ts +0 -13
  361. package/build-types/tree-grid/stories/index.d.ts.map +0 -1
  362. package/build-types/tree-select/stories/index.d.ts +0 -12
  363. package/build-types/tree-select/stories/index.d.ts.map +0 -1
  364. package/build-types/truncate/stories/index.d.ts +0 -13
  365. package/build-types/truncate/stories/index.d.ts.map +0 -1
  366. package/build-types/ui/control-group/component.d.ts +0 -27
  367. package/build-types/ui/control-group/component.d.ts.map +0 -1
  368. package/build-types/ui/control-group/context.d.ts +0 -4
  369. package/build-types/ui/control-group/context.d.ts.map +0 -1
  370. package/build-types/ui/control-group/hook.d.ts +0 -266
  371. package/build-types/ui/control-group/hook.d.ts.map +0 -1
  372. package/build-types/ui/control-group/index.d.ts +0 -4
  373. package/build-types/ui/control-group/index.d.ts.map +0 -1
  374. package/build-types/ui/control-group/styles.d.ts +0 -8
  375. package/build-types/ui/control-group/styles.d.ts.map +0 -1
  376. package/build-types/ui/control-group/types.d.ts +0 -27
  377. package/build-types/ui/control-group/types.d.ts.map +0 -1
  378. package/build-types/ui/control-label/component.d.ts +0 -23
  379. package/build-types/ui/control-label/component.d.ts.map +0 -1
  380. package/build-types/ui/control-label/hook.d.ts +0 -265
  381. package/build-types/ui/control-label/hook.d.ts.map +0 -1
  382. package/build-types/ui/control-label/index.d.ts +0 -3
  383. package/build-types/ui/control-label/index.d.ts.map +0 -1
  384. package/build-types/ui/control-label/styles.d.ts +0 -7
  385. package/build-types/ui/control-label/styles.d.ts.map +0 -1
  386. package/build-types/ui/control-label/types.d.ts +0 -9
  387. package/build-types/ui/control-label/types.d.ts.map +0 -1
  388. package/build-types/ui/form-group/form-group-content.d.ts +0 -7
  389. package/build-types/ui/form-group/form-group-content.d.ts.map +0 -1
  390. package/build-types/ui/form-group/form-group-context.d.ts +0 -11
  391. package/build-types/ui/form-group/form-group-context.d.ts.map +0 -1
  392. package/build-types/ui/form-group/form-group-help.d.ts +0 -18
  393. package/build-types/ui/form-group/form-group-help.d.ts.map +0 -1
  394. package/build-types/ui/form-group/form-group-label.d.ts +0 -8
  395. package/build-types/ui/form-group/form-group-label.d.ts.map +0 -1
  396. package/build-types/ui/form-group/form-group-styles.d.ts +0 -2
  397. package/build-types/ui/form-group/form-group-styles.d.ts.map +0 -1
  398. package/build-types/ui/form-group/form-group.d.ts +0 -53
  399. package/build-types/ui/form-group/form-group.d.ts.map +0 -1
  400. package/build-types/ui/form-group/index.d.ts +0 -4
  401. package/build-types/ui/form-group/index.d.ts.map +0 -1
  402. package/build-types/ui/form-group/types.d.ts +0 -30
  403. package/build-types/ui/form-group/types.d.ts.map +0 -1
  404. package/build-types/ui/form-group/use-form-group.d.ts +0 -593
  405. package/build-types/ui/form-group/use-form-group.d.ts.map +0 -1
  406. package/build-types/ui/index.d.ts +0 -6
  407. package/build-types/ui/index.d.ts.map +0 -1
  408. package/build-types/ui/spinner/component.d.ts +0 -13
  409. package/build-types/ui/spinner/component.d.ts.map +0 -1
  410. package/build-types/ui/spinner/index.d.ts +0 -2
  411. package/build-types/ui/spinner/index.d.ts.map +0 -1
  412. package/build-types/ui/spinner/styles.d.ts +0 -13
  413. package/build-types/ui/spinner/styles.d.ts.map +0 -1
  414. package/build-types/ui/spinner/utils.d.ts +0 -3
  415. package/build-types/ui/spinner/utils.d.ts.map +0 -1
  416. package/build-types/ui/utils/get-high-dpi.d.ts +0 -3
  417. package/build-types/ui/utils/get-high-dpi.d.ts.map +0 -1
  418. package/build-types/unit-control/stories/index.d.ts +0 -33
  419. package/build-types/unit-control/stories/index.d.ts.map +0 -1
  420. package/build-types/utils/browsers.d.ts +0 -11
  421. package/build-types/utils/browsers.d.ts.map +0 -1
  422. package/build-types/utils/events.d.ts +0 -11
  423. package/build-types/utils/events.d.ts.map +0 -1
  424. package/build-types/v-stack/stories/e2e/index.d.ts +0 -9
  425. package/build-types/v-stack/stories/e2e/index.d.ts.map +0 -1
  426. package/build-types/v-stack/stories/index.d.ts +0 -13
  427. package/build-types/v-stack/stories/index.d.ts.map +0 -1
  428. package/build-types/view/stories/index.d.ts +0 -12
  429. package/build-types/view/stories/index.d.ts.map +0 -1
  430. package/build-types/visually-hidden/stories/index.d.ts +0 -14
  431. package/build-types/visually-hidden/stories/index.d.ts.map +0 -1
  432. package/build-types/z-stack/stories/index.d.ts +0 -6
  433. package/build-types/z-stack/stories/index.d.ts.map +0 -1
  434. package/src/ui/utils/get-high-dpi.ts +0 -20
  435. package/src/utils/browsers.js +0 -36
  436. package/src/utils/events.ts +0 -50
  437. package/src/utils/test/events.js +0 -63
  438. package/src/utils/test/values.js +0 -101
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ### Bug Fix
6
+
7
+ - `SandBox`: Fix the cleanup method in useEffect ([#53796](https://github.com/WordPress/gutenberg/pull/53796)).
8
+
5
9
  ## 25.6.0 (2023-08-16)
6
10
 
7
11
  ### Enhancements
@@ -26,6 +30,7 @@
26
30
  - `ControlGroup`, `FormGroup`, `ControlLabel`, `Spinner`: Remove unused `ui/` components from the codebase ([#52953](https://github.com/WordPress/gutenberg/pull/52953)).
27
31
  - `MenuItem`: Convert to TypeScript ([#53132](https://github.com/WordPress/gutenberg/pull/53132)).
28
32
  - `MenuGroup`: Add Storybook stories ([#53090](https://github.com/WordPress/gutenberg/pull/53090)).
33
+ - Components: Remove unnecessary utils ([#53679](https://github.com/WordPress/gutenberg/pull/53679)).
29
34
 
30
35
  ## 25.5.0 (2023-08-10)
31
36
 
package/CONTRIBUTING.md CHANGED
@@ -622,7 +622,7 @@ Given a component folder (e.g. `packages/components/src/unit-control`):
622
622
  const meta: ComponentMeta< typeof MyComponent > = {
623
623
  parameters: {
624
624
  controls: { expanded: true },
625
- docs: { source: { state: 'open' } },
625
+ docs: { canvas: { sourceState: 'shown' } },
626
626
  },
627
627
  };
628
628
  ```
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.showTransparentBackground = exports.normalizeColorValue = exports.isMultiplePaletteObject = exports.isMultiplePaletteArray = exports.extractColorNameFromCurrentValue = void 0;
7
+ exports.normalizeColorValue = exports.isMultiplePaletteObject = exports.isMultiplePaletteArray = exports.extractColorNameFromCurrentValue = void 0;
8
8
  var _colord = require("colord");
9
9
  var _names = _interopRequireDefault(require("colord/plugins/names"));
10
10
  var _a11y = _interopRequireDefault(require("colord/plugins/a11y"));
@@ -47,17 +47,10 @@ const extractColorNameFromCurrentValue = (currentValue, colors = [], showMultipl
47
47
  // translators: shown when the user has picked a custom color (i.e not in the palette of colors).
48
48
  return (0, _i18n.__)('Custom');
49
49
  };
50
- exports.extractColorNameFromCurrentValue = extractColorNameFromCurrentValue;
51
- const showTransparentBackground = currentValue => {
52
- if (typeof currentValue === 'undefined') {
53
- return true;
54
- }
55
- return (0, _colord.colord)(currentValue).alpha() === 0;
56
- };
57
50
 
58
51
  // The PaletteObject type has a `colors` property (an array of ColorObject),
59
52
  // while the ColorObject type has a `color` property (the CSS color value).
60
- exports.showTransparentBackground = showTransparentBackground;
53
+ exports.extractColorNameFromCurrentValue = extractColorNameFromCurrentValue;
61
54
  const isMultiplePaletteObject = obj => Array.isArray(obj.colors) && !('color' in obj);
62
55
  exports.isMultiplePaletteObject = isMultiplePaletteObject;
63
56
  const isMultiplePaletteArray = arr => {
@@ -1 +1 @@
1
- {"version":3,"names":["_colord","require","_names","_interopRequireDefault","_a11y","_i18n","extend","namesPlugin","a11yPlugin","extractColorNameFromCurrentValue","currentValue","colors","showMultiplePalettes","currentValueIsCssVariable","test","normalizedCurrentValue","colord","toHex","colorPalettes","paletteColors","name","colorName","color","colorValue","normalizedColorValue","__","exports","showTransparentBackground","alpha","isMultiplePaletteObject","obj","Array","isArray","isMultiplePaletteArray","arr","length","every","colorObj","normalizeColorValue","value","element","ownerDocument","defaultView","computedBackgroundColor","getComputedStyle","backgroundColor"],"sources":["@wordpress/components/src/color-palette/utils.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { ColorObject, ColorPaletteProps, PaletteObject } from './types';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nexport const extractColorNameFromCurrentValue = (\n\tcurrentValue?: ColorPaletteProps[ 'value' ],\n\tcolors: ColorPaletteProps[ 'colors' ] = [],\n\tshowMultiplePalettes: boolean = false\n) => {\n\tif ( ! currentValue ) {\n\t\treturn '';\n\t}\n\n\tconst currentValueIsCssVariable = /^var\\(/.test( currentValue );\n\tconst normalizedCurrentValue = currentValueIsCssVariable\n\t\t? currentValue\n\t\t: colord( currentValue ).toHex();\n\n\t// Normalize format of `colors` to simplify the following loop\n\ttype normalizedPaletteObject = { colors: ColorObject[] };\n\tconst colorPalettes: normalizedPaletteObject[] = showMultiplePalettes\n\t\t? ( colors as PaletteObject[] )\n\t\t: [ { colors: colors as ColorObject[] } ];\n\tfor ( const { colors: paletteColors } of colorPalettes ) {\n\t\tfor ( const { name: colorName, color: colorValue } of paletteColors ) {\n\t\t\tconst normalizedColorValue = currentValueIsCssVariable\n\t\t\t\t? colorValue\n\t\t\t\t: colord( colorValue ).toHex();\n\n\t\t\tif ( normalizedCurrentValue === normalizedColorValue ) {\n\t\t\t\treturn colorName;\n\t\t\t}\n\t\t}\n\t}\n\n\t// translators: shown when the user has picked a custom color (i.e not in the palette of colors).\n\treturn __( 'Custom' );\n};\n\nexport const showTransparentBackground = ( currentValue?: string ) => {\n\tif ( typeof currentValue === 'undefined' ) {\n\t\treturn true;\n\t}\n\treturn colord( currentValue ).alpha() === 0;\n};\n\n// The PaletteObject type has a `colors` property (an array of ColorObject),\n// while the ColorObject type has a `color` property (the CSS color value).\nexport const isMultiplePaletteObject = (\n\tobj: PaletteObject | ColorObject\n): obj is PaletteObject =>\n\tArray.isArray( ( obj as PaletteObject ).colors ) && ! ( 'color' in obj );\n\nexport const isMultiplePaletteArray = (\n\tarr: ( PaletteObject | ColorObject )[]\n): arr is PaletteObject[] => {\n\treturn (\n\t\tarr.length > 0 &&\n\t\tarr.every( ( colorObj ) => isMultiplePaletteObject( colorObj ) )\n\t);\n};\n\n/**\n * Transform a CSS variable used as background color into the color value itself.\n *\n * @param value The color value that may be a CSS variable.\n * @param element The element for which to get the computed style.\n * @return The background color value computed from a element.\n */\nexport const normalizeColorValue = (\n\tvalue: string | undefined,\n\telement: HTMLElement | null\n) => {\n\tconst currentValueIsCssVariable = /^var\\(/.test( value ?? '' );\n\n\tif ( ! currentValueIsCssVariable || element === null ) {\n\t\treturn value;\n\t}\n\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst computedBackgroundColor =\n\t\tdefaultView?.getComputedStyle( element ).backgroundColor;\n\n\treturn computedBackgroundColor\n\t\t? colord( computedBackgroundColor ).toHex()\n\t\t: value;\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AAKA,IAAAI,KAAA,GAAAJ,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAQA,IAAAK,cAAM,EAAE,CAAEC,cAAW,EAAEC,aAAU,CAAG,CAAC;AAE9B,MAAMC,gCAAgC,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nB,MAAO,CAAC,IAAI,EAAI,OAAO,IAAImB,GAAG,CAAE;AAACJ,OAAA,CAAAG,uBAAA,GAAAA,uBAAA;AAEnE,MAAMI,sBAAsB,GAClCC,GAAsC,IACV;EAC5B,OACCA,GAAG,CAACC,MAAM,GAAG,CAAC,IACdD,GAAG,CAACE,KAAK,CAAIC,QAAQ,IAAMR,uBAAuB,CAAEQ,QAAS,CAAE,CAAC;AAElE,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANAX,OAAA,CAAAO,sBAAA,GAAAA,sBAAA;AAOO,MAAMK,mBAAmB,GAAGA,CAClCC,KAAyB,EACzBC,OAA2B,KACvB;EACJ,MAAM3B,yBAAyB,GAAG,QAAQ,CAACC,IAAI,CAAEyB,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAG,CAAC;EAE9D,IAAK,CAAE1B,yBAAyB,IAAI2B,OAAO,KAAK,IAAI,EAAG;IACtD,OAAOD,KAAK;EACb;EAEA,MAAM;IAAEE;EAAc,CAAC,GAAGD,OAAO;EACjC,MAAM;IAAEE;EAAY,CAAC,GAAGD,aAAa;EACrC,MAAME,uBAAuB,GAC5BD,WAAW,EAAEE,gBAAgB,CAAEJ,OAAQ,CAAC,CAACK,eAAe;EAEzD,OAAOF,uBAAuB,GAC3B,IAAA3B,cAAM,EAAE2B,uBAAwB,CAAC,CAAC1B,KAAK,CAAC,CAAC,GACzCsB,KAAK;AACT,CAAC;AAACb,OAAA,CAAAY,mBAAA,GAAAA,mBAAA"}
1
+ {"version":3,"names":["_colord","require","_names","_interopRequireDefault","_a11y","_i18n","extend","namesPlugin","a11yPlugin","extractColorNameFromCurrentValue","currentValue","colors","showMultiplePalettes","currentValueIsCssVariable","test","normalizedCurrentValue","colord","toHex","colorPalettes","paletteColors","name","colorName","color","colorValue","normalizedColorValue","__","exports","isMultiplePaletteObject","obj","Array","isArray","isMultiplePaletteArray","arr","length","every","colorObj","normalizeColorValue","value","element","ownerDocument","defaultView","computedBackgroundColor","getComputedStyle","backgroundColor"],"sources":["@wordpress/components/src/color-palette/utils.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { ColorObject, ColorPaletteProps, PaletteObject } from './types';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nexport const extractColorNameFromCurrentValue = (\n\tcurrentValue?: ColorPaletteProps[ 'value' ],\n\tcolors: ColorPaletteProps[ 'colors' ] = [],\n\tshowMultiplePalettes: boolean = false\n) => {\n\tif ( ! currentValue ) {\n\t\treturn '';\n\t}\n\n\tconst currentValueIsCssVariable = /^var\\(/.test( currentValue );\n\tconst normalizedCurrentValue = currentValueIsCssVariable\n\t\t? currentValue\n\t\t: colord( currentValue ).toHex();\n\n\t// Normalize format of `colors` to simplify the following loop\n\ttype normalizedPaletteObject = { colors: ColorObject[] };\n\tconst colorPalettes: normalizedPaletteObject[] = showMultiplePalettes\n\t\t? ( colors as PaletteObject[] )\n\t\t: [ { colors: colors as ColorObject[] } ];\n\tfor ( const { colors: paletteColors } of colorPalettes ) {\n\t\tfor ( const { name: colorName, color: colorValue } of paletteColors ) {\n\t\t\tconst normalizedColorValue = currentValueIsCssVariable\n\t\t\t\t? colorValue\n\t\t\t\t: colord( colorValue ).toHex();\n\n\t\t\tif ( normalizedCurrentValue === normalizedColorValue ) {\n\t\t\t\treturn colorName;\n\t\t\t}\n\t\t}\n\t}\n\n\t// translators: shown when the user has picked a custom color (i.e not in the palette of colors).\n\treturn __( 'Custom' );\n};\n\n// The PaletteObject type has a `colors` property (an array of ColorObject),\n// while the ColorObject type has a `color` property (the CSS color value).\nexport const isMultiplePaletteObject = (\n\tobj: PaletteObject | ColorObject\n): obj is PaletteObject =>\n\tArray.isArray( ( obj as PaletteObject ).colors ) && ! ( 'color' in obj );\n\nexport const isMultiplePaletteArray = (\n\tarr: ( PaletteObject | ColorObject )[]\n): arr is PaletteObject[] => {\n\treturn (\n\t\tarr.length > 0 &&\n\t\tarr.every( ( colorObj ) => isMultiplePaletteObject( colorObj ) )\n\t);\n};\n\n/**\n * Transform a CSS variable used as background color into the color value itself.\n *\n * @param value The color value that may be a CSS variable.\n * @param element The element for which to get the computed style.\n * @return The background color value computed from a element.\n */\nexport const normalizeColorValue = (\n\tvalue: string | undefined,\n\telement: HTMLElement | null\n) => {\n\tconst currentValueIsCssVariable = /^var\\(/.test( value ?? '' );\n\n\tif ( ! currentValueIsCssVariable || element === null ) {\n\t\treturn value;\n\t}\n\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst computedBackgroundColor =\n\t\tdefaultView?.getComputedStyle( element ).backgroundColor;\n\n\treturn computedBackgroundColor\n\t\t? colord( computedBackgroundColor ).toHex()\n\t\t: value;\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AAKA,IAAAI,KAAA,GAAAJ,OAAA;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAQA,IAAAK,cAAM,EAAE,CAAEC,cAAW,EAAEC,aAAU,CAAG,CAAC;AAE9B,MAAMC,gCAAgC,GAAGA,CAC/CC,YAA2C,EAC3CC,MAAqC,GAAG,EAAE,EAC1CC,oBAA6B,GAAG,KAAK,KACjC;EACJ,IAAK,CAAEF,YAAY,EAAG;IACrB,OAAO,EAAE;EACV;EAEA,MAAMG,yBAAyB,GAAG,QAAQ,CAACC,IAAI,CAAEJ,YAAa,CAAC;EAC/D,MAAMK,sBAAsB,GAAGF,yBAAyB,GACrDH,YAAY,GACZ,IAAAM,cAAM,EAAEN,YAAa,CAAC,CAACO,KAAK,CAAC,CAAC;;EAEjC;;EAEA,MAAMC,aAAwC,GAAG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;EAEA,MAAM;IAAEE;EAAc,CAAC,GAAGD,OAAO;EACjC,MAAM;IAAEE;EAAY,CAAC,GAAGD,aAAa;EACrC,MAAME,uBAAuB,GAC5BD,WAAW,EAAEE,gBAAgB,CAAEJ,OAAQ,CAAC,CAACK,eAAe;EAEzD,OAAOF,uBAAuB,GAC3B,IAAAzB,cAAM,EAAEyB,uBAAwB,CAAC,CAACxB,KAAK,CAAC,CAAC,GACzCoB,KAAK;AACT,CAAC;AAACX,OAAA,CAAAU,mBAAA,GAAAA,mBAAA"}
@@ -207,7 +207,7 @@ function SandBox({
207
207
  defaultView?.addEventListener('message', checkMessageForResize);
208
208
  return () => {
209
209
  iframe?.removeEventListener('load', tryNoForceSandBox, false);
210
- defaultView?.addEventListener('message', checkMessageForResize);
210
+ defaultView?.removeEventListener('message', checkMessageForResize);
211
211
  };
212
212
  // Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
213
213
  // See https://github.com/WordPress/gutenberg/pull/44378
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_compose","observeAndResizeJS","MutationObserver","window","document","body","parent","sendResize","clientBoundingRect","getBoundingClientRect","postMessage","action","width","height","observer","observe","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","addEventListener","removeViewportStyles","ruleOrNode","style","forEach","test","Array","prototype","call","querySelectorAll","styleSheets","stylesheet","cssRules","rules","position","setAttribute","SandBox","html","title","type","styles","scripts","onFocus","ref","useRef","setWidth","useState","setHeight","isFrameAccessible","current","contentDocument","e","trySandBox","forceRerender","ownerDocument","getAttribute","htmlDoc","createElement","lang","documentElement","className","dangerouslySetInnerHTML","__html","map","i","key","toString","src","open","write","renderToString","close","useEffect","tryNoForceSandBox","checkMessageForResize","event","iframe","contentWindow","source","data","JSON","parse","defaultView","removeEventListener","useMergeRefs","useFocusableIframe","sandbox","Math","ceil","_default","exports","default"],"sources":["@wordpress/components/src/sandbox/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseRef,\n\tuseState,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { SandBoxProps } from './types';\n\nconst observeAndResizeJS = function () {\n\tconst { MutationObserver } = window;\n\n\tif ( ! MutationObserver || ! document.body || ! window.parent ) {\n\t\treturn;\n\t}\n\n\tfunction sendResize() {\n\t\tconst clientBoundingRect = document.body.getBoundingClientRect();\n\n\t\twindow.parent.postMessage(\n\t\t\t{\n\t\t\t\taction: 'resize',\n\t\t\t\twidth: clientBoundingRect.width,\n\t\t\t\theight: clientBoundingRect.height,\n\t\t\t},\n\t\t\t'*'\n\t\t);\n\t}\n\n\tconst observer = new MutationObserver( sendResize );\n\tobserver.observe( document.body, {\n\t\tattributes: true,\n\t\tattributeOldValue: false,\n\t\tcharacterData: true,\n\t\tcharacterDataOldValue: false,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t} );\n\n\twindow.addEventListener( 'load', sendResize, true );\n\n\t// Hack: Remove viewport unit styles, as these are relative\n\t// the iframe root and interfere with our mechanism for\n\t// determining the unconstrained page bounds.\n\tfunction removeViewportStyles( ruleOrNode: ElementCSSInlineStyle ) {\n\t\tif ( ruleOrNode.style ) {\n\t\t\t(\n\t\t\t\t[ 'width', 'height', 'minHeight', 'maxHeight' ] as const\n\t\t\t ).forEach( function ( style ) {\n\t\t\t\tif (\n\t\t\t\t\t/^\\\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )\n\t\t\t\t) {\n\t\t\t\t\truleOrNode.style[ style ] = '';\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tArray.prototype.forEach.call(\n\t\tdocument.querySelectorAll( '[style]' ),\n\t\tremoveViewportStyles\n\t);\n\tArray.prototype.forEach.call(\n\t\tdocument.styleSheets,\n\t\tfunction ( stylesheet ) {\n\t\t\tArray.prototype.forEach.call(\n\t\t\t\tstylesheet.cssRules || stylesheet.rules,\n\t\t\t\tremoveViewportStyles\n\t\t\t);\n\t\t}\n\t);\n\n\tdocument.body.style.position = 'absolute';\n\tdocument.body.style.width = '100%';\n\tdocument.body.setAttribute( 'data-resizable-iframe-connected', '' );\n\n\tsendResize();\n\n\t// Resize events can change the width of elements with 100% width, but we don't\n\t// get an DOM mutations for that, so do the resize when the window is resized, too.\n\twindow.addEventListener( 'resize', sendResize, true );\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 * 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\thtml = '',\n\ttitle = '',\n\ttype,\n\tstyles = [],\n\tscripts = [],\n\tonFocus,\n}: SandBoxProps ) {\n\tconst ref = useRef< HTMLIFrameElement >();\n\tconst [ width, setWidth ] = useState( 0 );\n\tconst [ height, setHeight ] = useState( 0 );\n\n\tfunction isFrameAccessible() {\n\t\ttry {\n\t\t\treturn !! ref.current?.contentDocument?.body;\n\t\t} catch ( e ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction trySandBox( forceRerender = false ) {\n\t\tif ( ! isFrameAccessible() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { contentDocument, ownerDocument } =\n\t\t\tref.current as HTMLIFrameElement & {\n\t\t\t\tcontentDocument: Document;\n\t\t\t};\n\n\t\tif (\n\t\t\t! forceRerender &&\n\t\t\tnull !==\n\t\t\t\tcontentDocument?.body.getAttribute(\n\t\t\t\t\t'data-resizable-iframe-connected'\n\t\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Put the html snippet into a html document, and then write it to the iframe's document\n\t\t// we can use this in the future to inject custom styles or scripts.\n\t\t// Scripts go into the body rather than the head, to support embedded content such as Instagram\n\t\t// that expect the scripts to be part of the body.\n\t\tconst htmlDoc = (\n\t\t\t<html\n\t\t\t\tlang={ ownerDocument.documentElement.lang }\n\t\t\t\tclassName={ type }\n\t\t\t>\n\t\t\t\t<head>\n\t\t\t\t\t<title>{ title }</title>\n\t\t\t\t\t<style dangerouslySetInnerHTML={ { __html: style } } />\n\t\t\t\t\t{ styles.map( ( rules, i ) => (\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ { __html: rules } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</head>\n\t\t\t\t<body\n\t\t\t\t\tdata-resizable-iframe-connected=\"data-resizable-iframe-connected\"\n\t\t\t\t\tclassName={ type }\n\t\t\t\t>\n\t\t\t\t\t<div dangerouslySetInnerHTML={ { __html: html } } />\n\t\t\t\t\t<script\n\t\t\t\t\t\ttype=\"text/javascript\"\n\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t__html: `(${ observeAndResizeJS.toString() })();`,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ scripts.map( ( src ) => (\n\t\t\t\t\t\t<script key={ src } src={ src } />\n\t\t\t\t\t) ) }\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t);\n\n\t\t// Writing the document like this makes it act in the same way as if it was\n\t\t// loaded over the network, so DOM creation and mutation, script execution, etc.\n\t\t// all work as expected.\n\t\tcontentDocument.open();\n\t\tcontentDocument.write( '<!DOCTYPE html>' + renderToString( htmlDoc ) );\n\t\tcontentDocument.close();\n\t}\n\n\tuseEffect( () => {\n\t\ttrySandBox();\n\n\t\tfunction tryNoForceSandBox() {\n\t\t\ttrySandBox( false );\n\t\t}\n\n\t\tfunction checkMessageForResize( event: MessageEvent ) {\n\t\t\tconst iframe = ref.current;\n\n\t\t\t// Verify that the mounted element is the source of the message.\n\t\t\tif ( ! iframe || iframe.contentWindow !== event.source ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Attempt to parse the message data as JSON if passed as string.\n\t\t\tlet data = event.data || {};\n\n\t\t\tif ( 'string' === typeof data ) {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( data );\n\t\t\t\t} catch ( e ) {}\n\t\t\t}\n\n\t\t\t// Update the state only if the message is formatted as we expect,\n\t\t\t// i.e. as an object with a 'resize' action.\n\t\t\tif ( 'resize' !== data.action ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetWidth( data.width );\n\t\t\tsetHeight( data.height );\n\t\t}\n\n\t\tconst iframe = ref.current;\n\t\tconst defaultView = iframe?.ownerDocument?.defaultView;\n\n\t\t// This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n\t\t// after reordering the containing block. See these two issues for more details:\n\t\t// https://github.com/WordPress/gutenberg/issues/6146\n\t\t// https://github.com/facebook/react/issues/18752\n\t\tiframe?.addEventListener( 'load', tryNoForceSandBox, false );\n\t\tdefaultView?.addEventListener( 'message', checkMessageForResize );\n\n\t\treturn () => {\n\t\t\tiframe?.removeEventListener( 'load', tryNoForceSandBox, false );\n\t\t\tdefaultView?.addEventListener( 'message', checkMessageForResize );\n\t\t};\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tuseEffect( () => {\n\t\ttrySandBox();\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ title, styles, scripts ] );\n\n\tuseEffect( () => {\n\t\ttrySandBox( true );\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ html, type ] );\n\n\treturn (\n\t\t<iframe\n\t\t\tref={ useMergeRefs( [ ref, useFocusableIframe() ] ) }\n\t\t\ttitle={ title }\n\t\t\tclassName=\"components-sandbox\"\n\t\t\tsandbox=\"allow-scripts allow-same-origin allow-presentation\"\n\t\t\tonFocus={ onFocus }\n\t\t\twidth={ Math.ceil( width ) }\n\t\t\theight={ Math.ceil( height ) }\n\t\t/>\n\t);\n}\n\nexport default SandBox;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAD,OAAA;AATA;AACA;AACA;;AAcA,MAAME,kBAAkB,GAAG,SAAAA,CAAA,EAAY;EACtC,MAAM;IAAEC;EAAiB,CAAC,GAAGC,MAAM;EAEnC,IAAK,CAAED,gBAAgB,IAAI,CAAEE,QAAQ,CAACC,IAAI,IAAI,CAAEF,MAAM,CAACG,MAAM,EAAG;IAC/D;EACD;EAEA,SAASC,UAAUA,CAAA,EAAG;IACrB,MAAMC,kBAAkB,GAAGJ,QAAQ,CAACC,IAAI,CAACI,qBAAqB,CAAC,CAAC;IAEhEN,MAAM,CAACG,MAAM,CAACI,WAAW,CACxB;MACCC,MAAM,EAAE,QAAQ;MAChBC,KAAK,EAAEJ,kBAAkB,CAACI,KAAK;MAC/BC,MAAM,EAAEL,kBAAkB,CAACK;IAC5B,CAAC,EACD,GACD,CAAC;EACF;EAEA,MAAMC,QAAQ,GAAG,IAAIZ,gBAAgB,CAAEK,UAA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IAChBpB,UAAU,CAAC,CAAC;IACZ;IACA;IACA;EACD,CAAC,EAAE,CAAEd,KAAK,EAAEE,MAAM,EAAEC,OAAO,CAAG,CAAC;EAE/B,IAAA+B,kBAAS,EAAE,MAAM;IAChBpB,UAAU,CAAE,IAAK,CAAC;IAClB;IACA;IACA;EACD,CAAC,EAAE,CAAEf,IAAI,EAAEE,IAAI,CAAG,CAAC;EAEnB,OACC,IAAA3C,QAAA,CAAA6D,aAAA;IACCd,GAAG,EAAG,IAAAyC,qBAAY,EAAE,CAAEzC,GAAG,EAAE,IAAA0C,2BAAkB,EAAC,CAAC,CAAG,CAAG;IACrD/C,KAAK,EAAGA,KAAO;IACfsB,SAAS,EAAC,oBAAoB;IAC9B0B,OAAO,EAAC,oDAAoD;IAC5D5C,OAAO,EAAGA,OAAS;IACnBhC,KAAK,EAAG6E,IAAI,CAACC,IAAI,CAAE9E,KAAM,CAAG;IAC5BC,MAAM,EAAG4E,IAAI,CAACC,IAAI,CAAE7E,MAAO;EAAG,CAC9B,CAAC;AAEJ;AAAC,IAAA8E,QAAA,GAEcrD,OAAO;AAAAsD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_element","require","_compose","observeAndResizeJS","MutationObserver","window","document","body","parent","sendResize","clientBoundingRect","getBoundingClientRect","postMessage","action","width","height","observer","observe","attributes","attributeOldValue","characterData","characterDataOldValue","childList","subtree","addEventListener","removeViewportStyles","ruleOrNode","style","forEach","test","Array","prototype","call","querySelectorAll","styleSheets","stylesheet","cssRules","rules","position","setAttribute","SandBox","html","title","type","styles","scripts","onFocus","ref","useRef","setWidth","useState","setHeight","isFrameAccessible","current","contentDocument","e","trySandBox","forceRerender","ownerDocument","getAttribute","htmlDoc","createElement","lang","documentElement","className","dangerouslySetInnerHTML","__html","map","i","key","toString","src","open","write","renderToString","close","useEffect","tryNoForceSandBox","checkMessageForResize","event","iframe","contentWindow","source","data","JSON","parse","defaultView","removeEventListener","useMergeRefs","useFocusableIframe","sandbox","Math","ceil","_default","exports","default"],"sources":["@wordpress/components/src/sandbox/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseRef,\n\tuseState,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport type { SandBoxProps } from './types';\n\nconst observeAndResizeJS = function () {\n\tconst { MutationObserver } = window;\n\n\tif ( ! MutationObserver || ! document.body || ! window.parent ) {\n\t\treturn;\n\t}\n\n\tfunction sendResize() {\n\t\tconst clientBoundingRect = document.body.getBoundingClientRect();\n\n\t\twindow.parent.postMessage(\n\t\t\t{\n\t\t\t\taction: 'resize',\n\t\t\t\twidth: clientBoundingRect.width,\n\t\t\t\theight: clientBoundingRect.height,\n\t\t\t},\n\t\t\t'*'\n\t\t);\n\t}\n\n\tconst observer = new MutationObserver( sendResize );\n\tobserver.observe( document.body, {\n\t\tattributes: true,\n\t\tattributeOldValue: false,\n\t\tcharacterData: true,\n\t\tcharacterDataOldValue: false,\n\t\tchildList: true,\n\t\tsubtree: true,\n\t} );\n\n\twindow.addEventListener( 'load', sendResize, true );\n\n\t// Hack: Remove viewport unit styles, as these are relative\n\t// the iframe root and interfere with our mechanism for\n\t// determining the unconstrained page bounds.\n\tfunction removeViewportStyles( ruleOrNode: ElementCSSInlineStyle ) {\n\t\tif ( ruleOrNode.style ) {\n\t\t\t(\n\t\t\t\t[ 'width', 'height', 'minHeight', 'maxHeight' ] as const\n\t\t\t ).forEach( function ( style ) {\n\t\t\t\tif (\n\t\t\t\t\t/^\\\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )\n\t\t\t\t) {\n\t\t\t\t\truleOrNode.style[ style ] = '';\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tArray.prototype.forEach.call(\n\t\tdocument.querySelectorAll( '[style]' ),\n\t\tremoveViewportStyles\n\t);\n\tArray.prototype.forEach.call(\n\t\tdocument.styleSheets,\n\t\tfunction ( stylesheet ) {\n\t\t\tArray.prototype.forEach.call(\n\t\t\t\tstylesheet.cssRules || stylesheet.rules,\n\t\t\t\tremoveViewportStyles\n\t\t\t);\n\t\t}\n\t);\n\n\tdocument.body.style.position = 'absolute';\n\tdocument.body.style.width = '100%';\n\tdocument.body.setAttribute( 'data-resizable-iframe-connected', '' );\n\n\tsendResize();\n\n\t// Resize events can change the width of elements with 100% width, but we don't\n\t// get an DOM mutations for that, so do the resize when the window is resized, too.\n\twindow.addEventListener( 'resize', sendResize, true );\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 * 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\thtml = '',\n\ttitle = '',\n\ttype,\n\tstyles = [],\n\tscripts = [],\n\tonFocus,\n}: SandBoxProps ) {\n\tconst ref = useRef< HTMLIFrameElement >();\n\tconst [ width, setWidth ] = useState( 0 );\n\tconst [ height, setHeight ] = useState( 0 );\n\n\tfunction isFrameAccessible() {\n\t\ttry {\n\t\t\treturn !! ref.current?.contentDocument?.body;\n\t\t} catch ( e ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction trySandBox( forceRerender = false ) {\n\t\tif ( ! isFrameAccessible() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { contentDocument, ownerDocument } =\n\t\t\tref.current as HTMLIFrameElement & {\n\t\t\t\tcontentDocument: Document;\n\t\t\t};\n\n\t\tif (\n\t\t\t! forceRerender &&\n\t\t\tnull !==\n\t\t\t\tcontentDocument?.body.getAttribute(\n\t\t\t\t\t'data-resizable-iframe-connected'\n\t\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Put the html snippet into a html document, and then write it to the iframe's document\n\t\t// we can use this in the future to inject custom styles or scripts.\n\t\t// Scripts go into the body rather than the head, to support embedded content such as Instagram\n\t\t// that expect the scripts to be part of the body.\n\t\tconst htmlDoc = (\n\t\t\t<html\n\t\t\t\tlang={ ownerDocument.documentElement.lang }\n\t\t\t\tclassName={ type }\n\t\t\t>\n\t\t\t\t<head>\n\t\t\t\t\t<title>{ title }</title>\n\t\t\t\t\t<style dangerouslySetInnerHTML={ { __html: style } } />\n\t\t\t\t\t{ styles.map( ( rules, i ) => (\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ { __html: rules } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</head>\n\t\t\t\t<body\n\t\t\t\t\tdata-resizable-iframe-connected=\"data-resizable-iframe-connected\"\n\t\t\t\t\tclassName={ type }\n\t\t\t\t>\n\t\t\t\t\t<div dangerouslySetInnerHTML={ { __html: html } } />\n\t\t\t\t\t<script\n\t\t\t\t\t\ttype=\"text/javascript\"\n\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t__html: `(${ observeAndResizeJS.toString() })();`,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ scripts.map( ( src ) => (\n\t\t\t\t\t\t<script key={ src } src={ src } />\n\t\t\t\t\t) ) }\n\t\t\t\t</body>\n\t\t\t</html>\n\t\t);\n\n\t\t// Writing the document like this makes it act in the same way as if it was\n\t\t// loaded over the network, so DOM creation and mutation, script execution, etc.\n\t\t// all work as expected.\n\t\tcontentDocument.open();\n\t\tcontentDocument.write( '<!DOCTYPE html>' + renderToString( htmlDoc ) );\n\t\tcontentDocument.close();\n\t}\n\n\tuseEffect( () => {\n\t\ttrySandBox();\n\n\t\tfunction tryNoForceSandBox() {\n\t\t\ttrySandBox( false );\n\t\t}\n\n\t\tfunction checkMessageForResize( event: MessageEvent ) {\n\t\t\tconst iframe = ref.current;\n\n\t\t\t// Verify that the mounted element is the source of the message.\n\t\t\tif ( ! iframe || iframe.contentWindow !== event.source ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Attempt to parse the message data as JSON if passed as string.\n\t\t\tlet data = event.data || {};\n\n\t\t\tif ( 'string' === typeof data ) {\n\t\t\t\ttry {\n\t\t\t\t\tdata = JSON.parse( data );\n\t\t\t\t} catch ( e ) {}\n\t\t\t}\n\n\t\t\t// Update the state only if the message is formatted as we expect,\n\t\t\t// i.e. as an object with a 'resize' action.\n\t\t\tif ( 'resize' !== data.action ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetWidth( data.width );\n\t\t\tsetHeight( data.height );\n\t\t}\n\n\t\tconst iframe = ref.current;\n\t\tconst defaultView = iframe?.ownerDocument?.defaultView;\n\n\t\t// This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n\t\t// after reordering the containing block. See these two issues for more details:\n\t\t// https://github.com/WordPress/gutenberg/issues/6146\n\t\t// https://github.com/facebook/react/issues/18752\n\t\tiframe?.addEventListener( 'load', tryNoForceSandBox, false );\n\t\tdefaultView?.addEventListener( 'message', checkMessageForResize );\n\n\t\treturn () => {\n\t\t\tiframe?.removeEventListener( 'load', tryNoForceSandBox, false );\n\t\t\tdefaultView?.removeEventListener(\n\t\t\t\t'message',\n\t\t\t\tcheckMessageForResize\n\t\t\t);\n\t\t};\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\tuseEffect( () => {\n\t\ttrySandBox();\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ title, styles, scripts ] );\n\n\tuseEffect( () => {\n\t\ttrySandBox( true );\n\t\t// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.\n\t\t// See https://github.com/WordPress/gutenberg/pull/44378\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ html, type ] );\n\n\treturn (\n\t\t<iframe\n\t\t\tref={ useMergeRefs( [ ref, useFocusableIframe() ] ) }\n\t\t\ttitle={ title }\n\t\t\tclassName=\"components-sandbox\"\n\t\t\tsandbox=\"allow-scripts allow-same-origin allow-presentation\"\n\t\t\tonFocus={ onFocus }\n\t\t\twidth={ Math.ceil( width ) }\n\t\t\theight={ Math.ceil( height ) }\n\t\t/>\n\t);\n}\n\nexport default SandBox;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAD,OAAA;AATA;AACA;AACA;;AAcA,MAAME,kBAAkB,GAAG,SAAAA,CAAA,EAAY;EACtC,MAAM;IAAEC;EAAiB,CAAC,GAAGC,MAAM;EAEnC,IAAK,CAAED,gBAAgB,IAAI,CAAEE,QAAQ,CAACC,IAAI,IAAI,CAAEF,MAAM,CAACG,MAAM,EAAG;IAC/D;EACD;EAEA,SAASC,UAAUA,CAAA,EAAG;IACrB,MAAMC,kBAAkB,GAAGJ,QAAQ,CAACC,IAAI,CAACI,qBAAqB,CAAC,CAAC;IAEhEN,MAAM,CAACG,MAAM,CAACI,WAAW,CACxB;MACCC,MAAM,EAAE,QAAQ;MAChBC,KAAK,EAAEJ,kBAAk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AAEC,mBAAmB,CAC/B,SAAS,EACTT,qBACD,CAAC;IACF,CAAC;IACD;IACA;IACA;EACD,CAAC,EAAE,EAAG,CAAC;EAEP,IAAAF,kBAAS,EAAE,MAAM;IAChBpB,UAAU,CAAC,CAAC;IACZ;IACA;IACA;EACD,CAAC,EAAE,CAAEd,KAAK,EAAEE,MAAM,EAAEC,OAAO,CAAG,CAAC;EAE/B,IAAA+B,kBAAS,EAAE,MAAM;IAChBpB,UAAU,CAAE,IAAK,CAAC;IAClB;IACA;IACA;EACD,CAAC,EAAE,CAAEf,IAAI,EAAEE,IAAI,CAAG,CAAC;EAEnB,OACC,IAAA3C,QAAA,CAAA6D,aAAA;IACCd,GAAG,EAAG,IAAAyC,qBAAY,EAAE,CAAEzC,GAAG,EAAE,IAAA0C,2BAAkB,EAAC,CAAC,CAAG,CAAG;IACrD/C,KAAK,EAAGA,KAAO;IACfsB,SAAS,EAAC,oBAAoB;IAC9B0B,OAAO,EAAC,oDAAoD;IAC5D5C,OAAO,EAAGA,OAAS;IACnBhC,KAAK,EAAG6E,IAAI,CAACC,IAAI,CAAE9E,KAAM,CAAG;IAC5BC,MAAM,EAAG4E,IAAI,CAACC,IAAI,CAAE7E,MAAO;EAAG,CAC9B,CAAC;AAEJ;AAAC,IAAA8E,QAAA,GAEcrD,OAAO;AAAAsD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -21,7 +21,7 @@ const SlotFillContext = (0, _element.createContext)({
21
21
  slots: (0, _utils.proxyMap)(),
22
22
  fills: (0, _utils.proxyMap)(),
23
23
  registerSlot: () => {
24
- typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)('Components must be wrapped within `SlotFillProvider`. ' + 'See https://developer.wordpress.org/block-editor/components/slot-fill/') : void 0;
24
+ typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('Components must be wrapped within `SlotFillProvider`. ' + 'See https://developer.wordpress.org/block-editor/components/slot-fill/') : void 0;
25
25
  },
26
26
  updateSlot: () => {},
27
27
  unregisterSlot: () => {},
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","_element","_warning","_interopRequireDefault","SlotFillContext","createContext","slots","proxyMap","fills","registerSlot","process","env","NODE_ENV","warning","updateSlot","unregisterSlot","registerFill","unregisterFill","_default","exports","default"],"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/slot-fill-context.js"],"sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport { proxyMap } from 'valtio/utils';\n/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\nconst SlotFillContext = createContext( {\n\tslots: proxyMap(),\n\tfills: proxyMap(),\n\tregisterSlot: () => {\n\t\twarning(\n\t\t\t'Components must be wrapped within `SlotFillProvider`. ' +\n\t\t\t\t'See https://developer.wordpress.org/block-editor/components/slot-fill/'\n\t\t);\n\t},\n\tupdateSlot: () => {},\n\tunregisterSlot: () => {},\n\tregisterFill: () => {},\n\tunregisterFill: () => {},\n} );\n\nexport default SlotFillContext;\n"],"mappings":";;;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAIA,MAAMI,eAAe,GAAG,IAAAC,sBAAa,EAAE;EACtCC,KAAK,EAAE,IAAAC,eAAQ,EAAC,CAAC;EACjBC,KAAK,EAAE,IAAAD,eAAQ,EAAC,CAAC;EACjBE,YAAY,EAAEA,CAAA,KAAM;IACnB,OAAAC,OAAA,oBAAAA,OAAA,CAAAC,GAAA,IAAAD,OAAA,CAAAC,GAAA,CAAAC,QAAA,wBAAAC,gBAAO,EACN,wDAAwD,GACvD,wEACF,CAAC;EACF,CAAC;EACDC,UAAU,EAAEA,CAAA,KAAM,CAAC,CAAC;EACpBC,cAAc,EAAEA,CAAA,KAAM,CAAC,CAAC;EACxBC,YAAY,EAAEA,CAAA,KAAM,CAAC,CAAC;EACtBC,cAAc,EAAEA,CAAA,KAAM,CAAC;AACxB,CAAE,CAAC;AAAC,IAAAC,QAAA,GAEWd,eAAe;AAAAe,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
1
+ {"version":3,"names":["_utils","require","_element","_warning","_interopRequireDefault","SlotFillContext","createContext","slots","proxyMap","fills","registerSlot","SCRIPT_DEBUG","warning","updateSlot","unregisterSlot","registerFill","unregisterFill","_default","exports","default"],"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/slot-fill-context.js"],"sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport { proxyMap } from 'valtio/utils';\n/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\nconst SlotFillContext = createContext( {\n\tslots: proxyMap(),\n\tfills: proxyMap(),\n\tregisterSlot: () => {\n\t\twarning(\n\t\t\t'Components must be wrapped within `SlotFillProvider`. ' +\n\t\t\t\t'See https://developer.wordpress.org/block-editor/components/slot-fill/'\n\t\t);\n\t},\n\tupdateSlot: () => {},\n\tunregisterSlot: () => {},\n\tregisterFill: () => {},\n\tunregisterFill: () => {},\n} );\n\nexport default SlotFillContext;\n"],"mappings":";;;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAIA,MAAMI,eAAe,GAAG,IAAAC,sBAAa,EAAE;EACtCC,KAAK,EAAE,IAAAC,eAAQ,EAAC,CAAC;EACjBC,KAAK,EAAE,IAAAD,eAAQ,EAAC,CAAC;EACjBE,YAAY,EAAEA,CAAA,KAAM;IACnB,OAAAC,YAAA,oBAAAA,YAAA,gBAAAC,gBAAO,EACN,wDAAwD,GACvD,wEACF,CAAC;EACF,CAAC;EACDC,UAAU,EAAEA,CAAA,KAAM,CAAC,CAAC;EACpBC,cAAc,EAAEA,CAAA,KAAM,CAAC,CAAC;EACxBC,YAAY,EAAEA,CAAA,KAAM,CAAC,CAAC;EACtBC,cAAc,EAAEA,CAAA,KAAM,CAAC;AACxB,CAAE,CAAC;AAAC,IAAAC,QAAA,GAEWZ,eAAe;AAAAa,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -89,7 +89,7 @@ function UnforwardedSnackbar({
89
89
  });
90
90
  if (actions && actions.length > 1) {
91
91
  // We need to inform developers that snackbar only accepts 1 action.
92
- typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)('Snackbar can only have 1 action, use Notice if your message require many messages') : void 0;
92
+ typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('Snackbar can only have 1 action, use Notice if your message require many messages') : void 0;
93
93
  // return first element only while keeping it inside an array
94
94
  actions = [actions[0]];
95
95
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_a11y","_i18n","_warning","_button","NOTICE_TIMEOUT","useSpokenMessage","message","politeness","spokenMessage","renderToString","useEffect","speak","UnforwardedSnackbar","className","children","actions","onRemove","icon","explicitDismiss","onDismiss","listRef","ref","dismissMe","event","preventDefault","current","focus","onActionClick","onClick","stopPropagation","timeoutHandle","setTimeout","clearTimeout","classes","classnames","length","process","env","NODE_ENV","warning","snackbarContentClassnames","createElement","undefined","tabIndex","role","onKeyPress","__","map","label","url","index","default","key","href","variant","Snackbar","forwardRef","exports","_default"],"sources":["@wordpress/components/src/snackbar/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, KeyboardEvent, MouseEvent } from 'react';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { useEffect, forwardRef, renderToString } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport type { SnackbarProps } from './types';\nimport type { NoticeAction } from '../notice/types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst NOTICE_TIMEOUT = 10000;\n\n/**\n * Custom hook which announces the message with the given politeness, if a\n * valid message is provided.\n *\n * @param message Message to announce.\n * @param politeness Politeness to announce.\n */\nfunction useSpokenMessage(\n\tmessage: SnackbarProps[ 'spokenMessage' ],\n\tpoliteness: NonNullable< SnackbarProps[ 'politeness' ] >\n) {\n\tconst spokenMessage =\n\t\ttypeof message === 'string' ? message : renderToString( message );\n\n\tuseEffect( () => {\n\t\tif ( spokenMessage ) {\n\t\t\tspeak( spokenMessage, politeness );\n\t\t}\n\t}, [ spokenMessage, politeness ] );\n}\n\nfunction UnforwardedSnackbar(\n\t{\n\t\tclassName,\n\t\tchildren,\n\t\tspokenMessage = children,\n\t\tpoliteness = 'polite',\n\t\tactions = [],\n\t\tonRemove,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\t// onDismiss is a callback executed when the snackbar is dismissed.\n\t\t// It is distinct from onRemove, which _looks_ like a callback but is\n\t\t// actually the function to call to remove the snackbar from the UI.\n\t\tonDismiss,\n\t\tlistRef,\n\t}: WordPressComponentProps< SnackbarProps, 'div' >,\n\tref: ForwardedRef< any >\n) {\n\tfunction dismissMe( event: KeyboardEvent | MouseEvent ) {\n\t\tif ( event && event.preventDefault ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\t// Prevent focus loss by moving it to the list element.\n\t\tlistRef?.current?.focus();\n\n\t\tonDismiss?.();\n\t\tonRemove?.();\n\t}\n\n\tfunction onActionClick(\n\t\tevent: MouseEvent< HTMLButtonElement >,\n\t\tonClick: NoticeAction[ 'onClick' ]\n\t) {\n\t\tevent.stopPropagation();\n\n\t\tonRemove?.();\n\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\tuseSpokenMessage( spokenMessage, politeness );\n\n\t// Only set up the timeout dismiss if we're not explicitly dismissing.\n\tuseEffect( () => {\n\t\tconst timeoutHandle = setTimeout( () => {\n\t\t\tif ( ! explicitDismiss ) {\n\t\t\t\tonDismiss?.();\n\t\t\t\tonRemove?.();\n\t\t\t}\n\t\t}, NOTICE_TIMEOUT );\n\n\t\treturn () => clearTimeout( timeoutHandle );\n\t}, [ onDismiss, onRemove, explicitDismiss ] );\n\n\tconst classes = classnames( className, 'components-snackbar', {\n\t\t'components-snackbar-explicit-dismiss': !! explicitDismiss,\n\t} );\n\tif ( actions && actions.length > 1 ) {\n\t\t// We need to inform developers that snackbar only accepts 1 action.\n\t\twarning(\n\t\t\t'Snackbar can only have 1 action, use Notice if your message require many messages'\n\t\t);\n\t\t// return first element only while keeping it inside an array\n\t\tactions = [ actions[ 0 ] ];\n\t}\n\n\tconst snackbarContentClassnames = classnames(\n\t\t'components-snackbar__content',\n\t\t{\n\t\t\t'components-snackbar__content-with-icon': !! icon,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classes }\n\t\t\tonClick={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\ttabIndex={ 0 }\n\t\t\trole={ ! explicitDismiss ? 'button' : '' }\n\t\t\tonKeyPress={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\taria-label={ ! explicitDismiss ? __( 'Dismiss this notice' ) : '' }\n\t\t>\n\t\t\t<div className={ snackbarContentClassnames }>\n\t\t\t\t{ icon && (\n\t\t\t\t\t<div className=\"components-snackbar__icon\">{ icon }</div>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ actions.map( ( { label, onClick, url }, index ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\thref={ url }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\tevent: MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t) => onActionClick( event, onClick ) }\n\t\t\t\t\t\t\tclassName=\"components-snackbar__action\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ explicitDismiss && (\n\t\t\t\t\t<span\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\taria-label=\"Dismiss this notice\"\n\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\tclassName=\"components-snackbar__dismiss-button\"\n\t\t\t\t\t\tonClick={ dismissMe }\n\t\t\t\t\t\tonKeyPress={ dismissMe }\n\t\t\t\t\t>\n\t\t\t\t\t\t&#x2715;\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * A Snackbar displays a succinct message that is cleared out after a small delay.\n *\n * It can also offer the user options, like viewing a published post.\n * But these options should also be available elsewhere in the UI.\n *\n * ```jsx\n * const MySnackbarNotice = () => (\n * <Snackbar>Post published successfully.</Snackbar>\n * );\n * ```\n */\nexport const Snackbar = forwardRef( UnforwardedSnackbar );\n\nexport default Snackbar;\n"],"mappings":";;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AANA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAH,sBAAA,CAAAF,OAAA;AAKA,IAAAM,OAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAjBA;AACA;AACA;;AAIA;AACA;AACA;;AAMA;AACA;AACA;;AAMA,MAAMO,cAAc,GAAG,KAAK;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CACxBC,OAAyC,EACzCC,UAAwD,EACvD;EACD,MAAMC,aAAa,GAClB,OAAOF,OAAO,KAAK,QAAQ,GAAGA,OAAO,GAAG,IAAAG,uBAAc,EA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AA,CAAAgD,OAAM;MACNC,GAAG,EAAGF,KAAO;MACbG,IAAI,EAAGJ,GAAK;MACZK,OAAO,EAAC,UAAU;MAClB1B,OAAO,EACNL,KAAsC,IAClCI,aAAa,CAAEJ,KAAK,EAAEK,OAAQ,CAAG;MACtCf,SAAS,EAAC;IAA6B,GAErCmC,KACK,CAAC;EAEX,CAAE,CAAC,EACD9B,eAAe,IAChB,IAAAtB,QAAA,CAAA6C,aAAA;IACCG,IAAI,EAAC,QAAQ;IACb,cAAW,qBAAqB;IAChCD,QAAQ,EAAG,CAAG;IACd9B,SAAS,EAAC,qCAAqC;IAC/Ce,OAAO,EAAGN,SAAW;IACrBuB,UAAU,EAAGvB;EAAW,GACxB,QAEK,CAEH,CACD,CAAC;AAER;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMiC,QAAQ,GAAG,IAAAC,mBAAU,EAAE5C,mBAAoB,CAAC;AAAC6C,OAAA,CAAAF,QAAA,GAAAA,QAAA;AAAA,IAAAG,QAAA,GAE3CH,QAAQ;AAAAE,OAAA,CAAAN,OAAA,GAAAO,QAAA"}
1
+ {"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_a11y","_i18n","_warning","_button","NOTICE_TIMEOUT","useSpokenMessage","message","politeness","spokenMessage","renderToString","useEffect","speak","UnforwardedSnackbar","className","children","actions","onRemove","icon","explicitDismiss","onDismiss","listRef","ref","dismissMe","event","preventDefault","current","focus","onActionClick","onClick","stopPropagation","timeoutHandle","setTimeout","clearTimeout","classes","classnames","length","SCRIPT_DEBUG","warning","snackbarContentClassnames","createElement","undefined","tabIndex","role","onKeyPress","__","map","label","url","index","default","key","href","variant","Snackbar","forwardRef","exports","_default"],"sources":["@wordpress/components/src/snackbar/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, KeyboardEvent, MouseEvent } from 'react';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { useEffect, forwardRef, renderToString } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport type { SnackbarProps } from './types';\nimport type { NoticeAction } from '../notice/types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst NOTICE_TIMEOUT = 10000;\n\n/**\n * Custom hook which announces the message with the given politeness, if a\n * valid message is provided.\n *\n * @param message Message to announce.\n * @param politeness Politeness to announce.\n */\nfunction useSpokenMessage(\n\tmessage: SnackbarProps[ 'spokenMessage' ],\n\tpoliteness: NonNullable< SnackbarProps[ 'politeness' ] >\n) {\n\tconst spokenMessage =\n\t\ttypeof message === 'string' ? message : renderToString( message );\n\n\tuseEffect( () => {\n\t\tif ( spokenMessage ) {\n\t\t\tspeak( spokenMessage, politeness );\n\t\t}\n\t}, [ spokenMessage, politeness ] );\n}\n\nfunction UnforwardedSnackbar(\n\t{\n\t\tclassName,\n\t\tchildren,\n\t\tspokenMessage = children,\n\t\tpoliteness = 'polite',\n\t\tactions = [],\n\t\tonRemove,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\t// onDismiss is a callback executed when the snackbar is dismissed.\n\t\t// It is distinct from onRemove, which _looks_ like a callback but is\n\t\t// actually the function to call to remove the snackbar from the UI.\n\t\tonDismiss,\n\t\tlistRef,\n\t}: WordPressComponentProps< SnackbarProps, 'div' >,\n\tref: ForwardedRef< any >\n) {\n\tfunction dismissMe( event: KeyboardEvent | MouseEvent ) {\n\t\tif ( event && event.preventDefault ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\t// Prevent focus loss by moving it to the list element.\n\t\tlistRef?.current?.focus();\n\n\t\tonDismiss?.();\n\t\tonRemove?.();\n\t}\n\n\tfunction onActionClick(\n\t\tevent: MouseEvent< HTMLButtonElement >,\n\t\tonClick: NoticeAction[ 'onClick' ]\n\t) {\n\t\tevent.stopPropagation();\n\n\t\tonRemove?.();\n\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\tuseSpokenMessage( spokenMessage, politeness );\n\n\t// Only set up the timeout dismiss if we're not explicitly dismissing.\n\tuseEffect( () => {\n\t\tconst timeoutHandle = setTimeout( () => {\n\t\t\tif ( ! explicitDismiss ) {\n\t\t\t\tonDismiss?.();\n\t\t\t\tonRemove?.();\n\t\t\t}\n\t\t}, NOTICE_TIMEOUT );\n\n\t\treturn () => clearTimeout( timeoutHandle );\n\t}, [ onDismiss, onRemove, explicitDismiss ] );\n\n\tconst classes = classnames( className, 'components-snackbar', {\n\t\t'components-snackbar-explicit-dismiss': !! explicitDismiss,\n\t} );\n\tif ( actions && actions.length > 1 ) {\n\t\t// We need to inform developers that snackbar only accepts 1 action.\n\t\twarning(\n\t\t\t'Snackbar can only have 1 action, use Notice if your message require many messages'\n\t\t);\n\t\t// return first element only while keeping it inside an array\n\t\tactions = [ actions[ 0 ] ];\n\t}\n\n\tconst snackbarContentClassnames = classnames(\n\t\t'components-snackbar__content',\n\t\t{\n\t\t\t'components-snackbar__content-with-icon': !! icon,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classes }\n\t\t\tonClick={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\ttabIndex={ 0 }\n\t\t\trole={ ! explicitDismiss ? 'button' : '' }\n\t\t\tonKeyPress={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\taria-label={ ! explicitDismiss ? __( 'Dismiss this notice' ) : '' }\n\t\t>\n\t\t\t<div className={ snackbarContentClassnames }>\n\t\t\t\t{ icon && (\n\t\t\t\t\t<div className=\"components-snackbar__icon\">{ icon }</div>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ actions.map( ( { label, onClick, url }, index ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\thref={ url }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\tevent: MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t) => onActionClick( event, onClick ) }\n\t\t\t\t\t\t\tclassName=\"components-snackbar__action\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ explicitDismiss && (\n\t\t\t\t\t<span\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\taria-label=\"Dismiss this notice\"\n\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\tclassName=\"components-snackbar__dismiss-button\"\n\t\t\t\t\t\tonClick={ dismissMe }\n\t\t\t\t\t\tonKeyPress={ dismissMe }\n\t\t\t\t\t>\n\t\t\t\t\t\t&#x2715;\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * A Snackbar displays a succinct message that is cleared out after a small delay.\n *\n * It can also offer the user options, like viewing a published post.\n * But these options should also be available elsewhere in the UI.\n *\n * ```jsx\n * const MySnackbarNotice = () => (\n * <Snackbar>Post published successfully.</Snackbar>\n * );\n * ```\n */\nexport const Snackbar = forwardRef( UnforwardedSnackbar );\n\nexport default Snackbar;\n"],"mappings":";;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AANA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAH,sBAAA,CAAAF,OAAA;AAKA,IAAAM,OAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAjBA;AACA;AACA;;AAIA;AACA;AACA;;AAMA;AACA;AACA;;AAMA,MAAMO,cAAc,GAAG,KAAK;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CACxBC,OA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AK,KAAM;IACpD,OACC,IAAApD,QAAA,CAAA2C,aAAA,EAACpC,OAAA,CAAA8C,OAAM;MACNC,GAAG,EAAGF,KAAO;MACbG,IAAI,EAAGJ,GAAK;MACZK,OAAO,EAAC,UAAU;MAClBxB,OAAO,EACNL,KAAsC,IAClCI,aAAa,CAAEJ,KAAK,EAAEK,OAAQ,CAAG;MACtCf,SAAS,EAAC;IAA6B,GAErCiC,KACK,CAAC;EAEX,CAAE,CAAC,EACD5B,eAAe,IAChB,IAAAtB,QAAA,CAAA2C,aAAA;IACCG,IAAI,EAAC,QAAQ;IACb,cAAW,qBAAqB;IAChCD,QAAQ,EAAG,CAAG;IACd5B,SAAS,EAAC,qCAAqC;IAC/Ce,OAAO,EAAGN,SAAW;IACrBqB,UAAU,EAAGrB;EAAW,GACxB,QAEK,CAEH,CACD,CAAC;AAER;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM+B,QAAQ,GAAG,IAAAC,mBAAU,EAAE1C,mBAAoB,CAAC;AAAC2C,OAAA,CAAAF,QAAA,GAAAA,QAAA;AAAA,IAAAG,QAAA,GAE3CH,QAAQ;AAAAE,OAAA,CAAAN,OAAA,GAAAO,QAAA"}
@@ -35,7 +35,7 @@ function generateThemeVariables(inputs) {
35
35
  function validateInputs(inputs) {
36
36
  for (const [key, value] of Object.entries(inputs)) {
37
37
  if (typeof value !== 'undefined' && !(0, _colord.colord)(value).isValid()) {
38
- typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)(`wp.components.Theme: "${value}" is not a valid color value for the '${key}' prop.`) : void 0;
38
+ typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)(`wp.components.Theme: "${value}" is not a valid color value for the '${key}' prop.`) : void 0;
39
39
  }
40
40
  }
41
41
  }
@@ -53,7 +53,7 @@ function checkContrasts(inputs, outputs) {
53
53
  function warnContrastIssues(issues) {
54
54
  for (const error of Object.values(issues)) {
55
55
  if (error) {
56
- typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)('wp.components.Theme: ' + error) : void 0;
56
+ typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('wp.components.Theme: ' + error) : void 0;
57
57
  }
58
58
  }
59
59
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_colord","require","_a11y","_interopRequireDefault","_names","_warning","_utils","extend","namesPlugin","a11yPlugin","generateThemeVariables","inputs","validateInputs","generatedColors","generateAccentDependentColors","accent","generateBackgroundDependentColors","background","warnContrastIssues","checkContrasts","colors","key","value","Object","entries","colord","isValid","process","env","NODE_ENV","warning","outputs","COLORS","white","foreground","gray","isReadable","undefined","grays","contrast","issues","error","values","accentDarker10","darken","toHex","accentDarker20","accentInverted","getForegroundForColor","foregroundInverted","generateShades","color","isDark","SHADES","limit","direction","range","Math","abs","toHsl","l","result","forEach","parseInt"],"sources":["@wordpress/components/src/theme/color-algorithms.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport a11yPlugin from 'colord/plugins/a11y';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeInputValues, ThemeOutputValues } from './types';\nimport { COLORS } from '../utils';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nexport function generateThemeVariables(\n\tinputs: ThemeInputValues\n): ThemeOutputValues {\n\tvalidateInputs( inputs );\n\n\tconst generatedColors = {\n\t\t...generateAccentDependentColors( inputs.accent ),\n\t\t...generateBackgroundDependentColors( inputs.background ),\n\t};\n\n\twarnContrastIssues( checkContrasts( inputs, generatedColors ) );\n\n\treturn { colors: generatedColors };\n}\n\nfunction validateInputs( inputs: ThemeInputValues ) {\n\tfor ( const [ key, value ] of Object.entries( inputs ) ) {\n\t\tif ( typeof value !== 'undefined' && ! colord( value ).isValid() ) {\n\t\t\twarning(\n\t\t\t\t`wp.components.Theme: \"${ value }\" is not a valid color value for the '${ key }' prop.`\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport function checkContrasts(\n\tinputs: ThemeInputValues,\n\toutputs: ThemeOutputValues[ 'colors' ]\n) {\n\tconst background = inputs.background || COLORS.white;\n\tconst accent = inputs.accent || '#3858e9';\n\tconst foreground = outputs.foreground || COLORS.gray[ 900 ];\n\tconst gray = outputs.gray || COLORS.gray;\n\n\treturn {\n\t\taccent: colord( background ).isReadable( accent )\n\t\t\t? undefined\n\t\t\t: `The background color (\"${ background }\") does not have sufficient contrast against the accent color (\"${ accent }\").`,\n\t\tforeground: colord( background ).isReadable( foreground )\n\t\t\t? undefined\n\t\t\t: `The background color provided (\"${ background }\") does not have sufficient contrast against the standard foreground colors.`,\n\t\tgrays:\n\t\t\tcolord( background ).contrast( gray[ 600 ] ) >= 3 &&\n\t\t\tcolord( background ).contrast( gray[ 700 ] ) >= 4.5\n\t\t\t\t? undefined\n\t\t\t\t: `The background color provided (\"${ background }\") cannot generate a set of grayscale foreground colors with sufficient contrast. Try adjusting the color to be lighter or darker.`,\n\t};\n}\n\nfunction warnContrastIssues( issues: ReturnType< typeof checkContrasts > ) {\n\tfor ( const error of Object.values( issues ) ) {\n\t\tif ( error ) {\n\t\t\twarning( 'wp.components.Theme: ' + error );\n\t\t}\n\t}\n}\n\nfunction generateAccentDependentColors( accent?: string ) {\n\tif ( ! accent ) return {};\n\n\treturn {\n\t\taccent,\n\t\taccentDarker10: colord( accent ).darken( 0.1 ).toHex(),\n\t\taccentDarker20: colord( accent ).darken( 0.2 ).toHex(),\n\t\taccentInverted: getForegroundForColor( accent ),\n\t};\n}\n\nfunction generateBackgroundDependentColors( background?: string ) {\n\tif ( ! background ) return {};\n\n\tconst foreground = getForegroundForColor( background );\n\n\treturn {\n\t\tbackground,\n\t\tforeground,\n\t\tforegroundInverted: getForegroundForColor( foreground ),\n\t\tgray: generateShades( background, foreground ),\n\t};\n}\n\nfunction getForegroundForColor( color: string ) {\n\treturn colord( color ).isDark() ? COLORS.white : COLORS.gray[ 900 ];\n}\n\nexport function generateShades( background: string, foreground: string ) {\n\t// How much darkness you need to add to #fff to get the COLORS.gray[n] color\n\tconst SHADES = {\n\t\t100: 0.06,\n\t\t200: 0.121,\n\t\t300: 0.132,\n\t\t400: 0.2,\n\t\t600: 0.42,\n\t\t700: 0.543,\n\t\t800: 0.821,\n\t};\n\n\t// Darkness of COLORS.gray[ 900 ], relative to #fff\n\tconst limit = 0.884;\n\n\tconst direction = colord( background ).isDark() ? 'lighten' : 'darken';\n\n\t// Lightness delta between the background and foreground colors\n\tconst range =\n\t\tMath.abs(\n\t\t\tcolord( background ).toHsl().l - colord( foreground ).toHsl().l\n\t\t) / 100;\n\n\tconst result: Record< number, string > = {};\n\n\tObject.entries( SHADES ).forEach( ( [ key, value ] ) => {\n\t\tresult[ parseInt( key ) ] = colord( background )\n\t\t\t[ direction ]( ( value / limit ) * range )\n\t\t\t.toHex();\n\t} );\n\n\treturn result as NonNullable< ThemeOutputValues[ 'colors' ][ 'gray' ] >;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAKA,IAAAI,QAAA,GAAAF,sBAAA,CAAAF,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AAhBA;AACA;AACA;;AAKA;AACA;AACA;;AASA,IAAAM,cAAM,EAAE,CAAEC,cAAW,EAAEC,aAAU,CAAG,CAAC;AAE9B,SAASC,sBAAsBA,CACrCC,MAAwB,EACJ;EACpBC,cAAc,CAAED,MAAO,CAAC;EAExB,MAAME,eAAe,GAAG;IACvB,GAAGC,6BAA6B,CAAEH,MAAM,CAACI,MAAO,CAAC;IACjD,GAAGC,iCAAiC,CAAEL,MAAM,CAACM,UAAW;EACzD,CAAC;EAEDC,kBA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a,EAAG;EAC/C,OAAO,IAAA1B,cAAM,EAAE0B,KAAM,CAAC,CAACC,MAAM,CAAC,CAAC,GAAGpB,aAAM,CAACC,KAAK,GAAGD,aAAM,CAACG,IAAI,CAAE,GAAG,CAAE;AACpE;AAEO,SAASe,cAAcA,CAAEjC,UAAkB,EAAEiB,UAAkB,EAAG;EACxE;EACA,MAAMmB,MAAM,GAAG;IACd,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,KAAK;IACV,GAAG,EAAE;EACN,CAAC;;EAED;EACA,MAAMC,KAAK,GAAG,KAAK;EAEnB,MAAMC,SAAS,GAAG,IAAA9B,cAAM,EAAER,UAAW,CAAC,CAACmC,MAAM,CAAC,CAAC,GAAG,SAAS,GAAG,QAAQ;;EAEtE;EACA,MAAMI,KAAK,GACVC,IAAI,CAACC,GAAG,CACP,IAAAjC,cAAM,EAAER,UAAW,CAAC,CAAC0C,KAAK,CAAC,CAAC,CAACC,CAAC,GAAG,IAAAnC,cAAM,EAAES,UAAW,CAAC,CAACyB,KAAK,CAAC,CAAC,CAACC,CAC/D,CAAC,GAAG,GAAG;EAER,MAAMC,MAAgC,GAAG,CAAC,CAAC;EAE3CtC,MAAM,CAACC,OAAO,CAAE6B,MAAO,CAAC,CAACS,OAAO,CAAE,CAAE,CAAEzC,GAAG,EAAEC,KAAK,CAAE,KAAM;IACvDuC,MAAM,CAAEE,QAAQ,CAAE1C,GAAI,CAAC,CAAE,GAAG,IAAAI,cAAM,EAAER,UAAW,CAAC,CAC7CsC,SAAS,CAAE,CAAIjC,KAAK,GAAGgC,KAAK,GAAKE,KAAM,CAAC,CACzCX,KAAK,CAAC,CAAC;EACV,CAAE,CAAC;EAEH,OAAOgB,MAAM;AACd"}
1
+ {"version":3,"names":["_colord","require","_a11y","_interopRequireDefault","_names","_warning","_utils","extend","namesPlugin","a11yPlugin","generateThemeVariables","inputs","validateInputs","generatedColors","generateAccentDependentColors","accent","generateBackgroundDependentColors","background","warnContrastIssues","checkContrasts","colors","key","value","Object","entries","colord","isValid","SCRIPT_DEBUG","warning","outputs","COLORS","white","foreground","gray","isReadable","undefined","grays","contrast","issues","error","values","accentDarker10","darken","toHex","accentDarker20","accentInverted","getForegroundForColor","foregroundInverted","generateShades","color","isDark","SHADES","limit","direction","range","Math","abs","toHsl","l","result","forEach","parseInt"],"sources":["@wordpress/components/src/theme/color-algorithms.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport a11yPlugin from 'colord/plugins/a11y';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeInputValues, ThemeOutputValues } from './types';\nimport { COLORS } from '../utils';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nexport function generateThemeVariables(\n\tinputs: ThemeInputValues\n): ThemeOutputValues {\n\tvalidateInputs( inputs );\n\n\tconst generatedColors = {\n\t\t...generateAccentDependentColors( inputs.accent ),\n\t\t...generateBackgroundDependentColors( inputs.background ),\n\t};\n\n\twarnContrastIssues( checkContrasts( inputs, generatedColors ) );\n\n\treturn { colors: generatedColors };\n}\n\nfunction validateInputs( inputs: ThemeInputValues ) {\n\tfor ( const [ key, value ] of Object.entries( inputs ) ) {\n\t\tif ( typeof value !== 'undefined' && ! colord( value ).isValid() ) {\n\t\t\twarning(\n\t\t\t\t`wp.components.Theme: \"${ value }\" is not a valid color value for the '${ key }' prop.`\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport function checkContrasts(\n\tinputs: ThemeInputValues,\n\toutputs: ThemeOutputValues[ 'colors' ]\n) {\n\tconst background = inputs.background || COLORS.white;\n\tconst accent = inputs.accent || '#3858e9';\n\tconst foreground = outputs.foreground || COLORS.gray[ 900 ];\n\tconst gray = outputs.gray || COLORS.gray;\n\n\treturn {\n\t\taccent: colord( background ).isReadable( accent )\n\t\t\t? undefined\n\t\t\t: `The background color (\"${ background }\") does not have sufficient contrast against the accent color (\"${ accent }\").`,\n\t\tforeground: colord( background ).isReadable( foreground )\n\t\t\t? undefined\n\t\t\t: `The background color provided (\"${ background }\") does not have sufficient contrast against the standard foreground colors.`,\n\t\tgrays:\n\t\t\tcolord( background ).contrast( gray[ 600 ] ) >= 3 &&\n\t\t\tcolord( background ).contrast( gray[ 700 ] ) >= 4.5\n\t\t\t\t? undefined\n\t\t\t\t: `The background color provided (\"${ background }\") cannot generate a set of grayscale foreground colors with sufficient contrast. Try adjusting the color to be lighter or darker.`,\n\t};\n}\n\nfunction warnContrastIssues( issues: ReturnType< typeof checkContrasts > ) {\n\tfor ( const error of Object.values( issues ) ) {\n\t\tif ( error ) {\n\t\t\twarning( 'wp.components.Theme: ' + error );\n\t\t}\n\t}\n}\n\nfunction generateAccentDependentColors( accent?: string ) {\n\tif ( ! accent ) return {};\n\n\treturn {\n\t\taccent,\n\t\taccentDarker10: colord( accent ).darken( 0.1 ).toHex(),\n\t\taccentDarker20: colord( accent ).darken( 0.2 ).toHex(),\n\t\taccentInverted: getForegroundForColor( accent ),\n\t};\n}\n\nfunction generateBackgroundDependentColors( background?: string ) {\n\tif ( ! background ) return {};\n\n\tconst foreground = getForegroundForColor( background );\n\n\treturn {\n\t\tbackground,\n\t\tforeground,\n\t\tforegroundInverted: getForegroundForColor( foreground ),\n\t\tgray: generateShades( background, foreground ),\n\t};\n}\n\nfunction getForegroundForColor( color: string ) {\n\treturn colord( color ).isDark() ? COLORS.white : COLORS.gray[ 900 ];\n}\n\nexport function generateShades( background: string, foreground: string ) {\n\t// How much darkness you need to add to #fff to get the COLORS.gray[n] color\n\tconst SHADES = {\n\t\t100: 0.06,\n\t\t200: 0.121,\n\t\t300: 0.132,\n\t\t400: 0.2,\n\t\t600: 0.42,\n\t\t700: 0.543,\n\t\t800: 0.821,\n\t};\n\n\t// Darkness of COLORS.gray[ 900 ], relative to #fff\n\tconst limit = 0.884;\n\n\tconst direction = colord( background ).isDark() ? 'lighten' : 'darken';\n\n\t// Lightness delta between the background and foreground colors\n\tconst range =\n\t\tMath.abs(\n\t\t\tcolord( background ).toHsl().l - colord( foreground ).toHsl().l\n\t\t) / 100;\n\n\tconst result: Record< number, string > = {};\n\n\tObject.entries( SHADES ).forEach( ( [ key, value ] ) => {\n\t\tresult[ parseInt( key ) ] = colord( background )\n\t\t\t[ direction ]( ( value / limit ) * range )\n\t\t\t.toHex();\n\t} );\n\n\treturn result as NonNullable< ThemeOutputValues[ 'colors' ][ 'gray' ] >;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAKA,IAAAI,QAAA,GAAAF,sBAAA,CAAAF,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AAhBA;AACA;AACA;;AAKA;AACA;AACA;;AASA,IAAAM,cAAM,EAAE,CAAEC,cAAW,EAAEC,aAAU,CAAG,CAAC;AAE9B,SAASC,sBAAsBA,CACrCC,MAAwB,EACJ;EACpBC,cAAc,CAAED,MAAO,CAAC;EAExB,MAAME,eAAe,GAAG;IACvB,GAAGC,6BAA6B,CAAEH,MAAM,CAACI,MAAO,CAAC;IACjD,GAAGC,iCAAiC,CAAEL,MAAM,CAACM,UAAW;EACzD,CAAC;EAEDC,kBAAkB,CAAEC,cAAc,CAAER,MAAM,EAAEE,eAAgB,CAAE,CAAC;EAE/D,OAAO;IAAEO,MAAM,EAAEP;EAAgB,CAAC;AACnC;AAEA,SAASD,cAAcA,CAAED,MAAwB,EAAG;EACnD,KAAM,MAAM,CAAEU,GAAG,EAAEC,KAAK,CAAE,IAAIC,MAAM,CAACC,OAAO,CAAEb,MAAO,CAAC,EAAG;IACxD,IAAK,OAAOW,KAAK,KAAK,WAAW,IAAI,CAAE,IAAAG,c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ACA,MAAMC,KAAK,GAAG,KAAK;EAEnB,MAAMC,SAAS,GAAG,IAAA5B,cAAM,EAAER,UAAW,CAAC,CAACiC,MAAM,CAAC,CAAC,GAAG,SAAS,GAAG,QAAQ;;EAEtE;EACA,MAAMI,KAAK,GACVC,IAAI,CAACC,GAAG,CACP,IAAA/B,cAAM,EAAER,UAAW,CAAC,CAACwC,KAAK,CAAC,CAAC,CAACC,CAAC,GAAG,IAAAjC,cAAM,EAAEO,UAAW,CAAC,CAACyB,KAAK,CAAC,CAAC,CAACC,CAC/D,CAAC,GAAG,GAAG;EAER,MAAMC,MAAgC,GAAG,CAAC,CAAC;EAE3CpC,MAAM,CAACC,OAAO,CAAE2B,MAAO,CAAC,CAACS,OAAO,CAAE,CAAE,CAAEvC,GAAG,EAAEC,KAAK,CAAE,KAAM;IACvDqC,MAAM,CAAEE,QAAQ,CAAExC,GAAI,CAAC,CAAE,GAAG,IAAAI,cAAM,EAAER,UAAW,CAAC,CAC7CoC,SAAS,CAAE,CAAI/B,KAAK,GAAG8B,KAAK,GAAKE,KAAM,CAAC,CACzCX,KAAK,CAAC,CAAC;EACV,CAAE,CAAC;EAEH,OAAOgB,MAAM;AACd"}
@@ -29,7 +29,7 @@ function ToolbarItem({
29
29
  const accessibleToolbarStore = (0, _element.useContext)(_toolbarContext.default);
30
30
  const isRenderProp = typeof children === 'function';
31
31
  if (!isRenderProp && !Component) {
32
- typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)('`ToolbarItem` is a generic headless component. You must pass either a `children` prop as a function or an `as` prop as a component. ' + 'See https://developer.wordpress.org/block-editor/components/toolbar-item/') : void 0;
32
+ typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('`ToolbarItem` is a generic headless component. You must pass either a `children` prop as a function or an `as` prop as a component. ' + 'See https://developer.wordpress.org/block-editor/components/toolbar-item/') : void 0;
33
33
  return null;
34
34
  }
35
35
  const allProps = {
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_toolbar","_warning","_interopRequireDefault","_toolbarContext","ToolbarItem","children","as","Component","props","ref","accessibleToolbarStore","useContext","ToolbarContext","isRenderProp","process","env","NODE_ENV","warning","allProps","createElement","render","store","_default","forwardRef","exports","default"],"sources":["@wordpress/components/src/toolbar/toolbar-item/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { ToolbarItem as BaseToolbarItem } from '@ariakit/react/toolbar';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport ToolbarContext from '../toolbar-context';\nimport type { ToolbarItemProps } from './types';\n\nfunction ToolbarItem(\n\t{ children, as: Component, ...props }: ToolbarItemProps,\n\tref: ForwardedRef< any >\n) {\n\tconst accessibleToolbarStore = useContext( ToolbarContext );\n\tconst isRenderProp = typeof children === 'function';\n\n\tif ( ! isRenderProp && ! Component ) {\n\t\twarning(\n\t\t\t'`ToolbarItem` is a generic headless component. You must pass either a `children` prop as a function or an `as` prop as a component. ' +\n\t\t\t\t'See https://developer.wordpress.org/block-editor/components/toolbar-item/'\n\t\t);\n\t\treturn null;\n\t}\n\n\tconst allProps = { ...props, ref, 'data-toolbar-item': true };\n\n\tif ( ! accessibleToolbarStore ) {\n\t\tif ( Component ) {\n\t\t\treturn <Component { ...allProps }>{ children }</Component>;\n\t\t}\n\t\tif ( ! isRenderProp ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn children( allProps );\n\t}\n\n\tconst render = isRenderProp ? children : Component && <Component />;\n\n\treturn (\n\t\t<BaseToolbarItem\n\t\t\t{ ...allProps }\n\t\t\tstore={ accessibleToolbarStore }\n\t\t\trender={ render }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( ToolbarItem );\n"],"mappings":";;;;;;;AASA,IAAAA,QAAA,GAAAC,OAAA;AANA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE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C,mBAAU,EAAEnB,WAAY,CAAC;AAAAoB,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
1
+ {"version":3,"names":["_element","require","_toolbar","_warning","_interopRequireDefault","_toolbarContext","ToolbarItem","children","as","Component","props","ref","accessibleToolbarStore","useContext","ToolbarContext","isRenderProp","SCRIPT_DEBUG","warning","allProps","createElement","render","store","_default","forwardRef","exports","default"],"sources":["@wordpress/components/src/toolbar/toolbar-item/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { ToolbarItem as BaseToolbarItem } from '@ariakit/react/toolbar';\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport ToolbarContext from '../toolbar-context';\nimport type { ToolbarItemProps } from './types';\n\nfunction ToolbarItem(\n\t{ children, as: Component, ...props }: ToolbarItemProps,\n\tref: ForwardedRef< any >\n) {\n\tconst accessibleToolbarStore = useContext( ToolbarContext );\n\tconst isRenderProp = typeof children === 'function';\n\n\tif ( ! isRenderProp && ! Component ) {\n\t\twarning(\n\t\t\t'`ToolbarItem` is a generic headless component. You must pass either a `children` prop as a function or an `as` prop as a component. ' +\n\t\t\t\t'See https://developer.wordpress.org/block-editor/components/toolbar-item/'\n\t\t);\n\t\treturn null;\n\t}\n\n\tconst allProps = { ...props, ref, 'data-toolbar-item': true };\n\n\tif ( ! accessibleToolbarStore ) {\n\t\tif ( Component ) {\n\t\t\treturn <Component { ...allProps }>{ children }</Component>;\n\t\t}\n\t\tif ( ! isRenderProp ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn children( allProps );\n\t}\n\n\tconst render = isRenderProp ? children : Component && <Component />;\n\n\treturn (\n\t\t<BaseToolbarItem\n\t\t\t{ ...allProps }\n\t\t\tstore={ accessibleToolbarStore }\n\t\t\trender={ render }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( ToolbarItem );\n"],"mappings":";;;;;;;A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E,QAAA,GAEc,IAAAC,mBAAU,EAAEjB,WAAY,CAAC;AAAAkB,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
@@ -16,7 +16,7 @@ function ToolbarItem({
16
16
  ...props
17
17
  }, ref) {
18
18
  if (typeof children !== 'function') {
19
- typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)('`ToolbarItem` is a generic headless component that accepts only function children props') : void 0;
19
+ typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('`ToolbarItem` is a generic headless component that accepts only function children props') : void 0;
20
20
  return null;
21
21
  }
22
22
  return children({
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_warning","_interopRequireDefault","ToolbarItem","children","props","ref","process","env","NODE_ENV","warning","_default","forwardRef","exports","default"],"sources":["@wordpress/components/src/toolbar/toolbar-item/index.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\nfunction ToolbarItem( { children, ...props }, ref ) {\n\tif ( typeof children !== 'function' ) {\n\t\twarning(\n\t\t\t'`ToolbarItem` is a generic headless component that accepts only function children props'\n\t\t);\n\t\treturn null;\n\t}\n\treturn children( { ...props, ref } );\n}\n\nexport default forwardRef( ToolbarItem );\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAJA;AACA;AACA;;AAIA,SAASG,WAAWA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,EAAG;EACnD,IAAK,OAAOF,QAAQ,KAAK,UAAU,EAAG;IACrC,OAAAG,OAAA,oBAAAA,OAAA,CAAAC,GAAA,IAAAD,OAAA,CAAAC,GAAA,CAAAC,QAAA,wBAAAC,gBAAO,EACN,yFACD,CAAC;IACD,OAAO,IAAI;EACZ;EACA,OAAON,QAAQ,CAAE;IAAE,GAAGC,KAAK;IAAEC;EAAI,CAAE,CAAC;AACrC;AAAC,IAAAK,QAAA,GAEc,IAAAC,mBAAU,EAAET,WAAY,CAAC;AAAAU,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
1
+ {"version":3,"names":["_element","require","_warning","_interopRequireDefault","ToolbarItem","children","props","ref","SCRIPT_DEBUG","warning","_default","forwardRef","exports","default"],"sources":["@wordpress/components/src/toolbar/toolbar-item/index.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport warning from '@wordpress/warning';\n\nfunction ToolbarItem( { children, ...props }, ref ) {\n\tif ( typeof children !== 'function' ) {\n\t\twarning(\n\t\t\t'`ToolbarItem` is a generic headless component that accepts only function children props'\n\t\t);\n\t\treturn null;\n\t}\n\treturn children( { ...props, ref } );\n}\n\nexport default forwardRef( ToolbarItem );\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAJA;AACA;AACA;;AAIA,SAASG,WAAWA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,EAAG;EACnD,IAAK,OAAOF,QAAQ,KAAK,UAAU,EAAG;IACrC,OAAAG,YAAA,oBAAAA,YAAA,gBAAAC,gBAAO,EACN,yFACD,CAAC;IACD,OAAO,IAAI;EACZ;EACA,OAAOJ,QAAQ,CAAE;IAAE,GAAGC,KAAK;IAAEC;EAAI,CAAE,CAAC;AACrC;AAAC,IAAAG,QAAA,GAEc,IAAAC,mBAAU,EAAEP,WAAY,CAAC;AAAAQ,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
@@ -3,20 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.REACT_TYPEOF_KEY = exports.CONTEXT_COMPONENT_NAMESPACE = exports.CONNECT_STATIC_NAMESPACE = exports.CONNECTED_NAMESPACE = exports.COMPONENT_NAMESPACE = void 0;
7
- const REACT_TYPEOF_KEY = '$$typeof';
8
- exports.REACT_TYPEOF_KEY = REACT_TYPEOF_KEY;
6
+ exports.CONNECT_STATIC_NAMESPACE = exports.CONNECTED_NAMESPACE = exports.COMPONENT_NAMESPACE = void 0;
9
7
  const COMPONENT_NAMESPACE = 'data-wp-component';
10
8
  exports.COMPONENT_NAMESPACE = COMPONENT_NAMESPACE;
11
9
  const CONNECTED_NAMESPACE = 'data-wp-c16t';
12
- exports.CONNECTED_NAMESPACE = CONNECTED_NAMESPACE;
13
- const CONTEXT_COMPONENT_NAMESPACE = 'data-wp-c5tc8t';
14
10
 
15
11
  /**
16
12
  * Special key where the connected namespaces are stored.
17
13
  * This is attached to Context connected components as a static property.
18
14
  */
19
- exports.CONTEXT_COMPONENT_NAMESPACE = CONTEXT_COMPONENT_NAMESPACE;
15
+ exports.CONNECTED_NAMESPACE = CONNECTED_NAMESPACE;
20
16
  const CONNECT_STATIC_NAMESPACE = '__contextSystemKey__';
21
17
  exports.CONNECT_STATIC_NAMESPACE = CONNECT_STATIC_NAMESPACE;
22
18
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["REACT_TYPEOF_KEY","exports","COMPONENT_NAMESPACE","CONNECTED_NAMESPACE","CONTEXT_COMPONENT_NAMESPACE","CONNECT_STATIC_NAMESPACE"],"sources":["@wordpress/components/src/ui/context/constants.js"],"sourcesContent":["export const REACT_TYPEOF_KEY = '$$typeof';\nexport const COMPONENT_NAMESPACE = 'data-wp-component';\nexport const CONNECTED_NAMESPACE = 'data-wp-c16t';\nexport const CONTEXT_COMPONENT_NAMESPACE = 'data-wp-c5tc8t';\n\n/**\n * Special key where the connected namespaces are stored.\n * This is attached to Context connected components as a static property.\n */\nexport const CONNECT_STATIC_NAMESPACE = '__contextSystemKey__';\n"],"mappings":";;;;;;AAAO,MAAMA,gBAAgB,GAAG,UAAU;AAACC,OAAA,CAAAD,gBAAA,GAAAA,gBAAA;AACpC,MAAME,mBAAmB,GAAG,mBAAmB;AAACD,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AAChD,MAAMC,mBAAmB,GAAG,cAAc;AAACF,OAAA,CAAAE,mBAAA,GAAAA,mBAAA;AAC3C,MAAMC,2BAA2B,GAAG,gBAAgB;;AAE3D;AACA;AACA;AACA;AAHAH,OAAA,CAAAG,2BAAA,GAAAA,2BAAA;AAIO,MAAMC,wBAAwB,GAAG,sBAAsB;AAACJ,OAAA,CAAAI,wBAAA,GAAAA,wBAAA"}
1
+ {"version":3,"names":["COMPONENT_NAMESPACE","exports","CONNECTED_NAMESPACE","CONNECT_STATIC_NAMESPACE"],"sources":["@wordpress/components/src/ui/context/constants.js"],"sourcesContent":["export const COMPONENT_NAMESPACE = 'data-wp-component';\nexport const CONNECTED_NAMESPACE = 'data-wp-c16t';\n\n/**\n * Special key where the connected namespaces are stored.\n * This is attached to Context connected components as a static property.\n */\nexport const CONNECT_STATIC_NAMESPACE = '__contextSystemKey__';\n"],"mappings":";;;;;;AAAO,MAAMA,mBAAmB,GAAG,mBAAmB;AAACC,OAAA,CAAAD,mBAAA,GAAAA,mBAAA;AAChD,MAAME,mBAAmB,GAAG,cAAc;;AAEjD;AACA;AACA;AACA;AAHAD,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AAIO,MAAMC,wBAAwB,GAAG,sBAAsB;AAACF,OAAA,CAAAE,wBAAA,GAAAA,wBAAA"}
@@ -56,7 +56,7 @@ function contextConnectWithoutRef(Component, namespace) {
56
56
  function _contextConnect(Component, namespace, options) {
57
57
  const WrappedComponent = options?.forwardsRef ? (0, _element.forwardRef)(Component) : Component;
58
58
  if (typeof namespace === 'undefined') {
59
- typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)('contextConnect: Please provide a namespace') : void 0;
59
+ typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('contextConnect: Please provide a namespace') : void 0;
60
60
  }
61
61
 
62
62
  // @ts-expect-error internal property
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_warning","_interopRequireDefault","_constants","_getStyledClassNameFromKey","contextConnect","Component","namespace","_contextConnect","forwardsRef","contextConnectWithoutRef","options","WrappedComponent","forwardRef","process","env","NODE_ENV","warn","mergedNamespace","CONNECT_STATIC_NAMESPACE","Array","isArray","Object","assign","Set","displayName","selector","getStyledClassNameFromKey","getConnectNamespace","namespaces","type","hasConnectNamespace","match","includes","some","result"],"sources":["@wordpress/components/src/ui/context/context-connect.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, ReactChild, ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { CONNECT_STATIC_NAMESPACE } from './constants';\nimport { getStyledClassNameFromKey } from './get-styled-class-name-from-key';\nimport type { WordPressComponentFromProps } from '.';\n\ntype AcceptsTwoArgs<\n\tF extends ( ...args: any ) => any,\n\tErrorMessage = never\n> = Parameters< F >[ 'length' ] extends 2 ? {} : ErrorMessage;\n\ntype ContextConnectOptions = {\n\tforwardsRef?: boolean;\n};\n\n/**\n * Forwards ref (React.ForwardRef) and \"Connects\" (or registers) a component\n * within the Context system under a specified namespace.\n *\n * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @return The connected WordPressComponent\n */\nexport function contextConnect<\n\tC extends ( props: any, ref: ForwardedRef< any > ) => JSX.Element | null\n>(\n\tComponent: C &\n\t\tAcceptsTwoArgs<\n\t\t\tC,\n\t\t\t'Warning: Your component function does not take a ref as the second argument. Did you mean to use `contextConnectWithoutRef`?'\n\t\t>,\n\tnamespace: string\n) {\n\treturn _contextConnect( Component, namespace, { forwardsRef: true } );\n}\n\n/**\n * \"Connects\" (or registers) a component within the Context system under a specified namespace.\n * Does not forward a ref.\n *\n * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @return The connected WordPressComponent\n */\nexport function contextConnectWithoutRef< P >(\n\tComponent: ( props: P ) => JSX.Element | null,\n\tnamespace: string\n) {\n\treturn _contextConnect( Component, namespace );\n}\n\n// This is an (experimental) evolution of the initial connect() HOC.\n// The hope is that we can improve render performance by removing functional\n// component wrappers.\nfunction _contextConnect<\n\tC extends ( props: any, ref: ForwardedRef< any > ) => JSX.Element | null,\n\tO extends ContextConnectOptions\n>(\n\tComponent: C,\n\tnamespace: string,\n\toptions?: O\n): WordPressComponentFromProps<\n\tParameters< C >[ 0 ],\n\tO[ 'forwardsRef' ] extends true ? true : false\n> {\n\tconst WrappedComponent = options?.forwardsRef\n\t\t? forwardRef< any, Parameters< C >[ 0 ] >( Component )\n\t\t: Component;\n\n\tif ( typeof namespace === 'undefined' ) {\n\t\twarn( 'contextConnect: Please provide a namespace' );\n\t}\n\n\t// @ts-expect-error internal property\n\tlet mergedNamespace = WrappedComponent[ CONNECT_STATIC_NAMESPACE ] || [\n\t\tnamespace,\n\t];\n\n\t/**\n\t * Consolidate (merge) namespaces before attaching it to the WrappedComponent.\n\t */\n\tif ( Array.isArray( namespace ) ) {\n\t\tmergedNamespace = [ ...mergedNamespace, ...namespace ];\n\t}\n\tif ( typeof namespace === 'string' ) {\n\t\tmergedNamespace = [ ...mergedNamespace, namespace ];\n\t}\n\n\t// @ts-expect-error We can't rely on inferred types here because of the\n\t// `as` prop polymorphism we're handling in https://github.com/WordPress/gutenberg/blob/9620bae6fef4fde7cc2b7833f416e240207cda29/packages/components/src/ui/context/wordpress-component.ts#L32-L33\n\treturn Object.assign( WrappedComponent, {\n\t\t[ CONNECT_STATIC_NAMESPACE ]: [ ...new Set( mergedNamespace ) ],\n\t\tdisplayName: namespace,\n\t\tselector: `.${ getStyledClassNameFromKey( namespace ) }`,\n\t} );\n}\n\n/**\n * Attempts to retrieve the connected namespace from a component.\n *\n * @param Component The component to retrieve a namespace from.\n * @return The connected namespaces.\n */\nexport function getConnectNamespace(\n\tComponent: ReactChild | undefined | {}\n): string[] {\n\tif ( ! Component ) return [];\n\n\tlet namespaces = [];\n\n\t// @ts-ignore internal property\n\tif ( Component[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore internal property\n\t\tnamespaces = Component[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\t// @ts-ignore\n\tif ( Component.type && Component.type[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore\n\t\tnamespaces = Component.type[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\treturn namespaces;\n}\n\n/**\n * Checks to see if a component is connected within the Context system.\n *\n * @param Component The component to retrieve a namespace from.\n * @param match The namespace to check.\n */\nexport function hasConnectNamespace(\n\tComponent: ReactNode,\n\tmatch: string[] | string\n): boolean {\n\tif ( ! Component ) return false;\n\n\tif ( typeof match === 'string' ) {\n\t\treturn getConnectNamespace( Component ).includes( match );\n\t}\n\tif ( Array.isArray( match ) ) {\n\t\treturn match.some( ( result ) =>\n\t\t\tgetConnectNamespace( Component ).includes( result )\n\t\t);\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,0BAAA,GAAAJ,OAAA;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,cAAcA,CAG7BC,SAIE,EACFC,SAAiB,EAChB;EACD,OAAOC,eAAe,CAAEF,SAAS,EAAEC,SAAS,EAAE;IAAEE,WAAW,EAAE;EAAK,CAAE,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,wBAAwBA,CACvCJ,SAA6C,EAC7CC,SAAiB,EAChB;EACD,OAAOC,eAAe,CAAEF,SAAS,EAAEC,SAAU,CAAC;AAC/C;;AAEA;AACA;AACA;AACA,SAASC,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AAIxB,SAAS,CAACwB,IAAI,CAAEX,mCAAwB,CAAE,EAAG;IACnE;IACAU,UAAU,GAAGvB,SAAS,CAACwB,IAAI,CAAEX,mCAAwB,CAAE;EACxD;EAEA,OAAOU,UAAU;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,mBAAmBA,CAClCzB,SAAoB,EACpB0B,KAAwB,EACd;EACV,IAAK,CAAE1B,SAAS,EAAG,OAAO,KAAK;EAE/B,IAAK,OAAO0B,KAAK,KAAK,QAAQ,EAAG;IAChC,OAAOJ,mBAAmB,CAAEtB,SAAU,CAAC,CAAC2B,QAAQ,CAAED,KAAM,CAAC;EAC1D;EACA,IAAKZ,KAAK,CAACC,OAAO,CAAEW,KAAM,CAAC,EAAG;IAC7B,OAAOA,KAAK,CAACE,IAAI,CAAIC,MAAM,IAC1BP,mBAAmB,CAAEtB,SAAU,CAAC,CAAC2B,QAAQ,CAAEE,MAAO,CACnD,CAAC;EACF;EAEA,OAAO,KAAK;AACb"}
1
+ {"version":3,"names":["_element","require","_warning","_interopRequireDefault","_constants","_getStyledClassNameFromKey","contextConnect","Component","namespace","_contextConnect","forwardsRef","contextConnectWithoutRef","options","WrappedComponent","forwardRef","SCRIPT_DEBUG","warn","mergedNamespace","CONNECT_STATIC_NAMESPACE","Array","isArray","Object","assign","Set","displayName","selector","getStyledClassNameFromKey","getConnectNamespace","namespaces","type","hasConnectNamespace","match","includes","some","result"],"sources":["@wordpress/components/src/ui/context/context-connect.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, ReactChild, ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { CONNECT_STATIC_NAMESPACE } from './constants';\nimport { getStyledClassNameFromKey } from './get-styled-class-name-from-key';\nimport type { WordPressComponentFromProps } from '.';\n\ntype AcceptsTwoArgs<\n\tF extends ( ...args: any ) => any,\n\tErrorMessage = never\n> = Parameters< F >[ 'length' ] extends 2 ? {} : ErrorMessage;\n\ntype ContextConnectOptions = {\n\tforwardsRef?: boolean;\n};\n\n/**\n * Forwards ref (React.ForwardRef) and \"Connects\" (or registers) a component\n * within the Context system under a specified namespace.\n *\n * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @return The connected WordPressComponent\n */\nexport function contextConnect<\n\tC extends ( props: any, ref: ForwardedRef< any > ) => JSX.Element | null\n>(\n\tComponent: C &\n\t\tAcceptsTwoArgs<\n\t\t\tC,\n\t\t\t'Warning: Your component function does not take a ref as the second argument. Did you mean to use `contextConnectWithoutRef`?'\n\t\t>,\n\tnamespace: string\n) {\n\treturn _contextConnect( Component, namespace, { forwardsRef: true } );\n}\n\n/**\n * \"Connects\" (or registers) a component within the Context system under a specified namespace.\n * Does not forward a ref.\n *\n * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @return The connected WordPressComponent\n */\nexport function contextConnectWithoutRef< P >(\n\tComponent: ( props: P ) => JSX.Element | null,\n\tnamespace: string\n) {\n\treturn _contextConnect( Component, namespace );\n}\n\n// This is an (experimental) evolution of the initial connect() HOC.\n// The hope is that we can improve render performance by removing functional\n// component wrappers.\nfunction _contextConnect<\n\tC extends ( props: any, ref: ForwardedRef< any > ) => JSX.Element | null,\n\tO extends ContextConnectOptions\n>(\n\tComponent: C,\n\tnamespace: string,\n\toptions?: O\n): WordPressComponentFromProps<\n\tParameters< C >[ 0 ],\n\tO[ 'forwardsRef' ] extends true ? true : false\n> {\n\tconst WrappedComponent = options?.forwardsRef\n\t\t? forwardRef< any, Parameters< C >[ 0 ] >( Component )\n\t\t: Component;\n\n\tif ( typeof namespace === 'undefined' ) {\n\t\twarn( 'contextConnect: Please provide a namespace' );\n\t}\n\n\t// @ts-expect-error internal property\n\tlet mergedNamespace = WrappedComponent[ CONNECT_STATIC_NAMESPACE ] || [\n\t\tnamespace,\n\t];\n\n\t/**\n\t * Consolidate (merge) namespaces before attaching it to the WrappedComponent.\n\t */\n\tif ( Array.isArray( namespace ) ) {\n\t\tmergedNamespace = [ ...mergedNamespace, ...namespace ];\n\t}\n\tif ( typeof namespace === 'string' ) {\n\t\tmergedNamespace = [ ...mergedNamespace, namespace ];\n\t}\n\n\t// @ts-expect-error We can't rely on inferred types here because of the\n\t// `as` prop polymorphism we're handling in https://github.com/WordPress/gutenberg/blob/9620bae6fef4fde7cc2b7833f416e240207cda29/packages/components/src/ui/context/wordpress-component.ts#L32-L33\n\treturn Object.assign( WrappedComponent, {\n\t\t[ CONNECT_STATIC_NAMESPACE ]: [ ...new Set( mergedNamespace ) ],\n\t\tdisplayName: namespace,\n\t\tselector: `.${ getStyledClassNameFromKey( namespace ) }`,\n\t} );\n}\n\n/**\n * Attempts to retrieve the connected namespace from a component.\n *\n * @param Component The component to retrieve a namespace from.\n * @return The connected namespaces.\n */\nexport function getConnectNamespace(\n\tComponent: ReactChild | undefined | {}\n): string[] {\n\tif ( ! Component ) return [];\n\n\tlet namespaces = [];\n\n\t// @ts-ignore internal property\n\tif ( Component[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore internal property\n\t\tnamespaces = Component[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\t// @ts-ignore\n\tif ( Component.type && Component.type[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore\n\t\tnamespaces = Component.type[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\treturn namespaces;\n}\n\n/**\n * Checks to see if a component is connected within the Context system.\n *\n * @param Component The component to retrieve a namespace from.\n * @param match The namespace to check.\n */\nexport function hasConnectNamespace(\n\tComponent: ReactNode,\n\tmatch: string[] | string\n): boolean {\n\tif ( ! Component ) return false;\n\n\tif ( typeof match === 'string' ) {\n\t\treturn getConnectNamespace( Component ).includes( match );\n\t}\n\tif ( Array.isArray( match ) ) {\n\t\treturn match.some( ( result ) =>\n\t\t\tgetConnectNamespace( Component ).includes( result )\n\t\t);\n\t}\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
49
49
  // But not the same reference.
50
50
  valueRef.current !== value) {
51
- typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)(`Please memoize your context: ${JSON.stringify(value)}`) : void 0;
51
+ typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)(`Please memoize your context: ${JSON.stringify(value)}`) : void 0;
52
52
  }
53
53
  }, [value]);
54
54
 
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_deepmerge","_interopRequireDefault","_es","_isPlainObject","_warning","_utils","ComponentsContext","createContext","exports","useComponentsContext","useContext","useContextSystemBridge","value","parentContext","valueRef","useRef","useUpdateEffect","fastDeepEqual","current","process","env","NODE_ENV","warn","JSON","stringify","config","useMemo","deepmerge","isMergeableObject","isPlainObject","BaseContextSystemProvider","children","contextValue","createElement","Provider","ContextSystemProvider","memo"],"sources":["@wordpress/components/src/ui/context/context-system-provider.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport deepmerge from 'deepmerge';\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { isPlainObject } from 'is-plain-object';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseRef,\n\tuseMemo,\n\tmemo,\n} from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { useUpdateEffect } from '../../utils';\n\nexport const ComponentsContext = createContext(\n\t/** @type {Record<string, any>} */ ( {} )\n);\nexport const useComponentsContext = () => useContext( ComponentsContext );\n\n/**\n * Consolidates incoming ContextSystem values with a (potential) parent ContextSystem value.\n *\n * Note: This function will warn if it detects an un-memoized `value`\n *\n * @param {Object} props\n * @param {Record<string, any>} props.value\n * @return {Record<string, any>} The consolidated value.\n */\nfunction useContextSystemBridge( { value } ) {\n\tconst parentContext = useComponentsContext();\n\n\tconst valueRef = useRef( value );\n\n\tuseUpdateEffect( () => {\n\t\tif (\n\t\t\t// Objects are equivalent.\n\t\t\tfastDeepEqual( valueRef.current, value ) &&\n\t\t\t// But not the same reference.\n\t\t\tvalueRef.current !== value\n\t\t) {\n\t\t\twarn( `Please memoize your context: ${ JSON.stringify( value ) }` );\n\t\t}\n\t}, [ value ] );\n\n\t// `parentContext` will always be memoized (i.e., the result of this hook itself)\n\t// or the default value from when the `ComponentsContext` was originally\n\t// initialized (which will never change, it's a static variable)\n\t// so this memoization will prevent `deepmerge()` from rerunning unless\n\t// the references to `value` change OR the `parentContext` has an actual material change\n\t// (because again, it's guaranteed to be memoized or a static reference to the empty object\n\t// so we know that the only changes for `parentContext` are material ones... i.e., why we\n\t// don't have to warn in the `useUpdateEffect` hook above for `parentContext` and we only\n\t// need to bother with the `value`). The `useUpdateEffect` above will ensure that we are\n\t// correctly warning when the `value` isn't being properly memoized. All of that to say\n\t// that this should be super safe to assume that `useMemo` will only run on actual\n\t// changes to the two dependencies, therefore saving us calls to `deepmerge()`!\n\tconst config = useMemo( () => {\n\t\t// Deep clone `parentContext` to avoid mutating it later.\n\t\treturn deepmerge( parentContext ?? {}, value ?? {}, {\n\t\t\tisMergeableObject: isPlainObject,\n\t\t} );\n\t}, [ parentContext, value ] );\n\n\treturn config;\n}\n\n/**\n * A Provider component that can modify props for connected components within\n * the Context system.\n *\n * @example\n * ```jsx\n * <ContextSystemProvider value={{ Button: { size: 'small' }}}>\n * <Button>...</Button>\n * </ContextSystemProvider>\n * ```\n *\n * @template {Record<string, any>} T\n * @param {Object} options\n * @param {import('react').ReactNode} options.children Children to render.\n * @param {T} options.value Props to render into connected components.\n * @return {JSX.Element} A Provider wrapped component.\n */\nconst BaseContextSystemProvider = ( { children, value } ) => {\n\tconst contextValue = useContextSystemBridge( { value } );\n\n\treturn (\n\t\t<ComponentsContext.Provider value={ contextValue }>\n\t\t\t{ children }\n\t\t</ComponentsContext.Provider>\n\t);\n};\n\nexport const ContextSystemProvider = memo( BaseContextSystemProvider );\n"],"mappings":";;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AAPA,IAAAC,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AbA,aAAa,GAAI,CAAC,CAAC,EAAED,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,CAAC,CAAC,EAAE;MACnDgB,iBAAiB,EAAEC;IACpB,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEhB,aAAa,EAAED,KAAK,CAAG,CAAC;EAE7B,OAAOa,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,yBAAyB,GAAGA,CAAE;EAAEC,QAAQ;EAAEnB;AAAM,CAAC,KAAM;EAC5D,MAAMoB,YAAY,GAAGrB,sBAAsB,CAAE;IAAEC;EAAM,CAAE,CAAC;EAExD,OACC,IAAAd,QAAA,CAAAmC,aAAA,EAAC3B,iBAAiB,CAAC4B,QAAQ;IAACtB,KAAK,EAAGoB;EAAc,GAC/CD,QACyB,CAAC;AAE/B,CAAC;AAEM,MAAMI,qBAAqB,GAAG,IAAAC,aAAI,EAAEN,yBAA0B,CAAC;AAACtB,OAAA,CAAA2B,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"names":["_element","require","_deepmerge","_interopRequireDefault","_es","_isPlainObject","_warning","_utils","ComponentsContext","createContext","exports","useComponentsContext","useContext","useContextSystemBridge","value","parentContext","valueRef","useRef","useUpdateEffect","fastDeepEqual","current","SCRIPT_DEBUG","warn","JSON","stringify","config","useMemo","deepmerge","isMergeableObject","isPlainObject","BaseContextSystemProvider","children","contextValue","createElement","Provider","ContextSystemProvider","memo"],"sources":["@wordpress/components/src/ui/context/context-system-provider.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport deepmerge from 'deepmerge';\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { isPlainObject } from 'is-plain-object';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseRef,\n\tuseMemo,\n\tmemo,\n} from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { useUpdateEffect } from '../../utils';\n\nexport const ComponentsContext = createContext(\n\t/** @type {Record<string, any>} */ ( {} )\n);\nexport const useComponentsContext = () => useContext( ComponentsContext );\n\n/**\n * Consolidates incoming ContextSystem values with a (potential) parent ContextSystem value.\n *\n * Note: This function will warn if it detects an un-memoized `value`\n *\n * @param {Object} props\n * @param {Record<string, any>} props.value\n * @return {Record<string, any>} The consolidated value.\n */\nfunction useContextSystemBridge( { value } ) {\n\tconst parentContext = useComponentsContext();\n\n\tconst valueRef = useRef( value );\n\n\tuseUpdateEffect( () => {\n\t\tif (\n\t\t\t// Objects are equivalent.\n\t\t\tfastDeepEqual( valueRef.current, value ) &&\n\t\t\t// But not the same reference.\n\t\t\tvalueRef.current !== value\n\t\t) {\n\t\t\twarn( `Please memoize your context: ${ JSON.stringify( value ) }` );\n\t\t}\n\t}, [ value ] );\n\n\t// `parentContext` will always be memoized (i.e., the result of this hook itself)\n\t// or the default value from when the `ComponentsContext` was originally\n\t// initialized (which will never change, it's a static variable)\n\t// so this memoization will prevent `deepmerge()` from rerunning unless\n\t// the references to `value` change OR the `parentContext` has an actual material change\n\t// (because again, it's guaranteed to be memoized or a static reference to the empty object\n\t// so we know that the only changes for `parentContext` are material ones... i.e., why we\n\t// don't have to warn in the `useUpdateEffect` hook above for `parentContext` and we only\n\t// need to bother with the `value`). The `useUpdateEffect` above will ensure that we are\n\t// correctly warning when the `value` isn't being properly memoized. All of that to say\n\t// that this should be super safe to assume that `useMemo` will only run on actual\n\t// changes to the two dependencies, therefore saving us calls to `deepmerge()`!\n\tconst config = useMemo( () => {\n\t\t// Deep clone `parentContext` to avoid mutating it later.\n\t\treturn deepmerge( parentContext ?? {}, value ?? {}, {\n\t\t\tisMergeableObject: isPlainObject,\n\t\t} );\n\t}, [ parentContext, value ] );\n\n\treturn config;\n}\n\n/**\n * A Provider component that can modify props for connected components within\n * the Context system.\n *\n * @example\n * ```jsx\n * <ContextSystemProvider value={{ Button: { size: 'small' }}}>\n * <Button>...</Button>\n * </ContextSystemProvider>\n * ```\n *\n * @template {Record<string, any>} T\n * @param {Object} options\n * @param {import('react').ReactNode} options.children Children to render.\n * @param {T} options.value Props to render into connected components.\n * @return {JSX.Element} A Provider wrapped component.\n */\nconst BaseContextSystemProvider = ( { children, value } ) => {\n\tconst contextValue = useContextSystemBridge( { value } );\n\n\treturn (\n\t\t<ComponentsContext.Provider value={ contextValue }>\n\t\t\t{ children }\n\t\t</ComponentsContext.Provider>\n\t);\n};\n\nexport const ContextSystemProvider = memo( BaseContextSystemProvider );\n"],"mappings":";;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AAPA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,GAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAYA,IAAAK,QAAA,GAAAH,sBAAA,CAAAF,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AAtBA;AACA;AACA;;AAKA;AACA;AACA;;AAUA;AACA;AACA;;AAGO,MAAMO,iBAAiB,GAAG,IAAAC,sBAAa,GAC7C,kCAAqC,CAAC,CACvC,CAAC;AAACC,OAAA,CAAAF,iBAAA,GAAAA,iBAAA;AACK,MAAMG,oBAAoB,GAAGA,CAAA,KAAM,IAAAC,mBAAU,EAAEJ,iBAAkB,CAAC;;AAEzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARAE,OAAA,CAAAC,oBAAA,GAAAA,oBAAA;AASA,SAASE,sBAAsBA,CAAE;EAAEC;AAAM,CAAC,EAAG;EAC5C,MAAMC,aAAa,GAAGJ,oBAAoB,CAAC,CAAC;EAE5C,MAAMK,QAAQ,GAAG,IAAAC,eAAM,EAAEH,KAAM,CAAC;EAEhC,IAAAI,sBAAe,EAAE,MAAM;IACtB;IACC;IACA,IAAAC,WAAa,EAAEH,QAAQ,CAACI,OAAO,EAAEN,KAAM,CAAC;IACxC;IACAE,QAAQ,CAACI,OAAO,KAAKN,KAAK,EACzB;MACD,OAAAO,YAAA,oBAAAA,YAAA,gBAAAC,gBAAI,EAAG,gCAAgCC,IAAI,CAACC,SAAS,CAAEV,KAAM,CAAG,EAAE,CAAC;IACpE;EACD,CAAC,EAAE,CAAEA,KAAK,CAAG,CAAC;;EAEd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAMW,MAAM,GAAG,IAAAC,gBAAO,EAAE,MAAM;IAC7B;IACA,OAAO,IAAAC,kBAAS,EAAEZ,aAAa,aAAbA,aAAa,cAAbA,aAAa,GAAI,CAAC,CAAC,EAAED,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,CAAC,CAAC,EAAE;MACnDc,iBAAiB,EAAEC;IACpB,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEd,aAAa,EAAED,KAAK,CAAG,CAAC;EAE7B,OAAOW,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,yBAAyB,GAAGA,CAAE;EAAEC,QAAQ;EAAEjB;AAAM,CAAC,KAAM;EAC5D,MAAMkB,YAAY,GAAGnB,sBAAsB,CAAE;IAAEC;EAAM,CAAE,CAAC;EAExD,OACC,IAAAd,QAAA,CAAAiC,aAAA,EAACzB,iBAAiB,CAAC0B,QAAQ;IAACpB,KAAK,EAAGkB;EAAc,GAC/CD,QACyB,CAAC;AAE/B,CAAC;AAEM,MAAMI,qBAAqB,GAAG,IAAAC,aAAI,EAAEN,yBAA0B,CAAC;AAACpB,OAAA,CAAAyB,qBAAA,GAAAA,qBAAA"}
@@ -35,7 +35,7 @@ var _useCx = require("../../utils/hooks/use-cx");
35
35
  function useContextSystem(props, namespace) {
36
36
  const contextSystemProps = (0, _contextSystemProvider.useComponentsContext)();
37
37
  if (typeof namespace === 'undefined') {
38
- typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)('useContextSystem: Please provide a namespace') : void 0;
38
+ typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? (0, _warning.default)('useContextSystem: Please provide a namespace') : void 0;
39
39
  }
40
40
  const contextProps = contextSystemProps?.[namespace] || {};
41
41
 
@@ -1 +1 @@
1
- {"version":3,"names":["_warning","_interopRequireDefault","require","_contextSystemProvider","_utils","_getStyledClassNameFromKey","_useCx","useContextSystem","props","namespace","contextSystemProps","useComponentsContext","process","env","NODE_ENV","warn","contextProps","finalComponentProps","getConnectedNamespace","getNamespace","_overrides","overrideProps","otherContextProps","initialMergedProps","Object","entries","length","assign","cx","useCx","classes","getStyledClassNameFromKey","className","rendered","renderChildren","children","key","undefined"],"sources":["@wordpress/components/src/ui/context/use-context-system.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { useComponentsContext } from './context-system-provider';\nimport { getNamespace, getConnectedNamespace } from './utils';\nimport { getStyledClassNameFromKey } from './get-styled-class-name-from-key';\nimport { useCx } from '../../utils/hooks/use-cx';\n\n/**\n * @template TProps\n * @typedef {TProps & { className: string }} ConnectedProps\n */\n\n/**\n * Custom hook that derives registered props from the Context system.\n * These derived props are then consolidated with incoming component props.\n *\n * @template {{ className?: string }} P\n * @param {P} props Incoming props from the component.\n * @param {string} namespace The namespace to register and to derive context props from.\n * @return {ConnectedProps<P>} The connected props.\n */\nexport function useContextSystem( props, namespace ) {\n\tconst contextSystemProps = useComponentsContext();\n\tif ( typeof namespace === 'undefined' ) {\n\t\twarn( 'useContextSystem: Please provide a namespace' );\n\t}\n\n\tconst contextProps = contextSystemProps?.[ namespace ] || {};\n\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {ConnectedProps<P>} */\n\t// @ts-ignore We fill in the missing properties below\n\tconst finalComponentProps = {\n\t\t...getConnectedNamespace(),\n\t\t...getNamespace( namespace ),\n\t};\n\t/* eslint-enable jsdoc/no-undefined-types */\n\n\tconst { _overrides: overrideProps, ...otherContextProps } = contextProps;\n\n\tconst initialMergedProps = Object.entries( otherContextProps ).length\n\t\t? Object.assign( {}, otherContextProps, props )\n\t\t: props;\n\n\tconst cx = useCx();\n\n\tconst classes = cx(\n\t\tgetStyledClassNameFromKey( namespace ),\n\t\tprops.className\n\t);\n\n\t// Provides the ability to customize the render of the component.\n\tconst rendered =\n\t\ttypeof initialMergedProps.renderChildren === 'function'\n\t\t\t? initialMergedProps.renderChildren( initialMergedProps )\n\t\t\t: initialMergedProps.children;\n\n\tfor ( const key in initialMergedProps ) {\n\t\t// @ts-ignore filling in missing props\n\t\tfinalComponentProps[ key ] = initialMergedProps[ key ];\n\t}\n\n\tfor ( const key in overrideProps ) {\n\t\t// @ts-ignore filling in missing props\n\t\tfinalComponentProps[ key ] = overrideProps[ key ];\n\t}\n\n\t// Setting an `undefined` explicitly can cause unintended overwrites\n\t// when a `cloneElement()` is involved.\n\tif ( rendered !== undefined ) {\n\t\t// @ts-ignore\n\t\tfinalComponentProps.children = rendered;\n\t}\n\n\tfinalComponentProps.className = classes;\n\n\treturn finalComponentProps;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,gBAAgBA,CAAEC,KAAK,EAAEC,SAAS,EAAG;EACpD,MAAMC,kBAAkB,GAAG,IAAAC,2CAAoB,EAAC,CAAC;EACjD,IAAK,OAAOF,SAAS,KAAK,WAAW,EAAG;IACvC,OAAAG,OAAA,oBAAAA,OAAA,CAAAC,GAAA,IAAAD,OAAA,CAAAC,GAAA,CAAAC,QAAA,w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,mBAAmB;AAC3B"}
1
+ {"version":3,"names":["_warning","_interopRequireDefault","require","_contextSystemProvider","_utils","_getStyledClassNameFromKey","_useCx","useContextSystem","props","namespace","contextSystemProps","useComponentsContext","SCRIPT_DEBUG","warn","contextProps","finalComponentProps","getConnectedNamespace","getNamespace","_overrides","overrideProps","otherContextProps","initialMergedProps","Object","entries","length","assign","cx","useCx","classes","getStyledClassNameFromKey","className","rendered","renderChildren","children","key","undefined"],"sources":["@wordpress/components/src/ui/context/use-context-system.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { useComponentsContext } from './context-system-provider';\nimport { getNamespace, getConnectedNamespace } from './utils';\nimport { getStyledClassNameFromKey } from './get-styled-class-name-from-key';\nimport { useCx } from '../../utils/hooks/use-cx';\n\n/**\n * @template TProps\n * @typedef {TProps & { className: string }} ConnectedProps\n */\n\n/**\n * Custom hook that derives registered props from the Context system.\n * These derived props are then consolidated with incoming component props.\n *\n * @template {{ className?: string }} P\n * @param {P} props Incoming props from the component.\n * @param {string} namespace The namespace to register and to derive context props from.\n * @return {ConnectedProps<P>} The connected props.\n */\nexport function useContextSystem( props, namespace ) {\n\tconst contextSystemProps = useComponentsContext();\n\tif ( typeof namespace === 'undefined' ) {\n\t\twarn( 'useContextSystem: Please provide a namespace' );\n\t}\n\n\tconst contextProps = contextSystemProps?.[ namespace ] || {};\n\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {ConnectedProps<P>} */\n\t// @ts-ignore We fill in the missing properties below\n\tconst finalComponentProps = {\n\t\t...getConnectedNamespace(),\n\t\t...getNamespace( namespace ),\n\t};\n\t/* eslint-enable jsdoc/no-undefined-types */\n\n\tconst { _overrides: overrideProps, ...otherContextProps } = contextProps;\n\n\tconst initialMergedProps = Object.entries( otherContextProps ).length\n\t\t? Object.assign( {}, otherContextProps, props )\n\t\t: props;\n\n\tconst cx = useCx();\n\n\tconst classes = cx(\n\t\tgetStyledClassNameFromKey( namespace ),\n\t\tprops.className\n\t);\n\n\t// Provides the ability to customize the render of the component.\n\tconst rendered =\n\t\ttypeof initialMergedProps.renderChildren === 'function'\n\t\t\t? initialMergedProps.renderChildren( initialMergedProps )\n\t\t\t: initialMergedProps.children;\n\n\tfor ( const key in initialMergedProps ) {\n\t\t// @ts-ignore filling in missing props\n\t\tfinalComponentProps[ key ] = initialMergedProps[ key ];\n\t}\n\n\tfor ( const key in overrideProps ) {\n\t\t// @ts-ignore filling in missing props\n\t\tfinalComponentProps[ key ] = overrideProps[ key ];\n\t}\n\n\t// Setting an `undefined` explicitly can cause unintended overwrites\n\t// when a `cloneElement()` is involved.\n\tif ( rendered !== undefined ) {\n\t\t// @ts-ignore\n\t\tfinalComponentProps.children = rendered;\n\t}\n\n\tfinalComponentProps.className = classes;\n\n\treturn finalComponentProps;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,gBAAgBA,CAAEC,KAAK,EAAEC,SAAS,EAAG;EACpD,MAAMC,kBAAkB,GAAG,IAAAC,2CAAoB,EAAC,CAAC;EACjD,IAAK,OAAOF,SAAS,KAAK,WAAW,EAAG;IACvC,OAAAG,YAAA,oBAAAA,YAAA,gBAAAC,gBAAI,EAAE,8CAA+C,CAAC;EACvD;EAEA,MAAMC,YAAY,GAAGJ,kBAAkB,GAAID,SAAS,CAAE,IAAI,CAAC,CAAC;;EAE5D;EACA;EACA;EACA,MAAMM,mBAAmB,GAAG;IAC3B,GAAG,IAAAC,4BAAqB,EAAC,CAAC;IAC1B,GAAG,IAA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