@jsb188/react 1.1.11 → 1.1.13
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 +21 -0
- package/libs/page-filters.helpers.ts +65 -0
- package/libs/page-filters.ts +223 -0
- package/libs/use-page-filters.ts +168 -0
- package/package.json +21 -6
- package/states/appContext.ts +21 -59
- package/states/index.ts +1 -1
- package/states/keyDown.ts +158 -50
- package/states/keyboardLayer.ts +58 -0
- package/states/modal.ts +169 -88
- package/states/popOver.ts +246 -154
- package/states/uploads.ts +0 -2
- package/types/PopOver.d.ts +188 -63
- package/utils/hooks.ts +109 -29
- package/utils/lazy.ts +183 -0
- package/states/reactiveEvents.ts +0 -56
- package/utils/schema.ts +0 -170
package/states/popOver.ts
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
AcknowledgePopOverEventFn,
|
|
2
3
|
ClosePopOverFn,
|
|
3
4
|
CloseTooltipFn,
|
|
4
5
|
OpenPopOverFn,
|
|
5
6
|
OpenTooltipFn,
|
|
6
|
-
|
|
7
|
+
PopOverEventFilter,
|
|
8
|
+
PopOverEventObj,
|
|
9
|
+
PopOverEventParams,
|
|
7
10
|
PopOverProps,
|
|
8
|
-
|
|
11
|
+
PublishPopOverEventFn,
|
|
9
12
|
TooltipHookProps,
|
|
10
13
|
TooltipProps,
|
|
11
14
|
UpdatePopOverFn,
|
|
12
15
|
UpdatePopOverParams,
|
|
13
16
|
UpdateTooltipFn,
|
|
14
17
|
} from '@jsb188/react/types/PopOver.d';
|
|
15
|
-
import { atom, useAtom, useAtomValue, useSetAtom } from 'jotai';
|
|
16
|
-
import { useCallback } from 'react';
|
|
17
|
-
|
|
18
|
-
type SetPopOverAtomStateValue =
|
|
19
|
-
| PopOverProps
|
|
20
|
-
| null
|
|
21
|
-
| ((prev: PopOverProps | null) => PopOverProps | null);
|
|
22
|
-
type SetPopOverAtomFn = (value: SetPopOverAtomStateValue) => void;
|
|
18
|
+
import { atom, createStore, useAtom, useAtomValue, useSetAtom } from 'jotai';
|
|
19
|
+
import { useCallback, useMemo } from 'react';
|
|
23
20
|
|
|
24
21
|
/**
|
|
25
22
|
* Pop over class
|
|
@@ -28,39 +25,51 @@ type SetPopOverAtomFn = (value: SetPopOverAtomStateValue) => void;
|
|
|
28
25
|
class PopOver {
|
|
29
26
|
readonly name: string = 'pop_over_state';
|
|
30
27
|
readonly state = atom<PopOverProps | null>(null);
|
|
28
|
+
readonly eventState = atom<PopOverEventObj | null>(null);
|
|
31
29
|
public lastOpenId: string | null = null;
|
|
30
|
+
private eventId = 0;
|
|
31
|
+
private instanceId = 0;
|
|
32
32
|
|
|
33
|
+
/*
|
|
34
|
+
* Validate and normalize a newly opened popover definition.
|
|
35
|
+
*/
|
|
33
36
|
open(data: PopOverProps): PopOverProps | null {
|
|
34
|
-
// console.log('::::: OPEN', data);
|
|
35
37
|
if (!data?.name) {
|
|
36
38
|
return null;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
this.lastOpenId = data
|
|
40
|
-
|
|
41
|
+
this.lastOpenId = data.id || data.name;
|
|
42
|
+
this.instanceId += 1;
|
|
43
|
+
return {
|
|
44
|
+
...data,
|
|
45
|
+
instanceId: `popover_${this.instanceId}`,
|
|
46
|
+
} as PopOverProps;
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
): PopOverProps | null {
|
|
47
|
-
|
|
48
|
-
const nextName = name || prev?.name;
|
|
49
|
-
if (!nextName) {
|
|
49
|
+
/*
|
|
50
|
+
* Replace only the active popover iface while preserving its layout and instance identity.
|
|
51
|
+
*/
|
|
52
|
+
update(data: UpdatePopOverParams, prev: PopOverProps | null): PopOverProps | null {
|
|
53
|
+
if (!prev) {
|
|
50
54
|
return null;
|
|
51
55
|
}
|
|
56
|
+
if (prev.name === data.iface.name && prev.variables === data.iface.variables) {
|
|
57
|
+
return prev;
|
|
58
|
+
}
|
|
52
59
|
|
|
53
|
-
this.lastOpenId = prev
|
|
60
|
+
this.lastOpenId = prev.id || data.iface.name;
|
|
54
61
|
return {
|
|
55
62
|
...prev,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} as PopOverProps;
|
|
63
|
+
...data.iface,
|
|
64
|
+
};
|
|
59
65
|
}
|
|
60
66
|
|
|
67
|
+
/*
|
|
68
|
+
* Start the exit animation once and ignore additional dismiss requests until it completes.
|
|
69
|
+
*/
|
|
61
70
|
close(prev: PopOverProps | null): PopOverProps | null {
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
if (!prev?.animationClassName || !this.lastOpenId) {
|
|
72
|
+
this.lastOpenId = null;
|
|
64
73
|
return null;
|
|
65
74
|
}
|
|
66
75
|
|
|
@@ -68,16 +77,13 @@ class PopOver {
|
|
|
68
77
|
return prev;
|
|
69
78
|
}
|
|
70
79
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
nextAnimClassName = nextAnimClassName.replace(/\bon_mount\b/, '').trim();
|
|
74
|
-
} else if (!/\breverse\b/.test(nextAnimClassName)) {
|
|
75
|
-
nextAnimClassName += ' reverse';
|
|
76
|
-
} else {
|
|
77
|
-
this.lastOpenId = null;
|
|
78
|
-
return null;
|
|
80
|
+
if (prev.closing) {
|
|
81
|
+
return prev;
|
|
79
82
|
}
|
|
80
83
|
|
|
84
|
+
// Start the exit directly; stripping on_mount first creates a visible frame before the reverse animation restarts.
|
|
85
|
+
const nextAnimClassName = `${prev.animationClassName.replace(/\bon_mount\b/, '').trim()} reverse`;
|
|
86
|
+
|
|
81
87
|
return {
|
|
82
88
|
...prev,
|
|
83
89
|
closing: true,
|
|
@@ -85,22 +91,20 @@ class PopOver {
|
|
|
85
91
|
};
|
|
86
92
|
}
|
|
87
93
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (!prev) {
|
|
94
|
+
/*
|
|
95
|
+
* Create one immutable event scoped to the currently open popover instance.
|
|
96
|
+
*/
|
|
97
|
+
createEvent(event: PopOverEventParams, prev: PopOverProps | null): PopOverEventObj | null {
|
|
98
|
+
if (!prev?.instanceId) {
|
|
93
99
|
return null;
|
|
94
100
|
}
|
|
95
101
|
|
|
102
|
+
this.eventId += 1;
|
|
96
103
|
return {
|
|
97
|
-
...
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
id: prev.id,
|
|
102
|
-
...globalState,
|
|
103
|
-
},
|
|
104
|
+
...event,
|
|
105
|
+
id: prev.id,
|
|
106
|
+
eventId: this.eventId,
|
|
107
|
+
instanceId: prev.instanceId,
|
|
104
108
|
};
|
|
105
109
|
}
|
|
106
110
|
}
|
|
@@ -113,6 +117,9 @@ class Tooltip {
|
|
|
113
117
|
readonly name: string = 'tooltip_state';
|
|
114
118
|
readonly state = atom<TooltipProps | null>(null);
|
|
115
119
|
|
|
120
|
+
/*
|
|
121
|
+
* Validate one tooltip before opening it.
|
|
122
|
+
*/
|
|
116
123
|
open(data: TooltipProps): TooltipProps | null {
|
|
117
124
|
if (!data?.id) {
|
|
118
125
|
return null;
|
|
@@ -120,6 +127,9 @@ class Tooltip {
|
|
|
120
127
|
return data;
|
|
121
128
|
}
|
|
122
129
|
|
|
130
|
+
/*
|
|
131
|
+
* Merge changed tooltip properties into the active tooltip.
|
|
132
|
+
*/
|
|
123
133
|
update(data: TooltipProps, prev: TooltipProps | null): TooltipProps | null {
|
|
124
134
|
if (!data || !prev) {
|
|
125
135
|
return null;
|
|
@@ -130,12 +140,14 @@ class Tooltip {
|
|
|
130
140
|
};
|
|
131
141
|
}
|
|
132
142
|
|
|
143
|
+
/*
|
|
144
|
+
* Remove the active tooltip.
|
|
145
|
+
*/
|
|
133
146
|
close(): TooltipProps | null {
|
|
134
147
|
return null;
|
|
135
148
|
}
|
|
136
149
|
}
|
|
137
150
|
|
|
138
|
-
const popOverClass = new PopOver();
|
|
139
151
|
const tooltipClass = new Tooltip();
|
|
140
152
|
|
|
141
153
|
/**
|
|
@@ -152,123 +164,203 @@ export function useSetPopOverIsHover() {
|
|
|
152
164
|
return useSetAtom(popOverIsHoverState);
|
|
153
165
|
}
|
|
154
166
|
|
|
155
|
-
|
|
156
|
-
* Create
|
|
167
|
+
/*
|
|
168
|
+
* Create one isolated set of popover definition, event, and command atoms.
|
|
157
169
|
*/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const nextPopOverState = popOverClass.open(data);
|
|
164
|
-
if (nextPopOverState) {
|
|
165
|
-
setPopOver(nextPopOverState);
|
|
166
|
-
} else {
|
|
170
|
+
function createPopOverStateAtoms() {
|
|
171
|
+
const popOver = new PopOver();
|
|
172
|
+
const openState = atom(null, (_get, set, data: PopOverProps) => {
|
|
173
|
+
const nextPopOver = popOver.open(data);
|
|
174
|
+
if (!nextPopOver) {
|
|
167
175
|
console.warn('Invalid {popOver} data for open():', data);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
set(popOver.eventState, null);
|
|
180
|
+
set(popOver.state, nextPopOver);
|
|
181
|
+
});
|
|
182
|
+
const closeState = atom(null, (get, set, dismissIf?: string | { id?: string; name?: string }) => {
|
|
183
|
+
const prev = get(popOver.state);
|
|
184
|
+
const dismissIfId = typeof dismissIf === 'object' ? dismissIf.id : undefined;
|
|
185
|
+
const dismissIfName = typeof dismissIf === 'string' ? dismissIf : dismissIf?.name;
|
|
186
|
+
if (!prev || (dismissIfId && prev.id !== dismissIfId) || (dismissIfName && prev.name !== dismissIfName)) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
set(popOverIsHoverState, false);
|
|
191
|
+
const nextPopOver = popOver.close(prev);
|
|
192
|
+
set(popOver.state, nextPopOver);
|
|
193
|
+
if (!nextPopOver) {
|
|
194
|
+
set(popOver.eventState, null);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
/*
|
|
198
|
+
* Finish the rendered exit only if the same closing instance is still active.
|
|
199
|
+
*/
|
|
200
|
+
const completeCloseState = atom(null, (get, set, instanceId: string) => {
|
|
201
|
+
const current = get(popOver.state);
|
|
202
|
+
if (!current?.closing || current.instanceId !== instanceId) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
popOver.lastOpenId = null;
|
|
207
|
+
set(popOver.state, null);
|
|
208
|
+
set(popOver.eventState, null);
|
|
209
|
+
});
|
|
210
|
+
const updateState = atom(null, (get, set, data: UpdatePopOverParams) => {
|
|
211
|
+
const currentPopOver = get(popOver.state);
|
|
212
|
+
const nextPopOver = popOver.update(data, currentPopOver);
|
|
213
|
+
if (!nextPopOver) {
|
|
214
|
+
console.warn('{popOver} data should never be null when using update():', data);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (nextPopOver === currentPopOver) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
set(popOver.state, nextPopOver);
|
|
222
|
+
});
|
|
223
|
+
const publishEventState = atom(null, (get, set, data: PopOverEventParams) => {
|
|
224
|
+
const event = popOver.createEvent(data, get(popOver.state));
|
|
225
|
+
if (!event) {
|
|
226
|
+
console.warn('{popOver} data should never be null when publishing an event:', data);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
set(popOver.eventState, event);
|
|
231
|
+
});
|
|
232
|
+
const acknowledgeEventState = atom(null, (get, set, eventId: number) => {
|
|
233
|
+
if (get(popOver.eventState)?.eventId === eventId) {
|
|
234
|
+
set(popOver.eventState, null);
|
|
168
235
|
}
|
|
236
|
+
});
|
|
237
|
+
// Hard reset without the close animation; for when the popover/tooltip renderer unmounts
|
|
238
|
+
const resetState = atom(null, (_get, set) => {
|
|
239
|
+
popOver.lastOpenId = null;
|
|
240
|
+
set(popOverIsHoverState, false);
|
|
241
|
+
set(popOver.state, null);
|
|
242
|
+
set(popOver.eventState, null);
|
|
243
|
+
set(tooltipClass.state, tooltipClass.close());
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
return {
|
|
247
|
+
acknowledgeEventState,
|
|
248
|
+
closeState,
|
|
249
|
+
completeCloseState,
|
|
250
|
+
definitionState: popOver.state,
|
|
251
|
+
eventState: popOver.eventState,
|
|
252
|
+
openState,
|
|
253
|
+
publishEventState,
|
|
254
|
+
resetState,
|
|
255
|
+
updateState,
|
|
169
256
|
};
|
|
170
257
|
}
|
|
171
258
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
): ClosePopOverFn {
|
|
176
|
-
return (dismissIfName?: string) => {
|
|
177
|
-
setPopOverIsHover(false);
|
|
178
|
-
setPopOver((prev: PopOverProps | null) => {
|
|
179
|
-
if (
|
|
180
|
-
!prev ||
|
|
181
|
-
(typeof dismissIfName === 'string' && prev.name !== dismissIfName)
|
|
182
|
-
) {
|
|
183
|
-
return prev;
|
|
184
|
-
}
|
|
259
|
+
const sharedPopOverState = createPopOverStateAtoms();
|
|
260
|
+
export const resetPopOverState = sharedPopOverState.resetState;
|
|
261
|
+
const inactivePopOverState = atom(false);
|
|
185
262
|
|
|
186
|
-
|
|
187
|
-
|
|
263
|
+
/*
|
|
264
|
+
* Create an isolated imperative popover controller for non-React integrations and state tests.
|
|
265
|
+
*/
|
|
266
|
+
export function createPopOverController() {
|
|
267
|
+
const store = createStore();
|
|
268
|
+
const state = createPopOverStateAtoms();
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
acknowledgePopOverEvent: (eventId: number) => store.set(state.acknowledgeEventState, eventId),
|
|
272
|
+
closePopOver: (dismissIf?: string | { id?: string; name?: string }) => store.set(state.closeState, dismissIf),
|
|
273
|
+
completePopOverClose: (instanceId: string) => store.set(state.completeCloseState, instanceId),
|
|
274
|
+
getDefinition: () => store.get(state.definitionState),
|
|
275
|
+
getEvent: () => store.get(state.eventState),
|
|
276
|
+
openPopOver: (data: PopOverProps) => store.set(state.openState, data),
|
|
277
|
+
publishPopOverEvent: (data: PopOverEventParams) => store.set(state.publishEventState, data),
|
|
278
|
+
updatePopOver: (data: UpdatePopOverParams) => store.set(state.updateState, data),
|
|
188
279
|
};
|
|
189
280
|
}
|
|
190
281
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
282
|
+
/*
|
|
283
|
+
* Create stable commands for the shared popover definition and event atoms.
|
|
284
|
+
*/
|
|
285
|
+
export function usePopOverActions() {
|
|
286
|
+
const setOpenPopOver = useSetAtom(sharedPopOverState.openState);
|
|
287
|
+
const setClosePopOver = useSetAtom(sharedPopOverState.closeState);
|
|
288
|
+
const setCompletePopOverClose = useSetAtom(sharedPopOverState.completeCloseState);
|
|
289
|
+
const setUpdatePopOver = useSetAtom(sharedPopOverState.updateState);
|
|
290
|
+
const setPublishPopOverEvent = useSetAtom(sharedPopOverState.publishEventState);
|
|
291
|
+
const setAcknowledgePopOverEvent = useSetAtom(sharedPopOverState.acknowledgeEventState);
|
|
292
|
+
|
|
293
|
+
/*
|
|
294
|
+
* Acknowledge one event after its scoped consumer has handled it.
|
|
295
|
+
*/
|
|
296
|
+
const acknowledgePopOverEvent = useCallback<AcknowledgePopOverEventFn>((eventId: number) => setAcknowledgePopOverEvent(eventId), []);
|
|
297
|
+
/*
|
|
298
|
+
* Remove the closing instance after the renderer finishes its exit animation.
|
|
299
|
+
*/
|
|
300
|
+
const completePopOverClose = useCallback((instanceId: string) => setCompletePopOverClose(instanceId), []);
|
|
301
|
+
const openPopOver = useCallback<OpenPopOverFn>((data) => setOpenPopOver(data), []);
|
|
302
|
+
const closePopOver = useCallback<ClosePopOverFn>((dismissIf) => setClosePopOver(dismissIf), []);
|
|
303
|
+
const updatePopOver = useCallback<UpdatePopOverFn>((data) => setUpdatePopOver(data), []);
|
|
304
|
+
const publishPopOverEvent = useCallback<PublishPopOverEventFn>((data) => setPublishPopOverEvent(data), []);
|
|
305
|
+
|
|
306
|
+
return useMemo(
|
|
307
|
+
() => ({
|
|
308
|
+
acknowledgePopOverEvent,
|
|
309
|
+
openPopOver,
|
|
310
|
+
closePopOver,
|
|
311
|
+
completePopOverClose,
|
|
312
|
+
updatePopOver,
|
|
313
|
+
publishPopOverEvent,
|
|
314
|
+
}),
|
|
315
|
+
[acknowledgePopOverEvent, closePopOver, completePopOverClose, openPopOver, publishPopOverEvent, updatePopOver],
|
|
316
|
+
);
|
|
205
317
|
}
|
|
206
318
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
console.warn(
|
|
217
|
-
'{popOver} data should never be null when using setGlobalState():',
|
|
218
|
-
data,
|
|
219
|
-
);
|
|
220
|
-
return prev;
|
|
221
|
-
});
|
|
222
|
-
};
|
|
319
|
+
/**
|
|
320
|
+
* Return a stable function that clears the popover definition, event, hover,
|
|
321
|
+
* and tooltip state at once (no close animation). Use it when the component that
|
|
322
|
+
* renders popovers unmounts, so a stale popover can't reappear on remount.
|
|
323
|
+
*/
|
|
324
|
+
|
|
325
|
+
export function useResetPopOver() {
|
|
326
|
+
const setResetPopOver = useSetAtom(sharedPopOverState.resetState);
|
|
327
|
+
return useCallback(() => setResetPopOver(), []);
|
|
223
328
|
}
|
|
224
329
|
|
|
225
330
|
/**
|
|
226
|
-
*
|
|
331
|
+
* Read the active popover definition without subscribing to item events.
|
|
227
332
|
*/
|
|
228
333
|
|
|
229
|
-
export function
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
);
|
|
233
|
-
const setPopOverIsHover = useSetAtom(popOverIsHoverState);
|
|
334
|
+
export function usePopOverDefinition() {
|
|
335
|
+
return useAtomValue(sharedPopOverState.definitionState);
|
|
336
|
+
}
|
|
234
337
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
338
|
+
/*
|
|
339
|
+
* Read whether one popover id is active without subscribing the caller to the full definition object.
|
|
340
|
+
*/
|
|
341
|
+
export function usePopOverIsActive(popOverId: string | null | undefined) {
|
|
342
|
+
const isActiveState = useMemo(
|
|
343
|
+
() => (popOverId ? atom((get) => get(sharedPopOverState.definitionState)?.id === popOverId) : inactivePopOverState),
|
|
344
|
+
[popOverId],
|
|
239
345
|
);
|
|
240
|
-
const updatePopOver = useCallback(composeUpdatePopOverFn(setPopOver), []);
|
|
241
|
-
const setPopOverState = useCallback(composeSetPopOverState(setPopOver), []);
|
|
242
346
|
|
|
243
|
-
return
|
|
244
|
-
popOver,
|
|
245
|
-
openPopOver,
|
|
246
|
-
closePopOver,
|
|
247
|
-
updatePopOver,
|
|
248
|
-
setPopOverState,
|
|
249
|
-
};
|
|
347
|
+
return useAtomValue(isActiveState);
|
|
250
348
|
}
|
|
251
349
|
|
|
252
350
|
/**
|
|
253
|
-
*
|
|
351
|
+
* Read only events emitted by a requested popover id or open instance.
|
|
254
352
|
*/
|
|
255
353
|
|
|
256
|
-
export function
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
[],
|
|
265
|
-
);
|
|
354
|
+
export function usePopOverEvent(filter: PopOverEventFilter = {}) {
|
|
355
|
+
const event = useAtomValue(sharedPopOverState.eventState);
|
|
356
|
+
if (
|
|
357
|
+
(filter.instanceId !== undefined && event?.instanceId !== filter.instanceId) ||
|
|
358
|
+
(filter.popOverId !== undefined && event?.id !== filter.popOverId)
|
|
359
|
+
) {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
266
362
|
|
|
267
|
-
return
|
|
268
|
-
popOver: popOver?.globalState,
|
|
269
|
-
closePopOver,
|
|
270
|
-
updatePopOver,
|
|
271
|
-
};
|
|
363
|
+
return event;
|
|
272
364
|
}
|
|
273
365
|
|
|
274
366
|
/**
|
|
@@ -276,19 +368,25 @@ export function usePopOverState() {
|
|
|
276
368
|
*/
|
|
277
369
|
|
|
278
370
|
export function useClosePopOver(): ClosePopOverFn {
|
|
279
|
-
const
|
|
280
|
-
const setPopOverIsHover = useSetAtom(popOverIsHoverState);
|
|
371
|
+
const setClosePopOver = useSetAtom(sharedPopOverState.closeState);
|
|
281
372
|
|
|
282
|
-
return useCallback(
|
|
373
|
+
return useCallback((dismissIf) => setClosePopOver(dismissIf), []);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/*
|
|
377
|
+
* Return only the stable command used to open a popover.
|
|
378
|
+
*/
|
|
379
|
+
export function useOpenPopOver(): OpenPopOverFn {
|
|
380
|
+
const setOpenPopOver = useSetAtom(sharedPopOverState.openState);
|
|
381
|
+
|
|
382
|
+
return useCallback((data) => setOpenPopOver(data), []);
|
|
283
383
|
}
|
|
284
384
|
|
|
285
385
|
/**
|
|
286
386
|
* Create handlers functions for tooltips
|
|
287
387
|
*/
|
|
288
388
|
|
|
289
|
-
function composeOpenTooltipFn(
|
|
290
|
-
setTooltip: (value: TooltipProps | null) => void,
|
|
291
|
-
): OpenTooltipFn {
|
|
389
|
+
function composeOpenTooltipFn(setTooltip: (value: TooltipProps | null) => void): OpenTooltipFn {
|
|
292
390
|
return (data: TooltipProps) => {
|
|
293
391
|
const nextTooltipState = tooltipClass.open(data);
|
|
294
392
|
if (nextTooltipState) {
|
|
@@ -299,9 +397,7 @@ function composeOpenTooltipFn(
|
|
|
299
397
|
};
|
|
300
398
|
}
|
|
301
399
|
|
|
302
|
-
function composeCloseTooltipFn(
|
|
303
|
-
setTooltip: (value: TooltipProps | null) => void,
|
|
304
|
-
): CloseTooltipFn {
|
|
400
|
+
function composeCloseTooltipFn(setTooltip: (value: TooltipProps | null) => void): CloseTooltipFn {
|
|
305
401
|
return (removeId?: string) => {
|
|
306
402
|
if (!removeId) {
|
|
307
403
|
return;
|
|
@@ -317,9 +413,7 @@ function composeCloseTooltipFn(
|
|
|
317
413
|
};
|
|
318
414
|
}
|
|
319
415
|
|
|
320
|
-
function composeUpdateTooltipFn(
|
|
321
|
-
setTooltip: (value: TooltipProps | null) => void,
|
|
322
|
-
): UpdateTooltipFn {
|
|
416
|
+
function composeUpdateTooltipFn(setTooltip: (value: TooltipProps | null) => void): UpdateTooltipFn {
|
|
323
417
|
return (data: TooltipProps) => {
|
|
324
418
|
// @ts-expect-error - I couldn't get rid of this type error
|
|
325
419
|
setTooltip((prev: TooltipProps | null) => {
|
|
@@ -339,9 +433,7 @@ function composeUpdateTooltipFn(
|
|
|
339
433
|
*/
|
|
340
434
|
|
|
341
435
|
export function useTooltip(): TooltipHookProps {
|
|
342
|
-
const [tooltip, setTooltip] = useAtom<TooltipProps | null>(
|
|
343
|
-
tooltipClass.state,
|
|
344
|
-
);
|
|
436
|
+
const [tooltip, setTooltip] = useAtom<TooltipProps | null>(tooltipClass.state);
|
|
345
437
|
|
|
346
438
|
const openTooltip = useCallback(composeOpenTooltipFn(setTooltip), []);
|
|
347
439
|
const closeTooltip = useCallback(composeCloseTooltipFn(setTooltip), []);
|
package/states/uploads.ts
CHANGED
|
@@ -30,7 +30,6 @@ export function useUploadsValue() {
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
export function useUploadActions() {
|
|
33
|
-
const uploads = useAtomValue(uploadsState);
|
|
34
33
|
const setUploads = useSetAtom(uploadsState);
|
|
35
34
|
|
|
36
35
|
const startUploadProgress = useCallback(
|
|
@@ -64,7 +63,6 @@ export function useUploadActions() {
|
|
|
64
63
|
);
|
|
65
64
|
|
|
66
65
|
return {
|
|
67
|
-
uploads,
|
|
68
66
|
startUploadProgress,
|
|
69
67
|
updateUploadProgress,
|
|
70
68
|
removeUploadProgress,
|