@wordpress/style-engine 1.24.1-next.5a1d1283.0 → 1.25.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 +2 -0
- package/build/styles/background/index.js +43 -0
- package/build/styles/background/index.js.map +1 -0
- package/build/styles/index.js +2 -1
- package/build/styles/index.js.map +1 -1
- package/build/styles/utils.js +22 -0
- package/build/styles/utils.js.map +1 -1
- package/build/types.js.map +1 -1
- package/build-module/styles/background/index.js +36 -0
- package/build-module/styles/background/index.js.map +1 -0
- package/build-module/styles/index.js +2 -1
- package/build-module/styles/index.js.map +1 -1
- package/build-module/styles/utils.js +21 -0
- package/build-module/styles/utils.js.map +1 -1
- package/build-module/types.js.map +1 -1
- package/build-types/styles/background/index.d.ts +10 -0
- package/build-types/styles/background/index.d.ts.map +1 -0
- package/build-types/styles/index.d.ts.map +1 -1
- package/build-types/styles/utils.d.ts +14 -0
- package/build-types/styles/utils.d.ts.map +1 -1
- package/build-types/types.d.ts +7 -0
- package/build-types/types.d.ts.map +1 -1
- package/class-wp-style-engine.php +53 -1
- package/docs/using-the-style-engine-with-block-supports.md +8 -2
- package/package.json +2 -2
- package/src/styles/background/index.ts +43 -0
- package/src/styles/index.ts +2 -0
- package/src/styles/utils.ts +21 -0
- package/src/types.ts +7 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const backgroundImage = {
|
|
13
|
+
name: 'backgroundImage',
|
|
14
|
+
generate: (style, options) => {
|
|
15
|
+
const _backgroundImage = style?.background?.backgroundImage;
|
|
16
|
+
const _backgroundSize = style?.background?.backgroundSize;
|
|
17
|
+
const styleRules = [];
|
|
18
|
+
if (!_backgroundImage) {
|
|
19
|
+
return styleRules;
|
|
20
|
+
}
|
|
21
|
+
if (_backgroundImage?.source === 'file' && _backgroundImage?.url) {
|
|
22
|
+
styleRules.push({
|
|
23
|
+
selector: options.selector,
|
|
24
|
+
key: 'backgroundImage',
|
|
25
|
+
// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
|
|
26
|
+
value: `url( '${encodeURI((0, _utils.safeDecodeURI)(_backgroundImage.url))}' )`
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// If no background size is set, but an image is, default to cover.
|
|
31
|
+
if (!_backgroundSize) {
|
|
32
|
+
styleRules.push({
|
|
33
|
+
selector: options.selector,
|
|
34
|
+
key: 'backgroundSize',
|
|
35
|
+
value: 'cover'
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return styleRules;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var _default = [backgroundImage];
|
|
42
|
+
exports.default = _default;
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_utils","require","backgroundImage","name","generate","style","options","_backgroundImage","background","_backgroundSize","backgroundSize","styleRules","source","url","push","selector","key","value","encodeURI","safeDecodeURI","_default","exports","default"],"sources":["@wordpress/style-engine/src/styles/background/index.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { GeneratedCSSRule, Style, StyleOptions } from '../../types';\nimport { safeDecodeURI } from '../utils';\n\nconst backgroundImage = {\n\tname: 'backgroundImage',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\tconst _backgroundImage = style?.background?.backgroundImage;\n\t\tconst _backgroundSize = style?.background?.backgroundSize;\n\n\t\tconst styleRules: GeneratedCSSRule[] = [];\n\n\t\tif ( ! _backgroundImage ) {\n\t\t\treturn styleRules;\n\t\t}\n\n\t\tif ( _backgroundImage?.source === 'file' && _backgroundImage?.url ) {\n\t\t\tstyleRules.push( {\n\t\t\t\tselector: options.selector,\n\t\t\t\tkey: 'backgroundImage',\n\t\t\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t\t\tvalue: `url( '${ encodeURI(\n\t\t\t\t\tsafeDecodeURI( _backgroundImage.url )\n\t\t\t\t) }' )`,\n\t\t\t} );\n\t\t}\n\n\t\t// If no background size is set, but an image is, default to cover.\n\t\tif ( ! _backgroundSize ) {\n\t\t\tstyleRules.push( {\n\t\t\t\tselector: options.selector,\n\t\t\t\tkey: 'backgroundSize',\n\t\t\t\tvalue: 'cover',\n\t\t\t} );\n\t\t}\n\n\t\treturn styleRules;\n\t},\n};\n\nexport default [ backgroundImage ];\n"],"mappings":";;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA,MAAMC,eAAe,GAAG;EACvBC,IAAI,EAAE,iBAAiB;EACvBC,QAAQ,EAAEA,CAAEC,KAAY,EAAEC,OAAqB,KAAM;IACpD,MAAMC,gBAAgB,GAAGF,KAAK,EAAEG,UAAU,EAAEN,eAAe;IAC3D,MAAMO,eAAe,GAAGJ,KAAK,EAAEG,UAAU,EAAEE,cAAc;IAEzD,MAAMC,UAA8B,GAAG,EAAE;IAEzC,IAAK,CAAEJ,gBAAgB,EAAG;MACzB,OAAOI,UAAU;IAClB;IAEA,IAAKJ,gBAAgB,EAAEK,MAAM,KAAK,MAAM,IAAIL,gBAAgB,EAAEM,GAAG,EAAG;MACnEF,UAAU,CAACG,IAAI,CAAE;QAChBC,QAAQ,EAAET,OAAO,CAACS,QAAQ;QAC1BC,GAAG,EAAE,iBAAiB;QACtB;QACAC,KAAK,EAAG,SAASC,SAAS,CACzB,IAAAC,oBAAa,EAAEZ,gBAAgB,CAACM,GAAI,CACrC,CAAG;MACJ,CAAE,CAAC;IACJ;;IAEA;IACA,IAAK,CAAEJ,eAAe,EAAG;MACxBE,UAAU,CAACG,IAAI,CAAE;QAChBC,QAAQ,EAAET,OAAO,CAACS,QAAQ;QAC1BC,GAAG,EAAE,gBAAgB;QACrBC,KAAK,EAAE;MACR,CAAE,CAAC;IACJ;IAEA,OAAON,UAAU;EAClB;AACD,CAAC;AAAC,IAAAS,QAAA,GAEa,CAAElB,eAAe,CAAE;AAAAmB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
package/build/styles/index.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.styleDefinitions = void 0;
|
|
|
8
8
|
var _border = _interopRequireDefault(require("./border"));
|
|
9
9
|
var _color = _interopRequireDefault(require("./color"));
|
|
10
10
|
var _dimensions = _interopRequireDefault(require("./dimensions"));
|
|
11
|
+
var _background = _interopRequireDefault(require("./background"));
|
|
11
12
|
var _shadow = _interopRequireDefault(require("./shadow"));
|
|
12
13
|
var _outline = _interopRequireDefault(require("./outline"));
|
|
13
14
|
var _spacing = _interopRequireDefault(require("./spacing"));
|
|
@@ -16,6 +17,6 @@ var _typography = _interopRequireDefault(require("./typography"));
|
|
|
16
17
|
* Internal dependencies
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
|
-
const styleDefinitions = [..._border.default, ..._color.default, ..._dimensions.default, ..._outline.default, ..._spacing.default, ..._typography.default, ..._shadow.default];
|
|
20
|
+
const styleDefinitions = [..._border.default, ..._color.default, ..._dimensions.default, ..._outline.default, ..._spacing.default, ..._typography.default, ..._shadow.default, ..._background.default];
|
|
20
21
|
exports.styleDefinitions = styleDefinitions;
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_border","_interopRequireDefault","require","_color","_dimensions","_shadow","_outline","_spacing","_typography","styleDefinitions","border","color","dimensions","outline","spacing","typography","shadow","exports"],"sources":["@wordpress/style-engine/src/styles/index.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport border from './border';\nimport color from './color';\nimport dimensions from './dimensions';\nimport shadow from './shadow';\nimport outline from './outline';\nimport spacing from './spacing';\nimport typography from './typography';\n\nexport const styleDefinitions = [\n\t...border,\n\t...color,\n\t...dimensions,\n\t...outline,\n\t...spacing,\n\t...typography,\n\t...shadow,\n];\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,
|
|
1
|
+
{"version":3,"names":["_border","_interopRequireDefault","require","_color","_dimensions","_background","_shadow","_outline","_spacing","_typography","styleDefinitions","border","color","dimensions","outline","spacing","typography","shadow","background","exports"],"sources":["@wordpress/style-engine/src/styles/index.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport border from './border';\nimport color from './color';\nimport dimensions from './dimensions';\nimport background from './background';\nimport shadow from './shadow';\nimport outline from './outline';\nimport spacing from './spacing';\nimport typography from './typography';\n\nexport const styleDefinitions = [\n\t...border,\n\t...color,\n\t...dimensions,\n\t...outline,\n\t...spacing,\n\t...typography,\n\t...shadow,\n\t...background,\n];\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,WAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,QAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,WAAA,GAAAR,sBAAA,CAAAC,OAAA;AAVA;AACA;AACA;;AAUO,MAAMQ,gBAAgB,GAAG,CAC/B,GAAGC,eAAM,EACT,GAAGC,cAAK,EACR,GAAGC,mBAAU,EACb,GAAGC,gBAAO,EACV,GAAGC,gBAAO,EACV,GAAGC,mBAAU,EACb,GAAGC,eAAM,EACT,GAAGC,mBAAU,CACb;AAACC,OAAA,CAAAT,gBAAA,GAAAA,gBAAA"}
|
package/build/styles/utils.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.generateBoxRules = generateBoxRules;
|
|
|
8
8
|
exports.generateRule = generateRule;
|
|
9
9
|
exports.getCSSVarFromStyleValue = getCSSVarFromStyleValue;
|
|
10
10
|
exports.getStyleValueByPath = void 0;
|
|
11
|
+
exports.safeDecodeURI = safeDecodeURI;
|
|
11
12
|
exports.upperFirst = upperFirst;
|
|
12
13
|
var _changeCase = require("change-case");
|
|
13
14
|
var _constants = require("./constants");
|
|
@@ -138,4 +139,25 @@ function camelCaseJoin(strings) {
|
|
|
138
139
|
const [firstItem, ...rest] = strings;
|
|
139
140
|
return firstItem.toLowerCase() + rest.map(upperFirst).join('');
|
|
140
141
|
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
|
|
145
|
+
* `decodeURI` throws an error.
|
|
146
|
+
*
|
|
147
|
+
* @param {string} uri URI to decode.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```js
|
|
151
|
+
* const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @return {string} Decoded URI if possible.
|
|
155
|
+
*/
|
|
156
|
+
function safeDecodeURI(uri) {
|
|
157
|
+
try {
|
|
158
|
+
return decodeURI(uri);
|
|
159
|
+
} catch (uriError) {
|
|
160
|
+
return uri;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
141
163
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_changeCase","require","_constants","getStyleValueByPath","object","path","value","forEach","fieldName","exports","generateRule","style","options","ruleKey","styleValue","selector","key","getCSSVarFromStyleValue","generateBoxRules","ruleKeys","individualProperties","boxStyle","rules","push","default","sideRules","reduce","acc","side","individual","replace","upperFirst","startsWith","VARIABLE_REFERENCE_PREFIX","variable","slice","length","split","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","map","presetVariable","kebabCase","splitRegexp","join","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE","string","firstLetter","rest","toUpperCase","camelCaseJoin","strings","firstItem","toLowerCase"],"sources":["@wordpress/style-engine/src/styles/utils.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tCssRulesKeys,\n\tGeneratedCSSRule,\n\tStyle,\n\tBox,\n\tStyleOptions,\n} from '../types';\nimport {\n\tVARIABLE_REFERENCE_PREFIX,\n\tVARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE,\n\tVARIABLE_PATH_SEPARATOR_TOKEN_STYLE,\n} from './constants';\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as an array of properties, like `[ 'x', 'y' ]`.\n *\n * @param object Input object.\n * @param path Path to the object property.\n * @return Value of the object property at the specified path.\n */\nexport const getStyleValueByPath = (\n\tobject: Record< any, any >,\n\tpath: string[]\n) => {\n\tlet value: any = object;\n\tpath.forEach( ( fieldName: string ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Returns a JSON representation of the generated CSS rules.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n * @param path An array of strings representing the path to the style value in the style object.\n * @param ruleKey A CSS property key.\n *\n * @return GeneratedCSSRule[] CSS rules.\n */\nexport function generateRule(\n\tstyle: Style,\n\toptions: StyleOptions,\n\tpath: string[],\n\truleKey: string\n): GeneratedCSSRule[] {\n\tconst styleValue: string | undefined = getStyleValueByPath( style, path );\n\n\treturn styleValue\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tselector: options?.selector,\n\t\t\t\t\tkey: ruleKey,\n\t\t\t\t\tvalue: getCSSVarFromStyleValue( styleValue ),\n\t\t\t\t},\n\t\t ]\n\t\t: [];\n}\n\n/**\n * Returns a JSON representation of the generated CSS rules taking into account box model properties, top, right, bottom, left.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n * @param path An array of strings representing the path to the style value in the style object.\n * @param ruleKeys An array of CSS property keys and patterns.\n * @param individualProperties The \"sides\" or individual properties for which to generate rules.\n *\n * @return GeneratedCSSRule[] CSS rules.\n */\nexport function generateBoxRules(\n\tstyle: Style,\n\toptions: StyleOptions,\n\tpath: string[],\n\truleKeys: CssRulesKeys,\n\tindividualProperties: string[] = [ 'top', 'right', 'bottom', 'left' ]\n): GeneratedCSSRule[] {\n\tconst boxStyle: Box | string | undefined = getStyleValueByPath(\n\t\tstyle,\n\t\tpath\n\t);\n\tif ( ! boxStyle ) {\n\t\treturn [];\n\t}\n\n\tconst rules: GeneratedCSSRule[] = [];\n\tif ( typeof boxStyle === 'string' ) {\n\t\trules.push( {\n\t\t\tselector: options?.selector,\n\t\t\tkey: ruleKeys.default,\n\t\t\tvalue: boxStyle,\n\t\t} );\n\t} else {\n\t\tconst sideRules = individualProperties.reduce(\n\t\t\t( acc: GeneratedCSSRule[], side: string ) => {\n\t\t\t\tconst value: string | undefined = getCSSVarFromStyleValue(\n\t\t\t\t\tgetStyleValueByPath( boxStyle, [ side ] )\n\t\t\t\t);\n\t\t\t\tif ( value ) {\n\t\t\t\t\tacc.push( {\n\t\t\t\t\t\tselector: options?.selector,\n\t\t\t\t\t\tkey: ruleKeys?.individual.replace(\n\t\t\t\t\t\t\t'%s',\n\t\t\t\t\t\t\tupperFirst( side )\n\t\t\t\t\t\t),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\trules.push( ...sideRules );\n\t}\n\n\treturn rules;\n}\n\n/**\n * Returns a CSS var value from incoming style value following the pattern `var:description|context|slug`.\n *\n * @param styleValue A raw style value.\n *\n * @return string A CSS var value.\n */\nexport function getCSSVarFromStyleValue( styleValue: string ): string {\n\tif (\n\t\ttypeof styleValue === 'string' &&\n\t\tstyleValue.startsWith( VARIABLE_REFERENCE_PREFIX )\n\t) {\n\t\tconst variable = styleValue\n\t\t\t.slice( VARIABLE_REFERENCE_PREFIX.length )\n\t\t\t.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )\n\t\t\t.map( ( presetVariable ) =>\n\t\t\t\tkebabCase( presetVariable, {\n\t\t\t\t\tsplitRegexp: [\n\t\t\t\t\t\t/([a-z0-9])([A-Z])/g, // fooBar => foo-bar, 3Bar => 3-bar\n\t\t\t\t\t\t/([0-9])([a-z])/g, // 3bar => 3-bar\n\t\t\t\t\t\t/([A-Za-z])([0-9])/g, // Foo3 => foo-3, foo3 => foo-3\n\t\t\t\t\t\t/([A-Z])([A-Z][a-z])/g, // FOOBar => foo-bar\n\t\t\t\t\t],\n\t\t\t\t} )\n\t\t\t)\n\t\t\t.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );\n\t\treturn `var(--wp--${ variable })`;\n\t}\n\treturn styleValue;\n}\n\n/**\n * Capitalizes the first letter in a string.\n *\n * @param string The string whose first letter the function will capitalize.\n *\n * @return String with the first letter capitalized.\n */\nexport function upperFirst( string: string ): string {\n\tconst [ firstLetter, ...rest ] = string;\n\treturn firstLetter.toUpperCase() + rest.join( '' );\n}\n\n/**\n * Converts an array of strings into a camelCase string.\n *\n * @param strings The strings to join into a camelCase string.\n *\n * @return camelCase string.\n */\nexport function camelCaseJoin( strings: string[] ): string {\n\tconst [ firstItem, ...rest ] = strings;\n\treturn firstItem.toLowerCase() + rest.map( upperFirst ).join( '' );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_changeCase","require","_constants","getStyleValueByPath","object","path","value","forEach","fieldName","exports","generateRule","style","options","ruleKey","styleValue","selector","key","getCSSVarFromStyleValue","generateBoxRules","ruleKeys","individualProperties","boxStyle","rules","push","default","sideRules","reduce","acc","side","individual","replace","upperFirst","startsWith","VARIABLE_REFERENCE_PREFIX","variable","slice","length","split","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","map","presetVariable","kebabCase","splitRegexp","join","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE","string","firstLetter","rest","toUpperCase","camelCaseJoin","strings","firstItem","toLowerCase","safeDecodeURI","uri","decodeURI","uriError"],"sources":["@wordpress/style-engine/src/styles/utils.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tCssRulesKeys,\n\tGeneratedCSSRule,\n\tStyle,\n\tBox,\n\tStyleOptions,\n} from '../types';\nimport {\n\tVARIABLE_REFERENCE_PREFIX,\n\tVARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE,\n\tVARIABLE_PATH_SEPARATOR_TOKEN_STYLE,\n} from './constants';\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as an array of properties, like `[ 'x', 'y' ]`.\n *\n * @param object Input object.\n * @param path Path to the object property.\n * @return Value of the object property at the specified path.\n */\nexport const getStyleValueByPath = (\n\tobject: Record< any, any >,\n\tpath: string[]\n) => {\n\tlet value: any = object;\n\tpath.forEach( ( fieldName: string ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Returns a JSON representation of the generated CSS rules.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n * @param path An array of strings representing the path to the style value in the style object.\n * @param ruleKey A CSS property key.\n *\n * @return GeneratedCSSRule[] CSS rules.\n */\nexport function generateRule(\n\tstyle: Style,\n\toptions: StyleOptions,\n\tpath: string[],\n\truleKey: string\n): GeneratedCSSRule[] {\n\tconst styleValue: string | undefined = getStyleValueByPath( style, path );\n\n\treturn styleValue\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tselector: options?.selector,\n\t\t\t\t\tkey: ruleKey,\n\t\t\t\t\tvalue: getCSSVarFromStyleValue( styleValue ),\n\t\t\t\t},\n\t\t ]\n\t\t: [];\n}\n\n/**\n * Returns a JSON representation of the generated CSS rules taking into account box model properties, top, right, bottom, left.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n * @param path An array of strings representing the path to the style value in the style object.\n * @param ruleKeys An array of CSS property keys and patterns.\n * @param individualProperties The \"sides\" or individual properties for which to generate rules.\n *\n * @return GeneratedCSSRule[] CSS rules.\n */\nexport function generateBoxRules(\n\tstyle: Style,\n\toptions: StyleOptions,\n\tpath: string[],\n\truleKeys: CssRulesKeys,\n\tindividualProperties: string[] = [ 'top', 'right', 'bottom', 'left' ]\n): GeneratedCSSRule[] {\n\tconst boxStyle: Box | string | undefined = getStyleValueByPath(\n\t\tstyle,\n\t\tpath\n\t);\n\tif ( ! boxStyle ) {\n\t\treturn [];\n\t}\n\n\tconst rules: GeneratedCSSRule[] = [];\n\tif ( typeof boxStyle === 'string' ) {\n\t\trules.push( {\n\t\t\tselector: options?.selector,\n\t\t\tkey: ruleKeys.default,\n\t\t\tvalue: boxStyle,\n\t\t} );\n\t} else {\n\t\tconst sideRules = individualProperties.reduce(\n\t\t\t( acc: GeneratedCSSRule[], side: string ) => {\n\t\t\t\tconst value: string | undefined = getCSSVarFromStyleValue(\n\t\t\t\t\tgetStyleValueByPath( boxStyle, [ side ] )\n\t\t\t\t);\n\t\t\t\tif ( value ) {\n\t\t\t\t\tacc.push( {\n\t\t\t\t\t\tselector: options?.selector,\n\t\t\t\t\t\tkey: ruleKeys?.individual.replace(\n\t\t\t\t\t\t\t'%s',\n\t\t\t\t\t\t\tupperFirst( side )\n\t\t\t\t\t\t),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\trules.push( ...sideRules );\n\t}\n\n\treturn rules;\n}\n\n/**\n * Returns a CSS var value from incoming style value following the pattern `var:description|context|slug`.\n *\n * @param styleValue A raw style value.\n *\n * @return string A CSS var value.\n */\nexport function getCSSVarFromStyleValue( styleValue: string ): string {\n\tif (\n\t\ttypeof styleValue === 'string' &&\n\t\tstyleValue.startsWith( VARIABLE_REFERENCE_PREFIX )\n\t) {\n\t\tconst variable = styleValue\n\t\t\t.slice( VARIABLE_REFERENCE_PREFIX.length )\n\t\t\t.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )\n\t\t\t.map( ( presetVariable ) =>\n\t\t\t\tkebabCase( presetVariable, {\n\t\t\t\t\tsplitRegexp: [\n\t\t\t\t\t\t/([a-z0-9])([A-Z])/g, // fooBar => foo-bar, 3Bar => 3-bar\n\t\t\t\t\t\t/([0-9])([a-z])/g, // 3bar => 3-bar\n\t\t\t\t\t\t/([A-Za-z])([0-9])/g, // Foo3 => foo-3, foo3 => foo-3\n\t\t\t\t\t\t/([A-Z])([A-Z][a-z])/g, // FOOBar => foo-bar\n\t\t\t\t\t],\n\t\t\t\t} )\n\t\t\t)\n\t\t\t.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );\n\t\treturn `var(--wp--${ variable })`;\n\t}\n\treturn styleValue;\n}\n\n/**\n * Capitalizes the first letter in a string.\n *\n * @param string The string whose first letter the function will capitalize.\n *\n * @return String with the first letter capitalized.\n */\nexport function upperFirst( string: string ): string {\n\tconst [ firstLetter, ...rest ] = string;\n\treturn firstLetter.toUpperCase() + rest.join( '' );\n}\n\n/**\n * Converts an array of strings into a camelCase string.\n *\n * @param strings The strings to join into a camelCase string.\n *\n * @return camelCase string.\n */\nexport function camelCaseJoin( strings: string[] ): string {\n\tconst [ firstItem, ...rest ] = strings;\n\treturn firstItem.toLowerCase() + rest.map( upperFirst ).join( '' );\n}\n\n/**\n * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if\n * `decodeURI` throws an error.\n *\n * @param {string} uri URI to decode.\n *\n * @example\n * ```js\n * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'\n * ```\n *\n * @return {string} Decoded URI if possible.\n */\nexport function safeDecodeURI( uri: string ): string {\n\ttry {\n\t\treturn decodeURI( uri );\n\t} catch ( uriError ) {\n\t\treturn uri;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAYA,IAAAC,UAAA,GAAAD,OAAA;AAfA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,mBAAmB,GAAGA,CAClCC,MAA0B,EAC1BC,IAAc,KACV;EACJ,IAAIC,KAAU,GAAGF,MAAM;EACvBC,IAAI,CAACE,OAAO,CAAIC,SAAiB,IAAM;IACtCF,KAAK,GAAGA,KAAK,GAAIE,SAAS,CAAE;EAC7B,CAAE,CAAC;EACH,OAAOF,KAAK;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATAG,OAAA,CAAAN,mBAAA,GAAAA,mBAAA;AAUO,SAASO,YAAYA,CAC3BC,KAAY,EACZC,OAAqB,EACrBP,IAAc,EACdQ,OAAe,EACM;EACrB,MAAMC,UAA8B,GAAGX,mBAAmB,CAAEQ,KAAK,EAAEN,IAAK,CAAC;EAEzE,OAAOS,UAAU,GACd,CACA;IACCC,QAAQ,EAAEH,OAAO,EAAEG,QAAQ;IAC3BC,GAAG,EAAEH,OAAO;IACZP,KAAK,EAAEW,uBAAuB,CAAEH,UAAW;EAC5C,CAAC,CACA,GACD,EAAE;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,gBAAgBA,CAC/BP,KAAY,EACZC,OAAqB,EACrBP,IAAc,EACdc,QAAsB,EACtBC,oBAA8B,GAAG,CAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAE,EAChD;EACrB,MAAMC,QAAkC,GAAGlB,mBAAmB,CAC7DQ,KAAK,EACLN,IACD,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,CACZ,oBAAoB;MAAE;MACtB,iBAAiB;MAAE;MACnB,oBAAoB;MAAE;MACtB,sBAAsB,CAAE;MAAA;IAE1B,CAAE,CACH,CAAC,CACAC,IAAI,CAAEC,8CAAoC,CAAC;IAC7C,OAAQ,aAAaV,QAAU,GAAE;EAClC;EACA,OAAOpB,UAAU;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASiB,UAAUA,CAAEc,MAAc,EAAW;EACpD,MAAM,CAAEC,WAAW,EAAE,GAAGC,IAAI,CAAE,GAAGF,MAAM;EACvC,OAAOC,WAAW,CAACE,WAAW,CAAC,CAAC,GAAGD,IAAI,CAACJ,IAAI,CAAE,EAAG,CAAC;AACnD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,aAAaA,CAAEC,OAAiB,EAAW;EAC1D,MAAM,CAAEC,SAAS,EAAE,GAAGJ,IAAI,CAAE,GAAGG,OAAO;EACtC,OAAOC,SAAS,CAACC,WAAW,CAAC,CAAC,GAAGL,IAAI,CAACR,GAAG,CAAER,UAAW,CAAC,CAACY,IAAI,CAAE,EAAG,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASU,aAAaA,CAAEC,GAAW,EAAW;EACpD,IAAI;IACH,OAAOC,SAAS,CAAED,GAAI,CAAC;EACxB,CAAC,CAAC,OAAQE,QAAQ,EAAG;IACpB,OAAOF,GAAG;EACX;AACD"}
|
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/style-engine/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\ntype BoxVariant = 'margin' | 'padding';\nexport interface Box< T extends BoxVariant | undefined = undefined > {\n\ttop?: CSSProperties[ T extends undefined ? 'top' : `${ T }Top` ];\n\tright?: CSSProperties[ T extends undefined ? 'right' : `${ T }Right` ];\n\tbottom?: CSSProperties[ T extends undefined ? 'bottom' : `${ T }Bottom` ];\n\tleft?: CSSProperties[ T extends undefined ? 'left' : `${ T }Left` ];\n}\n\nexport type BoxEdge = 'top' | 'right' | 'bottom' | 'left';\n\n// `T` is one of the values in `BorderIndividualProperty`. The expected CSSProperties key is something like `borderTopColor`.\nexport interface BorderIndividualStyles< T extends BoxEdge > {\n\tcolor?: CSSProperties[ `border${ Capitalize< T > }Color` ];\n\tstyle?: CSSProperties[ `border${ Capitalize< T > }Style` ];\n\twidth?: CSSProperties[ `border${ Capitalize< T > }Width` ];\n}\n\nexport interface Style {\n\tborder?: {\n\t\tcolor?: CSSProperties[ 'borderColor' ];\n\t\tradius?:\n\t\t\t| CSSProperties[ 'borderRadius' ]\n\t\t\t| {\n\t\t\t\t\ttopLeft?: CSSProperties[ 'borderTopLeftRadius' ];\n\t\t\t\t\ttopRight?: CSSProperties[ 'borderTopRightRadius' ];\n\t\t\t\t\tbottomLeft?: CSSProperties[ 'borderBottomLeftRadius' ];\n\t\t\t\t\tbottomRight?: CSSProperties[ 'borderBottomLeftRadius' ];\n\t\t\t };\n\t\tstyle?: CSSProperties[ 'borderStyle' ];\n\t\twidth?: CSSProperties[ 'borderWidth' ];\n\t\ttop?: BorderIndividualStyles< 'top' >;\n\t\tright?: BorderIndividualStyles< 'right' >;\n\t\tbottom?: BorderIndividualStyles< 'bottom' >;\n\t\tleft?: BorderIndividualStyles< 'left' >;\n\t};\n\tdimensions?: {\n\t\tminHeight?: CSSProperties[ 'minHeight' ];\n\t};\n\tspacing?: {\n\t\tmargin?: CSSProperties[ 'margin' ] | Box< 'margin' >;\n\t\tpadding?: CSSProperties[ 'padding' ] | Box< 'padding' >;\n\t};\n\ttypography?: {\n\t\tfontSize?: CSSProperties[ 'fontSize' ];\n\t\tfontFamily?: CSSProperties[ 'fontFamily' ];\n\t\tfontWeight?: CSSProperties[ 'fontWeight' ];\n\t\tfontStyle?: CSSProperties[ 'fontStyle' ];\n\t\tletterSpacing?: CSSProperties[ 'letterSpacing' ];\n\t\tlineHeight?: CSSProperties[ 'lineHeight' ];\n\t\ttextColumns?: CSSProperties[ 'columnCount' ];\n\t\ttextDecoration?: CSSProperties[ 'textDecoration' ];\n\t\ttextTransform?: CSSProperties[ 'textTransform' ];\n\t\twritingMode?: CSSProperties[ 'writingMode' ];\n\t};\n\tcolor?: {\n\t\ttext?: CSSProperties[ 'color' ];\n\t\tbackground?: CSSProperties[ 'backgroundColor' ];\n\t\tgradient?: CSSProperties[ 'background' ];\n\t};\n\telements?: {\n\t\tlink?: {\n\t\t\tcolor?: {\n\t\t\t\ttext?: CSSProperties[ 'color' ];\n\t\t\t};\n\t\t};\n\t};\n}\n\nexport interface CssRulesKeys {\n\tdefault: string;\n\tindividual: string;\n}\n\nexport interface StyleOptions {\n\t/**\n\t * CSS selector for the generated style.\n\t */\n\tselector?: string;\n}\n\nexport interface GeneratedCSSRule {\n\tselector?: string;\n\tvalue: string;\n\t/**\n\t * The CSS key in JS style attribute format, compatible with React.\n\t * E.g. `paddingTop` instead of `padding-top`.\n\t */\n\tkey: string;\n}\n\nexport interface GenerateFunction {\n\t( style: Style, options: StyleOptions ): GeneratedCSSRule[];\n}\n\nexport interface StyleDefinition {\n\tname: string;\n\tgenerate?: GenerateFunction;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/style-engine/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\ntype BoxVariant = 'margin' | 'padding';\nexport interface Box< T extends BoxVariant | undefined = undefined > {\n\ttop?: CSSProperties[ T extends undefined ? 'top' : `${ T }Top` ];\n\tright?: CSSProperties[ T extends undefined ? 'right' : `${ T }Right` ];\n\tbottom?: CSSProperties[ T extends undefined ? 'bottom' : `${ T }Bottom` ];\n\tleft?: CSSProperties[ T extends undefined ? 'left' : `${ T }Left` ];\n}\n\nexport type BoxEdge = 'top' | 'right' | 'bottom' | 'left';\n\n// `T` is one of the values in `BorderIndividualProperty`. The expected CSSProperties key is something like `borderTopColor`.\nexport interface BorderIndividualStyles< T extends BoxEdge > {\n\tcolor?: CSSProperties[ `border${ Capitalize< T > }Color` ];\n\tstyle?: CSSProperties[ `border${ Capitalize< T > }Style` ];\n\twidth?: CSSProperties[ `border${ Capitalize< T > }Width` ];\n}\n\nexport interface Style {\n\tbackground?: {\n\t\tbackgroundImage: {\n\t\t\turl?: CSSProperties[ 'backgroundImage' ];\n\t\t\tsource?: string;\n\t\t};\n\t\tbackgroundSize?: CSSProperties[ 'backgroundSize' ];\n\t};\n\tborder?: {\n\t\tcolor?: CSSProperties[ 'borderColor' ];\n\t\tradius?:\n\t\t\t| CSSProperties[ 'borderRadius' ]\n\t\t\t| {\n\t\t\t\t\ttopLeft?: CSSProperties[ 'borderTopLeftRadius' ];\n\t\t\t\t\ttopRight?: CSSProperties[ 'borderTopRightRadius' ];\n\t\t\t\t\tbottomLeft?: CSSProperties[ 'borderBottomLeftRadius' ];\n\t\t\t\t\tbottomRight?: CSSProperties[ 'borderBottomLeftRadius' ];\n\t\t\t };\n\t\tstyle?: CSSProperties[ 'borderStyle' ];\n\t\twidth?: CSSProperties[ 'borderWidth' ];\n\t\ttop?: BorderIndividualStyles< 'top' >;\n\t\tright?: BorderIndividualStyles< 'right' >;\n\t\tbottom?: BorderIndividualStyles< 'bottom' >;\n\t\tleft?: BorderIndividualStyles< 'left' >;\n\t};\n\tdimensions?: {\n\t\tminHeight?: CSSProperties[ 'minHeight' ];\n\t};\n\tspacing?: {\n\t\tmargin?: CSSProperties[ 'margin' ] | Box< 'margin' >;\n\t\tpadding?: CSSProperties[ 'padding' ] | Box< 'padding' >;\n\t};\n\ttypography?: {\n\t\tfontSize?: CSSProperties[ 'fontSize' ];\n\t\tfontFamily?: CSSProperties[ 'fontFamily' ];\n\t\tfontWeight?: CSSProperties[ 'fontWeight' ];\n\t\tfontStyle?: CSSProperties[ 'fontStyle' ];\n\t\tletterSpacing?: CSSProperties[ 'letterSpacing' ];\n\t\tlineHeight?: CSSProperties[ 'lineHeight' ];\n\t\ttextColumns?: CSSProperties[ 'columnCount' ];\n\t\ttextDecoration?: CSSProperties[ 'textDecoration' ];\n\t\ttextTransform?: CSSProperties[ 'textTransform' ];\n\t\twritingMode?: CSSProperties[ 'writingMode' ];\n\t};\n\tcolor?: {\n\t\ttext?: CSSProperties[ 'color' ];\n\t\tbackground?: CSSProperties[ 'backgroundColor' ];\n\t\tgradient?: CSSProperties[ 'background' ];\n\t};\n\telements?: {\n\t\tlink?: {\n\t\t\tcolor?: {\n\t\t\t\ttext?: CSSProperties[ 'color' ];\n\t\t\t};\n\t\t};\n\t};\n}\n\nexport interface CssRulesKeys {\n\tdefault: string;\n\tindividual: string;\n}\n\nexport interface StyleOptions {\n\t/**\n\t * CSS selector for the generated style.\n\t */\n\tselector?: string;\n}\n\nexport interface GeneratedCSSRule {\n\tselector?: string;\n\tvalue: string;\n\t/**\n\t * The CSS key in JS style attribute format, compatible with React.\n\t * E.g. `paddingTop` instead of `padding-top`.\n\t */\n\tkey: string;\n}\n\nexport interface GenerateFunction {\n\t( style: Style, options: StyleOptions ): GeneratedCSSRule[];\n}\n\nexport interface StyleDefinition {\n\tname: string;\n\tgenerate?: GenerateFunction;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { safeDecodeURI } from '../utils';
|
|
6
|
+
const backgroundImage = {
|
|
7
|
+
name: 'backgroundImage',
|
|
8
|
+
generate: (style, options) => {
|
|
9
|
+
const _backgroundImage = style?.background?.backgroundImage;
|
|
10
|
+
const _backgroundSize = style?.background?.backgroundSize;
|
|
11
|
+
const styleRules = [];
|
|
12
|
+
if (!_backgroundImage) {
|
|
13
|
+
return styleRules;
|
|
14
|
+
}
|
|
15
|
+
if (_backgroundImage?.source === 'file' && _backgroundImage?.url) {
|
|
16
|
+
styleRules.push({
|
|
17
|
+
selector: options.selector,
|
|
18
|
+
key: 'backgroundImage',
|
|
19
|
+
// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
|
|
20
|
+
value: `url( '${encodeURI(safeDecodeURI(_backgroundImage.url))}' )`
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// If no background size is set, but an image is, default to cover.
|
|
25
|
+
if (!_backgroundSize) {
|
|
26
|
+
styleRules.push({
|
|
27
|
+
selector: options.selector,
|
|
28
|
+
key: 'backgroundSize',
|
|
29
|
+
value: 'cover'
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return styleRules;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export default [backgroundImage];
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["safeDecodeURI","backgroundImage","name","generate","style","options","_backgroundImage","background","_backgroundSize","backgroundSize","styleRules","source","url","push","selector","key","value","encodeURI"],"sources":["@wordpress/style-engine/src/styles/background/index.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { GeneratedCSSRule, Style, StyleOptions } from '../../types';\nimport { safeDecodeURI } from '../utils';\n\nconst backgroundImage = {\n\tname: 'backgroundImage',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\tconst _backgroundImage = style?.background?.backgroundImage;\n\t\tconst _backgroundSize = style?.background?.backgroundSize;\n\n\t\tconst styleRules: GeneratedCSSRule[] = [];\n\n\t\tif ( ! _backgroundImage ) {\n\t\t\treturn styleRules;\n\t\t}\n\n\t\tif ( _backgroundImage?.source === 'file' && _backgroundImage?.url ) {\n\t\t\tstyleRules.push( {\n\t\t\t\tselector: options.selector,\n\t\t\t\tkey: 'backgroundImage',\n\t\t\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t\t\tvalue: `url( '${ encodeURI(\n\t\t\t\t\tsafeDecodeURI( _backgroundImage.url )\n\t\t\t\t) }' )`,\n\t\t\t} );\n\t\t}\n\n\t\t// If no background size is set, but an image is, default to cover.\n\t\tif ( ! _backgroundSize ) {\n\t\t\tstyleRules.push( {\n\t\t\t\tselector: options.selector,\n\t\t\t\tkey: 'backgroundSize',\n\t\t\t\tvalue: 'cover',\n\t\t\t} );\n\t\t}\n\n\t\treturn styleRules;\n\t},\n};\n\nexport default [ backgroundImage ];\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,UAAU;AAExC,MAAMC,eAAe,GAAG;EACvBC,IAAI,EAAE,iBAAiB;EACvBC,QAAQ,EAAEA,CAAEC,KAAY,EAAEC,OAAqB,KAAM;IACpD,MAAMC,gBAAgB,GAAGF,KAAK,EAAEG,UAAU,EAAEN,eAAe;IAC3D,MAAMO,eAAe,GAAGJ,KAAK,EAAEG,UAAU,EAAEE,cAAc;IAEzD,MAAMC,UAA8B,GAAG,EAAE;IAEzC,IAAK,CAAEJ,gBAAgB,EAAG;MACzB,OAAOI,UAAU;IAClB;IAEA,IAAKJ,gBAAgB,EAAEK,MAAM,KAAK,MAAM,IAAIL,gBAAgB,EAAEM,GAAG,EAAG;MACnEF,UAAU,CAACG,IAAI,CAAE;QAChBC,QAAQ,EAAET,OAAO,CAACS,QAAQ;QAC1BC,GAAG,EAAE,iBAAiB;QACtB;QACAC,KAAK,EAAG,SAASC,SAAS,CACzBjB,aAAa,CAAEM,gBAAgB,CAACM,GAAI,CACrC,CAAG;MACJ,CAAE,CAAC;IACJ;;IAEA;IACA,IAAK,CAAEJ,eAAe,EAAG;MACxBE,UAAU,CAACG,IAAI,CAAE;QAChBC,QAAQ,EAAET,OAAO,CAACS,QAAQ;QAC1BC,GAAG,EAAE,gBAAgB;QACrBC,KAAK,EAAE;MACR,CAAE,CAAC;IACJ;IAEA,OAAON,UAAU;EAClB;AACD,CAAC;AAED,eAAe,CAAET,eAAe,CAAE"}
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
import border from './border';
|
|
5
5
|
import color from './color';
|
|
6
6
|
import dimensions from './dimensions';
|
|
7
|
+
import background from './background';
|
|
7
8
|
import shadow from './shadow';
|
|
8
9
|
import outline from './outline';
|
|
9
10
|
import spacing from './spacing';
|
|
10
11
|
import typography from './typography';
|
|
11
|
-
export const styleDefinitions = [...border, ...color, ...dimensions, ...outline, ...spacing, ...typography, ...shadow];
|
|
12
|
+
export const styleDefinitions = [...border, ...color, ...dimensions, ...outline, ...spacing, ...typography, ...shadow, ...background];
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["border","color","dimensions","shadow","outline","spacing","typography","styleDefinitions"],"sources":["@wordpress/style-engine/src/styles/index.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport border from './border';\nimport color from './color';\nimport dimensions from './dimensions';\nimport shadow from './shadow';\nimport outline from './outline';\nimport spacing from './spacing';\nimport typography from './typography';\n\nexport const styleDefinitions = [\n\t...border,\n\t...color,\n\t...dimensions,\n\t...outline,\n\t...spacing,\n\t...typography,\n\t...shadow,\n];\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,UAAU;AAC7B,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,MAAM,MAAM,UAAU;AAC7B,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAOC,UAAU,MAAM,cAAc;AAErC,OAAO,MAAMC,gBAAgB,GAAG,CAC/B,
|
|
1
|
+
{"version":3,"names":["border","color","dimensions","background","shadow","outline","spacing","typography","styleDefinitions"],"sources":["@wordpress/style-engine/src/styles/index.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport border from './border';\nimport color from './color';\nimport dimensions from './dimensions';\nimport background from './background';\nimport shadow from './shadow';\nimport outline from './outline';\nimport spacing from './spacing';\nimport typography from './typography';\n\nexport const styleDefinitions = [\n\t...border,\n\t...color,\n\t...dimensions,\n\t...outline,\n\t...spacing,\n\t...typography,\n\t...shadow,\n\t...background,\n];\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,UAAU;AAC7B,OAAOC,KAAK,MAAM,SAAS;AAC3B,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,MAAM,MAAM,UAAU;AAC7B,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAOC,UAAU,MAAM,cAAc;AAErC,OAAO,MAAMC,gBAAgB,GAAG,CAC/B,GAAGR,MAAM,EACT,GAAGC,KAAK,EACR,GAAGC,UAAU,EACb,GAAGG,OAAO,EACV,GAAGC,OAAO,EACV,GAAGC,UAAU,EACb,GAAGH,MAAM,EACT,GAAGD,UAAU,CACb"}
|
|
@@ -131,4 +131,25 @@ export function camelCaseJoin(strings) {
|
|
|
131
131
|
const [firstItem, ...rest] = strings;
|
|
132
132
|
return firstItem.toLowerCase() + rest.map(upperFirst).join('');
|
|
133
133
|
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
|
|
137
|
+
* `decodeURI` throws an error.
|
|
138
|
+
*
|
|
139
|
+
* @param {string} uri URI to decode.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```js
|
|
143
|
+
* const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @return {string} Decoded URI if possible.
|
|
147
|
+
*/
|
|
148
|
+
export function safeDecodeURI(uri) {
|
|
149
|
+
try {
|
|
150
|
+
return decodeURI(uri);
|
|
151
|
+
} catch (uriError) {
|
|
152
|
+
return uri;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
134
155
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["paramCase","kebabCase","VARIABLE_REFERENCE_PREFIX","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE","getStyleValueByPath","object","path","value","forEach","fieldName","generateRule","style","options","ruleKey","styleValue","selector","key","getCSSVarFromStyleValue","generateBoxRules","ruleKeys","individualProperties","boxStyle","rules","push","default","sideRules","reduce","acc","side","individual","replace","upperFirst","startsWith","variable","slice","length","split","map","presetVariable","splitRegexp","join","string","firstLetter","rest","toUpperCase","camelCaseJoin","strings","firstItem","toLowerCase"],"sources":["@wordpress/style-engine/src/styles/utils.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tCssRulesKeys,\n\tGeneratedCSSRule,\n\tStyle,\n\tBox,\n\tStyleOptions,\n} from '../types';\nimport {\n\tVARIABLE_REFERENCE_PREFIX,\n\tVARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE,\n\tVARIABLE_PATH_SEPARATOR_TOKEN_STYLE,\n} from './constants';\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as an array of properties, like `[ 'x', 'y' ]`.\n *\n * @param object Input object.\n * @param path Path to the object property.\n * @return Value of the object property at the specified path.\n */\nexport const getStyleValueByPath = (\n\tobject: Record< any, any >,\n\tpath: string[]\n) => {\n\tlet value: any = object;\n\tpath.forEach( ( fieldName: string ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Returns a JSON representation of the generated CSS rules.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n * @param path An array of strings representing the path to the style value in the style object.\n * @param ruleKey A CSS property key.\n *\n * @return GeneratedCSSRule[] CSS rules.\n */\nexport function generateRule(\n\tstyle: Style,\n\toptions: StyleOptions,\n\tpath: string[],\n\truleKey: string\n): GeneratedCSSRule[] {\n\tconst styleValue: string | undefined = getStyleValueByPath( style, path );\n\n\treturn styleValue\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tselector: options?.selector,\n\t\t\t\t\tkey: ruleKey,\n\t\t\t\t\tvalue: getCSSVarFromStyleValue( styleValue ),\n\t\t\t\t},\n\t\t ]\n\t\t: [];\n}\n\n/**\n * Returns a JSON representation of the generated CSS rules taking into account box model properties, top, right, bottom, left.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n * @param path An array of strings representing the path to the style value in the style object.\n * @param ruleKeys An array of CSS property keys and patterns.\n * @param individualProperties The \"sides\" or individual properties for which to generate rules.\n *\n * @return GeneratedCSSRule[] CSS rules.\n */\nexport function generateBoxRules(\n\tstyle: Style,\n\toptions: StyleOptions,\n\tpath: string[],\n\truleKeys: CssRulesKeys,\n\tindividualProperties: string[] = [ 'top', 'right', 'bottom', 'left' ]\n): GeneratedCSSRule[] {\n\tconst boxStyle: Box | string | undefined = getStyleValueByPath(\n\t\tstyle,\n\t\tpath\n\t);\n\tif ( ! boxStyle ) {\n\t\treturn [];\n\t}\n\n\tconst rules: GeneratedCSSRule[] = [];\n\tif ( typeof boxStyle === 'string' ) {\n\t\trules.push( {\n\t\t\tselector: options?.selector,\n\t\t\tkey: ruleKeys.default,\n\t\t\tvalue: boxStyle,\n\t\t} );\n\t} else {\n\t\tconst sideRules = individualProperties.reduce(\n\t\t\t( acc: GeneratedCSSRule[], side: string ) => {\n\t\t\t\tconst value: string | undefined = getCSSVarFromStyleValue(\n\t\t\t\t\tgetStyleValueByPath( boxStyle, [ side ] )\n\t\t\t\t);\n\t\t\t\tif ( value ) {\n\t\t\t\t\tacc.push( {\n\t\t\t\t\t\tselector: options?.selector,\n\t\t\t\t\t\tkey: ruleKeys?.individual.replace(\n\t\t\t\t\t\t\t'%s',\n\t\t\t\t\t\t\tupperFirst( side )\n\t\t\t\t\t\t),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\trules.push( ...sideRules );\n\t}\n\n\treturn rules;\n}\n\n/**\n * Returns a CSS var value from incoming style value following the pattern `var:description|context|slug`.\n *\n * @param styleValue A raw style value.\n *\n * @return string A CSS var value.\n */\nexport function getCSSVarFromStyleValue( styleValue: string ): string {\n\tif (\n\t\ttypeof styleValue === 'string' &&\n\t\tstyleValue.startsWith( VARIABLE_REFERENCE_PREFIX )\n\t) {\n\t\tconst variable = styleValue\n\t\t\t.slice( VARIABLE_REFERENCE_PREFIX.length )\n\t\t\t.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )\n\t\t\t.map( ( presetVariable ) =>\n\t\t\t\tkebabCase( presetVariable, {\n\t\t\t\t\tsplitRegexp: [\n\t\t\t\t\t\t/([a-z0-9])([A-Z])/g, // fooBar => foo-bar, 3Bar => 3-bar\n\t\t\t\t\t\t/([0-9])([a-z])/g, // 3bar => 3-bar\n\t\t\t\t\t\t/([A-Za-z])([0-9])/g, // Foo3 => foo-3, foo3 => foo-3\n\t\t\t\t\t\t/([A-Z])([A-Z][a-z])/g, // FOOBar => foo-bar\n\t\t\t\t\t],\n\t\t\t\t} )\n\t\t\t)\n\t\t\t.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );\n\t\treturn `var(--wp--${ variable })`;\n\t}\n\treturn styleValue;\n}\n\n/**\n * Capitalizes the first letter in a string.\n *\n * @param string The string whose first letter the function will capitalize.\n *\n * @return String with the first letter capitalized.\n */\nexport function upperFirst( string: string ): string {\n\tconst [ firstLetter, ...rest ] = string;\n\treturn firstLetter.toUpperCase() + rest.join( '' );\n}\n\n/**\n * Converts an array of strings into a camelCase string.\n *\n * @param strings The strings to join into a camelCase string.\n *\n * @return camelCase string.\n */\nexport function camelCaseJoin( strings: string[] ): string {\n\tconst [ firstItem, ...rest ] = strings;\n\treturn firstItem.toLowerCase() + rest.map( upperFirst ).join( '' );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,S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U,GAAE;EAClC;EACA,OAAOnB,UAAU;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASiB,UAAUA,CAAEU,MAAc,EAAW;EACpD,MAAM,CAAEC,WAAW,EAAE,GAAGC,IAAI,CAAE,GAAGF,MAAM;EACvC,OAAOC,WAAW,CAACE,WAAW,CAAC,CAAC,GAAGD,IAAI,CAACH,IAAI,CAAE,EAAG,CAAC;AACnD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,aAAaA,CAAEC,OAAiB,EAAW;EAC1D,MAAM,CAAEC,SAAS,EAAE,GAAGJ,IAAI,CAAE,GAAGG,OAAO;EACtC,OAAOC,SAAS,CAACC,WAAW,CAAC,CAAC,GAAGL,IAAI,CAACN,GAAG,CAAEN,UAAW,CAAC,CAACS,IAAI,CAAE,EAAG,CAAC;AACnE"}
|
|
1
|
+
{"version":3,"names":["paramCase","kebabCase","VARIABLE_REFERENCE_PREFIX","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE","getStyleValueByPath","object","path","value","forEach","fieldName","generateRule","style","options","ruleKey","styleValue","selector","key","getCSSVarFromStyleValue","generateBoxRules","ruleKeys","individualProperties","boxStyle","rules","push","default","sideRules","reduce","acc","side","individual","replace","upperFirst","startsWith","variable","slice","length","split","map","presetVariable","splitRegexp","join","string","firstLetter","rest","toUpperCase","camelCaseJoin","strings","firstItem","toLowerCase","safeDecodeURI","uri","decodeURI","uriError"],"sources":["@wordpress/style-engine/src/styles/utils.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tCssRulesKeys,\n\tGeneratedCSSRule,\n\tStyle,\n\tBox,\n\tStyleOptions,\n} from '../types';\nimport {\n\tVARIABLE_REFERENCE_PREFIX,\n\tVARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE,\n\tVARIABLE_PATH_SEPARATOR_TOKEN_STYLE,\n} from './constants';\n\n/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as an array of properties, like `[ 'x', 'y' ]`.\n *\n * @param object Input object.\n * @param path Path to the object property.\n * @return Value of the object property at the specified path.\n */\nexport const getStyleValueByPath = (\n\tobject: Record< any, any >,\n\tpath: string[]\n) => {\n\tlet value: any = object;\n\tpath.forEach( ( fieldName: string ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\n/**\n * Returns a JSON representation of the generated CSS rules.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n * @param path An array of strings representing the path to the style value in the style object.\n * @param ruleKey A CSS property key.\n *\n * @return GeneratedCSSRule[] CSS rules.\n */\nexport function generateRule(\n\tstyle: Style,\n\toptions: StyleOptions,\n\tpath: string[],\n\truleKey: string\n): GeneratedCSSRule[] {\n\tconst styleValue: string | undefined = getStyleValueByPath( style, path );\n\n\treturn styleValue\n\t\t? [\n\t\t\t\t{\n\t\t\t\t\tselector: options?.selector,\n\t\t\t\t\tkey: ruleKey,\n\t\t\t\t\tvalue: getCSSVarFromStyleValue( styleValue ),\n\t\t\t\t},\n\t\t ]\n\t\t: [];\n}\n\n/**\n * Returns a JSON representation of the generated CSS rules taking into account box model properties, top, right, bottom, left.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n * @param path An array of strings representing the path to the style value in the style object.\n * @param ruleKeys An array of CSS property keys and patterns.\n * @param individualProperties The \"sides\" or individual properties for which to generate rules.\n *\n * @return GeneratedCSSRule[] CSS rules.\n */\nexport function generateBoxRules(\n\tstyle: Style,\n\toptions: StyleOptions,\n\tpath: string[],\n\truleKeys: CssRulesKeys,\n\tindividualProperties: string[] = [ 'top', 'right', 'bottom', 'left' ]\n): GeneratedCSSRule[] {\n\tconst boxStyle: Box | string | undefined = getStyleValueByPath(\n\t\tstyle,\n\t\tpath\n\t);\n\tif ( ! boxStyle ) {\n\t\treturn [];\n\t}\n\n\tconst rules: GeneratedCSSRule[] = [];\n\tif ( typeof boxStyle === 'string' ) {\n\t\trules.push( {\n\t\t\tselector: options?.selector,\n\t\t\tkey: ruleKeys.default,\n\t\t\tvalue: boxStyle,\n\t\t} );\n\t} else {\n\t\tconst sideRules = individualProperties.reduce(\n\t\t\t( acc: GeneratedCSSRule[], side: string ) => {\n\t\t\t\tconst value: string | undefined = getCSSVarFromStyleValue(\n\t\t\t\t\tgetStyleValueByPath( boxStyle, [ side ] )\n\t\t\t\t);\n\t\t\t\tif ( value ) {\n\t\t\t\t\tacc.push( {\n\t\t\t\t\t\tselector: options?.selector,\n\t\t\t\t\t\tkey: ruleKeys?.individual.replace(\n\t\t\t\t\t\t\t'%s',\n\t\t\t\t\t\t\tupperFirst( side )\n\t\t\t\t\t\t),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\trules.push( ...sideRules );\n\t}\n\n\treturn rules;\n}\n\n/**\n * Returns a CSS var value from incoming style value following the pattern `var:description|context|slug`.\n *\n * @param styleValue A raw style value.\n *\n * @return string A CSS var value.\n */\nexport function getCSSVarFromStyleValue( styleValue: string ): string {\n\tif (\n\t\ttypeof styleValue === 'string' &&\n\t\tstyleValue.startsWith( VARIABLE_REFERENCE_PREFIX )\n\t) {\n\t\tconst variable = styleValue\n\t\t\t.slice( VARIABLE_REFERENCE_PREFIX.length )\n\t\t\t.split( VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE )\n\t\t\t.map( ( presetVariable ) =>\n\t\t\t\tkebabCase( presetVariable, {\n\t\t\t\t\tsplitRegexp: [\n\t\t\t\t\t\t/([a-z0-9])([A-Z])/g, // fooBar => foo-bar, 3Bar => 3-bar\n\t\t\t\t\t\t/([0-9])([a-z])/g, // 3bar => 3-bar\n\t\t\t\t\t\t/([A-Za-z])([0-9])/g, // Foo3 => foo-3, foo3 => foo-3\n\t\t\t\t\t\t/([A-Z])([A-Z][a-z])/g, // FOOBar => foo-bar\n\t\t\t\t\t],\n\t\t\t\t} )\n\t\t\t)\n\t\t\t.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );\n\t\treturn `var(--wp--${ variable })`;\n\t}\n\treturn styleValue;\n}\n\n/**\n * Capitalizes the first letter in a string.\n *\n * @param string The string whose first letter the function will capitalize.\n *\n * @return String with the first letter capitalized.\n */\nexport function upperFirst( string: string ): string {\n\tconst [ firstLetter, ...rest ] = string;\n\treturn firstLetter.toUpperCase() + rest.join( '' );\n}\n\n/**\n * Converts an array of strings into a camelCase string.\n *\n * @param strings The strings to join into a camelCase string.\n *\n * @return camelCase string.\n */\nexport function camelCaseJoin( strings: string[] ): string {\n\tconst [ firstItem, ...rest ] = strings;\n\treturn firstItem.toLowerCase() + rest.map( upperFirst ).join( '' );\n}\n\n/**\n * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if\n * `decodeURI` throws an error.\n *\n * @param {string} uri URI to decode.\n *\n * @example\n * ```js\n * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'\n * ```\n *\n * @return {string} Decoded URI if possible.\n */\nexport function safeDecodeURI( uri: string ): string {\n\ttry {\n\t\treturn decodeURI( uri );\n\t} catch ( uriError ) {\n\t\treturn uri;\n\t}\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa;;AAEpD;AACA;AACA;;AAQA,SACCC,yBAAyB,EACzBC,uCAAuC,EACvCC,mCAAmC,QAC7B,aAAa;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAGA,CAClCC,MAA0B,EAC1BC,IAAc,KACV;EACJ,IAAIC,KAAU,GAAGF,MAAM;EACvBC,IAAI,CAACE,OAAO,CAAIC,SAAiB,IAAM;IACtCF,KAAK,GAAGA,KAAK,GAAIE,SAAS,CAAE;EAC7B,CAAE,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D,MAAM,CAAEC,SAAS,EAAE,GAAGJ,IAAI,CAAE,GAAGG,OAAO;EACtC,OAAOC,SAAS,CAACC,WAAW,CAAC,CAAC,GAAGL,IAAI,CAACN,GAAG,CAAEN,UAAW,CAAC,CAACS,IAAI,CAAE,EAAG,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,aAAaA,CAAEC,GAAW,EAAW;EACpD,IAAI;IACH,OAAOC,SAAS,CAAED,GAAI,CAAC;EACxB,CAAC,CAAC,OAAQE,QAAQ,EAAG;IACpB,OAAOF,GAAG;EACX;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/style-engine/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\ntype BoxVariant = 'margin' | 'padding';\nexport interface Box< T extends BoxVariant | undefined = undefined > {\n\ttop?: CSSProperties[ T extends undefined ? 'top' : `${ T }Top` ];\n\tright?: CSSProperties[ T extends undefined ? 'right' : `${ T }Right` ];\n\tbottom?: CSSProperties[ T extends undefined ? 'bottom' : `${ T }Bottom` ];\n\tleft?: CSSProperties[ T extends undefined ? 'left' : `${ T }Left` ];\n}\n\nexport type BoxEdge = 'top' | 'right' | 'bottom' | 'left';\n\n// `T` is one of the values in `BorderIndividualProperty`. The expected CSSProperties key is something like `borderTopColor`.\nexport interface BorderIndividualStyles< T extends BoxEdge > {\n\tcolor?: CSSProperties[ `border${ Capitalize< T > }Color` ];\n\tstyle?: CSSProperties[ `border${ Capitalize< T > }Style` ];\n\twidth?: CSSProperties[ `border${ Capitalize< T > }Width` ];\n}\n\nexport interface Style {\n\tborder?: {\n\t\tcolor?: CSSProperties[ 'borderColor' ];\n\t\tradius?:\n\t\t\t| CSSProperties[ 'borderRadius' ]\n\t\t\t| {\n\t\t\t\t\ttopLeft?: CSSProperties[ 'borderTopLeftRadius' ];\n\t\t\t\t\ttopRight?: CSSProperties[ 'borderTopRightRadius' ];\n\t\t\t\t\tbottomLeft?: CSSProperties[ 'borderBottomLeftRadius' ];\n\t\t\t\t\tbottomRight?: CSSProperties[ 'borderBottomLeftRadius' ];\n\t\t\t };\n\t\tstyle?: CSSProperties[ 'borderStyle' ];\n\t\twidth?: CSSProperties[ 'borderWidth' ];\n\t\ttop?: BorderIndividualStyles< 'top' >;\n\t\tright?: BorderIndividualStyles< 'right' >;\n\t\tbottom?: BorderIndividualStyles< 'bottom' >;\n\t\tleft?: BorderIndividualStyles< 'left' >;\n\t};\n\tdimensions?: {\n\t\tminHeight?: CSSProperties[ 'minHeight' ];\n\t};\n\tspacing?: {\n\t\tmargin?: CSSProperties[ 'margin' ] | Box< 'margin' >;\n\t\tpadding?: CSSProperties[ 'padding' ] | Box< 'padding' >;\n\t};\n\ttypography?: {\n\t\tfontSize?: CSSProperties[ 'fontSize' ];\n\t\tfontFamily?: CSSProperties[ 'fontFamily' ];\n\t\tfontWeight?: CSSProperties[ 'fontWeight' ];\n\t\tfontStyle?: CSSProperties[ 'fontStyle' ];\n\t\tletterSpacing?: CSSProperties[ 'letterSpacing' ];\n\t\tlineHeight?: CSSProperties[ 'lineHeight' ];\n\t\ttextColumns?: CSSProperties[ 'columnCount' ];\n\t\ttextDecoration?: CSSProperties[ 'textDecoration' ];\n\t\ttextTransform?: CSSProperties[ 'textTransform' ];\n\t\twritingMode?: CSSProperties[ 'writingMode' ];\n\t};\n\tcolor?: {\n\t\ttext?: CSSProperties[ 'color' ];\n\t\tbackground?: CSSProperties[ 'backgroundColor' ];\n\t\tgradient?: CSSProperties[ 'background' ];\n\t};\n\telements?: {\n\t\tlink?: {\n\t\t\tcolor?: {\n\t\t\t\ttext?: CSSProperties[ 'color' ];\n\t\t\t};\n\t\t};\n\t};\n}\n\nexport interface CssRulesKeys {\n\tdefault: string;\n\tindividual: string;\n}\n\nexport interface StyleOptions {\n\t/**\n\t * CSS selector for the generated style.\n\t */\n\tselector?: string;\n}\n\nexport interface GeneratedCSSRule {\n\tselector?: string;\n\tvalue: string;\n\t/**\n\t * The CSS key in JS style attribute format, compatible with React.\n\t * E.g. `paddingTop` instead of `padding-top`.\n\t */\n\tkey: string;\n}\n\nexport interface GenerateFunction {\n\t( style: Style, options: StyleOptions ): GeneratedCSSRule[];\n}\n\nexport interface StyleDefinition {\n\tname: string;\n\tgenerate?: GenerateFunction;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/style-engine/src/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\ntype BoxVariant = 'margin' | 'padding';\nexport interface Box< T extends BoxVariant | undefined = undefined > {\n\ttop?: CSSProperties[ T extends undefined ? 'top' : `${ T }Top` ];\n\tright?: CSSProperties[ T extends undefined ? 'right' : `${ T }Right` ];\n\tbottom?: CSSProperties[ T extends undefined ? 'bottom' : `${ T }Bottom` ];\n\tleft?: CSSProperties[ T extends undefined ? 'left' : `${ T }Left` ];\n}\n\nexport type BoxEdge = 'top' | 'right' | 'bottom' | 'left';\n\n// `T` is one of the values in `BorderIndividualProperty`. The expected CSSProperties key is something like `borderTopColor`.\nexport interface BorderIndividualStyles< T extends BoxEdge > {\n\tcolor?: CSSProperties[ `border${ Capitalize< T > }Color` ];\n\tstyle?: CSSProperties[ `border${ Capitalize< T > }Style` ];\n\twidth?: CSSProperties[ `border${ Capitalize< T > }Width` ];\n}\n\nexport interface Style {\n\tbackground?: {\n\t\tbackgroundImage: {\n\t\t\turl?: CSSProperties[ 'backgroundImage' ];\n\t\t\tsource?: string;\n\t\t};\n\t\tbackgroundSize?: CSSProperties[ 'backgroundSize' ];\n\t};\n\tborder?: {\n\t\tcolor?: CSSProperties[ 'borderColor' ];\n\t\tradius?:\n\t\t\t| CSSProperties[ 'borderRadius' ]\n\t\t\t| {\n\t\t\t\t\ttopLeft?: CSSProperties[ 'borderTopLeftRadius' ];\n\t\t\t\t\ttopRight?: CSSProperties[ 'borderTopRightRadius' ];\n\t\t\t\t\tbottomLeft?: CSSProperties[ 'borderBottomLeftRadius' ];\n\t\t\t\t\tbottomRight?: CSSProperties[ 'borderBottomLeftRadius' ];\n\t\t\t };\n\t\tstyle?: CSSProperties[ 'borderStyle' ];\n\t\twidth?: CSSProperties[ 'borderWidth' ];\n\t\ttop?: BorderIndividualStyles< 'top' >;\n\t\tright?: BorderIndividualStyles< 'right' >;\n\t\tbottom?: BorderIndividualStyles< 'bottom' >;\n\t\tleft?: BorderIndividualStyles< 'left' >;\n\t};\n\tdimensions?: {\n\t\tminHeight?: CSSProperties[ 'minHeight' ];\n\t};\n\tspacing?: {\n\t\tmargin?: CSSProperties[ 'margin' ] | Box< 'margin' >;\n\t\tpadding?: CSSProperties[ 'padding' ] | Box< 'padding' >;\n\t};\n\ttypography?: {\n\t\tfontSize?: CSSProperties[ 'fontSize' ];\n\t\tfontFamily?: CSSProperties[ 'fontFamily' ];\n\t\tfontWeight?: CSSProperties[ 'fontWeight' ];\n\t\tfontStyle?: CSSProperties[ 'fontStyle' ];\n\t\tletterSpacing?: CSSProperties[ 'letterSpacing' ];\n\t\tlineHeight?: CSSProperties[ 'lineHeight' ];\n\t\ttextColumns?: CSSProperties[ 'columnCount' ];\n\t\ttextDecoration?: CSSProperties[ 'textDecoration' ];\n\t\ttextTransform?: CSSProperties[ 'textTransform' ];\n\t\twritingMode?: CSSProperties[ 'writingMode' ];\n\t};\n\tcolor?: {\n\t\ttext?: CSSProperties[ 'color' ];\n\t\tbackground?: CSSProperties[ 'backgroundColor' ];\n\t\tgradient?: CSSProperties[ 'background' ];\n\t};\n\telements?: {\n\t\tlink?: {\n\t\t\tcolor?: {\n\t\t\t\ttext?: CSSProperties[ 'color' ];\n\t\t\t};\n\t\t};\n\t};\n}\n\nexport interface CssRulesKeys {\n\tdefault: string;\n\tindividual: string;\n}\n\nexport interface StyleOptions {\n\t/**\n\t * CSS selector for the generated style.\n\t */\n\tselector?: string;\n}\n\nexport interface GeneratedCSSRule {\n\tselector?: string;\n\tvalue: string;\n\t/**\n\t * The CSS key in JS style attribute format, compatible with React.\n\t * E.g. `paddingTop` instead of `padding-top`.\n\t */\n\tkey: string;\n}\n\nexport interface GenerateFunction {\n\t( style: Style, options: StyleOptions ): GeneratedCSSRule[];\n}\n\nexport interface StyleDefinition {\n\tname: string;\n\tgenerate?: GenerateFunction;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { GeneratedCSSRule, Style, StyleOptions } from '../../types';
|
|
5
|
+
declare const _default: {
|
|
6
|
+
name: string;
|
|
7
|
+
generate: (style: Style, options: StyleOptions) => GeneratedCSSRule[];
|
|
8
|
+
}[];
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/styles/background/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;;;;;AAuCzE,wBAAmC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/styles/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/styles/index.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,gBAAgB;;;IAS5B,CAAC"}
|
|
@@ -58,4 +58,18 @@ export declare function upperFirst(string: string): string;
|
|
|
58
58
|
* @return camelCase string.
|
|
59
59
|
*/
|
|
60
60
|
export declare function camelCaseJoin(strings: string[]): string;
|
|
61
|
+
/**
|
|
62
|
+
* Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
|
|
63
|
+
* `decodeURI` throws an error.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} uri URI to decode.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```js
|
|
69
|
+
* const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @return {string} Decoded URI if possible.
|
|
73
|
+
*/
|
|
74
|
+
export declare function safeDecodeURI(uri: string): string;
|
|
61
75
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/styles/utils.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAChB,KAAK,EAEL,YAAY,EACZ,MAAM,UAAU,CAAC;AAOlB;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,WACvB,OAAQ,GAAG,EAAE,GAAG,CAAE,QACpB,MAAM,EAAE,QAOd,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,MAAM,GACb,gBAAgB,EAAE,CAYpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,YAAY,EACtB,oBAAoB,GAAE,MAAM,EAAyC,GACnE,gBAAgB,EAAE,CAwCpB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAE,UAAU,EAAE,MAAM,GAAI,MAAM,CAsBpE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAE,MAAM,EAAE,MAAM,GAAI,MAAM,CAGnD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAE,OAAO,EAAE,MAAM,EAAE,GAAI,MAAM,CAGzD"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/styles/utils.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAChB,KAAK,EAEL,YAAY,EACZ,MAAM,UAAU,CAAC;AAOlB;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,WACvB,OAAQ,GAAG,EAAE,GAAG,CAAE,QACpB,MAAM,EAAE,QAOd,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,MAAM,GACb,gBAAgB,EAAE,CAYpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,YAAY,EACtB,oBAAoB,GAAE,MAAM,EAAyC,GACnE,gBAAgB,EAAE,CAwCpB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAE,UAAU,EAAE,MAAM,GAAI,MAAM,CAsBpE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAE,MAAM,EAAE,MAAM,GAAI,MAAM,CAGnD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAE,OAAO,EAAE,MAAM,EAAE,GAAI,MAAM,CAGzD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAE,GAAG,EAAE,MAAM,GAAI,MAAM,CAMnD"}
|
package/build-types/types.d.ts
CHANGED
|
@@ -16,6 +16,13 @@ export interface BorderIndividualStyles<T extends BoxEdge> {
|
|
|
16
16
|
width?: CSSProperties[`border${Capitalize<T>}Width`];
|
|
17
17
|
}
|
|
18
18
|
export interface Style {
|
|
19
|
+
background?: {
|
|
20
|
+
backgroundImage: {
|
|
21
|
+
url?: CSSProperties['backgroundImage'];
|
|
22
|
+
source?: string;
|
|
23
|
+
};
|
|
24
|
+
backgroundSize?: CSSProperties['backgroundSize'];
|
|
25
|
+
};
|
|
19
26
|
border?: {
|
|
20
27
|
color?: CSSProperties['borderColor'];
|
|
21
28
|
radius?: CSSProperties['borderRadius'] | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,KAAK,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AACvC,MAAM,WAAW,GAAG,CAAE,CAAC,SAAS,UAAU,GAAG,SAAS,GAAG,SAAS;IACjE,GAAG,CAAC,EAAE,aAAa,CAAE,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,GAAI,CAAE,KAAK,CAAE,CAAC;IACjE,KAAK,CAAC,EAAE,aAAa,CAAE,CAAC,SAAS,SAAS,GAAG,OAAO,GAAG,GAAI,CAAE,OAAO,CAAE,CAAC;IACvE,MAAM,CAAC,EAAE,aAAa,CAAE,CAAC,SAAS,SAAS,GAAG,QAAQ,GAAG,GAAI,CAAE,QAAQ,CAAE,CAAC;IAC1E,IAAI,CAAC,EAAE,aAAa,CAAE,CAAC,SAAS,SAAS,GAAG,MAAM,GAAG,GAAI,CAAE,MAAM,CAAE,CAAC;CACpE;AAED,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAG1D,MAAM,WAAW,sBAAsB,CAAE,CAAC,SAAS,OAAO;IACzD,KAAK,CAAC,EAAE,aAAa,CAAE,SAAU,UAAU,CAAE,CAAC,CAAG,OAAO,CAAE,CAAC;IAC3D,KAAK,CAAC,EAAE,aAAa,CAAE,SAAU,UAAU,CAAE,CAAC,CAAG,OAAO,CAAE,CAAC;IAC3D,KAAK,CAAC,EAAE,aAAa,CAAE,SAAU,U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B;IAChC,CAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,GAAI,gBAAgB,EAAE,CAAC;CAC5D;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC5B"}
|
|
@@ -25,7 +25,9 @@ if ( class_exists( 'WP_Style_Engine' ) ) {
|
|
|
25
25
|
final class WP_Style_Engine {
|
|
26
26
|
/**
|
|
27
27
|
* Style definitions that contain the instructions to parse/output valid Gutenberg styles from a block's attributes.
|
|
28
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* For every style definition, the following properties are valid:
|
|
30
|
+
*
|
|
29
31
|
* - classnames => (array) an array of classnames to be returned for block styles. The key is a classname or pattern.
|
|
30
32
|
* A value of `true` means the classname should be applied always. Otherwise, a valid CSS property (string)
|
|
31
33
|
* to match the incoming value, e.g., "color" to match var:preset|color|somePresetSlug.
|
|
@@ -41,6 +43,21 @@ final class WP_Style_Engine {
|
|
|
41
43
|
* @var array
|
|
42
44
|
*/
|
|
43
45
|
const BLOCK_STYLE_DEFINITIONS_METADATA = array(
|
|
46
|
+
'background' => array(
|
|
47
|
+
'backgroundImage' => array(
|
|
48
|
+
'property_keys' => array(
|
|
49
|
+
'default' => 'background-image',
|
|
50
|
+
),
|
|
51
|
+
'value_func' => array( self::class, 'get_url_or_value_css_declaration' ),
|
|
52
|
+
'path' => array( 'background', 'backgroundImage' ),
|
|
53
|
+
),
|
|
54
|
+
'backgroundSize' => array(
|
|
55
|
+
'property_keys' => array(
|
|
56
|
+
'default' => 'background-size',
|
|
57
|
+
),
|
|
58
|
+
'path' => array( 'background', 'backgroundSize' ),
|
|
59
|
+
),
|
|
60
|
+
),
|
|
44
61
|
'color' => array(
|
|
45
62
|
'text' => array(
|
|
46
63
|
'property_keys' => array(
|
|
@@ -541,6 +558,41 @@ final class WP_Style_Engine {
|
|
|
541
558
|
return $css_declarations;
|
|
542
559
|
}
|
|
543
560
|
|
|
561
|
+
/**
|
|
562
|
+
* Style value parser that constructs a CSS definition array comprising a single CSS property and value.
|
|
563
|
+
* If the provided value is an array containing a `url` property, the function will return a CSS definition array
|
|
564
|
+
* with a single property and value, with `url` escaped and injected into a CSS `url()` function,
|
|
565
|
+
* e.g., array( 'background-image' => "url( '...' )" ).
|
|
566
|
+
*
|
|
567
|
+
* @param array $style_value A single raw style value from $block_styles array.
|
|
568
|
+
* @param array $style_definition A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA.
|
|
569
|
+
*
|
|
570
|
+
* @return string[] An associative array of CSS definitions, e.g., array( "$property" => "$value", "$property" => "$value" ).
|
|
571
|
+
*/
|
|
572
|
+
protected static function get_url_or_value_css_declaration( $style_value, $style_definition ) {
|
|
573
|
+
if ( empty( $style_value ) ) {
|
|
574
|
+
return array();
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
$css_declarations = array();
|
|
578
|
+
|
|
579
|
+
if ( isset( $style_definition['property_keys']['default'] ) ) {
|
|
580
|
+
$value = null;
|
|
581
|
+
|
|
582
|
+
if ( ! empty( $style_value['url'] ) ) {
|
|
583
|
+
$value = "url('" . $style_value['url'] . "')";
|
|
584
|
+
} elseif ( is_string( $style_value ) ) {
|
|
585
|
+
$value = $style_value;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
if ( null !== $value ) {
|
|
589
|
+
$css_declarations[ $style_definition['property_keys']['default'] ] = $value;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return $css_declarations;
|
|
594
|
+
}
|
|
595
|
+
|
|
544
596
|
/**
|
|
545
597
|
* Returns compiled CSS from css_declarations.
|
|
546
598
|
*
|
|
@@ -133,8 +133,14 @@ function gutenberg_apply_colors_support( $block_type, $block_attributes ) {
|
|
|
133
133
|
$color_block_styles = array();
|
|
134
134
|
|
|
135
135
|
// Set the color style values according to whether the block has support and does not skip serialization.
|
|
136
|
-
$spacing_block_styles['text'] =
|
|
137
|
-
$spacing_block_styles['background'] =
|
|
136
|
+
$spacing_block_styles['text'] = null;
|
|
137
|
+
$spacing_block_styles['background'] = null;
|
|
138
|
+
if ( $has_text_support && ! $skips_serialization_of_color_text ) {
|
|
139
|
+
$spacing_block_styles['text'] = $block_color_styles['text'] ?? null;
|
|
140
|
+
}
|
|
141
|
+
if $has_background_support && ! $skips_serialization_of_color_background ) {
|
|
142
|
+
$spacing_block_styles['background'] = $block_color_styles['background'] ?? null;
|
|
143
|
+
}
|
|
138
144
|
|
|
139
145
|
// Pass the color styles, excluding those that have no support or skip serialization, to the Style Engine.
|
|
140
146
|
$styles = wp_style_engine_get_styles( array( 'color' => $block_color_styles ) );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/style-engine",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
4
4
|
"description": "A suite of parsers and compilers for WordPress styles.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "cc35f517ed017ab7131319af3e87c359e8de175d"
|
|
39
39
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { GeneratedCSSRule, Style, StyleOptions } from '../../types';
|
|
5
|
+
import { safeDecodeURI } from '../utils';
|
|
6
|
+
|
|
7
|
+
const backgroundImage = {
|
|
8
|
+
name: 'backgroundImage',
|
|
9
|
+
generate: ( style: Style, options: StyleOptions ) => {
|
|
10
|
+
const _backgroundImage = style?.background?.backgroundImage;
|
|
11
|
+
const _backgroundSize = style?.background?.backgroundSize;
|
|
12
|
+
|
|
13
|
+
const styleRules: GeneratedCSSRule[] = [];
|
|
14
|
+
|
|
15
|
+
if ( ! _backgroundImage ) {
|
|
16
|
+
return styleRules;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if ( _backgroundImage?.source === 'file' && _backgroundImage?.url ) {
|
|
20
|
+
styleRules.push( {
|
|
21
|
+
selector: options.selector,
|
|
22
|
+
key: 'backgroundImage',
|
|
23
|
+
// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
|
|
24
|
+
value: `url( '${ encodeURI(
|
|
25
|
+
safeDecodeURI( _backgroundImage.url )
|
|
26
|
+
) }' )`,
|
|
27
|
+
} );
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// If no background size is set, but an image is, default to cover.
|
|
31
|
+
if ( ! _backgroundSize ) {
|
|
32
|
+
styleRules.push( {
|
|
33
|
+
selector: options.selector,
|
|
34
|
+
key: 'backgroundSize',
|
|
35
|
+
value: 'cover',
|
|
36
|
+
} );
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return styleRules;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default [ backgroundImage ];
|
package/src/styles/index.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import border from './border';
|
|
5
5
|
import color from './color';
|
|
6
6
|
import dimensions from './dimensions';
|
|
7
|
+
import background from './background';
|
|
7
8
|
import shadow from './shadow';
|
|
8
9
|
import outline from './outline';
|
|
9
10
|
import spacing from './spacing';
|
|
@@ -17,4 +18,5 @@ export const styleDefinitions = [
|
|
|
17
18
|
...spacing,
|
|
18
19
|
...typography,
|
|
19
20
|
...shadow,
|
|
21
|
+
...background,
|
|
20
22
|
];
|
package/src/styles/utils.ts
CHANGED
|
@@ -180,3 +180,24 @@ export function camelCaseJoin( strings: string[] ): string {
|
|
|
180
180
|
const [ firstItem, ...rest ] = strings;
|
|
181
181
|
return firstItem.toLowerCase() + rest.map( upperFirst ).join( '' );
|
|
182
182
|
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
|
|
186
|
+
* `decodeURI` throws an error.
|
|
187
|
+
*
|
|
188
|
+
* @param {string} uri URI to decode.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```js
|
|
192
|
+
* const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @return {string} Decoded URI if possible.
|
|
196
|
+
*/
|
|
197
|
+
export function safeDecodeURI( uri: string ): string {
|
|
198
|
+
try {
|
|
199
|
+
return decodeURI( uri );
|
|
200
|
+
} catch ( uriError ) {
|
|
201
|
+
return uri;
|
|
202
|
+
}
|
|
203
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -21,6 +21,13 @@ export interface BorderIndividualStyles< T extends BoxEdge > {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface Style {
|
|
24
|
+
background?: {
|
|
25
|
+
backgroundImage: {
|
|
26
|
+
url?: CSSProperties[ 'backgroundImage' ];
|
|
27
|
+
source?: string;
|
|
28
|
+
};
|
|
29
|
+
backgroundSize?: CSSProperties[ 'backgroundSize' ];
|
|
30
|
+
};
|
|
24
31
|
border?: {
|
|
25
32
|
color?: CSSProperties[ 'borderColor' ];
|
|
26
33
|
radius?:
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../node_modules/no-case/dist/index.d.ts","../../node_modules/pascal-case/dist/index.d.ts","../../node_modules/camel-case/dist/index.d.ts","../../node_modules/capital-case/dist/index.d.ts","../../node_modules/constant-case/dist/index.d.ts","../../node_modules/dot-case/dist/index.d.ts","../../node_modules/header-case/dist/index.d.ts","../../node_modules/param-case/dist/index.d.ts","../../node_modules/path-case/dist/index.d.ts","../../node_modules/sentence-case/dist/index.d.ts","../../node_modules/snake-case/dist/index.d.ts","../../node_modules/change-case/dist/index.d.ts","../../node_modules/@types/react/global.d.ts","../../node_modules/csstype/index.d.ts","../../node_modules/@types/prop-types/index.d.ts","../../node_modules/@types/scheduler/tracing.d.ts","../../node_modules/@types/react/index.d.ts","./src/types.ts","./src/styles/constants.ts","./src/styles/utils.ts","./src/styles/border/index.ts","./src/styles/color/background.ts","./src/styles/color/gradient.ts","./src/styles/color/text.ts","./src/styles/color/index.ts","./src/styles/dimensions/index.ts","./src/styles/shadow/index.ts","./src/styles/outline/index.ts","./src/styles/spacing/padding.ts","./src/styles/spacing/margin.ts","./src/styles/spacing/index.ts","./src/styles/typography/index.ts","./src/styles/index.ts","./src/index.ts"],"fileInfos":[{"version":"f59215c5f1d886b05395ee7aca73e0ac69ddfad2843aa88530e797879d511bad","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","f4e736d6c8d69ae5b3ab0ddfcaa3dc365c3e76909d6660af5b4e979b3934ac20","eeeb3aca31fbadef8b82502484499dfd1757204799a6f5b33116201c810676ec",{"version":"3dda5344576193a4ae48b8d03f105c86f20b2f2aff0a1d1fd7935f5d68649654","affectsGlobalScope":true},{"version":"9d9885c728913c1d16e0d2831b40341d6ad9a0ceecaabc55209b306ad9c736a5","affectsGlobalScope":true},{"version":"17bea081b9c0541f39dd1ae9bc8c78bdd561879a682e60e2f25f688c0ecab248","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true},{"version":"f06948deb2a51aae25184561c9640fb66afeddb34531a9212d011792b1d19e0a","affectsGlobalScope":true},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"709efdae0cb5df5f49376cde61daacc95cdd44ae4671da13a540da5088bf3f30","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"61ed9b6d07af959e745fb11f9593ecd743b279418cc8a99448ea3cd5f3b3eb22","affectsGlobalScope":true},{"version":"038a2f66a34ee7a9c2fbc3584c8ab43dff2995f8c68e3f566f4c300d2175e31e","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"f5c92f2c27b06c1a41b88f6db8299205aee52c2a2943f7ed29bd585977f254e8","affectsGlobalScope":true},{"version":"930b0e15811f84e203d3c23508674d5ded88266df4b10abee7b31b2ac77632d2","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"b9ea5778ff8b50d7c04c9890170db34c26a5358cccba36844fe319f50a43a61a","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"25de46552b782d43cb7284df22fe2a265de387cf0248b747a7a1b647d81861f6","affectsGlobalScope":true},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"b4e123af1af6049685c93073a15868b50aebdad666d422edc72fa2b585fa8a37","f86c04a744ebcede96bac376f9a2c90f2bd3c422740d91dda4ca6233199d4977","6ae1bddee5c790439bd992abd063b9b46e0cadd676c2a8562268d1869213ff60","606244fc97a6a74b877f2e924ba7e55b233bc6acb57d7bf40ba84a5be2d9adb0","4a1cabac71036b8a14f5db1b753b579f0c901c7d7b9227e6872dadf6efb104e8","062959a1d825b96639d87be35fe497cbd3f89544bf06fdad577bbfb85fcf604c","4c3672dc8f4e4fdd3d18525b22b31f1b5481f5a415db96550d3ac5163a6c3dd3","f9a69ca445010b91fe08f08c06e0f86d79c0d776905f9bdb828477cb2a1eb7fc","ad7fd0e7ee457d4884b3aaecbcbd2a80b6803407c4ce2540c296170d4c7918ef","a50ef21605f41c6acad6c3ef0307e5311b94963c846ca093c764b80cdb5318d6","74b4035dd26d09a417c44ca23ab5ee69b173f8c2f6b2e47350ab0795cf2d4a17","918f86ee2b19cc38cb8b1a4cf8f223eb228aaa39df3604c42f700fac2f0b3ea1",{"version":"bbdf156fea2fabed31a569445835aeedcc33643d404fcbaa54541f06c109df3f","affectsGlobalScope":true},"4c68749a564a6facdf675416d75789ee5a557afda8960e0803cf6711fa569288","f7b46d22a307739c145e5fddf537818038fdfffd580d79ed717f4d4d37249380","f5a8b384f182b3851cec3596ccc96cb7464f8d3469f48c74bf2befb782a19de5",{"version":"5917af4ff931b050dba49a1dedd9c00f15f7b3dc4345ad8491bfacd2ec68ed32","affectsGlobalScope":true},{"version":"034393ac2d79ac36ea29a7f05822e61d111b06771f58842948fd2c965163477f","signature":"3dd0768578062dd562296385b196c5cd868c221d9000d5d48ae6e30b45452e23"},{"version":"301543eebfdd2fc5e5d6d928c5ed3f65bd377e95d184eb1351df5fe38ef9eac0","signature":"b6dbb3376b4265410d8aad2c234b41ac0a1f8d29e0ae0bf06c159c9f2ef13fc0"},{"version":"f57932a72feb9f433f6f71fb5e7f7a8bdabce1e243c9e48fd5627974994a4c38","signature":"207918f1e0cf238af170f513414eb8fc7739680609c705cefcb4430d25320d76"},{"version":"6a47ab963c0de27ca91c40b8a8370d4c368f51bbcfeb70ca028fa3679afa56f9","signature":"65511c14946110a16693dd09273dfc0f8060d0ac6d0ad40cbcebdced0b251961"},{"version":"49dec6685c69b84a795d1e2c2a8d7ac8953efb4a7dadb9b1b04c836053e0ea21","signature":"9a4c1e89a7eeff330b95276972fee79058b121b261d1118ef7d5ef9cfc3bccdd"},{"version":"8cbcd8c85fe3627d4c9e75ccf2784b7e4d0082396600e9d432f1cd61009a7933","signature":"1bcecf449f856cced1aeb30fbb82a49e1037833139fd43bf1c1740ccc9ba0b6a"},{"version":"f303eb9a884f47802f08d6b1d376c737856c29783532a44116bfc7e4929a7204","signature":"629dbceb125f23c956f1f42fc11f9b37d42f49519267b4f8448a4e5c1214d142"},{"version":"e8dc9f16ad89ba54f1e7202369a69a265ccd5eec0df39cf429ff1a941603d4da","signature":"2439cec606f95353956bd2e48af0b238600ec807f6270db4fc22e6433bb59efd"},{"version":"65c3ed1afd27cc04c86fafa33cb549ac39f94d828ce06f0a9b3464b05c9a05d6","signature":"06f5b632cabf37fd02dd4ebff4cb0f8a693846cac3f30a47f1a517e9ff956bd3"},{"version":"51f25b3291c4ca38c72cb150453eb2961bb0ca2891102719064e2a695c47a55a","signature":"06f5b632cabf37fd02dd4ebff4cb0f8a693846cac3f30a47f1a517e9ff956bd3"},{"version":"697ce73163b0e4ac9fe325a666e48b76b0754eff4b3fe7906369894a76cd860f","signature":"a69042401e8a750db9b3e8be7898ee61a6af5bacdc2abfa373b596923b68f170"},{"version":"caa45d96bc56c4f2ea6dfbe715413636f0d8b74121a8820b70526a3ae1bfd9b9","signature":"aaf7dd84606d5f76aa8219904020c11a858ce264dc846a4023faff5e3823e9b4"},{"version":"3d0705f37a3de49d9210d2656cd697ae0cd93476a7e60f7b099797166e4d78b0","signature":"76fc0038ad0327ca885df7e552ebbf68e65ec59cf5ecab10cbdcb48486367cb0"},{"version":"b7003bd91d5a0b8bf84a3ef07a0cf5a4b8e0cef58d9e6404f54f05fd4ed6f0b2","signature":"2439cec606f95353956bd2e48af0b238600ec807f6270db4fc22e6433bb59efd"},{"version":"8f78e17d875af8af5817ba21888947d6a220016b0968e5f220292c24f09e5fb7","signature":"06f5b632cabf37fd02dd4ebff4cb0f8a693846cac3f30a47f1a517e9ff956bd3"},{"version":"fb22bd47aad5bb07bd4a88908ff4a3a02af74c3f7f3a56a76ed43ba80cea82e4","signature":"ed379548d37856782da05eb4ead24db026f64d325c2cfbe256e667da7efe7c42"},{"version":"babca4a1e05e5028c677a19ff566fc84f8b66ea081631a7fef795ff56e8aec60","signature":"41b50b205d6a222f23c5a4858b5250fb61998c40e89564e5f255221d9157135d"}],"root":[[78,94]],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[73,74,75,76],[62],[61],[61,62,63,64,65,66,67,68,69,70,71],[64],[66],[72,78,93],[78,80],[82,83,84],[81,85,86,87,88,91,92],[89,90],[72,78,79],[77],[78]],"referencedMap":[[77,1],[63,2],[64,3],[72,4],[65,3],[66,3],[67,5],[68,6],[62,3],[69,6],[70,3],[71,6],[94,7],[81,8],[82,8],[83,8],[85,9],[84,8],[86,8],[93,10],[88,8],[87,8],[91,11],[90,8],[89,8],[92,8],[80,12],[78,13]],"exportedModulesMap":[[77,1],[63,2],[64,3],[72,4],[65,3],[66,3],[67,5],[68,6],[62,3],[69,6],[70,3],[71,6],[94,14],[81,14],[82,14],[83,14],[85,14],[84,14],[86,14],[93,14],[88,14],[87,14],[91,14],[90,14],[89,14],[92,14],[80,14],[78,13]],"semanticDiagnosticsPerFile":[75,73,77,76,63,64,72,65,74,66,67,61,68,62,69,70,71,59,60,12,14,13,2,15,16,17,18,19,20,21,22,3,4,26,23,24,25,27,28,29,5,30,31,32,33,6,37,34,35,36,38,7,39,44,45,40,41,42,43,8,49,46,47,48,50,9,51,52,53,56,54,55,57,10,1,11,58,94,81,82,83,85,84,79,86,93,88,87,91,90,89,92,80,78],"latestChangedDtsFile":"./build-types/index.d.ts"},"version":"5.1.6"}
|
|
1
|
+
{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../node_modules/no-case/dist/index.d.ts","../../node_modules/pascal-case/dist/index.d.ts","../../node_modules/camel-case/dist/index.d.ts","../../node_modules/capital-case/dist/index.d.ts","../../node_modules/constant-case/dist/index.d.ts","../../node_modules/dot-case/dist/index.d.ts","../../node_modules/header-case/dist/index.d.ts","../../node_modules/param-case/dist/index.d.ts","../../node_modules/path-case/dist/index.d.ts","../../node_modules/sentence-case/dist/index.d.ts","../../node_modules/snake-case/dist/index.d.ts","../../node_modules/change-case/dist/index.d.ts","../../node_modules/@types/react/global.d.ts","../../node_modules/csstype/index.d.ts","../../node_modules/@types/prop-types/index.d.ts","../../node_modules/@types/scheduler/tracing.d.ts","../../node_modules/@types/react/index.d.ts","./src/types.ts","./src/styles/constants.ts","./src/styles/utils.ts","./src/styles/border/index.ts","./src/styles/color/background.ts","./src/styles/color/gradient.ts","./src/styles/color/text.ts","./src/styles/color/index.ts","./src/styles/dimensions/index.ts","./src/styles/background/index.ts","./src/styles/shadow/index.ts","./src/styles/outline/index.ts","./src/styles/spacing/padding.ts","./src/styles/spacing/margin.ts","./src/styles/spacing/index.ts","./src/styles/typography/index.ts","./src/styles/index.ts","./src/index.ts"],"fileInfos":[{"version":"f59215c5f1d886b05395ee7aca73e0ac69ddfad2843aa88530e797879d511bad","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","f4e736d6c8d69ae5b3ab0ddfcaa3dc365c3e76909d6660af5b4e979b3934ac20","eeeb3aca31fbadef8b82502484499dfd1757204799a6f5b33116201c810676ec",{"version":"3dda5344576193a4ae48b8d03f105c86f20b2f2aff0a1d1fd7935f5d68649654","affectsGlobalScope":true},{"version":"9d9885c728913c1d16e0d2831b40341d6ad9a0ceecaabc55209b306ad9c736a5","affectsGlobalScope":true},{"version":"17bea081b9c0541f39dd1ae9bc8c78bdd561879a682e60e2f25f688c0ecab248","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true},{"version":"f06948deb2a51aae25184561c9640fb66afeddb34531a9212d011792b1d19e0a","affectsGlobalScope":true},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"709efdae0cb5df5f49376cde61daacc95cdd44ae4671da13a540da5088bf3f30","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"61ed9b6d07af959e745fb11f9593ecd743b279418cc8a99448ea3cd5f3b3eb22","affectsGlobalScope":true},{"version":"038a2f66a34ee7a9c2fbc3584c8ab43dff2995f8c68e3f566f4c300d2175e31e","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"f5c92f2c27b06c1a41b88f6db8299205aee52c2a2943f7ed29bd585977f254e8","affectsGlobalScope":true},{"version":"930b0e15811f84e203d3c23508674d5ded88266df4b10abee7b31b2ac77632d2","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"b9ea5778ff8b50d7c04c9890170db34c26a5358cccba36844fe319f50a43a61a","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"25de46552b782d43cb7284df22fe2a265de387cf0248b747a7a1b647d81861f6","affectsGlobalScope":true},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"b4e123af1af6049685c93073a15868b50aebdad666d422edc72fa2b585fa8a37","f86c04a744ebcede96bac376f9a2c90f2bd3c422740d91dda4ca6233199d4977","6ae1bddee5c790439bd992abd063b9b46e0cadd676c2a8562268d1869213ff60","606244fc97a6a74b877f2e924ba7e55b233bc6acb57d7bf40ba84a5be2d9adb0","4a1cabac71036b8a14f5db1b753b579f0c901c7d7b9227e6872dadf6efb104e8","062959a1d825b96639d87be35fe497cbd3f89544bf06fdad577bbfb85fcf604c","4c3672dc8f4e4fdd3d18525b22b31f1b5481f5a415db96550d3ac5163a6c3dd3","f9a69ca445010b91fe08f08c06e0f86d79c0d776905f9bdb828477cb2a1eb7fc","ad7fd0e7ee457d4884b3aaecbcbd2a80b6803407c4ce2540c296170d4c7918ef","a50ef21605f41c6acad6c3ef0307e5311b94963c846ca093c764b80cdb5318d6","74b4035dd26d09a417c44ca23ab5ee69b173f8c2f6b2e47350ab0795cf2d4a17","918f86ee2b19cc38cb8b1a4cf8f223eb228aaa39df3604c42f700fac2f0b3ea1",{"version":"bbdf156fea2fabed31a569445835aeedcc33643d404fcbaa54541f06c109df3f","affectsGlobalScope":true},"4c68749a564a6facdf675416d75789ee5a557afda8960e0803cf6711fa569288","f7b46d22a307739c145e5fddf537818038fdfffd580d79ed717f4d4d37249380","f5a8b384f182b3851cec3596ccc96cb7464f8d3469f48c74bf2befb782a19de5",{"version":"5917af4ff931b050dba49a1dedd9c00f15f7b3dc4345ad8491bfacd2ec68ed32","affectsGlobalScope":true},{"version":"87bea162f9a463091c1a37872a3a8a81dff31c775ff563c1d2a0d90b60e53007","signature":"f77d55ca9bec105c83d1564f3f225508b0a7758f0322e544aaeaa2e014640110"},{"version":"301543eebfdd2fc5e5d6d928c5ed3f65bd377e95d184eb1351df5fe38ef9eac0","signature":"b6dbb3376b4265410d8aad2c234b41ac0a1f8d29e0ae0bf06c159c9f2ef13fc0"},{"version":"c3f0acdbfdc730cfafa6c7dec5bee986b9b2aa876641fd9f8b576c364e8e5940","signature":"774455d4fcae6aee2339b51f319ca5d0279ea7832fece5195875a9a3b94d2f35"},{"version":"6a47ab963c0de27ca91c40b8a8370d4c368f51bbcfeb70ca028fa3679afa56f9","signature":"65511c14946110a16693dd09273dfc0f8060d0ac6d0ad40cbcebdced0b251961"},{"version":"49dec6685c69b84a795d1e2c2a8d7ac8953efb4a7dadb9b1b04c836053e0ea21","signature":"9a4c1e89a7eeff330b95276972fee79058b121b261d1118ef7d5ef9cfc3bccdd"},{"version":"8cbcd8c85fe3627d4c9e75ccf2784b7e4d0082396600e9d432f1cd61009a7933","signature":"1bcecf449f856cced1aeb30fbb82a49e1037833139fd43bf1c1740ccc9ba0b6a"},{"version":"f303eb9a884f47802f08d6b1d376c737856c29783532a44116bfc7e4929a7204","signature":"629dbceb125f23c956f1f42fc11f9b37d42f49519267b4f8448a4e5c1214d142"},{"version":"e8dc9f16ad89ba54f1e7202369a69a265ccd5eec0df39cf429ff1a941603d4da","signature":"2439cec606f95353956bd2e48af0b238600ec807f6270db4fc22e6433bb59efd"},{"version":"65c3ed1afd27cc04c86fafa33cb549ac39f94d828ce06f0a9b3464b05c9a05d6","signature":"06f5b632cabf37fd02dd4ebff4cb0f8a693846cac3f30a47f1a517e9ff956bd3"},{"version":"1f45006c660c692ab30c09b50c4d8642a03a7f7e9f50fa95142f63369558a772","signature":"d06f7bb3014fad599289a8a9ec34c948d7a8b219eb098d968db24d67ceb94a06"},{"version":"51f25b3291c4ca38c72cb150453eb2961bb0ca2891102719064e2a695c47a55a","signature":"06f5b632cabf37fd02dd4ebff4cb0f8a693846cac3f30a47f1a517e9ff956bd3"},{"version":"697ce73163b0e4ac9fe325a666e48b76b0754eff4b3fe7906369894a76cd860f","signature":"a69042401e8a750db9b3e8be7898ee61a6af5bacdc2abfa373b596923b68f170"},{"version":"caa45d96bc56c4f2ea6dfbe715413636f0d8b74121a8820b70526a3ae1bfd9b9","signature":"aaf7dd84606d5f76aa8219904020c11a858ce264dc846a4023faff5e3823e9b4"},{"version":"3d0705f37a3de49d9210d2656cd697ae0cd93476a7e60f7b099797166e4d78b0","signature":"76fc0038ad0327ca885df7e552ebbf68e65ec59cf5ecab10cbdcb48486367cb0"},{"version":"b7003bd91d5a0b8bf84a3ef07a0cf5a4b8e0cef58d9e6404f54f05fd4ed6f0b2","signature":"2439cec606f95353956bd2e48af0b238600ec807f6270db4fc22e6433bb59efd"},{"version":"8f78e17d875af8af5817ba21888947d6a220016b0968e5f220292c24f09e5fb7","signature":"06f5b632cabf37fd02dd4ebff4cb0f8a693846cac3f30a47f1a517e9ff956bd3"},{"version":"c79131802a0c87da52604e6e6c6e87ef62168bbc7eb8f37ba587b0ef456d2e30","signature":"ed379548d37856782da05eb4ead24db026f64d325c2cfbe256e667da7efe7c42"},{"version":"babca4a1e05e5028c677a19ff566fc84f8b66ea081631a7fef795ff56e8aec60","signature":"41b50b205d6a222f23c5a4858b5250fb61998c40e89564e5f255221d9157135d"}],"root":[[78,95]],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[73,74,75,76],[62],[61],[61,62,63,64,65,66,67,68,69,70,71],[64],[66],[72,78,94],[78,80],[82,83,84],[81,85,86,87,88,89,92,93],[90,91],[72,78,79],[77],[78]],"referencedMap":[[77,1],[63,2],[64,3],[72,4],[65,3],[66,3],[67,5],[68,6],[62,3],[69,6],[70,3],[71,6],[95,7],[87,8],[81,8],[82,8],[83,8],[85,9],[84,8],[86,8],[94,10],[89,8],[88,8],[92,11],[91,8],[90,8],[93,8],[80,12],[78,13]],"exportedModulesMap":[[77,1],[63,2],[64,3],[72,4],[65,3],[66,3],[67,5],[68,6],[62,3],[69,6],[70,3],[71,6],[95,14],[87,14],[81,14],[82,14],[83,14],[85,14],[84,14],[86,14],[94,14],[89,14],[88,14],[92,14],[91,14],[90,14],[93,14],[80,14],[78,13]],"semanticDiagnosticsPerFile":[75,73,77,76,63,64,72,65,74,66,67,61,68,62,69,70,71,59,60,12,14,13,2,15,16,17,18,19,20,21,22,3,4,26,23,24,25,27,28,29,5,30,31,32,33,6,37,34,35,36,38,7,39,44,45,40,41,42,43,8,49,46,47,48,50,9,51,52,53,56,54,55,57,10,1,11,58,95,87,81,82,83,85,84,79,86,94,89,88,92,91,90,93,80,78],"latestChangedDtsFile":"./build-types/index.d.ts"},"version":"5.1.6"}
|