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,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objectToArray = exports.getObjectKeysAsNumber = exports.objectKeysToLowerCase = exports.isJson = exports.tryJsonParse = void 0;
|
|
4
|
+
const tryJsonParse = (str, defaultValue) => {
|
|
5
|
+
if (!str) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(str);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
return defaultValue;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
exports.tryJsonParse = tryJsonParse;
|
|
16
|
+
function isJson(str) {
|
|
17
|
+
try {
|
|
18
|
+
JSON.parse(typeof str === 'string' ? str : JSON.stringify(str));
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
exports.isJson = isJson;
|
|
26
|
+
const objectKeysToLowerCase = (origObj) => {
|
|
27
|
+
if (!origObj || Object.keys(origObj).length === 0) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
return Object.keys(origObj).reduce((newObj, key) => {
|
|
31
|
+
const val = origObj[key];
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
const newVal = typeof val === 'object'
|
|
34
|
+
? (0, exports.objectKeysToLowerCase)(val)
|
|
35
|
+
: val;
|
|
36
|
+
// eslint-disable-next-line no-param-reassign
|
|
37
|
+
newObj[key.toLowerCase()] = newVal;
|
|
38
|
+
return newObj;
|
|
39
|
+
}, {});
|
|
40
|
+
};
|
|
41
|
+
exports.objectKeysToLowerCase = objectKeysToLowerCase;
|
|
42
|
+
const getObjectKeysAsNumber = (o) => Object.keys(o).map((o2) => parseInt(o2, 10));
|
|
43
|
+
exports.getObjectKeysAsNumber = getObjectKeysAsNumber;
|
|
44
|
+
function objectToArray(obj) {
|
|
45
|
+
if (!obj) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
const ret = [];
|
|
49
|
+
Object.keys(obj).forEach((ok) => {
|
|
50
|
+
ret.push({ key: ok, value: obj[ok] });
|
|
51
|
+
});
|
|
52
|
+
return ret;
|
|
53
|
+
}
|
|
54
|
+
exports.objectToArray = objectToArray;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function shuffle(array: any[], seed: number): any[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shuffle = void 0;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
function shuffle(array, seed) {
|
|
6
|
+
let currentIndex = array.length;
|
|
7
|
+
let temporaryValue;
|
|
8
|
+
let randomIndex;
|
|
9
|
+
seed = seed || 1;
|
|
10
|
+
const random = function () {
|
|
11
|
+
const x = Math.sin((seed += 1)) * 10000;
|
|
12
|
+
return x - Math.floor(x);
|
|
13
|
+
};
|
|
14
|
+
// While there remain elements to shuffle...
|
|
15
|
+
while (currentIndex !== 0) {
|
|
16
|
+
// Pick a remaining element...
|
|
17
|
+
randomIndex = Math.floor(random() * currentIndex);
|
|
18
|
+
currentIndex -= 1;
|
|
19
|
+
// And swap it with the current element.
|
|
20
|
+
temporaryValue = array[currentIndex];
|
|
21
|
+
array[currentIndex] = array[randomIndex];
|
|
22
|
+
array[randomIndex] = temporaryValue;
|
|
23
|
+
}
|
|
24
|
+
return array;
|
|
25
|
+
}
|
|
26
|
+
exports.shuffle = shuffle;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** convert total seconds to nearest unit (minutes, hours, days)
|
|
2
|
+
* @param seconds total seconds > 0
|
|
3
|
+
* @param precision optional precision of number
|
|
4
|
+
*/
|
|
5
|
+
export declare const secondsInNearest: ({ seconds, precision, }: {
|
|
6
|
+
seconds: number;
|
|
7
|
+
precision?: number | undefined;
|
|
8
|
+
}) => string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secondsInNearest = void 0;
|
|
4
|
+
const toFixed = (num, fixed) => {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const re = new RegExp(`^-?\\d+(?:.\\d{0,${fixed || -1}})?`);
|
|
7
|
+
const x = (_b = (_a = num === null || num === void 0 ? void 0 : num.toString()) === null || _a === void 0 ? void 0 : _a.match(re)) === null || _b === void 0 ? void 0 : _b[0];
|
|
8
|
+
if (!x) {
|
|
9
|
+
return num;
|
|
10
|
+
}
|
|
11
|
+
return Number.parseFloat(x);
|
|
12
|
+
};
|
|
13
|
+
/** convert total seconds to nearest unit (minutes, hours, days)
|
|
14
|
+
* @param seconds total seconds > 0
|
|
15
|
+
* @param precision optional precision of number
|
|
16
|
+
*/
|
|
17
|
+
const secondsInNearest = ({ seconds, precision = 2, }) => {
|
|
18
|
+
if (seconds <= 0) {
|
|
19
|
+
return 'Now';
|
|
20
|
+
}
|
|
21
|
+
if (seconds < 90) {
|
|
22
|
+
const v = toFixed(seconds, precision);
|
|
23
|
+
return `${v} ${v === 1 ? 'second' : 'seconds'}`;
|
|
24
|
+
}
|
|
25
|
+
const mins = seconds / 60;
|
|
26
|
+
if (mins < 120) {
|
|
27
|
+
const v = toFixed(mins, precision);
|
|
28
|
+
return `${v} ${v === 1 ? 'minute' : 'minutes'}`;
|
|
29
|
+
}
|
|
30
|
+
const hours = mins / 60;
|
|
31
|
+
if (hours < 24) {
|
|
32
|
+
const v = toFixed(hours, precision);
|
|
33
|
+
return `${v} ${v === 1 ? 'hour' : 'hours'}`;
|
|
34
|
+
}
|
|
35
|
+
const days = hours / 24;
|
|
36
|
+
const v = toFixed(days, precision);
|
|
37
|
+
return `${v} ${v === 1 ? 'day' : 'days'}`;
|
|
38
|
+
};
|
|
39
|
+
exports.secondsInNearest = secondsInNearest;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const csvJSON: (csv: string) => {}[];
|
|
2
|
+
export declare function trimSide(str: string, fromStart?: boolean, ...params: string[]): string;
|
|
3
|
+
export declare function trim(str: string, ...params: string[]): string;
|
|
4
|
+
export declare function truncate(str: string | null | undefined, n: number, ellip: string): string | undefined;
|
|
5
|
+
export interface ISite {
|
|
6
|
+
siteUrl: string;
|
|
7
|
+
niceSiteUrl: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const niceUrl: (siteUrl: string) => string | ISite;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.niceUrl = exports.truncate = exports.trim = exports.trimSide = exports.csvJSON = void 0;
|
|
4
|
+
const csvJSON = (csv) => {
|
|
5
|
+
const lines = csv.split('\n');
|
|
6
|
+
const result = [];
|
|
7
|
+
// NOTE: If your columns contain commas in their values, you'll need
|
|
8
|
+
// to deal with those before doing the next step
|
|
9
|
+
// (you might convert them to &&& or something, then covert them back later)
|
|
10
|
+
// jsfiddle showing the issue https://jsfiddle.net/
|
|
11
|
+
const headers = lines[0].split(',');
|
|
12
|
+
for (let i = 1; i < lines.length; i += 1) {
|
|
13
|
+
const obj = {};
|
|
14
|
+
const currentline = lines[i].split(',');
|
|
15
|
+
for (let j = 0; j < headers.length; j += 1) {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
obj[headers[j]] = currentline[j];
|
|
19
|
+
}
|
|
20
|
+
result.push(obj);
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
exports.csvJSON = csvJSON;
|
|
25
|
+
function trimSide(str, fromStart = true, ...params) {
|
|
26
|
+
const pstr = params.join('');
|
|
27
|
+
if (!str) {
|
|
28
|
+
return str;
|
|
29
|
+
}
|
|
30
|
+
const ret = str.replace(new RegExp(`[${pstr}]*$`, 'g'), '');
|
|
31
|
+
if (fromStart) {
|
|
32
|
+
return ret.replace(new RegExp(`^[${pstr}]*`, 'g'), '');
|
|
33
|
+
}
|
|
34
|
+
return ret;
|
|
35
|
+
}
|
|
36
|
+
exports.trimSide = trimSide;
|
|
37
|
+
function trim(str, ...params) {
|
|
38
|
+
str = trimSide(str, true, ...params);
|
|
39
|
+
str = trimSide(str, false, ...params);
|
|
40
|
+
return str;
|
|
41
|
+
}
|
|
42
|
+
exports.trim = trim;
|
|
43
|
+
function truncate(str, n, ellip) {
|
|
44
|
+
if (!str) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return str.length > n ? str.substr(0, n - 1) + ellip : str;
|
|
48
|
+
}
|
|
49
|
+
exports.truncate = truncate;
|
|
50
|
+
const niceUrl = (siteUrl) => {
|
|
51
|
+
if (!siteUrl) {
|
|
52
|
+
return siteUrl;
|
|
53
|
+
}
|
|
54
|
+
let niceSiteUrl = siteUrl
|
|
55
|
+
.substr(siteUrl.indexOf(':') + 1)
|
|
56
|
+
.replace('sc-domain:', '')
|
|
57
|
+
.replace('https://', '')
|
|
58
|
+
.replace('http://', '');
|
|
59
|
+
niceSiteUrl = trim(niceSiteUrl, '/');
|
|
60
|
+
return { siteUrl, niceSiteUrl };
|
|
61
|
+
};
|
|
62
|
+
exports.niceUrl = niceUrl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './helpers';
|
|
@@ -0,0 +1,13 @@
|
|
|
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);
|
package/dist/index.d.ts
ADDED
package/dist/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("./ui"), exports);
|
|
14
|
+
__exportStar(require("./common"), exports);
|
|
15
|
+
__exportStar(require("./api"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
2
|
+
import { TLang, TResource } from '../../../common/helpers/i18n';
|
|
3
|
+
export declare const Button: React.FC<{
|
|
4
|
+
title?: TResource;
|
|
5
|
+
invert?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
lang: TLang;
|
|
8
|
+
className?: string;
|
|
9
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
10
|
+
onKeyPress?: KeyboardEventHandler<HTMLButtonElement>;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,45 @@
|
|
|
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.Button = void 0;
|
|
7
|
+
/* eslint-disable react/destructuring-assignment */
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
|
+
const i18n_1 = require("../../../common/helpers/i18n");
|
|
11
|
+
const colours_1 = require("../../styles/colours");
|
|
12
|
+
const Base = styled_components_1.default.button `
|
|
13
|
+
border: 0;
|
|
14
|
+
|
|
15
|
+
font-weight: bold;
|
|
16
|
+
font-family: inherit;
|
|
17
|
+
font-size: 1.2rem;
|
|
18
|
+
border-radius: 0.5rem;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
height: 3rem;
|
|
21
|
+
line-height: 1rem;
|
|
22
|
+
&:hover {
|
|
23
|
+
filter: saturate(1.5);
|
|
24
|
+
}
|
|
25
|
+
padding-left: 1rem;
|
|
26
|
+
padding-right: 1rem;
|
|
27
|
+
|
|
28
|
+
background-color: ${colours_1.colours.darkGreen};
|
|
29
|
+
color: white;
|
|
30
|
+
&[data-invert='true'] {
|
|
31
|
+
color: ${colours_1.colours.darkGreen};
|
|
32
|
+
background-color: white;
|
|
33
|
+
border: solid 1px ${colours_1.colours.darkGreen};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&[data-disabled='true'] {
|
|
37
|
+
cursor: default;
|
|
38
|
+
background-color: #888;
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
const Button = (props) => {
|
|
42
|
+
var _a;
|
|
43
|
+
return (react_1.default.createElement(Base, Object.assign({ className: props.className, "data-invert": props.invert, "data-disabled": (_a = props.disabled) !== null && _a !== void 0 ? _a : false }, props, { role: "button", title: !props.title ? undefined : (0, i18n_1.t)(props.title, props.lang) }), props.children));
|
|
44
|
+
};
|
|
45
|
+
exports.Button = Button;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const Dropdown: ({ options, position, topPosition, onSelect, className, enableHoverOpen, children, }: {
|
|
3
|
+
className?: string | undefined;
|
|
4
|
+
options: (string | JSX.Element)[];
|
|
5
|
+
topPosition?: "top" | "bottom" | undefined;
|
|
6
|
+
position?: "left" | "right" | undefined;
|
|
7
|
+
onSelect: (i: number, e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
8
|
+
enableHoverOpen?: boolean | undefined;
|
|
9
|
+
children?: JSX.Element | undefined;
|
|
10
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.Dropdown = void 0;
|
|
26
|
+
const react_1 = __importStar(require("react"));
|
|
27
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
28
|
+
const Modal_1 = require("../Modal");
|
|
29
|
+
const common_1 = require("../../styles/common");
|
|
30
|
+
const Base = styled_components_1.default.div `
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
`;
|
|
33
|
+
const Dots = (react_1.default.createElement("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", fillRule: "evenodd", clipRule: "evenodd" },
|
|
34
|
+
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" })));
|
|
35
|
+
const Icon = styled_components_1.default.div `
|
|
36
|
+
display: flex;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
align-content: center;
|
|
39
|
+
align-items: center;
|
|
40
|
+
&[data-fixedsize='true'] {
|
|
41
|
+
width: 1.5rem;
|
|
42
|
+
height: 1.5rem;
|
|
43
|
+
top: -0.5rem;
|
|
44
|
+
right: -0.5rem;
|
|
45
|
+
position: absolute;
|
|
46
|
+
}
|
|
47
|
+
border: solid 1px #ccc;
|
|
48
|
+
border-radius: 50%;
|
|
49
|
+
background-color: white;
|
|
50
|
+
`;
|
|
51
|
+
const Dropdown = ({ options, position = 'left', topPosition, onSelect, className, enableHoverOpen = false, children, }) => {
|
|
52
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
53
|
+
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),
|
|
54
|
+
react_1.default.createElement(Icon, { "data-fixedsize": !children, onClick: (e) => {
|
|
55
|
+
e.stopPropagation();
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
setOpen(!open);
|
|
58
|
+
} }, children || Dots),
|
|
59
|
+
react_1.default.createElement(Modal_1.ModalDropList, { position: position, topPosition: topPosition, options: options, open: open, setOpen: setOpen, onSelect: onSelect, showCloseButton: false })));
|
|
60
|
+
};
|
|
61
|
+
exports.Dropdown = Dropdown;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function DropdownList<T>({ options, value, onChange, placeholder, className, renderF, }: {
|
|
3
|
+
options: T[];
|
|
4
|
+
value: T;
|
|
5
|
+
onChange: (v: T, index: number) => void;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
renderF: (v: T) => string;
|
|
9
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,124 @@
|
|
|
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.DropdownList = void 0;
|
|
23
|
+
const colours_1 = require("../../styles/colours");
|
|
24
|
+
const react_1 = __importStar(require("react"));
|
|
25
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
26
|
+
const SBase = styled_components_1.default.div `
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-flow: row;
|
|
29
|
+
position: relative;
|
|
30
|
+
min-width: 5rem;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: space-between;
|
|
33
|
+
cursor: default;
|
|
34
|
+
background-color: ${colours_1.colours.darker};
|
|
35
|
+
color: ${colours_1.colours.dark};
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
flex-grow: 1;
|
|
38
|
+
`;
|
|
39
|
+
const SItems = styled_components_1.default.div `
|
|
40
|
+
flex-flow: column;
|
|
41
|
+
z-index: 5;
|
|
42
|
+
top: 100%;
|
|
43
|
+
display: none;
|
|
44
|
+
position: absolute;
|
|
45
|
+
background-color: ${colours_1.colours.mainLight};
|
|
46
|
+
cursor: default;
|
|
47
|
+
width: 100%;
|
|
48
|
+
${({ open }) => open &&
|
|
49
|
+
(0, styled_components_1.css) `
|
|
50
|
+
display: flex;
|
|
51
|
+
`}
|
|
52
|
+
`;
|
|
53
|
+
const SSelectedItem = styled_components_1.default.div `
|
|
54
|
+
font-weight: 500;
|
|
55
|
+
padding: 0.5rem;
|
|
56
|
+
`;
|
|
57
|
+
const SItem = styled_components_1.default.div `
|
|
58
|
+
z-index: 1;
|
|
59
|
+
word-break: break-all;
|
|
60
|
+
font-weight: 500;
|
|
61
|
+
padding-left: 0.5rem;
|
|
62
|
+
flex-grow: 1;
|
|
63
|
+
padding: 1rem;
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
${({ selected }) => selected &&
|
|
66
|
+
(0, styled_components_1.css) `
|
|
67
|
+
opacity: 1 !important;
|
|
68
|
+
`}
|
|
69
|
+
&:hover {
|
|
70
|
+
opacity: 0.9 !important;
|
|
71
|
+
background-color: ${colours_1.colours.orange} !important;
|
|
72
|
+
}
|
|
73
|
+
${({ selected }) => selected &&
|
|
74
|
+
(0, styled_components_1.css) `
|
|
75
|
+
background-color: ${colours_1.colours.orangeRed} !important;
|
|
76
|
+
&:hover {
|
|
77
|
+
background-color: ${colours_1.colours.orangeRed} !important;
|
|
78
|
+
}
|
|
79
|
+
`}
|
|
80
|
+
&:nth-child(even) {
|
|
81
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
82
|
+
}
|
|
83
|
+
&:nth-child(odd) {
|
|
84
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
function Items({ options, state, onChange, renderF, }) {
|
|
88
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, options.map((s, i) => (react_1.default.createElement(SItem, { key: renderF(s), selected: s === state, onClick: () => {
|
|
89
|
+
if (s !== state) {
|
|
90
|
+
onChange(s, i);
|
|
91
|
+
}
|
|
92
|
+
} }, renderF(s))))));
|
|
93
|
+
}
|
|
94
|
+
const ChevronStyled = styled_components_1.default.div `
|
|
95
|
+
margin-right: 0.5rem;
|
|
96
|
+
`;
|
|
97
|
+
function DropdownList({ options, value, onChange, placeholder, className, renderF, }) {
|
|
98
|
+
const ref = (0, react_1.useRef)(null);
|
|
99
|
+
const [state, setState] = (0, react_1.useState)(value);
|
|
100
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
|
+
const click = (e) => {
|
|
103
|
+
var _a;
|
|
104
|
+
const outside = !((_a = ref.current) === null || _a === void 0 ? void 0 : _a.contains(e.target));
|
|
105
|
+
if (outside) {
|
|
106
|
+
setOpen(false);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
(0, react_1.useEffect)(() => {
|
|
110
|
+
document.addEventListener('click', click, true);
|
|
111
|
+
return () => document.removeEventListener('click', click, true);
|
|
112
|
+
}, []);
|
|
113
|
+
(0, react_1.useEffect)(() => {
|
|
114
|
+
setState(value);
|
|
115
|
+
}, [value]);
|
|
116
|
+
return (react_1.default.createElement(SBase, { className: className, ref: ref, title: placeholder, onClick: (e) => {
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
setOpen(!open);
|
|
119
|
+
} },
|
|
120
|
+
react_1.default.createElement(SSelectedItem, null, renderF(state)),
|
|
121
|
+
react_1.default.createElement(ChevronStyled, null, open ? '˄' : '˅'),
|
|
122
|
+
react_1.default.createElement(SItems, { open: open }, open && (react_1.default.createElement(Items, { renderF: renderF, state: state, options: options, onChange: onChange })))));
|
|
123
|
+
}
|
|
124
|
+
exports.DropdownList = DropdownList;
|
|
@@ -0,0 +1,31 @@
|
|
|
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.FlexColumn = void 0;
|
|
7
|
+
/* eslint-disable react/destructuring-assignment */
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
|
+
const Base = styled_components_1.default.div `
|
|
11
|
+
position: relative;
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-flow: column;
|
|
14
|
+
flex-grow: 1;
|
|
15
|
+
&[data-center='true'] {
|
|
16
|
+
justify-content: center;
|
|
17
|
+
align-items: center;
|
|
18
|
+
}
|
|
19
|
+
&[data-nogrow='true'] {
|
|
20
|
+
flex-grow: 0;
|
|
21
|
+
}
|
|
22
|
+
overflow: visible;
|
|
23
|
+
&[data-allowoverflow='false'] {
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
const FlexColumn = (props) => {
|
|
28
|
+
var _a, _b, _c;
|
|
29
|
+
return (react_1.default.createElement(Base, Object.assign({ "data-nogrow": (_a = props.noGrow) !== null && _a !== void 0 ? _a : false, "data-center": (_b = props.center) !== null && _b !== void 0 ? _b : false, "data-allowoverflow": (_c = props.allowOverflow) !== null && _c !== void 0 ? _c : false }, props), props.children));
|
|
30
|
+
};
|
|
31
|
+
exports.FlexColumn = FlexColumn;
|
|
@@ -0,0 +1,42 @@
|
|
|
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.FlexRow = void 0;
|
|
7
|
+
/* eslint-disable react/destructuring-assignment */
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
|
+
const Base = styled_components_1.default.div `
|
|
11
|
+
position: relative;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-flow: row wrap;
|
|
15
|
+
|
|
16
|
+
&[data-nowrap='true'] {
|
|
17
|
+
flex-flow: row;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&[data-nogrow='true'] {
|
|
21
|
+
flex-grow: 0;
|
|
22
|
+
}
|
|
23
|
+
&[data-nogrow='false'] {
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 100%;
|
|
26
|
+
flex-grow: 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&[data-center='true'] {
|
|
30
|
+
justify-content: center;
|
|
31
|
+
align-items: center;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&[data-enableoverflow='true'] {
|
|
35
|
+
overflow: visible;
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
const FlexRow = (props) => {
|
|
39
|
+
var _a, _b, _c, _d;
|
|
40
|
+
return (react_1.default.createElement(Base, Object.assign({ "data-nowrap": (_a = props.noWrap) !== null && _a !== void 0 ? _a : false, "data-nogrow": (_b = props.noGrow) !== null && _b !== void 0 ? _b : false, "data-center": (_c = props.center) !== null && _c !== void 0 ? _c : false, "data-enableoverflow": (_d = props.enableOverflow) !== null && _d !== void 0 ? _d : false }, props), props.children));
|
|
41
|
+
};
|
|
42
|
+
exports.FlexRow = FlexRow;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TLang, TResource } from '../../../common/helpers/i18n';
|
|
3
|
+
export declare const HeadersRaw: ({ title, image, lang, SiteShort, FullSiteUrl, siteDesc, }: {
|
|
4
|
+
title?: TResource | null | undefined;
|
|
5
|
+
image?: string | undefined;
|
|
6
|
+
lang: TLang;
|
|
7
|
+
SiteShort: string;
|
|
8
|
+
FullSiteUrl: string;
|
|
9
|
+
siteDesc: TResource;
|
|
10
|
+
}) => JSX.Element[];
|
|
@@ -0,0 +1,44 @@
|
|
|
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.HeadersRaw = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const i18n_1 = require("../../../common/helpers/i18n");
|
|
9
|
+
const HeadersRaw = ({ title, image, lang, SiteShort, FullSiteUrl, siteDesc, }) => {
|
|
10
|
+
const dt = (0, i18n_1.t)(siteDesc, lang);
|
|
11
|
+
const titleText = !title ? undefined : (0, i18n_1.t)(title, lang);
|
|
12
|
+
const fullTitle = `${title ? `${titleText} | ` : ''}${SiteShort} | ${dt}`;
|
|
13
|
+
const titleBlock = title === undefined
|
|
14
|
+
? []
|
|
15
|
+
: [
|
|
16
|
+
react_1.default.createElement("title", { key: "1" }, fullTitle),
|
|
17
|
+
react_1.default.createElement("meta", { key: "2", property: "og:title", content: titleText }),
|
|
18
|
+
react_1.default.createElement("meta", { key: "3", name: "twitter:title", content: titleText }),
|
|
19
|
+
react_1.default.createElement("meta", { key: "4", itemProp: "name", content: titleText }),
|
|
20
|
+
react_1.default.createElement("meta", { key: "5", name: "description", content: fullTitle }),
|
|
21
|
+
react_1.default.createElement("meta", { key: "6", itemProp: "description", content: fullTitle }),
|
|
22
|
+
react_1.default.createElement("meta", { key: "7", property: "og:description", content: fullTitle }),
|
|
23
|
+
react_1.default.createElement("meta", { key: "8", name: "twitter:description", content: fullTitle }),
|
|
24
|
+
];
|
|
25
|
+
const imagearr = !image
|
|
26
|
+
? []
|
|
27
|
+
: [
|
|
28
|
+
react_1.default.createElement("meta", { key: "9", property: "og:image", content: image }),
|
|
29
|
+
react_1.default.createElement("meta", { key: "10", name: "twitter:image", content: image }),
|
|
30
|
+
];
|
|
31
|
+
return [
|
|
32
|
+
react_1.default.createElement("meta", { key: "11", charSet: "utf-8" }),
|
|
33
|
+
...titleBlock,
|
|
34
|
+
react_1.default.createElement("meta", { key: "12", property: "og:site_name", content: SiteShort }),
|
|
35
|
+
react_1.default.createElement("meta", { key: "13", property: "og:url", content: FullSiteUrl }),
|
|
36
|
+
react_1.default.createElement("meta", { key: "14", itemProp: "url", content: FullSiteUrl }),
|
|
37
|
+
react_1.default.createElement("meta", { key: "15", name: "twitter:url", content: FullSiteUrl }),
|
|
38
|
+
react_1.default.createElement("meta", { key: "16", property: "og:type", content: "website" }),
|
|
39
|
+
react_1.default.createElement("meta", { key: "17", name: "twitter:card", content: "summary" }),
|
|
40
|
+
react_1.default.createElement("meta", { key: "18", name: "robots", content: "index, follow" }),
|
|
41
|
+
...imagearr,
|
|
42
|
+
];
|
|
43
|
+
};
|
|
44
|
+
exports.HeadersRaw = HeadersRaw;
|