@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.
Files changed (54) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/builder/StyleAdvanceEditor.mjs +4 -3
  3. package/dist/builder/components/InputEasing/Curve.mjs +1 -1
  4. package/dist/builder/components/InputEasing/Grid.mjs +3 -3
  5. package/dist/builder/components/InputEasing/InputEasing.mjs +2 -2
  6. package/dist/builder/components/InputEasing/InputEasingButton.mjs +1 -1
  7. package/dist/builder/components/InputEasing/InputEasingList.mjs +4 -4
  8. package/dist/builder/components/Selector/Selector.mjs +143 -123
  9. package/dist/builder/components/Selector/SelectorItem/ItemOptions.mjs +4 -3
  10. package/dist/builder/components/Selector/SelectorItem/SelectorItem.mjs +29 -19
  11. package/dist/builder/components/Selector/SelectorItem/helpers.d.ts +1 -1
  12. package/dist/builder/components/Selector/SelectorItem/helpers.mjs +1 -1
  13. package/dist/builder/components/Selector/SelectorSuggestions/SelectorSuggestions.d.ts +6 -3
  14. package/dist/builder/components/Selector/SelectorSuggestions/SelectorSuggestions.mjs +56 -18
  15. package/dist/builder/components/Selector/SelectorSuggestions/helpers.d.ts +8 -0
  16. package/dist/builder/components/Selector/SelectorSuggestions/helpers.mjs +9 -0
  17. package/dist/builder/components/Selector/SelectorSuggestions/index.d.ts +1 -0
  18. package/dist/builder/components/Selector/SelectorSuggestions/index.mjs +3 -2
  19. package/dist/builder/components/StyleInspector/Inspector.mjs +1 -1
  20. package/dist/builder/components/StyleInspector/StyleInspector.mjs +2 -2
  21. package/dist/builder/components/StyleInspector/categories/Background/Background.mjs +1 -1
  22. package/dist/builder/components/StyleInspector/categories/Background/components/BackgroundLayer/BackgroundLayer.mjs +6 -6
  23. package/dist/builder/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopEditor.mjs +3 -3
  24. package/dist/builder/components/StyleInspector/categories/Background/components/LayerGroup/LayerGroup.mjs +1 -1
  25. package/dist/builder/components/StyleInspector/categories/Background/modes/RawMode.mjs +1 -1
  26. package/dist/builder/components/StyleInspector/categories/Effects/Filters/FilterItem.mjs +1 -1
  27. package/dist/builder/components/StyleInspector/categories/Effects/Transition/TransitionEasing.mjs +4 -4
  28. package/dist/builder/components/StyleInspector/categories/Effects/Transition/TransitionItem.mjs +1 -1
  29. package/dist/builder/components/StyleInspector/categories/Position/PositionAdvanced.mjs +5 -5
  30. package/dist/builder/components/StyleInspector/categories/Spacing/SpacingEditor.mjs +1 -1
  31. package/dist/builder/components/StyleInspector/categories/Spacing/SpacingMargin.mjs +1 -1
  32. package/dist/builder/components/StyleInspector/categories/Spacing/SpacingPadding.mjs +2 -2
  33. package/dist/builder/components/StyleInspector/components/AncestorRules/AncestorRuleChip.mjs +1 -1
  34. package/dist/builder/components/StyleInspector/components/AncestorRules/AncestorRules.mjs +1 -1
  35. package/dist/builder/components/StyleInspector/components/CategoryContainer/CategoryContainer.mjs +5 -5
  36. package/dist/builder/components/StyleInspector/components/CategoryOption/categoryTypes/OptionIconGroup.mjs +1 -1
  37. package/dist/builder/components/StyleInspector/components/InspectorFooter/InspectorFooter.mjs +3 -3
  38. package/dist/builder/components/StyleInspector/components/InspectorLabel/InspectorLabel.mjs +2 -2
  39. package/dist/builder/components/StyleInspector/components/InspectorSearch/InspectorSearch.mjs +1 -1
  40. package/dist/builder/components/StyleInspector/components/ShadowItem/ShadowItem.mjs +1 -1
  41. package/dist/builder/components/StyleInspector/components/TargetSummary/TargetSummary.mjs +2 -2
  42. package/dist/builder/components/StyleInspector/components/ValueList/ValueList.mjs +1 -1
  43. package/dist/builder/components/StyleInspector/components/ValueListItem/ValueListItem.mjs +6 -6
  44. package/dist/builder/components/StyleManager/ManagerSelector.mjs +281 -123
  45. package/dist/builder/components/StyleManager/StyleManager.mjs +75 -35
  46. package/dist/builder/components/StyleManager/StyleSelectorTag.d.ts +5 -1
  47. package/dist/builder/components/StyleManager/StyleSelectorTag.mjs +81 -63
  48. package/dist/builder/hooks/useWindowedList.d.ts +19 -0
  49. package/dist/builder/hooks/useWindowedList.mjs +38 -0
  50. package/package.json +8 -8
  51. package/dist/builder/components/Selector/SelectorSuggestions/SuggestionsCreator.d.ts +0 -7
  52. package/dist/builder/components/Selector/SelectorSuggestions/SuggestionsCreator.mjs +0 -19
  53. package/dist/builder/components/Selector/SelectorSuggestions/SuggestionsList.d.ts +0 -7
  54. 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 "../../models/SelectorForm/index.mjs";
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";
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 l, jsxs as u } from "react/jsx-runtime";
7
- import { produce as d } from "immer";
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 "@plitzi/plitzi-ui/Modal";
10
- import { ComponentContext as m } from "@plitzi/sdk-shared/elements";
11
- import { isEmpty as te } from "@plitzi/plitzi-ui/helpers/lodash";
12
- import h from "@plitzi/plitzi-ui/hooks/useDisclosure";
13
- import g from "@plitzi/plitzi-ui/Input";
14
- import { BuilderContext as _ } from "@plitzi/sdk-shared/builder/contexts";
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 v = (e) => e.split(":")[0], y = (e, t) => {
17
- let n = v(t);
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
- }, b = i(({ displayMode: i, flat: b, flatList: x, selectors: S, selected: C, onSelect: w }) => {
20
- let T = s(() => Object.values(S ?? {}), [S]), [E, D] = c(""), [O, k] = c([]), { builderHandler: A } = a(_), [j] = ee("style.platform"), { components: M } = a(m), ne = s(() => T.filter((e) => !!e.componentType).map((e) => e.componentType), [T]), N = s(() => {
21
- let e = T;
22
- return te(E) || (e = T.filter((e) => e.name.toLowerCase().includes(E.toLowerCase()))), e.sort((e, t) => {
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
- }, [T, E]), P = o((e) => D(e), [D]), F = o((e, t) => {
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
- A("styleAddSelector", i, e, "class", void 0, void 0, {
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
- A("styleAddSelector", i, e, "element", void 0, void 0, {
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
- }, [A, i]), [I, L, R, z] = h({
127
+ }, [F, a]), [pe, me, he, q] = _({
43
128
  id: "add-selector",
44
- onClose: F
45
- }), B = o((e) => {
46
- w?.((t) => t?.name === e ? void 0 : T.find((t) => t.name === e));
47
- }, [w, T]), V = o((e, t, n) => {
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), a = new Set(n.map(v)), o = x.filter((e) => n.some((t) => y(e, t))).map((e) => d(e, (e) => {
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 && !a.has(e)).join(" ");
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 && A("schemaUpdateElements", o), A("styleRemoveSelectors", i, n), k((e) => e.filter((e) => !r.has(e))), w?.((e) => e && r.has(e.name) ? void 0 : e);
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
- A,
56
- i,
57
- x,
58
- w
59
- ]), [H, U, W, G, , K] = h({
140
+ F,
141
+ a,
142
+ T,
143
+ D
144
+ ]), [ve, ye, J, Y, , X] = _({
60
145
  id: "delete-selector",
61
- onClose: V
62
- }), q = o((e) => W(void 0, [e]), [W]), J = o((e) => k((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]), []), Y = o(() => k([]), []), X = o(() => W(void 0, O), [W, O]), Z = Array.isArray(K) ? K.length : 0, re = s(() => N.reduce((e, t) => ({
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: r(b, e)
68
- }])), [b, T]), $ = s(() => Object.values(Q).reduce((e, { unused: t }) => e + t.size, 0), [Q]), ie = `${$} unused ancestor ${$ === 1 ? "rule" : "rules"}`, ae = o(() => {
69
- for (let [e, { unused: t }] of Object.entries(Q)) for (let r of n(j, e, t)) A("styleUpdateSelector", r.displayMode, e, void 0, void 0, {
70
- styleSelector: r.styleSelector,
71
- styleAncestor: r.styleAncestor,
72
- componentType: j[r.displayMode][e].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
- A,
77
- j
78
- ]), oe = o(() => void G(void 0, !1), [G]), se = o(() => void G(void 0, !0), [G]);
79
- return /* @__PURE__ */ u("div", {
80
- 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",
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__ */ u(f, {
83
- intent: "primary",
84
- size: "sm",
85
- className: "w-full",
86
- iconPlacement: "before",
87
- onClick: R,
88
- children: [/* @__PURE__ */ l(f.Icon, {
89
- icon: "fas fa-tint",
90
- size: "md",
91
- className: "text-base"
92
- }), "New Selector"]
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__ */ l(g, {
95
- placeholder: "Search Selector",
96
- value: E,
97
- onChange: P,
98
- size: "xs"
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__ */ u("div", {
101
- className: "flex items-center justify-between gap-2 rounded-sm bg-amber-500/10 px-2 py-1",
102
- children: [/* @__PURE__ */ u("span", {
103
- className: "text-xs text-amber-700 dark:text-amber-300",
104
- children: [/* @__PURE__ */ l("i", { className: "fas fa-triangle-exclamation mr-1" }), ie]
105
- }), /* @__PURE__ */ l(f, {
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: ae,
215
+ onClick: Ee,
108
216
  children: "Clean up"
109
217
  })]
110
218
  }),
111
- O.length > 0 && /* @__PURE__ */ u("div", {
112
- className: "bg-secondary-50 dark:bg-secondary-900/30 flex items-center justify-between gap-2 rounded-sm px-2 py-1",
113
- children: [/* @__PURE__ */ u("span", {
114
- className: "text-xs text-zinc-600 dark:text-zinc-300",
115
- children: [O.length, " selected"]
116
- }), /* @__PURE__ */ u("div", {
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__ */ l(f, {
234
+ children: [/* @__PURE__ */ u(f, {
119
235
  size: "xs",
120
- onClick: Y,
236
+ onClick: Se,
121
237
  children: "Clear"
122
- }), /* @__PURE__ */ u(f, {
238
+ }), /* @__PURE__ */ d(f, {
123
239
  intent: "danger",
124
240
  size: "xs",
125
241
  iconPlacement: "before",
126
- onClick: X,
127
- children: [/* @__PURE__ */ l(f.Icon, { icon: "fas fa-trash" }), "Delete"]
242
+ onClick: we,
243
+ children: [/* @__PURE__ */ u(f.Icon, { icon: "fas fa-trash" }), "Delete"]
128
244
  })]
129
245
  })]
130
246
  }),
131
- /* @__PURE__ */ l("div", {
132
- className: "flex grow basis-0 flex-col overflow-y-auto",
133
- children: N.map((t) => {
134
- let { name: n, type: r } = t;
135
- return /* @__PURE__ */ l(e, {
136
- id: n,
137
- active: n === C,
138
- checked: O.includes(n),
139
- label: n,
140
- type: r,
141
- elementsCount: re[n],
142
- ancestorsCount: Q[n].count,
143
- unusedAncestorsCount: Q[n].unused.size,
144
- onSelect: B,
145
- onDelete: q,
146
- onToggleCheck: J
147
- }, n);
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__ */ u(p, {
151
- id: I,
152
- open: L,
153
- onClose: z,
308
+ /* @__PURE__ */ d(m, {
309
+ id: pe,
310
+ open: me,
311
+ onClose: q,
154
312
  size: "sm",
155
- children: [/* @__PURE__ */ l(p.Header, { children: /* @__PURE__ */ l("h4", { children: "Add Selector" }) }), /* @__PURE__ */ l(p.Body, { children: /* @__PURE__ */ l(t, {
156
- componentsNotAvailables: ne,
157
- components: M.current,
158
- onSubmit: z,
159
- onClose: z
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__ */ u(p, {
163
- id: H,
164
- open: U,
165
- onClose: G,
320
+ /* @__PURE__ */ d(m, {
321
+ id: ve,
322
+ open: ye,
323
+ onClose: Y,
166
324
  children: [
167
- /* @__PURE__ */ l(p.Header, { children: /* @__PURE__ */ l("h4", { children: "Remove Selector" }) }),
168
- /* @__PURE__ */ u(p.Body, { children: [Z > 1 && /* @__PURE__ */ u("h4", { children: [
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__ */ l("h4", { children: "Do you want to remove this item ?" })] }),
173
- /* @__PURE__ */ u(p.Footer, {
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__ */ l(f, {
176
- onClick: oe,
333
+ children: [/* @__PURE__ */ u(f, {
334
+ onClick: De,
177
335
  size: "sm",
178
336
  children: "Cancel"
179
- }), /* @__PURE__ */ l(f, {
180
- onClick: se,
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 { b as default };
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 { jsx as o, jsxs as s } from "react/jsx-runtime";
6
- import { get as c } from "@plitzi/plitzi-ui/helpers";
7
- import { ComponentContext as l } from "@plitzi/sdk-shared/elements";
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 u = () => {
10
- let { componentDefinitions: u } = n(l), [d, f] = i(void 0), [[p, m]] = a(["schema.flat", "displayMode"]), [h] = a(`style.platform.${m}`), g = r(() => Object.values(p), [p]), _ = r(() => d?.type === "element" ? Object.keys(c(u.current, `${d.componentType}.definition.styleSelectors`, {})) : ["base"], [u, d]), v = r(() => d?.type === "element" ? Object.keys(c(u.current, `${d.componentType}.defaultStyle.subTypes`, {})) : [], [u, d]), y = r(() => {
11
- if (d) return d.type === "element" && _.length > 1 ? _.reduce((e, t) => ({
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]: d.componentType
14
- }), {}) : { base: d.name };
15
- }, [d, _]);
16
- return /* @__PURE__ */ o("div", {
17
- className: "flex h-full grow flex-col overflow-auto",
18
- children: /* @__PURE__ */ s("div", {
19
- className: "flex grow overflow-auto",
20
- children: [/* @__PURE__ */ o(e, {
21
- displayMode: m,
22
- selectors: h,
23
- flat: p,
24
- flatList: g,
25
- selected: d?.name,
26
- onSelect: f
27
- }), /* @__PURE__ */ s("div", {
28
- className: "flex grow basis-0 flex-col overflow-auto",
29
- children: [d && /* @__PURE__ */ o(t, {
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: m,
32
- selectors: h,
33
- styleSelectors: y,
34
- styleSelectorsAvailables: _,
35
- componentSubTypesAvailables: v,
36
- allowStyleSelector: d.type === "element",
37
- componentType: d.componentType,
38
- value: d.name
39
- }), !d && /* @__PURE__ */ o("div", {
40
- className: "m-3 rounded-sm border-2 border-dashed border-gray-300 p-3 text-center text-zinc-500 select-none dark:border-zinc-600 dark:text-zinc-400",
41
- children: "No selector or element selected. Click on one to select it."
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 { u as default };
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;