dce-reactkit 2.0.11 → 3.0.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 (194) 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 +2 -2
  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/cjs/types/helpers/alert.d.ts +2 -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/cjs/types/helpers/confirm.d.ts +2 -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/cjs/types/helpers/showFatalError.d.ts +2 -0
  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 +37 -36
  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.d.ts +0 -2
  147. package/lib/helpers/alert.js +0 -5
  148. package/lib/helpers/alert.js.map +0 -1
  149. package/lib/helpers/avg.js +0 -24
  150. package/lib/helpers/avg.js.map +0 -1
  151. package/lib/helpers/ceilToNumDecimals.js +0 -15
  152. package/lib/helpers/ceilToNumDecimals.js.map +0 -1
  153. package/lib/helpers/confirm.d.ts +0 -2
  154. package/lib/helpers/confirm.js +0 -5
  155. package/lib/helpers/confirm.js.map +0 -1
  156. package/lib/helpers/floorToNumDecimals.js +0 -15
  157. package/lib/helpers/floorToNumDecimals.js.map +0 -1
  158. package/lib/helpers/forceNumIntoBounds.js +0 -15
  159. package/lib/helpers/forceNumIntoBounds.js.map +0 -1
  160. package/lib/helpers/handleError.js +0 -54
  161. package/lib/helpers/handleError.js.map +0 -1
  162. package/lib/helpers/handleSuccess.js +0 -20
  163. package/lib/helpers/handleSuccess.js.map +0 -1
  164. package/lib/helpers/padDecimalZeros.js +0 -30
  165. package/lib/helpers/padDecimalZeros.js.map +0 -1
  166. package/lib/helpers/padZerosLeft.js +0 -21
  167. package/lib/helpers/padZerosLeft.js.map +0 -1
  168. package/lib/helpers/parseRequest.js +0 -240
  169. package/lib/helpers/parseRequest.js.map +0 -1
  170. package/lib/helpers/roundToNumDecimals.js +0 -15
  171. package/lib/helpers/roundToNumDecimals.js.map +0 -1
  172. package/lib/helpers/showFatalError.d.ts +0 -2
  173. package/lib/helpers/showFatalError.js +0 -5
  174. package/lib/helpers/showFatalError.js.map +0 -1
  175. package/lib/helpers/sum.js +0 -15
  176. package/lib/helpers/sum.js.map +0 -1
  177. package/lib/helpers/visitServerEndpoint.js +0 -135
  178. package/lib/helpers/visitServerEndpoint.js.map +0 -1
  179. package/lib/helpers/waitMs.js +0 -55
  180. package/lib/helpers/waitMs.js.map +0 -1
  181. package/lib/types/ParamType.js +0 -21
  182. package/lib/types/ParamType.js.map +0 -1
  183. package/lib/types/ReactKitErrorCode.js +0 -18
  184. package/lib/types/ReactKitErrorCode.js.map +0 -1
  185. package/lib/types/Variant.js +0 -19
  186. package/lib/types/Variant.js.map +0 -1
  187. package/src/helpers/alert.tsx +0 -3
  188. package/src/helpers/confirm.tsx +0 -3
  189. package/src/helpers/handleError.ts +0 -65
  190. package/src/helpers/handleSuccess.ts +0 -18
  191. package/src/helpers/parseRequest.ts +0 -299
  192. package/src/helpers/showFatalError.tsx +0 -3
  193. package/src/helpers/visitServerEndpoint.tsx +0 -110
  194. package/src/types/ParamType.ts +0 -18
@@ -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,17 @@
1
+ /**
2
+ * API param types
3
+ * @author Gabe Abrams
4
+ */
5
+ declare enum ParamType {
6
+ Boolean = "boolean",
7
+ BooleanOptional = "boolean-optional",
8
+ Float = "float",
9
+ FloatOptional = "float-optional",
10
+ Int = "int",
11
+ IntOptional = "int-optional",
12
+ JSON = "json",
13
+ JSONOptional = "json-optional",
14
+ String = "string",
15
+ StringOptional = "string-optional"
16
+ }
17
+ export default ParamType;
@@ -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,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,2 @@
1
+ declare const alert: (title: string, text: string) => Promise<unknown>;
2
+ export default alert;
@@ -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;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Round a number (ceiling) to a certain number of decimals
3
+ * @author Gabe Abrams
4
+ * @param num the number to round
5
+ * @param numDecimals the number of decimals to round to
6
+ * @returns rounded number
7
+ */
8
+ declare const ceilToNumDecimals: (num: number, numDecimals: number) => number;
9
+ export default ceilToNumDecimals;
@@ -0,0 +1,2 @@
1
+ declare const confirm: (title: string, text: string) => Promise<boolean>;
2
+ export default confirm;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Round a number (floor) to a certain number of decimals
3
+ * @author Gabe Abrams
4
+ * @param num the number to round
5
+ * @param numDecimals the number of decimals to round to
6
+ * @returns rounded number
7
+ */
8
+ declare const floorToNumDecimals: (num: number, numDecimals: number) => number;
9
+ export default floorToNumDecimals;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Force a number to stay within specific bounds
3
+ * @author Gabe Abrams
4
+ * @param num the number to move into the bounds
5
+ * @param min the minimum number in the bound
6
+ * @param max the maximum number in the bound
7
+ * @returns bounded number
8
+ */
9
+ declare const forceNumIntoBounds: (num: number, min: number, max: number) => number;
10
+ export default forceNumIntoBounds;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Handle an error and respond to the client
3
+ * @author Gabe Abrams
4
+ * @param res express response
5
+ * @param error error info
6
+ * @param opts.err the error to send to the client
7
+ * or the error message
8
+ * @param [opts.code] an error code (only used if err.code is not
9
+ * included)
10
+ * @param [opts.status=500] the https status code to use
11
+ * defined)
12
+ */
13
+ declare const handleError: (res: any, error: any) => undefined;
14
+ export default handleError;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Send successful API response
3
+ * @author Gabe Abrams
4
+ * @param res express response
5
+ * @param body the body of the response to send to the client
6
+ */
7
+ declare const handleSuccess: (res: any, body: any) => undefined;
8
+ export default handleSuccess;
@@ -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;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Pad a number with zeros on the left (e.g. 5 becomes 05 with 2 digit padding)
3
+ * @author Gabe Abrams
4
+ * @param num the number to pad
5
+ * @param numDigits the minimum number of digits before the decimal
6
+ * @returns padded number
7
+ */
8
+ declare const padZerosLeft: (num: number, numDigits: number) => string;
9
+ export default padZerosLeft;
@@ -0,0 +1,21 @@
1
+ import ParamType from '../types/ParamType';
2
+ /**
3
+ * Parse express request params and body
4
+ * @author Gabe Abrams
5
+ * @param opts object containing all arguments
6
+ * @param opts.req express request instance
7
+ * @param opts.res express response instance
8
+ * @param opts.params map of parameters that should be parsed out of the request
9
+ * @returns parsed params + user info from session (if it exists) or undefined
10
+ * if an error occurred
11
+ */
12
+ declare const parseRequest: (opts: {
13
+ req: any;
14
+ res: any;
15
+ params: {
16
+ [x: string]: ParamType;
17
+ };
18
+ }) => {
19
+ [x: string]: any;
20
+ } | undefined;
21
+ export default parseRequest;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Round a number to a certain number of decimals
3
+ * @author Gabe Abrams
4
+ * @param num the number to round
5
+ * @param numDecimals the number of decimals to round to
6
+ * @returns rounded number
7
+ */
8
+ declare const roundToNumDecimals: (num: number, numDecimals: number) => number;
9
+ export default roundToNumDecimals;
@@ -0,0 +1,2 @@
1
+ declare const showFatalError: (error: any, errorTitle?: string) => Promise<unknown> | undefined;
2
+ export default showFatalError;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Sum the numbers in an array
3
+ * @author Gabe Abrams
4
+ * @param nums the numbers to sum
5
+ * @returns the sum of the numbers
6
+ */
7
+ declare const sum: (nums: number[]) => number;
8
+ export default sum;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Set the session expiry handler
3
+ * @author Gabe Abrams
4
+ * @param handler new handler to use when session expires
5
+ */
6
+ export declare const setSessionExpiryHandler: (handler: () => void) => void;
7
+ /**
8
+ * Visit an endpoint on the server [for client only]
9
+ * @author Gabe Abrams
10
+ * @param opts object containing all arguments
11
+ * @param opts.path - the path of the server endpoint
12
+ * @param [opts.method=GET] - the method of the endpoint
13
+ * @param [opts.params] - query/body parameters to include
14
+ * @returns response from server
15
+ */
16
+ declare const visitServerEndpoint: (opts: {
17
+ path: string;
18
+ method?: "GET" | "POST" | "DELETE" | "PUT" | undefined;
19
+ params?: {
20
+ [x: string]: any;
21
+ } | undefined;
22
+ }) => Promise<any>;
23
+ export default visitServerEndpoint;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Wait for a certain number of ms
3
+ * @author Gabe Abrams
4
+ * @param ms number of ms to wait
5
+ */
6
+ declare const waitMs: (ms?: number) => Promise<unknown>;
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,17 @@
1
+ /**
2
+ * API param types
3
+ * @author Gabe Abrams
4
+ */
5
+ declare enum ParamType {
6
+ Boolean = "boolean",
7
+ BooleanOptional = "boolean-optional",
8
+ Float = "float",
9
+ FloatOptional = "float-optional",
10
+ Int = "int",
11
+ IntOptional = "int-optional",
12
+ JSON = "json",
13
+ JSONOptional = "json-optional",
14
+ String = "string",
15
+ StringOptional = "string-optional"
16
+ }
17
+ export default ParamType;
@@ -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;