@wordpress/global-styles-engine 1.3.0 → 1.3.1-next.738bb1424.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +1 -1
  2. package/build/core/{equal.js → equal.cjs} +2 -2
  3. package/build/core/{merge.js → merge.cjs} +2 -2
  4. package/build/core/{render.js → render.cjs} +41 -13
  5. package/build/core/render.cjs.map +7 -0
  6. package/build/core/{selectors.js → selectors.cjs} +3 -3
  7. package/build/{index.js → index.cjs} +17 -14
  8. package/build/{index.js.map → index.cjs.map} +2 -2
  9. package/build/settings/{get-palette.js → get-palette.cjs} +2 -2
  10. package/build/settings/{get-setting.js → get-setting.cjs} +4 -2
  11. package/build/settings/get-setting.cjs.map +7 -0
  12. package/build/settings/{get-style.js → get-style.cjs} +3 -3
  13. package/build/settings/{set-setting.js → set-setting.cjs} +2 -2
  14. package/build/settings/{set-style.js → set-style.cjs} +2 -2
  15. package/build/{types.js → types.cjs} +1 -1
  16. package/build/{types.js.map → types.cjs.map} +1 -1
  17. package/build/utils/{background.js → background.cjs} +1 -1
  18. package/build/utils/{common.js → common.cjs} +9 -3
  19. package/build/utils/common.cjs.map +7 -0
  20. package/build/utils/dimensions.cjs +40 -0
  21. package/build/utils/dimensions.cjs.map +7 -0
  22. package/build/utils/{duotone.js → duotone.cjs} +1 -1
  23. package/build/utils/{fluid.js → fluid.cjs} +1 -1
  24. package/build/utils/{gap.js → gap.cjs} +2 -2
  25. package/build/utils/{get-global-styles-changes.js → get-global-styles-changes.cjs} +2 -2
  26. package/build/utils/{layout.js → layout.cjs} +1 -1
  27. package/build/utils/{object.js → object.cjs} +1 -1
  28. package/build/utils/{spacing.js → spacing.cjs} +1 -1
  29. package/build/utils/{string.js → string.cjs} +1 -1
  30. package/build/utils/{typography.js → typography.cjs} +2 -2
  31. package/build-module/core/render.js +40 -12
  32. package/build-module/core/render.js.map +2 -2
  33. package/build-module/core/selectors.js +2 -2
  34. package/build-module/index.js +15 -13
  35. package/build-module/index.js.map +2 -2
  36. package/build-module/settings/get-palette.js +1 -1
  37. package/build-module/settings/get-setting.js +3 -1
  38. package/build-module/settings/get-setting.js.map +2 -2
  39. package/build-module/settings/get-style.js +2 -2
  40. package/build-module/settings/set-setting.js +1 -1
  41. package/build-module/settings/set-style.js +1 -1
  42. package/build-module/utils/common.js +8 -2
  43. package/build-module/utils/common.js.map +2 -2
  44. package/build-module/utils/dimensions.js +15 -0
  45. package/build-module/utils/dimensions.js.map +7 -0
  46. package/build-module/utils/gap.js +1 -1
  47. package/build-module/utils/typography.js +1 -1
  48. package/build-types/core/render.d.ts.map +1 -1
  49. package/build-types/index.d.ts +1 -0
  50. package/build-types/index.d.ts.map +1 -1
  51. package/build-types/settings/get-setting.d.ts.map +1 -1
  52. package/build-types/types.d.ts +1 -0
  53. package/build-types/types.d.ts.map +1 -1
  54. package/build-types/utils/common.d.ts.map +1 -1
  55. package/build-types/utils/dimensions.d.ts +2 -0
  56. package/build-types/utils/dimensions.d.ts.map +1 -0
  57. package/package.json +16 -8
  58. package/src/core/render.tsx +41 -2
  59. package/src/index.ts +1 -0
  60. package/src/settings/get-setting.ts +2 -0
  61. package/src/types.ts +1 -0
  62. package/src/utils/common.ts +6 -0
  63. package/src/utils/dimensions.ts +13 -0
  64. package/build/core/render.js.map +0 -7
  65. package/build/settings/get-setting.js.map +0 -7
  66. package/build/utils/common.js.map +0 -7
  67. package/tsconfig.json +0 -18
  68. package/tsconfig.tsbuildinfo +0 -1
  69. /package/build/core/{equal.js.map → equal.cjs.map} +0 -0
  70. /package/build/core/{merge.js.map → merge.cjs.map} +0 -0
  71. /package/build/core/{selectors.js.map → selectors.cjs.map} +0 -0
  72. /package/build/settings/{get-palette.js.map → get-palette.cjs.map} +0 -0
  73. /package/build/settings/{get-style.js.map → get-style.cjs.map} +0 -0
  74. /package/build/settings/{set-setting.js.map → set-setting.cjs.map} +0 -0
  75. /package/build/settings/{set-style.js.map → set-style.cjs.map} +0 -0
  76. /package/build/utils/{background.js.map → background.cjs.map} +0 -0
  77. /package/build/utils/{duotone.js.map → duotone.cjs.map} +0 -0
  78. /package/build/utils/{fluid.js.map → fluid.cjs.map} +0 -0
  79. /package/build/utils/{gap.js.map → gap.cjs.map} +0 -0
  80. /package/build/utils/{get-global-styles-changes.js.map → get-global-styles-changes.cjs.map} +0 -0
  81. /package/build/utils/{layout.js.map → layout.cjs.map} +0 -0
  82. /package/build/utils/{object.js.map → object.cjs.map} +0 -0
  83. /package/build/utils/{spacing.js.map → spacing.cjs.map} +0 -0
  84. /package/build/utils/{string.js.map → string.cjs.map} +0 -0
  85. /package/build/utils/{typography.js.map → typography.cjs.map} +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/common.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getCSSValueFromRawStyle } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tGlobalStylesSettings,\n\tThemeFileLink,\n\tTypographyPreset,\n\tUnresolvedValue,\n\tGlobalStylesConfig,\n} from '../types';\nimport { getTypographyFontSizeValue } from './typography';\nimport { getValueFromObjectPath } from './object';\n\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 }: { slug: string } ) =>\n\t\t\t`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: (\n\t\t\tpreset: TypographyPreset,\n\t\t\tsettings: GlobalStylesSettings\n\t\t) => getTypographyFontSizeValue( 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: string } ) => size,\n\t\tclasses: [],\n\t},\n\t{\n\t\tpath: [ 'border', 'radiusSizes' ],\n\t\tvalueKey: 'size',\n\t\tcssVarInfix: 'border-radius',\n\t\tclasses: [],\n\t},\n\t{\n\t\tpath: [ 'dimensions', 'dimensionSizes' ],\n\t\tvalueKey: 'size',\n\t\tcssVarInfix: 'dimension',\n\t\tclasses: [],\n\t},\n];\n\nexport const STYLE_PATH_TO_CSS_VAR_INFIX: Record< string, string > = {\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/**\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 scope Selector to scope to.\n * @param selector Original selector.\n *\n * @return Scoped selector.\n */\nexport function scopeSelector( scope: string | undefined, selector: string ) {\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: string[] = [];\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 scope Selector to scope collection of selectors with.\n * @param selectors Collection of feature selectors e.g.\n *\n * @return Scoped collection of feature selectors.\n */\nexport function scopeFeatureSelectors(\n\tscope: string | undefined,\n\tselectors: string | Record< string, string | Record< string, string > >\n) {\n\tif ( ! scope || ! selectors ) {\n\t\treturn;\n\t}\n\n\tconst featureSelectors: Record<\n\t\tstring,\n\t\tstring | Record< string, string >\n\t> = {};\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\t// @ts-expect-error\n\t\t\t\t\tfeatureSelectors[ feature ][ subfeature ] = scopeSelector(\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tsubfeatureSelector as string\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 selector Original selector.\n * @param toAppend Selector to append.\n *\n * @return The new selector.\n */\nexport function appendToSelector( selector: string, toAppend: string ) {\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 * 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 variation Name for the variation.\n * @param blockSelector CSS selector for the block.\n *\n * @return CSS selector for the block style variation.\n */\nexport function getBlockStyleVariationSelector(\n\tvariation: string,\n\tblockSelector: string\n) {\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 = (\n\t\t_match: string,\n\t\tgroup1: string,\n\t\tgroup2: string\n\t) => {\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\n/**\n * Resolves ref values in theme JSON.\n *\n * @param ruleValue A block style value that may contain a reference to a theme.json value.\n * @param tree A theme.json object.\n * @return The resolved value or incoming ruleValue.\n */\nexport function getResolvedRefValue(\n\truleValue: UnresolvedValue,\n\ttree?: GlobalStylesConfig\n): UnresolvedValue {\n\tif ( ! ruleValue || ! tree ) {\n\t\treturn ruleValue;\n\t}\n\n\t/*\n\t * Where the rule value is an object with a 'ref' property pointing\n\t * to a path, this converts that path into the value at that path.\n\t * For example: { \"ref\": \"style.color.background\" } => \"#fff\".\n\t */\n\tif (\n\t\ttypeof ruleValue === 'object' &&\n\t\t'ref' in ruleValue &&\n\t\truleValue?.ref\n\t) {\n\t\tconst resolvedRuleValue = getCSSValueFromRawStyle(\n\t\t\tgetValueFromObjectPath( tree, ruleValue.ref )\n\t\t) as UnresolvedValue;\n\n\t\t/*\n\t\t * Presence of another ref indicates a reference to another dynamic value.\n\t\t * Pointing to another dynamic value is not supported.\n\t\t */\n\t\tif (\n\t\t\ttypeof resolvedRuleValue === 'object' &&\n\t\t\tresolvedRuleValue !== null &&\n\t\t\t'ref' in resolvedRuleValue &&\n\t\t\tresolvedRuleValue?.ref\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif ( resolvedRuleValue === undefined ) {\n\t\t\treturn ruleValue;\n\t\t}\n\n\t\treturn resolvedRuleValue;\n\t}\n\treturn ruleValue;\n}\n\n/**\n * Looks up a theme file URI based on a relative path.\n *\n * @param file A relative path.\n * @param themeFileURIs A collection of absolute theme file URIs and their corresponding file paths.\n * @return A resolved theme file URI, if one is found in the themeFileURIs collection.\n */\nexport function getResolvedThemeFilePath(\n\tfile: string,\n\tthemeFileURIs?: ThemeFileLink[]\n) {\n\tif ( ! file || ! themeFileURIs || ! Array.isArray( themeFileURIs ) ) {\n\t\treturn file;\n\t}\n\n\tconst uri = themeFileURIs.find(\n\t\t( themeFileUri ) => themeFileUri?.name === file\n\t);\n\n\tif ( ! uri?.href ) {\n\t\treturn file;\n\t}\n\n\treturn uri?.href;\n}\n\n/**\n * Resolves ref and relative path values in theme JSON.\n *\n * @param ruleValue A block style value that may contain a reference to a theme.json value.\n * @param tree A theme.json object.\n * @return The resolved value or incoming ruleValue.\n */\nexport function getResolvedValue(\n\truleValue: UnresolvedValue,\n\ttree: GlobalStylesConfig | undefined\n) {\n\tif ( ! ruleValue || ! tree ) {\n\t\treturn ruleValue;\n\t}\n\n\t// Resolve ref values.\n\tconst resolvedValue = getResolvedRefValue( ruleValue, tree );\n\n\t// Resolve relative paths.\n\tif (\n\t\ttypeof resolvedValue === 'object' &&\n\t\tresolvedValue !== null &&\n\t\t'url' in resolvedValue &&\n\t\tresolvedValue?.url\n\t) {\n\t\tresolvedValue.url = getResolvedThemeFilePath(\n\t\t\tresolvedValue.url,\n\t\t\ttree?._links?.[ 'wp:theme-file' ]\n\t\t);\n\t}\n\n\treturn resolvedValue;\n}\n\nfunction findInPresetsBy(\n\tsettings: GlobalStylesSettings,\n\tblockName?: string,\n\tpresetPath: string[] = [],\n\tpresetProperty: string = 'slug',\n\tpresetValueValue?: string\n) {\n\t// Block presets take priority above root level presets.\n\tconst orderedPresetsByOrigin = [\n\t\tblockName\n\t\t\t? getValueFromObjectPath( settings, [\n\t\t\t\t\t'blocks',\n\t\t\t\t\tblockName,\n\t\t\t\t\t...presetPath,\n\t\t\t ] )\n\t\t\t: undefined,\n\t\tgetValueFromObjectPath( settings, presetPath ),\n\t].filter( Boolean );\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\t// @ts-expect-error\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: any ) =>\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\tsettings,\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\nfunction getValueFromPresetVariable(\n\tfeatures: GlobalStylesConfig,\n\tblockName?: string,\n\tvariable?: string,\n\t[ presetType, slug ]: string[] = []\n) {\n\tconst metadata = PRESET_METADATA.find(\n\t\t( data ) => data.cssVarInfix === presetType\n\t);\n\tif ( ! metadata || ! features.settings ) {\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(\n\tfeatures: GlobalStylesConfig,\n\tblockName?: string,\n\tvariable?: string,\n\tpath: string[] = []\n): string | undefined {\n\tconst result =\n\t\t( blockName\n\t\t\t? getValueFromObjectPath( features?.settings ?? {}, [\n\t\t\t\t\t'blocks',\n\t\t\t\t\tblockName,\n\t\t\t\t\t'custom',\n\t\t\t\t\t...path,\n\t\t\t ] )\n\t\t\t: undefined ) ??\n\t\tgetValueFromObjectPath( features?.settings ?? {}, [\n\t\t\t'custom',\n\t\t\t...path,\n\t\t] );\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 as string );\n}\n\n/**\n * Attempts to fetch the value of a theme.json CSS variable.\n *\n * This function resolves CSS variable references in two formats:\n * - User format: `var:preset|color|red` or `var:custom|spacing|small`\n * - Theme format: `var(--wp--preset--color--red)` or `var(--wp--custom--spacing--small)`\n *\n * It also handles ref-style variables in the format `{ ref: \"path.to.value\" }`.\n *\n * @param features GlobalStylesContext config (user, base, or merged). Represents the theme.json tree.\n * @param blockName The name of a block as represented in the styles property. E.g., 'root' for root-level, and 'core/block-name' for blocks.\n * @param variable An incoming style value. A CSS var value is expected, but it could be any value.\n * @return The value of the CSS var, if found. If not found, returns the original variable argument.\n */\nexport function getValueFromVariable(\n\tfeatures: GlobalStylesConfig,\n\tblockName?: string,\n\tvariable?: string | UnresolvedValue\n): any {\n\tif ( ! variable || typeof variable !== 'string' ) {\n\t\tif (\n\t\t\ttypeof variable === 'object' &&\n\t\t\tvariable !== null &&\n\t\t\t'ref' in variable &&\n\t\t\ttypeof variable.ref === 'string'\n\t\t) {\n\t\t\tconst resolvedVariable = getValueFromObjectPath(\n\t\t\t\tfeatures,\n\t\t\t\tvariable.ref\n\t\t\t);\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 (\n\t\t\t\t! resolvedVariable ||\n\t\t\t\t( typeof resolvedVariable === 'object' &&\n\t\t\t\t\t'ref' in resolvedVariable )\n\t\t\t) {\n\t\t\t\treturn resolvedVariable;\n\t\t\t}\n\t\t\tvariable = resolvedVariable as string;\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 * Encodes a value to a preset variable format if it matches a preset.\n * This is the inverse operation of getValueFromVariable().\n *\n * @example\n * ```js\n * const presetVar = getPresetVariableFromValue(\n * globalStyles.settings,\n * 'core/paragraph',\n * 'color.text',\n * '#ff0000'\n * );\n * // If #ff0000 is the 'red' preset color, returns 'var:preset|color|red'\n * // Otherwise returns '#ff0000'\n * ```\n *\n * @param features GlobalStylesContext settings object.\n * @param blockName The name of a block (e.g., 'core/paragraph').\n * @param variableStylePath The style path (e.g., 'color.text', 'typography.fontSize').\n * @param presetPropertyValue The value to encode (e.g., '#ff0000').\n * @return The preset variable if found, otherwise the original value.\n */\nexport function getPresetVariableFromValue(\n\tfeatures: GlobalStylesSettings,\n\tblockName: string | undefined,\n\tvariableStylePath: string,\n\tpresetPropertyValue: any\n): any {\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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAwC;AAYxC,wBAA2C;AAC3C,oBAAuC;AAEhC,IAAM,sBAAsB;AAC5B,IAAM,+BAA+B;AAErC,IAAM,kBAAkB;AAAA,EAC9B;AAAA,IACC,MAAM,CAAE,SAAS,SAAU;AAAA,IAC3B,UAAU;AAAA,IACV,aAAa;AAAA,IACb,SAAS;AAAA,MACR,EAAE,aAAa,SAAS,cAAc,QAAQ;AAAA,MAC9C;AAAA,QACC,aAAa;AAAA,QACb,cAAc;AAAA,MACf;AAAA,MACA;AAAA,QACC,aAAa;AAAA,QACb,cAAc;AAAA,MACf;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,MAAM,CAAE,SAAS,WAAY;AAAA,IAC7B,UAAU;AAAA,IACV,aAAa;AAAA,IACb,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,cAAc;AAAA,MACf;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,MAAM,CAAE,SAAS,SAAU;AAAA,IAC3B,UAAU;AAAA,IACV,aAAa;AAAA,IACb,WAAW,CAAE,EA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O,cAAe,WAAY,IAAK,aAAa,IAAK;AAC1D;",
6
+ "names": []
7
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/global-styles-engine/src/utils/dimensions.ts
21
+ var dimensions_exports = {};
22
+ __export(dimensions_exports, {
23
+ getDimensionPresetCssVar: () => getDimensionPresetCssVar
24
+ });
25
+ module.exports = __toCommonJS(dimensions_exports);
26
+ function getDimensionPresetCssVar(value) {
27
+ if (!value) {
28
+ return;
29
+ }
30
+ const slug = value.match(/var:preset\|dimension\|(.+)/);
31
+ if (!slug) {
32
+ return value;
33
+ }
34
+ return `var(--wp--preset--dimension--${slug[1]})`;
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ getDimensionPresetCssVar
39
+ });
40
+ //# sourceMappingURL=dimensions.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/dimensions.ts"],
4
+ "sourcesContent": ["export function getDimensionPresetCssVar( value?: string ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|dimension\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--dimension--${ slug[ 1 ] })`;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,yBAA0B,OAAiB;AAC1D,MAAK,CAAE,OAAQ;AACd;AAAA,EACD;AAEA,QAAM,OAAO,MAAM,MAAO,6BAA8B;AAExD,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAEA,SAAO,gCAAiC,KAAM,CAAE,CAAE;AACnD;",
6
+ "names": []
7
+ }
@@ -89,4 +89,4 @@ function getDuotoneFilter(id, colors) {
89
89
  getDuotoneUnsetStylesheet,
90
90
  getValuesFromColors
91
91
  });
92
- //# sourceMappingURL=duotone.js.map
92
+ //# sourceMappingURL=duotone.cjs.map
@@ -172,4 +172,4 @@ function roundToPrecision(value, digits = 3) {
172
172
  getTypographyValueAndUnit,
173
173
  roundToPrecision
174
174
  });
175
- //# sourceMappingURL=fluid.js.map
175
+ //# sourceMappingURL=fluid.cjs.map
@@ -24,7 +24,7 @@ __export(gap_exports, {
24
24
  getGapCSSValue: () => getGapCSSValue
25
25
  });
26
26
  module.exports = __toCommonJS(gap_exports);
27
- var import_spacing = require("./spacing");
27
+ var import_spacing = require("./spacing.cjs");
28
28
  function getGapBoxControlValueFromStyle(blockGapValue) {
29
29
  if (!blockGapValue) {
30
30
  return null;
@@ -49,4 +49,4 @@ function getGapCSSValue(blockGapValue, defaultValue = "0") {
49
49
  getGapBoxControlValueFromStyle,
50
50
  getGapCSSValue
51
51
  });
52
- //# sourceMappingURL=gap.js.map
52
+ //# sourceMappingURL=gap.cjs.map
@@ -34,7 +34,7 @@ __export(get_global_styles_changes_exports, {
34
34
  getGlobalStylesChangelist: () => getGlobalStylesChangelist
35
35
  });
36
36
  module.exports = __toCommonJS(get_global_styles_changes_exports);
37
- var import_memize = __toESM(require("memize"));
37
+ var import_memize = __toESM(require("memize"), 1);
38
38
  var import_i18n = require("@wordpress/i18n");
39
39
  var import_blocks = require("@wordpress/blocks");
40
40
  var globalStylesChangesCache = /* @__PURE__ */ new Map();
@@ -222,4 +222,4 @@ function getGlobalStylesChanges(next, previous, options = {}) {
222
222
  0 && (module.exports = {
223
223
  getGlobalStylesChangelist
224
224
  });
225
- //# sourceMappingURL=get-global-styles-changes.js.map
225
+ //# sourceMappingURL=get-global-styles-changes.cjs.map
@@ -198,4 +198,4 @@ var LAYOUT_DEFINITIONS = {
198
198
  0 && (module.exports = {
199
199
  LAYOUT_DEFINITIONS
200
200
  });
201
- //# sourceMappingURL=layout.js.map
201
+ //# sourceMappingURL=layout.cjs.map
@@ -49,4 +49,4 @@ var getValueFromObjectPath = (object, path, defaultValue) => {
49
49
  getValueFromObjectPath,
50
50
  setImmutably
51
51
  });
52
- //# sourceMappingURL=object.js.map
52
+ //# sourceMappingURL=object.cjs.map
@@ -37,4 +37,4 @@ function getSpacingPresetCssVar(value) {
37
37
  0 && (module.exports = {
38
38
  getSpacingPresetCssVar
39
39
  });
40
- //# sourceMappingURL=spacing.js.map
40
+ //# sourceMappingURL=spacing.cjs.map
@@ -30,4 +30,4 @@ function kebabCase(str) {
30
30
  0 && (module.exports = {
31
31
  kebabCase
32
32
  });
33
- //# sourceMappingURL=string.js.map
33
+ //# sourceMappingURL=string.cjs.map
@@ -24,7 +24,7 @@ __export(typography_exports, {
24
24
  getTypographyFontSizeValue: () => getTypographyFontSizeValue
25
25
  });
26
26
  module.exports = __toCommonJS(typography_exports);
27
- var import_fluid = require("./fluid");
27
+ var import_fluid = require("./fluid.cjs");
28
28
  function isFluidTypographyEnabled(typographySettings) {
29
29
  const fluidSettings = typographySettings?.fluid;
30
30
  return true === fluidSettings || fluidSettings && typeof fluidSettings === "object" && Object.keys(fluidSettings).length > 0;
@@ -71,4 +71,4 @@ function getTypographyFontSizeValue(preset, settings) {
71
71
  getFluidTypographyOptionsFromSettings,
72
72
  getTypographyFontSizeValue
73
73
  });
74
- //# sourceMappingURL=typography.js.map
74
+ //# sourceMappingURL=typography.cjs.map
@@ -17,16 +17,16 @@ import {
17
17
  appendToSelector,
18
18
  getBlockStyleVariationSelector,
19
19
  getResolvedValue
20
- } from "../utils/common";
21
- import { getBlockSelector } from "./selectors";
22
- import { getTypographyFontSizeValue } from "../utils/typography";
23
- import { getDuotoneFilter } from "../utils/duotone";
24
- import { kebabCase } from "../utils/string";
25
- import { getGapCSSValue } from "../utils/gap";
26
- import { setBackgroundStyleDefaults } from "../utils/background";
27
- import { LAYOUT_DEFINITIONS } from "../utils/layout";
28
- import { getValueFromObjectPath, setImmutably } from "../utils/object";
29
- import { getSetting } from "../settings/get-setting";
20
+ } from "../utils/common.js";
21
+ import { getBlockSelector } from "./selectors.js";
22
+ import { getTypographyFontSizeValue } from "../utils/typography.js";
23
+ import { getDuotoneFilter } from "../utils/duotone.js";
24
+ import { kebabCase } from "../utils/string.js";
25
+ import { getGapCSSValue } from "../utils/gap.js";
26
+ import { setBackgroundStyleDefaults } from "../utils/background.js";
27
+ import { LAYOUT_DEFINITIONS } from "../utils/layout.js";
28
+ import { getValueFromObjectPath, setImmutably } from "../utils/object.js";
29
+ import { getSetting } from "../settings/get-setting.js";
30
30
  var ELEMENT_CLASS_NAMES = {
31
31
  button: "wp-element-button",
32
32
  caption: "wp-element-caption"
@@ -405,9 +405,37 @@ var getNodesWithStyles = (tree, blockSelectors) => {
405
405
  }
406
406
  Object.entries(ELEMENTS).forEach(([name, selector]) => {
407
407
  if (tree.styles?.elements?.[name]) {
408
+ const elementStyles = tree.styles?.elements?.[name] ?? {};
409
+ const finalSelector = selector;
410
+ let textIndentStyles = null;
411
+ if (name === "text" && elementStyles?.typography?.textIndent) {
412
+ textIndentStyles = {
413
+ typography: {
414
+ textIndent: elementStyles.typography.textIndent
415
+ }
416
+ };
417
+ const stylesWithoutTextIndent = { ...elementStyles };
418
+ if (stylesWithoutTextIndent.typography) {
419
+ const { textIndent, ...restTypography } = stylesWithoutTextIndent.typography;
420
+ stylesWithoutTextIndent.typography = restTypography;
421
+ }
422
+ if (Object.keys(stylesWithoutTextIndent).length > 0) {
423
+ nodes.push({
424
+ styles: stylesWithoutTextIndent,
425
+ selector: finalSelector,
426
+ skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name]
427
+ });
428
+ }
429
+ nodes.push({
430
+ styles: textIndentStyles,
431
+ selector: "p + p",
432
+ skipSelectorWrapper: true
433
+ });
434
+ return;
435
+ }
408
436
  nodes.push({
409
- styles: tree.styles?.elements?.[name] ?? {},
410
- selector,
437
+ styles: elementStyles,
438
+ selector: finalSelector,
411
439
  // Top level elements that don't use a class name should not receive the
412
440
  // `:root :where()` wrapper to maintain backwards compatibility.
413
441
  skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name]