@panneau/medias 3.0.189 → 3.0.190
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 +37 -25
- package/lib/index.js +37 -25
- package/package.json +17 -17
package/es/index.js
CHANGED
@@ -814,7 +814,7 @@ var propTypes$5 = {
|
|
814
814
|
layout: PropTypes.string,
|
815
815
|
layouts: PropTypes.arrayOf(PropTypes.shape({})),
|
816
816
|
theme: PropTypes.string,
|
817
|
-
|
817
|
+
onMediaUploaded: PropTypes.func,
|
818
818
|
onItemsChange: PropTypes.func,
|
819
819
|
onLayoutChange: PropTypes.func,
|
820
820
|
onMediaFormOpen: PropTypes.func,
|
@@ -852,7 +852,7 @@ var defaultProps$5 = {
|
|
852
852
|
})
|
853
853
|
}],
|
854
854
|
theme: null,
|
855
|
-
|
855
|
+
onMediaUploaded: null,
|
856
856
|
onItemsChange: null,
|
857
857
|
onLayoutChange: null,
|
858
858
|
onMediaFormOpen: null,
|
@@ -880,7 +880,7 @@ function MediasBrowser(_ref) {
|
|
880
880
|
initialLayout = _ref.layout,
|
881
881
|
layouts = _ref.layouts,
|
882
882
|
theme = _ref.theme,
|
883
|
-
|
883
|
+
onMediaUploaded = _ref.onMediaUploaded,
|
884
884
|
onItemsChange = _ref.onItemsChange,
|
885
885
|
onLayoutChange = _ref.onLayoutChange,
|
886
886
|
onMediaFormOpen = _ref.onMediaFormOpen,
|
@@ -1008,18 +1008,20 @@ function MediasBrowser(_ref) {
|
|
1008
1008
|
_useState8 = _slicedToArray(_useState7, 2),
|
1009
1009
|
uploadedMedias = _useState8[0],
|
1010
1010
|
setUploadedMedias = _useState8[1];
|
1011
|
-
var
|
1011
|
+
var onUploadComplete = useCallback(function () {
|
1012
1012
|
var medias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
1013
1013
|
if (medias === null) return;
|
1014
1014
|
var rawMedias = (isArray(medias) ? medias : [medias]).filter(function (it) {
|
1015
1015
|
return it !== null;
|
1016
1016
|
});
|
1017
|
-
if (
|
1018
|
-
|
1017
|
+
if (onMediaUploaded !== null) {
|
1018
|
+
console.log('rawMedias', rawMedias);
|
1019
|
+
onMediaUploaded(rawMedias).then(function (newMedias) {
|
1019
1020
|
var uploadedNewMedias = (isArray(newMedias) ? [].concat(_toConsumableArray(uploadedMedias || []), _toConsumableArray(newMedias)) : [].concat(_toConsumableArray(uploadedMedias || []), [newMedias])).filter(function (it) {
|
1020
1021
|
return it !== null;
|
1021
1022
|
});
|
1022
1023
|
setUploadedMedias(uploadedNewMedias);
|
1024
|
+
console.log('uploaded', uploadedNewMedias, onSelectionChange);
|
1023
1025
|
if (onSelectionChange !== null) {
|
1024
1026
|
onSelectionChange(newMedias);
|
1025
1027
|
onQueryReset(); // think about this
|
@@ -1034,7 +1036,7 @@ function MediasBrowser(_ref) {
|
|
1034
1036
|
reload();
|
1035
1037
|
}
|
1036
1038
|
}
|
1037
|
-
}, [
|
1039
|
+
}, [onMediaUploaded, reload, onQueryReset, onSelectionChange, uploadedMedias, setUploadedMedias]);
|
1038
1040
|
var pagination = /*#__PURE__*/React.createElement(Pagination, {
|
1039
1041
|
page: page,
|
1040
1042
|
lastPage: lastPage,
|
@@ -1090,6 +1092,21 @@ function MediasBrowser(_ref) {
|
|
1090
1092
|
})
|
1091
1093
|
});
|
1092
1094
|
}
|
1095
|
+
if (columnId === 'actions') {
|
1096
|
+
// console.log('column', column);
|
1097
|
+
var _ref6 = column || {},
|
1098
|
+
_ref6$actions = _ref6.actions,
|
1099
|
+
actions = _ref6$actions === void 0 ? [] : _ref6$actions;
|
1100
|
+
return _objectSpread(_objectSpread({}, column), {}, {
|
1101
|
+
actions: (actions || []).reduce(function (acc, action) {
|
1102
|
+
if (action === 'delete') {
|
1103
|
+
acc.push('restore');
|
1104
|
+
}
|
1105
|
+
acc.push(action);
|
1106
|
+
return acc;
|
1107
|
+
}, [])
|
1108
|
+
});
|
1109
|
+
}
|
1093
1110
|
return column;
|
1094
1111
|
}) : columns;
|
1095
1112
|
}, [columns, withTrash, showTrashed]);
|
@@ -1099,9 +1116,9 @@ function MediasBrowser(_ref) {
|
|
1099
1116
|
var _item$id = item.id,
|
1100
1117
|
itemId = _item$id === void 0 ? null : _item$id;
|
1101
1118
|
return (allItems || []).find(function () {
|
1102
|
-
var
|
1103
|
-
|
1104
|
-
otherId =
|
1119
|
+
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
1120
|
+
_ref7$id = _ref7.id,
|
1121
|
+
otherId = _ref7$id === void 0 ? null : _ref7$id;
|
1105
1122
|
return otherId === itemId;
|
1106
1123
|
}) || item || null;
|
1107
1124
|
}).filter(function (it) {
|
@@ -1147,7 +1164,7 @@ function MediasBrowser(_ref) {
|
|
1147
1164
|
withButton: true,
|
1148
1165
|
withoutMedia: true,
|
1149
1166
|
uppyConfig: uppyConfig,
|
1150
|
-
onChange:
|
1167
|
+
onChange: onUploadComplete
|
1151
1168
|
}) : null), /*#__PURE__*/React.createElement("div", {
|
1152
1169
|
className: classNames(['d-flex', 'mt-1', 'mb-3', {
|
1153
1170
|
'justify-content-between': hasLayouts,
|
@@ -1198,9 +1215,9 @@ function MediasBrowser(_ref) {
|
|
1198
1215
|
loading: loading,
|
1199
1216
|
actionsProps: {
|
1200
1217
|
getDeletePropsFromItem: function getDeletePropsFromItem() {
|
1201
|
-
var
|
1202
|
-
|
1203
|
-
id =
|
1218
|
+
var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
1219
|
+
_ref8$id = _ref8.id,
|
1220
|
+
id = _ref8$id === void 0 ? null : _ref8$id;
|
1204
1221
|
return {
|
1205
1222
|
href: null,
|
1206
1223
|
onClick: function onClick() {
|
@@ -1278,31 +1295,25 @@ function MediasPicker(_ref) {
|
|
1278
1295
|
MediasPicker.propTypes = propTypes$4;
|
1279
1296
|
MediasPicker.defaultProps = defaultProps$4;
|
1280
1297
|
|
1281
|
-
var _excluded$3 = ["api", "media"
|
1298
|
+
var _excluded$3 = ["api", "media"];
|
1282
1299
|
var propTypes$3 = {
|
1283
1300
|
api: apiPropTypes,
|
1284
1301
|
media: PropTypes.shape({
|
1285
1302
|
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
1286
|
-
})
|
1287
|
-
fields: PropTypes.arrayOf(PropTypes.shape({
|
1288
|
-
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
1289
|
-
}))
|
1303
|
+
})
|
1290
1304
|
};
|
1291
1305
|
var defaultProps$3 = {
|
1292
1306
|
api: null,
|
1293
|
-
media: null
|
1294
|
-
fields: null
|
1307
|
+
media: null
|
1295
1308
|
};
|
1296
1309
|
function MediasBrowserContainer(_ref) {
|
1297
1310
|
var api = _ref.api,
|
1298
1311
|
media = _ref.media,
|
1299
|
-
fields = _ref.fields,
|
1300
1312
|
props = _objectWithoutProperties(_ref, _excluded$3);
|
1301
1313
|
return /*#__PURE__*/React.createElement(MediasApiProvider, {
|
1302
1314
|
api: api
|
1303
1315
|
}, /*#__PURE__*/React.createElement(MediaProvider, {
|
1304
|
-
media: media
|
1305
|
-
fields: fields
|
1316
|
+
media: media
|
1306
1317
|
}, /*#__PURE__*/React.createElement(MediasBrowser, props)));
|
1307
1318
|
}
|
1308
1319
|
MediasBrowserContainer.propTypes = propTypes$3;
|
@@ -1318,7 +1329,8 @@ var propTypes$2 = {
|
|
1318
1329
|
};
|
1319
1330
|
var defaultProps$2 = {
|
1320
1331
|
api: null,
|
1321
|
-
media: null
|
1332
|
+
media: null,
|
1333
|
+
onChange: null
|
1322
1334
|
};
|
1323
1335
|
function MediasPickerContainer(_ref) {
|
1324
1336
|
var api = _ref.api,
|
package/lib/index.js
CHANGED
@@ -816,7 +816,7 @@ var propTypes$5 = {
|
|
816
816
|
layout: PropTypes.string,
|
817
817
|
layouts: PropTypes.arrayOf(PropTypes.shape({})),
|
818
818
|
theme: PropTypes.string,
|
819
|
-
|
819
|
+
onMediaUploaded: PropTypes.func,
|
820
820
|
onItemsChange: PropTypes.func,
|
821
821
|
onLayoutChange: PropTypes.func,
|
822
822
|
onMediaFormOpen: PropTypes.func,
|
@@ -854,7 +854,7 @@ var defaultProps$5 = {
|
|
854
854
|
})
|
855
855
|
}],
|
856
856
|
theme: null,
|
857
|
-
|
857
|
+
onMediaUploaded: null,
|
858
858
|
onItemsChange: null,
|
859
859
|
onLayoutChange: null,
|
860
860
|
onMediaFormOpen: null,
|
@@ -882,7 +882,7 @@ function MediasBrowser(_ref) {
|
|
882
882
|
initialLayout = _ref.layout,
|
883
883
|
layouts = _ref.layouts,
|
884
884
|
theme = _ref.theme,
|
885
|
-
|
885
|
+
onMediaUploaded = _ref.onMediaUploaded,
|
886
886
|
onItemsChange = _ref.onItemsChange,
|
887
887
|
onLayoutChange = _ref.onLayoutChange,
|
888
888
|
onMediaFormOpen = _ref.onMediaFormOpen,
|
@@ -1010,18 +1010,20 @@ function MediasBrowser(_ref) {
|
|
1010
1010
|
_useState8 = _slicedToArray(_useState7, 2),
|
1011
1011
|
uploadedMedias = _useState8[0],
|
1012
1012
|
setUploadedMedias = _useState8[1];
|
1013
|
-
var
|
1013
|
+
var onUploadComplete = React.useCallback(function () {
|
1014
1014
|
var medias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
1015
1015
|
if (medias === null) return;
|
1016
1016
|
var rawMedias = (isArray(medias) ? medias : [medias]).filter(function (it) {
|
1017
1017
|
return it !== null;
|
1018
1018
|
});
|
1019
|
-
if (
|
1020
|
-
|
1019
|
+
if (onMediaUploaded !== null) {
|
1020
|
+
console.log('rawMedias', rawMedias);
|
1021
|
+
onMediaUploaded(rawMedias).then(function (newMedias) {
|
1021
1022
|
var uploadedNewMedias = (isArray(newMedias) ? [].concat(_toConsumableArray(uploadedMedias || []), _toConsumableArray(newMedias)) : [].concat(_toConsumableArray(uploadedMedias || []), [newMedias])).filter(function (it) {
|
1022
1023
|
return it !== null;
|
1023
1024
|
});
|
1024
1025
|
setUploadedMedias(uploadedNewMedias);
|
1026
|
+
console.log('uploaded', uploadedNewMedias, onSelectionChange);
|
1025
1027
|
if (onSelectionChange !== null) {
|
1026
1028
|
onSelectionChange(newMedias);
|
1027
1029
|
onQueryReset(); // think about this
|
@@ -1036,7 +1038,7 @@ function MediasBrowser(_ref) {
|
|
1036
1038
|
reload();
|
1037
1039
|
}
|
1038
1040
|
}
|
1039
|
-
}, [
|
1041
|
+
}, [onMediaUploaded, reload, onQueryReset, onSelectionChange, uploadedMedias, setUploadedMedias]);
|
1040
1042
|
var pagination = /*#__PURE__*/React.createElement(Pagination, {
|
1041
1043
|
page: page,
|
1042
1044
|
lastPage: lastPage,
|
@@ -1092,6 +1094,21 @@ function MediasBrowser(_ref) {
|
|
1092
1094
|
})
|
1093
1095
|
});
|
1094
1096
|
}
|
1097
|
+
if (columnId === 'actions') {
|
1098
|
+
// console.log('column', column);
|
1099
|
+
var _ref6 = column || {},
|
1100
|
+
_ref6$actions = _ref6.actions,
|
1101
|
+
actions = _ref6$actions === void 0 ? [] : _ref6$actions;
|
1102
|
+
return _objectSpread(_objectSpread({}, column), {}, {
|
1103
|
+
actions: (actions || []).reduce(function (acc, action) {
|
1104
|
+
if (action === 'delete') {
|
1105
|
+
acc.push('restore');
|
1106
|
+
}
|
1107
|
+
acc.push(action);
|
1108
|
+
return acc;
|
1109
|
+
}, [])
|
1110
|
+
});
|
1111
|
+
}
|
1095
1112
|
return column;
|
1096
1113
|
}) : columns;
|
1097
1114
|
}, [columns, withTrash, showTrashed]);
|
@@ -1101,9 +1118,9 @@ function MediasBrowser(_ref) {
|
|
1101
1118
|
var _item$id = item.id,
|
1102
1119
|
itemId = _item$id === void 0 ? null : _item$id;
|
1103
1120
|
return (allItems || []).find(function () {
|
1104
|
-
var
|
1105
|
-
|
1106
|
-
otherId =
|
1121
|
+
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
1122
|
+
_ref7$id = _ref7.id,
|
1123
|
+
otherId = _ref7$id === void 0 ? null : _ref7$id;
|
1107
1124
|
return otherId === itemId;
|
1108
1125
|
}) || item || null;
|
1109
1126
|
}).filter(function (it) {
|
@@ -1149,7 +1166,7 @@ function MediasBrowser(_ref) {
|
|
1149
1166
|
withButton: true,
|
1150
1167
|
withoutMedia: true,
|
1151
1168
|
uppyConfig: uppyConfig,
|
1152
|
-
onChange:
|
1169
|
+
onChange: onUploadComplete
|
1153
1170
|
}) : null), /*#__PURE__*/React.createElement("div", {
|
1154
1171
|
className: classNames(['d-flex', 'mt-1', 'mb-3', {
|
1155
1172
|
'justify-content-between': hasLayouts,
|
@@ -1200,9 +1217,9 @@ function MediasBrowser(_ref) {
|
|
1200
1217
|
loading: loading,
|
1201
1218
|
actionsProps: {
|
1202
1219
|
getDeletePropsFromItem: function getDeletePropsFromItem() {
|
1203
|
-
var
|
1204
|
-
|
1205
|
-
id =
|
1220
|
+
var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
1221
|
+
_ref8$id = _ref8.id,
|
1222
|
+
id = _ref8$id === void 0 ? null : _ref8$id;
|
1206
1223
|
return {
|
1207
1224
|
href: null,
|
1208
1225
|
onClick: function onClick() {
|
@@ -1280,31 +1297,25 @@ function MediasPicker(_ref) {
|
|
1280
1297
|
MediasPicker.propTypes = propTypes$4;
|
1281
1298
|
MediasPicker.defaultProps = defaultProps$4;
|
1282
1299
|
|
1283
|
-
var _excluded$3 = ["api", "media"
|
1300
|
+
var _excluded$3 = ["api", "media"];
|
1284
1301
|
var propTypes$3 = {
|
1285
1302
|
api: apiPropTypes,
|
1286
1303
|
media: PropTypes.shape({
|
1287
1304
|
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
1288
|
-
})
|
1289
|
-
fields: PropTypes.arrayOf(PropTypes.shape({
|
1290
|
-
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
1291
|
-
}))
|
1305
|
+
})
|
1292
1306
|
};
|
1293
1307
|
var defaultProps$3 = {
|
1294
1308
|
api: null,
|
1295
|
-
media: null
|
1296
|
-
fields: null
|
1309
|
+
media: null
|
1297
1310
|
};
|
1298
1311
|
function MediasBrowserContainer(_ref) {
|
1299
1312
|
var api = _ref.api,
|
1300
1313
|
media = _ref.media,
|
1301
|
-
fields = _ref.fields,
|
1302
1314
|
props = _objectWithoutProperties(_ref, _excluded$3);
|
1303
1315
|
return /*#__PURE__*/React.createElement(MediasApiProvider, {
|
1304
1316
|
api: api
|
1305
1317
|
}, /*#__PURE__*/React.createElement(MediaProvider, {
|
1306
|
-
media: media
|
1307
|
-
fields: fields
|
1318
|
+
media: media
|
1308
1319
|
}, /*#__PURE__*/React.createElement(MediasBrowser, props)));
|
1309
1320
|
}
|
1310
1321
|
MediasBrowserContainer.propTypes = propTypes$3;
|
@@ -1320,7 +1331,8 @@ var propTypes$2 = {
|
|
1320
1331
|
};
|
1321
1332
|
var defaultProps$2 = {
|
1322
1333
|
api: null,
|
1323
|
-
media: null
|
1334
|
+
media: null,
|
1335
|
+
onChange: null
|
1324
1336
|
};
|
1325
1337
|
function MediasPickerContainer(_ref) {
|
1326
1338
|
var api = _ref.api,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@panneau/medias",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.190",
|
4
4
|
"description": "",
|
5
5
|
"keywords": [
|
6
6
|
"javascript"
|
@@ -46,21 +46,21 @@
|
|
46
46
|
},
|
47
47
|
"dependencies": {
|
48
48
|
"@babel/runtime": "^7.12.5",
|
49
|
-
"@panneau/core": "^3.0.
|
50
|
-
"@panneau/data": "^3.0.
|
51
|
-
"@panneau/display-image": "^3.0.
|
52
|
-
"@panneau/element-button": "^3.0.
|
53
|
-
"@panneau/element-buttons": "^3.0.
|
54
|
-
"@panneau/element-form": "^3.0.
|
55
|
-
"@panneau/element-form-status": "^3.0.
|
56
|
-
"@panneau/element-grid": "^3.0.
|
57
|
-
"@panneau/element-icon": "^3.0.
|
58
|
-
"@panneau/element-media-card": "^3.0.
|
59
|
-
"@panneau/element-media-player": "^3.0.
|
60
|
-
"@panneau/element-pagination": "^3.0.
|
61
|
-
"@panneau/element-table": "^3.0.
|
62
|
-
"@panneau/field-upload": "^3.0.
|
63
|
-
"@panneau/filter-filters": "^3.0.
|
49
|
+
"@panneau/core": "^3.0.190",
|
50
|
+
"@panneau/data": "^3.0.190",
|
51
|
+
"@panneau/display-image": "^3.0.190",
|
52
|
+
"@panneau/element-button": "^3.0.190",
|
53
|
+
"@panneau/element-buttons": "^3.0.190",
|
54
|
+
"@panneau/element-form": "^3.0.190",
|
55
|
+
"@panneau/element-form-status": "^3.0.190",
|
56
|
+
"@panneau/element-grid": "^3.0.190",
|
57
|
+
"@panneau/element-icon": "^3.0.190",
|
58
|
+
"@panneau/element-media-card": "^3.0.190",
|
59
|
+
"@panneau/element-media-player": "^3.0.190",
|
60
|
+
"@panneau/element-pagination": "^3.0.190",
|
61
|
+
"@panneau/element-table": "^3.0.190",
|
62
|
+
"@panneau/field-upload": "^3.0.190",
|
63
|
+
"@panneau/filter-filters": "^3.0.190",
|
64
64
|
"classnames": "^2.5.1",
|
65
65
|
"lodash": "^4.17.21",
|
66
66
|
"prop-types": "^15.7.2",
|
@@ -69,5 +69,5 @@
|
|
69
69
|
"publishConfig": {
|
70
70
|
"access": "public"
|
71
71
|
},
|
72
|
-
"gitHead": "
|
72
|
+
"gitHead": "ec38fa9c18606a8d5566183b8acf659a894eca0d"
|
73
73
|
}
|