@plitzi/sdk-style 0.39.4 → 0.39.6
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 +19 -0
- package/dist/builder/StyleAdvanceEditor.mjs +4 -3
- package/dist/builder/components/InputEasing/Curve.mjs +1 -1
- package/dist/builder/components/InputEasing/Grid.mjs +3 -3
- package/dist/builder/components/InputEasing/InputEasing.mjs +2 -2
- package/dist/builder/components/InputEasing/InputEasingButton.mjs +1 -1
- package/dist/builder/components/InputEasing/InputEasingList.mjs +4 -4
- package/dist/builder/components/Selector/Selector.mjs +143 -123
- package/dist/builder/components/Selector/SelectorItem/ItemOptions.mjs +4 -3
- package/dist/builder/components/Selector/SelectorItem/SelectorItem.mjs +29 -19
- package/dist/builder/components/Selector/SelectorItem/helpers.d.ts +1 -1
- package/dist/builder/components/Selector/SelectorItem/helpers.mjs +1 -1
- package/dist/builder/components/Selector/SelectorSuggestions/SelectorSuggestions.d.ts +6 -3
- package/dist/builder/components/Selector/SelectorSuggestions/SelectorSuggestions.mjs +56 -18
- package/dist/builder/components/Selector/SelectorSuggestions/helpers.d.ts +8 -0
- package/dist/builder/components/Selector/SelectorSuggestions/helpers.mjs +9 -0
- package/dist/builder/components/Selector/SelectorSuggestions/index.d.ts +1 -0
- package/dist/builder/components/Selector/SelectorSuggestions/index.mjs +3 -2
- package/dist/builder/components/StyleInspector/Inspector.mjs +1 -1
- package/dist/builder/components/StyleInspector/StyleInspector.mjs +2 -2
- package/dist/builder/components/StyleInspector/categories/Background/Background.mjs +1 -1
- package/dist/builder/components/StyleInspector/categories/Background/components/BackgroundLayer/BackgroundLayer.mjs +6 -6
- package/dist/builder/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopEditor.mjs +3 -3
- package/dist/builder/components/StyleInspector/categories/Background/components/LayerGroup/LayerGroup.mjs +1 -1
- package/dist/builder/components/StyleInspector/categories/Background/modes/RawMode.mjs +1 -1
- package/dist/builder/components/StyleInspector/categories/Effects/Filters/FilterItem.mjs +1 -1
- package/dist/builder/components/StyleInspector/categories/Effects/Transition/TransitionEasing.mjs +4 -4
- package/dist/builder/components/StyleInspector/categories/Effects/Transition/TransitionItem.mjs +1 -1
- package/dist/builder/components/StyleInspector/categories/Position/PositionAdvanced.mjs +5 -5
- package/dist/builder/components/StyleInspector/categories/Spacing/SpacingEditor.mjs +1 -1
- package/dist/builder/components/StyleInspector/categories/Spacing/SpacingMargin.mjs +1 -1
- package/dist/builder/components/StyleInspector/categories/Spacing/SpacingPadding.mjs +2 -2
- package/dist/builder/components/StyleInspector/components/AncestorRules/AncestorRuleChip.mjs +1 -1
- package/dist/builder/components/StyleInspector/components/AncestorRules/AncestorRules.mjs +1 -1
- package/dist/builder/components/StyleInspector/components/CategoryContainer/CategoryContainer.mjs +5 -5
- package/dist/builder/components/StyleInspector/components/CategoryOption/categoryTypes/OptionIconGroup.mjs +1 -1
- package/dist/builder/components/StyleInspector/components/InspectorFooter/InspectorFooter.mjs +3 -3
- package/dist/builder/components/StyleInspector/components/InspectorLabel/InspectorLabel.mjs +2 -2
- package/dist/builder/components/StyleInspector/components/InspectorSearch/InspectorSearch.mjs +1 -1
- package/dist/builder/components/StyleInspector/components/ShadowItem/ShadowItem.mjs +1 -1
- package/dist/builder/components/StyleInspector/components/TargetSummary/TargetSummary.mjs +2 -2
- package/dist/builder/components/StyleInspector/components/ValueList/ValueList.mjs +1 -1
- package/dist/builder/components/StyleInspector/components/ValueListItem/ValueListItem.mjs +6 -6
- package/dist/builder/components/StyleManager/ManagerSelector.mjs +281 -123
- package/dist/builder/components/StyleManager/StyleManager.mjs +75 -35
- package/dist/builder/components/StyleManager/StyleSelectorTag.d.ts +5 -1
- package/dist/builder/components/StyleManager/StyleSelectorTag.mjs +81 -63
- package/dist/builder/hooks/useWindowedList.d.ts +19 -0
- package/dist/builder/hooks/useWindowedList.mjs +38 -0
- package/package.json +8 -8
- package/dist/builder/components/Selector/SelectorSuggestions/SuggestionsCreator.d.ts +0 -7
- package/dist/builder/components/Selector/SelectorSuggestions/SuggestionsCreator.mjs +0 -19
- package/dist/builder/components/Selector/SelectorSuggestions/SuggestionsList.d.ts +0 -7
- package/dist/builder/components/Selector/SelectorSuggestions/SuggestionsList.mjs +0 -24
|
@@ -1,183 +1,341 @@
|
|
|
1
1
|
import e from "./StyleSelectorTag.mjs";
|
|
2
|
-
import t from "../../
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import t from "../../hooks/useWindowedList.mjs";
|
|
3
|
+
import n from "../../models/SelectorForm/index.mjs";
|
|
4
|
+
import { ancestorRemovals as r, unusedAncestors as i } from "../StyleInspector/helpers.mjs";
|
|
5
|
+
import { memo as a, use as o, useCallback as s, useMemo as c, useState as l } from "react";
|
|
5
6
|
import { useBuilderStore as ee } from "@plitzi/sdk-shared/store";
|
|
6
|
-
import { jsx as
|
|
7
|
-
import { produce as
|
|
7
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
|
+
import { produce as te } from "immer";
|
|
8
9
|
import f from "@plitzi/plitzi-ui/Button";
|
|
9
|
-
import p from "
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
10
|
+
import p from "clsx";
|
|
11
|
+
import m from "@plitzi/plitzi-ui/Modal";
|
|
12
|
+
import { ComponentContext as h } from "@plitzi/sdk-shared/elements";
|
|
13
|
+
import { isEmpty as g } from "@plitzi/plitzi-ui/helpers/lodash";
|
|
14
|
+
import _ from "@plitzi/plitzi-ui/hooks/useDisclosure";
|
|
15
|
+
import v from "@plitzi/plitzi-ui/Input";
|
|
16
|
+
import { BuilderContext as ne } from "@plitzi/sdk-shared/builder/contexts";
|
|
15
17
|
// src/builder/components/StyleManager/ManagerSelector.tsx
|
|
16
|
-
var
|
|
17
|
-
let n =
|
|
18
|
+
var y = (e) => e.split(":")[0], re = (e, t) => {
|
|
19
|
+
let n = y(t);
|
|
18
20
|
return !!n && Object.values(e.definition.styleSelectors).some((e) => e.split(" ").includes(n));
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
}, ie = (e) => e < 1e3 ? String(e) : `${(e / 1e3).toFixed(+(e < 1e4)).replace(/\.0$/, "")}k`, ae = [
|
|
22
|
+
{
|
|
23
|
+
id: "all",
|
|
24
|
+
label: "All"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "classes",
|
|
28
|
+
label: "Classes"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "elements",
|
|
32
|
+
label: "Elements"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "unused",
|
|
36
|
+
label: "Unused"
|
|
37
|
+
}
|
|
38
|
+
], b = {
|
|
39
|
+
section: 28,
|
|
40
|
+
group: 28,
|
|
41
|
+
row: 28
|
|
42
|
+
}, x = 40, S = 5, C = "Other", oe = (e) => {
|
|
43
|
+
let t = e.indexOf("-");
|
|
44
|
+
return t > 0 ? e.slice(0, t + 1) : void 0;
|
|
45
|
+
}, w = a(({ displayMode: a, flat: w, flatList: T, selectors: E, selected: se, onSelect: D }) => {
|
|
46
|
+
let O = c(() => Object.values(E ?? {}), [E]), [k, A] = l(""), [j, M] = l("all"), [N, P] = l([]), { builderHandler: F } = o(ne), [I] = ee("style.platform"), { components: ce } = o(h), le = c(() => O.filter((e) => !!e.componentType).map((e) => e.componentType), [O]), L = c(() => {
|
|
47
|
+
let e = O;
|
|
48
|
+
return g(k) || (e = O.filter((e) => e.name.toLowerCase().includes(k.toLowerCase()))), [...e].sort((e, t) => {
|
|
23
49
|
let n = Number(e.type === "element"), r = Number(t.type === "element");
|
|
24
50
|
return n === r ? e.name.localeCompare(t.name) : r - n;
|
|
25
51
|
});
|
|
26
|
-
}, [
|
|
52
|
+
}, [O, k]), R = c(() => {
|
|
53
|
+
let e = {};
|
|
54
|
+
for (let t of T) new Set(Object.values(t.definition.styleSelectors).flatMap((e) => e.split(" ").filter(Boolean))).forEach((t) => {
|
|
55
|
+
e[t] = (e[t] ?? 0) + 1;
|
|
56
|
+
});
|
|
57
|
+
return Object.fromEntries(O.map((t) => [t.name, e[y(t.name)] ?? 0]));
|
|
58
|
+
}, [O, T]), z = c(() => {
|
|
59
|
+
let e = L.filter((e) => e.type !== "element");
|
|
60
|
+
return {
|
|
61
|
+
all: L,
|
|
62
|
+
classes: e,
|
|
63
|
+
elements: L.filter((e) => e.type === "element"),
|
|
64
|
+
unused: e.filter((e) => R[e.name] === 0)
|
|
65
|
+
};
|
|
66
|
+
}, [L, R]), B = z[j], [V, H] = l(/* @__PURE__ */ new Set()), U = c(() => {
|
|
67
|
+
let e = (e, t = !1) => e.map((e) => ({
|
|
68
|
+
kind: "row",
|
|
69
|
+
key: e.name,
|
|
70
|
+
selector: e,
|
|
71
|
+
nested: t
|
|
72
|
+
})), t = (t) => {
|
|
73
|
+
if (t.length < x || k) return e(t);
|
|
74
|
+
let n = /* @__PURE__ */ new Map(), r = [];
|
|
75
|
+
for (let e of t) {
|
|
76
|
+
let t = oe(e.name);
|
|
77
|
+
t ? n.set(t, [...n.get(t) ?? [], e]) : r.push(e);
|
|
78
|
+
}
|
|
79
|
+
let i = (t, n) => {
|
|
80
|
+
let r = V.has(t);
|
|
81
|
+
return [{
|
|
82
|
+
kind: "group",
|
|
83
|
+
key: `group:${t}`,
|
|
84
|
+
prefix: t,
|
|
85
|
+
count: n.length,
|
|
86
|
+
open: r
|
|
87
|
+
}, ...r ? e(n, !0) : []];
|
|
88
|
+
}, a = [...n.entries()].filter(([, e]) => e.length >= S), o = [...r, ...[...n.values()].filter((e) => e.length < S).flat()].sort((e, t) => e.name.localeCompare(t.name));
|
|
89
|
+
return [...a.sort(([e], [t]) => e.localeCompare(t)).flatMap(([e, t]) => i(e, t)), ...o.length > 0 ? i(C, o) : []];
|
|
90
|
+
};
|
|
91
|
+
return j === "all" ? [...z.elements.length > 0 ? [{
|
|
92
|
+
kind: "section",
|
|
93
|
+
key: "section:elements",
|
|
94
|
+
title: "Element defaults",
|
|
95
|
+
count: z.elements.length
|
|
96
|
+
}, ...e(z.elements)] : [], ...z.classes.length > 0 ? [{
|
|
97
|
+
kind: "section",
|
|
98
|
+
key: "section:classes",
|
|
99
|
+
title: "Classes",
|
|
100
|
+
count: z.classes.length
|
|
101
|
+
}, ...t(z.classes)] : []] : j === "elements" ? e(B) : t(B);
|
|
102
|
+
}, [
|
|
103
|
+
j,
|
|
104
|
+
z,
|
|
105
|
+
B,
|
|
106
|
+
k,
|
|
107
|
+
V
|
|
108
|
+
]), W = c(() => U.map((e) => b[e.kind]), [U]), G = t(W), K = s((e) => () => H((t) => {
|
|
109
|
+
let n = new Set(t);
|
|
110
|
+
return n.delete(e) || n.add(e), n;
|
|
111
|
+
}), []), ue = s((e) => A(e), [A]), de = s((e) => () => M(e), []), fe = s((e, t) => {
|
|
27
112
|
if (t) {
|
|
28
113
|
if (t.mode === "default") {
|
|
29
114
|
let { name: e } = t;
|
|
30
|
-
|
|
115
|
+
F("styleAddSelector", a, e, "class", void 0, void 0, {
|
|
31
116
|
styleSelector: void 0,
|
|
32
117
|
componentType: void 0
|
|
33
118
|
});
|
|
34
119
|
} else {
|
|
35
120
|
let { componentType: e } = t;
|
|
36
|
-
|
|
121
|
+
F("styleAddSelector", a, e, "element", void 0, void 0, {
|
|
37
122
|
styleSelector: void 0,
|
|
38
123
|
componentType: e
|
|
39
124
|
});
|
|
40
125
|
}
|
|
41
126
|
}
|
|
42
|
-
}, [
|
|
127
|
+
}, [F, a]), [pe, me, he, q] = _({
|
|
43
128
|
id: "add-selector",
|
|
44
|
-
onClose:
|
|
45
|
-
}),
|
|
46
|
-
|
|
47
|
-
}, [
|
|
129
|
+
onClose: fe
|
|
130
|
+
}), ge = s((e) => {
|
|
131
|
+
D?.((t) => t?.name === e ? void 0 : O.find((t) => t.name === e));
|
|
132
|
+
}, [D, O]), _e = s((e, t, n) => {
|
|
48
133
|
if (!t || !n || n.length === 0) return;
|
|
49
|
-
let r = new Set(n),
|
|
134
|
+
let r = new Set(n), i = new Set(n.map(y)), o = T.filter((e) => n.some((t) => re(e, t))).map((e) => te(e, (e) => {
|
|
50
135
|
let { styleSelectors: t } = e.definition;
|
|
51
|
-
for (let [e, n] of Object.entries(t)) t[e] = n.split(" ").filter((e) => e && !
|
|
136
|
+
for (let [e, n] of Object.entries(t)) t[e] = n.split(" ").filter((e) => e && !i.has(e)).join(" ");
|
|
52
137
|
}));
|
|
53
|
-
o.length > 0 &&
|
|
138
|
+
o.length > 0 && F("schemaUpdateElements", o), F("styleRemoveSelectors", a, n), P((e) => e.filter((e) => !r.has(e))), D?.((e) => e && r.has(e.name) ? void 0 : e);
|
|
54
139
|
}, [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
]), [
|
|
140
|
+
F,
|
|
141
|
+
a,
|
|
142
|
+
T,
|
|
143
|
+
D
|
|
144
|
+
]), [ve, ye, J, Y, , X] = _({
|
|
60
145
|
id: "delete-selector",
|
|
61
|
-
onClose:
|
|
62
|
-
}),
|
|
63
|
-
...e,
|
|
64
|
-
[t.name]: x.filter((e) => y(e, t.name)).length
|
|
65
|
-
}), {}), [N, x]), Q = s(() => Object.fromEntries(T.map((e) => [e.name, {
|
|
146
|
+
onClose: _e
|
|
147
|
+
}), be = s((e) => J(void 0, [e]), [J]), xe = s((e) => P((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]), []), Se = s(() => P([]), []), Ce = s(() => P(z.unused.map((e) => e.name)), [z.unused]), we = s(() => J(void 0, N), [J, N]), Z = Array.isArray(X) ? X.length : 0, Q = c(() => Object.fromEntries(O.map((e) => [e.name, {
|
|
66
148
|
count: new Set(Object.values(e.attributes).flatMap((e) => Object.keys(e.ancestors ?? {}))).size,
|
|
67
|
-
unused:
|
|
68
|
-
}])), [
|
|
69
|
-
for (let [e, { unused: t }] of Object.entries(Q)) for (let
|
|
70
|
-
styleSelector:
|
|
71
|
-
styleAncestor:
|
|
72
|
-
componentType:
|
|
149
|
+
unused: i(w, e)
|
|
150
|
+
}])), [w, O]), $ = c(() => Object.values(Q).reduce((e, { unused: t }) => e + t.size, 0), [Q]), Te = `${$} unused ancestor ${$ === 1 ? "rule" : "rules"}`, Ee = s(() => {
|
|
151
|
+
for (let [e, { unused: t }] of Object.entries(Q)) for (let n of r(I, e, t)) F("styleUpdateSelector", n.displayMode, e, void 0, void 0, {
|
|
152
|
+
styleSelector: n.styleSelector,
|
|
153
|
+
styleAncestor: n.styleAncestor,
|
|
154
|
+
componentType: I[n.displayMode][e].componentType
|
|
73
155
|
});
|
|
74
156
|
}, [
|
|
75
157
|
Q,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
]),
|
|
79
|
-
return /* @__PURE__ */
|
|
80
|
-
className: "flex
|
|
158
|
+
F,
|
|
159
|
+
I
|
|
160
|
+
]), De = s(() => void Y(void 0, !1), [Y]), Oe = s(() => void Y(void 0, !0), [Y]);
|
|
161
|
+
return /* @__PURE__ */ d("div", {
|
|
162
|
+
className: "border-ui-line flex w-[300px] shrink-0 flex-col gap-2 overflow-hidden border-r px-2 pt-2",
|
|
81
163
|
children: [
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
164
|
+
/* @__PURE__ */ d("div", {
|
|
165
|
+
className: "flex items-center gap-1.5",
|
|
166
|
+
children: [/* @__PURE__ */ u("div", {
|
|
167
|
+
className: "grow",
|
|
168
|
+
children: /* @__PURE__ */ u(v, {
|
|
169
|
+
placeholder: "Search selectors",
|
|
170
|
+
"aria-label": "Search selectors",
|
|
171
|
+
value: k,
|
|
172
|
+
onChange: ue,
|
|
173
|
+
size: "xs",
|
|
174
|
+
clearable: !0,
|
|
175
|
+
children: /* @__PURE__ */ u(v.Icon, { icon: "fa-solid fa-magnifying-glass" })
|
|
176
|
+
})
|
|
177
|
+
}), /* @__PURE__ */ d(f, {
|
|
178
|
+
intent: "primary",
|
|
179
|
+
size: "xs",
|
|
180
|
+
iconPlacement: "before",
|
|
181
|
+
title: "New selector",
|
|
182
|
+
onClick: he,
|
|
183
|
+
children: [/* @__PURE__ */ u(f.Icon, { icon: "fa-solid fa-plus" }), "New"]
|
|
184
|
+
})]
|
|
93
185
|
}),
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
186
|
+
/* @__PURE__ */ u("div", {
|
|
187
|
+
className: "bg-ui-raised flex gap-0.5 rounded-md p-0.5",
|
|
188
|
+
role: "tablist",
|
|
189
|
+
children: ae.map(({ id: e, label: t }) => /* @__PURE__ */ d("button", {
|
|
190
|
+
type: "button",
|
|
191
|
+
role: "tab",
|
|
192
|
+
"aria-selected": j === e,
|
|
193
|
+
className: p("flex min-w-0 flex-1 cursor-pointer items-center justify-center gap-1 rounded px-1 py-1 text-[11px] font-medium whitespace-nowrap", {
|
|
194
|
+
"bg-ui-active text-ui-fg shadow-sm": j === e,
|
|
195
|
+
"text-ui-fg-subtle hover:text-ui-fg": j !== e
|
|
196
|
+
}),
|
|
197
|
+
title: `${t} · ${z[e].length.toLocaleString("en")}`,
|
|
198
|
+
onClick: de(e),
|
|
199
|
+
children: [t, /* @__PURE__ */ u("span", {
|
|
200
|
+
className: p("tabular-nums", {
|
|
201
|
+
"text-amber-600 dark:text-amber-400": e === "unused" && z.unused.length > 0,
|
|
202
|
+
"opacity-60": !(e === "unused" && z.unused.length > 0)
|
|
203
|
+
}),
|
|
204
|
+
children: ie(z[e].length)
|
|
205
|
+
})]
|
|
206
|
+
}, e))
|
|
99
207
|
}),
|
|
100
|
-
$ > 0 && /* @__PURE__ */
|
|
101
|
-
className: "flex items-center justify-between gap-2 rounded-
|
|
102
|
-
children: [/* @__PURE__ */
|
|
103
|
-
className: "text-xs text-amber-
|
|
104
|
-
children: [/* @__PURE__ */
|
|
105
|
-
}), /* @__PURE__ */
|
|
208
|
+
$ > 0 && /* @__PURE__ */ d("div", {
|
|
209
|
+
className: "flex items-center justify-between gap-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-2 py-1.5",
|
|
210
|
+
children: [/* @__PURE__ */ d("span", {
|
|
211
|
+
className: "text-xs text-amber-800 dark:text-amber-200",
|
|
212
|
+
children: [/* @__PURE__ */ u("i", { className: "fas fa-sitemap mr-1.5 text-[10px]" }), Te]
|
|
213
|
+
}), /* @__PURE__ */ u(f, {
|
|
106
214
|
size: "xs",
|
|
107
|
-
onClick:
|
|
215
|
+
onClick: Ee,
|
|
108
216
|
children: "Clean up"
|
|
109
217
|
})]
|
|
110
218
|
}),
|
|
111
|
-
|
|
112
|
-
className: "
|
|
113
|
-
children: [/* @__PURE__ */ u("span", {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
219
|
+
j === "unused" && z.unused.length > 0 && N.length === 0 && /* @__PURE__ */ d("div", {
|
|
220
|
+
className: "text-ui-fg-subtle flex items-center justify-between gap-2 px-1 text-xs",
|
|
221
|
+
children: [/* @__PURE__ */ u("span", { children: "No element wears these classes." }), /* @__PURE__ */ u(f, {
|
|
222
|
+
size: "xs",
|
|
223
|
+
onClick: Ce,
|
|
224
|
+
children: "Select all"
|
|
225
|
+
})]
|
|
226
|
+
}),
|
|
227
|
+
N.length > 0 && /* @__PURE__ */ d("div", {
|
|
228
|
+
className: "bg-secondary-50 dark:bg-secondary-900/30 flex items-center justify-between gap-2 rounded-md px-2 py-1",
|
|
229
|
+
children: [/* @__PURE__ */ d("span", {
|
|
230
|
+
className: "text-ui-fg-muted text-xs",
|
|
231
|
+
children: [N.length, " selected"]
|
|
232
|
+
}), /* @__PURE__ */ d("div", {
|
|
117
233
|
className: "flex gap-1",
|
|
118
|
-
children: [/* @__PURE__ */
|
|
234
|
+
children: [/* @__PURE__ */ u(f, {
|
|
119
235
|
size: "xs",
|
|
120
|
-
onClick:
|
|
236
|
+
onClick: Se,
|
|
121
237
|
children: "Clear"
|
|
122
|
-
}), /* @__PURE__ */
|
|
238
|
+
}), /* @__PURE__ */ d(f, {
|
|
123
239
|
intent: "danger",
|
|
124
240
|
size: "xs",
|
|
125
241
|
iconPlacement: "before",
|
|
126
|
-
onClick:
|
|
127
|
-
children: [/* @__PURE__ */
|
|
242
|
+
onClick: we,
|
|
243
|
+
children: [/* @__PURE__ */ u(f.Icon, { icon: "fas fa-trash" }), "Delete"]
|
|
128
244
|
})]
|
|
129
245
|
})]
|
|
130
246
|
}),
|
|
131
|
-
/* @__PURE__ */
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
247
|
+
/* @__PURE__ */ d("div", {
|
|
248
|
+
ref: G.ref,
|
|
249
|
+
className: "-mx-2 flex grow basis-0 flex-col overflow-y-auto pb-2",
|
|
250
|
+
onScroll: G.onScroll,
|
|
251
|
+
children: [
|
|
252
|
+
/* @__PURE__ */ u("div", {
|
|
253
|
+
style: { height: G.before },
|
|
254
|
+
className: "shrink-0"
|
|
255
|
+
}),
|
|
256
|
+
U.slice(G.start, G.end).map((t) => {
|
|
257
|
+
if (t.kind === "section") return /* @__PURE__ */ d("h6", {
|
|
258
|
+
className: "text-ui-fg-subtle flex h-7 shrink-0 items-center justify-between px-2 text-[10px] font-semibold tracking-wider uppercase",
|
|
259
|
+
children: [t.title, /* @__PURE__ */ u("span", {
|
|
260
|
+
className: "font-normal tabular-nums",
|
|
261
|
+
children: t.count
|
|
262
|
+
})]
|
|
263
|
+
}, t.key);
|
|
264
|
+
if (t.kind === "group") return /* @__PURE__ */ d("button", {
|
|
265
|
+
type: "button",
|
|
266
|
+
"aria-expanded": t.open,
|
|
267
|
+
className: "text-ui-fg-muted hover:bg-ui-hover flex h-7 w-full shrink-0 cursor-pointer items-center gap-2 pr-2 pl-2 text-left text-xs",
|
|
268
|
+
onClick: K(t.prefix),
|
|
269
|
+
children: [
|
|
270
|
+
/* @__PURE__ */ u("i", { className: p("fa-solid text-ui-fg-subtle w-4 text-center text-[9px]", t.open ? "fa-chevron-down" : "fa-chevron-right") }),
|
|
271
|
+
/* @__PURE__ */ u("span", {
|
|
272
|
+
className: p("grow truncate", { "font-mono": t.prefix !== C }),
|
|
273
|
+
children: t.prefix === C ? C : `${t.prefix}…`
|
|
274
|
+
}),
|
|
275
|
+
/* @__PURE__ */ u("span", {
|
|
276
|
+
className: "text-ui-fg-subtle text-[11px] tabular-nums",
|
|
277
|
+
children: t.count
|
|
278
|
+
})
|
|
279
|
+
]
|
|
280
|
+
}, t.key);
|
|
281
|
+
let { name: n, type: r } = t.selector;
|
|
282
|
+
return /* @__PURE__ */ u(e, {
|
|
283
|
+
id: n,
|
|
284
|
+
active: n === se,
|
|
285
|
+
checked: N.includes(n),
|
|
286
|
+
selecting: N.length > 0,
|
|
287
|
+
nested: t.nested,
|
|
288
|
+
label: n,
|
|
289
|
+
type: r,
|
|
290
|
+
elementsCount: R[n],
|
|
291
|
+
ancestorsCount: Q[n].count,
|
|
292
|
+
unusedAncestorsCount: Q[n].unused.size,
|
|
293
|
+
onSelect: ge,
|
|
294
|
+
onDelete: be,
|
|
295
|
+
onToggleCheck: xe
|
|
296
|
+
}, t.key);
|
|
297
|
+
}),
|
|
298
|
+
/* @__PURE__ */ u("div", {
|
|
299
|
+
style: { height: G.after },
|
|
300
|
+
className: "shrink-0"
|
|
301
|
+
}),
|
|
302
|
+
B.length === 0 && /* @__PURE__ */ u("p", {
|
|
303
|
+
className: "text-ui-fg-subtle px-2 py-6 text-center text-xs",
|
|
304
|
+
children: k ? "No selector matches the search." : j === "unused" ? "Every class is worn by an element." : "No selectors yet: make one with New."
|
|
305
|
+
})
|
|
306
|
+
]
|
|
149
307
|
}),
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
id:
|
|
152
|
-
open:
|
|
153
|
-
onClose:
|
|
308
|
+
/* @__PURE__ */ d(m, {
|
|
309
|
+
id: pe,
|
|
310
|
+
open: me,
|
|
311
|
+
onClose: q,
|
|
154
312
|
size: "sm",
|
|
155
|
-
children: [/* @__PURE__ */
|
|
156
|
-
componentsNotAvailables:
|
|
157
|
-
components:
|
|
158
|
-
onSubmit:
|
|
159
|
-
onClose:
|
|
313
|
+
children: [/* @__PURE__ */ u(m.Header, { children: /* @__PURE__ */ u("h4", { children: "Add Selector" }) }), /* @__PURE__ */ u(m.Body, { children: /* @__PURE__ */ u(n, {
|
|
314
|
+
componentsNotAvailables: le,
|
|
315
|
+
components: ce.current,
|
|
316
|
+
onSubmit: q,
|
|
317
|
+
onClose: q
|
|
160
318
|
}) })]
|
|
161
319
|
}),
|
|
162
|
-
/* @__PURE__ */
|
|
163
|
-
id:
|
|
164
|
-
open:
|
|
165
|
-
onClose:
|
|
320
|
+
/* @__PURE__ */ d(m, {
|
|
321
|
+
id: ve,
|
|
322
|
+
open: ye,
|
|
323
|
+
onClose: Y,
|
|
166
324
|
children: [
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
/* @__PURE__ */
|
|
325
|
+
/* @__PURE__ */ u(m.Header, { children: /* @__PURE__ */ u("h4", { children: "Remove Selector" }) }),
|
|
326
|
+
/* @__PURE__ */ d(m.Body, { children: [Z > 1 && /* @__PURE__ */ d("h4", { children: [
|
|
169
327
|
"Do you want to remove these ",
|
|
170
328
|
Z,
|
|
171
329
|
" items ?"
|
|
172
|
-
] }), Z <= 1 && /* @__PURE__ */
|
|
173
|
-
/* @__PURE__ */
|
|
330
|
+
] }), Z <= 1 && /* @__PURE__ */ u("h4", { children: "Do you want to remove this item ?" })] }),
|
|
331
|
+
/* @__PURE__ */ d(m.Footer, {
|
|
174
332
|
justify: "end",
|
|
175
|
-
children: [/* @__PURE__ */
|
|
176
|
-
onClick:
|
|
333
|
+
children: [/* @__PURE__ */ u(f, {
|
|
334
|
+
onClick: De,
|
|
177
335
|
size: "sm",
|
|
178
336
|
children: "Cancel"
|
|
179
|
-
}), /* @__PURE__ */
|
|
180
|
-
onClick:
|
|
337
|
+
}), /* @__PURE__ */ u(f, {
|
|
338
|
+
onClick: Oe,
|
|
181
339
|
size: "sm",
|
|
182
340
|
children: "Submit"
|
|
183
341
|
})]
|
|
@@ -187,4 +345,4 @@ var v = (e) => e.split(":")[0], y = (e, t) => {
|
|
|
187
345
|
]
|
|
188
346
|
});
|
|
189
347
|
});
|
|
190
|
-
export {
|
|
348
|
+
export { w as default };
|
|
@@ -2,46 +2,86 @@ import e from "./ManagerSelector.mjs";
|
|
|
2
2
|
import t from "../StyleInspector/index.mjs";
|
|
3
3
|
import { use as n, useMemo as r, useState as i } from "react";
|
|
4
4
|
import { useBuilderStore as a } from "@plitzi/sdk-shared/store";
|
|
5
|
-
import {
|
|
6
|
-
import { get as
|
|
7
|
-
import { ComponentContext as
|
|
5
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
import { get as l } from "@plitzi/plitzi-ui/helpers";
|
|
7
|
+
import { ComponentContext as u } from "@plitzi/sdk-shared/elements";
|
|
8
8
|
// src/builder/components/StyleManager/StyleManager.tsx
|
|
9
|
-
var
|
|
10
|
-
let { componentDefinitions:
|
|
11
|
-
if (
|
|
9
|
+
var d = () => {
|
|
10
|
+
let { componentDefinitions: d } = n(u), [f, p] = i(void 0), [[m, h]] = a(["schema.flat", "displayMode"]), [g] = a(`style.platform.${h}`), _ = r(() => Object.values(m), [m]), v = r(() => f?.type === "element" ? Object.keys(l(d.current, `${f.componentType}.definition.styleSelectors`, {})) : ["base"], [d, f]), y = r(() => f?.type === "element" ? Object.keys(l(d.current, `${f.componentType}.defaultStyle.subTypes`, {})) : [], [d, f]), b = r(() => {
|
|
11
|
+
if (f) return f.type === "element" && v.length > 1 ? v.reduce((e, t) => ({
|
|
12
12
|
...e,
|
|
13
|
-
[t]:
|
|
14
|
-
}), {}) : { base:
|
|
15
|
-
}, [
|
|
16
|
-
return /* @__PURE__ */
|
|
17
|
-
className: "flex h-full grow flex-col overflow-
|
|
18
|
-
children: /* @__PURE__ */
|
|
19
|
-
className: "flex grow overflow-
|
|
20
|
-
children: [/* @__PURE__ */
|
|
21
|
-
displayMode:
|
|
22
|
-
selectors:
|
|
23
|
-
flat:
|
|
24
|
-
flatList:
|
|
25
|
-
selected:
|
|
26
|
-
onSelect:
|
|
27
|
-
}), /* @__PURE__ */
|
|
28
|
-
className: "flex grow basis-0 flex-col overflow-auto",
|
|
29
|
-
children: [
|
|
13
|
+
[t]: f.componentType
|
|
14
|
+
}), {}) : { base: f.name };
|
|
15
|
+
}, [f, v]), x = r(() => f ? _.filter((e) => Object.values(e.definition.styleSelectors).some((e) => e.split(" ").includes(f.name))).length : 0, [_, f]);
|
|
16
|
+
return /* @__PURE__ */ s("div", {
|
|
17
|
+
className: "flex h-full grow flex-col overflow-hidden",
|
|
18
|
+
children: /* @__PURE__ */ c("div", {
|
|
19
|
+
className: "flex grow overflow-hidden",
|
|
20
|
+
children: [/* @__PURE__ */ s(e, {
|
|
21
|
+
displayMode: h,
|
|
22
|
+
selectors: g,
|
|
23
|
+
flat: m,
|
|
24
|
+
flatList: _,
|
|
25
|
+
selected: f?.name,
|
|
26
|
+
onSelect: p
|
|
27
|
+
}), /* @__PURE__ */ c("div", {
|
|
28
|
+
className: "flex min-w-0 grow basis-0 flex-col overflow-auto",
|
|
29
|
+
children: [f && /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ c("div", {
|
|
30
|
+
className: "border-ui-line flex items-center gap-2 border-b px-3 py-2",
|
|
31
|
+
children: [
|
|
32
|
+
/* @__PURE__ */ s("span", {
|
|
33
|
+
className: "bg-primary-50 text-primary-600 dark:bg-primary-400/15 dark:text-primary-300 flex size-7 shrink-0 items-center justify-center rounded-md text-xs",
|
|
34
|
+
"aria-hidden": !0,
|
|
35
|
+
children: f.type === "element" ? /* @__PURE__ */ s("i", { className: "fa-solid fa-cube" }) : /* @__PURE__ */ s("b", {
|
|
36
|
+
className: "font-mono",
|
|
37
|
+
children: "."
|
|
38
|
+
})
|
|
39
|
+
}),
|
|
40
|
+
/* @__PURE__ */ c("div", {
|
|
41
|
+
className: "flex min-w-0 grow flex-col",
|
|
42
|
+
children: [/* @__PURE__ */ s("span", {
|
|
43
|
+
className: "text-ui-fg truncate font-mono text-sm font-semibold",
|
|
44
|
+
children: f.type === "element" ? f.name : `.${f.name}`
|
|
45
|
+
}), /* @__PURE__ */ s("span", {
|
|
46
|
+
className: "text-ui-fg-subtle truncate text-[11px]",
|
|
47
|
+
children: f.type === "element" ? `The defaults of every ${f.componentType ?? f.name}` : x > 0 ? `A class, worn by ${String(x)} element${x === 1 ? "" : "s"}` : "A class no element wears"
|
|
48
|
+
})]
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ c("span", {
|
|
51
|
+
className: "bg-ui-raised text-ui-fg-muted shrink-0 rounded px-1.5 py-0.5 text-[11px] capitalize",
|
|
52
|
+
title: "The breakpoint the styles below are edited at: the one the canvas shows",
|
|
53
|
+
children: [/* @__PURE__ */ s("i", { className: "fa-solid fa-display mr-1 text-[10px]" }), h]
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
}), /* @__PURE__ */ s(t, {
|
|
30
57
|
mode: "manager",
|
|
31
|
-
displayMode:
|
|
32
|
-
selectors:
|
|
33
|
-
styleSelectors:
|
|
34
|
-
styleSelectorsAvailables:
|
|
35
|
-
componentSubTypesAvailables:
|
|
36
|
-
allowStyleSelector:
|
|
37
|
-
componentType:
|
|
38
|
-
value:
|
|
39
|
-
}), !
|
|
40
|
-
className: "
|
|
41
|
-
children:
|
|
58
|
+
displayMode: h,
|
|
59
|
+
selectors: g,
|
|
60
|
+
styleSelectors: b,
|
|
61
|
+
styleSelectorsAvailables: v,
|
|
62
|
+
componentSubTypesAvailables: y,
|
|
63
|
+
allowStyleSelector: f.type === "element",
|
|
64
|
+
componentType: f.componentType,
|
|
65
|
+
value: f.name
|
|
66
|
+
})] }), !f && /* @__PURE__ */ c("div", {
|
|
67
|
+
className: "flex grow flex-col items-center justify-center gap-2 p-6 text-center select-none",
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ s("span", {
|
|
70
|
+
className: "bg-primary-50 text-primary-600 dark:bg-primary-400/15 dark:text-primary-300 flex size-10 items-center justify-center rounded-lg",
|
|
71
|
+
children: /* @__PURE__ */ s("i", { className: "fas fa-swatchbook" })
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ s("span", {
|
|
74
|
+
className: "text-ui-fg text-sm font-medium",
|
|
75
|
+
children: "Pick a selector to edit it"
|
|
76
|
+
}),
|
|
77
|
+
/* @__PURE__ */ s("span", {
|
|
78
|
+
className: "text-ui-fg-subtle max-w-64 text-xs",
|
|
79
|
+
children: "A class changes every element that wears it; an element’s defaults, every element of that type."
|
|
80
|
+
})
|
|
81
|
+
]
|
|
42
82
|
})]
|
|
43
83
|
})]
|
|
44
84
|
})
|
|
45
85
|
});
|
|
46
86
|
};
|
|
47
|
-
export {
|
|
87
|
+
export { d as default };
|
|
@@ -4,6 +4,10 @@ export type StyleSelectorTagProps = {
|
|
|
4
4
|
label?: string;
|
|
5
5
|
active?: boolean;
|
|
6
6
|
checked?: boolean;
|
|
7
|
+
/** Whether any row is checked: the boxes show on every row then, not only under the pointer. */
|
|
8
|
+
selecting?: boolean;
|
|
9
|
+
/** Listed inside a group: set in under the group's name. */
|
|
10
|
+
nested?: boolean;
|
|
7
11
|
elementsCount?: number;
|
|
8
12
|
/** Ancestors this selector has rules under, and how many of them no element it dresses sits inside. */
|
|
9
13
|
ancestorsCount?: number;
|
|
@@ -13,5 +17,5 @@ export type StyleSelectorTagProps = {
|
|
|
13
17
|
onDelete?: (id: string) => void;
|
|
14
18
|
onToggleCheck?: (id: string) => void;
|
|
15
19
|
};
|
|
16
|
-
declare const _default: import('react').MemoExoticComponent<({ id, label, active, checked, elementsCount, ancestorsCount, unusedAncestorsCount, type, onSelect, onDelete, onToggleCheck }: StyleSelectorTagProps) => import('react').JSX.Element>;
|
|
20
|
+
declare const _default: import('react').MemoExoticComponent<({ id, label, active, checked, selecting, nested, elementsCount, ancestorsCount, unusedAncestorsCount, type, onSelect, onDelete, onToggleCheck }: StyleSelectorTagProps) => import('react').JSX.Element>;
|
|
17
21
|
export default _default;
|