@scaleflex/widget-progress-panel 4.4.0 → 4.5.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.5.0](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.4.0...v4.5.0) (2025-10-08)
7
+
8
+ **Note:** Version bump only for package @scaleflex/widget-progress-panel
9
+
10
+
11
+
12
+
13
+
6
14
  # [4.4.0](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.1.0...v4.4.0) (2025-10-07)
7
15
 
8
16
  **Note:** Version bump only for package @scaleflex/widget-progress-panel
@@ -0,0 +1,84 @@
1
+ import { Divider } from '@scaleflex/ui/core';
2
+ import { PROGRESS_PANEL_STATUS } from '@scaleflex/widget-utils/lib/constants';
3
+ import { useCore } from '@scaleflex/widget-core/lib/hooks';
4
+ import { isProgressPanelActive } from '../progressPanel.slice';
5
+ import ActivityActions from './ActivityActions';
6
+ import ActivityStatus from './ActivityStatus';
7
+ import ProgressPanelFileIcon from './common/ProgressPanelFileIcon';
8
+ import Styled from '../ProgressPanel.styled';
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ var Activity = function Activity(_ref) {
11
+ var _activity$progress, _activity$progress2, _statusData$status, _statusData$PROGRESS_, _statusData$PROGRESS_2, _statusData$status2;
12
+ var activity = _ref.activity,
13
+ isLastItem = _ref.isLastItem,
14
+ i18n = _ref.i18n,
15
+ role = _ref.role;
16
+ var _useCore = useCore(),
17
+ emit = _useCore.emit;
18
+ var id = activity.id,
19
+ _activity$statusData = activity.statusData,
20
+ statusData = _activity$statusData === void 0 ? {} : _activity$statusData,
21
+ name = activity.name,
22
+ _activity$hideRetryBu = activity.hideRetryButton,
23
+ hideRetryButton = _activity$hideRetryBu === void 0 ? false : _activity$hideRetryBu;
24
+ var percentage = activity === null || activity === void 0 ? void 0 : (_activity$progress = activity.progress) === null || _activity$progress === void 0 ? void 0 : _activity$progress.percentage;
25
+ var status = activity === null || activity === void 0 ? void 0 : (_activity$progress2 = activity.progress) === null || _activity$progress2 === void 0 ? void 0 : _activity$progress2.status;
26
+ var isStatusComplete = status === PROGRESS_PANEL_STATUS.COMPLETE;
27
+ var actionButtons = (_statusData$status = statusData[status]) === null || _statusData$status === void 0 ? void 0 : _statusData$status.actionButtons;
28
+ var completeActionButton = (_statusData$PROGRESS_ = statusData[PROGRESS_PANEL_STATUS.COMPLETE]) === null || _statusData$PROGRESS_ === void 0 ? void 0 : (_statusData$PROGRESS_2 = _statusData$PROGRESS_.actionButtons) === null || _statusData$PROGRESS_2 === void 0 ? void 0 : _statusData$PROGRESS_2[0];
29
+ var hasCompleteActionButtons = isStatusComplete && !!completeActionButton;
30
+ var almostCompleted = status === PROGRESS_PANEL_STATUS.PROGRESSING && percentage === 100;
31
+ var isErrorStatus = status === PROGRESS_PANEL_STATUS.ERROR;
32
+ var hideActivityRetryButton = isErrorStatus && hideRetryButton;
33
+ var handleAction = function handleAction(event, activityActionType) {
34
+ event.stopPropagation();
35
+ emit('activity-action', {
36
+ id: id,
37
+ activity: activity,
38
+ activityActionType: activityActionType
39
+ });
40
+ };
41
+ var activityStatusLabel = i18n((_statusData$status2 = statusData[status]) === null || _statusData$status2 === void 0 ? void 0 : _statusData$status2.labelI18nKey);
42
+ var activityTitle = name || activityStatusLabel || status;
43
+ return /*#__PURE__*/_jsxs(Styled.ProgressPanelActivityContainerNew, {
44
+ showActivityButton: !hideActivityRetryButton,
45
+ disableAction: isStatusComplete && !actionButtons || almostCompleted,
46
+ showBackgroundHover: hasCompleteActionButtons,
47
+ onClick: hasCompleteActionButtons ? function (event) {
48
+ return handleAction(event, completeActionButton.type);
49
+ } : undefined,
50
+ role: role,
51
+ children: [/*#__PURE__*/_jsx(Styled.ProgressPanelActivityWrapper, {
52
+ children: /*#__PURE__*/_jsxs(Styled.ProgressPanelActivity, {
53
+ children: [/*#__PURE__*/_jsxs(Styled.ActivityInfo, {
54
+ $opacity: isProgressPanelActive(status) && 0.7,
55
+ "aria-label": activityTitle,
56
+ title: activityTitle,
57
+ children: [/*#__PURE__*/_jsx(ProgressPanelFileIcon, {
58
+ activity: activity
59
+ }), /*#__PURE__*/_jsxs(Styled.ActivityInfoMain, {
60
+ children: [/*#__PURE__*/_jsx(Styled.ActivityFileState, {
61
+ children: activityStatusLabel
62
+ }), name && /*#__PURE__*/_jsx(Styled.ActivityFileName, {
63
+ children: name
64
+ })]
65
+ })]
66
+ }), !almostCompleted && /*#__PURE__*/_jsx(ActivityActions, {
67
+ hideRetryButton: hideRetryButton,
68
+ id: id,
69
+ status: status,
70
+ i18n: i18n,
71
+ actionButtons: actionButtons,
72
+ handleAction: handleAction
73
+ }), /*#__PURE__*/_jsx(ActivityStatus, {
74
+ status: status,
75
+ statusTitle: activityStatusLabel,
76
+ percentage: percentage,
77
+ almostCompleted: almostCompleted,
78
+ i18n: i18n
79
+ })]
80
+ })
81
+ }), !isLastItem && /*#__PURE__*/_jsx(Divider, {})]
82
+ });
83
+ };
84
+ export default Activity;
@@ -0,0 +1,63 @@
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 { PROGRESS_PANEL_STATUS } from '@scaleflex/widget-utils/lib/constants';
8
+ import CancelButton from './CancelButton';
9
+ import { ACTIVITY_BUTTON_ICONS } from '../ProgressPanel.constants';
10
+ import RetryButton from './RetryButton';
11
+ import Styled from '../ProgressPanel.styled';
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ var ActivityActions = function ActivityActions(_ref) {
14
+ var _activityActions$stat;
15
+ var id = _ref.id,
16
+ status = _ref.status,
17
+ actionButtons = _ref.actionButtons,
18
+ i18n = _ref.i18n,
19
+ handleAction = _ref.handleAction,
20
+ hideRetryButton = _ref.hideRetryButton;
21
+ var activityActions = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, PROGRESS_PANEL_STATUS.PREPARING, function () {
22
+ return /*#__PURE__*/_jsx(CancelButton, {
23
+ id: id,
24
+ i18n: i18n
25
+ });
26
+ }), PROGRESS_PANEL_STATUS.PROGRESSING, function () {
27
+ return /*#__PURE__*/_jsx(CancelButton, {
28
+ id: id,
29
+ i18n: i18n
30
+ });
31
+ }), PROGRESS_PANEL_STATUS.PAUSED, function () {
32
+ return /*#__PURE__*/_jsx(CancelButton, {
33
+ id: id,
34
+ i18n: i18n
35
+ });
36
+ }), PROGRESS_PANEL_STATUS.ERROR, function () {
37
+ return !hideRetryButton && /*#__PURE__*/_jsx(RetryButton, {
38
+ id: id,
39
+ i18n: i18n
40
+ });
41
+ });
42
+ return /*#__PURE__*/_jsxs(Styled.ActionButtonsWrapper, {
43
+ children: [(_activityActions$stat = activityActions[status]) === null || _activityActions$stat === void 0 ? void 0 : _activityActions$stat.call(activityActions), actionButtons && actionButtons.map(function (button) {
44
+ var ButtonIcon = ACTIVITY_BUTTON_ICONS[button.icon];
45
+ return ButtonIcon && /*#__PURE__*/_jsx(Styled.ActionButton, {
46
+ size: "sm",
47
+ color: "primary",
48
+ onClick: function onClick(event) {
49
+ return handleAction(event, button.type);
50
+ },
51
+ "aria-label": i18n(button.titleI18nKey),
52
+ title: i18n(button.titleI18nKey),
53
+ isResumeButton: button.type === 'play',
54
+ children: function children(iconProps) {
55
+ return /*#__PURE__*/_jsx(ButtonIcon, _objectSpread(_objectSpread({}, iconProps), {}, {
56
+ size: 12
57
+ }));
58
+ }
59
+ }, i18n(button.titleI18nKey));
60
+ })]
61
+ });
62
+ };
63
+ export default ActivityActions;
@@ -0,0 +1,39 @@
1
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
2
+ function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
3
+ import styled, { css, keyframes } from 'styled-components';
4
+ import { PC } from '@scaleflex/widget-common';
5
+ var circulate = keyframes({
6
+ '0%': {
7
+ // let the progress start at the top of the ring
8
+ transform: 'rotate(-90deg)'
9
+ },
10
+ '100%': {
11
+ transform: 'rotate(270deg)'
12
+ }
13
+ });
14
+ var CircularProgressRoot = styled.span(function (_ref) {
15
+ var palette = _ref.theme.palette,
16
+ determinate = _ref.determinate;
17
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-block;\n width: 22px;\n height: 22px;\n color: ", ";\n\n ", "\n\n ", "\n"])), palette[PC.Success], determinate && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n transform: rotate(-90deg);\n transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n "]))), !determinate && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["animation: 0.5s linear 0s infinite normal none running ", ";"])), circulate));
18
+ });
19
+ var CircularProgressSvg = styled.svg(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: block\n"])));
20
+ var CircularProgressTrack = styled.circle(function (_ref2) {
21
+ var palette = _ref2.theme.palette,
22
+ size = _ref2.size,
23
+ thickness = _ref2.thickness;
24
+ return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n cx: ", ";\n cy: ", ";\n r: ", ";\n fill: transparent;\n stroke: ", ";\n stroke-width: ", " ;\n"])), size, size, (size - thickness) / 2, palette[PC.BackgroundGrey], thickness);
25
+ });
26
+ var CircularProgress = styled.circle(function (_ref3) {
27
+ var size = _ref3.size,
28
+ thickness = _ref3.thickness,
29
+ strokeDasharray = _ref3.strokeDasharray,
30
+ strokeDashoffset = _ref3.strokeDashoffset;
31
+ return css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n cx: ", ";\n cy: ", ";\n r: ", ";\n fill: none;\n stroke: currentColor;\n stroke-dasharray: ", ";\n stroke-dashoffset: ", ";\n stroke-width: ", " ;\n transition: stroke-dashoffset 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n"])), size, size, (size - thickness) / 2, strokeDasharray, strokeDashoffset, thickness);
32
+ });
33
+ var Styled = {
34
+ CircularProgressRoot: CircularProgressRoot,
35
+ CircularProgress: CircularProgress,
36
+ CircularProgressTrack: CircularProgressTrack,
37
+ CircularProgressSvg: CircularProgressSvg
38
+ };
39
+ export default Styled;
@@ -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,71 @@
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
+ role: "dialog",
52
+ "aria-label": "Progress panel",
53
+ children: [/*#__PURE__*/_jsx(ProgressPanelHeader, {
54
+ i18n: i18n
55
+ }), progressPanelDelayedActivitiesIds.length > 0 && /*#__PURE__*/_jsx(UploadDelayedNotification, {
56
+ i18n: i18n
57
+ }), !isPanelMinimized && /*#__PURE__*/_jsx(Styled.ProgressPanelList, {
58
+ role: "list",
59
+ children: /*#__PURE__*/_jsx(VirtualList, {
60
+ items: progressPanelActivitiesIds,
61
+ injectedItemPropName: "activityId",
62
+ children: /*#__PURE__*/_jsx(ProgressPanelItem, {
63
+ itemsCount: progressPanelActivitiesIds.length,
64
+ i18n: i18n,
65
+ role: "listitem"
66
+ })
67
+ })
68
+ })]
69
+ });
70
+ };
71
+ 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,21 @@
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
+ role = _ref.role;
11
+ var activity = useSelector(function (state) {
12
+ return selectProgressPanelActivityById(state, activityId);
13
+ });
14
+ return /*#__PURE__*/_jsx(Activity, {
15
+ activity: activity,
16
+ isLastItem: index === itemsCount - 1,
17
+ i18n: i18n,
18
+ role: role
19
+ }, activity.id);
20
+ };
21
+ 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,64 @@
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
+ var ACTIVITIES_STORAGE_KEY = 'activities';
8
+ export var getActivitiesStorageName = function getActivitiesStorageName(token) {
9
+ return "FMAW_".concat(token || '', "_").concat(ACTIVITIES_STORAGE_KEY);
10
+ };
11
+ export var getSavedActivities = function getSavedActivities(token) {
12
+ var _window;
13
+ if (!((_window = window) !== null && _window !== void 0 && _window.localStorage) || !token) {
14
+ return [];
15
+ }
16
+ try {
17
+ var loadedActivities = JSON.parse(window.localStorage.getItem(getActivitiesStorageName(token))) || [];
18
+ return loadedActivities;
19
+ } catch (_unused) {
20
+ return [];
21
+ }
22
+ };
23
+ export var pushToSavedActivities = function pushToSavedActivities(token) {
24
+ var _window2;
25
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
26
+ id = _ref.id,
27
+ type = _ref.type,
28
+ name = _ref.name,
29
+ data = _ref.data;
30
+ if (!((_window2 = window) !== null && _window2 !== void 0 && _window2.localStorage) || !token || !id || !type || !data || Object.keys(data || {}).length === 0) {
31
+ return;
32
+ }
33
+ var loadedActivities = getSavedActivities(token).filter(function (activity) {
34
+ return activity.id !== id;
35
+ });
36
+ var pushedActivity = _objectSpread(_objectSpread({
37
+ id: id,
38
+ type: type
39
+ }, name && {
40
+ name: name
41
+ }), {}, {
42
+ data: data
43
+ });
44
+ loadedActivities.push(pushedActivity);
45
+ window.localStorage.setItem(getActivitiesStorageName(token), JSON.stringify(loadedActivities));
46
+ return loadedActivities;
47
+ };
48
+ export var removeSavedActivity = function removeSavedActivity(token, id) {
49
+ var _window3;
50
+ if (!((_window3 = window) !== null && _window3 !== void 0 && _window3.localStorage) || !token || !id) {
51
+ return;
52
+ }
53
+ var loadedActivities = getSavedActivities(token);
54
+ var newActivities = loadedActivities.filter(function () {
55
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
56
+ _id = _ref2.id;
57
+ return _id !== id;
58
+ });
59
+ if (newActivities.length === 0) {
60
+ window.localStorage.removeItem(getActivitiesStorageName(token));
61
+ return;
62
+ }
63
+ window.localStorage.setItem(getActivitiesStorageName(token), JSON.stringify(newActivities));
64
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scaleflex/widget-progress-panel",
3
3
  "description": "A progress panel for Scaleflex, handles upload, download, video transformation operation simultaneously",
4
- "version": "4.4.0",
4
+ "version": "4.5.0",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
7
7
  "style": "dist/style.min.css",
@@ -15,9 +15,9 @@
15
15
  "access": "public"
16
16
  },
17
17
  "dependencies": {
18
- "@scaleflex/widget-common": "^4.4.0",
19
- "@scaleflex/widget-informer": "^4.4.0",
20
- "@scaleflex/widget-utils": "^4.4.0",
18
+ "@scaleflex/widget-common": "^4.5.0",
19
+ "@scaleflex/widget-informer": "^4.5.0",
20
+ "@scaleflex/widget-utils": "^4.5.0",
21
21
  "lodash.throttle": "^4.1.1"
22
22
  },
23
23
  "devDependencies": {
@@ -29,5 +29,5 @@
29
29
  "react": ">=19.0.0",
30
30
  "react-dom": ">=19.0.0"
31
31
  },
32
- "gitHead": "04b8ec545c4f10be89f5a44eed954acf8433360c"
32
+ "gitHead": "df64ca68034ed6c33e123e7dfa215176aa0a1196"
33
33
  }