@panneau/core 2.0.86 → 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 +56 -41
- package/lib/contexts.js +57 -41
- 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
|
|
|
@@ -1516,10 +1517,19 @@ var useUppy = function useUppy() {
|
|
|
1516
1517
|
onFail = _ref$onFail === void 0 ? null : _ref$onFail,
|
|
1517
1518
|
_ref$getFileName = _ref.getFileName,
|
|
1518
1519
|
getFileName = _ref$getFileName === void 0 ? function (_ref2) {
|
|
1519
|
-
var
|
|
1520
|
+
var filename = _ref2.filename,
|
|
1521
|
+
_ref2$extension = _ref2.extension,
|
|
1520
1522
|
extension = _ref2$extension === void 0 ? null : _ref2$extension;
|
|
1521
|
-
return "".concat(
|
|
1523
|
+
return "".concat((slugify(filename) || '').substring(0, 50)).concat(extension !== null ? ".".concat(extension) : '');
|
|
1522
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,
|
|
1523
1533
|
_ref$meta = _ref.meta,
|
|
1524
1534
|
meta = _ref$meta === void 0 ? null : _ref$meta,
|
|
1525
1535
|
_ref$allowMultipleUpl = _ref.allowMultipleUploads,
|
|
@@ -1532,9 +1542,9 @@ var useUppy = function useUppy() {
|
|
|
1532
1542
|
autoProceed = _ref$autoProceed === void 0 ? false : _ref$autoProceed,
|
|
1533
1543
|
_ref$debug = _ref.debug,
|
|
1534
1544
|
debug = _ref$debug === void 0 ? false : _ref$debug;
|
|
1535
|
-
var
|
|
1536
|
-
buildUppy =
|
|
1537
|
-
transport =
|
|
1545
|
+
var _ref4 = useContext(UppyContext) || null,
|
|
1546
|
+
buildUppy = _ref4.buildUppy,
|
|
1547
|
+
transport = _ref4.transport;
|
|
1538
1548
|
var uppy = useMemo(function () {
|
|
1539
1549
|
return buildUppy !== null ? buildUppy({
|
|
1540
1550
|
meta: meta,
|
|
@@ -1573,12 +1583,17 @@ var useUppy = function useUppy() {
|
|
|
1573
1583
|
if (uppy === null) {
|
|
1574
1584
|
return function () {};
|
|
1575
1585
|
}
|
|
1576
|
-
var onUpload = function onUpload(
|
|
1577
|
-
var
|
|
1578
|
-
ids =
|
|
1586
|
+
var onUpload = function onUpload(_ref5) {
|
|
1587
|
+
var _ref5$fileIDs = _ref5.fileIDs,
|
|
1588
|
+
ids = _ref5$fileIDs === void 0 ? [] : _ref5$fileIDs;
|
|
1579
1589
|
ids.forEach(function (id) {
|
|
1580
1590
|
var file = uppy.getFile(id);
|
|
1581
|
-
var newName =
|
|
1591
|
+
var newName = null;
|
|
1592
|
+
if (withUUID) {
|
|
1593
|
+
newName = getFileNameWithUUID(file);
|
|
1594
|
+
} else {
|
|
1595
|
+
newName = getFileName(file);
|
|
1596
|
+
}
|
|
1582
1597
|
if (newName !== null) {
|
|
1583
1598
|
uppy.setFileMeta(id, {
|
|
1584
1599
|
name: newName
|
|
@@ -1632,33 +1647,33 @@ var defaultProps = {
|
|
|
1632
1647
|
tus: null,
|
|
1633
1648
|
xhr: null
|
|
1634
1649
|
};
|
|
1635
|
-
var UppyProvider = function UppyProvider(
|
|
1636
|
-
var id =
|
|
1637
|
-
children =
|
|
1638
|
-
providedTransport =
|
|
1639
|
-
providedLocale =
|
|
1640
|
-
providedSources =
|
|
1641
|
-
providedTransloadit =
|
|
1642
|
-
providedCompanion =
|
|
1643
|
-
providedTus =
|
|
1644
|
-
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;
|
|
1645
1660
|
var _useIntl = useIntl(),
|
|
1646
1661
|
intlLocale = _useIntl.locale;
|
|
1647
|
-
var
|
|
1648
|
-
|
|
1649
|
-
contextTransport =
|
|
1650
|
-
|
|
1651
|
-
contextLocale =
|
|
1652
|
-
|
|
1653
|
-
contextSources =
|
|
1654
|
-
|
|
1655
|
-
contextTransloadit =
|
|
1656
|
-
|
|
1657
|
-
contextCompanion =
|
|
1658
|
-
|
|
1659
|
-
contextTus =
|
|
1660
|
-
|
|
1661
|
-
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;
|
|
1662
1677
|
var transport = providedTransport || contextTransport || 'xhr';
|
|
1663
1678
|
var locale = providedLocale || contextLocale || intlLocale;
|
|
1664
1679
|
var sources = providedSources || contextSources || ['webcam', 'facebook', 'instagram', 'dropbox', 'google-drive'];
|
|
@@ -1676,10 +1691,10 @@ var UppyProvider = function UppyProvider(_ref5) {
|
|
|
1676
1691
|
}
|
|
1677
1692
|
return function () {
|
|
1678
1693
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1679
|
-
var
|
|
1680
|
-
|
|
1681
|
-
customSources =
|
|
1682
|
-
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);
|
|
1683
1698
|
var newUppy = new Uppy(_objectSpread({
|
|
1684
1699
|
id: id,
|
|
1685
1700
|
locale: uppyLocale
|
|
@@ -1716,12 +1731,12 @@ var UppyProvider = function UppyProvider(_ref5) {
|
|
|
1716
1731
|
if (source === null) {
|
|
1717
1732
|
return currentUppy;
|
|
1718
1733
|
}
|
|
1719
|
-
var
|
|
1734
|
+
var _ref9 = companion || {
|
|
1720
1735
|
url: uppyTransport.COMPANION || null,
|
|
1721
1736
|
allowedHosts: uppyTransport.COMPANION_PATTERN || null
|
|
1722
1737
|
},
|
|
1723
|
-
companionUrl =
|
|
1724
|
-
companionAllowedHosts =
|
|
1738
|
+
companionUrl = _ref9.url,
|
|
1739
|
+
companionAllowedHosts = _ref9.allowedHosts;
|
|
1725
1740
|
return newUppy.use(source, {
|
|
1726
1741
|
id: sourceId,
|
|
1727
1742
|
companionUrl: companionUrl,
|
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';
|
|
@@ -1551,10 +1553,19 @@ var useUppy = function useUppy() {
|
|
|
1551
1553
|
onFail = _ref$onFail === void 0 ? null : _ref$onFail,
|
|
1552
1554
|
_ref$getFileName = _ref.getFileName,
|
|
1553
1555
|
getFileName = _ref$getFileName === void 0 ? function (_ref2) {
|
|
1554
|
-
var
|
|
1556
|
+
var filename = _ref2.filename,
|
|
1557
|
+
_ref2$extension = _ref2.extension,
|
|
1555
1558
|
extension = _ref2$extension === void 0 ? null : _ref2$extension;
|
|
1556
|
-
return "".concat(
|
|
1559
|
+
return "".concat((slugify__default["default"](filename) || '').substring(0, 50)).concat(extension !== null ? ".".concat(extension) : '');
|
|
1557
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,
|
|
1558
1569
|
_ref$meta = _ref.meta,
|
|
1559
1570
|
meta = _ref$meta === void 0 ? null : _ref$meta,
|
|
1560
1571
|
_ref$allowMultipleUpl = _ref.allowMultipleUploads,
|
|
@@ -1567,9 +1578,9 @@ var useUppy = function useUppy() {
|
|
|
1567
1578
|
autoProceed = _ref$autoProceed === void 0 ? false : _ref$autoProceed,
|
|
1568
1579
|
_ref$debug = _ref.debug,
|
|
1569
1580
|
debug = _ref$debug === void 0 ? false : _ref$debug;
|
|
1570
|
-
var
|
|
1571
|
-
buildUppy =
|
|
1572
|
-
transport =
|
|
1581
|
+
var _ref4 = React.useContext(UppyContext) || null,
|
|
1582
|
+
buildUppy = _ref4.buildUppy,
|
|
1583
|
+
transport = _ref4.transport;
|
|
1573
1584
|
var uppy = React.useMemo(function () {
|
|
1574
1585
|
return buildUppy !== null ? buildUppy({
|
|
1575
1586
|
meta: meta,
|
|
@@ -1608,12 +1619,17 @@ var useUppy = function useUppy() {
|
|
|
1608
1619
|
if (uppy === null) {
|
|
1609
1620
|
return function () {};
|
|
1610
1621
|
}
|
|
1611
|
-
var onUpload = function onUpload(
|
|
1612
|
-
var
|
|
1613
|
-
ids =
|
|
1622
|
+
var onUpload = function onUpload(_ref5) {
|
|
1623
|
+
var _ref5$fileIDs = _ref5.fileIDs,
|
|
1624
|
+
ids = _ref5$fileIDs === void 0 ? [] : _ref5$fileIDs;
|
|
1614
1625
|
ids.forEach(function (id) {
|
|
1615
1626
|
var file = uppy.getFile(id);
|
|
1616
|
-
var newName =
|
|
1627
|
+
var newName = null;
|
|
1628
|
+
if (withUUID) {
|
|
1629
|
+
newName = getFileNameWithUUID(file);
|
|
1630
|
+
} else {
|
|
1631
|
+
newName = getFileName(file);
|
|
1632
|
+
}
|
|
1617
1633
|
if (newName !== null) {
|
|
1618
1634
|
uppy.setFileMeta(id, {
|
|
1619
1635
|
name: newName
|
|
@@ -1667,33 +1683,33 @@ var defaultProps = {
|
|
|
1667
1683
|
tus: null,
|
|
1668
1684
|
xhr: null
|
|
1669
1685
|
};
|
|
1670
|
-
var UppyProvider = function UppyProvider(
|
|
1671
|
-
var id =
|
|
1672
|
-
children =
|
|
1673
|
-
providedTransport =
|
|
1674
|
-
providedLocale =
|
|
1675
|
-
providedSources =
|
|
1676
|
-
providedTransloadit =
|
|
1677
|
-
providedCompanion =
|
|
1678
|
-
providedTus =
|
|
1679
|
-
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;
|
|
1680
1696
|
var _useIntl = reactIntl.useIntl(),
|
|
1681
1697
|
intlLocale = _useIntl.locale;
|
|
1682
|
-
var
|
|
1683
|
-
|
|
1684
|
-
contextTransport =
|
|
1685
|
-
|
|
1686
|
-
contextLocale =
|
|
1687
|
-
|
|
1688
|
-
contextSources =
|
|
1689
|
-
|
|
1690
|
-
contextTransloadit =
|
|
1691
|
-
|
|
1692
|
-
contextCompanion =
|
|
1693
|
-
|
|
1694
|
-
contextTus =
|
|
1695
|
-
|
|
1696
|
-
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;
|
|
1697
1713
|
var transport = providedTransport || contextTransport || 'xhr';
|
|
1698
1714
|
var locale = providedLocale || contextLocale || intlLocale;
|
|
1699
1715
|
var sources = providedSources || contextSources || ['webcam', 'facebook', 'instagram', 'dropbox', 'google-drive'];
|
|
@@ -1711,10 +1727,10 @@ var UppyProvider = function UppyProvider(_ref5) {
|
|
|
1711
1727
|
}
|
|
1712
1728
|
return function () {
|
|
1713
1729
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1714
|
-
var
|
|
1715
|
-
|
|
1716
|
-
customSources =
|
|
1717
|
-
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);
|
|
1718
1734
|
var newUppy = new Uppy(_objectSpread__default["default"]({
|
|
1719
1735
|
id: id,
|
|
1720
1736
|
locale: uppyLocale
|
|
@@ -1751,12 +1767,12 @@ var UppyProvider = function UppyProvider(_ref5) {
|
|
|
1751
1767
|
if (source === null) {
|
|
1752
1768
|
return currentUppy;
|
|
1753
1769
|
}
|
|
1754
|
-
var
|
|
1770
|
+
var _ref9 = companion || {
|
|
1755
1771
|
url: uppyTransport.COMPANION || null,
|
|
1756
1772
|
allowedHosts: uppyTransport.COMPANION_PATTERN || null
|
|
1757
1773
|
},
|
|
1758
|
-
companionUrl =
|
|
1759
|
-
companionAllowedHosts =
|
|
1774
|
+
companionUrl = _ref9.url,
|
|
1775
|
+
companionAllowedHosts = _ref9.allowedHosts;
|
|
1760
1776
|
return newUppy.use(source, {
|
|
1761
1777
|
id: sourceId,
|
|
1762
1778
|
companionUrl: companionUrl,
|
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
|
}
|