@floegence/floe-webapp-core 0.101.34 → 0.101.35
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.
|
@@ -4,6 +4,8 @@ export interface FloeProviderProps {
|
|
|
4
4
|
children: JSX.Element;
|
|
5
5
|
/** Global Floe configuration (storage, keybinds, strings, defaults). */
|
|
6
6
|
config?: DeepPartial<FloeConfig>;
|
|
7
|
+
/** Stable owned element for embedded theme tokens and palette motion. */
|
|
8
|
+
themeTarget?: HTMLElement;
|
|
7
9
|
/**
|
|
8
10
|
* Allows consumers to inject their own providers *after* ThemeProvider,
|
|
9
11
|
* while ensuring the inner tree is created inside the injected provider.
|
package/dist/app/FloeProvider.js
CHANGED
|
@@ -3,22 +3,22 @@ import { FloeConfigProvider as i } from "../context/FloeConfigContext.js";
|
|
|
3
3
|
import { ThemeProvider as n } from "../context/ThemeContext.js";
|
|
4
4
|
import { NotificationProvider as m } from "../context/NotificationContext.js";
|
|
5
5
|
import { ComponentRegistryProvider as d } from "../context/ComponentRegistry.js";
|
|
6
|
-
import { LayoutProvider as
|
|
7
|
-
import { CommandProvider as
|
|
8
|
-
import { WidgetRegistryProvider as
|
|
6
|
+
import { LayoutProvider as g } from "../context/LayoutContext.js";
|
|
7
|
+
import { CommandProvider as c } from "../context/CommandContext.js";
|
|
8
|
+
import { WidgetRegistryProvider as f } from "../context/WidgetRegistry.js";
|
|
9
9
|
import { DeckProvider as h } from "../context/DeckContext.js";
|
|
10
10
|
function w(e) {
|
|
11
11
|
const t = () => r(m, {
|
|
12
12
|
get children() {
|
|
13
13
|
return r(d, {
|
|
14
14
|
get children() {
|
|
15
|
-
return r(
|
|
15
|
+
return r(g, {
|
|
16
16
|
get children() {
|
|
17
|
-
return r(
|
|
17
|
+
return r(f, {
|
|
18
18
|
get children() {
|
|
19
19
|
return r(h, {
|
|
20
20
|
get children() {
|
|
21
|
-
return r(
|
|
21
|
+
return r(c, {
|
|
22
22
|
get children() {
|
|
23
23
|
return e.children;
|
|
24
24
|
}
|
|
@@ -39,6 +39,9 @@ function w(e) {
|
|
|
39
39
|
},
|
|
40
40
|
get children() {
|
|
41
41
|
return r(n, {
|
|
42
|
+
get target() {
|
|
43
|
+
return e.themeTarget;
|
|
44
|
+
},
|
|
42
45
|
get children() {
|
|
43
46
|
return o(() => !!e.wrapAfterTheme)() ? e.wrapAfterTheme(t) : t();
|
|
44
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Accessor } from 'solid-js';
|
|
1
|
+
import { type Accessor, type JSX } from 'solid-js';
|
|
2
2
|
import { type FloeShellThemeMode, type FloeThemePreset, type ThemeType, type FloeSurfaceStyle } from '../styles/themes';
|
|
3
3
|
export interface ThemeContextValue {
|
|
4
4
|
surfaceStyle: Accessor<FloeSurfaceStyle>;
|
|
@@ -16,7 +16,11 @@ export interface ThemeContextValue {
|
|
|
16
16
|
setShellPreset: (presetName: string) => void;
|
|
17
17
|
selectShellTheme: (mode: FloeShellThemeMode, presetName: string) => void;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
/** An explicit target is owned for this service's lifetime. Its theme changes
|
|
20
|
+
* and palette motion never reach an enclosing document or sibling surface. */
|
|
21
|
+
export declare function createThemeService(target?: HTMLElement): ThemeContextValue;
|
|
22
|
+
export declare const useTheme: () => ThemeContextValue;
|
|
23
|
+
export declare function ThemeProvider(props: {
|
|
24
|
+
children: JSX.Element; /** Stable owned element; omitted uses the document root. */
|
|
25
|
+
target?: HTMLElement;
|
|
26
|
+
}): JSX.Element;
|
|
@@ -1,118 +1,154 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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";
|
|
3
|
+
import { createSimpleContext as fe } from "./createSimpleContext.js";
|
|
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";
|
|
6
|
+
import { normalizeShellThemeSelection as W, presetSupportsMode as X } from "../styles/themes/presets.js";
|
|
7
|
+
function g(o, s, r) {
|
|
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
10
|
}
|
|
10
|
-
function
|
|
11
|
-
const s =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
function Y(o) {
|
|
12
|
+
const s = ue(), r = o ?? (typeof document > "u" ? void 0 : document.documentElement), i = o ? {
|
|
13
|
+
light: o.classList.contains("light"),
|
|
14
|
+
dark: o.classList.contains("dark"),
|
|
15
|
+
colorScheme: o.style.getPropertyValue("color-scheme"),
|
|
16
|
+
colorSchemePriority: o.style.getPropertyPriority("color-scheme"),
|
|
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);
|
|
21
|
+
t?.value ? o?.style.setProperty(e, t.value, t.priority) : o?.style.removeProperty(e);
|
|
15
22
|
};
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
23
|
+
let M = !1;
|
|
24
|
+
const f = () => s.config.theme.storageKey, $ = () => s.config.theme.defaultTheme, E = () => s.config.theme.surfaceStyleStorageKey ?? `${f()}-surface-style`, T = "soft-neumorphic", k = s.persist.load(E(), T);
|
|
25
|
+
w(k) || s.persist.remove(E());
|
|
26
|
+
const [N, _] = p(w(k) ? k : T), ee = (e) => {
|
|
27
|
+
_(w(e) ? e : T);
|
|
28
|
+
};
|
|
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());
|
|
31
|
+
let d = [];
|
|
32
|
+
const z = G(() => {
|
|
33
|
+
const e = g(K(), c(), u());
|
|
21
34
|
if (e)
|
|
22
35
|
return c().find((t) => t.name === e);
|
|
23
|
-
}),
|
|
24
|
-
const e =
|
|
25
|
-
return e === "system" ?
|
|
26
|
-
},
|
|
27
|
-
const t =
|
|
36
|
+
}), y = () => {
|
|
37
|
+
const e = x();
|
|
38
|
+
return e === "system" ? le() : e;
|
|
39
|
+
}, Q = (e) => {
|
|
40
|
+
const t = A()[e];
|
|
28
41
|
if (t)
|
|
29
|
-
return h().find((
|
|
30
|
-
},
|
|
31
|
-
if (
|
|
32
|
-
const e =
|
|
33
|
-
|
|
34
|
-
}),
|
|
35
|
-
const e =
|
|
36
|
-
(e.light !== t.light || e.dark !== t.dark) &&
|
|
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());
|
|
49
|
+
(e.light !== t.light || e.dark !== t.dark) && q(t);
|
|
37
50
|
}), typeof window < "u") {
|
|
38
|
-
const e = window.matchMedia("(prefers-color-scheme: dark)"), t = (
|
|
39
|
-
|
|
51
|
+
const e = window.matchMedia("(prefers-color-scheme: dark)"), t = (n) => {
|
|
52
|
+
ie(n.matches ? "dark" : "light");
|
|
40
53
|
};
|
|
41
|
-
e.addEventListener("change", t),
|
|
54
|
+
e.addEventListener("change", t), H(() => e.removeEventListener("change", t));
|
|
42
55
|
}
|
|
43
|
-
|
|
44
|
-
const e =
|
|
45
|
-
|
|
46
|
-
|
|
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);
|
|
60
|
+
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)
|
|
65
|
+
});
|
|
66
|
+
const S = d;
|
|
67
|
+
if (d = U(m, S, r), o)
|
|
68
|
+
for (const l of S) d.includes(l) || L(l);
|
|
69
|
+
r && queueMicrotask(() => {
|
|
70
|
+
if (M) return;
|
|
71
|
+
const l = /* @__PURE__ */ new Set();
|
|
47
72
|
for (; ; ) {
|
|
48
|
-
const
|
|
73
|
+
const D = (r.getAnimations?.({
|
|
49
74
|
subtree: !0
|
|
50
|
-
}) ?? []).filter((
|
|
51
|
-
if (
|
|
52
|
-
for (const
|
|
53
|
-
|
|
75
|
+
}) ?? []).filter((a) => !l.has(a) && "transitionProperty" in a && /(^|-)color$|^(fill|stroke|box-shadow)$/.test(String(a.transitionProperty)));
|
|
76
|
+
if (D.length === 0) break;
|
|
77
|
+
for (const a of D)
|
|
78
|
+
l.add(a), a.finish();
|
|
54
79
|
}
|
|
55
80
|
});
|
|
56
|
-
}),
|
|
57
|
-
|
|
81
|
+
}), 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]])
|
|
85
|
+
t === null ? o.removeAttribute(e) : o.setAttribute(e, t);
|
|
86
|
+
for (const e of v.keys()) L(e);
|
|
87
|
+
}
|
|
58
88
|
});
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
const e =
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
const t =
|
|
66
|
-
if (
|
|
67
|
-
s.persist.remove(
|
|
89
|
+
const C = (e) => {
|
|
90
|
+
se(e), s.persist.debouncedSave(f(), e);
|
|
91
|
+
}, ce = () => {
|
|
92
|
+
const e = y();
|
|
93
|
+
C(e === "light" ? "dark" : "light");
|
|
94
|
+
}, me = (e) => {
|
|
95
|
+
const t = g(e, c(), u());
|
|
96
|
+
if (j(t), !t) {
|
|
97
|
+
s.persist.remove(b());
|
|
68
98
|
return;
|
|
69
99
|
}
|
|
70
|
-
s.persist.debouncedSave(
|
|
71
|
-
},
|
|
72
|
-
const
|
|
73
|
-
if (!
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
const
|
|
77
|
-
...
|
|
100
|
+
s.persist.debouncedSave(b(), t);
|
|
101
|
+
}, 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 = {
|
|
107
|
+
...m,
|
|
78
108
|
version: 1,
|
|
79
|
-
[e]:
|
|
109
|
+
[e]: n.name
|
|
80
110
|
};
|
|
81
|
-
return
|
|
111
|
+
return q(S), s.persist.debouncedSave(F(), S), !0;
|
|
82
112
|
};
|
|
83
113
|
return {
|
|
84
|
-
surfaceStyle:
|
|
85
|
-
setSurfaceStyle:
|
|
86
|
-
theme:
|
|
87
|
-
resolvedTheme:
|
|
88
|
-
setTheme:
|
|
89
|
-
toggleTheme:
|
|
114
|
+
surfaceStyle: N,
|
|
115
|
+
setSurfaceStyle: ee,
|
|
116
|
+
theme: x,
|
|
117
|
+
resolvedTheme: y,
|
|
118
|
+
setTheme: C,
|
|
119
|
+
toggleTheme: ce,
|
|
90
120
|
themePresets: c,
|
|
91
|
-
themePreset:
|
|
92
|
-
setThemePreset:
|
|
121
|
+
themePreset: z,
|
|
122
|
+
setThemePreset: me,
|
|
93
123
|
shellPresets: h,
|
|
94
|
-
shellPreset:
|
|
95
|
-
shellPresetForMode:
|
|
124
|
+
shellPreset: R,
|
|
125
|
+
shellPresetForMode: Q,
|
|
96
126
|
setShellPreset: (e) => {
|
|
97
|
-
const t = h().find((
|
|
127
|
+
const t = h().find((m) => m.name === e);
|
|
98
128
|
if (!t) return;
|
|
99
|
-
const
|
|
100
|
-
|
|
129
|
+
const n = t.mode === "light" || t.mode === "dark" ? t.mode : y();
|
|
130
|
+
B(n, e);
|
|
101
131
|
},
|
|
102
132
|
selectShellTheme: (e, t) => {
|
|
103
|
-
|
|
133
|
+
B(e, t) && C(e);
|
|
104
134
|
}
|
|
105
135
|
};
|
|
106
136
|
}
|
|
107
|
-
const {
|
|
108
|
-
Provider: ue,
|
|
109
|
-
use: Se
|
|
110
|
-
} = ee({
|
|
137
|
+
const Z = fe({
|
|
111
138
|
name: "Theme",
|
|
112
|
-
init:
|
|
113
|
-
});
|
|
139
|
+
init: Y
|
|
140
|
+
}), Ae = Z.use;
|
|
141
|
+
function Ce(o) {
|
|
142
|
+
const s = Y(ae(() => o.target));
|
|
143
|
+
return he(Z.Context.Provider, {
|
|
144
|
+
value: s,
|
|
145
|
+
get children() {
|
|
146
|
+
return o.children;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
114
150
|
export {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
151
|
+
Ce as ThemeProvider,
|
|
152
|
+
Y as createThemeService,
|
|
153
|
+
Ae as useTheme
|
|
118
154
|
};
|