@jsb188/react 1.1.8 → 1.1.11
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/package.json +20 -20
- package/states/apiData.ts +18 -14
- package/states/appContext.ts +366 -314
- package/states/connected.ts +135 -11
- package/states/index.ts +1 -1
- package/states/keyDown.ts +32 -27
- package/states/modal.ts +314 -243
- package/states/popOver.ts +270 -223
- package/states/reactiveEvents.ts +56 -0
- package/states/uploads.ts +41 -27
- package/types/PopOver.d.ts +461 -205
- package/utils/hooks.ts +319 -249
- package/utils/schema.ts +146 -129
- package/states/toasts.ts +0 -30
package/states/modal.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import i18n from '@jsb188/app/i18n';
|
|
2
|
-
import type { ServerErrorObj } from '@jsb188/app/types/app.d';
|
|
1
|
+
import i18n from '@jsb188/app/i18n/index.ts';
|
|
2
|
+
import type { ColorEnum, ServerErrorObj } from '@jsb188/app/types/app.d.ts';
|
|
3
3
|
import { atom, useAtom, useSetAtom } from 'jotai';
|
|
4
4
|
import { useCallback } from 'react';
|
|
5
5
|
|
|
@@ -8,47 +8,58 @@ import { useCallback } from 'react';
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
interface ModalRequestParams {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
name: string;
|
|
12
|
+
preset?: string;
|
|
13
|
+
color?: ColorEnum | null;
|
|
14
|
+
props?: Record<string, any>;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export interface ModalProps {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
name: string;
|
|
19
|
+
preset: string | null;
|
|
20
|
+
modalSessionKey?: string;
|
|
21
|
+
[key: string]: any;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export interface ModalPopUpComponentProps {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
// Can't extend ModalProps because [key: string]: any; nullifies the type checking
|
|
26
|
+
name: string;
|
|
27
|
+
preset: string | null;
|
|
26
28
|
onCloseModal: () => void;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
type ModalPropsFn = (prev: ModalProps | null) => ModalProps | null;
|
|
32
|
+
type ModalScreenSetter = (
|
|
33
|
+
value: ModalProps | null | ((prev: ModalProps | null) => ModalProps | null),
|
|
34
|
+
) => void;
|
|
30
35
|
|
|
31
|
-
export type OpenModalScreenFn = (
|
|
36
|
+
export type OpenModalScreenFn = (
|
|
37
|
+
data: ModalRequestParams | ModalPropsFn,
|
|
38
|
+
) => void;
|
|
32
39
|
|
|
33
|
-
export type OpenModalPopUpFn = (
|
|
40
|
+
export type OpenModalPopUpFn = (
|
|
41
|
+
data: ModalRequestParams | null,
|
|
42
|
+
err?: Partial<ServerErrorObj>,
|
|
43
|
+
) => void;
|
|
34
44
|
|
|
35
45
|
export interface ModalScreenProps {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
screen: ModalProps | null;
|
|
47
|
+
openModalScreen: OpenModalScreenFn;
|
|
48
|
+
closeModalScreen: () => void;
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
export interface ModalPopUpProps {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
popUp: ModalProps | null;
|
|
53
|
+
openModalPopUp: OpenModalPopUpFn;
|
|
54
|
+
closeModalPopUp: () => void;
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
export interface ModalHandlerProps {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
color?: ColorEnum | null;
|
|
59
|
+
openModalScreen: OpenModalScreenFn;
|
|
60
|
+
openModalPopUp: OpenModalPopUpFn;
|
|
61
|
+
closeModalScreen: () => void;
|
|
62
|
+
closeModalPopUp: () => void;
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
export interface ModalHookProps extends ModalScreenProps, ModalPopUpProps {}
|
|
@@ -59,53 +70,50 @@ export interface ModalHookProps extends ModalScreenProps, ModalPopUpProps {}
|
|
|
59
70
|
*/
|
|
60
71
|
|
|
61
72
|
export const POPUP_DEFAULT_VALUES = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
title: 'error.login_changed',
|
|
107
|
-
iconName: 'user-question',
|
|
108
|
-
},
|
|
73
|
+
app_error: {
|
|
74
|
+
iconName: 'file-broken',
|
|
75
|
+
title: 'error.app_error_title',
|
|
76
|
+
message: 'error.app_error',
|
|
77
|
+
},
|
|
78
|
+
chat_not_live_feature: {
|
|
79
|
+
iconName: 'message-cancel',
|
|
80
|
+
title: 'chat.is_offline',
|
|
81
|
+
message: 'chat.must_be_live_feature',
|
|
82
|
+
},
|
|
83
|
+
not_verified_email: {
|
|
84
|
+
iconName: 'mailbox',
|
|
85
|
+
title: 'form.check_email',
|
|
86
|
+
message: 'auth.not_verified_yet',
|
|
87
|
+
},
|
|
88
|
+
not_allowed_permission: {
|
|
89
|
+
iconName: 'lock',
|
|
90
|
+
title: 'error.not_allowed',
|
|
91
|
+
message: 'error.not_allowed_perms',
|
|
92
|
+
},
|
|
93
|
+
network_error: {
|
|
94
|
+
iconName: 'wifi-off',
|
|
95
|
+
title: 'error.network_error_title',
|
|
96
|
+
message: 'error.network_error',
|
|
97
|
+
},
|
|
98
|
+
external_link: {
|
|
99
|
+
iconName: 'outbound',
|
|
100
|
+
title: 'app.leaving_app',
|
|
101
|
+
message: 'app.leaving_app_desc',
|
|
102
|
+
confirmText: 'app.link_yes',
|
|
103
|
+
},
|
|
104
|
+
'20020': {
|
|
105
|
+
// Not allowed in chat
|
|
106
|
+
iconName: 'lock-square-rounded-filled',
|
|
107
|
+
},
|
|
108
|
+
'10000': {
|
|
109
|
+
preset: 'force_reload',
|
|
110
|
+
// iconName: '..', // This is controlled via i18n now
|
|
111
|
+
},
|
|
112
|
+
'10012': {
|
|
113
|
+
preset: 'force_reload',
|
|
114
|
+
title: 'error.login_changed',
|
|
115
|
+
iconName: 'question-circle', // Deprecated; icon names are controlled via i18n now
|
|
116
|
+
},
|
|
109
117
|
} as Record<string, Record<string, string>>;
|
|
110
118
|
|
|
111
119
|
/**
|
|
@@ -113,35 +121,45 @@ export const POPUP_DEFAULT_VALUES = {
|
|
|
113
121
|
*/
|
|
114
122
|
|
|
115
123
|
class ModalScreen {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
124
|
+
readonly name: string;
|
|
125
|
+
readonly state = atom<ModalProps | null>(null);
|
|
126
|
+
readonly defaultValues?: Record<string, any>;
|
|
127
|
+
|
|
128
|
+
constructor(name: string, defaultValues?: Record<string, any>) {
|
|
129
|
+
this.name = `modal_${name}_state`;
|
|
130
|
+
if (defaultValues) {
|
|
131
|
+
this.defaultValues = defaultValues;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
open(data: ModalRequestParams): ModalProps | null {
|
|
136
|
+
if (data) {
|
|
137
|
+
const { name, color, props } = data;
|
|
138
|
+
const values = this.defaultValues?.[name ?? ''];
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
name,
|
|
142
|
+
color,
|
|
143
|
+
...values,
|
|
144
|
+
...props,
|
|
145
|
+
modalSessionKey: getModalScreenSessionKey(),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
close() {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
* Create a unique session key for each fresh modal screen open request.
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
function getModalScreenSessionKey() {
|
|
162
|
+
return `modal-screen-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
145
163
|
}
|
|
146
164
|
|
|
147
165
|
/**
|
|
@@ -149,79 +167,87 @@ class ModalScreen {
|
|
|
149
167
|
*/
|
|
150
168
|
|
|
151
169
|
class ModalPopUp extends ModalScreen {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
170
|
+
readonly name: string = 'modal_popup_state';
|
|
171
|
+
|
|
172
|
+
open(
|
|
173
|
+
data: ModalRequestParams | null,
|
|
174
|
+
error?: Partial<ServerErrorObj>,
|
|
175
|
+
): ModalProps | null {
|
|
176
|
+
if (data) {
|
|
177
|
+
const { preset, name, props } = data;
|
|
178
|
+
const values = this.defaultValues?.[name ?? ''];
|
|
179
|
+
|
|
180
|
+
let updatedAlertValue: ModalProps = {
|
|
181
|
+
// Template values
|
|
182
|
+
name,
|
|
183
|
+
preset: preset || 'normal',
|
|
184
|
+
// Alert props
|
|
185
|
+
id: `alert-${name || 'normal'}`,
|
|
186
|
+
iconName: null,
|
|
187
|
+
title: '',
|
|
188
|
+
message: '',
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
if (values?.iconName) {
|
|
192
|
+
updatedAlertValue.iconName = values.iconName;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// NOTE: i18n() isn't ready yet, so I have to use i18n.t(..) in the logic
|
|
196
|
+
['title', 'message', 'confirmText', 'cancelText'].forEach((key) => {
|
|
197
|
+
if (values?.[key]) {
|
|
198
|
+
updatedAlertValue[key] = i18n.t(values[key]);
|
|
199
|
+
} else if (key === 'message' && i18n.has(`error.${name}`)) {
|
|
200
|
+
updatedAlertValue[key] = i18n.t(`error.${name}`);
|
|
201
|
+
} else if (i18n.has(`error.${name}_${key}`)) {
|
|
202
|
+
updatedAlertValue[key] = i18n.t(`error.${name}_${key}`);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
if (values?.preset) {
|
|
207
|
+
updatedAlertValue.preset = values.preset;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (props) {
|
|
211
|
+
updatedAlertValue = {
|
|
212
|
+
...updatedAlertValue,
|
|
213
|
+
...props,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (!updatedAlertValue.title && !isNaN(Number(name))) {
|
|
218
|
+
updatedAlertValue.title = i18n.t('error.error');
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return updatedAlertValue;
|
|
222
|
+
} else if (error) {
|
|
223
|
+
const { errorCode } = error;
|
|
224
|
+
const {
|
|
225
|
+
iconName: defIconName,
|
|
226
|
+
title: defTitle,
|
|
227
|
+
message: defMessage,
|
|
228
|
+
...values
|
|
229
|
+
} = this.defaultValues?.[errorCode ?? ''] || {};
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
// Template values
|
|
233
|
+
name: 'ERROR',
|
|
234
|
+
preset: 'normal',
|
|
235
|
+
// Alert props
|
|
236
|
+
id: `gql-${errorCode}`,
|
|
237
|
+
iconName: error.iconName || defIconName,
|
|
238
|
+
title: error.title || defTitle || i18n.t('error.error'),
|
|
239
|
+
message:
|
|
240
|
+
error.message || defMessage || i18n.t('error.unknown_error_msg'),
|
|
241
|
+
...values,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
close() {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
225
251
|
}
|
|
226
252
|
|
|
227
253
|
/**
|
|
@@ -235,41 +261,74 @@ const popUpClass = new ModalPopUp('popup', POPUP_DEFAULT_VALUES);
|
|
|
235
261
|
* Create handler functions
|
|
236
262
|
*/
|
|
237
263
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
264
|
+
/*
|
|
265
|
+
* Build the next modal screen state from either a direct open request or a state updater function.
|
|
266
|
+
*/
|
|
267
|
+
|
|
268
|
+
function getNextModalScreenState(
|
|
269
|
+
data: ModalRequestParams | ModalPropsFn,
|
|
270
|
+
prevScreen: ModalProps | null,
|
|
241
271
|
) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
272
|
+
const isStateUpdater = typeof data === 'function';
|
|
273
|
+
const nextScreenValue = isStateUpdater
|
|
274
|
+
? data(prevScreen)
|
|
275
|
+
: screenClass.open(data);
|
|
276
|
+
|
|
277
|
+
return isStateUpdater &&
|
|
278
|
+
nextScreenValue &&
|
|
279
|
+
prevScreen?.modalSessionKey &&
|
|
280
|
+
!nextScreenValue.modalSessionKey
|
|
281
|
+
? {
|
|
282
|
+
...nextScreenValue,
|
|
283
|
+
modalSessionKey: prevScreen.modalSessionKey,
|
|
284
|
+
}
|
|
285
|
+
: nextScreenValue;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/*
|
|
289
|
+
* Compose a stable modal screen open function that reads the latest screen state from the atom setter.
|
|
290
|
+
*/
|
|
291
|
+
|
|
292
|
+
function composeOpenModalScreenFn(setScreen: ModalScreenSetter) {
|
|
293
|
+
return (data: ModalRequestParams | ModalPropsFn) => {
|
|
294
|
+
setScreen((prevScreen) => {
|
|
295
|
+
const nextScreenState = getNextModalScreenState(data, prevScreen);
|
|
296
|
+
|
|
297
|
+
if (nextScreenState) {
|
|
298
|
+
return nextScreenState;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
console.warn('Invalid {screen} data:', data);
|
|
302
|
+
return prevScreen;
|
|
303
|
+
});
|
|
304
|
+
};
|
|
250
305
|
}
|
|
251
306
|
|
|
252
|
-
function composeCloseModalScreenFn(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
307
|
+
function composeCloseModalScreenFn(
|
|
308
|
+
setScreen: (value: ModalProps | null) => void,
|
|
309
|
+
) {
|
|
310
|
+
return () => {
|
|
311
|
+
setScreen(screenClass.close());
|
|
312
|
+
};
|
|
256
313
|
}
|
|
257
314
|
|
|
258
315
|
function composeOpenModalPopUpFn(setPopUp: (value: ModalProps | null) => void) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
316
|
+
return (data: ModalRequestParams | null, err?: Partial<ServerErrorObj>) => {
|
|
317
|
+
const nextPopUpState = popUpClass.open(data, err);
|
|
318
|
+
if (nextPopUpState) {
|
|
319
|
+
setPopUp(nextPopUpState);
|
|
320
|
+
} else {
|
|
321
|
+
console.warn('Invalid {popUp} data:', data, err);
|
|
322
|
+
}
|
|
323
|
+
};
|
|
267
324
|
}
|
|
268
325
|
|
|
269
|
-
function composeCloseModalPopUpFn(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
326
|
+
function composeCloseModalPopUpFn(
|
|
327
|
+
setPopUp: (value: ModalProps | null) => void,
|
|
328
|
+
) {
|
|
329
|
+
return () => {
|
|
330
|
+
setPopUp(popUpClass.close());
|
|
331
|
+
};
|
|
273
332
|
}
|
|
274
333
|
|
|
275
334
|
/**
|
|
@@ -277,15 +336,20 @@ function composeCloseModalPopUpFn(setPopUp: (value: ModalProps | null) => void)
|
|
|
277
336
|
*/
|
|
278
337
|
|
|
279
338
|
export function useModalScreen(): ModalScreenProps {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
339
|
+
const [screen, setScreen] = useAtom(screenClass.state);
|
|
340
|
+
const openModalScreen = useCallback(composeOpenModalScreenFn(setScreen), [
|
|
341
|
+
setScreen,
|
|
342
|
+
]);
|
|
343
|
+
const closeModalScreen = useCallback(
|
|
344
|
+
composeCloseModalScreenFn(setScreen),
|
|
345
|
+
[],
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
return {
|
|
349
|
+
screen,
|
|
350
|
+
openModalScreen,
|
|
351
|
+
closeModalScreen,
|
|
352
|
+
};
|
|
289
353
|
}
|
|
290
354
|
|
|
291
355
|
/**
|
|
@@ -293,10 +357,12 @@ export function useModalScreen(): ModalScreenProps {
|
|
|
293
357
|
*/
|
|
294
358
|
|
|
295
359
|
export function useOpenModalScreen(): OpenModalScreenFn {
|
|
296
|
-
|
|
297
|
-
|
|
360
|
+
const setScreen = useSetAtom(screenClass.state);
|
|
361
|
+
const openModalScreen = useCallback(composeOpenModalScreenFn(setScreen), [
|
|
362
|
+
setScreen,
|
|
363
|
+
]);
|
|
298
364
|
|
|
299
|
-
|
|
365
|
+
return openModalScreen;
|
|
300
366
|
}
|
|
301
367
|
|
|
302
368
|
/**
|
|
@@ -304,15 +370,15 @@ export function useOpenModalScreen(): OpenModalScreenFn {
|
|
|
304
370
|
*/
|
|
305
371
|
|
|
306
372
|
export function useModalPopUp(): ModalPopUpProps {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
373
|
+
const [popUp, setPopUp] = useAtom(popUpClass.state);
|
|
374
|
+
const openModalPopUp = useCallback(composeOpenModalPopUpFn(setPopUp), []);
|
|
375
|
+
const closeModalPopUp = useCallback(composeCloseModalPopUpFn(setPopUp), []);
|
|
376
|
+
|
|
377
|
+
return {
|
|
378
|
+
popUp,
|
|
379
|
+
openModalPopUp,
|
|
380
|
+
closeModalPopUp,
|
|
381
|
+
};
|
|
316
382
|
}
|
|
317
383
|
|
|
318
384
|
/**
|
|
@@ -320,20 +386,25 @@ export function useModalPopUp(): ModalPopUpProps {
|
|
|
320
386
|
*/
|
|
321
387
|
|
|
322
388
|
export function useModalHandlers(): ModalHandlerProps {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
389
|
+
const setScreen = useSetAtom(screenClass.state);
|
|
390
|
+
const setPopUp = useSetAtom(popUpClass.state);
|
|
391
|
+
|
|
392
|
+
const openModalScreen = useCallback(composeOpenModalScreenFn(setScreen), [
|
|
393
|
+
setScreen,
|
|
394
|
+
]);
|
|
395
|
+
const closeModalScreen = useCallback(
|
|
396
|
+
composeCloseModalScreenFn(setScreen),
|
|
397
|
+
[],
|
|
398
|
+
);
|
|
399
|
+
const openModalPopUp = useCallback(composeOpenModalPopUpFn(setPopUp), []);
|
|
400
|
+
const closeModalPopUp = useCallback(composeCloseModalPopUpFn(setPopUp), []);
|
|
401
|
+
|
|
402
|
+
return {
|
|
403
|
+
openModalScreen,
|
|
404
|
+
closeModalScreen,
|
|
405
|
+
openModalPopUp,
|
|
406
|
+
closeModalPopUp,
|
|
407
|
+
};
|
|
337
408
|
}
|
|
338
409
|
|
|
339
410
|
/**
|
|
@@ -341,10 +412,10 @@ export function useModalHandlers(): ModalHandlerProps {
|
|
|
341
412
|
*/
|
|
342
413
|
|
|
343
414
|
export function useOpenModalPopUp(): OpenModalPopUpFn {
|
|
344
|
-
|
|
345
|
-
|
|
415
|
+
const setPopUp = useSetAtom(popUpClass.state);
|
|
416
|
+
const openModalPopUp = useCallback(composeOpenModalPopUpFn(setPopUp), []);
|
|
346
417
|
|
|
347
|
-
|
|
418
|
+
return openModalPopUp;
|
|
348
419
|
}
|
|
349
420
|
|
|
350
421
|
/**
|
|
@@ -352,11 +423,11 @@ export function useOpenModalPopUp(): OpenModalPopUpFn {
|
|
|
352
423
|
*/
|
|
353
424
|
|
|
354
425
|
export function useModal(): ModalHookProps {
|
|
355
|
-
|
|
356
|
-
|
|
426
|
+
const screenProps = useModalScreen();
|
|
427
|
+
const popUpProps = useModalPopUp();
|
|
357
428
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
429
|
+
return {
|
|
430
|
+
...screenProps,
|
|
431
|
+
...popUpProps,
|
|
432
|
+
};
|
|
362
433
|
}
|