ag-common 0.0.211 → 0.0.214
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/Button/index.d.ts +5 -3
- package/dist/ui/components/HeadersRaw/index.d.ts +5 -4
- package/dist/ui/components/Icon/index.d.ts +3 -4
- package/dist/ui/components/Prompt/Dialog.d.ts +7 -0
- package/dist/ui/components/Prompt/Dialog.js +25 -0
- package/dist/ui/components/Prompt/Modal.d.ts +11 -0
- package/dist/ui/components/Prompt/Modal.js +96 -0
- package/dist/ui/components/Prompt/index.d.ts +2 -6
- package/dist/ui/components/Prompt/index.js +4 -97
- package/dist/ui/components/Sidebar/index.js +1 -1
- package/dist/ui/components/Toast/index.d.ts +2 -3
- package/package.json +5 -9
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
2
2
|
export declare const ButtonBase: import("styled-components").FlattenSimpleInterpolation;
|
|
3
|
-
export
|
|
3
|
+
export interface IButton {
|
|
4
4
|
title?: string;
|
|
5
5
|
invert?: boolean;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
className?: string;
|
|
8
8
|
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
9
9
|
onKeyPress?: KeyboardEventHandler<HTMLButtonElement>;
|
|
10
|
-
|
|
10
|
+
children: string | JSX.Element;
|
|
11
|
+
}
|
|
12
|
+
export declare const Button: (props: IButton) => JSX.Element;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export
|
|
3
|
-
title?: string
|
|
4
|
-
image?: string
|
|
2
|
+
export interface IHeadersRaw {
|
|
3
|
+
title?: string;
|
|
4
|
+
image?: string;
|
|
5
5
|
SiteShort: string;
|
|
6
6
|
FullSiteUrl: string;
|
|
7
7
|
siteDesc: string;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
|
+
export declare const HeadersRaw: ({ title, image, SiteShort, FullSiteUrl, siteDesc, }: IHeadersRaw) => JSX.Element[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
interface
|
|
2
|
+
export interface IIconProps {
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
fill?: string;
|
|
5
5
|
outline?: string;
|
|
@@ -16,6 +16,5 @@ interface IIcon {
|
|
|
16
16
|
tabIndex?: number;
|
|
17
17
|
className?: string;
|
|
18
18
|
}
|
|
19
|
-
export declare const IconF: import("styled-components").StyledComponent<"span", any,
|
|
20
|
-
export declare const Icon: (pr:
|
|
21
|
-
export {};
|
|
19
|
+
export declare const IconF: import("styled-components").StyledComponent<"span", any, IIconProps, never>;
|
|
20
|
+
export declare const Icon: (pr: IIconProps) => JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
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.PromptDialog = void 0;
|
|
16
|
+
const Modal_1 = require("./Modal");
|
|
17
|
+
const react_1 = __importDefault(require("react"));
|
|
18
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
19
|
+
const PromptDialog = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
return new Promise((res) => {
|
|
21
|
+
const wrapper = document.body.appendChild(document.createElement('div'));
|
|
22
|
+
react_dom_1.default.render(react_1.default.createElement(Modal_1.PromptModal, Object.assign({}, p, { res: res, wrapper: wrapper })), wrapper);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
exports.PromptDialog = PromptDialog;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const PromptModal: ({ wrapper, res, bottomText, topText, okText, cancelText, defaultValue, placeholder, }: {
|
|
3
|
+
defaultValue?: string | undefined;
|
|
4
|
+
placeholder?: string | undefined;
|
|
5
|
+
res: (v: string | undefined) => void;
|
|
6
|
+
wrapper: HTMLDivElement;
|
|
7
|
+
topText?: string | undefined;
|
|
8
|
+
bottomText: string;
|
|
9
|
+
okText?: string | undefined;
|
|
10
|
+
cancelText?: string | undefined;
|
|
11
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.PromptModal = void 0;
|
|
30
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
31
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
32
|
+
const Button_1 = require("../Button");
|
|
33
|
+
const FlexColumn_1 = require("../FlexColumn");
|
|
34
|
+
const FlexRow_1 = require("../FlexRow");
|
|
35
|
+
const Modal_1 = require("../Modal");
|
|
36
|
+
const TextEdit_1 = require("../TextEdit");
|
|
37
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
38
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
39
|
+
const react_1 = __importStar(require("react"));
|
|
40
|
+
const Base = styled_components_1.default.div `
|
|
41
|
+
width: 95vw;
|
|
42
|
+
max-width: 30rem;
|
|
43
|
+
height: 50vh;
|
|
44
|
+
max-height: 15rem;
|
|
45
|
+
padding: 1rem;
|
|
46
|
+
`;
|
|
47
|
+
const Content = (0, styled_components_1.default)(FlexColumn_1.FlexColumn) `
|
|
48
|
+
height: 100%;
|
|
49
|
+
`;
|
|
50
|
+
const TopText = styled_components_1.default.div `
|
|
51
|
+
font-weight: bold;
|
|
52
|
+
border-bottom: solid 1px #ccc;
|
|
53
|
+
padding-bottom: 0.25rem;
|
|
54
|
+
font-size: 1.5rem;
|
|
55
|
+
margin-bottom: 1rem;
|
|
56
|
+
`;
|
|
57
|
+
const BottomText = styled_components_1.default.div `
|
|
58
|
+
padding-bottom: 0.25rem;
|
|
59
|
+
font-size: 1.1rem;
|
|
60
|
+
`;
|
|
61
|
+
const Bottom = (0, styled_components_1.default)(FlexRow_1.FlexRow) `
|
|
62
|
+
margin-top: auto;
|
|
63
|
+
justify-content: flex-end;
|
|
64
|
+
> button:first-child {
|
|
65
|
+
margin-right: 1rem;
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
const PromptModal = ({ wrapper, res, bottomText, topText, okText = 'OK', cancelText = 'Cancel', defaultValue, placeholder, }) => {
|
|
69
|
+
const [text, setText] = (0, react_1.useState)(defaultValue || '');
|
|
70
|
+
const ret = (v) => {
|
|
71
|
+
try {
|
|
72
|
+
res(v);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
react_dom_1.default.unmountComponentAtNode(wrapper);
|
|
76
|
+
wrapper.remove();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return (react_1.default.createElement(Modal_1.Modal, { position: "center", topPosition: "center", open: true, setOpen: () => ret(undefined), showCloseButton: false, closeOnClickOutside: false },
|
|
80
|
+
react_1.default.createElement(Base, null,
|
|
81
|
+
react_1.default.createElement(Content, null,
|
|
82
|
+
topText && react_1.default.createElement(TopText, null, topText),
|
|
83
|
+
react_1.default.createElement(BottomText, null, bottomText),
|
|
84
|
+
react_1.default.createElement(TextEdit_1.TextEdit, { defaultValue: text, onSubmit: (c, enter) => {
|
|
85
|
+
if (enter) {
|
|
86
|
+
ret(c);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
setText(c);
|
|
90
|
+
}
|
|
91
|
+
}, placeholder: placeholder, defaultEditing: { focus: true }, singleLine: true, noGrow: true }),
|
|
92
|
+
react_1.default.createElement(Bottom, { noGrow: true },
|
|
93
|
+
react_1.default.createElement(Button_1.Button, { onClick: () => ret(text) }, okText),
|
|
94
|
+
react_1.default.createElement(Button_1.Button, { invert: true, onClick: () => ret(undefined) }, cancelText))))));
|
|
95
|
+
};
|
|
96
|
+
exports.PromptModal = PromptModal;
|
|
@@ -10,102 +10,9 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
-
var
|
|
14
|
-
|
|
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
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
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);
|
|
36
15
|
};
|
|
37
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports
|
|
39
|
-
|
|
40
|
-
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
41
|
-
const Button_1 = require("../Button");
|
|
42
|
-
const FlexColumn_1 = require("../FlexColumn");
|
|
43
|
-
const FlexRow_1 = require("../FlexRow");
|
|
44
|
-
const Modal_1 = require("../Modal");
|
|
45
|
-
const TextEdit_1 = require("../TextEdit");
|
|
46
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
47
|
-
const react_dom_1 = __importDefault(require("react-dom"));
|
|
48
|
-
const react_1 = __importStar(require("react"));
|
|
49
|
-
const Base = styled_components_1.default.div `
|
|
50
|
-
width: 95vw;
|
|
51
|
-
max-width: 30rem;
|
|
52
|
-
height: 50vh;
|
|
53
|
-
max-height: 15rem;
|
|
54
|
-
padding: 1rem;
|
|
55
|
-
`;
|
|
56
|
-
const Content = (0, styled_components_1.default)(FlexColumn_1.FlexColumn) `
|
|
57
|
-
height: 100%;
|
|
58
|
-
`;
|
|
59
|
-
const TopText = styled_components_1.default.div `
|
|
60
|
-
font-weight: bold;
|
|
61
|
-
border-bottom: solid 1px #ccc;
|
|
62
|
-
padding-bottom: 0.25rem;
|
|
63
|
-
font-size: 1.5rem;
|
|
64
|
-
margin-bottom: 1rem;
|
|
65
|
-
`;
|
|
66
|
-
const BottomText = styled_components_1.default.div `
|
|
67
|
-
padding-bottom: 0.25rem;
|
|
68
|
-
font-size: 1.1rem;
|
|
69
|
-
`;
|
|
70
|
-
const Bottom = (0, styled_components_1.default)(FlexRow_1.FlexRow) `
|
|
71
|
-
margin-top: auto;
|
|
72
|
-
justify-content: flex-end;
|
|
73
|
-
> button:first-child {
|
|
74
|
-
margin-right: 1rem;
|
|
75
|
-
}
|
|
76
|
-
`;
|
|
77
|
-
const PromptModal = ({ wrapper, res, bottomText, topText, okText = 'OK', cancelText = 'Cancel', defaultValue, placeholder, }) => {
|
|
78
|
-
const [text, setText] = (0, react_1.useState)(defaultValue || '');
|
|
79
|
-
const ret = (v) => {
|
|
80
|
-
try {
|
|
81
|
-
res(v);
|
|
82
|
-
}
|
|
83
|
-
finally {
|
|
84
|
-
react_dom_1.default.unmountComponentAtNode(wrapper);
|
|
85
|
-
wrapper.remove();
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
return (react_1.default.createElement(Modal_1.Modal, { position: "center", topPosition: "center", open: true, setOpen: () => ret(undefined), showCloseButton: false, closeOnClickOutside: false },
|
|
89
|
-
react_1.default.createElement(Base, null,
|
|
90
|
-
react_1.default.createElement(Content, null,
|
|
91
|
-
topText && react_1.default.createElement(TopText, null, topText),
|
|
92
|
-
react_1.default.createElement(BottomText, null, bottomText),
|
|
93
|
-
react_1.default.createElement(TextEdit_1.TextEdit, { defaultValue: text, onSubmit: (c, enter) => {
|
|
94
|
-
if (enter) {
|
|
95
|
-
ret(c);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
setText(c);
|
|
99
|
-
}
|
|
100
|
-
}, placeholder: placeholder, defaultEditing: { focus: true }, singleLine: true, noGrow: true }),
|
|
101
|
-
react_1.default.createElement(Bottom, { noGrow: true },
|
|
102
|
-
react_1.default.createElement(Button_1.Button, { onClick: () => ret(text) }, okText),
|
|
103
|
-
react_1.default.createElement(Button_1.Button, { invert: true, onClick: () => ret(undefined) }, cancelText))))));
|
|
104
|
-
};
|
|
105
|
-
const prompt = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
return new Promise((res) => {
|
|
107
|
-
const wrapper = document.body.appendChild(document.createElement('div'));
|
|
108
|
-
react_dom_1.default.render(react_1.default.createElement(PromptModal, Object.assign({}, p, { res: res, wrapper: wrapper })), wrapper);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
exports.prompt = prompt;
|
|
17
|
+
__exportStar(require("./Dialog"), exports);
|
|
18
|
+
__exportStar(require("./Modal"), exports);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ToastPosition } from 'react-hot-toast';
|
|
3
|
-
interface
|
|
3
|
+
export interface IToastOptions {
|
|
4
4
|
appearance: 'error' | 'success';
|
|
5
5
|
autoClose?: number;
|
|
6
6
|
}
|
|
7
|
-
export declare const addToast: (m: string, options?:
|
|
7
|
+
export declare const addToast: (m: string, options?: IToastOptions | undefined) => void;
|
|
8
8
|
export declare const ToastProvider: ({ position }: {
|
|
9
9
|
position: ToastPosition;
|
|
10
10
|
}) => JSX.Element;
|
|
11
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.214",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Andrei Gec <@andreigec> (https://gec.dev/)",
|
|
@@ -9,7 +9,7 @@
|
|
|
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 lint && tsc
|
|
12
|
+
"build": "rimraf dist && yarn lint && tsc",
|
|
13
13
|
"lint": "npx eslint --ext .ts,.tsx ./src",
|
|
14
14
|
"start": "cross-env BROWSER=none start-storybook -p 6006",
|
|
15
15
|
"build-storybook": "build-storybook -o docs --quiet"
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@babel/core": "7.17.8",
|
|
34
|
-
"@mdx-js/react": "1.6.22",
|
|
35
34
|
"@storybook/addon-actions": "6.4.20",
|
|
36
35
|
"@storybook/addon-docs": "6.4.20",
|
|
37
36
|
"@storybook/addon-essentials": "6.4.20",
|
|
38
37
|
"@storybook/addon-interactions": "6.4.20",
|
|
39
38
|
"@storybook/addon-links": "6.4.20",
|
|
39
|
+
"@storybook/addons": "^6.4.20",
|
|
40
40
|
"@storybook/react": "6.4.20",
|
|
41
|
-
"@storybook/
|
|
41
|
+
"@storybook/theming": "^6.4.20",
|
|
42
42
|
"@types/jsonwebtoken": "8.5.8",
|
|
43
43
|
"@types/node": "17.0.23",
|
|
44
44
|
"@types/react": "17.0.43",
|
|
@@ -46,21 +46,17 @@
|
|
|
46
46
|
"@types/styled-components": "5.1.24",
|
|
47
47
|
"@typescript-eslint/eslint-plugin": "5.18.0",
|
|
48
48
|
"@typescript-eslint/parser": "5.18.0",
|
|
49
|
-
"babel-loader": "8.2.4",
|
|
50
49
|
"cross-env": "7.0.3",
|
|
51
50
|
"eslint": "8.12.0",
|
|
52
51
|
"eslint-config-airbnb-typescript": "16.2.0",
|
|
53
52
|
"eslint-config-prettier": "8.5.0",
|
|
54
|
-
"eslint-config-react-app": "7.0.0",
|
|
55
53
|
"eslint-plugin-import": "2.25.4",
|
|
56
54
|
"eslint-plugin-jsx-a11y": "6.5.1",
|
|
57
55
|
"eslint-plugin-prettier": "4.0.0",
|
|
58
56
|
"eslint-plugin-react": "7.29.4",
|
|
59
57
|
"eslint-plugin-react-hooks": "4.4.0",
|
|
60
58
|
"prettier": "2.6.2",
|
|
61
|
-
"rimraf": "3.0.2"
|
|
62
|
-
"storybook": "6.4.20",
|
|
63
|
-
"typescript-styled-plugin": "0.18.2"
|
|
59
|
+
"rimraf": "3.0.2"
|
|
64
60
|
},
|
|
65
61
|
"files": [
|
|
66
62
|
"dist/**/*",
|