dce-reactkit 3.0.0 → 3.0.3
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/README.md +1 -546
- package/dist/cjs/index.js +1826 -0
- package/dist/cjs/index.js.map +1 -0
- package/{lib/esm → dist/cjs}/types/components/AppWrapper.d.ts +29 -4
- package/dist/cjs/types/components/ButtonInputGroup.d.ts +12 -0
- package/dist/cjs/types/components/CheckboxButton.d.ts +20 -0
- package/dist/cjs/types/components/Drawer.d.ts +10 -0
- package/{lib/cjs/lib → dist/cjs/types}/components/ErrorBox.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/components/LoadingSpinner.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/components/Modal.d.ts +0 -0
- package/dist/cjs/types/components/RadioButton.d.ts +20 -0
- package/dist/cjs/types/components/SimpleDateChooser.d.ts +22 -0
- package/{lib/esm/lib → dist/cjs/types}/components/TabBox.d.ts +1 -0
- package/{lib/cjs/lib → dist/cjs/types}/errors/ErrorWithCode.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/abbreviate.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/avg.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/ceilToNumDecimals.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/floorToNumDecimals.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/forceNumIntoBounds.d.ts +0 -0
- package/dist/cjs/types/helpers/genRouteHandler.d.ts +32 -0
- package/dist/cjs/types/helpers/getOrdinal.d.ts +8 -0
- package/dist/cjs/types/helpers/getTimeInfoInET.d.ts +17 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/handleError.d.ts +5 -1
- package/{lib/cjs/lib → dist/cjs/types}/helpers/handleSuccess.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/padDecimalZeros.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/padZerosLeft.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/roundToNumDecimals.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/sum.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/visitServerEndpoint.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/helpers/waitMs.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/index.d.ts +14 -6
- package/dist/cjs/types/server/initServer.d.ts +21 -0
- package/{lib/cjs/lib → dist/cjs/types}/types/ModalButtonType.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/types/ModalSize.d.ts +0 -0
- package/{lib/cjs/lib → dist/cjs/types}/types/ModalType.d.ts +0 -0
- package/{lib → dist}/cjs/types/types/ParamType.d.ts +1 -1
- package/{lib → dist}/cjs/types/types/ReactKitErrorCode.d.ts +3 -1
- package/{lib/cjs/lib → dist/cjs/types}/types/Variant.d.ts +0 -0
- package/dist/esm/index.js +1782 -0
- package/dist/esm/index.js.map +1 -0
- package/{lib/cjs → dist/esm}/types/components/AppWrapper.d.ts +29 -4
- package/dist/esm/types/components/ButtonInputGroup.d.ts +12 -0
- package/dist/esm/types/components/CheckboxButton.d.ts +20 -0
- package/dist/esm/types/components/Drawer.d.ts +10 -0
- package/{lib/cjs → dist/esm}/types/components/ErrorBox.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/components/LoadingSpinner.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/components/Modal.d.ts +0 -0
- package/dist/esm/types/components/RadioButton.d.ts +20 -0
- package/dist/esm/types/components/SimpleDateChooser.d.ts +22 -0
- package/{lib/cjs/lib → dist/esm/types}/components/TabBox.d.ts +1 -0
- package/{lib/cjs → dist/esm}/types/errors/ErrorWithCode.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/helpers/abbreviate.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/helpers/avg.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/helpers/ceilToNumDecimals.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/helpers/floorToNumDecimals.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/helpers/forceNumIntoBounds.d.ts +0 -0
- package/dist/esm/types/helpers/genRouteHandler.d.ts +32 -0
- package/dist/esm/types/helpers/getOrdinal.d.ts +8 -0
- package/dist/esm/types/helpers/getTimeInfoInET.d.ts +17 -0
- package/{lib/cjs → dist/esm}/types/helpers/handleError.d.ts +5 -1
- package/{lib/cjs → dist/esm}/types/helpers/handleSuccess.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/helpers/padDecimalZeros.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/helpers/padZerosLeft.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/helpers/roundToNumDecimals.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/helpers/sum.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/helpers/visitServerEndpoint.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/helpers/waitMs.d.ts +0 -0
- package/{lib/esm/lib → dist/esm/types}/index.d.ts +14 -6
- package/dist/esm/types/server/initServer.d.ts +21 -0
- package/{lib/cjs → dist/esm}/types/types/ModalButtonType.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/types/ModalSize.d.ts +0 -0
- package/{lib/cjs → dist/esm}/types/types/ModalType.d.ts +0 -0
- package/{lib/esm/lib → dist/esm/types}/types/ParamType.d.ts +1 -1
- package/{lib/esm/lib → dist/esm/types}/types/ReactKitErrorCode.d.ts +3 -1
- package/{lib/cjs → dist/esm}/types/types/Variant.d.ts +0 -0
- package/dist/index.d.ts +505 -0
- package/package.json +18 -29
- package/rollup.config.js +14 -13
- package/src/components/AppWrapper.tsx +85 -18
- package/src/components/ButtonInputGroup.tsx +89 -0
- package/src/components/CheckboxButton.tsx +100 -0
- package/src/components/Drawer.tsx +76 -0
- package/src/components/ErrorBox.tsx +4 -4
- package/src/components/LoadingSpinner.tsx +3 -3
- package/src/components/Modal.tsx +214 -97
- package/src/components/RadioButton.tsx +102 -0
- package/src/components/SimpleDateChooser.tsx +222 -0
- package/src/components/TabBox.tsx +65 -58
- package/src/helpers/genRouteHandler.ts +329 -0
- package/src/helpers/getOrdinal.tsx +13 -0
- package/src/helpers/getTimeInfoInET.tsx +56 -0
- package/src/helpers/handleError.ts +65 -0
- package/src/helpers/handleSuccess.ts +18 -0
- package/src/helpers/visitServerEndpoint.tsx +110 -0
- package/src/index.ts +29 -0
- package/src/server/initServer.ts +53 -0
- package/src/types/ParamType.ts +18 -0
- package/src/types/ReactKitErrorCode.tsx +3 -1
- package/tsconfig.json +9 -7
- package/lib/cjs/index.js +0 -2
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/lib/components/AppWrapper.d.ts +0 -35
- package/lib/cjs/lib/helpers/parseRequest.d.ts +0 -21
- package/lib/cjs/lib/types/ParamType.d.ts +0 -17
- package/lib/cjs/lib/types/ReactKitErrorCode.d.ts +0 -13
- package/lib/cjs/types/components/TabBox.d.ts +0 -11
- package/lib/cjs/types/helpers/alert.d.ts +0 -2
- package/lib/cjs/types/helpers/confirm.d.ts +0 -2
- package/lib/cjs/types/helpers/parseRequest.d.ts +0 -21
- package/lib/cjs/types/helpers/showFatalError.d.ts +0 -2
- package/lib/cjs/types/index.d.ts +0 -22
- package/lib/esm/index.js +0 -16
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/lib/components/AppWrapper.d.ts +0 -35
- package/lib/esm/lib/components/ErrorBox.d.ts +0 -12
- package/lib/esm/lib/components/LoadingSpinner.d.ts +0 -7
- package/lib/esm/lib/components/Modal.d.ts +0 -40
- package/lib/esm/lib/errors/ErrorWithCode.d.ts +0 -9
- package/lib/esm/lib/helpers/abbreviate.d.ts +0 -10
- package/lib/esm/lib/helpers/avg.d.ts +0 -8
- package/lib/esm/lib/helpers/ceilToNumDecimals.d.ts +0 -9
- package/lib/esm/lib/helpers/floorToNumDecimals.d.ts +0 -9
- package/lib/esm/lib/helpers/forceNumIntoBounds.d.ts +0 -10
- package/lib/esm/lib/helpers/handleError.d.ts +0 -14
- package/lib/esm/lib/helpers/handleSuccess.d.ts +0 -8
- package/lib/esm/lib/helpers/padDecimalZeros.d.ts +0 -10
- package/lib/esm/lib/helpers/padZerosLeft.d.ts +0 -9
- package/lib/esm/lib/helpers/parseRequest.d.ts +0 -21
- package/lib/esm/lib/helpers/roundToNumDecimals.d.ts +0 -9
- package/lib/esm/lib/helpers/sum.d.ts +0 -8
- package/lib/esm/lib/helpers/visitServerEndpoint.d.ts +0 -23
- package/lib/esm/lib/helpers/waitMs.d.ts +0 -7
- package/lib/esm/lib/types/ModalButtonType.d.ts +0 -17
- package/lib/esm/lib/types/ModalSize.d.ts +0 -11
- package/lib/esm/lib/types/ModalType.d.ts +0 -16
- package/lib/esm/lib/types/Variant.d.ts +0 -15
- package/lib/esm/types/components/ErrorBox.d.ts +0 -12
- package/lib/esm/types/components/LoadingSpinner.d.ts +0 -7
- package/lib/esm/types/components/Modal.d.ts +0 -40
- package/lib/esm/types/components/TabBox.d.ts +0 -11
- package/lib/esm/types/errors/ErrorWithCode.d.ts +0 -9
- package/lib/esm/types/helpers/abbreviate.d.ts +0 -10
- package/lib/esm/types/helpers/alert.d.ts +0 -2
- package/lib/esm/types/helpers/avg.d.ts +0 -8
- package/lib/esm/types/helpers/ceilToNumDecimals.d.ts +0 -9
- package/lib/esm/types/helpers/confirm.d.ts +0 -2
- package/lib/esm/types/helpers/floorToNumDecimals.d.ts +0 -9
- package/lib/esm/types/helpers/forceNumIntoBounds.d.ts +0 -10
- package/lib/esm/types/helpers/handleError.d.ts +0 -14
- package/lib/esm/types/helpers/handleSuccess.d.ts +0 -8
- package/lib/esm/types/helpers/padDecimalZeros.d.ts +0 -10
- package/lib/esm/types/helpers/padZerosLeft.d.ts +0 -9
- package/lib/esm/types/helpers/parseRequest.d.ts +0 -21
- package/lib/esm/types/helpers/roundToNumDecimals.d.ts +0 -9
- package/lib/esm/types/helpers/showFatalError.d.ts +0 -2
- package/lib/esm/types/helpers/sum.d.ts +0 -8
- package/lib/esm/types/helpers/visitServerEndpoint.d.ts +0 -23
- package/lib/esm/types/helpers/waitMs.d.ts +0 -7
- package/lib/esm/types/index.d.ts +0 -22
- package/lib/esm/types/types/ModalButtonType.d.ts +0 -17
- package/lib/esm/types/types/ModalSize.d.ts +0 -11
- package/lib/esm/types/types/ModalType.d.ts +0 -16
- package/lib/esm/types/types/ParamType.d.ts +0 -17
- package/lib/esm/types/types/ReactKitErrorCode.d.ts +0 -13
- package/lib/esm/types/types/Variant.d.ts +0 -15
- package/lib/index.d.ts +0 -274
package/src/components/Modal.tsx
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
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
|
|
@@ -16,69 +15,12 @@ import ModalButtonType from '../types/ModalButtonType';
|
|
|
16
15
|
import ModalSize from '../types/ModalSize';
|
|
17
16
|
import ModalType from '../types/ModalType';
|
|
18
17
|
|
|
19
|
-
/*------------------------------------------------------------------------*/
|
|
20
|
-
/* Style */
|
|
21
|
-
/*------------------------------------------------------------------------*/
|
|
22
|
-
|
|
23
|
-
const style = `
|
|
24
|
-
/* More opaque backdrop */
|
|
25
|
-
.Modal-backdrop {
|
|
26
|
-
background-color: black !important;
|
|
27
|
-
opacity: 0.8 !important;
|
|
28
|
-
z-index: 10000000 !important;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/* Customize the modal header and body */
|
|
32
|
-
.modal-header {
|
|
33
|
-
/* Dark theme */
|
|
34
|
-
background-color: #222 !important;
|
|
35
|
-
color: white !important;
|
|
36
|
-
|
|
37
|
-
/* Border */
|
|
38
|
-
border: 1px solid #545454 !important;
|
|
39
|
-
}
|
|
40
|
-
.modal-body {
|
|
41
|
-
/* Dark theme */
|
|
42
|
-
background-color: #222 !important;
|
|
43
|
-
color: white !important;
|
|
44
|
-
|
|
45
|
-
/* Border */
|
|
46
|
-
border-top: 0 !important;
|
|
47
|
-
border-left: 1px solid #545454 !important;
|
|
48
|
-
border-bottom: 1px solid #545454 !important;
|
|
49
|
-
border-right: 1px solid #545454 !important;
|
|
50
|
-
border-bottom-left-radius: 3px;
|
|
51
|
-
border-bottom-right-radius: 3px;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/* Create our own animation */
|
|
55
|
-
.modal-content {
|
|
56
|
-
animation-name: Modal-drop-in;
|
|
57
|
-
animation-duration: 0.4s;
|
|
58
|
-
animation-iteration-count: 1;
|
|
59
|
-
animation-fill-mode: forwards;
|
|
60
|
-
animation-timing-function: ease-out;
|
|
61
|
-
}
|
|
62
|
-
@keyframes Modal-drop-in {
|
|
63
|
-
0% {
|
|
64
|
-
transform: scale(0.8);
|
|
65
|
-
opacity: 0.5;
|
|
66
|
-
}
|
|
67
|
-
100% {
|
|
68
|
-
transform: scale(1);
|
|
69
|
-
opacity: 1;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
`;
|
|
73
|
-
|
|
74
18
|
/*------------------------------------------------------------------------*/
|
|
75
19
|
/* Constants */
|
|
76
20
|
/*------------------------------------------------------------------------*/
|
|
77
21
|
|
|
78
22
|
// Constants
|
|
79
|
-
const MS_TO_ANIMATE =
|
|
80
|
-
const MS_ANIMATE_IN_DELAY = 10;
|
|
81
|
-
// Time to wait before animating in (must be >0 or animation won't trigger)
|
|
23
|
+
const MS_TO_ANIMATE = 200; // Animation duration
|
|
82
24
|
|
|
83
25
|
// Modal type to list of buttons
|
|
84
26
|
const modalTypeToModalButtonTypes: {
|
|
@@ -162,6 +104,116 @@ const ModalButtonTypeToLabelAndVariant = {
|
|
|
162
104
|
},
|
|
163
105
|
};
|
|
164
106
|
|
|
107
|
+
/*------------------------------------------------------------------------*/
|
|
108
|
+
/* Style */
|
|
109
|
+
/*------------------------------------------------------------------------*/
|
|
110
|
+
|
|
111
|
+
const style = `
|
|
112
|
+
.Modal-backdrop {
|
|
113
|
+
position: fixed;
|
|
114
|
+
top: 0;
|
|
115
|
+
left: 0;
|
|
116
|
+
width: 100vw;
|
|
117
|
+
height: 100vw;
|
|
118
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.Modal-fading-in {
|
|
122
|
+
animation-name: Modal-fading-in;
|
|
123
|
+
animation-duration: ${Math.floor(MS_TO_ANIMATE * 2)}ms;
|
|
124
|
+
animation-iteration-count: 1;
|
|
125
|
+
animation-fill-mode: both;
|
|
126
|
+
animation-timing-function: ease-out;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@keyframes Modal-fading-in {
|
|
130
|
+
0% {
|
|
131
|
+
opacity: 0;
|
|
132
|
+
}
|
|
133
|
+
100% {
|
|
134
|
+
opacity: 1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.Modal-fading-out {
|
|
139
|
+
animation-name: Modal-fading-out;
|
|
140
|
+
animation-duration: ${MS_TO_ANIMATE}ms;
|
|
141
|
+
animation-iteration-count: 1;
|
|
142
|
+
animation-fill-mode: both;
|
|
143
|
+
animation-timing-function: ease-in;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@keyframes Modal-fading-out {
|
|
147
|
+
0% {
|
|
148
|
+
opacity: 1;
|
|
149
|
+
}
|
|
150
|
+
100% {
|
|
151
|
+
opacity: 0;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.Modal-animating-in {
|
|
156
|
+
animation-name: Modal-animating-in;
|
|
157
|
+
animation-duration: ${MS_TO_ANIMATE}ms;
|
|
158
|
+
animation-iteration-count: 1;
|
|
159
|
+
animation-fill-mode: both;
|
|
160
|
+
animation-timing-function: ease-out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@keyframes Modal-animating-in {
|
|
164
|
+
0% {
|
|
165
|
+
transform: scale(1.05) translate(0, -1.5rem);
|
|
166
|
+
opacity: 0;
|
|
167
|
+
}
|
|
168
|
+
100% {
|
|
169
|
+
transform: scale(1) translate(0, 0);
|
|
170
|
+
opacity: 1;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.Modal-animating-pop {
|
|
175
|
+
animation-name: Modal-animating-pop;
|
|
176
|
+
animation-duration: ${MS_TO_ANIMATE}ms;
|
|
177
|
+
animation-iteration-count: 1;
|
|
178
|
+
animation-fill-mode: both;
|
|
179
|
+
animation-timing-function: ease-in-out;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@keyframes Modal-animating-pop {
|
|
183
|
+
0% {
|
|
184
|
+
transform: scale(1);
|
|
185
|
+
opacity: 1;
|
|
186
|
+
}
|
|
187
|
+
50% {
|
|
188
|
+
transform: scale(1.05);
|
|
189
|
+
opacity: 0.9;
|
|
190
|
+
}
|
|
191
|
+
100% {
|
|
192
|
+
transform: scale(1);
|
|
193
|
+
opacity: 1;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.Modal-animating-out {
|
|
198
|
+
animation-name: Modal-animating-out;
|
|
199
|
+
animation-duration: ${MS_TO_ANIMATE}ms;
|
|
200
|
+
animation-iteration-count: 1;
|
|
201
|
+
animation-fill-mode: both;
|
|
202
|
+
animation-timing-function: ease-in;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
@keyframes Modal-animating-out {
|
|
206
|
+
0% {
|
|
207
|
+
transform: scale(1) translate(0, 0);
|
|
208
|
+
opacity: 1;
|
|
209
|
+
}
|
|
210
|
+
100% {
|
|
211
|
+
transform: scale(1.05) translate(0, -1.5rem);
|
|
212
|
+
opacity: 0;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
`;
|
|
216
|
+
|
|
165
217
|
/*------------------------------------------------------------------------*/
|
|
166
218
|
/* Types */
|
|
167
219
|
/*------------------------------------------------------------------------*/
|
|
@@ -246,11 +298,17 @@ const Modal: React.FC<Props> = (props) => {
|
|
|
246
298
|
|
|
247
299
|
/* -------------- State ------------- */
|
|
248
300
|
|
|
301
|
+
// If true, the modal is completely gone
|
|
302
|
+
// (not just invisible, also removed from the dom)
|
|
303
|
+
const [gone, setGone] = useState(false);
|
|
304
|
+
|
|
249
305
|
// If true, the modal is shown
|
|
250
306
|
const [visible, setVisible] = useState(false);
|
|
251
307
|
|
|
252
|
-
// True if
|
|
253
|
-
const [animatingIn, setAnimatingIn] = useState(
|
|
308
|
+
// True if animation is in use
|
|
309
|
+
const [animatingIn, setAnimatingIn] = useState(true);
|
|
310
|
+
const [animatingPop, setAnimatingPop] = useState(false);
|
|
311
|
+
const [animatingOut, setAnimatingOut] = useState(false);
|
|
254
312
|
|
|
255
313
|
/*------------------------------------------------------------------------*/
|
|
256
314
|
/* Lifecycle Functions */
|
|
@@ -263,13 +321,10 @@ const Modal: React.FC<Props> = (props) => {
|
|
|
263
321
|
useEffect(
|
|
264
322
|
() => {
|
|
265
323
|
(async () => {
|
|
266
|
-
// Start the component animating in
|
|
267
|
-
await waitMs(MS_ANIMATE_IN_DELAY);
|
|
268
|
-
setAnimatingIn(true);
|
|
269
|
-
|
|
270
324
|
// Wait and then set visible to true
|
|
271
325
|
await waitMs(MS_TO_ANIMATE);
|
|
272
326
|
setVisible(true);
|
|
327
|
+
setAnimatingIn(false);
|
|
273
328
|
})();
|
|
274
329
|
},
|
|
275
330
|
[],
|
|
@@ -303,16 +358,23 @@ const Modal: React.FC<Props> = (props) => {
|
|
|
303
358
|
|
|
304
359
|
// Update the state
|
|
305
360
|
setVisible(false);
|
|
361
|
+
setAnimatingOut(true);
|
|
306
362
|
|
|
307
363
|
// Call the handler after the modal has animated out
|
|
308
364
|
await waitMs(MS_TO_ANIMATE);
|
|
309
365
|
onClose(ModalButtonType);
|
|
366
|
+
setGone(true);
|
|
310
367
|
};
|
|
311
368
|
|
|
312
369
|
/*------------------------------------------------------------------------*/
|
|
313
370
|
/* Render */
|
|
314
371
|
/*------------------------------------------------------------------------*/
|
|
315
372
|
|
|
373
|
+
// Return nothing if gone
|
|
374
|
+
if (gone) {
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
|
|
316
378
|
/*----------------------------------------*/
|
|
317
379
|
/* Footer */
|
|
318
380
|
/*----------------------------------------*/
|
|
@@ -344,8 +406,9 @@ const Modal: React.FC<Props> = (props) => {
|
|
|
344
406
|
// Create the button
|
|
345
407
|
return (
|
|
346
408
|
<button
|
|
409
|
+
key={ModalButtonType}
|
|
347
410
|
type="button"
|
|
348
|
-
className={`Modal-${ModalButtonType}-button btn btn-${variant} ${last ? '' : '
|
|
411
|
+
className={`Modal-${ModalButtonType}-button btn btn-${variant} ${last ? '' : 'me-1'}`}
|
|
349
412
|
onClick={() => {
|
|
350
413
|
handleClose(ModalButtonType);
|
|
351
414
|
}}
|
|
@@ -366,47 +429,101 @@ const Modal: React.FC<Props> = (props) => {
|
|
|
366
429
|
: undefined
|
|
367
430
|
);
|
|
368
431
|
|
|
432
|
+
// Choose an animation
|
|
433
|
+
let animationClass = '';
|
|
434
|
+
let backdropAnimationClass = '';
|
|
435
|
+
if (animatingIn) {
|
|
436
|
+
animationClass = 'Modal-animating-in';
|
|
437
|
+
backdropAnimationClass = 'Modal-fading-in';
|
|
438
|
+
} else if (animatingOut) {
|
|
439
|
+
animationClass = 'Modal-animating-out';
|
|
440
|
+
backdropAnimationClass = 'Modal-fading-out';
|
|
441
|
+
} else if (animatingPop) {
|
|
442
|
+
animationClass = 'Modal-animating-pop';
|
|
443
|
+
}
|
|
444
|
+
|
|
369
445
|
// Render the modal
|
|
370
446
|
return (
|
|
371
|
-
<
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
onHide={() => {
|
|
375
|
-
if (!dontAllowBackdropExit) {
|
|
376
|
-
handleClose(ModalButtonType.Cancel);
|
|
377
|
-
}
|
|
378
|
-
}}
|
|
447
|
+
<div
|
|
448
|
+
className={`modal show modal-dialog-scrollable modal-dialog-centered modal-${size}`}
|
|
449
|
+
tabIndex={-1}
|
|
379
450
|
style={{
|
|
380
451
|
zIndex: (
|
|
381
452
|
onTopOfOtherModals
|
|
382
|
-
?
|
|
453
|
+
? 5000000001
|
|
383
454
|
: 5000000000
|
|
384
455
|
),
|
|
456
|
+
display: 'block',
|
|
457
|
+
margin: 'auto',
|
|
458
|
+
left: 0,
|
|
459
|
+
right: 0,
|
|
385
460
|
}}
|
|
386
|
-
backdropClassName="Modal-backdrop"
|
|
387
|
-
centered
|
|
388
461
|
>
|
|
389
462
|
<style>{style}</style>
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
463
|
+
<div
|
|
464
|
+
className={`Modal-backdrop ${backdropAnimationClass}`}
|
|
465
|
+
style={{
|
|
466
|
+
zIndex: 5000000003,
|
|
467
|
+
}}
|
|
468
|
+
onClick={async () => {
|
|
469
|
+
// Skip if exit via backdrop not allowed
|
|
470
|
+
if (dontAllowBackdropExit || !onClose) {
|
|
471
|
+
// Show pop animation
|
|
472
|
+
if (!animatingPop) {
|
|
473
|
+
setAnimatingPop(true);
|
|
474
|
+
|
|
475
|
+
// Wait then stop pop animation
|
|
476
|
+
await waitMs(MS_TO_ANIMATE);
|
|
477
|
+
setAnimatingPop(false);
|
|
478
|
+
}
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
// Handle close
|
|
482
|
+
handleClose(ModalButtonType.Cancel);
|
|
483
|
+
}}
|
|
484
|
+
/>
|
|
485
|
+
<div
|
|
486
|
+
className={`modal-dialog ${animationClass}`}
|
|
487
|
+
style={{
|
|
488
|
+
zIndex: 5000000002,
|
|
489
|
+
}}
|
|
490
|
+
>
|
|
491
|
+
<div className="modal-content">
|
|
492
|
+
<div className="modal-header">
|
|
493
|
+
<h5
|
|
494
|
+
className="modal-title"
|
|
495
|
+
style={{
|
|
496
|
+
fontWeight: 'bold',
|
|
497
|
+
}}
|
|
498
|
+
>
|
|
499
|
+
{title}
|
|
500
|
+
</h5>
|
|
501
|
+
|
|
502
|
+
{onClose && (
|
|
503
|
+
<button
|
|
504
|
+
type="button"
|
|
505
|
+
className="btn-close"
|
|
506
|
+
aria-label="Close"
|
|
507
|
+
onClick={() => {
|
|
508
|
+
// Handle close
|
|
509
|
+
handleClose(ModalButtonType.Cancel);
|
|
510
|
+
}}
|
|
511
|
+
/>
|
|
512
|
+
)}
|
|
513
|
+
</div>
|
|
514
|
+
{children && (
|
|
515
|
+
<div className="modal-body">
|
|
516
|
+
{children}
|
|
517
|
+
</div>
|
|
518
|
+
)}
|
|
519
|
+
{footer && (
|
|
520
|
+
<div className="modal-footer pt-1 pb-1">
|
|
521
|
+
{footer}
|
|
522
|
+
</div>
|
|
523
|
+
)}
|
|
524
|
+
</div>
|
|
525
|
+
</div>
|
|
526
|
+
</div>
|
|
410
527
|
);
|
|
411
528
|
};
|
|
412
529
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A radio selection button
|
|
3
|
+
* @author Gabe Abrams
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Import React
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
// Import FontAwesome Icons
|
|
10
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
11
|
+
import { faDotCircle } from '@fortawesome/free-solid-svg-icons';
|
|
12
|
+
import { faCircle } from '@fortawesome/free-regular-svg-icons';
|
|
13
|
+
|
|
14
|
+
// Import shared types
|
|
15
|
+
import Variant from '../types/Variant';
|
|
16
|
+
|
|
17
|
+
/*------------------------------------------------------------------------*/
|
|
18
|
+
/* Types */
|
|
19
|
+
/*------------------------------------------------------------------------*/
|
|
20
|
+
|
|
21
|
+
type Props = {
|
|
22
|
+
// Text of the button
|
|
23
|
+
text: string,
|
|
24
|
+
// Handler for when this item is selected (not called if already selected)
|
|
25
|
+
onSelected: () => void,
|
|
26
|
+
// Aria label
|
|
27
|
+
ariaLabel: string,
|
|
28
|
+
// Button title
|
|
29
|
+
title?: string,
|
|
30
|
+
// True if selected
|
|
31
|
+
selected?: boolean,
|
|
32
|
+
// The id of the button
|
|
33
|
+
id?: string,
|
|
34
|
+
// If true, no margin on right
|
|
35
|
+
noMarginOnRight?: boolean,
|
|
36
|
+
// Variant for when radio is selected
|
|
37
|
+
selectedVariant?: Variant,
|
|
38
|
+
// Variant for when radio is not selected
|
|
39
|
+
unselectedVariant?: Variant,
|
|
40
|
+
// True if using a small button
|
|
41
|
+
small?: boolean,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/*------------------------------------------------------------------------*/
|
|
45
|
+
/* Component */
|
|
46
|
+
/*------------------------------------------------------------------------*/
|
|
47
|
+
|
|
48
|
+
const RadioButton: React.FC<Props> = (props) => {
|
|
49
|
+
/*------------------------------------------------------------------------*/
|
|
50
|
+
/* Setup */
|
|
51
|
+
/*------------------------------------------------------------------------*/
|
|
52
|
+
|
|
53
|
+
/* -------------- Props ------------- */
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
text,
|
|
57
|
+
onSelected,
|
|
58
|
+
ariaLabel,
|
|
59
|
+
title,
|
|
60
|
+
selected,
|
|
61
|
+
id,
|
|
62
|
+
noMarginOnRight,
|
|
63
|
+
selectedVariant = Variant.Secondary,
|
|
64
|
+
unselectedVariant = Variant.Light,
|
|
65
|
+
small,
|
|
66
|
+
} = props;
|
|
67
|
+
|
|
68
|
+
/*------------------------------------------------------------------------*/
|
|
69
|
+
/* Render */
|
|
70
|
+
/*------------------------------------------------------------------------*/
|
|
71
|
+
|
|
72
|
+
/*----------------------------------------*/
|
|
73
|
+
/* Main UI */
|
|
74
|
+
/*----------------------------------------*/
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
id={id}
|
|
80
|
+
title={title}
|
|
81
|
+
className={`btn btn-${selected ? selectedVariant : unselectedVariant}${selected ? ' selected' : ''}${small ? ' btn-sm' : ''} m-0${noMarginOnRight ? '' : ' me-1'}`}
|
|
82
|
+
aria-label={`${ariaLabel}${selected ? ': currently selected' : ''}`}
|
|
83
|
+
onClick={() => {
|
|
84
|
+
if (!selected) {
|
|
85
|
+
onSelected();
|
|
86
|
+
}
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
<FontAwesomeIcon
|
|
90
|
+
icon={selected ? faDotCircle : faCircle}
|
|
91
|
+
className="me-1"
|
|
92
|
+
/>
|
|
93
|
+
{text}
|
|
94
|
+
</button>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/*------------------------------------------------------------------------*/
|
|
99
|
+
/* Wrap up */
|
|
100
|
+
/*------------------------------------------------------------------------*/
|
|
101
|
+
|
|
102
|
+
export default RadioButton;
|