ag-common 0.0.535 → 0.0.537
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/ui/components/Search/AutoHideSearchBox.js +1 -1
- package/dist/ui/components/Search/Base.d.ts +2 -0
- package/dist/ui/components/Search/Base.js +15 -1
- package/dist/ui/components/Search/Inline.d.ts +2 -0
- package/dist/ui/components/Search/SearchBox.d.ts +2 -1
- package/dist/ui/components/Search/SearchBox.js +10 -19
- package/package.json +1 -1
|
@@ -91,7 +91,7 @@ const AutoHideSearchBox = (p) => {
|
|
|
91
91
|
} },
|
|
92
92
|
open && react_1.default.createElement(icons_1.CrossIcon, null),
|
|
93
93
|
!open && react_1.default.createElement(icons_1.Magnify, { style: { fill: 'white' } })),
|
|
94
|
-
react_1.default.createElement(SearchBoxStyled, Object.assign({
|
|
94
|
+
react_1.default.createElement(SearchBoxStyled, Object.assign({ textBoxRef: textEditRef }, p, { className: "", "data-open": open, defaultValue: p.searchText, setSearchText: (val, enter) => {
|
|
95
95
|
//we dont want empty enters to do anything
|
|
96
96
|
if (val === '' && enter) {
|
|
97
97
|
p.setSearchText(val, false);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { IRefTextEdit } from '../TextEdit/types';
|
|
2
3
|
import type { ISearchDialog, TSearchModalRes } from './types';
|
|
3
4
|
type ISearchBase<T> = ISearchDialog<T> & {
|
|
4
5
|
onSearchTextChange?: (v: string) => void;
|
|
5
6
|
onSelectItem?: (v: TSearchModalRes<T>) => void;
|
|
7
|
+
textBoxRef?: React.RefObject<IRefTextEdit>;
|
|
6
8
|
};
|
|
7
9
|
export declare const SearchBase: <T>(p: ISearchBase<T>) => React.JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -67,6 +67,20 @@ const SearchBase = (p) => {
|
|
|
67
67
|
var _a, _b, _c, _d;
|
|
68
68
|
const { maxDisplayItems = 1000 } = p;
|
|
69
69
|
const [searchText, setSearchText] = (0, react_1.useState)((_a = p.defaultValue) !== null && _a !== void 0 ? _a : '');
|
|
70
|
+
(0, react_1.useImperativeHandle)(p.textBoxRef, () => ({
|
|
71
|
+
setValue: (v) => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
const value = (_a = divRef === null || divRef === void 0 ? void 0 : divRef.current) === null || _a === void 0 ? void 0 : _a.getValue();
|
|
74
|
+
if (v === value) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
(_b = divRef === null || divRef === void 0 ? void 0 : divRef.current) === null || _b === void 0 ? void 0 : _b.setValue(v);
|
|
78
|
+
setSearchText(v);
|
|
79
|
+
},
|
|
80
|
+
focus: () => { var _a; return (_a = divRef === null || divRef === void 0 ? void 0 : divRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
81
|
+
getValue: () => { var _a; return (_a = divRef === null || divRef === void 0 ? void 0 : divRef.current) === null || _a === void 0 ? void 0 : _a.getValue(); },
|
|
82
|
+
}));
|
|
83
|
+
const divRef = (0, react_1.useRef)(null);
|
|
70
84
|
const resWrap = (foundItem, target) => {
|
|
71
85
|
var _a, _b;
|
|
72
86
|
if (!foundItem) {
|
|
@@ -86,7 +100,7 @@ const SearchBase = (p) => {
|
|
|
86
100
|
var _a;
|
|
87
101
|
setSearchText(t);
|
|
88
102
|
(_a = p.onSearchTextChange) === null || _a === void 0 ? void 0 : _a.call(p, t);
|
|
89
|
-
} })),
|
|
103
|
+
}, textBoxRef: divRef })),
|
|
90
104
|
react_1.default.createElement(Content, { "data-hasitems": !!filteredItems.length, "data-type": "content" },
|
|
91
105
|
filteredItems.map((item, index) => (0, react_1.cloneElement)(p.renderItem({ searchText, item, index }), {
|
|
92
106
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { IRefTextEdit } from '../TextEdit/types';
|
|
2
3
|
import type { ISearchInline, TSearchModalRes } from './types';
|
|
3
4
|
export declare const SearchInline: <T>(p: ISearchInline<T> & {
|
|
4
5
|
onSelectItem?: ((v: TSearchModalRes<T>) => void) | undefined;
|
|
5
6
|
onSearchTextChange?: ((v: string) => void) | undefined;
|
|
7
|
+
textBoxRef?: React.RefObject<IRefTextEdit> | undefined;
|
|
6
8
|
}) => React.JSX.Element;
|
|
@@ -6,5 +6,6 @@ export interface ISearchBox {
|
|
|
6
6
|
setSearchText: (val: string, enterPressed: boolean) => void;
|
|
7
7
|
defaultValue?: string;
|
|
8
8
|
className?: string;
|
|
9
|
+
textBoxRef?: React.RefObject<IRefTextEdit>;
|
|
9
10
|
}
|
|
10
|
-
export declare const SearchBox:
|
|
11
|
+
export declare const SearchBox: (p: ISearchBox) => React.JSX.Element;
|
|
@@ -70,32 +70,23 @@ const TextEditStyled = (0, styled_1.default)(TextEdit_1.TextEdit) `
|
|
|
70
70
|
padding: 0;
|
|
71
71
|
height: 2.5rem;
|
|
72
72
|
`;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
(0, react_1.
|
|
76
|
-
setValue: (v) => {
|
|
77
|
-
var _a, _b;
|
|
78
|
-
const value = (_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.getValue();
|
|
79
|
-
if (v === value) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
(_b = textEditRef.current) === null || _b === void 0 ? void 0 : _b.setValue(v);
|
|
83
|
-
},
|
|
84
|
-
focus: () => { var _a; return (_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
85
|
-
getValue: () => { var _a; return (_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.getValue(); },
|
|
86
|
-
}));
|
|
73
|
+
const SearchBox = (p) => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
const ref = (0, react_1.useRef)((_b = (_a = p.textBoxRef) === null || _a === void 0 ? void 0 : _a.current) !== null && _b !== void 0 ? _b : null);
|
|
87
76
|
(0, react_1.useEffect)(() => {
|
|
88
77
|
var _a;
|
|
89
|
-
(_a =
|
|
90
|
-
|
|
78
|
+
(_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.setValue(p.searchText);
|
|
79
|
+
p.setSearchText(p.searchText, true);
|
|
80
|
+
}, [p]);
|
|
91
81
|
return (react_1.default.createElement(Base, Object.assign({ "data-type": "search", className: p.className }, (0, dom_1.filterDataProps)(p)),
|
|
92
|
-
react_1.default.createElement(TextEditStyled, { ref:
|
|
82
|
+
react_1.default.createElement(TextEditStyled, { ref: ref, placeholder: p.placeholderText, defaultEditing: { focus: true }, singleLine: true, leftContent: react_1.default.createElement(MagnifyIcon, { onClick: () => { var _a; return p.setSearchText(((_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.getValue()) || '', true); } },
|
|
93
83
|
react_1.default.createElement(icons_1.Magnify, null)), noGrow: true, allowUndo: false, onClickOutsideWithNoValue: null, onSubmit: (v, enterPressed) => (0, debounce_1.debounce)(() => {
|
|
94
84
|
p.setSearchText(v, enterPressed);
|
|
95
85
|
}, { key: 'pagesearch', time: 200 }), defaultValue: p.defaultValue }),
|
|
96
86
|
p.searchText && (react_1.default.createElement(CrossIconStyled, { onClick: () => {
|
|
97
87
|
var _a;
|
|
98
|
-
(_a =
|
|
88
|
+
(_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.setValue('');
|
|
99
89
|
p.setSearchText('', true);
|
|
100
90
|
} }))));
|
|
101
|
-
}
|
|
91
|
+
};
|
|
92
|
+
exports.SearchBox = SearchBox;
|
package/package.json
CHANGED