dce-reactkit 2.0.12 → 3.0.0-beta.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/dist/cjs/index.js +921 -0
- package/dist/cjs/index.js.map +1 -0
- package/{lib → dist/cjs/types}/components/AppWrapper.d.ts +10 -5
- package/{lib → dist/cjs/types}/components/ErrorBox.d.ts +0 -0
- package/{lib → dist/cjs/types}/components/LoadingSpinner.d.ts +1 -0
- package/{lib → dist/cjs/types}/components/Modal.d.ts +5 -36
- package/{lib → dist/cjs/types}/components/TabBox.d.ts +0 -0
- package/{lib → dist/cjs/types}/errors/ErrorWithCode.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/abbreviate.d.ts +1 -0
- package/{lib → dist/cjs/types}/helpers/avg.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/ceilToNumDecimals.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/floorToNumDecimals.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/forceNumIntoBounds.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/padDecimalZeros.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/padZerosLeft.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/roundToNumDecimals.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/sum.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/waitMs.d.ts +0 -0
- package/dist/cjs/types/index.d.ts +22 -0
- package/dist/cjs/types/types/ModalButtonType.d.ts +17 -0
- package/dist/cjs/types/types/ModalSize.d.ts +11 -0
- package/dist/cjs/types/types/ModalType.d.ts +16 -0
- package/{lib → dist/cjs/types}/types/ReactKitErrorCode.d.ts +0 -0
- package/{lib → dist/cjs/types}/types/Variant.d.ts +0 -0
- package/dist/esm/index.js +890 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/components/AppWrapper.d.ts +40 -0
- package/dist/esm/types/components/ErrorBox.d.ts +12 -0
- package/dist/esm/types/components/LoadingSpinner.d.ts +7 -0
- package/dist/esm/types/components/Modal.d.ts +40 -0
- package/dist/esm/types/components/TabBox.d.ts +11 -0
- package/dist/esm/types/errors/ErrorWithCode.d.ts +9 -0
- package/dist/esm/types/helpers/abbreviate.d.ts +10 -0
- package/dist/esm/types/helpers/avg.d.ts +8 -0
- package/dist/esm/types/helpers/ceilToNumDecimals.d.ts +9 -0
- package/dist/esm/types/helpers/floorToNumDecimals.d.ts +9 -0
- package/dist/esm/types/helpers/forceNumIntoBounds.d.ts +10 -0
- package/dist/esm/types/helpers/padDecimalZeros.d.ts +10 -0
- package/dist/esm/types/helpers/padZerosLeft.d.ts +9 -0
- package/dist/esm/types/helpers/roundToNumDecimals.d.ts +9 -0
- package/dist/esm/types/helpers/sum.d.ts +8 -0
- package/dist/esm/types/helpers/waitMs.d.ts +7 -0
- package/dist/esm/types/index.d.ts +22 -0
- package/dist/esm/types/types/ModalButtonType.d.ts +17 -0
- package/dist/esm/types/types/ModalSize.d.ts +11 -0
- package/dist/esm/types/types/ModalType.d.ts +16 -0
- package/dist/esm/types/types/ReactKitErrorCode.d.ts +13 -0
- package/dist/esm/types/types/Variant.d.ts +15 -0
- package/dist/index.d.ts +274 -0
- package/package.json +23 -15
- package/rollup.config.js +45 -0
- package/src/components/AppWrapper.tsx +40 -39
- package/src/components/LoadingSpinner.tsx +3 -0
- package/src/components/Modal.tsx +96 -170
- package/src/helpers/abbreviate.tsx +2 -0
- package/src/helpers/padDecimalZeros.tsx +1 -1
- package/src/index.ts +61 -0
- package/src/types/ModalButtonType.tsx +18 -0
- package/src/types/ModalSize.tsx +12 -0
- package/src/types/ModalType.tsx +17 -0
- package/tsconfig.json +16 -17
- package/lib/components/AppWrapper.js +0 -277
- package/lib/components/AppWrapper.js.map +0 -1
- package/lib/components/ErrorBox.js +0 -65
- package/lib/components/ErrorBox.js.map +0 -1
- package/lib/components/LoadingSpinner.js +0 -41
- package/lib/components/LoadingSpinner.js.map +0 -1
- package/lib/components/Modal.js +0 -321
- package/lib/components/Modal.js.map +0 -1
- package/lib/components/TabBox.js +0 -42
- package/lib/components/TabBox.js.map +0 -1
- package/lib/errors/ErrorWithCode.js +0 -33
- package/lib/errors/ErrorWithCode.js.map +0 -1
- package/lib/helpers/abbreviate.js +0 -21
- package/lib/helpers/abbreviate.js.map +0 -1
- package/lib/helpers/alert.d.ts +0 -2
- package/lib/helpers/alert.js +0 -6
- package/lib/helpers/alert.js.map +0 -1
- package/lib/helpers/avg.js +0 -24
- package/lib/helpers/avg.js.map +0 -1
- package/lib/helpers/ceilToNumDecimals.js +0 -15
- package/lib/helpers/ceilToNumDecimals.js.map +0 -1
- package/lib/helpers/confirm.d.ts +0 -2
- package/lib/helpers/confirm.js +0 -6
- package/lib/helpers/confirm.js.map +0 -1
- package/lib/helpers/floorToNumDecimals.js +0 -15
- package/lib/helpers/floorToNumDecimals.js.map +0 -1
- package/lib/helpers/forceNumIntoBounds.js +0 -15
- package/lib/helpers/forceNumIntoBounds.js.map +0 -1
- package/lib/helpers/handleError.d.ts +0 -14
- package/lib/helpers/handleError.js +0 -54
- package/lib/helpers/handleError.js.map +0 -1
- package/lib/helpers/handleSuccess.d.ts +0 -8
- package/lib/helpers/handleSuccess.js +0 -20
- package/lib/helpers/handleSuccess.js.map +0 -1
- package/lib/helpers/padDecimalZeros.js +0 -30
- package/lib/helpers/padDecimalZeros.js.map +0 -1
- package/lib/helpers/padZerosLeft.js +0 -21
- package/lib/helpers/padZerosLeft.js.map +0 -1
- package/lib/helpers/parseRequest.d.ts +0 -21
- package/lib/helpers/parseRequest.js +0 -240
- package/lib/helpers/parseRequest.js.map +0 -1
- package/lib/helpers/roundToNumDecimals.js +0 -15
- package/lib/helpers/roundToNumDecimals.js.map +0 -1
- package/lib/helpers/showFatalError.d.ts +0 -2
- package/lib/helpers/showFatalError.js +0 -6
- package/lib/helpers/showFatalError.js.map +0 -1
- package/lib/helpers/sum.js +0 -15
- package/lib/helpers/sum.js.map +0 -1
- package/lib/helpers/visitServerEndpoint.d.ts +0 -23
- package/lib/helpers/visitServerEndpoint.js +0 -135
- package/lib/helpers/visitServerEndpoint.js.map +0 -1
- package/lib/helpers/waitMs.js +0 -55
- package/lib/helpers/waitMs.js.map +0 -1
- package/lib/types/ParamType.d.ts +0 -17
- package/lib/types/ParamType.js +0 -21
- package/lib/types/ParamType.js.map +0 -1
- package/lib/types/ReactKitErrorCode.js +0 -18
- package/lib/types/ReactKitErrorCode.js.map +0 -1
- package/lib/types/Variant.js +0 -19
- package/lib/types/Variant.js.map +0 -1
- package/src/helpers/alert.tsx +0 -5
- package/src/helpers/confirm.tsx +0 -5
- package/src/helpers/handleError.ts +0 -65
- package/src/helpers/handleSuccess.ts +0 -18
- package/src/helpers/parseRequest.ts +0 -299
- package/src/helpers/showFatalError.tsx +0 -5
- package/src/helpers/visitServerEndpoint.tsx +0 -110
- package/src/types/ParamType.ts +0 -18
package/src/components/Modal.tsx
CHANGED
|
@@ -7,64 +7,27 @@
|
|
|
7
7
|
import React, { useState, useEffect } from 'react';
|
|
8
8
|
|
|
9
9
|
// Import other components
|
|
10
|
-
import BootstrapModal from 'react-bootstrap/Modal';
|
|
11
10
|
import waitMs from '../helpers/waitMs';
|
|
12
11
|
|
|
13
12
|
// Import types
|
|
14
13
|
import Variant from '../types/Variant';
|
|
14
|
+
import ModalButtonType from '../types/ModalButtonType';
|
|
15
|
+
import ModalSize from '../types/ModalSize';
|
|
16
|
+
import ModalType from '../types/ModalType';
|
|
15
17
|
|
|
16
18
|
/*------------------------------------------------------------------------*/
|
|
17
19
|
/* Style */
|
|
18
20
|
/*------------------------------------------------------------------------*/
|
|
19
21
|
|
|
20
22
|
const style = `
|
|
21
|
-
/* More opaque backdrop */
|
|
22
23
|
.Modal-backdrop {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/* Dark theme */
|
|
31
|
-
background-color: #222 !important;
|
|
32
|
-
color: white !important;
|
|
33
|
-
|
|
34
|
-
/* Border */
|
|
35
|
-
border: 1px solid #545454 !important;
|
|
36
|
-
}
|
|
37
|
-
.modal-body {
|
|
38
|
-
/* Dark theme */
|
|
39
|
-
background-color: #222 !important;
|
|
40
|
-
color: white !important;
|
|
41
|
-
|
|
42
|
-
/* Border */
|
|
43
|
-
border-top: 0 !important;
|
|
44
|
-
border-left: 1px solid #545454 !important;
|
|
45
|
-
border-bottom: 1px solid #545454 !important;
|
|
46
|
-
border-right: 1px solid #545454 !important;
|
|
47
|
-
border-bottom-left-radius: 3px;
|
|
48
|
-
border-bottom-right-radius: 3px;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/* Create our own animation */
|
|
52
|
-
.modal-content {
|
|
53
|
-
animation-name: Modal-drop-in;
|
|
54
|
-
animation-duration: 0.4s;
|
|
55
|
-
animation-iteration-count: 1;
|
|
56
|
-
animation-fill-mode: forwards;
|
|
57
|
-
animation-timing-function: ease-out;
|
|
58
|
-
}
|
|
59
|
-
@keyframes Modal-drop-in {
|
|
60
|
-
0% {
|
|
61
|
-
transform: scale(0.8);
|
|
62
|
-
opacity: 0.5;
|
|
63
|
-
}
|
|
64
|
-
100% {
|
|
65
|
-
transform: scale(1);
|
|
66
|
-
opacity: 1;
|
|
67
|
-
}
|
|
24
|
+
position: fixed;
|
|
25
|
+
top: 0;
|
|
26
|
+
left: 0;
|
|
27
|
+
width: 100vw;
|
|
28
|
+
height: 100vw;
|
|
29
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
30
|
+
z-index: 4000000000;
|
|
68
31
|
}
|
|
69
32
|
`;
|
|
70
33
|
|
|
@@ -77,118 +40,83 @@ const MS_TO_ANIMATE = 400; // Time to animate in/out (defined by bootstrap)
|
|
|
77
40
|
const MS_ANIMATE_IN_DELAY = 10;
|
|
78
41
|
// Time to wait before animating in (must be >0 or animation won't trigger)
|
|
79
42
|
|
|
80
|
-
// Modal types
|
|
81
|
-
enum ModalType {
|
|
82
|
-
Okay = 'okay', // [Okay]
|
|
83
|
-
OkayCancel = 'okay-cancel', // [Okay] [Cancel]
|
|
84
|
-
YesNo = 'yes-no', // [Yes] [No]
|
|
85
|
-
YesNoCancel = 'yes-no-cancel', // [Yes] [No] [Cancel]
|
|
86
|
-
AbandonGoBack = 'abandon-goBack', // [Abandon Changes] [Go Back]
|
|
87
|
-
ImSureCancel = 'imSure-cancel', // [I am sure] [Cancel]
|
|
88
|
-
DeleteCancel = 'delete-cancel', // [Yes, Delete] [Cancel]
|
|
89
|
-
ConfirmCancel = 'confirm-cancel', // [Confirm] [Cancel]
|
|
90
|
-
NoButtons = '-', // No buttons
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Modal sizes
|
|
94
|
-
enum ModalSize {
|
|
95
|
-
Small = 'sm',
|
|
96
|
-
Medium = 'md',
|
|
97
|
-
Large = 'lg',
|
|
98
|
-
ExtraLarge = 'xl',
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Button types
|
|
102
|
-
enum ButtonType {
|
|
103
|
-
Okay = 'okay',
|
|
104
|
-
Cancel = 'cancel',
|
|
105
|
-
Yes = 'yes',
|
|
106
|
-
No = 'no',
|
|
107
|
-
Abandon = 'abandon',
|
|
108
|
-
GoBack = 'goBack',
|
|
109
|
-
Continue = 'continue',
|
|
110
|
-
ImSure = 'imSure',
|
|
111
|
-
Delete = 'delete',
|
|
112
|
-
Confirm = 'confirm',
|
|
113
|
-
}
|
|
114
|
-
|
|
115
43
|
// Modal type to list of buttons
|
|
116
|
-
const
|
|
117
|
-
[k: string]:
|
|
44
|
+
const modalTypeToModalButtonTypes: {
|
|
45
|
+
[k: string]: ModalButtonType[]
|
|
118
46
|
} = {
|
|
119
47
|
[ModalType.Okay]: [
|
|
120
|
-
|
|
48
|
+
ModalButtonType.Okay,
|
|
121
49
|
],
|
|
122
50
|
[ModalType.OkayCancel]: [
|
|
123
|
-
|
|
124
|
-
|
|
51
|
+
ModalButtonType.Okay,
|
|
52
|
+
ModalButtonType.Cancel,
|
|
125
53
|
],
|
|
126
54
|
[ModalType.YesNo]: [
|
|
127
|
-
|
|
128
|
-
|
|
55
|
+
ModalButtonType.Yes,
|
|
56
|
+
ModalButtonType.No,
|
|
129
57
|
],
|
|
130
58
|
[ModalType.YesNoCancel]: [
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
59
|
+
ModalButtonType.Yes,
|
|
60
|
+
ModalButtonType.No,
|
|
61
|
+
ModalButtonType.Cancel,
|
|
134
62
|
],
|
|
135
63
|
[ModalType.AbandonGoBack]: [
|
|
136
|
-
|
|
137
|
-
|
|
64
|
+
ModalButtonType.Abandon,
|
|
65
|
+
ModalButtonType.GoBack,
|
|
138
66
|
],
|
|
139
67
|
[ModalType.ImSureCancel]: [
|
|
140
|
-
|
|
141
|
-
|
|
68
|
+
ModalButtonType.ImSure,
|
|
69
|
+
ModalButtonType.Cancel,
|
|
142
70
|
],
|
|
143
71
|
[ModalType.DeleteCancel]: [
|
|
144
|
-
|
|
145
|
-
|
|
72
|
+
ModalButtonType.Delete,
|
|
73
|
+
ModalButtonType.Cancel,
|
|
146
74
|
],
|
|
147
75
|
[ModalType.ConfirmCancel]: [
|
|
148
|
-
|
|
149
|
-
|
|
76
|
+
ModalButtonType.Confirm,
|
|
77
|
+
ModalButtonType.Cancel,
|
|
150
78
|
],
|
|
151
79
|
};
|
|
152
80
|
|
|
153
81
|
// Button type styling and labels
|
|
154
|
-
const
|
|
155
|
-
[
|
|
82
|
+
const ModalButtonTypeToLabelAndVariant = {
|
|
83
|
+
[ModalButtonType.Okay]: {
|
|
156
84
|
label: 'Okay',
|
|
157
85
|
variant: Variant.Dark,
|
|
158
86
|
},
|
|
159
|
-
[
|
|
87
|
+
[ModalButtonType.Cancel]: {
|
|
160
88
|
label: 'Cancel',
|
|
161
89
|
variant: Variant.Secondary,
|
|
162
90
|
},
|
|
163
|
-
[
|
|
91
|
+
[ModalButtonType.Yes]: {
|
|
164
92
|
label: 'Yes',
|
|
165
93
|
variant: Variant.Dark,
|
|
166
94
|
},
|
|
167
|
-
[
|
|
95
|
+
[ModalButtonType.No]: {
|
|
168
96
|
label: 'No',
|
|
169
97
|
variant: Variant.Secondary,
|
|
170
98
|
},
|
|
171
|
-
[
|
|
99
|
+
[ModalButtonType.Abandon]: {
|
|
172
100
|
label: 'Abandon Changes',
|
|
173
101
|
variant: Variant.Warning,
|
|
174
102
|
},
|
|
175
|
-
[
|
|
103
|
+
[ModalButtonType.GoBack]: {
|
|
176
104
|
label: 'Go Back',
|
|
177
105
|
variant: Variant.Secondary,
|
|
178
106
|
},
|
|
179
|
-
[
|
|
107
|
+
[ModalButtonType.Continue]: {
|
|
180
108
|
label: 'Continue',
|
|
181
109
|
variant: Variant.Dark,
|
|
182
110
|
},
|
|
183
|
-
[
|
|
111
|
+
[ModalButtonType.ImSure]: {
|
|
184
112
|
label: 'I am sure',
|
|
185
113
|
variant: Variant.Warning,
|
|
186
114
|
},
|
|
187
|
-
[
|
|
115
|
+
[ModalButtonType.Delete]: {
|
|
188
116
|
label: 'Yes, Delete',
|
|
189
117
|
variant: Variant.Danger,
|
|
190
118
|
},
|
|
191
|
-
[
|
|
119
|
+
[ModalButtonType.Confirm]: {
|
|
192
120
|
label: 'Confirm',
|
|
193
121
|
variant: Variant.Dark,
|
|
194
122
|
},
|
|
@@ -208,7 +136,7 @@ type Props = {
|
|
|
208
136
|
// The body of the modal
|
|
209
137
|
children?: React.ReactNode,
|
|
210
138
|
// Handler to call when modal is closed (if excluded, not closable)
|
|
211
|
-
onClose?: (type:
|
|
139
|
+
onClose?: (type: ModalButtonType) => void,
|
|
212
140
|
// If true, don't allow the user to click the backdrop to exit
|
|
213
141
|
dontAllowBackdropExit?: boolean,
|
|
214
142
|
// Custom label for "okay" button
|
|
@@ -259,15 +187,7 @@ type Props = {
|
|
|
259
187
|
/* Component */
|
|
260
188
|
/*------------------------------------------------------------------------*/
|
|
261
189
|
|
|
262
|
-
const Modal: (
|
|
263
|
-
React.FC<Props>
|
|
264
|
-
& {
|
|
265
|
-
ModalType: typeof ModalType,
|
|
266
|
-
ModalSize: typeof ModalSize,
|
|
267
|
-
ButtonType: typeof ButtonType,
|
|
268
|
-
Variant: typeof Variant,
|
|
269
|
-
}
|
|
270
|
-
) = (props) => {
|
|
190
|
+
const Modal: React.FC<Props> = (props) => {
|
|
271
191
|
/*------------------------------------------------------------------------*/
|
|
272
192
|
/* Setup */
|
|
273
193
|
/*------------------------------------------------------------------------*/
|
|
@@ -322,10 +242,10 @@ const Modal: (
|
|
|
322
242
|
/**
|
|
323
243
|
* Handles the closing of the modal
|
|
324
244
|
* @author Gabe Abrams
|
|
325
|
-
* @param
|
|
245
|
+
* @param ModalButtonType the button that was clicked when closing the
|
|
326
246
|
* modal
|
|
327
247
|
*/
|
|
328
|
-
const handleClose = async (
|
|
248
|
+
const handleClose = async (ModalButtonType: ModalButtonType) => {
|
|
329
249
|
// Don't close if no handler
|
|
330
250
|
if (!onClose) {
|
|
331
251
|
return;
|
|
@@ -346,7 +266,7 @@ const Modal: (
|
|
|
346
266
|
|
|
347
267
|
// Call the handler after the modal has animated out
|
|
348
268
|
await waitMs(MS_TO_ANIMATE);
|
|
349
|
-
onClose(
|
|
269
|
+
onClose(ModalButtonType);
|
|
350
270
|
};
|
|
351
271
|
|
|
352
272
|
/*------------------------------------------------------------------------*/
|
|
@@ -358,34 +278,36 @@ const Modal: (
|
|
|
358
278
|
/*----------------------------------------*/
|
|
359
279
|
|
|
360
280
|
// Get list of buttons for this modal type
|
|
361
|
-
const
|
|
281
|
+
const ModalButtonTypes: ModalButtonType[] = modalTypeToModalButtonTypes[type] ?? [];
|
|
362
282
|
|
|
363
283
|
// Create buttons
|
|
364
|
-
const buttons =
|
|
284
|
+
const buttons = ModalButtonTypes.map((ModalButtonType: ModalButtonType, i) => {
|
|
365
285
|
// Get default style
|
|
366
286
|
let {
|
|
367
287
|
label,
|
|
368
288
|
variant,
|
|
369
|
-
} =
|
|
289
|
+
} = ModalButtonTypeToLabelAndVariant[ModalButtonType];
|
|
370
290
|
|
|
371
291
|
// Override with customizations
|
|
372
|
-
|
|
373
|
-
|
|
292
|
+
const newLabel = props[`${ModalButtonType}Label`];
|
|
293
|
+
if (newLabel) {
|
|
294
|
+
label = newLabel;
|
|
374
295
|
}
|
|
375
|
-
|
|
376
|
-
|
|
296
|
+
const newVariant = props[`${ModalButtonType}Variant`];
|
|
297
|
+
if (newVariant) {
|
|
298
|
+
variant = newVariant;
|
|
377
299
|
}
|
|
378
300
|
|
|
379
301
|
// Check if this button is last
|
|
380
|
-
const last = (i ===
|
|
302
|
+
const last = (i === ModalButtonTypes.length - 1);
|
|
381
303
|
|
|
382
304
|
// Create the button
|
|
383
305
|
return (
|
|
384
306
|
<button
|
|
385
307
|
type="button"
|
|
386
|
-
className={`Modal-${
|
|
308
|
+
className={`Modal-${ModalButtonType}-button btn btn-${variant} ${last ? '' : 'mr-1'}`}
|
|
387
309
|
onClick={() => {
|
|
388
|
-
handleClose(
|
|
310
|
+
handleClose(ModalButtonType);
|
|
389
311
|
}}
|
|
390
312
|
>
|
|
391
313
|
{label}
|
|
@@ -406,45 +328,55 @@ const Modal: (
|
|
|
406
328
|
|
|
407
329
|
// Render the modal
|
|
408
330
|
return (
|
|
409
|
-
<
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
onHide={() => {
|
|
413
|
-
if (!dontAllowBackdropExit) {
|
|
414
|
-
handleClose(ButtonType.Cancel);
|
|
415
|
-
}
|
|
416
|
-
}}
|
|
331
|
+
<div
|
|
332
|
+
className={`modal show modal-dialog-scrollable modal-dialog-centered modal-${size}`}
|
|
333
|
+
tabIndex={-1}
|
|
417
334
|
style={{
|
|
418
335
|
zIndex: (
|
|
419
336
|
onTopOfOtherModals
|
|
420
337
|
? 6000000000
|
|
421
338
|
: 5000000000
|
|
422
339
|
),
|
|
340
|
+
display: 'block',
|
|
341
|
+
margin: 'auto',
|
|
342
|
+
left: 0,
|
|
343
|
+
right: 0,
|
|
423
344
|
}}
|
|
424
|
-
backdropClassName="Modal-backdrop"
|
|
425
|
-
centered
|
|
426
345
|
>
|
|
427
346
|
<style>{style}</style>
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
347
|
+
<div className="Modal-backdrop" />
|
|
348
|
+
<div className="modal-dialog">
|
|
349
|
+
<div className="modal-content">
|
|
350
|
+
<div className="modal-header">
|
|
351
|
+
<h5 className="modal-title">
|
|
352
|
+
{title}
|
|
353
|
+
</h5>
|
|
354
|
+
|
|
355
|
+
{onClose && (
|
|
356
|
+
<button
|
|
357
|
+
type="button"
|
|
358
|
+
className="btn-close"
|
|
359
|
+
data-bs-dismiss="modal"
|
|
360
|
+
aria-label="Close"
|
|
361
|
+
onClick={() => {
|
|
362
|
+
handleClose(ModalButtonType.Cancel);
|
|
363
|
+
}}
|
|
364
|
+
/>
|
|
365
|
+
)}
|
|
366
|
+
</div>
|
|
367
|
+
{children && (
|
|
368
|
+
<div className="modal-body">
|
|
369
|
+
{children}
|
|
370
|
+
</div>
|
|
371
|
+
)}
|
|
372
|
+
{footer && (
|
|
373
|
+
<div className="modal-footer">
|
|
374
|
+
{footer}
|
|
375
|
+
</div>
|
|
376
|
+
)}
|
|
377
|
+
</div>
|
|
378
|
+
</div>
|
|
379
|
+
</div>
|
|
448
380
|
);
|
|
449
381
|
};
|
|
450
382
|
|
|
@@ -452,10 +384,4 @@ const Modal: (
|
|
|
452
384
|
/* Wrap Up */
|
|
453
385
|
/*------------------------------------------------------------------------*/
|
|
454
386
|
|
|
455
|
-
// Add enums
|
|
456
|
-
Modal.ModalType = ModalType;
|
|
457
|
-
Modal.ModalSize = ModalSize;
|
|
458
|
-
Modal.ButtonType = ButtonType;
|
|
459
|
-
Modal.Variant = Variant;
|
|
460
|
-
|
|
461
387
|
export default Modal;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Import components
|
|
2
|
+
import AppWrapper, { alert, confirm, showFatalError } from './components/AppWrapper';
|
|
3
|
+
import LoadingSpinner from './components/LoadingSpinner';
|
|
4
|
+
import ErrorBox from './components/ErrorBox';
|
|
5
|
+
import Modal from './components/Modal';
|
|
6
|
+
import TabBox from './components/TabBox';
|
|
7
|
+
|
|
8
|
+
// Import errors
|
|
9
|
+
import ErrorWithCode from './errors/ErrorWithCode';
|
|
10
|
+
|
|
11
|
+
// Import helpers
|
|
12
|
+
import abbreviate from './helpers/abbreviate';
|
|
13
|
+
import avg from './helpers/avg';
|
|
14
|
+
import ceilToNumDecimals from './helpers/ceilToNumDecimals';
|
|
15
|
+
import floorToNumDecimals from './helpers/floorToNumDecimals';
|
|
16
|
+
import forceNumIntoBounds from './helpers/forceNumIntoBounds';
|
|
17
|
+
import padDecimalZeros from './helpers/padDecimalZeros';
|
|
18
|
+
import padZerosLeft from './helpers/padZerosLeft';
|
|
19
|
+
import roundToNumDecimals from './helpers/roundToNumDecimals';
|
|
20
|
+
import sum from './helpers/sum';
|
|
21
|
+
import waitMs from './helpers/waitMs';
|
|
22
|
+
|
|
23
|
+
// Import types
|
|
24
|
+
import ModalButtonType from './types/ModalButtonType';
|
|
25
|
+
import ModalSize from './types/ModalSize';
|
|
26
|
+
import ModalType from './types/ModalType';
|
|
27
|
+
import ReactKitErrorCode from './types/ReactKitErrorCode';
|
|
28
|
+
import Variant from './types/Variant';
|
|
29
|
+
|
|
30
|
+
// Export each item
|
|
31
|
+
export {
|
|
32
|
+
// Components
|
|
33
|
+
AppWrapper,
|
|
34
|
+
LoadingSpinner,
|
|
35
|
+
ErrorBox,
|
|
36
|
+
Modal,
|
|
37
|
+
TabBox,
|
|
38
|
+
// Global functions
|
|
39
|
+
alert,
|
|
40
|
+
confirm,
|
|
41
|
+
showFatalError,
|
|
42
|
+
// Errors
|
|
43
|
+
ErrorWithCode,
|
|
44
|
+
// Helpers
|
|
45
|
+
abbreviate,
|
|
46
|
+
avg,
|
|
47
|
+
ceilToNumDecimals,
|
|
48
|
+
floorToNumDecimals,
|
|
49
|
+
forceNumIntoBounds,
|
|
50
|
+
padDecimalZeros,
|
|
51
|
+
padZerosLeft,
|
|
52
|
+
roundToNumDecimals,
|
|
53
|
+
sum,
|
|
54
|
+
waitMs,
|
|
55
|
+
// Types
|
|
56
|
+
ModalButtonType,
|
|
57
|
+
ModalSize,
|
|
58
|
+
ModalType,
|
|
59
|
+
ReactKitErrorCode,
|
|
60
|
+
Variant,
|
|
61
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of buttons in the modal
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
enum ModalButtonType {
|
|
6
|
+
Okay = 'okay',
|
|
7
|
+
Cancel = 'cancel',
|
|
8
|
+
Yes = 'yes',
|
|
9
|
+
No = 'no',
|
|
10
|
+
Abandon = 'abandon',
|
|
11
|
+
GoBack = 'goBack',
|
|
12
|
+
Continue = 'continue',
|
|
13
|
+
ImSure = 'imSure',
|
|
14
|
+
Delete = 'delete',
|
|
15
|
+
Confirm = 'confirm',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default ModalButtonType;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of modals
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
enum ModalType {
|
|
6
|
+
Okay = 'okay', // [Okay]
|
|
7
|
+
OkayCancel = 'okay-cancel', // [Okay] [Cancel]
|
|
8
|
+
YesNo = 'yes-no', // [Yes] [No]
|
|
9
|
+
YesNoCancel = 'yes-no-cancel', // [Yes] [No] [Cancel]
|
|
10
|
+
AbandonGoBack = 'abandon-goBack', // [Abandon Changes] [Go Back]
|
|
11
|
+
ImSureCancel = 'imSure-cancel', // [I am sure] [Cancel]
|
|
12
|
+
DeleteCancel = 'delete-cancel', // [Yes, Delete] [Cancel]
|
|
13
|
+
ConfirmCancel = 'confirm-cancel', // [Confirm] [Cancel]
|
|
14
|
+
NoButtons = '-', // No buttons
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default ModalType;
|
package/tsconfig.json
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"
|
|
3
|
+
"target": "es2016",
|
|
4
4
|
"esModuleInterop": true,
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
"jsx": "react",
|
|
10
|
+
"module": "ESNext",
|
|
8
11
|
"declaration": true,
|
|
12
|
+
"declarationDir": "types",
|
|
9
13
|
"sourceMap": true,
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"dom"
|
|
15
|
-
],
|
|
16
|
-
"outDir": "./lib"
|
|
14
|
+
"outDir": "dist",
|
|
15
|
+
"moduleResolution": "node",
|
|
16
|
+
"allowSyntheticDefaultImports": true,
|
|
17
|
+
"emitDeclarationOnly": true
|
|
17
18
|
},
|
|
19
|
+
|
|
18
20
|
"include": [
|
|
19
|
-
"./src"
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
"files": true
|
|
23
|
-
}
|
|
24
|
-
}
|
|
21
|
+
"./src/**/*"
|
|
22
|
+
]
|
|
23
|
+
}
|