ag-common 0.0.48 → 0.0.52
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/common/helpers/func.d.ts +1 -0
- package/dist/common/helpers/func.js +22 -0
- package/dist/common/helpers/index.d.ts +2 -0
- package/dist/common/helpers/index.js +2 -0
- package/dist/common/helpers/memo.d.ts +1 -0
- package/dist/common/helpers/memo.js +15 -0
- package/dist/ui/components/Button/index.d.ts +1 -0
- package/dist/ui/components/Button/index.js +30 -3
- package/dist/ui/components/LoginButton/index.d.ts +1 -2
- package/dist/ui/components/LoginButton/index.js +6 -15
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function retry(name: string, fn: () => Promise<string>, retriesLeft?: number, interval?: number): Promise<unknown>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.retry = void 0;
|
|
4
|
+
const log_1 = require("./log");
|
|
5
|
+
function retry(name, fn, retriesLeft = 3, interval = 1000) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
fn()
|
|
8
|
+
.then(resolve)
|
|
9
|
+
.catch((e) => {
|
|
10
|
+
setTimeout(() => {
|
|
11
|
+
if (retriesLeft === 1) {
|
|
12
|
+
(0, log_1.error)(`retry/${name} failed:${e}`);
|
|
13
|
+
reject(e);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
retry(name, fn, retriesLeft - 1, interval).then(resolve, reject);
|
|
17
|
+
}
|
|
18
|
+
}, interval);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.retry = retry;
|
|
@@ -3,12 +3,14 @@ export * from './async';
|
|
|
3
3
|
export * from './date';
|
|
4
4
|
export * from './distinctBy';
|
|
5
5
|
export * from './email';
|
|
6
|
+
export * from './func';
|
|
6
7
|
export * from './generator';
|
|
7
8
|
export * from './groupBy';
|
|
8
9
|
export * from './hashCode';
|
|
9
10
|
export * from './i18n';
|
|
10
11
|
export * from './log';
|
|
11
12
|
export * from './math';
|
|
13
|
+
export * from './memo';
|
|
12
14
|
export * from './object';
|
|
13
15
|
export * from './random';
|
|
14
16
|
export * from './secondsInNearest';
|
|
@@ -15,12 +15,14 @@ __exportStar(require("./async"), exports);
|
|
|
15
15
|
__exportStar(require("./date"), exports);
|
|
16
16
|
__exportStar(require("./distinctBy"), exports);
|
|
17
17
|
__exportStar(require("./email"), exports);
|
|
18
|
+
__exportStar(require("./func"), exports);
|
|
18
19
|
__exportStar(require("./generator"), exports);
|
|
19
20
|
__exportStar(require("./groupBy"), exports);
|
|
20
21
|
__exportStar(require("./hashCode"), exports);
|
|
21
22
|
__exportStar(require("./i18n"), exports);
|
|
22
23
|
__exportStar(require("./log"), exports);
|
|
23
24
|
__exportStar(require("./math"), exports);
|
|
25
|
+
__exportStar(require("./memo"), exports);
|
|
24
26
|
__exportStar(require("./object"), exports);
|
|
25
27
|
__exportStar(require("./random"), exports);
|
|
26
28
|
__exportStar(require("./secondsInNearest"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function memo<T>(func: (...a: any) => T, ...args: any[]): T;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.memo = void 0;
|
|
4
|
+
const hashCode_1 = require("./hashCode");
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
const memoData = {};
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
function memo(func, ...args) {
|
|
9
|
+
const hc = (0, hashCode_1.hashCode)(JSON.stringify(args));
|
|
10
|
+
if (!memoData[hc]) {
|
|
11
|
+
memoData[hc] = func(...args);
|
|
12
|
+
}
|
|
13
|
+
return memoData[hc];
|
|
14
|
+
}
|
|
15
|
+
exports.memo = memo;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
2
2
|
import { TLang, TResource } from '../../../common/helpers/i18n';
|
|
3
|
+
export declare const ButtonBase: import("styled-components").FlattenSimpleInterpolation;
|
|
3
4
|
export declare const Button: React.FC<{
|
|
4
5
|
title?: TResource;
|
|
5
6
|
invert?: boolean;
|
|
@@ -1,15 +1,39 @@
|
|
|
1
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
|
+
};
|
|
2
21
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
23
|
};
|
|
5
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Button = void 0;
|
|
25
|
+
exports.Button = exports.ButtonBase = void 0;
|
|
7
26
|
/* eslint-disable react/destructuring-assignment */
|
|
8
27
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const styled_components_1 =
|
|
28
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
10
29
|
const i18n_1 = require("../../../common/helpers/i18n");
|
|
11
30
|
const colours_1 = require("../../styles/colours");
|
|
12
|
-
|
|
31
|
+
exports.ButtonBase = (0, styled_components_1.css) `
|
|
32
|
+
text-decoration: none;
|
|
33
|
+
display: flex;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
align-items: center;
|
|
36
|
+
|
|
13
37
|
border: 0;
|
|
14
38
|
|
|
15
39
|
font-weight: bold;
|
|
@@ -38,6 +62,9 @@ const Base = styled_components_1.default.button `
|
|
|
38
62
|
background-color: #888;
|
|
39
63
|
}
|
|
40
64
|
`;
|
|
65
|
+
const Base = styled_components_1.default.button `
|
|
66
|
+
${exports.ButtonBase}
|
|
67
|
+
`;
|
|
41
68
|
const Button = (props) => {
|
|
42
69
|
var _a;
|
|
43
70
|
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));
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TLang, TResource } from '../../../common/helpers/i18n';
|
|
3
|
-
export declare const LoginButton: ({ className, text, invert, title, savePath, lang,
|
|
3
|
+
export declare const LoginButton: ({ className, text, invert, title, savePath, lang, loginPath, }: {
|
|
4
4
|
title?: TResource | undefined;
|
|
5
5
|
invert?: boolean | undefined;
|
|
6
6
|
text?: TResource | undefined;
|
|
7
7
|
className?: string | undefined;
|
|
8
8
|
savePath?: boolean | undefined;
|
|
9
9
|
lang: TLang;
|
|
10
|
-
pushPath: (p: string) => void;
|
|
11
10
|
loginPath: (state?: Record<string, unknown> | undefined) => string;
|
|
12
11
|
}) => JSX.Element;
|
|
@@ -1,32 +1,23 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
6
|
exports.LoginButton = void 0;
|
|
16
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
17
9
|
const i18n_1 = require("../../../common/helpers/i18n");
|
|
18
10
|
const Button_1 = require("../Button");
|
|
19
11
|
const text_1 = require("./text");
|
|
20
|
-
const
|
|
12
|
+
const Base = styled_components_1.default.a `
|
|
13
|
+
${Button_1.ButtonBase}
|
|
14
|
+
`;
|
|
15
|
+
const LoginButton = ({ className, text = text_1.getstarted, invert, title, savePath = true, lang, loginPath, }) => {
|
|
21
16
|
const lp = loginPath(!savePath || typeof window === 'undefined'
|
|
22
17
|
? undefined
|
|
23
18
|
: {
|
|
24
19
|
redirect: window.location.href.substring(window.location.origin.length),
|
|
25
20
|
});
|
|
26
|
-
return (react_1.default.createElement(
|
|
27
|
-
yield pushPath(lp);
|
|
28
|
-
}), onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
yield pushPath(lp);
|
|
30
|
-
}) }, text && (0, i18n_1.t)(text, lang)));
|
|
21
|
+
return (react_1.default.createElement(Base, { href: lp, lang: lang, title: !title ? undefined : (0, i18n_1.t)(title, lang), "data-invert": invert, "data-disabled": false, className: className }, text && (0, i18n_1.t)(text, lang)));
|
|
31
22
|
};
|
|
32
23
|
exports.LoginButton = LoginButton;
|