@plumeria/core 3.0.1 → 4.0.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/css.d.ts +2 -1
- package/dist/css.js +34 -3
- package/dist/css.mjs +34 -3
- package/package.json +1 -10
- package/stylesheet.css +0 -3
package/dist/css.d.ts
CHANGED
|
@@ -61,10 +61,11 @@ type ViewTransition = {
|
|
|
61
61
|
old?: CSSProperties;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
declare function props(...rules: (false | CSSProperties | null | undefined)[]): string;
|
|
64
65
|
declare const css: {
|
|
65
66
|
new (): {};
|
|
66
67
|
create<const T extends Record<string, CSSProperties>>(_rule: CreateStyleType<T>): ReturnType<T>;
|
|
67
|
-
props
|
|
68
|
+
props: typeof props;
|
|
68
69
|
createTheme<const T extends CreateTheme>(_rule: T): ReturnVariableType<T>;
|
|
69
70
|
createStatic<const T extends CreateStatic>(_rule: T): T;
|
|
70
71
|
keyframes(_rule: Keyframes): string;
|
package/dist/css.js
CHANGED
|
@@ -2,13 +2,44 @@
|
|
|
2
2
|
function errorFn(fn) {
|
|
3
3
|
throw new Error(`css.${fn} requires bundler-plugin setup`);
|
|
4
4
|
}
|
|
5
|
+
function props(...rules) {
|
|
6
|
+
const chosen = new Map();
|
|
7
|
+
const classList = [];
|
|
8
|
+
const orderedKeys = [];
|
|
9
|
+
const rightmostKeys = [];
|
|
10
|
+
for (let i = rules.length - 1; i >= 0; i--) {
|
|
11
|
+
const arg = rules[i];
|
|
12
|
+
if (!arg || typeof arg === "string") continue;
|
|
13
|
+
for (const [key, hash] of Object.entries(arg)) if (!chosen.has(key)) chosen.set(key, {
|
|
14
|
+
hash,
|
|
15
|
+
propsIdx: i
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
for (let i = 0; i < rules.length; i++) {
|
|
19
|
+
const arg = rules[i];
|
|
20
|
+
if (!arg) continue;
|
|
21
|
+
if (typeof arg === "string") {
|
|
22
|
+
classList.push(arg);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
for (const [key] of Object.entries(arg)) {
|
|
26
|
+
const info = chosen.get(key);
|
|
27
|
+
if (info && info.propsIdx === i) {
|
|
28
|
+
if (i === rules.length - 1) rightmostKeys.push(info);
|
|
29
|
+
else orderedKeys.push(info);
|
|
30
|
+
chosen.delete(key);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const { hash } of orderedKeys) classList.push(hash);
|
|
35
|
+
for (const { hash } of rightmostKeys) classList.push(hash);
|
|
36
|
+
return classList.join(" ");
|
|
37
|
+
}
|
|
5
38
|
const css = class _css {
|
|
6
39
|
static create(_rule) {
|
|
7
40
|
throw errorFn("create");
|
|
8
41
|
}
|
|
9
|
-
static props
|
|
10
|
-
return rules.filter(Boolean).join(" ");
|
|
11
|
-
}
|
|
42
|
+
static props = props;
|
|
12
43
|
static createTheme(_rule) {
|
|
13
44
|
throw errorFn("createTheme");
|
|
14
45
|
}
|
package/dist/css.mjs
CHANGED
|
@@ -2,13 +2,44 @@
|
|
|
2
2
|
function errorFn(fn) {
|
|
3
3
|
throw new Error(`css.${fn} requires bundler-plugin setup`);
|
|
4
4
|
}
|
|
5
|
+
function props(...rules) {
|
|
6
|
+
const chosen = new Map();
|
|
7
|
+
const classList = [];
|
|
8
|
+
const orderedKeys = [];
|
|
9
|
+
const rightmostKeys = [];
|
|
10
|
+
for (let i = rules.length - 1; i >= 0; i--) {
|
|
11
|
+
const arg = rules[i];
|
|
12
|
+
if (!arg || typeof arg === "string") continue;
|
|
13
|
+
for (const [key, hash] of Object.entries(arg)) if (!chosen.has(key)) chosen.set(key, {
|
|
14
|
+
hash,
|
|
15
|
+
propsIdx: i
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
for (let i = 0; i < rules.length; i++) {
|
|
19
|
+
const arg = rules[i];
|
|
20
|
+
if (!arg) continue;
|
|
21
|
+
if (typeof arg === "string") {
|
|
22
|
+
classList.push(arg);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
for (const [key] of Object.entries(arg)) {
|
|
26
|
+
const info = chosen.get(key);
|
|
27
|
+
if (info && info.propsIdx === i) {
|
|
28
|
+
if (i === rules.length - 1) rightmostKeys.push(info);
|
|
29
|
+
else orderedKeys.push(info);
|
|
30
|
+
chosen.delete(key);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const { hash } of orderedKeys) classList.push(hash);
|
|
35
|
+
for (const { hash } of rightmostKeys) classList.push(hash);
|
|
36
|
+
return classList.join(" ");
|
|
37
|
+
}
|
|
5
38
|
const css = class _css {
|
|
6
39
|
static create(_rule) {
|
|
7
40
|
throw errorFn("create");
|
|
8
41
|
}
|
|
9
|
-
static props
|
|
10
|
-
return rules.filter(Boolean).join(" ");
|
|
11
|
-
}
|
|
42
|
+
static props = props;
|
|
12
43
|
static createTheme(_rule) {
|
|
13
44
|
throw errorFn("createTheme");
|
|
14
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumeria/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "An atomic CSS runtime designed to disappear.",
|
|
5
5
|
"author": "Refirst 11",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,15 +23,6 @@
|
|
|
23
23
|
"react-native-web"
|
|
24
24
|
],
|
|
25
25
|
"sideEffects": false,
|
|
26
|
-
"exports": {
|
|
27
|
-
"./package.json": "./package.json",
|
|
28
|
-
"./stylesheet.css": "./stylesheet.css",
|
|
29
|
-
".": {
|
|
30
|
-
"types": "./dist/css.d.ts",
|
|
31
|
-
"import": "./dist/css.mjs",
|
|
32
|
-
"default": "./dist/css.js"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
26
|
"main": "dist/css.js",
|
|
36
27
|
"module": "dist/css.mjs",
|
|
37
28
|
"types": "dist/css.d.ts",
|
package/stylesheet.css
DELETED