@scaleflex/widget-progress-panel 0.0.1

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.
@@ -0,0 +1,37 @@
1
+ import { useMemo } from 'react';
2
+ import Styled from './ActivityCircularProgress.styled';
3
+ import StyledProgressPanel from '../../ProgressPanel.styled';
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ var SIZE = 44;
6
+ var ActivityCircularProgress = function ActivityCircularProgress(_ref) {
7
+ var _ref$value = _ref.value,
8
+ value = _ref$value === void 0 ? 0 : _ref$value,
9
+ _ref$thickness = _ref.thickness,
10
+ thickness = _ref$thickness === void 0 ? 6 : _ref$thickness,
11
+ determinate = _ref.determinate,
12
+ statusTitle = _ref.statusTitle;
13
+ var circumference = useMemo(function () {
14
+ return 2 * Math.PI * ((SIZE - thickness) / 2);
15
+ }, [thickness]);
16
+ return /*#__PURE__*/_jsx(StyledProgressPanel.ActivityStatus, {
17
+ "aria-label": statusTitle,
18
+ title: statusTitle,
19
+ children: /*#__PURE__*/_jsx(Styled.CircularProgressRoot, {
20
+ "aria-valuenow": value,
21
+ determinate: determinate,
22
+ children: /*#__PURE__*/_jsxs(Styled.CircularProgressSvg, {
23
+ viewBox: "22 22 44 44",
24
+ children: [/*#__PURE__*/_jsx(Styled.CircularProgressTrack, {
25
+ size: SIZE,
26
+ thickness: thickness
27
+ }), /*#__PURE__*/_jsx(Styled.CircularProgress, {
28
+ size: SIZE,
29
+ thickness: thickness,
30
+ strokeDasharray: circumference.toFixed(3),
31
+ strokeDashoffset: ((100 - value) / 100 * circumference).toFixed(3)
32
+ })]
33
+ })
34
+ })
35
+ });
36
+ };
37
+ export default ActivityCircularProgress;
@@ -0,0 +1,51 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
4
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
+ import { useTheme } from '@scaleflex/ui/theme/hooks';
6
+ import { Success, WarningRound } from '@scaleflex/icons';
7
+ import { PC } from '@scaleflex/widget-common';
8
+ import { PROGRESS_PANEL_STATUS } from '@scaleflex/widget-utils/lib/constants';
9
+ import Styled from '../ProgressPanel.styled';
10
+ import ActivityCircularProgress from './ActivityCircularProgress';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ var activityStatusToComponent = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, PROGRESS_PANEL_STATUS.PREPARING, ActivityCircularProgress), PROGRESS_PANEL_STATUS.PROGRESSING, ActivityCircularProgress), PROGRESS_PANEL_STATUS.PAUSED, ActivityCircularProgress), PROGRESS_PANEL_STATUS.DELAYED, function (_ref) {
13
+ var theme = _ref.theme;
14
+ return /*#__PURE__*/_jsx(Success, {
15
+ size: 22,
16
+ color: theme.palette[PC.Success]
17
+ });
18
+ }), PROGRESS_PANEL_STATUS.COMPLETE, function (_ref2) {
19
+ var theme = _ref2.theme;
20
+ return /*#__PURE__*/_jsx(Success, {
21
+ size: 22,
22
+ color: theme.palette[PC.Success]
23
+ });
24
+ }), PROGRESS_PANEL_STATUS.ERROR, function (_ref3) {
25
+ var theme = _ref3.theme;
26
+ return /*#__PURE__*/_jsx(WarningRound, {
27
+ size: 22,
28
+ color: theme.palette[PC.Error]
29
+ });
30
+ });
31
+ var ActivityStatus = function ActivityStatus(_ref4) {
32
+ var status = _ref4.status,
33
+ statusTitle = _ref4.statusTitle,
34
+ percentage = _ref4.percentage,
35
+ almostCompleted = _ref4.almostCompleted,
36
+ i18n = _ref4.i18n;
37
+ var theme = useTheme();
38
+ var indeterminate = status === PROGRESS_PANEL_STATUS.PREPARING || almostCompleted;
39
+ var title = statusTitle || status;
40
+ var ActivityStatusComp = activityStatusToComponent[status];
41
+ return /*#__PURE__*/_jsx(Styled.ActivityStatus, {
42
+ title: title,
43
+ children: ActivityStatusComp && /*#__PURE__*/_jsx(ActivityStatusComp, {
44
+ theme: theme,
45
+ value: indeterminate ? 25 : percentage,
46
+ determinate: !indeterminate,
47
+ statusTitle: almostCompleted ? i18n('progressPanelAssetProcessingTitle') : title
48
+ })
49
+ });
50
+ };
51
+ export default ActivityStatus;
@@ -0,0 +1,34 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { Cross } from '@scaleflex/icons';
8
+ import { useCore } from '@scaleflex/widget-core/lib/hooks';
9
+ import Styled from '../ProgressPanel.styled';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ var CancelButton = function CancelButton(_ref) {
12
+ var id = _ref.id,
13
+ i18n = _ref.i18n;
14
+ var _useCore = useCore(),
15
+ emit = _useCore.emit;
16
+ var handleCancel = function handleCancel() {
17
+ emit('activity-cancel', {
18
+ id: id
19
+ });
20
+ };
21
+ return /*#__PURE__*/_jsx(Styled.ActionButton, {
22
+ size: "sm",
23
+ color: "primary",
24
+ onClick: handleCancel,
25
+ "aria-label": i18n('progressPanelProgressActionTitle'),
26
+ title: i18n('progressPanelProgressActionTitle'),
27
+ children: function children(iconProps) {
28
+ return /*#__PURE__*/_jsx(Cross, _objectSpread(_objectSpread({}, iconProps), {}, {
29
+ size: 12
30
+ }));
31
+ }
32
+ });
33
+ };
34
+ export default CancelButton;
@@ -0,0 +1,67 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ import { useEffect, useState } from 'react';
8
+ import { useSelector } from 'react-redux';
9
+ import { VirtualList } from '@scaleflex/widget-common';
10
+ import { EVENTS } from '@scaleflex/widget-utils/lib/constants';
11
+ import { useCore } from '@scaleflex/widget-core/lib/hooks';
12
+ import { selectProgressPanelActivitiesIds, selectIsProgressPanelMinimized, selectShowProgressPanel, selectProgressPanelDelayedActivitiesIds } from '../progressPanel.slice';
13
+ import ProgressPanelItem from './ProgressPanelItem';
14
+ import ProgressPanelHeader from './ProgressPanelHeader';
15
+ import Styled from '../ProgressPanel.styled';
16
+ import UploadDelayedNotification from './UploadDelayedNotification';
17
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
+ var ProgressPanel = function ProgressPanel(_ref) {
19
+ var i18n = _ref.i18n,
20
+ _ref$zIndex = _ref.zIndex,
21
+ zIndex = _ref$zIndex === void 0 ? 9999 : _ref$zIndex,
22
+ _ref$position = _ref.position,
23
+ position = _ref$position === void 0 ? 'fixed' : _ref$position;
24
+ var _useCore = useCore(),
25
+ on = _useCore.on,
26
+ off = _useCore.off;
27
+ var progressPanelActivitiesIds = useSelector(selectProgressPanelActivitiesIds);
28
+ var isPanelMinimized = useSelector(selectIsProgressPanelMinimized);
29
+ var showProgressPanel = useSelector(selectShowProgressPanel);
30
+ var progressPanelDelayedActivitiesIds = useSelector(selectProgressPanelDelayedActivitiesIds);
31
+ var _useState = useState(),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ style = _useState2[0],
34
+ setStyle = _useState2[1];
35
+ var handleOnStyleChange = function handleOnStyleChange(newStyle) {
36
+ setStyle(newStyle);
37
+ };
38
+ useEffect(function () {
39
+ on(EVENTS.CHANGE_PROGRESS_PANEL_STYLE, handleOnStyleChange);
40
+ return function () {
41
+ off(EVENTS.CHANGE_PROGRESS_PANEL_STYLE, handleOnStyleChange);
42
+ };
43
+ }, []);
44
+ return /*#__PURE__*/_jsxs(Styled.ProgressPanelContainer, {
45
+ className: "filerobot-progressPanel",
46
+ zIndex: zIndex,
47
+ show: showProgressPanel,
48
+ isMinimized: isPanelMinimized,
49
+ position: position,
50
+ style: style,
51
+ children: [/*#__PURE__*/_jsx(ProgressPanelHeader, {
52
+ i18n: i18n
53
+ }), progressPanelDelayedActivitiesIds.length > 0 && /*#__PURE__*/_jsx(UploadDelayedNotification, {
54
+ i18n: i18n
55
+ }), !isPanelMinimized && /*#__PURE__*/_jsx(Styled.ProgressPanelList, {
56
+ children: /*#__PURE__*/_jsx(VirtualList, {
57
+ items: progressPanelActivitiesIds,
58
+ injectedItemPropName: "activityId",
59
+ children: /*#__PURE__*/_jsx(ProgressPanelItem, {
60
+ itemsCount: progressPanelActivitiesIds.length,
61
+ i18n: i18n
62
+ })
63
+ })
64
+ })]
65
+ });
66
+ };
67
+ export default ProgressPanel;
@@ -0,0 +1,78 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { useSelector, useDispatch } from 'react-redux';
8
+ import throttle from 'lodash.throttle';
9
+ import { Cross } from '@scaleflex/icons';
10
+ import prettyETA from '@scaleflex/widget-utils/lib/prettyETA';
11
+ import { useCore } from '@scaleflex/widget-core/lib/hooks';
12
+ import { selectProgressPanelInProgressActivitiesIds, selectProgressPanelCompletedActivitiesIds, selectProgressPanelTotalEta, selectIsProgressPanelMinimized, progressPanelMinimized, resetPanel } from '../progressPanel.slice';
13
+ import Styled from '../ProgressPanel.styled';
14
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
+ var ProgressPanelHeader = function ProgressPanelHeader(_ref) {
16
+ var i18n = _ref.i18n;
17
+ var dispatch = useDispatch();
18
+ var _useCore = useCore(),
19
+ cancelUploads = _useCore.cancelUploads,
20
+ emit = _useCore.emit;
21
+ var isPanelMinimized = useSelector(selectIsProgressPanelMinimized);
22
+ var inProgressActivitiesIds = useSelector(selectProgressPanelInProgressActivitiesIds);
23
+ var completedActivitiesIds = useSelector(selectProgressPanelCompletedActivitiesIds);
24
+ var totalEta = useSelector(selectProgressPanelTotalEta);
25
+ var togglePanel = function togglePanel() {
26
+ dispatch(progressPanelMinimized(!isPanelMinimized));
27
+ emit('progressPanel-minimize', !isPanelMinimized);
28
+ };
29
+ var closeProgressPanel = function closeProgressPanel() {
30
+ dispatch(resetPanel());
31
+ cancelUploads();
32
+ };
33
+ var ProgressPanelEta = throttle(function () {
34
+ return /*#__PURE__*/_jsx(Styled.ProgressPanelEta, {
35
+ children: i18n('progressPanelEtaLeftText', {
36
+ time: prettyETA(totalEta)
37
+ })
38
+ });
39
+ }, 500, {
40
+ leading: true,
41
+ trailing: true
42
+ });
43
+ var isPanelActive = inProgressActivitiesIds.length;
44
+ var panelItems = isPanelActive ? inProgressActivitiesIds : completedActivitiesIds;
45
+ return /*#__PURE__*/_jsxs(Styled.ProgressPanelHeader, {
46
+ isMinimized: isPanelMinimized,
47
+ children: [/*#__PURE__*/_jsxs(Styled.ProgressPanelInfo, {
48
+ children: [/*#__PURE__*/_jsx(Styled.ProgressPanelState, {
49
+ hasTotalEta: !!totalEta,
50
+ children: "".concat(isPanelActive ? i18n('progressPanelProcessingHeaderLabel') : i18n('progressPanelProcessedHeaderLabel'), "\n (").concat(panelItems.length, " ").concat(i18n('progressPanelHeaderItemsText', {
51
+ smart_count: panelItems.length
52
+ }), ")")
53
+ }), !!totalEta && /*#__PURE__*/_jsx(ProgressPanelEta, {})]
54
+ }), /*#__PURE__*/_jsxs(Styled.ProgressPanelActions, {
55
+ children: [/*#__PURE__*/_jsx(Styled.ProgressPanelIconButton, {
56
+ onClick: togglePanel,
57
+ size: "xs",
58
+ color: "basic",
59
+ children: function children(iconProps) {
60
+ return /*#__PURE__*/_jsx(Styled.Arrow, _objectSpread(_objectSpread({}, iconProps), {}, {
61
+ $isMinimized: isPanelMinimized,
62
+ size: 12
63
+ }));
64
+ }
65
+ }), !isPanelActive && /*#__PURE__*/_jsx(Styled.ProgressPanelIconButton, {
66
+ onClick: closeProgressPanel,
67
+ size: "xs",
68
+ color: "basic",
69
+ children: function children(iconProps) {
70
+ return /*#__PURE__*/_jsx(Cross, _objectSpread(_objectSpread({}, iconProps), {}, {
71
+ size: 12
72
+ }));
73
+ }
74
+ })]
75
+ })]
76
+ });
77
+ };
78
+ export default ProgressPanelHeader;
@@ -0,0 +1,19 @@
1
+ import { useSelector } from 'react-redux';
2
+ import { selectProgressPanelActivityById } from '../progressPanel.slice';
3
+ import Activity from './Activity';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ var ProgressPanelItem = function ProgressPanelItem(_ref) {
6
+ var activityId = _ref.activityId,
7
+ index = _ref.index,
8
+ itemsCount = _ref.itemsCount,
9
+ i18n = _ref.i18n;
10
+ var activity = useSelector(function (state) {
11
+ return selectProgressPanelActivityById(state, activityId);
12
+ });
13
+ return /*#__PURE__*/_jsx(Activity, {
14
+ activity: activity,
15
+ isLastItem: index === itemsCount - 1,
16
+ i18n: i18n
17
+ }, activity.id);
18
+ };
19
+ export default ProgressPanelItem;
@@ -0,0 +1,36 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { Reload } from '@scaleflex/icons';
8
+ import { useCore } from '@scaleflex/widget-core/lib/hooks';
9
+ import Styled from '../ProgressPanel.styled';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ var RetryButton = function RetryButton(_ref) {
12
+ var id = _ref.id,
13
+ i18n = _ref.i18n;
14
+ var _useCore = useCore(),
15
+ emit = _useCore.emit;
16
+ var handleRetry = function handleRetry() {
17
+ emit('activity-retry', {
18
+ id: id
19
+ });
20
+ };
21
+ return /*#__PURE__*/_jsx(Styled.ActionButton, {
22
+ size: "sm",
23
+ color: "primary",
24
+ onClick: function onClick() {
25
+ return handleRetry();
26
+ },
27
+ "aria-label": i18n('progressPanelErrorActionTitle'),
28
+ title: i18n('progressPanelErrorActionTitle'),
29
+ children: function children(iconProps) {
30
+ return /*#__PURE__*/_jsx(Reload, _objectSpread(_objectSpread({}, iconProps), {}, {
31
+ size: 12
32
+ }));
33
+ }
34
+ });
35
+ };
36
+ export default RetryButton;
@@ -0,0 +1,26 @@
1
+ import { useTheme } from '@scaleflex/ui/theme/hooks';
2
+ import { Info } from '@scaleflex/icons';
3
+ import { PC } from '@scaleflex/widget-common';
4
+ import Styled from '../ProgressPanel.styled';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ var UploadDelayedNotification = function UploadDelayedNotification(_ref) {
7
+ var _theme$palette, _theme$palette2;
8
+ var i18n = _ref.i18n;
9
+ var theme = useTheme();
10
+ return /*#__PURE__*/_jsx(Styled.NotificationContainer, {
11
+ children: /*#__PURE__*/_jsx(Styled.ProgressPanelActivityWrapper, {
12
+ children: /*#__PURE__*/_jsxs(Styled.NotificationWrapper, {
13
+ children: [/*#__PURE__*/_jsx(Info, {
14
+ size: 22,
15
+ color: theme === null || theme === void 0 ? void 0 : (_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette[PC.Info]
16
+ }), /*#__PURE__*/_jsx(Styled.NotificationText, {
17
+ children: i18n('uploadDelayedHint')
18
+ }), /*#__PURE__*/_jsx(Styled.LoadingIcon, {
19
+ size: 22,
20
+ color: theme === null || theme === void 0 ? void 0 : (_theme$palette2 = theme.palette) === null || _theme$palette2 === void 0 ? void 0 : _theme$palette2[PC.AccentPrimary]
21
+ })]
22
+ })
23
+ })
24
+ });
25
+ };
26
+ export default UploadDelayedNotification;
@@ -0,0 +1,40 @@
1
+ import { FILE_TYPES_AND_ICONS } from '@scaleflex/widget-utils/lib/constants';
2
+ import getFileExtension from '@scaleflex/widget-utils/lib/getFileExtension';
3
+ import { useTheme } from '@scaleflex/ui/theme/hooks';
4
+ import mimeTypes from '@scaleflex/widget-utils/lib/mimeTypes';
5
+ import Styled from '../../ProgressPanel.styled';
6
+ import { ACTIVITY_ICONS, PROGRESS_PANEL_FILE_ICONS, PROGRESS_PANEL_FILE_ICON_BY_EXT } from '../../ProgressPanel.constants';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ var ProgressPanelFileIcon = function ProgressPanelFileIcon(_ref) {
9
+ var _mimeTypes$extension;
10
+ var file = _ref.file,
11
+ activity = _ref.activity;
12
+ var theme = useTheme();
13
+ var _ref2 = activity || {},
14
+ _ref2$icon = _ref2.icon,
15
+ icon = _ref2$icon === void 0 ? {} : _ref2$icon;
16
+ var ActivityIcon = ACTIVITY_ICONS[icon.name];
17
+ var themePalette = theme === null || theme === void 0 ? void 0 : theme.palette;
18
+ if (ActivityIcon) {
19
+ return /*#__PURE__*/_jsx(ActivityIcon, {
20
+ size: 22,
21
+ color: themePalette[icon.color]
22
+ });
23
+ }
24
+ var extension = getFileExtension(file || activity);
25
+ var type = (_mimeTypes$extension = mimeTypes[extension]) === null || _mimeTypes$extension === void 0 ? void 0 : _mimeTypes$extension.split('/')[0];
26
+ var fileIcon = PROGRESS_PANEL_FILE_ICONS[type] || PROGRESS_PANEL_FILE_ICON_BY_EXT[extension] || {};
27
+ var Icon = fileIcon.icon;
28
+ var iconColor = fileIcon.iconColor;
29
+ if (Icon) {
30
+ return /*#__PURE__*/_jsx(Icon, {
31
+ size: 22,
32
+ color: themePalette[iconColor]
33
+ });
34
+ }
35
+ return /*#__PURE__*/_jsx(Styled.FileIcon, {
36
+ alt: "icon",
37
+ src: FILE_TYPES_AND_ICONS[extension] || FILE_TYPES_AND_ICONS._default
38
+ });
39
+ };
40
+ export default ProgressPanelFileIcon;
@@ -0,0 +1,50 @@
1
+ export default {
2
+ progressPanelProcessingHeaderLabel: 'Processing',
3
+ progressPanelProcessedHeaderLabel: 'Processed',
4
+ progressPanelHeaderItemsText: {
5
+ 0: 'item',
6
+ 1: 'items'
7
+ },
8
+ progressPanelEtaLeftText: '%{time} left',
9
+ progressPanelActivityCompleteLabel: 'Uploaded',
10
+ progressPanelActivityErrorLabel: 'Uploading failed',
11
+ progressPanelActivityProgressLabel: 'Uploading',
12
+ progressPanelCompleteActionTitle: 'Show file location',
13
+ progressPanelVideoActivityCompleteActionTitle: 'Show link',
14
+ progressPanelErrorActionTitle: 'Retry',
15
+ progressPanelProgressActionTitle: 'Cancel',
16
+ progressPanelPauseActionTitle: 'Pause',
17
+ progressPanelResumeActionTitle: 'Resume',
18
+ progressPanelAssetProcessingTitle: 'Asset is being processed',
19
+ uploadDelayedHint: 'It takes few seconds to complete processing, after you can use your uploaded assets.',
20
+ progressPanelArchiveCompleteLabel: 'Completed archive',
21
+ progressPanelArchiveFailedLabel: 'Failed archive',
22
+ progressPanelPreparingArchiveLabel: 'Preparing archive',
23
+ progressPanelRestoringArchiveActivityLabel: 'Restoring archiving',
24
+ progressPanelDownloadingArchiveLabel: 'Downloading archive',
25
+ progressPanelDownloadingActivityLabel: 'Downloading',
26
+ progressPanelDownloadingActivityErrorLabel: 'Downloading failed',
27
+ progressPanelDownloadingActivityCompleteLabel: 'Downloaded',
28
+ progressPanelTranscodeActivityLabel: 'Transcoding',
29
+ progressPanelRestoringTranscodeActivityLabel: 'Restoring transcoding',
30
+ progressPanelTranscodedActivityLabel: 'Transcoded',
31
+ progressPanelTranscodeErrorActivityLabel: 'Transcoding failed',
32
+ progressPanelCompressActivityLabel: 'Compressing',
33
+ progressPanelRestoringCompressActivityLabel: 'Restoring compression',
34
+ progressPanelCompressedActivityLabel: 'Compressed',
35
+ progressPanelCompressErrorActivityLabel: 'Compressing failed',
36
+ progressPanelConvertActivityLabel: 'Converting',
37
+ progressPanelRestoringConvertActivityLabel: 'Restoring conversion',
38
+ progressPanelConvertedActivityLabel: 'Converted',
39
+ progressPanelConvertErrorActivityLabel: 'Converting failed',
40
+ progressPanelPreparingCsvActivityLabel: 'Preparing CSV',
41
+ progressPanelProcessingCsvActivityLabel: 'Processing CSV',
42
+ progressPanelProcessingCsvActivityErrorLabel: 'Processing CSV failed',
43
+ progressPanelProcessedCsvActivityLabel: 'Processed CSV',
44
+ progressPanelActivityFontProgressLabel: 'Installing font(s)',
45
+ progressPanelActivityFontCompleteLabel: 'Font installed',
46
+ progressPanelActivityFontErrorLabel: 'Font already installed',
47
+ progressPanelPreparingVideoLabel: 'Processing',
48
+ progressPanelVideoFailedLabel: 'Processing failed',
49
+ progressPanelVideoCompletedLabel: 'Processed'
50
+ };
package/lib/index.js ADDED
@@ -0,0 +1,120 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
5
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
6
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
9
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
10
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
12
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
13
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
14
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
+ import { createElement } from 'react';
18
+ import { Plugin } from '@scaleflex/widget-core';
19
+ import Translator from '@scaleflex/widget-utils/lib/Translator';
20
+ import { PLUGINS_IDS, EVENTS } from '@scaleflex/widget-utils/lib/constants';
21
+ import progressPanelReducer, { addActivity as _addActivity, selectProgressPanelUploadingActivitiesIds } from './progressPanel.slice';
22
+ import ProgressPanelUI from './components/ProgressPanel';
23
+ import defaultLocale from './defaultLocale';
24
+ import { getSavedActivities } from './utils/locallySavedActivities';
25
+
26
+ // TODO: find a way to show version of the current plugin
27
+ // why solution below isn't good?
28
+ // first import doesn't work with webpack 5 as it was deprecated
29
+ // second import fixes webpack 5 issue as it was mentioned in their docs
30
+ // but it exposes our package.json to the client and it is mentioned as security rist in mutiple places
31
+ // https://github.com/axelpale/genversion
32
+ // https://stackoverflow.com/questions/64993118/error-should-not-import-the-named-export-version-imported-as-version
33
+ // https://stackoverflow.com/questions/9153571/is-there-a-way-to-get-version-from-package-json-in-nodejs-code/10855054#10855054
34
+ // import { version } from '../package.json'
35
+ // import packageInfo from '../package.json'
36
+ var ProgressPanel = /*#__PURE__*/function (_Plugin) {
37
+ // static VERSION = packageInfo.version
38
+
39
+ function ProgressPanel(filerobot) {
40
+ var _this;
41
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
42
+ _classCallCheck(this, ProgressPanel);
43
+ _this = _callSuper(this, ProgressPanel, [filerobot, opts]);
44
+ _defineProperty(_this, "addTarget", function () {
45
+ return _this.el;
46
+ });
47
+ _defineProperty(_this, "render", function (props) {
48
+ return /*#__PURE__*/createElement(ProgressPanelUI, _objectSpread(_objectSpread({}, props), {}, {
49
+ i18n: _this.i18n
50
+ }));
51
+ });
52
+ _defineProperty(_this, "loadSavedActivities", function (cbk) {
53
+ var token = _this.filerobot.opts.container;
54
+ var savedActivities = getSavedActivities(token);
55
+ if (Array.isArray(savedActivities) && savedActivities.length > 0 && typeof cbk === 'function') {
56
+ cbk(savedActivities);
57
+ }
58
+ });
59
+ _defineProperty(_this, "initEvents", function () {
60
+ _this.filerobot.on(EVENTS.PROGRESS_PANEL_LOAD_SAVED_ACTIVITIES, _this.loadSavedActivities);
61
+ });
62
+ _defineProperty(_this, "removeEvents", function () {
63
+ _this.filerobot.off(EVENTS.PROGRESS_PANEL_LOAD_SAVED_ACTIVITIES, _this.loadSavedActivities);
64
+ });
65
+ _this.id = opts.id || PLUGINS_IDS.PROGRESS_PANEL;
66
+ _this.title = 'ProgressPanel';
67
+ _this.type = 'progressindicator';
68
+ _this.defaultLocale = {
69
+ strings: defaultLocale
70
+ };
71
+ _this.i18nInit();
72
+ _this.opts = _objectSpread({}, opts);
73
+ _this.addActivity = _this.addActivity.bind(_this);
74
+ _this.getUploadingActivitiesIds = _this.getUploadingActivitiesIds.bind(_this);
75
+ return _this;
76
+ }
77
+ _inherits(ProgressPanel, _Plugin);
78
+ return _createClass(ProgressPanel, [{
79
+ key: "i18nInit",
80
+ value: function i18nInit() {
81
+ this.translator = new Translator([this.defaultLocale, this.filerobot.locale, this.opts.locale]);
82
+ this.i18n = this.translator.translate.bind(this.translator);
83
+ }
84
+ }, {
85
+ key: "getPluginReducer",
86
+ value: function getPluginReducer() {
87
+ return progressPanelReducer;
88
+ }
89
+ }, {
90
+ key: "addActivity",
91
+ value: function addActivity(activity) {
92
+ return this.dispatch(_addActivity(activity));
93
+ }
94
+ }, {
95
+ key: "getUploadingActivitiesIds",
96
+ value: function getUploadingActivitiesIds() {
97
+ return selectProgressPanelUploadingActivitiesIds(this.getGlobalState());
98
+ }
99
+ }, {
100
+ key: "install",
101
+ value: function install() {
102
+ var target = this.opts.target || this.filerobot.getPlugin(PLUGINS_IDS.EXPLORER);
103
+ if (target) {
104
+ this.mount(target, this);
105
+ }
106
+ }
107
+ }, {
108
+ key: "onMount",
109
+ value: function onMount() {
110
+ this.initEvents();
111
+ }
112
+ }, {
113
+ key: "uninstall",
114
+ value: function uninstall() {
115
+ this.unmount();
116
+ this.removeEvents();
117
+ }
118
+ }]);
119
+ }(Plugin);
120
+ export { ProgressPanel as default };