@micromag/media-gallery 0.3.508 → 0.3.510
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/assets/css/styles.css +1 -12
- package/es/index.js +455 -1789
- package/lib/index.js +483 -1779
- package/package.json +17 -10
package/es/index.js
CHANGED
|
@@ -1,1846 +1,504 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
3
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
4
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
5
|
import classNames from 'classnames';
|
|
5
6
|
import isArray from 'lodash/isArray';
|
|
6
|
-
import PropTypes
|
|
7
|
-
import React, { useMemo,
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import React, { useMemo, useState, useCallback } from 'react';
|
|
8
9
|
import { createPortal } from 'react-dom';
|
|
9
|
-
import {
|
|
10
|
-
import { PropTypes } from '@micromag/core';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import uniqBy from 'lodash/uniqBy';
|
|
21
|
-
import prettyBytes from 'pretty-bytes';
|
|
22
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
23
|
-
import { faChevronLeft } from '@fortawesome/free-solid-svg-icons/faChevronLeft';
|
|
24
|
-
import { faPlus } from '@fortawesome/free-solid-svg-icons/faPlus';
|
|
25
|
-
import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
|
|
26
|
-
import { faSearch } from '@fortawesome/free-solid-svg-icons/faSearch';
|
|
27
|
-
import { faSpinner } from '@fortawesome/free-solid-svg-icons/faSpinner';
|
|
28
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
29
|
-
|
|
30
|
-
var middleEllipsis = function middleEllipsis(string, maxLength) {
|
|
31
|
-
if (!string) return string;
|
|
32
|
-
if (maxLength < 1) return string;
|
|
33
|
-
if (string.length <= maxLength) return string;
|
|
34
|
-
if (maxLength === 1) return "".concat(string.substring(0, 1), "...");
|
|
35
|
-
var midpoint = Math.ceil(string.length / 2);
|
|
36
|
-
var toremove = string.length - maxLength;
|
|
37
|
-
var lstrip = Math.ceil(toremove / 2);
|
|
38
|
-
var rstrip = toremove - lstrip;
|
|
39
|
-
return "".concat(string.substring(0, midpoint - lstrip), "...").concat(string.substring(midpoint + rstrip));
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
var styles$b = {"container":"micromag-media-gallery-items-gallery-item-container","selected":"micromag-media-gallery-items-gallery-item-selected","imageButton":"micromag-media-gallery-items-gallery-item-imageButton","image":"micromag-media-gallery-items-gallery-item-image","icon":"micromag-media-gallery-items-gallery-item-icon","footer":"micromag-media-gallery-items-gallery-item-footer","label":"micromag-media-gallery-items-gallery-item-label","infoButton":"micromag-media-gallery-items-gallery-item-infoButton","closeButton":"micromag-media-gallery-items-gallery-item-closeButton"};
|
|
43
|
-
|
|
44
|
-
var propTypes$b = {
|
|
45
|
-
item: PropTypes.media,
|
|
46
|
-
width: PropTypes$1.number,
|
|
47
|
-
selected: PropTypes$1.bool,
|
|
48
|
-
withInfoButton: PropTypes$1.bool,
|
|
49
|
-
className: PropTypes$1.string,
|
|
50
|
-
onClick: PropTypes$1.func,
|
|
51
|
-
onClickInfo: PropTypes$1.func,
|
|
52
|
-
onClickRemove: PropTypes$1.func
|
|
53
|
-
};
|
|
54
|
-
var defaultProps$b = {
|
|
55
|
-
item: null,
|
|
56
|
-
width: 0,
|
|
57
|
-
selected: false,
|
|
58
|
-
withInfoButton: false,
|
|
59
|
-
className: null,
|
|
60
|
-
onClick: null,
|
|
61
|
-
onClickInfo: null,
|
|
62
|
-
onClickRemove: null
|
|
63
|
-
};
|
|
64
|
-
var GalleryItem = function GalleryItem(_ref) {
|
|
65
|
-
var item = _ref.item,
|
|
66
|
-
width = _ref.width,
|
|
67
|
-
selected = _ref.selected,
|
|
68
|
-
withInfoButton = _ref.withInfoButton,
|
|
69
|
-
className = _ref.className,
|
|
70
|
-
onClick = _ref.onClick,
|
|
71
|
-
onClickInfo = _ref.onClickInfo,
|
|
72
|
-
onClickRemove = _ref.onClickRemove;
|
|
73
|
-
var type = item.type,
|
|
74
|
-
_item$thumbnail_url = item.thumbnail_url,
|
|
75
|
-
thumbnail = _item$thumbnail_url === void 0 ? null : _item$thumbnail_url,
|
|
76
|
-
name = item.name,
|
|
77
|
-
size = item.size;
|
|
78
|
-
var title = name;
|
|
79
|
-
if (width < 768) {
|
|
80
|
-
title = middleEllipsis(name, Math.floor(Math.max(18, width / 2 / 9)));
|
|
81
|
-
} else {
|
|
82
|
-
title = middleEllipsis(name, Math.floor(Math.max(25, width / 3 / 8)));
|
|
83
|
-
}
|
|
84
|
-
return /*#__PURE__*/React.createElement(Card, {
|
|
85
|
-
image: /*#__PURE__*/React.createElement("button", {
|
|
86
|
-
className: classNames(['d-block', 'position-relative', 'p-0', 'border-0', 'w-100', 'text-start', 'bg-dark', 'text-black', styles$b.imageButton]),
|
|
87
|
-
type: "button",
|
|
88
|
-
onClick: onClick
|
|
89
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
90
|
-
className: classNames(['card-img-top', styles$b.image]),
|
|
91
|
-
style: {
|
|
92
|
-
backgroundImage: thumbnail !== null ? "url('".concat(thumbnail, "')") : null
|
|
93
|
-
}
|
|
94
|
-
})),
|
|
95
|
-
beforeBody: /*#__PURE__*/React.createElement(React.Fragment, null, withInfoButton ? /*#__PURE__*/React.createElement(Button, {
|
|
96
|
-
className: styles$b.infoButton,
|
|
97
|
-
onClick: onClickInfo,
|
|
98
|
-
withoutStyle: true
|
|
99
|
-
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
100
|
-
icon: faInfoCircle,
|
|
101
|
-
className: styles$b.icon
|
|
102
|
-
})) : null, selected ? /*#__PURE__*/React.createElement(Button, {
|
|
103
|
-
className: classNames(['text-danger', styles$b.closeButton]),
|
|
104
|
-
onClick: onClickRemove,
|
|
105
|
-
withoutStyle: true
|
|
106
|
-
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
107
|
-
icon: faTimesCircle,
|
|
108
|
-
className: styles$b.icon
|
|
109
|
-
})) : null),
|
|
110
|
-
footer: /*#__PURE__*/React.createElement(React.Fragment, null, type === 'video' ? /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
111
|
-
className: styles$b.icon,
|
|
112
|
-
icon: faPlayCircle
|
|
113
|
-
}) : null, type === 'audio' ? /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
114
|
-
className: styles$b.icon,
|
|
115
|
-
icon: faHeadphonesAlt
|
|
116
|
-
}) : null, /*#__PURE__*/React.createElement("div", {
|
|
117
|
-
className: classNames(['text-truncate', styles$b.label])
|
|
118
|
-
}, /*#__PURE__*/React.createElement("small", null, title), size !== null ? /*#__PURE__*/React.createElement("small", {
|
|
119
|
-
className: "text-body-secondary ms-1"
|
|
120
|
-
}, size) : null)),
|
|
121
|
-
theme: selected ? null : null,
|
|
122
|
-
className: classNames([styles$b.container, _defineProperty(_defineProperty({}, styles$b.selected, selected), className, className !== null)]),
|
|
123
|
-
footerClassName: classNames(['p-1', styles$b.footer]),
|
|
124
|
-
onClickFooter: onClick
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
GalleryItem.propTypes = propTypes$b;
|
|
128
|
-
GalleryItem.defaultProps = defaultProps$b;
|
|
129
|
-
var GalleryItem$1 = GalleryItem;
|
|
130
|
-
|
|
131
|
-
var styles$a = {};
|
|
132
|
-
|
|
133
|
-
var propTypes$a = {
|
|
134
|
-
items: PropTypes.medias,
|
|
135
|
-
selectedItem: PropTypes.media,
|
|
136
|
-
withInfoButton: PropTypes$1.bool,
|
|
137
|
-
isSmall: PropTypes$1.bool,
|
|
138
|
-
selectedFirst: PropTypes$1.bool,
|
|
139
|
-
className: PropTypes$1.string,
|
|
140
|
-
onClickItem: PropTypes$1.func,
|
|
141
|
-
onClickItemInfo: PropTypes$1.func,
|
|
142
|
-
onClickRemoveItem: PropTypes$1.func
|
|
143
|
-
};
|
|
144
|
-
var defaultProps$a = {
|
|
145
|
-
items: null,
|
|
146
|
-
selectedItem: null,
|
|
147
|
-
withInfoButton: false,
|
|
148
|
-
isSmall: false,
|
|
149
|
-
selectedFirst: false,
|
|
150
|
-
className: null,
|
|
151
|
-
onClickItem: null,
|
|
152
|
-
onClickItemInfo: null,
|
|
153
|
-
onClickRemoveItem: null
|
|
154
|
-
};
|
|
155
|
-
function Gallery(_ref) {
|
|
156
|
-
var items = _ref.items,
|
|
157
|
-
selectedItem = _ref.selectedItem,
|
|
158
|
-
withInfoButton = _ref.withInfoButton,
|
|
159
|
-
isSmall = _ref.isSmall,
|
|
160
|
-
selectedFirst = _ref.selectedFirst,
|
|
161
|
-
className = _ref.className,
|
|
162
|
-
onClickItem = _ref.onClickItem,
|
|
163
|
-
onClickItemInfo = _ref.onClickItemInfo,
|
|
164
|
-
onClickRemoveItem = _ref.onClickRemoveItem;
|
|
165
|
-
var _useDimensionObserver = useDimensionObserver(),
|
|
166
|
-
ref = _useDimensionObserver.ref,
|
|
167
|
-
width = _useDimensionObserver.width;
|
|
168
|
-
var finalItems = useMemo(function () {
|
|
169
|
-
if (selectedFirst && selectedItem !== null && typeof selectedItem.id !== 'undefined') {
|
|
170
|
-
return [selectedItem].concat(_toConsumableArray(items.filter(function (_ref2) {
|
|
171
|
-
var id = _ref2.id;
|
|
172
|
-
return id !== selectedItem.id;
|
|
173
|
-
})));
|
|
174
|
-
}
|
|
175
|
-
return items;
|
|
176
|
-
}, [selectedFirst, selectedItem, items]);
|
|
177
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
178
|
-
className: classNames([styles$a.container, 'p-2', 'pt-0', _defineProperty({}, className, className !== null)]),
|
|
179
|
-
ref: ref
|
|
180
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
181
|
-
className: classNames(['row', 'mx-n1', 'row-cols-2', {
|
|
182
|
-
'row-cols-md-3': !isSmall
|
|
183
|
-
}])
|
|
184
|
-
}, finalItems.map(function (item) {
|
|
185
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
186
|
-
className: "col px-1 py-1",
|
|
187
|
-
key: "gallery-item-".concat(item.id)
|
|
188
|
-
}, /*#__PURE__*/React.createElement(GalleryItem$1, {
|
|
189
|
-
item: item,
|
|
190
|
-
width: width,
|
|
191
|
-
selected: selectedItem !== null && selectedItem.id === item.id,
|
|
192
|
-
onClick: onClickItem !== null ? function () {
|
|
193
|
-
return onClickItem(item);
|
|
194
|
-
} : null,
|
|
195
|
-
onClickInfo: onClickItemInfo !== null ? function () {
|
|
196
|
-
return onClickItemInfo(item);
|
|
197
|
-
} : null,
|
|
198
|
-
onClickRemove: onClickRemoveItem !== null ? function () {
|
|
199
|
-
onClickRemoveItem();
|
|
200
|
-
} : null,
|
|
201
|
-
withInfoButton: withInfoButton
|
|
202
|
-
}));
|
|
203
|
-
})));
|
|
204
|
-
}
|
|
205
|
-
Gallery.propTypes = propTypes$a;
|
|
206
|
-
Gallery.defaultProps = defaultProps$a;
|
|
207
|
-
|
|
208
|
-
var styles$9 = {"container":"micromag-media-gallery-partials-media-metadata-container","image":"micromag-media-gallery-partials-media-metadata-image","video":"micromag-media-gallery-partials-media-metadata-video","player":"micromag-media-gallery-partials-media-metadata-player","audio":"micromag-media-gallery-partials-media-metadata-audio","placeholder":"micromag-media-gallery-partials-media-metadata-placeholder"};
|
|
209
|
-
|
|
210
|
-
var propTypes$9 = {
|
|
211
|
-
media: PropTypes.media,
|
|
212
|
-
tags: PropTypes.tags,
|
|
213
|
-
onChange: PropTypes$1.func,
|
|
214
|
-
onClickClose: PropTypes$1.func,
|
|
215
|
-
onClickSave: PropTypes$1.func,
|
|
216
|
-
onClickDelete: PropTypes$1.func,
|
|
217
|
-
className: PropTypes$1.string
|
|
218
|
-
};
|
|
219
|
-
var defaultProps$9 = {
|
|
220
|
-
media: null,
|
|
221
|
-
tags: [],
|
|
222
|
-
onChange: null,
|
|
223
|
-
onClickClose: null,
|
|
224
|
-
onClickSave: null,
|
|
225
|
-
onClickDelete: null,
|
|
226
|
-
className: null
|
|
227
|
-
};
|
|
228
|
-
function MediaMetadata(_ref) {
|
|
229
|
-
var media = _ref.media,
|
|
230
|
-
allTags = _ref.tags,
|
|
231
|
-
onChange = _ref.onChange,
|
|
232
|
-
onClickClose = _ref.onClickClose,
|
|
233
|
-
onClickSave = _ref.onClickSave,
|
|
234
|
-
onClickDelete = _ref.onClickDelete,
|
|
235
|
-
className = _ref.className;
|
|
236
|
-
var _ref2 = media || {},
|
|
237
|
-
mediaId = _ref2.id,
|
|
238
|
-
type = _ref2.type,
|
|
239
|
-
_ref2$url = _ref2.url,
|
|
240
|
-
url = _ref2$url === void 0 ? null : _ref2$url,
|
|
241
|
-
_ref2$thumbnail_url = _ref2.thumbnail_url,
|
|
242
|
-
thumbnail = _ref2$thumbnail_url === void 0 ? null : _ref2$thumbnail_url,
|
|
243
|
-
_ref2$name = _ref2.name,
|
|
244
|
-
mediaName = _ref2$name === void 0 ? null : _ref2$name,
|
|
245
|
-
_ref2$metadata = _ref2.metadata,
|
|
246
|
-
metadata = _ref2$metadata === void 0 ? {} : _ref2$metadata;
|
|
247
|
-
var _ref3 = metadata || {},
|
|
248
|
-
_ref3$filename = _ref3.filename,
|
|
249
|
-
filename = _ref3$filename === void 0 ? null : _ref3$filename,
|
|
250
|
-
_ref3$size = _ref3.size,
|
|
251
|
-
size = _ref3$size === void 0 ? null : _ref3$size,
|
|
252
|
-
_ref3$width = _ref3.width,
|
|
253
|
-
width = _ref3$width === void 0 ? null : _ref3$width,
|
|
254
|
-
_ref3$height = _ref3.height,
|
|
255
|
-
height = _ref3$height === void 0 ? null : _ref3$height,
|
|
256
|
-
_ref3$duration = _ref3.duration,
|
|
257
|
-
duration = _ref3$duration === void 0 ? null : _ref3$duration,
|
|
258
|
-
_ref3$user = _ref3.user,
|
|
259
|
-
user = _ref3$user === void 0 ? null : _ref3$user,
|
|
260
|
-
_ref3$description = _ref3.description,
|
|
261
|
-
mediaDescription = _ref3$description === void 0 ? null : _ref3$description,
|
|
262
|
-
_ref3$tags = _ref3.tags,
|
|
263
|
-
mediaTags = _ref3$tags === void 0 ? [] : _ref3$tags;
|
|
264
|
-
var _useMediaUpdate = useMediaUpdate(),
|
|
265
|
-
update = _useMediaUpdate.update;
|
|
266
|
-
var _useMediaRequestDelet = useMediaRequestDelete(),
|
|
267
|
-
requestDeleteMedia = _useMediaRequestDelet.requestDeleteMedia;
|
|
268
|
-
var _useMediaDelete = useMediaDelete(),
|
|
269
|
-
deleteMedia = _useMediaDelete.deleteMedia;
|
|
270
|
-
var getOptionLabel = useCallback(function (_ref4) {
|
|
271
|
-
var name = _ref4.name;
|
|
272
|
-
return name;
|
|
273
|
-
}, []);
|
|
274
|
-
var getOptionValue = useCallback(function (_ref5) {
|
|
275
|
-
var name = _ref5.name;
|
|
276
|
-
return name;
|
|
277
|
-
}, []);
|
|
278
|
-
var getNewOptionData = useCallback(function (inputValue) {
|
|
279
|
-
return {
|
|
280
|
-
name: inputValue
|
|
281
|
-
};
|
|
282
|
-
}, []);
|
|
283
|
-
var finalTags = useMemo(function () {
|
|
284
|
-
return allTags !== null ? uniqBy(mediaTags.concat(allTags), function (_ref6) {
|
|
285
|
-
var id = _ref6.id;
|
|
286
|
-
return id;
|
|
287
|
-
}) : mediaTags;
|
|
288
|
-
}, [mediaTags, allTags]);
|
|
289
|
-
var _useState = useState(mediaName),
|
|
290
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
291
|
-
name = _useState2[0],
|
|
292
|
-
setName = _useState2[1];
|
|
293
|
-
var _useState3 = useState(mediaDescription),
|
|
294
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
295
|
-
description = _useState4[0],
|
|
296
|
-
setDescription = _useState4[1];
|
|
297
|
-
var _useState5 = useState(mediaTags.map(getOptionValue)),
|
|
298
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
299
|
-
tags = _useState6[0],
|
|
300
|
-
setTags = _useState6[1];
|
|
301
|
-
var _useState7 = useState(false),
|
|
302
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
303
|
-
changed = _useState8[0],
|
|
304
|
-
setChanged = _useState8[1];
|
|
305
|
-
var onTagChange = useCallback(function (val) {
|
|
306
|
-
setTags(val);
|
|
307
|
-
setChanged(true);
|
|
308
|
-
}, [tags, setTags, setChanged]);
|
|
309
|
-
var onNameChange = useCallback(function (val) {
|
|
310
|
-
setName(val);
|
|
311
|
-
setChanged(true);
|
|
312
|
-
}, [tags, setName, setChanged]);
|
|
313
|
-
var onDescriptionChange = useCallback(function (val) {
|
|
314
|
-
setDescription(val);
|
|
315
|
-
setChanged(true);
|
|
316
|
-
}, [tags, setDescription, setChanged]);
|
|
317
|
-
var _useState9 = useState(null),
|
|
318
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
319
|
-
saveState = _useState10[0],
|
|
320
|
-
setSaveState = _useState10[1];
|
|
321
|
-
var onSave = useCallback(function () {
|
|
322
|
-
return update(mediaId, {
|
|
323
|
-
name: name,
|
|
324
|
-
tags: tags,
|
|
325
|
-
description: description
|
|
326
|
-
}).then(function (response) {
|
|
327
|
-
setChanged(false);
|
|
328
|
-
setSaveState(null);
|
|
329
|
-
if (onClickSave !== null) {
|
|
330
|
-
onClickSave();
|
|
331
|
-
}
|
|
332
|
-
if (onChange !== null) {
|
|
333
|
-
onChange(response);
|
|
334
|
-
}
|
|
335
|
-
})["catch"](function () {
|
|
336
|
-
setSaveState(false);
|
|
337
|
-
});
|
|
338
|
-
}, [mediaId, name, tags, description, metadata, update, onChange, onClickSave, onClickClose, setChanged, setSaveState]);
|
|
339
|
-
var _useState11 = useState(null),
|
|
340
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
341
|
-
deletedState = _useState12[0],
|
|
342
|
-
setDeletedState = _useState12[1];
|
|
343
|
-
var _useState13 = useState(null),
|
|
344
|
-
_useState14 = _slicedToArray(_useState13, 2),
|
|
345
|
-
confirmation = _useState14[0],
|
|
346
|
-
setConfirmation = _useState14[1];
|
|
347
|
-
useEffect(function () {
|
|
348
|
-
setDeletedState(null);
|
|
349
|
-
setConfirmation(null);
|
|
350
|
-
}, [mediaId, setDeletedState, setConfirmation]);
|
|
351
|
-
var onConfirm = useCallback(function () {
|
|
352
|
-
requestDeleteMedia(mediaId).then(function (response) {
|
|
353
|
-
var _ref7 = response || {},
|
|
354
|
-
state = _ref7.state,
|
|
355
|
-
_ref7$items = _ref7.items,
|
|
356
|
-
items = _ref7$items === void 0 ? [] : _ref7$items;
|
|
357
|
-
if (state === 'needs_confirmation') {
|
|
358
|
-
setConfirmation(items || []);
|
|
359
|
-
} else {
|
|
360
|
-
setConfirmation(null);
|
|
361
|
-
}
|
|
362
|
-
})["catch"](function () {
|
|
363
|
-
setConfirmation(null);
|
|
364
|
-
});
|
|
365
|
-
}, [mediaId, requestDeleteMedia, setConfirmation]);
|
|
366
|
-
var onDelete = useCallback(function () {
|
|
367
|
-
deleteMedia(mediaId).then(function () {
|
|
368
|
-
setChanged(false);
|
|
369
|
-
setDeletedState(true);
|
|
370
|
-
setConfirmation(null);
|
|
371
|
-
if (onClickDelete !== null) {
|
|
372
|
-
onClickDelete(mediaId);
|
|
373
|
-
}
|
|
374
|
-
})["catch"](function () {
|
|
375
|
-
setDeletedState(false);
|
|
376
|
-
setConfirmation(null);
|
|
377
|
-
});
|
|
378
|
-
}, [mediaId, deleteMedia, onClickDelete, setChanged, setDeletedState, setConfirmation]);
|
|
379
|
-
var onCancelDelete = useCallback(function () {
|
|
380
|
-
setConfirmation(null);
|
|
381
|
-
setDeletedState(null);
|
|
382
|
-
}, [setConfirmation, setDeletedState]);
|
|
383
|
-
useEffect(function () {
|
|
384
|
-
if (media !== null) {
|
|
385
|
-
setTags(mediaTags);
|
|
386
|
-
setName(mediaName);
|
|
387
|
-
setDescription(mediaDescription);
|
|
388
|
-
} else {
|
|
389
|
-
setTags([]);
|
|
390
|
-
setName(null);
|
|
391
|
-
setDescription(null);
|
|
392
|
-
}
|
|
393
|
-
setChanged(false);
|
|
394
|
-
}, [media, setTags, setName, setDescription, setChanged]);
|
|
395
|
-
var TextField = useFieldComponent('text');
|
|
396
|
-
var TokensField = useFieldComponent('tokens');
|
|
397
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
398
|
-
className: classNames([styles$9.container, _defineProperty({}, className, className)])
|
|
399
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
400
|
-
className: classNames(['position-relative', _defineProperty({
|
|
401
|
-
'bg-light': type === 'audio',
|
|
402
|
-
'bg-black': type === 'image'
|
|
403
|
-
}, styles$9.video, type === 'video')])
|
|
404
|
-
}, type === 'video' ? /*#__PURE__*/React.createElement("video", {
|
|
405
|
-
className: styles$9.player,
|
|
406
|
-
controls: true,
|
|
407
|
-
src: url
|
|
408
|
-
}) : null, type === 'audio' ? /*#__PURE__*/React.createElement("div", {
|
|
409
|
-
className: styles$9.audio
|
|
410
|
-
}, /*#__PURE__*/React.createElement("audio", {
|
|
411
|
-
className: styles$9.player,
|
|
412
|
-
controls: true,
|
|
413
|
-
src: url
|
|
414
|
-
})) : null, type !== 'video' && thumbnail !== null ? /*#__PURE__*/React.createElement("img", {
|
|
415
|
-
src: thumbnail,
|
|
416
|
-
className: styles$9.image,
|
|
417
|
-
alt: filename
|
|
418
|
-
}) : /*#__PURE__*/React.createElement("div", {
|
|
419
|
-
className: styles$9.placeholder
|
|
420
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
421
|
-
className: "p-2"
|
|
422
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
423
|
-
className: "tags mb-4"
|
|
424
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
425
|
-
className: "my-3"
|
|
426
|
-
}, /*#__PURE__*/React.createElement("h6", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
427
|
-
id: "kBz8vF",
|
|
10
|
+
import { MediasPickerContainer, MediasBrowserContainer } from '@panneau/medias';
|
|
11
|
+
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
12
|
+
import { UploadModal } from '@micromag/core/components';
|
|
13
|
+
import { useApi, useMediaCreate } from '@micromag/data';
|
|
14
|
+
import { FormattedMessage } from 'react-intl';
|
|
15
|
+
import { useUrlGenerator } from '@folklore/routes';
|
|
16
|
+
|
|
17
|
+
var defaultColumns = [{
|
|
18
|
+
id: 'image',
|
|
19
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
20
|
+
id: "UbxbKP",
|
|
428
21
|
defaultMessage: [{
|
|
429
22
|
"type": 0,
|
|
430
|
-
"value": "
|
|
23
|
+
"value": "Preview"
|
|
431
24
|
}]
|
|
432
|
-
})
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
id: "YJZtWR",
|
|
441
|
-
defaultMessage: [{
|
|
442
|
-
"type": 0,
|
|
443
|
-
"value": "Description"
|
|
444
|
-
}]
|
|
445
|
-
})), /*#__PURE__*/React.createElement("p", {
|
|
446
|
-
className: "mb-1"
|
|
447
|
-
}, /*#__PURE__*/React.createElement("small", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
448
|
-
id: "EDFyUp",
|
|
449
|
-
defaultMessage: [{
|
|
450
|
-
"type": 0,
|
|
451
|
-
"value": "Alternative text (accessibility)"
|
|
452
|
-
}]
|
|
453
|
-
}))), /*#__PURE__*/React.createElement(TextField, {
|
|
454
|
-
value: description,
|
|
455
|
-
onChange: onDescriptionChange
|
|
456
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
457
|
-
className: "my-3"
|
|
458
|
-
}, /*#__PURE__*/React.createElement("h6", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
459
|
-
id: "4fHMVj",
|
|
460
|
-
defaultMessage: [{
|
|
461
|
-
"type": 0,
|
|
462
|
-
"value": "Tags"
|
|
463
|
-
}]
|
|
464
|
-
})), /*#__PURE__*/React.createElement(TokensField, {
|
|
465
|
-
value: tags,
|
|
466
|
-
options: finalTags
|
|
467
|
-
// loadOptions={loadTags}
|
|
468
|
-
,
|
|
469
|
-
getOptionLabel: getOptionLabel,
|
|
470
|
-
getOptionValue: getOptionValue,
|
|
471
|
-
getNewOptionData: getNewOptionData,
|
|
472
|
-
onChange: onTagChange
|
|
473
|
-
})), changed ? /*#__PURE__*/React.createElement(Button, {
|
|
474
|
-
theme: "primary",
|
|
475
|
-
onClick: onSave
|
|
476
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
477
|
-
id: "qIw1nW",
|
|
478
|
-
defaultMessage: [{
|
|
479
|
-
"type": 0,
|
|
480
|
-
"value": "Save"
|
|
481
|
-
}]
|
|
482
|
-
})) : null, saveState === false ? /*#__PURE__*/React.createElement("p", {
|
|
483
|
-
className: "pt-1 text-danger"
|
|
484
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
485
|
-
id: "DYjRd/",
|
|
486
|
-
defaultMessage: [{
|
|
487
|
-
"type": 0,
|
|
488
|
-
"value": "Sorry, this media could not be saved."
|
|
489
|
-
}]
|
|
490
|
-
})) : null), /*#__PURE__*/React.createElement("h6", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
491
|
-
id: "c9VwT/",
|
|
492
|
-
defaultMessage: [{
|
|
493
|
-
"type": 0,
|
|
494
|
-
"value": "Technical details"
|
|
495
|
-
}]
|
|
496
|
-
})), /*#__PURE__*/React.createElement("ul", {
|
|
497
|
-
className: "list-group"
|
|
498
|
-
}, type !== null ? /*#__PURE__*/React.createElement("li", {
|
|
499
|
-
className: "list-group-item py-2 px-2"
|
|
500
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
501
|
-
className: "row"
|
|
502
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
503
|
-
className: "col-4 text-body-secondary"
|
|
504
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
505
|
-
id: "OkNUmk",
|
|
506
|
-
defaultMessage: [{
|
|
507
|
-
"type": 0,
|
|
508
|
-
"value": "Type"
|
|
509
|
-
}]
|
|
510
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
511
|
-
className: "col text-capitalize"
|
|
512
|
-
}, /*#__PURE__*/React.createElement("small", null, type)))) : null, filename !== null ? /*#__PURE__*/React.createElement("li", {
|
|
513
|
-
className: "list-group-item py-2 px-2"
|
|
514
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
515
|
-
className: "row"
|
|
516
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
517
|
-
className: "col-4 text-body-secondary"
|
|
518
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
519
|
-
id: "aovRFH",
|
|
520
|
-
defaultMessage: [{
|
|
521
|
-
"type": 0,
|
|
522
|
-
"value": "Filename"
|
|
523
|
-
}]
|
|
524
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
525
|
-
className: "col"
|
|
526
|
-
}, /*#__PURE__*/React.createElement("small", null, filename)))) : null, duration ? /*#__PURE__*/React.createElement("li", {
|
|
527
|
-
className: "list-group-item py-2 px-2"
|
|
528
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
529
|
-
className: "row"
|
|
530
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
531
|
-
className: "col-4 text-body-secondary"
|
|
532
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
533
|
-
id: "eoW0tZ",
|
|
25
|
+
}),
|
|
26
|
+
component: 'image',
|
|
27
|
+
path: 'thumbnail_url',
|
|
28
|
+
sortable: false
|
|
29
|
+
}, {
|
|
30
|
+
id: 'name',
|
|
31
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
32
|
+
id: "WX83V9",
|
|
534
33
|
defaultMessage: [{
|
|
535
34
|
"type": 0,
|
|
536
|
-
"value": "
|
|
35
|
+
"value": "File name"
|
|
537
36
|
}]
|
|
538
|
-
})
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
37
|
+
}),
|
|
38
|
+
component: 'text-description',
|
|
39
|
+
path: 'name',
|
|
40
|
+
descriptionPath: 'type',
|
|
41
|
+
descriptionValues: {
|
|
42
|
+
image: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
43
|
+
id: "AwDQvD",
|
|
44
|
+
defaultMessage: [{
|
|
45
|
+
"type": 0,
|
|
46
|
+
"value": "Image"
|
|
47
|
+
}]
|
|
48
|
+
}),
|
|
49
|
+
video: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
50
|
+
id: "mQiyAm",
|
|
51
|
+
defaultMessage: [{
|
|
52
|
+
"type": 0,
|
|
53
|
+
"value": "Video"
|
|
54
|
+
}]
|
|
55
|
+
}),
|
|
56
|
+
audio: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
57
|
+
id: "XnyI69",
|
|
58
|
+
defaultMessage: [{
|
|
59
|
+
"type": 0,
|
|
60
|
+
"value": "Audio"
|
|
61
|
+
}]
|
|
62
|
+
}),
|
|
63
|
+
document: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
64
|
+
id: "1dqmFw",
|
|
65
|
+
defaultMessage: [{
|
|
66
|
+
"type": 0,
|
|
67
|
+
"value": "Document"
|
|
68
|
+
}]
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
sortable: true
|
|
72
|
+
}, {
|
|
73
|
+
id: 'dimensions',
|
|
74
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
75
|
+
id: "eCe9ZY",
|
|
548
76
|
defaultMessage: [{
|
|
549
77
|
"type": 0,
|
|
550
|
-
"value": "
|
|
78
|
+
"value": "Dimensions"
|
|
551
79
|
}]
|
|
552
|
-
})
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
561
|
-
id: "liyV7Y",
|
|
80
|
+
}),
|
|
81
|
+
component: 'unit',
|
|
82
|
+
format: 'dimensions',
|
|
83
|
+
path: 'metadata'
|
|
84
|
+
}, {
|
|
85
|
+
id: 'size',
|
|
86
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
87
|
+
id: "c3hu9o",
|
|
562
88
|
defaultMessage: [{
|
|
563
89
|
"type": 0,
|
|
564
90
|
"value": "Size"
|
|
565
91
|
}]
|
|
566
|
-
})
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
575
|
-
id: "7uyslu",
|
|
576
|
-
defaultMessage: [{
|
|
577
|
-
"type": 0,
|
|
578
|
-
"value": "Description"
|
|
579
|
-
}]
|
|
580
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
581
|
-
className: "col"
|
|
582
|
-
}, /*#__PURE__*/React.createElement("small", null, description)))) : null, user !== null && user.name ? /*#__PURE__*/React.createElement("li", {
|
|
583
|
-
className: "list-group-item py-2 px-2"
|
|
584
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
585
|
-
className: "row"
|
|
586
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
587
|
-
className: "col-4 text-body-secondary"
|
|
588
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
589
|
-
id: "sUR1xV",
|
|
92
|
+
}),
|
|
93
|
+
component: 'unit',
|
|
94
|
+
format: 'bytes',
|
|
95
|
+
path: 'metadata.size'
|
|
96
|
+
}, {
|
|
97
|
+
id: 'duration',
|
|
98
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
99
|
+
id: "002oWQ",
|
|
590
100
|
defaultMessage: [{
|
|
591
101
|
"type": 0,
|
|
592
|
-
"value": "
|
|
102
|
+
"value": "Duration"
|
|
593
103
|
}]
|
|
594
|
-
})
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
104
|
+
}),
|
|
105
|
+
component: 'unit',
|
|
106
|
+
format: 'duration',
|
|
107
|
+
path: 'metadata.duration'
|
|
108
|
+
},
|
|
109
|
+
// {
|
|
110
|
+
// id: 'author',
|
|
111
|
+
// label: <FormattedMessage defaultMessage="Added by" description="Field name" />,
|
|
112
|
+
// component: 'avatar',
|
|
113
|
+
// path: 'metadata.author',
|
|
114
|
+
// namePath: 'name',
|
|
115
|
+
// withoutName: true,
|
|
116
|
+
// },
|
|
117
|
+
{
|
|
118
|
+
id: 'created_at',
|
|
119
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
120
|
+
id: "OzYWZz",
|
|
602
121
|
defaultMessage: [{
|
|
603
122
|
"type": 0,
|
|
604
|
-
"value": "
|
|
123
|
+
"value": "Created at"
|
|
605
124
|
}]
|
|
606
|
-
})
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
id: "
|
|
125
|
+
}),
|
|
126
|
+
component: 'date',
|
|
127
|
+
path: 'created_at',
|
|
128
|
+
format: 'yyyy-MM-dd hh:ss',
|
|
129
|
+
sortable: true
|
|
130
|
+
}, {
|
|
131
|
+
id: 'actions',
|
|
132
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
133
|
+
id: "rtwfuZ",
|
|
615
134
|
defaultMessage: [{
|
|
616
135
|
"type": 0,
|
|
617
|
-
"value": "
|
|
136
|
+
"value": "Actions"
|
|
618
137
|
}]
|
|
619
|
-
})
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
138
|
+
}),
|
|
139
|
+
actions: ['edit', 'delete']
|
|
140
|
+
// component: ItemActions,
|
|
141
|
+
// label: 'Edit',
|
|
142
|
+
// url: '/edit/1',
|
|
143
|
+
}
|
|
144
|
+
// {
|
|
145
|
+
// id: 'status',
|
|
146
|
+
// label: <FormattedMessage defaultMessage="Status" description="Field name" />,
|
|
147
|
+
// component: 'text',
|
|
148
|
+
// path: 'metadata.status',
|
|
149
|
+
// },
|
|
150
|
+
];
|
|
151
|
+
|
|
152
|
+
var defaultFields = [{
|
|
153
|
+
name: 'name',
|
|
154
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
155
|
+
id: "WX83V9",
|
|
628
156
|
defaultMessage: [{
|
|
629
157
|
"type": 0,
|
|
630
|
-
"value": "
|
|
158
|
+
"value": "File name"
|
|
631
159
|
}]
|
|
632
|
-
})
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
160
|
+
}),
|
|
161
|
+
type: 'text',
|
|
162
|
+
component: 'text'
|
|
163
|
+
}, {
|
|
164
|
+
name: 'description',
|
|
165
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
166
|
+
id: "ygNvmz",
|
|
638
167
|
defaultMessage: [{
|
|
639
168
|
"type": 0,
|
|
640
|
-
"value": "
|
|
169
|
+
"value": "Description"
|
|
641
170
|
}]
|
|
642
|
-
})
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
171
|
+
}),
|
|
172
|
+
type: 'text',
|
|
173
|
+
component: 'text'
|
|
174
|
+
}, {
|
|
175
|
+
id: 'info',
|
|
176
|
+
component: 'fields',
|
|
177
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
178
|
+
id: "3RT69u",
|
|
646
179
|
defaultMessage: [{
|
|
647
180
|
"type": 0,
|
|
648
|
-
"value": "
|
|
181
|
+
"value": "Informations"
|
|
649
182
|
}]
|
|
650
|
-
})
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
var useSearchFilters = function useSearchFilters(_ref) {
|
|
656
|
-
var _ref$recent = _ref.recent,
|
|
657
|
-
recent = _ref$recent === void 0 ? [] : _ref$recent,
|
|
658
|
-
_ref$tags = _ref.tags,
|
|
659
|
-
tags = _ref$tags === void 0 ? [] : _ref$tags,
|
|
660
|
-
_ref$team = _ref.team,
|
|
661
|
-
team = _ref$team === void 0 ? [] : _ref$team,
|
|
662
|
-
_ref$sources = _ref.sources,
|
|
663
|
-
upstreamSources = _ref$sources === void 0 ? [] : _ref$sources,
|
|
664
|
-
_ref$withType = _ref.withType,
|
|
665
|
-
withType = _ref$withType === void 0 ? false : _ref$withType,
|
|
666
|
-
_ref$storyId = _ref.storyId,
|
|
667
|
-
storyId = _ref$storyId === void 0 ? null : _ref$storyId;
|
|
668
|
-
var sources = [].concat(_toConsumableArray(storyId !== null ? [{
|
|
669
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
670
|
-
id: "eiaIIB",
|
|
671
|
-
defaultMessage: [{
|
|
672
|
-
"type": 0,
|
|
673
|
-
"value": "This Micromag"
|
|
674
|
-
}]
|
|
675
|
-
}),
|
|
676
|
-
value: "document-".concat(storyId)
|
|
677
|
-
}] : []), [{
|
|
183
|
+
}),
|
|
184
|
+
isList: true,
|
|
185
|
+
hideWithoutValue: true,
|
|
186
|
+
fields: [{
|
|
187
|
+
id: 'user',
|
|
678
188
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
679
|
-
id: "
|
|
189
|
+
id: "yByaBh",
|
|
680
190
|
defaultMessage: [{
|
|
681
191
|
"type": 0,
|
|
682
|
-
"value": "
|
|
192
|
+
"value": "Added by"
|
|
683
193
|
}]
|
|
684
194
|
}),
|
|
685
|
-
|
|
686
|
-
|
|
195
|
+
type: 'display',
|
|
196
|
+
display: 'avatar',
|
|
197
|
+
name: 'user',
|
|
198
|
+
horizontal: true
|
|
199
|
+
}, {
|
|
200
|
+
id: 'created_at',
|
|
687
201
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
688
|
-
id: "
|
|
202
|
+
id: "PN+75e",
|
|
689
203
|
defaultMessage: [{
|
|
690
204
|
"type": 0,
|
|
691
|
-
"value": "
|
|
205
|
+
"value": "Created at"
|
|
692
206
|
}]
|
|
693
207
|
}),
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
208
|
+
type: 'display',
|
|
209
|
+
display: 'date',
|
|
210
|
+
name: 'created_at',
|
|
211
|
+
format: 'yyyy-MM-dd hh:ss',
|
|
212
|
+
horizontal: true
|
|
213
|
+
}]
|
|
214
|
+
}, {
|
|
215
|
+
id: 'technical',
|
|
216
|
+
component: 'fields',
|
|
217
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
218
|
+
id: "xKUOLG",
|
|
219
|
+
defaultMessage: [{
|
|
220
|
+
"type": 0,
|
|
221
|
+
"value": "Technical details"
|
|
222
|
+
}]
|
|
223
|
+
}),
|
|
224
|
+
isList: true,
|
|
225
|
+
hideWithoutValue: true,
|
|
226
|
+
fields: [{
|
|
227
|
+
id: 'format',
|
|
699
228
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
700
|
-
id: "
|
|
229
|
+
id: "JuxiUN",
|
|
701
230
|
defaultMessage: [{
|
|
702
231
|
"type": 0,
|
|
703
|
-
"value": "
|
|
232
|
+
"value": "Format"
|
|
704
233
|
}]
|
|
705
234
|
}),
|
|
706
|
-
|
|
235
|
+
type: 'display',
|
|
236
|
+
display: 'unit',
|
|
237
|
+
format: 'format',
|
|
238
|
+
name: 'format',
|
|
239
|
+
horizontal: true
|
|
707
240
|
}, {
|
|
241
|
+
id: 'dimensions',
|
|
708
242
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
709
|
-
id: "
|
|
243
|
+
id: "rmJBin",
|
|
710
244
|
defaultMessage: [{
|
|
711
245
|
"type": 0,
|
|
712
|
-
"value": "
|
|
246
|
+
"value": "Dimensions"
|
|
713
247
|
}]
|
|
714
248
|
}),
|
|
715
|
-
|
|
249
|
+
type: 'display',
|
|
250
|
+
display: 'unit',
|
|
251
|
+
format: 'dimensions',
|
|
252
|
+
name: 'metadata',
|
|
253
|
+
horizontal: true
|
|
716
254
|
}, {
|
|
255
|
+
id: 'size',
|
|
717
256
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
718
|
-
id: "
|
|
257
|
+
id: "g2CRt5",
|
|
719
258
|
defaultMessage: [{
|
|
720
259
|
"type": 0,
|
|
721
|
-
"value": "
|
|
260
|
+
"value": "Size"
|
|
722
261
|
}]
|
|
723
262
|
}),
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
defaultMessage: [{
|
|
730
|
-
"type": 0,
|
|
731
|
-
"value": "Unused"
|
|
732
|
-
}]
|
|
733
|
-
}),
|
|
734
|
-
value: 'unused'
|
|
263
|
+
type: 'display',
|
|
264
|
+
display: 'unit',
|
|
265
|
+
format: 'bytes',
|
|
266
|
+
name: 'metadata.size',
|
|
267
|
+
horizontal: true
|
|
735
268
|
}, {
|
|
269
|
+
id: 'duration',
|
|
736
270
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
737
|
-
id: "
|
|
738
|
-
defaultMessage: [{
|
|
739
|
-
"type": 0,
|
|
740
|
-
"value": "Used"
|
|
741
|
-
}]
|
|
742
|
-
}),
|
|
743
|
-
value: 'used'
|
|
744
|
-
}];
|
|
745
|
-
var sections = [withType ? {
|
|
746
|
-
value: 'types',
|
|
747
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
748
|
-
id: "/ca7BX",
|
|
271
|
+
id: "wU++NJ",
|
|
749
272
|
defaultMessage: [{
|
|
750
273
|
"type": 0,
|
|
751
|
-
"value": "
|
|
274
|
+
"value": "Duration"
|
|
752
275
|
}]
|
|
753
276
|
}),
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
277
|
+
type: 'display',
|
|
278
|
+
display: 'unit',
|
|
279
|
+
format: 'duration',
|
|
280
|
+
name: 'metadata.duration',
|
|
281
|
+
horizontal: true
|
|
282
|
+
}]
|
|
283
|
+
}];
|
|
284
|
+
|
|
285
|
+
function filters() {
|
|
286
|
+
var route = useUrlGenerator();
|
|
287
|
+
return [{
|
|
288
|
+
id: 'search',
|
|
289
|
+
component: 'search',
|
|
290
|
+
name: 'search'
|
|
291
|
+
}, {
|
|
292
|
+
id: 'types',
|
|
293
|
+
component: 'select',
|
|
294
|
+
name: 'types',
|
|
295
|
+
placeholder: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
296
|
+
id: "9/t5wK",
|
|
759
297
|
defaultMessage: [{
|
|
760
298
|
"type": 0,
|
|
761
|
-
"value": "
|
|
299
|
+
"value": "Type"
|
|
762
300
|
}]
|
|
763
301
|
}),
|
|
764
|
-
|
|
302
|
+
options: [{
|
|
303
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
304
|
+
id: "yHAmDD",
|
|
305
|
+
defaultMessage: [{
|
|
306
|
+
"type": 0,
|
|
307
|
+
"value": "Image"
|
|
308
|
+
}]
|
|
309
|
+
}),
|
|
310
|
+
value: 'image'
|
|
311
|
+
}, {
|
|
312
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
313
|
+
id: "xSERPA",
|
|
314
|
+
defaultMessage: [{
|
|
315
|
+
"type": 0,
|
|
316
|
+
"value": "Video"
|
|
317
|
+
}]
|
|
318
|
+
}),
|
|
319
|
+
value: 'video'
|
|
320
|
+
}, {
|
|
321
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
322
|
+
id: "yQRtgx",
|
|
323
|
+
defaultMessage: [{
|
|
324
|
+
"type": 0,
|
|
325
|
+
"value": "Audio"
|
|
326
|
+
}]
|
|
327
|
+
}),
|
|
328
|
+
value: 'audio'
|
|
329
|
+
}],
|
|
330
|
+
multiple: true
|
|
765
331
|
}, {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
332
|
+
id: 'source',
|
|
333
|
+
component: 'select',
|
|
334
|
+
placeholder: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
335
|
+
id: "Pc4AD8",
|
|
769
336
|
defaultMessage: [{
|
|
770
337
|
"type": 0,
|
|
771
|
-
"value": "
|
|
338
|
+
"value": "Source"
|
|
772
339
|
}]
|
|
773
340
|
}),
|
|
774
|
-
|
|
341
|
+
name: 'source',
|
|
342
|
+
options: [{
|
|
343
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
344
|
+
id: "DYxnlo",
|
|
345
|
+
defaultMessage: [{
|
|
346
|
+
"type": 0,
|
|
347
|
+
"value": "All"
|
|
348
|
+
}]
|
|
349
|
+
}),
|
|
350
|
+
value: 'all'
|
|
351
|
+
}, {
|
|
352
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
353
|
+
id: "AgH3AR",
|
|
354
|
+
defaultMessage: [{
|
|
355
|
+
"type": 0,
|
|
356
|
+
"value": "This micromag"
|
|
357
|
+
}]
|
|
358
|
+
}),
|
|
359
|
+
value: 'document-1'
|
|
360
|
+
}]
|
|
775
361
|
}, {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
362
|
+
id: 'authors',
|
|
363
|
+
component: 'select',
|
|
364
|
+
name: 'authors',
|
|
365
|
+
placeholder: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
366
|
+
id: "7oXkoj",
|
|
779
367
|
defaultMessage: [{
|
|
780
368
|
"type": 0,
|
|
781
|
-
"value": "
|
|
369
|
+
"value": "Authors"
|
|
782
370
|
}]
|
|
783
371
|
}),
|
|
784
|
-
|
|
372
|
+
requestUrl: route('medias.authors') || '/api/medias/authors',
|
|
373
|
+
itemLabelPath: 'name',
|
|
374
|
+
itemValuePath: 'id',
|
|
375
|
+
multiple: true
|
|
785
376
|
}, {
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
377
|
+
id: 'tags',
|
|
378
|
+
component: 'select',
|
|
379
|
+
name: 'tags',
|
|
380
|
+
placeholder: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
381
|
+
id: "9mXl24",
|
|
789
382
|
defaultMessage: [{
|
|
790
383
|
"type": 0,
|
|
791
|
-
"value": "
|
|
384
|
+
"value": "Tags"
|
|
792
385
|
}]
|
|
793
386
|
}),
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
sections: sections,
|
|
801
|
-
types: types
|
|
802
|
-
};
|
|
803
|
-
};
|
|
804
|
-
|
|
805
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
806
|
-
var filtersValue = PropTypes$1.shape({
|
|
807
|
-
search: PropTypes$1.string
|
|
808
|
-
});
|
|
809
|
-
PropTypes$1.shape({
|
|
810
|
-
types: PropTypes$1.arrayOf(PropTypes$1.string),
|
|
811
|
-
tags: PropTypes$1.arrayOf(PropTypes$1.string),
|
|
812
|
-
users: PropTypes$1.arrayOf(PropTypes$1.string),
|
|
813
|
-
usage: PropTypes$1.arrayOf(PropTypes$1.oneOf(['used', 'unused']))
|
|
814
|
-
});
|
|
815
|
-
|
|
816
|
-
var styles$8 = {"container":"micromag-media-gallery-forms-dropdown-section-container","dropdownToggle":"micromag-media-gallery-forms-dropdown-section-dropdownToggle","label":"micromag-media-gallery-forms-dropdown-section-label","dropdown":"micromag-media-gallery-forms-dropdown-section-dropdown"};
|
|
817
|
-
|
|
818
|
-
var propTypes$8 = {
|
|
819
|
-
value: PropTypes$1.string,
|
|
820
|
-
items: PropTypes$1.arrayOf(PropTypes$1.shape({
|
|
821
|
-
label: PropTypes.label,
|
|
822
|
-
value: PropTypes$1.oneOfType([PropTypes$1.string, PropTypes$1.node]),
|
|
823
|
-
active: PropTypes$1.bool
|
|
824
|
-
})),
|
|
825
|
-
onChange: PropTypes$1.func,
|
|
826
|
-
className: PropTypes$1.string
|
|
827
|
-
};
|
|
828
|
-
var defaultProps$8 = {
|
|
829
|
-
value: null,
|
|
830
|
-
items: null,
|
|
831
|
-
onChange: null,
|
|
832
|
-
className: null
|
|
833
|
-
};
|
|
834
|
-
function DropdownSection(_ref) {
|
|
835
|
-
var value = _ref.value,
|
|
836
|
-
items = _ref.items,
|
|
837
|
-
onChange = _ref.onChange,
|
|
838
|
-
className = _ref.className;
|
|
839
|
-
var _useState = useState(false),
|
|
840
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
841
|
-
open = _useState2[0],
|
|
842
|
-
setOpen = _useState2[1];
|
|
843
|
-
var currentItem = items.find(function (i) {
|
|
844
|
-
return i.value === value;
|
|
845
|
-
});
|
|
846
|
-
var onOpen = useCallback(function () {
|
|
847
|
-
setOpen(!open);
|
|
848
|
-
}, [open, setOpen]);
|
|
849
|
-
var onBlur = useCallback(function () {
|
|
850
|
-
// Work around the event call order
|
|
851
|
-
setTimeout(function () {
|
|
852
|
-
setOpen(false);
|
|
853
|
-
}, 300);
|
|
854
|
-
}, [setOpen]);
|
|
855
|
-
var onItemClick = useCallback(function (e) {
|
|
856
|
-
var val = e.target.dataset.value || null;
|
|
857
|
-
setOpen(false);
|
|
858
|
-
onChange(val);
|
|
859
|
-
}, [setOpen]);
|
|
860
|
-
return items !== null && items.length > 1 ? /*#__PURE__*/React.createElement("div", {
|
|
861
|
-
className: classNames([styles$8.container, 'dropdown', _defineProperty({}, className, className !== null)])
|
|
862
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
863
|
-
className: styles$8.label
|
|
864
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
865
|
-
id: "9ZdD+Q",
|
|
866
|
-
defaultMessage: [{
|
|
867
|
-
"type": 0,
|
|
868
|
-
"value": "Library for"
|
|
869
|
-
}]
|
|
870
|
-
})), /*#__PURE__*/React.createElement("button", {
|
|
871
|
-
className: classNames([styles$8.dropdownToggle, 'dropdown-toggle', {
|
|
872
|
-
open: open === true
|
|
873
|
-
}]),
|
|
874
|
-
type: "button",
|
|
875
|
-
onClick: onOpen,
|
|
876
|
-
onBlur: onBlur
|
|
877
|
-
}, (currentItem ? currentItem.label : null) || /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
878
|
-
id: "15GBmG",
|
|
879
|
-
defaultMessage: [{
|
|
880
|
-
"type": 0,
|
|
881
|
-
"value": "All"
|
|
882
|
-
}]
|
|
883
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
884
|
-
className: classNames([styles$8.dropdown, 'dropdown-menu', {
|
|
885
|
-
show: open === true
|
|
886
|
-
}])
|
|
887
|
-
}, items.map(function (_ref3) {
|
|
888
|
-
var label = _ref3.label,
|
|
889
|
-
itemValue = _ref3.value;
|
|
890
|
-
var itemClassNames = classNames(['dropdown-item', {
|
|
891
|
-
active: itemValue === value
|
|
892
|
-
}]);
|
|
893
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
894
|
-
className: itemClassNames,
|
|
895
|
-
type: "button",
|
|
896
|
-
key: "drop-".concat(itemValue),
|
|
897
|
-
onClick: onItemClick,
|
|
898
|
-
"data-value": itemValue
|
|
899
|
-
}, label);
|
|
900
|
-
}))) : null;
|
|
387
|
+
requestUrl: route('medias.tags') || '/api/medias/tags',
|
|
388
|
+
itemLabelPath: 'name',
|
|
389
|
+
itemValuePath: 'id',
|
|
390
|
+
multiple: true,
|
|
391
|
+
paginated: true
|
|
392
|
+
}];
|
|
901
393
|
}
|
|
902
|
-
DropdownSection.propTypes = propTypes$8;
|
|
903
|
-
DropdownSection.defaultProps = defaultProps$8;
|
|
904
|
-
|
|
905
|
-
var styles$7 = {"container":"micromag-media-gallery-forms-search-container","input":"micromag-media-gallery-forms-search-input","active":"micromag-media-gallery-forms-search-active"};
|
|
906
394
|
|
|
907
|
-
var
|
|
908
|
-
value: PropTypes$1.string,
|
|
909
|
-
loading: PropTypes$1.bool,
|
|
910
|
-
onChange: PropTypes$1.func,
|
|
911
|
-
onFocus: PropTypes$1.func,
|
|
912
|
-
onBlur: PropTypes$1.func,
|
|
913
|
-
onClickIcon: PropTypes$1.func,
|
|
914
|
-
className: PropTypes$1.string
|
|
915
|
-
};
|
|
916
|
-
var defaultProps$7 = {
|
|
917
|
-
value: null,
|
|
918
|
-
loading: false,
|
|
919
|
-
onChange: null,
|
|
920
|
-
onFocus: null,
|
|
921
|
-
onBlur: null,
|
|
922
|
-
onClickIcon: null,
|
|
923
|
-
className: null
|
|
924
|
-
};
|
|
925
|
-
var Search = function Search(_ref) {
|
|
926
|
-
var value = _ref.value,
|
|
927
|
-
loading = _ref.loading,
|
|
928
|
-
onChange = _ref.onChange,
|
|
929
|
-
onFocus = _ref.onFocus,
|
|
930
|
-
onBlur = _ref.onBlur,
|
|
931
|
-
onClickIcon = _ref.onClickIcon,
|
|
932
|
-
className = _ref.className;
|
|
933
|
-
var intl = useIntl();
|
|
934
|
-
var onSearchChange = useCallback(function (e) {
|
|
935
|
-
var newValue = e.currentTarget.value.length > 0 ? e.currentTarget.value : null;
|
|
936
|
-
if (onChange !== null) {
|
|
937
|
-
onChange(newValue);
|
|
938
|
-
}
|
|
939
|
-
}, [onChange]);
|
|
940
|
-
useCallback(function () {
|
|
941
|
-
if (onChange !== null) {
|
|
942
|
-
onChange('');
|
|
943
|
-
}
|
|
944
|
-
}, [onChange]);
|
|
945
|
-
var onClickSearchIcon = useCallback(function () {
|
|
946
|
-
if (onClickIcon !== null) {
|
|
947
|
-
onClickIcon();
|
|
948
|
-
}
|
|
949
|
-
}, [onClickIcon]);
|
|
950
|
-
return /*#__PURE__*/React.createElement("form", {
|
|
951
|
-
method: "post",
|
|
952
|
-
className: classNames([styles$7.container, 'w-100', 'border', 'border-dark', 'rounded', _defineProperty({}, className, className !== null)]),
|
|
953
|
-
onSubmit: function onSubmit(e) {
|
|
954
|
-
return e.preventDefault();
|
|
955
|
-
}
|
|
956
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
957
|
-
className: "input-group w-100"
|
|
958
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
959
|
-
type: "button",
|
|
960
|
-
className: "btn",
|
|
961
|
-
onClick: onClickSearchIcon
|
|
962
|
-
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
963
|
-
icon: loading ? faSpinner : faSearch,
|
|
964
|
-
spin: loading
|
|
965
|
-
})), /*#__PURE__*/React.createElement("input", {
|
|
966
|
-
className: classNames([styles$7.input, 'form-control', {
|
|
967
|
-
'bg-light': !!value,
|
|
968
|
-
'text-dark': value
|
|
969
|
-
}]),
|
|
970
|
-
type: "text",
|
|
971
|
-
value: value || '',
|
|
972
|
-
placeholder: intl.formatMessage({
|
|
973
|
-
id: "n/SxMs",
|
|
974
|
-
defaultMessage: [{
|
|
975
|
-
"type": 0,
|
|
976
|
-
"value": "Search medias"
|
|
977
|
-
}]
|
|
978
|
-
}),
|
|
979
|
-
onChange: onSearchChange,
|
|
980
|
-
onFocus: onFocus,
|
|
981
|
-
onBlur: onBlur
|
|
982
|
-
}), null));
|
|
983
|
-
};
|
|
984
|
-
Search.propTypes = propTypes$7;
|
|
985
|
-
Search.defaultProps = defaultProps$7;
|
|
986
|
-
var SearchForm = Search;
|
|
395
|
+
var styles = {"container":"micromag-media-gallery-new-media-gallery-container","browser":"micromag-media-gallery-new-media-gallery-browser"};
|
|
987
396
|
|
|
988
|
-
|
|
397
|
+
// const videoTypes = ['video', 'image/gif'];
|
|
989
398
|
|
|
990
|
-
var propTypes
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
399
|
+
var propTypes = {
|
|
400
|
+
value: PropTypes.shape({
|
|
401
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
402
|
+
}),
|
|
403
|
+
types: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
404
|
+
source: PropTypes.string,
|
|
405
|
+
filters: PropTypes.arrayOf(PropTypes.shape({
|
|
406
|
+
id: PropTypes.string
|
|
995
407
|
})),
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
className: PropTypes$1.string
|
|
999
|
-
};
|
|
1000
|
-
var defaultProps$6 = {
|
|
1001
|
-
tags: null,
|
|
1002
|
-
parent: null,
|
|
1003
|
-
onChange: null,
|
|
1004
|
-
className: null
|
|
1005
|
-
};
|
|
1006
|
-
var TagDropdown = function TagDropdown(_ref) {
|
|
1007
|
-
var tags = _ref.tags,
|
|
1008
|
-
parent = _ref.parent,
|
|
1009
|
-
onChange = _ref.onChange,
|
|
1010
|
-
className = _ref.className;
|
|
1011
|
-
var onItemChange = useCallback(function (e) {
|
|
1012
|
-
var val = e.target.dataset.value || null;
|
|
1013
|
-
onChange(val, parent);
|
|
1014
|
-
}, [onChange, parent]);
|
|
1015
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1016
|
-
className: classNames([styles$6.container, 'd-flex', 'mt-1', _defineProperty({}, className, className !== null)])
|
|
1017
|
-
}, /*#__PURE__*/React.createElement("select", {
|
|
1018
|
-
className: classNames(['form-select', styles$6.select])
|
|
1019
|
-
}, tags !== null ? tags.map(function (_ref3) {
|
|
1020
|
-
var label = _ref3.label,
|
|
1021
|
-
value = _ref3.value,
|
|
1022
|
-
active = _ref3.active;
|
|
1023
|
-
var itemClassNames = classNames([styles$6.tag, 'fs-6', {
|
|
1024
|
-
'btn-primary': active === true
|
|
1025
|
-
}]);
|
|
1026
|
-
return /*#__PURE__*/React.createElement("option", {
|
|
1027
|
-
className: itemClassNames,
|
|
1028
|
-
type: "button",
|
|
1029
|
-
key: "option-".concat(value),
|
|
1030
|
-
onClick: onItemChange,
|
|
1031
|
-
"data-value": value,
|
|
1032
|
-
value: value
|
|
1033
|
-
}, label);
|
|
1034
|
-
}) : null));
|
|
1035
|
-
};
|
|
1036
|
-
TagDropdown.propTypes = propTypes$6;
|
|
1037
|
-
TagDropdown.defaultProps = defaultProps$6;
|
|
1038
|
-
var TagDropdown$1 = TagDropdown;
|
|
1039
|
-
|
|
1040
|
-
var styles$5 = {"container":"micromag-media-gallery-forms-tag-section-container","tag":"micromag-media-gallery-forms-tag-section-tag"};
|
|
1041
|
-
|
|
1042
|
-
var propTypes$5 = {
|
|
1043
|
-
tags: PropTypes$1.arrayOf(PropTypes$1.shape({
|
|
1044
|
-
label: PropTypes$1.string,
|
|
1045
|
-
value: PropTypes$1.oneOf([PropTypes$1.string, PropTypes$1.node]),
|
|
1046
|
-
active: PropTypes$1.bool
|
|
408
|
+
fields: PropTypes.arrayOf(PropTypes.shape({
|
|
409
|
+
id: PropTypes.string
|
|
1047
410
|
})),
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
className: PropTypes$1.string
|
|
1051
|
-
};
|
|
1052
|
-
var defaultProps$5 = {
|
|
1053
|
-
tags: null,
|
|
1054
|
-
parent: null,
|
|
1055
|
-
onChange: null,
|
|
1056
|
-
className: null
|
|
1057
|
-
};
|
|
1058
|
-
var TagSection = function TagSection(_ref) {
|
|
1059
|
-
var tags = _ref.tags,
|
|
1060
|
-
parent = _ref.parent,
|
|
1061
|
-
onChange = _ref.onChange,
|
|
1062
|
-
className = _ref.className;
|
|
1063
|
-
var onItemChange = useCallback(function (e) {
|
|
1064
|
-
var val = e.target.dataset.value || null;
|
|
1065
|
-
onChange(val, parent);
|
|
1066
|
-
}, [onChange, parent]);
|
|
1067
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1068
|
-
className: classNames([styles$5.container, 'd-flex', 'mt-1', _defineProperty({}, className, className !== null)])
|
|
1069
|
-
}, tags !== null ? tags.map(function (_ref3) {
|
|
1070
|
-
var label = _ref3.label,
|
|
1071
|
-
value = _ref3.value,
|
|
1072
|
-
active = _ref3.active;
|
|
1073
|
-
var itemClassNames = classNames([styles$5.tag, 'btn', 'btn-sm', 'mb-1', 'me-1', 'p-1', 'btn-secondary', 'text-truncate', {
|
|
1074
|
-
'btn-primary': active === true
|
|
1075
|
-
// 'btn-outline-light': active === false,
|
|
1076
|
-
}]);
|
|
1077
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
1078
|
-
className: itemClassNames,
|
|
1079
|
-
type: "button",
|
|
1080
|
-
key: "tag-".concat(value),
|
|
1081
|
-
onClick: onItemChange,
|
|
1082
|
-
"data-value": value
|
|
1083
|
-
}, label);
|
|
1084
|
-
}) : null);
|
|
1085
|
-
};
|
|
1086
|
-
TagSection.propTypes = propTypes$5;
|
|
1087
|
-
TagSection.defaultProps = defaultProps$5;
|
|
1088
|
-
var TagSection$1 = TagSection;
|
|
1089
|
-
|
|
1090
|
-
var styles$4 = {"container":"micromag-media-gallery-forms-search-filters-container","closeBtn":"micromag-media-gallery-forms-search-filters-closeBtn","section":"micromag-media-gallery-forms-search-filters-section","title":"micromag-media-gallery-forms-search-filters-title","tags":"micromag-media-gallery-forms-search-filters-tags"};
|
|
1091
|
-
|
|
1092
|
-
var propTypes$4 = {
|
|
1093
|
-
filters: PropTypes$1.object,
|
|
1094
|
-
// eslint-disable-line
|
|
1095
|
-
sections: PropTypes$1.arrayOf(PropTypes$1.shape({})),
|
|
1096
|
-
onChange: PropTypes$1.func,
|
|
1097
|
-
onClose: PropTypes$1.func,
|
|
1098
|
-
className: PropTypes$1.string
|
|
1099
|
-
};
|
|
1100
|
-
var defaultProps$4 = {
|
|
1101
|
-
filters: null,
|
|
1102
|
-
sections: [],
|
|
1103
|
-
onChange: null,
|
|
1104
|
-
onClose: null,
|
|
1105
|
-
className: null
|
|
1106
|
-
};
|
|
1107
|
-
var SearchFilters = function SearchFilters(_ref) {
|
|
1108
|
-
var filters = _ref.filters,
|
|
1109
|
-
sections = _ref.sections,
|
|
1110
|
-
onChange = _ref.onChange,
|
|
1111
|
-
onClose = _ref.onClose,
|
|
1112
|
-
className = _ref.className;
|
|
1113
|
-
var intl = useIntl();
|
|
1114
|
-
var getActive = useCallback(function (items, sectionFilters) {
|
|
1115
|
-
return items !== null ? items.map(function (it) {
|
|
1116
|
-
return _objectSpread(_objectSpread({}, it), {}, {
|
|
1117
|
-
active: sectionFilters ? !!sectionFilters.find(function (f) {
|
|
1118
|
-
return f === it.value;
|
|
1119
|
-
}) : false
|
|
1120
|
-
});
|
|
1121
|
-
}) : [];
|
|
1122
|
-
}, []);
|
|
1123
|
-
var activeSections = useMemo(function () {
|
|
1124
|
-
return sections.map(function (section) {
|
|
1125
|
-
return _objectSpread(_objectSpread({}, section), {}, {
|
|
1126
|
-
items: getActive(section.items, filters[section.value])
|
|
1127
|
-
});
|
|
1128
|
-
});
|
|
1129
|
-
}, [getActive, sections, filters]);
|
|
1130
|
-
var onSectionChange = useCallback(function (data, section) {
|
|
1131
|
-
var val = filters[section] ? filters[section] : [];
|
|
1132
|
-
var found = !!val.find(function (f) {
|
|
1133
|
-
return f === data;
|
|
1134
|
-
});
|
|
1135
|
-
if (found) {
|
|
1136
|
-
onChange(section, val.filter(function (f) {
|
|
1137
|
-
return f !== data;
|
|
1138
|
-
}));
|
|
1139
|
-
} else if (data) {
|
|
1140
|
-
if (section === 'recent') {
|
|
1141
|
-
onChange('search', data);
|
|
1142
|
-
} else if (section === 'usage') {
|
|
1143
|
-
onChange(section, [data]);
|
|
1144
|
-
} else {
|
|
1145
|
-
onChange(section, [].concat(_toConsumableArray(val), [data]));
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
}, [filters, onChange]);
|
|
1149
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1150
|
-
className: classNames([styles$4.container, 'flex-nowrap', 'mt-1', _defineProperty({}, className, className !== null)])
|
|
1151
|
-
}, activeSections.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
1152
|
-
className: classNames(['bg-dark', 'flex-nowrap', 'text-dark', 'py-1', 'px-3', 'rounded'])
|
|
1153
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
1154
|
-
className: classNames([styles$4.closeBtn, 'py-1', 'px-1', 'text-light']),
|
|
1155
|
-
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1156
|
-
icon: faTimes
|
|
1157
|
-
}),
|
|
1158
|
-
onClick: onClose,
|
|
1159
|
-
title: intl.formatMessage({
|
|
1160
|
-
id: "yCXMzz",
|
|
1161
|
-
defaultMessage: [{
|
|
1162
|
-
"type": 0,
|
|
1163
|
-
"value": "Close"
|
|
1164
|
-
}]
|
|
1165
|
-
})
|
|
1166
|
-
}), activeSections.map(function (_ref3) {
|
|
1167
|
-
var value = _ref3.value,
|
|
1168
|
-
label = _ref3.label,
|
|
1169
|
-
items = _ref3.items;
|
|
1170
|
-
return items.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
1171
|
-
key: "filter-".concat(value),
|
|
1172
|
-
className: classNames([styles$4.section, 'py-2'])
|
|
1173
|
-
}, /*#__PURE__*/React.createElement("p", {
|
|
1174
|
-
className: classNames([styles$4.title, 'm-0'])
|
|
1175
|
-
}, label), value === 'tags' || value === 'recent' || value === 'users' ? /*#__PURE__*/React.createElement(TagDropdown$1, {
|
|
1176
|
-
className: classNames([styles$4.tags]),
|
|
1177
|
-
tags: items,
|
|
1178
|
-
parent: value,
|
|
1179
|
-
onChange: onSectionChange
|
|
1180
|
-
}) : /*#__PURE__*/React.createElement(TagSection$1, {
|
|
1181
|
-
className: classNames([styles$4.tags]),
|
|
1182
|
-
tags: items,
|
|
1183
|
-
parent: value,
|
|
1184
|
-
onChange: onSectionChange
|
|
1185
|
-
})) : null;
|
|
1186
|
-
})) : null);
|
|
1187
|
-
};
|
|
1188
|
-
SearchFilters.propTypes = propTypes$4;
|
|
1189
|
-
SearchFilters.defaultProps = defaultProps$4;
|
|
1190
|
-
var SearchFilters$1 = SearchFilters;
|
|
1191
|
-
|
|
1192
|
-
var styles$3 = {"container":"micromag-media-gallery-buttons-close-container"};
|
|
1193
|
-
|
|
1194
|
-
var _excluded = ["className"];
|
|
1195
|
-
var propTypes$3 = {
|
|
1196
|
-
className: PropTypes$1.string
|
|
1197
|
-
};
|
|
1198
|
-
var defaultProps$3 = {
|
|
1199
|
-
className: null
|
|
1200
|
-
};
|
|
1201
|
-
var CloseButton = function CloseButton(_ref) {
|
|
1202
|
-
var className = _ref.className,
|
|
1203
|
-
props = _objectWithoutProperties(_ref, _excluded);
|
|
1204
|
-
return /*#__PURE__*/React.createElement(Button, Object.assign({
|
|
1205
|
-
className: classNames([styles$3.container, _defineProperty({}, className, className !== null)]),
|
|
1206
|
-
withoutStyle: true,
|
|
1207
|
-
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1208
|
-
icon: faTimes,
|
|
1209
|
-
className: styles$3.icon
|
|
1210
|
-
}),
|
|
1211
|
-
iconPosition: "right"
|
|
1212
|
-
}, props));
|
|
1213
|
-
};
|
|
1214
|
-
CloseButton.propTypes = propTypes$3;
|
|
1215
|
-
CloseButton.defaultProps = defaultProps$3;
|
|
1216
|
-
var CloseButton$1 = CloseButton;
|
|
1217
|
-
|
|
1218
|
-
var styles$2 = {"container":"micromag-media-gallery-partials-active-filters-container","heading":"micromag-media-gallery-partials-active-filters-heading","title":"micromag-media-gallery-partials-active-filters-title","resetButton":"micromag-media-gallery-partials-active-filters-resetButton","activeTag":"micromag-media-gallery-partials-active-filters-activeTag"};
|
|
1219
|
-
|
|
1220
|
-
var propTypes$2 = {
|
|
1221
|
-
filters: PropTypes$1.shape({
|
|
1222
|
-
types: PropTypes$1.arrayOf(PropTypes$1.string),
|
|
1223
|
-
tags: PropTypes$1.arrayOf(PropTypes$1.string),
|
|
1224
|
-
users: PropTypes$1.arrayOf(PropTypes$1.string),
|
|
1225
|
-
usage: PropTypes$1.arrayOf(PropTypes$1.oneOf(['used', 'unused']))
|
|
1226
|
-
}),
|
|
1227
|
-
onChange: PropTypes$1.func,
|
|
1228
|
-
onReset: PropTypes$1.func,
|
|
1229
|
-
sections: PropTypes$1.arrayOf(PropTypes$1.shape({})),
|
|
1230
|
-
className: PropTypes$1.string
|
|
1231
|
-
};
|
|
1232
|
-
var defaultProps$2 = {
|
|
1233
|
-
filters: null,
|
|
1234
|
-
onChange: null,
|
|
1235
|
-
onReset: null,
|
|
1236
|
-
sections: [],
|
|
1237
|
-
className: null
|
|
1238
|
-
};
|
|
1239
|
-
function ActiveFilters(_ref) {
|
|
1240
|
-
var filters = _ref.filters,
|
|
1241
|
-
onChange = _ref.onChange,
|
|
1242
|
-
onReset = _ref.onReset,
|
|
1243
|
-
sections = _ref.sections,
|
|
1244
|
-
className = _ref.className;
|
|
1245
|
-
var handleReset = useCallback(function () {
|
|
1246
|
-
if (onReset !== null) {
|
|
1247
|
-
onReset();
|
|
1248
|
-
}
|
|
1249
|
-
}, [onReset]);
|
|
1250
|
-
var removeFilter = useCallback(function (key, activeValue) {
|
|
1251
|
-
var newFilterValue = filters[key].filter(function (it) {
|
|
1252
|
-
return it !== activeValue;
|
|
1253
|
-
});
|
|
1254
|
-
var newValue = newFilterValue.length > 0 ? newFilterValue : null;
|
|
1255
|
-
if (onChange !== null) {
|
|
1256
|
-
onChange(key, newValue);
|
|
1257
|
-
}
|
|
1258
|
-
}, [onChange, filters]);
|
|
1259
|
-
var hasValue = Object.keys(filters).reduce(function (oneHasValue, key) {
|
|
1260
|
-
return oneHasValue || filters[key] !== null;
|
|
1261
|
-
}, false);
|
|
1262
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1263
|
-
className: classNames(['w-100', styles$2.container, _defineProperty({}, className, className)])
|
|
1264
|
-
}, hasValue ? /*#__PURE__*/React.createElement("div", {
|
|
1265
|
-
className: styles$2.heading
|
|
1266
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1267
|
-
className: styles$2.title
|
|
1268
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1269
|
-
id: "t2cFdl",
|
|
1270
|
-
defaultMessage: [{
|
|
1271
|
-
"type": 0,
|
|
1272
|
-
"value": "Active filters"
|
|
1273
|
-
}]
|
|
1274
|
-
})), /*#__PURE__*/React.createElement(CloseButton$1, {
|
|
1275
|
-
className: styles$2.resetButton,
|
|
1276
|
-
onClick: handleReset
|
|
1277
|
-
}, /*#__PURE__*/React.createElement("u", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1278
|
-
id: "/T/UDH",
|
|
1279
|
-
defaultMessage: [{
|
|
1280
|
-
"type": 0,
|
|
1281
|
-
"value": "Remove all"
|
|
1282
|
-
}]
|
|
1283
|
-
})))) : null, filters !== null ? Object.keys(filters).map(function (key) {
|
|
1284
|
-
var section = sections.find(function (s) {
|
|
1285
|
-
return s.value === key;
|
|
1286
|
-
});
|
|
1287
|
-
return section && filters[key] !== null ? filters[key].map(function (activeValue) {
|
|
1288
|
-
var current = section.items.find(function (s) {
|
|
1289
|
-
return s.value === activeValue;
|
|
1290
|
-
});
|
|
1291
|
-
var _ref3 = current || {},
|
|
1292
|
-
_ref3$label = _ref3.label,
|
|
1293
|
-
label = _ref3$label === void 0 ? '' : _ref3$label;
|
|
1294
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
1295
|
-
className: styles$2.activeTag,
|
|
1296
|
-
key: "filter-button-".concat(activeValue),
|
|
1297
|
-
type: "submit",
|
|
1298
|
-
size: "sm",
|
|
1299
|
-
label: /*#__PURE__*/React.createElement("span", null, section.label, " : ", label),
|
|
1300
|
-
theme: "secondary",
|
|
1301
|
-
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1302
|
-
icon: faTimes
|
|
1303
|
-
}),
|
|
1304
|
-
iconPosition: "right",
|
|
1305
|
-
onClick: function onClick() {
|
|
1306
|
-
return removeFilter(key, activeValue);
|
|
1307
|
-
}
|
|
1308
|
-
});
|
|
1309
|
-
}) : null;
|
|
1310
|
-
}) : null);
|
|
1311
|
-
}
|
|
1312
|
-
ActiveFilters.propTypes = propTypes$2;
|
|
1313
|
-
ActiveFilters.defaultProps = defaultProps$2;
|
|
1314
|
-
|
|
1315
|
-
var styles$1 = {"container":"micromag-media-gallery-partials-navbar-container","inner":"micromag-media-gallery-partials-navbar-inner","mediaPreview":"micromag-media-gallery-partials-navbar-mediaPreview","thumbnail":"micromag-media-gallery-partials-navbar-thumbnail","mediaLabel":"micromag-media-gallery-partials-navbar-mediaLabel"};
|
|
1316
|
-
|
|
1317
|
-
var propTypes$1 = {
|
|
1318
|
-
types: PropTypes$1.arrayOf(PropTypes$1.string),
|
|
1319
|
-
filters: filtersValue,
|
|
1320
|
-
media: PropTypes.media,
|
|
1321
|
-
selectedMedia: PropTypes.media,
|
|
1322
|
-
storyId: PropTypes$1.oneOfType([PropTypes$1.string, PropTypes$1.number]),
|
|
1323
|
-
tags: PropTypes.tags,
|
|
1324
|
-
authors: PropTypes$1.arrayOf(PropTypes$1.shape({
|
|
1325
|
-
name: PropTypes$1.string
|
|
411
|
+
columns: PropTypes.arrayOf(PropTypes.shape({
|
|
412
|
+
id: PropTypes.string
|
|
1326
413
|
})),
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
onClickClear: PropTypes$1.func,
|
|
1334
|
-
// TODO: still needed?
|
|
1335
|
-
onFocusSearch: PropTypes$1.func,
|
|
1336
|
-
onFiltersChange: PropTypes$1.func,
|
|
1337
|
-
onClickBack: PropTypes$1.func,
|
|
1338
|
-
className: PropTypes$1.string
|
|
1339
|
-
};
|
|
1340
|
-
var defaultProps$1 = {
|
|
1341
|
-
types: null,
|
|
1342
|
-
filters: null,
|
|
1343
|
-
media: null,
|
|
1344
|
-
selectedMedia: null,
|
|
1345
|
-
storyId: null,
|
|
1346
|
-
tags: [],
|
|
1347
|
-
authors: [],
|
|
1348
|
-
loading: false,
|
|
1349
|
-
withoutSource: false,
|
|
1350
|
-
withoutType: true,
|
|
1351
|
-
onClickAdd: null,
|
|
1352
|
-
onClickItem: null,
|
|
1353
|
-
onClickItemInfo: null,
|
|
1354
|
-
onClickClear: null,
|
|
1355
|
-
onFocusSearch: null,
|
|
1356
|
-
onFiltersChange: null,
|
|
1357
|
-
onClickBack: null,
|
|
1358
|
-
className: null
|
|
1359
|
-
};
|
|
1360
|
-
function Navbar(_ref) {
|
|
1361
|
-
var types = _ref.types,
|
|
1362
|
-
filters = _ref.filters,
|
|
1363
|
-
media = _ref.media,
|
|
1364
|
-
selectedMedia = _ref.selectedMedia,
|
|
1365
|
-
storyId = _ref.storyId,
|
|
1366
|
-
tags = _ref.tags,
|
|
1367
|
-
authors = _ref.authors,
|
|
1368
|
-
loading = _ref.loading,
|
|
1369
|
-
withoutSource = _ref.withoutSource,
|
|
1370
|
-
withoutType = _ref.withoutType,
|
|
1371
|
-
className = _ref.className,
|
|
1372
|
-
onClickAdd = _ref.onClickAdd,
|
|
1373
|
-
onClickItem = _ref.onClickItem,
|
|
1374
|
-
onClickItemInfo = _ref.onClickItemInfo,
|
|
1375
|
-
onClickClear = _ref.onClickClear,
|
|
1376
|
-
onFocusSearch = _ref.onFocusSearch,
|
|
1377
|
-
onFiltersChange = _ref.onFiltersChange,
|
|
1378
|
-
onClickBack = _ref.onClickBack;
|
|
1379
|
-
var intl = useIntl();
|
|
1380
|
-
var throttle = useRef(null);
|
|
1381
|
-
var _useState = useState(false),
|
|
1382
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1383
|
-
open = _useState2[0],
|
|
1384
|
-
setOpen = _useState2[1];
|
|
1385
|
-
|
|
1386
|
-
// TODO: get data from api for real testing
|
|
1387
|
-
|
|
1388
|
-
var _useMediasRecentSearc = useMediasRecentSearches(),
|
|
1389
|
-
getSearches = _useMediasRecentSearc.getSearches,
|
|
1390
|
-
createSearch = _useMediasRecentSearc.createSearch;
|
|
1391
|
-
var recent = useMemo(function () {
|
|
1392
|
-
return getSearches();
|
|
1393
|
-
}, [getSearches]);
|
|
1394
|
-
var _useSearchFilters = useSearchFilters({
|
|
1395
|
-
recent: recent.map(function (val) {
|
|
1396
|
-
return {
|
|
1397
|
-
value: val,
|
|
1398
|
-
label: val
|
|
1399
|
-
};
|
|
1400
|
-
}),
|
|
1401
|
-
tags: tags !== null ? tags.map(function (t) {
|
|
1402
|
-
return {
|
|
1403
|
-
value: t.name,
|
|
1404
|
-
label: t.name
|
|
1405
|
-
};
|
|
1406
|
-
}) : [],
|
|
1407
|
-
team: authors || [],
|
|
1408
|
-
withType: !withoutType,
|
|
1409
|
-
storyId: storyId
|
|
1410
|
-
}),
|
|
1411
|
-
sources = _useSearchFilters.sources,
|
|
1412
|
-
sections = _useSearchFilters.sections;
|
|
1413
|
-
var searchValue = filters !== null ? filters.search || null : null;
|
|
1414
|
-
var hasFilter = filters !== null ? Object.keys(filters).reduce(function (acc, val) {
|
|
1415
|
-
if (val !== 'type' && val !== 'search' && val !== 'source' && filters[val] !== null && filters[val].length > 0) {
|
|
1416
|
-
return true;
|
|
1417
|
-
}
|
|
1418
|
-
return acc;
|
|
1419
|
-
}, false) : false;
|
|
1420
|
-
var onFilterChange = useCallback(function (type, value) {
|
|
1421
|
-
var isOpen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1422
|
-
var newFiltersValue = _objectSpread(_objectSpread({}, filters), {}, _defineProperty({}, type, value));
|
|
1423
|
-
if (onFiltersChange !== null) {
|
|
1424
|
-
onFiltersChange(newFiltersValue);
|
|
1425
|
-
}
|
|
1426
|
-
setOpen(isOpen);
|
|
1427
|
-
}, [filters, onFiltersChange, setOpen]);
|
|
1428
|
-
var onFiltersReset = useCallback(function () {
|
|
1429
|
-
onFiltersChange({
|
|
1430
|
-
type: filters.type || null,
|
|
1431
|
-
search: filters.search || null,
|
|
1432
|
-
source: filters.source || null
|
|
1433
|
-
});
|
|
1434
|
-
setOpen(false);
|
|
1435
|
-
}, [filters, onFiltersChange]);
|
|
1436
|
-
var onSearchChange = useCallback(function (value) {
|
|
1437
|
-
if (throttle.current !== null) {
|
|
1438
|
-
clearTimeout(throttle.current);
|
|
1439
|
-
}
|
|
1440
|
-
throttle.current = setTimeout(function () {
|
|
1441
|
-
createSearch(value);
|
|
1442
|
-
throttle.current = null;
|
|
1443
|
-
}, 5000);
|
|
1444
|
-
onFilterChange('search', value, !!value);
|
|
1445
|
-
setOpen(false);
|
|
1446
|
-
}, [onFilterChange, createSearch, setOpen, throttle]);
|
|
1447
|
-
var onSourceChange = useCallback(function (value) {
|
|
1448
|
-
onFilterChange('source', value);
|
|
1449
|
-
}, [onFilterChange]);
|
|
1450
|
-
var onSearchFocus = useCallback(function () {
|
|
1451
|
-
if (onFocusSearch !== null) {
|
|
1452
|
-
onFocusSearch();
|
|
1453
|
-
}
|
|
1454
|
-
}, [onFocusSearch]);
|
|
1455
|
-
var onCloseFilters = useCallback(function () {
|
|
1456
|
-
setOpen(false);
|
|
1457
|
-
}, [setOpen]);
|
|
1458
|
-
var onToggleMenu = useCallback(function () {
|
|
1459
|
-
setOpen(!open);
|
|
1460
|
-
}, [open, setOpen]);
|
|
1461
|
-
var onClickRemove = useCallback(function () {
|
|
1462
|
-
if (onClickClear !== null) {
|
|
1463
|
-
onClickClear();
|
|
1464
|
-
} else if (onClickItem !== null) {
|
|
1465
|
-
onClickItem(null);
|
|
1466
|
-
}
|
|
1467
|
-
}, [onClickClear, onClickItem]);
|
|
1468
|
-
var uploadMessage = useMemo(function () {
|
|
1469
|
-
var message = /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1470
|
-
id: "3Ap0C1",
|
|
1471
|
-
defaultMessage: [{
|
|
1472
|
-
"type": 0,
|
|
1473
|
-
"value": "Upload a media"
|
|
1474
|
-
}]
|
|
1475
|
-
});
|
|
1476
|
-
if (types !== null) {
|
|
1477
|
-
if (types.indexOf('video') !== -1 && types.indexOf('image') !== -1) {
|
|
1478
|
-
message = /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1479
|
-
id: "KK5teQ",
|
|
1480
|
-
defaultMessage: [{
|
|
1481
|
-
"type": 0,
|
|
1482
|
-
"value": "Upload a visual file"
|
|
1483
|
-
}]
|
|
1484
|
-
});
|
|
1485
|
-
} else if (types.indexOf('video') !== -1) {
|
|
1486
|
-
message = /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1487
|
-
id: "WeD4nB",
|
|
1488
|
-
defaultMessage: [{
|
|
1489
|
-
"type": 0,
|
|
1490
|
-
"value": "Upload a video file"
|
|
1491
|
-
}]
|
|
1492
|
-
});
|
|
1493
|
-
} else if (types.indexOf('image') !== -1) {
|
|
1494
|
-
message = /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1495
|
-
id: "KdAKt7",
|
|
1496
|
-
defaultMessage: [{
|
|
1497
|
-
"type": 0,
|
|
1498
|
-
"value": "Upload an image file"
|
|
1499
|
-
}]
|
|
1500
|
-
});
|
|
1501
|
-
} else if (types.indexOf('audio') !== -1) {
|
|
1502
|
-
message = /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1503
|
-
id: "6W4St0",
|
|
1504
|
-
defaultMessage: [{
|
|
1505
|
-
"type": 0,
|
|
1506
|
-
"value": "Upload an audio file"
|
|
1507
|
-
}]
|
|
1508
|
-
});
|
|
1509
|
-
} else if (types.indexOf('subtitle') !== -1) {
|
|
1510
|
-
message = /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1511
|
-
id: "BAfC6s",
|
|
1512
|
-
defaultMessage: [{
|
|
1513
|
-
"type": 0,
|
|
1514
|
-
"value": "Upload a closed captions file"
|
|
1515
|
-
}]
|
|
1516
|
-
});
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
return message;
|
|
1520
|
-
}, [types]);
|
|
1521
|
-
return /*#__PURE__*/React.createElement("nav", {
|
|
1522
|
-
className: classNames([styles$1.container, 'navbar', _defineProperty({}, className, className !== null)])
|
|
1523
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1524
|
-
className: classNames([styles$1.inner])
|
|
1525
|
-
}, media === null ? /*#__PURE__*/React.createElement("div", {
|
|
1526
|
-
className: classNames(['list-group-item rounded w-100 mw-100 navbar-text mb-2', {
|
|
1527
|
-
'border border-primary bg-dark py-2 px-2': selectedMedia !== null
|
|
1528
|
-
}])
|
|
1529
|
-
}, selectedMedia !== null ? /*#__PURE__*/React.createElement("div", {
|
|
1530
|
-
className: ""
|
|
1531
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
1532
|
-
className: "d-flex align-items-center mb-2 overflow-hidden"
|
|
1533
|
-
}, /*#__PURE__*/React.createElement(Media, {
|
|
1534
|
-
className: styles$1.mediaPreview,
|
|
1535
|
-
thumbnailClassName: styles$1.thumbnail,
|
|
1536
|
-
thumbnail: selectedMedia === null || selectedMedia === void 0 ? void 0 : selectedMedia.thumbnail_url,
|
|
1537
|
-
thumbnailAlign: "center"
|
|
1538
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
1539
|
-
className: classNames([styles$1.mediaLabel, 'd-inline-block', 'text-break', 'mx-1', 'me-2'])
|
|
1540
|
-
}, selectedMedia.name || /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1541
|
-
id: "fVqgfl",
|
|
1542
|
-
defaultMessage: [{
|
|
1543
|
-
"type": 0,
|
|
1544
|
-
"value": "[no title]"
|
|
1545
|
-
}]
|
|
1546
|
-
}))), /*#__PURE__*/React.createElement("div", {
|
|
1547
|
-
className: "d-flex w-100 align-content-center justify-content-between"
|
|
1548
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
1549
|
-
onClick: function onClick() {
|
|
1550
|
-
return onClickItemInfo(selectedMedia);
|
|
1551
|
-
},
|
|
1552
|
-
theme: "secondary",
|
|
1553
|
-
size: "sm",
|
|
1554
|
-
iconPosition: "right",
|
|
1555
|
-
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1556
|
-
icon: faInfoCircle
|
|
1557
|
-
}),
|
|
1558
|
-
outline: true
|
|
1559
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1560
|
-
id: "iCf/MP",
|
|
1561
|
-
defaultMessage: [{
|
|
1562
|
-
"type": 0,
|
|
1563
|
-
"value": "Edit"
|
|
1564
|
-
}]
|
|
1565
|
-
})), /*#__PURE__*/React.createElement(Button, {
|
|
1566
|
-
theme: "secondary",
|
|
1567
|
-
size: "sm",
|
|
1568
|
-
outline: true,
|
|
1569
|
-
iconPosition: "right",
|
|
1570
|
-
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1571
|
-
icon: faTimes
|
|
1572
|
-
}),
|
|
1573
|
-
onClick: onClickRemove,
|
|
1574
|
-
title: intl.formatMessage({
|
|
1575
|
-
id: "UG3SXh",
|
|
1576
|
-
defaultMessage: [{
|
|
1577
|
-
"type": 0,
|
|
1578
|
-
"value": "Remove"
|
|
1579
|
-
}]
|
|
1580
|
-
})
|
|
1581
|
-
}, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1582
|
-
id: "8TbpT7",
|
|
1583
|
-
defaultMessage: [{
|
|
1584
|
-
"type": 0,
|
|
1585
|
-
"value": "Remove"
|
|
1586
|
-
}]
|
|
1587
|
-
})))) : /*#__PURE__*/React.createElement(Button, {
|
|
1588
|
-
className: "w-100",
|
|
1589
|
-
theme: "primary",
|
|
1590
|
-
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1591
|
-
icon: faPlus
|
|
1592
|
-
}),
|
|
1593
|
-
onClick: onClickAdd,
|
|
1594
|
-
title: intl.formatMessage({
|
|
1595
|
-
id: "Tt4jN1",
|
|
1596
|
-
defaultMessage: [{
|
|
1597
|
-
"type": 0,
|
|
1598
|
-
"value": "Add"
|
|
1599
|
-
}]
|
|
1600
|
-
})
|
|
1601
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
1602
|
-
className: "ps-2"
|
|
1603
|
-
}, uploadMessage))) : null, !withoutSource && media === null && sources !== null && sources.length > 1 ? /*#__PURE__*/React.createElement("div", {
|
|
1604
|
-
className: "mb-2 d-flex w-100 align-items-center flex-nowrap"
|
|
1605
|
-
}, /*#__PURE__*/React.createElement(DropdownSection, {
|
|
1606
|
-
items: sources,
|
|
1607
|
-
value: filters.source || null,
|
|
1608
|
-
onChange: onSourceChange
|
|
1609
|
-
})) : null, media !== null ? /*#__PURE__*/React.createElement("div", {
|
|
1610
|
-
className: "w-100 d-flex flex-nowrap justify-content-between"
|
|
1611
|
-
}, /*#__PURE__*/React.createElement("form", {
|
|
1612
|
-
className: classNames(['d-flex', 'me-2'])
|
|
1613
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
1614
|
-
theme: "secondary",
|
|
1615
|
-
outline: true,
|
|
1616
|
-
size: "sm",
|
|
1617
|
-
icon: /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
1618
|
-
icon: faChevronLeft
|
|
1619
|
-
}),
|
|
1620
|
-
onClick: onClickBack
|
|
1621
|
-
})), /*#__PURE__*/React.createElement("strong", {
|
|
1622
|
-
className: "navbar-text me-auto w-100 text-truncate text-light"
|
|
1623
|
-
}, media !== null ? media.name : null)) : null, media === null ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
1624
|
-
className: "d-flex w-100 flex-nowrap justify-content-between"
|
|
1625
|
-
}, /*#__PURE__*/React.createElement(SearchForm, {
|
|
1626
|
-
value: searchValue,
|
|
1627
|
-
onChange: onSearchChange,
|
|
1628
|
-
onFocus: onSearchFocus,
|
|
1629
|
-
onClickIcon: onToggleMenu,
|
|
1630
|
-
loading: loading,
|
|
1631
|
-
className: classNames(['d-flex'])
|
|
1632
|
-
})), open ? /*#__PURE__*/React.createElement("div", {
|
|
1633
|
-
className: "d-flex w-100 my-1 flex-nowrap justify-content-between"
|
|
1634
|
-
}, /*#__PURE__*/React.createElement(SearchFilters$1, {
|
|
1635
|
-
filters: filters,
|
|
1636
|
-
sections: sections,
|
|
1637
|
-
onChange: onFilterChange,
|
|
1638
|
-
onClose: onCloseFilters
|
|
1639
|
-
})) : null) : null, hasFilter && !open && media === null ? /*#__PURE__*/React.createElement("div", {
|
|
1640
|
-
className: "list-group-item py-2 px-2 d-flex w-100 my-2 flex-nowrap justify-content-between"
|
|
1641
|
-
}, /*#__PURE__*/React.createElement(ActiveFilters, {
|
|
1642
|
-
filters: filters,
|
|
1643
|
-
sections: sections,
|
|
1644
|
-
onChange: onFilterChange,
|
|
1645
|
-
onReset: onFiltersReset
|
|
1646
|
-
})) : null));
|
|
1647
|
-
}
|
|
1648
|
-
Navbar.propTypes = propTypes$1;
|
|
1649
|
-
Navbar.defaultProps = defaultProps$1;
|
|
1650
|
-
|
|
1651
|
-
var styles = {"container":"micromag-media-gallery-container","metadataOpened":"micromag-media-gallery-metadataOpened","gallery":"micromag-media-gallery-gallery","mediaMetadata":"micromag-media-gallery-mediaMetadata","content":"micromag-media-gallery-content","loading":"micromag-media-gallery-loading"};
|
|
1652
|
-
|
|
1653
|
-
var videoTypes = ['video', 'image/gif'];
|
|
1654
|
-
var propTypes = {
|
|
1655
|
-
type: PropTypes$1.oneOfType([PropTypes$1.string, PropTypes$1.array]),
|
|
1656
|
-
source: PropTypes$1.string,
|
|
1657
|
-
isPicker: PropTypes$1.bool,
|
|
1658
|
-
isSmall: PropTypes$1.bool,
|
|
1659
|
-
withoutTitle: PropTypes$1.bool,
|
|
1660
|
-
withoutSource: PropTypes$1.bool,
|
|
1661
|
-
withoutType: PropTypes$1.bool,
|
|
1662
|
-
medias: PropTypes.medias,
|
|
1663
|
-
selectedMedia: PropTypes.media,
|
|
1664
|
-
className: PropTypes$1.string,
|
|
1665
|
-
navbarClassName: PropTypes$1.string,
|
|
1666
|
-
onChange: PropTypes$1.func,
|
|
1667
|
-
onClickMedia: PropTypes$1.func,
|
|
1668
|
-
onClearMedia: PropTypes$1.func
|
|
414
|
+
isPicker: PropTypes.bool,
|
|
415
|
+
multiple: PropTypes.bool,
|
|
416
|
+
medias: PropTypes$1.medias,
|
|
417
|
+
buttons: PropTypes.arrayOf(PropTypes.shape({})),
|
|
418
|
+
className: PropTypes.string,
|
|
419
|
+
onChange: PropTypes.func
|
|
1669
420
|
};
|
|
1670
421
|
var defaultProps = {
|
|
1671
|
-
|
|
422
|
+
value: null,
|
|
423
|
+
types: null,
|
|
1672
424
|
source: 'all',
|
|
425
|
+
filters: null,
|
|
426
|
+
fields: defaultFields,
|
|
427
|
+
columns: defaultColumns,
|
|
1673
428
|
isPicker: false,
|
|
1674
|
-
|
|
1675
|
-
withoutTitle: false,
|
|
1676
|
-
withoutSource: false,
|
|
1677
|
-
withoutType: true,
|
|
429
|
+
multiple: false,
|
|
1678
430
|
medias: null,
|
|
1679
|
-
|
|
431
|
+
buttons: null,
|
|
1680
432
|
className: null,
|
|
1681
|
-
|
|
1682
|
-
onChange: null,
|
|
1683
|
-
onClickMedia: null,
|
|
1684
|
-
onClearMedia: null
|
|
433
|
+
onChange: null
|
|
1685
434
|
};
|
|
1686
435
|
function MediaGallery(_ref) {
|
|
1687
|
-
var
|
|
436
|
+
var value = _ref.value,
|
|
437
|
+
types = _ref.types,
|
|
1688
438
|
source = _ref.source,
|
|
439
|
+
filters$1 = _ref.filters,
|
|
440
|
+
fields = _ref.fields,
|
|
441
|
+
columns = _ref.columns,
|
|
1689
442
|
isPicker = _ref.isPicker,
|
|
1690
|
-
|
|
1691
|
-
withoutTitle = _ref.withoutTitle,
|
|
1692
|
-
withoutSource = _ref.withoutSource,
|
|
1693
|
-
withoutType = _ref.withoutType,
|
|
443
|
+
multiple = _ref.multiple,
|
|
1694
444
|
initialMedias = _ref.medias,
|
|
1695
|
-
|
|
445
|
+
buttons = _ref.buttons,
|
|
1696
446
|
className = _ref.className,
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
clearTimeout(throttle.current);
|
|
1729
|
-
}
|
|
1730
|
-
throttle.current = setTimeout(function () {
|
|
1731
|
-
setQueryValue(value);
|
|
1732
|
-
throttle.current = null;
|
|
1733
|
-
}, 500);
|
|
1734
|
-
setFiltersValue(value);
|
|
1735
|
-
}, [setFiltersValue, setQueryValue, throttle]);
|
|
1736
|
-
var _useState5 = useState(initialMedias),
|
|
1737
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
1738
|
-
defaultItems = _useState6[0],
|
|
1739
|
-
setDefaultItems = _useState6[1];
|
|
1740
|
-
|
|
1741
|
-
// Items
|
|
1742
|
-
var _useMedias = useMedias(queryValue, 1, 30, {
|
|
1743
|
-
pages: defaultItems
|
|
1744
|
-
}),
|
|
1745
|
-
loadedMedias = _useMedias.items,
|
|
1746
|
-
_useMedias$loading = _useMedias.loading,
|
|
1747
|
-
loading = _useMedias$loading === void 0 ? false : _useMedias$loading,
|
|
1748
|
-
_useMedias$loadNextPa = _useMedias.loadNextPage,
|
|
1749
|
-
loadNextPage = _useMedias$loadNextPa === void 0 ? null : _useMedias$loadNextPa,
|
|
1750
|
-
_useMedias$allLoaded = _useMedias.allLoaded,
|
|
1751
|
-
allLoaded = _useMedias$allLoaded === void 0 ? false : _useMedias$allLoaded;
|
|
1752
|
-
|
|
1753
|
-
// Temporary type filter
|
|
1754
|
-
var _useState7 = useState([]),
|
|
1755
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
1756
|
-
addedMedias = _useState8[0],
|
|
1757
|
-
setAddedMedias = _useState8[1];
|
|
1758
|
-
var medias = useMemo(function () {
|
|
1759
|
-
var allMedias = [].concat(_toConsumableArray(addedMedias), _toConsumableArray(loadedMedias || []));
|
|
1760
|
-
return allMedias.length > 0 ? allMedias : null;
|
|
1761
|
-
}, [loadedMedias, addedMedias]);
|
|
1762
|
-
|
|
1763
|
-
// Medias
|
|
1764
|
-
var _useState9 = useState(null),
|
|
1765
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
1766
|
-
metadataMedia = _useState10[0],
|
|
1767
|
-
setMetadataMedia = _useState10[1];
|
|
1768
|
-
var onClickItem = useCallback(function (media) {
|
|
1769
|
-
var _ref3 = media || {},
|
|
1770
|
-
_ref3$id = _ref3.id,
|
|
1771
|
-
mediaId = _ref3$id === void 0 ? null : _ref3$id;
|
|
1772
|
-
var _ref4 = selectedMedia || {},
|
|
1773
|
-
_ref4$id = _ref4.id,
|
|
1774
|
-
selectedId = _ref4$id === void 0 ? null : _ref4$id;
|
|
1775
|
-
var different = mediaId !== selectedId;
|
|
1776
|
-
if (!isPicker) {
|
|
1777
|
-
setMetadataMedia(media);
|
|
1778
|
-
} else if (onClickMedia !== null) {
|
|
1779
|
-
if (different) {
|
|
1780
|
-
onClickMedia(media);
|
|
447
|
+
onChange = _ref.onChange;
|
|
448
|
+
var api = useApi();
|
|
449
|
+
var mediasApi = useMemo(function () {
|
|
450
|
+
return {
|
|
451
|
+
get: function get() {
|
|
452
|
+
var _api$medias;
|
|
453
|
+
return (_api$medias = api.medias).get.apply(_api$medias, arguments);
|
|
454
|
+
},
|
|
455
|
+
getTrashed: function getTrashed() {
|
|
456
|
+
var _api$medias2;
|
|
457
|
+
return (_api$medias2 = api.medias).get.apply(_api$medias2, arguments);
|
|
458
|
+
},
|
|
459
|
+
find: function find() {
|
|
460
|
+
var _api$medias3;
|
|
461
|
+
return (_api$medias3 = api.medias).find.apply(_api$medias3, arguments);
|
|
462
|
+
},
|
|
463
|
+
create: function create() {
|
|
464
|
+
var _api$medias4;
|
|
465
|
+
return (_api$medias4 = api.medias).create.apply(_api$medias4, arguments);
|
|
466
|
+
},
|
|
467
|
+
update: function update() {
|
|
468
|
+
var _api$medias5;
|
|
469
|
+
return (_api$medias5 = api.medias).update.apply(_api$medias5, arguments);
|
|
470
|
+
},
|
|
471
|
+
"delete": function _delete() {
|
|
472
|
+
var _api$medias6;
|
|
473
|
+
return (_api$medias6 = api.medias)["delete"].apply(_api$medias6, arguments);
|
|
474
|
+
},
|
|
475
|
+
trash: function trash() {
|
|
476
|
+
var _api$medias7;
|
|
477
|
+
return (_api$medias7 = api.medias)["delete"].apply(_api$medias7, arguments);
|
|
1781
478
|
}
|
|
1782
|
-
}
|
|
1783
|
-
}, [
|
|
1784
|
-
var onClickRemoveItem = useCallback(function () {
|
|
1785
|
-
setMetadataMedia(null);
|
|
1786
|
-
if (onClickMedia !== null) {
|
|
1787
|
-
onClickMedia(null);
|
|
1788
|
-
}
|
|
1789
|
-
}, [isPicker, setMetadataMedia, onClickMedia]);
|
|
1790
|
-
var onClickItemInfo = useCallback(function (media) {
|
|
1791
|
-
return setMetadataMedia(media);
|
|
1792
|
-
}, [setMetadataMedia]);
|
|
1793
|
-
var onMetadataClickClose = useCallback(function () {
|
|
1794
|
-
setMetadataMedia(null);
|
|
1795
|
-
}, [setMetadataMedia]);
|
|
1796
|
-
var onMetadataClickDelete = useCallback(function () {
|
|
1797
|
-
var mediaId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1798
|
-
var _ref5 = selectedMedia || {},
|
|
1799
|
-
_ref5$id = _ref5.id,
|
|
1800
|
-
selectedId = _ref5$id === void 0 ? null : _ref5$id;
|
|
1801
|
-
if (mediaId !== null && mediaId === selectedId && onClickMedia !== null) {
|
|
1802
|
-
onClickMedia(null);
|
|
1803
|
-
}
|
|
1804
|
-
setMetadataMedia(null);
|
|
1805
|
-
}, [setMetadataMedia, onClickMedia, selectedMedia]);
|
|
1806
|
-
var onMetadataChange = useCallback(function (val) {
|
|
1807
|
-
setMetadataMedia(val);
|
|
1808
|
-
var _ref6 = val || {},
|
|
1809
|
-
_ref6$id = _ref6.id,
|
|
1810
|
-
mediaId = _ref6$id === void 0 ? null : _ref6$id;
|
|
1811
|
-
var _ref7 = selectedMedia || {},
|
|
1812
|
-
_ref7$id = _ref7.id,
|
|
1813
|
-
selectedId = _ref7$id === void 0 ? null : _ref7$id;
|
|
1814
|
-
if (onChange !== null && mediaId === selectedId) {
|
|
1815
|
-
onChange(val);
|
|
1816
|
-
}
|
|
1817
|
-
}, [setMetadataMedia, selectedMedia, onChange]);
|
|
1818
|
-
useEffect(function () {
|
|
1819
|
-
if (metadataMedia !== null) {
|
|
1820
|
-
window.scrollTo(0, 0);
|
|
1821
|
-
}
|
|
1822
|
-
}, [metadataMedia]);
|
|
1823
|
-
|
|
1824
|
-
// Navigation
|
|
1825
|
-
var onClickBack = useCallback(function () {
|
|
1826
|
-
setMetadataMedia(null);
|
|
1827
|
-
}, [setMetadataMedia, setDefaultItems, setQueryValue]);
|
|
479
|
+
};
|
|
480
|
+
}, [api]);
|
|
1828
481
|
|
|
1829
482
|
// Upload modal
|
|
1830
|
-
var
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
var
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
var
|
|
1839
|
-
|
|
1840
|
-
|
|
483
|
+
var _useState = useState([]),
|
|
484
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
485
|
+
addedMedias = _useState2[0],
|
|
486
|
+
setAddedMedias = _useState2[1];
|
|
487
|
+
var _useState3 = useState(false),
|
|
488
|
+
_useState4 = _slicedToArray(_useState3, 2);
|
|
489
|
+
_useState4[0];
|
|
490
|
+
var setUploading = _useState4[1];
|
|
491
|
+
var _useState5 = useState(false),
|
|
492
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
493
|
+
uploadModalOpened = _useState6[0],
|
|
494
|
+
setUploadModalOpened = _useState6[1];
|
|
495
|
+
useCallback(function () {
|
|
1841
496
|
return setUploadModalOpened(true);
|
|
1842
497
|
}, [setUploadModalOpened]);
|
|
498
|
+
var _useMediaCreate = useMediaCreate(),
|
|
499
|
+
createMedia = _useMediaCreate.create;
|
|
1843
500
|
var onUploadCompleted = useCallback(function (newMedias) {
|
|
501
|
+
console.log('newMedias', newMedias);
|
|
1844
502
|
setUploading(true);
|
|
1845
503
|
Promise.all(newMedias.map(createMedia)).then(function (newAddedMedias) {
|
|
1846
504
|
setUploading(false);
|
|
@@ -1850,67 +508,75 @@ function MediaGallery(_ref) {
|
|
|
1850
508
|
var onUploadRequestClose = useCallback(function () {
|
|
1851
509
|
return setUploadModalOpened(false);
|
|
1852
510
|
}, [setUploadModalOpened]);
|
|
511
|
+
var partialFilters = filters$1 || filters() || [];
|
|
512
|
+
var finalFilters = useMemo(function () {
|
|
513
|
+
return partialFilters.map(function (filter) {
|
|
514
|
+
var _ref2 = filter || {},
|
|
515
|
+
_ref2$id = _ref2.id,
|
|
516
|
+
id = _ref2$id === void 0 ? null : _ref2$id;
|
|
517
|
+
if (id === 'sources') {
|
|
518
|
+
return filter;
|
|
519
|
+
}
|
|
520
|
+
// if (id === 'tags' && tags !== null) {
|
|
521
|
+
// return { ...filter, options: tags };
|
|
522
|
+
// }
|
|
523
|
+
return filter;
|
|
524
|
+
}).concat();
|
|
525
|
+
}, [partialFilters]);
|
|
526
|
+
var _useState7 = useState(source !== null ? {
|
|
527
|
+
source: source
|
|
528
|
+
} : null),
|
|
529
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
530
|
+
query = _useState8[0],
|
|
531
|
+
setQuery = _useState8[1];
|
|
532
|
+
var finalQuery = useMemo(function () {
|
|
533
|
+
setQuery(_objectSpread(_objectSpread({}, query || null), source !== null ? {
|
|
534
|
+
source: source
|
|
535
|
+
} : null));
|
|
536
|
+
}, [source, setQuery]);
|
|
537
|
+
var finalValue = useMemo(function () {
|
|
538
|
+
if (addedMedias === null || addedMedias.length === 0) {
|
|
539
|
+
return value;
|
|
540
|
+
}
|
|
541
|
+
console.log('finalValue', addedMedias);
|
|
542
|
+
var allMedias = [].concat(_toConsumableArray(addedMedias), _toConsumableArray(isArray(value) ? value || [] : [value]));
|
|
543
|
+
return allMedias.length > 0 ? allMedias : null;
|
|
544
|
+
}, [value, addedMedias]);
|
|
1853
545
|
return /*#__PURE__*/React.createElement("div", {
|
|
1854
|
-
className: classNames([styles.container, _defineProperty(
|
|
1855
|
-
}, /*#__PURE__*/React.createElement(
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
items:
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
className: "w-100 mb-2"
|
|
1889
|
-
}, loading || uploading ? /*#__PURE__*/React.createElement(Spinner, {
|
|
1890
|
-
className: styles.loading
|
|
1891
|
-
}) : null, !loading && !uploading ? /*#__PURE__*/React.createElement(Button, {
|
|
1892
|
-
className: "d-block mx-auto",
|
|
1893
|
-
theme: "secondary",
|
|
1894
|
-
outline: true,
|
|
1895
|
-
onClick: loadNextPage
|
|
1896
|
-
}, intl.formatMessage({
|
|
1897
|
-
id: "ur6G0U",
|
|
1898
|
-
defaultMessage: [{
|
|
1899
|
-
"type": 0,
|
|
1900
|
-
"value": "Load more"
|
|
1901
|
-
}]
|
|
1902
|
-
})) : null) : null), /*#__PURE__*/React.createElement("div", {
|
|
1903
|
-
className: styles.mediaMetadata
|
|
1904
|
-
}, /*#__PURE__*/React.createElement(MediaMetadata, {
|
|
1905
|
-
media: metadataMedia,
|
|
1906
|
-
tags: tags,
|
|
1907
|
-
onChange: onMetadataChange,
|
|
1908
|
-
onClickClose: onMetadataClickClose
|
|
1909
|
-
// onClickSave={onMetadataClickSave}
|
|
1910
|
-
,
|
|
1911
|
-
onClickDelete: onMetadataClickDelete
|
|
1912
|
-
}))), /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(UploadModal, {
|
|
1913
|
-
type: type === 'video' ? videoTypes : type,
|
|
546
|
+
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
547
|
+
}, isPicker ? /*#__PURE__*/React.createElement(MediasPickerContainer, {
|
|
548
|
+
className: styles.browser,
|
|
549
|
+
api: mediasApi,
|
|
550
|
+
value: finalValue,
|
|
551
|
+
theme: "dark",
|
|
552
|
+
types: types,
|
|
553
|
+
query: finalQuery,
|
|
554
|
+
multiple: multiple,
|
|
555
|
+
items: initialMedias,
|
|
556
|
+
filters: finalFilters,
|
|
557
|
+
fields: fields,
|
|
558
|
+
columns: columns,
|
|
559
|
+
onChange: onChange,
|
|
560
|
+
buttons: buttons,
|
|
561
|
+
buttonsClassName: "ms-xl-auto",
|
|
562
|
+
withStickySelection: true
|
|
563
|
+
}) : /*#__PURE__*/React.createElement(MediasBrowserContainer, {
|
|
564
|
+
className: styles.browser,
|
|
565
|
+
api: mediasApi,
|
|
566
|
+
value: finalValue,
|
|
567
|
+
theme: "dark",
|
|
568
|
+
types: types,
|
|
569
|
+
query: finalQuery,
|
|
570
|
+
multiple: multiple,
|
|
571
|
+
items: initialMedias,
|
|
572
|
+
filters: finalFilters,
|
|
573
|
+
fields: fields,
|
|
574
|
+
columns: columns,
|
|
575
|
+
buttons: buttons,
|
|
576
|
+
buttonsClassName: "ms-xl-auto",
|
|
577
|
+
withStickySelection: true
|
|
578
|
+
}), /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(UploadModal, {
|
|
579
|
+
types: types,
|
|
1914
580
|
opened: uploadModalOpened,
|
|
1915
581
|
onUploaded: onUploadCompleted,
|
|
1916
582
|
onRequestClose: onUploadRequestClose
|