dce-reactkit 3.0.41 → 3.0.42

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/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import React from 'react';
7
7
  * @author Gabe Abrams
8
8
  */
9
9
 
10
- declare type Props$9 = {
10
+ declare type Props$b = {
11
11
  children: React.ReactNode;
12
12
  sendRequest: SendRequestFunction;
13
13
  dark?: boolean;
@@ -52,7 +52,7 @@ declare const confirm: (title: string, text: string) => Promise<boolean>;
52
52
  * @param [errorTitle] title of the error box
53
53
  */
54
54
  declare const showFatalError: (error: any, errorTitle?: string) => undefined;
55
- declare const AppWrapper: React.FC<Props$9>;
55
+ declare const AppWrapper: React.FC<Props$b>;
56
56
 
57
57
  /**
58
58
  * Loading spinner/indicator
@@ -65,12 +65,12 @@ declare const LoadingSpinner: () => JSX.Element;
65
65
  * @author Gabe Abrams
66
66
  */
67
67
 
68
- declare type Props$8 = {
68
+ declare type Props$a = {
69
69
  error: any;
70
70
  title?: string;
71
71
  onClose?: () => void;
72
72
  };
73
- declare const ErrorBox: React.FC<Props$8>;
73
+ declare const ErrorBox: React.FC<Props$a>;
74
74
 
75
75
  /**
76
76
  * Bootstrap variants
@@ -136,7 +136,7 @@ declare enum ModalType {
136
136
  * @author Gabe Abrams
137
137
  */
138
138
 
139
- declare type Props$7 = {
139
+ declare type Props$9 = {
140
140
  type?: ModalType;
141
141
  size?: ModalSize;
142
142
  title?: React.ReactNode;
@@ -165,27 +165,27 @@ declare type Props$7 = {
165
165
  confirmVariant?: Variant;
166
166
  onTopOfOtherModals?: boolean;
167
167
  };
168
- declare const Modal: React.FC<Props$7>;
168
+ declare const Modal: React.FC<Props$9>;
169
169
 
170
170
  /**
171
171
  * A box with a tab on the top that holds buttons and other content
172
172
  * @author Gabe Abrams
173
173
  */
174
174
 
175
- declare type Props$6 = {
175
+ declare type Props$8 = {
176
176
  title: React.ReactNode;
177
177
  children: React.ReactNode;
178
178
  noBottomMargin?: boolean;
179
179
  noBottomPadding?: boolean;
180
180
  };
181
- declare const TabBox: React.FC<Props$6>;
181
+ declare const TabBox: React.FC<Props$8>;
182
182
 
183
183
  /**
184
184
  * A radio selection button
185
185
  * @author Gabe Abrams
186
186
  */
187
187
 
188
- declare type Props$5 = {
188
+ declare type Props$7 = {
189
189
  text: string;
190
190
  onSelected: () => void;
191
191
  ariaLabel: string;
@@ -197,14 +197,14 @@ declare type Props$5 = {
197
197
  unselectedVariant?: Variant;
198
198
  small?: boolean;
199
199
  };
200
- declare const RadioButton: React.FC<Props$5>;
200
+ declare const RadioButton: React.FC<Props$7>;
201
201
 
202
202
  /**
203
203
  * A checkbox button
204
204
  * @author Gabe Abrams
205
205
  */
206
206
 
207
- declare type Props$4 = {
207
+ declare type Props$6 = {
208
208
  text: string;
209
209
  onChanged: (checked: boolean) => void;
210
210
  ariaLabel: string;
@@ -216,26 +216,26 @@ declare type Props$4 = {
216
216
  uncheckedVariant?: Variant;
217
217
  small?: boolean;
218
218
  };
219
- declare const CheckboxButton: React.FC<Props$4>;
219
+ declare const CheckboxButton: React.FC<Props$6>;
220
220
 
221
221
  /**
222
222
  * Input group with a title and space for buttons
223
223
  * @author Gabe Abrams
224
224
  */
225
225
 
226
- declare type Props$3 = {
226
+ declare type Props$5 = {
227
227
  label: string;
228
228
  minLabelWidth?: string;
229
229
  children: React.ReactNode;
230
230
  };
231
- declare const ButtonInputGroup: React.FC<Props$3>;
231
+ declare const ButtonInputGroup: React.FC<Props$5>;
232
232
 
233
233
  /**
234
234
  * A very simple, lightweight date chooser
235
235
  * @author Gabe Abrams
236
236
  */
237
237
 
238
- declare type Props$2 = {
238
+ declare type Props$4 = {
239
239
  ariaLabel: string;
240
240
  name: string;
241
241
  month: number;
@@ -250,29 +250,53 @@ declare type Props$2 = {
250
250
  onChange: (month: number, day: number, year: number) => void;
251
251
  numMonthsToShow?: number;
252
252
  };
253
- declare const SimpleDateChooser: React.FC<Props$2>;
253
+ declare const SimpleDateChooser: React.FC<Props$4>;
254
254
 
255
255
  /**
256
256
  * Drawer container
257
257
  * @author Gabe Abrams
258
258
  */
259
259
 
260
- declare type Props$1 = {
260
+ declare type Props$3 = {
261
261
  children: React.ReactNode;
262
262
  };
263
- declare const Drawer: React.FC<Props$1>;
263
+ declare const Drawer: React.FC<Props$3>;
264
264
 
265
265
  /**
266
266
  * Success checkmark that pops into view
267
267
  * @author Gabe Abrams
268
268
  */
269
269
 
270
- declare type Props = {
270
+ declare type Props$2 = {
271
271
  sizeRem?: number;
272
272
  circleVariant?: string;
273
273
  checkVariant?: string;
274
274
  };
275
- declare const PopSuccessMark: React.FC<Props>;
275
+ declare const PopSuccessMark: React.FC<Props$2>;
276
+
277
+ /**
278
+ * Failure x mark that pops into view
279
+ * @author Gabe Abrams
280
+ */
281
+
282
+ declare type Props$1 = {
283
+ sizeRem?: number;
284
+ circleVariant?: string;
285
+ xVariant?: string;
286
+ };
287
+ declare const PopFailureMark: React.FC<Props$1>;
288
+
289
+ /**
290
+ * Failure pending that pops into view
291
+ * @author Gabe Abrams
292
+ */
293
+
294
+ declare type Props = {
295
+ sizeRem?: number;
296
+ circleVariant?: string;
297
+ hourglassVariant?: string;
298
+ };
299
+ declare const PopPendingMark: React.FC<Props>;
276
300
 
277
301
  /**
278
302
  * An error with a code
@@ -570,4 +594,4 @@ declare enum ReactKitErrorCode {
570
594
  NotAdmin = "DRK10"
571
595
  }
572
596
 
573
- export { AppWrapper, ButtonInputGroup, CheckboxButton, DAY_IN_MS, Drawer, ErrorBox, ErrorWithCode, HOUR_IN_MS, LoadingSpinner, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, alert, avg, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, genRouteHandler, getHumanReadableDate, getOrdinal, getTimeInfoInET, handleError, handleSuccess, initServer, padDecimalZeros, padZerosLeft, roundToNumDecimals, showFatalError, startMinWait, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
597
+ export { AppWrapper, ButtonInputGroup, CheckboxButton, DAY_IN_MS, Drawer, ErrorBox, ErrorWithCode, HOUR_IN_MS, LoadingSpinner, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, alert, avg, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, genRouteHandler, getHumanReadableDate, getOrdinal, getTimeInfoInET, handleError, handleSuccess, initServer, padDecimalZeros, padZerosLeft, roundToNumDecimals, showFatalError, startMinWait, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.0.41",
3
+ "version": "3.0.42",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Failure x mark that pops into view
3
+ * @author Gabe Abrams
4
+ */
5
+
6
+ // Import React
7
+ import React from 'react';
8
+
9
+ /*------------------------------------------------------------------------*/
10
+ /* Types */
11
+ /*------------------------------------------------------------------------*/
12
+
13
+ // Props definition
14
+ type Props = {
15
+ // Size of x mark in rem
16
+ sizeRem?: number,
17
+ // Bootstrap variant of circle
18
+ circleVariant?: string,
19
+ // Bootstrap variant of x mark
20
+ xVariant?: string,
21
+ };
22
+
23
+ /*------------------------------------------------------------------------*/
24
+ /* Style */
25
+ /*------------------------------------------------------------------------*/
26
+
27
+ const style = `
28
+ .PopFailureMark-outer-container {
29
+ position: relative;
30
+ display: inline-block;
31
+ border-radius: 50%;
32
+
33
+ animation-name: PopFailureMark-outer-container;
34
+ animation-duration: 0.8s;
35
+ animation-fill-mode: both;
36
+ animation-iteration-count: 1;
37
+ animation-timing-function: ease-out;
38
+ }
39
+ @keyframes PopFailureMark-outer-container {
40
+ 0% {
41
+ opacity: 0;
42
+ transform: scale(1.5);
43
+ filter: saturate(0);
44
+ }
45
+ 80.7% {
46
+ opacity: 1;
47
+ transform: scale(1);
48
+ filter: saturate(0);
49
+ }
50
+ 100% {
51
+ opacity: 1;
52
+ transform: scale(1);
53
+ filter: saturate(1);
54
+ }
55
+ }
56
+
57
+ .PopFailureMark-x-stroke-1 {
58
+ position: absolute;
59
+ left: 25%;
60
+ top: 19%;
61
+
62
+ display: inline-block;
63
+ height: 16%;
64
+ width: 70%;
65
+
66
+ transform-origin: left;
67
+
68
+ animation-name: PopFailureMark-x-stroke-1;
69
+ animation-duration: 0.3s;
70
+ animation-delay: 0.3s;
71
+ animation-fill-mode: both;
72
+ animation-iteration-count: 1;
73
+ animation-timing-function: ease-in;
74
+ }
75
+ @keyframes PopFailureMark-x-stroke-1 {
76
+ 0% {
77
+ transform: rotate(45deg) scaleX(0);
78
+ }
79
+ 100% {
80
+ transform: rotate(45deg) scaleX(1);
81
+ }
82
+ }
83
+
84
+ .PopFailureMark-x-stroke-2 {
85
+ position: absolute;
86
+ left: 75%;
87
+ top: 19%;
88
+
89
+ display: inline-block;
90
+ height: 16%;
91
+ width: 70%;
92
+
93
+ transform-origin: left;
94
+
95
+ animation-name: PopFailureMark-x-stroke-2;
96
+ animation-duration: 0.3s;
97
+ animation-delay: 0.6s;
98
+ animation-fill-mode: both;
99
+ animation-iteration-count: 1;
100
+ animation-timing-function: ease-out;
101
+ }
102
+ @keyframes PopFailureMark-x-stroke-2 {
103
+ 0% {
104
+ transform: rotate(135deg) scaleX(0);
105
+ }
106
+ 100% {
107
+ transform: rotate(135deg) scaleX(1);
108
+ }
109
+ }
110
+ `;
111
+
112
+ /*------------------------------------------------------------------------*/
113
+ /* Component */
114
+ /*------------------------------------------------------------------------*/
115
+
116
+ const PopFailureMark: React.FC<Props> = (props) => {
117
+ /*------------------------------------------------------------------------*/
118
+ /* Setup */
119
+ /*------------------------------------------------------------------------*/
120
+
121
+ /* -------------- Props ------------- */
122
+
123
+ // Destructure all props
124
+ const {
125
+ sizeRem = 3,
126
+ circleVariant = 'danger',
127
+ xVariant = 'white',
128
+ } = props;
129
+
130
+ /*------------------------------------------------------------------------*/
131
+ /* Render */
132
+ /*------------------------------------------------------------------------*/
133
+
134
+ /*----------------------------------------*/
135
+ /* Main UI */
136
+ /*----------------------------------------*/
137
+
138
+ return (
139
+ <div
140
+ className={`PopFailureMark-outer-container bg-${circleVariant}`}
141
+ style={{
142
+ width: `${sizeRem}rem`,
143
+ height: `${sizeRem}rem`,
144
+ }}
145
+ aria-label="mark indicating failure"
146
+ >
147
+ {/* Style */}
148
+ <style>{style}</style>
149
+ {/* Failure mark */}
150
+ <div
151
+ className={`PopFailureMark-x-stroke-1 bg-${xVariant}`}
152
+ style={{
153
+ borderRadius: `${sizeRem / 5}rem`,
154
+ }}
155
+ />
156
+ <div
157
+ className={`PopFailureMark-x-stroke-2 bg-${xVariant}`}
158
+ style={{
159
+ borderRadius: `${sizeRem / 5}rem`,
160
+ }}
161
+ />
162
+ </div>
163
+ );
164
+ };
165
+
166
+ /*------------------------------------------------------------------------*/
167
+ /* Wrap Up */
168
+ /*------------------------------------------------------------------------*/
169
+
170
+ // Export component
171
+ export default PopFailureMark;
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Failure pending that pops into view
3
+ * @author Gabe Abrams
4
+ */
5
+
6
+ // Import React
7
+ import React from 'react';
8
+
9
+ // Import FontAwesome
10
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
11
+ import { faHourglass } from '@fortawesome/free-solid-svg-icons';
12
+
13
+ /*------------------------------------------------------------------------*/
14
+ /* Types */
15
+ /*------------------------------------------------------------------------*/
16
+
17
+ // Props definition
18
+ type Props = {
19
+ // Size of pending in rem
20
+ sizeRem?: number,
21
+ // Bootstrap variant of circle
22
+ circleVariant?: string,
23
+ // Bootstrap variant of pending
24
+ hourglassVariant?: string,
25
+ };
26
+
27
+ /*------------------------------------------------------------------------*/
28
+ /* Style */
29
+ /*------------------------------------------------------------------------*/
30
+
31
+ const style = `
32
+ .PopPendingMark-outer-container {
33
+ position: relative;
34
+ display: inline-block;
35
+ border-radius: 50%;
36
+
37
+ animation-name: PopPendingMark-outer-container;
38
+ animation-duration: 0.8s;
39
+ animation-fill-mode: both;
40
+ animation-iteration-count: 1;
41
+ animation-timing-function: ease-out;
42
+ }
43
+ @keyframes PopPendingMark-outer-container {
44
+ 0% {
45
+ opacity: 0;
46
+ transform: scale(1.5);
47
+ filter: saturate(0);
48
+ }
49
+ 80.7% {
50
+ opacity: 1;
51
+ transform: scale(1);
52
+ filter: saturate(0);
53
+ }
54
+ 100% {
55
+ opacity: 1;
56
+ transform: scale(1);
57
+ filter: saturate(1);
58
+ }
59
+ }
60
+
61
+ .PopPendingMark-hourglass {
62
+ position: absolute;
63
+ left: 28%;
64
+ top: 21%;
65
+
66
+ animation-name: PopPendingMark-pending;
67
+ animation-duration: 0.3s;
68
+ animation-delay: 0.3s;
69
+ animation-fill-mode: both;
70
+ animation-iteration-count: 1;
71
+ animation-timing-function: ease-in;
72
+ }
73
+ @keyframes PopPendingMark-pending {
74
+ 0% {
75
+ transform: scale(0.7) rotate(30deg);
76
+ opacity: 0;
77
+ }
78
+ 100% {
79
+ transform: scale(1) rotate(0);
80
+ opacity: 1;
81
+ }
82
+ }
83
+ `;
84
+
85
+ /*------------------------------------------------------------------------*/
86
+ /* Component */
87
+ /*------------------------------------------------------------------------*/
88
+
89
+ const PopPendingMark: React.FC<Props> = (props) => {
90
+ /*------------------------------------------------------------------------*/
91
+ /* Setup */
92
+ /*------------------------------------------------------------------------*/
93
+
94
+ /* -------------- Props ------------- */
95
+
96
+ // Destructure all props
97
+ const {
98
+ sizeRem = 3,
99
+ circleVariant = 'warning',
100
+ hourglassVariant = 'white',
101
+ } = props;
102
+
103
+ /*------------------------------------------------------------------------*/
104
+ /* Render */
105
+ /*------------------------------------------------------------------------*/
106
+
107
+ /*----------------------------------------*/
108
+ /* Main UI */
109
+ /*----------------------------------------*/
110
+
111
+ return (
112
+ <div
113
+ className={`PopPendingMark-outer-container bg-${circleVariant}`}
114
+ style={{
115
+ width: `${sizeRem}rem`,
116
+ height: `${sizeRem}rem`,
117
+ }}
118
+ aria-label="mark indicating that the item is pending"
119
+ >
120
+ {/* Style */}
121
+ <style>{style}</style>
122
+ {/* Pending mark */}
123
+ <div>
124
+ <FontAwesomeIcon
125
+ icon={faHourglass}
126
+ className={`PopPendingMark-hourglass text-${hourglassVariant}`}
127
+ style={{
128
+ fontSize: `${sizeRem * 0.6}rem`,
129
+ }}
130
+ />
131
+ </div>
132
+ </div>
133
+ );
134
+ };
135
+
136
+ /*------------------------------------------------------------------------*/
137
+ /* Wrap Up */
138
+ /*------------------------------------------------------------------------*/
139
+
140
+ // Export component
141
+ export default PopPendingMark;
package/src/index.ts CHANGED
@@ -10,6 +10,8 @@ import ButtonInputGroup from './components/ButtonInputGroup';
10
10
  import SimpleDateChooser from './components/SimpleDateChooser';
11
11
  import Drawer from './components/Drawer';
12
12
  import PopSuccessMark from './components/PopSuccessMark';
13
+ import PopFailureMark from './components/PopFailureMark';
14
+ import PopPendingMark from './components/PopPendingMark';
13
15
 
14
16
  // Import errors
15
17
  import ErrorWithCode from './errors/ErrorWithCode';
@@ -63,6 +65,8 @@ export {
63
65
  SimpleDateChooser,
64
66
  Drawer,
65
67
  PopSuccessMark,
68
+ PopFailureMark,
69
+ PopPendingMark,
66
70
  // Global functions
67
71
  alert,
68
72
  confirm,