@plitzi/sdk-style 0.36.1 → 0.37.0

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 (47) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/dist/StyleMap/StyleMap.d.ts +5 -21
  3. package/dist/StyleMap/helpers/isValueValid.d.ts +1 -0
  4. package/dist/StyleMap/helpers/isValueValid.mjs +3 -3
  5. package/dist/StyleMap/helpers/utils.d.ts +2 -2
  6. package/dist/StyleMap/helpers/utils.mjs +43 -28
  7. package/dist/StyleMap/methods/addSelector.d.ts +2 -7
  8. package/dist/StyleMap/methods/addSelector.mjs +4 -4
  9. package/dist/StyleMap/methods/updateSelector.d.ts +2 -5
  10. package/dist/StyleMap/methods/updateSelector.mjs +2 -2
  11. package/dist/StyleReducer.d.ts +3 -11
  12. package/dist/components/Selector/Selector.mjs +149 -125
  13. package/dist/components/Selector/SelectorHelper.d.ts +25 -0
  14. package/dist/components/Selector/SelectorHelper.mjs +43 -2
  15. package/dist/components/StyleInspector/Inspector.d.ts +2 -1
  16. package/dist/components/StyleInspector/Inspector.mjs +92 -87
  17. package/dist/components/StyleInspector/StyleInspector.mjs +240 -169
  18. package/dist/components/StyleInspector/StyleInspectorContext.d.ts +1 -0
  19. package/dist/components/StyleInspector/StyleInspectorProvider.d.ts +2 -1
  20. package/dist/components/StyleInspector/StyleInspectorProvider.mjs +37 -31
  21. package/dist/components/StyleInspector/categories/Others/Others.mjs +58 -48
  22. package/dist/components/StyleInspector/categories/Others/OthersScrollbar.d.ts +9 -0
  23. package/dist/components/StyleInspector/categories/Others/OthersScrollbar.mjs +36 -0
  24. package/dist/components/StyleInspector/categories/Typography/Typography.mjs +29 -45
  25. package/dist/components/StyleInspector/categories/Typography/TypographyFigures.d.ts +13 -0
  26. package/dist/components/StyleInspector/categories/Typography/TypographyFigures.mjs +61 -0
  27. package/dist/components/StyleInspector/components/AncestorRules/AncestorRuleChip.d.ts +10 -0
  28. package/dist/components/StyleInspector/components/AncestorRules/AncestorRuleChip.mjs +39 -0
  29. package/dist/components/StyleInspector/components/AncestorRules/AncestorRules.d.ts +14 -0
  30. package/dist/components/StyleInspector/components/AncestorRules/AncestorRules.mjs +36 -0
  31. package/dist/components/StyleInspector/components/AncestorRules/index.d.ts +3 -0
  32. package/dist/components/StyleInspector/components/AncestorRules/index.mjs +5 -0
  33. package/dist/components/StyleInspector/helpers.d.ts +36 -0
  34. package/dist/components/StyleInspector/helpers.mjs +54 -0
  35. package/dist/components/StyleInspector/hooks/useStyleInherit.d.ts +2 -1
  36. package/dist/components/StyleInspector/hooks/useStyleInherit.mjs +7 -5
  37. package/dist/components/StyleManager/ManagerSelector.d.ts +3 -2
  38. package/dist/components/StyleManager/ManagerSelector.mjs +114 -86
  39. package/dist/components/StyleManager/StyleManager.mjs +1 -0
  40. package/dist/components/StyleManager/StyleSelectorTag.d.ts +4 -1
  41. package/dist/components/StyleManager/StyleSelectorTag.mjs +36 -22
  42. package/dist/helpers/calculateInheriting.d.ts +1 -0
  43. package/dist/helpers/calculateInheriting.mjs +38 -28
  44. package/dist/helpers/processSelector.mjs +44 -21
  45. package/dist/helpers/processSelectorAttributes.d.ts +14 -6
  46. package/dist/helpers/processSelectorAttributes.mjs +38 -22
  47. package/package.json +18 -6
@@ -1,201 +1,272 @@
1
- import e from "../Selector/index.mjs";
2
- import t from "./Inspector.mjs";
3
- import { use as n, useCallback as r, useEffect as i, useMemo as a, useState as o } from "react";
4
- import { useBuilderStoreSync as s } from "@plitzi/sdk-shared/store";
5
- import { get as c, pick as l, set as u } from "@plitzi/plitzi-ui/helpers";
6
- import { produce as d } from "immer";
7
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
8
- import { clsx as m } from "clsx";
9
- import h from "@plitzi/sdk-shared/builder/contexts/BuilderContext";
10
- import g from "@plitzi/plitzi-ui/hooks/useDidUpdateEffect";
11
- import _ from "@plitzi/plitzi-ui/Select";
12
- import v from "@plitzi/plitzi-ui/Select2";
1
+ import { STYLE_STATE_OPTIONS as e, ancestorClasses as t, ancestorConditions as n, ancestorOptions as r, ancestorRemovals as i, unusedAncestors as a } from "./helpers.mjs";
2
+ import o from "../Selector/index.mjs";
3
+ import ee from "./components/AncestorRules/index.mjs";
4
+ import te from "./Inspector.mjs";
5
+ import { use as ne, useCallback as s, useEffect as re, useMemo as c, useState as l } from "react";
6
+ import { useBuilderStore as ie, useBuilderStoreSync as u } from "@plitzi/sdk-shared/store";
7
+ import { get as d, pick as f, set as p } from "@plitzi/plitzi-ui/helpers";
8
+ import { produce as m } from "immer";
9
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
10
+ import { clsx as ae } from "clsx";
11
+ import oe from "@plitzi/sdk-shared/builder/contexts/BuilderContext";
12
+ import _ from "@plitzi/plitzi-ui/hooks/useDidUpdateEffect";
13
+ import v from "@plitzi/plitzi-ui/Select";
14
+ import y from "@plitzi/plitzi-ui/Select2";
13
15
  //#region src/components/StyleInspector/StyleInspector.tsx
14
- var y = ({ displayMode: y, selectors: b, value: x, element: S, mode: C = "element", componentType: w, styleSelectors: T, styleSelectorsAvailables: E, componentSubTypesAvailables: D, allowStyleSelector: O = !0, allowStyleState: k = !0, allowStyleVariant: A = !0, onChange: j, onRemoveVariant: M }) => {
15
- let [N, P] = o(void 0), [F, I] = o("base"), [L, R] = o(void 0), [z, B] = o(void 0);
16
- s("styleSelector", F, { enabled: C === "element" }), s("styleVariant", L, { enabled: C === "element" }), s("styleState", z, { enabled: C === "element" });
17
- let { builderHandler: V } = n(h), H = a(() => c(T, F, ""), [T, F]), U = a(() => Object.values(l(b ?? {}, S ? [S.definition.type, ...H.split(" ")] : H.split(" "))), [
18
- b,
19
- S,
20
- H
21
- ]), W = a(() => x ? c(b, x) : void 0, [b, x]), G = a(() => Object.keys(W?.attributes[F]?.variants ?? {}).map((e) => ({
22
- label: e,
23
- value: e
24
- })), [W?.attributes, F]);
25
- i(() => {
26
- if (I("base"), C !== "element") return;
27
- let e = c(T, "base", "").split(" "), t = e[e.length - 1];
28
- j?.(t || ""), B(void 0), P(void 0);
29
- }, [j, T]), g(() => {
30
- if (C === "element") {
31
- if (x !== S?.definition.type) {
32
- let e = c(T, F, "").split(" ");
16
+ var b = ({ displayMode: b, selectors: x, value: S, element: C, mode: w = "element", componentType: T, styleSelectors: E, styleSelectorsAvailables: D, componentSubTypesAvailables: O, allowStyleSelector: se = !0, allowStyleState: k = !0, allowStyleVariant: A = !0, onChange: j, onRemoveVariant: M }) => {
17
+ let [ce, N] = l(void 0), [P, F] = l("base"), [I, L] = l(void 0), [R, z] = l(void 0);
18
+ u("styleSelector", P, { enabled: w === "element" }), u("styleVariant", I, { enabled: w === "element" });
19
+ let [B, V] = l(void 0);
20
+ u("styleState", R, { enabled: w === "element" }), u("styleAncestor", B, { enabled: w === "element" });
21
+ let [[H, U]] = ie(["schema.flat", "style.platform"]), { builderHandler: W } = ne(oe), G = c(() => d(E, P, ""), [E, P]), le = c(() => Object.values(f(x ?? {}, C ? [C.definition.type, ...G.split(" ")] : G.split(" "))), [
22
+ x,
23
+ C,
24
+ G
25
+ ]), K = c(() => S ? d(x, S) : void 0, [x, S]), q = K?.attributes[P]?.ancestors, J = c(() => w === "element" ? t(H, C) : Object.values(x ?? {}).filter((e) => e.type === "class" && e.name !== S).map((e) => e.name).sort((e, t) => e.localeCompare(t)), [
26
+ C,
27
+ H,
28
+ w,
29
+ x,
30
+ S
31
+ ]), Y = c(() => r(J, q), [J, q]), X = c(() => n(q), [q]), Z = c(() => K ? a(H, K) : /* @__PURE__ */ new Set(), [H, K]), ue = c(() => {
32
+ let e = Object.keys(q ?? {}).length;
33
+ return e ? `When an ancestor is… (${e} set)` : "When an ancestor is…";
34
+ }, [q]), de = c(() => {
35
+ let e = K?.attributes[P], t = B ? [...Object.keys(x?.[B]?.attributes.base.variants ?? {}), ...Object.keys(e?.ancestors?.[B]?.variants ?? {})] : Object.keys(e?.variants ?? {});
36
+ return [...new Set(t)].map((e) => ({
37
+ label: e,
38
+ value: e
39
+ }));
40
+ }, [
41
+ K?.attributes,
42
+ x,
43
+ B,
44
+ P
45
+ ]);
46
+ re(() => {
47
+ if (F("base"), w !== "element") return;
48
+ let e = d(E, "base", "").split(" "), t = e[e.length - 1];
49
+ j?.(t || ""), z(void 0), V(void 0), N(void 0);
50
+ }, [j, E]), _(() => {
51
+ if (w === "element") {
52
+ if (S !== C?.definition.type) {
53
+ let e = d(E, P, "").split(" ");
33
54
  j?.(e[e.length - 1]);
34
55
  }
35
- B(void 0), R(void 0), P(void 0);
56
+ z(void 0), L(void 0), V(void 0), N(void 0);
36
57
  }
37
- }, [F]), g(() => {
38
- B(void 0), R(void 0), P(void 0);
39
- }, [x]);
40
- let K = r((e, t, n) => {
58
+ }, [P]), _(() => {
59
+ z(void 0), L(void 0), V(void 0), N(void 0);
60
+ }, [S]);
61
+ let fe = s((e, t, n) => {
41
62
  if (t && !n) return;
42
63
  let { name: r, type: i } = e;
43
- !t && r !== "" && !b?.[r] ? V("styleAddSelector", y, r, i, void 0, void 0, {
44
- styleSelector: F,
45
- componentType: i === "element" ? w : void 0
46
- }) : t && n && n.name !== r && b?.[n.name] && !b[r] && V("styleAddSelector", y, r, i, void 0, c(b, `${n.name}.attributes.${F}.default`, {}), {
47
- styleSelector: F,
48
- componentType: i === "element" ? w : void 0
64
+ !t && r !== "" && !x?.[r] ? W("styleAddSelector", b, r, i, void 0, void 0, {
65
+ styleSelector: P,
66
+ componentType: i === "element" ? T : void 0
67
+ }) : t && n && n.name !== r && x?.[n.name] && !x[r] && W("styleAddSelector", b, r, i, void 0, d(x, `${n.name}.attributes.${P}.default`, {}), {
68
+ styleSelector: P,
69
+ componentType: i === "element" ? T : void 0
49
70
  });
50
71
  }, [
51
- V,
52
- w,
53
- y,
72
+ W,
73
+ T,
54
74
  b,
55
- F
56
- ]), q = r((e) => {
57
- if (!e || x && x === e.name) {
75
+ x,
76
+ P
77
+ ]), pe = s((e) => {
78
+ if (!e || S && S === e.name) {
58
79
  j?.(void 0);
59
80
  return;
60
81
  }
61
82
  j?.(e.name);
62
- }, [j, x]), J = r((e) => {
63
- S && V("schemaUpdateElement", d(S, (t) => {
64
- u(t, `definition.styleSelectors.${F}`, e);
83
+ }, [j, S]), me = s((e) => {
84
+ C && W("schemaUpdateElement", m(C, (t) => {
85
+ p(t, `definition.styleSelectors.${P}`, e);
65
86
  }));
66
87
  }, [
67
- S,
68
- V,
69
- F
70
- ]), Y = r((e) => {
71
- V("styleRemoveSelector", y, e.name);
72
- }, [V, y]), X = r((e) => P(e), []), Z = r((e) => {
73
- I(e);
74
- }, []), Q = r((e) => B(e?.value), []), $ = r((e) => {
75
- R(e?.value);
76
- }, []), ee = r((e) => {
77
- M?.(e.value), z && B(void 0), e.value === L && R(void 0), V("styleUpdateSelector", y, W?.name, void 0, void 0, {
78
- styleSelector: F,
88
+ C,
89
+ W,
90
+ P
91
+ ]), he = s((e) => {
92
+ W("styleRemoveSelector", b, e.name);
93
+ }, [W, b]), ge = s((e) => N(e), []), _e = s((e) => {
94
+ F(e);
95
+ }, []), ve = s((e) => z(e?.value), []), ye = s((e) => {
96
+ V(e?.value), z(void 0), L(void 0);
97
+ }, []), be = s((e) => {
98
+ e.value === B && (V(void 0), z(void 0), L(void 0)), K?.attributes[P]?.ancestors?.[e.value] && W("styleUpdateSelector", b, K.name, void 0, void 0, {
99
+ styleSelector: P,
100
+ styleAncestor: e.value,
101
+ componentType: K.componentType
102
+ });
103
+ }, [
104
+ W,
105
+ b,
106
+ K,
107
+ B,
108
+ P
109
+ ]), xe = s((e) => {
110
+ V(e.ancestor), L(e.variant), z(e.state);
111
+ }, []), Q = s((e) => {
112
+ if (!K) return;
113
+ let { ancestor: t, state: n, variant: r } = e;
114
+ t === B && n === R && r === I && (z(void 0), L(void 0)), W("styleUpdateSelector", b, K.name, void 0, n || r ? void 0 : {}, {
115
+ styleSelector: P,
116
+ styleAncestor: t,
117
+ styleState: n,
118
+ styleVariant: r,
119
+ componentType: K.componentType
120
+ });
121
+ }, [
122
+ W,
123
+ b,
124
+ K,
125
+ B,
126
+ P,
127
+ R,
128
+ I
129
+ ]), Se = s(() => {
130
+ if (K) {
131
+ B && Z.has(B) && (V(void 0), z(void 0), L(void 0));
132
+ for (let e of i(U, K.name, Z)) W("styleUpdateSelector", e.displayMode, K.name, void 0, void 0, {
133
+ styleSelector: e.styleSelector,
134
+ styleAncestor: e.styleAncestor,
135
+ componentType: K.componentType
136
+ });
137
+ }
138
+ }, [
139
+ W,
140
+ U,
141
+ K,
142
+ B,
143
+ Z
144
+ ]), Ce = s((e) => {
145
+ L(e?.value);
146
+ }, []), we = s((e) => {
147
+ M?.(e.value), R && z(void 0), e.value === I && L(void 0), W("styleUpdateSelector", b, K?.name, void 0, void 0, {
148
+ styleSelector: P,
79
149
  styleVariant: e.value,
80
- styleState: z,
81
- componentType: W?.componentType
150
+ styleAncestor: B,
151
+ componentType: K?.componentType
82
152
  });
83
153
  }, [
84
- V,
85
- y,
154
+ W,
155
+ b,
86
156
  M,
87
- W?.componentType,
88
- W?.name,
89
- F,
90
- z,
91
- L
92
- ]), te = O && (A || k || !!E?.length || !!D?.length);
93
- return /* @__PURE__ */ p("div", {
157
+ K?.componentType,
158
+ K?.name,
159
+ P,
160
+ R,
161
+ I,
162
+ B
163
+ ]), $ = A || k || !!D?.length || !!O?.length;
164
+ return /* @__PURE__ */ g("div", {
94
165
  className: "flex w-full grow flex-col gap-2",
95
- children: [/* @__PURE__ */ p("div", {
166
+ children: [/* @__PURE__ */ g("div", {
96
167
  className: "flex w-full flex-col gap-2 px-1",
97
- children: [C === "element" && /* @__PURE__ */ f(e, {
98
- className: "min-h-0 w-full",
99
- value: H,
100
- selectors: b,
101
- selector: W,
102
- componentType: w,
103
- onAdd: K,
104
- onChange: J,
105
- onRemove: Y,
106
- onSelectorSelected: q
107
- }), te && /* @__PURE__ */ p("div", {
108
- className: m("flex w-full items-center gap-2", { "mt-2": C === "manager" }),
109
- children: [
110
- !!D?.length && /* @__PURE__ */ f(_, {
111
- className: "grow basis-0",
112
- size: "xs",
113
- value: N,
114
- onChange: X,
115
- children: D.map((e) => /* @__PURE__ */ f("option", {
116
- value: e,
117
- children: e
118
- }, e))
119
- }),
120
- E && E.length > 1 && /* @__PURE__ */ f(_, {
121
- className: "grow basis-0",
122
- size: "xs",
123
- onChange: Z,
124
- value: F,
125
- children: E.map((e) => /* @__PURE__ */ f("option", {
126
- value: e,
127
- children: e
128
- }, e))
129
- }),
130
- A && /* @__PURE__ */ f("div", {
131
- className: "grow basis-0",
132
- children: /* @__PURE__ */ f(v, {
168
+ children: [
169
+ w === "element" && /* @__PURE__ */ h(o, {
170
+ className: "min-h-0 w-full",
171
+ value: G,
172
+ selectors: x,
173
+ selector: K,
174
+ componentType: T,
175
+ onAdd: fe,
176
+ onChange: me,
177
+ onRemove: he,
178
+ onSelectorSelected: pe
179
+ }),
180
+ $ && /* @__PURE__ */ g("div", {
181
+ className: ae("flex w-full items-center gap-2", { "mt-2": w === "manager" }),
182
+ children: [
183
+ !!O?.length && /* @__PURE__ */ h(v, {
133
184
  className: "grow basis-0",
134
- value: L,
135
- options: G,
136
- placeholder: "Variant",
137
185
  size: "xs",
138
- allowCreateOptions: !0,
139
- allowRemoveOptions: !0,
140
- clearable: !0,
141
- onChange: $,
142
- onRemove: ee
143
- })
144
- }),
145
- k && /* @__PURE__ */ f("div", {
146
- className: "grow basis-0",
147
- children: /* @__PURE__ */ f(v, {
186
+ value: ce,
187
+ onChange: ge,
188
+ children: O.map((e) => /* @__PURE__ */ h("option", {
189
+ value: e,
190
+ children: e
191
+ }, e))
192
+ }),
193
+ se && D && D.length > 1 && /* @__PURE__ */ h(v, {
148
194
  className: "grow basis-0",
149
- value: z,
150
- options: [
151
- {
152
- label: "Hover",
153
- value: "hover"
154
- },
155
- {
156
- label: "Focus",
157
- value: "focus"
158
- },
159
- {
160
- label: "Active",
161
- value: "active"
162
- },
163
- {
164
- label: "Disabled",
165
- value: "disabled"
166
- },
167
- {
168
- label: "checked",
169
- value: "Checked"
170
- },
171
- {
172
- label: "visited",
173
- value: "Visited"
174
- }
175
- ],
176
- placeholder: "State",
177
195
  size: "xs",
178
- clearable: !0,
179
- onChange: Q
196
+ onChange: _e,
197
+ value: P,
198
+ children: D.map((e) => /* @__PURE__ */ h("option", {
199
+ value: e,
200
+ children: e
201
+ }, e))
202
+ }),
203
+ A && /* @__PURE__ */ h("div", {
204
+ className: "grow basis-0",
205
+ children: /* @__PURE__ */ h(y, {
206
+ className: "grow basis-0",
207
+ value: I,
208
+ options: de,
209
+ placeholder: "Variant",
210
+ size: "xs",
211
+ allowCreateOptions: !0,
212
+ allowRemoveOptions: !0,
213
+ clearable: !0,
214
+ onChange: Ce,
215
+ onRemove: we
216
+ })
217
+ }),
218
+ k && /* @__PURE__ */ h("div", {
219
+ className: "grow basis-0",
220
+ children: /* @__PURE__ */ h(y, {
221
+ className: "grow basis-0",
222
+ value: R,
223
+ options: e,
224
+ placeholder: "State",
225
+ size: "xs",
226
+ clearable: !0,
227
+ onChange: ve
228
+ })
180
229
  })
181
- })
182
- ]
183
- })]
184
- }), /* @__PURE__ */ f("div", {
230
+ ]
231
+ }),
232
+ $ && k && !!Y.length && /* @__PURE__ */ h(y, {
233
+ className: "w-full",
234
+ value: B,
235
+ options: Y,
236
+ placeholder: ue,
237
+ size: "xs",
238
+ clearable: !0,
239
+ allowRemoveOptions: !0,
240
+ onChange: ye,
241
+ onRemove: be
242
+ }),
243
+ k && X.length > 0 && /* @__PURE__ */ h(ee, {
244
+ conditions: X,
245
+ unused: Z,
246
+ activeAncestor: B,
247
+ activeState: R,
248
+ activeVariant: I,
249
+ onSelect: xe,
250
+ onRemove: Q,
251
+ onRemoveUnused: Se
252
+ })
253
+ ]
254
+ }), /* @__PURE__ */ h("div", {
185
255
  className: "flex grow basis-0 flex-col overflow-auto border-t border-gray-300 dark:border-zinc-700",
186
- children: /* @__PURE__ */ f(t, {
187
- selectors: U,
188
- componentType: w,
189
- selector: W,
190
- styleSelector: F,
191
- styleState: z,
192
- styleVariant: L,
193
- element: S,
194
- displayMode: y,
195
- mode: C
256
+ children: /* @__PURE__ */ h(te, {
257
+ selectors: le,
258
+ componentType: T,
259
+ selector: K,
260
+ styleSelector: P,
261
+ styleState: R,
262
+ styleVariant: I,
263
+ styleAncestor: B,
264
+ element: C,
265
+ displayMode: b,
266
+ mode: w
196
267
  })
197
268
  })]
198
269
  });
199
270
  };
200
271
  //#endregion
201
- export { y as default };
272
+ export { b as default };
@@ -9,6 +9,7 @@ export type StyleInspectorContextValue = {
9
9
  selector?: StyleItem;
10
10
  styleSelector: string;
11
11
  styleState?: StyleState;
12
+ styleAncestor?: string;
12
13
  styleVariant?: string;
13
14
  displayMode: DisplayMode;
14
15
  variables: Record<string, unknown>;
@@ -8,10 +8,11 @@ export type StyleInspectorProviderProps = {
8
8
  styleSelector?: string;
9
9
  styleState?: StyleState;
10
10
  styleVariant?: string;
11
+ styleAncestor?: string;
11
12
  element?: Element;
12
13
  inheritData: InheritData;
13
14
  displayMode: DisplayMode;
14
15
  onChange?: (path?: StyleCategory, values?: StyleObject | StyleValue) => void;
15
16
  };
16
- declare const StyleInspectorProvider: ({ children, componentType, selector, styleSelector, styleState, styleVariant, element, inheritData, displayMode, onChange }: StyleInspectorProviderProps) => import("react").JSX.Element;
17
+ declare const StyleInspectorProvider: ({ children, componentType, selector, styleSelector, styleState, styleVariant, styleAncestor, element, inheritData, displayMode, onChange }: StyleInspectorProviderProps) => import("react").JSX.Element;
17
18
  export default StyleInspectorProvider;
@@ -7,79 +7,85 @@ import { get as o, omit as s } from "@plitzi/plitzi-ui/helpers";
7
7
  import { jsx as c } from "react/jsx-runtime";
8
8
  import { baseDefaultValue as l } from "@plitzi/sdk-shared";
9
9
  //#region src/components/StyleInspector/StyleInspectorProvider.tsx
10
- var u = ({ children: u, componentType: d, selector: f, styleSelector: p = "base", styleState: m, styleVariant: h, element: g, inheritData: _, displayMode: v, onChange: y }) => {
11
- let b = t({ element: g }), [x = a] = i("runtime.sources.variables"), S = n(() => {
10
+ var u = ({ children: u, componentType: d, selector: f, styleSelector: p = "base", styleState: m, styleVariant: h, styleAncestor: g, element: _, inheritData: v, displayMode: y, onChange: b }) => {
11
+ let x = t({ element: _ }), [S = a] = i("runtime.sources.variables"), C = n(() => {
12
12
  let e;
13
13
  if (f && p && f.attributes[p]) {
14
14
  let t = f.attributes[p];
15
- e = m && h ? t.variants?.[h].states?.[m] ?? {} : h ? t.variants?.[h]?.default ?? {} : m ? t.states?.[m] ?? {} : t.default ?? {};
15
+ if (g) {
16
+ let n = t.ancestors?.[g], r = h ? n?.variants?.[h] : void 0, i = h ? r : n;
17
+ e = (m ? i?.states?.[m] : i?.default) ?? {};
18
+ } else e = m && h ? t.variants?.[h].states?.[m] ?? {} : h ? t.variants?.[h]?.default ?? {} : m ? t.states?.[m] ?? {} : t.default ?? {};
16
19
  } else e = {};
17
20
  return e;
18
21
  }, [
19
22
  f,
20
23
  p,
21
24
  m,
22
- h
23
- ]), C = n((e, t) => {
24
- if (!(e && typeof t != "string" && typeof t != "number" && t !== void 0 || !e && typeof t != "object" && t !== void 0 || e && o(b, e))) {
25
- if (!e && t && typeof t == "object" && (t = s(t, Object.keys(b))), !e && f && typeof t == "object") {
25
+ h,
26
+ g
27
+ ]), w = n((e, t) => {
28
+ if (!(e && typeof t != "string" && typeof t != "number" && t !== void 0 || !e && typeof t != "object" && t !== void 0 || e && o(x, e))) {
29
+ if (!e && t && typeof t == "object" && (t = s(t, Object.keys(x))), !e && f && typeof t == "object") {
26
30
  let e = {
27
- ...S(),
31
+ ...C(),
28
32
  ...t
29
33
  };
30
34
  Object.keys(e).forEach((t) => {
31
35
  e[t] === void 0 && delete e[t];
32
36
  }), t = e;
33
37
  }
34
- y?.(e, t);
38
+ b?.(e, t);
35
39
  }
36
40
  }, [
41
+ x,
42
+ C,
37
43
  b,
38
- S,
39
- y,
40
44
  f
41
- ]), w = n((e) => Array.isArray(e) ? e.reduce((e, t) => ({
45
+ ]), T = n((e) => Array.isArray(e) ? e.reduce((e, t) => ({
42
46
  ...e,
43
47
  [t]: o(l, t)
44
- }), {}) : e ? o(l, e) : l, []), T = n((e) => {
48
+ }), {}) : e ? o(l, e) : l, []), E = n((e) => {
45
49
  if (Array.isArray(e)) {
46
50
  let t = e.reduce((e, t) => ({
47
51
  ...e,
48
52
  [t]: void 0
49
53
  }), {});
50
- C(void 0, t);
51
- } else C(e);
52
- }, [C]), E = r(() => ({
54
+ w(void 0, t);
55
+ } else w(e);
56
+ }, [w]), D = r(() => ({
53
57
  componentType: d,
54
58
  selector: f,
55
59
  styleSelector: p,
56
60
  styleState: m,
57
61
  styleVariant: h,
58
- displayMode: v,
59
- variables: x,
60
- inheritData: _.style,
61
- bindingData: b,
62
- getValues: S,
63
- setValue: C,
64
- resetValue: T,
65
- getDefaultValue: w
62
+ styleAncestor: g,
63
+ displayMode: y,
64
+ variables: S,
65
+ inheritData: v.style,
66
+ bindingData: x,
67
+ getValues: C,
68
+ setValue: w,
69
+ resetValue: E,
70
+ getDefaultValue: T
66
71
  }), [
67
72
  d,
68
73
  f,
69
74
  p,
70
75
  m,
71
76
  h,
72
- v,
73
- x,
74
- _.style,
75
- b,
77
+ g,
78
+ y,
76
79
  S,
80
+ v.style,
81
+ x,
77
82
  C,
78
- T,
79
- w
83
+ w,
84
+ E,
85
+ T
80
86
  ]);
81
87
  return /* @__PURE__ */ c(e, {
82
- value: E,
88
+ value: D,
83
89
  children: u
84
90
  });
85
91
  };