@wordpress/block-editor 15.19.1-next.v.202605131006.0 → 15.20.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 (352) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/build/components/block-card/index.cjs +51 -41
  3. package/build/components/block-card/index.cjs.map +3 -3
  4. package/build/components/block-heading-level-dropdown/heading-level-icon.cjs.map +3 -3
  5. package/build/components/block-icon/index.cjs +7 -1
  6. package/build/components/block-icon/index.cjs.map +3 -3
  7. package/build/components/block-inspector/index.cjs +156 -11
  8. package/build/components/block-inspector/index.cjs.map +3 -3
  9. package/build/components/block-inspector/inspector-pre-tabs-slot-fill.cjs +38 -0
  10. package/build/components/block-inspector/inspector-pre-tabs-slot-fill.cjs.map +7 -0
  11. package/build/components/block-list/use-block-props/index.cjs +1 -1
  12. package/build/components/block-list/use-block-props/index.cjs.map +2 -2
  13. package/build/components/block-list/use-block-props/use-focus-handler.cjs +3 -4
  14. package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +3 -3
  15. package/build/components/block-list/use-block-props/use-is-hovered.cjs +24 -14
  16. package/build/components/block-list/use-block-props/use-is-hovered.cjs.map +3 -3
  17. package/build/components/block-lock/modal.cjs.map +3 -3
  18. package/build/components/block-patterns-list/index.cjs +13 -2
  19. package/build/components/block-patterns-list/index.cjs.map +2 -2
  20. package/build/components/block-popover/index.cjs +13 -3
  21. package/build/components/block-popover/index.cjs.map +2 -2
  22. package/build/components/block-toolbar/switch-section-style.cjs.map +3 -3
  23. package/build/components/block-visibility/modal.cjs.map +3 -3
  24. package/build/components/block-visibility/viewport-visibility-info.cjs.map +3 -3
  25. package/build/components/colors-gradients/control.cjs +7 -4
  26. package/build/components/colors-gradients/control.cjs.map +2 -2
  27. package/build/components/global-styles/advanced-panel.cjs +24 -22
  28. package/build/components/global-styles/advanced-panel.cjs.map +3 -3
  29. package/build/components/global-styles/color-panel.cjs +95 -58
  30. package/build/components/global-styles/color-panel.cjs.map +2 -2
  31. package/build/components/global-styles/dimensions-panel.cjs +11 -5
  32. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  33. package/build/components/global-styles/index.cjs +3 -0
  34. package/build/components/global-styles/index.cjs.map +2 -2
  35. package/build/components/global-styles/shadow-panel-components.cjs +38 -26
  36. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  37. package/build/components/global-styles/state-control-badges.cjs +69 -0
  38. package/build/components/global-styles/state-control-badges.cjs.map +7 -0
  39. package/build/components/global-styles/state-control.cjs +54 -63
  40. package/build/components/global-styles/state-control.cjs.map +3 -3
  41. package/build/components/iframe/index.cjs +0 -3
  42. package/build/components/iframe/index.cjs.map +2 -2
  43. package/build/components/iframe/use-scale-canvas.cjs +4 -1
  44. package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
  45. package/build/components/inserter/hooks/use-patterns-state.cjs +4 -6
  46. package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
  47. package/build/components/inserter/index.cjs +1 -0
  48. package/build/components/inserter/index.cjs.map +2 -2
  49. package/build/components/inserter/media-tab/media-preview.cjs +27 -18
  50. package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
  51. package/build/components/inserter/media-tab/utils.cjs +1 -1
  52. package/build/components/inserter/media-tab/utils.cjs.map +2 -2
  53. package/build/components/inserter/panel.cjs.map +3 -3
  54. package/build/components/inspector-controls/block-support-tools-panel.cjs +10 -2
  55. package/build/components/inspector-controls/block-support-tools-panel.cjs.map +2 -2
  56. package/build/components/inspector-controls/fill.cjs +14 -4
  57. package/build/components/inspector-controls/fill.cjs.map +2 -2
  58. package/build/components/inspector-controls/groups.cjs +2 -0
  59. package/build/components/inspector-controls/groups.cjs.map +2 -2
  60. package/build/components/inspector-controls-tabs/index.cjs +13 -8
  61. package/build/components/inspector-controls-tabs/index.cjs.map +3 -3
  62. package/build/components/inspector-controls-tabs/settings-tab.cjs +1 -4
  63. package/build/components/inspector-controls-tabs/settings-tab.cjs.map +3 -3
  64. package/build/components/inspector-controls-tabs/styles-tab.cjs +9 -0
  65. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +3 -3
  66. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +11 -5
  67. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
  68. package/build/components/list-view/block-select-button.cjs +20 -8
  69. package/build/components/list-view/block-select-button.cjs.map +2 -2
  70. package/build/components/list-view/block.cjs +2 -1
  71. package/build/components/list-view/block.cjs.map +2 -2
  72. package/build/components/preset-input-control/custom-value-controls.cjs +10 -1
  73. package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
  74. package/build/components/preset-input-control/index.cjs.map +3 -3
  75. package/build/components/provider/use-media-upload-settings.cjs +1 -0
  76. package/build/components/provider/use-media-upload-settings.cjs.map +2 -2
  77. package/build/components/rich-text/event-listeners/enter.cjs +9 -2
  78. package/build/components/rich-text/event-listeners/enter.cjs.map +3 -3
  79. package/build/components/rich-text/event-listeners/paste-handler.cjs +4 -4
  80. package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
  81. package/build/hooks/background.cjs +13 -3
  82. package/build/hooks/background.cjs.map +2 -2
  83. package/build/hooks/block-fields/link/index.cjs.map +3 -3
  84. package/build/hooks/block-fields/media/index.cjs.map +3 -3
  85. package/build/hooks/block-style-state.cjs +112 -0
  86. package/build/hooks/block-style-state.cjs.map +7 -0
  87. package/build/hooks/border.cjs +13 -3
  88. package/build/hooks/border.cjs.map +2 -2
  89. package/build/hooks/color.cjs +28 -9
  90. package/build/hooks/color.cjs.map +2 -2
  91. package/build/hooks/dimensions.cjs +15 -6
  92. package/build/hooks/dimensions.cjs.map +2 -2
  93. package/build/hooks/layout-child.cjs +147 -61
  94. package/build/hooks/layout-child.cjs.map +2 -2
  95. package/build/hooks/layout.cjs +263 -56
  96. package/build/hooks/layout.cjs.map +3 -3
  97. package/build/hooks/state-utils.cjs +94 -0
  98. package/build/hooks/state-utils.cjs.map +7 -0
  99. package/build/hooks/states.cjs +124 -0
  100. package/build/hooks/states.cjs.map +7 -0
  101. package/build/hooks/style.cjs +304 -17
  102. package/build/hooks/style.cjs.map +3 -3
  103. package/build/hooks/typography.cjs +14 -5
  104. package/build/hooks/typography.cjs.map +2 -2
  105. package/build/layouts/constrained.cjs +128 -55
  106. package/build/layouts/constrained.cjs.map +3 -3
  107. package/build/layouts/flex.cjs +119 -31
  108. package/build/layouts/flex.cjs.map +3 -3
  109. package/build/layouts/grid.cjs +103 -40
  110. package/build/layouts/grid.cjs.map +3 -3
  111. package/build/private-apis.cjs +2 -0
  112. package/build/private-apis.cjs.map +2 -2
  113. package/build/store/private-actions.cjs +18 -0
  114. package/build/store/private-actions.cjs.map +2 -2
  115. package/build/store/private-keys.cjs +10 -2
  116. package/build/store/private-keys.cjs.map +2 -2
  117. package/build/store/private-selectors.cjs +26 -2
  118. package/build/store/private-selectors.cjs.map +2 -2
  119. package/build/store/reducer.cjs +70 -1
  120. package/build/store/reducer.cjs.map +2 -2
  121. package/build/store/utils.cjs +1 -1
  122. package/build/store/utils.cjs.map +2 -2
  123. package/build/utils/color-values.cjs +44 -0
  124. package/build/utils/color-values.cjs.map +7 -0
  125. package/build-module/components/block-card/index.mjs +52 -45
  126. package/build-module/components/block-card/index.mjs.map +2 -2
  127. package/build-module/components/block-heading-level-dropdown/heading-level-icon.mjs +2 -2
  128. package/build-module/components/block-heading-level-dropdown/heading-level-icon.mjs.map +2 -2
  129. package/build-module/components/block-icon/index.mjs +8 -2
  130. package/build-module/components/block-icon/index.mjs.map +2 -2
  131. package/build-module/components/block-inspector/index.mjs +166 -13
  132. package/build-module/components/block-inspector/index.mjs.map +2 -2
  133. package/build-module/components/block-inspector/inspector-pre-tabs-slot-fill.mjs +12 -0
  134. package/build-module/components/block-inspector/inspector-pre-tabs-slot-fill.mjs.map +7 -0
  135. package/build-module/components/block-list/use-block-props/index.mjs +1 -1
  136. package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
  137. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +7 -5
  138. package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
  139. package/build-module/components/block-list/use-block-props/use-is-hovered.mjs +28 -15
  140. package/build-module/components/block-list/use-block-props/use-is-hovered.mjs.map +2 -2
  141. package/build-module/components/block-lock/modal.mjs +4 -4
  142. package/build-module/components/block-lock/modal.mjs.map +2 -2
  143. package/build-module/components/block-patterns-list/index.mjs +14 -4
  144. package/build-module/components/block-patterns-list/index.mjs.map +2 -2
  145. package/build-module/components/block-popover/index.mjs +13 -3
  146. package/build-module/components/block-popover/index.mjs.map +2 -2
  147. package/build-module/components/block-toolbar/switch-section-style.mjs +2 -2
  148. package/build-module/components/block-toolbar/switch-section-style.mjs.map +2 -2
  149. package/build-module/components/block-visibility/modal.mjs +2 -2
  150. package/build-module/components/block-visibility/modal.mjs.map +2 -2
  151. package/build-module/components/block-visibility/viewport-visibility-info.mjs +2 -2
  152. package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
  153. package/build-module/components/colors-gradients/control.mjs +7 -4
  154. package/build-module/components/colors-gradients/control.mjs.map +2 -2
  155. package/build-module/components/global-styles/advanced-panel.mjs +25 -27
  156. package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
  157. package/build-module/components/global-styles/color-panel.mjs +96 -59
  158. package/build-module/components/global-styles/color-panel.mjs.map +2 -2
  159. package/build-module/components/global-styles/dimensions-panel.mjs +14 -5
  160. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  161. package/build-module/components/global-styles/index.mjs +2 -0
  162. package/build-module/components/global-styles/index.mjs.map +2 -2
  163. package/build-module/components/global-styles/shadow-panel-components.mjs +39 -28
  164. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  165. package/build-module/components/global-styles/state-control-badges.mjs +48 -0
  166. package/build-module/components/global-styles/state-control-badges.mjs.map +7 -0
  167. package/build-module/components/global-styles/state-control.mjs +57 -71
  168. package/build-module/components/global-styles/state-control.mjs.map +2 -2
  169. package/build-module/components/iframe/index.mjs +0 -3
  170. package/build-module/components/iframe/index.mjs.map +2 -2
  171. package/build-module/components/iframe/use-scale-canvas.mjs +4 -1
  172. package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
  173. package/build-module/components/inserter/hooks/use-patterns-state.mjs +8 -7
  174. package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
  175. package/build-module/components/inserter/index.mjs +1 -0
  176. package/build-module/components/inserter/index.mjs.map +2 -2
  177. package/build-module/components/inserter/media-tab/media-preview.mjs +27 -19
  178. package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
  179. package/build-module/components/inserter/media-tab/utils.mjs +1 -1
  180. package/build-module/components/inserter/media-tab/utils.mjs.map +2 -2
  181. package/build-module/components/inserter/panel.mjs +2 -2
  182. package/build-module/components/inserter/panel.mjs.map +2 -2
  183. package/build-module/components/inspector-controls/block-support-tools-panel.mjs +10 -2
  184. package/build-module/components/inspector-controls/block-support-tools-panel.mjs.map +2 -2
  185. package/build-module/components/inspector-controls/fill.mjs +18 -5
  186. package/build-module/components/inspector-controls/fill.mjs.map +2 -2
  187. package/build-module/components/inspector-controls/groups.mjs +2 -0
  188. package/build-module/components/inspector-controls/groups.mjs.map +2 -2
  189. package/build-module/components/inspector-controls-tabs/index.mjs +14 -10
  190. package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
  191. package/build-module/components/inspector-controls-tabs/settings-tab.mjs +1 -4
  192. package/build-module/components/inspector-controls-tabs/settings-tab.mjs.map +2 -2
  193. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +9 -0
  194. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  195. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +11 -5
  196. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
  197. package/build-module/components/list-view/block-select-button.mjs +20 -9
  198. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  199. package/build-module/components/list-view/block.mjs +2 -1
  200. package/build-module/components/list-view/block.mjs.map +2 -2
  201. package/build-module/components/preset-input-control/custom-value-controls.mjs +10 -2
  202. package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
  203. package/build-module/components/preset-input-control/index.mjs +2 -2
  204. package/build-module/components/preset-input-control/index.mjs.map +2 -2
  205. package/build-module/components/provider/use-media-upload-settings.mjs +1 -0
  206. package/build-module/components/provider/use-media-upload-settings.mjs.map +2 -2
  207. package/build-module/components/rich-text/event-listeners/enter.mjs +9 -2
  208. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  209. package/build-module/components/rich-text/event-listeners/paste-handler.mjs +4 -4
  210. package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
  211. package/build-module/hooks/background.mjs +18 -3
  212. package/build-module/hooks/background.mjs.map +2 -2
  213. package/build-module/hooks/block-fields/link/index.mjs +3 -3
  214. package/build-module/hooks/block-fields/link/index.mjs.map +2 -2
  215. package/build-module/hooks/block-fields/media/index.mjs +3 -3
  216. package/build-module/hooks/block-fields/media/index.mjs.map +2 -2
  217. package/build-module/hooks/block-style-state.mjs +79 -0
  218. package/build-module/hooks/block-style-state.mjs.map +7 -0
  219. package/build-module/hooks/border.mjs +18 -3
  220. package/build-module/hooks/border.mjs.map +2 -2
  221. package/build-module/hooks/color.mjs +33 -9
  222. package/build-module/hooks/color.mjs.map +2 -2
  223. package/build-module/hooks/dimensions.mjs +20 -6
  224. package/build-module/hooks/dimensions.mjs.map +2 -2
  225. package/build-module/hooks/layout-child.mjs +141 -61
  226. package/build-module/hooks/layout-child.mjs.map +2 -2
  227. package/build-module/hooks/layout.mjs +270 -58
  228. package/build-module/hooks/layout.mjs.map +2 -2
  229. package/build-module/hooks/state-utils.mjs +64 -0
  230. package/build-module/hooks/state-utils.mjs.map +7 -0
  231. package/build-module/hooks/states.mjs +85 -0
  232. package/build-module/hooks/states.mjs.map +7 -0
  233. package/build-module/hooks/style.mjs +309 -18
  234. package/build-module/hooks/style.mjs.map +2 -2
  235. package/build-module/hooks/typography.mjs +19 -5
  236. package/build-module/hooks/typography.mjs.map +2 -2
  237. package/build-module/layouts/constrained.mjs +130 -57
  238. package/build-module/layouts/constrained.mjs.map +2 -2
  239. package/build-module/layouts/flex.mjs +123 -35
  240. package/build-module/layouts/flex.mjs.map +2 -2
  241. package/build-module/layouts/grid.mjs +105 -42
  242. package/build-module/layouts/grid.mjs.map +2 -2
  243. package/build-module/private-apis.mjs +4 -0
  244. package/build-module/private-apis.mjs.map +2 -2
  245. package/build-module/store/private-actions.mjs +16 -0
  246. package/build-module/store/private-actions.mjs.map +2 -2
  247. package/build-module/store/private-keys.mjs +7 -1
  248. package/build-module/store/private-keys.mjs.map +2 -2
  249. package/build-module/store/private-selectors.mjs +25 -2
  250. package/build-module/store/private-selectors.mjs.map +2 -2
  251. package/build-module/store/reducer.mjs +69 -1
  252. package/build-module/store/reducer.mjs.map +2 -2
  253. package/build-module/store/utils.mjs +5 -2
  254. package/build-module/store/utils.mjs.map +2 -2
  255. package/build-module/utils/color-values.mjs +19 -0
  256. package/build-module/utils/color-values.mjs.map +7 -0
  257. package/build-style/content-rtl.css +18 -3
  258. package/build-style/content.css +18 -3
  259. package/build-style/style-rtl.css +14 -17
  260. package/build-style/style.css +14 -17
  261. package/package.json +41 -41
  262. package/src/components/audio-player/index.native.js +7 -3
  263. package/src/components/block-card/index.js +67 -60
  264. package/src/components/block-heading-level-dropdown/heading-level-icon.js +2 -2
  265. package/src/components/block-icon/index.js +5 -2
  266. package/src/components/block-icon/index.native.js +2 -2
  267. package/src/components/block-inspector/index.js +153 -7
  268. package/src/components/block-inspector/inspector-pre-tabs-slot-fill.js +11 -0
  269. package/src/components/block-list/block-selection-button.native.js +3 -3
  270. package/src/components/block-list/content.scss +0 -6
  271. package/src/components/block-list/use-block-props/index.js +1 -1
  272. package/src/components/block-list/use-block-props/use-focus-handler.js +8 -6
  273. package/src/components/block-list/use-block-props/use-is-hovered.js +32 -15
  274. package/src/components/block-lock/modal.js +4 -4
  275. package/src/components/block-patterns-list/index.js +14 -5
  276. package/src/components/block-patterns-list/stories/index.story.jsx +2 -0
  277. package/src/components/block-patterns-list/style.scss +0 -1
  278. package/src/components/block-popover/index.js +20 -10
  279. package/src/components/block-toolbar/switch-section-style.js +2 -2
  280. package/src/components/block-visibility/modal.js +2 -2
  281. package/src/components/block-visibility/viewport-visibility-info.js +2 -2
  282. package/src/components/colors/test/with-colors.js +1 -1
  283. package/src/components/colors-gradients/control.js +10 -8
  284. package/src/components/colors-gradients/test/control.js +98 -1
  285. package/src/components/global-styles/advanced-panel.js +44 -39
  286. package/src/components/global-styles/color-panel.js +133 -60
  287. package/src/components/global-styles/dimensions-panel.js +17 -4
  288. package/src/components/global-styles/index.js +1 -0
  289. package/src/components/global-styles/shadow-panel-components.js +29 -19
  290. package/src/components/global-styles/state-control-badges.js +58 -0
  291. package/src/components/global-styles/state-control.js +28 -36
  292. package/src/components/global-styles/test/color-panel.js +135 -0
  293. package/src/components/iframe/index.js +0 -3
  294. package/src/components/iframe/use-scale-canvas.js +8 -2
  295. package/src/components/inserter/hooks/use-patterns-state.js +12 -7
  296. package/src/components/inserter/index.js +1 -0
  297. package/src/components/inserter/media-tab/media-preview.js +29 -20
  298. package/src/components/inserter/media-tab/utils.js +1 -1
  299. package/src/components/inserter/panel.js +2 -2
  300. package/src/components/inserter/style.scss +1 -0
  301. package/src/components/inserter-button/index.native.js +5 -2
  302. package/src/components/inspector-controls/block-support-tools-panel.js +10 -2
  303. package/src/components/inspector-controls/fill.js +18 -5
  304. package/src/components/inspector-controls/groups.js +2 -0
  305. package/src/components/inspector-controls-tabs/index.js +9 -5
  306. package/src/components/inspector-controls-tabs/settings-tab.js +1 -7
  307. package/src/components/inspector-controls-tabs/styles-tab.js +6 -0
  308. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +13 -7
  309. package/src/components/list-view/block-select-button.js +19 -9
  310. package/src/components/list-view/block.js +6 -1
  311. package/src/components/media-replace-flow/style.scss +0 -18
  312. package/src/components/preset-input-control/custom-value-controls.js +13 -6
  313. package/src/components/preset-input-control/index.js +2 -2
  314. package/src/components/provider/use-media-upload-settings.js +1 -0
  315. package/src/components/rich-text/event-listeners/enter.js +14 -2
  316. package/src/components/rich-text/event-listeners/paste-handler.js +5 -4
  317. package/src/components/unsupported-block-details/index.native.js +6 -2
  318. package/src/components/video-player/index.native.js +2 -2
  319. package/src/components/warning/index.native.js +2 -2
  320. package/src/hooks/background.js +59 -37
  321. package/src/hooks/block-fields/link/index.js +3 -3
  322. package/src/hooks/block-fields/media/index.js +3 -3
  323. package/src/hooks/block-style-state.js +127 -0
  324. package/src/hooks/border.js +25 -6
  325. package/src/hooks/color.js +40 -18
  326. package/src/hooks/dimensions.js +32 -11
  327. package/src/hooks/layout-child.js +179 -62
  328. package/src/hooks/layout.js +349 -75
  329. package/src/hooks/layout.scss +6 -0
  330. package/src/hooks/state-utils.js +158 -0
  331. package/src/hooks/states.js +109 -0
  332. package/src/hooks/style.js +456 -19
  333. package/src/hooks/test/block-style-state.js +270 -0
  334. package/src/hooks/test/layout.js +185 -0
  335. package/src/hooks/test/state-utils.js +193 -0
  336. package/src/hooks/test/style.js +301 -1
  337. package/src/hooks/typography.js +33 -14
  338. package/src/layouts/constrained.js +182 -95
  339. package/src/layouts/flex.js +141 -36
  340. package/src/layouts/grid.js +122 -32
  341. package/src/layouts/test/flex.js +57 -20
  342. package/src/private-apis.js +4 -0
  343. package/src/store/private-actions.js +32 -0
  344. package/src/store/private-keys.js +4 -0
  345. package/src/store/private-selectors.js +44 -2
  346. package/src/store/reducer.js +105 -1
  347. package/src/store/test/private-actions.js +26 -0
  348. package/src/store/test/private-selectors.js +90 -0
  349. package/src/store/test/reducer.js +363 -0
  350. package/src/store/utils.js +6 -2
  351. package/src/utils/color-values.js +28 -0
  352. package/src/utils/test/color-values.js +78 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/rich-text/event-listeners/paste-handler.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { pasteHandler } from '@wordpress/blocks';\nimport { isEmpty, insert, create } from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { addActiveFormats } from '../utils';\nimport { getPasteEventData } from '../../../utils/pasting';\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport default ( props ) => ( element ) => {\n\tfunction _onPaste( event ) {\n\t\tconst {\n\t\t\tdisableFormats,\n\t\t\tonChange,\n\t\t\tvalue,\n\t\t\tformatTypes,\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element or inside the element.\n\t\tif ( ! element.contains( event.target ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { plainText, html } = getPasteEventData( event );\n\n\t\tevent.preventDefault();\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\t// `pasteHandler` also logs this, but we're not using `pasteHandler` in\n\t\t// every case.\n\t\twindow.console.log( 'Received HTML (RichText):\\n\\n', html );\n\t\twindow.console.log( 'Received plain text (RichText):\\n\\n', plainText );\n\n\t\tif ( disableFormats ) {\n\t\t\tonChange( insert( value, plainText ) );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isInternal =\n\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\tfunction pasteInline( content ) {\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumulator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumulator === value ) {\n\t\t\t\t\t\taccumulator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t} else {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t}\n\t\t}\n\n\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t// without filtering the data. The filters are only meant for externally\n\t\t// pasted content and remove inline styles.\n\t\tif ( isInternal ) {\n\t\t\tpasteInline( html );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( pastePlainText ) {\n\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\treturn;\n\t\t}\n\n\t\tlet mode = 'INLINE';\n\n\t\tconst trimmedPlainText = plainText.trim();\n\n\t\tif (\n\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\tisEmpty( value ) &&\n\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t) {\n\t\t\tmode = 'BLOCKS';\n\t\t}\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode,\n\t\t\ttagName,\n\t\t\tpreserveWhiteSpace,\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tpasteInline( content );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! content.length || ! onReplace || ! isEmpty( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Record an intermediate paragraph-with-URL state so a single undo\n\t\t// after the URL \u2192 block transformation restores the pasted link.\n\t\tif ( mode === 'BLOCKS' ) {\n\t\t\tpasteInline( html );\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\t}\n\n\t\tonReplace( content, content.length - 1, -1 );\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\tdefaultView.addEventListener( 'paste', _onPaste );\n\treturn () => {\n\t\tdefaultView.removeEventListener( 'paste', _onPaste );\n\t};\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA6B;AAC7B,uBAAwC;AACxC,iBAAsB;AAKtB,mBAA0C;AAC1C,mBAAiC;AACjC,qBAAkC;AAIlC,IAAO,wBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,SAAU,OAAQ;AAC1B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,MAAM;AAIV,QAAK,CAAE,QAAQ,SAAU,MAAM,MAAO,GAAI;AACzC;AAAA,IACD;AAEA,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AAEA,UAAM,EAAE,WAAW,KAAK,QAAI,kCAAmB,KAAM;AAErD,UAAM,eAAe;AAKrB,WAAO,QAAQ,IAAK,iCAAiC,IAAK;AAC1D,WAAO,QAAQ,IAAK,uCAAuC,SAAU;AAErE,QAAK,gBAAiB;AACrB,mBAAU,yBAAQ,OAAO,SAAU,CAAE;AACrC;AAAA,IACD;AAEA,UAAM,aACL,MAAM,cAAc,QAAS,WAAY,MAAM;AAEhD,aAAS,YAAaA,UAAU;AAC/B,YAAM,cAAc,YAAY;AAAA,QAC/B,CAAE,aAAa,EAAE,oBAAoB,MAAO;AAE3C,cAAK,uBAAuB,gBAAgB,OAAQ;AACnD,0BAAc,oBAAqB,OAAO;AAAA,cACzC;AAAA,cACA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\n */\nimport { pasteHandler } from '@wordpress/blocks';\nimport { isEmpty, insert, create } from '@wordpress/rich-text';\nimport { isURL } from '@wordpress/url';\nimport { privateApis as composePrivateApis } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\nimport { addActiveFormats } from '../utils';\nimport { getPasteEventData } from '../../../utils/pasting';\nimport { unlock } from '../../../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\n/** @typedef {import('@wordpress/rich-text').RichTextValue} RichTextValue */\n\nexport default ( props ) => ( element ) => {\n\tfunction _onPaste( event ) {\n\t\tconst {\n\t\t\tdisableFormats,\n\t\t\tonChange,\n\t\t\tvalue,\n\t\t\tformatTypes,\n\t\t\ttagName,\n\t\t\tonReplace,\n\t\t\t__unstableEmbedURLOnPaste,\n\t\t\tpreserveWhiteSpace,\n\t\t\tpastePlainText,\n\t\t\tregistry,\n\t\t} = props.current;\n\n\t\t// The event listener is attached to the window, so we need to check if\n\t\t// the target is the element or inside the element.\n\t\tif ( ! element.contains( event.target ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { plainText, html } = getPasteEventData( event );\n\n\t\tevent.preventDefault();\n\n\t\t// Allows us to ask for this information when we get a report.\n\t\t// `pasteHandler` also logs this, but we're not using `pasteHandler` in\n\t\t// every case.\n\t\twindow.console.log( 'Received HTML (RichText):\\n\\n', html );\n\t\twindow.console.log( 'Received plain text (RichText):\\n\\n', plainText );\n\n\t\tif ( disableFormats ) {\n\t\t\tonChange( insert( value, plainText ) );\n\t\t\treturn;\n\t\t}\n\n\t\tconst isInternal =\n\t\t\tevent.clipboardData.getData( 'rich-text' ) === 'true';\n\n\t\tfunction pasteInline( content ) {\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumulator, { __unstablePasteRule } ) => {\n\t\t\t\t\t// Only allow one transform.\n\t\t\t\t\tif ( __unstablePasteRule && accumulator === value ) {\n\t\t\t\t\t\taccumulator = __unstablePasteRule( value, {\n\t\t\t\t\t\t\thtml,\n\t\t\t\t\t\t\tplainText,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\t\t\tif ( transformed !== value ) {\n\t\t\t\tonChange( transformed );\n\t\t\t} else {\n\t\t\t\tconst valueToInsert = create( { html: content } );\n\t\t\t\taddActiveFormats( valueToInsert, value.activeFormats );\n\t\t\t\tonChange( insert( value, valueToInsert ) );\n\t\t\t}\n\t\t}\n\n\t\t// If the data comes from a rich text instance, we can directly use it\n\t\t// without filtering the data. The filters are only meant for externally\n\t\t// pasted content and remove inline styles.\n\t\tif ( isInternal ) {\n\t\t\tpasteInline( html );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( pastePlainText ) {\n\t\t\tonChange( insert( value, create( { text: plainText } ) ) );\n\t\t\treturn;\n\t\t}\n\n\t\tlet mode = 'INLINE';\n\n\t\tconst trimmedPlainText = plainText.trim();\n\n\t\tif (\n\t\t\t__unstableEmbedURLOnPaste &&\n\t\t\tisEmpty( value ) &&\n\t\t\tisURL( trimmedPlainText ) &&\n\t\t\t// For the link pasting feature, allow only http(s) protocols.\n\t\t\t/^https?:/.test( trimmedPlainText )\n\t\t) {\n\t\t\tmode = 'BLOCKS';\n\t\t}\n\n\t\tconst content = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode,\n\t\t\ttagName,\n\t\t\tpreserveWhiteSpace,\n\t\t} );\n\n\t\tif ( typeof content === 'string' ) {\n\t\t\tpasteInline( content );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! content.length || ! onReplace || ! isEmpty( value ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Record an intermediate paragraph-with-URL state so a single undo\n\t\t// after the URL \u2192 block transformation restores the pasted link.\n\t\tif ( mode === 'BLOCKS' ) {\n\t\t\tpasteInline( html );\n\t\t\tregistry\n\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\t}\n\n\t\tonReplace( content, content.length - 1, -1 );\n\t}\n\n\tconst { defaultView } = element.ownerDocument;\n\n\t// Attach the listener to the window so parent elements have the chance to\n\t// prevent the default behavior.\n\treturn subscribeDelegatedListener( defaultView, 'paste', _onPaste );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA6B;AAC7B,uBAAwC;AACxC,iBAAsB;AACtB,qBAAkD;AAKlD,mBAA0C;AAC1C,mBAAiC;AACjC,qBAAkC;AAClC,yBAAuB;AAEvB,IAAM,EAAE,2BAA2B,QAAI,2BAAQ,eAAAA,WAAmB;AAIlE,IAAO,wBAAQ,CAAE,UAAW,CAAE,YAAa;AAC1C,WAAS,SAAU,OAAQ;AAC1B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,MAAM;AAIV,QAAK,CAAE,QAAQ,SAAU,MAAM,MAAO,GAAI;AACzC;AAAA,IACD;AAEA,QAAK,MAAM,kBAAmB;AAC7B;AAAA,IACD;AAEA,UAAM,EAAE,WAAW,KAAK,QAAI,kCAAmB,KAAM;AAErD,UAAM,eAAe;AAKrB,WAAO,QAAQ,IAAK,iCAAiC,IAAK;AAC1D,WAAO,QAAQ,IAAK,uCAAuC,SAAU;AAErE,QAAK,gBAAiB;AACrB,mBAAU,yBAAQ,OAAO,SAAU,CAAE;AACrC;AAAA,IACD;AAEA,UAAM,aACL,MAAM,cAAc,QAAS,WAAY,MAAM;AAEhD,aAAS,YAAaC,UAAU;AAC/B,YAAM,cAAc,YAAY;AAAA,QAC/B,CAAE,aAAa,EAAE,oBAAoB,MAAO;AAE3C,cAAK,uBAAuB,gBAAg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+48,7 @@ var import_utils = require("./utils.cjs");
48
48
  var import_store = require("../store/index.cjs");
49
49
  var import_background_panel = __toESM(require("../components/global-styles/background-panel.cjs"));
50
50
  var import_private_keys = require("../store/private-keys.cjs");
51
+ var import_block_style_state = require("./block-style-state.cjs");
51
52
  var import_jsx_runtime = require("react/jsx-runtime");
52
53
  var BACKGROUND_SUPPORT_KEY = "background";
53
54
  var BACKGROUND_BLOCK_DEFAULT_VALUES = {
@@ -131,6 +132,7 @@ function BackgroundImagePanel({
131
132
  setAttributes,
132
133
  settings
133
134
  }) {
135
+ const selectedState = (0, import_block_style_state.useBlockStyleState)();
134
136
  const { style, className, inheritedValue } = (0, import_data.useSelect)(
135
137
  (select) => {
136
138
  const { getBlockAttributes, getSettings } = select(import_store.store);
@@ -168,7 +170,12 @@ function BackgroundImagePanel({
168
170
  if (!(0, import_background_panel.useHasBackgroundPanel)(settings) || !hasBackgroundSupport(name)) {
169
171
  return null;
170
172
  }
171
- const onChange = (newStyle) => {
173
+ const isStateSelected = !(0, import_block_style_state.isDefaultBlockStyleState)(selectedState);
174
+ const onChange = isStateSelected ? (newStyle) => {
175
+ setAttributes({
176
+ style: (0, import_block_style_state.setStyleForState)(style, selectedState, newStyle)
177
+ });
178
+ } : (newStyle) => {
172
179
  const isMigrating = backgroundGradientSupported && !!style?.color?.gradient;
173
180
  const newAttributes = {
174
181
  style: (0, import_utils.cleanEmptyObject)(
@@ -182,7 +189,10 @@ function BackgroundImagePanel({
182
189
  )
183
190
  };
184
191
  if (isMigrating && !!newStyle?.background?.gradient) {
185
- newAttributes.className = (0, import_clsx.default)(className, "has-background");
192
+ newAttributes.className = (0, import_clsx.default)(
193
+ className,
194
+ "has-background"
195
+ );
186
196
  } else if (!newStyle?.background?.gradient && className?.includes("has-background")) {
187
197
  newAttributes.className = className.split(" ").filter((c) => c !== "has-background").join(" ") || void 0;
188
198
  }
@@ -216,7 +226,7 @@ function BackgroundImagePanel({
216
226
  settings: updatedSettings,
217
227
  onChange,
218
228
  defaultControls,
219
- value: styleValue
229
+ value: isStateSelected ? (0, import_block_style_state.getStyleForState)(style, selectedState) : styleValue
220
230
  }
221
231
  );
222
232
  }
@@ -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';\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 { 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 onChange = ( newStyle ) => {\n\t\tconst isMigrating =\n\t\t\tbackgroundGradientSupported && !! style?.color?.gradient;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject(\n\t\t\t\tbackgroundGradientSupported\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...newStyle,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...newStyle?.color,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }\n\t\t\t\t\t: newStyle\n\t\t\t),\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 \u2014 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\tif ( isMigrating && !! newStyle?.background?.gradient ) {\n\t\t\tnewAttributes.className = clsx( className, 'has-background' );\n\t\t} else if (\n\t\t\t! newStyle?.background?.gradient &&\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\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={ styleValue }\n\t\t/>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAAgC;AAChC,kBAA0B;AAC1B,qBAA4B;AAK5B,gCAA8B;AAC9B,mBAAiC;AACjC,mBAA0C;AAC1C,8BAKO;AACP,0BAAoC;AAkIlC;AAhIK,IAAM,yBAAyB;AAG/B,IAAM,kCAAkC;AAAA,EAC9C,gBAAgB;AAAA,EAChB,oBAAoB;AAAA;AACrB;AAUO,SAAS,qBAAsB,WAAW,UAAU,OAAQ;AAClE,QAAM,cAAU,+BAAiB,WAAW,sBAAuB;AAEnE,MAAK,YAAY,MAAO;AACvB,WAAO;AAAA,EACR;AAEA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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,gBAAY,YAAAC,SAAM,WAAW,gBAAiB;AAAA,IAC7D,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,EAC9B;AAKA,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,sBAAkB,+BAAiB,MAAM;AAAA,IAC9C;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SACC;AAAA,IAAC,wBAAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAU;AAAA,MACV,eAAgB;AAAA,MAChB,UAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,OAAQ;AAAA;AAAA,EACT;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 { 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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAAgC;AAChC,kBAA0B;AAC1B,qBAA4B;AAK5B,gCAA8B;AAC9B,mBAAiC;AACjC,mBAA0C;AAC1C,8BAKO;AACP,0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A,IAC9C;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SACC;AAAA,IAAC,wBAAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAU;AAAA,MACV,eAAgB;AAAA,MAChB,UAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,OACC,sBACG,2CAAkB,OAAO,aAAc,IACvC;AAAA;AAAA,EAEL;AAEF;AAEA,IAAO,qBAAQ;AAAA,EACd;AAAA,EACA,eAAe,CAAE,OAAQ;AAAA,EACzB,YAAY;AACb;",
6
6
  "names": ["InspectorControls", "blockEditorStore", "clsx", "StylesBackgroundPanel"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/hooks/block-fields/link/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tIcon,\n\t__experimentalGrid as Grid,\n\tPopover,\n} from '@wordpress/components';\nimport { useMemo, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { link } from '@wordpress/icons';\nimport { prependHTTP } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport LinkControl from '../../../components/link-control';\nimport { useInspectorPopoverPlacement } from '../use-inspector-popover-placement';\n\nexport const NEW_TAB_REL = 'noopener';\nexport const NEW_TAB_TARGET = '_blank';\nexport const NOFOLLOW_REL = 'nofollow';\n\n/**\n * Updates the link attributes.\n *\n * @param {Object} attributes The current block attributes.\n * @param {string} attributes.rel The current link rel attribute.\n * @param {string} attributes.url The current link url.\n * @param {boolean} attributes.opensInNewTab Whether the link should open in a new window.\n * @param {boolean} attributes.nofollow Whether the link should be marked as nofollow.\n */\nexport function getUpdatedLinkAttributes( {\n\trel = '',\n\turl = '',\n\topensInNewTab,\n\tnofollow,\n} ) {\n\tlet newLinkTarget;\n\t// Since `rel` is editable attribute, we need to check for existing values and proceed accordingly.\n\tlet updatedRel = rel;\n\n\tif ( opensInNewTab ) {\n\t\tnewLinkTarget = NEW_TAB_TARGET;\n\t\tupdatedRel = updatedRel?.includes( NEW_TAB_REL )\n\t\t\t? updatedRel\n\t\t\t: updatedRel + ` ${ NEW_TAB_REL }`;\n\t} else {\n\t\tconst relRegex = new RegExp( `\\\\b${ NEW_TAB_REL }\\\\s*`, 'g' );\n\t\tupdatedRel = updatedRel?.replace( relRegex, '' ).trim();\n\t}\n\n\tif ( nofollow ) {\n\t\tupdatedRel = updatedRel?.includes( NOFOLLOW_REL )\n\t\t\t? updatedRel\n\t\t\t: ( updatedRel + ` ${ NOFOLLOW_REL }` ).trim();\n\t} else {\n\t\tconst relRegex = new RegExp( `\\\\b${ NOFOLLOW_REL }\\\\s*`, 'g' );\n\t\tupdatedRel = updatedRel?.replace( relRegex, '' ).trim();\n\t}\n\n\treturn {\n\t\turl: prependHTTP( url ),\n\t\tlinkTarget: newLinkTarget,\n\t\trel: updatedRel || undefined,\n\t};\n}\n\nexport default function Link( { data, field, onChange } ) {\n\tconst [ isLinkControlOpen, setIsLinkControlOpen ] = useState( false );\n\tconst { popoverProps } = useInspectorPopoverPlacement( {\n\t\tisControl: true,\n\t} );\n\tconst value = field.getValue( { item: data } );\n\tconst url = value?.url;\n\tconst rel = value?.rel || '';\n\tconst target = value?.linkTarget;\n\n\tconst opensInNewTab = target === NEW_TAB_TARGET;\n\tconst nofollow = rel === NOFOLLOW_REL;\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/51256.\n\tconst linkValue = useMemo(\n\t\t() => ( { url, opensInNewTab, nofollow } ),\n\t\t[ url, opensInNewTab, nofollow ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"block-editor-content-only-controls__link\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsLinkControlOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Grid\n\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\ttemplateColumns=\"24px 1fr\"\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__link-row\"\n\t\t\t\t>\n\t\t\t\t\t{ url && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<Icon icon={ link } size={ 24 } />\n\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__link-title\">\n\t\t\t\t\t\t\t\t{ url }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\t\t\tstyle={ { opacity: 0.3 } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__link-title\">\n\t\t\t\t\t\t\t\t{ __( 'Link' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</Grid>\n\t\t\t</Button>\n\t\t\t{ isLinkControlOpen && (\n\t\t\t\t<Popover\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsLinkControlOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\t{ ...( popoverProps ?? {} ) }\n\t\t\t\t>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\tvalue={ linkValue }\n\t\t\t\t\t\tonChange={ ( newValues ) => {\n\t\t\t\t\t\t\tconst updatedAttrs = getUpdatedLinkAttributes( {\n\t\t\t\t\t\t\t\trel,\n\t\t\t\t\t\t\t\t...newValues,\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\t\tvalue: updatedAttrs,\n\t\t\t\t\t\t\t\t} )\n\t\t\t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QACE,GAAK,gBAAgB,CAAC;AAAA,QAExB;AAAA,UAAC,oBAAAC;AAAA,UAAA;AAAA,YACA,OAAQ;AAAA,YACR,UAAW,CAAE,cAAe;AAC3B,oBAAM,eAAe,yBAA0B;AAAA,gBAC9C;AAAA,gBACA,GAAG;AAAA,cACJ,CAAE;AAEF;AAAA,gBACC,MAAM,SAAU;AAAA,kBACf,MAAM;AAAA,kBACN,OAAO;AAAA,gBACR,CAAE;AAAA,cACH;AAAA,YACD;AAAA,YACA,UAAW,MAAM;AAChB;AAAA,gBACC,MAAM,SAAU;AAAA,kBACf,MAAM;AAAA,kBACN,OAAO,CAAC;AAAA,gBACT,CAAE;AAAA,cACH;AAAA,YACD;AAAA;AAAA,QACD;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
6
- "names": ["Grid", "LinkControl"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tIcon as WCIcon,\n\t__experimentalGrid as Grid,\n\tPopover,\n} from '@wordpress/components';\nimport { useMemo, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { link } from '@wordpress/icons';\nimport { prependHTTP } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport LinkControl from '../../../components/link-control';\nimport { useInspectorPopoverPlacement } from '../use-inspector-popover-placement';\n\nexport const NEW_TAB_REL = 'noopener';\nexport const NEW_TAB_TARGET = '_blank';\nexport const NOFOLLOW_REL = 'nofollow';\n\n/**\n * Updates the link attributes.\n *\n * @param {Object} attributes The current block attributes.\n * @param {string} attributes.rel The current link rel attribute.\n * @param {string} attributes.url The current link url.\n * @param {boolean} attributes.opensInNewTab Whether the link should open in a new window.\n * @param {boolean} attributes.nofollow Whether the link should be marked as nofollow.\n */\nexport function getUpdatedLinkAttributes( {\n\trel = '',\n\turl = '',\n\topensInNewTab,\n\tnofollow,\n} ) {\n\tlet newLinkTarget;\n\t// Since `rel` is editable attribute, we need to check for existing values and proceed accordingly.\n\tlet updatedRel = rel;\n\n\tif ( opensInNewTab ) {\n\t\tnewLinkTarget = NEW_TAB_TARGET;\n\t\tupdatedRel = updatedRel?.includes( NEW_TAB_REL )\n\t\t\t? updatedRel\n\t\t\t: updatedRel + ` ${ NEW_TAB_REL }`;\n\t} else {\n\t\tconst relRegex = new RegExp( `\\\\b${ NEW_TAB_REL }\\\\s*`, 'g' );\n\t\tupdatedRel = updatedRel?.replace( relRegex, '' ).trim();\n\t}\n\n\tif ( nofollow ) {\n\t\tupdatedRel = updatedRel?.includes( NOFOLLOW_REL )\n\t\t\t? updatedRel\n\t\t\t: ( updatedRel + ` ${ NOFOLLOW_REL }` ).trim();\n\t} else {\n\t\tconst relRegex = new RegExp( `\\\\b${ NOFOLLOW_REL }\\\\s*`, 'g' );\n\t\tupdatedRel = updatedRel?.replace( relRegex, '' ).trim();\n\t}\n\n\treturn {\n\t\turl: prependHTTP( url ),\n\t\tlinkTarget: newLinkTarget,\n\t\trel: updatedRel || undefined,\n\t};\n}\n\nexport default function Link( { data, field, onChange } ) {\n\tconst [ isLinkControlOpen, setIsLinkControlOpen ] = useState( false );\n\tconst { popoverProps } = useInspectorPopoverPlacement( {\n\t\tisControl: true,\n\t} );\n\tconst value = field.getValue( { item: data } );\n\tconst url = value?.url;\n\tconst rel = value?.rel || '';\n\tconst target = value?.linkTarget;\n\n\tconst opensInNewTab = target === NEW_TAB_TARGET;\n\tconst nofollow = rel === NOFOLLOW_REL;\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/51256.\n\tconst linkValue = useMemo(\n\t\t() => ( { url, opensInNewTab, nofollow } ),\n\t\t[ url, opensInNewTab, nofollow ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"block-editor-content-only-controls__link\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsLinkControlOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Grid\n\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\ttemplateColumns=\"24px 1fr\"\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__link-row\"\n\t\t\t\t>\n\t\t\t\t\t{ url && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<WCIcon icon={ link } size={ 24 } />\n\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__link-title\">\n\t\t\t\t\t\t\t\t{ url }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<WCIcon\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\t\t\tstyle={ { opacity: 0.3 } }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__link-title\">\n\t\t\t\t\t\t\t\t{ __( 'Link' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</Grid>\n\t\t\t</Button>\n\t\t\t{ isLinkControlOpen && (\n\t\t\t\t<Popover\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsLinkControlOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\t{ ...( popoverProps ?? {} ) }\n\t\t\t\t>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\tvalue={ linkValue }\n\t\t\t\t\t\tonChange={ ( newValues ) => {\n\t\t\t\t\t\t\tconst updatedAttrs = getUpdatedLinkAttributes( {\n\t\t\t\t\t\t\t\trel,\n\t\t\t\t\t\t\t\t...newValues,\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\t\tv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AA,MAAC;AAAA;AAAA,QACA,SAAU,MAAM;AACf,+BAAsB,KAAM;AAAA,QAC7B;AAAA,QACE,GAAK,gBAAgB,CAAC;AAAA,QAExB;AAAA,UAAC,oBAAAC;AAAA,UAAA;AAAA,YACA,OAAQ;AAAA,YACR,UAAW,CAAE,cAAe;AAC3B,oBAAM,eAAe,yBAA0B;AAAA,gBAC9C;AAAA,gBACA,GAAG;AAAA,cACJ,CAAE;AAEF;AAAA,gBACC,MAAM,SAAU;AAAA,kBACf,MAAM;AAAA,kBACN,OAAO;AAAA,gBACR,CAAE;AAAA,cACH;AAAA,YACD;AAAA,YACA,UAAW,MAAM;AAChB;AAAA,gBACC,MAAM,SAAU;AAAA,kBACf,MAAM;AAAA,kBACN,OAAO,CAAC;AAAA,gBACT,CAAE;AAAA,cACH;AAAA,YACD;AAAA;AAAA,QACD;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
6
+ "names": ["Grid", "WCIcon", "LinkControl"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/hooks/block-fields/media/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tIcon,\n\t__experimentalGrid as Grid,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\taudio as audioIcon,\n\timage as imageIcon,\n\tmedia as mediaIcon,\n\tvideo as videoIcon,\n\treset as resetIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport MediaReplaceFlow from '../../../components/media-replace-flow';\nimport MediaUploadCheck from '../../../components/media-upload/check';\nimport { useInspectorPopoverPlacement } from '../use-inspector-popover-placement';\nimport { getMediaSelectKey } from '../../../store/private-keys';\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Focuses the toggle button.\n *\n * @param {Object} containerRef - ref object containing current element\n */\nconst focusToggleButton = ( containerRef ) => {\n\t// Use requestAnimationFrame to ensure DOM updates are complete.\n\twindow.requestAnimationFrame( () => {\n\t\tconst [ toggleButton ] = focus.tabbable.find( containerRef?.current );\n\t\tif ( ! toggleButton ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttoggleButton.focus();\n\t} );\n};\n\nfunction MediaThumbnail( { data, field, attachment, config } ) {\n\tconst { allowedTypes = [], multiple = false } = config || {};\n\n\tif ( multiple ) {\n\t\treturn 'todo multiple';\n\t}\n\n\tif ( attachment?.media_type === 'image' || attachment?.poster ) {\n\t\treturn (\n\t\t\t<div className=\"block-editor-content-only-controls__media-thumbnail\">\n\t\t\t\t<img\n\t\t\t\t\talt=\"\"\n\t\t\t\t\twidth={ 20 }\n\t\t\t\t\theight={ 20 }\n\t\t\t\t\tsrc={\n\t\t\t\t\t\tattachment.media_type === 'image'\n\t\t\t\t\t\t\t? attachment.source_url\n\t\t\t\t\t\t\t: attachment.poster\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( allowedTypes.length === 1 ) {\n\t\tconst value = field.getValue( { item: data } );\n\t\tconst url = value?.url;\n\n\t\tif ( allowedTypes[ 0 ] === 'image' && url ) {\n\t\t\treturn (\n\t\t\t\t<div className=\"block-editor-content-only-controls__media-thumbnail\">\n\t\t\t\t\t<img alt=\"\" width={ 20 } height={ 20 } src={ url } />\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\tlet icon;\n\t\tif ( allowedTypes[ 0 ] === 'image' ) {\n\t\t\ticon = imageIcon;\n\t\t} else if ( allowedTypes[ 0 ] === 'video' ) {\n\t\t\ticon = videoIcon;\n\t\t} else if ( allowedTypes[ 0 ] === 'audio' ) {\n\t\t\ticon = audioIcon;\n\t\t} else {\n\t\t\ticon = mediaIcon;\n\t\t}\n\n\t\tif ( icon ) {\n\t\t\treturn <Icon icon={ icon } size={ 20 } />;\n\t\t}\n\t}\n\n\treturn <Icon icon={ mediaIcon } size={ 20 } />;\n}\n\nexport default function Media( { data, field, onChange, config = {} } ) {\n\tconst { popoverProps } = useInspectorPopoverPlacement( {\n\t\tisControl: true,\n\t} );\n\tconst value = field.getValue( { item: data } );\n\tconst {\n\t\tallowedTypes = [],\n\t\tmultiple = false,\n\t\tuseFeaturedImage = false,\n\t} = config;\n\n\tconst id = value?.id;\n\tconst url = value?.url;\n\n\tconst attachment = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! id ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\tconst getMedia = settings[ getMediaSelectKey ];\n\n\t\t\tif ( ! getMedia ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getMedia( select, id );\n\t\t},\n\t\t[ id ]\n\t);\n\n\t// TODO - pluralize when multiple.\n\tlet chooseItemLabel;\n\tif ( allowedTypes.length === 1 ) {\n\t\tconst allowedType = allowedTypes[ 0 ];\n\t\tif ( allowedType === 'image' ) {\n\t\t\tchooseItemLabel = __( 'Image' );\n\t\t} else if ( allowedType === 'video' ) {\n\t\t\tchooseItemLabel = __( 'Video' );\n\t\t} else if ( allowedType === 'application' ) {\n\t\t\tchooseItemLabel = __( 'File' );\n\t\t} else {\n\t\t\tchooseItemLabel = __( 'Media' );\n\t\t}\n\t} else {\n\t\tchooseItemLabel = __( 'Media' );\n\t}\n\tconst containerRef = useRef();\n\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<div\n\t\t\t\tref={ containerRef }\n\t\t\t\tclassName=\"block-editor-content-only-controls\"\n\t\t\t>\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-replace-flow\"\n\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tonReset={ () => {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\tvalue: {},\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{ ...( useFeaturedImage && {\n\t\t\t\t\t\tuseFeaturedImage: !! value?.featuredImage,\n\t\t\t\t\t\tonToggleFeaturedImage: () => {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\t\t\tfeaturedImage: ! value?.featuredImage,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t} ) }\n\t\t\t\t\tonSelect={ ( selectedMedia ) => {\n\t\t\t\t\t\tif ( selectedMedia.id && selectedMedia.url ) {\n\t\t\t\t\t\t\tconst newValue = {\n\t\t\t\t\t\t\t\t...selectedMedia,\n\t\t\t\t\t\t\t\tmediaType: selectedMedia.media_type,\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t// Turn off featured image when manually selecting media\n\t\t\t\t\t\t\tif ( useFeaturedImage ) {\n\t\t\t\t\t\t\t\tnewValue.featuredImage = false;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\trenderToggle={ ( buttonProps ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media\"\n\t\t\t\t\t\t\t{ ...buttonProps }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\t\ttemplateColumns=\"20px 1fr\"\n\t\t\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-row\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<MediaThumbnail\n\t\t\t\t\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\t\t\t\tconfig={ config }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__media-title\">\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t// TODO - truncate long titles or url smartly (e.g. show filename).\n\t\t\t\t\t\t\t\t\t\t\t\tattachment?.title?.raw &&\n\t\t\t\t\t\t\t\t\t\t\t\tattachment?.title?.raw !== ''\n\t\t\t\t\t\t\t\t\t\t\t\t\t? attachment?.title?.raw\n\t\t\t\t\t\t\t\t\t\t\t\t\t: url\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-placeholder\"\n\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\twidth: '20px',\n\t\t\t\t\t\t\t\t\t\t\t\theight: '20px',\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__media-title\">\n\t\t\t\t\t\t\t\t\t\t\t{ chooseItemLabel }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t{ url && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tlabel={ __( 'Reset' ) }\n\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-reset\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\ticon={ resetIcon }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\t\tvalue: {},\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tfocusToggleButton( containerRef );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</MediaUploadCheck>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAIO;AACP,kBAA0B;AAC1B,iBAAsB;AACtB,qBAAuB;AACvB,kBAAmB;AACnB,mBAMO;AAKP,gCAA6B;AAC7B,mBAA6B;AAC7B,6CAA6C;AAC7C,0BAAkC;AAClC,mBAA0C;AA6BtC;AAtBJ,IAAM,oBAAoB,CAAE,iBAAkB;AAE7C,SAAO,sBAAuB,MAAM;AACnC,UAAM,CAAE,YAAa,IAAI,iBAAM,SAAS,KAAM,cAAc,OAAQ;AACpE,QAAK,CAAE,cAAe;AACrB;AAAA,IACD;AAEA,iBAAa,MAAM;AAAA,EACpB,CAAE;AAC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AAK,WAAU,mDACb,2BACH;AAAA,yBACD;AAAA;AAAA;AAAA,gBAEF;AAAA;AAAA,YACD;AAAA;AAAA,QAEF;AAAA,QACE,OACD;AAAA,UAAC;AAAA;AAAA,YACA,WAAQ,gBAAI,OAAQ;AAAA,YACpB,WAAU;AAAA,YACV,MAAK;AAAA,YACL,MAAO,aAAAC;AAAA,YACP,SAAU,MAAM;AACf;AAAA,gBACC,MAAM,SAAU;AAAA,kBACf,MAAM;AAAA,kBACN,OAAO,CAAC;AAAA,gBACT,CAAE;AAAA,cACH;AAEA,gCAAmB,YAAa;AAAA,YACjC;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF,GACD;AAEF;",
6
- "names": ["imageIcon", "videoIcon", "audioIcon", "mediaIcon", "blockEditorStore", "MediaUploadCheck", "MediaReplaceFlow", "Grid", "resetIcon"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tIcon as WCIcon,\n\t__experimentalGrid as Grid,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\taudio as audioIcon,\n\timage as imageIcon,\n\tmedia as mediaIcon,\n\tvideo as videoIcon,\n\treset as resetIcon,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport MediaReplaceFlow from '../../../components/media-replace-flow';\nimport MediaUploadCheck from '../../../components/media-upload/check';\nimport { useInspectorPopoverPlacement } from '../use-inspector-popover-placement';\nimport { getMediaSelectKey } from '../../../store/private-keys';\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Focuses the toggle button.\n *\n * @param {Object} containerRef - ref object containing current element\n */\nconst focusToggleButton = ( containerRef ) => {\n\t// Use requestAnimationFrame to ensure DOM updates are complete.\n\twindow.requestAnimationFrame( () => {\n\t\tconst [ toggleButton ] = focus.tabbable.find( containerRef?.current );\n\t\tif ( ! toggleButton ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttoggleButton.focus();\n\t} );\n};\n\nfunction MediaThumbnail( { data, field, attachment, config } ) {\n\tconst { allowedTypes = [], multiple = false } = config || {};\n\n\tif ( multiple ) {\n\t\treturn 'todo multiple';\n\t}\n\n\tif ( attachment?.media_type === 'image' || attachment?.poster ) {\n\t\treturn (\n\t\t\t<div className=\"block-editor-content-only-controls__media-thumbnail\">\n\t\t\t\t<img\n\t\t\t\t\talt=\"\"\n\t\t\t\t\twidth={ 20 }\n\t\t\t\t\theight={ 20 }\n\t\t\t\t\tsrc={\n\t\t\t\t\t\tattachment.media_type === 'image'\n\t\t\t\t\t\t\t? attachment.source_url\n\t\t\t\t\t\t\t: attachment.poster\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( allowedTypes.length === 1 ) {\n\t\tconst value = field.getValue( { item: data } );\n\t\tconst url = value?.url;\n\n\t\tif ( allowedTypes[ 0 ] === 'image' && url ) {\n\t\t\treturn (\n\t\t\t\t<div className=\"block-editor-content-only-controls__media-thumbnail\">\n\t\t\t\t\t<img alt=\"\" width={ 20 } height={ 20 } src={ url } />\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\tlet icon;\n\t\tif ( allowedTypes[ 0 ] === 'image' ) {\n\t\t\ticon = imageIcon;\n\t\t} else if ( allowedTypes[ 0 ] === 'video' ) {\n\t\t\ticon = videoIcon;\n\t\t} else if ( allowedTypes[ 0 ] === 'audio' ) {\n\t\t\ticon = audioIcon;\n\t\t} else {\n\t\t\ticon = mediaIcon;\n\t\t}\n\n\t\tif ( icon ) {\n\t\t\treturn <WCIcon icon={ icon } size={ 20 } />;\n\t\t}\n\t}\n\n\treturn <WCIcon icon={ mediaIcon } size={ 20 } />;\n}\n\nexport default function Media( { data, field, onChange, config = {} } ) {\n\tconst { popoverProps } = useInspectorPopoverPlacement( {\n\t\tisControl: true,\n\t} );\n\tconst value = field.getValue( { item: data } );\n\tconst {\n\t\tallowedTypes = [],\n\t\tmultiple = false,\n\t\tuseFeaturedImage = false,\n\t} = config;\n\n\tconst id = value?.id;\n\tconst url = value?.url;\n\n\tconst attachment = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! id ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\t\tconst getMedia = settings[ getMediaSelectKey ];\n\n\t\t\tif ( ! getMedia ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getMedia( select, id );\n\t\t},\n\t\t[ id ]\n\t);\n\n\t// TODO - pluralize when multiple.\n\tlet chooseItemLabel;\n\tif ( allowedTypes.length === 1 ) {\n\t\tconst allowedType = allowedTypes[ 0 ];\n\t\tif ( allowedType === 'image' ) {\n\t\t\tchooseItemLabel = __( 'Image' );\n\t\t} else if ( allowedType === 'video' ) {\n\t\t\tchooseItemLabel = __( 'Video' );\n\t\t} else if ( allowedType === 'application' ) {\n\t\t\tchooseItemLabel = __( 'File' );\n\t\t} else {\n\t\t\tchooseItemLabel = __( 'Media' );\n\t\t}\n\t} else {\n\t\tchooseItemLabel = __( 'Media' );\n\t}\n\tconst containerRef = useRef();\n\n\treturn (\n\t\t<MediaUploadCheck>\n\t\t\t<div\n\t\t\t\tref={ containerRef }\n\t\t\t\tclassName=\"block-editor-content-only-controls\"\n\t\t\t>\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-replace-flow\"\n\t\t\t\t\tallowedTypes={ allowedTypes }\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\tmultiple={ multiple }\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tonReset={ () => {\n\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\tvalue: {},\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{ ...( useFeaturedImage && {\n\t\t\t\t\t\tuseFeaturedImage: !! value?.featuredImage,\n\t\t\t\t\t\tonToggleFeaturedImage: () => {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\t\t\tfeaturedImage: ! value?.featuredImage,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t} ) }\n\t\t\t\t\tonSelect={ ( selectedMedia ) => {\n\t\t\t\t\t\tif ( selectedMedia.id && selectedMedia.url ) {\n\t\t\t\t\t\t\tconst newValue = {\n\t\t\t\t\t\t\t\t...selectedMedia,\n\t\t\t\t\t\t\t\tmediaType: selectedMedia.media_type,\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t// Turn off featured image when manually selecting media\n\t\t\t\t\t\t\tif ( useFeaturedImage ) {\n\t\t\t\t\t\t\t\tnewValue.featuredImage = false;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t\trenderToggle={ ( buttonProps ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media\"\n\t\t\t\t\t\t\t{ ...buttonProps }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\t\ttemplateColumns=\"20px 1fr\"\n\t\t\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-row\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<MediaThumbnail\n\t\t\t\t\t\t\t\t\t\t\tattachment={ attachment }\n\t\t\t\t\t\t\t\t\t\t\tfield={ field }\n\t\t\t\t\t\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\t\t\t\t\t\tconfig={ config }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__media-title\">\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t// TODO - truncate long titles or url smartly (e.g. show filename).\n\t\t\t\t\t\t\t\t\t\t\t\tattachment?.title?.raw &&\n\t\t\t\t\t\t\t\t\t\t\t\tattachment?.title?.raw !== ''\n\t\t\t\t\t\t\t\t\t\t\t\t\t? attachment?.title?.raw\n\t\t\t\t\t\t\t\t\t\t\t\t\t: url\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-placeholder\"\n\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\twidth: '20px',\n\t\t\t\t\t\t\t\t\t\t\t\theight: '20px',\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<span className=\"block-editor-content-only-controls__media-title\">\n\t\t\t\t\t\t\t\t\t\t\t{ chooseItemLabel }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t\t{ url && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tlabel={ __( 'Reset' ) }\n\t\t\t\t\t\tclassName=\"block-editor-content-only-controls__media-reset\"\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\ticon={ resetIcon }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChange(\n\t\t\t\t\t\t\t\tfield.setValue( {\n\t\t\t\t\t\t\t\t\titem: data,\n\t\t\t\t\t\t\t\t\tvalue: {},\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tfocusToggleButton( containerRef );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</MediaUploadCheck>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAIO;AACP,kBAA0B;AAC1B,iBAAsB;AACtB,qBAAuB;AACvB,kBAAmB;AACnB,mBAMO;AAKP,gCAA6B;AAC7B,mBAA6B;AAC7B,6CAA6C;AAC7C,0BAAkC;AAClC,mBAA0C;AA6BtC;AAtBJ,IAAM,oBAAoB,CAAE,iBAAkB;AAE7C,SAAO,sBAAuB,MAAM;AACnC,UAAM,CAAE,YAAa,IAAI,iBAAM,SAAS,KAAM,cAAc,OAAQ;AACpE,QAAK,CAAE,cAAe;AACrB;AAAA,IACD;AAEA,iBAAa,MAAM;AAAA,EACpB,CAAE;AACH;AAEA,SAAS,eAAgB,EAAE,MAAM,OAAO,YAAY,OAAO,GAAI;AAC9D,QAAM,EAAE,eAAe,CAAC,GAAG,WAAW,MAAM,IAAI,UAAU,CAAC;AAE3D,MAAK,UAAW;AACf,WA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AAA;AAAA,YACA,WAAQ,gBAAI,OAAQ;AAAA,YACpB,WAAU;AAAA,YACV,MAAK;AAAA,YACL,MAAO,aAAAC;AAAA,YACP,SAAU,MAAM;AACf;AAAA,gBACC,MAAM,SAAU;AAAA,kBACf,MAAM;AAAA,kBACN,OAAO,CAAC;AAAA,gBACT,CAAE;AAAA,cACH;AAEA,gCAAmB,YAAa;AAAA,YACjC;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF,GACD;AAEF;",
6
+ "names": ["imageIcon", "videoIcon", "audioIcon", "mediaIcon", "WCIcon", "blockEditorStore", "MediaUploadCheck", "MediaReplaceFlow", "Grid", "resetIcon"]
7
7
  }
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/block-editor/src/hooks/block-style-state.js
21
+ var block_style_state_exports = {};
22
+ __export(block_style_state_exports, {
23
+ BlockStyleStateProvider: () => BlockStyleStateProvider,
24
+ DEFAULT_BLOCK_STYLE_STATE: () => DEFAULT_BLOCK_STYLE_STATE,
25
+ getStyleForState: () => getStyleForState,
26
+ hasPseudoBlockStyleState: () => hasPseudoBlockStyleState,
27
+ hasViewportBlockStyleState: () => hasViewportBlockStyleState,
28
+ isDefaultBlockStyleState: () => isDefaultBlockStyleState,
29
+ scopeResetAllFilterToState: () => scopeResetAllFilterToState,
30
+ setStyleForState: () => setStyleForState,
31
+ useBlockStyleState: () => useBlockStyleState
32
+ });
33
+ module.exports = __toCommonJS(block_style_state_exports);
34
+ var import_element = require("@wordpress/element");
35
+ var import_utils = require("./utils.cjs");
36
+ var import_object = require("../utils/object.cjs");
37
+ var DEFAULT_STATE_VALUE = "default";
38
+ var DEFAULT_BLOCK_STYLE_STATE = {
39
+ viewport: DEFAULT_STATE_VALUE,
40
+ pseudo: DEFAULT_STATE_VALUE
41
+ };
42
+ var BlockStyleStateContext = (0, import_element.createContext)(DEFAULT_BLOCK_STYLE_STATE);
43
+ var BlockStyleStateProvider = BlockStyleStateContext.Provider;
44
+ function useBlockStyleState() {
45
+ return (0, import_element.useContext)(BlockStyleStateContext);
46
+ }
47
+ function hasViewportBlockStyleState(selectedState) {
48
+ return !!selectedState?.viewport && selectedState.viewport !== DEFAULT_STATE_VALUE;
49
+ }
50
+ function hasPseudoBlockStyleState(selectedState) {
51
+ return !!selectedState?.pseudo && selectedState.pseudo !== DEFAULT_STATE_VALUE;
52
+ }
53
+ function isDefaultBlockStyleState(selectedState) {
54
+ return !hasViewportBlockStyleState(selectedState) && !hasPseudoBlockStyleState(selectedState);
55
+ }
56
+ function getStyleStatePath(selectedState) {
57
+ if (isDefaultBlockStyleState(selectedState)) {
58
+ return [];
59
+ }
60
+ return [selectedState.viewport, selectedState.pseudo].filter(
61
+ (state) => state && state !== DEFAULT_STATE_VALUE
62
+ );
63
+ }
64
+ function getStyleForState(style, selectedState) {
65
+ const path = getStyleStatePath(selectedState);
66
+ if (!path.length) {
67
+ return style;
68
+ }
69
+ return (0, import_object.getValueFromObjectPath)(style, path);
70
+ }
71
+ function setStyleForState(style, selectedState, newStyle) {
72
+ const path = getStyleStatePath(selectedState);
73
+ if (!path.length) {
74
+ return (0, import_utils.cleanEmptyObject)(newStyle);
75
+ }
76
+ return (0, import_utils.cleanEmptyObject)((0, import_object.setImmutably)(style, path, newStyle));
77
+ }
78
+ function scopeResetAllFilterToState(selectedState, resetAllFilter) {
79
+ if (!resetAllFilter || isDefaultBlockStyleState(selectedState)) {
80
+ return resetAllFilter;
81
+ }
82
+ return (attributes) => {
83
+ const existingStateStyle = getStyleForState(attributes?.style, selectedState) || {};
84
+ const updatedStateAttributes = resetAllFilter({
85
+ style: existingStateStyle
86
+ });
87
+ const updatedStateStyle = updatedStateAttributes && typeof updatedStateAttributes === "object" && !Array.isArray(updatedStateAttributes) && Object.prototype.hasOwnProperty.call(
88
+ updatedStateAttributes,
89
+ "style"
90
+ ) ? updatedStateAttributes.style : updatedStateAttributes;
91
+ return {
92
+ style: setStyleForState(
93
+ attributes?.style,
94
+ selectedState,
95
+ updatedStateStyle
96
+ )
97
+ };
98
+ };
99
+ }
100
+ // Annotate the CommonJS export names for ESM import in node:
101
+ 0 && (module.exports = {
102
+ BlockStyleStateProvider,
103
+ DEFAULT_BLOCK_STYLE_STATE,
104
+ getStyleForState,
105
+ hasPseudoBlockStyleState,
106
+ hasViewportBlockStyleState,
107
+ isDefaultBlockStyleState,
108
+ scopeResetAllFilterToState,
109
+ setStyleForState,
110
+ useBlockStyleState
111
+ });
112
+ //# sourceMappingURL=block-style-state.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/hooks/block-style-state.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { cleanEmptyObject } from './utils';\nimport { getValueFromObjectPath, setImmutably } from '../utils/object';\n\nconst DEFAULT_STATE_VALUE = 'default';\n\nexport const DEFAULT_BLOCK_STYLE_STATE = {\n\tviewport: DEFAULT_STATE_VALUE,\n\tpseudo: DEFAULT_STATE_VALUE,\n};\n\nconst BlockStyleStateContext = createContext( DEFAULT_BLOCK_STYLE_STATE );\n\nexport const BlockStyleStateProvider = BlockStyleStateContext.Provider;\n\nexport function useBlockStyleState() {\n\treturn useContext( BlockStyleStateContext );\n}\n\n/**\n * Returns true when a viewport style state is selected.\n *\n * @param {Object} selectedState Selected block style state.\n * @return {boolean} Whether a viewport state is selected.\n */\nexport function hasViewportBlockStyleState( selectedState ) {\n\treturn (\n\t\t!! selectedState?.viewport &&\n\t\tselectedState.viewport !== DEFAULT_STATE_VALUE\n\t);\n}\n\n/**\n * Returns true when a pseudo style state is selected.\n *\n * @param {Object} selectedState Selected block style state.\n * @return {boolean} Whether a pseudo state is selected.\n */\nexport function hasPseudoBlockStyleState( selectedState ) {\n\treturn (\n\t\t!! selectedState?.pseudo && selectedState.pseudo !== DEFAULT_STATE_VALUE\n\t);\n}\n\n/**\n * Returns true when the default style state is selected.\n *\n * @param {Object} selectedState Selected block style state.\n * @return {boolean} Whether the default style state is selected.\n */\nexport function isDefaultBlockStyleState( selectedState ) {\n\treturn (\n\t\t! hasViewportBlockStyleState( selectedState ) &&\n\t\t! hasPseudoBlockStyleState( selectedState )\n\t);\n}\n\n/**\n * Returns the style object path for the selected block style state.\n *\n * @param {Object} selectedState Selected block style state.\n * @return {string[]} Object path for the selected state styles.\n */\nfunction getStyleStatePath( selectedState ) {\n\tif ( isDefaultBlockStyleState( selectedState ) ) {\n\t\treturn [];\n\t}\n\n\treturn [ selectedState.viewport, selectedState.pseudo ].filter(\n\t\t( state ) => state && state !== DEFAULT_STATE_VALUE\n\t);\n}\n\nexport function getStyleForState( style, selectedState ) {\n\tconst path = getStyleStatePath( selectedState );\n\tif ( ! path.length ) {\n\t\treturn style;\n\t}\n\treturn getValueFromObjectPath( style, path );\n}\n\nexport function setStyleForState( style, selectedState, newStyle ) {\n\tconst path = getStyleStatePath( selectedState );\n\tif ( ! path.length ) {\n\t\treturn cleanEmptyObject( newStyle );\n\t}\n\treturn cleanEmptyObject( setImmutably( style, path, newStyle ) );\n}\n\nexport function scopeResetAllFilterToState( selectedState, resetAllFilter ) {\n\tif ( ! resetAllFilter || isDefaultBlockStyleState( selectedState ) ) {\n\t\treturn resetAllFilter;\n\t}\n\n\treturn ( attributes ) => {\n\t\tconst existingStateStyle =\n\t\t\tgetStyleForState( attributes?.style, selectedState ) || {};\n\t\tconst updatedStateAttributes = resetAllFilter( {\n\t\t\tstyle: existingStateStyle,\n\t\t} );\n\t\tconst updatedStateStyle =\n\t\t\tupdatedStateAttributes &&\n\t\t\ttypeof updatedStateAttributes === 'object' &&\n\t\t\t! Array.isArray( updatedStateAttributes ) &&\n\t\t\tObject.prototype.hasOwnProperty.call(\n\t\t\t\tupdatedStateAttributes,\n\t\t\t\t'style'\n\t\t\t)\n\t\t\t\t? updatedStateAttributes.style\n\t\t\t\t: updatedStateAttributes;\n\n\t\treturn {\n\t\t\tstyle: setStyleForState(\n\t\t\t\tattributes?.style,\n\t\t\t\tselectedState,\n\t\t\t\tupdatedStateStyle\n\t\t\t),\n\t\t};\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA0C;AAK1C,mBAAiC;AACjC,oBAAqD;AAErD,IAAM,sBAAsB;AAErB,IAAM,4BAA4B;AAAA,EACxC,UAAU;AAAA,EACV,QAAQ;AACT;AAEA,IAAM,6BAAyB,8BAAe,yBAA0B;AAEjE,IAAM,0BAA0B,uBAAuB;AAEvD,SAAS,qBAAqB;AACpC,aAAO,2BAAY,sBAAuB;AAC3C;AAQO,SAAS,2BAA4B,eAAgB;AAC3D,SACC,CAAC,CAAE,eAAe,YAClB,cAAc,aAAa;AAE7B;AAQO,SAAS,yBAA0B,eAAgB;AACzD,SACC,CAAC,CAAE,eAAe,UAAU,cAAc,WAAW;AAEvD;AAQO,SAAS,yBAA0B,eAAgB;AACzD,SACC,CAAE,2BAA4B,aAAc,KAC5C,CAAE,yBAA0B,aAAc;AAE5C;AAQA,SAAS,kBAAmB,eAAgB;AAC3C,MAAK,yBAA0B,aAAc,GAAI;AAChD,WAAO,CAAC;AAAA,EACT;AAEA,SAAO,CAAE,cAAc,UAAU,cAAc,MAAO,EAAE;AAAA,IACvD,CAAE,UAAW,SAAS,UAAU;AAAA,EACjC;AACD;AAEO,SAAS,iBAAkB,OAAO,eAAgB;AACxD,QAAM,OAAO,kBAAmB,aAAc;AAC9C,MAAK,CAAE,KAAK,QAAS;AACpB,WAAO;AAAA,EACR;AACA,aAAO,sCAAwB,OAAO,IAAK;AAC5C;AAEO,SAAS,iBAAkB,OAAO,eAAe,UAAW;AAClE,QAAM,OAAO,kBAAmB,aAAc;AAC9C,MAAK,CAAE,KAAK,QAAS;AACpB,eAAO,+BAAkB,QAAS;AAAA,EACnC;AACA,aAAO,mCAAkB,4BAAc,OAAO,MAAM,QAAS,CAAE;AAChE;AAEO,SAAS,2BAA4B,eAAe,gBAAiB;AAC3E,MAAK,CAAE,kBAAkB,yBAA0B,aAAc,GAAI;AACpE,WAAO;AAAA,EACR;AAEA,SAAO,CAAE,eAAgB;AACxB,UAAM,qBACL,iBAAkB,YAAY,OAAO,aAAc,KAAK,CAAC;AAC1D,UAAM,yBAAyB,eAAgB;AAAA,MAC9C,OAAO;AAAA,IACR,CAAE;AACF,UAAM,oBACL,0BACA,OAAO,2BAA2B,YAClC,CAAE,MAAM,QAAS,sBAAuB,KACxC,OAAO,UAAU,eAAe;AAAA,MAC/B;AAAA,MACA;AAAA,IACD,IACG,uBAAuB,QACvB;AAEJ,WAAO;AAAA,MACN,OAAO;AAAA,QACN,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -48,13 +48,14 @@ var import_components = require("@wordpress/components");
48
48
  var import_element = require("@wordpress/element");
49
49
  var import_hooks = require("@wordpress/hooks");
50
50
  var import_data = require("@wordpress/data");
51
+ var import_i18n = require("@wordpress/i18n");
51
52
  var import_colors = require("../components/colors/index.cjs");
52
53
  var import_inspector_controls = __toESM(require("../components/inspector-controls/index.cjs"));
53
54
  var import_use_multiple_origin_colors_and_gradients = __toESM(require("../components/colors-gradients/use-multiple-origin-colors-and-gradients.cjs"));
54
55
  var import_utils = require("./utils.cjs");
55
56
  var import_global_styles = require("../components/global-styles/index.cjs");
56
57
  var import_store = require("../store/index.cjs");
57
- var import_i18n = require("@wordpress/i18n");
58
+ var import_block_style_state = require("./block-style-state.cjs");
58
59
  var import_jsx_runtime = require("react/jsx-runtime");
59
60
  var BORDER_SUPPORT_KEY = "__experimentalBorder";
60
61
  var SHADOW_SUPPORT_KEY = "shadow";
@@ -145,6 +146,7 @@ function BordersInspectorControl({ label, children, resetAllFilter }) {
145
146
  );
146
147
  }
147
148
  function BorderPanel({ clientId, name, setAttributes, settings }) {
149
+ const selectedState = (0, import_block_style_state.useBlockStyleState)();
148
150
  const isEnabled = (0, import_global_styles.useHasBorderPanel)(settings);
149
151
  const { style, borderColor } = (0, import_data.useSelect)(
150
152
  (select) => {
@@ -156,10 +158,18 @@ function BorderPanel({ clientId, name, setAttributes, settings }) {
156
158
  },
157
159
  [clientId, isEnabled]
158
160
  );
161
+ const isStateSelected = !(0, import_block_style_state.isDefaultBlockStyleState)(selectedState);
159
162
  const value = (0, import_element.useMemo)(() => {
163
+ if (isStateSelected) {
164
+ return (0, import_block_style_state.getStyleForState)(style, selectedState);
165
+ }
160
166
  return attributesToStyle({ style, borderColor });
161
- }, [style, borderColor]);
162
- const onChange = (newStyle) => {
167
+ }, [isStateSelected, selectedState, style, borderColor]);
168
+ const onChange = isStateSelected ? (newStyle) => {
169
+ setAttributes({
170
+ style: (0, import_block_style_state.setStyleForState)(style, selectedState, newStyle)
171
+ });
172
+ } : (newStyle) => {
163
173
  setAttributes(styleToAttributes(newStyle));
164
174
  };
165
175
  if (!isEnabled) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/border.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { hasBlockSupport, getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\nimport { Platform, useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tcleanEmptyObject,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport {\n\tuseHasBorderPanel,\n\tuseHasBorderPanelControls,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\nimport { store as blockEditorStore } from '../store';\nimport { __ } from '@wordpress/i18n';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\nexport const SHADOW_SUPPORT_KEY = 'shadow';\n\nconst getColorByProperty = ( colors, property, value ) => {\n\tlet matchedColor;\n\n\tcolors.some( ( origin ) =>\n\t\torigin.colors.some( ( color ) => {\n\t\t\tif ( color[ property ] === value ) {\n\t\t\t\tmatchedColor = color;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} )\n\t);\n\n\treturn matchedColor;\n};\n\nexport const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {\n\t// Search each origin (default, theme, or user) for matching color by name.\n\tif ( namedColor ) {\n\t\tconst colorObject = getColorByProperty( colors, 'slug', namedColor );\n\t\tif ( colorObject ) {\n\t\t\treturn colorObject;\n\t\t}\n\t}\n\n\t// Skip if no custom color or matching named color.\n\tif ( ! customColor ) {\n\t\treturn { color: undefined };\n\t}\n\n\t// Attempt to find color via custom color value or build new object.\n\tconst colorObject = getColorByProperty( colors, 'color', customColor );\n\treturn colorObject ? colorObject : { color: customColor };\n};\n\nfunction getColorSlugFromVariable( value ) {\n\tconst namedColor = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( namedColor && namedColor[ 1 ] ) {\n\t\treturn namedColor[ 1 ];\n\t}\n\treturn null;\n}\n\nfunction styleToAttributes( style ) {\n\tif ( hasSplitBorders( style?.border ) ) {\n\t\treturn {\n\t\t\tstyle,\n\t\t\tborderColor: undefined,\n\t\t};\n\t}\n\n\tconst borderColorValue = style?.border?.color;\n\tconst borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )\n\t\t? borderColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.border = {\n\t\t...updatedStyle.border,\n\t\tcolor: borderColorSlug ? undefined : borderColorValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tborderColor: borderColorSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\tif ( hasSplitBorders( attributes.style?.border ) ) {\n\t\treturn attributes.style;\n\t}\n\treturn {\n\t\t...attributes.style,\n\t\tborder: {\n\t\t\t...attributes.style?.border,\n\t\t\tcolor: attributes.borderColor\n\t\t\t\t? 'var:preset|color|' + attributes.borderColor\n\t\t\t\t: attributes.style?.border?.color,\n\t\t},\n\t};\n}\n\nfunction BordersInspectorControl( { label, children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"border\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t\tlabel={ label }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BorderPanel( { clientId, name, setAttributes, settings } ) {\n\tconst isEnabled = useHasBorderPanel( settings );\n\tconst { style, borderColor } = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when disabled\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst { style: _style, borderColor: _borderColor } =\n\t\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId ) || {};\n\t\t\treturn { style: _style, borderColor: _borderColor };\n\t\t},\n\t\t[ clientId, isEnabled ]\n\t);\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( { style, borderColor } );\n\t}, [ style, borderColor ] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = {\n\t\t...getBlockSupport( name, [\n\t\t\tBORDER_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\n\t\t...getBlockSupport( name, [\n\t\t\tSHADOW_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\n\t};\n\n\treturn (\n\t\t<StylesBorderPanel\n\t\t\tas={ BordersInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Determine whether there is block support for shadow properties.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasShadowSupport( blockName ) {\n\treturn hasBlockSupport( blockName, SHADOW_SUPPORT_KEY );\n}\n\nexport function useBorderPanelLabel( {\n\tblockName,\n\thasBorderControl,\n\thasShadowControl,\n} = {} ) {\n\tconst settings = useBlockSettings( blockName );\n\tconst controls = useHasBorderPanelControls( settings );\n\n\tif ( ! hasBorderControl && ! hasShadowControl && blockName ) {\n\t\thasBorderControl =\n\t\t\tcontrols?.hasBorderColor ||\n\t\t\tcontrols?.hasBorderStyle ||\n\t\t\tcontrols?.hasBorderWidth ||\n\t\t\tcontrols?.hasBorderRadius;\n\t\thasShadowControl = controls?.hasShadow;\n\t}\n\n\tif ( hasBorderControl && hasShadowControl ) {\n\t\treturn __( 'Border & Shadow' );\n\t}\n\n\tif ( hasShadowControl ) {\n\t\treturn __( 'Shadow' );\n\t}\n\n\treturn __( 'Border' );\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object|string} blockNameOrType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockNameOrType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockNameOrType, 'color' ) ||\n\t\tshouldSkipSerialization( blockNameOrType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = clsx( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn clsx( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\nfunction useBlockProps( { name, borderColor, style } ) {\n\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\tif (\n\t\t! hasBorderSupport( name, 'color' ) ||\n\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn {};\n\t}\n\n\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: borderColor,\n\t} );\n\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t} );\n\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t} );\n\n\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.bottom?.color ),\n\t} );\n\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t} );\n\n\tconst extraStyles = {\n\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t};\n\n\treturn addSaveProps(\n\t\t{ style: cleanEmptyObject( extraStyles ) || {} },\n\t\tname,\n\t\t{ borderColor, style }\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'borderColor', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBorderSupport( name, 'color' );\n\t},\n};\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAAiD;AACjD,wBAAiE;AACjE,qBAA+C;AAC/C,mBAA0B;AAC1B,kBAA0B;AAK1B,oBAAkC;AAClC,gCAA8B;AAC9B,sDAAgD;AAChD,mBAIO;AACP,2BAIO;AACP,mBAA0C;AAC1C,kBAAmB;AAqGjB;AAnGK,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAElC,IAAM,qBAAqB,CAAE,QAAQ,UAAU,UAAW;AACzD,MAAI;AAEJ,SAAO;AAAA,IAAM,CAAE,WACd,OAAO,OAAO,KAAM,CAAE,UAAW;AAChC,UAAK,MAAO,QAAS,MAAM,OAAQ;AAClC,uBAAe;AACf,eAAO;AAAA,MACR;AAEA,aAAO;AAAA,IACR,C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AAAA,IACxD;AAAA,IACA,YAAY,yBAA0B,OAAO,QAAQ,OAAO,KAAM;AAAA,EACnE,CAAE;AAEF,QAAM,EAAE,OAAO,kBAAkB,IAAI,oBAAqB;AAAA,IACzD;AAAA,IACA,YAAY,yBAA0B,OAAO,QAAQ,QAAQ,KAAM;AAAA,EACpE,CAAE;AACF,QAAM,EAAE,OAAO,gBAAgB,IAAI,oBAAqB;AAAA,IACvD;AAAA,IACA,YAAY,yBAA0B,OAAO,QAAQ,MAAM,KAAM;AAAA,EAClE,CAAE;AAEF,QAAM,cAAc;AAAA,IACnB,gBAAgB,kBAAkB;AAAA,IAClC,kBAAkB,oBAAoB;AAAA,IACtC,mBAAmB,qBAAqB;AAAA,IACxC,iBAAiB,mBAAmB;AAAA,EACrC;AAEA,SAAO;AAAA,IACN,EAAE,WAAO,+BAAkB,WAAY,KAAK,CAAC,EAAE;AAAA,IAC/C;AAAA,IACA,EAAE,aAAa,MAAM;AAAA,EACtB;AACD;AAEA,IAAO,iBAAQ;AAAA,EACd;AAAA,EACA;AAAA,EACA,eAAe,CAAE,eAAe,OAAQ;AAAA,EACxC,WAAY,MAAO;AAClB,WAAO,iBAAkB,MAAM,OAAQ;AAAA,EACxC;AACD;AAAA,IAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { hasBlockSupport, getBlockSupport } from '@wordpress/blocks';\nimport { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';\nimport { Platform, useCallback, useMemo } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getColorClassName } from '../components/colors';\nimport InspectorControls from '../components/inspector-controls';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tcleanEmptyObject,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport {\n\tuseHasBorderPanel,\n\tuseHasBorderPanelControls,\n\tBorderPanel as StylesBorderPanel,\n} from '../components/global-styles';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\n\nexport const BORDER_SUPPORT_KEY = '__experimentalBorder';\nexport const SHADOW_SUPPORT_KEY = 'shadow';\n\nconst getColorByProperty = ( colors, property, value ) => {\n\tlet matchedColor;\n\n\tcolors.some( ( origin ) =>\n\t\torigin.colors.some( ( color ) => {\n\t\t\tif ( color[ property ] === value ) {\n\t\t\t\tmatchedColor = color;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t} )\n\t);\n\n\treturn matchedColor;\n};\n\nexport const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {\n\t// Search each origin (default, theme, or user) for matching color by name.\n\tif ( namedColor ) {\n\t\tconst colorObject = getColorByProperty( colors, 'slug', namedColor );\n\t\tif ( colorObject ) {\n\t\t\treturn colorObject;\n\t\t}\n\t}\n\n\t// Skip if no custom color or matching named color.\n\tif ( ! customColor ) {\n\t\treturn { color: undefined };\n\t}\n\n\t// Attempt to find color via custom color value or build new object.\n\tconst colorObject = getColorByProperty( colors, 'color', customColor );\n\treturn colorObject ? colorObject : { color: customColor };\n};\n\nfunction getColorSlugFromVariable( value ) {\n\tconst namedColor = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( namedColor && namedColor[ 1 ] ) {\n\t\treturn namedColor[ 1 ];\n\t}\n\treturn null;\n}\n\nfunction styleToAttributes( style ) {\n\tif ( hasSplitBorders( style?.border ) ) {\n\t\treturn {\n\t\t\tstyle,\n\t\t\tborderColor: undefined,\n\t\t};\n\t}\n\n\tconst borderColorValue = style?.border?.color;\n\tconst borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )\n\t\t? borderColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.border = {\n\t\t...updatedStyle.border,\n\t\tcolor: borderColorSlug ? undefined : borderColorValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tborderColor: borderColorSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\tif ( hasSplitBorders( attributes.style?.border ) ) {\n\t\treturn attributes.style;\n\t}\n\treturn {\n\t\t...attributes.style,\n\t\tborder: {\n\t\t\t...attributes.style?.border,\n\t\t\tcolor: attributes.borderColor\n\t\t\t\t? 'var:preset|color|' + attributes.borderColor\n\t\t\t\t: attributes.style?.border?.color,\n\t\t},\n\t};\n}\n\nfunction BordersInspectorControl( { label, children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"border\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t\tlabel={ label }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BorderPanel( { clientId, name, setAttributes, settings } ) {\n\tconst selectedState = useBlockStyleState();\n\tconst isEnabled = useHasBorderPanel( settings );\n\tconst { style, borderColor } = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when disabled\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst { style: _style, borderColor: _borderColor } =\n\t\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId ) || {};\n\t\t\treturn { style: _style, borderColor: _borderColor };\n\t\t},\n\t\t[ clientId, isEnabled ]\n\t);\n\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\n\tconst value = useMemo( () => {\n\t\tif ( isStateSelected ) {\n\t\t\treturn getStyleForState( style, selectedState );\n\t\t}\n\t\treturn attributesToStyle( { style, borderColor } );\n\t}, [ isStateSelected, selectedState, style, borderColor ] );\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\tsetAttributes( styleToAttributes( newStyle ) );\n\t\t };\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = {\n\t\t...getBlockSupport( name, [\n\t\t\tBORDER_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\n\t\t...getBlockSupport( name, [\n\t\t\tSHADOW_SUPPORT_KEY,\n\t\t\t'__experimentalDefaultControls',\n\t\t] ),\n\t};\n\n\treturn (\n\t\t<StylesBorderPanel\n\t\t\tas={ BordersInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\n/**\n * Determine whether there is block support for border properties.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Border feature to check support for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBorderSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BORDER_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.color ||\n\t\t\tsupport?.radius ||\n\t\t\tsupport?.width ||\n\t\t\tsupport?.style\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Determine whether there is block support for shadow properties.\n *\n * @param {string} blockName Block name.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasShadowSupport( blockName ) {\n\treturn hasBlockSupport( blockName, SHADOW_SUPPORT_KEY );\n}\n\nexport function useBorderPanelLabel( {\n\tblockName,\n\thasBorderControl,\n\thasShadowControl,\n} = {} ) {\n\tconst settings = useBlockSettings( blockName );\n\tconst controls = useHasBorderPanelControls( settings );\n\n\tif ( ! hasBorderControl && ! hasShadowControl && blockName ) {\n\t\thasBorderControl =\n\t\t\tcontrols?.hasBorderColor ||\n\t\t\tcontrols?.hasBorderStyle ||\n\t\t\tcontrols?.hasBorderWidth ||\n\t\t\tcontrols?.hasBorderRadius;\n\t\thasShadowControl = controls?.hasShadow;\n\t}\n\n\tif ( hasBorderControl && hasShadowControl ) {\n\t\treturn __( 'Border & Shadow' );\n\t}\n\n\tif ( hasShadowControl ) {\n\t\treturn __( 'Shadow' );\n\t}\n\n\treturn __( 'Border' );\n}\n\n/**\n * Returns a new style object where the specified border attribute has been\n * removed.\n *\n * @param {Object} style Styles from block attributes.\n * @param {string} attribute The border style attribute to clear.\n *\n * @return {Object} Style object with the specified attribute removed.\n */\nexport function removeBorderAttribute( style, attribute ) {\n\treturn cleanEmptyObject( {\n\t\t...style,\n\t\tborder: {\n\t\t\t...style?.border,\n\t\t\t[ attribute ]: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object|string} blockNameOrType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockNameOrType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockNameOrType, 'color' ) ||\n\t\tshouldSkipSerialization( blockNameOrType, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst borderClasses = getBorderClasses( attributes );\n\tconst newClassName = clsx( props.className, borderClasses );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Generates a CSS class name consisting of all the applicable border color\n * classes given the current block attributes.\n *\n * @param {Object} attributes Block's attributes.\n *\n * @return {string} CSS class name.\n */\nexport function getBorderClasses( attributes ) {\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\treturn clsx( {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n}\n\nfunction useBlockProps( { name, borderColor, style } ) {\n\tconst { colors } = useMultipleOriginColorsAndGradients();\n\n\tif (\n\t\t! hasBorderSupport( name, 'color' ) ||\n\t\tshouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )\n\t) {\n\t\treturn {};\n\t}\n\n\tconst { color: borderColorValue } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: borderColor,\n\t} );\n\tconst { color: borderTopColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.top?.color ),\n\t} );\n\tconst { color: borderRightColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.right?.color ),\n\t} );\n\n\tconst { color: borderBottomColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.bottom?.color ),\n\t} );\n\tconst { color: borderLeftColor } = getMultiOriginColor( {\n\t\tcolors,\n\t\tnamedColor: getColorSlugFromVariable( style?.border?.left?.color ),\n\t} );\n\n\tconst extraStyles = {\n\t\tborderTopColor: borderTopColor || borderColorValue,\n\t\tborderRightColor: borderRightColor || borderColorValue,\n\t\tborderBottomColor: borderBottomColor || borderColorValue,\n\t\tborderLeftColor: borderLeftColor || borderColorValue,\n\t};\n\n\treturn addSaveProps(\n\t\t{ style: cleanEmptyObject( extraStyles ) || {} },\n\t\tname,\n\t\t{ borderColor, style }\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'borderColor', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBorderSupport( name, 'color' );\n\t},\n};\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAAiD;AACjD,wBAAiE;AACjE,qBAA+C;AAC/C,mBAA0B;AAC1B,kBAA0B;AAC1B,kBAAmB;AAKnB,oBAAkC;AAClC,gCAA8B;AAC9B,sDAAgD;AAChD,mBAIO;AACP,2BAIO;AACP,mBAA0C;AAC1C,+BAKO;AAqGL;AAnGK,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAElC,IAAM,qBAAqB,CAAE,QAAQ,UAAU,UAAW;AACzD,MAAI;AAEJ,SAAO;AAAA,IAAM,CAAE,WACd,OAAO,OAAO,KAAM,CAAE,UAAW;AAChC,UAAK,MAAO,QAAS,MAAM,OAAQ;AAClC,uBAAe;AACf,eAAO;AAAA,MACR;AAEA,aAAO;AAAA,IACR,CAAE;A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AM,EAAE,OAAO,iBAAiB,IAAI,oBAAqB;AAAA,IACxD;AAAA,IACA,YAAY;AAAA,EACb,CAAE;AACF,QAAM,EAAE,OAAO,eAAe,IAAI,oBAAqB;AAAA,IACtD;AAAA,IACA,YAAY,yBAA0B,OAAO,QAAQ,KAAK,KAAM;AAAA,EACjE,CAAE;AACF,QAAM,EAAE,OAAO,iBAAiB,IAAI,oBAAqB;AAAA,IACxD;AAAA,IACA,YAAY,yBAA0B,OAAO,QAAQ,OAAO,KAAM;AAAA,EACnE,CAAE;AAEF,QAAM,EAAE,OAAO,kBAAkB,IAAI,oBAAqB;AAAA,IACzD;AAAA,IACA,YAAY,yBAA0B,OAAO,QAAQ,QAAQ,KAAM;AAAA,EACpE,CAAE;AACF,QAAM,EAAE,OAAO,gBAAgB,IAAI,oBAAqB;AAAA,IACvD;AAAA,IACA,YAAY,yBAA0B,OAAO,QAAQ,MAAM,KAAM;AAAA,EAClE,CAAE;AAEF,QAAM,cAAc;AAAA,IACnB,gBAAgB,kBAAkB;AAAA,IAClC,kBAAkB,oBAAoB;AAAA,IACtC,mBAAmB,qBAAqB;AAAA,IACxC,iBAAiB,mBAAmB;AAAA,EACrC;AAEA,SAAO;AAAA,IACN,EAAE,WAAO,+BAAkB,WAAY,KAAK,CAAC,EAAE;AAAA,IAC/C;AAAA,IACA,EAAE,aAAa,MAAM;AAAA,EACtB;AACD;AAEA,IAAO,iBAAQ;AAAA,EACd;AAAA,EACA;AAAA,EACA,eAAe,CAAE,eAAe,OAAQ;AAAA,EACxC,WAAY,MAAO;AAClB,WAAO,iBAAkB,MAAM,OAAQ;AAAA,EACxC;AACD;AAAA,IAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
6
6
  "names": ["colorObject", "hasSplitBorders", "InspectorControls", "blockEditorStore", "StylesBorderPanel", "clsx", "useMultipleOriginColorsAndGradients"]
7
7
  }