dce-reactkit 2.0.12 → 3.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 (191) hide show
  1. package/lib/cjs/index.js +2 -0
  2. package/lib/cjs/index.js.map +1 -0
  3. package/lib/{components → cjs/lib/components}/AppWrapper.d.ts +4 -4
  4. package/lib/{components → cjs/lib/components}/ErrorBox.d.ts +0 -0
  5. package/lib/{components → cjs/lib/components}/LoadingSpinner.d.ts +1 -0
  6. package/lib/{components → cjs/lib/components}/Modal.d.ts +5 -36
  7. package/lib/{components → cjs/lib/components}/TabBox.d.ts +0 -0
  8. package/lib/{errors → cjs/lib/errors}/ErrorWithCode.d.ts +0 -0
  9. package/lib/{helpers → cjs/lib/helpers}/abbreviate.d.ts +1 -0
  10. package/lib/{helpers → cjs/lib/helpers}/avg.d.ts +0 -0
  11. package/lib/{helpers → cjs/lib/helpers}/ceilToNumDecimals.d.ts +0 -0
  12. package/lib/{helpers → cjs/lib/helpers}/floorToNumDecimals.d.ts +0 -0
  13. package/lib/{helpers → cjs/lib/helpers}/forceNumIntoBounds.d.ts +0 -0
  14. package/lib/{helpers → cjs/lib/helpers}/handleError.d.ts +0 -0
  15. package/lib/{helpers → cjs/lib/helpers}/handleSuccess.d.ts +0 -0
  16. package/lib/{helpers → cjs/lib/helpers}/padDecimalZeros.d.ts +0 -0
  17. package/lib/{helpers → cjs/lib/helpers}/padZerosLeft.d.ts +0 -0
  18. package/lib/{helpers → cjs/lib/helpers}/parseRequest.d.ts +1 -1
  19. package/lib/{helpers → cjs/lib/helpers}/roundToNumDecimals.d.ts +0 -0
  20. package/lib/{helpers → cjs/lib/helpers}/sum.d.ts +0 -0
  21. package/lib/{helpers → cjs/lib/helpers}/visitServerEndpoint.d.ts +2 -2
  22. package/lib/{helpers → cjs/lib/helpers}/waitMs.d.ts +0 -0
  23. package/lib/cjs/lib/index.d.ts +27 -0
  24. package/lib/cjs/lib/types/ModalButtonType.d.ts +17 -0
  25. package/lib/cjs/lib/types/ModalSize.d.ts +11 -0
  26. package/lib/cjs/lib/types/ModalType.d.ts +16 -0
  27. package/lib/{types → cjs/lib/types}/ParamType.d.ts +0 -0
  28. package/lib/{types → cjs/lib/types}/ReactKitErrorCode.d.ts +0 -0
  29. package/lib/{types → cjs/lib/types}/Variant.d.ts +0 -0
  30. package/lib/cjs/types/components/AppWrapper.d.ts +40 -0
  31. package/lib/cjs/types/components/ErrorBox.d.ts +12 -0
  32. package/lib/cjs/types/components/LoadingSpinner.d.ts +7 -0
  33. package/lib/cjs/types/components/Modal.d.ts +40 -0
  34. package/lib/cjs/types/components/TabBox.d.ts +11 -0
  35. package/lib/cjs/types/errors/ErrorWithCode.d.ts +9 -0
  36. package/lib/cjs/types/helpers/abbreviate.d.ts +10 -0
  37. package/lib/{helpers → cjs/types/helpers}/alert.d.ts +0 -0
  38. package/lib/cjs/types/helpers/avg.d.ts +8 -0
  39. package/lib/cjs/types/helpers/ceilToNumDecimals.d.ts +9 -0
  40. package/lib/{helpers → cjs/types/helpers}/confirm.d.ts +0 -0
  41. package/lib/cjs/types/helpers/floorToNumDecimals.d.ts +9 -0
  42. package/lib/cjs/types/helpers/forceNumIntoBounds.d.ts +10 -0
  43. package/lib/cjs/types/helpers/handleError.d.ts +14 -0
  44. package/lib/cjs/types/helpers/handleSuccess.d.ts +8 -0
  45. package/lib/cjs/types/helpers/padDecimalZeros.d.ts +10 -0
  46. package/lib/cjs/types/helpers/padZerosLeft.d.ts +9 -0
  47. package/lib/cjs/types/helpers/parseRequest.d.ts +21 -0
  48. package/lib/cjs/types/helpers/roundToNumDecimals.d.ts +9 -0
  49. package/lib/{helpers → cjs/types/helpers}/showFatalError.d.ts +1 -1
  50. package/lib/cjs/types/helpers/sum.d.ts +8 -0
  51. package/lib/cjs/types/helpers/visitServerEndpoint.d.ts +23 -0
  52. package/lib/cjs/types/helpers/waitMs.d.ts +7 -0
  53. package/lib/cjs/types/index.d.ts +22 -0
  54. package/lib/cjs/types/types/ModalButtonType.d.ts +17 -0
  55. package/lib/cjs/types/types/ModalSize.d.ts +11 -0
  56. package/lib/cjs/types/types/ModalType.d.ts +16 -0
  57. package/lib/cjs/types/types/ParamType.d.ts +17 -0
  58. package/lib/cjs/types/types/ReactKitErrorCode.d.ts +13 -0
  59. package/lib/cjs/types/types/Variant.d.ts +15 -0
  60. package/lib/esm/index.js +16 -0
  61. package/lib/esm/index.js.map +1 -0
  62. package/lib/esm/lib/components/AppWrapper.d.ts +35 -0
  63. package/lib/esm/lib/components/ErrorBox.d.ts +12 -0
  64. package/lib/esm/lib/components/LoadingSpinner.d.ts +7 -0
  65. package/lib/esm/lib/components/Modal.d.ts +40 -0
  66. package/lib/esm/lib/components/TabBox.d.ts +11 -0
  67. package/lib/esm/lib/errors/ErrorWithCode.d.ts +9 -0
  68. package/lib/esm/lib/helpers/abbreviate.d.ts +10 -0
  69. package/lib/esm/lib/helpers/avg.d.ts +8 -0
  70. package/lib/esm/lib/helpers/ceilToNumDecimals.d.ts +9 -0
  71. package/lib/esm/lib/helpers/floorToNumDecimals.d.ts +9 -0
  72. package/lib/esm/lib/helpers/forceNumIntoBounds.d.ts +10 -0
  73. package/lib/esm/lib/helpers/handleError.d.ts +14 -0
  74. package/lib/esm/lib/helpers/handleSuccess.d.ts +8 -0
  75. package/lib/esm/lib/helpers/padDecimalZeros.d.ts +10 -0
  76. package/lib/esm/lib/helpers/padZerosLeft.d.ts +9 -0
  77. package/lib/esm/lib/helpers/parseRequest.d.ts +21 -0
  78. package/lib/esm/lib/helpers/roundToNumDecimals.d.ts +9 -0
  79. package/lib/esm/lib/helpers/sum.d.ts +8 -0
  80. package/lib/esm/lib/helpers/visitServerEndpoint.d.ts +23 -0
  81. package/lib/esm/lib/helpers/waitMs.d.ts +7 -0
  82. package/lib/esm/lib/index.d.ts +27 -0
  83. package/lib/esm/lib/types/ModalButtonType.d.ts +17 -0
  84. package/lib/esm/lib/types/ModalSize.d.ts +11 -0
  85. package/lib/esm/lib/types/ModalType.d.ts +16 -0
  86. package/lib/esm/lib/types/ParamType.d.ts +17 -0
  87. package/lib/esm/lib/types/ReactKitErrorCode.d.ts +13 -0
  88. package/lib/esm/lib/types/Variant.d.ts +15 -0
  89. package/lib/esm/types/components/AppWrapper.d.ts +40 -0
  90. package/lib/esm/types/components/ErrorBox.d.ts +12 -0
  91. package/lib/esm/types/components/LoadingSpinner.d.ts +7 -0
  92. package/lib/esm/types/components/Modal.d.ts +40 -0
  93. package/lib/esm/types/components/TabBox.d.ts +11 -0
  94. package/lib/esm/types/errors/ErrorWithCode.d.ts +9 -0
  95. package/lib/esm/types/helpers/abbreviate.d.ts +10 -0
  96. package/lib/esm/types/helpers/alert.d.ts +2 -0
  97. package/lib/esm/types/helpers/avg.d.ts +8 -0
  98. package/lib/esm/types/helpers/ceilToNumDecimals.d.ts +9 -0
  99. package/lib/esm/types/helpers/confirm.d.ts +2 -0
  100. package/lib/esm/types/helpers/floorToNumDecimals.d.ts +9 -0
  101. package/lib/esm/types/helpers/forceNumIntoBounds.d.ts +10 -0
  102. package/lib/esm/types/helpers/handleError.d.ts +14 -0
  103. package/lib/esm/types/helpers/handleSuccess.d.ts +8 -0
  104. package/lib/esm/types/helpers/padDecimalZeros.d.ts +10 -0
  105. package/lib/esm/types/helpers/padZerosLeft.d.ts +9 -0
  106. package/lib/esm/types/helpers/parseRequest.d.ts +21 -0
  107. package/lib/esm/types/helpers/roundToNumDecimals.d.ts +9 -0
  108. package/lib/esm/types/helpers/showFatalError.d.ts +2 -0
  109. package/lib/esm/types/helpers/sum.d.ts +8 -0
  110. package/lib/esm/types/helpers/visitServerEndpoint.d.ts +23 -0
  111. package/lib/esm/types/helpers/waitMs.d.ts +7 -0
  112. package/lib/esm/types/index.d.ts +22 -0
  113. package/lib/esm/types/types/ModalButtonType.d.ts +17 -0
  114. package/lib/esm/types/types/ModalSize.d.ts +11 -0
  115. package/lib/esm/types/types/ModalType.d.ts +16 -0
  116. package/lib/esm/types/types/ParamType.d.ts +17 -0
  117. package/lib/esm/types/types/ReactKitErrorCode.d.ts +13 -0
  118. package/lib/esm/types/types/Variant.d.ts +15 -0
  119. package/lib/index.d.ts +274 -0
  120. package/package.json +26 -5
  121. package/rollup.config.js +43 -0
  122. package/src/components/AppWrapper.tsx +31 -35
  123. package/src/components/LoadingSpinner.tsx +3 -0
  124. package/src/components/Modal.tsx +50 -94
  125. package/src/helpers/abbreviate.tsx +2 -0
  126. package/src/helpers/padDecimalZeros.tsx +1 -1
  127. package/src/index.ts +61 -0
  128. package/src/types/ModalButtonType.tsx +18 -0
  129. package/src/types/ModalSize.tsx +12 -0
  130. package/src/types/ModalType.tsx +17 -0
  131. package/tsconfig.json +14 -17
  132. package/lib/components/AppWrapper.js +0 -277
  133. package/lib/components/AppWrapper.js.map +0 -1
  134. package/lib/components/ErrorBox.js +0 -65
  135. package/lib/components/ErrorBox.js.map +0 -1
  136. package/lib/components/LoadingSpinner.js +0 -41
  137. package/lib/components/LoadingSpinner.js.map +0 -1
  138. package/lib/components/Modal.js +0 -321
  139. package/lib/components/Modal.js.map +0 -1
  140. package/lib/components/TabBox.js +0 -42
  141. package/lib/components/TabBox.js.map +0 -1
  142. package/lib/errors/ErrorWithCode.js +0 -33
  143. package/lib/errors/ErrorWithCode.js.map +0 -1
  144. package/lib/helpers/abbreviate.js +0 -21
  145. package/lib/helpers/abbreviate.js.map +0 -1
  146. package/lib/helpers/alert.js +0 -6
  147. package/lib/helpers/alert.js.map +0 -1
  148. package/lib/helpers/avg.js +0 -24
  149. package/lib/helpers/avg.js.map +0 -1
  150. package/lib/helpers/ceilToNumDecimals.js +0 -15
  151. package/lib/helpers/ceilToNumDecimals.js.map +0 -1
  152. package/lib/helpers/confirm.js +0 -6
  153. package/lib/helpers/confirm.js.map +0 -1
  154. package/lib/helpers/floorToNumDecimals.js +0 -15
  155. package/lib/helpers/floorToNumDecimals.js.map +0 -1
  156. package/lib/helpers/forceNumIntoBounds.js +0 -15
  157. package/lib/helpers/forceNumIntoBounds.js.map +0 -1
  158. package/lib/helpers/handleError.js +0 -54
  159. package/lib/helpers/handleError.js.map +0 -1
  160. package/lib/helpers/handleSuccess.js +0 -20
  161. package/lib/helpers/handleSuccess.js.map +0 -1
  162. package/lib/helpers/padDecimalZeros.js +0 -30
  163. package/lib/helpers/padDecimalZeros.js.map +0 -1
  164. package/lib/helpers/padZerosLeft.js +0 -21
  165. package/lib/helpers/padZerosLeft.js.map +0 -1
  166. package/lib/helpers/parseRequest.js +0 -240
  167. package/lib/helpers/parseRequest.js.map +0 -1
  168. package/lib/helpers/roundToNumDecimals.js +0 -15
  169. package/lib/helpers/roundToNumDecimals.js.map +0 -1
  170. package/lib/helpers/showFatalError.js +0 -6
  171. package/lib/helpers/showFatalError.js.map +0 -1
  172. package/lib/helpers/sum.js +0 -15
  173. package/lib/helpers/sum.js.map +0 -1
  174. package/lib/helpers/visitServerEndpoint.js +0 -135
  175. package/lib/helpers/visitServerEndpoint.js.map +0 -1
  176. package/lib/helpers/waitMs.js +0 -55
  177. package/lib/helpers/waitMs.js.map +0 -1
  178. package/lib/types/ParamType.js +0 -21
  179. package/lib/types/ParamType.js.map +0 -1
  180. package/lib/types/ReactKitErrorCode.js +0 -18
  181. package/lib/types/ReactKitErrorCode.js.map +0 -1
  182. package/lib/types/Variant.js +0 -19
  183. package/lib/types/Variant.js.map +0 -1
  184. package/src/helpers/alert.tsx +0 -5
  185. package/src/helpers/confirm.tsx +0 -5
  186. package/src/helpers/handleError.ts +0 -65
  187. package/src/helpers/handleSuccess.ts +0 -18
  188. package/src/helpers/parseRequest.ts +0 -299
  189. package/src/helpers/showFatalError.tsx +0 -5
  190. package/src/helpers/visitServerEndpoint.tsx +0 -110
  191. package/src/types/ParamType.ts +0 -18
@@ -12,6 +12,9 @@ import waitMs from '../helpers/waitMs';
12
12
 
13
13
  // Import types
14
14
  import Variant from '../types/Variant';
15
+ import ModalButtonType from '../types/ModalButtonType';
16
+ import ModalSize from '../types/ModalSize';
17
+ import ModalType from '../types/ModalType';
15
18
 
16
19
  /*------------------------------------------------------------------------*/
17
20
  /* Style */
@@ -77,118 +80,83 @@ const MS_TO_ANIMATE = 400; // Time to animate in/out (defined by bootstrap)
77
80
  const MS_ANIMATE_IN_DELAY = 10;
78
81
  // Time to wait before animating in (must be >0 or animation won't trigger)
79
82
 
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
83
  // Modal type to list of buttons
116
- const modalTypeToButtonTypes: {
117
- [k: string]: ButtonType[]
84
+ const modalTypeToModalButtonTypes: {
85
+ [k: string]: ModalButtonType[]
118
86
  } = {
119
87
  [ModalType.Okay]: [
120
- ButtonType.Okay,
88
+ ModalButtonType.Okay,
121
89
  ],
122
90
  [ModalType.OkayCancel]: [
123
- ButtonType.Okay,
124
- ButtonType.Cancel,
91
+ ModalButtonType.Okay,
92
+ ModalButtonType.Cancel,
125
93
  ],
126
94
  [ModalType.YesNo]: [
127
- ButtonType.Yes,
128
- ButtonType.No,
95
+ ModalButtonType.Yes,
96
+ ModalButtonType.No,
129
97
  ],
130
98
  [ModalType.YesNoCancel]: [
131
- ButtonType.Yes,
132
- ButtonType.No,
133
- ButtonType.Cancel,
99
+ ModalButtonType.Yes,
100
+ ModalButtonType.No,
101
+ ModalButtonType.Cancel,
134
102
  ],
135
103
  [ModalType.AbandonGoBack]: [
136
- ButtonType.Abandon,
137
- ButtonType.GoBack,
104
+ ModalButtonType.Abandon,
105
+ ModalButtonType.GoBack,
138
106
  ],
139
107
  [ModalType.ImSureCancel]: [
140
- ButtonType.ImSure,
141
- ButtonType.Cancel,
108
+ ModalButtonType.ImSure,
109
+ ModalButtonType.Cancel,
142
110
  ],
143
111
  [ModalType.DeleteCancel]: [
144
- ButtonType.Delete,
145
- ButtonType.Cancel,
112
+ ModalButtonType.Delete,
113
+ ModalButtonType.Cancel,
146
114
  ],
147
115
  [ModalType.ConfirmCancel]: [
148
- ButtonType.Confirm,
149
- ButtonType.Cancel,
116
+ ModalButtonType.Confirm,
117
+ ModalButtonType.Cancel,
150
118
  ],
151
119
  };
152
120
 
153
121
  // Button type styling and labels
154
- const buttonTypeToLabelAndVariant = {
155
- [ButtonType.Okay]: {
122
+ const ModalButtonTypeToLabelAndVariant = {
123
+ [ModalButtonType.Okay]: {
156
124
  label: 'Okay',
157
125
  variant: Variant.Dark,
158
126
  },
159
- [ButtonType.Cancel]: {
127
+ [ModalButtonType.Cancel]: {
160
128
  label: 'Cancel',
161
129
  variant: Variant.Secondary,
162
130
  },
163
- [ButtonType.Yes]: {
131
+ [ModalButtonType.Yes]: {
164
132
  label: 'Yes',
165
133
  variant: Variant.Dark,
166
134
  },
167
- [ButtonType.No]: {
135
+ [ModalButtonType.No]: {
168
136
  label: 'No',
169
137
  variant: Variant.Secondary,
170
138
  },
171
- [ButtonType.Abandon]: {
139
+ [ModalButtonType.Abandon]: {
172
140
  label: 'Abandon Changes',
173
141
  variant: Variant.Warning,
174
142
  },
175
- [ButtonType.GoBack]: {
143
+ [ModalButtonType.GoBack]: {
176
144
  label: 'Go Back',
177
145
  variant: Variant.Secondary,
178
146
  },
179
- [ButtonType.Continue]: {
147
+ [ModalButtonType.Continue]: {
180
148
  label: 'Continue',
181
149
  variant: Variant.Dark,
182
150
  },
183
- [ButtonType.ImSure]: {
151
+ [ModalButtonType.ImSure]: {
184
152
  label: 'I am sure',
185
153
  variant: Variant.Warning,
186
154
  },
187
- [ButtonType.Delete]: {
155
+ [ModalButtonType.Delete]: {
188
156
  label: 'Yes, Delete',
189
157
  variant: Variant.Danger,
190
158
  },
191
- [ButtonType.Confirm]: {
159
+ [ModalButtonType.Confirm]: {
192
160
  label: 'Confirm',
193
161
  variant: Variant.Dark,
194
162
  },
@@ -208,7 +176,7 @@ type Props = {
208
176
  // The body of the modal
209
177
  children?: React.ReactNode,
210
178
  // Handler to call when modal is closed (if excluded, not closable)
211
- onClose?: (type: ButtonType) => void,
179
+ onClose?: (type: ModalButtonType) => void,
212
180
  // If true, don't allow the user to click the backdrop to exit
213
181
  dontAllowBackdropExit?: boolean,
214
182
  // Custom label for "okay" button
@@ -259,15 +227,7 @@ type Props = {
259
227
  /* Component */
260
228
  /*------------------------------------------------------------------------*/
261
229
 
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) => {
230
+ const Modal: React.FC<Props> = (props) => {
271
231
  /*------------------------------------------------------------------------*/
272
232
  /* Setup */
273
233
  /*------------------------------------------------------------------------*/
@@ -322,10 +282,10 @@ const Modal: (
322
282
  /**
323
283
  * Handles the closing of the modal
324
284
  * @author Gabe Abrams
325
- * @param buttonType the button that was clicked when closing the
285
+ * @param ModalButtonType the button that was clicked when closing the
326
286
  * modal
327
287
  */
328
- const handleClose = async (buttonType: ButtonType) => {
288
+ const handleClose = async (ModalButtonType: ModalButtonType) => {
329
289
  // Don't close if no handler
330
290
  if (!onClose) {
331
291
  return;
@@ -346,7 +306,7 @@ const Modal: (
346
306
 
347
307
  // Call the handler after the modal has animated out
348
308
  await waitMs(MS_TO_ANIMATE);
349
- onClose(buttonType);
309
+ onClose(ModalButtonType);
350
310
  };
351
311
 
352
312
  /*------------------------------------------------------------------------*/
@@ -358,34 +318,36 @@ const Modal: (
358
318
  /*----------------------------------------*/
359
319
 
360
320
  // Get list of buttons for this modal type
361
- const buttonTypes: ButtonType[] = modalTypeToButtonTypes[type] ?? [];
321
+ const ModalButtonTypes: ModalButtonType[] = modalTypeToModalButtonTypes[type] ?? [];
362
322
 
363
323
  // Create buttons
364
- const buttons = buttonTypes.map((buttonType: ButtonType, i) => {
324
+ const buttons = ModalButtonTypes.map((ModalButtonType: ModalButtonType, i) => {
365
325
  // Get default style
366
326
  let {
367
327
  label,
368
328
  variant,
369
- } = buttonTypeToLabelAndVariant[buttonType];
329
+ } = ModalButtonTypeToLabelAndVariant[ModalButtonType];
370
330
 
371
331
  // Override with customizations
372
- if (props[`${buttonType}Label`]) {
373
- label = props[`${buttonType}Label`];
332
+ const newLabel = props[`${ModalButtonType}Label`];
333
+ if (newLabel) {
334
+ label = newLabel;
374
335
  }
375
- if (props[`${buttonType}Variant`]) {
376
- variant = props[`${buttonType}Variant`];
336
+ const newVariant = props[`${ModalButtonType}Variant`];
337
+ if (newVariant) {
338
+ variant = newVariant;
377
339
  }
378
340
 
379
341
  // Check if this button is last
380
- const last = (i === buttonTypes.length - 1);
342
+ const last = (i === ModalButtonTypes.length - 1);
381
343
 
382
344
  // Create the button
383
345
  return (
384
346
  <button
385
347
  type="button"
386
- className={`Modal-${buttonType}-button btn btn-${variant} ${last ? '' : 'mr-1'}`}
348
+ className={`Modal-${ModalButtonType}-button btn btn-${variant} ${last ? '' : 'mr-1'}`}
387
349
  onClick={() => {
388
- handleClose(buttonType);
350
+ handleClose(ModalButtonType);
389
351
  }}
390
352
  >
391
353
  {label}
@@ -411,7 +373,7 @@ const Modal: (
411
373
  size={size !== ModalSize.Medium ? size : undefined}
412
374
  onHide={() => {
413
375
  if (!dontAllowBackdropExit) {
414
- handleClose(ButtonType.Cancel);
376
+ handleClose(ModalButtonType.Cancel);
415
377
  }
416
378
  }}
417
379
  style={{
@@ -452,10 +414,4 @@ const Modal: (
452
414
  /* Wrap Up */
453
415
  /*------------------------------------------------------------------------*/
454
416
 
455
- // Add enums
456
- Modal.ModalType = ModalType;
457
- Modal.ModalSize = ModalSize;
458
- Modal.ButtonType = ButtonType;
459
- Modal.Variant = Variant;
460
-
461
417
  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,21 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "module": "commonjs",
4
3
  "esModuleInterop": true,
5
- "noImplicitAny": true,
6
- "noEmitOnError": true,
7
- "removeComments": false,
4
+ "strict": true,
5
+ "skipLibCheck": true,
6
+ "jsx": "react",
7
+ "module": "ESNext",
8
8
  "declaration": true,
9
+ "declarationDir": "types",
9
10
  "sourceMap": true,
10
- "target": "es5",
11
- "jsx": "react-jsx",
12
- "lib": [
13
- "es2017",
14
- "dom"
15
- ],
16
- "outDir": "./lib"
11
+ "outDir": "./lib",
12
+ "moduleResolution": "node",
13
+ "emitDeclarationOnly": true,
14
+ "allowSyntheticDefaultImports": true,
15
+ "forceConsistentCasingInFileNames": true,
17
16
  },
18
- "include": [
19
- "./src"
20
- ],
21
- "ts-node": {
22
- "files": true
23
- }
17
+ "exclude": [
18
+ "lib",
19
+ "node_modules"
20
+ ]
24
21
  }