ag-common 0.0.419 → 0.0.421
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/dist/api/helpers/api.js +35 -34
- package/dist/api/helpers/aws.js +13 -9
- package/dist/api/helpers/cloudfront.js +24 -7
- package/dist/api/helpers/dynamo.js +134 -85
- package/dist/api/helpers/dynamoInfra.js +19 -14
- package/dist/api/helpers/enforceDynamoProvisionCap.js +18 -14
- package/dist/api/helpers/index.js +30 -14
- package/dist/api/helpers/openApiHelpers.js +37 -34
- package/dist/api/helpers/s3.js +126 -81
- package/dist/api/helpers/ses.js +28 -9
- package/dist/api/helpers/sqs.js +26 -9
- package/dist/api/helpers/ssm.js +14 -8
- package/dist/api/helpers/sts.js +34 -16
- package/dist/api/helpers/validateOpenApi.js +103 -92
- package/dist/api/helpers/validations.js +46 -29
- package/dist/api/index.js +18 -2
- package/dist/api/openapi-prefix.js +38 -25
- package/dist/api/types/aws.js +2 -1
- package/dist/api/types/index.js +17 -1
- package/dist/common/const.js +5 -2
- package/dist/common/helpers/array.js +19 -8
- package/dist/common/helpers/async.js +28 -10
- package/dist/common/helpers/binary.js +10 -5
- package/dist/common/helpers/date.js +25 -14
- package/dist/common/helpers/email.js +11 -5
- package/dist/common/helpers/func.js +7 -3
- package/dist/common/helpers/generator.js +24 -9
- package/dist/common/helpers/groupBy.js +9 -3
- package/dist/common/helpers/hashCode.js +9 -3
- package/dist/common/helpers/i18n.js +17 -9
- package/dist/common/helpers/index.js +34 -18
- package/dist/common/helpers/log.js +28 -16
- package/dist/common/helpers/math.js +21 -9
- package/dist/common/helpers/memo.js +7 -3
- package/dist/common/helpers/object.js +35 -20
- package/dist/common/helpers/random.js +10 -4
- package/dist/common/helpers/secondsInNearest.js +7 -2
- package/dist/common/helpers/sleep.js +5 -1
- package/dist/common/helpers/string/base64.js +7 -2
- package/dist/common/helpers/string/chunk.js +5 -1
- package/dist/common/helpers/string/contains.js +7 -2
- package/dist/common/helpers/string/getExtendedStringSegment.js +9 -5
- package/dist/common/helpers/string/index.js +26 -10
- package/dist/common/helpers/string/json.js +5 -1
- package/dist/common/helpers/string/object.js +5 -1
- package/dist/common/helpers/string/surround.js +5 -1
- package/dist/common/helpers/string/trim.js +7 -2
- package/dist/common/helpers/string/truncate.js +5 -1
- package/dist/common/helpers/string/url.js +9 -4
- package/dist/common/index.js +18 -2
- package/dist/index.js +19 -3
- package/dist/ui/components/BorderGradient/index.js +25 -18
- package/dist/ui/components/Button/index.js +25 -17
- package/dist/ui/components/Chevron/index.js +16 -9
- package/dist/ui/components/Close/index.js +13 -6
- package/dist/ui/components/Confirm/Dialog.js +25 -9
- package/dist/ui/components/Confirm/Modal.js +27 -20
- package/dist/ui/components/Confirm/index.js +19 -3
- package/dist/ui/components/Confirm/types.js +2 -1
- package/dist/ui/components/DropdownList/Base.js +64 -33
- package/dist/ui/components/DropdownList/Dialog.js +24 -8
- package/dist/ui/components/DropdownList/index.js +18 -2
- package/dist/ui/components/DropdownList/types.js +2 -1
- package/dist/ui/components/FlexColumn/index.js +14 -4
- package/dist/ui/components/FlexRow/index.js +14 -4
- package/dist/ui/components/HeadersRaw/index.js +27 -20
- package/dist/ui/components/HorizontalScrollBar/index.js +34 -6
- package/dist/ui/components/Icon/index.js +16 -9
- package/dist/ui/components/Image/index.js +28 -10
- package/dist/ui/components/InfiniteScroll/index.js +50 -18
- package/dist/ui/components/KebabDots/index.js +13 -6
- package/dist/ui/components/Loader/index.js +39 -9
- package/dist/ui/components/Modal/Dialog.js +23 -7
- package/dist/ui/components/Modal/Modal.js +49 -19
- package/dist/ui/components/Modal/index.js +19 -3
- package/dist/ui/components/Modal/types.js +2 -1
- package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.js +34 -26
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.js +19 -12
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/getCurlLines.js +11 -6
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.js +15 -8
- package/dist/ui/components/OpenApiCodeBlock/curl/index.js +21 -14
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/call.js +15 -8
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/getFetchLines.js +8 -3
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +34 -27
- package/dist/ui/components/OpenApiCodeBlock/fetch/index.js +18 -11
- package/dist/ui/components/OpenApiCodeBlock/helpers/common.js +17 -7
- package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.js +15 -6
- package/dist/ui/components/OpenApiCodeBlock/index.js +18 -2
- package/dist/ui/components/OpenApiCodeBlock/types.js +2 -1
- package/dist/ui/components/PieChart/index.js +18 -11
- package/dist/ui/components/ProgressBar/index.js +45 -15
- package/dist/ui/components/Prompt/Dialog.js +23 -7
- package/dist/ui/components/Prompt/Modal.js +55 -25
- package/dist/ui/components/Prompt/index.js +18 -2
- package/dist/ui/components/RowOrColumn/index.js +17 -7
- package/dist/ui/components/Search/AutoHideSearchBox.js +56 -24
- package/dist/ui/components/Search/Base.js +52 -21
- package/dist/ui/components/Search/Dialog.js +26 -10
- package/dist/ui/components/Search/Inline.js +10 -3
- package/dist/ui/components/Search/Modal.js +17 -10
- package/dist/ui/components/Search/SearchBox.js +58 -26
- package/dist/ui/components/Search/index.js +23 -7
- package/dist/ui/components/Search/types.js +2 -1
- package/dist/ui/components/Sidebar/index.js +25 -18
- package/dist/ui/components/SparkLine/index.js +27 -17
- package/dist/ui/components/Table/index.js +22 -15
- package/dist/ui/components/TextEdit/CheckboxEdit.js +51 -21
- package/dist/ui/components/TextEdit/ColourEdit.js +44 -17
- package/dist/ui/components/TextEdit/LengthBox.js +12 -5
- package/dist/ui/components/TextEdit/ListboxEdit.js +42 -15
- package/dist/ui/components/TextEdit/RadioGroup.js +43 -13
- package/dist/ui/components/TextEdit/TextEdit.js +78 -48
- package/dist/ui/components/TextEdit/common.js +17 -11
- package/dist/ui/components/TextEdit/index.js +22 -6
- package/dist/ui/components/TextEdit/types.js +2 -1
- package/dist/ui/components/TextWithButton/index.js +40 -10
- package/dist/ui/components/TimelineChart/index.js +24 -14
- package/dist/ui/components/Toast/Cross.js +16 -9
- package/dist/ui/components/Toast/Tick.js +11 -4
- package/dist/ui/components/Toast/Warning.js +15 -8
- package/dist/ui/components/Toast/base.js +65 -33
- package/dist/ui/components/Toast/index.js +18 -2
- package/dist/ui/components/Toast/types.js +2 -1
- package/dist/ui/components/UserImage/index.js +48 -17
- package/dist/ui/components/index.js +46 -30
- package/dist/ui/helpers/axiosHelper.js +39 -25
- package/dist/ui/helpers/browserHelpers.js +22 -7
- package/dist/ui/helpers/callOpenApi/cached.js +37 -18
- package/dist/ui/helpers/callOpenApi/direct.js +59 -46
- package/dist/ui/helpers/callOpenApi/helpers.js +40 -25
- package/dist/ui/helpers/callOpenApi/hook.js +36 -47
- package/dist/ui/helpers/callOpenApi/index.js +21 -5
- package/dist/ui/helpers/callOpenApi/types.js +2 -1
- package/dist/ui/helpers/cognito.js +2 -1
- package/dist/ui/helpers/cookie/const.js +5 -2
- package/dist/ui/helpers/cookie/get.js +14 -13
- package/dist/ui/helpers/cookie/index.js +21 -5
- package/dist/ui/helpers/cookie/raw.js +16 -9
- package/dist/ui/helpers/cookie/set.js +15 -10
- package/dist/ui/helpers/cookie/use.js +16 -23
- package/dist/ui/helpers/date.js +15 -10
- package/dist/ui/helpers/debounce.js +10 -5
- package/dist/ui/helpers/dom.js +13 -6
- package/dist/ui/helpers/extractAttributes.js +7 -2
- package/dist/ui/helpers/index.js +41 -25
- package/dist/ui/helpers/jwt.js +2 -1
- package/dist/ui/helpers/plural.js +5 -1
- package/dist/ui/helpers/routes.js +24 -17
- package/dist/ui/helpers/serviceWorker.js +23 -8
- package/dist/ui/helpers/useContextMenu.js +14 -9
- package/dist/ui/helpers/useElementAttribute.js +7 -3
- package/dist/ui/helpers/useGranularHook.js +10 -5
- package/dist/ui/helpers/useInterval.js +12 -8
- package/dist/ui/helpers/useLocalStorage.js +32 -24
- package/dist/ui/helpers/useLockBodyScroll.js +7 -3
- package/dist/ui/helpers/useOnClickOutside.js +12 -7
- package/dist/ui/helpers/useOnScroll.js +21 -15
- package/dist/ui/helpers/useOverloadPageSearch.js +7 -3
- package/dist/ui/helpers/useQueryString.js +20 -14
- package/dist/ui/helpers/useResize.js +19 -17
- package/dist/ui/helpers/useTimeout.js +9 -5
- package/dist/ui/icons/ChevronRight.js +9 -3
- package/dist/ui/icons/CrossIcon.js +12 -5
- package/dist/ui/icons/Door.js +10 -4
- package/dist/ui/icons/HorizontalDots.js +9 -3
- package/dist/ui/icons/Magnify.js +10 -3
- package/dist/ui/icons/Pencil.js +12 -5
- package/dist/ui/icons/Save.js +11 -4
- package/dist/ui/icons/Undo.js +12 -5
- package/dist/ui/icons/UserOutline.js +9 -3
- package/dist/ui/icons/index.js +25 -9
- package/dist/ui/index.js +20 -4
- package/dist/ui/styles/colours.js +12 -7
- package/dist/ui/styles/common.js +22 -14
- package/dist/ui/styles/index.js +20 -4
- package/dist/ui/styles/media.js +10 -7
- package/dist/ui/styles/standaloneStyles.js +16 -10
- package/package.json +2 -2
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
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
|
+
exports.Tick = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
2
8
|
//green tick
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
9
|
+
const Tick = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 64 64" },
|
|
10
|
+
react_1.default.createElement("circle", { cx: "32", cy: "32", r: "30", fill: "#fff" }),
|
|
11
|
+
react_1.default.createElement("path", { fill: "#7cb342", d: "M32 2C15.431 2 2 15.432 2 32c0 16.568 13.432 30 30 30 16.568 0 30-13.432 30-30C62 15.432 48.568 2 32 2zm-6.975 48-.02-.02-.017.02L11 35.6l7.029-7.164 6.977 7.184 21-21.619L53 21.199 25.025 50z" })));
|
|
12
|
+
exports.Tick = Tick;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
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
|
+
exports.Warning = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
2
8
|
//yellow warning
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const Warning = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 64 64" },
|
|
10
|
+
react_1.default.createElement("defs", null,
|
|
11
|
+
react_1.default.createElement("linearGradient", { id: "a", x2: "0", y1: "45.47", y2: "-.599", gradientTransform: "matrix(1.31117 0 0 1.30239 737.39 159.91)", gradientUnits: "userSpaceOnUse" },
|
|
12
|
+
react_1.default.createElement("stop", { stopColor: "#ffc515" }),
|
|
13
|
+
react_1.default.createElement("stop", { offset: "1", stopColor: "#ffd55b" }))),
|
|
14
|
+
react_1.default.createElement("path", { fill: "url(#a)", d: "m797.94 212.01-25.607-48c-.736-1.333-2.068-2.074-3.551-2.074s-2.822.889-3.569 2.222l-25.417 48c-.598 1.185-.605 2.815.132 4s1.921 1.778 3.404 1.778h51.02c1.483 0 2.821-.741 3.42-1.926.747-1.185.753-2.667.165-4", transform: "translate(-627.02 -130.8) scale(.85714)" }),
|
|
15
|
+
react_1.default.createElement("path", { fillOpacity: ".75", stroke: "#40330d", strokeWidth: ".90168", d: "M31.996 24.239a1.93 1.93 0 0 0-1.926 1.92v11.559c0 1.06.855 1.92 1.926 1.92a1.929 1.929 0 0 0 1.925-1.92v-11.56c0-1.06-.853-1.92-1.925-1.92zm0 19.249c-1.064 0-1.926.86-1.926 1.925 0 1.064.86 1.925 1.926 1.925 1.064 0 1.925-.86 1.925-1.925a1.922 1.922 0 0 0-1.925-1.925z" })));
|
|
16
|
+
exports.Warning = Warning;
|
|
@@ -1,19 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ToastProvider = exports.Toast = exports.ToastContext = void 0;
|
|
30
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const random_1 = require("../../../common/helpers/random");
|
|
33
|
+
const ProgressBar_1 = require("../ProgressBar");
|
|
34
|
+
const Cross_1 = require("./Cross");
|
|
35
|
+
const Tick_1 = require("./Tick");
|
|
36
|
+
const Warning_1 = require("./Warning");
|
|
37
|
+
exports.ToastContext = (0, react_1.createContext)({});
|
|
38
|
+
const ToastContainerStyle = styled_1.default.div `
|
|
10
39
|
position: fixed;
|
|
11
40
|
bottom: 0;
|
|
12
41
|
right: 0;
|
|
13
42
|
margin: 0.5rem;
|
|
14
43
|
z-index: 10000;
|
|
15
44
|
`;
|
|
16
|
-
const ToastStyle =
|
|
45
|
+
const ToastStyle = styled_1.default.div `
|
|
17
46
|
display: flex;
|
|
18
47
|
flex-flow: row wrap;
|
|
19
48
|
align-items: center;
|
|
@@ -33,7 +62,7 @@ const ToastStyle = styled.div `
|
|
|
33
62
|
color: black;
|
|
34
63
|
}
|
|
35
64
|
`;
|
|
36
|
-
const CloseStyle =
|
|
65
|
+
const CloseStyle = styled_1.default.span `
|
|
37
66
|
position: absolute;
|
|
38
67
|
top: 0;
|
|
39
68
|
right: 0;
|
|
@@ -58,38 +87,39 @@ const CloseStyle = styled.span `
|
|
|
58
87
|
}
|
|
59
88
|
}
|
|
60
89
|
`;
|
|
61
|
-
const Icon =
|
|
90
|
+
const Icon = styled_1.default.div `
|
|
62
91
|
width: 1.5rem;
|
|
63
92
|
height: 1.5rem;
|
|
64
93
|
margin-right: 0.5rem;
|
|
65
94
|
`;
|
|
66
|
-
const ProgressBarStyled =
|
|
95
|
+
const ProgressBarStyled = (0, styled_1.default)(ProgressBar_1.ProgressBar) `
|
|
67
96
|
height: 0.75rem;
|
|
68
97
|
margin-top: 0.5rem;
|
|
69
98
|
`;
|
|
70
|
-
|
|
71
|
-
|
|
99
|
+
const Toast = ({ toast, close, providerOptions, }) => {
|
|
100
|
+
var _a, _b, _c, _d, _e;
|
|
101
|
+
const darkMode = (_a = providerOptions === null || providerOptions === void 0 ? void 0 : providerOptions.darkMode) !== null && _a !== void 0 ? _a : false;
|
|
72
102
|
let closeMs;
|
|
73
|
-
if (toast.options
|
|
74
|
-
closeMs = toast.options
|
|
103
|
+
if ((_b = toast.options) === null || _b === void 0 ? void 0 : _b.autoClose) {
|
|
104
|
+
closeMs = (_c = toast.options) === null || _c === void 0 ? void 0 : _c.autoClose;
|
|
75
105
|
}
|
|
76
|
-
else if (toast.options
|
|
106
|
+
else if (((_d = toast.options) === null || _d === void 0 ? void 0 : _d.autoClose) === undefined) {
|
|
77
107
|
closeMs = 5000;
|
|
78
108
|
}
|
|
79
|
-
let icon =
|
|
80
|
-
switch (toast
|
|
109
|
+
let icon = react_1.default.createElement(Tick_1.Tick, null);
|
|
110
|
+
switch ((_e = toast === null || toast === void 0 ? void 0 : toast.options) === null || _e === void 0 ? void 0 : _e.appearance) {
|
|
81
111
|
case 'error': {
|
|
82
112
|
closeMs = undefined;
|
|
83
|
-
icon =
|
|
113
|
+
icon = react_1.default.createElement(Cross_1.Cross, null);
|
|
84
114
|
break;
|
|
85
115
|
}
|
|
86
116
|
case 'warning': {
|
|
87
117
|
closeMs = undefined;
|
|
88
|
-
icon =
|
|
118
|
+
icon = react_1.default.createElement(Warning_1.Warning, null);
|
|
89
119
|
break;
|
|
90
120
|
}
|
|
91
121
|
}
|
|
92
|
-
useEffect(() => {
|
|
122
|
+
(0, react_1.useEffect)(() => {
|
|
93
123
|
if (!closeMs) {
|
|
94
124
|
return;
|
|
95
125
|
}
|
|
@@ -97,21 +127,23 @@ export const Toast = ({ toast, close, providerOptions, }) => {
|
|
|
97
127
|
return () => clearTimeout(timeout);
|
|
98
128
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
99
129
|
}, []);
|
|
100
|
-
return (
|
|
101
|
-
|
|
102
|
-
|
|
130
|
+
return (react_1.default.createElement(ToastStyle, { "data-dark": darkMode },
|
|
131
|
+
react_1.default.createElement(CloseStyle, { "data-dark": darkMode, onClick: () => close(toast.id) }, "\u00D7"),
|
|
132
|
+
react_1.default.createElement(Icon, null, icon),
|
|
103
133
|
toast.message,
|
|
104
|
-
closeMs !== undefined && (
|
|
134
|
+
closeMs !== undefined && (react_1.default.createElement(ProgressBarStyled, { max: 100, min: 0, dotPercentages: null, transitionToMs: closeMs }))));
|
|
105
135
|
};
|
|
106
|
-
|
|
107
|
-
|
|
136
|
+
exports.Toast = Toast;
|
|
137
|
+
const ToastProvider = ({ children, providerOptions, }) => {
|
|
138
|
+
const [toasts, setToasts] = (0, react_1.useState)([]);
|
|
108
139
|
const addToast = (message, options) => setToasts((currentToasts) => [
|
|
109
140
|
...currentToasts,
|
|
110
|
-
{ id: random(10000).toString(), message, options },
|
|
141
|
+
{ id: (0, random_1.random)(10000).toString(), message, options },
|
|
111
142
|
]);
|
|
112
143
|
const close = (id) => setToasts((currentToasts) => currentToasts.filter((toast) => toast.id !== id));
|
|
113
|
-
const contextValue = useMemo(() => ({ addToast }), []);
|
|
114
|
-
return (
|
|
144
|
+
const contextValue = (0, react_1.useMemo)(() => ({ addToast }), []);
|
|
145
|
+
return (react_1.default.createElement(exports.ToastContext.Provider, { value: contextValue },
|
|
115
146
|
children,
|
|
116
|
-
|
|
147
|
+
react_1.default.createElement(ToastContainerStyle, null, toasts.map((toast) => (react_1.default.createElement(exports.Toast, { key: toast.id, toast: toast, close: close, providerOptions: providerOptions || {} }))))));
|
|
117
148
|
};
|
|
149
|
+
exports.ToastProvider = ToastProvider;
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,9 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.UserProfileImage = exports.UserImage = void 0;
|
|
30
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
31
|
+
const react_1 = __importStar(require("react"));
|
|
32
|
+
const array_1 = require("../../../common/helpers/array");
|
|
33
|
+
const log_1 = require("../../../common/helpers/log");
|
|
34
|
+
const UserOutline_1 = require("../../icons/UserOutline");
|
|
35
|
+
const Base = styled_1.default.div `
|
|
7
36
|
width: 2.5rem;
|
|
8
37
|
height: 2.5rem;
|
|
9
38
|
border-radius: 50%;
|
|
@@ -11,27 +40,29 @@ const Base = styled.div `
|
|
|
11
40
|
overflow: hidden;
|
|
12
41
|
position: relative;
|
|
13
42
|
`;
|
|
14
|
-
const Img =
|
|
43
|
+
const Img = styled_1.default.img `
|
|
15
44
|
width: 2.5rem;
|
|
16
45
|
height: 2.5rem;
|
|
17
46
|
`;
|
|
18
47
|
const images = {
|
|
19
48
|
domains: ['platform-lookaside.fbsbx.com', 'lh3.googleusercontent.com'],
|
|
20
49
|
};
|
|
21
|
-
|
|
22
|
-
const [fallback, setFallback] = useState(false);
|
|
23
|
-
return (
|
|
24
|
-
image && !fallback && (
|
|
25
|
-
(!image || fallback) && UserOutline));
|
|
50
|
+
const UserImage = ({ image, className, title = 'user image', }) => {
|
|
51
|
+
const [fallback, setFallback] = (0, react_1.useState)(false);
|
|
52
|
+
return (react_1.default.createElement(Base, { className: className, title: title },
|
|
53
|
+
image && !fallback && (react_1.default.createElement(Img, { alt: "user", src: image, onError: () => setFallback(true) })),
|
|
54
|
+
(!image || fallback) && UserOutline_1.UserOutline));
|
|
26
55
|
};
|
|
27
|
-
|
|
28
|
-
|
|
56
|
+
exports.UserImage = UserImage;
|
|
57
|
+
const UserProfileImage = ({ className, user }) => {
|
|
58
|
+
const image = user === null || user === void 0 ? void 0 : user.picture;
|
|
29
59
|
if (image) {
|
|
30
60
|
if (!images.domains.find((i) => image.includes(i))) {
|
|
31
|
-
warn(`bad domain:${image}`);
|
|
61
|
+
(0, log_1.warn)(`bad domain:${image}`);
|
|
32
62
|
}
|
|
33
63
|
}
|
|
34
|
-
const titleA = [user
|
|
64
|
+
const titleA = [user === null || user === void 0 ? void 0 : user.fullname, user === null || user === void 0 ? void 0 : user.userId].filter(array_1.notEmpty);
|
|
35
65
|
const title = titleA.length === 0 ? '' : titleA.join(' - ');
|
|
36
|
-
return
|
|
66
|
+
return react_1.default.createElement(exports.UserImage, { image: image, title: title, className: className });
|
|
37
67
|
};
|
|
68
|
+
exports.UserProfileImage = UserProfileImage;
|
|
@@ -1,30 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./BorderGradient"), exports);
|
|
18
|
+
__exportStar(require("./Button"), exports);
|
|
19
|
+
__exportStar(require("./Chevron"), exports);
|
|
20
|
+
__exportStar(require("./Close"), exports);
|
|
21
|
+
__exportStar(require("./Confirm"), exports);
|
|
22
|
+
__exportStar(require("./DropdownList"), exports);
|
|
23
|
+
__exportStar(require("./FlexColumn"), exports);
|
|
24
|
+
__exportStar(require("./FlexRow"), exports);
|
|
25
|
+
__exportStar(require("./HeadersRaw"), exports);
|
|
26
|
+
__exportStar(require("./HorizontalScrollBar"), exports);
|
|
27
|
+
__exportStar(require("./Icon"), exports);
|
|
28
|
+
__exportStar(require("./Image"), exports);
|
|
29
|
+
__exportStar(require("./InfiniteScroll"), exports);
|
|
30
|
+
__exportStar(require("./KebabDots"), exports);
|
|
31
|
+
__exportStar(require("./Loader"), exports);
|
|
32
|
+
__exportStar(require("./Modal"), exports);
|
|
33
|
+
__exportStar(require("./OpenApiCodeBlock"), exports);
|
|
34
|
+
__exportStar(require("./PieChart"), exports);
|
|
35
|
+
__exportStar(require("./ProgressBar"), exports);
|
|
36
|
+
__exportStar(require("./Prompt"), exports);
|
|
37
|
+
__exportStar(require("./RowOrColumn"), exports);
|
|
38
|
+
__exportStar(require("./Search"), exports);
|
|
39
|
+
__exportStar(require("./Sidebar"), exports);
|
|
40
|
+
__exportStar(require("./SparkLine"), exports);
|
|
41
|
+
__exportStar(require("./Table"), exports);
|
|
42
|
+
__exportStar(require("./TextEdit"), exports);
|
|
43
|
+
__exportStar(require("./TextWithButton"), exports);
|
|
44
|
+
__exportStar(require("./TimelineChart"), exports);
|
|
45
|
+
__exportStar(require("./Toast"), exports);
|
|
46
|
+
__exportStar(require("./UserImage"), exports);
|
|
@@ -1,24 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.axiosHelper = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const const_1 = require("../../common/const");
|
|
18
|
+
const log_1 = require("../../common/helpers/log");
|
|
19
|
+
const object_1 = require("../../common/helpers/object");
|
|
20
|
+
const sleep_1 = require("../../common/helpers/sleep");
|
|
6
21
|
/**
|
|
7
22
|
*
|
|
8
23
|
* @param body accepts object or json, and passes as-is
|
|
9
24
|
* @returns
|
|
10
25
|
*/
|
|
11
|
-
|
|
26
|
+
const axiosHelper = ({ verb, url, body, headers, timeout = 30000, retryMax = 0, onStaleAuth, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
var _a;
|
|
12
28
|
let retry = 0;
|
|
13
29
|
let ret;
|
|
14
30
|
do {
|
|
15
31
|
try {
|
|
16
|
-
const setHeaders = {
|
|
17
|
-
Accept: 'application/json',
|
|
18
|
-
...headers,
|
|
19
|
-
};
|
|
32
|
+
const setHeaders = Object.assign({ Accept: 'application/json' }, headers);
|
|
20
33
|
if (verb === 'get') {
|
|
21
|
-
ret =
|
|
34
|
+
ret = yield axios_1.default.get(url, {
|
|
22
35
|
headers: setHeaders,
|
|
23
36
|
timeout,
|
|
24
37
|
timeoutErrorMessage: `${url} timeout`,
|
|
@@ -27,53 +40,54 @@ export const axiosHelper = async ({ verb, url, body, headers, timeout = 30000, r
|
|
|
27
40
|
}
|
|
28
41
|
let noBody = false;
|
|
29
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
-
let axiosV =
|
|
43
|
+
let axiosV = axios_1.default.post;
|
|
31
44
|
if (verb === 'put') {
|
|
32
|
-
axiosV =
|
|
45
|
+
axiosV = axios_1.default.put;
|
|
33
46
|
}
|
|
34
47
|
else if (verb === 'post') {
|
|
35
|
-
axiosV =
|
|
48
|
+
axiosV = axios_1.default.post;
|
|
36
49
|
}
|
|
37
50
|
else if (verb === 'patch') {
|
|
38
|
-
axiosV =
|
|
51
|
+
axiosV = axios_1.default.patch;
|
|
39
52
|
}
|
|
40
53
|
else if (verb === 'delete') {
|
|
41
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
axiosV =
|
|
55
|
+
axiosV = axios_1.default.delete;
|
|
43
56
|
noBody = true;
|
|
44
57
|
}
|
|
45
58
|
if (noBody) {
|
|
46
|
-
ret =
|
|
59
|
+
ret = yield axiosV(url, {
|
|
47
60
|
headers: setHeaders,
|
|
48
61
|
timeout,
|
|
49
62
|
timeoutErrorMessage: `${url} timeout`,
|
|
50
63
|
});
|
|
51
64
|
}
|
|
52
65
|
else {
|
|
53
|
-
if (body && isJson(body)) {
|
|
66
|
+
if (body && (0, object_1.isJson)(body)) {
|
|
54
67
|
setHeaders['Content-Type'] =
|
|
55
68
|
setHeaders['Content-Type'] || 'application/json';
|
|
56
69
|
}
|
|
57
|
-
ret =
|
|
70
|
+
ret = yield axiosV(url, body, { headers: setHeaders });
|
|
58
71
|
}
|
|
59
72
|
return ret;
|
|
60
73
|
}
|
|
61
74
|
catch (e) {
|
|
62
75
|
const em = e;
|
|
63
|
-
const c = Number(em.code
|
|
76
|
+
const c = Number((_a = em.code) !== null && _a !== void 0 ? _a : '500');
|
|
64
77
|
// jwt expired or bad response
|
|
65
78
|
// 403 returned for old token - will be refreshed
|
|
66
79
|
if (c === 401 || c === 403) {
|
|
67
|
-
debug('auth expired');
|
|
68
|
-
onStaleAuth
|
|
80
|
+
(0, log_1.debug)('auth expired');
|
|
81
|
+
onStaleAuth === null || onStaleAuth === void 0 ? void 0 : onStaleAuth();
|
|
69
82
|
retry = retryMax;
|
|
70
83
|
}
|
|
71
|
-
if (!retryHttpCodes.includes(c) || retry >= retryMax) {
|
|
84
|
+
if (!const_1.retryHttpCodes.includes(c) || retry >= retryMax) {
|
|
72
85
|
throw em;
|
|
73
86
|
}
|
|
74
87
|
}
|
|
75
88
|
retry += 1;
|
|
76
|
-
|
|
89
|
+
yield (0, sleep_1.sleep)(const_1.retryHttpMs);
|
|
77
90
|
} while (retry <= retryMax);
|
|
78
91
|
throw new Error('unexpected');
|
|
79
|
-
};
|
|
92
|
+
});
|
|
93
|
+
exports.axiosHelper = axiosHelper;
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.supportsWebp = void 0;
|
|
13
|
+
function supportsWebp() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
if (!window.createImageBitmap) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const webpData = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=';
|
|
19
|
+
const blob = yield fetch(webpData).then((r) => r.blob());
|
|
20
|
+
return createImageBitmap(blob).then(() => true, () => false);
|
|
21
|
+
});
|
|
8
22
|
}
|
|
23
|
+
exports.supportsWebp = supportsWebp;
|