ag-common 0.0.26 → 0.0.30
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/index.d.ts +1 -0
- package/dist/api/helpers/index.js +1 -0
- package/dist/api/helpers/s3.d.ts +15 -0
- package/dist/api/helpers/s3.js +37 -0
- package/dist/common/helpers/generator.d.ts +1 -0
- package/dist/common/helpers/generator.js +26 -0
- package/dist/common/helpers/index.d.ts +1 -0
- package/dist/common/helpers/index.js +1 -0
- package/dist/ui/components/Modal/Close.js +2 -0
- package/dist/ui/components/TextEdit/CheckboxEdit.d.ts +2 -1
- package/dist/ui/components/TextEdit/CheckboxEdit.js +2 -2
- package/dist/ui/components/TextEdit/TextEdit.d.ts +1 -0
- package/dist/ui/components/TextEdit/TextEdit.js +36 -12
- package/dist/ui/components/TextEdit/common.d.ts +0 -3
- package/dist/ui/components/TextEdit/common.js +6 -6
- package/dist/ui/helpers/debounce.js +6 -8
- package/package.json +1 -1
|
@@ -14,5 +14,6 @@ __exportStar(require("./api"), exports);
|
|
|
14
14
|
__exportStar(require("./dynamo"), exports);
|
|
15
15
|
__exportStar(require("./dynamoInfra"), exports);
|
|
16
16
|
__exportStar(require("./openApiHelpers"), exports);
|
|
17
|
+
__exportStar(require("./s3"), exports);
|
|
17
18
|
__exportStar(require("./validateOpenApi"), exports);
|
|
18
19
|
__exportStar(require("./validations"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Blob } from 'aws-sdk/lib/dynamodb/document_client';
|
|
2
|
+
import AWS from 'aws-sdk';
|
|
3
|
+
export declare const setS3: (region: string) => void;
|
|
4
|
+
export declare const getS3Object: ({ fileurl, }: {
|
|
5
|
+
fileurl: {
|
|
6
|
+
Bucket: string;
|
|
7
|
+
Key: string;
|
|
8
|
+
};
|
|
9
|
+
}) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.S3.GetObjectOutput, AWS.AWSError>>;
|
|
10
|
+
export declare const putS3Object: ({ Body, Bucket, Key, ContentType, }: {
|
|
11
|
+
ContentType?: string | undefined;
|
|
12
|
+
Body: string | Blob;
|
|
13
|
+
Bucket: string;
|
|
14
|
+
Key: string;
|
|
15
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
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.putS3Object = exports.getS3Object = exports.setS3 = void 0;
|
|
16
|
+
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
17
|
+
let s3 = new aws_sdk_1.default.S3();
|
|
18
|
+
const setS3 = (region) => {
|
|
19
|
+
s3 = new aws_sdk_1.default.S3({ region });
|
|
20
|
+
};
|
|
21
|
+
exports.setS3 = setS3;
|
|
22
|
+
const getS3Object = ({ fileurl, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const content = yield s3.getObject(fileurl).promise();
|
|
24
|
+
return content;
|
|
25
|
+
});
|
|
26
|
+
exports.getS3Object = getS3Object;
|
|
27
|
+
const putS3Object = ({ Body, Bucket, Key, ContentType, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
yield s3
|
|
29
|
+
.putObject({
|
|
30
|
+
Body,
|
|
31
|
+
Bucket,
|
|
32
|
+
Key,
|
|
33
|
+
ContentType,
|
|
34
|
+
})
|
|
35
|
+
.promise();
|
|
36
|
+
});
|
|
37
|
+
exports.putS3Object = putS3Object;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runGenerator<T>(iter: AsyncGenerator<T[], T[], unknown>, partialRun: (value: T[]) => Promise<void>): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
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.runGenerator = void 0;
|
|
13
|
+
/* eslint-disable no-await-in-loop */
|
|
14
|
+
function runGenerator(iter, partialRun) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
let curr;
|
|
17
|
+
do {
|
|
18
|
+
curr = yield iter.next();
|
|
19
|
+
if (!(curr === null || curr === void 0 ? void 0 : curr.value) || curr.value.length === 0) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
yield partialRun(curr.value);
|
|
23
|
+
} while (!curr.done);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.runGenerator = runGenerator;
|
|
@@ -15,6 +15,7 @@ __exportStar(require("./async"), exports);
|
|
|
15
15
|
__exportStar(require("./date"), exports);
|
|
16
16
|
__exportStar(require("./distinctBy"), exports);
|
|
17
17
|
__exportStar(require("./email"), exports);
|
|
18
|
+
__exportStar(require("./generator"), exports);
|
|
18
19
|
__exportStar(require("./groupBy"), exports);
|
|
19
20
|
__exportStar(require("./hashCode"), exports);
|
|
20
21
|
__exportStar(require("./i18n"), exports);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const CheckboxEdit: ({ defaultValue, onSubmit, }: {
|
|
2
|
+
export declare const CheckboxEdit: ({ defaultValue, onSubmit, noGrow, }: {
|
|
3
3
|
defaultValue: boolean;
|
|
4
4
|
onSubmit: (val: boolean) => void;
|
|
5
|
+
noGrow?: boolean | undefined;
|
|
5
6
|
}) => JSX.Element;
|
|
@@ -36,7 +36,7 @@ const Icons = (0, styled_components_1.default)(FlexRow_1.FlexRow) `
|
|
|
36
36
|
top: 0;
|
|
37
37
|
right: -2rem;
|
|
38
38
|
`;
|
|
39
|
-
const CheckboxEdit = ({ defaultValue, onSubmit, }) => {
|
|
39
|
+
const CheckboxEdit = ({ defaultValue, onSubmit, noGrow = false, }) => {
|
|
40
40
|
const ref = (0, react_1.useRef)(null);
|
|
41
41
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
42
42
|
(0, react_1.useEffect)(() => {
|
|
@@ -48,7 +48,7 @@ const CheckboxEdit = ({ defaultValue, onSubmit, }) => {
|
|
|
48
48
|
onSubmit(value);
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
-
return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag, { ref: ref }),
|
|
51
|
+
return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag, { ref: ref, "data-nogrow": noGrow }),
|
|
52
52
|
react_1.default.createElement(common_1.ValueInputCB, { type: "checkbox", "data-type": "checkbox", checked: value, onChange: () => setValue(!value), onKeyPress: (e) => e.key === 'Enter' && value !== defaultValue && onSubmit(value) }),
|
|
53
53
|
react_1.default.createElement(Icons, { center: true, enableOverflow: true },
|
|
54
54
|
value !== defaultValue && (react_1.default.createElement(common_1.IconD, { style: common_1.iconLeft, onClick: () => value !== defaultValue && onSubmit(value) },
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
export declare const ValueReadonly: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
3
|
export declare const TextEdit: ({ defaultValue, defaultEditing, onSubmit, canEdit, placeholder, onEditingChange, onClickOutsideWithNoValue, onClickNotEditing, className, singleLine, }: {
|
|
3
4
|
singleLine?: boolean | undefined;
|
|
4
5
|
className?: string | undefined;
|
|
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.TextEdit = void 0;
|
|
25
|
+
exports.TextEdit = exports.ValueReadonly = void 0;
|
|
26
26
|
/* eslint-disable jsx-a11y/no-onchange */
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const images_1 = require("./images");
|
|
@@ -30,14 +30,37 @@ const common_1 = require("./common");
|
|
|
30
30
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
31
31
|
const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
|
|
32
32
|
const common_2 = require("../../styles/common");
|
|
33
|
+
exports.ValueReadonly = styled_components_1.default.div `
|
|
34
|
+
${common_1.valueCss};
|
|
35
|
+
word-break: break-word;
|
|
36
|
+
flex-basis: calc(100% - 3rem);
|
|
37
|
+
`;
|
|
33
38
|
const ValueTextArea = styled_components_1.default.textarea `
|
|
39
|
+
border: 0;
|
|
40
|
+
word-break: break-word;
|
|
34
41
|
${common_1.valueCss};
|
|
35
42
|
resize: none;
|
|
36
43
|
overflow: hidden;
|
|
44
|
+
background-color: white;
|
|
37
45
|
&[data-editing='true'] {
|
|
38
46
|
min-height: 5rem;
|
|
39
47
|
}
|
|
40
48
|
`;
|
|
49
|
+
const ValueBoxEdit = (0, styled_components_1.default)(common_1.ValueBox) `
|
|
50
|
+
border: solid 1px #ccc;
|
|
51
|
+
`;
|
|
52
|
+
const Right = styled_components_1.default.div `
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-flow: row;
|
|
55
|
+
align-content: center;
|
|
56
|
+
`;
|
|
57
|
+
const Icon = styled_components_1.default.div `
|
|
58
|
+
width: 1.5rem;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
&:hover {
|
|
61
|
+
filter: saturate(3);
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
41
64
|
const TextEdit = ({ defaultValue, defaultEditing = false, onSubmit, canEdit = true, placeholder, onEditingChange, onClickOutsideWithNoValue, onClickNotEditing, className, singleLine = false, }) => {
|
|
42
65
|
const ref = (0, react_1.useRef)(null);
|
|
43
66
|
const taref = (0, react_1.useRef)(null);
|
|
@@ -78,24 +101,25 @@ const TextEdit = ({ defaultValue, defaultEditing = false, onSubmit, canEdit = tr
|
|
|
78
101
|
}, [defaultEditing]);
|
|
79
102
|
if (!editing || !canEdit) {
|
|
80
103
|
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' }),
|
|
81
|
-
react_1.default.createElement(
|
|
82
|
-
canEdit && (react_1.default.createElement(
|
|
104
|
+
react_1.default.createElement(exports.ValueReadonly, { "data-type": "text" }, value),
|
|
105
|
+
react_1.default.createElement(Right, null, canEdit && (react_1.default.createElement(Icon, { style: common_1.iconRight, onClick: (e) => {
|
|
83
106
|
e.stopPropagation();
|
|
84
107
|
setEditing(true);
|
|
85
108
|
} },
|
|
86
|
-
react_1.default.createElement(images_1.PencilIcon, null)))));
|
|
109
|
+
react_1.default.createElement(images_1.PencilIcon, null))))));
|
|
87
110
|
}
|
|
88
111
|
if (!open) {
|
|
89
112
|
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
90
113
|
}
|
|
91
|
-
return (react_1.default.createElement(
|
|
114
|
+
return (react_1.default.createElement(ValueBoxEdit, Object.assign({ "data-editing": "true" }, common_2.noDrag, { ref: ref, tabIndex: editing ? 0 : undefined, className: className }),
|
|
92
115
|
react_1.default.createElement(ValueTextArea, { "data-editing": "true", "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 }),
|
|
93
|
-
|
|
94
|
-
react_1.default.createElement(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
116
|
+
react_1.default.createElement(Right, null,
|
|
117
|
+
valueChange && (react_1.default.createElement(Icon, { style: common_1.iconLeft, onClick: () => valueChange && onSubmit(value) },
|
|
118
|
+
react_1.default.createElement(images_1.SaveIcon, null))),
|
|
119
|
+
(valueChange || editing !== defaultEditing) && (react_1.default.createElement(Icon, { style: common_1.iconRight, onClick: () => {
|
|
120
|
+
setEditing(defaultEditing);
|
|
121
|
+
setValue(defaultValue);
|
|
122
|
+
} },
|
|
123
|
+
react_1.default.createElement(images_1.UndoIcon, null))))));
|
|
100
124
|
};
|
|
101
125
|
exports.TextEdit = TextEdit;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export declare const ValueBox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
2
|
export declare const valueCss: import("styled-components").FlattenSimpleInterpolation;
|
|
3
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
4
|
export declare const IconD: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
5
|
export declare const iconRight: {
|
|
7
6
|
right: string;
|
|
8
|
-
top: string;
|
|
9
7
|
};
|
|
10
8
|
export declare const iconLeft: {
|
|
11
9
|
right: string;
|
|
12
|
-
top: string;
|
|
13
10
|
};
|
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.iconLeft = exports.iconRight = exports.IconD = exports.
|
|
22
|
+
exports.iconLeft = exports.iconRight = exports.IconD = exports.ValueInputCB = exports.valueCss = exports.ValueBox = void 0;
|
|
23
23
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
24
24
|
const colours_1 = require("../../styles/colours");
|
|
25
25
|
exports.ValueBox = styled_components_1.default.div `
|
|
@@ -36,6 +36,9 @@ exports.ValueBox = styled_components_1.default.div `
|
|
|
36
36
|
&[data-pointer='true'] {
|
|
37
37
|
cursor: pointer;
|
|
38
38
|
}
|
|
39
|
+
&[data-nogrow='true'] {
|
|
40
|
+
flex-grow: 0;
|
|
41
|
+
}
|
|
39
42
|
`;
|
|
40
43
|
exports.valueCss = (0, styled_components_1.css) `
|
|
41
44
|
width: 100%;
|
|
@@ -52,9 +55,6 @@ exports.valueCss = (0, styled_components_1.css) `
|
|
|
52
55
|
exports.ValueInputCB = styled_components_1.default.input `
|
|
53
56
|
${exports.valueCss};
|
|
54
57
|
`;
|
|
55
|
-
exports.ValueReadonly = styled_components_1.default.div `
|
|
56
|
-
${exports.valueCss};
|
|
57
|
-
`;
|
|
58
58
|
exports.IconD = styled_components_1.default.div `
|
|
59
59
|
z-index: 1;
|
|
60
60
|
font-size: 1rem;
|
|
@@ -66,5 +66,5 @@ exports.IconD = styled_components_1.default.div `
|
|
|
66
66
|
fill: ${colours_1.colours.notificationBlue};
|
|
67
67
|
}
|
|
68
68
|
`;
|
|
69
|
-
exports.iconRight = { right: '0'
|
|
70
|
-
exports.iconLeft = { right: '1.5rem'
|
|
69
|
+
exports.iconRight = { right: '0' };
|
|
70
|
+
exports.iconLeft = { right: '1.5rem' };
|
|
@@ -20,14 +20,12 @@ const sleep = (ms) => {
|
|
|
20
20
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21
21
|
};
|
|
22
22
|
exports.sleep = sleep;
|
|
23
|
-
const
|
|
23
|
+
const hashMap = {};
|
|
24
24
|
function debounce(callback, { key, time, }) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
debounceMap[key] = now;
|
|
31
|
-
callback();
|
|
25
|
+
clearTimeout(hashMap[key]);
|
|
26
|
+
hashMap[key] = setTimeout(() => {
|
|
27
|
+
delete hashMap[key];
|
|
28
|
+
callback();
|
|
29
|
+
}, time);
|
|
32
30
|
}
|
|
33
31
|
exports.debounce = debounce;
|