@panneau/field-upload 3.0.107 → 3.0.108

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.
@@ -1 +1 @@
1
- .panneau-field-upload-container{width:100%}.panneau-field-upload-container .panneau-field-upload-dashboard{position:relative}
1
+ .panneau-field-upload-container{position:relative;width:100%}.panneau-field-upload-container .panneau-field-upload-dashboard{position:relative}.panneau-field-upload-container .panneau-field-upload-uppyDashboardContainer{margin-top:10px}
package/es/index.js CHANGED
@@ -7,7 +7,7 @@ import classNames from 'classnames';
7
7
  import isArray from 'lodash/isArray';
8
8
  import isObject from 'lodash/isObject';
9
9
  import PropTypes from 'prop-types';
10
- import React, { useCallback, useMemo, useState } from 'react';
10
+ import React, { useCallback, useMemo, useState, useRef } from 'react';
11
11
  import { FormattedMessage } from 'react-intl';
12
12
  import { PropTypes as PropTypes$1 } from '@panneau/core';
13
13
  import { useResourceQuery } from '@panneau/core/hooks';
@@ -16,13 +16,14 @@ import Label from '@panneau/element-label';
16
16
  import { MediaCards } from '@panneau/element-media-card';
17
17
  import ResourceItemsList from '@panneau/list-resource-items';
18
18
  import Dialog from '@panneau/modal-dialog';
19
+ import UploadModal from '@panneau/modal-upload';
19
20
  import { useUppy } from '@panneau/uppy';
20
- import '@uppy/core/dist/style.css';
21
- import '@uppy/dashboard/dist/style.css';
22
- import '@uppy/drag-drop/dist/style.css';
23
- import '@uppy/status-bar/dist/style.css';
21
+ import '@uppy/core/dist/style.min.css';
22
+ import '@uppy/dashboard/dist/style.min.css';
23
+ import '@uppy/drag-drop/dist/style.min.css';
24
+ import '@uppy/status-bar/dist/style.min.css';
24
25
 
25
- var styles = {"container":"panneau-field-upload-container","dashboard":"panneau-field-upload-dashboard"};
26
+ var styles = {"container":"panneau-field-upload-container","dashboard":"panneau-field-upload-dashboard","uppyDashboardContainer":"panneau-field-upload-uppyDashboardContainer"};
26
27
 
27
28
  var propTypes = {
28
29
  value: PropTypes.oneOfType([PropTypes.array, PropTypes.shape({
@@ -209,9 +210,9 @@ var UploadField = function UploadField(_ref) {
209
210
  modalOpened = _useState2[0],
210
211
  setModalOpened = _useState2[1];
211
212
  var openModal = useCallback(function () {
212
- setModalOpened(true);
213
- }, [setModalOpened]);
214
- var closeModal = useCallback(function () {
213
+ setModalOpened(!modalOpened);
214
+ }, [modalOpened, setModalOpened]);
215
+ useCallback(function () {
215
216
  setModalOpened(false);
216
217
  if (uppy !== null) {
217
218
  uppy.cancelAll({
@@ -311,15 +312,12 @@ var UploadField = function UploadField(_ref) {
311
312
  onListPageChange = _useResourceQuery.onPageChange,
312
313
  onListQueryChange = _useResourceQuery.onQueryChange,
313
314
  onListQueryReset = _useResourceQuery.onQueryReset;
314
-
315
- // console.log(
316
- // 'modalOpened',
317
- // !showResourceModal && !disabled && withButton && uppy !== null && modalOpened,
318
- // );
319
-
315
+ console.log('modalOpened', !showResourceModal && !disabled && withButton && uppy !== null && modalOpened);
316
+ console.log('uppy', uppy);
317
+ var containerRef = useRef(null);
320
318
  return /*#__PURE__*/React.createElement("div", {
321
- className: classNames([styles.container, _defineProperty({}, className, className !== null)])
322
- // ref={containerRef}
319
+ className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
320
+ ref: containerRef
323
321
  }, hasMedia ? /*#__PURE__*/React.createElement(MediaCards, {
324
322
  value: values,
325
323
  namePath: namePath,
@@ -341,6 +339,7 @@ var UploadField = function UploadField(_ref) {
341
339
  }, /*#__PURE__*/React.createElement("div", {
342
340
  className: "col-auto"
343
341
  }, /*#__PURE__*/React.createElement(Button, {
342
+ id: "trigger-uppy",
344
343
  type: "button",
345
344
  theme: "primary",
346
345
  onClick: openModal,
@@ -371,29 +370,18 @@ var UploadField = function UploadField(_ref) {
371
370
  showProgressDetails: true,
372
371
  areInsidesReadyToBeVisible: true,
373
372
  proudlyDisplayPoweredByUppy: false
374
- }))) : null, !showResourceModal && !disabled && withButton && uppy !== null && modalOpened ? /*#__PURE__*/React.createElement(Dialog, {
375
- size: "lg",
376
- onClose: closeModal,
377
- title: addButtonLabel
378
- }, /*#__PURE__*/React.createElement(Dashboard, Object.assign({
379
- uppy: uppy
380
- // {...(containerWidth !== null && height !== null
381
- // ? { width: containerWidth }
382
- // : null)}
383
- }, width !== null ? {
384
- width: width
385
- } : null, height !== null ? {
386
- height: height
387
- } : null, {
373
+ }))) : null, !showResourceModal && !disabled && withButton && uppy !== null && modalOpened ? /*#__PURE__*/React.createElement("div", {
374
+ className: styles.uppyDashboardContainer
375
+ }, /*#__PURE__*/React.createElement(UploadModal, {
376
+ title: addButtonLabel,
377
+ uppy: uppy,
388
378
  plugins: sources,
389
379
  inline: true,
380
+ width: "100%",
381
+ height: "300px",
390
382
  showProgressDetails: true,
391
- areInsidesReadyToBeVisible: true,
392
- isDashboardVisible: true,
393
- showAddFilesPanel: true,
394
- proudlyDisplayPoweredByUppy: false,
395
- doneButtonHandler: closeModal
396
- }))) : null, showResourceModal ? /*#__PURE__*/React.createElement(Dialog, {
383
+ proudlyDisplayPoweredByUppy: false
384
+ })) : null, showResourceModal ? /*#__PURE__*/React.createElement(Dialog, {
397
385
  title: /*#__PURE__*/React.createElement(Label, null, findButtonLabel),
398
386
  size: "xl",
399
387
  onClose: closeResourceModal
package/lib/index.js CHANGED
@@ -20,11 +20,12 @@ var Label = require('@panneau/element-label');
20
20
  var elementMediaCard = require('@panneau/element-media-card');
21
21
  var ResourceItemsList = require('@panneau/list-resource-items');
22
22
  var Dialog = require('@panneau/modal-dialog');
23
+ var UploadModal = require('@panneau/modal-upload');
23
24
  var uppy = require('@panneau/uppy');
24
- require('@uppy/core/dist/style.css');
25
- require('@uppy/dashboard/dist/style.css');
26
- require('@uppy/drag-drop/dist/style.css');
27
- require('@uppy/status-bar/dist/style.css');
25
+ require('@uppy/core/dist/style.min.css');
26
+ require('@uppy/dashboard/dist/style.min.css');
27
+ require('@uppy/drag-drop/dist/style.min.css');
28
+ require('@uppy/status-bar/dist/style.min.css');
28
29
 
29
30
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
30
31
 
@@ -41,8 +42,9 @@ var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
41
42
  var Label__default = /*#__PURE__*/_interopDefaultLegacy(Label);
42
43
  var ResourceItemsList__default = /*#__PURE__*/_interopDefaultLegacy(ResourceItemsList);
43
44
  var Dialog__default = /*#__PURE__*/_interopDefaultLegacy(Dialog);
45
+ var UploadModal__default = /*#__PURE__*/_interopDefaultLegacy(UploadModal);
44
46
 
45
- var styles = {"container":"panneau-field-upload-container","dashboard":"panneau-field-upload-dashboard"};
47
+ var styles = {"container":"panneau-field-upload-container","dashboard":"panneau-field-upload-dashboard","uppyDashboardContainer":"panneau-field-upload-uppyDashboardContainer"};
46
48
 
47
49
  var propTypes = {
48
50
  value: PropTypes__default["default"].oneOfType([PropTypes__default["default"].array, PropTypes__default["default"].shape({
@@ -229,9 +231,9 @@ var UploadField = function UploadField(_ref) {
229
231
  modalOpened = _useState2[0],
230
232
  setModalOpened = _useState2[1];
231
233
  var openModal = React.useCallback(function () {
232
- setModalOpened(true);
233
- }, [setModalOpened]);
234
- var closeModal = React.useCallback(function () {
234
+ setModalOpened(!modalOpened);
235
+ }, [modalOpened, setModalOpened]);
236
+ React.useCallback(function () {
235
237
  setModalOpened(false);
236
238
  if (uppy$1 !== null) {
237
239
  uppy$1.cancelAll({
@@ -331,15 +333,12 @@ var UploadField = function UploadField(_ref) {
331
333
  onListPageChange = _useResourceQuery.onPageChange,
332
334
  onListQueryChange = _useResourceQuery.onQueryChange,
333
335
  onListQueryReset = _useResourceQuery.onQueryReset;
334
-
335
- // console.log(
336
- // 'modalOpened',
337
- // !showResourceModal && !disabled && withButton && uppy !== null && modalOpened,
338
- // );
339
-
336
+ console.log('modalOpened', !showResourceModal && !disabled && withButton && uppy$1 !== null && modalOpened);
337
+ console.log('uppy', uppy$1);
338
+ var containerRef = React.useRef(null);
340
339
  return /*#__PURE__*/React__default["default"].createElement("div", {
341
- className: classNames__default["default"]([styles.container, _defineProperty__default["default"]({}, className, className !== null)])
342
- // ref={containerRef}
340
+ className: classNames__default["default"]([styles.container, _defineProperty__default["default"]({}, className, className !== null)]),
341
+ ref: containerRef
343
342
  }, hasMedia ? /*#__PURE__*/React__default["default"].createElement(elementMediaCard.MediaCards, {
344
343
  value: values,
345
344
  namePath: namePath,
@@ -361,6 +360,7 @@ var UploadField = function UploadField(_ref) {
361
360
  }, /*#__PURE__*/React__default["default"].createElement("div", {
362
361
  className: "col-auto"
363
362
  }, /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
363
+ id: "trigger-uppy",
364
364
  type: "button",
365
365
  theme: "primary",
366
366
  onClick: openModal,
@@ -391,29 +391,18 @@ var UploadField = function UploadField(_ref) {
391
391
  showProgressDetails: true,
392
392
  areInsidesReadyToBeVisible: true,
393
393
  proudlyDisplayPoweredByUppy: false
394
- }))) : null, !showResourceModal && !disabled && withButton && uppy$1 !== null && modalOpened ? /*#__PURE__*/React__default["default"].createElement(Dialog__default["default"], {
395
- size: "lg",
396
- onClose: closeModal,
397
- title: addButtonLabel
398
- }, /*#__PURE__*/React__default["default"].createElement(react.Dashboard, Object.assign({
399
- uppy: uppy$1
400
- // {...(containerWidth !== null && height !== null
401
- // ? { width: containerWidth }
402
- // : null)}
403
- }, width !== null ? {
404
- width: width
405
- } : null, height !== null ? {
406
- height: height
407
- } : null, {
394
+ }))) : null, !showResourceModal && !disabled && withButton && uppy$1 !== null && modalOpened ? /*#__PURE__*/React__default["default"].createElement("div", {
395
+ className: styles.uppyDashboardContainer
396
+ }, /*#__PURE__*/React__default["default"].createElement(UploadModal__default["default"], {
397
+ title: addButtonLabel,
398
+ uppy: uppy$1,
408
399
  plugins: sources,
409
400
  inline: true,
401
+ width: "100%",
402
+ height: "300px",
410
403
  showProgressDetails: true,
411
- areInsidesReadyToBeVisible: true,
412
- isDashboardVisible: true,
413
- showAddFilesPanel: true,
414
- proudlyDisplayPoweredByUppy: false,
415
- doneButtonHandler: closeModal
416
- }))) : null, showResourceModal ? /*#__PURE__*/React__default["default"].createElement(Dialog__default["default"], {
404
+ proudlyDisplayPoweredByUppy: false
405
+ })) : null, showResourceModal ? /*#__PURE__*/React__default["default"].createElement(Dialog__default["default"], {
417
406
  title: /*#__PURE__*/React__default["default"].createElement(Label__default["default"], null, findButtonLabel),
418
407
  size: "xl",
419
408
  onClose: closeResourceModal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/field-upload",
3
- "version": "3.0.107",
3
+ "version": "3.0.108",
4
4
  "description": "An Upload field",
5
5
  "keywords": [
6
6
  "javascript"
@@ -63,6 +63,7 @@
63
63
  "@panneau/element-media-card": "^3.0.101",
64
64
  "@panneau/list-resource-items": "^3.0.103",
65
65
  "@panneau/modal-dialog": "^3.0.101",
66
+ "@panneau/modal-upload": "^3.0.108",
66
67
  "@panneau/themes": "^3.0.101",
67
68
  "@panneau/uppy": "^3.0.105",
68
69
  "@uppy/core": "^3.9.1",
@@ -81,5 +82,5 @@
81
82
  "publishConfig": {
82
83
  "access": "public"
83
84
  },
84
- "gitHead": "84147f217be4806d5a6fb111cee39c0e6b0719cc"
85
+ "gitHead": "e0d3677666eee6729ca3c48d06ea8564e2078c86"
85
86
  }