dce-reactkit 2.0.12 → 3.0.0-beta.1

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 (131) hide show
  1. package/dist/cjs/index.js +36424 -0
  2. package/dist/cjs/index.js.map +1 -0
  3. package/{lib → dist/cjs/types}/components/AppWrapper.d.ts +9 -4
  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 +36375 -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/{src/helpers/ceilToNumDecimals.tsx → dist/esm/types/helpers/ceilToNumDecimals.d.ts} +1 -5
  36. package/{src/helpers/floorToNumDecimals.tsx → dist/esm/types/helpers/floorToNumDecimals.d.ts} +1 -5
  37. package/{src/helpers/forceNumIntoBounds.tsx → dist/esm/types/helpers/forceNumIntoBounds.d.ts} +1 -10
  38. package/dist/esm/types/helpers/padDecimalZeros.d.ts +10 -0
  39. package/{src/helpers/padZerosLeft.tsx → dist/esm/types/helpers/padZerosLeft.d.ts} +1 -13
  40. package/{src/helpers/roundToNumDecimals.tsx → dist/esm/types/helpers/roundToNumDecimals.d.ts} +1 -5
  41. package/{src/helpers/sum.tsx → dist/esm/types/helpers/sum.d.ts} +1 -9
  42. package/{src/helpers/waitMs.tsx → dist/esm/types/helpers/waitMs.d.ts} +1 -6
  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 -22
  51. package/.eslintrc.js +0 -95
  52. package/lib/components/AppWrapper.js +0 -277
  53. package/lib/components/AppWrapper.js.map +0 -1
  54. package/lib/components/ErrorBox.js +0 -65
  55. package/lib/components/ErrorBox.js.map +0 -1
  56. package/lib/components/LoadingSpinner.js +0 -41
  57. package/lib/components/LoadingSpinner.js.map +0 -1
  58. package/lib/components/Modal.js +0 -321
  59. package/lib/components/Modal.js.map +0 -1
  60. package/lib/components/TabBox.js +0 -42
  61. package/lib/components/TabBox.js.map +0 -1
  62. package/lib/errors/ErrorWithCode.js +0 -33
  63. package/lib/errors/ErrorWithCode.js.map +0 -1
  64. package/lib/helpers/abbreviate.js +0 -21
  65. package/lib/helpers/abbreviate.js.map +0 -1
  66. package/lib/helpers/alert.d.ts +0 -2
  67. package/lib/helpers/alert.js +0 -6
  68. package/lib/helpers/alert.js.map +0 -1
  69. package/lib/helpers/avg.js +0 -24
  70. package/lib/helpers/avg.js.map +0 -1
  71. package/lib/helpers/ceilToNumDecimals.js +0 -15
  72. package/lib/helpers/ceilToNumDecimals.js.map +0 -1
  73. package/lib/helpers/confirm.d.ts +0 -2
  74. package/lib/helpers/confirm.js +0 -6
  75. package/lib/helpers/confirm.js.map +0 -1
  76. package/lib/helpers/floorToNumDecimals.js +0 -15
  77. package/lib/helpers/floorToNumDecimals.js.map +0 -1
  78. package/lib/helpers/forceNumIntoBounds.js +0 -15
  79. package/lib/helpers/forceNumIntoBounds.js.map +0 -1
  80. package/lib/helpers/handleError.d.ts +0 -14
  81. package/lib/helpers/handleError.js +0 -54
  82. package/lib/helpers/handleError.js.map +0 -1
  83. package/lib/helpers/handleSuccess.d.ts +0 -8
  84. package/lib/helpers/handleSuccess.js +0 -20
  85. package/lib/helpers/handleSuccess.js.map +0 -1
  86. package/lib/helpers/padDecimalZeros.js +0 -30
  87. package/lib/helpers/padDecimalZeros.js.map +0 -1
  88. package/lib/helpers/padZerosLeft.js +0 -21
  89. package/lib/helpers/padZerosLeft.js.map +0 -1
  90. package/lib/helpers/parseRequest.d.ts +0 -21
  91. package/lib/helpers/parseRequest.js +0 -240
  92. package/lib/helpers/parseRequest.js.map +0 -1
  93. package/lib/helpers/roundToNumDecimals.js +0 -15
  94. package/lib/helpers/roundToNumDecimals.js.map +0 -1
  95. package/lib/helpers/showFatalError.d.ts +0 -2
  96. package/lib/helpers/showFatalError.js +0 -6
  97. package/lib/helpers/showFatalError.js.map +0 -1
  98. package/lib/helpers/sum.js +0 -15
  99. package/lib/helpers/sum.js.map +0 -1
  100. package/lib/helpers/visitServerEndpoint.d.ts +0 -23
  101. package/lib/helpers/visitServerEndpoint.js +0 -135
  102. package/lib/helpers/visitServerEndpoint.js.map +0 -1
  103. package/lib/helpers/waitMs.js +0 -55
  104. package/lib/helpers/waitMs.js.map +0 -1
  105. package/lib/types/ParamType.d.ts +0 -17
  106. package/lib/types/ParamType.js +0 -21
  107. package/lib/types/ParamType.js.map +0 -1
  108. package/lib/types/ReactKitErrorCode.js +0 -18
  109. package/lib/types/ReactKitErrorCode.js.map +0 -1
  110. package/lib/types/Variant.js +0 -19
  111. package/lib/types/Variant.js.map +0 -1
  112. package/src/components/AppWrapper.tsx +0 -369
  113. package/src/components/ErrorBox.tsx +0 -124
  114. package/src/components/LoadingSpinner.tsx +0 -105
  115. package/src/components/Modal.tsx +0 -461
  116. package/src/components/TabBox.tsx +0 -136
  117. package/src/errors/ErrorWithCode.tsx +0 -15
  118. package/src/helpers/abbreviate.tsx +0 -23
  119. package/src/helpers/alert.tsx +0 -5
  120. package/src/helpers/avg.tsx +0 -22
  121. package/src/helpers/confirm.tsx +0 -5
  122. package/src/helpers/handleError.ts +0 -65
  123. package/src/helpers/handleSuccess.ts +0 -18
  124. package/src/helpers/padDecimalZeros.tsx +0 -32
  125. package/src/helpers/parseRequest.ts +0 -299
  126. package/src/helpers/showFatalError.tsx +0 -5
  127. package/src/helpers/visitServerEndpoint.tsx +0 -110
  128. package/src/types/ParamType.ts +0 -18
  129. package/src/types/ReactKitErrorCode.tsx +0 -16
  130. package/src/types/Variant.tsx +0 -16
  131. package/tsconfig.json +0 -24
@@ -1,461 +0,0 @@
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
- /* Style */
18
- /*------------------------------------------------------------------------*/
19
-
20
- const style = `
21
- /* More opaque backdrop */
22
- .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
- }
68
- }
69
- `;
70
-
71
- /*------------------------------------------------------------------------*/
72
- /* Constants */
73
- /*------------------------------------------------------------------------*/
74
-
75
- // Constants
76
- const MS_TO_ANIMATE = 400; // Time to animate in/out (defined by bootstrap)
77
- const MS_ANIMATE_IN_DELAY = 10;
78
- // Time to wait before animating in (must be >0 or animation won't trigger)
79
-
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
- // Modal type to list of buttons
116
- const modalTypeToButtonTypes: {
117
- [k: string]: ButtonType[]
118
- } = {
119
- [ModalType.Okay]: [
120
- ButtonType.Okay,
121
- ],
122
- [ModalType.OkayCancel]: [
123
- ButtonType.Okay,
124
- ButtonType.Cancel,
125
- ],
126
- [ModalType.YesNo]: [
127
- ButtonType.Yes,
128
- ButtonType.No,
129
- ],
130
- [ModalType.YesNoCancel]: [
131
- ButtonType.Yes,
132
- ButtonType.No,
133
- ButtonType.Cancel,
134
- ],
135
- [ModalType.AbandonGoBack]: [
136
- ButtonType.Abandon,
137
- ButtonType.GoBack,
138
- ],
139
- [ModalType.ImSureCancel]: [
140
- ButtonType.ImSure,
141
- ButtonType.Cancel,
142
- ],
143
- [ModalType.DeleteCancel]: [
144
- ButtonType.Delete,
145
- ButtonType.Cancel,
146
- ],
147
- [ModalType.ConfirmCancel]: [
148
- ButtonType.Confirm,
149
- ButtonType.Cancel,
150
- ],
151
- };
152
-
153
- // Button type styling and labels
154
- const buttonTypeToLabelAndVariant = {
155
- [ButtonType.Okay]: {
156
- label: 'Okay',
157
- variant: Variant.Dark,
158
- },
159
- [ButtonType.Cancel]: {
160
- label: 'Cancel',
161
- variant: Variant.Secondary,
162
- },
163
- [ButtonType.Yes]: {
164
- label: 'Yes',
165
- variant: Variant.Dark,
166
- },
167
- [ButtonType.No]: {
168
- label: 'No',
169
- variant: Variant.Secondary,
170
- },
171
- [ButtonType.Abandon]: {
172
- label: 'Abandon Changes',
173
- variant: Variant.Warning,
174
- },
175
- [ButtonType.GoBack]: {
176
- label: 'Go Back',
177
- variant: Variant.Secondary,
178
- },
179
- [ButtonType.Continue]: {
180
- label: 'Continue',
181
- variant: Variant.Dark,
182
- },
183
- [ButtonType.ImSure]: {
184
- label: 'I am sure',
185
- variant: Variant.Warning,
186
- },
187
- [ButtonType.Delete]: {
188
- label: 'Yes, Delete',
189
- variant: Variant.Danger,
190
- },
191
- [ButtonType.Confirm]: {
192
- label: 'Confirm',
193
- variant: Variant.Dark,
194
- },
195
- };
196
-
197
- /*------------------------------------------------------------------------*/
198
- /* Types */
199
- /*------------------------------------------------------------------------*/
200
-
201
- type Props = {
202
- // Type of the modal
203
- type?: ModalType,
204
- // Size of the modal
205
- size?: ModalSize,
206
- // Title of the modal (if excluded, no header)
207
- title?: React.ReactNode,
208
- // The body of the modal
209
- children?: React.ReactNode,
210
- // Handler to call when modal is closed (if excluded, not closable)
211
- onClose?: (type: ButtonType) => void,
212
- // If true, don't allow the user to click the backdrop to exit
213
- dontAllowBackdropExit?: boolean,
214
- // Custom label for "okay" button
215
- okayLabel?: string,
216
- // Custom variant for "okay" button
217
- okayVariant?: Variant,
218
- // Custom label for "cancel" button
219
- cancelLabel?: string,
220
- // Custom variant for "cancel" button
221
- cancelVariant?: Variant,
222
- // Custom label for "yes" button
223
- yesLabel?: string,
224
- // Custom variant for "yes" button
225
- yesVariant?: Variant,
226
- // Custom label for "no" button
227
- noLabel?: string,
228
- // Custom variant for "no" button
229
- noVariant?: Variant,
230
- // Custom label for "abandon" button
231
- abandonLabel?: string,
232
- // Custom variant for "abandon" button
233
- abandonVariant?: Variant,
234
- // Custom label for "goBack" button
235
- goBackLabel?: string,
236
- // Custom variant for "goBack" button
237
- goBackVariant?: Variant,
238
- // Custom label for "continue" button
239
- continueLabel?: string,
240
- // Custom variant for "continue" button
241
- continueVariant?: Variant,
242
- // Custom label for "imSure" button
243
- imSureLabel?: string,
244
- // Custom variant for "imSure" button
245
- imSureVariant?: Variant,
246
- // Custom label for "delete" button
247
- deleteLabel?: string,
248
- // Custom variant for "delete" button
249
- deleteVariant?: Variant,
250
- // Custom label for "confirm" button
251
- confirmLabel?: string,
252
- // Custom variant for "confirm" button
253
- confirmVariant?: Variant,
254
- // True if modal should be on top of other modals
255
- onTopOfOtherModals?: boolean,
256
- };
257
-
258
- /*------------------------------------------------------------------------*/
259
- /* Component */
260
- /*------------------------------------------------------------------------*/
261
-
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) => {
271
- /*------------------------------------------------------------------------*/
272
- /* Setup */
273
- /*------------------------------------------------------------------------*/
274
-
275
- /* -------------- Props ------------- */
276
-
277
- const {
278
- type = ModalType.NoButtons,
279
- size = ModalSize.Large,
280
- title,
281
- children,
282
- onClose,
283
- dontAllowBackdropExit,
284
- onTopOfOtherModals,
285
- } = props;
286
-
287
- /* -------------- State ------------- */
288
-
289
- // If true, the modal is shown
290
- const [visible, setVisible] = useState(false);
291
-
292
- // True if currently animating in
293
- const [animatingIn, setAnimatingIn] = useState(false);
294
-
295
- /*------------------------------------------------------------------------*/
296
- /* Lifecycle Functions */
297
- /*------------------------------------------------------------------------*/
298
-
299
- /**
300
- * Mount
301
- * @author Gabe Abrams
302
- */
303
- useEffect(
304
- () => {
305
- (async () => {
306
- // Start the component animating in
307
- await waitMs(MS_ANIMATE_IN_DELAY);
308
- setAnimatingIn(true);
309
-
310
- // Wait and then set visible to true
311
- await waitMs(MS_TO_ANIMATE);
312
- setVisible(true);
313
- })();
314
- },
315
- [],
316
- );
317
-
318
- /*------------------------------------------------------------------------*/
319
- /* Component Functions */
320
- /*------------------------------------------------------------------------*/
321
-
322
- /**
323
- * Handles the closing of the modal
324
- * @author Gabe Abrams
325
- * @param buttonType the button that was clicked when closing the
326
- * modal
327
- */
328
- const handleClose = async (buttonType: ButtonType) => {
329
- // Don't close if no handler
330
- if (!onClose) {
331
- return;
332
- }
333
-
334
- // Don't close if animating in
335
- if (animatingIn) {
336
- return;
337
- }
338
-
339
- // Don't close if already closed
340
- if (!visible) {
341
- return;
342
- }
343
-
344
- // Update the state
345
- setVisible(false);
346
-
347
- // Call the handler after the modal has animated out
348
- await waitMs(MS_TO_ANIMATE);
349
- onClose(buttonType);
350
- };
351
-
352
- /*------------------------------------------------------------------------*/
353
- /* Render */
354
- /*------------------------------------------------------------------------*/
355
-
356
- /*----------------------------------------*/
357
- /* Footer */
358
- /*----------------------------------------*/
359
-
360
- // Get list of buttons for this modal type
361
- const buttonTypes: ButtonType[] = modalTypeToButtonTypes[type] ?? [];
362
-
363
- // Create buttons
364
- const buttons = buttonTypes.map((buttonType: ButtonType, i) => {
365
- // Get default style
366
- let {
367
- label,
368
- variant,
369
- } = buttonTypeToLabelAndVariant[buttonType];
370
-
371
- // Override with customizations
372
- if (props[`${buttonType}Label`]) {
373
- label = props[`${buttonType}Label`];
374
- }
375
- if (props[`${buttonType}Variant`]) {
376
- variant = props[`${buttonType}Variant`];
377
- }
378
-
379
- // Check if this button is last
380
- const last = (i === buttonTypes.length - 1);
381
-
382
- // Create the button
383
- return (
384
- <button
385
- type="button"
386
- className={`Modal-${buttonType}-button btn btn-${variant} ${last ? '' : 'mr-1'}`}
387
- onClick={() => {
388
- handleClose(buttonType);
389
- }}
390
- >
391
- {label}
392
- </button>
393
- );
394
- });
395
-
396
- // Put all buttons in a footer
397
- const footer = (
398
- (buttons && buttons.length)
399
- ? (
400
- <div>
401
- {buttons}
402
- </div>
403
- )
404
- : undefined
405
- );
406
-
407
- // Render the modal
408
- return (
409
- <BootstrapModal
410
- show={visible}
411
- size={size !== ModalSize.Medium ? size : undefined}
412
- onHide={() => {
413
- if (!dontAllowBackdropExit) {
414
- handleClose(ButtonType.Cancel);
415
- }
416
- }}
417
- style={{
418
- zIndex: (
419
- onTopOfOtherModals
420
- ? 6000000000
421
- : 5000000000
422
- ),
423
- }}
424
- backdropClassName="Modal-backdrop"
425
- centered
426
- >
427
- <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>
448
- );
449
- };
450
-
451
- /*------------------------------------------------------------------------*/
452
- /* Wrap Up */
453
- /*------------------------------------------------------------------------*/
454
-
455
- // Add enums
456
- Modal.ModalType = ModalType;
457
- Modal.ModalSize = ModalSize;
458
- Modal.ButtonType = ButtonType;
459
- Modal.Variant = Variant;
460
-
461
- export default Modal;
@@ -1,136 +0,0 @@
1
- /**
2
- * A box with a tab on the top that holds buttons and other content
3
- * @author Gabe Abrams
4
- */
5
-
6
- // Import React
7
- import React from 'react';
8
-
9
- /*------------------------------------------------------------------------*/
10
- /* Types */
11
- /*------------------------------------------------------------------------*/
12
-
13
- type Props = {
14
- // Title of the box
15
- title: React.ReactNode,
16
- // Children/contents inside the box
17
- children: React.ReactNode,
18
- };
19
-
20
- /*------------------------------------------------------------------------*/
21
- /* Style */
22
- /*------------------------------------------------------------------------*/
23
-
24
- const style = `
25
- /* Tab Box */
26
- .TabBox-box {
27
- /* Light Border */
28
- border: 2px solid #dedede;
29
-
30
- /* Rounded Corners (except top-left) */
31
- border-bottom-right-radius: 5px;
32
- border-bottom-left-radius: 5px;
33
- border-top-right-radius: 5px;
34
-
35
- /* Very Light Gray Border */
36
- background: #fdfdfd;
37
-
38
- /* Align Contents on Left */
39
- text-align: left;
40
- }
41
-
42
- /* Container for Title */
43
- .TabBox-title-container {
44
- /* Place on Left */
45
- position: relative;
46
- left: 0;
47
- text-align: left;
48
- }
49
-
50
- /* Tab-style Title */
51
- .TabBox-title {
52
- /* Place so it Barely Overlaps the Box Border */
53
- display: inline-block;
54
- position: relative;
55
- top: 2px; /* Gives Illusion that Border Doesn't Exist Below Tab */
56
-
57
- /* Title-sized Font */
58
- font-size: 25px;
59
-
60
- /* Add Border on Top and Sides */
61
- border-top: 2px solid #dedede;
62
- border-left: 2px solid #dedede;
63
- border-right: 2px solid #dedede;
64
-
65
- /* Round the Top Corners */
66
- border-top-left-radius: 5px;
67
- border-top-right-radius: 5px;
68
-
69
- /* Add Text Padding */
70
- padding-left: 12px;
71
- padding-right: 12px;
72
-
73
- /* Match Background Color of Box */
74
- background: #fdfdfd;
75
- }
76
-
77
- /* Make the TabBox's Children Appear Above Title if Overlap Occurs */
78
- .TabBox-children {
79
- position: relative;
80
- z-index: 1;
81
- }
82
- `;
83
-
84
- /*------------------------------------------------------------------------*/
85
- /* Component */
86
- /*------------------------------------------------------------------------*/
87
-
88
- const TabBox: React.FC<Props> = (props) => {
89
- /*------------------------------------------------------------------------*/
90
- /* Setup */
91
- /*------------------------------------------------------------------------*/
92
-
93
- /* -------------- Props ------------- */
94
-
95
- const {
96
- title,
97
- children,
98
- } = props;
99
-
100
- /*------------------------------------------------------------------------*/
101
- /* Render */
102
- /*------------------------------------------------------------------------*/
103
-
104
- /*----------------------------------------*/
105
- /* Main UI */
106
- /*----------------------------------------*/
107
-
108
- // Full UI
109
- return (
110
- <div>
111
- {/* Style */}
112
- <style>{style}</style>
113
-
114
- {/* Title */}
115
- <div className="TabBox-title-container">
116
- <div className="TabBox-title">
117
- {title}
118
- </div>
119
- </div>
120
-
121
- {/* Contents */}
122
- <div className="TabBox-box p-2">
123
- <div className="TabBox-children">
124
- {children}
125
- </div>
126
- </div>
127
- </div>
128
- );
129
- };
130
-
131
- /*------------------------------------------------------------------------*/
132
- /* Wrap Up */
133
- /*------------------------------------------------------------------------*/
134
-
135
- // Export component
136
- export default TabBox;
@@ -1,15 +0,0 @@
1
- /**
2
- * An error with a code
3
- * @author Gabe Abrams
4
- */
5
- class ErrorWithCode extends Error {
6
- code: string;
7
-
8
- constructor(message: string, code: string) {
9
- super(message);
10
- this.name = 'ErrorWithCode';
11
- this.code = code;
12
- }
13
- }
14
-
15
- export default ErrorWithCode;
@@ -1,23 +0,0 @@
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
- };
@@ -1,5 +0,0 @@
1
- import { _alert } from '../components/AppWrapper';
2
-
3
- const alert = _alert;
4
-
5
- export default alert;
@@ -1,22 +0,0 @@
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;
@@ -1,5 +0,0 @@
1
- import { _confirm } from '../components/AppWrapper';
2
-
3
- const confirm = _confirm;
4
-
5
- export default confirm;