@wordpress/block-editor 13.0.4 → 13.0.6

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 (33) hide show
  1. package/build/components/block-list/use-block-props/use-block-refs.js +9 -2
  2. package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  3. package/build/components/block-toolbar/shuffle.js +1 -1
  4. package/build/components/block-toolbar/shuffle.js.map +1 -1
  5. package/build/components/global-styles/hooks.js +5 -1
  6. package/build/components/global-styles/hooks.js.map +1 -1
  7. package/build/components/global-styles/use-global-styles-output.js +28 -12
  8. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  9. package/build/hooks/block-style-variation.js +63 -4
  10. package/build/hooks/block-style-variation.js.map +1 -1
  11. package/build/layouts/constrained.js +6 -2
  12. package/build/layouts/constrained.js.map +1 -1
  13. package/build-module/components/block-list/use-block-props/use-block-refs.js +11 -4
  14. package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
  15. package/build-module/components/block-toolbar/shuffle.js +1 -1
  16. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  17. package/build-module/components/global-styles/hooks.js +5 -1
  18. package/build-module/components/global-styles/hooks.js.map +1 -1
  19. package/build-module/components/global-styles/use-global-styles-output.js +28 -12
  20. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  21. package/build-module/hooks/block-style-variation.js +62 -4
  22. package/build-module/hooks/block-style-variation.js.map +1 -1
  23. package/build-module/layouts/constrained.js +6 -2
  24. package/build-module/layouts/constrained.js.map +1 -1
  25. package/package.json +2 -2
  26. package/src/components/block-list/use-block-props/use-block-refs.js +19 -3
  27. package/src/components/block-toolbar/shuffle.js +2 -1
  28. package/src/components/global-styles/hooks.js +5 -1
  29. package/src/components/global-styles/test/use-global-styles-output.js +2 -1
  30. package/src/components/global-styles/use-global-styles-output.js +27 -10
  31. package/src/hooks/block-style-variation.js +80 -3
  32. package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
  33. package/src/layouts/constrained.js +10 -2
@@ -184,15 +184,19 @@ var _default = exports.default = {
184
184
  const paddingValues = (0, _styleEngine.getCSSRules)(style);
185
185
  paddingValues.forEach(rule => {
186
186
  if (rule.key === 'paddingRight') {
187
+ // Add unit if 0, to avoid calc(0 * -1) which is invalid.
188
+ const paddingRightValue = rule.value === '0' ? '0px' : rule.value;
187
189
  output += `
188
190
  ${(0, _utils.appendSelectors)(selector, '> .alignfull')} {
189
- margin-right: calc(${rule.value} * -1);
191
+ margin-right: calc(${paddingRightValue} * -1);
190
192
  }
191
193
  `;
192
194
  } else if (rule.key === 'paddingLeft') {
195
+ // Add unit if 0, to avoid calc(0 * -1) which is invalid.
196
+ const paddingLeftValue = rule.value === '0' ? '0px' : rule.value;
193
197
  output += `
194
198
  ${(0, _utils.appendSelectors)(selector, '> .alignfull')} {
195
- margin-left: calc(${rule.value} * -1);
199
+ margin-left: calc(${paddingLeftValue} * -1);
196
200
  }
197
201
  `;
198
202
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_i18n","_icons","_styleEngine","_useSettings","_utils","_gap","_utils2","_definitions","_jsxRuntime","_default","exports","default","name","label","__","inspectorControls","DefaultLayoutInspectorControls","layout","onChange","layoutBlockSupport","wideSize","contentSize","justifyContent","allowJustification","allowCustomContentAndWideSize","onJustificationChange","value","justificationOptions","icon","justifyLeft","justifyCenter","justifyRight","availableUnits","useSettings","units","useCustomUnits","jsxs","Fragment","children","className","jsx","__experimentalUnitControl","labelPosition","__unstableInputWidth","nextWidth","parseFloat","Icon","positionCenter","stretchWide","__experimentalToggleGroupControl","__nextHasNoMarginBottom","map","__experimentalToggleGroupControlOptionIcon","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","LAYOUT_DEFINITIONS","blockGapStyleValue","getGapCSSValue","spacing","blockGap","blockGapValue","shouldSkipSerialization","top","marginLeft","marginRight","output","appendSelectors","padding","paddingValues","getCSSRules","forEach","rule","key","getBlockGapCSS","getOrientation","getAlignments","alignmentInfo","getAlignmentsInfo","alignments","undefined","includes","unshift","alignment","info","wide","none"],"sources":["@wordpress/block-editor/src/layouts/constrained.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tIcon,\n\tpositionCenter,\n\tstretchWide,\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n} from '@wordpress/icons';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport { appendSelectors, getBlockGapCSS, getAlignmentsInfo } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\nimport { LAYOUT_DEFINITIONS } from './definitions';\n\nexport default {\n\tname: 'constrained',\n\tlabel: __( 'Constrained' ),\n\tinspectorControls: function DefaultLayoutInspectorControls( {\n\t\tlayout,\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { wideSize, contentSize, justifyContent = 'center' } = layout;\n\t\tconst {\n\t\t\tallowJustification = true,\n\t\t\tallowCustomContentAndWideSize = true,\n\t\t} = layoutBlockSupport;\n\t\tconst onJustificationChange = ( value ) => {\n\t\t\tonChange( {\n\t\t\t\t...layout,\n\t\t\t\tjustifyContent: value,\n\t\t\t} );\n\t\t};\n\t\tconst justificationOptions = [\n\t\t\t{\n\t\t\t\tvalue: 'left',\n\t\t\t\ticon: justifyLeft,\n\t\t\t\tlabel: __( 'Justify items left' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'center',\n\t\t\t\ticon: justifyCenter,\n\t\t\t\tlabel: __( 'Justify items center' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'right',\n\t\t\t\ticon: justifyRight,\n\t\t\t\tlabel: __( 'Justify items right' ),\n\t\t\t},\n\t\t];\n\t\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\t\tconst units = useCustomUnits( {\n\t\t\tavailableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],\n\t\t} );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ allowCustomContentAndWideSize && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls\">\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Content' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ contentSize || wideSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\tcontentSize: nextWidth,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ positionCenter } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Wide' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ wideSize || contentSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\twideSize: nextWidth,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ stretchWide } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<p className=\"block-editor-hooks__layout-controls-helptext\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Customize the width for all elements that are assigned to the center or wide columns.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ allowJustification && (\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Justification' ) }\n\t\t\t\t\t\tvalue={ justifyContent }\n\t\t\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ justificationOptions.map(\n\t\t\t\t\t\t\t( { value, icon, label } ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tlayout = {},\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions = LAYOUT_DEFINITIONS,\n\t} ) {\n\t\tconst { contentSize, wideSize, justifyContent } = layout;\n\t\tconst blockGapStyleValue = getGapCSSValue( style?.spacing?.blockGap );\n\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tlet blockGapValue = '';\n\t\tif ( ! shouldSkipSerialization( blockName, 'spacing', 'blockGap' ) ) {\n\t\t\t// If an object is provided only use the 'top' value for this kind of gap.\n\t\t\tif ( blockGapStyleValue?.top ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue?.top );\n\t\t\t} else if ( typeof blockGapStyleValue === 'string' ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue );\n\t\t\t}\n\t\t}\n\n\t\tconst marginLeft =\n\t\t\tjustifyContent === 'left' ? '0 !important' : 'auto !important';\n\t\tconst marginRight =\n\t\t\tjustifyContent === 'right' ? '0 !important' : 'auto !important';\n\n\t\tlet output =\n\t\t\t!! contentSize || !! wideSize\n\t\t\t\t? `\n\t\t\t\t\t${ appendSelectors(\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t\t\t) } {\n\t\t\t\t\t\tmax-width: ${ contentSize ?? wideSize };\n\t\t\t\t\t\tmargin-left: ${ marginLeft };\n\t\t\t\t\t\tmargin-right: ${ marginRight };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignwide' ) } {\n\t\t\t\t\t\tmax-width: ${ wideSize ?? contentSize };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmax-width: none;\n\t\t\t\t\t}\n\t\t\t\t`\n\t\t\t\t: '';\n\n\t\tif ( justifyContent === 'left' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-left: ${ marginLeft }; }`;\n\t\t} else if ( justifyContent === 'right' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-right: ${ marginRight }; }`;\n\t\t}\n\n\t\t// If there is custom padding, add negative margins for alignfull blocks.\n\t\tif ( style?.spacing?.padding ) {\n\t\t\t// The style object might be storing a preset so we need to make sure we get a usable value.\n\t\t\tconst paddingValues = getCSSRules( style );\n\t\t\tpaddingValues.forEach( ( rule ) => {\n\t\t\t\tif ( rule.key === 'paddingRight' ) {\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-right: calc(${ rule.value } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t} else if ( rule.key === 'paddingLeft' ) {\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-left: calc(${ rule.value } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'constrained',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\t\tconst { contentSize, wideSize } = layout;\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\tif ( contentSize ) {\n\t\t\talignments.unshift( { name: 'full' } );\n\t\t}\n\n\t\tif ( wideSize ) {\n\t\t\talignments.unshift( { name: 'wide', info: alignmentInfo.wide } );\n\t\t}\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAQA,IAAAG,YAAA,GAAAH,OAAA;AAKA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAAmD,IAAAS,WAAA,GAAAT,OAAA;AA3BnD;AACA;AACA;AAkBA;AACA;AACA;AAFA,IAAAU,QAAA,G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AQ,CAAE,MAAO,CAAC,EAAG;QAC7CrE,MAAM,CAACmE,UAAU,CAACG,OAAO,CAAE,MAAO,CAAC;MACpC;MACA,OAAOtE,MAAM,CAACmE,UAAU,CAACjC,GAAG,CAAIqC,SAAS,KAAQ;QAChD5E,IAAI,EAAE4E,SAAS;QACfC,IAAI,EAAEP,aAAa,CAAEM,SAAS;MAC/B,CAAC,CAAG,CAAC;IACN;IACA,MAAM;MAAEnE,WAAW;MAAED;IAAS,CAAC,GAAGH,MAAM;IAExC,MAAMmE,UAAU,GAAG,CAClB;MAAExE,IAAI,EAAE;IAAO,CAAC,EAChB;MAAEA,IAAI,EAAE;IAAS,CAAC,EAClB;MAAEA,IAAI,EAAE;IAAQ,CAAC,CACjB;IAED,IAAKS,WAAW,EAAG;MAClB+D,UAAU,CAACG,OAAO,CAAE;QAAE3E,IAAI,EAAE;MAAO,CAAE,CAAC;IACvC;IAEA,IAAKQ,QAAQ,EAAG;MACfgE,UAAU,CAACG,OAAO,CAAE;QAAE3E,IAAI,EAAE,MAAM;QAAE6E,IAAI,EAAEP,aAAa,CAACQ;MAAK,CAAE,CAAC;IACjE;IAEAN,UAAU,CAACG,OAAO,CAAE;MAAE3E,IAAI,EAAE,MAAM;MAAE6E,IAAI,EAAEP,aAAa,CAACS;IAAK,CAAE,CAAC;IAEhE,OAAOP,UAAU;EAClB;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_i18n","_icons","_styleEngine","_useSettings","_utils","_gap","_utils2","_definitions","_jsxRuntime","_default","exports","default","name","label","__","inspectorControls","DefaultLayoutInspectorControls","layout","onChange","layoutBlockSupport","wideSize","contentSize","justifyContent","allowJustification","allowCustomContentAndWideSize","onJustificationChange","value","justificationOptions","icon","justifyLeft","justifyCenter","justifyRight","availableUnits","useSettings","units","useCustomUnits","jsxs","Fragment","children","className","jsx","__experimentalUnitControl","labelPosition","__unstableInputWidth","nextWidth","parseFloat","Icon","positionCenter","stretchWide","__experimentalToggleGroupControl","__nextHasNoMarginBottom","map","__experimentalToggleGroupControlOptionIcon","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","LAYOUT_DEFINITIONS","blockGapStyleValue","getGapCSSValue","spacing","blockGap","blockGapValue","shouldSkipSerialization","top","marginLeft","marginRight","output","appendSelectors","padding","paddingValues","getCSSRules","forEach","rule","key","paddingRightValue","paddingLeftValue","getBlockGapCSS","getOrientation","getAlignments","alignmentInfo","getAlignmentsInfo","alignments","undefined","includes","unshift","alignment","info","wide","none"],"sources":["@wordpress/block-editor/src/layouts/constrained.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tIcon,\n\tpositionCenter,\n\tstretchWide,\n\tjustifyLeft,\n\tjustifyCenter,\n\tjustifyRight,\n} from '@wordpress/icons';\nimport { getCSSRules } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport { appendSelectors, getBlockGapCSS, getAlignmentsInfo } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\nimport { LAYOUT_DEFINITIONS } from './definitions';\n\nexport default {\n\tname: 'constrained',\n\tlabel: __( 'Constrained' ),\n\tinspectorControls: function DefaultLayoutInspectorControls( {\n\t\tlayout,\n\t\tonChange,\n\t\tlayoutBlockSupport = {},\n\t} ) {\n\t\tconst { wideSize, contentSize, justifyContent = 'center' } = layout;\n\t\tconst {\n\t\t\tallowJustification = true,\n\t\t\tallowCustomContentAndWideSize = true,\n\t\t} = layoutBlockSupport;\n\t\tconst onJustificationChange = ( value ) => {\n\t\t\tonChange( {\n\t\t\t\t...layout,\n\t\t\t\tjustifyContent: value,\n\t\t\t} );\n\t\t};\n\t\tconst justificationOptions = [\n\t\t\t{\n\t\t\t\tvalue: 'left',\n\t\t\t\ticon: justifyLeft,\n\t\t\t\tlabel: __( 'Justify items left' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'center',\n\t\t\t\ticon: justifyCenter,\n\t\t\t\tlabel: __( 'Justify items center' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: 'right',\n\t\t\t\ticon: justifyRight,\n\t\t\t\tlabel: __( 'Justify items right' ),\n\t\t\t},\n\t\t];\n\t\tconst [ availableUnits ] = useSettings( 'spacing.units' );\n\t\tconst units = useCustomUnits( {\n\t\t\tavailableUnits: availableUnits || [ '%', 'px', 'em', 'rem', 'vw' ],\n\t\t} );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ allowCustomContentAndWideSize && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls\">\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Content' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ contentSize || wideSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\tcontentSize: nextWidth,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ positionCenter } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__layout-controls-unit-input\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Wide' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ wideSize || contentSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\twideSize: nextWidth,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ stretchWide } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<p className=\"block-editor-hooks__layout-controls-helptext\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Customize the width for all elements that are assigned to the center or wide columns.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ allowJustification && (\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Justification' ) }\n\t\t\t\t\t\tvalue={ justifyContent }\n\t\t\t\t\t\tonChange={ onJustificationChange }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ justificationOptions.map(\n\t\t\t\t\t\t\t( { value, icon, label } ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\t\t\t\t\tkey={ value }\n\t\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tlayout = {},\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions = LAYOUT_DEFINITIONS,\n\t} ) {\n\t\tconst { contentSize, wideSize, justifyContent } = layout;\n\t\tconst blockGapStyleValue = getGapCSSValue( style?.spacing?.blockGap );\n\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tlet blockGapValue = '';\n\t\tif ( ! shouldSkipSerialization( blockName, 'spacing', 'blockGap' ) ) {\n\t\t\t// If an object is provided only use the 'top' value for this kind of gap.\n\t\t\tif ( blockGapStyleValue?.top ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue?.top );\n\t\t\t} else if ( typeof blockGapStyleValue === 'string' ) {\n\t\t\t\tblockGapValue = getGapCSSValue( blockGapStyleValue );\n\t\t\t}\n\t\t}\n\n\t\tconst marginLeft =\n\t\t\tjustifyContent === 'left' ? '0 !important' : 'auto !important';\n\t\tconst marginRight =\n\t\t\tjustifyContent === 'right' ? '0 !important' : 'auto !important';\n\n\t\tlet output =\n\t\t\t!! contentSize || !! wideSize\n\t\t\t\t? `\n\t\t\t\t\t${ appendSelectors(\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t\t\t) } {\n\t\t\t\t\t\tmax-width: ${ contentSize ?? wideSize };\n\t\t\t\t\t\tmargin-left: ${ marginLeft };\n\t\t\t\t\t\tmargin-right: ${ marginRight };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignwide' ) } {\n\t\t\t\t\t\tmax-width: ${ wideSize ?? contentSize };\n\t\t\t\t\t}\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmax-width: none;\n\t\t\t\t\t}\n\t\t\t\t`\n\t\t\t\t: '';\n\n\t\tif ( justifyContent === 'left' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-left: ${ marginLeft }; }`;\n\t\t} else if ( justifyContent === 'right' ) {\n\t\t\toutput += `${ appendSelectors(\n\t\t\t\tselector,\n\t\t\t\t'> :where(:not(.alignleft):not(.alignright):not(.alignfull))'\n\t\t\t) }\n\t\t\t{ margin-right: ${ marginRight }; }`;\n\t\t}\n\n\t\t// If there is custom padding, add negative margins for alignfull blocks.\n\t\tif ( style?.spacing?.padding ) {\n\t\t\t// The style object might be storing a preset so we need to make sure we get a usable value.\n\t\t\tconst paddingValues = getCSSRules( style );\n\t\t\tpaddingValues.forEach( ( rule ) => {\n\t\t\t\tif ( rule.key === 'paddingRight' ) {\n\t\t\t\t\t// Add unit if 0, to avoid calc(0 * -1) which is invalid.\n\t\t\t\t\tconst paddingRightValue =\n\t\t\t\t\t\trule.value === '0' ? '0px' : rule.value;\n\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-right: calc(${ paddingRightValue } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t} else if ( rule.key === 'paddingLeft' ) {\n\t\t\t\t\t// Add unit if 0, to avoid calc(0 * -1) which is invalid.\n\t\t\t\t\tconst paddingLeftValue =\n\t\t\t\t\t\trule.value === '0' ? '0px' : rule.value;\n\n\t\t\t\t\toutput += `\n\t\t\t\t\t${ appendSelectors( selector, '> .alignfull' ) } {\n\t\t\t\t\t\tmargin-left: calc(${ paddingLeftValue } * -1);\n\t\t\t\t\t}\n\t\t\t\t\t`;\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'constrained',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\t\tconst { contentSize, wideSize } = layout;\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\tif ( contentSize ) {\n\t\t\talignments.unshift( { name: 'full' } );\n\t\t}\n\n\t\tif ( wideSize ) {\n\t\t\talignments.unshift( { name: 'wide', info: alignmentInfo.wide } );\n\t\t}\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAQA,IAAAG,YAAA,GAAAH,OAAA;AAKA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,IAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAAmD,IAAAS,WAAA,GAAAT,OAAA;AA3BnD;AACA;AACA;AAkBA;AACA;AACA;AAFA,IAAAU,QAAA,GAAAC,OAAA,CAAAC,OAAA,GASe;EACdC,IAAI,EAAE,aAAa;EACnBC,KAAK,EAAE,IAAAC,QAAE,EAAE,aAAc,CAAC;EAC1BC,iBAAiB,EAAE,SAASC,8BAA8BA,CAAE;IAC3DC,MAAM;IACNC,QAAQ;IACRC,kBAAkB,GAAG,CAAC;EACvB,CAAC,EAAG;IACH,MAAM;MAAEC,QAAQ;MAAEC,WAAW;MAAEC,cAAc,GAAG;IAAS,CAAC,GAAGL,MAAM;IACnE,MAAM;MACLM,kBAAkB,GAAG,IAAI;MACzBC,6BAA6B,GAAG;IACjC,CAAC,GAAGL,kBAAkB;IACtB,MAAMM,qBAAqB,GAAKC,KAAK,IAAM;MAC1CR,QAAQ,CAAE;QACT,GAAGD,MAAM;QACTK,cAAc,EAAEI;MACjB,CAAE,CAAC;IACJ,CAAC;IACD,MAAMC,oBAAoB,GAAG,CAC5B;MACCD,KAAK,EAAE,MAAM;MACbE,IAAI,EAAEC,kBAAW;MACjBhB,KAAK,EAAE,IAAAC,QAAE,EAAE,oBAAqB;IACjC,CAAC,EACD;MACCY,KAAK,EAAE,QAAQ;MACfE,IAAI,EAAEE,oBAAa;MACnBjB,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,CAAE,CAAC;IACvC;IAEA,IAAKQ,QAAQ,EAAG;MACfkE,UAAU,CAACG,OAAO,CAAE;QAAE7E,IAAI,EAAE,MAAM;QAAE+E,IAAI,EAAEP,aAAa,CAACQ;MAAK,CAAE,CAAC;IACjE;IAEAN,UAAU,CAACG,OAAO,CAAE;MAAE7E,IAAI,EAAE,MAAM;MAAE+E,IAAI,EAAEP,aAAa,CAACS;IAAK,CAAE,CAAC;IAEhE,OAAOP,UAAU;EAClB;AACD,CAAC","ignoreList":[]}
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useContext, useMemo, useRef } from '@wordpress/element';
5
- import { useRefEffect, useObservableValue } from '@wordpress/compose';
4
+ import { useContext, useMemo, useRef, useState, useLayoutEffect } from '@wordpress/element';
5
+ import { useRefEffect } from '@wordpress/compose';
6
6
 
7
7
  /**
8
8
  * Internal dependencies
@@ -65,11 +65,18 @@ function useBlockRef(clientId) {
65
65
  * @return {Element|null} The block's wrapper element.
66
66
  */
67
67
  function useBlockElement(clientId) {
68
- var _useObservableValue;
69
68
  const {
70
69
  refsMap
71
70
  } = useContext(BlockRefs);
72
- return (_useObservableValue = useObservableValue(refsMap, clientId)) !== null && _useObservableValue !== void 0 ? _useObservableValue : null;
71
+ const [blockElement, setBlockElement] = useState(null);
72
+ // Delay setting the resulting `blockElement` until an effect. If the block element
73
+ // changes (i.e., the block is unmounted and re-mounted), this allows enough time
74
+ // for the ref callbacks to clean up the old element and set the new one.
75
+ useLayoutEffect(() => {
76
+ setBlockElement(refsMap.get(clientId));
77
+ return refsMap.subscribe(clientId, () => setBlockElement(refsMap.get(clientId)));
78
+ }, [refsMap, clientId]);
79
+ return blockElement;
73
80
  }
74
81
  export { useBlockRef as __unstableUseBlockRef };
75
82
  export { useBlockElement as __unstableUseBlockElement };
@@ -1 +1 @@
1
- {"version":3,"names":["useContext","useMemo","useRef","useRefEffect","useObservableValue","BlockRefs","useBlockRefProvider","clientId","refsMap","element","set","delete","useBlockRef","latestClientId","current","_refsMap$get","get","useBlockElement","_useObservableValue","__unstableUseBlockRef","__unstableUseBlockElement"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-block-refs.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useMemo, useRef } from '@wordpress/element';\nimport { useRefEffect, useObservableValue } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { BlockRefs } from '../../provider/block-refs-provider';\n\n/** @typedef {import('@wordpress/element').RefCallback} RefCallback */\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * Provides a ref to the BlockRefs context.\n *\n * @param {string} clientId The client ID of the element ref.\n *\n * @return {RefCallback} Ref callback.\n */\nexport function useBlockRefProvider( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\trefsMap.set( clientId, element );\n\t\t\treturn () => refsMap.delete( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n\n/**\n * Gets a ref pointing to the current block element. Continues to return the same\n * stable ref object even if the `clientId` argument changes. This hook is not\n * reactive, i.e., it won't trigger a rerender of the calling component if the\n * ref value changes. For reactive use cases there is the `useBlockElement` hook.\n *\n * @param {string} clientId The client ID to get a ref for.\n *\n * @return {RefObject} A ref containing the element.\n */\nfunction useBlockRef( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\tconst latestClientId = useRef();\n\tlatestClientId.current = clientId;\n\n\t// Always return an object, even if no ref exists for a given client ID, so\n\t// that `current` works at a later point.\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tget current() {\n\t\t\t\treturn refsMap.get( latestClientId.current ) ?? null;\n\t\t\t},\n\t\t} ),\n\t\t[ refsMap ]\n\t);\n}\n\n/**\n * Return the element for a given client ID. Updates whenever the element\n * changes, becomes available, or disappears.\n *\n * @param {string} clientId The client ID to an element for.\n *\n * @return {Element|null} The block's wrapper element.\n */\nfunction useBlockElement( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\treturn useObservableValue( refsMap, clientId ) ?? null;\n}\n\nexport { useBlockRef as __unstableUseBlockRef };\nexport { useBlockElement as __unstableUseBlockElement };\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,OAAO,EAAEC,MAAM,QAAQ,oBAAoB;AAChE,SAASC,YAAY,EAAEC,kBAAkB,QAAQ,oBAAoB;;AAErE;AACA;AACA;AACA,SAASC,SAAS,QAAQ,oCAAoC;;AAE9D;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAEC,QAAQ,EAAG;EAC/C,MAAM;IAAEC;EAAQ,CAAC,GAAGR,UAAU,CAAEK,SAAU,CAAC;EAC3C,OAAOF,YAAY,CAChBM,OAAO,IAAM;IACdD,OAAO,CAACE,GAAG,CAAEH,QAAQ,EAAEE,OAAQ,CAAC;IAChC,OAAO,MAAMD,OAAO,CAACG,MAAM,CAAEJ,QAAS,CAAC;EACxC,CAAC,EACD,CAAEA,QAAQ,CACX,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,WAAWA,CAAEL,QAAQ,EAAG;EAChC,MAAM;IAAEC;EAAQ,CAAC,GAAGR,UAAU,CAAEK,SAAU,CAAC;EAC3C,MAAMQ,cAAc,GAAGX,MAAM,CAAC,CAAC;EAC/BW,cAAc,CAACC,OAAO,GAAGP,QAAQ;;EAEjC;EACA;EACA,OAAON,OAAO,CACb,OAAQ;IACP,IAAIa,OAAOA,CAAA,EAAG;MAAA,IAAAC,YAAA;MACb,QAAAA,YAAA,GAAOP,OAAO,CAACQ,GAAG,CAAEH,cAAc,CAACC,OAAQ,CAAC,cAAAC,YAAA,cAAAA,YAAA,GAAI,IAAI;IACrD;EACD,CAAC,CAAE,EACH,CAAEP,OAAO,CACV,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASS,eAAeA,CAAEV,QAAQ,EAAG;EAAA,IAAAW,mBAAA;EACpC,MAAM;IAAEV;EAAQ,CAAC,GAAGR,UAAU,CAAEK,SAAU,CAAC;EAC3C,QAAAa,mBAAA,GAAOd,kBAAkB,CAAEI,OAAO,EAAED,QAAS,CAAC,cAAAW,mBAAA,cAAAA,mBAAA,GAAI,IAAI;AACvD;AAEA,SAASN,WAAW,IAAIO,qBAAqB;AAC7C,SAASF,eAAe,IAAIG,yBAAyB","ignoreList":[]}
1
+ {"version":3,"names":["useContext","useMemo","useRef","useState","useLayoutEffect","useRefEffect","BlockRefs","useBlockRefProvider","clientId","refsMap","element","set","delete","useBlockRef","latestClientId","current","_refsMap$get","get","useBlockElement","blockElement","setBlockElement","subscribe","__unstableUseBlockRef","__unstableUseBlockElement"],"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-block-refs.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseContext,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { BlockRefs } from '../../provider/block-refs-provider';\n\n/** @typedef {import('@wordpress/element').RefCallback} RefCallback */\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * Provides a ref to the BlockRefs context.\n *\n * @param {string} clientId The client ID of the element ref.\n *\n * @return {RefCallback} Ref callback.\n */\nexport function useBlockRefProvider( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\trefsMap.set( clientId, element );\n\t\t\treturn () => refsMap.delete( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n\n/**\n * Gets a ref pointing to the current block element. Continues to return the same\n * stable ref object even if the `clientId` argument changes. This hook is not\n * reactive, i.e., it won't trigger a rerender of the calling component if the\n * ref value changes. For reactive use cases there is the `useBlockElement` hook.\n *\n * @param {string} clientId The client ID to get a ref for.\n *\n * @return {RefObject} A ref containing the element.\n */\nfunction useBlockRef( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\tconst latestClientId = useRef();\n\tlatestClientId.current = clientId;\n\n\t// Always return an object, even if no ref exists for a given client ID, so\n\t// that `current` works at a later point.\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tget current() {\n\t\t\t\treturn refsMap.get( latestClientId.current ) ?? null;\n\t\t\t},\n\t\t} ),\n\t\t[ refsMap ]\n\t);\n}\n\n/**\n * Return the element for a given client ID. Updates whenever the element\n * changes, becomes available, or disappears.\n *\n * @param {string} clientId The client ID to an element for.\n *\n * @return {Element|null} The block's wrapper element.\n */\nfunction useBlockElement( clientId ) {\n\tconst { refsMap } = useContext( BlockRefs );\n\tconst [ blockElement, setBlockElement ] = useState( null );\n\t// Delay setting the resulting `blockElement` until an effect. If the block element\n\t// changes (i.e., the block is unmounted and re-mounted), this allows enough time\n\t// for the ref callbacks to clean up the old element and set the new one.\n\tuseLayoutEffect( () => {\n\t\tsetBlockElement( refsMap.get( clientId ) );\n\t\treturn refsMap.subscribe( clientId, () =>\n\t\t\tsetBlockElement( refsMap.get( clientId ) )\n\t\t);\n\t}, [ refsMap, clientId ] );\n\treturn blockElement;\n}\n\nexport { useBlockRef as __unstableUseBlockRef };\nexport { useBlockElement as __unstableUseBlockElement };\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,UAAU,EACVC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,eAAe,QACT,oBAAoB;AAC3B,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,SAAS,QAAQ,oCAAoC;;AAE9D;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAEC,QAAQ,EAAG;EAC/C,MAAM;IAAEC;EAAQ,CAAC,GAAGT,UAAU,CAAEM,SAAU,CAAC;EAC3C,OAAOD,YAAY,CAChBK,OAAO,IAAM;IACdD,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qB;AAC7C,SAASJ,eAAe,IAAIK,yBAAyB","ignoreList":[]}
@@ -64,7 +64,7 @@ export default function Shuffle({
64
64
  );
65
65
  });
66
66
  }, [categories, patterns]);
67
- if (sameCategoryPatternsWithSingleWrapper.length === 0) {
67
+ if (sameCategoryPatternsWithSingleWrapper.length < 2) {
68
68
  return null;
69
69
  }
70
70
  function getNextPattern() {
@@ -1 +1 @@
1
- {"version":3,"names":["shuffle","ToolbarButton","ToolbarGroup","__","useMemo","useSelect","useDispatch","store","blockEditorStore","jsx","_jsx","EMPTY_ARRAY","Container","props","children","Shuffle","clientId","as","categories","patterns","patternName","select","getBlockAttributes","getBlockRootClientId","__experimentalGetAllowedPatterns","attributes","_categories","metadata","_patternName","rootBlock","_patterns","replaceBlocks","sameCategoryPatternsWithSingleWrapper","length","filter","pattern","blocks","some","category","includes","syncStatus","id","getNextPattern","numberOfPatterns","patternIndex","findIndex","name","nextPatternIndex","ComponentToUse","label","icon","onClick","nextPattern"],"sources":["@wordpress/block-editor/src/components/block-toolbar/shuffle.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { shuffle } from '@wordpress/icons';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nfunction Container( props ) {\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton { ...props } />\n\t\t</ToolbarGroup>\n\t);\n}\n\nexport default function Shuffle( { clientId, as = Container } ) {\n\tconst { categories, patterns, patternName } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetAllowedPatterns,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst _categories = attributes?.metadata?.categories || EMPTY_ARRAY;\n\t\t\tconst _patternName = attributes?.metadata?.patternName;\n\t\t\tconst rootBlock = getBlockRootClientId( clientId );\n\t\t\tconst _patterns = __experimentalGetAllowedPatterns( rootBlock );\n\t\t\treturn {\n\t\t\t\tcategories: _categories,\n\t\t\t\tpatterns: _patterns,\n\t\t\t\tpatternName: _patternName,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst sameCategoryPatternsWithSingleWrapper = useMemo( () => {\n\t\tif (\n\t\t\t! categories ||\n\t\t\tcategories.length === 0 ||\n\t\t\t! patterns ||\n\t\t\tpatterns.length === 0\n\t\t) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn patterns.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t// Check if the pattern has only one top level block,\n\t\t\t\t// otherwise we may shuffle to pattern that will not allow to continue shuffling.\n\t\t\t\tpattern.blocks.length === 1 &&\n\t\t\t\tpattern.categories?.some( ( category ) => {\n\t\t\t\t\treturn categories.includes( category );\n\t\t\t\t} ) &&\n\t\t\t\t// Check if the pattern is not a synced pattern.\n\t\t\t\t( pattern.syncStatus === 'unsynced' || ! pattern.id )\n\t\t\t);\n\t\t} );\n\t}, [ categories, patterns ] );\n\tif ( sameCategoryPatternsWithSingleWrapper.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tfunction getNextPattern() {\n\t\tconst numberOfPatterns = sameCategoryPatternsWithSingleWrapper.length;\n\t\tconst patternIndex = sameCategoryPatternsWithSingleWrapper.findIndex(\n\t\t\t( { name } ) => name === patternName\n\t\t);\n\t\tconst nextPatternIndex =\n\t\t\tpatternIndex + 1 < numberOfPatterns ? patternIndex + 1 : 0;\n\t\treturn sameCategoryPatternsWithSingleWrapper[ nextPatternIndex ];\n\t}\n\n\tconst ComponentToUse = as;\n\treturn (\n\t\t<ComponentToUse\n\t\t\tlabel={ __( 'Shuffle' ) }\n\t\t\ticon={ shuffle }\n\t\t\tonClick={ () => {\n\t\t\t\tconst nextPattern = getNextPattern();\n\t\t\t\tnextPattern.blocks[ 0 ].attributes = {\n\t\t\t\t\t...nextPattern.blocks[ 0 ].attributes,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...nextPattern.blocks[ 0 ].attributes.metadata,\n\t\t\t\t\t\tcategories,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treplaceBlocks( clientId, nextPattern.blocks );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,aAAa,EAAEC,YAAY,QAAQ,uBAAuB;AACnE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExD,MAAMC,WAAW,GAAG,EAAE;AAEtB,SAASC,SAASA,CAAEC,KAAK,EAAG;EAC3B,oBACCH,IAAA,CAACR,YAAY;IAAAY,QAAA,eACZJ,IAAA,CAACT,aAAa;MAAA,GAAMY;IAAK,CAAI;EAAC,CACjB,CAAC;AAEjB;AAEA,eAAe,SAASE,OAAOA,CAAE;EAAEC,QAAQ;EAAEC,EAAE,GAAGL;AAAU,CAAC,EAAG;EAC/D,MAAM;IAAEM,UAAU;IAAEC,QAAQ;IAAEC;EAAY,CAAC,GAAGf,SAAS,CACpDgB,MAAM,IAAM;IACb,MAAM;MACLC,kBAAkB;MAClBC,oBAAoB;MACpBC;IACD,CAAC,GAAGH,MAAM,CAAEb,gBAAiB,CAAC;IAC9B,MAAMiB,UAAU,GAAGH,kBAAkB,CAAEN,QAAS,CAAC;IACjD,MAAMU,WAAW,GAAGD,UAAU,EAAEE,QAAQ,EAAET,UA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AAC,KAAMA,IAAI,KAAK1B,WAC1B,CAAC;IACD,MAAM2B,gBAAgB,GACrBH,YAAY,GAAG,CAAC,GAAGD,gBAAgB,GAAGC,YAAY,GAAG,CAAC,GAAG,CAAC;IAC3D,OAAOZ,qCAAqC,CAAEe,gBAAgB,CAAE;EACjE;EAEA,MAAMC,cAAc,GAAG/B,EAAE;EACzB,oBACCP,IAAA,CAACsC,cAAc;IACdC,KAAK,EAAG9C,EAAE,CAAE,SAAU,CAAG;IACzB+C,IAAI,EAAGlD,OAAS;IAChBmD,OAAO,EAAGA,CAAA,KAAM;MACf,MAAMC,WAAW,GAAGV,cAAc,CAAC,CAAC;MACpCU,WAAW,CAAChB,MAAM,CAAE,CAAC,CAAE,CAACX,UAAU,GAAG;QACpC,GAAG2B,WAAW,CAAChB,MAAM,CAAE,CAAC,CAAE,CAACX,UAAU;QACrCE,QAAQ,EAAE;UACT,GAAGyB,WAAW,CAAChB,MAAM,CAAE,CAAC,CAAE,CAACX,UAAU,CAACE,QAAQ;UAC9CT;QACD;MACD,CAAC;MACDa,aAAa,CAAEf,QAAQ,EAAEoC,WAAW,CAAChB,MAAO,CAAC;IAC9C;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"names":["shuffle","ToolbarButton","ToolbarGroup","__","useMemo","useSelect","useDispatch","store","blockEditorStore","jsx","_jsx","EMPTY_ARRAY","Container","props","children","Shuffle","clientId","as","categories","patterns","patternName","select","getBlockAttributes","getBlockRootClientId","__experimentalGetAllowedPatterns","attributes","_categories","metadata","_patternName","rootBlock","_patterns","replaceBlocks","sameCategoryPatternsWithSingleWrapper","length","filter","pattern","blocks","some","category","includes","syncStatus","id","getNextPattern","numberOfPatterns","patternIndex","findIndex","name","nextPatternIndex","ComponentToUse","label","icon","onClick","nextPattern"],"sources":["@wordpress/block-editor/src/components/block-toolbar/shuffle.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { shuffle } from '@wordpress/icons';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nfunction Container( props ) {\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton { ...props } />\n\t\t</ToolbarGroup>\n\t);\n}\n\nexport default function Shuffle( { clientId, as = Container } ) {\n\tconst { categories, patterns, patternName } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetAllowedPatterns,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst _categories = attributes?.metadata?.categories || EMPTY_ARRAY;\n\t\t\tconst _patternName = attributes?.metadata?.patternName;\n\t\t\tconst rootBlock = getBlockRootClientId( clientId );\n\t\t\tconst _patterns = __experimentalGetAllowedPatterns( rootBlock );\n\t\t\treturn {\n\t\t\t\tcategories: _categories,\n\t\t\t\tpatterns: _patterns,\n\t\t\t\tpatternName: _patternName,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst sameCategoryPatternsWithSingleWrapper = useMemo( () => {\n\t\tif (\n\t\t\t! categories ||\n\t\t\tcategories.length === 0 ||\n\t\t\t! patterns ||\n\t\t\tpatterns.length === 0\n\t\t) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\treturn patterns.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t// Check if the pattern has only one top level block,\n\t\t\t\t// otherwise we may shuffle to pattern that will not allow to continue shuffling.\n\t\t\t\tpattern.blocks.length === 1 &&\n\t\t\t\tpattern.categories?.some( ( category ) => {\n\t\t\t\t\treturn categories.includes( category );\n\t\t\t\t} ) &&\n\t\t\t\t// Check if the pattern is not a synced pattern.\n\t\t\t\t( pattern.syncStatus === 'unsynced' || ! pattern.id )\n\t\t\t);\n\t\t} );\n\t}, [ categories, patterns ] );\n\n\tif ( sameCategoryPatternsWithSingleWrapper.length < 2 ) {\n\t\treturn null;\n\t}\n\n\tfunction getNextPattern() {\n\t\tconst numberOfPatterns = sameCategoryPatternsWithSingleWrapper.length;\n\t\tconst patternIndex = sameCategoryPatternsWithSingleWrapper.findIndex(\n\t\t\t( { name } ) => name === patternName\n\t\t);\n\t\tconst nextPatternIndex =\n\t\t\tpatternIndex + 1 < numberOfPatterns ? patternIndex + 1 : 0;\n\t\treturn sameCategoryPatternsWithSingleWrapper[ nextPatternIndex ];\n\t}\n\n\tconst ComponentToUse = as;\n\treturn (\n\t\t<ComponentToUse\n\t\t\tlabel={ __( 'Shuffle' ) }\n\t\t\ticon={ shuffle }\n\t\t\tonClick={ () => {\n\t\t\t\tconst nextPattern = getNextPattern();\n\t\t\t\tnextPattern.blocks[ 0 ].attributes = {\n\t\t\t\t\t...nextPattern.blocks[ 0 ].attributes,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...nextPattern.blocks[ 0 ].attributes.metadata,\n\t\t\t\t\t\tcategories,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treplaceBlocks( clientId, nextPattern.blocks );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,aAAa,EAAEC,YAAY,QAAQ,uBAAuB;AACnE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAExD,MAAMC,WAAW,GAAG,EAAE;AAEtB,SAASC,SAASA,CAAEC,KAAK,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;EAAG,CACH,CAAC;AAEJ","ignoreList":[]}
@@ -25,9 +25,13 @@ const EMPTY_CONFIG = {
25
25
  const VALID_SETTINGS = ['appearanceTools', 'useRootPaddingAwareAlignments', 'background.backgroundImage', 'background.backgroundRepeat', 'background.backgroundSize', 'background.backgroundPosition', 'border.color', 'border.radius', 'border.style', 'border.width', 'shadow.presets', 'shadow.defaultPresets', 'color.background', 'color.button', 'color.caption', 'color.custom', 'color.customDuotone', 'color.customGradient', 'color.defaultDuotone', 'color.defaultGradients', 'color.defaultPalette', 'color.duotone', 'color.gradients', 'color.heading', 'color.link', 'color.palette', 'color.text', 'custom', 'dimensions.aspectRatio', 'dimensions.minHeight', 'layout.contentSize', 'layout.definitions', 'layout.wideSize', 'lightbox.enabled', 'lightbox.allowEditing', 'position.fixed', 'position.sticky', 'spacing.customSpacingSize', 'spacing.defaultSpacingSizes', 'spacing.spacingSizes', 'spacing.spacingScale', 'spacing.blockGap', 'spacing.margin', 'spacing.padding', 'spacing.units', 'typography.fluid', 'typography.customFontSize', 'typography.defaultFontSizes', 'typography.dropCap', 'typography.fontFamilies', 'typography.fontSizes', 'typography.fontStyle', 'typography.fontWeight', 'typography.letterSpacing', 'typography.lineHeight', 'typography.textAlign', 'typography.textColumns', 'typography.textDecoration', 'typography.textTransform', 'typography.writingMode'];
26
26
  export const useGlobalStylesReset = () => {
27
27
  const {
28
- user: config,
28
+ user,
29
29
  setUserConfig
30
30
  } = useContext(GlobalStylesContext);
31
+ const config = {
32
+ settings: user.settings,
33
+ styles: user.styles
34
+ };
31
35
  const canReset = !!config && !fastDeepEqual(config, EMPTY_CONFIG);
32
36
  return [canReset, useCallback(() => setUserConfig(EMPTY_CONFIG), [setUserConfig])];
33
37
  };
@@ -1 +1 @@
1
- {"version":3,"names":["fastDeepEqual","useContext","useCallback","useMemo","useSelect","store","blocksStore","_x","getValueFromVariable","getPresetVariableFromValue","getValueFromObjectPath","setImmutably","GlobalStylesContext","unlock","EMPTY_CONFIG","settings","styles","VALID_SETTINGS","useGlobalStylesReset","user","config","setUserConfig","canReset","useGlobalSetting","propertyPath","blockName","source","configs","appendedBlockPath","appendedPropertyPath","contextualPath","globalPath","sourceKey","settingValue","configToUse","_getValueFromObjectPa","result","forEach","setting","_getValueFromObjectPa2","value","undefined","split","setSetting","newValue","currentConfig","useGlobalStyle","path","shouldDecodeEncode","merged","mergedConfig","base","baseConfig","userConfig","appendedPath","finalPath","setStyle","rawResult","useGlobalStyleLinks","_links","useSettingsForBlockElement","parentSettings","element","supportedStyles","supports","select","getSupportedStyles","getBlockType","updatedSettings","includes","typography","fontSizes","customFontSize","defaultFontSizes","fontFamilies","color","text","background","button","heading","link","caption","gradients","customGradient","defaultDuotone","customDuotone","key","textColumns","layout","spacing","sides","Array","isArray","length","dimensions","charAt","toUpperCase","slice","border","shadow","textAlign","useColorsPerOrigin","customColors","palette","custom","themeColors","theme","defaultColors","default","shouldDisplayDefaultColors","defaultPalette","push","name","colors","useGradientsPerOrigin","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients"],"sources":["@wordpress/block-editor/src/components/global-styles/hooks.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { getValueFromObjectPath, setImmutably } from '../../utils/object';\nimport { GlobalStylesContext } from './context';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'background.backgroundImage',\n\t'background.backgroundRepeat',\n\t'background.backgroundSize',\n\t'background.backgroundPosition',\n\t'border.color',\n\t'border.radius',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.button',\n\t'color.caption',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.heading',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.aspectRatio',\n\t'dimensions.minHeight',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'lightbox.enabled',\n\t'lightbox.allowEditing',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.defaultSpacingSizes',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.defaultFontSizes',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textAlign',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textTransform',\n\t'typography.writingMode',\n];\n\nexport const useGlobalStylesReset = () => {\n\tconst { user: config, setUserConfig } = useContext( GlobalStylesContext );\n\tconst canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback( () => setUserConfig( EMPTY_CONFIG ), [ setUserConfig ] ),\n\t];\n};\n\nexport function useGlobalSetting( propertyPath, blockName, source = 'all' ) {\n\tconst { setUserConfig, ...configs } = useContext( GlobalStylesContext );\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = propertyPath ? '.' + propertyPath : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\tconst sourceKey = source === 'all' ? 'merged' : source;\n\n\tconst settingValue = useMemo( () => {\n\t\tconst configToUse = configs[ sourceKey ];\n\t\tif ( ! configToUse ) {\n\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\tif ( propertyPath ) {\n\t\t\treturn (\n\t\t\t\tgetValueFromObjectPath( configToUse, contextualPath ) ??\n\t\t\t\tgetValueFromObjectPath( configToUse, globalPath )\n\t\t\t);\n\t\t}\n\n\t\tlet result = {};\n\t\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\t\tconst value =\n\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\tconfigToUse,\n\t\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t\t) ??\n\t\t\t\tgetValueFromObjectPath( configToUse, `settings.${ setting }` );\n\t\t\tif ( value !== undefined ) {\n\t\t\t\tresult = setImmutably( result, setting.split( '.' ), value );\n\t\t\t}\n\t\t} );\n\t\treturn result;\n\t}, [\n\t\tconfigs,\n\t\tsourceKey,\n\t\tpropertyPath,\n\t\tcontextualPath,\n\t\tglobalPath,\n\t\tappendedBlockPath,\n\t] );\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) =>\n\t\t\tsetImmutably( currentConfig, contextualPath.split( '.' ), newValue )\n\t\t);\n\t};\n\treturn [ settingValue, setSetting ];\n}\n\nexport function useGlobalStyle(\n\tpath,\n\tblockName,\n\tsource = 'all',\n\t{ shouldDecodeEncode = true } = {}\n) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst appendedPath = path ? '.' + path : '';\n\tconst finalPath = ! blockName\n\t\t? `styles${ appendedPath }`\n\t\t: `styles.blocks.${ blockName }${ appendedPath }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) =>\n\t\t\tsetImmutably(\n\t\t\t\tcurrentConfig,\n\t\t\t\tfinalPath.split( '.' ),\n\t\t\t\tshouldDecodeEncode\n\t\t\t\t\t? getPresetVariableFromValue(\n\t\t\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tnewValue\n\t\t\t\t\t )\n\t\t\t\t\t: newValue\n\t\t\t)\n\t\t);\n\t};\n\n\tlet rawResult, result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\trawResult = getValueFromObjectPath( mergedConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\trawResult = getValueFromObjectPath( userConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\trawResult = getValueFromObjectPath( baseConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( baseConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\nexport function useGlobalStyleLinks() {\n\tconst { merged: mergedConfig } = useContext( GlobalStylesContext );\n\treturn mergedConfig?._links;\n}\n\n/**\n * React hook that overrides a global settings object with block and element specific settings.\n *\n * @param {Object} parentSettings Settings object.\n * @param {blockName?} blockName Block name.\n * @param {element?} element Element name.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function useSettingsForBlockElement(\n\tparentSettings,\n\tblockName,\n\telement\n) {\n\tconst { supportedStyles, supports } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedStyles: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( blockName, element ),\n\t\t\t\tsupports:\n\t\t\t\t\tselect( blocksStore ).getBlockType( blockName )?.supports,\n\t\t\t};\n\t\t},\n\t\t[ blockName, element ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst updatedSettings = { ...parentSettings };\n\n\t\tif ( ! supportedStyles.includes( 'fontSize' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontSizes: {},\n\t\t\t\tcustomFontSize: false,\n\t\t\t\tdefaultFontSizes: false,\n\t\t\t};\n\t\t}\n\n\t\tif ( ! supportedStyles.includes( 'fontFamily' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontFamilies: {},\n\t\t\t};\n\t\t}\n\n\t\tupdatedSettings.color = {\n\t\t\t...updatedSettings.color,\n\t\t\ttext:\n\t\t\t\tupdatedSettings.color?.text &&\n\t\t\t\tsupportedStyles.includes( 'color' ),\n\t\t\tbackground:\n\t\t\t\tupdatedSettings.color?.background &&\n\t\t\t\t( supportedStyles.includes( 'background' ) ||\n\t\t\t\t\tsupportedStyles.includes( 'backgroundColor' ) ),\n\t\t\tbutton:\n\t\t\t\tupdatedSettings.color?.button &&\n\t\t\t\tsupportedStyles.includes( 'buttonColor' ),\n\t\t\theading:\n\t\t\t\tupdatedSettings.color?.heading &&\n\t\t\t\tsupportedStyles.includes( 'headingColor' ),\n\t\t\tlink:\n\t\t\t\tupdatedSettings.color?.link &&\n\t\t\t\tsupportedStyles.includes( 'linkColor' ),\n\t\t\tcaption:\n\t\t\t\tupdatedSettings.color?.caption &&\n\t\t\t\tsupportedStyles.includes( 'captionColor' ),\n\t\t};\n\n\t\t// Some blocks can enable background colors but disable gradients.\n\t\tif ( ! supportedStyles.includes( 'background' ) ) {\n\t\t\tupdatedSettings.color.gradients = [];\n\t\t\tupdatedSettings.color.customGradient = false;\n\t\t}\n\n\t\t// If filters are not supported by the block/element, disable duotone.\n\t\tif ( ! supportedStyles.includes( 'filter' ) ) {\n\t\t\tupdatedSettings.color.defaultDuotone = false;\n\t\t\tupdatedSettings.color.customDuotone = false;\n\t\t}\n\n\t\t[\n\t\t\t'lineHeight',\n\t\t\t'fontStyle',\n\t\t\t'fontWeight',\n\t\t\t'letterSpacing',\n\t\t\t'textAlign',\n\t\t\t'textTransform',\n\t\t\t'textDecoration',\n\t\t\t'writingMode',\n\t\t].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.typography = {\n\t\t\t\t\t...updatedSettings.typography,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// The column-count style is named text column to reduce confusion with\n\t\t// the columns block and manage expectations from the support.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/33587\n\t\tif ( ! supportedStyles.includes( 'columnCount' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextColumns: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'contentSize', 'wideSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.layout = {\n\t\t\t\t\t...updatedSettings.layout,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst sides = Array.isArray( supports?.spacing?.[ key ] )\n\t\t\t\t? supports?.spacing?.[ key ]\n\t\t\t\t: supports?.spacing?.[ key ]?.sides;\n\t\t\t// Check if spacing type is supported before adding sides.\n\t\t\tif ( sides?.length && updatedSettings.spacing?.[ key ] ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: {\n\t\t\t\t\t\t...updatedSettings.spacing?.[ key ],\n\t\t\t\t\t\tsides,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'aspectRatio', 'minHeight' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.dimensions = {\n\t\t\t\t\t...updatedSettings.dimensions,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {\n\t\t\tif (\n\t\t\t\t! supportedStyles.includes(\n\t\t\t\t\t'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedSettings.border = {\n\t\t\t\t\t...updatedSettings.border,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tupdatedSettings.shadow = supportedStyles.includes( 'shadow' )\n\t\t\t? updatedSettings.shadow\n\t\t\t: false;\n\n\t\t// Text alignment is only available for blocks.\n\t\tif ( element ) {\n\t\t\tupdatedSettings.typography.textAlign = false;\n\t\t}\n\n\t\treturn updatedSettings;\n\t}, [ parentSettings, supportedStyles, supports, element ] );\n}\n\nexport function useColorsPerOrigin( settings ) {\n\tconst customColors = settings?.color?.palette?.custom;\n\tconst themeColors = settings?.color?.palette?.theme;\n\tconst defaultColors = settings?.color?.palette?.default;\n\tconst shouldDisplayDefaultColors = settings?.color?.defaultPalette;\n\n\treturn 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 is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n}\n\nexport function useGradientsPerOrigin( settings ) {\n\tconst customGradients = settings?.color?.gradients?.custom;\n\tconst themeGradients = settings?.color?.gradients?.theme;\n\tconst defaultGradients = settings?.color?.gradients?.default;\n\tconst shouldDisplayDefaultGradients = settings?.color?.defaultGradients;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;;AAE/C;AACA;AACA;AACA,SAASC,UAAU,EAAEC,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACrE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,oBAAoB,EAAEC,0BAA0B,QAAQ,SAAS;AAC1E,SAASC,sBAAsB,EAAEC,YAAY,QAAQ,oBAAoB;AACzE,SAASC,mBAAmB,QAAQ,WAAW;AAC/C,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAMC,YAAY,GAAG;EAAEC,QAAQ,EAAE,CAAC,CAAC;EAAEC,MAAM,EAAE,CAAC;AAAE,CAAC;AAEjD,MAAMC,cAAc,GAAG,CACtB,iBAAiB,EACjB,+BAA+B,EAC/B,4BAA4B,EAC5B,6BAA6B,EAC7B,2BAA2B,EAC3B,+BAA+B,EAC/B,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,EACjB,2BAA2B,EAC3B,6BAA6B,EAC7B,s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K,EAAEO,SAAS,EAAE0B,OAAO;EAC5D,MAAMU,6BAA6B,GAAGvG,QAAQ,EAAE4D,KAAK,EAAE0C,gBAAgB;EAEvE,OAAOlH,OAAO,CAAE,MAAM;IACrB,MAAMiC,MAAM,GAAG,EAAE;IACjB,IAAKgF,cAAc,IAAIA,cAAc,CAACvB,MAAM,EAAG;MAC9CzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,OAAO,EACP,8CACD,CAAC;QACD2E,SAAS,EAAEkC;MACZ,CAAE,CAAC;IACJ;IACA,IACCE,6BAA6B,IAC7BD,gBAAgB,IAChBA,gBAAgB,CAACxB,MAAM,EACtB;MACDzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,SAAS,EACT,8CACD,CAAC;QACD2E,SAAS,EAAEmC;MACZ,CAAE,CAAC;IACJ;IACA,IAAKF,eAAe,IAAIA,eAAe,CAACtB,MAAM,EAAG;MAChDzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,QAAQ,EACR,gDACD,CAAC;QACD2E,SAAS,EAAEiC;MACZ,CAAE,CAAC;IACJ;IACA,OAAO/E,MAAM;EACd,CAAC,EAAE,CACF+E,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,6BAA6B,CAC5B,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["fastDeepEqual","useContext","useCallback","useMemo","useSelect","store","blocksStore","_x","getValueFromVariable","getPresetVariableFromValue","getValueFromObjectPath","setImmutably","GlobalStylesContext","unlock","EMPTY_CONFIG","settings","styles","VALID_SETTINGS","useGlobalStylesReset","user","setUserConfig","config","canReset","useGlobalSetting","propertyPath","blockName","source","configs","appendedBlockPath","appendedPropertyPath","contextualPath","globalPath","sourceKey","settingValue","configToUse","_getValueFromObjectPa","result","forEach","setting","_getValueFromObjectPa2","value","undefined","split","setSetting","newValue","currentConfig","useGlobalStyle","path","shouldDecodeEncode","merged","mergedConfig","base","baseConfig","userConfig","appendedPath","finalPath","setStyle","rawResult","useGlobalStyleLinks","_links","useSettingsForBlockElement","parentSettings","element","supportedStyles","supports","select","getSupportedStyles","getBlockType","updatedSettings","includes","typography","fontSizes","customFontSize","defaultFontSizes","fontFamilies","color","text","background","button","heading","link","caption","gradients","customGradient","defaultDuotone","customDuotone","key","textColumns","layout","spacing","sides","Array","isArray","length","dimensions","charAt","toUpperCase","slice","border","shadow","textAlign","useColorsPerOrigin","customColors","palette","custom","themeColors","theme","defaultColors","default","shouldDisplayDefaultColors","defaultPalette","push","name","colors","useGradientsPerOrigin","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients"],"sources":["@wordpress/block-editor/src/components/global-styles/hooks.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { getValueFromObjectPath, setImmutably } from '../../utils/object';\nimport { GlobalStylesContext } from './context';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'background.backgroundImage',\n\t'background.backgroundRepeat',\n\t'background.backgroundSize',\n\t'background.backgroundPosition',\n\t'border.color',\n\t'border.radius',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.button',\n\t'color.caption',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.heading',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.aspectRatio',\n\t'dimensions.minHeight',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'lightbox.enabled',\n\t'lightbox.allowEditing',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.defaultSpacingSizes',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.defaultFontSizes',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textAlign',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textTransform',\n\t'typography.writingMode',\n];\n\nexport const useGlobalStylesReset = () => {\n\tconst { user, setUserConfig } = useContext( GlobalStylesContext );\n\tconst config = {\n\t\tsettings: user.settings,\n\t\tstyles: user.styles,\n\t};\n\tconst canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback( () => setUserConfig( EMPTY_CONFIG ), [ setUserConfig ] ),\n\t];\n};\n\nexport function useGlobalSetting( propertyPath, blockName, source = 'all' ) {\n\tconst { setUserConfig, ...configs } = useContext( GlobalStylesContext );\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = propertyPath ? '.' + propertyPath : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\tconst sourceKey = source === 'all' ? 'merged' : source;\n\n\tconst settingValue = useMemo( () => {\n\t\tconst configToUse = configs[ sourceKey ];\n\t\tif ( ! configToUse ) {\n\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\tif ( propertyPath ) {\n\t\t\treturn (\n\t\t\t\tgetValueFromObjectPath( configToUse, contextualPath ) ??\n\t\t\t\tgetValueFromObjectPath( configToUse, globalPath )\n\t\t\t);\n\t\t}\n\n\t\tlet result = {};\n\t\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\t\tconst value =\n\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\tconfigToUse,\n\t\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t\t) ??\n\t\t\t\tgetValueFromObjectPath( configToUse, `settings.${ setting }` );\n\t\t\tif ( value !== undefined ) {\n\t\t\t\tresult = setImmutably( result, setting.split( '.' ), value );\n\t\t\t}\n\t\t} );\n\t\treturn result;\n\t}, [\n\t\tconfigs,\n\t\tsourceKey,\n\t\tpropertyPath,\n\t\tcontextualPath,\n\t\tglobalPath,\n\t\tappendedBlockPath,\n\t] );\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) =>\n\t\t\tsetImmutably( currentConfig, contextualPath.split( '.' ), newValue )\n\t\t);\n\t};\n\treturn [ settingValue, setSetting ];\n}\n\nexport function useGlobalStyle(\n\tpath,\n\tblockName,\n\tsource = 'all',\n\t{ shouldDecodeEncode = true } = {}\n) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst appendedPath = path ? '.' + path : '';\n\tconst finalPath = ! blockName\n\t\t? `styles${ appendedPath }`\n\t\t: `styles.blocks.${ blockName }${ appendedPath }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) =>\n\t\t\tsetImmutably(\n\t\t\t\tcurrentConfig,\n\t\t\t\tfinalPath.split( '.' ),\n\t\t\t\tshouldDecodeEncode\n\t\t\t\t\t? getPresetVariableFromValue(\n\t\t\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tnewValue\n\t\t\t\t\t )\n\t\t\t\t\t: newValue\n\t\t\t)\n\t\t);\n\t};\n\n\tlet rawResult, result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\trawResult = getValueFromObjectPath( mergedConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\trawResult = getValueFromObjectPath( userConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\trawResult = getValueFromObjectPath( baseConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( baseConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\nexport function useGlobalStyleLinks() {\n\tconst { merged: mergedConfig } = useContext( GlobalStylesContext );\n\treturn mergedConfig?._links;\n}\n\n/**\n * React hook that overrides a global settings object with block and element specific settings.\n *\n * @param {Object} parentSettings Settings object.\n * @param {blockName?} blockName Block name.\n * @param {element?} element Element name.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function useSettingsForBlockElement(\n\tparentSettings,\n\tblockName,\n\telement\n) {\n\tconst { supportedStyles, supports } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedStyles: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( blockName, element ),\n\t\t\t\tsupports:\n\t\t\t\t\tselect( blocksStore ).getBlockType( blockName )?.supports,\n\t\t\t};\n\t\t},\n\t\t[ blockName, element ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst updatedSettings = { ...parentSettings };\n\n\t\tif ( ! supportedStyles.includes( 'fontSize' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontSizes: {},\n\t\t\t\tcustomFontSize: false,\n\t\t\t\tdefaultFontSizes: false,\n\t\t\t};\n\t\t}\n\n\t\tif ( ! supportedStyles.includes( 'fontFamily' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontFamilies: {},\n\t\t\t};\n\t\t}\n\n\t\tupdatedSettings.color = {\n\t\t\t...updatedSettings.color,\n\t\t\ttext:\n\t\t\t\tupdatedSettings.color?.text &&\n\t\t\t\tsupportedStyles.includes( 'color' ),\n\t\t\tbackground:\n\t\t\t\tupdatedSettings.color?.background &&\n\t\t\t\t( supportedStyles.includes( 'background' ) ||\n\t\t\t\t\tsupportedStyles.includes( 'backgroundColor' ) ),\n\t\t\tbutton:\n\t\t\t\tupdatedSettings.color?.button &&\n\t\t\t\tsupportedStyles.includes( 'buttonColor' ),\n\t\t\theading:\n\t\t\t\tupdatedSettings.color?.heading &&\n\t\t\t\tsupportedStyles.includes( 'headingColor' ),\n\t\t\tlink:\n\t\t\t\tupdatedSettings.color?.link &&\n\t\t\t\tsupportedStyles.includes( 'linkColor' ),\n\t\t\tcaption:\n\t\t\t\tupdatedSettings.color?.caption &&\n\t\t\t\tsupportedStyles.includes( 'captionColor' ),\n\t\t};\n\n\t\t// Some blocks can enable background colors but disable gradients.\n\t\tif ( ! supportedStyles.includes( 'background' ) ) {\n\t\t\tupdatedSettings.color.gradients = [];\n\t\t\tupdatedSettings.color.customGradient = false;\n\t\t}\n\n\t\t// If filters are not supported by the block/element, disable duotone.\n\t\tif ( ! supportedStyles.includes( 'filter' ) ) {\n\t\t\tupdatedSettings.color.defaultDuotone = false;\n\t\t\tupdatedSettings.color.customDuotone = false;\n\t\t}\n\n\t\t[\n\t\t\t'lineHeight',\n\t\t\t'fontStyle',\n\t\t\t'fontWeight',\n\t\t\t'letterSpacing',\n\t\t\t'textAlign',\n\t\t\t'textTransform',\n\t\t\t'textDecoration',\n\t\t\t'writingMode',\n\t\t].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.typography = {\n\t\t\t\t\t...updatedSettings.typography,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// The column-count style is named text column to reduce confusion with\n\t\t// the columns block and manage expectations from the support.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/33587\n\t\tif ( ! supportedStyles.includes( 'columnCount' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextColumns: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'contentSize', 'wideSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.layout = {\n\t\t\t\t\t...updatedSettings.layout,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst sides = Array.isArray( supports?.spacing?.[ key ] )\n\t\t\t\t? supports?.spacing?.[ key ]\n\t\t\t\t: supports?.spacing?.[ key ]?.sides;\n\t\t\t// Check if spacing type is supported before adding sides.\n\t\t\tif ( sides?.length && updatedSettings.spacing?.[ key ] ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: {\n\t\t\t\t\t\t...updatedSettings.spacing?.[ key ],\n\t\t\t\t\t\tsides,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'aspectRatio', 'minHeight' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.dimensions = {\n\t\t\t\t\t...updatedSettings.dimensions,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {\n\t\t\tif (\n\t\t\t\t! supportedStyles.includes(\n\t\t\t\t\t'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedSettings.border = {\n\t\t\t\t\t...updatedSettings.border,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tupdatedSettings.shadow = supportedStyles.includes( 'shadow' )\n\t\t\t? updatedSettings.shadow\n\t\t\t: false;\n\n\t\t// Text alignment is only available for blocks.\n\t\tif ( element ) {\n\t\t\tupdatedSettings.typography.textAlign = false;\n\t\t}\n\n\t\treturn updatedSettings;\n\t}, [ parentSettings, supportedStyles, supports, element ] );\n}\n\nexport function useColorsPerOrigin( settings ) {\n\tconst customColors = settings?.color?.palette?.custom;\n\tconst themeColors = settings?.color?.palette?.theme;\n\tconst defaultColors = settings?.color?.palette?.default;\n\tconst shouldDisplayDefaultColors = settings?.color?.defaultPalette;\n\n\treturn 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 is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n}\n\nexport function useGradientsPerOrigin( settings ) {\n\tconst customGradients = settings?.color?.gradients?.custom;\n\tconst themeGradients = settings?.color?.gradients?.theme;\n\tconst defaultGradients = settings?.color?.gradients?.default;\n\tconst shouldDisplayDefaultGradients = settings?.color?.defaultGradients;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n}\n"],"mappings":"AAAA;AACA;AACA;A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E4D,KAAK,EAAE0C,gBAAgB;EAEvE,OAAOlH,OAAO,CAAE,MAAM;IACrB,MAAMiC,MAAM,GAAG,EAAE;IACjB,IAAKgF,cAAc,IAAIA,cAAc,CAACvB,MAAM,EAAG;MAC9CzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,OAAO,EACP,8CACD,CAAC;QACD2E,SAAS,EAAEkC;MACZ,CAAE,CAAC;IACJ;IACA,IACCE,6BAA6B,IAC7BD,gBAAgB,IAChBA,gBAAgB,CAACxB,MAAM,EACtB;MACDzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,SAAS,EACT,8CACD,CAAC;QACD2E,SAAS,EAAEmC;MACZ,CAAE,CAAC;IACJ;IACA,IAAKF,eAAe,IAAIA,eAAe,CAACtB,MAAM,EAAG;MAChDzD,MAAM,CAAC2E,IAAI,CAAE;QACZC,IAAI,EAAEzG,EAAE,CACP,QAAQ,EACR,gDACD,CAAC;QACD2E,SAAS,EAAEiC;MACZ,CAAE,CAAC;IACJ;IACA,OAAO/E,MAAM;EACd,CAAC,EAAE,CACF+E,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,6BAA6B,CAC5B,CAAC;AACJ","ignoreList":[]}
@@ -23,6 +23,12 @@ import { getValueFromObjectPath, setImmutably } from '../../utils/object';
23
23
  import { unlock } from '../../lock-unlock';
24
24
  import { setThemeFileUris } from './theme-file-uri-utils';
25
25
 
26
+ // Elements that rely on class names in their selectors.
27
+ const ELEMENT_CLASS_NAMES = {
28
+ button: 'wp-element-button',
29
+ caption: 'wp-element-caption'
30
+ };
31
+
26
32
  // List of block support features that can have their related styles
27
33
  // generated under their own feature level selector rather than the block's.
28
34
  const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
@@ -451,7 +457,10 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
451
457
  if (tree.styles?.elements?.[name]) {
452
458
  nodes.push({
453
459
  styles: tree.styles?.elements?.[name],
454
- selector
460
+ selector,
461
+ // Top level elements that don't use a class name should not receive the
462
+ // `:root :where()` wrapper to maintain backwards compatibility.
463
+ skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name]
455
464
  });
456
465
  }
457
466
  });
@@ -468,7 +477,7 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
468
477
  if (variation?.css) {
469
478
  variations[variationName].css = variation.css;
470
479
  }
471
- const variationSelector = blockSelectors[blockName].styleVariationSelectors?.[variationName];
480
+ const variationSelector = blockSelectors[blockName]?.styleVariationSelectors?.[variationName];
472
481
 
473
482
  // Process the variation's inner element styles.
474
483
  // This comes before the inner block styles so the
@@ -486,9 +495,9 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
486
495
  // Process the variations inner block type styles.
487
496
  Object.entries((_variation$blocks = variation?.blocks) !== null && _variation$blocks !== void 0 ? _variation$blocks : {}).forEach(([variationBlockName, variationBlockStyles]) => {
488
497
  var _variationBlockStyles;
489
- const variationBlockSelector = scopeSelector(variationSelector, blockSelectors[variationBlockName].selector);
490
- const variationDuotoneSelector = scopeSelector(variationSelector, blockSelectors[variationBlockName].duotoneSelector);
491
- const variationFeatureSelectors = scopeFeatureSelectors(variationSelector, blockSelectors[variationBlockName].featureSelectors);
498
+ const variationBlockSelector = scopeSelector(variationSelector, blockSelectors[variationBlockName]?.selector);
499
+ const variationDuotoneSelector = scopeSelector(variationSelector, blockSelectors[variationBlockName]?.duotoneSelector);
500
+ const variationFeatureSelectors = scopeFeatureSelectors(variationSelector, blockSelectors[variationBlockName]?.featureSelectors);
492
501
  const variationBlockStyleNodes = pickStyleKeys(variationBlockStyles);
493
502
  if (variationBlockStyles?.css) {
494
503
  variationBlockStyleNodes.css = variationBlockStyles.css;
@@ -497,8 +506,8 @@ export const getNodesWithStyles = (tree, blockSelectors) => {
497
506
  selector: variationBlockSelector,
498
507
  duotoneSelector: variationDuotoneSelector,
499
508
  featureSelectors: variationFeatureSelectors,
500
- fallbackGapValue: blockSelectors[variationBlockName].fallbackGapValue,
501
- hasLayoutSupport: blockSelectors[variationBlockName].hasLayoutSupport,
509
+ fallbackGapValue: blockSelectors[variationBlockName]?.fallbackGapValue,
510
+ hasLayoutSupport: blockSelectors[variationBlockName]?.hasLayoutSupport,
502
511
  styles: variationBlockStyleNodes
503
512
  });
504
513
 
@@ -651,8 +660,8 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGa
651
660
  ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
652
661
  .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
653
662
  .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
654
- .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }
655
- .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0;
663
+ .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; }
664
+ .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0;
656
665
  `;
657
666
  }
658
667
  ruleset += '}';
@@ -665,7 +674,8 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGa
665
674
  fallbackGapValue,
666
675
  hasLayoutSupport,
667
676
  featureSelectors,
668
- styleVariationSelectors
677
+ styleVariationSelectors,
678
+ skipSelectorWrapper
669
679
  }) => {
670
680
  // Process styles for block support features with custom feature level
671
681
  // CSS selectors set.
@@ -706,7 +716,8 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGa
706
716
  // Process the remaining block styles (they use either normal block class or __experimentalSelector).
707
717
  const styleDeclarations = getStylesDeclarations(styles, selector, useRootPaddingAlign, tree, disableRootPadding);
708
718
  if (styleDeclarations?.length) {
709
- ruleset += `:root :where(${selector}){${styleDeclarations.join(';')};}`;
719
+ const generalSelector = skipSelectorWrapper ? selector : `:root :where(${selector})`;
720
+ ruleset += `${generalSelector}{${styleDeclarations.join(';')};}`;
710
721
  }
711
722
  if (styles?.css) {
712
723
  ruleset += processCSSNesting(styles.css, `:root :where(${selector})`);
@@ -756,7 +767,12 @@ export const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGa
756
767
  // Split and append pseudo selector to create
757
768
  // the proper rules to target the elements.
758
769
  const _selector = selector.split(',').map(sel => sel + pseudoKey).join(',');
759
- const pseudoRule = `${_selector}{${pseudoDeclarations.join(';')};}`;
770
+
771
+ // As pseudo classes such as :hover, :focus etc. have class-level
772
+ // specificity, they must use the `:root :where()` wrapper. This.
773
+ // caps the specificity at `0-1-0` to allow proper nesting of variations
774
+ // and block type element styles.
775
+ const pseudoRule = `:root :where(${_selector}){${pseudoDeclarations.join(';')};}`;
760
776
  ruleset += pseudoRule;
761
777
  });
762
778
  }