@wordpress/block-editor 13.0.3 → 13.0.5
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.
- package/build/components/global-styles/background-panel.js +2 -1
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +2 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +2 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +2 -1
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +8 -8
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +17 -7
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/hooks/block-style-variation.js +171 -6
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/duotone.js +16 -11
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +7 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +11 -6
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/utils.js +2 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +2 -1
- package/build/private-apis.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +3 -2
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -2
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +3 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +3 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +3 -2
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +8 -8
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +15 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +170 -6
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -11
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +11 -6
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/utils.js +2 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +3 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-style/content-rtl.css +1 -0
- package/build-style/content.css +1 -0
- package/package.json +2 -2
- package/src/components/global-styles/background-panel.js +3 -2
- package/src/components/global-styles/border-panel.js +3 -2
- package/src/components/global-styles/color-panel.js +3 -2
- package/src/components/global-styles/dimensions-panel.js +3 -2
- package/src/components/global-styles/filters-panel.js +3 -2
- package/src/components/global-styles/image-settings-panel.js +3 -2
- package/src/components/global-styles/typography-panel.js +3 -2
- package/src/components/global-styles/use-global-styles-output.js +8 -8
- package/src/components/global-styles/utils.js +17 -6
- package/src/components/iframe/content.scss +1 -0
- package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
- package/src/hooks/block-style-variation.js +204 -5
- package/src/hooks/duotone.js +16 -12
- package/src/hooks/index.js +1 -0
- package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
- package/src/hooks/use-bindings-attributes.js +13 -4
- package/src/hooks/utils.js +2 -0
- package/src/private-apis.js +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_es","_interopRequireDefault","require","_typographyUtils","_object","ROOT_BLOCK_SELECTOR","exports","ROOT_CSS_PROPERTIES_SELECTOR","PRESET_METADATA","path","valueKey","cssVarInfix","classes","classSuffix","propertyName","valueFunc","slug","preset","settings","getTypographyFontSizeValue","size","STYLE_PATH_TO_CSS_VAR_INFIX","shadow","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","TOOLSPANEL_DROPDOWNMENU_PROPS","popoverProps","placement","offset","findInPresetsBy","features","blockName","presetPath","presetProperty","presetValueValue","orderedPresetsByOrigin","getValueFromObjectPath","presetByOrigin","origins","origin","presets","presetObject","find","highestPresetObjectWithSameSlug","undefined","getPresetVariableFromValue","variableStylePath","presetPropertyValue","metadata","data","getValueFromPresetVariable","variable","presetType","result","getValueFromVariable","getValueFromCustomVariable","_getValueFromObjectPa","ref","refPath","split","USER_VALUE_PREFIX","THEME_VALUE_PREFIX","THEME_VALUE_SUFFIX","parsedVar","startsWith","slice","length","endsWith","type","scopeSelector","scope","selector","scopes","selectors","selectorsScoped","forEach","outer","inner","push","trim","join","scopeFeatureSelectors","featureSelectors","Object","entries","feature","subfeature","subfeatureSelector","appendToSelector","toAppend","includes","newSelectors","map","sel","areGlobalStyleConfigsEqual","original","variation","fastDeepEqual","styles","getBlockStyleVariationSelector","blockSelector","variationClass","ancestorRegex","addVariationClass","_match","group1","group2","part","replace"],"sources":["@wordpress/block-editor/src/components/global-styles/utils.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * Internal dependencies\n */\nimport { getTypographyFontSizeValue } from './typography-utils';\nimport { getValueFromObjectPath } from '../../utils/object';\n\n/* Supporting data. */\nexport const ROOT_BLOCK_SELECTOR = 'body';\nexport const ROOT_CSS_PROPERTIES_SELECTOR = ':root';\n\nexport const PRESET_METADATA = [\n\t{\n\t\tpath: [ 'color', 'palette' ],\n\t\tvalueKey: 'color',\n\t\tcssVarInfix: 'color',\n\t\tclasses: [\n\t\t\t{ classSuffix: 'color', propertyName: 'color' },\n\t\t\t{\n\t\t\t\tclassSuffix: 'background-color',\n\t\t\t\tpropertyName: 'background-color',\n\t\t\t},\n\t\t\t{\n\t\t\t\tclassSuffix: 'border-color',\n\t\t\t\tpropertyName: 'border-color',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'color', 'gradients' ],\n\t\tvalueKey: 'gradient',\n\t\tcssVarInfix: 'gradient',\n\t\tclasses: [\n\t\t\t{\n\t\t\t\tclassSuffix: 'gradient-background',\n\t\t\t\tpropertyName: 'background',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'color', 'duotone' ],\n\t\tvalueKey: 'colors',\n\t\tcssVarInfix: 'duotone',\n\t\tvalueFunc: ( { slug } ) => `url( '#wp-duotone-${ slug }' )`,\n\t\tclasses: [],\n\t},\n\t{\n\t\tpath: [ 'shadow', 'presets' ],\n\t\tvalueKey: 'shadow',\n\t\tcssVarInfix: 'shadow',\n\t\tclasses: [],\n\t},\n\t{\n\t\tpath: [ 'typography', 'fontSizes' ],\n\t\tvalueFunc: ( preset, settings ) =>\n\t\t\tgetTypographyFontSizeValue( preset, settings ),\n\t\tvalueKey: 'size',\n\t\tcssVarInfix: 'font-size',\n\t\tclasses: [ { classSuffix: 'font-size', propertyName: 'font-size' } ],\n\t},\n\t{\n\t\tpath: [ 'typography', 'fontFamilies' ],\n\t\tvalueKey: 'fontFamily',\n\t\tcssVarInfix: 'font-family',\n\t\tclasses: [\n\t\t\t{ classSuffix: 'font-family', propertyName: 'font-family' },\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'spacing', 'spacingSizes' ],\n\t\tvalueKey: 'size',\n\t\tcssVarInfix: 'spacing',\n\t\tvalueFunc: ( { size } ) => size,\n\t\tclasses: [],\n\t},\n];\n\nexport const STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'filter.duotone': 'duotone',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.caption.color.text': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\tshadow: 'shadow',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// A static list of block attributes that store global style preset slugs.\nexport const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nexport const TOOLSPANEL_DROPDOWNMENU_PROPS = {\n\tpopoverProps: {\n\t\tplacement: 'left-start',\n\t\toffset: 259, // Inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)\n\t},\n};\n\nfunction findInPresetsBy(\n\tfeatures,\n\tblockName,\n\tpresetPath,\n\tpresetProperty,\n\tpresetValueValue\n) {\n\t// Block presets take priority above root level presets.\n\tconst orderedPresetsByOrigin = [\n\t\tgetValueFromObjectPath( features, [\n\t\t\t'blocks',\n\t\t\tblockName,\n\t\t\t...presetPath,\n\t\t] ),\n\t\tgetValueFromObjectPath( features, presetPath ),\n\t];\n\n\tfor ( const presetByOrigin of orderedPresetsByOrigin ) {\n\t\tif ( presetByOrigin ) {\n\t\t\t// Preset origins ordered by priority.\n\t\t\tconst origins = [ 'custom', 'theme', 'default' ];\n\t\t\tfor ( const origin of origins ) {\n\t\t\t\tconst presets = presetByOrigin[ origin ];\n\t\t\t\tif ( presets ) {\n\t\t\t\t\tconst presetObject = presets.find(\n\t\t\t\t\t\t( preset ) =>\n\t\t\t\t\t\t\tpreset[ presetProperty ] === presetValueValue\n\t\t\t\t\t);\n\t\t\t\t\tif ( presetObject ) {\n\t\t\t\t\t\tif ( presetProperty === 'slug' ) {\n\t\t\t\t\t\t\treturn presetObject;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.\n\t\t\t\t\t\tconst highestPresetObjectWithSameSlug = findInPresetsBy(\n\t\t\t\t\t\t\tfeatures,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpresetPath,\n\t\t\t\t\t\t\t'slug',\n\t\t\t\t\t\t\tpresetObject.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thighestPresetObjectWithSameSlug[\n\t\t\t\t\t\t\t\tpresetProperty\n\t\t\t\t\t\t\t] === presetObject[ presetProperty ]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn presetObject;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function getPresetVariableFromValue(\n\tfeatures,\n\tblockName,\n\tvariableStylePath,\n\tpresetPropertyValue\n) {\n\tif ( ! presetPropertyValue ) {\n\t\treturn presetPropertyValue;\n\t}\n\n\tconst cssVarInfix = STYLE_PATH_TO_CSS_VAR_INFIX[ variableStylePath ];\n\n\tconst metadata = PRESET_METADATA.find(\n\t\t( data ) => data.cssVarInfix === cssVarInfix\n\t);\n\n\tif ( ! metadata ) {\n\t\t// The property doesn't have preset data\n\t\t// so the value should be returned as it is.\n\t\treturn presetPropertyValue;\n\t}\n\tconst { valueKey, path } = metadata;\n\n\tconst presetObject = findInPresetsBy(\n\t\tfeatures,\n\t\tblockName,\n\t\tpath,\n\t\tvalueKey,\n\t\tpresetPropertyValue\n\t);\n\n\tif ( ! presetObject ) {\n\t\t// Value wasn't found in the presets,\n\t\t// so it must be a custom value.\n\t\treturn presetPropertyValue;\n\t}\n\n\treturn `var:preset|${ cssVarInfix }|${ presetObject.slug }`;\n}\n\nfunction getValueFromPresetVariable(\n\tfeatures,\n\tblockName,\n\tvariable,\n\t[ presetType, slug ]\n) {\n\tconst metadata = PRESET_METADATA.find(\n\t\t( data ) => data.cssVarInfix === presetType\n\t);\n\tif ( ! metadata ) {\n\t\treturn variable;\n\t}\n\n\tconst presetObject = findInPresetsBy(\n\t\tfeatures.settings,\n\t\tblockName,\n\t\tmetadata.path,\n\t\t'slug',\n\t\tslug\n\t);\n\n\tif ( presetObject ) {\n\t\tconst { valueKey } = metadata;\n\t\tconst result = presetObject[ valueKey ];\n\t\treturn getValueFromVariable( features, blockName, result );\n\t}\n\n\treturn variable;\n}\n\nfunction getValueFromCustomVariable( features, blockName, variable, path ) {\n\tconst result =\n\t\tgetValueFromObjectPath( features.settings, [\n\t\t\t'blocks',\n\t\t\tblockName,\n\t\t\t'custom',\n\t\t\t...path,\n\t\t] ) ??\n\t\tgetValueFromObjectPath( features.settings, [ 'custom', ...path ] );\n\tif ( ! result ) {\n\t\treturn variable;\n\t}\n\t// A variable may reference another variable so we need recursion until we find the value.\n\treturn getValueFromVariable( features, blockName, result );\n}\n\n/**\n * Attempts to fetch the value of a theme.json CSS variable.\n *\n * @param {Object} features GlobalStylesContext config, e.g., user, base or merged. Represents the theme.json tree.\n * @param {string} blockName The name of a block as represented in the styles property. E.g., 'root' for root-level, and 'core/${blockName}' for blocks.\n * @param {string|*} variable An incoming style value. A CSS var value is expected, but it could be any value.\n * @return {string|*|{ref}} The value of the CSS var, if found. If not found, the passed variable argument.\n */\nexport function getValueFromVariable( features, blockName, variable ) {\n\tif ( ! variable || typeof variable !== 'string' ) {\n\t\tif ( variable?.ref && typeof variable?.ref === 'string' ) {\n\t\t\tconst refPath = variable.ref.split( '.' );\n\t\t\tvariable = getValueFromObjectPath( features, refPath );\n\t\t\t// Presence of another ref indicates a reference to another dynamic value.\n\t\t\t// Pointing to another dynamic value is not supported.\n\t\t\tif ( ! variable || !! variable?.ref ) {\n\t\t\t\treturn variable;\n\t\t\t}\n\t\t} else {\n\t\t\treturn variable;\n\t\t}\n\t}\n\tconst USER_VALUE_PREFIX = 'var:';\n\tconst THEME_VALUE_PREFIX = 'var(--wp--';\n\tconst THEME_VALUE_SUFFIX = ')';\n\n\tlet parsedVar;\n\n\tif ( variable.startsWith( USER_VALUE_PREFIX ) ) {\n\t\tparsedVar = variable.slice( USER_VALUE_PREFIX.length ).split( '|' );\n\t} else if (\n\t\tvariable.startsWith( THEME_VALUE_PREFIX ) &&\n\t\tvariable.endsWith( THEME_VALUE_SUFFIX )\n\t) {\n\t\tparsedVar = variable\n\t\t\t.slice( THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length )\n\t\t\t.split( '--' );\n\t} else {\n\t\t// We don't know how to parse the value: either is raw of uses complex CSS such as `calc(1px * var(--wp--variable) )`\n\t\treturn variable;\n\t}\n\n\tconst [ type, ...path ] = parsedVar;\n\tif ( type === 'preset' ) {\n\t\treturn getValueFromPresetVariable(\n\t\t\tfeatures,\n\t\t\tblockName,\n\t\t\tvariable,\n\t\t\tpath\n\t\t);\n\t}\n\tif ( type === 'custom' ) {\n\t\treturn getValueFromCustomVariable(\n\t\t\tfeatures,\n\t\t\tblockName,\n\t\t\tvariable,\n\t\t\tpath\n\t\t);\n\t}\n\treturn variable;\n}\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nexport function scopeSelector( scope, selector ) {\n\tif ( ! scope || ! selector ) {\n\t\treturn selector;\n\t}\n\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Scopes a collection of selectors for features and subfeatures.\n *\n * @example\n * ```js\n * const scope = '.custom-scope';\n * const selectors = {\n * color: '.wp-my-block p',\n * typography: { fontSize: '.wp-my-block caption' },\n * };\n * const result = scopeFeatureSelector( scope, selectors );\n * // result is {\n * // color: '.custom-scope .wp-my-block p',\n * // typography: { fonSize: '.custom-scope .wp-my-block caption' },\n * // }\n * ```\n *\n * @param {string} scope Selector to scope collection of selectors with.\n * @param {Object} selectors Collection of feature selectors e.g.\n *\n * @return {Object|undefined} Scoped collection of feature selectors.\n */\nexport function scopeFeatureSelectors( scope, selectors ) {\n\tif ( ! scope || ! selectors ) {\n\t\treturn;\n\t}\n\n\tconst featureSelectors = {};\n\n\tObject.entries( selectors ).forEach( ( [ feature, selector ] ) => {\n\t\tif ( typeof selector === 'string' ) {\n\t\t\tfeatureSelectors[ feature ] = scopeSelector( scope, selector );\n\t\t}\n\n\t\tif ( typeof selector === 'object' ) {\n\t\t\tfeatureSelectors[ feature ] = {};\n\n\t\t\tObject.entries( selector ).forEach(\n\t\t\t\t( [ subfeature, subfeatureSelector ] ) => {\n\t\t\t\t\tfeatureSelectors[ feature ][ subfeature ] = scopeSelector(\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tsubfeatureSelector\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn featureSelectors;\n}\n\n/**\n * Appends a sub-selector to an existing one.\n *\n * Given the compounded `selector` \"h1, h2, h3\"\n * and the `toAppend` selector \".some-class\" the result will be\n * \"h1.some-class, h2.some-class, h3.some-class\".\n *\n * @param {string} selector Original selector.\n * @param {string} toAppend Selector to append.\n *\n * @return {string} The new selector.\n */\nexport function appendToSelector( selector, toAppend ) {\n\tif ( ! selector.includes( ',' ) ) {\n\t\treturn selector + toAppend;\n\t}\n\tconst selectors = selector.split( ',' );\n\tconst newSelectors = selectors.map( ( sel ) => sel + toAppend );\n\treturn newSelectors.join( ',' );\n}\n\n/**\n * Compares global style variations according to their styles and settings properties.\n *\n * @example\n * ```js\n * const globalStyles = { styles: { typography: { fontSize: '10px' } }, settings: {} };\n * const variation = { styles: { typography: { fontSize: '10000px' } }, settings: {} };\n * const isEqual = areGlobalStyleConfigsEqual( globalStyles, variation );\n * // false\n * ```\n *\n * @param {Object} original A global styles object.\n * @param {Object} variation A global styles object.\n *\n * @return {boolean} Whether `original` and `variation` match.\n */\nexport function areGlobalStyleConfigsEqual( original, variation ) {\n\tif ( typeof original !== 'object' || typeof variation !== 'object' ) {\n\t\treturn original === variation;\n\t}\n\treturn (\n\t\tfastDeepEqual( original?.styles, variation?.styles ) &&\n\t\tfastDeepEqual( original?.settings, variation?.settings )\n\t);\n}\n\n/**\n * Generates the selector for a block style variation by creating the\n * appropriate CSS class and adding it to the ancestor portion of the block's\n * selector.\n *\n * For example, take the Button block which has a compound selector:\n * `.wp-block-button .wp-block-button__link`. With a variation named 'custom',\n * the class `.is-style-custom` should be added to the `.wp-block-button`\n * ancestor only.\n *\n * This function will take into account comma separated and complex selectors.\n *\n * @param {string} variation Name for the variation.\n * @param {string} blockSelector CSS selector for the block.\n *\n * @return {string} CSS selector for the block style variation.\n */\nexport function getBlockStyleVariationSelector( variation, blockSelector ) {\n\tconst variationClass = `.is-style-${ variation }`;\n\n\tif ( ! blockSelector ) {\n\t\treturn variationClass;\n\t}\n\n\tconst ancestorRegex = /((?::\\([^)]+\\))?\\s*)([^\\s:]+)/;\n\tconst addVariationClass = ( _match, group1, group2 ) => {\n\t\treturn group1 + group2 + variationClass;\n\t};\n\n\tconst result = blockSelector\n\t\t.split( ',' )\n\t\t.map( ( part ) => part.replace( ancestorRegex, addVariationClass ) );\n\n\treturn result.join( ',' );\n}\n"],"mappings":";;;;;;;;;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACO,MAAMG,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,MAAM;AAClC,MAAME,4BAA4B,GAAAD,OAAA,CAAAC,4BAAA,GAAG,OAAO;AAE5C,MAAMC,eAAe,GAAAF,O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;EAC9B;EACA,OACC,IAAAC,WAAa,EAAEF,QAAQ,EAAEG,MAAM,EAAEF,SAAS,EAAEE,MAAO,CAAC,IACpD,IAAAD,WAAa,EAAEF,QAAQ,EAAE5E,QAAQ,EAAE6E,SAAS,EAAE7E,QAAS,CAAC;AAE1D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASgF,8BAA8BA,CAAEH,SAAS,EAAEI,aAAa,EAAG;EAC1E,MAAMC,cAAc,GAAI,aAAaL,SAAW,EAAC;EAEjD,IAAK,CAAEI,aAAa,EAAG;IACtB,OAAOC,cAAc;EACtB;EAEA,MAAMC,aAAa,GAAG,+BAA+B;EACrD,MAAMC,iBAAiB,GAAGA,CAAEC,MAAM,EAAEC,MAAM,EAAEC,MAAM,KAAM;IACvD,OAAOD,MAAM,GAAGC,MAAM,GAAGL,cAAc;EACxC,CAAC;EAED,MAAMhD,MAAM,GAAG+C,aAAa,CAC1BzC,KAAK,CAAE,GAAI,CAAC,CACZiC,GAAG,CAAIe,IAAI,IAAMA,IAAI,CAACC,OAAO,CAAEN,aAAa,EAAEC,iBAAkB,CAAE,CAAC;EAErE,OAAOlD,MAAM,CAAC2B,IAAI,CAAE,GAAI,CAAC;AAC1B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_es","_interopRequireDefault","require","_compose","_typographyUtils","_object","ROOT_BLOCK_SELECTOR","exports","ROOT_CSS_PROPERTIES_SELECTOR","PRESET_METADATA","path","valueKey","cssVarInfix","classes","classSuffix","propertyName","valueFunc","slug","preset","settings","getTypographyFontSizeValue","size","STYLE_PATH_TO_CSS_VAR_INFIX","shadow","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","useToolsPanelDropdownMenuProps","isMobile","useViewportMatch","popoverProps","placement","offset","findInPresetsBy","features","blockName","presetPath","presetProperty","presetValueValue","orderedPresetsByOrigin","getValueFromObjectPath","presetByOrigin","origins","origin","presets","presetObject","find","highestPresetObjectWithSameSlug","undefined","getPresetVariableFromValue","variableStylePath","presetPropertyValue","metadata","data","getValueFromPresetVariable","variable","presetType","result","getValueFromVariable","getValueFromCustomVariable","_getValueFromObjectPa","ref","refPath","split","USER_VALUE_PREFIX","THEME_VALUE_PREFIX","THEME_VALUE_SUFFIX","parsedVar","startsWith","slice","length","endsWith","type","scopeSelector","scope","selector","scopes","selectors","selectorsScoped","forEach","outer","inner","push","trim","join","scopeFeatureSelectors","featureSelectors","Object","entries","feature","subfeature","subfeatureSelector","appendToSelector","toAppend","includes","newSelectors","map","sel","areGlobalStyleConfigsEqual","original","variation","fastDeepEqual","styles","getBlockStyleVariationSelector","blockSelector","variationClass","ancestorRegex","addVariationClass","_match","group1","group2","part","replace"],"sources":["@wordpress/block-editor/src/components/global-styles/utils.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getTypographyFontSizeValue } from './typography-utils';\nimport { getValueFromObjectPath } from '../../utils/object';\n\n/* Supporting data. */\nexport const ROOT_BLOCK_SELECTOR = 'body';\nexport const ROOT_CSS_PROPERTIES_SELECTOR = ':root';\n\nexport const PRESET_METADATA = [\n\t{\n\t\tpath: [ 'color', 'palette' ],\n\t\tvalueKey: 'color',\n\t\tcssVarInfix: 'color',\n\t\tclasses: [\n\t\t\t{ classSuffix: 'color', propertyName: 'color' },\n\t\t\t{\n\t\t\t\tclassSuffix: 'background-color',\n\t\t\t\tpropertyName: 'background-color',\n\t\t\t},\n\t\t\t{\n\t\t\t\tclassSuffix: 'border-color',\n\t\t\t\tpropertyName: 'border-color',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'color', 'gradients' ],\n\t\tvalueKey: 'gradient',\n\t\tcssVarInfix: 'gradient',\n\t\tclasses: [\n\t\t\t{\n\t\t\t\tclassSuffix: 'gradient-background',\n\t\t\t\tpropertyName: 'background',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'color', 'duotone' ],\n\t\tvalueKey: 'colors',\n\t\tcssVarInfix: 'duotone',\n\t\tvalueFunc: ( { slug } ) => `url( '#wp-duotone-${ slug }' )`,\n\t\tclasses: [],\n\t},\n\t{\n\t\tpath: [ 'shadow', 'presets' ],\n\t\tvalueKey: 'shadow',\n\t\tcssVarInfix: 'shadow',\n\t\tclasses: [],\n\t},\n\t{\n\t\tpath: [ 'typography', 'fontSizes' ],\n\t\tvalueFunc: ( preset, settings ) =>\n\t\t\tgetTypographyFontSizeValue( preset, settings ),\n\t\tvalueKey: 'size',\n\t\tcssVarInfix: 'font-size',\n\t\tclasses: [ { classSuffix: 'font-size', propertyName: 'font-size' } ],\n\t},\n\t{\n\t\tpath: [ 'typography', 'fontFamilies' ],\n\t\tvalueKey: 'fontFamily',\n\t\tcssVarInfix: 'font-family',\n\t\tclasses: [\n\t\t\t{ classSuffix: 'font-family', propertyName: 'font-family' },\n\t\t],\n\t},\n\t{\n\t\tpath: [ 'spacing', 'spacingSizes' ],\n\t\tvalueKey: 'size',\n\t\tcssVarInfix: 'spacing',\n\t\tvalueFunc: ( { size } ) => size,\n\t\tclasses: [],\n\t},\n];\n\nexport const STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'filter.duotone': 'duotone',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.caption.color.text': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\tshadow: 'shadow',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// A static list of block attributes that store global style preset slugs.\nexport const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nexport function useToolsPanelDropdownMenuProps() {\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn ! isMobile\n\t\t? {\n\t\t\t\tpopoverProps: {\n\t\t\t\t\tplacement: 'left-start',\n\t\t\t\t\t// For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px)\n\t\t\t\t\toffset: 259,\n\t\t\t\t},\n\t\t }\n\t\t: {};\n}\n\nfunction findInPresetsBy(\n\tfeatures,\n\tblockName,\n\tpresetPath,\n\tpresetProperty,\n\tpresetValueValue\n) {\n\t// Block presets take priority above root level presets.\n\tconst orderedPresetsByOrigin = [\n\t\tgetValueFromObjectPath( features, [\n\t\t\t'blocks',\n\t\t\tblockName,\n\t\t\t...presetPath,\n\t\t] ),\n\t\tgetValueFromObjectPath( features, presetPath ),\n\t];\n\n\tfor ( const presetByOrigin of orderedPresetsByOrigin ) {\n\t\tif ( presetByOrigin ) {\n\t\t\t// Preset origins ordered by priority.\n\t\t\tconst origins = [ 'custom', 'theme', 'default' ];\n\t\t\tfor ( const origin of origins ) {\n\t\t\t\tconst presets = presetByOrigin[ origin ];\n\t\t\t\tif ( presets ) {\n\t\t\t\t\tconst presetObject = presets.find(\n\t\t\t\t\t\t( preset ) =>\n\t\t\t\t\t\t\tpreset[ presetProperty ] === presetValueValue\n\t\t\t\t\t);\n\t\t\t\t\tif ( presetObject ) {\n\t\t\t\t\t\tif ( presetProperty === 'slug' ) {\n\t\t\t\t\t\t\treturn presetObject;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.\n\t\t\t\t\t\tconst highestPresetObjectWithSameSlug = findInPresetsBy(\n\t\t\t\t\t\t\tfeatures,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpresetPath,\n\t\t\t\t\t\t\t'slug',\n\t\t\t\t\t\t\tpresetObject.slug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thighestPresetObjectWithSameSlug[\n\t\t\t\t\t\t\t\tpresetProperty\n\t\t\t\t\t\t\t] === presetObject[ presetProperty ]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn presetObject;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function getPresetVariableFromValue(\n\tfeatures,\n\tblockName,\n\tvariableStylePath,\n\tpresetPropertyValue\n) {\n\tif ( ! presetPropertyValue ) {\n\t\treturn presetPropertyValue;\n\t}\n\n\tconst cssVarInfix = STYLE_PATH_TO_CSS_VAR_INFIX[ variableStylePath ];\n\n\tconst metadata = PRESET_METADATA.find(\n\t\t( data ) => data.cssVarInfix === cssVarInfix\n\t);\n\n\tif ( ! metadata ) {\n\t\t// The property doesn't have preset data\n\t\t// so the value should be returned as it is.\n\t\treturn presetPropertyValue;\n\t}\n\tconst { valueKey, path } = metadata;\n\n\tconst presetObject = findInPresetsBy(\n\t\tfeatures,\n\t\tblockName,\n\t\tpath,\n\t\tvalueKey,\n\t\tpresetPropertyValue\n\t);\n\n\tif ( ! presetObject ) {\n\t\t// Value wasn't found in the presets,\n\t\t// so it must be a custom value.\n\t\treturn presetPropertyValue;\n\t}\n\n\treturn `var:preset|${ cssVarInfix }|${ presetObject.slug }`;\n}\n\nfunction getValueFromPresetVariable(\n\tfeatures,\n\tblockName,\n\tvariable,\n\t[ presetType, slug ]\n) {\n\tconst metadata = PRESET_METADATA.find(\n\t\t( data ) => data.cssVarInfix === presetType\n\t);\n\tif ( ! metadata ) {\n\t\treturn variable;\n\t}\n\n\tconst presetObject = findInPresetsBy(\n\t\tfeatures.settings,\n\t\tblockName,\n\t\tmetadata.path,\n\t\t'slug',\n\t\tslug\n\t);\n\n\tif ( presetObject ) {\n\t\tconst { valueKey } = metadata;\n\t\tconst result = presetObject[ valueKey ];\n\t\treturn getValueFromVariable( features, blockName, result );\n\t}\n\n\treturn variable;\n}\n\nfunction getValueFromCustomVariable( features, blockName, variable, path ) {\n\tconst result =\n\t\tgetValueFromObjectPath( features.settings, [\n\t\t\t'blocks',\n\t\t\tblockName,\n\t\t\t'custom',\n\t\t\t...path,\n\t\t] ) ??\n\t\tgetValueFromObjectPath( features.settings, [ 'custom', ...path ] );\n\tif ( ! result ) {\n\t\treturn variable;\n\t}\n\t// A variable may reference another variable so we need recursion until we find the value.\n\treturn getValueFromVariable( features, blockName, result );\n}\n\n/**\n * Attempts to fetch the value of a theme.json CSS variable.\n *\n * @param {Object} features GlobalStylesContext config, e.g., user, base or merged. Represents the theme.json tree.\n * @param {string} blockName The name of a block as represented in the styles property. E.g., 'root' for root-level, and 'core/${blockName}' for blocks.\n * @param {string|*} variable An incoming style value. A CSS var value is expected, but it could be any value.\n * @return {string|*|{ref}} The value of the CSS var, if found. If not found, the passed variable argument.\n */\nexport function getValueFromVariable( features, blockName, variable ) {\n\tif ( ! variable || typeof variable !== 'string' ) {\n\t\tif ( variable?.ref && typeof variable?.ref === 'string' ) {\n\t\t\tconst refPath = variable.ref.split( '.' );\n\t\t\tvariable = getValueFromObjectPath( features, refPath );\n\t\t\t// Presence of another ref indicates a reference to another dynamic value.\n\t\t\t// Pointing to another dynamic value is not supported.\n\t\t\tif ( ! variable || !! variable?.ref ) {\n\t\t\t\treturn variable;\n\t\t\t}\n\t\t} else {\n\t\t\treturn variable;\n\t\t}\n\t}\n\tconst USER_VALUE_PREFIX = 'var:';\n\tconst THEME_VALUE_PREFIX = 'var(--wp--';\n\tconst THEME_VALUE_SUFFIX = ')';\n\n\tlet parsedVar;\n\n\tif ( variable.startsWith( USER_VALUE_PREFIX ) ) {\n\t\tparsedVar = variable.slice( USER_VALUE_PREFIX.length ).split( '|' );\n\t} else if (\n\t\tvariable.startsWith( THEME_VALUE_PREFIX ) &&\n\t\tvariable.endsWith( THEME_VALUE_SUFFIX )\n\t) {\n\t\tparsedVar = variable\n\t\t\t.slice( THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length )\n\t\t\t.split( '--' );\n\t} else {\n\t\t// We don't know how to parse the value: either is raw of uses complex CSS such as `calc(1px * var(--wp--variable) )`\n\t\treturn variable;\n\t}\n\n\tconst [ type, ...path ] = parsedVar;\n\tif ( type === 'preset' ) {\n\t\treturn getValueFromPresetVariable(\n\t\t\tfeatures,\n\t\t\tblockName,\n\t\t\tvariable,\n\t\t\tpath\n\t\t);\n\t}\n\tif ( type === 'custom' ) {\n\t\treturn getValueFromCustomVariable(\n\t\t\tfeatures,\n\t\t\tblockName,\n\t\t\tvariable,\n\t\t\tpath\n\t\t);\n\t}\n\treturn variable;\n}\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nexport function scopeSelector( scope, selector ) {\n\tif ( ! scope || ! selector ) {\n\t\treturn selector;\n\t}\n\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Scopes a collection of selectors for features and subfeatures.\n *\n * @example\n * ```js\n * const scope = '.custom-scope';\n * const selectors = {\n * color: '.wp-my-block p',\n * typography: { fontSize: '.wp-my-block caption' },\n * };\n * const result = scopeFeatureSelector( scope, selectors );\n * // result is {\n * // color: '.custom-scope .wp-my-block p',\n * // typography: { fonSize: '.custom-scope .wp-my-block caption' },\n * // }\n * ```\n *\n * @param {string} scope Selector to scope collection of selectors with.\n * @param {Object} selectors Collection of feature selectors e.g.\n *\n * @return {Object|undefined} Scoped collection of feature selectors.\n */\nexport function scopeFeatureSelectors( scope, selectors ) {\n\tif ( ! scope || ! selectors ) {\n\t\treturn;\n\t}\n\n\tconst featureSelectors = {};\n\n\tObject.entries( selectors ).forEach( ( [ feature, selector ] ) => {\n\t\tif ( typeof selector === 'string' ) {\n\t\t\tfeatureSelectors[ feature ] = scopeSelector( scope, selector );\n\t\t}\n\n\t\tif ( typeof selector === 'object' ) {\n\t\t\tfeatureSelectors[ feature ] = {};\n\n\t\t\tObject.entries( selector ).forEach(\n\t\t\t\t( [ subfeature, subfeatureSelector ] ) => {\n\t\t\t\t\tfeatureSelectors[ feature ][ subfeature ] = scopeSelector(\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tsubfeatureSelector\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn featureSelectors;\n}\n\n/**\n * Appends a sub-selector to an existing one.\n *\n * Given the compounded `selector` \"h1, h2, h3\"\n * and the `toAppend` selector \".some-class\" the result will be\n * \"h1.some-class, h2.some-class, h3.some-class\".\n *\n * @param {string} selector Original selector.\n * @param {string} toAppend Selector to append.\n *\n * @return {string} The new selector.\n */\nexport function appendToSelector( selector, toAppend ) {\n\tif ( ! selector.includes( ',' ) ) {\n\t\treturn selector + toAppend;\n\t}\n\tconst selectors = selector.split( ',' );\n\tconst newSelectors = selectors.map( ( sel ) => sel + toAppend );\n\treturn newSelectors.join( ',' );\n}\n\n/**\n * Compares global style variations according to their styles and settings properties.\n *\n * @example\n * ```js\n * const globalStyles = { styles: { typography: { fontSize: '10px' } }, settings: {} };\n * const variation = { styles: { typography: { fontSize: '10000px' } }, settings: {} };\n * const isEqual = areGlobalStyleConfigsEqual( globalStyles, variation );\n * // false\n * ```\n *\n * @param {Object} original A global styles object.\n * @param {Object} variation A global styles object.\n *\n * @return {boolean} Whether `original` and `variation` match.\n */\nexport function areGlobalStyleConfigsEqual( original, variation ) {\n\tif ( typeof original !== 'object' || typeof variation !== 'object' ) {\n\t\treturn original === variation;\n\t}\n\treturn (\n\t\tfastDeepEqual( original?.styles, variation?.styles ) &&\n\t\tfastDeepEqual( original?.settings, variation?.settings )\n\t);\n}\n\n/**\n * Generates the selector for a block style variation by creating the\n * appropriate CSS class and adding it to the ancestor portion of the block's\n * selector.\n *\n * For example, take the Button block which has a compound selector:\n * `.wp-block-button .wp-block-button__link`. With a variation named 'custom',\n * the class `.is-style-custom` should be added to the `.wp-block-button`\n * ancestor only.\n *\n * This function will take into account comma separated and complex selectors.\n *\n * @param {string} variation Name for the variation.\n * @param {string} blockSelector CSS selector for the block.\n *\n * @return {string} CSS selector for the block style variation.\n */\nexport function getBlockStyleVariationSelector( variation, blockSelector ) {\n\tconst variationClass = `.is-style-${ variation }`;\n\n\tif ( ! blockSelector ) {\n\t\treturn variationClass;\n\t}\n\n\tconst ancestorRegex = /((?::\\([^)]+\\))?\\s*)([^\\s:]+)/;\n\tconst addVariationClass = ( _match, group1, group2 ) => {\n\t\treturn group1 + group2 + variationClass;\n\t};\n\n\tconst result = blockSelector\n\t\t.split( ',' )\n\t\t.map( ( part ) => part.replace( ancestorRegex, addVariationClass ) );\n\n\treturn result.join( ',' );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACO,MAAMI,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,MAAM;AAClC,MAAME,4BAA4B,GAAAD,OAAA,CAAAC,4BAAA,GAAG,OAAO;AAE5C,MAAMC,eAAe,GAAAF,OAAA,CAAAE,eAAA,GAAG,CAC9B;EACCC,IAAI,EAAE,CAAE,OAAO,EAAE,SAAS,CAAE;EAC5BC,QAAQ,EAAE,OAAO;EACjBC,WAAW,EAAE,OAAO;EACpBC,OAAO,EAAE,CACR;IAAEC,WAAW,EAAE,OAAO;IAAEC,YAAY,EAAE;EAAQ,CAAC,EAC/C;IACCD,WAAW,EAAE,kBAAkB;IAC/BC,YAAY,EAAE;EACf,CAAC,EACD;IACCD,WAAW,EAAE,cAAc;IAC3BC,YAAY,EAAE;EACf,CAAC;AAEH,CAAC,EACD;EACCL,IAAI,EAAE,CAAE,OAAO,EAAE,WAAW,CAAE;EAC9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,EAAG;EAC1E,MAAMC,cAAc,GAAI,aAAaL,SAAW,EAAC;EAEjD,IAAK,CAAEI,aAAa,EAAG;IACtB,OAAOC,cAAc;EACtB;EAEA,MAAMC,aAAa,GAAG,+BAA+B;EACrD,MAAMC,iBAAiB,GAAGA,CAAEC,MAAM,EAAEC,MAAM,EAAEC,MAAM,KAAM;IACvD,OAAOD,MAAM,GAAGC,MAAM,GAAGL,cAAc;EACxC,CAAC;EAED,MAAMhD,MAAM,GAAG+C,aAAa,CAC1BzC,KAAK,CAAE,GAAI,CAAC,CACZiC,GAAG,CAAIe,IAAI,IAAMA,IAAI,CAACC,OAAO,CAAEN,aAAa,EAAEC,iBAAkB,CAAE,CAAC;EAErE,OAAOlD,MAAM,CAAC2B,IAAI,CAAE,GAAI,CAAC;AAC1B","ignoreList":[]}
|
|
@@ -33,6 +33,7 @@ function BlockSupportToolsPanel({
|
|
|
33
33
|
getSelectedBlockClientId,
|
|
34
34
|
hasMultiSelection
|
|
35
35
|
} = (0, _data.useSelect)(_store.store);
|
|
36
|
+
const dropdownMenuProps = (0, _utils2.useToolsPanelDropdownMenuProps)();
|
|
36
37
|
const panelId = getSelectedBlockClientId();
|
|
37
38
|
const resetAll = (0, _element.useCallback)((resetFilters = []) => {
|
|
38
39
|
const newAttributes = {};
|
|
@@ -70,7 +71,7 @@ function BlockSupportToolsPanel({
|
|
|
70
71
|
,
|
|
71
72
|
__experimentalFirstVisibleItemClass: "first",
|
|
72
73
|
__experimentalLastVisibleItemClass: "last",
|
|
73
|
-
dropdownMenuProps:
|
|
74
|
+
dropdownMenuProps: dropdownMenuProps,
|
|
74
75
|
children: children
|
|
75
76
|
}, panelId);
|
|
76
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_data","_element","_store","_utils","_utils2","_jsxRuntime","BlockSupportToolsPanel","children","group","label","updateBlockAttributes","useDispatch","blockEditorStore","getBlockAttributes","getMultiSelectedBlockClientIds","getSelectedBlockClientId","hasMultiSelection","useSelect","panelId","resetAll","useCallback","resetFilters","newAttributes","clientIds","forEach","clientId","style","newBlockAttributes","resetFilter","cleanEmptyObject","jsx","__experimentalToolsPanel","className","hasInnerWrapper","shouldRenderPlaceholderItems","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass"
|
|
1
|
+
{"version":3,"names":["_components","require","_data","_element","_store","_utils","_utils2","_jsxRuntime","BlockSupportToolsPanel","children","group","label","updateBlockAttributes","useDispatch","blockEditorStore","getBlockAttributes","getMultiSelectedBlockClientIds","getSelectedBlockClientId","hasMultiSelection","useSelect","dropdownMenuProps","useToolsPanelDropdownMenuProps","panelId","resetAll","useCallback","resetFilters","newAttributes","clientIds","forEach","clientId","style","newBlockAttributes","resetFilter","cleanEmptyObject","jsx","__experimentalToolsPanel","className","hasInnerWrapper","shouldRenderPlaceholderItems","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass"],"sources":["@wordpress/block-editor/src/components/inspector-controls/block-support-tools-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalToolsPanel as ToolsPanel } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { cleanEmptyObject } from '../../hooks/utils';\nimport { useToolsPanelDropdownMenuProps } from '../global-styles/utils';\n\nexport default function BlockSupportToolsPanel( { children, group, label } ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockAttributes,\n\t\tgetMultiSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\thasMultiSelection,\n\t} = useSelect( blockEditorStore );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst panelId = getSelectedBlockClientId();\n\tconst resetAll = useCallback(\n\t\t( resetFilters = [] ) => {\n\t\t\tconst newAttributes = {};\n\n\t\t\tconst clientIds = hasMultiSelection()\n\t\t\t\t? getMultiSelectedBlockClientIds()\n\t\t\t\t: [ panelId ];\n\n\t\t\tclientIds.forEach( ( clientId ) => {\n\t\t\t\tconst { style } = getBlockAttributes( clientId );\n\t\t\t\tlet newBlockAttributes = { style };\n\n\t\t\t\tresetFilters.forEach( ( resetFilter ) => {\n\t\t\t\t\tnewBlockAttributes = {\n\t\t\t\t\t\t...newBlockAttributes,\n\t\t\t\t\t\t...resetFilter( newBlockAttributes ),\n\t\t\t\t\t};\n\t\t\t\t} );\n\n\t\t\t\t// Enforce a cleaned style object.\n\t\t\t\tnewBlockAttributes = {\n\t\t\t\t\t...newBlockAttributes,\n\t\t\t\t\tstyle: cleanEmptyObject( newBlockAttributes.style ),\n\t\t\t\t};\n\n\t\t\t\tnewAttributes[ clientId ] = newBlockAttributes;\n\t\t\t} );\n\n\t\t\tupdateBlockAttributes( clientIds, newAttributes, true );\n\t\t},\n\t\t[\n\t\t\tgetBlockAttributes,\n\t\t\tgetMultiSelectedBlockClientIds,\n\t\t\thasMultiSelection,\n\t\t\tpanelId,\n\t\t\tupdateBlockAttributes,\n\t\t]\n\t);\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tclassName={ `${ group }-block-support-panel` }\n\t\t\tlabel={ label }\n\t\t\tresetAll={ resetAll }\n\t\t\tkey={ panelId }\n\t\t\tpanelId={ panelId }\n\t\t\thasInnerWrapper\n\t\t\tshouldRenderPlaceholderItems // Required to maintain fills ordering.\n\t\t\t__experimentalFirstVisibleItemClass=\"first\"\n\t\t\t__experimentalLastVisibleItemClass=\"last\"\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,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AC;EACxD,CAAC,EACD,CACCX,kBAAkB,EAClBC,8BAA8B,EAC9BE,iBAAiB,EACjBI,OAAO,EACPV,qBAAqB,CAEvB,CAAC;EAED,oBACC,IAAAL,WAAA,CAAA2B,GAAA,EAAClC,WAAA,CAAAmC,wBAAU;IACVC,SAAS,EAAI,GAAG1B,KAAO,sBAAuB;IAC9CC,KAAK,EAAGA,KAAO;IACfY,QAAQ,EAAGA,QAAU;IAErBD,OAAO,EAAGA,OAAS;IACnBe,eAAe;IACfC,4BAA4B,OAAC;IAAA;IAC7BC,mCAAmC,EAAC,OAAO;IAC3CC,kCAAkC,EAAC,MAAM;IACzCpB,iBAAiB,EAAGA,iBAAmB;IAAAX,QAAA,EAErCA;EAAQ,GARJa,OASK,CAAC;AAEf","ignoreList":[]}
|
|
@@ -3,14 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.__unstableBlockStyleVariationOverridesWithConfig = __unstableBlockStyleVariationOverridesWithConfig;
|
|
6
7
|
exports.default = void 0;
|
|
8
|
+
exports.getVariationStylesWithRefValues = getVariationStylesWithRefValues;
|
|
7
9
|
var _blocks = require("@wordpress/blocks");
|
|
8
10
|
var _data = require("@wordpress/data");
|
|
9
11
|
var _element = require("@wordpress/element");
|
|
10
12
|
var _globalStyles = require("../components/global-styles");
|
|
11
13
|
var _utils = require("./utils");
|
|
14
|
+
var _object = require("../utils/object");
|
|
12
15
|
var _store = require("../store");
|
|
13
16
|
var _privateKeys = require("../store/private-keys");
|
|
17
|
+
var _lockUnlock = require("../lock-unlock");
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
19
|
/**
|
|
15
20
|
* WordPress dependencies
|
|
16
21
|
*/
|
|
@@ -57,7 +62,164 @@ function getVariationNameFromClass(className, registeredStyles = []) {
|
|
|
57
62
|
}
|
|
58
63
|
return null;
|
|
59
64
|
}
|
|
60
|
-
|
|
65
|
+
|
|
66
|
+
// A helper component to apply a style override using the useStyleOverride hook.
|
|
67
|
+
function OverrideStyles({
|
|
68
|
+
override
|
|
69
|
+
}) {
|
|
70
|
+
(0, _utils.useStyleOverride)(override);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* This component is used to generate new block style variation overrides
|
|
75
|
+
* based on an incoming theme config. If a matching style is found in the config,
|
|
76
|
+
* a new override is created and returned. The overrides can be used in conjunction with
|
|
77
|
+
* useStyleOverride to apply the new styles to the editor. Its use is
|
|
78
|
+
* subject to change.
|
|
79
|
+
*
|
|
80
|
+
* @param {Object} props Props.
|
|
81
|
+
* @param {Object} props.config A global styles object, containing settings and styles.
|
|
82
|
+
* @return {JSX.Element|undefined} An array of new block variation overrides.
|
|
83
|
+
*/
|
|
84
|
+
function __unstableBlockStyleVariationOverridesWithConfig({
|
|
85
|
+
config
|
|
86
|
+
}) {
|
|
87
|
+
const {
|
|
88
|
+
getBlockStyles,
|
|
89
|
+
overrides
|
|
90
|
+
} = (0, _data.useSelect)(select => ({
|
|
91
|
+
getBlockStyles: select(_blocks.store).getBlockStyles,
|
|
92
|
+
overrides: (0, _lockUnlock.unlock)(select(_store.store)).getStyleOverrides()
|
|
93
|
+
}), []);
|
|
94
|
+
const {
|
|
95
|
+
getBlockName
|
|
96
|
+
} = (0, _data.useSelect)(_store.store);
|
|
97
|
+
const overridesWithConfig = (0, _element.useMemo)(() => {
|
|
98
|
+
if (!overrides?.length) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const newOverrides = [];
|
|
102
|
+
const overriddenClientIds = [];
|
|
103
|
+
for (const [, override] of overrides) {
|
|
104
|
+
if (override?.variation && override?.clientId &&
|
|
105
|
+
/*
|
|
106
|
+
* Because this component overwrites existing style overrides,
|
|
107
|
+
* filter out any overrides that are already present in the store.
|
|
108
|
+
*/
|
|
109
|
+
!overriddenClientIds.includes(override.clientId)) {
|
|
110
|
+
const blockName = getBlockName(override.clientId);
|
|
111
|
+
const configStyles = config?.styles?.blocks?.[blockName]?.variations?.[override.variation];
|
|
112
|
+
if (configStyles) {
|
|
113
|
+
const variationConfig = {
|
|
114
|
+
settings: config?.settings,
|
|
115
|
+
// The variation style data is all that is needed to generate
|
|
116
|
+
// the styles for the current application to a block. The variation
|
|
117
|
+
// name is updated to match the instance specific class name.
|
|
118
|
+
styles: {
|
|
119
|
+
blocks: {
|
|
120
|
+
[blockName]: {
|
|
121
|
+
variations: {
|
|
122
|
+
[`${override.variation}-${override.clientId}`]: configStyles
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const blockSelectors = (0, _globalStyles.getBlockSelectors)((0, _blocks.getBlockTypes)(), getBlockStyles, override.clientId);
|
|
129
|
+
const hasBlockGapSupport = false;
|
|
130
|
+
const hasFallbackGapSupport = true;
|
|
131
|
+
const disableLayoutStyles = true;
|
|
132
|
+
const disableRootPadding = true;
|
|
133
|
+
const variationStyles = (0, _globalStyles.toStyles)(variationConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles, disableRootPadding, {
|
|
134
|
+
blockGap: false,
|
|
135
|
+
blockStyles: true,
|
|
136
|
+
layoutStyles: false,
|
|
137
|
+
marginReset: false,
|
|
138
|
+
presets: false,
|
|
139
|
+
rootPadding: false,
|
|
140
|
+
variationStyles: true
|
|
141
|
+
});
|
|
142
|
+
newOverrides.push({
|
|
143
|
+
id: `${override.variation}-${override.clientId}`,
|
|
144
|
+
css: variationStyles,
|
|
145
|
+
__unstableType: 'variation',
|
|
146
|
+
variation: override.variation,
|
|
147
|
+
// The clientId will be stored with the override and used to ensure
|
|
148
|
+
// the order of overrides matches the order of blocks so that the
|
|
149
|
+
// correct CSS cascade is maintained.
|
|
150
|
+
clientId: override.clientId
|
|
151
|
+
});
|
|
152
|
+
overriddenClientIds.push(override.clientId);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return newOverrides;
|
|
157
|
+
}, [config, overrides, getBlockStyles, getBlockName]);
|
|
158
|
+
if (!overridesWithConfig || !overridesWithConfig.length) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
162
|
+
children: overridesWithConfig.map(override => /*#__PURE__*/(0, _jsxRuntime.jsx)(OverrideStyles, {
|
|
163
|
+
override: override
|
|
164
|
+
}, override.id))
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Retrieves any variation styles data and resolves any referenced values.
|
|
170
|
+
*
|
|
171
|
+
* @param {Object} globalStyles A complete global styles object, containing settings and styles.
|
|
172
|
+
* @param {string} name The name of the desired block type.
|
|
173
|
+
* @param {variation} variation The of the block style variation to retrieve data for.
|
|
174
|
+
*
|
|
175
|
+
* @return {Object|undefined} The global styles data for the specified variation.
|
|
176
|
+
*/
|
|
177
|
+
function getVariationStylesWithRefValues(globalStyles, name, variation) {
|
|
178
|
+
if (!globalStyles?.styles?.blocks?.[name]?.variations?.[variation]) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Helper to recursively look for `ref` values to resolve.
|
|
183
|
+
const replaceRefs = variationStyles => {
|
|
184
|
+
Object.keys(variationStyles).forEach(key => {
|
|
185
|
+
const value = variationStyles[key];
|
|
186
|
+
|
|
187
|
+
// Only process objects.
|
|
188
|
+
if (typeof value === 'object' && value !== null) {
|
|
189
|
+
// Process `ref` value if present.
|
|
190
|
+
if (value.ref !== undefined) {
|
|
191
|
+
if (typeof value.ref !== 'string' || value.ref.trim() === '') {
|
|
192
|
+
// Remove invalid ref.
|
|
193
|
+
delete variationStyles[key];
|
|
194
|
+
} else {
|
|
195
|
+
// Resolve `ref` value.
|
|
196
|
+
const refValue = (0, _object.getValueFromObjectPath)(globalStyles, value.ref);
|
|
197
|
+
if (refValue) {
|
|
198
|
+
variationStyles[key] = refValue;
|
|
199
|
+
} else {
|
|
200
|
+
delete variationStyles[key];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
} else {
|
|
204
|
+
// Recursively resolve `ref` values in nested objects.
|
|
205
|
+
replaceRefs(value);
|
|
206
|
+
|
|
207
|
+
// After recursion, if value is empty due to explicitly
|
|
208
|
+
// `undefined` ref value, remove it.
|
|
209
|
+
if (Object.keys(value).length === 0) {
|
|
210
|
+
delete variationStyles[key];
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// Deep clone variation node to avoid mutating it within global styles and losing refs.
|
|
218
|
+
const styles = JSON.parse(JSON.stringify(globalStyles.styles.blocks[name].variations[variation]));
|
|
219
|
+
replaceRefs(styles);
|
|
220
|
+
return styles;
|
|
221
|
+
}
|
|
222
|
+
function useBlockStyleVariation(name, variation, clientId) {
|
|
61
223
|
// Prefer global styles data in GlobalStylesContext, which are available
|
|
62
224
|
// if in the site editor. Otherwise fall back to whatever is in the
|
|
63
225
|
// editor settings and available in the post editor.
|
|
@@ -75,11 +237,13 @@ function useBlockSyleVariation(name, variation, clientId) {
|
|
|
75
237
|
};
|
|
76
238
|
}, []);
|
|
77
239
|
return (0, _element.useMemo)(() => {
|
|
78
|
-
var _mergedConfig$styles, _mergedConfig$
|
|
79
|
-
const
|
|
80
|
-
const variationStyles = styles?.blocks?.[name]?.variations?.[variation];
|
|
81
|
-
return {
|
|
240
|
+
var _mergedConfig$setting, _mergedConfig$styles, _mergedConfig$setting2;
|
|
241
|
+
const variationStyles = getVariationStylesWithRefValues({
|
|
82
242
|
settings: (_mergedConfig$setting = mergedConfig?.settings) !== null && _mergedConfig$setting !== void 0 ? _mergedConfig$setting : globalSettings,
|
|
243
|
+
styles: (_mergedConfig$styles = mergedConfig?.styles) !== null && _mergedConfig$styles !== void 0 ? _mergedConfig$styles : globalStyles
|
|
244
|
+
}, name, variation);
|
|
245
|
+
return {
|
|
246
|
+
settings: (_mergedConfig$setting2 = mergedConfig?.settings) !== null && _mergedConfig$setting2 !== void 0 ? _mergedConfig$setting2 : globalSettings,
|
|
83
247
|
// The variation style data is all that is needed to generate
|
|
84
248
|
// the styles for the current application to a block. The variation
|
|
85
249
|
// name is updated to match the instance specific class name.
|
|
@@ -113,7 +277,7 @@ function useBlockProps({
|
|
|
113
277
|
const {
|
|
114
278
|
settings,
|
|
115
279
|
styles
|
|
116
|
-
} =
|
|
280
|
+
} = useBlockStyleVariation(name, variation, clientId);
|
|
117
281
|
const variationStyles = (0, _element.useMemo)(() => {
|
|
118
282
|
if (!variation) {
|
|
119
283
|
return;
|
|
@@ -141,6 +305,7 @@ function useBlockProps({
|
|
|
141
305
|
id: `variation-${clientId}`,
|
|
142
306
|
css: variationStyles,
|
|
143
307
|
__unstableType: 'variation',
|
|
308
|
+
variation,
|
|
144
309
|
// The clientId will be stored with the override and used to ensure
|
|
145
310
|
// the order of overrides matches the order of blocks so that the
|
|
146
311
|
// correct CSS cascade is maintained.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_data","_element","_globalStyles","_utils","_store","_privateKeys","VARIATION_PREFIX","getVariationMatches","className","split","reduce","matches","name","startsWith","match","slice","length","push","getVariationNameFromClass","registeredStyles","variation","some","style","useBlockSyleVariation","clientId","merged","mergedConfig","useContext","GlobalStylesContext","globalSettings","globalStyles","useSelect","select","settings","blockEditorStore","getSettings","__experimentalFeatures","globalStylesDataKey","useMemo","_mergedConfig$styles","_mergedConfig$setting","styles","variationStyles","blocks","variations","useBlockProps","getBlockStyles","blocksStore","variationClass","variationConfig","blockSelectors","getBlockSelectors","getBlockTypes","hasBlockGapSupport","hasFallbackGapSupport","disableLayoutStyles","disableRootPadding","toStyles","blockGap","blockStyles","layoutStyles","marginReset","presets","rootPadding","useStyleOverride","id","css","__unstableType","_default","exports","default","hasSupport","attributeKeys","isMatch"],"sources":["@wordpress/block-editor/src/hooks/block-style-variation.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockTypes, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tGlobalStylesContext,\n\ttoStyles,\n\tgetBlockSelectors,\n} from '../components/global-styles';\nimport { useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport { globalStylesDataKey } from '../store/private-keys';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nfunction getVariationMatches( className ) {\n\tif ( ! className ) {\n\t\treturn [];\n\t}\n\treturn className.split( /\\s+/ ).reduce( ( matches, name ) => {\n\t\tif ( name.startsWith( VARIATION_PREFIX ) ) {\n\t\t\tconst match = name.slice( VARIATION_PREFIX.length );\n\t\t\tif ( match !== 'default' ) {\n\t\t\t\tmatches.push( match );\n\t\t\t}\n\t\t}\n\t\treturn matches;\n\t}, [] );\n}\n\n/**\n * Get the first block style variation that has been registered from the class string.\n *\n * @param {string} className CSS class string for a block.\n * @param {Array} registeredStyles Currently registered block styles.\n *\n * @return {string|null} The name of the first registered variation.\n */\nfunction getVariationNameFromClass( className, registeredStyles = [] ) {\n\t// The global flag affects how capturing groups work in JS. So the regex\n\t// below will only return full CSS classes not just the variation name.\n\tconst matches = getVariationMatches( className );\n\n\tif ( ! matches ) {\n\t\treturn null;\n\t}\n\n\tfor ( const variation of matches ) {\n\t\tif ( registeredStyles.some( ( style ) => style.name === variation ) ) {\n\t\t\treturn variation;\n\t\t}\n\t}\n\treturn null;\n}\n\nfunction useBlockSyleVariation( name, variation, clientId ) {\n\t// Prefer global styles data in GlobalStylesContext, which are available\n\t// if in the site editor. Otherwise fall back to whatever is in the\n\t// editor settings and available in the post editor.\n\tconst { merged: mergedConfig } = useContext( GlobalStylesContext );\n\tconst { globalSettings, globalStyles } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tglobalSettings: settings.__experimentalFeatures,\n\t\t\tglobalStyles: settings[ globalStylesDataKey ],\n\t\t};\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\tconst styles = mergedConfig?.styles ?? globalStyles;\n\t\tconst variationStyles =\n\t\t\tstyles?.blocks?.[ name ]?.variations?.[ variation ];\n\n\t\treturn {\n\t\t\tsettings: mergedConfig?.settings ?? globalSettings,\n\t\t\t// The variation style data is all that is needed to generate\n\t\t\t// the styles for the current application to a block. The variation\n\t\t\t// name is updated to match the instance specific class name.\n\t\t\tstyles: {\n\t\t\t\tblocks: {\n\t\t\t\t\t[ name ]: {\n\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t[ `${ variation }-${ clientId }` ]: variationStyles,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, [\n\t\tmergedConfig,\n\t\tglobalSettings,\n\t\tglobalStyles,\n\t\tvariation,\n\t\tclientId,\n\t\tname,\n\t] );\n}\n\n// Rather than leveraging `useInstanceId` here, the `clientId` is used.\n// This is so that the variation style override's ID is predictable\n// when the order of applied style variations changes.\nfunction useBlockProps( { name, className, clientId } ) {\n\tconst { getBlockStyles } = useSelect( blocksStore );\n\n\tconst registeredStyles = getBlockStyles( name );\n\tconst variation = getVariationNameFromClass( className, registeredStyles );\n\tconst variationClass = `${ VARIATION_PREFIX }${ variation }-${ clientId }`;\n\n\tconst { settings, styles } = useBlockSyleVariation(\n\t\tname,\n\t\tvariation,\n\t\tclientId\n\t);\n\n\tconst variationStyles = useMemo( () => {\n\t\tif ( ! variation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst variationConfig = { settings, styles };\n\t\tconst blockSelectors = getBlockSelectors(\n\t\t\tgetBlockTypes(),\n\t\t\tgetBlockStyles,\n\t\t\tclientId\n\t\t);\n\t\tconst hasBlockGapSupport = false;\n\t\tconst hasFallbackGapSupport = true;\n\t\tconst disableLayoutStyles = true;\n\t\tconst disableRootPadding = true;\n\n\t\treturn toStyles(\n\t\t\tvariationConfig,\n\t\t\tblockSelectors,\n\t\t\thasBlockGapSupport,\n\t\t\thasFallbackGapSupport,\n\t\t\tdisableLayoutStyles,\n\t\t\tdisableRootPadding,\n\t\t\t{\n\t\t\t\tblockGap: false,\n\t\t\t\tblockStyles: true,\n\t\t\t\tlayoutStyles: false,\n\t\t\t\tmarginReset: false,\n\t\t\t\tpresets: false,\n\t\t\t\trootPadding: false,\n\t\t\t\tvariationStyles: true,\n\t\t\t}\n\t\t);\n\t}, [ variation, settings, styles, getBlockStyles, clientId ] );\n\n\tuseStyleOverride( {\n\t\tid: `variation-${ clientId }`,\n\t\tcss: variationStyles,\n\t\t__unstableType: 'variation',\n\t\t// The clientId will be stored with the override and used to ensure\n\t\t// the order of overrides matches the order of blocks so that the\n\t\t// correct CSS cascade is maintained.\n\t\tclientId,\n\t} );\n\n\treturn variation ? { className: variationClass } : {};\n}\n\nexport default {\n\thasSupport: () => true,\n\tattributeKeys: [ 'className' ],\n\tisMatch: ( { className } ) => getVariationMatches( className ).length > 0,\n\tuseBlockProps,\n};\n"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAjBA;AACA;AACA;;AAKA;AACA;AACA;;AAUA,MAAMO,gBAAgB,GAAG,WAAW;AAEpC,SAASC,mBAAmBA,CAAEC,SAAS,EAAG;EACzC,IAAK,CAAEA,SAAS,EAAG;IAClB,OAAO,EAAE;EACV;EACA,OAAOA,SAAS,CAACC,KAAK,CAAE,KAAM,CAAC,CAACC,MAAM,CAAE,CAAEC,OAAO,EAAEC,IAAI,KAAM;IAC5D,IAAKA,IAAI,CAACC,UAAU,CAAEP,gB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C,MAAMS,cAAc,GAAG,IAAAC,+BAAiB,EACvC,IAAAC,qBAAa,EAAC,CAAC,EACfN,cAAc,EACdtB,QACD,CAAC;IACD,MAAM6B,kBAAkB,GAAG,KAAK;IAChC,MAAMC,qBAAqB,GAAG,IAAI;IAClC,MAAMC,mBAAmB,GAAG,IAAI;IAChC,MAAMC,kBAAkB,GAAG,IAAI;IAE/B,OAAO,IAAAC,sBAAQ,EACdR,eAAe,EACfC,cAAc,EACdG,kBAAkB,EAClBC,qBAAqB,EACrBC,mBAAmB,EACnBC,kBAAkB,EAClB;MACCE,QAAQ,EAAE,KAAK;MACfC,WAAW,EAAE,IAAI;MACjBC,YAAY,EAAE,KAAK;MACnBC,WAAW,EAAE,KAAK;MAClBC,OAAO,EAAE,KAAK;MACdC,WAAW,EAAE,KAAK;MAClBrB,eAAe,EAAE;IAClB,CACD,CAAC;EACF,CAAC,EAAE,CAAEtB,SAAS,EAAEa,QAAQ,EAAEQ,MAAM,EAAEK,cAAc,EAAEtB,QAAQ,CAAG,CAAC;EAE9D,IAAAwC,uBAAgB,EAAE;IACjBC,EAAE,EAAG,aAAazC,QAAU,EAAC;IAC7B0C,GAAG,EAAExB,eAAe;IACpByB,cAAc,EAAE,WAAW;IAC3B;IACA;IACA;IACA3C;EACD,CAAE,CAAC;EAEH,OAAOJ,SAAS,GAAG;IAAEZ,SAAS,EAAEwC;EAAe,CAAC,GAAG,CAAC,CAAC;AACtD;AAAC,IAAAoB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc;EACdC,UAAU,EAAEA,CAAA,KAAM,IAAI;EACtBC,aAAa,EAAE,CAAE,WAAW,CAAE;EAC9BC,OAAO,EAAEA,CAAE;IAAEjE;EAAU,CAAC,KAAMD,mBAAmB,CAAEC,SAAU,CAAC,CAACQ,MAAM,GAAG,CAAC;EACzE6B;AACD,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_blocks","require","_data","_element","_globalStyles","_utils","_object","_store","_privateKeys","_lockUnlock","_jsxRuntime","VARIATION_PREFIX","getVariationMatches","className","split","reduce","matches","name","startsWith","match","slice","length","push","getVariationNameFromClass","registeredStyles","variation","some","style","OverrideStyles","override","useStyleOverride","__unstableBlockStyleVariationOverridesWithConfig","config","getBlockStyles","overrides","useSelect","select","blocksStore","unlock","blockEditorStore","getStyleOverrides","getBlockName","overridesWithConfig","useMemo","newOverrides","overriddenClientIds","clientId","includes","blockName","configStyles","styles","blocks","variations","variationConfig","settings","blockSelectors","getBlockSelectors","getBlockTypes","hasBlockGapSupport","hasFallbackGapSupport","disableLayoutStyles","disableRootPadding","variationStyles","toStyles","blockGap","blockStyles","layoutStyles","marginReset","presets","rootPadding","id","css","__unstableType","jsx","Fragment","children","map","getVariationStylesWithRefValues","globalStyles","replaceRefs","Object","keys","forEach","key","value","ref","undefined","trim","refValue","getValueFromObjectPath","JSON","parse","stringify","useBlockStyleVariation","merged","mergedConfig","useContext","GlobalStylesContext","globalSettings","getSettings","__experimentalFeatures","globalStylesDataKey","_mergedConfig$setting","_mergedConfig$styles","_mergedConfig$setting2","useBlockProps","variationClass","_default","exports","default","hasSupport","attributeKeys","isMatch"],"sources":["@wordpress/block-editor/src/hooks/block-style-variation.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockTypes, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tGlobalStylesContext,\n\ttoStyles,\n\tgetBlockSelectors,\n} from '../components/global-styles';\nimport { useStyleOverride } from './utils';\nimport { getValueFromObjectPath } from '../utils/object';\nimport { store as blockEditorStore } from '../store';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { unlock } from '../lock-unlock';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nfunction getVariationMatches( className ) {\n\tif ( ! className ) {\n\t\treturn [];\n\t}\n\treturn className.split( /\\s+/ ).reduce( ( matches, name ) => {\n\t\tif ( name.startsWith( VARIATION_PREFIX ) ) {\n\t\t\tconst match = name.slice( VARIATION_PREFIX.length );\n\t\t\tif ( match !== 'default' ) {\n\t\t\t\tmatches.push( match );\n\t\t\t}\n\t\t}\n\t\treturn matches;\n\t}, [] );\n}\n\n/**\n * Get the first block style variation that has been registered from the class string.\n *\n * @param {string} className CSS class string for a block.\n * @param {Array} registeredStyles Currently registered block styles.\n *\n * @return {string|null} The name of the first registered variation.\n */\nfunction getVariationNameFromClass( className, registeredStyles = [] ) {\n\t// The global flag affects how capturing groups work in JS. So the regex\n\t// below will only return full CSS classes not just the variation name.\n\tconst matches = getVariationMatches( className );\n\n\tif ( ! matches ) {\n\t\treturn null;\n\t}\n\n\tfor ( const variation of matches ) {\n\t\tif ( registeredStyles.some( ( style ) => style.name === variation ) ) {\n\t\t\treturn variation;\n\t\t}\n\t}\n\treturn null;\n}\n\n// A helper component to apply a style override using the useStyleOverride hook.\nfunction OverrideStyles( { override } ) {\n\tuseStyleOverride( override );\n}\n\n/**\n * This component is used to generate new block style variation overrides\n * based on an incoming theme config. If a matching style is found in the config,\n * a new override is created and returned. The overrides can be used in conjunction with\n * useStyleOverride to apply the new styles to the editor. Its use is\n * subject to change.\n *\n * @param {Object} props Props.\n * @param {Object} props.config A global styles object, containing settings and styles.\n * @return {JSX.Element|undefined} An array of new block variation overrides.\n */\nexport function __unstableBlockStyleVariationOverridesWithConfig( { config } ) {\n\tconst { getBlockStyles, overrides } = useSelect(\n\t\t( select ) => ( {\n\t\t\tgetBlockStyles: select( blocksStore ).getBlockStyles,\n\t\t\toverrides: unlock( select( blockEditorStore ) ).getStyleOverrides(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getBlockName } = useSelect( blockEditorStore );\n\n\tconst overridesWithConfig = useMemo( () => {\n\t\tif ( ! overrides?.length ) {\n\t\t\treturn;\n\t\t}\n\t\tconst newOverrides = [];\n\t\tconst overriddenClientIds = [];\n\t\tfor ( const [ , override ] of overrides ) {\n\t\t\tif (\n\t\t\t\toverride?.variation &&\n\t\t\t\toverride?.clientId &&\n\t\t\t\t/*\n\t\t\t\t * Because this component overwrites existing style overrides,\n\t\t\t\t * filter out any overrides that are already present in the store.\n\t\t\t\t */\n\t\t\t\t! overriddenClientIds.includes( override.clientId )\n\t\t\t) {\n\t\t\t\tconst blockName = getBlockName( override.clientId );\n\t\t\t\tconst configStyles =\n\t\t\t\t\tconfig?.styles?.blocks?.[ blockName ]?.variations?.[\n\t\t\t\t\t\toverride.variation\n\t\t\t\t\t];\n\t\t\t\tif ( configStyles ) {\n\t\t\t\t\tconst variationConfig = {\n\t\t\t\t\t\tsettings: config?.settings,\n\t\t\t\t\t\t// The variation style data is all that is needed to generate\n\t\t\t\t\t\t// the styles for the current application to a block. The variation\n\t\t\t\t\t\t// name is updated to match the instance specific class name.\n\t\t\t\t\t\tstyles: {\n\t\t\t\t\t\t\tblocks: {\n\t\t\t\t\t\t\t\t[ blockName ]: {\n\t\t\t\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t\t\t\t[ `${ override.variation }-${ override.clientId }` ]:\n\t\t\t\t\t\t\t\t\t\t\tconfigStyles,\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};\n\t\t\t\t\tconst blockSelectors = getBlockSelectors(\n\t\t\t\t\t\tgetBlockTypes(),\n\t\t\t\t\t\tgetBlockStyles,\n\t\t\t\t\t\toverride.clientId\n\t\t\t\t\t);\n\t\t\t\t\tconst hasBlockGapSupport = false;\n\t\t\t\t\tconst hasFallbackGapSupport = true;\n\t\t\t\t\tconst disableLayoutStyles = true;\n\t\t\t\t\tconst disableRootPadding = true;\n\t\t\t\t\tconst variationStyles = toStyles(\n\t\t\t\t\t\tvariationConfig,\n\t\t\t\t\t\tblockSelectors,\n\t\t\t\t\t\thasBlockGapSupport,\n\t\t\t\t\t\thasFallbackGapSupport,\n\t\t\t\t\t\tdisableLayoutStyles,\n\t\t\t\t\t\tdisableRootPadding,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tblockGap: false,\n\t\t\t\t\t\t\tblockStyles: true,\n\t\t\t\t\t\t\tlayoutStyles: false,\n\t\t\t\t\t\t\tmarginReset: false,\n\t\t\t\t\t\t\tpresets: false,\n\t\t\t\t\t\t\trootPadding: false,\n\t\t\t\t\t\t\tvariationStyles: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tnewOverrides.push( {\n\t\t\t\t\t\tid: `${ override.variation }-${ override.clientId }`,\n\t\t\t\t\t\tcss: variationStyles,\n\t\t\t\t\t\t__unstableType: 'variation',\n\t\t\t\t\t\tvariation: override.variation,\n\t\t\t\t\t\t// The clientId will be stored with the override and used to ensure\n\t\t\t\t\t\t// the order of overrides matches the order of blocks so that the\n\t\t\t\t\t\t// correct CSS cascade is maintained.\n\t\t\t\t\t\tclientId: override.clientId,\n\t\t\t\t\t} );\n\t\t\t\t\toverriddenClientIds.push( override.clientId );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn newOverrides;\n\t}, [ config, overrides, getBlockStyles, getBlockName ] );\n\n\tif ( ! overridesWithConfig || ! overridesWithConfig.length ) {\n\t\treturn;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ overridesWithConfig.map( ( override ) => (\n\t\t\t\t<OverrideStyles key={ override.id } override={ override } />\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\n/**\n * Retrieves any variation styles data and resolves any referenced values.\n *\n * @param {Object} globalStyles A complete global styles object, containing settings and styles.\n * @param {string} name The name of the desired block type.\n * @param {variation} variation The of the block style variation to retrieve data for.\n *\n * @return {Object|undefined} The global styles data for the specified variation.\n */\nexport function getVariationStylesWithRefValues(\n\tglobalStyles,\n\tname,\n\tvariation\n) {\n\tif ( ! globalStyles?.styles?.blocks?.[ name ]?.variations?.[ variation ] ) {\n\t\treturn;\n\t}\n\n\t// Helper to recursively look for `ref` values to resolve.\n\tconst replaceRefs = ( variationStyles ) => {\n\t\tObject.keys( variationStyles ).forEach( ( key ) => {\n\t\t\tconst value = variationStyles[ key ];\n\n\t\t\t// Only process objects.\n\t\t\tif ( typeof value === 'object' && value !== null ) {\n\t\t\t\t// Process `ref` value if present.\n\t\t\t\tif ( value.ref !== undefined ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof value.ref !== 'string' ||\n\t\t\t\t\t\tvalue.ref.trim() === ''\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Remove invalid ref.\n\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Resolve `ref` value.\n\t\t\t\t\t\tconst refValue = getValueFromObjectPath(\n\t\t\t\t\t\t\tglobalStyles,\n\t\t\t\t\t\t\tvalue.ref\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( refValue ) {\n\t\t\t\t\t\t\tvariationStyles[ key ] = refValue;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Recursively resolve `ref` values in nested objects.\n\t\t\t\t\treplaceRefs( value );\n\n\t\t\t\t\t// After recursion, if value is empty due to explicitly\n\t\t\t\t\t// `undefined` ref value, remove it.\n\t\t\t\t\tif ( Object.keys( value ).length === 0 ) {\n\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t};\n\n\t// Deep clone variation node to avoid mutating it within global styles and losing refs.\n\tconst styles = JSON.parse(\n\t\tJSON.stringify(\n\t\t\tglobalStyles.styles.blocks[ name ].variations[ variation ]\n\t\t)\n\t);\n\treplaceRefs( styles );\n\n\treturn styles;\n}\n\nfunction useBlockStyleVariation( name, variation, clientId ) {\n\t// Prefer global styles data in GlobalStylesContext, which are available\n\t// if in the site editor. Otherwise fall back to whatever is in the\n\t// editor settings and available in the post editor.\n\tconst { merged: mergedConfig } = useContext( GlobalStylesContext );\n\tconst { globalSettings, globalStyles } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tglobalSettings: settings.__experimentalFeatures,\n\t\t\tglobalStyles: settings[ globalStylesDataKey ],\n\t\t};\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\tconst variationStyles = getVariationStylesWithRefValues(\n\t\t\t{\n\t\t\t\tsettings: mergedConfig?.settings ?? globalSettings,\n\t\t\t\tstyles: mergedConfig?.styles ?? globalStyles,\n\t\t\t},\n\t\t\tname,\n\t\t\tvariation\n\t\t);\n\n\t\treturn {\n\t\t\tsettings: mergedConfig?.settings ?? globalSettings,\n\t\t\t// The variation style data is all that is needed to generate\n\t\t\t// the styles for the current application to a block. The variation\n\t\t\t// name is updated to match the instance specific class name.\n\t\t\tstyles: {\n\t\t\t\tblocks: {\n\t\t\t\t\t[ name ]: {\n\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t[ `${ variation }-${ clientId }` ]: variationStyles,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, [\n\t\tmergedConfig,\n\t\tglobalSettings,\n\t\tglobalStyles,\n\t\tvariation,\n\t\tclientId,\n\t\tname,\n\t] );\n}\n\n// Rather than leveraging `useInstanceId` here, the `clientId` is used.\n// This is so that the variation style override's ID is predictable\n// when the order of applied style variations changes.\nfunction useBlockProps( { name, className, clientId } ) {\n\tconst { getBlockStyles } = useSelect( blocksStore );\n\n\tconst registeredStyles = getBlockStyles( name );\n\tconst variation = getVariationNameFromClass( className, registeredStyles );\n\tconst variationClass = `${ VARIATION_PREFIX }${ variation }-${ clientId }`;\n\n\tconst { settings, styles } = useBlockStyleVariation(\n\t\tname,\n\t\tvariation,\n\t\tclientId\n\t);\n\n\tconst variationStyles = useMemo( () => {\n\t\tif ( ! variation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst variationConfig = { settings, styles };\n\t\tconst blockSelectors = getBlockSelectors(\n\t\t\tgetBlockTypes(),\n\t\t\tgetBlockStyles,\n\t\t\tclientId\n\t\t);\n\t\tconst hasBlockGapSupport = false;\n\t\tconst hasFallbackGapSupport = true;\n\t\tconst disableLayoutStyles = true;\n\t\tconst disableRootPadding = true;\n\n\t\treturn toStyles(\n\t\t\tvariationConfig,\n\t\t\tblockSelectors,\n\t\t\thasBlockGapSupport,\n\t\t\thasFallbackGapSupport,\n\t\t\tdisableLayoutStyles,\n\t\t\tdisableRootPadding,\n\t\t\t{\n\t\t\t\tblockGap: false,\n\t\t\t\tblockStyles: true,\n\t\t\t\tlayoutStyles: false,\n\t\t\t\tmarginReset: false,\n\t\t\t\tpresets: false,\n\t\t\t\trootPadding: false,\n\t\t\t\tvariationStyles: true,\n\t\t\t}\n\t\t);\n\t}, [ variation, settings, styles, getBlockStyles, clientId ] );\n\n\tuseStyleOverride( {\n\t\tid: `variation-${ clientId }`,\n\t\tcss: variationStyles,\n\t\t__unstableType: 'variation',\n\t\tvariation,\n\t\t// The clientId will be stored with the override and used to ensure\n\t\t// the order of overrides matches the order of blocks so that the\n\t\t// correct CSS cascade is maintained.\n\t\tclientId,\n\t} );\n\n\treturn variation ? { className: variationClass } : {};\n}\n\nexport default {\n\thasSupport: () => true,\n\tattributeKeys: [ 'className' ],\n\tisMatch: ( { className } ) => getVariationMatches( className ).length > 0,\n\tuseBlockProps,\n};\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AAAwC,IAAAS,WAAA,GAAAT,OAAA;AAnBx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IAE/B,OAAO,IAAAE,sBAAQ,EACdV,eAAe,EACfE,cAAc,EACdG,kBAAkB,EAClBC,qBAAqB,EACrBC,mBAAmB,EACnBC,kBAAkB,EAClB;MACCG,QAAQ,EAAE,KAAK;MACfC,WAAW,EAAE,IAAI;MACjBC,YAAY,EAAE,KAAK;MACnBC,WAAW,EAAE,KAAK;MAClBC,OAAO,EAAE,KAAK;MACdC,WAAW,EAAE,KAAK;MAClBP,eAAe,EAAE;IAClB,CACD,CAAC;EACF,CAAC,EAAE,CAAErC,SAAS,EAAE6B,QAAQ,EAAEJ,MAAM,EAAEjB,cAAc,EAAEa,QAAQ,CAAG,CAAC;EAE9D,IAAAhB,uBAAgB,EAAE;IACjBwC,EAAE,EAAG,aAAaxB,QAAU,EAAC;IAC7ByB,GAAG,EAAET,eAAe;IACpBU,cAAc,EAAE,WAAW;IAC3B/C,SAAS;IACT;IACA;IACA;IACAqB;EACD,CAAE,CAAC;EAEH,OAAOrB,SAAS,GAAG;IAAEZ,SAAS,EAAE6F;EAAe,CAAC,GAAG,CAAC,CAAC;AACtD;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc;EACdC,UAAU,EAAEA,CAAA,KAAM,IAAI;EACtBC,aAAa,EAAE,CAAE,WAAW,CAAE;EAC9BC,OAAO,EAAEA,CAAE;IAAEnG;EAAU,CAAC,KAAMD,mBAAmB,CAAEC,SAAU,CAAC,CAACQ,MAAM,GAAG,CAAC;EACzEoF;AACD,CAAC","ignoreList":[]}
|
package/build/hooks/duotone.js
CHANGED
|
@@ -240,25 +240,30 @@ function useDuotoneStyles({
|
|
|
240
240
|
return;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
// Safari does not always update the duotone filter when the duotone
|
|
244
|
-
// are changed. When using Safari, force the block element to be
|
|
245
|
-
// the browser to ensure any changes are reflected
|
|
246
|
-
// that used on the site frontend in
|
|
243
|
+
// Safari does not always update the duotone filter when the duotone
|
|
244
|
+
// colors are changed. When using Safari, force the block element to be
|
|
245
|
+
// repainted by the browser to ensure any changes are reflected
|
|
246
|
+
// visually. This logic matches that used on the site frontend in
|
|
247
|
+
// `block-supports/duotone.php`.
|
|
247
248
|
if (blockElement && isSafari) {
|
|
248
249
|
const display = blockElement.style.display;
|
|
249
|
-
// Switch to `inline-block` to force a repaint. In the editor,
|
|
250
|
-
// is used instead of `none` to ensure that scroll
|
|
251
|
-
// as `none` results in the editor
|
|
250
|
+
// Switch to `inline-block` to force a repaint. In the editor,
|
|
251
|
+
// `inline-block` is used instead of `none` to ensure that scroll
|
|
252
|
+
// position is not affected, as `none` results in the editor
|
|
253
|
+
// scrolling to the top of the block.
|
|
252
254
|
blockElement.style.display = 'inline-block';
|
|
253
|
-
// Simply accessing el.offsetHeight flushes layout and style
|
|
254
|
-
//
|
|
255
|
+
// Simply accessing el.offsetHeight flushes layout and style changes
|
|
256
|
+
// in WebKit without having to wait for setTimeout.
|
|
255
257
|
// eslint-disable-next-line no-unused-expressions
|
|
256
258
|
blockElement.offsetHeight;
|
|
257
259
|
blockElement.style.display = display;
|
|
258
260
|
}
|
|
259
|
-
|
|
261
|
+
// `colors` must be a dependency so this effect runs when the colors
|
|
262
|
+
// change in Safari.
|
|
263
|
+
}, [isValidFilter, blockElement, colors]);
|
|
260
264
|
}
|
|
261
265
|
function useBlockProps({
|
|
266
|
+
clientId,
|
|
262
267
|
name,
|
|
263
268
|
style
|
|
264
269
|
}) {
|
|
@@ -294,7 +299,7 @@ function useBlockProps({
|
|
|
294
299
|
const filterClass = `wp-duotone-${id}`;
|
|
295
300
|
const shouldRender = selector && attribute;
|
|
296
301
|
useDuotoneStyles({
|
|
297
|
-
clientId
|
|
302
|
+
clientId,
|
|
298
303
|
id: filterClass,
|
|
299
304
|
selector,
|
|
300
305
|
attribute
|