@floegence/floe-webapp-core 0.36.74 → 0.36.75

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,6 +1,6 @@
1
1
  import { FloeProvider as r } from "./app/FloeProvider.js";
2
2
  import { applyTheme as i, builtInThemes as s, getSystemTheme as n, mergeThemeTokenMaps as a, resolveThemeTokenOverrides as m, resolveThemeTokens as p, syncThemeTokenOverrides as l } from "./styles/themes/index.js";
3
- import { floeColorTokenCategories as d, floeDesignTokens as g, floeFontFamilyTokens as T, floeMotionTokens as u, floeRadiusTokens as x, floeSharedCssVariables as c, floeSpacingTokens as C, floeThemeColorVariables as y, floeTypographyTokens as v, getFloeColorTokenValue as F } from "./styles/tokens.js";
3
+ import { floeColorTokenCategories as d, floeDesignTokens as g, floeFontFamilyTokens as c, floeMotionTokens as x, floeRadiusTokens as T, floeSharedCssVariables as u, floeSpacingTokens as C, floeThemeColorVariables as y, floeTypographyTokens as v, getFloeColorTokenValue as F } from "./styles/tokens.js";
4
4
  import { CommandProvider as h, createCommandService as P, useCommand as R } from "./context/CommandContext.js";
5
5
  import { ComponentRegistryProvider as I, createComponentRegistry as S, hasComponentRegistryContext as b, useComponentContextFactory as O, useComponentRegistry as A, useOptionalComponentRegistry as E } from "./context/ComponentRegistry.js";
6
6
  import { DEFAULT_FLOE_CONFIG as B, FloeConfigProvider as N, useFloeConfig as _, useResolvedFloeConfig as w } from "./context/FloeConfigContext.js";
@@ -11,25 +11,26 @@ import { LayoutProvider as X, createLayoutService as Z, useLayout as $ } from ".
11
11
  import { NotificationContainer as oe, NotificationProvider as re, createNotificationService as te, useNotification as ie } from "./context/NotificationContext.js";
12
12
  import { ThemeProvider as ne, createThemeService as ae, useTheme as me } from "./context/ThemeContext.js";
13
13
  import { ViewActivationProvider as le, useViewActivation as fe } from "./context/ViewActivationContext.js";
14
- import { WidgetRegistryProvider as ge, createWidgetRegistry as Te, useWidgetRegistry as ue } from "./context/WidgetRegistry.js";
15
- import { WidgetStateProvider as ce, useCurrentWidgetId as Ce, useWidgetState as ye, useWidgetStateContext as ve } from "./context/WidgetStateContext.js";
14
+ import { WidgetRegistryProvider as ge, createWidgetRegistry as ce, useWidgetRegistry as xe } from "./context/WidgetRegistry.js";
15
+ import { WidgetStateProvider as ue, useCurrentWidgetId as Ce, useWidgetState as ye, useWidgetStateContext as ve } from "./context/WidgetStateContext.js";
16
16
  import { applyDragDelta as ke, applyResizeDelta as he, getGridCellSize as Pe, pixelDeltaToGridDelta as Re, positionToGridArea as De, snapToGrid as Ie } from "./utils/gridLayout.js";
17
17
  import { checkCollision as be, constrainPosition as Oe, findFreePosition as Ae, hasCollision as Ee, sameGridPosition as Le } from "./utils/gridCollision.js";
18
18
  import { cn as Ne } from "./utils/cn.js";
19
19
  import { createSimpleContext as we } from "./context/createSimpleContext.js";
20
- import { deferAfterPaint as We, deferNonBlocking as Me } from "./utils/defer.js";
21
- import { duration as Ke, easing as ze, fadeIn as He, listContainer as Ue, listItem as Qe, panelResize as Ye, popIn as je, scaleIn as qe, sidebarVariants as Je, slideInFromBottom as Xe, slideInFromLeft as Ze, slideInFromRight as $e, slideInFromTop as eo, springConfig as oo } from "./utils/animations.js";
22
- import { formatKeybind as to, isMacLikePlatform as io, isPrimaryModKeyPressed as so, matchKeybind as no, parseKeybind as ao } from "./utils/keybind.js";
23
- import { isTypingElement as po, shouldIgnoreHotkeys as lo } from "./utils/dom.js";
24
- import { lockBodyStyle as go } from "./utils/bodyStyleLock.js";
25
- import { registerCommandContributions as uo, useCommandContributions as xo } from "./hooks/useCommandContributions.js";
26
- import { useDebounce as Co } from "./hooks/useDebounce.js";
27
- import { useDeckDrag as vo } from "./hooks/useDeckDrag.js";
28
- import { useFileBrowserDropTarget as ko, useFileBrowserItemDrag as ho } from "./hooks/useFileBrowserDrag.js";
29
- import { useKeybind as Ro } from "./hooks/useKeybind.js";
30
- import { useMediaQuery as Io } from "./hooks/useMediaQuery.js";
31
- import { usePersisted as bo } from "./hooks/usePersisted.js";
32
- import { useResizeObserver as Ao } from "./hooks/useResizeObserver.js";
20
+ import { createUIFirstSelection as We } from "./utils/uiFirstSelection.js";
21
+ import { deferAfterPaint as Ve, deferNonBlocking as Ke } from "./utils/defer.js";
22
+ import { duration as He, easing as Ue, fadeIn as Qe, listContainer as Ye, listItem as je, panelResize as qe, popIn as Je, scaleIn as Xe, sidebarVariants as Ze, slideInFromBottom as $e, slideInFromLeft as eo, slideInFromRight as oo, slideInFromTop as ro, springConfig as to } from "./utils/animations.js";
23
+ import { formatKeybind as so, isMacLikePlatform as no, isPrimaryModKeyPressed as ao, matchKeybind as mo, parseKeybind as po } from "./utils/keybind.js";
24
+ import { isTypingElement as fo, shouldIgnoreHotkeys as go } from "./utils/dom.js";
25
+ import { lockBodyStyle as xo } from "./utils/bodyStyleLock.js";
26
+ import { registerCommandContributions as uo, useCommandContributions as Co } from "./hooks/useCommandContributions.js";
27
+ import { useDebounce as vo } from "./hooks/useDebounce.js";
28
+ import { useDeckDrag as ko } from "./hooks/useDeckDrag.js";
29
+ import { useFileBrowserDropTarget as Po, useFileBrowserItemDrag as Ro } from "./hooks/useFileBrowserDrag.js";
30
+ import { useKeybind as Io } from "./hooks/useKeybind.js";
31
+ import { useMediaQuery as bo } from "./hooks/useMediaQuery.js";
32
+ import { usePersisted as Ao } from "./hooks/usePersisted.js";
33
+ import { useResizeObserver as Lo } from "./hooks/useResizeObserver.js";
33
34
  export {
34
35
  h as CommandProvider,
35
36
  I as ComponentRegistryProvider,
@@ -46,7 +47,7 @@ export {
46
47
  ne as ThemeProvider,
47
48
  le as ViewActivationProvider,
48
49
  ge as WidgetRegistryProvider,
49
- ce as WidgetStateProvider,
50
+ ue as WidgetStateProvider,
50
51
  ke as applyDragDelta,
51
52
  he as applyResizeDelta,
52
53
  i as applyTheme,
@@ -61,80 +62,81 @@ export {
61
62
  te as createNotificationService,
62
63
  we as createSimpleContext,
63
64
  ae as createThemeService,
64
- Te as createWidgetRegistry,
65
- We as deferAfterPaint,
66
- Me as deferNonBlocking,
67
- Ke as duration,
68
- ze as easing,
69
- He as fadeIn,
65
+ We as createUIFirstSelection,
66
+ ce as createWidgetRegistry,
67
+ Ve as deferAfterPaint,
68
+ Ke as deferNonBlocking,
69
+ He as duration,
70
+ Ue as easing,
71
+ Qe as fadeIn,
70
72
  Ae as findFreePosition,
71
73
  d as floeColorTokenCategories,
72
74
  g as floeDesignTokens,
73
- T as floeFontFamilyTokens,
74
- u as floeMotionTokens,
75
- x as floeRadiusTokens,
76
- c as floeSharedCssVariables,
75
+ c as floeFontFamilyTokens,
76
+ x as floeMotionTokens,
77
+ T as floeRadiusTokens,
78
+ u as floeSharedCssVariables,
77
79
  C as floeSpacingTokens,
78
80
  y as floeThemeColorVariables,
79
81
  v as floeTypographyTokens,
80
- to as formatKeybind,
82
+ so as formatKeybind,
81
83
  F as getFloeColorTokenValue,
82
84
  Pe as getGridCellSize,
83
85
  n as getSystemTheme,
84
86
  Ee as hasCollision,
85
87
  b as hasComponentRegistryContext,
86
88
  j as hasFileBrowserDragContext,
87
- io as isMacLikePlatform,
88
- so as isPrimaryModKeyPressed,
89
- po as isTypingElement,
90
- Ue as listContainer,
91
- Qe as listItem,
92
- go as lockBodyStyle,
93
- no as matchKeybind,
89
+ no as isMacLikePlatform,
90
+ ao as isPrimaryModKeyPressed,
91
+ fo as isTypingElement,
92
+ Ye as listContainer,
93
+ je as listItem,
94
+ xo as lockBodyStyle,
95
+ mo as matchKeybind,
94
96
  a as mergeThemeTokenMaps,
95
- Ye as panelResize,
96
- ao as parseKeybind,
97
+ qe as panelResize,
98
+ po as parseKeybind,
97
99
  Re as pixelDeltaToGridDelta,
98
- je as popIn,
100
+ Je as popIn,
99
101
  De as positionToGridArea,
100
102
  uo as registerCommandContributions,
101
103
  m as resolveThemeTokenOverrides,
102
104
  p as resolveThemeTokens,
103
105
  Le as sameGridPosition,
104
- qe as scaleIn,
105
- lo as shouldIgnoreHotkeys,
106
- Je as sidebarVariants,
107
- Xe as slideInFromBottom,
108
- Ze as slideInFromLeft,
109
- $e as slideInFromRight,
110
- eo as slideInFromTop,
106
+ Xe as scaleIn,
107
+ go as shouldIgnoreHotkeys,
108
+ Ze as sidebarVariants,
109
+ $e as slideInFromBottom,
110
+ eo as slideInFromLeft,
111
+ oo as slideInFromRight,
112
+ ro as slideInFromTop,
111
113
  Ie as snapToGrid,
112
- oo as springConfig,
114
+ to as springConfig,
113
115
  U as startHotInteraction,
114
116
  l as syncThemeTokenOverrides,
115
117
  R as useCommand,
116
- xo as useCommandContributions,
118
+ Co as useCommandContributions,
117
119
  O as useComponentContextFactory,
118
120
  A as useComponentRegistry,
119
121
  Ce as useCurrentWidgetId,
120
- Co as useDebounce,
122
+ vo as useDebounce,
121
123
  V as useDeck,
122
- vo as useDeckDrag,
124
+ ko as useDeckDrag,
123
125
  q as useFileBrowserDrag,
124
- ko as useFileBrowserDropTarget,
125
- ho as useFileBrowserItemDrag,
126
+ Po as useFileBrowserDropTarget,
127
+ Ro as useFileBrowserItemDrag,
126
128
  _ as useFloeConfig,
127
- Ro as useKeybind,
129
+ Io as useKeybind,
128
130
  $ as useLayout,
129
- Io as useMediaQuery,
131
+ bo as useMediaQuery,
130
132
  ie as useNotification,
131
133
  E as useOptionalComponentRegistry,
132
- bo as usePersisted,
133
- Ao as useResizeObserver,
134
+ Ao as usePersisted,
135
+ Lo as useResizeObserver,
134
136
  w as useResolvedFloeConfig,
135
137
  me as useTheme,
136
138
  fe as useViewActivation,
137
- ue as useWidgetRegistry,
139
+ xe as useWidgetRegistry,
138
140
  ye as useWidgetState,
139
141
  ve as useWidgetStateContext
140
142
  };
@@ -7,3 +7,4 @@ export * from './dom';
7
7
  export * from './gridCollision';
8
8
  export * from './gridLayout';
9
9
  export * from './hotInteraction';
10
+ export * from './uiFirstSelection';
@@ -0,0 +1,29 @@
1
+ import { type Accessor } from 'solid-js';
2
+ export type UIFirstSelectionPhase = 'requested' | 'intent_presented' | 'commit_started' | 'committed' | 'content_presented' | 'cancelled';
3
+ export interface UIFirstSelectionEvent<T, M = undefined> {
4
+ phase: UIFirstSelectionPhase;
5
+ value: T;
6
+ metadata: M | undefined;
7
+ transactionId: number;
8
+ startedAt: number;
9
+ timestamp: number;
10
+ elapsedMs: number;
11
+ }
12
+ export interface CreateUIFirstSelectionOptions<T, M = undefined> {
13
+ committed: Accessor<T>;
14
+ commit: (value: T, metadata: M | undefined) => void;
15
+ equals?: (left: T, right: T) => boolean;
16
+ onEvent?: (event: UIFirstSelectionEvent<T, M>) => void;
17
+ scheduleAfterPaint?: (callback: () => void) => void;
18
+ }
19
+ export interface UIFirstSelectionController<T, M = undefined> {
20
+ visual: Accessor<T>;
21
+ committed: Accessor<T>;
22
+ pending: Accessor<boolean>;
23
+ preview: (value: T) => void;
24
+ resetPreview: () => void;
25
+ request: (value: T, metadata?: M) => void;
26
+ commitNow: (value: T, metadata?: M) => void;
27
+ cancel: () => void;
28
+ }
29
+ export declare function createUIFirstSelection<T, M = undefined>(options: CreateUIFirstSelectionOptions<T, M>): UIFirstSelectionController<T, M>;
@@ -0,0 +1,66 @@
1
+ import { createSignal as w, untrack as q, createEffect as h, onCleanup as x } from "solid-js";
2
+ import { deferAfterPaint as I } from "./defer.js";
3
+ function g() {
4
+ return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
5
+ }
6
+ function E(n) {
7
+ const f = n.equals ?? Object.is, o = n.scheduleAfterPaint ?? I, [v, i] = w(q(n.committed), { equals: f }), [A, d] = w(!1);
8
+ let r = null, u = 1, c = !1, m = !1;
9
+ const s = (e, t) => {
10
+ const a = g();
11
+ n.onEvent?.({
12
+ phase: e,
13
+ value: t.value,
14
+ metadata: t.metadata,
15
+ transactionId: t.id,
16
+ startedAt: t.startedAt,
17
+ timestamp: a,
18
+ elapsedMs: Math.max(0, a - t.startedAt)
19
+ });
20
+ }, l = (e) => {
21
+ const t = r;
22
+ r = null, m = !1, d(!1), t && s("cancelled", t), e && !c && i(() => n.committed());
23
+ }, P = (e, t) => {
24
+ if (c) return;
25
+ if (r && l(!1), m = !1, i(() => e), f(e, n.committed())) {
26
+ d(!1);
27
+ return;
28
+ }
29
+ const a = {
30
+ id: u,
31
+ value: e,
32
+ metadata: t,
33
+ startedAt: g(),
34
+ committing: !1
35
+ };
36
+ u += 1, r = a, d(!0), s("requested", a), o(() => {
37
+ c || r !== a || (s("intent_presented", a), s("commit_started", a), a.committing = !0, n.commit(a.value, a.metadata), a.committing = !1, !(c || r !== a) && (s("committed", a), o(() => {
38
+ c || r !== a || (s("content_presented", a), r = null, d(!1), i(() => n.committed()));
39
+ })));
40
+ });
41
+ }, p = (e, t) => {
42
+ c || (l(!1), m = !1, i(() => e), f(e, n.committed()) || n.commit(e, t), i(() => n.committed()));
43
+ };
44
+ return h(() => {
45
+ const e = n.committed(), t = r;
46
+ t && t.committing && f(e, t.value) || (t && !f(e, t.value) && l(!1), (!r || !f(e, r.value)) && (m = !1, i(() => e)));
47
+ }), x(() => {
48
+ c = !0, l(!1);
49
+ }), {
50
+ visual: v,
51
+ committed: n.committed,
52
+ pending: A,
53
+ preview: (e) => {
54
+ c || r || (m = !0, i(() => e));
55
+ },
56
+ resetPreview: () => {
57
+ c || !m || r || (m = !1, i(() => n.committed()));
58
+ },
59
+ request: P,
60
+ commitNow: p,
61
+ cancel: () => l(!0)
62
+ };
63
+ }
64
+ export {
65
+ E as createUIFirstSelection
66
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.36.74",
3
+ "version": "0.36.75",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",