ag-common 0.0.207 → 0.0.210
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/common/helpers/log.d.ts +1 -1
- package/dist/common/helpers/log.js +1 -1
- package/dist/ui/components/Confirm/Dialog.d.ts +5 -0
- package/dist/ui/components/Confirm/Dialog.js +42 -0
- package/dist/ui/components/Confirm/Modal.d.ts +8 -0
- package/dist/ui/components/Confirm/Modal.js +51 -0
- package/dist/ui/components/Confirm/index.d.ts +2 -4
- package/dist/ui/components/Confirm/index.js +15 -74
- package/dist/ui/components/Dropdown/Modal.d.ts +12 -0
- package/dist/ui/components/Dropdown/Modal.js +20 -0
- package/dist/ui/components/Dropdown/index.d.ts +3 -0
- package/dist/ui/components/Dropdown/index.js +12 -7
- package/dist/ui/components/DropdownList/index.js +4 -12
- package/dist/ui/components/Modal/index.d.ts +1 -12
- package/dist/ui/components/Modal/index.js +4 -15
- package/dist/ui/components/Prompt/index.js +1 -0
- package/dist/ui/components/Search/Base.d.ts +1 -1
- package/dist/ui/components/Search/Base.js +3 -3
- package/dist/ui/components/Search/{searchDialog.d.ts → Dialog.d.ts} +1 -1
- package/dist/ui/components/Search/{searchDialog.js → Dialog.js} +9 -7
- package/dist/ui/components/Search/{SearchBox.d.ts → Inline.d.ts} +1 -1
- package/dist/ui/components/Search/{SearchBox.js → Inline.js} +3 -3
- package/dist/ui/components/Search/{SearchModal.d.ts → Modal.d.ts} +0 -0
- package/dist/ui/components/Search/{SearchModal.js → Modal.js} +1 -1
- package/dist/ui/components/Search/index.d.ts +3 -3
- package/dist/ui/components/Search/index.js +3 -3
- package/dist/ui/components/{Sparkline → SparkLine}/index.d.ts +10 -9
- package/dist/ui/components/{Sparkline → SparkLine}/index.js +0 -0
- package/dist/ui/components/TextEdit/TextEdit.js +1 -1
- package/dist/ui/components/index.d.ts +2 -2
- package/dist/ui/components/index.js +2 -2
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare type TLogType = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL';
|
|
2
2
|
export declare const GetLogLevel: (l: TLogType) => number;
|
|
3
|
-
export declare const SetLogLevel: (l:
|
|
3
|
+
export declare const SetLogLevel: (l: TLogType) => void;
|
|
4
4
|
export declare const debug: (...args: unknown[]) => void;
|
|
5
5
|
export declare const info: (...args: unknown[]) => void;
|
|
6
6
|
export declare const warn: (...args: unknown[]) => void;
|
|
@@ -14,7 +14,7 @@ const SetLogLevel = (l) => {
|
|
|
14
14
|
userLogLevel = lu;
|
|
15
15
|
};
|
|
16
16
|
exports.SetLogLevel = SetLogLevel;
|
|
17
|
-
(0, exports.SetLogLevel)(process.env.LOG_LEVEL
|
|
17
|
+
(0, exports.SetLogLevel)(process.env.LOG_LEVEL);
|
|
18
18
|
function logprocess(type, args) {
|
|
19
19
|
const min = (0, exports.GetLogLevel)(userLogLevel);
|
|
20
20
|
const typesLogLevel = (0, exports.GetLogLevel)(type);
|
|
@@ -0,0 +1,42 @@
|
|
|
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.ConfirmDialog = void 0;
|
|
16
|
+
const Modal_1 = require("./Modal");
|
|
17
|
+
const log_1 = require("../../../common/helpers/log");
|
|
18
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
19
|
+
const react_1 = __importDefault(require("react"));
|
|
20
|
+
const ConfirmDialog = ({ bottomText, topText, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
return new Promise((res) => {
|
|
22
|
+
const idName = 'ag-confirm-dialog';
|
|
23
|
+
if (document.body.querySelectorAll('#' + idName).length !== 0) {
|
|
24
|
+
(0, log_1.error)('confirmDialog already open');
|
|
25
|
+
res(false);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const wrapper = document.body.appendChild(document.createElement('div'));
|
|
29
|
+
wrapper.id = idName;
|
|
30
|
+
const onSubmit = (v) => {
|
|
31
|
+
try {
|
|
32
|
+
res(v);
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
react_dom_1.default.unmountComponentAtNode(wrapper);
|
|
36
|
+
wrapper.remove();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
react_dom_1.default.render(react_1.default.createElement(Modal_1.ConfirmModal, { bottomText: bottomText, topText: topText, onSubmit: onSubmit }), wrapper);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
exports.ConfirmDialog = ConfirmDialog;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const ConfirmModal: ({ onSubmit, bottomText, topText, okText, cancelText, }: {
|
|
3
|
+
onSubmit: (v: boolean) => void;
|
|
4
|
+
topText?: string | undefined;
|
|
5
|
+
bottomText: string;
|
|
6
|
+
okText?: string | undefined;
|
|
7
|
+
cancelText?: string | undefined;
|
|
8
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
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.ConfirmModal = void 0;
|
|
7
|
+
const Button_1 = require("../Button");
|
|
8
|
+
const FlexColumn_1 = require("../FlexColumn");
|
|
9
|
+
const FlexRow_1 = require("../FlexRow");
|
|
10
|
+
const Modal_1 = require("../Modal");
|
|
11
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
+
const react_1 = __importDefault(require("react"));
|
|
13
|
+
const Base = styled_components_1.default.div `
|
|
14
|
+
width: 95vw;
|
|
15
|
+
max-width: 30rem;
|
|
16
|
+
height: 50vh;
|
|
17
|
+
max-height: 15rem;
|
|
18
|
+
padding: 1rem;
|
|
19
|
+
`;
|
|
20
|
+
const Content = (0, styled_components_1.default)(FlexColumn_1.FlexColumn) `
|
|
21
|
+
height: 100%;
|
|
22
|
+
`;
|
|
23
|
+
const TopText = styled_components_1.default.div `
|
|
24
|
+
font-weight: bold;
|
|
25
|
+
border-bottom: solid 1px #ccc;
|
|
26
|
+
padding-bottom: 0.25rem;
|
|
27
|
+
font-size: 1.5rem;
|
|
28
|
+
margin-bottom: 1rem;
|
|
29
|
+
`;
|
|
30
|
+
const BottomText = styled_components_1.default.div `
|
|
31
|
+
padding-bottom: 0.25rem;
|
|
32
|
+
font-size: 1.1rem;
|
|
33
|
+
`;
|
|
34
|
+
const Bottom = (0, styled_components_1.default)(FlexRow_1.FlexRow) `
|
|
35
|
+
margin-top: auto;
|
|
36
|
+
justify-content: flex-end;
|
|
37
|
+
> button:first-child {
|
|
38
|
+
margin-right: 1rem;
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
const ConfirmModal = ({ onSubmit, bottomText, topText, okText = 'OK', cancelText = 'Cancel', }) => {
|
|
42
|
+
return (react_1.default.createElement(Modal_1.Modal, { position: "center", topPosition: "center", open: true, setOpen: () => onSubmit(false), showCloseButton: false, closeOnClickOutside: false },
|
|
43
|
+
react_1.default.createElement(Base, null,
|
|
44
|
+
react_1.default.createElement(Content, null,
|
|
45
|
+
topText && react_1.default.createElement(TopText, null, topText),
|
|
46
|
+
react_1.default.createElement(BottomText, null, bottomText),
|
|
47
|
+
react_1.default.createElement(Bottom, { noGrow: true },
|
|
48
|
+
react_1.default.createElement(Button_1.Button, { onClick: () => onSubmit(true) }, okText),
|
|
49
|
+
react_1.default.createElement(Button_1.Button, { invert: true, onClick: () => onSubmit(false) }, cancelText))))));
|
|
50
|
+
};
|
|
51
|
+
exports.ConfirmModal = ConfirmModal;
|
|
@@ -1,77 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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);
|
|
13
15
|
};
|
|
14
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports
|
|
16
|
-
|
|
17
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
18
|
-
const Button_1 = require("../Button");
|
|
19
|
-
const FlexColumn_1 = require("../FlexColumn");
|
|
20
|
-
const FlexRow_1 = require("../FlexRow");
|
|
21
|
-
const Modal_1 = require("../Modal");
|
|
22
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
23
|
-
const react_dom_1 = __importDefault(require("react-dom"));
|
|
24
|
-
const react_1 = __importDefault(require("react"));
|
|
25
|
-
const Base = styled_components_1.default.div `
|
|
26
|
-
width: 95vw;
|
|
27
|
-
max-width: 30rem;
|
|
28
|
-
height: 50vh;
|
|
29
|
-
max-height: 15rem;
|
|
30
|
-
padding: 1rem;
|
|
31
|
-
`;
|
|
32
|
-
const Content = (0, styled_components_1.default)(FlexColumn_1.FlexColumn) `
|
|
33
|
-
height: 100%;
|
|
34
|
-
`;
|
|
35
|
-
const TopText = styled_components_1.default.div `
|
|
36
|
-
font-weight: bold;
|
|
37
|
-
border-bottom: solid 1px #ccc;
|
|
38
|
-
padding-bottom: 0.25rem;
|
|
39
|
-
font-size: 1.5rem;
|
|
40
|
-
margin-bottom: 1rem;
|
|
41
|
-
`;
|
|
42
|
-
const BottomText = styled_components_1.default.div `
|
|
43
|
-
padding-bottom: 0.25rem;
|
|
44
|
-
font-size: 1.1rem;
|
|
45
|
-
`;
|
|
46
|
-
const Bottom = (0, styled_components_1.default)(FlexRow_1.FlexRow) `
|
|
47
|
-
margin-top: auto;
|
|
48
|
-
justify-content: flex-end;
|
|
49
|
-
> button:first-child {
|
|
50
|
-
margin-right: 1rem;
|
|
51
|
-
}
|
|
52
|
-
`;
|
|
53
|
-
const ConfirmModal = ({ wrapper, res, bottomText, topText, okText = 'OK', cancelText = 'Cancel', }) => {
|
|
54
|
-
const ret = (v) => {
|
|
55
|
-
try {
|
|
56
|
-
res(v);
|
|
57
|
-
}
|
|
58
|
-
finally {
|
|
59
|
-
react_dom_1.default.unmountComponentAtNode(wrapper);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
return (react_1.default.createElement(Modal_1.Modal, { position: "center", topPosition: "center", open: true, setOpen: () => ret(false), showCloseButton: false, closeOnClickOutside: false },
|
|
63
|
-
react_1.default.createElement(Base, null,
|
|
64
|
-
react_1.default.createElement(Content, null,
|
|
65
|
-
topText && react_1.default.createElement(TopText, null, topText),
|
|
66
|
-
react_1.default.createElement(BottomText, null, bottomText),
|
|
67
|
-
react_1.default.createElement(Bottom, { noGrow: true },
|
|
68
|
-
react_1.default.createElement(Button_1.Button, { onClick: () => ret(true) }, okText),
|
|
69
|
-
react_1.default.createElement(Button_1.Button, { invert: true, onClick: () => ret(false) }, cancelText))))));
|
|
70
|
-
};
|
|
71
|
-
const confirm = ({ bottomText, topText, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
-
return new Promise((res) => {
|
|
73
|
-
const wrapper = document.body.appendChild(document.createElement('div'));
|
|
74
|
-
react_dom_1.default.render(react_1.default.createElement(ConfirmModal, { bottomText: bottomText, topText: topText, res: res, wrapper: wrapper }), wrapper);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
exports.confirm = confirm;
|
|
17
|
+
__exportStar(require("./Dialog"), exports);
|
|
18
|
+
__exportStar(require("./Modal"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const DropdownModal: (p: {
|
|
3
|
+
options: (string | JSX.Element)[];
|
|
4
|
+
onSelect?: ((i: number, e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
|
|
5
|
+
position?: "left" | "right" | undefined;
|
|
6
|
+
topPosition?: "top" | "bottom" | undefined;
|
|
7
|
+
open: boolean;
|
|
8
|
+
setOpen: (b: boolean) => void;
|
|
9
|
+
closeOnMoveMouseOutside?: boolean | undefined;
|
|
10
|
+
showCloseButton?: boolean | undefined;
|
|
11
|
+
className?: string | undefined;
|
|
12
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
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.DropdownModal = void 0;
|
|
7
|
+
const Modal_1 = require("../Modal");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
|
+
const ModalDropdownStyled = (0, styled_components_1.default)(Modal_1.Modal) `
|
|
11
|
+
flex-flow: column;
|
|
12
|
+
`;
|
|
13
|
+
const DropdownModal = (p) => (react_1.default.createElement(ModalDropdownStyled, Object.assign({}, p, { className: p.className }), p.options.map((option, index) => (react_1.default.createElement(Modal_1.ModalItem, { key: option, onClick: (e) => {
|
|
14
|
+
var _a;
|
|
15
|
+
e.stopPropagation();
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
(_a = p.onSelect) === null || _a === void 0 ? void 0 : _a.call(p, index, e);
|
|
18
|
+
p.setOpen(false);
|
|
19
|
+
} }, option)))));
|
|
20
|
+
exports.DropdownModal = DropdownModal;
|
|
@@ -6,5 +6,8 @@ export declare const Dropdown: ({ options, position, topPosition, onSelect, clas
|
|
|
6
6
|
position?: "left" | "right" | undefined;
|
|
7
7
|
onSelect: (i: number, e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
8
8
|
enableHoverOpen?: boolean | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* if not provided, will show ... dots to click to open (default)
|
|
11
|
+
*/
|
|
9
12
|
children?: JSX.Element | undefined;
|
|
10
13
|
}) => JSX.Element;
|
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Dropdown = void 0;
|
|
30
|
-
const Modal_1 = require("
|
|
30
|
+
const Modal_1 = require("./Modal");
|
|
31
31
|
const common_1 = require("../../styles/common");
|
|
32
32
|
const react_1 = __importStar(require("react"));
|
|
33
33
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
@@ -54,12 +54,17 @@ const Icon = styled_components_1.default.div `
|
|
|
54
54
|
`;
|
|
55
55
|
const Dropdown = ({ options, position = 'left', topPosition, onSelect, className, enableHoverOpen = false, children, }) => {
|
|
56
56
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
57
|
+
const child = !children ? (react_1.default.createElement(Icon, { "data-fixedsize": true, onClick: (e) => {
|
|
58
|
+
e.stopPropagation();
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
setOpen(!open);
|
|
61
|
+
} }, Dots)) : (react_1.default.createElement("div", { tabIndex: -1, role: "button", onKeyDown: (e) => e.key === 'Enter' && setOpen(!open), "data-fixedsize": false, onClick: (e) => {
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
setOpen(!open);
|
|
65
|
+
} }, children));
|
|
57
66
|
return (react_1.default.createElement(Base, Object.assign({ onKeyPress: (e) => e.key === 'Enter' && setOpen(!open), onMouseEnter: () => enableHoverOpen && setOpen(true), onMouseLeave: () => enableHoverOpen && setOpen(false), className: className }, common_1.noDrag),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
e.preventDefault();
|
|
61
|
-
setOpen(!open);
|
|
62
|
-
} }, children || Dots),
|
|
63
|
-
react_1.default.createElement(Modal_1.ModalDropList, { position: position, topPosition: topPosition, options: options, open: open, setOpen: setOpen, onSelect: onSelect, showCloseButton: false })));
|
|
67
|
+
child,
|
|
68
|
+
react_1.default.createElement(Modal_1.DropdownModal, { position: position, topPosition: topPosition, options: options, open: open, setOpen: setOpen, onSelect: onSelect, showCloseButton: false })));
|
|
64
69
|
};
|
|
65
70
|
exports.Dropdown = Dropdown;
|
|
@@ -28,6 +28,7 @@ const colours_1 = require("../../styles/colours");
|
|
|
28
28
|
const Icon_1 = require("../Icon");
|
|
29
29
|
const dom_1 = require("../../helpers/dom");
|
|
30
30
|
const common_1 = require("../../styles/common");
|
|
31
|
+
const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
|
|
31
32
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
32
33
|
const react_1 = __importStar(require("react"));
|
|
33
34
|
const SBase = styled_components_1.default.div `
|
|
@@ -97,18 +98,9 @@ function DropdownList({ options, value, onChange, placeholder, className, render
|
|
|
97
98
|
const ref = (0, react_1.useRef)(null);
|
|
98
99
|
const [state, setState] = (0, react_1.useState)(value);
|
|
99
100
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const outside = !((_a = ref.current) === null || _a === void 0 ? void 0 : _a.contains(e.target));
|
|
104
|
-
if (outside) {
|
|
105
|
-
setOpen(false);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
(0, react_1.useEffect)(() => {
|
|
109
|
-
document.addEventListener('click', click, true);
|
|
110
|
-
return () => document.removeEventListener('click', click, true);
|
|
111
|
-
}, []);
|
|
101
|
+
(0, useOnClickOutside_1.useOnClickOutside)({ disabled: !open, ref, moveMouseOutside: false }, () => {
|
|
102
|
+
setOpen(false);
|
|
103
|
+
});
|
|
112
104
|
(0, react_1.useEffect)(() => {
|
|
113
105
|
const newv = value;
|
|
114
106
|
if (JSON.stringify(newv) !== JSON.stringify(value))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
export declare const ModalItem: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
3
|
export declare const Modal: ({ open, setOpen, children, position, topPosition, showCloseButton, closeOnMoveMouseOutside, className, closeOnClickOutside, }: {
|
|
4
4
|
open: boolean;
|
|
@@ -11,14 +11,3 @@ export declare const Modal: ({ open, setOpen, children, position, topPosition, s
|
|
|
11
11
|
className?: string | undefined;
|
|
12
12
|
closeOnClickOutside?: boolean | undefined;
|
|
13
13
|
}) => JSX.Element;
|
|
14
|
-
export declare const ModalDropList: (p: {
|
|
15
|
-
options: (string | JSX.Element)[];
|
|
16
|
-
onSelect?: ((i: number, e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
|
|
17
|
-
position?: "left" | "right" | undefined;
|
|
18
|
-
topPosition?: "top" | "bottom" | undefined;
|
|
19
|
-
open: boolean;
|
|
20
|
-
setOpen: (b: boolean) => void;
|
|
21
|
-
closeOnMoveMouseOutside?: boolean | undefined;
|
|
22
|
-
showCloseButton?: boolean | undefined;
|
|
23
|
-
className?: string | undefined;
|
|
24
|
-
}) => JSX.Element;
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.Modal = exports.ModalItem = void 0;
|
|
30
30
|
const Close_1 = require("../Close");
|
|
31
31
|
const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
|
|
32
32
|
const react_1 = __importStar(require("react"));
|
|
@@ -59,10 +59,10 @@ const ModalBase = styled_components_1.default.div `
|
|
|
59
59
|
&[data-position='right'] {
|
|
60
60
|
right: 0;
|
|
61
61
|
}
|
|
62
|
-
&[data-topposition='
|
|
62
|
+
&[data-topposition='top'] {
|
|
63
63
|
top: 0;
|
|
64
64
|
}
|
|
65
|
-
&[data-topposition='
|
|
65
|
+
&[data-topposition='bottom'] {
|
|
66
66
|
bottom: 0;
|
|
67
67
|
}
|
|
68
68
|
`;
|
|
@@ -77,7 +77,7 @@ exports.ModalItem = styled_components_1.default.div `
|
|
|
77
77
|
const CloseStyled = (0, styled_components_1.default)(Close_1.Close) `
|
|
78
78
|
z-index: 1;
|
|
79
79
|
`;
|
|
80
|
-
const Modal = ({ open, setOpen, children, position = 'left', topPosition = '
|
|
80
|
+
const Modal = ({ open, setOpen, children, position = 'left', topPosition = 'top', showCloseButton = true, closeOnMoveMouseOutside = false, className, closeOnClickOutside = true, }) => {
|
|
81
81
|
const ref = (0, react_1.useRef)(null);
|
|
82
82
|
(0, useOnClickOutside_1.useOnClickOutside)({
|
|
83
83
|
disabled: !open,
|
|
@@ -97,14 +97,3 @@ const Modal = ({ open, setOpen, children, position = 'left', topPosition = 'bott
|
|
|
97
97
|
children)));
|
|
98
98
|
};
|
|
99
99
|
exports.Modal = Modal;
|
|
100
|
-
const ModalDropListStyled = (0, styled_components_1.default)(exports.Modal) `
|
|
101
|
-
flex-flow: column;
|
|
102
|
-
`;
|
|
103
|
-
const ModalDropList = (p) => (react_1.default.createElement(ModalDropListStyled, Object.assign({}, p, { className: p.className }), p.options.map((option, index) => (react_1.default.createElement(exports.ModalItem, { key: option, onClick: (e) => {
|
|
104
|
-
var _a;
|
|
105
|
-
e.stopPropagation();
|
|
106
|
-
e.preventDefault();
|
|
107
|
-
(_a = p.onSelect) === null || _a === void 0 ? void 0 : _a.call(p, index, e);
|
|
108
|
-
p.setOpen(false);
|
|
109
|
-
} }, option)))));
|
|
110
|
-
exports.ModalDropList = ModalDropList;
|
|
@@ -82,6 +82,7 @@ const PromptModal = ({ wrapper, res, bottomText, topText, okText = 'OK', cancelT
|
|
|
82
82
|
}
|
|
83
83
|
finally {
|
|
84
84
|
react_dom_1.default.unmountComponentAtNode(wrapper);
|
|
85
|
+
wrapper.remove();
|
|
85
86
|
}
|
|
86
87
|
};
|
|
87
88
|
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
|
|
3
|
+
export declare const SearchBase: <T>({ onSelectItem, onSearchTextChange, placeholderText, closeText, renderItem, displayItems, willDisplayItem, getKeyF, }: ISearchDialog<T> & {
|
|
4
4
|
onSearchTextChange?: ((v: string) => void) | undefined;
|
|
5
5
|
onSelectItem?: ((v: TSearchModalRes<T>) => void) | undefined;
|
|
6
6
|
}) => JSX.Element;
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.SearchBase = void 0;
|
|
30
30
|
const helpers_1 = require("../../helpers");
|
|
31
31
|
const TextEdit_1 = require("../TextEdit");
|
|
32
32
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
@@ -79,7 +79,7 @@ const Row = styled_components_1.default.div `
|
|
|
79
79
|
justify-content: center;
|
|
80
80
|
align-items: center;
|
|
81
81
|
`;
|
|
82
|
-
const
|
|
82
|
+
const SearchBase = ({ onSelectItem, onSearchTextChange, placeholderText, closeText, renderItem, displayItems, willDisplayItem, getKeyF, }) => {
|
|
83
83
|
const [searchText, setSearchText] = (0, react_1.useState)('');
|
|
84
84
|
const resWrap = (foundItem) => {
|
|
85
85
|
if (!foundItem) {
|
|
@@ -99,4 +99,4 @@ const Base = ({ onSelectItem, onSearchTextChange, placeholderText, closeText, re
|
|
|
99
99
|
react_1.default.createElement(CloseButton, { onClick: () => resWrap(undefined) }, closeText)),
|
|
100
100
|
react_1.default.createElement(Content, { "data-hasitems": !!filteredItems.length }, filteredItems.map((i) => (react_1.default.createElement(Row, { key: getKeyF(i), onClick: () => resWrap(i) }, renderItem(searchText, i)))))));
|
|
101
101
|
};
|
|
102
|
-
exports.
|
|
102
|
+
exports.SearchBase = SearchBase;
|
|
@@ -4,4 +4,4 @@ import { ISearchDialog, TSearchModalRes } from './types';
|
|
|
4
4
|
* @param p
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const SearchDialog: <T>(p: ISearchDialog<T>) => Promise<TSearchModalRes<T>>;
|
|
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
16
|
-
const
|
|
15
|
+
exports.SearchDialog = void 0;
|
|
16
|
+
const Modal_1 = require("./Modal");
|
|
17
17
|
const common_1 = require("../../../common");
|
|
18
18
|
const react_1 = __importDefault(require("react"));
|
|
19
19
|
const react_dom_1 = __importDefault(require("react-dom"));
|
|
@@ -22,18 +22,19 @@ const react_dom_1 = __importDefault(require("react-dom"));
|
|
|
22
22
|
* @param p
|
|
23
23
|
* @returns
|
|
24
24
|
*/
|
|
25
|
-
const
|
|
25
|
+
const SearchDialog = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
26
|
const placeholderText = p.placeholderText || '';
|
|
27
27
|
const closeText = p.closeText || 'CLOSE';
|
|
28
28
|
let originalStyle;
|
|
29
29
|
return new Promise((res) => {
|
|
30
|
-
|
|
30
|
+
const idName = 'ag-search-dialog';
|
|
31
|
+
if (document.body.querySelectorAll('#' + idName).length !== 0) {
|
|
31
32
|
(0, common_1.error)('searchDialog already open');
|
|
32
33
|
res(undefined);
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
36
|
const wrapper = document.body.appendChild(document.createElement('div'));
|
|
36
|
-
wrapper.id =
|
|
37
|
+
wrapper.id = idName;
|
|
37
38
|
if (originalStyle === undefined) {
|
|
38
39
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
40
|
originalStyle = window.getComputedStyle(document.body).overflow || '';
|
|
@@ -46,9 +47,10 @@ const searchDialog = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
46
47
|
}
|
|
47
48
|
finally {
|
|
48
49
|
react_dom_1.default.unmountComponentAtNode(wrapper);
|
|
50
|
+
wrapper.remove();
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
|
-
react_dom_1.default.render(react_1.default.createElement(
|
|
53
|
+
react_dom_1.default.render(react_1.default.createElement(Modal_1.SearchModal, Object.assign({}, p, { placeholderText: placeholderText, closeText: closeText, onSelectItem: onSelectItem })), wrapper);
|
|
52
54
|
});
|
|
53
55
|
});
|
|
54
|
-
exports.
|
|
56
|
+
exports.SearchDialog = SearchDialog;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ISearchDialog, TSearchModalRes } from './types';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const SearchInline: <T>(p: ISearchDialog<T> & {
|
|
4
4
|
onSelectItem?: ((v: TSearchModalRes<T>) => void) | undefined;
|
|
5
5
|
onSearchTextChange?: ((v: string) => void) | undefined;
|
|
6
6
|
}) => JSX.Element;
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.SearchInline = void 0;
|
|
7
7
|
const Base_1 = require("./Base");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const
|
|
10
|
-
exports.
|
|
9
|
+
const SearchInline = (p) => react_1.default.createElement(Base_1.SearchBase, Object.assign({}, p));
|
|
10
|
+
exports.SearchInline = SearchInline;
|
|
File without changes
|
|
@@ -23,5 +23,5 @@ const ModalStyled = (0, styled_components_1.default)(Modal_1.Modal) `
|
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
25
25
|
const SearchModal = (p) => (react_1.default.createElement(ModalStyled, { position: "center", topPosition: "center", open: true, setOpen: () => p.onSelectItem(undefined), showCloseButton: false, closeOnClickOutside: true },
|
|
26
|
-
react_1.default.createElement(Base_1.
|
|
26
|
+
react_1.default.createElement(Base_1.SearchBase, Object.assign({}, p))));
|
|
27
27
|
exports.SearchModal = SearchModal;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './types';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
2
|
+
export * from './Modal';
|
|
3
|
+
export * from './Dialog';
|
|
4
|
+
export * from './Inline';
|
|
@@ -15,6 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./types"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./Modal"), exports);
|
|
19
|
+
__exportStar(require("./Dialog"), exports);
|
|
20
|
+
__exportStar(require("./Inline"), exports);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export
|
|
3
|
-
x: number;
|
|
4
|
-
y: number;
|
|
5
|
-
};
|
|
6
|
-
export declare const SparkLine: ({ data: raw, className, pointTitleF, pointColour, }: {
|
|
2
|
+
export interface ISparkLine {
|
|
7
3
|
/**
|
|
8
4
|
* default #4d76ff
|
|
9
5
|
*/
|
|
10
|
-
pointColour?: string
|
|
11
|
-
className?: string
|
|
6
|
+
pointColour?: string;
|
|
7
|
+
className?: string;
|
|
12
8
|
data: TSparkLineData[];
|
|
13
|
-
pointTitleF?: (
|
|
14
|
-
}
|
|
9
|
+
pointTitleF?: (p: TSparkLineData) => string;
|
|
10
|
+
}
|
|
11
|
+
export declare type TSparkLineData = {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const SparkLine: ({ data: raw, className, pointTitleF, pointColour, }: ISparkLine) => JSX.Element;
|
|
File without changes
|
|
@@ -80,7 +80,7 @@ const TextEdit = ({ defaultValue = '', defaultEditing, disableEdit = false, plac
|
|
|
80
80
|
const [editing, setEditingRaw] = (0, react_1.useState)(!!defaultEditing);
|
|
81
81
|
const valueChange = value !== defaultValue;
|
|
82
82
|
(0, useOnClickOutside_1.useOnClickOutside)({
|
|
83
|
-
disabled: onClickOutsideWithNoValue === null,
|
|
83
|
+
disabled: onClickOutsideWithNoValue === null || disableEdit,
|
|
84
84
|
ref,
|
|
85
85
|
moveMouseOutside: false,
|
|
86
86
|
}, () => {
|
|
@@ -2,7 +2,7 @@ export * from './BorderGradient';
|
|
|
2
2
|
export * from './Button';
|
|
3
3
|
export * from './Chevron';
|
|
4
4
|
export * from './Close';
|
|
5
|
-
export * from './Confirm';
|
|
5
|
+
export * from './Confirm/Dialog';
|
|
6
6
|
export * from './Dropdown';
|
|
7
7
|
export * from './DropdownList';
|
|
8
8
|
export * from './FlexColumn';
|
|
@@ -17,7 +17,7 @@ export * from './Prompt';
|
|
|
17
17
|
export * from './RowOrColumn';
|
|
18
18
|
export * from './Search';
|
|
19
19
|
export * from './Sidebar';
|
|
20
|
-
export * from './
|
|
20
|
+
export * from './SparkLine';
|
|
21
21
|
export * from './Table';
|
|
22
22
|
export * from './TextEdit';
|
|
23
23
|
export * from './Toast';
|
|
@@ -18,7 +18,7 @@ __exportStar(require("./BorderGradient"), exports);
|
|
|
18
18
|
__exportStar(require("./Button"), exports);
|
|
19
19
|
__exportStar(require("./Chevron"), exports);
|
|
20
20
|
__exportStar(require("./Close"), exports);
|
|
21
|
-
__exportStar(require("./Confirm"), exports);
|
|
21
|
+
__exportStar(require("./Confirm/Dialog"), exports);
|
|
22
22
|
__exportStar(require("./Dropdown"), exports);
|
|
23
23
|
__exportStar(require("./DropdownList"), exports);
|
|
24
24
|
__exportStar(require("./FlexColumn"), exports);
|
|
@@ -33,7 +33,7 @@ __exportStar(require("./Prompt"), exports);
|
|
|
33
33
|
__exportStar(require("./RowOrColumn"), exports);
|
|
34
34
|
__exportStar(require("./Search"), exports);
|
|
35
35
|
__exportStar(require("./Sidebar"), exports);
|
|
36
|
-
__exportStar(require("./
|
|
36
|
+
__exportStar(require("./SparkLine"), exports);
|
|
37
37
|
__exportStar(require("./Table"), exports);
|
|
38
38
|
__exportStar(require("./TextEdit"), exports);
|
|
39
39
|
__exportStar(require("./Toast"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.210",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Andrei Gec <@andreigec> (https://gec.dev/)",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"packageManager": "yarn@3.2.0",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"format": "npx eslint --ext .ts,.tsx ./src --fix",
|
|
12
|
-
"build": "rimraf dist && yarn
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"build-storybook": "build-storybook -o docs"
|
|
12
|
+
"build": "rimraf dist && yarn lint && tsc && rimraf dist/story",
|
|
13
|
+
"lint": "npx eslint --ext .ts,.tsx ./src",
|
|
14
|
+
"start": "cross-env BROWSER=none start-storybook -p 6006",
|
|
15
|
+
"build-storybook": "build-storybook -o docs --quiet"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"aws-cdk-lib": "2.x",
|