argous 1.2.156 → 1.2.157

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.
@@ -31,9 +31,13 @@ export interface ArgousComplexTableProps extends ArgousComplexTableBodyProps, Ar
31
31
  */
32
32
  footerProps?: object,
33
33
  /**
34
- * Array de dados fornecido paa a tabela
34
+ * Array de dados fornecido para a tabela
35
35
  */
36
36
  dados?: Array<Array<any> | Object>,
37
+ /**
38
+ * Objeto com parâmetros para controle de paginação pelo backend
39
+ */
40
+ paginationControl?: Object,
37
41
  /**
38
42
  * Número de linhas padrão por página
39
43
  */
@@ -148,6 +148,9 @@ var useStyles = core_1.makeStyles(function (theme) { return ({
148
148
  background: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.05)' : 'rgba(255, 255, 255, 0.08)'
149
149
  }
150
150
  },
151
+ hoverListItem: {
152
+ background: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.05)' : 'rgba(255, 255, 255, 0.08)'
153
+ },
151
154
  listItemText: {
152
155
  margin: 0,
153
156
  width: '100%',
@@ -178,7 +181,7 @@ var useStyles = core_1.makeStyles(function (theme) { return ({
178
181
  }
179
182
  },
180
183
  popper: {
181
- zIndex: 1301,
184
+ zIndex: 1300,
182
185
  width: function (_a) {
183
186
  var widthListBox = _a.widthListBox;
184
187
  return widthListBox ? "" + widthListBox + (testWidth(widthListBox.toString()) ? 'px' : '') + " !important" : '';
@@ -206,7 +209,7 @@ exports.CustomTooltip = core_1.withStyles(function (theme) { return ({
206
209
  var ListboxFavorites = react_1.forwardRef(function (props, ref) {
207
210
  var classes = useStyles();
208
211
  var children = props.children, favoritePage = props.favoritePage, dados = props.dados, setDados = props.setDados, group = props.group, groupHeaderColor = props.groupHeaderColor, groupTitleColor = props.groupTitleColor;
209
- var pageNumber = dados.pageNumber, favoritosLength = dados.favoritosLength, direction = dados.direction, slide = dados.slide;
212
+ var pageNumber = dados.pageNumber, favoritosLength = dados.favoritosLength, direction = dados.direction, slide = dados.slide, cursor = dados.cursor;
210
213
  function retornaInicio() {
211
214
  switch (pageNumber) {
212
215
  case 1:
@@ -234,16 +237,15 @@ var ListboxFavorites = react_1.forwardRef(function (props, ref) {
234
237
  return section.props.children[1].props.children.slice(retornaInicio(), retornaFim());
235
238
  return section.props.children[1].props.children;
236
239
  }
237
- function retornaEstrutura(sectionIndex, item) {
240
+ function retornaEstrutura(sectionIndex, item, itemIndex) {
241
+ var _a;
242
+ var content = 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 } } },
243
+ react_1.default.createElement(core_1.ListItem, __assign({}, item.props, { id: 'listItem', key: item.key, className: clsx_1.default(classes.listItem, (_a = {}, _a[classes.hoverListItem] = cursor.index === itemIndex && cursor.page === pageNumber, _a)) }),
244
+ react_1.default.createElement(core_1.ListItemText, { primary: item.props.children, className: classes.listItemText })));
238
245
  if (sectionIndex === 0 && favoritePage && favoritosLength > 7) {
239
- return (react_1.default.createElement(core_1.Slide, { in: slide, direction: direction },
240
- 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 } } },
241
- react_1.default.createElement(core_1.ListItem, __assign({}, item.props, { key: item.key, className: classes.listItem }),
242
- react_1.default.createElement(core_1.ListItemText, { primary: item.props.children, className: classes.listItemText })))));
246
+ return react_1.default.createElement(core_1.Slide, { in: slide, direction: direction }, content);
243
247
  }
244
- 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 } } },
245
- react_1.default.createElement(core_1.ListItem, __assign({}, item.props, { key: item.key, className: classes.listItem }),
246
- react_1.default.createElement(core_1.ListItemText, { primary: item.props.children, className: classes.listItemText }))));
248
+ return content;
247
249
  }
248
250
  function buttonClick(evento, value) {
249
251
  evento.preventDefault();
@@ -288,7 +290,7 @@ var ListboxFavorites = react_1.forwardRef(function (props, ref) {
288
290
  react_1.default.createElement(react_1.default.Fragment, null,
289
291
  react_1.default.createElement("div", { className: classes.areaButton },
290
292
  react_1.default.createElement("div", { onClick: function (e) { return buttonClick(e, 3); }, className: clsx_1.default((_c = {}, _c[classes.buttonActive] = pageNumber === 3, _c), classes.button) }, "3")))))),
291
- retornaArray(sectionIndex, section).map(function (item, itemIndex) { return retornaEstrutura(sectionIndex, item); }))
293
+ retornaArray(sectionIndex, section).map(function (item, itemIndex) { return retornaEstrutura(sectionIndex, item, itemIndex); }))
292
294
  : retornaEstrutura(sectionIndex, section)));
293
295
  }));
294
296
  });
@@ -298,6 +300,7 @@ var AutoCompleteFavorites = function (_a) {
298
300
  var _d = react_1.useState({
299
301
  lista: [],
300
302
  slide: true,
303
+ cursor: { index: '', page: '' },
301
304
  direction: '',
302
305
  favoritosLength: '',
303
306
  pageNumber: favoritePage ? 1 : '',
@@ -365,7 +368,48 @@ var AutoCompleteFavorites = function (_a) {
365
368
  react_1.useEffect(function () { return autoSearch && seconds === 1 && buscar(); }, [autoSearch, seconds, buscar]);
366
369
  // eslint-disable-next-line react-hooks/exhaustive-deps
367
370
  react_1.useEffect(function () { return lodash_1.isString(value) && buscar(value); }, []);
368
- 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,
371
+ react_1.useEffect(function () { var _a; return (value === null || value === void 0 ? void 0 : value[3]) !== ((_a = dados.cursor.linha) === null || _a === void 0 ? void 0 : _a[3]) && setDados(function (v) { return (__assign(__assign({}, v), { cursor: { index: '', page: '' } })); }); }, [value, dados.cursor.linha]);
372
+ var keyUp = function (e) {
373
+ e.preventDefault();
374
+ e.stopPropagation();
375
+ ((e.key === 'Enter' || e.key === 'Tab') && !loading) && buscar();
376
+ (e.key === 'ArrowDown' || e.key === 'ArrowUp') && selectListboxItem(e.key);
377
+ };
378
+ var keyDown = function (e) { return (e.key === 'Enter' || e.key === 'Tab') && e.stopPropagation(); };
379
+ function selectListboxItem(key) {
380
+ var _a;
381
+ var directionIndex = key === 'ArrowDown' ? 1 : key === 'ArrowUp' ? -1 : 0;
382
+ var itens = document.querySelectorAll('#listItem');
383
+ var array = Array.from(itens);
384
+ var el = '';
385
+ var indexCapture = 0;
386
+ if (!value)
387
+ el = array === null || array === void 0 ? void 0 : array[0];
388
+ else {
389
+ array.forEach(function (v, i) {
390
+ var elInnerText = v.innerText;
391
+ var endIndexCode = elInnerText.indexOf('-') - 1;
392
+ var code = elInnerText.substring(0, endIndexCode);
393
+ if (code === value[3]) {
394
+ var nextIndex = i + directionIndex;
395
+ if (nextIndex < array.length)
396
+ indexCapture = nextIndex > -1 ? nextIndex : i;
397
+ else
398
+ indexCapture = i;
399
+ }
400
+ });
401
+ el = array[indexCapture];
402
+ }
403
+ var elInnerText = el.innerText;
404
+ var endIndexCode = elInnerText.indexOf('-') - 1;
405
+ var code = elInnerText.substring(0, endIndexCode);
406
+ var linha = (_a = dados.lista.map(function (v) { return v[3] === code && v; }).filter(function (v) { return v && v; })) === null || _a === void 0 ? void 0 : _a[0];
407
+ setDados(function (v) { return (__assign(__assign({}, v), { cursor: { index: indexCapture, page: v.pageNumber, linha: linha } })); });
408
+ if (linha !== value)
409
+ invokeOnChange('', linha);
410
+ }
411
+ var invokeOnChange = onChange;
412
+ return (react_1.default.createElement(lab_1.Autocomplete, __assign({}, props, { value: value }, { onChange: invokeOnChange, 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 keyUp(e); }, inputProps: __assign(__assign({}, params.inputProps), { onKeyDown: function (e) { return keyDown(e); } }), InputProps: __assign(__assign(__assign({}, textFieldProps.InputProps), params.InputProps), { endAdornment: (react_1.default.createElement(react_1.default.Fragment, null,
369
413
  params.InputProps.endAdornment,
370
414
  react_1.default.createElement(core_1.Fade, { in: loading },
371
415
  react_1.default.createElement(core_1.CircularProgress, { disableShrink: true, color: loadingColor || 'inherit', size: 20 })),
@@ -31,9 +31,13 @@ export interface ArgousComplexTableProps extends ArgousComplexTableBodyProps, Ar
31
31
  */
32
32
  footerProps?: object,
33
33
  /**
34
- * Array de dados fornecido paa a tabela
34
+ * Array de dados fornecido para a tabela
35
35
  */
36
36
  dados?: Array<Array<any> | Object>,
37
+ /**
38
+ * Objeto com parâmetros para controle de paginação pelo backend
39
+ */
40
+ paginationControl?: Object,
37
41
  /**
38
42
  * Número de linhas padrão por página
39
43
  */
@@ -66,6 +66,9 @@ const useStyles = makeStyles((theme) => ({
66
66
  background: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.05)' : 'rgba(255, 255, 255, 0.08)'
67
67
  }
68
68
  },
69
+ hoverListItem: {
70
+ background: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.05)' : 'rgba(255, 255, 255, 0.08)'
71
+ },
69
72
  listItemText: {
70
73
  margin: 0,
71
74
  width: '100%',
@@ -96,7 +99,7 @@ const useStyles = makeStyles((theme) => ({
96
99
  }
97
100
  },
98
101
  popper: {
99
- zIndex: 1301,
102
+ zIndex: 1300,
100
103
  width: ({ widthListBox }) => widthListBox ? `${widthListBox}${testWidth(widthListBox.toString()) ? 'px' : ''} !important` : '',
101
104
  }
102
105
  }));
@@ -126,7 +129,7 @@ const ListboxFavorites = forwardRef((props, ref) => {
126
129
 
127
130
  const classes = useStyles();
128
131
  const { children, favoritePage, dados, setDados, group, groupHeaderColor, groupTitleColor } = props;
129
- const { pageNumber, favoritosLength, direction, slide } = dados;
132
+ const { pageNumber, favoritosLength, direction, slide, cursor } = dados;
130
133
 
131
134
  function retornaInicio() {
132
135
  switch (pageNumber) {
@@ -157,24 +160,17 @@ const ListboxFavorites = forwardRef((props, ref) => {
157
160
  return section.props.children[1].props.children;
158
161
  }
159
162
 
160
- function retornaEstrutura(sectionIndex, item) {
163
+ function retornaEstrutura(sectionIndex, item, itemIndex) {
164
+ const content = <CustomTooltip title={item.props.children} arrow enterDelay='1000' enterNextDelay='1000' placement='top-end' TransitionComponent={Fade} TransitionProps={{ timeout: { enter: 100, exit: 500 } }}>
165
+ <ListItem {...item.props} id='listItem' key={item.key} className={clsx(classes.listItem, { [classes.hoverListItem]: cursor.index === itemIndex && cursor.page === pageNumber })}>
166
+ <ListItemText primary={item.props.children} className={classes.listItemText} />
167
+ </ListItem>
168
+ </CustomTooltip>;
161
169
  if (sectionIndex === 0 && favoritePage && favoritosLength > 7) {
162
- return (
163
- <Slide in={slide} direction={direction}>
164
- <CustomTooltip title={item.props.children} arrow enterDelay='1000' enterNextDelay='1000' placement='top-end' TransitionComponent={Fade} TransitionProps={{ timeout: { enter: 100, exit: 500 } }}>
165
- <ListItem {...item.props} key={item.key} className={classes.listItem}>
166
- <ListItemText primary={item.props.children} className={classes.listItemText} />
167
- </ListItem>
168
- </CustomTooltip>
169
- </Slide>
170
- );
171
- } return (
172
- <CustomTooltip title={item.props.children} arrow enterDelay='1000' enterNextDelay='1000' placement='top-end' TransitionComponent={Fade} TransitionProps={{ timeout: { enter: 100, exit: 500 } }}>
173
- <ListItem {...item.props} key={item.key} className={classes.listItem}>
174
- <ListItemText primary={item.props.children} className={classes.listItemText} />
175
- </ListItem>
176
- </CustomTooltip>
177
- );
170
+ return <Slide in={slide} direction={direction}>
171
+ {content}
172
+ </Slide>;
173
+ } return content;
178
174
  }
179
175
 
180
176
  function buttonClick(evento, value) {
@@ -219,16 +215,16 @@ const ListboxFavorites = forwardRef((props, ref) => {
219
215
  <div onClick={e => buttonClick(e, 2)} className={clsx({ [classes.buttonActive]: pageNumber === 2 }, classes.button)}>2</div>
220
216
  </div>
221
217
  {favoritosLength > 14 &&
222
- <React.Fragment>
223
- <div className={classes.areaButton}>
224
- <div onClick={e => buttonClick(e, 3)} className={clsx({ [classes.buttonActive]: pageNumber === 3 }, classes.button)}>3</div>
225
- </div>
226
- </React.Fragment>
218
+ <React.Fragment>
219
+ <div className={classes.areaButton}>
220
+ <div onClick={e => buttonClick(e, 3)} className={clsx({ [classes.buttonActive]: pageNumber === 3 }, classes.button)}>3</div>
221
+ </div>
222
+ </React.Fragment>
227
223
  }
228
224
  </div>
229
225
  </Fade>
230
226
  </ListSubheader>
231
- {retornaArray(sectionIndex, section).map((item, itemIndex) => retornaEstrutura(sectionIndex, item))}
227
+ {retornaArray(sectionIndex, section).map((item, itemIndex) => retornaEstrutura(sectionIndex, item, itemIndex))}
232
228
  </React.Fragment>
233
229
  : retornaEstrutura(sectionIndex, section)
234
230
  }
@@ -243,6 +239,7 @@ const AutoCompleteFavorites = ({ action, busca, resposta, autoSearch, label, val
243
239
  const [dados, setDados] = useState({
244
240
  lista: [],
245
241
  slide: true,
242
+ cursor: { index: '', page: '' },
246
243
  direction: '',
247
244
  favoritosLength: '',
248
245
  pageNumber: favoritePage ? 1 : '',
@@ -291,10 +288,52 @@ const AutoCompleteFavorites = ({ action, busca, resposta, autoSearch, label, val
291
288
  // eslint-disable-next-line react-hooks/exhaustive-deps
292
289
  useEffect(() => isString(value) && buscar(value), []);
293
290
 
291
+ useEffect(() => value?.[3] !== dados.cursor.linha?.[3] && setDados(v => ({ ...v, cursor: { index: '', page: '' } })), [value, dados.cursor.linha]);
292
+
293
+ const keyUp = e => {
294
+ e.preventDefault();
295
+ e.stopPropagation();
296
+ ((e.key === 'Enter' || e.key === 'Tab') && !loading) && buscar();
297
+ (e.key === 'ArrowDown' || e.key === 'ArrowUp') && selectListboxItem(e.key);
298
+ };
299
+
300
+ const keyDown = e => (e.key === 'Enter' || e.key === 'Tab') && e.stopPropagation();
301
+
302
+ function selectListboxItem(key) {
303
+ const directionIndex = key === 'ArrowDown' ? 1 : key === 'ArrowUp' ? -1 : 0;
304
+ const itens = document.querySelectorAll('#listItem');
305
+ const array = Array.from(itens);
306
+ let el = '';
307
+ let indexCapture = 0;
308
+ if (!value) el = array?.[0];
309
+ else {
310
+ array.forEach((v, i) => {
311
+ const elInnerText = v.innerText;
312
+ const endIndexCode = elInnerText.indexOf('-') - 1;
313
+ const code = elInnerText.substring(0, endIndexCode);
314
+ if (code === value[3]) {
315
+ const nextIndex = i + directionIndex;
316
+ if (nextIndex < array.length) indexCapture = nextIndex > -1 ? nextIndex : i;
317
+ else indexCapture = i;
318
+ }
319
+ });
320
+ el = array[indexCapture];
321
+ }
322
+ const elInnerText = el.innerText;
323
+ const endIndexCode = elInnerText.indexOf('-') - 1;
324
+ const code = elInnerText.substring(0, endIndexCode);
325
+ const linha = dados.lista.map(v => v[3] === code && v).filter(v => v && v)?.[0];
326
+ setDados(v => ({ ...v, cursor: { index: indexCapture, page: v.pageNumber, linha: linha } }));
327
+ if (linha !== value) invokeOnChange('', linha);
328
+ }
329
+
330
+ const invokeOnChange = onChange;
331
+
294
332
  return (
295
333
  <Autocomplete
296
334
  {...props}
297
- {...{ value, onChange }}
335
+ {...{ value }}
336
+ onChange={invokeOnChange}
298
337
  autoComplete
299
338
  autoHighlight
300
339
  openText='Abrir'
@@ -312,10 +351,10 @@ const AutoCompleteFavorites = ({ action, busca, resposta, autoSearch, label, val
312
351
  label={label}
313
352
  {...params}
314
353
  {...textFieldProps}
315
- onKeyUp={e => ((e.key === 'Enter' || e.key === 'Tab') && !loading) && buscar()}
354
+ onKeyUp={e => keyUp(e)}
316
355
  inputProps={{
317
356
  ...params.inputProps,
318
- onKeyDown: e => (e.key === 'Enter' || e.key === 'Tab') && e.stopPropagation()
357
+ onKeyDown: e => keyDown(e)
319
358
  }}
320
359
  InputProps={{
321
360
  ...textFieldProps.InputProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.156",
3
+ "version": "1.2.157",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",