@synerise/ds-item-picker 1.17.0 → 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 +4 -0
- 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 +4 -4
- package/dist/components/ItemPickerList/ItemPickerList.js +199 -267
- 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 +3 -3
- package/dist/components/ItemPickerList/components/EmptyListMessage.js +27 -40
- 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 +55 -100
- package/dist/components/ItemPickerNew/ItemPickerNew.types.d.ts +13 -13
- 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 +1 -1
- 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 -121
- 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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.17.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-item-picker@1.17.0...@synerise/ds-item-picker@1.17.1) (2026-03-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-item-picker
|
|
9
|
+
|
|
6
10
|
# [1.17.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-item-picker@1.16.2...@synerise/ds-item-picker@1.17.0) (2026-03-20)
|
|
7
11
|
|
|
8
12
|
### Bug Fixes
|
package/dist/ItemPicker.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ItemPickerProps } from './components/ItemPickerLegacy/ItemPickerLegacy.types';
|
|
3
|
+
import { ItemPickerListRef } from './components/ItemPickerList/ItemPickerList.types';
|
|
4
|
+
import { ItemPickerProps as ItemPickerPropsNew } from './components/ItemPickerNew/ItemPickerNew.types';
|
|
5
|
+
import { BaseItemType, BaseSectionType } from './components/ItemPickerNew/types/baseItemSectionType.types';
|
|
6
6
|
declare const ItemPickerInner: <ItemType extends BaseItemType, SectionType extends BaseSectionType | undefined>(props: ItemPickerProps | ItemPickerPropsNew<ItemType, SectionType>, forwardedRef: ItemPickerListRef) => React.JSX.Element;
|
|
7
7
|
type ItemPickerType = <ItemType extends BaseItemType, SectionType extends BaseSectionType>(p: ItemPickerProps | (ItemPickerPropsNew<ItemType, SectionType> & {
|
|
8
8
|
ref?: ItemPickerListRef;
|
package/dist/ItemPicker.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import ItemPickerLegacy from
|
|
4
|
-
import { ItemPickerNew } from
|
|
5
|
-
|
|
6
|
-
return
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import ItemPickerLegacy from "./components/ItemPickerLegacy/ItemPickerLegacy.js";
|
|
4
|
+
import { ItemPickerNew } from "./components/ItemPickerNew/ItemPickerNew.js";
|
|
5
|
+
const isNewItemPicker = (props) => {
|
|
6
|
+
return "isNewVersion" in props && props.isNewVersion;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
const ItemPickerInner = (props, forwardedRef) => {
|
|
9
9
|
if (isNewItemPicker(props)) {
|
|
10
|
-
return
|
|
11
|
-
key: "ds-item-picker"
|
|
12
|
-
}, props, {
|
|
13
|
-
ref: forwardedRef
|
|
14
|
-
}));
|
|
10
|
+
return /* @__PURE__ */ jsx(ItemPickerNew, { ...props, ref: forwardedRef }, "ds-item-picker");
|
|
15
11
|
}
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
return /* @__PURE__ */ jsx(ItemPickerLegacy, { ...props }, "ds-item-picker-legacy");
|
|
13
|
+
};
|
|
14
|
+
const ItemPicker = forwardRef(ItemPickerInner);
|
|
15
|
+
export {
|
|
16
|
+
ItemPicker as default
|
|
19
17
|
};
|
|
20
|
-
var ItemPicker = /*#__PURE__*/forwardRef(ItemPickerInner);
|
|
21
|
-
export default ItemPicker;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const ItemPickerWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "ItemPickerstyles__ItemPickerWrapper",
|
|
4
4
|
componentId: "sc-1dxa5ip-0"
|
|
5
|
-
})(["position:relative;"]);
|
|
5
|
+
})(["position:relative;"]);
|
|
6
|
+
export {
|
|
7
|
+
ItemPickerWrapper
|
|
8
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ItemPickerDropdownProps } from './ItemPickerDropdown.types';
|
|
3
3
|
declare const ItemPickerDropdown: ({ onChange, placeholder, dataSource, closeDropdown, noResults, dropdownVisibleRows, dropdownRowHeight, dropdownBottomAction, closeOnBottomAction, isDropdownOpened, searchBarProps, hideSearchBar, scrollbarProps, clearSearchQuery, }: ItemPickerDropdownProps) => React.JSX.Element;
|
|
4
4
|
export default ItemPickerDropdown;
|
|
@@ -1,47 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import Icon, { SearchM } from
|
|
4
|
-
import Result from
|
|
5
|
-
import SearchBar from
|
|
6
|
-
import { SearchItems } from
|
|
7
|
-
import { useKeyboardShortcuts } from
|
|
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
|
-
scrollTop = _useState2[0],
|
|
34
|
-
setScrollTop = _useState2[1];
|
|
35
|
-
var containerRef = useRef(null);
|
|
36
|
-
useEffect(function () {
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect, useMemo } from "react";
|
|
3
|
+
import Icon, { SearchM } from "@synerise/ds-icon";
|
|
4
|
+
import Result from "@synerise/ds-result";
|
|
5
|
+
import SearchBar from "@synerise/ds-search-bar";
|
|
6
|
+
import { SearchItems } from "@synerise/ds-search/dist/Elements";
|
|
7
|
+
import { useKeyboardShortcuts } from "@synerise/ds-utils";
|
|
8
|
+
import { DropdownWrapper, ListWrapper, StyledScrollbar, ListItem, DropdownFooter, BottomActionWrapper } from "./ItemPickerDropdown.style.js";
|
|
9
|
+
const DEFAULT_ROW_HEIGHT = 32;
|
|
10
|
+
const DEFAULT_VISIBLE_ROWS = 10;
|
|
11
|
+
const ItemPickerDropdown = ({
|
|
12
|
+
onChange,
|
|
13
|
+
placeholder,
|
|
14
|
+
dataSource,
|
|
15
|
+
closeDropdown,
|
|
16
|
+
noResults,
|
|
17
|
+
dropdownVisibleRows,
|
|
18
|
+
dropdownRowHeight,
|
|
19
|
+
dropdownBottomAction,
|
|
20
|
+
closeOnBottomAction,
|
|
21
|
+
isDropdownOpened,
|
|
22
|
+
searchBarProps,
|
|
23
|
+
hideSearchBar,
|
|
24
|
+
scrollbarProps,
|
|
25
|
+
clearSearchQuery
|
|
26
|
+
}) => {
|
|
27
|
+
const rowCount = dropdownVisibleRows || DEFAULT_VISIBLE_ROWS;
|
|
28
|
+
const rowHeight = dropdownRowHeight || DEFAULT_ROW_HEIGHT;
|
|
29
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
30
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
31
|
+
const containerRef = useRef(null);
|
|
32
|
+
useEffect(() => {
|
|
37
33
|
if (clearSearchQuery && clearSearchQuery > 0) {
|
|
38
|
-
setSearchQuery(
|
|
34
|
+
setSearchQuery("");
|
|
39
35
|
}
|
|
40
36
|
}, [clearSearchQuery]);
|
|
41
37
|
useKeyboardShortcuts({
|
|
42
|
-
Escape:
|
|
43
|
-
|
|
44
|
-
if (!((_containerRef$current = containerRef.current) != null && _containerRef$current.offsetParent)) {
|
|
38
|
+
Escape: (event) => {
|
|
39
|
+
if (!containerRef.current?.offsetParent) {
|
|
45
40
|
return;
|
|
46
41
|
}
|
|
47
42
|
if (!searchQuery) {
|
|
@@ -51,70 +46,34 @@ var ItemPickerDropdown = function ItemPickerDropdown(_ref) {
|
|
|
51
46
|
}
|
|
52
47
|
}
|
|
53
48
|
});
|
|
54
|
-
|
|
55
|
-
setSearchQuery(
|
|
49
|
+
const handleClose = () => {
|
|
50
|
+
setSearchQuery("");
|
|
56
51
|
closeDropdown();
|
|
57
52
|
};
|
|
58
|
-
|
|
53
|
+
const handleChange = (item) => {
|
|
59
54
|
handleClose();
|
|
60
55
|
onChange(item);
|
|
61
56
|
};
|
|
62
|
-
|
|
63
|
-
return searchQuery ? dataSource.filter(
|
|
64
|
-
return item.text && String(item.text).toLowerCase().includes(searchQuery.toLowerCase());
|
|
65
|
-
}) : dataSource;
|
|
57
|
+
const filteredDataSource = useMemo(() => {
|
|
58
|
+
return searchQuery ? dataSource.filter((item) => item.text && String(item.text).toLowerCase().includes(searchQuery.toLowerCase())) : dataSource;
|
|
66
59
|
}, [searchQuery, dataSource]);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}, dropdownBottomAction);
|
|
71
|
-
return dropdownBottomAction && /*#__PURE__*/React.createElement(S.DropdownFooter, null, bottomAction);
|
|
60
|
+
const renderBottomAction = () => {
|
|
61
|
+
const bottomAction = !closeOnBottomAction ? dropdownBottomAction : /* @__PURE__ */ jsx(BottomActionWrapper, { onClick: handleClose, children: dropdownBottomAction });
|
|
62
|
+
return dropdownBottomAction && /* @__PURE__ */ jsx(DropdownFooter, { children: bottomAction });
|
|
72
63
|
};
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
type: "no-results",
|
|
89
|
-
description: noResults
|
|
90
|
-
}), /*#__PURE__*/React.createElement(S.StyledScrollbar, _extends({
|
|
91
|
-
maxHeight: rowCount * rowHeight,
|
|
92
|
-
absolute: true,
|
|
93
|
-
onScroll: function onScroll(event) {
|
|
94
|
-
return setScrollTop(event.currentTarget.scrollTop);
|
|
95
|
-
},
|
|
96
|
-
style: {
|
|
97
|
-
paddingRight: '8px'
|
|
98
|
-
}
|
|
99
|
-
}, scrollbarProps), /*#__PURE__*/React.createElement(SearchItems, {
|
|
100
|
-
data: filteredDataSource,
|
|
101
|
-
highlight: (_searchBarProps$value = searchBarProps == null ? void 0 : searchBarProps.value) != null ? _searchBarProps$value : searchQuery,
|
|
102
|
-
itemRender: function itemRender(item) {
|
|
103
|
-
return /*#__PURE__*/React.createElement(S.ListItem, _extends({
|
|
104
|
-
key: item == null ? void 0 : item.text
|
|
105
|
-
}, item));
|
|
106
|
-
},
|
|
107
|
-
onItemClick: function onItemClick(i) {
|
|
108
|
-
return handleChange(i);
|
|
109
|
-
},
|
|
110
|
-
rowHeight: rowHeight,
|
|
111
|
-
height: rowCount * rowHeight,
|
|
112
|
-
visibleRows: rowCount,
|
|
113
|
-
listProps: {
|
|
114
|
-
scrollTop: scrollTop
|
|
115
|
-
},
|
|
116
|
-
width: "100%",
|
|
117
|
-
renderInMenu: false
|
|
118
|
-
}))), renderBottomAction());
|
|
64
|
+
return /* @__PURE__ */ jsxs(DropdownWrapper, { ref: containerRef, "data-testid": "ds-item-picker-dropdown", children: [
|
|
65
|
+
hideSearchBar !== true && /* @__PURE__ */ jsx(SearchBar, { iconLeft: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(SearchM, {}) }), onSearchChange: setSearchQuery, placeholder, value: searchQuery, onClearInput: () => setSearchQuery(""), autofocus: isDropdownOpened, ...searchBarProps }),
|
|
66
|
+
/* @__PURE__ */ jsxs(ListWrapper, { children: [
|
|
67
|
+
filteredDataSource?.length === 0 && /* @__PURE__ */ jsx(Result, { type: "no-results", description: noResults }),
|
|
68
|
+
/* @__PURE__ */ jsx(StyledScrollbar, { maxHeight: rowCount * rowHeight, absolute: true, onScroll: (event) => setScrollTop(event.currentTarget.scrollTop), style: {
|
|
69
|
+
paddingRight: "8px"
|
|
70
|
+
}, ...scrollbarProps, children: /* @__PURE__ */ jsx(SearchItems, { data: filteredDataSource, highlight: searchBarProps?.value ?? searchQuery, itemRender: (item) => /* @__PURE__ */ jsx(ListItem, { ...item }, item?.text), onItemClick: (i) => handleChange(i), rowHeight, height: rowCount * rowHeight, visibleRows: rowCount, listProps: {
|
|
71
|
+
scrollTop
|
|
72
|
+
}, width: "100%", renderInMenu: false }) })
|
|
73
|
+
] }),
|
|
74
|
+
renderBottomAction()
|
|
75
|
+
] });
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
ItemPickerDropdown as default
|
|
119
79
|
};
|
|
120
|
-
export default ItemPickerDropdown;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const DropdownWrapper: import(
|
|
1
|
+
import { StyledListItem } from '@synerise/ds-list-item';
|
|
2
|
+
import { ScrollbarProps } from '@synerise/ds-scrollbar';
|
|
3
|
+
export declare const DropdownWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
4
4
|
export declare const ListItem: StyledListItem;
|
|
5
|
-
export declare const ListWrapper: import(
|
|
6
|
-
export declare const StyledScrollbar: import(
|
|
7
|
-
export declare const DropdownFooter: import(
|
|
8
|
-
export declare const BottomActionWrapper: import(
|
|
5
|
+
export declare const ListWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const StyledScrollbar: import('styled-components').StyledComponent<import('react').ForwardRefExoticComponent<(ScrollbarProps | import('@synerise/ds-scrollbar').VirtualScrollbarProps) & import('react').RefAttributes<HTMLElement>>, any, ScrollbarProps, never>;
|
|
7
|
+
export declare const DropdownFooter: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const BottomActionWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -1,34 +1,37 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
import DSListItem from
|
|
3
|
-
import Scrollbar from
|
|
4
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import DSListItem from "@synerise/ds-list-item";
|
|
3
|
+
import Scrollbar from "@synerise/ds-scrollbar";
|
|
4
|
+
const DropdownWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
5
5
|
displayName: "ItemPickerDropdownstyle__DropdownWrapper",
|
|
6
6
|
componentId: "sc-1y4j72s-0"
|
|
7
7
|
})(["display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;width:100%;"]);
|
|
8
|
-
|
|
8
|
+
const ListItem = /* @__PURE__ */ styled(DSListItem).withConfig({
|
|
9
9
|
displayName: "ItemPickerDropdownstyle__ListItem",
|
|
10
10
|
componentId: "sc-1y4j72s-1"
|
|
11
11
|
})(["min-width:auto;"]);
|
|
12
|
-
|
|
12
|
+
const ListWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
13
13
|
displayName: "ItemPickerDropdownstyle__ListWrapper",
|
|
14
14
|
componentId: "sc-1y4j72s-2"
|
|
15
|
-
})(["display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;padding:8px 0 8px 8px;background:", ";"],
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export var StyledScrollbar = styled(Scrollbar).withConfig({
|
|
15
|
+
})(["display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;padding:8px 0 8px 8px;background:", ";"], ({
|
|
16
|
+
theme
|
|
17
|
+
}) => theme.palette.white);
|
|
18
|
+
const StyledScrollbar = /* @__PURE__ */ styled(Scrollbar).withConfig({
|
|
20
19
|
displayName: "ItemPickerDropdownstyle__StyledScrollbar",
|
|
21
20
|
componentId: "sc-1y4j72s-3"
|
|
22
21
|
})(["&&{.scrollbar-container{padding-right:8px;}}"]);
|
|
23
|
-
|
|
22
|
+
const DropdownFooter = /* @__PURE__ */ styled.div.withConfig({
|
|
24
23
|
displayName: "ItemPickerDropdownstyle__DropdownFooter",
|
|
25
24
|
componentId: "sc-1y4j72s-4"
|
|
26
|
-
})(["background-color:", ";height:52px;display:flex;align-items:center;border-top:1px solid ", ";cursor:default;margin:0;padding:0 8px;"],
|
|
27
|
-
|
|
28
|
-
}, function (props) {
|
|
29
|
-
return props.theme.palette['grey-100'];
|
|
30
|
-
});
|
|
31
|
-
export var BottomActionWrapper = styled.div.withConfig({
|
|
25
|
+
})(["background-color:", ";height:52px;display:flex;align-items:center;border-top:1px solid ", ";cursor:default;margin:0;padding:0 8px;"], (props) => props.theme.palette["grey-050"], (props) => props.theme.palette["grey-100"]);
|
|
26
|
+
const BottomActionWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
32
27
|
displayName: "ItemPickerDropdownstyle__BottomActionWrapper",
|
|
33
28
|
componentId: "sc-1y4j72s-5"
|
|
34
|
-
})([""]);
|
|
29
|
+
})([""]);
|
|
30
|
+
export {
|
|
31
|
+
BottomActionWrapper,
|
|
32
|
+
DropdownFooter,
|
|
33
|
+
DropdownWrapper,
|
|
34
|
+
ListItem,
|
|
35
|
+
ListWrapper,
|
|
36
|
+
StyledScrollbar
|
|
37
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ListItemProps } from '@synerise/ds-list-item';
|
|
3
|
+
import { ScrollbarAdditionalProps } from '@synerise/ds-scrollbar';
|
|
4
|
+
import { SearchBarProps } from '@synerise/ds-search-bar/dist/SearchBar.types';
|
|
5
5
|
export type ItemPickerDropdownProps = {
|
|
6
6
|
onChange: (item: ListItemProps) => void;
|
|
7
7
|
placeholder: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,166 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { useIntl } from
|
|
4
|
-
import Dropdown from
|
|
5
|
-
import FormField from
|
|
6
|
-
import
|
|
7
|
-
import ItemPickerDropdown from
|
|
8
|
-
import Trigger from
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
defaultMessage: 'Yes'
|
|
76
|
-
}),
|
|
77
|
-
searchPlaceholder: searchPlaceholder || intl.formatMessage({
|
|
78
|
-
id: 'DS.ITEM-PICKER.SEARCH',
|
|
79
|
-
defaultMessage: 'Search'
|
|
80
|
-
})
|
|
81
|
-
};
|
|
82
|
-
}, [changeButtonLabel, clear, clearConfirmTitle, intl, noResults, noText, searchPlaceholder, yesText]);
|
|
83
|
-
var onVisibilityChange = function onVisibilityChange(state) {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useMemo, useCallback } from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import Dropdown from "@synerise/ds-dropdown";
|
|
5
|
+
import FormField from "@synerise/ds-form-field";
|
|
6
|
+
import { ItemPickerWrapper } from "../../ItemPicker.styles.js";
|
|
7
|
+
import ItemPickerDropdown from "../ItemPickerDropdown/ItemPickerDropdown.js";
|
|
8
|
+
import Trigger from "../ItemPickerTrigger/Trigger.js";
|
|
9
|
+
const ItemPickerLegacy = ({
|
|
10
|
+
dataSource,
|
|
11
|
+
onChange,
|
|
12
|
+
onClear,
|
|
13
|
+
placeholder,
|
|
14
|
+
changeButtonLabel,
|
|
15
|
+
clear,
|
|
16
|
+
clearConfirmTitle,
|
|
17
|
+
closeOnBottomAction,
|
|
18
|
+
description,
|
|
19
|
+
disabled,
|
|
20
|
+
dropdownBottomAction,
|
|
21
|
+
dropdownProps = {},
|
|
22
|
+
dropdownRowHeight,
|
|
23
|
+
dropdownVisibleRows,
|
|
24
|
+
error,
|
|
25
|
+
errorMessage,
|
|
26
|
+
label,
|
|
27
|
+
onBlur,
|
|
28
|
+
onFocus,
|
|
29
|
+
noResults,
|
|
30
|
+
noText,
|
|
31
|
+
placeholderIcon,
|
|
32
|
+
searchPlaceholder,
|
|
33
|
+
searchBarProps,
|
|
34
|
+
selectedItem,
|
|
35
|
+
tooltip,
|
|
36
|
+
tooltipConfig,
|
|
37
|
+
size = "small",
|
|
38
|
+
yesText,
|
|
39
|
+
withClearConfirmation,
|
|
40
|
+
scrollbarProps,
|
|
41
|
+
informationCardTooltipProps,
|
|
42
|
+
hideSearchBar
|
|
43
|
+
}) => {
|
|
44
|
+
const [dropdownOpened, setDropdownOpened] = useState(false);
|
|
45
|
+
const clearSearchBarValue = useRef();
|
|
46
|
+
const intl = useIntl();
|
|
47
|
+
const texts = useMemo(() => ({
|
|
48
|
+
changeButtonLabel: changeButtonLabel || intl.formatMessage({
|
|
49
|
+
id: "DS.ITEM-PICKER.CHANGE-BUTTON"
|
|
50
|
+
}),
|
|
51
|
+
clear: clear || intl.formatMessage({
|
|
52
|
+
id: "DS.ITEM-PICKER.CLEAR"
|
|
53
|
+
}),
|
|
54
|
+
clearConfirmTitle: clearConfirmTitle || intl.formatMessage({
|
|
55
|
+
id: "DS.ITEM-PICKER.CLEAR-CONFIRM"
|
|
56
|
+
}),
|
|
57
|
+
noResults: noResults || intl.formatMessage({
|
|
58
|
+
id: "DS.ITEM-PICKER.NO-RESULTS",
|
|
59
|
+
defaultMessage: "No results"
|
|
60
|
+
}),
|
|
61
|
+
noText: noText || intl.formatMessage({
|
|
62
|
+
id: "DS.ITEM-PICKER.NO-TEXT",
|
|
63
|
+
defaultMessage: "No"
|
|
64
|
+
}),
|
|
65
|
+
yesText: yesText || intl.formatMessage({
|
|
66
|
+
id: "DS.ITEM-PICKER.YES-TEXT",
|
|
67
|
+
defaultMessage: "Yes"
|
|
68
|
+
}),
|
|
69
|
+
searchPlaceholder: searchPlaceholder || intl.formatMessage({
|
|
70
|
+
id: "DS.ITEM-PICKER.SEARCH",
|
|
71
|
+
defaultMessage: "Search"
|
|
72
|
+
})
|
|
73
|
+
}), [changeButtonLabel, clear, clearConfirmTitle, intl, noResults, noText, searchPlaceholder, yesText]);
|
|
74
|
+
const onVisibilityChange = (state) => {
|
|
84
75
|
setDropdownOpened(state);
|
|
85
|
-
if (state && typeof onFocus ===
|
|
76
|
+
if (state && typeof onFocus === "function") {
|
|
86
77
|
onFocus();
|
|
87
78
|
}
|
|
88
79
|
if (!state) {
|
|
89
80
|
clearSearchBarValue.current = clearSearchBarValue.current ? clearSearchBarValue.current += 1 : 1;
|
|
90
|
-
if (typeof onBlur ===
|
|
81
|
+
if (typeof onBlur === "function") {
|
|
91
82
|
onBlur();
|
|
92
83
|
}
|
|
93
84
|
}
|
|
94
85
|
};
|
|
95
|
-
|
|
86
|
+
const openDropdown = useCallback(() => {
|
|
96
87
|
setDropdownOpened(true);
|
|
97
|
-
typeof onFocus ===
|
|
88
|
+
typeof onFocus === "function" && onFocus();
|
|
98
89
|
}, [setDropdownOpened, onFocus]);
|
|
99
|
-
|
|
90
|
+
const closeDropdown = useCallback(() => {
|
|
100
91
|
setDropdownOpened(false);
|
|
101
|
-
typeof onBlur ===
|
|
92
|
+
typeof onBlur === "function" && onBlur();
|
|
102
93
|
}, [setDropdownOpened, onBlur]);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
dropdownVisibleRows: dropdownVisibleRows,
|
|
113
|
-
dropdownRowHeight: dropdownRowHeight,
|
|
114
|
-
dropdownBottomAction: dropdownBottomAction,
|
|
115
|
-
closeOnBottomAction: closeOnBottomAction,
|
|
116
|
-
isDropdownOpened: dropdownOpened,
|
|
117
|
-
scrollbarProps: scrollbarProps,
|
|
118
|
-
hideSearchBar: hideSearchBar
|
|
119
|
-
});
|
|
120
|
-
}, [searchBarProps, onChange, dataSource, texts, closeDropdown, dropdownVisibleRows, dropdownRowHeight, dropdownBottomAction, closeOnBottomAction, dropdownOpened, hideSearchBar, scrollbarProps]);
|
|
121
|
-
var renderTrigger = useMemo(function () {
|
|
122
|
-
return /*#__PURE__*/React.createElement(Trigger, {
|
|
123
|
-
clear: texts.clear,
|
|
124
|
-
selected: selectedItem,
|
|
125
|
-
onClear: onClear,
|
|
126
|
-
opened: dropdownOpened,
|
|
127
|
-
placeholder: placeholder,
|
|
128
|
-
placeholderIcon: placeholderIcon,
|
|
129
|
-
error: error,
|
|
130
|
-
disabled: disabled,
|
|
131
|
-
openDropdown: openDropdown,
|
|
132
|
-
closeDropdown: closeDropdown,
|
|
133
|
-
size: size,
|
|
134
|
-
changeButtonLabel: texts.changeButtonLabel,
|
|
135
|
-
withChangeButton: !withClearConfirmation,
|
|
136
|
-
clearConfirmTitle: texts.clearConfirmTitle,
|
|
137
|
-
yesText: texts.yesText,
|
|
138
|
-
noText: texts.noText,
|
|
139
|
-
withClearConfirmation: Boolean(withClearConfirmation),
|
|
140
|
-
informationCardTooltipProps: informationCardTooltipProps
|
|
141
|
-
});
|
|
142
|
-
}, [closeDropdown, disabled, dropdownOpened, error, informationCardTooltipProps, onClear, openDropdown, placeholder, placeholderIcon, selectedItem, size, texts.changeButtonLabel, texts.clear, texts.clearConfirmTitle, texts.noText, texts.yesText, withClearConfirmation]);
|
|
143
|
-
return /*#__PURE__*/React.createElement(S.ItemPickerWrapper, {
|
|
144
|
-
className: "ds-items-picker",
|
|
145
|
-
disabled: disabled
|
|
146
|
-
}, /*#__PURE__*/React.createElement(FormField, {
|
|
147
|
-
label: label,
|
|
148
|
-
tooltip: tooltip,
|
|
149
|
-
tooltipConfig: tooltipConfig,
|
|
150
|
-
errorText: errorMessage,
|
|
151
|
-
description: description
|
|
152
|
-
}, /*#__PURE__*/React.createElement(Dropdown, _extends({
|
|
153
|
-
open: dropdownOpened,
|
|
154
|
-
disabled: disabled,
|
|
155
|
-
trigger: ['click'],
|
|
156
|
-
overlay: dropdownOverlay,
|
|
157
|
-
onOpenChange: onVisibilityChange,
|
|
158
|
-
asChild: true,
|
|
159
|
-
size: "match-trigger"
|
|
160
|
-
}, dropdownProps, {
|
|
161
|
-
popoverProps: _extends({
|
|
162
|
-
testId: 'item-picker-legacy'
|
|
163
|
-
}, dropdownProps == null ? void 0 : dropdownProps.popoverProps)
|
|
164
|
-
}), renderTrigger)));
|
|
94
|
+
const dropdownOverlay = useMemo(() => /* @__PURE__ */ jsx(ItemPickerDropdown, { searchBarProps, clearSearchQuery: clearSearchBarValue.current, onChange, dataSource, placeholder: texts.searchPlaceholder, closeDropdown, noResults: texts.noResults, dropdownVisibleRows, dropdownRowHeight, dropdownBottomAction, closeOnBottomAction, isDropdownOpened: dropdownOpened, scrollbarProps, hideSearchBar }), [searchBarProps, onChange, dataSource, texts, closeDropdown, dropdownVisibleRows, dropdownRowHeight, dropdownBottomAction, closeOnBottomAction, dropdownOpened, hideSearchBar, scrollbarProps]);
|
|
95
|
+
const renderTrigger = useMemo(() => /* @__PURE__ */ jsx(Trigger, { clear: texts.clear, selected: selectedItem, onClear, opened: dropdownOpened, placeholder, placeholderIcon, error, disabled, openDropdown, closeDropdown, size, changeButtonLabel: texts.changeButtonLabel, withChangeButton: !withClearConfirmation, clearConfirmTitle: texts.clearConfirmTitle, yesText: texts.yesText, noText: texts.noText, withClearConfirmation: Boolean(withClearConfirmation), informationCardTooltipProps }), [closeDropdown, disabled, dropdownOpened, error, informationCardTooltipProps, onClear, openDropdown, placeholder, placeholderIcon, selectedItem, size, texts.changeButtonLabel, texts.clear, texts.clearConfirmTitle, texts.noText, texts.yesText, withClearConfirmation]);
|
|
96
|
+
return /* @__PURE__ */ jsx(ItemPickerWrapper, { className: "ds-items-picker", disabled, children: /* @__PURE__ */ jsx(FormField, { label, tooltip, tooltipConfig, errorText: errorMessage, description, children: /* @__PURE__ */ jsx(Dropdown, { open: dropdownOpened, disabled, trigger: ["click"], overlay: dropdownOverlay, onOpenChange: onVisibilityChange, asChild: true, size: "match-trigger", ...dropdownProps, popoverProps: {
|
|
97
|
+
testId: "item-picker-legacy",
|
|
98
|
+
...dropdownProps?.popoverProps
|
|
99
|
+
}, children: renderTrigger }) }) });
|
|
100
|
+
};
|
|
101
|
+
export {
|
|
102
|
+
ItemPickerLegacy as default
|
|
165
103
|
};
|
|
166
|
-
export default ItemPickerLegacy;
|