@plumeria/core 0.22.3 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8,27 +8,36 @@ function create(object) {
8
8
  const flat = {};
9
9
  const nonFlat = {};
10
10
  (0, zss_engine.splitAtomicAndNested)(styleObj, flat, nonFlat);
11
- const props$1 = Object.keys(flat);
12
- const finalFlat = {};
13
- for (let i = 0; i < props$1.length; i++) {
14
- const prop = props$1[i];
15
- const kebab = (0, zss_engine.camelToKebabCase)(prop);
16
- const isShorthand = !!zss_engine.SHORTHAND_PROPERTIES[kebab];
17
- if (isShorthand) finalFlat[prop] = flat[prop];
18
- else {
19
- let isOverridden = false;
20
- const shorthands = zss_engine.LONG_TO_SHORT[kebab] || [];
21
- for (let j = i + 1; j < props$1.length; j++) {
22
- const futureProp = props$1[j];
23
- const futureKebab = (0, zss_engine.camelToKebabCase)(futureProp);
24
- if (shorthands.includes(futureKebab)) {
25
- isOverridden = true;
26
- break;
11
+ const overrideLonghand = (style) => {
12
+ const props$1 = Object.keys(style);
13
+ if (props$1.some((p) => p.startsWith("@"))) {
14
+ const finalStyle$1 = { ...style };
15
+ for (const key$1 of props$1) if (key$1.startsWith("@")) finalStyle$1[key$1] = overrideLonghand(style[key$1]);
16
+ return finalStyle$1;
17
+ }
18
+ const finalStyle = {};
19
+ for (let i = 0; i < props$1.length; i++) {
20
+ const prop = props$1[i];
21
+ const kebab = (0, zss_engine.camelToKebabCase)(prop);
22
+ const isShorthand = !!zss_engine.SHORTHAND_PROPERTIES[kebab];
23
+ if (isShorthand) finalStyle[prop] = style[prop];
24
+ else {
25
+ let isOverridden = false;
26
+ const shorthands = zss_engine.LONG_TO_SHORT[kebab] || [];
27
+ for (let j = i + 1; j < props$1.length; j++) {
28
+ const futureProp = props$1[j];
29
+ const futureKebab = (0, zss_engine.camelToKebabCase)(futureProp);
30
+ if (shorthands.includes(futureKebab)) {
31
+ isOverridden = true;
32
+ break;
33
+ }
27
34
  }
35
+ if (!isOverridden) finalStyle[prop] = style[prop];
28
36
  }
29
- if (!isOverridden) finalFlat[prop] = flat[prop];
30
37
  }
31
- }
38
+ return finalStyle;
39
+ };
40
+ const finalFlat = overrideLonghand(flat);
32
41
  const records = [];
33
42
  Object.entries(finalFlat).forEach(([prop, value]) => {
34
43
  const hashes = new Set();
@@ -63,11 +72,15 @@ function create(object) {
63
72
  });
64
73
  });
65
74
  if (Object.keys(nonFlat).length > 0) {
66
- const nonFlatObj = { [key]: nonFlat };
75
+ const finalNonFlat = {};
76
+ Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
77
+ finalNonFlat[atRule] = overrideLonghand(nestedObj);
78
+ });
79
+ const nonFlatObj = { [key]: finalNonFlat };
67
80
  const nonFlatHash = (0, zss_engine.genBase36Hash)(nonFlatObj, 1, 7);
68
81
  const { styleSheet } = (0, zss_engine.transpile)(nonFlatObj, nonFlatHash);
69
- Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
70
- Object.entries(nestedObj).forEach(([prop]) => {
82
+ Object.entries(finalNonFlat).forEach(([atRule, nestedObj]) => {
83
+ Object.keys(nestedObj).forEach((prop) => {
71
84
  records.push({
72
85
  key: atRule + prop,
73
86
  hash: nonFlatHash,
package/dist/index.mjs CHANGED
@@ -8,27 +8,36 @@ function create(object) {
8
8
  const flat = {};
9
9
  const nonFlat = {};
10
10
  splitAtomicAndNested(styleObj, flat, nonFlat);
11
- const props$1 = Object.keys(flat);
12
- const finalFlat = {};
13
- for (let i = 0; i < props$1.length; i++) {
14
- const prop = props$1[i];
15
- const kebab = camelToKebabCase(prop);
16
- const isShorthand = !!SHORTHAND_PROPERTIES[kebab];
17
- if (isShorthand) finalFlat[prop] = flat[prop];
18
- else {
19
- let isOverridden = false;
20
- const shorthands = LONG_TO_SHORT[kebab] || [];
21
- for (let j = i + 1; j < props$1.length; j++) {
22
- const futureProp = props$1[j];
23
- const futureKebab = camelToKebabCase(futureProp);
24
- if (shorthands.includes(futureKebab)) {
25
- isOverridden = true;
26
- break;
11
+ const overrideLonghand = (style) => {
12
+ const props$1 = Object.keys(style);
13
+ if (props$1.some((p) => p.startsWith("@"))) {
14
+ const finalStyle$1 = { ...style };
15
+ for (const key$1 of props$1) if (key$1.startsWith("@")) finalStyle$1[key$1] = overrideLonghand(style[key$1]);
16
+ return finalStyle$1;
17
+ }
18
+ const finalStyle = {};
19
+ for (let i = 0; i < props$1.length; i++) {
20
+ const prop = props$1[i];
21
+ const kebab = camelToKebabCase(prop);
22
+ const isShorthand = !!SHORTHAND_PROPERTIES[kebab];
23
+ if (isShorthand) finalStyle[prop] = style[prop];
24
+ else {
25
+ let isOverridden = false;
26
+ const shorthands = LONG_TO_SHORT[kebab] || [];
27
+ for (let j = i + 1; j < props$1.length; j++) {
28
+ const futureProp = props$1[j];
29
+ const futureKebab = camelToKebabCase(futureProp);
30
+ if (shorthands.includes(futureKebab)) {
31
+ isOverridden = true;
32
+ break;
33
+ }
27
34
  }
35
+ if (!isOverridden) finalStyle[prop] = style[prop];
28
36
  }
29
- if (!isOverridden) finalFlat[prop] = flat[prop];
30
37
  }
31
- }
38
+ return finalStyle;
39
+ };
40
+ const finalFlat = overrideLonghand(flat);
32
41
  const records = [];
33
42
  Object.entries(finalFlat).forEach(([prop, value]) => {
34
43
  const hashes = new Set();
@@ -63,11 +72,15 @@ function create(object) {
63
72
  });
64
73
  });
65
74
  if (Object.keys(nonFlat).length > 0) {
66
- const nonFlatObj = { [key]: nonFlat };
75
+ const finalNonFlat = {};
76
+ Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
77
+ finalNonFlat[atRule] = overrideLonghand(nestedObj);
78
+ });
79
+ const nonFlatObj = { [key]: finalNonFlat };
67
80
  const nonFlatHash = genBase36Hash(nonFlatObj, 1, 7);
68
81
  const { styleSheet } = transpile(nonFlatObj, nonFlatHash);
69
- Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
70
- Object.entries(nestedObj).forEach(([prop]) => {
82
+ Object.entries(finalNonFlat).forEach(([atRule, nestedObj]) => {
83
+ Object.keys(nestedObj).forEach((prop) => {
71
84
  records.push({
72
85
  key: atRule + prop,
73
86
  hash: nonFlatHash,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/core",
3
- "version": "0.22.3",
3
+ "version": "0.23.0",
4
4
  "description": "The atomic on-demand CSS-in-JS.",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",