@panneau/medias 3.0.204 → 3.0.205

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 +17 -18
  2. package/lib/index.js +17 -18
  3. package/package.json +2 -2
package/es/index.js CHANGED
@@ -1126,13 +1126,13 @@ function MediasBrowser(_ref) {
1126
1126
  }) : columns;
1127
1127
  }, [columns, withTrash, showTrashed]);
1128
1128
  var finalItems = useMemo(function () {
1129
- if (withStickySelection && (extraItems !== null || selectedItems !== null || uploadedMedias !== null || uploadProcessing === true)) {
1129
+ if (withStickySelection && (extraItems !== null || uploadedMedias !== null || uploadProcessing === true)) {
1130
1130
  return uniqBy([].concat(_toConsumableArray(uploadProcessing ? [{
1131
1131
  id: '-',
1132
1132
  loading: true,
1133
1133
  actionsDisabled: true,
1134
1134
  selectionDisabled: true
1135
- }] : []), _toConsumableArray(page === 1 ? uploadedMedias || [] : []), _toConsumableArray(page === 1 ? (selectedItems || []).map(function (item) {
1135
+ }] : []), _toConsumableArray(page === 1 ? uploadedMedias || [] : []), _toConsumableArray(page === 1 ? (extraItems || []).map(function (item) {
1136
1136
  var _item$id = item.id,
1137
1137
  itemId = _item$id === void 0 ? null : _item$id;
1138
1138
  return (allItems || []).find(function () {
@@ -1143,18 +1143,7 @@ function MediasBrowser(_ref) {
1143
1143
  }) || item || null;
1144
1144
  }).filter(function (it) {
1145
1145
  return it !== null;
1146
- }) || [] : []), _toConsumableArray((extraItems || []).map(function (item) {
1147
- var _item$id2 = item.id,
1148
- itemId = _item$id2 === void 0 ? null : _item$id2;
1149
- return (allItems || []).find(function () {
1150
- var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1151
- _ref10$id = _ref10.id,
1152
- otherId = _ref10$id === void 0 ? null : _ref10$id;
1153
- return otherId === itemId;
1154
- }) || item || null;
1155
- }).filter(function (it) {
1156
- return it !== null;
1157
- })), _toConsumableArray(items || [])), function (it) {
1146
+ }) || [] : []), _toConsumableArray(items || [])), function (it) {
1158
1147
  return it === null || it === void 0 ? void 0 : it.id;
1159
1148
  });
1160
1149
  }
@@ -1253,9 +1242,9 @@ function MediasBrowser(_ref) {
1253
1242
  loaded: loaded,
1254
1243
  actionsProps: {
1255
1244
  getDeletePropsFromItem: function getDeletePropsFromItem() {
1256
- var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1257
- _ref11$id = _ref11.id,
1258
- id = _ref11$id === void 0 ? null : _ref11$id;
1245
+ var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1246
+ _ref10$id = _ref10.id,
1247
+ id = _ref10$id === void 0 ? null : _ref10$id;
1259
1248
  return {
1260
1249
  href: null,
1261
1250
  onClick: function onClick() {
@@ -1302,6 +1291,15 @@ function MediasPicker(_ref) {
1302
1291
  multiple = _ref.multiple,
1303
1292
  className = _ref.className,
1304
1293
  props = _objectWithoutProperties(_ref, _excluded$4);
1294
+ // Keep the previous selection on top of first page
1295
+ var extraItems = useMemo(function () {
1296
+ if (initialSelectedItems === null) {
1297
+ return null;
1298
+ }
1299
+ return isArray(initialSelectedItems) ? initialSelectedItems : [initialSelectedItems];
1300
+ }, []);
1301
+
1302
+ // Mostly for testing
1305
1303
  var _useState = useState(initialSelectedItems || null),
1306
1304
  _useState2 = _slicedToArray(_useState, 2),
1307
1305
  selectedItems = _useState2[0],
@@ -1327,7 +1325,8 @@ function MediasPicker(_ref) {
1327
1325
  selectable: true,
1328
1326
  selectedItems: selectedItems,
1329
1327
  onSelectionChange: onSelectionChange,
1330
- multipleSelection: multiple
1328
+ multipleSelection: multiple,
1329
+ extraItems: extraItems
1331
1330
  }, props)));
1332
1331
  }
1333
1332
  MediasPicker.propTypes = propTypes$4;
package/lib/index.js CHANGED
@@ -1128,13 +1128,13 @@ function MediasBrowser(_ref) {
1128
1128
  }) : columns;
1129
1129
  }, [columns, withTrash, showTrashed]);
1130
1130
  var finalItems = React.useMemo(function () {
1131
- if (withStickySelection && (extraItems !== null || selectedItems !== null || uploadedMedias !== null || uploadProcessing === true)) {
1131
+ if (withStickySelection && (extraItems !== null || uploadedMedias !== null || uploadProcessing === true)) {
1132
1132
  return uniqBy([].concat(_toConsumableArray(uploadProcessing ? [{
1133
1133
  id: '-',
1134
1134
  loading: true,
1135
1135
  actionsDisabled: true,
1136
1136
  selectionDisabled: true
1137
- }] : []), _toConsumableArray(page === 1 ? uploadedMedias || [] : []), _toConsumableArray(page === 1 ? (selectedItems || []).map(function (item) {
1137
+ }] : []), _toConsumableArray(page === 1 ? uploadedMedias || [] : []), _toConsumableArray(page === 1 ? (extraItems || []).map(function (item) {
1138
1138
  var _item$id = item.id,
1139
1139
  itemId = _item$id === void 0 ? null : _item$id;
1140
1140
  return (allItems || []).find(function () {
@@ -1145,18 +1145,7 @@ function MediasBrowser(_ref) {
1145
1145
  }) || item || null;
1146
1146
  }).filter(function (it) {
1147
1147
  return it !== null;
1148
- }) || [] : []), _toConsumableArray((extraItems || []).map(function (item) {
1149
- var _item$id2 = item.id,
1150
- itemId = _item$id2 === void 0 ? null : _item$id2;
1151
- return (allItems || []).find(function () {
1152
- var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1153
- _ref10$id = _ref10.id,
1154
- otherId = _ref10$id === void 0 ? null : _ref10$id;
1155
- return otherId === itemId;
1156
- }) || item || null;
1157
- }).filter(function (it) {
1158
- return it !== null;
1159
- })), _toConsumableArray(items || [])), function (it) {
1148
+ }) || [] : []), _toConsumableArray(items || [])), function (it) {
1160
1149
  return it === null || it === void 0 ? void 0 : it.id;
1161
1150
  });
1162
1151
  }
@@ -1255,9 +1244,9 @@ function MediasBrowser(_ref) {
1255
1244
  loaded: loaded,
1256
1245
  actionsProps: {
1257
1246
  getDeletePropsFromItem: function getDeletePropsFromItem() {
1258
- var _ref11 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1259
- _ref11$id = _ref11.id,
1260
- id = _ref11$id === void 0 ? null : _ref11$id;
1247
+ var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1248
+ _ref10$id = _ref10.id,
1249
+ id = _ref10$id === void 0 ? null : _ref10$id;
1261
1250
  return {
1262
1251
  href: null,
1263
1252
  onClick: function onClick() {
@@ -1304,6 +1293,15 @@ function MediasPicker(_ref) {
1304
1293
  multiple = _ref.multiple,
1305
1294
  className = _ref.className,
1306
1295
  props = _objectWithoutProperties(_ref, _excluded$4);
1296
+ // Keep the previous selection on top of first page
1297
+ var extraItems = React.useMemo(function () {
1298
+ if (initialSelectedItems === null) {
1299
+ return null;
1300
+ }
1301
+ return isArray(initialSelectedItems) ? initialSelectedItems : [initialSelectedItems];
1302
+ }, []);
1303
+
1304
+ // Mostly for testing
1307
1305
  var _useState = React.useState(initialSelectedItems || null),
1308
1306
  _useState2 = _slicedToArray(_useState, 2),
1309
1307
  selectedItems = _useState2[0],
@@ -1329,7 +1327,8 @@ function MediasPicker(_ref) {
1329
1327
  selectable: true,
1330
1328
  selectedItems: selectedItems,
1331
1329
  onSelectionChange: onSelectionChange,
1332
- multipleSelection: multiple
1330
+ multipleSelection: multiple,
1331
+ extraItems: extraItems
1333
1332
  }, props)));
1334
1333
  }
1335
1334
  MediasPicker.propTypes = propTypes$4;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/medias",
3
- "version": "3.0.204",
3
+ "version": "3.0.205",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "d9693b3e1d6112feb97a0752590c2715024b6789"
72
+ "gitHead": "55528c93af0666376842ab8c4f56e70e0d461c68"
73
73
  }