dce-reactkit 2.0.10 → 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 (122) hide show
  1. package/dist/cjs/index.js +36424 -0
  2. package/dist/cjs/index.js.map +1 -0
  3. package/dist/cjs/types/components/AppWrapper.d.ts +40 -0
  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/dist/cjs/types/components/Modal.d.ts +40 -0
  7. package/dist/cjs/types/components/TabBox.d.ts +11 -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.d.ts +0 -20
  53. package/lib/components/AppWrapper.js +0 -133
  54. package/lib/components/AppWrapper.js.map +0 -1
  55. package/lib/components/ErrorBox.js +0 -65
  56. package/lib/components/ErrorBox.js.map +0 -1
  57. package/lib/components/LoadingSpinner.js +0 -41
  58. package/lib/components/LoadingSpinner.js.map +0 -1
  59. package/lib/components/Modal.d.ts +0 -69
  60. package/lib/components/Modal.js +0 -315
  61. package/lib/components/Modal.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/avg.js +0 -24
  67. package/lib/helpers/avg.js.map +0 -1
  68. package/lib/helpers/ceilToNumDecimals.js +0 -15
  69. package/lib/helpers/ceilToNumDecimals.js.map +0 -1
  70. package/lib/helpers/floorToNumDecimals.js +0 -15
  71. package/lib/helpers/floorToNumDecimals.js.map +0 -1
  72. package/lib/helpers/forceNumIntoBounds.js +0 -15
  73. package/lib/helpers/forceNumIntoBounds.js.map +0 -1
  74. package/lib/helpers/handleError.d.ts +0 -14
  75. package/lib/helpers/handleError.js +0 -54
  76. package/lib/helpers/handleError.js.map +0 -1
  77. package/lib/helpers/handleSuccess.d.ts +0 -8
  78. package/lib/helpers/handleSuccess.js +0 -20
  79. package/lib/helpers/handleSuccess.js.map +0 -1
  80. package/lib/helpers/padDecimalZeros.js +0 -30
  81. package/lib/helpers/padDecimalZeros.js.map +0 -1
  82. package/lib/helpers/padZerosLeft.js +0 -21
  83. package/lib/helpers/padZerosLeft.js.map +0 -1
  84. package/lib/helpers/parseRequest.d.ts +0 -21
  85. package/lib/helpers/parseRequest.js +0 -240
  86. package/lib/helpers/parseRequest.js.map +0 -1
  87. package/lib/helpers/roundToNumDecimals.js +0 -15
  88. package/lib/helpers/roundToNumDecimals.js.map +0 -1
  89. package/lib/helpers/showFatalError.d.ts +0 -2
  90. package/lib/helpers/showFatalError.js +0 -5
  91. package/lib/helpers/showFatalError.js.map +0 -1
  92. package/lib/helpers/sum.js +0 -15
  93. package/lib/helpers/sum.js.map +0 -1
  94. package/lib/helpers/visitServerEndpoint.d.ts +0 -23
  95. package/lib/helpers/visitServerEndpoint.js +0 -135
  96. package/lib/helpers/visitServerEndpoint.js.map +0 -1
  97. package/lib/helpers/waitMs.js +0 -55
  98. package/lib/helpers/waitMs.js.map +0 -1
  99. package/lib/types/ParamType.d.ts +0 -17
  100. package/lib/types/ParamType.js +0 -21
  101. package/lib/types/ParamType.js.map +0 -1
  102. package/lib/types/ReactKitErrorCode.js +0 -18
  103. package/lib/types/ReactKitErrorCode.js.map +0 -1
  104. package/lib/types/Variant.js +0 -19
  105. package/lib/types/Variant.js.map +0 -1
  106. package/src/components/AppWrapper.tsx +0 -189
  107. package/src/components/ErrorBox.tsx +0 -124
  108. package/src/components/LoadingSpinner.tsx +0 -105
  109. package/src/components/Modal.tsx +0 -447
  110. package/src/errors/ErrorWithCode.tsx +0 -15
  111. package/src/helpers/abbreviate.tsx +0 -23
  112. package/src/helpers/avg.tsx +0 -22
  113. package/src/helpers/handleError.ts +0 -65
  114. package/src/helpers/handleSuccess.ts +0 -18
  115. package/src/helpers/padDecimalZeros.tsx +0 -32
  116. package/src/helpers/parseRequest.ts +0 -299
  117. package/src/helpers/showFatalError.tsx +0 -3
  118. package/src/helpers/visitServerEndpoint.tsx +0 -110
  119. package/src/types/ParamType.ts +0 -18
  120. package/src/types/ReactKitErrorCode.tsx +0 -16
  121. package/src/types/Variant.tsx +0 -16
  122. package/tsconfig.json +0 -24
@@ -0,0 +1,40 @@
1
+ /**
2
+ * A wrapper for the entire React app that adds global functionality like
3
+ * handling for fatal error messages
4
+ * @author Gabe Abrams
5
+ */
6
+ import React from 'react';
7
+ declare type Props = {
8
+ children: React.ReactNode;
9
+ dark?: boolean;
10
+ sessionExpiredMessage?: string;
11
+ };
12
+ /**
13
+ * Show an alert modal with an "Okay" button
14
+ * @author Gabe Abrams
15
+ * @param title the title text to display at the top of the alert
16
+ * @param text the text to display in the alert
17
+ */
18
+ export declare const alert: (title: string, text: string) => Promise<undefined>;
19
+ /**
20
+ * Show a confirmation modal with an "Okay" and a "Cancel" button
21
+ * @author Gabe Abrams
22
+ * @param title the title text to display at the top of the alert
23
+ * @param text the text to display in the alert
24
+ * @returns true if the user confirmed
25
+ */
26
+ export declare const confirm: (title: string, text: string) => Promise<boolean>;
27
+ /**
28
+ * Show a fatal error message
29
+ * @author Gabe Abrams
30
+ * @param error the error to show
31
+ * @param [errorTitle] title of the error box
32
+ */
33
+ export declare const showFatalError: (error: any, errorTitle?: string) => undefined;
34
+ /**
35
+ * Show the "session expired" message
36
+ * @author Gabe Abrams
37
+ */
38
+ export declare const showSessionExpiredMessage: () => undefined;
39
+ declare const AppWrapper: React.FC<Props>;
40
+ export default AppWrapper;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Displays an error
3
+ * @author Gabe Abrams
4
+ */
5
+ import React from 'react';
6
+ declare type Props = {
7
+ error: any;
8
+ title?: string;
9
+ onClose?: () => void;
10
+ };
11
+ declare const ErrorBox: React.FC<Props>;
12
+ export default ErrorBox;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Loading spinner/indicator
3
+ * @author Gabe Abrams
4
+ */
5
+ /// <reference types="react" />
6
+ declare const LoadingSpinner: () => JSX.Element;
7
+ export default LoadingSpinner;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * A generic popup modal
3
+ * @author Gabe Abrams
4
+ */
5
+ import React from 'react';
6
+ import Variant from '../types/Variant';
7
+ import ModalButtonType from '../types/ModalButtonType';
8
+ import ModalSize from '../types/ModalSize';
9
+ import ModalType from '../types/ModalType';
10
+ declare type Props = {
11
+ type?: ModalType;
12
+ size?: ModalSize;
13
+ title?: React.ReactNode;
14
+ children?: React.ReactNode;
15
+ onClose?: (type: ModalButtonType) => void;
16
+ dontAllowBackdropExit?: boolean;
17
+ okayLabel?: string;
18
+ okayVariant?: Variant;
19
+ cancelLabel?: string;
20
+ cancelVariant?: Variant;
21
+ yesLabel?: string;
22
+ yesVariant?: Variant;
23
+ noLabel?: string;
24
+ noVariant?: Variant;
25
+ abandonLabel?: string;
26
+ abandonVariant?: Variant;
27
+ goBackLabel?: string;
28
+ goBackVariant?: Variant;
29
+ continueLabel?: string;
30
+ continueVariant?: Variant;
31
+ imSureLabel?: string;
32
+ imSureVariant?: Variant;
33
+ deleteLabel?: string;
34
+ deleteVariant?: Variant;
35
+ confirmLabel?: string;
36
+ confirmVariant?: Variant;
37
+ onTopOfOtherModals?: boolean;
38
+ };
39
+ declare const Modal: React.FC<Props>;
40
+ export default Modal;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A box with a tab on the top that holds buttons and other content
3
+ * @author Gabe Abrams
4
+ */
5
+ import React from 'react';
6
+ declare type Props = {
7
+ title: React.ReactNode;
8
+ children: React.ReactNode;
9
+ };
10
+ declare const TabBox: React.FC<Props>;
11
+ export default TabBox;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * An error with a code
3
+ * @author Gabe Abrams
4
+ */
5
+ declare class ErrorWithCode extends Error {
6
+ code: string;
7
+ constructor(message: string, code: string);
8
+ }
9
+ export default ErrorWithCode;
@@ -0,0 +1,10 @@
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
+ declare const abbreviate: (text: string, maxChars: number) => string;
10
+ export default abbreviate;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Get the average of a set of numbers
3
+ * @author Gabe Abrams
4
+ * @param nums the numbers to average
5
+ * @returns average value or 0 if no numbers
6
+ */
7
+ declare const avg: (nums: number[]) => number;
8
+ export default avg;
@@ -5,9 +5,5 @@
5
5
  * @param numDecimals the number of decimals to round to
6
6
  * @returns rounded number
7
7
  */
8
- const ceilToNumDecimals = (num: number, numDecimals: number): number => {
9
- const rounder = 10 ** numDecimals;
10
- return (Math.ceil(num * rounder) / rounder);
11
- };
12
-
8
+ declare const ceilToNumDecimals: (num: number, numDecimals: number) => number;
13
9
  export default ceilToNumDecimals;
@@ -5,9 +5,5 @@
5
5
  * @param numDecimals the number of decimals to round to
6
6
  * @returns rounded number
7
7
  */
8
- const floorToNumDecimals = (num: number, numDecimals: number): number => {
9
- const rounder = 10 ** numDecimals;
10
- return (Math.floor(num * rounder) / rounder);
11
- };
12
-
8
+ declare const floorToNumDecimals: (num: number, numDecimals: number) => number;
13
9
  export default floorToNumDecimals;
@@ -6,14 +6,5 @@
6
6
  * @param max the maximum number in the bound
7
7
  * @returns bounded number
8
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
-
9
+ declare const forceNumIntoBounds: (num: number, min: number, max: number) => number;
19
10
  export default forceNumIntoBounds;
@@ -0,0 +1,10 @@
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
+ declare const padDecimalZeros: (num: number, numDigits: number) => string;
10
+ export default padDecimalZeros;
@@ -5,17 +5,5 @@
5
5
  * @param numDigits the minimum number of digits before the decimal
6
6
  * @returns padded number
7
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
-
8
+ declare const padZerosLeft: (num: number, numDigits: number) => string;
21
9
  export default padZerosLeft;
@@ -5,9 +5,5 @@
5
5
  * @param numDecimals the number of decimals to round to
6
6
  * @returns rounded number
7
7
  */
8
- const roundToNumDecimals = (num: number, numDecimals: number): number => {
9
- const rounder = 10 ** numDecimals;
10
- return (Math.round(num * rounder) / rounder);
11
- };
12
-
8
+ declare const roundToNumDecimals: (num: number, numDecimals: number) => number;
13
9
  export default roundToNumDecimals;
@@ -4,13 +4,5 @@
4
4
  * @param nums the numbers to sum
5
5
  * @returns the sum of the numbers
6
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
-
7
+ declare const sum: (nums: number[]) => number;
16
8
  export default sum;
@@ -3,10 +3,5 @@
3
3
  * @author Gabe Abrams
4
4
  * @param ms number of ms to wait
5
5
  */
6
- const waitMs = async (ms = 0) => {
7
- return new Promise((resolve) => {
8
- setTimeout(resolve, ms);
9
- });
10
- };
11
-
6
+ declare const waitMs: (ms?: number) => Promise<unknown>;
12
7
  export default waitMs;
@@ -0,0 +1,22 @@
1
+ import AppWrapper, { alert, confirm, showFatalError } from './components/AppWrapper';
2
+ import LoadingSpinner from './components/LoadingSpinner';
3
+ import ErrorBox from './components/ErrorBox';
4
+ import Modal from './components/Modal';
5
+ import TabBox from './components/TabBox';
6
+ import ErrorWithCode from './errors/ErrorWithCode';
7
+ import abbreviate from './helpers/abbreviate';
8
+ import avg from './helpers/avg';
9
+ import ceilToNumDecimals from './helpers/ceilToNumDecimals';
10
+ import floorToNumDecimals from './helpers/floorToNumDecimals';
11
+ import forceNumIntoBounds from './helpers/forceNumIntoBounds';
12
+ import padDecimalZeros from './helpers/padDecimalZeros';
13
+ import padZerosLeft from './helpers/padZerosLeft';
14
+ import roundToNumDecimals from './helpers/roundToNumDecimals';
15
+ import sum from './helpers/sum';
16
+ import waitMs from './helpers/waitMs';
17
+ import ModalButtonType from './types/ModalButtonType';
18
+ import ModalSize from './types/ModalSize';
19
+ import ModalType from './types/ModalType';
20
+ import ReactKitErrorCode from './types/ReactKitErrorCode';
21
+ import Variant from './types/Variant';
22
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, alert, confirm, showFatalError, ErrorWithCode, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Types of buttons in the modal
3
+ * @author Gabe Abrams
4
+ */
5
+ declare 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
+ export default ModalButtonType;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Modal sizes
3
+ * @author Gabe Abrams
4
+ */
5
+ declare enum ModalSize {
6
+ Small = "sm",
7
+ Medium = "md",
8
+ Large = "lg",
9
+ ExtraLarge = "xl"
10
+ }
11
+ export default ModalSize;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Types of modals
3
+ * @author Gabe Abrams
4
+ */
5
+ declare enum ModalType {
6
+ Okay = "okay",
7
+ OkayCancel = "okay-cancel",
8
+ YesNo = "yes-no",
9
+ YesNoCancel = "yes-no-cancel",
10
+ AbandonGoBack = "abandon-goBack",
11
+ ImSureCancel = "imSure-cancel",
12
+ DeleteCancel = "delete-cancel",
13
+ ConfirmCancel = "confirm-cancel",
14
+ NoButtons = "-"
15
+ }
16
+ export default ModalType;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * List of error codes built into the react kit
3
+ * @author Gabe Abrams
4
+ */
5
+ declare enum ReactKitErrorCode {
6
+ NoResponse = "DRK1",
7
+ NoCode = "DRK2",
8
+ SessionExpired = "DRK3",
9
+ MissingParameter = "DRK4",
10
+ InvalidParameter = "DRK5",
11
+ WrongCourse = "DRK6"
12
+ }
13
+ export default ReactKitErrorCode;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Bootstrap variants
3
+ * @author Gabe Abrams
4
+ */
5
+ declare 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
+ export default Variant;
@@ -0,0 +1,274 @@
1
+ /// <reference types="react" />
2
+ import React from 'react';
3
+
4
+ /**
5
+ * A wrapper for the entire React app that adds global functionality like
6
+ * handling for fatal error messages
7
+ * @author Gabe Abrams
8
+ */
9
+
10
+ declare type Props$3 = {
11
+ children: React.ReactNode;
12
+ dark?: boolean;
13
+ sessionExpiredMessage?: string;
14
+ };
15
+ /**
16
+ * Show an alert modal with an "Okay" button
17
+ * @author Gabe Abrams
18
+ * @param title the title text to display at the top of the alert
19
+ * @param text the text to display in the alert
20
+ */
21
+ declare const alert: (title: string, text: string) => Promise<undefined>;
22
+ /**
23
+ * Show a confirmation modal with an "Okay" and a "Cancel" button
24
+ * @author Gabe Abrams
25
+ * @param title the title text to display at the top of the alert
26
+ * @param text the text to display in the alert
27
+ * @returns true if the user confirmed
28
+ */
29
+ declare const confirm: (title: string, text: string) => Promise<boolean>;
30
+ /**
31
+ * Show a fatal error message
32
+ * @author Gabe Abrams
33
+ * @param error the error to show
34
+ * @param [errorTitle] title of the error box
35
+ */
36
+ declare const showFatalError: (error: any, errorTitle?: string) => undefined;
37
+ declare const AppWrapper: React.FC<Props$3>;
38
+
39
+ /**
40
+ * Loading spinner/indicator
41
+ * @author Gabe Abrams
42
+ */
43
+ declare const LoadingSpinner: () => JSX.Element;
44
+
45
+ /**
46
+ * Displays an error
47
+ * @author Gabe Abrams
48
+ */
49
+
50
+ declare type Props$2 = {
51
+ error: any;
52
+ title?: string;
53
+ onClose?: () => void;
54
+ };
55
+ declare const ErrorBox: React.FC<Props$2>;
56
+
57
+ /**
58
+ * Bootstrap variants
59
+ * @author Gabe Abrams
60
+ */
61
+ declare enum Variant {
62
+ Primary = "primary",
63
+ Secondary = "secondary",
64
+ Success = "success",
65
+ Warning = "warning",
66
+ Info = "info",
67
+ Danger = "danger",
68
+ Light = "light",
69
+ Dark = "dark"
70
+ }
71
+
72
+ /**
73
+ * Types of buttons in the modal
74
+ * @author Gabe Abrams
75
+ */
76
+ declare enum ModalButtonType {
77
+ Okay = "okay",
78
+ Cancel = "cancel",
79
+ Yes = "yes",
80
+ No = "no",
81
+ Abandon = "abandon",
82
+ GoBack = "goBack",
83
+ Continue = "continue",
84
+ ImSure = "imSure",
85
+ Delete = "delete",
86
+ Confirm = "confirm"
87
+ }
88
+
89
+ /**
90
+ * Modal sizes
91
+ * @author Gabe Abrams
92
+ */
93
+ declare enum ModalSize {
94
+ Small = "sm",
95
+ Medium = "md",
96
+ Large = "lg",
97
+ ExtraLarge = "xl"
98
+ }
99
+
100
+ /**
101
+ * Types of modals
102
+ * @author Gabe Abrams
103
+ */
104
+ declare enum ModalType {
105
+ Okay = "okay",
106
+ OkayCancel = "okay-cancel",
107
+ YesNo = "yes-no",
108
+ YesNoCancel = "yes-no-cancel",
109
+ AbandonGoBack = "abandon-goBack",
110
+ ImSureCancel = "imSure-cancel",
111
+ DeleteCancel = "delete-cancel",
112
+ ConfirmCancel = "confirm-cancel",
113
+ NoButtons = "-"
114
+ }
115
+
116
+ /**
117
+ * A generic popup modal
118
+ * @author Gabe Abrams
119
+ */
120
+
121
+ declare type Props$1 = {
122
+ type?: ModalType;
123
+ size?: ModalSize;
124
+ title?: React.ReactNode;
125
+ children?: React.ReactNode;
126
+ onClose?: (type: ModalButtonType) => void;
127
+ dontAllowBackdropExit?: boolean;
128
+ okayLabel?: string;
129
+ okayVariant?: Variant;
130
+ cancelLabel?: string;
131
+ cancelVariant?: Variant;
132
+ yesLabel?: string;
133
+ yesVariant?: Variant;
134
+ noLabel?: string;
135
+ noVariant?: Variant;
136
+ abandonLabel?: string;
137
+ abandonVariant?: Variant;
138
+ goBackLabel?: string;
139
+ goBackVariant?: Variant;
140
+ continueLabel?: string;
141
+ continueVariant?: Variant;
142
+ imSureLabel?: string;
143
+ imSureVariant?: Variant;
144
+ deleteLabel?: string;
145
+ deleteVariant?: Variant;
146
+ confirmLabel?: string;
147
+ confirmVariant?: Variant;
148
+ onTopOfOtherModals?: boolean;
149
+ };
150
+ declare const Modal: React.FC<Props$1>;
151
+
152
+ /**
153
+ * A box with a tab on the top that holds buttons and other content
154
+ * @author Gabe Abrams
155
+ */
156
+
157
+ declare type Props = {
158
+ title: React.ReactNode;
159
+ children: React.ReactNode;
160
+ };
161
+ declare const TabBox: React.FC<Props>;
162
+
163
+ /**
164
+ * An error with a code
165
+ * @author Gabe Abrams
166
+ */
167
+ declare class ErrorWithCode extends Error {
168
+ code: string;
169
+ constructor(message: string, code: string);
170
+ }
171
+
172
+ /**
173
+ * Shorten text so it fits into a certain number of chars
174
+ * @author Gabe Abrams
175
+ * @param text the text to abbreviate
176
+ * @param maxChars the maximum number of chars to include
177
+ * @returns abbreviated text with length no greater than maxChars
178
+ * (including ellipses if applicable)
179
+ */
180
+ declare const abbreviate: (text: string, maxChars: number) => string;
181
+
182
+ /**
183
+ * Get the average of a set of numbers
184
+ * @author Gabe Abrams
185
+ * @param nums the numbers to average
186
+ * @returns average value or 0 if no numbers
187
+ */
188
+ declare const avg: (nums: number[]) => number;
189
+
190
+ /**
191
+ * Round a number (ceiling) to a certain number of decimals
192
+ * @author Gabe Abrams
193
+ * @param num the number to round
194
+ * @param numDecimals the number of decimals to round to
195
+ * @returns rounded number
196
+ */
197
+ declare const ceilToNumDecimals: (num: number, numDecimals: number) => number;
198
+
199
+ /**
200
+ * Round a number (floor) to a certain number of decimals
201
+ * @author Gabe Abrams
202
+ * @param num the number to round
203
+ * @param numDecimals the number of decimals to round to
204
+ * @returns rounded number
205
+ */
206
+ declare const floorToNumDecimals: (num: number, numDecimals: number) => number;
207
+
208
+ /**
209
+ * Force a number to stay within specific bounds
210
+ * @author Gabe Abrams
211
+ * @param num the number to move into the bounds
212
+ * @param min the minimum number in the bound
213
+ * @param max the maximum number in the bound
214
+ * @returns bounded number
215
+ */
216
+ declare const forceNumIntoBounds: (num: number, min: number, max: number) => number;
217
+
218
+ /**
219
+ * Pad a number's decimal with zeros on the right
220
+ * (e.g. 5.2 becomes 5.20 with 2 digit padding)
221
+ * @author Gabe Abrams
222
+ * @param num the number to pad
223
+ * @param numDigits the minimum number of digits after the decimal
224
+ * @returns padded number
225
+ */
226
+ declare const padDecimalZeros: (num: number, numDigits: number) => string;
227
+
228
+ /**
229
+ * Pad a number with zeros on the left (e.g. 5 becomes 05 with 2 digit padding)
230
+ * @author Gabe Abrams
231
+ * @param num the number to pad
232
+ * @param numDigits the minimum number of digits before the decimal
233
+ * @returns padded number
234
+ */
235
+ declare const padZerosLeft: (num: number, numDigits: number) => string;
236
+
237
+ /**
238
+ * Round a number to a certain number of decimals
239
+ * @author Gabe Abrams
240
+ * @param num the number to round
241
+ * @param numDecimals the number of decimals to round to
242
+ * @returns rounded number
243
+ */
244
+ declare const roundToNumDecimals: (num: number, numDecimals: number) => number;
245
+
246
+ /**
247
+ * Sum the numbers in an array
248
+ * @author Gabe Abrams
249
+ * @param nums the numbers to sum
250
+ * @returns the sum of the numbers
251
+ */
252
+ declare const sum: (nums: number[]) => number;
253
+
254
+ /**
255
+ * Wait for a certain number of ms
256
+ * @author Gabe Abrams
257
+ * @param ms number of ms to wait
258
+ */
259
+ declare const waitMs: (ms?: number) => Promise<unknown>;
260
+
261
+ /**
262
+ * List of error codes built into the react kit
263
+ * @author Gabe Abrams
264
+ */
265
+ declare enum ReactKitErrorCode {
266
+ NoResponse = "DRK1",
267
+ NoCode = "DRK2",
268
+ SessionExpired = "DRK3",
269
+ MissingParameter = "DRK4",
270
+ InvalidParameter = "DRK5",
271
+ WrongCourse = "DRK6"
272
+ }
273
+
274
+ export { AppWrapper, ErrorBox, ErrorWithCode, LoadingSpinner, Modal, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, TabBox, Variant, abbreviate, alert, avg, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, showFatalError, sum, waitMs };