@almadar/ui 2.0.4 → 2.1.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.
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Valid UI slot names
3
+ */
4
+ type UISlot = 'main' | 'sidebar' | 'modal' | 'drawer' | 'overlay' | 'center' | 'toast' | 'hud-top' | 'hud-bottom' | 'floating';
5
+ /**
6
+ * Animation types for slot transitions
7
+ */
8
+ type SlotAnimation = 'fade' | 'slide' | 'scale' | 'none';
9
+ /**
10
+ * Content rendered in a slot
11
+ */
12
+ interface SlotContent {
13
+ /** Unique ID for this content */
14
+ id: string;
15
+ /** Pattern/component type to render */
16
+ pattern: string;
17
+ /** Props to pass to the pattern component */
18
+ props: Record<string, unknown>;
19
+ /** Priority for conflict resolution (higher wins) */
20
+ priority: number;
21
+ /** Animation for showing/hiding */
22
+ animation?: SlotAnimation;
23
+ /** Auto-dismiss timestamp (for toasts) */
24
+ autoDismissAt?: number;
25
+ /** Callback when dismissed */
26
+ onDismiss?: () => void;
27
+ /** Source trait that rendered this content */
28
+ sourceTrait?: string;
29
+ }
30
+ /**
31
+ * Configuration for render_ui effect
32
+ */
33
+ interface RenderUIConfig {
34
+ /** Target slot */
35
+ target: UISlot;
36
+ /** Pattern/component to render */
37
+ pattern: string;
38
+ /** Props for the pattern */
39
+ props?: Record<string, unknown>;
40
+ /** Priority (default: 0) */
41
+ priority?: number;
42
+ /** Animation type */
43
+ animation?: SlotAnimation;
44
+ /** Auto-dismiss after ms (for toasts) */
45
+ autoDismissMs?: number;
46
+ /** Callback on dismiss */
47
+ onDismiss?: () => void;
48
+ /** Source trait name */
49
+ sourceTrait?: string;
50
+ }
51
+ /**
52
+ * Callback for slot changes
53
+ */
54
+ type SlotChangeCallback = (slot: UISlot, content: SlotContent | null) => void;
55
+ /**
56
+ * UI Slot Manager interface
57
+ */
58
+ interface UISlotManager {
59
+ /** Current content for each slot */
60
+ slots: Record<UISlot, SlotContent | null>;
61
+ /** Render content to a slot */
62
+ render: (config: RenderUIConfig) => string;
63
+ /** Clear a specific slot */
64
+ clear: (slot: UISlot) => void;
65
+ /** Clear content by ID */
66
+ clearById: (id: string) => void;
67
+ /** Clear all slots */
68
+ clearAll: () => void;
69
+ /** Subscribe to slot changes */
70
+ subscribe: (callback: SlotChangeCallback) => () => void;
71
+ /** Check if a slot has content */
72
+ hasContent: (slot: UISlot) => boolean;
73
+ /** Get content for a slot */
74
+ getContent: (slot: UISlot) => SlotContent | null;
75
+ }
76
+ declare const DEFAULT_SLOTS: Record<UISlot, SlotContent | null>;
77
+ /**
78
+ * Create a UI Slot Manager instance.
79
+ *
80
+ * This is the internal hook that creates the manager.
81
+ * Use `useUISlots()` from context in components.
82
+ */
83
+ declare function useUISlotManager(): UISlotManager;
84
+
85
+ export { DEFAULT_SLOTS as D, type RenderUIConfig as R, type SlotContent as S, type UISlotManager as U, type UISlot as a, type SlotAnimation as b, type SlotChangeCallback as c, useUISlotManager as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",
@@ -1,7 +1,7 @@
1
1
  import { apiClient } from './chunk-XSEDIUM6.js';
2
+ import { subscribe, getSnapshot, clearEntities, removeEntity, updateSingleton, updateEntity, spawnEntity, getSingleton, getAllEntities, getByType, getEntity } from './chunk-N7MVUW4R.js';
2
3
  import { SelectionContext, entityDataKeys, useEntityList } from './chunk-PE2H3NAW.js';
3
4
  import { useEventBus } from './chunk-YXZM3WCF.js';
4
- import { subscribe, getSnapshot, clearEntities, removeEntity, updateSingleton, updateEntity, spawnEntity, getSingleton, getAllEntities, getByType, getEntity } from './chunk-N7MVUW4R.js';
5
5
  import { useCallback, useState, useEffect, useMemo, useContext, useSyncExternalStore } from 'react';
6
6
  import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
7
7