@scaleflex/widget-explorer 4.5.0 → 4.5.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.
- package/CHANGELOG.md +11 -0
- package/README.md +21 -3
- package/lib/components/ActionBar/DownloadWithExportButton.js +32 -4
- package/lib/components/AssetsList/ListView/AssetsSection/AssetsSectionTableRow.js +1 -1
- package/lib/components/Breadcrumbs/index.js +114 -6
- package/lib/components/CollectionsView/CollectionFolderIcon.js +35 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/CollectionTreeSkeletion.js +26 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/CollectionVirtualFoldersTree.styled.js +52 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/CollectionVirtualFoldersTree.utils.js +24 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/Folder.js +88 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/Tree.js +50 -0
- package/lib/components/CollectionsView/CollectionVirtualFoldersTree/index.js +75 -0
- package/lib/components/CollectionsView/CollectionsSkeleton.js +30 -0
- package/lib/components/CollectionsView/CollectionsTree/ActiveCollectionContent.js +61 -0
- package/lib/components/CollectionsView/CollectionsTree/CollectionTreeItem.js +44 -0
- package/lib/components/CollectionsView/CollectionsTree/CollectionsContent.js +130 -0
- package/lib/components/CollectionsView/CollectionsTree/CollectionsTree.styled.js +84 -0
- package/lib/components/CollectionsView/CollectionsTree/index.js +47 -0
- package/lib/components/CollectionsView/CollectionsView.styled.js +38 -0
- package/lib/components/CollectionsView/VirtualFoldersGrid.js +67 -0
- package/lib/components/CollectionsView/index.js +188 -0
- package/lib/components/Details/Details.constants.js +1 -0
- package/lib/components/FileItem/FileInfo/index.js +8 -2
- package/lib/components/FileWindowPanel/FileTabs/VariationsTab/VariationsTabNavigator.js +1 -7
- package/lib/components/FileWindowPanel/FileTabs/VariationsTab/index.js +4 -1
- package/lib/components/FileWindowPanel/Header/index.js +9 -0
- package/lib/components/Filters/hooks/useFilters.js +3 -2
- package/lib/components/HeaderBar/index.js +6 -2
- package/lib/components/LabelsView/LabelsTree/LabelsTree.styled.js +86 -0
- package/lib/components/LabelsView/LabelsTree/LabelsTreeSkeleton.js +21 -0
- package/lib/components/LabelsView/LabelsTree/index.js +128 -0
- package/lib/components/LabelsView/LabelsView.styled.js +10 -0
- package/lib/components/LabelsView/index.js +139 -0
- package/lib/components/Modals/DownloadConsent/DownloadConsent.hooks.js +11 -0
- package/lib/components/Modals/TransformedDownload/TransformedDownload.hooks.js +9 -0
- package/lib/components/Views/Views.constants.js +30 -4
- package/lib/components/Views/index.js +11 -4
- package/lib/components/common/FileMetadataFieldValue/GeneralMetadataFieldValue.js +1 -1
- package/lib/components/common/Sort/Sort.constants.js +28 -1
- package/lib/defaultLocale.js +36 -1
- package/lib/slices/collections.slice.js +714 -0
- package/lib/slices/common.slice.js +15 -52
- package/lib/slices/files.slice.js +6 -3
- package/lib/slices/index.js +5 -1
- package/lib/slices/labels.slice.js +652 -0
- package/lib/slices/views.slice.js +12 -0
- package/lib/utils/prepareSearchUrl.js +10 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.1](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.5.0...v4.5.1) (2025-10-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update active variant handling in VariationsTab ([d631729](https://code.scaleflex.cloud/scaleflex/widget/commits/d631729d5646779218008844a92edadeee686d47))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [4.5.0](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.4.0...v4.5.0) (2025-10-08)
|
|
7
18
|
|
|
8
19
|
|
package/README.md
CHANGED
|
@@ -381,7 +381,7 @@ List of file UUIDs with the state "muted". These files cannot be selected or hav
|
|
|
381
381
|
|
|
382
382
|
<u>Type:</u> `array`.
|
|
383
383
|
|
|
384
|
-
<u>Default:</u> `['ASSETS', 'FOLDERS']`
|
|
384
|
+
<u>Default:</u> `['ASSETS', 'FOLDERS', 'LABELS', 'COLLECTIONS']`
|
|
385
385
|
|
|
386
386
|
List of available views.
|
|
387
387
|
|
|
@@ -401,7 +401,7 @@ View which will be currently opened.
|
|
|
401
401
|
|
|
402
402
|
<u>Default:</u> `null`
|
|
403
403
|
|
|
404
|
-
Open the provided view's item/object for ex. (folders view => folder path, labels view => label sid or uuid ...etc.)
|
|
404
|
+
Open the provided view's item/object for ex. (folders view => folder path, labels view => label sid or uuid, collections view => collection uuid...etc.)
|
|
405
405
|
|
|
406
406
|
> Note: No auto redirect to the view, you have to provide the proper view from [`view prop`](#view).
|
|
407
407
|
|
|
@@ -411,7 +411,7 @@ Open the provided view's item/object for ex. (folders view => folder path, label
|
|
|
411
411
|
|
|
412
412
|
<u>Default:</u> `null`
|
|
413
413
|
|
|
414
|
-
A sub item that should be opened inside the provided [`view`](#view) & [`viewItem`](#viewitem).
|
|
414
|
+
A sub item that should be opened inside the provided [`view`](#view) & [`viewItem`](#viewitem), mostly used for opening a collection virtual folder that's found inside some collection.
|
|
415
415
|
|
|
416
416
|
> Note: No auto redirect to the view, you have to provide the proper view from [`view prop`](#view).
|
|
417
417
|
|
|
@@ -708,6 +708,24 @@ Shows/hides on initial load the folder tree as a sidebar at the left of the plug
|
|
|
708
708
|
|
|
709
709
|
Shows/hides the asset details view as a sidebar at the right of the plugin to view various details about selected assets. The user can shows/hides the details view from the info icon in the right side of the breadcrumbs.
|
|
710
710
|
|
|
711
|
+
### `showCollectionsTree`
|
|
712
|
+
|
|
713
|
+
<u>Type:</u> `boolean`.
|
|
714
|
+
|
|
715
|
+
<u>Default:</u> `false`
|
|
716
|
+
|
|
717
|
+
Shows/hides the collection tree as a sidebar at the left of the plugin to navigate collections. The user can shows/hides the collection tree from the tree icon in the breadcrumbs.
|
|
718
|
+
|
|
719
|
+
> **_Only relevant if_** collection view is provided in [views](#views)
|
|
720
|
+
|
|
721
|
+
### `showLabelsTree`
|
|
722
|
+
|
|
723
|
+
<u>Type:</u> `boolean`.
|
|
724
|
+
|
|
725
|
+
<u>Default:</u> `false`
|
|
726
|
+
|
|
727
|
+
Shows/hides the label tree as a sidebar at the left of the plugin to navigate labels. The user can shows/hides the label tree from the tree icon in the breadcrumbs.
|
|
728
|
+
|
|
711
729
|
### `hideDetailsViewButton` ![asset-picker-supported] ![asset-manager-supported]
|
|
712
730
|
|
|
713
731
|
<u>Type:</u> `boolean`.
|
|
@@ -23,6 +23,9 @@ import { downloadOneFile, downloadItems, emitExportEvent } from '../../thunks/do
|
|
|
23
23
|
import { selectAllSelectedItems, selectFirstSelectedFileOrFolder, selectIsFolderSelected, selectSelectedFiles, selectionsCleared } from '../../slices/selections.slice';
|
|
24
24
|
import { useDownloadConsentModal, useTransformedDownloadModal } from '../Modals';
|
|
25
25
|
import Styled from './ActionBar.styled';
|
|
26
|
+
import { collectionsDeselected } from '../../slices/collections.slice';
|
|
27
|
+
import { selectIsCollectionsView, selectIsLabelsView } from '../../slices/views.slice';
|
|
28
|
+
import { downloadLabelAssets, labelsSelectionToggled, selectLabelsArray, selectLabelsSelectedUuids } from '../../slices/labels.slice';
|
|
26
29
|
import { ANIMATED_IMG_ACCEPT_HEADER } from '../../utils/constants';
|
|
27
30
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
28
31
|
var SIZE = 16;
|
|
@@ -41,6 +44,10 @@ var DownloadWithExportButton = function DownloadWithExportButton() {
|
|
|
41
44
|
var selectedFiles = useSelector(selectSelectedFiles);
|
|
42
45
|
var selectedItems = useSelector(selectAllSelectedItems);
|
|
43
46
|
var firstItem = useSelector(selectFirstSelectedFileOrFolder);
|
|
47
|
+
var isCollectionsView = useSelector(selectIsCollectionsView);
|
|
48
|
+
var isLabelsView = useSelector(selectIsLabelsView);
|
|
49
|
+
var labels = useSelector(selectLabelsArray);
|
|
50
|
+
var selectedLabelsUuids = useSelector(selectLabelsSelectedUuids);
|
|
44
51
|
var iconPrimaryColor = theme.palette[PC.IconsPrimary];
|
|
45
52
|
var disableDownloadButton = opts.disableDownloadButton,
|
|
46
53
|
preventDownloadDefaultBehavior = opts.preventDownloadDefaultBehavior,
|
|
@@ -52,13 +59,22 @@ var DownloadWithExportButton = function DownloadWithExportButton() {
|
|
|
52
59
|
exportOptionsMenuAnchor = _useState2[0],
|
|
53
60
|
setExportOptionsMenuAnchor = _useState2[1];
|
|
54
61
|
var menuRef = useRef(null);
|
|
62
|
+
var firstSelectedLabelAssetsCount = useMemo(function () {
|
|
63
|
+
var _labels$find;
|
|
64
|
+
return (selectedLabelsUuids === null || selectedLabelsUuids === void 0 ? void 0 : selectedLabelsUuids.length) === 1 && ((_labels$find = labels.find(function (label) {
|
|
65
|
+
return label.uuid === selectedLabelsUuids[0];
|
|
66
|
+
})) === null || _labels$find === void 0 ? void 0 : _labels$find.assets_count);
|
|
67
|
+
}, [selectedLabelsUuids, labels]);
|
|
55
68
|
var unsupportedExportReason = useMemo(function () {
|
|
56
69
|
return checkItemsSupportExportWithReason(selectedFiles);
|
|
57
70
|
}, [selectedFiles]);
|
|
58
71
|
var hideTransformation = isFolderSelected || !!unsupportedExportReason || hideDownloadVariationsOption;
|
|
59
72
|
var tooltipTitle = i18n(unsupportedExportReason);
|
|
60
|
-
var showDownloadButtonArrow = !disableDownloadButton && !isWidgetSmallSize && !useAssetsPicker;
|
|
61
|
-
var
|
|
73
|
+
var showDownloadButtonArrow = !disableDownloadButton && isCollectionsView && !isLabelsView && !isWidgetSmallSize && !useAssetsPicker;
|
|
74
|
+
var isSingleSelectedLabelWithAssets = (selectedLabelsUuids === null || selectedLabelsUuids === void 0 ? void 0 : selectedLabelsUuids.length) === 1 && !!firstSelectedLabelAssetsCount;
|
|
75
|
+
var isDownloadAllowedInLabelsView = !isLabelsView || isLabelsView && useAssetsPicker || isSingleSelectedLabelWithAssets;
|
|
76
|
+
var isDownloadAllowedInCollectionsView = !isCollectionsView || isCollectionsView && useAssetsPicker;
|
|
77
|
+
var downloadButtonVisible = isDownloadAllowedInLabelsView && isDownloadAllowedInCollectionsView && !preventDownloadDefaultBehavior;
|
|
62
78
|
var downloadButtonDisabled = !checkUserPermissions([PERMISSIONS.DISPLAY]) || !checkFileFolderPermissions({
|
|
63
79
|
permissionsToCheck: [PERMISSIONS.DISPLAY],
|
|
64
80
|
permissionsList: firstItem === null || firstItem === void 0 ? void 0 : firstItem.permissions
|
|
@@ -67,8 +83,15 @@ var DownloadWithExportButton = function DownloadWithExportButton() {
|
|
|
67
83
|
event.stopPropagation();
|
|
68
84
|
setExportOptionsMenuAnchor(exportOptionsMenuAnchor ? null : menuRef.current);
|
|
69
85
|
};
|
|
86
|
+
var deselectAllLabels = function deselectAllLabels() {
|
|
87
|
+
return dispatch(labelsSelectionToggled({
|
|
88
|
+
uuids: []
|
|
89
|
+
}));
|
|
90
|
+
};
|
|
70
91
|
var handleClearSelection = function handleClearSelection() {
|
|
71
92
|
dispatch(selectionsCleared());
|
|
93
|
+
deselectAllLabels();
|
|
94
|
+
dispatch(collectionsDeselected());
|
|
72
95
|
};
|
|
73
96
|
var emitExport = function emitExport() {
|
|
74
97
|
if (selectedItems.length > 0) {
|
|
@@ -93,8 +116,13 @@ var DownloadWithExportButton = function DownloadWithExportButton() {
|
|
|
93
116
|
}
|
|
94
117
|
};
|
|
95
118
|
var onClickDownload = function onClickDownload() {
|
|
119
|
+
if ((selectedLabelsUuids === null || selectedLabelsUuids === void 0 ? void 0 : selectedLabelsUuids.length) === 1) {
|
|
120
|
+
triggerDownloadConsentModal(function () {
|
|
121
|
+
return dispatch(downloadLabelAssets(selectedLabelsUuids[0]));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
96
124
|
setExportOptionsMenuAnchor(null);
|
|
97
|
-
if (!preventDownloadDefaultBehavior && !useAssetsPicker) {
|
|
125
|
+
if (!preventDownloadDefaultBehavior && (!isLabelsView || useAssetsPicker)) {
|
|
98
126
|
var isOneItem = selectedItems.length === 1;
|
|
99
127
|
var items = !isOneItem || isFolderSelected ? selectedItems : selectedItems[0];
|
|
100
128
|
triggerDownloadConsentModal(isOneItem && !isFolderSelected ? function () {
|
|
@@ -170,7 +198,7 @@ var DownloadWithExportButton = function DownloadWithExportButton() {
|
|
|
170
198
|
})
|
|
171
199
|
})
|
|
172
200
|
})]
|
|
173
|
-
}), !disableDownloadButton && /*#__PURE__*/_jsx(_Fragment, {
|
|
201
|
+
}), !disableDownloadButton && !isLabelsView && !isCollectionsView && /*#__PURE__*/_jsx(_Fragment, {
|
|
174
202
|
children: /*#__PURE__*/_jsxs(Menu, {
|
|
175
203
|
anchorEl: exportOptionsMenuAnchor,
|
|
176
204
|
open: Boolean(exportOptionsMenuAnchor),
|
|
@@ -38,7 +38,7 @@ import { selectActiveRegionalLang } from '../../../../slices/metadata.slice';
|
|
|
38
38
|
import { selectIsSimilarSearchActive, selectSearchQuery, selectSimilarSearchOriginalFile } from '../../../../slices/search.slice';
|
|
39
39
|
import StyledAssetsList from '../../AssetsList.styled';
|
|
40
40
|
import Styled from '../ListView.styled';
|
|
41
|
-
import { selectFileLabels } from '../../../../slices/
|
|
41
|
+
import { selectFileLabels } from '../../../../slices/labels.slice';
|
|
42
42
|
import { selectIsAssetsView, selectViewLayout } from '../../../../slices/views.slice';
|
|
43
43
|
import { selectCurrentFileByUuid } from '../../../../slices/files.slice';
|
|
44
44
|
import FileMetadataFieldValue from '../../../common/FileMetadataFieldValue';
|
|
@@ -16,14 +16,19 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
16
16
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
17
17
|
import { useState, useEffect, useMemo } from 'react';
|
|
18
18
|
import { useSelector, useDispatch } from 'react-redux';
|
|
19
|
-
import { FolderTree, More } from '@scaleflex/icons';
|
|
19
|
+
import { Bookmark, FolderTree, Label, More } from '@scaleflex/icons';
|
|
20
20
|
import { EllipsedText } from '@scaleflex/ui/core';
|
|
21
21
|
import ignoreEvent from '@scaleflex/widget-utils/lib/ignoreEvent';
|
|
22
|
+
import { useTheme } from '@scaleflex/ui/theme/hooks';
|
|
23
|
+
import { PC } from '@scaleflex/widget-common';
|
|
22
24
|
import { VIEW_OPTIONS } from '../Views/Views.constants';
|
|
23
25
|
import { useExplorer } from '../../hooks';
|
|
24
|
-
import { selectActiveView, selectAllViews, selectIsFoldersView } from '../../slices/views.slice';
|
|
26
|
+
import { selectActiveView, selectAllViews, selectIsCollectionsView, selectIsFoldersView, selectIsLabelsView } from '../../slices/views.slice';
|
|
27
|
+
import { collectionsSearchTermUpdated, fetchCollections, fetchCollectionsFiles, selectActiveCollection, selectCollectionsActiveVirtualFolder, selectIsCollectionTreeOpened, fetchCollectionVirtualFolders } from '../../slices/collections.slice';
|
|
28
|
+
import { fetchLabels, labelsSearchTermUpdated, selectActiveLabel, selectIsLabelsTreeOpened, activateLabel } from '../../slices/labels.slice';
|
|
25
29
|
import Breadcrumb from './Breadcrumb';
|
|
26
30
|
import { openFolderByPath, selectIsFoldersTreeOpened, selectOpenedFolders } from '../../slices/folders.slice';
|
|
31
|
+
import BreadcrumbsViews from './BreadCrumbViews';
|
|
27
32
|
import Styled from './Breadcrumbs.styled';
|
|
28
33
|
|
|
29
34
|
// TODO: Refactor this component to be more dynamic and not rely on conditions (isView...).
|
|
@@ -34,10 +39,18 @@ var Breadcrumbs = function Breadcrumbs() {
|
|
|
34
39
|
var _useExplorer = useExplorer(),
|
|
35
40
|
i18n = _useExplorer.i18n,
|
|
36
41
|
opts = _useExplorer.opts;
|
|
42
|
+
var theme = useTheme();
|
|
37
43
|
var hideLeftSideBar = opts.hideLeftSideBar;
|
|
38
44
|
var openedFolders = useSelector(selectOpenedFolders);
|
|
39
45
|
var activeView = useSelector(selectActiveView);
|
|
40
46
|
var isFoldersView = useSelector(selectIsFoldersView);
|
|
47
|
+
var isCollectionsView = useSelector(selectIsCollectionsView);
|
|
48
|
+
var isLabelsView = useSelector(selectIsLabelsView);
|
|
49
|
+
var activeCollection = useSelector(selectActiveCollection);
|
|
50
|
+
var activeCollectionVirtualFolder = useSelector(selectCollectionsActiveVirtualFolder);
|
|
51
|
+
var showCollectionsTree = useSelector(selectIsCollectionTreeOpened);
|
|
52
|
+
var activeLabel = useSelector(selectActiveLabel);
|
|
53
|
+
var showLabelsTree = useSelector(selectIsLabelsTreeOpened);
|
|
41
54
|
var allViews = useSelector(selectAllViews);
|
|
42
55
|
var showFoldersTree = useSelector(selectIsFoldersTreeOpened);
|
|
43
56
|
var _useState = useState(undefined),
|
|
@@ -52,7 +65,23 @@ var Breadcrumbs = function Breadcrumbs() {
|
|
|
52
65
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
53
66
|
moreFolders = _useState6[0],
|
|
54
67
|
setMoreFolders = _useState6[1];
|
|
55
|
-
var showTreeToggleIcon = !hideLeftSideBar && isFoldersView && !showFoldersTree;
|
|
68
|
+
var showTreeToggleIcon = !hideLeftSideBar && (isFoldersView && !showFoldersTree || isCollectionsView && !showCollectionsTree || isLabelsView && !showLabelsTree);
|
|
69
|
+
var refreshCollections = function refreshCollections() {
|
|
70
|
+
return dispatch(fetchCollections());
|
|
71
|
+
};
|
|
72
|
+
var refreshLabels = function refreshLabels() {
|
|
73
|
+
return dispatch(fetchLabels());
|
|
74
|
+
};
|
|
75
|
+
var refreshActiveCollection = function refreshActiveCollection() {
|
|
76
|
+
return dispatch(fetchCollectionVirtualFolders({
|
|
77
|
+
collectionUuid: activeCollection.uuid
|
|
78
|
+
}));
|
|
79
|
+
};
|
|
80
|
+
var refreshActiveLabel = function refreshActiveLabel() {
|
|
81
|
+
return dispatch(activateLabel({
|
|
82
|
+
uuid: activeLabel.uuid
|
|
83
|
+
}));
|
|
84
|
+
};
|
|
56
85
|
var handleOpenFoldersMenu = function handleOpenFoldersMenu(event) {
|
|
57
86
|
return setFoldersMenuAnchorEl(event.currentTarget);
|
|
58
87
|
};
|
|
@@ -67,15 +96,67 @@ var Breadcrumbs = function Breadcrumbs() {
|
|
|
67
96
|
}
|
|
68
97
|
}
|
|
69
98
|
};
|
|
99
|
+
var onClickMainItem = function onClickMainItem() {
|
|
100
|
+
if (isCollectionsView) activeCollection ? refreshActiveCollection() : refreshCollections();else if (isLabelsView) activeLabel ? refreshActiveLabel() : refreshLabels();
|
|
101
|
+
};
|
|
70
102
|
var breadcrumbs = useMemo(function () {
|
|
103
|
+
var filterBreadcrumbs = function filterBreadcrumbs(breadcrumb) {
|
|
104
|
+
return breadcrumb && (breadcrumb.name || breadcrumb.title);
|
|
105
|
+
};
|
|
71
106
|
var adaptedOpenedFolders = _toConsumableArray(openedFolders);
|
|
72
107
|
var getMainItemName = function getMainItemName() {
|
|
108
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
109
|
+
_ref$showActiveLabel = _ref.showActiveLabel,
|
|
110
|
+
showActiveLabel = _ref$showActiveLabel === void 0 ? false : _ref$showActiveLabel;
|
|
111
|
+
if (isCollectionsView) {
|
|
112
|
+
if (activeCollection) {
|
|
113
|
+
var _theme$palette;
|
|
114
|
+
return /*#__PURE__*/_jsx(BreadcrumbsViews, {
|
|
115
|
+
mainText: i18n('collectionsViewBreadcrumbLabel'),
|
|
116
|
+
icon: /*#__PURE__*/_jsx(Bookmark, {
|
|
117
|
+
size: 16,
|
|
118
|
+
color: theme === null || theme === void 0 ? void 0 : (_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette[PC.IconsPrimary]
|
|
119
|
+
}),
|
|
120
|
+
activeName: activeCollection.title,
|
|
121
|
+
onClickMain: refreshCollections,
|
|
122
|
+
showActiveLabel: showActiveLabel
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
return /*#__PURE__*/_jsx(BreadcrumbsViews, {
|
|
126
|
+
mainText: i18n('collectionsViewBreadcrumbLabel'),
|
|
127
|
+
activeName: i18n('collectionsViewBreadcrumbNotSelectedLabel'),
|
|
128
|
+
onClickMain: refreshCollections,
|
|
129
|
+
showActiveLabel: showActiveLabel
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (isLabelsView) {
|
|
134
|
+
if (!showActiveLabel || showActiveLabel && activeLabel) {
|
|
135
|
+
return /*#__PURE__*/_jsx(BreadcrumbsViews, {
|
|
136
|
+
mainText: i18n('labelsViewBreadcrumbLabel'),
|
|
137
|
+
icon: activeLabel ? /*#__PURE__*/_jsx(Label, {
|
|
138
|
+
size: 16,
|
|
139
|
+
style: {
|
|
140
|
+
color: activeLabel === null || activeLabel === void 0 ? void 0 : activeLabel.color
|
|
141
|
+
}
|
|
142
|
+
}) : null,
|
|
143
|
+
activeName: activeLabel === null || activeLabel === void 0 ? void 0 : activeLabel.name,
|
|
144
|
+
showActiveLabel: showActiveLabel,
|
|
145
|
+
onClickMain: refreshLabels
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
73
150
|
return i18n(VIEW_OPTIONS[activeView].i18nKey);
|
|
74
151
|
};
|
|
75
152
|
var Icon = VIEW_OPTIONS[activeView].icon;
|
|
76
153
|
var mainItem = {
|
|
77
154
|
uuid: "view-mode-".concat(activeView),
|
|
78
155
|
name: getMainItemName(),
|
|
156
|
+
activeLabel: !isFoldersView && getMainItemName({
|
|
157
|
+
showActiveLabel: true
|
|
158
|
+
}),
|
|
159
|
+
onClick: onClickMainItem,
|
|
79
160
|
icon: function icon(props) {
|
|
80
161
|
return /*#__PURE__*/_jsx(Icon, _objectSpread({}, props));
|
|
81
162
|
}
|
|
@@ -90,13 +171,39 @@ var Breadcrumbs = function Breadcrumbs() {
|
|
|
90
171
|
});
|
|
91
172
|
return adaptedOpenedFolders;
|
|
92
173
|
}
|
|
174
|
+
if (isLabelsView) {
|
|
175
|
+
return [mainItem].filter(filterBreadcrumbs);
|
|
176
|
+
}
|
|
177
|
+
if (isCollectionsView) {
|
|
178
|
+
var collectionsVirtualFoldersPath = [];
|
|
179
|
+
var _addInPath = function addInPath(folder) {
|
|
180
|
+
if (folder !== null && folder !== void 0 && folder.name) {
|
|
181
|
+
collectionsVirtualFoldersPath.push({
|
|
182
|
+
name: folder.name,
|
|
183
|
+
onClick: function onClick() {
|
|
184
|
+
return dispatch(fetchCollectionsFiles({
|
|
185
|
+
folder: folder,
|
|
186
|
+
offset: 0
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (folder !== null && folder !== void 0 && folder.parent) _addInPath(folder === null || folder === void 0 ? void 0 : folder.parent);
|
|
192
|
+
};
|
|
193
|
+
_addInPath(activeCollectionVirtualFolder);
|
|
194
|
+
return [mainItem].concat(_toConsumableArray(collectionsVirtualFoldersPath.reverse())).filter(filterBreadcrumbs);
|
|
195
|
+
}
|
|
93
196
|
return [mainItem].concat(adaptedOpenedFolders);
|
|
94
|
-
}, [openedFolders, activeView, allViews]);
|
|
197
|
+
}, [openedFolders, activeView, allViews, activeLabel, activeCollection, activeCollectionVirtualFolder]);
|
|
95
198
|
var breadcrumbsLength = breadcrumbs.length;
|
|
96
199
|
var maxNumberOfBreadcrumbsToShow = 3;
|
|
97
200
|
var breadcrumbsFolders = breadcrumbsLength >= maxNumberOfBreadcrumbsToShow ? newBreadcrumbs : breadcrumbs;
|
|
98
201
|
var closeMenu = function closeMenu() {
|
|
99
202
|
setFoldersMenuAnchorEl(undefined);
|
|
203
|
+
|
|
204
|
+
// Reset search values from sub lists
|
|
205
|
+
dispatch(collectionsSearchTermUpdated(''));
|
|
206
|
+
dispatch(labelsSearchTermUpdated(''));
|
|
100
207
|
};
|
|
101
208
|
useEffect(function () {
|
|
102
209
|
var _openedFolders$, _openedFolders$2;
|
|
@@ -123,7 +230,7 @@ var Breadcrumbs = function Breadcrumbs() {
|
|
|
123
230
|
}
|
|
124
231
|
setMoreFolders(breadcrumbsList);
|
|
125
232
|
setNewBreadcrumbs(newBreadcrumbsArray);
|
|
126
|
-
}, [openedFolders]);
|
|
233
|
+
}, [openedFolders, activeCollectionVirtualFolder]);
|
|
127
234
|
var handleToggleTree = function handleToggleTree() {
|
|
128
235
|
var activeViewToggleTreeAction = VIEW_OPTIONS[activeView].toggleTreeAction;
|
|
129
236
|
if (activeViewToggleTreeAction) {
|
|
@@ -156,7 +263,8 @@ var Breadcrumbs = function Breadcrumbs() {
|
|
|
156
263
|
isLast: i + 1 === breadcrumbsFolders.length,
|
|
157
264
|
isFirst: i === 0,
|
|
158
265
|
Icon: breadcrumb.Icon,
|
|
159
|
-
isMenuOpen: Boolean(foldersMenuAnchorEl)
|
|
266
|
+
isMenuOpen: Boolean(foldersMenuAnchorEl),
|
|
267
|
+
activeLabel: breadcrumb.activeLabel
|
|
160
268
|
}, breadcrumb.uuid || breadcrumb.id || breadcrumb.path || breadcrumb.name || breadcrumb.title);
|
|
161
269
|
}), /*#__PURE__*/_jsx(Styled.Menu, {
|
|
162
270
|
anchorEl: foldersMenuAnchorEl,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
var CollectionFolderIcon = function CollectionFolderIcon() {
|
|
3
|
+
return /*#__PURE__*/_jsxs("svg", {
|
|
4
|
+
width: "269",
|
|
5
|
+
height: "202",
|
|
6
|
+
viewBox: "0 0 269 202",
|
|
7
|
+
fill: "none",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
10
|
+
fillRule: "evenodd",
|
|
11
|
+
clipRule: "evenodd",
|
|
12
|
+
d: "M0 4.53098V16H108C96.9047 3.11111 93.0089 0 89.6267 0H47.6318H5.6369C2.25476 0 0 2.26549 0 4.53098Z",
|
|
13
|
+
fill: "#F9FBFC"
|
|
14
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
15
|
+
d: "M0 16H264.5C266.709 16 268.5 17.7909 268.5 20V162H0V16Z",
|
|
16
|
+
fill: "#F9FBFC"
|
|
17
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
18
|
+
d: "M0 162H268.5V198C268.5 200.209 266.709 202 264.5 202H4C1.79086 202 0 200.209 0 198V162Z",
|
|
19
|
+
fill: "#F9FBFC"
|
|
20
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
21
|
+
d: "M108.587 16.0715L108.736 16.2403H108.961H264.441C266.789 16.2403 268.5 17.7563 268.5 19.413V198.327C268.5 199.984 266.789 201.5 264.441 201.5H4.55933C2.21105 201.5 0.5 199.984 0.5 198.327V4.94031C0.5 2.77804 2.51087 0.5 5.66894 0.5H90.1361C91.6108 0.5 93.6068 1.40089 96.5901 3.86166C99.5538 6.3062 103.408 10.2172 108.587 16.0715Z",
|
|
22
|
+
stroke: "#E2E8EC"
|
|
23
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
24
|
+
d: "M236 14H206V62.0793C206 62.8884 206.911 63.3625 207.573 62.8986L221 53.5L234.427 62.8986C235.089 63.3625 236 62.8884 236 62.0793V14Z",
|
|
25
|
+
fill: "#A9B6C2"
|
|
26
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
27
|
+
d: "M206 14V13.5H205.5V14H206ZM236 14H236.5V13.5H236V14ZM234.427 62.8986L234.713 62.489L234.427 62.8986ZM221 53.5L221.287 53.0904L221 52.8897L220.713 53.0904L221 53.5ZM207.573 62.8986L207.86 63.3082H207.86L207.573 62.8986ZM206 14.5H236V13.5H206V14.5ZM235.5 14V62.0793H236.5V14H235.5ZM234.713 62.489L221.287 53.0904L220.713 53.9096L234.14 63.3082L234.713 62.489ZM220.713 53.0904L207.287 62.489L207.86 63.3082L221.287 53.9096L220.713 53.0904ZM206.5 62.0793V14H205.5V62.0793H206.5ZM207.287 62.489C206.955 62.7209 206.5 62.4839 206.5 62.0793H205.5C205.5 63.2929 206.866 64.0041 207.86 63.3082L207.287 62.489ZM235.5 62.0793C235.5 62.4839 235.045 62.7209 234.713 62.489L234.14 63.3082C235.134 64.0041 236.5 63.2929 236.5 62.0793H235.5Z",
|
|
28
|
+
fill: "#E2E8EC"
|
|
29
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
30
|
+
d: "M206.5 14H235.5",
|
|
31
|
+
stroke: "#A9B6C2"
|
|
32
|
+
})]
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
export default CollectionFolderIcon;
|
package/lib/components/CollectionsView/CollectionVirtualFoldersTree/CollectionTreeSkeletion.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Skeleton } from '@scaleflex/ui/core';
|
|
2
|
+
import Styled from './CollectionVirtualFoldersTree.styled';
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
var CollectionTreeSkeleton = function CollectionTreeSkeleton() {
|
|
5
|
+
return Array(20).fill().map(function (_, index) {
|
|
6
|
+
return /*#__PURE__*/_jsxs(Styled.SkeletonItem, {
|
|
7
|
+
children: [/*#__PURE__*/_jsx(Skeleton, {
|
|
8
|
+
width: 20,
|
|
9
|
+
height: 20,
|
|
10
|
+
style: {
|
|
11
|
+
borderRadius: 4
|
|
12
|
+
}
|
|
13
|
+
}), /*#__PURE__*/_jsx(Styled.SkeletonItemName, {
|
|
14
|
+
children: /*#__PURE__*/_jsx(Skeleton, {
|
|
15
|
+
width: 160,
|
|
16
|
+
height: 10,
|
|
17
|
+
style: {
|
|
18
|
+
marginBottom: 4,
|
|
19
|
+
borderRadius: 2
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
})]
|
|
23
|
+
}, "".concat(index, "-loading"));
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export default CollectionTreeSkeleton;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
2
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
3
|
+
import { FV, PC } from '@scaleflex/widget-common/lib';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
var Container = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
|
|
6
|
+
var FolderContainer = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n"])));
|
|
7
|
+
var FolderArrow = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n width: 16px;\n\n svg {\n color: ", ";\n }\n"])), function (_ref) {
|
|
8
|
+
var theme = _ref.theme;
|
|
9
|
+
return theme.palette[PC.IconsPrimary];
|
|
10
|
+
});
|
|
11
|
+
var FolderIcon = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n\n svg {\n color: ", ";\n }\n"])), function (_ref2) {
|
|
12
|
+
var theme = _ref2.theme;
|
|
13
|
+
return theme.palette[PC.IconsSecondary];
|
|
14
|
+
});
|
|
15
|
+
var FolderName = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n ", "\n ", "\n color: ", ";\n"])), function (props) {
|
|
16
|
+
return props.theme.typography.font[FV.LabelSmall];
|
|
17
|
+
}, function (_ref3) {
|
|
18
|
+
var font = _ref3.theme.typography.font;
|
|
19
|
+
return font[FV.LabelMedium];
|
|
20
|
+
}, function (_ref4) {
|
|
21
|
+
var palette = _ref4.theme.palette;
|
|
22
|
+
return palette[PC.TextPrimary];
|
|
23
|
+
});
|
|
24
|
+
var Folder = styled.div(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n align-items: center;\n height: 36px;\n padding: 8px 12px;\n cursor: pointer;\n gap: 6px;\n ", "\n\n ", " {\n ", "\n }\n\n ", "\n\n &:hover {\n background: ", ";\n }\n\n ", "\n"])), function (props) {
|
|
25
|
+
return "margin-left: ".concat(props.$level * 12, "px;");
|
|
26
|
+
}, FolderArrow, function (props) {
|
|
27
|
+
return props.$hasChildren ? '' : 'visibility: hidden;';
|
|
28
|
+
}, function (props) {
|
|
29
|
+
return !props.$hasChildren ? "\n ".concat(FolderArrow, " { visibility: hidden; }\n ") : '';
|
|
30
|
+
}, function (_ref5) {
|
|
31
|
+
var palette = _ref5.theme.palette;
|
|
32
|
+
return palette[PC.BackgroundHover];
|
|
33
|
+
}, function (_ref6) {
|
|
34
|
+
var $active = _ref6.$active,
|
|
35
|
+
palette = _ref6.theme.palette;
|
|
36
|
+
return $active ? "\n background: ".concat(palette[PC.BackgroundActive], " !important;\n\n ").concat(FolderIcon, " svg { color: ").concat(palette[PC.AccentStateless], "; }\n ").concat(FolderName, " { color: ").concat(palette[PC.AccentStateless], "; }\n ") : '';
|
|
37
|
+
});
|
|
38
|
+
var FolderChildren = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral([""])));
|
|
39
|
+
var SkeletonItem = styled.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n height: 36px;\n padding: 8px 0;\n border-radius: 4px;\n column-gap: 6px;\n transition: all 100ms ease-out;\n\n span {\n border-radius: 4px;\n }\n"])));
|
|
40
|
+
var SkeletonItemName = styled.div(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n"])));
|
|
41
|
+
var Styled = {
|
|
42
|
+
Container: Container,
|
|
43
|
+
FolderContainer: FolderContainer,
|
|
44
|
+
Folder: Folder,
|
|
45
|
+
FolderArrow: FolderArrow,
|
|
46
|
+
FolderIcon: FolderIcon,
|
|
47
|
+
FolderName: FolderName,
|
|
48
|
+
FolderChildren: FolderChildren,
|
|
49
|
+
SkeletonItem: SkeletonItem,
|
|
50
|
+
SkeletonItemName: SkeletonItemName
|
|
51
|
+
};
|
|
52
|
+
export default Styled;
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
export var filterFolders = function filterFolders() {
|
|
8
|
+
var folders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
9
|
+
var searchTerm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
10
|
+
var _getChildren = function getChildren(result, folder) {
|
|
11
|
+
if ((folder.name || '').toLowerCase().includes((searchTerm || '').toLowerCase())) {
|
|
12
|
+
result.push(folder);
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(folder.children)) {
|
|
16
|
+
var children = folder.children.reduce(_getChildren, []);
|
|
17
|
+
if (children.length) result.push(_objectSpread(_objectSpread({}, folder), {}, {
|
|
18
|
+
children: children
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
return folders.reduce(_getChildren, []);
|
|
24
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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; } }
|
|
10
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
|
+
import { useState, memo } from 'react';
|
|
14
|
+
import { ArrowBottom, ArrowRightOutline, Collections } from '@scaleflex/icons';
|
|
15
|
+
import { EllipsedText } from '@scaleflex/ui/core';
|
|
16
|
+
import Styled from './CollectionVirtualFoldersTree.styled';
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
var _Folder = function Folder(_ref) {
|
|
19
|
+
var name = _ref.name,
|
|
20
|
+
childrenFolders = _ref.childrenFolders,
|
|
21
|
+
_ref$noArrow = _ref.noArrow,
|
|
22
|
+
noArrow = _ref$noArrow === void 0 ? false : _ref$noArrow,
|
|
23
|
+
_ref$level = _ref.level,
|
|
24
|
+
level = _ref$level === void 0 ? 0 : _ref$level,
|
|
25
|
+
activeFolder = _ref.activeFolder,
|
|
26
|
+
activateFolder = _ref.activateFolder,
|
|
27
|
+
folder = _ref.folder,
|
|
28
|
+
_ref$expandedByDefaul = _ref.expandedByDefault,
|
|
29
|
+
expandedByDefault = _ref$expandedByDefaul === void 0 ? false : _ref$expandedByDefaul,
|
|
30
|
+
_ref$forceExpanded = _ref.forceExpanded,
|
|
31
|
+
forceExpanded = _ref$forceExpanded === void 0 ? false : _ref$forceExpanded;
|
|
32
|
+
var _useState = useState(expandedByDefault),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
isExpanded = _useState2[0],
|
|
35
|
+
setIsExpanded = _useState2[1];
|
|
36
|
+
var isActive = (activeFolder === null || activeFolder === void 0 ? void 0 : activeFolder.path) === (folder === null || folder === void 0 ? void 0 : folder.path);
|
|
37
|
+
return /*#__PURE__*/_jsxs(Styled.FolderContainer, {
|
|
38
|
+
children: [/*#__PURE__*/_jsxs(Styled.Folder, {
|
|
39
|
+
$level: level,
|
|
40
|
+
$hasChildren: Boolean(childrenFolders === null || childrenFolders === void 0 ? void 0 : childrenFolders.length),
|
|
41
|
+
$active: isActive,
|
|
42
|
+
onClick: function onClick() {
|
|
43
|
+
activateFolder(folder);
|
|
44
|
+
setIsExpanded(true);
|
|
45
|
+
},
|
|
46
|
+
children: [!noArrow && /*#__PURE__*/_jsx(Styled.FolderArrow, {
|
|
47
|
+
// $expanded={isExpanded}
|
|
48
|
+
onClick: forceExpanded ? undefined : function (event) {
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
setIsExpanded(function (_isExpanded) {
|
|
51
|
+
return !_isExpanded;
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
children: forceExpanded || isExpanded ? /*#__PURE__*/_jsx(ArrowBottom, {
|
|
55
|
+
size: 11
|
|
56
|
+
}) : /*#__PURE__*/_jsx(ArrowRightOutline, {
|
|
57
|
+
size: 11
|
|
58
|
+
})
|
|
59
|
+
}), /*#__PURE__*/_jsx(Styled.FolderIcon, {
|
|
60
|
+
children: /*#__PURE__*/_jsx(Collections, {
|
|
61
|
+
size: 16
|
|
62
|
+
})
|
|
63
|
+
}), /*#__PURE__*/_jsx(Styled.FolderName, {
|
|
64
|
+
children: /*#__PURE__*/_jsx(EllipsedText, {
|
|
65
|
+
maxLinesCount: 1,
|
|
66
|
+
children: name
|
|
67
|
+
})
|
|
68
|
+
})]
|
|
69
|
+
}), (forceExpanded || isExpanded) && childrenFolders && childrenFolders.length > 0 && /*#__PURE__*/_jsx(Styled.FolderChildren, {
|
|
70
|
+
children: childrenFolders.map(function (childFolder) {
|
|
71
|
+
return /*#__PURE__*/_jsx(_Folder, {
|
|
72
|
+
name: childFolder === null || childFolder === void 0 ? void 0 : childFolder.name
|
|
73
|
+
// path={`${path}/${decodeURIComponent(childFolder?.name)}`}
|
|
74
|
+
,
|
|
75
|
+
childrenFolders: childFolder === null || childFolder === void 0 ? void 0 : childFolder.children,
|
|
76
|
+
level: level + 1,
|
|
77
|
+
activateFolder: activateFolder,
|
|
78
|
+
activeFolder: activeFolder,
|
|
79
|
+
folder: _objectSpread(_objectSpread({}, childFolder), {}, {
|
|
80
|
+
parent: folder
|
|
81
|
+
}),
|
|
82
|
+
forceExpanded: forceExpanded
|
|
83
|
+
}, childFolder === null || childFolder === void 0 ? void 0 : childFolder.name);
|
|
84
|
+
})
|
|
85
|
+
})]
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
export default /*#__PURE__*/memo(_Folder);
|
|
@@ -0,0 +1,50 @@
|
|
|
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 Folder from './Folder';
|
|
8
|
+
import CollectionTreeSkeleton from './CollectionTreeSkeletion';
|
|
9
|
+
import Styled from './CollectionVirtualFoldersTree.styled';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { createElement as _createElement } from "react";
|
|
12
|
+
var Tree = function Tree(_ref) {
|
|
13
|
+
var activeCollectionVirtualFolders = _ref.activeCollectionVirtualFolders,
|
|
14
|
+
activeCollectionVirtualFolder = _ref.activeCollectionVirtualFolder,
|
|
15
|
+
isActiveCollectionVirtualFoldersLoading = _ref.isActiveCollectionVirtualFoldersLoading,
|
|
16
|
+
activateFolder = _ref.activateFolder,
|
|
17
|
+
searchTerm = _ref.searchTerm;
|
|
18
|
+
/**
|
|
19
|
+
* Main value is stored in activeCollectionVirtualFoldersPath global state but we use extra state level to avoid delay between click on virtual folder and activation.
|
|
20
|
+
* Hence the only reason of having extra state level is better UI performance.
|
|
21
|
+
*
|
|
22
|
+
* TODO Vitaly: Check this part. It doesn't optimise performance.
|
|
23
|
+
*/
|
|
24
|
+
// const [activePath, setActivePath] = useState(activeCollectionVirtualFoldersPath)
|
|
25
|
+
|
|
26
|
+
// useEffect(() => {
|
|
27
|
+
// setActivePath(activeCollectionVirtualFoldersPath)
|
|
28
|
+
// }, [activeCollectionVirtualFoldersPath])
|
|
29
|
+
|
|
30
|
+
var folderCommonProps = {
|
|
31
|
+
activeFolder: activeCollectionVirtualFolder,
|
|
32
|
+
activateFolder: activateFolder
|
|
33
|
+
};
|
|
34
|
+
if (isActiveCollectionVirtualFoldersLoading) {
|
|
35
|
+
return /*#__PURE__*/_jsx(CollectionTreeSkeleton, {});
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/_jsx(Styled.Container, {
|
|
38
|
+
children: (activeCollectionVirtualFolders || []).map(function (folder) {
|
|
39
|
+
return /*#__PURE__*/_createElement(Folder, _objectSpread(_objectSpread({}, folderCommonProps), {}, {
|
|
40
|
+
key: folder === null || folder === void 0 ? void 0 : folder.name,
|
|
41
|
+
folder: folder,
|
|
42
|
+
name: folder === null || folder === void 0 ? void 0 : folder.name,
|
|
43
|
+
childrenFolders: folder === null || folder === void 0 ? void 0 : folder.children,
|
|
44
|
+
expandedByDefault: (activeCollectionVirtualFolder === null || activeCollectionVirtualFolder === void 0 ? void 0 : activeCollectionVirtualFolder.path) === (folder === null || folder === void 0 ? void 0 : folder.path),
|
|
45
|
+
forceExpanded: Boolean(searchTerm)
|
|
46
|
+
}));
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export default Tree;
|