2022-09-20 11:43:29 -04:00
|
|
|
/******/ (function() { // webpackBootstrap
|
|
|
|
/******/ "use strict";
|
|
|
|
/******/ // The require scope
|
|
|
|
/******/ var __webpack_require__ = {};
|
|
|
|
/******/
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ /* webpack/runtime/define property getters */
|
|
|
|
/******/ !function() {
|
|
|
|
/******/ // define getter functions for harmony exports
|
|
|
|
/******/ __webpack_require__.d = function(exports, definition) {
|
|
|
|
/******/ for(var key in definition) {
|
|
|
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
|
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
|
|
/******/ }
|
|
|
|
/******/ }
|
|
|
|
/******/ };
|
|
|
|
/******/ }();
|
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
|
|
/******/ !function() {
|
|
|
|
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
|
|
|
/******/ }();
|
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/make namespace object */
|
|
|
|
/******/ !function() {
|
|
|
|
/******/ // define __esModule on exports
|
|
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
/******/ }
|
|
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
/******/ };
|
|
|
|
/******/ }();
|
|
|
|
/******/
|
|
|
|
/************************************************************************/
|
|
|
|
var __webpack_exports__ = {};
|
|
|
|
// ESM COMPAT FLAG
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
|
"compileCSS": function() { return /* binding */ compileCSS; },
|
|
|
|
"getCSSRules": function() { return /* binding */ getCSSRules; }
|
|
|
|
});
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: external "lodash"
|
|
|
|
var external_lodash_namespaceObject = window["lodash"];
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/constants.js
|
|
|
|
const VARIABLE_REFERENCE_PREFIX = 'var:';
|
|
|
|
const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
|
|
|
|
const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/utils.js
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a JSON representation of the generated CSS rules.
|
|
|
|
*
|
2023-06-27 10:24:19 -04:00
|
|
|
* @param style Style object.
|
|
|
|
* @param options Options object with settings to adjust how the styles are generated.
|
|
|
|
* @param path An array of strings representing the path to the style value in the style object.
|
|
|
|
* @param ruleKey A CSS property key.
|
2022-09-20 11:43:29 -04:00
|
|
|
*
|
|
|
|
* @return GeneratedCSSRule[] CSS rules.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function generateRule(style, options, path, ruleKey) {
|
|
|
|
const styleValue = (0,external_lodash_namespaceObject.get)(style, path);
|
|
|
|
return styleValue ? [{
|
2023-06-27 10:24:19 -04:00
|
|
|
selector: options?.selector,
|
2022-09-20 11:43:29 -04:00
|
|
|
key: ruleKey,
|
|
|
|
value: getCSSVarFromStyleValue(styleValue)
|
|
|
|
}] : [];
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Returns a JSON representation of the generated CSS rules taking into account box model properties, top, right, bottom, left.
|
|
|
|
*
|
2023-06-27 10:24:19 -04:00
|
|
|
* @param style Style object.
|
|
|
|
* @param options Options object with settings to adjust how the styles are generated.
|
|
|
|
* @param path An array of strings representing the path to the style value in the style object.
|
|
|
|
* @param ruleKeys An array of CSS property keys and patterns.
|
|
|
|
* @param individualProperties The "sides" or individual properties for which to generate rules.
|
2022-09-20 11:43:29 -04:00
|
|
|
*
|
|
|
|
* @return GeneratedCSSRule[] CSS rules.
|
|
|
|
*/
|
|
|
|
|
2023-06-27 10:24:19 -04:00
|
|
|
function generateBoxRules(style, options, path, ruleKeys, individualProperties = ['top', 'right', 'bottom', 'left']) {
|
2022-09-20 11:43:29 -04:00
|
|
|
const boxStyle = (0,external_lodash_namespaceObject.get)(style, path);
|
|
|
|
|
|
|
|
if (!boxStyle) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
const rules = [];
|
|
|
|
|
|
|
|
if (typeof boxStyle === 'string') {
|
|
|
|
rules.push({
|
2023-06-27 10:24:19 -04:00
|
|
|
selector: options?.selector,
|
2022-09-20 11:43:29 -04:00
|
|
|
key: ruleKeys.default,
|
|
|
|
value: boxStyle
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
const sideRules = individualProperties.reduce((acc, side) => {
|
|
|
|
const value = getCSSVarFromStyleValue((0,external_lodash_namespaceObject.get)(boxStyle, [side]));
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
acc.push({
|
2023-06-27 10:24:19 -04:00
|
|
|
selector: options?.selector,
|
|
|
|
key: ruleKeys?.individual.replace('%s', upperFirst(side)),
|
2022-09-20 11:43:29 -04:00
|
|
|
value
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
}, []);
|
|
|
|
rules.push(...sideRules);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rules;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Returns a CSS var value from incoming style value following the pattern `var:description|context|slug`.
|
|
|
|
*
|
2023-06-27 10:24:19 -04:00
|
|
|
* @param styleValue A raw style value.
|
2022-09-20 11:43:29 -04:00
|
|
|
*
|
|
|
|
* @return string A CSS var value.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function getCSSVarFromStyleValue(styleValue) {
|
|
|
|
if (typeof styleValue === 'string' && styleValue.startsWith(VARIABLE_REFERENCE_PREFIX)) {
|
2022-09-27 13:32:52 -04:00
|
|
|
const variable = styleValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).map(presetVariable => (0,external_lodash_namespaceObject.kebabCase)(presetVariable)).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
|
2022-09-20 11:43:29 -04:00
|
|
|
return `var(--wp--${variable})`;
|
|
|
|
}
|
|
|
|
|
|
|
|
return styleValue;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Capitalizes the first letter in a string.
|
|
|
|
*
|
2023-06-27 10:24:19 -04:00
|
|
|
* @param string The string whose first letter the function will capitalize.
|
2022-09-20 11:43:29 -04:00
|
|
|
*
|
2023-02-07 02:04:52 -05:00
|
|
|
* @return String with the first letter capitalized.
|
2022-09-20 11:43:29 -04:00
|
|
|
*/
|
|
|
|
|
2023-02-07 02:04:52 -05:00
|
|
|
function upperFirst(string) {
|
|
|
|
const [firstLetter, ...rest] = string;
|
2022-09-20 11:43:29 -04:00
|
|
|
return firstLetter.toUpperCase() + rest.join('');
|
|
|
|
}
|
2023-02-07 02:04:52 -05:00
|
|
|
/**
|
|
|
|
* Converts an array of strings into a camelCase string.
|
|
|
|
*
|
2023-06-27 10:24:19 -04:00
|
|
|
* @param strings The strings to join into a camelCase string.
|
2023-02-07 02:04:52 -05:00
|
|
|
*
|
|
|
|
* @return camelCase string.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function camelCaseJoin(strings) {
|
|
|
|
const [firstItem, ...rest] = strings;
|
|
|
|
return firstItem.toLowerCase() + rest.map(upperFirst).join('');
|
|
|
|
}
|
2022-09-20 11:43:29 -04:00
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/border/index.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
2023-02-07 02:04:52 -05:00
|
|
|
/**
|
|
|
|
* Creates a function for generating CSS rules when the style path is the same as the camelCase CSS property used in React.
|
|
|
|
*
|
2023-06-27 10:24:19 -04:00
|
|
|
* @param path An array of strings representing the path to the style value in the style object.
|
2023-02-07 02:04:52 -05:00
|
|
|
*
|
|
|
|
* @return A function that generates CSS rules.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function createBorderGenerateFunction(path) {
|
|
|
|
return (style, options) => generateRule(style, options, path, camelCaseJoin(path));
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Creates a function for generating border-{top,bottom,left,right}-{color,style,width} CSS rules.
|
|
|
|
*
|
2023-06-27 10:24:19 -04:00
|
|
|
* @param edge The edge to create CSS rules for.
|
2023-02-07 02:04:52 -05:00
|
|
|
*
|
|
|
|
* @return A function that generates CSS rules.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
function createBorderEdgeGenerateFunction(edge) {
|
|
|
|
return (style, options) => {
|
|
|
|
return ['color', 'style', 'width'].flatMap(key => {
|
|
|
|
const path = ['border', edge, key];
|
|
|
|
return createBorderGenerateFunction(path)(style, options);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-09-20 11:43:29 -04:00
|
|
|
const color = {
|
|
|
|
name: 'color',
|
2023-02-07 02:04:52 -05:00
|
|
|
generate: createBorderGenerateFunction(['border', 'color'])
|
2022-09-20 11:43:29 -04:00
|
|
|
};
|
|
|
|
const radius = {
|
|
|
|
name: 'radius',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateBoxRules(style, options, ['border', 'radius'], {
|
|
|
|
default: 'borderRadius',
|
|
|
|
individual: 'border%sRadius'
|
|
|
|
}, ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const borderStyle = {
|
|
|
|
name: 'style',
|
2023-02-07 02:04:52 -05:00
|
|
|
generate: createBorderGenerateFunction(['border', 'style'])
|
2022-09-20 11:43:29 -04:00
|
|
|
};
|
|
|
|
const width = {
|
|
|
|
name: 'width',
|
2023-02-07 02:04:52 -05:00
|
|
|
generate: createBorderGenerateFunction(['border', 'width'])
|
2022-09-20 11:43:29 -04:00
|
|
|
};
|
|
|
|
const borderTop = {
|
|
|
|
name: 'borderTop',
|
2023-02-07 02:04:52 -05:00
|
|
|
generate: createBorderEdgeGenerateFunction('top')
|
2022-09-20 11:43:29 -04:00
|
|
|
};
|
|
|
|
const borderRight = {
|
|
|
|
name: 'borderRight',
|
2023-02-07 02:04:52 -05:00
|
|
|
generate: createBorderEdgeGenerateFunction('right')
|
2022-09-20 11:43:29 -04:00
|
|
|
};
|
|
|
|
const borderBottom = {
|
|
|
|
name: 'borderBottom',
|
2023-02-07 02:04:52 -05:00
|
|
|
generate: createBorderEdgeGenerateFunction('bottom')
|
2022-09-20 11:43:29 -04:00
|
|
|
};
|
|
|
|
const borderLeft = {
|
|
|
|
name: 'borderLeft',
|
2023-02-07 02:04:52 -05:00
|
|
|
generate: createBorderEdgeGenerateFunction('left')
|
2022-09-20 11:43:29 -04:00
|
|
|
};
|
2023-02-07 02:04:52 -05:00
|
|
|
/* harmony default export */ var border = ([color, borderStyle, width, radius, borderTop, borderRight, borderBottom, borderLeft]);
|
2022-09-20 11:43:29 -04:00
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/background.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
const background = {
|
|
|
|
name: 'background',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['color', 'background'], 'backgroundColor');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/* harmony default export */ var color_background = (background);
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/gradient.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
const gradient = {
|
|
|
|
name: 'gradient',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['color', 'gradient'], 'background');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/* harmony default export */ var color_gradient = (gradient);
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/text.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
const text_text = {
|
|
|
|
name: 'text',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['color', 'text'], 'color');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/* harmony default export */ var color_text = (text_text);
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/index.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ var styles_color = ([color_text, color_gradient, color_background]);
|
|
|
|
|
2023-02-07 02:04:52 -05:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/dimensions/index.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
const minHeight = {
|
|
|
|
name: 'minHeight',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['dimensions', 'minHeight'], 'minHeight');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/* harmony default export */ var dimensions = ([minHeight]);
|
|
|
|
|
2022-09-20 11:43:29 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/shadow/index.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
const shadow = {
|
|
|
|
name: 'shadow',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['shadow'], 'boxShadow');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/* harmony default export */ var styles_shadow = ([shadow]);
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/outline/index.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
const outline_color = {
|
|
|
|
name: 'color',
|
2023-06-27 10:24:19 -04:00
|
|
|
generate: (style, options, path = ['outline', 'color'], ruleKey = 'outlineColor') => {
|
2022-09-20 11:43:29 -04:00
|
|
|
return generateRule(style, options, path, ruleKey);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const offset = {
|
|
|
|
name: 'offset',
|
2023-06-27 10:24:19 -04:00
|
|
|
generate: (style, options, path = ['outline', 'offset'], ruleKey = 'outlineOffset') => {
|
2022-09-20 11:43:29 -04:00
|
|
|
return generateRule(style, options, path, ruleKey);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const outlineStyle = {
|
|
|
|
name: 'style',
|
2023-06-27 10:24:19 -04:00
|
|
|
generate: (style, options, path = ['outline', 'style'], ruleKey = 'outlineStyle') => {
|
2022-09-20 11:43:29 -04:00
|
|
|
return generateRule(style, options, path, ruleKey);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const outline_width = {
|
|
|
|
name: 'width',
|
2023-06-27 10:24:19 -04:00
|
|
|
generate: (style, options, path = ['outline', 'width'], ruleKey = 'outlineWidth') => {
|
2022-09-20 11:43:29 -04:00
|
|
|
return generateRule(style, options, path, ruleKey);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/* harmony default export */ var outline = ([outline_color, outlineStyle, offset, outline_width]);
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/spacing/padding.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
const padding = {
|
|
|
|
name: 'padding',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateBoxRules(style, options, ['spacing', 'padding'], {
|
|
|
|
default: 'padding',
|
|
|
|
individual: 'padding%s'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/* harmony default export */ var spacing_padding = (padding);
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/spacing/margin.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
const margin = {
|
|
|
|
name: 'margin',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateBoxRules(style, options, ['spacing', 'margin'], {
|
|
|
|
default: 'margin',
|
|
|
|
individual: 'margin%s'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/* harmony default export */ var spacing_margin = (margin);
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/spacing/index.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* harmony default export */ var spacing = ([spacing_margin, spacing_padding]);
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/typography/index.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
const fontSize = {
|
|
|
|
name: 'fontSize',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['typography', 'fontSize'], 'fontSize');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const fontStyle = {
|
|
|
|
name: 'fontStyle',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['typography', 'fontStyle'], 'fontStyle');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const fontWeight = {
|
|
|
|
name: 'fontWeight',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['typography', 'fontWeight'], 'fontWeight');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const fontFamily = {
|
|
|
|
name: 'fontFamily',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['typography', 'fontFamily'], 'fontFamily');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const letterSpacing = {
|
|
|
|
name: 'letterSpacing',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['typography', 'letterSpacing'], 'letterSpacing');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const lineHeight = {
|
2023-06-27 10:24:19 -04:00
|
|
|
name: 'lineHeight',
|
2022-09-20 11:43:29 -04:00
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['typography', 'lineHeight'], 'lineHeight');
|
|
|
|
}
|
|
|
|
};
|
2023-02-07 02:04:52 -05:00
|
|
|
const textColumns = {
|
|
|
|
name: 'textColumns',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['typography', 'textColumns'], 'columnCount');
|
|
|
|
}
|
|
|
|
};
|
2022-09-20 11:43:29 -04:00
|
|
|
const textDecoration = {
|
|
|
|
name: 'textDecoration',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['typography', 'textDecoration'], 'textDecoration');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const textTransform = {
|
|
|
|
name: 'textTransform',
|
|
|
|
generate: (style, options) => {
|
|
|
|
return generateRule(style, options, ['typography', 'textTransform'], 'textTransform');
|
|
|
|
}
|
|
|
|
};
|
2023-02-07 02:04:52 -05:00
|
|
|
/* harmony default export */ var typography = ([fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textColumns, textDecoration, textTransform]);
|
2022-09-20 11:43:29 -04:00
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/index.js
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-07 02:04:52 -05:00
|
|
|
|
|
|
|
const styleDefinitions = [...border, ...styles_color, ...dimensions, ...outline, ...spacing, ...typography, ...styles_shadow];
|
2022-09-20 11:43:29 -04:00
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/index.js
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates a stylesheet for a given style object and selector.
|
|
|
|
*
|
|
|
|
* @since 6.1.0 Introduced in WordPress core.
|
|
|
|
*
|
2023-06-27 10:24:19 -04:00
|
|
|
* @param style Style object, for example, the value of a block's attributes.style object or the top level styles in theme.json
|
|
|
|
* @param options Options object with settings to adjust how the styles are generated.
|
2022-09-20 11:43:29 -04:00
|
|
|
*
|
|
|
|
* @return A generated stylesheet or inline style declarations.
|
|
|
|
*/
|
|
|
|
|
2023-06-27 10:24:19 -04:00
|
|
|
function compileCSS(style, options = {}) {
|
2022-09-20 11:43:29 -04:00
|
|
|
const rules = getCSSRules(style, options); // If no selector is provided, treat generated rules as inline styles to be returned as a single string.
|
|
|
|
|
2023-06-27 10:24:19 -04:00
|
|
|
if (!options?.selector) {
|
2022-09-20 11:43:29 -04:00
|
|
|
const inlineRules = [];
|
|
|
|
rules.forEach(rule => {
|
|
|
|
inlineRules.push(`${(0,external_lodash_namespaceObject.kebabCase)(rule.key)}: ${rule.value};`);
|
|
|
|
});
|
|
|
|
return inlineRules.join(' ');
|
|
|
|
}
|
|
|
|
|
2023-06-27 10:24:19 -04:00
|
|
|
const groupedRules = rules.reduce((acc, rule) => {
|
|
|
|
const {
|
|
|
|
selector
|
|
|
|
} = rule;
|
|
|
|
|
|
|
|
if (!selector) {
|
|
|
|
return acc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!acc[selector]) {
|
|
|
|
acc[selector] = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
acc[selector].push(rule);
|
|
|
|
return acc;
|
|
|
|
}, {});
|
2022-09-20 11:43:29 -04:00
|
|
|
const selectorRules = Object.keys(groupedRules).reduce((acc, subSelector) => {
|
|
|
|
acc.push(`${subSelector} { ${groupedRules[subSelector].map(rule => `${(0,external_lodash_namespaceObject.kebabCase)(rule.key)}: ${rule.value};`).join(' ')} }`);
|
|
|
|
return acc;
|
|
|
|
}, []);
|
|
|
|
return selectorRules.join('\n');
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Returns a JSON representation of the generated CSS rules.
|
|
|
|
*
|
|
|
|
* @since 6.1.0 Introduced in WordPress core.
|
|
|
|
*
|
2023-06-27 10:24:19 -04:00
|
|
|
* @param style Style object, for example, the value of a block's attributes.style object or the top level styles in theme.json
|
|
|
|
* @param options Options object with settings to adjust how the styles are generated.
|
2022-09-20 11:43:29 -04:00
|
|
|
*
|
|
|
|
* @return A collection of objects containing the selector, if any, the CSS property key (camelcase) and parsed CSS value.
|
|
|
|
*/
|
|
|
|
|
2023-06-27 10:24:19 -04:00
|
|
|
function getCSSRules(style, options = {}) {
|
2022-09-20 11:43:29 -04:00
|
|
|
const rules = [];
|
|
|
|
styleDefinitions.forEach(definition => {
|
|
|
|
if (typeof definition.generate === 'function') {
|
|
|
|
rules.push(...definition.generate(style, options));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return rules;
|
|
|
|
}
|
|
|
|
|
|
|
|
(window.wp = window.wp || {}).styleEngine = __webpack_exports__;
|
|
|
|
/******/ })()
|
|
|
|
;
|