@panneau/medias 3.0.208 → 3.0.210

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.
Files changed (3) hide show
  1. package/es/index.js +54 -32
  2. package/lib/index.js +54 -32
  3. package/package.json +7 -7
package/es/index.js CHANGED
@@ -496,7 +496,20 @@ function MediaForm(_ref) {
496
496
  style: {
497
497
  maxWidth: '66%'
498
498
  }
499
- }, /*#__PURE__*/React.createElement("h4", {
499
+ }, /*#__PURE__*/React.createElement("div", {
500
+ className: "me-3 mb-0"
501
+ }, /*#__PURE__*/React.createElement(Button, {
502
+ theme: "secondary",
503
+ outline: true,
504
+ onClick: onClose,
505
+ icon: "arrow-left"
506
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
507
+ id: "8NyYTH",
508
+ defaultMessage: [{
509
+ "type": 0,
510
+ "value": "Back"
511
+ }]
512
+ }))), /*#__PURE__*/React.createElement("h4", {
500
513
  className: "d-inline text-truncate mb-0"
501
514
  }, name), /*#__PURE__*/React.createElement("span", {
502
515
  className: "mx-2"
@@ -905,9 +918,9 @@ function MediasBrowser(_ref) {
905
918
  var baseQuery = useMemo(function () {
906
919
  return _objectSpread(_objectSpread({
907
920
  count: 12
908
- }, initialQuery), {}, {
921
+ }, initialQuery), types !== null ? {
909
922
  types: types
910
- });
923
+ } : null);
911
924
  }, [initialQuery, types]);
912
925
  var _useQuery = useQuery(baseQuery),
913
926
  fullQuery = _useQuery.query,
@@ -937,8 +950,9 @@ function MediasBrowser(_ref) {
937
950
  // eslint-disable-next-line no-unused-vars
938
951
  var _ref3 = query || {};
939
952
  _ref3.types;
940
- _ref3.trashed;
941
- var queryWithoutTypes = _objectWithoutProperties(_ref3, _excluded2);
953
+ var _ref3$trashed = _ref3.trashed,
954
+ trashed = _ref3$trashed === void 0 ? null : _ref3$trashed,
955
+ queryWithoutTypes = _objectWithoutProperties(_ref3, _excluded2);
942
956
  var _useMediaTrash = useMediaTrash$1(),
943
957
  mediaTrash = _useMediaTrash.mediaTrash,
944
958
  trashing = _useMediaTrash.trashing;
@@ -1067,6 +1081,7 @@ function MediasBrowser(_ref) {
1067
1081
  withPreviousNext: true,
1068
1082
  alwaysShowButtons: true
1069
1083
  });
1084
+ var hidePagination = loaded && !loading && (items || []).length === 0;
1070
1085
  var finalFilters = useMemo(function () {
1071
1086
  var partialFilters = withTrash ? (filters || []).concat([{
1072
1087
  name: 'trashed',
@@ -1113,7 +1128,11 @@ function MediasBrowser(_ref) {
1113
1128
  return _objectSpread(_objectSpread({}, column), {}, {
1114
1129
  actions: (actions || []).reduce(function (acc, action) {
1115
1130
  if (action === 'delete') {
1116
- acc.push('restore');
1131
+ acc.push({
1132
+ id: 'restore',
1133
+ component: 'restore',
1134
+ withConfirmation: true
1135
+ });
1117
1136
  }
1118
1137
  acc.push(action);
1119
1138
  return acc;
@@ -1125,6 +1144,10 @@ function MediasBrowser(_ref) {
1125
1144
  return column;
1126
1145
  }) : columns;
1127
1146
  }, [columns, withTrash, showTrashed]);
1147
+ var hasQueryItem = useMemo(function () {
1148
+ var showOnTopQuery = types === null ? query : queryWithoutTypes;
1149
+ return showOnTopQuery !== null && !trashed ? Object.keys(showOnTopQuery).length > 0 : false;
1150
+ }, [types, query, queryWithoutTypes, trashed]);
1128
1151
  var finalItems = useMemo(function () {
1129
1152
  if (withStickySelection && (extraItems !== null || uploadedMedias !== null || uploadProcessing === true)) {
1130
1153
  return uniqBy([].concat(_toConsumableArray(uploadProcessing ? [{
@@ -1132,7 +1155,7 @@ function MediasBrowser(_ref) {
1132
1155
  loading: true,
1133
1156
  actionsDisabled: true,
1134
1157
  selectionDisabled: true
1135
- }] : []), _toConsumableArray(page === 1 ? uploadedMedias || [] : []), _toConsumableArray(page === 1 ? (extraItems || []).map(function (item) {
1158
+ }] : []), _toConsumableArray(page === 1 && !hasQueryItem ? uploadedMedias || [] : []), _toConsumableArray(page === 1 && !hasQueryItem ? (extraItems || []).map(function (item) {
1136
1159
  var _item$id = item.id,
1137
1160
  itemId = _item$id === void 0 ? null : _item$id;
1138
1161
  return (allItems || []).find(function () {
@@ -1148,29 +1171,23 @@ function MediasBrowser(_ref) {
1148
1171
  });
1149
1172
  }
1150
1173
  return items;
1151
- }, [items, page, allItems, withStickySelection, extraItems, uploadProcessing]);
1174
+ }, [items, page, allItems, withStickySelection, extraItems, uploadProcessing, hasQueryItem]);
1175
+
1176
+ // const emptyWithSticky = useMemo(
1177
+ // () => (items || []).length === 0 && (finalItems || []).length > 0,
1178
+ // [items, finalItems],
1179
+ // );
1180
+
1152
1181
  return /*#__PURE__*/React.createElement("div", {
1153
1182
  className: className
1154
- }, currentMedia !== null ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1155
- className: "mt-2 mb-0"
1156
- }, /*#__PURE__*/React.createElement(Button, {
1157
- theme: "primary",
1158
- onClick: onCloseMedia,
1159
- icon: "arrow-left"
1160
- }, /*#__PURE__*/React.createElement(FormattedMessage, {
1161
- id: "ac4218",
1162
- defaultMessage: [{
1163
- "type": 0,
1164
- "value": "Back to files"
1165
- }]
1166
- }))), /*#__PURE__*/React.createElement(MediaForm, {
1183
+ }, currentMedia !== null ? /*#__PURE__*/React.createElement(MediaForm, {
1167
1184
  value: currentMedia,
1168
1185
  fields: fields,
1169
1186
  onChange: setCurrentMedia,
1170
1187
  onSave: onSaveMedia,
1171
1188
  onClose: onCloseMedia,
1172
1189
  withTrash: withTrash
1173
- }, formChildren)) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1190
+ }, formChildren) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1174
1191
  className: classNames(['d-flex', 'justify-content-between'])
1175
1192
  }, filters !== null ? /*#__PURE__*/React.createElement(Filters, {
1176
1193
  value: query,
@@ -1205,10 +1222,10 @@ function MediasBrowser(_ref) {
1205
1222
  onClick: function onClick() {
1206
1223
  return onClickLayout(lay.id);
1207
1224
  },
1208
- className: 'px-3'
1225
+ className: 'px-3 py-2'
1209
1226
  });
1210
1227
  })
1211
- }) : null, pagination), layout === 'grid' ? /*#__PURE__*/React.createElement(Grid, {
1228
+ }) : null, !hidePagination ? pagination : /*#__PURE__*/React.createElement("div", null)), layout === 'grid' ? /*#__PURE__*/React.createElement(Grid, {
1212
1229
  size: "small",
1213
1230
  theme: theme,
1214
1231
  component: MediaCard,
@@ -1227,6 +1244,7 @@ function MediasBrowser(_ref) {
1227
1244
  items: finalItems || [],
1228
1245
  loading: loading,
1229
1246
  loaded: loaded
1247
+ // empty={emptyWithSticky}
1230
1248
  }) : null, layout === 'table' ? /*#__PURE__*/React.createElement(Table, {
1231
1249
  theme: theme,
1232
1250
  columns: finalColumns,
@@ -1239,20 +1257,24 @@ function MediasBrowser(_ref) {
1239
1257
  multipleSelection: multipleSelection,
1240
1258
  items: finalItems,
1241
1259
  loading: loading,
1242
- loaded: loaded,
1260
+ loaded: loaded
1261
+ // empty={emptyWithSticky}
1262
+ ,
1243
1263
  actionsProps: {
1244
1264
  getDeletePropsFromItem: function getDeletePropsFromItem() {
1245
1265
  var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1246
1266
  _ref10$id = _ref10.id,
1247
1267
  id = _ref10$id === void 0 ? null : _ref10$id;
1248
- return {
1268
+ return _objectSpread({
1249
1269
  href: null,
1250
- onClick: function onClick() {
1251
- return !showTrashed && withTrash ? mediaTrash(id) : mediaDelete(id);
1252
- },
1270
+ withConfirmation: true,
1253
1271
  disabled: trashing || deleting,
1254
1272
  icon: showTrashed ? 'trash-fill' : 'trash'
1255
- };
1273
+ }, withTrash ? {
1274
+ onClick: function onClick() {
1275
+ return !showTrashed && withTrash ? mediaTrash(id) : mediaDelete(id);
1276
+ }
1277
+ } : null);
1256
1278
  },
1257
1279
  getEditPropsFromItem: function getEditPropsFromItem(it) {
1258
1280
  return {
@@ -1263,9 +1285,9 @@ function MediasBrowser(_ref) {
1263
1285
  };
1264
1286
  }
1265
1287
  }
1266
- }) : null, /*#__PURE__*/React.createElement("div", {
1288
+ }) : null, !hidePagination ? /*#__PURE__*/React.createElement("div", {
1267
1289
  className: classNames(['d-flex', 'mt-3', 'mb-1', 'justify-content-end'])
1268
- }, pagination)));
1290
+ }, pagination) : null));
1269
1291
  }
1270
1292
  MediasBrowser.propTypes = propTypes$5;
1271
1293
  MediasBrowser.defaultProps = defaultProps$5;
package/lib/index.js CHANGED
@@ -498,7 +498,20 @@ function MediaForm(_ref) {
498
498
  style: {
499
499
  maxWidth: '66%'
500
500
  }
501
- }, /*#__PURE__*/React.createElement("h4", {
501
+ }, /*#__PURE__*/React.createElement("div", {
502
+ className: "me-3 mb-0"
503
+ }, /*#__PURE__*/React.createElement(Button, {
504
+ theme: "secondary",
505
+ outline: true,
506
+ onClick: onClose,
507
+ icon: "arrow-left"
508
+ }, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
509
+ id: "8NyYTH",
510
+ defaultMessage: [{
511
+ "type": 0,
512
+ "value": "Back"
513
+ }]
514
+ }))), /*#__PURE__*/React.createElement("h4", {
502
515
  className: "d-inline text-truncate mb-0"
503
516
  }, name), /*#__PURE__*/React.createElement("span", {
504
517
  className: "mx-2"
@@ -907,9 +920,9 @@ function MediasBrowser(_ref) {
907
920
  var baseQuery = React.useMemo(function () {
908
921
  return _objectSpread(_objectSpread({
909
922
  count: 12
910
- }, initialQuery), {}, {
923
+ }, initialQuery), types !== null ? {
911
924
  types: types
912
- });
925
+ } : null);
913
926
  }, [initialQuery, types]);
914
927
  var _useQuery = hooks.useQuery(baseQuery),
915
928
  fullQuery = _useQuery.query,
@@ -939,8 +952,9 @@ function MediasBrowser(_ref) {
939
952
  // eslint-disable-next-line no-unused-vars
940
953
  var _ref3 = query || {};
941
954
  _ref3.types;
942
- _ref3.trashed;
943
- var queryWithoutTypes = _objectWithoutProperties(_ref3, _excluded2);
955
+ var _ref3$trashed = _ref3.trashed,
956
+ trashed = _ref3$trashed === void 0 ? null : _ref3$trashed,
957
+ queryWithoutTypes = _objectWithoutProperties(_ref3, _excluded2);
944
958
  var _useMediaTrash = useMediaTrash$1(),
945
959
  mediaTrash = _useMediaTrash.mediaTrash,
946
960
  trashing = _useMediaTrash.trashing;
@@ -1069,6 +1083,7 @@ function MediasBrowser(_ref) {
1069
1083
  withPreviousNext: true,
1070
1084
  alwaysShowButtons: true
1071
1085
  });
1086
+ var hidePagination = loaded && !loading && (items || []).length === 0;
1072
1087
  var finalFilters = React.useMemo(function () {
1073
1088
  var partialFilters = withTrash ? (filters || []).concat([{
1074
1089
  name: 'trashed',
@@ -1115,7 +1130,11 @@ function MediasBrowser(_ref) {
1115
1130
  return _objectSpread(_objectSpread({}, column), {}, {
1116
1131
  actions: (actions || []).reduce(function (acc, action) {
1117
1132
  if (action === 'delete') {
1118
- acc.push('restore');
1133
+ acc.push({
1134
+ id: 'restore',
1135
+ component: 'restore',
1136
+ withConfirmation: true
1137
+ });
1119
1138
  }
1120
1139
  acc.push(action);
1121
1140
  return acc;
@@ -1127,6 +1146,10 @@ function MediasBrowser(_ref) {
1127
1146
  return column;
1128
1147
  }) : columns;
1129
1148
  }, [columns, withTrash, showTrashed]);
1149
+ var hasQueryItem = React.useMemo(function () {
1150
+ var showOnTopQuery = types === null ? query : queryWithoutTypes;
1151
+ return showOnTopQuery !== null && !trashed ? Object.keys(showOnTopQuery).length > 0 : false;
1152
+ }, [types, query, queryWithoutTypes, trashed]);
1130
1153
  var finalItems = React.useMemo(function () {
1131
1154
  if (withStickySelection && (extraItems !== null || uploadedMedias !== null || uploadProcessing === true)) {
1132
1155
  return uniqBy([].concat(_toConsumableArray(uploadProcessing ? [{
@@ -1134,7 +1157,7 @@ function MediasBrowser(_ref) {
1134
1157
  loading: true,
1135
1158
  actionsDisabled: true,
1136
1159
  selectionDisabled: true
1137
- }] : []), _toConsumableArray(page === 1 ? uploadedMedias || [] : []), _toConsumableArray(page === 1 ? (extraItems || []).map(function (item) {
1160
+ }] : []), _toConsumableArray(page === 1 && !hasQueryItem ? uploadedMedias || [] : []), _toConsumableArray(page === 1 && !hasQueryItem ? (extraItems || []).map(function (item) {
1138
1161
  var _item$id = item.id,
1139
1162
  itemId = _item$id === void 0 ? null : _item$id;
1140
1163
  return (allItems || []).find(function () {
@@ -1150,29 +1173,23 @@ function MediasBrowser(_ref) {
1150
1173
  });
1151
1174
  }
1152
1175
  return items;
1153
- }, [items, page, allItems, withStickySelection, extraItems, uploadProcessing]);
1176
+ }, [items, page, allItems, withStickySelection, extraItems, uploadProcessing, hasQueryItem]);
1177
+
1178
+ // const emptyWithSticky = useMemo(
1179
+ // () => (items || []).length === 0 && (finalItems || []).length > 0,
1180
+ // [items, finalItems],
1181
+ // );
1182
+
1154
1183
  return /*#__PURE__*/React.createElement("div", {
1155
1184
  className: className
1156
- }, currentMedia !== null ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1157
- className: "mt-2 mb-0"
1158
- }, /*#__PURE__*/React.createElement(Button, {
1159
- theme: "primary",
1160
- onClick: onCloseMedia,
1161
- icon: "arrow-left"
1162
- }, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
1163
- id: "ac4218",
1164
- defaultMessage: [{
1165
- "type": 0,
1166
- "value": "Back to files"
1167
- }]
1168
- }))), /*#__PURE__*/React.createElement(MediaForm, {
1185
+ }, currentMedia !== null ? /*#__PURE__*/React.createElement(MediaForm, {
1169
1186
  value: currentMedia,
1170
1187
  fields: fields,
1171
1188
  onChange: setCurrentMedia,
1172
1189
  onSave: onSaveMedia,
1173
1190
  onClose: onCloseMedia,
1174
1191
  withTrash: withTrash
1175
- }, formChildren)) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1192
+ }, formChildren) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1176
1193
  className: classNames(['d-flex', 'justify-content-between'])
1177
1194
  }, filters !== null ? /*#__PURE__*/React.createElement(Filters, {
1178
1195
  value: query,
@@ -1207,10 +1224,10 @@ function MediasBrowser(_ref) {
1207
1224
  onClick: function onClick() {
1208
1225
  return onClickLayout(lay.id);
1209
1226
  },
1210
- className: 'px-3'
1227
+ className: 'px-3 py-2'
1211
1228
  });
1212
1229
  })
1213
- }) : null, pagination), layout === 'grid' ? /*#__PURE__*/React.createElement(Grid, {
1230
+ }) : null, !hidePagination ? pagination : /*#__PURE__*/React.createElement("div", null)), layout === 'grid' ? /*#__PURE__*/React.createElement(Grid, {
1214
1231
  size: "small",
1215
1232
  theme: theme,
1216
1233
  component: MediaCard,
@@ -1229,6 +1246,7 @@ function MediasBrowser(_ref) {
1229
1246
  items: finalItems || [],
1230
1247
  loading: loading,
1231
1248
  loaded: loaded
1249
+ // empty={emptyWithSticky}
1232
1250
  }) : null, layout === 'table' ? /*#__PURE__*/React.createElement(Table, {
1233
1251
  theme: theme,
1234
1252
  columns: finalColumns,
@@ -1241,20 +1259,24 @@ function MediasBrowser(_ref) {
1241
1259
  multipleSelection: multipleSelection,
1242
1260
  items: finalItems,
1243
1261
  loading: loading,
1244
- loaded: loaded,
1262
+ loaded: loaded
1263
+ // empty={emptyWithSticky}
1264
+ ,
1245
1265
  actionsProps: {
1246
1266
  getDeletePropsFromItem: function getDeletePropsFromItem() {
1247
1267
  var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1248
1268
  _ref10$id = _ref10.id,
1249
1269
  id = _ref10$id === void 0 ? null : _ref10$id;
1250
- return {
1270
+ return _objectSpread({
1251
1271
  href: null,
1252
- onClick: function onClick() {
1253
- return !showTrashed && withTrash ? mediaTrash(id) : mediaDelete(id);
1254
- },
1272
+ withConfirmation: true,
1255
1273
  disabled: trashing || deleting,
1256
1274
  icon: showTrashed ? 'trash-fill' : 'trash'
1257
- };
1275
+ }, withTrash ? {
1276
+ onClick: function onClick() {
1277
+ return !showTrashed && withTrash ? mediaTrash(id) : mediaDelete(id);
1278
+ }
1279
+ } : null);
1258
1280
  },
1259
1281
  getEditPropsFromItem: function getEditPropsFromItem(it) {
1260
1282
  return {
@@ -1265,9 +1287,9 @@ function MediasBrowser(_ref) {
1265
1287
  };
1266
1288
  }
1267
1289
  }
1268
- }) : null, /*#__PURE__*/React.createElement("div", {
1290
+ }) : null, !hidePagination ? /*#__PURE__*/React.createElement("div", {
1269
1291
  className: classNames(['d-flex', 'mt-3', 'mb-1', 'justify-content-end'])
1270
- }, pagination)));
1292
+ }, pagination) : null));
1271
1293
  }
1272
1294
  MediasBrowser.propTypes = propTypes$5;
1273
1295
  MediasBrowser.defaultProps = defaultProps$5;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/medias",
3
- "version": "3.0.208",
3
+ "version": "3.0.210",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -47,19 +47,19 @@
47
47
  "dependencies": {
48
48
  "@babel/runtime": "^7.12.5",
49
49
  "@panneau/core": "^3.0.194",
50
- "@panneau/data": "^3.0.208",
50
+ "@panneau/data": "^3.0.209",
51
51
  "@panneau/display-image": "^3.0.201",
52
52
  "@panneau/element-button": "^3.0.194",
53
53
  "@panneau/element-buttons": "^3.0.194",
54
54
  "@panneau/element-form": "^3.0.199",
55
55
  "@panneau/element-form-status": "^3.0.194",
56
- "@panneau/element-grid": "^3.0.200",
56
+ "@panneau/element-grid": "^3.0.209",
57
57
  "@panneau/element-icon": "^3.0.194",
58
58
  "@panneau/element-media-card": "^3.0.201",
59
- "@panneau/element-media-player": "^3.0.199",
59
+ "@panneau/element-media-player": "^3.0.210",
60
60
  "@panneau/element-pagination": "^3.0.194",
61
- "@panneau/element-table": "^3.0.200",
62
- "@panneau/field-upload": "^3.0.208",
61
+ "@panneau/element-table": "^3.0.210",
62
+ "@panneau/field-upload": "^3.0.210",
63
63
  "@panneau/filter-filters": "^3.0.208",
64
64
  "classnames": "^2.5.1",
65
65
  "lodash": "^4.17.21",
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "784e87ce65299b81ce5f139a676ded4d70f5cfb1"
72
+ "gitHead": "43a3318fcab6ff8fb8294ad640df584f01a7c156"
73
73
  }