@micromag/media-gallery 0.3.512 → 0.3.514
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 +58 -25
- package/lib/index.js +58 -25
- package/package.json +4 -4
package/es/index.js
CHANGED
|
@@ -7,22 +7,16 @@ 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';
|
|
13
14
|
import { useApi, useMediaCreate } from '@micromag/data';
|
|
14
|
-
import { FormattedMessage } from 'react-intl';
|
|
15
15
|
import { useUrlGenerator } from '@folklore/routes';
|
|
16
16
|
|
|
17
17
|
var defaultColumns = [{
|
|
18
18
|
id: 'image',
|
|
19
|
-
label:
|
|
20
|
-
id: "UbxbKP",
|
|
21
|
-
defaultMessage: [{
|
|
22
|
-
"type": 0,
|
|
23
|
-
"value": "Preview"
|
|
24
|
-
}]
|
|
25
|
-
}),
|
|
19
|
+
label: null,
|
|
26
20
|
component: 'image',
|
|
27
21
|
path: 'thumbnail_url',
|
|
28
22
|
sortable: false
|
|
@@ -171,6 +165,19 @@ var defaultFields = [{
|
|
|
171
165
|
}),
|
|
172
166
|
type: 'text',
|
|
173
167
|
component: 'text'
|
|
168
|
+
}, {
|
|
169
|
+
name: 'tags',
|
|
170
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
171
|
+
id: "IOVper",
|
|
172
|
+
defaultMessage: [{
|
|
173
|
+
"type": 0,
|
|
174
|
+
"value": "Tags"
|
|
175
|
+
}]
|
|
176
|
+
}),
|
|
177
|
+
type: 'array',
|
|
178
|
+
component: 'select'
|
|
179
|
+
// requestUrl: route('medias.tags') || '/api/medias/tags',
|
|
180
|
+
// itemLabelPath: 'name',
|
|
174
181
|
}, {
|
|
175
182
|
id: 'custom_field',
|
|
176
183
|
component: 'custom_field',
|
|
@@ -366,7 +373,7 @@ function filters() {
|
|
|
366
373
|
"value": "This micromag"
|
|
367
374
|
}]
|
|
368
375
|
}),
|
|
369
|
-
value: 'document'
|
|
376
|
+
value: 'document-'
|
|
370
377
|
}]
|
|
371
378
|
}, {
|
|
372
379
|
id: 'authors',
|
|
@@ -404,8 +411,7 @@ function filters() {
|
|
|
404
411
|
|
|
405
412
|
var styles = {"container":"micromag-media-gallery-new-media-gallery-container","browser":"micromag-media-gallery-new-media-gallery-browser"};
|
|
406
413
|
|
|
407
|
-
|
|
408
|
-
|
|
414
|
+
var videoTypes = ['video', 'image/gif'];
|
|
409
415
|
var propTypes = {
|
|
410
416
|
value: PropTypes.shape({
|
|
411
417
|
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
@@ -451,9 +457,9 @@ function MediaGallery(_ref) {
|
|
|
451
457
|
columns = _ref.columns,
|
|
452
458
|
isPicker = _ref.isPicker,
|
|
453
459
|
multiple = _ref.multiple,
|
|
454
|
-
initialMedias = _ref.medias
|
|
455
|
-
|
|
456
|
-
className = _ref.className,
|
|
460
|
+
initialMedias = _ref.medias;
|
|
461
|
+
_ref.buttons;
|
|
462
|
+
var className = _ref.className,
|
|
457
463
|
onChange = _ref.onChange;
|
|
458
464
|
var api = useApi();
|
|
459
465
|
var mediasApi = useMemo(function () {
|
|
@@ -495,14 +501,14 @@ function MediaGallery(_ref) {
|
|
|
495
501
|
addedMedias = _useState2[0],
|
|
496
502
|
setAddedMedias = _useState2[1];
|
|
497
503
|
var _useState3 = useState(false),
|
|
498
|
-
_useState4 = _slicedToArray(_useState3, 2)
|
|
499
|
-
_useState4[0]
|
|
500
|
-
|
|
504
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
505
|
+
uploading = _useState4[0],
|
|
506
|
+
setUploading = _useState4[1];
|
|
501
507
|
var _useState5 = useState(false),
|
|
502
508
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
503
509
|
uploadModalOpened = _useState6[0],
|
|
504
510
|
setUploadModalOpened = _useState6[1];
|
|
505
|
-
useCallback(function () {
|
|
511
|
+
var onClickAdd = useCallback(function () {
|
|
506
512
|
return setUploadModalOpened(true);
|
|
507
513
|
}, [setUploadModalOpened]);
|
|
508
514
|
var _useMediaCreate = useMediaCreate(),
|
|
@@ -549,10 +555,37 @@ function MediaGallery(_ref) {
|
|
|
549
555
|
if (addedMedias === null || addedMedias.length === 0) {
|
|
550
556
|
return value;
|
|
551
557
|
}
|
|
552
|
-
console.log('
|
|
558
|
+
console.log('addedMedias', addedMedias);
|
|
559
|
+
if (!multiple) {
|
|
560
|
+
var _ref3 = addedMedias || [],
|
|
561
|
+
_ref4 = _slicedToArray(_ref3, 1),
|
|
562
|
+
_ref4$ = _ref4[0],
|
|
563
|
+
firstMedia = _ref4$ === void 0 ? null : _ref4$;
|
|
564
|
+
return firstMedia || null;
|
|
565
|
+
}
|
|
553
566
|
var allMedias = [].concat(_toConsumableArray(addedMedias), _toConsumableArray(isArray(value) ? value || [] : [value]));
|
|
554
567
|
return allMedias.length > 0 ? allMedias : null;
|
|
555
|
-
}, [value, addedMedias]);
|
|
568
|
+
}, [value, addedMedias, multiple]);
|
|
569
|
+
var finalButtons = useMemo(function () {
|
|
570
|
+
return [{
|
|
571
|
+
id: 'upload',
|
|
572
|
+
theme: 'primary',
|
|
573
|
+
label: /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
574
|
+
id: "hrS5Pj",
|
|
575
|
+
defaultMessage: [{
|
|
576
|
+
"type": 0,
|
|
577
|
+
"value": "Upload"
|
|
578
|
+
}]
|
|
579
|
+
}),
|
|
580
|
+
onClick: onClickAdd,
|
|
581
|
+
disabled: uploading
|
|
582
|
+
}];
|
|
583
|
+
}, [onClickAdd, uploading]);
|
|
584
|
+
var finalTypes = useMemo(function () {
|
|
585
|
+
var partialTypes = !isArray(types) ? [types] : types;
|
|
586
|
+
return types === 'video' ? videoTypes : partialTypes;
|
|
587
|
+
}, [types]);
|
|
588
|
+
console.log('yesh', uploadModalOpened);
|
|
556
589
|
return /*#__PURE__*/React.createElement("div", {
|
|
557
590
|
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
558
591
|
}, isPicker ? /*#__PURE__*/React.createElement(MediasPickerContainer, {
|
|
@@ -560,7 +593,7 @@ function MediaGallery(_ref) {
|
|
|
560
593
|
api: mediasApi,
|
|
561
594
|
value: finalValue,
|
|
562
595
|
theme: "dark",
|
|
563
|
-
types:
|
|
596
|
+
types: finalTypes,
|
|
564
597
|
query: finalQuery,
|
|
565
598
|
multiple: multiple,
|
|
566
599
|
items: initialMedias,
|
|
@@ -568,7 +601,7 @@ function MediaGallery(_ref) {
|
|
|
568
601
|
fields: fields,
|
|
569
602
|
columns: columns,
|
|
570
603
|
onChange: onChange,
|
|
571
|
-
buttons:
|
|
604
|
+
buttons: finalButtons,
|
|
572
605
|
buttonsClassName: "ms-xl-auto",
|
|
573
606
|
withStickySelection: true
|
|
574
607
|
}) : /*#__PURE__*/React.createElement(MediasBrowserContainer, {
|
|
@@ -576,18 +609,18 @@ function MediaGallery(_ref) {
|
|
|
576
609
|
api: mediasApi,
|
|
577
610
|
value: finalValue,
|
|
578
611
|
theme: "dark",
|
|
579
|
-
types:
|
|
612
|
+
types: finalTypes,
|
|
580
613
|
query: finalQuery,
|
|
581
614
|
multiple: multiple,
|
|
582
615
|
items: initialMedias,
|
|
583
616
|
filters: finalFilters,
|
|
584
617
|
fields: fields,
|
|
585
618
|
columns: columns,
|
|
586
|
-
buttons:
|
|
619
|
+
buttons: finalButtons,
|
|
587
620
|
buttonsClassName: "ms-xl-auto",
|
|
588
621
|
withStickySelection: true
|
|
589
622
|
}), /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(UploadModal, {
|
|
590
|
-
types:
|
|
623
|
+
types: finalTypes,
|
|
591
624
|
opened: uploadModalOpened,
|
|
592
625
|
onUploaded: onUploadCompleted,
|
|
593
626
|
onRequestClose: onUploadRequestClose
|
package/lib/index.js
CHANGED
|
@@ -9,22 +9,16 @@ 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');
|
|
15
16
|
var data = require('@micromag/data');
|
|
16
|
-
var reactIntl = require('react-intl');
|
|
17
17
|
var pathToRegexp = require('path-to-regexp');
|
|
18
18
|
|
|
19
19
|
var defaultColumns = [{
|
|
20
20
|
id: 'image',
|
|
21
|
-
label:
|
|
22
|
-
id: "UbxbKP",
|
|
23
|
-
defaultMessage: [{
|
|
24
|
-
"type": 0,
|
|
25
|
-
"value": "Preview"
|
|
26
|
-
}]
|
|
27
|
-
}),
|
|
21
|
+
label: null,
|
|
28
22
|
component: 'image',
|
|
29
23
|
path: 'thumbnail_url',
|
|
30
24
|
sortable: false
|
|
@@ -173,6 +167,19 @@ var defaultFields = [{
|
|
|
173
167
|
}),
|
|
174
168
|
type: 'text',
|
|
175
169
|
component: 'text'
|
|
170
|
+
}, {
|
|
171
|
+
name: 'tags',
|
|
172
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
173
|
+
id: "IOVper",
|
|
174
|
+
defaultMessage: [{
|
|
175
|
+
"type": 0,
|
|
176
|
+
"value": "Tags"
|
|
177
|
+
}]
|
|
178
|
+
}),
|
|
179
|
+
type: 'array',
|
|
180
|
+
component: 'select'
|
|
181
|
+
// requestUrl: route('medias.tags') || '/api/medias/tags',
|
|
182
|
+
// itemLabelPath: 'name',
|
|
176
183
|
}, {
|
|
177
184
|
id: 'custom_field',
|
|
178
185
|
component: 'custom_field',
|
|
@@ -406,7 +413,7 @@ function filters() {
|
|
|
406
413
|
"value": "This micromag"
|
|
407
414
|
}]
|
|
408
415
|
}),
|
|
409
|
-
value: 'document'
|
|
416
|
+
value: 'document-'
|
|
410
417
|
}]
|
|
411
418
|
}, {
|
|
412
419
|
id: 'authors',
|
|
@@ -444,8 +451,7 @@ function filters() {
|
|
|
444
451
|
|
|
445
452
|
var styles = {"container":"micromag-media-gallery-new-media-gallery-container","browser":"micromag-media-gallery-new-media-gallery-browser"};
|
|
446
453
|
|
|
447
|
-
|
|
448
|
-
|
|
454
|
+
var videoTypes = ['video', 'image/gif'];
|
|
449
455
|
var propTypes = {
|
|
450
456
|
value: PropTypes.shape({
|
|
451
457
|
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
@@ -491,9 +497,9 @@ function MediaGallery(_ref) {
|
|
|
491
497
|
columns = _ref.columns,
|
|
492
498
|
isPicker = _ref.isPicker,
|
|
493
499
|
multiple = _ref.multiple,
|
|
494
|
-
initialMedias = _ref.medias
|
|
495
|
-
|
|
496
|
-
className = _ref.className,
|
|
500
|
+
initialMedias = _ref.medias;
|
|
501
|
+
_ref.buttons;
|
|
502
|
+
var className = _ref.className,
|
|
497
503
|
onChange = _ref.onChange;
|
|
498
504
|
var api = data.useApi();
|
|
499
505
|
var mediasApi = React.useMemo(function () {
|
|
@@ -535,14 +541,14 @@ function MediaGallery(_ref) {
|
|
|
535
541
|
addedMedias = _useState2[0],
|
|
536
542
|
setAddedMedias = _useState2[1];
|
|
537
543
|
var _useState3 = React.useState(false),
|
|
538
|
-
_useState4 = _slicedToArray(_useState3, 2)
|
|
539
|
-
_useState4[0]
|
|
540
|
-
|
|
544
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
545
|
+
uploading = _useState4[0],
|
|
546
|
+
setUploading = _useState4[1];
|
|
541
547
|
var _useState5 = React.useState(false),
|
|
542
548
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
543
549
|
uploadModalOpened = _useState6[0],
|
|
544
550
|
setUploadModalOpened = _useState6[1];
|
|
545
|
-
React.useCallback(function () {
|
|
551
|
+
var onClickAdd = React.useCallback(function () {
|
|
546
552
|
return setUploadModalOpened(true);
|
|
547
553
|
}, [setUploadModalOpened]);
|
|
548
554
|
var _useMediaCreate = data.useMediaCreate(),
|
|
@@ -589,10 +595,37 @@ function MediaGallery(_ref) {
|
|
|
589
595
|
if (addedMedias === null || addedMedias.length === 0) {
|
|
590
596
|
return value;
|
|
591
597
|
}
|
|
592
|
-
console.log('
|
|
598
|
+
console.log('addedMedias', addedMedias);
|
|
599
|
+
if (!multiple) {
|
|
600
|
+
var _ref3 = addedMedias || [],
|
|
601
|
+
_ref4 = _slicedToArray(_ref3, 1),
|
|
602
|
+
_ref4$ = _ref4[0],
|
|
603
|
+
firstMedia = _ref4$ === void 0 ? null : _ref4$;
|
|
604
|
+
return firstMedia || null;
|
|
605
|
+
}
|
|
593
606
|
var allMedias = [].concat(_toConsumableArray(addedMedias), _toConsumableArray(isArray(value) ? value || [] : [value]));
|
|
594
607
|
return allMedias.length > 0 ? allMedias : null;
|
|
595
|
-
}, [value, addedMedias]);
|
|
608
|
+
}, [value, addedMedias, multiple]);
|
|
609
|
+
var finalButtons = React.useMemo(function () {
|
|
610
|
+
return [{
|
|
611
|
+
id: 'upload',
|
|
612
|
+
theme: 'primary',
|
|
613
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
614
|
+
id: "hrS5Pj",
|
|
615
|
+
defaultMessage: [{
|
|
616
|
+
"type": 0,
|
|
617
|
+
"value": "Upload"
|
|
618
|
+
}]
|
|
619
|
+
}),
|
|
620
|
+
onClick: onClickAdd,
|
|
621
|
+
disabled: uploading
|
|
622
|
+
}];
|
|
623
|
+
}, [onClickAdd, uploading]);
|
|
624
|
+
var finalTypes = React.useMemo(function () {
|
|
625
|
+
var partialTypes = !isArray(types) ? [types] : types;
|
|
626
|
+
return types === 'video' ? videoTypes : partialTypes;
|
|
627
|
+
}, [types]);
|
|
628
|
+
console.log('yesh', uploadModalOpened);
|
|
596
629
|
return /*#__PURE__*/React.createElement("div", {
|
|
597
630
|
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
598
631
|
}, isPicker ? /*#__PURE__*/React.createElement(medias.MediasPickerContainer, {
|
|
@@ -600,7 +633,7 @@ function MediaGallery(_ref) {
|
|
|
600
633
|
api: mediasApi,
|
|
601
634
|
value: finalValue,
|
|
602
635
|
theme: "dark",
|
|
603
|
-
types:
|
|
636
|
+
types: finalTypes,
|
|
604
637
|
query: finalQuery,
|
|
605
638
|
multiple: multiple,
|
|
606
639
|
items: initialMedias,
|
|
@@ -608,7 +641,7 @@ function MediaGallery(_ref) {
|
|
|
608
641
|
fields: fields,
|
|
609
642
|
columns: columns,
|
|
610
643
|
onChange: onChange,
|
|
611
|
-
buttons:
|
|
644
|
+
buttons: finalButtons,
|
|
612
645
|
buttonsClassName: "ms-xl-auto",
|
|
613
646
|
withStickySelection: true
|
|
614
647
|
}) : /*#__PURE__*/React.createElement(medias.MediasBrowserContainer, {
|
|
@@ -616,18 +649,18 @@ function MediaGallery(_ref) {
|
|
|
616
649
|
api: mediasApi,
|
|
617
650
|
value: finalValue,
|
|
618
651
|
theme: "dark",
|
|
619
|
-
types:
|
|
652
|
+
types: finalTypes,
|
|
620
653
|
query: finalQuery,
|
|
621
654
|
multiple: multiple,
|
|
622
655
|
items: initialMedias,
|
|
623
656
|
filters: finalFilters,
|
|
624
657
|
fields: fields,
|
|
625
658
|
columns: columns,
|
|
626
|
-
buttons:
|
|
659
|
+
buttons: finalButtons,
|
|
627
660
|
buttonsClassName: "ms-xl-auto",
|
|
628
661
|
withStickySelection: true
|
|
629
662
|
}), /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React.createElement(components.UploadModal, {
|
|
630
|
-
types:
|
|
663
|
+
types: finalTypes,
|
|
631
664
|
opened: uploadModalOpened,
|
|
632
665
|
onUploaded: onUploadCompleted,
|
|
633
666
|
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.514",
|
|
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": "40bbf8d97c0d912ce8be3c8caa2c70e117286fc2"
|
|
91
91
|
}
|