@micromag/media-gallery 0.3.514 → 0.3.516
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 +67 -53
- package/lib/index.js +67 -53
- package/package.json +4 -4
package/es/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { FormattedMessage } from 'react-intl';
|
|
|
11
11
|
import { MediasPickerContainer, MediasBrowserContainer } from '@panneau/medias';
|
|
12
12
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
13
13
|
import { UploadModal } from '@micromag/core/components';
|
|
14
|
+
import { useStory } from '@micromag/core/contexts';
|
|
14
15
|
import { useApi, useMediaCreate } from '@micromag/data';
|
|
15
16
|
import { useUrlGenerator } from '@folklore/routes';
|
|
16
17
|
|
|
@@ -175,17 +176,20 @@ var defaultFields = [{
|
|
|
175
176
|
}]
|
|
176
177
|
}),
|
|
177
178
|
type: 'array',
|
|
178
|
-
component: 'select'
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
component: 'select',
|
|
180
|
+
requestUrl: '/api/medias/tags',
|
|
181
|
+
optionLabelPath: 'name',
|
|
182
|
+
optionValuePath: 'id',
|
|
183
|
+
multiple: true,
|
|
184
|
+
paginated: false
|
|
181
185
|
}, {
|
|
182
|
-
id: '
|
|
183
|
-
component: '
|
|
186
|
+
id: 'jobs',
|
|
187
|
+
component: 'jobs',
|
|
184
188
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
185
|
-
id: "
|
|
189
|
+
id: "SrFsAq",
|
|
186
190
|
defaultMessage: [{
|
|
187
191
|
"type": 0,
|
|
188
|
-
"value": "
|
|
192
|
+
"value": "Jobs"
|
|
189
193
|
}]
|
|
190
194
|
})
|
|
191
195
|
}, {
|
|
@@ -358,39 +362,27 @@ function filters() {
|
|
|
358
362
|
name: 'source',
|
|
359
363
|
options: [{
|
|
360
364
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
361
|
-
id: "
|
|
365
|
+
id: "o+7d2z",
|
|
362
366
|
defaultMessage: [{
|
|
363
367
|
"type": 0,
|
|
364
|
-
"value": "All"
|
|
368
|
+
"value": "All medias"
|
|
365
369
|
}]
|
|
366
370
|
}),
|
|
367
371
|
value: 'all'
|
|
368
|
-
}, {
|
|
369
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
370
|
-
id: "AgH3AR",
|
|
371
|
-
defaultMessage: [{
|
|
372
|
-
"type": 0,
|
|
373
|
-
"value": "This micromag"
|
|
374
|
-
}]
|
|
375
|
-
}),
|
|
376
|
-
value: 'document-'
|
|
377
372
|
}]
|
|
378
|
-
},
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
itemValuePath: 'id',
|
|
392
|
-
multiple: true
|
|
393
|
-
}, {
|
|
373
|
+
},
|
|
374
|
+
// TODO: fix this on micromag.ca
|
|
375
|
+
// {
|
|
376
|
+
// id: 'authors',
|
|
377
|
+
// component: 'select',
|
|
378
|
+
// name: 'authors',
|
|
379
|
+
// placeholder: <FormattedMessage defaultMessage="Authors" description="Filter label" />,
|
|
380
|
+
// requestUrl: route('medias.authors') || '/api/medias/authors',
|
|
381
|
+
// itemLabelPath: 'name',
|
|
382
|
+
// itemValuePath: 'id',
|
|
383
|
+
// multiple: true,
|
|
384
|
+
// },
|
|
385
|
+
{
|
|
394
386
|
id: 'tags',
|
|
395
387
|
component: 'select',
|
|
396
388
|
name: 'tags',
|
|
@@ -457,11 +449,16 @@ function MediaGallery(_ref) {
|
|
|
457
449
|
columns = _ref.columns,
|
|
458
450
|
isPicker = _ref.isPicker,
|
|
459
451
|
multiple = _ref.multiple,
|
|
460
|
-
initialMedias = _ref.medias
|
|
461
|
-
_ref.buttons
|
|
462
|
-
|
|
452
|
+
initialMedias = _ref.medias,
|
|
453
|
+
buttons = _ref.buttons,
|
|
454
|
+
className = _ref.className,
|
|
463
455
|
onChange = _ref.onChange;
|
|
464
456
|
var api = useApi();
|
|
457
|
+
var story = useStory();
|
|
458
|
+
var _ref2 = story || {},
|
|
459
|
+
_ref2$id = _ref2.id,
|
|
460
|
+
storyId = _ref2$id === void 0 ? null : _ref2$id;
|
|
461
|
+
console.log('storyId', storyId);
|
|
465
462
|
var mediasApi = useMemo(function () {
|
|
466
463
|
return {
|
|
467
464
|
get: function get() {
|
|
@@ -528,18 +525,35 @@ function MediaGallery(_ref) {
|
|
|
528
525
|
var partialFilters = filters$1 || filters() || [];
|
|
529
526
|
var finalFilters = useMemo(function () {
|
|
530
527
|
return partialFilters.map(function (filter) {
|
|
531
|
-
var
|
|
532
|
-
|
|
533
|
-
id =
|
|
534
|
-
if (id === '
|
|
535
|
-
|
|
528
|
+
var _ref3 = filter || {},
|
|
529
|
+
_ref3$id = _ref3.id,
|
|
530
|
+
id = _ref3$id === void 0 ? null : _ref3$id;
|
|
531
|
+
if (id === 'source' && storyId !== null) {
|
|
532
|
+
var _ref4 = filter || {},
|
|
533
|
+
_ref4$options = _ref4.options,
|
|
534
|
+
options = _ref4$options === void 0 ? null : _ref4$options;
|
|
535
|
+
var finalOptions = (options || []).length > 0 ? [].concat(_toConsumableArray(options), [{
|
|
536
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
537
|
+
id: "eiaIIB",
|
|
538
|
+
defaultMessage: [{
|
|
539
|
+
"type": 0,
|
|
540
|
+
"value": "This Micromag"
|
|
541
|
+
}]
|
|
542
|
+
}),
|
|
543
|
+
value: "document-".concat(storyId)
|
|
544
|
+
}]) : null;
|
|
545
|
+
if (finalOptions === null) {
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
548
|
+
return _objectSpread(_objectSpread({}, filter), {}, {
|
|
549
|
+
options: finalOptions
|
|
550
|
+
});
|
|
536
551
|
}
|
|
537
|
-
// if (id === 'tags' && tags !== null) {
|
|
538
|
-
// return { ...filter, options: tags };
|
|
539
|
-
// }
|
|
540
552
|
return filter;
|
|
541
|
-
}).
|
|
542
|
-
|
|
553
|
+
}).filter(function (f) {
|
|
554
|
+
return f !== null;
|
|
555
|
+
});
|
|
556
|
+
}, [partialFilters, storyId]);
|
|
543
557
|
var _useState7 = useState(source !== null ? {
|
|
544
558
|
source: source
|
|
545
559
|
} : null),
|
|
@@ -557,10 +571,10 @@ function MediaGallery(_ref) {
|
|
|
557
571
|
}
|
|
558
572
|
console.log('addedMedias', addedMedias);
|
|
559
573
|
if (!multiple) {
|
|
560
|
-
var
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
firstMedia =
|
|
574
|
+
var _ref5 = addedMedias || [],
|
|
575
|
+
_ref6 = _slicedToArray(_ref5, 1),
|
|
576
|
+
_ref6$ = _ref6[0],
|
|
577
|
+
firstMedia = _ref6$ === void 0 ? null : _ref6$;
|
|
564
578
|
return firstMedia || null;
|
|
565
579
|
}
|
|
566
580
|
var allMedias = [].concat(_toConsumableArray(addedMedias), _toConsumableArray(isArray(value) ? value || [] : [value]));
|
|
@@ -601,7 +615,7 @@ function MediaGallery(_ref) {
|
|
|
601
615
|
fields: fields,
|
|
602
616
|
columns: columns,
|
|
603
617
|
onChange: onChange,
|
|
604
|
-
buttons: finalButtons,
|
|
618
|
+
buttons: buttons || finalButtons,
|
|
605
619
|
buttonsClassName: "ms-xl-auto",
|
|
606
620
|
withStickySelection: true
|
|
607
621
|
}) : /*#__PURE__*/React.createElement(MediasBrowserContainer, {
|
|
@@ -616,7 +630,7 @@ function MediaGallery(_ref) {
|
|
|
616
630
|
filters: finalFilters,
|
|
617
631
|
fields: fields,
|
|
618
632
|
columns: columns,
|
|
619
|
-
buttons: finalButtons,
|
|
633
|
+
buttons: buttons || finalButtons,
|
|
620
634
|
buttonsClassName: "ms-xl-auto",
|
|
621
635
|
withStickySelection: true
|
|
622
636
|
}), /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(UploadModal, {
|
package/lib/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var reactIntl = require('react-intl');
|
|
|
13
13
|
var medias = require('@panneau/medias');
|
|
14
14
|
var core = require('@micromag/core');
|
|
15
15
|
var components = require('@micromag/core/components');
|
|
16
|
+
var contexts = require('@micromag/core/contexts');
|
|
16
17
|
var data = require('@micromag/data');
|
|
17
18
|
var pathToRegexp = require('path-to-regexp');
|
|
18
19
|
|
|
@@ -177,17 +178,20 @@ var defaultFields = [{
|
|
|
177
178
|
}]
|
|
178
179
|
}),
|
|
179
180
|
type: 'array',
|
|
180
|
-
component: 'select'
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
component: 'select',
|
|
182
|
+
requestUrl: '/api/medias/tags',
|
|
183
|
+
optionLabelPath: 'name',
|
|
184
|
+
optionValuePath: 'id',
|
|
185
|
+
multiple: true,
|
|
186
|
+
paginated: false
|
|
183
187
|
}, {
|
|
184
|
-
id: '
|
|
185
|
-
component: '
|
|
188
|
+
id: 'jobs',
|
|
189
|
+
component: 'jobs',
|
|
186
190
|
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
187
|
-
id: "
|
|
191
|
+
id: "SrFsAq",
|
|
188
192
|
defaultMessage: [{
|
|
189
193
|
"type": 0,
|
|
190
|
-
"value": "
|
|
194
|
+
"value": "Jobs"
|
|
191
195
|
}]
|
|
192
196
|
})
|
|
193
197
|
}, {
|
|
@@ -398,39 +402,27 @@ function filters() {
|
|
|
398
402
|
name: 'source',
|
|
399
403
|
options: [{
|
|
400
404
|
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
401
|
-
id: "
|
|
405
|
+
id: "o+7d2z",
|
|
402
406
|
defaultMessage: [{
|
|
403
407
|
"type": 0,
|
|
404
|
-
"value": "All"
|
|
408
|
+
"value": "All medias"
|
|
405
409
|
}]
|
|
406
410
|
}),
|
|
407
411
|
value: 'all'
|
|
408
|
-
}, {
|
|
409
|
-
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
410
|
-
id: "AgH3AR",
|
|
411
|
-
defaultMessage: [{
|
|
412
|
-
"type": 0,
|
|
413
|
-
"value": "This micromag"
|
|
414
|
-
}]
|
|
415
|
-
}),
|
|
416
|
-
value: 'document-'
|
|
417
412
|
}]
|
|
418
|
-
},
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
itemValuePath: 'id',
|
|
432
|
-
multiple: true
|
|
433
|
-
}, {
|
|
413
|
+
},
|
|
414
|
+
// TODO: fix this on micromag.ca
|
|
415
|
+
// {
|
|
416
|
+
// id: 'authors',
|
|
417
|
+
// component: 'select',
|
|
418
|
+
// name: 'authors',
|
|
419
|
+
// placeholder: <FormattedMessage defaultMessage="Authors" description="Filter label" />,
|
|
420
|
+
// requestUrl: route('medias.authors') || '/api/medias/authors',
|
|
421
|
+
// itemLabelPath: 'name',
|
|
422
|
+
// itemValuePath: 'id',
|
|
423
|
+
// multiple: true,
|
|
424
|
+
// },
|
|
425
|
+
{
|
|
434
426
|
id: 'tags',
|
|
435
427
|
component: 'select',
|
|
436
428
|
name: 'tags',
|
|
@@ -497,11 +489,16 @@ function MediaGallery(_ref) {
|
|
|
497
489
|
columns = _ref.columns,
|
|
498
490
|
isPicker = _ref.isPicker,
|
|
499
491
|
multiple = _ref.multiple,
|
|
500
|
-
initialMedias = _ref.medias
|
|
501
|
-
_ref.buttons
|
|
502
|
-
|
|
492
|
+
initialMedias = _ref.medias,
|
|
493
|
+
buttons = _ref.buttons,
|
|
494
|
+
className = _ref.className,
|
|
503
495
|
onChange = _ref.onChange;
|
|
504
496
|
var api = data.useApi();
|
|
497
|
+
var story = contexts.useStory();
|
|
498
|
+
var _ref2 = story || {},
|
|
499
|
+
_ref2$id = _ref2.id,
|
|
500
|
+
storyId = _ref2$id === void 0 ? null : _ref2$id;
|
|
501
|
+
console.log('storyId', storyId);
|
|
505
502
|
var mediasApi = React.useMemo(function () {
|
|
506
503
|
return {
|
|
507
504
|
get: function get() {
|
|
@@ -568,18 +565,35 @@ function MediaGallery(_ref) {
|
|
|
568
565
|
var partialFilters = filters$1 || filters() || [];
|
|
569
566
|
var finalFilters = React.useMemo(function () {
|
|
570
567
|
return partialFilters.map(function (filter) {
|
|
571
|
-
var
|
|
572
|
-
|
|
573
|
-
id =
|
|
574
|
-
if (id === '
|
|
575
|
-
|
|
568
|
+
var _ref3 = filter || {},
|
|
569
|
+
_ref3$id = _ref3.id,
|
|
570
|
+
id = _ref3$id === void 0 ? null : _ref3$id;
|
|
571
|
+
if (id === 'source' && storyId !== null) {
|
|
572
|
+
var _ref4 = filter || {},
|
|
573
|
+
_ref4$options = _ref4.options,
|
|
574
|
+
options = _ref4$options === void 0 ? null : _ref4$options;
|
|
575
|
+
var finalOptions = (options || []).length > 0 ? [].concat(_toConsumableArray(options), [{
|
|
576
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
577
|
+
id: "eiaIIB",
|
|
578
|
+
defaultMessage: [{
|
|
579
|
+
"type": 0,
|
|
580
|
+
"value": "This Micromag"
|
|
581
|
+
}]
|
|
582
|
+
}),
|
|
583
|
+
value: "document-".concat(storyId)
|
|
584
|
+
}]) : null;
|
|
585
|
+
if (finalOptions === null) {
|
|
586
|
+
return null;
|
|
587
|
+
}
|
|
588
|
+
return _objectSpread(_objectSpread({}, filter), {}, {
|
|
589
|
+
options: finalOptions
|
|
590
|
+
});
|
|
576
591
|
}
|
|
577
|
-
// if (id === 'tags' && tags !== null) {
|
|
578
|
-
// return { ...filter, options: tags };
|
|
579
|
-
// }
|
|
580
592
|
return filter;
|
|
581
|
-
}).
|
|
582
|
-
|
|
593
|
+
}).filter(function (f) {
|
|
594
|
+
return f !== null;
|
|
595
|
+
});
|
|
596
|
+
}, [partialFilters, storyId]);
|
|
583
597
|
var _useState7 = React.useState(source !== null ? {
|
|
584
598
|
source: source
|
|
585
599
|
} : null),
|
|
@@ -597,10 +611,10 @@ function MediaGallery(_ref) {
|
|
|
597
611
|
}
|
|
598
612
|
console.log('addedMedias', addedMedias);
|
|
599
613
|
if (!multiple) {
|
|
600
|
-
var
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
firstMedia =
|
|
614
|
+
var _ref5 = addedMedias || [],
|
|
615
|
+
_ref6 = _slicedToArray(_ref5, 1),
|
|
616
|
+
_ref6$ = _ref6[0],
|
|
617
|
+
firstMedia = _ref6$ === void 0 ? null : _ref6$;
|
|
604
618
|
return firstMedia || null;
|
|
605
619
|
}
|
|
606
620
|
var allMedias = [].concat(_toConsumableArray(addedMedias), _toConsumableArray(isArray(value) ? value || [] : [value]));
|
|
@@ -641,7 +655,7 @@ function MediaGallery(_ref) {
|
|
|
641
655
|
fields: fields,
|
|
642
656
|
columns: columns,
|
|
643
657
|
onChange: onChange,
|
|
644
|
-
buttons: finalButtons,
|
|
658
|
+
buttons: buttons || finalButtons,
|
|
645
659
|
buttonsClassName: "ms-xl-auto",
|
|
646
660
|
withStickySelection: true
|
|
647
661
|
}) : /*#__PURE__*/React.createElement(medias.MediasBrowserContainer, {
|
|
@@ -656,7 +670,7 @@ function MediaGallery(_ref) {
|
|
|
656
670
|
filters: finalFilters,
|
|
657
671
|
fields: fields,
|
|
658
672
|
columns: columns,
|
|
659
|
-
buttons: finalButtons,
|
|
673
|
+
buttons: buttons || finalButtons,
|
|
660
674
|
buttonsClassName: "ms-xl-auto",
|
|
661
675
|
withStickySelection: true
|
|
662
676
|
}), /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React.createElement(components.UploadModal, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/media-gallery",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.516",
|
|
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.516",
|
|
76
|
+
"@micromag/data": "^0.3.516",
|
|
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": "27d49f1cd9ba3bac90dcd7f20ff053078be20333"
|
|
91
91
|
}
|