@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @plitzi/sdk-style
2
2
 
3
+ ## 0.39.6
4
+
5
+ ### Patch Changes
6
+
7
+ - @plitzi/sdk-event-bridge@0.39.6
8
+ - @plitzi/sdk-shared@0.39.6
9
+ - @plitzi/sdk-variables@0.39.6
10
+
11
+ ## 0.39.5
12
+
13
+ ### Patch Changes
14
+
15
+ - 4427674: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
16
+ `@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
17
+ - Updated dependencies [4427674]
18
+ - @plitzi/sdk-event-bridge@0.39.5
19
+ - @plitzi/sdk-shared@0.39.5
20
+ - @plitzi/sdk-variables@0.39.5
21
+
22
+ ## 0.39.4
23
+
24
+ ### Patch Changes
25
+
26
+ - 35415a1: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
27
+ `@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
28
+ - Updated dependencies [35415a1]
29
+ - @plitzi/sdk-event-bridge@0.39.4
30
+ - @plitzi/sdk-shared@0.39.4
31
+ - @plitzi/sdk-variables@0.39.4
32
+
3
33
  ## 0.39.3
4
34
 
5
35
  ### Patch Changes
@@ -4,20 +4,25 @@ export type StyleMapProps = {
4
4
  variables?: Style['variables'];
5
5
  fonts?: Style['fonts'];
6
6
  };
7
+ /**
8
+ * What a selector is written with: its attributes whole, or — at a `styleSelector` and a `path` — the block, the object
9
+ * or the value that goes there. The reducer's actions and the builder's style context take the same.
10
+ */
11
+ export type SelectorValue = StyleItem['attributes'] | Partial<StyleObject> | StyleValue;
7
12
  declare class StyleMap {
8
13
  platform: Style['platform'];
9
14
  variables: Style['variables'];
10
15
  fonts: SpaceFont[];
11
16
  constructor(props: StyleMapProps);
12
17
  static getInstance: (props: StyleMapProps) => StyleMap;
13
- addSelector(displayMode: DisplayMode, selector: string, type: TagType, path: StyleCategory | undefined, value: StyleItem['attributes'] | Partial<StyleObject> | StyleValue | undefined, params: StyleTarget): boolean;
14
- static addSelector(style: Pick<Style, 'platform' | 'variables'>, displayMode: DisplayMode, selector: string, type: TagType, path: StyleCategory | undefined, value: StyleItem['attributes'] | Partial<StyleObject> | StyleValue | undefined, params: StyleTarget): boolean;
18
+ addSelector(displayMode: DisplayMode, selector: string, type: TagType, path: StyleCategory | undefined, value: SelectorValue | undefined, params: StyleTarget): boolean;
19
+ static addSelector(style: Pick<Style, 'platform' | 'variables'>, displayMode: DisplayMode, selector: string, type: TagType, path: StyleCategory | undefined, value: SelectorValue | undefined, params: StyleTarget): boolean;
15
20
  getSelector: (displayMode: DisplayMode, selector: string) => StyleItem | undefined;
16
21
  static getSelector: (style: Pick<Style, "platform" | "variables">, displayMode: DisplayMode, selector: string) => StyleItem | undefined;
17
- updateSelector(displayMode: DisplayMode, selector: string, path: StyleCategory | undefined, value: StyleItem['attributes'] | Partial<StyleObject> | StyleValue | undefined, params: StyleTarget & {
22
+ updateSelector(displayMode: DisplayMode, selector: string, path: StyleCategory | undefined, value: SelectorValue | undefined, params: StyleTarget & {
18
23
  styleSelector: string;
19
24
  }): boolean;
20
- static updateSelector(style: Pick<Style, 'platform' | 'variables'>, displayMode: DisplayMode, selector: string, path: StyleCategory | undefined, value: StyleItem['attributes'] | Partial<StyleObject> | StyleValue | undefined, params: StyleTarget & {
25
+ static updateSelector(style: Pick<Style, 'platform' | 'variables'>, displayMode: DisplayMode, selector: string, path: StyleCategory | undefined, value: SelectorValue | undefined, params: StyleTarget & {
21
26
  styleSelector: string;
22
27
  }): boolean;
23
28
  removeSelector: (displayMode: DisplayMode | undefined, selector: string) => boolean;
@@ -29,10 +29,10 @@ var o = class {
29
29
  return this.getInstance(e).updateSelector(t, n, r, i, a);
30
30
  }
31
31
  removeSelector = (e, t) => {
32
- if (e) return this.platform[e][t] ? (delete this.platform[e][t], !0) : !1;
32
+ if (e) return this.platform[e][t] ? (Reflect.deleteProperty(this.platform[e], t), !0) : !1;
33
33
  let n = !1;
34
34
  return Object.keys(this.platform).forEach((e) => {
35
- this.platform[e][t] && (n = !0, delete this.platform[e][t]);
35
+ this.platform[e][t] && (n = !0, Reflect.deleteProperty(this.platform[e], t));
36
36
  }), n;
37
37
  };
38
38
  static removeSelector = (e, t, n) => this.getInstance(e).removeSelector(t, n);
@@ -48,14 +48,14 @@ var o = class {
48
48
  static updateSelectorVariable = (e, t, n, r, i, a) => this.getInstance(e).updateSelectorVariable(t, n, r, i, a);
49
49
  removeSelectorVariable = (n, r, i, o) => {
50
50
  let s = t(this.platform, n, r);
51
- return !s || !s.variables || !s.variables[i] || !s.variables[i][o] ? !1 : (delete s.variables[i][o], Object.keys(s.variables[i]).length === 0 && delete s.variables[i], Object.keys(s.variables).length === 0 && delete s.variables, a(this.platform, `${n}.${r}.cache`, e(s)), !0);
51
+ return !s || !s.variables || !s.variables[i] || !s.variables[i][o] ? !1 : (Reflect.deleteProperty(s.variables[i], o), Object.keys(s.variables[i]).length === 0 && Reflect.deleteProperty(s.variables, i), Object.keys(s.variables).length === 0 && delete s.variables, a(this.platform, `${n}.${r}.cache`, e(s)), !0);
52
52
  };
53
53
  static removeSelectorVariable = (e, t, n, r, i) => this.getInstance(e).removeSelectorVariable(t, n, r, i);
54
54
  addVariable = (e, t, n) => (this.variables[e] || (this.variables[e] = {}), !this.variables[e][t] && (this.variables[e][t] = n, !0));
55
55
  static addVariable = (e, t, n, r) => this.getInstance(e).addVariable(t, n, r);
56
56
  updateVariable = (e, t, n) => !this.variables[e] || !this.variables[e][t] ? !1 : (this.variables[e][t] = n, !0);
57
57
  static updateVariable = (e, t, n, r) => this.getInstance(e).updateVariable(t, n, r);
58
- removeVariable = (e, t) => !this.variables[e] || !this.variables[e][t] ? !1 : (delete this.variables[e][t], Object.keys(this.variables[e]).length === 0 && delete this.variables[e], !0);
58
+ removeVariable = (e, t) => !this.variables[e] || !this.variables[e][t] ? !1 : (Reflect.deleteProperty(this.variables[e], t), Object.keys(this.variables[e]).length === 0 && Reflect.deleteProperty(this.variables, e), !0);
59
59
  static removeVariable = (e, t, n) => this.getInstance(e).removeVariable(t, n);
60
60
  addFont = (e) => !this.fonts.some((t) => t.family === e.family) && (this.fonts.push(e), !0);
61
61
  static addFont = (e, t) => {
@@ -10,7 +10,7 @@ var s = (t, n, r) => {
10
10
  };
11
11
  if (n && e(n)) {
12
12
  let e = { ...n };
13
- for (let t in n) e[t] === void 0 && delete e[t];
13
+ for (let t in n) e[t] === void 0 && Reflect.deleteProperty(e, t);
14
14
  return e;
15
15
  }
16
16
  return r;
@@ -1,4 +1,5 @@
1
- import { DisplayMode, SnippetStyle, SpaceFont, Style, StyleCategory, StyleItem, StyleTarget, StyleVariableCategory, StyleVariableValue, TagType } from '@plitzi/sdk-shared';
1
+ import { SelectorValue } from './StyleMap/StyleMap';
2
+ import { DisplayMode, SnippetStyle, SpaceFont, Style, StyleCategory, StyleTarget, StyleVariableCategory, StyleVariableValue, TagType } from '@plitzi/sdk-shared';
2
3
  import { ReducerActionOrigin } from '@plitzi/sdk-shared/helpers';
3
4
  export declare const StyleActions: {
4
5
  readonly STYLE_UPDATE: "STYLE_UPDATE";
@@ -28,14 +29,14 @@ export type StyleReducerActions = StyleReducerActionsBase & ({
28
29
  selector: string;
29
30
  path?: StyleCategory;
30
31
  selectorType: TagType;
31
- value?: StyleItem['attributes'];
32
+ value?: SelectorValue;
32
33
  params: StyleTarget;
33
34
  } | {
34
35
  type: 'STYLE_UPDATE_SELECTOR';
35
36
  displayMode: DisplayMode;
36
37
  selector: string;
37
38
  path?: StyleCategory;
38
- value?: StyleItem['attributes'];
39
+ value?: SelectorValue;
39
40
  params: StyleTarget & {
40
41
  styleSelector: string;
41
42
  };
@@ -38,12 +38,12 @@ var _ = () => {
38
38
  children: [/* @__PURE__ */ l("div", {
39
39
  className: "flex flex-col items-end gap-2",
40
40
  children: [/* @__PURE__ */ l("p", {
41
- className: "self-stretch text-xs leading-relaxed text-zinc-600 dark:text-zinc-400",
41
+ className: "text-ui-fg-muted self-stretch text-xs leading-relaxed",
42
42
  children: [
43
43
  "CSS of your own for the whole space, past what the style inspector writes.",
44
44
  " ",
45
45
  /* @__PURE__ */ c("span", {
46
- className: "font-medium text-zinc-800 dark:text-zinc-200",
46
+ className: "text-ui-fg font-medium",
47
47
  children: "Ctrl + Space"
48
48
  }),
49
49
  " completes a token.",
@@ -65,10 +65,11 @@ var _ = () => {
65
65
  children: [/* @__PURE__ */ c(f.Icon, { icon: "fa-solid fa-wand-magic-sparkles" }), "Format"]
66
66
  })]
67
67
  }), /* @__PURE__ */ c(p, {
68
- className: "min-h-0 grow overflow-hidden rounded-md border border-gray-300 dark:border-zinc-700",
68
+ className: "border-ui-line-strong min-h-0 grow overflow-hidden rounded-md border",
69
69
  value: S,
70
70
  autoComplete: M,
71
71
  theme: _,
72
+ size: "xs",
72
73
  lineWrapping: !0,
73
74
  onChange: A
74
75
  })]
@@ -3,7 +3,7 @@ import { jsx as e } from "react/jsx-runtime";
3
3
  var t = [], n = ({ value: n = t, xFrom: r = 0, xTo: i = 0, yFrom: a = 0, yTo: o = 0 }) => {
4
4
  let s = (e, t, n) => e * (1 - n) + t * n, c = (e) => Math.round(s(r, i, e)), l = (e) => Math.round(s(a, o, e)), u = c(0), d = l(0), f = c(1), p = l(1), m = c(n[0]), h = l(n[1]), g = c(n[2]), _ = l(n[3]);
5
5
  return /* @__PURE__ */ e("path", {
6
- className: "fill-transparent stroke-gray-900 stroke-2",
6
+ className: "stroke-ui-fg fill-transparent stroke-2",
7
7
  d: `M${u},${d} C${m},${h} ${g},${_} ${f},${p}`
8
8
  });
9
9
  };
@@ -14,16 +14,16 @@ var n = ({ xFrom: n = 0, xTo: r = 0, yFrom: i = 0, yTo: a = 0 }) => {
14
14
  }).join(" ");
15
15
  return /* @__PURE__ */ t("g", { children: [
16
16
  /* @__PURE__ */ e("path", {
17
- className: "fill-white",
17
+ className: "fill-ui-panel",
18
18
  d: b
19
19
  }),
20
20
  /* @__PURE__ */ e("path", {
21
- className: "stroke-gray-300",
21
+ className: "stroke-ui-fg-subtle",
22
22
  strokeWidth: "1px",
23
23
  d: x
24
24
  }),
25
25
  /* @__PURE__ */ e("path", {
26
- className: "stroke-gray-300",
26
+ className: "stroke-ui-fg-subtle",
27
27
  strokeWidth: "2px",
28
28
  d: S
29
29
  }),
@@ -95,7 +95,7 @@ var l = [
95
95
  cy: x,
96
96
  r: f,
97
97
  onMouseDown: this.handleMouseDown("bottom"),
98
- className: "cursor-pointer fill-blue-400 stroke-blue-400 stroke-[3px] group-hover:fill-white group-hover:stroke-[6px]"
98
+ className: "group-hover:fill-ui-panel cursor-pointer fill-blue-400 stroke-blue-400 stroke-[3px] group-hover:stroke-[6px]"
99
99
  })]
100
100
  }), /* @__PURE__ */ s("g", {
101
101
  className: "group",
@@ -110,7 +110,7 @@ var l = [
110
110
  cy: O,
111
111
  r: f,
112
112
  onMouseDown: this.handleMouseDown("top"),
113
- className: "cursor-pointer fill-blue-400 stroke-blue-400 stroke-[3px] group-hover:fill-white group-hover:stroke-[6px]"
113
+ className: "group-hover:fill-ui-panel cursor-pointer fill-blue-400 stroke-blue-400 stroke-[3px] group-hover:stroke-[6px]"
114
114
  })]
115
115
  })] })
116
116
  ]
@@ -5,7 +5,7 @@ var n = ({ children: n, title: r = "", className: i = "", onClick: a }) => /* @_
5
5
  type: "button",
6
6
  title: r,
7
7
  onClick: a,
8
- className: t("hover:text-primary-600 dark:hover:text-primary-300 m-0.5 h-7 w-7 cursor-pointer rounded-md p-1 text-zinc-600 hover:bg-gray-100 dark:text-zinc-300 dark:hover:bg-zinc-800", i),
8
+ className: t("hover:text-primary-600 dark:hover:text-primary-300 text-ui-fg-muted hover:bg-ui-hover m-0.5 h-7 w-7 cursor-pointer rounded-md p-1", i),
9
9
  children: /* @__PURE__ */ e("svg", {
10
10
  viewBox: "0 0 30 30",
11
11
  className: "overflow-visible",
@@ -11,7 +11,7 @@ var a = ({ className: a = "", onChange: o }) => {
11
11
  /* @__PURE__ */ r("div", {
12
12
  className: "flex flex-col",
13
13
  children: [/* @__PURE__ */ n("div", {
14
- className: "px-1 pt-2 pb-0.5 text-[11px] font-semibold tracking-wide text-zinc-500 uppercase dark:text-zinc-400",
14
+ className: "text-ui-fg-subtle px-1 pt-2 pb-0.5 text-[11px] font-semibold tracking-wide uppercase",
15
15
  children: "Default"
16
16
  }), /* @__PURE__ */ r("div", {
17
17
  className: "flex flex-wrap",
@@ -62,7 +62,7 @@ var a = ({ className: a = "", onChange: o }) => {
62
62
  /* @__PURE__ */ r("div", {
63
63
  className: "flex flex-col",
64
64
  children: [/* @__PURE__ */ n("div", {
65
- className: "px-1 pt-2 pb-0.5 text-[11px] font-semibold tracking-wide text-zinc-500 uppercase dark:text-zinc-400",
65
+ className: "text-ui-fg-subtle px-1 pt-2 pb-0.5 text-[11px] font-semibold tracking-wide uppercase",
66
66
  children: "Ease In"
67
67
  }), /* @__PURE__ */ r("div", {
68
68
  className: "flex flex-wrap",
@@ -137,7 +137,7 @@ var a = ({ className: a = "", onChange: o }) => {
137
137
  /* @__PURE__ */ r("div", {
138
138
  className: "flex flex-col",
139
139
  children: [/* @__PURE__ */ n("div", {
140
- className: "px-1 pt-2 pb-0.5 text-[11px] font-semibold tracking-wide text-zinc-500 uppercase dark:text-zinc-400",
140
+ className: "text-ui-fg-subtle px-1 pt-2 pb-0.5 text-[11px] font-semibold tracking-wide uppercase",
141
141
  children: "Ease Out"
142
142
  }), /* @__PURE__ */ r("div", {
143
143
  className: "flex flex-wrap",
@@ -212,7 +212,7 @@ var a = ({ className: a = "", onChange: o }) => {
212
212
  /* @__PURE__ */ r("div", {
213
213
  className: "flex flex-col",
214
214
  children: [/* @__PURE__ */ n("div", {
215
- className: "px-1 pt-2 pb-0.5 text-[11px] font-semibold tracking-wide text-zinc-500 uppercase dark:text-zinc-400",
215
+ className: "text-ui-fg-subtle px-1 pt-2 pb-0.5 text-[11px] font-semibold tracking-wide uppercase",
216
216
  children: "Ease In Out"
217
217
  }), /* @__PURE__ */ r("div", {
218
218
  className: "flex flex-wrap",
@@ -6,11 +6,13 @@ export type SelectorProps = {
6
6
  selectors?: Record<string, StyleItem>;
7
7
  selector?: Pick<StyleItem, 'name' | 'type'>;
8
8
  componentType?: string;
9
+ /** What a class's chip reads as instead of its name, by name (see `SelectorItem`'s `label`). */
10
+ labels?: Record<string, string>;
9
11
  disabled?: boolean;
10
12
  onSelectorSelected?: (selector?: SelectorValue) => void;
11
13
  onAdd?: (selector: SelectorValue, isDuplicated: boolean, originalSelector?: SelectorValue) => void;
12
14
  onChange?: (value: string) => void;
13
15
  onRemove?: (selector: SelectorValue) => void;
14
16
  };
15
- declare const _default: import('react').MemoExoticComponent<({ className, value, selectors, selector: selectorProp, componentType, disabled, onChange, onSelectorSelected, onAdd, onRemove }: SelectorProps) => import('react').JSX.Element>;
17
+ declare const _default: import('react').MemoExoticComponent<({ className, value, selectors, selector: selectorProp, componentType, labels, disabled, onChange, onSelectorSelected, onAdd, onRemove }: SelectorProps) => import('react').JSX.Element>;
16
18
  export default _default;
@@ -1,110 +1,124 @@
1
1
  import { inStylesheetOrder as e, overriddenProperties as t, overrideNote as n, selectorFormatter as r } from "./SelectorHelper.mjs";
2
2
  import i from "./SelectorItem/index.mjs";
3
- import a from "./SelectorSuggestions/index.mjs";
4
- import o from "../StyleManager/index.mjs";
5
- import { memo as s, useCallback as c, useMemo as l, useRef as u, useState as d } from "react";
6
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
7
- import { get as m, omit as h, pick as g } from "@plitzi/plitzi-ui/helpers";
8
- import _ from "@plitzi/plitzi-ui/Button";
9
- import v from "clsx";
10
- import y, { useFloating as b } from "@plitzi/plitzi-ui/ContainerFloating";
11
- import { usePopup as x } from "@plitzi/plitzi-ui/Popup";
3
+ import { suggestionsFor as a } from "./SelectorSuggestions/helpers.mjs";
4
+ import ee from "./SelectorSuggestions/index.mjs";
5
+ import te from "../StyleManager/index.mjs";
6
+ import { memo as o, useCallback as s, useMemo as c, useRef as l, useState as u } from "react";
7
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
8
+ import { get as p, omit as ne, pick as m } from "@plitzi/plitzi-ui/helpers";
9
+ import h from "@plitzi/plitzi-ui/Button";
10
+ import g from "clsx";
11
+ import _, { useFloating as v } from "@plitzi/plitzi-ui/ContainerFloating";
12
+ import { usePopup as y } from "@plitzi/plitzi-ui/Popup";
12
13
  // src/builder/components/Selector/Selector.tsx
13
- var S = "Classes apply left to right, in the order the stylesheet lists them: where two set the same property, the one further right wins.", C = s(({ className: s = "", value: C = "", selectors: w, selector: T, componentType: E, disabled: D = !1, onChange: O, onSelectorSelected: k, onAdd: A, onRemove: j }) => {
14
- let M = u(null), [N, P] = d(""), [F, I, , L, R] = b({ disabled: D }), { existsPopup: z, addPopup: B } = x("floating"), V = l(() => Object.values(w ?? {}).find((e) => e.type === "element" && e.componentType === E), [E, w]), H = l(() => Object.values(g(w ?? {}, C.split(" "))).map((e) => g(e, ["name", "type"])), [w, C]), U = l(() => e(H.map((e, t) => ({
14
+ var b = "Classes apply left to right, in the order the stylesheet lists them: where two set the same property, the one further right wins.", x = o(({ className: o = "", value: x = "", selectors: S, selector: C, componentType: w, labels: T, disabled: E = !1, onChange: D, onSelectorSelected: O, onAdd: k, onRemove: A }) => {
15
+ let j = l(null), [M, N] = u(""), [P, F] = u(-1), [I, L, , R, z] = v({ disabled: E }), { existsPopup: B, addPopup: V } = y("floating"), H = c(() => Object.values(S ?? {}).find((e) => e.type === "element" && e.componentType === w), [w, S]), U = c(() => Object.values(m(S ?? {}, x.split(" "))).map((e) => m(e, ["name", "type"])), [S, x]), W = c(() => e(U.map((e, t) => ({
15
16
  ...e,
16
17
  position: t
17
- })), Object.keys(w ?? {})), [H, w]), W = l(() => t(U.map(({ name: e }) => e), w ?? {}), [U, w]), G = l(() => n(T?.name.replace(/:.*/, ""), W), [T, W]), K = l(() => Object.values(h(w ?? {}, C.split(" "))), [w, C]), q = c((e) => {
18
- I(e.target.value.length > 0), P(e.target.value);
19
- }, [I]), J = c(() => {
20
- M.current?.focus(), I(N.length > 0);
18
+ })), Object.keys(S ?? {})), [U, S]), G = c(() => t(W.map(({ name: e }) => e), S ?? {}), [W, S]), K = c(() => n(C?.name.replace(/:.*/, ""), G), [C, G]), q = c(() => Object.values(ne(S ?? {}, x.split(" "))), [S, x]), J = c(() => a(M, q), [M, q]), Y = J.list.length + +!!J.creates, X = s((e) => {
19
+ L(!0), N(e.target.value), F(-1);
20
+ }, [L]), re = s(() => {
21
+ j.current?.focus(), L(!0);
22
+ }, [j, L]), Z = s((e) => O?.(e), [O]), ie = s((e) => (t, n = !0) => {
23
+ let r = [...U.filter((t, n) => n !== e), t].filter((e) => !!e.name).reduce((e, t) => `${e} ${t.name}`, "").trim();
24
+ k?.(t, !1), D?.(r), n && O?.(t);
21
25
  }, [
22
- M,
23
- N,
24
- I
25
- ]), Y = c((e) => k?.(e), [k]), X = c((e) => (t, n = !0) => {
26
- let r = [...H.filter((t, n) => n !== e), t].filter((e) => !!e.name).reduce((e, t) => `${e} ${t.name}`, "").trim();
27
- A?.(t, !1), O?.(r), n && k?.(t);
28
- }, [
29
- H,
30
- A,
31
- O,
32
- k
33
- ]), Z = c((e) => (t, n) => {
26
+ U,
27
+ k,
28
+ D,
29
+ O
30
+ ]), ae = s((e) => (t, n) => {
34
31
  switch (t) {
35
32
  case "remove":
36
33
  case "delete": {
37
- let n = H.filter((t, n) => n !== e), r = n.reduce((e, t) => `${e} ${t.name}`, "").trim();
38
- T && H[e].name === T.name && k?.(m(n, "0")), O?.(r), t === "delete" && j?.(H[e]);
34
+ let n = U.filter((t, n) => n !== e), r = n.reduce((e, t) => `${e} ${t.name}`, "").trim();
35
+ C && U[e].name === C.name && O?.(p(n, "0")), D?.(r), t === "delete" && A?.(U[e]);
39
36
  break;
40
37
  }
41
38
  case "duplicate": {
42
39
  if (!n) break;
43
- let t = [...H, n].filter((e) => !!e.name).reduce((e, t) => `${e} ${t.name}`, "").trim();
44
- A?.(n, !0, m(H, `${e}`)), O?.(t);
40
+ let t = [...U, n].filter((e) => !!e.name).reduce((e, t) => `${e} ${t.name}`, "").trim();
41
+ k?.(n, !0, p(U, `${e}`)), D?.(t);
45
42
  break;
46
43
  }
47
44
  }
48
45
  }, [
49
- H,
50
- T,
46
+ U,
47
+ C,
48
+ D,
49
+ O,
50
+ k,
51
+ A
52
+ ]), Q = s((e) => {
53
+ setTimeout(() => N(""), 0), L(!1);
54
+ let t = [...U, e].reduce((e, t) => `${e} ${t.name}`, "").trim();
55
+ D?.(t), O?.(e);
56
+ }, [
57
+ U,
58
+ D,
51
59
  O,
60
+ L
61
+ ]), $ = s((e) => {
62
+ setTimeout(() => N(""), 0), L(!1);
63
+ let t = [...U, e].reduce((e, t) => `${e} ${t.name}`, "").trim();
64
+ D?.(t), k?.(e, !1), O?.(e);
65
+ }, [
66
+ U,
67
+ D,
52
68
  k,
53
- A,
54
- j
55
- ]), Q = c((e) => {
69
+ O,
70
+ L
71
+ ]), oe = s((e) => {
56
72
  switch (e.key) {
57
73
  case "Enter": {
74
+ if (P >= 0) {
75
+ if (e.preventDefault(), J.creates && P === 0) $({
76
+ name: J.creates,
77
+ type: "class"
78
+ });
79
+ else {
80
+ let e = J.list.at(P - +!!J.creates);
81
+ e && Q(e);
82
+ }
83
+ F(-1);
84
+ break;
85
+ }
58
86
  let { value: t } = e.currentTarget;
59
- if (t !== "" && !H.find((e) => e.name === t)) {
60
- P("");
87
+ if (t !== "" && !U.find((e) => e.name === t)) {
88
+ N("");
61
89
  let n = {
62
90
  name: r(t),
63
91
  type: "class"
64
- }, i = [...H, n].filter((e) => !!e.name).reduce((e, t) => `${e} ${t.name}`, "").trim();
65
- A?.(n, !1), O?.(i), I(!1), e.currentTarget.blur(), k?.(n);
92
+ }, i = [...U, n].filter((e) => !!e.name).reduce((e, t) => `${e} ${t.name}`, "").trim();
93
+ k?.(n, !1), D?.(i), L(!1), e.currentTarget.blur(), O?.(n);
66
94
  }
67
95
  setTimeout(() => {
68
- M.current?.focus();
96
+ j.current?.focus();
69
97
  }, 0);
70
98
  break;
71
99
  }
72
100
  case "ArrowUp":
73
- I(!1);
101
+ e.preventDefault(), F((e) => Math.max(e - 1, -1));
74
102
  break;
75
103
  case "ArrowDown":
76
- I(!0);
104
+ e.preventDefault(), L(!0), F((e) => Math.min(e + 1, Y - 1));
77
105
  break;
78
- case "Escape": e.stopPropagation(), P(""), e.currentTarget.blur();
106
+ case "Escape": e.stopPropagation(), N(""), F(-1), L(!1), e.currentTarget.blur();
79
107
  }
80
108
  }, [
81
- H,
82
- A,
83
- O,
84
- k,
85
- I
86
- ]), $ = c((e) => {
87
- setTimeout(() => P(""), 0), I(!1);
88
- let t = [...H, e].reduce((e, t) => `${e} ${t.name}`, "").trim();
89
- O?.(t), k?.(e);
90
- }, [
91
- H,
92
- O,
109
+ U,
93
110
  k,
94
- I
95
- ]), ee = c((e) => {
96
- setTimeout(() => P(""), 0), I(!1);
97
- let t = [...H, e].reduce((e, t) => `${e} ${t.name}`, "").trim();
98
- O?.(t), A?.(e, !1), k?.(e);
99
- }, [
100
- H,
111
+ D,
101
112
  O,
102
- A,
103
- k,
104
- I
105
- ]), te = c((e) => {
106
- e.preventDefault(), e.stopPropagation(), z("styleManager") || B("styleManager", /* @__PURE__ */ f(o, {}), {
107
- icon: /* @__PURE__ */ f("i", { className: "fas fa-swatchbook text-base" }),
113
+ L,
114
+ P,
115
+ J,
116
+ Y,
117
+ $,
118
+ Q
119
+ ]), se = s((e) => {
120
+ e.preventDefault(), e.stopPropagation(), B("styleManager") || V("styleManager", /* @__PURE__ */ d(te, {}), {
121
+ icon: /* @__PURE__ */ d("i", { className: "fas fa-swatchbook text-base" }),
108
122
  title: "Style Manager",
109
123
  resizeHandles: ["se"],
110
124
  allowLeftSide: !0,
@@ -113,79 +127,86 @@ var S = "Classes apply left to right, in the order the stylesheet lists them: wh
113
127
  width: 720,
114
128
  height: 640
115
129
  });
116
- }, [B, z]), ne = l(() => ({ width: R?.width }), [R]);
117
- return /* @__PURE__ */ p("div", {
130
+ }, [V, B]), ce = c(() => ({ width: z?.width }), [z]);
131
+ return /* @__PURE__ */ f("div", {
118
132
  className: "flex w-full min-w-0 flex-col gap-1",
119
- children: [/* @__PURE__ */ p(y, {
120
- ref: L,
133
+ children: [/* @__PURE__ */ f(_, {
134
+ ref: R,
121
135
  className: "w-full",
122
- open: F,
123
- children: [/* @__PURE__ */ f(y.Trigger, {
136
+ open: I,
137
+ children: [/* @__PURE__ */ d(_.Trigger, {
124
138
  className: "w-full",
125
- children: /* @__PURE__ */ p("div", {
126
- className: v("bg-grayviolet-200 relative flex flex-wrap gap-1 rounded-sm p-1 dark:bg-zinc-800", s, {
127
- "pointer-events-none cursor-not-allowed bg-gray-100 dark:bg-zinc-900": D,
128
- "cursor-pointer": !D
139
+ children: /* @__PURE__ */ f("div", {
140
+ className: g("bg-ui-panel relative flex min-h-8 items-center gap-1 rounded-md border py-1 pr-1 pl-1", o, {
141
+ "border-ui-line pointer-events-none cursor-not-allowed opacity-60": E,
142
+ "focus-within:border-primary-500 focus-within:ring-primary-500/20 border-ui-line-strong cursor-text focus-within:ring-2": !E
129
143
  }),
130
- onClick: J,
131
- onKeyDown: Q,
132
- children: [
133
- /* @__PURE__ */ f(_, {
134
- intent: "secondary",
135
- size: "custom",
136
- onClick: te,
137
- className: "h-7 w-7 rounded-sm bg-white dark:bg-zinc-700 dark:text-zinc-200",
138
- title: "Style Manager",
139
- children: /* @__PURE__ */ f(_.Icon, { icon: "fas fa-swatchbook" })
140
- }),
141
- V && /* @__PURE__ */ f(i, {
142
- selector: V.name,
143
- type: V.type,
144
- editable: !1,
145
- active: V.name === T?.name.replace(/:.*/, ""),
146
- onClick: Y
147
- }),
148
- U.map(({ position: e, ...t }) => /* @__PURE__ */ f(i, {
149
- selector: t.name,
150
- type: t.type,
151
- editable: t.type !== "element",
152
- active: t.name === T?.name.replace(/:.*/, ""),
153
- onAction: Z(e),
154
- onClick: Y,
155
- onChange: X(e)
156
- }, `${e}_${t.name}`)),
157
- /* @__PURE__ */ f("input", {
158
- ref: M,
159
- className: "flex min-h-0 w-0 border-none bg-transparent px-1 py-0 text-xs text-inherit outline-hidden focus:min-w-[50px] focus:grow focus:ring-transparent",
160
- autoComplete: "off",
161
- autoCorrect: "off",
162
- autoCapitalize: "off",
163
- spellCheck: "false",
164
- value: N,
165
- onChange: q
166
- })
167
- ]
144
+ onClick: re,
145
+ onKeyDown: oe,
146
+ children: [/* @__PURE__ */ f("div", {
147
+ className: "flex min-w-0 grow flex-wrap items-center gap-1",
148
+ children: [
149
+ H && /* @__PURE__ */ d(i, {
150
+ selector: H.name,
151
+ type: H.type,
152
+ editable: !1,
153
+ active: H.name === C?.name.replace(/:.*/, ""),
154
+ onClick: Z
155
+ }),
156
+ W.map(({ position: e, ...t }) => /* @__PURE__ */ d(i, {
157
+ selector: t.name,
158
+ label: T?.[t.name],
159
+ type: t.type,
160
+ editable: t.type !== "element",
161
+ active: t.name === C?.name.replace(/:.*/, ""),
162
+ onAction: ae(e),
163
+ onClick: Z,
164
+ onChange: ie(e)
165
+ }, `${e}_${t.name}`)),
166
+ /* @__PURE__ */ d("input", {
167
+ ref: j,
168
+ className: "placeholder:text-ui-fg-subtle min-w-20 grow basis-0 border-none bg-transparent px-1 py-0.5 text-xs text-inherit outline-hidden focus:ring-transparent",
169
+ placeholder: W.length > 0 ? "Add class…" : "Add a class to style it…",
170
+ "aria-label": "Add a class",
171
+ "aria-expanded": I,
172
+ "aria-autocomplete": "list",
173
+ autoComplete: "off",
174
+ autoCorrect: "off",
175
+ autoCapitalize: "off",
176
+ spellCheck: "false",
177
+ value: M,
178
+ onChange: X
179
+ })
180
+ ]
181
+ }), /* @__PURE__ */ d(h, {
182
+ intent: "secondary",
183
+ size: "custom",
184
+ onClick: se,
185
+ className: "text-ui-fg-subtle hover:bg-ui-hover hover:text-ui-fg h-6 w-6 shrink-0 self-start rounded bg-transparent dark:bg-transparent",
186
+ title: "Open the Style Manager: every class and element default of the space",
187
+ children: /* @__PURE__ */ d(h.Icon, { icon: "fas fa-swatchbook" })
188
+ })]
168
189
  })
169
- }), /* @__PURE__ */ f(y.Content, {
170
- style: ne,
171
- children: /* @__PURE__ */ f(a, {
172
- selector: N,
173
- selectors: K,
174
- onSelect: $,
175
- onCreate: ee
190
+ }), /* @__PURE__ */ d(_.Content, {
191
+ style: ce,
192
+ children: /* @__PURE__ */ d(ee, {
193
+ suggestions: J,
194
+ highlighted: P,
195
+ onSelect: Q,
196
+ onCreate: $
176
197
  })
177
198
  })]
178
- }), U.length > 1 && /* @__PURE__ */ p("div", {
179
- className: "flex min-w-0 items-center gap-1.5 px-1 text-[11px] text-gray-500 dark:text-zinc-400",
180
- title: G ?? S,
181
- children: [/* @__PURE__ */ f("i", {
199
+ }), W.length > 1 && /* @__PURE__ */ f("div", {
200
+ className: "text-ui-fg-subtle flex min-w-0 items-center gap-1.5 px-1 text-[11px]",
201
+ title: K ?? b,
202
+ children: [/* @__PURE__ */ d("i", {
182
203
  className: "fas fa-circle-info shrink-0",
183
- title: S
184
- }), /* @__PURE__ */ f("span", {
204
+ title: b
205
+ }), /* @__PURE__ */ d("span", {
185
206
  className: "truncate",
186
- children: G ?? "Left to right: the class further right wins where they overlap"
207
+ children: K ?? "Left to right: the class further right wins where they overlap"
187
208
  })]
188
209
  })]
189
210
  });
190
211
  });
191
- export { C as default };
212
+ export { x as default };
@@ -26,11 +26,12 @@ var l = ({ selector: l = "", type: u = "class", onAction: d }) => {
26
26
  ]);
27
27
  return /* @__PURE__ */ r(a, { children: [/* @__PURE__ */ n(a.Trigger, { children: /* @__PURE__ */ n(o, {
28
28
  icon: "fa-solid fa-ellipsis-vertical",
29
- className: "h-4 w-4 !min-w-4"
29
+ className: "h-4 w-3 !min-w-3 rounded-sm opacity-70 hover:opacity-100",
30
+ title: "Class actions: duplicate, remove, delete"
30
31
  }) }), /* @__PURE__ */ n(a.Content, {
31
- className: "text-xs text-zinc-700 dark:text-zinc-300",
32
+ className: "text-ui-fg text-xs",
32
33
  children: /* @__PURE__ */ n("div", {
33
- className: "min-w-44 rounded-md border border-gray-200 bg-white p-1 shadow-lg dark:border-zinc-700 dark:bg-zinc-800",
34
+ className: "border-ui-line bg-ui-overlay min-w-44 rounded-md border p-1 shadow-lg",
34
35
  children: /* @__PURE__ */ r("ul", {
35
36
  className: "m-0 flex list-none flex-col p-0",
36
37
  children: [