@synerise/ds-item-picker 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/CLAUDE.md +67 -9
- package/README.md +42 -0
- package/dist/components/ItemPickerList/ItemPickerList.js +40 -8
- package/dist/components/ItemPickerList/ItemPickerList.styles.d.ts +4 -1
- package/dist/components/ItemPickerList/ItemPickerList.styles.js +21 -6
- package/dist/components/ItemPickerList/components/EmptyListMessage.d.ts +3 -2
- package/dist/components/ItemPickerList/components/EmptyListMessage.js +4 -0
- package/dist/components/ItemPickerList/components/ItemPickerListRow.js +1 -1
- package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.d.ts +3 -1
- package/dist/components/ItemPickerList/components/ItemPickerListSkeleton.js +17 -10
- package/dist/components/ItemPickerList/components/ListSearchInput.d.ts +3 -1
- package/dist/components/ItemPickerList/components/ListSearchInput.js +10 -3
- package/dist/components/ItemPickerList/constants.d.ts +2 -0
- package/dist/components/ItemPickerList/constants.js +4 -0
- package/dist/components/ItemPickerList/hooks/index.d.ts +1 -0
- package/dist/components/ItemPickerList/hooks/index.js +2 -0
- package/dist/components/ItemPickerList/hooks/useFolderLevel.d.ts +9 -0
- package/dist/components/ItemPickerList/hooks/useFolderLevel.js +31 -0
- package/dist/components/ItemPickerList/hooks/useItemsInSections.d.ts +5 -0
- package/dist/components/ItemPickerList/hooks/useItemsInSections.js +208 -68
- package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.d.ts +9 -1
- package/dist/components/ItemPickerList/hooks/useItemsInSections.utils.js +33 -1
- package/dist/components/ItemPickerList/types/renderMode.d.ts +1 -0
- package/dist/components/ItemPickerList/types/renderMode.js +2 -1
- package/dist/components/ItemPickerList/utils/actionItemsUtils.js +6 -2
- package/dist/components/ItemPickerList/utils/formatFolderPath.d.ts +4 -0
- package/dist/components/ItemPickerList/utils/formatFolderPath.js +13 -0
- package/dist/components/ItemPickerList/utils/index.d.ts +1 -0
- package/dist/components/ItemPickerList/utils/index.js +5 -1
- package/dist/components/ItemPickerList/utils/typeguards.utils.d.ts +7 -2
- package/dist/components/ItemPickerList/utils/typeguards.utils.js +4 -0
- package/dist/components/ItemPickerNew/ItemPickerNew.js +5 -3
- package/dist/components/ItemPickerNew/ItemPickerNew.types.d.ts +2 -1
- package/dist/components/ItemPickerNew/types/actions.types.d.ts +5 -0
- package/dist/components/ItemPickerNew/types/itemPickerListTexts.types.d.ts +1 -1
- package/dist/components/ItemPickerNew/types/mixedLoader.types.d.ts +52 -0
- package/dist/components/ItemPickerNew/types/mixedLoader.types.js +1 -0
- package/dist/hooks/useDefaultTexts.js +8 -0
- package/dist/index.d.ts +1 -0
- package/package.json +23 -23
|
@@ -4,6 +4,7 @@ import Dropdown from "@synerise/ds-dropdown";
|
|
|
4
4
|
import FormField from "@synerise/ds-form-field";
|
|
5
5
|
import { useDefaultTexts } from "../../hooks/useDefaultTexts.js";
|
|
6
6
|
import { ItemPickerWrapper } from "../../ItemPicker.styles.js";
|
|
7
|
+
import { GET_ITEM_KEY } from "../ItemPickerList/constants.js";
|
|
7
8
|
import { ItemPickerList } from "../ItemPickerList/ItemPickerList.js";
|
|
8
9
|
import Trigger from "../ItemPickerTrigger/Trigger.js";
|
|
9
10
|
const ItemPickerNewInner = ({
|
|
@@ -46,12 +47,13 @@ const ItemPickerNewInner = ({
|
|
|
46
47
|
onChange?.(item);
|
|
47
48
|
closeDropdown();
|
|
48
49
|
};
|
|
50
|
+
const selectedItemKey = selectedItem ? GET_ITEM_KEY(selectedItem) : void 0;
|
|
51
|
+
useEffect(() => setSelected(selectedItem), [selectedItem]);
|
|
49
52
|
useEffect(() => {
|
|
50
|
-
|
|
51
|
-
if (selectedItem) {
|
|
53
|
+
if (selectedItemKey !== void 0) {
|
|
52
54
|
setVisible(false);
|
|
53
55
|
}
|
|
54
|
-
}, [
|
|
56
|
+
}, [selectedItemKey]);
|
|
55
57
|
const trigger = useMemo(() => {
|
|
56
58
|
return renderTrigger ? renderTrigger({
|
|
57
59
|
selected: selectedItem,
|
|
@@ -11,6 +11,7 @@ import { ItemPickerTriggerProps, ItemPickerTriggerTexts } from '../ItemPickerTri
|
|
|
11
11
|
import { Action } from './types/actions.types';
|
|
12
12
|
import { BaseItemType, BaseSectionType, BaseSectionTypeWithFolders } from './types/baseItemSectionType.types';
|
|
13
13
|
import { ItemPickerListTexts } from './types/itemPickerListTexts.types';
|
|
14
|
+
import { MixedLoaderConfig } from './types/mixedLoader.types';
|
|
14
15
|
type HeightConfig = {
|
|
15
16
|
defaultHeight: number;
|
|
16
17
|
viewportHeightThreshold?: number;
|
|
@@ -87,7 +88,7 @@ export type ItemPickerListProps<ItemType extends BaseItemType, SectionType exten
|
|
|
87
88
|
scrollbarProps?: ScrollbarAdditionalProps;
|
|
88
89
|
searchBarProps?: Omit<SearchBarProps, 'value' | 'onSearchChange' | 'placeholder'>;
|
|
89
90
|
onRefresh?: () => void;
|
|
90
|
-
items: ItemType[] | ItemsConfig<ItemType> | ItemLoaderConfig<ItemType>;
|
|
91
|
+
items: ItemType[] | ItemsConfig<ItemType> | ItemLoaderConfig<ItemType> | MixedLoaderConfig<ItemType>;
|
|
91
92
|
isLoading?: boolean;
|
|
92
93
|
isVisible?: boolean;
|
|
93
94
|
sections?: SectionType extends BaseSectionType ? BaseSectionTypeWithFolders<SectionType>[] : undefined;
|
|
@@ -11,6 +11,11 @@ type BasicAction = Omit<InheritedFromListItem, 'onClick'> & {
|
|
|
11
11
|
id: string | number;
|
|
12
12
|
text: ReactNode;
|
|
13
13
|
icon?: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* `false` keeps the action out of the list; it is still offered under `/`.
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
showInList?: boolean;
|
|
14
19
|
};
|
|
15
20
|
type RedirectAction = BasicAction & {
|
|
16
21
|
actionType: typeof ACTION_TYPES.redirect;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
type TextsAsReactNode = 'basicSearchPlaceholder' | 'searchPlaceholder' | 'refreshButtonLabel' | 'showMoreResultsLabel' | 'noItems' | 'noResults' | 'noResultsInSection' | 'searchAllFoldersButtonLabel' | 'recentsSectionLabel' | 'actionsSectionLabel' | 'resultsSectionLabel' | 'noActions' | 'emptyStateLabel' | 'itemsSectionLabel' | 'infiniteScrollLoadingMore' | 'infiniteScrollLoadingError' | 'errorMessageTitle' | 'errorMessageDetails' | 'backTooltip' | 'clearSearchTooltip' | 'infiniteScrollAllLoaded';
|
|
2
|
+
type TextsAsReactNode = 'basicSearchPlaceholder' | 'searchPlaceholder' | 'refreshButtonLabel' | 'showMoreResultsLabel' | 'noItems' | 'noResults' | 'noResultsInSection' | 'searchAllFoldersButtonLabel' | 'recentsSectionLabel' | 'actionsSectionLabel' | 'resultsSectionLabel' | 'noActions' | 'emptyStateLabel' | 'itemsSectionLabel' | 'infiniteScrollLoadingMore' | 'infiniteScrollLoadingError' | 'errorMessageTitle' | 'errorMessageDetails' | 'backTooltip' | 'clearSearchTooltip' | 'infiniteScrollAllLoaded' | 'searchInFolderPlaceholder' | 'emptyFolder';
|
|
3
3
|
export type ItemPickerListTexts = {
|
|
4
4
|
[key in TextsAsReactNode]: ReactNode;
|
|
5
5
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { InformationCardProps } from '@synerise/ds-information-card';
|
|
3
|
+
import { BaseItemType } from './baseItemSectionType.types';
|
|
4
|
+
export type FolderNode = {
|
|
5
|
+
id: string;
|
|
6
|
+
text: string;
|
|
7
|
+
/** Second line of a large row. */
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Shown on the right of a disabled default row, or as the second line of a large one. */
|
|
11
|
+
disabledReason?: ReactNode;
|
|
12
|
+
informationCardProps?: InformationCardProps;
|
|
13
|
+
};
|
|
14
|
+
export type LevelEntry<ItemType extends BaseItemType> = ({
|
|
15
|
+
type: 'folder';
|
|
16
|
+
folder: FolderNode;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'item';
|
|
19
|
+
item: ItemType;
|
|
20
|
+
}) & {
|
|
21
|
+
/** Where a search result sits; the second line of a large row in search results. */
|
|
22
|
+
location?: ReactNode;
|
|
23
|
+
};
|
|
24
|
+
/** `id: null` is the root. */
|
|
25
|
+
export type PathStep = {
|
|
26
|
+
id: string | null;
|
|
27
|
+
text: string;
|
|
28
|
+
};
|
|
29
|
+
export type LoadLevelParams = {
|
|
30
|
+
/** `null` is the root. */
|
|
31
|
+
folderId: string | null;
|
|
32
|
+
/** Empty: the level itself. Otherwise: matches from this level and every level below it. */
|
|
33
|
+
searchQuery: string;
|
|
34
|
+
searchKey?: string;
|
|
35
|
+
page: number;
|
|
36
|
+
limit: number;
|
|
37
|
+
abortController?: AbortController;
|
|
38
|
+
};
|
|
39
|
+
export type LoadLevelResult<ItemType extends BaseItemType> = {
|
|
40
|
+
/** One page, folders first. */
|
|
41
|
+
entries: LevelEntry<ItemType>[];
|
|
42
|
+
total: number;
|
|
43
|
+
/** From the root to `folderId`. */
|
|
44
|
+
path: PathStep[];
|
|
45
|
+
};
|
|
46
|
+
export type MixedLoaderConfig<ItemType extends BaseItemType> = {
|
|
47
|
+
loadLevel: (params: LoadLevelParams) => Promise<LoadLevelResult<ItemType>>;
|
|
48
|
+
/** @default 30 */
|
|
49
|
+
limitPerPage?: number;
|
|
50
|
+
/** @default 'default' */
|
|
51
|
+
rowSize?: 'default' | 'large';
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -88,6 +88,14 @@ const useDefaultTexts = (texts) => {
|
|
|
88
88
|
id: "DS.ITEM-PICKER-DROPDOWN.LOADED-ALL",
|
|
89
89
|
defaultMessage: "All items loaded"
|
|
90
90
|
}),
|
|
91
|
+
searchInFolderPlaceholder: intl.formatMessage({
|
|
92
|
+
id: "DS.ITEM-PICKER-DROPDOWN.SEARCH-IN-FOLDER-PLACEHOLDER",
|
|
93
|
+
defaultMessage: "Search in this folder"
|
|
94
|
+
}),
|
|
95
|
+
emptyFolder: intl.formatMessage({
|
|
96
|
+
id: "DS.ITEM-PICKER-DROPDOWN.EMPTY-FOLDER",
|
|
97
|
+
defaultMessage: "This folder is empty"
|
|
98
|
+
}),
|
|
91
99
|
errorMessageTitle: intl.formatMessage({
|
|
92
100
|
id: "DS.ITEM-PICKER-DROPDOWN.ERROR-TITLE",
|
|
93
101
|
defaultMessage: "Items can`t be loaded"
|
package/dist/index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export type { ItemLoaderConfig, ItemLoaderResponse, ItemPickerListProps, ItemPic
|
|
|
8
8
|
export type { Action } from './components/ItemPickerNew/types/actions.types';
|
|
9
9
|
export type { BaseItemType, BaseSectionType, BaseSectionTypeWithFolders, } from './components/ItemPickerNew/types/baseItemSectionType.types';
|
|
10
10
|
export type { ItemPickerListTexts } from './components/ItemPickerNew/types/itemPickerListTexts.types';
|
|
11
|
+
export type { FolderNode, LevelEntry, LoadLevelParams, LoadLevelResult, MixedLoaderConfig, PathStep, } from './components/ItemPickerNew/types/mixedLoader.types';
|
|
11
12
|
export { default as ItemPickerTrigger } from './components/ItemPickerTrigger/Trigger';
|
|
12
13
|
export { default } from './ItemPicker';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-item-picker",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "ItemPicker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -42,27 +42,27 @@
|
|
|
42
42
|
],
|
|
43
43
|
"types": "dist/index.d.ts",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@synerise/ds-avatar": "^2.1.
|
|
46
|
-
"@synerise/ds-button": "^2.2.
|
|
47
|
-
"@synerise/ds-dropdown": "^2.2.
|
|
48
|
-
"@synerise/ds-empty-states": "^2.1.
|
|
49
|
-
"@synerise/ds-flag": "^2.0.
|
|
50
|
-
"@synerise/ds-form-field": "^2.1.
|
|
51
|
-
"@synerise/ds-icon": "^2.3.
|
|
52
|
-
"@synerise/ds-information-card": "^2.1.
|
|
53
|
-
"@synerise/ds-inline-alert": "^2.1.
|
|
54
|
-
"@synerise/ds-list-item": "^2.
|
|
55
|
-
"@synerise/ds-loader": "^2.1.
|
|
56
|
-
"@synerise/ds-popconfirm": "^2.1.
|
|
57
|
-
"@synerise/ds-result": "^2.1.
|
|
58
|
-
"@synerise/ds-scrollbar": "^2.1.
|
|
59
|
-
"@synerise/ds-search": "^2.1.
|
|
60
|
-
"@synerise/ds-search-bar": "^2.1.
|
|
61
|
-
"@synerise/ds-short-cuts": "^2.1.
|
|
62
|
-
"@synerise/ds-skeleton": "^2.1.
|
|
63
|
-
"@synerise/ds-tooltip": "^2.1.
|
|
64
|
-
"@synerise/ds-typography": "^2.1.
|
|
65
|
-
"@synerise/ds-utils": "^2.3.
|
|
45
|
+
"@synerise/ds-avatar": "^2.1.1",
|
|
46
|
+
"@synerise/ds-button": "^2.2.1",
|
|
47
|
+
"@synerise/ds-dropdown": "^2.2.1",
|
|
48
|
+
"@synerise/ds-empty-states": "^2.1.1",
|
|
49
|
+
"@synerise/ds-flag": "^2.0.4",
|
|
50
|
+
"@synerise/ds-form-field": "^2.1.1",
|
|
51
|
+
"@synerise/ds-icon": "^2.3.1",
|
|
52
|
+
"@synerise/ds-information-card": "^2.1.1",
|
|
53
|
+
"@synerise/ds-inline-alert": "^2.1.1",
|
|
54
|
+
"@synerise/ds-list-item": "^2.4.0",
|
|
55
|
+
"@synerise/ds-loader": "^2.1.1",
|
|
56
|
+
"@synerise/ds-popconfirm": "^2.1.1",
|
|
57
|
+
"@synerise/ds-result": "^2.1.1",
|
|
58
|
+
"@synerise/ds-scrollbar": "^2.1.1",
|
|
59
|
+
"@synerise/ds-search": "^2.1.1",
|
|
60
|
+
"@synerise/ds-search-bar": "^2.1.1",
|
|
61
|
+
"@synerise/ds-short-cuts": "^2.1.1",
|
|
62
|
+
"@synerise/ds-skeleton": "^2.1.1",
|
|
63
|
+
"@synerise/ds-tooltip": "^2.1.1",
|
|
64
|
+
"@synerise/ds-typography": "^2.1.1",
|
|
65
|
+
"@synerise/ds-utils": "^2.3.1",
|
|
66
66
|
"lodash.debounce": "^4.0.8",
|
|
67
67
|
"react-window": "^1.8.11"
|
|
68
68
|
},
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
77
77
|
"styled-components": "^5.3.3"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "2d2a540b35fddf8855da45f0dec2f4612c6d87b6"
|
|
80
80
|
}
|