@plitzi/sdk-style 0.39.3 → 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 (62) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/StyleMap/StyleMap.d.ts +9 -4
  3. package/dist/StyleMap/StyleMap.mjs +4 -4
  4. package/dist/StyleMap/helpers/utils.mjs +1 -1
  5. package/dist/StyleReducer.d.ts +4 -3
  6. package/dist/builder/StyleAdvanceEditor.mjs +4 -3
  7. package/dist/builder/components/InputEasing/Curve.mjs +1 -1
  8. package/dist/builder/components/InputEasing/Grid.mjs +3 -3
  9. package/dist/builder/components/InputEasing/InputEasing.mjs +2 -2
  10. package/dist/builder/components/InputEasing/InputEasingButton.mjs +1 -1
  11. package/dist/builder/components/InputEasing/InputEasingList.mjs +4 -4
  12. package/dist/builder/components/Selector/Selector.d.ts +3 -1
  13. package/dist/builder/components/Selector/Selector.mjs +153 -132
  14. package/dist/builder/components/Selector/SelectorItem/ItemOptions.mjs +4 -3
  15. package/dist/builder/components/Selector/SelectorItem/SelectorItem.d.ts +6 -1
  16. package/dist/builder/components/Selector/SelectorItem/SelectorItem.mjs +51 -39
  17. package/dist/builder/components/Selector/SelectorItem/helpers.d.ts +1 -1
  18. package/dist/builder/components/Selector/SelectorItem/helpers.mjs +1 -1
  19. package/dist/builder/components/Selector/SelectorSuggestions/SelectorSuggestions.d.ts +6 -3
  20. package/dist/builder/components/Selector/SelectorSuggestions/SelectorSuggestions.mjs +56 -18
  21. package/dist/builder/components/Selector/SelectorSuggestions/helpers.d.ts +8 -0
  22. package/dist/builder/components/Selector/SelectorSuggestions/helpers.mjs +9 -0
  23. package/dist/builder/components/Selector/SelectorSuggestions/index.d.ts +1 -0
  24. package/dist/builder/components/Selector/SelectorSuggestions/index.mjs +3 -2
  25. package/dist/builder/components/StyleInspector/Inspector.mjs +1 -1
  26. package/dist/builder/components/StyleInspector/StyleInspector.mjs +4 -3
  27. package/dist/builder/components/StyleInspector/StyleInspectorProvider.mjs +1 -1
  28. package/dist/builder/components/StyleInspector/categories/Background/Background.mjs +1 -1
  29. package/dist/builder/components/StyleInspector/categories/Background/components/BackgroundLayer/BackgroundLayer.mjs +6 -6
  30. package/dist/builder/components/StyleInspector/categories/Background/components/GradientStopBar/GradientStopEditor.mjs +3 -3
  31. package/dist/builder/components/StyleInspector/categories/Background/components/LayerGroup/LayerGroup.mjs +1 -1
  32. package/dist/builder/components/StyleInspector/categories/Background/modes/RawMode.mjs +1 -1
  33. package/dist/builder/components/StyleInspector/categories/Effects/Filters/FilterItem.mjs +1 -1
  34. package/dist/builder/components/StyleInspector/categories/Effects/Transition/TransitionEasing.mjs +4 -4
  35. package/dist/builder/components/StyleInspector/categories/Effects/Transition/TransitionItem.mjs +1 -1
  36. package/dist/builder/components/StyleInspector/categories/Position/PositionAdvanced.mjs +5 -5
  37. package/dist/builder/components/StyleInspector/categories/Spacing/SpacingEditor.mjs +1 -1
  38. package/dist/builder/components/StyleInspector/categories/Spacing/SpacingMargin.mjs +1 -1
  39. package/dist/builder/components/StyleInspector/categories/Spacing/SpacingPadding.mjs +2 -2
  40. package/dist/builder/components/StyleInspector/components/AncestorRules/AncestorRuleChip.mjs +1 -1
  41. package/dist/builder/components/StyleInspector/components/AncestorRules/AncestorRules.mjs +1 -1
  42. package/dist/builder/components/StyleInspector/components/CategoryContainer/CategoryContainer.mjs +5 -5
  43. package/dist/builder/components/StyleInspector/components/CategoryOption/categoryTypes/OptionIconGroup.mjs +1 -1
  44. package/dist/builder/components/StyleInspector/components/InspectorFooter/InspectorFooter.mjs +3 -3
  45. package/dist/builder/components/StyleInspector/components/InspectorLabel/InspectorLabel.mjs +2 -2
  46. package/dist/builder/components/StyleInspector/components/InspectorSearch/InspectorSearch.mjs +1 -1
  47. package/dist/builder/components/StyleInspector/components/ShadowItem/ShadowItem.mjs +1 -1
  48. package/dist/builder/components/StyleInspector/components/TargetSummary/TargetSummary.mjs +2 -2
  49. package/dist/builder/components/StyleInspector/components/ValueList/ValueList.mjs +1 -1
  50. package/dist/builder/components/StyleInspector/components/ValueListItem/ValueListItem.mjs +6 -6
  51. package/dist/builder/components/StyleManager/ManagerSelector.mjs +272 -116
  52. package/dist/builder/components/StyleManager/StyleManager.mjs +75 -35
  53. package/dist/builder/components/StyleManager/StyleSelectorTag.d.ts +5 -1
  54. package/dist/builder/components/StyleManager/StyleSelectorTag.mjs +81 -63
  55. package/dist/builder/hooks/useWindowedList.d.ts +19 -0
  56. package/dist/builder/hooks/useWindowedList.mjs +38 -0
  57. package/dist/helpers/processSelectorVariables.mjs +12 -13
  58. package/package.json +8 -8
  59. package/dist/builder/components/Selector/SelectorSuggestions/SuggestionsCreator.d.ts +0 -7
  60. package/dist/builder/components/Selector/SelectorSuggestions/SuggestionsCreator.mjs +0 -19
  61. package/dist/builder/components/Selector/SelectorSuggestions/SuggestionsList.d.ts +0 -7
  62. package/dist/builder/components/Selector/SelectorSuggestions/SuggestionsList.mjs +0 -24
@@ -4,11 +4,11 @@ import r from "@plitzi/plitzi-ui/Icon";
4
4
  import i from "@plitzi/plitzi-ui/Switch";
5
5
  // src/builder/components/StyleInspector/components/InspectorFooter/InspectorFooter.tsx
6
6
  var a = ({ replaceTokens: a, showAllOptions: o, canShowAllOptions: s, onCollapseAll: c, onChangeReplaceTokens: l, onChangeShowAllOptions: u }) => /* @__PURE__ */ n("div", {
7
- className: "flex items-center justify-between gap-3 border-t border-gray-200 px-2.5 py-1.5 dark:border-zinc-800",
7
+ className: "border-ui-line flex items-center justify-between gap-3 border-t px-2.5 py-1.5",
8
8
  children: [/* @__PURE__ */ n("div", {
9
- className: "flex items-center gap-3 text-zinc-500 dark:text-zinc-400",
9
+ className: "text-ui-fg-subtle flex items-center gap-3",
10
10
  children: [/* @__PURE__ */ t(r, {
11
- className: "cursor-pointer text-xs hover:text-zinc-800 dark:hover:text-zinc-100",
11
+ className: "hover:text-ui-fg cursor-pointer text-xs",
12
12
  icon: "fa-solid fa-angles-up",
13
13
  title: "Collapse every category",
14
14
  onClick: c
@@ -26,8 +26,8 @@ var l = i(({ keyValue: i, children: l, className: u = "", size: d = "small", sec
26
26
  children: /* @__PURE__ */ s("label", {
27
27
  className: c("m-0 truncate rounded-sm leading-5 transition-colors duration-150", {
28
28
  "px-1": !f,
29
- "rounded-b-none border border-gray-300 bg-gray-100 px-2 font-semibold text-zinc-700 dark:border-zinc-600 dark:bg-zinc-700 dark:text-zinc-200": f,
30
- "text-zinc-600 dark:text-zinc-400": !f && _ === "none",
29
+ "border-ui-line-strong bg-ui-active text-ui-fg rounded-b-none border px-2 font-semibold": f,
30
+ "text-ui-fg-muted": !f && _ === "none",
31
31
  "bg-sky-500/12 text-sky-700 dark:bg-sky-400/12 dark:text-sky-300": _ === "value",
32
32
  "bg-emerald-500/12 text-emerald-700 dark:bg-emerald-400/12 dark:text-emerald-300": _ === "variable",
33
33
  "bg-violet-500/12 text-violet-700 dark:bg-violet-400/14 dark:text-violet-300": _ === "binding",
@@ -7,7 +7,7 @@ var r = ({ value: r, onChange: i }) => {
7
7
  e.key === "Escape" && r && (e.stopPropagation(), i(""));
8
8
  }, [i, r]);
9
9
  return /* @__PURE__ */ t("div", {
10
- className: "border-b border-gray-200 px-2 py-1.5 dark:border-zinc-800",
10
+ className: "border-ui-line border-b px-2 py-1.5",
11
11
  children: /* @__PURE__ */ t(n, {
12
12
  size: "xs",
13
13
  value: r,
@@ -55,7 +55,7 @@ var p = o(({ value: o, withSpread: p, onChange: m, onRemove: h }) => {
55
55
  value: o,
56
56
  onChange: b
57
57
  }), /* @__PURE__ */ d("p", {
58
- className: "m-0 text-[11px] text-zinc-500 dark:text-zinc-400",
58
+ className: "text-ui-fg-subtle m-0 text-[11px]",
59
59
  children: "Not a single shadow the editor can split into parts (a token, for one), so it is edited as written."
60
60
  })] }),
61
61
  g && p && /* @__PURE__ */ d(r, {
@@ -5,7 +5,7 @@ var i = e(({ selectorName: e, parts: i, onReset: a }) => /* @__PURE__ */ n("div"
5
5
  className: "bg-primary-500/10 dark:bg-primary-400/10 flex items-center gap-2 rounded-md px-2 py-1 text-xs",
6
6
  children: [
7
7
  /* @__PURE__ */ t("span", {
8
- className: "shrink-0 text-zinc-500 dark:text-zinc-400",
8
+ className: "text-ui-fg-subtle shrink-0",
9
9
  children: "Editing"
10
10
  }),
11
11
  /* @__PURE__ */ t("span", {
@@ -13,7 +13,7 @@ var i = e(({ selectorName: e, parts: i, onReset: a }) => /* @__PURE__ */ n("div"
13
13
  children: [e, ...i].filter(Boolean).join(" › ")
14
14
  }),
15
15
  /* @__PURE__ */ t(r, {
16
- className: "shrink-0 cursor-pointer text-zinc-500 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-100",
16
+ className: "text-ui-fg-subtle hover:text-ui-fg shrink-0 cursor-pointer",
17
17
  icon: "fa-solid fa-xmark",
18
18
  title: "Back to the selector's own rules",
19
19
  onClick: a
@@ -10,7 +10,7 @@ var i = t(({ label: t, keys: i, addLabel: a, onAdd: o, children: s }) => /* @__P
10
10
  children: t
11
11
  }), /* @__PURE__ */ n("button", {
12
12
  type: "button",
13
- className: "focus-visible:outline-primary-500 flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-zinc-500 transition-colors duration-150 hover:bg-gray-100 hover:text-zinc-900 focus-visible:outline-2 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-100",
13
+ className: "focus-visible:outline-primary-500 text-ui-fg-subtle hover:bg-ui-hover hover:text-ui-fg flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-md transition-colors duration-150 focus-visible:outline-2",
14
14
  title: a,
15
15
  "aria-label": a,
16
16
  onClick: o,
@@ -21,19 +21,19 @@ var l = e(({ summary: e, preview: l, title: u, removeLabel: d, onRemove: f, chil
21
21
  children: [/* @__PURE__ */ o(c.Trigger, {
22
22
  className: s("group flex h-7 w-full min-w-0 cursor-pointer items-center gap-2 rounded-md border px-2 text-xs transition-colors duration-150 select-none", {
23
23
  "border-primary-500/60 bg-primary-500/5 dark:border-primary-400/60 dark:bg-primary-400/10": m,
24
- "border-gray-200 bg-white hover:border-gray-300 hover:bg-gray-50 dark:border-zinc-700 dark:bg-zinc-800/50 dark:hover:border-zinc-600 dark:hover:bg-zinc-800": !m
24
+ "border-ui-line bg-ui-raised hover:border-ui-line-strong hover:bg-ui-hover": !m
25
25
  }),
26
26
  onClick: _,
27
27
  children: [
28
28
  l,
29
29
  /* @__PURE__ */ a("span", {
30
- className: "min-w-0 grow truncate font-mono text-[11px] text-zinc-700 dark:text-zinc-200",
30
+ className: "text-ui-fg min-w-0 grow truncate font-mono text-[11px]",
31
31
  title: e,
32
32
  children: e
33
33
  }),
34
34
  /* @__PURE__ */ a("button", {
35
35
  type: "button",
36
- className: "flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded text-zinc-400 transition-colors duration-150 group-hover:text-zinc-500 hover:bg-red-500/10 hover:text-red-600 dark:text-zinc-500 dark:group-hover:text-zinc-400 dark:hover:text-red-400",
36
+ className: "text-ui-fg-subtle group-hover:text-ui-fg flex h-5 w-5 shrink-0 cursor-pointer items-center justify-center rounded transition-colors duration-150 hover:bg-red-500/10 hover:text-red-600 dark:hover:text-red-400",
37
37
  title: d,
38
38
  "aria-label": d,
39
39
  onClick: y,
@@ -47,13 +47,13 @@ var l = e(({ summary: e, preview: l, title: u, removeLabel: d, onRemove: f, chil
47
47
  className: "flex w-full flex-col outline-none",
48
48
  tabIndex: -1,
49
49
  children: [/* @__PURE__ */ o("div", {
50
- className: "flex items-center justify-between gap-2 border-b border-gray-200 px-3 py-2 dark:border-zinc-700",
50
+ className: "border-ui-line flex items-center justify-between gap-2 border-b px-3 py-2",
51
51
  children: [/* @__PURE__ */ a("span", {
52
- className: "text-xs font-semibold text-zinc-800 dark:text-zinc-100",
52
+ className: "text-ui-fg text-xs font-semibold",
53
53
  children: u
54
54
  }), /* @__PURE__ */ a("button", {
55
55
  type: "button",
56
- className: "flex h-5 w-5 cursor-pointer items-center justify-center rounded text-zinc-400 hover:bg-gray-100 hover:text-zinc-900 dark:text-zinc-500 dark:hover:bg-zinc-800 dark:hover:text-zinc-100",
56
+ className: "text-ui-fg-subtle hover:bg-ui-hover hover:text-ui-fg flex h-5 w-5 cursor-pointer items-center justify-center rounded",
57
57
  title: "Close",
58
58
  "aria-label": "Close",
59
59
  onClick: v,
@@ -1,170 +1,326 @@
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";
5
- import { useBuilderStore as l } from "@plitzi/sdk-shared/store";
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";
6
+ import { useBuilderStore as ee } from "@plitzi/sdk-shared/store";
6
7
  import { jsx as u, jsxs as d } from "react/jsx-runtime";
7
- import { produce as f } from "immer";
8
- import p from "@plitzi/plitzi-ui/Button";
8
+ import { produce as te } from "immer";
9
+ import f from "@plitzi/plitzi-ui/Button";
10
+ import p from "clsx";
9
11
  import m from "@plitzi/plitzi-ui/Modal";
10
12
  import { ComponentContext as h } from "@plitzi/sdk-shared/elements";
11
- import { get as g, isEmpty as _, set as ee } 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 { BuilderContext as b } from "@plitzi/sdk-shared/builder/contexts";
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(h), ne = s(() => E.filter((e) => !!e.componentType).map((e) => e.componentType), [E]), N = s(() => {
17
- let e = E;
18
- return _(D) || (e = E.filter((e) => e.name.toLowerCase().includes(D.toLowerCase()))), e.sort((e, t) => {
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";
17
+ // src/builder/components/StyleManager/ManagerSelector.tsx
18
+ var y = (e) => e.split(":")[0], re = (e, t) => {
19
+ let n = y(t);
20
+ return !!n && Object.values(e.definition.styleSelectors).some((e) => e.split(" ").includes(n));
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) => {
19
49
  let n = Number(e.type === "element"), r = Number(t.type === "element");
20
50
  return n === r ? e.name.localeCompare(t.name) : r - n;
21
51
  });
22
- }, [E, D]), P = o((e) => O(e), [O]), 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) => {
23
112
  if (t) {
24
113
  if (t.mode === "default") {
25
114
  let { name: e } = t;
26
- j("styleAddSelector", i, e, "class", void 0, void 0, {
115
+ F("styleAddSelector", a, e, "class", void 0, void 0, {
27
116
  styleSelector: void 0,
28
117
  componentType: void 0
29
118
  });
30
119
  } else {
31
120
  let { componentType: e } = t;
32
- j("styleAddSelector", i, e, "element", void 0, void 0, {
121
+ F("styleAddSelector", a, e, "element", void 0, void 0, {
33
122
  styleSelector: void 0,
34
123
  componentType: e
35
124
  });
36
125
  }
37
126
  }
38
- }, [j, i]), [I, L, R, z] = v({
127
+ }, [F, a]), [pe, me, he, q] = _({
39
128
  id: "add-selector",
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(g(e, "definition.styleSelectors", {})).find((e) => (t.includes(":") && (t = g(t.split(":"), "0", t)), e && t && e.split(" ").includes(t))) : [], []), H = 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) => {
44
133
  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) => f(e, (t) => {
46
- Object.keys(e.definition.styleSelectors).forEach((e) => {
47
- r.has(g(t, `definition.styleSelectors.${e}`, "")) && ee(t, `definition.styleSelectors.${e}`, "");
48
- });
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) => {
135
+ let { styleSelectors: t } = e.definition;
136
+ for (let [e, n] of Object.entries(t)) t[e] = n.split(" ").filter((e) => e && !i.has(e)).join(" ");
49
137
  }));
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);
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);
51
139
  }, [
52
- j,
53
- i,
54
- V,
55
- S,
56
- T
57
- ]), [U, W, G, K, , q] = v({
140
+ F,
141
+ a,
142
+ T,
143
+ D
144
+ ]), [ve, ye, J, Y, , X] = _({
58
145
  id: "delete-selector",
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) => ({
61
- ...e,
62
- [t.name]: S.filter((e) => V(e, t.name)).length
63
- }), {}), [
64
- N,
65
- S,
66
- V
67
- ]), Q = s(() => Object.fromEntries(E.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, {
68
148
  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
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
75
155
  });
76
156
  }, [
77
157
  Q,
78
- j,
79
- M
80
- ]), se = o(() => void K(void 0, !1), [K]), ce = o(() => void K(void 0, !0), [K]);
158
+ F,
159
+ I
160
+ ]), De = s(() => void Y(void 0, !1), [Y]), Oe = s(() => void Y(void 0, !0), [Y]);
81
161
  return /* @__PURE__ */ d("div", {
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",
162
+ className: "border-ui-line flex w-[300px] shrink-0 flex-col gap-2 overflow-hidden border-r px-2 pt-2",
83
163
  children: [
84
- /* @__PURE__ */ d(p, {
85
- intent: "primary",
86
- size: "sm",
87
- className: "w-full",
88
- iconPlacement: "before",
89
- onClick: R,
90
- children: [/* @__PURE__ */ u(p.Icon, {
91
- icon: "fas fa-tint",
92
- size: "md",
93
- className: "text-base"
94
- }), "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
+ })]
95
185
  }),
96
- /* @__PURE__ */ u(y, {
97
- placeholder: "Search Selector",
98
- value: D,
99
- onChange: P,
100
- 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))
101
207
  }),
102
208
  $ > 0 && /* @__PURE__ */ d("div", {
103
- className: "flex items-center justify-between gap-2 rounded-sm bg-amber-500/10 px-2 py-1",
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",
104
210
  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(p, {
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, {
108
214
  size: "xs",
109
- onClick: oe,
215
+ onClick: Ee,
110
216
  children: "Clean up"
111
217
  })]
112
218
  }),
113
- k.length > 0 && /* @__PURE__ */ d("div", {
114
- className: "bg-secondary-50 dark:bg-secondary-900/30 flex items-center justify-between gap-2 rounded-sm px-2 py-1",
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",
115
229
  children: [/* @__PURE__ */ d("span", {
116
- className: "text-xs text-zinc-600 dark:text-zinc-300",
117
- children: [k.length, " selected"]
230
+ className: "text-ui-fg-muted text-xs",
231
+ children: [N.length, " selected"]
118
232
  }), /* @__PURE__ */ d("div", {
119
233
  className: "flex gap-1",
120
- children: [/* @__PURE__ */ u(p, {
234
+ children: [/* @__PURE__ */ u(f, {
121
235
  size: "xs",
122
- onClick: X,
236
+ onClick: Se,
123
237
  children: "Clear"
124
- }), /* @__PURE__ */ d(p, {
238
+ }), /* @__PURE__ */ d(f, {
125
239
  intent: "danger",
126
240
  size: "xs",
127
241
  iconPlacement: "before",
128
- onClick: re,
129
- children: [/* @__PURE__ */ u(p.Icon, { icon: "fas fa-trash" }), "Delete"]
242
+ onClick: we,
243
+ children: [/* @__PURE__ */ u(f.Icon, { icon: "fas fa-trash" }), "Delete"]
130
244
  })]
131
245
  })]
132
246
  }),
133
- /* @__PURE__ */ u("div", {
134
- className: "flex grow basis-0 flex-col overflow-y-auto",
135
- children: N.map((t) => {
136
- let { name: n, type: r } = t;
137
- return /* @__PURE__ */ u(e, {
138
- id: n,
139
- active: n === w,
140
- checked: k.includes(n),
141
- label: n,
142
- type: r,
143
- elementsCount: ie[n],
144
- ancestorsCount: Q[n].count,
145
- unusedAncestorsCount: Q[n].unused.size,
146
- onSelect: B,
147
- onDelete: J,
148
- onToggleCheck: Y
149
- }, n);
150
- })
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
+ ]
151
307
  }),
152
308
  /* @__PURE__ */ d(m, {
153
- id: I,
154
- open: L,
155
- onClose: z,
309
+ id: pe,
310
+ open: me,
311
+ onClose: q,
156
312
  size: "sm",
157
- children: [/* @__PURE__ */ u(m.Header, { children: /* @__PURE__ */ u("h4", { children: "Add Selector" }) }), /* @__PURE__ */ u(m.Body, { children: /* @__PURE__ */ u(t, {
158
- componentsNotAvailables: ne,
159
- components: te.current,
160
- onSubmit: z,
161
- 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
162
318
  }) })]
163
319
  }),
164
320
  /* @__PURE__ */ d(m, {
165
- id: U,
166
- open: W,
167
- onClose: K,
321
+ id: ve,
322
+ open: ye,
323
+ onClose: Y,
168
324
  children: [
169
325
  /* @__PURE__ */ u(m.Header, { children: /* @__PURE__ */ u("h4", { children: "Remove Selector" }) }),
170
326
  /* @__PURE__ */ d(m.Body, { children: [Z > 1 && /* @__PURE__ */ d("h4", { children: [
@@ -174,12 +330,12 @@ var x = i(({ displayMode: i, flat: x, flatList: S, selectors: C, selected: w, on
174
330
  ] }), Z <= 1 && /* @__PURE__ */ u("h4", { children: "Do you want to remove this item ?" })] }),
175
331
  /* @__PURE__ */ d(m.Footer, {
176
332
  justify: "end",
177
- children: [/* @__PURE__ */ u(p, {
178
- onClick: se,
333
+ children: [/* @__PURE__ */ u(f, {
334
+ onClick: De,
179
335
  size: "sm",
180
336
  children: "Cancel"
181
- }), /* @__PURE__ */ u(p, {
182
- onClick: ce,
337
+ }), /* @__PURE__ */ u(f, {
338
+ onClick: Oe,
183
339
  size: "sm",
184
340
  children: "Submit"
185
341
  })]
@@ -189,4 +345,4 @@ var x = i(({ displayMode: i, flat: x, flatList: S, selectors: C, selected: w, on
189
345
  ]
190
346
  });
191
347
  });
192
- export { x as default };
348
+ export { w as default };