dce-reactkit 1.0.19 → 2.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 (203) hide show
  1. package/.eslintrc.js +95 -0
  2. package/lib/components/LoadingSpinner.d.ts +6 -0
  3. package/lib/components/LoadingSpinner.js +41 -0
  4. package/lib/components/LoadingSpinner.js.map +1 -0
  5. package/lib/components/Modal.d.ts +69 -0
  6. package/lib/components/Modal.js +315 -0
  7. package/lib/components/Modal.js.map +1 -0
  8. package/lib/helpers/abbreviate.d.ts +9 -0
  9. package/lib/helpers/abbreviate.js +21 -0
  10. package/lib/helpers/abbreviate.js.map +1 -0
  11. package/lib/helpers/avg.d.ts +8 -0
  12. package/lib/helpers/avg.js +24 -0
  13. package/lib/helpers/avg.js.map +1 -0
  14. package/lib/helpers/ceilToNumDecimals.d.ts +9 -0
  15. package/lib/helpers/ceilToNumDecimals.js +15 -0
  16. package/lib/helpers/ceilToNumDecimals.js.map +1 -0
  17. package/lib/helpers/floorToNumDecimals.d.ts +9 -0
  18. package/lib/helpers/floorToNumDecimals.js +15 -0
  19. package/lib/helpers/floorToNumDecimals.js.map +1 -0
  20. package/lib/helpers/forceNumIntoBounds.d.ts +10 -0
  21. package/lib/helpers/forceNumIntoBounds.js +15 -0
  22. package/lib/helpers/forceNumIntoBounds.js.map +1 -0
  23. package/lib/helpers/padDecimalZeros.d.ts +10 -0
  24. package/lib/helpers/padDecimalZeros.js +30 -0
  25. package/lib/helpers/padDecimalZeros.js.map +1 -0
  26. package/lib/helpers/padZerosLeft.d.ts +9 -0
  27. package/lib/helpers/padZerosLeft.js +21 -0
  28. package/lib/helpers/padZerosLeft.js.map +1 -0
  29. package/lib/helpers/roundToNumDecimals.d.ts +9 -0
  30. package/lib/helpers/roundToNumDecimals.js +15 -0
  31. package/lib/helpers/roundToNumDecimals.js.map +1 -0
  32. package/lib/helpers/sum.d.ts +8 -0
  33. package/lib/helpers/sum.js +15 -0
  34. package/lib/helpers/sum.js.map +1 -0
  35. package/lib/helpers/waitMs.d.ts +7 -0
  36. package/lib/helpers/waitMs.js +55 -0
  37. package/lib/helpers/waitMs.js.map +1 -0
  38. package/lib/types/Variant.d.ts +15 -0
  39. package/lib/types/Variant.js +19 -0
  40. package/lib/types/Variant.js.map +1 -0
  41. package/package.json +21 -39
  42. package/src/components/LoadingSpinner.tsx +105 -0
  43. package/src/components/Modal.tsx +447 -0
  44. package/src/helpers/abbreviate.tsx +23 -0
  45. package/src/helpers/avg.tsx +22 -0
  46. package/src/helpers/ceilToNumDecimals.tsx +13 -0
  47. package/src/helpers/floorToNumDecimals.tsx +13 -0
  48. package/src/helpers/forceNumIntoBounds.tsx +19 -0
  49. package/src/helpers/padDecimalZeros.tsx +32 -0
  50. package/src/helpers/padZerosLeft.tsx +21 -0
  51. package/src/helpers/roundToNumDecimals.tsx +13 -0
  52. package/src/helpers/sum.tsx +16 -0
  53. package/src/helpers/waitMs.tsx +12 -0
  54. package/src/types/Variant.tsx +16 -0
  55. package/tsconfig.json +24 -0
  56. package/index.js +0 -1
  57. package/lib/Bar.js +0 -169
  58. package/lib/Donut.js +0 -145
  59. package/lib/DownloadButton.js +0 -81
  60. package/lib/Histogram.js +0 -193
  61. package/lib/Scatter.js +0 -162
  62. package/lib/StackedBar.js +0 -243
  63. package/lib/common/chart/Holder/index.js +0 -182
  64. package/lib/common/chart/Holder/style.css +0 -41
  65. package/lib/common/chart/colors.js +0 -12
  66. package/lib/common/csvToString.js +0 -23
  67. package/lib/common/isFloat.js +0 -14
  68. package/lib/common/isInteger.js +0 -24
  69. package/lib/common/math.js +0 -21
  70. package/lib/common/validators.js +0 -18
  71. package/lib/glyph/Adjust.js +0 -13
  72. package/lib/glyph/Angle.js +0 -44
  73. package/lib/glyph/Archive.js +0 -13
  74. package/lib/glyph/Arrow.js +0 -49
  75. package/lib/glyph/ArrowsHorizontal.js +0 -13
  76. package/lib/glyph/ArrowsVertical.js +0 -13
  77. package/lib/glyph/Award.js +0 -13
  78. package/lib/glyph/Ban.js +0 -13
  79. package/lib/glyph/Barcode.js +0 -13
  80. package/lib/glyph/Bed.js +0 -13
  81. package/lib/glyph/Bell.js +0 -35
  82. package/lib/glyph/Bolt.js +0 -13
  83. package/lib/glyph/Bookmark.js +0 -37
  84. package/lib/glyph/Bug.js +0 -13
  85. package/lib/glyph/Calendar.js +0 -13
  86. package/lib/glyph/Check.js +0 -36
  87. package/lib/glyph/Checkbox.js +0 -40
  88. package/lib/glyph/Chevron.js +0 -63
  89. package/lib/glyph/Circle.js +0 -15
  90. package/lib/glyph/Cog.js +0 -13
  91. package/lib/glyph/DoubleAngle.js +0 -45
  92. package/lib/glyph/Download.js +0 -13
  93. package/lib/glyph/Ellipsis.js +0 -36
  94. package/lib/glyph/Envelope.js +0 -13
  95. package/lib/glyph/File.js +0 -37
  96. package/lib/glyph/IdCard.js +0 -13
  97. package/lib/glyph/Menu.js +0 -13
  98. package/lib/glyph/Minus.js +0 -13
  99. package/lib/glyph/Move.js +0 -13
  100. package/lib/glyph/Plus.js +0 -13
  101. package/lib/glyph/Square.js +0 -47
  102. package/lib/glyph/Teacher.js +0 -13
  103. package/lib/glyph/TextAlign.js +0 -53
  104. package/lib/glyph/Times.js +0 -36
  105. package/lib/glyph/WarningTriangle.js +0 -13
  106. package/lib/index.js +0 -1
  107. package/src-old/common/csvToString.js +0 -5
  108. package/src-old/common/isFloat.js +0 -3
  109. package/src-old/common/isInteger.js +0 -14
  110. package/src-old/common/math.js +0 -16
  111. package/src-old/common/validators.js +0 -14
  112. package/src-old/components/Alert.js +0 -79
  113. package/src-old/components/Button.js +0 -64
  114. package/src-old/components/CSV/autoMatch.js +0 -174
  115. package/src-old/components/CSV/getNumCols.js +0 -15
  116. package/src-old/components/CSV/index.js +0 -743
  117. package/src-old/components/Card.js +0 -64
  118. package/src-old/components/Chart/Bar.js +0 -169
  119. package/src-old/components/Chart/Donut.js +0 -160
  120. package/src-old/components/Chart/Histogram.js +0 -189
  121. package/src-old/components/Chart/Scatter.js +0 -162
  122. package/src-old/components/Chart/colors.js +0 -20
  123. package/src-old/components/Checkbox/index.js +0 -106
  124. package/src-old/components/Checkbox/style.css +0 -11
  125. package/src-old/components/DatePicker.js +0 -59
  126. package/src-old/components/DownloadButton.js +0 -72
  127. package/src-old/components/Dropdown.js +0 -120
  128. package/src-old/components/Layout/LeftAddon.js +0 -63
  129. package/src-old/components/Layout/RightAddon.js +0 -64
  130. package/src-old/components/Layout/TwoCol.js +0 -67
  131. package/src-old/components/Modal.js +0 -161
  132. package/src-old/components/PhotoRoster.js +0 -152
  133. package/src-old/components/Pills.js +0 -117
  134. package/src-old/components/Radio.js +0 -94
  135. package/src-old/components/Splash/Error.js +0 -62
  136. package/src-old/components/Splash/Load/index.js +0 -32
  137. package/src-old/components/Splash/Load/style.css +0 -51
  138. package/src-old/components/Stat/General.js +0 -252
  139. package/src-old/components/Stat/helpers/calcAverage.js +0 -20
  140. package/src-old/components/Stat/helpers/calcExtremes.js +0 -27
  141. package/src-old/components/Stat/helpers/calcMedian.js +0 -32
  142. package/src-old/components/Stat/helpers/calcStdDev.js +0 -30
  143. package/src-old/components/Stat/helpers/calcSum.js +0 -8
  144. package/src-old/components/UserProfile/index.js +0 -151
  145. package/src-old/components/UserProfile/style.css +0 -33
  146. package/src-old/components/Well.js +0 -28
  147. package/src-old/components/Wizard/Question/CSV.js +0 -307
  148. package/src-old/components/Wizard/Question/Chooser/Assignment.js +0 -108
  149. package/src-old/components/Wizard/Question/Chooser/Course.js +0 -214
  150. package/src-old/components/Wizard/Question/Chooser/helpers/divideIntoSections.js +0 -16
  151. package/src-old/components/Wizard/Question/Chooser/helpers/genGetItemsPromise.js +0 -20
  152. package/src-old/components/Wizard/Question/Chooser/helpers/preprocessSections.js +0 -36
  153. package/src-old/components/Wizard/Question/Chooser/index.js +0 -306
  154. package/src-old/components/Wizard/Question/Form/Field/CheckableItem.js +0 -155
  155. package/src-old/components/Wizard/Question/Form/Field/Input.js +0 -149
  156. package/src-old/components/Wizard/Question/Form/Field/NumberItem.js +0 -374
  157. package/src-old/components/Wizard/Question/Form/Field/index.js +0 -34
  158. package/src-old/components/Wizard/Question/Form/Field/readme.md +0 -7
  159. package/src-old/components/Wizard/Question/Form/index.js +0 -175
  160. package/src-old/components/Wizard/Question/Form/style.css +0 -3
  161. package/src-old/components/Wizard/Question/OneButton.js +0 -80
  162. package/src-old/components/Wizard/Question/index.js +0 -46
  163. package/src-old/components/Wizard/Question/readme.md +0 -10
  164. package/src-old/components/Wizard/QuestionGroup/AnswerAll.js +0 -126
  165. package/src-old/components/Wizard/QuestionGroup/AnswerAny.js +0 -60
  166. package/src-old/components/Wizard/index.js +0 -233
  167. package/src-old/components/Wizard/style.css +0 -21
  168. package/src-old/glyphs/Adjust.js +0 -13
  169. package/src-old/glyphs/Angle.js +0 -57
  170. package/src-old/glyphs/Archive.js +0 -13
  171. package/src-old/glyphs/Arrow.js +0 -85
  172. package/src-old/glyphs/ArrowsHorizontal.js +0 -13
  173. package/src-old/glyphs/ArrowsVertical.js +0 -13
  174. package/src-old/glyphs/Award.js +0 -13
  175. package/src-old/glyphs/Ban.js +0 -13
  176. package/src-old/glyphs/Barcode.js +0 -13
  177. package/src-old/glyphs/Bed.js +0 -13
  178. package/src-old/glyphs/Bell.js +0 -34
  179. package/src-old/glyphs/Bolt.js +0 -13
  180. package/src-old/glyphs/Bookmark.js +0 -36
  181. package/src-old/glyphs/Bug.js +0 -13
  182. package/src-old/glyphs/Calendar.js +0 -13
  183. package/src-old/glyphs/Check.js +0 -34
  184. package/src-old/glyphs/Checkbox.js +0 -42
  185. package/src-old/glyphs/Chevron.js +0 -88
  186. package/src-old/glyphs/Circle.js +0 -16
  187. package/src-old/glyphs/Cog.js +0 -13
  188. package/src-old/glyphs/DoubleAngle.js +0 -58
  189. package/src-old/glyphs/Download.js +0 -13
  190. package/src-old/glyphs/Ellipsis.js +0 -35
  191. package/src-old/glyphs/Envelope.js +0 -13
  192. package/src-old/glyphs/File.js +0 -40
  193. package/src-old/glyphs/IdCard.js +0 -13
  194. package/src-old/glyphs/Menu.js +0 -13
  195. package/src-old/glyphs/Minus.js +0 -13
  196. package/src-old/glyphs/Move.js +0 -13
  197. package/src-old/glyphs/Plus.js +0 -13
  198. package/src-old/glyphs/Square.js +0 -48
  199. package/src-old/glyphs/Teacher.js +0 -13
  200. package/src-old/glyphs/TextAlign.js +0 -58
  201. package/src-old/glyphs/Times.js +0 -34
  202. package/src-old/glyphs/WarningTriangle.js +0 -13
  203. package/src-old/index.js +0 -1
package/.eslintrc.js ADDED
@@ -0,0 +1,95 @@
1
+ const config = {
2
+ extends: [
3
+ 'airbnb',
4
+ 'airbnb/hooks',
5
+ 'react-app',
6
+ 'react-app/jest',
7
+ ],
8
+ overrides: [
9
+ {
10
+ files: [
11
+ '*.ts',
12
+ '*.tsx',
13
+ ],
14
+ extends: [
15
+ 'airbnb-typescript',
16
+ ],
17
+ parserOptions: {
18
+ project: './tsconfig.json',
19
+ tsconfigRootDir: __dirname,
20
+ sourceType: 'module',
21
+ },
22
+ rules: {
23
+ '@typescript-eslint/lines-between-class-members': 'off',
24
+ '@typescript-eslint/no-unused-expressions': 'off',
25
+ },
26
+ },
27
+ ],
28
+ rules: {
29
+ 'arrow-body-style': [
30
+ 'warn',
31
+ 'always',
32
+ ],
33
+ 'react/prop-types': 'off',
34
+ 'react/function-component-definition': [
35
+ 2,
36
+ {
37
+ namedComponents: 'arrow-function',
38
+ },
39
+ ],
40
+ 'no-spaced-func': 'off',
41
+ 'react-hooks/exhaustive-deps': 'off',
42
+ 'lines-between-class-members': 'off',
43
+ 'no-case-declarations': 'off',
44
+ 'react/require-default-props': 'off',
45
+ 'react/react-in-jsx-scope': 'off',
46
+ 'arrow-parens': [
47
+ 'warn',
48
+ 'always',
49
+ ],
50
+ 'comma-dangle': [
51
+ 'error',
52
+ {
53
+ arrays: 'always-multiline',
54
+ objects: 'always-multiline',
55
+ imports: 'always-multiline',
56
+ exports: 'always-multiline',
57
+ functions: 'always-multiline',
58
+ },
59
+ ],
60
+ 'consistent-return': 'off',
61
+ 'id-length': 'off',
62
+ 'max-len': [
63
+ 'error',
64
+ {
65
+ code: 125,
66
+ ignoreStrings: true,
67
+ ignoreTemplateLiterals: true,
68
+ ignoreUrls: true,
69
+ },
70
+ ],
71
+ 'newline-per-chained-call': [
72
+ 'error',
73
+ {
74
+ ignoreChainWithDepth: 2,
75
+ },
76
+ ],
77
+ 'no-plusplus': [
78
+ 'warn',
79
+ {
80
+ allowForLoopAfterthoughts: true,
81
+ },
82
+ ],
83
+ 'prefer-template': 1,
84
+ radix: 'error',
85
+ 'no-await-in-loop': 'off',
86
+ 'max-params': [
87
+ 'warn',
88
+ {
89
+ max: 3,
90
+ },
91
+ ],
92
+ },
93
+ };
94
+
95
+ module.exports = config;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Loading spinner/indicator
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const LoadingSpinner: () => JSX.Element;
6
+ export default LoadingSpinner;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ var jsx_runtime_1 = require("react/jsx-runtime");
15
+ /**
16
+ * Loading spinner/indicator
17
+ * @author Gabe Abrams
18
+ */
19
+ // Import FontAwesome Icons
20
+ var react_fontawesome_1 = require("@fortawesome/react-fontawesome");
21
+ var free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
22
+ /*------------------------------------------------------------------------*/
23
+ /* Style */
24
+ /*------------------------------------------------------------------------*/
25
+ var style = "\n/* Blips */\n.LoadingSpinner-blip-1,\n.LoadingSpinner-blip-2,\n.LoadingSpinner-blip-3,\n.LoadingSpinner-blip-4 {\n font-size: 25px;\n opacity: 0.6;\n margin-top: 20px;\n margin-bottom: 20px;\n}\n\n/* First Blip */\n.LoadingSpinner-blip-1 {\n animation: LoadingSpinner-pop-animation 2s infinite;\n}\n\n/* Second Blip */\n.LoadingSpinner-blip-2 {\n animation: LoadingSpinner-pop-animation 2s infinite;\n -webkit-animation-delay: 0.1s;\n animation-delay: 0.1s;\n}\n\n/* Third Blip */\n.LoadingSpinner-blip-3 {\n animation: LoadingSpinner-pop-animation 2s infinite;\n animation-delay: 0.2s;\n}\n\n/* Fourth Blip */\n.LoadingSpinner-blip-4 {\n animation: LoadingSpinner-pop-animation 2s infinite;\n animation-delay: 0.3s;\n}\n\n/* Pop Animation for Each Blip */\n@keyframes LoadingSpinner-pop-animation {\n 0% {\n transform: scale(1.0);\n }\n 10% {\n transform: scale(1.5);\n }\n 30% {\n transform: scale(1.0);\n }\n 100% {\n transform: scale(1.0);\n }\n}\n";
26
+ /*------------------------------------------------------------------------*/
27
+ /* Component */
28
+ /*------------------------------------------------------------------------*/
29
+ var LoadingSpinner = function () {
30
+ /*------------------------------------------------------------------------*/
31
+ /* Render */
32
+ /*------------------------------------------------------------------------*/
33
+ // Add all four blips to a container
34
+ return ((0, jsx_runtime_1.jsxs)("div", __assign({ className: "text-center LoadingSpinner LoadingSpinner-container" }, { children: [(0, jsx_runtime_1.jsx)("style", { children: style }), (0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faCircle, className: "LoadingSpinner-blip-1 me-1" }), (0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faCircle, className: "LoadingSpinner-blip-2 me-1" }), (0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faCircle, className: "LoadingSpinner-blip-3 me-1" }), (0, jsx_runtime_1.jsx)(react_fontawesome_1.FontAwesomeIcon, { icon: free_solid_svg_icons_1.faCircle, className: "LoadingSpinner-blip-4" })] })));
35
+ };
36
+ /*------------------------------------------------------------------------*/
37
+ /* Wrap Up */
38
+ /*------------------------------------------------------------------------*/
39
+ // Export component
40
+ exports.default = LoadingSpinner;
41
+ //# sourceMappingURL=LoadingSpinner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoadingSpinner.js","sourceRoot":"","sources":["../../src/components/LoadingSpinner.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;GAGG;AAEH,2BAA2B;AAC3B,oEAAiE;AACjE,0EAA6D;AAE7D,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,IAAM,KAAK,GAAG,69BAmDb,CAAC;AAEF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,IAAM,cAAc,GAAG;IACrB,4EAA4E;IAC5E,4EAA4E;IAC5E,4EAA4E;IAE5E,oCAAoC;IACpC,OAAO,CACL,0CAAK,SAAS,EAAC,qDAAqD,iBAClE,4CAAQ,KAAK,GAAS,EACtB,uBAAC,mCAAe,IACd,IAAI,EAAE,+BAAQ,EACd,SAAS,EAAC,4BAA4B,GACtC,EACF,uBAAC,mCAAe,IACd,IAAI,EAAE,+BAAQ,EACd,SAAS,EAAC,4BAA4B,GACtC,EACF,uBAAC,mCAAe,IACd,IAAI,EAAE,+BAAQ,EACd,SAAS,EAAC,4BAA4B,GACtC,EACF,uBAAC,mCAAe,IACd,IAAI,EAAE,+BAAQ,EACd,SAAS,EAAC,uBAAuB,GACjC,KACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,mBAAmB;AACnB,kBAAe,cAAc,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * A generic popup modal
3
+ * @author Gabe Abrams
4
+ */
5
+ import React from 'react';
6
+ import Variant from '../types/Variant';
7
+ declare enum ModalType {
8
+ Okay = "okay",
9
+ OkayCancel = "okay-cancel",
10
+ YesNo = "yes-no",
11
+ YesNoCancel = "yes-no-cancel",
12
+ AbandonGoBack = "abandon-goBack",
13
+ ImSureCancel = "imSure-cancel",
14
+ DeleteCancel = "delete-cancel",
15
+ ConfirmCancel = "confirm-cancel",
16
+ NoButtons = "-"
17
+ }
18
+ declare enum ModalSize {
19
+ Small = "sm",
20
+ Medium = "md",
21
+ Large = "lg",
22
+ ExtraLarge = "xl"
23
+ }
24
+ declare enum ButtonType {
25
+ Okay = "okay",
26
+ Cancel = "cancel",
27
+ Yes = "yes",
28
+ No = "no",
29
+ Abandon = "abandon",
30
+ GoBack = "goBack",
31
+ Continue = "continue",
32
+ ImSure = "imSure",
33
+ Delete = "delete",
34
+ Confirm = "confirm"
35
+ }
36
+ declare type Props = {
37
+ type?: ModalType;
38
+ size?: ModalSize;
39
+ title?: React.ReactNode;
40
+ children?: React.ReactNode;
41
+ onClose?: (type: ButtonType) => void;
42
+ okayLabel?: string;
43
+ okayVariant?: Variant;
44
+ cancelLabel?: string;
45
+ cancelVariant?: Variant;
46
+ yesLabel?: string;
47
+ yesVariant?: Variant;
48
+ noLabel?: string;
49
+ noVariant?: Variant;
50
+ abandonLabel?: string;
51
+ abandonVariant?: Variant;
52
+ goBackLabel?: string;
53
+ goBackVariant?: Variant;
54
+ continueLabel?: string;
55
+ continueVariant?: Variant;
56
+ imSureLabel?: string;
57
+ imSureVariant?: Variant;
58
+ deleteLabel?: string;
59
+ deleteVariant?: Variant;
60
+ confirmLabel?: string;
61
+ confirmVariant?: Variant;
62
+ };
63
+ declare const Modal: (React.FC<Props> & {
64
+ ModalType: typeof ModalType;
65
+ ModalSize: typeof ModalSize;
66
+ ButtonType: typeof ButtonType;
67
+ Variant: typeof Variant;
68
+ });
69
+ export default Modal;
@@ -0,0 +1,315 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ var _a, _b;
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ var jsx_runtime_1 = require("react/jsx-runtime");
55
+ /**
56
+ * A generic popup modal
57
+ * @author Gabe Abrams
58
+ */
59
+ // Import React
60
+ var react_1 = require("react");
61
+ // Import other components
62
+ var Modal_1 = __importDefault(require("react-bootstrap/Modal"));
63
+ var waitMs_1 = __importDefault(require("../helpers/waitMs"));
64
+ // Import types
65
+ var Variant_1 = __importDefault(require("../types/Variant"));
66
+ /*------------------------------------------------------------------------*/
67
+ /* Style */
68
+ /*------------------------------------------------------------------------*/
69
+ var style = "\n/* More opaque backdrop */\n.Modal-backdrop {\n background-color: black !important;\n opacity: 0.8 !important;\n z-index: 10000000 !important;\n}\n\n/* Customize the modal header and body */\n.modal-header {\n /* Dark theme */\n background-color: #222 !important;\n color: white !important;\n\n /* Border */\n border: 1px solid #545454 !important;\n}\n.modal-body {\n /* Dark theme */\n background-color: #222 !important;\n color: white !important;\n\n /* Border */\n border-top: 0 !important;\n border-left: 1px solid #545454 !important;\n border-bottom: 1px solid #545454 !important;\n border-right: 1px solid #545454 !important;\n border-bottom-left-radius: 3px;\n border-bottom-right-radius: 3px;\n}\n\n/* Create our own animation */\n.modal-content {\n animation-name: Modal-drop-in;\n animation-duration: 0.4s;\n animation-iteration-count: 1;\n animation-fill-mode: forwards;\n animation-timing-function: ease-out;\n}\n@keyframes Modal-drop-in {\n 0% {\n transform: scale(0.8);\n opacity: 0.5;\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n}\n";
70
+ /*------------------------------------------------------------------------*/
71
+ /* Constants */
72
+ /*------------------------------------------------------------------------*/
73
+ // Constants
74
+ var MS_TO_ANIMATE = 400; // Time to animate in/out (defined by bootstrap)
75
+ var MS_ANIMATE_IN_DELAY = 10;
76
+ // Time to wait before animating in (must be >0 or animation won't trigger)
77
+ // Modal types
78
+ var ModalType;
79
+ (function (ModalType) {
80
+ ModalType["Okay"] = "okay";
81
+ ModalType["OkayCancel"] = "okay-cancel";
82
+ ModalType["YesNo"] = "yes-no";
83
+ ModalType["YesNoCancel"] = "yes-no-cancel";
84
+ ModalType["AbandonGoBack"] = "abandon-goBack";
85
+ ModalType["ImSureCancel"] = "imSure-cancel";
86
+ ModalType["DeleteCancel"] = "delete-cancel";
87
+ ModalType["ConfirmCancel"] = "confirm-cancel";
88
+ ModalType["NoButtons"] = "-";
89
+ })(ModalType || (ModalType = {}));
90
+ // Modal sizes
91
+ var ModalSize;
92
+ (function (ModalSize) {
93
+ ModalSize["Small"] = "sm";
94
+ ModalSize["Medium"] = "md";
95
+ ModalSize["Large"] = "lg";
96
+ ModalSize["ExtraLarge"] = "xl";
97
+ })(ModalSize || (ModalSize = {}));
98
+ // Button types
99
+ var ButtonType;
100
+ (function (ButtonType) {
101
+ ButtonType["Okay"] = "okay";
102
+ ButtonType["Cancel"] = "cancel";
103
+ ButtonType["Yes"] = "yes";
104
+ ButtonType["No"] = "no";
105
+ ButtonType["Abandon"] = "abandon";
106
+ ButtonType["GoBack"] = "goBack";
107
+ ButtonType["Continue"] = "continue";
108
+ ButtonType["ImSure"] = "imSure";
109
+ ButtonType["Delete"] = "delete";
110
+ ButtonType["Confirm"] = "confirm";
111
+ })(ButtonType || (ButtonType = {}));
112
+ // Modal type to list of buttons
113
+ var modalTypeToButtonTypes = (_a = {},
114
+ _a[ModalType.Okay] = [
115
+ ButtonType.Okay,
116
+ ],
117
+ _a[ModalType.OkayCancel] = [
118
+ ButtonType.Okay,
119
+ ButtonType.Cancel,
120
+ ],
121
+ _a[ModalType.YesNo] = [
122
+ ButtonType.Yes,
123
+ ButtonType.No,
124
+ ],
125
+ _a[ModalType.YesNoCancel] = [
126
+ ButtonType.Yes,
127
+ ButtonType.No,
128
+ ButtonType.Cancel,
129
+ ],
130
+ _a[ModalType.AbandonGoBack] = [
131
+ ButtonType.Abandon,
132
+ ButtonType.GoBack,
133
+ ],
134
+ _a[ModalType.ImSureCancel] = [
135
+ ButtonType.ImSure,
136
+ ButtonType.Cancel,
137
+ ],
138
+ _a[ModalType.DeleteCancel] = [
139
+ ButtonType.Delete,
140
+ ButtonType.Cancel,
141
+ ],
142
+ _a[ModalType.ConfirmCancel] = [
143
+ ButtonType.Confirm,
144
+ ButtonType.Cancel,
145
+ ],
146
+ _a);
147
+ // Button type styling and labels
148
+ var buttonTypeToLabelAndVariant = (_b = {},
149
+ _b[ButtonType.Okay] = {
150
+ label: 'Okay',
151
+ variant: Variant_1.default.Dark,
152
+ },
153
+ _b[ButtonType.Cancel] = {
154
+ label: 'Cancel',
155
+ variant: Variant_1.default.Secondary,
156
+ },
157
+ _b[ButtonType.Yes] = {
158
+ label: 'Yes',
159
+ variant: Variant_1.default.Dark,
160
+ },
161
+ _b[ButtonType.No] = {
162
+ label: 'No',
163
+ variant: Variant_1.default.Secondary,
164
+ },
165
+ _b[ButtonType.Abandon] = {
166
+ label: 'Abandon Changes',
167
+ variant: Variant_1.default.Warning,
168
+ },
169
+ _b[ButtonType.GoBack] = {
170
+ label: 'Go Back',
171
+ variant: Variant_1.default.Secondary,
172
+ },
173
+ _b[ButtonType.Continue] = {
174
+ label: 'Continue',
175
+ variant: Variant_1.default.Dark,
176
+ },
177
+ _b[ButtonType.ImSure] = {
178
+ label: 'I am sure',
179
+ variant: Variant_1.default.Warning,
180
+ },
181
+ _b[ButtonType.Delete] = {
182
+ label: 'Yes, Delete',
183
+ variant: Variant_1.default.Danger,
184
+ },
185
+ _b[ButtonType.Confirm] = {
186
+ label: 'Confirm',
187
+ variant: Variant_1.default.Dark,
188
+ },
189
+ _b);
190
+ /*------------------------------------------------------------------------*/
191
+ /* Component */
192
+ /*------------------------------------------------------------------------*/
193
+ var Modal = function (props) {
194
+ /*------------------------------------------------------------------------*/
195
+ /* Setup */
196
+ /*------------------------------------------------------------------------*/
197
+ var _a;
198
+ /* -------------- Props ------------- */
199
+ var _b = props.type, type = _b === void 0 ? ModalType.NoButtons : _b, _c = props.size, size = _c === void 0 ? ModalSize.Large : _c, title = props.title, children = props.children, onClose = props.onClose;
200
+ /* -------------- State ------------- */
201
+ // If true, the modal is shown
202
+ var _d = (0, react_1.useState)(false), visible = _d[0], setVisible = _d[1];
203
+ // True if currently animating in
204
+ var _e = (0, react_1.useState)(false), animatingIn = _e[0], setAnimatingIn = _e[1];
205
+ /*------------------------------------------------------------------------*/
206
+ /* Lifecycle Functions */
207
+ /*------------------------------------------------------------------------*/
208
+ /**
209
+ * Mount
210
+ * @author Gabe Abrams
211
+ */
212
+ (0, react_1.useEffect)(function () {
213
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
214
+ return __generator(this, function (_a) {
215
+ switch (_a.label) {
216
+ case 0:
217
+ // Start the component animating in
218
+ return [4 /*yield*/, (0, waitMs_1.default)(MS_ANIMATE_IN_DELAY)];
219
+ case 1:
220
+ // Start the component animating in
221
+ _a.sent();
222
+ setAnimatingIn(true);
223
+ // Wait and then set visible to true
224
+ return [4 /*yield*/, (0, waitMs_1.default)(MS_TO_ANIMATE)];
225
+ case 2:
226
+ // Wait and then set visible to true
227
+ _a.sent();
228
+ setVisible(true);
229
+ return [2 /*return*/];
230
+ }
231
+ });
232
+ }); })();
233
+ }, []);
234
+ /*------------------------------------------------------------------------*/
235
+ /* Component Functions */
236
+ /*------------------------------------------------------------------------*/
237
+ /**
238
+ * Handles the closing of the modal
239
+ * @author Gabe Abrams
240
+ * @param buttonType the button that was clicked when closing the
241
+ * modal
242
+ */
243
+ var handleClose = function (buttonType) { return __awaiter(void 0, void 0, void 0, function () {
244
+ return __generator(this, function (_a) {
245
+ switch (_a.label) {
246
+ case 0:
247
+ // Don't close if no handler
248
+ if (!onClose) {
249
+ return [2 /*return*/];
250
+ }
251
+ // Don't close if animating in
252
+ if (animatingIn) {
253
+ return [2 /*return*/];
254
+ }
255
+ // Don't close if already closed
256
+ if (!visible) {
257
+ return [2 /*return*/];
258
+ }
259
+ // Update the state
260
+ setVisible(false);
261
+ // Call the handler after the modal has animated out
262
+ return [4 /*yield*/, (0, waitMs_1.default)(MS_TO_ANIMATE)];
263
+ case 1:
264
+ // Call the handler after the modal has animated out
265
+ _a.sent();
266
+ onClose(buttonType);
267
+ return [2 /*return*/];
268
+ }
269
+ });
270
+ }); };
271
+ /*------------------------------------------------------------------------*/
272
+ /* Render */
273
+ /*------------------------------------------------------------------------*/
274
+ /*----------------------------------------*/
275
+ /* Footer */
276
+ /*----------------------------------------*/
277
+ // Get list of buttons for this modal type
278
+ var buttonTypes = (_a = modalTypeToButtonTypes[type]) !== null && _a !== void 0 ? _a : [];
279
+ // Create buttons
280
+ var buttons = buttonTypes.map(function (buttonType, i) {
281
+ // Get default style
282
+ var _a = buttonTypeToLabelAndVariant[buttonType], label = _a.label, variant = _a.variant;
283
+ // Override with customizations
284
+ if (props["".concat(buttonType, "Label")]) {
285
+ label = props["".concat(buttonType, "Label")];
286
+ }
287
+ if (props["".concat(buttonType, "Variant")]) {
288
+ variant = props["".concat(buttonType, "Variant")];
289
+ }
290
+ // Check if this button is last
291
+ var last = (i === buttonTypes.length - 1);
292
+ // Create the button
293
+ return ((0, jsx_runtime_1.jsx)("button", __assign({ type: "button", className: "Modal-".concat(buttonType, "-button btn btn-").concat(variant, " ").concat(last ? '' : 'mr-1'), onClick: function () {
294
+ handleClose(buttonType);
295
+ } }, { children: label })));
296
+ });
297
+ // Put all buttons in a footer
298
+ var footer = ((buttons && buttons.length)
299
+ ? ((0, jsx_runtime_1.jsx)("div", { children: buttons }))
300
+ : undefined);
301
+ // Render the modal
302
+ return ((0, jsx_runtime_1.jsxs)(Modal_1.default, __assign({ show: visible, size: size !== ModalSize.Medium ? size : undefined, onHide: function () {
303
+ handleClose(ButtonType.Cancel);
304
+ }, style: { zIndex: 5000000000 }, backdropClassName: "Modal-backdrop", centered: true }, { children: [(0, jsx_runtime_1.jsx)("style", { children: style }), title && ((0, jsx_runtime_1.jsx)(Modal_1.default.Header, __assign({ closeButton: !!onClose }, { children: (0, jsx_runtime_1.jsx)(Modal_1.default.Title, { children: title }) }))), children && ((0, jsx_runtime_1.jsx)(Modal_1.default.Body, { children: children })), footer && ((0, jsx_runtime_1.jsx)(Modal_1.default.Footer, { children: footer }))] })));
305
+ };
306
+ /*------------------------------------------------------------------------*/
307
+ /* Wrap Up */
308
+ /*------------------------------------------------------------------------*/
309
+ // Add enums
310
+ Modal.ModalType = ModalType;
311
+ Modal.ModalSize = ModalSize;
312
+ Modal.ButtonType = ButtonType;
313
+ Modal.Variant = Variant_1.default;
314
+ exports.default = Modal;
315
+ //# sourceMappingURL=Modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/components/Modal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;GAGG;AAEH,eAAe;AACf,+BAAmD;AAEnD,0BAA0B;AAC1B,gEAAmD;AACnD,6DAAuC;AAEvC,eAAe;AACf,6DAAuC;AAEvC,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,IAAM,KAAK,GAAG,6kCAiDb,CAAC;AAEF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,YAAY;AACZ,IAAM,aAAa,GAAG,GAAG,CAAC,CAAC,gDAAgD;AAC3E,IAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,2EAA2E;AAE3E,cAAc;AACd,IAAK,SAUJ;AAVD,WAAK,SAAS;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,GAAG,iBAAO,CAAC;AAExB,kBAAe,KAAK,CAAC"}
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,21 @@
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
+ var abbreviate = function (text, maxChars) {
10
+ // Check if already short enough
11
+ if (text.trim().length < maxChars) {
12
+ return text.trim();
13
+ }
14
+ // Abbreviate
15
+ var shortenedText = (text
16
+ .trim()
17
+ .substring(0, maxChars - 3)
18
+ .trim());
19
+ return "".concat(shortenedText, "...");
20
+ };
21
+ //# sourceMappingURL=abbreviate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abbreviate.js","sourceRoot":"","sources":["../../src/helpers/abbreviate.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,IAAM,UAAU,GAAG,UAAC,IAAY,EAAE,QAAgB;IAChD,gCAAgC;IAChC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,QAAQ,EAAE;QACjC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;KACpB;IAED,aAAa;IACb,IAAM,aAAa,GAAG,CACpB,IAAI;SACD,IAAI,EAAE;SACN,SAAS,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC;SAC1B,IAAI,EAAE,CACV,CAAC;IACF,OAAO,UAAG,aAAa,QAAK,CAAC;AAC/B,CAAC,CAAC"}
@@ -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,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var sum_1 = __importDefault(require("./sum"));
7
+ /**
8
+ * Get the average of a set of numbers
9
+ * @author Gabe Abrams
10
+ * @param nums the numbers to average
11
+ * @returns average value or 0 if no numbers
12
+ */
13
+ var avg = function (nums) {
14
+ // Handle empty array case
15
+ if (nums.length === 0) {
16
+ return 0;
17
+ }
18
+ // Get the total value
19
+ var total = (0, sum_1.default)(nums);
20
+ // Get average
21
+ return (total / nums.length);
22
+ };
23
+ exports.default = avg;
24
+ //# sourceMappingURL=avg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avg.js","sourceRoot":"","sources":["../../src/helpers/avg.tsx"],"names":[],"mappings":";;;;;AAAA,8CAAwB;AAExB;;;;;GAKG;AACH,IAAM,GAAG,GAAG,UAAC,IAAc;IACzB,0BAA0B;IAC1B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,OAAO,CAAC,CAAC;KACV;IAED,sBAAsB;IACtB,IAAM,KAAK,GAAG,IAAA,aAAG,EAAC,IAAI,CAAC,CAAC;IAExB,cAAc;IACd,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,kBAAe,GAAG,CAAC"}
@@ -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,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Round a number (ceiling) to a certain number of decimals
5
+ * @author Gabe Abrams
6
+ * @param num the number to round
7
+ * @param numDecimals the number of decimals to round to
8
+ * @returns rounded number
9
+ */
10
+ var ceilToNumDecimals = function (num, numDecimals) {
11
+ var rounder = Math.pow(10, numDecimals);
12
+ return (Math.ceil(num * rounder) / rounder);
13
+ };
14
+ exports.default = ceilToNumDecimals;
15
+ //# sourceMappingURL=ceilToNumDecimals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ceilToNumDecimals.js","sourceRoot":"","sources":["../../src/helpers/ceilToNumDecimals.tsx"],"names":[],"mappings":";;AAAA;;;;;;GAMG;AACH,IAAM,iBAAiB,GAAG,UAAC,GAAW,EAAE,WAAmB;IACzD,IAAM,OAAO,GAAG,SAAA,EAAE,EAAI,WAAW,CAAA,CAAC;IAClC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF,kBAAe,iBAAiB,CAAC"}
@@ -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;