ag-common 0.0.370 → 0.0.372
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/dynamo.js +28 -7
- package/dist/ui/components/Confirm/Dialog.js +4 -3
- package/dist/ui/components/DropdownList/Dialog.js +5 -4
- package/dist/ui/components/Modal/Dialog.js +5 -4
- package/dist/ui/components/Prompt/Dialog.js +3 -2
- package/dist/ui/components/Prompt/Modal.d.ts +3 -1
- package/dist/ui/components/Prompt/Modal.js +3 -6
- package/dist/ui/components/Search/Base.d.ts +1 -1
- package/dist/ui/components/Search/Base.js +4 -3
- package/dist/ui/components/Search/Dialog.js +5 -4
- package/dist/ui/components/Search/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,27 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,20 +31,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
32
|
});
|
|
10
33
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
35
|
exports.getDynamoUpdates = exports.wipeTable = exports.getDynamoTtlMinutes = exports.getDynamoTtlDays = exports.queryDynamo = exports.getItemsDynamo = exports.getItemDynamo = exports.scan = exports.batchDelete = exports.batchWrite = exports.putDynamo = exports.setDynamo = exports.dynamoDb = void 0;
|
|
16
36
|
const log_1 = require("../../common/helpers/log");
|
|
17
37
|
const array_1 = require("../../common/helpers/array");
|
|
18
38
|
const sleep_1 = require("../../common/helpers/sleep");
|
|
19
39
|
const async_1 = require("../../common/helpers/async");
|
|
20
|
-
const dynamodb_1 =
|
|
40
|
+
const dynamodb_1 = __importStar(require("aws-sdk/clients/dynamodb"));
|
|
21
41
|
// eslint-disable-next-line import/no-mutable-exports
|
|
22
|
-
exports.dynamoDb = new dynamodb_1.
|
|
42
|
+
exports.dynamoDb = new dynamodb_1.DocumentClient();
|
|
23
43
|
const setDynamo = (region) => {
|
|
24
|
-
exports.dynamoDb = new dynamodb_1.
|
|
44
|
+
exports.dynamoDb = new dynamodb_1.DocumentClient({ region });
|
|
25
45
|
};
|
|
26
46
|
exports.setDynamo = setDynamo;
|
|
27
47
|
const putDynamo = (item, tableName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -207,7 +227,8 @@ const getItemsDynamo = ({ tableName, items, }) => __awaiter(void 0, void 0, void
|
|
|
207
227
|
try {
|
|
208
228
|
const res = yield dbRaw.batchGetItem(params).promise();
|
|
209
229
|
(0, log_1.debug)(`got dynamo getitems=${JSON.stringify(res, null, 2)}`);
|
|
210
|
-
let ret = ((_f = (_e = res.Responses) === null || _e === void 0 ? void 0 : _e[tableName]) === null || _f === void 0 ? void 0 : _f.map((s) => dynamodb_1.
|
|
230
|
+
let ret = ((_f = (_e = res.Responses) === null || _e === void 0 ? void 0 : _e[tableName]) === null || _f === void 0 ? void 0 : _f.map((s) => dynamodb_1.Converter.unmarshall(s))) ||
|
|
231
|
+
[];
|
|
211
232
|
return ret;
|
|
212
233
|
}
|
|
213
234
|
catch (e) {
|
|
@@ -15,8 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.ConfirmDialog = void 0;
|
|
16
16
|
const Modal_1 = require("./Modal");
|
|
17
17
|
const log_1 = require("../../../common/helpers/log");
|
|
18
|
-
const react_dom_1 = __importDefault(require("react-dom"));
|
|
19
18
|
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const client_1 = require("react-dom/client");
|
|
20
20
|
/**
|
|
21
21
|
* opens a dialog programatically
|
|
22
22
|
* @param param0
|
|
@@ -32,16 +32,17 @@ const ConfirmDialog = ({ bottomText, topText, }) => __awaiter(void 0, void 0, vo
|
|
|
32
32
|
}
|
|
33
33
|
const wrapper = document.body.appendChild(document.createElement('div'));
|
|
34
34
|
wrapper.id = idName;
|
|
35
|
+
const root = (0, client_1.createRoot)(wrapper);
|
|
35
36
|
const onSubmit = (v) => {
|
|
36
37
|
try {
|
|
37
38
|
res(v);
|
|
38
39
|
}
|
|
39
40
|
finally {
|
|
40
|
-
|
|
41
|
+
root.unmount();
|
|
41
42
|
wrapper.remove();
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
|
-
|
|
45
|
+
root.render(react_1.default.createElement(Modal_1.ConfirmModal, { bottomText: bottomText, topText: topText, onSubmit: onSubmit }));
|
|
45
46
|
});
|
|
46
47
|
});
|
|
47
48
|
exports.ConfirmDialog = ConfirmDialog;
|
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.DropdownListDialog = void 0;
|
|
16
16
|
const index_1 = require("./index");
|
|
17
17
|
const react_1 = __importDefault(require("react"));
|
|
18
|
-
const
|
|
18
|
+
const client_1 = require("react-dom/client");
|
|
19
19
|
const DropdownListDialog = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
20
|
return new Promise((res) => {
|
|
21
21
|
const id = 'ag-common-ddld';
|
|
@@ -28,11 +28,12 @@ const DropdownListDialog = (p) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
28
28
|
wrapper.style.position = 'absolute';
|
|
29
29
|
wrapper.style.top = `${p.position.y}px`;
|
|
30
30
|
wrapper.style.left = `${p.position.x}px`;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const root = (0, client_1.createRoot)(wrapper);
|
|
32
|
+
root.render(react_1.default.createElement(index_1.DropdownList, Object.assign({}, p, { open: true, onChange: (v, i) => {
|
|
33
|
+
root.unmount();
|
|
33
34
|
wrapper.remove();
|
|
34
35
|
res(!v ? undefined : [v, i]);
|
|
35
|
-
} }), "\u00A0")
|
|
36
|
+
} }), "\u00A0"));
|
|
36
37
|
});
|
|
37
38
|
});
|
|
38
39
|
exports.DropdownListDialog = DropdownListDialog;
|
|
@@ -15,17 +15,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.ModalDialog = void 0;
|
|
16
16
|
const Modal_1 = require("./Modal");
|
|
17
17
|
const react_1 = __importDefault(require("react"));
|
|
18
|
-
const
|
|
18
|
+
const client_1 = require("react-dom/client");
|
|
19
19
|
const ModalDialog = (content) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
20
|
return new Promise((res) => {
|
|
21
21
|
const wrapper = document.body.appendChild(document.createElement('div'));
|
|
22
|
-
|
|
22
|
+
const root = (0, client_1.createRoot)(wrapper);
|
|
23
|
+
root.render(react_1.default.createElement(Modal_1.Modal, { open: true, setOpen: (o) => {
|
|
23
24
|
if (!o) {
|
|
24
|
-
|
|
25
|
+
root.unmount();
|
|
25
26
|
wrapper.remove();
|
|
26
27
|
}
|
|
27
28
|
res('ok');
|
|
28
|
-
}, topPosition: "center", position: "center" }, content)
|
|
29
|
+
}, topPosition: "center", position: "center" }, content));
|
|
29
30
|
});
|
|
30
31
|
});
|
|
31
32
|
exports.ModalDialog = ModalDialog;
|
|
@@ -15,11 +15,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.PromptDialog = void 0;
|
|
16
16
|
const Modal_1 = require("./Modal");
|
|
17
17
|
const react_1 = __importDefault(require("react"));
|
|
18
|
-
const
|
|
18
|
+
const client_1 = require("react-dom/client");
|
|
19
19
|
const PromptDialog = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
20
|
return new Promise((res) => {
|
|
21
21
|
const wrapper = document.body.appendChild(document.createElement('div'));
|
|
22
|
-
|
|
22
|
+
const root = (0, client_1.createRoot)(wrapper);
|
|
23
|
+
root.render(react_1.default.createElement(Modal_1.PromptModal, Object.assign({}, p, { res: res, root: root, wrapper: wrapper })));
|
|
23
24
|
});
|
|
24
25
|
});
|
|
25
26
|
exports.PromptDialog = PromptDialog;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { Root } from 'react-dom/client';
|
|
2
3
|
export interface IPromptModal {
|
|
3
4
|
defaultValue?: string;
|
|
4
5
|
placeholder?: string;
|
|
5
6
|
res: (v: string | undefined) => void;
|
|
7
|
+
root?: Root;
|
|
6
8
|
wrapper?: HTMLDivElement;
|
|
7
9
|
topText?: string;
|
|
8
10
|
bottomText: string;
|
|
@@ -11,4 +13,4 @@ export interface IPromptModal {
|
|
|
11
13
|
/** default "cancel" */
|
|
12
14
|
cancelText?: string;
|
|
13
15
|
}
|
|
14
|
-
export declare const PromptModal: ({ wrapper, res, bottomText, topText, okText, cancelText, defaultValue, placeholder, }: IPromptModal) => JSX.Element;
|
|
16
|
+
export declare const PromptModal: ({ root, wrapper, res, bottomText, topText, okText, cancelText, defaultValue, placeholder, }: IPromptModal) => JSX.Element;
|
|
@@ -33,7 +33,6 @@ const FlexRow_1 = require("../FlexRow");
|
|
|
33
33
|
const Modal_1 = require("../Modal/Modal");
|
|
34
34
|
const TextEdit_1 = require("../TextEdit");
|
|
35
35
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
36
|
-
const react_dom_1 = __importDefault(require("react-dom"));
|
|
37
36
|
const react_1 = __importStar(require("react"));
|
|
38
37
|
const Base = styled_components_1.default.div `
|
|
39
38
|
width: 95vw;
|
|
@@ -63,17 +62,15 @@ const Bottom = (0, styled_components_1.default)(FlexRow_1.FlexRow) `
|
|
|
63
62
|
margin-right: 1rem;
|
|
64
63
|
}
|
|
65
64
|
`;
|
|
66
|
-
const PromptModal = ({ wrapper, res, bottomText, topText, okText = 'OK', cancelText = 'Cancel', defaultValue, placeholder, }) => {
|
|
65
|
+
const PromptModal = ({ root, wrapper, res, bottomText, topText, okText = 'OK', cancelText = 'Cancel', defaultValue, placeholder, }) => {
|
|
67
66
|
const [text, setText] = (0, react_1.useState)(defaultValue || '');
|
|
68
67
|
const ret = (v) => {
|
|
69
68
|
try {
|
|
70
69
|
res(v);
|
|
71
70
|
}
|
|
72
71
|
finally {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
wrapper.remove();
|
|
76
|
-
}
|
|
72
|
+
root === null || root === void 0 ? void 0 : root.unmount();
|
|
73
|
+
wrapper === null || wrapper === void 0 ? void 0 : wrapper.remove();
|
|
77
74
|
}
|
|
78
75
|
};
|
|
79
76
|
return (react_1.default.createElement(Modal_1.Modal, { position: "center", topPosition: "center", open: true, setOpen: () => ret(undefined), showCloseButton: false, closeOnClickOutside: false },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ISearchDialog, TSearchModalRes } from './types';
|
|
3
|
-
export declare const SearchBase: <T>({ onSelectItem, onSearchTextChange, placeholderText, renderItem, displayItems, willDisplayItem, getKeyF, className, texts, maxDisplayItems, }: ISearchDialog<T> & {
|
|
3
|
+
export declare const SearchBase: <T>({ onSelectItem, onSearchTextChange, placeholderText, renderItem, displayItems, willDisplayItem, getKeyF, className, texts, maxDisplayItems, defaultValue, }: ISearchDialog<T> & {
|
|
4
4
|
onSearchTextChange?: ((v: string) => void) | undefined;
|
|
5
5
|
onSelectItem?: ((v: TSearchModalRes<T>) => void) | undefined;
|
|
6
6
|
}) => JSX.Element;
|
|
@@ -94,9 +94,9 @@ const CrossIconStyled = (0, styled_components_1.default)(CrossIcon_1.CrossIcon)
|
|
|
94
94
|
right: 2rem;
|
|
95
95
|
}
|
|
96
96
|
`;
|
|
97
|
-
const SearchBase = ({ onSelectItem, onSearchTextChange, placeholderText, renderItem, displayItems, willDisplayItem, getKeyF, className, texts, maxDisplayItems = 20, }) => {
|
|
97
|
+
const SearchBase = ({ onSelectItem, onSearchTextChange, placeholderText, renderItem, displayItems, willDisplayItem, getKeyF, className, texts, maxDisplayItems = 20, defaultValue, }) => {
|
|
98
98
|
var _a, _b;
|
|
99
|
-
const [searchText, setSearchText] = (0, react_1.useState)('');
|
|
99
|
+
const [searchText, setSearchText] = (0, react_1.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
|
|
100
100
|
const resWrap = (foundItem) => {
|
|
101
101
|
if (!foundItem) {
|
|
102
102
|
onSelectItem === null || onSelectItem === void 0 ? void 0 : onSelectItem(undefined);
|
|
@@ -115,11 +115,12 @@ const SearchBase = ({ onSelectItem, onSearchTextChange, placeholderText, renderI
|
|
|
115
115
|
react_1.default.createElement(TextEdit_1.TextEdit, { ref: textEditRef, placeholder: placeholderText, defaultEditing: { focus: true }, singleLine: true, leftContent: react_1.default.createElement(Icon, null, Magnify_1.Magnify), noGrow: true, allowUndo: false, onEscape: () => resWrap(undefined), onClickOutsideWithNoValue: null, onSubmit: (v) => (0, helpers_1.debounce)(() => {
|
|
116
116
|
setSearchText(v);
|
|
117
117
|
onSearchTextChange === null || onSearchTextChange === void 0 ? void 0 : onSearchTextChange(v);
|
|
118
|
-
}, { key: 'pagesearch', time: 200 }) }),
|
|
118
|
+
}, { key: 'pagesearch', time: 200 }), defaultValue: defaultValue }),
|
|
119
119
|
searchText && (react_1.default.createElement(CrossIconStyled, { onClick: () => {
|
|
120
120
|
var _a;
|
|
121
121
|
(_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.setValue('');
|
|
122
122
|
setSearchText('');
|
|
123
|
+
onSearchTextChange === null || onSearchTextChange === void 0 ? void 0 : onSearchTextChange('');
|
|
123
124
|
} }))),
|
|
124
125
|
react_1.default.createElement(Content, { "data-hasitems": !!filteredItems.length, "data-type": "content" },
|
|
125
126
|
filteredItems.map((item, index) => (react_1.default.createElement(Row, { key: getKeyF(item), onClick: () => resWrap(item) }, renderItem({ searchText, item, index })))),
|
|
@@ -16,7 +16,7 @@ exports.SearchDialog = void 0;
|
|
|
16
16
|
const Modal_1 = require("./Modal");
|
|
17
17
|
const common_1 = require("../../../common");
|
|
18
18
|
const react_1 = __importDefault(require("react"));
|
|
19
|
-
const
|
|
19
|
+
const client_1 = require("react-dom/client");
|
|
20
20
|
/**
|
|
21
21
|
* opens a searchmodal programatically, and resolves to either undefined, or the selected item
|
|
22
22
|
* @param p
|
|
@@ -38,16 +38,17 @@ const SearchDialog = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
38
38
|
originalStyle = window.getComputedStyle(document.body).overflow || '';
|
|
39
39
|
document.body.style.overflow = 'hidden';
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
const root = (0, client_1.createRoot)(wrapper);
|
|
42
|
+
root.render(react_1.default.createElement(Modal_1.SearchModal, Object.assign({}, p, { placeholderText: placeholderText, onSelectItem: (f) => {
|
|
42
43
|
try {
|
|
43
44
|
document.body.style.overflow = originalStyle || '';
|
|
44
45
|
res(f);
|
|
45
46
|
}
|
|
46
47
|
finally {
|
|
47
|
-
|
|
48
|
+
root.unmount();
|
|
48
49
|
wrapper.remove();
|
|
49
50
|
}
|
|
50
|
-
} }))
|
|
51
|
+
} })));
|
|
51
52
|
});
|
|
52
53
|
});
|
|
53
54
|
exports.SearchDialog = SearchDialog;
|