@wordpress/block-editor 8.0.4 → 8.0.8

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 (81) hide show
  1. package/build/components/block-preview/auto.js +1 -0
  2. package/build/components/block-preview/auto.js.map +1 -1
  3. package/build/components/block-tools/block-selection-button.js +7 -1
  4. package/build/components/block-tools/block-selection-button.js.map +1 -1
  5. package/build/components/colors/with-colors.js +9 -4
  6. package/build/components/colors/with-colors.js.map +1 -1
  7. package/build/components/colors-gradients/control.js +6 -2
  8. package/build/components/colors-gradients/control.js.map +1 -1
  9. package/build/components/colors-gradients/panel-color-gradient-settings.js +11 -70
  10. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  11. package/build/components/colors-gradients/use-common-single-multiple-selects.js +21 -0
  12. package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +1 -0
  13. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +98 -0
  14. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -0
  15. package/build/components/gradients/use-gradient.js +7 -6
  16. package/build/components/gradients/use-gradient.js.map +1 -1
  17. package/build/components/use-setting/index.js +1 -1
  18. package/build/components/use-setting/index.js.map +1 -1
  19. package/build/hooks/border-color.js +12 -12
  20. package/build/hooks/border-color.js.map +1 -1
  21. package/build/hooks/color-panel.js +2 -1
  22. package/build/hooks/color-panel.js.map +1 -1
  23. package/build/hooks/color.js +45 -23
  24. package/build/hooks/color.js.map +1 -1
  25. package/build/hooks/typography.js +3 -0
  26. package/build/hooks/typography.js.map +1 -1
  27. package/build/hooks/use-color-props.js +19 -6
  28. package/build/hooks/use-color-props.js.map +1 -1
  29. package/build/store/selectors.js +37 -43
  30. package/build/store/selectors.js.map +1 -1
  31. package/build-module/components/block-preview/auto.js +1 -0
  32. package/build-module/components/block-preview/auto.js.map +1 -1
  33. package/build-module/components/block-tools/block-selection-button.js +7 -1
  34. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  35. package/build-module/components/colors/with-colors.js +9 -4
  36. package/build-module/components/colors/with-colors.js.map +1 -1
  37. package/build-module/components/colors-gradients/control.js +6 -2
  38. package/build-module/components/colors-gradients/control.js.map +1 -1
  39. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +10 -72
  40. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  41. package/build-module/components/colors-gradients/use-common-single-multiple-selects.js +11 -0
  42. package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +1 -0
  43. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +85 -0
  44. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -0
  45. package/build-module/components/gradients/use-gradient.js +7 -6
  46. package/build-module/components/gradients/use-gradient.js.map +1 -1
  47. package/build-module/components/use-setting/index.js +1 -1
  48. package/build-module/components/use-setting/index.js.map +1 -1
  49. package/build-module/hooks/border-color.js +11 -12
  50. package/build-module/hooks/border-color.js.map +1 -1
  51. package/build-module/hooks/color-panel.js +2 -1
  52. package/build-module/hooks/color-panel.js.map +1 -1
  53. package/build-module/hooks/color.js +46 -24
  54. package/build-module/hooks/color.js.map +1 -1
  55. package/build-module/hooks/typography.js +1 -2
  56. package/build-module/hooks/typography.js.map +1 -1
  57. package/build-module/hooks/use-color-props.js +16 -4
  58. package/build-module/hooks/use-color-props.js.map +1 -1
  59. package/build-module/store/selectors.js +37 -43
  60. package/build-module/store/selectors.js.map +1 -1
  61. package/build-style/style-rtl.css +8 -1
  62. package/build-style/style.css +8 -1
  63. package/package.json +3 -3
  64. package/src/components/block-preview/auto.js +3 -0
  65. package/src/components/block-preview/style.scss +5 -0
  66. package/src/components/block-tools/block-selection-button.js +5 -1
  67. package/src/components/colors/with-colors.js +16 -5
  68. package/src/components/colors-gradients/control.js +6 -0
  69. package/src/components/colors-gradients/panel-color-gradient-settings.js +8 -92
  70. package/src/components/colors-gradients/use-common-single-multiple-selects.js +11 -0
  71. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +107 -0
  72. package/src/components/gradients/use-gradient.js +18 -7
  73. package/src/components/link-control/style.scss +6 -2
  74. package/src/components/use-setting/index.js +1 -1
  75. package/src/hooks/border-color.js +15 -9
  76. package/src/hooks/color-panel.js +1 -0
  77. package/src/hooks/color.js +71 -31
  78. package/src/hooks/test/color.js +109 -0
  79. package/src/hooks/typography.js +1 -1
  80. package/src/hooks/use-color-props.js +30 -4
  81. package/src/store/selectors.js +14 -26
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js"],"names":["useMultipleOriginColorsAndGradients","colorGradientSettings","customColors","themeColors","defaultColors","shouldDisplayDefaultColors","colors","result","length","push","name","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients","gradients"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,mCAAT,GAA+C;AAC7D,QAAMC,qBAAqB,GAAG,8CAA9B;AACA,QAAMC,YAAY,GAAG,yBAAY,sBAAZ,CAArB;AACA,QAAMC,WAAW,GAAG,yBAAY,qBAAZ,CAApB;AACA,QAAMC,aAAa,GAAG,yBAAY,uBAAZ,CAAtB;AACA,QAAMC,0BAA0B,GAAG,yBAAY,sBAAZ,CAAnC;AAEAJ,EAAAA,qBAAqB,CAACK,MAAtB,GAA+B,sBAAS,MAAM;AAC7C,UAAMC,MAAM,GAAG,EAAf;;AACA,QAAKJ,WAAW,IAAIA,WAAW,CAACK,MAAhC,EAAyC;AACxCD,MAAAA,MAAM,CAACE,IAAP,CAAa;AACZC,QAAAA,IAAI,EAAE,cACL,OADK,EAEL,8CAFK,CADM;AAKZJ,QAAAA,MAAM,EAAEH;AALI,OAAb;AAOA;;AACD,QACCE,0BAA0B,IAC1BD,aADA,IAEAA,aAAa,CAACI,M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E,cACL,QADK,EAEL,gDAFK,CADM;AAKZK,QAAAA,SAAS,EAAEJ;AALC,OAAb;AAOA;;AACD,WAAOJ,MAAP;AACA,GAlCiC,EAkC/B,CAAEI,eAAF,EAAmBC,cAAnB,EAAmCC,gBAAnC,CAlC+B,CAAlC;AAoCA,SAAOZ,qBAAP;AACA","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';\nimport useCommonSingleMultipleSelects from './use-common-single-multiple-selects';\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 = useCommonSingleMultipleSelects();\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}, [ defaultColors, themeColors, customColors ] );\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}, [ customGradients, themeGradients, defaultGradients ] );\n\n\treturn colorGradientSettings;\n}\n"]}
@@ -34,8 +34,6 @@ var _store = require("../../store");
34
34
  /**
35
35
  * Internal dependencies
36
36
  */
37
- const EMPTY_ARRAY = [];
38
-
39
37
  function __experimentalGetGradientClass(gradientSlug) {
40
38
  if (!gradientSlug) {
41
39
  return undefined;
@@ -77,6 +75,8 @@ function getGradientSlugByValue(gradients, value) {
77
75
  return gradient && gradient.slug;
78
76
  }
79
77
 
78
+ const EMPTY_OBJECT = {};
79
+
80
80
  function __experimentalUseGradient() {
81
81
  let {
82
82
  gradientAttribute = 'gradient',
@@ -85,7 +85,8 @@ function __experimentalUseGradient() {
85
85
  const {
86
86
  clientId
87
87
  } = (0, _blockEdit.useBlockEditContext)();
88
- const gradients = (0, _useSetting.default)('color.gradients') || EMPTY_ARRAY;
88
+ const gradientsPerOrigin = (0, _useSetting.default)('color.gradients') || EMPTY_OBJECT;
89
+ const allGradients = (0, _element.useMemo)(() => [...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.custom) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.theme) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.default) || [])], [gradientsPerOrigin]);
89
90
  const {
90
91
  gradient,
91
92
  customGradient
@@ -103,7 +104,7 @@ function __experimentalUseGradient() {
103
104
  updateBlockAttributes
104
105
  } = (0, _data.useDispatch)(_store.store);
105
106
  const setGradient = (0, _element.useCallback)(newGradientValue => {
106
- const slug = getGradientSlugByValue(gradients, newGradientValue);
107
+ const slug = getGradientSlugByValue(allGradients, newGradientValue);
107
108
 
108
109
  if (slug) {
109
110
  updateBlockAttributes(clientId, {
@@ -117,14 +118,14 @@ function __experimentalUseGradient() {
117
118
  [gradientAttribute]: undefined,
118
119
  [customGradientAttribute]: newGradientValue
119
120
  });
120
- }, [gradients, clientId, updateBlockAttributes]);
121
+ }, [allGradients, clientId, updateBlockAttributes]);
121
122
 
122
123
  const gradientClass = __experimentalGetGradientClass(gradient);
123
124
 
124
125
  let gradientValue;
125
126
 
126
127
  if (gradient) {
127
- gradientValue = getGradientValueBySlug(gradients, gradient);
128
+ gradientValue = getGradientValueBySlug(allGradients, gradient);
128
129
  } else {
129
130
  gradientValue = customGradient;
130
131
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/gradients/use-gradient.js"],"names":["EMPTY_ARRAY","__experimentalGetGradientClass","gradientSlug","undefined","getGradientValueBySlug","gradients","slug","gradient","__experimentalGetGradientObjectByGradientValue","value","getGradientSlugByValue","__experimentalUseGradient","gradientAttribute","customGradientAttribute","clientId","customGradient","select","getBlockAttributes","blockEditorStore","attributes","updateBlockAttributes","setGradient","newGradientValue","gradientClass","gradientValue"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAKA,MAAMA,WAAW,GAAG,EAApB;;AAEO,SAASC,8BAAT,CAAyCC,YAAzC,EAAwD;AAC9D,MAAK,CAAEA,YAAP,EAAsB;AACrB,WAAOC,SAAP;AACA;;AACD,SAAQ,OAAOD,YAAc,sBAA7B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,sBAAT,CAAiCC,SAAjC,EAA4CC,IAA5C,EAAmD;AACzD,QAAMC,QAAQ,GAAG,kBAAMF,SAAN,EAAiB,CAAE,MAAF,EAAUC,IAAV,CAAjB,CAAjB;AACA,SAAOC,QAAQ,IAAIA,QAAQ,CAACA,QAA5B;AACA;;AAEM,SAASC,8CAAT,CACNH,SADM,EAENI,KAFM,EAGL;AACD,QAAMF,QAAQ,GAAG,kBAAMF,SAAN,EAAiB,CAAE,UAAF,EAAcI,KAAd,CAAjB,CAAjB;AACA,SAAOF,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,sBAAT,CAAiCL,SAAjC,EAA4CI,KAA5C,EAAoD;AAC1D,QAAMF,QAAQ,GAAGC,8CAA8C,CAC9DH,SAD8D,EAE9DI,KAF8D,CAA/D;;AAIA,SAAOF,QAAQ,IAAIA,QAAQ,CAACD,IAA5B;AACA;;AAEM,SAASK,yBAAT,GAGE;AAAA,MAHkC;AAC1CC,IAAAA,iBAAiB,GAAG,UADsB;AAE1CC,IAAAA,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GpB,sBAAsB,CAAEC,SAAF,EAAaE,QAAb,CAAtC;AACA,GAFD,MAEO;AACNiB,IAAAA,aAAa,GAAGT,cAAhB;AACA;;AACD,SAAO;AAAEQ,IAAAA,aAAF;AAAiBC,IAAAA,aAAjB;AAAgCH,IAAAA;AAAhC,GAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport useSetting from '../use-setting';\nimport { store as blockEditorStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nexport function __experimentalGetGradientClass( gradientSlug ) {\n\tif ( ! gradientSlug ) {\n\t\treturn undefined;\n\t}\n\treturn `has-${ gradientSlug }-gradient-background`;\n}\n\n/**\n * Retrieves the gradient value per slug.\n *\n * @param {Array} gradients Gradient Palette\n * @param {string} slug Gradient slug\n *\n * @return {string} Gradient value.\n */\nexport function getGradientValueBySlug( gradients, slug ) {\n\tconst gradient = find( gradients, [ 'slug', slug ] );\n\treturn gradient && gradient.gradient;\n}\n\nexport function __experimentalGetGradientObjectByGradientValue(\n\tgradients,\n\tvalue\n) {\n\tconst gradient = find( gradients, [ 'gradient', value ] );\n\treturn gradient;\n}\n\n/**\n * Retrieves the gradient slug per slug.\n *\n * @param {Array} gradients Gradient Palette\n * @param {string} value Gradient value\n * @return {string} Gradient slug.\n */\nexport function getGradientSlugByValue( gradients, value ) {\n\tconst gradient = __experimentalGetGradientObjectByGradientValue(\n\t\tgradients,\n\t\tvalue\n\t);\n\treturn gradient && gradient.slug;\n}\n\nexport function __experimentalUseGradient( {\n\tgradientAttribute = 'gradient',\n\tcustomGradientAttribute = 'customGradient',\n} = {} ) {\n\tconst { clientId } = useBlockEditContext();\n\n\tconst gradients = useSetting( 'color.gradients' ) || EMPTY_ARRAY;\n\tconst { gradient, customGradient } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId ) || {};\n\t\t\treturn {\n\t\t\t\tcustomGradient: attributes[ customGradientAttribute ],\n\t\t\t\tgradient: attributes[ gradientAttribute ],\n\t\t\t};\n\t\t},\n\t\t[ clientId, gradientAttribute, customGradientAttribute ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst setGradient = useCallback(\n\t\t( newGradientValue ) => {\n\t\t\tconst slug = getGradientSlugByValue( gradients, newGradientValue );\n\t\t\tif ( slug ) {\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\t[ gradientAttribute ]: slug,\n\t\t\t\t\t[ customGradientAttribute ]: undefined,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t[ gradientAttribute ]: undefined,\n\t\t\t\t[ customGradientAttribute ]: newGradientValue,\n\t\t\t} );\n\t\t},\n\t\t[ gradients, clientId, updateBlockAttributes ]\n\t);\n\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tlet gradientValue;\n\tif ( gradient ) {\n\t\tgradientValue = getGradientValueBySlug( gradients, gradient );\n\t} else {\n\t\tgradientValue = customGradient;\n\t}\n\treturn { gradientClass, gradientValue, setGradient };\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/gradients/use-gradient.js"],"names":["__experimentalGetGradientClass","gradientSlug","undefined","getGradientValueBySlug","gradients","slug","gradient","__experimentalGetGradientObjectByGradientValue","value","getGradientSlugByValue","EMPTY_OBJECT","__experimentalUseGradient","gradientAttribute","customGradientAttribute","clientId","gradientsPerOrigin","allGradients","custom","theme","default","customGradient","select","getBlockAttributes","blockEditorStore","attributes","updateBlockAttributes","setGradient","newGradientValue","gradientClass","gradientValue"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;AACA;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8B,CAAEM,QAAF,CAApD;;AACA,MAAIuB,aAAJ;;AACA,MAAKvB,QAAL,EAAgB;AACfuB,IAAAA,aAAa,GAAG1B,sBAAsB,CAAEa,YAAF,EAAgBV,QAAhB,CAAtC;AACA,GAFD,MAEO;AACNuB,IAAAA,aAAa,GAAGT,cAAhB;AACA;;AACD,SAAO;AAAEQ,IAAAA,aAAF;AAAiBC,IAAAA,aAAjB;AAAgCH,IAAAA;AAAhC,GAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport useSetting from '../use-setting';\nimport { store as blockEditorStore } from '../../store';\n\nexport function __experimentalGetGradientClass( gradientSlug ) {\n\tif ( ! gradientSlug ) {\n\t\treturn undefined;\n\t}\n\treturn `has-${ gradientSlug }-gradient-background`;\n}\n\n/**\n * Retrieves the gradient value per slug.\n *\n * @param {Array} gradients Gradient Palette\n * @param {string} slug Gradient slug\n *\n * @return {string} Gradient value.\n */\nexport function getGradientValueBySlug( gradients, slug ) {\n\tconst gradient = find( gradients, [ 'slug', slug ] );\n\treturn gradient && gradient.gradient;\n}\n\nexport function __experimentalGetGradientObjectByGradientValue(\n\tgradients,\n\tvalue\n) {\n\tconst gradient = find( gradients, [ 'gradient', value ] );\n\treturn gradient;\n}\n\n/**\n * Retrieves the gradient slug per slug.\n *\n * @param {Array} gradients Gradient Palette\n * @param {string} value Gradient value\n * @return {string} Gradient slug.\n */\nexport function getGradientSlugByValue( gradients, value ) {\n\tconst gradient = __experimentalGetGradientObjectByGradientValue(\n\t\tgradients,\n\t\tvalue\n\t);\n\treturn gradient && gradient.slug;\n}\n\nconst EMPTY_OBJECT = {};\n\nexport function __experimentalUseGradient( {\n\tgradientAttribute = 'gradient',\n\tcustomGradientAttribute = 'customGradient',\n} = {} ) {\n\tconst { clientId } = useBlockEditContext();\n\n\tconst gradientsPerOrigin = useSetting( 'color.gradients' ) || EMPTY_OBJECT;\n\tconst allGradients = useMemo(\n\t\t() => [\n\t\t\t...( gradientsPerOrigin?.custom || [] ),\n\t\t\t...( gradientsPerOrigin?.theme || [] ),\n\t\t\t...( gradientsPerOrigin?.default || [] ),\n\t\t],\n\t\t[ gradientsPerOrigin ]\n\t);\n\tconst { gradient, customGradient } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId ) || {};\n\t\t\treturn {\n\t\t\t\tcustomGradient: attributes[ customGradientAttribute ],\n\t\t\t\tgradient: attributes[ gradientAttribute ],\n\t\t\t};\n\t\t},\n\t\t[ clientId, gradientAttribute, customGradientAttribute ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst setGradient = useCallback(\n\t\t( newGradientValue ) => {\n\t\t\tconst slug = getGradientSlugByValue(\n\t\t\t\tallGradients,\n\t\t\t\tnewGradientValue\n\t\t\t);\n\t\t\tif ( slug ) {\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\t[ gradientAttribute ]: slug,\n\t\t\t\t\t[ customGradientAttribute ]: undefined,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t[ gradientAttribute ]: undefined,\n\t\t\t\t[ customGradientAttribute ]: newGradientValue,\n\t\t\t} );\n\t\t},\n\t\t[ allGradients, clientId, updateBlockAttributes ]\n\t);\n\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tlet gradientValue;\n\tif ( gradient ) {\n\t\tgradientValue = getGradientValueBySlug( allGradients, gradient );\n\t} else {\n\t\tgradientValue = customGradient;\n\t}\n\treturn { gradientClass, gradientValue, setGradient };\n}\n"]}
@@ -118,7 +118,7 @@ function useSetting(path) {
118
118
  if (_blocks.__EXPERIMENTAL_PATHS_WITH_MERGE[normalizedPath]) {
119
119
  var _ref, _experimentalFeatures;
120
120
 
121
- return (_ref = (_experimentalFeatures = experimentalFeaturesResult.user) !== null && _experimentalFeatures !== void 0 ? _experimentalFeatures : experimentalFeaturesResult.theme) !== null && _ref !== void 0 ? _ref : experimentalFeaturesResult.default;
121
+ return (_ref = (_experimentalFeatures = experimentalFeaturesResult.custom) !== null && _experimentalFeatures !== void 0 ? _experimentalFeatures : experimentalFeaturesResult.theme) !== null && _ref !== void 0 ? _ref : experimentalFeaturesResult.default;
122
122
  }
123
123
 
124
124
  return experimentalFeaturesResult;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","setting","select","blockEditorStore","getSettings","normalizedPath","defaultsPath","blockPath","experimentalFeaturesResult","PATHS_WITH_MERGE","user","theme","default","deprecatedSettingsValue"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAIA,MAAMA,eAAe,GAAG;AACvB,mBAAmBC,QAAF,IAChBA,QAAQ,CAACC,MAAT,KAAoBC,SAApB,GAAgCA,SAAhC,GAA4CF,QAAQ,CAACC,MAF/B;AAGvB,qBAAqBD,QAAF,IAClBA,QAAQ,CAACG,SAAT,KAAuBD,SAAvB,GAAmCA,SAAnC,GAA+CF,QAAQ,CAACG,SAJlC;AAKvB,kBAAkBH,QAAF,IACfA,QAAQ,CAACI,mBAAT,KAAiCF,SAAjC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACI,mBARQ;AASvB,0BAA0BJ,QAAF,IACvBA,QAAQ,CAACK,sBAAT,KAAoCH,SAApC,GACGA,SADH,GAEG,CAAEF,QAAQ,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C,UAAT,CAAqBD,IAArB,EAA4B;AAC1C,QAAM;AAAEE,IAAAA,IAAI,EAAEC;AAAR,MAAsB,qCAA5B;AAEA,QAAMC,OAAO,GAAG,qBACbC,MAAF,IAAc;AAAA;;AACb,UAAMlB,QAAQ,GAAGkB,MAAM,CAAEC,YAAF,CAAN,CAA2BC,WAA3B,EAAjB,CADa,CAGb;AACA;;AACA,UAAMC,cAAc,GAAGT,oBAAoB,CAAEC,IAAF,CAA3C;AACA,UAAMS,YAAY,GAAI,0BAA0BD,cAAgB,EAAhE;AACA,UAAME,SAAS,GAAI,iCAAiCP,SAAW,IAAIK,cAAgB,EAAnF;AACA,UAAMG,0BAA0B,WAC/B,iBAAKxB,QAAL,EAAeuB,SAAf,CAD+B,uCACD,iBAAKvB,QAAL,EAAesB,YAAf,CAD/B;;AAGA,QAAKE,0BAA0B,KAAKtB,SAApC,EAAgD;AAC/C,UAAKuB,wCAAkBJ,cAAlB,CAAL,EAA0C;AAAA;;AACzC,gDACCG,0BAA0B,CAACE,IAD5B,yEAECF,0BAA0B,CAACG,KAF5B,uCAGCH,0BAA0B,CAACI,OAH5B;AAKA;;AACD,aAAOJ,0BAAP;AACA,KApBY,CAsBb;;;AACA,UAAMK,uBAAuB,GAAG9B,eAAe,CAAEsB,cAAF,CAAf,GAC7BtB,eAAe,CAAEsB,cAAF,CAAf,CAAmCrB,QAAnC,CAD6B,GAE7BE,SAFH;;AAGA,QAAK2B,uBAAuB,KAAK3B,SAAjC,EAA6C;AAC5C,aAAO2B,uBAAP;AACA,KA5BY,CA8Bb;AACA;AACA;AACA;;;AACA,WAAOR,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDnB,SAAxD;AACA,GApCc,EAqCf,CAAEc,SAAF,EAAaH,IAAb,CArCe,CAAhB;AAwCA,SAAOI,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * Hook that retrieves the editor setting.\n * It works with nested objects using by finding the value at path.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\t// 1 - Use __experimental features, if available.\n\t\t\t// We cascade to the all value if the block one is not available.\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\tconst experimentalFeaturesResult =\n\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\n\t\t\tif ( experimentalFeaturesResult !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\texperimentalFeaturesResult.user ??\n\t\t\t\t\t\texperimentalFeaturesResult.theme ??\n\t\t\t\t\t\texperimentalFeaturesResult.default\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn experimentalFeaturesResult;\n\t\t\t}\n\n\t\t\t// 2 - Use deprecated settings, otherwise.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]\n\t\t\t\t? deprecatedFlags[ normalizedPath ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 3 - Fall back for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, path ]\n\t);\n\n\treturn setting;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","setting","select","blockEditorStore","getSettings","normalizedPath","defaultsPath","blockPath","experimentalFeaturesResult","PATHS_WITH_MERGE","custom","theme","default","deprecatedSettingsValue"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAIA,MAAMA,eAAe,GAAG;AACvB,mBAAmBC,QAAF,IAChBA,QAAQ,CAACC,MAAT,KAAoBC,SAApB,GAAgCA,SAAhC,GAA4CF,QAAQ,CAACC,MAF/B;AAGvB,qBAAqBD,QAAF,IAClBA,QAAQ,CAACG,SAAT,KAAuBD,SAAvB,GAAmCA,SAAnC,GAA+CF,QAAQ,CAACG,SAJlC;AAKvB,kBAAkBH,QAAF,IACfA,QAAQ,CAACI,mBAAT,KAAiCF,SAAjC,GACGA,SADH,GAEG,CAAEF,QAAQ,CAACI,mBARQ;AASvB,0BAA0BJ,QAAF,IACvBA,QAAQ,CAACK,sBAAT,KAAoCH,SAApC,G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AACA;AACA;AACA;AACA;;;AACe,SAASC,UAAT,CAAqBD,IAArB,EAA4B;AAC1C,QAAM;AAAEE,IAAAA,IAAI,EAAEC;AAAR,MAAsB,qCAA5B;AAEA,QAAMC,OAAO,GAAG,qBACbC,MAAF,IAAc;AAAA;;AACb,UAAMlB,QAAQ,GAAGkB,MAAM,CAAEC,YAAF,CAAN,CAA2BC,WAA3B,EAAjB,CADa,CAGb;AACA;;AACA,UAAMC,cAAc,GAAGT,oBAAoB,CAAEC,IAAF,CAA3C;AACA,UAAMS,YAAY,GAAI,0BAA0BD,cAAgB,EAAhE;AACA,UAAME,SAAS,GAAI,iCAAiCP,SAAW,IAAIK,cAAgB,EAAnF;AACA,UAAMG,0BAA0B,WAC/B,iBAAKxB,QAAL,EAAeuB,SAAf,CAD+B,uCACD,iBAAKvB,QAAL,EAAesB,YAAf,CAD/B;;AAGA,QAAKE,0BAA0B,KAAKtB,SAApC,EAAgD;AAC/C,UAAKuB,wCAAkBJ,cAAlB,CAAL,EAA0C;AAAA;;AACzC,gDACCG,0BAA0B,CAACE,MAD5B,yEAECF,0BAA0B,CAACG,KAF5B,uCAGCH,0BAA0B,CAACI,OAH5B;AAKA;;AACD,aAAOJ,0BAAP;AACA,KApBY,CAsBb;;;AACA,UAAMK,uBAAuB,GAAG9B,eAAe,CAAEsB,cAAF,CAAf,GAC7BtB,eAAe,CAAEsB,cAAF,CAAf,CAAmCrB,QAAnC,CAD6B,GAE7BE,SAFH;;AAGA,QAAK2B,uBAAuB,KAAK3B,SAAjC,EAA6C;AAC5C,aAAO2B,uBAAP;AACA,KA5BY,CA8Bb;AACA;AACA;AACA;;;AACA,WAAOR,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDnB,SAAxD;AACA,GApCc,EAqCf,CAAEc,SAAF,EAAaH,IAAb,CArCe,CAAhB;AAwCA,SAAOI,OAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditContext } from '../block-edit';\nimport { store as blockEditorStore } from '../../store';\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) =>\n\t\tsettings.colors === undefined ? undefined : settings.colors,\n\t'color.gradients': ( settings ) =>\n\t\tsettings.gradients === undefined ? undefined : settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) =>\n\t\tsettings.fontSizes === undefined ? undefined : settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * Hook that retrieves the editor setting.\n * It works with nested objects using by finding the value at path.\n *\n * @param {string} path The path to the setting.\n * @return {any} Returns the value defined for the setting.\n * @example\n * ```js\n * const isEnabled = useSetting( 'typography.dropCap' );\n * ```\n */\nexport default function useSetting( path ) {\n\tconst { name: blockName } = useBlockEditContext();\n\n\tconst setting = useSelect(\n\t\t( select ) => {\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\t// 1 - Use __experimental features, if available.\n\t\t\t// We cascade to the all value if the block one is not available.\n\t\t\tconst normalizedPath = removeCustomPrefixes( path );\n\t\t\tconst defaultsPath = `__experimentalFeatures.${ normalizedPath }`;\n\t\t\tconst blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;\n\t\t\tconst experimentalFeaturesResult =\n\t\t\t\tget( settings, blockPath ) ?? get( settings, defaultsPath );\n\n\t\t\tif ( experimentalFeaturesResult !== undefined ) {\n\t\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\texperimentalFeaturesResult.custom ??\n\t\t\t\t\t\texperimentalFeaturesResult.theme ??\n\t\t\t\t\t\texperimentalFeaturesResult.default\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn experimentalFeaturesResult;\n\t\t\t}\n\n\t\t\t// 2 - Use deprecated settings, otherwise.\n\t\t\tconst deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]\n\t\t\t\t? deprecatedFlags[ normalizedPath ]( settings )\n\t\t\t\t: undefined;\n\t\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\t\treturn deprecatedSettingsValue;\n\t\t\t}\n\n\t\t\t// 3 - Fall back for typography.dropCap:\n\t\t\t// This is only necessary to support typography.dropCap.\n\t\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t\t// To remove when __experimentalFeatures are ported to core.\n\t\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t\t},\n\t\t[ blockName, path ]\n\t);\n\n\treturn setting;\n}\n"]}
@@ -22,6 +22,8 @@ var _compose = require("@wordpress/compose");
22
22
 
23
23
  var _control = _interopRequireDefault(require("../components/colors-gradients/control"));
24
24
 
25
+ var _useMultipleOriginColorsAndGradients = _interopRequireDefault(require("../components/colors-gradients/use-multiple-origin-colors-and-gradients"));
26
+
25
27
  var _colors = require("../components/colors");
26
28
 
27
29
  var _useSetting = _interopRequireDefault(require("../components/use-setting"));
@@ -66,18 +68,17 @@ function BorderColorEdit(props) {
66
68
  },
67
69
  setAttributes
68
70
  } = props;
69
- const colors = (0, _useSetting.default)('color.palette') || EMPTY_ARRAY;
70
- const disableCustomColors = !(0, _useSetting.default)('color.custom');
71
- const disableCustomGradients = !(0, _useSetting.default)('color.customGradient');
71
+ const colorGradientSettings = (0, _useMultipleOriginColorsAndGradients.default)();
72
+ const availableColors = colorGradientSettings.colors.reduce((colors, origin) => colors.concat(origin.colors), []);
72
73
  const [colorValue, setColorValue] = (0, _element.useState)(() => {
73
74
  var _getColorObjectByAttr, _style$border;
74
75
 
75
- return (_getColorObjectByAttr = (0, _colors.getColorObjectByAttributeValues)(colors, borderColor, style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
76
+ return (_getColorObjectByAttr = (0, _colors.getColorObjectByAttributeValues)(availableColors, borderColor, style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
76
77
  });
77
78
 
78
79
  const onChangeColor = value => {
79
80
  setColorValue(value);
80
- const colorObject = (0, _colors.getColorObjectByColorValue)(colors, value);
81
+ const colorObject = (0, _colors.getColorObjectByColorValue)(availableColors, value);
81
82
  const newStyle = { ...style,
82
83
  border: { ...(style === null || style === void 0 ? void 0 : style.border),
83
84
  color: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
@@ -91,15 +92,14 @@ function BorderColorEdit(props) {
91
92
  });
92
93
  };
93
94
 
94
- return (0, _element.createElement)(_control.default, {
95
+ return (0, _element.createElement)(_control.default, (0, _extends2.default)({
95
96
  label: (0, _i18n.__)('Color'),
96
97
  colorValue: colorValue,
97
- colors: colors,
98
- gradients: undefined,
99
- disableCustomColors: disableCustomColors,
100
- disableCustomGradients: disableCustomGradients,
101
- onColorChange: onChangeColor
102
- });
98
+ onColorChange: onChangeColor,
99
+ clearable: false,
100
+ __experimentalHasMultipleOrigins: true,
101
+ __experimentalIsRenderedInSidebar: true
102
+ }, colorGradientSettings));
103
103
  }
104
104
  /**
105
105
  * Filters registered block settings, extending attributes to include
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-color.js"],"names":["EMPTY_ARRAY","BorderColorEdit","props","attributes","borderColor","style","setAttributes","colors","disableCustomColors","disableCustomGradients","colorValue","setColorValue","border","color","onChangeColor","value","colorObject","newStyle","slug","undefined","newNamedColor","addAttributes","settings","type","addSaveProps","blockType","borderColorClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","name","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;AAWA;;;;AARA;;AAKA;;AAC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iCP,WAAhD;;AAEA,MACC,CAAE,8BAAkBkC,IAAlB,EAAwB,OAAxB,CAAF,IACA,qCAAyBA,IAAzB,CAFD,EAGE;AACD,WAAO,4BAAC,cAAD,EAAqBhC,KAArB,CAAP;AACA;;AAED,QAAMiC,WAAW,GAAG;AACnB/B,IAAAA,WAAW,EAAEA,WAAW,6BACrB,6CAAiCG,MAAjC,EAAyCH,WAAzC,CADqB,2DACrB,uBAAwDS,KADnC,GAErBM;AAHgB,GAApB;AAMA,MAAIiB,YAAY,GAAGlC,KAAK,CAACkC,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAGlC,KAAK,CAACkC,YADK;AAEd/B,IAAAA,KAAK,EAAE,EACN,GAAG8B,WADG;AAEN,iCAAGjC,KAAK,CAACkC,YAAT,wDAAG,oBAAoB/B,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,4BAAC,cAAD,6BAAqBH,KAArB;AAA6B,IAAA,YAAY,EAAGkC;AAA5C,KAAP;AACA,CA7B0C,CAArC;;AAgCP,sBACC,0BADD,EAEC,2BAFD,EAGCf,aAHD;AAMA,sBACC,kCADD,EAEC,0BAFD,EAGCG,YAHD;AAMA,sBACC,0BADD,EAEC,0BAFD,EAGCK,YAHD;AAMA,sBACC,uBADD,EAEC,8CAFD,EAGCG,4BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientControl from '../components/colors-gradients/control';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport useSetting from '../components/use-setting';\nimport { hasBorderSupport, shouldSkipSerialization } from './border';\nimport { cleanEmptyObject } from './utils';\n\n// Defining empty array here instead of inline avoids unnecessary re-renders of\n// color control.\nconst EMPTY_ARRAY = [];\n\n/**\n * Inspector control panel containing the border color related configuration.\n *\n * There is deliberate overlap between the colors and borders block supports\n * relating to border color. It can be argued the border color controls could\n * be included within either, or both, the colors and borders panels in the\n * inspector controls. If they share the same block attributes it should not\n * matter.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border color edit element.\n */\nexport function BorderColorEdit( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomGradients = ! useSetting( 'color.customGradient' );\n\tconst [ colorValue, setColorValue ] = useState(\n\t\t() =>\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\tborderColor,\n\t\t\t\tstyle?.border?.color\n\t\t\t)?.color\n\t);\n\n\tconst onChangeColor = ( value ) => {\n\t\tsetColorValue( value );\n\n\t\tconst colorObject = getColorObjectByColorValue( colors, value );\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tcolor: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\t// If empty slug, ensure undefined to remove attribute.\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\tborderColor: newNamedColor,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<ColorGradientControl\n\t\t\tlabel={ __( 'Color' ) }\n\t\t\tcolorValue={ colorValue }\n\t\t\tcolors={ colors }\n\t\t\tgradients={ undefined }\n\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\tdisableCustomGradients={ disableCustomGradients }\n\t\t\tonColorChange={ onChangeColor }\n\t\t/>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\tconst newClassName = classnames( props.className, {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor } = attributes;\n\t\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst extraStyles = {\n\t\t\tborderColor: borderColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, borderColor )?.color\n\t\t\t\t: undefined,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-color.js"],"names":["EMPTY_ARRAY","BorderColorEdit","props","attributes","borderColor","style","setAttributes","colorGradientSettings","availableColors","colors","reduce","origin","concat","colorValue","setColorValue","border","color","onChangeColor","value","colorObject","newStyle","slug","undefined","newNamedColor","addAttributes","settings","type","addSaveProps","blockType","borderColorClass","newClassName","className","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBorderColorPaletteStyles","BlockListBlock","name","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAzBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAYA;AACA;AACA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,WAAF;AAAeC,MAAAA;AAAf,KADP;AAELC,IAAAA;AAFK,MAGFJ,KAHJ;AAIA,QAAMK,qBAAqB,GAAG,mDAA9B;AACA,QAAMC,eAAe,GAAGD,qBAAqB,CAACE,MAAtB,CAA6BC,MAA7B,CACvB,CAAED,MAAF,EAAUE,MAAV,KAAsBF,MAAM,CAACG,MAAP,CAAeD,MAAM,CAACF,MAAtB,CADC,EAEvB,EAFuB,CAAxB;AAIA,QAAM,CAAEI,UAAF,EAAcC,aAAd,IAAgC,uBACrC;AAAA;;AAAA,oCACC,6CACCN,eADD,EAECJ,WAFD,EAGCC,KAHD,aAGCA,KAHD,wCAGCA,KAAK,CAAEU,MAHR,kDAGC,cAAeC,KAHhB,CADD,0DACC,sBAIGA,KALJ;AAAA,GADqC,CAAtC;;AASA,QAAMC,aAAa,GAAKC,KAAF,IAAa;AAClCJ,IAAAA,aAAa,CAAEI,KAAF,CAAb;AAEA,UAAMC,WAAW,GAAG,wCACnBX,eADmB,EAEnBU,KAFmB,CAApB;AAIA,UAAME,QAAQ,GAAG,EAChB,GAAGf,KADa;AAEhBU,MAAAA,MAAM,EAAE,EACP,IAAGV,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEU,MAAV,CADO;AAEPC,QAAA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AAAA;;AAClC,QAAM;AAAEmC,IAAAA,IAAF;AAAQlC,IAAAA;AAAR,MAAuBD,KAA7B;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAkBD,UAAxB;AACA,QAAMM,MAAM,GAAG,yBAAY,eAAZ,KAAiCT,WAAhD;;AAEA,MACC,CAAE,8BAAkBqC,IAAlB,EAAwB,OAAxB,CAAF,IACA,qCAAyBA,IAAzB,CAFD,EAGE;AACD,WAAO,4BAAC,cAAD,EAAqBnC,KAArB,CAAP;AACA;;AAED,QAAMoC,WAAW,GAAG;AACnBlC,IAAAA,WAAW,EAAEA,WAAW,6BACrB,6CAAiCK,MAAjC,EAAyCL,WAAzC,CADqB,2DACrB,uBAAwDY,KADnC,GAErBM;AAHgB,GAApB;AAMA,MAAIiB,YAAY,GAAGrC,KAAK,CAACqC,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAGrC,KAAK,CAACqC,YADK;AAEdlC,IAAAA,KAAK,EAAE,EACN,GAAGiC,WADG;AAEN,iCAAGpC,KAAK,CAACqC,YAAT,wDAAG,oBAAoBlC,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,4BAAC,cAAD,6BAAqBH,KAArB;AAA6B,IAAA,YAAY,EAAGqC;AAA5C,KAAP;AACA,CA7B0C,CAArC;;AAgCP,sBACC,0BADD,EAEC,2BAFD,EAGCf,aAHD;AAMA,sBACC,kCADD,EAEC,0BAFD,EAGCG,YAHD;AAMA,sBACC,0BADD,EAEC,0BAFD,EAGCK,YAHD;AAMA,sBACC,uBADD,EAEC,8CAFD,EAGCG,4BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ColorGradientControl from '../components/colors-gradients/control';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport useSetting from '../components/use-setting';\nimport { hasBorderSupport, shouldSkipSerialization } from './border';\nimport { cleanEmptyObject } from './utils';\n\n// Defining empty array here instead of inline avoids unnecessary re-renders of\n// color control.\nconst EMPTY_ARRAY = [];\n\n/**\n * Inspector control panel containing the border color related configuration.\n *\n * There is deliberate overlap between the colors and borders block supports\n * relating to border color. It can be argued the border color controls could\n * be included within either, or both, the colors and borders panels in the\n * inspector controls. If they share the same block attributes it should not\n * matter.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Border color edit element.\n */\nexport function BorderColorEdit( props ) {\n\tconst {\n\t\tattributes: { borderColor, style },\n\t\tsetAttributes,\n\t} = props;\n\tconst colorGradientSettings = useMultipleOriginColorsAndGradients();\n\tconst availableColors = colorGradientSettings.colors.reduce(\n\t\t( colors, origin ) => colors.concat( origin.colors ),\n\t\t[]\n\t);\n\tconst [ colorValue, setColorValue ] = useState(\n\t\t() =>\n\t\t\tgetColorObjectByAttributeValues(\n\t\t\t\tavailableColors,\n\t\t\t\tborderColor,\n\t\t\t\tstyle?.border?.color\n\t\t\t)?.color\n\t);\n\n\tconst onChangeColor = ( value ) => {\n\t\tsetColorValue( value );\n\n\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\tavailableColors,\n\t\t\tvalue\n\t\t);\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tborder: {\n\t\t\t\t...style?.border,\n\t\t\t\tcolor: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\t// If empty slug, ensure undefined to remove attribute.\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\tborderColor: newNamedColor,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<ColorGradientControl\n\t\t\tlabel={ __( 'Color' ) }\n\t\t\tcolorValue={ colorValue }\n\t\t\tonColorChange={ onChangeColor }\n\t\t\tclearable={ false }\n\t\t\t__experimentalHasMultipleOrigins\n\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t{ ...colorGradientSettings }\n\t\t/>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * `borderColor` if needed.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Updated block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBorderSupport( settings, 'color' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify default value if needed.\n\tif ( settings.attributes.borderColor ) {\n\t\treturn settings;\n\t}\n\n\t// Add new borderColor attribute to block settings.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tborderColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Override props assigned to save component to inject border color.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n *\n * @return {Object} Filtered props to apply to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasBorderSupport( blockType, 'color' ) ||\n\t\tshouldSkipSerialization( blockType )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst { borderColor, style } = attributes;\n\tconst borderColorClass = getColorClassName( 'border-color', borderColor );\n\n\tconst newClassName = classnames( props.className, {\n\t\t'has-border-color': borderColor || style?.border?.color,\n\t\t[ borderColorClass ]: !! borderColorClass,\n\t} );\n\n\t// If we are clearing the last of the previous classes in `className`\n\t// set it to `undefined` to avoid rendering empty DOM attributes.\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters the registered block settings to apply border color styles and\n * classnames to the block edit wrapper.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif (\n\t\t! hasBorderSupport( settings, 'color' ) ||\n\t\tshouldSkipSerialization( settings )\n\t) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBorderColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { borderColor } = attributes;\n\t\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\n\t\tif (\n\t\t\t! hasBorderSupport( name, 'color' ) ||\n\t\t\tshouldSkipSerialization( name )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst extraStyles = {\n\t\t\tborderColor: borderColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, borderColor )?.color\n\t\t\t\t: undefined,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addAttributes',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/border/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/border/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/border/with-border-color-palette-styles',\n\twithBorderColorPaletteStyles\n);\n"]}
@@ -65,7 +65,8 @@ function ColorPanel(_ref) {
65
65
  initialOpen: false,
66
66
  settings: settings,
67
67
  showTitle: showTitle,
68
- __experimentalHasMultipleOrigins: true
68
+ __experimentalHasMultipleOrigins: true,
69
+ __experimentalIsRenderedInSidebar: true
69
70
  }, enableContrastChecking && (0, _element.createElement)(_contrastChecker.default, {
70
71
  backgroundColor: detectedBackgroundColor,
71
72
  textColor: detectedColor
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/color-panel.js"],"names":["getComputedStyle","node","ownerDocument","defaultView","ColorPanel","settings","clientId","enableContrastChecking","showTitle","detectedBackgroundColor","setDetectedBackgroundColor","detectedColor","setDetectedColor","ref","current","color","backgroundColorNode","backgroundColor","parentNode","nodeType","ELEMENT_NODE"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAZA;AACA;AACA;;AAIA;AACA;AACA;AAMA,SAASA,gBAAT,CAA2BC,IAA3B,EAAkC;AACjC,SAAOA,IAAI,CAACC,aAAL,CAAmBC,WAAnB,CAA+BH,gBAA/B,CAAiDC,IAAjD,CAAP;AACA;;AAEc,SAASG,UAAT,OAKX;AAAA,MALgC;AACnCC,IAAAA,QADmC;AAEnCC,IAAAA,QAFmC;AAGnCC,IAAAA,sBAAsB,GAAG,IAHU;AAInCC,IAAAA,SAAS,GAAG;AAJuB,GAKhC;AACH,QAAM,CAAEC,uBAAF,EAA2BC,0BAA3B,IAA0D,wBAAhE;AACA,QAAM,CAAEC,aAAF,EAAiBC,gBAAjB,IAAsC,wBAA5C;AACA,QAAMC,GAAG,GAAG,yCAAaP,QAAb,CAAZ;AAEA,0BAAW,MAAM;AAChB,QAAK,CAAEC,sBAAP,EAAgC;AAC/B;AACA;;AAED,QAAK,CAAEM,GAAG,CAACC,OAAX,EAAqB;AACpB;AACA;;AACDF,IAAAA,gBAAgB,CAAEZ,gBAAgB,CAAEa,GAAG,CAACC,OAAN,CAAhB,CAAgCC,KAAlC,CAAhB;AAEA,QAAIC,mBAAmB,GAAGH,GAAG,CAACC,OAA9B;AACA,QAAIG,eAAe,GAAGjB,gBAAgB,CAAEgB,mBAAF,CAAhB,CACpBC,eADF;;AAEA,WACCA,eAAe,KAAK,kBAApB,IACAD,mBAAmB,CAACE,UADpB,IAEAF,mBAAmB,CAACE,UAApB,CAA+BC,QAA/B,KACCH,mBAAmB,CAACE,UAApB,CAA+BE,YAJjC,EAKE;AACDJ,MAAAA,mBAAmB,GAAGA,mBAAmB,CAACE,UAA1C;AACAD,MAAAA,eAAe,GAAGjB,gBAAgB,CAAEgB,mBAAF,CAAhB,CAChBC,eADF;AAEA;;AAEDP,IAAAA,0BAA0B,CAAEO,eAAF,CAA1B;AACA,GAzBD;AA2BA,SACC,4BAAC,0BAAD,QACC,4BAAC,mCAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,WAAW,EAAG,KAFf;AAGC,IAAA,QAAQ,EAAGZ,QAHZ;AAIC,IAAA,SAAS,EAAGG,SAJb;AAKC,IAAA,gCAAgC;AALjC,KAOGD,sBAAsB,IACvB,4BAAC,wBAAD;AACC,IAAA,eAAe,EAAGE,uBADnB;AAEC,IAAA,SAAS,EAAGE;AAFb,IARF,CADD,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PanelColorGradientSettings from '../components/colors-gradients/panel-color-gradient-settings';\nimport ContrastChecker from '../components/contrast-checker';\nimport InspectorControls from '../components/inspector-controls';\nimport { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';\n\nfunction getComputedStyle( node ) {\n\treturn node.ownerDocument.defaultView.getComputedStyle( node );\n}\n\nexport default function ColorPanel( {\n\tsettings,\n\tclientId,\n\tenableContrastChecking = true,\n\tshowTitle = true,\n} ) {\n\tconst [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();\n\tconst [ detectedColor, setDetectedColor ] = useState();\n\tconst ref = useBlockRef( clientId );\n\n\tuseEffect( () => {\n\t\tif ( ! enableContrastChecking ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\t\tsetDetectedColor( getComputedStyle( ref.current ).color );\n\n\t\tlet backgroundColorNode = ref.current;\n\t\tlet backgroundColor = getComputedStyle( backgroundColorNode )\n\t\t\t.backgroundColor;\n\t\twhile (\n\t\t\tbackgroundColor === 'rgba(0, 0, 0, 0)' &&\n\t\t\tbackgroundColorNode.parentNode &&\n\t\t\tbackgroundColorNode.parentNode.nodeType ===\n\t\t\t\tbackgroundColorNode.parentNode.ELEMENT_NODE\n\t\t) {\n\t\t\tbackgroundColorNode = backgroundColorNode.parentNode;\n\t\t\tbackgroundColor = getComputedStyle( backgroundColorNode )\n\t\t\t\t.backgroundColor;\n\t\t}\n\n\t\tsetDetectedBackgroundColor( backgroundColor );\n\t} );\n\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelColorGradientSettings\n\t\t\t\ttitle={ __( 'Color' ) }\n\t\t\t\tinitialOpen={ false }\n\t\t\t\tsettings={ settings }\n\t\t\t\tshowTitle={ showTitle }\n\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t>\n\t\t\t\t{ enableContrastChecking && (\n\t\t\t\t\t<ContrastChecker\n\t\t\t\t\t\tbackgroundColor={ detectedBackgroundColor }\n\t\t\t\t\t\ttextColor={ detectedColor }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</PanelColorGradientSettings>\n\t\t</InspectorControls>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/color-panel.js"],"names":["getComputedStyle","node","ownerDocument","defaultView","ColorPanel","settings","clientId","enableContrastChecking","showTitle","detectedBackgroundColor","setDetectedBackgroundColor","detectedColor","setDetectedColor","ref","current","color","backgroundColorNode","backgroundColor","parentNode","nodeType","ELEMENT_NODE"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAZA;AACA;AACA;;AAIA;AACA;AACA;AAMA,SAASA,gBAAT,CAA2BC,IAA3B,EAAkC;AACjC,SAAOA,IAAI,CAACC,aAAL,CAAmBC,WAAnB,CAA+BH,gBAA/B,CAAiDC,IAAjD,CAAP;AACA;;AAEc,SAASG,UAAT,OAKX;AAAA,MALgC;AACnCC,IAAAA,QADmC;AAEnCC,IAAAA,QAFmC;AAGnCC,IAAAA,sBAAsB,GAAG,IAHU;AAInCC,IAAAA,SAAS,GAAG;AAJuB,GAKhC;AACH,QAAM,CAAEC,uBAAF,EAA2BC,0BAA3B,IAA0D,wBAAhE;AACA,QAAM,CAAEC,aAAF,EAAiBC,gBAAjB,IAAsC,wBAA5C;AACA,QAAMC,GAAG,GAAG,yCAAaP,QAAb,CAAZ;AAEA,0BAAW,MAAM;AAChB,QAAK,CAAEC,sBAAP,EAAgC;AAC/B;AACA;;AAED,QAAK,CAAEM,GAAG,CAACC,OAAX,EAAqB;AACpB;AACA;;AACDF,IAAAA,gBAAgB,CAAEZ,gBAAgB,CAAEa,GAAG,CAACC,OAAN,CAAhB,CAAgCC,KAAlC,CAAhB;AAEA,QAAIC,mBAAmB,GAAGH,GAAG,CAACC,OAA9B;AACA,QAAIG,eAAe,GAAGjB,gBAAgB,CAAEgB,mBAAF,CAAhB,CACpBC,eADF;;AAEA,WACCA,eAAe,KAAK,kBAApB,IACAD,mBAAmB,CAACE,UADpB,IAEAF,mBAAmB,CAACE,UAApB,CAA+BC,QAA/B,KACCH,mBAAmB,CAACE,UAApB,CAA+BE,YAJjC,EAKE;AACDJ,MAAAA,mBAAmB,GAAGA,mBAAmB,CAACE,UAA1C;AACAD,MAAAA,eAAe,GAAGjB,gBAAgB,CAAEgB,mBAAF,CAAhB,CAChBC,eADF;AAEA;;AAEDP,IAAAA,0BAA0B,CAAEO,eAAF,CAA1B;AACA,GAzBD;AA2BA,SACC,4BAAC,0BAAD,QACC,4BAAC,mCAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,WAAW,EAAG,KAFf;AAGC,IAAA,QAAQ,EAAGZ,QAHZ;AAIC,IAAA,SAAS,EAAGG,SAJb;AAKC,IAAA,gCAAgC,MALjC;AAMC,IAAA,iCAAiC;AANlC,KAQGD,sBAAsB,IACvB,4BAAC,wBAAD;AACC,IAAA,eAAe,EAAGE,uBADnB;AAEC,IAAA,SAAS,EAAGE;AAFb,IATF,CADD,CADD;AAmBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PanelColorGradientSettings from '../components/colors-gradients/panel-color-gradient-settings';\nimport ContrastChecker from '../components/contrast-checker';\nimport InspectorControls from '../components/inspector-controls';\nimport { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';\n\nfunction getComputedStyle( node ) {\n\treturn node.ownerDocument.defaultView.getComputedStyle( node );\n}\n\nexport default function ColorPanel( {\n\tsettings,\n\tclientId,\n\tenableContrastChecking = true,\n\tshowTitle = true,\n} ) {\n\tconst [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();\n\tconst [ detectedColor, setDetectedColor ] = useState();\n\tconst ref = useBlockRef( clientId );\n\n\tuseEffect( () => {\n\t\tif ( ! enableContrastChecking ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\t\tsetDetectedColor( getComputedStyle( ref.current ).color );\n\n\t\tlet backgroundColorNode = ref.current;\n\t\tlet backgroundColor = getComputedStyle( backgroundColorNode )\n\t\t\t.backgroundColor;\n\t\twhile (\n\t\t\tbackgroundColor === 'rgba(0, 0, 0, 0)' &&\n\t\t\tbackgroundColorNode.parentNode &&\n\t\t\tbackgroundColorNode.parentNode.nodeType ===\n\t\t\t\tbackgroundColorNode.parentNode.ELEMENT_NODE\n\t\t) {\n\t\t\tbackgroundColorNode = backgroundColorNode.parentNode;\n\t\t\tbackgroundColor = getComputedStyle( backgroundColorNode )\n\t\t\t\t.backgroundColor;\n\t\t}\n\n\t\tsetDetectedBackgroundColor( backgroundColor );\n\t} );\n\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelColorGradientSettings\n\t\t\t\ttitle={ __( 'Color' ) }\n\t\t\t\tinitialOpen={ false }\n\t\t\t\tsettings={ settings }\n\t\t\t\tshowTitle={ showTitle }\n\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t>\n\t\t\t\t{ enableContrastChecking && (\n\t\t\t\t\t<ContrastChecker\n\t\t\t\t\t\tbackgroundColor={ detectedBackgroundColor }\n\t\t\t\t\t\ttextColor={ detectedColor }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</PanelColorGradientSettings>\n\t\t</InspectorControls>\n\t);\n}\n"]}
@@ -50,7 +50,7 @@ var _useSetting = _interopRequireDefault(require("../components/use-setting"));
50
50
  */
51
51
  const COLOR_SUPPORT_KEY = 'color';
52
52
  exports.COLOR_SUPPORT_KEY = COLOR_SUPPORT_KEY;
53
- const EMPTY_ARRAY = [];
53
+ const EMPTY_OBJECT = {};
54
54
 
55
55
  const hasColorSupport = blockType => {
56
56
  const colorSupport = (0, _blocks.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
@@ -219,19 +219,28 @@ function immutableSet(object, path, value) {
219
219
 
220
220
 
221
221
  function ColorEdit(props) {
222
- var _style$color6, _style$color7, _style$color8, _style$elements2, _style$elements2$link, _style$elements2$link2, _style$elements3, _style$elements3$link, _style$elements3$link2;
222
+ var _gradientsPerOrigin$t, _style$color6, _style$color7, _style$color8, _style$elements2, _style$elements2$link, _style$elements2$link2, _style$elements3, _style$elements3$link, _style$elements3$link2;
223
223
 
224
224
  const {
225
225
  name: blockName,
226
226
  attributes
227
- } = props;
228
- const solids = (0, _useSetting.default)('color.palette') || EMPTY_ARRAY;
229
- const gradients = (0, _useSetting.default)('color.gradients') || EMPTY_ARRAY;
227
+ } = props; // Some color settings have a special handling for deprecated flags in `useSetting`,
228
+ // so we can't unwrap them by doing const { ... } = useSetting('color')
229
+ // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
230
+
231
+ const userPalette = (0, _useSetting.default)('color.palette.custom');
232
+ const themePalette = (0, _useSetting.default)('color.palette.theme');
233
+ const defaultPalette = (0, _useSetting.default)('color.palette.default');
234
+ const allSolids = (0, _element.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
235
+ const gradientsPerOrigin = (0, _useSetting.default)('color.gradients') || EMPTY_OBJECT;
230
236
  const areCustomSolidsEnabled = (0, _useSetting.default)('color.custom');
231
237
  const areCustomGradientsEnabled = (0, _useSetting.default)('color.customGradient');
238
+ const isBackgroundEnabled = (0, _useSetting.default)('color.background');
232
239
  const isLinkEnabled = (0, _useSetting.default)('color.link');
233
240
  const isTextEnabled = (0, _useSetting.default)('color.text');
234
- const isBackgroundEnabled = (0, _useSetting.default)('color.background'); // Shouldn't be needed but right now the ColorGradientsPanel
241
+ const solidsEnabled = areCustomSolidsEnabled || !themePalette || (themePalette === null || themePalette === void 0 ? void 0 : themePalette.length) > 0;
242
+ const gradientsEnabled = areCustomGradientsEnabled || !(gradientsPerOrigin !== null && gradientsPerOrigin !== void 0 && gradientsPerOrigin.theme) || (gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : (_gradientsPerOrigin$t = gradientsPerOrigin.theme) === null || _gradientsPerOrigin$t === void 0 ? void 0 : _gradientsPerOrigin$t.length) > 0;
243
+ const allGradients = (0, _element.useMemo)(() => [...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.custom) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.theme) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.default) || [])], [gradientsPerOrigin]); // Shouldn't be needed but right now the ColorGradientsPanel
235
244
  // can trigger both onChangeColor and onChangeBackground
236
245
  // synchronously causing our two callbacks to override changes
237
246
  // from each other.
@@ -245,10 +254,10 @@ function ColorEdit(props) {
245
254
  return null;
246
255
  }
247
256
 
248
- const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled && (solids.length > 0 || areCustomSolidsEnabled);
249
- const hasTextColor = hasTextColorSupport(blockName) && isTextEnabled && (solids.length > 0 || areCustomSolidsEnabled);
250
- const hasBackgroundColor = hasBackgroundColorSupport(blockName) && isBackgroundEnabled && (solids.length > 0 || areCustomSolidsEnabled);
251
- const hasGradientColor = hasGradientSupport(blockName) && (gradients.length > 0 || areCustomGradientsEnabled);
257
+ const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled && solidsEnabled;
258
+ const hasTextColor = hasTextColorSupport(blockName) && isTextEnabled && solidsEnabled;
259
+ const hasBackgroundColor = hasBackgroundColorSupport(blockName) && isBackgroundEnabled && solidsEnabled;
260
+ const hasGradientColor = hasGradientSupport(blockName) && gradientsEnabled;
252
261
 
253
262
  if (!hasLinkColor && !hasTextColor && !hasBackgroundColor && !hasGradientColor) {
254
263
  return null;
@@ -263,7 +272,7 @@ function ColorEdit(props) {
263
272
  let gradientValue;
264
273
 
265
274
  if (hasGradientColor && gradient) {
266
- gradientValue = (0, _gradients.getGradientValueBySlug)(gradients, gradient);
275
+ gradientValue = (0, _gradients.getGradientValueBySlug)(allGradients, gradient);
267
276
  } else if (hasGradientColor) {
268
277
  var _style$color5;
269
278
 
@@ -273,7 +282,7 @@ function ColorEdit(props) {
273
282
  const onChangeColor = name => value => {
274
283
  var _localAttributes$curr, _localAttributes$curr2;
275
284
 
276
- const colorObject = (0, _colors.getColorObjectByColorValue)(solids, value);
285
+ const colorObject = (0, _colors.getColorObjectByColorValue)(allSolids, value);
277
286
  const attributeName = name + 'Color';
278
287
  const newStyle = { ...localAttributes.current.style,
279
288
  color: { ...((_localAttributes$curr = localAttributes.current) === null || _localAttributes$curr === void 0 ? void 0 : (_localAttributes$curr2 = _localAttributes$curr.style) === null || _localAttributes$curr2 === void 0 ? void 0 : _localAttributes$curr2.color),
@@ -292,7 +301,7 @@ function ColorEdit(props) {
292
301
  };
293
302
 
294
303
  const onChangeGradient = value => {
295
- const slug = (0, _gradients.getGradientSlugByValue)(gradients, value);
304
+ const slug = (0, _gradients.getGradientSlugByValue)(allGradients, value);
296
305
  let newAttributes;
297
306
 
298
307
  if (slug) {
@@ -328,7 +337,7 @@ function ColorEdit(props) {
328
337
  };
329
338
 
330
339
  const onChangeLinkColor = value => {
331
- const colorObject = (0, _colors.getColorObjectByColorValue)(solids, value);
340
+ const colorObject = (0, _colors.getColorObjectByColorValue)(allSolids, value);
332
341
  const newLinkColorValue = colorObject !== null && colorObject !== void 0 && colorObject.slug ? `var:preset|color|${colorObject.slug}` : value;
333
342
  const newStyle = (0, _utils.cleanEmptyObject)(immutableSet(style, ['elements', 'link', 'color', 'text'], newLinkColorValue));
334
343
  props.setAttributes({
@@ -343,17 +352,17 @@ function ColorEdit(props) {
343
352
  settings: [...(hasTextColor ? [{
344
353
  label: (0, _i18n.__)('Text color'),
345
354
  onColorChange: onChangeColor('text'),
346
- colorValue: (0, _colors.getColorObjectByAttributeValues)(solids, textColor, style === null || style === void 0 ? void 0 : (_style$color7 = style.color) === null || _style$color7 === void 0 ? void 0 : _style$color7.text).color
355
+ colorValue: (0, _colors.getColorObjectByAttributeValues)(allSolids, textColor, style === null || style === void 0 ? void 0 : (_style$color7 = style.color) === null || _style$color7 === void 0 ? void 0 : _style$color7.text).color
347
356
  }] : []), ...(hasBackgroundColor || hasGradientColor ? [{
348
357
  label: (0, _i18n.__)('Background color'),
349
358
  onColorChange: hasBackgroundColor ? onChangeColor('background') : undefined,
350
- colorValue: (0, _colors.getColorObjectByAttributeValues)(solids, backgroundColor, style === null || style === void 0 ? void 0 : (_style$color8 = style.color) === null || _style$color8 === void 0 ? void 0 : _style$color8.background).color,
359
+ colorValue: (0, _colors.getColorObjectByAttributeValues)(allSolids, backgroundColor, style === null || style === void 0 ? void 0 : (_style$color8 = style.color) === null || _style$color8 === void 0 ? void 0 : _style$color8.background).color,
351
360
  gradientValue,
352
361
  onGradientChange: hasGradientColor ? onChangeGradient : undefined
353
362
  }] : []), ...(hasLinkColor ? [{
354
363
  label: (0, _i18n.__)('Link Color'),
355
364
  onColorChange: onChangeLinkColor,
356
- colorValue: getLinkColorFromAttributeValue(solids, style === null || style === void 0 ? void 0 : (_style$elements2 = style.elements) === null || _style$elements2 === void 0 ? void 0 : (_style$elements2$link = _style$elements2.link) === null || _style$elements2$link === void 0 ? void 0 : (_style$elements2$link2 = _style$elements2$link.color) === null || _style$elements2$link2 === void 0 ? void 0 : _style$elements2$link2.text),
365
+ colorValue: getLinkColorFromAttributeValue(allSolids, style === null || style === void 0 ? void 0 : (_style$elements2 = style.elements) === null || _style$elements2 === void 0 ? void 0 : (_style$elements2$link = _style$elements2.link) === null || _style$elements2$link === void 0 ? void 0 : (_style$elements2$link2 = _style$elements2$link.color) === null || _style$elements2$link2 === void 0 ? void 0 : _style$elements2$link2.text),
357
366
  clearable: !!(style !== null && style !== void 0 && (_style$elements3 = style.elements) !== null && _style$elements3 !== void 0 && (_style$elements3$link = _style$elements3.link) !== null && _style$elements3$link !== void 0 && (_style$elements3$link2 = _style$elements3$link.color) !== null && _style$elements3$link2 !== void 0 && _style$elements3$link2.text)
358
367
  }] : [])]
359
368
  });
@@ -369,7 +378,7 @@ function ColorEdit(props) {
369
378
 
370
379
 
371
380
  const withColorPaletteStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock => props => {
372
- var _getColorObjectByAttr, _getColorObjectByAttr2, _props$wrapperProps;
381
+ var _props$wrapperProps;
373
382
 
374
383
  const {
375
384
  name,
@@ -379,16 +388,29 @@ const withColorPaletteStyles = (0, _compose.createHigherOrderComponent)(BlockLis
379
388
  backgroundColor,
380
389
  textColor
381
390
  } = attributes;
382
- const colors = (0, _useSetting.default)('color.palette') || EMPTY_ARRAY;
391
+ const userPalette = (0, _useSetting.default)('color.palette.custom') || [];
392
+ const themePalette = (0, _useSetting.default)('color.palette.theme') || [];
393
+ const defaultPalette = (0, _useSetting.default)('color.palette.default') || [];
394
+ const colors = (0, _element.useMemo)(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
383
395
 
384
396
  if (!hasColorSupport(name) || shouldSkipSerialization(name)) {
385
397
  return (0, _element.createElement)(BlockListBlock, props);
386
398
  }
387
399
 
388
- const extraStyles = {
389
- color: textColor ? (_getColorObjectByAttr = (0, _colors.getColorObjectByAttributeValues)(colors, textColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color : undefined,
390
- backgroundColor: backgroundColor ? (_getColorObjectByAttr2 = (0, _colors.getColorObjectByAttributeValues)(colors, backgroundColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color : undefined
391
- };
400
+ const extraStyles = {};
401
+
402
+ if (textColor) {
403
+ var _getColorObjectByAttr;
404
+
405
+ extraStyles.color = (_getColorObjectByAttr = (0, _colors.getColorObjectByAttributeValues)(colors, textColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
406
+ }
407
+
408
+ if (backgroundColor) {
409
+ var _getColorObjectByAttr2;
410
+
411
+ extraStyles.backgroundColor = (_getColorObjectByAttr2 = (0, _colors.getColorObjectByAttributeValues)(colors, backgroundColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color;
412
+ }
413
+
392
414
  let wrapperProps = props.wrapperProps;
393
415
  wrapperProps = { ...props.wrapperProps,
394
416
  style: { ...extraStyles,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/color.js"],"names":["COLOR_SUPPORT_KEY","EMPTY_ARRAY","hasColorSupport","blockType","colorSupport","link","gradient","background","text","shouldSkipSerialization","__experimentalSkipSerialization","hasLinkColorSupport","Platform","OS","hasGradientSupport","gradients","hasBackgroundColorSupport","hasTextColorSupport","addAttributes","settings","attributes","backgroundColor","Object","assign","type","textColor","addSaveProps","props","hasGradient","style","backgroundClass","gradientClass","textClass","newClassName","className","color","elements","undefined","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","getLinkColorFromAttributeValue","colors","value","attributeParsed","exec","immutableSet","object","path","clone","ColorEdit","name","blockName","solids","areCustomSolidsEnabled","areCustomGradientsEnabled","isLinkEnabled","isTextEnabled","isBackgroundEnabled","localAttributes","current","hasLinkColor","length","hasTextColor","hasBackgroundColor","hasGradientColor","gradientValue","onChangeColor","colorObject","attributeName","newStyle","slug","newNamedColor","newAttributes","setAttributes","onChangeGradient","onChangeLinkColor","newLinkColorValue","clientId","label","onColorChange","colorValue","onGradientChange","clearable","withColorPaletteStyles","BlockListBlock","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;;;;AAYA;;;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AAKA;;AAKA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAeO,MAAMA,iBAAiB,GAAG,OAA1B;;AACP,MAAMC,WAAW,GAAG,EAApB;;AAEA,MAAMC,eAAe,GAAKC,SAAF,IAAiB;AACxC,QAAMC,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BH,iBAA5B,CAArB;AACA,SACCI,YAAY,KACVA,YAAY,CAACC,IAAb,KAAsB,IAAtB,IACDD,YAAY,CAACE,QAAb,KAA0B,IADzB,IAEDF,YAAY,CAACG,UAAb,KAA4B,KAF3B,IAGDH,YAAY,CAACI,IAAb,KAAsB,KAJX,CADb;AAOA,CATD;;AAWA,MAAMC,uBAAuB,GAAKN,SAAF,IAAiB;AAChD,QAAMC,YA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IAAA,YAAY,EAAG4D;AAA5C,KAAP;AACA,CA7BoC,CAA/B;;AAgCP,sBACC,0BADD,EAEC,yBAFD,EAGCrE,aAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGCQ,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCY,YAHD;AAMA,sBACC,uBADD,EAEC,sCAFD,EAGC8C,sBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { isObject, setWith, clone } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, Platform } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport {\n\t__experimentalGetGradientClass,\n\tgetGradientValueBySlug,\n\tgetGradientSlugByValue,\n} from '../components/gradients';\nimport { cleanEmptyObject } from './utils';\nimport ColorPanel from './color-panel';\nimport useSetting from '../components/use-setting';\n\nexport const COLOR_SUPPORT_KEY = 'color';\nconst EMPTY_ARRAY = [];\n\nconst hasColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\treturn (\n\t\tcolorSupport &&\n\t\t( colorSupport.link === true ||\n\t\t\tcolorSupport.gradient === true ||\n\t\t\tcolorSupport.background !== false ||\n\t\t\tcolorSupport.text !== false )\n\t);\n};\n\nconst shouldSkipSerialization = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport?.__experimentalSkipSerialization;\n};\n\nconst hasLinkColorSupport = ( blockType ) => {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn isObject( colorSupport ) && !! colorSupport.link;\n};\n\nconst hasGradientSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn isObject( colorSupport ) && !! colorSupport.gradients;\n};\n\nconst hasBackgroundColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.background !== false;\n};\n\nconst hasTextColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.text !== false;\n};\n\n/**\n * Filters registered block settings, extending attributes to include\n * `backgroundColor` and `textColor` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasColorSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.backgroundColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tbackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\tif ( ! settings.attributes.textColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\ttextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( hasGradientSupport( settings ) && ! settings.attributes.gradient ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tgradient: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject colors classnames.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasColorSupport( blockType ) ||\n\t\tshouldSkipSerialization( blockType )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst hasGradient = hasGradientSupport( blockType );\n\n\t// I'd have prefered to avoid the \"style\" attribute usage here\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\tconst backgroundClass = getColorClassName(\n\t\t'background-color',\n\t\tbackgroundColor\n\t);\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tconst textClass = getColorClassName( 'color', textColor );\n\tconst newClassName = classnames(\n\t\tprops.className,\n\t\ttextClass,\n\t\tgradientClass,\n\t\t{\n\t\t\t// Don't apply the background class if there's a custom gradient\n\t\t\t[ backgroundClass ]:\n\t\t\t\t( ! hasGradient || ! style?.color?.gradient ) &&\n\t\t\t\t!! backgroundClass,\n\t\t\t'has-text-color': textColor || style?.color?.text,\n\t\t\t'has-background':\n\t\t\t\tbackgroundColor ||\n\t\t\t\tstyle?.color?.background ||\n\t\t\t\t( hasGradient && ( gradient || style?.color?.gradient ) ),\n\t\t\t'has-link-color': style?.elements?.link?.color,\n\t\t}\n\t);\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extand the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif (\n\t\t! hasColorSupport( settings ) ||\n\t\tshouldSkipSerialization( settings )\n\t) {\n\t\treturn settings;\n\t}\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\nconst getLinkColorFromAttributeValue = ( colors, value ) => {\n\tconst attributeParsed = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( attributeParsed && attributeParsed[ 1 ] ) {\n\t\treturn getColorObjectByAttributeValues( colors, attributeParsed[ 1 ] )\n\t\t\t.color;\n\t}\n\treturn value;\n};\n\nfunction immutableSet( object, path, value ) {\n\treturn setWith( object ? clone( object ) : {}, path, value, clone );\n}\n\n/**\n * Inspector control panel containing the color related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Color edit element.\n */\nexport function ColorEdit( props ) {\n\tconst { name: blockName, attributes } = props;\n\tconst solids = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst gradients = useSetting( 'color.gradients' ) || EMPTY_ARRAY;\n\tconst areCustomSolidsEnabled = useSetting( 'color.custom' );\n\tconst areCustomGradientsEnabled = useSetting( 'color.customGradient' );\n\tconst isLinkEnabled = useSetting( 'color.link' );\n\tconst isTextEnabled = useSetting( 'color.text' );\n\tconst isBackgroundEnabled = useSetting( 'color.background' );\n\n\t// Shouldn't be needed but right now the ColorGradientsPanel\n\t// can trigger both onChangeColor and onChangeBackground\n\t// synchronously causing our two callbacks to override changes\n\t// from each other.\n\tconst localAttributes = useRef( attributes );\n\tuseEffect( () => {\n\t\tlocalAttributes.current = attributes;\n\t}, [ attributes ] );\n\n\tif ( ! hasColorSupport( blockName ) ) {\n\t\treturn null;\n\t}\n\n\tconst hasLinkColor =\n\t\thasLinkColorSupport( blockName ) &&\n\t\tisLinkEnabled &&\n\t\t( solids.length > 0 || areCustomSolidsEnabled );\n\tconst hasTextColor =\n\t\thasTextColorSupport( blockName ) &&\n\t\tisTextEnabled &&\n\t\t( solids.length > 0 || areCustomSolidsEnabled );\n\tconst hasBackgroundColor =\n\t\thasBackgroundColorSupport( blockName ) &&\n\t\tisBackgroundEnabled &&\n\t\t( solids.length > 0 || areCustomSolidsEnabled );\n\tconst hasGradientColor =\n\t\thasGradientSupport( blockName ) &&\n\t\t( gradients.length > 0 || areCustomGradientsEnabled );\n\n\tif (\n\t\t! hasLinkColor &&\n\t\t! hasTextColor &&\n\t\t! hasBackgroundColor &&\n\t\t! hasGradientColor\n\t) {\n\t\treturn null;\n\t}\n\n\tconst { style, textColor, backgroundColor, gradient } = attributes;\n\tlet gradientValue;\n\tif ( hasGradientColor && gradient ) {\n\t\tgradientValue = getGradientValueBySlug( gradients, gradient );\n\t} else if ( hasGradientColor ) {\n\t\tgradientValue = style?.color?.gradient;\n\t}\n\n\tconst onChangeColor = ( name ) => ( value ) => {\n\t\tconst colorObject = getColorObjectByColorValue( solids, value );\n\t\tconst attributeName = name + 'Color';\n\t\tconst newStyle = {\n\t\t\t...localAttributes.current.style,\n\t\t\tcolor: {\n\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t[ name ]: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t[ attributeName ]: newNamedColor,\n\t\t};\n\n\t\tprops.setAttributes( newAttributes );\n\t\tlocalAttributes.current = {\n\t\t\t...localAttributes.current,\n\t\t\t...newAttributes,\n\t\t};\n\t};\n\n\tconst onChangeGradient = ( value ) => {\n\t\tconst slug = getGradientSlugByValue( gradients, value );\n\t\tlet newAttributes;\n\t\tif ( slug ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...localAttributes.current?.style,\n\t\t\t\tcolor: {\n\t\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t\tgradient: undefined,\n\t\t\t\t},\n\t\t\t};\n\t\t\tnewAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\tgradient: slug,\n\t\t\t};\n\t\t} else {\n\t\t\tconst newStyle = {\n\t\t\t\t...localAttributes.current?.style,\n\t\t\t\tcolor: {\n\t\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t\tgradient: value,\n\t\t\t\t},\n\t\t\t};\n\t\t\tnewAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\tgradient: undefined,\n\t\t\t};\n\t\t}\n\t\tprops.setAttributes( newAttributes );\n\t\tlocalAttributes.current = {\n\t\t\t...localAttributes.current,\n\t\t\t...newAttributes,\n\t\t};\n\t};\n\n\tconst onChangeLinkColor = ( value ) => {\n\t\tconst colorObject = getColorObjectByColorValue( solids, value );\n\t\tconst newLinkColorValue = colorObject?.slug\n\t\t\t? `var:preset|color|${ colorObject.slug }`\n\t\t\t: value;\n\n\t\tconst newStyle = cleanEmptyObject(\n\t\t\timmutableSet(\n\t\t\t\tstyle,\n\t\t\t\t[ 'elements', 'link', 'color', 'text' ],\n\t\t\t\tnewLinkColorValue\n\t\t\t)\n\t\t);\n\t\tprops.setAttributes( { style: newStyle } );\n\t};\n\n\treturn (\n\t\t<ColorPanel\n\t\t\tenableContrastChecking={\n\t\t\t\t// Turn on contrast checker for web only since it's not supported on mobile yet.\n\t\t\t\tPlatform.OS === 'web' && ! gradient && ! style?.color?.gradient\n\t\t\t}\n\t\t\tclientId={ props.clientId }\n\t\t\tsettings={ [\n\t\t\t\t...( hasTextColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Text color' ),\n\t\t\t\t\t\t\t\tonColorChange: onChangeColor( 'text' ),\n\t\t\t\t\t\t\t\tcolorValue: getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\t\tsolids,\n\t\t\t\t\t\t\t\t\ttextColor,\n\t\t\t\t\t\t\t\t\tstyle?.color?.text\n\t\t\t\t\t\t\t\t).color,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t\t...( hasBackgroundColor || hasGradientColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Background color' ),\n\t\t\t\t\t\t\t\tonColorChange: hasBackgroundColor\n\t\t\t\t\t\t\t\t\t? onChangeColor( 'background' )\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\tcolorValue: getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\t\tsolids,\n\t\t\t\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\t\t\t\tstyle?.color?.background\n\t\t\t\t\t\t\t\t).color,\n\t\t\t\t\t\t\t\tgradientValue,\n\t\t\t\t\t\t\t\tonGradientChange: hasGradientColor\n\t\t\t\t\t\t\t\t\t? onChangeGradient\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t\t...( hasLinkColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Link Color' ),\n\t\t\t\t\t\t\t\tonColorChange: onChangeLinkColor,\n\t\t\t\t\t\t\t\tcolorValue: getLinkColorFromAttributeValue(\n\t\t\t\t\t\t\t\t\tsolids,\n\t\t\t\t\t\t\t\t\tstyle?.elements?.link?.color?.text\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tclearable: !! style?.elements?.link?.color\n\t\t\t\t\t\t\t\t\t?.text,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t] }\n\t\t/>\n\t);\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { backgroundColor, textColor } = attributes;\n\t\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\t\tif ( ! hasColorSupport( name ) || shouldSkipSerialization( name ) ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst extraStyles = {\n\t\t\tcolor: textColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, textColor )?.color\n\t\t\t\t: undefined,\n\t\t\tbackgroundColor: backgroundColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, backgroundColor )\n\t\t\t\t\t\t?.color\n\t\t\t\t: undefined,\n\t\t};\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/color/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/color/with-color-palette-styles',\n\twithColorPaletteStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/color.js"],"names":["COLOR_SUPPORT_KEY","EMPTY_OBJECT","hasColorSupport","blockType","colorSupport","link","gradient","background","text","shouldSkipSerialization","__experimentalSkipSerialization","hasLinkColorSupport","Platform","OS","hasGradientSupport","gradients","hasBackgroundColorSupport","hasTextColorSupport","addAttributes","settings","attributes","backgroundColor","Object","assign","type","textColor","addSaveProps","props","hasGradient","style","backgroundClass","gradientClass","textClass","newClassName","className","color","elements","undefined","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","getLinkColorFromAttributeValue","colors","value","attributeParsed","exec","immutableSet","object","path","clone","ColorEdit","name","blockName","userPalette","themePalette","defaultPalette","allSolids","gradientsPerOrigin","areCustomSolidsEnabled","areCustomGradientsEnabled","isBackgroundEnabled","isLinkEnabled","isTextEnabled","solidsEnabled","length","gradientsEnabled","theme","allGradients","custom","default","localAttributes","current","hasLinkColor","hasTextColor","hasBackgroundColor","hasGradientColor","gradientValue","onChangeColor","colorObject","attributeName","newStyle","slug","newNamedColor","newAttributes","setAttributes","onChangeGradient","onChangeLinkColor","newLinkColorValue","clientId","label","onColorChange","colorValue","onGradientChange","clearable","withColorPaletteStyles","BlockListBlock","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;;;;AAYA;;;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AAKA;;AAKA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAeO,MAAMA,iBAAiB,GAAG,OAA1B;;AAEP,MAAMC,YAAY,GAAG,EAArB;;AAEA,MAAMC,eAAe,GAAKC,SAAF,IAAiB;AACxC,QAAMC,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BH,iBAA5B,CAArB;AACA,SACCI,YAAY,KACVA,YAAY,CAACC,IAAb,KAAsB,IAAtB,IACDD,YAAY,CAACE,QAAb,KAA0B,IADzB,IAEDF,YAAY,CAACG,UAAb,KAA4B,KAF3B,IAGDH,YAAY,CAACI,IAAb,KAAsB,KAJX,CADb;AAOA,CATD;;AAWA,MAAMC,uBAAuB,GAAKN,SAAF,IAAiB;AAChD,QAAMC,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BH,iBAA5B,CAArB;AAEA,SAAOI,YAAP,aAAOA,YAAP,uBAAOA,YAAY,CAAEM,+BAArB;AACA,CAJD;;AAMA,MAAMC,mBAAmB,GAAKR,SAAF,IAAiB;AAC5C,MAAKS,kBAASC,EAAT,KAAgB,KAArB,EAA6B;AAC5B,WAAO,KAAP;AACA;;AAED,QAAMT,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BH,iBAA5B,CAArB;AAEA,SAAO,sBAAUI,YAAV,KAA4B,CAAC,CAAEA,YAAY,CAACC,IAAnD;AACA,CARD;;AAUA,MAAMS,kBAAkB,GAAKX,SAAF,IAAiB;AAC3C,QAAMC,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BH,iBAA5B,CAArB;AAEA,SAAO,sBAAUI,YAAV,KAA4B,CAAC,CAAEA,YAAY,CAACW,SAAnD;AACA,CAJD;;AAMA,MAAMC,yBAAyB,G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,CAAE0C,IAAF,CAAzD,EAAoE;AACnE,WAAO,4BAAC,cAAD,EAAqBxB,KAArB,CAAP;AACA;;AACD,QAAMqE,WAAW,GAAG,EAApB;;AAEA,MAAKvE,SAAL,EAAiB;AAAA;;AAChBuE,IAAAA,WAAW,CAAC7D,KAAZ,4BAAoB,6CACnBO,MADmB,EAEnBjB,SAFmB,CAApB,0DAAoB,sBAGjBU,KAHH;AAIA;;AACD,MAAKd,eAAL,EAAuB;AAAA;;AACtB2E,IAAAA,WAAW,CAAC3E,eAAZ,6BAA8B,6CAC7BqB,MAD6B,EAE7BrB,eAF6B,CAA9B,2DAA8B,uBAG3Bc,KAHH;AAIA;;AAED,MAAI8D,YAAY,GAAGtE,KAAK,CAACsE,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAGtE,KAAK,CAACsE,YADK;AAEdpE,IAAAA,KAAK,EAAE,EACN,GAAGmE,WADG;AAEN,iCAAGrE,KAAK,CAACsE,YAAT,wDAAG,oBAAoBpE,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,4BAAC,cAAD,6BAAqBF,KAArB;AAA6B,IAAA,YAAY,EAAGsE;AAA5C,KAAP;AACA,CA3CoC,CAA/B;;AA8CP,sBACC,0BADD,EAEC,yBAFD,EAGC/E,aAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGCQ,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCY,YAHD;AAMA,sBACC,uBADD,EAEC,sCAFD,EAGCwD,sBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { isObject, setWith, clone } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, useMemo, Platform } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport {\n\t__experimentalGetGradientClass,\n\tgetGradientValueBySlug,\n\tgetGradientSlugByValue,\n} from '../components/gradients';\nimport { cleanEmptyObject } from './utils';\nimport ColorPanel from './color-panel';\nimport useSetting from '../components/use-setting';\n\nexport const COLOR_SUPPORT_KEY = 'color';\n\nconst EMPTY_OBJECT = {};\n\nconst hasColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\treturn (\n\t\tcolorSupport &&\n\t\t( colorSupport.link === true ||\n\t\t\tcolorSupport.gradient === true ||\n\t\t\tcolorSupport.background !== false ||\n\t\t\tcolorSupport.text !== false )\n\t);\n};\n\nconst shouldSkipSerialization = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport?.__experimentalSkipSerialization;\n};\n\nconst hasLinkColorSupport = ( blockType ) => {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn isObject( colorSupport ) && !! colorSupport.link;\n};\n\nconst hasGradientSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn isObject( colorSupport ) && !! colorSupport.gradients;\n};\n\nconst hasBackgroundColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.background !== false;\n};\n\nconst hasTextColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.text !== false;\n};\n\n/**\n * Filters registered block settings, extending attributes to include\n * `backgroundColor` and `textColor` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasColorSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.backgroundColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tbackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\tif ( ! settings.attributes.textColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\ttextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( hasGradientSupport( settings ) && ! settings.attributes.gradient ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tgradient: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject colors classnames.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasColorSupport( blockType ) ||\n\t\tshouldSkipSerialization( blockType )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst hasGradient = hasGradientSupport( blockType );\n\n\t// I'd have prefered to avoid the \"style\" attribute usage here\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\tconst backgroundClass = getColorClassName(\n\t\t'background-color',\n\t\tbackgroundColor\n\t);\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tconst textClass = getColorClassName( 'color', textColor );\n\tconst newClassName = classnames(\n\t\tprops.className,\n\t\ttextClass,\n\t\tgradientClass,\n\t\t{\n\t\t\t// Don't apply the background class if there's a custom gradient\n\t\t\t[ backgroundClass ]:\n\t\t\t\t( ! hasGradient || ! style?.color?.gradient ) &&\n\t\t\t\t!! backgroundClass,\n\t\t\t'has-text-color': textColor || style?.color?.text,\n\t\t\t'has-background':\n\t\t\t\tbackgroundColor ||\n\t\t\t\tstyle?.color?.background ||\n\t\t\t\t( hasGradient && ( gradient || style?.color?.gradient ) ),\n\t\t\t'has-link-color': style?.elements?.link?.color,\n\t\t}\n\t);\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extand the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif (\n\t\t! hasColorSupport( settings ) ||\n\t\tshouldSkipSerialization( settings )\n\t) {\n\t\treturn settings;\n\t}\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\nconst getLinkColorFromAttributeValue = ( colors, value ) => {\n\tconst attributeParsed = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( attributeParsed && attributeParsed[ 1 ] ) {\n\t\treturn getColorObjectByAttributeValues( colors, attributeParsed[ 1 ] )\n\t\t\t.color;\n\t}\n\treturn value;\n};\n\nfunction immutableSet( object, path, value ) {\n\treturn setWith( object ? clone( object ) : {}, path, value, clone );\n}\n\n/**\n * Inspector control panel containing the color related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Color edit element.\n */\nexport function ColorEdit( props ) {\n\tconst { name: blockName, attributes } = props;\n\t// Some color settings have a special handling for deprecated flags in `useSetting`,\n\t// so we can't unwrap them by doing const { ... } = useSetting('color')\n\t// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.\n\tconst userPalette = useSetting( 'color.palette.custom' );\n\tconst themePalette = useSetting( 'color.palette.theme' );\n\tconst defaultPalette = useSetting( 'color.palette.default' );\n\tconst allSolids = useMemo(\n\t\t() => [\n\t\t\t...( userPalette || [] ),\n\t\t\t...( themePalette || [] ),\n\t\t\t...( defaultPalette || [] ),\n\t\t],\n\t\t[ userPalette, themePalette, defaultPalette ]\n\t);\n\tconst gradientsPerOrigin = useSetting( 'color.gradients' ) || EMPTY_OBJECT;\n\tconst areCustomSolidsEnabled = useSetting( 'color.custom' );\n\tconst areCustomGradientsEnabled = useSetting( 'color.customGradient' );\n\tconst isBackgroundEnabled = useSetting( 'color.background' );\n\tconst isLinkEnabled = useSetting( 'color.link' );\n\tconst isTextEnabled = useSetting( 'color.text' );\n\n\tconst solidsEnabled =\n\t\tareCustomSolidsEnabled || ! themePalette || themePalette?.length > 0;\n\n\tconst gradientsEnabled =\n\t\tareCustomGradientsEnabled ||\n\t\t! gradientsPerOrigin?.theme ||\n\t\tgradientsPerOrigin?.theme?.length > 0;\n\n\tconst allGradients = useMemo(\n\t\t() => [\n\t\t\t...( gradientsPerOrigin?.custom || [] ),\n\t\t\t...( gradientsPerOrigin?.theme || [] ),\n\t\t\t...( gradientsPerOrigin?.default || [] ),\n\t\t],\n\t\t[ gradientsPerOrigin ]\n\t);\n\n\t// Shouldn't be needed but right now the ColorGradientsPanel\n\t// can trigger both onChangeColor and onChangeBackground\n\t// synchronously causing our two callbacks to override changes\n\t// from each other.\n\tconst localAttributes = useRef( attributes );\n\tuseEffect( () => {\n\t\tlocalAttributes.current = attributes;\n\t}, [ attributes ] );\n\n\tif ( ! hasColorSupport( blockName ) ) {\n\t\treturn null;\n\t}\n\n\tconst hasLinkColor =\n\t\thasLinkColorSupport( blockName ) && isLinkEnabled && solidsEnabled;\n\tconst hasTextColor =\n\t\thasTextColorSupport( blockName ) && isTextEnabled && solidsEnabled;\n\tconst hasBackgroundColor =\n\t\thasBackgroundColorSupport( blockName ) &&\n\t\tisBackgroundEnabled &&\n\t\tsolidsEnabled;\n\tconst hasGradientColor =\n\t\thasGradientSupport( blockName ) && gradientsEnabled;\n\n\tif (\n\t\t! hasLinkColor &&\n\t\t! hasTextColor &&\n\t\t! hasBackgroundColor &&\n\t\t! hasGradientColor\n\t) {\n\t\treturn null;\n\t}\n\n\tconst { style, textColor, backgroundColor, gradient } = attributes;\n\tlet gradientValue;\n\tif ( hasGradientColor && gradient ) {\n\t\tgradientValue = getGradientValueBySlug( allGradients, gradient );\n\t} else if ( hasGradientColor ) {\n\t\tgradientValue = style?.color?.gradient;\n\t}\n\n\tconst onChangeColor = ( name ) => ( value ) => {\n\t\tconst colorObject = getColorObjectByColorValue( allSolids, value );\n\t\tconst attributeName = name + 'Color';\n\t\tconst newStyle = {\n\t\t\t...localAttributes.current.style,\n\t\t\tcolor: {\n\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t[ name ]: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t[ attributeName ]: newNamedColor,\n\t\t};\n\n\t\tprops.setAttributes( newAttributes );\n\t\tlocalAttributes.current = {\n\t\t\t...localAttributes.current,\n\t\t\t...newAttributes,\n\t\t};\n\t};\n\n\tconst onChangeGradient = ( value ) => {\n\t\tconst slug = getGradientSlugByValue( allGradients, value );\n\t\tlet newAttributes;\n\t\tif ( slug ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...localAttributes.current?.style,\n\t\t\t\tcolor: {\n\t\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t\tgradient: undefined,\n\t\t\t\t},\n\t\t\t};\n\t\t\tnewAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\tgradient: slug,\n\t\t\t};\n\t\t} else {\n\t\t\tconst newStyle = {\n\t\t\t\t...localAttributes.current?.style,\n\t\t\t\tcolor: {\n\t\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t\tgradient: value,\n\t\t\t\t},\n\t\t\t};\n\t\t\tnewAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\tgradient: undefined,\n\t\t\t};\n\t\t}\n\t\tprops.setAttributes( newAttributes );\n\t\tlocalAttributes.current = {\n\t\t\t...localAttributes.current,\n\t\t\t...newAttributes,\n\t\t};\n\t};\n\n\tconst onChangeLinkColor = ( value ) => {\n\t\tconst colorObject = getColorObjectByColorValue( allSolids, value );\n\t\tconst newLinkColorValue = colorObject?.slug\n\t\t\t? `var:preset|color|${ colorObject.slug }`\n\t\t\t: value;\n\n\t\tconst newStyle = cleanEmptyObject(\n\t\t\timmutableSet(\n\t\t\t\tstyle,\n\t\t\t\t[ 'elements', 'link', 'color', 'text' ],\n\t\t\t\tnewLinkColorValue\n\t\t\t)\n\t\t);\n\t\tprops.setAttributes( { style: newStyle } );\n\t};\n\n\treturn (\n\t\t<ColorPanel\n\t\t\tenableContrastChecking={\n\t\t\t\t// Turn on contrast checker for web only since it's not supported on mobile yet.\n\t\t\t\tPlatform.OS === 'web' && ! gradient && ! style?.color?.gradient\n\t\t\t}\n\t\t\tclientId={ props.clientId }\n\t\t\tsettings={ [\n\t\t\t\t...( hasTextColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Text color' ),\n\t\t\t\t\t\t\t\tonColorChange: onChangeColor( 'text' ),\n\t\t\t\t\t\t\t\tcolorValue: getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\ttextColor,\n\t\t\t\t\t\t\t\t\tstyle?.color?.text\n\t\t\t\t\t\t\t\t).color,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t\t...( hasBackgroundColor || hasGradientColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Background color' ),\n\t\t\t\t\t\t\t\tonColorChange: hasBackgroundColor\n\t\t\t\t\t\t\t\t\t? onChangeColor( 'background' )\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\tcolorValue: getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\t\t\t\tstyle?.color?.background\n\t\t\t\t\t\t\t\t).color,\n\t\t\t\t\t\t\t\tgradientValue,\n\t\t\t\t\t\t\t\tonGradientChange: hasGradientColor\n\t\t\t\t\t\t\t\t\t? onChangeGradient\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t\t...( hasLinkColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Link Color' ),\n\t\t\t\t\t\t\t\tonColorChange: onChangeLinkColor,\n\t\t\t\t\t\t\t\tcolorValue: getLinkColorFromAttributeValue(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\tstyle?.elements?.link?.color?.text\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tclearable: !! style?.elements?.link?.color\n\t\t\t\t\t\t\t\t\t?.text,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t] }\n\t\t/>\n\t);\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { backgroundColor, textColor } = attributes;\n\t\tconst userPalette = useSetting( 'color.palette.custom' ) || [];\n\t\tconst themePalette = useSetting( 'color.palette.theme' ) || [];\n\t\tconst defaultPalette = useSetting( 'color.palette.default' ) || [];\n\t\tconst colors = useMemo(\n\t\t\t() => [\n\t\t\t\t...( userPalette || [] ),\n\t\t\t\t...( themePalette || [] ),\n\t\t\t\t...( defaultPalette || [] ),\n\t\t\t],\n\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t);\n\t\tif ( ! hasColorSupport( name ) || shouldSkipSerialization( name ) ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\t\tconst extraStyles = {};\n\n\t\tif ( textColor ) {\n\t\t\textraStyles.color = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\ttextColor\n\t\t\t)?.color;\n\t\t}\n\t\tif ( backgroundColor ) {\n\t\t\textraStyles.backgroundColor = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\tbackgroundColor\n\t\t\t)?.color;\n\t\t}\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/color/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/color/with-color-palette-styles',\n\twithColorPaletteStyles\n);\n"]}