@wordpress/block-editor 10.4.0 → 10.5.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 (254) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +0 -1
  3. package/build/components/block-lock/menu-item.js +1 -1
  4. package/build/components/block-lock/menu-item.js.map +1 -1
  5. package/build/components/block-lock/modal.js +16 -9
  6. package/build/components/block-lock/modal.js.map +1 -1
  7. package/build/components/block-styles/utils.js +3 -3
  8. package/build/components/block-styles/utils.js.map +1 -1
  9. package/build/components/block-switcher/index.js +19 -4
  10. package/build/components/block-switcher/index.js.map +1 -1
  11. package/build/components/block-tools/selected-block-popover.js +27 -4
  12. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  13. package/build/components/colors/with-colors.js +4 -3
  14. package/build/components/colors/with-colors.js.map +1 -1
  15. package/build/components/font-sizes/fluid-utils.js +24 -40
  16. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  17. package/build/components/font-sizes/with-font-sizes.js +7 -5
  18. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  19. package/build/components/index.js +9 -0
  20. package/build/components/index.js.map +1 -1
  21. package/build/components/inner-blocks/index.js +5 -3
  22. package/build/components/inner-blocks/index.js.map +1 -1
  23. package/build/components/inserter/reusable-blocks-tab.js +4 -1
  24. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  25. package/build/components/link-control/index.js +18 -34
  26. package/build/components/link-control/index.js.map +1 -1
  27. package/build/components/link-control/search-input.js +1 -1
  28. package/build/components/link-control/search-input.js.map +1 -1
  29. package/build/components/link-control/use-internal-input-value.js +26 -0
  30. package/build/components/link-control/use-internal-input-value.js.map +1 -0
  31. package/build/components/list-view/block.js +5 -3
  32. package/build/components/list-view/block.js.map +1 -1
  33. package/build/components/list-view/branch.js +9 -3
  34. package/build/components/list-view/branch.js.map +1 -1
  35. package/build/components/off-canvas-editor/block-contents.js +100 -0
  36. package/build/components/off-canvas-editor/block-contents.js.map +1 -0
  37. package/build/components/off-canvas-editor/block-select-button.js +119 -0
  38. package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
  39. package/build/components/off-canvas-editor/block.js +292 -0
  40. package/build/components/off-canvas-editor/block.js.map +1 -0
  41. package/build/components/off-canvas-editor/branch.js +181 -0
  42. package/build/components/off-canvas-editor/branch.js.map +1 -0
  43. package/build/components/off-canvas-editor/context.js +19 -0
  44. package/build/components/off-canvas-editor/context.js.map +1 -0
  45. package/build/components/off-canvas-editor/drop-indicator.js +118 -0
  46. package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
  47. package/build/components/off-canvas-editor/expander.js +41 -0
  48. package/build/components/off-canvas-editor/expander.js.map +1 -0
  49. package/build/components/off-canvas-editor/index.js +204 -0
  50. package/build/components/off-canvas-editor/index.js.map +1 -0
  51. package/build/components/off-canvas-editor/leaf.js +60 -0
  52. package/build/components/off-canvas-editor/leaf.js.map +1 -0
  53. package/build/components/off-canvas-editor/use-block-selection.js +139 -0
  54. package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
  55. package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
  56. package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  57. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
  58. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  59. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
  60. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  61. package/build/components/off-canvas-editor/utils.js +60 -0
  62. package/build/components/off-canvas-editor/utils.js.map +1 -0
  63. package/build/components/url-popover/index.js +31 -2
  64. package/build/components/url-popover/index.js.map +1 -1
  65. package/build/components/use-setting/index.js +1 -1
  66. package/build/components/use-setting/index.js.map +1 -1
  67. package/build/hooks/color-panel.js +17 -1
  68. package/build/hooks/color-panel.js.map +1 -1
  69. package/build/hooks/color.js +1 -1
  70. package/build/hooks/color.js.map +1 -1
  71. package/build/hooks/content-lock-ui.js +13 -6
  72. package/build/hooks/content-lock-ui.js.map +1 -1
  73. package/build/hooks/dimensions.js +44 -13
  74. package/build/hooks/dimensions.js.map +1 -1
  75. package/build/hooks/layout.js +2 -2
  76. package/build/hooks/layout.js.map +1 -1
  77. package/build/hooks/margin.js +4 -2
  78. package/build/hooks/margin.js.map +1 -1
  79. package/build/hooks/min-height.js +145 -0
  80. package/build/hooks/min-height.js.map +1 -0
  81. package/build/hooks/padding.js +4 -2
  82. package/build/hooks/padding.js.map +1 -1
  83. package/build/hooks/style.js +3 -2
  84. package/build/hooks/style.js.map +1 -1
  85. package/build/layouts/flex.js +22 -21
  86. package/build/layouts/flex.js.map +1 -1
  87. package/build/store/actions.js +26 -0
  88. package/build/store/actions.js.map +1 -1
  89. package/build/store/reducer.js +46 -14
  90. package/build/store/reducer.js.map +1 -1
  91. package/build/store/selectors.js +16 -2
  92. package/build/store/selectors.js.map +1 -1
  93. package/build-module/components/block-lock/menu-item.js +2 -2
  94. package/build-module/components/block-lock/menu-item.js.map +1 -1
  95. package/build-module/components/block-lock/modal.js +17 -10
  96. package/build-module/components/block-lock/modal.js.map +1 -1
  97. package/build-module/components/block-styles/utils.js +3 -3
  98. package/build-module/components/block-styles/utils.js.map +1 -1
  99. package/build-module/components/block-switcher/index.js +19 -4
  100. package/build-module/components/block-switcher/index.js.map +1 -1
  101. package/build-module/components/block-tools/selected-block-popover.js +27 -5
  102. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  103. package/build-module/components/colors/with-colors.js +5 -4
  104. package/build-module/components/colors/with-colors.js.map +1 -1
  105. package/build-module/components/font-sizes/fluid-utils.js +24 -40
  106. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  107. package/build-module/components/font-sizes/with-font-sizes.js +8 -6
  108. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  109. package/build-module/components/index.js +1 -0
  110. package/build-module/components/index.js.map +1 -1
  111. package/build-module/components/inner-blocks/index.js +5 -3
  112. package/build-module/components/inner-blocks/index.js.map +1 -1
  113. package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
  114. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  115. package/build-module/components/link-control/index.js +17 -34
  116. package/build-module/components/link-control/index.js.map +1 -1
  117. package/build-module/components/link-control/search-input.js +1 -1
  118. package/build-module/components/link-control/search-input.js.map +1 -1
  119. package/build-module/components/link-control/use-internal-input-value.js +18 -0
  120. package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
  121. package/build-module/components/list-view/block.js +5 -3
  122. package/build-module/components/list-view/block.js.map +1 -1
  123. package/build-module/components/list-view/branch.js +9 -3
  124. package/build-module/components/list-view/branch.js.map +1 -1
  125. package/build-module/components/off-canvas-editor/block-contents.js +85 -0
  126. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
  127. package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
  128. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
  129. package/build-module/components/off-canvas-editor/block.js +268 -0
  130. package/build-module/components/off-canvas-editor/block.js.map +1 -0
  131. package/build-module/components/off-canvas-editor/branch.js +165 -0
  132. package/build-module/components/off-canvas-editor/branch.js.map +1 -0
  133. package/build-module/components/off-canvas-editor/context.js +7 -0
  134. package/build-module/components/off-canvas-editor/context.js.map +1 -0
  135. package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
  136. package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
  137. package/build-module/components/off-canvas-editor/expander.js +32 -0
  138. package/build-module/components/off-canvas-editor/expander.js.map +1 -0
  139. package/build-module/components/off-canvas-editor/index.js +181 -0
  140. package/build-module/components/off-canvas-editor/index.js.map +1 -0
  141. package/build-module/components/off-canvas-editor/leaf.js +45 -0
  142. package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
  143. package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
  144. package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
  145. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
  146. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  147. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
  148. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  149. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
  150. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  151. package/build-module/components/off-canvas-editor/utils.js +44 -0
  152. package/build-module/components/off-canvas-editor/utils.js.map +1 -0
  153. package/build-module/components/url-popover/index.js +30 -3
  154. package/build-module/components/url-popover/index.js.map +1 -1
  155. package/build-module/components/use-setting/index.js +1 -1
  156. package/build-module/components/use-setting/index.js.map +1 -1
  157. package/build-module/hooks/color-panel.js +17 -1
  158. package/build-module/hooks/color-panel.js.map +1 -1
  159. package/build-module/hooks/color.js +1 -1
  160. package/build-module/hooks/color.js.map +1 -1
  161. package/build-module/hooks/content-lock-ui.js +15 -8
  162. package/build-module/hooks/content-lock-ui.js.map +1 -1
  163. package/build-module/hooks/dimensions.js +39 -12
  164. package/build-module/hooks/dimensions.js.map +1 -1
  165. package/build-module/hooks/layout.js +2 -2
  166. package/build-module/hooks/layout.js.map +1 -1
  167. package/build-module/hooks/margin.js +4 -2
  168. package/build-module/hooks/margin.js.map +1 -1
  169. package/build-module/hooks/min-height.js +122 -0
  170. package/build-module/hooks/min-height.js.map +1 -0
  171. package/build-module/hooks/padding.js +4 -2
  172. package/build-module/hooks/padding.js.map +1 -1
  173. package/build-module/hooks/style.js +4 -3
  174. package/build-module/hooks/style.js.map +1 -1
  175. package/build-module/layouts/flex.js +23 -22
  176. package/build-module/layouts/flex.js.map +1 -1
  177. package/build-module/store/actions.js +22 -0
  178. package/build-module/store/actions.js.map +1 -1
  179. package/build-module/store/reducer.js +44 -14
  180. package/build-module/store/reducer.js.map +1 -1
  181. package/build-module/store/selectors.js +13 -2
  182. package/build-module/store/selectors.js.map +1 -1
  183. package/build-style/style-rtl.css +39 -26
  184. package/build-style/style.css +39 -26
  185. package/package.json +28 -28
  186. package/src/components/alignment-control/README.md +1 -1
  187. package/src/components/block-alignment-control/test/index.native.js +4 -4
  188. package/src/components/block-draggable/test/helpers.native.js +3 -3
  189. package/src/components/block-draggable/test/index.native.js +27 -27
  190. package/src/components/block-list/style.scss +10 -5
  191. package/src/components/block-lock/menu-item.js +5 -2
  192. package/src/components/block-lock/modal.js +19 -36
  193. package/src/components/block-lock/style.scss +8 -17
  194. package/src/components/block-mover/style.scss +0 -1
  195. package/src/components/block-popover/style.scss +1 -1
  196. package/src/components/block-styles/utils.js +3 -3
  197. package/src/components/block-switcher/index.js +19 -4
  198. package/src/components/block-tools/selected-block-popover.js +80 -34
  199. package/src/components/block-tools/style.scss +15 -0
  200. package/src/components/colors/with-colors.js +13 -23
  201. package/src/components/default-block-appender/style.scss +1 -0
  202. package/src/components/font-sizes/fluid-utils.js +37 -64
  203. package/src/components/font-sizes/test/fluid-utils.js +5 -5
  204. package/src/components/font-sizes/with-font-sizes.js +14 -11
  205. package/src/components/index.js +1 -0
  206. package/src/components/inner-blocks/index.js +7 -4
  207. package/src/components/inserter/reusable-blocks-tab.js +4 -2
  208. package/src/components/inserter/style.scss +8 -7
  209. package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
  210. package/src/components/link-control/index.js +23 -39
  211. package/src/components/link-control/search-input.js +1 -1
  212. package/src/components/link-control/test/index.js +272 -241
  213. package/src/components/link-control/use-internal-input-value.js +22 -0
  214. package/src/components/list-view/block.js +4 -3
  215. package/src/components/list-view/branch.js +11 -6
  216. package/src/components/off-canvas-editor/README.md +5 -0
  217. package/src/components/off-canvas-editor/block-contents.js +89 -0
  218. package/src/components/off-canvas-editor/block-select-button.js +113 -0
  219. package/src/components/off-canvas-editor/block.js +335 -0
  220. package/src/components/off-canvas-editor/branch.js +210 -0
  221. package/src/components/off-canvas-editor/context.js +8 -0
  222. package/src/components/off-canvas-editor/drop-indicator.js +126 -0
  223. package/src/components/off-canvas-editor/expander.js +26 -0
  224. package/src/components/off-canvas-editor/index.js +216 -0
  225. package/src/components/off-canvas-editor/leaf.js +48 -0
  226. package/src/components/off-canvas-editor/style.scss +397 -0
  227. package/src/components/off-canvas-editor/test/utils.js +50 -0
  228. package/src/components/off-canvas-editor/use-block-selection.js +169 -0
  229. package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
  230. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
  231. package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
  232. package/src/components/off-canvas-editor/utils.js +58 -0
  233. package/src/components/responsive-block-control/test/index.js +69 -92
  234. package/src/components/url-popover/README.md +12 -3
  235. package/src/components/url-popover/index.js +33 -3
  236. package/src/components/use-setting/index.js +7 -1
  237. package/src/hooks/color-panel.js +13 -1
  238. package/src/hooks/color.js +2 -0
  239. package/src/hooks/content-lock-ui.js +46 -34
  240. package/src/hooks/dimensions.js +76 -16
  241. package/src/hooks/layout.js +2 -3
  242. package/src/hooks/margin.js +4 -3
  243. package/src/hooks/min-height.js +121 -0
  244. package/src/hooks/padding.js +4 -3
  245. package/src/hooks/style.js +10 -2
  246. package/src/hooks/test/style.js +4 -0
  247. package/src/hooks/test/use-typography-props.js +1 -1
  248. package/src/layouts/flex.js +43 -38
  249. package/src/store/actions.js +22 -0
  250. package/src/store/reducer.js +50 -40
  251. package/src/store/selectors.js +16 -9
  252. package/src/store/test/actions.js +18 -0
  253. package/src/store/test/reducer.js +40 -0
  254. package/src/store/test/selectors.js +19 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 10.5.0 (2022-11-16)
6
+
7
+ ### Enhancement
8
+
9
+ - `BlockLockModal`: Move Icon component out of CheckboxControl label ([#45535](https://github.com/WordPress/gutenberg/pull/45535))
10
+ - Fluid typography: adjust font size min and max rules ([#45536](https://github.com/WordPress/gutenberg/pull/45536)).
11
+
5
12
  ## 10.4.0 (2022-11-02)
6
13
 
7
14
  ### Bug Fix
package/README.md CHANGED
@@ -428,7 +428,6 @@ _Parameters_
428
428
  - _args.minimumFontSize_ `?string`: Minimum font size for any clamp() calculation. Optional.
429
429
  - _args.scaleFactor_ `?number`: A scale factor to determine how fast a font scales within boundaries. Optional.
430
430
  - _args.minimumFontSizeFactor_ `?number`: How much to scale defaultFontSize by to derive minimumFontSize. Optional.
431
- - _args.maximumFontSizeFactor_ `?number`: How much to scale defaultFontSize by to derive maximumFontSize. Optional.
432
431
 
433
432
  _Returns_
434
433
 
@@ -42,7 +42,7 @@ function BlockLockMenuItem(_ref) {
42
42
 
43
43
  const label = isLocked ? (0, _i18n.__)('Unlock') : (0, _i18n.__)('Lock');
44
44
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuItem, {
45
- icon: isLocked ? _icons.unlock : _icons.lock,
45
+ icon: isLocked ? _icons.unlock : _icons.lockOutline,
46
46
  onClick: toggleModal
47
47
  }, label), isModalOpen && (0, _element.createElement)(_modal.default, {
48
48
  clientId: clientId,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/menu-item.js"],"names":["BlockLockMenuItem","clientId","canLock","isLocked","isModalOpen","toggleModal","isActive","label","unlock","lock"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAKA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIe,SAASA,iBAAT,OAA2C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACzD,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,MAAwB,2BAAcF,QAAd,CAA9B;AAEA,QAAM,CAAEG,WAAF,EAAeC,WAAf,IAA+B,yBAClCC,QAAF,IAAgB,CAAEA,QADkB,EAEpC,KAFoC,CAArC;;AAKA,MAAK,CAAEJ,OAAP,EAAiB;AAChB,WAAO,IAAP;AACA;;AAED,QAAMK,KAAK,GAAGJ,QAAQ,GAAG,cAAI,QAAJ,CAAH,GAAoB,cAAI,MAAJ,CAA1C;AAEA,SACC,qDACC,4BAAC,oBAAD;AAAU,IAAA,IAAI,EAAGA,QAAQ,GAAGK,aAAH,GAAYC,WAArC;AAA4C,IAAA,OAAO,EAAGJ;AAAtD,KACGE,KADH,CADD,EAIGH,WAAW,IACZ,4BAAC,cAAD;AAAgB,IAAA,QAAQ,EAAGH,QAA3B;AAAsC,IAAA,OAAO,EAAGI;AAAhD,IALF,CADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useReducer } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { lock, unlock } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport BlockLockModal from './modal';\n\nexport default function BlockLockMenuItem( { clientId } ) {\n\tconst { canLock, isLocked } = useBlockLock( clientId );\n\n\tconst [ isModalOpen, toggleModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tif ( ! canLock ) {\n\t\treturn null;\n\t}\n\n\tconst label = isLocked ? __( 'Unlock' ) : __( 'Lock' );\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem icon={ isLocked ? unlock : lock } onClick={ toggleModal }>\n\t\t\t\t{ label }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<BlockLockModal clientId={ clientId } onClose={ toggleModal } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/menu-item.js"],"names":["BlockLockMenuItem","clientId","canLock","isLocked","isModalOpen","toggleModal","isActive","label","unlock","lockOutline"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAKA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIe,SAASA,iBAAT,OAA2C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACzD,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,MAAwB,2BAAcF,QAAd,CAA9B;AAEA,QAAM,CAAEG,WAAF,EAAeC,WAAf,IAA+B,yBAClCC,QAAF,IAAgB,CAAEA,QADkB,EAEpC,KAFoC,CAArC;;AAKA,MAAK,CAAEJ,OAAP,EAAiB;AAChB,WAAO,IAAP;AACA;;AAED,QAAMK,KAAK,GAAGJ,QAAQ,GAAG,cAAI,QAAJ,CAAH,GAAoB,cAAI,MAAJ,CAA1C;AAEA,SACC,qDACC,4BAAC,oBAAD;AACC,IAAA,IAAI,EAAGA,QAAQ,GAAGK,aAAH,GAAYC,kBAD5B;AAEC,IAAA,OAAO,EAAGJ;AAFX,KAIGE,KAJH,CADD,EAOGH,WAAW,IACZ,4BAAC,cAAD;AAAgB,IAAA,QAAQ,EAAGH,QAA3B;AAAsC,IAAA,OAAO,EAAGI;AAAhD,IARF,CADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useReducer } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { lockOutline, unlock } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport BlockLockModal from './modal';\n\nexport default function BlockLockMenuItem( { clientId } ) {\n\tconst { canLock, isLocked } = useBlockLock( clientId );\n\n\tconst [ isModalOpen, toggleModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tif ( ! canLock ) {\n\t\treturn null;\n\t}\n\n\tconst label = isLocked ? __( 'Unlock' ) : __( 'Lock' );\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\ticon={ isLocked ? unlock : lockOutline }\n\t\t\t\tonClick={ toggleModal }\n\t\t\t>\n\t\t\t\t{ label }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<BlockLockModal clientId={ clientId } onClose={ toggleModal } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
@@ -122,6 +122,7 @@ function BlockLockModal(_ref) {
122
122
  "aria-labelledby": instanceId,
123
123
  className: "block-editor-block-lock-modal__options"
124
124
  }, (0, _element.createElement)(_components.CheckboxControl, {
125
+ __nextHasNoMarginBottom: true,
125
126
  className: "block-editor-block-lock-modal__options-title",
126
127
  label: (0, _element.createElement)("span", {
127
128
  id: instanceId
@@ -140,33 +141,39 @@ function BlockLockModal(_ref) {
140
141
  }, allowsEditLocking && (0, _element.createElement)("li", {
141
142
  className: "block-editor-block-lock-modal__checklist-item"
142
143
  }, (0, _element.createElement)(_components.CheckboxControl, {
143
- label: (0, _element.createElement)(_element.Fragment, null, (0, _i18n.__)('Restrict editing'), (0, _element.createElement)(_components.Icon, {
144
- icon: lock.edit ? _icons.lock : _icons.unlock
145
- })),
144
+ __nextHasNoMarginBottom: true,
145
+ label: (0, _i18n.__)('Restrict editing'),
146
146
  checked: !!lock.edit,
147
147
  onChange: edit => setLock(prevLock => ({ ...prevLock,
148
148
  edit
149
149
  }))
150
+ }), (0, _element.createElement)(_components.Icon, {
151
+ className: "block-editor-block-lock-modal__lock-icon",
152
+ icon: lock.edit ? _icons.lock : _icons.unlock
150
153
  })), (0, _element.createElement)("li", {
151
154
  className: "block-editor-block-lock-modal__checklist-item"
152
155
  }, (0, _element.createElement)(_components.CheckboxControl, {
153
- label: (0, _element.createElement)(_element.Fragment, null, (0, _i18n.__)('Disable movement'), (0, _element.createElement)(_components.Icon, {
154
- icon: lock.move ? _icons.lock : _icons.unlock
155
- })),
156
+ __nextHasNoMarginBottom: true,
157
+ label: (0, _i18n.__)('Disable movement'),
156
158
  checked: lock.move,
157
159
  onChange: move => setLock(prevLock => ({ ...prevLock,
158
160
  move
159
161
  }))
162
+ }), (0, _element.createElement)(_components.Icon, {
163
+ className: "block-editor-block-lock-modal__lock-icon",
164
+ icon: lock.move ? _icons.lock : _icons.unlock
160
165
  })), (0, _element.createElement)("li", {
161
166
  className: "block-editor-block-lock-modal__checklist-item"
162
167
  }, (0, _element.createElement)(_components.CheckboxControl, {
163
- label: (0, _element.createElement)(_element.Fragment, null, (0, _i18n.__)('Prevent removal'), (0, _element.createElement)(_components.Icon, {
164
- icon: lock.remove ? _icons.lock : _icons.unlock
165
- })),
168
+ __nextHasNoMarginBottom: true,
169
+ label: (0, _i18n.__)('Prevent removal'),
166
170
  checked: lock.remove,
167
171
  onChange: remove => setLock(prevLock => ({ ...prevLock,
168
172
  remove
169
173
  }))
174
+ }), (0, _element.createElement)(_components.Icon, {
175
+ className: "block-editor-block-lock-modal__lock-icon",
176
+ icon: lock.remove ? _icons.lock : _icons.unlock
170
177
  }))), hasTemplateLock && (0, _element.createElement)(_components.ToggleControl, {
171
178
  className: "block-editor-block-lock-modal__template-lock",
172
179
  label: (0, _i18n.__)('Apply to all blocks inside'),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/modal.js"],"names":["ALLOWS_EDIT_LOCKING","getTemplateLockValue","lock","remove","move","BlockLockModal","clientId","onClose","setLock","canEdit","canMove","canRemove","allowsEditLocking","templateLock","hasTemplateLock","select","getBlockName","getBlockAttributes","blockEditorStore","blockName","blockType","includes","attributes","applyTemplateLock","setApplyTemplateLock","updateBlockAttributes","blockInformation","instanceId","edit","isAllChecked","Object","values","every","Boolean","isMixed","some","title","event","preventDefault","undefined","newValue","lockIcon","unlockIcon","prevLock"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AASA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAiBA;AACA;AACA;AAKA;AACA,MAAMA,mBAAmB,GAAG,CAAE,YAAF,EAAgB,iBAAhB,CAA5B;;AAEA,SAASC,oBAAT,CAA+BC,IAA/B,EAAsC;AACrC;AACA,MAAKA,IAAI,CAACC,MAAL,IAAeD,IAAI,CAACE,IAAzB,EAAgC;AAC/B,WAAO,KAAP;AACA,GAJoC,CAMrC;;;AACA,MA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import { useEffect, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon,\n\tModal,\n\tToggleControl,\n} from '@wordpress/components';\nimport { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\n// Entity based blocks which allow edit locking\nconst ALLOWS_EDIT_LOCKING = [ 'core/block', 'core/navigation' ];\n\nfunction getTemplateLockValue( lock ) {\n\t// Prevents all operations.\n\tif ( lock.remove && lock.move ) {\n\t\treturn 'all';\n\t}\n\n\t// Prevents inserting or removing blocks, but allows moving existing blocks.\n\tif ( lock.remove && ! lock.move ) {\n\t\treturn 'insert';\n\t}\n\n\treturn false;\n}\n\nexport default function BlockLockModal( { clientId, onClose } ) {\n\tconst [ lock, setLock ] = useState( { move: false, remove: false } );\n\tconst { canEdit, canMove, canRemove } = useBlockLock( clientId );\n\tconst { allowsEditLocking, templateLock, hasTemplateLock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\treturn {\n\t\t\t\tallowsEditLocking: ALLOWS_EDIT_LOCKING.includes( blockName ),\n\t\t\t\ttemplateLock: getBlockAttributes( clientId )?.templateLock,\n\t\t\t\thasTemplateLock: !! blockType?.attributes?.templateLock,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst [ applyTemplateLock, setApplyTemplateLock ] = useState(\n\t\t!! templateLock\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId(\n\t\tBlockLockModal,\n\t\t'block-editor-block-lock-modal__options-title'\n\t);\n\n\tuseEffect( () => {\n\t\tsetLock( {\n\t\t\tmove: ! canMove,\n\t\t\tremove: ! canRemove,\n\t\t\t...( allowsEditLocking ? { edit: ! canEdit } : {} ),\n\t\t} );\n\t}, [ canEdit, canMove, canRemove, allowsEditLocking ] );\n\n\tconst isAllChecked = Object.values( lock ).every( Boolean );\n\tconst isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t/* translators: %s: Name of the block. */\n\t\t\t\t__( 'Lock %s' ),\n\t\t\t\tblockInformation.title\n\t\t\t) }\n\t\t\toverlayClassName=\"block-editor-block-lock-modal\"\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Choose specific attributes to restrict or lock all available options.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tupdateBlockAttributes( [ clientId ], {\n\t\t\t\t\t\tlock,\n\t\t\t\t\t\ttemplateLock: applyTemplateLock\n\t\t\t\t\t\t\t? getTemplateLockValue( lock )\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t} );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-labelledby={ instanceId }\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options-title\"\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t<span id={ instanceId }>{ __( 'Lock all' ) }</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchecked={ isAllChecked }\n\t\t\t\t\t\tindeterminate={ isMixed }\n\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\tsetLock( {\n\t\t\t\t\t\t\t\tmove: newValue,\n\t\t\t\t\t\t\t\tremove: newValue,\n\t\t\t\t\t\t\t\t...( allowsEditLocking\n\t\t\t\t\t\t\t\t\t? { edit: newValue }\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}\n\t\t\t\t\t/>\n\t\t\t\t\t<ul className=\"block-editor-block-lock-modal__checklist\">\n\t\t\t\t\t\t{ allowsEditLocking && (\n\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Restrict editing' ) }\n\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\t\tlock.edit\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t}\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}\n\t\t\t\t\t\t\t\t\tchecked={ !! lock.edit }\n\t\t\t\t\t\t\t\t\tonChange={ ( edit ) =>\n\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\tedit,\n\t\t\t\t\t\t\t\t\t\t} ) )\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</li>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Disable movement' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.move\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\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</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.move }\n\t\t\t\t\t\t\t\tonChange={ ( move ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tmove,\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</li>\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Prevent removal' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.remove\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\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</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.remove }\n\t\t\t\t\t\t\t\tonChange={ ( remove ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tremove,\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</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ hasTemplateLock && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__template-lock\"\n\t\t\t\t\t\t\tlabel={ __( 'Apply to all blocks inside' ) }\n\t\t\t\t\t\t\tchecked={ applyTemplateLock }\n\t\t\t\t\t\t\tdisabled={ lock.move && ! lock.remove }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetApplyTemplateLock( ! applyTemplateLock )\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</div>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/modal.js"],"names":["ALLOWS_EDIT_LOCKING","getTemplateLockValue","lock","remove","move","BlockLockModal","clientId","onClose","setLock","canEdit","canMove","canRemove","allowsEditLocking","templateLock","hasTemplateLock","select","getBlockName","getBlockAttributes","blockEditorStore","blockName","blockType","includes","attributes","applyTemplateLock","setApplyTemplateLock","updateBlockAttributes","blockInformation","instanceId","edit","isAllChecked","Object","values","every","Boolean","isMixed","some","title","event","preventDefault","undefined","newValue","prevLock","lockIcon","unlockIcon"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AASA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAxBA;AACA;AACA;;AAiBA;AACA;AACA;AAKA;AACA,MAAMA,mBAAmB,GAAG,CAAE,YAAF,EAAgB,iBAAhB,CAA5B;;AAEA,SAASC,oBAAT,CAA+BC,IAA/B,EAAsC;AACrC;AACA,MAAKA,IAAI,CAACC,MAAL,IAAeD,IAAI,CAACE,IAAzB,EAAgC;AAC/B,WAAO,KAAP;AACA,GAJoC,CAMrC;;;AACA,MAAKF,IAAI,CAACC,MAAL,IAAe,CAAED,IAAI,CAACE,IAA3B,EAAkC;AACjC,WAAO,QAAP;AACA;;AAED,SAAO,KAAP;AACA;;AAEc,SAASC,cAAT,OAAiD;AAAA,MAAxB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAwB;AAC/D,QAAM,CAAEL,IAAF,EAAQM,OAAR,IAAoB,uBAAU;AAAEJ,IAAAA,IAAI,EAAE,KAAR;AAAeD,IAAAA,MAAM,EAAE;AAAvB,GAAV,CAA1B;AACA,QAAM;AAAEM,IAAAA,OAAF;AAAWC,IAAAA,OAAX;AAAoBC,IAAAA;AAApB,MAAkC,2BAAcL,QAAd,CAAxC;AACA,QAAM;AAAEM,IAAAA,iBAAF;AAAqBC,IAAAA,YAArB;AAAmCC,IAAAA;AAAnC,MAAuD,qBAC1DC,MAAF,IAAc;AAAA;;AACb,UAAM;AAAEC,MAAAA,YAAF;AAAgBC,MAAAA;AAAhB,QACLF,MAAM,CAAEG,YAAF,CADP;AAEA,UAAMC,SAAS,GAAGH,YAAY,CAAE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AC,yBAAD;AACC,IAAA,SAAS,EAAC,8CADX;AAEC,IAAA,KAAK,EAAG,cAAI,4BAAJ,CAFT;AAGC,IAAA,OAAO,EAAGS,iBAHX;AAIC,IAAA,QAAQ,EAAGrB,IAAI,CAACE,IAAL,IAAa,CAAEF,IAAI,CAACC,MAJhC;AAKC,IAAA,QAAQ,EAAG,MACVqB,oBAAoB,CAAE,CAAED,iBAAJ;AANtB,IA/EF,CAZD,EAsGC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,QAAQ,EAAG;AAHZ,KAKC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGhB;AAArC,KACG,cAAI,QAAJ,CADH,CADD,CALD,EAUC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACG,cAAI,OAAJ,CADH,CADD,CAVD,CAtGD,CAfD,CADD;AAyIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon,\n\tModal,\n\tToggleControl,\n} from '@wordpress/components';\nimport { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\n// Entity based blocks which allow edit locking\nconst ALLOWS_EDIT_LOCKING = [ 'core/block', 'core/navigation' ];\n\nfunction getTemplateLockValue( lock ) {\n\t// Prevents all operations.\n\tif ( lock.remove && lock.move ) {\n\t\treturn 'all';\n\t}\n\n\t// Prevents inserting or removing blocks, but allows moving existing blocks.\n\tif ( lock.remove && ! lock.move ) {\n\t\treturn 'insert';\n\t}\n\n\treturn false;\n}\n\nexport default function BlockLockModal( { clientId, onClose } ) {\n\tconst [ lock, setLock ] = useState( { move: false, remove: false } );\n\tconst { canEdit, canMove, canRemove } = useBlockLock( clientId );\n\tconst { allowsEditLocking, templateLock, hasTemplateLock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName, getBlockAttributes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\treturn {\n\t\t\t\tallowsEditLocking: ALLOWS_EDIT_LOCKING.includes( blockName ),\n\t\t\t\ttemplateLock: getBlockAttributes( clientId )?.templateLock,\n\t\t\t\thasTemplateLock: !! blockType?.attributes?.templateLock,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst [ applyTemplateLock, setApplyTemplateLock ] = useState(\n\t\t!! templateLock\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId(\n\t\tBlockLockModal,\n\t\t'block-editor-block-lock-modal__options-title'\n\t);\n\n\tuseEffect( () => {\n\t\tsetLock( {\n\t\t\tmove: ! canMove,\n\t\t\tremove: ! canRemove,\n\t\t\t...( allowsEditLocking ? { edit: ! canEdit } : {} ),\n\t\t} );\n\t}, [ canEdit, canMove, canRemove, allowsEditLocking ] );\n\n\tconst isAllChecked = Object.values( lock ).every( Boolean );\n\tconst isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t/* translators: %s: Name of the block. */\n\t\t\t\t__( 'Lock %s' ),\n\t\t\t\tblockInformation.title\n\t\t\t) }\n\t\t\toverlayClassName=\"block-editor-block-lock-modal\"\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Choose specific attributes to restrict or lock all available options.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tupdateBlockAttributes( [ clientId ], {\n\t\t\t\t\t\tlock,\n\t\t\t\t\t\ttemplateLock: applyTemplateLock\n\t\t\t\t\t\t\t? getTemplateLockValue( lock )\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t} );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-labelledby={ instanceId }\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options-title\"\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t<span id={ instanceId }>{ __( 'Lock all' ) }</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchecked={ isAllChecked }\n\t\t\t\t\t\tindeterminate={ isMixed }\n\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\tsetLock( {\n\t\t\t\t\t\t\t\tmove: newValue,\n\t\t\t\t\t\t\t\tremove: newValue,\n\t\t\t\t\t\t\t\t...( allowsEditLocking\n\t\t\t\t\t\t\t\t\t? { edit: newValue }\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}\n\t\t\t\t\t/>\n\t\t\t\t\t<ul className=\"block-editor-block-lock-modal__checklist\">\n\t\t\t\t\t\t{ allowsEditLocking && (\n\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Restrict editing' ) }\n\t\t\t\t\t\t\t\t\tchecked={ !! lock.edit }\n\t\t\t\t\t\t\t\t\tonChange={ ( edit ) =>\n\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\tedit,\n\t\t\t\t\t\t\t\t\t\t} ) )\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<Icon\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\t\ticon={ lock.edit ? lockIcon : unlockIcon }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Disable movement' ) }\n\t\t\t\t\t\t\t\tchecked={ lock.move }\n\t\t\t\t\t\t\t\tonChange={ ( move ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tmove,\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\t<Icon\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\ticon={ lock.move ? lockIcon : unlockIcon }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Prevent removal' ) }\n\t\t\t\t\t\t\t\tchecked={ lock.remove }\n\t\t\t\t\t\t\t\tonChange={ ( remove ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tremove,\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\t<Icon\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__lock-icon\"\n\t\t\t\t\t\t\t\ticon={ lock.remove ? lockIcon : unlockIcon }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ hasTemplateLock && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__template-lock\"\n\t\t\t\t\t\t\tlabel={ __( 'Apply to all blocks inside' ) }\n\t\t\t\t\t\t\tchecked={ applyTemplateLock }\n\t\t\t\t\t\t\tdisabled={ lock.move && ! lock.remove }\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetApplyTemplateLock( ! applyTemplateLock )\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</div>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
@@ -27,7 +27,7 @@ var _i18n = require("@wordpress/i18n");
27
27
  /**
28
28
  * Returns the active style from the given className.
29
29
  *
30
- * @param {Array} styles Block style variations.
30
+ * @param {Array} styles Block styles.
31
31
  * @param {string} className Class name
32
32
  *
33
33
  * @return {Object?} The active style.
@@ -77,7 +77,7 @@ function replaceActiveStyle(className, activeStyle, newStyle) {
77
77
  * act as a fallback for when there is no active style applied to a block. The default item also serves
78
78
  * as a switch on the frontend to deactivate non-default styles.
79
79
  *
80
- * @param {Array} styles Block style variations.
80
+ * @param {Array} styles Block styles.
81
81
  *
82
82
  * @return {Array<Object?>} The style collection.
83
83
  */
@@ -97,7 +97,7 @@ function getRenderedStyles(styles) {
97
97
  /**
98
98
  * Returns a style object from a collection of styles where that style object is the default block style.
99
99
  *
100
- * @param {Array} styles Block style variations.
100
+ * @param {Array} styles Block styles.
101
101
  *
102
102
  * @return {Object?} The default style object, if found.
103
103
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/utils.js"],"names":["getActiveStyle","styles","className","style","TokenList","values","indexOf","potentialStyleName","substring","activeStyle","name","replaceActiveStyle","newStyle","list","remove","add","value","getRenderedStyles","length","getDefaultStyle","label","isDefault"],"mappings":";;;;;;;;;;;;AAGA;;AAIA;;AACA;;AARA;AACA;AACA;;AAEA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,MAAzB,EAAiCC,SAAjC,EAA6C;AACnD,OAAM,MAAMC,KAAZ,IAAqB,IAAIC,kBAAJ,CAAeF,SAAf,EAA2BG,MAA3B,EAArB,EAA2D;AAC1D,QAAKF,KAAK,CAACG,OAAN,CAAe,WAAf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n * External dependencies\n */\nimport { find } from 'lodash';\n/**\n * WordPress dependencies\n */\nimport TokenList from '@wordpress/token-list';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Returns the active style from the given className.\n *\n * @param {Array} styles Block style variations.\n * @param {string} className Class name\n *\n * @return {Object?} The active style.\n */\nexport function getActiveStyle( styles, className ) {\n\tfor ( const style of new TokenList( className ).values() ) {\n\t\tif ( style.indexOf( 'is-style-' ) === -1 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst potentialStyleName = style.substring( 9 );\n\t\tconst activeStyle = find( styles, { name: potentialStyleName } );\n\t\tif ( activeStyle ) {\n\t\t\treturn activeStyle;\n\t\t}\n\t}\n\n\treturn find( styles, 'isDefault' );\n}\n\n/**\n * Replaces the active style in the block's className.\n *\n * @param {string} className Class name.\n * @param {Object?} activeStyle The replaced style.\n * @param {Object} newStyle The replacing style.\n *\n * @return {string} The updated className.\n */\nexport function replaceActiveStyle( className, activeStyle, newStyle ) {\n\tconst list = new TokenList( className );\n\n\tif ( activeStyle ) {\n\t\tlist.remove( 'is-style-' + activeStyle.name );\n\t}\n\n\tlist.add( 'is-style-' + newStyle.name );\n\n\treturn list.value;\n}\n\n/**\n * Returns a collection of styles that can be represented on the frontend.\n * The function checks a style collection for a default style. If none is found, it adds one to\n * act as a fallback for when there is no active style applied to a block. The default item also serves\n * as a switch on the frontend to deactivate non-default styles.\n *\n * @param {Array} styles Block style variations.\n *\n * @return {Array<Object?>} The style collection.\n */\nexport function getRenderedStyles( styles ) {\n\tif ( ! styles || styles.length === 0 ) {\n\t\treturn [];\n\t}\n\n\treturn getDefaultStyle( styles )\n\t\t? styles\n\t\t: [\n\t\t\t\t{\n\t\t\t\t\tname: 'default',\n\t\t\t\t\tlabel: _x( 'Default', 'block style' ),\n\t\t\t\t\tisDefault: true,\n\t\t\t\t},\n\t\t\t\t...styles,\n\t\t ];\n}\n\n/**\n * Returns a style object from a collection of styles where that style object is the default block style.\n *\n * @param {Array} styles Block style variations.\n *\n * @return {Object?} The default style object, if found.\n */\nexport function getDefaultStyle( styles ) {\n\treturn find( styles, 'isDefault' );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/utils.js"],"names":["getActiveStyle","styles","className","style","TokenList","values","indexOf","potentialStyleName","substring","activeStyle","name","replaceActiveStyle","newStyle","list","remove","add","value","getRenderedStyles","length","getDefaultStyle","label","isDefault"],"mappings":";;;;;;;;;;;;AAGA;;AAIA;;AACA;;AARA;AACA;AACA;;AAEA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,MAAzB,EAAiCC,SAAjC,EAA6C;AACnD,OAAM,MAAMC,KAAZ,IAAqB,IAAIC,kBAAJ,CAAeF,SAAf,EAA2BG,MAA3B,EAArB,EAA2D;AAC1D,QAAKF,KAAK,CAACG,OAAN,CAAe,WAAf,MAAiC,CAAC,CAAvC,EAA2C;AAC1C;AACA;;AAED,UAAMC,kBAAkB,GAAGJ,KAAK,CAACK,SAAN,CAAiB,CAAjB,CAA3B;AACA,UAAMC,WAAW,GAAG,kBAAMR,MAAN,EAAc;AAAES,MAAAA,IAAI,EAAEH;AAAR,KAAd,CAApB;;AACA,QAAKE,WAAL,EAAmB;AAClB,aAAOA,WAAP;AACA;AACD;;AAED,SAAO,kBAAMR,MAAN,EAAc,WAAd,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASU,kBAAT,CAA6BT,SAA7B,EAAwCO,WAAxC,EAAqDG,QAArD,EAAgE;AACtE,QAAMC,IAAI,GAAG,IAAIT,kBAAJ,CAAeF,SAAf,CAAb;;AAEA,MAAKO,WAAL,EAAmB;AAClBI,IAAAA,IAAI,CAACC,MAAL,CAAa,cAAcL,WAAW,CAACC,IAAvC;AACA;;AAEDG,EAAAA,IAAI,CAACE,GAAL,CAAU,cAAcH,QAAQ,CAACF,IAAjC;AAEA,SAAOG,IAAI,CAACG,KAAZ;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,iBAAT,CAA4BhB,MAA5B,EAAqC;AAC3C,MAAK,CAAEA,MAAF,IAAYA,MAAM,CAACiB,MAAP,KAAkB,CAAnC,EAAuC;AACtC,WAAO,EAAP;AACA;;AAED,SAAOC,eAAe,CAAElB,MAAF,CAAf,GACJA,MADI,GAEJ,CACA;AACCS,IAAAA,IAAI,EAAE,SADP;AAECU,IAAAA,KAAK,EAAE,cAAI,SAAJ,EAAe,aAAf,CAFR;AAGCC,IAAAA,SAAS,EAAE;AAHZ,GADA,EAMA,GAAGpB,MANH,CAFH;AAUA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASkB,eAAT,CAA0BlB,MAA1B,EAAmC;AACzC,SAAO,kBAAMA,MAAN,EAAc,WAAd,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\n/**\n * WordPress dependencies\n */\nimport TokenList from '@wordpress/token-list';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Returns the active style from the given className.\n *\n * @param {Array} styles Block styles.\n * @param {string} className Class name\n *\n * @return {Object?} The active style.\n */\nexport function getActiveStyle( styles, className ) {\n\tfor ( const style of new TokenList( className ).values() ) {\n\t\tif ( style.indexOf( 'is-style-' ) === -1 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst potentialStyleName = style.substring( 9 );\n\t\tconst activeStyle = find( styles, { name: potentialStyleName } );\n\t\tif ( activeStyle ) {\n\t\t\treturn activeStyle;\n\t\t}\n\t}\n\n\treturn find( styles, 'isDefault' );\n}\n\n/**\n * Replaces the active style in the block's className.\n *\n * @param {string} className Class name.\n * @param {Object?} activeStyle The replaced style.\n * @param {Object} newStyle The replacing style.\n *\n * @return {string} The updated className.\n */\nexport function replaceActiveStyle( className, activeStyle, newStyle ) {\n\tconst list = new TokenList( className );\n\n\tif ( activeStyle ) {\n\t\tlist.remove( 'is-style-' + activeStyle.name );\n\t}\n\n\tlist.add( 'is-style-' + newStyle.name );\n\n\treturn list.value;\n}\n\n/**\n * Returns a collection of styles that can be represented on the frontend.\n * The function checks a style collection for a default style. If none is found, it adds one to\n * act as a fallback for when there is no active style applied to a block. The default item also serves\n * as a switch on the frontend to deactivate non-default styles.\n *\n * @param {Array} styles Block styles.\n *\n * @return {Array<Object?>} The style collection.\n */\nexport function getRenderedStyles( styles ) {\n\tif ( ! styles || styles.length === 0 ) {\n\t\treturn [];\n\t}\n\n\treturn getDefaultStyle( styles )\n\t\t? styles\n\t\t: [\n\t\t\t\t{\n\t\t\t\t\tname: 'default',\n\t\t\t\t\tlabel: _x( 'Default', 'block style' ),\n\t\t\t\t\tisDefault: true,\n\t\t\t\t},\n\t\t\t\t...styles,\n\t\t ];\n}\n\n/**\n * Returns a style object from a collection of styles where that style object is the default block style.\n *\n * @param {Array} styles Block styles.\n *\n * @return {Object?} The default style object, if found.\n */\nexport function getDefaultStyle( styles ) {\n\treturn find( styles, 'isDefault' );\n}\n"]}
@@ -46,7 +46,8 @@ const BlockSwitcherDropdownMenu = _ref => {
46
46
  blocks
47
47
  } = _ref;
48
48
  const {
49
- replaceBlocks
49
+ replaceBlocks,
50
+ multiSelect
50
51
  } = (0, _data.useDispatch)(_store.store);
51
52
  const blockInformation = (0, _useBlockDisplayInformation.default)(blocks[0].clientId);
52
53
  const {
@@ -108,12 +109,26 @@ const BlockSwitcherDropdownMenu = _ref => {
108
109
  maximumLength: 35
109
110
  });
110
111
  const isReusable = blocks.length === 1 && (0, _blocks.isReusableBlock)(blocks[0]);
111
- const isTemplate = blocks.length === 1 && (0, _blocks.isTemplatePart)(blocks[0]); // Simple block tranformation based on the `Block Transforms` API.
112
+ const isTemplate = blocks.length === 1 && (0, _blocks.isTemplatePart)(blocks[0]);
113
+
114
+ function selectForMultipleBlocks(insertedBlocks) {
115
+ if (insertedBlocks.length > 1) {
116
+ multiSelect(insertedBlocks[0].clientId, insertedBlocks[insertedBlocks.length - 1].clientId);
117
+ }
118
+ } // Simple block tranformation based on the `Block Transforms` API.
112
119
 
113
- const onBlockTransform = name => replaceBlocks(clientIds, (0, _blocks.switchToBlockType)(blocks, name)); // Pattern transformation through the `Patterns` API.
114
120
 
121
+ function onBlockTransform(name) {
122
+ const newBlocks = (0, _blocks.switchToBlockType)(blocks, name);
123
+ replaceBlocks(clientIds, newBlocks);
124
+ selectForMultipleBlocks(newBlocks);
125
+ } // Pattern transformation through the `Patterns` API.
115
126
 
116
- const onPatternTransform = transformedBlocks => replaceBlocks(clientIds, transformedBlocks);
127
+
128
+ function onPatternTransform(transformedBlocks) {
129
+ replaceBlocks(clientIds, transformedBlocks);
130
+ selectForMultipleBlocks(transformedBlocks);
131
+ }
117
132
  /**
118
133
  * The `isTemplate` check is a stopgap solution here.
119
134
  * Ideally, the Transforms API should handle this
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-switcher/index.js"],"names":["BlockSwitcherDropdownMenu","clientIds","blocks","replaceBlocks","blockEditorStore","blockInformation","clientId","possibleBlockTransformations","canRemove","hasBlockStyles","icon","patterns","select","getBlockRootClientId","getBlockTransformItems","__experimentalGetPatternTransformItems","getBlockStyles","getBlockType","blocksStore","canRemoveBlocks","rootClientId","Array","isArray","name","firstBlockName","_isSingleBlockSelected","length","styles","_icon","isSelectionOfSameType","Set","map","size","copy","blockTitle","maximumLength","isReusable","isTemplate","onBlockTransform","onPatternTransform","transformedBlocks","hasPossibleBlockTransformations","hasPatternTransformation","blockSwitcherLabel","blockSwitcherDescription","showDropDown","toggleProps","position","variant","className","describedBy","orientation","onClose","BlockSwitcher","getBlocksByClientId","some","block"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAMA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA5BA;AACA;AACA;;AAiBA;AACA;AACA;AASO,MAAMA,yBAAyB,GAAG,QAA6B;AAAA,MAA3B;AAAEC,IAAAA,SAAF;AAA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AAEpD,IAAAA;AAAF,GAAmB;AACjD,QAAMC,MAAM,GAAG,qBACZU,MAAF,IACCA,MAAM,CAAER,YAAF,CAAN,CAA2BkD,mBAA3B,CAAgDrD,SAAhD,CAFa,EAGd,CAAEA,SAAF,CAHc,CAAf;;AAMA,MAAK,CAAEC,MAAM,CAACwB,MAAT,IAAmBxB,MAAM,CAACqD,IAAP,CAAeC,KAAF,IAAa,CAAEA,KAA5B,CAAxB,EAA8D;AAC7D,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,yBAAD;AAA2B,IAAA,SAAS,EAAGvD,SAAvC;AAAmD,IAAA,MAAM,EAAGC;AAA5D,IADD;AAGA,CAdM;;;eAgBQmD,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tToolbarButton,\n\tToolbarGroup,\n\tToolbarItem,\n} from '@wordpress/components';\nimport {\n\tswitchToBlockType,\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { copy } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockIcon from '../block-icon';\nimport BlockTransformationsMenu from './block-transformations-menu';\nimport BlockStylesMenu from './block-styles-menu';\nimport PatternTransformationsMenu from './pattern-transformations-menu';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\n\nexport const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( blocks[ 0 ].clientId );\n\tconst {\n\t\tpossibleBlockTransformations,\n\t\tcanRemove,\n\t\thasBlockStyles,\n\t\ticon,\n\t\tpatterns,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t\t__experimentalGetPatternTransformItems,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockStyles, getBlockType } = select( blocksStore );\n\t\t\tconst { canRemoveBlocks } = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\tArray.isArray( clientIds ) ? clientIds[ 0 ] : clientIds\n\t\t\t);\n\t\t\tconst [ { name: firstBlockName } ] = blocks;\n\t\t\tconst _isSingleBlockSelected = blocks.length === 1;\n\t\t\tconst styles =\n\t\t\t\t_isSingleBlockSelected && getBlockStyles( firstBlockName );\n\t\t\tlet _icon;\n\t\t\tif ( _isSingleBlockSelected ) {\n\t\t\t\t_icon = blockInformation?.icon; // Take into account active block variations.\n\t\t\t} else {\n\t\t\t\tconst isSelectionOfSameType =\n\t\t\t\t\tnew Set( blocks.map( ( { name } ) => name ) ).size === 1;\n\t\t\t\t// When selection consists of blocks of multiple types, display an\n\t\t\t\t// appropriate icon to communicate the non-uniformity.\n\t\t\t\t_icon = isSelectionOfSameType\n\t\t\t\t\t? getBlockType( firstBlockName )?.icon\n\t\t\t\t\t: copy;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpossibleBlockTransformations: getBlockTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanRemove: canRemoveBlocks( clientIds, rootClientId ),\n\t\t\t\thasBlockStyles: !! styles?.length,\n\t\t\t\ticon: _icon,\n\t\t\t\tpatterns: __experimentalGetPatternTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds, blocks, blockInformation?.icon ]\n\t);\n\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId: Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds,\n\t\tmaximumLength: 35,\n\t} );\n\tconst isReusable = blocks.length === 1 && isReusableBlock( blocks[ 0 ] );\n\tconst isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );\n\n\t// Simple block tranformation based on the `Block Transforms` API.\n\tconst onBlockTransform = ( name ) =>\n\t\treplaceBlocks( clientIds, switchToBlockType( blocks, name ) );\n\t// Pattern transformation through the `Patterns` API.\n\tconst onPatternTransform = ( transformedBlocks ) =>\n\t\treplaceBlocks( clientIds, transformedBlocks );\n\n\t/**\n\t * The `isTemplate` check is a stopgap solution here.\n\t * Ideally, the Transforms API should handle this\n\t * by allowing to exclude blocks from wildcard transformations.\n\t */\n\tconst hasPossibleBlockTransformations =\n\t\t!! possibleBlockTransformations.length && canRemove && ! isTemplate;\n\tconst hasPatternTransformation = !! patterns?.length && canRemove;\n\tif ( ! hasBlockStyles && ! hasPossibleBlockTransformations ) {\n\t\treturn (\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tdisabled\n\t\t\t\t\tclassName=\"block-editor-block-switcher__no-switcher-icon\"\n\t\t\t\t\ttitle={ blockTitle }\n\t\t\t\t\ticon={\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BlockIcon icon={ icon } showColors />\n\t\t\t\t\t\t\t{ ( isReusable || isTemplate ) && (\n\t\t\t\t\t\t\t\t<span className=\"block-editor-block-switcher__toggle-text\">\n\t\t\t\t\t\t\t\t\t{ blockTitle }\n\t\t\t\t\t\t\t\t</span>\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/>\n\t\t\t</ToolbarGroup>\n\t\t);\n\t}\n\n\tconst blockSwitcherLabel = blockTitle;\n\n\tconst blockSwitcherDescription =\n\t\t1 === blocks.length\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: block title. */\n\t\t\t\t\t__( '%s: Change block type or style' ),\n\t\t\t\t\tblockTitle\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: %d: number of blocks. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'Change type of %d block',\n\t\t\t\t\t\t'Change type of %d blocks',\n\t\t\t\t\t\tblocks.length\n\t\t\t\t\t),\n\t\t\t\t\tblocks.length\n\t\t\t );\n\n\tconst showDropDown =\n\t\thasBlockStyles ||\n\t\thasPossibleBlockTransformations ||\n\t\thasPatternTransformation;\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarItem>\n\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\tclassName=\"block-editor-block-switcher\"\n\t\t\t\t\t\tlabel={ blockSwitcherLabel }\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\t\t\tvariant: 'toolbar',\n\t\t\t\t\t\t\tclassName: 'block-editor-block-switcher__popover',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__toggle\"\n\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ ( isReusable || isTemplate ) && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-block-switcher__toggle-text\">\n\t\t\t\t\t\t\t\t\t\t{ blockTitle }\n\t\t\t\t\t\t\t\t\t</span>\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\ttoggleProps={ {\n\t\t\t\t\t\t\tdescribedBy: blockSwitcherDescription,\n\t\t\t\t\t\t\t...toggleProps,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tmenuProps={ { orientation: 'both' } }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { onClose } ) =>\n\t\t\t\t\t\t\tshowDropDown && (\n\t\t\t\t\t\t\t\t<div className=\"block-editor-block-switcher__container\">\n\t\t\t\t\t\t\t\t\t{ hasPatternTransformation && (\n\t\t\t\t\t\t\t\t\t\t<PatternTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tpatterns={ patterns }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ (\n\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\n\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonPatternTransform(\n\t\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\tonClose();\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) }\n\t\t\t\t\t\t\t\t\t{ hasPossibleBlockTransformations && (\n\t\t\t\t\t\t\t\t\t\t<BlockTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__transforms__menugroup\"\n\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations={\n\t\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ ( name ) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonBlockTransform( name );\n\t\t\t\t\t\t\t\t\t\t\t\tonClose();\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) }\n\t\t\t\t\t\t\t\t\t{ hasBlockStyles && (\n\t\t\t\t\t\t\t\t\t\t<BlockStylesMenu\n\t\t\t\t\t\t\t\t\t\t\thoveredBlock={ blocks[ 0 ] }\n\t\t\t\t\t\t\t\t\t\t\tonSwitch={ onClose }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</DropdownMenu>\n\t\t\t\t) }\n\t\t\t</ToolbarItem>\n\t\t</ToolbarGroup>\n\t);\n};\n\nexport const BlockSwitcher = ( { clientIds } ) => {\n\tconst blocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds ),\n\t\t[ clientIds ]\n\t);\n\n\tif ( ! blocks.length || blocks.some( ( block ) => ! block ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockSwitcherDropdownMenu clientIds={ clientIds } blocks={ blocks } />\n\t);\n};\n\nexport default BlockSwitcher;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-switcher/index.js"],"names":["BlockSwitcherDropdownMenu","clientIds","blocks","replaceBlocks","multiSelect","blockEditorStore","blockInformation","clientId","possibleBlockTransformations","canRemove","hasBlockStyles","icon","patterns","select","getBlockRootClientId","getBlockTransformItems","__experimentalGetPatternTransformItems","getBlockStyles","getBlockType","blocksStore","canRemoveBlocks","rootClientId","Array","isArray","name","firstBlockName","_isSingleBlockSelected","length","styles","_icon","isSelectionOfSameType","Set","map","size","copy","blockTitle","maximumLength","isReusable","isTemplate","selectForMultipleBlocks","insertedBlocks","onBlockTransform","newBlocks","onPatternTransform","transformedBlocks","hasPossibleBlockTransformations","hasPatternTransformation","blockSwitcherLabel","blockSwitcherDescription","showDropDown","toggleProps","position","variant","className","describedBy","orientation","onClose","BlockSwitcher","getBlocksByClientId","some","block"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAMA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA5BA;AACA;AACA;;AAiBA;AACA;AACA;AASO,MAAMA,yBAAyB,GAAG,QAA6B;AAAA,MAA3B;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GAA2B;AACrE,QAAM;AAAEC,IAAAA,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,EAC3BrC,4BAHF;AAKC,MAAA,MAAM,EAAGN,MALV;AAMC,MAAA,QAAQ,EAAKsB,IAAF,IAAY;AACtBiB,QAAAA,gBAAgB,CAAEjB,IAAF,CAAhB;AACAgC,QAAAA,OAAO;AACP;AATF,MAhBF,EA4BG9C,cAAc,IACf,4BAAC,wBAAD;AACC,MAAA,YAAY,EAAGR,MAAM,CAAE,CAAF,CADtB;AAEC,MAAA,QAAQ,EAAGsD;AAFZ,MA7BF,CAFA;AAAA,GA5BH,CAFF,CADD,CADD;AA4EA,CApNM;;;;AAsNA,MAAMC,aAAa,GAAG,SAAqB;AAAA,MAAnB;AAAExD,IAAAA;AAAF,GAAmB;AACjD,QAAMC,MAAM,GAAG,qBACZW,MAAF,IACCA,MAAM,CAAER,YAAF,CAAN,CAA2BqD,mBAA3B,CAAgDzD,SAAhD,CAFa,EAGd,CAAEA,SAAF,CAHc,CAAf;;AAMA,MAAK,CAAEC,MAAM,CAACyB,MAAT,IAAmBzB,MAAM,CAACyD,IAAP,CAAeC,KAAF,IAAa,CAAEA,KAA5B,CAAxB,EAA8D;AAC7D,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,yBAAD;AAA2B,IAAA,SAAS,EAAG3D,SAAvC;AAAmD,IAAA,MAAM,EAAGC;AAA5D,IADD;AAGA,CAdM;;;eAgBQuD,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tDropdownMenu,\n\tToolbarButton,\n\tToolbarGroup,\n\tToolbarItem,\n} from '@wordpress/components';\nimport {\n\tswitchToBlockType,\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { copy } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockIcon from '../block-icon';\nimport BlockTransformationsMenu from './block-transformations-menu';\nimport BlockStylesMenu from './block-styles-menu';\nimport PatternTransformationsMenu from './pattern-transformations-menu';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\n\nexport const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {\n\tconst { replaceBlocks, multiSelect } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( blocks[ 0 ].clientId );\n\tconst {\n\t\tpossibleBlockTransformations,\n\t\tcanRemove,\n\t\thasBlockStyles,\n\t\ticon,\n\t\tpatterns,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockTransformItems,\n\t\t\t\t__experimentalGetPatternTransformItems,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockStyles, getBlockType } = select( blocksStore );\n\t\t\tconst { canRemoveBlocks } = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId(\n\t\t\t\tArray.isArray( clientIds ) ? clientIds[ 0 ] : clientIds\n\t\t\t);\n\t\t\tconst [ { name: firstBlockName } ] = blocks;\n\t\t\tconst _isSingleBlockSelected = blocks.length === 1;\n\t\t\tconst styles =\n\t\t\t\t_isSingleBlockSelected && getBlockStyles( firstBlockName );\n\t\t\tlet _icon;\n\t\t\tif ( _isSingleBlockSelected ) {\n\t\t\t\t_icon = blockInformation?.icon; // Take into account active block variations.\n\t\t\t} else {\n\t\t\t\tconst isSelectionOfSameType =\n\t\t\t\t\tnew Set( blocks.map( ( { name } ) => name ) ).size === 1;\n\t\t\t\t// When selection consists of blocks of multiple types, display an\n\t\t\t\t// appropriate icon to communicate the non-uniformity.\n\t\t\t\t_icon = isSelectionOfSameType\n\t\t\t\t\t? getBlockType( firstBlockName )?.icon\n\t\t\t\t\t: copy;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpossibleBlockTransformations: getBlockTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tcanRemove: canRemoveBlocks( clientIds, rootClientId ),\n\t\t\t\thasBlockStyles: !! styles?.length,\n\t\t\t\ticon: _icon,\n\t\t\t\tpatterns: __experimentalGetPatternTransformItems(\n\t\t\t\t\tblocks,\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds, blocks, blockInformation?.icon ]\n\t);\n\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId: Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds,\n\t\tmaximumLength: 35,\n\t} );\n\tconst isReusable = blocks.length === 1 && isReusableBlock( blocks[ 0 ] );\n\tconst isTemplate = blocks.length === 1 && isTemplatePart( blocks[ 0 ] );\n\n\tfunction selectForMultipleBlocks( insertedBlocks ) {\n\t\tif ( insertedBlocks.length > 1 ) {\n\t\t\tmultiSelect(\n\t\t\t\tinsertedBlocks[ 0 ].clientId,\n\t\t\t\tinsertedBlocks[ insertedBlocks.length - 1 ].clientId\n\t\t\t);\n\t\t}\n\t}\n\n\t// Simple block tranformation based on the `Block Transforms` API.\n\tfunction onBlockTransform( name ) {\n\t\tconst newBlocks = switchToBlockType( blocks, name );\n\t\treplaceBlocks( clientIds, newBlocks );\n\t\tselectForMultipleBlocks( newBlocks );\n\t}\n\n\t// Pattern transformation through the `Patterns` API.\n\tfunction onPatternTransform( transformedBlocks ) {\n\t\treplaceBlocks( clientIds, transformedBlocks );\n\t\tselectForMultipleBlocks( transformedBlocks );\n\t}\n\n\t/**\n\t * The `isTemplate` check is a stopgap solution here.\n\t * Ideally, the Transforms API should handle this\n\t * by allowing to exclude blocks from wildcard transformations.\n\t */\n\tconst hasPossibleBlockTransformations =\n\t\t!! possibleBlockTransformations.length && canRemove && ! isTemplate;\n\tconst hasPatternTransformation = !! patterns?.length && canRemove;\n\tif ( ! hasBlockStyles && ! hasPossibleBlockTransformations ) {\n\t\treturn (\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tdisabled\n\t\t\t\t\tclassName=\"block-editor-block-switcher__no-switcher-icon\"\n\t\t\t\t\ttitle={ blockTitle }\n\t\t\t\t\ticon={\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<BlockIcon icon={ icon } showColors />\n\t\t\t\t\t\t\t{ ( isReusable || isTemplate ) && (\n\t\t\t\t\t\t\t\t<span className=\"block-editor-block-switcher__toggle-text\">\n\t\t\t\t\t\t\t\t\t{ blockTitle }\n\t\t\t\t\t\t\t\t</span>\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/>\n\t\t\t</ToolbarGroup>\n\t\t);\n\t}\n\n\tconst blockSwitcherLabel = blockTitle;\n\n\tconst blockSwitcherDescription =\n\t\t1 === blocks.length\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: block title. */\n\t\t\t\t\t__( '%s: Change block type or style' ),\n\t\t\t\t\tblockTitle\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t/* translators: %d: number of blocks. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'Change type of %d block',\n\t\t\t\t\t\t'Change type of %d blocks',\n\t\t\t\t\t\tblocks.length\n\t\t\t\t\t),\n\t\t\t\t\tblocks.length\n\t\t\t );\n\n\tconst showDropDown =\n\t\thasBlockStyles ||\n\t\thasPossibleBlockTransformations ||\n\t\thasPatternTransformation;\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarItem>\n\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\tclassName=\"block-editor-block-switcher\"\n\t\t\t\t\t\tlabel={ blockSwitcherLabel }\n\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\tposition: 'bottom right',\n\t\t\t\t\t\t\tvariant: 'toolbar',\n\t\t\t\t\t\t\tclassName: 'block-editor-block-switcher__popover',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__toggle\"\n\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ ( isReusable || isTemplate ) && (\n\t\t\t\t\t\t\t\t\t<span className=\"block-editor-block-switcher__toggle-text\">\n\t\t\t\t\t\t\t\t\t\t{ blockTitle }\n\t\t\t\t\t\t\t\t\t</span>\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\ttoggleProps={ {\n\t\t\t\t\t\t\tdescribedBy: blockSwitcherDescription,\n\t\t\t\t\t\t\t...toggleProps,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tmenuProps={ { orientation: 'both' } }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { onClose } ) =>\n\t\t\t\t\t\t\tshowDropDown && (\n\t\t\t\t\t\t\t\t<div className=\"block-editor-block-switcher__container\">\n\t\t\t\t\t\t\t\t\t{ hasPatternTransformation && (\n\t\t\t\t\t\t\t\t\t\t<PatternTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tpatterns={ patterns }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ (\n\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\n\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonPatternTransform(\n\t\t\t\t\t\t\t\t\t\t\t\t\ttransformedBlocks\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\tonClose();\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) }\n\t\t\t\t\t\t\t\t\t{ hasPossibleBlockTransformations && (\n\t\t\t\t\t\t\t\t\t\t<BlockTransformationsMenu\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-switcher__transforms__menugroup\"\n\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations={\n\t\t\t\t\t\t\t\t\t\t\t\tpossibleBlockTransformations\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\t\t\t\t\tonSelect={ ( name ) => {\n\t\t\t\t\t\t\t\t\t\t\t\tonBlockTransform( name );\n\t\t\t\t\t\t\t\t\t\t\t\tonClose();\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) }\n\t\t\t\t\t\t\t\t\t{ hasBlockStyles && (\n\t\t\t\t\t\t\t\t\t\t<BlockStylesMenu\n\t\t\t\t\t\t\t\t\t\t\thoveredBlock={ blocks[ 0 ] }\n\t\t\t\t\t\t\t\t\t\t\tonSwitch={ onClose }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</DropdownMenu>\n\t\t\t\t) }\n\t\t\t</ToolbarItem>\n\t\t</ToolbarGroup>\n\t);\n};\n\nexport const BlockSwitcher = ( { clientIds } ) => {\n\tconst blocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds ),\n\t\t[ clientIds ]\n\t);\n\n\tif ( ! blocks.length || blocks.some( ( block ) => ! block ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockSwitcherDropdownMenu clientIds={ clientIds } blocks={ blocks } />\n\t);\n};\n\nexport default BlockSwitcher;\n"]}
@@ -33,6 +33,8 @@ var _blockPopover = _interopRequireDefault(require("../block-popover"));
33
33
 
34
34
  var _useBlockToolbarPopoverProps = _interopRequireDefault(require("./use-block-toolbar-popover-props"));
35
35
 
36
+ var _inserter = _interopRequireDefault(require("../inserter"));
37
+
36
38
  /**
37
39
  * External dependencies
38
40
  */
@@ -50,6 +52,7 @@ function selector(select) {
50
52
  isMultiSelecting,
51
53
  hasMultiSelection,
52
54
  isTyping,
55
+ __experimentalIsBlockInterfaceHidden: isBlockInterfaceHidden,
53
56
  getSettings,
54
57
  getLastMultiSelectedBlockClientId
55
58
  } = select(_store.store);
@@ -57,6 +60,7 @@ function selector(select) {
57
60
  editorMode: __unstableGetEditorMode(),
58
61
  isMultiSelecting: isMultiSelecting(),
59
62
  isTyping: isTyping(),
63
+ isBlockInterfaceHidden: isBlockInterfaceHidden(),
60
64
  hasFixedToolbar: getSettings().hasFixedToolbar,
61
65
  isDistractionFree: getSettings().isDistractionFree,
62
66
  lastClientId: hasMultiSelection() ? getLastMultiSelectedBlockClientId() : null
@@ -78,6 +82,7 @@ function SelectedBlockPopover(_ref) {
78
82
  editorMode,
79
83
  isMultiSelecting,
80
84
  isTyping,
85
+ isBlockInterfaceHidden,
81
86
  hasFixedToolbar,
82
87
  isDistractionFree,
83
88
  lastClientId
@@ -104,7 +109,7 @@ function SelectedBlockPopover(_ref) {
104
109
  } = (0, _data.useDispatch)(_store.store);
105
110
  const showEmptyBlockSideInserter = !isTyping && editorMode === 'edit' && isEmptyDefaultBlock;
106
111
  const shouldShowBreadcrumb = editorMode === 'navigation' || editorMode === 'zoom-out';
107
- const shouldShowContextualToolbar = editorMode === 'edit' && !hasFixedToolbar && isLargeViewport && !isMultiSelecting && !showEmptyBlockSideInserter && !isTyping;
112
+ const shouldShowContextualToolbar = editorMode === 'edit' && !hasFixedToolbar && isLargeViewport && !isMultiSelecting && !showEmptyBlockSideInserter && !isTyping && !isBlockInterfaceHidden;
108
113
  const canFocusHiddenToolbar = editorMode === 'edit' && !shouldShowContextualToolbar && !hasFixedToolbar && !isDistractionFree && !isEmptyDefaultBlock;
109
114
  (0, _keyboardShortcuts.useShortcut)('core/block-editor/focus-toolbar', () => {
110
115
  isToolbarForced.current = true;
@@ -123,11 +128,29 @@ function SelectedBlockPopover(_ref) {
123
128
  clientId
124
129
  });
125
130
 
126
- if (!shouldShowBreadcrumb && !shouldShowContextualToolbar) {
131
+ if (!shouldShowBreadcrumb && !shouldShowContextualToolbar && !showEmptyBlockSideInserter) {
127
132
  return null;
128
133
  }
129
134
 
130
- return (0, _element.createElement)(_blockPopover.default, (0, _extends2.default)({
135
+ return (0, _element.createElement)(_element.Fragment, null, showEmptyBlockSideInserter && (0, _element.createElement)(_blockPopover.default, (0, _extends2.default)({
136
+ clientId: capturingClientId || clientId,
137
+ __unstableCoverTarget: true,
138
+ bottomClientId: lastClientId,
139
+ className: (0, _classnames.default)('block-editor-block-list__block-side-inserter-popover', {
140
+ 'is-insertion-point-visible': isInsertionPointVisible
141
+ }),
142
+ __unstablePopoverSlot: __unstablePopoverSlot,
143
+ __unstableContentRef: __unstableContentRef,
144
+ resize: false,
145
+ shift: false
146
+ }, popoverProps), (0, _element.createElement)("div", {
147
+ className: "block-editor-block-list__empty-block-inserter"
148
+ }, (0, _element.createElement)(_inserter.default, {
149
+ position: "bottom right",
150
+ rootClientId: rootClientId,
151
+ clientId: clientId,
152
+ __experimentalIsQuick: true
153
+ }))), (shouldShowBreadcrumb || shouldShowContextualToolbar) && (0, _element.createElement)(_blockPopover.default, (0, _extends2.default)({
131
154
  clientId: capturingClientId || clientId,
132
155
  bottomClientId: lastClientId,
133
156
  className: (0, _classnames.default)('block-editor-block-list__block-popover', {
@@ -150,7 +173,7 @@ function SelectedBlockPopover(_ref) {
150
173
  }), shouldShowBreadcrumb && (0, _element.createElement)(_blockSelectionButton.default, {
151
174
  clientId: clientId,
152
175
  rootClientId: rootClientId
153
- }));
176
+ })));
154
177
  }
155
178
 
156
179
  function wrapperSelector(select) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["selector","select","__unstableGetEditorMode","isMultiSelecting","hasMultiSelection","isTyping","getSettings","getLastMultiSelectedBlockClientId","blockEditorStore","editorMode","hasFixedToolbar","isDistractionFree","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","showContents","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","popoverProps","contentElement","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","isNavigationMode","_isNavigationMode","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","settings","WrappedBlockPopover","selected"],"mappings":";;;;;;;;;AASA;;;;AANA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAOA,SAASA,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,uBADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,QAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA;AANK,MAOFN,MAAM,CAAEO,YAAF,CAPV;AAQA,SAAO;AACNC,IAAAA,UAAU,EAAEP,uBAAuB,EAD7B;AAENC,IAAAA,gBAAgB,EAAEA,gBAAgB,EAF5B;AAGNE,IAAAA,QAAQ,EAAEA,QAAQ,EAHZ;AAINK,IAAAA,eAAe,EAAEJ,WAAW,GAAGI,eAJzB;AAKNC,IAAAA,iBAAiB,EAAEL,WAAW,GAAGK,iBAL3B;AAMNC,IAAAA,YAAY,EAAER,iBAAiB,KAC5BG,iCAAiC,EADL,GAE5B;AARG,GAAP;A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BAJtB;AAKNmC,IAAAA,gBAAgB,EAAEC,iBAAiB,EAL7B;AAMN/B,IAAAA,mBAAmB,EAClBiC,IAAI,IAAI,sCAA0B;AAAEA,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAA1B,CAPH;AAQNhC,IAAAA;AARM,GAAP;AAUA;;AAEc,SAASsC,mBAAT,QAGX;AAAA,MAHyC;AAC5CrC,IAAAA,qBAD4C;AAE5CC,IAAAA;AAF4C,GAGzC;AACH,QAAMqC,QAAQ,GAAG,qBAAWjB,eAAX,EAA4B,EAA5B,CAAjB;;AAEA,MAAK,CAAEiB,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAM;AACL3C,IAAAA,QADK;AAELC,IAAAA,YAFK;AAGLkC,IAAAA,IAHK;AAILjC,IAAAA,mBAJK;AAKLE,IAAAA,iBALK;AAMLP,IAAAA,iBANK;AAOLmC,IAAAA;AAPK,MAQFW,QARJ;;AAUA,MAAK,CAAER,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,oBAAD;AACC,IAAA,QAAQ,EAAGnC,QADZ;AAEC,IAAA,YAAY,EAAGC,YAFhB;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,YAAY,EAAG,CAAEL,iBAAF,IAAuBmC,gBAJvC;AAKC,IAAA,iBAAiB,EAAG5B,iBALrB;AAMC,IAAA,qBAAqB,EAAGC,qBANzB;AAOC,IAAA,oBAAoB,EAAGC;AAPxB,IADD;AAWA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\nimport useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';\n\nfunction selector( select ) {\n\tconst {\n\t\t__unstableGetEditorMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\teditorMode: __unstableGetEditorMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisDistractionFree: getSettings().isDistractionFree,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tshowContents, // we may need to mount an empty popover because we reuse\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\teditorMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isToolbarForced = useRef( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && editorMode === 'edit' && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb =\n\t\teditorMode === 'navigation' || editorMode === 'zoom-out';\n\tconst shouldShowContextualToolbar =\n\t\teditorMode === 'edit' &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping;\n\tconst canFocusHiddenToolbar =\n\t\teditorMode === 'edit' &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isDistractionFree &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tconst popoverProps = useBlockToolbarPopoverProps( {\n\t\tcontentElement: __unstableContentRef?.current,\n\t\tclientId,\n\t} );\n\n\tif ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\tresize={ false }\n\t\t\t{ ...popoverProps }\n\t\t>\n\t\t\t{ shouldShowContextualToolbar && showContents && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockPopover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\tgetSettings,\n\t\tisNavigationMode: _isNavigationMode,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\tconst settings = getSettings();\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisDistractionFree: settings.isDistractionFree,\n\t\tisNavigationMode: _isNavigationMode(),\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t\tisDistractionFree,\n\t\tisNavigationMode,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tshowContents={ ! isDistractionFree || isNavigationMode }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["selector","select","__unstableGetEditorMode","isMultiSelecting","hasMultiSelection","isTyping","__experimentalIsBlockInterfaceHidden","isBlockInterfaceHidden","getSettings","getLastMultiSelectedBlockClientId","blockEditorStore","editorMode","hasFixedToolbar","isDistractionFree","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","showContents","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","popoverProps","contentElement","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","isNavigationMode","_isNavigationMode","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","settings","WrappedBlockPopover","selected"],"mappings":";;;;;;;;;AASA;;;;AANA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAQA,SAASA,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,uBADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,QAJK;AAKLC,IAAAA,oCAAoC,EAAEC,sBALjC;AAMLC,IAAAA,WANK;AAOLC,IAAAA;AAPK,MAQFR,MAAM,CAAES,YAAF,CARV;AAUA,SAAO;AACNC,IAAAA,UAAU,EAAET,uBAAuB,EAD7B;AAENC,IAAAA,gBAAgB,EAAEA,gBAAgB,EAF5B;AAGNE,IAAAA,QAAQ,EAAEA,QAAQ,EAHZ;AAINE,IAAAA,sBAAsB,EAAEA,sBAAsB,EAJxC;AAKNK,IAAAA,eAAe,EAAEJ,WAAW,GAAGI,eALzB;AAMNC,IAAAA,iBAAiB,EAAEL,WAAW,GAAGK,iBAN3B;AAONC,IAAAA,YAAY,EAAEV,iBAAiB,KAC5BK,iCAAiC,EADL,GAE5B;AATG,GAAP;AAWA;;AAED,SAASM,oBAAT,OAQI;AAAA,MAR2B;AAC9BC,IAAAA,QAD8B;AAE9BC,IAAAA,YAF8B;AAG9BC,IAAAA,mBAH8B;AAI9BC,IAAAA,YAJ8B;AAIhB;AACdC,IAAAA,iBAL8B;AAM9BC,IAAAA,qBAN8B;AAO9BC,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YAAY,EAAG,CAAEL,iBAAF,IAAuBmC,gBAJvC;AAKC,IAAA,iBAAiB,EAAG5B,iBALrB;AAMC,IAAA,qBAAqB,EAAGC,qBANzB;AAOC,IAAA,oBAAoB,EAAGC;AAPxB,IADD;AAWA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\nimport useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';\nimport Inserter from '../inserter';\n\nfunction selector( select ) {\n\tconst {\n\t\t__unstableGetEditorMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\t__experimentalIsBlockInterfaceHidden: isBlockInterfaceHidden,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\teditorMode: __unstableGetEditorMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\tisBlockInterfaceHidden: isBlockInterfaceHidden(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisDistractionFree: getSettings().isDistractionFree,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tshowContents, // we may need to mount an empty popover because we reuse\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\teditorMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\tisBlockInterfaceHidden,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isToolbarForced = useRef( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && editorMode === 'edit' && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb =\n\t\teditorMode === 'navigation' || editorMode === 'zoom-out';\n\tconst shouldShowContextualToolbar =\n\t\teditorMode === 'edit' &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping &&\n\t\t! isBlockInterfaceHidden;\n\tconst canFocusHiddenToolbar =\n\t\teditorMode === 'edit' &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isDistractionFree &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tconst popoverProps = useBlockToolbarPopoverProps( {\n\t\tcontentElement: __unstableContentRef?.current,\n\t\tclientId,\n\t} );\n\n\tif (\n\t\t! shouldShowBreadcrumb &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! showEmptyBlockSideInserter\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t<BlockPopover\n\t\t\t\t\tclientId={ capturingClientId || clientId }\n\t\t\t\t\t__unstableCoverTarget\n\t\t\t\t\tbottomClientId={ lastClientId }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-block-list__block-side-inserter-popover',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-insertion-point-visible':\n\t\t\t\t\t\t\t\tisInsertionPointVisible,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\tresize={ false }\n\t\t\t\t\tshift={ false }\n\t\t\t\t\t{ ...popoverProps }\n\t\t\t\t>\n\t\t\t\t\t<div className=\"block-editor-block-list__empty-block-inserter\">\n\t\t\t\t\t\t<Inserter\n\t\t\t\t\t\t\tposition=\"bottom right\"\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</BlockPopover>\n\t\t\t) }\n\t\t\t{ ( shouldShowBreadcrumb || shouldShowContextualToolbar ) && (\n\t\t\t\t<BlockPopover\n\t\t\t\t\tclientId={ capturingClientId || clientId }\n\t\t\t\t\tbottomClientId={ lastClientId }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-block-list__block-popover',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-insertion-point-visible':\n\t\t\t\t\t\t\t\tisInsertionPointVisible,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\tresize={ false }\n\t\t\t\t\t{ ...popoverProps }\n\t\t\t\t>\n\t\t\t\t\t{ shouldShowContextualToolbar && showContents && (\n\t\t\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t\t\t<BlockSelectionButton\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</BlockPopover>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\tgetSettings,\n\t\tisNavigationMode: _isNavigationMode,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\tconst settings = getSettings();\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisDistractionFree: settings.isDistractionFree,\n\t\tisNavigationMode: _isNavigationMode(),\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t\tisDistractionFree,\n\t\tisNavigationMode,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tshowContents={ ! isDistractionFree || isNavigationMode }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
@@ -88,7 +88,7 @@ const withEditorColorPalette = () => (0, _compose.createHigherOrderComponent)(Wr
88
88
 
89
89
 
90
90
  function createColorHOC(colorTypes, withColorPalette) {
91
- const colorMap = (0, _lodash.reduce)(colorTypes, (colorObject, colorType) => {
91
+ const colorMap = colorTypes.reduce((colorObject, colorType) => {
92
92
  return { ...colorObject,
93
93
  ...(typeof colorType === 'string' ? {
94
94
  [colorType]: (0, _lodash.kebabCase)(colorType)
@@ -114,7 +114,7 @@ function createColorHOC(colorTypes, withColorPalette) {
114
114
  }
115
115
 
116
116
  createSetters() {
117
- return (0, _lodash.reduce)(colorMap, (settersAccumulator, colorContext, colorAttributeName) => {
117
+ return Object.keys(colorMap).reduce((settersAccumulator, colorAttributeName) => {
118
118
  const upperFirstColorAttributeName = upperFirst(colorAttributeName);
119
119
  const customColorAttributeName = `custom${upperFirstColorAttributeName}`;
120
120
  settersAccumulator[`set${upperFirstColorAttributeName}`] = this.createSetColor(colorAttributeName, customColorAttributeName);
@@ -137,7 +137,8 @@ function createColorHOC(colorTypes, withColorPalette) {
137
137
  attributes,
138
138
  colors
139
139
  } = _ref2;
140
- return (0, _lodash.reduce)(colorMap, (newState, colorContext, colorAttributeName) => {
140
+ return Object.entries(colorMap).reduce((newState, _ref3) => {
141
+ let [colorAttributeName, colorContext] = _ref3;
141
142
  const colorObject = (0, _utils.getColorObjectByAttributeValues)(colors, attributes[colorAttributeName], attributes[`custom${upperFirst(colorAttributeName)}`]);
142
143
  const previousColorObject = previousState[colorAttributeName];
143
144
  const previousColor = previousColorObject === null || previousColorObject === void 0 ? void 0 : previousColorObject.color;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/colors/with-colors.js"],"names":["upperFirst","firstLetter","rest","toUpperCase","join","withCustomColorPalette","colorsArray","WrappedComponent","props","withEditorColorPalette","userPalette","themePalette","defaultPalette","allColors","createColorHOC","colorTypes","withColorPalette","colorMap","colorObject","colorType","Component","constructor","setters","createSetters","colorUtils","getMostReadableColor","bind","state","colorValue","colors","settersAccumulator","colorContext","colorAttributeName","upperFirstColorAttributeName","customColorAttributeName","createSetColor","setAttributes","slug","undefined","getDerivedStateFromProps","previousState","attributes","newState","previousColorObject","previousColor","color","class","render","createCustomColorsHOC","withColors"],"mappings":";;;;;;;;;;AAQA;;;;AALA;;AAMA;;AAKA;;AAMA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,UAAU,GAAG;AAAA,MAAE,CAAEC,WAAF,EAAe,GAAGC,IAAlB,CAAF;AAAA,SAClBD,WAAW,CAACE,WAAZ,KAA4BD,IAAI,CAACE,IAAL,CAAW,EAAX,CADV;AAAA,CAAnB;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMC,sBAAsB,GAAKC,WAAF,IAC9B,yCACGC,gBAAF,IAA0BC,KAAF,IACvB,4BAAC,gBAAD,6BAAuBA,KAAvB;AAA+B,EAAA,MAAM,EAAGF;AAAxC,GAFF,EAGC,wBAHD,CADD;AAOA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMG,sBAAsB,GAAG,MAC9B,yCACGF,gBAAF,IAA0BC,KAAF,IAAa;AACpC;AACA;AACA;AACA,QAAME,WAAW,GAAG,yBAAY,sBAAZ,CAApB;AACA,QAAMC,YAAY,GAAG,yBAAY,qBAAZ,CAArB;AACA,QAAMC,cAAc,GAAG,yBAAY,uBAAZ,CAAvB;AACA,QAAMC,SAAS,GAAG,sBACjB,MAAM,CACL,IAAKH,WAAW,IAAI,EAApB,CADK,EAEL,IAAKC,YAAY,IAAI,EAArB,CAFK,EAGL,IAAKC,cAAc,IAAI,EAAvB,CAHK,CADW,EAMjB,CAAEF,WAAF,EAAeC,YAAf,EAA6BC,cAA7B,CANiB,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,GAAiC,EAChC,GAAGd,WAD6B;AAEhC4B,cAAAA,KAAK,EAAE,8BACNf,YADM,EAENb,WAAW,CAACmB,IAFN;AAFyB,aAAjC;AAOA;;AACD,iBAAOK,QAAP;AACA,SArCK,EAsCN,EAtCM,CAAP;AAwCA;;AAEDK,MAAAA,MAAM,GAAG;AACR,eACC,4BAAC,gBAAD,6BAEK,KAAKvC,KAFV;AAGEqB,UAAAA,MAAM,EAAES;AAHV,WAIK,KAAKX,KAJV,EAKK,KAAKL,OALV;AAMEE,UAAAA,UAAU,EAAE,KAAKA;AANnB,WADD;AAWA;;AAtH6B,KAA/B;AAwHA,GA3Hc,CAAT,CAAP;AA6HA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASwB,qBAAT,CAAgC1C,WAAhC,EAA8C;AACpD,SAAO,YAAqB;AAC3B,UAAMU,gBAAgB,GAAGX,sBAAsB,CAAEC,WAAF,CAA/C;;AAD2B,sCAAhBS,UAAgB;AAAhBA,MAAAA,UAAgB;AAAA;;AAE3B,WAAO,yCACND,cAAc,CAAEC,UAAF,EAAcC,gBAAd,CADR,EAEN,kBAFM,CAAP;AAIA,GAND;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASiC,UAAT,GAAqC;AACnD,QAAMjC,gBAAgB,GAAGP,sBAAsB,EAA/C;;AADmD,qCAAbM,UAAa;AAAbA,IAAAA,UAAa;AAAA;;AAEnD,SAAO,yCACND,cAAc,CAAEC,UAAF,EAAcC,gBAAd,CADR,EAEN,YAFM,CAAP;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase, reduce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, Component } from '@wordpress/element';\nimport { compose, createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tgetMostReadableColor,\n} from './utils';\nimport useSetting from '../use-setting';\n\n/**\n * Capitalizes the first letter in a string.\n *\n * @param {string} str The string whose first letter the function will capitalize.\n *\n * @return {string} Capitalized string.\n */\nconst upperFirst = ( [ firstLetter, ...rest ] ) =>\n\tfirstLetter.toUpperCase() + rest.join( '' );\n\n/**\n * Higher order component factory for injecting the `colorsArray` argument as\n * the colors prop in the `withCustomColors` HOC.\n *\n * @param {Array} colorsArray An array of color objects.\n *\n * @return {Function} The higher order component.\n */\nconst withCustomColorPalette = ( colorsArray ) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) =>\n\t\t\t<WrappedComponent { ...props } colors={ colorsArray } />,\n\t\t'withCustomColorPalette'\n\t);\n\n/**\n * Higher order component factory for injecting the editor colors as the\n * `colors` prop in the `withColors` HOC.\n *\n * @return {Function} The higher order component.\n */\nconst withEditorColorPalette = () =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) => {\n\t\t\t// Some color settings have a special handling for deprecated flags in `useSetting`,\n\t\t\t// so we can't unwrap them by doing const { ... } = useSetting('color')\n\t\t\t// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.\n\t\t\tconst userPalette = useSetting( 'color.palette.custom' );\n\t\t\tconst themePalette = useSetting( 'color.palette.theme' );\n\t\t\tconst defaultPalette = useSetting( 'color.palette.default' );\n\t\t\tconst allColors = useMemo(\n\t\t\t\t() => [\n\t\t\t\t\t...( userPalette || [] ),\n\t\t\t\t\t...( themePalette || [] ),\n\t\t\t\t\t...( defaultPalette || [] ),\n\t\t\t\t],\n\t\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t\t);\n\t\t\treturn <WrappedComponent { ...props } colors={ allColors } />;\n\t\t},\n\t\t'withEditorColorPalette'\n\t);\n\n/**\n * Helper function used with `createHigherOrderComponent` to create\n * higher order components for managing color logic.\n *\n * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).\n * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.\n *\n * @return {WPComponent} The component that can be used as a HOC.\n */\nfunction createColorHOC( colorTypes, withColorPalette ) {\n\tconst colorMap = reduce(\n\t\tcolorTypes,\n\t\t( colorObject, colorType ) => {\n\t\t\treturn {\n\t\t\t\t...colorObject,\n\t\t\t\t...( typeof colorType === 'string'\n\t\t\t\t\t? { [ colorType ]: kebabCase( colorType ) }\n\t\t\t\t\t: colorType ),\n\t\t\t};\n\t\t},\n\t\t{}\n\t);\n\n\treturn compose( [\n\t\twithColorPalette,\n\t\t( WrappedComponent ) => {\n\t\t\treturn class extends Component {\n\t\t\t\tconstructor( props ) {\n\t\t\t\t\tsuper( props );\n\n\t\t\t\t\tthis.setters = this.createSetters();\n\t\t\t\t\tthis.colorUtils = {\n\t\t\t\t\t\tgetMostReadableColor:\n\t\t\t\t\t\t\tthis.getMostReadableColor.bind( this ),\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.state = {};\n\t\t\t\t}\n\n\t\t\t\tgetMostReadableColor( colorValue ) {\n\t\t\t\t\tconst { colors } = this.props;\n\t\t\t\t\treturn getMostReadableColor( colors, colorValue );\n\t\t\t\t}\n\n\t\t\t\tcreateSetters() {\n\t\t\t\t\treturn reduce(\n\t\t\t\t\t\tcolorMap,\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tsettersAccumulator,\n\t\t\t\t\t\t\tcolorContext,\n\t\t\t\t\t\t\tcolorAttributeName\n\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\tconst upperFirstColorAttributeName =\n\t\t\t\t\t\t\t\tupperFirst( colorAttributeName );\n\t\t\t\t\t\t\tconst customColorAttributeName = `custom${ upperFirstColorAttributeName }`;\n\t\t\t\t\t\t\tsettersAccumulator[\n\t\t\t\t\t\t\t\t`set${ upperFirstColorAttributeName }`\n\t\t\t\t\t\t\t] = this.createSetColor(\n\t\t\t\t\t\t\t\tcolorAttributeName,\n\t\t\t\t\t\t\t\tcustomColorAttributeName\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn settersAccumulator;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tcreateSetColor( colorAttributeName, customColorAttributeName ) {\n\t\t\t\t\treturn ( colorValue ) => {\n\t\t\t\t\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\t\t\t\t\tthis.props.colors,\n\t\t\t\t\t\t\tcolorValue\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.props.setAttributes( {\n\t\t\t\t\t\t\t[ colorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? colorObject.slug\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t[ customColorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t: colorValue,\n\t\t\t\t\t\t} );\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tstatic getDerivedStateFromProps(\n\t\t\t\t\t{ attributes, colors },\n\t\t\t\t\tpreviousState\n\t\t\t\t) {\n\t\t\t\t\treturn reduce(\n\t\t\t\t\t\tcolorMap,\n\t\t\t\t\t\t( newState, colorContext, colorAttributeName ) => {\n\t\t\t\t\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\tcolors,\n\t\t\t\t\t\t\t\tattributes[ colorAttributeName ],\n\t\t\t\t\t\t\t\tattributes[\n\t\t\t\t\t\t\t\t\t`custom${ upperFirst(\n\t\t\t\t\t\t\t\t\t\tcolorAttributeName\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\n\t\t\t\t\t\t\tconst previousColorObject =\n\t\t\t\t\t\t\t\tpreviousState[ colorAttributeName ];\n\t\t\t\t\t\t\tconst previousColor = previousColorObject?.color;\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * The \"and previousColorObject\" condition checks that a previous color object was already computed.\n\t\t\t\t\t\t\t * At the start previousColorObject and colorValue are both equal to undefined\n\t\t\t\t\t\t\t * bus as previousColorObject does not exist we should compute the object.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpreviousColor === colorObject.color &&\n\t\t\t\t\t\t\t\tpreviousColorObject\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] =\n\t\t\t\t\t\t\t\t\tpreviousColorObject;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] = {\n\t\t\t\t\t\t\t\t\t...colorObject,\n\t\t\t\t\t\t\t\t\tclass: getColorClassName(\n\t\t\t\t\t\t\t\t\t\tcolorContext,\n\t\t\t\t\t\t\t\t\t\tcolorObject.slug\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\treturn newState;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\trender() {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\t...this.props,\n\t\t\t\t\t\t\t\tcolors: undefined,\n\t\t\t\t\t\t\t\t...this.state,\n\t\t\t\t\t\t\t\t...this.setters,\n\t\t\t\t\t\t\t\tcolorUtils: this.colorUtils,\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}\n\t\t\t};\n\t\t},\n\t] );\n}\n\n/**\n * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic\n * for class generation color value, retrieval and color attribute setting.\n *\n * Use this higher-order component to work with a custom set of colors.\n *\n * @example\n *\n * ```jsx\n * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];\n * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );\n * // ...\n * export default compose(\n * withCustomColors( 'backgroundColor', 'borderColor' ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).\n *\n * @return {Function} Higher-order component.\n */\nexport function createCustomColorsHOC( colorsArray ) {\n\treturn ( ...colorTypes ) => {\n\t\tconst withColorPalette = withCustomColorPalette( colorsArray );\n\t\treturn createHigherOrderComponent(\n\t\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t\t'withCustomColors'\n\t\t);\n\t};\n}\n\n/**\n * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.\n *\n * For use with the default editor/theme color palette.\n *\n * @example\n *\n * ```jsx\n * export default compose(\n * withColors( 'backgroundColor', { textColor: 'color' } ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,\n * it should contain the color attribute name as key and the color context as value.\n * If the argument is a string the value should be the color attribute name,\n * the color context is computed by applying a kebab case transform to the value.\n * Color context represents the context/place where the color is going to be used.\n * The class name of the color is generated using 'has' followed by the color name\n * and ending with the color context all in kebab case e.g: has-green-background-color.\n *\n * @return {Function} Higher-order component.\n */\nexport default function withColors( ...colorTypes ) {\n\tconst withColorPalette = withEditorColorPalette();\n\treturn createHigherOrderComponent(\n\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t'withColors'\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/colors/with-colors.js"],"names":["upperFirst","firstLetter","rest","toUpperCase","join","withCustomColorPalette","colorsArray","WrappedComponent","props","withEditorColorPalette","userPalette","themePalette","defaultPalette","allColors","createColorHOC","colorTypes","withColorPalette","colorMap","reduce","colorObject","colorType","Component","constructor","setters","createSetters","colorUtils","getMostReadableColor","bind","state","colorValue","colors","Object","keys","settersAccumulator","colorAttributeName","upperFirstColorAttributeName","customColorAttributeName","createSetColor","setAttributes","slug","undefined","getDerivedStateFromProps","previousState","attributes","entries","newState","colorContext","previousColorObject","previousColor","color","class","render","createCustomColorsHOC","withColors"],"mappings":";;;;;;;;;;AAQA;;;;AALA;;AAMA;;AAKA;;AAMA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,UAAU,GAAG;AAAA,MAAE,CAAEC,WAAF,EAAe,GAAGC,IAAlB,CAAF;AAAA,SAClBD,WAAW,CAACE,WAAZ,KAA4BD,IAAI,CAACE,IAAL,CAAW,EAAX,CADV;AAAA,CAAnB;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMC,sBAAsB,GAAKC,WAAF,IAC9B,yCACGC,gBAAF,IAA0BC,KAAF,IACvB,4BAAC,gBAAD,6BAAuBA,KAAvB;AAA+B,EAAA,MAAM,EAAGF;AAAxC,GAFF,EAGC,wBAHD,CADD;AAOA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMG,sBAAsB,GAAG,MAC9B,yCACGF,gBAAF,IAA0BC,KAAF,IAAa;AACpC;AACA;AACA;AACA,QAAME,WAAW,GAAG,yBAAY,sBAAZ,CAApB;AACA,QAAMC,YAAY,GAAG,yBAAY,qBAAZ,CAArB;AACA,QAAMC,cAAc,GAAG,yBAAY,uBAAZ,CAAvB;AACA,QAAMC,SAAS,GAAG,sBACjB,MAAM,CACL,IAAKH,WAAW,IAAI,EAApB,CADK,EAEL,IAAKC,YAAY,IAAI,EAArB,CAFK,EAGL,IAAKC,cAAc,IAAI,EAAvB,CAHK,CADW,EAMjB,CAAEF,WAAF,EAAeC,YAAf,EAA6BC,cAA7B,CANiB,CAAlB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kBAAF,CAAR,GACCa,mBADD;AAEA,WAND,MAMO;AACNF,YAAAA,QAAQ,CAAEX,kBAAF,CAAR,GAAiC,EAChC,GAAGf,WAD6B;AAEhC+B,cAAAA,KAAK,EAAE,8BACNJ,YADM,EAEN3B,WAAW,CAACoB,IAFN;AAFyB,aAAjC;AAOA;;AACD,iBAAOM,QAAP;AACA,SApCK,EAqCN,EArCM,CAAP;AAuCA;;AAEDM,MAAAA,MAAM,GAAG;AACR,eACC,4BAAC,gBAAD,6BAEK,KAAK3C,KAFV;AAGEsB,UAAAA,MAAM,EAAEU;AAHV,WAIK,KAAKZ,KAJV,EAKK,KAAKL,OALV;AAMEE,UAAAA,UAAU,EAAE,KAAKA;AANnB,WADD;AAWA;;AAhH6B,KAA/B;AAkHA,GArHc,CAAT,CAAP;AAuHA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAAS2B,qBAAT,CAAgC9C,WAAhC,EAA8C;AACpD,SAAO,YAAqB;AAC3B,UAAMU,gBAAgB,GAAGX,sBAAsB,CAAEC,WAAF,CAA/C;;AAD2B,sCAAhBS,UAAgB;AAAhBA,MAAAA,UAAgB;AAAA;;AAE3B,WAAO,yCACND,cAAc,CAAEC,UAAF,EAAcC,gBAAd,CADR,EAEN,kBAFM,CAAP;AAIA,GAND;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASqC,UAAT,GAAqC;AACnD,QAAMrC,gBAAgB,GAAGP,sBAAsB,EAA/C;;AADmD,qCAAbM,UAAa;AAAbA,IAAAA,UAAa;AAAA;;AAEnD,SAAO,yCACND,cAAc,CAAEC,UAAF,EAAcC,gBAAd,CADR,EAEN,YAFM,CAAP;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, Component } from '@wordpress/element';\nimport { compose, createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tgetMostReadableColor,\n} from './utils';\nimport useSetting from '../use-setting';\n\n/**\n * Capitalizes the first letter in a string.\n *\n * @param {string} str The string whose first letter the function will capitalize.\n *\n * @return {string} Capitalized string.\n */\nconst upperFirst = ( [ firstLetter, ...rest ] ) =>\n\tfirstLetter.toUpperCase() + rest.join( '' );\n\n/**\n * Higher order component factory for injecting the `colorsArray` argument as\n * the colors prop in the `withCustomColors` HOC.\n *\n * @param {Array} colorsArray An array of color objects.\n *\n * @return {Function} The higher order component.\n */\nconst withCustomColorPalette = ( colorsArray ) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) =>\n\t\t\t<WrappedComponent { ...props } colors={ colorsArray } />,\n\t\t'withCustomColorPalette'\n\t);\n\n/**\n * Higher order component factory for injecting the editor colors as the\n * `colors` prop in the `withColors` HOC.\n *\n * @return {Function} The higher order component.\n */\nconst withEditorColorPalette = () =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) => {\n\t\t\t// Some color settings have a special handling for deprecated flags in `useSetting`,\n\t\t\t// so we can't unwrap them by doing const { ... } = useSetting('color')\n\t\t\t// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.\n\t\t\tconst userPalette = useSetting( 'color.palette.custom' );\n\t\t\tconst themePalette = useSetting( 'color.palette.theme' );\n\t\t\tconst defaultPalette = useSetting( 'color.palette.default' );\n\t\t\tconst allColors = useMemo(\n\t\t\t\t() => [\n\t\t\t\t\t...( userPalette || [] ),\n\t\t\t\t\t...( themePalette || [] ),\n\t\t\t\t\t...( defaultPalette || [] ),\n\t\t\t\t],\n\t\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t\t);\n\t\t\treturn <WrappedComponent { ...props } colors={ allColors } />;\n\t\t},\n\t\t'withEditorColorPalette'\n\t);\n\n/**\n * Helper function used with `createHigherOrderComponent` to create\n * higher order components for managing color logic.\n *\n * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).\n * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.\n *\n * @return {WPComponent} The component that can be used as a HOC.\n */\nfunction createColorHOC( colorTypes, withColorPalette ) {\n\tconst colorMap = colorTypes.reduce( ( colorObject, colorType ) => {\n\t\treturn {\n\t\t\t...colorObject,\n\t\t\t...( typeof colorType === 'string'\n\t\t\t\t? { [ colorType ]: kebabCase( colorType ) }\n\t\t\t\t: colorType ),\n\t\t};\n\t}, {} );\n\n\treturn compose( [\n\t\twithColorPalette,\n\t\t( WrappedComponent ) => {\n\t\t\treturn class extends Component {\n\t\t\t\tconstructor( props ) {\n\t\t\t\t\tsuper( props );\n\n\t\t\t\t\tthis.setters = this.createSetters();\n\t\t\t\t\tthis.colorUtils = {\n\t\t\t\t\t\tgetMostReadableColor:\n\t\t\t\t\t\t\tthis.getMostReadableColor.bind( this ),\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.state = {};\n\t\t\t\t}\n\n\t\t\t\tgetMostReadableColor( colorValue ) {\n\t\t\t\t\tconst { colors } = this.props;\n\t\t\t\t\treturn getMostReadableColor( colors, colorValue );\n\t\t\t\t}\n\n\t\t\t\tcreateSetters() {\n\t\t\t\t\treturn Object.keys( colorMap ).reduce(\n\t\t\t\t\t\t( settersAccumulator, colorAttributeName ) => {\n\t\t\t\t\t\t\tconst upperFirstColorAttributeName =\n\t\t\t\t\t\t\t\tupperFirst( colorAttributeName );\n\t\t\t\t\t\t\tconst customColorAttributeName = `custom${ upperFirstColorAttributeName }`;\n\t\t\t\t\t\t\tsettersAccumulator[\n\t\t\t\t\t\t\t\t`set${ upperFirstColorAttributeName }`\n\t\t\t\t\t\t\t] = this.createSetColor(\n\t\t\t\t\t\t\t\tcolorAttributeName,\n\t\t\t\t\t\t\t\tcustomColorAttributeName\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn settersAccumulator;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tcreateSetColor( colorAttributeName, customColorAttributeName ) {\n\t\t\t\t\treturn ( colorValue ) => {\n\t\t\t\t\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\t\t\t\t\tthis.props.colors,\n\t\t\t\t\t\t\tcolorValue\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.props.setAttributes( {\n\t\t\t\t\t\t\t[ colorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? colorObject.slug\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t[ customColorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t: colorValue,\n\t\t\t\t\t\t} );\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tstatic getDerivedStateFromProps(\n\t\t\t\t\t{ attributes, colors },\n\t\t\t\t\tpreviousState\n\t\t\t\t) {\n\t\t\t\t\treturn Object.entries( colorMap ).reduce(\n\t\t\t\t\t\t( newState, [ colorAttributeName, colorContext ] ) => {\n\t\t\t\t\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\tcolors,\n\t\t\t\t\t\t\t\tattributes[ colorAttributeName ],\n\t\t\t\t\t\t\t\tattributes[\n\t\t\t\t\t\t\t\t\t`custom${ upperFirst(\n\t\t\t\t\t\t\t\t\t\tcolorAttributeName\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\n\t\t\t\t\t\t\tconst previousColorObject =\n\t\t\t\t\t\t\t\tpreviousState[ colorAttributeName ];\n\t\t\t\t\t\t\tconst previousColor = previousColorObject?.color;\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * The \"and previousColorObject\" condition checks that a previous color object was already computed.\n\t\t\t\t\t\t\t * At the start previousColorObject and colorValue are both equal to undefined\n\t\t\t\t\t\t\t * bus as previousColorObject does not exist we should compute the object.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpreviousColor === colorObject.color &&\n\t\t\t\t\t\t\t\tpreviousColorObject\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] =\n\t\t\t\t\t\t\t\t\tpreviousColorObject;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] = {\n\t\t\t\t\t\t\t\t\t...colorObject,\n\t\t\t\t\t\t\t\t\tclass: getColorClassName(\n\t\t\t\t\t\t\t\t\t\tcolorContext,\n\t\t\t\t\t\t\t\t\t\tcolorObject.slug\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\treturn newState;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\trender() {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\t...this.props,\n\t\t\t\t\t\t\t\tcolors: undefined,\n\t\t\t\t\t\t\t\t...this.state,\n\t\t\t\t\t\t\t\t...this.setters,\n\t\t\t\t\t\t\t\tcolorUtils: this.colorUtils,\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}\n\t\t\t};\n\t\t},\n\t] );\n}\n\n/**\n * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic\n * for class generation color value, retrieval and color attribute setting.\n *\n * Use this higher-order component to work with a custom set of colors.\n *\n * @example\n *\n * ```jsx\n * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];\n * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );\n * // ...\n * export default compose(\n * withCustomColors( 'backgroundColor', 'borderColor' ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).\n *\n * @return {Function} Higher-order component.\n */\nexport function createCustomColorsHOC( colorsArray ) {\n\treturn ( ...colorTypes ) => {\n\t\tconst withColorPalette = withCustomColorPalette( colorsArray );\n\t\treturn createHigherOrderComponent(\n\t\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t\t'withCustomColors'\n\t\t);\n\t};\n}\n\n/**\n * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.\n *\n * For use with the default editor/theme color palette.\n *\n * @example\n *\n * ```jsx\n * export default compose(\n * withColors( 'backgroundColor', { textColor: 'color' } ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,\n * it should contain the color attribute name as key and the color context as value.\n * If the argument is a string the value should be the color attribute name,\n * the color context is computed by applying a kebab case transform to the value.\n * Color context represents the context/place where the color is going to be used.\n * The class name of the color is generated using 'has' followed by the color name\n * and ending with the color context all in kebab case e.g: has-green-background-color.\n *\n * @return {Function} Higher-order component.\n */\nexport default function withColors( ...colorTypes ) {\n\tconst withColorPalette = withEditorColorPalette();\n\treturn createHigherOrderComponent(\n\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t'withColors'\n\t);\n}\n"]}