ag-common 0.0.152 → 0.0.156
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/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/DropdownList/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/TextEdit/TextEdit.d.ts +21 -6
- package/dist/ui/components/TextEdit/TextEdit.js +13 -9
- package/dist/ui/components/index.d.ts +1 -0
- package/dist/ui/components/index.js +1 -0
- 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/useOverloadPageSearch.d.ts +7 -0
- package/dist/ui/helpers/useOverloadPageSearch.js +20 -0
- package/dist/ui/styles/common.d.ts +1 -0
- package/dist/ui/styles/common.js +5 -1
- package/package.json +1 -1
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
|
|
|
@@ -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
|
|
@@ -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 react_1 = __importStar(require("react"));
|
|
36
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
37
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
38
|
+
const debounce_1 = require("../../helpers/debounce");
|
|
39
|
+
const media_1 = require("../../styles/media");
|
|
40
|
+
const Modal_1 = require("../Modal");
|
|
41
|
+
const TextEdit_1 = require("../TextEdit/TextEdit");
|
|
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;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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);
|
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;
|
|
@@ -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;
|
|
@@ -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,7 +19,7 @@ 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;
|
|
22
|
+
exports.FullScreenPage = exports.noDrag = exports.Card = exports.FadeBottom = exports.CssTransparentBlock = exports.TextOverflowEllipsis = exports.NoTextSelect = exports.Shadow = exports.HardOutline = void 0;
|
|
23
23
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
24
24
|
const colours_1 = require("./colours");
|
|
25
25
|
const HardOutline = (colour) => (0, styled_components_1.css) `
|
|
@@ -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;
|