@panneau/medias 3.0.158 → 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 +246 -359
- package/lib/index.js +244 -359
- 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
|
-
}, {
|
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
258
|
}, {
|
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, {
|
@@ -774,8 +646,9 @@ var defaultColumns = [{
|
|
774
646
|
"type": 0,
|
775
647
|
"value": "Actions"
|
776
648
|
}]
|
777
|
-
})
|
778
|
-
|
649
|
+
}),
|
650
|
+
actions: ['edit']
|
651
|
+
// component: ItemActions,
|
779
652
|
// label: 'Edit',
|
780
653
|
// url: '/edit/1',
|
781
654
|
}
|
@@ -836,35 +709,26 @@ var defaultFilters = [{
|
|
836
709
|
value: 'document'
|
837
710
|
}],
|
838
711
|
multiple: true
|
839
|
-
},
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
defaultMessage: [{
|
860
|
-
"type": 0,
|
861
|
-
"value": "Tag"
|
862
|
-
}]
|
863
|
-
}),
|
864
|
-
requestUrl: '/tags',
|
865
|
-
itemLabelPath: 'label',
|
866
|
-
multiple: true
|
867
|
-
}, {
|
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
|
+
{
|
868
732
|
id: 'search',
|
869
733
|
component: 'search',
|
870
734
|
name: 'search'
|
@@ -884,14 +748,6 @@ var propTypes$5 = {
|
|
884
748
|
query: PropTypes.shape({}),
|
885
749
|
baseUrl: PropTypes.string,
|
886
750
|
fields: PropTypes$1.fields,
|
887
|
-
metadatas: PropTypes.shape({
|
888
|
-
sections: PropTypes.arrayOf(PropTypes.shape({
|
889
|
-
id: PropTypes.string
|
890
|
-
})),
|
891
|
-
displays: PropTypes.arrayOf(PropTypes.shape({
|
892
|
-
id: PropTypes.string
|
893
|
-
}))
|
894
|
-
}),
|
895
751
|
layout: PropTypes.string,
|
896
752
|
layouts: PropTypes.arrayOf(PropTypes.shape({})),
|
897
753
|
theme: PropTypes.string,
|
@@ -912,10 +768,6 @@ var defaultProps$5 = {
|
|
912
768
|
filters: defaultFilters,
|
913
769
|
columns: defaultColumns,
|
914
770
|
fields: defaultFields,
|
915
|
-
metadatas: {
|
916
|
-
sections: defaultSections,
|
917
|
-
displays: defaultDisplays
|
918
|
-
},
|
919
771
|
query: null,
|
920
772
|
baseUrl: null,
|
921
773
|
layout: 'table',
|
@@ -949,7 +801,6 @@ function MediasBrowser(_ref) {
|
|
949
801
|
filters = _ref.filters,
|
950
802
|
columns = _ref.columns,
|
951
803
|
fields = _ref.fields,
|
952
|
-
metadatas = _ref.metadatas,
|
953
804
|
initialQuery = _ref.query,
|
954
805
|
initialLayout = _ref.layout,
|
955
806
|
layouts = _ref.layouts,
|
@@ -962,14 +813,13 @@ function MediasBrowser(_ref) {
|
|
962
813
|
selectedCount = _ref.selectedCount,
|
963
814
|
onClearSelected = _ref.onClearSelected,
|
964
815
|
className = _ref.className;
|
965
|
-
var _ref2 = metadatas || {},
|
966
|
-
sections = _ref2.sections,
|
967
|
-
displays = _ref2.displays;
|
968
816
|
var _useState = useState(initialItems || null),
|
969
817
|
_useState2 = _slicedToArray(_useState, 1),
|
970
818
|
baseItems = _useState2[0];
|
971
819
|
var baseQuery = useMemo(function () {
|
972
|
-
return _objectSpread(_objectSpread({
|
820
|
+
return _objectSpread(_objectSpread({
|
821
|
+
count: 12
|
822
|
+
}, initialQuery), {}, {
|
973
823
|
types: types
|
974
824
|
});
|
975
825
|
}, [initialQuery, types]);
|
@@ -979,12 +829,12 @@ function MediasBrowser(_ref) {
|
|
979
829
|
onQueryChange = _useQuery.onQueryChange,
|
980
830
|
onQueryReset = _useQuery.onQueryReset;
|
981
831
|
var _useMemo = useMemo(function () {
|
982
|
-
var
|
983
|
-
|
984
|
-
fullQueryPage =
|
985
|
-
|
986
|
-
fullQueryCount =
|
987
|
-
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);
|
988
838
|
return {
|
989
839
|
page: fullQueryPage,
|
990
840
|
count: fullQueryCount,
|
@@ -999,9 +849,9 @@ function MediasBrowser(_ref) {
|
|
999
849
|
query = _useMemo$query === void 0 ? null : _useMemo$query;
|
1000
850
|
|
1001
851
|
// eslint-disable-next-line no-unused-vars
|
1002
|
-
var
|
1003
|
-
|
1004
|
-
var queryWithoutTypes = _objectWithoutProperties(
|
852
|
+
var _ref3 = query || {};
|
853
|
+
_ref3.types;
|
854
|
+
var queryWithoutTypes = _objectWithoutProperties(_ref3, _excluded2);
|
1005
855
|
var _useMedias = useMedias$1(query, page, count, {
|
1006
856
|
items: baseItems
|
1007
857
|
}),
|
@@ -1029,10 +879,11 @@ function MediasBrowser(_ref) {
|
|
1029
879
|
onLayoutChange(newLayout);
|
1030
880
|
}
|
1031
881
|
}, [setLayout]);
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
882
|
+
|
883
|
+
// const [currentMedia, setCurrentMedia] = useState(null);
|
884
|
+
var _useMediasForm = useMediasForm(),
|
885
|
+
currentMedia = _useMediasForm.media,
|
886
|
+
setCurrentMedia = _useMediasForm.setMedia;
|
1036
887
|
var onOpenMedia = useCallback(function (media) {
|
1037
888
|
setCurrentMedia(media);
|
1038
889
|
}, [setCurrentMedia]);
|
@@ -1041,7 +892,6 @@ function MediasBrowser(_ref) {
|
|
1041
892
|
}, [setCurrentMedia]);
|
1042
893
|
var onChangeMedia = useCallback(function () {
|
1043
894
|
var media = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
1044
|
-
console.log('media', media);
|
1045
895
|
onSelectItems(media);
|
1046
896
|
onQueryReset();
|
1047
897
|
}, [setCurrentMedia, onQueryReset, onSelectItems]);
|
@@ -1062,9 +912,9 @@ function MediasBrowser(_ref) {
|
|
1062
912
|
var finalFilters = useMemo(function () {
|
1063
913
|
if (types !== null && filters !== null) {
|
1064
914
|
return (filters || []).map(function (filter) {
|
1065
|
-
var
|
1066
|
-
|
1067
|
-
id =
|
915
|
+
var _ref4 = filter || {},
|
916
|
+
_ref4$id = _ref4.id,
|
917
|
+
id = _ref4$id === void 0 ? null : _ref4$id;
|
1068
918
|
return id === 'types' ? _objectSpread(_objectSpread({}, filter), {}, {
|
1069
919
|
disabled: true
|
1070
920
|
}) : filter;
|
@@ -1090,25 +940,30 @@ function MediasBrowser(_ref) {
|
|
1090
940
|
}))), /*#__PURE__*/React.createElement(MediaForm, {
|
1091
941
|
value: currentMedia,
|
1092
942
|
fields: fields,
|
1093
|
-
sections: sections,
|
1094
|
-
displays: displays,
|
1095
943
|
onClose: onCloseMedia
|
1096
|
-
})) : /*#__PURE__*/React.createElement(React.Fragment, null,
|
1097
|
-
className: "mt-2 mb-4"
|
1098
|
-
}, /*#__PURE__*/React.createElement(UploadField, Object.assign({
|
1099
|
-
onChange: onChangeMedia,
|
1100
|
-
withButton: true
|
1101
|
-
}, uploadButton))) : null, buttons !== null ? /*#__PURE__*/React.createElement(Buttons, {
|
944
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null, buttons !== null ? /*#__PURE__*/React.createElement(Buttons, {
|
1102
945
|
items: buttons,
|
1103
946
|
className: "mb-2"
|
1104
947
|
}) : null, filters !== null ? /*#__PURE__*/React.createElement(Filters, {
|
948
|
+
className: "mt-0 pt-0",
|
1105
949
|
value: query,
|
1106
950
|
clearValue: types !== null ? queryWithoutTypes : null,
|
1107
951
|
filters: finalFilters,
|
1108
952
|
onChange: onQueryChange,
|
1109
953
|
onReset: onQueryReset,
|
1110
954
|
theme: theme
|
1111
|
-
}
|
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", {
|
1112
967
|
className: classNames(['d-flex', 'mt-1', 'mb-3', {
|
1113
968
|
'justify-content-between': hasLayouts,
|
1114
969
|
'justify-content-end': !hasLayouts
|
@@ -1127,7 +982,7 @@ function MediasBrowser(_ref) {
|
|
1127
982
|
});
|
1128
983
|
})
|
1129
984
|
}) : null, pagination), layout === 'grid' ? /*#__PURE__*/React.createElement(Grid, Object.assign({
|
1130
|
-
size: "
|
985
|
+
size: "small",
|
1131
986
|
theme: theme,
|
1132
987
|
component: MediaCard,
|
1133
988
|
componentProps: {
|
@@ -1150,6 +1005,16 @@ function MediasBrowser(_ref) {
|
|
1150
1005
|
items: items,
|
1151
1006
|
onSelectItem: onSelectItem !== null ? onSelectItem : function (it) {
|
1152
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
|
+
}
|
1153
1018
|
}
|
1154
1019
|
})) : null, /*#__PURE__*/React.createElement("div", {
|
1155
1020
|
className: classNames(['d-flex', 'mt-3', 'mb-1', 'justify-content-end'])
|
@@ -1207,6 +1072,8 @@ function MediasPicker(_ref) {
|
|
1207
1072
|
setItems(pageItems);
|
1208
1073
|
}, [setItems]);
|
1209
1074
|
var disabled = initialItems === null || initialItems.length < 1;
|
1075
|
+
var _useMediasForm = useMediasForm(),
|
1076
|
+
currentMedia = _useMediasForm.media;
|
1210
1077
|
var _useItemSelection = useItemSelection({
|
1211
1078
|
items: items,
|
1212
1079
|
selectedItems: initialSelectedItems,
|
@@ -1220,6 +1087,11 @@ function MediasPicker(_ref) {
|
|
1220
1087
|
pageSelected = _useItemSelection.pageSelected,
|
1221
1088
|
selectedCount = _useItemSelection.selectedCount,
|
1222
1089
|
selectedItems = _useItemSelection.selectedItems;
|
1090
|
+
var onConfirmSelection = useCallback(function () {
|
1091
|
+
if (onConfirm !== null) {
|
1092
|
+
onConfirm(selectedItems);
|
1093
|
+
}
|
1094
|
+
}, [selectedItems, onConfirm]);
|
1223
1095
|
var finalUploadButton = useMemo(function () {
|
1224
1096
|
return _objectSpread(_objectSpread(_objectSpread({}, uploadButton || null), types !== null ? {
|
1225
1097
|
types: types
|
@@ -1248,7 +1120,7 @@ function MediasPicker(_ref) {
|
|
1248
1120
|
onClearSelected: onClearSelected,
|
1249
1121
|
uploadButton: finalUploadButton,
|
1250
1122
|
types: types
|
1251
|
-
}, props)), multiple && !withoutButtons ? /*#__PURE__*/React.createElement("div", {
|
1123
|
+
}, props)), multiple && !withoutButtons && currentMedia === null ? /*#__PURE__*/React.createElement("div", {
|
1252
1124
|
className: "d-flex w-100 align-items-end justify-content-end mt-3"
|
1253
1125
|
}, /*#__PURE__*/React.createElement("div", {
|
1254
1126
|
className: "btn-group"
|
@@ -1266,7 +1138,7 @@ function MediasPicker(_ref) {
|
|
1266
1138
|
})) : null, /*#__PURE__*/React.createElement(Button, {
|
1267
1139
|
type: "button",
|
1268
1140
|
theme: "primary",
|
1269
|
-
onClick:
|
1141
|
+
onClick: onConfirmSelection,
|
1270
1142
|
disabled: disabled,
|
1271
1143
|
outline: disabled,
|
1272
1144
|
className: "d-block"
|
@@ -1281,40 +1153,54 @@ function MediasPicker(_ref) {
|
|
1281
1153
|
MediasPicker.propTypes = propTypes$4;
|
1282
1154
|
MediasPicker.defaultProps = defaultProps$4;
|
1283
1155
|
|
1284
|
-
var _excluded$3 = ["api"];
|
1156
|
+
var _excluded$3 = ["api", "media"];
|
1285
1157
|
var propTypes$3 = {
|
1286
|
-
api: apiPropTypes
|
1158
|
+
api: apiPropTypes,
|
1159
|
+
media: PropTypes.shape({
|
1160
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
1161
|
+
})
|
1287
1162
|
};
|
1288
1163
|
var defaultProps$3 = {
|
1289
|
-
api: null
|
1164
|
+
api: null,
|
1165
|
+
media: null
|
1290
1166
|
};
|
1291
1167
|
function MediasBrowserContainer(_ref) {
|
1292
1168
|
var api = _ref.api,
|
1169
|
+
media = _ref.media,
|
1293
1170
|
props = _objectWithoutProperties(_ref, _excluded$3);
|
1294
1171
|
return /*#__PURE__*/React.createElement(MediasApiProvider, {
|
1295
1172
|
api: api
|
1296
|
-
}, /*#__PURE__*/React.createElement(
|
1173
|
+
}, /*#__PURE__*/React.createElement(MediasFormProvider, {
|
1174
|
+
media: media
|
1175
|
+
}, /*#__PURE__*/React.createElement(MediasBrowser, props)));
|
1297
1176
|
}
|
1298
1177
|
MediasBrowserContainer.propTypes = propTypes$3;
|
1299
1178
|
MediasBrowserContainer.defaultProps = defaultProps$3;
|
1300
1179
|
|
1301
|
-
var _excluded$2 = ["api", "onChange"];
|
1180
|
+
var _excluded$2 = ["api", "media", "onChange"];
|
1302
1181
|
var propTypes$2 = {
|
1303
1182
|
api: apiPropTypes,
|
1183
|
+
media: PropTypes.shape({
|
1184
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
1185
|
+
}),
|
1304
1186
|
onChange: PropTypes.func.isRequired
|
1305
1187
|
};
|
1306
1188
|
var defaultProps$2 = {
|
1307
|
-
api: null
|
1189
|
+
api: null,
|
1190
|
+
media: null
|
1308
1191
|
};
|
1309
1192
|
function MediasPickerContainer(_ref) {
|
1310
1193
|
var api = _ref.api,
|
1194
|
+
media = _ref.media,
|
1311
1195
|
onChange = _ref.onChange,
|
1312
1196
|
props = _objectWithoutProperties(_ref, _excluded$2);
|
1313
1197
|
return /*#__PURE__*/React.createElement(MediasApiProvider, {
|
1314
1198
|
api: api
|
1199
|
+
}, /*#__PURE__*/React.createElement(MediasFormProvider, {
|
1200
|
+
media: media
|
1315
1201
|
}, /*#__PURE__*/React.createElement(MediasPicker, Object.assign({}, props, {
|
1316
1202
|
onChange: onChange
|
1317
|
-
})));
|
1203
|
+
}))));
|
1318
1204
|
}
|
1319
1205
|
MediasPickerContainer.propTypes = propTypes$2;
|
1320
1206
|
MediasPickerContainer.defaultProps = defaultProps$2;
|
@@ -1388,6 +1274,7 @@ function MediasResourcePicker(_ref) {
|
|
1388
1274
|
var resourceId = _ref.resource,
|
1389
1275
|
props = _objectWithoutProperties(_ref, _excluded);
|
1390
1276
|
var resource = usePanneauResource(resourceId);
|
1277
|
+
// console.log('resource', resource);
|
1391
1278
|
var api = useApi();
|
1392
1279
|
var mediasApi = useMemo(function () {
|
1393
1280
|
return {
|
@@ -1435,4 +1322,4 @@ function MediasResourcePicker(_ref) {
|
|
1435
1322
|
MediasResourcePicker.propTypes = propTypes;
|
1436
1323
|
MediasResourcePicker.defaultProps = defaultProps;
|
1437
1324
|
|
1438
|
-
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 };
|