@floegence/floe-webapp-core 0.101.35 → 0.101.36

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.
@@ -1,23 +1,24 @@
1
1
  import { createComponent as he } from "solid-js/web";
2
- import { untrack as ae, createSignal as p, createEffect as P, createMemo as G, onCleanup as H } from "solid-js";
2
+ import { untrack as ae, createSignal as p, createEffect as g, createMemo as G, onCleanup as H } from "solid-js";
3
3
  import { createSimpleContext as fe } from "./createSimpleContext.js";
4
4
  import { useResolvedFloeConfig as ue } from "./FloeConfigContext.js";
5
- import { isFloeSurfaceStyle as w, applySurfaceStyleAttribute as I, isThemeType as de, getSystemTheme as ye, applyTheme as Se, applyShellThemeAttribute as J, resolveThemeTokens as pe, syncThemeTokenOverrides as U } from "../styles/themes/index.js";
5
+ import { isFloeSurfaceStyle as w, applySurfaceStyleAttribute as I, isThemeType as de, getSystemTheme as Se, applyTheme as ye, applyShellThemeAttribute as J, resolveThemeTokens as pe, syncThemeTokenOverrides as U } from "../styles/themes/index.js";
6
6
  import { normalizeShellThemeSelection as W, presetSupportsMode as X } from "../styles/themes/presets.js";
7
- function g(o, s, r) {
7
+ function v(o, s, r) {
8
8
  if (s.length !== 0)
9
- return o && s.some((i) => i.name === o) ? o : r && s.some((i) => i.name === r) ? r : s[0]?.name;
9
+ return o && s.some((n) => n.name === o) ? o : r && s.some((n) => n.name === r) ? r : s[0]?.name;
10
10
  }
11
11
  function Y(o) {
12
- const s = ue(), r = o ?? (typeof document > "u" ? void 0 : document.documentElement), i = o ? {
12
+ const s = ue(), r = o ?? (typeof document > "u" ? void 0 : document.documentElement), n = o ? {
13
13
  light: o.classList.contains("light"),
14
14
  dark: o.classList.contains("dark"),
15
15
  colorScheme: o.style.getPropertyValue("color-scheme"),
16
16
  colorSchemePriority: o.style.getPropertyPriority("color-scheme"),
17
17
  material: o.getAttribute("data-floe-surface-style"),
18
- shell: o.getAttribute("data-floe-shell-theme")
19
- } : void 0, v = /* @__PURE__ */ new Map(), L = (e) => {
20
- const t = v.get(e);
18
+ shell: o.getAttribute("data-floe-shell-theme"),
19
+ themeScope: o.getAttribute("data-floe-theme")
20
+ } : void 0, P = /* @__PURE__ */ new Map(), L = (e) => {
21
+ const t = P.get(e);
21
22
  t?.value ? o?.style.setProperty(e, t.value, t.priority) : o?.style.removeProperty(e);
22
23
  };
23
24
  let M = !1;
@@ -26,95 +27,95 @@ function Y(o) {
26
27
  const [N, _] = p(w(k) ? k : T), ee = (e) => {
27
28
  _(w(e) ? e : T);
28
29
  };
29
- P(() => I(N(), r));
30
- const te = () => s.config.theme.tokens, c = () => s.config.theme.presets ?? [], b = () => s.config.theme.presetStorageKey ?? `${f()}-preset`, u = () => g(s.config.theme.defaultPreset, c()), h = () => s.config.theme.shellPresets ?? [], F = () => s.config.theme.shellPresetStorageKey ?? `${f()}-shell-preset`, V = () => s.config.theme.defaultShellPreset ?? {}, O = s.persist.load(f(), $()), oe = de(O) ? O : $(), [x, se] = p(oe), re = s.persist.load(b(), u()), [K, j] = p(g(re, c(), u())), ne = s.persist.load(F(), void 0), [A, q] = p(W(ne, h(), V())), [le, ie] = p(ye());
30
+ g(() => I(N(), r));
31
+ const te = () => s.config.theme.tokens, c = () => s.config.theme.presets ?? [], b = () => s.config.theme.presetStorageKey ?? `${f()}-preset`, u = () => v(s.config.theme.defaultPreset, c()), h = () => s.config.theme.shellPresets ?? [], F = () => s.config.theme.shellPresetStorageKey ?? `${f()}-shell-preset`, V = () => s.config.theme.defaultShellPreset ?? {}, O = s.persist.load(f(), $()), oe = de(O) ? O : $(), [x, se] = p(oe), re = s.persist.load(b(), u()), [A, j] = p(v(re, c(), u())), ne = s.persist.load(F(), void 0), [K, q] = p(W(ne, h(), V())), [le, ie] = p(Se());
31
32
  let d = [];
32
33
  const z = G(() => {
33
- const e = g(K(), c(), u());
34
+ const e = v(A(), c(), u());
34
35
  if (e)
35
36
  return c().find((t) => t.name === e);
36
- }), y = () => {
37
+ }), S = () => {
37
38
  const e = x();
38
39
  return e === "system" ? le() : e;
39
40
  }, Q = (e) => {
40
- const t = A()[e];
41
+ const t = K()[e];
41
42
  if (t)
42
- return h().find((n) => n.name === t && X(n, e));
43
- }, R = G(() => Q(y()));
44
- if (P(() => {
45
- const e = g(K(), c(), u());
46
- K() !== e && j(e);
47
- }), P(() => {
48
- const e = A(), t = W(e, h(), V());
43
+ return h().find((l) => l.name === t && X(l, e));
44
+ }, R = G(() => Q(S()));
45
+ if (g(() => {
46
+ const e = v(A(), c(), u());
47
+ A() !== e && j(e);
48
+ }), g(() => {
49
+ const e = K(), t = W(e, h(), V());
49
50
  (e.light !== t.light || e.dark !== t.dark) && q(t);
50
51
  }), typeof window < "u") {
51
- const e = window.matchMedia("(prefers-color-scheme: dark)"), t = (n) => {
52
- ie(n.matches ? "dark" : "light");
52
+ const e = window.matchMedia("(prefers-color-scheme: dark)"), t = (l) => {
53
+ ie(l.matches ? "dark" : "light");
53
54
  };
54
55
  e.addEventListener("change", t), H(() => e.removeEventListener("change", t));
55
56
  }
56
- P(() => {
57
- const e = x(), t = y(), n = R();
58
- Se(e, r), J(n?.name, r);
59
- const m = pe(t, te(), n?.tokens, z()?.tokens);
57
+ g(() => {
58
+ const e = x(), t = S(), l = R();
59
+ o && o.setAttribute("data-floe-theme", ""), ye(e, r), J(l?.name, r);
60
+ const m = pe(t, te(), l?.tokens, z()?.tokens);
60
61
  if (o)
61
- for (const l of Object.keys(m))
62
- v.has(l) || v.set(l, {
63
- value: o.style.getPropertyValue(l),
64
- priority: o.style.getPropertyPriority(l)
62
+ for (const i of Object.keys(m))
63
+ P.has(i) || P.set(i, {
64
+ value: o.style.getPropertyValue(i),
65
+ priority: o.style.getPropertyPriority(i)
65
66
  });
66
- const S = d;
67
- if (d = U(m, S, r), o)
68
- for (const l of S) d.includes(l) || L(l);
67
+ const y = d;
68
+ if (d = U(m, y, r), o)
69
+ for (const i of y) d.includes(i) || L(i);
69
70
  r && queueMicrotask(() => {
70
71
  if (M) return;
71
- const l = /* @__PURE__ */ new Set();
72
+ const i = /* @__PURE__ */ new Set();
72
73
  for (; ; ) {
73
74
  const D = (r.getAnimations?.({
74
75
  subtree: !0
75
- }) ?? []).filter((a) => !l.has(a) && "transitionProperty" in a && /(^|-)color$|^(fill|stroke|box-shadow)$/.test(String(a.transitionProperty)));
76
+ }) ?? []).filter((a) => !i.has(a) && "transitionProperty" in a && /(^|-)color$|^(fill|stroke|box-shadow)$/.test(String(a.transitionProperty)));
76
77
  if (D.length === 0) break;
77
78
  for (const a of D)
78
- l.add(a), a.finish();
79
+ i.add(a), a.finish();
79
80
  }
80
81
  });
81
82
  }), H(() => {
82
- if (M = !0, I(void 0, r), J(void 0, r), d = U(void 0, d, r), o && i) {
83
- o.classList.toggle("light", i.light), o.classList.toggle("dark", i.dark), i.colorScheme ? o.style.setProperty("color-scheme", i.colorScheme, i.colorSchemePriority) : o.style.removeProperty("color-scheme");
84
- for (const [e, t] of [["data-floe-surface-style", i.material], ["data-floe-shell-theme", i.shell]])
83
+ if (M = !0, I(void 0, r), J(void 0, r), d = U(void 0, d, r), o && n) {
84
+ o.classList.toggle("light", n.light), o.classList.toggle("dark", n.dark), n.colorScheme ? o.style.setProperty("color-scheme", n.colorScheme, n.colorSchemePriority) : o.style.removeProperty("color-scheme");
85
+ for (const [e, t] of [["data-floe-surface-style", n.material], ["data-floe-shell-theme", n.shell], ["data-floe-theme", n.themeScope]])
85
86
  t === null ? o.removeAttribute(e) : o.setAttribute(e, t);
86
- for (const e of v.keys()) L(e);
87
+ for (const e of P.keys()) L(e);
87
88
  }
88
89
  });
89
90
  const C = (e) => {
90
91
  se(e), s.persist.debouncedSave(f(), e);
91
92
  }, ce = () => {
92
- const e = y();
93
+ const e = S();
93
94
  C(e === "light" ? "dark" : "light");
94
95
  }, me = (e) => {
95
- const t = g(e, c(), u());
96
+ const t = v(e, c(), u());
96
97
  if (j(t), !t) {
97
98
  s.persist.remove(b());
98
99
  return;
99
100
  }
100
101
  s.persist.debouncedSave(b(), t);
101
102
  }, B = (e, t) => {
102
- const n = h().find((l) => l.name === t && X(l, e));
103
- if (!n) return !1;
104
- const m = A();
105
- if (m[e] === n.name) return !0;
106
- const S = {
103
+ const l = h().find((i) => i.name === t && X(i, e));
104
+ if (!l) return !1;
105
+ const m = K();
106
+ if (m[e] === l.name) return !0;
107
+ const y = {
107
108
  ...m,
108
109
  version: 1,
109
- [e]: n.name
110
+ [e]: l.name
110
111
  };
111
- return q(S), s.persist.debouncedSave(F(), S), !0;
112
+ return q(y), s.persist.debouncedSave(F(), y), !0;
112
113
  };
113
114
  return {
114
115
  surfaceStyle: N,
115
116
  setSurfaceStyle: ee,
116
117
  theme: x,
117
- resolvedTheme: y,
118
+ resolvedTheme: S,
118
119
  setTheme: C,
119
120
  toggleTheme: ce,
120
121
  themePresets: c,
@@ -126,8 +127,8 @@ function Y(o) {
126
127
  setShellPreset: (e) => {
127
128
  const t = h().find((m) => m.name === e);
128
129
  if (!t) return;
129
- const n = t.mode === "light" || t.mode === "dark" ? t.mode : y();
130
- B(n, e);
130
+ const l = t.mode === "light" || t.mode === "dark" ? t.mode : S();
131
+ B(l, e);
131
132
  },
132
133
  selectShellTheme: (e, t) => {
133
134
  B(e, t) && C(e);
@@ -137,7 +138,7 @@ function Y(o) {
137
138
  const Z = fe({
138
139
  name: "Theme",
139
140
  init: Y
140
- }), Ae = Z.use;
141
+ }), Ke = Z.use;
141
142
  function Ce(o) {
142
143
  const s = Y(ae(() => o.target));
143
144
  return he(Z.Context.Provider, {
@@ -150,5 +151,5 @@ function Ce(o) {
150
151
  export {
151
152
  Ce as ThemeProvider,
152
153
  Y as createThemeService,
153
- Ae as useTheme
154
+ Ke as useTheme
154
155
  };