ag-common 0.0.261 → 0.0.264
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/validations.d.ts +1 -0
- package/dist/api/helpers/validations.js +1 -0
- package/dist/ui/components/BorderGradient/index.d.ts +17 -15
- package/dist/ui/components/BorderGradient/index.js +20 -40
- package/dist/ui/components/DropdownList/index.js +8 -8
- package/dist/ui/components/Icon/index.d.ts +5 -1
- package/dist/ui/components/Icon/index.js +30 -59
- package/dist/ui/styles/common.d.ts +1 -1
- package/dist/ui/styles/common.js +3 -4
- package/package.json +6 -6
|
@@ -58,6 +58,7 @@ const jwtVerify = ({ token, jwksUri, issuer, }) => __awaiter(void 0, void 0, voi
|
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
|
+
/** extracts user details from oauth token */
|
|
61
62
|
const getAndValidateToken = ({ tokenRaw, jwksRegion = 'ap-southeast-2', COGNITO_USER_POOL_ID, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
63
|
var _a, _b;
|
|
63
64
|
const jwksUri = `https://cognito-idp.${jwksRegion}.amazonaws.com/${COGNITO_USER_POOL_ID}/.well-known/jwks.json`;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare type IOnClick = React.MouseEvent<HTMLDivElement, MouseEvent> | React.MouseEvent<HTMLAnchorElement, MouseEvent>;
|
|
3
|
-
export
|
|
4
|
-
canClick?: boolean
|
|
5
|
-
noGrow?: boolean
|
|
6
|
-
className?: string
|
|
7
|
-
fill?: boolean
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
export interface IBorderGradient {
|
|
4
|
+
canClick?: boolean;
|
|
5
|
+
noGrow?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
fill?: boolean;
|
|
8
|
+
/** default 2rem */
|
|
9
|
+
radius?: string;
|
|
10
|
+
left?: string;
|
|
11
|
+
right?: string;
|
|
11
12
|
children: JSX.Element | (JSX.Element | string | number | undefined)[];
|
|
12
|
-
padding?: string
|
|
13
|
-
onClick?: (
|
|
14
|
-
href?: string
|
|
15
|
-
target?: string
|
|
16
|
-
rel?: string
|
|
17
|
-
disabled?: boolean
|
|
18
|
-
}
|
|
13
|
+
padding?: string;
|
|
14
|
+
onClick?: (e: IOnClick) => void;
|
|
15
|
+
href?: string;
|
|
16
|
+
target?: string;
|
|
17
|
+
rel?: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const BorderGradient: ({ left, right, children, radius, fill, padding, className, onClick, href, target, rel, noGrow, disabled, canClick, }: IBorderGradient) => JSX.Element;
|
|
19
21
|
export {};
|
|
@@ -34,36 +34,16 @@ const BGcss = (0, styled_components_1.css) `
|
|
|
34
34
|
display: flex;
|
|
35
35
|
border: 0;
|
|
36
36
|
padding: 3px;
|
|
37
|
-
border-radius: ${({ radius }) => radius};
|
|
38
37
|
background-image: linear-gradient(white, white),
|
|
39
|
-
linear-gradient(
|
|
40
|
-
to bottom right,
|
|
41
|
-
${({ left }) => left},
|
|
42
|
-
${({ right }) => right}
|
|
43
|
-
);
|
|
38
|
+
linear-gradient(to bottom right, var(--left), var(--right));
|
|
44
39
|
background-origin: border-box;
|
|
45
40
|
background-clip: content-box, border-box;
|
|
46
41
|
overflow: hidden;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
(0, styled_components_1.css) `
|
|
53
|
-
filter: grayscale(1);
|
|
54
|
-
`}
|
|
55
|
-
|
|
56
|
-
${({ canClick, disabled }) => (0, styled_components_1.css) `
|
|
57
|
-
cursor: ${canClick && !disabled ? 'pointer' : 'default'};
|
|
58
|
-
`}
|
|
59
|
-
|
|
60
|
-
${({ canClick, disabled }) => canClick &&
|
|
61
|
-
!disabled &&
|
|
62
|
-
(0, styled_components_1.css) `
|
|
63
|
-
&:hover {
|
|
64
|
-
filter: saturate(3);
|
|
65
|
-
}
|
|
66
|
-
`}
|
|
42
|
+
&[data-ccnd='true'] {
|
|
43
|
+
&:hover {
|
|
44
|
+
filter: saturate(3);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
67
47
|
`;
|
|
68
48
|
const BGLink = styled_components_1.default.div `
|
|
69
49
|
${BGcss};
|
|
@@ -76,37 +56,37 @@ const Padding = styled_components_1.default.div `
|
|
|
76
56
|
align-items: center;
|
|
77
57
|
display: flex;
|
|
78
58
|
flex-flow: column;
|
|
79
|
-
padding: ${({ padding }) => padding};
|
|
80
59
|
border: 0;
|
|
81
60
|
flex-grow: 1;
|
|
82
61
|
`;
|
|
83
62
|
const FeatureBoxFill = (0, styled_components_1.default)(Padding) `
|
|
84
|
-
background-image: linear-gradient(
|
|
85
|
-
to bottom right,
|
|
86
|
-
${({ left }) => left},
|
|
87
|
-
${({ right }) => right}
|
|
88
|
-
);
|
|
63
|
+
background-image: linear-gradient(to bottom right, var(--left), var(--right));
|
|
89
64
|
color: ${colours_1.colours.mainLight};
|
|
90
|
-
border-radius: ${({ radius }) => radius};
|
|
91
65
|
flex-grow: 1;
|
|
92
66
|
`;
|
|
93
67
|
const BorderGradient = ({ left = colours_1.colours.orange, right = colours_1.colours.orangeRed, children, radius = '2rem', fill = false, padding = '2rem', className, onClick, href, target, rel, noGrow = false, disabled = false, canClick = false, }) => {
|
|
68
|
+
const CCND = canClick && !disabled;
|
|
69
|
+
const style = {
|
|
70
|
+
flexGrow: noGrow ? 0 : 1,
|
|
71
|
+
'--left': left,
|
|
72
|
+
'--right': right,
|
|
73
|
+
borderRadius: radius,
|
|
74
|
+
filter: !disabled ? '' : 'grayscale(1)',
|
|
75
|
+
cursor: CCND ? 'pointer' : 'default',
|
|
76
|
+
};
|
|
94
77
|
const props = {
|
|
95
78
|
onClick: (e) => !disabled && onClick && onClick(e),
|
|
96
79
|
className,
|
|
97
|
-
left: (!fill && left) || undefined,
|
|
98
|
-
right: (!fill && right) || undefined,
|
|
99
|
-
radius,
|
|
100
80
|
href,
|
|
101
81
|
target,
|
|
102
82
|
rel,
|
|
103
|
-
noGrow,
|
|
104
|
-
disabled,
|
|
105
83
|
canClick: !!onClick || canClick,
|
|
84
|
+
style,
|
|
85
|
+
'data-ccnd': CCND,
|
|
106
86
|
};
|
|
107
87
|
const child = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
108
|
-
!fill && react_1.default.createElement(Padding, {
|
|
109
|
-
fill &&
|
|
88
|
+
!fill && react_1.default.createElement(Padding, { style: { padding } }, children),
|
|
89
|
+
fill && react_1.default.createElement(FeatureBoxFill, { style: { padding } }, children)));
|
|
110
90
|
if (href) {
|
|
111
91
|
return react_1.default.createElement(BGALink, Object.assign({}, props), child);
|
|
112
92
|
}
|
|
@@ -22,6 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
exports.DropdownList = void 0;
|
|
27
30
|
const dom_1 = require("../../helpers/dom");
|
|
@@ -29,7 +32,7 @@ const common_1 = require("../../styles/common");
|
|
|
29
32
|
const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
|
|
30
33
|
const colours_1 = require("../../styles/colours");
|
|
31
34
|
const KebabDots_1 = require("../KebabDots");
|
|
32
|
-
const styled_components_1 =
|
|
35
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
36
|
const react_1 = __importStar(require("react"));
|
|
34
37
|
const SBase = styled_components_1.default.div `
|
|
35
38
|
display: flex;
|
|
@@ -48,11 +51,6 @@ const DropItems = styled_components_1.default.div `
|
|
|
48
51
|
cursor: default;
|
|
49
52
|
width: 100%;
|
|
50
53
|
position: absolute;
|
|
51
|
-
${({ shadow }) => shadow && (0, common_1.Shadow)(shadow)}
|
|
52
|
-
${({ maxHeight }) => maxHeight &&
|
|
53
|
-
(0, styled_components_1.css) `
|
|
54
|
-
max-height: ${maxHeight};
|
|
55
|
-
`}
|
|
56
54
|
|
|
57
55
|
overflow-y: auto;
|
|
58
56
|
&[data-open='true'] {
|
|
@@ -137,10 +135,12 @@ function DropdownList(p) {
|
|
|
137
135
|
else {
|
|
138
136
|
newStyle.top = '0';
|
|
139
137
|
}
|
|
138
|
+
newStyle.filter = `drop-shadow(1px 1px 0.5rem ${shadow})`;
|
|
139
|
+
newStyle.maxHeight = maxHeight;
|
|
140
140
|
if (JSON.stringify(style) !== JSON.stringify(newStyle)) {
|
|
141
141
|
setStyle(newStyle);
|
|
142
142
|
}
|
|
143
|
-
}, [open, options, renderF, style]);
|
|
143
|
+
}, [maxHeight, open, options, renderF, shadow, style]);
|
|
144
144
|
const defaultRender = !p.value ? react_1.default.createElement(KebabDots_1.KebabDots, null) : react_1.default.createElement(react_1.default.Fragment, null, p.renderF(p.value));
|
|
145
145
|
const defaultKey = !p.value ? '(noval)' : p.renderF(p.value);
|
|
146
146
|
const openDisplay = p.children || (react_1.default.createElement(ListItem, { selected: true, render: defaultRender, key: defaultKey, defaultV: !p.value }));
|
|
@@ -154,7 +154,7 @@ function DropdownList(p) {
|
|
|
154
154
|
e.preventDefault();
|
|
155
155
|
setOpen(!open);
|
|
156
156
|
} },
|
|
157
|
-
react_1.default.createElement(DropItems, { "data-open": open, style: style,
|
|
157
|
+
react_1.default.createElement(DropItems, { "data-open": open, style: style, "data-bounced": bounced }, open &&
|
|
158
158
|
options.map((s, i) => (react_1.default.createElement(ListItem, { key: p.renderF(s), render: p.renderF(s), onChange: () => p.onChange(s, i), selected: s === state })))),
|
|
159
159
|
openDisplay));
|
|
160
160
|
}
|
|
@@ -3,11 +3,15 @@ export interface IIconProps {
|
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
fill?: string;
|
|
5
5
|
outline?: string;
|
|
6
|
+
/** default 100% */
|
|
6
7
|
width?: string;
|
|
8
|
+
/** default 100% */
|
|
7
9
|
height?: string;
|
|
8
10
|
rotate?: number;
|
|
9
11
|
canHover?: boolean;
|
|
12
|
+
/** default 'unset' */
|
|
10
13
|
margin?: string;
|
|
14
|
+
/** default 0 */
|
|
11
15
|
padding?: string;
|
|
12
16
|
onClick?: (e: React.MouseEvent<HTMLSpanElement, MouseEvent>) => void;
|
|
13
17
|
children?: JSX.Element | JSX.Element[];
|
|
@@ -16,5 +20,5 @@ export interface IIconProps {
|
|
|
16
20
|
tabIndex?: number;
|
|
17
21
|
className?: string;
|
|
18
22
|
}
|
|
19
|
-
export declare const IconF: import("styled-components").StyledComponent<"span", any,
|
|
23
|
+
export declare const IconF: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
20
24
|
export declare const Icon: (pr: IIconProps) => JSX.Element;
|
|
@@ -1,27 +1,4 @@
|
|
|
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
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
@@ -29,54 +6,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
6
|
exports.Icon = exports.IconF = void 0;
|
|
30
7
|
const common_1 = require("../../styles/common");
|
|
31
8
|
const react_1 = __importDefault(require("react"));
|
|
32
|
-
const styled_components_1 =
|
|
9
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
10
|
exports.IconF = styled_components_1.default.span `
|
|
34
11
|
transition: all 200ms;
|
|
35
12
|
display: flex;
|
|
36
13
|
justify-content: center;
|
|
37
14
|
align-items: center;
|
|
38
15
|
font-size: 2rem;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
16
|
+
cursor: inherit;
|
|
17
|
+
&[data-chnd='true'] {
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
&:hover {
|
|
20
|
+
filter: saturate(3);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
42
24
|
> svg {
|
|
43
25
|
flex-grow: 1;
|
|
44
26
|
}
|
|
45
|
-
${({ disabled }) => disabled &&
|
|
46
|
-
(0, styled_components_1.css) `
|
|
47
|
-
filter: grayscale(1);
|
|
48
|
-
`}
|
|
49
|
-
${({ canHover, disabled }) => canHover &&
|
|
50
|
-
!disabled &&
|
|
51
|
-
(0, styled_components_1.css) `
|
|
52
|
-
&:hover {
|
|
53
|
-
filter: saturate(3);
|
|
54
|
-
}
|
|
55
|
-
`}
|
|
56
27
|
|
|
57
|
-
|
|
28
|
+
fill: var(--fill);
|
|
58
29
|
|
|
59
|
-
|
|
60
|
-
(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
svg {
|
|
64
|
-
fill: ${fill};
|
|
65
|
-
}
|
|
30
|
+
svg {
|
|
31
|
+
fill: var(--fill);
|
|
32
|
+
}
|
|
66
33
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
`};
|
|
72
|
-
${({ outline }) => outline && (0, common_1.HardOutline)(outline)};
|
|
34
|
+
linearGradient > *,
|
|
35
|
+
radialGradient > * {
|
|
36
|
+
stop-color: var(--fill) !important;
|
|
37
|
+
}
|
|
73
38
|
|
|
74
|
-
|
|
75
|
-
height: ${({ height }) => height || '100%'};
|
|
76
|
-
${({ rotate }) => rotate &&
|
|
77
|
-
(0, styled_components_1.css) `
|
|
78
|
-
transform: rotate(${rotate}deg);
|
|
79
|
-
`};
|
|
39
|
+
${common_1.HardOutline}
|
|
80
40
|
|
|
81
41
|
svg {
|
|
82
42
|
width: 100%;
|
|
@@ -85,6 +45,17 @@ exports.IconF = styled_components_1.default.span `
|
|
|
85
45
|
`;
|
|
86
46
|
const Icon = (pr) => {
|
|
87
47
|
const { className, children, disabled, onClick } = pr;
|
|
88
|
-
|
|
48
|
+
const CHND = pr.canHover && !pr.disabled;
|
|
49
|
+
const style = {
|
|
50
|
+
'--fill': pr.fill || '',
|
|
51
|
+
width: pr.width || '100%',
|
|
52
|
+
height: pr.height || '100%',
|
|
53
|
+
padding: pr.padding || '0',
|
|
54
|
+
margin: pr.margin || 'unset',
|
|
55
|
+
transform: !pr.rotate ? '' : `rotate(${pr.rotate || 0}deg)`,
|
|
56
|
+
filter: !pr.disabled ? '' : 'grayscale(1)',
|
|
57
|
+
'--outlinecolour': pr.outline || '',
|
|
58
|
+
};
|
|
59
|
+
return (react_1.default.createElement(exports.IconF, Object.assign({}, pr, { className: className, onClick: (e) => !disabled && (onClick === null || onClick === void 0 ? void 0 : onClick(e)), style: style, "data-chnd": CHND }), children));
|
|
89
60
|
};
|
|
90
61
|
exports.Icon = Icon;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const HardOutline: (
|
|
2
|
+
export declare const HardOutline = "\n filter: drop-shadow(1px 1px 0px var(--outlinecolour)) drop-shadow(-1px 1px 0px var(--outlinecolour))\n drop-shadow(1px -1px 0px var(--outlinecolour)) drop-shadow(-1px -1px 0px var(--outlinecolour));\n";
|
|
3
3
|
export declare const Shadow: (colour?: string) => import("styled-components").FlattenSimpleInterpolation;
|
|
4
4
|
export declare const NoTextSelect: import("styled-components").FlattenSimpleInterpolation;
|
|
5
5
|
export declare const TextOverflowEllipsis: import("styled-components").FlattenSimpleInterpolation;
|
package/dist/ui/styles/common.js
CHANGED
|
@@ -26,11 +26,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.bounce = exports.FullScreenPage = exports.noDrag = exports.Card = exports.FadeBottom = exports.CssTransparentBlock = exports.TextOverflowEllipsis = exports.NoTextSelect = exports.Shadow = exports.HardOutline = void 0;
|
|
27
27
|
const colours_1 = require("./colours");
|
|
28
28
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
29
|
-
|
|
30
|
-
filter: drop-shadow(1px 1px 0px
|
|
31
|
-
drop-shadow(1px -1px 0px
|
|
29
|
+
exports.HardOutline = `
|
|
30
|
+
filter: drop-shadow(1px 1px 0px var(--outlinecolour)) drop-shadow(-1px 1px 0px var(--outlinecolour))
|
|
31
|
+
drop-shadow(1px -1px 0px var(--outlinecolour)) drop-shadow(-1px -1px 0px var(--outlinecolour));
|
|
32
32
|
`;
|
|
33
|
-
exports.HardOutline = HardOutline;
|
|
34
33
|
const Shadow = (
|
|
35
34
|
/**
|
|
36
35
|
* colour of shadow, default #555
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.264",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Andrei Gec <@andreigec> (https://gec.dev/)",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"jsonwebtoken": "8.x",
|
|
23
23
|
"jwks-rsa": "2.x",
|
|
24
24
|
"node-cache": "5.x",
|
|
25
|
-
"openapi-request-validator": "
|
|
25
|
+
"openapi-request-validator": "12.0.0",
|
|
26
26
|
"react": "18.2.0",
|
|
27
27
|
"react-dom": "18.2.0",
|
|
28
28
|
"react-hot-toast": "2.x",
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"@storybook/react": "6.5.9",
|
|
41
41
|
"@storybook/theming": "6.5.9",
|
|
42
42
|
"@types/jsonwebtoken": "8.5.8",
|
|
43
|
-
"@types/node": "
|
|
43
|
+
"@types/node": "18.0.0",
|
|
44
44
|
"@types/react": "17.0.43",
|
|
45
45
|
"@types/react-dom": "17.0.14",
|
|
46
46
|
"@types/styled-components": "5.1.25",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
48
|
-
"@typescript-eslint/parser": "5.
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "5.29.0",
|
|
48
|
+
"@typescript-eslint/parser": "5.29.0",
|
|
49
49
|
"cross-env": "7.0.3",
|
|
50
|
-
"eslint": "8.
|
|
50
|
+
"eslint": "8.18.0",
|
|
51
51
|
"eslint-config-airbnb-typescript": "17.0.0",
|
|
52
52
|
"eslint-config-prettier": "8.5.0",
|
|
53
53
|
"eslint-plugin-import": "2.26.0",
|