dce-reactkit 3.5.4 → 3.5.5
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/cjs/index.js +65 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/AppWrapper.d.ts +5 -0
- package/dist/cjs/types/components/ToggleSwitch.d.ts +20 -0
- package/dist/cjs/types/index.d.ts +3 -2
- package/dist/esm/index.js +64 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/AppWrapper.d.ts +5 -0
- package/dist/esm/types/components/ToggleSwitch.d.ts +20 -0
- package/dist/esm/types/index.d.ts +3 -2
- package/dist/index.d.ts +63 -39
- package/package.json +1 -1
- package/src/components/AppWrapper.tsx +52 -34
- package/src/components/ToggleSwitch.tsx +102 -0
- package/src/index.ts +9 -1
|
@@ -44,6 +44,11 @@ export declare const confirm: (title: string, text: string, opts?: {
|
|
|
44
44
|
* @param [errorTitle] title of the error box
|
|
45
45
|
*/
|
|
46
46
|
export declare const showFatalError: (error: any, errorTitle?: string) => undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Add a handler for when a fatal error occurs
|
|
49
|
+
* @author Gabe Abrams
|
|
50
|
+
*/
|
|
51
|
+
export declare const addFatalErrorHandler: (handler: () => void) => void;
|
|
47
52
|
/**
|
|
48
53
|
* Show the "session expired" message
|
|
49
54
|
* @author Gabe Abrams
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A toggle switch that toggles on or off
|
|
3
|
+
* @author Alessandra De Lucas
|
|
4
|
+
* @author Gabe Abrams
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import Variant from '../types/Variant';
|
|
8
|
+
type Props = {
|
|
9
|
+
isOn: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* A handler to call when the switch is toggled
|
|
12
|
+
* @param isOn Updated value for isOn
|
|
13
|
+
*/
|
|
14
|
+
onToggle: (isOn: boolean) => void;
|
|
15
|
+
id?: string;
|
|
16
|
+
description: string;
|
|
17
|
+
backgroundVariantWhenOn?: Variant;
|
|
18
|
+
};
|
|
19
|
+
declare const ToggleSwitch: React.FC<Props>;
|
|
20
|
+
export default ToggleSwitch;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import AppWrapper, { alert, confirm, showFatalError } from './components/AppWrapper';
|
|
1
|
+
import AppWrapper, { alert, confirm, showFatalError, addFatalErrorHandler } from './components/AppWrapper';
|
|
2
2
|
import LoadingSpinner from './components/LoadingSpinner';
|
|
3
3
|
import ErrorBox from './components/ErrorBox';
|
|
4
4
|
import Modal from './components/Modal';
|
|
@@ -18,6 +18,7 @@ import IntelliTable from './components/IntelliTable';
|
|
|
18
18
|
import CSVDownloadButton from './components/CSVDownloadButton';
|
|
19
19
|
import DBEntryManagerPanel from './components/DBEntryManagerPanel';
|
|
20
20
|
import Tooltip from './components/Tooltip';
|
|
21
|
+
import ToggleSwitch from './components/ToggleSwitch';
|
|
21
22
|
import ErrorWithCode from './errors/ErrorWithCode';
|
|
22
23
|
import MINUTE_IN_MS from './constants/MINUTE_IN_MS';
|
|
23
24
|
import HOUR_IN_MS from './constants/HOUR_IN_MS';
|
|
@@ -80,4 +81,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
|
80
81
|
import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
|
|
81
82
|
import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
|
|
82
83
|
import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
|
|
83
|
-
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, initClient, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
|
|
84
|
+
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ declare enum Variant {
|
|
|
24
24
|
* @author Gabe Abrams
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
type Props$
|
|
27
|
+
type Props$j = {
|
|
28
28
|
children: React.ReactNode;
|
|
29
29
|
dark?: boolean;
|
|
30
30
|
};
|
|
@@ -63,7 +63,12 @@ declare const confirm: (title: string, text: string, opts?: {
|
|
|
63
63
|
* @param [errorTitle] title of the error box
|
|
64
64
|
*/
|
|
65
65
|
declare const showFatalError: (error: any, errorTitle?: string) => undefined;
|
|
66
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Add a handler for when a fatal error occurs
|
|
68
|
+
* @author Gabe Abrams
|
|
69
|
+
*/
|
|
70
|
+
declare const addFatalErrorHandler: (handler: () => void) => void;
|
|
71
|
+
declare const AppWrapper: React.FC<Props$j>;
|
|
67
72
|
|
|
68
73
|
/**
|
|
69
74
|
* Loading spinner/indicator
|
|
@@ -76,12 +81,12 @@ declare const LoadingSpinner: () => JSX.Element;
|
|
|
76
81
|
* @author Gabe Abrams
|
|
77
82
|
*/
|
|
78
83
|
|
|
79
|
-
type Props$
|
|
84
|
+
type Props$i = {
|
|
80
85
|
error: any;
|
|
81
86
|
title?: string;
|
|
82
87
|
onClose?: () => void;
|
|
83
88
|
};
|
|
84
|
-
declare const ErrorBox: React.FC<Props$
|
|
89
|
+
declare const ErrorBox: React.FC<Props$i>;
|
|
85
90
|
|
|
86
91
|
/**
|
|
87
92
|
* Types of buttons in the modal
|
|
@@ -132,7 +137,7 @@ declare enum ModalType {
|
|
|
132
137
|
* @author Gabe Abrams
|
|
133
138
|
*/
|
|
134
139
|
|
|
135
|
-
type Props$
|
|
140
|
+
type Props$h = {
|
|
136
141
|
type?: ModalType;
|
|
137
142
|
size?: ModalSize;
|
|
138
143
|
title?: React.ReactNode;
|
|
@@ -161,27 +166,27 @@ type Props$g = {
|
|
|
161
166
|
confirmVariant?: Variant;
|
|
162
167
|
onTopOfOtherModals?: boolean;
|
|
163
168
|
};
|
|
164
|
-
declare const Modal: React.FC<Props$
|
|
169
|
+
declare const Modal: React.FC<Props$h>;
|
|
165
170
|
|
|
166
171
|
/**
|
|
167
172
|
* A box with a tab on the top that holds buttons and other content
|
|
168
173
|
* @author Gabe Abrams
|
|
169
174
|
*/
|
|
170
175
|
|
|
171
|
-
type Props$
|
|
176
|
+
type Props$g = {
|
|
172
177
|
title: React.ReactNode;
|
|
173
178
|
children: React.ReactNode;
|
|
174
179
|
noBottomMargin?: boolean;
|
|
175
180
|
noBottomPadding?: boolean;
|
|
176
181
|
};
|
|
177
|
-
declare const TabBox: React.FC<Props$
|
|
182
|
+
declare const TabBox: React.FC<Props$g>;
|
|
178
183
|
|
|
179
184
|
/**
|
|
180
185
|
* A radio selection button
|
|
181
186
|
* @author Gabe Abrams
|
|
182
187
|
*/
|
|
183
188
|
|
|
184
|
-
type Props$
|
|
189
|
+
type Props$f = {
|
|
185
190
|
text: string;
|
|
186
191
|
onSelected: () => void;
|
|
187
192
|
ariaLabel: string;
|
|
@@ -193,14 +198,14 @@ type Props$e = {
|
|
|
193
198
|
unselectedVariant?: Variant;
|
|
194
199
|
small?: boolean;
|
|
195
200
|
};
|
|
196
|
-
declare const RadioButton: React.FC<Props$
|
|
201
|
+
declare const RadioButton: React.FC<Props$f>;
|
|
197
202
|
|
|
198
203
|
/**
|
|
199
204
|
* A checkbox button
|
|
200
205
|
* @author Gabe Abrams
|
|
201
206
|
*/
|
|
202
207
|
|
|
203
|
-
type Props$
|
|
208
|
+
type Props$e = {
|
|
204
209
|
text: string;
|
|
205
210
|
onChanged: (checked: boolean) => void;
|
|
206
211
|
ariaLabel: string;
|
|
@@ -214,28 +219,28 @@ type Props$d = {
|
|
|
214
219
|
small?: boolean;
|
|
215
220
|
dashed?: boolean;
|
|
216
221
|
};
|
|
217
|
-
declare const CheckboxButton: React.FC<Props$
|
|
222
|
+
declare const CheckboxButton: React.FC<Props$e>;
|
|
218
223
|
|
|
219
224
|
/**
|
|
220
225
|
* Input group with a title and space for buttons
|
|
221
226
|
* @author Gabe Abrams
|
|
222
227
|
*/
|
|
223
228
|
|
|
224
|
-
type Props$
|
|
229
|
+
type Props$d = {
|
|
225
230
|
label: string;
|
|
226
231
|
minLabelWidth?: string;
|
|
227
232
|
children: React.ReactNode;
|
|
228
233
|
className?: string;
|
|
229
234
|
wrapButtonsAndAddGaps?: boolean;
|
|
230
235
|
};
|
|
231
|
-
declare const ButtonInputGroup: React.FC<Props$
|
|
236
|
+
declare const ButtonInputGroup: React.FC<Props$d>;
|
|
232
237
|
|
|
233
238
|
/**
|
|
234
239
|
* A very simple, lightweight date chooser
|
|
235
240
|
* @author Gabe Abrams
|
|
236
241
|
*/
|
|
237
242
|
|
|
238
|
-
type Props$
|
|
243
|
+
type Props$c = {
|
|
239
244
|
ariaLabel: string;
|
|
240
245
|
name: string;
|
|
241
246
|
month: number;
|
|
@@ -251,61 +256,61 @@ type Props$b = {
|
|
|
251
256
|
numMonthsToShow?: number;
|
|
252
257
|
chooseFromPast?: boolean;
|
|
253
258
|
};
|
|
254
|
-
declare const SimpleDateChooser: React.FC<Props$
|
|
259
|
+
declare const SimpleDateChooser: React.FC<Props$c>;
|
|
255
260
|
|
|
256
261
|
/**
|
|
257
262
|
* Drawer container
|
|
258
263
|
* @author Gabe Abrams
|
|
259
264
|
*/
|
|
260
265
|
|
|
261
|
-
type Props$
|
|
266
|
+
type Props$b = {
|
|
262
267
|
customBackgroundColor?: string;
|
|
263
268
|
children: React.ReactNode;
|
|
264
269
|
};
|
|
265
|
-
declare const Drawer: React.FC<Props$
|
|
270
|
+
declare const Drawer: React.FC<Props$b>;
|
|
266
271
|
|
|
267
272
|
/**
|
|
268
273
|
* Success checkmark that pops into view
|
|
269
274
|
* @author Gabe Abrams
|
|
270
275
|
*/
|
|
271
276
|
|
|
272
|
-
type Props$
|
|
277
|
+
type Props$a = {
|
|
273
278
|
sizeRem?: number;
|
|
274
279
|
circleVariant?: string;
|
|
275
280
|
checkVariant?: string;
|
|
276
281
|
};
|
|
277
|
-
declare const PopSuccessMark: React.FC<Props$
|
|
282
|
+
declare const PopSuccessMark: React.FC<Props$a>;
|
|
278
283
|
|
|
279
284
|
/**
|
|
280
285
|
* Failure x mark that pops into view
|
|
281
286
|
* @author Gabe Abrams
|
|
282
287
|
*/
|
|
283
288
|
|
|
284
|
-
type Props$
|
|
289
|
+
type Props$9 = {
|
|
285
290
|
sizeRem?: number;
|
|
286
291
|
circleVariant?: string;
|
|
287
292
|
xVariant?: string;
|
|
288
293
|
};
|
|
289
|
-
declare const PopFailureMark: React.FC<Props$
|
|
294
|
+
declare const PopFailureMark: React.FC<Props$9>;
|
|
290
295
|
|
|
291
296
|
/**
|
|
292
297
|
* Failure pending that pops into view
|
|
293
298
|
* @author Gabe Abrams
|
|
294
299
|
*/
|
|
295
300
|
|
|
296
|
-
type Props$
|
|
301
|
+
type Props$8 = {
|
|
297
302
|
sizeRem?: number;
|
|
298
303
|
circleVariant?: string;
|
|
299
304
|
hourglassVariant?: string;
|
|
300
305
|
};
|
|
301
|
-
declare const PopPendingMark: React.FC<Props$
|
|
306
|
+
declare const PopPendingMark: React.FC<Props$8>;
|
|
302
307
|
|
|
303
308
|
/**
|
|
304
309
|
* Copiable text box
|
|
305
310
|
* @author Gabe Abrams
|
|
306
311
|
*/
|
|
307
312
|
|
|
308
|
-
type Props$
|
|
313
|
+
type Props$7 = {
|
|
309
314
|
text: string;
|
|
310
315
|
maxTextWidthRem?: number;
|
|
311
316
|
label?: string;
|
|
@@ -317,7 +322,7 @@ type Props$6 = {
|
|
|
317
322
|
textAreaId?: string;
|
|
318
323
|
copyButtonId?: string;
|
|
319
324
|
};
|
|
320
|
-
declare const CopiableBox: React.FC<Props$
|
|
325
|
+
declare const CopiableBox: React.FC<Props$7>;
|
|
321
326
|
|
|
322
327
|
/**
|
|
323
328
|
* An item that can be chosen (for use within ItemPicker)
|
|
@@ -340,7 +345,7 @@ type PickableItem = ({
|
|
|
340
345
|
* @author Yuen Ler Chow
|
|
341
346
|
*/
|
|
342
347
|
|
|
343
|
-
type Props$
|
|
348
|
+
type Props$6 = {
|
|
344
349
|
title: string;
|
|
345
350
|
items: PickableItem[];
|
|
346
351
|
/**
|
|
@@ -351,7 +356,7 @@ type Props$5 = {
|
|
|
351
356
|
onChanged: (updatedItems: PickableItem[]) => void;
|
|
352
357
|
noBottomMargin?: boolean;
|
|
353
358
|
};
|
|
354
|
-
declare const ItemPicker: React.FC<Props$
|
|
359
|
+
declare const ItemPicker: React.FC<Props$6>;
|
|
355
360
|
|
|
356
361
|
/**
|
|
357
362
|
* Type of the context map in a LogMetadata file
|
|
@@ -396,11 +401,11 @@ type LogMetadataType = {
|
|
|
396
401
|
* @author Gabe Abrams
|
|
397
402
|
*/
|
|
398
403
|
|
|
399
|
-
type Props$
|
|
404
|
+
type Props$5 = {
|
|
400
405
|
LogMetadata: LogMetadataType;
|
|
401
406
|
onClose: () => void;
|
|
402
407
|
};
|
|
403
|
-
declare const LogReviewer: React.FC<Props$
|
|
408
|
+
declare const LogReviewer: React.FC<Props$5>;
|
|
404
409
|
|
|
405
410
|
/**
|
|
406
411
|
* Server-side API param types
|
|
@@ -435,7 +440,7 @@ type IntelliTableColumn = {
|
|
|
435
440
|
* @author Gabe Abrams
|
|
436
441
|
*/
|
|
437
442
|
|
|
438
|
-
type Props$
|
|
443
|
+
type Props$4 = {
|
|
439
444
|
title: string;
|
|
440
445
|
id: string;
|
|
441
446
|
data: {
|
|
@@ -445,14 +450,14 @@ type Props$3 = {
|
|
|
445
450
|
columns: IntelliTableColumn[];
|
|
446
451
|
csvName?: string;
|
|
447
452
|
};
|
|
448
|
-
declare const IntelliTable: React.FC<Props$
|
|
453
|
+
declare const IntelliTable: React.FC<Props$4>;
|
|
449
454
|
|
|
450
455
|
/**
|
|
451
456
|
* Button for downloading a csv file
|
|
452
457
|
* @author Gabe Abrams
|
|
453
458
|
*/
|
|
454
459
|
|
|
455
|
-
type Props$
|
|
460
|
+
type Props$3 = {
|
|
456
461
|
filename: string;
|
|
457
462
|
csv: string;
|
|
458
463
|
id?: string;
|
|
@@ -464,7 +469,7 @@ type Props$2 = {
|
|
|
464
469
|
onClick?: () => void;
|
|
465
470
|
children?: React.ReactNode;
|
|
466
471
|
};
|
|
467
|
-
declare const CSVDownloadButton: React.FC<Props$
|
|
472
|
+
declare const CSVDownloadButton: React.FC<Props$3>;
|
|
468
473
|
|
|
469
474
|
/**
|
|
470
475
|
* Generic type for an object
|
|
@@ -540,7 +545,7 @@ type DBEntryField = ({
|
|
|
540
545
|
* @author Gabe Abrams
|
|
541
546
|
*/
|
|
542
547
|
|
|
543
|
-
type Props$
|
|
548
|
+
type Props$2 = {
|
|
544
549
|
entryFields: DBEntryField[];
|
|
545
550
|
idPropName: string;
|
|
546
551
|
titlePropName: string;
|
|
@@ -566,21 +571,40 @@ type Props$1 = {
|
|
|
566
571
|
[k: string]: any;
|
|
567
572
|
};
|
|
568
573
|
};
|
|
569
|
-
declare const DBEntryManagerPanel: React.FC<Props$
|
|
574
|
+
declare const DBEntryManagerPanel: React.FC<Props$2>;
|
|
570
575
|
|
|
571
576
|
/**
|
|
572
577
|
* Simple tooltip component
|
|
573
578
|
* @author Gabe Abrams
|
|
574
579
|
*/
|
|
575
580
|
|
|
576
|
-
type Props = {
|
|
581
|
+
type Props$1 = {
|
|
577
582
|
icon?: IconProp;
|
|
578
583
|
text: string;
|
|
579
584
|
children: React.ReactNode;
|
|
580
585
|
wide?: boolean;
|
|
581
586
|
thin?: boolean;
|
|
582
587
|
};
|
|
583
|
-
declare const Tooltip: React.FC<Props>;
|
|
588
|
+
declare const Tooltip: React.FC<Props$1>;
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* A toggle switch that toggles on or off
|
|
592
|
+
* @author Alessandra De Lucas
|
|
593
|
+
* @author Gabe Abrams
|
|
594
|
+
*/
|
|
595
|
+
|
|
596
|
+
type Props = {
|
|
597
|
+
isOn: boolean;
|
|
598
|
+
/**
|
|
599
|
+
* A handler to call when the switch is toggled
|
|
600
|
+
* @param isOn Updated value for isOn
|
|
601
|
+
*/
|
|
602
|
+
onToggle: (isOn: boolean) => void;
|
|
603
|
+
id?: string;
|
|
604
|
+
description: string;
|
|
605
|
+
backgroundVariantWhenOn?: Variant;
|
|
606
|
+
};
|
|
607
|
+
declare const ToggleSwitch: React.FC<Props>;
|
|
584
608
|
|
|
585
609
|
/**
|
|
586
610
|
* An error with a code
|
|
@@ -1359,4 +1383,4 @@ declare const LogBuiltInMetadata: {
|
|
|
1359
1383
|
};
|
|
1360
1384
|
};
|
|
1361
1385
|
|
|
1362
|
-
export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Tooltip, Variant, abbreviate, addDBEditorEndpoints, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
|
|
1386
|
+
export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
} from '../client/initClient';
|
|
31
31
|
|
|
32
32
|
/*------------------------------------------------------------------------*/
|
|
33
|
-
/*
|
|
33
|
+
/* -------------------------------- Props ------------------------------- */
|
|
34
34
|
/*------------------------------------------------------------------------*/
|
|
35
35
|
|
|
36
36
|
type Props = {
|
|
@@ -41,11 +41,11 @@ type Props = {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
/*------------------------------------------------------------------------*/
|
|
44
|
-
/*
|
|
44
|
+
/* --------------------------- Static Helpers --------------------------- */
|
|
45
45
|
/*------------------------------------------------------------------------*/
|
|
46
46
|
|
|
47
47
|
/*----------------------------------------*/
|
|
48
|
-
/*
|
|
48
|
+
/* ---------------- Alert --------------- */
|
|
49
49
|
/*----------------------------------------*/
|
|
50
50
|
|
|
51
51
|
// Stored copies of setters
|
|
@@ -61,6 +61,7 @@ let onAlertClosed: () => void;
|
|
|
61
61
|
export const alert = async (title: string, text: string): Promise<undefined> => {
|
|
62
62
|
// Fallback if alert not available
|
|
63
63
|
if (!setAlertInfo) {
|
|
64
|
+
// eslint-disable-next-line no-alert
|
|
64
65
|
window.alert(`${title}\n\n${text}`);
|
|
65
66
|
return undefined;
|
|
66
67
|
}
|
|
@@ -81,7 +82,7 @@ export const alert = async (title: string, text: string): Promise<undefined> =>
|
|
|
81
82
|
};
|
|
82
83
|
|
|
83
84
|
/*----------------------------------------*/
|
|
84
|
-
/*
|
|
85
|
+
/* --------------- Confirm -------------- */
|
|
85
86
|
/*----------------------------------------*/
|
|
86
87
|
|
|
87
88
|
// Stored copies of setters
|
|
@@ -129,6 +130,7 @@ export const confirm = async (
|
|
|
129
130
|
): Promise<boolean> => {
|
|
130
131
|
// Fallback if confirm is not available
|
|
131
132
|
if (!setConfirmInfo) {
|
|
133
|
+
// eslint-disable-next-line no-alert
|
|
132
134
|
return window.confirm(`${title}\n\n${text}`);
|
|
133
135
|
}
|
|
134
136
|
|
|
@@ -136,7 +138,7 @@ export const confirm = async (
|
|
|
136
138
|
return new Promise((resolve) => {
|
|
137
139
|
// Setup handler
|
|
138
140
|
onConfirmClosed = (confirmed: boolean) => {
|
|
139
|
-
resolve(confirmed)
|
|
141
|
+
resolve(confirmed);
|
|
140
142
|
};
|
|
141
143
|
|
|
142
144
|
// Show the confirm
|
|
@@ -149,7 +151,7 @@ export const confirm = async (
|
|
|
149
151
|
};
|
|
150
152
|
|
|
151
153
|
/*----------------------------------------*/
|
|
152
|
-
/*
|
|
154
|
+
/* ------------- Fatal Error ------------ */
|
|
153
155
|
/*----------------------------------------*/
|
|
154
156
|
|
|
155
157
|
// Stored copies of setters
|
|
@@ -157,6 +159,9 @@ let setFatalErrorMessage: (message: string) => void;
|
|
|
157
159
|
let setFatalErrorCode: (code: string) => void;
|
|
158
160
|
let setFatalErrorTitle: (title: string) => void;
|
|
159
161
|
|
|
162
|
+
// Fatal error listeners
|
|
163
|
+
const fatalErrorHandlers: (() => void)[] = [];
|
|
164
|
+
|
|
160
165
|
/**
|
|
161
166
|
* Show a fatal error message
|
|
162
167
|
* @author Gabe Abrams
|
|
@@ -179,6 +184,15 @@ export const showFatalError = (
|
|
|
179
184
|
: String(error.code ?? ReactKitErrorCode.NoCode)
|
|
180
185
|
);
|
|
181
186
|
|
|
187
|
+
// Call all fatal error listeners
|
|
188
|
+
try {
|
|
189
|
+
fatalErrorHandlers.forEach((handler) => {
|
|
190
|
+
handler();
|
|
191
|
+
});
|
|
192
|
+
} catch (err) {
|
|
193
|
+
// Ignore listener errors
|
|
194
|
+
}
|
|
195
|
+
|
|
182
196
|
// Add log
|
|
183
197
|
logClientEvent({
|
|
184
198
|
context: LogBuiltInMetadata.Context.ClientFatalError,
|
|
@@ -209,8 +223,16 @@ export const showFatalError = (
|
|
|
209
223
|
return undefined;
|
|
210
224
|
};
|
|
211
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Add a handler for when a fatal error occurs
|
|
228
|
+
* @author Gabe Abrams
|
|
229
|
+
*/
|
|
230
|
+
export const addFatalErrorHandler = (handler: () => void) => {
|
|
231
|
+
fatalErrorHandlers.push(handler);
|
|
232
|
+
};
|
|
233
|
+
|
|
212
234
|
/*----------------------------------------*/
|
|
213
|
-
/*
|
|
235
|
+
/* ----------- Session Expired ---------- */
|
|
214
236
|
/*----------------------------------------*/
|
|
215
237
|
|
|
216
238
|
// Stored copies of setters
|
|
@@ -226,12 +248,12 @@ export const showSessionExpiredMessage = (): undefined => {
|
|
|
226
248
|
};
|
|
227
249
|
|
|
228
250
|
/*------------------------------------------------------------------------*/
|
|
229
|
-
/*
|
|
251
|
+
/* ------------------------------ Component ----------------------------- */
|
|
230
252
|
/*------------------------------------------------------------------------*/
|
|
231
253
|
|
|
232
254
|
const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
|
|
233
255
|
/*------------------------------------------------------------------------*/
|
|
234
|
-
/*
|
|
256
|
+
/* -------------------------------- Setup ------------------------------- */
|
|
235
257
|
/*------------------------------------------------------------------------*/
|
|
236
258
|
|
|
237
259
|
/* -------------- Props ------------- */
|
|
@@ -265,11 +287,11 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
|
|
|
265
287
|
alertInfo,
|
|
266
288
|
setAlertInfoInner,
|
|
267
289
|
] = useState<
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
290
|
+
undefined
|
|
291
|
+
| {
|
|
292
|
+
title: string,
|
|
293
|
+
text: string,
|
|
294
|
+
}
|
|
273
295
|
>(undefined);
|
|
274
296
|
setAlertInfo = setAlertInfoInner;
|
|
275
297
|
|
|
@@ -278,17 +300,17 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
|
|
|
278
300
|
confirmInfo,
|
|
279
301
|
setConfirmInfoInner,
|
|
280
302
|
] = useState<
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
303
|
+
undefined
|
|
304
|
+
| {
|
|
305
|
+
title: string,
|
|
306
|
+
text: string,
|
|
307
|
+
opts: {
|
|
308
|
+
confirmButtonText?: string,
|
|
309
|
+
confirmButtonVariant?: Variant,
|
|
310
|
+
cancelButtonText?: string,
|
|
311
|
+
cancelButtonVariant?: Variant,
|
|
312
|
+
},
|
|
313
|
+
}
|
|
292
314
|
>(undefined);
|
|
293
315
|
setConfirmInfo = setConfirmInfoInner;
|
|
294
316
|
|
|
@@ -300,11 +322,11 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
|
|
|
300
322
|
setSessionHasExpired = setSessionHasExpiredInner;
|
|
301
323
|
|
|
302
324
|
/*------------------------------------------------------------------------*/
|
|
303
|
-
/*
|
|
325
|
+
/* ------------------------------- Render ------------------------------- */
|
|
304
326
|
/*------------------------------------------------------------------------*/
|
|
305
327
|
|
|
306
328
|
/*----------------------------------------*/
|
|
307
|
-
/*
|
|
329
|
+
/* ---------------- Modal --------------- */
|
|
308
330
|
/*----------------------------------------*/
|
|
309
331
|
|
|
310
332
|
// Modal that may be defined
|
|
@@ -358,7 +380,7 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
|
|
|
358
380
|
}
|
|
359
381
|
|
|
360
382
|
/*----------------------------------------*/
|
|
361
|
-
/*
|
|
383
|
+
/* ---------------- Views --------------- */
|
|
362
384
|
/*----------------------------------------*/
|
|
363
385
|
|
|
364
386
|
// Body that will be filled with the current view
|
|
@@ -410,11 +432,7 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
|
|
|
410
432
|
/* --------------- App -------------- */
|
|
411
433
|
|
|
412
434
|
if (!body) {
|
|
413
|
-
body =
|
|
414
|
-
<>
|
|
415
|
-
{children}
|
|
416
|
-
</>
|
|
417
|
-
);
|
|
435
|
+
body = children;
|
|
418
436
|
}
|
|
419
437
|
|
|
420
438
|
/*----------------------------------------*/
|
|
@@ -434,4 +452,4 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
|
|
|
434
452
|
/*------------------------------------------------------------------------*/
|
|
435
453
|
|
|
436
454
|
// Export component
|
|
437
|
-
export default AppWrapper;
|
|
455
|
+
export default AppWrapper;
|