@plumeria/core 0.22.2 → 0.22.4
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 +34 -21
- package/dist/index.mjs +34 -21
- package/package.json +1 -1
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
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(
|
|
70
|
-
Object.
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
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(
|
|
70
|
-
Object.
|
|
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,
|