@ssplib/react-components 0.0.278 → 0.0.280
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.
|
@@ -74,7 +74,7 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
74
74
|
const theme = (0, material_1.useTheme)();
|
|
75
75
|
const isSmall = (0, material_1.useMediaQuery)(theme.breakpoints.only('xs'));
|
|
76
76
|
const startData = (0, react_1.useRef)(data);
|
|
77
|
-
const orderAsc = (0, react_1.useRef)(false);
|
|
77
|
+
const orderAsc = (0, react_1.useRef)((localStorage.getItem(`order-${id}`) === 'true') || false);
|
|
78
78
|
const lg = (0, material_1.useMediaQuery)(theme.breakpoints.up(2000));
|
|
79
79
|
localTableName = `tableFilter_${id}`;
|
|
80
80
|
localTableNameCache = `tableFilterCache_${id}`;
|
|
@@ -116,8 +116,31 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
116
116
|
startData.current = [];
|
|
117
117
|
}
|
|
118
118
|
else {
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
let newValue = value;
|
|
120
|
+
// começando a ordenação padrão
|
|
121
|
+
if (localStorage.getItem(`order-data-${id}`)) {
|
|
122
|
+
try {
|
|
123
|
+
const orderData = JSON.parse(localStorage.getItem(`order-data-${id}`));
|
|
124
|
+
newValue = (0, utils_1.ordenarDados)({
|
|
125
|
+
order: orderData,
|
|
126
|
+
list: value,
|
|
127
|
+
orderAsc: orderAsc.current,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
console.log(err);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (orderBy.length > 0) {
|
|
135
|
+
// se não tiver salvo uma ordenação, ordena pelo primeiro da lista
|
|
136
|
+
newValue = (0, utils_1.ordenarDados)({
|
|
137
|
+
order: orderBy[0],
|
|
138
|
+
list: value,
|
|
139
|
+
orderAsc: orderAsc.current,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
setData(newValue);
|
|
143
|
+
startData.current = JSON.parse(JSON.stringify(newValue));
|
|
121
144
|
}
|
|
122
145
|
}
|
|
123
146
|
setIsLoading(false);
|
|
@@ -139,7 +162,7 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
139
162
|
(0, react_1.useEffect)(() => {
|
|
140
163
|
if (isLoading || error || !getData(data))
|
|
141
164
|
return;
|
|
142
|
-
|
|
165
|
+
let value = getData(data);
|
|
143
166
|
setList(value);
|
|
144
167
|
setListClone(value);
|
|
145
168
|
setPagCount((0, utils_1.getCount)(value, itemsCount));
|
|
@@ -313,13 +336,15 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
313
336
|
});
|
|
314
337
|
};
|
|
315
338
|
const handleOrdenarDados = (x) => {
|
|
339
|
+
/** Inverter a ordem de ordenação no segundo clique */
|
|
340
|
+
orderAsc.current = !orderAsc.current;
|
|
316
341
|
const dadosOrdenados = (0, utils_1.ordenarDados)({
|
|
317
342
|
order: x,
|
|
318
343
|
list,
|
|
319
344
|
orderAsc: orderAsc.current,
|
|
320
345
|
});
|
|
321
|
-
|
|
322
|
-
|
|
346
|
+
localStorage.setItem(`order-${id}`, orderAsc.current.toString());
|
|
347
|
+
localStorage.setItem(`order-data-${id}`, JSON.stringify(x));
|
|
323
348
|
setList(dadosOrdenados);
|
|
324
349
|
};
|
|
325
350
|
if (error)
|
|
@@ -353,7 +378,7 @@ function Table({ mediaQueryLG, columns, fetchFunc, emptyMsg = {
|
|
|
353
378
|
react_1.default.createElement(material_1.Stack, { direction: 'row', borderRadius: 5, padding: 0 },
|
|
354
379
|
react_1.default.createElement("span", null, "Filtrar"))),
|
|
355
380
|
react_1.default.createElement(material_1.Stack, { direction: 'row', spacing: 1 },
|
|
356
|
-
react_1.default.createElement(CustomMenu_1.default, { data: orderBy.map((x) => ({
|
|
381
|
+
orderBy.length > 0 && react_1.default.createElement(CustomMenu_1.default, { data: orderBy.map((x) => ({
|
|
357
382
|
name: x.label,
|
|
358
383
|
onClick: () => handleOrdenarDados(x),
|
|
359
384
|
})), btProps: {
|
|
@@ -124,7 +124,7 @@ export interface TableProps {
|
|
|
124
124
|
/** Usa autenticação via Keycloak */
|
|
125
125
|
useKC?: boolean;
|
|
126
126
|
/** Dados iniciais da tabela */
|
|
127
|
-
initialData
|
|
127
|
+
initialData?: Array<{
|
|
128
128
|
[key: string]: any;
|
|
129
129
|
}> | null;
|
|
130
130
|
/** Flag de carregamento dos dados da tabela */
|
|
@@ -28,7 +28,7 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
28
28
|
const form_1 = require("../../context/form");
|
|
29
29
|
const react_toastify_1 = require("react-toastify");
|
|
30
30
|
function FormProvider({ children, onSubmit, formMethod = 'GET', submiting = false }) {
|
|
31
|
-
const { register, handleSubmit, control, formState
|
|
31
|
+
const { register, handleSubmit, control, formState, reset, watch, trigger, setValue, unregister, getValues } = (0, react_hook_form_1.useForm)();
|
|
32
32
|
const [filesUid, setFilesUid] = (0, react_1.useState)([]);
|
|
33
33
|
return (react_1.default.createElement(form_1.FormContext.Provider, { value: {
|
|
34
34
|
formRegister: register,
|
|
@@ -41,7 +41,8 @@ function FormProvider({ children, onSubmit, formMethod = 'GET', submiting = fals
|
|
|
41
41
|
formGetValues: getValues,
|
|
42
42
|
formHandleSubmit: handleSubmit,
|
|
43
43
|
setFilesUid: setFilesUid,
|
|
44
|
-
|
|
44
|
+
formState: formState,
|
|
45
|
+
errors: formState === null || formState === void 0 ? void 0 : formState.errors,
|
|
45
46
|
submiting: submiting,
|
|
46
47
|
} },
|
|
47
48
|
react_1.default.createElement("form", { method: formMethod, onSubmit: handleSubmit((data) => onSubmit(data, filesUid), () => (0, react_toastify_1.toast)('Formulário incompleto! Verifique os campos marcados e tente novamente.', {
|
package/context/form.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { Control, FieldErrors, FieldValues, UseFormGetValues, UseFormHandleSubmit, UseFormRegister, UseFormReset, UseFormSetValue, UseFormTrigger, UseFormUnregister, UseFormWatch } from 'react-hook-form';
|
|
2
|
+
import { Control, FieldErrors, FieldValues, UseFormGetValues, UseFormHandleSubmit, UseFormRegister, UseFormReset, UseFormSetValue, UseFormStateReturn, UseFormTrigger, UseFormUnregister, UseFormWatch } from 'react-hook-form';
|
|
3
3
|
export declare const FormContext: import("react").Context<{
|
|
4
4
|
formRegister: UseFormRegister<FieldValues>;
|
|
5
5
|
formWatch: UseFormWatch<FieldValues>;
|
|
@@ -14,6 +14,7 @@ export declare const FormContext: import("react").Context<{
|
|
|
14
14
|
CO_SEQ_ARQUIVO: number;
|
|
15
15
|
CO_TIPO_ARQUIVO: number;
|
|
16
16
|
}[]>>;
|
|
17
|
+
formState: UseFormStateReturn<FieldValues>;
|
|
17
18
|
errors: FieldErrors<FieldValues>;
|
|
18
19
|
submiting: boolean;
|
|
19
20
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssplib/react-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.280",
|
|
4
4
|
"description": "SSP React Components",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Pedro Henrique <sr.hudrick@gmail.com>",
|
|
@@ -36,9 +36,15 @@
|
|
|
36
36
|
"type": "git",
|
|
37
37
|
"url": "git+https://github.com/SSPDF/ssp-components.git"
|
|
38
38
|
},
|
|
39
|
-
"keywords": [
|
|
39
|
+
"keywords": [
|
|
40
|
+
"front",
|
|
41
|
+
"react",
|
|
42
|
+
"components",
|
|
43
|
+
"ssp",
|
|
44
|
+
"df"
|
|
45
|
+
],
|
|
40
46
|
"bugs": {
|
|
41
47
|
"url": "https://github.com/SSPDF/ssp-components/issues"
|
|
42
48
|
},
|
|
43
49
|
"homepage": "https://github.com/SSPDF/ssp-components#readme"
|
|
44
|
-
}
|
|
50
|
+
}
|