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