ag-common 0.0.115 → 0.0.119
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/ui/components/DropdownList/index.d.ts +5 -1
- package/dist/ui/components/DropdownList/index.js +4 -2
- package/dist/ui/components/Icon/index.js +1 -1
- package/dist/ui/components/Prompt/index.d.ts +6 -0
- package/dist/ui/components/Prompt/index.js +99 -0
- package/dist/ui/components/index.d.ts +1 -0
- package/dist/ui/components/index.js +1 -0
- package/dist/ui/helpers/callOpenApi.d.ts +1 -1
- package/dist/ui/helpers/callOpenApi.js +2 -2
- package/dist/ui/helpers/types.d.ts +1 -0
- package/dist/ui/styles/common.d.ts +2 -1
- package/dist/ui/styles/common.js +9 -6
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare function DropdownList<T>({ options, value, onChange, placeholder, className, renderF, children, }: {
|
|
2
|
+
export declare function DropdownList<T>({ options, value, onChange, placeholder, className, renderF, children, shadow, }: {
|
|
3
3
|
options: T[];
|
|
4
4
|
value?: T;
|
|
5
5
|
onChange: (v: T, index: number) => void;
|
|
@@ -7,4 +7,8 @@ export declare function DropdownList<T>({ options, value, onChange, placeholder,
|
|
|
7
7
|
className?: string;
|
|
8
8
|
renderF: (v: T) => string;
|
|
9
9
|
children?: JSX.Element;
|
|
10
|
+
/**
|
|
11
|
+
* colour of dropdown shadow. default #555
|
|
12
|
+
*/
|
|
13
|
+
shadow?: string;
|
|
10
14
|
}): JSX.Element;
|
|
@@ -25,6 +25,7 @@ const react_1 = __importStar(require("react"));
|
|
|
25
25
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
26
26
|
const Icon_1 = require("../Icon");
|
|
27
27
|
const dom_1 = require("../../helpers/dom");
|
|
28
|
+
const common_1 = require("../../styles/common");
|
|
28
29
|
const SBase = styled_components_1.default.div `
|
|
29
30
|
display: flex;
|
|
30
31
|
flex-flow: row;
|
|
@@ -48,6 +49,7 @@ const SItems = styled_components_1.default.div `
|
|
|
48
49
|
(0, styled_components_1.css) `
|
|
49
50
|
display: flex;
|
|
50
51
|
`}
|
|
52
|
+
${({ shadow }) => shadow && (0, common_1.Shadow)(shadow)}
|
|
51
53
|
`;
|
|
52
54
|
const Dots = (react_1.default.createElement("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", fillRule: "evenodd", clipRule: "evenodd" },
|
|
53
55
|
react_1.default.createElement("path", { d: "M16 12a3.001 3.001 0 016 0 3.001 3.001 0 01-6 0zm1 0a2 2 0 114.001.001A2 2 0 0117 12zm-8 0a3.001 3.001 0 016 0 3.001 3.001 0 01-6 0zm1 0a2 2 0 114.001.001A2 2 0 0110 12zm-8 0a3.001 3.001 0 016 0 3.001 3.001 0 01-6 0zm1 0a2 2 0 114.001.001A2 2 0 013 12z" })));
|
|
@@ -80,7 +82,7 @@ const SItem = styled_components_1.default.div `
|
|
|
80
82
|
background-color: rgba(0, 0, 0, 0.2);
|
|
81
83
|
}
|
|
82
84
|
`;
|
|
83
|
-
function DropdownList({ options, value, onChange, placeholder, className, renderF, children, }) {
|
|
85
|
+
function DropdownList({ options, value, onChange, placeholder, className, renderF, children, shadow = '#555', }) {
|
|
84
86
|
var _a, _b;
|
|
85
87
|
const ref = (0, react_1.useRef)(null);
|
|
86
88
|
const [state, setState] = (0, react_1.useState)(value);
|
|
@@ -122,7 +124,7 @@ function DropdownList({ options, value, onChange, placeholder, className, render
|
|
|
122
124
|
e.preventDefault();
|
|
123
125
|
setOpen(!open);
|
|
124
126
|
} },
|
|
125
|
-
react_1.default.createElement(SItems, { open: open, style: style }, open &&
|
|
127
|
+
react_1.default.createElement(SItems, { open: open, style: style, shadow: shadow }, open &&
|
|
126
128
|
options.map((s, i) => (react_1.default.createElement(SItem, { key: renderF(s), selected: s === state, onClick: (e) => {
|
|
127
129
|
if (s !== state) {
|
|
128
130
|
onChange(s, i);
|
|
@@ -65,7 +65,7 @@ exports.IconF = styled_components_1.default.span `
|
|
|
65
65
|
stop-color: ${fill} !important;
|
|
66
66
|
}
|
|
67
67
|
`};
|
|
68
|
-
${({ outline }) => outline && (0, common_1.
|
|
68
|
+
${({ outline }) => outline && (0, common_1.HardOutline)(outline)};
|
|
69
69
|
|
|
70
70
|
width: ${({ width }) => width || '100%'};
|
|
71
71
|
height: ${({ height }) => height || '100%'};
|
|
@@ -0,0 +1,99 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.prompt = void 0;
|
|
35
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
36
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
39
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
40
|
+
const Button_1 = require("../Button");
|
|
41
|
+
const FlexColumn_1 = require("../FlexColumn");
|
|
42
|
+
const FlexRow_1 = require("../FlexRow");
|
|
43
|
+
const Modal_1 = require("../Modal");
|
|
44
|
+
const TextInput_1 = require("../TextInput");
|
|
45
|
+
const Base = styled_components_1.default.div `
|
|
46
|
+
width: 95vw;
|
|
47
|
+
max-width: 30rem;
|
|
48
|
+
height: 50vh;
|
|
49
|
+
max-height: 15rem;
|
|
50
|
+
padding: 1rem;
|
|
51
|
+
`;
|
|
52
|
+
const Content = (0, styled_components_1.default)(FlexColumn_1.FlexColumn) `
|
|
53
|
+
height: 100%;
|
|
54
|
+
`;
|
|
55
|
+
const TopText = styled_components_1.default.div `
|
|
56
|
+
font-weight: bold;
|
|
57
|
+
border-bottom: solid 1px #ccc;
|
|
58
|
+
padding-bottom: 0.25rem;
|
|
59
|
+
font-size: 1.5rem;
|
|
60
|
+
margin-bottom: 1rem;
|
|
61
|
+
`;
|
|
62
|
+
const BottomText = styled_components_1.default.div `
|
|
63
|
+
padding-bottom: 0.25rem;
|
|
64
|
+
font-size: 1.1rem;
|
|
65
|
+
`;
|
|
66
|
+
const Bottom = (0, styled_components_1.default)(FlexRow_1.FlexRow) `
|
|
67
|
+
margin-top: auto;
|
|
68
|
+
justify-content: flex-end;
|
|
69
|
+
> button:first-child {
|
|
70
|
+
margin-right: 1rem;
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
const PromptModal = ({ wrapper, res, bottomText, topText, okText = 'OK', cancelText = 'Cancel', defaultValue, placeholder, }) => {
|
|
74
|
+
const [text, setText] = (0, react_1.useState)(defaultValue || '');
|
|
75
|
+
const ret = (v) => {
|
|
76
|
+
try {
|
|
77
|
+
res(v);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
wrapper.remove();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return (react_1.default.createElement(Modal_1.Modal, { position: "center", topPosition: "center", open: true, setOpen: () => ret(undefined), showCloseButton: false, closeOnClickOutside: false },
|
|
84
|
+
react_1.default.createElement(Base, null,
|
|
85
|
+
react_1.default.createElement(Content, null,
|
|
86
|
+
topText && react_1.default.createElement(TopText, null, topText),
|
|
87
|
+
react_1.default.createElement(BottomText, null, bottomText),
|
|
88
|
+
react_1.default.createElement(TextInput_1.TextInput, { value: text, onChange: (c) => setText(c), type: "text", placeholder: placeholder }),
|
|
89
|
+
react_1.default.createElement(Bottom, { noGrow: true },
|
|
90
|
+
react_1.default.createElement(Button_1.Button, { onClick: () => ret(text) }, okText),
|
|
91
|
+
react_1.default.createElement(Button_1.Button, { invert: true, onClick: () => ret(undefined) }, cancelText))))));
|
|
92
|
+
};
|
|
93
|
+
const prompt = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
return new Promise((res) => {
|
|
95
|
+
const wrapper = document.body.appendChild(document.createElement('div'));
|
|
96
|
+
react_dom_1.default.render(react_1.default.createElement(PromptModal, Object.assign({}, p, { res: res, wrapper: wrapper })), wrapper);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
exports.prompt = prompt;
|
|
@@ -25,6 +25,7 @@ __exportStar(require("./Loader"), exports);
|
|
|
25
25
|
__exportStar(require("./LoginButton"), exports);
|
|
26
26
|
__exportStar(require("./LogoutButton"), exports);
|
|
27
27
|
__exportStar(require("./Modal"), exports);
|
|
28
|
+
__exportStar(require("./Prompt"), exports);
|
|
28
29
|
__exportStar(require("./RowOrColumn"), exports);
|
|
29
30
|
__exportStar(require("./Table"), exports);
|
|
30
31
|
__exportStar(require("./TextEdit"), exports);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { AxiosWrapper } from './jwt';
|
|
2
2
|
import { ICallOpenApi } from './types';
|
|
3
|
-
export declare const callOpenApi: <T, TDefaultApi>({ func, apiUrl, overrideAuth, refreshToken, logout, newDefaultApi, }: ICallOpenApi<T, TDefaultApi>) => Promise<AxiosWrapper<T>>;
|
|
3
|
+
export declare const callOpenApi: <T, TDefaultApi>({ func, apiUrl, overrideAuth, refreshToken, logout, newDefaultApi, headers, }: ICallOpenApi<T, TDefaultApi>) => Promise<AxiosWrapper<T>>;
|
|
@@ -13,14 +13,14 @@ exports.callOpenApi = void 0;
|
|
|
13
13
|
const cookie_1 = require("./cookie");
|
|
14
14
|
const sleep_1 = require("../../common/helpers/sleep");
|
|
15
15
|
const array_1 = require("../../common/helpers/array");
|
|
16
|
-
const callOpenApi = ({ func, apiUrl, overrideAuth, refreshToken, logout, newDefaultApi, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const callOpenApi = ({ func, apiUrl, overrideAuth, refreshToken, logout, newDefaultApi, headers, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
19
|
let error;
|
|
20
20
|
let data = undefined;
|
|
21
21
|
const config = {
|
|
22
22
|
basePath: apiUrl,
|
|
23
|
-
baseOptions: { headers: { authorization: '' } },
|
|
23
|
+
baseOptions: { headers: Object.assign({ authorization: '' }, (headers || {})) },
|
|
24
24
|
};
|
|
25
25
|
const isAuthed = !!(0, cookie_1.getCookieWrapper)({ cname: 'id_token' });
|
|
26
26
|
if (overrideAuth === null || overrideAuth === void 0 ? void 0 : overrideAuth.id_token) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const HardOutline: (colour: string) => import("styled-components").FlattenSimpleInterpolation;
|
|
3
|
+
export declare const Shadow: (colour: string) => import("styled-components").FlattenSimpleInterpolation;
|
|
3
4
|
export declare const NoTextSelect: import("styled-components").FlattenSimpleInterpolation;
|
|
4
5
|
export declare const CssTransparentBlock: import("styled-components").FlattenSimpleInterpolation;
|
|
5
6
|
export declare const FadeBottom: ({ height }: {
|
package/dist/ui/styles/common.js
CHANGED
|
@@ -19,15 +19,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.FullScreenPage = exports.noDrag = exports.Card = exports.FadeBottom = exports.CssTransparentBlock = exports.NoTextSelect = exports.
|
|
22
|
+
exports.FullScreenPage = exports.noDrag = exports.Card = exports.FadeBottom = exports.CssTransparentBlock = exports.NoTextSelect = exports.Shadow = exports.HardOutline = void 0;
|
|
23
23
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
24
24
|
const colours_1 = require("./colours");
|
|
25
|
-
const
|
|
26
|
-
filter: drop-shadow(1px 1px 0px ${
|
|
27
|
-
drop-shadow(
|
|
28
|
-
drop-shadow(-1px -1px 0px ${outline});
|
|
25
|
+
const HardOutline = (colour) => (0, styled_components_1.css) `
|
|
26
|
+
filter: drop-shadow(1px 1px 0px ${colour}) drop-shadow(-1px 1px 0px ${colour})
|
|
27
|
+
drop-shadow(1px -1px 0px ${colour}) drop-shadow(-1px -1px 0px ${colour});
|
|
29
28
|
`;
|
|
30
|
-
exports.
|
|
29
|
+
exports.HardOutline = HardOutline;
|
|
30
|
+
const Shadow = (colour) => (0, styled_components_1.css) `
|
|
31
|
+
filter: drop-shadow(1px 1px 0.5rem ${colour});
|
|
32
|
+
`;
|
|
33
|
+
exports.Shadow = Shadow;
|
|
31
34
|
exports.NoTextSelect = (0, styled_components_1.css) `
|
|
32
35
|
user-select: none; /* supported by Chrome and Opera */
|
|
33
36
|
-webkit-user-select: none; /* Safari */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.119",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Andrei Gec <@andreigec> (https://gec.dev/)",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"@types/react": "17.0.38",
|
|
33
33
|
"@types/react-dom": "17.0.11",
|
|
34
34
|
"@types/styled-components": "5.1.21",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "5.10.
|
|
36
|
-
"@typescript-eslint/parser": "5.10.
|
|
37
|
-
"eslint": "8.
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "5.10.2",
|
|
36
|
+
"@typescript-eslint/parser": "5.10.2",
|
|
37
|
+
"eslint": "8.8.0",
|
|
38
38
|
"eslint-config-airbnb-typescript": "16.1.0",
|
|
39
39
|
"eslint-config-prettier": "8.3.0",
|
|
40
40
|
"eslint-config-react-app": "7.0.0",
|