dce-reactkit 3.0.1 → 3.0.2

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 (162) hide show
  1. package/README.md +1 -546
  2. package/dist/cjs/index.js +1782 -0
  3. package/dist/cjs/index.js.map +1 -0
  4. package/{lib/esm → dist/cjs}/types/components/AppWrapper.d.ts +26 -1
  5. package/dist/cjs/types/components/ButtonInputGroup.d.ts +12 -0
  6. package/dist/cjs/types/components/CheckboxButton.d.ts +20 -0
  7. package/{lib/cjs/lib → dist/cjs/types}/components/ErrorBox.d.ts +0 -0
  8. package/{lib/cjs/lib → dist/cjs/types}/components/LoadingSpinner.d.ts +0 -0
  9. package/{lib/cjs/lib → dist/cjs/types}/components/Modal.d.ts +0 -0
  10. package/dist/cjs/types/components/RadioButton.d.ts +20 -0
  11. package/dist/cjs/types/components/SimpleDateChooser.d.ts +22 -0
  12. package/{lib/esm/lib → dist/cjs/types}/components/TabBox.d.ts +1 -0
  13. package/{lib/cjs/lib → dist/cjs/types}/errors/ErrorWithCode.d.ts +0 -0
  14. package/{lib/cjs/lib → dist/cjs/types}/helpers/abbreviate.d.ts +0 -0
  15. package/{lib/cjs/lib → dist/cjs/types}/helpers/avg.d.ts +0 -0
  16. package/{lib/cjs/lib → dist/cjs/types}/helpers/ceilToNumDecimals.d.ts +0 -0
  17. package/{lib/cjs/lib → dist/cjs/types}/helpers/floorToNumDecimals.d.ts +0 -0
  18. package/{lib/cjs/lib → dist/cjs/types}/helpers/forceNumIntoBounds.d.ts +0 -0
  19. package/dist/cjs/types/helpers/genRouteHandler.d.ts +32 -0
  20. package/dist/cjs/types/helpers/getOrdinal.d.ts +8 -0
  21. package/dist/cjs/types/helpers/getTimeInfoInET.d.ts +17 -0
  22. package/{lib/cjs/lib → dist/cjs/types}/helpers/handleError.d.ts +5 -1
  23. package/{lib/cjs/lib → dist/cjs/types}/helpers/handleSuccess.d.ts +0 -0
  24. package/{lib/cjs/lib → dist/cjs/types}/helpers/padDecimalZeros.d.ts +0 -0
  25. package/{lib/cjs/lib → dist/cjs/types}/helpers/padZerosLeft.d.ts +0 -0
  26. package/{lib/cjs/lib → dist/cjs/types}/helpers/roundToNumDecimals.d.ts +0 -0
  27. package/{lib/cjs/lib → dist/cjs/types}/helpers/sum.d.ts +0 -0
  28. package/{lib/cjs/lib → dist/cjs/types}/helpers/visitServerEndpoint.d.ts +0 -0
  29. package/{lib/cjs/lib → dist/cjs/types}/helpers/waitMs.d.ts +0 -0
  30. package/{lib/cjs/lib → dist/cjs/types}/index.d.ts +13 -6
  31. package/dist/cjs/types/server/initServer.d.ts +21 -0
  32. package/{lib/cjs/lib → dist/cjs/types}/types/ModalButtonType.d.ts +0 -0
  33. package/{lib/cjs/lib → dist/cjs/types}/types/ModalSize.d.ts +0 -0
  34. package/{lib/cjs/lib → dist/cjs/types}/types/ModalType.d.ts +0 -0
  35. package/{lib → dist}/cjs/types/types/ParamType.d.ts +1 -1
  36. package/{lib → dist}/cjs/types/types/ReactKitErrorCode.d.ts +3 -1
  37. package/{lib/cjs/lib → dist/cjs/types}/types/Variant.d.ts +0 -0
  38. package/dist/esm/index.js +1739 -0
  39. package/dist/esm/index.js.map +1 -0
  40. package/{lib/cjs → dist/esm}/types/components/AppWrapper.d.ts +26 -1
  41. package/dist/esm/types/components/ButtonInputGroup.d.ts +12 -0
  42. package/dist/esm/types/components/CheckboxButton.d.ts +20 -0
  43. package/{lib/cjs → dist/esm}/types/components/ErrorBox.d.ts +0 -0
  44. package/{lib/cjs → dist/esm}/types/components/LoadingSpinner.d.ts +0 -0
  45. package/{lib/cjs → dist/esm}/types/components/Modal.d.ts +0 -0
  46. package/dist/esm/types/components/RadioButton.d.ts +20 -0
  47. package/dist/esm/types/components/SimpleDateChooser.d.ts +22 -0
  48. package/{lib/cjs/lib → dist/esm/types}/components/TabBox.d.ts +1 -0
  49. package/{lib/cjs → dist/esm}/types/errors/ErrorWithCode.d.ts +0 -0
  50. package/{lib/cjs → dist/esm}/types/helpers/abbreviate.d.ts +0 -0
  51. package/{lib/cjs → dist/esm}/types/helpers/avg.d.ts +0 -0
  52. package/{lib/cjs → dist/esm}/types/helpers/ceilToNumDecimals.d.ts +0 -0
  53. package/{lib/cjs → dist/esm}/types/helpers/floorToNumDecimals.d.ts +0 -0
  54. package/{lib/cjs → dist/esm}/types/helpers/forceNumIntoBounds.d.ts +0 -0
  55. package/dist/esm/types/helpers/genRouteHandler.d.ts +32 -0
  56. package/dist/esm/types/helpers/getOrdinal.d.ts +8 -0
  57. package/dist/esm/types/helpers/getTimeInfoInET.d.ts +17 -0
  58. package/{lib/cjs → dist/esm}/types/helpers/handleError.d.ts +5 -1
  59. package/{lib/cjs → dist/esm}/types/helpers/handleSuccess.d.ts +0 -0
  60. package/{lib/cjs → dist/esm}/types/helpers/padDecimalZeros.d.ts +0 -0
  61. package/{lib/cjs → dist/esm}/types/helpers/padZerosLeft.d.ts +0 -0
  62. package/{lib/cjs → dist/esm}/types/helpers/roundToNumDecimals.d.ts +0 -0
  63. package/{lib/cjs → dist/esm}/types/helpers/sum.d.ts +0 -0
  64. package/{lib/cjs → dist/esm}/types/helpers/visitServerEndpoint.d.ts +0 -0
  65. package/{lib/cjs → dist/esm}/types/helpers/waitMs.d.ts +0 -0
  66. package/{lib/esm/lib → dist/esm/types}/index.d.ts +13 -6
  67. package/dist/esm/types/server/initServer.d.ts +21 -0
  68. package/{lib/cjs → dist/esm}/types/types/ModalButtonType.d.ts +0 -0
  69. package/{lib/cjs → dist/esm}/types/types/ModalSize.d.ts +0 -0
  70. package/{lib/cjs → dist/esm}/types/types/ModalType.d.ts +0 -0
  71. package/{lib/esm/lib → dist/esm/types}/types/ParamType.d.ts +1 -1
  72. package/{lib/esm/lib → dist/esm/types}/types/ReactKitErrorCode.d.ts +3 -1
  73. package/{lib/cjs → dist/esm}/types/types/Variant.d.ts +0 -0
  74. package/{lib → dist}/index.d.ts +232 -11
  75. package/package.json +18 -29
  76. package/rollup.config.js +14 -13
  77. package/src/components/AppWrapper.tsx +74 -12
  78. package/src/components/ButtonInputGroup.tsx +89 -0
  79. package/src/components/CheckboxButton.tsx +100 -0
  80. package/src/components/ErrorBox.tsx +4 -4
  81. package/src/components/LoadingSpinner.tsx +3 -3
  82. package/src/components/Modal.tsx +214 -97
  83. package/src/components/RadioButton.tsx +102 -0
  84. package/src/components/SimpleDateChooser.tsx +222 -0
  85. package/src/components/TabBox.tsx +65 -58
  86. package/src/helpers/genRouteHandler.ts +329 -0
  87. package/src/helpers/getOrdinal.tsx +13 -0
  88. package/src/helpers/getTimeInfoInET.tsx +56 -0
  89. package/src/helpers/handleError.ts +65 -0
  90. package/src/helpers/handleSuccess.ts +18 -0
  91. package/src/helpers/visitServerEndpoint.tsx +110 -0
  92. package/src/index.ts +27 -0
  93. package/src/server/initServer.ts +53 -0
  94. package/src/types/ParamType.ts +18 -0
  95. package/src/types/ReactKitErrorCode.tsx +3 -1
  96. package/tsconfig.json +9 -7
  97. package/lib/cjs/index.js +0 -2
  98. package/lib/cjs/index.js.map +0 -1
  99. package/lib/cjs/lib/components/AppWrapper.d.ts +0 -35
  100. package/lib/cjs/lib/helpers/parseRequest.d.ts +0 -21
  101. package/lib/cjs/lib/types/ParamType.d.ts +0 -17
  102. package/lib/cjs/lib/types/ReactKitErrorCode.d.ts +0 -13
  103. package/lib/cjs/types/components/TabBox.d.ts +0 -11
  104. package/lib/cjs/types/helpers/alert.d.ts +0 -2
  105. package/lib/cjs/types/helpers/confirm.d.ts +0 -2
  106. package/lib/cjs/types/helpers/parseRequest.d.ts +0 -21
  107. package/lib/cjs/types/helpers/showFatalError.d.ts +0 -2
  108. package/lib/cjs/types/index.d.ts +0 -22
  109. package/lib/esm/index.js +0 -16
  110. package/lib/esm/index.js.map +0 -1
  111. package/lib/esm/lib/components/AppWrapper.d.ts +0 -35
  112. package/lib/esm/lib/components/ErrorBox.d.ts +0 -12
  113. package/lib/esm/lib/components/LoadingSpinner.d.ts +0 -7
  114. package/lib/esm/lib/components/Modal.d.ts +0 -40
  115. package/lib/esm/lib/errors/ErrorWithCode.d.ts +0 -9
  116. package/lib/esm/lib/helpers/abbreviate.d.ts +0 -10
  117. package/lib/esm/lib/helpers/avg.d.ts +0 -8
  118. package/lib/esm/lib/helpers/ceilToNumDecimals.d.ts +0 -9
  119. package/lib/esm/lib/helpers/floorToNumDecimals.d.ts +0 -9
  120. package/lib/esm/lib/helpers/forceNumIntoBounds.d.ts +0 -10
  121. package/lib/esm/lib/helpers/handleError.d.ts +0 -14
  122. package/lib/esm/lib/helpers/handleSuccess.d.ts +0 -8
  123. package/lib/esm/lib/helpers/padDecimalZeros.d.ts +0 -10
  124. package/lib/esm/lib/helpers/padZerosLeft.d.ts +0 -9
  125. package/lib/esm/lib/helpers/parseRequest.d.ts +0 -21
  126. package/lib/esm/lib/helpers/roundToNumDecimals.d.ts +0 -9
  127. package/lib/esm/lib/helpers/sum.d.ts +0 -8
  128. package/lib/esm/lib/helpers/visitServerEndpoint.d.ts +0 -23
  129. package/lib/esm/lib/helpers/waitMs.d.ts +0 -7
  130. package/lib/esm/lib/types/ModalButtonType.d.ts +0 -17
  131. package/lib/esm/lib/types/ModalSize.d.ts +0 -11
  132. package/lib/esm/lib/types/ModalType.d.ts +0 -16
  133. package/lib/esm/lib/types/Variant.d.ts +0 -15
  134. package/lib/esm/types/components/ErrorBox.d.ts +0 -12
  135. package/lib/esm/types/components/LoadingSpinner.d.ts +0 -7
  136. package/lib/esm/types/components/Modal.d.ts +0 -40
  137. package/lib/esm/types/components/TabBox.d.ts +0 -11
  138. package/lib/esm/types/errors/ErrorWithCode.d.ts +0 -9
  139. package/lib/esm/types/helpers/abbreviate.d.ts +0 -10
  140. package/lib/esm/types/helpers/alert.d.ts +0 -2
  141. package/lib/esm/types/helpers/avg.d.ts +0 -8
  142. package/lib/esm/types/helpers/ceilToNumDecimals.d.ts +0 -9
  143. package/lib/esm/types/helpers/confirm.d.ts +0 -2
  144. package/lib/esm/types/helpers/floorToNumDecimals.d.ts +0 -9
  145. package/lib/esm/types/helpers/forceNumIntoBounds.d.ts +0 -10
  146. package/lib/esm/types/helpers/handleError.d.ts +0 -14
  147. package/lib/esm/types/helpers/handleSuccess.d.ts +0 -8
  148. package/lib/esm/types/helpers/padDecimalZeros.d.ts +0 -10
  149. package/lib/esm/types/helpers/padZerosLeft.d.ts +0 -9
  150. package/lib/esm/types/helpers/parseRequest.d.ts +0 -21
  151. package/lib/esm/types/helpers/roundToNumDecimals.d.ts +0 -9
  152. package/lib/esm/types/helpers/showFatalError.d.ts +0 -2
  153. package/lib/esm/types/helpers/sum.d.ts +0 -8
  154. package/lib/esm/types/helpers/visitServerEndpoint.d.ts +0 -23
  155. package/lib/esm/types/helpers/waitMs.d.ts +0 -7
  156. package/lib/esm/types/index.d.ts +0 -22
  157. package/lib/esm/types/types/ModalButtonType.d.ts +0 -17
  158. package/lib/esm/types/types/ModalSize.d.ts +0 -11
  159. package/lib/esm/types/types/ModalType.d.ts +0 -16
  160. package/lib/esm/types/types/ParamType.d.ts +0 -17
  161. package/lib/esm/types/types/ReactKitErrorCode.d.ts +0 -13
  162. package/lib/esm/types/types/Variant.d.ts +0 -15
@@ -1,9 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- declare const confirm: (title: string, text: string) => Promise<boolean>;
2
- export default confirm;
@@ -1,9 +0,0 @@
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;
@@ -1,10 +0,0 @@
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;
@@ -1,14 +0,0 @@
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;
@@ -1,8 +0,0 @@
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;
@@ -1,10 +0,0 @@
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;
@@ -1,9 +0,0 @@
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;
@@ -1,21 +0,0 @@
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;
@@ -1,9 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- declare const showFatalError: (error: any, errorTitle?: string) => Promise<unknown> | undefined;
2
- export default showFatalError;
@@ -1,8 +0,0 @@
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;
@@ -1,23 +0,0 @@
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;
@@ -1,7 +0,0 @@
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;
@@ -1,22 +0,0 @@
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, };
@@ -1,17 +0,0 @@
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;
@@ -1,11 +0,0 @@
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;
@@ -1,16 +0,0 @@
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;
@@ -1,17 +0,0 @@
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;
@@ -1,13 +0,0 @@
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;
@@ -1,15 +0,0 @@
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;