@plitzi/sdk-style 0.39.2 → 0.39.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/StyleMap/StyleMap.d.ts +9 -4
- package/dist/StyleMap/StyleMap.mjs +4 -4
- package/dist/StyleMap/helpers/utils.mjs +1 -1
- package/dist/StyleReducer.d.ts +4 -3
- package/dist/builder/components/Selector/Selector.d.ts +3 -1
- package/dist/builder/components/Selector/Selector.mjs +82 -81
- package/dist/builder/components/Selector/SelectorItem/SelectorItem.d.ts +6 -1
- package/dist/builder/components/Selector/SelectorItem/SelectorItem.mjs +37 -35
- package/dist/builder/components/StyleInspector/StyleInspector.mjs +2 -1
- package/dist/builder/components/StyleInspector/StyleInspectorProvider.mjs +1 -1
- package/dist/builder/components/StyleManager/ManagerSelector.mjs +85 -87
- package/dist/helpers/processSelectorVariables.mjs +12 -13
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @plitzi/sdk-style
|
|
2
2
|
|
|
3
|
+
## 0.39.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 35415a1: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [35415a1]
|
|
10
|
+
- @plitzi/sdk-event-bridge@0.39.4
|
|
11
|
+
- @plitzi/sdk-shared@0.39.4
|
|
12
|
+
- @plitzi/sdk-variables@0.39.4
|
|
13
|
+
|
|
14
|
+
## 0.39.3
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- @plitzi/sdk-event-bridge@0.39.3
|
|
19
|
+
- @plitzi/sdk-shared@0.39.3
|
|
20
|
+
- @plitzi/sdk-variables@0.39.3
|
|
21
|
+
|
|
3
22
|
## 0.39.2
|
|
4
23
|
|
|
5
24
|
### 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:
|
|
14
|
-
static addSelector(style: Pick<Style, 'platform' | 'variables'>, displayMode: DisplayMode, selector: string, type: TagType, path: StyleCategory | undefined, value:
|
|
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:
|
|
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:
|
|
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] ? (
|
|
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,
|
|
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 : (
|
|
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 : (
|
|
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) => {
|
package/dist/StyleReducer.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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?:
|
|
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?:
|
|
39
|
+
value?: SelectorValue;
|
|
39
40
|
params: StyleTarget & {
|
|
40
41
|
styleSelector: string;
|
|
41
42
|
};
|
|
@@ -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;
|
|
@@ -10,100 +10,100 @@ import v from "clsx";
|
|
|
10
10
|
import y, { useFloating as b } from "@plitzi/plitzi-ui/ContainerFloating";
|
|
11
11
|
import { usePopup as x } from "@plitzi/plitzi-ui/Popup";
|
|
12
12
|
// 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,
|
|
14
|
-
let
|
|
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, labels: D, disabled: O = !1, onChange: k, onSelectorSelected: A, onAdd: j, onRemove: M }) => {
|
|
14
|
+
let N = u(null), [P, F] = d(""), [I, L, , R, z] = b({ disabled: O }), { existsPopup: B, addPopup: V } = x("floating"), H = l(() => Object.values(w ?? {}).find((e) => e.type === "element" && e.componentType === E), [E, w]), U = l(() => Object.values(g(w ?? {}, C.split(" "))).map((e) => g(e, ["name", "type"])), [w, C]), W = l(() => e(U.map((e, t) => ({
|
|
15
15
|
...e,
|
|
16
16
|
position: t
|
|
17
|
-
})), Object.keys(w ?? {})), [
|
|
18
|
-
|
|
19
|
-
}, [
|
|
20
|
-
|
|
17
|
+
})), Object.keys(w ?? {})), [U, w]), G = l(() => t(W.map(({ name: e }) => e), w ?? {}), [W, w]), K = l(() => n(T?.name.replace(/:.*/, ""), G), [T, G]), q = l(() => Object.values(h(w ?? {}, C.split(" "))), [w, C]), J = c((e) => {
|
|
18
|
+
L(e.target.value.length > 0), F(e.target.value);
|
|
19
|
+
}, [L]), Y = c(() => {
|
|
20
|
+
N.current?.focus(), L(P.length > 0);
|
|
21
21
|
}, [
|
|
22
|
-
M,
|
|
23
22
|
N,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
P,
|
|
24
|
+
L
|
|
25
|
+
]), X = c((e) => A?.(e), [A]), Z = c((e) => (t, n = !0) => {
|
|
26
|
+
let r = [...U.filter((t, n) => n !== e), t].filter((e) => !!e.name).reduce((e, t) => `${e} ${t.name}`, "").trim();
|
|
27
|
+
j?.(t, !1), k?.(r), n && A?.(t);
|
|
28
28
|
}, [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
]),
|
|
29
|
+
U,
|
|
30
|
+
j,
|
|
31
|
+
k,
|
|
32
|
+
A
|
|
33
|
+
]), Q = c((e) => (t, n) => {
|
|
34
34
|
switch (t) {
|
|
35
35
|
case "remove":
|
|
36
36
|
case "delete": {
|
|
37
|
-
let n =
|
|
38
|
-
T &&
|
|
37
|
+
let n = U.filter((t, n) => n !== e), r = n.reduce((e, t) => `${e} ${t.name}`, "").trim();
|
|
38
|
+
T && U[e].name === T.name && A?.(m(n, "0")), k?.(r), t === "delete" && M?.(U[e]);
|
|
39
39
|
break;
|
|
40
40
|
}
|
|
41
41
|
case "duplicate": {
|
|
42
42
|
if (!n) break;
|
|
43
|
-
let t = [...
|
|
44
|
-
|
|
43
|
+
let t = [...U, n].filter((e) => !!e.name).reduce((e, t) => `${e} ${t.name}`, "").trim();
|
|
44
|
+
j?.(n, !0, m(U, `${e}`)), k?.(t);
|
|
45
45
|
break;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}, [
|
|
49
|
-
|
|
49
|
+
U,
|
|
50
50
|
T,
|
|
51
|
-
O,
|
|
52
51
|
k,
|
|
53
52
|
A,
|
|
54
|
-
j
|
|
55
|
-
|
|
53
|
+
j,
|
|
54
|
+
M
|
|
55
|
+
]), $ = c((e) => {
|
|
56
56
|
switch (e.key) {
|
|
57
57
|
case "Enter": {
|
|
58
58
|
let { value: t } = e.currentTarget;
|
|
59
|
-
if (t !== "" && !
|
|
60
|
-
|
|
59
|
+
if (t !== "" && !U.find((e) => e.name === t)) {
|
|
60
|
+
F("");
|
|
61
61
|
let n = {
|
|
62
62
|
name: r(t),
|
|
63
63
|
type: "class"
|
|
64
|
-
}, i = [...
|
|
65
|
-
|
|
64
|
+
}, i = [...U, n].filter((e) => !!e.name).reduce((e, t) => `${e} ${t.name}`, "").trim();
|
|
65
|
+
j?.(n, !1), k?.(i), L(!1), e.currentTarget.blur(), A?.(n);
|
|
66
66
|
}
|
|
67
67
|
setTimeout(() => {
|
|
68
|
-
|
|
68
|
+
N.current?.focus();
|
|
69
69
|
}, 0);
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
72
|
case "ArrowUp":
|
|
73
|
-
|
|
73
|
+
L(!1);
|
|
74
74
|
break;
|
|
75
75
|
case "ArrowDown":
|
|
76
|
-
|
|
76
|
+
L(!0);
|
|
77
77
|
break;
|
|
78
|
-
case "Escape": e.stopPropagation(),
|
|
78
|
+
case "Escape": e.stopPropagation(), F(""), e.currentTarget.blur();
|
|
79
79
|
}
|
|
80
80
|
}, [
|
|
81
|
-
|
|
82
|
-
|
|
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,
|
|
81
|
+
U,
|
|
82
|
+
j,
|
|
93
83
|
k,
|
|
94
|
-
|
|
84
|
+
A,
|
|
85
|
+
L
|
|
95
86
|
]), ee = c((e) => {
|
|
96
|
-
setTimeout(() =>
|
|
97
|
-
let t = [...
|
|
98
|
-
|
|
87
|
+
setTimeout(() => F(""), 0), L(!1);
|
|
88
|
+
let t = [...U, e].reduce((e, t) => `${e} ${t.name}`, "").trim();
|
|
89
|
+
k?.(t), A?.(e);
|
|
99
90
|
}, [
|
|
100
|
-
|
|
101
|
-
O,
|
|
102
|
-
A,
|
|
91
|
+
U,
|
|
103
92
|
k,
|
|
104
|
-
|
|
93
|
+
A,
|
|
94
|
+
L
|
|
105
95
|
]), te = c((e) => {
|
|
106
|
-
|
|
96
|
+
setTimeout(() => F(""), 0), L(!1);
|
|
97
|
+
let t = [...U, e].reduce((e, t) => `${e} ${t.name}`, "").trim();
|
|
98
|
+
k?.(t), j?.(e, !1), A?.(e);
|
|
99
|
+
}, [
|
|
100
|
+
U,
|
|
101
|
+
k,
|
|
102
|
+
j,
|
|
103
|
+
A,
|
|
104
|
+
L
|
|
105
|
+
]), ne = c((e) => {
|
|
106
|
+
e.preventDefault(), e.stopPropagation(), B("styleManager") || V("styleManager", /* @__PURE__ */ f(o, {}), {
|
|
107
107
|
icon: /* @__PURE__ */ f("i", { className: "fas fa-swatchbook text-base" }),
|
|
108
108
|
title: "Style Manager",
|
|
109
109
|
resizeHandles: ["se"],
|
|
@@ -113,77 +113,78 @@ var S = "Classes apply left to right, in the order the stylesheet lists them: wh
|
|
|
113
113
|
width: 720,
|
|
114
114
|
height: 640
|
|
115
115
|
});
|
|
116
|
-
}, [
|
|
116
|
+
}, [V, B]), re = l(() => ({ width: z?.width }), [z]);
|
|
117
117
|
return /* @__PURE__ */ p("div", {
|
|
118
118
|
className: "flex w-full min-w-0 flex-col gap-1",
|
|
119
119
|
children: [/* @__PURE__ */ p(y, {
|
|
120
|
-
ref:
|
|
120
|
+
ref: R,
|
|
121
121
|
className: "w-full",
|
|
122
|
-
open:
|
|
122
|
+
open: I,
|
|
123
123
|
children: [/* @__PURE__ */ f(y.Trigger, {
|
|
124
124
|
className: "w-full",
|
|
125
125
|
children: /* @__PURE__ */ p("div", {
|
|
126
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":
|
|
128
|
-
"cursor-pointer": !
|
|
127
|
+
"pointer-events-none cursor-not-allowed bg-gray-100 dark:bg-zinc-900": O,
|
|
128
|
+
"cursor-pointer": !O
|
|
129
129
|
}),
|
|
130
|
-
onClick:
|
|
131
|
-
onKeyDown:
|
|
130
|
+
onClick: Y,
|
|
131
|
+
onKeyDown: $,
|
|
132
132
|
children: [
|
|
133
133
|
/* @__PURE__ */ f(_, {
|
|
134
134
|
intent: "secondary",
|
|
135
135
|
size: "custom",
|
|
136
|
-
onClick:
|
|
136
|
+
onClick: ne,
|
|
137
137
|
className: "h-7 w-7 rounded-sm bg-white dark:bg-zinc-700 dark:text-zinc-200",
|
|
138
138
|
title: "Style Manager",
|
|
139
139
|
children: /* @__PURE__ */ f(_.Icon, { icon: "fas fa-swatchbook" })
|
|
140
140
|
}),
|
|
141
|
-
|
|
142
|
-
selector:
|
|
143
|
-
type:
|
|
141
|
+
H && /* @__PURE__ */ f(i, {
|
|
142
|
+
selector: H.name,
|
|
143
|
+
type: H.type,
|
|
144
144
|
editable: !1,
|
|
145
|
-
active:
|
|
146
|
-
onClick:
|
|
145
|
+
active: H.name === T?.name.replace(/:.*/, ""),
|
|
146
|
+
onClick: X
|
|
147
147
|
}),
|
|
148
|
-
|
|
148
|
+
W.map(({ position: e, ...t }) => /* @__PURE__ */ f(i, {
|
|
149
149
|
selector: t.name,
|
|
150
|
+
label: D?.[t.name],
|
|
150
151
|
type: t.type,
|
|
151
152
|
editable: t.type !== "element",
|
|
152
153
|
active: t.name === T?.name.replace(/:.*/, ""),
|
|
153
|
-
onAction:
|
|
154
|
-
onClick:
|
|
155
|
-
onChange:
|
|
154
|
+
onAction: Q(e),
|
|
155
|
+
onClick: X,
|
|
156
|
+
onChange: Z(e)
|
|
156
157
|
}, `${e}_${t.name}`)),
|
|
157
158
|
/* @__PURE__ */ f("input", {
|
|
158
|
-
ref:
|
|
159
|
+
ref: N,
|
|
159
160
|
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
161
|
autoComplete: "off",
|
|
161
162
|
autoCorrect: "off",
|
|
162
163
|
autoCapitalize: "off",
|
|
163
164
|
spellCheck: "false",
|
|
164
|
-
value:
|
|
165
|
-
onChange:
|
|
165
|
+
value: P,
|
|
166
|
+
onChange: J
|
|
166
167
|
})
|
|
167
168
|
]
|
|
168
169
|
})
|
|
169
170
|
}), /* @__PURE__ */ f(y.Content, {
|
|
170
|
-
style:
|
|
171
|
+
style: re,
|
|
171
172
|
children: /* @__PURE__ */ f(a, {
|
|
172
|
-
selector:
|
|
173
|
-
selectors:
|
|
174
|
-
onSelect:
|
|
175
|
-
onCreate:
|
|
173
|
+
selector: P,
|
|
174
|
+
selectors: q,
|
|
175
|
+
onSelect: ee,
|
|
176
|
+
onCreate: te
|
|
176
177
|
})
|
|
177
178
|
})]
|
|
178
|
-
}),
|
|
179
|
+
}), W.length > 1 && /* @__PURE__ */ p("div", {
|
|
179
180
|
className: "flex min-w-0 items-center gap-1.5 px-1 text-[11px] text-gray-500 dark:text-zinc-400",
|
|
180
|
-
title:
|
|
181
|
+
title: K ?? S,
|
|
181
182
|
children: [/* @__PURE__ */ f("i", {
|
|
182
183
|
className: "fas fa-circle-info shrink-0",
|
|
183
184
|
title: S
|
|
184
185
|
}), /* @__PURE__ */ f("span", {
|
|
185
186
|
className: "truncate",
|
|
186
|
-
children:
|
|
187
|
+
children: K ?? "Left to right: the class further right wins where they overlap"
|
|
187
188
|
})]
|
|
188
189
|
})]
|
|
189
190
|
});
|
|
@@ -3,6 +3,11 @@ import { TagType } from '@plitzi/sdk-shared';
|
|
|
3
3
|
export type SelectorItemProps = {
|
|
4
4
|
className?: string;
|
|
5
5
|
selector?: string;
|
|
6
|
+
/**
|
|
7
|
+
* What the chip reads as instead of the class's name, when the name says nothing to a person — a class the builder
|
|
8
|
+
* named after its element (`container-2f16`) reads as the element's label. Double-clicking still edits the name.
|
|
9
|
+
*/
|
|
10
|
+
label?: string;
|
|
6
11
|
type?: TagType;
|
|
7
12
|
editable?: boolean;
|
|
8
13
|
active?: boolean;
|
|
@@ -11,5 +16,5 @@ export type SelectorItemProps = {
|
|
|
11
16
|
onChange?: (selector: SelectorValue) => void;
|
|
12
17
|
onAction?: (action: 'duplicate' | 'remove' | 'delete', data?: SelectorValue) => void;
|
|
13
18
|
};
|
|
14
|
-
declare const SelectorItem: ({ className, selector, type, editable, active, readOnly, onClick, onChange, onAction }: SelectorItemProps) => import('react').JSX.Element;
|
|
19
|
+
declare const SelectorItem: ({ className, selector, label, type, editable, active, readOnly, onClick, onChange, onAction }: SelectorItemProps) => import('react').JSX.Element;
|
|
15
20
|
export default SelectorItem;
|
|
@@ -1,49 +1,51 @@
|
|
|
1
1
|
import { selectorFormatter as e } from "../SelectorHelper.mjs";
|
|
2
2
|
import t from "./ItemOptions.mjs";
|
|
3
|
-
import { useCallback as n } from "react";
|
|
4
|
-
import { jsx as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import { useCallback as n, useState as r } from "react";
|
|
4
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
|
+
import o from "clsx";
|
|
6
|
+
import s from "@plitzi/plitzi-ui/ContentEditable";
|
|
7
7
|
// src/builder/components/Selector/SelectorItem/SelectorItem.tsx
|
|
8
|
-
var
|
|
9
|
-
let
|
|
10
|
-
e.preventDefault(),
|
|
11
|
-
name:
|
|
12
|
-
type:
|
|
8
|
+
var c = ({ className: c = "", selector: l = "", label: u, type: d = "class", editable: f = !0, active: p = !1, readOnly: m = !1, onClick: h, onChange: g, onAction: _ }) => {
|
|
9
|
+
let v = n((e) => {
|
|
10
|
+
e.preventDefault(), m || e.stopPropagation(), h?.({
|
|
11
|
+
name: l,
|
|
12
|
+
type: d
|
|
13
13
|
});
|
|
14
14
|
}, [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
]),
|
|
20
|
-
|
|
15
|
+
h,
|
|
16
|
+
m,
|
|
17
|
+
l,
|
|
18
|
+
d
|
|
19
|
+
]), [y, b] = r(!1), x = y || !u ? l : u, S = n(() => b(!0), []), C = n(() => b(!1), []), w = n((t) => {
|
|
20
|
+
g?.({
|
|
21
21
|
name: e(t),
|
|
22
|
-
type:
|
|
22
|
+
type: d
|
|
23
23
|
});
|
|
24
|
-
}, [
|
|
25
|
-
return /* @__PURE__ */
|
|
26
|
-
className:
|
|
27
|
-
"bg-primary-600 text-white":
|
|
28
|
-
"bg-primary-500/20 text-primary-800 dark:text-primary-200":
|
|
29
|
-
"bg-gray-200 text-zinc-700 hover:bg-gray-300 dark:bg-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-600": !
|
|
30
|
-
"max-w-full min-w-0": !
|
|
24
|
+
}, [d, g]);
|
|
25
|
+
return /* @__PURE__ */ a("div", {
|
|
26
|
+
className: o("relative flex cursor-pointer items-center gap-1 rounded-sm px-2 py-1 select-none", c, {
|
|
27
|
+
"bg-primary-600 text-white": d !== "element" && p,
|
|
28
|
+
"bg-primary-500/20 text-primary-800 dark:text-primary-200": d === "element" && p,
|
|
29
|
+
"bg-gray-200 text-zinc-700 hover:bg-gray-300 dark:bg-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-600": !p,
|
|
30
|
+
"max-w-full min-w-0": !f
|
|
31
31
|
}),
|
|
32
|
-
onClick:
|
|
33
|
-
title: `${
|
|
34
|
-
children: [/* @__PURE__ */
|
|
32
|
+
onClick: v,
|
|
33
|
+
title: `${d}: ${l}`,
|
|
34
|
+
children: [/* @__PURE__ */ a("div", {
|
|
35
35
|
className: "flex min-w-0 grow basis-0 text-xs",
|
|
36
|
-
children: [
|
|
36
|
+
children: [f && /* @__PURE__ */ i(s, {
|
|
37
37
|
className: "inline text-nowrap focus-visible:m-[1px] focus-visible:px-1 focus-visible:outline-1 focus-visible:outline-dashed",
|
|
38
|
-
value:
|
|
38
|
+
value: x,
|
|
39
39
|
openMode: "doubleClick",
|
|
40
|
-
onChange:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
onChange: w,
|
|
41
|
+
onEditOpen: S,
|
|
42
|
+
onEditClose: C
|
|
43
|
+
}), !f && x]
|
|
44
|
+
}), f && d !== "element" && /* @__PURE__ */ i(t, {
|
|
45
|
+
selector: l,
|
|
46
|
+
type: d,
|
|
47
|
+
onAction: _
|
|
46
48
|
})]
|
|
47
49
|
});
|
|
48
50
|
};
|
|
49
|
-
export {
|
|
51
|
+
export { c as default };
|
|
@@ -184,7 +184,7 @@ var h = ({ displayMode: h, selectors: g, value: _, element: v, mode: y = "elemen
|
|
|
184
184
|
N,
|
|
185
185
|
j,
|
|
186
186
|
F
|
|
187
|
-
]), $ = T || w || !!S?.length || !!C?.length;
|
|
187
|
+
]), $e = o(() => v?.definition.label ? { [v.id]: v.definition.label } : void 0, [v?.id, v?.definition.label]), $ = T || w || !!S?.length || !!C?.length;
|
|
188
188
|
return /* @__PURE__ */ u("div", {
|
|
189
189
|
className: "flex w-full grow flex-col gap-2",
|
|
190
190
|
children: [/* @__PURE__ */ u("div", {
|
|
@@ -196,6 +196,7 @@ var h = ({ displayMode: h, selectors: g, value: _, element: v, mode: y = "elemen
|
|
|
196
196
|
selectors: g,
|
|
197
197
|
selector: K,
|
|
198
198
|
componentType: b,
|
|
199
|
+
labels: $e,
|
|
199
200
|
onAdd: Pe,
|
|
200
201
|
onChange: Ie,
|
|
201
202
|
onRemove: Le,
|
|
@@ -2,184 +2,182 @@ import e from "./StyleSelectorTag.mjs";
|
|
|
2
2
|
import t from "../../models/SelectorForm/index.mjs";
|
|
3
3
|
import { ancestorRemovals as n, unusedAncestors as r } from "../StyleInspector/helpers.mjs";
|
|
4
4
|
import { memo as i, use as a, useCallback as o, useMemo as s, useState as c } from "react";
|
|
5
|
-
import { useBuilderStore as
|
|
6
|
-
import { jsx as
|
|
7
|
-
import { produce as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { ComponentContext as
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { BuilderContext as
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
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";
|
|
8
|
+
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";
|
|
15
|
+
// src/builder/components/StyleManager/ManagerSelector.tsx
|
|
16
|
+
var v = (e) => e.split(":")[0], y = (e, t) => {
|
|
17
|
+
let n = v(t);
|
|
18
|
+
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) => {
|
|
19
23
|
let n = Number(e.type === "element"), r = Number(t.type === "element");
|
|
20
24
|
return n === r ? e.name.localeCompare(t.name) : r - n;
|
|
21
25
|
});
|
|
22
|
-
}, [
|
|
26
|
+
}, [T, E]), P = o((e) => D(e), [D]), F = o((e, t) => {
|
|
23
27
|
if (t) {
|
|
24
28
|
if (t.mode === "default") {
|
|
25
29
|
let { name: e } = t;
|
|
26
|
-
|
|
30
|
+
A("styleAddSelector", i, e, "class", void 0, void 0, {
|
|
27
31
|
styleSelector: void 0,
|
|
28
32
|
componentType: void 0
|
|
29
33
|
});
|
|
30
34
|
} else {
|
|
31
35
|
let { componentType: e } = t;
|
|
32
|
-
|
|
36
|
+
A("styleAddSelector", i, e, "element", void 0, void 0, {
|
|
33
37
|
styleSelector: void 0,
|
|
34
38
|
componentType: e
|
|
35
39
|
});
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
|
-
}, [
|
|
42
|
+
}, [A, i]), [I, L, R, z] = h({
|
|
39
43
|
id: "add-selector",
|
|
40
44
|
onClose: F
|
|
41
45
|
}), B = o((e) => {
|
|
42
|
-
|
|
43
|
-
}, [
|
|
46
|
+
w?.((t) => t?.name === e ? void 0 : T.find((t) => t.name === e));
|
|
47
|
+
}, [w, T]), V = o((e, t, n) => {
|
|
44
48
|
if (!t || !n || n.length === 0) return;
|
|
45
|
-
let r = new Set(n), a =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
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) => {
|
|
50
|
+
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(" ");
|
|
49
52
|
}));
|
|
50
|
-
|
|
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);
|
|
51
54
|
}, [
|
|
52
|
-
|
|
55
|
+
A,
|
|
53
56
|
i,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
]), [U, W, G, K, , q] = v({
|
|
57
|
+
x,
|
|
58
|
+
w
|
|
59
|
+
]), [H, U, W, G, , K] = h({
|
|
58
60
|
id: "delete-selector",
|
|
59
|
-
onClose:
|
|
60
|
-
}),
|
|
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) => ({
|
|
61
63
|
...e,
|
|
62
|
-
[t.name]:
|
|
63
|
-
}), {}), [
|
|
64
|
-
N,
|
|
65
|
-
S,
|
|
66
|
-
V
|
|
67
|
-
]), Q = s(() => Object.fromEntries(E.map((e) => [e.name, {
|
|
64
|
+
[t.name]: x.filter((e) => y(e, t.name)).length
|
|
65
|
+
}), {}), [N, x]), Q = s(() => Object.fromEntries(T.map((e) => [e.name, {
|
|
68
66
|
count: new Set(Object.values(e.attributes).flatMap((e) => Object.keys(e.ancestors ?? {}))).size,
|
|
69
|
-
unused: r(
|
|
70
|
-
}])), [
|
|
71
|
-
for (let [e, { unused: t }] of Object.entries(Q)) for (let r of n(
|
|
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, {
|
|
72
70
|
styleSelector: r.styleSelector,
|
|
73
71
|
styleAncestor: r.styleAncestor,
|
|
74
|
-
componentType:
|
|
72
|
+
componentType: j[r.displayMode][e].componentType
|
|
75
73
|
});
|
|
76
74
|
}, [
|
|
77
75
|
Q,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
]),
|
|
81
|
-
return /* @__PURE__ */
|
|
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", {
|
|
82
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",
|
|
83
81
|
children: [
|
|
84
|
-
/* @__PURE__ */
|
|
82
|
+
/* @__PURE__ */ u(f, {
|
|
85
83
|
intent: "primary",
|
|
86
84
|
size: "sm",
|
|
87
85
|
className: "w-full",
|
|
88
86
|
iconPlacement: "before",
|
|
89
87
|
onClick: R,
|
|
90
|
-
children: [/* @__PURE__ */
|
|
88
|
+
children: [/* @__PURE__ */ l(f.Icon, {
|
|
91
89
|
icon: "fas fa-tint",
|
|
92
90
|
size: "md",
|
|
93
91
|
className: "text-base"
|
|
94
92
|
}), "New Selector"]
|
|
95
93
|
}),
|
|
96
|
-
/* @__PURE__ */
|
|
94
|
+
/* @__PURE__ */ l(g, {
|
|
97
95
|
placeholder: "Search Selector",
|
|
98
|
-
value:
|
|
96
|
+
value: E,
|
|
99
97
|
onChange: P,
|
|
100
98
|
size: "xs"
|
|
101
99
|
}),
|
|
102
|
-
$ > 0 && /* @__PURE__ */
|
|
100
|
+
$ > 0 && /* @__PURE__ */ u("div", {
|
|
103
101
|
className: "flex items-center justify-between gap-2 rounded-sm bg-amber-500/10 px-2 py-1",
|
|
104
|
-
children: [/* @__PURE__ */
|
|
102
|
+
children: [/* @__PURE__ */ u("span", {
|
|
105
103
|
className: "text-xs text-amber-700 dark:text-amber-300",
|
|
106
|
-
children: [/* @__PURE__ */
|
|
107
|
-
}), /* @__PURE__ */
|
|
104
|
+
children: [/* @__PURE__ */ l("i", { className: "fas fa-triangle-exclamation mr-1" }), ie]
|
|
105
|
+
}), /* @__PURE__ */ l(f, {
|
|
108
106
|
size: "xs",
|
|
109
|
-
onClick:
|
|
107
|
+
onClick: ae,
|
|
110
108
|
children: "Clean up"
|
|
111
109
|
})]
|
|
112
110
|
}),
|
|
113
|
-
|
|
111
|
+
O.length > 0 && /* @__PURE__ */ u("div", {
|
|
114
112
|
className: "bg-secondary-50 dark:bg-secondary-900/30 flex items-center justify-between gap-2 rounded-sm px-2 py-1",
|
|
115
|
-
children: [/* @__PURE__ */
|
|
113
|
+
children: [/* @__PURE__ */ u("span", {
|
|
116
114
|
className: "text-xs text-zinc-600 dark:text-zinc-300",
|
|
117
|
-
children: [
|
|
118
|
-
}), /* @__PURE__ */
|
|
115
|
+
children: [O.length, " selected"]
|
|
116
|
+
}), /* @__PURE__ */ u("div", {
|
|
119
117
|
className: "flex gap-1",
|
|
120
|
-
children: [/* @__PURE__ */
|
|
118
|
+
children: [/* @__PURE__ */ l(f, {
|
|
121
119
|
size: "xs",
|
|
122
|
-
onClick:
|
|
120
|
+
onClick: Y,
|
|
123
121
|
children: "Clear"
|
|
124
|
-
}), /* @__PURE__ */
|
|
122
|
+
}), /* @__PURE__ */ u(f, {
|
|
125
123
|
intent: "danger",
|
|
126
124
|
size: "xs",
|
|
127
125
|
iconPlacement: "before",
|
|
128
|
-
onClick:
|
|
129
|
-
children: [/* @__PURE__ */
|
|
126
|
+
onClick: X,
|
|
127
|
+
children: [/* @__PURE__ */ l(f.Icon, { icon: "fas fa-trash" }), "Delete"]
|
|
130
128
|
})]
|
|
131
129
|
})]
|
|
132
130
|
}),
|
|
133
|
-
/* @__PURE__ */
|
|
131
|
+
/* @__PURE__ */ l("div", {
|
|
134
132
|
className: "flex grow basis-0 flex-col overflow-y-auto",
|
|
135
133
|
children: N.map((t) => {
|
|
136
134
|
let { name: n, type: r } = t;
|
|
137
|
-
return /* @__PURE__ */
|
|
135
|
+
return /* @__PURE__ */ l(e, {
|
|
138
136
|
id: n,
|
|
139
|
-
active: n ===
|
|
140
|
-
checked:
|
|
137
|
+
active: n === C,
|
|
138
|
+
checked: O.includes(n),
|
|
141
139
|
label: n,
|
|
142
140
|
type: r,
|
|
143
|
-
elementsCount:
|
|
141
|
+
elementsCount: re[n],
|
|
144
142
|
ancestorsCount: Q[n].count,
|
|
145
143
|
unusedAncestorsCount: Q[n].unused.size,
|
|
146
144
|
onSelect: B,
|
|
147
|
-
onDelete:
|
|
148
|
-
onToggleCheck:
|
|
145
|
+
onDelete: q,
|
|
146
|
+
onToggleCheck: J
|
|
149
147
|
}, n);
|
|
150
148
|
})
|
|
151
149
|
}),
|
|
152
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ u(p, {
|
|
153
151
|
id: I,
|
|
154
152
|
open: L,
|
|
155
153
|
onClose: z,
|
|
156
154
|
size: "sm",
|
|
157
|
-
children: [/* @__PURE__ */
|
|
155
|
+
children: [/* @__PURE__ */ l(p.Header, { children: /* @__PURE__ */ l("h4", { children: "Add Selector" }) }), /* @__PURE__ */ l(p.Body, { children: /* @__PURE__ */ l(t, {
|
|
158
156
|
componentsNotAvailables: ne,
|
|
159
|
-
components:
|
|
157
|
+
components: M.current,
|
|
160
158
|
onSubmit: z,
|
|
161
159
|
onClose: z
|
|
162
160
|
}) })]
|
|
163
161
|
}),
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
-
id:
|
|
166
|
-
open:
|
|
167
|
-
onClose:
|
|
162
|
+
/* @__PURE__ */ u(p, {
|
|
163
|
+
id: H,
|
|
164
|
+
open: U,
|
|
165
|
+
onClose: G,
|
|
168
166
|
children: [
|
|
169
|
-
/* @__PURE__ */
|
|
170
|
-
/* @__PURE__ */
|
|
167
|
+
/* @__PURE__ */ l(p.Header, { children: /* @__PURE__ */ l("h4", { children: "Remove Selector" }) }),
|
|
168
|
+
/* @__PURE__ */ u(p.Body, { children: [Z > 1 && /* @__PURE__ */ u("h4", { children: [
|
|
171
169
|
"Do you want to remove these ",
|
|
172
170
|
Z,
|
|
173
171
|
" items ?"
|
|
174
|
-
] }), Z <= 1 && /* @__PURE__ */
|
|
175
|
-
/* @__PURE__ */
|
|
172
|
+
] }), Z <= 1 && /* @__PURE__ */ l("h4", { children: "Do you want to remove this item ?" })] }),
|
|
173
|
+
/* @__PURE__ */ u(p.Footer, {
|
|
176
174
|
justify: "end",
|
|
177
|
-
children: [/* @__PURE__ */
|
|
178
|
-
onClick:
|
|
175
|
+
children: [/* @__PURE__ */ l(f, {
|
|
176
|
+
onClick: oe,
|
|
179
177
|
size: "sm",
|
|
180
178
|
children: "Cancel"
|
|
181
|
-
}), /* @__PURE__ */
|
|
182
|
-
onClick:
|
|
179
|
+
}), /* @__PURE__ */ l(f, {
|
|
180
|
+
onClick: se,
|
|
183
181
|
size: "sm",
|
|
184
182
|
children: "Submit"
|
|
185
183
|
})]
|
|
@@ -189,4 +187,4 @@ var x = i(({ displayMode: i, flat: x, flatList: S, selectors: C, selected: w, on
|
|
|
189
187
|
]
|
|
190
188
|
});
|
|
191
189
|
});
|
|
192
|
-
export {
|
|
190
|
+
export { b as default };
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { StyleVariableCategory as e, isStyleVariableCategory as t } from "@plitzi/sdk-shared/types";
|
|
2
2
|
// src/helpers/processSelectorVariables.ts
|
|
3
|
-
var n = (
|
|
4
|
-
let { variables:
|
|
5
|
-
if (!
|
|
6
|
-
let
|
|
3
|
+
var n = (e) => typeof e == "object", r = (r) => {
|
|
4
|
+
let { variables: i } = r;
|
|
5
|
+
if (!i || !Object.keys(i).length) return;
|
|
6
|
+
let a = {
|
|
7
7
|
default: [],
|
|
8
8
|
light: [],
|
|
9
9
|
dark: []
|
|
10
10
|
};
|
|
11
|
-
return Object.entries(
|
|
12
|
-
switch (t(
|
|
11
|
+
return Object.entries(i).forEach(([r, i]) => {
|
|
12
|
+
switch (t(r) ? r : e.CUSTOM) {
|
|
13
13
|
case e.COLOR:
|
|
14
|
-
Object.
|
|
15
|
-
|
|
16
|
-
i.default.push(`--${e}:${t.default};`), t.light && i.light.push(`--${e}:${t.light};`), t.dark && i.dark.push(`--${e}:${t.dark};`);
|
|
14
|
+
Object.entries(i).forEach(([e, t]) => {
|
|
15
|
+
n(t) ? (t.default !== void 0 && a.default.push(`--${e}:${t.default};`), t.light && a.light.push(`--${e}:${t.light};`), t.dark && a.dark.push(`--${e}:${t.dark};`)) : a.default.push(`--${e}:${String(t)};`);
|
|
17
16
|
});
|
|
18
17
|
break;
|
|
19
18
|
case e.SPACING:
|
|
20
19
|
case e.SHADOW:
|
|
21
20
|
case e.CUSTOM:
|
|
22
|
-
default: Object.keys(
|
|
23
|
-
|
|
21
|
+
default: Object.keys(i).forEach((e) => {
|
|
22
|
+
a.default.push(`--${e}:${i[e]};`);
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
|
-
}),
|
|
25
|
+
}), a;
|
|
27
26
|
};
|
|
28
|
-
export {
|
|
27
|
+
export { r as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-style",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.4",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@plitzi/nexus": "^1.4.0",
|
|
36
|
-
"@plitzi/plitzi-ui": "^1.6.
|
|
37
|
-
"@plitzi/sdk-event-bridge": "0.39.
|
|
38
|
-
"@plitzi/sdk-shared": "0.39.
|
|
39
|
-
"@plitzi/sdk-variables": "0.39.
|
|
36
|
+
"@plitzi/plitzi-ui": "^1.6.39",
|
|
37
|
+
"@plitzi/sdk-event-bridge": "0.39.4",
|
|
38
|
+
"@plitzi/sdk-shared": "0.39.4",
|
|
39
|
+
"@plitzi/sdk-variables": "0.39.4",
|
|
40
40
|
"clsx": "^2.1.1",
|
|
41
41
|
"immer": "^11.2.9",
|
|
42
42
|
"zod": "^4.6.7"
|