@experium/findy-form 1.2.50 → 1.2.53

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.
@@ -35,8 +35,6 @@ var _reactI18next = require("react-i18next");
35
35
 
36
36
  var _getusermedia = _interopRequireDefault(require("getusermedia"));
37
37
 
38
- var _axios = _interopRequireDefault(require("axios"));
39
-
40
38
  var _withFieldWrapper = _interopRequireDefault(require("../hocs/withFieldWrapper"));
41
39
 
42
40
  var _ImageFile = _interopRequireDefault(require("./ImageFile"));
@@ -185,7 +183,6 @@ var File = /*#__PURE__*/function (_Component) {
185
183
  var validFileType = (0, _validation.checkFileType)(type, file.type, fileExtenstion, allowFileExtensions);
186
184
  fd.append('file', file);
187
185
  fd.append('name', file.name);
188
- fd.append('mimetype', fileType);
189
186
 
190
187
  if (validFileType) {
191
188
  _this.setState({
@@ -194,13 +191,16 @@ var File = /*#__PURE__*/function (_Component) {
194
191
  });
195
192
 
196
193
  setInputError(undefined);
197
-
198
- _axios["default"].post(postFileUrl, fd, {
199
- headers: {
200
- 'Content-Type': 'multipart/form-data'
201
- }
194
+ fetch(postFileUrl, {
195
+ method: 'POST',
196
+ body: fd
202
197
  }).then(function (response) {
203
- var data = response.data;
198
+ if (!response.ok && response.status !== 400) {
199
+ throw new Error();
200
+ } else {
201
+ return response.json();
202
+ }
203
+ }).then(function (data) {
204
204
  var name = _this.props.input.name;
205
205
  var fileName = data.filename;
206
206
 
@@ -249,7 +249,7 @@ var File = /*#__PURE__*/function (_Component) {
249
249
  onChange(fileItem);
250
250
  }
251
251
  })["catch"](function (error) {
252
- setInputError((0, _file.getFileErrorText)((0, _ramda.pathOr)('', ['response', 'data', 'message'], error)));
252
+ setInputError((0, _file.getFileErrorText)(error));
253
253
 
254
254
  _this.setState({
255
255
  error: true
@@ -285,7 +285,6 @@ var File = /*#__PURE__*/function (_Component) {
285
285
  }
286
286
  });
287
287
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (e) {
288
- console.log(e, e.target);
289
288
  var file = e.target.files[0];
290
289
 
291
290
  _this.onSave(file);
@@ -422,6 +421,7 @@ var File = /*#__PURE__*/function (_Component) {
422
421
  var _this$state = this.state,
423
422
  loading = _this$state.loading,
424
423
  error = _this$state.error;
424
+ var isLoading = loading && !error;
425
425
  return /*#__PURE__*/_react["default"].createElement("div", {
426
426
  id: "".concat(name, "-file")
427
427
  }, !(0, _ramda.isEmpty)(value) && /*#__PURE__*/_react["default"].createElement("div", {
@@ -453,16 +453,17 @@ var File = /*#__PURE__*/function (_Component) {
453
453
  className: styles.fileInput,
454
454
  id: name,
455
455
  type: "file",
456
+ value: "",
456
457
  onChange: this.onChange,
457
458
  accept: this.getAccept(type),
458
- disabled: disabled || loading && !error
459
+ disabled: disabled || isLoading
459
460
  }), /*#__PURE__*/_react["default"].createElement("label", {
460
461
  htmlFor: name,
461
462
  className: "".concat(disabled ? 'disabled' : '')
462
- }, loading && !error && /*#__PURE__*/_react["default"].createElement(_Spinner["default"], null), /*#__PURE__*/_react["default"].createElement("span", {
463
+ }, isLoading && /*#__PURE__*/_react["default"].createElement(_Spinner["default"], null), /*#__PURE__*/_react["default"].createElement("span", {
463
464
  className: "button-text"
464
465
  }, t('upload')))), !multiple && value.length > 1 || !BTN_TEXT[type] ? null : type && /*#__PURE__*/_react["default"].createElement("button", {
465
- disabled: loading && !error || disabled,
466
+ disabled: isLoading || disabled,
466
467
  className: formStyles.formBtn,
467
468
  type: "button",
468
469
  onClick: this.openModal
@@ -156,7 +156,7 @@ var Select = /*#__PURE__*/function (_Component) {
156
156
  var regionParent = (0, _ramda.prop)(settings.regionField, formValues);
157
157
  var countryParent = (0, _ramda.prop)(settings.countryField, formValues);
158
158
  var filteredOptions = (0, _ramda.filter)((0, _ramda.allPass)([function (item) {
159
- if (countryParent || countryParent) {
159
+ if (countryParent || regionParent) {
160
160
  var regionEqual = regionParent ? regionParent === item.region : true;
161
161
  var countryEqual = countryParent ? countryParent === item.country : true;
162
162
  return regionEqual && countryEqual;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@experium/findy-form",
3
- "version": "1.2.50",
3
+ "version": "1.2.53",
4
4
  "main": "./lib/index.js",
5
5
  "homepage": "https://experium.github.io/findy-form",
6
6
  "repository": "https://github.com/experium/findy-form",
@@ -10,7 +10,6 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "@ant-design/icons": "^4.2.2",
13
- "axios": "^0.26.0",
14
13
  "class-validator": "^0.12.2",
15
14
  "classnames": "^2.2.6",
16
15
  "final-form": "^4.20.2",
@@ -3,7 +3,6 @@ import { prop, append, remove, isEmpty, path, pathOr, join, values, keys, last }
3
3
  import Modal from 'react-responsive-modal';
4
4
  import { withTranslation } from 'react-i18next';
5
5
  import getusermedia from 'getusermedia';
6
- import axios from 'axios';
7
6
 
8
7
  import withFieldWrapper from '../hocs/withFieldWrapper';
9
8
  import ImageFile from './ImageFile';
@@ -62,19 +61,23 @@ class File extends Component {
62
61
 
63
62
  fd.append('file', file);
64
63
  fd.append('name', file.name);
65
- fd.append('mimetype', fileType);
66
64
 
67
65
  if (validFileType) {
68
66
  this.setState({ loading: true, error: false });
69
67
  setInputError(undefined);
70
68
 
71
- axios.post(postFileUrl, fd, {
72
- headers: {
73
- 'Content-Type': 'multipart/form-data',
74
- },
69
+ fetch(postFileUrl, {
70
+ method: 'POST',
71
+ body: fd
75
72
  })
76
73
  .then(response => {
77
- const { data } = response;
74
+ if (!response.ok && response.status !== 400) {
75
+ throw new Error();
76
+ } else {
77
+ return response.json();
78
+ }
79
+ })
80
+ .then(data => {
78
81
  const { input: { name } } = this.props;
79
82
  const fileName = data.filename;
80
83
 
@@ -112,7 +115,7 @@ class File extends Component {
112
115
  }
113
116
  })
114
117
  .catch((error) => {
115
- setInputError(getFileErrorText(pathOr('', ['response', 'data', 'message'], error)));
118
+ setInputError(getFileErrorText(error));
116
119
  this.setState({ error: true });
117
120
  });
118
121
  } else {
@@ -147,7 +150,6 @@ class File extends Component {
147
150
  }
148
151
 
149
152
  onChange = e => {
150
- console.log(e, e.target);
151
153
  const file = e.target.files[0];
152
154
 
153
155
  this.onSave(file);
@@ -266,6 +268,8 @@ class File extends Component {
266
268
  const ModalContent = MODAL_CONTENT[type];
267
269
  const { loading, error } = this.state;
268
270
 
271
+ const isLoading = loading && !error;
272
+
269
273
  return <div id={`${name}-file`}>
270
274
  { !isEmpty(value) && (
271
275
  <div className={styles.fileList}>
@@ -304,12 +308,13 @@ class File extends Component {
304
308
  className={styles.fileInput}
305
309
  id={name}
306
310
  type='file'
311
+ value=''
307
312
  onChange={this.onChange}
308
313
  accept={this.getAccept(type)}
309
- disabled={disabled || (loading && !error)}
314
+ disabled={disabled || isLoading}
310
315
  />
311
316
  <label htmlFor={name} className={`${disabled ? 'disabled' : ''}`}>
312
- { (loading && !error) && <Spinner /> }
317
+ { isLoading && <Spinner /> }
313
318
  <span className='button-text'>
314
319
  {t('upload')}
315
320
  </span>
@@ -318,7 +323,7 @@ class File extends Component {
318
323
  }
319
324
  { (!multiple && value.length > 1) || !BTN_TEXT[type] ? null : (
320
325
  type && (
321
- <button disabled={loading && !error || disabled} className={formStyles.formBtn} type='button' onClick={this.openModal}>
326
+ <button disabled={isLoading || disabled} className={formStyles.formBtn} type='button' onClick={this.openModal}>
322
327
  { t(BTN_TEXT[type]) }
323
328
  </button>
324
329
  )
@@ -112,7 +112,7 @@ class Select extends Component {
112
112
 
113
113
  const filteredOptions = filter(allPass([
114
114
  item => {
115
- if (countryParent || countryParent) {
115
+ if (countryParent || regionParent) {
116
116
  const regionEqual = regionParent ? regionParent === item.region : true;
117
117
  const countryEqual = countryParent ? countryParent === item.country : true;
118
118