ag-common 0.0.3
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.d.ts +16 -0
- package/dist/api/helpers/api.js +67 -0
- package/dist/api/helpers/dynamo.d.ts +44 -0
- package/dist/api/helpers/dynamo.js +307 -0
- package/dist/api/helpers/dynamoInfra.d.ts +15 -0
- package/dist/api/helpers/dynamoInfra.js +64 -0
- package/dist/api/helpers/index.d.ts +3 -0
- package/dist/api/helpers/index.js +15 -0
- package/dist/api/helpers/openApiHelpers.d.ts +14 -0
- package/dist/api/helpers/openApiHelpers.js +131 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +14 -0
- package/dist/api/types.d.ts +45 -0
- package/dist/api/types.js +2 -0
- package/dist/common/helpers/array.d.ts +9 -0
- package/dist/common/helpers/array.js +51 -0
- package/dist/common/helpers/distinctBy.d.ts +8 -0
- package/dist/common/helpers/distinctBy.js +35 -0
- package/dist/common/helpers/email.d.ts +7 -0
- package/dist/common/helpers/email.js +35 -0
- package/dist/common/helpers/groupBy.d.ts +22 -0
- package/dist/common/helpers/groupBy.js +53 -0
- package/dist/common/helpers/hashCode.d.ts +2 -0
- package/dist/common/helpers/hashCode.js +27 -0
- package/dist/common/helpers/i18n.d.ts +11 -0
- package/dist/common/helpers/i18n.js +14 -0
- package/dist/common/helpers/index.d.ts +12 -0
- package/dist/common/helpers/index.js +24 -0
- package/dist/common/helpers/log.d.ts +5 -0
- package/dist/common/helpers/log.js +25 -0
- package/dist/common/helpers/math.d.ts +11 -0
- package/dist/common/helpers/math.js +65 -0
- package/dist/common/helpers/object.d.ts +17 -0
- package/dist/common/helpers/object.js +54 -0
- package/dist/common/helpers/random.d.ts +1 -0
- package/dist/common/helpers/random.js +26 -0
- package/dist/common/helpers/secondsInNearest.d.ts +8 -0
- package/dist/common/helpers/secondsInNearest.js +39 -0
- package/dist/common/helpers/string.d.ts +9 -0
- package/dist/common/helpers/string.js +62 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +13 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +15 -0
- package/dist/ui/components/Button/index.d.ts +11 -0
- package/dist/ui/components/Button/index.js +45 -0
- package/dist/ui/components/Dropdown/index.d.ts +10 -0
- package/dist/ui/components/Dropdown/index.js +61 -0
- package/dist/ui/components/DropdownList/index.d.ts +9 -0
- package/dist/ui/components/DropdownList/index.js +124 -0
- package/dist/ui/components/FlexColumn/index.d.ts +6 -0
- package/dist/ui/components/FlexColumn/index.js +31 -0
- package/dist/ui/components/FlexRow/index.d.ts +7 -0
- package/dist/ui/components/FlexRow/index.js +42 -0
- package/dist/ui/components/HeadersRaw/index.d.ts +10 -0
- package/dist/ui/components/HeadersRaw/index.js +44 -0
- package/dist/ui/components/Input/index.d.ts +15 -0
- package/dist/ui/components/Input/index.js +54 -0
- package/dist/ui/components/Loader/index.d.ts +4 -0
- package/dist/ui/components/Loader/index.js +69 -0
- package/dist/ui/components/LoginButton/index.d.ts +12 -0
- package/dist/ui/components/LoginButton/index.js +32 -0
- package/dist/ui/components/LoginButton/text.d.ts +3 -0
- package/dist/ui/components/LoginButton/text.js +9 -0
- package/dist/ui/components/Modal/Close.d.ts +5 -0
- package/dist/ui/components/Modal/Close.js +37 -0
- package/dist/ui/components/Modal/index.d.ts +21 -0
- package/dist/ui/components/Modal/index.js +93 -0
- package/dist/ui/components/RowOrColumn/index.d.ts +6 -0
- package/dist/ui/components/RowOrColumn/index.js +40 -0
- package/dist/ui/components/Table/index.d.ts +9 -0
- package/dist/ui/components/Table/index.js +31 -0
- package/dist/ui/components/TextEdit/CheckboxEdit.d.ts +5 -0
- package/dist/ui/components/TextEdit/CheckboxEdit.js +59 -0
- package/dist/ui/components/TextEdit/ColourEdit.d.ts +5 -0
- package/dist/ui/components/TextEdit/ColourEdit.js +48 -0
- package/dist/ui/components/TextEdit/ListboxEdit.d.ts +6 -0
- package/dist/ui/components/TextEdit/ListboxEdit.js +41 -0
- package/dist/ui/components/TextEdit/TextEdit.d.ts +13 -0
- package/dist/ui/components/TextEdit/TextEdit.js +95 -0
- package/dist/ui/components/TextEdit/common.d.ts +5 -0
- package/dist/ui/components/TextEdit/common.js +70 -0
- package/dist/ui/components/TextEdit/images.d.ts +4 -0
- package/dist/ui/components/TextEdit/images.js +21 -0
- package/dist/ui/components/TextEdit/index.d.ts +4 -0
- package/dist/ui/components/TextEdit/index.js +16 -0
- package/dist/ui/components/TextInput/index.d.ts +12 -0
- package/dist/ui/components/TextInput/index.js +30 -0
- package/dist/ui/components/Toast/index.d.ts +11 -0
- package/dist/ui/components/Toast/index.js +42 -0
- package/dist/ui/components/UserImage/index.d.ts +8 -0
- package/dist/ui/components/UserImage/index.js +66 -0
- package/dist/ui/components/index.d.ts +16 -0
- package/dist/ui/components/index.js +28 -0
- package/dist/ui/helpers/browserHelpers.d.ts +1 -0
- package/dist/ui/helpers/browserHelpers.js +23 -0
- package/dist/ui/helpers/callOpenApi.d.ts +13 -0
- package/dist/ui/helpers/callOpenApi.js +85 -0
- package/dist/ui/helpers/cookie.d.ts +14 -0
- package/dist/ui/helpers/cookie.js +110 -0
- package/dist/ui/helpers/debounce.d.ts +6 -0
- package/dist/ui/helpers/debounce.js +33 -0
- package/dist/ui/helpers/dom.d.ts +1 -0
- package/dist/ui/helpers/dom.js +10 -0
- package/dist/ui/helpers/extractAttributes.d.ts +3 -0
- package/dist/ui/helpers/extractAttributes.js +17 -0
- package/dist/ui/helpers/index.d.ts +17 -0
- package/dist/ui/helpers/index.js +29 -0
- package/dist/ui/helpers/lang.d.ts +5 -0
- package/dist/ui/helpers/lang.js +23 -0
- package/dist/ui/helpers/mutex.d.ts +22 -0
- package/dist/ui/helpers/mutex.js +53 -0
- package/dist/ui/helpers/mutexData.d.ts +12 -0
- package/dist/ui/helpers/mutexData.js +46 -0
- package/dist/ui/helpers/plural.d.ts +1 -0
- package/dist/ui/helpers/plural.js +13 -0
- package/dist/ui/helpers/routes.d.ts +34 -0
- package/dist/ui/helpers/routes.js +2 -0
- package/dist/ui/helpers/useLocalStorage.d.ts +5 -0
- package/dist/ui/helpers/useLocalStorage.js +80 -0
- package/dist/ui/helpers/useLockBodyScroll.d.ts +1 -0
- package/dist/ui/helpers/useLockBodyScroll.js +19 -0
- package/dist/ui/helpers/useOnClickOutside.d.ts +7 -0
- package/dist/ui/helpers/useOnClickOutside.js +28 -0
- package/dist/ui/helpers/useOnScroll.d.ts +6 -0
- package/dist/ui/helpers/useOnScroll.js +33 -0
- package/dist/ui/helpers/useOpenApiStore.d.ts +14 -0
- package/dist/ui/helpers/useOpenApiStore.js +145 -0
- package/dist/ui/helpers/useQueryString.d.ts +8 -0
- package/dist/ui/helpers/useQueryString.js +38 -0
- package/dist/ui/helpers/useResize.d.ts +8 -0
- package/dist/ui/helpers/useResize.js +33 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.js +15 -0
- package/dist/ui/styles/colours.d.ts +25 -0
- package/dist/ui/styles/colours.js +51 -0
- package/dist/ui/styles/common.d.ts +13 -0
- package/dist/ui/styles/common.js +94 -0
- package/dist/ui/styles/index.d.ts +4 -0
- package/dist/ui/styles/index.js +16 -0
- package/dist/ui/styles/media.d.ts +5 -0
- package/dist/ui/styles/media.js +8 -0
- package/dist/ui/styles/standaloneStyles.d.ts +6 -0
- package/dist/ui/styles/standaloneStyles.js +69 -0
- package/package.json +40 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.TextEdit = void 0;
|
|
26
|
+
/* eslint-disable jsx-a11y/no-onchange */
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const images_1 = require("./images");
|
|
29
|
+
const common_1 = require("./common");
|
|
30
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
31
|
+
const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
|
|
32
|
+
const common_2 = require("../../styles/common");
|
|
33
|
+
const ValueTextArea = styled_components_1.default.textarea `
|
|
34
|
+
${common_1.valueCss};
|
|
35
|
+
resize: none;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
`;
|
|
38
|
+
const TextEdit = ({ defaultValue, defaultEditing = false, onSubmit, canEdit = true, placeholder, onEditingChange, onClickOutsideWithNoValue, onClickNotEditing, className, singleLine = false, }) => {
|
|
39
|
+
const ref = (0, react_1.useRef)(null);
|
|
40
|
+
const taref = (0, react_1.useRef)(null);
|
|
41
|
+
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
42
|
+
const [editing, setEditingRaw] = (0, react_1.useState)(defaultEditing);
|
|
43
|
+
const valueChange = value !== defaultValue;
|
|
44
|
+
(0, useOnClickOutside_1.useOnClickOutside)({ ref, moveMouseOutside: false }, () => {
|
|
45
|
+
if (valueChange) {
|
|
46
|
+
onSubmit(value);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (onClickOutsideWithNoValue) {
|
|
50
|
+
onClickOutsideWithNoValue();
|
|
51
|
+
}
|
|
52
|
+
setEditingRaw(false);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const setEditing = (b) => {
|
|
56
|
+
setEditingRaw(b);
|
|
57
|
+
if (onEditingChange) {
|
|
58
|
+
onEditingChange(b);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
(0, react_1.useEffect)(() => {
|
|
62
|
+
setValue(defaultValue);
|
|
63
|
+
//setEditing(false);
|
|
64
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
+
}, [defaultValue]);
|
|
66
|
+
(0, react_1.useEffect)(() => {
|
|
67
|
+
if (defaultEditing && taref.current) {
|
|
68
|
+
taref.current.focus();
|
|
69
|
+
}
|
|
70
|
+
setEditing(defaultEditing);
|
|
71
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
+
}, [defaultEditing]);
|
|
73
|
+
if (!editing || !canEdit) {
|
|
74
|
+
return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag, { className: className, "data-editing": "false", onClick: () => onClickNotEditing === null || onClickNotEditing === void 0 ? void 0 : onClickNotEditing(), "data-pointer": onClickNotEditing ? 'true' : 'false' }),
|
|
75
|
+
react_1.default.createElement(common_1.ValueReadonly, { "data-type": "text" }, value),
|
|
76
|
+
canEdit && (react_1.default.createElement(common_1.Icon, { style: { right: '0.5rem' }, onClick: (e) => {
|
|
77
|
+
e.stopPropagation();
|
|
78
|
+
setEditing(true);
|
|
79
|
+
} },
|
|
80
|
+
react_1.default.createElement(images_1.PencilIcon, null)))));
|
|
81
|
+
}
|
|
82
|
+
if (!open) {
|
|
83
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
84
|
+
}
|
|
85
|
+
return (react_1.default.createElement(common_1.ValueBox, Object.assign({ "data-editing": "true" }, common_2.noDrag, { ref: ref, tabIndex: editing ? 0 : undefined, className: className }),
|
|
86
|
+
react_1.default.createElement(ValueTextArea, { "data-valuechange": valueChange.toString(), ref: taref, "data-type": "text", value: value, onChange: (v) => setValue(v.currentTarget.value), placeholder: placeholder, rows: singleLine ? 1 : undefined, onKeyDown: (e) => singleLine && e.code.endsWith('Enter') && onSubmit(value) && false }),
|
|
87
|
+
valueChange && (react_1.default.createElement(common_1.Icon, { style: { right: '2rem' }, onClick: () => valueChange && onSubmit(value) },
|
|
88
|
+
react_1.default.createElement(images_1.SaveIcon, null))),
|
|
89
|
+
(valueChange || editing !== defaultEditing) && (react_1.default.createElement(common_1.Icon, { style: { right: '0.5rem' }, onClick: () => {
|
|
90
|
+
setEditing(defaultEditing);
|
|
91
|
+
setValue(defaultValue);
|
|
92
|
+
} },
|
|
93
|
+
react_1.default.createElement(images_1.UndoIcon, null)))));
|
|
94
|
+
};
|
|
95
|
+
exports.TextEdit = TextEdit;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const ValueBox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const valueCss: import("styled-components").FlattenSimpleInterpolation;
|
|
3
|
+
export declare const ValueInputCB: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
4
|
+
export declare const ValueReadonly: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const Icon: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.Icon = exports.ValueReadonly = exports.ValueInputCB = exports.valueCss = exports.ValueBox = void 0;
|
|
23
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
24
|
+
const colours_1 = require("../../styles/colours");
|
|
25
|
+
exports.ValueBox = styled_components_1.default.div `
|
|
26
|
+
padding: 0.5rem;
|
|
27
|
+
|
|
28
|
+
display: flex;
|
|
29
|
+
position: relative;
|
|
30
|
+
align-items: center;
|
|
31
|
+
|
|
32
|
+
justify-content: flex-start;
|
|
33
|
+
flex-grow: 1;
|
|
34
|
+
max-width: 100%;
|
|
35
|
+
&[data-editing='false'] {
|
|
36
|
+
padding-right: 2rem;
|
|
37
|
+
}
|
|
38
|
+
&[data-pointer='true'] {
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
exports.valueCss = (0, styled_components_1.css) `
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: 100%;
|
|
45
|
+
word-break: break-all;
|
|
46
|
+
font-size: 1rem;
|
|
47
|
+
|
|
48
|
+
&[data-type='checkbox'] {
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
width: 1.5rem;
|
|
51
|
+
height: 1.5rem;
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
exports.ValueInputCB = styled_components_1.default.input `
|
|
55
|
+
${exports.valueCss};
|
|
56
|
+
`;
|
|
57
|
+
exports.ValueReadonly = styled_components_1.default.div `
|
|
58
|
+
${exports.valueCss};
|
|
59
|
+
`;
|
|
60
|
+
exports.Icon = styled_components_1.default.div `
|
|
61
|
+
z-index: 1;
|
|
62
|
+
font-size: 1rem;
|
|
63
|
+
width: 1.5rem;
|
|
64
|
+
height: 1.5rem;
|
|
65
|
+
position: absolute;
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
svg {
|
|
68
|
+
fill: ${colours_1.colours.notificationBlue};
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
@@ -0,0 +1,21 @@
|
|
|
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.SaveIcon = exports.PencilIcon = exports.UndoIcon = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const UndoIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 64 64" },
|
|
9
|
+
react_1.default.createElement("g", { fill: "#134563" },
|
|
10
|
+
react_1.default.createElement("path", { d: "M32.1 51.9c-7.8 0-14.9-4.6-18.1-11.6l2.6-1.2c2.8 6 8.9 9.9 15.5 9.9 9.4 0 17-7.6 17-17s-7.6-17-17-17C25 15 19 19.4 16.5 26.4l-2.7-1c2.9-8.1 10-13.3 18.3-13.3C43.1 12.1 52 21 52 32s-9 19.9-19.9 19.9" }),
|
|
11
|
+
react_1.default.createElement("path", { d: "M24.4 27.4H12V15.1h3.1v9.2h9.3v3.1" }))));
|
|
12
|
+
exports.UndoIcon = UndoIcon;
|
|
13
|
+
const PencilIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 50 50" },
|
|
14
|
+
react_1.default.createElement("path", { d: "M9.6 40.4l2.5-9.9L27 15.6l7.4 7.4-14.9 14.9-9.9 2.5zm4.3-8.9l-1.5 6.1 6.1-1.5L31.6 23 27 18.4 13.9 31.5z" }),
|
|
15
|
+
react_1.default.createElement("path", { d: "M17.8 37.3c-.6-2.5-2.6-4.5-5.1-5.1l.5-1.9c3.2.8 5.7 3.3 6.5 6.5l-1.9.5z" }),
|
|
16
|
+
react_1.default.createElement("path", { d: "M29.298 19.287l1.414 1.414-13.01 13.02-1.414-1.412zM11 39l2.9-.7c-.3-1.1-1.1-1.9-2.2-2.2L11 39zM35 22.4L27.6 15l3-3 .5.1c3.6.5 6.4 3.3 6.9 6.9l.1.5-3.1 2.9zM30.4 15l4.6 4.6.9-.9c-.5-2.3-2.3-4.1-4.6-4.6l-.9.9z" })));
|
|
17
|
+
exports.PencilIcon = PencilIcon;
|
|
18
|
+
const SaveIcon = () => (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 100 100" },
|
|
19
|
+
react_1.default.createElement("path", { d: "M50 12c-21 0-38 17-38 38s17 38 38 38 38-17 38-38-17-38-38-38zm0 72c-18.8 0-34-15.2-34-34s15.2-34 34-34 34 15.2 34 34-15.2 34-34 34zm22.9-46.9c-.8-.8-2-.8-2.8 0L44.6 62.7 33.9 52c-.8-.8-2.1-.8-2.8 0-.8.8-.8 2.1 0 2.8l12.1 12.1c.4.4.9.6 1.4.6.5 0 1-.2 1.4-.6l26.9-27c.8-.8.8-2 0-2.8z" }),
|
|
20
|
+
react_1.default.createElement("path", { fill: "#00F", d: "M1644-1210V474H-140v-1684h1784m8-8H-148V482h1800v-1700z" })));
|
|
21
|
+
exports.SaveIcon = SaveIcon;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./CheckboxEdit"), exports);
|
|
14
|
+
__exportStar(require("./ColourEdit"), exports);
|
|
15
|
+
__exportStar(require("./ListboxEdit"), exports);
|
|
16
|
+
__exportStar(require("./TextEdit"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputTypes } from '../Input';
|
|
3
|
+
export declare const TextInput: ({ type, placeholder, value, onChange, onKeyPress, label, disabled, className, }: {
|
|
4
|
+
className?: string | undefined;
|
|
5
|
+
disabled?: boolean | undefined;
|
|
6
|
+
label?: string | JSX.Element | undefined;
|
|
7
|
+
placeholder?: string | undefined;
|
|
8
|
+
type: InputTypes;
|
|
9
|
+
value: string;
|
|
10
|
+
onChange: (value: string) => void;
|
|
11
|
+
onKeyPress?: ((event: React.KeyboardEvent<HTMLInputElement>) => void) | undefined;
|
|
12
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.TextInput = void 0;
|
|
23
|
+
const react_1 = __importStar(require("react"));
|
|
24
|
+
const math_1 = require("../../../common/helpers/math");
|
|
25
|
+
const Input_1 = require("../Input");
|
|
26
|
+
const TextInput = ({ type = 'text', placeholder, value, onChange, onKeyPress, label, disabled = false, className, }) => {
|
|
27
|
+
const [id] = (0, react_1.useState)((0, math_1.getRandomInt)(1000).toString());
|
|
28
|
+
return (react_1.default.createElement(Input_1.Input, { className: className, disabled: disabled, id: id, label: label, type: type, placeholder: placeholder, required: true, value: value, onChange: (e) => onChange(e.target.value), onKeyPress: (e) => onKeyPress && onKeyPress(e) }));
|
|
29
|
+
};
|
|
30
|
+
exports.TextInput = TextInput;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ToastPosition } from 'react-hot-toast';
|
|
3
|
+
interface Options {
|
|
4
|
+
appearance: 'error' | 'success';
|
|
5
|
+
autoClose?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const addToast: (m: string, options?: Options | undefined) => void;
|
|
8
|
+
export declare const ToastProvider: ({ position }: {
|
|
9
|
+
position: ToastPosition;
|
|
10
|
+
}) => JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.ToastProvider = exports.addToast = void 0;
|
|
26
|
+
const react_hot_toast_1 = __importStar(require("react-hot-toast"));
|
|
27
|
+
const react_1 = __importDefault(require("react"));
|
|
28
|
+
const addToast = (m, options) => {
|
|
29
|
+
if ((options === null || options === void 0 ? void 0 : options.appearance) === 'error') {
|
|
30
|
+
react_hot_toast_1.default.error(m, {
|
|
31
|
+
duration: (options === null || options === void 0 ? void 0 : options.autoClose) || 5000,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
react_hot_toast_1.default.success(m, {
|
|
36
|
+
duration: (options === null || options === void 0 ? void 0 : options.autoClose) || 5000,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.addToast = addToast;
|
|
41
|
+
const ToastProvider = ({ position }) => (react_1.default.createElement(react_hot_toast_1.Toaster, { position: position }));
|
|
42
|
+
exports.ToastProvider = ToastProvider;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AuthedUserContext } from 'analytica.click';
|
|
3
|
+
export declare const UserImage: ({ image, className, showProfilePicture, CognitoAuthContext, }: {
|
|
4
|
+
image?: string | undefined;
|
|
5
|
+
className?: string | undefined;
|
|
6
|
+
showProfilePicture?: boolean | undefined;
|
|
7
|
+
CognitoAuthContext: React.Context<AuthedUserContext>;
|
|
8
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.UserImage = void 0;
|
|
26
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const log_1 = require("../../../common/helpers/log");
|
|
29
|
+
const array_1 = require("../../../common/helpers/array");
|
|
30
|
+
const User = (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512" },
|
|
31
|
+
react_1.default.createElement("path", { d: "M256 48C141.1 48 48 141.1 48 256s93.1 208 208 208 208-93.1 208-208S370.9 48 256 48zm0 398.7c-58.6 0-111.1-26.6-146.1-68.3 17.8-7.7 62.2-23.7 90.3-31.9 2.2-.7 2.6-.8 2.6-10.7 0-10.6-1.2-18.1-3.8-23.6-3.5-7.5-7.7-20.2-9.2-31.6-4.2-4.9-9.9-14.5-13.6-32.9-3.2-16.2-1.7-22.1.4-27.6.2-.6.5-1.2.6-1.8.8-3.7-.3-23.5-3.1-38.8-1.9-10.5.5-32.8 15-51.3 9.1-11.7 26.6-26 58-28h17.5c31.9 2 49.4 16.3 58.5 28 14.5 18.5 16.9 40.8 14.9 51.3-2.8 15.3-3.9 35-3.1 38.8.1.6.4 1.2.6 1.7 2.1 5.5 3.7 11.4.4 27.6-3.7 18.4-9.4 28-13.6 32.9-1.5 11.4-5.7 24-9.2 31.6-3.3 6.9-6.6 15.1-6.6 23.3 0 9.9.4 10 2.7 10.7 26.7 7.9 72.7 23.8 93 32.1-35 41.8-87.5 68.5-146.2 68.5z" })));
|
|
32
|
+
const Base = styled_components_1.default.div `
|
|
33
|
+
width: 2.5rem;
|
|
34
|
+
height: 2.5rem;
|
|
35
|
+
border-radius: 50%;
|
|
36
|
+
border: solid 1px white;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
position: relative;
|
|
39
|
+
`;
|
|
40
|
+
const Img = styled_components_1.default.img `
|
|
41
|
+
width: 2.5rem;
|
|
42
|
+
height: 2.5rem;
|
|
43
|
+
`;
|
|
44
|
+
const images = {
|
|
45
|
+
domains: ['platform-lookaside.fbsbx.com', 'lh3.googleusercontent.com'],
|
|
46
|
+
};
|
|
47
|
+
const UserImage = ({ image, className, showProfilePicture, CognitoAuthContext, }) => {
|
|
48
|
+
var _a, _b, _c, _d;
|
|
49
|
+
const { user } = (0, react_1.useContext)(CognitoAuthContext);
|
|
50
|
+
let imageSet = image;
|
|
51
|
+
if (!imageSet && showProfilePicture) {
|
|
52
|
+
imageSet = (_a = user === null || user === void 0 ? void 0 : user.data) === null || _a === void 0 ? void 0 : _a.picture;
|
|
53
|
+
}
|
|
54
|
+
if ((_b = user === null || user === void 0 ? void 0 : user.data) === null || _b === void 0 ? void 0 : _b.picture) {
|
|
55
|
+
if (!images.domains.find((i) => user.data.picture.includes(i))) {
|
|
56
|
+
imageSet = image || '';
|
|
57
|
+
(0, log_1.warn)(`bad domain:${user.data.picture}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const titleA = [(_c = user === null || user === void 0 ? void 0 : user.data) === null || _c === void 0 ? void 0 : _c.fullname, (_d = user === null || user === void 0 ? void 0 : user.data) === null || _d === void 0 ? void 0 : _d.userId].filter(array_1.notEmpty);
|
|
61
|
+
const title = titleA.length === 0 ? '' : titleA.join(' - ');
|
|
62
|
+
return (react_1.default.createElement(Base, { className: className, title: title },
|
|
63
|
+
imageSet && react_1.default.createElement(Img, { alt: "user", src: imageSet }),
|
|
64
|
+
!imageSet && User));
|
|
65
|
+
};
|
|
66
|
+
exports.UserImage = UserImage;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './Button';
|
|
2
|
+
export * from './Dropdown';
|
|
3
|
+
export * from './DropdownList';
|
|
4
|
+
export * from './FlexColumn';
|
|
5
|
+
export * from './FlexRow';
|
|
6
|
+
export * from './HeadersRaw';
|
|
7
|
+
export * from './Input';
|
|
8
|
+
export * from './Loader';
|
|
9
|
+
export * from './LoginButton';
|
|
10
|
+
export * from './Modal';
|
|
11
|
+
export * from './RowOrColumn';
|
|
12
|
+
export * from './Table';
|
|
13
|
+
export * from './TextEdit';
|
|
14
|
+
export * from './TextInput';
|
|
15
|
+
export * from './Toast';
|
|
16
|
+
export * from './UserImage';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./Button"), exports);
|
|
14
|
+
__exportStar(require("./Dropdown"), exports);
|
|
15
|
+
__exportStar(require("./DropdownList"), exports);
|
|
16
|
+
__exportStar(require("./FlexColumn"), exports);
|
|
17
|
+
__exportStar(require("./FlexRow"), exports);
|
|
18
|
+
__exportStar(require("./HeadersRaw"), exports);
|
|
19
|
+
__exportStar(require("./Input"), exports);
|
|
20
|
+
__exportStar(require("./Loader"), exports);
|
|
21
|
+
__exportStar(require("./LoginButton"), exports);
|
|
22
|
+
__exportStar(require("./Modal"), exports);
|
|
23
|
+
__exportStar(require("./RowOrColumn"), exports);
|
|
24
|
+
__exportStar(require("./Table"), exports);
|
|
25
|
+
__exportStar(require("./TextEdit"), exports);
|
|
26
|
+
__exportStar(require("./TextInput"), exports);
|
|
27
|
+
__exportStar(require("./Toast"), exports);
|
|
28
|
+
__exportStar(require("./UserImage"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function supportsWebp(): Promise<boolean>;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.supportsWebp = supportsWebp;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AxiosWrapper, User } from 'analytica.click';
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
3
|
+
export interface OverrideAuth {
|
|
4
|
+
id_token?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const callOpenApi: <T, TDefaultApi>({ func, apiUrl, overrideAuth, refreshToken, logout, newDefaultApi, }: {
|
|
7
|
+
func: (f: TDefaultApi) => Promise<AxiosResponse<T, any>>;
|
|
8
|
+
apiUrl: string;
|
|
9
|
+
overrideAuth?: OverrideAuth | undefined;
|
|
10
|
+
logout: () => void;
|
|
11
|
+
refreshToken: () => Promise<User | undefined>;
|
|
12
|
+
newDefaultApi: (config: any) => TDefaultApi;
|
|
13
|
+
}) => Promise<AxiosWrapper<T | undefined>>;
|
|
@@ -0,0 +1,85 @@
|
|
|
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.callOpenApi = void 0;
|
|
13
|
+
const cookie_1 = require("./cookie");
|
|
14
|
+
const debounce_1 = require("./debounce");
|
|
15
|
+
const callOpenApi = ({ func, apiUrl, overrideAuth, refreshToken, logout, newDefaultApi, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
var _a, _b, _c, _d, _e, _f;
|
|
17
|
+
let error;
|
|
18
|
+
let data;
|
|
19
|
+
const config = {
|
|
20
|
+
basePath: apiUrl,
|
|
21
|
+
baseOptions: { headers: { authorization: '' } },
|
|
22
|
+
};
|
|
23
|
+
const isAuthed = !!(0, cookie_1.getCookieWrapper)({ cname: 'id_token' });
|
|
24
|
+
if (overrideAuth === null || overrideAuth === void 0 ? void 0 : overrideAuth.id_token) {
|
|
25
|
+
config.baseOptions.headers.authorization = `Bearer ${overrideAuth === null || overrideAuth === void 0 ? void 0 : overrideAuth.id_token}`;
|
|
26
|
+
}
|
|
27
|
+
else if (isAuthed) {
|
|
28
|
+
const updated = yield refreshToken();
|
|
29
|
+
if ((_a = updated === null || updated === void 0 ? void 0 : updated.jwt) === null || _a === void 0 ? void 0 : _a.id_token) {
|
|
30
|
+
config.baseOptions.headers.authorization = `Bearer ${(_b = updated === null || updated === void 0 ? void 0 : updated.jwt) === null || _b === void 0 ? void 0 : _b.id_token}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const cl = newDefaultApi(config);
|
|
34
|
+
let errorCount = 0;
|
|
35
|
+
const errorMax = 3;
|
|
36
|
+
while (errorCount <= errorMax) {
|
|
37
|
+
errorCount += 1;
|
|
38
|
+
try {
|
|
39
|
+
// eslint-disable-next-line no-await-in-loop
|
|
40
|
+
const resp = yield func(cl);
|
|
41
|
+
if (resp.status < 400) {
|
|
42
|
+
data = resp.data;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
throw new Error(JSON.stringify(resp.data) || resp.statusText);
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
const ae = e;
|
|
49
|
+
const status = (_c = ae.response) === null || _c === void 0 ? void 0 : _c.status;
|
|
50
|
+
const errorMessage = (((_d = ae.response) === null || _d === void 0 ? void 0 : _d.data) ||
|
|
51
|
+
((_e = ae.response) === null || _e === void 0 ? void 0 : _e.statusText) ||
|
|
52
|
+
((_f = ae.response) === null || _f === void 0 ? void 0 : _f.status) ||
|
|
53
|
+
'ERROR');
|
|
54
|
+
if (status === 403) {
|
|
55
|
+
logout();
|
|
56
|
+
return {
|
|
57
|
+
error: ae,
|
|
58
|
+
data: undefined,
|
|
59
|
+
datetime: new Date().getTime(),
|
|
60
|
+
loading: false,
|
|
61
|
+
reFetch: () => __awaiter(void 0, void 0, void 0, function* () { }),
|
|
62
|
+
url: func.toString(),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (status !== 500 || errorCount === errorMax) {
|
|
66
|
+
error = Object.assign(Object.assign({}, ae), { message: errorMessage });
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// eslint-disable-next-line no-await-in-loop
|
|
71
|
+
yield (0, debounce_1.sleep)(2000);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
data,
|
|
75
|
+
error,
|
|
76
|
+
loading: false,
|
|
77
|
+
reFetch: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
const ret = func(cl);
|
|
79
|
+
return ret;
|
|
80
|
+
}),
|
|
81
|
+
url: func.toString(),
|
|
82
|
+
datetime: new Date().getTime(),
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
exports.callOpenApi = callOpenApi;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const toBase64: (str: string) => string;
|
|
2
|
+
export declare const fromBase64: (str: string) => string;
|
|
3
|
+
export declare function setCookieWrapper<T>(cname: string, raw: T, exdays?: number): void;
|
|
4
|
+
export declare function wipeCookies(cname: string): void;
|
|
5
|
+
export declare function getCookieWrapper<T>({ cname, cookieDocument, defaultValue, }: {
|
|
6
|
+
cname: string;
|
|
7
|
+
cookieDocument?: string;
|
|
8
|
+
defaultValue?: string;
|
|
9
|
+
}): T;
|
|
10
|
+
export declare function useCookie<T>({ key, defaultValue, cookieDocument, }: {
|
|
11
|
+
key: string;
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
cookieDocument?: string;
|
|
14
|
+
}): [T, (v: T) => any];
|