@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
@@ -6,7 +6,7 @@ import { find } from 'lodash';
6
6
  * WordPress dependencies
7
7
  */
8
8
 
9
- import { useCallback } from '@wordpress/element';
9
+ import { useCallback, useMemo } from '@wordpress/element';
10
10
  import { useSelect, useDispatch } from '@wordpress/data';
11
11
  /**
12
12
  * Internal dependencies
@@ -15,7 +15,6 @@ import { useSelect, useDispatch } from '@wordpress/data';
15
15
  import { useBlockEditContext } from '../block-edit';
16
16
  import useSetting from '../use-setting';
17
17
  import { store as blockEditorStore } from '../../store';
18
- const EMPTY_ARRAY = [];
19
18
  export function __experimentalGetGradientClass(gradientSlug) {
20
19
  if (!gradientSlug) {
21
20
  return undefined;
@@ -53,6 +52,7 @@ export function getGradientSlugByValue(gradients, value) {
53
52
 
54
53
  return gradient && gradient.slug;
55
54
  }
55
+ const EMPTY_OBJECT = {};
56
56
  export function __experimentalUseGradient() {
57
57
  let {
58
58
  gradientAttribute = 'gradient',
@@ -61,7 +61,8 @@ export function __experimentalUseGradient() {
61
61
  const {
62
62
  clientId
63
63
  } = useBlockEditContext();
64
- const gradients = useSetting('color.gradients') || EMPTY_ARRAY;
64
+ const gradientsPerOrigin = useSetting('color.gradients') || EMPTY_OBJECT;
65
+ const allGradients = 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]);
65
66
  const {
66
67
  gradient,
67
68
  customGradient
@@ -79,7 +80,7 @@ export function __experimentalUseGradient() {
79
80
  updateBlockAttributes
80
81
  } = useDispatch(blockEditorStore);
81
82
  const setGradient = useCallback(newGradientValue => {
82
- const slug = getGradientSlugByValue(gradients, newGradientValue);
83
+ const slug = getGradientSlugByValue(allGradients, newGradientValue);
83
84
 
84
85
  if (slug) {
85
86
  updateBlockAttributes(clientId, {
@@ -93,14 +94,14 @@ export function __experimentalUseGradient() {
93
94
  [gradientAttribute]: undefined,
94
95
  [customGradientAttribute]: newGradientValue
95
96
  });
96
- }, [gradients, clientId, updateBlockAttributes]);
97
+ }, [allGradients, clientId, updateBlockAttributes]);
97
98
 
98
99
  const gradientClass = __experimentalGetGradientClass(gradient);
99
100
 
100
101
  let gradientValue;
101
102
 
102
103
  if (gradient) {
103
- gradientValue = getGradientValueBySlug(gradients, gradient);
104
+ gradientValue = getGradientValueBySlug(allGradients, gradient);
104
105
  } else {
105
106
  gradientValue = customGradient;
106
107
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/gradients/use-gradient.js"],"names":["find","useCallback","useSelect","useDispatch","useBlockEditContext","useSetting","store","blockEditorStore","EMPTY_ARRAY","__experimentalGetGradientClass","gradientSlug","undefined","getGradientValueBySlug","gradients","slug","gradient","__experimentalGetGradientObjectByGradientValue","value","getGradientSlugByValue","__experimentalUseGradient","gradientAttribute","customGradientAttribute","clientId","customGradient","select","getBlockAttributes","attributes","updateBlockAttributes","setGradient","newGradientValue","gradientClass","gradientValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,OAAOC,UA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":["/**\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":["find","useCallback","useMemo","useSelect","useDispatch","useBlockEditContext","useSetting","store","blockEditorStore","__experimentalGetGradientClass","gradientSlug","undefined","getGradientValueBySlug","gradients","slug","gradient","__experimentalGetGradientObjectByGradientValue","value","getGradientSlugByValue","EMPTY_OBJECT","__experimentalUseGradient","gradientAttribute","customGradientAttribute","clientId","gradientsPerOrigin","allGradients","custom","theme","default","customGradient","select","getBlockAttributes","attributes","updateBlockAttributes","setGradient","newGradientValue","gradientClass","gradientValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,OAAOC,UAA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,CAArB;AAIA,GAjB6B,EAkB9B,CAAEV,YAAF,EAAgBF,QAAhB,EAA0BU,qBAA1B,CAlB8B,CAA/B;;AAqBA,QAAMG,aAAa,GAAG3B,8BAA8B,CAAEM,QAAF,CAApD;;AACA,MAAIsB,aAAJ;;AACA,MAAKtB,QAAL,EAAgB;AACfsB,IAAAA,aAAa,GAAGzB,sBAAsB,CAAEa,YAAF,EAAgBV,QAAhB,CAAtC;AACA,GAFD,MAEO;AACNsB,IAAAA,aAAa,GAAGR,cAAhB;AACA;;AACD,SAAO;AAAEO,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"]}
@@ -106,7 +106,7 @@ export default function useSetting(path) {
106
106
  if (PATHS_WITH_MERGE[normalizedPath]) {
107
107
  var _ref, _experimentalFeatures;
108
108
 
109
- return (_ref = (_experimentalFeatures = experimentalFeaturesResult.user) !== null && _experimentalFeatures !== void 0 ? _experimentalFeatures : experimentalFeaturesResult.theme) !== null && _ref !== void 0 ? _ref : experimentalFeaturesResult.default;
109
+ return (_ref = (_experimentalFeatures = experimentalFeaturesResult.custom) !== null && _experimentalFeatures !== void 0 ? _experimentalFeatures : experimentalFeaturesResult.theme) !== null && _ref !== void 0 ? _ref : experimentalFeaturesResult.default;
110
110
  }
111
111
 
112
112
  return experimentalFeaturesResult;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/use-setting/index.js"],"names":["get","useSelect","__EXPERIMENTAL_PATHS_WITH_MERGE","PATHS_WITH_MERGE","useBlockEditContext","store","blockEditorStore","deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","setting","select","getSettings","normalizedPath","defaultsPath","blockPath","experimentalFeaturesResult","user","theme","default","deprecatedSettingsValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,+BAA+B,IAAIC,gBAA5C,QAAoE,mBAApE;AAEA;AACA;AACA;;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,eAAe,GAAG;AACvB,mBAAmBC,QAAF,IAChBA,QAAQ,CAACC,MAAT,KAAoBC,SAApB,GAAgCA,SAAhC,GAA4CF,QAAQ,CAACC,MAF/B;AAGv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AFH;;AAGA,QAAKyB,uBAAuB,KAAKzB,SAAjC,EAA6C;AAC5C,aAAOyB,uBAAP;AACA,KA5BY,CA8Bb;AACA;AACA;AACA;;;AACA,WAAOP,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDlB,SAAxD;AACA,GApCuB,EAqCxB,CAAEc,SAAF,EAAaH,IAAb,CArCwB,CAAzB;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":["get","useSelect","__EXPERIMENTAL_PATHS_WITH_MERGE","PATHS_WITH_MERGE","useBlockEditContext","store","blockEditorStore","deprecatedFlags","settings","colors","undefined","gradients","disableCustomColors","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","useSetting","name","blockName","setting","select","getSettings","normalizedPath","defaultsPath","blockPath","experimentalFeaturesResult","custom","theme","default","deprecatedSettingsValue"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1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ArB,EAA0C;AAAA;;AACzC,gDACCG,0BAA0B,CAACC,MAD5B,yEAECD,0BAA0B,CAACE,KAF5B,uCAGCF,0BAA0B,CAACG,OAH5B;AAKA;;AACD,aAAOH,0BAAP;AACA,KApBY,CAsBb;;;AACA,UAAMI,uBAAuB,GAAG5B,eAAe,CAAEqB,cAAF,CAAf,GAC7BrB,eAAe,CAAEqB,cAAF,CAAf,CAAmCpB,QAAnC,CAD6B,GAE7BE,SAFH;;AAGA,QAAKyB,uBAAuB,KAAKzB,SAAjC,EAA6C;AAC5C,aAAOyB,uBAAP;AACA,KA5BY,CA8Bb;AACA;AACA;AACA;;;AACA,WAAOP,cAAc,KAAK,oBAAnB,GAA0C,IAA1C,GAAiDlB,SAAxD;AACA,GApCuB,EAqCxB,CAAEc,SAAF,EAAaH,IAAb,CArCwB,CAAzB;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"]}
@@ -18,6 +18,7 @@ import { useState } from '@wordpress/element';
18
18
  */
19
19
 
20
20
  import ColorGradientControl from '../components/colors-gradients/control';
21
+ import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
21
22
  import { getColorClassName, getColorObjectByColorValue, getColorObjectByAttributeValues } from '../components/colors';
22
23
  import useSetting from '../components/use-setting';
23
24
  import { hasBorderSupport, shouldSkipSerialization } from './border';
@@ -47,18 +48,17 @@ export function BorderColorEdit(props) {
47
48
  },
48
49
  setAttributes
49
50
  } = props;
50
- const colors = useSetting('color.palette') || EMPTY_ARRAY;
51
- const disableCustomColors = !useSetting('color.custom');
52
- const disableCustomGradients = !useSetting('color.customGradient');
51
+ const colorGradientSettings = useMultipleOriginColorsAndGradients();
52
+ const availableColors = colorGradientSettings.colors.reduce((colors, origin) => colors.concat(origin.colors), []);
53
53
  const [colorValue, setColorValue] = useState(() => {
54
54
  var _getColorObjectByAttr, _style$border;
55
55
 
56
- return (_getColorObjectByAttr = 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;
56
+ return (_getColorObjectByAttr = 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;
57
57
  });
58
58
 
59
59
  const onChangeColor = value => {
60
60
  setColorValue(value);
61
- const colorObject = getColorObjectByColorValue(colors, value);
61
+ const colorObject = getColorObjectByColorValue(availableColors, value);
62
62
  const newStyle = { ...style,
63
63
  border: { ...(style === null || style === void 0 ? void 0 : style.border),
64
64
  color: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
@@ -72,15 +72,14 @@ export function BorderColorEdit(props) {
72
72
  });
73
73
  };
74
74
 
75
- return createElement(ColorGradientControl, {
75
+ return createElement(ColorGradientControl, _extends({
76
76
  label: __('Color'),
77
77
  colorValue: colorValue,
78
- colors: colors,
79
- gradients: undefined,
80
- disableCustomColors: disableCustomColors,
81
- disableCustomGradients: disableCustomGradients,
82
- onColorChange: onChangeColor
83
- });
78
+ onColorChange: onChangeColor,
79
+ clearable: false,
80
+ __experimentalHasMultipleOrigins: true,
81
+ __experimentalIsRenderedInSidebar: true
82
+ }, colorGradientSettings));
84
83
  }
85
84
  /**
86
85
  * Filters registered block settings, extending attributes to include
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/border-color.js"],"names":["classnames","addFilter","__","createHigherOrderComponent","useState","ColorGradientControl","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","useSetting","hasBorderSupport","shouldSkipSerialization","cleanEmptyObject","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":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,wCAAjC;AACA,SACCC,iBADD,EAECC,0BAFD,EAGCC,+BAHD,QAIO,sBAJP;AAKA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,gBAAT,EAA2BC,uBAA3B,QAA0D,UAA1D;AACA,SAASC,gBAAT,QAAiC,SAAjC,C,CAEA;AACA;;AACA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACxC,QAAM;AACLC,IAAAA,UAAU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EAGE;AACD,WAAO,cAAC,cAAD,EAAqBhC,KAArB,CAAP;AACA;;AAED,QAAMiC,WAAW,GAAG;AACnB/B,IAAAA,WAAW,EAAEA,WAAW,6BACrBT,+BAA+B,CAAEY,MAAF,EAAUH,WAAV,CADV,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,cAAC,cAAD,eAAqBH,KAArB;AAA6B,IAAA,YAAY,EAAGkC;AAA5C,KAAP;AACA,CA7BoE,CAA/D;AAgCPhD,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGRiC,aAHQ,CAAT;AAMAjC,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGRoC,YAHQ,CAAT;AAMApC,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGRyC,YAHQ,CAAT;AAMAzC,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGR4C,4BAHQ,CAAT","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":["classnames","addFilter","__","createHigherOrderComponent","useState","ColorGradientControl","useMultipleOriginColorsAndGradients","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","useSetting","hasBorderSupport","shouldSkipSerialization","cleanEmptyObject","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":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,wCAAjC;AACA,OAAOC,mCAAP,MAAgD,yEAAhD;AACA,SACCC,iBADD,EAECC,0BAFD,EAGCC,+BAHD,QAIO,sBAJP;AAKA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,gBAAT,EAA2BC,uBAA3B,QAA0D,UAA1D;AACA,SAASC,gBAAT,QAAiC,SAAjC,C,CAEA;AACA;;AACA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,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,GAAGf,mCAAmC,EAAjE;AACA,QAAMgB,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,IAAgCxB,Q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AGiC,WADG;AAEN,iCAAGpC,KAAK,CAACqC,YAAT,wDAAG,oBAAoBlC,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,cAAC,cAAD,eAAqBH,KAArB;AAA6B,IAAA,YAAY,EAAGqC;AAA5C,KAAP;AACA,CA7BoE,CAA/D;AAgCPpD,SAAS,CACR,0BADQ,EAER,2BAFQ,EAGRqC,aAHQ,CAAT;AAMArC,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGRwC,YAHQ,CAAT;AAMAxC,SAAS,CACR,0BADQ,EAER,0BAFQ,EAGR6C,YAHQ,CAAT;AAMA7C,SAAS,CACR,uBADQ,EAER,8CAFQ,EAGRgD,4BAHQ,CAAT","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"]}
@@ -53,7 +53,8 @@ export default function ColorPanel(_ref) {
53
53
  initialOpen: false,
54
54
  settings: settings,
55
55
  showTitle: showTitle,
56
- __experimentalHasMultipleOrigins: true
56
+ __experimentalHasMultipleOrigins: true,
57
+ __experimentalIsRenderedInSidebar: true
57
58
  }, enableContrastChecking && createElement(ContrastChecker, {
58
59
  backgroundColor: detectedBackgroundColor,
59
60
  textColor: detectedColor
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/color-panel.js"],"names":["useState","useEffect","__","PanelColorGradientSettings","ContrastChecker","InspectorControls","__unstableUseBlockRef","useBlockRef","getComputedStyle","node","ownerDocument","defaultView","ColorPanel","settings","clientId","enableContrastChecking","showTitle","detectedBackgroundColor","setDetectedBackgroundColor","detectedColor","setDetectedColor","ref","current","color","backgroundColorNode","backgroundColor","parentNode","nodeType","ELEMENT_NODE"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,8DAAvC;AACA,OAAOC,eAAP,MAA4B,gCAA5B;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,SAASC,qBAAqB,IAAIC,WAAlC,QAAqD,yDAArD;;AAEA,SAASC,gBAAT,CAA2BC,IAA3B,EAAkC;AACjC,SAAOA,IAAI,CAACC,aAAL,CAAmBC,WAAnB,CAA+BH,gBAA/B,CAAiDC,IAAjD,CAAP;AACA;;AAED,eAAe,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,IAA0DlB,QAAQ,EAAxE;AACA,QAAM,CAAEmB,aAAF,EAAiBC,gBAAjB,IAAsCpB,QAAQ,EAApD;AACA,QAAMqB,GAAG,GAAGd,WAAW,CAAEO,QAAF,CAAvB;AAEAb,EAAAA,SAAS,CAAE,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,GAzBQ,CAAT;AA2BA,SACC,cAAC,iBAAD,QACC,cAAC,0BAAD;AACC,IAAA,KAAK,EAAGvB,EAAE,CAAE,OAAF,CADX;AAEC,IAAA,WAAW,EAAG,KAFf;AAGC,IAAA,QAAQ,EAAGW,QAHZ;AAIC,IAAA,SAAS,EAAGG,SAJb;AAKC,IAAA,gCAAgC;AALjC,KAOGD,sBAAsB,IACvB,cAAC,eAAD;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":["useState","useEffect","__","PanelColorGradientSettings","ContrastChecker","InspectorControls","__unstableUseBlockRef","useBlockRef","getComputedStyle","node","ownerDocument","defaultView","ColorPanel","settings","clientId","enableContrastChecking","showTitle","detectedBackgroundColor","setDetectedBackgroundColor","detectedColor","setDetectedColor","ref","current","color","backgroundColorNode","backgroundColor","parentNode","nodeType","ELEMENT_NODE"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;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CAAhB,CAChBC,eADF;AAEA;;AAEDP,IAAAA,0BAA0B,CAAEO,eAAF,CAA1B;AACA,GAzBQ,CAAT;AA2BA,SACC,cAAC,iBAAD,QACC,cAAC,0BAAD;AACC,IAAA,KAAK,EAAGvB,EAAE,CAAE,OAAF,CADX;AAEC,IAAA,WAAW,EAAG,KAFf;AAGC,IAAA,QAAQ,EAAGW,QAHZ;AAIC,IAAA,SAAS,EAAGG,SAJb;AAKC,IAAA,gCAAgC,MALjC;AAMC,IAAA,iCAAiC;AANlC,KAQGD,sBAAsB,IACvB,cAAC,eAAD;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"]}
@@ -13,7 +13,7 @@ import { isObject, setWith, clone } from 'lodash';
13
13
  import { addFilter } from '@wordpress/hooks';
14
14
  import { getBlockSupport } from '@wordpress/blocks';
15
15
  import { __ } from '@wordpress/i18n';
16
- import { useRef, useEffect, Platform } from '@wordpress/element';
16
+ import { useRef, useEffect, useMemo, Platform } from '@wordpress/element';
17
17
  import { createHigherOrderComponent } from '@wordpress/compose';
18
18
  /**
19
19
  * Internal dependencies
@@ -25,7 +25,7 @@ import { cleanEmptyObject } from './utils';
25
25
  import ColorPanel from './color-panel';
26
26
  import useSetting from '../components/use-setting';
27
27
  export const COLOR_SUPPORT_KEY = 'color';
28
- const EMPTY_ARRAY = [];
28
+ const EMPTY_OBJECT = {};
29
29
 
30
30
  const hasColorSupport = blockType => {
31
31
  const colorSupport = getBlockSupport(blockType, COLOR_SUPPORT_KEY);
@@ -195,19 +195,28 @@ function immutableSet(object, path, value) {
195
195
 
196
196
 
197
197
  export function ColorEdit(props) {
198
- var _style$color6, _style$color7, _style$color8, _style$elements2, _style$elements2$link, _style$elements2$link2, _style$elements3, _style$elements3$link, _style$elements3$link2;
198
+ 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;
199
199
 
200
200
  const {
201
201
  name: blockName,
202
202
  attributes
203
- } = props;
204
- const solids = useSetting('color.palette') || EMPTY_ARRAY;
205
- const gradients = useSetting('color.gradients') || EMPTY_ARRAY;
203
+ } = props; // Some color settings have a special handling for deprecated flags in `useSetting`,
204
+ // so we can't unwrap them by doing const { ... } = useSetting('color')
205
+ // until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
206
+
207
+ const userPalette = useSetting('color.palette.custom');
208
+ const themePalette = useSetting('color.palette.theme');
209
+ const defaultPalette = useSetting('color.palette.default');
210
+ const allSolids = useMemo(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
211
+ const gradientsPerOrigin = useSetting('color.gradients') || EMPTY_OBJECT;
206
212
  const areCustomSolidsEnabled = useSetting('color.custom');
207
213
  const areCustomGradientsEnabled = useSetting('color.customGradient');
214
+ const isBackgroundEnabled = useSetting('color.background');
208
215
  const isLinkEnabled = useSetting('color.link');
209
216
  const isTextEnabled = useSetting('color.text');
210
- const isBackgroundEnabled = useSetting('color.background'); // Shouldn't be needed but right now the ColorGradientsPanel
217
+ const solidsEnabled = areCustomSolidsEnabled || !themePalette || (themePalette === null || themePalette === void 0 ? void 0 : themePalette.length) > 0;
218
+ 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;
219
+ const allGradients = 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
211
220
  // can trigger both onChangeColor and onChangeBackground
212
221
  // synchronously causing our two callbacks to override changes
213
222
  // from each other.
@@ -221,10 +230,10 @@ export function ColorEdit(props) {
221
230
  return null;
222
231
  }
223
232
 
224
- const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled && (solids.length > 0 || areCustomSolidsEnabled);
225
- const hasTextColor = hasTextColorSupport(blockName) && isTextEnabled && (solids.length > 0 || areCustomSolidsEnabled);
226
- const hasBackgroundColor = hasBackgroundColorSupport(blockName) && isBackgroundEnabled && (solids.length > 0 || areCustomSolidsEnabled);
227
- const hasGradientColor = hasGradientSupport(blockName) && (gradients.length > 0 || areCustomGradientsEnabled);
233
+ const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled && solidsEnabled;
234
+ const hasTextColor = hasTextColorSupport(blockName) && isTextEnabled && solidsEnabled;
235
+ const hasBackgroundColor = hasBackgroundColorSupport(blockName) && isBackgroundEnabled && solidsEnabled;
236
+ const hasGradientColor = hasGradientSupport(blockName) && gradientsEnabled;
228
237
 
229
238
  if (!hasLinkColor && !hasTextColor && !hasBackgroundColor && !hasGradientColor) {
230
239
  return null;
@@ -239,7 +248,7 @@ export function ColorEdit(props) {
239
248
  let gradientValue;
240
249
 
241
250
  if (hasGradientColor && gradient) {
242
- gradientValue = getGradientValueBySlug(gradients, gradient);
251
+ gradientValue = getGradientValueBySlug(allGradients, gradient);
243
252
  } else if (hasGradientColor) {
244
253
  var _style$color5;
245
254
 
@@ -249,7 +258,7 @@ export function ColorEdit(props) {
249
258
  const onChangeColor = name => value => {
250
259
  var _localAttributes$curr, _localAttributes$curr2;
251
260
 
252
- const colorObject = getColorObjectByColorValue(solids, value);
261
+ const colorObject = getColorObjectByColorValue(allSolids, value);
253
262
  const attributeName = name + 'Color';
254
263
  const newStyle = { ...localAttributes.current.style,
255
264
  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),
@@ -268,7 +277,7 @@ export function ColorEdit(props) {
268
277
  };
269
278
 
270
279
  const onChangeGradient = value => {
271
- const slug = getGradientSlugByValue(gradients, value);
280
+ const slug = getGradientSlugByValue(allGradients, value);
272
281
  let newAttributes;
273
282
 
274
283
  if (slug) {
@@ -304,7 +313,7 @@ export function ColorEdit(props) {
304
313
  };
305
314
 
306
315
  const onChangeLinkColor = value => {
307
- const colorObject = getColorObjectByColorValue(solids, value);
316
+ const colorObject = getColorObjectByColorValue(allSolids, value);
308
317
  const newLinkColorValue = colorObject !== null && colorObject !== void 0 && colorObject.slug ? `var:preset|color|${colorObject.slug}` : value;
309
318
  const newStyle = cleanEmptyObject(immutableSet(style, ['elements', 'link', 'color', 'text'], newLinkColorValue));
310
319
  props.setAttributes({
@@ -319,17 +328,17 @@ export function ColorEdit(props) {
319
328
  settings: [...(hasTextColor ? [{
320
329
  label: __('Text color'),
321
330
  onColorChange: onChangeColor('text'),
322
- colorValue: 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
331
+ colorValue: 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
323
332
  }] : []), ...(hasBackgroundColor || hasGradientColor ? [{
324
333
  label: __('Background color'),
325
334
  onColorChange: hasBackgroundColor ? onChangeColor('background') : undefined,
326
- colorValue: 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,
335
+ colorValue: 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,
327
336
  gradientValue,
328
337
  onGradientChange: hasGradientColor ? onChangeGradient : undefined
329
338
  }] : []), ...(hasLinkColor ? [{
330
339
  label: __('Link Color'),
331
340
  onColorChange: onChangeLinkColor,
332
- 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),
341
+ 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),
333
342
  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)
334
343
  }] : [])]
335
344
  });
@@ -344,7 +353,7 @@ export function ColorEdit(props) {
344
353
  */
345
354
 
346
355
  export const withColorPaletteStyles = createHigherOrderComponent(BlockListBlock => props => {
347
- var _getColorObjectByAttr, _getColorObjectByAttr2, _props$wrapperProps;
356
+ var _props$wrapperProps;
348
357
 
349
358
  const {
350
359
  name,
@@ -354,16 +363,29 @@ export const withColorPaletteStyles = createHigherOrderComponent(BlockListBlock
354
363
  backgroundColor,
355
364
  textColor
356
365
  } = attributes;
357
- const colors = useSetting('color.palette') || EMPTY_ARRAY;
366
+ const userPalette = useSetting('color.palette.custom') || [];
367
+ const themePalette = useSetting('color.palette.theme') || [];
368
+ const defaultPalette = useSetting('color.palette.default') || [];
369
+ const colors = useMemo(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
358
370
 
359
371
  if (!hasColorSupport(name) || shouldSkipSerialization(name)) {
360
372
  return createElement(BlockListBlock, props);
361
373
  }
362
374
 
363
- const extraStyles = {
364
- color: textColor ? (_getColorObjectByAttr = getColorObjectByAttributeValues(colors, textColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color : undefined,
365
- backgroundColor: backgroundColor ? (_getColorObjectByAttr2 = getColorObjectByAttributeValues(colors, backgroundColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color : undefined
366
- };
375
+ const extraStyles = {};
376
+
377
+ if (textColor) {
378
+ var _getColorObjectByAttr;
379
+
380
+ extraStyles.color = (_getColorObjectByAttr = getColorObjectByAttributeValues(colors, textColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color;
381
+ }
382
+
383
+ if (backgroundColor) {
384
+ var _getColorObjectByAttr2;
385
+
386
+ extraStyles.backgroundColor = (_getColorObjectByAttr2 = getColorObjectByAttributeValues(colors, backgroundColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color;
387
+ }
388
+
367
389
  let wrapperProps = props.wrapperProps;
368
390
  wrapperProps = { ...props.wrapperProps,
369
391
  style: { ...extraStyles,