@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 +58 -41
- package/es/index.js +2 -0
- package/lib/contexts.js +59 -41
- package/lib/index.js +2 -0
- package/package.json +2 -2
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
|
|
1520
|
+
var filename = _ref2.filename,
|
|
1521
|
+
_ref2$extension = _ref2.extension,
|
|
1518
1522
|
extension = _ref2$extension === void 0 ? null : _ref2$extension;
|
|
1519
|
-
return "".concat(
|
|
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
|
|
1534
|
-
buildUppy =
|
|
1535
|
-
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(
|
|
1575
|
-
var
|
|
1576
|
-
ids =
|
|
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 =
|
|
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(
|
|
1634
|
-
var id =
|
|
1635
|
-
children =
|
|
1636
|
-
providedTransport =
|
|
1637
|
-
providedLocale =
|
|
1638
|
-
providedSources =
|
|
1639
|
-
providedTransloadit =
|
|
1640
|
-
providedCompanion =
|
|
1641
|
-
providedTus =
|
|
1642
|
-
providedXhr =
|
|
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
|
|
1646
|
-
|
|
1647
|
-
contextTransport =
|
|
1648
|
-
|
|
1649
|
-
contextLocale =
|
|
1650
|
-
|
|
1651
|
-
contextSources =
|
|
1652
|
-
|
|
1653
|
-
contextTransloadit =
|
|
1654
|
-
|
|
1655
|
-
contextCompanion =
|
|
1656
|
-
|
|
1657
|
-
contextTus =
|
|
1658
|
-
|
|
1659
|
-
contextXhr =
|
|
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
|
|
1678
|
-
|
|
1679
|
-
customSources =
|
|
1680
|
-
uppyOpts = _objectWithoutProperties(
|
|
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
|
|
1734
|
+
var _ref9 = companion || {
|
|
1718
1735
|
url: uppyTransport.COMPANION || null,
|
|
1719
1736
|
allowedHosts: uppyTransport.COMPANION_PATTERN || null
|
|
1720
1737
|
},
|
|
1721
|
-
companionUrl =
|
|
1722
|
-
companionAllowedHosts =
|
|
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
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
|
|
1556
|
+
var filename = _ref2.filename,
|
|
1557
|
+
_ref2$extension = _ref2.extension,
|
|
1553
1558
|
extension = _ref2$extension === void 0 ? null : _ref2$extension;
|
|
1554
|
-
return "".concat(
|
|
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
|
|
1569
|
-
buildUppy =
|
|
1570
|
-
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(
|
|
1610
|
-
var
|
|
1611
|
-
ids =
|
|
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 =
|
|
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(
|
|
1669
|
-
var id =
|
|
1670
|
-
children =
|
|
1671
|
-
providedTransport =
|
|
1672
|
-
providedLocale =
|
|
1673
|
-
providedSources =
|
|
1674
|
-
providedTransloadit =
|
|
1675
|
-
providedCompanion =
|
|
1676
|
-
providedTus =
|
|
1677
|
-
providedXhr =
|
|
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
|
|
1681
|
-
|
|
1682
|
-
contextTransport =
|
|
1683
|
-
|
|
1684
|
-
contextLocale =
|
|
1685
|
-
|
|
1686
|
-
contextSources =
|
|
1687
|
-
|
|
1688
|
-
contextTransloadit =
|
|
1689
|
-
|
|
1690
|
-
contextCompanion =
|
|
1691
|
-
|
|
1692
|
-
contextTus =
|
|
1693
|
-
|
|
1694
|
-
contextXhr =
|
|
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
|
|
1713
|
-
|
|
1714
|
-
customSources =
|
|
1715
|
-
uppyOpts = _objectWithoutProperties__default["default"](
|
|
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
|
|
1770
|
+
var _ref9 = companion || {
|
|
1753
1771
|
url: uppyTransport.COMPANION || null,
|
|
1754
1772
|
allowedHosts: uppyTransport.COMPANION_PATTERN || null
|
|
1755
1773
|
},
|
|
1756
|
-
companionUrl =
|
|
1757
|
-
companionAllowedHosts =
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/core",
|
|
3
|
-
"version": "2.0.
|
|
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": "
|
|
117
|
+
"gitHead": "a0ea54191eb4d1f28d0918203f483f11d7b9e52f"
|
|
118
118
|
}
|