dce-reactkit 1.0.18 → 2.0.0

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.
Files changed (106) hide show
  1. package/.eslintrc.js +95 -0
  2. package/lib/components/LoadingSpinner.d.ts +7 -0
  3. package/lib/components/LoadingSpinner.js +39 -0
  4. package/lib/components/LoadingSpinner.js.map +1 -0
  5. package/lib/components/Modal.d.ts +69 -0
  6. package/lib/components/Modal.js +311 -0
  7. package/lib/components/Modal.js.map +1 -0
  8. package/lib/helpers/abbreviate.d.ts +9 -0
  9. package/lib/helpers/abbreviate.js +21 -0
  10. package/lib/helpers/abbreviate.js.map +1 -0
  11. package/lib/helpers/avg.d.ts +8 -0
  12. package/lib/helpers/avg.js +24 -0
  13. package/lib/helpers/avg.js.map +1 -0
  14. package/lib/helpers/ceilToNumDecimals.d.ts +9 -0
  15. package/lib/helpers/ceilToNumDecimals.js +15 -0
  16. package/lib/helpers/ceilToNumDecimals.js.map +1 -0
  17. package/lib/helpers/floorToNumDecimals.d.ts +9 -0
  18. package/lib/helpers/floorToNumDecimals.js +15 -0
  19. package/lib/helpers/floorToNumDecimals.js.map +1 -0
  20. package/lib/helpers/forceNumIntoBounds.d.ts +10 -0
  21. package/lib/helpers/forceNumIntoBounds.js +15 -0
  22. package/lib/helpers/forceNumIntoBounds.js.map +1 -0
  23. package/lib/helpers/padDecimalZeros.d.ts +10 -0
  24. package/lib/helpers/padDecimalZeros.js +30 -0
  25. package/lib/helpers/padDecimalZeros.js.map +1 -0
  26. package/lib/helpers/padZerosLeft.d.ts +9 -0
  27. package/lib/helpers/padZerosLeft.js +21 -0
  28. package/lib/helpers/padZerosLeft.js.map +1 -0
  29. package/lib/helpers/roundToNumDecimals.d.ts +9 -0
  30. package/lib/helpers/roundToNumDecimals.js +15 -0
  31. package/lib/helpers/roundToNumDecimals.js.map +1 -0
  32. package/lib/helpers/sum.d.ts +8 -0
  33. package/lib/helpers/sum.js +15 -0
  34. package/lib/helpers/sum.js.map +1 -0
  35. package/lib/helpers/waitMs.d.ts +7 -0
  36. package/lib/helpers/waitMs.js +55 -0
  37. package/lib/helpers/waitMs.js.map +1 -0
  38. package/lib/types/Variant.d.ts +15 -0
  39. package/lib/types/Variant.js +19 -0
  40. package/lib/types/Variant.js.map +1 -0
  41. package/package.json +22 -39
  42. package/src/components/LoadingSpinner.scss +50 -0
  43. package/src/components/LoadingSpinner.tsx +50 -0
  44. package/src/components/Modal.scss +48 -0
  45. package/src/components/Modal.tsx +391 -0
  46. package/src/helpers/abbreviate.tsx +23 -0
  47. package/src/helpers/avg.tsx +22 -0
  48. package/src/helpers/ceilToNumDecimals.tsx +13 -0
  49. package/src/helpers/floorToNumDecimals.tsx +13 -0
  50. package/src/helpers/forceNumIntoBounds.tsx +19 -0
  51. package/src/helpers/padDecimalZeros.tsx +32 -0
  52. package/src/helpers/padZerosLeft.tsx +21 -0
  53. package/src/helpers/roundToNumDecimals.tsx +13 -0
  54. package/src/helpers/sum.tsx +16 -0
  55. package/src/helpers/waitMs.tsx +12 -0
  56. package/src/types/Variant.tsx +16 -0
  57. package/tsconfig.json +24 -0
  58. package/Bar.js +0 -169
  59. package/Donut.js +0 -145
  60. package/DownloadButton.js +0 -81
  61. package/Histogram.js +0 -193
  62. package/Scatter.js +0 -162
  63. package/common/chart/Holder/index.js +0 -182
  64. package/common/chart/Holder/style.css +0 -41
  65. package/common/chart/colors.js +0 -12
  66. package/common/csvToString.js +0 -23
  67. package/common/isFloat.js +0 -14
  68. package/common/isInteger.js +0 -24
  69. package/common/math.js +0 -21
  70. package/common/validators.js +0 -18
  71. package/glyph/Adjust.js +0 -13
  72. package/glyph/Angle.js +0 -44
  73. package/glyph/Archive.js +0 -13
  74. package/glyph/Arrow.js +0 -49
  75. package/glyph/ArrowsHorizontal.js +0 -13
  76. package/glyph/ArrowsVertical.js +0 -13
  77. package/glyph/Award.js +0 -13
  78. package/glyph/Ban.js +0 -13
  79. package/glyph/Barcode.js +0 -13
  80. package/glyph/Bed.js +0 -13
  81. package/glyph/Bell.js +0 -35
  82. package/glyph/Bolt.js +0 -13
  83. package/glyph/Bookmark.js +0 -37
  84. package/glyph/Bug.js +0 -13
  85. package/glyph/Calendar.js +0 -13
  86. package/glyph/Check.js +0 -36
  87. package/glyph/Checkbox.js +0 -40
  88. package/glyph/Chevron.js +0 -63
  89. package/glyph/Circle.js +0 -15
  90. package/glyph/Cog.js +0 -13
  91. package/glyph/DoubleAngle.js +0 -45
  92. package/glyph/Download.js +0 -13
  93. package/glyph/Ellipsis.js +0 -36
  94. package/glyph/Envelope.js +0 -13
  95. package/glyph/File.js +0 -37
  96. package/glyph/IdCard.js +0 -13
  97. package/glyph/Menu.js +0 -13
  98. package/glyph/Minus.js +0 -13
  99. package/glyph/Move.js +0 -13
  100. package/glyph/Plus.js +0 -13
  101. package/glyph/Square.js +0 -47
  102. package/glyph/Teacher.js +0 -13
  103. package/glyph/TextAlign.js +0 -53
  104. package/glyph/Times.js +0 -36
  105. package/glyph/WarningTriangle.js +0 -13
  106. package/index.js +0 -1
@@ -0,0 +1,391 @@
1
+ /**
2
+ * A generic popup modal
3
+ * @author Gabe Abrams
4
+ */
5
+
6
+ // Import React
7
+ import React, { useState, useEffect } from 'react';
8
+
9
+ // Import other components
10
+ import BootstrapModal from 'react-bootstrap/Modal';
11
+ import waitMs from '../helpers/waitMs';
12
+
13
+ // Import types
14
+ import Variant from '../types/Variant';
15
+
16
+ /*------------------------------------------------------------------------*/
17
+ /* Constants */
18
+ /*------------------------------------------------------------------------*/
19
+
20
+ // Constants
21
+ const MS_TO_ANIMATE = 400; // Time to animate in/out (defined by bootstrap)
22
+ const MS_ANIMATE_IN_DELAY = 10;
23
+ // Time to wait before animating in (must be >0 or animation won't trigger)
24
+
25
+ // Modal types
26
+ enum ModalType {
27
+ Okay = 'okay', // [Okay]
28
+ OkayCancel = 'okay-cancel', // [Okay] [Cancel]
29
+ YesNo = 'yes-no', // [Yes] [No]
30
+ YesNoCancel = 'yes-no-cancel', // [Yes] [No] [Cancel]
31
+ AbandonGoBack = 'abandon-goBack', // [Abandon Changes] [Go Back]
32
+ ImSureCancel = 'imSure-cancel', // [I am sure] [Cancel]
33
+ DeleteCancel = 'delete-cancel', // [Yes, Delete] [Cancel]
34
+ ConfirmCancel = 'confirm-cancel', // [Confirm] [Cancel]
35
+ NoButtons = '-', // No buttons
36
+ }
37
+
38
+ // Modal sizes
39
+ enum ModalSize {
40
+ Small = 'sm',
41
+ Medium = 'md',
42
+ Large = 'lg',
43
+ ExtraLarge = 'xl',
44
+ }
45
+
46
+ // Button types
47
+ enum ButtonType {
48
+ Okay = 'okay',
49
+ Cancel = 'cancel',
50
+ Yes = 'yes',
51
+ No = 'no',
52
+ Abandon = 'abandon',
53
+ GoBack = 'goBack',
54
+ Continue = 'continue',
55
+ ImSure = 'imSure',
56
+ Delete = 'delete',
57
+ Confirm = 'confirm',
58
+ }
59
+
60
+ // Modal type to list of buttons
61
+ const modalTypeToButtonTypes: {
62
+ [k: string]: ButtonType[]
63
+ } = {
64
+ [ModalType.Okay]: [
65
+ ButtonType.Okay,
66
+ ],
67
+ [ModalType.OkayCancel]: [
68
+ ButtonType.Okay,
69
+ ButtonType.Cancel,
70
+ ],
71
+ [ModalType.YesNo]: [
72
+ ButtonType.Yes,
73
+ ButtonType.No,
74
+ ],
75
+ [ModalType.YesNoCancel]: [
76
+ ButtonType.Yes,
77
+ ButtonType.No,
78
+ ButtonType.Cancel,
79
+ ],
80
+ [ModalType.AbandonGoBack]: [
81
+ ButtonType.Abandon,
82
+ ButtonType.GoBack,
83
+ ],
84
+ [ModalType.ImSureCancel]: [
85
+ ButtonType.ImSure,
86
+ ButtonType.Cancel,
87
+ ],
88
+ [ModalType.DeleteCancel]: [
89
+ ButtonType.Delete,
90
+ ButtonType.Cancel,
91
+ ],
92
+ [ModalType.ConfirmCancel]: [
93
+ ButtonType.Confirm,
94
+ ButtonType.Cancel,
95
+ ],
96
+ };
97
+
98
+ // Button type styling and labels
99
+ const buttonTypeToLabelAndVariant = {
100
+ [ButtonType.Okay]: {
101
+ label: 'Okay',
102
+ variant: Variant.Dark,
103
+ },
104
+ [ButtonType.Cancel]: {
105
+ label: 'Cancel',
106
+ variant: Variant.Secondary,
107
+ },
108
+ [ButtonType.Yes]: {
109
+ label: 'Yes',
110
+ variant: Variant.Dark,
111
+ },
112
+ [ButtonType.No]: {
113
+ label: 'No',
114
+ variant: Variant.Secondary,
115
+ },
116
+ [ButtonType.Abandon]: {
117
+ label: 'Abandon Changes',
118
+ variant: Variant.Warning,
119
+ },
120
+ [ButtonType.GoBack]: {
121
+ label: 'Go Back',
122
+ variant: Variant.Secondary,
123
+ },
124
+ [ButtonType.Continue]: {
125
+ label: 'Continue',
126
+ variant: Variant.Dark,
127
+ },
128
+ [ButtonType.ImSure]: {
129
+ label: 'I am sure',
130
+ variant: Variant.Warning,
131
+ },
132
+ [ButtonType.Delete]: {
133
+ label: 'Yes, Delete',
134
+ variant: Variant.Danger,
135
+ },
136
+ [ButtonType.Confirm]: {
137
+ label: 'Confirm',
138
+ variant: Variant.Dark,
139
+ },
140
+ };
141
+
142
+ /*------------------------------------------------------------------------*/
143
+ /* Types */
144
+ /*------------------------------------------------------------------------*/
145
+
146
+ type Props = {
147
+ // Type of the modal
148
+ type?: ModalType,
149
+ // Size of the modal
150
+ size?: ModalSize,
151
+ // Title of the modal (if excluded, no header)
152
+ title?: React.ReactNode,
153
+ // The body of the modal
154
+ children?: React.ReactNode,
155
+ // Handler to call when modal is closed (if excluded, not closable)
156
+ onClose?: (type: ButtonType) => void,
157
+ // Custom label for "okay" button
158
+ okayLabel?: string,
159
+ // Custom variant for "okay" button
160
+ okayVariant?: Variant,
161
+ // Custom label for "cancel" button
162
+ cancelLabel?: string,
163
+ // Custom variant for "cancel" button
164
+ cancelVariant?: Variant,
165
+ // Custom label for "yes" button
166
+ yesLabel?: string,
167
+ // Custom variant for "yes" button
168
+ yesVariant?: Variant,
169
+ // Custom label for "no" button
170
+ noLabel?: string,
171
+ // Custom variant for "no" button
172
+ noVariant?: Variant,
173
+ // Custom label for "abandon" button
174
+ abandonLabel?: string,
175
+ // Custom variant for "abandon" button
176
+ abandonVariant?: Variant,
177
+ // Custom label for "goBack" button
178
+ goBackLabel?: string,
179
+ // Custom variant for "goBack" button
180
+ goBackVariant?: Variant,
181
+ // Custom label for "continue" button
182
+ continueLabel?: string,
183
+ // Custom variant for "continue" button
184
+ continueVariant?: Variant,
185
+ // Custom label for "imSure" button
186
+ imSureLabel?: string,
187
+ // Custom variant for "imSure" button
188
+ imSureVariant?: Variant,
189
+ // Custom label for "delete" button
190
+ deleteLabel?: string,
191
+ // Custom variant for "delete" button
192
+ deleteVariant?: Variant,
193
+ // Custom label for "confirm" button
194
+ confirmLabel?: string,
195
+ // Custom variant for "confirm" button
196
+ confirmVariant?: Variant,
197
+ };
198
+
199
+ /*------------------------------------------------------------------------*/
200
+ /* Component */
201
+ /*------------------------------------------------------------------------*/
202
+
203
+ const Modal: (
204
+ React.FC<Props>
205
+ & {
206
+ ModalType: typeof ModalType,
207
+ ModalSize: typeof ModalSize,
208
+ ButtonType: typeof ButtonType,
209
+ Variant: typeof Variant,
210
+ }
211
+ ) = (props) => {
212
+ /*------------------------------------------------------------------------*/
213
+ /* Setup */
214
+ /*------------------------------------------------------------------------*/
215
+
216
+ /* -------------- Props ------------- */
217
+
218
+ const {
219
+ type = ModalType.NoButtons,
220
+ size = ModalSize.Large,
221
+ title,
222
+ children,
223
+ onClose,
224
+ } = props;
225
+
226
+ /* -------------- State ------------- */
227
+
228
+ // If true, the modal is shown
229
+ const [visible, setVisible] = useState(false);
230
+
231
+ // True if currently animating in
232
+ const [animatingIn, setAnimatingIn] = useState(false);
233
+
234
+ /*------------------------------------------------------------------------*/
235
+ /* Lifecycle Functions */
236
+ /*------------------------------------------------------------------------*/
237
+
238
+ /**
239
+ * Mount
240
+ * @author Gabe Abrams
241
+ */
242
+ useEffect(
243
+ () => {
244
+ (async () => {
245
+ // Start the component animating in
246
+ await waitMs(MS_ANIMATE_IN_DELAY);
247
+ setAnimatingIn(true);
248
+
249
+ // Wait and then set visible to true
250
+ await waitMs(MS_TO_ANIMATE);
251
+ setVisible(true);
252
+ })();
253
+ },
254
+ [],
255
+ );
256
+
257
+ /*------------------------------------------------------------------------*/
258
+ /* Component Functions */
259
+ /*------------------------------------------------------------------------*/
260
+
261
+ /**
262
+ * Handles the closing of the modal
263
+ * @author Gabe Abrams
264
+ * @param buttonType the button that was clicked when closing the
265
+ * modal
266
+ */
267
+ const handleClose = async (buttonType: ButtonType) => {
268
+ // Don't close if no handler
269
+ if (!onClose) {
270
+ return;
271
+ }
272
+
273
+ // Don't close if animating in
274
+ if (animatingIn) {
275
+ return;
276
+ }
277
+
278
+ // Don't close if already closed
279
+ if (!visible) {
280
+ return;
281
+ }
282
+
283
+ // Update the state
284
+ setVisible(false);
285
+
286
+ // Call the handler after the modal has animated out
287
+ await waitMs(MS_TO_ANIMATE);
288
+ onClose(buttonType);
289
+ };
290
+
291
+ /*------------------------------------------------------------------------*/
292
+ /* Render */
293
+ /*------------------------------------------------------------------------*/
294
+
295
+ /*----------------------------------------*/
296
+ /* Footer */
297
+ /*----------------------------------------*/
298
+
299
+ // Get list of buttons for this modal type
300
+ const buttonTypes: ButtonType[] = modalTypeToButtonTypes[type] ?? [];
301
+
302
+ // Create buttons
303
+ const buttons = buttonTypes.map((buttonType: ButtonType, i) => {
304
+ // Get default style
305
+ let {
306
+ label,
307
+ variant,
308
+ } = buttonTypeToLabelAndVariant[buttonType];
309
+
310
+ // Override with customizations
311
+ if (props[`${buttonType}Label`]) {
312
+ label = props[`${buttonType}Label`];
313
+ }
314
+ if (props[`${buttonType}Variant`]) {
315
+ variant = props[`${buttonType}Variant`];
316
+ }
317
+
318
+ // Check if this button is last
319
+ const last = (i === buttonTypes.length - 1);
320
+
321
+ // Create the button
322
+ return (
323
+ <button
324
+ type="button"
325
+ className={`Modal-${buttonType}-button btn btn-${variant} ${last ? '' : 'mr-1'}`}
326
+ onClick={() => {
327
+ handleClose(buttonType);
328
+ }}
329
+ >
330
+ {label}
331
+ </button>
332
+ );
333
+ });
334
+
335
+ // Put all buttons in a footer
336
+ const footer = (
337
+ (buttons && buttons.length)
338
+ ? (
339
+ <div>
340
+ {buttons}
341
+ </div>
342
+ )
343
+ : undefined
344
+ );
345
+
346
+ // Render the modal
347
+ return (
348
+ <BootstrapModal
349
+ show={visible}
350
+ size={size !== ModalSize.Medium ? size : undefined}
351
+ onHide={() => {
352
+ handleClose(ButtonType.Cancel);
353
+ }}
354
+ style={{ zIndex: 5000000000 }}
355
+ backdropClassName="Modal-backdrop"
356
+ centered
357
+ >
358
+ {title && (
359
+ <BootstrapModal.Header
360
+ closeButton={!!onClose}
361
+ >
362
+ <BootstrapModal.Title>
363
+ {title}
364
+ </BootstrapModal.Title>
365
+ </BootstrapModal.Header>
366
+ )}
367
+ {children && (
368
+ <BootstrapModal.Body>
369
+ {children}
370
+ </BootstrapModal.Body>
371
+ )}
372
+ {footer && (
373
+ <BootstrapModal.Footer>
374
+ {footer}
375
+ </BootstrapModal.Footer>
376
+ )}
377
+ </BootstrapModal>
378
+ );
379
+ };
380
+
381
+ /*------------------------------------------------------------------------*/
382
+ /* Wrap Up */
383
+ /*------------------------------------------------------------------------*/
384
+
385
+ // Add enums
386
+ Modal.ModalType = ModalType;
387
+ Modal.ModalSize = ModalSize;
388
+ Modal.ButtonType = ButtonType;
389
+ Modal.Variant = Variant;
390
+
391
+ export default Modal;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Shorten text so it fits into a certain number of chars
3
+ * @author Gabe Abrams
4
+ * @param text the text to abbreviate
5
+ * @param maxChars the maximum number of chars to include
6
+ * @returns abbreviated text with length no greater than maxChars
7
+ * (including ellipses if applicable)
8
+ */
9
+ const abbreviate = (text: string, maxChars: number): string => {
10
+ // Check if already short enough
11
+ if (text.trim().length < maxChars) {
12
+ return text.trim();
13
+ }
14
+
15
+ // Abbreviate
16
+ const shortenedText = (
17
+ text
18
+ .trim()
19
+ .substring(0, maxChars - 3)
20
+ .trim()
21
+ );
22
+ return `${shortenedText}...`;
23
+ };
@@ -0,0 +1,22 @@
1
+ import sum from './sum';
2
+
3
+ /**
4
+ * Get the average of a set of numbers
5
+ * @author Gabe Abrams
6
+ * @param nums the numbers to average
7
+ * @returns average value or 0 if no numbers
8
+ */
9
+ const avg = (nums: number[]) => {
10
+ // Handle empty array case
11
+ if (nums.length === 0) {
12
+ return 0;
13
+ }
14
+
15
+ // Get the total value
16
+ const total = sum(nums);
17
+
18
+ // Get average
19
+ return (total / nums.length);
20
+ };
21
+
22
+ export default avg;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Round a number (ceiling) to a certain number of decimals
3
+ * @author Gabe Abrams
4
+ * @param num the number to round
5
+ * @param numDecimals the number of decimals to round to
6
+ * @returns rounded number
7
+ */
8
+ const ceilToNumDecimals = (num: number, numDecimals: number): number => {
9
+ const rounder = 10 ** numDecimals;
10
+ return (Math.ceil(num * rounder) / rounder);
11
+ };
12
+
13
+ export default ceilToNumDecimals;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Round a number (floor) to a certain number of decimals
3
+ * @author Gabe Abrams
4
+ * @param num the number to round
5
+ * @param numDecimals the number of decimals to round to
6
+ * @returns rounded number
7
+ */
8
+ const floorToNumDecimals = (num: number, numDecimals: number): number => {
9
+ const rounder = 10 ** numDecimals;
10
+ return (Math.floor(num * rounder) / rounder);
11
+ };
12
+
13
+ export default floorToNumDecimals;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Force a number to stay within specific bounds
3
+ * @author Gabe Abrams
4
+ * @param num the number to move into the bounds
5
+ * @param min the minimum number in the bound
6
+ * @param max the maximum number in the bound
7
+ * @returns bounded number
8
+ */
9
+ const forceNumIntoBounds = (num: number, min: number, max: number): number => {
10
+ return Math.max(
11
+ min,
12
+ Math.min(
13
+ max,
14
+ num,
15
+ ),
16
+ );
17
+ };
18
+
19
+ export default forceNumIntoBounds;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Pad a number's decimal with zeros on the right
3
+ * (e.g. 5.2 becomes 5.20 with 2 digit padding)
4
+ * @author Gabe Abrams
5
+ * @param num the number to pad
6
+ * @param numDigits the minimum number of digits after the decimal
7
+ * @returns padded number
8
+ */
9
+ const padDecimalZeros = (num: number, numDigits: number): string => {
10
+ // Skip if nothing to do
11
+ if (numDigits < 1) {
12
+ return;
13
+ }
14
+
15
+ // Convert to string
16
+ let out = String(num);
17
+
18
+ // Add a decimal point if there isn't one
19
+ if (!out.includes('.')) {
20
+ out += '.';
21
+ }
22
+
23
+ // Add zeros
24
+ while (out.split('.')[1].length < numDigits) {
25
+ out = `${out}0`;
26
+ }
27
+
28
+ // Return
29
+ return out;
30
+ };
31
+
32
+ export default padDecimalZeros;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Pad a number with zeros on the left (e.g. 5 becomes 05 with 2 digit padding)
3
+ * @author Gabe Abrams
4
+ * @param num the number to pad
5
+ * @param numDigits the minimum number of digits before the decimal
6
+ * @returns padded number
7
+ */
8
+ const padZerosLeft = (num: number, numDigits: number): string => {
9
+ // Convert to string
10
+ let out = String(num);
11
+
12
+ // Add zeros
13
+ while (out.split('.')[0].length < numDigits) {
14
+ out = `0${out}`;
15
+ }
16
+
17
+ // Return
18
+ return out;
19
+ };
20
+
21
+ export default padZerosLeft;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Round a number to a certain number of decimals
3
+ * @author Gabe Abrams
4
+ * @param num the number to round
5
+ * @param numDecimals the number of decimals to round to
6
+ * @returns rounded number
7
+ */
8
+ const roundToNumDecimals = (num: number, numDecimals: number): number => {
9
+ const rounder = 10 ** numDecimals;
10
+ return (Math.round(num * rounder) / rounder);
11
+ };
12
+
13
+ export default roundToNumDecimals;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Sum the numbers in an array
3
+ * @author Gabe Abrams
4
+ * @param nums the numbers to sum
5
+ * @returns the sum of the numbers
6
+ */
7
+ const sum = (nums: number[]): number => {
8
+ return nums.reduce(
9
+ (a: number, b: number) => {
10
+ return (a + b);
11
+ },
12
+ 0,
13
+ );
14
+ };
15
+
16
+ export default sum;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Wait for a certain number of ms
3
+ * @author Gabe Abrams
4
+ * @param ms number of ms to wait
5
+ */
6
+ const waitMs = async (ms = 0) => {
7
+ return new Promise((resolve) => {
8
+ setTimeout(resolve, ms);
9
+ });
10
+ };
11
+
12
+ export default waitMs;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Bootstrap variants
3
+ * @author Gabe Abrams
4
+ */
5
+ enum Variant {
6
+ Primary = 'primary',
7
+ Secondary = 'secondary',
8
+ Success = 'success',
9
+ Warning = 'warning',
10
+ Info = 'info',
11
+ Danger = 'danger',
12
+ Light = 'light',
13
+ Dark = 'dark',
14
+ }
15
+
16
+ export default Variant;
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "esModuleInterop": true,
5
+ "noImplicitAny": true,
6
+ "noEmitOnError": true,
7
+ "removeComments": false,
8
+ "declaration": true,
9
+ "sourceMap": true,
10
+ "target": "es5",
11
+ "jsx": "react-jsx",
12
+ "lib": [
13
+ "es2015",
14
+ "dom"
15
+ ],
16
+ "outDir": "./lib"
17
+ },
18
+ "include": [
19
+ "./src"
20
+ ],
21
+ "ts-node": {
22
+ "files": true
23
+ }
24
+ }