@wordpress/style-engine 0.5.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/index.js +13 -2
  3. package/build/index.js.map +1 -1
  4. package/build/styles/color/background.js +21 -0
  5. package/build/styles/color/background.js.map +1 -0
  6. package/build/styles/color/gradient.js +21 -0
  7. package/build/styles/color/gradient.js.map +1 -0
  8. package/build/styles/color/index.js +21 -0
  9. package/build/styles/color/index.js.map +1 -0
  10. package/build/styles/color/text.js +21 -0
  11. package/build/styles/color/text.js.map +1 -0
  12. package/build/styles/constants.js +13 -0
  13. package/build/styles/constants.js.map +1 -0
  14. package/build/styles/index.js +5 -3
  15. package/build/styles/index.js.map +1 -1
  16. package/build/styles/spacing/index.js +19 -0
  17. package/build/styles/spacing/index.js.map +1 -0
  18. package/build/styles/{margin.js → spacing/margin.js} +1 -1
  19. package/build/styles/spacing/margin.js.map +1 -0
  20. package/build/styles/{padding.js → spacing/padding.js} +1 -1
  21. package/build/styles/spacing/padding.js.map +1 -0
  22. package/build/styles/typography/index.js +57 -0
  23. package/build/styles/typography/index.js.map +1 -0
  24. package/build/styles/utils.js +54 -2
  25. package/build/styles/utils.js.map +1 -1
  26. package/build-module/index.js +13 -2
  27. package/build-module/index.js.map +1 -1
  28. package/build-module/styles/color/background.js +12 -0
  29. package/build-module/styles/color/background.js.map +1 -0
  30. package/build-module/styles/color/gradient.js +12 -0
  31. package/build-module/styles/color/gradient.js.map +1 -0
  32. package/build-module/styles/color/index.js +8 -0
  33. package/build-module/styles/color/index.js.map +1 -0
  34. package/build-module/styles/color/text.js +12 -0
  35. package/build-module/styles/color/text.js.map +1 -0
  36. package/build-module/styles/constants.js +4 -0
  37. package/build-module/styles/constants.js.map +1 -0
  38. package/build-module/styles/index.js +4 -3
  39. package/build-module/styles/index.js.map +1 -1
  40. package/build-module/styles/spacing/index.js +7 -0
  41. package/build-module/styles/spacing/index.js.map +1 -0
  42. package/build-module/styles/{margin.js → spacing/margin.js} +1 -1
  43. package/build-module/styles/spacing/margin.js.map +1 -0
  44. package/build-module/styles/{padding.js → spacing/padding.js} +1 -1
  45. package/build-module/styles/spacing/padding.js.map +1 -0
  46. package/build-module/styles/typography/index.js +48 -0
  47. package/build-module/styles/typography/index.js.map +1 -0
  48. package/build-module/styles/utils.js +49 -2
  49. package/build-module/styles/utils.js.map +1 -1
  50. package/build-types/index.d.ts.map +1 -1
  51. package/build-types/styles/color/background.d.ts +14 -0
  52. package/build-types/styles/color/background.d.ts.map +1 -0
  53. package/build-types/styles/color/gradient.d.ts +14 -0
  54. package/build-types/styles/color/gradient.d.ts.map +1 -0
  55. package/build-types/styles/color/index.d.ts +10 -0
  56. package/build-types/styles/color/index.d.ts.map +1 -0
  57. package/build-types/styles/color/text.d.ts +14 -0
  58. package/build-types/styles/color/text.d.ts.map +1 -0
  59. package/build-types/styles/constants.d.ts +4 -0
  60. package/build-types/styles/constants.d.ts.map +1 -0
  61. package/build-types/styles/index.d.ts +5 -1
  62. package/build-types/styles/index.d.ts.map +1 -1
  63. package/build-types/styles/spacing/index.d.ts +6 -0
  64. package/build-types/styles/spacing/index.d.ts.map +1 -0
  65. package/build-types/styles/{margin.d.ts → spacing/margin.d.ts} +2 -2
  66. package/build-types/styles/spacing/margin.d.ts.map +1 -0
  67. package/build-types/styles/{padding.d.ts → spacing/padding.d.ts} +2 -2
  68. package/build-types/styles/spacing/padding.d.ts.map +1 -0
  69. package/build-types/styles/typography/index.d.ts +14 -0
  70. package/build-types/styles/typography/index.d.ts.map +1 -0
  71. package/build-types/styles/utils.d.ts +33 -0
  72. package/build-types/styles/utils.d.ts.map +1 -1
  73. package/build-types/types.d.ts +14 -1
  74. package/build-types/types.d.ts.map +1 -1
  75. package/class-wp-style-engine.php +189 -61
  76. package/package.json +2 -2
  77. package/phpunit/class-wp-style-engine-test.php +86 -67
  78. package/src/index.ts +13 -1
  79. package/src/styles/color/background.ts +19 -0
  80. package/src/styles/color/gradient.ts +19 -0
  81. package/src/styles/color/index.ts +8 -0
  82. package/src/styles/color/text.ts +14 -0
  83. package/src/styles/constants.ts +3 -0
  84. package/src/styles/index.ts +4 -3
  85. package/src/styles/spacing/index.ts +7 -0
  86. package/src/styles/{margin.ts → spacing/margin.ts} +2 -2
  87. package/src/styles/{padding.ts → spacing/padding.ts} +2 -2
  88. package/src/styles/typography/index.ts +99 -0
  89. package/src/styles/utils.ts +67 -2
  90. package/src/test/index.js +101 -2
  91. package/src/types.ts +14 -1
  92. package/tsconfig.tsbuildinfo +1 -1
  93. package/build/styles/margin.js.map +0 -1
  94. package/build/styles/padding.js.map +0 -1
  95. package/build-module/styles/margin.js.map +0 -1
  96. package/build-module/styles/padding.js.map +0 -1
  97. package/build-types/styles/margin.d.ts.map +0 -1
  98. package/build-types/styles/padding.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.8.0 (2022-05-18)
6
+
7
+ ## 0.7.0 (2022-05-04)
8
+
9
+ ## 0.6.0 (2022-04-21)
10
+
5
11
  ## 0.5.0 (2022-04-08)
6
12
 
7
13
  ## 0.4.0 (2022-03-23)
package/build/index.js CHANGED
@@ -23,7 +23,16 @@ var _styles = require("./styles");
23
23
  * @return generated stylesheet.
24
24
  */
25
25
  function generate(style, options) {
26
- const rules = getCSSRules(style, options);
26
+ const rules = getCSSRules(style, options); // If no selector is provided, treat generated rules as inline styles to be returned as a single string.
27
+
28
+ if (!(options !== null && options !== void 0 && options.selector)) {
29
+ const inlineRules = [];
30
+ rules.forEach(rule => {
31
+ inlineRules.push(`${(0, _lodash.kebabCase)(rule.key)}: ${rule.value};`);
32
+ });
33
+ return inlineRules.join(' ');
34
+ }
35
+
27
36
  const groupedRules = (0, _lodash.groupBy)(rules, 'selector');
28
37
  const selectorRules = Object.keys(groupedRules).reduce((acc, subSelector) => {
29
38
  acc.push(`${subSelector} { ${groupedRules[subSelector].map(rule => `${(0, _lodash.kebabCase)(rule.key)}: ${rule.value};`).join(' ')} }`);
@@ -45,7 +54,9 @@ function getCSSRules(style, options) {
45
54
  const rules = [];
46
55
 
47
56
  _styles.styleDefinitions.forEach(definition => {
48
- rules.push(...definition.generate(style, options));
57
+ if (typeof definition.generate === 'function') {
58
+ rules.push(...definition.generate(style, options));
59
+ }
49
60
  });
50
61
 
51
62
  return rules;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/style-engine/src/index.ts"],"names":["generate","style","options","rules","getCSSRules","groupedRules","selectorRules","Object","keys","reduce","acc","subSelector","push","map","rule","key","value","join","styleDefinitions","forEach","definition"],"mappings":";;;;;;;;AAGA;;AAWA;;AAdA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAT,CAAmBC,KAAnB,EAAiCC,OAAjC,EAAiE;AACvE,QAAMC,KAAK,GAAGC,WAAW,CAAEH,KAAF,EAASC,OAAT,CAAzB;AACA,QAAMG,YAAY,GAAG,qBAASF,KAAT,EAAgB,UAAhB,CAArB;AACA,QAAMG,aAAa,GAAGC,MAAM,CAACC,IAAP,CAAaH,YAAb,EAA4BI,MAA5B,CACrB,CAAEC,GAAF,EAAiBC,WAAjB,KAA0C;AACzCD,IAAAA,GAAG,CAACE,IAAJ,CACE,GAAGD,WAAa,MAAMN,YAAY,CAAEM,WAAF,CAAZ,CACrBE,GADqB,CAEnBC,IAAF,IACE,GAAG,uBAAWA,IAAI,CAACC,GAAhB,CAAuB,KAAKD,IAAI,CAACE,KAAO,GAHxB,EAKrBC,IALqB,CAKf,GALe,CAKR,IANhB;AAQA,WAAOP,GAAP;AACA,GAXoB,EAYrB,EAZqB,CAAtB;AAeA,SAAOJ,aAAa,CAACW,IAAd,CAAoB,IAApB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASb,WAAT,CACNH,KADM,EAENC,OAFM,EAGe;AACrB,QAAMC,KAAyB,GAAG,EAAlC;;AACAe,2BAAiBC,OAAjB,CAA4BC,UAAF,IAAmC;AAC5DjB,IAAAA,KAAK,CAACS,IAAN,CAAY,GAAGQ,UAAU,CAACpB,QAAX,CAAqBC,KAArB,EAA4BC,OAA5B,CAAf;AACA,GAFD;;AAIA,SAAOC,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { groupBy, kebabCase } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tStyle,\n\tStyleOptions,\n\tGeneratedCSSRule,\n\tStyleDefinition,\n} from './types';\nimport { styleDefinitions } from './styles';\n\n/**\n * Generates a stylesheet for a given style object and selector.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n *\n * @return generated stylesheet.\n */\nexport function generate( style: Style, options: StyleOptions ): string {\n\tconst rules = getCSSRules( style, options );\n\tconst groupedRules = groupBy( rules, 'selector' );\n\tconst selectorRules = Object.keys( groupedRules ).reduce(\n\t\t( acc: string[], subSelector: string ) => {\n\t\t\tacc.push(\n\t\t\t\t`${ subSelector } { ${ groupedRules[ subSelector ]\n\t\t\t\t\t.map(\n\t\t\t\t\t\t( rule: GeneratedCSSRule ) =>\n\t\t\t\t\t\t\t`${ kebabCase( rule.key ) }: ${ rule.value };`\n\t\t\t\t\t)\n\t\t\t\t\t.join( ' ' ) } }`\n\t\t\t);\n\t\t\treturn acc;\n\t\t},\n\t\t[]\n\t);\n\n\treturn selectorRules.join( '\\n' );\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 *\n * @return generated styles.\n */\nexport function getCSSRules(\n\tstyle: Style,\n\toptions: StyleOptions\n): GeneratedCSSRule[] {\n\tconst rules: GeneratedCSSRule[] = [];\n\tstyleDefinitions.forEach( ( definition: StyleDefinition ) => {\n\t\trules.push( ...definition.generate( style, options ) );\n\t} );\n\n\treturn rules;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/style-engine/src/index.ts"],"names":["generate","style","options","rules","getCSSRules","selector","inlineRules","forEach","rule","push","key","value","join","groupedRules","selectorRules","Object","keys","reduce","acc","subSelector","map","styleDefinitions","definition"],"mappings":";;;;;;;;AAGA;;AAWA;;AAdA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAT,CAAmBC,KAAnB,EAAiCC,OAAjC,EAAiE;AACvE,QAAMC,KAAK,GAAGC,WAAW,CAAEH,KAAF,EAASC,OAAT,CAAzB,CADuE,CAGvE;;AACA,MAAK,EAAEA,OAAF,aAAEA,OAAF,eAAEA,OAAO,CAAEG,QAAX,CAAL,EAA2B;AAC1B,UAAMC,WAAqB,GAAG,EAA9B;AACAH,IAAAA,KAAK,CAACI,OAAN,CAAiBC,IAAF,IAAY;AAC1BF,MAAAA,WAAW,CAACG,IAAZ,CAAmB,GAAG,uBAAWD,IAAI,CAACE,GAAhB,CAAuB,KAAKF,IAAI,CAACG,KAAO,GAA9D;AACA,KAFD;AAGA,WAAOL,WAAW,CAACM,IAAZ,CAAkB,GAAlB,CAAP;AACA;;AAED,QAAMC,YAAY,GAAG,qBAASV,KAAT,EAAgB,UAAhB,CAArB;AACA,QAAMW,aAAa,GAAGC,MAAM,CAACC,IAAP,CAAaH,YAAb,EAA4BI,MAA5B,CACrB,CAAEC,GAAF,EAAiBC,WAAjB,KAA0C;AACzCD,IAAAA,GAAG,CAACT,IAAJ,CACE,GAAGU,WAAa,MAAMN,YAAY,CAAEM,WAAF,CAAZ,CACrBC,GADqB,CAEnBZ,IAAF,IACE,GAAG,uBAAWA,IAAI,CAACE,GAAhB,CAAuB,KAAKF,IAAI,CAACG,KAAO,GAHxB,EAKrBC,IALqB,CAKf,GALe,CAKR,IANhB;AAQA,WAAOM,GAAP;AACA,GAXoB,EAYrB,EAZqB,CAAtB;AAeA,SAAOJ,aAAa,CAACF,IAAd,CAAoB,IAApB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASR,WAAT,CACNH,KADM,EAENC,OAFM,EAGe;AACrB,QAAMC,KAAyB,GAAG,EAAlC;;AACAkB,2BAAiBd,OAAjB,CAA4Be,UAAF,IAAmC;AAC5D,QAAK,OAAOA,UAAU,CAACtB,QAAlB,KAA+B,UAApC,EAAiD;AAChDG,MAAAA,KAAK,CAACM,IAAN,CAAY,GAAGa,UAAU,CAACtB,QAAX,CAAqBC,KAArB,EAA4BC,OAA5B,CAAf;AACA;AACD,GAJD;;AAMA,SAAOC,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { groupBy, kebabCase } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tStyle,\n\tStyleOptions,\n\tGeneratedCSSRule,\n\tStyleDefinition,\n} from './types';\nimport { styleDefinitions } from './styles';\n\n/**\n * Generates a stylesheet for a given style object and selector.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n *\n * @return generated stylesheet.\n */\nexport function generate( style: Style, options: StyleOptions ): string {\n\tconst rules = getCSSRules( style, options );\n\n\t// If no selector is provided, treat generated rules as inline styles to be returned as a single string.\n\tif ( ! options?.selector ) {\n\t\tconst inlineRules: string[] = [];\n\t\trules.forEach( ( rule ) => {\n\t\t\tinlineRules.push( `${ kebabCase( rule.key ) }: ${ rule.value };` );\n\t\t} );\n\t\treturn inlineRules.join( ' ' );\n\t}\n\n\tconst groupedRules = groupBy( rules, 'selector' );\n\tconst selectorRules = Object.keys( groupedRules ).reduce(\n\t\t( acc: string[], subSelector: string ) => {\n\t\t\tacc.push(\n\t\t\t\t`${ subSelector } { ${ groupedRules[ subSelector ]\n\t\t\t\t\t.map(\n\t\t\t\t\t\t( rule: GeneratedCSSRule ) =>\n\t\t\t\t\t\t\t`${ kebabCase( rule.key ) }: ${ rule.value };`\n\t\t\t\t\t)\n\t\t\t\t\t.join( ' ' ) } }`\n\t\t\t);\n\t\t\treturn acc;\n\t\t},\n\t\t[]\n\t);\n\n\treturn selectorRules.join( '\\n' );\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 *\n * @return generated styles.\n */\nexport function getCSSRules(\n\tstyle: Style,\n\toptions: StyleOptions\n): GeneratedCSSRule[] {\n\tconst rules: GeneratedCSSRule[] = [];\n\tstyleDefinitions.forEach( ( definition: StyleDefinition ) => {\n\t\tif ( typeof definition.generate === 'function' ) {\n\t\t\trules.push( ...definition.generate( style, options ) );\n\t\t}\n\t} );\n\n\treturn rules;\n}\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("../utils");
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ const background = {
14
+ name: 'background',
15
+ generate: (style, options) => {
16
+ return (0, _utils.generateRule)(style, options, ['color', 'background'], 'backgroundColor');
17
+ }
18
+ };
19
+ var _default = background;
20
+ exports.default = _default;
21
+ //# sourceMappingURL=background.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/color/background.ts"],"names":["background","name","generate","style","options"],"mappings":";;;;;;;AAIA;;AAJA;AACA;AACA;AAIA,MAAMA,UAAU,GAAG;AAClBC,EAAAA,IAAI,EAAE,YADY;AAElBC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,yBACND,KADM,EAENC,OAFM,EAGN,CAAE,OAAF,EAAW,YAAX,CAHM,EAIN,iBAJM,CAAP;AAMA;AATiB,CAAnB;eAYeJ,U","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Style, StyleOptions } from '../../types';\nimport { generateRule } from '../utils';\n\nconst background = {\n\tname: 'background',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'color', 'background' ],\n\t\t\t'backgroundColor'\n\t\t);\n\t},\n};\n\nexport default background;\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("../utils");
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ const gradient = {
14
+ name: 'gradient',
15
+ generate: (style, options) => {
16
+ return (0, _utils.generateRule)(style, options, ['color', 'gradient'], 'background');
17
+ }
18
+ };
19
+ var _default = gradient;
20
+ exports.default = _default;
21
+ //# sourceMappingURL=gradient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/color/gradient.ts"],"names":["gradient","name","generate","style","options"],"mappings":";;;;;;;AAIA;;AAJA;AACA;AACA;AAIA,MAAMA,QAAQ,GAAG;AAChBC,EAAAA,IAAI,EAAE,UADU;AAEhBC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,yBACND,KADM,EAENC,OAFM,EAGN,CAAE,OAAF,EAAW,UAAX,CAHM,EAIN,YAJM,CAAP;AAMA;AATe,CAAjB;eAYeJ,Q","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Style, StyleOptions } from '../../types';\nimport { generateRule } from '../utils';\n\nconst gradient = {\n\tname: 'gradient',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'color', 'gradient' ],\n\t\t\t'background'\n\t\t);\n\t},\n};\n\nexport default gradient;\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _background = _interopRequireDefault(require("./background"));
11
+
12
+ var _gradient = _interopRequireDefault(require("./gradient"));
13
+
14
+ var _text = _interopRequireDefault(require("./text"));
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+ var _default = [_text.default, _gradient.default, _background.default];
20
+ exports.default = _default;
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/color/index.ts"],"names":["text","gradient","background"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;eAKe,CAAEA,aAAF,EAAQC,iBAAR,EAAkBC,mBAAlB,C","sourcesContent":["/**\n * Internal dependencies\n */\nimport background from './background';\nimport gradient from './gradient';\nimport text from './text';\n\nexport default [ text, gradient, background ];\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("../utils");
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ const text = {
14
+ name: 'text',
15
+ generate: (style, options) => {
16
+ return (0, _utils.generateRule)(style, options, ['color', 'text'], 'color');
17
+ }
18
+ };
19
+ var _default = text;
20
+ exports.default = _default;
21
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/color/text.ts"],"names":["text","name","generate","style","options"],"mappings":";;;;;;;AAIA;;AAJA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG;AACZC,EAAAA,IAAI,EAAE,MADM;AAEZC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,yBAAcD,KAAd,EAAqBC,OAArB,EAA8B,CAAE,OAAF,EAAW,MAAX,CAA9B,EAAmD,OAAnD,CAAP;AACA;AAJW,CAAb;eAOeJ,I","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Style, StyleOptions } from '../../types';\nimport { generateRule } from '../utils';\n\nconst text = {\n\tname: 'text',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule( style, options, [ 'color', 'text' ], 'color' );\n\t},\n};\n\nexport default text;\n"]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VARIABLE_REFERENCE_PREFIX = exports.VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = exports.VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = void 0;
7
+ const VARIABLE_REFERENCE_PREFIX = 'var:';
8
+ exports.VARIABLE_REFERENCE_PREFIX = VARIABLE_REFERENCE_PREFIX;
9
+ const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
10
+ exports.VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE;
11
+ const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
12
+ exports.VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = VARIABLE_PATH_SEPARATOR_TOKEN_STYLE;
13
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/constants.ts"],"names":["VARIABLE_REFERENCE_PREFIX","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE"],"mappings":";;;;;;AAAO,MAAMA,yBAAyB,GAAG,MAAlC;;AACA,MAAMC,uCAAuC,GAAG,GAAhD;;AACA,MAAMC,mCAAmC,GAAG,IAA5C","sourcesContent":["export const VARIABLE_REFERENCE_PREFIX = 'var:';\nexport const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';\nexport const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';\n"]}
@@ -7,13 +7,15 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.styleDefinitions = void 0;
9
9
 
10
- var _padding = _interopRequireDefault(require("./padding"));
10
+ var _color = _interopRequireDefault(require("./color"));
11
11
 
12
- var _margin = _interopRequireDefault(require("./margin"));
12
+ var _spacing = _interopRequireDefault(require("./spacing"));
13
+
14
+ var _typography = _interopRequireDefault(require("./typography"));
13
15
 
14
16
  /**
15
17
  * Internal dependencies
16
18
  */
17
- const styleDefinitions = [_margin.default, _padding.default];
19
+ const styleDefinitions = [..._color.default, ..._spacing.default, ..._typography.default];
18
20
  exports.styleDefinitions = styleDefinitions;
19
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/style-engine/src/styles/index.ts"],"names":["styleDefinitions","margin","padding"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIO,MAAMA,gBAAgB,GAAG,CAAEC,eAAF,EAAUC,gBAAV,CAAzB","sourcesContent":["/**\n * Internal dependencies\n */\nimport padding from './padding';\nimport margin from './margin';\n\nexport const styleDefinitions = [ margin, padding ];\n"]}
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/index.ts"],"names":["styleDefinitions","color","spacing","typography"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKO,MAAMA,gBAAgB,GAAG,CAAE,GAAGC,cAAL,EAAY,GAAGC,gBAAf,EAAwB,GAAGC,mBAA3B,CAAzB","sourcesContent":["/**\n * Internal dependencies\n */\nimport color from './color';\nimport spacing from './spacing';\nimport typography from './typography';\n\nexport const styleDefinitions = [ ...color, ...spacing, ...typography ];\n"]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _padding = _interopRequireDefault(require("./padding"));
11
+
12
+ var _margin = _interopRequireDefault(require("./margin"));
13
+
14
+ /**
15
+ * Internal dependencies
16
+ */
17
+ var _default = [_margin.default, _padding.default];
18
+ exports.default = _default;
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/spacing/index.ts"],"names":["margin","padding"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;eAIe,CAAEA,eAAF,EAAUC,gBAAV,C","sourcesContent":["/**\n * Internal dependencies\n */\nimport padding from './padding';\nimport margin from './margin';\n\nexport default [ margin, padding ];\n"]}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _utils = require("./utils");
8
+ var _utils = require("../utils");
9
9
 
10
10
  /**
11
11
  * Internal dependencies
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/spacing/margin.ts"],"names":["margin","name","generate","style","options"],"mappings":";;;;;;;AAIA;;AAJA;AACA;AACA;AAIA,MAAMA,MAAM,GAAG;AACdC,EAAAA,IAAI,EAAE,QADQ;AAEdC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,6BACND,KADM,EAENC,OAFM,EAGN,CAAE,SAAF,EAAa,QAAb,CAHM,EAIN,QAJM,CAAP;AAMA;AATa,CAAf;eAYeJ,M","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Style, StyleOptions } from '../../types';\nimport { generateBoxRules } from '../utils';\n\nconst margin = {\n\tname: 'margin',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateBoxRules(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'spacing', 'margin' ],\n\t\t\t'margin'\n\t\t);\n\t},\n};\n\nexport default margin;\n"]}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _utils = require("./utils");
8
+ var _utils = require("../utils");
9
9
 
10
10
  /**
11
11
  * Internal dependencies
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/spacing/padding.ts"],"names":["padding","name","generate","style","options"],"mappings":";;;;;;;AAIA;;AAJA;AACA;AACA;AAIA,MAAMA,OAAO,GAAG;AACfC,EAAAA,IAAI,EAAE,SADS;AAEfC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,6BACND,KADM,EAENC,OAFM,EAGN,CAAE,SAAF,EAAa,SAAb,CAHM,EAIN,SAJM,CAAP;AAMA;AATc,CAAhB;eAYeJ,O","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Style, StyleOptions } from '../../types';\nimport { generateBoxRules } from '../utils';\n\nconst padding = {\n\tname: 'padding',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateBoxRules(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'spacing', 'padding' ],\n\t\t\t'padding'\n\t\t);\n\t},\n};\n\nexport default padding;\n"]}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("../utils");
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ const fontSize = {
14
+ name: 'fontSize',
15
+ generate: (style, options) => {
16
+ return (0, _utils.generateRule)(style, options, ['typography', 'fontSize'], 'fontSize');
17
+ }
18
+ };
19
+ const fontStyle = {
20
+ name: 'fontStyle',
21
+ generate: (style, options) => {
22
+ return (0, _utils.generateRule)(style, options, ['typography', 'fontStyle'], 'fontStyle');
23
+ }
24
+ };
25
+ const fontWeight = {
26
+ name: 'fontWeight',
27
+ generate: (style, options) => {
28
+ return (0, _utils.generateRule)(style, options, ['typography', 'fontWeight'], 'fontWeight');
29
+ }
30
+ };
31
+ const letterSpacing = {
32
+ name: 'letterSpacing',
33
+ generate: (style, options) => {
34
+ return (0, _utils.generateRule)(style, options, ['typography', 'letterSpacing'], 'letterSpacing');
35
+ }
36
+ };
37
+ const lineHeight = {
38
+ name: 'letterSpacing',
39
+ generate: (style, options) => {
40
+ return (0, _utils.generateRule)(style, options, ['typography', 'lineHeight'], 'lineHeight');
41
+ }
42
+ };
43
+ const textDecoration = {
44
+ name: 'textDecoration',
45
+ generate: (style, options) => {
46
+ return (0, _utils.generateRule)(style, options, ['typography', 'textDecoration'], 'textDecoration');
47
+ }
48
+ };
49
+ const textTransform = {
50
+ name: 'textTransform',
51
+ generate: (style, options) => {
52
+ return (0, _utils.generateRule)(style, options, ['typography', 'textTransform'], 'textTransform');
53
+ }
54
+ };
55
+ var _default = [fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textDecoration, textTransform];
56
+ exports.default = _default;
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/typography/index.ts"],"names":["fontSize","name","generate","style","options","fontStyle","fontWeight","letterSpacing","lineHeight","textDecoration","textTransform"],"mappings":";;;;;;;AAIA;;AAJA;AACA;AACA;AAIA,MAAMA,QAAQ,GAAG;AAChBC,EAAAA,IAAI,EAAE,UADU;AAEhBC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,yBACND,KADM,EAENC,OAFM,EAGN,CAAE,YAAF,EAAgB,UAAhB,CAHM,EAIN,UAJM,CAAP;AAMA;AATe,CAAjB;AAYA,MAAMC,SAAS,GAAG;AACjBJ,EAAAA,IAAI,EAAE,WADW;AAEjBC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,yBACND,KADM,EAENC,OAFM,EAGN,CAAE,YAAF,EAAgB,WAAhB,CAHM,EAIN,WAJM,CAAP;AAMA;AATgB,CAAlB;AAYA,MAAME,UAAU,GAAG;AAClBL,EAAAA,IAAI,EAAE,YADY;AAElBC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,yBACND,KADM,EAENC,OAFM,EAGN,CAAE,YAAF,EAAgB,YAAhB,CAHM,EAIN,YAJM,CAAP;AAMA;AATiB,CAAnB;AAYA,MAAMG,aAAa,GAAG;AACrBN,EAAAA,IAAI,EAAE,eADe;AAErBC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,yBACND,KADM,EAENC,OAFM,EAGN,CAAE,YAAF,EAAgB,eAAhB,CAHM,EAIN,eAJM,CAAP;AAMA;AAToB,CAAtB;AAYA,MAAMI,UAAU,GAAG;AAClBP,EAAAA,IAAI,EAAE,eADY;AAElBC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,yBACND,KADM,EAENC,OAFM,EAGN,CAAE,YAAF,EAAgB,YAAhB,CAHM,EAIN,YAJM,CAAP;AAMA;AATiB,CAAnB;AAYA,MAAMK,cAAc,GAAG;AACtBR,EAAAA,IAAI,EAAE,gBADgB;AAEtBC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,yBACND,KADM,EAENC,OAFM,EAGN,CAAE,YAAF,EAAgB,gBAAhB,CAHM,EAIN,gBAJM,CAAP;AAMA;AATqB,CAAvB;AAYA,MAAMM,aAAa,GAAG;AACrBT,EAAAA,IAAI,EAAE,eADe;AAErBC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAO,yBACND,KADM,EAENC,OAFM,EAGN,CAAE,YAAF,EAAgB,eAAhB,CAHM,EAIN,eAJM,CAAP;AAMA;AAToB,CAAtB;eAYe,CACdJ,QADc,EAEdK,SAFc,EAGdC,UAHc,EAIdC,aAJc,EAKdC,UALc,EAMdC,cANc,EAOdC,aAPc,C","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Style, StyleOptions } from '../../types';\nimport { generateRule } from '../utils';\n\nconst fontSize = {\n\tname: 'fontSize',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'fontSize' ],\n\t\t\t'fontSize'\n\t\t);\n\t},\n};\n\nconst fontStyle = {\n\tname: 'fontStyle',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'fontStyle' ],\n\t\t\t'fontStyle'\n\t\t);\n\t},\n};\n\nconst fontWeight = {\n\tname: 'fontWeight',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'fontWeight' ],\n\t\t\t'fontWeight'\n\t\t);\n\t},\n};\n\nconst letterSpacing = {\n\tname: 'letterSpacing',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'letterSpacing' ],\n\t\t\t'letterSpacing'\n\t\t);\n\t},\n};\n\nconst lineHeight = {\n\tname: 'letterSpacing',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'lineHeight' ],\n\t\t\t'lineHeight'\n\t\t);\n\t},\n};\n\nconst textDecoration = {\n\tname: 'textDecoration',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'textDecoration' ],\n\t\t\t'textDecoration'\n\t\t);\n\t},\n};\n\nconst textTransform = {\n\tname: 'textTransform',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'textTransform' ],\n\t\t\t'textTransform'\n\t\t);\n\t},\n};\n\nexport default [\n\tfontSize,\n\tfontStyle,\n\tfontWeight,\n\tletterSpacing,\n\tlineHeight,\n\ttextDecoration,\n\ttextTransform,\n];\n"]}
@@ -4,12 +4,47 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.generateBoxRules = generateBoxRules;
7
+ exports.generateRule = generateRule;
8
+ exports.getCSSVarFromStyleValue = getCSSVarFromStyleValue;
7
9
 
8
10
  var _lodash = require("lodash");
9
11
 
12
+ var _constants = require("./constants");
13
+
10
14
  /**
11
15
  * External dependencies
12
16
  */
17
+
18
+ /**
19
+ * Returns a JSON representation of the generated CSS rules.
20
+ *
21
+ * @param style Style object.
22
+ * @param options Options object with settings to adjust how the styles are generated.
23
+ * @param path An array of strings representing the path to the style value in the style object.
24
+ * @param ruleKey A CSS property key.
25
+ *
26
+ * @return GeneratedCSSRule[] CSS rules.
27
+ */
28
+ function generateRule(style, options, path, ruleKey) {
29
+ const styleValue = (0, _lodash.get)(style, path);
30
+ return styleValue ? [{
31
+ selector: options === null || options === void 0 ? void 0 : options.selector,
32
+ key: ruleKey,
33
+ value: getCSSVarFromStyleValue(styleValue)
34
+ }] : [];
35
+ }
36
+ /**
37
+ * Returns a JSON representation of the generated CSS rules taking into account box model properties, top, right, bottom, left.
38
+ *
39
+ * @param style Style object.
40
+ * @param options Options object with settings to adjust how the styles are generated.
41
+ * @param path An array of strings representing the path to the style value in the style object.
42
+ * @param ruleKey A CSS property key.
43
+ *
44
+ * @return GeneratedCSSRule[] CSS rules.
45
+ */
46
+
47
+
13
48
  function generateBoxRules(style, options, path, ruleKey) {
14
49
  const boxStyle = (0, _lodash.get)(style, path);
15
50
 
@@ -21,7 +56,7 @@ function generateBoxRules(style, options, path, ruleKey) {
21
56
 
22
57
  if (typeof boxStyle === 'string') {
23
58
  rules.push({
24
- selector: options.selector,
59
+ selector: options === null || options === void 0 ? void 0 : options.selector,
25
60
  key: ruleKey,
26
61
  value: boxStyle
27
62
  });
@@ -31,7 +66,7 @@ function generateBoxRules(style, options, path, ruleKey) {
31
66
 
32
67
  if (value) {
33
68
  acc.push({
34
- selector: options.selector,
69
+ selector: options === null || options === void 0 ? void 0 : options.selector,
35
70
  key: `${ruleKey}${(0, _lodash.upperFirst)(side)}`,
36
71
  value
37
72
  });
@@ -44,4 +79,21 @@ function generateBoxRules(style, options, path, ruleKey) {
44
79
 
45
80
  return rules;
46
81
  }
82
+ /**
83
+ * Returns a CSS var value from incoming style value following the pattern `var:description|context|slug`.
84
+ *
85
+ * @param styleValue A raw style value.
86
+ *
87
+ * @return string A CSS var value.
88
+ */
89
+
90
+
91
+ function getCSSVarFromStyleValue(styleValue) {
92
+ if (typeof styleValue === 'string' && styleValue.startsWith(_constants.VARIABLE_REFERENCE_PREFIX)) {
93
+ const variable = styleValue.slice(_constants.VARIABLE_REFERENCE_PREFIX.length).split(_constants.VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(_constants.VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
94
+ return `var(--wp--${variable})`;
95
+ }
96
+
97
+ return styleValue;
98
+ }
47
99
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/style-engine/src/styles/utils.ts"],"names":["generateBoxRules","style","options","path","ruleKey","boxStyle","rules","push","selector","key","value","sideRules","reduce","acc","side"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAQO,SAASA,gBAAT,CACNC,KADM,EAENC,OAFM,EAGNC,IAHM,EAINC,OAJM,EAKe;AACrB,QAAMC,QAAkC,GAAG,iBAAKJ,KAAL,EAAYE,IAAZ,CAA3C;;AACA,MAAK,CAAEE,QAAP,EAAkB;AACjB,WAAO,EAAP;AACA;;AAED,QAAMC,KAAyB,GAAG,EAAlC;;AACA,MAAK,OAAOD,QAAP,KAAoB,QAAzB,EAAoC;AACnCC,IAAAA,KAAK,CAACC,IAAN,CAAY;AACXC,MAAAA,QAAQ,EAAEN,OAAO,CAACM,QADP;AAEXC,MAAAA,GAAG,EAAEL,OAFM;AAGXM,MAAAA,KAAK,EAAEL;AAHI,KAAZ;AAKA,GAND,MAMO;AACN,UAAMM,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,EAAqCC,MAArC,CACjB,CAAEC,GAAF,EAA2BC,IAA3B,KAA6C;AAC5C,YAAMJ,KAAyB,GAAG,iBAAKL,QAAL,EAAe,CAAES,IAAF,CAAf,CAAlC;;AACA,UAAKJ,KAAL,EAAa;AACZG,QAAAA,GAAG,CAACN,IAAJ,CAAU;AACTC,UAAAA,QAAQ,EAAEN,OAAO,CAACM,QADT;AAETC,UAAAA,GAAG,EAAG,GAAGL,OAAS,GAAG,wBAAYU,IAAZ,CAAoB,EAFhC;AAGTJ,UAAAA;AAHS,SAAV;AAKA;;AACD,aAAOG,GAAP;AACA,KAXgB,EAYjB,EAZiB,CAAlB;AAcAP,IAAAA,KAAK,CAACC,IAAN,CAAY,GAAGI,SAAf;AACA;;AAED,SAAOL,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, upperFirst } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport type { GeneratedCSSRule, Style, Box, StyleOptions } from '../types';\n\nexport function generateBoxRules(\n\tstyle: Style,\n\toptions: StyleOptions,\n\tpath: string[],\n\truleKey: string\n): GeneratedCSSRule[] {\n\tconst boxStyle: Box | string | undefined = get( style, path );\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: ruleKey,\n\t\t\tvalue: boxStyle,\n\t\t} );\n\t} else {\n\t\tconst sideRules = [ 'top', 'right', 'bottom', 'left' ].reduce(\n\t\t\t( acc: GeneratedCSSRule[], side: string ) => {\n\t\t\t\tconst value: string | undefined = get( boxStyle, [ side ] );\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: `${ ruleKey }${ upperFirst( side ) }`,\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"]}
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/utils.ts"],"names":["generateRule","style","options","path","ruleKey","styleValue","selector","key","value","getCSSVarFromStyleValue","generateBoxRules","boxStyle","rules","push","sideRules","reduce","acc","side","startsWith","VARIABLE_REFERENCE_PREFIX","variable","slice","length","split","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","join","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAT,CACNC,KADM,EAENC,OAFM,EAGNC,IAHM,EAINC,OAJM,EAKL;AACD,QAAMC,UAA8B,GAAG,iBAAKJ,KAAL,EAAYE,IAAZ,CAAvC;AAEA,SAAOE,UAAU,GACd,CACA;AACCC,IAAAA,QAAQ,EAAEJ,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI,QADpB;AAECC,IAAAA,GAAG,EAAEH,OAFN;AAGCI,IAAAA,KAAK,EAAEC,uBAAuB,CAAEJ,UAAF;AAH/B,GADA,CADc,GAQd,EARH;AASA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,gBAAT,CACNT,KADM,EAENC,OAFM,EAGNC,IAHM,EAINC,OAJM,EAKe;AACrB,QAAMO,QAAkC,GAAG,iBAAKV,KAAL,EAAYE,IAAZ,CAA3C;;AACA,MAAK,CAAEQ,QAAP,EAAkB;AACjB,WAAO,EAAP;AACA;;AAED,QAAMC,KAAyB,GAAG,EAAlC;;AACA,MAAK,OAAOD,QAAP,KAAoB,QAAzB,EAAoC;AACnCC,IAAAA,KAAK,CAACC,IAAN,CAAY;AACXP,MAAAA,QAAQ,EAAEJ,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI,QADR;AAEXC,MAAAA,GAAG,EAAEH,OAFM;AAGXI,MAAAA,KAAK,EAAEG;AAHI,KAAZ;AAKA,GAND,MAMO;AACN,UAAMG,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,EAAqCC,MAArC,CACjB,CAAEC,GAAF,EAA2BC,IAA3B,KAA6C;AAC5C,YAAMT,KAAyB,GAAG,iBAAKG,QAAL,EAAe,CAAEM,IAAF,CAAf,CAAlC;;AACA,UAAKT,KAAL,EAAa;AACZQ,QAAAA,GAAG,CAACH,IAAJ,CAAU;AACTP,UAAAA,QAAQ,EAAEJ,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI,QADV;AAETC,UAAAA,GAAG,EAAG,GAAGH,OAAS,GAAG,wBAAYa,IAAZ,CAAoB,EAFhC;AAGTT,UAAAA;AAHS,SAAV;AAKA;;AACD,aAAOQ,GAAP;AACA,KAXgB,EAYjB,EAZiB,CAAlB;AAcAJ,IAAAA,KAAK,CAACC,IAAN,CAAY,GAAGC,SAAf;AACA;;AAED,SAAOF,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASH,uBAAT,CAAkCJ,UAAlC,EAA+D;AACrE,MACC,OAAOA,UAAP,KAAsB,QAAtB,IACAA,UAAU,CAACa,UAAX,CAAuBC,oCAAvB,CAFD,EAGE;AACD,UAAMC,QAAQ,GAAGf,UAAU,CACzBgB,KADe,CACRF,qCAA0BG,MADlB,EAEfC,KAFe,CAERC,kDAFQ,EAGfC,IAHe,CAGTC,8CAHS,CAAjB;AAIA,WAAQ,aAAaN,QAAU,GAA/B;AACA;;AACD,SAAOf,UAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, upperFirst } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport type { GeneratedCSSRule, Style, Box, StyleOptions } 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 * 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) {\n\tconst styleValue: string | undefined = get( 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 ruleKey A CSS property key.\n *\n * @return GeneratedCSSRule[] CSS rules.\n */\nexport function generateBoxRules(\n\tstyle: Style,\n\toptions: StyleOptions,\n\tpath: string[],\n\truleKey: string\n): GeneratedCSSRule[] {\n\tconst boxStyle: Box | string | undefined = get( style, path );\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: ruleKey,\n\t\t\tvalue: boxStyle,\n\t\t} );\n\t} else {\n\t\tconst sideRules = [ 'top', 'right', 'bottom', 'left' ].reduce(\n\t\t\t( acc: GeneratedCSSRule[], side: string ) => {\n\t\t\t\tconst value: string | undefined = get( boxStyle, [ side ] );\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: `${ ruleKey }${ upperFirst( side ) }`,\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.join( VARIABLE_PATH_SEPARATOR_TOKEN_STYLE );\n\t\treturn `var(--wp--${ variable })`;\n\t}\n\treturn styleValue;\n}\n"]}
@@ -17,7 +17,16 @@ import { styleDefinitions } from './styles';
17
17
  */
18
18
 
19
19
  export function generate(style, options) {
20
- const rules = getCSSRules(style, options);
20
+ const rules = getCSSRules(style, options); // If no selector is provided, treat generated rules as inline styles to be returned as a single string.
21
+
22
+ if (!(options !== null && options !== void 0 && options.selector)) {
23
+ const inlineRules = [];
24
+ rules.forEach(rule => {
25
+ inlineRules.push(`${kebabCase(rule.key)}: ${rule.value};`);
26
+ });
27
+ return inlineRules.join(' ');
28
+ }
29
+
21
30
  const groupedRules = groupBy(rules, 'selector');
22
31
  const selectorRules = Object.keys(groupedRules).reduce((acc, subSelector) => {
23
32
  acc.push(`${subSelector} { ${groupedRules[subSelector].map(rule => `${kebabCase(rule.key)}: ${rule.value};`).join(' ')} }`);
@@ -37,7 +46,9 @@ export function generate(style, options) {
37
46
  export function getCSSRules(style, options) {
38
47
  const rules = [];
39
48
  styleDefinitions.forEach(definition => {
40
- rules.push(...definition.generate(style, options));
49
+ if (typeof definition.generate === 'function') {
50
+ rules.push(...definition.generate(style, options));
51
+ }
41
52
  });
42
53
  return rules;
43
54
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/style-engine/src/index.ts"],"names":["groupBy","kebabCase","styleDefinitions","generate","style","options","rules","getCSSRules","groupedRules","selectorRules","Object","keys","reduce","acc","subSelector","push","map","rule","key","value","join","forEach","definition"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,SAAlB,QAAmC,QAAnC;AAEA;AACA;AACA;;AAOA,SAASC,gBAAT,QAAiC,UAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,QAAT,CAAmBC,KAAnB,EAAiCC,OAAjC,EAAiE;AACvE,QAAMC,KAAK,GAAGC,WAAW,CAAEH,KAAF,EAASC,OAAT,CAAzB;AACA,QAAMG,YAAY,GAAGR,OAAO,CAAEM,KAAF,EAAS,UAAT,CAA5B;AACA,QAAMG,aAAa,GAAGC,MAAM,CAACC,IAAP,CAAaH,YAAb,EAA4BI,MAA5B,CACrB,CAAEC,GAAF,EAAiBC,WAAjB,KAA0C;AACzCD,IAAAA,GAAG,CAACE,IAAJ,CACE,GAAGD,WAAa,MAAMN,YAAY,CAAEM,WAAF,CAAZ,CACrBE,GADqB,CAEnBC,IAAF,IACE,GAAGhB,SAAS,CAAEgB,IAAI,CAACC,GAAP,CAAc,KAAKD,IAAI,CAACE,KAAO,GAHxB,EAKrBC,IALqB,CAKf,GALe,CAKR,IANhB;AAQA,WAAOP,GAAP;AACA,GAXoB,EAYrB,EAZqB,CAAtB;AAeA,SAAOJ,aAAa,CAACW,IAAd,CAAoB,IAApB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASb,WAAT,CACNH,KADM,EAENC,OAFM,EAGe;AACrB,QAAMC,KAAyB,GAAG,EAAlC;AACAJ,EAAAA,gBAAgB,CAACmB,OAAjB,CAA4BC,UAAF,IAAmC;AAC5DhB,IAAAA,KAAK,CAACS,IAAN,CAAY,GAAGO,UAAU,CAACnB,QAAX,CAAqBC,KAArB,EAA4BC,OAA5B,CAAf;AACA,GAFD;AAIA,SAAOC,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { groupBy, kebabCase } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tStyle,\n\tStyleOptions,\n\tGeneratedCSSRule,\n\tStyleDefinition,\n} from './types';\nimport { styleDefinitions } from './styles';\n\n/**\n * Generates a stylesheet for a given style object and selector.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n *\n * @return generated stylesheet.\n */\nexport function generate( style: Style, options: StyleOptions ): string {\n\tconst rules = getCSSRules( style, options );\n\tconst groupedRules = groupBy( rules, 'selector' );\n\tconst selectorRules = Object.keys( groupedRules ).reduce(\n\t\t( acc: string[], subSelector: string ) => {\n\t\t\tacc.push(\n\t\t\t\t`${ subSelector } { ${ groupedRules[ subSelector ]\n\t\t\t\t\t.map(\n\t\t\t\t\t\t( rule: GeneratedCSSRule ) =>\n\t\t\t\t\t\t\t`${ kebabCase( rule.key ) }: ${ rule.value };`\n\t\t\t\t\t)\n\t\t\t\t\t.join( ' ' ) } }`\n\t\t\t);\n\t\t\treturn acc;\n\t\t},\n\t\t[]\n\t);\n\n\treturn selectorRules.join( '\\n' );\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 *\n * @return generated styles.\n */\nexport function getCSSRules(\n\tstyle: Style,\n\toptions: StyleOptions\n): GeneratedCSSRule[] {\n\tconst rules: GeneratedCSSRule[] = [];\n\tstyleDefinitions.forEach( ( definition: StyleDefinition ) => {\n\t\trules.push( ...definition.generate( style, options ) );\n\t} );\n\n\treturn rules;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/style-engine/src/index.ts"],"names":["groupBy","kebabCase","styleDefinitions","generate","style","options","rules","getCSSRules","selector","inlineRules","forEach","rule","push","key","value","join","groupedRules","selectorRules","Object","keys","reduce","acc","subSelector","map","definition"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,SAAlB,QAAmC,QAAnC;AAEA;AACA;AACA;;AAOA,SAASC,gBAAT,QAAiC,UAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,QAAT,CAAmBC,KAAnB,EAAiCC,OAAjC,EAAiE;AACvE,QAAMC,KAAK,GAAGC,WAAW,CAAEH,KAAF,EAASC,OAAT,CAAzB,CADuE,CAGvE;;AACA,MAAK,EAAEA,OAAF,aAAEA,OAAF,eAAEA,OAAO,CAAEG,QAAX,CAAL,EAA2B;AAC1B,UAAMC,WAAqB,GAAG,EAA9B;AACAH,IAAAA,KAAK,CAACI,OAAN,CAAiBC,IAAF,IAAY;AAC1BF,MAAAA,WAAW,CAACG,IAAZ,CAAmB,GAAGX,SAAS,CAAEU,IAAI,CAACE,GAAP,CAAc,KAAKF,IAAI,CAACG,KAAO,GAA9D;AACA,KAFD;AAGA,WAAOL,WAAW,CAACM,IAAZ,CAAkB,GAAlB,CAAP;AACA;;AAED,QAAMC,YAAY,GAAGhB,OAAO,CAAEM,KAAF,EAAS,UAAT,CAA5B;AACA,QAAMW,aAAa,GAAGC,MAAM,CAACC,IAAP,CAAaH,YAAb,EAA4BI,MAA5B,CACrB,CAAEC,GAAF,EAAiBC,WAAjB,KAA0C;AACzCD,IAAAA,GAAG,CAACT,IAAJ,CACE,GAAGU,WAAa,MAAMN,YAAY,CAAEM,WAAF,CAAZ,CACrBC,GADqB,CAEnBZ,IAAF,IACE,GAAGV,SAAS,CAAEU,IAAI,CAACE,GAAP,CAAc,KAAKF,IAAI,CAACG,KAAO,GAHxB,EAKrBC,IALqB,CAKf,GALe,CAKR,IANhB;AAQA,WAAOM,GAAP;AACA,GAXoB,EAYrB,EAZqB,CAAtB;AAeA,SAAOJ,aAAa,CAACF,IAAd,CAAoB,IAApB,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASR,WAAT,CACNH,KADM,EAENC,OAFM,EAGe;AACrB,QAAMC,KAAyB,GAAG,EAAlC;AACAJ,EAAAA,gBAAgB,CAACQ,OAAjB,CAA4Bc,UAAF,IAAmC;AAC5D,QAAK,OAAOA,UAAU,CAACrB,QAAlB,KAA+B,UAApC,EAAiD;AAChDG,MAAAA,KAAK,CAACM,IAAN,CAAY,GAAGY,UAAU,CAACrB,QAAX,CAAqBC,KAArB,EAA4BC,OAA5B,CAAf;AACA;AACD,GAJD;AAMA,SAAOC,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { groupBy, kebabCase } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tStyle,\n\tStyleOptions,\n\tGeneratedCSSRule,\n\tStyleDefinition,\n} from './types';\nimport { styleDefinitions } from './styles';\n\n/**\n * Generates a stylesheet for a given style object and selector.\n *\n * @param style Style object.\n * @param options Options object with settings to adjust how the styles are generated.\n *\n * @return generated stylesheet.\n */\nexport function generate( style: Style, options: StyleOptions ): string {\n\tconst rules = getCSSRules( style, options );\n\n\t// If no selector is provided, treat generated rules as inline styles to be returned as a single string.\n\tif ( ! options?.selector ) {\n\t\tconst inlineRules: string[] = [];\n\t\trules.forEach( ( rule ) => {\n\t\t\tinlineRules.push( `${ kebabCase( rule.key ) }: ${ rule.value };` );\n\t\t} );\n\t\treturn inlineRules.join( ' ' );\n\t}\n\n\tconst groupedRules = groupBy( rules, 'selector' );\n\tconst selectorRules = Object.keys( groupedRules ).reduce(\n\t\t( acc: string[], subSelector: string ) => {\n\t\t\tacc.push(\n\t\t\t\t`${ subSelector } { ${ groupedRules[ subSelector ]\n\t\t\t\t\t.map(\n\t\t\t\t\t\t( rule: GeneratedCSSRule ) =>\n\t\t\t\t\t\t\t`${ kebabCase( rule.key ) }: ${ rule.value };`\n\t\t\t\t\t)\n\t\t\t\t\t.join( ' ' ) } }`\n\t\t\t);\n\t\t\treturn acc;\n\t\t},\n\t\t[]\n\t);\n\n\treturn selectorRules.join( '\\n' );\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 *\n * @return generated styles.\n */\nexport function getCSSRules(\n\tstyle: Style,\n\toptions: StyleOptions\n): GeneratedCSSRule[] {\n\tconst rules: GeneratedCSSRule[] = [];\n\tstyleDefinitions.forEach( ( definition: StyleDefinition ) => {\n\t\tif ( typeof definition.generate === 'function' ) {\n\t\t\trules.push( ...definition.generate( style, options ) );\n\t\t}\n\t} );\n\n\treturn rules;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { generateRule } from '../utils';
5
+ const background = {
6
+ name: 'background',
7
+ generate: (style, options) => {
8
+ return generateRule(style, options, ['color', 'background'], 'backgroundColor');
9
+ }
10
+ };
11
+ export default background;
12
+ //# sourceMappingURL=background.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/color/background.ts"],"names":["generateRule","background","name","generate","style","options"],"mappings":"AAAA;AACA;AACA;AAEA,SAASA,YAAT,QAA6B,UAA7B;AAEA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,IAAI,EAAE,YADY;AAElBC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAOL,YAAY,CAClBI,KADkB,EAElBC,OAFkB,EAGlB,CAAE,OAAF,EAAW,YAAX,CAHkB,EAIlB,iBAJkB,CAAnB;AAMA;AATiB,CAAnB;AAYA,eAAeJ,UAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Style, StyleOptions } from '../../types';\nimport { generateRule } from '../utils';\n\nconst background = {\n\tname: 'background',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'color', 'background' ],\n\t\t\t'backgroundColor'\n\t\t);\n\t},\n};\n\nexport default background;\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { generateRule } from '../utils';
5
+ const gradient = {
6
+ name: 'gradient',
7
+ generate: (style, options) => {
8
+ return generateRule(style, options, ['color', 'gradient'], 'background');
9
+ }
10
+ };
11
+ export default gradient;
12
+ //# sourceMappingURL=gradient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/color/gradient.ts"],"names":["generateRule","gradient","name","generate","style","options"],"mappings":"AAAA;AACA;AACA;AAEA,SAASA,YAAT,QAA6B,UAA7B;AAEA,MAAMC,QAAQ,GAAG;AAChBC,EAAAA,IAAI,EAAE,UADU;AAEhBC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAOL,YAAY,CAClBI,KADkB,EAElBC,OAFkB,EAGlB,CAAE,OAAF,EAAW,UAAX,CAHkB,EAIlB,YAJkB,CAAnB;AAMA;AATe,CAAjB;AAYA,eAAeJ,QAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Style, StyleOptions } from '../../types';\nimport { generateRule } from '../utils';\n\nconst gradient = {\n\tname: 'gradient',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'color', 'gradient' ],\n\t\t\t'background'\n\t\t);\n\t},\n};\n\nexport default gradient;\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import background from './background';
5
+ import gradient from './gradient';
6
+ import text from './text';
7
+ export default [text, gradient, background];
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/color/index.ts"],"names":["background","gradient","text"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,cAAvB;AACA,OAAOC,QAAP,MAAqB,YAArB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,eAAe,CAAEA,IAAF,EAAQD,QAAR,EAAkBD,UAAlB,CAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport background from './background';\nimport gradient from './gradient';\nimport text from './text';\n\nexport default [ text, gradient, background ];\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { generateRule } from '../utils';
5
+ const text = {
6
+ name: 'text',
7
+ generate: (style, options) => {
8
+ return generateRule(style, options, ['color', 'text'], 'color');
9
+ }
10
+ };
11
+ export default text;
12
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/color/text.ts"],"names":["generateRule","text","name","generate","style","options"],"mappings":"AAAA;AACA;AACA;AAEA,SAASA,YAAT,QAA6B,UAA7B;AAEA,MAAMC,IAAI,GAAG;AACZC,EAAAA,IAAI,EAAE,MADM;AAEZC,EAAAA,QAAQ,EAAE,CAAEC,KAAF,EAAgBC,OAAhB,KAA2C;AACpD,WAAOL,YAAY,CAAEI,KAAF,EAASC,OAAT,EAAkB,CAAE,OAAF,EAAW,MAAX,CAAlB,EAAuC,OAAvC,CAAnB;AACA;AAJW,CAAb;AAOA,eAAeJ,IAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Style, StyleOptions } from '../../types';\nimport { generateRule } from '../utils';\n\nconst text = {\n\tname: 'text',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule( style, options, [ 'color', 'text' ], 'color' );\n\t},\n};\n\nexport default text;\n"]}
@@ -0,0 +1,4 @@
1
+ export const VARIABLE_REFERENCE_PREFIX = 'var:';
2
+ export const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
3
+ export const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
4
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/constants.ts"],"names":["VARIABLE_REFERENCE_PREFIX","VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE","VARIABLE_PATH_SEPARATOR_TOKEN_STYLE"],"mappings":"AAAA,OAAO,MAAMA,yBAAyB,GAAG,MAAlC;AACP,OAAO,MAAMC,uCAAuC,GAAG,GAAhD;AACP,OAAO,MAAMC,mCAAmC,GAAG,IAA5C","sourcesContent":["export const VARIABLE_REFERENCE_PREFIX = 'var:';\nexport const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';\nexport const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';\n"]}
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import padding from './padding';
5
- import margin from './margin';
6
- export const styleDefinitions = [margin, padding];
4
+ import color from './color';
5
+ import spacing from './spacing';
6
+ import typography from './typography';
7
+ export const styleDefinitions = [...color, ...spacing, ...typography];
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/style-engine/src/styles/index.ts"],"names":["padding","margin","styleDefinitions"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,OAAP,MAAoB,WAApB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,OAAO,MAAMC,gBAAgB,GAAG,CAAED,MAAF,EAAUD,OAAV,CAAzB","sourcesContent":["/**\n * Internal dependencies\n */\nimport padding from './padding';\nimport margin from './margin';\n\nexport const styleDefinitions = [ margin, padding ];\n"]}
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/index.ts"],"names":["color","spacing","typography","styleDefinitions"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,KAAP,MAAkB,SAAlB;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,OAAO,MAAMC,gBAAgB,GAAG,CAAE,GAAGH,KAAL,EAAY,GAAGC,OAAf,EAAwB,GAAGC,UAA3B,CAAzB","sourcesContent":["/**\n * Internal dependencies\n */\nimport color from './color';\nimport spacing from './spacing';\nimport typography from './typography';\n\nexport const styleDefinitions = [ ...color, ...spacing, ...typography ];\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import padding from './padding';
5
+ import margin from './margin';
6
+ export default [margin, padding];
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/style-engine/src/styles/spacing/index.ts"],"names":["padding","margin"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,OAAP,MAAoB,WAApB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,eAAe,CAAEA,MAAF,EAAUD,OAAV,CAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport padding from './padding';\nimport margin from './margin';\n\nexport default [ margin, padding ];\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import { generateBoxRules } from './utils';
4
+ import { generateBoxRules } from '../utils';
5
5
  const margin = {
6
6
  name: 'margin',
7
7
  generate: (style, options) => {