@wordpress/block-editor 12.12.0 → 12.13.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 (287) hide show
  1. package/CHANGELOG.md +12 -10
  2. package/README.md +35 -3
  3. package/build/components/block-alignment-control/use-available-alignments.js +30 -28
  4. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  5. package/build/components/block-list/block.native.js +4 -4
  6. package/build/components/block-list/block.native.js.map +1 -1
  7. package/build/components/block-list/layout.js +2 -3
  8. package/build/components/block-list/layout.js.map +1 -1
  9. package/build/components/border-radius-control/index.js +3 -2
  10. package/build/components/border-radius-control/index.js.map +1 -1
  11. package/build/components/color-palette/with-color-context.js +6 -6
  12. package/build/components/color-palette/with-color-context.js.map +1 -1
  13. package/build/components/colors/with-colors.js +2 -8
  14. package/build/components/colors/with-colors.js.map +1 -1
  15. package/build/components/colors-gradients/control.js +6 -7
  16. package/build/components/colors-gradients/control.js.map +1 -1
  17. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -13
  18. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  19. package/build/components/font-family/index.js +2 -3
  20. package/build/components/font-family/index.js.map +1 -1
  21. package/build/components/font-sizes/font-size-picker.js +3 -5
  22. package/build/components/font-sizes/font-size-picker.js.map +1 -1
  23. package/build/components/font-sizes/with-font-sizes.js +3 -4
  24. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  25. package/build/components/global-styles/filters-panel.js +7 -8
  26. package/build/components/global-styles/filters-panel.js.map +1 -1
  27. package/build/components/global-styles/image-settings-panel.js +2 -2
  28. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  29. package/build/components/global-styles/typography-panel.js +1 -1
  30. package/build/components/global-styles/typography-panel.js.map +1 -1
  31. package/build/components/gradients/use-gradient.js +2 -5
  32. package/build/components/gradients/use-gradient.js.map +1 -1
  33. package/build/components/height-control/index.js +3 -3
  34. package/build/components/height-control/index.js.map +1 -1
  35. package/build/components/index.js +9 -2
  36. package/build/components/index.js.map +1 -1
  37. package/build/components/index.native.js +9 -2
  38. package/build/components/index.native.js.map +1 -1
  39. package/build/components/inner-blocks/index.js +2 -2
  40. package/build/components/inner-blocks/index.js.map +1 -1
  41. package/build/components/letter-spacing-control/index.js +3 -3
  42. package/build/components/letter-spacing-control/index.js.map +1 -1
  43. package/build/components/link-control/search-item.js +11 -0
  44. package/build/components/link-control/search-item.js.map +1 -1
  45. package/build/components/link-control/search-results.js +2 -1
  46. package/build/components/link-control/search-results.js.map +1 -1
  47. package/build/components/link-control/use-search-handler.js +10 -5
  48. package/build/components/link-control/use-search-handler.js.map +1 -1
  49. package/build/components/resizable-box-popover/index.js +1 -1
  50. package/build/components/resizable-box-popover/index.js.map +1 -1
  51. package/build/components/rich-text/index.js +1 -1
  52. package/build/components/rich-text/index.js.map +1 -1
  53. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -3
  54. package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  55. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -3
  56. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  57. package/build/components/unit-control/index.js +3 -3
  58. package/build/components/unit-control/index.js.map +1 -1
  59. package/build/components/use-block-commands/index.js +6 -1
  60. package/build/components/use-block-commands/index.js.map +1 -1
  61. package/build/components/use-settings/index.js +212 -0
  62. package/build/components/use-settings/index.js.map +1 -0
  63. package/build/hooks/align.js +51 -35
  64. package/build/hooks/align.js.map +1 -1
  65. package/build/hooks/anchor.js +37 -32
  66. package/build/hooks/anchor.js.map +1 -1
  67. package/build/hooks/background.js +4 -4
  68. package/build/hooks/background.js.map +1 -1
  69. package/build/hooks/color.js +2 -4
  70. package/build/hooks/color.js.map +1 -1
  71. package/build/hooks/duotone.js +10 -9
  72. package/build/hooks/duotone.js.map +1 -1
  73. package/build/hooks/font-size.js +4 -4
  74. package/build/hooks/font-size.js.map +1 -1
  75. package/build/hooks/layout.js +10 -11
  76. package/build/hooks/layout.js.map +1 -1
  77. package/build/hooks/line-height.js +3 -3
  78. package/build/hooks/line-height.js.map +1 -1
  79. package/build/hooks/position.js +2 -3
  80. package/build/hooks/position.js.map +1 -1
  81. package/build/hooks/use-color-props.js +3 -11
  82. package/build/hooks/use-color-props.js.map +1 -1
  83. package/build/hooks/utils.js +1 -42
  84. package/build/hooks/utils.js.map +1 -1
  85. package/build/layouts/constrained.js +3 -3
  86. package/build/layouts/constrained.js.map +1 -1
  87. package/build/utils/object.js +4 -1
  88. package/build/utils/object.js.map +1 -1
  89. package/build/utils/transform-styles/index.js +19 -24
  90. package/build/utils/transform-styles/index.js.map +1 -1
  91. package/build-module/components/block-alignment-control/use-available-alignments.js +30 -28
  92. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  93. package/build-module/components/block-list/block.native.js +4 -4
  94. package/build-module/components/block-list/block.native.js.map +1 -1
  95. package/build-module/components/block-list/layout.js +2 -2
  96. package/build-module/components/block-list/layout.js.map +1 -1
  97. package/build-module/components/border-radius-control/index.js +3 -2
  98. package/build-module/components/border-radius-control/index.js.map +1 -1
  99. package/build-module/components/color-palette/with-color-context.js +6 -5
  100. package/build-module/components/color-palette/with-color-context.js.map +1 -1
  101. package/build-module/components/colors/with-colors.js +2 -7
  102. package/build-module/components/colors/with-colors.js.map +1 -1
  103. package/build-module/components/colors-gradients/control.js +6 -7
  104. package/build-module/components/colors-gradients/control.js.map +1 -1
  105. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -12
  106. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  107. package/build-module/components/font-family/index.js +2 -2
  108. package/build-module/components/font-family/index.js.map +1 -1
  109. package/build-module/components/font-sizes/font-size-picker.js +3 -4
  110. package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
  111. package/build-module/components/font-sizes/with-font-sizes.js +3 -3
  112. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  113. package/build-module/components/global-styles/filters-panel.js +7 -8
  114. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  115. package/build-module/components/global-styles/image-settings-panel.js +2 -2
  116. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  117. package/build-module/components/global-styles/typography-panel.js +1 -1
  118. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  119. package/build-module/components/gradients/use-gradient.js +2 -4
  120. package/build-module/components/gradients/use-gradient.js.map +1 -1
  121. package/build-module/components/height-control/index.js +3 -2
  122. package/build-module/components/height-control/index.js.map +1 -1
  123. package/build-module/components/index.js +1 -1
  124. package/build-module/components/index.js.map +1 -1
  125. package/build-module/components/index.native.js +1 -1
  126. package/build-module/components/index.native.js.map +1 -1
  127. package/build-module/components/inner-blocks/index.js +2 -2
  128. package/build-module/components/inner-blocks/index.js.map +1 -1
  129. package/build-module/components/letter-spacing-control/index.js +3 -2
  130. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  131. package/build-module/components/link-control/search-item.js +12 -1
  132. package/build-module/components/link-control/search-item.js.map +1 -1
  133. package/build-module/components/link-control/search-results.js +2 -1
  134. package/build-module/components/link-control/search-results.js.map +1 -1
  135. package/build-module/components/link-control/use-search-handler.js +10 -5
  136. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  137. package/build-module/components/resizable-box-popover/index.js +1 -1
  138. package/build-module/components/resizable-box-popover/index.js.map +1 -1
  139. package/build-module/components/rich-text/index.js +1 -1
  140. package/build-module/components/rich-text/index.js.map +1 -1
  141. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -2
  142. package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
  143. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -2
  144. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  145. package/build-module/components/unit-control/index.js +3 -2
  146. package/build-module/components/unit-control/index.js.map +1 -1
  147. package/build-module/components/use-block-commands/index.js +5 -1
  148. package/build-module/components/use-block-commands/index.js.map +1 -1
  149. package/build-module/components/use-settings/index.js +203 -0
  150. package/build-module/components/use-settings/index.js.map +1 -0
  151. package/build-module/hooks/align.js +51 -35
  152. package/build-module/hooks/align.js.map +1 -1
  153. package/build-module/hooks/anchor.js +37 -32
  154. package/build-module/hooks/anchor.js.map +1 -1
  155. package/build-module/hooks/background.js +4 -4
  156. package/build-module/hooks/background.js.map +1 -1
  157. package/build-module/hooks/color.js +2 -4
  158. package/build-module/hooks/color.js.map +1 -1
  159. package/build-module/hooks/duotone.js +11 -10
  160. package/build-module/hooks/duotone.js.map +1 -1
  161. package/build-module/hooks/font-size.js +4 -4
  162. package/build-module/hooks/font-size.js.map +1 -1
  163. package/build-module/hooks/layout.js +10 -11
  164. package/build-module/hooks/layout.js.map +1 -1
  165. package/build-module/hooks/line-height.js +3 -3
  166. package/build-module/hooks/line-height.js.map +1 -1
  167. package/build-module/hooks/position.js +2 -3
  168. package/build-module/hooks/position.js.map +1 -1
  169. package/build-module/hooks/use-color-props.js +3 -11
  170. package/build-module/hooks/use-color-props.js.map +1 -1
  171. package/build-module/hooks/utils.js +2 -43
  172. package/build-module/hooks/utils.js.map +1 -1
  173. package/build-module/layouts/constrained.js +3 -2
  174. package/build-module/layouts/constrained.js.map +1 -1
  175. package/build-module/utils/object.js +3 -1
  176. package/build-module/utils/object.js.map +1 -1
  177. package/build-module/utils/transform-styles/index.js +20 -24
  178. package/build-module/utils/transform-styles/index.js.map +1 -1
  179. package/build-style/style-rtl.css +13 -6
  180. package/build-style/style.css +13 -6
  181. package/package.json +36 -34
  182. package/src/components/block-alignment-control/use-available-alignments.js +49 -34
  183. package/src/components/block-list/block.native.js +4 -4
  184. package/src/components/block-list/layout.js +2 -2
  185. package/src/components/block-styles/style.scss +1 -1
  186. package/src/components/border-radius-control/index.js +3 -2
  187. package/src/components/color-palette/with-color-context.js +9 -9
  188. package/src/components/colors/with-colors.js +6 -7
  189. package/src/components/colors-gradients/control.js +10 -7
  190. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +29 -15
  191. package/src/components/font-family/index.js +2 -2
  192. package/src/components/font-sizes/font-size-picker.js +6 -4
  193. package/src/components/font-sizes/with-font-sizes.js +3 -5
  194. package/src/components/global-styles/filters-panel.js +9 -15
  195. package/src/components/global-styles/image-settings-panel.js +2 -2
  196. package/src/components/global-styles/typography-panel.js +1 -1
  197. package/src/components/gradients/use-gradient.js +10 -4
  198. package/src/components/height-control/index.js +3 -2
  199. package/src/components/index.js +1 -1
  200. package/src/components/index.native.js +1 -1
  201. package/src/components/inner-blocks/index.js +2 -2
  202. package/src/components/inserter/style.scss +9 -1
  203. package/src/components/letter-spacing-control/index.js +3 -2
  204. package/src/components/link-control/search-item.js +14 -0
  205. package/src/components/link-control/search-results.js +1 -0
  206. package/src/components/link-control/use-search-handler.js +22 -15
  207. package/src/components/resizable-box-popover/index.js +1 -1
  208. package/src/components/rich-text/index.js +1 -1
  209. package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +7 -5
  210. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +3 -2
  211. package/src/components/unit-control/index.js +3 -8
  212. package/src/components/use-block-commands/index.js +2 -1
  213. package/src/components/{use-setting → use-settings}/README.md +9 -10
  214. package/src/components/use-settings/index.js +272 -0
  215. package/src/components/{use-setting → use-settings}/test/index.js +47 -5
  216. package/src/hooks/align.js +79 -54
  217. package/src/hooks/anchor.js +75 -65
  218. package/src/hooks/background.js +7 -9
  219. package/src/hooks/color.js +7 -4
  220. package/src/hooks/duotone.js +24 -19
  221. package/src/hooks/font-size.js +4 -4
  222. package/src/hooks/layout.js +11 -11
  223. package/src/hooks/line-height.js +3 -3
  224. package/src/hooks/position.js +5 -3
  225. package/src/hooks/use-color-props.js +21 -14
  226. package/src/hooks/utils.js +88 -43
  227. package/src/layouts/constrained.js +3 -8
  228. package/src/utils/object.js +4 -1
  229. package/src/utils/test/__snapshots__/transform-styles.js.snap +103 -0
  230. package/src/utils/test/transform-styles.js +217 -0
  231. package/src/utils/transform-styles/index.js +25 -25
  232. package/build/components/use-setting/index.js +0 -161
  233. package/build/components/use-setting/index.js.map +0 -1
  234. package/build/utils/transform-styles/ast/index.js +0 -21
  235. package/build/utils/transform-styles/ast/index.js.map +0 -1
  236. package/build/utils/transform-styles/ast/parse.js +0 -660
  237. package/build/utils/transform-styles/ast/parse.js.map +0 -1
  238. package/build/utils/transform-styles/ast/stringify/compiler.js +0 -52
  239. package/build/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
  240. package/build/utils/transform-styles/ast/stringify/compress.js +0 -178
  241. package/build/utils/transform-styles/ast/stringify/compress.js.map +0 -1
  242. package/build/utils/transform-styles/ast/stringify/identity.js +0 -207
  243. package/build/utils/transform-styles/ast/stringify/identity.js.map +0 -1
  244. package/build/utils/transform-styles/ast/stringify/index.js +0 -36
  245. package/build/utils/transform-styles/ast/stringify/index.js.map +0 -1
  246. package/build/utils/transform-styles/transforms/url-rewrite.js +0 -130
  247. package/build/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
  248. package/build/utils/transform-styles/transforms/wrap.js +0 -59
  249. package/build/utils/transform-styles/transforms/wrap.js.map +0 -1
  250. package/build/utils/transform-styles/traverse.js +0 -37
  251. package/build/utils/transform-styles/traverse.js.map +0 -1
  252. package/build-module/components/use-setting/index.js +0 -154
  253. package/build-module/components/use-setting/index.js.map +0 -1
  254. package/build-module/utils/transform-styles/ast/index.js +0 -6
  255. package/build-module/utils/transform-styles/ast/index.js.map +0 -1
  256. package/build-module/utils/transform-styles/ast/parse.js +0 -654
  257. package/build-module/utils/transform-styles/ast/parse.js.map +0 -1
  258. package/build-module/utils/transform-styles/ast/stringify/compiler.js +0 -49
  259. package/build-module/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
  260. package/build-module/utils/transform-styles/ast/stringify/compress.js +0 -176
  261. package/build-module/utils/transform-styles/ast/stringify/compress.js.map +0 -1
  262. package/build-module/utils/transform-styles/ast/stringify/identity.js +0 -206
  263. package/build-module/utils/transform-styles/ast/stringify/identity.js.map +0 -1
  264. package/build-module/utils/transform-styles/ast/stringify/index.js +0 -29
  265. package/build-module/utils/transform-styles/ast/stringify/index.js.map +0 -1
  266. package/build-module/utils/transform-styles/transforms/url-rewrite.js +0 -123
  267. package/build-module/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
  268. package/build-module/utils/transform-styles/transforms/wrap.js +0 -52
  269. package/build-module/utils/transform-styles/transforms/wrap.js.map +0 -1
  270. package/build-module/utils/transform-styles/traverse.js +0 -28
  271. package/build-module/utils/transform-styles/traverse.js.map +0 -1
  272. package/src/components/use-setting/index.js +0 -218
  273. package/src/utils/transform-styles/ast/index.js +0 -5
  274. package/src/utils/transform-styles/ast/parse.js +0 -732
  275. package/src/utils/transform-styles/ast/stringify/compiler.js +0 -50
  276. package/src/utils/transform-styles/ast/stringify/compress.js +0 -238
  277. package/src/utils/transform-styles/ast/stringify/identity.js +0 -286
  278. package/src/utils/transform-styles/ast/stringify/index.js +0 -32
  279. package/src/utils/transform-styles/test/__snapshots__/traverse.js.snap +0 -7
  280. package/src/utils/transform-styles/test/traverse.js +0 -24
  281. package/src/utils/transform-styles/transforms/test/__snapshots__/url-rewrite.js.snap +0 -25
  282. package/src/utils/transform-styles/transforms/test/__snapshots__/wrap.js.snap +0 -64
  283. package/src/utils/transform-styles/transforms/test/url-rewrite.js +0 -39
  284. package/src/utils/transform-styles/transforms/test/wrap.js +0 -95
  285. package/src/utils/transform-styles/transforms/url-rewrite.js +0 -139
  286. package/src/utils/transform-styles/transforms/wrap.js +0 -56
  287. package/src/utils/transform-styles/traverse.js +0 -32
@@ -1 +1 @@
1
- {"version":3,"names":["createContext","useContext","getLayoutType","useSetting","defaultLayout","type","Layout","LayoutProvider","Provider","useLayout","LayoutStyle","layout","css","props","layoutType","blockGapSupport","hasBlockGapSupport","createElement","layoutStyle","getLayoutStyle"],"sources":["@wordpress/block-editor/src/components/block-list/layout.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getLayoutType } from '../../layouts';\nimport useSetting from '../use-setting';\n\nexport const defaultLayout = { type: 'default' };\n\nconst Layout = createContext( defaultLayout );\n\n/**\n * Allows to define the layout.\n */\nexport const LayoutProvider = Layout.Provider;\n\n/**\n * React hook used to retrieve the layout config.\n */\nexport function useLayout() {\n\treturn useContext( Layout );\n}\n\nexport function LayoutStyle( { layout = {}, css, ...props } ) {\n\tconst layoutType = getLayoutType( layout.type );\n\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\tif ( layoutType ) {\n\t\tif ( css ) {\n\t\t\treturn <style>{ css }</style>;\n\t\t}\n\t\tconst layoutStyle = layoutType.getLayoutStyle?.( {\n\t\t\thasBlockGapSupport,\n\t\t\tlayout,\n\t\t\t...props,\n\t\t} );\n\t\tif ( layoutStyle ) {\n\t\t\treturn <style>{ layoutStyle }</style>;\n\t\t}\n\t}\n\treturn null;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;;AAE9D;AACA;AACA;AACA,SAASC,aAAa,QAAQ,eAAe;AAC7C,OAAOC,UAAU,MAAM,gBAAgB;AAEvC,OAAO,MAAMC,aAAa,GAAG;EAAEC,IAAI,EAAE;AAAU,CAAC;AAEhD,MAAMC,MAAM,GAAGN,aAAa,CAAEI,aAAc,CAAC;;AAE7C;AACA;AACA;AACA,OAAO,MAAMG,cAAc,GAAGD,MAAM,CAACE,QAAQ;;AAE7C;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAAA,EAAG;EAC3B,OAAOR,UAAU,CAAEK,MAAO,CAAC;AAC5B;AAEA,OAAO,SAASI,WAAWA,CAAE;EAAEC,MAAM,GAAG,CAAC,CAAC;EAAEC,GAAG;EAAE,GAAGC;AAAM,CAAC,EAAG;EAC7D,MAAMC,UAAU,GAAGZ,aAAa,CAAES,MAAM,CAACN,IAAK,CAAC;EAC/C,MAAMU,eAAe,GAAGZ,UAAU,CAAE,kBAAmB,CAAC;EACxD,MAAMa,kBAAkB,GAAGD,eAAe,KAAK,IAAI;EAEnD,IAAKD,UAAU,EAAG;IACjB,IAAKF,GAAG,EAAG;MACV,OAAOK,aAAA,gBAASL,GAAY,CAAC;IAC9B;IACA,MAAMM,WAAW,GAAGJ,UAAU,CAACK,cAAc,GAAI;MAChDH,kBAAkB;MAClBL,MAAM;MACN,GAAGE;IACJ,CAAE,CAAC;IACH,IAAKK,WAAW,EAAG;MAClB,OAAOD,aAAA,gBAASC,WAAoB,CAAC;IACtC;EACD;EACA,OAAO,IAAI;AACZ"}
1
+ {"version":3,"names":["createContext","useContext","getLayoutType","useSettings","defaultLayout","type","Layout","LayoutProvider","Provider","useLayout","LayoutStyle","layout","css","props","layoutType","blockGapSupport","hasBlockGapSupport","createElement","layoutStyle","getLayoutStyle"],"sources":["@wordpress/block-editor/src/components/block-list/layout.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getLayoutType } from '../../layouts';\nimport { useSettings } from '../use-settings';\n\nexport const defaultLayout = { type: 'default' };\n\nconst Layout = createContext( defaultLayout );\n\n/**\n * Allows to define the layout.\n */\nexport const LayoutProvider = Layout.Provider;\n\n/**\n * React hook used to retrieve the layout config.\n */\nexport function useLayout() {\n\treturn useContext( Layout );\n}\n\nexport function LayoutStyle( { layout = {}, css, ...props } ) {\n\tconst layoutType = getLayoutType( layout.type );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\tif ( layoutType ) {\n\t\tif ( css ) {\n\t\t\treturn <style>{ css }</style>;\n\t\t}\n\t\tconst layoutStyle = layoutType.getLayoutStyle?.( {\n\t\t\thasBlockGapSupport,\n\t\t\tlayout,\n\t\t\t...props,\n\t\t} );\n\t\tif ( layoutStyle ) {\n\t\t\treturn <style>{ layoutStyle }</style>;\n\t\t}\n\t}\n\treturn null;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;;AAE9D;AACA;AACA;AACA,SAASC,aAAa,QAAQ,eAAe;AAC7C,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,OAAO,MAAMC,aAAa,GAAG;EAAEC,IAAI,EAAE;AAAU,CAAC;AAEhD,MAAMC,MAAM,GAAGN,aAAa,CAAEI,aAAc,CAAC;;AAE7C;AACA;AACA;AACA,OAAO,MAAMG,cAAc,GAAGD,MAAM,CAACE,QAAQ;;AAE7C;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAAA,EAAG;EAC3B,OAAOR,UAAU,CAAEK,MAAO,CAAC;AAC5B;AAEA,OAAO,SAASI,WAAWA,CAAE;EAAEC,MAAM,GAAG,CAAC,CAAC;EAAEC,GAAG;EAAE,GAAGC;AAAM,CAAC,EAAG;EAC7D,MAAMC,UAAU,GAAGZ,aAAa,CAAES,MAAM,CAACN,IAAK,CAAC;EAC/C,MAAM,CAAEU,eAAe,CAAE,GAAGZ,WAAW,CAAE,kBAAmB,CAAC;EAC7D,MAAMa,kBAAkB,GAAGD,eAAe,KAAK,IAAI;EAEnD,IAAKD,UAAU,EAAG;IACjB,IAAKF,GAAG,EAAG;MACV,OAAOK,aAAA,gBAASL,GAAY,CAAC;IAC9B;IACA,MAAMM,WAAW,GAAGJ,UAAU,CAACK,cAAc,GAAI;MAChDH,kBAAkB;MAClBL,MAAM;MACN,GAAGE;IACJ,CAAE,CAAC;IACH,IAAKK,WAAW,EAAG;MAClB,OAAOD,aAAA,gBAASC,WAAoB,CAAC;IACtC;EACD;EACA,OAAO,IAAI;AACZ"}
@@ -12,7 +12,7 @@ import { __ } from '@wordpress/i18n';
12
12
  import AllInputControl from './all-input-control';
13
13
  import InputControls from './input-controls';
14
14
  import LinkedButton from './linked-button';
15
- import useSetting from '../use-setting';
15
+ import { useSettings } from '../use-settings';
16
16
  import { getAllValue, getAllUnit, hasDefinedValues, hasMixedValues } from './utils';
17
17
  const DEFAULT_VALUES = {
18
18
  topLeft: undefined,
@@ -52,8 +52,9 @@ export default function BorderRadiusControl({
52
52
  bottomLeft: parseQuantityAndUnitFromRawValue(values?.bottomLeft)[1],
53
53
  bottomRight: parseQuantityAndUnitFromRawValue(values?.bottomRight)[1]
54
54
  });
55
+ const [availableUnits] = useSettings('spacing.units');
55
56
  const units = useCustomUnits({
56
- availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem']
57
+ availableUnits: availableUnits || ['px', 'em', 'rem']
57
58
  });
58
59
  const unit = getAllUnit(selectedUnits);
59
60
  const unitConfig = units && units.find(item => item.value === unit);
@@ -1 +1 @@
1
- {"version":3,"names":["BaseControl","RangeControl","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","__experimentalUseCustomUnits","useCustomUnits","useState","__","AllInputControl","InputControls","LinkedButton","useSetting","getAllValue","getAllUnit","hasDefinedValues","hasMixedValues","DEFAULT_VALUES","topLeft","undefined","topRight","bottomLeft","bottomRight","MIN_BORDER_RADIUS_VALUE","MAX_BORDER_RADIUS_VALUES","px","em","rem","BorderRadiusControl","onChange","values","isLinked","setIsLinked","selectedUnits","setSelectedUnits","flat","units","availableUnits","unit","unitConfig","find","item","value","step","allValue","toggleLinked","handleSliderChange","next","createElement","className","VisualLabel","as","Fragment","min","label","hideLabelFromVision","max","initialPosition","withInputField","__nextHasNoMarginBottom","onClick"],"sources":["@wordpress/block-editor/src/components/border-radius-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBaseControl,\n\tRangeControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport AllInputControl from './all-input-control';\nimport InputControls from './input-controls';\nimport LinkedButton from './linked-button';\nimport useSetting from '../use-setting';\nimport {\n\tgetAllValue,\n\tgetAllUnit,\n\thasDefinedValues,\n\thasMixedValues,\n} from './utils';\n\nconst DEFAULT_VALUES = {\n\ttopLeft: undefined,\n\ttopRight: undefined,\n\tbottomLeft: undefined,\n\tbottomRight: undefined,\n};\nconst MIN_BORDER_RADIUS_VALUE = 0;\nconst MAX_BORDER_RADIUS_VALUES = {\n\tpx: 100,\n\tem: 20,\n\trem: 20,\n};\n\n/**\n * Control to display border radius options.\n *\n * @param {Object} props Component props.\n * @param {Function} props.onChange Callback to handle onChange.\n * @param {Object} props.values Border radius values.\n *\n * @return {Element} Custom border radius control.\n */\nexport default function BorderRadiusControl( { onChange, values } ) {\n\tconst [ isLinked, setIsLinked ] = useState(\n\t\t! hasDefinedValues( values ) || ! hasMixedValues( values )\n\t);\n\n\t// Tracking selected units via internal state allows filtering of CSS unit\n\t// only values from being saved while maintaining preexisting unit selection\n\t// behaviour. Filtering CSS unit only values prevents invalid style values.\n\tconst [ selectedUnits, setSelectedUnits ] = useState( {\n\t\tflat:\n\t\t\ttypeof values === 'string'\n\t\t\t\t? parseQuantityAndUnitFromRawValue( values )[ 1 ]\n\t\t\t\t: undefined,\n\t\ttopLeft: parseQuantityAndUnitFromRawValue( values?.topLeft )[ 1 ],\n\t\ttopRight: parseQuantityAndUnitFromRawValue( values?.topRight )[ 1 ],\n\t\tbottomLeft: parseQuantityAndUnitFromRawValue( values?.bottomLeft )[ 1 ],\n\t\tbottomRight: parseQuantityAndUnitFromRawValue(\n\t\t\tvalues?.bottomRight\n\t\t)[ 1 ],\n\t} );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],\n\t} );\n\n\tconst unit = getAllUnit( selectedUnits );\n\tconst unitConfig = units && units.find( ( item ) => item.value === unit );\n\tconst step = unitConfig?.step || 1;\n\n\tconst [ allValue ] = parseQuantityAndUnitFromRawValue(\n\t\tgetAllValue( values )\n\t);\n\n\tconst toggleLinked = () => setIsLinked( ! isLinked );\n\n\tconst handleSliderChange = ( next ) => {\n\t\tonChange( next !== undefined ? `${ next }${ unit }` : undefined );\n\t};\n\n\treturn (\n\t\t<fieldset className=\"components-border-radius-control\">\n\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t{ __( 'Radius' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<div className=\"components-border-radius-control__wrapper\">\n\t\t\t\t{ isLinked ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<AllInputControl\n\t\t\t\t\t\t\tclassName=\"components-border-radius-control__unit-control\"\n\t\t\t\t\t\t\tvalues={ values }\n\t\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tselectedUnits={ selectedUnits }\n\t\t\t\t\t\t\tsetSelectedUnits={ setSelectedUnits }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\tlabel={ __( 'Border radius' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tclassName=\"components-border-radius-control__range-control\"\n\t\t\t\t\t\t\tvalue={ allValue ?? '' }\n\t\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\tmax={ MAX_BORDER_RADIUS_VALUES[ unit ] }\n\t\t\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\t\tonChange={ handleSliderChange }\n\t\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<InputControls\n\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tselectedUnits={ selectedUnits }\n\t\t\t\t\t\tsetSelectedUnits={ setSelectedUnits }\n\t\t\t\t\t\tvalues={ values || DEFAULT_VALUES }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<LinkedButton onClick={ toggleLinked } isLinked={ isLinked } />\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,WAAW,EACXC,YAAY,EACZC,8CAA8C,IAAIC,gCAAgC,EAClFC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,OAAOC,UAAU,MAAM,gBAAgB;AACvC,SACCC,WAAW,EACXC,UAAU,EACVC,gBAAgB,EAChBC,cAAc,QACR,SAAS;AAEhB,MAAMC,cAAc,GAAG;EACtBC,OAAO,EAAEC,SAAS;EAClBC,QAAQ,EAAED,SAAS;EACnBE,UAAU,EAAEF,SAAS;EACrBG,WAAW,EAAEH;AACd,CAAC;AACD,MAAMI,uBAAuB,GAAG,CAAC;AACjC,MAAMC,wBAAwB,GAAG;EAChCC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,EAAE;EACNC,GAAG,EAAE;AACN,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,mBAAmBA,CAAE;EAAEC,QAAQ;EAAEC;AAAO,CAAC,EAAG;EACnE,MAAM,CAAEC,QAAQ,EAAEC,WAAW,CAAE,GAAGzB,QAAQ,CACzC,CAAEQ,gBAAgB,CAAEe,MAAO,CAAC,IAAI,CA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E,CAC1D,CACI,CAAC;AAEb"}
1
+ {"version":3,"names":["BaseControl","RangeControl","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","__experimentalUseCustomUnits","useCustomUnits","useState","__","AllInputControl","InputControls","LinkedButton","useSettings","getAllValue","getAllUnit","hasDefinedValues","hasMixedValues","DEFAULT_VALUES","topLeft","undefined","topRight","bottomLeft","bottomRight","MIN_BORDER_RADIUS_VALUE","MAX_BORDER_RADIUS_VALUES","px","em","rem","BorderRadiusControl","onChange","values","isLinked","setIsLinked","selectedUnits","setSelectedUnits","flat","availableUnits","units","unit","unitConfig","find","item","value","step","allValue","toggleLinked","handleSliderChange","next","createElement","className","VisualLabel","as","Fragment","min","label","hideLabelFromVision","max","initialPosition","withInputField","__nextHasNoMarginBottom","onClick"],"sources":["@wordpress/block-editor/src/components/border-radius-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBaseControl,\n\tRangeControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport AllInputControl from './all-input-control';\nimport InputControls from './input-controls';\nimport LinkedButton from './linked-button';\nimport { useSettings } from '../use-settings';\nimport {\n\tgetAllValue,\n\tgetAllUnit,\n\thasDefinedValues,\n\thasMixedValues,\n} from './utils';\n\nconst DEFAULT_VALUES = {\n\ttopLeft: undefined,\n\ttopRight: undefined,\n\tbottomLeft: undefined,\n\tbottomRight: undefined,\n};\nconst MIN_BORDER_RADIUS_VALUE = 0;\nconst MAX_BORDER_RADIUS_VALUES = {\n\tpx: 100,\n\tem: 20,\n\trem: 20,\n};\n\n/**\n * Control to display border radius options.\n *\n * @param {Object} props Component props.\n * @param {Function} props.onChange Callback to handle onChange.\n * @param {Object} props.values Border radius values.\n *\n * @return {Element} Custom border radius control.\n */\nexport default function BorderRadiusControl( { onChange, values } ) {\n\tconst [ isLinked, setIsLinked ] = useState(\n\t\t! hasDefinedValues( values ) || ! hasMixedValues( values )\n\t);\n\n\t// Tracking selected units via internal state allows filtering of CSS unit\n\t// only values from being saved while maintaining preexisting unit selection\n\t// behaviour. Filtering CSS unit only values prevents invalid style values.\n\tconst [ selectedUnits, setSelectedUnits ] = useState( {\n\t\tflat:\n\t\t\ttypeof values === 'string'\n\t\t\t\t? parseQuantityAndUnitFromRawValue( values )[ 1 ]\n\t\t\t\t: undefined,\n\t\ttopLeft: parseQuantityAndUnitFromRawValue( values?.topLeft )[ 1 ],\n\t\ttopRight: parseQuantityAndUnitFromRawValue( values?.topRight )[ 1 ],\n\t\tbottomLeft: parseQuantityAndUnitFromRawValue( values?.bottomLeft )[ 1 ],\n\t\tbottomRight: parseQuantityAndUnitFromRawValue(\n\t\t\tvalues?.bottomRight\n\t\t)[ 1 ],\n\t} );\n\n\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnits || [ 'px', 'em', 'rem' ],\n\t} );\n\n\tconst unit = getAllUnit( selectedUnits );\n\tconst unitConfig = units && units.find( ( item ) => item.value === unit );\n\tconst step = unitConfig?.step || 1;\n\n\tconst [ allValue ] = parseQuantityAndUnitFromRawValue(\n\t\tgetAllValue( values )\n\t);\n\n\tconst toggleLinked = () => setIsLinked( ! isLinked );\n\n\tconst handleSliderChange = ( next ) => {\n\t\tonChange( next !== undefined ? `${ next }${ unit }` : undefined );\n\t};\n\n\treturn (\n\t\t<fieldset className=\"components-border-radius-control\">\n\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t{ __( 'Radius' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<div className=\"components-border-radius-control__wrapper\">\n\t\t\t\t{ isLinked ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<AllInputControl\n\t\t\t\t\t\t\tclassName=\"components-border-radius-control__unit-control\"\n\t\t\t\t\t\t\tvalues={ values }\n\t\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tselectedUnits={ selectedUnits }\n\t\t\t\t\t\t\tsetSelectedUnits={ setSelectedUnits }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\tlabel={ __( 'Border radius' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tclassName=\"components-border-radius-control__range-control\"\n\t\t\t\t\t\t\tvalue={ allValue ?? '' }\n\t\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\tmax={ MAX_BORDER_RADIUS_VALUES[ unit ] }\n\t\t\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\t\tonChange={ handleSliderChange }\n\t\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<InputControls\n\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tselectedUnits={ selectedUnits }\n\t\t\t\t\t\tsetSelectedUnits={ setSelectedUnits }\n\t\t\t\t\t\tvalues={ values || DEFAULT_VALUES }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<LinkedButton onClick={ toggleLinked } isLinked={ isLinked } />\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,WAAW,EACXC,YAAY,EACZC,8CAA8C,IAAIC,gCAAgC,EAClFC,4BAA4B,IAAIC,cAAc,QACxC,uBAAuB;AAC9B,SAASC,QAAQ,QAAQ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BI,aAAa,EAAGA,aAAe;IAC/BC,gBAAgB,EAAGA,gBAAkB;IACrCG,KAAK,EAAGA;EAAO,CACf,CAAC,EACFW,aAAA,CAAC9C,YAAY;IACZoD,KAAK,EAAG9C,EAAE,CAAE,eAAgB,CAAG;IAC/B+C,mBAAmB;IACnBN,SAAS,EAAC,iDAAiD;IAC3DP,KAAK,EAAGE,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI,EAAI;IACxBS,GAAG,EAAG9B,uBAAyB;IAC/BiC,GAAG,EAAGhC,wBAAwB,CAAEc,IAAI,CAAI;IACxCmB,eAAe,EAAG,CAAG;IACrBC,cAAc,EAAG,KAAO;IACxB7B,QAAQ,EAAGiB,kBAAoB;IAC/BH,IAAI,EAAGA,IAAM;IACbgB,uBAAuB;EAAA,CACvB,CACA,CAAC,GAEHX,aAAA,CAACtC,aAAa;IACb2C,GAAG,EAAG9B,uBAAyB;IAC/BM,QAAQ,EAAGA,QAAU;IACrBI,aAAa,EAAGA,aAAe;IAC/BC,gBAAgB,EAAGA,gBAAkB;IACrCJ,MAAM,EAAGA,MAAM,IAAIb,cAAgB;IACnCoB,KAAK,EAAGA;EAAO,CACf,CACD,EACDW,aAAA,CAACrC,YAAY;IAACiD,OAAO,EAAGf,YAAc;IAACd,QAAQ,EAAGA;EAAU,CAAE,CAC1D,CACI,CAAC;AAEb"}
@@ -7,13 +7,14 @@ import { createHigherOrderComponent } from '@wordpress/compose';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
- import useSetting from '../use-setting';
10
+ import { useSettings } from '../use-settings';
11
11
  export default createHigherOrderComponent(WrappedComponent => {
12
12
  return props => {
13
- const colorsFeature = useSetting('color.palette');
14
- const disableCustomColorsFeature = !useSetting('color.custom');
15
- const colors = props.colors === undefined ? colorsFeature : props.colors;
16
- const disableCustomColors = props.disableCustomColors === undefined ? disableCustomColorsFeature : props.disableCustomColors;
13
+ const [colorsFeature, enableCustomColors] = useSettings('color.palette', 'color.custom');
14
+ const {
15
+ colors = colorsFeature,
16
+ disableCustomColors = !enableCustomColors
17
+ } = props;
17
18
  const hasColorsToChoose = colors && colors.length > 0 || !disableCustomColors;
18
19
  return createElement(WrappedComponent, {
19
20
  ...props,
@@ -1 +1 @@
1
- {"version":3,"names":["createHigherOrderComponent","useSetting","WrappedComponent","props","colorsFeature","disableCustomColorsFeature","colors","undefined","disableCustomColors","hasColorsToChoose","length","createElement"],"sources":["@wordpress/block-editor/src/components/color-palette/with-color-context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\n\nexport default createHigherOrderComponent( ( WrappedComponent ) => {\n\treturn ( props ) => {\n\t\tconst colorsFeature = useSetting( 'color.palette' );\n\t\tconst disableCustomColorsFeature = ! useSetting( 'color.custom' );\n\t\tconst colors =\n\t\t\tprops.colors === undefined ? colorsFeature : props.colors;\n\t\tconst disableCustomColors =\n\t\t\tprops.disableCustomColors === undefined\n\t\t\t\t? disableCustomColorsFeature\n\t\t\t\t: props.disableCustomColors;\n\t\tconst hasColorsToChoose =\n\t\t\t( colors && colors.length > 0 ) || ! disableCustomColors;\n\t\treturn (\n\t\t\t<WrappedComponent\n\t\t\t\t{ ...{\n\t\t\t\t\t...props,\n\t\t\t\t\tcolors,\n\t\t\t\t\tdisableCustomColors,\n\t\t\t\t\thasColorsToChoose,\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t};\n}, 'withColorContext' );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,QAAQ,oBAAoB;;AAE/D;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AAEvC,eAAeD,0BAA0B,CAAIE,gBAAgB,IAAM;EAClE,OAASC,KAAK,IAAM;IACnB,MAAMC,aAAa,GAAGH,UAAU,CAAE,eAAgB,CAAC;IACnD,MAAMI,0BAA0B,GAAG,CAAEJ,UAAU,CAAE,cAAe,CAAC;IACjE,MAAMK,MAAM,GACXH,KAAK,CAACG,MAAM,KAAKC,SAAS,GAAGH,aAAa,GAAGD,KAAK,CAACG,MAAM;IAC1D,MAAME,mBAAmB,GACxBL,KAAK,CAACK,mBAAmB,KAAKD,SAAS,GACpCF,0BAA0B,GAC1BF,KAAK,CAACK,mBAAmB;IAC7B,MAAMC,iBAAiB,GACpBH,MAAM,IAAIA,MAAM,CAACI,MAAM,GAAG,CAAC,IAAM,CAAEF,mBAAmB;IACzD,OACCG,aAAA,CAACT,gBAAgB;MAEf,GAAGC,KAAK;MACRG,MAAM;MACNE,mBAAmB;MACnBC;IAAiB,CAElB,CAAC;EAEJ,CAAC;AACF,CAAC,EAAE,kBAAmB,CAAC"}
1
+ {"version":3,"names":["createHigherOrderComponent","useSettings","WrappedComponent","props","colorsFeature","enableCustomColors","colors","disableCustomColors","hasColorsToChoose","length","createElement"],"sources":["@wordpress/block-editor/src/components/color-palette/with-color-context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\nexport default createHigherOrderComponent( ( WrappedComponent ) => {\n\treturn ( props ) => {\n\t\tconst [ colorsFeature, enableCustomColors ] = useSettings(\n\t\t\t'color.palette',\n\t\t\t'color.custom'\n\t\t);\n\t\tconst {\n\t\t\tcolors = colorsFeature,\n\t\t\tdisableCustomColors = ! enableCustomColors,\n\t\t} = props;\n\t\tconst hasColorsToChoose =\n\t\t\t( colors && colors.length > 0 ) || ! disableCustomColors;\n\t\treturn (\n\t\t\t<WrappedComponent\n\t\t\t\t{ ...{\n\t\t\t\t\t...props,\n\t\t\t\t\tcolors,\n\t\t\t\t\tdisableCustomColors,\n\t\t\t\t\thasColorsToChoose,\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t};\n}, 'withColorContext' );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,QAAQ,oBAAoB;;AAE/D;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,eAAeD,0BAA0B,CAAIE,gBAAgB,IAAM;EAClE,OAASC,KAAK,IAAM;IACnB,MAAM,CAAEC,aAAa,EAAEC,kBAAkB,CAAE,GAAGJ,WAAW,CACxD,eAAe,EACf,cACD,CAAC;IACD,MAAM;MACLK,MAAM,GAAGF,aAAa;MACtBG,mBAAmB,GAAG,CAAEF;IACzB,CAAC,GAAGF,KAAK;IACT,MAAMK,iBAAiB,GACpBF,MAAM,IAAIA,MAAM,CAACG,MAAM,GAAG,CAAC,IAAM,CAAEF,mBAAmB;IACzD,OACCG,aAAA,CAACR,gBAAgB;MAEf,GAAGC,KAAK;MACRG,MAAM;MACNC,mBAAmB;MACnBC;IAAiB,CAElB,CAAC;EAEJ,CAAC;AACF,CAAC,EAAE,kBAAmB,CAAC"}
@@ -9,7 +9,7 @@ import { compose, createHigherOrderComponent } from '@wordpress/compose';
9
9
  * Internal dependencies
10
10
  */
11
11
  import { getColorClassName, getColorObjectByColorValue, getColorObjectByAttributeValues, getMostReadableColor } from './utils';
12
- import useSetting from '../use-setting';
12
+ import { useSettings } from '../use-settings';
13
13
  import { kebabCase } from '../../utils/object';
14
14
 
15
15
  /**
@@ -41,12 +41,7 @@ const withCustomColorPalette = colorsArray => createHigherOrderComponent(Wrapped
41
41
  * @return {Function} The higher order component.
42
42
  */
43
43
  const withEditorColorPalette = () => createHigherOrderComponent(WrappedComponent => props => {
44
- // Some color settings have a special handling for deprecated flags in `useSetting`,
45
- // so we can't unwrap them by doing const { ... } = useSetting('color')
46
- // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
47
- const userPalette = useSetting('color.palette.custom');
48
- const themePalette = useSetting('color.palette.theme');
49
- const defaultPalette = useSetting('color.palette.default');
44
+ const [userPalette, themePalette, defaultPalette] = useSettings('color.palette.custom', 'color.palette.theme', 'color.palette.default');
50
45
  const allColors = useMemo(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
51
46
  return createElement(WrappedComponent, {
52
47
  ...props,
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","Component","compose","createHigherOrderComponent","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","getMostReadableColor","useSetting","kebabCase","upperFirst","firstLetter","rest","toUpperCase","join","withCustomColorPalette","colorsArray","WrappedComponent","props","createElement","colors","withEditorColorPalette","userPalette","themePalette","defaultPalette","allColors","createColorHOC","colorTypes","withColorPalette","colorMap","reduce","colorObject","colorType","constructor","setters","createSetters","colorUtils","bind","state","colorValue","Object","keys","settersAccumulator","colorAttributeName","upperFirstColorAttributeName","customColorAttributeName","createSetColor","setAttributes","slug","undefined","getDerivedStateFromProps","attributes","previousState","entries","newState","colorContext","previousColorObject","previousColor","color","class","render","createCustomColorsHOC","withColors"],"sources":["@wordpress/block-editor/src/components/colors/with-colors.js"],"sourcesContent":["/**\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';\nimport { kebabCase } from '../../utils/object';\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),\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 {Component} 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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACvD,SAASC,OAAO,EAAEC,0BAA0B,QAAQ,oBAAoB;;AAExE;AACA;AACA;AACA,SACCC,iBAAiB,EACjBC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,oBAAoB,QACd,SAAS;AAChB,OAAOC,UAAU,MAAM,gBAAgB;AACvC,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAGA,CAAE,CAAEC,WAAW,EAAE,GAAGC,IAAI,CAAE,KAC5CD,WAAW,CAACE,WAAW,CAAC,CAAC,GAAGD,IAAI,CAACE,IAAI,CAAE,EAAG,CAAC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GAAKC,WAAW,IAC3Cb,0BAA0B,CACvBc,gBAAgB,IAAQC,KAAK,IAC9BC,aAAA,CAACF,gBAAgB;EAAA,GAAMC,KAAK;EAAGE,MAAM,EAAGJ;AAAa,CAAE,CACvD,EACD,wBACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,sBAAsB,GAAGA,CAAA,KAC9BlB,0BAA0B,CACvBc,gBAAgB,IAAQC,KAAK,IAAM;EACpC;EACA;EACA;EACA,MAAMI,WAAW,GAAGd,UAAU,CAAE,sBA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AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASkC,UAAUA,CAAE,GAAGnC,UAAU,EAAG;EACnD,MAAMC,gBAAgB,GAAGP,sBAAsB,CAAC,CAAC;EACjD,OAAOlB,0BAA0B,CAChCuB,cAAc,CAAEC,UAAU,EAAEC,gBAAiB,CAAC,EAC9C,YACD,CAAC;AACF"}
1
+ {"version":3,"names":["useMemo","Component","compose","createHigherOrderComponent","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","getMostReadableColor","useSettings","kebabCase","upperFirst","firstLetter","rest","toUpperCase","join","withCustomColorPalette","colorsArray","WrappedComponent","props","createElement","colors","withEditorColorPalette","userPalette","themePalette","defaultPalette","allColors","createColorHOC","colorTypes","withColorPalette","colorMap","reduce","colorObject","colorType","constructor","setters","createSetters","colorUtils","bind","state","colorValue","Object","keys","settersAccumulator","colorAttributeName","upperFirstColorAttributeName","customColorAttributeName","createSetColor","setAttributes","slug","undefined","getDerivedStateFromProps","attributes","previousState","entries","newState","colorContext","previousColorObject","previousColor","color","class","render","createCustomColorsHOC","withColors"],"sources":["@wordpress/block-editor/src/components/colors/with-colors.js"],"sourcesContent":["/**\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 { useSettings } from '../use-settings';\nimport { kebabCase } from '../../utils/object';\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),\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\tconst [ userPalette, themePalette, defaultPalette ] = useSettings(\n\t\t\t\t'color.palette.custom',\n\t\t\t\t'color.palette.theme',\n\t\t\t\t'color.palette.default'\n\t\t\t);\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 {Component} 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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACvD,SAASC,OAAO,EAAEC,0BAA0B,QAAQ,oBAAoB;;AAExE;AACA;AACA;AACA,SACCC,iBAAiB,EACjBC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,oBAAoB,QACd,SAAS;AAChB,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAGA,CAAE,CAAEC,WAAW,EAAE,GAAGC,IAAI,CAAE,KAC5CD,WAAW,CAACE,WAAW,CAAC,CAAC,GAAGD,IAAI,CAACE,IAAI,CAAE,EAAG,CAAC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GAAKC,WAAW,IAC3Cb,0BAA0B,CACvBc,gBAAgB,IAAQC,KAAK,IAC9BC,aAAA,CAACF,gBAAgB;EAAA,GAAMC,KAAK;EAAGE,MAAM,EAAGJ;AAAa,CAAE,CACvD,EACD,wBACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,sBAAs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C,UAAU,EAAEC,gBAAiB,CAAC,EAC9C,kBACD,CAAC;EACF,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASkC,UAAUA,CAAE,GAAGnC,UAAU,EAAG;EACnD,MAAMC,gBAAgB,GAAGP,sBAAsB,CAAC,CAAC;EACjD,OAAOlB,0BAA0B,CAChCuB,cAAc,CAAEC,UAAU,EAAEC,gBAAiB,CAAC,EAC9C,YACD,CAAC;AACF"}
@@ -13,7 +13,7 @@ import { BaseControl, __experimentalVStack as VStack, TabPanel, ColorPalette, Gr
13
13
  /**
14
14
  * Internal dependencies
15
15
  */
16
- import useSetting from '../use-setting';
16
+ import { useSettings } from '../use-settings';
17
17
  const colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients'];
18
18
  const TAB_COLOR = {
19
19
  name: 'color',
@@ -95,13 +95,12 @@ function ColorGradientControlInner({
95
95
  }, tab => renderPanelType(tab.value)), !canChooseAGradient && renderPanelType(TAB_COLOR.value), !canChooseAColor && renderPanelType(TAB_GRADIENT.value))));
96
96
  }
97
97
  function ColorGradientControlSelect(props) {
98
- const colorGradientSettings = {};
99
- colorGradientSettings.colors = useSetting('color.palette');
100
- colorGradientSettings.gradients = useSetting('color.gradients');
101
- colorGradientSettings.disableCustomColors = !useSetting('color.custom');
102
- colorGradientSettings.disableCustomGradients = !useSetting('color.customGradient');
98
+ const [colors, gradients, customColors, customGradients] = useSettings('color.palette', 'color.gradients', 'color.custom', 'color.customGradient');
103
99
  return createElement(ColorGradientControlInner, {
104
- ...colorGradientSettings,
100
+ colors: colors,
101
+ gradients: gradients,
102
+ disableCustomColors: !customColors,
103
+ disableCustomGradients: !customGradients,
105
104
  ...props
106
105
  });
107
106
  }
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","__","BaseControl","__experimentalVStack","VStack","TabPanel","ColorPalette","GradientPicker","useSetting","colorsAndGradientKeys","TAB_COLOR","name","title","value","TAB_GRADIENT","TABS_SETTINGS","ColorGradientControlInner","colors","gradients","disableCustomColors","disableCustomGradients","__experimentalIsRenderedInSidebar","className","label","onColorChange","onGradientChange","colorValue","gradientValue","clearable","showTitle","enableAlpha","headingLevel","canChooseAColor","length","canChooseAGradient","tabPanels","createElement","onChange","newColor","__nextHasNoMargin","newGradient","renderPanelType","type","__nextHasNoMarginBottom","spacing","VisualLabel","tabs","initialTabName","tab","ColorGradientControlSelect","props","colorGradientSettings","ColorGradientControl","every","key","hasOwnProperty"],"sources":["@wordpress/block-editor/src/components/colors-gradients/control.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBaseControl,\n\t__experimentalVStack as VStack,\n\tTabPanel,\n\tColorPalette,\n\tGradientPicker,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\n\nconst colorsAndGradientKeys = [\n\t'colors',\n\t'disableCustomColors',\n\t'gradients',\n\t'disableCustomGradients',\n];\n\nconst TAB_COLOR = {\n\tname: 'color',\n\ttitle: __( 'Solid' ),\n\tvalue: 'color',\n};\nconst TAB_GRADIENT = {\n\tname: 'gradient',\n\ttitle: __( 'Gradient' ),\n\tvalue: 'gradient',\n};\n\nconst TABS_SETTINGS = [ TAB_COLOR, TAB_GRADIENT ];\n\nfunction ColorGradientControlInner( {\n\tcolors,\n\tgradients,\n\tdisableCustomColors,\n\tdisableCustomGradients,\n\t__experimentalIsRenderedInSidebar,\n\tclassName,\n\tlabel,\n\tonColorChange,\n\tonGradientChange,\n\tcolorValue,\n\tgradientValue,\n\tclearable,\n\tshowTitle = true,\n\tenableAlpha,\n\theadingLevel,\n} ) {\n\tconst canChooseAColor =\n\t\tonColorChange &&\n\t\t( ( colors && colors.length > 0 ) || ! disableCustomColors );\n\tconst canChooseAGradient =\n\t\tonGradientChange &&\n\t\t( ( gradients && gradients.length > 0 ) || ! disableCustomGradients );\n\n\tif ( ! canChooseAColor && ! canChooseAGradient ) {\n\t\treturn null;\n\t}\n\n\tconst tabPanels = {\n\t\t[ TAB_COLOR.value ]: (\n\t\t\t<ColorPalette\n\t\t\t\tvalue={ colorValue }\n\t\t\t\tonChange={\n\t\t\t\t\tcanChooseAGradient\n\t\t\t\t\t\t? ( newColor ) => {\n\t\t\t\t\t\t\t\tonColorChange( newColor );\n\t\t\t\t\t\t\t\tonGradientChange();\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: onColorChange\n\t\t\t\t}\n\t\t\t\t{ ...{ colors, disableCustomColors } }\n\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t}\n\t\t\t\tclearable={ clearable }\n\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\theadingLevel={ headingLevel }\n\t\t\t/>\n\t\t),\n\t\t[ TAB_GRADIENT.value ]: (\n\t\t\t<GradientPicker\n\t\t\t\t__nextHasNoMargin\n\t\t\t\tvalue={ gradientValue }\n\t\t\t\tonChange={\n\t\t\t\t\tcanChooseAColor\n\t\t\t\t\t\t? ( newGradient ) => {\n\t\t\t\t\t\t\t\tonGradientChange( newGradient );\n\t\t\t\t\t\t\t\tonColorChange();\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: onGradientChange\n\t\t\t\t}\n\t\t\t\t{ ...{ gradients, disableCustomGradients } }\n\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t}\n\t\t\t\tclearable={ clearable }\n\t\t\t\theadingLevel={ headingLevel }\n\t\t\t/>\n\t\t),\n\t};\n\n\tconst renderPanelType = ( type ) => (\n\t\t<div className=\"block-editor-color-gradient-control__panel\">\n\t\t\t{ tabPanels[ type ] }\n\t\t</div>\n\t);\n\n\treturn (\n\t\t<BaseControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-color-gradient-control',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t<fieldset className=\"block-editor-color-gradient-control__fieldset\">\n\t\t\t\t<VStack spacing={ 1 }>\n\t\t\t\t\t{ showTitle && (\n\t\t\t\t\t\t<legend>\n\t\t\t\t\t\t\t<div className=\"block-editor-color-gradient-control__color-indicator\">\n\t\t\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</legend>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canChooseAColor && canChooseAGradient && (\n\t\t\t\t\t\t<TabPanel\n\t\t\t\t\t\t\tclassName=\"block-editor-color-gradient-control__tabs\"\n\t\t\t\t\t\t\ttabs={ TABS_SETTINGS }\n\t\t\t\t\t\t\tinitialTabName={\n\t\t\t\t\t\t\t\tgradientValue\n\t\t\t\t\t\t\t\t\t? TAB_GRADIENT.value\n\t\t\t\t\t\t\t\t\t: !! canChooseAColor && TAB_COLOR.value\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ( tab ) => renderPanelType( tab.value ) }\n\t\t\t\t\t\t</TabPanel>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! canChooseAGradient &&\n\t\t\t\t\t\trenderPanelType( TAB_COLOR.value ) }\n\t\t\t\t\t{ ! canChooseAColor &&\n\t\t\t\t\t\trenderPanelType( TAB_GRADIENT.value ) }\n\t\t\t\t</VStack>\n\t\t\t</fieldset>\n\t\t</BaseControl>\n\t);\n}\n\nfunction ColorGradientControlSelect( props ) {\n\tconst colorGradientSettings = {};\n\tcolorGradientSettings.colors = useSetting( 'color.palette' );\n\tcolorGradientSettings.gradients = useSetting( 'color.gradients' );\n\tcolorGradientSettings.disableCustomColors = ! useSetting( 'color.custom' );\n\tcolorGradientSettings.disableCustomGradients = ! useSetting(\n\t\t'color.customGradient'\n\t);\n\n\treturn (\n\t\t<ColorGradientControlInner\n\t\t\t{ ...{ ...colorGradientSettings, ...props } }\n\t\t/>\n\t);\n}\n\nfunction ColorGradientControl( props ) {\n\tif (\n\t\tcolorsAndGradientKeys.every( ( key ) => props.hasOwnProperty( key ) )\n\t) {\n\t\treturn <ColorGradientControlInner { ...props } />;\n\t}\n\treturn <ColorGradientControlSelect { ...props } />;\n}\n\nexport default ColorGradientControl;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,WAAW,EACXC,oBAAoB,IAAIC,MAAM,EAC9BC,QAAQ,EACRC,YAAY,EACZC,cAAc,QACR,uBAAuB;;AAE9B;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AAEvC,MAAMC,qBAAqB,GAAG,CAC7B,QAAQ,EACR,qBAAqB,EACrB,WAAW,EACX,wBAAwB,CACxB;AAED,MAAMC,SAAS,GAAG;EACjBC,IAAI,EAAE,OAAO;EACbC,KAAK,EAAEX,EAAE,CAAE,OAAQ,CAAC;EACpBY,KAAK,EAAE;AACR,CAAC;AACD,MAAMC,YAAY,GAAG;EACpBH,IAAI,EAAE,UAAU;EAChBC,KAAK,EAAEX,EAAE,CAAE,UAAW,CAAC;EACvBY,KAAK,EAAE;AACR,CAAC;AAED,MAAME,aAAa,GAAG,CAAEL,SAAS,EAAEI,YAAY,CAAE;AAEjD,SAASE,yBAAyBA,CAAE;EACnCC,MAAM;EACNC,SAAS;EACTC,mBAAmB;EACnBC,sBAAsB;EACtBC,iCAAiC;EACjCC,SAAS;EACTC,KAAK;EACLC,aAAa;EACbC,gBAAgB;EAChBC,UAAU;EACVC,aAAa;EACbC,SAAS;EACTC,SAAS,GAAG,IAAI;EAChBC,WAAW;EACXC;AACD,CAAC,EAAG;EACH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AAIC,GAAG,IAAMJ,KAAK,CAACK,cAAc,CAAED,GAAI,CAAE,CAAC,EACpE;IACD,OAAOlB,aAAA,CAACpB,yBAAyB;MAAA,GAAMkC;IAAK,CAAI,CAAC;EAClD;EACA,OAAOd,aAAA,CAACa,0BAA0B;IAAA,GAAMC;EAAK,CAAI,CAAC;AACnD;AAEA,eAAeE,oBAAoB"}
1
+ {"version":3,"names":["classnames","__","BaseControl","__experimentalVStack","VStack","TabPanel","ColorPalette","GradientPicker","useSettings","colorsAndGradientKeys","TAB_COLOR","name","title","value","TAB_GRADIENT","TABS_SETTINGS","ColorGradientControlInner","colors","gradients","disableCustomColors","disableCustomGradients","__experimentalIsRenderedInSidebar","className","label","onColorChange","onGradientChange","colorValue","gradientValue","clearable","showTitle","enableAlpha","headingLevel","canChooseAColor","length","canChooseAGradient","tabPanels","createElement","onChange","newColor","__nextHasNoMargin","newGradient","renderPanelType","type","__nextHasNoMarginBottom","spacing","VisualLabel","tabs","initialTabName","tab","ColorGradientControlSelect","props","customColors","customGradients","ColorGradientControl","every","key","hasOwnProperty"],"sources":["@wordpress/block-editor/src/components/colors-gradients/control.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBaseControl,\n\t__experimentalVStack as VStack,\n\tTabPanel,\n\tColorPalette,\n\tGradientPicker,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\nconst colorsAndGradientKeys = [\n\t'colors',\n\t'disableCustomColors',\n\t'gradients',\n\t'disableCustomGradients',\n];\n\nconst TAB_COLOR = {\n\tname: 'color',\n\ttitle: __( 'Solid' ),\n\tvalue: 'color',\n};\nconst TAB_GRADIENT = {\n\tname: 'gradient',\n\ttitle: __( 'Gradient' ),\n\tvalue: 'gradient',\n};\n\nconst TABS_SETTINGS = [ TAB_COLOR, TAB_GRADIENT ];\n\nfunction ColorGradientControlInner( {\n\tcolors,\n\tgradients,\n\tdisableCustomColors,\n\tdisableCustomGradients,\n\t__experimentalIsRenderedInSidebar,\n\tclassName,\n\tlabel,\n\tonColorChange,\n\tonGradientChange,\n\tcolorValue,\n\tgradientValue,\n\tclearable,\n\tshowTitle = true,\n\tenableAlpha,\n\theadingLevel,\n} ) {\n\tconst canChooseAColor =\n\t\tonColorChange &&\n\t\t( ( colors && colors.length > 0 ) || ! disableCustomColors );\n\tconst canChooseAGradient =\n\t\tonGradientChange &&\n\t\t( ( gradients && gradients.length > 0 ) || ! disableCustomGradients );\n\n\tif ( ! canChooseAColor && ! canChooseAGradient ) {\n\t\treturn null;\n\t}\n\n\tconst tabPanels = {\n\t\t[ TAB_COLOR.value ]: (\n\t\t\t<ColorPalette\n\t\t\t\tvalue={ colorValue }\n\t\t\t\tonChange={\n\t\t\t\t\tcanChooseAGradient\n\t\t\t\t\t\t? ( newColor ) => {\n\t\t\t\t\t\t\t\tonColorChange( newColor );\n\t\t\t\t\t\t\t\tonGradientChange();\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: onColorChange\n\t\t\t\t}\n\t\t\t\t{ ...{ colors, disableCustomColors } }\n\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t}\n\t\t\t\tclearable={ clearable }\n\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\theadingLevel={ headingLevel }\n\t\t\t/>\n\t\t),\n\t\t[ TAB_GRADIENT.value ]: (\n\t\t\t<GradientPicker\n\t\t\t\t__nextHasNoMargin\n\t\t\t\tvalue={ gradientValue }\n\t\t\t\tonChange={\n\t\t\t\t\tcanChooseAColor\n\t\t\t\t\t\t? ( newGradient ) => {\n\t\t\t\t\t\t\t\tonGradientChange( newGradient );\n\t\t\t\t\t\t\t\tonColorChange();\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: onGradientChange\n\t\t\t\t}\n\t\t\t\t{ ...{ gradients, disableCustomGradients } }\n\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t}\n\t\t\t\tclearable={ clearable }\n\t\t\t\theadingLevel={ headingLevel }\n\t\t\t/>\n\t\t),\n\t};\n\n\tconst renderPanelType = ( type ) => (\n\t\t<div className=\"block-editor-color-gradient-control__panel\">\n\t\t\t{ tabPanels[ type ] }\n\t\t</div>\n\t);\n\n\treturn (\n\t\t<BaseControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-color-gradient-control',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t<fieldset className=\"block-editor-color-gradient-control__fieldset\">\n\t\t\t\t<VStack spacing={ 1 }>\n\t\t\t\t\t{ showTitle && (\n\t\t\t\t\t\t<legend>\n\t\t\t\t\t\t\t<div className=\"block-editor-color-gradient-control__color-indicator\">\n\t\t\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</legend>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canChooseAColor && canChooseAGradient && (\n\t\t\t\t\t\t<TabPanel\n\t\t\t\t\t\t\tclassName=\"block-editor-color-gradient-control__tabs\"\n\t\t\t\t\t\t\ttabs={ TABS_SETTINGS }\n\t\t\t\t\t\t\tinitialTabName={\n\t\t\t\t\t\t\t\tgradientValue\n\t\t\t\t\t\t\t\t\t? TAB_GRADIENT.value\n\t\t\t\t\t\t\t\t\t: !! canChooseAColor && TAB_COLOR.value\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ( tab ) => renderPanelType( tab.value ) }\n\t\t\t\t\t\t</TabPanel>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! canChooseAGradient &&\n\t\t\t\t\t\trenderPanelType( TAB_COLOR.value ) }\n\t\t\t\t\t{ ! canChooseAColor &&\n\t\t\t\t\t\trenderPanelType( TAB_GRADIENT.value ) }\n\t\t\t\t</VStack>\n\t\t\t</fieldset>\n\t\t</BaseControl>\n\t);\n}\n\nfunction ColorGradientControlSelect( props ) {\n\tconst [ colors, gradients, customColors, customGradients ] = useSettings(\n\t\t'color.palette',\n\t\t'color.gradients',\n\t\t'color.custom',\n\t\t'color.customGradient'\n\t);\n\n\treturn (\n\t\t<ColorGradientControlInner\n\t\t\tcolors={ colors }\n\t\t\tgradients={ gradients }\n\t\t\tdisableCustomColors={ ! customColors }\n\t\t\tdisableCustomGradients={ ! customGradients }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction ColorGradientControl( props ) {\n\tif (\n\t\tcolorsAndGradientKeys.every( ( key ) => props.hasOwnProperty( key ) )\n\t) {\n\t\treturn <ColorGradientControlInner { ...props } />;\n\t}\n\treturn <ColorGradientControlSelect { ...props } />;\n}\n\nexport default ColorGradientControl;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,WAAW,EACXC,oBAAoB,IAAIC,MAAM,EAC9BC,QAAQ,EACRC,YAAY,EACZC,cAAc,QACR,uBAAuB;;AAE9B;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,MAAMC,qBAAqB,GAAG,CAC7B,QAAQ,EACR,qBAAqB,EACrB,WAAW,EACX,wBAAwB,CACxB;AAED,MAAMC,SAAS,GAAG;EACjBC,IAAI,EAAE,OAAO;EACbC,KAAK,EAAEX,EAAE,CAAE,OAAQ,CAAC;EACpBY,KAAK,EAAE;AACR,CAAC;AACD,MAAMC,YAAY,GAAG;EACpBH,IAAI,EAAE,UAAU;EAChBC,KAAK,EAAEX,EAAE,CAAE,UAAW,CAAC;EACvBY,KAAK,EAAE;AACR,CAAC;AAED,MAAME,aAAa,GAAG,CAAEL,SAAS,EA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S,EAAGA,SAAW;IACvBC,mBAAmB,EAAG,CAAEgC,YAAc;IACtC/B,sBAAsB,EAAG,CAAEgC,eAAiB;IAAA,GACvCF;EAAK,CACV,CAAC;AAEJ;AAEA,SAASG,oBAAoBA,CAAEH,KAAK,EAAG;EACtC,IACCzC,qBAAqB,CAAC6C,KAAK,CAAIC,GAAG,IAAML,KAAK,CAACM,cAAc,CAAED,GAAI,CAAE,CAAC,EACpE;IACD,OAAOnB,aAAA,CAACpB,yBAAyB;MAAA,GAAMkC;IAAK,CAAI,CAAC;EAClD;EACA,OAAOd,aAAA,CAACa,0BAA0B;IAAA,GAAMC;EAAK,CAAI,CAAC;AACnD;AAEA,eAAeG,oBAAoB"}
@@ -7,7 +7,7 @@ import { _x } from '@wordpress/i18n';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
- import useSetting from '../use-setting';
10
+ import { useSettings } from '../use-settings';
11
11
 
12
12
  /**
13
13
  * Retrieves color and gradient related settings.
@@ -18,14 +18,11 @@ import useSetting from '../use-setting';
18
18
  * @return {Object} Color and gradient related settings.
19
19
  */
20
20
  export default function useMultipleOriginColorsAndGradients() {
21
+ const [enableCustomColors, customColors, themeColors, defaultColors, shouldDisplayDefaultColors, enableCustomGradients, customGradients, themeGradients, defaultGradients, shouldDisplayDefaultGradients] = useSettings('color.custom', 'color.palette.custom', 'color.palette.theme', 'color.palette.default', 'color.defaultPalette', 'color.customGradient', 'color.gradients.custom', 'color.gradients.theme', 'color.gradients.default', 'color.defaultGradients');
21
22
  const colorGradientSettings = {
22
- disableCustomColors: !useSetting('color.custom'),
23
- disableCustomGradients: !useSetting('color.customGradient')
23
+ disableCustomColors: !enableCustomColors,
24
+ disableCustomGradients: !enableCustomGradients
24
25
  };
25
- const customColors = useSetting('color.palette.custom');
26
- const themeColors = useSetting('color.palette.theme');
27
- const defaultColors = useSetting('color.palette.default');
28
- const shouldDisplayDefaultColors = useSetting('color.defaultPalette');
29
26
  colorGradientSettings.colors = useMemo(() => {
30
27
  const result = [];
31
28
  if (themeColors && themeColors.length) {
@@ -47,11 +44,7 @@ export default function useMultipleOriginColorsAndGradients() {
47
44
  });
48
45
  }
49
46
  return result;
50
- }, [defaultColors, themeColors, customColors, shouldDisplayDefaultColors]);
51
- const customGradients = useSetting('color.gradients.custom');
52
- const themeGradients = useSetting('color.gradients.theme');
53
- const defaultGradients = useSetting('color.gradients.default');
54
- const shouldDisplayDefaultGradients = useSetting('color.defaultGradients');
47
+ }, [customColors, themeColors, defaultColors, shouldDisplayDefaultColors]);
55
48
  colorGradientSettings.gradients = useMemo(() => {
56
49
  const result = [];
57
50
  if (themeGradients && themeGradients.length) {
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","_x","useSetting","useMultipleOriginColorsAndGradients","colorGradientSettings","disableCustomColors","disableCustomGradients","customColors","themeColors","defaultColors","shouldDisplayDefaultColors","colors","result","length","push","name","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients","gradients","hasColorsOrGradients"],"sources":["@wordpress/block-editor/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\n\n/**\n * Retrieves color and gradient related settings.\n *\n * The arrays for colors and gradients are made up of color palettes from each\n * origin i.e. \"Core\", \"Theme\", and \"User\".\n *\n * @return {Object} Color and gradient related settings.\n */\nexport default function useMultipleOriginColorsAndGradients() {\n\tconst colorGradientSettings = {\n\t\tdisableCustomColors: ! useSetting( 'color.custom' ),\n\t\tdisableCustomGradients: ! useSetting( 'color.customGradient' ),\n\t};\n\tconst customColors = useSetting( 'color.palette.custom' );\n\tconst themeColors = useSetting( 'color.palette.theme' );\n\tconst defaultColors = useSetting( 'color.palette.default' );\n\tconst shouldDisplayDefaultColors = useSetting( 'color.defaultPalette' );\n\n\tcolorGradientSettings.colors = useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tdefaultColors,\n\t\tthemeColors,\n\t\tcustomColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n\n\tconst customGradients = useSetting( 'color.gradients.custom' );\n\tconst themeGradients = useSetting( 'color.gradients.theme' );\n\tconst defaultGradients = useSetting( 'color.gradients.default' );\n\tconst shouldDisplayDefaultGradients = useSetting(\n\t\t'color.defaultGradients'\n\t);\n\tcolorGradientSettings.gradients = useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n\n\tcolorGradientSettings.hasColorsOrGradients =\n\t\t!! colorGradientSettings.colors.length ||\n\t\t!! colorGradientSettings.gradients.length;\n\n\treturn colorGradientSettings;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,mCAAmCA,CAAA,EAAG;EAC7D,MAAMC,qBAAqB,GAAG;IAC7BC,mBAAmB,EAAE,CAAEH,UAAU,CAAE,cAAe,CAAC;IACnDI,sBAAsB,EAAE,CAAEJ,UAAU,CAAE,sBAAuB;EAC9D,CAAC;EACD,MAAMK,YAAY,GAAGL,UAAU,CAAE,sBAAuB,CAAC;EACzD,MAAMM,WAAW,GAAGN,UAAU,CAAE,qBAAsB,CAAC;EACvD,MAAMO,aAAa,GAAGP,UAAU,CAAE,uBAAwB,CAAC;EAC3D,MAAMQ,0BAA0B,GAAGR,UAAU,CAAE,sBAAuB,CAAC;EAEvEE,qBAAqB,CAACO,MAAM,GAAGX,OAAO,CAAE,MAAM;IAC7C,MAAMY,MAAM,GAAG,EAAE;IACjB,IAAKJ,WAAW,IAAIA,WAAW,CAACK,MAAM,EAAG;MACxCD,MAAM,CAACE,IAAI,CAAE;QACZC,IAAI,EAAEd,EAAE,CACP,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Ae,IAAIA,eAAe,CAACH,MAAM,EAAG;MAChDD,MAAM,CAACE,IAAI,CAAE;QACZC,IAAI,EAAEd,EAAE,CACP,QAAQ,EACR,gDACD,CAAC;QACDmB,SAAS,EAAEJ;MACZ,CAAE,CAAC;IACJ;IACA,OAAOJ,MAAM;EACd,CAAC,EAAE,CACFI,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,6BAA6B,CAC5B,CAAC;EAEHf,qBAAqB,CAACiB,oBAAoB,GACzC,CAAC,CAAEjB,qBAAqB,CAACO,MAAM,CAACE,MAAM,IACtC,CAAC,CAAET,qBAAqB,CAACgB,SAAS,CAACP,MAAM;EAE1C,OAAOT,qBAAqB;AAC7B"}
1
+ {"version":3,"names":["useMemo","_x","useSettings","useMultipleOriginColorsAndGradients","enableCustomColors","customColors","themeColors","defaultColors","shouldDisplayDefaultColors","enableCustomGradients","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients","colorGradientSettings","disableCustomColors","disableCustomGradients","colors","result","length","push","name","gradients","hasColorsOrGradients"],"sources":["@wordpress/block-editor/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\n/**\n * Retrieves color and gradient related settings.\n *\n * The arrays for colors and gradients are made up of color palettes from each\n * origin i.e. \"Core\", \"Theme\", and \"User\".\n *\n * @return {Object} Color and gradient related settings.\n */\nexport default function useMultipleOriginColorsAndGradients() {\n\tconst [\n\t\tenableCustomColors,\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t\tenableCustomGradients,\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] = useSettings(\n\t\t'color.custom',\n\t\t'color.palette.custom',\n\t\t'color.palette.theme',\n\t\t'color.palette.default',\n\t\t'color.defaultPalette',\n\t\t'color.customGradient',\n\t\t'color.gradients.custom',\n\t\t'color.gradients.theme',\n\t\t'color.gradients.default',\n\t\t'color.defaultGradients'\n\t);\n\n\tconst colorGradientSettings = {\n\t\tdisableCustomColors: ! enableCustomColors,\n\t\tdisableCustomGradients: ! enableCustomGradients,\n\t};\n\n\tcolorGradientSettings.colors = useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n\n\tcolorGradientSettings.gradients = useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n\n\tcolorGradientSettings.hasColorsOrGradients =\n\t\t!! colorGradientSettings.colors.length ||\n\t\t!! colorGradientSettings.gradients.length;\n\n\treturn colorGradientSettings;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,mCAAmCA,CAAA,EAAG;EAC7D,MAAM,CACLC,kBAAkB,EAClBC,YAAY,EACZC,WAAW,EACXC,aAAa,EACbC,0BAA0B,EAC1BC,qBAAqB,EACrBC,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,6BAA6B,CAC7B,GAAGX,WAAW,CACd,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,EACzB,wBACD,CAAC;EAED,MAAMY,qBAAqB,GAAG;IAC7BC,mBAAmB,EAAE,CAAEX,kBAAkB;IACzCY,sBAAsB,EAAE,CAAEP;EAC3B,CAAC;EAEDK,qBAAqB,CAACG,MAA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MAChDD,MAAM,CAACE,IAAI,CAAE;QACZC,IAAI,EAAEpB,EAAE,CACP,QAAQ,EACR,gDACD,CAAC;QACDqB,SAAS,EAAEZ;MACZ,CAAE,CAAC;IACJ;IACA,OAAOQ,MAAM;EACd,CAAC,EAAE,CACFR,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,6BAA6B,CAC5B,CAAC;EAEHC,qBAAqB,CAACS,oBAAoB,GACzC,CAAC,CAAET,qBAAqB,CAACG,MAAM,CAACE,MAAM,IACtC,CAAC,CAAEL,qBAAqB,CAACQ,SAAS,CAACH,MAAM;EAE1C,OAAOL,qBAAqB;AAC7B"}
@@ -8,14 +8,14 @@ import { __ } from '@wordpress/i18n';
8
8
  /**
9
9
  * Internal dependencies
10
10
  */
11
- import useSetting from '../use-setting';
11
+ import { useSettings } from '../use-settings';
12
12
  export default function FontFamilyControl({
13
13
  value = '',
14
14
  onChange,
15
15
  fontFamilies,
16
16
  ...props
17
17
  }) {
18
- const blockLevelFontFamilies = useSetting('typography.fontFamilies');
18
+ const [blockLevelFontFamilies] = useSettings('typography.fontFamilies');
19
19
  if (!fontFamilies) {
20
20
  fontFamilies = blockLevelFontFamilies;
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"names":["SelectControl","__","useSetting","FontFamilyControl","value","onChange","fontFamilies","props","blockLevelFontFamilies","length","options","label","map","fontFamily","name","createElement","labelPosition"],"sources":["@wordpress/block-editor/src/components/font-family/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\n\nexport default function FontFamilyControl( {\n\tvalue = '',\n\tonChange,\n\tfontFamilies,\n\t...props\n} ) {\n\tconst blockLevelFontFamilies = useSetting( 'typography.fontFamilies' );\n\tif ( ! fontFamilies ) {\n\t\tfontFamilies = blockLevelFontFamilies;\n\t}\n\n\tif ( ! fontFamilies || fontFamilies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst options = [\n\t\t{ value: '', label: __( 'Default' ) },\n\t\t...fontFamilies.map( ( { fontFamily, name } ) => {\n\t\t\treturn {\n\t\t\t\tvalue: fontFamily,\n\t\t\t\tlabel: name || fontFamily,\n\t\t\t};\n\t\t} ),\n\t];\n\treturn (\n\t\t<SelectControl\n\t\t\tlabel={ __( 'Font' ) }\n\t\t\toptions={ options }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tlabelPosition=\"top\"\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AAEvC,eAAe,SAASC,iBAAiBA,CAAE;EAC1CC,KAAK,GAAG,EAAE;EACVC,QAAQ;EACRC,YAAY;EACZ,GAAGC;AACJ,CAAC,EAAG;EACH,MAAMC,sBAAsB,GAAGN,UAAU,CAAE,yBAA0B,CAAC;EACtE,IAAK,CAAEI,YAAY,EAAG;IACrBA,YAAY,GAAGE,sBAAsB;EACtC;EAEA,IAAK,CAAEF,YAAY,IAAIA,YAAY,CAACG,MAAM,KAAK,CAAC,EAAG;IAClD,OAAO,IAAI;EACZ;EAEA,MAAMC,OAAO,GAAG,CACf;IAAEN,KAAK,EAAE,EAAE;IAAEO,KAAK,EAAEV,EAAE,CAAE,SAAU;EAAE,CAAC,EACrC,GAAGK,YAAY,CAACM,GAAG,CAAE,CAAE;IAAEC,UAAU;IAAEC;EAAK,CAAC,KAAM;IAChD,OAAO;MACNV,KAAK,EAAES,UAAU;MACjBF,KAAK,EAAEG,IAAI,IAAID;IAChB,CAAC;EACF,CAAE,CAAC,CACH;EACD,OACCE,aAAA,CAACf,aAAa;IACbW,KAAK,EAAGV,EAAE,CAAE,MAAO,CAAG;IACtBS,OAAO,EAAGA,OAAS;IACnBN,KAAK,EAAGA,KAAO;IACfC,QAAQ,EAAGA,QAAU;IACrBW,aAAa,EAAC,KAAK;IAAA,GACdT;EAAK,CACV,CAAC;AAEJ"}
1
+ {"version":3,"names":["SelectControl","__","useSettings","FontFamilyControl","value","onChange","fontFamilies","props","blockLevelFontFamilies","length","options","label","map","fontFamily","name","createElement","labelPosition"],"sources":["@wordpress/block-editor/src/components/font-family/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\nexport default function FontFamilyControl( {\n\tvalue = '',\n\tonChange,\n\tfontFamilies,\n\t...props\n} ) {\n\tconst [ blockLevelFontFamilies ] = useSettings( 'typography.fontFamilies' );\n\tif ( ! fontFamilies ) {\n\t\tfontFamilies = blockLevelFontFamilies;\n\t}\n\n\tif ( ! fontFamilies || fontFamilies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst options = [\n\t\t{ value: '', label: __( 'Default' ) },\n\t\t...fontFamilies.map( ( { fontFamily, name } ) => {\n\t\t\treturn {\n\t\t\t\tvalue: fontFamily,\n\t\t\t\tlabel: name || fontFamily,\n\t\t\t};\n\t\t} ),\n\t];\n\treturn (\n\t\t<SelectControl\n\t\t\tlabel={ __( 'Font' ) }\n\t\t\toptions={ options }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tlabelPosition=\"top\"\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,eAAe,SAASC,iBAAiBA,CAAE;EAC1CC,KAAK,GAAG,EAAE;EACVC,QAAQ;EACRC,YAAY;EACZ,GAAGC;AACJ,CAAC,EAAG;EACH,MAAM,CAAEC,sBAAsB,CAAE,GAAGN,WAAW,CAAE,yBAA0B,CAAC;EAC3E,IAAK,CAAEI,YAAY,EAAG;IACrBA,YAAY,GAAGE,sBAAsB;EACtC;EAEA,IAAK,CAAEF,YAAY,IAAIA,YAAY,CAACG,MAAM,KAAK,CAAC,EAAG;IAClD,OAAO,IAAI;EACZ;EAEA,MAAMC,OAAO,GAAG,CACf;IAAEN,KAAK,EAAE,EAAE;IAAEO,KAAK,EAAEV,EAAE,CAAE,SAAU;EAAE,CAAC,EACrC,GAAGK,YAAY,CAACM,GAAG,CAAE,CAAE;IAAEC,UAAU;IAAEC;EAAK,CAAC,KAAM;IAChD,OAAO;MACNV,KAAK,EAAES,UAAU;MACjBF,KAAK,EAAEG,IAAI,IAAID;IAChB,CAAC;EACF,CAAE,CAAC,CACH;EACD,OACCE,aAAA,CAACf,aAAa;IACbW,KAAK,EAAGV,EAAE,CAAE,MAAO,CAAG;IACtBS,OAAO,EAAGA,OAAS;IACnBN,KAAK,EAAGA,KAAO;IACfC,QAAQ,EAAGA,QAAU;IACrBW,aAAa,EAAC,KAAK;IAAA,GACdT;EAAK,CACV,CAAC;AAEJ"}
@@ -7,14 +7,13 @@ import { FontSizePicker as BaseFontSizePicker } from '@wordpress/components';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
- import useSetting from '../use-setting';
10
+ import { useSettings } from '../use-settings';
11
11
  function FontSizePicker(props) {
12
- const fontSizes = useSetting('typography.fontSizes');
13
- const disableCustomFontSizes = !useSetting('typography.customFontSize');
12
+ const [fontSizes, customFontSize] = useSettings('typography.fontSizes', 'typography.customFontSize');
14
13
  return createElement(BaseFontSizePicker, {
15
14
  ...props,
16
15
  fontSizes: fontSizes,
17
- disableCustomFontSizes: disableCustomFontSizes
16
+ disableCustomFontSizes: !customFontSize
18
17
  });
19
18
  }
20
19
 
@@ -1 +1 @@
1
- {"version":3,"names":["FontSizePicker","BaseFontSizePicker","useSetting","props","fontSizes","disableCustomFontSizes","createElement"],"sources":["@wordpress/block-editor/src/components/font-sizes/font-size-picker.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FontSizePicker as BaseFontSizePicker } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../use-setting';\n\nfunction FontSizePicker( props ) {\n\tconst fontSizes = useSetting( 'typography.fontSizes' );\n\tconst disableCustomFontSizes = ! useSetting( 'typography.customFontSize' );\n\n\treturn (\n\t\t<BaseFontSizePicker\n\t\t\t{ ...props }\n\t\t\tfontSizes={ fontSizes }\n\t\t\tdisableCustomFontSizes={ disableCustomFontSizes }\n\t\t/>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/font-sizes/README.md\n */\nexport default FontSizePicker;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,cAAc,IAAIC,kBAAkB,QAAQ,uBAAuB;;AAE5E;AACA;AACA;AACA,OAAOC,UAAU,MAAM,gBAAgB;AAEvC,SAASF,cAAcA,CAAEG,KAAK,EAAG;EAChC,MAAMC,SAAS,GAAGF,UAAU,CAAE,sBAAuB,CAAC;EACtD,MAAMG,sBAAsB,GAAG,CAAEH,UAAU,CAAE,2BAA4B,CAAC;EAE1E,OACCI,aAAA,CAACL,kBAAkB;IAAA,GACbE,KAAK;IACVC,SAAS,EAAGA,SAAW;IACvBC,sBAAsB,EAAGA;EAAwB,CACjD,CAAC;AAEJ;;AAEA;AACA;AACA;AACA,eAAeL,cAAc"}
1
+ {"version":3,"names":["FontSizePicker","BaseFontSizePicker","useSettings","props","fontSizes","customFontSize","createElement","disableCustomFontSizes"],"sources":["@wordpress/block-editor/src/components/font-sizes/font-size-picker.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FontSizePicker as BaseFontSizePicker } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\nfunction FontSizePicker( props ) {\n\tconst [ fontSizes, customFontSize ] = useSettings(\n\t\t'typography.fontSizes',\n\t\t'typography.customFontSize'\n\t);\n\n\treturn (\n\t\t<BaseFontSizePicker\n\t\t\t{ ...props }\n\t\t\tfontSizes={ fontSizes }\n\t\t\tdisableCustomFontSizes={ ! customFontSize }\n\t\t/>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/font-sizes/README.md\n */\nexport default FontSizePicker;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,cAAc,IAAIC,kBAAkB,QAAQ,uBAAuB;;AAE5E;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,SAASF,cAAcA,CAAEG,KAAK,EAAG;EAChC,MAAM,CAAEC,SAAS,EAAEC,cAAc,CAAE,GAAGH,WAAW,CAChD,sBAAsB,EACtB,2BACD,CAAC;EAED,OACCI,aAAA,CAACL,kBAAkB;IAAA,GACbE,KAAK;IACVC,SAAS,EAAGA,SAAW;IACvBG,sBAAsB,EAAG,CAAEF;EAAgB,CAC3C,CAAC;AAEJ;;AAEA;AACA;AACA;AACA,eAAeL,cAAc"}
@@ -9,7 +9,7 @@ import { Component } from '@wordpress/element';
9
9
  * Internal dependencies
10
10
  */
11
11
  import { getFontSize, getFontSizeClass } from './utils';
12
- import useSetting from '../use-setting';
12
+ import { useSettings } from '../use-settings';
13
13
  const DEFAULT_FONT_SIZES = [];
14
14
 
15
15
  /**
@@ -42,10 +42,10 @@ export default ((...fontSizeNames) => {
42
42
  return fontSizeAttributeNamesAccumulator;
43
43
  }, {});
44
44
  return createHigherOrderComponent(compose([createHigherOrderComponent(WrappedComponent => props => {
45
- const fontSizes = useSetting('typography.fontSizes') || DEFAULT_FONT_SIZES;
45
+ const [fontSizes] = useSettings('typography.fontSizes');
46
46
  return createElement(WrappedComponent, {
47
47
  ...props,
48
- fontSizes: fontSizes
48
+ fontSizes: fontSizes || DEFAULT_FONT_SIZES
49
49
  });
50
50
  }, 'withFontSizes'), WrappedComponent => {
51
51
  return class extends Component {
@@ -1 +1 @@
1
- {"version":3,"names":["createHigherOrderComponent","compose","Component","getFontSize","getFontSizeClass","useSetting","DEFAULT_FONT_SIZES","upperFirst","firstLetter","rest","toUpperCase","join","fontSizeNames","fontSizeAttributeNames","reduce","fontSizeAttributeNamesAccumulator","fontSizeAttributeName","WrappedComponent","props","fontSizes","createElement","constructor","setters","createSetters","state","Object","entries","settersAccumulator","customFontSizeAttributeName","upperFirstFontSizeAttributeName","createSetFontSize","fontSizeValue","fontSizeObject","find","size","Number","setAttributes","slug","undefined","getDerivedStateFromProps","attributes","previousState","didAttributesChange","values","some","newState","filter","key","value","newStateAccumulator","fontSizeAttributeValue","class","render"],"sources":["@wordpress/block-editor/src/components/font-sizes/with-font-sizes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, compose } from '@wordpress/compose';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getFontSize, getFontSizeClass } from './utils';\nimport useSetting from '../use-setting';\n\nconst DEFAULT_FONT_SIZES = [];\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, which handles font size logic for class generation,\n * font size value retrieval, and font size change handling.\n *\n * @param {...(Object|string)} fontSizeNames The arguments should all be strings.\n * Each string contains the font size\n * attribute name e.g: 'fontSize'.\n *\n * @return {Function} Higher-order component.\n */\nexport default ( ...fontSizeNames ) => {\n\t/*\n\t * Computes an object whose key is the font size attribute name as passed in the array,\n\t * and the value is the custom font size attribute name.\n\t * Custom font size is automatically compted by appending custom followed by the font size attribute name in with the first letter capitalized.\n\t */\n\tconst fontSizeAttributeNames = fontSizeNames.reduce(\n\t\t( fontSizeAttributeNamesAccumulator, fontSizeAttributeName ) => {\n\t\t\tfontSizeAttributeNamesAccumulator[\n\t\t\t\tfontSizeAttributeName\n\t\t\t] = `custom${ upperFirst( fontSizeAttributeName ) }`;\n\t\t\treturn fontSizeAttributeNamesAccumulator;\n\t\t},\n\t\t{}\n\t);\n\n\treturn createHigherOrderComponent(\n\t\tcompose( [\n\t\t\tcreateHigherOrderComponent(\n\t\t\t\t( WrappedComponent ) => ( props ) => {\n\t\t\t\t\tconst fontSizes =\n\t\t\t\t\t\tuseSetting( 'typography.fontSizes' ) ||\n\t\t\t\t\t\tDEFAULT_FONT_SIZES;\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\tfontSizes={ fontSizes }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t'withFontSizes'\n\t\t\t),\n\t\t\t( WrappedComponent ) => {\n\t\t\t\treturn class extends Component {\n\t\t\t\t\tconstructor( props ) {\n\t\t\t\t\t\tsuper( props );\n\n\t\t\t\t\t\tthis.setters = this.createSetters();\n\n\t\t\t\t\t\tthis.state = {};\n\t\t\t\t\t}\n\n\t\t\t\t\tcreateSetters() {\n\t\t\t\t\t\treturn Object.entries( fontSizeAttributeNames ).reduce(\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tsettersAccumulator,\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\tfontSizeAttributeName,\n\t\t\t\t\t\t\t\t\tcustomFontSizeAttributeName,\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\tconst upperFirstFontSizeAttributeName =\n\t\t\t\t\t\t\t\t\tupperFirst( fontSizeAttributeName );\n\t\t\t\t\t\t\t\tsettersAccumulator[\n\t\t\t\t\t\t\t\t\t`set${ upperFirstFontSizeAttributeName }`\n\t\t\t\t\t\t\t\t] = this.createSetFontSize(\n\t\t\t\t\t\t\t\t\tfontSizeAttributeName,\n\t\t\t\t\t\t\t\t\tcustomFontSizeAttributeName\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn settersAccumulator;\n\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\n\t\t\t\t\tcreateSetFontSize(\n\t\t\t\t\t\tfontSizeAttributeName,\n\t\t\t\t\t\tcustomFontSizeAttributeName\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn ( fontSizeValue ) => {\n\t\t\t\t\t\t\tconst fontSizeObject = this.props.fontSizes?.find(\n\t\t\t\t\t\t\t\t( { size } ) => size === Number( fontSizeValue )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.props.setAttributes( {\n\t\t\t\t\t\t\t\t[ fontSizeAttributeName ]:\n\t\t\t\t\t\t\t\t\tfontSizeObject && fontSizeObject.slug\n\t\t\t\t\t\t\t\t\t\t? fontSizeObject.slug\n\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t[ customFontSizeAttributeName ]:\n\t\t\t\t\t\t\t\t\tfontSizeObject && fontSizeObject.slug\n\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t: fontSizeValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tstatic getDerivedStateFromProps(\n\t\t\t\t\t\t{ attributes, fontSizes },\n\t\t\t\t\t\tpreviousState\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst didAttributesChange = (\n\t\t\t\t\t\t\tcustomFontSizeAttributeName,\n\t\t\t\t\t\t\tfontSizeAttributeName\n\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\tif ( previousState[ fontSizeAttributeName ] ) {\n\t\t\t\t\t\t\t\t// If new font size is name compare with the previous slug.\n\t\t\t\t\t\t\t\tif ( attributes[ fontSizeAttributeName ] ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\tattributes[ fontSizeAttributeName ] !==\n\t\t\t\t\t\t\t\t\t\tpreviousState[ fontSizeAttributeName ]\n\t\t\t\t\t\t\t\t\t\t\t.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\t// If font size is not named, update when the font size value changes.\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\tpreviousState[ fontSizeAttributeName ]\n\t\t\t\t\t\t\t\t\t\t.size !==\n\t\t\t\t\t\t\t\t\tattributes[ customFontSizeAttributeName ]\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// In this case we need to build the font size object.\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! Object.values( fontSizeAttributeNames ).some(\n\t\t\t\t\t\t\t\tdidAttributesChange\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst newState = Object.entries(\n\t\t\t\t\t\t\tfontSizeAttributeNames\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.filter( ( [ key, value ] ) =>\n\t\t\t\t\t\t\t\tdidAttributesChange( value, key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.reduce(\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\tnewStateAccumulator,\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\tfontSizeAttributeName,\n\t\t\t\t\t\t\t\t\t\tcustomFontSizeAttributeName,\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\tconst fontSizeAttributeValue =\n\t\t\t\t\t\t\t\t\t\tattributes[ fontSizeAttributeName ];\n\t\t\t\t\t\t\t\t\tconst fontSizeObject = getFontSize(\n\t\t\t\t\t\t\t\t\t\tfontSizes,\n\t\t\t\t\t\t\t\t\t\tfontSizeAttributeValue,\n\t\t\t\t\t\t\t\t\t\tattributes[\n\t\t\t\t\t\t\t\t\t\t\tcustomFontSizeAttributeName\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\tnewStateAccumulator[\n\t\t\t\t\t\t\t\t\t\tfontSizeAttributeName\n\t\t\t\t\t\t\t\t\t] = {\n\t\t\t\t\t\t\t\t\t\t...fontSizeObject,\n\t\t\t\t\t\t\t\t\t\tclass: getFontSizeClass(\n\t\t\t\t\t\t\t\t\t\t\tfontSizeAttributeValue\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\treturn newStateAccumulator;\n\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\treturn {\n\t\t\t\t\t\t\t...previousState,\n\t\t\t\t\t\t\t...newState,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\trender() {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\t\t...this.props,\n\t\t\t\t\t\t\t\t\tfontSizes: undefined,\n\t\t\t\t\t\t\t\t\t...this.state,\n\t\t\t\t\t\t\t\t\t...this.setters,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\t\t] ),\n\t\t'withFontSizes'\n\t);\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,EAAEC,OAAO,QAAQ,oBAAoB;AACxE,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA,SAASC,WAAW,EAAEC,gBAAgB,QAAQ,SAAS;AACvD,OAAOC,UAAU,MAAM,gBAAgB;AAEvC,MAAMC,kBAAkB,GAAG,EAAE;;AAE7B;AACA;AACA;AACA;AACA;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EACA;UACD,OAAO,IAAI;QACZ;QAEA,MAAMG,QAAQ,GAAGpB,MAAM,CAACC,OAAO,CAC9Bb,sBACD,CAAC,CACCiC,MAAM,CAAE,CAAE,CAAEC,GAAG,EAAEC,KAAK,CAAE,KACxBN,mBAAmB,CAAEM,KAAK,EAAED,GAAI,CACjC,CAAC,CACAjC,MAAM,CACN,CACCmC,mBAAmB,EACnB,CACCjC,qBAAqB,EACrBY,2BAA2B,CAC3B,KACG;UACJ,MAAMsB,sBAAsB,GAC3BV,UAAU,CAAExB,qBAAqB,CAAE;UACpC,MAAMgB,cAAc,GAAG7B,WAAW,CACjCgB,SAAS,EACT+B,sBAAsB,EACtBV,UAAU,CACTZ,2BAA2B,CAE7B,CAAC;UACDqB,mBAAmB,CAClBjC,qBAAqB,CACrB,GAAG;YACH,GAAGgB,cAAc;YACjBmB,KAAK,EAAE/C,gBAAgB,CACtB8C,sBACD;UACD,CAAC;UACD,OAAOD,mBAAmB;QAC3B,CAAC,EACD,CAAC,CACF,CAAC;QAEF,OAAO;UACN,GAAGR,aAAa;UAChB,GAAGI;QACJ,CAAC;MACF;MAEAO,MAAMA,CAAA,EAAG;QACR,OACChC,aAAA,CAACH,gBAAgB;UAEf,GAAG,IAAI,CAACC,KAAK;UACbC,SAAS,EAAEmB,SAAS;UACpB,GAAG,IAAI,CAACd,KAAK;UACb,GAAG,IAAI,CAACF;QAAO,CAEhB,CAAC;MAEJ;IACD,CAAC;EACF,CAAC,CACA,CAAC,EACH,eACD,CAAC;AACF,CAAC"}
1
+ {"version":3,"names":["createHigherOrderComponent","compose","Component","getFontSize","getFontSizeClass","useSettings","DEFAULT_FONT_SIZES","upperFirst","firstLetter","rest","toUpperCase","join","fontSizeNames","fontSizeAttributeNames","reduce","fontSizeAttributeNamesAccumulator","fontSizeAttributeName","WrappedComponent","props","fontSizes","createElement","constructor","setters","createSetters","state","Object","entries","settersAccumulator","customFontSizeAttributeName","upperFirstFontSizeAttributeName","createSetFontSize","fontSizeValue","fontSizeObject","find","size","Number","setAttributes","slug","undefined","getDerivedStateFromProps","attributes","previousState","didAttributesChange","values","some","newState","filter","key","value","newStateAccumulator","fontSizeAttributeValue","class","render"],"sources":["@wordpress/block-editor/src/components/font-sizes/with-font-sizes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, compose } from '@wordpress/compose';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getFontSize, getFontSizeClass } from './utils';\nimport { useSettings } from '../use-settings';\n\nconst DEFAULT_FONT_SIZES = [];\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, which handles font size logic for class generation,\n * font size value retrieval, and font size change handling.\n *\n * @param {...(Object|string)} fontSizeNames The arguments should all be strings.\n * Each string contains the font size\n * attribute name e.g: 'fontSize'.\n *\n * @return {Function} Higher-order component.\n */\nexport default ( ...fontSizeNames ) => {\n\t/*\n\t * Computes an object whose key is the font size attribute name as passed in the array,\n\t * and the value is the custom font size attribute name.\n\t * Custom font size is automatically compted by appending custom followed by the font size attribute name in with the first letter capitalized.\n\t */\n\tconst fontSizeAttributeNames = fontSizeNames.reduce(\n\t\t( fontSizeAttributeNamesAccumulator, fontSizeAttributeName ) => {\n\t\t\tfontSizeAttributeNamesAccumulator[\n\t\t\t\tfontSizeAttributeName\n\t\t\t] = `custom${ upperFirst( fontSizeAttributeName ) }`;\n\t\t\treturn fontSizeAttributeNamesAccumulator;\n\t\t},\n\t\t{}\n\t);\n\n\treturn createHigherOrderComponent(\n\t\tcompose( [\n\t\t\tcreateHigherOrderComponent(\n\t\t\t\t( WrappedComponent ) => ( props ) => {\n\t\t\t\t\tconst [ fontSizes ] = useSettings( 'typography.fontSizes' );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\tfontSizes={ fontSizes || DEFAULT_FONT_SIZES }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t'withFontSizes'\n\t\t\t),\n\t\t\t( WrappedComponent ) => {\n\t\t\t\treturn class extends Component {\n\t\t\t\t\tconstructor( props ) {\n\t\t\t\t\t\tsuper( props );\n\n\t\t\t\t\t\tthis.setters = this.createSetters();\n\n\t\t\t\t\t\tthis.state = {};\n\t\t\t\t\t}\n\n\t\t\t\t\tcreateSetters() {\n\t\t\t\t\t\treturn Object.entries( fontSizeAttributeNames ).reduce(\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tsettersAccumulator,\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\tfontSizeAttributeName,\n\t\t\t\t\t\t\t\t\tcustomFontSizeAttributeName,\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\tconst upperFirstFontSizeAttributeName =\n\t\t\t\t\t\t\t\t\tupperFirst( fontSizeAttributeName );\n\t\t\t\t\t\t\t\tsettersAccumulator[\n\t\t\t\t\t\t\t\t\t`set${ upperFirstFontSizeAttributeName }`\n\t\t\t\t\t\t\t\t] = this.createSetFontSize(\n\t\t\t\t\t\t\t\t\tfontSizeAttributeName,\n\t\t\t\t\t\t\t\t\tcustomFontSizeAttributeName\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn settersAccumulator;\n\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\n\t\t\t\t\tcreateSetFontSize(\n\t\t\t\t\t\tfontSizeAttributeName,\n\t\t\t\t\t\tcustomFontSizeAttributeName\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn ( fontSizeValue ) => {\n\t\t\t\t\t\t\tconst fontSizeObject = this.props.fontSizes?.find(\n\t\t\t\t\t\t\t\t( { size } ) => size === Number( fontSizeValue )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tthis.props.setAttributes( {\n\t\t\t\t\t\t\t\t[ fontSizeAttributeName ]:\n\t\t\t\t\t\t\t\t\tfontSizeObject && fontSizeObject.slug\n\t\t\t\t\t\t\t\t\t\t? fontSizeObject.slug\n\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t[ customFontSizeAttributeName ]:\n\t\t\t\t\t\t\t\t\tfontSizeObject && fontSizeObject.slug\n\t\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t\t: fontSizeValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tstatic getDerivedStateFromProps(\n\t\t\t\t\t\t{ attributes, fontSizes },\n\t\t\t\t\t\tpreviousState\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst didAttributesChange = (\n\t\t\t\t\t\t\tcustomFontSizeAttributeName,\n\t\t\t\t\t\t\tfontSizeAttributeName\n\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\tif ( previousState[ fontSizeAttributeName ] ) {\n\t\t\t\t\t\t\t\t// If new font size is name compare with the previous slug.\n\t\t\t\t\t\t\t\tif ( attributes[ fontSizeAttributeName ] ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\tattributes[ fontSizeAttributeName ] !==\n\t\t\t\t\t\t\t\t\t\tpreviousState[ fontSizeAttributeName ]\n\t\t\t\t\t\t\t\t\t\t\t.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\t// If font size is not named, update when the font size value changes.\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\tpreviousState[ fontSizeAttributeName ]\n\t\t\t\t\t\t\t\t\t\t.size !==\n\t\t\t\t\t\t\t\t\tattributes[ customFontSizeAttributeName ]\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// In this case we need to build the font size object.\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t! Object.values( fontSizeAttributeNames ).some(\n\t\t\t\t\t\t\t\tdidAttributesChange\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst newState = Object.entries(\n\t\t\t\t\t\t\tfontSizeAttributeNames\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.filter( ( [ key, value ] ) =>\n\t\t\t\t\t\t\t\tdidAttributesChange( value, key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.reduce(\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\tnewStateAccumulator,\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\tfontSizeAttributeName,\n\t\t\t\t\t\t\t\t\t\tcustomFontSizeAttributeName,\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\tconst fontSizeAttributeValue =\n\t\t\t\t\t\t\t\t\t\tattributes[ fontSizeAttributeName ];\n\t\t\t\t\t\t\t\t\tconst fontSizeObject = getFontSize(\n\t\t\t\t\t\t\t\t\t\tfontSizes,\n\t\t\t\t\t\t\t\t\t\tfontSizeAttributeValue,\n\t\t\t\t\t\t\t\t\t\tattributes[\n\t\t\t\t\t\t\t\t\t\t\tcustomFontSizeAttributeName\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\tnewStateAccumulator[\n\t\t\t\t\t\t\t\t\t\tfontSizeAttributeName\n\t\t\t\t\t\t\t\t\t] = {\n\t\t\t\t\t\t\t\t\t\t...fontSizeObject,\n\t\t\t\t\t\t\t\t\t\tclass: getFontSizeClass(\n\t\t\t\t\t\t\t\t\t\t\tfontSizeAttributeValue\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\treturn newStateAccumulator;\n\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\treturn {\n\t\t\t\t\t\t\t...previousState,\n\t\t\t\t\t\t\t...newState,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\trender() {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\t\t...this.props,\n\t\t\t\t\t\t\t\t\tfontSizes: undefined,\n\t\t\t\t\t\t\t\t\t...this.state,\n\t\t\t\t\t\t\t\t\t...this.setters,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\t\t] ),\n\t\t'withFontSizes'\n\t);\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,EAAEC,OAAO,QAAQ,oBAAoB;AACxE,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA,SAASC,WAAW,EAAEC,gBAAgB,QAAQ,SAAS;AACvD,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,MAAMC,kBAAkB,GAAG,EAAE;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAGA,CAAE,CAAEC,WAAW,EAAE,GAAGC,IAAI,CAAE,KAC5CD,WAAW,CAACE,WAAW,CAAC,CAAC,GAAGD,IAAI,CAACE,IAAI,CAAE,EAAG,CAAC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,CAAE,GAAGC,aAAa,KAAM;EACtC;AACD;AACA;AACA;AACA;EACC,MAAMC,sBAAsB,GAAGD,aA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ACJ,MAAMsB,sBAAsB,GAC3BV,UAAU,CAAExB,qBAAqB,CAAE;UACpC,MAAMgB,cAAc,GAAG7B,WAAW,CACjCgB,SAAS,EACT+B,sBAAsB,EACtBV,UAAU,CACTZ,2BAA2B,CAE7B,CAAC;UACDqB,mBAAmB,CAClBjC,qBAAqB,CACrB,GAAG;YACH,GAAGgB,cAAc;YACjBmB,KAAK,EAAE/C,gBAAgB,CACtB8C,sBACD;UACD,CAAC;UACD,OAAOD,mBAAmB;QAC3B,CAAC,EACD,CAAC,CACF,CAAC;QAEF,OAAO;UACN,GAAGR,aAAa;UAChB,GAAGI;QACJ,CAAC;MACF;MAEAO,MAAMA,CAAA,EAAG;QACR,OACChC,aAAA,CAACH,gBAAgB;UAEf,GAAG,IAAI,CAACC,KAAK;UACbC,SAAS,EAAEmB,SAAS;UACpB,GAAG,IAAI,CAACd,KAAK;UACb,GAAG,IAAI,CAACF;QAAO,CAEhB,CAAC;MAEJ;IACD,CAAC;EACF,CAAC,CACA,CAAC,EACH,eACD,CAAC;AACF,CAAC"}
@@ -28,11 +28,10 @@ function useMultiOriginColorPresets(settings, {
28
28
  return useMemo(() => [...userPresets, ...themePresets, ...(disableDefault ? EMPTY_ARRAY : defaultPresets)], [disableDefault, userPresets, themePresets, defaultPresets]);
29
29
  }
30
30
  export function useHasFiltersPanel(settings) {
31
- const hasDuotone = useHasDuotoneControl(settings);
32
- return hasDuotone;
31
+ return useHasDuotoneControl(settings);
33
32
  }
34
33
  function useHasDuotoneControl(settings) {
35
- return settings.color.customDuotone || settings.color.defaultDuotone;
34
+ return settings.color.customDuotone || settings.color.defaultDuotone || settings.color.duotone.length > 0;
36
35
  }
37
36
  function FiltersToolsPanel({
38
37
  resetAllFilter,
@@ -113,8 +112,6 @@ export default function FiltersPanel({
113
112
  };
114
113
  const hasDuotone = () => !!value?.filter?.duotone;
115
114
  const resetDuotone = () => setDuotone(undefined);
116
- const disableCustomColors = !settings?.color?.custom;
117
- const disableCustomDuotone = !settings?.color?.customDuotone || colorPalette?.length === 0 && disableCustomColors;
118
115
  const resetAllFilter = useCallback(previousValue => {
119
116
  return {
120
117
  ...previousValue,
@@ -163,9 +160,11 @@ export default function FiltersPanel({
163
160
  paddingSize: "medium"
164
161
  }, createElement(VStack, null, createElement("p", null, __('Create a two-tone color effect without losing your original image.')), createElement(DuotonePicker, {
165
162
  colorPalette: colorPalette,
166
- duotonePalette: duotonePalette,
167
- disableCustomColors: disableCustomColors,
168
- disableCustomDuotone: disableCustomDuotone,
163
+ duotonePalette: duotonePalette
164
+ // TODO: Re-enable both when custom colors are supported for block-level styles.
165
+ ,
166
+ disableCustomColors: true,
167
+ disableCustomDuotone: true,
169
168
  value: duotone,
170
169
  onChange: setDuotone
171
170
  })))