@panneau/field-upload 3.0.6 → 3.0.9
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 +21 -5
- package/lib/index.js +21 -5
- package/package.json +10 -9
package/es/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
3
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
+
import { useLocation } from '@folklore/routes';
|
|
4
5
|
import { faTimes, faFileVideo, faFileImage, faFileAudio } from '@fortawesome/free-solid-svg-icons';
|
|
5
6
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
6
7
|
import { Dashboard, DashboardModal } from '@uppy/react';
|
|
@@ -106,12 +107,24 @@ var UploadField = function UploadField(_ref) {
|
|
|
106
107
|
disabled = _ref.disabled,
|
|
107
108
|
onChange = _ref.onChange,
|
|
108
109
|
className = _ref.className;
|
|
110
|
+
var _useLocation = useLocation(),
|
|
111
|
+
_useLocation2 = _slicedToArray(_useLocation, 1),
|
|
112
|
+
_useLocation2$0$pathn = _useLocation2[0].pathname,
|
|
113
|
+
pathname = _useLocation2$0$pathn === void 0 ? null : _useLocation2$0$pathn;
|
|
109
114
|
// const { ref: containerRef, entry = null } = useResizeObserver();
|
|
110
115
|
// const { contentRect } = entry || {};
|
|
111
116
|
// const { width: containerWidth = null } = contentRect || {};
|
|
112
117
|
|
|
118
|
+
var mergeData = useCallback(function (newValue) {
|
|
119
|
+
// Merge the response from our back-end
|
|
120
|
+
if (isObject(newValue) && isObject(newValue.response) && newValue.response.status === 200 && newValue.response.body !== null) {
|
|
121
|
+
return _objectSpread(_objectSpread({}, newValue), newValue.response.body || null);
|
|
122
|
+
}
|
|
123
|
+
return newValue;
|
|
124
|
+
}, []);
|
|
113
125
|
var onComplete = useCallback(function (response) {
|
|
114
126
|
console.log('upload complete', response); // eslint-disable-line
|
|
127
|
+
|
|
115
128
|
var newValue = null;
|
|
116
129
|
if (isArray(response)) {
|
|
117
130
|
if (allowMultipleUploads) {
|
|
@@ -124,17 +137,19 @@ var UploadField = function UploadField(_ref) {
|
|
|
124
137
|
} else if (response && response.successful) {
|
|
125
138
|
newValue = response.successful.length > 0 ? response.successful[0].response.body : null;
|
|
126
139
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
if (isArray(newValue)) {
|
|
141
|
+
newValue = newValue.map(function (val) {
|
|
142
|
+
return mergeData(val);
|
|
143
|
+
});
|
|
144
|
+
} else {
|
|
145
|
+
newValue = mergeData(newValue);
|
|
131
146
|
}
|
|
132
147
|
console.log('new upload value', newValue); // eslint-disable-line
|
|
133
148
|
|
|
134
149
|
if (onChange !== null) {
|
|
135
150
|
onChange(newValue);
|
|
136
151
|
}
|
|
137
|
-
}, [onChange, allowMultipleUploads]);
|
|
152
|
+
}, [onChange, allowMultipleUploads, mergeData]);
|
|
138
153
|
var typesString = types.join('.');
|
|
139
154
|
var allowedFileTypes = useMemo(function () {
|
|
140
155
|
if (fileTypes !== null) {
|
|
@@ -349,6 +364,7 @@ var UploadField = function UploadField(_ref) {
|
|
|
349
364
|
onPageChange: onListPageChange,
|
|
350
365
|
onQueryChange: onListQueryChange,
|
|
351
366
|
onQueryReset: onListQueryReset,
|
|
367
|
+
baseUrl: pathname,
|
|
352
368
|
listProps: {
|
|
353
369
|
actions: ['select'],
|
|
354
370
|
actionsProps: {
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
6
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
7
7
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
8
|
+
var routes = require('@folklore/routes');
|
|
8
9
|
var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
|
|
9
10
|
var reactFontawesome = require('@fortawesome/react-fontawesome');
|
|
10
11
|
var react = require('@uppy/react');
|
|
@@ -127,12 +128,24 @@ var UploadField = function UploadField(_ref) {
|
|
|
127
128
|
disabled = _ref.disabled,
|
|
128
129
|
onChange = _ref.onChange,
|
|
129
130
|
className = _ref.className;
|
|
131
|
+
var _useLocation = routes.useLocation(),
|
|
132
|
+
_useLocation2 = _slicedToArray__default["default"](_useLocation, 1),
|
|
133
|
+
_useLocation2$0$pathn = _useLocation2[0].pathname,
|
|
134
|
+
pathname = _useLocation2$0$pathn === void 0 ? null : _useLocation2$0$pathn;
|
|
130
135
|
// const { ref: containerRef, entry = null } = useResizeObserver();
|
|
131
136
|
// const { contentRect } = entry || {};
|
|
132
137
|
// const { width: containerWidth = null } = contentRect || {};
|
|
133
138
|
|
|
139
|
+
var mergeData = React.useCallback(function (newValue) {
|
|
140
|
+
// Merge the response from our back-end
|
|
141
|
+
if (isObject__default["default"](newValue) && isObject__default["default"](newValue.response) && newValue.response.status === 200 && newValue.response.body !== null) {
|
|
142
|
+
return _objectSpread__default["default"](_objectSpread__default["default"]({}, newValue), newValue.response.body || null);
|
|
143
|
+
}
|
|
144
|
+
return newValue;
|
|
145
|
+
}, []);
|
|
134
146
|
var onComplete = React.useCallback(function (response) {
|
|
135
147
|
console.log('upload complete', response); // eslint-disable-line
|
|
148
|
+
|
|
136
149
|
var newValue = null;
|
|
137
150
|
if (isArray__default["default"](response)) {
|
|
138
151
|
if (allowMultipleUploads) {
|
|
@@ -145,17 +158,19 @@ var UploadField = function UploadField(_ref) {
|
|
|
145
158
|
} else if (response && response.successful) {
|
|
146
159
|
newValue = response.successful.length > 0 ? response.successful[0].response.body : null;
|
|
147
160
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
161
|
+
if (isArray__default["default"](newValue)) {
|
|
162
|
+
newValue = newValue.map(function (val) {
|
|
163
|
+
return mergeData(val);
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
newValue = mergeData(newValue);
|
|
152
167
|
}
|
|
153
168
|
console.log('new upload value', newValue); // eslint-disable-line
|
|
154
169
|
|
|
155
170
|
if (onChange !== null) {
|
|
156
171
|
onChange(newValue);
|
|
157
172
|
}
|
|
158
|
-
}, [onChange, allowMultipleUploads]);
|
|
173
|
+
}, [onChange, allowMultipleUploads, mergeData]);
|
|
159
174
|
var typesString = types.join('.');
|
|
160
175
|
var allowedFileTypes = React.useMemo(function () {
|
|
161
176
|
if (fileTypes !== null) {
|
|
@@ -370,6 +385,7 @@ var UploadField = function UploadField(_ref) {
|
|
|
370
385
|
onPageChange: onListPageChange,
|
|
371
386
|
onQueryChange: onListQueryChange,
|
|
372
387
|
onQueryReset: onListQueryReset,
|
|
388
|
+
baseUrl: pathname,
|
|
373
389
|
listProps: {
|
|
374
390
|
actions: ['select'],
|
|
375
391
|
actionsProps: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/field-upload",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.9",
|
|
4
4
|
"description": "An Upload field",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -53,16 +53,17 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/runtime": "^7.12.5",
|
|
56
|
+
"@folklore/routes": "^0.2.10",
|
|
56
57
|
"@fortawesome/fontawesome-svg-core": "^1.2.35",
|
|
57
58
|
"@fortawesome/free-solid-svg-icons": "^5.15.3",
|
|
58
59
|
"@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.
|
|
60
|
+
"@panneau/core": "^3.0.9",
|
|
61
|
+
"@panneau/element-button": "^3.0.9",
|
|
62
|
+
"@panneau/element-card": "^3.0.9",
|
|
63
|
+
"@panneau/element-label": "^3.0.9",
|
|
64
|
+
"@panneau/list-resource-items": "^3.0.9",
|
|
65
|
+
"@panneau/modal-dialog": "^3.0.9",
|
|
66
|
+
"@panneau/themes": "^3.0.9",
|
|
66
67
|
"@uppy/core": "^3.2.0",
|
|
67
68
|
"@uppy/dashboard": "^3.4.0",
|
|
68
69
|
"@uppy/drag-drop": "^3.0.2",
|
|
@@ -80,5 +81,5 @@
|
|
|
80
81
|
"publishConfig": {
|
|
81
82
|
"access": "public"
|
|
82
83
|
},
|
|
83
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "5725a31a8f873f1ae84c6df3ac712baf75be15b5"
|
|
84
85
|
}
|