@floegence/floe-webapp-core 0.34.0 → 0.35.1

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/dist/index.js CHANGED
@@ -1,118 +1,120 @@
1
1
  import { FloeProvider as r } from "./app/FloeProvider.js";
2
- import { applyTheme as i, builtInThemes as n, getSystemTheme as s } from "./styles/themes/index.js";
3
- import { CommandProvider as a, createCommandService as p, useCommand as d } from "./context/CommandContext.js";
4
- import { ComponentRegistryProvider as l, createComponentRegistry as u, hasComponentRegistryContext as x, useComponentContextFactory as g, useComponentRegistry as c, useOptionalComponentRegistry as C } from "./context/ComponentRegistry.js";
5
- import { DEFAULT_FLOE_CONFIG as v, FloeConfigProvider as F, useFloeConfig as D, useResolvedFloeConfig as P } from "./context/FloeConfigContext.js";
6
- import { DeckProvider as I, createDeckService as R, useDeck as T } from "./context/DeckContext.js";
7
- import { FileBrowserDragProvider as b, hasFileBrowserDragContext as k, useFileBrowserDrag as B } from "./context/FileBrowserDragContext.js";
8
- import { LayoutProvider as W, createLayoutService as L, useLayout as N } from "./context/LayoutContext.js";
9
- import { NotificationContainer as G, NotificationProvider as z, createNotificationService as K, useNotification as O } from "./context/NotificationContext.js";
10
- import { ThemeProvider as V, createThemeService as _, useTheme as H } from "./context/ThemeContext.js";
11
- import { ViewActivationProvider as Q, useViewActivation as U } from "./context/ViewActivationContext.js";
12
- import { WidgetRegistryProvider as q, createWidgetRegistry as J, useWidgetRegistry as X } from "./context/WidgetRegistry.js";
13
- import { WidgetStateProvider as Z, useCurrentWidgetId as $, useWidgetState as ee, useWidgetStateContext as oe } from "./context/WidgetStateContext.js";
14
- import { applyDragDelta as te, applyResizeDelta as ie, getGridCellSize as ne, pixelDeltaToGridDelta as se, positionToGridArea as me, snapToGrid as ae } from "./utils/gridLayout.js";
15
- import { checkCollision as de, constrainPosition as fe, findFreePosition as le, hasCollision as ue } from "./utils/gridCollision.js";
16
- import { cn as ge } from "./utils/cn.js";
17
- import { createSimpleContext as Ce } from "./context/createSimpleContext.js";
18
- import { deferAfterPaint as ve, deferNonBlocking as Fe } from "./utils/defer.js";
19
- import { duration as Pe, easing as he, fadeIn as Ie, listContainer as Re, listItem as Te, panelResize as Se, popIn as be, scaleIn as ke, sidebarVariants as Be, slideInFromBottom as we, slideInFromLeft as We, slideInFromRight as Le, slideInFromTop as Ne, springConfig as Ae } from "./utils/animations.js";
20
- import { formatKeybind as ze, matchKeybind as Ke, parseKeybind as Oe } from "./utils/keybind.js";
21
- import { isTypingElement as Ve, shouldIgnoreHotkeys as _e } from "./utils/dom.js";
22
- import { lockBodyStyle as Me } from "./utils/bodyStyleLock.js";
23
- import { registerCommandContributions as Ue, useCommandContributions as je } from "./hooks/useCommandContributions.js";
24
- import { useDebounce as Je } from "./hooks/useDebounce.js";
25
- import { useDeckDrag as Ye } from "./hooks/useDeckDrag.js";
26
- import { useFileBrowserDropTarget as $e, useFileBrowserItemDrag as eo } from "./hooks/useFileBrowserDrag.js";
27
- import { useKeybind as ro } from "./hooks/useKeybind.js";
28
- import { useMediaQuery as io } from "./hooks/useMediaQuery.js";
29
- import { usePersisted as so } from "./hooks/usePersisted.js";
30
- import { useResizeObserver as ao } from "./hooks/useResizeObserver.js";
2
+ import { applyTheme as i, builtInThemes as n, getSystemTheme as s, resolveThemeTokenOverrides as m, syncThemeTokenOverrides as a } from "./styles/themes/index.js";
3
+ import { CommandProvider as d, createCommandService as f, useCommand as l } from "./context/CommandContext.js";
4
+ import { ComponentRegistryProvider as x, createComponentRegistry as g, hasComponentRegistryContext as c, useComponentContextFactory as C, useComponentRegistry as y, useOptionalComponentRegistry as v } from "./context/ComponentRegistry.js";
5
+ import { DEFAULT_FLOE_CONFIG as D, FloeConfigProvider as T, useFloeConfig as P, useResolvedFloeConfig as h } from "./context/FloeConfigContext.js";
6
+ import { DeckProvider as R, createDeckService as S, useDeck as b } from "./context/DeckContext.js";
7
+ import { FileBrowserDragProvider as B, hasFileBrowserDragContext as w, useFileBrowserDrag as W } from "./context/FileBrowserDragContext.js";
8
+ import { LayoutProvider as N, createLayoutService as O, useLayout as A } from "./context/LayoutContext.js";
9
+ import { NotificationContainer as z, NotificationProvider as K, createNotificationService as E, useNotification as V } from "./context/NotificationContext.js";
10
+ import { ThemeProvider as H, createThemeService as M, useTheme as Q } from "./context/ThemeContext.js";
11
+ import { ViewActivationProvider as j, useViewActivation as q } from "./context/ViewActivationContext.js";
12
+ import { WidgetRegistryProvider as X, createWidgetRegistry as Y, useWidgetRegistry as Z } from "./context/WidgetRegistry.js";
13
+ import { WidgetStateProvider as ee, useCurrentWidgetId as oe, useWidgetState as re, useWidgetStateContext as te } from "./context/WidgetStateContext.js";
14
+ import { applyDragDelta as ne, applyResizeDelta as se, getGridCellSize as me, pixelDeltaToGridDelta as ae, positionToGridArea as pe, snapToGrid as de } from "./utils/gridLayout.js";
15
+ import { checkCollision as le, constrainPosition as ue, findFreePosition as xe, hasCollision as ge } from "./utils/gridCollision.js";
16
+ import { cn as Ce } from "./utils/cn.js";
17
+ import { createSimpleContext as ve } from "./context/createSimpleContext.js";
18
+ import { deferAfterPaint as De, deferNonBlocking as Te } from "./utils/defer.js";
19
+ import { duration as he, easing as Ie, fadeIn as Re, listContainer as Se, listItem as be, panelResize as ke, popIn as Be, scaleIn as we, sidebarVariants as We, slideInFromBottom as Le, slideInFromLeft as Ne, slideInFromRight as Oe, slideInFromTop as Ae, springConfig as Ge } from "./utils/animations.js";
20
+ import { formatKeybind as Ke, matchKeybind as Ee, parseKeybind as Ve } from "./utils/keybind.js";
21
+ import { isTypingElement as He, shouldIgnoreHotkeys as Me } from "./utils/dom.js";
22
+ import { lockBodyStyle as Ue } from "./utils/bodyStyleLock.js";
23
+ import { registerCommandContributions as qe, useCommandContributions as Je } from "./hooks/useCommandContributions.js";
24
+ import { useDebounce as Ye } from "./hooks/useDebounce.js";
25
+ import { useDeckDrag as $e } from "./hooks/useDeckDrag.js";
26
+ import { useFileBrowserDropTarget as oo, useFileBrowserItemDrag as ro } from "./hooks/useFileBrowserDrag.js";
27
+ import { useKeybind as io } from "./hooks/useKeybind.js";
28
+ import { useMediaQuery as so } from "./hooks/useMediaQuery.js";
29
+ import { usePersisted as ao } from "./hooks/usePersisted.js";
30
+ import { useResizeObserver as fo } from "./hooks/useResizeObserver.js";
31
31
  export {
32
- a as CommandProvider,
33
- l as ComponentRegistryProvider,
34
- v as DEFAULT_FLOE_CONFIG,
35
- I as DeckProvider,
36
- b as FileBrowserDragProvider,
37
- F as FloeConfigProvider,
32
+ d as CommandProvider,
33
+ x as ComponentRegistryProvider,
34
+ D as DEFAULT_FLOE_CONFIG,
35
+ R as DeckProvider,
36
+ B as FileBrowserDragProvider,
37
+ T as FloeConfigProvider,
38
38
  r as FloeProvider,
39
- W as LayoutProvider,
40
- G as NotificationContainer,
41
- z as NotificationProvider,
42
- V as ThemeProvider,
43
- Q as ViewActivationProvider,
44
- q as WidgetRegistryProvider,
45
- Z as WidgetStateProvider,
46
- te as applyDragDelta,
47
- ie as applyResizeDelta,
39
+ N as LayoutProvider,
40
+ z as NotificationContainer,
41
+ K as NotificationProvider,
42
+ H as ThemeProvider,
43
+ j as ViewActivationProvider,
44
+ X as WidgetRegistryProvider,
45
+ ee as WidgetStateProvider,
46
+ ne as applyDragDelta,
47
+ se as applyResizeDelta,
48
48
  i as applyTheme,
49
49
  n as builtInThemes,
50
- de as checkCollision,
51
- ge as cn,
52
- fe as constrainPosition,
53
- p as createCommandService,
54
- u as createComponentRegistry,
55
- R as createDeckService,
56
- L as createLayoutService,
57
- K as createNotificationService,
58
- Ce as createSimpleContext,
59
- _ as createThemeService,
60
- J as createWidgetRegistry,
61
- ve as deferAfterPaint,
62
- Fe as deferNonBlocking,
63
- Pe as duration,
64
- he as easing,
65
- Ie as fadeIn,
66
- le as findFreePosition,
67
- ze as formatKeybind,
68
- ne as getGridCellSize,
50
+ le as checkCollision,
51
+ Ce as cn,
52
+ ue as constrainPosition,
53
+ f as createCommandService,
54
+ g as createComponentRegistry,
55
+ S as createDeckService,
56
+ O as createLayoutService,
57
+ E as createNotificationService,
58
+ ve as createSimpleContext,
59
+ M as createThemeService,
60
+ Y as createWidgetRegistry,
61
+ De as deferAfterPaint,
62
+ Te as deferNonBlocking,
63
+ he as duration,
64
+ Ie as easing,
65
+ Re as fadeIn,
66
+ xe as findFreePosition,
67
+ Ke as formatKeybind,
68
+ me as getGridCellSize,
69
69
  s as getSystemTheme,
70
- ue as hasCollision,
71
- x as hasComponentRegistryContext,
72
- k as hasFileBrowserDragContext,
73
- Ve as isTypingElement,
74
- Re as listContainer,
75
- Te as listItem,
76
- Me as lockBodyStyle,
77
- Ke as matchKeybind,
78
- Se as panelResize,
79
- Oe as parseKeybind,
80
- se as pixelDeltaToGridDelta,
81
- be as popIn,
82
- me as positionToGridArea,
83
- Ue as registerCommandContributions,
84
- ke as scaleIn,
85
- _e as shouldIgnoreHotkeys,
86
- Be as sidebarVariants,
87
- we as slideInFromBottom,
88
- We as slideInFromLeft,
89
- Le as slideInFromRight,
90
- Ne as slideInFromTop,
91
- ae as snapToGrid,
92
- Ae as springConfig,
93
- d as useCommand,
94
- je as useCommandContributions,
95
- g as useComponentContextFactory,
96
- c as useComponentRegistry,
97
- $ as useCurrentWidgetId,
98
- Je as useDebounce,
99
- T as useDeck,
100
- Ye as useDeckDrag,
101
- B as useFileBrowserDrag,
102
- $e as useFileBrowserDropTarget,
103
- eo as useFileBrowserItemDrag,
104
- D as useFloeConfig,
105
- ro as useKeybind,
106
- N as useLayout,
107
- io as useMediaQuery,
108
- O as useNotification,
109
- C as useOptionalComponentRegistry,
110
- so as usePersisted,
111
- ao as useResizeObserver,
112
- P as useResolvedFloeConfig,
113
- H as useTheme,
114
- U as useViewActivation,
115
- X as useWidgetRegistry,
116
- ee as useWidgetState,
117
- oe as useWidgetStateContext
70
+ ge as hasCollision,
71
+ c as hasComponentRegistryContext,
72
+ w as hasFileBrowserDragContext,
73
+ He as isTypingElement,
74
+ Se as listContainer,
75
+ be as listItem,
76
+ Ue as lockBodyStyle,
77
+ Ee as matchKeybind,
78
+ ke as panelResize,
79
+ Ve as parseKeybind,
80
+ ae as pixelDeltaToGridDelta,
81
+ Be as popIn,
82
+ pe as positionToGridArea,
83
+ qe as registerCommandContributions,
84
+ m as resolveThemeTokenOverrides,
85
+ we as scaleIn,
86
+ Me as shouldIgnoreHotkeys,
87
+ We as sidebarVariants,
88
+ Le as slideInFromBottom,
89
+ Ne as slideInFromLeft,
90
+ Oe as slideInFromRight,
91
+ Ae as slideInFromTop,
92
+ de as snapToGrid,
93
+ Ge as springConfig,
94
+ a as syncThemeTokenOverrides,
95
+ l as useCommand,
96
+ Je as useCommandContributions,
97
+ C as useComponentContextFactory,
98
+ y as useComponentRegistry,
99
+ oe as useCurrentWidgetId,
100
+ Ye as useDebounce,
101
+ b as useDeck,
102
+ $e as useDeckDrag,
103
+ W as useFileBrowserDrag,
104
+ oo as useFileBrowserDropTarget,
105
+ ro as useFileBrowserItemDrag,
106
+ P as useFloeConfig,
107
+ io as useKeybind,
108
+ A as useLayout,
109
+ so as useMediaQuery,
110
+ V as useNotification,
111
+ v as useOptionalComponentRegistry,
112
+ ao as usePersisted,
113
+ fo as useResizeObserver,
114
+ h as useResolvedFloeConfig,
115
+ Q as useTheme,
116
+ q as useViewActivation,
117
+ Z as useWidgetRegistry,
118
+ re as useWidgetState,
119
+ te as useWidgetStateContext
118
120
  };
@@ -1,4 +1,21 @@
1
1
  export type ThemeType = 'light' | 'dark' | 'system';
2
+ export type FloeThemeTokenMap = Partial<Record<`--${string}`, string>>;
3
+ export interface FloeThemeTokenOverrides {
4
+ shared?: FloeThemeTokenMap;
5
+ light?: FloeThemeTokenMap;
6
+ dark?: FloeThemeTokenMap;
7
+ }
8
+ export interface ThemeTarget {
9
+ classList: {
10
+ add: (...tokens: string[]) => void;
11
+ remove: (...tokens: string[]) => void;
12
+ };
13
+ style: {
14
+ colorScheme?: string;
15
+ setProperty: (property: string, value: string) => void;
16
+ removeProperty: (property: string) => void;
17
+ };
18
+ }
2
19
  export interface FloeTheme {
3
20
  name: string;
4
21
  displayName: string;
@@ -6,4 +23,6 @@ export interface FloeTheme {
6
23
  }
7
24
  export declare const builtInThemes: FloeTheme[];
8
25
  export declare function getSystemTheme(): 'light' | 'dark';
9
- export declare function applyTheme(theme: ThemeType): void;
26
+ export declare function resolveThemeTokenOverrides(tokens: FloeThemeTokenOverrides | undefined, resolvedTheme: 'light' | 'dark'): FloeThemeTokenMap;
27
+ export declare function applyTheme(theme: ThemeType, target?: ThemeTarget): void;
28
+ export declare function syncThemeTokenOverrides(tokens: FloeThemeTokenMap | undefined, previousTokenNames?: Iterable<string>, target?: ThemeTarget): string[];
@@ -2,16 +2,43 @@ const d = [
2
2
  { name: "light", displayName: "Light", type: "light" },
3
3
  { name: "dark", displayName: "Dark", type: "dark" }
4
4
  ];
5
- function o() {
5
+ function l() {
6
6
  return typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
7
7
  }
8
- function i(t) {
9
- if (typeof document > "u") return;
10
- const e = document.documentElement, n = t === "system" ? o() : t;
11
- e.classList.remove("light", "dark"), e.classList.add(n), e.style.colorScheme = n;
8
+ function c(e) {
9
+ if (e) return e;
10
+ if (!(typeof document > "u"))
11
+ return document.documentElement;
12
+ }
13
+ function m(e, o) {
14
+ return {
15
+ ...e?.shared ?? {},
16
+ ...o === "light" ? e?.light ?? {} : e?.dark ?? {}
17
+ };
18
+ }
19
+ function u(e, o) {
20
+ const r = c(o);
21
+ if (!r) return;
22
+ const n = e === "system" ? l() : e;
23
+ r.classList.remove("light", "dark"), r.classList.add(n), r.style.colorScheme = n;
24
+ }
25
+ function f(e, o = [], r) {
26
+ const n = c(r);
27
+ if (!n) return [];
28
+ const i = Object.entries(e ?? {}).filter((t) => {
29
+ const [, s] = t;
30
+ return typeof s == "string" && s.length > 0;
31
+ }), a = new Set(i.map(([t]) => t));
32
+ for (const t of o)
33
+ a.has(t) || n.style.removeProperty(t);
34
+ for (const [t, s] of i)
35
+ n.style.setProperty(t, s);
36
+ return [...a];
12
37
  }
13
38
  export {
14
- i as applyTheme,
39
+ u as applyTheme,
15
40
  d as builtInThemes,
16
- o as getSystemTheme
41
+ l as getSystemTheme,
42
+ m as resolveThemeTokenOverrides,
43
+ f as syncThemeTokenOverrides
17
44
  };