@plitzi/sdk-style 0.36.1 → 0.37.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/CHANGELOG.md +72 -0
- package/dist/StyleMap/StyleMap.d.ts +5 -21
- package/dist/StyleMap/helpers/isValueValid.d.ts +1 -0
- package/dist/StyleMap/helpers/isValueValid.mjs +3 -3
- package/dist/StyleMap/helpers/utils.d.ts +2 -2
- package/dist/StyleMap/helpers/utils.mjs +43 -28
- package/dist/StyleMap/methods/addSelector.d.ts +2 -7
- package/dist/StyleMap/methods/addSelector.mjs +4 -4
- package/dist/StyleMap/methods/updateSelector.d.ts +2 -5
- package/dist/StyleMap/methods/updateSelector.mjs +2 -2
- package/dist/StyleReducer.d.ts +3 -11
- package/dist/components/Selector/Selector.mjs +149 -125
- package/dist/components/Selector/SelectorHelper.d.ts +25 -0
- package/dist/components/Selector/SelectorHelper.mjs +43 -2
- package/dist/components/StyleInspector/Inspector.d.ts +2 -1
- package/dist/components/StyleInspector/Inspector.mjs +92 -87
- package/dist/components/StyleInspector/StyleInspector.mjs +240 -169
- package/dist/components/StyleInspector/StyleInspectorContext.d.ts +1 -0
- package/dist/components/StyleInspector/StyleInspectorProvider.d.ts +2 -1
- package/dist/components/StyleInspector/StyleInspectorProvider.mjs +37 -31
- package/dist/components/StyleInspector/categories/Others/Others.mjs +58 -48
- package/dist/components/StyleInspector/categories/Others/OthersScrollbar.d.ts +9 -0
- package/dist/components/StyleInspector/categories/Others/OthersScrollbar.mjs +36 -0
- package/dist/components/StyleInspector/categories/Typography/Typography.mjs +29 -45
- package/dist/components/StyleInspector/categories/Typography/TypographyFigures.d.ts +13 -0
- package/dist/components/StyleInspector/categories/Typography/TypographyFigures.mjs +61 -0
- package/dist/components/StyleInspector/components/AncestorRules/AncestorRuleChip.d.ts +10 -0
- package/dist/components/StyleInspector/components/AncestorRules/AncestorRuleChip.mjs +39 -0
- package/dist/components/StyleInspector/components/AncestorRules/AncestorRules.d.ts +14 -0
- package/dist/components/StyleInspector/components/AncestorRules/AncestorRules.mjs +36 -0
- package/dist/components/StyleInspector/components/AncestorRules/index.d.ts +3 -0
- package/dist/components/StyleInspector/components/AncestorRules/index.mjs +5 -0
- package/dist/components/StyleInspector/helpers.d.ts +36 -0
- package/dist/components/StyleInspector/helpers.mjs +54 -0
- package/dist/components/StyleInspector/hooks/useStyleInherit.d.ts +2 -1
- package/dist/components/StyleInspector/hooks/useStyleInherit.mjs +7 -5
- package/dist/components/StyleManager/ManagerSelector.d.ts +3 -2
- package/dist/components/StyleManager/ManagerSelector.mjs +114 -86
- package/dist/components/StyleManager/StyleManager.mjs +1 -0
- package/dist/components/StyleManager/StyleSelectorTag.d.ts +4 -1
- package/dist/components/StyleManager/StyleSelectorTag.mjs +36 -22
- package/dist/helpers/calculateInheriting.d.ts +1 -0
- package/dist/helpers/calculateInheriting.mjs +38 -28
- package/dist/helpers/processSelector.mjs +44 -21
- package/dist/helpers/processSelectorAttributes.d.ts +14 -6
- package/dist/helpers/processSelectorAttributes.mjs +38 -22
- package/package.json +18 -6
|
@@ -3,15 +3,16 @@ 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 }) => {
|
|
7
|
-
let [[
|
|
6
|
+
var a = ({ element: a, componentType: o, componentSubType: s, selector: c, styleSelector: l = "base", styleState: u, styleVariant: d, styleAncestor: f }) => {
|
|
7
|
+
let [[p, m]] = r(["schema.flat", "style.platform"]), { componentDefinitions: h } = 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, p, m, h.current, {
|
|
11
11
|
componentSubType: s,
|
|
12
12
|
styleSelector: l,
|
|
13
13
|
styleState: u,
|
|
14
14
|
styleVariant: d,
|
|
15
|
+
styleAncestor: f,
|
|
15
16
|
includeSelf: r.length > 1,
|
|
16
17
|
skipSelectors: t,
|
|
17
18
|
addSelectors: n
|
|
@@ -21,12 +22,13 @@ var a = ({ element: a, componentType: o, componentSubType: s, selector: c, style
|
|
|
21
22
|
l,
|
|
22
23
|
c,
|
|
23
24
|
o,
|
|
24
|
-
f,
|
|
25
25
|
p,
|
|
26
26
|
m,
|
|
27
|
+
h,
|
|
27
28
|
s,
|
|
28
29
|
u,
|
|
29
|
-
d
|
|
30
|
+
d,
|
|
31
|
+
f
|
|
30
32
|
]);
|
|
31
33
|
};
|
|
32
34
|
//#endregion
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { DisplayMode, Element, StyleItem } from '@plitzi/sdk-shared';
|
|
1
|
+
import { DisplayMode, Element, Schema, StyleItem } from '@plitzi/sdk-shared';
|
|
2
2
|
import { Dispatch, SetStateAction } from 'react';
|
|
3
3
|
export type ManagerSelectorProps = {
|
|
4
4
|
displayMode: DisplayMode;
|
|
5
|
+
flat: Schema['flat'];
|
|
5
6
|
flatList: Element[];
|
|
6
7
|
selected?: string;
|
|
7
8
|
onSelect?: Dispatch<SetStateAction<StyleItem | undefined>>;
|
|
8
9
|
selectors?: Record<string, StyleItem>;
|
|
9
10
|
};
|
|
10
|
-
declare const _default: import('react').MemoExoticComponent<({ displayMode, flatList, selectors, selected, onSelect }: ManagerSelectorProps) => import("react").JSX.Element>;
|
|
11
|
+
declare const _default: import('react').MemoExoticComponent<({ displayMode, flat, flatList, selectors, selected, onSelect }: ManagerSelectorProps) => import("react").JSX.Element>;
|
|
11
12
|
export default _default;
|
|
@@ -1,157 +1,185 @@
|
|
|
1
1
|
import e from "./StyleSelectorTag.mjs";
|
|
2
2
|
import t from "../../models/SelectorForm/index.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import d from "
|
|
8
|
-
import f from "@plitzi/
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import _ from "@plitzi/plitzi-ui/
|
|
12
|
-
import v from "@plitzi/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
import { ancestorRemovals as n, unusedAncestors as r } from "../StyleInspector/helpers.mjs";
|
|
4
|
+
import { memo as i, use as a, useCallback as o, useMemo as s, useState as c } from "react";
|
|
5
|
+
import { useBuilderStore as l } from "@plitzi/sdk-shared/store";
|
|
6
|
+
import { produce as ee } from "immer";
|
|
7
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
|
+
import f from "@plitzi/plitzi-ui/Button";
|
|
9
|
+
import p from "@plitzi/plitzi-ui/Modal";
|
|
10
|
+
import m from "@plitzi/sdk-shared/elements/ComponentContext";
|
|
11
|
+
import { get as h, isEmpty as g, set as _ } from "@plitzi/plitzi-ui/helpers/lodash";
|
|
12
|
+
import v from "@plitzi/plitzi-ui/hooks/useDisclosure";
|
|
13
|
+
import y from "@plitzi/plitzi-ui/Input";
|
|
14
|
+
import b from "@plitzi/sdk-shared/builder/contexts/BuilderContext";
|
|
15
|
+
var x = i(({ displayMode: i, flat: x, flatList: S, selectors: C, selected: w, onSelect: T }) => {
|
|
16
|
+
let E = s(() => Object.values(C ?? {}), [C]), [D, O] = c(""), [k, A] = c([]), { builderHandler: j } = a(b), [M] = l("style.platform"), { components: te } = a(m), ne = s(() => E.filter((e) => !!e.componentType).map((e) => e.componentType), [E]), N = s(() => {
|
|
17
|
+
let e = E;
|
|
18
|
+
return g(D) || (e = E.filter((e) => e.name.toLowerCase().includes(D.toLowerCase()))), e.sort((e, t) => {
|
|
17
19
|
let n = Number(e.type === "element"), r = Number(t.type === "element");
|
|
18
20
|
return n === r ? e.name.localeCompare(t.name) : r - n;
|
|
19
21
|
});
|
|
20
|
-
}, [
|
|
22
|
+
}, [E, D]), P = o((e) => O(e), [O]), F = o((e, t) => {
|
|
21
23
|
if (t) {
|
|
22
24
|
if (t.mode === "default") {
|
|
23
25
|
let { name: e } = t;
|
|
24
|
-
|
|
26
|
+
j("styleAddSelector", i, e, "class", void 0, void 0, {
|
|
25
27
|
styleSelector: void 0,
|
|
26
28
|
componentType: void 0
|
|
27
29
|
});
|
|
28
30
|
} else {
|
|
29
31
|
let { componentType: e } = t;
|
|
30
|
-
|
|
32
|
+
j("styleAddSelector", i, e, "element", void 0, void 0, {
|
|
31
33
|
styleSelector: void 0,
|
|
32
34
|
componentType: e
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
|
-
}, [
|
|
38
|
+
}, [j, i]), [I, L, R, z] = v({
|
|
37
39
|
id: "add-selector",
|
|
38
|
-
onClose:
|
|
39
|
-
}),
|
|
40
|
-
|
|
41
|
-
}, [
|
|
42
|
-
if (!t || !
|
|
43
|
-
let
|
|
40
|
+
onClose: F
|
|
41
|
+
}), B = o((e) => {
|
|
42
|
+
T?.((t) => t?.name === e ? void 0 : E.find((t) => t.name === e));
|
|
43
|
+
}, [T, E]), V = o((e, t) => t ? Object.values(h(e, "definition.styleSelectors", {})).find((e) => (t.includes(":") && (t = h(t.split(":"), "0", t)), e && t && e.split(" ").includes(t))) : [], []), H = o((e, t, n) => {
|
|
44
|
+
if (!t || !n || n.length === 0) return;
|
|
45
|
+
let r = new Set(n), a = S.filter((e) => n.some((t) => V(e, t))).map((e) => ee(e, (t) => {
|
|
44
46
|
Object.keys(e.definition.styleSelectors).forEach((e) => {
|
|
45
|
-
|
|
47
|
+
r.has(h(t, `definition.styleSelectors.${e}`, "")) && _(t, `definition.styleSelectors.${e}`, "");
|
|
46
48
|
});
|
|
47
49
|
}));
|
|
48
|
-
a.length > 0 &&
|
|
50
|
+
a.length > 0 && j("schemaUpdateElements", a), j("styleRemoveSelectors", i, n), A((e) => e.filter((e) => !r.has(e))), T?.((e) => e && r.has(e.name) ? void 0 : e);
|
|
49
51
|
}, [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
]), [
|
|
52
|
+
j,
|
|
53
|
+
i,
|
|
54
|
+
V,
|
|
55
|
+
S,
|
|
56
|
+
T
|
|
57
|
+
]), [U, W, G, K, , q] = v({
|
|
56
58
|
id: "delete-selector",
|
|
57
|
-
onClose:
|
|
58
|
-
}),
|
|
59
|
+
onClose: H
|
|
60
|
+
}), J = o((e) => G(void 0, [e]), [G]), Y = o((e) => A((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]), []), X = o(() => A([]), []), re = o(() => G(void 0, k), [G, k]), Z = Array.isArray(q) ? q.length : 0, ie = s(() => N.reduce((e, t) => ({
|
|
59
61
|
...e,
|
|
60
|
-
[t.name]:
|
|
62
|
+
[t.name]: S.filter((e) => V(e, t.name)).length
|
|
61
63
|
}), {}), [
|
|
64
|
+
N,
|
|
65
|
+
S,
|
|
66
|
+
V
|
|
67
|
+
]), Q = s(() => Object.fromEntries(E.map((e) => [e.name, {
|
|
68
|
+
count: new Set(Object.values(e.attributes).flatMap((e) => Object.keys(e.ancestors ?? {}))).size,
|
|
69
|
+
unused: r(x, e)
|
|
70
|
+
}])), [x, E]), $ = s(() => Object.values(Q).reduce((e, { unused: t }) => e + t.size, 0), [Q]), ae = `${$} unused ancestor ${$ === 1 ? "rule" : "rules"}`, oe = o(() => {
|
|
71
|
+
for (let [e, { unused: t }] of Object.entries(Q)) for (let r of n(M, e, t)) j("styleUpdateSelector", r.displayMode, e, void 0, void 0, {
|
|
72
|
+
styleSelector: r.styleSelector,
|
|
73
|
+
styleAncestor: r.styleAncestor,
|
|
74
|
+
componentType: M[r.displayMode][e].componentType
|
|
75
|
+
});
|
|
76
|
+
}, [
|
|
77
|
+
Q,
|
|
62
78
|
j,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return /* @__PURE__ */ l("div", {
|
|
79
|
+
M
|
|
80
|
+
]), se = o(() => void K(void 0, !1), [K]), ce = o(() => void K(void 0, !0), [K]);
|
|
81
|
+
return /* @__PURE__ */ d("div", {
|
|
67
82
|
className: "flex max-w-[350px] grow basis-0 flex-col gap-2 overflow-auto border-r border-gray-300 pt-2 pr-2 dark:border-zinc-700",
|
|
68
83
|
children: [
|
|
69
|
-
/* @__PURE__ */
|
|
84
|
+
/* @__PURE__ */ d(f, {
|
|
70
85
|
intent: "primary",
|
|
71
86
|
size: "sm",
|
|
72
87
|
className: "w-full",
|
|
73
88
|
iconPlacement: "before",
|
|
74
|
-
onClick:
|
|
75
|
-
children: [/* @__PURE__ */
|
|
89
|
+
onClick: R,
|
|
90
|
+
children: [/* @__PURE__ */ u(f.Icon, {
|
|
76
91
|
icon: "fas fa-tint",
|
|
77
92
|
size: "md",
|
|
78
93
|
className: "text-base"
|
|
79
94
|
}), "New Selector"]
|
|
80
95
|
}),
|
|
81
|
-
/* @__PURE__ */
|
|
96
|
+
/* @__PURE__ */ u(y, {
|
|
82
97
|
placeholder: "Search Selector",
|
|
83
|
-
value:
|
|
84
|
-
onChange:
|
|
98
|
+
value: D,
|
|
99
|
+
onChange: P,
|
|
85
100
|
size: "xs"
|
|
86
101
|
}),
|
|
87
|
-
|
|
102
|
+
$ > 0 && /* @__PURE__ */ d("div", {
|
|
103
|
+
className: "flex items-center justify-between gap-2 rounded-sm bg-amber-500/10 px-2 py-1",
|
|
104
|
+
children: [/* @__PURE__ */ d("span", {
|
|
105
|
+
className: "text-xs text-amber-700 dark:text-amber-300",
|
|
106
|
+
children: [/* @__PURE__ */ u("i", { className: "fas fa-triangle-exclamation mr-1" }), ae]
|
|
107
|
+
}), /* @__PURE__ */ u(f, {
|
|
108
|
+
size: "xs",
|
|
109
|
+
onClick: oe,
|
|
110
|
+
children: "Clean up"
|
|
111
|
+
})]
|
|
112
|
+
}),
|
|
113
|
+
k.length > 0 && /* @__PURE__ */ d("div", {
|
|
88
114
|
className: "bg-secondary-50 dark:bg-secondary-900/30 flex items-center justify-between gap-2 rounded-sm px-2 py-1",
|
|
89
|
-
children: [/* @__PURE__ */
|
|
115
|
+
children: [/* @__PURE__ */ d("span", {
|
|
90
116
|
className: "text-xs text-zinc-600 dark:text-zinc-300",
|
|
91
|
-
children: [
|
|
92
|
-
}), /* @__PURE__ */
|
|
117
|
+
children: [k.length, " selected"]
|
|
118
|
+
}), /* @__PURE__ */ d("div", {
|
|
93
119
|
className: "flex gap-1",
|
|
94
|
-
children: [/* @__PURE__ */
|
|
120
|
+
children: [/* @__PURE__ */ u(f, {
|
|
95
121
|
size: "xs",
|
|
96
|
-
onClick:
|
|
122
|
+
onClick: X,
|
|
97
123
|
children: "Clear"
|
|
98
|
-
}), /* @__PURE__ */
|
|
124
|
+
}), /* @__PURE__ */ d(f, {
|
|
99
125
|
intent: "danger",
|
|
100
126
|
size: "xs",
|
|
101
127
|
iconPlacement: "before",
|
|
102
|
-
onClick:
|
|
103
|
-
children: [/* @__PURE__ */
|
|
128
|
+
onClick: re,
|
|
129
|
+
children: [/* @__PURE__ */ u(f.Icon, { icon: "fas fa-trash" }), "Delete"]
|
|
104
130
|
})]
|
|
105
131
|
})]
|
|
106
132
|
}),
|
|
107
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ u("div", {
|
|
108
134
|
className: "flex grow basis-0 flex-col overflow-y-auto",
|
|
109
|
-
children:
|
|
135
|
+
children: N.map((t) => {
|
|
110
136
|
let { name: n, type: r } = t;
|
|
111
|
-
return /* @__PURE__ */
|
|
137
|
+
return /* @__PURE__ */ u(e, {
|
|
112
138
|
id: n,
|
|
113
|
-
active: n ===
|
|
114
|
-
checked:
|
|
139
|
+
active: n === w,
|
|
140
|
+
checked: k.includes(n),
|
|
115
141
|
label: n,
|
|
116
142
|
type: r,
|
|
117
|
-
elementsCount:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
143
|
+
elementsCount: ie[n],
|
|
144
|
+
ancestorsCount: Q[n].count,
|
|
145
|
+
unusedAncestorsCount: Q[n].unused.size,
|
|
146
|
+
onSelect: B,
|
|
147
|
+
onDelete: J,
|
|
148
|
+
onToggleCheck: Y
|
|
121
149
|
}, n);
|
|
122
150
|
})
|
|
123
151
|
}),
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
id:
|
|
126
|
-
open:
|
|
127
|
-
onClose:
|
|
152
|
+
/* @__PURE__ */ d(p, {
|
|
153
|
+
id: I,
|
|
154
|
+
open: L,
|
|
155
|
+
onClose: z,
|
|
128
156
|
size: "sm",
|
|
129
|
-
children: [/* @__PURE__ */
|
|
130
|
-
componentsNotAvailables:
|
|
131
|
-
components:
|
|
132
|
-
onSubmit:
|
|
133
|
-
onClose:
|
|
157
|
+
children: [/* @__PURE__ */ u(p.Header, { children: /* @__PURE__ */ u("h4", { children: "Add Selector" }) }), /* @__PURE__ */ u(p.Body, { children: /* @__PURE__ */ u(t, {
|
|
158
|
+
componentsNotAvailables: ne,
|
|
159
|
+
components: te.current,
|
|
160
|
+
onSubmit: z,
|
|
161
|
+
onClose: z
|
|
134
162
|
}) })]
|
|
135
163
|
}),
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
id:
|
|
138
|
-
open:
|
|
139
|
-
onClose:
|
|
164
|
+
/* @__PURE__ */ d(p, {
|
|
165
|
+
id: U,
|
|
166
|
+
open: W,
|
|
167
|
+
onClose: K,
|
|
140
168
|
children: [
|
|
141
|
-
/* @__PURE__ */
|
|
142
|
-
/* @__PURE__ */
|
|
169
|
+
/* @__PURE__ */ u(p.Header, { children: /* @__PURE__ */ u("h4", { children: "Remove Selector" }) }),
|
|
170
|
+
/* @__PURE__ */ d(p.Body, { children: [Z > 1 && /* @__PURE__ */ d("h4", { children: [
|
|
143
171
|
"Do you want to remove these ",
|
|
144
|
-
|
|
172
|
+
Z,
|
|
145
173
|
" items ?"
|
|
146
|
-
] }),
|
|
147
|
-
/* @__PURE__ */
|
|
174
|
+
] }), Z <= 1 && /* @__PURE__ */ u("h4", { children: "Do you want to remove this item ?" })] }),
|
|
175
|
+
/* @__PURE__ */ d(p.Footer, {
|
|
148
176
|
justify: "end",
|
|
149
|
-
children: [/* @__PURE__ */
|
|
150
|
-
onClick:
|
|
177
|
+
children: [/* @__PURE__ */ u(f, {
|
|
178
|
+
onClick: se,
|
|
151
179
|
size: "sm",
|
|
152
180
|
children: "Cancel"
|
|
153
|
-
}), /* @__PURE__ */
|
|
154
|
-
onClick:
|
|
181
|
+
}), /* @__PURE__ */ u(f, {
|
|
182
|
+
onClick: ce,
|
|
155
183
|
size: "sm",
|
|
156
184
|
children: "Submit"
|
|
157
185
|
})]
|
|
@@ -162,4 +190,4 @@ var y = n(({ displayMode: n, flatList: y, selectors: b, selected: x, onSelect: S
|
|
|
162
190
|
});
|
|
163
191
|
});
|
|
164
192
|
//#endregion
|
|
165
|
-
export {
|
|
193
|
+
export { x as default };
|
|
@@ -5,10 +5,13 @@ export type StyleSelectorTagProps = {
|
|
|
5
5
|
active?: boolean;
|
|
6
6
|
checked?: boolean;
|
|
7
7
|
elementsCount?: number;
|
|
8
|
+
/** Ancestors this selector has rules under, and how many of them no element it dresses sits inside. */
|
|
9
|
+
ancestorsCount?: number;
|
|
10
|
+
unusedAncestorsCount?: number;
|
|
8
11
|
type?: TagType;
|
|
9
12
|
onSelect?: (id: string) => void;
|
|
10
13
|
onDelete?: (id: string) => void;
|
|
11
14
|
onToggleCheck?: (id: string) => void;
|
|
12
15
|
};
|
|
13
|
-
declare const _default: import('react').MemoExoticComponent<({ id, label, active, checked, elementsCount, type, onSelect, onDelete, onToggleCheck }: StyleSelectorTagProps) => import("react").JSX.Element>;
|
|
16
|
+
declare const _default: import('react').MemoExoticComponent<({ id, label, active, checked, elementsCount, ancestorsCount, unusedAncestorsCount, type, onSelect, onDelete, onToggleCheck }: StyleSelectorTagProps) => import("react").JSX.Element>;
|
|
14
17
|
export default _default;
|
|
@@ -4,17 +4,17 @@ import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
|
4
4
|
import a from "@plitzi/plitzi-ui/Button";
|
|
5
5
|
import o from "clsx";
|
|
6
6
|
import s from "@plitzi/plitzi-ui/Checkbox";
|
|
7
|
-
var c = t(({ id: t, label: c = "Selector", active: l = !1, checked: u = !1, elementsCount: d = 0,
|
|
8
|
-
let
|
|
9
|
-
e.stopPropagation(), t &&
|
|
10
|
-
}, [t,
|
|
7
|
+
var c = t(({ id: t, label: c = "Selector", active: l = !1, checked: u = !1, elementsCount: d = 0, ancestorsCount: f = 0, unusedAncestorsCount: p = 0, type: m = "class", onSelect: h, onDelete: g, onToggleCheck: _ }) => {
|
|
8
|
+
let v = n(() => h?.(t), [t, h]), y = n((e) => {
|
|
9
|
+
e.stopPropagation(), t && g?.(t);
|
|
10
|
+
}, [t, g]), b = n(() => _?.(t), [t, _]), x = n((e) => e.stopPropagation(), []), S = p ? `Rules under ${f} ancestor classes, ${p} of them around no element it dresses` : `Rules under ${f} ancestor classes`;
|
|
11
11
|
return /* @__PURE__ */ i("div", {
|
|
12
12
|
className: o("group flex cursor-pointer items-center justify-between gap-2 border-t border-gray-300 p-1 dark:border-zinc-700", {
|
|
13
13
|
"hover:bg-gray-100 dark:hover:bg-zinc-700/60": !l && !u,
|
|
14
14
|
"bg-gray-200 dark:bg-zinc-700": l,
|
|
15
15
|
"bg-secondary-50 dark:bg-secondary-900/30": u && !l
|
|
16
16
|
}),
|
|
17
|
-
onClick:
|
|
17
|
+
onClick: v,
|
|
18
18
|
children: [/* @__PURE__ */ i("div", {
|
|
19
19
|
className: "flex min-w-0 items-center gap-2",
|
|
20
20
|
children: [/* @__PURE__ */ r("div", {
|
|
@@ -22,33 +22,47 @@ var c = t(({ id: t, label: c = "Selector", active: l = !1, checked: u = !1, elem
|
|
|
22
22
|
children: /* @__PURE__ */ r(s, {
|
|
23
23
|
size: "xs",
|
|
24
24
|
checked: u,
|
|
25
|
-
onChange:
|
|
26
|
-
onClick:
|
|
25
|
+
onChange: b,
|
|
26
|
+
onClick: x
|
|
27
27
|
})
|
|
28
28
|
}), /* @__PURE__ */ r(e, {
|
|
29
29
|
editable: !1,
|
|
30
30
|
selector: c,
|
|
31
|
-
type:
|
|
31
|
+
type: m,
|
|
32
32
|
active: !0,
|
|
33
33
|
readOnly: !0
|
|
34
34
|
})]
|
|
35
35
|
}), /* @__PURE__ */ i("div", {
|
|
36
|
-
className: "flex",
|
|
37
|
-
children: [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
className: "flex items-center",
|
|
37
|
+
children: [
|
|
38
|
+
f > 0 && /* @__PURE__ */ i("div", {
|
|
39
|
+
className: o("mr-1 flex items-center gap-1 rounded-sm px-1.5 py-1 text-xs", {
|
|
40
|
+
"bg-amber-500/15 text-amber-700 dark:text-amber-300": p > 0,
|
|
41
|
+
"bg-gray-200 text-zinc-600 dark:bg-zinc-700 dark:text-zinc-300": p === 0
|
|
42
|
+
}),
|
|
43
|
+
title: S,
|
|
44
|
+
children: [/* @__PURE__ */ r("i", { className: o("fas", {
|
|
45
|
+
"fa-sitemap": !p,
|
|
46
|
+
"fa-triangle-exclamation": !!p
|
|
47
|
+
}) }), f]
|
|
41
48
|
}),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
/* @__PURE__ */ r("div", {
|
|
50
|
+
className: o("mr-1", {
|
|
51
|
+
flex: l,
|
|
52
|
+
"hidden group-hover:flex": !l
|
|
53
|
+
}),
|
|
54
|
+
children: /* @__PURE__ */ r(a, {
|
|
55
|
+
intent: "danger",
|
|
56
|
+
size: "xs",
|
|
57
|
+
onClick: y,
|
|
58
|
+
children: /* @__PURE__ */ r(a.Icon, { icon: "fas fa-trash" })
|
|
59
|
+
})
|
|
60
|
+
}),
|
|
61
|
+
d > 0 && /* @__PURE__ */ r("div", {
|
|
62
|
+
className: "bg-secondary-400 flex items-center justify-center rounded-sm px-1.5 py-1 text-xs text-white",
|
|
63
|
+
children: d
|
|
47
64
|
})
|
|
48
|
-
|
|
49
|
-
className: "bg-secondary-400 flex items-center justify-center rounded-sm px-1.5 py-1 text-xs text-white",
|
|
50
|
-
children: d
|
|
51
|
-
})]
|
|
65
|
+
]
|
|
52
66
|
})]
|
|
53
67
|
});
|
|
54
68
|
});
|
|
@@ -114,6 +114,7 @@ declare const calculateInheriting: (element: Element | undefined, componentType:
|
|
|
114
114
|
styleSelector?: string;
|
|
115
115
|
styleState?: StyleState;
|
|
116
116
|
styleVariant?: string;
|
|
117
|
+
styleAncestor?: string;
|
|
117
118
|
includeSelf?: boolean;
|
|
118
119
|
skipSelectors?: string[];
|
|
119
120
|
addSelectors?: string[];
|
|
@@ -38,29 +38,39 @@ var r = (e, t) => {
|
|
|
38
38
|
isAncestor: !1,
|
|
39
39
|
isDefault: !0
|
|
40
40
|
};
|
|
41
|
-
}, o = (e, t, n, r) => {
|
|
42
|
-
let
|
|
43
|
-
if (!
|
|
44
|
-
let
|
|
41
|
+
}, o = (e, t, n, r, i) => {
|
|
42
|
+
let a = e[t];
|
|
43
|
+
if (!a) return {};
|
|
44
|
+
let o = a.default ?? {};
|
|
45
|
+
if (i) {
|
|
46
|
+
let e = a.ancestors?.[i], t = r ? e?.variants?.[r] : void 0, s = n ? (t ?? e)?.states?.[n] : void 0;
|
|
47
|
+
return {
|
|
48
|
+
...o,
|
|
49
|
+
...e?.default,
|
|
50
|
+
...t?.default,
|
|
51
|
+
...s
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
let s = r ? a.variants?.[r]?.default ?? {} : {}, c = n ? a.states?.[n] ?? {} : {}, l = r && n ? a.variants?.[r]?.states?.[n] ?? {} : {};
|
|
45
55
|
return {
|
|
46
|
-
...a,
|
|
47
56
|
...o,
|
|
48
57
|
...s,
|
|
49
|
-
...c
|
|
58
|
+
...c,
|
|
59
|
+
...l
|
|
50
60
|
};
|
|
51
|
-
}, s = (e, t, n, r) => o(e.attributes, t, n, r), c = (e, o, c, l, u = {}, d = {}) => {
|
|
52
|
-
let { componentSubType: f, styleSelector: p = "base", styleState: m, styleVariant: h,
|
|
61
|
+
}, s = (e, t, n, r, i) => o(e.attributes, t, n, r, i), c = (e, o, c, l, u = {}, d = {}) => {
|
|
62
|
+
let { componentSubType: f, styleSelector: p = "base", styleState: m, styleVariant: h, styleAncestor: g, includeSelf: _ = !1, skipSelectors: v = [], addSelectors: y = [] } = d, b = {
|
|
53
63
|
tree: [],
|
|
54
64
|
style: {},
|
|
55
65
|
parentStyle: {}
|
|
56
|
-
},
|
|
66
|
+
}, x = e ? r(c, e) : [], S = /* @__PURE__ */ new Set();
|
|
57
67
|
for (let t of Object.keys(l)) {
|
|
58
68
|
let n = l[t];
|
|
59
69
|
if (n) {
|
|
60
70
|
if (!e && !o) {
|
|
61
|
-
for (let e of
|
|
71
|
+
for (let e of y) {
|
|
62
72
|
let r = n[e];
|
|
63
|
-
r &&
|
|
73
|
+
r && b.tree.push({
|
|
64
74
|
name: e,
|
|
65
75
|
displayMode: t,
|
|
66
76
|
attributes: r.attributes,
|
|
@@ -78,8 +88,8 @@ var r = (e, t) => {
|
|
|
78
88
|
parentId: void 0
|
|
79
89
|
},
|
|
80
90
|
attributes: {}
|
|
81
|
-
}, o, n, p,
|
|
82
|
-
for (let n of e)
|
|
91
|
+
}, o, n, p, y);
|
|
92
|
+
for (let n of e) v.includes(n.name) || b.tree.push({
|
|
83
93
|
name: n.name,
|
|
84
94
|
displayMode: t,
|
|
85
95
|
attributes: n.attributes,
|
|
@@ -87,16 +97,16 @@ var r = (e, t) => {
|
|
|
87
97
|
isAncestor: !1
|
|
88
98
|
});
|
|
89
99
|
let r = a(o, f, p, u);
|
|
90
|
-
r &&
|
|
100
|
+
r && b.tree.push({
|
|
91
101
|
...r,
|
|
92
102
|
displayMode: t
|
|
93
103
|
});
|
|
94
104
|
continue;
|
|
95
105
|
}
|
|
96
|
-
for (let r of
|
|
97
|
-
let s = e?.definition.parentId === r.id, c = r.id !== e?.id, l = i(r, r.definition.type === o ? o : void 0, n, p,
|
|
98
|
-
!
|
|
99
|
-
for (let e of l) (!
|
|
106
|
+
for (let r of x) {
|
|
107
|
+
let s = e?.definition.parentId === r.id, c = r.id !== e?.id, l = i(r, r.definition.type === o ? o : void 0, n, p, y);
|
|
108
|
+
!_ && !c && !m && !h && Object.keys(l).length && (l = l.filter((e) => e.type === "element"));
|
|
109
|
+
for (let e of l) (!v.includes(e.name) || c) && b.tree.push({
|
|
100
110
|
name: e.name,
|
|
101
111
|
displayMode: t,
|
|
102
112
|
attributes: e.attributes,
|
|
@@ -106,7 +116,7 @@ var r = (e, t) => {
|
|
|
106
116
|
isDefault: !1
|
|
107
117
|
});
|
|
108
118
|
let d = a(r.definition.type, r.attributes.subType, p, u);
|
|
109
|
-
d && !
|
|
119
|
+
d && !S.has(r.definition.type) && (S.add(r.definition.type), b.tree.push({
|
|
110
120
|
...d,
|
|
111
121
|
displayMode: t,
|
|
112
122
|
isParent: s,
|
|
@@ -115,23 +125,23 @@ var r = (e, t) => {
|
|
|
115
125
|
}
|
|
116
126
|
}
|
|
117
127
|
}
|
|
118
|
-
let
|
|
119
|
-
for (let e of
|
|
120
|
-
let r = s(e, p, m, h);
|
|
121
|
-
if (r && Object.keys(r).length && ((e.isAncestor || e.isDefault && e.componentType !== o) && (r = t(r, n)), Object.keys(r).length)) for (let t of Object.keys(r))
|
|
128
|
+
let C = {};
|
|
129
|
+
for (let e of b.tree) {
|
|
130
|
+
let r = s(e, p, m, h, g);
|
|
131
|
+
if (r && Object.keys(r).length && ((e.isAncestor || e.isDefault && e.componentType !== o) && (r = t(r, n)), Object.keys(r).length)) for (let t of Object.keys(r)) C[t] || (C[t] = []), C[t].push({
|
|
122
132
|
key: e.name,
|
|
123
133
|
value: r[t],
|
|
124
134
|
displayMode: e.displayMode
|
|
125
135
|
});
|
|
126
136
|
}
|
|
127
|
-
let
|
|
137
|
+
let w = b.tree.filter((e) => e.isParent).reduce((e, t) => ({
|
|
128
138
|
...e,
|
|
129
|
-
...s(t, p, m, h)
|
|
139
|
+
...s(t, p, m, h, g)
|
|
130
140
|
}), {});
|
|
131
141
|
return {
|
|
132
|
-
...
|
|
133
|
-
style:
|
|
134
|
-
parentStyle:
|
|
142
|
+
...b,
|
|
143
|
+
style: C,
|
|
144
|
+
parentStyle: w
|
|
135
145
|
};
|
|
136
146
|
};
|
|
137
147
|
//#endregion
|