@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.
Files changed (94) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +2 -3
  3. package/dist/ItemPicker.d.ts +5 -5
  4. package/dist/ItemPicker.js +13 -17
  5. package/dist/ItemPicker.styles.d.ts +1 -1
  6. package/dist/ItemPicker.styles.js +6 -3
  7. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.d.ts +2 -2
  8. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.js +58 -99
  9. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.style.d.ts +7 -7
  10. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.style.js +22 -19
  11. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.types.d.ts +4 -4
  12. package/dist/components/ItemPickerDropdown/ItemPickerDropdown.types.js +1 -1
  13. package/dist/components/ItemPickerLegacy/ItemPickerLegacy.d.ts +2 -2
  14. package/dist/components/ItemPickerLegacy/ItemPickerLegacy.js +89 -152
  15. package/dist/components/ItemPickerLegacy/ItemPickerLegacy.types.d.ts +8 -8
  16. package/dist/components/ItemPickerLegacy/ItemPickerLegacy.types.js +1 -1
  17. package/dist/components/ItemPickerList/ItemPickerList.d.ts +5 -5
  18. package/dist/components/ItemPickerList/ItemPickerList.js +199 -258
  19. package/dist/components/ItemPickerList/ItemPickerList.styles.d.ts +18 -18
  20. package/dist/components/ItemPickerList/ItemPickerList.styles.js +55 -64
  21. package/dist/components/ItemPickerList/ItemPickerList.types.d.ts +3 -3
  22. package/dist/components/ItemPickerList/ItemPickerList.types.js +1 -1
  23. package/dist/components/ItemPickerList/components/EmptyListMessage.d.ts +10 -5
  24. package/dist/components/ItemPickerList/components/EmptyListMessage.js +33 -29
  25. package/dist/components/ItemPickerList/components/ErrorItem.d.ts +1 -1
  26. package/dist/components/ItemPickerList/components/ErrorItem.js +10 -9
  27. package/dist/components/ItemPickerList/components/ErrorMessage.d.ts +2 -2
  28. package/dist/components/ItemPickerList/components/ErrorMessage.js +12 -15
  29. package/dist/components/ItemPickerList/components/InfiniteLoaderItem.d.ts +2 -2
  30. package/dist/components/ItemPickerList/components/InfiniteLoaderItem.js +19 -17
  31. package/dist/components/ItemPickerList/components/ItemPickerListFooter.d.ts +3 -3
  32. package/dist/components/ItemPickerList/components/ItemPickerListFooter.js +21 -20
  33. package/dist/components/ItemPickerList/components/ItemPickerListRow.d.ts +4 -4
  34. package/dist/components/ItemPickerList/components/ItemPickerListRow.js +42 -43
  35. package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.d.ts +1 -1
  36. package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.js +16 -23
  37. package/dist/components/ItemPickerList/components/ListSearchInput.d.ts +4 -4
  38. package/dist/components/ItemPickerList/components/ListSearchInput.js +36 -51
  39. package/dist/components/ItemPickerList/components/LoadingItem.d.ts +1 -1
  40. package/dist/components/ItemPickerList/components/LoadingItem.js +10 -9
  41. package/dist/components/ItemPickerList/components/NoMoreItem.d.ts +1 -1
  42. package/dist/components/ItemPickerList/components/NoMoreItem.js +10 -9
  43. package/dist/components/ItemPickerList/components/index.js +14 -6
  44. package/dist/components/ItemPickerList/constants.d.ts +2 -2
  45. package/dist/components/ItemPickerList/constants.js +47 -26
  46. package/dist/components/ItemPickerList/hooks/index.js +8 -3
  47. package/dist/components/ItemPickerList/hooks/useFlattenFolders.d.ts +2 -2
  48. package/dist/components/ItemPickerList/hooks/useFlattenFolders.js +40 -61
  49. package/dist/components/ItemPickerList/hooks/useItemsInSections.d.ts +7 -7
  50. package/dist/components/ItemPickerList/hooks/useItemsInSections.js +342 -443
  51. package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.d.ts +5 -5
  52. package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.js +77 -74
  53. package/dist/components/ItemPickerList/hooks/useListHeight.d.ts +2 -2
  54. package/dist/components/ItemPickerList/hooks/useListHeight.js +37 -41
  55. package/dist/components/ItemPickerList/types/renderMode.js +8 -5
  56. package/dist/components/ItemPickerList/utils/actionItemsUtils.d.ts +4 -4
  57. package/dist/components/ItemPickerList/utils/actionItemsUtils.js +92 -92
  58. package/dist/components/ItemPickerList/utils/createTitleFromTitlePath.d.ts +2 -2
  59. package/dist/components/ItemPickerList/utils/createTitleFromTitlePath.js +7 -4
  60. package/dist/components/ItemPickerList/utils/findSectionById.d.ts +1 -1
  61. package/dist/components/ItemPickerList/utils/findSectionById.js +10 -12
  62. package/dist/components/ItemPickerList/utils/getContextAwareActions.d.ts +1 -1
  63. package/dist/components/ItemPickerList/utils/getContextAwareActions.js +19 -15
  64. package/dist/components/ItemPickerList/utils/getSearchByActionItems.d.ts +2 -2
  65. package/dist/components/ItemPickerList/utils/getSearchByActionItems.js +28 -29
  66. package/dist/components/ItemPickerList/utils/index.js +16 -4
  67. package/dist/components/ItemPickerList/utils/isNavKey.d.ts +1 -1
  68. package/dist/components/ItemPickerList/utils/isNavKey.js +6 -3
  69. package/dist/components/ItemPickerList/utils/resolveSectionId.d.ts +2 -2
  70. package/dist/components/ItemPickerList/utils/resolveSectionId.js +15 -9
  71. package/dist/components/ItemPickerList/utils/typeguards.utils.d.ts +5 -5
  72. package/dist/components/ItemPickerList/utils/typeguards.utils.js +23 -14
  73. package/dist/components/ItemPickerNew/ItemPickerNew.d.ts +4 -4
  74. package/dist/components/ItemPickerNew/ItemPickerNew.js +59 -101
  75. package/dist/components/ItemPickerNew/ItemPickerNew.types.d.ts +18 -16
  76. package/dist/components/ItemPickerNew/ItemPickerNew.types.js +1 -1
  77. package/dist/components/ItemPickerNew/types/actions.types.d.ts +2 -2
  78. package/dist/components/ItemPickerNew/types/actions.types.js +10 -6
  79. package/dist/components/ItemPickerNew/types/baseItemSectionType.types.d.ts +3 -3
  80. package/dist/components/ItemPickerNew/types/baseItemSectionType.types.js +1 -1
  81. package/dist/components/ItemPickerNew/types/itemPickerListTexts.types.d.ts +2 -2
  82. package/dist/components/ItemPickerNew/types/itemPickerListTexts.types.js +1 -1
  83. package/dist/components/ItemPickerTrigger/Trigger.d.ts +5 -5
  84. package/dist/components/ItemPickerTrigger/Trigger.js +71 -111
  85. package/dist/components/ItemPickerTrigger/Trigger.styles.d.ts +12 -12
  86. package/dist/components/ItemPickerTrigger/Trigger.styles.js +70 -93
  87. package/dist/components/ItemPickerTrigger/Trigger.types.d.ts +3 -3
  88. package/dist/components/ItemPickerTrigger/Trigger.types.js +1 -1
  89. package/dist/hooks/useDefaultTexts.d.ts +1 -1
  90. package/dist/hooks/useDefaultTexts.js +116 -117
  91. package/dist/index.js +14 -6
  92. package/dist/modules.d.js +1 -1
  93. package/dist/modules.d.ts +0 -0
  94. package/package.json +25 -25
@@ -1,66 +1,51 @@
1
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useEffect, useState } 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 * as S from '../ItemPickerList.styles';
7
- var CLEAR_TOOLTIP_PROPS = {
8
- shortCuts: 'ESC'
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
- export var ListSearchInput = function ListSearchInput(_ref) {
11
- var searchByParamConfig = _ref.searchByParamConfig,
12
- changeLocalSearchQueryRef = _ref.changeLocalSearchQueryRef,
13
- clearSearchQuery = _ref.clearSearchQuery,
14
- setSearchByParamConfig = _ref.setSearchByParamConfig,
15
- debouncedChangeSearchQuery = _ref.debouncedChangeSearchQuery,
16
- searchBarProps = _ref.searchBarProps,
17
- allTexts = _ref.allTexts,
18
- inputRef = _ref.inputRef,
19
- canPerformListActions = _ref.canPerformListActions;
20
- var theme = useTheme();
21
- var _useState = useState(''),
22
- localSearchQuery = _useState[0],
23
- setLocalSearchQuery = _useState[1];
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
- var handleInputRef = useCallback(function (ref) {
29
- var localRef = inputRef;
27
+ const handleInputRef = useCallback((ref) => {
28
+ const localRef = inputRef;
30
29
  localRef.current = ref.current;
31
30
  }, [inputRef]);
32
- var handleKeyDown = function handleKeyDown(event) {
33
- if (event.key === 'Backspace' && !localSearchQuery) {
34
- setSearchByParamConfig(undefined);
31
+ const handleKeyDown = (event) => {
32
+ if (event.key === "Backspace" && !localSearchQuery) {
33
+ setSearchByParamConfig(void 0);
35
34
  }
36
35
  };
37
- var handleClearInput = function handleClearInput() {
36
+ const handleClearInput = () => {
38
37
  if (localSearchQuery) {
39
38
  clearSearchQuery();
40
39
  return;
41
40
  }
42
- setSearchByParamConfig(undefined);
41
+ setSearchByParamConfig(void 0);
43
42
  };
44
- useEffect(function () {
45
- var ref = changeLocalSearchQueryRef;
43
+ useEffect(() => {
44
+ const ref = changeLocalSearchQueryRef;
46
45
  ref.current = setLocalSearchQuery;
47
46
  }, [changeLocalSearchQueryRef]);
48
- return /*#__PURE__*/React.createElement(S.SearchWrapper, {
49
- "data-testid": "search-wrapper"
50
- }, /*#__PURE__*/React.createElement(Dropdown.SearchInput, _extends({
51
- iconLeft: /*#__PURE__*/React.createElement(Icon, {
52
- component: (searchByParamConfig == null ? void 0 : searchByParamConfig.icon) || /*#__PURE__*/React.createElement(SearchM, null),
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,4 +1,4 @@
1
- import React, { type ReactNode } from 'react';
1
+ import { default as React, ReactNode } from 'react';
2
2
  export declare const LoadingItem: ({ label }: {
3
3
  label: ReactNode;
4
4
  }) => React.JSX.Element;
@@ -1,9 +1,10 @@
1
- import React from 'react';
2
- import { Loader } from '../ItemPickerList.styles';
3
- export var LoadingItem = function LoadingItem(_ref) {
4
- var label = _ref.label;
5
- return /*#__PURE__*/React.createElement(Loader, {
6
- size: "M",
7
- label: label
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,4 +1,4 @@
1
- import React, { type ReactNode } from 'react';
1
+ import { default as React, ReactNode } from 'react';
2
2
  export declare const NoMoreItem: ({ label }: {
3
3
  label: ReactNode;
4
4
  }) => React.JSX.Element;
@@ -1,9 +1,10 @@
1
- import React from 'react';
2
- import Alert from '@synerise/ds-alert';
3
- export var NoMoreItem = function NoMoreItem(_ref) {
4
- var label = _ref.label;
5
- return /*#__PURE__*/React.createElement(Alert.InlineAlert, {
6
- type: "info",
7
- message: label
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
- export * from './EmptyListMessage';
2
- export * from './ErrorMessage';
3
- export * from './InfiniteLoaderItem';
4
- export * from './ItemPickerListFooter';
5
- export * from './ItemPickerListRow';
6
- export * from './ItemPickerListSkeleton';
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 type { CSSProperties } from 'react';
2
- import type { BaseItemType } from '../ItemPickerNew/types/baseItemSectionType.types';
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
- var _ITEM_SIZE;
2
- import { itemSizes } from '@synerise/ds-list-item';
3
- export var LIST_STYLE = {
4
- overflowX: 'unset',
5
- overflowY: 'unset'
1
+ import { itemSizes } from "@synerise/ds-list-item";
2
+ const LIST_STYLE = {
3
+ overflowX: "unset",
4
+ overflowY: "unset"
6
5
  };
7
- export var ITEM_SIZE = (_ITEM_SIZE = {}, _ITEM_SIZE[itemSizes.LARGE] = 50, _ITEM_SIZE[itemSizes.DEFAULT] = 32, _ITEM_SIZE.title = 32, _ITEM_SIZE);
8
- export var DEFAULT_HEIGHT = 420;
9
- export var DEFAULT_HEIGHT_BELOW_THRESHOLD = 350;
10
- export var DEFAULT_HEIGHT_THRESHOLD = 800;
11
- export var SECTION_HEADER_HEIGHT = 53;
12
- export var SEARCH_BAR_HEIGHT = 53;
13
- export var FOOTER_HEIGHT = 48;
14
- export var LIST_INNER_PADDING = 8;
15
- export var FIRST_PAGE = 0;
16
- export var SECOND_PAGE = 1;
17
- export var ITEMS_PER_PAGE = 150;
18
- export var ITEMS_PER_SECTION = 4;
19
- export var ITEMS_PER_SECTION_IN_SEARCH = 4;
20
- export var TITLE_PATH_SEPARATOR = ' - ';
21
- var counter = 0;
22
- var keyMap = new WeakMap();
23
- export var GET_ITEM_KEY = function GET_ITEM_KEY(item) {
24
- if (item != null && item.id) {
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
- var key = keyMap.get(item);
30
+ let key = keyMap.get(item);
28
31
  if (!key) {
29
- key = "__item_" + counter++;
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
- export * from './useItemsInSections';
2
- export * from './useListHeight';
3
- export * from './useFlattenFolders';
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 { type ReactNode } from 'react';
2
- import type { BaseSectionType, BaseSectionTypeWithFolders } from '../../ItemPickerNew/types/baseItemSectionType.types';
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
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import { useMemo } from 'react';
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 [].concat(item.folders.flatMap(function (f) {
9
- return _mapParent(f, item);
10
- }), [{
4
+ return [...item.folders.flatMap((f) => mapParent(f, item)), {
11
5
  id: item.id,
12
- parent: parent
13
- }]);
6
+ parent
7
+ }];
14
8
  }
15
9
  return [{
16
10
  id: item.id,
17
- parent: parent
11
+ parent
18
12
  }];
19
13
  };
20
- var _getFolders = function getFolders(folder, titles) {
21
- var _folder$folders;
22
- var newPath = titles ? [].concat(titles, [folder.text]) : [folder.text];
23
- if ((_folder$folders = folder.folders) != null && _folder$folders.length) {
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 [_extends({}, folder, {
19
+ return [{
20
+ ...folder,
29
21
  titles: newPath
30
- })];
22
+ }];
31
23
  };
32
- export var useFlattenFolders = function useFlattenFolders(_ref) {
33
- var _allItemFolders$find;
34
- var currentSection = _ref.currentSection,
35
- sections = _ref.sections;
36
- var folderParentMap = useMemo(function () {
37
- return sections == null ? void 0 : sections.flatMap(function (section) {
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
- var titlePathIndex = folderParentMap != null && folderParentMap.length ? 1 : 0;
44
- var allItemFolders = useMemo(function () {
45
- var mappedFolders = sections == null ? void 0 : sections.flatMap(function (section) {
46
- return _getFolders(section);
47
- });
48
- return mappedFolders == null ? void 0 : mappedFolders.map(function (folder) {
49
- var _folder$titles;
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
- var childFolders = useMemo(function () {
56
- var _currentSection$folde;
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
- var parentFolder = useMemo(function () {
62
- var _folderParentMap$find;
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
- var currentTitlePath = allItemFolders == null || (_allItemFolders$find = allItemFolders.find(function (folder) {
68
- return folder.id === (currentSection == null ? void 0 : currentSection.id);
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: childFolders,
76
- parentFolder: parentFolder,
77
- currentFolders: currentFolders,
78
- currentSectionHasFolders: !!(childFolders != null && childFolders.length),
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 type { ItemPickerListProps, OnLoadedData } from '../../ItemPickerNew/ItemPickerNew.types';
2
- import type { SearchByAction, SearchByParamConfig, SearchInAction } from '../../ItemPickerNew/types/actions.types';
3
- import type { BaseItemType, BaseSectionType, BaseSectionTypeWithFolders } from '../../ItemPickerNew/types/baseItemSectionType.types';
4
- import type { ItemPickerListTexts } from '../../ItemPickerNew/types/itemPickerListTexts.types';
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("react").ReactNode[] | undefined;
22
+ currentPath: import('react').ReactNode[] | undefined;
23
23
  goBack: () => void;
24
24
  resetCurrentSection: () => void;
25
25
  setCurrentSection: (section?: SectionType | BaseSectionType) => void;
26
- mergedItemsList: (import("@synerise/ds-list-item").ListItemProps | import("../ItemPickerList.types").TitleListItemProps)[];
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("react").Dispatch<import("react").SetStateAction<SearchByParamConfig | undefined>>;
38
+ setSearchByParamConfig: import('react').Dispatch<import('react').SetStateAction<SearchByParamConfig | undefined>>;
39
39
  listActions: boolean;
40
40
  searchInItem: ItemType | undefined;
41
41
  searchInAction: SearchInAction | undefined;