@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,25 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return actions == null ? void 0 : actions.find(function (action) {
|
|
5
|
-
return action.actionType === actionType && (action == null ? void 0 : action.sectionId) === sectionId;
|
|
6
|
-
});
|
|
1
|
+
import { CONTEXT_AWARE_ACTIONS } from "../../ItemPickerNew/types/actions.types.js";
|
|
2
|
+
const getActionByTypeAndSectionId = (actions, sectionId, actionType) => {
|
|
3
|
+
return actions?.find((action) => action.actionType === actionType && action?.sectionId === sectionId);
|
|
7
4
|
};
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const getContextAwareActions = (actions, sectionId) => {
|
|
6
|
+
const globalLocalContextActions = CONTEXT_AWARE_ACTIONS.reduce((contextActionsObject, contextActionsType) => {
|
|
10
7
|
if (sectionId) {
|
|
11
|
-
|
|
8
|
+
const localAction = getActionByTypeAndSectionId(actions, sectionId, contextActionsType);
|
|
12
9
|
if (localAction) {
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
return {
|
|
11
|
+
...contextActionsObject,
|
|
12
|
+
[contextActionsType]: localAction
|
|
13
|
+
};
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
|
|
16
|
+
const globalAction = getActionByTypeAndSectionId(actions, void 0, contextActionsType);
|
|
18
17
|
if (globalAction) {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
return {
|
|
19
|
+
...contextActionsObject,
|
|
20
|
+
[contextActionsType]: globalAction
|
|
21
|
+
};
|
|
21
22
|
}
|
|
22
23
|
return contextActionsObject;
|
|
23
24
|
}, {});
|
|
24
25
|
return globalLocalContextActions;
|
|
25
|
-
};
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
getContextAwareActions
|
|
29
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SearchByAction, SearchByParamConfig } from '../../ItemPickerNew/types/actions.types';
|
|
2
2
|
type GetSearchByActionItemsOptions = {
|
|
3
3
|
action: SearchByAction;
|
|
4
4
|
setSearchByAction: (value: SearchByAction | undefined) => void;
|
|
@@ -6,5 +6,5 @@ type GetSearchByActionItemsOptions = {
|
|
|
6
6
|
changeSearchQuery: (query: string) => void;
|
|
7
7
|
searchQuery?: string;
|
|
8
8
|
};
|
|
9
|
-
export declare const getSearchByActionItems: ({ action, searchQuery, setSearchByParamConfig, setSearchByAction, changeSearchQuery, }: GetSearchByActionItemsOptions) => import(
|
|
9
|
+
export declare const getSearchByActionItems: ({ action, searchQuery, setSearchByParamConfig, setSearchByAction, changeSearchQuery, }: GetSearchByActionItemsOptions) => import('@synerise/ds-list-item').ListItemProps[];
|
|
10
10
|
export {};
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Icon from
|
|
3
|
-
import { matchesSearchQuery } from
|
|
4
|
-
import { getActionItem } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import Icon from "@synerise/ds-icon";
|
|
3
|
+
import { matchesSearchQuery } from "../hooks/useItemsInSections.utils.js";
|
|
4
|
+
import { getActionItem } from "./actionItemsUtils.js";
|
|
5
|
+
const getSearchByActionItems = ({
|
|
6
|
+
action,
|
|
7
|
+
searchQuery,
|
|
8
|
+
setSearchByParamConfig,
|
|
9
|
+
setSearchByAction,
|
|
10
|
+
changeSearchQuery
|
|
11
|
+
}) => {
|
|
12
|
+
const filteredSearchParams = action?.searchParams?.filter((searchParam) => {
|
|
13
13
|
if (!searchQuery) {
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
16
|
return matchesSearchQuery(searchParam.searchLabel || searchParam.paramKeyLabel, searchQuery);
|
|
17
17
|
});
|
|
18
|
-
return filteredSearchParams.map(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
18
|
+
return filteredSearchParams.map((searchParam) => getActionItem({
|
|
19
|
+
text: searchParam.paramListLabel,
|
|
20
|
+
id: searchParam.paramKey,
|
|
21
|
+
actionType: "custom",
|
|
22
|
+
prefixel: searchParam.icon ? /* @__PURE__ */ jsx(Icon, { component: searchParam.icon }) : void 0,
|
|
23
|
+
onClick: () => {
|
|
24
|
+
changeSearchQuery("");
|
|
25
|
+
setSearchByParamConfig(searchParam);
|
|
26
|
+
setSearchByAction(void 0);
|
|
27
|
+
action.onSearchByParamClick?.(searchParam);
|
|
28
|
+
}
|
|
29
|
+
}, searchQuery));
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
getSearchByActionItems
|
|
33
|
+
};
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { isItems, isItemsConfig, isSearchByAction, isSearchInAction, isTitle, isTruthy, isWithOutSections } from "./typeguards.utils.js";
|
|
2
|
+
import { isNavKey } from "./isNavKey.js";
|
|
3
|
+
import { createTitleFromTitlePath } from "./createTitleFromTitlePath.js";
|
|
4
|
+
import { findSectionById } from "./findSectionById.js";
|
|
5
|
+
export {
|
|
6
|
+
createTitleFromTitlePath,
|
|
7
|
+
findSectionById,
|
|
8
|
+
isItems,
|
|
9
|
+
isItemsConfig,
|
|
10
|
+
isNavKey,
|
|
11
|
+
isSearchByAction,
|
|
12
|
+
isSearchInAction,
|
|
13
|
+
isTitle,
|
|
14
|
+
isTruthy,
|
|
15
|
+
isWithOutSections
|
|
16
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
2
2
|
export declare const isNavKey: (event: KeyboardEvent) => boolean;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const NAV_KEYS = ["ArrowUp", "Enter", "ArrowDown"];
|
|
2
|
+
const isNavKey = (event) => {
|
|
3
3
|
return NAV_KEYS.includes(event.key);
|
|
4
|
-
};
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
isNavKey
|
|
7
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { SearchInAction } from '../../ItemPickerNew/types/actions.types';
|
|
2
|
+
import { BaseItemType, BaseSectionType } from '../../ItemPickerNew/types/baseItemSectionType.types';
|
|
3
3
|
type ResolveSectionIdOptions<ItemType extends BaseItemType> = {
|
|
4
4
|
searchInItem: ItemType | undefined;
|
|
5
5
|
searchInAction: SearchInAction | undefined;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const resolveSectionId = ({
|
|
2
|
+
currentSection,
|
|
3
|
+
searchInAction,
|
|
4
|
+
searchInItem
|
|
5
|
+
}) => {
|
|
5
6
|
if (searchInAction) {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const {
|
|
8
|
+
searchInSectionId,
|
|
9
|
+
loadItemsSectionId
|
|
10
|
+
} = searchInAction;
|
|
8
11
|
if (searchInItem) {
|
|
9
12
|
return {
|
|
10
13
|
isListItemsRenderingMode: !!searchInSectionId,
|
|
11
|
-
activeSectionId: searchInSectionId ||
|
|
14
|
+
activeSectionId: searchInSectionId || currentSection?.id
|
|
12
15
|
};
|
|
13
16
|
}
|
|
14
17
|
return {
|
|
@@ -18,6 +21,9 @@ export var resolveSectionId = function resolveSectionId(_ref) {
|
|
|
18
21
|
}
|
|
19
22
|
return {
|
|
20
23
|
isListItemsRenderingMode: false,
|
|
21
|
-
activeSectionId: currentSection
|
|
24
|
+
activeSectionId: currentSection?.id
|
|
22
25
|
};
|
|
23
|
-
};
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
resolveSectionId
|
|
29
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { ListItemProps } from '@synerise/ds-list-item';
|
|
2
|
+
import { ItemLoaderConfig, ItemsConfig } from '../../ItemPickerNew/ItemPickerNew.types';
|
|
3
|
+
import { Action, SearchByAction, SearchInAction } from '../../ItemPickerNew/types/actions.types';
|
|
4
|
+
import { BaseItemType, BaseSectionType, BaseSectionTypeWithFolders } from '../../ItemPickerNew/types/baseItemSectionType.types';
|
|
5
|
+
import { TitleListItemProps } from '../ItemPickerList.types';
|
|
6
6
|
export declare const isTitle: (item: TitleListItemProps | ListItemProps) => item is TitleListItemProps;
|
|
7
7
|
export declare const isItems: <ItemType extends BaseItemType>(items: ItemType[] | ItemsConfig<ItemType> | ItemLoaderConfig<ItemType>) => items is ItemType[];
|
|
8
8
|
export declare const isItemsConfig: <ItemType extends BaseItemType>(items: ItemType[] | ItemsConfig<ItemType> | ItemLoaderConfig<ItemType>) => items is ItemsConfig<ItemType>;
|
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
import { ACTION_TYPES } from
|
|
2
|
-
|
|
3
|
-
return
|
|
1
|
+
import { ACTION_TYPES } from "../../ItemPickerNew/types/actions.types.js";
|
|
2
|
+
const isTitle = (item) => {
|
|
3
|
+
return "type" in item && item.type === "title";
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
const isItems = (items) => {
|
|
6
6
|
if (Array.isArray(items)) {
|
|
7
7
|
return true;
|
|
8
8
|
}
|
|
9
9
|
return false;
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
if (
|
|
11
|
+
const isItemsConfig = (items) => {
|
|
12
|
+
if ("items" in items && Array.isArray(items.items)) {
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
15
|
return false;
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
return sections ===
|
|
17
|
+
const isWithOutSections = (sections) => {
|
|
18
|
+
return sections === void 0;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
const isTruthy = (value) => {
|
|
21
21
|
return Boolean(value);
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
return
|
|
23
|
+
const isSearchByAction = (action) => {
|
|
24
|
+
return action?.actionType === ACTION_TYPES.searchBy;
|
|
25
|
+
};
|
|
26
|
+
const isSearchInAction = (action) => {
|
|
27
|
+
return action?.actionType === ACTION_TYPES.searchIn;
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
isItems,
|
|
31
|
+
isItemsConfig,
|
|
32
|
+
isSearchByAction,
|
|
33
|
+
isSearchInAction,
|
|
34
|
+
isTitle,
|
|
35
|
+
isTruthy,
|
|
36
|
+
isWithOutSections
|
|
25
37
|
};
|
|
26
|
-
export var isSearchInAction = function isSearchInAction(action) {
|
|
27
|
-
return (action == null ? void 0 : action.actionType) === ACTION_TYPES.searchIn;
|
|
28
|
-
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ItemPickerListRef } from '../ItemPickerList/ItemPickerList.types';
|
|
3
|
+
import { ItemPickerProps } from './ItemPickerNew.types';
|
|
4
|
+
import { BaseItemType, BaseSectionType } from './types/baseItemSectionType.types';
|
|
5
5
|
declare const ItemPickerNewInner: <ItemType extends BaseItemType, SectionType extends BaseSectionType>({ onFocus, onBlur, onClear, selectedItem, onChange, dropdownProps, texts, triggerProps, renderTrigger, placeholder, placeholderIcon, label, description, error, errorMessage, errorText, disabled, tooltip, tooltipConfig, ...rest }: ItemPickerProps<ItemType, SectionType>, forwardedRef: ItemPickerListRef) => React.JSX.Element;
|
|
6
6
|
type ItemPickerNewType = <ItemType extends BaseItemType, SectionType extends BaseSectionType>(p: ItemPickerProps<ItemType, SectionType> & {
|
|
7
7
|
ref?: ItemPickerListRef;
|
|
@@ -1,42 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var _useState2 = useState(false),
|
|
36
|
-
visible = _useState2[0],
|
|
37
|
-
setVisible = _useState2[1];
|
|
38
|
-
var allTexts = useDefaultTexts(texts);
|
|
39
|
-
var handleVisibilityChange = function handleVisibilityChange(state) {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useEffect, useMemo } from "react";
|
|
3
|
+
import Dropdown from "@synerise/ds-dropdown";
|
|
4
|
+
import FormField from "@synerise/ds-form-field";
|
|
5
|
+
import { ItemPickerWrapper } from "../../ItemPicker.styles.js";
|
|
6
|
+
import { useDefaultTexts } from "../../hooks/useDefaultTexts.js";
|
|
7
|
+
import { ItemPickerList } from "../ItemPickerList/ItemPickerList.js";
|
|
8
|
+
import Trigger from "../ItemPickerTrigger/Trigger.js";
|
|
9
|
+
const ItemPickerNewInner = ({
|
|
10
|
+
onFocus,
|
|
11
|
+
onBlur,
|
|
12
|
+
onClear,
|
|
13
|
+
selectedItem,
|
|
14
|
+
onChange,
|
|
15
|
+
dropdownProps,
|
|
16
|
+
texts,
|
|
17
|
+
triggerProps,
|
|
18
|
+
renderTrigger,
|
|
19
|
+
placeholder,
|
|
20
|
+
placeholderIcon,
|
|
21
|
+
label,
|
|
22
|
+
description,
|
|
23
|
+
error,
|
|
24
|
+
errorMessage,
|
|
25
|
+
errorText,
|
|
26
|
+
disabled,
|
|
27
|
+
tooltip,
|
|
28
|
+
tooltipConfig,
|
|
29
|
+
...rest
|
|
30
|
+
}, forwardedRef) => {
|
|
31
|
+
const [selected, setSelected] = useState(selectedItem);
|
|
32
|
+
const [visible, setVisible] = useState(false);
|
|
33
|
+
const allTexts = useDefaultTexts(texts);
|
|
34
|
+
const handleVisibilityChange = (state) => {
|
|
40
35
|
setVisible(state);
|
|
41
36
|
if (state) {
|
|
42
37
|
onFocus && onFocus();
|
|
@@ -44,72 +39,35 @@ var ItemPickerNewInner = function ItemPickerNewInner(_ref, forwardedRef) {
|
|
|
44
39
|
onBlur && onBlur();
|
|
45
40
|
}
|
|
46
41
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return setVisible(false);
|
|
52
|
-
};
|
|
53
|
-
var handleItemSelect = function handleItemSelect(item) {
|
|
54
|
-
onChange == null || onChange(item);
|
|
42
|
+
const openDropdown = () => setVisible(true);
|
|
43
|
+
const closeDropdown = () => setVisible(false);
|
|
44
|
+
const handleItemSelect = (item) => {
|
|
45
|
+
onChange?.(item);
|
|
55
46
|
closeDropdown();
|
|
56
47
|
};
|
|
57
|
-
useEffect(
|
|
58
|
-
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
setSelected(selectedItem);
|
|
50
|
+
if (selectedItem) {
|
|
51
|
+
setVisible(false);
|
|
52
|
+
}
|
|
59
53
|
}, [selectedItem]);
|
|
60
|
-
|
|
54
|
+
const trigger = useMemo(() => {
|
|
61
55
|
return renderTrigger ? renderTrigger({
|
|
62
56
|
selected: selectedItem,
|
|
63
|
-
openDropdown
|
|
64
|
-
closeDropdown
|
|
65
|
-
error
|
|
66
|
-
disabled
|
|
67
|
-
}) :
|
|
68
|
-
size: "small"
|
|
69
|
-
}, triggerProps, {
|
|
70
|
-
opened: visible,
|
|
71
|
-
texts: allTexts,
|
|
72
|
-
disabled: disabled,
|
|
73
|
-
placeholder: placeholder,
|
|
74
|
-
placeholderIcon: placeholderIcon,
|
|
75
|
-
selected: selectedItem,
|
|
76
|
-
onClear: onClear,
|
|
77
|
-
openDropdown: openDropdown,
|
|
78
|
-
closeDropdown: closeDropdown,
|
|
79
|
-
error: error
|
|
80
|
-
}));
|
|
57
|
+
openDropdown,
|
|
58
|
+
closeDropdown,
|
|
59
|
+
error,
|
|
60
|
+
disabled
|
|
61
|
+
}) : /* @__PURE__ */ jsx(Trigger, { size: "small", ...triggerProps, opened: visible, texts: allTexts, disabled, placeholder, placeholderIcon, selected: selectedItem, onClear, openDropdown, closeDropdown, error });
|
|
81
62
|
}, [allTexts, disabled, error, onClear, placeholder, placeholderIcon, renderTrigger, selectedItem, triggerProps, visible]);
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
overlayStyle: {
|
|
93
|
-
minWidth: '400px'
|
|
94
|
-
},
|
|
95
|
-
size: "match-trigger",
|
|
96
|
-
asChild: true
|
|
97
|
-
}, dropdownProps, {
|
|
98
|
-
popoverProps: _extends({
|
|
99
|
-
testId: 'item-picker'
|
|
100
|
-
}, dropdownProps == null ? void 0 : dropdownProps.popoverProps),
|
|
101
|
-
open: visible,
|
|
102
|
-
trigger: ['click'],
|
|
103
|
-
disabled: disabled,
|
|
104
|
-
onOpenChange: handleVisibilityChange,
|
|
105
|
-
overlay: /*#__PURE__*/React.createElement(ItemPickerList, _extends({}, rest, {
|
|
106
|
-
isDropdown: true,
|
|
107
|
-
texts: allTexts,
|
|
108
|
-
isVisible: visible,
|
|
109
|
-
selectedItem: selected,
|
|
110
|
-
onItemSelect: handleItemSelect,
|
|
111
|
-
ref: forwardedRef
|
|
112
|
-
}))
|
|
113
|
-
}), trigger)));
|
|
63
|
+
return /* @__PURE__ */ jsx(ItemPickerWrapper, { className: "ds-items-picker", disabled, children: /* @__PURE__ */ jsx(FormField, { label, tooltip, tooltipConfig, errorText: errorText || errorMessage, description, children: /* @__PURE__ */ jsx(Dropdown, { overlayStyle: {
|
|
64
|
+
minWidth: "400px"
|
|
65
|
+
}, size: "match-trigger", asChild: true, ...dropdownProps, popoverProps: {
|
|
66
|
+
testId: "item-picker",
|
|
67
|
+
...dropdownProps?.popoverProps
|
|
68
|
+
}, open: visible, trigger: ["click"], disabled, onOpenChange: handleVisibilityChange, overlay: /* @__PURE__ */ jsx(ItemPickerList, { ...rest, isDropdown: true, texts: allTexts, isVisible: visible, selectedItem: selected, onItemSelect: handleItemSelect, ref: forwardedRef }), children: trigger }) }) });
|
|
69
|
+
};
|
|
70
|
+
const ItemPickerNew = forwardRef(ItemPickerNewInner);
|
|
71
|
+
export {
|
|
72
|
+
ItemPickerNew
|
|
114
73
|
};
|
|
115
|
-
export var ItemPickerNew = /*#__PURE__*/forwardRef(ItemPickerNewInner);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
1
|
+
import { ItemSelectHandler } from 'components/ItemPickerList/ItemPickerList.types';
|
|
2
|
+
import { ReactElement, ReactNode, Ref } from 'react';
|
|
3
|
+
import { DropdownSharedProps } from '@synerise/ds-dropdown';
|
|
4
|
+
import { FormFieldCommonProps } from '@synerise/ds-form-field';
|
|
5
|
+
import { InformationCardTooltipProps } from '@synerise/ds-information-card';
|
|
6
|
+
import { ScrollbarAdditionalProps } from '@synerise/ds-scrollbar';
|
|
7
|
+
import { SearchBarProps } from '@synerise/ds-search-bar';
|
|
8
|
+
import { WithHTMLAttributes } from '@synerise/ds-utils';
|
|
9
|
+
import { RenderMode } from '../ItemPickerList/types/renderMode';
|
|
10
|
+
import { ItemPickerTriggerProps, ItemPickerTriggerTexts } from '../ItemPickerTrigger/Trigger.types';
|
|
11
|
+
import { Action } from './types/actions.types';
|
|
12
|
+
import { BaseItemType, BaseSectionType, BaseSectionTypeWithFolders } from './types/baseItemSectionType.types';
|
|
13
|
+
import { ItemPickerListTexts } from './types/itemPickerListTexts.types';
|
|
14
14
|
type HeightConfig = {
|
|
15
15
|
defaultHeight: number;
|
|
16
16
|
viewportHeightThreshold?: number;
|
|
@@ -68,15 +68,17 @@ export type ItemPickerProps<ItemType extends BaseItemType, SectionType extends B
|
|
|
68
68
|
onBlur?: () => void;
|
|
69
69
|
onLoadedData?: OnLoadedData;
|
|
70
70
|
dropdownProps?: Partial<Omit<DropdownSharedProps, 'children' | 'overlay' | 'disabled'>>;
|
|
71
|
-
} & Pick<ItemPickerListProps<ItemType, SectionType>, 'items' | 'actions' | 'recents' | 'sections' | 'isLoading' | 'onRefresh' | 'onSectionChange' | 'containerHeight' | 'showItemsSectionLabel' | 'noResultsIcon' | 'emptyListIcon' | 'selectedItem' | 'getItemHeight' | 'scrollbarProps' | 'searchBarProps' | 'includeFooter' | 'includeSearchBar'>> & FormFieldCommonProps & Partial<Pick<ItemPickerTriggerProps, 'placeholder' | 'placeholderIcon' | 'onClear'>>;
|
|
71
|
+
} & Pick<ItemPickerListProps<ItemType, SectionType>, 'items' | 'actions' | 'recents' | 'sections' | 'isLoading' | 'onRefresh' | 'onSectionChange' | 'containerHeight' | 'showItemsSectionLabel' | 'noResultsIcon' | 'emptyListIcon' | 'emptyStateComponent' | 'noResultsComponent' | 'selectedItem' | 'getItemHeight' | 'scrollbarProps' | 'searchBarProps' | 'includeFooter' | 'includeSearchBar'>> & FormFieldCommonProps & Partial<Pick<ItemPickerTriggerProps, 'placeholder' | 'placeholderIcon' | 'onClear'>>;
|
|
72
72
|
export type ItemPickerListProps<ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined> = WithHTMLAttributes<HTMLDivElement, {
|
|
73
73
|
recents?: ItemType[];
|
|
74
74
|
actions?: Action[];
|
|
75
75
|
texts?: Partial<ItemPickerListTexts>;
|
|
76
76
|
containerHeight?: ContainerHeightType;
|
|
77
77
|
showItemsSectionLabel?: boolean;
|
|
78
|
-
noResultsIcon?:
|
|
79
|
-
emptyListIcon?:
|
|
78
|
+
noResultsIcon?: ReactElement;
|
|
79
|
+
emptyListIcon?: ReactElement;
|
|
80
|
+
emptyStateComponent?: ReactNode;
|
|
81
|
+
noResultsComponent?: ReactNode;
|
|
80
82
|
onItemSelect: ItemSelectHandler<ItemType, SectionType>;
|
|
81
83
|
onSectionChange?: SectionType extends BaseSectionType ? (section?: BaseSectionTypeWithFolders<SectionType>) => void : undefined;
|
|
82
84
|
selectedItem?: ItemType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BaseItemType, BaseSectionType, InheritedFromListItem } from './baseItemSectionType.types';
|
|
3
3
|
export declare const ACTION_TYPES: {
|
|
4
4
|
readonly redirect: "redirect";
|
|
5
5
|
readonly custom: "custom";
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
redirect:
|
|
3
|
-
custom:
|
|
4
|
-
searchBy:
|
|
5
|
-
searchIn:
|
|
1
|
+
const ACTION_TYPES = {
|
|
2
|
+
redirect: "redirect",
|
|
3
|
+
custom: "custom",
|
|
4
|
+
searchBy: "searchBy",
|
|
5
|
+
searchIn: "searchIn"
|
|
6
|
+
};
|
|
7
|
+
const CONTEXT_AWARE_ACTIONS = [ACTION_TYPES.searchBy, ACTION_TYPES.searchIn];
|
|
8
|
+
export {
|
|
9
|
+
ACTION_TYPES,
|
|
10
|
+
CONTEXT_AWARE_ACTIONS
|
|
6
11
|
};
|
|
7
|
-
export var CONTEXT_AWARE_ACTIONS = [ACTION_TYPES.searchBy, ACTION_TYPES.searchIn];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { InformationCardProps } from '@synerise/ds-information-card';
|
|
2
|
+
import { ListItemProps } from '@synerise/ds-list-item';
|
|
3
|
+
import { ItemPickerListTexts } from './itemPickerListTexts.types';
|
|
4
4
|
export type InheritedFromListItem = Pick<ListItemProps, 'id' | 'type' | 'selected' | 'prefixel' | 'prefixVisibilityTrigger' | 'suffixel' | 'suffixVisibilityTrigger' | 'highlight' | 'renderHoverTooltip' | 'popoverProps' | 'timeToHideTooltip'>;
|
|
5
5
|
export type BaseSectionType = InheritedFromListItem & {
|
|
6
6
|
text: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type TextsAsReactNode = 'basicSearchPlaceholder' | 'searchPlaceholder' | 'refreshButtonLabel' | 'showMoreResultsLabel' | 'noItems' | 'noResults' | 'noResultsInSection' | 'searchAllFoldersButtonLabel' | 'recentsSectionLabel' | 'actionsSectionLabel' | 'resultsSectionLabel' | 'noActions' | 'itemsSectionLabel' | 'infiniteScrollLoadingMore' | 'infiniteScrollLoadingError' | 'errorMessageTitle' | 'errorMessageDetails' | 'backTooltip' | 'clearSearchTooltip' | 'infiniteScrollAllLoaded';
|
|
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';
|
|
3
3
|
export type ItemPickerListTexts = {
|
|
4
4
|
[key in TextsAsReactNode]: ReactNode;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import { default as React } from 'react';
|
|
2
2
|
declare const Trigger: React.ForwardRefExoticComponent<{
|
|
3
3
|
openDropdown: () => void;
|
|
4
4
|
closeDropdown: () => void;
|
|
5
|
-
size: import(
|
|
5
|
+
size: import('../ItemPickerLegacy/ItemPickerLegacy.types').ItemPickerSize;
|
|
6
6
|
clear?: React.ReactNode;
|
|
7
7
|
onClear?: () => void;
|
|
8
8
|
opened: boolean;
|
|
@@ -10,13 +10,13 @@ declare const Trigger: React.ForwardRefExoticComponent<{
|
|
|
10
10
|
placeholderIcon?: React.ReactNode;
|
|
11
11
|
error?: boolean;
|
|
12
12
|
disabled?: boolean;
|
|
13
|
-
selected?: import(
|
|
13
|
+
selected?: import('@synerise/ds-list-item').ListItemProps;
|
|
14
14
|
changeButtonLabel?: React.ReactNode;
|
|
15
15
|
withChangeButton?: boolean;
|
|
16
16
|
clearConfirmTitle?: string;
|
|
17
17
|
yesText?: string;
|
|
18
18
|
noText?: string;
|
|
19
19
|
withClearConfirmation?: boolean;
|
|
20
|
-
texts?: Partial<import(
|
|
21
|
-
} & Pick<import(
|
|
20
|
+
texts?: Partial<import('./Trigger.types').ItemPickerTriggerTexts>;
|
|
21
|
+
} & Pick<import('../..').ItemPickerProps, "informationCardTooltipProps"> & React.RefAttributes<HTMLDivElement>>;
|
|
22
22
|
export default Trigger;
|