argous 1.2.138 → 1.2.142
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/components/AutoCompleteFavorites/AutoCompleteFavorites.d.ts +89 -20
- package/dist/components/AutoCompleteFavorites/AutoCompleteFavorites.js +45 -27
- package/dist/components/AutoCompleteFavorites/index.d.ts +2 -1
- package/dist/components/index.d.ts +4 -1
- package/lib/components/AutoCompleteFavorites/AutoCompleteFavorites.d.ts +89 -0
- package/lib/components/AutoCompleteFavorites/AutoCompleteFavorites.js +36 -31
- package/lib/components/AutoCompleteFavorites/index.d.ts +2 -0
- package/lib/components/index.d.ts +4 -1
- package/package.json +1 -1
|
@@ -1,20 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { TextFieldProps } from '@material-ui/core';
|
|
2
|
+
import { AutocompleteProps, AutocompleteChangeDetails } from '@material-ui/lab';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
export interface AutoCompleteFavoritesProps extends Omit<AutocompleteProps<any, false, false, false>, 'getOptionLabel'>{
|
|
6
|
+
/**
|
|
7
|
+
* Valor do campo
|
|
8
|
+
*/
|
|
9
|
+
value?: Array<number|string> | object,
|
|
10
|
+
/**
|
|
11
|
+
* Props repassados ao componente Textfield
|
|
12
|
+
*/
|
|
13
|
+
textFieldProps?: TextFieldProps,
|
|
14
|
+
/**
|
|
15
|
+
* Callback fired when the value changes.
|
|
16
|
+
*
|
|
17
|
+
* @param event — The event source of the callback.
|
|
18
|
+
*
|
|
19
|
+
* @param value — The new value of the component.
|
|
20
|
+
*
|
|
21
|
+
* @param reason — One of "create-option", "select-option", "remove-option", "blur", "clear" ou "only-one-left".
|
|
22
|
+
*/
|
|
23
|
+
onChange?: ((event: React.ChangeEvent<{}>, value: any, reason: 'create-option' | 'select-option' | 'remove-option' | 'blur' | 'clear' | 'only-one-left', details?: AutocompleteChangeDetails<any> | undefined) => void) | undefined,
|
|
24
|
+
/**
|
|
25
|
+
* Formata o valor que aparece na listagem
|
|
26
|
+
*
|
|
27
|
+
* @param option - Opção sendo testada ou selecionada
|
|
28
|
+
*
|
|
29
|
+
* @param lista - Lista com todas as opções
|
|
30
|
+
*/
|
|
31
|
+
getOptionLabel?: ((option: Array<any>, lista: Array<Array<any>>) => string),
|
|
32
|
+
/**
|
|
33
|
+
* Utiliza um pgCode diferente do padrão
|
|
34
|
+
*/
|
|
35
|
+
pgCode?: string,
|
|
36
|
+
/**
|
|
37
|
+
* Objeto de busca personalizado
|
|
38
|
+
*/
|
|
39
|
+
busca?: string,
|
|
40
|
+
/**
|
|
41
|
+
* Objeto de resposta personalizado
|
|
42
|
+
*/
|
|
43
|
+
resposta?: string,
|
|
44
|
+
/**
|
|
45
|
+
* Action personalizada
|
|
46
|
+
*/
|
|
47
|
+
action?: string,
|
|
48
|
+
/**
|
|
49
|
+
* Label do campo
|
|
50
|
+
*/
|
|
51
|
+
label?: string,
|
|
52
|
+
/**
|
|
53
|
+
* Parametros utilizados no metodo de busca
|
|
54
|
+
*/
|
|
55
|
+
searchParams?: object,
|
|
56
|
+
/**
|
|
57
|
+
* Define a cor do loading
|
|
58
|
+
*/
|
|
59
|
+
loadingColor?: string,
|
|
60
|
+
/**
|
|
61
|
+
* Parametro que define se terá paginação
|
|
62
|
+
*/
|
|
63
|
+
favoritePage?: boolean,
|
|
64
|
+
/**
|
|
65
|
+
* Array contendo nome do grupo
|
|
66
|
+
*/
|
|
67
|
+
groupName?: Array<string>,
|
|
68
|
+
/**
|
|
69
|
+
* Array contendo a cor do titulo no grupo
|
|
70
|
+
*/
|
|
71
|
+
groupTitleColor?: Array<string>,
|
|
72
|
+
/**
|
|
73
|
+
* Array contendo o backgroundColor do header no grupo
|
|
74
|
+
*/
|
|
75
|
+
groupHeaderColor?: Array<string>,
|
|
76
|
+
/**
|
|
77
|
+
* Função para filtrar a lista de opções
|
|
78
|
+
*
|
|
79
|
+
* @param valor - Valor setado no componente
|
|
80
|
+
* @param item - Item a ser testado contra o valor
|
|
81
|
+
*
|
|
82
|
+
* @returns {boolean} Retorna true se item de ser removido da lista
|
|
83
|
+
*/
|
|
84
|
+
filterFunction?: (valor: any, item: any) => boolean,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare function AutoCompleteFavorites(props: AutoCompleteFavoritesProps): JSX.Element
|
|
88
|
+
|
|
89
|
+
export default AutoCompleteFavorites;
|
|
@@ -80,6 +80,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
80
80
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
81
81
|
};
|
|
82
82
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
83
|
+
exports.CustomTooltip = void 0;
|
|
83
84
|
var api_1 = require("../../utils/api");
|
|
84
85
|
var core_1 = require("@material-ui/core");
|
|
85
86
|
var lab_1 = require("@material-ui/lab");
|
|
@@ -169,16 +170,16 @@ var useStyles = core_1.makeStyles(function (theme) { return ({
|
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
}); });
|
|
172
|
-
|
|
173
|
+
exports.CustomTooltip = core_1.withStyles(function (theme) { return ({
|
|
173
174
|
tooltip: theme.palette.type === 'light' ? {
|
|
174
175
|
fontSize: 15,
|
|
175
176
|
fontWeight: 400,
|
|
176
|
-
color: '
|
|
177
|
+
color: '#FFF',
|
|
177
178
|
backgroundColor: '#333333e3',
|
|
178
179
|
} : {
|
|
179
180
|
fontSize: 15,
|
|
180
181
|
fontWeight: 400,
|
|
181
|
-
color: '
|
|
182
|
+
color: '#000',
|
|
182
183
|
backgroundColor: '#fbfbfbd1',
|
|
183
184
|
},
|
|
184
185
|
arrow: {
|
|
@@ -189,6 +190,7 @@ var ListboxFavorites = react_1.forwardRef(function (props, ref) {
|
|
|
189
190
|
var classes = useStyles();
|
|
190
191
|
var children = props.children, favoritePage = props.favoritePage, dados = props.dados, setDados = props.setDados, groupHeaderColor = props.groupHeaderColor, groupTitleColor = props.groupTitleColor;
|
|
191
192
|
var pageNumber = dados.pageNumber, favoritosLength = dados.favoritosLength, direction = dados.direction, slide = dados.slide;
|
|
193
|
+
console.log('Listbox', children);
|
|
192
194
|
function retornaInicio() {
|
|
193
195
|
switch (pageNumber) {
|
|
194
196
|
case 1:
|
|
@@ -219,11 +221,11 @@ var ListboxFavorites = react_1.forwardRef(function (props, ref) {
|
|
|
219
221
|
function retornaEstrutura(sectionIndex, item) {
|
|
220
222
|
if (sectionIndex === 0 && favoritePage && favoritosLength > 7) {
|
|
221
223
|
return (react_1.default.createElement(core_1.Slide, { in: slide, direction: direction },
|
|
222
|
-
react_1.default.createElement(CustomTooltip, { title: item.props.children, arrow: true, enterDelay: '1000', enterNextDelay: '1000', placement: 'top-end', TransitionComponent: core_1.Fade, TransitionProps: { timeout: { enter: 100, exit: 500 } } },
|
|
224
|
+
react_1.default.createElement(exports.CustomTooltip, { title: item.props.children, arrow: true, enterDelay: '1000', enterNextDelay: '1000', placement: 'top-end', TransitionComponent: core_1.Fade, TransitionProps: { timeout: { enter: 100, exit: 500 } } },
|
|
223
225
|
react_1.default.createElement(core_1.ListItem, __assign({}, item.props, { key: item.key, className: classes.listItem }),
|
|
224
226
|
react_1.default.createElement(core_1.ListItemText, { primary: item.props.children, className: classes.listItemText })))));
|
|
225
227
|
}
|
|
226
|
-
return (react_1.default.createElement(CustomTooltip, { title: item.props.children, arrow: true, enterDelay: '1000', enterNextDelay: '1000', placement: 'top-end', TransitionComponent: core_1.Fade, TransitionProps: { timeout: { enter: 100, exit: 500 } } },
|
|
228
|
+
return (react_1.default.createElement(exports.CustomTooltip, { title: item.props.children, arrow: true, enterDelay: '1000', enterNextDelay: '1000', placement: 'top-end', TransitionComponent: core_1.Fade, TransitionProps: { timeout: { enter: 100, exit: 500 } } },
|
|
227
229
|
react_1.default.createElement(core_1.ListItem, __assign({}, item.props, { key: item.key, className: classes.listItem }),
|
|
228
230
|
react_1.default.createElement(core_1.ListItemText, { primary: item.props.children, className: classes.listItemText }))));
|
|
229
231
|
}
|
|
@@ -283,6 +285,28 @@ var AutoCompleteFavorites = function (_a) {
|
|
|
283
285
|
}), dados = _d[0], setDados = _d[1];
|
|
284
286
|
var _e = react_1.useState(false), loading = _e[0], setLoading = _e[1];
|
|
285
287
|
var _f = react_1.useState(''), inputValue = _f[0], setInputValue = _f[1];
|
|
288
|
+
function carimbaLista(lista) {
|
|
289
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
290
|
+
var completo;
|
|
291
|
+
return __generator(this, function (_a) {
|
|
292
|
+
console.log('carimbaLista', lista);
|
|
293
|
+
completo = [];
|
|
294
|
+
lista.map(function (arr, index) {
|
|
295
|
+
index === 0 && favoritePage && setDados(function (v) { return (__assign(__assign({}, v), { favoritosLength: arr.length })); });
|
|
296
|
+
return arr.map(function (itemArr) { return itemArr.length < itemArr.length + 1 && itemArr.push(groupName[index]); });
|
|
297
|
+
});
|
|
298
|
+
lista.forEach(function (v) {
|
|
299
|
+
for (var _i = 0, _a = v.values(); _i < _a.length; _i++) {
|
|
300
|
+
var item = _a[_i];
|
|
301
|
+
completo.push(item);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
console.log('carimbaLista completo', completo);
|
|
305
|
+
setDados(function (v) { return (__assign(__assign({}, v), { lista: completo })); });
|
|
306
|
+
return [2 /*return*/];
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
}
|
|
286
310
|
var buscar = react_1.useCallback(function (valor) { return __awaiter(void 0, void 0, void 0, function () {
|
|
287
311
|
var res;
|
|
288
312
|
var _a;
|
|
@@ -294,38 +318,32 @@ var AutoCompleteFavorites = function (_a) {
|
|
|
294
318
|
return [4 /*yield*/, api_1.serverAction(action, __assign((_a = {}, _a[busca] = valor || inputValue, _a), searchParams), true, pgCode)];
|
|
295
319
|
case 1:
|
|
296
320
|
res = _c.sent();
|
|
297
|
-
if (
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
321
|
+
if (res)
|
|
322
|
+
console.log('Resposta busca', res);
|
|
323
|
+
if (!(((_b = res[resposta || 'result']) === null || _b === void 0 ? void 0 : _b.length) > 1)) return [3 /*break*/, 3];
|
|
324
|
+
return [4 /*yield*/, carimbaLista(res[resposta || 'result'])];
|
|
325
|
+
case 2:
|
|
326
|
+
_c.sent();
|
|
327
|
+
return [3 /*break*/, 4];
|
|
328
|
+
case 3:
|
|
329
|
+
if (res[resposta || 'result'])
|
|
330
|
+
setDados({ lista: res[resposta || 'result'] || [] });
|
|
301
331
|
else
|
|
302
332
|
api_1.setError('Erro ao tentar buscar dados.');
|
|
333
|
+
_c.label = 4;
|
|
334
|
+
case 4:
|
|
303
335
|
setLoading(false);
|
|
304
336
|
return [2 /*return*/];
|
|
305
337
|
}
|
|
306
338
|
});
|
|
307
339
|
}); }, [inputValue, searchParams]);
|
|
308
|
-
function carimbaLista(lista) {
|
|
309
|
-
var completo = [];
|
|
310
|
-
lista.map(function (arr, index) {
|
|
311
|
-
index === 0 && favoritePage && setDados(function (v) { return (__assign(__assign({}, v), { favoritosLength: arr.length })); });
|
|
312
|
-
return arr.map(function (itemArr) { return itemArr.length < 3 && itemArr.push(groupName[index]); });
|
|
313
|
-
});
|
|
314
|
-
lista.forEach(function (v) {
|
|
315
|
-
for (var _i = 0, _a = v.values(); _i < _a.length; _i++) {
|
|
316
|
-
var item = _a[_i];
|
|
317
|
-
completo.push(item);
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
setDados(function (v) { return (__assign(__assign({}, v), { lista: completo })); });
|
|
321
|
-
}
|
|
322
340
|
react_1.useEffect(function () { return buscar(); }, [inputValue, buscar]);
|
|
341
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
323
342
|
react_1.useEffect(function () { return lodash_1.isString(value) && buscar(value); }, []);
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}, renderInput: function (params) { return (react_1.default.createElement(core_1.TextField, __assign({ margin: 'dense', variant: 'outlined', label: label }, params, textFieldProps, { InputProps: __assign(__assign(__assign({}, textFieldProps.InputProps), params.InputProps), { endAdornment: (react_1.default.createElement(react_1.default.Fragment, null,
|
|
343
|
+
console.log('Lista', dados.lista);
|
|
344
|
+
return (react_1.default.createElement(lab_1.Autocomplete, __assign({}, props, { value: value, onChange: onChange }, { 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, 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', onInputChange: function (e) { var _a; return setInputValue(((_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; }, autoComplete: true, autoHighlight: true, openText: 'Abrir', clearText: 'Limpar', filterSelectedOptions: true, renderInput: function (params) { return (react_1.default.createElement(core_1.TextField, __assign({ margin: 'dense', variant: 'outlined', label: label }, params, textFieldProps, { InputProps: __assign(__assign(__assign({}, textFieldProps.InputProps), params.InputProps), { endAdornment: (react_1.default.createElement(react_1.default.Fragment, null,
|
|
327
345
|
params.InputProps.endAdornment,
|
|
328
346
|
react_1.default.createElement(core_1.Fade, { in: loading },
|
|
329
|
-
react_1.default.createElement(core_1.CircularProgress, { disableShrink: true, color: loadingColor || 'inherit', size: 20 })))) }) }))); }
|
|
347
|
+
react_1.default.createElement(core_1.CircularProgress, { disableShrink: true, color: loadingColor || 'inherit', size: 20 })))) }) }))); }, ListboxComponent: ListboxFavorites, ListboxProps: { dados: dados, setDados: setDados, favoritePage: favoritePage, groupHeaderColor: groupHeaderColor, groupTitleColor: groupTitleColor } })));
|
|
330
348
|
};
|
|
331
349
|
exports.default = AutoCompleteFavorites;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from
|
|
1
|
+
export { default } from './AutoCompleteFavorites';
|
|
2
|
+
export * from './AutoCompleteFavorites';
|
|
@@ -145,4 +145,7 @@ export { default as ThreadLog } from './ThreadLog';
|
|
|
145
145
|
export * from './ThreadLog';
|
|
146
146
|
|
|
147
147
|
export { default as UtilAutoComplete } from './UtilAutoComplete';
|
|
148
|
-
export * from './UtilAutoComplete';
|
|
148
|
+
export * from './UtilAutoComplete';
|
|
149
|
+
|
|
150
|
+
export { default as AutoCompleteFavorites } from './AutoCompleteFavorites';
|
|
151
|
+
export * from './AutoCompleteFavorites';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { TextFieldProps } from '@material-ui/core';
|
|
2
|
+
import { AutocompleteProps, AutocompleteChangeDetails } from '@material-ui/lab';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
export interface AutoCompleteFavoritesProps extends Omit<AutocompleteProps<any, false, false, false>, 'getOptionLabel'>{
|
|
6
|
+
/**
|
|
7
|
+
* Valor do campo
|
|
8
|
+
*/
|
|
9
|
+
value?: Array<number|string> | object,
|
|
10
|
+
/**
|
|
11
|
+
* Props repassados ao componente Textfield
|
|
12
|
+
*/
|
|
13
|
+
textFieldProps?: TextFieldProps,
|
|
14
|
+
/**
|
|
15
|
+
* Callback fired when the value changes.
|
|
16
|
+
*
|
|
17
|
+
* @param event — The event source of the callback.
|
|
18
|
+
*
|
|
19
|
+
* @param value — The new value of the component.
|
|
20
|
+
*
|
|
21
|
+
* @param reason — One of "create-option", "select-option", "remove-option", "blur", "clear" ou "only-one-left".
|
|
22
|
+
*/
|
|
23
|
+
onChange?: ((event: React.ChangeEvent<{}>, value: any, reason: 'create-option' | 'select-option' | 'remove-option' | 'blur' | 'clear' | 'only-one-left', details?: AutocompleteChangeDetails<any> | undefined) => void) | undefined,
|
|
24
|
+
/**
|
|
25
|
+
* Formata o valor que aparece na listagem
|
|
26
|
+
*
|
|
27
|
+
* @param option - Opção sendo testada ou selecionada
|
|
28
|
+
*
|
|
29
|
+
* @param lista - Lista com todas as opções
|
|
30
|
+
*/
|
|
31
|
+
getOptionLabel?: ((option: Array<any>, lista: Array<Array<any>>) => string),
|
|
32
|
+
/**
|
|
33
|
+
* Utiliza um pgCode diferente do padrão
|
|
34
|
+
*/
|
|
35
|
+
pgCode?: string,
|
|
36
|
+
/**
|
|
37
|
+
* Objeto de busca personalizado
|
|
38
|
+
*/
|
|
39
|
+
busca?: string,
|
|
40
|
+
/**
|
|
41
|
+
* Objeto de resposta personalizado
|
|
42
|
+
*/
|
|
43
|
+
resposta?: string,
|
|
44
|
+
/**
|
|
45
|
+
* Action personalizada
|
|
46
|
+
*/
|
|
47
|
+
action?: string,
|
|
48
|
+
/**
|
|
49
|
+
* Label do campo
|
|
50
|
+
*/
|
|
51
|
+
label?: string,
|
|
52
|
+
/**
|
|
53
|
+
* Parametros utilizados no metodo de busca
|
|
54
|
+
*/
|
|
55
|
+
searchParams?: object,
|
|
56
|
+
/**
|
|
57
|
+
* Define a cor do loading
|
|
58
|
+
*/
|
|
59
|
+
loadingColor?: string,
|
|
60
|
+
/**
|
|
61
|
+
* Parametro que define se terá paginação
|
|
62
|
+
*/
|
|
63
|
+
favoritePage?: boolean,
|
|
64
|
+
/**
|
|
65
|
+
* Array contendo nome do grupo
|
|
66
|
+
*/
|
|
67
|
+
groupName?: Array<string>,
|
|
68
|
+
/**
|
|
69
|
+
* Array contendo a cor do titulo no grupo
|
|
70
|
+
*/
|
|
71
|
+
groupTitleColor?: Array<string>,
|
|
72
|
+
/**
|
|
73
|
+
* Array contendo o backgroundColor do header no grupo
|
|
74
|
+
*/
|
|
75
|
+
groupHeaderColor?: Array<string>,
|
|
76
|
+
/**
|
|
77
|
+
* Função para filtrar a lista de opções
|
|
78
|
+
*
|
|
79
|
+
* @param valor - Valor setado no componente
|
|
80
|
+
* @param item - Item a ser testado contra o valor
|
|
81
|
+
*
|
|
82
|
+
* @returns {boolean} Retorna true se item de ser removido da lista
|
|
83
|
+
*/
|
|
84
|
+
filterFunction?: (valor: any, item: any) => boolean,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare function AutoCompleteFavorites(props: AutoCompleteFavoritesProps): JSX.Element
|
|
88
|
+
|
|
89
|
+
export default AutoCompleteFavorites;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { serverAction, setError } from '../../utils/api';
|
|
2
|
-
import {
|
|
2
|
+
import { CircularProgress, Fade, 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';
|
|
@@ -89,16 +89,16 @@ const useStyles = makeStyles((theme) => ({
|
|
|
89
89
|
}
|
|
90
90
|
}));
|
|
91
91
|
|
|
92
|
-
const CustomTooltip = withStyles((theme) => ({
|
|
92
|
+
export const CustomTooltip = withStyles((theme) => ({
|
|
93
93
|
tooltip: theme.palette.type === 'light' ? {
|
|
94
94
|
fontSize: 15,
|
|
95
95
|
fontWeight: 400,
|
|
96
|
-
color: '
|
|
96
|
+
color: '#FFF',
|
|
97
97
|
backgroundColor: '#333333e3',
|
|
98
98
|
} : {
|
|
99
99
|
fontSize: 15,
|
|
100
100
|
fontWeight: 400,
|
|
101
|
-
color: '
|
|
101
|
+
color: '#000',
|
|
102
102
|
backgroundColor: '#fbfbfbd1',
|
|
103
103
|
},
|
|
104
104
|
arrow: {
|
|
@@ -112,6 +112,8 @@ const ListboxFavorites = forwardRef((props, ref) => {
|
|
|
112
112
|
const { children, favoritePage, dados, setDados, groupHeaderColor, groupTitleColor } = props;
|
|
113
113
|
const { pageNumber, favoritosLength, direction, slide } = dados;
|
|
114
114
|
|
|
115
|
+
console.log('Listbox', children);
|
|
116
|
+
|
|
115
117
|
function retornaInicio() {
|
|
116
118
|
switch (pageNumber) {
|
|
117
119
|
case 1:
|
|
@@ -200,11 +202,11 @@ const ListboxFavorites = forwardRef((props, ref) => {
|
|
|
200
202
|
<div onClick={e => buttonClick(e, 2)} className={clsx({ [classes.buttonActive]: pageNumber === 2 }, classes.button)}>2</div>
|
|
201
203
|
</div>
|
|
202
204
|
{favoritosLength > 14 &&
|
|
203
|
-
|
|
205
|
+
<React.Fragment>
|
|
204
206
|
<div className={classes.areaButton}>
|
|
205
207
|
<div onClick={e => buttonClick(e, 3)} className={clsx({ [classes.buttonActive]: pageNumber === 3 }, classes.button)}>3</div>
|
|
206
208
|
</div>
|
|
207
|
-
|
|
209
|
+
</React.Fragment>
|
|
208
210
|
}
|
|
209
211
|
</div>
|
|
210
212
|
</Fade>
|
|
@@ -215,7 +217,7 @@ const ListboxFavorites = forwardRef((props, ref) => {
|
|
|
215
217
|
});
|
|
216
218
|
|
|
217
219
|
const AutoCompleteFavorites = ({ action, busca, resposta, label, value, pgCode, favoritePage, groupName, groupHeaderColor, groupTitleColor, loadingColor, filterFunction, getOptionLabel, onChange = e => e, textFieldProps = {}, searchParams, ...props }) => {
|
|
218
|
-
|
|
220
|
+
|
|
219
221
|
const [dados, setDados] = useState({
|
|
220
222
|
lista: [],
|
|
221
223
|
slide: true,
|
|
@@ -226,48 +228,53 @@ const AutoCompleteFavorites = ({ action, busca, resposta, label, value, pgCode,
|
|
|
226
228
|
const [loading, setLoading] = useState(false);
|
|
227
229
|
const [inputValue, setInputValue] = useState('');
|
|
228
230
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const res = await serverAction(action, { [busca]: valor || inputValue, ...searchParams }, true, pgCode);
|
|
232
|
-
if (res[resposta || 'result']?.length > 1) carimbaLista(res[resposta || 'result']);
|
|
233
|
-
else if (res[resposta || 'result']) setDados(v => ({ ...v, lista: res[resposta || 'result'] || [] }));
|
|
234
|
-
else setError('Erro ao tentar buscar dados.');
|
|
235
|
-
setLoading(false);
|
|
236
|
-
}, [inputValue, searchParams]);
|
|
237
|
-
|
|
238
|
-
function carimbaLista(lista) {
|
|
231
|
+
async function carimbaLista(lista) {
|
|
232
|
+
console.log('carimbaLista', lista);
|
|
239
233
|
let completo = [];
|
|
240
234
|
lista.map((arr, index) => {
|
|
241
235
|
index === 0 && favoritePage && setDados(v => ({ ...v, favoritosLength: arr.length }));
|
|
242
|
-
return arr.map(itemArr => itemArr.length <
|
|
236
|
+
return arr.map(itemArr => itemArr.length < itemArr.length + 1 && itemArr.push(groupName[index]));
|
|
243
237
|
});
|
|
244
238
|
lista.forEach(v => {
|
|
245
239
|
for (let item of v.values()) {
|
|
246
240
|
completo.push(item);
|
|
247
241
|
}
|
|
248
242
|
});
|
|
243
|
+
console.log('carimbaLista completo', completo);
|
|
249
244
|
setDados(v => ({ ...v, lista: completo }));
|
|
250
245
|
}
|
|
251
246
|
|
|
247
|
+
const buscar = useCallback(async valor => {
|
|
248
|
+
setLoading(true);
|
|
249
|
+
const res = await serverAction(action, { [busca]: valor || inputValue, ...searchParams }, true, pgCode);
|
|
250
|
+
if (res) console.log('Resposta busca', res);
|
|
251
|
+
if (res[resposta || 'result']?.length > 1) await carimbaLista(res[resposta || 'result']);
|
|
252
|
+
else if (res[resposta || 'result']) setDados({ lista: res[resposta || 'result'] || [] });
|
|
253
|
+
else setError('Erro ao tentar buscar dados.');
|
|
254
|
+
setLoading(false);
|
|
255
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
256
|
+
}, [inputValue, searchParams]);
|
|
257
|
+
|
|
252
258
|
useEffect(() => buscar(), [inputValue, buscar]);
|
|
259
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
253
260
|
useEffect(() => isString(value) && buscar(value), []);
|
|
254
261
|
|
|
262
|
+
console.log('Lista', dados.lista);
|
|
263
|
+
|
|
255
264
|
return (
|
|
256
265
|
<Autocomplete
|
|
266
|
+
{...props}
|
|
267
|
+
{...{ value, onChange }}
|
|
268
|
+
options={isObject(value) ? dados?.lista.filter(v => filterFunction ? filterFunction(v, value) : true || v[0] !== value[0]) : dados?.lista}
|
|
269
|
+
getOptionLabel={getOptionLabel && (option => getOptionLabel(option, dados?.lista))}
|
|
270
|
+
noOptionsText={inputValue.length < 2 ? 'Digite para pesquisar' : 'Não Encontrado'}
|
|
271
|
+
onInputChange={e => setInputValue(e?.target?.value || '')}
|
|
272
|
+
getOptionSelected={(o, v) => o[0] === v}
|
|
257
273
|
autoComplete
|
|
258
274
|
autoHighlight
|
|
259
275
|
openText='Abrir'
|
|
260
276
|
clearText='Limpar'
|
|
261
277
|
filterSelectedOptions
|
|
262
|
-
onInputChange={e => setInputValue(e?.target?.value || '')}
|
|
263
|
-
options={isObject(value) ? dados?.lista.filter(v => filterFunction ? filterFunction(v, value) : true || v[0] !== value[0]) : dados?.lista}
|
|
264
|
-
getOptionLabel={getOptionLabel && (option => getOptionLabel(option, dados?.lista))}
|
|
265
|
-
getOptionSelected={(o, v) => o[0] === v}
|
|
266
|
-
renderTags={(value, getTagProps) =>
|
|
267
|
-
value.map((option, index) => (
|
|
268
|
-
<Chip variant='outlined' size='small' label={option} {...getTagProps({ index })} />
|
|
269
|
-
))
|
|
270
|
-
}
|
|
271
278
|
renderInput={params => (
|
|
272
279
|
<TextField
|
|
273
280
|
margin='dense'
|
|
@@ -279,16 +286,14 @@ const AutoCompleteFavorites = ({ action, busca, resposta, label, value, pgCode,
|
|
|
279
286
|
...textFieldProps.InputProps,
|
|
280
287
|
...params.InputProps,
|
|
281
288
|
endAdornment: (
|
|
282
|
-
|
|
289
|
+
<React.Fragment>
|
|
283
290
|
{params.InputProps.endAdornment}
|
|
284
291
|
<Fade in={loading}><CircularProgress disableShrink color={loadingColor || 'inherit'} size={20} /></Fade>
|
|
285
|
-
|
|
292
|
+
</React.Fragment>
|
|
286
293
|
)
|
|
287
294
|
}}
|
|
288
295
|
/>
|
|
289
296
|
)}
|
|
290
|
-
{...props}
|
|
291
|
-
{...{ value, onChange }}
|
|
292
297
|
ListboxComponent={ListboxFavorites}
|
|
293
298
|
ListboxProps={{ dados, setDados, favoritePage, groupHeaderColor, groupTitleColor }}
|
|
294
299
|
/>
|
|
@@ -145,4 +145,7 @@ export { default as ThreadLog } from './ThreadLog';
|
|
|
145
145
|
export * from './ThreadLog';
|
|
146
146
|
|
|
147
147
|
export { default as UtilAutoComplete } from './UtilAutoComplete';
|
|
148
|
-
export * from './UtilAutoComplete';
|
|
148
|
+
export * from './UtilAutoComplete';
|
|
149
|
+
|
|
150
|
+
export { default as AutoCompleteFavorites } from './AutoCompleteFavorites';
|
|
151
|
+
export * from './AutoCompleteFavorites';
|