@panneau/field-upload 4.0.2 → 4.0.4
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 +186 -160
- package/package.json +9 -9
package/es/index.js
CHANGED
|
@@ -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 = [{
|
|
@@ -480,7 +502,7 @@ function AudioField(props) {
|
|
|
480
502
|
var types = useMemo(function () {
|
|
481
503
|
return ['audio'];
|
|
482
504
|
}, []);
|
|
483
|
-
return /*#__PURE__*/
|
|
505
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
484
506
|
types: types
|
|
485
507
|
}));
|
|
486
508
|
}
|
|
@@ -489,7 +511,7 @@ function ImageField(props) {
|
|
|
489
511
|
var types = useMemo(function () {
|
|
490
512
|
return ['image'];
|
|
491
513
|
}, []);
|
|
492
|
-
return /*#__PURE__*/
|
|
514
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
493
515
|
types: types
|
|
494
516
|
}));
|
|
495
517
|
}
|
|
@@ -498,7 +520,7 @@ function ImagesField(props) {
|
|
|
498
520
|
var types = useMemo(function () {
|
|
499
521
|
return ['image'];
|
|
500
522
|
}, []);
|
|
501
|
-
return /*#__PURE__*/
|
|
523
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
502
524
|
types: types,
|
|
503
525
|
allowMultipleUploads: true
|
|
504
526
|
}));
|
|
@@ -508,7 +530,7 @@ function VideoField(props) {
|
|
|
508
530
|
var types = useMemo(function () {
|
|
509
531
|
return ['video'];
|
|
510
532
|
}, []);
|
|
511
|
-
return /*#__PURE__*/
|
|
533
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
512
534
|
types: types
|
|
513
535
|
}));
|
|
514
536
|
}
|
|
@@ -520,7 +542,7 @@ function DocumentField(props) {
|
|
|
520
542
|
var types = useMemo(function () {
|
|
521
543
|
return ['document'];
|
|
522
544
|
}, []);
|
|
523
|
-
return /*#__PURE__*/
|
|
545
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
524
546
|
fileTypes: fileTypes,
|
|
525
547
|
types: types
|
|
526
548
|
}));
|
|
@@ -530,7 +552,7 @@ function FontField(props) {
|
|
|
530
552
|
var fileTypes = useMemo(function () {
|
|
531
553
|
return ['.ttf', '.otf'];
|
|
532
554
|
}, []);
|
|
533
|
-
return /*#__PURE__*/
|
|
555
|
+
return /*#__PURE__*/jsx(UploadField, _objectSpread(_objectSpread({}, props), {}, {
|
|
534
556
|
fileTypes: fileTypes
|
|
535
557
|
}));
|
|
536
558
|
}
|
|
@@ -591,30 +613,34 @@ function UpdateFileField(_ref) {
|
|
|
591
613
|
}
|
|
592
614
|
return null;
|
|
593
615
|
}, [type]);
|
|
594
|
-
return /*#__PURE__*/
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
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
|
+
});
|
|
618
644
|
}
|
|
619
645
|
|
|
620
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.4",
|
|
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.4",
|
|
66
|
+
"@panneau/element-button": "^4.0.4",
|
|
67
|
+
"@panneau/element-label": "^4.0.4",
|
|
68
|
+
"@panneau/element-media-card": "^4.0.4",
|
|
69
|
+
"@panneau/modal-resource-items": "^4.0.4",
|
|
70
|
+
"@panneau/themes": "^4.0.4",
|
|
71
|
+
"@panneau/uppy": "^4.0.4",
|
|
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": "e854451a718c6bc7dcde2b804c9913d8ac0297ff"
|
|
86
86
|
}
|