@jsb188/react 1.1.10 → 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 -16
- package/states/appContext.ts +364 -311
- package/states/connected.ts +135 -11
- package/states/index.ts +1 -1
- package/states/keyDown.ts +32 -27
- package/states/modal.ts +291 -260
- package/states/popOver.ts +268 -229
- package/states/reactiveEvents.ts +56 -0
- package/states/uploads.ts +41 -27
- package/types/PopOver.d.ts +424 -230
- package/utils/hooks.ts +306 -271
- package/utils/schema.ts +144 -132
- package/states/toasts.ts +0 -30
package/states/modal.ts
CHANGED
|
@@ -8,53 +8,58 @@ import { useCallback } from 'react';
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
interface ModalRequestParams {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
name: string;
|
|
12
|
+
preset?: string;
|
|
13
|
+
color?: ColorEnum | null;
|
|
14
|
+
props?: Record<string, any>;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface ModalProps {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
name: string;
|
|
19
|
+
preset: string | null;
|
|
20
|
+
modalSessionKey?: string;
|
|
21
|
+
[key: string]: any;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface ModalPopUpComponentProps {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// Can't extend ModalProps because [key: string]: any; nullifies the type checking
|
|
26
|
+
name: string;
|
|
27
|
+
preset: string | null;
|
|
28
28
|
onCloseModal: () => void;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
type ModalPropsFn = (prev: ModalProps | null) => ModalProps | null;
|
|
32
32
|
type ModalScreenSetter = (
|
|
33
|
-
|
|
33
|
+
value: ModalProps | null | ((prev: ModalProps | null) => ModalProps | null),
|
|
34
34
|
) => void;
|
|
35
35
|
|
|
36
|
-
export type OpenModalScreenFn = (
|
|
36
|
+
export type OpenModalScreenFn = (
|
|
37
|
+
data: ModalRequestParams | ModalPropsFn,
|
|
38
|
+
) => void;
|
|
37
39
|
|
|
38
|
-
export type OpenModalPopUpFn = (
|
|
40
|
+
export type OpenModalPopUpFn = (
|
|
41
|
+
data: ModalRequestParams | null,
|
|
42
|
+
err?: Partial<ServerErrorObj>,
|
|
43
|
+
) => void;
|
|
39
44
|
|
|
40
45
|
export interface ModalScreenProps {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
screen: ModalProps | null;
|
|
47
|
+
openModalScreen: OpenModalScreenFn;
|
|
48
|
+
closeModalScreen: () => void;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
export interface ModalPopUpProps {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
popUp: ModalProps | null;
|
|
53
|
+
openModalPopUp: OpenModalPopUpFn;
|
|
54
|
+
closeModalPopUp: () => void;
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
export interface ModalHandlerProps {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
color?: ColorEnum | null;
|
|
59
|
+
openModalScreen: OpenModalScreenFn;
|
|
60
|
+
openModalPopUp: OpenModalPopUpFn;
|
|
61
|
+
closeModalScreen: () => void;
|
|
62
|
+
closeModalPopUp: () => void;
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
export interface ModalHookProps extends ModalScreenProps, ModalPopUpProps {}
|
|
@@ -65,50 +70,50 @@ export interface ModalHookProps extends ModalScreenProps, ModalPopUpProps {}
|
|
|
65
70
|
*/
|
|
66
71
|
|
|
67
72
|
export const POPUP_DEFAULT_VALUES = {
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
+
},
|
|
112
117
|
} as Record<string, Record<string, string>>;
|
|
113
118
|
|
|
114
119
|
/**
|
|
@@ -116,37 +121,37 @@ export const POPUP_DEFAULT_VALUES = {
|
|
|
116
121
|
*/
|
|
117
122
|
|
|
118
123
|
class ModalScreen {
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
+
}
|
|
150
155
|
}
|
|
151
156
|
|
|
152
157
|
/*
|
|
@@ -154,7 +159,7 @@ class ModalScreen {
|
|
|
154
159
|
*/
|
|
155
160
|
|
|
156
161
|
function getModalScreenSessionKey() {
|
|
157
|
-
|
|
162
|
+
return `modal-screen-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
158
163
|
}
|
|
159
164
|
|
|
160
165
|
/**
|
|
@@ -162,79 +167,87 @@ function getModalScreenSessionKey() {
|
|
|
162
167
|
*/
|
|
163
168
|
|
|
164
169
|
class ModalPopUp extends ModalScreen {
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
+
}
|
|
238
251
|
}
|
|
239
252
|
|
|
240
253
|
/**
|
|
@@ -253,21 +266,23 @@ const popUpClass = new ModalPopUp('popup', POPUP_DEFAULT_VALUES);
|
|
|
253
266
|
*/
|
|
254
267
|
|
|
255
268
|
function getNextModalScreenState(
|
|
256
|
-
|
|
257
|
-
|
|
269
|
+
data: ModalRequestParams | ModalPropsFn,
|
|
270
|
+
prevScreen: ModalProps | null,
|
|
258
271
|
) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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;
|
|
271
286
|
}
|
|
272
287
|
|
|
273
288
|
/*
|
|
@@ -275,41 +290,45 @@ function getNextModalScreenState(
|
|
|
275
290
|
*/
|
|
276
291
|
|
|
277
292
|
function composeOpenModalScreenFn(setScreen: ModalScreenSetter) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
+
};
|
|
290
305
|
}
|
|
291
306
|
|
|
292
|
-
function composeCloseModalScreenFn(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
307
|
+
function composeCloseModalScreenFn(
|
|
308
|
+
setScreen: (value: ModalProps | null) => void,
|
|
309
|
+
) {
|
|
310
|
+
return () => {
|
|
311
|
+
setScreen(screenClass.close());
|
|
312
|
+
};
|
|
296
313
|
}
|
|
297
314
|
|
|
298
315
|
function composeOpenModalPopUpFn(setPopUp: (value: ModalProps | null) => void) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
+
};
|
|
307
324
|
}
|
|
308
325
|
|
|
309
|
-
function composeCloseModalPopUpFn(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
326
|
+
function composeCloseModalPopUpFn(
|
|
327
|
+
setPopUp: (value: ModalProps | null) => void,
|
|
328
|
+
) {
|
|
329
|
+
return () => {
|
|
330
|
+
setPopUp(popUpClass.close());
|
|
331
|
+
};
|
|
313
332
|
}
|
|
314
333
|
|
|
315
334
|
/**
|
|
@@ -317,15 +336,20 @@ function composeCloseModalPopUpFn(setPopUp: (value: ModalProps | null) => void)
|
|
|
317
336
|
*/
|
|
318
337
|
|
|
319
338
|
export function useModalScreen(): ModalScreenProps {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
+
};
|
|
329
353
|
}
|
|
330
354
|
|
|
331
355
|
/**
|
|
@@ -333,10 +357,12 @@ export function useModalScreen(): ModalScreenProps {
|
|
|
333
357
|
*/
|
|
334
358
|
|
|
335
359
|
export function useOpenModalScreen(): OpenModalScreenFn {
|
|
336
|
-
|
|
337
|
-
|
|
360
|
+
const setScreen = useSetAtom(screenClass.state);
|
|
361
|
+
const openModalScreen = useCallback(composeOpenModalScreenFn(setScreen), [
|
|
362
|
+
setScreen,
|
|
363
|
+
]);
|
|
338
364
|
|
|
339
|
-
|
|
365
|
+
return openModalScreen;
|
|
340
366
|
}
|
|
341
367
|
|
|
342
368
|
/**
|
|
@@ -344,15 +370,15 @@ export function useOpenModalScreen(): OpenModalScreenFn {
|
|
|
344
370
|
*/
|
|
345
371
|
|
|
346
372
|
export function useModalPopUp(): ModalPopUpProps {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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
|
+
};
|
|
356
382
|
}
|
|
357
383
|
|
|
358
384
|
/**
|
|
@@ -360,20 +386,25 @@ export function useModalPopUp(): ModalPopUpProps {
|
|
|
360
386
|
*/
|
|
361
387
|
|
|
362
388
|
export function useModalHandlers(): ModalHandlerProps {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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
|
+
};
|
|
377
408
|
}
|
|
378
409
|
|
|
379
410
|
/**
|
|
@@ -381,10 +412,10 @@ export function useModalHandlers(): ModalHandlerProps {
|
|
|
381
412
|
*/
|
|
382
413
|
|
|
383
414
|
export function useOpenModalPopUp(): OpenModalPopUpFn {
|
|
384
|
-
|
|
385
|
-
|
|
415
|
+
const setPopUp = useSetAtom(popUpClass.state);
|
|
416
|
+
const openModalPopUp = useCallback(composeOpenModalPopUpFn(setPopUp), []);
|
|
386
417
|
|
|
387
|
-
|
|
418
|
+
return openModalPopUp;
|
|
388
419
|
}
|
|
389
420
|
|
|
390
421
|
/**
|
|
@@ -392,11 +423,11 @@ export function useOpenModalPopUp(): OpenModalPopUpFn {
|
|
|
392
423
|
*/
|
|
393
424
|
|
|
394
425
|
export function useModal(): ModalHookProps {
|
|
395
|
-
|
|
396
|
-
|
|
426
|
+
const screenProps = useModalScreen();
|
|
427
|
+
const popUpProps = useModalPopUp();
|
|
397
428
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
429
|
+
return {
|
|
430
|
+
...screenProps,
|
|
431
|
+
...popUpProps,
|
|
432
|
+
};
|
|
402
433
|
}
|