dce-reactkit 1.0.18 → 2.0.0
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.
- package/.eslintrc.js +95 -0
- package/lib/components/LoadingSpinner.d.ts +7 -0
- package/lib/components/LoadingSpinner.js +39 -0
- package/lib/components/LoadingSpinner.js.map +1 -0
- package/lib/components/Modal.d.ts +69 -0
- package/lib/components/Modal.js +311 -0
- package/lib/components/Modal.js.map +1 -0
- package/lib/helpers/abbreviate.d.ts +9 -0
- package/lib/helpers/abbreviate.js +21 -0
- package/lib/helpers/abbreviate.js.map +1 -0
- package/lib/helpers/avg.d.ts +8 -0
- package/lib/helpers/avg.js +24 -0
- package/lib/helpers/avg.js.map +1 -0
- package/lib/helpers/ceilToNumDecimals.d.ts +9 -0
- package/lib/helpers/ceilToNumDecimals.js +15 -0
- package/lib/helpers/ceilToNumDecimals.js.map +1 -0
- package/lib/helpers/floorToNumDecimals.d.ts +9 -0
- package/lib/helpers/floorToNumDecimals.js +15 -0
- package/lib/helpers/floorToNumDecimals.js.map +1 -0
- package/lib/helpers/forceNumIntoBounds.d.ts +10 -0
- package/lib/helpers/forceNumIntoBounds.js +15 -0
- package/lib/helpers/forceNumIntoBounds.js.map +1 -0
- package/lib/helpers/padDecimalZeros.d.ts +10 -0
- package/lib/helpers/padDecimalZeros.js +30 -0
- package/lib/helpers/padDecimalZeros.js.map +1 -0
- package/lib/helpers/padZerosLeft.d.ts +9 -0
- package/lib/helpers/padZerosLeft.js +21 -0
- package/lib/helpers/padZerosLeft.js.map +1 -0
- package/lib/helpers/roundToNumDecimals.d.ts +9 -0
- package/lib/helpers/roundToNumDecimals.js +15 -0
- package/lib/helpers/roundToNumDecimals.js.map +1 -0
- package/lib/helpers/sum.d.ts +8 -0
- package/lib/helpers/sum.js +15 -0
- package/lib/helpers/sum.js.map +1 -0
- package/lib/helpers/waitMs.d.ts +7 -0
- package/lib/helpers/waitMs.js +55 -0
- package/lib/helpers/waitMs.js.map +1 -0
- package/lib/types/Variant.d.ts +15 -0
- package/lib/types/Variant.js +19 -0
- package/lib/types/Variant.js.map +1 -0
- package/package.json +22 -39
- package/src/components/LoadingSpinner.scss +50 -0
- package/src/components/LoadingSpinner.tsx +50 -0
- package/src/components/Modal.scss +48 -0
- package/src/components/Modal.tsx +391 -0
- package/src/helpers/abbreviate.tsx +23 -0
- package/src/helpers/avg.tsx +22 -0
- package/src/helpers/ceilToNumDecimals.tsx +13 -0
- package/src/helpers/floorToNumDecimals.tsx +13 -0
- package/src/helpers/forceNumIntoBounds.tsx +19 -0
- package/src/helpers/padDecimalZeros.tsx +32 -0
- package/src/helpers/padZerosLeft.tsx +21 -0
- package/src/helpers/roundToNumDecimals.tsx +13 -0
- package/src/helpers/sum.tsx +16 -0
- package/src/helpers/waitMs.tsx +12 -0
- package/src/types/Variant.tsx +16 -0
- package/tsconfig.json +24 -0
- package/Bar.js +0 -169
- package/Donut.js +0 -145
- package/DownloadButton.js +0 -81
- package/Histogram.js +0 -193
- package/Scatter.js +0 -162
- package/common/chart/Holder/index.js +0 -182
- package/common/chart/Holder/style.css +0 -41
- package/common/chart/colors.js +0 -12
- package/common/csvToString.js +0 -23
- package/common/isFloat.js +0 -14
- package/common/isInteger.js +0 -24
- package/common/math.js +0 -21
- package/common/validators.js +0 -18
- package/glyph/Adjust.js +0 -13
- package/glyph/Angle.js +0 -44
- package/glyph/Archive.js +0 -13
- package/glyph/Arrow.js +0 -49
- package/glyph/ArrowsHorizontal.js +0 -13
- package/glyph/ArrowsVertical.js +0 -13
- package/glyph/Award.js +0 -13
- package/glyph/Ban.js +0 -13
- package/glyph/Barcode.js +0 -13
- package/glyph/Bed.js +0 -13
- package/glyph/Bell.js +0 -35
- package/glyph/Bolt.js +0 -13
- package/glyph/Bookmark.js +0 -37
- package/glyph/Bug.js +0 -13
- package/glyph/Calendar.js +0 -13
- package/glyph/Check.js +0 -36
- package/glyph/Checkbox.js +0 -40
- package/glyph/Chevron.js +0 -63
- package/glyph/Circle.js +0 -15
- package/glyph/Cog.js +0 -13
- package/glyph/DoubleAngle.js +0 -45
- package/glyph/Download.js +0 -13
- package/glyph/Ellipsis.js +0 -36
- package/glyph/Envelope.js +0 -13
- package/glyph/File.js +0 -37
- package/glyph/IdCard.js +0 -13
- package/glyph/Menu.js +0 -13
- package/glyph/Minus.js +0 -13
- package/glyph/Move.js +0 -13
- package/glyph/Plus.js +0 -13
- package/glyph/Square.js +0 -47
- package/glyph/Teacher.js +0 -13
- package/glyph/TextAlign.js +0 -53
- package/glyph/Times.js +0 -36
- package/glyph/WarningTriangle.js +0 -13
- package/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,39 @@
|
|
|
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
|
+
// Import style
|
|
23
|
+
require("./LoadingSpinner.scss");
|
|
24
|
+
/*------------------------------------------------------------------------*/
|
|
25
|
+
/* Component */
|
|
26
|
+
/*------------------------------------------------------------------------*/
|
|
27
|
+
var LoadingSpinner = function () {
|
|
28
|
+
/*------------------------------------------------------------------------*/
|
|
29
|
+
/* Render */
|
|
30
|
+
/*------------------------------------------------------------------------*/
|
|
31
|
+
// Add all four blips to a container
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)("div", __assign({ className: "text-center LoadingSpinner LoadingSpinner-container" }, { children: [(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" })] })));
|
|
33
|
+
};
|
|
34
|
+
/*------------------------------------------------------------------------*/
|
|
35
|
+
/* Wrap Up */
|
|
36
|
+
/*------------------------------------------------------------------------*/
|
|
37
|
+
// Export component
|
|
38
|
+
exports.default = LoadingSpinner;
|
|
39
|
+
//# 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,eAAe;AACf,iCAA+B;AAE/B,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,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,311 @@
|
|
|
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
|
+
/* Constants */
|
|
68
|
+
/*------------------------------------------------------------------------*/
|
|
69
|
+
// Constants
|
|
70
|
+
var MS_TO_ANIMATE = 400; // Time to animate in/out (defined by bootstrap)
|
|
71
|
+
var MS_ANIMATE_IN_DELAY = 10;
|
|
72
|
+
// Time to wait before animating in (must be >0 or animation won't trigger)
|
|
73
|
+
// Modal types
|
|
74
|
+
var ModalType;
|
|
75
|
+
(function (ModalType) {
|
|
76
|
+
ModalType["Okay"] = "okay";
|
|
77
|
+
ModalType["OkayCancel"] = "okay-cancel";
|
|
78
|
+
ModalType["YesNo"] = "yes-no";
|
|
79
|
+
ModalType["YesNoCancel"] = "yes-no-cancel";
|
|
80
|
+
ModalType["AbandonGoBack"] = "abandon-goBack";
|
|
81
|
+
ModalType["ImSureCancel"] = "imSure-cancel";
|
|
82
|
+
ModalType["DeleteCancel"] = "delete-cancel";
|
|
83
|
+
ModalType["ConfirmCancel"] = "confirm-cancel";
|
|
84
|
+
ModalType["NoButtons"] = "-";
|
|
85
|
+
})(ModalType || (ModalType = {}));
|
|
86
|
+
// Modal sizes
|
|
87
|
+
var ModalSize;
|
|
88
|
+
(function (ModalSize) {
|
|
89
|
+
ModalSize["Small"] = "sm";
|
|
90
|
+
ModalSize["Medium"] = "md";
|
|
91
|
+
ModalSize["Large"] = "lg";
|
|
92
|
+
ModalSize["ExtraLarge"] = "xl";
|
|
93
|
+
})(ModalSize || (ModalSize = {}));
|
|
94
|
+
// Button types
|
|
95
|
+
var ButtonType;
|
|
96
|
+
(function (ButtonType) {
|
|
97
|
+
ButtonType["Okay"] = "okay";
|
|
98
|
+
ButtonType["Cancel"] = "cancel";
|
|
99
|
+
ButtonType["Yes"] = "yes";
|
|
100
|
+
ButtonType["No"] = "no";
|
|
101
|
+
ButtonType["Abandon"] = "abandon";
|
|
102
|
+
ButtonType["GoBack"] = "goBack";
|
|
103
|
+
ButtonType["Continue"] = "continue";
|
|
104
|
+
ButtonType["ImSure"] = "imSure";
|
|
105
|
+
ButtonType["Delete"] = "delete";
|
|
106
|
+
ButtonType["Confirm"] = "confirm";
|
|
107
|
+
})(ButtonType || (ButtonType = {}));
|
|
108
|
+
// Modal type to list of buttons
|
|
109
|
+
var modalTypeToButtonTypes = (_a = {},
|
|
110
|
+
_a[ModalType.Okay] = [
|
|
111
|
+
ButtonType.Okay,
|
|
112
|
+
],
|
|
113
|
+
_a[ModalType.OkayCancel] = [
|
|
114
|
+
ButtonType.Okay,
|
|
115
|
+
ButtonType.Cancel,
|
|
116
|
+
],
|
|
117
|
+
_a[ModalType.YesNo] = [
|
|
118
|
+
ButtonType.Yes,
|
|
119
|
+
ButtonType.No,
|
|
120
|
+
],
|
|
121
|
+
_a[ModalType.YesNoCancel] = [
|
|
122
|
+
ButtonType.Yes,
|
|
123
|
+
ButtonType.No,
|
|
124
|
+
ButtonType.Cancel,
|
|
125
|
+
],
|
|
126
|
+
_a[ModalType.AbandonGoBack] = [
|
|
127
|
+
ButtonType.Abandon,
|
|
128
|
+
ButtonType.GoBack,
|
|
129
|
+
],
|
|
130
|
+
_a[ModalType.ImSureCancel] = [
|
|
131
|
+
ButtonType.ImSure,
|
|
132
|
+
ButtonType.Cancel,
|
|
133
|
+
],
|
|
134
|
+
_a[ModalType.DeleteCancel] = [
|
|
135
|
+
ButtonType.Delete,
|
|
136
|
+
ButtonType.Cancel,
|
|
137
|
+
],
|
|
138
|
+
_a[ModalType.ConfirmCancel] = [
|
|
139
|
+
ButtonType.Confirm,
|
|
140
|
+
ButtonType.Cancel,
|
|
141
|
+
],
|
|
142
|
+
_a);
|
|
143
|
+
// Button type styling and labels
|
|
144
|
+
var buttonTypeToLabelAndVariant = (_b = {},
|
|
145
|
+
_b[ButtonType.Okay] = {
|
|
146
|
+
label: 'Okay',
|
|
147
|
+
variant: Variant_1.default.Dark,
|
|
148
|
+
},
|
|
149
|
+
_b[ButtonType.Cancel] = {
|
|
150
|
+
label: 'Cancel',
|
|
151
|
+
variant: Variant_1.default.Secondary,
|
|
152
|
+
},
|
|
153
|
+
_b[ButtonType.Yes] = {
|
|
154
|
+
label: 'Yes',
|
|
155
|
+
variant: Variant_1.default.Dark,
|
|
156
|
+
},
|
|
157
|
+
_b[ButtonType.No] = {
|
|
158
|
+
label: 'No',
|
|
159
|
+
variant: Variant_1.default.Secondary,
|
|
160
|
+
},
|
|
161
|
+
_b[ButtonType.Abandon] = {
|
|
162
|
+
label: 'Abandon Changes',
|
|
163
|
+
variant: Variant_1.default.Warning,
|
|
164
|
+
},
|
|
165
|
+
_b[ButtonType.GoBack] = {
|
|
166
|
+
label: 'Go Back',
|
|
167
|
+
variant: Variant_1.default.Secondary,
|
|
168
|
+
},
|
|
169
|
+
_b[ButtonType.Continue] = {
|
|
170
|
+
label: 'Continue',
|
|
171
|
+
variant: Variant_1.default.Dark,
|
|
172
|
+
},
|
|
173
|
+
_b[ButtonType.ImSure] = {
|
|
174
|
+
label: 'I am sure',
|
|
175
|
+
variant: Variant_1.default.Warning,
|
|
176
|
+
},
|
|
177
|
+
_b[ButtonType.Delete] = {
|
|
178
|
+
label: 'Yes, Delete',
|
|
179
|
+
variant: Variant_1.default.Danger,
|
|
180
|
+
},
|
|
181
|
+
_b[ButtonType.Confirm] = {
|
|
182
|
+
label: 'Confirm',
|
|
183
|
+
variant: Variant_1.default.Dark,
|
|
184
|
+
},
|
|
185
|
+
_b);
|
|
186
|
+
/*------------------------------------------------------------------------*/
|
|
187
|
+
/* Component */
|
|
188
|
+
/*------------------------------------------------------------------------*/
|
|
189
|
+
var Modal = function (props) {
|
|
190
|
+
/*------------------------------------------------------------------------*/
|
|
191
|
+
/* Setup */
|
|
192
|
+
/*------------------------------------------------------------------------*/
|
|
193
|
+
var _a;
|
|
194
|
+
/* -------------- Props ------------- */
|
|
195
|
+
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;
|
|
196
|
+
/* -------------- State ------------- */
|
|
197
|
+
// If true, the modal is shown
|
|
198
|
+
var _d = (0, react_1.useState)(false), visible = _d[0], setVisible = _d[1];
|
|
199
|
+
// True if currently animating in
|
|
200
|
+
var _e = (0, react_1.useState)(false), animatingIn = _e[0], setAnimatingIn = _e[1];
|
|
201
|
+
/*------------------------------------------------------------------------*/
|
|
202
|
+
/* Lifecycle Functions */
|
|
203
|
+
/*------------------------------------------------------------------------*/
|
|
204
|
+
/**
|
|
205
|
+
* Mount
|
|
206
|
+
* @author Gabe Abrams
|
|
207
|
+
*/
|
|
208
|
+
(0, react_1.useEffect)(function () {
|
|
209
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
210
|
+
return __generator(this, function (_a) {
|
|
211
|
+
switch (_a.label) {
|
|
212
|
+
case 0:
|
|
213
|
+
// Start the component animating in
|
|
214
|
+
return [4 /*yield*/, (0, waitMs_1.default)(MS_ANIMATE_IN_DELAY)];
|
|
215
|
+
case 1:
|
|
216
|
+
// Start the component animating in
|
|
217
|
+
_a.sent();
|
|
218
|
+
setAnimatingIn(true);
|
|
219
|
+
// Wait and then set visible to true
|
|
220
|
+
return [4 /*yield*/, (0, waitMs_1.default)(MS_TO_ANIMATE)];
|
|
221
|
+
case 2:
|
|
222
|
+
// Wait and then set visible to true
|
|
223
|
+
_a.sent();
|
|
224
|
+
setVisible(true);
|
|
225
|
+
return [2 /*return*/];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}); })();
|
|
229
|
+
}, []);
|
|
230
|
+
/*------------------------------------------------------------------------*/
|
|
231
|
+
/* Component Functions */
|
|
232
|
+
/*------------------------------------------------------------------------*/
|
|
233
|
+
/**
|
|
234
|
+
* Handles the closing of the modal
|
|
235
|
+
* @author Gabe Abrams
|
|
236
|
+
* @param buttonType the button that was clicked when closing the
|
|
237
|
+
* modal
|
|
238
|
+
*/
|
|
239
|
+
var handleClose = function (buttonType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
240
|
+
return __generator(this, function (_a) {
|
|
241
|
+
switch (_a.label) {
|
|
242
|
+
case 0:
|
|
243
|
+
// Don't close if no handler
|
|
244
|
+
if (!onClose) {
|
|
245
|
+
return [2 /*return*/];
|
|
246
|
+
}
|
|
247
|
+
// Don't close if animating in
|
|
248
|
+
if (animatingIn) {
|
|
249
|
+
return [2 /*return*/];
|
|
250
|
+
}
|
|
251
|
+
// Don't close if already closed
|
|
252
|
+
if (!visible) {
|
|
253
|
+
return [2 /*return*/];
|
|
254
|
+
}
|
|
255
|
+
// Update the state
|
|
256
|
+
setVisible(false);
|
|
257
|
+
// Call the handler after the modal has animated out
|
|
258
|
+
return [4 /*yield*/, (0, waitMs_1.default)(MS_TO_ANIMATE)];
|
|
259
|
+
case 1:
|
|
260
|
+
// Call the handler after the modal has animated out
|
|
261
|
+
_a.sent();
|
|
262
|
+
onClose(buttonType);
|
|
263
|
+
return [2 /*return*/];
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}); };
|
|
267
|
+
/*------------------------------------------------------------------------*/
|
|
268
|
+
/* Render */
|
|
269
|
+
/*------------------------------------------------------------------------*/
|
|
270
|
+
/*----------------------------------------*/
|
|
271
|
+
/* Footer */
|
|
272
|
+
/*----------------------------------------*/
|
|
273
|
+
// Get list of buttons for this modal type
|
|
274
|
+
var buttonTypes = (_a = modalTypeToButtonTypes[type]) !== null && _a !== void 0 ? _a : [];
|
|
275
|
+
// Create buttons
|
|
276
|
+
var buttons = buttonTypes.map(function (buttonType, i) {
|
|
277
|
+
// Get default style
|
|
278
|
+
var _a = buttonTypeToLabelAndVariant[buttonType], label = _a.label, variant = _a.variant;
|
|
279
|
+
// Override with customizations
|
|
280
|
+
if (props["".concat(buttonType, "Label")]) {
|
|
281
|
+
label = props["".concat(buttonType, "Label")];
|
|
282
|
+
}
|
|
283
|
+
if (props["".concat(buttonType, "Variant")]) {
|
|
284
|
+
variant = props["".concat(buttonType, "Variant")];
|
|
285
|
+
}
|
|
286
|
+
// Check if this button is last
|
|
287
|
+
var last = (i === buttonTypes.length - 1);
|
|
288
|
+
// Create the button
|
|
289
|
+
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 () {
|
|
290
|
+
handleClose(buttonType);
|
|
291
|
+
} }, { children: label })));
|
|
292
|
+
});
|
|
293
|
+
// Put all buttons in a footer
|
|
294
|
+
var footer = ((buttons && buttons.length)
|
|
295
|
+
? ((0, jsx_runtime_1.jsx)("div", { children: buttons }))
|
|
296
|
+
: undefined);
|
|
297
|
+
// Render the modal
|
|
298
|
+
return ((0, jsx_runtime_1.jsxs)(Modal_1.default, __assign({ show: visible, size: size !== ModalSize.Medium ? size : undefined, onHide: function () {
|
|
299
|
+
handleClose(ButtonType.Cancel);
|
|
300
|
+
}, style: { zIndex: 5000000000 }, backdropClassName: "Modal-backdrop", centered: true }, { children: [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 }))] })));
|
|
301
|
+
};
|
|
302
|
+
/*------------------------------------------------------------------------*/
|
|
303
|
+
/* Wrap Up */
|
|
304
|
+
/*------------------------------------------------------------------------*/
|
|
305
|
+
// Add enums
|
|
306
|
+
Modal.ModalType = ModalType;
|
|
307
|
+
Modal.ModalSize = ModalSize;
|
|
308
|
+
Modal.ButtonType = ButtonType;
|
|
309
|
+
Modal.Variant = Variant_1.default;
|
|
310
|
+
exports.default = Modal;
|
|
311
|
+
//# 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,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;IACZ,0BAAa,CAAA;IACb,uCAA0B,CAAA;IAC1B,6BAAgB,CAAA;IAChB,0CAA6B,CAAA;IAC7B,6CAAgC,CAAA;IAChC,2CAA8B,CAAA;IAC9B,2CAA8B,CAAA;IAC9B,6CAAgC,CAAA;IAChC,4BAAe,CAAA;AACjB,CAAC,EAVI,SAAS,KAAT,SAAS,QAUb;AAED,cAAc;AACd,IAAK,SAKJ;AALD,WAAK,SAAS;IACZ,yBAAY,CAAA;IACZ,0BAAa,CAAA;IACb,yBAAY,CAAA;IACZ,8BAAiB,CAAA;AACnB,CAAC,EALI,SAAS,KAAT,SAAS,QAKb;AAED,eAAe;AACf,IAAK,UA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AAI,EAAE,IAAI,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAClD,MAAM,EAAE;YACN,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,EAC7B,iBAAiB,EAAC,gBAAgB,EAClC,QAAQ,uBAEP,KAAK,IAAI,CACR,uBAAC,eAAc,CAAC,MAAM,aACpB,WAAW,EAAE,CAAC,CAAC,OAAO,gBAEtB,uBAAC,eAAc,CAAC,KAAK,cAClB,KAAK,GACe,IACD,CACzB,EACA,QAAQ,IAAI,CACX,uBAAC,eAAc,CAAC,IAAI,cACjB,QAAQ,GACW,CACvB,EACA,MAAM,IAAI,CACT,uBAAC,eAAc,CAAC,MAAM,cACnB,MAAM,GACe,CACzB,KACc,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAE5E,YAAY;AACZ,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;AAC5B,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;AAC5B,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;AAC9B,KAAK,CAAC,OAAO,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,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;
|