argous 1.2.150 → 1.2.151
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.
|
@@ -87,6 +87,7 @@ var lab_1 = require("@material-ui/lab");
|
|
|
87
87
|
var clsx_1 = __importDefault(require("clsx"));
|
|
88
88
|
var lodash_1 = require("lodash");
|
|
89
89
|
var react_1 = __importStar(require("react"));
|
|
90
|
+
var io_1 = require("react-icons/io");
|
|
90
91
|
var useStyles = core_1.makeStyles(function (theme) { return ({
|
|
91
92
|
subHeader: {
|
|
92
93
|
display: 'flex',
|
|
@@ -168,6 +169,13 @@ var useStyles = core_1.makeStyles(function (theme) { return ({
|
|
|
168
169
|
'&::-webkit-scrollbar-thumb': {
|
|
169
170
|
background: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.1)' : 'rgba(255, 255, 255, 0.1)'
|
|
170
171
|
}
|
|
172
|
+
},
|
|
173
|
+
searchButton: {
|
|
174
|
+
color: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.4)' : 'rgba(255, 255, 255, 0.5)',
|
|
175
|
+
'&:hover': {
|
|
176
|
+
color: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.8)' : 'rgba(255, 255, 255, 0.9)',
|
|
177
|
+
background: '#0000'
|
|
178
|
+
}
|
|
171
179
|
}
|
|
172
180
|
}); });
|
|
173
181
|
exports.CustomTooltip = core_1.withStyles(function (theme) { return ({
|
|
@@ -274,7 +282,8 @@ var ListboxFavorites = react_1.forwardRef(function (props, ref) {
|
|
|
274
282
|
});
|
|
275
283
|
});
|
|
276
284
|
var AutoCompleteFavorites = function (_a) {
|
|
277
|
-
var action = _a.action, busca = _a.busca, resposta = _a.resposta, label = _a.label, value = _a.value, pgCode = _a.pgCode, favoritePage = _a.favoritePage, groupName = _a.groupName, groupHeaderColor = _a.groupHeaderColor, groupTitleColor = _a.groupTitleColor, loadingColor = _a.loadingColor, filterFunction = _a.filterFunction, getOptionLabel = _a.getOptionLabel, _b = _a.onChange, onChange = _b === void 0 ? function (e) { return e; } : _b, _c = _a.textFieldProps, textFieldProps = _c === void 0 ? {} : _c, searchParams = _a.searchParams, props = __rest(_a, ["action", "busca", "resposta", "label", "value", "pgCode", "favoritePage", "groupName", "groupHeaderColor", "groupTitleColor", "loadingColor", "filterFunction", "getOptionLabel", "onChange", "textFieldProps", "searchParams"]);
|
|
285
|
+
var action = _a.action, busca = _a.busca, resposta = _a.resposta, autoSearch = _a.autoSearch, label = _a.label, value = _a.value, pgCode = _a.pgCode, favoritePage = _a.favoritePage, groupName = _a.groupName, groupHeaderColor = _a.groupHeaderColor, groupTitleColor = _a.groupTitleColor, loadingColor = _a.loadingColor, filterFunction = _a.filterFunction, getOptionLabel = _a.getOptionLabel, _b = _a.onChange, onChange = _b === void 0 ? function (e) { return e; } : _b, _c = _a.textFieldProps, textFieldProps = _c === void 0 ? {} : _c, searchParams = _a.searchParams, props = __rest(_a, ["action", "busca", "resposta", "autoSearch", "label", "value", "pgCode", "favoritePage", "groupName", "groupHeaderColor", "groupTitleColor", "loadingColor", "filterFunction", "getOptionLabel", "onChange", "textFieldProps", "searchParams"]);
|
|
286
|
+
var classes = useStyles();
|
|
278
287
|
var _d = react_1.useState({
|
|
279
288
|
lista: [],
|
|
280
289
|
slide: true,
|
|
@@ -292,9 +301,11 @@ var AutoCompleteFavorites = function (_a) {
|
|
|
292
301
|
setSeconds(0);
|
|
293
302
|
};
|
|
294
303
|
var setInput = function (value) {
|
|
304
|
+
if (loading)
|
|
305
|
+
return;
|
|
295
306
|
stopCounter();
|
|
296
307
|
setInputValue(value);
|
|
297
|
-
startCounter();
|
|
308
|
+
autoSearch && startCounter();
|
|
298
309
|
};
|
|
299
310
|
function carimbaLista(lista) {
|
|
300
311
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -340,12 +351,14 @@ var AutoCompleteFavorites = function (_a) {
|
|
|
340
351
|
}
|
|
341
352
|
});
|
|
342
353
|
}); }, [inputValue, searchParams]);
|
|
343
|
-
react_1.useEffect(function () { return seconds === 1 && buscar(); }, [seconds, buscar]);
|
|
354
|
+
react_1.useEffect(function () { return autoSearch && seconds === 1 && buscar(); }, [autoSearch, seconds, buscar]);
|
|
344
355
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
345
356
|
react_1.useEffect(function () { return lodash_1.isString(value) && buscar(value); }, []);
|
|
346
|
-
return (react_1.default.createElement(lab_1.Autocomplete, __assign({}, props, { value: value, onChange: onChange }, {
|
|
357
|
+
return (react_1.default.createElement(lab_1.Autocomplete, __assign({}, props, { value: value, onChange: onChange }, { autoComplete: true, autoHighlight: true, openText: 'Abrir', clearText: 'Limpar', filterSelectedOptions: true, onInputChange: function (e) { var _a; return setInput(((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.value) || ''); }, getOptionSelected: function (o, v) { return o[0] === v; }, getOptionLabel: getOptionLabel && (function (option) { return getOptionLabel(option, dados === null || dados === void 0 ? void 0 : dados.lista); }), noOptionsText: inputValue.length < 2 ? 'Digite para pesquisar' : 'Não Encontrado', options: lodash_1.isObject(value) ? dados === null || dados === void 0 ? void 0 : dados.lista.filter(function (v) { return filterFunction ? filterFunction(v, value) : true || v[0] !== value[0]; }) : dados === null || dados === void 0 ? void 0 : dados.lista, renderInput: function (params) { return (react_1.default.createElement(core_1.TextField, __assign({ margin: 'dense', variant: 'outlined', label: label }, params, textFieldProps, { onKeyUp: function (e) { return ((e.key === 'Enter' || e.key === 'Tab') && !loading) && buscar(); }, inputProps: __assign(__assign({}, params.inputProps), { onKeyDown: function (e) { return (e.key === 'Enter' || e.key === 'Tab') && e.stopPropagation(); } }), InputProps: __assign(__assign(__assign({}, textFieldProps.InputProps), params.InputProps), { endAdornment: (react_1.default.createElement(react_1.default.Fragment, null,
|
|
347
358
|
params.InputProps.endAdornment,
|
|
348
359
|
react_1.default.createElement(core_1.Fade, { in: loading },
|
|
349
|
-
react_1.default.createElement(core_1.CircularProgress, { disableShrink: true, color: loadingColor || 'inherit', size: 20 }))
|
|
360
|
+
react_1.default.createElement(core_1.CircularProgress, { disableShrink: true, color: loadingColor || 'inherit', size: 20 })),
|
|
361
|
+
!autoSearch && react_1.default.createElement(core_1.IconButton, { size: 'small', onClick: function (e) { return buscar(); }, className: classes.searchButton },
|
|
362
|
+
react_1.default.createElement(io_1.IoIosSearch, { size: 20 })))) }) }))); }, ListboxComponent: ListboxFavorites, ListboxProps: { dados: dados, setDados: setDados, favoritePage: favoritePage, groupHeaderColor: groupHeaderColor, groupTitleColor: groupTitleColor } })));
|
|
350
363
|
};
|
|
351
364
|
exports.default = AutoCompleteFavorites;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { serverAction, setError } from '../../utils/api';
|
|
2
|
-
import { CircularProgress, Fade, ListItem, ListItemText, ListSubheader, makeStyles, Slide, TextField, Tooltip, withStyles } from '@material-ui/core';
|
|
2
|
+
import { CircularProgress, Fade, IconButton, ListItem, ListItemText, ListSubheader, makeStyles, Slide, TextField, Tooltip, withStyles } from '@material-ui/core';
|
|
3
3
|
import { Autocomplete } from '@material-ui/lab';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { isObject, isString } from 'lodash';
|
|
6
6
|
import React, { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
7
|
+
import { IoIosSearch } from 'react-icons/io';
|
|
7
8
|
|
|
8
9
|
const useStyles = makeStyles((theme) => ({
|
|
9
10
|
subHeader: {
|
|
@@ -86,6 +87,13 @@ const useStyles = makeStyles((theme) => ({
|
|
|
86
87
|
'&::-webkit-scrollbar-thumb': {
|
|
87
88
|
background: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.1)' : 'rgba(255, 255, 255, 0.1)'
|
|
88
89
|
}
|
|
90
|
+
},
|
|
91
|
+
searchButton: {
|
|
92
|
+
color: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.4)' : 'rgba(255, 255, 255, 0.5)',
|
|
93
|
+
'&:hover': {
|
|
94
|
+
color: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.8)' : 'rgba(255, 255, 255, 0.9)',
|
|
95
|
+
background: '#0000'
|
|
96
|
+
}
|
|
89
97
|
}
|
|
90
98
|
}));
|
|
91
99
|
|
|
@@ -214,8 +222,9 @@ const ListboxFavorites = forwardRef((props, ref) => {
|
|
|
214
222
|
));
|
|
215
223
|
});
|
|
216
224
|
|
|
217
|
-
const AutoCompleteFavorites = ({ action, busca, resposta, label, value, pgCode, favoritePage, groupName, groupHeaderColor, groupTitleColor, loadingColor, filterFunction, getOptionLabel, onChange = e => e, textFieldProps = {}, searchParams, ...props }) => {
|
|
225
|
+
const AutoCompleteFavorites = ({ action, busca, resposta, autoSearch, label, value, pgCode, favoritePage, groupName, groupHeaderColor, groupTitleColor, loadingColor, filterFunction, getOptionLabel, onChange = e => e, textFieldProps = {}, searchParams, ...props }) => {
|
|
218
226
|
|
|
227
|
+
const classes = useStyles();
|
|
219
228
|
const [dados, setDados] = useState({
|
|
220
229
|
lista: [],
|
|
221
230
|
slide: true,
|
|
@@ -236,9 +245,10 @@ const AutoCompleteFavorites = ({ action, busca, resposta, label, value, pgCode,
|
|
|
236
245
|
};
|
|
237
246
|
|
|
238
247
|
const setInput = value => {
|
|
248
|
+
if (loading) return;
|
|
239
249
|
stopCounter();
|
|
240
250
|
setInputValue(value);
|
|
241
|
-
startCounter();
|
|
251
|
+
autoSearch && startCounter();
|
|
242
252
|
};
|
|
243
253
|
|
|
244
254
|
async function carimbaLista(lista) {
|
|
@@ -262,7 +272,7 @@ const AutoCompleteFavorites = ({ action, busca, resposta, label, value, pgCode,
|
|
|
262
272
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
263
273
|
}, [inputValue, searchParams]);
|
|
264
274
|
|
|
265
|
-
useEffect(() => seconds === 1 && buscar(), [seconds, buscar]);
|
|
275
|
+
useEffect(() => autoSearch && seconds === 1 && buscar(), [autoSearch, seconds, buscar]);
|
|
266
276
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
267
277
|
useEffect(() => isString(value) && buscar(value), []);
|
|
268
278
|
|
|
@@ -270,16 +280,16 @@ const AutoCompleteFavorites = ({ action, busca, resposta, label, value, pgCode,
|
|
|
270
280
|
<Autocomplete
|
|
271
281
|
{...props}
|
|
272
282
|
{...{ value, onChange }}
|
|
273
|
-
options={isObject(value) ? dados?.lista.filter(v => filterFunction ? filterFunction(v, value) : true || v[0] !== value[0]) : dados?.lista}
|
|
274
|
-
getOptionLabel={getOptionLabel && (option => getOptionLabel(option, dados?.lista))}
|
|
275
|
-
noOptionsText={inputValue.length < 2 ? 'Digite para pesquisar' : 'Não Encontrado'}
|
|
276
|
-
onInputChange={e => setInput(e?.target?.value || '')}
|
|
277
|
-
getOptionSelected={(o, v) => o[0] === v}
|
|
278
283
|
autoComplete
|
|
279
284
|
autoHighlight
|
|
280
285
|
openText='Abrir'
|
|
281
286
|
clearText='Limpar'
|
|
282
287
|
filterSelectedOptions
|
|
288
|
+
onInputChange={e => setInput(e?.target?.value || '')}
|
|
289
|
+
getOptionSelected={(o, v) => o[0] === v}
|
|
290
|
+
getOptionLabel={getOptionLabel && (option => getOptionLabel(option, dados?.lista))}
|
|
291
|
+
noOptionsText={inputValue.length < 2 ? 'Digite para pesquisar' : 'Não Encontrado'}
|
|
292
|
+
options={isObject(value) ? dados?.lista.filter(v => filterFunction ? filterFunction(v, value) : true || v[0] !== value[0]) : dados?.lista}
|
|
283
293
|
renderInput={params => (
|
|
284
294
|
<TextField
|
|
285
295
|
margin='dense'
|
|
@@ -287,6 +297,11 @@ const AutoCompleteFavorites = ({ action, busca, resposta, label, value, pgCode,
|
|
|
287
297
|
label={label}
|
|
288
298
|
{...params}
|
|
289
299
|
{...textFieldProps}
|
|
300
|
+
onKeyUp={e => ((e.key === 'Enter' || e.key === 'Tab') && !loading) && buscar()}
|
|
301
|
+
inputProps={{
|
|
302
|
+
...params.inputProps,
|
|
303
|
+
onKeyDown: e => (e.key === 'Enter' || e.key === 'Tab') && e.stopPropagation()
|
|
304
|
+
}}
|
|
290
305
|
InputProps={{
|
|
291
306
|
...textFieldProps.InputProps,
|
|
292
307
|
...params.InputProps,
|
|
@@ -294,6 +309,7 @@ const AutoCompleteFavorites = ({ action, busca, resposta, label, value, pgCode,
|
|
|
294
309
|
<React.Fragment>
|
|
295
310
|
{params.InputProps.endAdornment}
|
|
296
311
|
<Fade in={loading}><CircularProgress disableShrink color={loadingColor || 'inherit'} size={20} /></Fade>
|
|
312
|
+
{!autoSearch && <IconButton size='small' onClick={e => buscar()} className={classes.searchButton}><IoIosSearch size={20} /></IconButton>}
|
|
297
313
|
</React.Fragment>
|
|
298
314
|
)
|
|
299
315
|
}}
|