@micromag/media-gallery 0.3.512 → 0.3.515
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 +109 -62
- package/lib/index.js +109 -62
- package/package.json +4 -4
package/es/index.js
CHANGED
|
@@ -7,22 +7,17 @@ import isArray from 'lodash/isArray';
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import React, { useMemo, useState, useCallback } from 'react';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
|
+
import { FormattedMessage } from 'react-intl';
|
|
10
11
|
import { MediasPickerContainer, MediasBrowserContainer } from '@panneau/medias';
|
|
11
12
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
12
13
|
import { UploadModal } from '@micromag/core/components';
|
|
14
|
+
import { useStory } from '@micromag/core/contexts';
|
|
13
15
|
import { useApi, useMediaCreate } from '@micromag/data';
|
|
14
|
-
import { FormattedMessage } from 'react-intl';
|
|
15
16
|
import { useUrlGenerator } from '@folklore/routes';
|
|
16
17
|
|
|
17
18
|
var defaultColumns = [{
|
|
18
19
|
id: 'image',
|
|
19
|
-
label:
|
|
20
|
-
id: "UbxbKP",
|
|
21
|
-
defaultMessage: [{
|
|
22
|
-
"type": 0,
|
|
23
|
-
"value": "Preview"
|
|
24
|
-
}]
|
|
25
|
-
}),
|
|
20
|
+
label: null,
|
|
26
21
|
component: 'image',
|
|
27
22
|
path: 'thumbnail_url',
|
|
28
23
|
sortable: false
|
|
@@ -172,13 +167,29 @@ var defaultFields = [{
|
|
|
172
167
|
type: 'text',
|
|
173
168
|
component: 'text'
|
|
174
169
|
}, {
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
name: 'tags',
|
|
171
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
172
|
+
id: "IOVper",
|
|
173
|
+
defaultMessage: [{
|
|
174
|
+
"type": 0,
|
|
175
|
+
"value": "Tags"
|
|
176
|
+
}]
|
|
177
|
+
}),
|
|
178
|
+
type: 'array',
|
|
179
|
+
component: 'select',
|
|
180
|
+
requestUrl: '/api/medias/tags',
|
|
181
|
+
optionLabelPath: 'name',
|
|
182
|
+
optionValuePath: 'id',
|
|
183
|
+
multiple: true,
|
|
184
|
+
paginated: false
|
|
185
|
+
}, {
|
|
186
|
+
id: 'jobs',
|
|
187
|
+
component: 'jobs',
|
|
177
188
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
178
|
-
id: "
|
|
189
|
+
id: "SrFsAq",
|
|
179
190
|
defaultMessage: [{
|
|
180
191
|
"type": 0,
|
|
181
|
-
"value": "
|
|
192
|
+
"value": "Jobs"
|
|
182
193
|
}]
|
|
183
194
|
})
|
|
184
195
|
}, {
|
|
@@ -351,39 +362,27 @@ function filters() {
|
|
|
351
362
|
name: 'source',
|
|
352
363
|
options: [{
|
|
353
364
|
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
354
|
-
id: "
|
|
365
|
+
id: "o+7d2z",
|
|
355
366
|
defaultMessage: [{
|
|
356
367
|
"type": 0,
|
|
357
|
-
"value": "All"
|
|
368
|
+
"value": "All medias"
|
|
358
369
|
}]
|
|
359
370
|
}),
|
|
360
371
|
value: 'all'
|
|
361
|
-
}, {
|
|
362
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
363
|
-
id: "AgH3AR",
|
|
364
|
-
defaultMessage: [{
|
|
365
|
-
"type": 0,
|
|
366
|
-
"value": "This micromag"
|
|
367
|
-
}]
|
|
368
|
-
}),
|
|
369
|
-
value: 'document'
|
|
370
372
|
}]
|
|
371
|
-
},
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
itemValuePath: 'id',
|
|
385
|
-
multiple: true
|
|
386
|
-
}, {
|
|
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
|
+
{
|
|
387
386
|
id: 'tags',
|
|
388
387
|
component: 'select',
|
|
389
388
|
name: 'tags',
|
|
@@ -404,8 +403,7 @@ function filters() {
|
|
|
404
403
|
|
|
405
404
|
var styles = {"container":"micromag-media-gallery-new-media-gallery-container","browser":"micromag-media-gallery-new-media-gallery-browser"};
|
|
406
405
|
|
|
407
|
-
|
|
408
|
-
|
|
406
|
+
var videoTypes = ['video', 'image/gif'];
|
|
409
407
|
var propTypes = {
|
|
410
408
|
value: PropTypes.shape({
|
|
411
409
|
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
@@ -456,6 +454,11 @@ function MediaGallery(_ref) {
|
|
|
456
454
|
className = _ref.className,
|
|
457
455
|
onChange = _ref.onChange;
|
|
458
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);
|
|
459
462
|
var mediasApi = useMemo(function () {
|
|
460
463
|
return {
|
|
461
464
|
get: function get() {
|
|
@@ -495,14 +498,14 @@ function MediaGallery(_ref) {
|
|
|
495
498
|
addedMedias = _useState2[0],
|
|
496
499
|
setAddedMedias = _useState2[1];
|
|
497
500
|
var _useState3 = useState(false),
|
|
498
|
-
_useState4 = _slicedToArray(_useState3, 2)
|
|
499
|
-
_useState4[0]
|
|
500
|
-
|
|
501
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
502
|
+
uploading = _useState4[0],
|
|
503
|
+
setUploading = _useState4[1];
|
|
501
504
|
var _useState5 = useState(false),
|
|
502
505
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
503
506
|
uploadModalOpened = _useState6[0],
|
|
504
507
|
setUploadModalOpened = _useState6[1];
|
|
505
|
-
useCallback(function () {
|
|
508
|
+
var onClickAdd = useCallback(function () {
|
|
506
509
|
return setUploadModalOpened(true);
|
|
507
510
|
}, [setUploadModalOpened]);
|
|
508
511
|
var _useMediaCreate = useMediaCreate(),
|
|
@@ -522,18 +525,35 @@ function MediaGallery(_ref) {
|
|
|
522
525
|
var partialFilters = filters$1 || filters() || [];
|
|
523
526
|
var finalFilters = useMemo(function () {
|
|
524
527
|
return partialFilters.map(function (filter) {
|
|
525
|
-
var
|
|
526
|
-
|
|
527
|
-
id =
|
|
528
|
-
if (id === '
|
|
529
|
-
|
|
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
|
+
});
|
|
530
551
|
}
|
|
531
|
-
// if (id === 'tags' && tags !== null) {
|
|
532
|
-
// return { ...filter, options: tags };
|
|
533
|
-
// }
|
|
534
552
|
return filter;
|
|
535
|
-
}).
|
|
536
|
-
|
|
553
|
+
}).filter(function (f) {
|
|
554
|
+
return f !== null;
|
|
555
|
+
});
|
|
556
|
+
}, [partialFilters, storyId]);
|
|
537
557
|
var _useState7 = useState(source !== null ? {
|
|
538
558
|
source: source
|
|
539
559
|
} : null),
|
|
@@ -549,10 +569,37 @@ function MediaGallery(_ref) {
|
|
|
549
569
|
if (addedMedias === null || addedMedias.length === 0) {
|
|
550
570
|
return value;
|
|
551
571
|
}
|
|
552
|
-
console.log('
|
|
572
|
+
console.log('addedMedias', addedMedias);
|
|
573
|
+
if (!multiple) {
|
|
574
|
+
var _ref5 = addedMedias || [],
|
|
575
|
+
_ref6 = _slicedToArray(_ref5, 1),
|
|
576
|
+
_ref6$ = _ref6[0],
|
|
577
|
+
firstMedia = _ref6$ === void 0 ? null : _ref6$;
|
|
578
|
+
return firstMedia || null;
|
|
579
|
+
}
|
|
553
580
|
var allMedias = [].concat(_toConsumableArray(addedMedias), _toConsumableArray(isArray(value) ? value || [] : [value]));
|
|
554
581
|
return allMedias.length > 0 ? allMedias : null;
|
|
555
|
-
}, [value, addedMedias]);
|
|
582
|
+
}, [value, addedMedias, multiple]);
|
|
583
|
+
var finalButtons = useMemo(function () {
|
|
584
|
+
return [{
|
|
585
|
+
id: 'upload',
|
|
586
|
+
theme: 'primary',
|
|
587
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
588
|
+
id: "hrS5Pj",
|
|
589
|
+
defaultMessage: [{
|
|
590
|
+
"type": 0,
|
|
591
|
+
"value": "Upload"
|
|
592
|
+
}]
|
|
593
|
+
}),
|
|
594
|
+
onClick: onClickAdd,
|
|
595
|
+
disabled: uploading
|
|
596
|
+
}];
|
|
597
|
+
}, [onClickAdd, uploading]);
|
|
598
|
+
var finalTypes = useMemo(function () {
|
|
599
|
+
var partialTypes = !isArray(types) ? [types] : types;
|
|
600
|
+
return types === 'video' ? videoTypes : partialTypes;
|
|
601
|
+
}, [types]);
|
|
602
|
+
console.log('yesh', uploadModalOpened);
|
|
556
603
|
return /*#__PURE__*/React.createElement("div", {
|
|
557
604
|
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
558
605
|
}, isPicker ? /*#__PURE__*/React.createElement(MediasPickerContainer, {
|
|
@@ -560,7 +607,7 @@ function MediaGallery(_ref) {
|
|
|
560
607
|
api: mediasApi,
|
|
561
608
|
value: finalValue,
|
|
562
609
|
theme: "dark",
|
|
563
|
-
types:
|
|
610
|
+
types: finalTypes,
|
|
564
611
|
query: finalQuery,
|
|
565
612
|
multiple: multiple,
|
|
566
613
|
items: initialMedias,
|
|
@@ -568,7 +615,7 @@ function MediaGallery(_ref) {
|
|
|
568
615
|
fields: fields,
|
|
569
616
|
columns: columns,
|
|
570
617
|
onChange: onChange,
|
|
571
|
-
buttons: buttons,
|
|
618
|
+
buttons: buttons || finalButtons,
|
|
572
619
|
buttonsClassName: "ms-xl-auto",
|
|
573
620
|
withStickySelection: true
|
|
574
621
|
}) : /*#__PURE__*/React.createElement(MediasBrowserContainer, {
|
|
@@ -576,18 +623,18 @@ function MediaGallery(_ref) {
|
|
|
576
623
|
api: mediasApi,
|
|
577
624
|
value: finalValue,
|
|
578
625
|
theme: "dark",
|
|
579
|
-
types:
|
|
626
|
+
types: finalTypes,
|
|
580
627
|
query: finalQuery,
|
|
581
628
|
multiple: multiple,
|
|
582
629
|
items: initialMedias,
|
|
583
630
|
filters: finalFilters,
|
|
584
631
|
fields: fields,
|
|
585
632
|
columns: columns,
|
|
586
|
-
buttons: buttons,
|
|
633
|
+
buttons: buttons || finalButtons,
|
|
587
634
|
buttonsClassName: "ms-xl-auto",
|
|
588
635
|
withStickySelection: true
|
|
589
636
|
}), /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(UploadModal, {
|
|
590
|
-
types:
|
|
637
|
+
types: finalTypes,
|
|
591
638
|
opened: uploadModalOpened,
|
|
592
639
|
onUploaded: onUploadCompleted,
|
|
593
640
|
onRequestClose: onUploadRequestClose
|
package/lib/index.js
CHANGED
|
@@ -9,22 +9,17 @@ var isArray = require('lodash/isArray');
|
|
|
9
9
|
var PropTypes = require('prop-types');
|
|
10
10
|
var React = require('react');
|
|
11
11
|
var reactDom = require('react-dom');
|
|
12
|
+
var reactIntl = require('react-intl');
|
|
12
13
|
var medias = require('@panneau/medias');
|
|
13
14
|
var core = require('@micromag/core');
|
|
14
15
|
var components = require('@micromag/core/components');
|
|
16
|
+
var contexts = require('@micromag/core/contexts');
|
|
15
17
|
var data = require('@micromag/data');
|
|
16
|
-
var reactIntl = require('react-intl');
|
|
17
18
|
var pathToRegexp = require('path-to-regexp');
|
|
18
19
|
|
|
19
20
|
var defaultColumns = [{
|
|
20
21
|
id: 'image',
|
|
21
|
-
label:
|
|
22
|
-
id: "UbxbKP",
|
|
23
|
-
defaultMessage: [{
|
|
24
|
-
"type": 0,
|
|
25
|
-
"value": "Preview"
|
|
26
|
-
}]
|
|
27
|
-
}),
|
|
22
|
+
label: null,
|
|
28
23
|
component: 'image',
|
|
29
24
|
path: 'thumbnail_url',
|
|
30
25
|
sortable: false
|
|
@@ -174,13 +169,29 @@ var defaultFields = [{
|
|
|
174
169
|
type: 'text',
|
|
175
170
|
component: 'text'
|
|
176
171
|
}, {
|
|
177
|
-
|
|
178
|
-
|
|
172
|
+
name: 'tags',
|
|
173
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
174
|
+
id: "IOVper",
|
|
175
|
+
defaultMessage: [{
|
|
176
|
+
"type": 0,
|
|
177
|
+
"value": "Tags"
|
|
178
|
+
}]
|
|
179
|
+
}),
|
|
180
|
+
type: 'array',
|
|
181
|
+
component: 'select',
|
|
182
|
+
requestUrl: '/api/medias/tags',
|
|
183
|
+
optionLabelPath: 'name',
|
|
184
|
+
optionValuePath: 'id',
|
|
185
|
+
multiple: true,
|
|
186
|
+
paginated: false
|
|
187
|
+
}, {
|
|
188
|
+
id: 'jobs',
|
|
189
|
+
component: 'jobs',
|
|
179
190
|
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
180
|
-
id: "
|
|
191
|
+
id: "SrFsAq",
|
|
181
192
|
defaultMessage: [{
|
|
182
193
|
"type": 0,
|
|
183
|
-
"value": "
|
|
194
|
+
"value": "Jobs"
|
|
184
195
|
}]
|
|
185
196
|
})
|
|
186
197
|
}, {
|
|
@@ -391,39 +402,27 @@ function filters() {
|
|
|
391
402
|
name: 'source',
|
|
392
403
|
options: [{
|
|
393
404
|
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
394
|
-
id: "
|
|
405
|
+
id: "o+7d2z",
|
|
395
406
|
defaultMessage: [{
|
|
396
407
|
"type": 0,
|
|
397
|
-
"value": "All"
|
|
408
|
+
"value": "All medias"
|
|
398
409
|
}]
|
|
399
410
|
}),
|
|
400
411
|
value: 'all'
|
|
401
|
-
}, {
|
|
402
|
-
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
403
|
-
id: "AgH3AR",
|
|
404
|
-
defaultMessage: [{
|
|
405
|
-
"type": 0,
|
|
406
|
-
"value": "This micromag"
|
|
407
|
-
}]
|
|
408
|
-
}),
|
|
409
|
-
value: 'document'
|
|
410
412
|
}]
|
|
411
|
-
},
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
itemValuePath: 'id',
|
|
425
|
-
multiple: true
|
|
426
|
-
}, {
|
|
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
|
+
{
|
|
427
426
|
id: 'tags',
|
|
428
427
|
component: 'select',
|
|
429
428
|
name: 'tags',
|
|
@@ -444,8 +443,7 @@ function filters() {
|
|
|
444
443
|
|
|
445
444
|
var styles = {"container":"micromag-media-gallery-new-media-gallery-container","browser":"micromag-media-gallery-new-media-gallery-browser"};
|
|
446
445
|
|
|
447
|
-
|
|
448
|
-
|
|
446
|
+
var videoTypes = ['video', 'image/gif'];
|
|
449
447
|
var propTypes = {
|
|
450
448
|
value: PropTypes.shape({
|
|
451
449
|
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
@@ -496,6 +494,11 @@ function MediaGallery(_ref) {
|
|
|
496
494
|
className = _ref.className,
|
|
497
495
|
onChange = _ref.onChange;
|
|
498
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);
|
|
499
502
|
var mediasApi = React.useMemo(function () {
|
|
500
503
|
return {
|
|
501
504
|
get: function get() {
|
|
@@ -535,14 +538,14 @@ function MediaGallery(_ref) {
|
|
|
535
538
|
addedMedias = _useState2[0],
|
|
536
539
|
setAddedMedias = _useState2[1];
|
|
537
540
|
var _useState3 = React.useState(false),
|
|
538
|
-
_useState4 = _slicedToArray(_useState3, 2)
|
|
539
|
-
_useState4[0]
|
|
540
|
-
|
|
541
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
542
|
+
uploading = _useState4[0],
|
|
543
|
+
setUploading = _useState4[1];
|
|
541
544
|
var _useState5 = React.useState(false),
|
|
542
545
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
543
546
|
uploadModalOpened = _useState6[0],
|
|
544
547
|
setUploadModalOpened = _useState6[1];
|
|
545
|
-
React.useCallback(function () {
|
|
548
|
+
var onClickAdd = React.useCallback(function () {
|
|
546
549
|
return setUploadModalOpened(true);
|
|
547
550
|
}, [setUploadModalOpened]);
|
|
548
551
|
var _useMediaCreate = data.useMediaCreate(),
|
|
@@ -562,18 +565,35 @@ function MediaGallery(_ref) {
|
|
|
562
565
|
var partialFilters = filters$1 || filters() || [];
|
|
563
566
|
var finalFilters = React.useMemo(function () {
|
|
564
567
|
return partialFilters.map(function (filter) {
|
|
565
|
-
var
|
|
566
|
-
|
|
567
|
-
id =
|
|
568
|
-
if (id === '
|
|
569
|
-
|
|
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
|
+
});
|
|
570
591
|
}
|
|
571
|
-
// if (id === 'tags' && tags !== null) {
|
|
572
|
-
// return { ...filter, options: tags };
|
|
573
|
-
// }
|
|
574
592
|
return filter;
|
|
575
|
-
}).
|
|
576
|
-
|
|
593
|
+
}).filter(function (f) {
|
|
594
|
+
return f !== null;
|
|
595
|
+
});
|
|
596
|
+
}, [partialFilters, storyId]);
|
|
577
597
|
var _useState7 = React.useState(source !== null ? {
|
|
578
598
|
source: source
|
|
579
599
|
} : null),
|
|
@@ -589,10 +609,37 @@ function MediaGallery(_ref) {
|
|
|
589
609
|
if (addedMedias === null || addedMedias.length === 0) {
|
|
590
610
|
return value;
|
|
591
611
|
}
|
|
592
|
-
console.log('
|
|
612
|
+
console.log('addedMedias', addedMedias);
|
|
613
|
+
if (!multiple) {
|
|
614
|
+
var _ref5 = addedMedias || [],
|
|
615
|
+
_ref6 = _slicedToArray(_ref5, 1),
|
|
616
|
+
_ref6$ = _ref6[0],
|
|
617
|
+
firstMedia = _ref6$ === void 0 ? null : _ref6$;
|
|
618
|
+
return firstMedia || null;
|
|
619
|
+
}
|
|
593
620
|
var allMedias = [].concat(_toConsumableArray(addedMedias), _toConsumableArray(isArray(value) ? value || [] : [value]));
|
|
594
621
|
return allMedias.length > 0 ? allMedias : null;
|
|
595
|
-
}, [value, addedMedias]);
|
|
622
|
+
}, [value, addedMedias, multiple]);
|
|
623
|
+
var finalButtons = React.useMemo(function () {
|
|
624
|
+
return [{
|
|
625
|
+
id: 'upload',
|
|
626
|
+
theme: 'primary',
|
|
627
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
628
|
+
id: "hrS5Pj",
|
|
629
|
+
defaultMessage: [{
|
|
630
|
+
"type": 0,
|
|
631
|
+
"value": "Upload"
|
|
632
|
+
}]
|
|
633
|
+
}),
|
|
634
|
+
onClick: onClickAdd,
|
|
635
|
+
disabled: uploading
|
|
636
|
+
}];
|
|
637
|
+
}, [onClickAdd, uploading]);
|
|
638
|
+
var finalTypes = React.useMemo(function () {
|
|
639
|
+
var partialTypes = !isArray(types) ? [types] : types;
|
|
640
|
+
return types === 'video' ? videoTypes : partialTypes;
|
|
641
|
+
}, [types]);
|
|
642
|
+
console.log('yesh', uploadModalOpened);
|
|
596
643
|
return /*#__PURE__*/React.createElement("div", {
|
|
597
644
|
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
598
645
|
}, isPicker ? /*#__PURE__*/React.createElement(medias.MediasPickerContainer, {
|
|
@@ -600,7 +647,7 @@ function MediaGallery(_ref) {
|
|
|
600
647
|
api: mediasApi,
|
|
601
648
|
value: finalValue,
|
|
602
649
|
theme: "dark",
|
|
603
|
-
types:
|
|
650
|
+
types: finalTypes,
|
|
604
651
|
query: finalQuery,
|
|
605
652
|
multiple: multiple,
|
|
606
653
|
items: initialMedias,
|
|
@@ -608,7 +655,7 @@ function MediaGallery(_ref) {
|
|
|
608
655
|
fields: fields,
|
|
609
656
|
columns: columns,
|
|
610
657
|
onChange: onChange,
|
|
611
|
-
buttons: buttons,
|
|
658
|
+
buttons: buttons || finalButtons,
|
|
612
659
|
buttonsClassName: "ms-xl-auto",
|
|
613
660
|
withStickySelection: true
|
|
614
661
|
}) : /*#__PURE__*/React.createElement(medias.MediasBrowserContainer, {
|
|
@@ -616,18 +663,18 @@ function MediaGallery(_ref) {
|
|
|
616
663
|
api: mediasApi,
|
|
617
664
|
value: finalValue,
|
|
618
665
|
theme: "dark",
|
|
619
|
-
types:
|
|
666
|
+
types: finalTypes,
|
|
620
667
|
query: finalQuery,
|
|
621
668
|
multiple: multiple,
|
|
622
669
|
items: initialMedias,
|
|
623
670
|
filters: finalFilters,
|
|
624
671
|
fields: fields,
|
|
625
672
|
columns: columns,
|
|
626
|
-
buttons: buttons,
|
|
673
|
+
buttons: buttons || finalButtons,
|
|
627
674
|
buttonsClassName: "ms-xl-auto",
|
|
628
675
|
withStickySelection: true
|
|
629
676
|
}), /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React.createElement(components.UploadModal, {
|
|
630
|
-
types:
|
|
677
|
+
types: finalTypes,
|
|
631
678
|
opened: uploadModalOpened,
|
|
632
679
|
onUploaded: onUploadCompleted,
|
|
633
680
|
onRequestClose: onUploadRequestClose
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/media-gallery",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.515",
|
|
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.514",
|
|
76
|
+
"@micromag/data": "^0.3.514",
|
|
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": "34c550d446b1719075278d17267ad8f4bd68b76b"
|
|
91
91
|
}
|