@wordpress/block-editor 15.21.1 → 15.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (490) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -2
  3. package/build/components/block-card/index.cjs +4 -5
  4. package/build/components/block-card/index.cjs.map +2 -2
  5. package/build/components/block-editing-mode/index.cjs +13 -7
  6. package/build/components/block-editing-mode/index.cjs.map +2 -2
  7. package/build/components/block-inspector/index.cjs +35 -20
  8. package/build/components/block-inspector/index.cjs.map +2 -2
  9. package/build/components/block-mover/mover-description.cjs +6 -6
  10. package/build/components/block-mover/mover-description.cjs.map +1 -1
  11. package/build/components/block-patterns-list/index.cjs.map +2 -2
  12. package/build/components/block-patterns-paging/index.cjs +4 -4
  13. package/build/components/block-patterns-paging/index.cjs.map +2 -2
  14. package/build/components/block-popover/use-popover-scroll.cjs.map +1 -1
  15. package/build/components/block-quick-navigation/index.cjs +7 -5
  16. package/build/components/block-quick-navigation/index.cjs.map +2 -2
  17. package/build/components/block-rename/modal.cjs +0 -1
  18. package/build/components/block-rename/modal.cjs.map +2 -2
  19. package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
  20. package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
  21. package/build/components/block-toolbar/edit-section-button.cjs.map +1 -1
  22. package/build/components/block-tools/use-block-toolbar-popover-props.cjs +10 -4
  23. package/build/components/block-tools/use-block-toolbar-popover-props.cjs.map +2 -2
  24. package/build/components/child-layout-control/index.cjs +51 -19
  25. package/build/components/child-layout-control/index.cjs.map +2 -2
  26. package/build/components/colors-gradients/control.cjs +25 -14
  27. package/build/components/colors-gradients/control.cjs.map +2 -2
  28. package/build/components/colors-gradients/dropdown.cjs +4 -1
  29. package/build/components/colors-gradients/dropdown.cjs.map +3 -3
  30. package/build/components/contrast-checker/index.cjs +22 -4
  31. package/build/components/contrast-checker/index.cjs.map +2 -2
  32. package/build/components/date-format-picker/index.cjs +0 -1
  33. package/build/components/date-format-picker/index.cjs.map +2 -2
  34. package/build/components/dimensions-tool/index.cjs +4 -5
  35. package/build/components/dimensions-tool/index.cjs.map +2 -2
  36. package/build/components/dimensions-tool/scale-tool.cjs +1 -1
  37. package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
  38. package/build/components/global-styles/background-panel.cjs +153 -25
  39. package/build/components/global-styles/background-panel.cjs.map +3 -3
  40. package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
  41. package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
  42. package/build/components/global-styles/color-panel.cjs +98 -375
  43. package/build/components/global-styles/color-panel.cjs.map +3 -3
  44. package/build/components/global-styles/dimensions-panel.cjs +1 -4
  45. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  46. package/build/components/global-styles/hooks.cjs +34 -0
  47. package/build/components/global-styles/hooks.cjs.map +2 -2
  48. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  49. package/build/components/global-styles/typography-panel.cjs +82 -10
  50. package/build/components/global-styles/typography-panel.cjs.map +3 -3
  51. package/build/components/grid/grid-item-resizer.cjs.map +1 -1
  52. package/build/components/grid/grid-visualizer.cjs.map +1 -1
  53. package/build/components/iframe/index.cjs +6 -3
  54. package/build/components/iframe/index.cjs.map +3 -3
  55. package/build/components/image-editor/use-transform-image.cjs.map +1 -1
  56. package/build/components/inserter/get-appender-label.cjs.map +1 -1
  57. package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
  58. package/build/components/inserter/search-items.cjs.map +1 -1
  59. package/build/components/inspector-controls/fill.cjs +1 -3
  60. package/build/components/inspector-controls/fill.cjs.map +2 -2
  61. package/build/components/inspector-controls/groups.cjs +2 -0
  62. package/build/components/inspector-controls/groups.cjs.map +2 -2
  63. package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
  64. package/build/components/inspector-controls-tabs/styles-tab.cjs +76 -32
  65. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  66. package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
  67. package/build/components/line-height-control/index.cjs.map +1 -1
  68. package/build/components/link-control/index.cjs +2 -3
  69. package/build/components/link-control/index.cjs.map +2 -2
  70. package/build/components/link-control/normalize-url.cjs.map +1 -1
  71. package/build/components/list-view/block-select-button.cjs +1 -10
  72. package/build/components/list-view/block-select-button.cjs.map +3 -3
  73. package/build/components/list-view/utils.cjs.map +1 -1
  74. package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
  75. package/build/components/provider/index.cjs.map +1 -1
  76. package/build/components/provider/use-block-sync.cjs +3 -1
  77. package/build/components/provider/use-block-sync.cjs.map +2 -2
  78. package/build/components/rich-text/event-listeners/before-input-rules.cjs +1 -1
  79. package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +2 -2
  80. package/build/components/rich-text/event-listeners/paste-handler.cjs.map +1 -1
  81. package/build/components/rich-text/prevent-event-discovery.cjs +1 -1
  82. package/build/components/rich-text/prevent-event-discovery.cjs.map +1 -1
  83. package/build/components/url-popover/image-url-input-ui.cjs +0 -2
  84. package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
  85. package/build/components/use-block-display-information/index.cjs +10 -3
  86. package/build/components/use-block-display-information/index.cjs.map +2 -2
  87. package/build/components/writing-flow/use-tab-nav.cjs.map +1 -1
  88. package/build/hooks/anchor.cjs +1 -2
  89. package/build/hooks/anchor.cjs.map +2 -2
  90. package/build/hooks/background.cjs +124 -75
  91. package/build/hooks/background.cjs.map +3 -3
  92. package/build/hooks/block-fields/index.cjs +13 -2
  93. package/build/hooks/block-fields/index.cjs.map +2 -2
  94. package/build/hooks/color.cjs +0 -162
  95. package/build/hooks/color.cjs.map +3 -3
  96. package/build/hooks/contrast-checker.cjs +31 -28
  97. package/build/hooks/contrast-checker.cjs.map +3 -3
  98. package/build/hooks/custom-class-name.cjs +0 -1
  99. package/build/hooks/custom-class-name.cjs.map +2 -2
  100. package/build/hooks/dimensions.cjs +13 -2
  101. package/build/hooks/dimensions.cjs.map +2 -2
  102. package/build/hooks/elements.cjs +142 -0
  103. package/build/hooks/elements.cjs.map +7 -0
  104. package/build/hooks/grid-visualizer.cjs +21 -11
  105. package/build/hooks/grid-visualizer.cjs.map +2 -2
  106. package/build/hooks/layout-child.cjs +65 -10
  107. package/build/hooks/layout-child.cjs.map +2 -2
  108. package/build/hooks/layout.cjs +6 -3
  109. package/build/hooks/layout.cjs.map +2 -2
  110. package/build/hooks/list-view.cjs +10 -7
  111. package/build/hooks/list-view.cjs.map +2 -2
  112. package/build/hooks/spacing-visualizer.cjs.map +1 -1
  113. package/build/hooks/state-utils.cjs.map +1 -1
  114. package/build/hooks/states.cjs +2 -2
  115. package/build/hooks/states.cjs.map +2 -2
  116. package/build/hooks/style.cjs +50 -6
  117. package/build/hooks/style.cjs.map +2 -2
  118. package/build/hooks/typography.cjs +62 -10
  119. package/build/hooks/typography.cjs.map +3 -3
  120. package/build/layouts/flex.cjs +99 -6
  121. package/build/layouts/flex.cjs.map +2 -2
  122. package/build/private-apis.cjs +4 -0
  123. package/build/private-apis.cjs.map +2 -2
  124. package/build/store/actions.cjs.map +1 -1
  125. package/build/store/private-selectors.cjs +19 -2
  126. package/build/store/private-selectors.cjs.map +2 -2
  127. package/build/store/reducer.cjs.map +1 -1
  128. package/build/store/selectors.cjs.map +1 -1
  129. package/build/utils/block-bindings.cjs +9 -9
  130. package/build/utils/block-bindings.cjs.map +3 -3
  131. package/build/utils/color-values.cjs +10 -1
  132. package/build/utils/color-values.cjs.map +3 -3
  133. package/build/utils/dom.cjs +2 -5
  134. package/build/utils/dom.cjs.map +3 -3
  135. package/build/utils/fit-text-frontend.cjs +6 -2
  136. package/build/utils/fit-text-frontend.cjs.map +3 -3
  137. package/build/utils/fit-text-utils.cjs +1 -1
  138. package/build/utils/fit-text-utils.cjs.map +3 -3
  139. package/build/utils/format-font-style.cjs +1 -1
  140. package/build/utils/format-font-style.cjs.map +3 -3
  141. package/build/utils/format-font-weight.cjs +1 -1
  142. package/build/utils/format-font-weight.cjs.map +3 -3
  143. package/build/utils/get-editor-region.cjs +4 -2
  144. package/build/utils/get-editor-region.cjs.map +3 -3
  145. package/build/utils/get-font-styles-and-weights.cjs +8 -12
  146. package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
  147. package/build/utils/get-px-from-css-unit.cjs +1 -1
  148. package/build/utils/get-px-from-css-unit.cjs.map +1 -1
  149. package/build/utils/index.cjs +1 -1
  150. package/build/utils/index.cjs.map +1 -1
  151. package/build/utils/math.cjs +1 -1
  152. package/build/utils/math.cjs.map +3 -3
  153. package/build/utils/object.cjs +8 -8
  154. package/build/utils/object.cjs.map +3 -3
  155. package/build/utils/order-inserter-block-items.cjs +1 -1
  156. package/build/utils/order-inserter-block-items.cjs.map +3 -3
  157. package/build/utils/pasting.cjs +4 -2
  158. package/build/utils/pasting.cjs.map +3 -3
  159. package/build/utils/selection.cjs +3 -2
  160. package/build/utils/selection.cjs.map +3 -3
  161. package/build/utils/sorting.cjs +9 -3
  162. package/build/utils/sorting.cjs.map +3 -3
  163. package/build/utils/transform-styles/index.cjs +3 -2
  164. package/build/utils/transform-styles/index.cjs.map +3 -3
  165. package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
  166. package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
  167. package/build/utils/transform-styles/types.cjs +19 -0
  168. package/build/utils/transform-styles/types.cjs.map +7 -0
  169. package/build/utils/types.cjs +19 -0
  170. package/build/utils/types.cjs.map +7 -0
  171. package/build-module/components/block-card/index.mjs +5 -6
  172. package/build-module/components/block-card/index.mjs.map +2 -2
  173. package/build-module/components/block-editing-mode/index.mjs +14 -8
  174. package/build-module/components/block-editing-mode/index.mjs.map +2 -2
  175. package/build-module/components/block-inspector/index.mjs +35 -21
  176. package/build-module/components/block-inspector/index.mjs.map +2 -2
  177. package/build-module/components/block-mover/mover-description.mjs +6 -6
  178. package/build-module/components/block-mover/mover-description.mjs.map +1 -1
  179. package/build-module/components/block-patterns-list/index.mjs.map +2 -2
  180. package/build-module/components/block-patterns-paging/index.mjs +4 -4
  181. package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
  182. package/build-module/components/block-popover/use-popover-scroll.mjs.map +1 -1
  183. package/build-module/components/block-quick-navigation/index.mjs +8 -6
  184. package/build-module/components/block-quick-navigation/index.mjs.map +2 -2
  185. package/build-module/components/block-rename/modal.mjs +0 -1
  186. package/build-module/components/block-rename/modal.mjs.map +2 -2
  187. package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
  188. package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
  189. package/build-module/components/block-toolbar/edit-section-button.mjs.map +1 -1
  190. package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs +10 -4
  191. package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs.map +2 -2
  192. package/build-module/components/child-layout-control/index.mjs +51 -19
  193. package/build-module/components/child-layout-control/index.mjs.map +2 -2
  194. package/build-module/components/colors-gradients/control.mjs +27 -15
  195. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  196. package/build-module/components/colors-gradients/dropdown.mjs +4 -1
  197. package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
  198. package/build-module/components/contrast-checker/index.mjs +18 -4
  199. package/build-module/components/contrast-checker/index.mjs.map +2 -2
  200. package/build-module/components/date-format-picker/index.mjs +0 -1
  201. package/build-module/components/date-format-picker/index.mjs.map +2 -2
  202. package/build-module/components/dimensions-tool/index.mjs +4 -5
  203. package/build-module/components/dimensions-tool/index.mjs.map +2 -2
  204. package/build-module/components/dimensions-tool/scale-tool.mjs +1 -1
  205. package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
  206. package/build-module/components/global-styles/background-panel.mjs +155 -27
  207. package/build-module/components/global-styles/background-panel.mjs.map +2 -2
  208. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
  209. package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
  210. package/build-module/components/global-styles/color-panel.mjs +106 -387
  211. package/build-module/components/global-styles/color-panel.mjs.map +3 -3
  212. package/build-module/components/global-styles/dimensions-panel.mjs +1 -5
  213. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  214. package/build-module/components/global-styles/hooks.mjs +33 -0
  215. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  216. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  217. package/build-module/components/global-styles/typography-panel.mjs +84 -10
  218. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  219. package/build-module/components/grid/grid-item-resizer.mjs.map +1 -1
  220. package/build-module/components/grid/grid-visualizer.mjs.map +1 -1
  221. package/build-module/components/iframe/index.mjs +6 -3
  222. package/build-module/components/iframe/index.mjs.map +2 -2
  223. package/build-module/components/image-editor/use-transform-image.mjs.map +1 -1
  224. package/build-module/components/inserter/get-appender-label.mjs.map +1 -1
  225. package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
  226. package/build-module/components/inserter/search-items.mjs.map +1 -1
  227. package/build-module/components/inspector-controls/fill.mjs +1 -3
  228. package/build-module/components/inspector-controls/fill.mjs.map +2 -2
  229. package/build-module/components/inspector-controls/groups.mjs +2 -0
  230. package/build-module/components/inspector-controls/groups.mjs.map +2 -2
  231. package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
  232. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +76 -32
  233. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  234. package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -1
  235. package/build-module/components/line-height-control/index.mjs.map +1 -1
  236. package/build-module/components/link-control/index.mjs +2 -3
  237. package/build-module/components/link-control/index.mjs.map +2 -2
  238. package/build-module/components/link-control/normalize-url.mjs.map +1 -1
  239. package/build-module/components/list-view/block-select-button.mjs +2 -17
  240. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  241. package/build-module/components/list-view/utils.mjs.map +1 -1
  242. package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
  243. package/build-module/components/provider/index.mjs.map +1 -1
  244. package/build-module/components/provider/use-block-sync.mjs +3 -1
  245. package/build-module/components/provider/use-block-sync.mjs.map +2 -2
  246. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +1 -1
  247. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
  248. package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +1 -1
  249. package/build-module/components/rich-text/prevent-event-discovery.mjs +1 -1
  250. package/build-module/components/rich-text/prevent-event-discovery.mjs.map +1 -1
  251. package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
  252. package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
  253. package/build-module/components/use-block-display-information/index.mjs +10 -3
  254. package/build-module/components/use-block-display-information/index.mjs.map +2 -2
  255. package/build-module/components/writing-flow/use-tab-nav.mjs.map +1 -1
  256. package/build-module/hooks/anchor.mjs +1 -2
  257. package/build-module/hooks/anchor.mjs.map +2 -2
  258. package/build-module/hooks/background.mjs +123 -75
  259. package/build-module/hooks/background.mjs.map +2 -2
  260. package/build-module/hooks/block-fields/index.mjs +13 -2
  261. package/build-module/hooks/block-fields/index.mjs.map +2 -2
  262. package/build-module/hooks/color.mjs +2 -175
  263. package/build-module/hooks/color.mjs.map +2 -2
  264. package/build-module/hooks/contrast-checker.mjs +32 -19
  265. package/build-module/hooks/contrast-checker.mjs.map +2 -2
  266. package/build-module/hooks/custom-class-name.mjs +0 -1
  267. package/build-module/hooks/custom-class-name.mjs.map +2 -2
  268. package/build-module/hooks/dimensions.mjs +12 -2
  269. package/build-module/hooks/dimensions.mjs.map +2 -2
  270. package/build-module/hooks/elements.mjs +115 -0
  271. package/build-module/hooks/elements.mjs.map +7 -0
  272. package/build-module/hooks/grid-visualizer.mjs +21 -11
  273. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  274. package/build-module/hooks/layout-child.mjs +68 -10
  275. package/build-module/hooks/layout-child.mjs.map +2 -2
  276. package/build-module/hooks/layout.mjs +6 -3
  277. package/build-module/hooks/layout.mjs.map +2 -2
  278. package/build-module/hooks/list-view.mjs +10 -7
  279. package/build-module/hooks/list-view.mjs.map +2 -2
  280. package/build-module/hooks/spacing-visualizer.mjs.map +1 -1
  281. package/build-module/hooks/state-utils.mjs.map +1 -1
  282. package/build-module/hooks/states.mjs +2 -2
  283. package/build-module/hooks/states.mjs.map +2 -2
  284. package/build-module/hooks/style.mjs +53 -8
  285. package/build-module/hooks/style.mjs.map +2 -2
  286. package/build-module/hooks/typography.mjs +62 -10
  287. package/build-module/hooks/typography.mjs.map +2 -2
  288. package/build-module/layouts/flex.mjs +105 -7
  289. package/build-module/layouts/flex.mjs.map +2 -2
  290. package/build-module/private-apis.mjs +8 -0
  291. package/build-module/private-apis.mjs.map +2 -2
  292. package/build-module/store/actions.mjs.map +1 -1
  293. package/build-module/store/private-selectors.mjs +18 -1
  294. package/build-module/store/private-selectors.mjs.map +2 -2
  295. package/build-module/store/reducer.mjs.map +1 -1
  296. package/build-module/store/selectors.mjs.map +1 -1
  297. package/build-module/utils/block-bindings.mjs +9 -9
  298. package/build-module/utils/block-bindings.mjs.map +3 -3
  299. package/build-module/utils/color-values.mjs +9 -1
  300. package/build-module/utils/color-values.mjs.map +3 -3
  301. package/build-module/utils/dom.mjs +2 -5
  302. package/build-module/utils/dom.mjs.map +3 -3
  303. package/build-module/utils/fit-text-frontend.mjs +6 -2
  304. package/build-module/utils/fit-text-frontend.mjs.map +3 -3
  305. package/build-module/utils/fit-text-utils.mjs +1 -1
  306. package/build-module/utils/fit-text-utils.mjs.map +3 -3
  307. package/build-module/utils/format-font-style.mjs +1 -1
  308. package/build-module/utils/format-font-style.mjs.map +3 -3
  309. package/build-module/utils/format-font-weight.mjs +1 -1
  310. package/build-module/utils/format-font-weight.mjs.map +3 -3
  311. package/build-module/utils/get-editor-region.mjs +4 -2
  312. package/build-module/utils/get-editor-region.mjs.map +3 -3
  313. package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
  314. package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
  315. package/build-module/utils/get-px-from-css-unit.mjs +1 -1
  316. package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
  317. package/build-module/utils/index.mjs +1 -1
  318. package/build-module/utils/index.mjs.map +1 -1
  319. package/build-module/utils/math.mjs +1 -1
  320. package/build-module/utils/math.mjs.map +3 -3
  321. package/build-module/utils/object.mjs +8 -8
  322. package/build-module/utils/object.mjs.map +3 -3
  323. package/build-module/utils/order-inserter-block-items.mjs +1 -1
  324. package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
  325. package/build-module/utils/pasting.mjs +4 -2
  326. package/build-module/utils/pasting.mjs.map +3 -3
  327. package/build-module/utils/selection.mjs +3 -2
  328. package/build-module/utils/selection.mjs.map +3 -3
  329. package/build-module/utils/sorting.mjs +9 -3
  330. package/build-module/utils/sorting.mjs.map +3 -3
  331. package/build-module/utils/transform-styles/index.mjs +3 -2
  332. package/build-module/utils/transform-styles/index.mjs.map +3 -3
  333. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
  334. package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
  335. package/build-module/utils/transform-styles/types.mjs +1 -0
  336. package/build-module/utils/transform-styles/types.mjs.map +7 -0
  337. package/build-module/utils/types.mjs +1 -0
  338. package/build-module/utils/types.mjs.map +7 -0
  339. package/build-style/content-rtl.css +2 -0
  340. package/build-style/content.css +2 -0
  341. package/build-style/style-rtl.css +34 -41
  342. package/build-style/style.css +34 -41
  343. package/build-types/utils/block-bindings.d.ts +27 -0
  344. package/build-types/utils/block-bindings.d.ts.map +1 -0
  345. package/build-types/utils/color-values.d.ts +40 -0
  346. package/build-types/utils/color-values.d.ts.map +1 -0
  347. package/build-types/utils/dom.d.ts +19 -19
  348. package/build-types/utils/dom.d.ts.map +1 -1
  349. package/build-types/utils/fit-text-frontend.d.ts +7 -0
  350. package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
  351. package/build-types/utils/fit-text-utils.d.ts +15 -0
  352. package/build-types/utils/fit-text-utils.d.ts.map +1 -0
  353. package/build-types/utils/format-font-style.d.ts +12 -0
  354. package/build-types/utils/format-font-style.d.ts.map +1 -0
  355. package/build-types/utils/format-font-weight.d.ts +12 -0
  356. package/build-types/utils/format-font-weight.d.ts.map +1 -0
  357. package/build-types/utils/get-editor-region.d.ts +9 -0
  358. package/build-types/utils/get-editor-region.d.ts.map +1 -0
  359. package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
  360. package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
  361. package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
  362. package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
  363. package/build-types/utils/index.d.ts +3 -0
  364. package/build-types/utils/index.d.ts.map +1 -0
  365. package/build-types/utils/math.d.ts +61 -0
  366. package/build-types/utils/math.d.ts.map +1 -0
  367. package/build-types/utils/object.d.ts +39 -0
  368. package/build-types/utils/object.d.ts.map +1 -0
  369. package/build-types/utils/order-inserter-block-items.d.ts +13 -0
  370. package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
  371. package/build-types/utils/pasting.d.ts +28 -0
  372. package/build-types/utils/pasting.d.ts.map +1 -0
  373. package/build-types/utils/selection.d.ts +21 -0
  374. package/build-types/utils/selection.d.ts.map +1 -0
  375. package/build-types/utils/sorting.d.ts +17 -0
  376. package/build-types/utils/sorting.d.ts.map +1 -0
  377. package/build-types/utils/transform-styles/index.d.ts +15 -0
  378. package/build-types/utils/transform-styles/index.d.ts.map +1 -0
  379. package/build-types/utils/transform-styles/types.d.ts +13 -0
  380. package/build-types/utils/transform-styles/types.d.ts.map +1 -0
  381. package/build-types/utils/types.d.ts +28 -0
  382. package/build-types/utils/types.d.ts.map +1 -0
  383. package/package.json +46 -40
  384. package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
  385. package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
  386. package/src/components/block-card/index.js +7 -13
  387. package/src/components/block-editing-mode/index.js +17 -9
  388. package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
  389. package/src/components/block-inspector/index.js +22 -20
  390. package/src/components/block-patterns-list/index.js +0 -1
  391. package/src/components/block-quick-navigation/index.js +7 -7
  392. package/src/components/block-rename/modal.js +0 -1
  393. package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
  394. package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
  395. package/src/components/block-tools/use-block-toolbar-popover-props.js +10 -4
  396. package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
  397. package/src/components/child-layout-control/index.js +65 -20
  398. package/src/components/child-layout-control/test/index.js +64 -0
  399. package/src/components/colors-gradients/control.js +29 -12
  400. package/src/components/colors-gradients/dropdown.js +4 -1
  401. package/src/components/colors-gradients/style.scss +39 -2
  402. package/src/components/contrast-checker/README.md +9 -0
  403. package/src/components/contrast-checker/index.js +42 -3
  404. package/src/components/date-format-picker/index.js +0 -1
  405. package/src/components/default-block-appender/content.scss +3 -0
  406. package/src/components/dimensions-tool/index.js +4 -9
  407. package/src/components/dimensions-tool/scale-tool.js +1 -2
  408. package/src/components/dimensions-tool/test/index.js +89 -11
  409. package/src/components/global-styles/background-panel.js +201 -34
  410. package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
  411. package/src/components/global-styles/color-panel.js +125 -487
  412. package/src/components/global-styles/dimensions-panel.js +1 -5
  413. package/src/components/global-styles/hooks.js +45 -0
  414. package/src/components/global-styles/shadow-panel-components.js +0 -1
  415. package/src/components/global-styles/test/background-panel.js +56 -0
  416. package/src/components/global-styles/test/color-panel.js +172 -118
  417. package/src/components/global-styles/test/typography-panel.js +167 -0
  418. package/src/components/global-styles/typography-panel.js +100 -11
  419. package/src/components/iframe/index.js +8 -3
  420. package/src/components/inserter/media-tab/media-preview.js +0 -1
  421. package/src/components/inspector-controls/README.md +0 -2
  422. package/src/components/inspector-controls/fill.js +6 -8
  423. package/src/components/inspector-controls/groups.js +2 -0
  424. package/src/components/inspector-controls-tabs/index.js +0 -1
  425. package/src/components/inspector-controls-tabs/styles-tab.js +78 -28
  426. package/src/components/link-control/index.js +0 -1
  427. package/src/components/link-control/test/index.js +2 -3
  428. package/src/components/list-view/block-select-button.js +2 -18
  429. package/src/components/preset-input-control/custom-value-controls.js +0 -1
  430. package/src/components/provider/use-block-sync.js +3 -1
  431. package/src/components/rich-text/content.scss +2 -0
  432. package/src/components/url-popover/image-url-input-ui.js +0 -2
  433. package/src/components/use-block-display-information/index.js +15 -2
  434. package/src/components/use-block-display-information/test/index.js +140 -0
  435. package/src/hooks/anchor.js +0 -1
  436. package/src/hooks/background.js +210 -133
  437. package/src/hooks/background.scss +0 -35
  438. package/src/hooks/block-fields/index.js +27 -2
  439. package/src/hooks/color.js +2 -205
  440. package/src/hooks/color.scss +3 -9
  441. package/src/hooks/contrast-checker.js +60 -17
  442. package/src/hooks/custom-class-name.js +0 -1
  443. package/src/hooks/dimensions.js +14 -3
  444. package/src/hooks/elements.js +140 -0
  445. package/src/hooks/elements.scss +8 -0
  446. package/src/hooks/grid-visualizer.js +59 -45
  447. package/src/hooks/layout-child.js +92 -14
  448. package/src/hooks/layout.js +6 -3
  449. package/src/hooks/list-view.js +10 -11
  450. package/src/hooks/states.js +2 -2
  451. package/src/hooks/style.js +91 -9
  452. package/src/hooks/test/background.js +59 -0
  453. package/src/hooks/test/block-style-state.js +14 -14
  454. package/src/hooks/test/dimensions.js +71 -0
  455. package/src/hooks/test/layout-child.js +165 -0
  456. package/src/hooks/test/layout.js +6 -6
  457. package/src/hooks/test/style.js +133 -11
  458. package/src/hooks/typography.js +70 -6
  459. package/src/layouts/flex.js +118 -15
  460. package/src/private-apis.js +8 -0
  461. package/src/store/private-selectors.js +47 -0
  462. package/src/store/test/private-selectors.js +166 -7
  463. package/src/store/test/reducer.js +61 -10
  464. package/src/style.scss +1 -0
  465. package/src/utils/block-bindings.ts +51 -0
  466. package/src/utils/color-values.ts +63 -0
  467. package/src/utils/{dom.js → dom.ts} +27 -27
  468. package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
  469. package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
  470. package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
  471. package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
  472. package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
  473. package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
  474. package/src/utils/{math.js → math.ts} +37 -30
  475. package/src/utils/object.ts +89 -0
  476. package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
  477. package/src/utils/{pasting.js → pasting.ts} +18 -11
  478. package/src/utils/{selection.js → selection.ts} +11 -4
  479. package/src/utils/sorting.ts +81 -0
  480. package/src/utils/test/color-values.js +44 -1
  481. package/src/utils/transform-styles/{index.js → index.ts} +25 -25
  482. package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
  483. package/src/utils/transform-styles/types.ts +13 -0
  484. package/src/utils/types.ts +29 -0
  485. package/src/utils/block-bindings.js +0 -46
  486. package/src/utils/color-values.js +0 -28
  487. package/src/utils/object.js +0 -67
  488. package/src/utils/sorting.js +0 -54
  489. /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
  490. /package/src/utils/{index.js → index.ts} +0 -0
@@ -2,10 +2,12 @@
2
2
  import clsx from "clsx";
3
3
  import { getBlockSupport } from "@wordpress/blocks";
4
4
  import { useSelect } from "@wordpress/data";
5
- import { useCallback } from "@wordpress/element";
5
+ import { __ } from "@wordpress/i18n";
6
6
  import InspectorControls from "../components/inspector-controls/index.mjs";
7
7
  import { cleanEmptyObject } from "./utils.mjs";
8
+ import { extractPresetSlug } from "../utils/color-values.mjs";
8
9
  import { store as blockEditorStore } from "../store/index.mjs";
10
+ import useBlockColorContrastWarning from "./contrast-checker.mjs";
9
11
  import {
10
12
  default as StylesBackgroundPanel,
11
13
  useHasBackgroundPanel,
@@ -70,40 +72,46 @@ function useBlockProps({ name, style }) {
70
72
  function getBackgroundImageClasses(style) {
71
73
  return hasBackgroundImageValue(style) || hasBackgroundGradientValue(style) ? "has-background" : "";
72
74
  }
73
- function BackgroundInspectorControl({
74
- children,
75
- backgroundGradientSupported = false
76
- }) {
77
- const resetAllFilter = useCallback(
78
- (attributes) => {
79
- const updatedClassName = attributes.className?.includes(
80
- "has-background"
81
- ) ? attributes.className.split(" ").filter((c) => c !== "has-background").join(" ") || void 0 : attributes.className;
82
- return {
83
- ...attributes,
84
- className: updatedClassName,
85
- style: cleanEmptyObject({
86
- ...attributes.style,
87
- background: void 0,
88
- color: backgroundGradientSupported ? {
89
- ...attributes.style?.color,
90
- gradient: void 0
91
- } : attributes.style?.color
92
- })
93
- };
94
- },
95
- [backgroundGradientSupported]
75
+ function backgroundResetAllFilter(attributes) {
76
+ const updatedClassName = attributes.className?.includes("has-background") ? attributes.className.split(" ").filter((c) => c !== "has-background").join(" ") || void 0 : attributes.className;
77
+ return {
78
+ ...attributes,
79
+ className: updatedClassName,
80
+ backgroundColor: void 0,
81
+ gradient: void 0,
82
+ style: cleanEmptyObject({
83
+ ...attributes.style,
84
+ background: void 0,
85
+ color: {
86
+ ...attributes.style?.color,
87
+ background: void 0,
88
+ gradient: void 0
89
+ }
90
+ })
91
+ };
92
+ }
93
+ function BackgroundInspectorControl({ children }) {
94
+ return /* @__PURE__ */ jsx(
95
+ InspectorControls,
96
+ {
97
+ group: "background",
98
+ resetAllFilter: backgroundResetAllFilter,
99
+ children
100
+ }
96
101
  );
97
- return /* @__PURE__ */ jsx(InspectorControls, { group: "background", resetAllFilter, children });
98
102
  }
99
103
  function BackgroundImagePanel({
100
104
  clientId,
101
105
  name,
102
106
  setAttributes,
103
- settings
107
+ settings,
108
+ // Allows rendering outside the `background` inspector group (e.g. section
109
+ // blocks direct-render this panel because their support fills are gated
110
+ // off by editing mode). Defaults to the slot-based wrapper.
111
+ asWrapper
104
112
  }) {
105
113
  const selectedState = useBlockStyleState();
106
- const { style, className, inheritedValue } = useSelect(
114
+ const { style, className, backgroundColor, gradient, inheritedValue } = useSelect(
107
115
  (select) => {
108
116
  const { getBlockAttributes, getSettings } = select(blockEditorStore);
109
117
  const _settings = getSettings();
@@ -111,13 +119,8 @@ function BackgroundImagePanel({
111
119
  return {
112
120
  style: blockAttributes?.style,
113
121
  className: blockAttributes?.className,
114
- /*
115
- * To ensure we pass down the right inherited values:
116
- * @TODO 1. Pass inherited value down to all block style controls,
117
- * See: packages/block-editor/src/hooks/style.js
118
- * @TODO 2. Add support for block style variations,
119
- * See implementation: packages/block-editor/src/hooks/block-style-variation.js
120
- */
122
+ backgroundColor: blockAttributes?.backgroundColor,
123
+ gradient: blockAttributes?.gradient,
121
124
  inheritedValue: _settings[globalStylesDataKey]?.blocks?.[name]
122
125
  };
123
126
  },
@@ -127,54 +130,85 @@ function BackgroundImagePanel({
127
130
  name,
128
131
  "gradient"
129
132
  );
130
- const as = useCallback(
131
- ({ children }) => /* @__PURE__ */ jsx(
132
- BackgroundInspectorControl,
133
- {
134
- backgroundGradientSupported,
135
- children
133
+ const colorSupport = getBlockSupport(name, "color");
134
+ const hasColorBackgroundSupport = colorSupport && colorSupport.background !== false;
135
+ const hasColorGradientSupport = !!colorSupport?.gradients;
136
+ const isStateSelected = !isDefaultBlockStyleState(selectedState);
137
+ const styleValue = {
138
+ ...style,
139
+ color: {
140
+ ...style?.color,
141
+ background: backgroundColor ? "var:preset|color|" + backgroundColor : style?.color?.background,
142
+ gradient: !backgroundGradientSupported && gradient ? "var:preset|gradient|" + gradient : style?.color?.gradient
143
+ },
144
+ ...backgroundGradientSupported && {
145
+ background: {
146
+ ...style?.background,
147
+ gradient: gradient ? "var:preset|gradient|" + gradient : style?.background?.gradient ?? style?.color?.gradient
136
148
  }
137
- ),
138
- [backgroundGradientSupported]
139
- );
140
- if (!useHasBackgroundPanel(settings) || !hasBackgroundSupport(name)) {
149
+ }
150
+ };
151
+ const enableContrastChecking = !isStateSelected && !styleValue?.color?.gradient && !styleValue?.background?.gradient && !!styleValue?.color?.background && (settings?.color?.text || settings?.color?.link) && false !== getBlockSupport(name, ["color", "enableContrastChecker"]);
152
+ const contrastWarning = useBlockColorContrastWarning({
153
+ clientId,
154
+ name,
155
+ enabled: !!enableContrastChecking,
156
+ messageOverride: __(
157
+ "This color combination has poor contrast. Consider increasing contrast between background and foreground."
158
+ )
159
+ });
160
+ if (!useHasBackgroundPanel(settings) || !hasBackgroundSupport(name) && !hasColorBackgroundSupport && !hasColorGradientSupport) {
141
161
  return null;
142
162
  }
143
- const isStateSelected = !isDefaultBlockStyleState(selectedState);
144
- const onChange = isStateSelected ? (newStyle) => {
145
- setAttributes({
146
- style: setStyleForState(style, selectedState, newStyle)
147
- });
148
- } : (newStyle) => {
163
+ const onChange = (newStyle) => {
164
+ if (isStateSelected) {
165
+ setAttributes({
166
+ style: setStyleForState(style, selectedState, newStyle)
167
+ });
168
+ return;
169
+ }
170
+ const newBackgroundColorValue = newStyle?.color?.background;
171
+ const newBackgroundColorSlug = extractPresetSlug(
172
+ newBackgroundColorValue,
173
+ "color"
174
+ );
175
+ const newGradientValue = backgroundGradientSupported ? newStyle?.background?.gradient : newStyle?.color?.gradient;
176
+ const newGradientSlug = extractPresetSlug(
177
+ newGradientValue,
178
+ "gradient"
179
+ );
180
+ const cleanedColorGradient = newGradientSlug ? void 0 : newStyle?.color?.gradient;
181
+ const cleanedStyle = {
182
+ ...newStyle,
183
+ color: {
184
+ ...newStyle?.color,
185
+ background: newBackgroundColorSlug ? void 0 : newBackgroundColorValue,
186
+ gradient: backgroundGradientSupported ? void 0 : cleanedColorGradient
187
+ }
188
+ };
189
+ if (backgroundGradientSupported) {
190
+ cleanedStyle.background = {
191
+ ...cleanedStyle.background,
192
+ gradient: newStyle?.background?.gradient
193
+ };
194
+ }
149
195
  const isMigrating = backgroundGradientSupported && !!style?.color?.gradient;
150
196
  const newAttributes = {
151
- style: cleanEmptyObject(
152
- backgroundGradientSupported ? {
153
- ...newStyle,
154
- color: {
155
- ...newStyle?.color,
156
- gradient: void 0
157
- }
158
- } : newStyle
159
- )
197
+ style: cleanEmptyObject(cleanedStyle),
198
+ backgroundColor: newBackgroundColorSlug,
199
+ // The legacy `gradient` attribute is only used when the block does
200
+ // not support `background.gradient`; otherwise the gradient is
201
+ // stored in `style.background.gradient` above.
202
+ gradient: backgroundGradientSupported ? void 0 : newGradientSlug
160
203
  };
161
- if (isMigrating && !!newStyle?.background?.gradient) {
162
- newAttributes.className = clsx(
163
- className,
164
- "has-background"
165
- );
166
- } else if (!newStyle?.background?.gradient && className?.includes("has-background")) {
204
+ const hasNewGradient = !!newGradientSlug || !!newGradientValue;
205
+ if (isMigrating && hasNewGradient) {
206
+ newAttributes.className = clsx(className, "has-background");
207
+ } else if (!hasNewGradient && className?.includes("has-background")) {
167
208
  newAttributes.className = className.split(" ").filter((c) => c !== "has-background").join(" ") || void 0;
168
209
  }
169
210
  setAttributes(newAttributes);
170
211
  };
171
- const styleValue = backgroundGradientSupported && !style?.background?.gradient && style?.color?.gradient ? {
172
- ...style,
173
- background: {
174
- ...style?.background,
175
- gradient: style?.color?.gradient
176
- }
177
- } : style;
178
212
  const updatedSettings = {
179
213
  ...settings,
180
214
  background: {
@@ -182,21 +216,34 @@ function BackgroundImagePanel({
182
216
  backgroundSize: settings?.background?.backgroundSize && hasBackgroundSupport(name, "backgroundSize")
183
217
  }
184
218
  };
185
- const defaultControls = getBlockSupport(name, [
219
+ const backgroundDefaultControls = getBlockSupport(name, [
186
220
  BACKGROUND_SUPPORT_KEY,
187
221
  "__experimentalDefaultControls"
188
222
  ]);
223
+ const colorDefaultControls = getBlockSupport(name, [
224
+ "color",
225
+ "__experimentalDefaultControls"
226
+ ]);
227
+ const defaultControls = {
228
+ ...backgroundDefaultControls,
229
+ backgroundColor: colorDefaultControls?.background,
230
+ // Mirror the old combined control: show the gradient item by default
231
+ // when background color was shown by default.
232
+ gradient: backgroundDefaultControls?.gradient ?? colorDefaultControls?.background
233
+ };
234
+ const Wrapper = asWrapper || BackgroundInspectorControl;
189
235
  return /* @__PURE__ */ jsx(
190
236
  StylesBackgroundPanel,
191
237
  {
192
238
  inheritedValue,
193
- as,
239
+ as: Wrapper,
194
240
  panelId: clientId,
195
241
  defaultValues: BACKGROUND_BLOCK_DEFAULT_VALUES,
196
242
  settings: updatedSettings,
197
243
  onChange,
198
244
  defaultControls,
199
- value: isStateSelected ? getStyleForState(style, selectedState) : styleValue
245
+ value: isStateSelected ? getStyleForState(style, selectedState) : styleValue,
246
+ contrastWarning
200
247
  }
201
248
  );
202
249
  }
@@ -209,6 +256,7 @@ export {
209
256
  BACKGROUND_BLOCK_DEFAULT_VALUES,
210
257
  BACKGROUND_SUPPORT_KEY,
211
258
  BackgroundImagePanel,
259
+ backgroundResetAllFilter,
212
260
  background_default as default,
213
261
  getBackgroundImageClasses,
214
262
  hasBackgroundSupport,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/background.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n\thasBackgroundGradientValue,\n} from '../components/global-styles/background-panel';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values.\nexport const BACKGROUND_BLOCK_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n\tbackgroundPosition: '50% 50%', // used only when backgroundSize is 'contain'.\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat ||\n\t\t\t!! support?.gradient\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle || ! backgroundStyle?.backgroundImage?.url ) {\n\t\treturn;\n\t}\n\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,\n\t\t};\n\t}\n\n\tif (\n\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t! backgroundStyle?.backgroundPosition\n\t) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundPosition:\n\t\t\t\tBACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,\n\t\t};\n\t}\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ||\n\t\thasBackgroundGradientValue( style )\n\t\t? 'has-background'\n\t\t: '';\n}\n\nfunction BackgroundInspectorControl( {\n\tchildren,\n\tbackgroundGradientSupported = false,\n} ) {\n\tconst resetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst updatedClassName = attributes.className?.includes(\n\t\t\t\t'has-background'\n\t\t\t)\n\t\t\t\t? attributes.className\n\t\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t\t.join( ' ' ) || undefined\n\t\t\t\t: attributes.className;\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\tclassName: updatedClassName,\n\t\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t\t...attributes.style,\n\t\t\t\t\tbackground: undefined,\n\t\t\t\t\tcolor: backgroundGradientSupported\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...attributes.style?.color,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: attributes.style?.color,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ backgroundGradientSupported ]\n\t);\n\treturn (\n\t\t<InspectorControls group=\"background\" resetAllFilter={ resetAllFilter }>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BackgroundImagePanel( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n} ) {\n\tconst selectedState = useBlockStyleState();\n\tconst { style, className, inheritedValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _settings = getSettings();\n\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\treturn {\n\t\t\t\tstyle: blockAttributes?.style,\n\t\t\t\tclassName: blockAttributes?.className,\n\t\t\t\t/*\n\t\t\t\t * To ensure we pass down the right inherited values:\n\t\t\t\t * @TODO 1. Pass inherited value down to all block style controls,\n\t\t\t\t * See: packages/block-editor/src/hooks/style.js\n\t\t\t\t * @TODO 2. Add support for block style variations,\n\t\t\t\t * See implementation: packages/block-editor/src/hooks/block-style-variation.js\n\t\t\t\t */\n\t\t\t\tinheritedValue:\n\t\t\t\t\t_settings[ globalStylesDataKey ]?.blocks?.[ name ],\n\t\t\t};\n\t\t},\n\t\t[ clientId, name ]\n\t);\n\n\tconst backgroundGradientSupported = hasBackgroundSupport(\n\t\tname,\n\t\t'gradient'\n\t);\n\n\t// Must be declared before the early return to follow Rules of Hooks.\n\t// Passes backgroundGradientSupported so that \"Reset All\" also clears\n\t// the legacy color.gradient value when background.gradient is supported.\n\tconst as = useCallback(\n\t\t( { children } ) => (\n\t\t\t<BackgroundInspectorControl\n\t\t\t\tbackgroundGradientSupported={ backgroundGradientSupported }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</BackgroundInspectorControl>\n\t\t),\n\t\t[ backgroundGradientSupported ]\n\t);\n\n\tif (\n\t\t! useHasBackgroundPanel( settings ) ||\n\t\t! hasBackgroundSupport( name )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\n\tconst onChange = isStateSelected\n\t\t? ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t\t} );\n\t\t }\n\t\t: ( newStyle ) => {\n\t\t\t\tconst isMigrating =\n\t\t\t\t\tbackgroundGradientSupported && !! style?.color?.gradient;\n\t\t\t\tconst newAttributes = {\n\t\t\t\t\tstyle: cleanEmptyObject(\n\t\t\t\t\t\tbackgroundGradientSupported\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t...newStyle,\n\t\t\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t\t\t...newStyle?.color,\n\t\t\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: newStyle\n\t\t\t\t\t),\n\t\t\t\t};\n\n\t\t\t\t// When migrating from color.gradient to background.gradient, preserve\n\t\t\t\t// the has-background class so existing styles relying on it (e.g.\n\t\t\t\t// theme padding) are not silently broken. Only add the class when a\n\t\t\t\t// gradient value is being set \u2014 not when it is being cleared/reset.\n\t\t\t\t// Conversely, if the gradient is cleared and has-background was added\n\t\t\t\t// during a previous migration, remove it so it does not linger.\n\t\t\t\tif ( isMigrating && !! newStyle?.background?.gradient ) {\n\t\t\t\t\tnewAttributes.className = clsx(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'has-background'\n\t\t\t\t\t);\n\t\t\t\t} else if (\n\t\t\t\t\t! newStyle?.background?.gradient &&\n\t\t\t\t\tclassName?.includes( 'has-background' )\n\t\t\t\t) {\n\t\t\t\t\tnewAttributes.className =\n\t\t\t\t\t\tclassName\n\t\t\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t\t\t.join( ' ' ) || undefined;\n\t\t\t\t}\n\n\t\t\t\tsetAttributes( newAttributes );\n\t\t };\n\n\t// When background.gradient is supported but not yet explicitly set, fall\n\t// back to color.gradient for display. Any write from this panel migrates\n\t// the value to background.gradient and clears color.gradient atomically.\n\tconst styleValue =\n\t\tbackgroundGradientSupported &&\n\t\t! style?.background?.gradient &&\n\t\tstyle?.color?.gradient\n\t\t\t? {\n\t\t\t\t\t...style,\n\t\t\t\t\tbackground: {\n\t\t\t\t\t\t...style?.background,\n\t\t\t\t\t\tgradient: style?.color?.gradient,\n\t\t\t\t\t},\n\t\t\t }\n\t\t\t: style;\n\n\tconst updatedSettings = {\n\t\t...settings,\n\t\tbackground: {\n\t\t\t...settings.background,\n\t\t\tbackgroundSize:\n\t\t\t\tsettings?.background?.backgroundSize &&\n\t\t\t\thasBackgroundSupport( name, 'backgroundSize' ),\n\t\t},\n\t};\n\n\tconst defaultControls = getBlockSupport( name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesBackgroundPanel\n\t\t\tinheritedValue={ inheritedValue }\n\t\t\tas={ as }\n\t\t\tpanelId={ clientId }\n\t\t\tdefaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }\n\t\t\tsettings={ updatedSettings }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tvalue={\n\t\t\t\tisStateSelected\n\t\t\t\t\t? getStyleForState( style, selectedState )\n\t\t\t\t\t: styleValue\n\t\t\t}\n\t\t/>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAK5B,OAAO,uBAAuB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,SAAS,wBAAwB;AAC1C;AAAA,EACC,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,2BAA2B;AACpC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAkIL;AAhIK,IAAM,yBAAyB;AAG/B,IAAM,kCAAkC;AAAA,EAC9C,gBAAgB;AAAA,EAChB,oBAAoB;AAAA;AACrB;AAUO,SAAS,qBAAsB,WAAW,UAAU,OAAQ;AAClE,QAAM,UAAU,gBAAiB,WAAW,sBAAuB;AAEnE,MAAK,YAAY,MAAO;AACvB,WAAO;AAAA,EACR;AAEA,MAAK,YAAY,OAAQ;AACxB,WACC,CAAC,CAAE,SAAS,mBACZ,CAAC,CAAE,SAAS,kBACZ,CAAC,CAAE,SA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AgB;AAAA,MACrB,OAAO;AAAA,QACN,8BACG;AAAA,UACA,GAAG;AAAA,UACH,OAAO;AAAA,YACN,GAAG,UAAU;AAAA,YACb,UAAU;AAAA,UACX;AAAA,QACA,IACA;AAAA,MACJ;AAAA,IACD;AAQA,QAAK,eAAe,CAAC,CAAE,UAAU,YAAY,UAAW;AACvD,oBAAc,YAAY;AAAA,QACzB;AAAA,QACA;AAAA,MACD;AAAA,IACD,WACC,CAAE,UAAU,YAAY,YACxB,WAAW,SAAU,gBAAiB,GACrC;AACD,oBAAc,YACb,UACE,MAAO,GAAI,EACX,OAAQ,CAAE,MAAO,MAAM,gBAAiB,EACxC,KAAM,GAAI,KAAK;AAAA,IACnB;AAEA,kBAAe,aAAc;AAAA,EAC7B;AAKH,QAAM,aACL,+BACA,CAAE,OAAO,YAAY,YACrB,OAAO,OAAO,WACX;AAAA,IACA,GAAG;AAAA,IACH,YAAY;AAAA,MACX,GAAG,OAAO;AAAA,MACV,UAAU,OAAO,OAAO;AAAA,IACzB;AAAA,EACA,IACA;AAEJ,QAAM,kBAAkB;AAAA,IACvB,GAAG;AAAA,IACH,YAAY;AAAA,MACX,GAAG,SAAS;AAAA,MACZ,gBACC,UAAU,YAAY,kBACtB,qBAAsB,MAAM,gBAAiB;AAAA,IAC/C;AAAA,EACD;AAEA,QAAM,kBAAkB,gBAAiB,MAAM;AAAA,IAC9C;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAU;AAAA,MACV,eAAgB;AAAA,MAChB,UAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,OACC,kBACG,iBAAkB,OAAO,aAAc,IACvC;AAAA;AAAA,EAEL;AAEF;AAEA,IAAO,qBAAQ;AAAA,EACd;AAAA,EACA,eAAe,CAAE,OAAQ;AAAA,EACzB,YAAY;AACb;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { extractPresetSlug } from '../utils/color-values';\nimport { store as blockEditorStore } from '../store';\nimport useBlockColorContrastWarning from './contrast-checker';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n\thasBackgroundGradientValue,\n} from '../components/global-styles/background-panel';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values.\nexport const BACKGROUND_BLOCK_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n\tbackgroundPosition: '50% 50%', // used only when backgroundSize is 'contain'.\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat ||\n\t\t\t!! support?.gradient\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle || ! backgroundStyle?.backgroundImage?.url ) {\n\t\treturn;\n\t}\n\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,\n\t\t};\n\t}\n\n\tif (\n\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t! backgroundStyle?.backgroundPosition\n\t) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundPosition:\n\t\t\t\tBACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,\n\t\t};\n\t}\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ||\n\t\thasBackgroundGradientValue( style )\n\t\t? 'has-background'\n\t\t: '';\n}\n\n// Clears every control the Background panel owns: the background image,\n// background color, and the gradient. The Background panel owns the gradient\n// control for both the newer `background.gradient` support and the legacy\n// `color.gradient` path, so \"Reset all\" clears the legacy value too,\n// regardless of which path stored it.\nexport function backgroundResetAllFilter( attributes ) {\n\tconst updatedClassName = attributes.className?.includes( 'has-background' )\n\t\t? attributes.className\n\t\t\t\t.split( ' ' )\n\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t.join( ' ' ) || undefined\n\t\t: attributes.className;\n\treturn {\n\t\t...attributes,\n\t\tclassName: updatedClassName,\n\t\tbackgroundColor: undefined,\n\t\tgradient: undefined,\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...attributes.style,\n\t\t\tbackground: undefined,\n\t\t\tcolor: {\n\t\t\t\t...attributes.style?.color,\n\t\t\t\tbackground: undefined,\n\t\t\t\tgradient: undefined,\n\t\t\t},\n\t\t} ),\n\t};\n}\n\nfunction BackgroundInspectorControl( { children } ) {\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"background\"\n\t\t\tresetAllFilter={ backgroundResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BackgroundImagePanel( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n\t// Allows rendering outside the `background` inspector group (e.g. section\n\t// blocks direct-render this panel because their support fills are gated\n\t// off by editing mode). Defaults to the slot-based wrapper.\n\tasWrapper,\n} ) {\n\tconst selectedState = useBlockStyleState();\n\tconst { style, className, backgroundColor, gradient, inheritedValue } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\t\tselect( blockEditorStore );\n\t\t\t\tconst _settings = getSettings();\n\t\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\t\treturn {\n\t\t\t\t\tstyle: blockAttributes?.style,\n\t\t\t\t\tclassName: blockAttributes?.className,\n\t\t\t\t\tbackgroundColor: blockAttributes?.backgroundColor,\n\t\t\t\t\tgradient: blockAttributes?.gradient,\n\t\t\t\t\tinheritedValue:\n\t\t\t\t\t\t_settings[ globalStylesDataKey ]?.blocks?.[ name ],\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ clientId, name ]\n\t\t);\n\n\tconst backgroundGradientSupported = hasBackgroundSupport(\n\t\tname,\n\t\t'gradient'\n\t);\n\n\tconst colorSupport = getBlockSupport( name, 'color' );\n\tconst hasColorBackgroundSupport =\n\t\tcolorSupport && colorSupport.background !== false;\n\tconst hasColorGradientSupport = !! colorSupport?.gradients;\n\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\n\t// Fold the backgroundColor / gradient attribute slugs back into the style\n\t// object the panel consumes. When background.gradient is supported but not\n\t// yet explicitly set, fall back to color.gradient for display.\n\tconst styleValue = {\n\t\t...style,\n\t\tcolor: {\n\t\t\t...style?.color,\n\t\t\tbackground: backgroundColor\n\t\t\t\t? 'var:preset|color|' + backgroundColor\n\t\t\t\t: style?.color?.background,\n\t\t\tgradient:\n\t\t\t\t! backgroundGradientSupported && gradient\n\t\t\t\t\t? 'var:preset|gradient|' + gradient\n\t\t\t\t\t: style?.color?.gradient,\n\t\t},\n\t\t...( backgroundGradientSupported && {\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tgradient: gradient\n\t\t\t\t\t? 'var:preset|gradient|' + gradient\n\t\t\t\t\t: style?.background?.gradient ?? style?.color?.gradient,\n\t\t\t},\n\t\t} ),\n\t};\n\n\t// Skipped for gradients, which can't be reliably evaluated for contrast.\n\tconst enableContrastChecking =\n\t\t! isStateSelected &&\n\t\t! styleValue?.color?.gradient &&\n\t\t! styleValue?.background?.gradient &&\n\t\t!! styleValue?.color?.background &&\n\t\t( settings?.color?.text || settings?.color?.link ) &&\n\t\tfalse !== getBlockSupport( name, [ 'color', 'enableContrastChecker' ] );\n\n\tconst contrastWarning = useBlockColorContrastWarning( {\n\t\tclientId,\n\t\tname,\n\t\tenabled: !! enableContrastChecking,\n\t\tmessageOverride: __(\n\t\t\t'This color combination has poor contrast. Consider increasing contrast between background and foreground.'\n\t\t),\n\t} );\n\n\tif (\n\t\t! useHasBackgroundPanel( settings ) ||\n\t\t( ! hasBackgroundSupport( name ) &&\n\t\t\t! hasColorBackgroundSupport &&\n\t\t\t! hasColorGradientSupport )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( newStyle ) => {\n\t\tif ( isStateSelected ) {\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\t// Extract background color slug from style.color.background.\n\t\tconst newBackgroundColorValue = newStyle?.color?.background;\n\t\tconst newBackgroundColorSlug = extractPresetSlug(\n\t\t\tnewBackgroundColorValue,\n\t\t\t'color'\n\t\t);\n\n\t\t// Extract gradient slug — prefer the new background.gradient path\n\t\t// when backgroundGradientSupported, fall back to color.gradient.\n\t\tconst newGradientValue = backgroundGradientSupported\n\t\t\t? newStyle?.background?.gradient\n\t\t\t: newStyle?.color?.gradient;\n\t\tconst newGradientSlug = extractPresetSlug(\n\t\t\tnewGradientValue,\n\t\t\t'gradient'\n\t\t);\n\t\tconst cleanedColorGradient = newGradientSlug\n\t\t\t? undefined\n\t\t\t: newStyle?.color?.gradient;\n\n\t\t// Drop slug-resolved values so they aren't persisted inline alongside\n\t\t// the attribute slugs.\n\t\tconst cleanedStyle = {\n\t\t\t...newStyle,\n\t\t\tcolor: {\n\t\t\t\t...newStyle?.color,\n\t\t\t\tbackground: newBackgroundColorSlug\n\t\t\t\t\t? undefined\n\t\t\t\t\t: newBackgroundColorValue,\n\t\t\t\tgradient: backgroundGradientSupported\n\t\t\t\t\t? undefined\n\t\t\t\t\t: cleanedColorGradient,\n\t\t\t},\n\t\t};\n\t\tif ( backgroundGradientSupported ) {\n\t\t\t// Background gradients are kept whole in `style.background.gradient`\n\t\t\t// rather than extracted to the legacy `gradient` attribute.\n\t\t\tcleanedStyle.background = {\n\t\t\t\t...cleanedStyle.background,\n\t\t\t\tgradient: newStyle?.background?.gradient,\n\t\t\t};\n\t\t}\n\n\t\tconst isMigrating =\n\t\t\tbackgroundGradientSupported && !! style?.color?.gradient;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( cleanedStyle ),\n\t\t\tbackgroundColor: newBackgroundColorSlug,\n\t\t\t// The legacy `gradient` attribute is only used when the block does\n\t\t\t// not support `background.gradient`; otherwise the gradient is\n\t\t\t// stored in `style.background.gradient` above.\n\t\t\tgradient: backgroundGradientSupported ? undefined : newGradientSlug,\n\t\t};\n\n\t\t// When migrating from color.gradient to background.gradient, preserve\n\t\t// the has-background class so existing styles relying on it (e.g.\n\t\t// theme padding) are not silently broken. Only add the class when a\n\t\t// gradient value is being set — not when it is being cleared/reset.\n\t\t// Conversely, if the gradient is cleared and has-background was added\n\t\t// during a previous migration, remove it so it does not linger.\n\t\tconst hasNewGradient = !! newGradientSlug || !! newGradientValue;\n\t\tif ( isMigrating && hasNewGradient ) {\n\t\t\tnewAttributes.className = clsx( className, 'has-background' );\n\t\t} else if (\n\t\t\t! hasNewGradient &&\n\t\t\tclassName?.includes( 'has-background' )\n\t\t) {\n\t\t\tnewAttributes.className =\n\t\t\t\tclassName\n\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t.join( ' ' ) || undefined;\n\t\t}\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\tconst updatedSettings = {\n\t\t...settings,\n\t\tbackground: {\n\t\t\t...settings.background,\n\t\t\tbackgroundSize:\n\t\t\t\tsettings?.background?.backgroundSize &&\n\t\t\t\thasBackgroundSupport( name, 'backgroundSize' ),\n\t\t},\n\t};\n\n\tconst backgroundDefaultControls = getBlockSupport( name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst colorDefaultControls = getBlockSupport( name, [\n\t\t'color',\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultControls = {\n\t\t...backgroundDefaultControls,\n\t\tbackgroundColor: colorDefaultControls?.background,\n\t\t// Mirror the old combined control: show the gradient item by default\n\t\t// when background color was shown by default.\n\t\tgradient:\n\t\t\tbackgroundDefaultControls?.gradient ??\n\t\t\tcolorDefaultControls?.background,\n\t};\n\n\tconst Wrapper = asWrapper || BackgroundInspectorControl;\n\n\treturn (\n\t\t<StylesBackgroundPanel\n\t\t\tinheritedValue={ inheritedValue }\n\t\t\tas={ Wrapper }\n\t\t\tpanelId={ clientId }\n\t\t\tdefaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }\n\t\t\tsettings={ updatedSettings }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tvalue={\n\t\t\t\tisStateSelected\n\t\t\t\t\t? getStyleForState( style, selectedState )\n\t\t\t\t\t: styleValue\n\t\t\t}\n\t\t\tcontrastWarning={ contrastWarning }\n\t\t/>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAKnB,OAAO,uBAAuB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,SAAS,wBAAwB;AAC1C,OAAO,kCAAkC;AACzC;AAAA,EACC,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,2BAA2B;AACpC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAiIL;AA/HK,IAAM,yBAAyB;AAG/B,IAAM,kCAAkC;AAAA,EAC9C,gBAAgB;AAAA,EAChB,oBAAoB;AAAA;AACrB;AAUO,SAAS,qBAAsB,WAAW,UAAU,OAAQ;AAClE,QAAM,UAAU,gBAAiB,WAAW,sBAAuB;AAEnE,MAAK,YAAY,MAAO;AACvB,WAAO;AAAA,EACR;AAEA,MAAK,YAAY,OAAQ;AACxB,WACC,CAAC,CAAE,SAAS,mBACZ,CAAC,CAAE,SAAS,kBACZ,CAAC,CAAE,SAAS,oBACZ,CAAC,CAAE,SAAS;AAAA,EAEd;AAEA,SAAO,CAAC,CAAE,UAAW,OAAQ;AAC9B;AAEO,SAAS,2BAA4B,iBAAkB;AAC7D,MAAK,CAAE,mBAAmB,CAAE,iBAAiB,iBAAiB,KAAM;AACnE;AAAA,EACD;AAEA,MAAI;AAGJ,MAAK,CAAE,iBAAiB,gBAAiB;AACxC,mCAA+B;AAAA,MAC9B,gBAAgB,gCAAgC;AAAA,IACjD;AAAA,EACD;AAEA,MACC,cAAc,iBAAiB,kBAC/B,CAAE,iBAAiB,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ACX,OAAQ,CAAE,MAAO,MAAM,gBAAiB,EACxC,KAAM,GAAI,KAAK;AAAA,IACnB;AAEA,kBAAe,aAAc;AAAA,EAC9B;AAEA,QAAM,kBAAkB;AAAA,IACvB,GAAG;AAAA,IACH,YAAY;AAAA,MACX,GAAG,SAAS;AAAA,MACZ,gBACC,UAAU,YAAY,kBACtB,qBAAsB,MAAM,gBAAiB;AAAA,IAC/C;AAAA,EACD;AAEA,QAAM,4BAA4B,gBAAiB,MAAM;AAAA,IACxD;AAAA,IACA;AAAA,EACD,CAAE;AACF,QAAM,uBAAuB,gBAAiB,MAAM;AAAA,IACnD;AAAA,IACA;AAAA,EACD,CAAE;AACF,QAAM,kBAAkB;AAAA,IACvB,GAAG;AAAA,IACH,iBAAiB,sBAAsB;AAAA;AAAA;AAAA,IAGvC,UACC,2BAA2B,YAC3B,sBAAsB;AAAA,EACxB;AAEA,QAAM,UAAU,aAAa;AAE7B,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,IAAK;AAAA,MACL,SAAU;AAAA,MACV,eAAgB;AAAA,MAChB,UAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,OACC,kBACG,iBAAkB,OAAO,aAAc,IACvC;AAAA,MAEJ;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,qBAAQ;AAAA,EACd;AAAA,EACA,eAAe,CAAE,OAAQ;AAAA,EACzB,YAAY;AACb;",
6
6
  "names": []
7
7
  }
@@ -15,6 +15,7 @@ import { useContext, useState, useMemo } from "@wordpress/element";
15
15
  import { __ } from "@wordpress/i18n";
16
16
  import { store as blockEditorStore } from "../../store/index.mjs";
17
17
  import { unlock } from "../../lock-unlock.mjs";
18
+ import { replacePatternOverridesDefaultBinding } from "../../utils/block-bindings.mjs";
18
19
  import BlockContext from "../../components/block-context/index.mjs";
19
20
  import BlockIcon from "../../components/block-icon/index.mjs";
20
21
  import useBlockDisplayTitle from "../../components/block-title/use-block-display-title.mjs";
@@ -51,15 +52,25 @@ function BlockFields({
51
52
  if (!_attributes?.metadata?.bindings) {
52
53
  return _attributes;
53
54
  }
55
+ const { __experimentalBlockBindingsSupportedAttributes } = select(blockEditorStore).getSettings();
56
+ const bindableAttributes = __experimentalBlockBindingsSupportedAttributes?.[blockType?.name];
57
+ const bindings = bindableAttributes ? replacePatternOverridesDefaultBinding(
58
+ _attributes.metadata.bindings,
59
+ bindableAttributes
60
+ ) : _attributes.metadata.bindings;
54
61
  const { getBlockBindingsSource } = unlock(select(blocksStore));
55
- return Object.entries(_attributes.metadata.bindings).reduce(
62
+ return Object.entries(bindings).reduce(
56
63
  (acc, [attribute, binding]) => {
64
+ if (attribute === "__default") {
65
+ return acc;
66
+ }
57
67
  const source = getBlockBindingsSource(binding.source);
58
68
  if (!source) {
59
69
  return acc;
60
70
  }
61
71
  const values = source.getValues({
62
72
  select,
73
+ clientId,
63
74
  context: blockContext,
64
75
  bindings: { [attribute]: binding }
65
76
  });
@@ -68,7 +79,7 @@ function BlockFields({
68
79
  _attributes
69
80
  );
70
81
  },
71
- [blockContext, clientId]
82
+ [blockContext, clientId, blockType?.name]
72
83
  );
73
84
  const { selectBlock, toggleBlockHighlight } = useDispatch(blockEditorStore);
74
85
  const debouncedToggleBlockHighlight = useDebounce(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/block-fields/index.js"],
4
- "sourcesContent": ["import {\n\tprivateApis as blocksPrivateApis,\n\tgetBlockType,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useDebounce } from '@wordpress/compose';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { DataForm } from '@wordpress/dataviews';\nimport { useContext, useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport BlockContext from '../../components/block-context';\nimport BlockIcon from '../../components/block-icon';\nimport useBlockDisplayTitle from '../../components/block-title/use-block-display-title';\nimport useBlockDisplayInformation from '../../components/use-block-display-information';\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\nimport FieldsDropdownMenu from './fields-dropdown-menu';\nimport { PrivateBlockContext } from '../../components/block-list/private-block-context';\nimport InspectorControls from '../../components/inspector-controls/fill';\n\n// controls\nimport RichText from './rich-text';\nimport Media from './media';\nimport Link from './link';\n\n/**\n * Creates a configured control component that wraps a custom control\n * and passes configuration as props.\n *\n * @param {Component} ControlComponent The React component for the control.\n * @param {Object} config The control configuration passed as a prop.\n *\n * @return {Function} A wrapped control component\n */\nfunction createConfiguredControl( ControlComponent, config = {} ) {\n\treturn function ConfiguredControl( props ) {\n\t\treturn <ControlComponent { ...props } config={ config } />;\n\t};\n}\n\n/**\n * Component that renders a DataForm for a single block's attributes\n * @param {Object} props\n * @param {string} props.clientId The clientId of the block.\n * @param {Object} props.blockType The blockType definition.\n * @param {Function} props.setAttributes Action to set the block's attributes.\n * @param {boolean} props.isMultiBlock Whether forms for multiple blocks are shown at the same time.\n * This changes the behavior of the component:\n * - Only the first field is shown for each block.\n * - A dropdown is rendered allowing display of additional fields.\n * - Hovering the block fields highlights the block in the canvas\n * - Focusing a block field soft-selects the block in the canvas.\n */\nfunction BlockFields( {\n\tclientId,\n\tblockType,\n\tsetAttributes,\n\tisMultiBlock = false,\n} ) {\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\tconst blockTypeFields = blockType?.[ fieldsKey ];\n\n\tconst blockContext = useContext( BlockContext );\n\n\tconst attributes = useSelect(\n\t\t( select ) => {\n\t\t\tconst _attributes =\n\t\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId );\n\t\t\tif ( ! _attributes?.metadata?.bindings ) {\n\t\t\t\treturn _attributes;\n\t\t\t}\n\n\t\t\tconst { getBlockBindingsSource } = unlock( select( blocksStore ) );\n\t\t\treturn Object.entries( _attributes.metadata.bindings ).reduce(\n\t\t\t\t( acc, [ attribute, binding ] ) => {\n\t\t\t\t\tconst source = getBlockBindingsSource( binding.source );\n\t\t\t\t\tif ( ! source ) {\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t}\n\t\t\t\t\tconst values = source.getValues( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext: blockContext,\n\t\t\t\t\t\tbindings: { [ attribute ]: binding },\n\t\t\t\t\t} );\n\t\t\t\t\treturn { ...acc, ...values };\n\t\t\t\t},\n\t\t\t\t_attributes\n\t\t\t);\n\t\t},\n\t\t[ blockContext, clientId ]\n\t);\n\tconst { selectBlock, toggleBlockHighlight } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst debouncedToggleBlockHighlight = useDebounce(\n\t\ttoggleBlockHighlight,\n\t\t50\n\t);\n\n\tconst computedForm = useMemo( () => {\n\t\tif ( ! isMultiBlock ) {\n\t\t\treturn blockType?.[ formKey ];\n\t\t}\n\n\t\t// For a collapsed form only show the first field by default.\n\t\treturn {\n\t\t\t...blockType?.[ formKey ],\n\t\t\tfields: [ blockType?.[ formKey ]?.fields?.[ 0 ] ],\n\t\t};\n\t}, [ blockType, isMultiBlock ] );\n\n\tconst [ form, setForm ] = useState( computedForm );\n\n\t// Build DataForm fields with proper structure\n\tconst dataFormFields = useMemo( () => {\n\t\tif ( ! blockTypeFields?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn blockTypeFields.map( ( fieldDef ) => {\n\t\t\tconst field = {\n\t\t\t\t...fieldDef,\n\t\t\t};\n\n\t\t\t// These should be custom Edit components, not replaced here.\n\t\t\t//\n\t\t\t// - rich-text control: it needs clientId\n\t\t\t// - link control: does not need anything extra\n\t\t\t// - media control: needs the Edit config\n\t\t\tif (\n\t\t\t\t'string' === typeof fieldDef.Edit &&\n\t\t\t\tfieldDef.Edit === 'rich-text'\n\t\t\t) {\n\t\t\t\tfield.Edit = createConfiguredControl( RichText, {\n\t\t\t\t\tclientId,\n\t\t\t\t} );\n\t\t\t} else if (\n\t\t\t\t'string' === typeof fieldDef.Edit &&\n\t\t\t\tfieldDef.Edit === 'link'\n\t\t\t) {\n\t\t\t\tfield.Edit = createConfiguredControl( Link );\n\t\t\t} else if (\n\t\t\t\t'object' === typeof fieldDef.Edit &&\n\t\t\t\tfieldDef.Edit.control === 'media'\n\t\t\t) {\n\t\t\t\tfield.Edit = createConfiguredControl( Media, {\n\t\t\t\t\t...fieldDef.Edit,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn field;\n\t\t} );\n\t}, [ blockTypeFields, clientId ] );\n\n\tif ( ! blockTypeFields?.length ) {\n\t\t// TODO - we might still want to show a placeholder for blocks with no fields.\n\t\t// for example, a way to select the block.\n\t\treturn null;\n\t}\n\n\tconst handleToggleField = ( fieldId ) => {\n\t\tsetForm( ( prev ) => {\n\t\t\tif ( prev.fields?.includes( fieldId ) ) {\n\t\t\t\treturn {\n\t\t\t\t\t...prev,\n\t\t\t\t\tfields: prev.fields.filter( ( id ) => id !== fieldId ),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...prev,\n\t\t\t\tfields: [ ...( prev.fields || [] ), fieldId ],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-fields__container\"\n\t\t\tonMouseEnter={\n\t\t\t\tisMultiBlock\n\t\t\t\t\t? () => debouncedToggleBlockHighlight( clientId, true )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonMouseLeave={ () =>\n\t\t\t\tisMultiBlock\n\t\t\t\t\t? debouncedToggleBlockHighlight( clientId, false )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonFocus={\n\t\t\t\tisMultiBlock\n\t\t\t\t\t? () => {\n\t\t\t\t\t\t\tselectBlock(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tnull /* null to avoid focus on the block in the canvas */\n\t\t\t\t\t\t\t);\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t>\n\t\t\t<div className=\"block-editor-block-fields__header\">\n\t\t\t\t<HStack spacing={ 1 }>\n\t\t\t\t\t{ isMultiBlock && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-fields__header-icon\"\n\t\t\t\t\t\t\t\ticon={ blockInformation?.icon }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<h2 className=\"block-editor-block-fields__header-title\">\n\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t{ blockTitle }\n\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t\t<FieldsDropdownMenu\n\t\t\t\t\t\t\t\tfields={ dataFormFields }\n\t\t\t\t\t\t\t\tvisibleFields={ form.fields }\n\t\t\t\t\t\t\t\tonToggleField={ handleToggleField }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isMultiBlock && (\n\t\t\t\t\t\t<h2 className=\"block-editor-block-fields__header-title\">\n\t\t\t\t\t\t\t{ __( 'Content' ) }\n\t\t\t\t\t\t</h2>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t\t<DataForm\n\t\t\t\tdata={ attributes }\n\t\t\t\tfields={ dataFormFields }\n\t\t\t\tform={ form }\n\t\t\t\tonChange={ setAttributes }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction hasBlockFieldsSupport( blockName ) {\n\treturn !! (\n\t\twindow?.__experimentalContentOnlyInspectorFields &&\n\t\tgetBlockType( blockName )?.[ fieldsKey ]\n\t);\n}\n\nexport function BlockFieldsPanel( props ) {\n\tconst { blockType, isSelectionWithinCurrentSection } =\n\t\tuseContext( PrivateBlockContext );\n\n\treturn (\n\t\t<InspectorControls group=\"content\">\n\t\t\t<BlockFields\n\t\t\t\t{ ...props }\n\t\t\t\tblockType={ blockType }\n\t\t\t\tisMultiBlock={ isSelectionWithinCurrentSection }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Export block support definition.\n */\nexport default {\n\tedit: BlockFieldsPanel,\n\thasSupport: hasBlockFieldsSupport,\n\tattributeKeys: [],\n\tsupportsPatternEditing: true,\n};\n"],
5
- "mappings": ";AAAA;AAAA,EACC,eAAe;AAAA,EACf;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,mBAAmB;AAC5B;AAAA,EACC,wBAAwB;AAAA,EACxB,0BAA0B;AAAA,OACpB;AACP,SAAS,aAAa,iBAAiB;AACvC,SAAS,gBAAgB;AACzB,SAAS,YAAY,UAAU,eAAe;AAC9C,SAAS,UAAU;AACnB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AACvB,OAAO,kBAAkB;AACzB,OAAO,eAAe;AACtB,OAAO,0BAA0B;AACjC,OAAO,gCAAgC;AAEvC,OAAO,wBAAwB;AAC/B,SAAS,2BAA2B;AACpC,OAAO,uBAAuB;AAG9B,OAAO,cAAc;AACrB,OAAO,WAAW;AAClB,OAAO,UAAU;AAaR,SA4KH,UA5KG,KA4KH,YA5KG;AArBT,IAAM,EAAE,WAAW,QAAQ,IAAI,OAAQ,iBAAkB;AAmBzD,SAAS,wBAAyB,kBAAkB,SAAS,CAAC,GAAI;AACjE,SAAO,SAAS,kBAAmB,OAAQ;AAC1C,WAAO,oBAAC,oBAAmB,GAAG,OAAQ,QAAkB;AAAA,EACzD;AACD;AAeA,SAAS,YAAa;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAChB,GAAI;AACH,QAAM,aAAa,qBAAsB;AAAA,IACxC;AAAA,IACA,SAAS;AAAA,EACV,CAAE;AACF,QAAM,mBAAmB,2BAA4B,QAAS;AAE9D,QAAM,kBAAkB,YA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AC;AAAA;AAAA,gBACA,WAAU;AAAA,gBACV,MAAO,kBAAkB;AAAA;AAAA,YAC1B;AAAA,YACA,oBAAC,QAAG,WAAU,2CACb,8BAAC,YAAS,eAAgB,GACvB,sBACH,GACD;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACA,QAAS;AAAA,gBACT,eAAgB,KAAK;AAAA,gBACrB,eAAgB;AAAA;AAAA,YACjB;AAAA,aACD;AAAA,UAEC,CAAE,gBACH,oBAAC,QAAG,WAAU,2CACX,aAAI,SAAU,GACjB;AAAA,WAEF,GACD;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,MAAO;AAAA,YACP,QAAS;AAAA,YACT;AAAA,YACA,UAAW;AAAA;AAAA,QACZ;AAAA;AAAA;AAAA,EACD;AAEF;AAEA,SAAS,sBAAuB,WAAY;AAC3C,SAAO,CAAC,EACP,QAAQ,4CACR,aAAc,SAAU,IAAK,SAAU;AAEzC;AAEO,SAAS,iBAAkB,OAAQ;AACzC,QAAM,EAAE,WAAW,gCAAgC,IAClD,WAAY,mBAAoB;AAEjC,SACC,oBAAC,qBAAkB,OAAM,WACxB;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACL;AAAA,MACA,cAAe;AAAA;AAAA,EAChB,GACD;AAEF;AAKA,IAAO,uBAAQ;AAAA,EACd,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,eAAe,CAAC;AAAA,EAChB,wBAAwB;AACzB;",
4
+ "sourcesContent": ["import {\n\tprivateApis as blocksPrivateApis,\n\tgetBlockType,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useDebounce } from '@wordpress/compose';\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { DataForm } from '@wordpress/dataviews';\nimport { useContext, useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { replacePatternOverridesDefaultBinding } from '../../utils/block-bindings';\nimport BlockContext from '../../components/block-context';\nimport BlockIcon from '../../components/block-icon';\nimport useBlockDisplayTitle from '../../components/block-title/use-block-display-title';\nimport useBlockDisplayInformation from '../../components/use-block-display-information';\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\nimport FieldsDropdownMenu from './fields-dropdown-menu';\nimport { PrivateBlockContext } from '../../components/block-list/private-block-context';\nimport InspectorControls from '../../components/inspector-controls/fill';\n\n// controls\nimport RichText from './rich-text';\nimport Media from './media';\nimport Link from './link';\n\n/**\n * Creates a configured control component that wraps a custom control\n * and passes configuration as props.\n *\n * @param {Component} ControlComponent The React component for the control.\n * @param {Object} config The control configuration passed as a prop.\n *\n * @return {Function} A wrapped control component\n */\nfunction createConfiguredControl( ControlComponent, config = {} ) {\n\treturn function ConfiguredControl( props ) {\n\t\treturn <ControlComponent { ...props } config={ config } />;\n\t};\n}\n\n/**\n * Component that renders a DataForm for a single block's attributes\n * @param {Object} props\n * @param {string} props.clientId The clientId of the block.\n * @param {Object} props.blockType The blockType definition.\n * @param {Function} props.setAttributes Action to set the block's attributes.\n * @param {boolean} props.isMultiBlock Whether forms for multiple blocks are shown at the same time.\n * This changes the behavior of the component:\n * - Only the first field is shown for each block.\n * - A dropdown is rendered allowing display of additional fields.\n * - Hovering the block fields highlights the block in the canvas\n * - Focusing a block field soft-selects the block in the canvas.\n */\nfunction BlockFields( {\n\tclientId,\n\tblockType,\n\tsetAttributes,\n\tisMultiBlock = false,\n} ) {\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\n\tconst blockTypeFields = blockType?.[ fieldsKey ];\n\n\tconst blockContext = useContext( BlockContext );\n\n\tconst attributes = useSelect(\n\t\t( select ) => {\n\t\t\tconst _attributes =\n\t\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId );\n\t\t\tif ( ! _attributes?.metadata?.bindings ) {\n\t\t\t\treturn _attributes;\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * The pattern overrides `__default` binding is a placeholder, not\n\t\t\t * a real attribute: expand it to the block's bindable attributes\n\t\t\t * before resolving values, as other bindings consumers do.\n\t\t\t */\n\t\t\tconst { __experimentalBlockBindingsSupportedAttributes } =\n\t\t\t\tselect( blockEditorStore ).getSettings();\n\t\t\tconst bindableAttributes =\n\t\t\t\t__experimentalBlockBindingsSupportedAttributes?.[\n\t\t\t\t\tblockType?.name\n\t\t\t\t];\n\t\t\tconst bindings = bindableAttributes\n\t\t\t\t? replacePatternOverridesDefaultBinding(\n\t\t\t\t\t\t_attributes.metadata.bindings,\n\t\t\t\t\t\tbindableAttributes\n\t\t\t\t )\n\t\t\t\t: _attributes.metadata.bindings;\n\n\t\t\tconst { getBlockBindingsSource } = unlock( select( blocksStore ) );\n\t\t\treturn Object.entries( bindings ).reduce(\n\t\t\t\t( acc, [ attribute, binding ] ) => {\n\t\t\t\t\t// Skip a `__default` binding that could not be expanded:\n\t\t\t\t\t// it is not a real block attribute.\n\t\t\t\t\tif ( attribute === '__default' ) {\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t}\n\t\t\t\t\tconst source = getBlockBindingsSource( binding.source );\n\t\t\t\t\tif ( ! source ) {\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t}\n\t\t\t\t\tconst values = source.getValues( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tcontext: blockContext,\n\t\t\t\t\t\tbindings: { [ attribute ]: binding },\n\t\t\t\t\t} );\n\t\t\t\t\treturn { ...acc, ...values };\n\t\t\t\t},\n\t\t\t\t_attributes\n\t\t\t);\n\t\t},\n\t\t[ blockContext, clientId, blockType?.name ]\n\t);\n\tconst { selectBlock, toggleBlockHighlight } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst debouncedToggleBlockHighlight = useDebounce(\n\t\ttoggleBlockHighlight,\n\t\t50\n\t);\n\n\tconst computedForm = useMemo( () => {\n\t\tif ( ! isMultiBlock ) {\n\t\t\treturn blockType?.[ formKey ];\n\t\t}\n\n\t\t// For a collapsed form only show the first field by default.\n\t\treturn {\n\t\t\t...blockType?.[ formKey ],\n\t\t\tfields: [ blockType?.[ formKey ]?.fields?.[ 0 ] ],\n\t\t};\n\t}, [ blockType, isMultiBlock ] );\n\n\tconst [ form, setForm ] = useState( computedForm );\n\n\t// Build DataForm fields with proper structure\n\tconst dataFormFields = useMemo( () => {\n\t\tif ( ! blockTypeFields?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn blockTypeFields.map( ( fieldDef ) => {\n\t\t\tconst field = {\n\t\t\t\t...fieldDef,\n\t\t\t};\n\n\t\t\t// These should be custom Edit components, not replaced here.\n\t\t\t//\n\t\t\t// - rich-text control: it needs clientId\n\t\t\t// - link control: does not need anything extra\n\t\t\t// - media control: needs the Edit config\n\t\t\tif (\n\t\t\t\t'string' === typeof fieldDef.Edit &&\n\t\t\t\tfieldDef.Edit === 'rich-text'\n\t\t\t) {\n\t\t\t\tfield.Edit = createConfiguredControl( RichText, {\n\t\t\t\t\tclientId,\n\t\t\t\t} );\n\t\t\t} else if (\n\t\t\t\t'string' === typeof fieldDef.Edit &&\n\t\t\t\tfieldDef.Edit === 'link'\n\t\t\t) {\n\t\t\t\tfield.Edit = createConfiguredControl( Link );\n\t\t\t} else if (\n\t\t\t\t'object' === typeof fieldDef.Edit &&\n\t\t\t\tfieldDef.Edit.control === 'media'\n\t\t\t) {\n\t\t\t\tfield.Edit = createConfiguredControl( Media, {\n\t\t\t\t\t...fieldDef.Edit,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn field;\n\t\t} );\n\t}, [ blockTypeFields, clientId ] );\n\n\tif ( ! blockTypeFields?.length ) {\n\t\t// TODO - we might still want to show a placeholder for blocks with no fields.\n\t\t// for example, a way to select the block.\n\t\treturn null;\n\t}\n\n\tconst handleToggleField = ( fieldId ) => {\n\t\tsetForm( ( prev ) => {\n\t\t\tif ( prev.fields?.includes( fieldId ) ) {\n\t\t\t\treturn {\n\t\t\t\t\t...prev,\n\t\t\t\t\tfields: prev.fields.filter( ( id ) => id !== fieldId ),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...prev,\n\t\t\t\tfields: [ ...( prev.fields || [] ), fieldId ],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-fields__container\"\n\t\t\tonMouseEnter={\n\t\t\t\tisMultiBlock\n\t\t\t\t\t? () => debouncedToggleBlockHighlight( clientId, true )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonMouseLeave={ () =>\n\t\t\t\tisMultiBlock\n\t\t\t\t\t? debouncedToggleBlockHighlight( clientId, false )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\tonFocus={\n\t\t\t\tisMultiBlock\n\t\t\t\t\t? () => {\n\t\t\t\t\t\t\tselectBlock(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tnull /* null to avoid focus on the block in the canvas */\n\t\t\t\t\t\t\t);\n\t\t\t\t\t }\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t>\n\t\t\t<div className=\"block-editor-block-fields__header\">\n\t\t\t\t<HStack spacing={ 1 }>\n\t\t\t\t\t{ isMultiBlock && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-fields__header-icon\"\n\t\t\t\t\t\t\t\ticon={ blockInformation?.icon }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<h2 className=\"block-editor-block-fields__header-title\">\n\t\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t\t{ blockTitle }\n\t\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t\t<FieldsDropdownMenu\n\t\t\t\t\t\t\t\tfields={ dataFormFields }\n\t\t\t\t\t\t\t\tvisibleFields={ form.fields }\n\t\t\t\t\t\t\t\tonToggleField={ handleToggleField }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isMultiBlock && (\n\t\t\t\t\t\t<h2 className=\"block-editor-block-fields__header-title\">\n\t\t\t\t\t\t\t{ __( 'Content' ) }\n\t\t\t\t\t\t</h2>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t\t<DataForm\n\t\t\t\tdata={ attributes }\n\t\t\t\tfields={ dataFormFields }\n\t\t\t\tform={ form }\n\t\t\t\tonChange={ setAttributes }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction hasBlockFieldsSupport( blockName ) {\n\treturn !! (\n\t\twindow?.__experimentalContentOnlyInspectorFields &&\n\t\tgetBlockType( blockName )?.[ fieldsKey ]\n\t);\n}\n\nexport function BlockFieldsPanel( props ) {\n\tconst { blockType, isSelectionWithinCurrentSection } =\n\t\tuseContext( PrivateBlockContext );\n\n\treturn (\n\t\t<InspectorControls group=\"content\">\n\t\t\t<BlockFields\n\t\t\t\t{ ...props }\n\t\t\t\tblockType={ blockType }\n\t\t\t\tisMultiBlock={ isSelectionWithinCurrentSection }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Export block support definition.\n */\nexport default {\n\tedit: BlockFieldsPanel,\n\thasSupport: hasBlockFieldsSupport,\n\tattributeKeys: [],\n\tsupportsPatternEditing: true,\n};\n"],
5
+ "mappings": ";AAAA;AAAA,EACC,eAAe;AAAA,EACf;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,mBAAmB;AAC5B;AAAA,EACC,wBAAwB;AAAA,EACxB,0BAA0B;AAAA,OACpB;AACP,SAAS,aAAa,iBAAiB;AACvC,SAAS,gBAAgB;AACzB,SAAS,YAAY,UAAU,eAAe;AAC9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