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.
Files changed (129) hide show
  1. package/dist/cjs/index.js +921 -0
  2. package/dist/cjs/index.js.map +1 -0
  3. package/{lib → dist/cjs/types}/components/AppWrapper.d.ts +10 -5
  4. package/{lib → dist/cjs/types}/components/ErrorBox.d.ts +0 -0
  5. package/{lib → dist/cjs/types}/components/LoadingSpinner.d.ts +1 -0
  6. package/{lib → dist/cjs/types}/components/Modal.d.ts +5 -36
  7. package/{lib → dist/cjs/types}/components/TabBox.d.ts +0 -0
  8. package/{lib → dist/cjs/types}/errors/ErrorWithCode.d.ts +0 -0
  9. package/{lib → dist/cjs/types}/helpers/abbreviate.d.ts +1 -0
  10. package/{lib → dist/cjs/types}/helpers/avg.d.ts +0 -0
  11. package/{lib → dist/cjs/types}/helpers/ceilToNumDecimals.d.ts +0 -0
  12. package/{lib → dist/cjs/types}/helpers/floorToNumDecimals.d.ts +0 -0
  13. package/{lib → dist/cjs/types}/helpers/forceNumIntoBounds.d.ts +0 -0
  14. package/{lib → dist/cjs/types}/helpers/padDecimalZeros.d.ts +0 -0
  15. package/{lib → dist/cjs/types}/helpers/padZerosLeft.d.ts +0 -0
  16. package/{lib → dist/cjs/types}/helpers/roundToNumDecimals.d.ts +0 -0
  17. package/{lib → dist/cjs/types}/helpers/sum.d.ts +0 -0
  18. package/{lib → dist/cjs/types}/helpers/waitMs.d.ts +0 -0
  19. package/dist/cjs/types/index.d.ts +22 -0
  20. package/dist/cjs/types/types/ModalButtonType.d.ts +17 -0
  21. package/dist/cjs/types/types/ModalSize.d.ts +11 -0
  22. package/dist/cjs/types/types/ModalType.d.ts +16 -0
  23. package/{lib → dist/cjs/types}/types/ReactKitErrorCode.d.ts +0 -0
  24. package/{lib → dist/cjs/types}/types/Variant.d.ts +0 -0
  25. package/dist/esm/index.js +890 -0
  26. package/dist/esm/index.js.map +1 -0
  27. package/dist/esm/types/components/AppWrapper.d.ts +40 -0
  28. package/dist/esm/types/components/ErrorBox.d.ts +12 -0
  29. package/dist/esm/types/components/LoadingSpinner.d.ts +7 -0
  30. package/dist/esm/types/components/Modal.d.ts +40 -0
  31. package/dist/esm/types/components/TabBox.d.ts +11 -0
  32. package/dist/esm/types/errors/ErrorWithCode.d.ts +9 -0
  33. package/dist/esm/types/helpers/abbreviate.d.ts +10 -0
  34. package/dist/esm/types/helpers/avg.d.ts +8 -0
  35. package/dist/esm/types/helpers/ceilToNumDecimals.d.ts +9 -0
  36. package/dist/esm/types/helpers/floorToNumDecimals.d.ts +9 -0
  37. package/dist/esm/types/helpers/forceNumIntoBounds.d.ts +10 -0
  38. package/dist/esm/types/helpers/padDecimalZeros.d.ts +10 -0
  39. package/dist/esm/types/helpers/padZerosLeft.d.ts +9 -0
  40. package/dist/esm/types/helpers/roundToNumDecimals.d.ts +9 -0
  41. package/dist/esm/types/helpers/sum.d.ts +8 -0
  42. package/dist/esm/types/helpers/waitMs.d.ts +7 -0
  43. package/dist/esm/types/index.d.ts +22 -0
  44. package/dist/esm/types/types/ModalButtonType.d.ts +17 -0
  45. package/dist/esm/types/types/ModalSize.d.ts +11 -0
  46. package/dist/esm/types/types/ModalType.d.ts +16 -0
  47. package/dist/esm/types/types/ReactKitErrorCode.d.ts +13 -0
  48. package/dist/esm/types/types/Variant.d.ts +15 -0
  49. package/dist/index.d.ts +274 -0
  50. package/package.json +23 -15
  51. package/rollup.config.js +45 -0
  52. package/src/components/AppWrapper.tsx +40 -39
  53. package/src/components/LoadingSpinner.tsx +3 -0
  54. package/src/components/Modal.tsx +96 -170
  55. package/src/helpers/abbreviate.tsx +2 -0
  56. package/src/helpers/padDecimalZeros.tsx +1 -1
  57. package/src/index.ts +61 -0
  58. package/src/types/ModalButtonType.tsx +18 -0
  59. package/src/types/ModalSize.tsx +12 -0
  60. package/src/types/ModalType.tsx +17 -0
  61. package/tsconfig.json +16 -17
  62. package/lib/components/AppWrapper.js +0 -277
  63. package/lib/components/AppWrapper.js.map +0 -1
  64. package/lib/components/ErrorBox.js +0 -65
  65. package/lib/components/ErrorBox.js.map +0 -1
  66. package/lib/components/LoadingSpinner.js +0 -41
  67. package/lib/components/LoadingSpinner.js.map +0 -1
  68. package/lib/components/Modal.js +0 -321
  69. package/lib/components/Modal.js.map +0 -1
  70. package/lib/components/TabBox.js +0 -42
  71. package/lib/components/TabBox.js.map +0 -1
  72. package/lib/errors/ErrorWithCode.js +0 -33
  73. package/lib/errors/ErrorWithCode.js.map +0 -1
  74. package/lib/helpers/abbreviate.js +0 -21
  75. package/lib/helpers/abbreviate.js.map +0 -1
  76. package/lib/helpers/alert.d.ts +0 -2
  77. package/lib/helpers/alert.js +0 -6
  78. package/lib/helpers/alert.js.map +0 -1
  79. package/lib/helpers/avg.js +0 -24
  80. package/lib/helpers/avg.js.map +0 -1
  81. package/lib/helpers/ceilToNumDecimals.js +0 -15
  82. package/lib/helpers/ceilToNumDecimals.js.map +0 -1
  83. package/lib/helpers/confirm.d.ts +0 -2
  84. package/lib/helpers/confirm.js +0 -6
  85. package/lib/helpers/confirm.js.map +0 -1
  86. package/lib/helpers/floorToNumDecimals.js +0 -15
  87. package/lib/helpers/floorToNumDecimals.js.map +0 -1
  88. package/lib/helpers/forceNumIntoBounds.js +0 -15
  89. package/lib/helpers/forceNumIntoBounds.js.map +0 -1
  90. package/lib/helpers/handleError.d.ts +0 -14
  91. package/lib/helpers/handleError.js +0 -54
  92. package/lib/helpers/handleError.js.map +0 -1
  93. package/lib/helpers/handleSuccess.d.ts +0 -8
  94. package/lib/helpers/handleSuccess.js +0 -20
  95. package/lib/helpers/handleSuccess.js.map +0 -1
  96. package/lib/helpers/padDecimalZeros.js +0 -30
  97. package/lib/helpers/padDecimalZeros.js.map +0 -1
  98. package/lib/helpers/padZerosLeft.js +0 -21
  99. package/lib/helpers/padZerosLeft.js.map +0 -1
  100. package/lib/helpers/parseRequest.d.ts +0 -21
  101. package/lib/helpers/parseRequest.js +0 -240
  102. package/lib/helpers/parseRequest.js.map +0 -1
  103. package/lib/helpers/roundToNumDecimals.js +0 -15
  104. package/lib/helpers/roundToNumDecimals.js.map +0 -1
  105. package/lib/helpers/showFatalError.d.ts +0 -2
  106. package/lib/helpers/showFatalError.js +0 -6
  107. package/lib/helpers/showFatalError.js.map +0 -1
  108. package/lib/helpers/sum.js +0 -15
  109. package/lib/helpers/sum.js.map +0 -1
  110. package/lib/helpers/visitServerEndpoint.d.ts +0 -23
  111. package/lib/helpers/visitServerEndpoint.js +0 -135
  112. package/lib/helpers/visitServerEndpoint.js.map +0 -1
  113. package/lib/helpers/waitMs.js +0 -55
  114. package/lib/helpers/waitMs.js.map +0 -1
  115. package/lib/types/ParamType.d.ts +0 -17
  116. package/lib/types/ParamType.js +0 -21
  117. package/lib/types/ParamType.js.map +0 -1
  118. package/lib/types/ReactKitErrorCode.js +0 -18
  119. package/lib/types/ReactKitErrorCode.js.map +0 -1
  120. package/lib/types/Variant.js +0 -19
  121. package/lib/types/Variant.js.map +0 -1
  122. package/src/helpers/alert.tsx +0 -5
  123. package/src/helpers/confirm.tsx +0 -5
  124. package/src/helpers/handleError.ts +0 -65
  125. package/src/helpers/handleSuccess.ts +0 -18
  126. package/src/helpers/parseRequest.ts +0 -299
  127. package/src/helpers/showFatalError.tsx +0 -5
  128. package/src/helpers/visitServerEndpoint.tsx +0 -110
  129. package/src/types/ParamType.ts +0 -18
@@ -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
- 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
- }
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 modalTypeToButtonTypes: {
117
- [k: string]: ButtonType[]
44
+ const modalTypeToModalButtonTypes: {
45
+ [k: string]: ModalButtonType[]
118
46
  } = {
119
47
  [ModalType.Okay]: [
120
- ButtonType.Okay,
48
+ ModalButtonType.Okay,
121
49
  ],
122
50
  [ModalType.OkayCancel]: [
123
- ButtonType.Okay,
124
- ButtonType.Cancel,
51
+ ModalButtonType.Okay,
52
+ ModalButtonType.Cancel,
125
53
  ],
126
54
  [ModalType.YesNo]: [
127
- ButtonType.Yes,
128
- ButtonType.No,
55
+ ModalButtonType.Yes,
56
+ ModalButtonType.No,
129
57
  ],
130
58
  [ModalType.YesNoCancel]: [
131
- ButtonType.Yes,
132
- ButtonType.No,
133
- ButtonType.Cancel,
59
+ ModalButtonType.Yes,
60
+ ModalButtonType.No,
61
+ ModalButtonType.Cancel,
134
62
  ],
135
63
  [ModalType.AbandonGoBack]: [
136
- ButtonType.Abandon,
137
- ButtonType.GoBack,
64
+ ModalButtonType.Abandon,
65
+ ModalButtonType.GoBack,
138
66
  ],
139
67
  [ModalType.ImSureCancel]: [
140
- ButtonType.ImSure,
141
- ButtonType.Cancel,
68
+ ModalButtonType.ImSure,
69
+ ModalButtonType.Cancel,
142
70
  ],
143
71
  [ModalType.DeleteCancel]: [
144
- ButtonType.Delete,
145
- ButtonType.Cancel,
72
+ ModalButtonType.Delete,
73
+ ModalButtonType.Cancel,
146
74
  ],
147
75
  [ModalType.ConfirmCancel]: [
148
- ButtonType.Confirm,
149
- ButtonType.Cancel,
76
+ ModalButtonType.Confirm,
77
+ ModalButtonType.Cancel,
150
78
  ],
151
79
  };
152
80
 
153
81
  // Button type styling and labels
154
- const buttonTypeToLabelAndVariant = {
155
- [ButtonType.Okay]: {
82
+ const ModalButtonTypeToLabelAndVariant = {
83
+ [ModalButtonType.Okay]: {
156
84
  label: 'Okay',
157
85
  variant: Variant.Dark,
158
86
  },
159
- [ButtonType.Cancel]: {
87
+ [ModalButtonType.Cancel]: {
160
88
  label: 'Cancel',
161
89
  variant: Variant.Secondary,
162
90
  },
163
- [ButtonType.Yes]: {
91
+ [ModalButtonType.Yes]: {
164
92
  label: 'Yes',
165
93
  variant: Variant.Dark,
166
94
  },
167
- [ButtonType.No]: {
95
+ [ModalButtonType.No]: {
168
96
  label: 'No',
169
97
  variant: Variant.Secondary,
170
98
  },
171
- [ButtonType.Abandon]: {
99
+ [ModalButtonType.Abandon]: {
172
100
  label: 'Abandon Changes',
173
101
  variant: Variant.Warning,
174
102
  },
175
- [ButtonType.GoBack]: {
103
+ [ModalButtonType.GoBack]: {
176
104
  label: 'Go Back',
177
105
  variant: Variant.Secondary,
178
106
  },
179
- [ButtonType.Continue]: {
107
+ [ModalButtonType.Continue]: {
180
108
  label: 'Continue',
181
109
  variant: Variant.Dark,
182
110
  },
183
- [ButtonType.ImSure]: {
111
+ [ModalButtonType.ImSure]: {
184
112
  label: 'I am sure',
185
113
  variant: Variant.Warning,
186
114
  },
187
- [ButtonType.Delete]: {
115
+ [ModalButtonType.Delete]: {
188
116
  label: 'Yes, Delete',
189
117
  variant: Variant.Danger,
190
118
  },
191
- [ButtonType.Confirm]: {
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: ButtonType) => void,
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 buttonType the button that was clicked when closing the
245
+ * @param ModalButtonType the button that was clicked when closing the
326
246
  * modal
327
247
  */
328
- const handleClose = async (buttonType: ButtonType) => {
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(buttonType);
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 buttonTypes: ButtonType[] = modalTypeToButtonTypes[type] ?? [];
281
+ const ModalButtonTypes: ModalButtonType[] = modalTypeToModalButtonTypes[type] ?? [];
362
282
 
363
283
  // Create buttons
364
- const buttons = buttonTypes.map((buttonType: ButtonType, i) => {
284
+ const buttons = ModalButtonTypes.map((ModalButtonType: ModalButtonType, i) => {
365
285
  // Get default style
366
286
  let {
367
287
  label,
368
288
  variant,
369
- } = buttonTypeToLabelAndVariant[buttonType];
289
+ } = ModalButtonTypeToLabelAndVariant[ModalButtonType];
370
290
 
371
291
  // Override with customizations
372
- if (props[`${buttonType}Label`]) {
373
- label = props[`${buttonType}Label`];
292
+ const newLabel = props[`${ModalButtonType}Label`];
293
+ if (newLabel) {
294
+ label = newLabel;
374
295
  }
375
- if (props[`${buttonType}Variant`]) {
376
- variant = props[`${buttonType}Variant`];
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 === buttonTypes.length - 1);
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-${buttonType}-button btn btn-${variant} ${last ? '' : 'mr-1'}`}
308
+ className={`Modal-${ModalButtonType}-button btn btn-${variant} ${last ? '' : 'mr-1'}`}
387
309
  onClick={() => {
388
- handleClose(buttonType);
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
- <BootstrapModal
410
- show={visible}
411
- size={size !== ModalSize.Medium ? size : undefined}
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
- {title && (
429
- <BootstrapModal.Header
430
- closeButton={!!onClose}
431
- >
432
- <BootstrapModal.Title>
433
- {title}
434
- </BootstrapModal.Title>
435
- </BootstrapModal.Header>
436
- )}
437
- {children && (
438
- <BootstrapModal.Body>
439
- {children}
440
- </BootstrapModal.Body>
441
- )}
442
- {footer && (
443
- <BootstrapModal.Footer>
444
- {footer}
445
- </BootstrapModal.Footer>
446
- )}
447
- </BootstrapModal>
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;
@@ -21,3 +21,5 @@ const abbreviate = (text: string, maxChars: number): string => {
21
21
  );
22
22
  return `${shortenedText}...`;
23
23
  };
24
+
25
+ export default abbreviate;
@@ -9,7 +9,7 @@
9
9
  const padDecimalZeros = (num: number, numDigits: number): string => {
10
10
  // Skip if nothing to do
11
11
  if (numDigits < 1) {
12
- return;
12
+ return String(num);
13
13
  }
14
14
 
15
15
  // Convert to string
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,12 @@
1
+ /**
2
+ * Modal sizes
3
+ * @author Gabe Abrams
4
+ */
5
+ enum ModalSize {
6
+ Small = 'sm',
7
+ Medium = 'md',
8
+ Large = 'lg',
9
+ ExtraLarge = 'xl',
10
+ }
11
+
12
+ export default ModalSize;
@@ -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
- "module": "commonjs",
3
+ "target": "es2016",
4
4
  "esModuleInterop": true,
5
- "noImplicitAny": true,
6
- "noEmitOnError": true,
7
- "removeComments": false,
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
- "target": "es5",
11
- "jsx": "react-jsx",
12
- "lib": [
13
- "es2017",
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
- "ts-node": {
22
- "files": true
23
- }
24
- }
21
+ "./src/**/*"
22
+ ]
23
+ }