@almadar/ui 1.0.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.
- package/LICENSE +72 -0
- package/README.md +335 -0
- package/dist/ThemeContext-lI5bo85E.d.ts +103 -0
- package/dist/components/index.d.ts +4789 -0
- package/dist/components/index.js +21566 -0
- package/dist/components/index.js.map +1 -0
- package/dist/context/index.d.ts +208 -0
- package/dist/context/index.js +443 -0
- package/dist/context/index.js.map +1 -0
- package/dist/event-bus-types-8-cjyMxw.d.ts +65 -0
- package/dist/hooks/index.d.ts +1006 -0
- package/dist/hooks/index.js +2262 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/lib/index.d.ts +291 -0
- package/dist/lib/index.js +431 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/offline-executor-CHr4uAhf.d.ts +401 -0
- package/dist/providers/index.d.ts +386 -0
- package/dist/providers/index.js +1111 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/renderer/index.d.ts +382 -0
- package/dist/renderer/index.js +808 -0
- package/dist/renderer/index.js.map +1 -0
- package/dist/stores/index.d.ts +151 -0
- package/dist/stores/index.js +196 -0
- package/dist/stores/index.js.map +1 -0
- package/dist/useUISlots-mnggE9X9.d.ts +105 -0
- package/package.json +121 -0
- package/themes/almadar.css +196 -0
- package/themes/index.css +11 -0
- package/themes/minimalist.css +193 -0
- package/themes/wireframe.css +188 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import React__default, { ReactNode } from 'react';
|
|
2
|
+
import { b as ThemeDefinition } from '../ThemeContext-lI5bo85E.js';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { E as EventBusContextType } from '../event-bus-types-8-cjyMxw.js';
|
|
5
|
+
import { U as UseOfflineExecutorResult, a as UseOfflineExecutorOptions } from '../offline-executor-CHr4uAhf.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Extended context type for backward compatibility.
|
|
9
|
+
*
|
|
10
|
+
* @deprecated getSelectedEntity and clearSelectedEntity are deprecated.
|
|
11
|
+
* Use SelectionProvider and useSelection hook instead.
|
|
12
|
+
*/
|
|
13
|
+
interface EventBusContextTypeExtended extends EventBusContextType {
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use useSelection from SelectionProvider instead.
|
|
16
|
+
* This method now returns null - selection state moved to SelectionProvider.
|
|
17
|
+
*/
|
|
18
|
+
getSelectedEntity: () => unknown | null;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use useSelection from SelectionProvider instead.
|
|
21
|
+
* This method is now a no-op - selection state moved to SelectionProvider.
|
|
22
|
+
*/
|
|
23
|
+
clearSelectedEntity: () => void;
|
|
24
|
+
}
|
|
25
|
+
declare const EventBusContext: React__default.Context<EventBusContextTypeExtended | null>;
|
|
26
|
+
interface EventBusProviderProps {
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
/** Enable debug logging in development */
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Provider component for the page event bus.
|
|
33
|
+
*
|
|
34
|
+
* This is a pure pub/sub event bus. For selection state,
|
|
35
|
+
* use SelectionProvider which listens to events and maintains state.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* function TaskDetailPage() {
|
|
40
|
+
* return (
|
|
41
|
+
* <EventBusProvider debug={process.env.NODE_ENV === 'development'}>
|
|
42
|
+
* <SelectionProvider>
|
|
43
|
+
* <TaskHeader />
|
|
44
|
+
* <TaskForm />
|
|
45
|
+
* <TaskActions />
|
|
46
|
+
* </SelectionProvider>
|
|
47
|
+
* </EventBusProvider>
|
|
48
|
+
* );
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function EventBusProvider({ children, debug }: EventBusProviderProps): react_jsx_runtime.JSX.Element;
|
|
53
|
+
|
|
54
|
+
interface SelectionContextType<T = unknown> {
|
|
55
|
+
/** The currently selected entity */
|
|
56
|
+
selected: T | null;
|
|
57
|
+
/** Manually set the selected entity */
|
|
58
|
+
setSelected: (entity: T | null) => void;
|
|
59
|
+
/** Clear the selection */
|
|
60
|
+
clearSelection: () => void;
|
|
61
|
+
/** Check if an entity is selected */
|
|
62
|
+
isSelected: (entity: T) => boolean;
|
|
63
|
+
}
|
|
64
|
+
declare const SelectionContext: React__default.Context<SelectionContextType<unknown> | null>;
|
|
65
|
+
interface SelectionProviderProps {
|
|
66
|
+
children: ReactNode;
|
|
67
|
+
/** Enable debug logging */
|
|
68
|
+
debug?: boolean;
|
|
69
|
+
/** Custom comparison function for isSelected */
|
|
70
|
+
compareEntities?: (a: unknown, b: unknown) => boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Provider component for selection state.
|
|
74
|
+
*
|
|
75
|
+
* Must be used within an EventBusProvider.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* function OrderListPage() {
|
|
80
|
+
* return (
|
|
81
|
+
* <EventBusProvider>
|
|
82
|
+
* <SelectionProvider debug={process.env.NODE_ENV === 'development'}>
|
|
83
|
+
* <OrderTable />
|
|
84
|
+
* <OrderDetailDrawer />
|
|
85
|
+
* </SelectionProvider>
|
|
86
|
+
* </EventBusProvider>
|
|
87
|
+
* );
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare function SelectionProvider({ children, debug, compareEntities, }: SelectionProviderProps): react_jsx_runtime.JSX.Element;
|
|
92
|
+
/**
|
|
93
|
+
* Hook to access selection state.
|
|
94
|
+
*
|
|
95
|
+
* @throws Error if used outside SelectionProvider
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```tsx
|
|
99
|
+
* function OrderDetailDrawer() {
|
|
100
|
+
* const { selected, clearSelection } = useSelection<Order>();
|
|
101
|
+
*
|
|
102
|
+
* if (!selected) return null;
|
|
103
|
+
*
|
|
104
|
+
* return (
|
|
105
|
+
* <Drawer onClose={clearSelection}>
|
|
106
|
+
* <OrderDetail order={selected} />
|
|
107
|
+
* </Drawer>
|
|
108
|
+
* );
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
declare function useSelection<T = unknown>(): SelectionContextType<T>;
|
|
113
|
+
/**
|
|
114
|
+
* Hook to access selection state with fallback for components
|
|
115
|
+
* that may be used outside SelectionProvider.
|
|
116
|
+
*
|
|
117
|
+
* Returns null if no SelectionProvider is found.
|
|
118
|
+
*/
|
|
119
|
+
declare function useSelectionOptional<T = unknown>(): SelectionContextType<T> | null;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* FetchedDataProvider
|
|
123
|
+
*
|
|
124
|
+
* Provides server-fetched entity data to the client runtime.
|
|
125
|
+
* This context stores data returned from compiled event handlers
|
|
126
|
+
* via the `data` field in EventResponse.
|
|
127
|
+
*
|
|
128
|
+
* Data Flow:
|
|
129
|
+
* 1. Client sends event to server
|
|
130
|
+
* 2. Server executes compiled handler with fetch effects
|
|
131
|
+
* 3. Server returns { data: { EntityName: [...records] }, clientEffects: [...] }
|
|
132
|
+
* 4. Provider stores data in this context
|
|
133
|
+
* 5. Pattern components access data via useFetchedData hook
|
|
134
|
+
*
|
|
135
|
+
* Used by both Builder preview and compiled shell.
|
|
136
|
+
*
|
|
137
|
+
* @packageDocumentation
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
interface EntityRecord {
|
|
141
|
+
id: string;
|
|
142
|
+
[key: string]: unknown;
|
|
143
|
+
}
|
|
144
|
+
interface FetchedDataState {
|
|
145
|
+
/** Entity data by entity name (e.g., { Task: [...], User: [...] }) */
|
|
146
|
+
data: Record<string, EntityRecord[]>;
|
|
147
|
+
/** Timestamp of last fetch per entity */
|
|
148
|
+
fetchedAt: Record<string, number>;
|
|
149
|
+
/** Whether data is currently being fetched */
|
|
150
|
+
loading: boolean;
|
|
151
|
+
/** Last error message */
|
|
152
|
+
error: string | null;
|
|
153
|
+
}
|
|
154
|
+
interface FetchedDataContextValue {
|
|
155
|
+
/** Get all records for an entity */
|
|
156
|
+
getData: (entityName: string) => EntityRecord[];
|
|
157
|
+
/** Get a single record by ID */
|
|
158
|
+
getById: (entityName: string, id: string) => EntityRecord | undefined;
|
|
159
|
+
/** Check if entity data exists */
|
|
160
|
+
hasData: (entityName: string) => boolean;
|
|
161
|
+
/** Get fetch timestamp for entity */
|
|
162
|
+
getFetchedAt: (entityName: string) => number | undefined;
|
|
163
|
+
/** Update data from server response */
|
|
164
|
+
setData: (data: Record<string, unknown[]>) => void;
|
|
165
|
+
/** Clear all fetched data */
|
|
166
|
+
clearData: () => void;
|
|
167
|
+
/** Clear data for specific entity */
|
|
168
|
+
clearEntity: (entityName: string) => void;
|
|
169
|
+
/** Current loading state */
|
|
170
|
+
loading: boolean;
|
|
171
|
+
/** Set loading state */
|
|
172
|
+
setLoading: (loading: boolean) => void;
|
|
173
|
+
/** Current error */
|
|
174
|
+
error: string | null;
|
|
175
|
+
/** Set error */
|
|
176
|
+
setError: (error: string | null) => void;
|
|
177
|
+
}
|
|
178
|
+
declare const FetchedDataContext: React__default.Context<FetchedDataContextValue | null>;
|
|
179
|
+
interface FetchedDataProviderProps {
|
|
180
|
+
/** Initial data (optional) */
|
|
181
|
+
initialData?: Record<string, unknown[]>;
|
|
182
|
+
/** Children */
|
|
183
|
+
children: React__default.ReactNode;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* FetchedDataProvider - Provides server-fetched entity data
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```tsx
|
|
190
|
+
* <FetchedDataProvider>
|
|
191
|
+
* <OrbitalProvider>
|
|
192
|
+
* <App />
|
|
193
|
+
* </OrbitalProvider>
|
|
194
|
+
* </FetchedDataProvider>
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
declare function FetchedDataProvider({ initialData, children, }: FetchedDataProviderProps): React__default.ReactElement;
|
|
198
|
+
/**
|
|
199
|
+
* Access the fetched data context.
|
|
200
|
+
* Returns null if not within a FetchedDataProvider.
|
|
201
|
+
*/
|
|
202
|
+
declare function useFetchedDataContext(): FetchedDataContextValue | null;
|
|
203
|
+
/**
|
|
204
|
+
* Access fetched data with fallback behavior.
|
|
205
|
+
* If not in a provider, returns empty data.
|
|
206
|
+
*/
|
|
207
|
+
declare function useFetchedData(): FetchedDataContextValue;
|
|
208
|
+
/**
|
|
209
|
+
* Access fetched data for a specific entity.
|
|
210
|
+
* Provides a convenient API for entity-specific operations.
|
|
211
|
+
*/
|
|
212
|
+
declare function useFetchedEntity(entityName: string): {
|
|
213
|
+
/** All fetched records for this entity */
|
|
214
|
+
records: EntityRecord[];
|
|
215
|
+
/** Get a record by ID */
|
|
216
|
+
getById: (id: string) => EntityRecord | undefined;
|
|
217
|
+
/** Whether data has been fetched for this entity */
|
|
218
|
+
hasData: boolean;
|
|
219
|
+
/** When data was last fetched */
|
|
220
|
+
fetchedAt: number | undefined;
|
|
221
|
+
/** Whether data is loading */
|
|
222
|
+
loading: boolean;
|
|
223
|
+
/** Current error */
|
|
224
|
+
error: string | null;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* OrbitalProvider
|
|
229
|
+
*
|
|
230
|
+
* Unified provider that combines all required contexts for Orbital applications.
|
|
231
|
+
* Provides a single import for both Builder preview and compiled shell.
|
|
232
|
+
*
|
|
233
|
+
* Combines:
|
|
234
|
+
* - ThemeProvider - Theme and color mode management
|
|
235
|
+
* - EventBusProvider - Page-scoped event pub/sub
|
|
236
|
+
* - UISlotProvider - UI slot management for render_ui effects
|
|
237
|
+
* - SelectionProvider - Selected entity tracking
|
|
238
|
+
* - FetchedDataProvider - Server-fetched entity data
|
|
239
|
+
*
|
|
240
|
+
* @packageDocumentation
|
|
241
|
+
*/
|
|
242
|
+
|
|
243
|
+
interface OrbitalProviderProps {
|
|
244
|
+
children: ReactNode;
|
|
245
|
+
/** Custom themes (merged with built-in themes) */
|
|
246
|
+
themes?: ThemeDefinition[];
|
|
247
|
+
/** Default theme name */
|
|
248
|
+
defaultTheme?: string;
|
|
249
|
+
/** Default color mode */
|
|
250
|
+
defaultMode?: 'light' | 'dark' | 'system';
|
|
251
|
+
/** Enable debug logging for all providers */
|
|
252
|
+
debug?: boolean;
|
|
253
|
+
/** Initial fetched data */
|
|
254
|
+
initialData?: Record<string, unknown[]>;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* OrbitalProvider - Unified context provider for Orbital applications
|
|
258
|
+
*
|
|
259
|
+
* Wraps your application with all required providers in the correct order.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```tsx
|
|
263
|
+
* // Basic usage
|
|
264
|
+
* function App() {
|
|
265
|
+
* return (
|
|
266
|
+
* <OrbitalProvider>
|
|
267
|
+
* <Router>
|
|
268
|
+
* <Routes />
|
|
269
|
+
* </Router>
|
|
270
|
+
* </OrbitalProvider>
|
|
271
|
+
* );
|
|
272
|
+
* }
|
|
273
|
+
*
|
|
274
|
+
* // With configuration
|
|
275
|
+
* function App() {
|
|
276
|
+
* return (
|
|
277
|
+
* <OrbitalProvider
|
|
278
|
+
* defaultTheme="minimalist"
|
|
279
|
+
* defaultMode="dark"
|
|
280
|
+
* debug={process.env.NODE_ENV === 'development'}
|
|
281
|
+
* >
|
|
282
|
+
* <Router>
|
|
283
|
+
* <Routes />
|
|
284
|
+
* </Router>
|
|
285
|
+
* </OrbitalProvider>
|
|
286
|
+
* );
|
|
287
|
+
* }
|
|
288
|
+
*
|
|
289
|
+
* // With custom themes from schema
|
|
290
|
+
* import { THEMES } from './generated/theme-manifest';
|
|
291
|
+
*
|
|
292
|
+
* function App() {
|
|
293
|
+
* return (
|
|
294
|
+
* <OrbitalProvider themes={THEMES} defaultTheme="ocean">
|
|
295
|
+
* <Router>
|
|
296
|
+
* <Routes />
|
|
297
|
+
* </Router>
|
|
298
|
+
* </OrbitalProvider>
|
|
299
|
+
* );
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
declare function OrbitalProvider({ children, themes, defaultTheme, defaultMode, debug, initialData, }: OrbitalProviderProps): React__default.ReactElement;
|
|
304
|
+
declare namespace OrbitalProvider {
|
|
305
|
+
var displayName: string;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* OfflineModeProvider
|
|
310
|
+
*
|
|
311
|
+
* Context provider that wraps useOfflineExecutor with force-offline toggle support.
|
|
312
|
+
* Enables testing offline behavior without actually disconnecting.
|
|
313
|
+
*
|
|
314
|
+
* @packageDocumentation
|
|
315
|
+
*/
|
|
316
|
+
|
|
317
|
+
interface OfflineModeContextValue extends UseOfflineExecutorResult {
|
|
318
|
+
/** Force offline mode for testing */
|
|
319
|
+
forceOffline: boolean;
|
|
320
|
+
/** Toggle force offline mode */
|
|
321
|
+
setForceOffline: (value: boolean) => void;
|
|
322
|
+
/** Whether effectively offline (real or forced) */
|
|
323
|
+
effectivelyOffline: boolean;
|
|
324
|
+
}
|
|
325
|
+
interface OfflineModeProviderProps extends UseOfflineExecutorOptions {
|
|
326
|
+
children: React__default.ReactNode;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* OfflineModeProvider - Wraps offline executor with force-offline support.
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* ```tsx
|
|
333
|
+
* function App() {
|
|
334
|
+
* return (
|
|
335
|
+
* <OfflineModeProvider
|
|
336
|
+
* serverUrl="/api/orbitals"
|
|
337
|
+
* authToken={token}
|
|
338
|
+
* autoSync={true}
|
|
339
|
+
* renderToSlot={slotManager.render}
|
|
340
|
+
* navigate={router.push}
|
|
341
|
+
* notify={toast.show}
|
|
342
|
+
* eventBus={{ emit: bus.emit }}
|
|
343
|
+
* >
|
|
344
|
+
* <PreviewPage />
|
|
345
|
+
* </OfflineModeProvider>
|
|
346
|
+
* );
|
|
347
|
+
* }
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
declare function OfflineModeProvider({ children, ...executorOptions }: OfflineModeProviderProps): React__default.ReactElement;
|
|
351
|
+
/**
|
|
352
|
+
* Access offline mode context.
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* ```tsx
|
|
356
|
+
* function OfflineToggle() {
|
|
357
|
+
* const {
|
|
358
|
+
* effectivelyOffline,
|
|
359
|
+
* forceOffline,
|
|
360
|
+
* setForceOffline,
|
|
361
|
+
* pendingCount,
|
|
362
|
+
* sync,
|
|
363
|
+
* } = useOfflineMode();
|
|
364
|
+
*
|
|
365
|
+
* return (
|
|
366
|
+
* <div>
|
|
367
|
+
* <Toggle
|
|
368
|
+
* checked={forceOffline}
|
|
369
|
+
* onChange={setForceOffline}
|
|
370
|
+
* >
|
|
371
|
+
* Test Offline
|
|
372
|
+
* </Toggle>
|
|
373
|
+
* {pendingCount > 0 && <Badge>{pendingCount} pending</Badge>}
|
|
374
|
+
* <Button onClick={sync}>Sync Now</Button>
|
|
375
|
+
* </div>
|
|
376
|
+
* );
|
|
377
|
+
* }
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
declare function useOfflineMode(): OfflineModeContextValue;
|
|
381
|
+
/**
|
|
382
|
+
* Check if offline mode provider is available (optional usage).
|
|
383
|
+
*/
|
|
384
|
+
declare function useOptionalOfflineMode(): OfflineModeContextValue | null;
|
|
385
|
+
|
|
386
|
+
export { type EntityRecord, EventBusContext, EventBusProvider, FetchedDataContext, type FetchedDataContextValue, FetchedDataProvider, type FetchedDataProviderProps, type FetchedDataState, type OfflineModeContextValue, OfflineModeProvider, type OfflineModeProviderProps, OrbitalProvider, type OrbitalProviderProps, SelectionContext, type SelectionContextType, SelectionProvider, useFetchedData, useFetchedDataContext, useFetchedEntity, useOfflineMode, useOptionalOfflineMode, useSelection, useSelectionOptional };
|