@rencar-dev/feature-modules-public 1.2.2 → 1.2.3
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/presence/index.cjs +114 -40
- package/dist/presence/index.cjs.map +1 -1
- package/dist/presence/index.d.cts +106 -32
- package/dist/presence/index.d.ts +106 -32
- package/dist/presence/index.js +116 -44
- package/dist/presence/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -16,6 +16,19 @@ type PresenceConfig = {
|
|
|
16
16
|
url: string;
|
|
17
17
|
transports?: ("websocket" | "polling")[];
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* PresenceProvider component props
|
|
21
|
+
*/
|
|
22
|
+
type PresenceProviderProps = {
|
|
23
|
+
/** Socket server URL */
|
|
24
|
+
url: string;
|
|
25
|
+
/** Transport methods (default: ['websocket']) */
|
|
26
|
+
transports?: ("websocket" | "polling")[];
|
|
27
|
+
/** Enable debug logging (default: false) */
|
|
28
|
+
debug?: boolean;
|
|
29
|
+
/** Children components */
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
};
|
|
19
32
|
/**
|
|
20
33
|
* usePresence hook options
|
|
21
34
|
*/
|
|
@@ -41,19 +54,19 @@ type UsePresenceWatchOptions = {
|
|
|
41
54
|
/**
|
|
42
55
|
* usePresenceAvatarsState hook options
|
|
43
56
|
*/
|
|
44
|
-
type UsePresenceAvatarsStateOptions = {
|
|
57
|
+
type UsePresenceAvatarsStateOptions<T extends PresenceUser = PresenceUser> = {
|
|
45
58
|
/** List of presence users */
|
|
46
|
-
users:
|
|
59
|
+
users: T[];
|
|
47
60
|
/** Maximum visible avatars (default: 3) */
|
|
48
61
|
maxVisible?: number;
|
|
49
62
|
};
|
|
50
63
|
/**
|
|
51
64
|
* usePresenceAvatarsState return type
|
|
52
65
|
*/
|
|
53
|
-
type UsePresenceAvatarsStateReturn = {
|
|
54
|
-
visibleUsers:
|
|
66
|
+
type UsePresenceAvatarsStateReturn<T extends PresenceUser = PresenceUser> = {
|
|
67
|
+
visibleUsers: T[];
|
|
55
68
|
moreCount: number;
|
|
56
|
-
hoveredUser:
|
|
69
|
+
hoveredUser: T | null;
|
|
57
70
|
hoveredIndex: number | null;
|
|
58
71
|
setHoveredIndex: (index: number | null) => void;
|
|
59
72
|
getInitial: (user: PresenceUser) => string;
|
|
@@ -62,9 +75,9 @@ type UsePresenceAvatarsStateReturn = {
|
|
|
62
75
|
/**
|
|
63
76
|
* usePresenceFloatingState hook options
|
|
64
77
|
*/
|
|
65
|
-
type UsePresenceFloatingStateOptions = {
|
|
78
|
+
type UsePresenceFloatingStateOptions<T extends PresenceUser = PresenceUser> = {
|
|
66
79
|
/** List of presence users */
|
|
67
|
-
users:
|
|
80
|
+
users: T[];
|
|
68
81
|
/** Maximum visible avatars (default: 8) */
|
|
69
82
|
maxVisible?: number;
|
|
70
83
|
/** Initial position */
|
|
@@ -75,7 +88,7 @@ type UsePresenceFloatingStateOptions = {
|
|
|
75
88
|
/**
|
|
76
89
|
* usePresenceFloatingState return type
|
|
77
90
|
*/
|
|
78
|
-
type UsePresenceFloatingStateReturn = {
|
|
91
|
+
type UsePresenceFloatingStateReturn<T extends PresenceUser = PresenceUser> = {
|
|
79
92
|
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
80
93
|
position: {
|
|
81
94
|
top: number;
|
|
@@ -84,20 +97,20 @@ type UsePresenceFloatingStateReturn = {
|
|
|
84
97
|
isDragging: boolean;
|
|
85
98
|
hasDragged: boolean;
|
|
86
99
|
inlineStyle: React.CSSProperties;
|
|
87
|
-
visibleUsers:
|
|
100
|
+
visibleUsers: T[];
|
|
88
101
|
moreCount: number;
|
|
89
|
-
hoveredUser:
|
|
102
|
+
hoveredUser: T | null;
|
|
90
103
|
tooltipTop: number;
|
|
91
104
|
onMouseDownHeader: (e: React.MouseEvent) => void;
|
|
92
105
|
onTouchStartHeader: (e: React.TouchEvent) => void;
|
|
93
|
-
onAvatarEnter: (e: React.MouseEvent, user:
|
|
106
|
+
onAvatarEnter: (e: React.MouseEvent, user: T) => void;
|
|
94
107
|
onAvatarLeave: () => void;
|
|
95
108
|
};
|
|
96
109
|
/**
|
|
97
110
|
* Render props for individual avatar in PresenceAvatars
|
|
98
111
|
*/
|
|
99
|
-
type PresenceAvatarRenderProps = {
|
|
100
|
-
user:
|
|
112
|
+
type PresenceAvatarRenderProps<T extends PresenceUser = PresenceUser> = {
|
|
113
|
+
user: T;
|
|
101
114
|
index: number;
|
|
102
115
|
initial: string;
|
|
103
116
|
isHovered: boolean;
|
|
@@ -106,8 +119,8 @@ type PresenceAvatarRenderProps = {
|
|
|
106
119
|
/**
|
|
107
120
|
* Render props for tooltip in PresenceAvatars
|
|
108
121
|
*/
|
|
109
|
-
type PresenceAvatarsTooltipRenderProps = {
|
|
110
|
-
user:
|
|
122
|
+
type PresenceAvatarsTooltipRenderProps<T extends PresenceUser = PresenceUser> = {
|
|
123
|
+
user: T;
|
|
111
124
|
position: {
|
|
112
125
|
top: number;
|
|
113
126
|
left: number;
|
|
@@ -116,40 +129,40 @@ type PresenceAvatarsTooltipRenderProps = {
|
|
|
116
129
|
/**
|
|
117
130
|
* Props for PresenceAvatars component
|
|
118
131
|
*/
|
|
119
|
-
type PresenceAvatarsProps = {
|
|
132
|
+
type PresenceAvatarsProps<T extends PresenceUser = PresenceUser> = {
|
|
120
133
|
/** List of presence users */
|
|
121
|
-
users:
|
|
134
|
+
users: T[];
|
|
122
135
|
/** Maximum visible avatars (default: 3) */
|
|
123
136
|
maxVisible?: number;
|
|
124
137
|
/** Additional CSS class */
|
|
125
138
|
className?: string;
|
|
126
139
|
/** Custom avatar renderer */
|
|
127
|
-
renderAvatar?: (props: PresenceAvatarRenderProps) => React.ReactNode;
|
|
140
|
+
renderAvatar?: (props: PresenceAvatarRenderProps<T>) => React.ReactNode;
|
|
128
141
|
/** Custom tooltip renderer */
|
|
129
|
-
renderTooltip?: (props: PresenceAvatarsTooltipRenderProps) => React.ReactNode;
|
|
142
|
+
renderTooltip?: (props: PresenceAvatarsTooltipRenderProps<T>) => React.ReactNode;
|
|
130
143
|
/** Custom "more" badge renderer */
|
|
131
144
|
renderMore?: (count: number) => React.ReactNode;
|
|
132
145
|
};
|
|
133
146
|
/**
|
|
134
147
|
* Render props for individual avatar in PresenceFloating
|
|
135
148
|
*/
|
|
136
|
-
type PresenceFloatingAvatarRenderProps = {
|
|
137
|
-
user:
|
|
149
|
+
type PresenceFloatingAvatarRenderProps<T extends PresenceUser = PresenceUser> = {
|
|
150
|
+
user: T;
|
|
138
151
|
initial: string;
|
|
139
152
|
};
|
|
140
153
|
/**
|
|
141
154
|
* Render props for tooltip in PresenceFloating
|
|
142
155
|
*/
|
|
143
|
-
type PresenceFloatingTooltipRenderProps = {
|
|
144
|
-
user:
|
|
156
|
+
type PresenceFloatingTooltipRenderProps<T extends PresenceUser = PresenceUser> = {
|
|
157
|
+
user: T;
|
|
145
158
|
top: number;
|
|
146
159
|
};
|
|
147
160
|
/**
|
|
148
161
|
* Props for PresenceFloating component
|
|
149
162
|
*/
|
|
150
|
-
type PresenceFloatingProps = {
|
|
163
|
+
type PresenceFloatingProps<T extends PresenceUser = PresenceUser> = {
|
|
151
164
|
/** List of presence users */
|
|
152
|
-
users:
|
|
165
|
+
users: T[];
|
|
153
166
|
/** Maximum visible avatars (default: 8) */
|
|
154
167
|
maxVisible?: number;
|
|
155
168
|
/** Additional CSS class */
|
|
@@ -167,9 +180,9 @@ type PresenceFloatingProps = {
|
|
|
167
180
|
/** More count text formatter (default: (n) => `+${n}명`) */
|
|
168
181
|
moreText?: (count: number) => string;
|
|
169
182
|
/** Custom avatar renderer */
|
|
170
|
-
renderAvatar?: (props: PresenceFloatingAvatarRenderProps) => React.ReactNode;
|
|
183
|
+
renderAvatar?: (props: PresenceFloatingAvatarRenderProps<T>) => React.ReactNode;
|
|
171
184
|
/** Custom tooltip renderer */
|
|
172
|
-
renderTooltip?: (props: PresenceFloatingTooltipRenderProps) => React.ReactNode;
|
|
185
|
+
renderTooltip?: (props: PresenceFloatingTooltipRenderProps<T>) => React.ReactNode;
|
|
173
186
|
};
|
|
174
187
|
|
|
175
188
|
/**
|
|
@@ -261,7 +274,7 @@ declare function usePresenceWatch(options: UsePresenceWatchOptions): Record<stri
|
|
|
261
274
|
* );
|
|
262
275
|
* ```
|
|
263
276
|
*/
|
|
264
|
-
declare function usePresenceAvatarsState(options: UsePresenceAvatarsStateOptions): UsePresenceAvatarsStateReturn
|
|
277
|
+
declare function usePresenceAvatarsState<T extends PresenceUser = PresenceUser>(options: UsePresenceAvatarsStateOptions<T>): UsePresenceAvatarsStateReturn<T>;
|
|
265
278
|
|
|
266
279
|
/**
|
|
267
280
|
* Headless hook for presence floating UI state management
|
|
@@ -305,7 +318,7 @@ declare function usePresenceAvatarsState(options: UsePresenceAvatarsStateOptions
|
|
|
305
318
|
* );
|
|
306
319
|
* ```
|
|
307
320
|
*/
|
|
308
|
-
declare function usePresenceFloatingState(options: UsePresenceFloatingStateOptions): UsePresenceFloatingStateReturn
|
|
321
|
+
declare function usePresenceFloatingState<T extends PresenceUser = PresenceUser>(options: UsePresenceFloatingStateOptions<T>): UsePresenceFloatingStateReturn<T>;
|
|
309
322
|
|
|
310
323
|
/**
|
|
311
324
|
* PresenceAvatars - Displays a stack of user avatars with hover tooltips
|
|
@@ -334,7 +347,7 @@ declare function usePresenceFloatingState(options: UsePresenceFloatingStateOptio
|
|
|
334
347
|
* />
|
|
335
348
|
* ```
|
|
336
349
|
*/
|
|
337
|
-
declare function PresenceAvatars({ users, maxVisible, className, renderAvatar, renderTooltip, renderMore, }: PresenceAvatarsProps): react_jsx_runtime.JSX.Element;
|
|
350
|
+
declare function PresenceAvatars<T extends PresenceUser = PresenceUser>({ users, maxVisible, className, renderAvatar, renderTooltip, renderMore, }: PresenceAvatarsProps<T>): react_jsx_runtime.JSX.Element;
|
|
338
351
|
|
|
339
352
|
/**
|
|
340
353
|
* PresenceFloating - Draggable floating panel showing presence users
|
|
@@ -361,6 +374,67 @@ declare function PresenceAvatars({ users, maxVisible, className, renderAvatar, r
|
|
|
361
374
|
* />
|
|
362
375
|
* ```
|
|
363
376
|
*/
|
|
364
|
-
declare function PresenceFloating({ users, maxVisible, className, style, initialPosition, title, emptyText, moreText, renderAvatar, renderTooltip, }: PresenceFloatingProps): react_jsx_runtime.JSX.Element;
|
|
377
|
+
declare function PresenceFloating<T extends PresenceUser = PresenceUser>({ users, maxVisible, className, style, initialPosition, title, emptyText, moreText, renderAvatar, renderTooltip, }: PresenceFloatingProps<T>): react_jsx_runtime.JSX.Element;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Presence Context value type
|
|
381
|
+
*/
|
|
382
|
+
type PresenceContextValue = {
|
|
383
|
+
/** Whether the socket is initialized */
|
|
384
|
+
isInitialized: boolean;
|
|
385
|
+
/** Current connection status */
|
|
386
|
+
status: "connecting" | "connected" | "disconnected";
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* PresenceProvider - Manages socket initialization lifecycle
|
|
390
|
+
*
|
|
391
|
+
* Wrap your app with this provider to automatically initialize
|
|
392
|
+
* and cleanup the presence socket connection.
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```tsx
|
|
396
|
+
* // In your app entry point
|
|
397
|
+
* import { PresenceProvider } from '@rencar-dev/feature-modules-public';
|
|
398
|
+
*
|
|
399
|
+
* function App() {
|
|
400
|
+
* return (
|
|
401
|
+
* <PresenceProvider url="https://socket.example.com">
|
|
402
|
+
* <MyApp />
|
|
403
|
+
* </PresenceProvider>
|
|
404
|
+
* );
|
|
405
|
+
* }
|
|
406
|
+
*
|
|
407
|
+
* // In child components, hooks work automatically
|
|
408
|
+
* function MyComponent() {
|
|
409
|
+
* const users = usePresence({ roomId: 'room-1', currentUser });
|
|
410
|
+
* return <PresenceFloating users={users} />;
|
|
411
|
+
* }
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
declare function PresenceProvider({ url, transports, debug, children, }: PresenceProviderProps): react_jsx_runtime.JSX.Element;
|
|
415
|
+
/**
|
|
416
|
+
* Hook to access presence connection status
|
|
417
|
+
*
|
|
418
|
+
* @returns Connection status object or null if not inside PresenceProvider
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```tsx
|
|
422
|
+
* function StatusIndicator() {
|
|
423
|
+
* const presence = usePresenceStatus();
|
|
424
|
+
*
|
|
425
|
+
* if (!presence) {
|
|
426
|
+
* return <span>Not initialized</span>;
|
|
427
|
+
* }
|
|
428
|
+
*
|
|
429
|
+
* return (
|
|
430
|
+
* <span>
|
|
431
|
+
* Status: {presence.status}
|
|
432
|
+
* {presence.status === 'connecting' && <Spinner />}
|
|
433
|
+
* </span>
|
|
434
|
+
* );
|
|
435
|
+
* }
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
438
|
+
declare function usePresenceStatus(): PresenceContextValue | null;
|
|
365
439
|
|
|
366
|
-
export { type PresenceAvatarRenderProps, PresenceAvatars, type PresenceAvatarsProps, type PresenceAvatarsTooltipRenderProps, type PresenceConfig, PresenceFloating, type PresenceFloatingAvatarRenderProps, type PresenceFloatingProps, type PresenceFloatingTooltipRenderProps, type PresenceUser, type UsePresenceAvatarsStateOptions, type UsePresenceAvatarsStateReturn, type UsePresenceFloatingStateOptions, type UsePresenceFloatingStateReturn, type UsePresenceOptions, type UsePresenceWatchOptions, disconnectPresenceSocket, getPresenceSocket, initPresenceSocket, isPresenceSocketInitialized, usePresence, usePresenceAvatarsState, usePresenceFloatingState, usePresenceWatch };
|
|
440
|
+
export { type PresenceAvatarRenderProps, PresenceAvatars, type PresenceAvatarsProps, type PresenceAvatarsTooltipRenderProps, type PresenceConfig, PresenceFloating, type PresenceFloatingAvatarRenderProps, type PresenceFloatingProps, type PresenceFloatingTooltipRenderProps, PresenceProvider, type PresenceProviderProps, type PresenceUser, type UsePresenceAvatarsStateOptions, type UsePresenceAvatarsStateReturn, type UsePresenceFloatingStateOptions, type UsePresenceFloatingStateReturn, type UsePresenceOptions, type UsePresenceWatchOptions, disconnectPresenceSocket, getPresenceSocket, initPresenceSocket, isPresenceSocketInitialized, usePresence, usePresenceAvatarsState, usePresenceFloatingState, usePresenceStatus, usePresenceWatch };
|
package/dist/presence/index.d.ts
CHANGED
|
@@ -16,6 +16,19 @@ type PresenceConfig = {
|
|
|
16
16
|
url: string;
|
|
17
17
|
transports?: ("websocket" | "polling")[];
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* PresenceProvider component props
|
|
21
|
+
*/
|
|
22
|
+
type PresenceProviderProps = {
|
|
23
|
+
/** Socket server URL */
|
|
24
|
+
url: string;
|
|
25
|
+
/** Transport methods (default: ['websocket']) */
|
|
26
|
+
transports?: ("websocket" | "polling")[];
|
|
27
|
+
/** Enable debug logging (default: false) */
|
|
28
|
+
debug?: boolean;
|
|
29
|
+
/** Children components */
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
};
|
|
19
32
|
/**
|
|
20
33
|
* usePresence hook options
|
|
21
34
|
*/
|
|
@@ -41,19 +54,19 @@ type UsePresenceWatchOptions = {
|
|
|
41
54
|
/**
|
|
42
55
|
* usePresenceAvatarsState hook options
|
|
43
56
|
*/
|
|
44
|
-
type UsePresenceAvatarsStateOptions = {
|
|
57
|
+
type UsePresenceAvatarsStateOptions<T extends PresenceUser = PresenceUser> = {
|
|
45
58
|
/** List of presence users */
|
|
46
|
-
users:
|
|
59
|
+
users: T[];
|
|
47
60
|
/** Maximum visible avatars (default: 3) */
|
|
48
61
|
maxVisible?: number;
|
|
49
62
|
};
|
|
50
63
|
/**
|
|
51
64
|
* usePresenceAvatarsState return type
|
|
52
65
|
*/
|
|
53
|
-
type UsePresenceAvatarsStateReturn = {
|
|
54
|
-
visibleUsers:
|
|
66
|
+
type UsePresenceAvatarsStateReturn<T extends PresenceUser = PresenceUser> = {
|
|
67
|
+
visibleUsers: T[];
|
|
55
68
|
moreCount: number;
|
|
56
|
-
hoveredUser:
|
|
69
|
+
hoveredUser: T | null;
|
|
57
70
|
hoveredIndex: number | null;
|
|
58
71
|
setHoveredIndex: (index: number | null) => void;
|
|
59
72
|
getInitial: (user: PresenceUser) => string;
|
|
@@ -62,9 +75,9 @@ type UsePresenceAvatarsStateReturn = {
|
|
|
62
75
|
/**
|
|
63
76
|
* usePresenceFloatingState hook options
|
|
64
77
|
*/
|
|
65
|
-
type UsePresenceFloatingStateOptions = {
|
|
78
|
+
type UsePresenceFloatingStateOptions<T extends PresenceUser = PresenceUser> = {
|
|
66
79
|
/** List of presence users */
|
|
67
|
-
users:
|
|
80
|
+
users: T[];
|
|
68
81
|
/** Maximum visible avatars (default: 8) */
|
|
69
82
|
maxVisible?: number;
|
|
70
83
|
/** Initial position */
|
|
@@ -75,7 +88,7 @@ type UsePresenceFloatingStateOptions = {
|
|
|
75
88
|
/**
|
|
76
89
|
* usePresenceFloatingState return type
|
|
77
90
|
*/
|
|
78
|
-
type UsePresenceFloatingStateReturn = {
|
|
91
|
+
type UsePresenceFloatingStateReturn<T extends PresenceUser = PresenceUser> = {
|
|
79
92
|
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
80
93
|
position: {
|
|
81
94
|
top: number;
|
|
@@ -84,20 +97,20 @@ type UsePresenceFloatingStateReturn = {
|
|
|
84
97
|
isDragging: boolean;
|
|
85
98
|
hasDragged: boolean;
|
|
86
99
|
inlineStyle: React.CSSProperties;
|
|
87
|
-
visibleUsers:
|
|
100
|
+
visibleUsers: T[];
|
|
88
101
|
moreCount: number;
|
|
89
|
-
hoveredUser:
|
|
102
|
+
hoveredUser: T | null;
|
|
90
103
|
tooltipTop: number;
|
|
91
104
|
onMouseDownHeader: (e: React.MouseEvent) => void;
|
|
92
105
|
onTouchStartHeader: (e: React.TouchEvent) => void;
|
|
93
|
-
onAvatarEnter: (e: React.MouseEvent, user:
|
|
106
|
+
onAvatarEnter: (e: React.MouseEvent, user: T) => void;
|
|
94
107
|
onAvatarLeave: () => void;
|
|
95
108
|
};
|
|
96
109
|
/**
|
|
97
110
|
* Render props for individual avatar in PresenceAvatars
|
|
98
111
|
*/
|
|
99
|
-
type PresenceAvatarRenderProps = {
|
|
100
|
-
user:
|
|
112
|
+
type PresenceAvatarRenderProps<T extends PresenceUser = PresenceUser> = {
|
|
113
|
+
user: T;
|
|
101
114
|
index: number;
|
|
102
115
|
initial: string;
|
|
103
116
|
isHovered: boolean;
|
|
@@ -106,8 +119,8 @@ type PresenceAvatarRenderProps = {
|
|
|
106
119
|
/**
|
|
107
120
|
* Render props for tooltip in PresenceAvatars
|
|
108
121
|
*/
|
|
109
|
-
type PresenceAvatarsTooltipRenderProps = {
|
|
110
|
-
user:
|
|
122
|
+
type PresenceAvatarsTooltipRenderProps<T extends PresenceUser = PresenceUser> = {
|
|
123
|
+
user: T;
|
|
111
124
|
position: {
|
|
112
125
|
top: number;
|
|
113
126
|
left: number;
|
|
@@ -116,40 +129,40 @@ type PresenceAvatarsTooltipRenderProps = {
|
|
|
116
129
|
/**
|
|
117
130
|
* Props for PresenceAvatars component
|
|
118
131
|
*/
|
|
119
|
-
type PresenceAvatarsProps = {
|
|
132
|
+
type PresenceAvatarsProps<T extends PresenceUser = PresenceUser> = {
|
|
120
133
|
/** List of presence users */
|
|
121
|
-
users:
|
|
134
|
+
users: T[];
|
|
122
135
|
/** Maximum visible avatars (default: 3) */
|
|
123
136
|
maxVisible?: number;
|
|
124
137
|
/** Additional CSS class */
|
|
125
138
|
className?: string;
|
|
126
139
|
/** Custom avatar renderer */
|
|
127
|
-
renderAvatar?: (props: PresenceAvatarRenderProps) => React.ReactNode;
|
|
140
|
+
renderAvatar?: (props: PresenceAvatarRenderProps<T>) => React.ReactNode;
|
|
128
141
|
/** Custom tooltip renderer */
|
|
129
|
-
renderTooltip?: (props: PresenceAvatarsTooltipRenderProps) => React.ReactNode;
|
|
142
|
+
renderTooltip?: (props: PresenceAvatarsTooltipRenderProps<T>) => React.ReactNode;
|
|
130
143
|
/** Custom "more" badge renderer */
|
|
131
144
|
renderMore?: (count: number) => React.ReactNode;
|
|
132
145
|
};
|
|
133
146
|
/**
|
|
134
147
|
* Render props for individual avatar in PresenceFloating
|
|
135
148
|
*/
|
|
136
|
-
type PresenceFloatingAvatarRenderProps = {
|
|
137
|
-
user:
|
|
149
|
+
type PresenceFloatingAvatarRenderProps<T extends PresenceUser = PresenceUser> = {
|
|
150
|
+
user: T;
|
|
138
151
|
initial: string;
|
|
139
152
|
};
|
|
140
153
|
/**
|
|
141
154
|
* Render props for tooltip in PresenceFloating
|
|
142
155
|
*/
|
|
143
|
-
type PresenceFloatingTooltipRenderProps = {
|
|
144
|
-
user:
|
|
156
|
+
type PresenceFloatingTooltipRenderProps<T extends PresenceUser = PresenceUser> = {
|
|
157
|
+
user: T;
|
|
145
158
|
top: number;
|
|
146
159
|
};
|
|
147
160
|
/**
|
|
148
161
|
* Props for PresenceFloating component
|
|
149
162
|
*/
|
|
150
|
-
type PresenceFloatingProps = {
|
|
163
|
+
type PresenceFloatingProps<T extends PresenceUser = PresenceUser> = {
|
|
151
164
|
/** List of presence users */
|
|
152
|
-
users:
|
|
165
|
+
users: T[];
|
|
153
166
|
/** Maximum visible avatars (default: 8) */
|
|
154
167
|
maxVisible?: number;
|
|
155
168
|
/** Additional CSS class */
|
|
@@ -167,9 +180,9 @@ type PresenceFloatingProps = {
|
|
|
167
180
|
/** More count text formatter (default: (n) => `+${n}명`) */
|
|
168
181
|
moreText?: (count: number) => string;
|
|
169
182
|
/** Custom avatar renderer */
|
|
170
|
-
renderAvatar?: (props: PresenceFloatingAvatarRenderProps) => React.ReactNode;
|
|
183
|
+
renderAvatar?: (props: PresenceFloatingAvatarRenderProps<T>) => React.ReactNode;
|
|
171
184
|
/** Custom tooltip renderer */
|
|
172
|
-
renderTooltip?: (props: PresenceFloatingTooltipRenderProps) => React.ReactNode;
|
|
185
|
+
renderTooltip?: (props: PresenceFloatingTooltipRenderProps<T>) => React.ReactNode;
|
|
173
186
|
};
|
|
174
187
|
|
|
175
188
|
/**
|
|
@@ -261,7 +274,7 @@ declare function usePresenceWatch(options: UsePresenceWatchOptions): Record<stri
|
|
|
261
274
|
* );
|
|
262
275
|
* ```
|
|
263
276
|
*/
|
|
264
|
-
declare function usePresenceAvatarsState(options: UsePresenceAvatarsStateOptions): UsePresenceAvatarsStateReturn
|
|
277
|
+
declare function usePresenceAvatarsState<T extends PresenceUser = PresenceUser>(options: UsePresenceAvatarsStateOptions<T>): UsePresenceAvatarsStateReturn<T>;
|
|
265
278
|
|
|
266
279
|
/**
|
|
267
280
|
* Headless hook for presence floating UI state management
|
|
@@ -305,7 +318,7 @@ declare function usePresenceAvatarsState(options: UsePresenceAvatarsStateOptions
|
|
|
305
318
|
* );
|
|
306
319
|
* ```
|
|
307
320
|
*/
|
|
308
|
-
declare function usePresenceFloatingState(options: UsePresenceFloatingStateOptions): UsePresenceFloatingStateReturn
|
|
321
|
+
declare function usePresenceFloatingState<T extends PresenceUser = PresenceUser>(options: UsePresenceFloatingStateOptions<T>): UsePresenceFloatingStateReturn<T>;
|
|
309
322
|
|
|
310
323
|
/**
|
|
311
324
|
* PresenceAvatars - Displays a stack of user avatars with hover tooltips
|
|
@@ -334,7 +347,7 @@ declare function usePresenceFloatingState(options: UsePresenceFloatingStateOptio
|
|
|
334
347
|
* />
|
|
335
348
|
* ```
|
|
336
349
|
*/
|
|
337
|
-
declare function PresenceAvatars({ users, maxVisible, className, renderAvatar, renderTooltip, renderMore, }: PresenceAvatarsProps): react_jsx_runtime.JSX.Element;
|
|
350
|
+
declare function PresenceAvatars<T extends PresenceUser = PresenceUser>({ users, maxVisible, className, renderAvatar, renderTooltip, renderMore, }: PresenceAvatarsProps<T>): react_jsx_runtime.JSX.Element;
|
|
338
351
|
|
|
339
352
|
/**
|
|
340
353
|
* PresenceFloating - Draggable floating panel showing presence users
|
|
@@ -361,6 +374,67 @@ declare function PresenceAvatars({ users, maxVisible, className, renderAvatar, r
|
|
|
361
374
|
* />
|
|
362
375
|
* ```
|
|
363
376
|
*/
|
|
364
|
-
declare function PresenceFloating({ users, maxVisible, className, style, initialPosition, title, emptyText, moreText, renderAvatar, renderTooltip, }: PresenceFloatingProps): react_jsx_runtime.JSX.Element;
|
|
377
|
+
declare function PresenceFloating<T extends PresenceUser = PresenceUser>({ users, maxVisible, className, style, initialPosition, title, emptyText, moreText, renderAvatar, renderTooltip, }: PresenceFloatingProps<T>): react_jsx_runtime.JSX.Element;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Presence Context value type
|
|
381
|
+
*/
|
|
382
|
+
type PresenceContextValue = {
|
|
383
|
+
/** Whether the socket is initialized */
|
|
384
|
+
isInitialized: boolean;
|
|
385
|
+
/** Current connection status */
|
|
386
|
+
status: "connecting" | "connected" | "disconnected";
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* PresenceProvider - Manages socket initialization lifecycle
|
|
390
|
+
*
|
|
391
|
+
* Wrap your app with this provider to automatically initialize
|
|
392
|
+
* and cleanup the presence socket connection.
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```tsx
|
|
396
|
+
* // In your app entry point
|
|
397
|
+
* import { PresenceProvider } from '@rencar-dev/feature-modules-public';
|
|
398
|
+
*
|
|
399
|
+
* function App() {
|
|
400
|
+
* return (
|
|
401
|
+
* <PresenceProvider url="https://socket.example.com">
|
|
402
|
+
* <MyApp />
|
|
403
|
+
* </PresenceProvider>
|
|
404
|
+
* );
|
|
405
|
+
* }
|
|
406
|
+
*
|
|
407
|
+
* // In child components, hooks work automatically
|
|
408
|
+
* function MyComponent() {
|
|
409
|
+
* const users = usePresence({ roomId: 'room-1', currentUser });
|
|
410
|
+
* return <PresenceFloating users={users} />;
|
|
411
|
+
* }
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
declare function PresenceProvider({ url, transports, debug, children, }: PresenceProviderProps): react_jsx_runtime.JSX.Element;
|
|
415
|
+
/**
|
|
416
|
+
* Hook to access presence connection status
|
|
417
|
+
*
|
|
418
|
+
* @returns Connection status object or null if not inside PresenceProvider
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```tsx
|
|
422
|
+
* function StatusIndicator() {
|
|
423
|
+
* const presence = usePresenceStatus();
|
|
424
|
+
*
|
|
425
|
+
* if (!presence) {
|
|
426
|
+
* return <span>Not initialized</span>;
|
|
427
|
+
* }
|
|
428
|
+
*
|
|
429
|
+
* return (
|
|
430
|
+
* <span>
|
|
431
|
+
* Status: {presence.status}
|
|
432
|
+
* {presence.status === 'connecting' && <Spinner />}
|
|
433
|
+
* </span>
|
|
434
|
+
* );
|
|
435
|
+
* }
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
438
|
+
declare function usePresenceStatus(): PresenceContextValue | null;
|
|
365
439
|
|
|
366
|
-
export { type PresenceAvatarRenderProps, PresenceAvatars, type PresenceAvatarsProps, type PresenceAvatarsTooltipRenderProps, type PresenceConfig, PresenceFloating, type PresenceFloatingAvatarRenderProps, type PresenceFloatingProps, type PresenceFloatingTooltipRenderProps, type PresenceUser, type UsePresenceAvatarsStateOptions, type UsePresenceAvatarsStateReturn, type UsePresenceFloatingStateOptions, type UsePresenceFloatingStateReturn, type UsePresenceOptions, type UsePresenceWatchOptions, disconnectPresenceSocket, getPresenceSocket, initPresenceSocket, isPresenceSocketInitialized, usePresence, usePresenceAvatarsState, usePresenceFloatingState, usePresenceWatch };
|
|
440
|
+
export { type PresenceAvatarRenderProps, PresenceAvatars, type PresenceAvatarsProps, type PresenceAvatarsTooltipRenderProps, type PresenceConfig, PresenceFloating, type PresenceFloatingAvatarRenderProps, type PresenceFloatingProps, type PresenceFloatingTooltipRenderProps, PresenceProvider, type PresenceProviderProps, type PresenceUser, type UsePresenceAvatarsStateOptions, type UsePresenceAvatarsStateReturn, type UsePresenceFloatingStateOptions, type UsePresenceFloatingStateReturn, type UsePresenceOptions, type UsePresenceWatchOptions, disconnectPresenceSocket, getPresenceSocket, initPresenceSocket, isPresenceSocketInitialized, usePresence, usePresenceAvatarsState, usePresenceFloatingState, usePresenceStatus, usePresenceWatch };
|