@panneau/field-upload 4.0.1 → 4.0.3
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 +187 -167
- package/package.json +9 -9
package/es/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import DashboardModal from '@uppy/react/dashboard-modal';
|
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import isArray from 'lodash-es/isArray';
|
|
10
10
|
import isObject from 'lodash-es/isObject';
|
|
11
|
-
import
|
|
11
|
+
import { useCallback, useMemo, useState, useRef, useEffect } from 'react';
|
|
12
12
|
import { FormattedMessage } from 'react-intl';
|
|
13
13
|
import { useQuery } from '@panneau/core/hooks';
|
|
14
14
|
import Button from '@panneau/element-button';
|
|
@@ -18,12 +18,11 @@ import ModalResourceItems from '@panneau/modal-resource-items';
|
|
|
18
18
|
import { useUppy } from '@panneau/uppy';
|
|
19
19
|
import '@uppy/core/css/style.css';
|
|
20
20
|
import '@uppy/dashboard/css/style.css';
|
|
21
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
21
22
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
22
23
|
|
|
23
24
|
var styles = {"container":"panneau-field-upload-container","dashboard":"panneau-field-upload-dashboard","dashboardModal":"panneau-field-upload-dashboardModal"};
|
|
24
25
|
|
|
25
|
-
// import '@uppy/react/css/style.css';
|
|
26
|
-
|
|
27
26
|
var DEFAULT_TYPES = ['audio', 'image', 'video'];
|
|
28
27
|
var DEFAULT_SOURCES = ['webcam', 'facebook', 'instagram', 'dropbox', 'google-drive'];
|
|
29
28
|
function UploadField(_ref) {
|
|
@@ -91,21 +90,21 @@ function UploadField(_ref) {
|
|
|
91
90
|
onClickFind = _ref$onClickFind === void 0 ? null : _ref$onClickFind,
|
|
92
91
|
_ref$className = _ref.className,
|
|
93
92
|
className = _ref$className === void 0 ? null : _ref$className;
|
|
94
|
-
var addButtonLabel = initialAddButtonLabel || /*#__PURE__*/
|
|
93
|
+
var addButtonLabel = initialAddButtonLabel || /*#__PURE__*/jsx(FormattedMessage, {
|
|
95
94
|
id: "BeKVq6",
|
|
96
95
|
defaultMessage: [{
|
|
97
96
|
"type": 0,
|
|
98
97
|
"value": "Upload file"
|
|
99
98
|
}]
|
|
100
99
|
});
|
|
101
|
-
var findButtonLabel = initialFindButtonLabel || /*#__PURE__*/
|
|
100
|
+
var findButtonLabel = initialFindButtonLabel || /*#__PURE__*/jsx(FormattedMessage, {
|
|
102
101
|
id: "une5WQ",
|
|
103
102
|
defaultMessage: [{
|
|
104
103
|
"type": 0,
|
|
105
104
|
"value": "Find a file"
|
|
106
105
|
}]
|
|
107
106
|
});
|
|
108
|
-
var clearButtonLabel = initialCleanButtonLabel || /*#__PURE__*/
|
|
107
|
+
var clearButtonLabel = initialCleanButtonLabel || /*#__PURE__*/jsx(FormattedMessage, {
|
|
109
108
|
id: "odaCUe",
|
|
110
109
|
defaultMessage: [{
|
|
111
110
|
"type": 0,
|
|
@@ -328,132 +327,155 @@ function UploadField(_ref) {
|
|
|
328
327
|
};
|
|
329
328
|
}, [uppy, startLoading, endLoading]);
|
|
330
329
|
var finalLoading = loading || parentLoading;
|
|
331
|
-
return /*#__PURE__*/
|
|
330
|
+
return /*#__PURE__*/jsxs("div", {
|
|
332
331
|
className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
|
|
333
|
-
ref: containerRef
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
332
|
+
ref: containerRef,
|
|
333
|
+
children: [!withoutMedia && hasMedia ? /*#__PURE__*/jsx(MediaCards, {
|
|
334
|
+
value: values,
|
|
335
|
+
namePath: namePath,
|
|
336
|
+
thumbnailPath: thumbnailPath,
|
|
337
|
+
sizePath: sizePath,
|
|
338
|
+
linkPath: linkPath,
|
|
339
|
+
disabled: disabled,
|
|
340
|
+
onClickRemove: onClickRemove
|
|
341
|
+
}) : null, !withoutMedia && hasMedia && withClearButton ? /*#__PURE__*/jsx("div", {
|
|
342
|
+
className: "row mt-2",
|
|
343
|
+
children: /*#__PURE__*/jsx("div", {
|
|
344
|
+
className: "col-auto",
|
|
345
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
346
|
+
type: "button",
|
|
347
|
+
theme: "primary",
|
|
348
|
+
onClick: onClickClear,
|
|
349
|
+
children: /*#__PURE__*/jsx(Label, {
|
|
350
|
+
children: clearButtonLabel
|
|
351
|
+
})
|
|
352
|
+
})
|
|
353
|
+
})
|
|
354
|
+
}) : null, withoutMedia || (!hasMedia || allowMultipleUploads) && withButton ? /*#__PURE__*/jsxs("div", {
|
|
355
|
+
className: "row",
|
|
356
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
357
|
+
className: "col-auto",
|
|
358
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
359
|
+
id: "trigger-uppy",
|
|
360
|
+
type: "button",
|
|
361
|
+
theme: "primary",
|
|
362
|
+
icon: finalLoading ? 'loading' : 'upload',
|
|
363
|
+
iconPosition: "right",
|
|
364
|
+
onClick: onClickAdd || openModal,
|
|
365
|
+
disabled: finalLoading || disabled,
|
|
366
|
+
outline: outline,
|
|
367
|
+
children: /*#__PURE__*/jsx(Label, {
|
|
368
|
+
children: finalLoading ? /*#__PURE__*/jsx(FormattedMessage, {
|
|
369
|
+
id: "NozDYd",
|
|
370
|
+
defaultMessage: [{
|
|
371
|
+
"type": 0,
|
|
372
|
+
"value": "Uploading"
|
|
373
|
+
}]
|
|
374
|
+
}) : addButtonLabel
|
|
375
|
+
})
|
|
376
|
+
})
|
|
377
|
+
}), withFind ? /*#__PURE__*/jsx("div", {
|
|
378
|
+
className: "col-auto ps-0",
|
|
379
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
380
|
+
type: "button",
|
|
381
|
+
theme: "primary",
|
|
382
|
+
icon: "search",
|
|
383
|
+
iconPosition: "right",
|
|
384
|
+
onClick: finalOnClickFind,
|
|
385
|
+
disabled: disabled,
|
|
386
|
+
outline: outline,
|
|
387
|
+
children: /*#__PURE__*/jsx(Label, {
|
|
388
|
+
children: findButtonLabel
|
|
389
|
+
})
|
|
390
|
+
})
|
|
391
|
+
}) : null]
|
|
392
|
+
}) : null, finalUppy !== null ? /*#__PURE__*/jsxs(UppyContextProvider, {
|
|
393
|
+
uppy: finalUppy,
|
|
394
|
+
children: [!uploadDisabled && !hasMedia && !withButton && finalUppy !== null ? /*#__PURE__*/jsx("div", {
|
|
395
|
+
className: styles.dashboard,
|
|
396
|
+
children: /*#__PURE__*/jsx(Dashboard, _objectSpread(_objectSpread(_objectSpread({
|
|
397
|
+
uppy: finalUppy
|
|
398
|
+
// {...(containerWidth !== null && height !== null
|
|
399
|
+
// ? { width: containerWidth }
|
|
400
|
+
// : null)}
|
|
401
|
+
}, width !== null ? {
|
|
402
|
+
width: width
|
|
403
|
+
} : null), height !== null ? {
|
|
404
|
+
height: height
|
|
405
|
+
} : null), {}, {
|
|
406
|
+
plugins: sources,
|
|
407
|
+
inline: true,
|
|
408
|
+
showProgressDetails: true,
|
|
409
|
+
areInsidesReadyToBeVisible: true,
|
|
410
|
+
proudlyDisplayPoweredByUppy: false
|
|
411
|
+
}))
|
|
412
|
+
}) : null, !showResourceModal && !uploadDisabled && withButton && finalUppy !== null && modalOpened ? /*#__PURE__*/jsx(DashboardModal, {
|
|
413
|
+
uppy: finalUppy,
|
|
414
|
+
className: styles.dashboardModal,
|
|
415
|
+
plugins: sources,
|
|
416
|
+
open: true,
|
|
417
|
+
onRequestClose: closeModal,
|
|
418
|
+
proudlyDisplayPoweredByUppy: false,
|
|
419
|
+
closeModalOnClickOutside: true,
|
|
420
|
+
areInsidesReadyToBeVisible: true,
|
|
421
|
+
isDashboardVisible: true,
|
|
422
|
+
showProgressDetails: true,
|
|
423
|
+
showAddFilesPanel: true,
|
|
424
|
+
doneButtonHandler: closeModal,
|
|
425
|
+
closeAfterFinish: closeAfterFinish
|
|
426
|
+
}) : null]
|
|
427
|
+
}) : null, showResourceModal ? /*#__PURE__*/jsx(ModalResourceItems, {
|
|
428
|
+
id: "upload-".concat(name),
|
|
429
|
+
resource: resource,
|
|
430
|
+
query: listQuery,
|
|
431
|
+
onPageChange: onListPageChange,
|
|
432
|
+
onQueryChange: onListQueryChange,
|
|
433
|
+
onQueryReset: onListQueryReset,
|
|
434
|
+
baseUrl: null,
|
|
435
|
+
showActions: false,
|
|
436
|
+
selectable: true,
|
|
437
|
+
selectedItems: modalItems,
|
|
438
|
+
onSelectionChange: onSelectionChange,
|
|
439
|
+
multipleSelection: allowMultipleUploads,
|
|
440
|
+
onClose: closeResourceModal,
|
|
441
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
442
|
+
className: "d-flex mt-4 justify-content-between",
|
|
443
|
+
children: [modalItems !== null && modalItems.length > 0 ? /*#__PURE__*/jsxs("span", {
|
|
444
|
+
className: "me-2",
|
|
445
|
+
children: [modalItems.length, " items"]
|
|
446
|
+
}) : /*#__PURE__*/jsx("span", {}), /*#__PURE__*/jsxs("div", {
|
|
447
|
+
className: "d-flex",
|
|
448
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
449
|
+
type: "button",
|
|
450
|
+
theme: "secondary",
|
|
451
|
+
onClick: closeResourceModal,
|
|
452
|
+
disabled: disabled,
|
|
453
|
+
className: "d-block me-2",
|
|
454
|
+
children: /*#__PURE__*/jsx(FormattedMessage, {
|
|
455
|
+
id: "PyxZY2",
|
|
456
|
+
defaultMessage: [{
|
|
457
|
+
"type": 0,
|
|
458
|
+
"value": "Cancel"
|
|
459
|
+
}]
|
|
460
|
+
})
|
|
461
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
462
|
+
type: "button",
|
|
463
|
+
theme: "primary",
|
|
464
|
+
onClick: confirmResourceModal,
|
|
465
|
+
disabled: disabled || modalItems !== null && modalItems.length === 0,
|
|
466
|
+
className: "d-block",
|
|
467
|
+
children: /*#__PURE__*/jsx(FormattedMessage, {
|
|
468
|
+
id: "rvOVCV",
|
|
469
|
+
defaultMessage: [{
|
|
470
|
+
"type": 0,
|
|
471
|
+
"value": "Confirm selection"
|
|
472
|
+
}]
|
|
473
|
+
})
|
|
474
|
+
})]
|
|
475
|
+
})]
|
|
476
|
+
})
|
|
477
|
+
}) : null]
|
|
478
|
+
});
|
|
457
479
|
}
|
|
458
480
|
|
|
459
481
|
var definition = [{
|
|
@@ -476,48 +498,43 @@ var definition = [{
|
|
|
476
498
|
component: 'Font'
|
|
477
499
|
}];
|
|
478
500
|
|
|
479
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
480
501
|
function AudioField(props) {
|
|
481
502
|
var types = useMemo(function () {
|
|
482
503
|
return ['audio'];
|
|
483
504
|
}, []);
|
|
484
|
-
return /*#__PURE__*/
|
|
505
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
485
506
|
types: types
|
|
486
507
|
}));
|
|
487
508
|
}
|
|
488
509
|
|
|
489
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
490
510
|
function ImageField(props) {
|
|
491
511
|
var types = useMemo(function () {
|
|
492
512
|
return ['image'];
|
|
493
513
|
}, []);
|
|
494
|
-
return /*#__PURE__*/
|
|
514
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
495
515
|
types: types
|
|
496
516
|
}));
|
|
497
517
|
}
|
|
498
518
|
|
|
499
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
500
519
|
function ImagesField(props) {
|
|
501
520
|
var types = useMemo(function () {
|
|
502
521
|
return ['image'];
|
|
503
522
|
}, []);
|
|
504
|
-
return /*#__PURE__*/
|
|
523
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
505
524
|
types: types,
|
|
506
525
|
allowMultipleUploads: true
|
|
507
526
|
}));
|
|
508
527
|
}
|
|
509
528
|
|
|
510
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
511
529
|
function VideoField(props) {
|
|
512
530
|
var types = useMemo(function () {
|
|
513
531
|
return ['video'];
|
|
514
532
|
}, []);
|
|
515
|
-
return /*#__PURE__*/
|
|
533
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
516
534
|
types: types
|
|
517
535
|
}));
|
|
518
536
|
}
|
|
519
537
|
|
|
520
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
521
538
|
function DocumentField(props) {
|
|
522
539
|
var fileTypes = useMemo(function () {
|
|
523
540
|
return ['.pdf'];
|
|
@@ -525,18 +542,17 @@ function DocumentField(props) {
|
|
|
525
542
|
var types = useMemo(function () {
|
|
526
543
|
return ['document'];
|
|
527
544
|
}, []);
|
|
528
|
-
return /*#__PURE__*/
|
|
545
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
529
546
|
fileTypes: fileTypes,
|
|
530
547
|
types: types
|
|
531
548
|
}));
|
|
532
549
|
}
|
|
533
550
|
|
|
534
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
535
551
|
function FontField(props) {
|
|
536
552
|
var fileTypes = useMemo(function () {
|
|
537
553
|
return ['.ttf', '.otf'];
|
|
538
554
|
}, []);
|
|
539
|
-
return /*#__PURE__*/
|
|
555
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
540
556
|
fileTypes: fileTypes
|
|
541
557
|
}));
|
|
542
558
|
}
|
|
@@ -597,30 +613,34 @@ function UpdateFileField(_ref) {
|
|
|
597
613
|
}
|
|
598
614
|
return null;
|
|
599
615
|
}, [type]);
|
|
600
|
-
return /*#__PURE__*/
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
616
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
617
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
618
|
+
className: "mb-3",
|
|
619
|
+
children: /*#__PURE__*/jsx(MediaCard, {
|
|
620
|
+
value: visibleFile || value,
|
|
621
|
+
withoutDescription: true
|
|
622
|
+
})
|
|
623
|
+
}), /*#__PURE__*/jsx("div", {
|
|
624
|
+
className: "mb-3",
|
|
625
|
+
children: /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread(_objectSpread({}, props), uploadProps), {}, {
|
|
626
|
+
addButtonLabel: /*#__PURE__*/jsx(FormattedMessage, {
|
|
627
|
+
id: "daHjZg",
|
|
628
|
+
defaultMessage: [{
|
|
629
|
+
"type": 0,
|
|
630
|
+
"value": "Edit file"
|
|
631
|
+
}]
|
|
632
|
+
}),
|
|
633
|
+
allowMultipleUploads: false,
|
|
634
|
+
linkPath: "panneauUrl",
|
|
635
|
+
onChange: onUploadChange,
|
|
636
|
+
onClose: onUploadChange,
|
|
637
|
+
maxNumberOfFiles: 1,
|
|
638
|
+
value: newValue,
|
|
639
|
+
withButton: true,
|
|
640
|
+
uppyProps: uppyProps
|
|
641
|
+
}))
|
|
642
|
+
})]
|
|
643
|
+
});
|
|
624
644
|
}
|
|
625
645
|
|
|
626
646
|
export { AudioField, DocumentField, FontField, ImageField, ImagesField, UpdateFileField, VideoField, UploadField as default, definition };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/field-upload",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "An Upload field",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
|
63
63
|
"@fortawesome/free-solid-svg-icons": "^6.5.1",
|
|
64
64
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
65
|
-
"@panneau/core": "^4.0.
|
|
66
|
-
"@panneau/element-button": "^4.0.
|
|
67
|
-
"@panneau/element-label": "^4.0.
|
|
68
|
-
"@panneau/element-media-card": "^4.0.
|
|
69
|
-
"@panneau/modal-resource-items": "^4.0.
|
|
70
|
-
"@panneau/themes": "^4.0.
|
|
71
|
-
"@panneau/uppy": "^4.0.
|
|
65
|
+
"@panneau/core": "^4.0.2",
|
|
66
|
+
"@panneau/element-button": "^4.0.2",
|
|
67
|
+
"@panneau/element-label": "^4.0.2",
|
|
68
|
+
"@panneau/element-media-card": "^4.0.2",
|
|
69
|
+
"@panneau/modal-resource-items": "^4.0.3",
|
|
70
|
+
"@panneau/themes": "^4.0.2",
|
|
71
|
+
"@panneau/uppy": "^4.0.2",
|
|
72
72
|
"@uppy/core": "^5.1.1",
|
|
73
73
|
"@uppy/dashboard": "^5.0.4",
|
|
74
74
|
"@uppy/react": "^5.1.1",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "26b5ab7536b0e8c3197d40d302fc2681e7c7122e"
|
|
86
86
|
}
|