@plitzi/sdk-style 0.38.6 → 0.38.7
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 +202 -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
|
@@ -4,90 +4,93 @@ import { useCallback as n, useMemo as r } from "react";
|
|
|
4
4
|
import { useCommonStore as i } from "@plitzi/sdk-shared/store";
|
|
5
5
|
import { emptyObject as a } from "@plitzi/sdk-shared/helpers/utils";
|
|
6
6
|
import { get as o, omit as s } from "@plitzi/plitzi-ui/helpers";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { styleTargetRules as c } from "@plitzi/sdk-shared/style/styleTarget";
|
|
8
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
9
|
+
import { baseDefaultValue as u } from "@plitzi/sdk-shared";
|
|
9
10
|
//#region src/components/StyleInspector/StyleInspectorProvider.tsx
|
|
10
|
-
var
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} else e = m && h ? t.variants?.[h].states?.[m] ?? {} : h ? t.variants?.[h]?.default ?? {} : m ? t.states?.[m] ?? {} : t.default ?? {};
|
|
19
|
-
} else e = {};
|
|
20
|
-
return e;
|
|
21
|
-
}, [
|
|
22
|
-
f,
|
|
11
|
+
var d = ({ children: d, componentType: f, selector: p, styleSelector: m = "base", styleState: h, styleVariant: g, styleAncestor: _, stylePseudo: v, styleCondition: y, element: b, inheritData: x, displayMode: S, onChange: C }) => {
|
|
12
|
+
let w = t({ element: b }), [T = a] = i("runtime.sources.variables"), E = n(() => c(p?.attributes[m], {
|
|
13
|
+
styleState: h,
|
|
14
|
+
styleVariant: g,
|
|
15
|
+
styleAncestor: _,
|
|
16
|
+
stylePseudo: v,
|
|
17
|
+
styleCondition: y
|
|
18
|
+
}) ?? {}, [
|
|
23
19
|
p,
|
|
24
20
|
m,
|
|
25
21
|
h,
|
|
26
|
-
g
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
g,
|
|
23
|
+
_,
|
|
24
|
+
v,
|
|
25
|
+
y
|
|
26
|
+
]), D = n((e, t) => {
|
|
27
|
+
if (!(e && typeof t != "string" && typeof t != "number" && t !== void 0 || !e && typeof t != "object" && t !== void 0 || e && o(w, e))) {
|
|
28
|
+
if (!e && t && typeof t == "object" && (t = s(t, Object.keys(w))), !e && p && typeof t == "object") {
|
|
30
29
|
let e = {
|
|
31
|
-
...
|
|
30
|
+
...E(),
|
|
32
31
|
...t
|
|
33
32
|
};
|
|
34
33
|
Object.keys(e).forEach((t) => {
|
|
35
34
|
e[t] === void 0 && delete e[t];
|
|
36
35
|
}), t = e;
|
|
37
36
|
}
|
|
38
|
-
|
|
37
|
+
C?.(e, t);
|
|
39
38
|
}
|
|
40
39
|
}, [
|
|
41
|
-
|
|
40
|
+
w,
|
|
41
|
+
E,
|
|
42
42
|
C,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
]), T = n((e) => Array.isArray(e) ? e.reduce((e, t) => ({
|
|
43
|
+
p
|
|
44
|
+
]), O = n((e) => Array.isArray(e) ? e.reduce((e, t) => ({
|
|
46
45
|
...e,
|
|
47
|
-
[t]: o(
|
|
48
|
-
}), {}) : e ? o(
|
|
46
|
+
[t]: o(u, t)
|
|
47
|
+
}), {}) : e ? o(u, e) : u, []), k = n((e) => {
|
|
49
48
|
if (Array.isArray(e)) {
|
|
50
49
|
let t = e.reduce((e, t) => ({
|
|
51
50
|
...e,
|
|
52
51
|
[t]: void 0
|
|
53
52
|
}), {});
|
|
54
|
-
|
|
55
|
-
} else
|
|
56
|
-
}, [
|
|
57
|
-
componentType:
|
|
58
|
-
selector:
|
|
59
|
-
styleSelector:
|
|
60
|
-
styleState:
|
|
61
|
-
styleVariant:
|
|
62
|
-
styleAncestor:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
D(void 0, t);
|
|
54
|
+
} else D(e);
|
|
55
|
+
}, [D]), A = r(() => ({
|
|
56
|
+
componentType: f,
|
|
57
|
+
selector: p,
|
|
58
|
+
styleSelector: m,
|
|
59
|
+
styleState: h,
|
|
60
|
+
styleVariant: g,
|
|
61
|
+
styleAncestor: _,
|
|
62
|
+
stylePseudo: v,
|
|
63
|
+
styleCondition: y,
|
|
64
|
+
displayMode: S,
|
|
65
|
+
variables: T,
|
|
66
|
+
inheritData: x.style,
|
|
67
|
+
bindingData: w,
|
|
68
|
+
getValues: E,
|
|
69
|
+
setValue: D,
|
|
70
|
+
resetValue: k,
|
|
71
|
+
getDefaultValue: O
|
|
71
72
|
}), [
|
|
72
|
-
d,
|
|
73
73
|
f,
|
|
74
74
|
p,
|
|
75
75
|
m,
|
|
76
76
|
h,
|
|
77
77
|
g,
|
|
78
|
+
_,
|
|
79
|
+
v,
|
|
78
80
|
y,
|
|
79
81
|
S,
|
|
80
|
-
|
|
81
|
-
x,
|
|
82
|
-
C,
|
|
82
|
+
T,
|
|
83
|
+
x.style,
|
|
83
84
|
w,
|
|
84
85
|
E,
|
|
85
|
-
|
|
86
|
+
D,
|
|
87
|
+
k,
|
|
88
|
+
O
|
|
86
89
|
]);
|
|
87
|
-
return /* @__PURE__ */
|
|
88
|
-
value:
|
|
89
|
-
children:
|
|
90
|
+
return /* @__PURE__ */ l(e, {
|
|
91
|
+
value: A,
|
|
92
|
+
children: d
|
|
90
93
|
});
|
|
91
94
|
};
|
|
92
95
|
//#endregion
|
|
93
|
-
export {
|
|
96
|
+
export { d as default };
|
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import i from "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"border-
|
|
10
|
-
"border-
|
|
1
|
+
import { ancestorName as e } from "../../helpers.mjs";
|
|
2
|
+
import { memo as t, useCallback as n } from "react";
|
|
3
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
import a from "clsx";
|
|
5
|
+
var o = t(({ condition: t, active: o = !1, unused: s = !1, onSelect: c, onRemove: l }) => {
|
|
6
|
+
let u = n(() => c?.(t), [t, c]), d = n(() => l?.(t), [t, l]), f = e(t.ancestor), p = s ? `No element this selector dresses sits inside ${f}, so this rule never matches` : `Edit the rules for inside ${f} (${t.label})`;
|
|
7
|
+
return /* @__PURE__ */ i("div", {
|
|
8
|
+
className: a("flex max-w-full items-center overflow-hidden rounded-sm border text-[11px] leading-none", {
|
|
9
|
+
"border-primary-500 bg-primary-500/15 text-primary-700 dark:text-primary-200": o,
|
|
10
|
+
"border-amber-500/70 bg-amber-500/10 text-amber-700 dark:text-amber-300": s && !o,
|
|
11
|
+
"border-gray-300 bg-gray-100 text-zinc-600 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-300": !s && !o
|
|
11
12
|
}),
|
|
12
|
-
children: [/* @__PURE__ */
|
|
13
|
+
children: [/* @__PURE__ */ i("button", {
|
|
13
14
|
type: "button",
|
|
14
15
|
className: "flex min-w-0 items-center gap-1 px-1.5 py-1",
|
|
15
|
-
title:
|
|
16
|
-
onClick:
|
|
16
|
+
title: p,
|
|
17
|
+
onClick: u,
|
|
17
18
|
children: [
|
|
18
|
-
|
|
19
|
+
s && /* @__PURE__ */ r("i", { className: "fas fa-triangle-exclamation" }),
|
|
19
20
|
/* @__PURE__ */ r("span", {
|
|
20
21
|
className: "truncate",
|
|
21
|
-
children:
|
|
22
|
+
children: f
|
|
22
23
|
}),
|
|
23
|
-
/* @__PURE__ */
|
|
24
|
+
/* @__PURE__ */ i("span", {
|
|
24
25
|
className: "opacity-70",
|
|
25
|
-
children: ["· ",
|
|
26
|
+
children: ["· ", t.label]
|
|
26
27
|
})
|
|
27
28
|
]
|
|
28
|
-
}), /* @__PURE__ */
|
|
29
|
+
}), /* @__PURE__ */ r("button", {
|
|
29
30
|
type: "button",
|
|
30
31
|
className: "cursor-pointer border-l border-inherit px-1.5 py-1 hover:bg-red-500/15 hover:text-red-600 dark:hover:text-red-400",
|
|
31
32
|
title: "Remove this rule",
|
|
32
|
-
"aria-label": `Remove the ${
|
|
33
|
-
onClick:
|
|
34
|
-
children: /* @__PURE__ */
|
|
33
|
+
"aria-label": `Remove the ${t.label} rule under ${f}`,
|
|
34
|
+
onClick: d,
|
|
35
|
+
children: /* @__PURE__ */ r("i", { className: "fas fa-xmark" })
|
|
35
36
|
})]
|
|
36
37
|
});
|
|
37
38
|
});
|
|
38
39
|
//#endregion
|
|
39
|
-
export {
|
|
40
|
+
export { o as default };
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { Option } from '@plitzi/plitzi-ui/Select2';
|
|
2
|
-
import { DisplayMode, Element, Schema, Style, StyleAncestors, StyleItem, StyleState } from '@plitzi/sdk-shared';
|
|
2
|
+
import { DisplayMode, Element, Schema, Style, StyleAncestors, StyleBlock, StyleItem, StyleState } from '@plitzi/sdk-shared';
|
|
3
3
|
/** The states a selector can react to, as the state picker offers them — from the one list every layer reads. */
|
|
4
4
|
export declare const STYLE_STATE_OPTIONS: Option[];
|
|
5
|
+
/** How an ancestor key reads in the inspector: its class, or the parent it stands for. */
|
|
6
|
+
export declare const ancestorName: (ancestor: string) => string;
|
|
7
|
+
/** The pseudo-element picker's options, the ones the block already dresses saying so. */
|
|
8
|
+
export declare const pseudoOptions: (block?: StyleBlock) => Option[];
|
|
9
|
+
/**
|
|
10
|
+
* The condition picker's options: reduced motion and its opposite, then every container query the block already holds.
|
|
11
|
+
* A new container query is typed in (`container (max-width: 30rem)`) and kept only in the spelling
|
|
12
|
+
* `canonicalCondition` reads.
|
|
13
|
+
*/
|
|
14
|
+
export declare const conditionOptions: (block?: StyleBlock) => Option[];
|
|
5
15
|
/**
|
|
6
16
|
* The classes an element's ancestors carry, closest first: what an "ancestor" condition can name. Only the base slot
|
|
7
17
|
* counts — a slot's class sits on an inner node of that ancestor, not around the element.
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { STYLE_MOTION_CONDITIONS as e, conditionLabel as t } from "@plitzi/sdk-shared/style/styleConditions";
|
|
2
|
+
import { STYLE_PSEUDOS as n, STYLE_PSEUDO_LABELS as r } from "@plitzi/sdk-shared/style/stylePseudos";
|
|
3
|
+
import { PARENT_ANCESTOR as i, STYLE_STATES as a, STYLE_STATE_LABELS as o, inCascadeOrder as s, isKnownState as c, isParentAncestor as l } from "@plitzi/sdk-shared/style/styleStates";
|
|
2
4
|
//#region src/components/StyleInspector/helpers.ts
|
|
3
|
-
var
|
|
4
|
-
label:
|
|
5
|
+
var u = a.map((e) => ({
|
|
6
|
+
label: o[e],
|
|
5
7
|
value: e
|
|
6
|
-
})),
|
|
8
|
+
})), d = (e) => l(e) ? "the element around it" : `.${e}`, f = (e) => n.map((t) => ({
|
|
9
|
+
label: e?.pseudos?.[t] ? `${r[t]} (set)` : r[t],
|
|
10
|
+
value: t
|
|
11
|
+
})), p = (n) => [.../* @__PURE__ */ new Set([...e, ...Object.keys(n?.conditions ?? {})])].map((e) => ({
|
|
12
|
+
label: n?.conditions?.[e] ? `${t(e)} (set)` : t(e),
|
|
13
|
+
value: e
|
|
14
|
+
})), m = (e, t) => {
|
|
7
15
|
let n = /* @__PURE__ */ new Set(), r = t?.definition.parentId, i = r ? e[r] : void 0;
|
|
8
16
|
for (; i;) {
|
|
9
17
|
for (let e of i.definition.styleSelectors.base.split(" ")) e && n.add(e);
|
|
@@ -11,44 +19,48 @@ var i = e.map((e) => ({
|
|
|
11
19
|
i = t ? e[t] : void 0;
|
|
12
20
|
}
|
|
13
21
|
return [...n];
|
|
14
|
-
},
|
|
15
|
-
...
|
|
22
|
+
}, h = (e) => !!e && Object.keys(e).length > 0, g = (e) => s(e ?? {}).filter(([, e]) => h(e)).map(([e]) => e).filter(c), _ = (e = {}) => Object.entries(e).flatMap(([e, { default: t, states: n, variants: r }]) => [
|
|
23
|
+
...h(t) ? [{
|
|
16
24
|
ancestor: e,
|
|
17
25
|
label: "inside"
|
|
18
26
|
}] : [],
|
|
19
|
-
...
|
|
27
|
+
...g(n).map((t) => ({
|
|
20
28
|
ancestor: e,
|
|
21
29
|
state: t,
|
|
22
30
|
label: t
|
|
23
31
|
})),
|
|
24
|
-
...Object.entries(r ?? {}).flatMap(([t, n]) => [...
|
|
32
|
+
...Object.entries(r ?? {}).flatMap(([t, n]) => [...h(n.default) ? [{
|
|
25
33
|
ancestor: e,
|
|
26
34
|
variant: t,
|
|
27
35
|
label: t
|
|
28
|
-
}] : [], ...
|
|
36
|
+
}] : [], ...g(n.states).map((n) => ({
|
|
29
37
|
ancestor: e,
|
|
30
38
|
variant: t,
|
|
31
39
|
state: n,
|
|
32
40
|
label: `${t}:${n}`
|
|
33
41
|
}))])
|
|
34
|
-
]),
|
|
35
|
-
let n =
|
|
36
|
-
return [.../* @__PURE__ */ new Set([
|
|
37
|
-
|
|
42
|
+
]), v = (e, t = {}) => {
|
|
43
|
+
let n = _(t);
|
|
44
|
+
return [.../* @__PURE__ */ new Set([
|
|
45
|
+
i,
|
|
46
|
+
...e,
|
|
47
|
+
...Object.keys(t)
|
|
48
|
+
])].map((e) => {
|
|
49
|
+
let t = n.filter((t) => t.ancestor === e).map((e) => e.label), r = d(e);
|
|
38
50
|
return {
|
|
39
|
-
label: t.length ?
|
|
51
|
+
label: t.length ? `${r} — ${t.join(", ")}` : r,
|
|
40
52
|
value: e
|
|
41
53
|
};
|
|
42
54
|
});
|
|
43
|
-
},
|
|
44
|
-
let n = new Set(Object.values(t.attributes).flatMap((e) => Object.keys(e.ancestors ?? {})));
|
|
55
|
+
}, y = (e, t) => Object.values(e).filter((e) => t.type === "element" ? e.definition.type === (t.componentType ?? t.name) : Object.values(e.definition.styleSelectors).some((e) => e.split(" ").includes(t.name))), b = (e, t) => {
|
|
56
|
+
let n = new Set(Object.values(t.attributes).flatMap((e) => Object.keys(e.ancestors ?? {})).filter((e) => !l(e)));
|
|
45
57
|
if (!n.size) return n;
|
|
46
|
-
for (let r of
|
|
58
|
+
for (let r of y(e, t)) if (m(e, r).forEach((e) => n.delete(e)), !n.size) break;
|
|
47
59
|
return n;
|
|
48
|
-
},
|
|
60
|
+
}, x = (e, t, n) => Object.keys(e).flatMap((r) => Object.entries(e[r][t]?.attributes ?? {}).flatMap(([e, t]) => Object.keys(t.ancestors ?? {}).filter((e) => n.has(e)).map((t) => ({
|
|
49
61
|
displayMode: r,
|
|
50
62
|
styleSelector: e,
|
|
51
63
|
styleAncestor: t
|
|
52
64
|
}))));
|
|
53
65
|
//#endregion
|
|
54
|
-
export {
|
|
66
|
+
export { u as STYLE_STATE_OPTIONS, m as ancestorClasses, _ as ancestorConditions, d as ancestorName, v as ancestorOptions, x as ancestorRemovals, p as conditionOptions, f as pseudoOptions, b as unusedAncestors };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Element, StyleState } from '@plitzi/sdk-shared';
|
|
1
|
+
import { Element, StylePseudo, StyleState } from '@plitzi/sdk-shared';
|
|
2
2
|
export type UseStyleInheritProps = {
|
|
3
3
|
element?: Element;
|
|
4
4
|
componentType?: string;
|
|
@@ -8,6 +8,8 @@ export type UseStyleInheritProps = {
|
|
|
8
8
|
styleState?: StyleState;
|
|
9
9
|
styleVariant?: string;
|
|
10
10
|
styleAncestor?: string;
|
|
11
|
+
stylePseudo?: StylePseudo;
|
|
12
|
+
styleCondition?: string;
|
|
11
13
|
};
|
|
12
|
-
declare const useStyleInherit: ({ element, componentType, componentSubType, selector, styleSelector, styleState, styleVariant, styleAncestor }: UseStyleInheritProps) => import('../../..').InheritData;
|
|
14
|
+
declare const useStyleInherit: ({ element, componentType, componentSubType, selector, styleSelector, styleState, styleVariant, styleAncestor, stylePseudo, styleCondition }: UseStyleInheritProps) => import('../../..').InheritData;
|
|
13
15
|
export default useStyleInherit;
|
|
@@ -3,16 +3,18 @@ import { use as t, useMemo as n } from "react";
|
|
|
3
3
|
import { useBuilderStore as r } from "@plitzi/sdk-shared/store";
|
|
4
4
|
import i from "@plitzi/sdk-shared/elements/ComponentContext";
|
|
5
5
|
//#region src/components/StyleInspector/hooks/useStyleInherit.ts
|
|
6
|
-
var a = ({ element: a, componentType: o, componentSubType: s, selector: c, styleSelector: l = "base", styleState: u, styleVariant: d, styleAncestor: f }) => {
|
|
7
|
-
let [[
|
|
6
|
+
var a = ({ element: a, componentType: o, componentSubType: s, selector: c, styleSelector: l = "base", styleState: u, styleVariant: d, styleAncestor: f, stylePseudo: p, styleCondition: m }) => {
|
|
7
|
+
let [[h, g]] = r(["schema.flat", "style.platform"]), { componentDefinitions: _ } = t(i);
|
|
8
8
|
return n(() => {
|
|
9
9
|
let t = [], n = [], r = (a?.definition.styleSelectors[l] ?? "").split(" ");
|
|
10
|
-
return c && r.length > 1 && t.push(c), e(a, o,
|
|
10
|
+
return c && r.length > 1 && t.push(c), e(a, o, h, g, _.current, {
|
|
11
11
|
componentSubType: s,
|
|
12
12
|
styleSelector: l,
|
|
13
13
|
styleState: u,
|
|
14
14
|
styleVariant: d,
|
|
15
15
|
styleAncestor: f,
|
|
16
|
+
stylePseudo: p,
|
|
17
|
+
styleCondition: m,
|
|
16
18
|
includeSelf: r.length > 1,
|
|
17
19
|
skipSelectors: t,
|
|
18
20
|
addSelectors: n
|
|
@@ -22,13 +24,15 @@ var a = ({ element: a, componentType: o, componentSubType: s, selector: c, style
|
|
|
22
24
|
l,
|
|
23
25
|
c,
|
|
24
26
|
o,
|
|
25
|
-
p,
|
|
26
|
-
m,
|
|
27
27
|
h,
|
|
28
|
+
g,
|
|
29
|
+
_,
|
|
28
30
|
s,
|
|
29
31
|
u,
|
|
30
32
|
d,
|
|
31
|
-
f
|
|
33
|
+
f,
|
|
34
|
+
p,
|
|
35
|
+
m
|
|
32
36
|
]);
|
|
33
37
|
};
|
|
34
38
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentDefinition, DisplayMode, Element, Schema, Style, StyleItem, StyleState, StyleValue } from '@plitzi/sdk-shared';
|
|
1
|
+
import { ComponentDefinition, DisplayMode, Element, Schema, Style, StyleItem, StylePseudo, StyleState, StyleValue } from '@plitzi/sdk-shared';
|
|
2
2
|
export type InheritData = {
|
|
3
3
|
tree: {
|
|
4
4
|
name: string;
|
|
@@ -115,6 +115,8 @@ declare const calculateInheriting: (element: Element | undefined, componentType:
|
|
|
115
115
|
styleState?: StyleState;
|
|
116
116
|
styleVariant?: string;
|
|
117
117
|
styleAncestor?: string;
|
|
118
|
+
stylePseudo?: StylePseudo;
|
|
119
|
+
styleCondition?: string;
|
|
118
120
|
includeSelf?: boolean;
|
|
119
121
|
skipSelectors?: string[];
|
|
120
122
|
addSelectors?: string[];
|
|
@@ -38,39 +38,64 @@ var r = (e, t) => {
|
|
|
38
38
|
isAncestor: !1,
|
|
39
39
|
isDefault: !0
|
|
40
40
|
};
|
|
41
|
-
}, o = (e, t, n
|
|
42
|
-
let a = e[t];
|
|
43
|
-
if (!
|
|
44
|
-
let
|
|
45
|
-
if (
|
|
46
|
-
let e =
|
|
41
|
+
}, o = (e, t, n) => {
|
|
42
|
+
let { styleState: r, styleVariant: i, styleAncestor: a, stylePseudo: o, styleCondition: s } = n, c = e[t];
|
|
43
|
+
if (!c) return {};
|
|
44
|
+
let l = c.default ?? {};
|
|
45
|
+
if (a) {
|
|
46
|
+
let e = c.ancestors?.[a], t = i ? e?.variants?.[i] : void 0, n = r ? (t ?? e)?.states?.[r] : void 0;
|
|
47
47
|
return {
|
|
48
|
-
...
|
|
48
|
+
...l,
|
|
49
49
|
...e?.default,
|
|
50
50
|
...t?.default,
|
|
51
|
-
...
|
|
51
|
+
...n
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
if (o) {
|
|
55
|
+
let e = c.pseudos?.[o], t = ((s ? c.conditions?.[s] : void 0) ?? (i ? c.variants?.[i] : void 0))?.pseudos?.[o];
|
|
56
|
+
return {
|
|
57
|
+
...e?.default,
|
|
58
|
+
...r ? e?.states?.[r] : {},
|
|
59
|
+
...t?.default,
|
|
60
|
+
...r ? t?.states?.[r] : {}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
let u = r ? c.states?.[r] ?? {} : {};
|
|
64
|
+
if (s) {
|
|
65
|
+
let e = c.conditions?.[s];
|
|
66
|
+
return {
|
|
67
|
+
...l,
|
|
68
|
+
...u,
|
|
69
|
+
...e?.default,
|
|
70
|
+
...r ? e?.states?.[r] : {}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
let d = i ? c.variants?.[i]?.default ?? {} : {}, f = i && r ? c.variants?.[i]?.states?.[r] ?? {} : {};
|
|
55
74
|
return {
|
|
56
|
-
...
|
|
57
|
-
...
|
|
58
|
-
...
|
|
59
|
-
...
|
|
75
|
+
...l,
|
|
76
|
+
...d,
|
|
77
|
+
...u,
|
|
78
|
+
...f
|
|
60
79
|
};
|
|
61
|
-
}, s = (e, t, n
|
|
62
|
-
let { componentSubType: f, styleSelector: p = "base", styleState: m, styleVariant: h, styleAncestor: g,
|
|
80
|
+
}, s = (e, t, n) => o(e.attributes, t, n), c = (t, o, c, l, u = {}, d = {}) => {
|
|
81
|
+
let { componentSubType: f, styleSelector: p = "base", styleState: m, styleVariant: h, styleAncestor: g, stylePseudo: _, styleCondition: v, includeSelf: y = !1, skipSelectors: b = [], addSelectors: x = [] } = d, S = {
|
|
82
|
+
styleState: m,
|
|
83
|
+
styleVariant: h,
|
|
84
|
+
styleAncestor: g,
|
|
85
|
+
stylePseudo: _,
|
|
86
|
+
styleCondition: v
|
|
87
|
+
}, C = {
|
|
63
88
|
tree: [],
|
|
64
89
|
style: {},
|
|
65
90
|
parentStyle: {}
|
|
66
|
-
},
|
|
91
|
+
}, w = t ? r(c, t) : [], T = /* @__PURE__ */ new Set();
|
|
67
92
|
for (let e of Object.keys(l)) {
|
|
68
93
|
let n = l[e];
|
|
69
94
|
if (n) {
|
|
70
95
|
if (!t && !o) {
|
|
71
|
-
for (let t of
|
|
96
|
+
for (let t of x) {
|
|
72
97
|
let r = n[t];
|
|
73
|
-
r &&
|
|
98
|
+
r && C.tree.push({
|
|
74
99
|
name: t,
|
|
75
100
|
displayMode: e,
|
|
76
101
|
attributes: r.attributes,
|
|
@@ -88,8 +113,8 @@ var r = (e, t) => {
|
|
|
88
113
|
parentId: void 0
|
|
89
114
|
},
|
|
90
115
|
attributes: {}
|
|
91
|
-
}, o, n, p,
|
|
92
|
-
for (let n of t)
|
|
116
|
+
}, o, n, p, x);
|
|
117
|
+
for (let n of t) b.includes(n.name) || C.tree.push({
|
|
93
118
|
name: n.name,
|
|
94
119
|
displayMode: e,
|
|
95
120
|
attributes: n.attributes,
|
|
@@ -97,16 +122,16 @@ var r = (e, t) => {
|
|
|
97
122
|
isAncestor: !1
|
|
98
123
|
});
|
|
99
124
|
let r = a(o, f, p, u);
|
|
100
|
-
r &&
|
|
125
|
+
r && C.tree.push({
|
|
101
126
|
...r,
|
|
102
127
|
displayMode: e
|
|
103
128
|
});
|
|
104
129
|
continue;
|
|
105
130
|
}
|
|
106
|
-
for (let r of
|
|
107
|
-
let s = t?.definition.parentId === r.id, c = r.id !== t?.id, l = i(r, r.definition.type === o ? o : void 0, n, p,
|
|
108
|
-
!
|
|
109
|
-
for (let t of l) (!
|
|
131
|
+
for (let r of w) {
|
|
132
|
+
let s = t?.definition.parentId === r.id, c = r.id !== t?.id, l = i(r, r.definition.type === o ? o : void 0, n, p, x);
|
|
133
|
+
!y && !c && !m && !h && Object.keys(l).length && (l = l.filter((e) => e.type === "element"));
|
|
134
|
+
for (let t of l) (!b.includes(t.name) || c) && C.tree.push({
|
|
110
135
|
name: t.name,
|
|
111
136
|
displayMode: e,
|
|
112
137
|
attributes: t.attributes,
|
|
@@ -116,7 +141,7 @@ var r = (e, t) => {
|
|
|
116
141
|
isDefault: !1
|
|
117
142
|
});
|
|
118
143
|
let d = a(r.definition.type, r.attributes.subType, p, u);
|
|
119
|
-
d && !
|
|
144
|
+
d && !T.has(r.definition.type) && (T.add(r.definition.type), C.tree.push({
|
|
120
145
|
...d,
|
|
121
146
|
displayMode: e,
|
|
122
147
|
isParent: s,
|
|
@@ -125,23 +150,23 @@ var r = (e, t) => {
|
|
|
125
150
|
}
|
|
126
151
|
}
|
|
127
152
|
}
|
|
128
|
-
let
|
|
129
|
-
for (let t of
|
|
130
|
-
let r = s(t, p,
|
|
131
|
-
if (r && Object.keys(r).length && ((t.isAncestor || t.isDefault && t.componentType !== o) && (r = n(r, e)), Object.keys(r).length)) for (let e of Object.keys(r))
|
|
153
|
+
let E = {};
|
|
154
|
+
for (let t of C.tree) {
|
|
155
|
+
let r = s(t, p, S);
|
|
156
|
+
if (r && Object.keys(r).length && ((t.isAncestor || t.isDefault && t.componentType !== o) && (r = n(r, e)), Object.keys(r).length)) for (let e of Object.keys(r)) E[e] || (E[e] = []), E[e].push({
|
|
132
157
|
key: t.name,
|
|
133
158
|
value: r[e],
|
|
134
159
|
displayMode: t.displayMode
|
|
135
160
|
});
|
|
136
161
|
}
|
|
137
|
-
let
|
|
162
|
+
let D = C.tree.filter((e) => e.isParent).reduce((e, t) => ({
|
|
138
163
|
...e,
|
|
139
|
-
...s(t, p,
|
|
164
|
+
...s(t, p, S)
|
|
140
165
|
}), {});
|
|
141
166
|
return {
|
|
142
|
-
...
|
|
143
|
-
style:
|
|
144
|
-
parentStyle:
|
|
167
|
+
...C,
|
|
168
|
+
style: E,
|
|
169
|
+
parentStyle: D
|
|
145
170
|
};
|
|
146
171
|
};
|
|
147
172
|
//#endregion
|