@plitzi/sdk-style 0.38.6 → 0.38.8
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/CHANGELOG.md +211 -0
- package/dist/StyleMap/helpers/isValueValid.d.ts +2 -0
- package/dist/StyleMap/helpers/isValueValid.mjs +6 -4
- package/dist/StyleMap/helpers/utils.d.ts +3 -4
- package/dist/StyleMap/helpers/utils.mjs +36 -46
- package/dist/StyleMap/methods/addSelector.mjs +13 -12
- package/dist/StyleMap/methods/updateSelector.mjs +6 -5
- package/dist/components/StyleInspector/Inspector.d.ts +4 -2
- package/dist/components/StyleInspector/Inspector.mjs +98 -88
- package/dist/components/StyleInspector/StyleInspector.mjs +203 -155
- package/dist/components/StyleInspector/StyleInspectorContext.d.ts +3 -1
- package/dist/components/StyleInspector/StyleInspectorProvider.d.ts +4 -2
- package/dist/components/StyleInspector/StyleInspectorProvider.mjs +56 -53
- package/dist/components/StyleInspector/components/AncestorRules/AncestorRuleChip.mjs +23 -22
- package/dist/components/StyleInspector/helpers.d.ts +11 -1
- package/dist/components/StyleInspector/helpers.mjs +31 -19
- package/dist/components/StyleInspector/hooks/useStyleInherit.d.ts +4 -2
- package/dist/components/StyleInspector/hooks/useStyleInherit.mjs +10 -6
- package/dist/helpers/calculateInheriting.d.ts +3 -1
- package/dist/helpers/calculateInheriting.mjs +60 -35
- package/dist/helpers/processSelector.mjs +64 -46
- package/dist/helpers/processSelectorAttributes.d.ts +12 -4
- package/dist/helpers/processSelectorAttributes.mjs +26 -10
- package/package.json +5 -5
|
@@ -1,70 +1,88 @@
|
|
|
1
1
|
import e from "./processSelectorAttributes.mjs";
|
|
2
2
|
import t from "./processSelectorName.mjs";
|
|
3
3
|
import n from "./processSelectorVariables.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { conditionAtRule as r } from "@plitzi/sdk-shared/style/styleConditions";
|
|
5
|
+
import { pseudoSuffix as i } from "@plitzi/sdk-shared/style/stylePseudos";
|
|
6
|
+
import { inCascadeOrder as a, isParentAncestor as o, isStartingState as s, stateSuffix as c } from "@plitzi/sdk-shared/style/styleStates";
|
|
5
7
|
//#region src/helpers/processSelector.ts
|
|
6
|
-
var
|
|
7
|
-
let i = [], a =
|
|
8
|
+
var l = 2, u = (e = l) => " ".repeat(e), d = (e, t, n) => `${n || !t.length ? e : `${e}\n`}${t.join(n ? "" : "\n")}`, f = (e, t, n = !0, r = l) => {
|
|
9
|
+
let i = [], a = u(r), o = u(r + l);
|
|
8
10
|
for (let r of ["light", "dark"]) if (t[r].length) {
|
|
9
11
|
if (n) i.push(`@media(prefers-color-scheme:${r}){${e}{${t[r].join("")}}}`);
|
|
10
12
|
else {
|
|
11
|
-
let n = t[r].map((e) => `${
|
|
13
|
+
let n = t[r].map((e) => `${o}${e}`).join("\n").replaceAll(":", ": ");
|
|
12
14
|
i.push(`\n@media(prefers-color-scheme: ${r}) {\n${a}${e} {\n${n}\n${a}}\n}`);
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
return i;
|
|
16
|
-
},
|
|
17
|
-
let
|
|
18
|
-
for (let [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
for (let [e,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
}, p = (e, t, n = "") => [`${e}[data-variant="${t}"]${n}`, `${e}--${t}${n}`], m = (e, t, n) => {
|
|
19
|
+
let r = t ? "," : ", ", i = [];
|
|
20
|
+
for (let [l, { default: u, states: d, variants: f }] of Object.entries(e)) {
|
|
21
|
+
let e = o(l), m = e ? "" : `.${l}`, h = e ? " > &" : " &", g = e ? "*" : m;
|
|
22
|
+
u?.length && i.push(y(`:where(${g})${h}`, u, {}, t, n));
|
|
23
|
+
for (let [e, r] of a(d ?? {})) i.push(y(`:where(${m}${c(e)})${h}`, r, {}, t, n)), s(e) && i.push(v(`:where(${g})${h}`, r, t, n));
|
|
24
|
+
let _ = (t, n = "") => e ? [`[data-variant="${t}"]${n}`] : p(m, t, n);
|
|
25
|
+
for (let [e, o] of Object.entries(f ?? {})) {
|
|
26
|
+
if (o.default.length) {
|
|
27
|
+
let a = _(e).join(r);
|
|
28
|
+
i.push(y(`:where(${a})${h}`, o.default, {}, t, n));
|
|
25
29
|
}
|
|
26
|
-
for (let [
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
-
let r = u(`.${c}`, e).join(o);
|
|
30
|
-
s.push(p(`:where(${r}) &`, f, t, n));
|
|
31
|
-
}
|
|
30
|
+
for (let [l, u] of a(o.states ?? {})) {
|
|
31
|
+
let a = _(e, c(l)).join(r);
|
|
32
|
+
i.push(y(`:where(${a})${h}`, u, {}, t, n)), s(l) && i.push(v(`:where(${_(e).join(r)})${h}`, u, t, n));
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
|
-
return
|
|
36
|
-
},
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
36
|
+
return i;
|
|
37
|
+
}, h = (e, t, n) => Object.entries(e).flatMap(([e, { default: r, states: o }]) => {
|
|
38
|
+
let l = i(e), u = r.length ? [y(`&${l}`, r, {}, t, n)] : [];
|
|
39
|
+
for (let [e, r] of a(o ?? {})) u.push(y(`&${c(e)}${l}`, r, {}, t, n)), s(e) && u.push(v(`&${l}`, r, t, n));
|
|
40
|
+
return u;
|
|
41
|
+
}), g = (e, t, n, i) => Object.entries(t).flatMap(([t, { default: a, states: o, pseudos: s }]) => {
|
|
42
|
+
let c = r(t);
|
|
43
|
+
if (!c) return [];
|
|
44
|
+
let l = _(e, a, {
|
|
45
|
+
states: o,
|
|
46
|
+
pseudos: s
|
|
47
|
+
}, n, i);
|
|
48
|
+
return l ? [n ? `${c}{${l}}` : `${u(i)}${c} {\n${l}\n${u(i)}}`] : [];
|
|
49
|
+
}), _ = (e, t, n, r = !0, i = l) => {
|
|
50
|
+
let { states: o, variants: d, ancestors: f, pseudos: p, conditions: _ } = n, b = r ? t.join("") : t.map((e) => `${u(i + l)}${e}`).join("\n").replaceAll(":", ": "), x = o ? a(o).flatMap(([e, t]) => {
|
|
51
|
+
let n = y(`&${c(e)}`, t, {}, r, i + l);
|
|
52
|
+
return s(e) ? [n, v("&", t, r, i + l)] : [n];
|
|
53
|
+
}) : [], S = e.replace("plitzi__", ""), C = d ? Object.entries(d).map(([e, t]) => y(`&[data-variant="${e}"]${r ? "," : ", "}&${S}--${e}`, t.default, {
|
|
54
|
+
states: t.states,
|
|
55
|
+
pseudos: t.pseudos
|
|
56
|
+
}, r, i + l)) : [], w = [
|
|
57
|
+
x,
|
|
58
|
+
p ? h(p, r, i + l) : [],
|
|
59
|
+
C,
|
|
60
|
+
f ? m(f, r, i + l) : [],
|
|
61
|
+
_ ? g(e, _, r, i + l) : []
|
|
62
|
+
];
|
|
63
|
+
if (r) return `${b}${w.map((e) => e.join("")).join("")}`;
|
|
64
|
+
let T = b ? [b] : [];
|
|
65
|
+
for (let e of w) e.length && T.push(e.join("\n\n"));
|
|
66
|
+
return T.join("\n\n");
|
|
67
|
+
}, v = (e, t, n, r) => n ? `@starting-style{${y(e, t, {}, n, r)}}` : `${u(r)}@starting-style {\n${y(e, t, {}, n, r + l)}\n${u(r)}}`, y = (e, t, n, r = !0, i = l) => {
|
|
68
|
+
let a = _(e, t, n, r, i);
|
|
69
|
+
return r ? `${e}{${a}}` : `${u(i)}${e} {\n${a}\n${u(i)}}`;
|
|
70
|
+
}, b = (e, t, n = !0, r = l) => {
|
|
53
71
|
let i = [];
|
|
54
|
-
for (let [a,
|
|
72
|
+
for (let [a, o] of Object.entries(t)) {
|
|
55
73
|
if (a === "base") {
|
|
56
|
-
let t =
|
|
74
|
+
let t = _(e, o.default, o, n, r);
|
|
57
75
|
t && i.push(t);
|
|
58
76
|
continue;
|
|
59
77
|
}
|
|
60
|
-
i.push(
|
|
78
|
+
i.push(y(`${e}-${a}`, o.default, o, n, r + l));
|
|
61
79
|
}
|
|
62
80
|
return n ? `${e}{${i.join("")}}` : `${e} {\n${i.join("\n\n")}\n}`;
|
|
63
|
-
},
|
|
64
|
-
let a = t(r), o = n(r), s = e(r),
|
|
81
|
+
}, x = (r, i = !0) => {
|
|
82
|
+
let a = t(r), o = n(r), s = e(r), c = o ? f(a, o, i) : void 0;
|
|
65
83
|
o && s.attributes.base.default.push(...o.default);
|
|
66
|
-
let
|
|
67
|
-
return
|
|
68
|
-
},
|
|
84
|
+
let l = b(a, s.attributes, i, 0);
|
|
85
|
+
return c ? d(l, c, i) : l;
|
|
86
|
+
}, S = (e, t = !1) => e.map((e) => x(e, t));
|
|
69
87
|
//#endregion
|
|
70
|
-
export {
|
|
88
|
+
export { x as default, S as processSelectors };
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import { StyleItem, StyleState } from '@plitzi/sdk-shared';
|
|
1
|
+
import { StyleItem, StylePseudo, StyleState } from '@plitzi/sdk-shared';
|
|
2
2
|
type ProcessedStates = Partial<Record<StyleState, string[]>>;
|
|
3
|
-
type
|
|
3
|
+
type ProcessedStateBlock = {
|
|
4
4
|
default: string[];
|
|
5
5
|
states?: ProcessedStates;
|
|
6
|
-
}
|
|
6
|
+
};
|
|
7
|
+
type ProcessedPseudos = Partial<Record<StylePseudo, ProcessedStateBlock>>;
|
|
8
|
+
type ProcessedPart = ProcessedStateBlock & {
|
|
9
|
+
pseudos?: ProcessedPseudos;
|
|
10
|
+
};
|
|
11
|
+
type ProcessedVariants = Record<string, ProcessedPart>;
|
|
12
|
+
type ProcessedConditions = Record<string, ProcessedPart>;
|
|
7
13
|
export type ProcessedAncestors = Record<string, {
|
|
8
14
|
default?: string[];
|
|
9
15
|
states?: ProcessedStates;
|
|
10
|
-
variants?:
|
|
16
|
+
variants?: Record<string, ProcessedStateBlock>;
|
|
11
17
|
}>;
|
|
12
18
|
export type Attributes = Record<string, {
|
|
13
19
|
default: string[];
|
|
14
20
|
states?: ProcessedStates;
|
|
15
21
|
variants?: ProcessedVariants;
|
|
16
22
|
ancestors?: ProcessedAncestors;
|
|
23
|
+
pseudos?: ProcessedPseudos;
|
|
24
|
+
conditions?: ProcessedConditions;
|
|
17
25
|
}>;
|
|
18
26
|
export declare const processCssString: (attribute: string, value?: string) => {
|
|
19
27
|
variables: string[];
|
|
@@ -89,21 +89,35 @@ var e = (e, t, { keepEmpty: n = !1, closeEndsPart: r = !1 } = {}) => {
|
|
|
89
89
|
}
|
|
90
90
|
return Object.keys(t).length ? t : void 0;
|
|
91
91
|
}, l = (e) => {
|
|
92
|
+
let t = c(e.states);
|
|
93
|
+
return {
|
|
94
|
+
default: r(e.default),
|
|
95
|
+
...t && { states: t }
|
|
96
|
+
};
|
|
97
|
+
}, u = (e) => {
|
|
92
98
|
if (!e) return;
|
|
93
99
|
let t = {};
|
|
94
|
-
for (let [n,
|
|
95
|
-
let e =
|
|
100
|
+
for (let [n, r] of Object.entries(e)) {
|
|
101
|
+
let e = l(r);
|
|
102
|
+
(e.default.length || e.states) && (t[n] = e);
|
|
103
|
+
}
|
|
104
|
+
return Object.keys(t).length ? t : void 0;
|
|
105
|
+
}, d = (e) => {
|
|
106
|
+
if (!e) return;
|
|
107
|
+
let t = {};
|
|
108
|
+
for (let [n, r] of Object.entries(e)) {
|
|
109
|
+
let e = u(r.pseudos);
|
|
96
110
|
t[n] = {
|
|
97
|
-
|
|
98
|
-
...e && {
|
|
111
|
+
...l(r),
|
|
112
|
+
...e && { pseudos: e }
|
|
99
113
|
};
|
|
100
114
|
}
|
|
101
115
|
return Object.keys(t).length ? t : void 0;
|
|
102
|
-
},
|
|
116
|
+
}, f = (e) => {
|
|
103
117
|
if (!e) return;
|
|
104
118
|
let t = {};
|
|
105
119
|
for (let [n, i] of Object.entries(e)) {
|
|
106
|
-
let e = r(i.default), a = c(i.states), o =
|
|
120
|
+
let e = r(i.default), a = c(i.states), o = d(i.variants);
|
|
107
121
|
(e.length || a || o) && (t[n] = {
|
|
108
122
|
...e.length && { default: e },
|
|
109
123
|
...a && { states: a },
|
|
@@ -112,19 +126,21 @@ var e = (e, t, { keepEmpty: n = !1, closeEndsPart: r = !1 } = {}) => {
|
|
|
112
126
|
}
|
|
113
127
|
return Object.keys(t).length ? t : void 0;
|
|
114
128
|
};
|
|
115
|
-
function
|
|
129
|
+
function p(e) {
|
|
116
130
|
if (!e?.attributes || !Object.keys(e.attributes).length) return { attributes: { base: { default: [] } } };
|
|
117
131
|
let t = {};
|
|
118
132
|
for (let n in e.attributes) {
|
|
119
|
-
let i = e.attributes[n], a = c(i.states), o =
|
|
133
|
+
let i = e.attributes[n], a = c(i.states), o = d(i.variants), s = f(i.ancestors), l = u(i.pseudos), p = d(i.conditions);
|
|
120
134
|
t[n] = {
|
|
121
135
|
default: r(i.default),
|
|
122
136
|
...a && { states: a },
|
|
123
137
|
...o && { variants: o },
|
|
124
|
-
...s && { ancestors: s }
|
|
138
|
+
...s && { ancestors: s },
|
|
139
|
+
...l && { pseudos: l },
|
|
140
|
+
...p && { conditions: p }
|
|
125
141
|
};
|
|
126
142
|
}
|
|
127
143
|
return { attributes: t };
|
|
128
144
|
}
|
|
129
145
|
//#endregion
|
|
130
|
-
export {
|
|
146
|
+
export { p as default, s as processCssString };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-style",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.8",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -944,10 +944,10 @@
|
|
|
944
944
|
"build:prod": "vite build && node ../sdk-shared/scripts/generate-exports.mjs"
|
|
945
945
|
},
|
|
946
946
|
"dependencies": {
|
|
947
|
-
"@plitzi/plitzi-ui": "^1.6.
|
|
948
|
-
"@plitzi/sdk-event-bridge": "0.38.
|
|
949
|
-
"@plitzi/sdk-shared": "0.38.
|
|
950
|
-
"@plitzi/sdk-variables": "0.38.
|
|
947
|
+
"@plitzi/plitzi-ui": "^1.6.32",
|
|
948
|
+
"@plitzi/sdk-event-bridge": "0.38.8",
|
|
949
|
+
"@plitzi/sdk-shared": "0.38.8",
|
|
950
|
+
"@plitzi/sdk-variables": "0.38.8",
|
|
951
951
|
"clsx": "^2.1.1",
|
|
952
952
|
"immer": "^11.1.21",
|
|
953
953
|
"zod": "^4.6.5"
|