@panneau/medias 3.0.159 → 3.0.160
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 -1
- package/es/index.js +243 -357
- package/lib/index.js +241 -357
- package/package.json +17 -17
package/es/index.js
CHANGED
@@ -4,16 +4,15 @@ import classNames from 'classnames';
|
|
4
4
|
import PropTypes from 'prop-types';
|
5
5
|
import React, { useContext, useMemo, useCallback, useState, useEffect } from 'react';
|
6
6
|
import { FormattedMessage } from 'react-intl';
|
7
|
-
import {
|
7
|
+
import { useFieldComponent, usePanneauResource } from '@panneau/core/contexts';
|
8
8
|
import { useForm, useQuery, useItemSelection } from '@panneau/core/hooks';
|
9
9
|
import Button from '@panneau/element-button';
|
10
10
|
import Form from '@panneau/element-form';
|
11
11
|
import FormStatus from '@panneau/element-form-status';
|
12
12
|
import MediaPlayer from '@panneau/element-media-player';
|
13
13
|
import MediaPreview from '@panneau/element-media-preview';
|
14
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
15
14
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
16
|
-
import
|
15
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
17
16
|
import { PropTypes as PropTypes$1 } from '@panneau/core';
|
18
17
|
import Buttons from '@panneau/element-buttons';
|
19
18
|
import Grid from '@panneau/element-grid';
|
@@ -59,7 +58,7 @@ function MediasApiProvider(_ref) {
|
|
59
58
|
MediasApiProvider.propTypes = propTypes$9;
|
60
59
|
MediasApiProvider.defaultProps = defaultProps$9;
|
61
60
|
|
62
|
-
var _excluded$
|
61
|
+
var _excluded$7 = ["items", "pageItems"];
|
63
62
|
var useMedias = function useMedias() {
|
64
63
|
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
65
64
|
var page = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
@@ -77,7 +76,7 @@ var useMedias = function useMedias() {
|
|
77
76
|
}, opts)),
|
78
77
|
items = _useItems.items,
|
79
78
|
pageItems = _useItems.pageItems,
|
80
|
-
request = _objectWithoutProperties(_useItems, _excluded$
|
79
|
+
request = _objectWithoutProperties(_useItems, _excluded$7);
|
81
80
|
return _objectSpread({
|
82
81
|
medias: page !== null ? pageItems : items,
|
83
82
|
allMedias: items
|
@@ -113,7 +112,7 @@ var useMediasRecent = function useMediasRecent(opts) {
|
|
113
112
|
};
|
114
113
|
var useMediasRecent$1 = useMediasRecent;
|
115
114
|
|
116
|
-
var _excluded$
|
115
|
+
var _excluded$6 = ["data"];
|
117
116
|
var useMedia = function useMedia(id, opts) {
|
118
117
|
var api = useMediasApi();
|
119
118
|
var loader = useCallback(function () {
|
@@ -121,7 +120,7 @@ var useMedia = function useMedia(id, opts) {
|
|
121
120
|
}, [api, id]);
|
122
121
|
var _useData = useData(loader, opts),
|
123
122
|
data = _useData.data,
|
124
|
-
request = _objectWithoutProperties(_useData, _excluded$
|
123
|
+
request = _objectWithoutProperties(_useData, _excluded$6);
|
125
124
|
return _objectSpread({
|
126
125
|
story: data
|
127
126
|
}, request);
|
@@ -234,120 +233,7 @@ function MediaFrame(_ref) {
|
|
234
233
|
MediaFrame.propTypes = propTypes$8;
|
235
234
|
MediaFrame.defaultProps = defaultProps$8;
|
236
235
|
|
237
|
-
var
|
238
|
-
_excluded2$1 = ["label", "value", "component"];
|
239
|
-
var propTypes$7 = {
|
240
|
-
value: PropTypes.shape({
|
241
|
-
metadata: PropTypes.shape({}),
|
242
|
-
user: PropTypes.shape({}),
|
243
|
-
createdAt: PropTypes.string
|
244
|
-
}),
|
245
|
-
sections: PropTypes.arrayOf(PropTypes.shape({
|
246
|
-
title: PropTypes.node,
|
247
|
-
items: PropTypes.arrayOf(PropTypes.shape({})) // displays
|
248
|
-
})),
|
249
|
-
displays: PropTypes.arrayOf(PropTypes.shape({
|
250
|
-
section: PropTypes.string
|
251
|
-
})),
|
252
|
-
className: PropTypes.string
|
253
|
-
};
|
254
|
-
var defaultProps$7 = {
|
255
|
-
value: null,
|
256
|
-
sections: null,
|
257
|
-
displays: null,
|
258
|
-
className: null
|
259
|
-
};
|
260
|
-
function MediaMetadata(_ref) {
|
261
|
-
var sections = _ref.sections,
|
262
|
-
displays = _ref.displays,
|
263
|
-
filtersValue = _ref.value,
|
264
|
-
className = _ref.className;
|
265
|
-
var displayComponents = useDisplaysComponentsManager();
|
266
|
-
var finalSections = useMemo(function () {
|
267
|
-
var displaysWithValue = (displays || []).map(function (_ref2) {
|
268
|
-
var _ref2$path = _ref2.path,
|
269
|
-
path = _ref2$path === void 0 ? null : _ref2$path,
|
270
|
-
props = _objectWithoutProperties(_ref2, _excluded$6);
|
271
|
-
return _objectSpread({
|
272
|
-
value: get(filtersValue, path, null)
|
273
|
-
}, props);
|
274
|
-
}).filter(function (_ref3) {
|
275
|
-
var _ref3$value = _ref3.value,
|
276
|
-
value = _ref3$value === void 0 ? null : _ref3$value;
|
277
|
-
return value !== null;
|
278
|
-
});
|
279
|
-
var displaysWithoutSection = (displaysWithValue || []).filter(function (_ref4) {
|
280
|
-
var _ref4$section = _ref4.section,
|
281
|
-
section = _ref4$section === void 0 ? null : _ref4$section;
|
282
|
-
return section === null;
|
283
|
-
});
|
284
|
-
return (sections || []).map(function (_ref5) {
|
285
|
-
var _ref5$id = _ref5.id,
|
286
|
-
id = _ref5$id === void 0 ? null : _ref5$id,
|
287
|
-
_ref5$title = _ref5.title,
|
288
|
-
title = _ref5$title === void 0 ? null : _ref5$title;
|
289
|
-
return {
|
290
|
-
id: id,
|
291
|
-
title: title,
|
292
|
-
items: (displaysWithValue || []).filter(function (_ref6) {
|
293
|
-
var _ref6$section = _ref6.section,
|
294
|
-
section = _ref6$section === void 0 ? null : _ref6$section;
|
295
|
-
return section === id;
|
296
|
-
})
|
297
|
-
};
|
298
|
-
}).concat({
|
299
|
-
id: 'others',
|
300
|
-
title: null,
|
301
|
-
items: displaysWithoutSection
|
302
|
-
}).filter(function (_ref7) {
|
303
|
-
var _ref7$items = _ref7.items,
|
304
|
-
items = _ref7$items === void 0 ? null : _ref7$items;
|
305
|
-
return items !== null && items.length > 0;
|
306
|
-
});
|
307
|
-
}, [sections, displays, filtersValue]);
|
308
|
-
return /*#__PURE__*/React.createElement("div", {
|
309
|
-
className: classNames(['px-2', _defineProperty({}, className, className !== null)])
|
310
|
-
}, (finalSections || []).map(function (_ref9, idx) {
|
311
|
-
var _ref9$title = _ref9.title,
|
312
|
-
title = _ref9$title === void 0 ? null : _ref9$title,
|
313
|
-
_ref9$items = _ref9.items,
|
314
|
-
items = _ref9$items === void 0 ? [] : _ref9$items;
|
315
|
-
return /*#__PURE__*/React.createElement("div", {
|
316
|
-
className: idx < finalSections.length - 1 ? 'mb-5' : null,
|
317
|
-
key: "section-".concat(idx + 1)
|
318
|
-
}, title !== null ? /*#__PURE__*/React.createElement("h6", {
|
319
|
-
className: "px-1"
|
320
|
-
}, title) : null, /*#__PURE__*/React.createElement("ul", {
|
321
|
-
className: "list-group list-group-flush"
|
322
|
-
}, (items || []).map(function (_ref10, index) {
|
323
|
-
var label = _ref10.label,
|
324
|
-
value = _ref10.value,
|
325
|
-
_ref10$component = _ref10.component,
|
326
|
-
component = _ref10$component === void 0 ? null : _ref10$component,
|
327
|
-
props = _objectWithoutProperties(_ref10, _excluded2$1);
|
328
|
-
var Component = displayComponents.getComponent(component || 'text');
|
329
|
-
var itemValue = value || null;
|
330
|
-
return Component !== null && itemValue !== null ? /*#__PURE__*/React.createElement("li", {
|
331
|
-
key: "item-".concat(index + 1),
|
332
|
-
className: classNames(['row', 'd-flex', 'align-items-center', 'justify-content-between', 'p-1', 'border-secondary-1', 'border-1', 'border-bottom', 'text-small', {
|
333
|
-
'border-top': index === 0
|
334
|
-
}])
|
335
|
-
}, /*#__PURE__*/React.createElement("div", {
|
336
|
-
className: "col-auto"
|
337
|
-
}, label), /*#__PURE__*/React.createElement("div", {
|
338
|
-
className: "col-auto align-right"
|
339
|
-
}, /*#__PURE__*/React.createElement(Component, Object.assign({}, props, {
|
340
|
-
value: itemValue
|
341
|
-
})))) : null;
|
342
|
-
})));
|
343
|
-
}));
|
344
|
-
}
|
345
|
-
MediaMetadata.propTypes = propTypes$7;
|
346
|
-
MediaMetadata.defaultProps = defaultProps$7;
|
347
|
-
|
348
|
-
var defaultFields = [
|
349
|
-
// { name: 'type', label: 'Type', type: 'string', component: 'text', disabled: true },
|
350
|
-
{
|
236
|
+
var defaultFields = [{
|
351
237
|
name: 'name',
|
352
238
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
353
239
|
id: "WX83V9",
|
@@ -369,159 +255,121 @@ var defaultFields = [
|
|
369
255
|
}),
|
370
256
|
type: 'text',
|
371
257
|
component: 'text'
|
372
|
-
}
|
373
|
-
// {
|
374
|
-
// name: 'url',
|
375
|
-
// label: <FormattedMessage defaultMessage="URL" description="Field name" />,
|
376
|
-
// type: 'text',
|
377
|
-
// component: 'url',
|
378
|
-
// },
|
379
|
-
// {
|
380
|
-
// name: 'thumbnail_url',
|
381
|
-
// label: <FormattedMessage defaultMessage="Thumbnail URL" description="Field name" />,
|
382
|
-
// type: 'text',
|
383
|
-
// component: 'url',
|
384
|
-
// },
|
385
|
-
];
|
386
|
-
|
387
|
-
var defaultDisplays = [{
|
388
|
-
id: 'user',
|
389
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
390
|
-
id: "yByaBh",
|
391
|
-
defaultMessage: [{
|
392
|
-
"type": 0,
|
393
|
-
"value": "Added by"
|
394
|
-
}]
|
395
|
-
}),
|
396
|
-
component: 'avatar',
|
397
|
-
path: 'user',
|
398
|
-
section: 'info'
|
399
258
|
}, {
|
400
|
-
id: 'created_at',
|
401
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
402
|
-
id: "PN+75e",
|
403
|
-
defaultMessage: [{
|
404
|
-
"type": 0,
|
405
|
-
"value": "Created at"
|
406
|
-
}]
|
407
|
-
}),
|
408
|
-
component: 'date',
|
409
|
-
path: 'created_at',
|
410
|
-
format: 'yyyy-MM-dd hh:ss',
|
411
|
-
section: 'info'
|
412
|
-
}, {
|
413
|
-
id: 'format',
|
414
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
415
|
-
id: "JuxiUN",
|
416
|
-
defaultMessage: [{
|
417
|
-
"type": 0,
|
418
|
-
"value": "Format"
|
419
|
-
}]
|
420
|
-
}),
|
421
|
-
component: 'unit',
|
422
|
-
format: 'format',
|
423
|
-
path: 'format',
|
424
|
-
section: 'technical'
|
425
|
-
}, {
|
426
|
-
id: 'dimensions',
|
427
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
428
|
-
id: "rmJBin",
|
429
|
-
defaultMessage: [{
|
430
|
-
"type": 0,
|
431
|
-
"value": "Dimensions"
|
432
|
-
}]
|
433
|
-
}),
|
434
|
-
component: 'unit',
|
435
|
-
format: 'dimensions',
|
436
|
-
path: 'metadata',
|
437
|
-
section: 'technical'
|
438
|
-
}, {
|
439
|
-
id: 'size',
|
440
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
441
|
-
id: "g2CRt5",
|
442
|
-
defaultMessage: [{
|
443
|
-
"type": 0,
|
444
|
-
"value": "Size"
|
445
|
-
}]
|
446
|
-
}),
|
447
|
-
component: 'unit',
|
448
|
-
format: 'bytes',
|
449
|
-
path: 'metadata.size',
|
450
|
-
section: 'technical'
|
451
|
-
}, {
|
452
|
-
id: 'duration',
|
453
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
454
|
-
id: "wU++NJ",
|
455
|
-
defaultMessage: [{
|
456
|
-
"type": 0,
|
457
|
-
"value": "Duration"
|
458
|
-
}]
|
459
|
-
}),
|
460
|
-
component: 'unit',
|
461
|
-
format: 'duration',
|
462
|
-
path: 'metadata.duration',
|
463
|
-
section: 'technical'
|
464
|
-
}];
|
465
|
-
|
466
|
-
var defaultSections = [{
|
467
259
|
id: 'info',
|
260
|
+
component: 'fields',
|
468
261
|
title: /*#__PURE__*/React.createElement(FormattedMessage, {
|
469
262
|
id: "3RT69u",
|
470
263
|
defaultMessage: [{
|
471
264
|
"type": 0,
|
472
265
|
"value": "Informations"
|
473
266
|
}]
|
474
|
-
})
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
267
|
+
}),
|
268
|
+
fields: [{
|
269
|
+
id: 'user',
|
270
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
271
|
+
id: "yByaBh",
|
272
|
+
defaultMessage: [{
|
273
|
+
"type": 0,
|
274
|
+
"value": "Added by"
|
275
|
+
}]
|
276
|
+
}),
|
277
|
+
component: 'display',
|
278
|
+
type: 'avatar',
|
279
|
+
path: 'user',
|
280
|
+
section: 'info'
|
281
|
+
}, {
|
282
|
+
id: 'created_at',
|
283
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
284
|
+
id: "PN+75e",
|
285
|
+
defaultMessage: [{
|
286
|
+
"type": 0,
|
287
|
+
"value": "Created at"
|
288
|
+
}]
|
289
|
+
}),
|
290
|
+
component: 'display',
|
291
|
+
type: 'date',
|
292
|
+
path: 'created_at',
|
293
|
+
format: 'yyyy-MM-dd hh:ss',
|
294
|
+
section: 'info'
|
295
|
+
}]
|
296
|
+
}
|
297
|
+
// {
|
298
|
+
// id: 'technical',
|
299
|
+
// component: 'fields',
|
300
|
+
// title: <FormattedMessage defaultMessage="Technical details" description="Field title" />,
|
301
|
+
// fields: [
|
302
|
+
// {
|
303
|
+
// id: 'format',
|
304
|
+
// label: <FormattedMessage defaultMessage="Format" description="Field label" />,
|
305
|
+
// type: 'display',
|
306
|
+
// component: 'unit',
|
307
|
+
// format: 'format',
|
308
|
+
// path: 'format',
|
309
|
+
// section: 'technical',
|
310
|
+
// },
|
311
|
+
// {
|
312
|
+
// id: 'dimensions',
|
313
|
+
// label: <FormattedMessage defaultMessage="Dimensions" description="Field label" />,
|
314
|
+
// type: 'display',
|
315
|
+
// component: 'unit',
|
316
|
+
// format: 'dimensions',
|
317
|
+
// path: 'metadata',
|
318
|
+
// section: 'technical',
|
319
|
+
// },
|
320
|
+
// {
|
321
|
+
// id: 'size',
|
322
|
+
// label: <FormattedMessage defaultMessage="Size" description="Field label" />,
|
323
|
+
// type: 'display',
|
324
|
+
// component: 'unit',
|
325
|
+
// format: 'bytes',
|
326
|
+
// path: 'metadata.size',
|
327
|
+
// section: 'technical',
|
328
|
+
// },
|
329
|
+
// {
|
330
|
+
// id: 'duration',
|
331
|
+
// label: <FormattedMessage defaultMessage="Duration" description="Field label" />,
|
332
|
+
// type: 'display',
|
333
|
+
// component: 'unit',
|
334
|
+
// format: 'duration',
|
335
|
+
// path: 'metadata.duration',
|
336
|
+
// section: 'technical',
|
337
|
+
// },
|
338
|
+
// ],
|
339
|
+
// },
|
340
|
+
];
|
485
341
|
|
486
|
-
var propTypes$
|
342
|
+
var propTypes$7 = {
|
487
343
|
value: PropTypes.shape({
|
488
344
|
id: PropTypes.string
|
489
345
|
}),
|
490
346
|
fields: PropTypes.arrayOf(PropTypes.shape({
|
491
347
|
name: PropTypes.string
|
492
348
|
})),
|
493
|
-
sections: PropTypes.arrayOf(PropTypes.shape({
|
494
|
-
id: PropTypes.string,
|
495
|
-
title: PropTypes.string
|
496
|
-
})),
|
497
|
-
displays: PropTypes.arrayOf(PropTypes.shape({
|
498
|
-
name: PropTypes.string
|
499
|
-
})),
|
500
349
|
onChange: PropTypes.func.isRequired,
|
501
350
|
onSave: PropTypes.func.isRequired,
|
502
351
|
onDelete: PropTypes.func,
|
503
352
|
onClose: PropTypes.func,
|
504
|
-
className: PropTypes.string
|
353
|
+
className: PropTypes.string,
|
354
|
+
children: PropTypes.node
|
505
355
|
};
|
506
|
-
var defaultProps$
|
356
|
+
var defaultProps$7 = {
|
507
357
|
value: null,
|
508
358
|
fields: defaultFields,
|
509
|
-
sections: defaultSections,
|
510
|
-
displays: defaultDisplays,
|
511
359
|
onClose: null,
|
512
360
|
onDelete: null,
|
513
|
-
className: null
|
361
|
+
className: null,
|
362
|
+
children: null
|
514
363
|
};
|
515
364
|
function MediaForm(_ref) {
|
516
365
|
var initialValue = _ref.value,
|
517
366
|
initialFields = _ref.fields,
|
518
|
-
sections = _ref.sections,
|
519
|
-
displays = _ref.displays,
|
520
367
|
onChange = _ref.onChange,
|
521
368
|
onSave = _ref.onSave,
|
522
369
|
onDelete = _ref.onDelete,
|
523
370
|
onClose = _ref.onClose,
|
524
|
-
className = _ref.className
|
371
|
+
className = _ref.className,
|
372
|
+
children = _ref.children;
|
525
373
|
var FieldsComponent = useFieldComponent('fields');
|
526
374
|
var _useMediaUpdate = useMediaUpdate$1(),
|
527
375
|
update = _useMediaUpdate.update,
|
@@ -588,9 +436,9 @@ function MediaForm(_ref) {
|
|
588
436
|
}, /*#__PURE__*/React.createElement("div", {
|
589
437
|
className: "d-flex w-100 align-items-start justify-content-between mb-3 pb-2 border-bottom"
|
590
438
|
}, /*#__PURE__*/React.createElement("div", {
|
591
|
-
className: "d-flex align-items-end mb-0"
|
439
|
+
className: "d-flex align-items-end justify-content-end mb-0"
|
592
440
|
}, /*#__PURE__*/React.createElement("h4", {
|
593
|
-
className: "d-inline text-break mb-
|
441
|
+
className: "d-inline text-break mb-0"
|
594
442
|
}, name), /*#__PURE__*/React.createElement("span", {
|
595
443
|
className: "mx-2"
|
596
444
|
}, type)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
|
@@ -625,7 +473,7 @@ function MediaForm(_ref) {
|
|
625
473
|
className: styles.mediaFrame
|
626
474
|
}, /*#__PURE__*/React.createElement(MediaFrame, {
|
627
475
|
value: value
|
628
|
-
})))), /*#__PURE__*/React.createElement("div", {
|
476
|
+
}))), children), /*#__PURE__*/React.createElement("div", {
|
629
477
|
className: "col-md-6"
|
630
478
|
}, /*#__PURE__*/React.createElement(Form, {
|
631
479
|
onChange: onChangeMedia,
|
@@ -635,19 +483,47 @@ function MediaForm(_ref) {
|
|
635
483
|
value: value,
|
636
484
|
onChange: setValue,
|
637
485
|
disabled: disabled
|
638
|
-
})), /*#__PURE__*/React.createElement(
|
639
|
-
className: "mt-5",
|
640
|
-
value: value,
|
641
|
-
sections: sections,
|
642
|
-
displays: displays
|
643
|
-
}), generalError !== null && status !== null ? /*#__PURE__*/React.createElement("div", {
|
486
|
+
})), generalError !== null && status !== null ? /*#__PURE__*/React.createElement("div", {
|
644
487
|
className: "mt-5"
|
645
488
|
}, /*#__PURE__*/React.createElement(FormStatus, {
|
646
489
|
status: status
|
647
490
|
})) : null)));
|
648
491
|
}
|
649
|
-
MediaForm.propTypes = propTypes$
|
650
|
-
MediaForm.defaultProps = defaultProps$
|
492
|
+
MediaForm.propTypes = propTypes$7;
|
493
|
+
MediaForm.defaultProps = defaultProps$7;
|
494
|
+
|
495
|
+
var MediasFormContext = /*#__PURE__*/React.createContext(null);
|
496
|
+
var useMediasForm = function useMediasForm() {
|
497
|
+
return useContext(MediasFormContext);
|
498
|
+
};
|
499
|
+
var propTypes$6 = {
|
500
|
+
media: PropTypes.shape({
|
501
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
502
|
+
}),
|
503
|
+
children: PropTypes.node.isRequired
|
504
|
+
};
|
505
|
+
var defaultProps$6 = {
|
506
|
+
media: null
|
507
|
+
};
|
508
|
+
function MediasFormProvider(_ref) {
|
509
|
+
var providedMedia = _ref.media,
|
510
|
+
children = _ref.children;
|
511
|
+
var _useState = useState(providedMedia),
|
512
|
+
_useState2 = _slicedToArray(_useState, 2),
|
513
|
+
media = _useState2[0],
|
514
|
+
setMedia = _useState2[1];
|
515
|
+
var values = useMemo(function () {
|
516
|
+
return {
|
517
|
+
media: media,
|
518
|
+
setMedia: setMedia
|
519
|
+
};
|
520
|
+
}, [media, setMedia]);
|
521
|
+
return /*#__PURE__*/React.createElement(MediasFormContext.Provider, {
|
522
|
+
value: values
|
523
|
+
}, children);
|
524
|
+
}
|
525
|
+
MediasFormProvider.propTypes = propTypes$6;
|
526
|
+
MediasFormProvider.defaultProps = defaultProps$6;
|
651
527
|
|
652
528
|
var defaultColumns = [{
|
653
529
|
id: 'image',
|
@@ -704,19 +580,6 @@ var defaultColumns = [{
|
|
704
580
|
})
|
705
581
|
},
|
706
582
|
sortable: true
|
707
|
-
}, {
|
708
|
-
id: 'created_at',
|
709
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
710
|
-
id: "OzYWZz",
|
711
|
-
defaultMessage: [{
|
712
|
-
"type": 0,
|
713
|
-
"value": "Created at"
|
714
|
-
}]
|
715
|
-
}),
|
716
|
-
component: 'date',
|
717
|
-
path: 'created_at',
|
718
|
-
format: 'yyyy-MM-dd hh:ss',
|
719
|
-
sortable: true
|
720
583
|
}, {
|
721
584
|
id: 'dimensions',
|
722
585
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
@@ -753,19 +616,28 @@ var defaultColumns = [{
|
|
753
616
|
component: 'unit',
|
754
617
|
format: 'duration',
|
755
618
|
path: 'metadata.duration'
|
756
|
-
},
|
757
|
-
|
619
|
+
},
|
620
|
+
// {
|
621
|
+
// id: 'author',
|
622
|
+
// label: <FormattedMessage defaultMessage="Added by" description="Field name" />,
|
623
|
+
// component: 'avatar',
|
624
|
+
// path: 'metadata.author',
|
625
|
+
// namePath: 'name',
|
626
|
+
// withoutName: true,
|
627
|
+
// },
|
628
|
+
{
|
629
|
+
id: 'created_at',
|
758
630
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
759
|
-
id: "
|
631
|
+
id: "OzYWZz",
|
760
632
|
defaultMessage: [{
|
761
633
|
"type": 0,
|
762
|
-
"value": "
|
634
|
+
"value": "Created at"
|
763
635
|
}]
|
764
636
|
}),
|
765
|
-
component: '
|
766
|
-
path: '
|
767
|
-
|
768
|
-
|
637
|
+
component: 'date',
|
638
|
+
path: 'created_at',
|
639
|
+
format: 'yyyy-MM-dd hh:ss',
|
640
|
+
sortable: true
|
769
641
|
}, {
|
770
642
|
id: 'actions',
|
771
643
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
@@ -837,35 +709,26 @@ var defaultFilters = [{
|
|
837
709
|
value: 'document'
|
838
710
|
}],
|
839
711
|
multiple: true
|
840
|
-
},
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
defaultMessage: [{
|
861
|
-
"type": 0,
|
862
|
-
"value": "Tag"
|
863
|
-
}]
|
864
|
-
}),
|
865
|
-
requestUrl: '/tags',
|
866
|
-
itemLabelPath: 'label',
|
867
|
-
multiple: true
|
868
|
-
}, {
|
712
|
+
},
|
713
|
+
// {
|
714
|
+
// id: 'author',
|
715
|
+
// component: 'select',
|
716
|
+
// name: 'author',
|
717
|
+
// placeholder: <FormattedMessage defaultMessage="Author" description="Filter label" />,
|
718
|
+
// requestUrl: '/persons',
|
719
|
+
// itemLabelPath: 'name',
|
720
|
+
// multiple: true,
|
721
|
+
// },
|
722
|
+
// {
|
723
|
+
// id: 'tag',
|
724
|
+
// component: 'select',
|
725
|
+
// name: 'tag',
|
726
|
+
// placeholder: <FormattedMessage defaultMessage="Tag" description="Filter label" />,
|
727
|
+
// requestUrl: '/tags',
|
728
|
+
// itemLabelPath: 'label',
|
729
|
+
// multiple: true,
|
730
|
+
// },
|
731
|
+
{
|
869
732
|
id: 'search',
|
870
733
|
component: 'search',
|
871
734
|
name: 'search'
|
@@ -885,14 +748,6 @@ var propTypes$5 = {
|
|
885
748
|
query: PropTypes.shape({}),
|
886
749
|
baseUrl: PropTypes.string,
|
887
750
|
fields: PropTypes$1.fields,
|
888
|
-
metadatas: PropTypes.shape({
|
889
|
-
sections: PropTypes.arrayOf(PropTypes.shape({
|
890
|
-
id: PropTypes.string
|
891
|
-
})),
|
892
|
-
displays: PropTypes.arrayOf(PropTypes.shape({
|
893
|
-
id: PropTypes.string
|
894
|
-
}))
|
895
|
-
}),
|
896
751
|
layout: PropTypes.string,
|
897
752
|
layouts: PropTypes.arrayOf(PropTypes.shape({})),
|
898
753
|
theme: PropTypes.string,
|
@@ -913,10 +768,6 @@ var defaultProps$5 = {
|
|
913
768
|
filters: defaultFilters,
|
914
769
|
columns: defaultColumns,
|
915
770
|
fields: defaultFields,
|
916
|
-
metadatas: {
|
917
|
-
sections: defaultSections,
|
918
|
-
displays: defaultDisplays
|
919
|
-
},
|
920
771
|
query: null,
|
921
772
|
baseUrl: null,
|
922
773
|
layout: 'table',
|
@@ -950,7 +801,6 @@ function MediasBrowser(_ref) {
|
|
950
801
|
filters = _ref.filters,
|
951
802
|
columns = _ref.columns,
|
952
803
|
fields = _ref.fields,
|
953
|
-
metadatas = _ref.metadatas,
|
954
804
|
initialQuery = _ref.query,
|
955
805
|
initialLayout = _ref.layout,
|
956
806
|
layouts = _ref.layouts,
|
@@ -963,14 +813,13 @@ function MediasBrowser(_ref) {
|
|
963
813
|
selectedCount = _ref.selectedCount,
|
964
814
|
onClearSelected = _ref.onClearSelected,
|
965
815
|
className = _ref.className;
|
966
|
-
var _ref2 = metadatas || {},
|
967
|
-
sections = _ref2.sections,
|
968
|
-
displays = _ref2.displays;
|
969
816
|
var _useState = useState(initialItems || null),
|
970
817
|
_useState2 = _slicedToArray(_useState, 1),
|
971
818
|
baseItems = _useState2[0];
|
972
819
|
var baseQuery = useMemo(function () {
|
973
|
-
return _objectSpread(_objectSpread({
|
820
|
+
return _objectSpread(_objectSpread({
|
821
|
+
count: 12
|
822
|
+
}, initialQuery), {}, {
|
974
823
|
types: types
|
975
824
|
});
|
976
825
|
}, [initialQuery, types]);
|
@@ -980,12 +829,12 @@ function MediasBrowser(_ref) {
|
|
980
829
|
onQueryChange = _useQuery.onQueryChange,
|
981
830
|
onQueryReset = _useQuery.onQueryReset;
|
982
831
|
var _useMemo = useMemo(function () {
|
983
|
-
var
|
984
|
-
|
985
|
-
fullQueryPage =
|
986
|
-
|
987
|
-
fullQueryCount =
|
988
|
-
params = _objectWithoutProperties(
|
832
|
+
var _ref2 = fullQuery || {},
|
833
|
+
_ref2$page = _ref2.page,
|
834
|
+
fullQueryPage = _ref2$page === void 0 ? null : _ref2$page,
|
835
|
+
_ref2$count = _ref2.count,
|
836
|
+
fullQueryCount = _ref2$count === void 0 ? null : _ref2$count,
|
837
|
+
params = _objectWithoutProperties(_ref2, _excluded$5);
|
989
838
|
return {
|
990
839
|
page: fullQueryPage,
|
991
840
|
count: fullQueryCount,
|
@@ -1000,9 +849,9 @@ function MediasBrowser(_ref) {
|
|
1000
849
|
query = _useMemo$query === void 0 ? null : _useMemo$query;
|
1001
850
|
|
1002
851
|
// eslint-disable-next-line no-unused-vars
|
1003
|
-
var
|
1004
|
-
|
1005
|
-
var queryWithoutTypes = _objectWithoutProperties(
|
852
|
+
var _ref3 = query || {};
|
853
|
+
_ref3.types;
|
854
|
+
var queryWithoutTypes = _objectWithoutProperties(_ref3, _excluded2);
|
1006
855
|
var _useMedias = useMedias$1(query, page, count, {
|
1007
856
|
items: baseItems
|
1008
857
|
}),
|
@@ -1030,10 +879,11 @@ function MediasBrowser(_ref) {
|
|
1030
879
|
onLayoutChange(newLayout);
|
1031
880
|
}
|
1032
881
|
}, [setLayout]);
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
882
|
+
|
883
|
+
// const [currentMedia, setCurrentMedia] = useState(null);
|
884
|
+
var _useMediasForm = useMediasForm(),
|
885
|
+
currentMedia = _useMediasForm.media,
|
886
|
+
setCurrentMedia = _useMediasForm.setMedia;
|
1037
887
|
var onOpenMedia = useCallback(function (media) {
|
1038
888
|
setCurrentMedia(media);
|
1039
889
|
}, [setCurrentMedia]);
|
@@ -1042,7 +892,6 @@ function MediasBrowser(_ref) {
|
|
1042
892
|
}, [setCurrentMedia]);
|
1043
893
|
var onChangeMedia = useCallback(function () {
|
1044
894
|
var media = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
1045
|
-
console.log('media', media);
|
1046
895
|
onSelectItems(media);
|
1047
896
|
onQueryReset();
|
1048
897
|
}, [setCurrentMedia, onQueryReset, onSelectItems]);
|
@@ -1063,9 +912,9 @@ function MediasBrowser(_ref) {
|
|
1063
912
|
var finalFilters = useMemo(function () {
|
1064
913
|
if (types !== null && filters !== null) {
|
1065
914
|
return (filters || []).map(function (filter) {
|
1066
|
-
var
|
1067
|
-
|
1068
|
-
id =
|
915
|
+
var _ref4 = filter || {},
|
916
|
+
_ref4$id = _ref4.id,
|
917
|
+
id = _ref4$id === void 0 ? null : _ref4$id;
|
1069
918
|
return id === 'types' ? _objectSpread(_objectSpread({}, filter), {}, {
|
1070
919
|
disabled: true
|
1071
920
|
}) : filter;
|
@@ -1091,25 +940,30 @@ function MediasBrowser(_ref) {
|
|
1091
940
|
}))), /*#__PURE__*/React.createElement(MediaForm, {
|
1092
941
|
value: currentMedia,
|
1093
942
|
fields: fields,
|
1094
|
-
sections: sections,
|
1095
|
-
displays: displays,
|
1096
943
|
onClose: onCloseMedia
|
1097
|
-
})) : /*#__PURE__*/React.createElement(React.Fragment, null,
|
1098
|
-
className: "mt-2 mb-4"
|
1099
|
-
}, /*#__PURE__*/React.createElement(UploadField, Object.assign({
|
1100
|
-
onChange: onChangeMedia,
|
1101
|
-
withButton: true
|
1102
|
-
}, uploadButton))) : null, buttons !== null ? /*#__PURE__*/React.createElement(Buttons, {
|
944
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null, buttons !== null ? /*#__PURE__*/React.createElement(Buttons, {
|
1103
945
|
items: buttons,
|
1104
946
|
className: "mb-2"
|
1105
947
|
}) : null, filters !== null ? /*#__PURE__*/React.createElement(Filters, {
|
948
|
+
className: "mt-0 pt-0",
|
1106
949
|
value: query,
|
1107
950
|
clearValue: types !== null ? queryWithoutTypes : null,
|
1108
951
|
filters: finalFilters,
|
1109
952
|
onChange: onQueryChange,
|
1110
953
|
onReset: onQueryReset,
|
1111
954
|
theme: theme
|
1112
|
-
}
|
955
|
+
}, uploadButton !== null ? /*#__PURE__*/React.createElement(UploadField, Object.assign({
|
956
|
+
className: "w-auto mb-2",
|
957
|
+
onChange: onChangeMedia,
|
958
|
+
withButton: true,
|
959
|
+
withoutMedia: true
|
960
|
+
}, uploadButton)) : null) : null, filters === null && uploadButton !== null ? /*#__PURE__*/React.createElement("div", {
|
961
|
+
className: "mt-2 mb-2"
|
962
|
+
}, /*#__PURE__*/React.createElement(UploadField, Object.assign({
|
963
|
+
onChange: onChangeMedia,
|
964
|
+
withButton: true,
|
965
|
+
withoutMedia: true
|
966
|
+
}, uploadButton))) : null, /*#__PURE__*/React.createElement("div", {
|
1113
967
|
className: classNames(['d-flex', 'mt-1', 'mb-3', {
|
1114
968
|
'justify-content-between': hasLayouts,
|
1115
969
|
'justify-content-end': !hasLayouts
|
@@ -1128,7 +982,7 @@ function MediasBrowser(_ref) {
|
|
1128
982
|
});
|
1129
983
|
})
|
1130
984
|
}) : null, pagination), layout === 'grid' ? /*#__PURE__*/React.createElement(Grid, Object.assign({
|
1131
|
-
size: "
|
985
|
+
size: "small",
|
1132
986
|
theme: theme,
|
1133
987
|
component: MediaCard,
|
1134
988
|
componentProps: {
|
@@ -1151,6 +1005,16 @@ function MediasBrowser(_ref) {
|
|
1151
1005
|
items: items,
|
1152
1006
|
onSelectItem: onSelectItem !== null ? onSelectItem : function (it) {
|
1153
1007
|
return onOpenMedia(it);
|
1008
|
+
},
|
1009
|
+
actionsProps: {
|
1010
|
+
getEditPropsFromItem: function getEditPropsFromItem(it) {
|
1011
|
+
return {
|
1012
|
+
href: null,
|
1013
|
+
onClick: function onClick() {
|
1014
|
+
onOpenMedia(it);
|
1015
|
+
}
|
1016
|
+
};
|
1017
|
+
}
|
1154
1018
|
}
|
1155
1019
|
})) : null, /*#__PURE__*/React.createElement("div", {
|
1156
1020
|
className: classNames(['d-flex', 'mt-3', 'mb-1', 'justify-content-end'])
|
@@ -1208,6 +1072,8 @@ function MediasPicker(_ref) {
|
|
1208
1072
|
setItems(pageItems);
|
1209
1073
|
}, [setItems]);
|
1210
1074
|
var disabled = initialItems === null || initialItems.length < 1;
|
1075
|
+
var _useMediasForm = useMediasForm(),
|
1076
|
+
currentMedia = _useMediasForm.media;
|
1211
1077
|
var _useItemSelection = useItemSelection({
|
1212
1078
|
items: items,
|
1213
1079
|
selectedItems: initialSelectedItems,
|
@@ -1221,6 +1087,11 @@ function MediasPicker(_ref) {
|
|
1221
1087
|
pageSelected = _useItemSelection.pageSelected,
|
1222
1088
|
selectedCount = _useItemSelection.selectedCount,
|
1223
1089
|
selectedItems = _useItemSelection.selectedItems;
|
1090
|
+
var onConfirmSelection = useCallback(function () {
|
1091
|
+
if (onConfirm !== null) {
|
1092
|
+
onConfirm(selectedItems);
|
1093
|
+
}
|
1094
|
+
}, [selectedItems, onConfirm]);
|
1224
1095
|
var finalUploadButton = useMemo(function () {
|
1225
1096
|
return _objectSpread(_objectSpread(_objectSpread({}, uploadButton || null), types !== null ? {
|
1226
1097
|
types: types
|
@@ -1249,7 +1120,7 @@ function MediasPicker(_ref) {
|
|
1249
1120
|
onClearSelected: onClearSelected,
|
1250
1121
|
uploadButton: finalUploadButton,
|
1251
1122
|
types: types
|
1252
|
-
}, props)), multiple && !withoutButtons ? /*#__PURE__*/React.createElement("div", {
|
1123
|
+
}, props)), multiple && !withoutButtons && currentMedia === null ? /*#__PURE__*/React.createElement("div", {
|
1253
1124
|
className: "d-flex w-100 align-items-end justify-content-end mt-3"
|
1254
1125
|
}, /*#__PURE__*/React.createElement("div", {
|
1255
1126
|
className: "btn-group"
|
@@ -1267,7 +1138,7 @@ function MediasPicker(_ref) {
|
|
1267
1138
|
})) : null, /*#__PURE__*/React.createElement(Button, {
|
1268
1139
|
type: "button",
|
1269
1140
|
theme: "primary",
|
1270
|
-
onClick:
|
1141
|
+
onClick: onConfirmSelection,
|
1271
1142
|
disabled: disabled,
|
1272
1143
|
outline: disabled,
|
1273
1144
|
className: "d-block"
|
@@ -1282,40 +1153,54 @@ function MediasPicker(_ref) {
|
|
1282
1153
|
MediasPicker.propTypes = propTypes$4;
|
1283
1154
|
MediasPicker.defaultProps = defaultProps$4;
|
1284
1155
|
|
1285
|
-
var _excluded$3 = ["api"];
|
1156
|
+
var _excluded$3 = ["api", "media"];
|
1286
1157
|
var propTypes$3 = {
|
1287
|
-
api: apiPropTypes
|
1158
|
+
api: apiPropTypes,
|
1159
|
+
media: PropTypes.shape({
|
1160
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
1161
|
+
})
|
1288
1162
|
};
|
1289
1163
|
var defaultProps$3 = {
|
1290
|
-
api: null
|
1164
|
+
api: null,
|
1165
|
+
media: null
|
1291
1166
|
};
|
1292
1167
|
function MediasBrowserContainer(_ref) {
|
1293
1168
|
var api = _ref.api,
|
1169
|
+
media = _ref.media,
|
1294
1170
|
props = _objectWithoutProperties(_ref, _excluded$3);
|
1295
1171
|
return /*#__PURE__*/React.createElement(MediasApiProvider, {
|
1296
1172
|
api: api
|
1297
|
-
}, /*#__PURE__*/React.createElement(
|
1173
|
+
}, /*#__PURE__*/React.createElement(MediasFormProvider, {
|
1174
|
+
media: media
|
1175
|
+
}, /*#__PURE__*/React.createElement(MediasBrowser, props)));
|
1298
1176
|
}
|
1299
1177
|
MediasBrowserContainer.propTypes = propTypes$3;
|
1300
1178
|
MediasBrowserContainer.defaultProps = defaultProps$3;
|
1301
1179
|
|
1302
|
-
var _excluded$2 = ["api", "onChange"];
|
1180
|
+
var _excluded$2 = ["api", "media", "onChange"];
|
1303
1181
|
var propTypes$2 = {
|
1304
1182
|
api: apiPropTypes,
|
1183
|
+
media: PropTypes.shape({
|
1184
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
1185
|
+
}),
|
1305
1186
|
onChange: PropTypes.func.isRequired
|
1306
1187
|
};
|
1307
1188
|
var defaultProps$2 = {
|
1308
|
-
api: null
|
1189
|
+
api: null,
|
1190
|
+
media: null
|
1309
1191
|
};
|
1310
1192
|
function MediasPickerContainer(_ref) {
|
1311
1193
|
var api = _ref.api,
|
1194
|
+
media = _ref.media,
|
1312
1195
|
onChange = _ref.onChange,
|
1313
1196
|
props = _objectWithoutProperties(_ref, _excluded$2);
|
1314
1197
|
return /*#__PURE__*/React.createElement(MediasApiProvider, {
|
1315
1198
|
api: api
|
1199
|
+
}, /*#__PURE__*/React.createElement(MediasFormProvider, {
|
1200
|
+
media: media
|
1316
1201
|
}, /*#__PURE__*/React.createElement(MediasPicker, Object.assign({}, props, {
|
1317
1202
|
onChange: onChange
|
1318
|
-
})));
|
1203
|
+
}))));
|
1319
1204
|
}
|
1320
1205
|
MediasPickerContainer.propTypes = propTypes$2;
|
1321
1206
|
MediasPickerContainer.defaultProps = defaultProps$2;
|
@@ -1389,6 +1274,7 @@ function MediasResourcePicker(_ref) {
|
|
1389
1274
|
var resourceId = _ref.resource,
|
1390
1275
|
props = _objectWithoutProperties(_ref, _excluded);
|
1391
1276
|
var resource = usePanneauResource(resourceId);
|
1277
|
+
// console.log('resource', resource);
|
1392
1278
|
var api = useApi();
|
1393
1279
|
var mediasApi = useMemo(function () {
|
1394
1280
|
return {
|
@@ -1436,4 +1322,4 @@ function MediasResourcePicker(_ref) {
|
|
1436
1322
|
MediasResourcePicker.propTypes = propTypes;
|
1437
1323
|
MediasResourcePicker.defaultProps = defaultProps;
|
1438
1324
|
|
1439
|
-
export { MediaForm, MediasApiProvider, MediasBrowser, MediasBrowserContainer, MediasPicker, MediasPickerContainer, MediasResourceBrowser, MediasResourcePicker, apiPropTypes, defaultColumns as columns, defaultFields as fields, defaultFilters as filters,
|
1325
|
+
export { MediaForm, MediasApiProvider, MediasBrowser, MediasBrowserContainer, MediasPicker, MediasPickerContainer, MediasResourceBrowser, MediasResourcePicker, apiPropTypes, defaultColumns as columns, defaultFields as fields, defaultFilters as filters, useMedia$1 as useMedia, useMediaCreate$1 as useMediaCreate, useMediaUpdate$1 as useMediaUpdate, useMedias$1 as useMedias, useMediasApi, useMediasRecent$1 as useMediasRecentSearches };
|