@micromag/media-gallery 0.3.519 → 0.3.520
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 +76 -46
- package/lib/index.js +76 -46
- 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',
|
|
@@ -484,13 +494,29 @@ function MediaGallery(_ref) {
|
|
|
484
494
|
var partialFilters = filters$1 || filters() || [];
|
|
485
495
|
var _useMediaCreate = useMediaCreate(),
|
|
486
496
|
createMedia = _useMediaCreate.create;
|
|
487
|
-
var
|
|
497
|
+
var onMediaUploaded = useCallback(function (newMedias) {
|
|
488
498
|
console.log('newMedias', newMedias);
|
|
489
|
-
Promise.all(newMedias.map(createMedia)).then(function (newAddedMedias) {
|
|
490
|
-
console.log('not uploading anymore', newAddedMedias);
|
|
499
|
+
return Promise.all(newMedias.map(createMedia)).then(function (newAddedMedias) {
|
|
500
|
+
console.log('done creating, not uploading anymore', 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]);
|
|
494
520
|
var finalFilters = useMemo(function () {
|
|
495
521
|
return partialFilters.map(function (filter) {
|
|
496
522
|
var _ref3 = filter || {},
|
|
@@ -524,7 +550,9 @@ function MediaGallery(_ref) {
|
|
|
524
550
|
var partialTypes = !isArray(types) ? [types] : types;
|
|
525
551
|
return types === 'video' ? videoTypes : partialTypes;
|
|
526
552
|
}, [types]);
|
|
527
|
-
|
|
553
|
+
|
|
554
|
+
// console.log('value', value);
|
|
555
|
+
|
|
528
556
|
return /*#__PURE__*/React.createElement("div", {
|
|
529
557
|
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
530
558
|
}, isPicker ? /*#__PURE__*/React.createElement(MediasPickerContainer, {
|
|
@@ -540,7 +568,8 @@ function MediaGallery(_ref) {
|
|
|
540
568
|
columns: columns,
|
|
541
569
|
multiple: multiple,
|
|
542
570
|
onChange: onChange,
|
|
543
|
-
|
|
571
|
+
uppyConfig: uppyConfig,
|
|
572
|
+
onMediaUploaded: onMediaUploaded,
|
|
544
573
|
onMediaFormOpen: onMediaFormOpen,
|
|
545
574
|
onMediaFormClose: onMediaFormClose,
|
|
546
575
|
withStickySelection: true
|
|
@@ -555,7 +584,8 @@ function MediaGallery(_ref) {
|
|
|
555
584
|
filters: finalFilters,
|
|
556
585
|
fields: fields,
|
|
557
586
|
columns: columns,
|
|
558
|
-
|
|
587
|
+
uppyConfig: uppyConfig,
|
|
588
|
+
onMediaUploaded: onMediaUploaded,
|
|
559
589
|
withStickySelection: true
|
|
560
590
|
}));
|
|
561
591
|
}
|
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',
|
|
@@ -524,13 +534,29 @@ function MediaGallery(_ref) {
|
|
|
524
534
|
var partialFilters = filters$1 || filters() || [];
|
|
525
535
|
var _useMediaCreate = data.useMediaCreate(),
|
|
526
536
|
createMedia = _useMediaCreate.create;
|
|
527
|
-
var
|
|
537
|
+
var onMediaUploaded = React.useCallback(function (newMedias) {
|
|
528
538
|
console.log('newMedias', newMedias);
|
|
529
|
-
Promise.all(newMedias.map(createMedia)).then(function (newAddedMedias) {
|
|
530
|
-
console.log('not uploading anymore', newAddedMedias);
|
|
539
|
+
return Promise.all(newMedias.map(createMedia)).then(function (newAddedMedias) {
|
|
540
|
+
console.log('done creating, not uploading anymore', 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]);
|
|
534
560
|
var finalFilters = React.useMemo(function () {
|
|
535
561
|
return partialFilters.map(function (filter) {
|
|
536
562
|
var _ref3 = filter || {},
|
|
@@ -564,7 +590,9 @@ function MediaGallery(_ref) {
|
|
|
564
590
|
var partialTypes = !isArray(types) ? [types] : types;
|
|
565
591
|
return types === 'video' ? videoTypes : partialTypes;
|
|
566
592
|
}, [types]);
|
|
567
|
-
|
|
593
|
+
|
|
594
|
+
// console.log('value', value);
|
|
595
|
+
|
|
568
596
|
return /*#__PURE__*/React.createElement("div", {
|
|
569
597
|
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
570
598
|
}, isPicker ? /*#__PURE__*/React.createElement(medias.MediasPickerContainer, {
|
|
@@ -580,7 +608,8 @@ function MediaGallery(_ref) {
|
|
|
580
608
|
columns: columns,
|
|
581
609
|
multiple: multiple,
|
|
582
610
|
onChange: onChange,
|
|
583
|
-
|
|
611
|
+
uppyConfig: uppyConfig,
|
|
612
|
+
onMediaUploaded: onMediaUploaded,
|
|
584
613
|
onMediaFormOpen: onMediaFormOpen,
|
|
585
614
|
onMediaFormClose: onMediaFormClose,
|
|
586
615
|
withStickySelection: true
|
|
@@ -595,7 +624,8 @@ function MediaGallery(_ref) {
|
|
|
595
624
|
filters: finalFilters,
|
|
596
625
|
fields: fields,
|
|
597
626
|
columns: columns,
|
|
598
|
-
|
|
627
|
+
uppyConfig: uppyConfig,
|
|
628
|
+
onMediaUploaded: onMediaUploaded,
|
|
599
629
|
withStickySelection: true
|
|
600
630
|
}));
|
|
601
631
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/media-gallery",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.520",
|
|
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": "08f32dc09a2237cdbfaef5bac4c7964ef822b6c9"
|
|
91
91
|
}
|