@micromag/media-gallery 0.4.71 → 0.4.74
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 +113 -272
- package/package.json +12 -15
package/es/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
1
|
import classNames from 'classnames';
|
|
3
2
|
import isArray from 'lodash/isArray';
|
|
4
3
|
import { useMemo, useCallback } from 'react';
|
|
@@ -19,10 +18,7 @@ var defaultColumns = [{
|
|
|
19
18
|
id: 'name',
|
|
20
19
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
21
20
|
id: "WX83V9",
|
|
22
|
-
defaultMessage:
|
|
23
|
-
"type": 0,
|
|
24
|
-
"value": "File name"
|
|
25
|
-
}]
|
|
21
|
+
defaultMessage: "File name"
|
|
26
22
|
}),
|
|
27
23
|
component: 'text-description',
|
|
28
24
|
path: 'name',
|
|
@@ -30,31 +26,19 @@ var defaultColumns = [{
|
|
|
30
26
|
descriptionValues: {
|
|
31
27
|
image: /*#__PURE__*/jsx(FormattedMessage, {
|
|
32
28
|
id: "AwDQvD",
|
|
33
|
-
defaultMessage:
|
|
34
|
-
"type": 0,
|
|
35
|
-
"value": "Image"
|
|
36
|
-
}]
|
|
29
|
+
defaultMessage: "Image"
|
|
37
30
|
}),
|
|
38
31
|
video: /*#__PURE__*/jsx(FormattedMessage, {
|
|
39
32
|
id: "mQiyAm",
|
|
40
|
-
defaultMessage:
|
|
41
|
-
"type": 0,
|
|
42
|
-
"value": "Video"
|
|
43
|
-
}]
|
|
33
|
+
defaultMessage: "Video"
|
|
44
34
|
}),
|
|
45
35
|
audio: /*#__PURE__*/jsx(FormattedMessage, {
|
|
46
36
|
id: "XnyI69",
|
|
47
|
-
defaultMessage:
|
|
48
|
-
"type": 0,
|
|
49
|
-
"value": "Audio"
|
|
50
|
-
}]
|
|
37
|
+
defaultMessage: "Audio"
|
|
51
38
|
}),
|
|
52
39
|
document: /*#__PURE__*/jsx(FormattedMessage, {
|
|
53
40
|
id: "1dqmFw",
|
|
54
|
-
defaultMessage:
|
|
55
|
-
"type": 0,
|
|
56
|
-
"value": "Document"
|
|
57
|
-
}]
|
|
41
|
+
defaultMessage: "Document"
|
|
58
42
|
})
|
|
59
43
|
},
|
|
60
44
|
sortable: true
|
|
@@ -62,10 +46,7 @@ var defaultColumns = [{
|
|
|
62
46
|
id: 'dimensions',
|
|
63
47
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
64
48
|
id: "eCe9ZY",
|
|
65
|
-
defaultMessage:
|
|
66
|
-
"type": 0,
|
|
67
|
-
"value": "Dimensions"
|
|
68
|
-
}]
|
|
49
|
+
defaultMessage: "Dimensions"
|
|
69
50
|
}),
|
|
70
51
|
component: 'unit',
|
|
71
52
|
format: 'dimensions',
|
|
@@ -74,10 +55,7 @@ var defaultColumns = [{
|
|
|
74
55
|
id: 'size',
|
|
75
56
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
76
57
|
id: "c3hu9o",
|
|
77
|
-
defaultMessage:
|
|
78
|
-
"type": 0,
|
|
79
|
-
"value": "Size"
|
|
80
|
-
}]
|
|
58
|
+
defaultMessage: "Size"
|
|
81
59
|
}),
|
|
82
60
|
component: 'unit',
|
|
83
61
|
format: 'bytes',
|
|
@@ -86,10 +64,7 @@ var defaultColumns = [{
|
|
|
86
64
|
id: 'duration',
|
|
87
65
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
88
66
|
id: "002oWQ",
|
|
89
|
-
defaultMessage:
|
|
90
|
-
"type": 0,
|
|
91
|
-
"value": "Duration"
|
|
92
|
-
}]
|
|
67
|
+
defaultMessage: "Duration"
|
|
93
68
|
}),
|
|
94
69
|
component: 'unit',
|
|
95
70
|
format: 'duration',
|
|
@@ -107,10 +82,7 @@ var defaultColumns = [{
|
|
|
107
82
|
id: 'created_at',
|
|
108
83
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
109
84
|
id: "OzYWZz",
|
|
110
|
-
defaultMessage:
|
|
111
|
-
"type": 0,
|
|
112
|
-
"value": "Created at"
|
|
113
|
-
}]
|
|
85
|
+
defaultMessage: "Created at"
|
|
114
86
|
}),
|
|
115
87
|
component: 'date',
|
|
116
88
|
path: 'created_at',
|
|
@@ -120,10 +92,7 @@ var defaultColumns = [{
|
|
|
120
92
|
id: 'actions',
|
|
121
93
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
122
94
|
id: "rtwfuZ",
|
|
123
|
-
defaultMessage:
|
|
124
|
-
"type": 0,
|
|
125
|
-
"value": "Actions"
|
|
126
|
-
}]
|
|
95
|
+
defaultMessage: "Actions"
|
|
127
96
|
}),
|
|
128
97
|
actions: ['edit', 'delete']
|
|
129
98
|
// component: ItemActions,
|
|
@@ -139,15 +108,12 @@ var defaultColumns = [{
|
|
|
139
108
|
];
|
|
140
109
|
|
|
141
110
|
function fields() {
|
|
142
|
-
|
|
111
|
+
const route = useUrlGenerator();
|
|
143
112
|
return [{
|
|
144
113
|
name: 'name',
|
|
145
114
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
146
115
|
id: "WX83V9",
|
|
147
|
-
defaultMessage:
|
|
148
|
-
"type": 0,
|
|
149
|
-
"value": "File name"
|
|
150
|
-
}]
|
|
116
|
+
defaultMessage: "File name"
|
|
151
117
|
}),
|
|
152
118
|
type: 'text',
|
|
153
119
|
component: 'text'
|
|
@@ -159,10 +125,7 @@ function fields() {
|
|
|
159
125
|
name: 'description',
|
|
160
126
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
161
127
|
id: "ygNvmz",
|
|
162
|
-
defaultMessage:
|
|
163
|
-
"type": 0,
|
|
164
|
-
"value": "Description"
|
|
165
|
-
}]
|
|
128
|
+
defaultMessage: "Description"
|
|
166
129
|
}),
|
|
167
130
|
type: 'text',
|
|
168
131
|
component: 'text'
|
|
@@ -170,10 +133,7 @@ function fields() {
|
|
|
170
133
|
name: 'tags',
|
|
171
134
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
172
135
|
id: "IOVper",
|
|
173
|
-
defaultMessage:
|
|
174
|
-
"type": 0,
|
|
175
|
-
"value": "Tags"
|
|
176
|
-
}]
|
|
136
|
+
defaultMessage: "Tags"
|
|
177
137
|
}),
|
|
178
138
|
createPrefix: 'Create',
|
|
179
139
|
type: 'array',
|
|
@@ -193,10 +153,7 @@ function fields() {
|
|
|
193
153
|
component: 'fields',
|
|
194
154
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
195
155
|
id: "3RT69u",
|
|
196
|
-
defaultMessage:
|
|
197
|
-
"type": 0,
|
|
198
|
-
"value": "Informations"
|
|
199
|
-
}]
|
|
156
|
+
defaultMessage: "Informations"
|
|
200
157
|
}),
|
|
201
158
|
isList: true,
|
|
202
159
|
hideWithoutValue: true,
|
|
@@ -204,10 +161,7 @@ function fields() {
|
|
|
204
161
|
id: 'user',
|
|
205
162
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
206
163
|
id: "yByaBh",
|
|
207
|
-
defaultMessage:
|
|
208
|
-
"type": 0,
|
|
209
|
-
"value": "Added by"
|
|
210
|
-
}]
|
|
164
|
+
defaultMessage: "Added by"
|
|
211
165
|
}),
|
|
212
166
|
type: 'display',
|
|
213
167
|
display: 'avatar',
|
|
@@ -217,10 +171,7 @@ function fields() {
|
|
|
217
171
|
id: 'created_at',
|
|
218
172
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
219
173
|
id: "PN+75e",
|
|
220
|
-
defaultMessage:
|
|
221
|
-
"type": 0,
|
|
222
|
-
"value": "Created at"
|
|
223
|
-
}]
|
|
174
|
+
defaultMessage: "Created at"
|
|
224
175
|
}),
|
|
225
176
|
type: 'display',
|
|
226
177
|
display: 'date',
|
|
@@ -233,10 +184,7 @@ function fields() {
|
|
|
233
184
|
component: 'fields',
|
|
234
185
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
235
186
|
id: "xKUOLG",
|
|
236
|
-
defaultMessage:
|
|
237
|
-
"type": 0,
|
|
238
|
-
"value": "Technical details"
|
|
239
|
-
}]
|
|
187
|
+
defaultMessage: "Technical details"
|
|
240
188
|
}),
|
|
241
189
|
isList: true,
|
|
242
190
|
hideWithoutValue: true,
|
|
@@ -244,10 +192,7 @@ function fields() {
|
|
|
244
192
|
id: 'format',
|
|
245
193
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
246
194
|
id: "JuxiUN",
|
|
247
|
-
defaultMessage:
|
|
248
|
-
"type": 0,
|
|
249
|
-
"value": "Format"
|
|
250
|
-
}]
|
|
195
|
+
defaultMessage: "Format"
|
|
251
196
|
}),
|
|
252
197
|
type: 'display',
|
|
253
198
|
display: 'unit',
|
|
@@ -258,10 +203,7 @@ function fields() {
|
|
|
258
203
|
id: 'dimensions',
|
|
259
204
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
260
205
|
id: "rmJBin",
|
|
261
|
-
defaultMessage:
|
|
262
|
-
"type": 0,
|
|
263
|
-
"value": "Dimensions"
|
|
264
|
-
}]
|
|
206
|
+
defaultMessage: "Dimensions"
|
|
265
207
|
}),
|
|
266
208
|
type: 'display',
|
|
267
209
|
display: 'unit',
|
|
@@ -272,10 +214,7 @@ function fields() {
|
|
|
272
214
|
id: 'size',
|
|
273
215
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
274
216
|
id: "g2CRt5",
|
|
275
|
-
defaultMessage:
|
|
276
|
-
"type": 0,
|
|
277
|
-
"value": "Size"
|
|
278
|
-
}]
|
|
217
|
+
defaultMessage: "Size"
|
|
279
218
|
}),
|
|
280
219
|
type: 'display',
|
|
281
220
|
display: 'unit',
|
|
@@ -286,10 +225,7 @@ function fields() {
|
|
|
286
225
|
id: 'duration',
|
|
287
226
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
288
227
|
id: "wU++NJ",
|
|
289
|
-
defaultMessage:
|
|
290
|
-
"type": 0,
|
|
291
|
-
"value": "Duration"
|
|
292
|
-
}]
|
|
228
|
+
defaultMessage: "Duration"
|
|
293
229
|
}),
|
|
294
230
|
type: 'display',
|
|
295
231
|
display: 'unit',
|
|
@@ -302,10 +238,7 @@ function fields() {
|
|
|
302
238
|
component: 'fields',
|
|
303
239
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
304
240
|
id: "pBNrdH",
|
|
305
|
-
defaultMessage:
|
|
306
|
-
"type": 0,
|
|
307
|
-
"value": "Conversion"
|
|
308
|
-
}]
|
|
241
|
+
defaultMessage: "Conversion"
|
|
309
242
|
}),
|
|
310
243
|
isList: true,
|
|
311
244
|
hideWithoutValue: true,
|
|
@@ -313,10 +246,7 @@ function fields() {
|
|
|
313
246
|
id: 'h264',
|
|
314
247
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
315
248
|
id: "4RV6+9",
|
|
316
|
-
defaultMessage:
|
|
317
|
-
"type": 0,
|
|
318
|
-
"value": "H264"
|
|
319
|
-
}]
|
|
249
|
+
defaultMessage: "H264"
|
|
320
250
|
}),
|
|
321
251
|
type: 'text',
|
|
322
252
|
component: 'text',
|
|
@@ -326,10 +256,7 @@ function fields() {
|
|
|
326
256
|
id: 'webm',
|
|
327
257
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
328
258
|
id: "3I2Xl7",
|
|
329
|
-
defaultMessage:
|
|
330
|
-
"type": 0,
|
|
331
|
-
"value": "WebM"
|
|
332
|
-
}]
|
|
259
|
+
defaultMessage: "WebM"
|
|
333
260
|
}),
|
|
334
261
|
type: 'text',
|
|
335
262
|
component: 'text',
|
|
@@ -340,7 +267,7 @@ function fields() {
|
|
|
340
267
|
}
|
|
341
268
|
|
|
342
269
|
function filters() {
|
|
343
|
-
|
|
270
|
+
const route = useUrlGenerator();
|
|
344
271
|
return [{
|
|
345
272
|
id: 'search',
|
|
346
273
|
component: 'search',
|
|
@@ -352,45 +279,30 @@ function filters() {
|
|
|
352
279
|
name: 'types',
|
|
353
280
|
placeholder: /*#__PURE__*/jsx(FormattedMessage, {
|
|
354
281
|
id: "9/t5wK",
|
|
355
|
-
defaultMessage:
|
|
356
|
-
"type": 0,
|
|
357
|
-
"value": "Type"
|
|
358
|
-
}]
|
|
282
|
+
defaultMessage: "Type"
|
|
359
283
|
}),
|
|
360
284
|
options: [{
|
|
361
285
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
362
286
|
id: "yHAmDD",
|
|
363
|
-
defaultMessage:
|
|
364
|
-
"type": 0,
|
|
365
|
-
"value": "Image"
|
|
366
|
-
}]
|
|
287
|
+
defaultMessage: "Image"
|
|
367
288
|
}),
|
|
368
289
|
value: 'image'
|
|
369
290
|
}, {
|
|
370
291
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
371
292
|
id: "xSERPA",
|
|
372
|
-
defaultMessage:
|
|
373
|
-
"type": 0,
|
|
374
|
-
"value": "Video"
|
|
375
|
-
}]
|
|
293
|
+
defaultMessage: "Video"
|
|
376
294
|
}),
|
|
377
295
|
value: 'video'
|
|
378
296
|
}, {
|
|
379
297
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
380
298
|
id: "yQRtgx",
|
|
381
|
-
defaultMessage:
|
|
382
|
-
"type": 0,
|
|
383
|
-
"value": "Audio"
|
|
384
|
-
}]
|
|
299
|
+
defaultMessage: "Audio"
|
|
385
300
|
}),
|
|
386
301
|
value: 'audio'
|
|
387
302
|
}, {
|
|
388
303
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
389
304
|
id: "fpQzza",
|
|
390
|
-
defaultMessage:
|
|
391
|
-
"type": 0,
|
|
392
|
-
"value": "Font"
|
|
393
|
-
}]
|
|
305
|
+
defaultMessage: "Font"
|
|
394
306
|
}),
|
|
395
307
|
value: 'font'
|
|
396
308
|
}],
|
|
@@ -401,10 +313,7 @@ function filters() {
|
|
|
401
313
|
name: 'authors',
|
|
402
314
|
placeholder: /*#__PURE__*/jsx(FormattedMessage, {
|
|
403
315
|
id: "7oXkoj",
|
|
404
|
-
defaultMessage:
|
|
405
|
-
"type": 0,
|
|
406
|
-
"value": "Authors"
|
|
407
|
-
}]
|
|
316
|
+
defaultMessage: "Authors"
|
|
408
317
|
}),
|
|
409
318
|
requestUrl: route('medias.authors') || '/medias/authors',
|
|
410
319
|
itemLabelPath: 'name',
|
|
@@ -417,10 +326,7 @@ function filters() {
|
|
|
417
326
|
name: 'tags',
|
|
418
327
|
placeholder: /*#__PURE__*/jsx(FormattedMessage, {
|
|
419
328
|
id: "9mXl24",
|
|
420
|
-
defaultMessage:
|
|
421
|
-
"type": 0,
|
|
422
|
-
"value": "Tags"
|
|
423
|
-
}]
|
|
329
|
+
defaultMessage: "Tags"
|
|
424
330
|
}),
|
|
425
331
|
requestUrl: route('medias.tags') || '/medias/tags',
|
|
426
332
|
itemLabelPath: 'name',
|
|
@@ -434,10 +340,7 @@ function filters() {
|
|
|
434
340
|
options: [{
|
|
435
341
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
436
342
|
id: "bCtuS/",
|
|
437
|
-
defaultMessage:
|
|
438
|
-
"type": 0,
|
|
439
|
-
"value": "In this Micromag"
|
|
440
|
-
}]
|
|
343
|
+
defaultMessage: "In this Micromag"
|
|
441
344
|
}),
|
|
442
345
|
value: 'document-'
|
|
443
346
|
}]
|
|
@@ -446,157 +349,95 @@ function filters() {
|
|
|
446
349
|
|
|
447
350
|
var styles = {"container":"micromag-media-gallery-new-media-gallery-container","browser":"micromag-media-gallery-new-media-gallery-browser"};
|
|
448
351
|
|
|
449
|
-
function MediaGallery(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
var mediasApi = useMemo(function () {
|
|
483
|
-
return {
|
|
484
|
-
get: function get() {
|
|
485
|
-
var _api$medias;
|
|
486
|
-
return (_api$medias = api.medias).get.apply(_api$medias, arguments);
|
|
487
|
-
},
|
|
488
|
-
getTrashed: function getTrashed() {
|
|
489
|
-
var _api$medias2;
|
|
490
|
-
return (_api$medias2 = api.medias).getTrashed.apply(_api$medias2, arguments);
|
|
491
|
-
},
|
|
492
|
-
find: function find() {
|
|
493
|
-
var _api$medias3;
|
|
494
|
-
return (_api$medias3 = api.medias).find.apply(_api$medias3, arguments);
|
|
495
|
-
},
|
|
496
|
-
create: function create() {
|
|
497
|
-
var _api$medias4;
|
|
498
|
-
return (_api$medias4 = api.medias).create.apply(_api$medias4, arguments);
|
|
499
|
-
},
|
|
500
|
-
update: function update() {
|
|
501
|
-
var _api$medias5;
|
|
502
|
-
return (_api$medias5 = api.medias).update.apply(_api$medias5, arguments);
|
|
503
|
-
},
|
|
504
|
-
replace: function replace() {
|
|
505
|
-
var _api$medias6;
|
|
506
|
-
return (_api$medias6 = api.medias).replace.apply(_api$medias6, arguments);
|
|
507
|
-
},
|
|
508
|
-
"delete": function _delete() {
|
|
509
|
-
var _api$medias7, _api$medias8;
|
|
510
|
-
return typeof api.medias.forceDelete !== 'undefined' ? (_api$medias7 = api.medias).forceDelete.apply(_api$medias7, arguments) : (_api$medias8 = api.medias)["delete"].apply(_api$medias8, arguments);
|
|
511
|
-
},
|
|
512
|
-
// TODO: Temporary compat... see how this works
|
|
513
|
-
trash: function trash() {
|
|
514
|
-
var _api$medias9;
|
|
515
|
-
return (_api$medias9 = api.medias)["delete"].apply(_api$medias9, arguments);
|
|
516
|
-
},
|
|
517
|
-
restore: function restore() {
|
|
518
|
-
var _api$medias0;
|
|
519
|
-
return (_api$medias0 = api.medias).restore.apply(_api$medias0, arguments);
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
}, [api]);
|
|
352
|
+
function MediaGallery({
|
|
353
|
+
value = null,
|
|
354
|
+
types = null,
|
|
355
|
+
source = 'all',
|
|
356
|
+
filters: filters$1 = null,
|
|
357
|
+
fields: providedFields = null,
|
|
358
|
+
columns = defaultColumns,
|
|
359
|
+
isPicker = false,
|
|
360
|
+
multiple = false,
|
|
361
|
+
medias: initialMedias = null,
|
|
362
|
+
onChange = null,
|
|
363
|
+
onMediaFormOpen = null,
|
|
364
|
+
onMediaFormClose = null,
|
|
365
|
+
className = null
|
|
366
|
+
}) {
|
|
367
|
+
const api = useApi();
|
|
368
|
+
const story = useStory();
|
|
369
|
+
const {
|
|
370
|
+
id: storyId = null
|
|
371
|
+
} = story || {};
|
|
372
|
+
const fields$1 = providedFields === null ? fields() : providedFields;
|
|
373
|
+
const mediasApi = useMemo(() => ({
|
|
374
|
+
get: (...args) => api.medias.get(...args),
|
|
375
|
+
getTrashed: (...args_0) => api.medias.getTrashed(...args_0),
|
|
376
|
+
find: (...args_1) => api.medias.find(...args_1),
|
|
377
|
+
create: (...args_2) => api.medias.create(...args_2),
|
|
378
|
+
update: (...args_3) => api.medias.update(...args_3),
|
|
379
|
+
replace: (...args_4) => api.medias.replace(...args_4),
|
|
380
|
+
delete: (...args_5) => typeof api.medias.forceDelete !== 'undefined' ? api.medias.forceDelete(...args_5) : api.medias.delete(...args_5),
|
|
381
|
+
// TODO: Temporary compat... see how this works
|
|
382
|
+
trash: (...args_6) => api.medias.delete(...args_6),
|
|
383
|
+
restore: (...args_7) => api.medias.restore(...args_7)
|
|
384
|
+
}), [api]);
|
|
523
385
|
|
|
524
386
|
// Upload
|
|
525
|
-
|
|
526
|
-
createMedia
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}, [createMedia]);
|
|
532
|
-
var fileTypes = useMemo(function () {
|
|
533
|
-
var finalTypes = [];
|
|
387
|
+
const {
|
|
388
|
+
create: createMedia
|
|
389
|
+
} = useMediaCreate();
|
|
390
|
+
const onMediaUploaded = useCallback(newMedias => Promise.all(newMedias.map(createMedia)).then(newAddedMedias => newAddedMedias), [createMedia]);
|
|
391
|
+
const fileTypes = useMemo(() => {
|
|
392
|
+
let finalTypes = [];
|
|
534
393
|
if (isArray(types)) {
|
|
535
|
-
finalTypes = types.map(
|
|
536
|
-
return ['image', 'video', 'audio'].indexOf(t) !== -1 ? "".concat(t, "/*") : null;
|
|
537
|
-
}).filter(function (t) {
|
|
538
|
-
return t !== null;
|
|
539
|
-
});
|
|
394
|
+
finalTypes = types.map(t => ['image', 'video', 'audio'].indexOf(t) !== -1 ? `${t}/*` : null).filter(t_0 => t_0 !== null);
|
|
540
395
|
}
|
|
541
|
-
finalTypes = ['image', 'video', 'audio'].indexOf(types) !== -1 ? [
|
|
396
|
+
finalTypes = ['image', 'video', 'audio'].indexOf(types) !== -1 ? [`${types}/*`] : null;
|
|
542
397
|
if (finalTypes !== null && isArray(finalTypes) && finalTypes.indexOf('video/*') !== -1) {
|
|
543
398
|
finalTypes.push('image/gif');
|
|
544
399
|
}
|
|
545
400
|
return finalTypes;
|
|
546
401
|
}, [types]);
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}, [fileTypes]);
|
|
553
|
-
var finalTypes = useMemo(function () {
|
|
554
|
-
return !isArray(types) && types !== null ? [types] : types;
|
|
555
|
-
}, [types]);
|
|
402
|
+
const uppyConfig = useMemo(() => ({
|
|
403
|
+
// set sources ? - uppy sources -
|
|
404
|
+
allowedFileTypes: fileTypes !== null && fileTypes.length > 0 ? fileTypes : null
|
|
405
|
+
}), [fileTypes]);
|
|
406
|
+
const finalTypes_0 = useMemo(() => !isArray(types) && types !== null ? [types] : types, [types]);
|
|
556
407
|
|
|
557
408
|
// Filters
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
if (storyId === null) {
|
|
571
|
-
return null;
|
|
572
|
-
}
|
|
573
|
-
return _objectSpread(_objectSpread({}, filter), {}, {
|
|
574
|
-
options: (options || []).map(function () {
|
|
575
|
-
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
576
|
-
_ref4$value = _ref4.value,
|
|
577
|
-
optionValue = _ref4$value === void 0 ? null : _ref4$value,
|
|
578
|
-
_ref4$label = _ref4.label,
|
|
579
|
-
label = _ref4$label === void 0 ? null : _ref4$label;
|
|
580
|
-
return optionValue === 'document-' ? {
|
|
581
|
-
value: "document-".concat(storyId),
|
|
582
|
-
label: label
|
|
583
|
-
} : {
|
|
584
|
-
value: optionValue,
|
|
585
|
-
label: label
|
|
586
|
-
};
|
|
587
|
-
})
|
|
588
|
-
});
|
|
409
|
+
const partialFilters = filters$1 || filters() || [];
|
|
410
|
+
const finalFilters = useMemo(() => partialFilters.map(filter => {
|
|
411
|
+
const {
|
|
412
|
+
id = null,
|
|
413
|
+
options = []
|
|
414
|
+
} = filter || {};
|
|
415
|
+
if (id === 'types' && finalTypes_0 !== null) {
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
if (id === 'source') {
|
|
419
|
+
if (storyId === null) {
|
|
420
|
+
return null;
|
|
589
421
|
}
|
|
590
|
-
return
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
422
|
+
return {
|
|
423
|
+
...filter,
|
|
424
|
+
options: (options || []).map(({
|
|
425
|
+
value: optionValue = null,
|
|
426
|
+
label = null
|
|
427
|
+
} = {}) => optionValue === 'document-' ? {
|
|
428
|
+
value: `document-${storyId}`,
|
|
429
|
+
label
|
|
430
|
+
} : {
|
|
431
|
+
value: optionValue,
|
|
432
|
+
label
|
|
433
|
+
})
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
return filter;
|
|
437
|
+
}).filter(f => f !== null), [partialFilters, storyId]);
|
|
438
|
+
const finalQuery = useMemo(() => source !== null ? {
|
|
439
|
+
source
|
|
440
|
+
} : null, [source]);
|
|
600
441
|
return /*#__PURE__*/jsx("div", {
|
|
601
442
|
className: classNames([styles.container, className]),
|
|
602
443
|
children: isPicker ? /*#__PURE__*/jsx(MediasPickerContainer, {
|
|
@@ -604,7 +445,7 @@ function MediaGallery(_ref) {
|
|
|
604
445
|
api: mediasApi,
|
|
605
446
|
value: value,
|
|
606
447
|
theme: "dark",
|
|
607
|
-
types:
|
|
448
|
+
types: finalTypes_0,
|
|
608
449
|
query: finalQuery,
|
|
609
450
|
items: initialMedias,
|
|
610
451
|
filters: finalFilters,
|
|
@@ -623,7 +464,7 @@ function MediaGallery(_ref) {
|
|
|
623
464
|
api: mediasApi,
|
|
624
465
|
value: value,
|
|
625
466
|
theme: "dark",
|
|
626
|
-
types:
|
|
467
|
+
types: finalTypes_0,
|
|
627
468
|
query: finalQuery,
|
|
628
469
|
items: initialMedias,
|
|
629
470
|
filters: finalFilters,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/media-gallery",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.74",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -32,9 +32,11 @@
|
|
|
32
32
|
"license": "ISC",
|
|
33
33
|
"type": "module",
|
|
34
34
|
"module": "es/index.js",
|
|
35
|
+
"style": "./assets/css/styles.css",
|
|
35
36
|
"exports": {
|
|
36
37
|
".": {
|
|
37
38
|
"types": "./es/index.d.ts",
|
|
39
|
+
"style": "./assets/css/styles.css",
|
|
38
40
|
"import": "./es/index.js"
|
|
39
41
|
},
|
|
40
42
|
"./assets/css/styles": "./assets/css/styles.css",
|
|
@@ -51,27 +53,22 @@
|
|
|
51
53
|
"build": "../../scripts/prepare-package.sh --types"
|
|
52
54
|
},
|
|
53
55
|
"devDependencies": {
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"@panneau/fields": "^4.0.28",
|
|
57
|
-
"@panneau/filters": "^4.0.27",
|
|
58
|
-
"@panneau/uppy": "^4.0.27",
|
|
59
|
-
"react": "^18.3.0 || ^19.0.0",
|
|
60
|
-
"react-dom": "^18.3.0 || ^19.0.0"
|
|
56
|
+
"react": "^19.0.0",
|
|
57
|
+
"react-dom": "^19.0.0"
|
|
61
58
|
},
|
|
62
59
|
"peerDependencies": {
|
|
63
|
-
"react": "^
|
|
64
|
-
"react-dom": "^
|
|
60
|
+
"react": "^19.0.0",
|
|
61
|
+
"react-dom": "^19.0.0"
|
|
65
62
|
},
|
|
66
63
|
"dependencies": {
|
|
67
64
|
"@babel/runtime": "^7.28.6",
|
|
68
|
-
"@folklore/routes": "^0.
|
|
65
|
+
"@folklore/routes": "^0.4.4",
|
|
69
66
|
"@fortawesome/fontawesome-svg-core": "^7.2.0",
|
|
70
67
|
"@fortawesome/free-solid-svg-icons": "^7.2.0",
|
|
71
68
|
"@fortawesome/react-fontawesome": "^3.2.0",
|
|
72
|
-
"@micromag/core": "^0.4.
|
|
73
|
-
"@micromag/data": "^0.4.
|
|
74
|
-
"@panneau/medias": "^4.0.
|
|
69
|
+
"@micromag/core": "^0.4.74",
|
|
70
|
+
"@micromag/data": "^0.4.74",
|
|
71
|
+
"@panneau/medias": "^4.0.40-alpha.1",
|
|
75
72
|
"bootstrap": "^5.3.8",
|
|
76
73
|
"classnames": "^2.2.6",
|
|
77
74
|
"lodash": "^4.17.23",
|
|
@@ -83,6 +80,6 @@
|
|
|
83
80
|
"access": "public",
|
|
84
81
|
"registry": "https://registry.npmjs.org/"
|
|
85
82
|
},
|
|
86
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "fe510ee87845280d0760cb292aef9d2eb69e67c1",
|
|
87
84
|
"types": "es/index.d.ts"
|
|
88
85
|
}
|