@ssplib/react-components 0.0.106 → 0.0.107

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.
@@ -115,11 +115,13 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
115
115
  };
116
116
  (0, react_1.useEffect)(() => {
117
117
  const dt = new DataTransfer();
118
- files.forEach((x) => {
118
+ files
119
+ .filter((x) => !filesError.includes(x.id))
120
+ .forEach((x) => {
119
121
  dt.items.add(x.file);
120
122
  });
121
123
  context === null || context === void 0 ? void 0 : context.formSetValue(name, dt.files);
122
- }, [files, context, name]);
124
+ }, [files, context, filesError, name]);
123
125
  (0, react_1.useEffect)(() => {
124
126
  return () => {
125
127
  context.setFilesUid((files) => files.filter((x) => x.CO_TIPO_ARQUIVO !== parseInt(tipoArquivo)));
@@ -130,12 +132,14 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
130
132
  react_1.default.createElement(material_1.Box, { sx: { backgroundColor: '#e2eafc', padding: 1, borderRadius: 1, marginTop: 1 } },
131
133
  react_1.default.createElement("input", Object.assign({ id: name, type: 'file', multiple: multiple }, context === null || context === void 0 ? void 0 : context.formRegister(name, {
132
134
  validate: (v, f) => {
135
+ console.log('dsadsadas 1');
133
136
  if (v.length <= 0 && required)
134
137
  return 'O campo de arquivo é obrigatório';
135
138
  },
136
139
  }), { onChange: onFile, accept: '.pdf', style: { display: 'none' } })),
137
140
  react_1.default.createElement("input", Object.assign({ id: name + 'foto', type: 'file', capture: 'environment', multiple: multiple }, context === null || context === void 0 ? void 0 : context.formRegister(name, {
138
141
  validate: (v, f) => {
142
+ console.log('dsadsadas 2');
139
143
  if (v.length <= 0 && required)
140
144
  return 'O campo de arquivo é obrigatório';
141
145
  },
@@ -155,7 +159,6 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
155
159
  files.length,
156
160
  " arquivo",
157
161
  files.length > 1 && 's'),
158
- (0, lodash_get_1.default)(context === null || context === void 0 ? void 0 : context.errors, name) && (react_1.default.createElement(material_1.Typography, { variant: 'caption', sx: { color: '#e53935' } }, "* O campo de arquivo \u00E9 obrigat\u00F3rio")),
159
162
  files.length > 0 && (react_1.default.createElement(material_1.TableContainer, { component: material_1.Paper },
160
163
  react_1.default.createElement(system_1.Stack, { direction: 'column' }, files.map((x) => (react_1.default.createElement(system_1.Stack, { key: x.name, direction: 'row', justifyContent: 'space-between', padding: 0.5 },
161
164
  react_1.default.createElement(material_1.Box, null,
@@ -163,6 +166,7 @@ function FileUpload({ name, tipoArquivo, title, required = false, multiple = fal
163
166
  filesLoaded.includes(x.id) ? (react_1.default.createElement(Done_1.default, { sx: { fill: '#06d6a0' } })) : filesError.includes(x.id) ? (react_1.default.createElement(Clear_1.default, { sx: { fill: 'red' } })) : (react_1.default.createElement(material_1.CircularProgress, { size: 22, sx: { color: 'black' } })),
164
167
  react_1.default.createElement(PictureAsPdf_1.default, { color: 'error' }),
165
168
  react_1.default.createElement(material_1.Typography, { fontWeight: 600 }, x.name))),
166
- react_1.default.createElement(material_1.Box, null, (filesLoaded.includes(x.id) || filesError.includes(x.id)) && (react_1.default.createElement(material_1.Button, { variant: 'contained', size: 'small', sx: { textTransform: 'none', backgroundColor: '#d1495b', '&:hover': { backgroundColor: '#c1121f' } }, onClick: (e) => deleteFile(e, x.id), startIcon: react_1.default.createElement(Delete_1.default, null) }, "Remover"))))))))))));
169
+ react_1.default.createElement(material_1.Box, null, (filesLoaded.includes(x.id) || filesError.includes(x.id)) && (react_1.default.createElement(material_1.Button, { variant: 'contained', size: 'small', sx: { textTransform: 'none', backgroundColor: '#d1495b', '&:hover': { backgroundColor: '#c1121f' } }, onClick: (e) => deleteFile(e, x.id), startIcon: react_1.default.createElement(Delete_1.default, null) }, "Remover"))))))))),
170
+ (0, lodash_get_1.default)(context === null || context === void 0 ? void 0 : context.errors, name) && (react_1.default.createElement(material_1.Typography, { variant: 'caption', color: '#e53935', fontWeight: 600, fontSize: 14, paddingTop: 2 }, "* O campo de arquivo \u00E9 obrigat\u00F3rio")))));
167
171
  }
168
172
  exports.default = FileUpload;
@@ -206,12 +206,10 @@ function Table({ columns, fetchFunc, emptyMsg = {
206
206
  });
207
207
  const csvData = header + values.join('\n');
208
208
  // download
209
- const a = document.createElement('a');
210
- a.href = 'data:text/csv;charset=utf-8,' + csvData;
211
- a.download = `${csv === null || csv === void 0 ? void 0 : csv.fileName}.csv`;
212
- document.body.appendChild(a);
213
- a.click();
214
- document.body.removeChild(a);
209
+ var link = window.document.createElement('a');
210
+ link.setAttribute('href', 'data:text/csv;charset=utf-8,%EF%BB%BF' + encodeURI(csvData));
211
+ link.setAttribute('download', `${csv === null || csv === void 0 ? void 0 : csv.fileName}.csv`);
212
+ link.click();
215
213
  }, [list]);
216
214
  const downloadCSVAll = (0, react_1.useCallback)((e) => {
217
215
  e.preventDefault();
@@ -236,12 +234,10 @@ function Table({ columns, fetchFunc, emptyMsg = {
236
234
  .join('\n');
237
235
  const csvData = header + values;
238
236
  // download
239
- const a = document.createElement('a');
240
- a.href = 'data:text/csv;charset=utf-8,' + csvData;
241
- a.download = `${csv === null || csv === void 0 ? void 0 : csv.fileName}.csv`;
242
- document.body.appendChild(a);
243
- a.click();
244
- document.body.removeChild(a);
237
+ var link = window.document.createElement('a');
238
+ link.setAttribute('href', 'data:text/csv;charset=utf-8,%EF%BB%BF' + encodeURI(csvData));
239
+ link.setAttribute('download', `${csv === null || csv === void 0 ? void 0 : csv.fileName}.csv`);
240
+ link.click();
245
241
  }, [list]);
246
242
  const getStatusMsg = (0, react_1.useCallback)((cod) => {
247
243
  switch (cod) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.106",
3
+ "version": "0.0.107",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",