@micromag/media-gallery 0.3.515 → 0.3.517
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 +26 -115
- package/lib/index.js +25 -114
- package/package.json +4 -4
package/es/index.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
3
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
4
2
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
5
4
|
import classNames from 'classnames';
|
|
6
5
|
import isArray from 'lodash/isArray';
|
|
7
6
|
import PropTypes from 'prop-types';
|
|
8
|
-
import React, { useMemo,
|
|
9
|
-
import { createPortal } from 'react-dom';
|
|
10
|
-
import { FormattedMessage } from 'react-intl';
|
|
7
|
+
import React, { useMemo, useCallback, useState } from 'react';
|
|
11
8
|
import { MediasPickerContainer, MediasBrowserContainer } from '@panneau/medias';
|
|
12
9
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
13
|
-
import { UploadModal } from '@micromag/core/components';
|
|
14
10
|
import { useStory } from '@micromag/core/contexts';
|
|
15
11
|
import { useApi, useMediaCreate } from '@micromag/data';
|
|
12
|
+
import { FormattedMessage } from 'react-intl';
|
|
16
13
|
import { useUrlGenerator } from '@folklore/routes';
|
|
17
14
|
|
|
18
15
|
var defaultColumns = [{
|
|
@@ -308,7 +305,8 @@ function filters() {
|
|
|
308
305
|
return [{
|
|
309
306
|
id: 'search',
|
|
310
307
|
component: 'search',
|
|
311
|
-
name: 'search'
|
|
308
|
+
name: 'search',
|
|
309
|
+
width: 220
|
|
312
310
|
}, {
|
|
313
311
|
id: 'types',
|
|
314
312
|
component: 'select',
|
|
@@ -351,25 +349,15 @@ function filters() {
|
|
|
351
349
|
multiple: true
|
|
352
350
|
}, {
|
|
353
351
|
id: 'source',
|
|
354
|
-
component: '
|
|
355
|
-
|
|
356
|
-
id: "
|
|
352
|
+
component: 'toggle',
|
|
353
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
354
|
+
id: "AX9qes",
|
|
357
355
|
defaultMessage: [{
|
|
358
356
|
"type": 0,
|
|
359
|
-
"value": "
|
|
357
|
+
"value": "This micromag"
|
|
360
358
|
}]
|
|
361
359
|
}),
|
|
362
|
-
name: 'source'
|
|
363
|
-
options: [{
|
|
364
|
-
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
365
|
-
id: "o+7d2z",
|
|
366
|
-
defaultMessage: [{
|
|
367
|
-
"type": 0,
|
|
368
|
-
"value": "All medias"
|
|
369
|
-
}]
|
|
370
|
-
}),
|
|
371
|
-
value: 'all'
|
|
372
|
-
}]
|
|
360
|
+
name: 'source'
|
|
373
361
|
},
|
|
374
362
|
// TODO: fix this on micromag.ca
|
|
375
363
|
// {
|
|
@@ -422,7 +410,6 @@ var propTypes = {
|
|
|
422
410
|
isPicker: PropTypes.bool,
|
|
423
411
|
multiple: PropTypes.bool,
|
|
424
412
|
medias: PropTypes$1.medias,
|
|
425
|
-
buttons: PropTypes.arrayOf(PropTypes.shape({})),
|
|
426
413
|
className: PropTypes.string,
|
|
427
414
|
onChange: PropTypes.func
|
|
428
415
|
};
|
|
@@ -436,7 +423,6 @@ var defaultProps = {
|
|
|
436
423
|
isPicker: false,
|
|
437
424
|
multiple: false,
|
|
438
425
|
medias: null,
|
|
439
|
-
buttons: null,
|
|
440
426
|
className: null,
|
|
441
427
|
onChange: null
|
|
442
428
|
};
|
|
@@ -450,7 +436,6 @@ function MediaGallery(_ref) {
|
|
|
450
436
|
isPicker = _ref.isPicker,
|
|
451
437
|
multiple = _ref.multiple,
|
|
452
438
|
initialMedias = _ref.medias,
|
|
453
|
-
buttons = _ref.buttons,
|
|
454
439
|
className = _ref.className,
|
|
455
440
|
onChange = _ref.onChange;
|
|
456
441
|
var api = useApi();
|
|
@@ -458,7 +443,6 @@ function MediaGallery(_ref) {
|
|
|
458
443
|
var _ref2 = story || {},
|
|
459
444
|
_ref2$id = _ref2.id,
|
|
460
445
|
storyId = _ref2$id === void 0 ? null : _ref2$id;
|
|
461
|
-
console.log('storyId', storyId);
|
|
462
446
|
var mediasApi = useMemo(function () {
|
|
463
447
|
return {
|
|
464
448
|
get: function get() {
|
|
@@ -491,62 +475,27 @@ function MediaGallery(_ref) {
|
|
|
491
475
|
}
|
|
492
476
|
};
|
|
493
477
|
}, [api]);
|
|
494
|
-
|
|
495
|
-
// Upload modal
|
|
496
|
-
var _useState = useState([]),
|
|
497
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
498
|
-
addedMedias = _useState2[0],
|
|
499
|
-
setAddedMedias = _useState2[1];
|
|
500
|
-
var _useState3 = useState(false),
|
|
501
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
502
|
-
uploading = _useState4[0],
|
|
503
|
-
setUploading = _useState4[1];
|
|
504
|
-
var _useState5 = useState(false),
|
|
505
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
506
|
-
uploadModalOpened = _useState6[0],
|
|
507
|
-
setUploadModalOpened = _useState6[1];
|
|
508
|
-
var onClickAdd = useCallback(function () {
|
|
509
|
-
return setUploadModalOpened(true);
|
|
510
|
-
}, [setUploadModalOpened]);
|
|
478
|
+
var partialFilters = filters$1 || filters() || [];
|
|
511
479
|
var _useMediaCreate = useMediaCreate(),
|
|
512
480
|
createMedia = _useMediaCreate.create;
|
|
513
|
-
var
|
|
481
|
+
var onUpload = useCallback(function (newMedias) {
|
|
514
482
|
console.log('newMedias', newMedias);
|
|
515
|
-
setUploading(true);
|
|
516
483
|
Promise.all(newMedias.map(createMedia)).then(function (newAddedMedias) {
|
|
517
484
|
console.log('not uploading anymore', newAddedMedias);
|
|
518
|
-
|
|
519
|
-
return setAddedMedias([].concat(_toConsumableArray(addedMedias), _toConsumableArray(newAddedMedias)));
|
|
485
|
+
return newAddedMedias;
|
|
520
486
|
});
|
|
521
|
-
}, [createMedia
|
|
522
|
-
var onUploadRequestClose = useCallback(function () {
|
|
523
|
-
return setUploadModalOpened(false);
|
|
524
|
-
}, [setUploadModalOpened]);
|
|
525
|
-
var partialFilters = filters$1 || filters() || [];
|
|
487
|
+
}, [createMedia]);
|
|
526
488
|
var finalFilters = useMemo(function () {
|
|
527
489
|
return partialFilters.map(function (filter) {
|
|
528
490
|
var _ref3 = filter || {},
|
|
529
491
|
_ref3$id = _ref3.id,
|
|
530
492
|
id = _ref3$id === void 0 ? null : _ref3$id;
|
|
531
|
-
if (id === 'source'
|
|
532
|
-
|
|
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) {
|
|
493
|
+
if (id === 'source') {
|
|
494
|
+
if (storyId === null) {
|
|
546
495
|
return null;
|
|
547
496
|
}
|
|
548
497
|
return _objectSpread(_objectSpread({}, filter), {}, {
|
|
549
|
-
|
|
498
|
+
value: "document-".concat(storyId)
|
|
550
499
|
});
|
|
551
500
|
}
|
|
552
501
|
return filter;
|
|
@@ -554,58 +503,27 @@ function MediaGallery(_ref) {
|
|
|
554
503
|
return f !== null;
|
|
555
504
|
});
|
|
556
505
|
}, [partialFilters, storyId]);
|
|
557
|
-
var
|
|
506
|
+
var _useState = useState(source !== null ? {
|
|
558
507
|
source: source
|
|
559
508
|
} : null),
|
|
560
|
-
|
|
561
|
-
query =
|
|
562
|
-
setQuery =
|
|
509
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
510
|
+
query = _useState2[0],
|
|
511
|
+
setQuery = _useState2[1];
|
|
563
512
|
var finalQuery = useMemo(function () {
|
|
564
513
|
setQuery(_objectSpread(_objectSpread({}, query || null), source !== null ? {
|
|
565
514
|
source: source
|
|
566
515
|
} : null));
|
|
567
516
|
}, [source, setQuery]);
|
|
568
|
-
var finalValue = useMemo(function () {
|
|
569
|
-
if (addedMedias === null || addedMedias.length === 0) {
|
|
570
|
-
return value;
|
|
571
|
-
}
|
|
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
|
-
}
|
|
580
|
-
var allMedias = [].concat(_toConsumableArray(addedMedias), _toConsumableArray(isArray(value) ? value || [] : [value]));
|
|
581
|
-
return allMedias.length > 0 ? allMedias : null;
|
|
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
517
|
var finalTypes = useMemo(function () {
|
|
599
518
|
var partialTypes = !isArray(types) ? [types] : types;
|
|
600
519
|
return types === 'video' ? videoTypes : partialTypes;
|
|
601
520
|
}, [types]);
|
|
602
|
-
console.log('yesh', uploadModalOpened);
|
|
603
521
|
return /*#__PURE__*/React.createElement("div", {
|
|
604
522
|
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
605
523
|
}, isPicker ? /*#__PURE__*/React.createElement(MediasPickerContainer, {
|
|
606
524
|
className: styles.browser,
|
|
607
525
|
api: mediasApi,
|
|
608
|
-
value:
|
|
526
|
+
value: value,
|
|
609
527
|
theme: "dark",
|
|
610
528
|
types: finalTypes,
|
|
611
529
|
query: finalQuery,
|
|
@@ -615,13 +533,12 @@ function MediaGallery(_ref) {
|
|
|
615
533
|
fields: fields,
|
|
616
534
|
columns: columns,
|
|
617
535
|
onChange: onChange,
|
|
618
|
-
|
|
619
|
-
buttonsClassName: "ms-xl-auto",
|
|
536
|
+
onUpload: onUpload,
|
|
620
537
|
withStickySelection: true
|
|
621
538
|
}) : /*#__PURE__*/React.createElement(MediasBrowserContainer, {
|
|
622
539
|
className: styles.browser,
|
|
623
540
|
api: mediasApi,
|
|
624
|
-
value:
|
|
541
|
+
value: value,
|
|
625
542
|
theme: "dark",
|
|
626
543
|
types: finalTypes,
|
|
627
544
|
query: finalQuery,
|
|
@@ -630,15 +547,9 @@ function MediaGallery(_ref) {
|
|
|
630
547
|
filters: finalFilters,
|
|
631
548
|
fields: fields,
|
|
632
549
|
columns: columns,
|
|
633
|
-
|
|
634
|
-
buttonsClassName: "ms-xl-auto",
|
|
550
|
+
onUpload: onUpload,
|
|
635
551
|
withStickySelection: true
|
|
636
|
-
})
|
|
637
|
-
types: finalTypes,
|
|
638
|
-
opened: uploadModalOpened,
|
|
639
|
-
onUploaded: onUploadCompleted,
|
|
640
|
-
onRequestClose: onUploadRequestClose
|
|
641
|
-
}), document.body));
|
|
552
|
+
}));
|
|
642
553
|
}
|
|
643
554
|
MediaGallery.propTypes = propTypes;
|
|
644
555
|
MediaGallery.defaultProps = defaultProps;
|
package/lib/index.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
5
|
-
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
6
4
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
5
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
7
6
|
var classNames = require('classnames');
|
|
8
7
|
var isArray = require('lodash/isArray');
|
|
9
8
|
var PropTypes = require('prop-types');
|
|
10
9
|
var React = require('react');
|
|
11
|
-
var reactDom = require('react-dom');
|
|
12
|
-
var reactIntl = require('react-intl');
|
|
13
10
|
var medias = require('@panneau/medias');
|
|
14
11
|
var core = require('@micromag/core');
|
|
15
|
-
var components = require('@micromag/core/components');
|
|
16
12
|
var contexts = require('@micromag/core/contexts');
|
|
17
13
|
var data = require('@micromag/data');
|
|
14
|
+
var reactIntl = require('react-intl');
|
|
18
15
|
var pathToRegexp = require('path-to-regexp');
|
|
19
16
|
|
|
20
17
|
var defaultColumns = [{
|
|
@@ -348,7 +345,8 @@ function filters() {
|
|
|
348
345
|
return [{
|
|
349
346
|
id: 'search',
|
|
350
347
|
component: 'search',
|
|
351
|
-
name: 'search'
|
|
348
|
+
name: 'search',
|
|
349
|
+
width: 220
|
|
352
350
|
}, {
|
|
353
351
|
id: 'types',
|
|
354
352
|
component: 'select',
|
|
@@ -391,25 +389,15 @@ function filters() {
|
|
|
391
389
|
multiple: true
|
|
392
390
|
}, {
|
|
393
391
|
id: 'source',
|
|
394
|
-
component: '
|
|
395
|
-
|
|
396
|
-
id: "
|
|
392
|
+
component: 'toggle',
|
|
393
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
394
|
+
id: "AX9qes",
|
|
397
395
|
defaultMessage: [{
|
|
398
396
|
"type": 0,
|
|
399
|
-
"value": "
|
|
397
|
+
"value": "This micromag"
|
|
400
398
|
}]
|
|
401
399
|
}),
|
|
402
|
-
name: 'source'
|
|
403
|
-
options: [{
|
|
404
|
-
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
405
|
-
id: "o+7d2z",
|
|
406
|
-
defaultMessage: [{
|
|
407
|
-
"type": 0,
|
|
408
|
-
"value": "All medias"
|
|
409
|
-
}]
|
|
410
|
-
}),
|
|
411
|
-
value: 'all'
|
|
412
|
-
}]
|
|
400
|
+
name: 'source'
|
|
413
401
|
},
|
|
414
402
|
// TODO: fix this on micromag.ca
|
|
415
403
|
// {
|
|
@@ -462,7 +450,6 @@ var propTypes = {
|
|
|
462
450
|
isPicker: PropTypes.bool,
|
|
463
451
|
multiple: PropTypes.bool,
|
|
464
452
|
medias: core.PropTypes.medias,
|
|
465
|
-
buttons: PropTypes.arrayOf(PropTypes.shape({})),
|
|
466
453
|
className: PropTypes.string,
|
|
467
454
|
onChange: PropTypes.func
|
|
468
455
|
};
|
|
@@ -476,7 +463,6 @@ var defaultProps = {
|
|
|
476
463
|
isPicker: false,
|
|
477
464
|
multiple: false,
|
|
478
465
|
medias: null,
|
|
479
|
-
buttons: null,
|
|
480
466
|
className: null,
|
|
481
467
|
onChange: null
|
|
482
468
|
};
|
|
@@ -490,7 +476,6 @@ function MediaGallery(_ref) {
|
|
|
490
476
|
isPicker = _ref.isPicker,
|
|
491
477
|
multiple = _ref.multiple,
|
|
492
478
|
initialMedias = _ref.medias,
|
|
493
|
-
buttons = _ref.buttons,
|
|
494
479
|
className = _ref.className,
|
|
495
480
|
onChange = _ref.onChange;
|
|
496
481
|
var api = data.useApi();
|
|
@@ -498,7 +483,6 @@ function MediaGallery(_ref) {
|
|
|
498
483
|
var _ref2 = story || {},
|
|
499
484
|
_ref2$id = _ref2.id,
|
|
500
485
|
storyId = _ref2$id === void 0 ? null : _ref2$id;
|
|
501
|
-
console.log('storyId', storyId);
|
|
502
486
|
var mediasApi = React.useMemo(function () {
|
|
503
487
|
return {
|
|
504
488
|
get: function get() {
|
|
@@ -531,62 +515,27 @@ function MediaGallery(_ref) {
|
|
|
531
515
|
}
|
|
532
516
|
};
|
|
533
517
|
}, [api]);
|
|
534
|
-
|
|
535
|
-
// Upload modal
|
|
536
|
-
var _useState = React.useState([]),
|
|
537
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
538
|
-
addedMedias = _useState2[0],
|
|
539
|
-
setAddedMedias = _useState2[1];
|
|
540
|
-
var _useState3 = React.useState(false),
|
|
541
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
542
|
-
uploading = _useState4[0],
|
|
543
|
-
setUploading = _useState4[1];
|
|
544
|
-
var _useState5 = React.useState(false),
|
|
545
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
546
|
-
uploadModalOpened = _useState6[0],
|
|
547
|
-
setUploadModalOpened = _useState6[1];
|
|
548
|
-
var onClickAdd = React.useCallback(function () {
|
|
549
|
-
return setUploadModalOpened(true);
|
|
550
|
-
}, [setUploadModalOpened]);
|
|
518
|
+
var partialFilters = filters$1 || filters() || [];
|
|
551
519
|
var _useMediaCreate = data.useMediaCreate(),
|
|
552
520
|
createMedia = _useMediaCreate.create;
|
|
553
|
-
var
|
|
521
|
+
var onUpload = React.useCallback(function (newMedias) {
|
|
554
522
|
console.log('newMedias', newMedias);
|
|
555
|
-
setUploading(true);
|
|
556
523
|
Promise.all(newMedias.map(createMedia)).then(function (newAddedMedias) {
|
|
557
524
|
console.log('not uploading anymore', newAddedMedias);
|
|
558
|
-
|
|
559
|
-
return setAddedMedias([].concat(_toConsumableArray(addedMedias), _toConsumableArray(newAddedMedias)));
|
|
525
|
+
return newAddedMedias;
|
|
560
526
|
});
|
|
561
|
-
}, [createMedia
|
|
562
|
-
var onUploadRequestClose = React.useCallback(function () {
|
|
563
|
-
return setUploadModalOpened(false);
|
|
564
|
-
}, [setUploadModalOpened]);
|
|
565
|
-
var partialFilters = filters$1 || filters() || [];
|
|
527
|
+
}, [createMedia]);
|
|
566
528
|
var finalFilters = React.useMemo(function () {
|
|
567
529
|
return partialFilters.map(function (filter) {
|
|
568
530
|
var _ref3 = filter || {},
|
|
569
531
|
_ref3$id = _ref3.id,
|
|
570
532
|
id = _ref3$id === void 0 ? null : _ref3$id;
|
|
571
|
-
if (id === 'source'
|
|
572
|
-
|
|
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) {
|
|
533
|
+
if (id === 'source') {
|
|
534
|
+
if (storyId === null) {
|
|
586
535
|
return null;
|
|
587
536
|
}
|
|
588
537
|
return _objectSpread(_objectSpread({}, filter), {}, {
|
|
589
|
-
|
|
538
|
+
value: "document-".concat(storyId)
|
|
590
539
|
});
|
|
591
540
|
}
|
|
592
541
|
return filter;
|
|
@@ -594,58 +543,27 @@ function MediaGallery(_ref) {
|
|
|
594
543
|
return f !== null;
|
|
595
544
|
});
|
|
596
545
|
}, [partialFilters, storyId]);
|
|
597
|
-
var
|
|
546
|
+
var _useState = React.useState(source !== null ? {
|
|
598
547
|
source: source
|
|
599
548
|
} : null),
|
|
600
|
-
|
|
601
|
-
query =
|
|
602
|
-
setQuery =
|
|
549
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
550
|
+
query = _useState2[0],
|
|
551
|
+
setQuery = _useState2[1];
|
|
603
552
|
var finalQuery = React.useMemo(function () {
|
|
604
553
|
setQuery(_objectSpread(_objectSpread({}, query || null), source !== null ? {
|
|
605
554
|
source: source
|
|
606
555
|
} : null));
|
|
607
556
|
}, [source, setQuery]);
|
|
608
|
-
var finalValue = React.useMemo(function () {
|
|
609
|
-
if (addedMedias === null || addedMedias.length === 0) {
|
|
610
|
-
return value;
|
|
611
|
-
}
|
|
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
|
-
}
|
|
620
|
-
var allMedias = [].concat(_toConsumableArray(addedMedias), _toConsumableArray(isArray(value) ? value || [] : [value]));
|
|
621
|
-
return allMedias.length > 0 ? allMedias : null;
|
|
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
557
|
var finalTypes = React.useMemo(function () {
|
|
639
558
|
var partialTypes = !isArray(types) ? [types] : types;
|
|
640
559
|
return types === 'video' ? videoTypes : partialTypes;
|
|
641
560
|
}, [types]);
|
|
642
|
-
console.log('yesh', uploadModalOpened);
|
|
643
561
|
return /*#__PURE__*/React.createElement("div", {
|
|
644
562
|
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
645
563
|
}, isPicker ? /*#__PURE__*/React.createElement(medias.MediasPickerContainer, {
|
|
646
564
|
className: styles.browser,
|
|
647
565
|
api: mediasApi,
|
|
648
|
-
value:
|
|
566
|
+
value: value,
|
|
649
567
|
theme: "dark",
|
|
650
568
|
types: finalTypes,
|
|
651
569
|
query: finalQuery,
|
|
@@ -655,13 +573,12 @@ function MediaGallery(_ref) {
|
|
|
655
573
|
fields: fields,
|
|
656
574
|
columns: columns,
|
|
657
575
|
onChange: onChange,
|
|
658
|
-
|
|
659
|
-
buttonsClassName: "ms-xl-auto",
|
|
576
|
+
onUpload: onUpload,
|
|
660
577
|
withStickySelection: true
|
|
661
578
|
}) : /*#__PURE__*/React.createElement(medias.MediasBrowserContainer, {
|
|
662
579
|
className: styles.browser,
|
|
663
580
|
api: mediasApi,
|
|
664
|
-
value:
|
|
581
|
+
value: value,
|
|
665
582
|
theme: "dark",
|
|
666
583
|
types: finalTypes,
|
|
667
584
|
query: finalQuery,
|
|
@@ -670,15 +587,9 @@ function MediaGallery(_ref) {
|
|
|
670
587
|
filters: finalFilters,
|
|
671
588
|
fields: fields,
|
|
672
589
|
columns: columns,
|
|
673
|
-
|
|
674
|
-
buttonsClassName: "ms-xl-auto",
|
|
590
|
+
onUpload: onUpload,
|
|
675
591
|
withStickySelection: true
|
|
676
|
-
})
|
|
677
|
-
types: finalTypes,
|
|
678
|
-
opened: uploadModalOpened,
|
|
679
|
-
onUploaded: onUploadCompleted,
|
|
680
|
-
onRequestClose: onUploadRequestClose
|
|
681
|
-
}), document.body));
|
|
592
|
+
}));
|
|
682
593
|
}
|
|
683
594
|
MediaGallery.propTypes = propTypes;
|
|
684
595
|
MediaGallery.defaultProps = defaultProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/media-gallery",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.517",
|
|
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.517",
|
|
76
|
+
"@micromag/data": "^0.3.517",
|
|
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": "31938e53d440266802a0c575af50a13b1e730ed8"
|
|
91
91
|
}
|