@micromag/media-gallery 0.3.519 → 0.3.521
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/es/index.js +93 -50
- package/lib/index.js +93 -50
- package/package.json +4 -4
package/es/index.js
CHANGED
|
@@ -153,32 +153,38 @@ var defaultFields = [{
|
|
|
153
153
|
type: 'text',
|
|
154
154
|
component: 'text'
|
|
155
155
|
}, {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
156
|
+
id: 'metadata',
|
|
157
|
+
component: 'fields',
|
|
158
|
+
name: 'metadata',
|
|
159
|
+
fields: [{
|
|
160
|
+
name: 'description',
|
|
161
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
162
|
+
id: "ygNvmz",
|
|
163
|
+
defaultMessage: [{
|
|
164
|
+
"type": 0,
|
|
165
|
+
"value": "Description"
|
|
166
|
+
}]
|
|
167
|
+
}),
|
|
168
|
+
type: 'text',
|
|
169
|
+
component: 'text'
|
|
170
|
+
}, {
|
|
171
|
+
name: 'tags',
|
|
172
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
173
|
+
id: "IOVper",
|
|
174
|
+
defaultMessage: [{
|
|
175
|
+
"type": 0,
|
|
176
|
+
"value": "Tags"
|
|
177
|
+
}]
|
|
178
|
+
}),
|
|
179
|
+
type: 'array',
|
|
180
|
+
component: 'select',
|
|
181
|
+
requestUrl: '/api/medias/tags',
|
|
182
|
+
optionLabelPath: 'name',
|
|
183
|
+
optionValuePath: 'name',
|
|
184
|
+
// Uses taggable
|
|
185
|
+
multiple: true,
|
|
186
|
+
paginated: false
|
|
187
|
+
}]
|
|
182
188
|
}, {
|
|
183
189
|
id: 'jobs',
|
|
184
190
|
component: 'jobs',
|
|
@@ -347,19 +353,23 @@ function filters() {
|
|
|
347
353
|
value: 'audio'
|
|
348
354
|
}],
|
|
349
355
|
multiple: true
|
|
350
|
-
},
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
356
|
+
}, {
|
|
357
|
+
id: 'authors',
|
|
358
|
+
component: 'select',
|
|
359
|
+
name: 'authors',
|
|
360
|
+
placeholder: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
361
|
+
id: "7oXkoj",
|
|
362
|
+
defaultMessage: [{
|
|
363
|
+
"type": 0,
|
|
364
|
+
"value": "Authors"
|
|
365
|
+
}]
|
|
366
|
+
}),
|
|
367
|
+
requestUrl: route('medias.authors') || '/api/medias/authors',
|
|
368
|
+
itemLabelPath: 'name',
|
|
369
|
+
itemValuePath: 'id',
|
|
370
|
+
multiple: true,
|
|
371
|
+
paginated: false
|
|
372
|
+
}, {
|
|
363
373
|
id: 'tags',
|
|
364
374
|
component: 'select',
|
|
365
375
|
name: 'tags',
|
|
@@ -374,7 +384,7 @@ function filters() {
|
|
|
374
384
|
itemLabelPath: 'name',
|
|
375
385
|
itemValuePath: 'id',
|
|
376
386
|
multiple: true,
|
|
377
|
-
paginated:
|
|
387
|
+
paginated: false
|
|
378
388
|
}, {
|
|
379
389
|
id: 'source',
|
|
380
390
|
component: 'toggle',
|
|
@@ -459,6 +469,7 @@ function MediaGallery(_ref) {
|
|
|
459
469
|
var _api$medias2;
|
|
460
470
|
return (_api$medias2 = api.medias).get.apply(_api$medias2, arguments);
|
|
461
471
|
},
|
|
472
|
+
// Change this
|
|
462
473
|
find: function find() {
|
|
463
474
|
var _api$medias3;
|
|
464
475
|
return (_api$medias3 = api.medias).find.apply(_api$medias3, arguments);
|
|
@@ -478,19 +489,37 @@ function MediaGallery(_ref) {
|
|
|
478
489
|
trash: function trash() {
|
|
479
490
|
var _api$medias7;
|
|
480
491
|
return (_api$medias7 = api.medias)["delete"].apply(_api$medias7, arguments);
|
|
481
|
-
}
|
|
492
|
+
} // Change this
|
|
482
493
|
};
|
|
483
494
|
}, [api]);
|
|
484
|
-
|
|
495
|
+
|
|
496
|
+
// Upload
|
|
485
497
|
var _useMediaCreate = useMediaCreate(),
|
|
486
498
|
createMedia = _useMediaCreate.create;
|
|
487
|
-
var
|
|
488
|
-
|
|
489
|
-
Promise.all(newMedias.map(createMedia)).then(function (newAddedMedias) {
|
|
490
|
-
console.log('not uploading anymore', newAddedMedias);
|
|
499
|
+
var onMediaUploaded = useCallback(function (newMedias) {
|
|
500
|
+
return Promise.all(newMedias.map(createMedia)).then(function (newAddedMedias) {
|
|
491
501
|
return newAddedMedias;
|
|
492
502
|
});
|
|
493
503
|
}, [createMedia]);
|
|
504
|
+
var fileTypes = useMemo(function () {
|
|
505
|
+
if (isArray(types)) {
|
|
506
|
+
return types.map(function (t) {
|
|
507
|
+
return ['image', 'video', 'audio'].indexOf(t) !== -1 ? "".concat(t, "/*") : null;
|
|
508
|
+
}).filter(function (t) {
|
|
509
|
+
return t !== null;
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
return ['image', 'video', 'audio'].indexOf(types) !== -1 ? ["".concat(types, "/*")] : null;
|
|
513
|
+
}, [types]);
|
|
514
|
+
var uppyConfig = useMemo(function () {
|
|
515
|
+
return {
|
|
516
|
+
// sources, - uppy sources -
|
|
517
|
+
allowedFileTypes: fileTypes !== null && fileTypes.length > 0 ? fileTypes : null
|
|
518
|
+
};
|
|
519
|
+
}, [fileTypes]);
|
|
520
|
+
|
|
521
|
+
// Filters
|
|
522
|
+
var partialFilters = filters$1 || filters() || [];
|
|
494
523
|
var finalFilters = useMemo(function () {
|
|
495
524
|
return partialFilters.map(function (filter) {
|
|
496
525
|
var _ref3 = filter || {},
|
|
@@ -524,7 +553,19 @@ function MediaGallery(_ref) {
|
|
|
524
553
|
var partialTypes = !isArray(types) ? [types] : types;
|
|
525
554
|
return types === 'video' ? videoTypes : partialTypes;
|
|
526
555
|
}, [types]);
|
|
527
|
-
|
|
556
|
+
var finalOnChange = useCallback(function (newMedias) {
|
|
557
|
+
if (multiple) {
|
|
558
|
+
onChange(newMedias || []);
|
|
559
|
+
} else if (isArray(newMedias)) {
|
|
560
|
+
var _ref4 = newMedias || [],
|
|
561
|
+
_ref5 = _slicedToArray(_ref4, 1),
|
|
562
|
+
_ref5$ = _ref5[0],
|
|
563
|
+
firstMedia = _ref5$ === void 0 ? null : _ref5$;
|
|
564
|
+
onChange(firstMedia || null);
|
|
565
|
+
} else {
|
|
566
|
+
onChange(newMedias || null);
|
|
567
|
+
}
|
|
568
|
+
}, [onChange, multiple]);
|
|
528
569
|
return /*#__PURE__*/React.createElement("div", {
|
|
529
570
|
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
530
571
|
}, isPicker ? /*#__PURE__*/React.createElement(MediasPickerContainer, {
|
|
@@ -539,8 +580,9 @@ function MediaGallery(_ref) {
|
|
|
539
580
|
fields: fields,
|
|
540
581
|
columns: columns,
|
|
541
582
|
multiple: multiple,
|
|
542
|
-
onChange:
|
|
543
|
-
|
|
583
|
+
onChange: finalOnChange,
|
|
584
|
+
uppyConfig: uppyConfig,
|
|
585
|
+
onMediaUploaded: onMediaUploaded,
|
|
544
586
|
onMediaFormOpen: onMediaFormOpen,
|
|
545
587
|
onMediaFormClose: onMediaFormClose,
|
|
546
588
|
withStickySelection: true
|
|
@@ -555,7 +597,8 @@ function MediaGallery(_ref) {
|
|
|
555
597
|
filters: finalFilters,
|
|
556
598
|
fields: fields,
|
|
557
599
|
columns: columns,
|
|
558
|
-
|
|
600
|
+
uppyConfig: uppyConfig,
|
|
601
|
+
onMediaUploaded: onMediaUploaded,
|
|
559
602
|
withStickySelection: true
|
|
560
603
|
}));
|
|
561
604
|
}
|
package/lib/index.js
CHANGED
|
@@ -155,32 +155,38 @@ var defaultFields = [{
|
|
|
155
155
|
type: 'text',
|
|
156
156
|
component: 'text'
|
|
157
157
|
}, {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
158
|
+
id: 'metadata',
|
|
159
|
+
component: 'fields',
|
|
160
|
+
name: 'metadata',
|
|
161
|
+
fields: [{
|
|
162
|
+
name: 'description',
|
|
163
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
164
|
+
id: "ygNvmz",
|
|
165
|
+
defaultMessage: [{
|
|
166
|
+
"type": 0,
|
|
167
|
+
"value": "Description"
|
|
168
|
+
}]
|
|
169
|
+
}),
|
|
170
|
+
type: 'text',
|
|
171
|
+
component: 'text'
|
|
172
|
+
}, {
|
|
173
|
+
name: 'tags',
|
|
174
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
175
|
+
id: "IOVper",
|
|
176
|
+
defaultMessage: [{
|
|
177
|
+
"type": 0,
|
|
178
|
+
"value": "Tags"
|
|
179
|
+
}]
|
|
180
|
+
}),
|
|
181
|
+
type: 'array',
|
|
182
|
+
component: 'select',
|
|
183
|
+
requestUrl: '/api/medias/tags',
|
|
184
|
+
optionLabelPath: 'name',
|
|
185
|
+
optionValuePath: 'name',
|
|
186
|
+
// Uses taggable
|
|
187
|
+
multiple: true,
|
|
188
|
+
paginated: false
|
|
189
|
+
}]
|
|
184
190
|
}, {
|
|
185
191
|
id: 'jobs',
|
|
186
192
|
component: 'jobs',
|
|
@@ -387,19 +393,23 @@ function filters() {
|
|
|
387
393
|
value: 'audio'
|
|
388
394
|
}],
|
|
389
395
|
multiple: true
|
|
390
|
-
},
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
396
|
+
}, {
|
|
397
|
+
id: 'authors',
|
|
398
|
+
component: 'select',
|
|
399
|
+
name: 'authors',
|
|
400
|
+
placeholder: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
401
|
+
id: "7oXkoj",
|
|
402
|
+
defaultMessage: [{
|
|
403
|
+
"type": 0,
|
|
404
|
+
"value": "Authors"
|
|
405
|
+
}]
|
|
406
|
+
}),
|
|
407
|
+
requestUrl: route('medias.authors') || '/api/medias/authors',
|
|
408
|
+
itemLabelPath: 'name',
|
|
409
|
+
itemValuePath: 'id',
|
|
410
|
+
multiple: true,
|
|
411
|
+
paginated: false
|
|
412
|
+
}, {
|
|
403
413
|
id: 'tags',
|
|
404
414
|
component: 'select',
|
|
405
415
|
name: 'tags',
|
|
@@ -414,7 +424,7 @@ function filters() {
|
|
|
414
424
|
itemLabelPath: 'name',
|
|
415
425
|
itemValuePath: 'id',
|
|
416
426
|
multiple: true,
|
|
417
|
-
paginated:
|
|
427
|
+
paginated: false
|
|
418
428
|
}, {
|
|
419
429
|
id: 'source',
|
|
420
430
|
component: 'toggle',
|
|
@@ -499,6 +509,7 @@ function MediaGallery(_ref) {
|
|
|
499
509
|
var _api$medias2;
|
|
500
510
|
return (_api$medias2 = api.medias).get.apply(_api$medias2, arguments);
|
|
501
511
|
},
|
|
512
|
+
// Change this
|
|
502
513
|
find: function find() {
|
|
503
514
|
var _api$medias3;
|
|
504
515
|
return (_api$medias3 = api.medias).find.apply(_api$medias3, arguments);
|
|
@@ -518,19 +529,37 @@ function MediaGallery(_ref) {
|
|
|
518
529
|
trash: function trash() {
|
|
519
530
|
var _api$medias7;
|
|
520
531
|
return (_api$medias7 = api.medias)["delete"].apply(_api$medias7, arguments);
|
|
521
|
-
}
|
|
532
|
+
} // Change this
|
|
522
533
|
};
|
|
523
534
|
}, [api]);
|
|
524
|
-
|
|
535
|
+
|
|
536
|
+
// Upload
|
|
525
537
|
var _useMediaCreate = data.useMediaCreate(),
|
|
526
538
|
createMedia = _useMediaCreate.create;
|
|
527
|
-
var
|
|
528
|
-
|
|
529
|
-
Promise.all(newMedias.map(createMedia)).then(function (newAddedMedias) {
|
|
530
|
-
console.log('not uploading anymore', newAddedMedias);
|
|
539
|
+
var onMediaUploaded = React.useCallback(function (newMedias) {
|
|
540
|
+
return Promise.all(newMedias.map(createMedia)).then(function (newAddedMedias) {
|
|
531
541
|
return newAddedMedias;
|
|
532
542
|
});
|
|
533
543
|
}, [createMedia]);
|
|
544
|
+
var fileTypes = React.useMemo(function () {
|
|
545
|
+
if (isArray(types)) {
|
|
546
|
+
return types.map(function (t) {
|
|
547
|
+
return ['image', 'video', 'audio'].indexOf(t) !== -1 ? "".concat(t, "/*") : null;
|
|
548
|
+
}).filter(function (t) {
|
|
549
|
+
return t !== null;
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
return ['image', 'video', 'audio'].indexOf(types) !== -1 ? ["".concat(types, "/*")] : null;
|
|
553
|
+
}, [types]);
|
|
554
|
+
var uppyConfig = React.useMemo(function () {
|
|
555
|
+
return {
|
|
556
|
+
// sources, - uppy sources -
|
|
557
|
+
allowedFileTypes: fileTypes !== null && fileTypes.length > 0 ? fileTypes : null
|
|
558
|
+
};
|
|
559
|
+
}, [fileTypes]);
|
|
560
|
+
|
|
561
|
+
// Filters
|
|
562
|
+
var partialFilters = filters$1 || filters() || [];
|
|
534
563
|
var finalFilters = React.useMemo(function () {
|
|
535
564
|
return partialFilters.map(function (filter) {
|
|
536
565
|
var _ref3 = filter || {},
|
|
@@ -564,7 +593,19 @@ function MediaGallery(_ref) {
|
|
|
564
593
|
var partialTypes = !isArray(types) ? [types] : types;
|
|
565
594
|
return types === 'video' ? videoTypes : partialTypes;
|
|
566
595
|
}, [types]);
|
|
567
|
-
|
|
596
|
+
var finalOnChange = React.useCallback(function (newMedias) {
|
|
597
|
+
if (multiple) {
|
|
598
|
+
onChange(newMedias || []);
|
|
599
|
+
} else if (isArray(newMedias)) {
|
|
600
|
+
var _ref4 = newMedias || [],
|
|
601
|
+
_ref5 = _slicedToArray(_ref4, 1),
|
|
602
|
+
_ref5$ = _ref5[0],
|
|
603
|
+
firstMedia = _ref5$ === void 0 ? null : _ref5$;
|
|
604
|
+
onChange(firstMedia || null);
|
|
605
|
+
} else {
|
|
606
|
+
onChange(newMedias || null);
|
|
607
|
+
}
|
|
608
|
+
}, [onChange, multiple]);
|
|
568
609
|
return /*#__PURE__*/React.createElement("div", {
|
|
569
610
|
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
570
611
|
}, isPicker ? /*#__PURE__*/React.createElement(medias.MediasPickerContainer, {
|
|
@@ -579,8 +620,9 @@ function MediaGallery(_ref) {
|
|
|
579
620
|
fields: fields,
|
|
580
621
|
columns: columns,
|
|
581
622
|
multiple: multiple,
|
|
582
|
-
onChange:
|
|
583
|
-
|
|
623
|
+
onChange: finalOnChange,
|
|
624
|
+
uppyConfig: uppyConfig,
|
|
625
|
+
onMediaUploaded: onMediaUploaded,
|
|
584
626
|
onMediaFormOpen: onMediaFormOpen,
|
|
585
627
|
onMediaFormClose: onMediaFormClose,
|
|
586
628
|
withStickySelection: true
|
|
@@ -595,7 +637,8 @@ function MediaGallery(_ref) {
|
|
|
595
637
|
filters: finalFilters,
|
|
596
638
|
fields: fields,
|
|
597
639
|
columns: columns,
|
|
598
|
-
|
|
640
|
+
uppyConfig: uppyConfig,
|
|
641
|
+
onMediaUploaded: onMediaUploaded,
|
|
599
642
|
withStickySelection: true
|
|
600
643
|
}));
|
|
601
644
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/media-gallery",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.521",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"@fortawesome/fontawesome-svg-core": "^6.5.2",
|
|
73
73
|
"@fortawesome/free-solid-svg-icons": "^6.5.2",
|
|
74
74
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
75
|
-
"@micromag/core": "^0.3.
|
|
76
|
-
"@micromag/data": "^0.3.
|
|
75
|
+
"@micromag/core": "^0.3.520",
|
|
76
|
+
"@micromag/data": "^0.3.520",
|
|
77
77
|
"@panneau/medias": "^3.0.163",
|
|
78
78
|
"bootstrap": "^5.3.1",
|
|
79
79
|
"classnames": "^2.2.6",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"access": "public",
|
|
88
88
|
"registry": "https://registry.npmjs.org/"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "231e8620bd6c5077b9df4836c5ab2126001bd7f0"
|
|
91
91
|
}
|