@panneau/field-upload 3.0.6 → 3.0.7
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/es/index.js +16 -6
- package/lib/index.js +17 -7
- package/package.json +9 -9
package/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
2
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
4
4
|
import { faTimes, faFileVideo, faFileImage, faFileAudio } from '@fortawesome/free-solid-svg-icons';
|
|
5
5
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
6
6
|
import { Dashboard, DashboardModal } from '@uppy/react';
|
|
@@ -110,8 +110,16 @@ var UploadField = function UploadField(_ref) {
|
|
|
110
110
|
// const { contentRect } = entry || {};
|
|
111
111
|
// const { width: containerWidth = null } = contentRect || {};
|
|
112
112
|
|
|
113
|
+
var mergeData = useCallback(function (newValue) {
|
|
114
|
+
// Merge the response from our back-end
|
|
115
|
+
if (isObject(newValue) && isObject(newValue.response) && newValue.response.status === 200 && newValue.response.body !== null) {
|
|
116
|
+
return _objectSpread(_objectSpread({}, newValue), newValue.response.body || null);
|
|
117
|
+
}
|
|
118
|
+
return newValue;
|
|
119
|
+
}, []);
|
|
113
120
|
var onComplete = useCallback(function (response) {
|
|
114
121
|
console.log('upload complete', response); // eslint-disable-line
|
|
122
|
+
|
|
115
123
|
var newValue = null;
|
|
116
124
|
if (isArray(response)) {
|
|
117
125
|
if (allowMultipleUploads) {
|
|
@@ -124,17 +132,19 @@ var UploadField = function UploadField(_ref) {
|
|
|
124
132
|
} else if (response && response.successful) {
|
|
125
133
|
newValue = response.successful.length > 0 ? response.successful[0].response.body : null;
|
|
126
134
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
135
|
+
if (isArray(newValue)) {
|
|
136
|
+
newValue = newValue.map(function (val) {
|
|
137
|
+
return mergeData(val);
|
|
138
|
+
});
|
|
139
|
+
} else {
|
|
140
|
+
newValue = mergeData(newValue);
|
|
131
141
|
}
|
|
132
142
|
console.log('new upload value', newValue); // eslint-disable-line
|
|
133
143
|
|
|
134
144
|
if (onChange !== null) {
|
|
135
145
|
onChange(newValue);
|
|
136
146
|
}
|
|
137
|
-
}, [onChange, allowMultipleUploads]);
|
|
147
|
+
}, [onChange, allowMultipleUploads, mergeData]);
|
|
138
148
|
var typesString = types.join('.');
|
|
139
149
|
var allowedFileTypes = useMemo(function () {
|
|
140
150
|
if (fileTypes !== null) {
|
package/lib/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
7
6
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
7
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
8
8
|
var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
|
|
9
9
|
var reactFontawesome = require('@fortawesome/react-fontawesome');
|
|
10
10
|
var react = require('@uppy/react');
|
|
@@ -31,8 +31,8 @@ require('@uppy/status-bar/dist/style.min.css');
|
|
|
31
31
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
32
32
|
|
|
33
33
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
34
|
-
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
35
34
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
35
|
+
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
36
36
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
37
37
|
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
38
38
|
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
|
|
@@ -131,8 +131,16 @@ var UploadField = function UploadField(_ref) {
|
|
|
131
131
|
// const { contentRect } = entry || {};
|
|
132
132
|
// const { width: containerWidth = null } = contentRect || {};
|
|
133
133
|
|
|
134
|
+
var mergeData = React.useCallback(function (newValue) {
|
|
135
|
+
// Merge the response from our back-end
|
|
136
|
+
if (isObject__default["default"](newValue) && isObject__default["default"](newValue.response) && newValue.response.status === 200 && newValue.response.body !== null) {
|
|
137
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, newValue), newValue.response.body || null);
|
|
138
|
+
}
|
|
139
|
+
return newValue;
|
|
140
|
+
}, []);
|
|
134
141
|
var onComplete = React.useCallback(function (response) {
|
|
135
142
|
console.log('upload complete', response); // eslint-disable-line
|
|
143
|
+
|
|
136
144
|
var newValue = null;
|
|
137
145
|
if (isArray__default["default"](response)) {
|
|
138
146
|
if (allowMultipleUploads) {
|
|
@@ -145,17 +153,19 @@ var UploadField = function UploadField(_ref) {
|
|
|
145
153
|
} else if (response && response.successful) {
|
|
146
154
|
newValue = response.successful.length > 0 ? response.successful[0].response.body : null;
|
|
147
155
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
if (isArray__default["default"](newValue)) {
|
|
157
|
+
newValue = newValue.map(function (val) {
|
|
158
|
+
return mergeData(val);
|
|
159
|
+
});
|
|
160
|
+
} else {
|
|
161
|
+
newValue = mergeData(newValue);
|
|
152
162
|
}
|
|
153
163
|
console.log('new upload value', newValue); // eslint-disable-line
|
|
154
164
|
|
|
155
165
|
if (onChange !== null) {
|
|
156
166
|
onChange(newValue);
|
|
157
167
|
}
|
|
158
|
-
}, [onChange, allowMultipleUploads]);
|
|
168
|
+
}, [onChange, allowMultipleUploads, mergeData]);
|
|
159
169
|
var typesString = types.join('.');
|
|
160
170
|
var allowedFileTypes = React.useMemo(function () {
|
|
161
171
|
if (fileTypes !== null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/field-upload",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"description": "An Upload field",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"@fortawesome/fontawesome-svg-core": "^1.2.35",
|
|
57
57
|
"@fortawesome/free-solid-svg-icons": "^5.15.3",
|
|
58
58
|
"@fortawesome/react-fontawesome": "^0.1.14",
|
|
59
|
-
"@panneau/core": "^3.0.
|
|
60
|
-
"@panneau/element-button": "^3.0.
|
|
61
|
-
"@panneau/element-card": "^3.0.
|
|
62
|
-
"@panneau/element-label": "^3.0.
|
|
63
|
-
"@panneau/list-resource-items": "^3.0.
|
|
64
|
-
"@panneau/modal-dialog": "^3.0.
|
|
65
|
-
"@panneau/themes": "^3.0.
|
|
59
|
+
"@panneau/core": "^3.0.7",
|
|
60
|
+
"@panneau/element-button": "^3.0.7",
|
|
61
|
+
"@panneau/element-card": "^3.0.7",
|
|
62
|
+
"@panneau/element-label": "^3.0.7",
|
|
63
|
+
"@panneau/list-resource-items": "^3.0.7",
|
|
64
|
+
"@panneau/modal-dialog": "^3.0.7",
|
|
65
|
+
"@panneau/themes": "^3.0.7",
|
|
66
66
|
"@uppy/core": "^3.2.0",
|
|
67
67
|
"@uppy/dashboard": "^3.4.0",
|
|
68
68
|
"@uppy/drag-drop": "^3.0.2",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "a35958b1d0dcaae2aecac6f30dab29c2616fcc22"
|
|
84
84
|
}
|