ag-common 0.0.386 → 0.0.387
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IRefTextEdit } from '../TextEdit';
|
|
2
3
|
export interface ISearchBox {
|
|
3
4
|
placeholderText?: string;
|
|
4
5
|
searchText: string;
|
|
@@ -6,4 +7,4 @@ export interface ISearchBox {
|
|
|
6
7
|
defaultValue?: string;
|
|
7
8
|
className?: string;
|
|
8
9
|
}
|
|
9
|
-
export declare const SearchBox:
|
|
10
|
+
export declare const SearchBox: React.ForwardRefExoticComponent<ISearchBox & React.RefAttributes<IRefTextEdit>>;
|
|
@@ -50,10 +50,11 @@ const Base = styled_1.default.div `
|
|
|
50
50
|
width: 100%;
|
|
51
51
|
}
|
|
52
52
|
`;
|
|
53
|
-
const
|
|
53
|
+
const MagnifyIcon = styled_1.default.div `
|
|
54
54
|
width: 1.5rem;
|
|
55
55
|
height: 1.5rem;
|
|
56
56
|
margin-right: 0.5rem;
|
|
57
|
+
cursor: pointer;
|
|
57
58
|
`;
|
|
58
59
|
const CrossIconStyled = (0, styled_1.default)(icons_1.CrossIcon) `
|
|
59
60
|
position: absolute;
|
|
@@ -62,14 +63,26 @@ const CrossIconStyled = (0, styled_1.default)(icons_1.CrossIcon) `
|
|
|
62
63
|
right: 2rem;
|
|
63
64
|
}
|
|
64
65
|
`;
|
|
65
|
-
|
|
66
|
+
exports.SearchBox = (0, react_1.forwardRef)((p, ref) => {
|
|
66
67
|
const textEditRef = (0, react_1.createRef)();
|
|
68
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
69
|
+
setValue: (v) => {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
const value = (_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.getValue();
|
|
72
|
+
if (v === value) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
(_b = textEditRef.current) === null || _b === void 0 ? void 0 : _b.setValue(v);
|
|
76
|
+
},
|
|
77
|
+
focus: () => { var _a; return (_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
78
|
+
getValue: () => { var _a; return (_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.getValue(); },
|
|
79
|
+
}));
|
|
67
80
|
(0, react_1.useEffect)(() => {
|
|
68
81
|
var _a;
|
|
69
|
-
(_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.setValue(p.searchText);
|
|
82
|
+
(_a = textEditRef === null || textEditRef === void 0 ? void 0 : textEditRef.current) === null || _a === void 0 ? void 0 : _a.setValue(p.searchText);
|
|
70
83
|
}, [p.searchText, textEditRef]);
|
|
71
84
|
return (react_1.default.createElement(Base, Object.assign({ "data-type": "search", className: p.className }, (0, helpers_1.filterDataProps)(p)),
|
|
72
|
-
react_1.default.createElement(TextEdit_1.TextEdit, { ref: textEditRef, placeholder: p.placeholderText, defaultEditing: { focus: true }, singleLine: true, leftContent: react_1.default.createElement(
|
|
85
|
+
react_1.default.createElement(TextEdit_1.TextEdit, { ref: textEditRef, placeholder: p.placeholderText, defaultEditing: { focus: true }, singleLine: true, leftContent: react_1.default.createElement(MagnifyIcon, { onClick: () => { var _a; return p.setSearchText(((_a = textEditRef === null || textEditRef === void 0 ? void 0 : textEditRef.current) === null || _a === void 0 ? void 0 : _a.getValue()) || '', true); } },
|
|
73
86
|
react_1.default.createElement(icons_1.Magnify, null)), noGrow: true, allowUndo: false, onClickOutsideWithNoValue: null, onSubmit: (v, enterPressed) => (0, helpers_1.debounce)(() => {
|
|
74
87
|
p.setSearchText(v, enterPressed);
|
|
75
88
|
}, { key: 'pagesearch', time: 200 }), defaultValue: p.defaultValue }),
|
|
@@ -78,5 +91,4 @@ const SearchBox = (p) => {
|
|
|
78
91
|
(_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.setValue('');
|
|
79
92
|
p.setSearchText('', true);
|
|
80
93
|
} }))));
|
|
81
|
-
};
|
|
82
|
-
exports.SearchBox = SearchBox;
|
|
94
|
+
});
|
|
@@ -103,10 +103,7 @@ exports.TextEdit = (0, react_2.forwardRef)((p, ref) => {
|
|
|
103
103
|
}
|
|
104
104
|
setValue(v);
|
|
105
105
|
},
|
|
106
|
-
focus: () => {
|
|
107
|
-
var _a, _b;
|
|
108
|
-
(_b = (_a = taref.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
109
|
-
},
|
|
106
|
+
focus: () => { var _a; return (_a = taref.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
110
107
|
getValue: () => { var _a; return (_a = taref.current) === null || _a === void 0 ? void 0 : _a.value; },
|
|
111
108
|
}));
|
|
112
109
|
(0, useOnClickOutside_1.useOnClickOutside)({
|