ag-common 0.0.3
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/api.d.ts +16 -0
- package/dist/api/helpers/api.js +67 -0
- package/dist/api/helpers/dynamo.d.ts +44 -0
- package/dist/api/helpers/dynamo.js +307 -0
- package/dist/api/helpers/dynamoInfra.d.ts +15 -0
- package/dist/api/helpers/dynamoInfra.js +64 -0
- package/dist/api/helpers/index.d.ts +3 -0
- package/dist/api/helpers/index.js +15 -0
- package/dist/api/helpers/openApiHelpers.d.ts +14 -0
- package/dist/api/helpers/openApiHelpers.js +131 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +14 -0
- package/dist/api/types.d.ts +45 -0
- package/dist/api/types.js +2 -0
- package/dist/common/helpers/array.d.ts +9 -0
- package/dist/common/helpers/array.js +51 -0
- package/dist/common/helpers/distinctBy.d.ts +8 -0
- package/dist/common/helpers/distinctBy.js +35 -0
- package/dist/common/helpers/email.d.ts +7 -0
- package/dist/common/helpers/email.js +35 -0
- package/dist/common/helpers/groupBy.d.ts +22 -0
- package/dist/common/helpers/groupBy.js +53 -0
- package/dist/common/helpers/hashCode.d.ts +2 -0
- package/dist/common/helpers/hashCode.js +27 -0
- package/dist/common/helpers/i18n.d.ts +11 -0
- package/dist/common/helpers/i18n.js +14 -0
- package/dist/common/helpers/index.d.ts +12 -0
- package/dist/common/helpers/index.js +24 -0
- package/dist/common/helpers/log.d.ts +5 -0
- package/dist/common/helpers/log.js +25 -0
- package/dist/common/helpers/math.d.ts +11 -0
- package/dist/common/helpers/math.js +65 -0
- package/dist/common/helpers/object.d.ts +17 -0
- package/dist/common/helpers/object.js +54 -0
- package/dist/common/helpers/random.d.ts +1 -0
- package/dist/common/helpers/random.js +26 -0
- package/dist/common/helpers/secondsInNearest.d.ts +8 -0
- package/dist/common/helpers/secondsInNearest.js +39 -0
- package/dist/common/helpers/string.d.ts +9 -0
- package/dist/common/helpers/string.js +62 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +13 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +15 -0
- package/dist/ui/components/Button/index.d.ts +11 -0
- package/dist/ui/components/Button/index.js +45 -0
- package/dist/ui/components/Dropdown/index.d.ts +10 -0
- package/dist/ui/components/Dropdown/index.js +61 -0
- package/dist/ui/components/DropdownList/index.d.ts +9 -0
- package/dist/ui/components/DropdownList/index.js +124 -0
- package/dist/ui/components/FlexColumn/index.d.ts +6 -0
- package/dist/ui/components/FlexColumn/index.js +31 -0
- package/dist/ui/components/FlexRow/index.d.ts +7 -0
- package/dist/ui/components/FlexRow/index.js +42 -0
- package/dist/ui/components/HeadersRaw/index.d.ts +10 -0
- package/dist/ui/components/HeadersRaw/index.js +44 -0
- package/dist/ui/components/Input/index.d.ts +15 -0
- package/dist/ui/components/Input/index.js +54 -0
- package/dist/ui/components/Loader/index.d.ts +4 -0
- package/dist/ui/components/Loader/index.js +69 -0
- package/dist/ui/components/LoginButton/index.d.ts +12 -0
- package/dist/ui/components/LoginButton/index.js +32 -0
- package/dist/ui/components/LoginButton/text.d.ts +3 -0
- package/dist/ui/components/LoginButton/text.js +9 -0
- package/dist/ui/components/Modal/Close.d.ts +5 -0
- package/dist/ui/components/Modal/Close.js +37 -0
- package/dist/ui/components/Modal/index.d.ts +21 -0
- package/dist/ui/components/Modal/index.js +93 -0
- package/dist/ui/components/RowOrColumn/index.d.ts +6 -0
- package/dist/ui/components/RowOrColumn/index.js +40 -0
- package/dist/ui/components/Table/index.d.ts +9 -0
- package/dist/ui/components/Table/index.js +31 -0
- package/dist/ui/components/TextEdit/CheckboxEdit.d.ts +5 -0
- package/dist/ui/components/TextEdit/CheckboxEdit.js +59 -0
- package/dist/ui/components/TextEdit/ColourEdit.d.ts +5 -0
- package/dist/ui/components/TextEdit/ColourEdit.js +48 -0
- package/dist/ui/components/TextEdit/ListboxEdit.d.ts +6 -0
- package/dist/ui/components/TextEdit/ListboxEdit.js +41 -0
- package/dist/ui/components/TextEdit/TextEdit.d.ts +13 -0
- package/dist/ui/components/TextEdit/TextEdit.js +95 -0
- package/dist/ui/components/TextEdit/common.d.ts +5 -0
- package/dist/ui/components/TextEdit/common.js +70 -0
- package/dist/ui/components/TextEdit/images.d.ts +4 -0
- package/dist/ui/components/TextEdit/images.js +21 -0
- package/dist/ui/components/TextEdit/index.d.ts +4 -0
- package/dist/ui/components/TextEdit/index.js +16 -0
- package/dist/ui/components/TextInput/index.d.ts +12 -0
- package/dist/ui/components/TextInput/index.js +30 -0
- package/dist/ui/components/Toast/index.d.ts +11 -0
- package/dist/ui/components/Toast/index.js +42 -0
- package/dist/ui/components/UserImage/index.d.ts +8 -0
- package/dist/ui/components/UserImage/index.js +66 -0
- package/dist/ui/components/index.d.ts +16 -0
- package/dist/ui/components/index.js +28 -0
- package/dist/ui/helpers/browserHelpers.d.ts +1 -0
- package/dist/ui/helpers/browserHelpers.js +23 -0
- package/dist/ui/helpers/callOpenApi.d.ts +13 -0
- package/dist/ui/helpers/callOpenApi.js +85 -0
- package/dist/ui/helpers/cookie.d.ts +14 -0
- package/dist/ui/helpers/cookie.js +110 -0
- package/dist/ui/helpers/debounce.d.ts +6 -0
- package/dist/ui/helpers/debounce.js +33 -0
- package/dist/ui/helpers/dom.d.ts +1 -0
- package/dist/ui/helpers/dom.js +10 -0
- package/dist/ui/helpers/extractAttributes.d.ts +3 -0
- package/dist/ui/helpers/extractAttributes.js +17 -0
- package/dist/ui/helpers/index.d.ts +17 -0
- package/dist/ui/helpers/index.js +29 -0
- package/dist/ui/helpers/lang.d.ts +5 -0
- package/dist/ui/helpers/lang.js +23 -0
- package/dist/ui/helpers/mutex.d.ts +22 -0
- package/dist/ui/helpers/mutex.js +53 -0
- package/dist/ui/helpers/mutexData.d.ts +12 -0
- package/dist/ui/helpers/mutexData.js +46 -0
- package/dist/ui/helpers/plural.d.ts +1 -0
- package/dist/ui/helpers/plural.js +13 -0
- package/dist/ui/helpers/routes.d.ts +34 -0
- package/dist/ui/helpers/routes.js +2 -0
- package/dist/ui/helpers/useLocalStorage.d.ts +5 -0
- package/dist/ui/helpers/useLocalStorage.js +80 -0
- package/dist/ui/helpers/useLockBodyScroll.d.ts +1 -0
- package/dist/ui/helpers/useLockBodyScroll.js +19 -0
- package/dist/ui/helpers/useOnClickOutside.d.ts +7 -0
- package/dist/ui/helpers/useOnClickOutside.js +28 -0
- package/dist/ui/helpers/useOnScroll.d.ts +6 -0
- package/dist/ui/helpers/useOnScroll.js +33 -0
- package/dist/ui/helpers/useOpenApiStore.d.ts +14 -0
- package/dist/ui/helpers/useOpenApiStore.js +145 -0
- package/dist/ui/helpers/useQueryString.d.ts +8 -0
- package/dist/ui/helpers/useQueryString.js +38 -0
- package/dist/ui/helpers/useResize.d.ts +8 -0
- package/dist/ui/helpers/useResize.js +33 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.js +15 -0
- package/dist/ui/styles/colours.d.ts +25 -0
- package/dist/ui/styles/colours.js +51 -0
- package/dist/ui/styles/common.d.ts +13 -0
- package/dist/ui/styles/common.js +94 -0
- package/dist/ui/styles/index.d.ts +4 -0
- package/dist/ui/styles/index.js +16 -0
- package/dist/ui/styles/media.d.ts +5 -0
- package/dist/ui/styles/media.js +8 -0
- package/dist/ui/styles/standaloneStyles.d.ts +6 -0
- package/dist/ui/styles/standaloneStyles.js +69 -0
- package/package.json +40 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { AxiosWrapper, User } from 'analytica.click';
|
|
3
|
+
import { CacheItems } from './routes';
|
|
4
|
+
export declare const useOpenApiStore: <T, TDefaultApi>({ func, cacheKey, ttlSeconds, logout, refreshToken, disabled, apiUrl, newDefaultApi, }: {
|
|
5
|
+
ttlSeconds?: number | undefined;
|
|
6
|
+
func: (f: TDefaultApi) => Promise<AxiosResponse<T, any>>;
|
|
7
|
+
cacheKey: string;
|
|
8
|
+
logout: () => void;
|
|
9
|
+
refreshToken: () => Promise<User | undefined>;
|
|
10
|
+
disabled?: boolean | undefined;
|
|
11
|
+
apiUrl: string;
|
|
12
|
+
newDefaultApi: (config: any) => TDefaultApi;
|
|
13
|
+
}) => AxiosWrapper<T>;
|
|
14
|
+
export declare const setOpenApiCache: (items: CacheItems) => void;
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.setOpenApiCache = exports.useOpenApiStore = void 0;
|
|
13
|
+
const react_1 = require("react");
|
|
14
|
+
const mutex_1 = require("./mutex");
|
|
15
|
+
const mutexData_1 = require("./mutexData");
|
|
16
|
+
const callOpenApi_1 = require("./callOpenApi");
|
|
17
|
+
const log_1 = require("../../common/helpers/log");
|
|
18
|
+
const mutex = new mutex_1.Mutex({
|
|
19
|
+
autoUnlockTimeoutMs: 10000,
|
|
20
|
+
intervalMs: 100,
|
|
21
|
+
Promise: Promise,
|
|
22
|
+
});
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
const mutexData = new mutexData_1.MutexData();
|
|
25
|
+
const setMutexData = ({ key, data, ttlSeconds = 3600, }) => {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
const wrap = {
|
|
28
|
+
data,
|
|
29
|
+
loading: false,
|
|
30
|
+
reFetch: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
(0, log_1.info)('mocked');
|
|
32
|
+
}),
|
|
33
|
+
datetime: new Date().getTime(),
|
|
34
|
+
error: undefined,
|
|
35
|
+
url: '',
|
|
36
|
+
};
|
|
37
|
+
mutexData.setData(key, wrap, ttlSeconds);
|
|
38
|
+
};
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
const getMutexData = (key) => mutexData.getData(key);
|
|
41
|
+
function mLock(key, func, ttlSeconds, logout, refreshToken, apiUrl, newDefaultApi) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
let unlock;
|
|
44
|
+
try {
|
|
45
|
+
unlock = yield mutex.capture(key);
|
|
46
|
+
if (mutexData.getData(key)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const newData = yield (0, callOpenApi_1.callOpenApi)({
|
|
50
|
+
apiUrl,
|
|
51
|
+
func,
|
|
52
|
+
logout,
|
|
53
|
+
refreshToken,
|
|
54
|
+
newDefaultApi,
|
|
55
|
+
});
|
|
56
|
+
if (!newData) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (newData.error) {
|
|
60
|
+
(0, log_1.error)('api error:', newData.error);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
mutexData.setData(key, newData, ttlSeconds);
|
|
64
|
+
}
|
|
65
|
+
mutexData.pingSubscribers(key);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
(0, log_1.error)('mutex error:', e);
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
if (unlock) {
|
|
74
|
+
unlock();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const getTs = () => new Date().getTime();
|
|
80
|
+
const useOpenApiStore = ({ func, cacheKey, ttlSeconds = 3600, logout, refreshToken, disabled = false, apiUrl, newDefaultApi, }) => {
|
|
81
|
+
if (!cacheKey) {
|
|
82
|
+
throw new Error('no cache key');
|
|
83
|
+
}
|
|
84
|
+
const [key, setKey] = (0, react_1.useState)(cacheKey);
|
|
85
|
+
(0, react_1.useEffect)(() => {
|
|
86
|
+
setKey(cacheKey);
|
|
87
|
+
}, [cacheKey]);
|
|
88
|
+
const [, setTs] = (0, react_1.useState)(0);
|
|
89
|
+
(0, react_1.useEffect)(() => {
|
|
90
|
+
const myHash = getTs().toString();
|
|
91
|
+
mutexData.subscribe(key, myHash, setTs);
|
|
92
|
+
return () => mutexData.unsubscribe(key, myHash);
|
|
93
|
+
}, [key]);
|
|
94
|
+
(0, react_1.useEffect)(() => {
|
|
95
|
+
if (!disabled && !mutexData.getData(key)) {
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
97
|
+
mLock(key, func, ttlSeconds, logout, refreshToken, apiUrl, newDefaultApi);
|
|
98
|
+
}
|
|
99
|
+
}, [
|
|
100
|
+
disabled,
|
|
101
|
+
func,
|
|
102
|
+
key,
|
|
103
|
+
ttlSeconds,
|
|
104
|
+
logout,
|
|
105
|
+
refreshToken,
|
|
106
|
+
apiUrl,
|
|
107
|
+
newDefaultApi,
|
|
108
|
+
]);
|
|
109
|
+
if (!mutexData.getData(key)) {
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
+
return { loading: true };
|
|
112
|
+
}
|
|
113
|
+
if (disabled) {
|
|
114
|
+
return {
|
|
115
|
+
loading: false,
|
|
116
|
+
error: undefined,
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
data: undefined,
|
|
119
|
+
datetime: new Date().getTime(),
|
|
120
|
+
reFetch: () => __awaiter(void 0, void 0, void 0, function* () { }),
|
|
121
|
+
url: '',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const current = mutexData.getData(key);
|
|
125
|
+
return Object.assign(Object.assign({}, current), { reFetch: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
+
mutexData.setData(key, Object.assign(Object.assign({}, current), { loading: true }), ttlSeconds);
|
|
127
|
+
mutexData.pingSubscribers(key);
|
|
128
|
+
const newData = yield (0, callOpenApi_1.callOpenApi)({
|
|
129
|
+
apiUrl,
|
|
130
|
+
func,
|
|
131
|
+
logout,
|
|
132
|
+
refreshToken,
|
|
133
|
+
newDefaultApi,
|
|
134
|
+
});
|
|
135
|
+
mutexData.setData(key, newData, ttlSeconds);
|
|
136
|
+
mutexData.pingSubscribers(key);
|
|
137
|
+
}) });
|
|
138
|
+
};
|
|
139
|
+
exports.useOpenApiStore = useOpenApiStore;
|
|
140
|
+
const setOpenApiCache = (items) => {
|
|
141
|
+
items.forEach(({ cacheKey, prefillData, ttlSeconds }) => {
|
|
142
|
+
mutexData.setData(cacheKey, prefillData, ttlSeconds);
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
exports.setOpenApiCache = setOpenApiCache;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const isServer: boolean;
|
|
2
|
+
export declare const useQueryString: <T>({ name, searchOverride, defaultValue, stringify, parse, }: {
|
|
3
|
+
name: string;
|
|
4
|
+
searchOverride?: string | undefined;
|
|
5
|
+
defaultValue: T;
|
|
6
|
+
stringify: (v: T) => string | undefined;
|
|
7
|
+
parse: (v: string | undefined) => T | undefined;
|
|
8
|
+
}) => [T, (v: T) => void];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useQueryString = exports.isServer = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.isServer = typeof window === 'undefined';
|
|
6
|
+
const useQueryString = ({ name, searchOverride, defaultValue, stringify, parse, }) => {
|
|
7
|
+
const raw = exports.isServer ? searchOverride : window.location.search;
|
|
8
|
+
const [state, setStateRaw] = (0, react_1.useState)(() => {
|
|
9
|
+
if (!raw) {
|
|
10
|
+
return defaultValue;
|
|
11
|
+
}
|
|
12
|
+
const parsed = new URLSearchParams(raw);
|
|
13
|
+
const g = parsed.get(name);
|
|
14
|
+
if (!g) {
|
|
15
|
+
return defaultValue;
|
|
16
|
+
}
|
|
17
|
+
return parse(g) || defaultValue;
|
|
18
|
+
});
|
|
19
|
+
const setState = (v) => {
|
|
20
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
21
|
+
const sv = stringify(v);
|
|
22
|
+
if (sv) {
|
|
23
|
+
searchParams.set(name, sv);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
searchParams.delete(name);
|
|
27
|
+
}
|
|
28
|
+
let qs = '';
|
|
29
|
+
if (Array.from(searchParams).length !== 0) {
|
|
30
|
+
qs = '?' + searchParams.toString();
|
|
31
|
+
}
|
|
32
|
+
const loc = `${location.pathname}${qs}${window.location.hash}`;
|
|
33
|
+
window.history.replaceState({}, '', loc);
|
|
34
|
+
setStateRaw(v);
|
|
35
|
+
};
|
|
36
|
+
return [state, setState];
|
|
37
|
+
};
|
|
38
|
+
exports.useQueryString = useQueryString;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
function getWindowDimensions() {
|
|
5
|
+
if (typeof window !== 'undefined') {
|
|
6
|
+
return {
|
|
7
|
+
width: window.innerWidth,
|
|
8
|
+
height: window.innerHeight,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function UseWindowDimensions() {
|
|
16
|
+
const [windowDimensions, setWindowDimensions] = (0, react_1.useState)(getWindowDimensions());
|
|
17
|
+
(0, react_1.useEffect)(() => {
|
|
18
|
+
function handleResize() {
|
|
19
|
+
const wd = getWindowDimensions();
|
|
20
|
+
if (JSON.stringify(windowDimensions) === JSON.stringify(wd)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
setWindowDimensions(wd);
|
|
24
|
+
}
|
|
25
|
+
window.addEventListener('resize', handleResize);
|
|
26
|
+
handleResize();
|
|
27
|
+
return () => {
|
|
28
|
+
window.removeEventListener('resize', handleResize);
|
|
29
|
+
};
|
|
30
|
+
}, [windowDimensions]);
|
|
31
|
+
return windowDimensions;
|
|
32
|
+
}
|
|
33
|
+
exports.default = UseWindowDimensions;
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./helpers"), exports);
|
|
14
|
+
__exportStar(require("./styles"), exports);
|
|
15
|
+
__exportStar(require("./components"), exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const colours: {
|
|
2
|
+
mainLight: string;
|
|
3
|
+
lightest: string;
|
|
4
|
+
darker: string;
|
|
5
|
+
lighter: string;
|
|
6
|
+
dark: string;
|
|
7
|
+
charcoal: string;
|
|
8
|
+
lightCharcoal: string;
|
|
9
|
+
orangeRed: string;
|
|
10
|
+
orange: string;
|
|
11
|
+
yellow: string;
|
|
12
|
+
lightBlue: string;
|
|
13
|
+
lightGreen: string;
|
|
14
|
+
lightGreen2: string;
|
|
15
|
+
darkGreen: string;
|
|
16
|
+
peach: string;
|
|
17
|
+
purple: string;
|
|
18
|
+
notificationBlue: string;
|
|
19
|
+
notificationBlue2: string;
|
|
20
|
+
notificationBlue3: string;
|
|
21
|
+
gradient: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const colourWheel: string[];
|
|
24
|
+
export declare const getColourWheel: (i: number) => string;
|
|
25
|
+
export declare const rgbVariation: (rgb: string, diff: number) => string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rgbVariation = exports.getColourWheel = exports.colourWheel = exports.colours = void 0;
|
|
4
|
+
const math_1 = require("../../common/helpers/math");
|
|
5
|
+
exports.colours = {
|
|
6
|
+
mainLight: 'rgb(255,255,255)',
|
|
7
|
+
lightest: 'rgb(247,247,247)',
|
|
8
|
+
darker: 'rgb(0,0,0,0.1)',
|
|
9
|
+
lighter: 'rgb(234,234,234)',
|
|
10
|
+
dark: 'rgb(23,25,23)',
|
|
11
|
+
charcoal: 'rgb(50,50,50)',
|
|
12
|
+
lightCharcoal: 'rgb(154,154,154)',
|
|
13
|
+
orangeRed: '#d65873',
|
|
14
|
+
orange: '#e88070',
|
|
15
|
+
yellow: 'rgb(255,206,109)',
|
|
16
|
+
lightBlue: 'rgb(90,129,255)',
|
|
17
|
+
lightGreen: 'rgb(75,236,120)',
|
|
18
|
+
lightGreen2: 'rgb(14, 165, 0)',
|
|
19
|
+
darkGreen: '#228B22',
|
|
20
|
+
peach: 'rgb(245,169,169)',
|
|
21
|
+
purple: 'rgb(173,121,255)',
|
|
22
|
+
notificationBlue: '#4d76ff',
|
|
23
|
+
notificationBlue2: '#002ab3',
|
|
24
|
+
notificationBlue3: 'rgb(230,238,246)',
|
|
25
|
+
gradient: '---generated---',
|
|
26
|
+
};
|
|
27
|
+
const gradgen = (left, right) => `linear-gradient(to right, ${left}, ${right})`;
|
|
28
|
+
exports.colours.gradient = gradgen(exports.colours.orangeRed, exports.colours.orange);
|
|
29
|
+
exports.colourWheel = [
|
|
30
|
+
'rgb(11,132,165)',
|
|
31
|
+
'rgb(246,200,95)',
|
|
32
|
+
'rgb(111,78,124)',
|
|
33
|
+
'rgb(157,216,102)',
|
|
34
|
+
'rgb(202,71,47)',
|
|
35
|
+
'rgb(255,160,86)',
|
|
36
|
+
'rgb(141,221,208)',
|
|
37
|
+
];
|
|
38
|
+
const getColourWheel = (i) => exports.colourWheel[i % exports.colourWheel.length];
|
|
39
|
+
exports.getColourWheel = getColourWheel;
|
|
40
|
+
const rgbVariation = (rgb, diff) => {
|
|
41
|
+
const nums = rgb.match(/[0-9]+/gi);
|
|
42
|
+
if (!nums || (nums.length !== 3 && nums.length !== 4)) {
|
|
43
|
+
return rgb;
|
|
44
|
+
}
|
|
45
|
+
const nums2 = nums.map((n) => (0, math_1.clamp)({ value: Number(n) + diff, min: 0, max: 255 }));
|
|
46
|
+
if (nums2.length === 3) {
|
|
47
|
+
return `rgb(${nums2.join(',')})`;
|
|
48
|
+
}
|
|
49
|
+
return `rgba(${nums2.join(',')})`;
|
|
50
|
+
};
|
|
51
|
+
exports.rgbVariation = rgbVariation;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const DropShadow: (outline: string) => import("styled-components").FlattenSimpleInterpolation;
|
|
3
|
+
export declare const NoTextSelect: import("styled-components").FlattenSimpleInterpolation;
|
|
4
|
+
export declare const CssTransparentBlock: import("styled-components").FlattenSimpleInterpolation;
|
|
5
|
+
export declare const FadeBottom: ({ height }: {
|
|
6
|
+
height: string;
|
|
7
|
+
}) => import("styled-components").FlattenSimpleInterpolation;
|
|
8
|
+
export declare const Card: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const noDrag: {
|
|
10
|
+
draggable: boolean;
|
|
11
|
+
onDragStart: React.DragEventHandler<HTMLDivElement>;
|
|
12
|
+
onTouchStart: React.TouchEventHandler<HTMLDivElement>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.noDrag = exports.Card = exports.FadeBottom = exports.CssTransparentBlock = exports.NoTextSelect = exports.DropShadow = void 0;
|
|
23
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
24
|
+
const colours_1 = require("./colours");
|
|
25
|
+
const DropShadow = (outline) => (0, styled_components_1.css) `
|
|
26
|
+
filter: drop-shadow(1px 1px 0px ${outline})
|
|
27
|
+
drop-shadow(-1px 1px 0px ${outline}) drop-shadow(1px -1px 0px ${outline})
|
|
28
|
+
drop-shadow(-1px -1px 0px ${outline});
|
|
29
|
+
`;
|
|
30
|
+
exports.DropShadow = DropShadow;
|
|
31
|
+
exports.NoTextSelect = (0, styled_components_1.css) `
|
|
32
|
+
user-select: none; /* supported by Chrome and Opera */
|
|
33
|
+
-webkit-user-select: none; /* Safari */
|
|
34
|
+
-khtml-user-select: none; /* Konqueror HTML */
|
|
35
|
+
-moz-user-select: none; /* Firefox */
|
|
36
|
+
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
37
|
+
`;
|
|
38
|
+
exports.CssTransparentBlock = (0, styled_components_1.css) `
|
|
39
|
+
background-color: rgba(150, 150, 150, 0.5);
|
|
40
|
+
border-radius: 3px;
|
|
41
|
+
font-weight: 600;
|
|
42
|
+
color: ${colours_1.colours.mainLight};
|
|
43
|
+
`;
|
|
44
|
+
const FadeBottom = ({ height }) => (0, styled_components_1.css) `
|
|
45
|
+
&:after {
|
|
46
|
+
content: '';
|
|
47
|
+
position: absolute;
|
|
48
|
+
bottom: 0;
|
|
49
|
+
width: 100%;
|
|
50
|
+
height: ${height};
|
|
51
|
+
background: -webkit-linear-gradient(
|
|
52
|
+
rgba(255, 255, 255, 0) 0%,
|
|
53
|
+
rgba(255, 255, 255, 1) 100%
|
|
54
|
+
);
|
|
55
|
+
background-image: -moz-linear-gradient(
|
|
56
|
+
rgba(255, 255, 255, 0) 0%,
|
|
57
|
+
rgba(255, 255, 255, 1) 100%
|
|
58
|
+
);
|
|
59
|
+
background-image: -o-linear-gradient(
|
|
60
|
+
rgba(255, 255, 255, 0) 0%,
|
|
61
|
+
rgba(255, 255, 255, 1) 100%
|
|
62
|
+
);
|
|
63
|
+
background-image: linear-gradient(
|
|
64
|
+
rgba(255, 255, 255, 0) 0%,
|
|
65
|
+
rgba(255, 255, 255, 1) 100%
|
|
66
|
+
);
|
|
67
|
+
background-image: -ms-linear-gradient(
|
|
68
|
+
rgba(255, 255, 255, 0) 0%,
|
|
69
|
+
rgba(255, 255, 255, 1) 100%
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
exports.FadeBottom = FadeBottom;
|
|
74
|
+
exports.Card = styled_components_1.default.div `
|
|
75
|
+
background-color: white;
|
|
76
|
+
margin: 0.5rem;
|
|
77
|
+
|
|
78
|
+
position: relative;
|
|
79
|
+
border-radius: 0.5rem;
|
|
80
|
+
max-width: 40rem;
|
|
81
|
+
padding: 1rem;
|
|
82
|
+
border: solid 2px ${colours_1.colours.lighter};
|
|
83
|
+
`;
|
|
84
|
+
exports.noDrag = {
|
|
85
|
+
draggable: false,
|
|
86
|
+
onDragStart: (e) => {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
},
|
|
90
|
+
onTouchStart: (e) => {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./colours"), exports);
|
|
14
|
+
__exportStar(require("./common"), exports);
|
|
15
|
+
__exportStar(require("./media"), exports);
|
|
16
|
+
__exportStar(require("./standaloneStyles"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vBigScreen = exports.bigScreen = exports.smallScreen = exports.bigScreenPx = exports.smallScreenPx = void 0;
|
|
4
|
+
exports.smallScreenPx = 1024;
|
|
5
|
+
exports.bigScreenPx = 2000;
|
|
6
|
+
exports.smallScreen = `(max-width: ${exports.smallScreenPx}px)`;
|
|
7
|
+
exports.bigScreen = `(min-width: ${exports.smallScreenPx}px)`;
|
|
8
|
+
exports.vBigScreen = `(min-width: ${exports.bigScreenPx}px)`;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const SOBase: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const SOBR: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const SOB: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export declare const SOP: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const SOCenter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const SOA: import("styled-components").StyledComponent<"a", any, {}, never>;
|
|
@@ -0,0 +1,69 @@
|
|
|
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.SOA = exports.SOCenter = exports.SOP = exports.SOB = exports.SOBR = exports.SOBase = void 0;
|
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
+
const media_1 = require("./media");
|
|
9
|
+
const FullScreenPage = styled_components_1.default.div `
|
|
10
|
+
display: flex;
|
|
11
|
+
width: 100%;
|
|
12
|
+
flex-grow: 1;
|
|
13
|
+
flex-flow: column;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
align-content: flex-start;
|
|
16
|
+
align-items: flex-start;
|
|
17
|
+
`;
|
|
18
|
+
exports.SOBase = (0, styled_components_1.default)(FullScreenPage) `
|
|
19
|
+
> h1,
|
|
20
|
+
h2,
|
|
21
|
+
> p {
|
|
22
|
+
white-space: pre-wrap;
|
|
23
|
+
font-size: 1.2rem;
|
|
24
|
+
}
|
|
25
|
+
h1,
|
|
26
|
+
h2 {
|
|
27
|
+
font-weight: normal;
|
|
28
|
+
font-size: 2rem;
|
|
29
|
+
flex-basis: 100%;
|
|
30
|
+
margin: 0;
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
exports.SOBR = styled_components_1.default.div `
|
|
34
|
+
height: 0.5rem;
|
|
35
|
+
width: 0.5rem;
|
|
36
|
+
`;
|
|
37
|
+
exports.SOB = styled_components_1.default.div `
|
|
38
|
+
font-size: 1.4em;
|
|
39
|
+
font-weight: bold;
|
|
40
|
+
`;
|
|
41
|
+
exports.SOP = styled_components_1.default.div `
|
|
42
|
+
margin-bottom: 1rem;
|
|
43
|
+
`;
|
|
44
|
+
exports.SOCenter = styled_components_1.default.div `
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-flow: column;
|
|
47
|
+
margin-left: auto;
|
|
48
|
+
margin-right: auto;
|
|
49
|
+
@media ${media_1.smallScreen} {
|
|
50
|
+
width: calc(100% - 2rem);
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
exports.SOA = styled_components_1.default.a `
|
|
54
|
+
width: fit-content;
|
|
55
|
+
color: rgb(125, 171, 255);
|
|
56
|
+
text-decoration: none;
|
|
57
|
+
&:hover {
|
|
58
|
+
text-decoration: underline;
|
|
59
|
+
}
|
|
60
|
+
&[data-inline='true'] {
|
|
61
|
+
display: inline-block;
|
|
62
|
+
margin-left: 5px;
|
|
63
|
+
margin-right: 5px;
|
|
64
|
+
}
|
|
65
|
+
&[data-inline='false'] {
|
|
66
|
+
display: flex;
|
|
67
|
+
margin: auto;
|
|
68
|
+
}
|
|
69
|
+
`;
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ag-common",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"axios": "0.24.0",
|
|
8
|
+
"typescript": "4.5.4"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/node": "^17.0.5",
|
|
12
|
+
"@types/aws-lambda": "8.10.89",
|
|
13
|
+
"@types/react": "*",
|
|
14
|
+
"@types/react-dom": "*",
|
|
15
|
+
"@types/styled-components": "*",
|
|
16
|
+
"analytica.click": "*",
|
|
17
|
+
"aws-cdk-lib": "*",
|
|
18
|
+
"aws-sdk": "2.1048.0",
|
|
19
|
+
"constructs": "*",
|
|
20
|
+
"eslint": "*",
|
|
21
|
+
"react": "*",
|
|
22
|
+
"react-dom": "*",
|
|
23
|
+
"react-hot-toast": "2.1.1",
|
|
24
|
+
"rimraf": "*",
|
|
25
|
+
"typescript-styled-plugin": "*"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"aws-lambda": "1.0.7",
|
|
29
|
+
"styled-components": "*"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "rimraf dist && tsc",
|
|
33
|
+
"fix": "./node_modules/.bin/eslint --fix './src/**/*.ts' './src/**/*.tsx'",
|
|
34
|
+
"checklint": "npx eslint --ext .ts,.tsx ./src",
|
|
35
|
+
"start": "tsc --watch"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist/**/*"
|
|
39
|
+
]
|
|
40
|
+
}
|