ag-common 0.0.154 → 0.0.158
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/LICENSE.md +5 -1
- package/dist/api/helpers/dynamo.d.ts +2 -2
- package/dist/api/helpers/dynamo.js +1 -1
- package/dist/api/helpers/dynamoInfra.d.ts +1 -1
- package/dist/api/helpers/openApiHelpers.d.ts +2 -2
- package/dist/api/helpers/openApiHelpers.js +1 -1
- package/dist/api/helpers/validateOpenApi.js +2 -2
- package/dist/api/helpers/validations.js +3 -3
- package/dist/api/types/index.d.ts +1 -1
- package/dist/common/helpers/i18n.d.ts +1 -1
- package/dist/common/helpers/string.d.ts +20 -1
- package/dist/common/helpers/string.js +27 -5
- package/dist/ui/components/BorderGradient/index.js +1 -1
- package/dist/ui/components/Button/index.js +1 -1
- package/dist/ui/components/Chevron/index.js +5 -5
- package/dist/ui/components/Confirm/index.js +3 -3
- package/dist/ui/components/Dropdown/index.js +2 -2
- package/dist/ui/components/DropdownList/index.js +2 -2
- package/dist/ui/components/Icon/index.js +1 -1
- package/dist/ui/components/LoginButton/index.js +1 -1
- package/dist/ui/components/LogoutButton/index.js +2 -2
- package/dist/ui/components/Modal/index.js +2 -2
- package/dist/ui/components/Prompt/index.js +3 -3
- package/dist/ui/components/RowOrColumn/index.js +1 -1
- package/dist/ui/components/SearchModal/index.d.ts +22 -0
- package/dist/ui/components/SearchModal/index.js +129 -0
- package/dist/ui/components/Sidebar/index.js +3 -3
- package/dist/ui/components/Table/index.js +1 -1
- package/dist/ui/components/TextEdit/CheckboxEdit.js +2 -2
- package/dist/ui/components/TextEdit/ColourEdit.js +1 -1
- package/dist/ui/components/TextEdit/ListboxEdit.js +1 -1
- package/dist/ui/components/TextEdit/TextEdit.d.ts +21 -6
- package/dist/ui/components/TextEdit/TextEdit.js +15 -11
- package/dist/ui/components/TextEdit/common.js +1 -1
- package/dist/ui/components/UserImage/index.js +2 -2
- package/dist/ui/components/index.d.ts +1 -0
- package/dist/ui/components/index.js +1 -0
- package/dist/ui/helpers/axiosHelper.js +1 -1
- package/dist/ui/helpers/callOpenApi/cached.js +2 -2
- package/dist/ui/helpers/callOpenApi/hook.d.ts +1 -1
- package/dist/ui/helpers/callOpenApi/hook.js +1 -1
- package/dist/ui/helpers/callOpenApi/types.d.ts +1 -1
- package/dist/ui/helpers/cookie/get.js +1 -1
- package/dist/ui/helpers/cookie/set.js +2 -2
- package/dist/ui/helpers/cookie/use.js +1 -1
- package/dist/ui/helpers/date.js +1 -1
- package/dist/ui/helpers/index.d.ts +1 -0
- package/dist/ui/helpers/index.js +1 -0
- package/dist/ui/helpers/lang.d.ts +1 -1
- package/dist/ui/helpers/routes.d.ts +1 -1
- package/dist/ui/helpers/routes.js +1 -1
- package/dist/ui/helpers/useLocalStorage.js +1 -1
- package/dist/ui/helpers/useOverloadPageSearch.d.ts +7 -0
- package/dist/ui/helpers/useOverloadPageSearch.js +20 -0
- package/dist/ui/helpers/useQueryString.js +1 -1
- package/dist/ui/helpers/useResize.js +1 -1
- package/dist/ui/styles/common.d.ts +1 -0
- package/dist/ui/styles/common.js +6 -2
- package/dist/ui/styles/standaloneStyles.js +1 -1
- package/package.json +2 -2
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
ISC License
|
|
2
|
+
---
|
|
2
3
|
|
|
3
|
-
Copyright 2021 Andrei Gec
|
|
4
|
+
ag-common - Copyright 2021 Andrei Gec
|
|
5
|
+
check out https://github.com/andreigec/ag-common or https://gec.dev for more info
|
|
6
|
+
|
|
7
|
+
---
|
|
4
8
|
|
|
5
9
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DocumentClient } from 'aws-sdk/clients/dynamodb';
|
|
2
1
|
import { IQueryDynamo, Key } from '../types';
|
|
3
|
-
|
|
2
|
+
import AWS from 'aws-sdk';
|
|
3
|
+
export declare let dynamoDb: AWS.DynamoDB.DocumentClient;
|
|
4
4
|
export declare const setDynamo: (region: string) => void;
|
|
5
5
|
export declare const putDynamo: <T>(item: T, tableName: string) => Promise<{
|
|
6
6
|
error?: string | undefined;
|
|
@@ -13,11 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.wipeTable = exports.getDynamoTtl = exports.queryDynamo = exports.getItemsDynamo = exports.getItemDynamo = exports.scan = exports.batchDelete = exports.batchWrite = exports.putDynamo = exports.setDynamo = exports.dynamoDb = void 0;
|
|
16
|
-
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
17
16
|
const log_1 = require("../../common/helpers/log");
|
|
18
17
|
const array_1 = require("../../common/helpers/array");
|
|
19
18
|
const sleep_1 = require("../../common/helpers/sleep");
|
|
20
19
|
const async_1 = require("../../common/helpers/async");
|
|
20
|
+
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
21
21
|
// eslint-disable-next-line import/no-mutable-exports
|
|
22
22
|
exports.dynamoDb = new aws_sdk_1.default.DynamoDB.DocumentClient();
|
|
23
23
|
const setDynamo = (region) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Stack, aws_dynamodb as dynamodb } from 'aws-cdk-lib';
|
|
2
1
|
import { IGeneratedDynamoData } from '../types';
|
|
2
|
+
import { Stack, aws_dynamodb as dynamodb } from 'aws-cdk-lib';
|
|
3
3
|
export declare const generateTableRef: ({ stack, baseKey, hasStream, hasGSI, }: {
|
|
4
4
|
hasStream: boolean;
|
|
5
5
|
hasGSI: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { aws_certificatemanager as certmgr, aws_route53 as route53 } from 'aws-cdk-lib';
|
|
2
|
-
import { Construct } from 'constructs';
|
|
3
1
|
import { ILambdaConfigs } from '../types';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
import { aws_certificatemanager as certmgr, aws_route53 as route53 } from 'aws-cdk-lib';
|
|
4
4
|
export declare const openApiImpl: (p: {
|
|
5
5
|
schema: unknown;
|
|
6
6
|
stack: Construct;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.openApiImpl = void 0;
|
|
4
4
|
/* eslint-disable no-new */
|
|
5
|
-
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
6
5
|
const array_1 = require("../../common/helpers/array");
|
|
7
6
|
const log_1 = require("../../common/helpers/log");
|
|
7
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
8
8
|
// eslint-disable-next-line
|
|
9
9
|
const getPaths = (schema) => Object.entries(schema.paths).map(([fullPath, verbs]) => ({
|
|
10
10
|
fullPath,
|
|
@@ -14,12 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.validateOpenApi = void 0;
|
|
16
16
|
// eslint-disable-next-line import/no-unresolved
|
|
17
|
-
const openapi_request_validator_1 = __importDefault(require("openapi-request-validator"));
|
|
18
17
|
const validations_1 = require("./validations");
|
|
18
|
+
const api_1 = require("./api");
|
|
19
19
|
const log_1 = require("../../common/helpers/log");
|
|
20
20
|
const object_1 = require("../../common/helpers/object");
|
|
21
|
-
const api_1 = require("./api");
|
|
22
21
|
const i18n_1 = require("../../common/helpers/i18n");
|
|
22
|
+
const openapi_request_validator_1 = __importDefault(require("openapi-request-validator"));
|
|
23
23
|
//
|
|
24
24
|
const getOperation = ({ path, method, resource, schema, }) => {
|
|
25
25
|
var _a;
|
|
@@ -14,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.getAndValidateToken = void 0;
|
|
16
16
|
/* eslint-disable import/no-unresolved */
|
|
17
|
-
const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
|
|
18
|
-
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
19
|
-
const log_1 = require("../../common/helpers/log");
|
|
20
17
|
const api_1 = require("./api");
|
|
18
|
+
const log_1 = require("../../common/helpers/log");
|
|
19
|
+
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
20
|
+
const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
|
|
21
21
|
let jwksClient;
|
|
22
22
|
const jwtVerify = ({ token, jwksUri, issuer, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
23
|
return new Promise((resolve, reject) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { aws_dynamodb as dynamodb, aws_iam as iam, aws_lambda as lambda } from 'aws-cdk-lib';
|
|
2
1
|
import { Key } from './aws';
|
|
2
|
+
import { aws_dynamodb as dynamodb, aws_iam as iam, aws_lambda as lambda } from 'aws-cdk-lib';
|
|
3
3
|
export interface DYNAMOKEYS {
|
|
4
4
|
type: string;
|
|
5
5
|
L1: string;
|
|
@@ -2,7 +2,7 @@ declare type TLangExceptEn = 'id' | 'vi';
|
|
|
2
2
|
export declare type TLang = TLangExceptEn | 'en';
|
|
3
3
|
export declare const AllLang: TLang[];
|
|
4
4
|
export declare type TResource = {
|
|
5
|
-
[k in TLangExceptEn]
|
|
5
|
+
[k in TLangExceptEn]?: string;
|
|
6
6
|
} & {
|
|
7
7
|
en: string;
|
|
8
8
|
};
|
|
@@ -25,7 +25,26 @@ export declare function toTitleCase(str: string): string;
|
|
|
25
25
|
* @returns
|
|
26
26
|
*/
|
|
27
27
|
export declare function replaceRemove(str: string, ...params: string[]): string;
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* returns >-1 if found
|
|
30
|
+
* @param str
|
|
31
|
+
* @param args
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare function containsInsensitiveIndex({ str, fromLast, }: {
|
|
35
|
+
/**
|
|
36
|
+
* if true, will return highest number. default false
|
|
37
|
+
*/
|
|
38
|
+
fromLast?: boolean;
|
|
39
|
+
str: string;
|
|
40
|
+
}, ...args: string[]): number;
|
|
41
|
+
/**
|
|
42
|
+
* returns true if text is found
|
|
43
|
+
* @param str
|
|
44
|
+
* @param args
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
export declare const containsInsensitive: (str: string, ...args: string[]) => boolean;
|
|
29
48
|
/**
|
|
30
49
|
* safely handles circular references
|
|
31
50
|
* @param obj
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringToObject = exports.chunkString = exports.safeStringify = exports.containsInsensitive = exports.replaceRemove = exports.toTitleCase = exports.niceUrl = exports.truncate = exports.trim = exports.trimSide = exports.csvJSON = exports.fromBase64 = exports.toBase64 = void 0;
|
|
3
|
+
exports.stringToObject = exports.chunkString = exports.safeStringify = exports.containsInsensitive = exports.containsInsensitiveIndex = exports.replaceRemove = exports.toTitleCase = exports.niceUrl = exports.truncate = exports.trim = exports.trimSide = exports.csvJSON = exports.fromBase64 = exports.toBase64 = void 0;
|
|
4
4
|
const toBase64 = (str) => Buffer.from(str).toString('base64');
|
|
5
5
|
exports.toBase64 = toBase64;
|
|
6
6
|
const fromBase64 = (str) => Buffer.from(decodeURIComponent(str), 'base64').toString();
|
|
@@ -116,13 +116,35 @@ function replaceRemove(str, ...params) {
|
|
|
116
116
|
return ret;
|
|
117
117
|
}
|
|
118
118
|
exports.replaceRemove = replaceRemove;
|
|
119
|
-
|
|
119
|
+
/**
|
|
120
|
+
* returns >-1 if found
|
|
121
|
+
* @param str
|
|
122
|
+
* @param args
|
|
123
|
+
* @returns
|
|
124
|
+
*/
|
|
125
|
+
function containsInsensitiveIndex({ str, fromLast = false, }, ...args) {
|
|
120
126
|
if (!str || !args) {
|
|
121
|
-
return
|
|
127
|
+
return -1;
|
|
128
|
+
}
|
|
129
|
+
const largs = args.map((a) => a.toLowerCase());
|
|
130
|
+
const lstr = str.toLowerCase();
|
|
131
|
+
const finds = largs
|
|
132
|
+
.map((arg) => (fromLast ? lstr.lastIndexOf(arg) : lstr.indexOf(arg)))
|
|
133
|
+
.filter((s) => s !== -1)
|
|
134
|
+
.sort();
|
|
135
|
+
if (finds.length === 0) {
|
|
136
|
+
return -1;
|
|
122
137
|
}
|
|
123
|
-
|
|
124
|
-
return !!args.find((a) => l.includes(a));
|
|
138
|
+
return !fromLast ? finds[0] : finds[finds.length - 1];
|
|
125
139
|
}
|
|
140
|
+
exports.containsInsensitiveIndex = containsInsensitiveIndex;
|
|
141
|
+
/**
|
|
142
|
+
* returns true if text is found
|
|
143
|
+
* @param str
|
|
144
|
+
* @param args
|
|
145
|
+
* @returns
|
|
146
|
+
*/
|
|
147
|
+
const containsInsensitive = (str, ...args) => containsInsensitiveIndex({ str }, ...args) !== -1;
|
|
126
148
|
exports.containsInsensitive = containsInsensitive;
|
|
127
149
|
/**
|
|
128
150
|
* safely handles circular references
|
|
@@ -23,9 +23,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.BorderGradient = void 0;
|
|
26
|
+
const colours_1 = require("../../styles/colours");
|
|
26
27
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
27
28
|
const react_1 = __importDefault(require("react"));
|
|
28
|
-
const colours_1 = require("../../styles/colours");
|
|
29
29
|
const BGcss = (0, styled_components_1.css) `
|
|
30
30
|
display: flex;
|
|
31
31
|
border: 0;
|
|
@@ -24,9 +24,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.Button = exports.ButtonBase = void 0;
|
|
26
26
|
/* eslint-disable react/destructuring-assignment */
|
|
27
|
+
const colours_1 = require("../../styles/colours");
|
|
27
28
|
const react_1 = __importDefault(require("react"));
|
|
28
29
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
29
|
-
const colours_1 = require("../../styles/colours");
|
|
30
30
|
exports.ButtonBase = (0, styled_components_1.css) `
|
|
31
31
|
text-decoration: none;
|
|
32
32
|
display: flex;
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Chevron = void 0;
|
|
7
|
+
const Icon_1 = require("../Icon");
|
|
7
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
9
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const Icon_1 = require("../Icon");
|
|
10
10
|
const SChevron = styled_components_1.default.span `
|
|
11
11
|
font-size: 2rem;
|
|
12
12
|
display: flex;
|
|
@@ -24,19 +24,19 @@ const Chevron = ({ width = '1.2rem', className, colour = 'black', onToggle, poin
|
|
|
24
24
|
let rotate = 0;
|
|
25
25
|
switch (point) {
|
|
26
26
|
case 'down': {
|
|
27
|
-
rotate =
|
|
27
|
+
rotate = 90;
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
case 'left': {
|
|
31
|
-
rotate =
|
|
31
|
+
rotate = 180;
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
34
|
case 'up': {
|
|
35
|
-
rotate =
|
|
35
|
+
rotate = 270;
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
38
|
case 'right': {
|
|
39
|
-
rotate =
|
|
39
|
+
rotate = 0;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
return (react_1.default.createElement(SChevron, { className: className, onClick: () => onToggle === null || onToggle === void 0 ? void 0 : onToggle(), onTouchStart: () => onToggle === null || onToggle === void 0 ? void 0 : onToggle(), onKeyPress: (e) => e.key === 'Enter' && (onToggle === null || onToggle === void 0 ? void 0 : onToggle()) },
|
|
@@ -15,13 +15,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.confirm = void 0;
|
|
16
16
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
17
17
|
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
18
|
-
const react_1 = __importDefault(require("react"));
|
|
19
|
-
const react_dom_1 = __importDefault(require("react-dom"));
|
|
20
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
21
18
|
const Button_1 = require("../Button");
|
|
22
19
|
const FlexColumn_1 = require("../FlexColumn");
|
|
23
20
|
const FlexRow_1 = require("../FlexRow");
|
|
24
21
|
const Modal_1 = require("../Modal");
|
|
22
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
23
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
24
|
+
const react_1 = __importDefault(require("react"));
|
|
25
25
|
const Base = styled_components_1.default.div `
|
|
26
26
|
width: 95vw;
|
|
27
27
|
max-width: 30rem;
|
|
@@ -23,10 +23,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.Dropdown = void 0;
|
|
26
|
-
const react_1 = __importStar(require("react"));
|
|
27
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
28
26
|
const Modal_1 = require("../Modal");
|
|
29
27
|
const common_1 = require("../../styles/common");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
30
30
|
const Base = styled_components_1.default.div `
|
|
31
31
|
cursor: pointer;
|
|
32
32
|
`;
|
|
@@ -21,11 +21,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.DropdownList = void 0;
|
|
23
23
|
const colours_1 = require("../../styles/colours");
|
|
24
|
-
const react_1 = __importStar(require("react"));
|
|
25
|
-
const styled_components_1 = __importStar(require("styled-components"));
|
|
26
24
|
const Icon_1 = require("../Icon");
|
|
27
25
|
const dom_1 = require("../../helpers/dom");
|
|
28
26
|
const common_1 = require("../../styles/common");
|
|
27
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
29
|
const SBase = styled_components_1.default.div `
|
|
30
30
|
display: flex;
|
|
31
31
|
flex-flow: row;
|
|
@@ -23,9 +23,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.Icon = exports.IconF = void 0;
|
|
26
|
+
const common_1 = require("../../styles/common");
|
|
26
27
|
const react_1 = __importDefault(require("react"));
|
|
27
28
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
28
|
-
const common_1 = require("../../styles/common");
|
|
29
29
|
exports.IconF = styled_components_1.default.span `
|
|
30
30
|
transition: all 200ms;
|
|
31
31
|
display: flex;
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.LoginButton = void 0;
|
|
7
|
+
const Button_1 = require("../Button");
|
|
7
8
|
const react_1 = __importDefault(require("react"));
|
|
8
9
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
-
const Button_1 = require("../Button");
|
|
10
10
|
const Base = styled_components_1.default.a `
|
|
11
11
|
${Button_1.ButtonBase}
|
|
12
12
|
`;
|
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.LogoutButton = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
7
|
const colours_1 = require("../../styles/colours");
|
|
10
8
|
const Button_1 = require("../Button");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
11
11
|
const Door = (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20" },
|
|
12
12
|
react_1.default.createElement("path", { d: "M3 3h8V1H3a2 2 0 00-2 2v14a2 2 0 002 2h8v-2H3z" }),
|
|
13
13
|
react_1.default.createElement("path", { d: "M19 10l-6-5v4H5v2h8v4l6-5z" })));
|
|
@@ -23,10 +23,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.ModalDropList = exports.Modal = exports.ModalItem = void 0;
|
|
26
|
-
const react_1 = __importStar(require("react"));
|
|
27
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
28
26
|
const Close_1 = require("../Close");
|
|
29
27
|
const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
30
30
|
const FixedBackground = styled_components_1.default.div `
|
|
31
31
|
position: fixed;
|
|
32
32
|
top: 0;
|
|
@@ -34,14 +34,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
34
34
|
exports.prompt = void 0;
|
|
35
35
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
36
36
|
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
37
|
-
const react_1 = __importStar(require("react"));
|
|
38
|
-
const react_dom_1 = __importDefault(require("react-dom"));
|
|
39
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
40
37
|
const Button_1 = require("../Button");
|
|
41
38
|
const FlexColumn_1 = require("../FlexColumn");
|
|
42
39
|
const FlexRow_1 = require("../FlexRow");
|
|
43
40
|
const Modal_1 = require("../Modal");
|
|
44
41
|
const TextEdit_1 = require("../TextEdit");
|
|
42
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
43
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
44
|
+
const react_1 = __importStar(require("react"));
|
|
45
45
|
const Base = styled_components_1.default.div `
|
|
46
46
|
width: 95vw;
|
|
47
47
|
max-width: 30rem;
|
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RowOrColumn = void 0;
|
|
7
7
|
/* eslint-disable react/destructuring-assignment */
|
|
8
|
+
const media_1 = require("../../styles/media");
|
|
8
9
|
const react_1 = __importDefault(require("react"));
|
|
9
10
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
|
-
const media_1 = require("../../styles/media");
|
|
11
11
|
const Base = styled_components_1.default.div `
|
|
12
12
|
display: flex;
|
|
13
13
|
flex-flow: row wrap;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface ISearchDialog<T> {
|
|
3
|
+
placeholderText?: string;
|
|
4
|
+
closeText?: string;
|
|
5
|
+
/**
|
|
6
|
+
* method run to render each filtered item
|
|
7
|
+
*/
|
|
8
|
+
renderItem: (searchText: string, item: T) => JSX.Element | string;
|
|
9
|
+
/**
|
|
10
|
+
* all potential items
|
|
11
|
+
*/
|
|
12
|
+
displayItems: T[];
|
|
13
|
+
/**
|
|
14
|
+
* run to filter items by search text
|
|
15
|
+
*/
|
|
16
|
+
willDisplayItem: (searchText: string, item: T) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* get unique render key
|
|
19
|
+
*/
|
|
20
|
+
getKeyF: (i: T) => string;
|
|
21
|
+
}
|
|
22
|
+
export declare const searchDialog: <T>(p: ISearchDialog<T>) => Promise<T | undefined>;
|
|
@@ -0,0 +1,129 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.searchDialog = void 0;
|
|
35
|
+
const debounce_1 = require("../../helpers/debounce");
|
|
36
|
+
const media_1 = require("../../styles/media");
|
|
37
|
+
const Modal_1 = require("../Modal");
|
|
38
|
+
const TextEdit_1 = require("../TextEdit/TextEdit");
|
|
39
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
40
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
41
|
+
const react_1 = __importStar(require("react"));
|
|
42
|
+
const ModalStyled = (0, styled_components_1.default)(Modal_1.Modal) `
|
|
43
|
+
top: 10rem;
|
|
44
|
+
@media ${media_1.bigScreen} {
|
|
45
|
+
width: 50vw;
|
|
46
|
+
max-width: 60rem;
|
|
47
|
+
}
|
|
48
|
+
@media ${media_1.smallScreen} {
|
|
49
|
+
max-width: 95vw;
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
const SearchBox = styled_components_1.default.div `
|
|
53
|
+
padding: 1rem;
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-flow: row;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
align-items: center;
|
|
58
|
+
`;
|
|
59
|
+
const MagnifyIconSvg = (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 490 490" },
|
|
60
|
+
react_1.default.createElement("path", { fill: "none", stroke: "#000", strokeWidth: "36", strokeLinecap: "round", d: "M280 278a153 153 0 1 0-2 2l170 170m-91-117 110 110-26 26-110-110" })));
|
|
61
|
+
const Icon = styled_components_1.default.div `
|
|
62
|
+
width: 1.5rem;
|
|
63
|
+
height: 1.5rem;
|
|
64
|
+
margin-right: 0.5rem;
|
|
65
|
+
`;
|
|
66
|
+
const CloseButton = styled_components_1.default.div `
|
|
67
|
+
font-weight: bold;
|
|
68
|
+
margin-left: 1rem;
|
|
69
|
+
font-size: 1.1rem;
|
|
70
|
+
color: #333;
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
&:hover {
|
|
73
|
+
text-decoration: underline;
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
const Content = styled_components_1.default.div `
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-flow: column;
|
|
79
|
+
justify-content: flex-start;
|
|
80
|
+
align-items: center;
|
|
81
|
+
max-height: calc(100vh - 20rem);
|
|
82
|
+
overflow-y: auto;
|
|
83
|
+
padding-bottom: 0.5rem;
|
|
84
|
+
`;
|
|
85
|
+
const Row = styled_components_1.default.div `
|
|
86
|
+
width: 100%;
|
|
87
|
+
height: 100%;
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-flow: column;
|
|
90
|
+
justify-content: center;
|
|
91
|
+
align-items: center;
|
|
92
|
+
`;
|
|
93
|
+
const SearchModal = ({ res, wrapper, placeholderText, closeText, renderItem, displayItems, willDisplayItem, getKeyF, }) => {
|
|
94
|
+
let originalStyle;
|
|
95
|
+
(0, react_1.useEffect)(() => {
|
|
96
|
+
if (originalStyle === undefined) {
|
|
97
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
|
+
originalStyle = window.getComputedStyle(document.body).overflow || '';
|
|
99
|
+
document.body.style.overflow = 'hidden';
|
|
100
|
+
}
|
|
101
|
+
}, []);
|
|
102
|
+
const ret = (v) => {
|
|
103
|
+
try {
|
|
104
|
+
document.body.style.overflow = originalStyle || '';
|
|
105
|
+
res(v);
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
wrapper.remove();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const [searchText, setSearchText] = (0, react_1.useState)('');
|
|
112
|
+
const filteredItems = displayItems.filter((i) => willDisplayItem(searchText, i));
|
|
113
|
+
return (react_1.default.createElement(ModalStyled, { position: "center", topPosition: "center", open: true, setOpen: () => ret(undefined), showCloseButton: false, closeOnClickOutside: true },
|
|
114
|
+
react_1.default.createElement(SearchBox, null,
|
|
115
|
+
react_1.default.createElement(TextEdit_1.TextEdit, { placeholder: placeholderText, defaultValue: "", onSubmit: (v) => (0, debounce_1.debounce)(() => {
|
|
116
|
+
setSearchText(v);
|
|
117
|
+
}, { key: 'pagesearch', time: 200 }), defaultEditing: { focus: true }, singleLine: true, leftContent: react_1.default.createElement(Icon, null, MagnifyIconSvg), noGrow: true, allowUndo: false }),
|
|
118
|
+
react_1.default.createElement(CloseButton, { onClick: () => ret(undefined) }, closeText)),
|
|
119
|
+
react_1.default.createElement(Content, null, filteredItems.map((i) => (react_1.default.createElement(Row, { key: getKeyF(i), onClick: () => ret(i) }, renderItem(searchText, i)))))));
|
|
120
|
+
};
|
|
121
|
+
const searchDialog = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
122
|
+
const placeholderText = p.placeholderText || '';
|
|
123
|
+
const closeText = p.closeText || 'CLOSE';
|
|
124
|
+
return new Promise((res) => {
|
|
125
|
+
const wrapper = document.body.appendChild(document.createElement('div'));
|
|
126
|
+
react_dom_1.default.render(react_1.default.createElement(SearchModal, Object.assign({}, p, { placeholderText: placeholderText, closeText: closeText, res: (r) => res(r), wrapper: wrapper })), wrapper);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
exports.searchDialog = searchDialog;
|
|
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Sidebar = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
7
|
const use_1 = require("../../helpers/cookie/use");
|
|
10
8
|
const common_1 = require("../../styles/common");
|
|
11
9
|
const Chevron_1 = require("../Chevron");
|
|
10
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
11
|
+
const react_1 = __importDefault(require("react"));
|
|
12
12
|
const Base = styled_components_1.default.div `
|
|
13
13
|
position: relative;
|
|
14
14
|
transition: all 200ms;
|
|
@@ -99,7 +99,7 @@ const Sidebar = ({ children, className, key = 'sidebar', cookieDocument, }) => {
|
|
|
99
99
|
});
|
|
100
100
|
return (react_1.default.createElement(Base, { className: className, "data-open": open, onClick: () => !open && setOpen(true), "data-hover": true },
|
|
101
101
|
react_1.default.createElement(Hamburger, { "data-open": open, onClick: () => setOpen(!open), "data-hover": true },
|
|
102
|
-
react_1.default.createElement(ChevronStyled, { point: open ? '
|
|
102
|
+
react_1.default.createElement(ChevronStyled, { point: open ? 'left' : 'right', width: "100%" })),
|
|
103
103
|
react_1.default.createElement(ContentBlock, { "data-content": true, "data-open": open },
|
|
104
104
|
react_1.default.createElement(Content, { "data-open": open, onClick: (e) => {
|
|
105
105
|
e.stopPropagation();
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Table = void 0;
|
|
7
|
+
const groupBy_1 = require("../../../common/helpers/groupBy");
|
|
7
8
|
const react_1 = __importDefault(require("react"));
|
|
8
9
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
-
const groupBy_1 = require("../../../common/helpers/groupBy");
|
|
10
10
|
const Base = styled_components_1.default.div `
|
|
11
11
|
display: flex;
|
|
12
12
|
flex-flow: column;
|
|
@@ -24,13 +24,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.CheckboxEdit = void 0;
|
|
26
26
|
/* eslint-disable jsx-a11y/no-onchange */
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
27
|
const images_1 = require("./images");
|
|
29
28
|
const common_1 = require("./common");
|
|
30
29
|
const common_2 = require("../../styles/common");
|
|
31
30
|
const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
|
|
32
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
31
|
const FlexRow_1 = require("../FlexRow");
|
|
32
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
|
+
const react_1 = __importStar(require("react"));
|
|
34
34
|
const Icons = (0, styled_components_1.default)(FlexRow_1.FlexRow) `
|
|
35
35
|
position: absolute;
|
|
36
36
|
top: 0;
|
|
@@ -21,11 +21,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.ColourEdit = void 0;
|
|
23
23
|
/* eslint-disable jsx-a11y/no-onchange */
|
|
24
|
-
const react_1 = __importStar(require("react"));
|
|
25
24
|
const images_1 = require("./images");
|
|
26
25
|
const common_1 = require("./common");
|
|
27
26
|
const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
|
|
28
27
|
const common_2 = require("../../styles/common");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
29
|
const ColourEdit = ({ defaultValue, onSubmit, }) => {
|
|
30
30
|
const ref = (0, react_1.useRef)(null);
|
|
31
31
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
@@ -21,10 +21,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.ListboxEdit = void 0;
|
|
23
23
|
/* eslint-disable jsx-a11y/no-onchange */
|
|
24
|
-
const react_1 = __importStar(require("react"));
|
|
25
24
|
const images_1 = require("./images");
|
|
26
25
|
const common_1 = require("./common");
|
|
27
26
|
const common_2 = require("../../styles/common");
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
28
|
const ListboxEdit = ({ defaultValue, onSubmit, values, }) => {
|
|
29
29
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
30
30
|
(0, react_1.useEffect)(() => {
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { StyledComponent } from 'styled-components';
|
|
3
3
|
export declare const ValueReadonly: StyledComponent<"div", any, {}, never>;
|
|
4
|
-
export declare const TextEdit: ({ defaultValue, defaultEditing,
|
|
4
|
+
export declare const TextEdit: ({ defaultValue, defaultEditing, disableEdit, placeholder, className, singleLine, noGrow, attributes, leftContent, onSubmit, onEditingChange, onClickOutsideWithNoValue, onClickNotEditing, allowUndo, }: {
|
|
5
5
|
/**
|
|
6
6
|
* forces single row input style. will also enable 'Enter' to auto submit
|
|
7
7
|
*/
|
|
8
8
|
singleLine?: boolean | undefined;
|
|
9
9
|
className?: string | undefined;
|
|
10
|
-
defaultValue: string;
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* default value of field. default empty
|
|
12
|
+
*/
|
|
13
|
+
defaultValue?: string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* if truthy will enable text edit mode by default. if focus is true, will also focus on open
|
|
13
16
|
*/
|
|
14
17
|
defaultEditing?: {
|
|
15
|
-
focus
|
|
18
|
+
focus?: boolean | undefined;
|
|
16
19
|
} | undefined;
|
|
20
|
+
onSubmit: (val: string, enterPressed: boolean) => void;
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
22
|
+
* disable edit text functionality
|
|
19
23
|
*/
|
|
20
|
-
onSubmit: (val: string, enterPressed: boolean) => void;
|
|
21
24
|
disableEdit?: boolean | undefined;
|
|
22
25
|
placeholder?: string | undefined;
|
|
23
26
|
onEditingChange?: ((editing: boolean) => void) | undefined;
|
|
@@ -27,4 +30,16 @@ export declare const TextEdit: ({ defaultValue, defaultEditing, onSubmit, disabl
|
|
|
27
30
|
* if true, will not grow. default false
|
|
28
31
|
*/
|
|
29
32
|
noGrow?: boolean | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* will set these attributes directly on element. can put data-* here
|
|
35
|
+
*/
|
|
36
|
+
attributes?: Record<string, string | number | boolean> | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* optional content at the left of the box
|
|
39
|
+
*/
|
|
40
|
+
leftContent?: JSX.Element | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* if true, will add undo button after changes. if false, will submit after every keypress. default true
|
|
43
|
+
*/
|
|
44
|
+
allowUndo?: boolean | undefined;
|
|
30
45
|
}) => JSX.Element;
|
|
@@ -21,12 +21,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.TextEdit = exports.ValueReadonly = void 0;
|
|
23
23
|
/* eslint-disable jsx-a11y/no-onchange */
|
|
24
|
-
const react_1 = __importStar(require("react"));
|
|
25
24
|
const images_1 = require("./images");
|
|
26
25
|
const common_1 = require("./common");
|
|
27
|
-
const styled_components_1 = __importStar(require("styled-components"));
|
|
28
26
|
const useOnClickOutside_1 = require("../../helpers/useOnClickOutside");
|
|
29
27
|
const common_2 = require("../../styles/common");
|
|
28
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
30
|
exports.ValueReadonly = styled_components_1.default.div `
|
|
31
31
|
${common_1.valueCss};
|
|
32
32
|
word-break: break-word;
|
|
@@ -69,7 +69,7 @@ const Icon = styled_components_1.default.div `
|
|
|
69
69
|
filter: saturate(3);
|
|
70
70
|
}
|
|
71
71
|
`;
|
|
72
|
-
const TextEdit = ({ defaultValue, defaultEditing,
|
|
72
|
+
const TextEdit = ({ defaultValue = '', defaultEditing, disableEdit = false, placeholder, className, singleLine = false, noGrow = false, attributes, leftContent, onSubmit, onEditingChange, onClickOutsideWithNoValue, onClickNotEditing, allowUndo = true, }) => {
|
|
73
73
|
const ref = (0, react_1.useRef)(null);
|
|
74
74
|
const taref = (0, react_1.useRef)(null);
|
|
75
75
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
@@ -107,7 +107,8 @@ const TextEdit = ({ defaultValue, defaultEditing, onSubmit, disableEdit = false,
|
|
|
107
107
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
108
108
|
}, [defaultEditing]);
|
|
109
109
|
if (!editing || disableEdit) {
|
|
110
|
-
return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag, { className: className, "data-editing": "false", onClick: () => onClickNotEditing === null || onClickNotEditing === void 0 ? void 0 : onClickNotEditing(), "data-pointer": onClickNotEditing ? 'true' : 'false', "data-nogrow": noGrow }),
|
|
110
|
+
return (react_1.default.createElement(common_1.ValueBox, Object.assign({}, common_2.noDrag, { className: className, "data-editing": "false", onClick: () => onClickNotEditing === null || onClickNotEditing === void 0 ? void 0 : onClickNotEditing(), "data-pointer": onClickNotEditing ? 'true' : 'false', "data-nogrow": noGrow }, attributes),
|
|
111
|
+
leftContent || null,
|
|
111
112
|
react_1.default.createElement(exports.ValueReadonly, { "data-type": "text" }, value),
|
|
112
113
|
react_1.default.createElement(Right, null, !disableEdit && (react_1.default.createElement(Icon, { style: common_1.iconRight, onClick: (e) => {
|
|
113
114
|
e.stopPropagation();
|
|
@@ -115,9 +116,6 @@ const TextEdit = ({ defaultValue, defaultEditing, onSubmit, disableEdit = false,
|
|
|
115
116
|
} },
|
|
116
117
|
react_1.default.createElement(images_1.PencilIcon, null))))));
|
|
117
118
|
}
|
|
118
|
-
if (!open) {
|
|
119
|
-
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
120
|
-
}
|
|
121
119
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
120
|
const Comp = singleLine
|
|
123
121
|
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -125,18 +123,24 @@ const TextEdit = ({ defaultValue, defaultEditing, onSubmit, disableEdit = false,
|
|
|
125
123
|
: ValueTextArea;
|
|
126
124
|
return (react_1.default.createElement(ValueBoxEdit, Object.assign({}, common_2.noDrag, { className: className, "data-editing": "true",
|
|
127
125
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
-
ref: ref, tabIndex: editing ? 0 : undefined, "data-nogrow": noGrow }),
|
|
129
|
-
|
|
126
|
+
ref: ref, tabIndex: editing ? 0 : undefined, "data-nogrow": noGrow }, attributes),
|
|
127
|
+
leftContent || null,
|
|
128
|
+
react_1.default.createElement(Comp, { "data-editing": "true", "data-valuechange": valueChange.toString(), ref: taref, "data-type": "text", value: value, onChange: (v) => {
|
|
129
|
+
setValue(v.currentTarget.value);
|
|
130
|
+
if (!allowUndo) {
|
|
131
|
+
onSubmit(v.currentTarget.value, false);
|
|
132
|
+
}
|
|
133
|
+
}, placeholder: placeholder, rows: singleLine ? 1 : undefined, onKeyDown: (e) => singleLine &&
|
|
130
134
|
e.code.endsWith('Enter') &&
|
|
131
135
|
onSubmit(value, true) &&
|
|
132
136
|
false }),
|
|
133
|
-
react_1.default.createElement(Right, null,
|
|
137
|
+
allowUndo && (react_1.default.createElement(Right, null,
|
|
134
138
|
valueChange && (react_1.default.createElement(Icon, { style: common_1.iconLeft, onClick: () => valueChange && onSubmit(value, false) },
|
|
135
139
|
react_1.default.createElement(images_1.SaveIcon, null))),
|
|
136
140
|
(valueChange || editing !== !!defaultEditing) && (react_1.default.createElement(Icon, { style: common_1.iconRight, onClick: () => {
|
|
137
141
|
setEditing(!!defaultEditing);
|
|
138
142
|
setValue(defaultValue);
|
|
139
143
|
} },
|
|
140
|
-
react_1.default.createElement(images_1.UndoIcon, null))))));
|
|
144
|
+
react_1.default.createElement(images_1.UndoIcon, null)))))));
|
|
141
145
|
};
|
|
142
146
|
exports.TextEdit = TextEdit;
|
|
@@ -20,8 +20,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.iconLeft = exports.iconRight = exports.IconD = exports.ValueInputCB = exports.valueCss = exports.ValueBox = void 0;
|
|
23
|
-
const styled_components_1 = __importStar(require("styled-components"));
|
|
24
23
|
const colours_1 = require("../../styles/colours");
|
|
24
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
25
25
|
exports.ValueBox = styled_components_1.default.div `
|
|
26
26
|
padding: 0.5rem;
|
|
27
27
|
|
|
@@ -23,10 +23,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.UserProfileImage = exports.UserImage = exports.UserImageIcon = void 0;
|
|
26
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
26
|
const log_1 = require("../../../common/helpers/log");
|
|
29
27
|
const array_1 = require("../../../common/helpers/array");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
30
30
|
exports.UserImageIcon = (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512" },
|
|
31
31
|
react_1.default.createElement("path", { d: "M256 48C141.1 48 48 141.1 48 256s93.1 208 208 208 208-93.1 208-208S370.9 48 256 48zm0 398.7c-58.6 0-111.1-26.6-146.1-68.3 17.8-7.7 62.2-23.7 90.3-31.9 2.2-.7 2.6-.8 2.6-10.7 0-10.6-1.2-18.1-3.8-23.6-3.5-7.5-7.7-20.2-9.2-31.6-4.2-4.9-9.9-14.5-13.6-32.9-3.2-16.2-1.7-22.1.4-27.6.2-.6.5-1.2.6-1.8.8-3.7-.3-23.5-3.1-38.8-1.9-10.5.5-32.8 15-51.3 9.1-11.7 26.6-26 58-28h17.5c31.9 2 49.4 16.3 58.5 28 14.5 18.5 16.9 40.8 14.9 51.3-2.8 15.3-3.9 35-3.1 38.8.1.6.4 1.2.6 1.7 2.1 5.5 3.7 11.4.4 27.6-3.7 18.4-9.4 28-13.6 32.9-1.5 11.4-5.7 24-9.2 31.6-3.3 6.9-6.6 15.1-6.6 23.3 0 9.9.4 10 2.7 10.7 26.7 7.9 72.7 23.8 93 32.1-35 41.8-87.5 68.5-146.2 68.5z" })));
|
|
32
32
|
const Base = styled_components_1.default.div `
|
|
@@ -27,6 +27,7 @@ __exportStar(require("./LogoutButton"), exports);
|
|
|
27
27
|
__exportStar(require("./Modal"), exports);
|
|
28
28
|
__exportStar(require("./Prompt"), exports);
|
|
29
29
|
__exportStar(require("./RowOrColumn"), exports);
|
|
30
|
+
__exportStar(require("./SearchModal"), exports);
|
|
30
31
|
__exportStar(require("./Sidebar"), exports);
|
|
31
32
|
__exportStar(require("./Table"), exports);
|
|
32
33
|
__exportStar(require("./TextEdit"), exports);
|
|
@@ -13,9 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.axiosHelper = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
16
|
const log_1 = require("../../common/helpers/log");
|
|
18
17
|
const object_1 = require("../../common/helpers/object");
|
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
|
19
19
|
/**
|
|
20
20
|
*
|
|
21
21
|
* @param body accepts object or json, and passes as-is
|
|
@@ -13,10 +13,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.callOpenApiCached = exports.callOpenApiCachedRaw = void 0;
|
|
16
|
-
const cookie_1 = require("../cookie");
|
|
17
|
-
const node_cache_1 = __importDefault(require("node-cache"));
|
|
18
16
|
const direct_1 = require("./direct");
|
|
17
|
+
const cookie_1 = require("../cookie");
|
|
19
18
|
const string_1 = require("../../../common/helpers/string");
|
|
19
|
+
const node_cache_1 = __importDefault(require("node-cache"));
|
|
20
20
|
let callOpenApiCache;
|
|
21
21
|
function getCacheKey({ cacheKey, overrideAuth, }) {
|
|
22
22
|
const authkeyPrefix = (overrideAuth === null || overrideAuth === void 0 ? void 0 : overrideAuth.id_token) ||
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AxiosWrapper } from '../jwt';
|
|
2
1
|
import { ICallOpenApi } from './types';
|
|
3
2
|
import { CacheItems } from '../routes';
|
|
3
|
+
import { AxiosWrapper } from '../jwt';
|
|
4
4
|
export declare type TUseCallOpenApiDispatch<A> = (value: A) => A;
|
|
5
5
|
export declare type TUseCallOpenApi<T> = AxiosWrapper<T> & {
|
|
6
6
|
loaded: boolean;
|
|
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.useCallOpenApi = void 0;
|
|
13
|
-
const react_1 = require("react");
|
|
14
13
|
const cached_1 = require("./cached");
|
|
15
14
|
const direct_1 = require("./direct");
|
|
15
|
+
const react_1 = require("react");
|
|
16
16
|
/**
|
|
17
17
|
* hooks+cached call to callOpenApi
|
|
18
18
|
* @param p
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCookieString = exports.getCookieRawWrapper = exports.getCookieRaw = void 0;
|
|
4
|
+
const set_1 = require("./set");
|
|
4
5
|
const log_1 = require("../../../common/helpers/log");
|
|
5
6
|
const string_1 = require("../../../common/helpers/string");
|
|
6
|
-
const set_1 = require("./set");
|
|
7
7
|
function getCookieRaw({ name, cookieDocument, }) {
|
|
8
8
|
const nameeq = `${name}=`;
|
|
9
9
|
const ca1 = cookieDocument || (typeof window !== 'undefined' && document.cookie);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setCookieString = exports.setCookieRawWrapper = exports.wipeCookies = void 0;
|
|
4
|
-
const log_1 = require("../../../common/helpers/log");
|
|
5
|
-
const string_1 = require("../../../common/helpers/string");
|
|
6
4
|
const const_1 = require("./const");
|
|
7
5
|
const get_1 = require("./get");
|
|
6
|
+
const log_1 = require("../../../common/helpers/log");
|
|
7
|
+
const string_1 = require("../../../common/helpers/string");
|
|
8
8
|
/**
|
|
9
9
|
* expiryDays <0 will delete
|
|
10
10
|
* @param param0
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useCookieBoolean = exports.useCookieNumber = exports.useCookieString = exports.useCookie = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
4
|
const get_1 = require("./get");
|
|
6
5
|
const set_1 = require("./set");
|
|
6
|
+
const react_1 = require("react");
|
|
7
7
|
function useCookie(p) {
|
|
8
8
|
const parse = (s) => {
|
|
9
9
|
if (!s) {
|
package/dist/ui/helpers/date.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDMY = exports.daydiffstr = void 0;
|
|
4
|
+
const plural_1 = require("./plural");
|
|
4
5
|
const date_1 = require("../../common/helpers/date");
|
|
5
6
|
const math_1 = require("../../common/helpers/math");
|
|
6
|
-
const plural_1 = require("./plural");
|
|
7
7
|
const daydiffstr = (dayticks) => {
|
|
8
8
|
const ticksSince = new Date().getTime() - dayticks;
|
|
9
9
|
const totalMinutes = (0, math_1.toFixedDown)(ticksSince / 1000 / 60, 0);
|
package/dist/ui/helpers/index.js
CHANGED
|
@@ -28,5 +28,6 @@ __exportStar(require("./useLocalStorage"), exports);
|
|
|
28
28
|
__exportStar(require("./useLockBodyScroll"), exports);
|
|
29
29
|
__exportStar(require("./useOnClickOutside"), exports);
|
|
30
30
|
__exportStar(require("./useOnScroll"), exports);
|
|
31
|
+
__exportStar(require("./useOverloadPageSearch"), exports);
|
|
31
32
|
__exportStar(require("./useQueryString"), exports);
|
|
32
33
|
__exportStar(require("./useResize"), exports);
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { TLang, TResource } from '../../common/helpers/i18n';
|
|
3
3
|
export declare const useTranslation: <T extends {
|
|
4
4
|
[a: string]: TResource;
|
|
5
|
-
}>(texts: T, lang: TLang) => (lineText: keyof T) => string | JSX.Element |
|
|
5
|
+
}>(texts: T, lang: TLang) => (lineText: keyof T) => string | JSX.Element | undefined;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getServerReq = exports.getClientOrServerReqHref = void 0;
|
|
4
|
-
const url_1 = require("url");
|
|
5
4
|
const string_1 = require("../../common/helpers/string");
|
|
6
5
|
const object_1 = require("../../common/helpers/object");
|
|
6
|
+
const url_1 = require("url");
|
|
7
7
|
const calculateServerHref = ({ host, pathname, }) => {
|
|
8
8
|
if (!host) {
|
|
9
9
|
return undefined;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UseLocalStorage = exports.getLocalStorageItem = exports.setLocalStorageItem = exports.clearAllLocalStorage = exports.clearLocalStorageItem = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
4
|
const log_1 = require("../../common/helpers/log");
|
|
6
5
|
const object_1 = require("../../common/helpers/object");
|
|
6
|
+
const react_1 = require("react");
|
|
7
7
|
const getTimeSeconds = () => Math.ceil(new Date().getTime() / 1000);
|
|
8
8
|
const clearLocalStorageItem = (key) => {
|
|
9
9
|
if (typeof window === 'undefined') {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useOverloadPageSearch = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useOverloadPageSearch = ({ disabled = false, onTrigger, }) => {
|
|
6
|
+
(0, react_1.useEffect)(() => {
|
|
7
|
+
const ctrlF = (e) => {
|
|
8
|
+
if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)) {
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
onTrigger();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
window.removeEventListener('keydown', ctrlF);
|
|
14
|
+
if (!disabled) {
|
|
15
|
+
window.addEventListener('keydown', ctrlF);
|
|
16
|
+
}
|
|
17
|
+
return () => window.removeEventListener('keydown', ctrlF);
|
|
18
|
+
}, [disabled, onTrigger]);
|
|
19
|
+
};
|
|
20
|
+
exports.useOverloadPageSearch = useOverloadPageSearch;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useQueryStringSingle = exports.useQueryStringArray = exports.useQueryStringRaw = exports.isServer = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
4
|
const object_1 = require("../../common/helpers/object");
|
|
5
|
+
const react_1 = require("react");
|
|
6
6
|
exports.isServer = typeof window === 'undefined';
|
|
7
7
|
/**
|
|
8
8
|
* hook for query string value
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useResize = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
4
|
const media_1 = require("../styles/media");
|
|
5
|
+
const react_1 = require("react");
|
|
6
6
|
function getWindowDimensions() {
|
|
7
7
|
if (typeof window !== 'undefined') {
|
|
8
8
|
const width = window.innerWidth;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export declare const HardOutline: (colour: string) => import("styled-components").FlattenSimpleInterpolation;
|
|
3
3
|
export declare const Shadow: (colour?: string) => import("styled-components").FlattenSimpleInterpolation;
|
|
4
4
|
export declare const NoTextSelect: import("styled-components").FlattenSimpleInterpolation;
|
|
5
|
+
export declare const TextOverflowEllipsis: import("styled-components").FlattenSimpleInterpolation;
|
|
5
6
|
export declare const CssTransparentBlock: import("styled-components").FlattenSimpleInterpolation;
|
|
6
7
|
export declare const FadeBottom: ({ height }: {
|
|
7
8
|
height: string;
|
package/dist/ui/styles/common.js
CHANGED
|
@@ -19,9 +19,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.FullScreenPage = exports.noDrag = exports.Card = exports.FadeBottom = exports.CssTransparentBlock = exports.NoTextSelect = exports.Shadow = exports.HardOutline = void 0;
|
|
23
|
-
const styled_components_1 = __importStar(require("styled-components"));
|
|
22
|
+
exports.FullScreenPage = exports.noDrag = exports.Card = exports.FadeBottom = exports.CssTransparentBlock = exports.TextOverflowEllipsis = exports.NoTextSelect = exports.Shadow = exports.HardOutline = void 0;
|
|
24
23
|
const colours_1 = require("./colours");
|
|
24
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
25
25
|
const HardOutline = (colour) => (0, styled_components_1.css) `
|
|
26
26
|
filter: drop-shadow(1px 1px 0px ${colour}) drop-shadow(-1px 1px 0px ${colour})
|
|
27
27
|
drop-shadow(1px -1px 0px ${colour}) drop-shadow(-1px -1px 0px ${colour});
|
|
@@ -42,6 +42,10 @@ exports.NoTextSelect = (0, styled_components_1.css) `
|
|
|
42
42
|
-moz-user-select: none; /* Firefox */
|
|
43
43
|
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
44
44
|
`;
|
|
45
|
+
exports.TextOverflowEllipsis = (0, styled_components_1.css) `
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
text-overflow: ellipsis;
|
|
48
|
+
`;
|
|
45
49
|
exports.CssTransparentBlock = (0, styled_components_1.css) `
|
|
46
50
|
background-color: rgba(150, 150, 150, 0.5);
|
|
47
51
|
border-radius: 3px;
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
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
7
|
const common_1 = require("./common");
|
|
9
8
|
const media_1 = require("./media");
|
|
9
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
10
|
exports.SOBase = (0, styled_components_1.default)(common_1.FullScreenPage) `
|
|
11
11
|
> h1,
|
|
12
12
|
h2,
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.158",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Andrei Gec <@andreigec> (https://gec.dev/)",
|
|
7
7
|
"repository": "github:andreigec/ag-common",
|
|
8
8
|
"license": "ISC",
|
|
9
9
|
"scripts": {
|
|
10
|
+
"format": "npx eslint --ext .ts,.tsx ./src --fix",
|
|
10
11
|
"build": "rimraf dist && yarn checklint && tsc",
|
|
11
|
-
"fix": "./node_modules/.bin/eslint --fix './src/**/*.ts' './src/**/*.tsx'",
|
|
12
12
|
"checklint": "npx eslint --ext .ts,.tsx ./src",
|
|
13
13
|
"start": "tsc --watch"
|
|
14
14
|
},
|