@wordpress/style-engine 2.32.0 → 2.32.1-next.47f435fc9.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 (73) hide show
  1. package/build/index.js +62 -69
  2. package/build/index.js.map +7 -1
  3. package/build/styles/background/index.js +76 -34
  4. package/build/styles/background/index.js.map +7 -1
  5. package/build/styles/border/index.js +61 -48
  6. package/build/styles/border/index.js.map +7 -1
  7. package/build/styles/color/background.js +31 -13
  8. package/build/styles/color/background.js.map +7 -1
  9. package/build/styles/color/gradient.js +31 -13
  10. package/build/styles/color/gradient.js.map +7 -1
  11. package/build/styles/color/index.js +36 -13
  12. package/build/styles/color/index.js.map +7 -1
  13. package/build/styles/color/text.js +26 -13
  14. package/build/styles/color/text.js.map +7 -1
  15. package/build/styles/constants.js +33 -8
  16. package/build/styles/constants.js.map +7 -1
  17. package/build/styles/dimensions/index.js +38 -15
  18. package/build/styles/dimensions/index.js.map +7 -1
  19. package/build/styles/index.js +54 -19
  20. package/build/styles/index.js.map +7 -1
  21. package/build/styles/outline/index.js +36 -23
  22. package/build/styles/outline/index.js.map +7 -1
  23. package/build/styles/shadow/index.js +26 -13
  24. package/build/styles/shadow/index.js.map +7 -1
  25. package/build/styles/spacing/index.js +35 -12
  26. package/build/styles/spacing/index.js.map +7 -1
  27. package/build/styles/spacing/margin.js +28 -15
  28. package/build/styles/spacing/margin.js.map +7 -1
  29. package/build/styles/spacing/padding.js +28 -15
  30. package/build/styles/spacing/padding.js.map +7 -1
  31. package/build/styles/typography/index.js +105 -31
  32. package/build/styles/typography/index.js.map +7 -1
  33. package/build/styles/utils.js +90 -132
  34. package/build/styles/utils.js.map +7 -1
  35. package/build/types.js +16 -5
  36. package/build/types.js.map +7 -1
  37. package/build-module/index.js +40 -61
  38. package/build-module/index.js.map +7 -1
  39. package/build-module/styles/background/index.js +58 -30
  40. package/build-module/styles/background/index.js.map +7 -1
  41. package/build-module/styles/border/index.js +42 -44
  42. package/build-module/styles/border/index.js.map +7 -1
  43. package/build-module/styles/color/background.js +13 -9
  44. package/build-module/styles/color/background.js.map +7 -1
  45. package/build-module/styles/color/gradient.js +13 -9
  46. package/build-module/styles/color/gradient.js.map +7 -1
  47. package/build-module/styles/color/index.js +8 -8
  48. package/build-module/styles/color/index.js.map +7 -1
  49. package/build-module/styles/color/text.js +8 -9
  50. package/build-module/styles/color/text.js.map +7 -1
  51. package/build-module/styles/constants.js +9 -4
  52. package/build-module/styles/constants.js.map +7 -1
  53. package/build-module/styles/dimensions/index.js +20 -11
  54. package/build-module/styles/dimensions/index.js.map +7 -1
  55. package/build-module/styles/index.js +22 -13
  56. package/build-module/styles/index.js.map +7 -1
  57. package/build-module/styles/outline/index.js +14 -15
  58. package/build-module/styles/outline/index.js.map +7 -1
  59. package/build-module/styles/shadow/index.js +8 -9
  60. package/build-module/styles/shadow/index.js.map +7 -1
  61. package/build-module/styles/spacing/index.js +7 -7
  62. package/build-module/styles/spacing/index.js.map +7 -1
  63. package/build-module/styles/spacing/margin.js +10 -11
  64. package/build-module/styles/spacing/margin.js.map +7 -1
  65. package/build-module/styles/spacing/padding.js +10 -11
  66. package/build-module/styles/spacing/padding.js.map +7 -1
  67. package/build-module/styles/typography/index.js +87 -27
  68. package/build-module/styles/typography/index.js.map +7 -1
  69. package/build-module/styles/utils.js +72 -128
  70. package/build-module/styles/utils.js.map +7 -1
  71. package/build-module/types.js +1 -2
  72. package/build-module/types.js.map +7 -1
  73. package/package.json +10 -3
@@ -1,22 +1,35 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var padding_exports = {};
20
+ __export(padding_exports, {
21
+ default: () => padding_default
5
22
  });
6
- exports.default = void 0;
7
- var _utils = require("../utils");
8
- /**
9
- * Internal dependencies
10
- */
11
-
23
+ module.exports = __toCommonJS(padding_exports);
24
+ var import_utils = require("../utils");
12
25
  const padding = {
13
- name: 'padding',
26
+ name: "padding",
14
27
  generate: (style, options) => {
15
- return (0, _utils.generateBoxRules)(style, options, ['spacing', 'padding'], {
16
- default: 'padding',
17
- individual: 'padding%s'
28
+ return (0, import_utils.generateBoxRules)(style, options, ["spacing", "padding"], {
29
+ default: "padding",
30
+ individual: "padding%s"
18
31
  });
19
32
  }
20
33
  };
21
- var _default = exports.default = padding;
22
- //# sourceMappingURL=padding.js.map
34
+ var padding_default = padding;
35
+ //# sourceMappingURL=padding.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_utils","require","padding","name","generate","style","options","generateBoxRules","default","individual","_default","exports"],"sources":["@wordpress/style-engine/src/styles/spacing/padding.ts"],"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( style, options, [ 'spacing', 'padding' ], {\n\t\t\tdefault: 'padding',\n\t\t\tindividual: 'padding%s',\n\t\t} );\n\t},\n};\n\nexport default padding;\n"],"mappings":";;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA,MAAMC,OAAO,GAAG;EACfC,IAAI,EAAE,SAAS;EACfC,QAAQ,EAAEA,CAAEC,KAAY,EAAEC,OAAqB,KAAM;IACpD,OAAO,IAAAC,uBAAgB,EAAEF,KAAK,EAAEC,OAAO,EAAE,CAAE,SAAS,EAAE,SAAS,CAAE,EAAE;MAClEE,OAAO,EAAE,SAAS;MAClBC,UAAU,EAAE;IACb,CAAE,CAAC;EACJ;AACD,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAH,OAAA,GAEaN,OAAO","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/styles/spacing/padding.ts"],
4
+ "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( style, options, [ 'spacing', 'padding' ], {\n\t\t\tdefault: 'padding',\n\t\t\tindividual: 'padding%s',\n\t\t} );\n\t},\n};\n\nexport default padding;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAAiC;AAEjC,MAAM,UAAU;AAAA,EACf,MAAM;AAAA,EACN,UAAU,CAAE,OAAc,YAA2B;AACpD,eAAO,+BAAkB,OAAO,SAAS,CAAE,WAAW,SAAU,GAAG;AAAA,MAClE,SAAS;AAAA,MACT,YAAY;AAAA,IACb,CAAE;AAAA,EACH;AACD;AAEA,IAAO,kBAAQ;",
6
+ "names": []
7
+ }
@@ -1,73 +1,147 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var typography_exports = {};
20
+ __export(typography_exports, {
21
+ default: () => typography_default
5
22
  });
6
- exports.default = void 0;
7
- var _utils = require("../utils");
8
- /**
9
- * Internal dependencies
10
- */
11
-
23
+ module.exports = __toCommonJS(typography_exports);
24
+ var import_utils = require("../utils");
12
25
  const fontSize = {
13
- name: 'fontSize',
26
+ name: "fontSize",
14
27
  generate: (style, options) => {
15
- return (0, _utils.generateRule)(style, options, ['typography', 'fontSize'], 'fontSize');
28
+ return (0, import_utils.generateRule)(
29
+ style,
30
+ options,
31
+ ["typography", "fontSize"],
32
+ "fontSize"
33
+ );
16
34
  }
17
35
  };
18
36
  const fontStyle = {
19
- name: 'fontStyle',
37
+ name: "fontStyle",
20
38
  generate: (style, options) => {
21
- return (0, _utils.generateRule)(style, options, ['typography', 'fontStyle'], 'fontStyle');
39
+ return (0, import_utils.generateRule)(
40
+ style,
41
+ options,
42
+ ["typography", "fontStyle"],
43
+ "fontStyle"
44
+ );
22
45
  }
23
46
  };
24
47
  const fontWeight = {
25
- name: 'fontWeight',
48
+ name: "fontWeight",
26
49
  generate: (style, options) => {
27
- return (0, _utils.generateRule)(style, options, ['typography', 'fontWeight'], 'fontWeight');
50
+ return (0, import_utils.generateRule)(
51
+ style,
52
+ options,
53
+ ["typography", "fontWeight"],
54
+ "fontWeight"
55
+ );
28
56
  }
29
57
  };
30
58
  const fontFamily = {
31
- name: 'fontFamily',
59
+ name: "fontFamily",
32
60
  generate: (style, options) => {
33
- return (0, _utils.generateRule)(style, options, ['typography', 'fontFamily'], 'fontFamily');
61
+ return (0, import_utils.generateRule)(
62
+ style,
63
+ options,
64
+ ["typography", "fontFamily"],
65
+ "fontFamily"
66
+ );
34
67
  }
35
68
  };
36
69
  const letterSpacing = {
37
- name: 'letterSpacing',
70
+ name: "letterSpacing",
38
71
  generate: (style, options) => {
39
- return (0, _utils.generateRule)(style, options, ['typography', 'letterSpacing'], 'letterSpacing');
72
+ return (0, import_utils.generateRule)(
73
+ style,
74
+ options,
75
+ ["typography", "letterSpacing"],
76
+ "letterSpacing"
77
+ );
40
78
  }
41
79
  };
42
80
  const lineHeight = {
43
- name: 'lineHeight',
81
+ name: "lineHeight",
44
82
  generate: (style, options) => {
45
- return (0, _utils.generateRule)(style, options, ['typography', 'lineHeight'], 'lineHeight');
83
+ return (0, import_utils.generateRule)(
84
+ style,
85
+ options,
86
+ ["typography", "lineHeight"],
87
+ "lineHeight"
88
+ );
46
89
  }
47
90
  };
48
91
  const textColumns = {
49
- name: 'textColumns',
92
+ name: "textColumns",
50
93
  generate: (style, options) => {
51
- return (0, _utils.generateRule)(style, options, ['typography', 'textColumns'], 'columnCount');
94
+ return (0, import_utils.generateRule)(
95
+ style,
96
+ options,
97
+ ["typography", "textColumns"],
98
+ "columnCount"
99
+ );
52
100
  }
53
101
  };
54
102
  const textDecoration = {
55
- name: 'textDecoration',
103
+ name: "textDecoration",
56
104
  generate: (style, options) => {
57
- return (0, _utils.generateRule)(style, options, ['typography', 'textDecoration'], 'textDecoration');
105
+ return (0, import_utils.generateRule)(
106
+ style,
107
+ options,
108
+ ["typography", "textDecoration"],
109
+ "textDecoration"
110
+ );
58
111
  }
59
112
  };
60
113
  const textTransform = {
61
- name: 'textTransform',
114
+ name: "textTransform",
62
115
  generate: (style, options) => {
63
- return (0, _utils.generateRule)(style, options, ['typography', 'textTransform'], 'textTransform');
116
+ return (0, import_utils.generateRule)(
117
+ style,
118
+ options,
119
+ ["typography", "textTransform"],
120
+ "textTransform"
121
+ );
64
122
  }
65
123
  };
66
124
  const writingMode = {
67
- name: 'writingMode',
125
+ name: "writingMode",
68
126
  generate: (style, options) => {
69
- return (0, _utils.generateRule)(style, options, ['typography', 'writingMode'], 'writingMode');
127
+ return (0, import_utils.generateRule)(
128
+ style,
129
+ options,
130
+ ["typography", "writingMode"],
131
+ "writingMode"
132
+ );
70
133
  }
71
134
  };
72
- var _default = exports.default = [fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textColumns, textDecoration, textTransform, writingMode];
73
- //# sourceMappingURL=index.js.map
135
+ var typography_default = [
136
+ fontFamily,
137
+ fontSize,
138
+ fontStyle,
139
+ fontWeight,
140
+ letterSpacing,
141
+ lineHeight,
142
+ textColumns,
143
+ textDecoration,
144
+ textTransform,
145
+ writingMode
146
+ ];
147
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_utils","require","fontSize","name","generate","style","options","generateRule","fontStyle","fontWeight","fontFamily","letterSpacing","lineHeight","textColumns","textDecoration","textTransform","writingMode","_default","exports","default"],"sources":["@wordpress/style-engine/src/styles/typography/index.ts"],"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 fontFamily = {\n\tname: 'fontFamily',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'fontFamily' ],\n\t\t\t'fontFamily'\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: 'lineHeight',\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 textColumns = {\n\tname: 'textColumns',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'textColumns' ],\n\t\t\t'columnCount'\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\nconst writingMode = {\n\tname: 'writingMode',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'writingMode' ],\n\t\t\t'writingMode'\n\t\t);\n\t},\n};\n\nexport default [\n\tfontFamily,\n\tfontSize,\n\tfontStyle,\n\tfontWeight,\n\tletterSpacing,\n\tlineHeight,\n\ttextColumns,\n\ttextDecoration,\n\ttextTransform,\n\twritingMode,\n];\n"],"mappings":";;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA,MAAMC,QAAQ,GAAG;EAChBC,IAAI,EAAE,UAAU;EAChBC,QAAQ,EAAEA,CAAEC,KAAY,EAAEC,OAAqB,KAAM;IACpD,OAAO,IAAAC,mBAAY,EAClBF,KAAK,EACLC,OAAO,EACP,CAAE,YAAY,EAAE,UAAU,CAAE,EAC5B,UACD,CAAC;EACF;AACD,CAAC;AAED,MAAME,SAAS,GAAG;EACjBL,IAAI,EAAE,WAAW;EACjBC,QAAQ,EAAEA,CAAEC,KAAY,EAAEC,OAAqB,KAAM;IACpD,OAAO,IAAAC,mBAAY,EAClBF,KAAK,EACLC,OAAO,EACP,CAAE,YAAY,EAAE,WAAW,CAAE,EAC7B,WACD,CAAC;EACF;AACD,CAAC;AAED,MAAMG,UAAU,GAAG;EAClBN,IAAI,EAAE,YAAY;EAClBC,QAAQ,EAAEA,CAAEC,KAAY,EAAEC,OAAqB,KAAM;IACpD,OAAO,IAAAC,mBAAY,EAClBF,KAAK,EACLC,OAAO,EACP,CAAE,YAAY,EAAE,YAAY,CAAE,EAC9B,YACD,CAAC;EACF;AACD,CAAC;AAED,MAAMI,UAAU,GAAG;EAClBP,IAAI,EAAE,YAAY;EAClBC,QAAQ,EAAEA,CAAEC,KAAY,EAAEC,OAAqB,KAAM;IACpD,OAAO,IAAAC,mBAAY,EAClBF,KAAK,EACLC,OAAO,EACP,CAAE,YAAY,EAAE,YAAY,CAAE,EAC9B,YACD,CAAC;EACF;AACD,CAAC;AAED,MAAMK,aAAa,GAAG;EACrBR,IAAI,EAAE,eAAe;EACrBC,QAAQ,EAAEA,CAAEC,KAAY,EAAEC,OAAqB,KAAM;IACpD,OAAO,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CAAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa,CACdT,UAAU,EACVR,QAAQ,EACRM,SAAS,EACTC,UAAU,EACVE,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,aAAa,EACbC,WAAW,CACX","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/styles/typography/index.ts"],
4
+ "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 fontFamily = {\n\tname: 'fontFamily',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'fontFamily' ],\n\t\t\t'fontFamily'\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: 'lineHeight',\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 textColumns = {\n\tname: 'textColumns',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'textColumns' ],\n\t\t\t'columnCount'\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\nconst writingMode = {\n\tname: 'writingMode',\n\tgenerate: ( style: Style, options: StyleOptions ) => {\n\t\treturn generateRule(\n\t\t\tstyle,\n\t\t\toptions,\n\t\t\t[ 'typography', 'writingMode' ],\n\t\t\t'writingMode'\n\t\t);\n\t},\n};\n\nexport default [\n\tfontFamily,\n\tfontSize,\n\tfontStyle,\n\tfontWeight,\n\tletterSpacing,\n\tlineHeight,\n\ttextColumns,\n\ttextDecoration,\n\ttextTransform,\n\twritingMode,\n];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,mBAA6B;AAE7B,MAAM,WAAW;AAAA,EAChB,MAAM;AAAA,EACN,UAAU,CAAE,OAAc,YAA2B;AACpD,eAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA,CAAE,cAAc,UAAW;AAAA,MAC3B;AAAA,IACD;AAAA,EACD;AAC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EA,MAAM,gBAAgB;AAAA,EACrB,MAAM;AAAA,EACN,UAAU,CAAE,OAAc,YAA2B;AACpD,eAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA,CAAE,cAAc,eAAgB;AAAA,MAChC;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,cAAc;AAAA,EACnB,MAAM;AAAA,EACN,UAAU,CAAE,OAAc,YAA2B;AACpD,eAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA,CAAE,cAAc,aAAc;AAAA,MAC9B;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;",
6
+ "names": []
7
+ }
@@ -1,170 +1,118 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var utils_exports = {};
20
+ __export(utils_exports, {
21
+ camelCaseJoin: () => camelCaseJoin,
22
+ generateBoxRules: () => generateBoxRules,
23
+ generateRule: () => generateRule,
24
+ getCSSValueFromRawStyle: () => getCSSValueFromRawStyle,
25
+ getStyleValueByPath: () => getStyleValueByPath,
26
+ safeDecodeURI: () => safeDecodeURI,
27
+ upperFirst: () => upperFirst
5
28
  });
6
- exports.camelCaseJoin = camelCaseJoin;
7
- exports.generateBoxRules = generateBoxRules;
8
- exports.generateRule = generateRule;
9
- exports.getCSSValueFromRawStyle = getCSSValueFromRawStyle;
10
- exports.getStyleValueByPath = void 0;
11
- exports.safeDecodeURI = safeDecodeURI;
12
- exports.upperFirst = upperFirst;
13
- var _changeCase = require("change-case");
14
- var _constants = require("./constants");
15
- /**
16
- * External dependencies
17
- */
18
-
19
- /**
20
- * Internal dependencies
21
- */
22
-
23
- /**
24
- * Helper util to return a value from a certain path of the object.
25
- * Path is specified as an array of properties, like `[ 'x', 'y' ]`.
26
- *
27
- * @param object Input object.
28
- * @param path Path to the object property.
29
- * @return Value of the object property at the specified path.
30
- */
29
+ module.exports = __toCommonJS(utils_exports);
30
+ var import_change_case = require("change-case");
31
+ var import_constants = require("./constants");
31
32
  const getStyleValueByPath = (object, path) => {
32
33
  let value = object;
33
- path.forEach(fieldName => {
34
+ path.forEach((fieldName) => {
34
35
  value = value?.[fieldName];
35
36
  });
36
37
  return value;
37
38
  };
38
-
39
- /**
40
- * Returns a JSON representation of the generated CSS rules.
41
- *
42
- * @param style Style object.
43
- * @param options Options object with settings to adjust how the styles are generated.
44
- * @param path An array of strings representing the path to the style value in the style object.
45
- * @param ruleKey A CSS property key.
46
- *
47
- * @return GeneratedCSSRule[] CSS rules.
48
- */
49
- exports.getStyleValueByPath = getStyleValueByPath;
50
39
  function generateRule(style, options, path, ruleKey) {
51
40
  const styleValue = getStyleValueByPath(style, path);
52
- return styleValue ? [{
53
- selector: options?.selector,
54
- key: ruleKey,
55
- value: getCSSValueFromRawStyle(styleValue)
56
- }] : [];
41
+ return styleValue ? [
42
+ {
43
+ selector: options?.selector,
44
+ key: ruleKey,
45
+ value: getCSSValueFromRawStyle(styleValue)
46
+ }
47
+ ] : [];
57
48
  }
58
-
59
- /**
60
- * Returns a JSON representation of the generated CSS rules taking into account box model properties, top, right, bottom, left.
61
- *
62
- * @param style Style object.
63
- * @param options Options object with settings to adjust how the styles are generated.
64
- * @param path An array of strings representing the path to the style value in the style object.
65
- * @param ruleKeys An array of CSS property keys and patterns.
66
- * @param individualProperties The "sides" or individual properties for which to generate rules.
67
- *
68
- * @return GeneratedCSSRule[] CSS rules.
69
- */
70
- function generateBoxRules(style, options, path, ruleKeys, individualProperties = ['top', 'right', 'bottom', 'left']) {
71
- const boxStyle = getStyleValueByPath(style, path);
49
+ function generateBoxRules(style, options, path, ruleKeys, individualProperties = ["top", "right", "bottom", "left"]) {
50
+ const boxStyle = getStyleValueByPath(
51
+ style,
52
+ path
53
+ );
72
54
  if (!boxStyle) {
73
55
  return [];
74
56
  }
75
57
  const rules = [];
76
- if (typeof boxStyle === 'string') {
58
+ if (typeof boxStyle === "string") {
77
59
  rules.push({
78
60
  selector: options?.selector,
79
61
  key: ruleKeys.default,
80
62
  value: getCSSValueFromRawStyle(boxStyle)
81
63
  });
82
64
  } else {
83
- const sideRules = individualProperties.reduce((acc, side) => {
84
- const value = getCSSValueFromRawStyle(getStyleValueByPath(boxStyle, [side]));
85
- if (value) {
86
- acc.push({
87
- selector: options?.selector,
88
- key: ruleKeys?.individual.replace('%s', upperFirst(side)),
89
- value
90
- });
91
- }
92
- return acc;
93
- }, []);
65
+ const sideRules = individualProperties.reduce(
66
+ (acc, side) => {
67
+ const value = getCSSValueFromRawStyle(
68
+ getStyleValueByPath(boxStyle, [side])
69
+ );
70
+ if (value) {
71
+ acc.push({
72
+ selector: options?.selector,
73
+ key: ruleKeys?.individual.replace(
74
+ "%s",
75
+ upperFirst(side)
76
+ ),
77
+ value
78
+ });
79
+ }
80
+ return acc;
81
+ },
82
+ []
83
+ );
94
84
  rules.push(...sideRules);
95
85
  }
96
86
  return rules;
97
87
  }
98
-
99
- /**
100
- * Returns a WordPress CSS custom var value from incoming style preset value,
101
- * if one is detected.
102
- *
103
- * The preset value is a string and follows the pattern `var:description|context|slug`.
104
- *
105
- * Example:
106
- *
107
- * `getCSSValueFromRawStyle( 'var:preset|color|heavenlyBlue' )` // returns 'var(--wp--preset--color--heavenly-blue)'
108
- *
109
- * @param styleValue A string representing a raw CSS value. Non-strings won't be processed.
110
- *
111
- * @return A CSS custom var value if the incoming style value is a preset value.
112
- */
113
-
114
88
  function getCSSValueFromRawStyle(styleValue) {
115
- if (typeof styleValue === 'string' && styleValue.startsWith(_constants.VARIABLE_REFERENCE_PREFIX)) {
116
- const variable = styleValue.slice(_constants.VARIABLE_REFERENCE_PREFIX.length).split(_constants.VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).map(presetVariable => (0, _changeCase.paramCase)(presetVariable, {
117
- splitRegexp: [/([a-z0-9])([A-Z])/g,
118
- // fooBar => foo-bar, 3Bar => 3-bar
119
- /([0-9])([a-z])/g,
120
- // 3bar => 3-bar
121
- /([A-Za-z])([0-9])/g,
122
- // Foo3 => foo-3, foo3 => foo-3
123
- /([A-Z])([A-Z][a-z])/g // FOOBar => foo-bar
124
- ]
125
- })).join(_constants.VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
89
+ if (typeof styleValue === "string" && styleValue.startsWith(import_constants.VARIABLE_REFERENCE_PREFIX)) {
90
+ const variable = styleValue.slice(import_constants.VARIABLE_REFERENCE_PREFIX.length).split(import_constants.VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).map(
91
+ (presetVariable) => (0, import_change_case.paramCase)(presetVariable, {
92
+ splitRegexp: [
93
+ /([a-z0-9])([A-Z])/g,
94
+ // fooBar => foo-bar, 3Bar => 3-bar
95
+ /([0-9])([a-z])/g,
96
+ // 3bar => 3-bar
97
+ /([A-Za-z])([0-9])/g,
98
+ // Foo3 => foo-3, foo3 => foo-3
99
+ /([A-Z])([A-Z][a-z])/g
100
+ // FOOBar => foo-bar
101
+ ]
102
+ })
103
+ ).join(import_constants.VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
126
104
  return `var(--wp--${variable})`;
127
105
  }
128
106
  return styleValue;
129
107
  }
130
-
131
- /**
132
- * Capitalizes the first letter in a string.
133
- *
134
- * @param string The string whose first letter the function will capitalize.
135
- *
136
- * @return String with the first letter capitalized.
137
- */
138
108
  function upperFirst(string) {
139
109
  const [firstLetter, ...rest] = string;
140
- return firstLetter.toUpperCase() + rest.join('');
110
+ return firstLetter.toUpperCase() + rest.join("");
141
111
  }
142
-
143
- /**
144
- * Converts an array of strings into a camelCase string.
145
- *
146
- * @param strings The strings to join into a camelCase string.
147
- *
148
- * @return camelCase string.
149
- */
150
112
  function camelCaseJoin(strings) {
151
113
  const [firstItem, ...rest] = strings;
152
- return firstItem.toLowerCase() + rest.map(upperFirst).join('');
114
+ return firstItem.toLowerCase() + rest.map(upperFirst).join("");
153
115
  }
154
-
155
- /**
156
- * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
157
- * `decodeURI` throws an error.
158
- *
159
- * @param {string} uri URI to decode.
160
- *
161
- * @example
162
- * ```js
163
- * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
164
- * ```
165
- *
166
- * @return {string} Decoded URI if possible.
167
- */
168
116
  function safeDecodeURI(uri) {
169
117
  try {
170
118
  return decodeURI(uri);
@@ -172,4 +120,14 @@ function safeDecodeURI(uri) {
172
120
  return uri;
173
121
  }
174
122
  }
175
- //# sourceMappingURL=utils.js.map
123
+ // Annotate the CommonJS export names for ESM import in node:
124
+ 0 && (module.exports = {
125
+ camelCaseJoin,
126
+ generateBoxRules,
127
+ generateRule,
128
+ getCSSValueFromRawStyle,
129
+ getStyleValueByPath,
130
+ safeDecodeURI,
131
+ upperFirst
132
+ });
133
+ //# sourceMappingURL=utils.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_changeCase","require","_constants","getStyleValueByPath","object","path","value","forEach","fieldName","exports","generateRule","style","options","ruleKey","styleValue","selector","key","getCSSValueFromRawStyle","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: getCSSValueFromRawStyle( 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: getCSSValueFromRawStyle( 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 = getCSSValueFromRawStyle(\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 WordPress CSS custom var value from incoming style preset value,\n * if one is detected.\n *\n * The preset value is a string and follows the pattern `var:description|context|slug`.\n *\n * Example:\n *\n * `getCSSValueFromRawStyle( 'var:preset|color|heavenlyBlue' )` // returns 'var(--wp--preset--color--heavenly-blue)'\n *\n * @param styleValue A string representing a raw CSS value. Non-strings won't be processed.\n *\n * @return A CSS custom var value if the incoming style value is a preset value.\n */\n\nexport function getCSSValueFromRawStyle< StyleValue = string >(\n\tstyleValue: StyleValue\n): StyleValue {\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 })` as StyleValue;\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;;AAGA;AACA;AACA;;AAcA;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,KA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],
4
+ "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: getCSSValueFromRawStyle( 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: getCSSValueFromRawStyle( 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 = getCSSValueFromRawStyle(\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 WordPress CSS custom var value from incoming style preset value,\n * if one is detected.\n *\n * The preset value is a string and follows the pattern `var:description|context|slug`.\n *\n * Example:\n *\n * `getCSSValueFromRawStyle( 'var:preset|color|heavenlyBlue' )` // returns 'var(--wp--preset--color--heavenly-blue)'\n *\n * @param styleValue A string representing a raw CSS value. Non-strings won't be processed.\n *\n * @return A CSS custom var value if the incoming style value is a preset value.\n */\n\nexport function getCSSValueFromRawStyle< StyleValue = string >(\n\tstyleValue: StyleValue\n): StyleValue {\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 })` as StyleValue;\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\tt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AE;AAAA,QACH;AACA,eAAO;AAAA,MACR;AAAA,MACA,CAAC;AAAA,IACF;AACA,UAAM,KAAM,GAAG,SAAU;AAAA,EAC1B;AAEA,SAAO;AACR;AAiBO,SAAS,wBACf,YACa;AACb,MACC,OAAO,eAAe,YACtB,WAAW,WAAY,0CAA0B,GAChD;AACD,UAAM,WAAW,WACf,MAAO,2CAA0B,MAAO,EACxC,MAAO,wDAAwC,EAC/C;AAAA,MAAK,CAAE,uBACP,mBAAAA,WAAW,gBAAgB;AAAA,QAC1B,aAAa;AAAA,UACZ;AAAA;AAAA,UACA;AAAA;AAAA,UACA;AAAA;AAAA,UACA;AAAA;AAAA,QACD;AAAA,MACD,CAAE;AAAA,IACH,EACC,KAAM,oDAAoC;AAC5C,WAAO,aAAc,QAAS;AAAA,EAC/B;AACA,SAAO;AACR;AASO,SAAS,WAAY,QAAyB;AACpD,QAAM,CAAE,aAAa,GAAG,IAAK,IAAI;AACjC,SAAO,YAAY,YAAY,IAAI,KAAK,KAAM,EAAG;AAClD;AASO,SAAS,cAAe,SAA4B;AAC1D,QAAM,CAAE,WAAW,GAAG,IAAK,IAAI;AAC/B,SAAO,UAAU,YAAY,IAAI,KAAK,IAAK,UAAW,EAAE,KAAM,EAAG;AAClE;AAeO,SAAS,cAAe,KAAsB;AACpD,MAAI;AACH,WAAO,UAAW,GAAI;AAAA,EACvB,SAAU,UAAW;AACpB,WAAO;AAAA,EACR;AACD;",
6
+ "names": ["kebabCase"]
7
+ }
package/build/types.js CHANGED
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=types.js.map
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
17
+ //# sourceMappingURL=types.js.map
@@ -1 +1,7 @@
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\t| { url?: CSSProperties[ 'backgroundImage' ]; source?: string }\n\t\t\t| CSSProperties[ 'backgroundImage' ];\n\t\tbackgroundPosition?: CSSProperties[ 'backgroundPosition' ];\n\t\tbackgroundRepeat?: CSSProperties[ 'backgroundRepeat' ];\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\taspectRatio?: CSSProperties[ 'aspectRatio' ];\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 | unknown;\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":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/types.ts"],
4
+ "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\t| { url?: CSSProperties[ 'backgroundImage' ]; source?: string }\n\t\t\t| CSSProperties[ 'backgroundImage' ];\n\t\tbackgroundPosition?: CSSProperties[ 'backgroundPosition' ];\n\t\tbackgroundRepeat?: CSSProperties[ 'backgroundRepeat' ];\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\taspectRatio?: CSSProperties[ 'aspectRatio' ];\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 | unknown;\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"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }