@panneau/core 2.0.85 → 2.0.91

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/contexts.js CHANGED
@@ -16,6 +16,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
16
16
  import { generatePath, useNavigate } from 'react-router';
17
17
  import { TrackingContext, TrackingContainer } from '@folklore/tracking';
18
18
  export { TrackingContext } from '@folklore/tracking';
19
+ import slugify from 'slugify';
19
20
  import { v1 } from 'uuid';
20
21
  import EventEmitter from 'wolfy87-eventemitter';
21
22
 
@@ -388,6 +389,8 @@ var modal = PropTypes.shape({
388
389
  });
389
390
  PropTypes.arrayOf(modal);
390
391
 
392
+ //
393
+
391
394
  /* eslint-disable react/jsx-props-no-spreading */
392
395
  var DefinitionContext = /*#__PURE__*/React.createContext(null);
393
396
  var useDefinitionContext = function useDefinitionContext() {
@@ -1514,10 +1517,19 @@ var useUppy = function useUppy() {
1514
1517
  onFail = _ref$onFail === void 0 ? null : _ref$onFail,
1515
1518
  _ref$getFileName = _ref.getFileName,
1516
1519
  getFileName = _ref$getFileName === void 0 ? function (_ref2) {
1517
- var _ref2$extension = _ref2.extension,
1520
+ var filename = _ref2.filename,
1521
+ _ref2$extension = _ref2.extension,
1518
1522
  extension = _ref2$extension === void 0 ? null : _ref2$extension;
1519
- return "".concat(v1()).concat(extension !== null ? ".".concat(extension) : '');
1523
+ return "".concat((slugify(filename) || '').substring(0, 50)).concat(extension !== null ? ".".concat(extension) : '');
1520
1524
  } : _ref$getFileName,
1525
+ _ref$getFileNameWithU = _ref.getFileNameWithUUID,
1526
+ getFileNameWithUUID = _ref$getFileNameWithU === void 0 ? function (_ref3) {
1527
+ var _ref3$extension = _ref3.extension,
1528
+ extension = _ref3$extension === void 0 ? null : _ref3$extension;
1529
+ return "".concat(v1()).concat(extension !== null ? ".".concat(extension) : '');
1530
+ } : _ref$getFileNameWithU,
1531
+ _ref$withUUID = _ref.withUUID,
1532
+ withUUID = _ref$withUUID === void 0 ? false : _ref$withUUID,
1521
1533
  _ref$meta = _ref.meta,
1522
1534
  meta = _ref$meta === void 0 ? null : _ref$meta,
1523
1535
  _ref$allowMultipleUpl = _ref.allowMultipleUploads,
@@ -1530,9 +1542,9 @@ var useUppy = function useUppy() {
1530
1542
  autoProceed = _ref$autoProceed === void 0 ? false : _ref$autoProceed,
1531
1543
  _ref$debug = _ref.debug,
1532
1544
  debug = _ref$debug === void 0 ? false : _ref$debug;
1533
- var _ref3 = useContext(UppyContext) || null,
1534
- buildUppy = _ref3.buildUppy,
1535
- transport = _ref3.transport;
1545
+ var _ref4 = useContext(UppyContext) || null,
1546
+ buildUppy = _ref4.buildUppy,
1547
+ transport = _ref4.transport;
1536
1548
  var uppy = useMemo(function () {
1537
1549
  return buildUppy !== null ? buildUppy({
1538
1550
  meta: meta,
@@ -1571,12 +1583,17 @@ var useUppy = function useUppy() {
1571
1583
  if (uppy === null) {
1572
1584
  return function () {};
1573
1585
  }
1574
- var onUpload = function onUpload(_ref4) {
1575
- var _ref4$fileIDs = _ref4.fileIDs,
1576
- ids = _ref4$fileIDs === void 0 ? [] : _ref4$fileIDs;
1586
+ var onUpload = function onUpload(_ref5) {
1587
+ var _ref5$fileIDs = _ref5.fileIDs,
1588
+ ids = _ref5$fileIDs === void 0 ? [] : _ref5$fileIDs;
1577
1589
  ids.forEach(function (id) {
1578
1590
  var file = uppy.getFile(id);
1579
- var newName = getFileName(file);
1591
+ var newName = null;
1592
+ if (withUUID) {
1593
+ newName = getFileNameWithUUID(file);
1594
+ } else {
1595
+ newName = getFileName(file);
1596
+ }
1580
1597
  if (newName !== null) {
1581
1598
  uppy.setFileMeta(id, {
1582
1599
  name: newName
@@ -1630,33 +1647,33 @@ var defaultProps = {
1630
1647
  tus: null,
1631
1648
  xhr: null
1632
1649
  };
1633
- var UppyProvider = function UppyProvider(_ref5) {
1634
- var id = _ref5.id,
1635
- children = _ref5.children,
1636
- providedTransport = _ref5.transport,
1637
- providedLocale = _ref5.locale,
1638
- providedSources = _ref5.sources,
1639
- providedTransloadit = _ref5.transloadit,
1640
- providedCompanion = _ref5.companion,
1641
- providedTus = _ref5.tus,
1642
- providedXhr = _ref5.xhr;
1650
+ var UppyProvider = function UppyProvider(_ref6) {
1651
+ var id = _ref6.id,
1652
+ children = _ref6.children,
1653
+ providedTransport = _ref6.transport,
1654
+ providedLocale = _ref6.locale,
1655
+ providedSources = _ref6.sources,
1656
+ providedTransloadit = _ref6.transloadit,
1657
+ providedCompanion = _ref6.companion,
1658
+ providedTus = _ref6.tus,
1659
+ providedXhr = _ref6.xhr;
1643
1660
  var _useIntl = useIntl(),
1644
1661
  intlLocale = _useIntl.locale;
1645
- var _ref6 = useContext(UppyContext) || {},
1646
- _ref6$transport = _ref6.transport,
1647
- contextTransport = _ref6$transport === void 0 ? null : _ref6$transport,
1648
- _ref6$locale = _ref6.locale,
1649
- contextLocale = _ref6$locale === void 0 ? null : _ref6$locale,
1650
- _ref6$sources = _ref6.sources,
1651
- contextSources = _ref6$sources === void 0 ? null : _ref6$sources,
1652
- _ref6$transloadit = _ref6.transloadit,
1653
- contextTransloadit = _ref6$transloadit === void 0 ? null : _ref6$transloadit,
1654
- _ref6$companion = _ref6.companion,
1655
- contextCompanion = _ref6$companion === void 0 ? null : _ref6$companion,
1656
- _ref6$tus = _ref6.tus,
1657
- contextTus = _ref6$tus === void 0 ? null : _ref6$tus,
1658
- _ref6$xhr = _ref6.xhr,
1659
- contextXhr = _ref6$xhr === void 0 ? null : _ref6$xhr;
1662
+ var _ref7 = useContext(UppyContext) || {},
1663
+ _ref7$transport = _ref7.transport,
1664
+ contextTransport = _ref7$transport === void 0 ? null : _ref7$transport,
1665
+ _ref7$locale = _ref7.locale,
1666
+ contextLocale = _ref7$locale === void 0 ? null : _ref7$locale,
1667
+ _ref7$sources = _ref7.sources,
1668
+ contextSources = _ref7$sources === void 0 ? null : _ref7$sources,
1669
+ _ref7$transloadit = _ref7.transloadit,
1670
+ contextTransloadit = _ref7$transloadit === void 0 ? null : _ref7$transloadit,
1671
+ _ref7$companion = _ref7.companion,
1672
+ contextCompanion = _ref7$companion === void 0 ? null : _ref7$companion,
1673
+ _ref7$tus = _ref7.tus,
1674
+ contextTus = _ref7$tus === void 0 ? null : _ref7$tus,
1675
+ _ref7$xhr = _ref7.xhr,
1676
+ contextXhr = _ref7$xhr === void 0 ? null : _ref7$xhr;
1660
1677
  var transport = providedTransport || contextTransport || 'xhr';
1661
1678
  var locale = providedLocale || contextLocale || intlLocale;
1662
1679
  var sources = providedSources || contextSources || ['webcam', 'facebook', 'instagram', 'dropbox', 'google-drive'];
@@ -1674,10 +1691,10 @@ var UppyProvider = function UppyProvider(_ref5) {
1674
1691
  }
1675
1692
  return function () {
1676
1693
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1677
- var _ref7 = opts || {},
1678
- _ref7$sources = _ref7.sources,
1679
- customSources = _ref7$sources === void 0 ? sources : _ref7$sources,
1680
- uppyOpts = _objectWithoutProperties(_ref7, _excluded);
1694
+ var _ref8 = opts || {},
1695
+ _ref8$sources = _ref8.sources,
1696
+ customSources = _ref8$sources === void 0 ? sources : _ref8$sources,
1697
+ uppyOpts = _objectWithoutProperties(_ref8, _excluded);
1681
1698
  var newUppy = new Uppy(_objectSpread({
1682
1699
  id: id,
1683
1700
  locale: uppyLocale
@@ -1714,12 +1731,12 @@ var UppyProvider = function UppyProvider(_ref5) {
1714
1731
  if (source === null) {
1715
1732
  return currentUppy;
1716
1733
  }
1717
- var _ref8 = companion || {
1734
+ var _ref9 = companion || {
1718
1735
  url: uppyTransport.COMPANION || null,
1719
1736
  allowedHosts: uppyTransport.COMPANION_PATTERN || null
1720
1737
  },
1721
- companionUrl = _ref8.url,
1722
- companionAllowedHosts = _ref8.allowedHosts;
1738
+ companionUrl = _ref9.url,
1739
+ companionAllowedHosts = _ref9.allowedHosts;
1723
1740
  return newUppy.use(source, {
1724
1741
  id: sourceId,
1725
1742
  companionUrl: companionUrl,
package/es/index.js CHANGED
@@ -173,6 +173,8 @@ var modal = PropTypes$1.shape({
173
173
  });
174
174
  var modals = PropTypes$1.arrayOf(modal);
175
175
 
176
+ //
177
+
176
178
  var PropTypes = /*#__PURE__*/Object.freeze({
177
179
  __proto__: null,
178
180
  message: message,
package/lib/contexts.js CHANGED
@@ -19,6 +19,7 @@ var utils = require('@panneau/core/utils');
19
19
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
20
20
  var reactRouter = require('react-router');
21
21
  var tracking = require('@folklore/tracking');
22
+ var slugify = require('slugify');
22
23
  var uuid = require('uuid');
23
24
  var EventEmitter = require('wolfy87-eventemitter');
24
25
 
@@ -52,6 +53,7 @@ var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
52
53
  var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
53
54
  var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
54
55
  var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
56
+ var slugify__default = /*#__PURE__*/_interopDefaultLegacy(slugify);
55
57
  var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
56
58
 
57
59
  var MODALS_NAMESPACE = 'modals';
@@ -423,6 +425,8 @@ var modal = PropTypes__default["default"].shape({
423
425
  });
424
426
  PropTypes__default["default"].arrayOf(modal);
425
427
 
428
+ //
429
+
426
430
  /* eslint-disable react/jsx-props-no-spreading */
427
431
  var DefinitionContext = /*#__PURE__*/React__default["default"].createContext(null);
428
432
  var useDefinitionContext = function useDefinitionContext() {
@@ -1549,10 +1553,19 @@ var useUppy = function useUppy() {
1549
1553
  onFail = _ref$onFail === void 0 ? null : _ref$onFail,
1550
1554
  _ref$getFileName = _ref.getFileName,
1551
1555
  getFileName = _ref$getFileName === void 0 ? function (_ref2) {
1552
- var _ref2$extension = _ref2.extension,
1556
+ var filename = _ref2.filename,
1557
+ _ref2$extension = _ref2.extension,
1553
1558
  extension = _ref2$extension === void 0 ? null : _ref2$extension;
1554
- return "".concat(uuid.v1()).concat(extension !== null ? ".".concat(extension) : '');
1559
+ return "".concat((slugify__default["default"](filename) || '').substring(0, 50)).concat(extension !== null ? ".".concat(extension) : '');
1555
1560
  } : _ref$getFileName,
1561
+ _ref$getFileNameWithU = _ref.getFileNameWithUUID,
1562
+ getFileNameWithUUID = _ref$getFileNameWithU === void 0 ? function (_ref3) {
1563
+ var _ref3$extension = _ref3.extension,
1564
+ extension = _ref3$extension === void 0 ? null : _ref3$extension;
1565
+ return "".concat(uuid.v1()).concat(extension !== null ? ".".concat(extension) : '');
1566
+ } : _ref$getFileNameWithU,
1567
+ _ref$withUUID = _ref.withUUID,
1568
+ withUUID = _ref$withUUID === void 0 ? false : _ref$withUUID,
1556
1569
  _ref$meta = _ref.meta,
1557
1570
  meta = _ref$meta === void 0 ? null : _ref$meta,
1558
1571
  _ref$allowMultipleUpl = _ref.allowMultipleUploads,
@@ -1565,9 +1578,9 @@ var useUppy = function useUppy() {
1565
1578
  autoProceed = _ref$autoProceed === void 0 ? false : _ref$autoProceed,
1566
1579
  _ref$debug = _ref.debug,
1567
1580
  debug = _ref$debug === void 0 ? false : _ref$debug;
1568
- var _ref3 = React.useContext(UppyContext) || null,
1569
- buildUppy = _ref3.buildUppy,
1570
- transport = _ref3.transport;
1581
+ var _ref4 = React.useContext(UppyContext) || null,
1582
+ buildUppy = _ref4.buildUppy,
1583
+ transport = _ref4.transport;
1571
1584
  var uppy = React.useMemo(function () {
1572
1585
  return buildUppy !== null ? buildUppy({
1573
1586
  meta: meta,
@@ -1606,12 +1619,17 @@ var useUppy = function useUppy() {
1606
1619
  if (uppy === null) {
1607
1620
  return function () {};
1608
1621
  }
1609
- var onUpload = function onUpload(_ref4) {
1610
- var _ref4$fileIDs = _ref4.fileIDs,
1611
- ids = _ref4$fileIDs === void 0 ? [] : _ref4$fileIDs;
1622
+ var onUpload = function onUpload(_ref5) {
1623
+ var _ref5$fileIDs = _ref5.fileIDs,
1624
+ ids = _ref5$fileIDs === void 0 ? [] : _ref5$fileIDs;
1612
1625
  ids.forEach(function (id) {
1613
1626
  var file = uppy.getFile(id);
1614
- var newName = getFileName(file);
1627
+ var newName = null;
1628
+ if (withUUID) {
1629
+ newName = getFileNameWithUUID(file);
1630
+ } else {
1631
+ newName = getFileName(file);
1632
+ }
1615
1633
  if (newName !== null) {
1616
1634
  uppy.setFileMeta(id, {
1617
1635
  name: newName
@@ -1665,33 +1683,33 @@ var defaultProps = {
1665
1683
  tus: null,
1666
1684
  xhr: null
1667
1685
  };
1668
- var UppyProvider = function UppyProvider(_ref5) {
1669
- var id = _ref5.id,
1670
- children = _ref5.children,
1671
- providedTransport = _ref5.transport,
1672
- providedLocale = _ref5.locale,
1673
- providedSources = _ref5.sources,
1674
- providedTransloadit = _ref5.transloadit,
1675
- providedCompanion = _ref5.companion,
1676
- providedTus = _ref5.tus,
1677
- providedXhr = _ref5.xhr;
1686
+ var UppyProvider = function UppyProvider(_ref6) {
1687
+ var id = _ref6.id,
1688
+ children = _ref6.children,
1689
+ providedTransport = _ref6.transport,
1690
+ providedLocale = _ref6.locale,
1691
+ providedSources = _ref6.sources,
1692
+ providedTransloadit = _ref6.transloadit,
1693
+ providedCompanion = _ref6.companion,
1694
+ providedTus = _ref6.tus,
1695
+ providedXhr = _ref6.xhr;
1678
1696
  var _useIntl = reactIntl.useIntl(),
1679
1697
  intlLocale = _useIntl.locale;
1680
- var _ref6 = React.useContext(UppyContext) || {},
1681
- _ref6$transport = _ref6.transport,
1682
- contextTransport = _ref6$transport === void 0 ? null : _ref6$transport,
1683
- _ref6$locale = _ref6.locale,
1684
- contextLocale = _ref6$locale === void 0 ? null : _ref6$locale,
1685
- _ref6$sources = _ref6.sources,
1686
- contextSources = _ref6$sources === void 0 ? null : _ref6$sources,
1687
- _ref6$transloadit = _ref6.transloadit,
1688
- contextTransloadit = _ref6$transloadit === void 0 ? null : _ref6$transloadit,
1689
- _ref6$companion = _ref6.companion,
1690
- contextCompanion = _ref6$companion === void 0 ? null : _ref6$companion,
1691
- _ref6$tus = _ref6.tus,
1692
- contextTus = _ref6$tus === void 0 ? null : _ref6$tus,
1693
- _ref6$xhr = _ref6.xhr,
1694
- contextXhr = _ref6$xhr === void 0 ? null : _ref6$xhr;
1698
+ var _ref7 = React.useContext(UppyContext) || {},
1699
+ _ref7$transport = _ref7.transport,
1700
+ contextTransport = _ref7$transport === void 0 ? null : _ref7$transport,
1701
+ _ref7$locale = _ref7.locale,
1702
+ contextLocale = _ref7$locale === void 0 ? null : _ref7$locale,
1703
+ _ref7$sources = _ref7.sources,
1704
+ contextSources = _ref7$sources === void 0 ? null : _ref7$sources,
1705
+ _ref7$transloadit = _ref7.transloadit,
1706
+ contextTransloadit = _ref7$transloadit === void 0 ? null : _ref7$transloadit,
1707
+ _ref7$companion = _ref7.companion,
1708
+ contextCompanion = _ref7$companion === void 0 ? null : _ref7$companion,
1709
+ _ref7$tus = _ref7.tus,
1710
+ contextTus = _ref7$tus === void 0 ? null : _ref7$tus,
1711
+ _ref7$xhr = _ref7.xhr,
1712
+ contextXhr = _ref7$xhr === void 0 ? null : _ref7$xhr;
1695
1713
  var transport = providedTransport || contextTransport || 'xhr';
1696
1714
  var locale = providedLocale || contextLocale || intlLocale;
1697
1715
  var sources = providedSources || contextSources || ['webcam', 'facebook', 'instagram', 'dropbox', 'google-drive'];
@@ -1709,10 +1727,10 @@ var UppyProvider = function UppyProvider(_ref5) {
1709
1727
  }
1710
1728
  return function () {
1711
1729
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1712
- var _ref7 = opts || {},
1713
- _ref7$sources = _ref7.sources,
1714
- customSources = _ref7$sources === void 0 ? sources : _ref7$sources,
1715
- uppyOpts = _objectWithoutProperties__default["default"](_ref7, _excluded);
1730
+ var _ref8 = opts || {},
1731
+ _ref8$sources = _ref8.sources,
1732
+ customSources = _ref8$sources === void 0 ? sources : _ref8$sources,
1733
+ uppyOpts = _objectWithoutProperties__default["default"](_ref8, _excluded);
1716
1734
  var newUppy = new Uppy(_objectSpread__default["default"]({
1717
1735
  id: id,
1718
1736
  locale: uppyLocale
@@ -1749,12 +1767,12 @@ var UppyProvider = function UppyProvider(_ref5) {
1749
1767
  if (source === null) {
1750
1768
  return currentUppy;
1751
1769
  }
1752
- var _ref8 = companion || {
1770
+ var _ref9 = companion || {
1753
1771
  url: uppyTransport.COMPANION || null,
1754
1772
  allowedHosts: uppyTransport.COMPANION_PATTERN || null
1755
1773
  },
1756
- companionUrl = _ref8.url,
1757
- companionAllowedHosts = _ref8.allowedHosts;
1774
+ companionUrl = _ref9.url,
1775
+ companionAllowedHosts = _ref9.allowedHosts;
1758
1776
  return newUppy.use(source, {
1759
1777
  id: sourceId,
1760
1778
  companionUrl: companionUrl,
package/lib/index.js CHANGED
@@ -195,6 +195,8 @@ var modal = PropTypes__default["default"].shape({
195
195
  });
196
196
  var modals = PropTypes__default["default"].arrayOf(modal);
197
197
 
198
+ //
199
+
198
200
  var PropTypes = /*#__PURE__*/Object.freeze({
199
201
  __proto__: null,
200
202
  message: message,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/core",
3
- "version": "2.0.85",
3
+ "version": "2.0.91",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -114,5 +114,5 @@
114
114
  "publishConfig": {
115
115
  "access": "public"
116
116
  },
117
- "gitHead": "4d9a6b55e2ff8199e2c82bb8d8cf1c7244bae0be"
117
+ "gitHead": "a0ea54191eb4d1f28d0918203f483f11d7b9e52f"
118
118
  }