dce-reactkit 2.0.11 → 3.0.0-beta.10
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 +9 -4
- 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 +38 -37
- package/src/components/LoadingSpinner.tsx +3 -0
- package/src/components/Modal.tsx +86 -173
- 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 -5
- 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 -5
- 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 -5
- 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 -3
- package/src/helpers/confirm.tsx +0 -3
- 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 -3
- package/src/helpers/visitServerEndpoint.tsx +0 -110
- package/src/types/ParamType.ts +0 -18
package/src/components/Modal.tsx
CHANGED
|
@@ -7,65 +7,19 @@
|
|
|
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
|
-
.Modal-backdrop {
|
|
23
|
-
background-color: black !important;
|
|
24
|
-
opacity: 0.8 !important;
|
|
25
|
-
z-index: 10000000 !important;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* Customize the modal header and body */
|
|
29
|
-
.modal-header {
|
|
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
|
-
}
|
|
68
|
-
}
|
|
69
23
|
`;
|
|
70
24
|
|
|
71
25
|
/*------------------------------------------------------------------------*/
|
|
@@ -77,118 +31,83 @@ const MS_TO_ANIMATE = 400; // Time to animate in/out (defined by bootstrap)
|
|
|
77
31
|
const MS_ANIMATE_IN_DELAY = 10;
|
|
78
32
|
// Time to wait before animating in (must be >0 or animation won't trigger)
|
|
79
33
|
|
|
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
34
|
// Modal type to list of buttons
|
|
116
|
-
const
|
|
117
|
-
[k: string]:
|
|
35
|
+
const modalTypeToModalButtonTypes: {
|
|
36
|
+
[k: string]: ModalButtonType[]
|
|
118
37
|
} = {
|
|
119
38
|
[ModalType.Okay]: [
|
|
120
|
-
|
|
39
|
+
ModalButtonType.Okay,
|
|
121
40
|
],
|
|
122
41
|
[ModalType.OkayCancel]: [
|
|
123
|
-
|
|
124
|
-
|
|
42
|
+
ModalButtonType.Okay,
|
|
43
|
+
ModalButtonType.Cancel,
|
|
125
44
|
],
|
|
126
45
|
[ModalType.YesNo]: [
|
|
127
|
-
|
|
128
|
-
|
|
46
|
+
ModalButtonType.Yes,
|
|
47
|
+
ModalButtonType.No,
|
|
129
48
|
],
|
|
130
49
|
[ModalType.YesNoCancel]: [
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
50
|
+
ModalButtonType.Yes,
|
|
51
|
+
ModalButtonType.No,
|
|
52
|
+
ModalButtonType.Cancel,
|
|
134
53
|
],
|
|
135
54
|
[ModalType.AbandonGoBack]: [
|
|
136
|
-
|
|
137
|
-
|
|
55
|
+
ModalButtonType.Abandon,
|
|
56
|
+
ModalButtonType.GoBack,
|
|
138
57
|
],
|
|
139
58
|
[ModalType.ImSureCancel]: [
|
|
140
|
-
|
|
141
|
-
|
|
59
|
+
ModalButtonType.ImSure,
|
|
60
|
+
ModalButtonType.Cancel,
|
|
142
61
|
],
|
|
143
62
|
[ModalType.DeleteCancel]: [
|
|
144
|
-
|
|
145
|
-
|
|
63
|
+
ModalButtonType.Delete,
|
|
64
|
+
ModalButtonType.Cancel,
|
|
146
65
|
],
|
|
147
66
|
[ModalType.ConfirmCancel]: [
|
|
148
|
-
|
|
149
|
-
|
|
67
|
+
ModalButtonType.Confirm,
|
|
68
|
+
ModalButtonType.Cancel,
|
|
150
69
|
],
|
|
151
70
|
};
|
|
152
71
|
|
|
153
72
|
// Button type styling and labels
|
|
154
|
-
const
|
|
155
|
-
[
|
|
73
|
+
const ModalButtonTypeToLabelAndVariant = {
|
|
74
|
+
[ModalButtonType.Okay]: {
|
|
156
75
|
label: 'Okay',
|
|
157
76
|
variant: Variant.Dark,
|
|
158
77
|
},
|
|
159
|
-
[
|
|
78
|
+
[ModalButtonType.Cancel]: {
|
|
160
79
|
label: 'Cancel',
|
|
161
80
|
variant: Variant.Secondary,
|
|
162
81
|
},
|
|
163
|
-
[
|
|
82
|
+
[ModalButtonType.Yes]: {
|
|
164
83
|
label: 'Yes',
|
|
165
84
|
variant: Variant.Dark,
|
|
166
85
|
},
|
|
167
|
-
[
|
|
86
|
+
[ModalButtonType.No]: {
|
|
168
87
|
label: 'No',
|
|
169
88
|
variant: Variant.Secondary,
|
|
170
89
|
},
|
|
171
|
-
[
|
|
90
|
+
[ModalButtonType.Abandon]: {
|
|
172
91
|
label: 'Abandon Changes',
|
|
173
92
|
variant: Variant.Warning,
|
|
174
93
|
},
|
|
175
|
-
[
|
|
94
|
+
[ModalButtonType.GoBack]: {
|
|
176
95
|
label: 'Go Back',
|
|
177
96
|
variant: Variant.Secondary,
|
|
178
97
|
},
|
|
179
|
-
[
|
|
98
|
+
[ModalButtonType.Continue]: {
|
|
180
99
|
label: 'Continue',
|
|
181
100
|
variant: Variant.Dark,
|
|
182
101
|
},
|
|
183
|
-
[
|
|
102
|
+
[ModalButtonType.ImSure]: {
|
|
184
103
|
label: 'I am sure',
|
|
185
104
|
variant: Variant.Warning,
|
|
186
105
|
},
|
|
187
|
-
[
|
|
106
|
+
[ModalButtonType.Delete]: {
|
|
188
107
|
label: 'Yes, Delete',
|
|
189
108
|
variant: Variant.Danger,
|
|
190
109
|
},
|
|
191
|
-
[
|
|
110
|
+
[ModalButtonType.Confirm]: {
|
|
192
111
|
label: 'Confirm',
|
|
193
112
|
variant: Variant.Dark,
|
|
194
113
|
},
|
|
@@ -208,7 +127,7 @@ type Props = {
|
|
|
208
127
|
// The body of the modal
|
|
209
128
|
children?: React.ReactNode,
|
|
210
129
|
// Handler to call when modal is closed (if excluded, not closable)
|
|
211
|
-
onClose?: (type:
|
|
130
|
+
onClose?: (type: ModalButtonType) => void,
|
|
212
131
|
// If true, don't allow the user to click the backdrop to exit
|
|
213
132
|
dontAllowBackdropExit?: boolean,
|
|
214
133
|
// Custom label for "okay" button
|
|
@@ -259,15 +178,7 @@ type Props = {
|
|
|
259
178
|
/* Component */
|
|
260
179
|
/*------------------------------------------------------------------------*/
|
|
261
180
|
|
|
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) => {
|
|
181
|
+
const Modal: React.FC<Props> = (props) => {
|
|
271
182
|
/*------------------------------------------------------------------------*/
|
|
272
183
|
/* Setup */
|
|
273
184
|
/*------------------------------------------------------------------------*/
|
|
@@ -322,10 +233,10 @@ const Modal: (
|
|
|
322
233
|
/**
|
|
323
234
|
* Handles the closing of the modal
|
|
324
235
|
* @author Gabe Abrams
|
|
325
|
-
* @param
|
|
236
|
+
* @param ModalButtonType the button that was clicked when closing the
|
|
326
237
|
* modal
|
|
327
238
|
*/
|
|
328
|
-
const handleClose = async (
|
|
239
|
+
const handleClose = async (ModalButtonType: ModalButtonType) => {
|
|
329
240
|
// Don't close if no handler
|
|
330
241
|
if (!onClose) {
|
|
331
242
|
return;
|
|
@@ -346,7 +257,7 @@ const Modal: (
|
|
|
346
257
|
|
|
347
258
|
// Call the handler after the modal has animated out
|
|
348
259
|
await waitMs(MS_TO_ANIMATE);
|
|
349
|
-
onClose(
|
|
260
|
+
onClose(ModalButtonType);
|
|
350
261
|
};
|
|
351
262
|
|
|
352
263
|
/*------------------------------------------------------------------------*/
|
|
@@ -358,34 +269,36 @@ const Modal: (
|
|
|
358
269
|
/*----------------------------------------*/
|
|
359
270
|
|
|
360
271
|
// Get list of buttons for this modal type
|
|
361
|
-
const
|
|
272
|
+
const ModalButtonTypes: ModalButtonType[] = modalTypeToModalButtonTypes[type] ?? [];
|
|
362
273
|
|
|
363
274
|
// Create buttons
|
|
364
|
-
const buttons =
|
|
275
|
+
const buttons = ModalButtonTypes.map((ModalButtonType: ModalButtonType, i) => {
|
|
365
276
|
// Get default style
|
|
366
277
|
let {
|
|
367
278
|
label,
|
|
368
279
|
variant,
|
|
369
|
-
} =
|
|
280
|
+
} = ModalButtonTypeToLabelAndVariant[ModalButtonType];
|
|
370
281
|
|
|
371
282
|
// Override with customizations
|
|
372
|
-
|
|
373
|
-
|
|
283
|
+
const newLabel = props[`${ModalButtonType}Label`];
|
|
284
|
+
if (newLabel) {
|
|
285
|
+
label = newLabel;
|
|
374
286
|
}
|
|
375
|
-
|
|
376
|
-
|
|
287
|
+
const newVariant = props[`${ModalButtonType}Variant`];
|
|
288
|
+
if (newVariant) {
|
|
289
|
+
variant = newVariant;
|
|
377
290
|
}
|
|
378
291
|
|
|
379
292
|
// Check if this button is last
|
|
380
|
-
const last = (i ===
|
|
293
|
+
const last = (i === ModalButtonTypes.length - 1);
|
|
381
294
|
|
|
382
295
|
// Create the button
|
|
383
296
|
return (
|
|
384
297
|
<button
|
|
385
298
|
type="button"
|
|
386
|
-
className={`Modal-${
|
|
299
|
+
className={`Modal-${ModalButtonType}-button btn btn-${variant} ${last ? '' : 'mr-1'}`}
|
|
387
300
|
onClick={() => {
|
|
388
|
-
handleClose(
|
|
301
|
+
handleClose(ModalButtonType);
|
|
389
302
|
}}
|
|
390
303
|
>
|
|
391
304
|
{label}
|
|
@@ -406,45 +319,51 @@ const Modal: (
|
|
|
406
319
|
|
|
407
320
|
// Render the modal
|
|
408
321
|
return (
|
|
409
|
-
<
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
onHide={() => {
|
|
413
|
-
if (!dontAllowBackdropExit) {
|
|
414
|
-
handleClose(ButtonType.Cancel);
|
|
415
|
-
}
|
|
416
|
-
}}
|
|
322
|
+
<div
|
|
323
|
+
className={`modal show modal-dialog-scrollable modal-dialog-centered modal-${size}`}
|
|
324
|
+
tabIndex={-1}
|
|
417
325
|
style={{
|
|
418
326
|
zIndex: (
|
|
419
327
|
onTopOfOtherModals
|
|
420
328
|
? 6000000000
|
|
421
329
|
: 5000000000
|
|
422
330
|
),
|
|
331
|
+
display: 'block',
|
|
332
|
+
margin: 'auto',
|
|
423
333
|
}}
|
|
424
|
-
backdropClassName="Modal-backdrop"
|
|
425
|
-
centered
|
|
426
334
|
>
|
|
427
|
-
<
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
335
|
+
<div className="modal-dialog">
|
|
336
|
+
<div className="modal-content">
|
|
337
|
+
<div className="modal-header">
|
|
338
|
+
<h5 className="modal-title">
|
|
339
|
+
{title}
|
|
340
|
+
</h5>
|
|
341
|
+
|
|
342
|
+
{onClose && (
|
|
343
|
+
<button
|
|
344
|
+
type="button"
|
|
345
|
+
className="btn-close"
|
|
346
|
+
data-bs-dismiss="modal"
|
|
347
|
+
aria-label="Close"
|
|
348
|
+
onClick={() => {
|
|
349
|
+
handleClose(ModalButtonType.Cancel);
|
|
350
|
+
}}
|
|
351
|
+
/>
|
|
352
|
+
)}
|
|
353
|
+
</div>
|
|
354
|
+
{children && (
|
|
355
|
+
<div className="modal-body">
|
|
356
|
+
{children}
|
|
357
|
+
</div>
|
|
358
|
+
)}
|
|
359
|
+
{footer && (
|
|
360
|
+
<div className="modal-footer">
|
|
361
|
+
{footer}
|
|
362
|
+
</div>
|
|
363
|
+
)}
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
</div>
|
|
448
367
|
);
|
|
449
368
|
};
|
|
450
369
|
|
|
@@ -452,10 +371,4 @@ const Modal: (
|
|
|
452
371
|
/* Wrap Up */
|
|
453
372
|
/*------------------------------------------------------------------------*/
|
|
454
373
|
|
|
455
|
-
// Add enums
|
|
456
|
-
Modal.ModalType = ModalType;
|
|
457
|
-
Modal.ModalSize = ModalSize;
|
|
458
|
-
Modal.ButtonType = ButtonType;
|
|
459
|
-
Modal.Variant = Variant;
|
|
460
|
-
|
|
461
374
|
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
|
+
}
|