@wordpress/global-styles-engine 1.17.0 → 1.18.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.
- package/CHANGELOG.md +7 -0
- package/build/core/render.cjs +36 -16
- package/build/core/render.cjs.map +2 -2
- package/build/index.cjs +3 -0
- package/build/index.cjs.map +2 -2
- package/build/lock-unlock.cjs +37 -0
- package/build/lock-unlock.cjs.map +7 -0
- package/build/private-apis.cjs +38 -0
- package/build/private-apis.cjs.map +7 -0
- package/build/settings/get-setting.cjs +3 -1
- package/build/settings/get-setting.cjs.map +2 -2
- package/build/types.cjs.map +1 -1
- package/build/utils/common.cjs +2 -4
- package/build/utils/common.cjs.map +2 -2
- package/build/utils/viewport.cjs +108 -0
- package/build/utils/viewport.cjs.map +7 -0
- package/build-module/core/render.mjs +36 -16
- package/build-module/core/render.mjs.map +2 -2
- package/build-module/index.mjs +2 -0
- package/build-module/index.mjs.map +2 -2
- package/build-module/lock-unlock.mjs +11 -0
- package/build-module/lock-unlock.mjs.map +7 -0
- package/build-module/private-apis.mjs +17 -0
- package/build-module/private-apis.mjs.map +7 -0
- package/build-module/settings/get-setting.mjs +3 -1
- package/build-module/settings/get-setting.mjs.map +2 -2
- package/build-module/utils/common.mjs +2 -4
- package/build-module/utils/common.mjs.map +2 -2
- package/build-module/utils/viewport.mjs +81 -0
- package/build-module/utils/viewport.mjs.map +7 -0
- package/build-types/core/render.d.ts +1 -1
- package/build-types/core/render.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/private-apis.d.ts +2 -0
- package/build-types/private-apis.d.ts.map +1 -0
- package/build-types/settings/get-setting.d.ts.map +1 -1
- package/build-types/style-state-back-compat.d.ts.map +1 -1
- package/build-types/types.d.ts +4 -0
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/common.d.ts.map +1 -1
- package/build-types/utils/fluid.d.ts +1 -1
- package/build-types/utils/fluid.d.ts.map +1 -1
- package/build-types/utils/viewport.d.ts +41 -0
- package/build-types/utils/viewport.d.ts.map +1 -0
- package/package.json +7 -6
- package/src/core/render.tsx +45 -21
- package/src/index.ts +1 -0
- package/src/lock-unlock.ts +10 -0
- package/src/private-apis.ts +16 -0
- package/src/settings/get-setting.ts +2 -0
- package/src/test/render.test.ts +182 -0
- package/src/test/viewport-utils.test.ts +168 -0
- package/src/types.ts +4 -0
- package/src/utils/common.ts +13 -8
- package/src/utils/viewport.ts +153 -0
package/build/index.cjs
CHANGED
|
@@ -46,6 +46,7 @@ __export(index_exports, {
|
|
|
46
46
|
getTypographyFontSizeValue: () => import_typography.getTypographyFontSizeValue,
|
|
47
47
|
getValueFromVariable: () => import_common.getValueFromVariable,
|
|
48
48
|
mergeGlobalStyles: () => import_merge.mergeGlobalStyles,
|
|
49
|
+
privateApis: () => import_private_apis.privateApis,
|
|
49
50
|
processCSSNesting: () => import_render2.processCSSNesting,
|
|
50
51
|
setSetting: () => import_set_setting.setSetting,
|
|
51
52
|
setStyle: () => import_set_style.setStyle,
|
|
@@ -67,6 +68,7 @@ var import_selectors = require("./core/selectors.cjs");
|
|
|
67
68
|
var import_typography = require("./utils/typography.cjs");
|
|
68
69
|
var import_dimensions = require("./utils/dimensions.cjs");
|
|
69
70
|
var import_common = require("./utils/common.cjs");
|
|
71
|
+
var import_private_apis = require("./private-apis.cjs");
|
|
70
72
|
var import_preview_state_styles = require("./preview-state-styles.cjs");
|
|
71
73
|
// Annotate the CommonJS export names for ESM import in node:
|
|
72
74
|
0 && (module.exports = {
|
|
@@ -86,6 +88,7 @@ var import_preview_state_styles = require("./preview-state-styles.cjs");
|
|
|
86
88
|
getTypographyFontSizeValue,
|
|
87
89
|
getValueFromVariable,
|
|
88
90
|
mergeGlobalStyles,
|
|
91
|
+
privateApis,
|
|
89
92
|
processCSSNesting,
|
|
90
93
|
setSetting,
|
|
91
94
|
setStyle,
|
package/build/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["// High-level Settings API\nexport { getSetting } from './settings/get-setting';\nexport { setSetting } from './settings/set-setting';\nexport { getStyle } from './settings/get-style';\nexport { setStyle } from './settings/set-style';\nexport { default as getPalettes } from './settings/get-palette';\n\n// Utilities\nexport { areGlobalStylesEqual } from './core/equal';\nexport { mergeGlobalStyles } from './core/merge';\nexport { default as getGlobalStylesChanges } from './utils/get-global-styles-changes';\n\n// Core rendering\nexport { generateGlobalStyles } from './core/render';\nexport {\n\ttransformToStyles as toStyles,\n\tgetBlockSelectors,\n\tgetLayoutStyles,\n\tprocessCSSNesting,\n} from './core/render';\nexport { getBlockSelector } from './core/selectors';\n\n// Utilities (Ideally these shouldn't be exposed)\nexport { getTypographyFontSizeValue } from './utils/typography';\nexport { getDimensionPresetCssVar } from './utils/dimensions';\nexport {\n\tgetValueFromVariable,\n\tgetPresetVariableFromValue,\n\tgetResolvedValue,\n\tsplitSelectorList,\n} from './utils/common';\n\n// Types\nexport type * from './types';\n\nexport { generatePreviewStateStyles as __unstableGeneratePreviewStateStyles } from './preview-state-styles';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA2B;AAC3B,yBAA2B;AAC3B,uBAAyB;AACzB,uBAAyB;AACzB,yBAAuC;AAGvC,mBAAqC;AACrC,mBAAkC;AAClC,uCAAkD;AAGlD,oBAAqC;AACrC,IAAAA,iBAKO;AACP,uBAAiC;AAGjC,wBAA2C;AAC3C,wBAAyC;AACzC,oBAKO;
|
|
4
|
+
"sourcesContent": ["// High-level Settings API\nexport { getSetting } from './settings/get-setting';\nexport { setSetting } from './settings/set-setting';\nexport { getStyle } from './settings/get-style';\nexport { setStyle } from './settings/set-style';\nexport { default as getPalettes } from './settings/get-palette';\n\n// Utilities\nexport { areGlobalStylesEqual } from './core/equal';\nexport { mergeGlobalStyles } from './core/merge';\nexport { default as getGlobalStylesChanges } from './utils/get-global-styles-changes';\n\n// Core rendering\nexport { generateGlobalStyles } from './core/render';\nexport {\n\ttransformToStyles as toStyles,\n\tgetBlockSelectors,\n\tgetLayoutStyles,\n\tprocessCSSNesting,\n} from './core/render';\nexport { getBlockSelector } from './core/selectors';\n\n// Utilities (Ideally these shouldn't be exposed)\nexport { getTypographyFontSizeValue } from './utils/typography';\nexport { getDimensionPresetCssVar } from './utils/dimensions';\nexport {\n\tgetValueFromVariable,\n\tgetPresetVariableFromValue,\n\tgetResolvedValue,\n\tsplitSelectorList,\n} from './utils/common';\nexport { privateApis } from './private-apis';\n\n// Types\nexport type * from './types';\n\nexport { generatePreviewStateStyles as __unstableGeneratePreviewStateStyles } from './preview-state-styles';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA2B;AAC3B,yBAA2B;AAC3B,uBAAyB;AACzB,uBAAyB;AACzB,yBAAuC;AAGvC,mBAAqC;AACrC,mBAAkC;AAClC,uCAAkD;AAGlD,oBAAqC;AACrC,IAAAA,iBAKO;AACP,uBAAiC;AAGjC,wBAA2C;AAC3C,wBAAyC;AACzC,oBAKO;AACP,0BAA4B;AAK5B,kCAAmF;",
|
|
6
6
|
"names": ["import_render"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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/lock-unlock.ts
|
|
21
|
+
var lock_unlock_exports = {};
|
|
22
|
+
__export(lock_unlock_exports, {
|
|
23
|
+
lock: () => lock,
|
|
24
|
+
unlock: () => unlock
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(lock_unlock_exports);
|
|
27
|
+
var import_private_apis = require("@wordpress/private-apis");
|
|
28
|
+
var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
|
|
29
|
+
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
|
|
30
|
+
"@wordpress/global-styles-engine"
|
|
31
|
+
);
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
lock,
|
|
35
|
+
unlock
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=lock-unlock.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lock-unlock.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/global-styles-engine'\n\t);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAiE;AAE1D,IAAM,EAAE,MAAM,OAAO,QAC3B;AAAA,EACC;AAAA,EACA;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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/private-apis.ts
|
|
21
|
+
var private_apis_exports = {};
|
|
22
|
+
__export(private_apis_exports, {
|
|
23
|
+
privateApis: () => privateApis
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(private_apis_exports);
|
|
26
|
+
var import_viewport = require("./utils/viewport.cjs");
|
|
27
|
+
var import_lock_unlock = require("./lock-unlock.cjs");
|
|
28
|
+
var privateApis = {};
|
|
29
|
+
(0, import_lock_unlock.lock)(privateApis, {
|
|
30
|
+
getResponsiveMediaQueries: import_viewport.getResponsiveMediaQueries,
|
|
31
|
+
getViewportBreakpoints: import_viewport.getViewportBreakpoints,
|
|
32
|
+
getViewportBreakpointValueInPixels: import_viewport.getViewportBreakpointValueInPixels
|
|
33
|
+
});
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
privateApis
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=private-apis.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/private-apis.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport {\n\tgetResponsiveMediaQueries,\n\tgetViewportBreakpoints,\n\tgetViewportBreakpointValueInPixels,\n} from './utils/viewport';\nimport { lock } from './lock-unlock';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tgetResponsiveMediaQueries,\n\tgetViewportBreakpoints,\n\tgetViewportBreakpointValueInPixels,\n} );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAIO;AACP,yBAAqB;AAEd,IAAM,cAAc,CAAC;AAAA,IAC5B,yBAAM,aAAa;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACD,CAAE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -91,7 +91,9 @@ var VALID_SETTINGS = [
|
|
|
91
91
|
"typography.textDecoration",
|
|
92
92
|
"typography.textIndent",
|
|
93
93
|
"typography.textTransform",
|
|
94
|
-
"typography.writingMode"
|
|
94
|
+
"typography.writingMode",
|
|
95
|
+
"viewport.mobile",
|
|
96
|
+
"viewport.tablet"
|
|
95
97
|
];
|
|
96
98
|
function getSetting(globalStyles, path, blockName) {
|
|
97
99
|
const appendedBlockPath = blockName ? ".blocks." + blockName : "";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/settings/get-setting.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getValueFromObjectPath, setImmutably } from '../utils/object';\nimport type { GlobalStylesConfig } from '../types';\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'background.backgroundImage',\n\t'background.backgroundRepeat',\n\t'background.backgroundSize',\n\t'background.backgroundPosition',\n\t'background.gradient',\n\t'border.color',\n\t'border.radius',\n\t'border.radiusSizes',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.button',\n\t'color.caption',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.heading',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.aspectRatio',\n\t'dimensions.height',\n\t'dimensions.minHeight',\n\t'dimensions.minWidth',\n\t'dimensions.width',\n\t'dimensions.dimensionSizes',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'lightbox.enabled',\n\t'lightbox.allowEditing',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.defaultSpacingSizes',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.defaultFontSizes',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textAlign',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textIndent',\n\t'typography.textTransform',\n\t'typography.writingMode',\n];\n\nexport function getSetting< T = any >(\n\tglobalStyles: GlobalStylesConfig,\n\tpath: string,\n\tblockName?: string\n): T {\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = path ? '.' + path : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\n\tif ( path ) {\n\t\treturn ( getValueFromObjectPath( globalStyles, contextualPath ) ??\n\t\t\tgetValueFromObjectPath( globalStyles, globalPath ) ) as T;\n\t}\n\n\tlet result = {};\n\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\tconst value =\n\t\t\tgetValueFromObjectPath(\n\t\t\t\tglobalStyles,\n\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t) ??\n\t\t\tgetValueFromObjectPath( globalStyles, `settings.${ setting }` );\n\t\tif ( value !== undefined ) {\n\t\t\tresult = setImmutably( result, setting.split( '.' ), value );\n\t\t}\n\t} );\n\treturn result as T;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAqD;AAGrD,IAAM,iBAAiB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,SAAS,WACf,cACA,MACA,WACI;AACJ,QAAM,oBAAoB,YAAY,aAAa,YAAY;AAC/D,QAAM,uBAAuB,OAAO,MAAM,OAAO;AACjD,QAAM,iBAAiB,WAAY,iBAAkB,GAAI,oBAAqB;AAC9E,QAAM,aAAa,WAAY,oBAAqB;AAEpD,MAAK,MAAO;AACX,eAAS,sCAAwB,cAAc,cAAe,SAC7D,sCAAwB,cAAc,UAAW;AAAA,EACnD;AAEA,MAAI,SAAS,CAAC;AACd,iBAAe,QAAS,CAAE,YAAa;AACtC,UAAM,YACL;AAAA,MACC;AAAA,MACA,WAAY,iBAAkB,IAAK,OAAQ;AAAA,IAC5C,SACA,sCAAwB,cAAc,YAAa,OAAQ,EAAG;AAC/D,QAAK,UAAU,QAAY;AAC1B,mBAAS,4BAAc,QAAQ,QAAQ,MAAO,GAAI,GAAG,KAAM;AAAA,IAC5D;AAAA,EACD,CAAE;AACF,SAAO;AACR;",
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getValueFromObjectPath, setImmutably } from '../utils/object';\nimport type { GlobalStylesConfig } from '../types';\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'background.backgroundImage',\n\t'background.backgroundRepeat',\n\t'background.backgroundSize',\n\t'background.backgroundPosition',\n\t'background.gradient',\n\t'border.color',\n\t'border.radius',\n\t'border.radiusSizes',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.button',\n\t'color.caption',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.heading',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.aspectRatio',\n\t'dimensions.height',\n\t'dimensions.minHeight',\n\t'dimensions.minWidth',\n\t'dimensions.width',\n\t'dimensions.dimensionSizes',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'lightbox.enabled',\n\t'lightbox.allowEditing',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.defaultSpacingSizes',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.defaultFontSizes',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textAlign',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textIndent',\n\t'typography.textTransform',\n\t'typography.writingMode',\n\t'viewport.mobile',\n\t'viewport.tablet',\n];\n\nexport function getSetting< T = any >(\n\tglobalStyles: GlobalStylesConfig,\n\tpath: string,\n\tblockName?: string\n): T {\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = path ? '.' + path : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\n\tif ( path ) {\n\t\treturn ( getValueFromObjectPath( globalStyles, contextualPath ) ??\n\t\t\tgetValueFromObjectPath( globalStyles, globalPath ) ) as T;\n\t}\n\n\tlet result = {};\n\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\tconst value =\n\t\t\tgetValueFromObjectPath(\n\t\t\t\tglobalStyles,\n\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t) ??\n\t\t\tgetValueFromObjectPath( globalStyles, `settings.${ setting }` );\n\t\tif ( value !== undefined ) {\n\t\t\tresult = setImmutably( result, setting.split( '.' ), value );\n\t\t}\n\t} );\n\treturn result as T;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAqD;AAGrD,IAAM,iBAAiB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,SAAS,WACf,cACA,MACA,WACI;AACJ,QAAM,oBAAoB,YAAY,aAAa,YAAY;AAC/D,QAAM,uBAAuB,OAAO,MAAM,OAAO;AACjD,QAAM,iBAAiB,WAAY,iBAAkB,GAAI,oBAAqB;AAC9E,QAAM,aAAa,WAAY,oBAAqB;AAEpD,MAAK,MAAO;AACX,eAAS,sCAAwB,cAAc,cAAe,SAC7D,sCAAwB,cAAc,UAAW;AAAA,EACnD;AAEA,MAAI,SAAS,CAAC;AACd,iBAAe,QAAS,CAAE,YAAa;AACtC,UAAM,YACL;AAAA,MACC;AAAA,MACA,WAAY,iBAAkB,IAAK,OAAQ;AAAA,IAC5C,SACA,sCAAwB,cAAc,YAAa,OAAQ,EAAG;AAC/D,QAAK,UAAU,QAAY;AAC1B,mBAAS,4BAAc,QAAQ,QAAQ,MAAO,GAAI,GAAG,KAAM;AAAA,IAC5D;AAAA,EACD,CAAE;AACF,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/types.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["// =============================================================================\n// CORE PRIMITIVE TYPES\n// =============================================================================\n\n/**\n * Value that can be resolved from various sources (direct value, reference, or URL)\n */\nexport type UnresolvedValue =\n\t| string\n\t| number\n\t| { ref: string }\n\t| { url: string }\n\t| undefined\n\t| null;\n\n/**\n * Origin of a preset (theme, user customizations, or WordPress defaults)\n */\nexport type PresetOrigin = 'theme' | 'custom' | 'default';\n\n/**\n * Common properties for all preset types\n */\nexport interface BasePreset {\n\tname: string;\n\tslug: string;\n}\n\n// =============================================================================\n// COLOR SYSTEM TYPES\n// =============================================================================\n\n/**\n * Color preset definition\n */\nexport interface Color extends BasePreset {\n\tcolor: string;\n}\n\n/**\n * Gradient preset definition\n */\nexport interface Gradient extends BasePreset {\n\tgradient: string;\n}\n\n/**\n * Duotone filter preset definition\n */\nexport interface Duotone extends BasePreset {\n\tcolors: string[];\n}\n\n/**\n * Palette collection for a specific origin (theme, custom, default)\n */\nexport interface Palette {\n\tname: string;\n\tslug: PresetOrigin;\n\tcolors?: Color[];\n\tgradients?: Gradient[];\n\tduotones?: Duotone[];\n}\n\n/**\n * Multi-origin palette structure used by StyleBook\n */\nexport interface MultiOriginPalettes {\n\tcolors?: Palette[];\n\tgradients?: Palette[];\n\tduotones?: Palette[];\n\tdisableCustomColors?: boolean;\n\tdisableCustomGradients?: boolean;\n\thasColorsOrGradients?: boolean;\n}\n\n/**\n * Background style properties\n */\nexport interface BackgroundStyle {\n\tbackgroundColor?: UnresolvedValue;\n\tbackgroundImage?:\n\t\t| {\n\t\t\t\turl: string;\n\t\t\t\tid?: number;\n\t\t }\n\t\t| UnresolvedValue;\n\tbackgroundSize?: UnresolvedValue;\n\tbackgroundPosition?: UnresolvedValue;\n\tbackgroundRepeat?: UnresolvedValue;\n\tbackgroundAttachment?: UnresolvedValue;\n\tbackgroundBlendMode?: UnresolvedValue;\n\tbackgroundOpacity?: UnresolvedValue;\n}\n\n// =============================================================================\n// TYPOGRAPHY SYSTEM TYPES\n// =============================================================================\n\n/**\n * Fluid typography settings for responsive font sizes\n */\nexport interface FluidTypographyConfig {\n\tmin?: string;\n\tmax?: string;\n}\n\n/**\n * Typography preset (font size) definition\n */\nexport interface TypographyPreset extends BasePreset {\n\tsize: string | number | null;\n\tpreviewFontSize?: string;\n\tfluid?: boolean | FluidTypographyConfig;\n}\n\n/**\n * Font size preset definition (alias for TypographyPreset for clarity)\n */\nexport interface FontSizePreset extends TypographyPreset {}\n\n/**\n * Convenience type alias for font size data\n */\nexport type FontSize = FontSizePreset;\n\n/**\n * Font face definition as found in theme.json\n */\nexport interface FontFace {\n\tfontFamily: string;\n\tfontWeight?: string | number;\n\tfontStyle?: string;\n\tfontStretch?: string;\n\tfontDisplay?: string;\n\tsrc?: string | string[];\n}\n\n/**\n * Font family preset definition as found in theme.json\n */\nexport interface FontFamilyPreset extends BasePreset {\n\tfontFamily: string;\n\tfontFace?: FontFace[];\n}\n\n/**\n * Global fluid typography settings\n */\nexport interface FluidTypographySettings {\n\tmaxViewportWidth?: string;\n\tminFontSize?: string;\n\tminViewportWidth?: string;\n}\n\n/**\n * Typography settings collection\n */\nexport interface TypographySettings {\n\tfluid?: boolean | FluidTypographySettings;\n\tfontSizes?: TypographyPreset[] | Record< string, TypographyPreset[] >;\n\tfontFamilies?: Record< string, FontFamilyPreset[] >;\n\tdefaultFontSizes?: boolean;\n}\n\n// =============================================================================\n// LAYOUT SYSTEM TYPES\n// =============================================================================\n\n/**\n * Layout constraint settings\n */\nexport interface LayoutSettings {\n\twideSize?: string;\n\tcontentSize?: string;\n}\n\n/**\n * Spacing settings\n */\nexport interface SpacingSettings {\n\tpadding?: string | Record< string, string >;\n\tmargin?: string | Record< string, string >;\n\tblockGap?: string;\n}\n\n// =============================================================================\n// GLOBAL STYLES STRUCTURE TYPES\n// =============================================================================\n\n/**\n * Global styles settings node\n */\nexport interface GlobalStylesSettings {\n\tuseRootPaddingAwareAlignments?: boolean;\n\ttypography?: TypographySettings;\n\tlayout?: LayoutSettings;\n\tspacing?: SpacingSettings;\n\tcolor?: {\n\t\tpalette?:\n\t\t\t| Color[]\n\t\t\t| {\n\t\t\t\t\ttheme?: Color[];\n\t\t\t\t\tcustom?: Color[];\n\t\t\t\t\tdefault?: Color[];\n\t\t\t };\n\t\tgradients?: {\n\t\t\ttheme?: Gradient[];\n\t\t\tcustom?: Gradient[];\n\t\t\tdefault?: Gradient[];\n\t\t};\n\t\tduotone?: {\n\t\t\ttheme?: Duotone[];\n\t\t\tcustom?: Duotone[];\n\t\t\tdefault?: Duotone[];\n\t\t};\n\t\tlink?: boolean;\n\t\tcustom?: boolean;\n\t\tcustomGradient?: boolean;\n\t\tcustomDuotone?: boolean;\n\t\tdefaultPalette?: boolean;\n\t\tdefaultGradients?: boolean;\n\t\tdefaultDuotone?: boolean;\n\t};\n\tcustom?: Record<\n\t\tstring,\n\t\tstring | number | Record< string, string | number >\n\t>;\n\tblocks?: Record< string, Omit< GlobalStylesSettings, 'blocks' > >;\n}\n\n/**\n * Global styles values node\n */\nexport interface GlobalStylesStyles {\n\tcolor?: {\n\t\tbackground?: UnresolvedValue;\n\t\ttext?: UnresolvedValue;\n\t};\n\ttypography?: {\n\t\tfontFamily?: UnresolvedValue;\n\t\tfontSize?: UnresolvedValue;\n\t\tfontWeight?: UnresolvedValue;\n\t\tlineHeight?: UnresolvedValue;\n\t\tletterSpacing?: UnresolvedValue;\n\t\ttextTransform?: UnresolvedValue;\n\t\ttextIndent?: UnresolvedValue;\n\t};\n\tspacing?: {\n\t\tpadding?: UnresolvedValue | Record< string, UnresolvedValue >;\n\t\tmargin?: UnresolvedValue | Record< string, UnresolvedValue >;\n\t\tblockGap?: string;\n\t};\n\tbackground?: BackgroundStyle;\n\tborder?: {\n\t\tcolor?: UnresolvedValue;\n\t\twidth?: UnresolvedValue;\n\t\tstyle?: UnresolvedValue;\n\t\tradius?:\n\t\t\t| UnresolvedValue\n\t\t\t| {\n\t\t\t\t\ttopLeft?: UnresolvedValue;\n\t\t\t\t\ttopRight?: UnresolvedValue;\n\t\t\t\t\tbottomRight?: UnresolvedValue;\n\t\t\t\t\tbottomLeft?: UnresolvedValue;\n\t\t\t };\n\t\ttop?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tright?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tbottom?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tleft?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t};\n\tfilter?: {\n\t\tduotone?: UnresolvedValue;\n\t\topacity?: UnresolvedValue;\n\t};\n\tdimensions?: {\n\t\twidth?: UnresolvedValue;\n\t\theight?: UnresolvedValue;\n\t\tminWidth?: UnresolvedValue;\n\t\tminHeight?: UnresolvedValue;\n\t\tmaxWidth?: UnresolvedValue;\n\t\tmaxHeight?: UnresolvedValue;\n\t};\n\telements?: Record<\n\t\tstring,\n\t\tOmit< GlobalStylesStyles, 'blocks' | 'elements' | 'variations' > & {\n\t\t\t':hover'?: Omit<\n\t\t\t\tGlobalStylesStyles,\n\t\t\t\t'blocks' | 'elements' | 'variations'\n\t\t\t>;\n\t\t}\n\t>;\n\tblocks?: Record< string, Omit< GlobalStylesStyles, 'blocks' > >;\n\tvariations?: Record< string, Omit< GlobalStylesStyles, 'blocks' > >;\n\tcss?: string;\n}\n\n/**\n * Complete global styles configuration\n */\nexport interface GlobalStylesConfig {\n\tversion?: number;\n\tsettings?: GlobalStylesSettings;\n\tstyles?: GlobalStylesStyles;\n\t_links?: {\n\t\t[ 'wp:theme-file' ]?: ThemeFileLink[];\n\t\t[ 'wp:action-edit-css' ]?: Array< { href: string } >;\n\t};\n}\n\n/**\n * Style variation (extends GlobalStylesConfig with metadata)\n */\nexport interface StyleVariation extends GlobalStylesConfig {\n\ttitle?: string;\n\tdescription?: string;\n}\n\n/**\n * WordPress theme file link\n */\nexport interface ThemeFileLink {\n\tname: string;\n\thref: string;\n\ttarget?: string;\n}\n\n// =============================================================================\n// UTILITY TYPES\n// =============================================================================\n\n/**\n * Deep partial type for global styles merging\n */\nexport type DeepPartial< T > = {\n\t[ P in keyof T ]?: T[ P ] extends object ? DeepPartial< T[ P ] > : T[ P ];\n};\n\n/**\n * CSS selector string\n */\nexport type CSSSelector = string;\n\n/**\n * CSS property value\n */\nexport type CSSValue = string | number | undefined;\n\n/**\n * CSS rules object\n */\nexport type CSSRules = Record< string, CSSValue >;\n"],
|
|
4
|
+
"sourcesContent": ["// =============================================================================\n// CORE PRIMITIVE TYPES\n// =============================================================================\n\n/**\n * Value that can be resolved from various sources (direct value, reference, or URL)\n */\nexport type UnresolvedValue =\n\t| string\n\t| number\n\t| { ref: string }\n\t| { url: string }\n\t| undefined\n\t| null;\n\n/**\n * Origin of a preset (theme, user customizations, or WordPress defaults)\n */\nexport type PresetOrigin = 'theme' | 'custom' | 'default';\n\n/**\n * Common properties for all preset types\n */\nexport interface BasePreset {\n\tname: string;\n\tslug: string;\n}\n\n// =============================================================================\n// COLOR SYSTEM TYPES\n// =============================================================================\n\n/**\n * Color preset definition\n */\nexport interface Color extends BasePreset {\n\tcolor: string;\n}\n\n/**\n * Gradient preset definition\n */\nexport interface Gradient extends BasePreset {\n\tgradient: string;\n}\n\n/**\n * Duotone filter preset definition\n */\nexport interface Duotone extends BasePreset {\n\tcolors: string[];\n}\n\n/**\n * Palette collection for a specific origin (theme, custom, default)\n */\nexport interface Palette {\n\tname: string;\n\tslug: PresetOrigin;\n\tcolors?: Color[];\n\tgradients?: Gradient[];\n\tduotones?: Duotone[];\n}\n\n/**\n * Multi-origin palette structure used by StyleBook\n */\nexport interface MultiOriginPalettes {\n\tcolors?: Palette[];\n\tgradients?: Palette[];\n\tduotones?: Palette[];\n\tdisableCustomColors?: boolean;\n\tdisableCustomGradients?: boolean;\n\thasColorsOrGradients?: boolean;\n}\n\n/**\n * Background style properties\n */\nexport interface BackgroundStyle {\n\tbackgroundColor?: UnresolvedValue;\n\tbackgroundImage?:\n\t\t| {\n\t\t\t\turl: string;\n\t\t\t\tid?: number;\n\t\t }\n\t\t| UnresolvedValue;\n\tbackgroundSize?: UnresolvedValue;\n\tbackgroundPosition?: UnresolvedValue;\n\tbackgroundRepeat?: UnresolvedValue;\n\tbackgroundAttachment?: UnresolvedValue;\n\tbackgroundBlendMode?: UnresolvedValue;\n\tbackgroundOpacity?: UnresolvedValue;\n}\n\n// =============================================================================\n// TYPOGRAPHY SYSTEM TYPES\n// =============================================================================\n\n/**\n * Fluid typography settings for responsive font sizes\n */\nexport interface FluidTypographyConfig {\n\tmin?: string;\n\tmax?: string;\n}\n\n/**\n * Typography preset (font size) definition\n */\nexport interface TypographyPreset extends BasePreset {\n\tsize: string | number | null;\n\tpreviewFontSize?: string;\n\tfluid?: boolean | FluidTypographyConfig;\n}\n\n/**\n * Font size preset definition (alias for TypographyPreset for clarity)\n */\nexport interface FontSizePreset extends TypographyPreset {}\n\n/**\n * Convenience type alias for font size data\n */\nexport type FontSize = FontSizePreset;\n\n/**\n * Font face definition as found in theme.json\n */\nexport interface FontFace {\n\tfontFamily: string;\n\tfontWeight?: string | number;\n\tfontStyle?: string;\n\tfontStretch?: string;\n\tfontDisplay?: string;\n\tsrc?: string | string[];\n}\n\n/**\n * Font family preset definition as found in theme.json\n */\nexport interface FontFamilyPreset extends BasePreset {\n\tfontFamily: string;\n\tfontFace?: FontFace[];\n}\n\n/**\n * Global fluid typography settings\n */\nexport interface FluidTypographySettings {\n\tmaxViewportWidth?: string;\n\tminFontSize?: string;\n\tminViewportWidth?: string;\n}\n\n/**\n * Typography settings collection\n */\nexport interface TypographySettings {\n\tfluid?: boolean | FluidTypographySettings;\n\tfontSizes?: TypographyPreset[] | Record< string, TypographyPreset[] >;\n\tfontFamilies?: Record< string, FontFamilyPreset[] >;\n\tdefaultFontSizes?: boolean;\n}\n\n// =============================================================================\n// LAYOUT SYSTEM TYPES\n// =============================================================================\n\n/**\n * Layout constraint settings\n */\nexport interface LayoutSettings {\n\twideSize?: string;\n\tcontentSize?: string;\n}\n\n/**\n * Spacing settings\n */\nexport interface SpacingSettings {\n\tpadding?: string | Record< string, string >;\n\tmargin?: string | Record< string, string >;\n\tblockGap?: string;\n}\n\n// =============================================================================\n// GLOBAL STYLES STRUCTURE TYPES\n// =============================================================================\n\n/**\n * Global styles settings node\n */\nexport interface GlobalStylesSettings {\n\tuseRootPaddingAwareAlignments?: boolean;\n\tviewport?: {\n\t\tmobile?: string;\n\t\ttablet?: string;\n\t};\n\ttypography?: TypographySettings;\n\tlayout?: LayoutSettings;\n\tspacing?: SpacingSettings;\n\tcolor?: {\n\t\tpalette?:\n\t\t\t| Color[]\n\t\t\t| {\n\t\t\t\t\ttheme?: Color[];\n\t\t\t\t\tcustom?: Color[];\n\t\t\t\t\tdefault?: Color[];\n\t\t\t };\n\t\tgradients?: {\n\t\t\ttheme?: Gradient[];\n\t\t\tcustom?: Gradient[];\n\t\t\tdefault?: Gradient[];\n\t\t};\n\t\tduotone?: {\n\t\t\ttheme?: Duotone[];\n\t\t\tcustom?: Duotone[];\n\t\t\tdefault?: Duotone[];\n\t\t};\n\t\tlink?: boolean;\n\t\tcustom?: boolean;\n\t\tcustomGradient?: boolean;\n\t\tcustomDuotone?: boolean;\n\t\tdefaultPalette?: boolean;\n\t\tdefaultGradients?: boolean;\n\t\tdefaultDuotone?: boolean;\n\t};\n\tcustom?: Record<\n\t\tstring,\n\t\tstring | number | Record< string, string | number >\n\t>;\n\tblocks?: Record< string, Omit< GlobalStylesSettings, 'blocks' > >;\n}\n\n/**\n * Global styles values node\n */\nexport interface GlobalStylesStyles {\n\tcolor?: {\n\t\tbackground?: UnresolvedValue;\n\t\ttext?: UnresolvedValue;\n\t};\n\ttypography?: {\n\t\tfontFamily?: UnresolvedValue;\n\t\tfontSize?: UnresolvedValue;\n\t\tfontWeight?: UnresolvedValue;\n\t\tlineHeight?: UnresolvedValue;\n\t\tletterSpacing?: UnresolvedValue;\n\t\ttextTransform?: UnresolvedValue;\n\t\ttextIndent?: UnresolvedValue;\n\t};\n\tspacing?: {\n\t\tpadding?: UnresolvedValue | Record< string, UnresolvedValue >;\n\t\tmargin?: UnresolvedValue | Record< string, UnresolvedValue >;\n\t\tblockGap?: string;\n\t};\n\tbackground?: BackgroundStyle;\n\tborder?: {\n\t\tcolor?: UnresolvedValue;\n\t\twidth?: UnresolvedValue;\n\t\tstyle?: UnresolvedValue;\n\t\tradius?:\n\t\t\t| UnresolvedValue\n\t\t\t| {\n\t\t\t\t\ttopLeft?: UnresolvedValue;\n\t\t\t\t\ttopRight?: UnresolvedValue;\n\t\t\t\t\tbottomRight?: UnresolvedValue;\n\t\t\t\t\tbottomLeft?: UnresolvedValue;\n\t\t\t };\n\t\ttop?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tright?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tbottom?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tleft?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t};\n\tfilter?: {\n\t\tduotone?: UnresolvedValue;\n\t\topacity?: UnresolvedValue;\n\t};\n\tdimensions?: {\n\t\twidth?: UnresolvedValue;\n\t\theight?: UnresolvedValue;\n\t\tminWidth?: UnresolvedValue;\n\t\tminHeight?: UnresolvedValue;\n\t\tmaxWidth?: UnresolvedValue;\n\t\tmaxHeight?: UnresolvedValue;\n\t};\n\telements?: Record<\n\t\tstring,\n\t\tOmit< GlobalStylesStyles, 'blocks' | 'elements' | 'variations' > & {\n\t\t\t':hover'?: Omit<\n\t\t\t\tGlobalStylesStyles,\n\t\t\t\t'blocks' | 'elements' | 'variations'\n\t\t\t>;\n\t\t}\n\t>;\n\tblocks?: Record< string, Omit< GlobalStylesStyles, 'blocks' > >;\n\tvariations?: Record< string, Omit< GlobalStylesStyles, 'blocks' > >;\n\tcss?: string;\n}\n\n/**\n * Complete global styles configuration\n */\nexport interface GlobalStylesConfig {\n\tversion?: number;\n\tsettings?: GlobalStylesSettings;\n\tstyles?: GlobalStylesStyles;\n\t_links?: {\n\t\t[ 'wp:theme-file' ]?: ThemeFileLink[];\n\t\t[ 'wp:action-edit-css' ]?: Array< { href: string } >;\n\t};\n}\n\n/**\n * Style variation (extends GlobalStylesConfig with metadata)\n */\nexport interface StyleVariation extends GlobalStylesConfig {\n\ttitle?: string;\n\tdescription?: string;\n}\n\n/**\n * WordPress theme file link\n */\nexport interface ThemeFileLink {\n\tname: string;\n\thref: string;\n\ttarget?: string;\n}\n\n// =============================================================================\n// UTILITY TYPES\n// =============================================================================\n\n/**\n * Deep partial type for global styles merging\n */\nexport type DeepPartial< T > = {\n\t[ P in keyof T ]?: T[ P ] extends object ? DeepPartial< T[ P ] > : T[ P ];\n};\n\n/**\n * CSS selector string\n */\nexport type CSSSelector = string;\n\n/**\n * CSS property value\n */\nexport type CSSValue = string | number | undefined;\n\n/**\n * CSS rules object\n */\nexport type CSSRules = Record< string, CSSValue >;\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/utils/common.cjs
CHANGED
|
@@ -237,10 +237,8 @@ function getBlockStyleVariationSelector(variation, blockSelector) {
|
|
|
237
237
|
if (!blockSelector) {
|
|
238
238
|
return variationClass;
|
|
239
239
|
}
|
|
240
|
-
const ancestorRegex = /
|
|
241
|
-
const addVariationClass = (
|
|
242
|
-
return group1 + group2 + variationClass;
|
|
243
|
-
};
|
|
240
|
+
const ancestorRegex = /[^\s:]+/;
|
|
241
|
+
const addVariationClass = (match) => match + variationClass;
|
|
244
242
|
const result = splitSelectorList(blockSelector).map(
|
|
245
243
|
(part) => part.replace(ancestorRegex, addVariationClass)
|
|
246
244
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 function splitSelectorList( selector: string ) {\n\tif ( ! selector.includes( ',' ) ) {\n\t\treturn [ selector ];\n\t}\n\n\tconst selectors: string[] = [];\n\tlet currentSelector = '';\n\tlet parenthesesDepth = 0;\n\n\tfor ( const char of selector ) {\n\t\tif ( char === '(' ) {\n\t\t\tparenthesesDepth++;\n\t\t} else if ( char === ')' && parenthesesDepth > 0 ) {\n\t\t\tparenthesesDepth--;\n\t\t} else if ( char === ',' && parenthesesDepth === 0 ) {\n\t\t\tselectors.push( currentSelector );\n\t\t\tcurrentSelector = '';\n\t\t\tcontinue;\n\t\t}\n\n\t\tcurrentSelector += char;\n\t}\n\n\tselectors.push( currentSelector );\n\n\treturn selectors;\n}\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 = splitSelectorList( scope );\n\tconst selectors = splitSelectorList( selector );\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 = splitSelectorList( selector );\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 = splitSelectorList( blockSelector ).map( ( part ) =>\n\t\tpart.replace( ancestorRegex, addVariationClass )\n\t);\n\n\treturn result.join( ',' );\n}\n\n/**\n * Generates the selector for a block style variation feature selector.\n *\n * Feature selectors can target a different element than the block root\n * selector. Apply the variation class directly to the selector that receives\n * the declarations instead of deriving it from the block root selector.\n *\n * @param variation Name for the variation.\n * @param featureSelector CSS selector for the feature.\n *\n * @return CSS selector for the block style variation feature.\n */\nexport function getBlockStyleVariationFeatureSelector(\n\tvariation: string,\n\tfeatureSelector: string\n) {\n\tconst variationClass = `.is-style-${ variation }`;\n\tconst selectorParts = splitSelectorList( featureSelector ).map(\n\t\t( selector ) => {\n\t\t\tconst trimmedSelector = selector.trim();\n\t\t\tconst prefix = `${ variationClass } `;\n\n\t\t\tif ( trimmedSelector.startsWith( prefix ) ) {\n\t\t\t\treturn trimmedSelector.slice( prefix.length );\n\t\t\t}\n\n\t\t\treturn trimmedSelector;\n\t\t}\n\t);\n\n\treturn getBlockStyleVariationSelector(\n\t\tvariation,\n\t\tselectorParts.join( ',' )\n\t);\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;AAAA;AAAA;AAGA,0BAAwC;AAYxC,wBAA2C;AAC3C,oBAAuC;AAEhC,IAAM,sBAAsB;AAC5B,IAAM,+BAA+B;AAErC,SAAS,kBAAmB,UAAmB;AACrD,MAAK,CAAE,SAAS,SAAU,GAAI,GAAI;AACjC,WAAO,CAAE,QAAS;AAAA,EACnB;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AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAE;AAEF,SAAO;AACR;AAcO,SAAS,iBAAkB,UAAkB,UAAmB;AACtE,MAAK,CAAE,SAAS,SAAU,GAAI,GAAI;AACjC,WAAO,WAAW;AAAA,EACnB;AACA,QAAM,YAAY,kBAAmB,QAAS;AAC9C,QAAM,eAAe,UAAU,IAAK,CAAE,QAAS,MAAM,QAAS;AAC9D,SAAO,aAAa,KAAM,GAAI;AAC/B;AAmBO,SAAS,+BACf,WACA,eACC;AACD,QAAM,iBAAiB,aAAc,SAAU;AAE/C,MAAK,CAAE,eAAgB;AACtB,WAAO;AAAA,EACR;
|
|
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 function splitSelectorList( selector: string ) {\n\tif ( ! selector.includes( ',' ) ) {\n\t\treturn [ selector ];\n\t}\n\n\tconst selectors: string[] = [];\n\tlet currentSelector = '';\n\tlet parenthesesDepth = 0;\n\n\tfor ( const char of selector ) {\n\t\tif ( char === '(' ) {\n\t\t\tparenthesesDepth++;\n\t\t} else if ( char === ')' && parenthesesDepth > 0 ) {\n\t\t\tparenthesesDepth--;\n\t\t} else if ( char === ',' && parenthesesDepth === 0 ) {\n\t\t\tselectors.push( currentSelector );\n\t\t\tcurrentSelector = '';\n\t\t\tcontinue;\n\t\t}\n\n\t\tcurrentSelector += char;\n\t}\n\n\tselectors.push( currentSelector );\n\n\treturn selectors;\n}\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 = splitSelectorList( scope );\n\tconst selectors = splitSelectorList( selector );\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 = splitSelectorList( selector );\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\t/*\n\t * Append the variation class to each selector's ancestor: the first run\n\t * of characters before any combinator (whitespace) or pseudo-class (`:`).\n\t * `String.prototype.replace` only replaces the first match.\n\t *\n\t * Examples (\"custom\" variation):\n\t * - `.wp-block` => `.wp-block.is-style-custom`\n\t * - `.wp-block .inner` => `.wp-block.is-style-custom .inner`\n\t * - `.wp-block:where(.a .b)` => `.wp-block.is-style-custom:where(.a .b)`\n\t * - `:where(.outer .inner)` => `:where(.outer.is-style-custom .inner)`\n\t */\n\tconst ancestorRegex = /[^\\s:]+/;\n\tconst addVariationClass = ( match: string ) => match + variationClass;\n\n\tconst result = splitSelectorList( blockSelector ).map( ( part ) =>\n\t\tpart.replace( ancestorRegex, addVariationClass )\n\t);\n\n\treturn result.join( ',' );\n}\n\n/**\n * Generates the selector for a block style variation feature selector.\n *\n * Feature selectors can target a different element than the block root\n * selector. Apply the variation class directly to the selector that receives\n * the declarations instead of deriving it from the block root selector.\n *\n * @param variation Name for the variation.\n * @param featureSelector CSS selector for the feature.\n *\n * @return CSS selector for the block style variation feature.\n */\nexport function getBlockStyleVariationFeatureSelector(\n\tvariation: string,\n\tfeatureSelector: string\n) {\n\tconst variationClass = `.is-style-${ variation }`;\n\tconst selectorParts = splitSelectorList( featureSelector ).map(\n\t\t( selector ) => {\n\t\t\tconst trimmedSelector = selector.trim();\n\t\t\tconst prefix = `${ variationClass } `;\n\n\t\t\tif ( trimmedSelector.startsWith( prefix ) ) {\n\t\t\t\treturn trimmedSelector.slice( prefix.length );\n\t\t\t}\n\n\t\t\treturn trimmedSelector;\n\t\t}\n\t);\n\n\treturn getBlockStyleVariationSelector(\n\t\tvariation,\n\t\tselectorParts.join( ',' )\n\t);\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;AAAA;AAAA;AAGA,0BAAwC;AAYxC,wBAA2C;AAC3C,oBAAuC;AAEhC,IAAM,sBAAsB;AAC5B,IAAM,+BAA+B;AAErC,SAAS,kBAAmB,UAAmB;AACrD,MAAK,CAAE,SAAS,SAAU,GAAI,GAAI;AACjC,WAAO,CAAE,QAAS;AAAA,EACnB;AAEA,QAAM,YAAsB,CAAC;AAC7B,MAAI,kBAAkB;AACtB,MAAI,mBAAmB;AAEvB,aAAY,QAAQ,UAAW;AAC9B,QAAK,SAAS,KAAM;AACnB;AAAA,IACD,WAAY,SAAS,OAAO,mBAAmB,GAAI;AAClD;AAAA,IACD,WAAY,SAAS,OAAO,qBAAqB,GAAI;AACpD,gBAAU,KAAM,eAAgB;AAChC,wBAAkB;AAClB;AAAA,IACD;AAEA,uBAAmB;AAAA,EACpB;AAEA,YAAU,KAAM,eAAgB;AAEhC,SAAO;AACR;AAEO,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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,MAAO,IAAK;AAAA,EACf,OAAO;AAEN,WAAO;AAAA,EACR;AAEA,QAAM,CAAE,MAAM,GAAG,IAAK,IAAI;AAC1B,MAAK,SAAS,UAAW;AACxB,WAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACA,MAAK,SAAS,UAAW;AACxB,WAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;AAwBO,SAAS,2BACf,UACA,WACA,mBACA,qBACM;AACN,MAAK,CAAE,qBAAsB;AAC5B,WAAO;AAAA,EACR;AAEA,QAAM,cAAc,4BAA6B,iBAAkB;AAEnE,QAAM,WAAW,gBAAgB;AAAA,IAChC,CAAE,SAAU,KAAK,gBAAgB;AAAA,EAClC;AAEA,MAAK,CAAE,UAAW;AAGjB,WAAO;AAAA,EACR;AACA,QAAM,EAAE,UAAU,KAAK,IAAI;AAE3B,QAAM,eAAe;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,MAAK,CAAE,cAAe;AAGrB,WAAO;AAAA,EACR;AAEA,SAAO,cAAe,WAAY,IAAK,aAAa,IAAK;AAC1D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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/viewport.ts
|
|
21
|
+
var viewport_exports = {};
|
|
22
|
+
__export(viewport_exports, {
|
|
23
|
+
getResponsiveMediaQueries: () => getResponsiveMediaQueries,
|
|
24
|
+
getViewportBreakpointValueInPixels: () => getViewportBreakpointValueInPixels,
|
|
25
|
+
getViewportBreakpoints: () => getViewportBreakpoints
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(viewport_exports);
|
|
28
|
+
var DEFAULT_VIEWPORT_BREAKPOINTS = {
|
|
29
|
+
mobile: "480px",
|
|
30
|
+
tablet: "782px"
|
|
31
|
+
};
|
|
32
|
+
var VIEWPORT_SIZE_REGEXP = /^(\d+|\d*\.\d+)(px|em|rem)$/;
|
|
33
|
+
var DEFAULT_FONT_SIZE = 16;
|
|
34
|
+
function isViewportSettings(configOrSettings) {
|
|
35
|
+
return "mobile" in configOrSettings || "tablet" in configOrSettings;
|
|
36
|
+
}
|
|
37
|
+
function getViewportSettings(configOrSettings) {
|
|
38
|
+
if (!configOrSettings || typeof configOrSettings !== "object") {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
if (isViewportSettings(configOrSettings)) {
|
|
42
|
+
return configOrSettings;
|
|
43
|
+
}
|
|
44
|
+
return configOrSettings.settings?.viewport ?? {};
|
|
45
|
+
}
|
|
46
|
+
function isValidViewportSize(value) {
|
|
47
|
+
return typeof value === "string" && VIEWPORT_SIZE_REGEXP.test(value.trim());
|
|
48
|
+
}
|
|
49
|
+
function getViewportBreakpointValueInPixels(value) {
|
|
50
|
+
if (typeof value === "number") {
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
if (typeof value !== "string") {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
const match = value.trim().match(VIEWPORT_SIZE_REGEXP);
|
|
57
|
+
if (!match) {
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
const numericValue = Number.parseFloat(match[1]);
|
|
61
|
+
const unit = match[2];
|
|
62
|
+
return unit === "px" ? numericValue : numericValue * DEFAULT_FONT_SIZE;
|
|
63
|
+
}
|
|
64
|
+
function getViewportBreakpoints(configOrSettings) {
|
|
65
|
+
const viewportSettings = getViewportSettings(configOrSettings);
|
|
66
|
+
const breakpoints = {};
|
|
67
|
+
const breakpointValuesInPixels = {};
|
|
68
|
+
Object.keys(DEFAULT_VIEWPORT_BREAKPOINTS).forEach((breakpoint) => {
|
|
69
|
+
const key = breakpoint;
|
|
70
|
+
const value = viewportSettings[key];
|
|
71
|
+
const px = getViewportBreakpointValueInPixels(value);
|
|
72
|
+
if (px !== void 0 && isValidViewportSize(value)) {
|
|
73
|
+
breakpoints[key] = value.trim();
|
|
74
|
+
breakpointValuesInPixels[key] = px;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const breakpointNames = Object.keys(breakpoints);
|
|
78
|
+
if (!breakpointNames.length) {
|
|
79
|
+
return { ...DEFAULT_VIEWPORT_BREAKPOINTS };
|
|
80
|
+
}
|
|
81
|
+
if (1 === breakpointNames.length) {
|
|
82
|
+
return breakpoints;
|
|
83
|
+
}
|
|
84
|
+
const mobile = breakpoints.mobile;
|
|
85
|
+
const tablet = breakpoints.tablet;
|
|
86
|
+
if (breakpointValuesInPixels.mobile >= breakpointValuesInPixels.tablet) {
|
|
87
|
+
return { mobile };
|
|
88
|
+
}
|
|
89
|
+
return { mobile, tablet };
|
|
90
|
+
}
|
|
91
|
+
function getResponsiveMediaQueries(configOrSettings) {
|
|
92
|
+
const breakpoints = getViewportBreakpoints(configOrSettings);
|
|
93
|
+
const mediaQueries = {};
|
|
94
|
+
if (breakpoints.mobile) {
|
|
95
|
+
mediaQueries["@mobile"] = `@media (width <= ${breakpoints.mobile})`;
|
|
96
|
+
}
|
|
97
|
+
if (breakpoints.tablet) {
|
|
98
|
+
mediaQueries["@tablet"] = breakpoints.mobile ? `@media (${breakpoints.mobile} < width <= ${breakpoints.tablet})` : `@media (width <= ${breakpoints.tablet})`;
|
|
99
|
+
}
|
|
100
|
+
return mediaQueries;
|
|
101
|
+
}
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
getResponsiveMediaQueries,
|
|
105
|
+
getViewportBreakpointValueInPixels,
|
|
106
|
+
getViewportBreakpoints
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=viewport.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/viewport.ts"],
|
|
4
|
+
"sourcesContent": ["import type { GlobalStylesConfig } from '../types';\n\nconst DEFAULT_VIEWPORT_BREAKPOINTS = {\n\tmobile: '480px',\n\ttablet: '782px',\n};\n\ntype ViewportBreakpoint = keyof typeof DEFAULT_VIEWPORT_BREAKPOINTS;\ntype ViewportSettings = Partial< Record< ViewportBreakpoint, string > >;\ntype ViewportBreakpoints = Partial< Record< ViewportBreakpoint, string > >;\n\n// Matches positive CSS length values supported for viewport breakpoints, and\n// captures the numeric value and unit for conversion to pixels.\nconst VIEWPORT_SIZE_REGEXP = /^(\\d+|\\d*\\.\\d+)(px|em|rem)$/;\nconst DEFAULT_FONT_SIZE = 16;\n\nfunction isViewportSettings(\n\tconfigOrSettings: GlobalStylesConfig | ViewportSettings\n): configOrSettings is ViewportSettings {\n\treturn 'mobile' in configOrSettings || 'tablet' in configOrSettings;\n}\n\nfunction getViewportSettings(\n\tconfigOrSettings?: GlobalStylesConfig | ViewportSettings\n): ViewportSettings {\n\tif ( ! configOrSettings || typeof configOrSettings !== 'object' ) {\n\t\treturn {};\n\t}\n\n\tif ( isViewportSettings( configOrSettings ) ) {\n\t\treturn configOrSettings;\n\t}\n\n\treturn configOrSettings.settings?.viewport ?? {};\n}\n\nfunction isValidViewportSize( value: unknown ): value is string {\n\treturn (\n\t\ttypeof value === 'string' && VIEWPORT_SIZE_REGEXP.test( value.trim() )\n\t);\n}\n\n/**\n * Converts a viewport breakpoint value to pixels.\n *\n * Numeric values are returned as-is. CSS length values are only supported when\n * expressed in px, em, or rem units.\n *\n * @param value Breakpoint value as a number or CSS length.\n * @return The breakpoint value in pixels, or undefined when invalid.\n */\nexport function getViewportBreakpointValueInPixels(\n\tvalue: number | string | undefined\n): number | undefined {\n\tif ( typeof value === 'number' ) {\n\t\treturn value;\n\t}\n\n\tif ( typeof value !== 'string' ) {\n\t\treturn undefined;\n\t}\n\n\tconst match = value.trim().match( VIEWPORT_SIZE_REGEXP );\n\tif ( ! match ) {\n\t\treturn undefined;\n\t}\n\n\tconst numericValue = Number.parseFloat( match[ 1 ] );\n\tconst unit = match[ 2 ];\n\n\t// Use the most common browser default font size as the base for em/rem\n\t// media query conversions. This pixel value is used to compare breakpoint\n\t// order and calculate preview sizes; generated media queries keep the\n\t// original units.\n\treturn unit === 'px' ? numericValue : numericValue * DEFAULT_FONT_SIZE;\n}\n\n/**\n * Returns sanitized viewport breakpoints keyed by viewport state.\n *\n * Falls back to default breakpoints when no valid values are provided. If the\n * mobile breakpoint is missing, a valid tablet breakpoint remains keyed as\n * tablet so the editor can present it as a tablet breakpoint. If the tablet\n * breakpoint is missing, invalid, or not larger than the mobile breakpoint, the\n * result only includes the mobile breakpoint.\n *\n * @param configOrSettings Global styles config or viewport settings.\n * @return Sanitized viewport breakpoints.\n */\nexport function getViewportBreakpoints(\n\tconfigOrSettings?: GlobalStylesConfig | ViewportSettings\n): ViewportBreakpoints {\n\tconst viewportSettings = getViewportSettings( configOrSettings );\n\tconst breakpoints: ViewportBreakpoints = {};\n\tconst breakpointValuesInPixels: Partial<\n\t\tRecord< ViewportBreakpoint, number >\n\t> = {};\n\n\tObject.keys( DEFAULT_VIEWPORT_BREAKPOINTS ).forEach( ( breakpoint ) => {\n\t\tconst key = breakpoint as ViewportBreakpoint;\n\t\tconst value = viewportSettings[ key ];\n\t\tconst px = getViewportBreakpointValueInPixels( value );\n\t\tif ( px !== undefined && isValidViewportSize( value ) ) {\n\t\t\tbreakpoints[ key ] = value.trim();\n\t\t\tbreakpointValuesInPixels[ key ] = px;\n\t\t}\n\t} );\n\n\tconst breakpointNames = Object.keys( breakpoints );\n\tif ( ! breakpointNames.length ) {\n\t\treturn { ...DEFAULT_VIEWPORT_BREAKPOINTS };\n\t}\n\n\tif ( 1 === breakpointNames.length ) {\n\t\treturn breakpoints;\n\t}\n\n\tconst mobile = breakpoints.mobile!;\n\tconst tablet = breakpoints.tablet!;\n\tif (\n\t\tbreakpointValuesInPixels.mobile! >= breakpointValuesInPixels.tablet!\n\t) {\n\t\treturn { mobile };\n\t}\n\n\treturn { mobile, tablet };\n}\n\n/**\n * Returns responsive media query aliases for the configured viewport\n * breakpoints.\n *\n * @param configOrSettings Global styles config or viewport settings.\n * @return Responsive media queries keyed by alias.\n */\nexport function getResponsiveMediaQueries(\n\tconfigOrSettings?: GlobalStylesConfig | ViewportSettings\n): Record< string, string > {\n\tconst breakpoints = getViewportBreakpoints( configOrSettings );\n\tconst mediaQueries: Record< string, string > = {};\n\n\tif ( breakpoints.mobile ) {\n\t\tmediaQueries[ '@mobile' ] = `@media (width <= ${ breakpoints.mobile })`;\n\t}\n\n\tif ( breakpoints.tablet ) {\n\t\tmediaQueries[ '@tablet' ] = breakpoints.mobile\n\t\t\t? `@media (${ breakpoints.mobile } < width <= ${ breakpoints.tablet })`\n\t\t\t: `@media (width <= ${ breakpoints.tablet })`;\n\t}\n\n\treturn mediaQueries;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA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