@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/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 lodash = require('lodash');
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$8 = ["items", "pageItems"];
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$8);
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$7 = ["data"];
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$7);
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 _excluded$6 = ["path"],
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
- }, {
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
260
  }, {
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
- id: 'technical',
479
- title: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
480
- id: "xKUOLG",
481
- defaultMessage: [{
482
- "type": 0,
483
- "value": "Technical details"
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$6 = {
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$6 = {
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-1"
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(MediaMetadata, {
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$6;
652
- MediaForm.defaultProps = defaultProps$6;
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
- id: 'author',
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: "KNeQ6y",
633
+ id: "OzYWZz",
762
634
  defaultMessage: [{
763
635
  "type": 0,
764
- "value": "Added by"
636
+ "value": "Created at"
765
637
  }]
766
638
  }),
767
- component: 'avatar',
768
- path: 'metadata.author',
769
- namePath: 'name',
770
- withoutName: true
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, {
@@ -776,8 +648,9 @@ var defaultColumns = [{
776
648
  "type": 0,
777
649
  "value": "Actions"
778
650
  }]
779
- })
780
- // component: 'button',
651
+ }),
652
+ actions: ['edit']
653
+ // component: ItemActions,
781
654
  // label: 'Edit',
782
655
  // url: '/edit/1',
783
656
  }
@@ -838,35 +711,26 @@ var defaultFilters = [{
838
711
  value: 'document'
839
712
  }],
840
713
  multiple: true
841
- }, {
842
- id: 'author',
843
- component: 'select',
844
- name: 'author',
845
- placeholder: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
846
- id: "skmuWU",
847
- defaultMessage: [{
848
- "type": 0,
849
- "value": "Author"
850
- }]
851
- }),
852
- requestUrl: '/persons',
853
- itemLabelPath: 'name',
854
- multiple: true
855
- }, {
856
- id: 'tag',
857
- component: 'select',
858
- name: 'tag',
859
- placeholder: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
860
- id: "hnLSrX",
861
- defaultMessage: [{
862
- "type": 0,
863
- "value": "Tag"
864
- }]
865
- }),
866
- requestUrl: '/tags',
867
- itemLabelPath: 'label',
868
- multiple: true
869
- }, {
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
+ {
870
734
  id: 'search',
871
735
  component: 'search',
872
736
  name: 'search'
@@ -886,14 +750,6 @@ var propTypes$5 = {
886
750
  query: PropTypes.shape({}),
887
751
  baseUrl: PropTypes.string,
888
752
  fields: core.PropTypes.fields,
889
- metadatas: PropTypes.shape({
890
- sections: PropTypes.arrayOf(PropTypes.shape({
891
- id: PropTypes.string
892
- })),
893
- displays: PropTypes.arrayOf(PropTypes.shape({
894
- id: PropTypes.string
895
- }))
896
- }),
897
753
  layout: PropTypes.string,
898
754
  layouts: PropTypes.arrayOf(PropTypes.shape({})),
899
755
  theme: PropTypes.string,
@@ -914,10 +770,6 @@ var defaultProps$5 = {
914
770
  filters: defaultFilters,
915
771
  columns: defaultColumns,
916
772
  fields: defaultFields,
917
- metadatas: {
918
- sections: defaultSections,
919
- displays: defaultDisplays
920
- },
921
773
  query: null,
922
774
  baseUrl: null,
923
775
  layout: 'table',
@@ -951,7 +803,6 @@ function MediasBrowser(_ref) {
951
803
  filters = _ref.filters,
952
804
  columns = _ref.columns,
953
805
  fields = _ref.fields,
954
- metadatas = _ref.metadatas,
955
806
  initialQuery = _ref.query,
956
807
  initialLayout = _ref.layout,
957
808
  layouts = _ref.layouts,
@@ -964,14 +815,13 @@ function MediasBrowser(_ref) {
964
815
  selectedCount = _ref.selectedCount,
965
816
  onClearSelected = _ref.onClearSelected,
966
817
  className = _ref.className;
967
- var _ref2 = metadatas || {},
968
- sections = _ref2.sections,
969
- displays = _ref2.displays;
970
818
  var _useState = React.useState(initialItems || null),
971
819
  _useState2 = _slicedToArray(_useState, 1),
972
820
  baseItems = _useState2[0];
973
821
  var baseQuery = React.useMemo(function () {
974
- return _objectSpread(_objectSpread({}, initialQuery), {}, {
822
+ return _objectSpread(_objectSpread({
823
+ count: 12
824
+ }, initialQuery), {}, {
975
825
  types: types
976
826
  });
977
827
  }, [initialQuery, types]);
@@ -981,12 +831,12 @@ function MediasBrowser(_ref) {
981
831
  onQueryChange = _useQuery.onQueryChange,
982
832
  onQueryReset = _useQuery.onQueryReset;
983
833
  var _useMemo = React.useMemo(function () {
984
- var _ref3 = fullQuery || {},
985
- _ref3$page = _ref3.page,
986
- fullQueryPage = _ref3$page === void 0 ? null : _ref3$page,
987
- _ref3$count = _ref3.count,
988
- fullQueryCount = _ref3$count === void 0 ? null : _ref3$count,
989
- params = _objectWithoutProperties(_ref3, _excluded$5);
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);
990
840
  return {
991
841
  page: fullQueryPage,
992
842
  count: fullQueryCount,
@@ -1001,9 +851,9 @@ function MediasBrowser(_ref) {
1001
851
  query = _useMemo$query === void 0 ? null : _useMemo$query;
1002
852
 
1003
853
  // eslint-disable-next-line no-unused-vars
1004
- var _ref4 = query || {};
1005
- _ref4.types;
1006
- var queryWithoutTypes = _objectWithoutProperties(_ref4, _excluded2);
854
+ var _ref3 = query || {};
855
+ _ref3.types;
856
+ var queryWithoutTypes = _objectWithoutProperties(_ref3, _excluded2);
1007
857
  var _useMedias = useMedias$1(query, page, count, {
1008
858
  items: baseItems
1009
859
  }),
@@ -1031,10 +881,11 @@ function MediasBrowser(_ref) {
1031
881
  onLayoutChange(newLayout);
1032
882
  }
1033
883
  }, [setLayout]);
1034
- var _useState5 = React.useState(null),
1035
- _useState6 = _slicedToArray(_useState5, 2),
1036
- currentMedia = _useState6[0],
1037
- setCurrentMedia = _useState6[1];
884
+
885
+ // const [currentMedia, setCurrentMedia] = useState(null);
886
+ var _useMediasForm = useMediasForm(),
887
+ currentMedia = _useMediasForm.media,
888
+ setCurrentMedia = _useMediasForm.setMedia;
1038
889
  var onOpenMedia = React.useCallback(function (media) {
1039
890
  setCurrentMedia(media);
1040
891
  }, [setCurrentMedia]);
@@ -1043,7 +894,6 @@ function MediasBrowser(_ref) {
1043
894
  }, [setCurrentMedia]);
1044
895
  var onChangeMedia = React.useCallback(function () {
1045
896
  var media = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1046
- console.log('media', media);
1047
897
  onSelectItems(media);
1048
898
  onQueryReset();
1049
899
  }, [setCurrentMedia, onQueryReset, onSelectItems]);
@@ -1064,9 +914,9 @@ function MediasBrowser(_ref) {
1064
914
  var finalFilters = React.useMemo(function () {
1065
915
  if (types !== null && filters !== null) {
1066
916
  return (filters || []).map(function (filter) {
1067
- var _ref5 = filter || {},
1068
- _ref5$id = _ref5.id,
1069
- id = _ref5$id === void 0 ? null : _ref5$id;
917
+ var _ref4 = filter || {},
918
+ _ref4$id = _ref4.id,
919
+ id = _ref4$id === void 0 ? null : _ref4$id;
1070
920
  return id === 'types' ? _objectSpread(_objectSpread({}, filter), {}, {
1071
921
  disabled: true
1072
922
  }) : filter;
@@ -1092,25 +942,30 @@ function MediasBrowser(_ref) {
1092
942
  }))), /*#__PURE__*/React.createElement(MediaForm, {
1093
943
  value: currentMedia,
1094
944
  fields: fields,
1095
- sections: sections,
1096
- displays: displays,
1097
945
  onClose: onCloseMedia
1098
- })) : /*#__PURE__*/React.createElement(React.Fragment, null, uploadButton !== null ? /*#__PURE__*/React.createElement("div", {
1099
- className: "mt-2 mb-4"
1100
- }, /*#__PURE__*/React.createElement(UploadField, Object.assign({
1101
- onChange: onChangeMedia,
1102
- withButton: true
1103
- }, uploadButton))) : null, buttons !== null ? /*#__PURE__*/React.createElement(Buttons, {
946
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, buttons !== null ? /*#__PURE__*/React.createElement(Buttons, {
1104
947
  items: buttons,
1105
948
  className: "mb-2"
1106
949
  }) : null, filters !== null ? /*#__PURE__*/React.createElement(Filters, {
950
+ className: "mt-0 pt-0",
1107
951
  value: query,
1108
952
  clearValue: types !== null ? queryWithoutTypes : null,
1109
953
  filters: finalFilters,
1110
954
  onChange: onQueryChange,
1111
955
  onReset: onQueryReset,
1112
956
  theme: theme
1113
- }) : null, /*#__PURE__*/React.createElement("div", {
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", {
1114
969
  className: classNames(['d-flex', 'mt-1', 'mb-3', {
1115
970
  'justify-content-between': hasLayouts,
1116
971
  'justify-content-end': !hasLayouts
@@ -1129,7 +984,7 @@ function MediasBrowser(_ref) {
1129
984
  });
1130
985
  })
1131
986
  }) : null, pagination), layout === 'grid' ? /*#__PURE__*/React.createElement(Grid, Object.assign({
1132
- size: "xsmall",
987
+ size: "small",
1133
988
  theme: theme,
1134
989
  component: MediaCard,
1135
990
  componentProps: {
@@ -1152,6 +1007,16 @@ function MediasBrowser(_ref) {
1152
1007
  items: items,
1153
1008
  onSelectItem: onSelectItem !== null ? onSelectItem : function (it) {
1154
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
+ }
1155
1020
  }
1156
1021
  })) : null, /*#__PURE__*/React.createElement("div", {
1157
1022
  className: classNames(['d-flex', 'mt-3', 'mb-1', 'justify-content-end'])
@@ -1209,6 +1074,8 @@ function MediasPicker(_ref) {
1209
1074
  setItems(pageItems);
1210
1075
  }, [setItems]);
1211
1076
  var disabled = initialItems === null || initialItems.length < 1;
1077
+ var _useMediasForm = useMediasForm(),
1078
+ currentMedia = _useMediasForm.media;
1212
1079
  var _useItemSelection = hooks.useItemSelection({
1213
1080
  items: items,
1214
1081
  selectedItems: initialSelectedItems,
@@ -1222,6 +1089,11 @@ function MediasPicker(_ref) {
1222
1089
  pageSelected = _useItemSelection.pageSelected,
1223
1090
  selectedCount = _useItemSelection.selectedCount,
1224
1091
  selectedItems = _useItemSelection.selectedItems;
1092
+ var onConfirmSelection = React.useCallback(function () {
1093
+ if (onConfirm !== null) {
1094
+ onConfirm(selectedItems);
1095
+ }
1096
+ }, [selectedItems, onConfirm]);
1225
1097
  var finalUploadButton = React.useMemo(function () {
1226
1098
  return _objectSpread(_objectSpread(_objectSpread({}, uploadButton || null), types !== null ? {
1227
1099
  types: types
@@ -1250,7 +1122,7 @@ function MediasPicker(_ref) {
1250
1122
  onClearSelected: onClearSelected,
1251
1123
  uploadButton: finalUploadButton,
1252
1124
  types: types
1253
- }, props)), multiple && !withoutButtons ? /*#__PURE__*/React.createElement("div", {
1125
+ }, props)), multiple && !withoutButtons && currentMedia === null ? /*#__PURE__*/React.createElement("div", {
1254
1126
  className: "d-flex w-100 align-items-end justify-content-end mt-3"
1255
1127
  }, /*#__PURE__*/React.createElement("div", {
1256
1128
  className: "btn-group"
@@ -1268,7 +1140,7 @@ function MediasPicker(_ref) {
1268
1140
  })) : null, /*#__PURE__*/React.createElement(Button, {
1269
1141
  type: "button",
1270
1142
  theme: "primary",
1271
- onClick: onConfirm,
1143
+ onClick: onConfirmSelection,
1272
1144
  disabled: disabled,
1273
1145
  outline: disabled,
1274
1146
  className: "d-block"
@@ -1283,40 +1155,54 @@ function MediasPicker(_ref) {
1283
1155
  MediasPicker.propTypes = propTypes$4;
1284
1156
  MediasPicker.defaultProps = defaultProps$4;
1285
1157
 
1286
- var _excluded$3 = ["api"];
1158
+ var _excluded$3 = ["api", "media"];
1287
1159
  var propTypes$3 = {
1288
- api: apiPropTypes
1160
+ api: apiPropTypes,
1161
+ media: PropTypes.shape({
1162
+ id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
1163
+ })
1289
1164
  };
1290
1165
  var defaultProps$3 = {
1291
- api: null
1166
+ api: null,
1167
+ media: null
1292
1168
  };
1293
1169
  function MediasBrowserContainer(_ref) {
1294
1170
  var api = _ref.api,
1171
+ media = _ref.media,
1295
1172
  props = _objectWithoutProperties(_ref, _excluded$3);
1296
1173
  return /*#__PURE__*/React.createElement(MediasApiProvider, {
1297
1174
  api: api
1298
- }, /*#__PURE__*/React.createElement(MediasBrowser, props));
1175
+ }, /*#__PURE__*/React.createElement(MediasFormProvider, {
1176
+ media: media
1177
+ }, /*#__PURE__*/React.createElement(MediasBrowser, props)));
1299
1178
  }
1300
1179
  MediasBrowserContainer.propTypes = propTypes$3;
1301
1180
  MediasBrowserContainer.defaultProps = defaultProps$3;
1302
1181
 
1303
- var _excluded$2 = ["api", "onChange"];
1182
+ var _excluded$2 = ["api", "media", "onChange"];
1304
1183
  var propTypes$2 = {
1305
1184
  api: apiPropTypes,
1185
+ media: PropTypes.shape({
1186
+ id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
1187
+ }),
1306
1188
  onChange: PropTypes.func.isRequired
1307
1189
  };
1308
1190
  var defaultProps$2 = {
1309
- api: null
1191
+ api: null,
1192
+ media: null
1310
1193
  };
1311
1194
  function MediasPickerContainer(_ref) {
1312
1195
  var api = _ref.api,
1196
+ media = _ref.media,
1313
1197
  onChange = _ref.onChange,
1314
1198
  props = _objectWithoutProperties(_ref, _excluded$2);
1315
1199
  return /*#__PURE__*/React.createElement(MediasApiProvider, {
1316
1200
  api: api
1201
+ }, /*#__PURE__*/React.createElement(MediasFormProvider, {
1202
+ media: media
1317
1203
  }, /*#__PURE__*/React.createElement(MediasPicker, Object.assign({}, props, {
1318
1204
  onChange: onChange
1319
- })));
1205
+ }))));
1320
1206
  }
1321
1207
  MediasPickerContainer.propTypes = propTypes$2;
1322
1208
  MediasPickerContainer.defaultProps = defaultProps$2;
@@ -1390,6 +1276,7 @@ function MediasResourcePicker(_ref) {
1390
1276
  var resourceId = _ref.resource,
1391
1277
  props = _objectWithoutProperties(_ref, _excluded);
1392
1278
  var resource = contexts.usePanneauResource(resourceId);
1279
+ // console.log('resource', resource);
1393
1280
  var api = data.useApi();
1394
1281
  var mediasApi = React.useMemo(function () {
1395
1282
  return {
@@ -1449,8 +1336,6 @@ exports.apiPropTypes = apiPropTypes;
1449
1336
  exports.columns = defaultColumns;
1450
1337
  exports.fields = defaultFields;
1451
1338
  exports.filters = defaultFilters;
1452
- exports.metadataDisplays = defaultDisplays;
1453
- exports.metadataSections = defaultSections;
1454
1339
  exports.useMedia = useMedia$1;
1455
1340
  exports.useMediaCreate = useMediaCreate$1;
1456
1341
  exports.useMediaUpdate = useMediaUpdate$1;