@synerise/ds-item-picker 1.16.2 → 1.17.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 +14 -0
- package/README.md +2 -3
- package/dist/ItemPicker.d.ts +5 -5
- package/dist/ItemPicker.js +13 -17
- package/dist/ItemPicker.styles.d.ts +1 -1
- package/dist/ItemPicker.styles.js +6 -3
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.d.ts +2 -2
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.js +58 -99
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.style.d.ts +7 -7
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.style.js +22 -19
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.types.d.ts +4 -4
- package/dist/components/ItemPickerDropdown/ItemPickerDropdown.types.js +1 -1
- package/dist/components/ItemPickerLegacy/ItemPickerLegacy.d.ts +2 -2
- package/dist/components/ItemPickerLegacy/ItemPickerLegacy.js +89 -152
- package/dist/components/ItemPickerLegacy/ItemPickerLegacy.types.d.ts +8 -8
- package/dist/components/ItemPickerLegacy/ItemPickerLegacy.types.js +1 -1
- package/dist/components/ItemPickerList/ItemPickerList.d.ts +5 -5
- package/dist/components/ItemPickerList/ItemPickerList.js +199 -258
- package/dist/components/ItemPickerList/ItemPickerList.styles.d.ts +18 -18
- package/dist/components/ItemPickerList/ItemPickerList.styles.js +55 -64
- package/dist/components/ItemPickerList/ItemPickerList.types.d.ts +3 -3
- package/dist/components/ItemPickerList/ItemPickerList.types.js +1 -1
- package/dist/components/ItemPickerList/components/EmptyListMessage.d.ts +10 -5
- package/dist/components/ItemPickerList/components/EmptyListMessage.js +33 -29
- package/dist/components/ItemPickerList/components/ErrorItem.d.ts +1 -1
- package/dist/components/ItemPickerList/components/ErrorItem.js +10 -9
- package/dist/components/ItemPickerList/components/ErrorMessage.d.ts +2 -2
- package/dist/components/ItemPickerList/components/ErrorMessage.js +12 -15
- package/dist/components/ItemPickerList/components/InfiniteLoaderItem.d.ts +2 -2
- package/dist/components/ItemPickerList/components/InfiniteLoaderItem.js +19 -17
- package/dist/components/ItemPickerList/components/ItemPickerListFooter.d.ts +3 -3
- package/dist/components/ItemPickerList/components/ItemPickerListFooter.js +21 -20
- package/dist/components/ItemPickerList/components/ItemPickerListRow.d.ts +4 -4
- package/dist/components/ItemPickerList/components/ItemPickerListRow.js +42 -43
- package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.d.ts +1 -1
- package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.js +16 -23
- package/dist/components/ItemPickerList/components/ListSearchInput.d.ts +4 -4
- package/dist/components/ItemPickerList/components/ListSearchInput.js +36 -51
- package/dist/components/ItemPickerList/components/LoadingItem.d.ts +1 -1
- package/dist/components/ItemPickerList/components/LoadingItem.js +10 -9
- package/dist/components/ItemPickerList/components/NoMoreItem.d.ts +1 -1
- package/dist/components/ItemPickerList/components/NoMoreItem.js +10 -9
- package/dist/components/ItemPickerList/components/index.js +14 -6
- package/dist/components/ItemPickerList/constants.d.ts +2 -2
- package/dist/components/ItemPickerList/constants.js +47 -26
- package/dist/components/ItemPickerList/hooks/index.js +8 -3
- package/dist/components/ItemPickerList/hooks/useFlattenFolders.d.ts +2 -2
- package/dist/components/ItemPickerList/hooks/useFlattenFolders.js +40 -61
- package/dist/components/ItemPickerList/hooks/useItemsInSections.d.ts +7 -7
- package/dist/components/ItemPickerList/hooks/useItemsInSections.js +342 -443
- package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.d.ts +5 -5
- package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.js +77 -74
- package/dist/components/ItemPickerList/hooks/useListHeight.d.ts +2 -2
- package/dist/components/ItemPickerList/hooks/useListHeight.js +37 -41
- package/dist/components/ItemPickerList/types/renderMode.js +8 -5
- package/dist/components/ItemPickerList/utils/actionItemsUtils.d.ts +4 -4
- package/dist/components/ItemPickerList/utils/actionItemsUtils.js +92 -92
- package/dist/components/ItemPickerList/utils/createTitleFromTitlePath.d.ts +2 -2
- package/dist/components/ItemPickerList/utils/createTitleFromTitlePath.js +7 -4
- package/dist/components/ItemPickerList/utils/findSectionById.d.ts +1 -1
- package/dist/components/ItemPickerList/utils/findSectionById.js +10 -12
- package/dist/components/ItemPickerList/utils/getContextAwareActions.d.ts +1 -1
- package/dist/components/ItemPickerList/utils/getContextAwareActions.js +19 -15
- package/dist/components/ItemPickerList/utils/getSearchByActionItems.d.ts +2 -2
- package/dist/components/ItemPickerList/utils/getSearchByActionItems.js +28 -29
- package/dist/components/ItemPickerList/utils/index.js +16 -4
- package/dist/components/ItemPickerList/utils/isNavKey.d.ts +1 -1
- package/dist/components/ItemPickerList/utils/isNavKey.js +6 -3
- package/dist/components/ItemPickerList/utils/resolveSectionId.d.ts +2 -2
- package/dist/components/ItemPickerList/utils/resolveSectionId.js +15 -9
- package/dist/components/ItemPickerList/utils/typeguards.utils.d.ts +5 -5
- package/dist/components/ItemPickerList/utils/typeguards.utils.js +23 -14
- package/dist/components/ItemPickerNew/ItemPickerNew.d.ts +4 -4
- package/dist/components/ItemPickerNew/ItemPickerNew.js +59 -101
- package/dist/components/ItemPickerNew/ItemPickerNew.types.d.ts +18 -16
- package/dist/components/ItemPickerNew/ItemPickerNew.types.js +1 -1
- package/dist/components/ItemPickerNew/types/actions.types.d.ts +2 -2
- package/dist/components/ItemPickerNew/types/actions.types.js +10 -6
- package/dist/components/ItemPickerNew/types/baseItemSectionType.types.d.ts +3 -3
- package/dist/components/ItemPickerNew/types/baseItemSectionType.types.js +1 -1
- package/dist/components/ItemPickerNew/types/itemPickerListTexts.types.d.ts +2 -2
- package/dist/components/ItemPickerNew/types/itemPickerListTexts.types.js +1 -1
- package/dist/components/ItemPickerTrigger/Trigger.d.ts +5 -5
- package/dist/components/ItemPickerTrigger/Trigger.js +71 -111
- package/dist/components/ItemPickerTrigger/Trigger.styles.d.ts +12 -12
- package/dist/components/ItemPickerTrigger/Trigger.styles.js +70 -93
- package/dist/components/ItemPickerTrigger/Trigger.types.d.ts +3 -3
- package/dist/components/ItemPickerTrigger/Trigger.types.js +1 -1
- package/dist/hooks/useDefaultTexts.d.ts +1 -1
- package/dist/hooks/useDefaultTexts.js +116 -117
- package/dist/index.js +14 -6
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/package.json +25 -25
|
@@ -1,66 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { useTheme } from
|
|
4
|
-
import Dropdown from
|
|
5
|
-
import Icon, { SearchM } from
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
shortCuts:
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback, useEffect } from "react";
|
|
3
|
+
import { useTheme } from "@synerise/ds-core";
|
|
4
|
+
import Dropdown from "@synerise/ds-dropdown";
|
|
5
|
+
import Icon, { SearchM } from "@synerise/ds-icon";
|
|
6
|
+
import { SearchWrapper } from "../ItemPickerList.styles.js";
|
|
7
|
+
const CLEAR_TOOLTIP_PROPS = {
|
|
8
|
+
shortCuts: "ESC"
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var handleSearchChange = useCallback(function (value) {
|
|
10
|
+
const ListSearchInput = ({
|
|
11
|
+
searchByParamConfig,
|
|
12
|
+
changeLocalSearchQueryRef,
|
|
13
|
+
clearSearchQuery,
|
|
14
|
+
setSearchByParamConfig,
|
|
15
|
+
debouncedChangeSearchQuery,
|
|
16
|
+
searchBarProps,
|
|
17
|
+
allTexts,
|
|
18
|
+
inputRef,
|
|
19
|
+
canPerformListActions
|
|
20
|
+
}) => {
|
|
21
|
+
const theme = useTheme();
|
|
22
|
+
const [localSearchQuery, setLocalSearchQuery] = useState("");
|
|
23
|
+
const handleSearchChange = useCallback((value) => {
|
|
25
24
|
setLocalSearchQuery(value);
|
|
26
25
|
debouncedChangeSearchQuery(value);
|
|
27
26
|
}, [debouncedChangeSearchQuery]);
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const handleInputRef = useCallback((ref) => {
|
|
28
|
+
const localRef = inputRef;
|
|
30
29
|
localRef.current = ref.current;
|
|
31
30
|
}, [inputRef]);
|
|
32
|
-
|
|
33
|
-
if (event.key ===
|
|
34
|
-
setSearchByParamConfig(
|
|
31
|
+
const handleKeyDown = (event) => {
|
|
32
|
+
if (event.key === "Backspace" && !localSearchQuery) {
|
|
33
|
+
setSearchByParamConfig(void 0);
|
|
35
34
|
}
|
|
36
35
|
};
|
|
37
|
-
|
|
36
|
+
const handleClearInput = () => {
|
|
38
37
|
if (localSearchQuery) {
|
|
39
38
|
clearSearchQuery();
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
|
-
setSearchByParamConfig(
|
|
41
|
+
setSearchByParamConfig(void 0);
|
|
43
42
|
};
|
|
44
|
-
useEffect(
|
|
45
|
-
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const ref = changeLocalSearchQueryRef;
|
|
46
45
|
ref.current = setLocalSearchQuery;
|
|
47
46
|
}, [changeLocalSearchQueryRef]);
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
color: theme.palette['grey-600']
|
|
54
|
-
}),
|
|
55
|
-
placeholder: canPerformListActions ? allTexts.searchPlaceholder : allTexts.basicSearchPlaceholder
|
|
56
|
-
}, searchBarProps, {
|
|
57
|
-
valuePrefix: searchByParamConfig == null ? void 0 : searchByParamConfig.paramKeyLabel,
|
|
58
|
-
onKeyDown: handleKeyDown,
|
|
59
|
-
clearTooltip: allTexts.clearSearchTooltip,
|
|
60
|
-
clearTooltipProps: CLEAR_TOOLTIP_PROPS,
|
|
61
|
-
onClearInput: handleClearInput,
|
|
62
|
-
handleInputRef: handleInputRef,
|
|
63
|
-
onSearchChange: handleSearchChange,
|
|
64
|
-
value: localSearchQuery
|
|
65
|
-
})));
|
|
66
|
-
};
|
|
47
|
+
return /* @__PURE__ */ jsx(SearchWrapper, { "data-testid": "search-wrapper", children: /* @__PURE__ */ jsx(Dropdown.SearchInput, { iconLeft: /* @__PURE__ */ jsx(Icon, { component: searchByParamConfig?.icon || /* @__PURE__ */ jsx(SearchM, {}), color: theme.palette["grey-600"] }), placeholder: canPerformListActions ? allTexts.searchPlaceholder : allTexts.basicSearchPlaceholder, ...searchBarProps, valuePrefix: searchByParamConfig?.paramKeyLabel, onKeyDown: handleKeyDown, clearTooltip: allTexts.clearSearchTooltip, clearTooltipProps: CLEAR_TOOLTIP_PROPS, onClearInput: handleClearInput, handleInputRef, onSearchChange: handleSearchChange, value: localSearchQuery }) });
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
ListSearchInput
|
|
51
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Loader } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Loader } from "../ItemPickerList.styles.js";
|
|
3
|
+
const LoadingItem = ({
|
|
4
|
+
label
|
|
5
|
+
}) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(Loader, { size: "M", label });
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
LoadingItem
|
|
10
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Alert from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import Alert from "@synerise/ds-alert";
|
|
3
|
+
const NoMoreItem = ({
|
|
4
|
+
label
|
|
5
|
+
}) => {
|
|
6
|
+
return /* @__PURE__ */ jsx(Alert.InlineAlert, { type: "info", message: label });
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
NoMoreItem
|
|
10
|
+
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { EmptyListMessage } from "./EmptyListMessage.js";
|
|
2
|
+
import { ErrorMessage } from "./ErrorMessage.js";
|
|
3
|
+
import { InfiniteLoaderItem } from "./InfiniteLoaderItem.js";
|
|
4
|
+
import { ItemPickerListFooter } from "./ItemPickerListFooter.js";
|
|
5
|
+
import { ItemPickerListRow } from "./ItemPickerListRow.js";
|
|
6
|
+
import { ItemPickerListSkeleton } from "./ItemPickerListSkeleton.js";
|
|
7
|
+
export {
|
|
8
|
+
EmptyListMessage,
|
|
9
|
+
ErrorMessage,
|
|
10
|
+
InfiniteLoaderItem,
|
|
11
|
+
ItemPickerListFooter,
|
|
12
|
+
ItemPickerListRow,
|
|
13
|
+
ItemPickerListSkeleton
|
|
14
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { BaseItemType } from '../ItemPickerNew/types/baseItemSectionType.types';
|
|
3
3
|
export declare const LIST_STYLE: CSSProperties;
|
|
4
4
|
export declare const ITEM_SIZE: {
|
|
5
5
|
large: number;
|
|
@@ -1,33 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
overflowY: 'unset'
|
|
1
|
+
import { itemSizes } from "@synerise/ds-list-item";
|
|
2
|
+
const LIST_STYLE = {
|
|
3
|
+
overflowX: "unset",
|
|
4
|
+
overflowY: "unset"
|
|
6
5
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
const ITEM_SIZE = {
|
|
7
|
+
[itemSizes.LARGE]: 50,
|
|
8
|
+
[itemSizes.DEFAULT]: 32,
|
|
9
|
+
title: 32
|
|
10
|
+
};
|
|
11
|
+
const DEFAULT_HEIGHT = 420;
|
|
12
|
+
const DEFAULT_HEIGHT_BELOW_THRESHOLD = 350;
|
|
13
|
+
const DEFAULT_HEIGHT_THRESHOLD = 800;
|
|
14
|
+
const SECTION_HEADER_HEIGHT = 53;
|
|
15
|
+
const SEARCH_BAR_HEIGHT = 53;
|
|
16
|
+
const FOOTER_HEIGHT = 48;
|
|
17
|
+
const LIST_INNER_PADDING = 8;
|
|
18
|
+
const FIRST_PAGE = 0;
|
|
19
|
+
const SECOND_PAGE = 1;
|
|
20
|
+
const ITEMS_PER_PAGE = 150;
|
|
21
|
+
const ITEMS_PER_SECTION = 4;
|
|
22
|
+
const ITEMS_PER_SECTION_IN_SEARCH = 4;
|
|
23
|
+
const TITLE_PATH_SEPARATOR = " - ";
|
|
24
|
+
let counter = 0;
|
|
25
|
+
const keyMap = /* @__PURE__ */ new WeakMap();
|
|
26
|
+
const GET_ITEM_KEY = (item) => {
|
|
27
|
+
if (item?.id) {
|
|
25
28
|
return item.id;
|
|
26
29
|
}
|
|
27
|
-
|
|
30
|
+
let key = keyMap.get(item);
|
|
28
31
|
if (!key) {
|
|
29
|
-
key =
|
|
32
|
+
key = `__item_${counter++}`;
|
|
30
33
|
keyMap.set(item, key);
|
|
31
34
|
}
|
|
32
35
|
return key;
|
|
33
|
-
};
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
DEFAULT_HEIGHT,
|
|
39
|
+
DEFAULT_HEIGHT_BELOW_THRESHOLD,
|
|
40
|
+
DEFAULT_HEIGHT_THRESHOLD,
|
|
41
|
+
FIRST_PAGE,
|
|
42
|
+
FOOTER_HEIGHT,
|
|
43
|
+
GET_ITEM_KEY,
|
|
44
|
+
ITEMS_PER_PAGE,
|
|
45
|
+
ITEMS_PER_SECTION,
|
|
46
|
+
ITEMS_PER_SECTION_IN_SEARCH,
|
|
47
|
+
ITEM_SIZE,
|
|
48
|
+
LIST_INNER_PADDING,
|
|
49
|
+
LIST_STYLE,
|
|
50
|
+
SEARCH_BAR_HEIGHT,
|
|
51
|
+
SECOND_PAGE,
|
|
52
|
+
SECTION_HEADER_HEIGHT,
|
|
53
|
+
TITLE_PATH_SEPARATOR
|
|
54
|
+
};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { useItemsInSections } from "./useItemsInSections.js";
|
|
2
|
+
import { useListHeight } from "./useListHeight.js";
|
|
3
|
+
import { useFlattenFolders } from "./useFlattenFolders.js";
|
|
4
|
+
export {
|
|
5
|
+
useFlattenFolders,
|
|
6
|
+
useItemsInSections,
|
|
7
|
+
useListHeight
|
|
8
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BaseSectionType, BaseSectionTypeWithFolders } from '../../ItemPickerNew/types/baseItemSectionType.types';
|
|
3
3
|
type NestedFoldersProps<SectionType extends BaseSectionType | undefined> = {
|
|
4
4
|
currentSection?: SectionType extends BaseSectionType ? BaseSectionTypeWithFolders<SectionType> : undefined;
|
|
5
5
|
sections?: SectionType extends BaseSectionType ? BaseSectionTypeWithFolders<SectionType>[] : undefined;
|
|
@@ -1,81 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// Concrete return types (use BaseSectionType to keep the return shape assignable)
|
|
5
|
-
|
|
6
|
-
var _mapParent = function mapParent(item, parent) {
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
const mapParent = (item, parent) => {
|
|
7
3
|
if (item.folders) {
|
|
8
|
-
return [
|
|
9
|
-
return _mapParent(f, item);
|
|
10
|
-
}), [{
|
|
4
|
+
return [...item.folders.flatMap((f) => mapParent(f, item)), {
|
|
11
5
|
id: item.id,
|
|
12
|
-
parent
|
|
13
|
-
}]
|
|
6
|
+
parent
|
|
7
|
+
}];
|
|
14
8
|
}
|
|
15
9
|
return [{
|
|
16
10
|
id: item.id,
|
|
17
|
-
parent
|
|
11
|
+
parent
|
|
18
12
|
}];
|
|
19
13
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return folder.folders.flatMap(function (f) {
|
|
25
|
-
return _getFolders(f, newPath);
|
|
26
|
-
});
|
|
14
|
+
const getFolders = (folder, titles) => {
|
|
15
|
+
const newPath = titles ? [...titles, folder.text] : [folder.text];
|
|
16
|
+
if (folder.folders?.length) {
|
|
17
|
+
return folder.folders.flatMap((f) => getFolders(f, newPath));
|
|
27
18
|
}
|
|
28
|
-
return [
|
|
19
|
+
return [{
|
|
20
|
+
...folder,
|
|
29
21
|
titles: newPath
|
|
30
|
-
}
|
|
22
|
+
}];
|
|
31
23
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return sections
|
|
38
|
-
return section.folders ? section.folders.flatMap(function (f) {
|
|
39
|
-
return _mapParent(f);
|
|
40
|
-
}) : [];
|
|
41
|
-
});
|
|
24
|
+
const useFlattenFolders = ({
|
|
25
|
+
currentSection,
|
|
26
|
+
sections
|
|
27
|
+
}) => {
|
|
28
|
+
const folderParentMap = useMemo(() => {
|
|
29
|
+
return sections?.flatMap((section) => section.folders ? section.folders.flatMap((f) => mapParent(f)) : []);
|
|
42
30
|
}, [sections]);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return _extends({}, folder, {
|
|
51
|
-
titles: (_folder$titles = folder.titles) == null ? void 0 : _folder$titles.slice(titlePathIndex)
|
|
52
|
-
});
|
|
53
|
-
});
|
|
31
|
+
const titlePathIndex = folderParentMap?.length ? 1 : 0;
|
|
32
|
+
const allItemFolders = useMemo(() => {
|
|
33
|
+
const mappedFolders = sections?.flatMap((section) => getFolders(section));
|
|
34
|
+
return mappedFolders?.map((folder) => ({
|
|
35
|
+
...folder,
|
|
36
|
+
titles: folder.titles?.slice(titlePathIndex)
|
|
37
|
+
}));
|
|
54
38
|
}, [sections, titlePathIndex]);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return currentSection == null || (_currentSection$folde = currentSection.folders) == null ? void 0 : _currentSection$folde.flatMap(function (folder) {
|
|
58
|
-
return _getFolders(folder);
|
|
59
|
-
});
|
|
39
|
+
const childFolders = useMemo(() => {
|
|
40
|
+
return currentSection?.folders?.flatMap((folder) => getFolders(folder));
|
|
60
41
|
}, [currentSection]);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return currentSection && (folderParentMap == null || (_folderParentMap$find = folderParentMap.find(function (item) {
|
|
64
|
-
return item.id === currentSection.id;
|
|
65
|
-
})) == null ? void 0 : _folderParentMap$find.parent);
|
|
42
|
+
const parentFolder = useMemo(() => {
|
|
43
|
+
return currentSection && folderParentMap?.find((item) => item.id === currentSection.id)?.parent;
|
|
66
44
|
}, [currentSection, folderParentMap]);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
})) == null ? void 0 : _allItemFolders$find.titles;
|
|
70
|
-
var currentFolders = useMemo(function () {
|
|
45
|
+
const currentTitlePath = allItemFolders?.find((folder) => folder.id === currentSection?.id)?.titles;
|
|
46
|
+
const currentFolders = useMemo(() => {
|
|
71
47
|
return currentSection ? childFolders : allItemFolders;
|
|
72
48
|
}, [allItemFolders, childFolders, currentSection]);
|
|
73
49
|
return {
|
|
74
50
|
allFolders: allItemFolders,
|
|
75
|
-
childFolders
|
|
76
|
-
parentFolder
|
|
77
|
-
currentFolders
|
|
78
|
-
currentSectionHasFolders: !!
|
|
51
|
+
childFolders,
|
|
52
|
+
parentFolder,
|
|
53
|
+
currentFolders,
|
|
54
|
+
currentSectionHasFolders: !!childFolders?.length,
|
|
79
55
|
currentPath: currentTitlePath
|
|
80
56
|
};
|
|
81
|
-
};
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
useFlattenFolders
|
|
60
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { ItemPickerListProps, OnLoadedData } from '../../ItemPickerNew/ItemPickerNew.types';
|
|
2
|
+
import { SearchByAction, SearchByParamConfig, SearchInAction } from '../../ItemPickerNew/types/actions.types';
|
|
3
|
+
import { BaseItemType, BaseSectionType, BaseSectionTypeWithFolders } from '../../ItemPickerNew/types/baseItemSectionType.types';
|
|
4
|
+
import { ItemPickerListTexts } from '../../ItemPickerNew/types/itemPickerListTexts.types';
|
|
5
5
|
type ItemsInSectionsType<ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined> = {
|
|
6
6
|
items: ItemPickerListProps<ItemType, SectionType>['items'];
|
|
7
7
|
texts: ItemPickerListTexts;
|
|
@@ -19,11 +19,11 @@ type ItemsInSectionsType<ItemType extends BaseItemType, SectionType extends Base
|
|
|
19
19
|
};
|
|
20
20
|
export declare const useItemsInSections: <ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined>({ items, texts, selectedItem, sections, recents, actions, searchQuery, handleItemSelect, onSectionChange, getItemKey, showItemsSectionLabel, changeSearchQuery, onLoadedData, }: ItemsInSectionsType<ItemType, SectionType>) => {
|
|
21
21
|
currentSection: BaseSectionType | undefined;
|
|
22
|
-
currentPath: import(
|
|
22
|
+
currentPath: import('react').ReactNode[] | undefined;
|
|
23
23
|
goBack: () => void;
|
|
24
24
|
resetCurrentSection: () => void;
|
|
25
25
|
setCurrentSection: (section?: SectionType | BaseSectionType) => void;
|
|
26
|
-
mergedItemsList: (import(
|
|
26
|
+
mergedItemsList: (import('@synerise/ds-list-item').ListItemProps | import('../ItemPickerList.types').TitleListItemProps)[];
|
|
27
27
|
isLoading: boolean;
|
|
28
28
|
isLoadingMore: boolean;
|
|
29
29
|
isLoadedAll: boolean;
|
|
@@ -35,7 +35,7 @@ export declare const useItemsInSections: <ItemType extends BaseItemType, Section
|
|
|
35
35
|
refreshEnabled: boolean;
|
|
36
36
|
searchByAction: SearchByAction | undefined;
|
|
37
37
|
searchByParamConfig: SearchByParamConfig | undefined;
|
|
38
|
-
setSearchByParamConfig: import(
|
|
38
|
+
setSearchByParamConfig: import('react').Dispatch<import('react').SetStateAction<SearchByParamConfig | undefined>>;
|
|
39
39
|
listActions: boolean;
|
|
40
40
|
searchInItem: ItemType | undefined;
|
|
41
41
|
searchInAction: SearchInAction | undefined;
|