@synerise/ds-dropdown 1.3.0 → 1.3.2
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 +8 -0
- package/README.md +17 -10
- package/dist/Dropdown.const.d.ts +4 -4
- package/dist/Dropdown.const.js +31 -21
- package/dist/Dropdown.d.ts +3 -3
- package/dist/Dropdown.js +64 -81
- package/dist/Dropdown.styles.d.ts +1 -1
- package/dist/Dropdown.styles.js +7 -6
- package/dist/Dropdown.types.d.ts +4 -4
- package/dist/Dropdown.types.js +1 -1
- package/dist/components/BackAction/BackAction.d.ts +2 -2
- package/dist/components/BackAction/BackAction.js +20 -25
- package/dist/components/BackAction/BackAction.styles.d.ts +4 -4
- package/dist/components/BackAction/BackAction.styles.js +15 -17
- package/dist/components/BackAction/BackAction.types.d.ts +2 -2
- package/dist/components/BackAction/BackAction.types.js +1 -1
- package/dist/components/BottomAction/BottomAction.d.ts +2 -2
- package/dist/components/BottomAction/BottomAction.js +15 -17
- package/dist/components/BottomAction/BottomAction.styles.d.ts +3 -3
- package/dist/components/BottomAction/BottomAction.styles.js +11 -18
- package/dist/components/BottomAction/BottomAction.types.d.ts +2 -2
- package/dist/components/BottomAction/BottomAction.types.js +1 -1
- package/dist/components/DropdownFooter/DropdownFooter.d.ts +2 -2
- package/dist/components/DropdownFooter/DropdownFooter.js +15 -10
- package/dist/components/DropdownFooter/DropdownFooter.styles.d.ts +3 -3
- package/dist/components/DropdownFooter/DropdownFooter.styles.js +11 -10
- package/dist/components/DropdownFooter/DropdownFooter.types.d.ts +1 -1
- package/dist/components/DropdownFooter/DropdownFooter.types.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +3 -3
- package/dist/components/DropdownMenu/DropdownMenu.js +71 -118
- package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +3 -3
- package/dist/components/DropdownMenu/DropdownMenu.types.js +1 -1
- package/dist/components/DropdownMenuList/DropdownMenuList.d.ts +3 -3
- package/dist/components/DropdownMenuList/DropdownMenuList.js +62 -76
- package/dist/components/DropdownMenuList/DropdownMenuList.styles.d.ts +5 -5
- package/dist/components/DropdownMenuList/DropdownMenuList.styles.js +16 -9
- package/dist/components/DropdownMenuList/DropdownMenuList.types.d.ts +2 -2
- package/dist/components/DropdownMenuList/DropdownMenuList.types.js +1 -1
- package/dist/components/DropdownOverlay/DropdownOverlay.d.ts +2 -2
- package/dist/components/DropdownOverlay/DropdownOverlay.js +45 -53
- package/dist/components/DropdownOverlay/DropdownOverlay.styles.d.ts +1 -1
- package/dist/components/DropdownOverlay/DropdownOverlay.styles.js +7 -10
- package/dist/components/DropdownOverlay/DropdownOverlay.types.d.ts +2 -2
- package/dist/components/DropdownOverlay/DropdownOverlay.types.js +1 -1
- package/dist/components/DropdownPopover/DropdownPopover.d.ts +2 -2
- package/dist/components/DropdownPopover/DropdownPopover.js +44 -74
- package/dist/components/DropdownPopover/DropdownPopover.types.d.ts +1 -1
- package/dist/components/DropdownPopover/DropdownPopover.types.js +1 -1
- package/dist/components/TextTrigger/TextTrigger.d.ts +2 -2
- package/dist/components/TextTrigger/TextTrigger.js +24 -31
- package/dist/components/TextTrigger/TextTrigger.styles.d.ts +3 -3
- package/dist/components/TextTrigger/TextTrigger.styles.js +9 -23
- package/dist/components/TextTrigger/TextTrigger.types.d.ts +1 -1
- package/dist/components/TextTrigger/TextTrigger.types.js +1 -1
- package/dist/hooks/useDefaultTexts.d.ts +1 -1
- package/dist/hooks/useDefaultTexts.js +18 -20
- package/dist/hooks/useDropdownVisibility.js +19 -21
- package/dist/index.js +15 -6
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils/getDropdownWidth.d.ts +1 -1
- package/dist/utils/getDropdownWidth.js +12 -9
- package/dist/utils/getTransitionConfig.d.ts +1 -1
- package/dist/utils/getTransitionConfig.js +11 -7
- package/dist/utils/index.js +8 -3
- package/dist/utils/isSplitFooter.d.ts +1 -1
- package/dist/utils/isSplitFooter.js +6 -3
- package/package.json +16 -16
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const DropdownFooterWrapper: import(
|
|
1
|
+
export declare const DropdownFooterWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
2
2
|
split?: boolean;
|
|
3
3
|
}, never>;
|
|
4
|
-
export declare const DropdownFooterLeft: import(
|
|
5
|
-
export declare const DropdownFooterRight: import(
|
|
4
|
+
export declare const DropdownFooterLeft: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const DropdownFooterRight: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const DropdownFooterWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "DropdownFooterstyles__DropdownFooterWrapper",
|
|
4
4
|
componentId: "sc-q7mkt3-0"
|
|
5
|
-
})(["background:", ";height:48px;padding:8px;display:flex;align-items:center;justify-content:", ";"],
|
|
6
|
-
|
|
7
|
-
}, function (props) {
|
|
8
|
-
return props.split ? 'space-between' : 'flex-end';
|
|
9
|
-
});
|
|
10
|
-
export var DropdownFooterLeft = styled.div.withConfig({
|
|
5
|
+
})(["background:", ";height:48px;padding:8px;display:flex;align-items:center;justify-content:", ";"], (props) => props.theme.palette["grey-100"], (props) => props.split ? "space-between" : "flex-end");
|
|
6
|
+
const DropdownFooterLeft = /* @__PURE__ */ styled.div.withConfig({
|
|
11
7
|
displayName: "DropdownFooterstyles__DropdownFooterLeft",
|
|
12
8
|
componentId: "sc-q7mkt3-1"
|
|
13
9
|
})([""]);
|
|
14
|
-
|
|
10
|
+
const DropdownFooterRight = /* @__PURE__ */ styled.div.withConfig({
|
|
15
11
|
displayName: "DropdownFooterstyles__DropdownFooterRight",
|
|
16
12
|
componentId: "sc-q7mkt3-2"
|
|
17
|
-
})([""]);
|
|
13
|
+
})([""]);
|
|
14
|
+
export {
|
|
15
|
+
DropdownFooterLeft,
|
|
16
|
+
DropdownFooterRight,
|
|
17
|
+
DropdownFooterWrapper
|
|
18
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ListItemProps } from '@synerise/ds-list-item';
|
|
3
|
+
import { DropdownMenuProps } from './DropdownMenu.types';
|
|
4
4
|
export declare const DropdownMenu: <ItemType extends ListItemProps>({ dataSource, withSearch, texts, children, trigger, placement, maxVisibleItems, size, open, onOpenChange, onDismiss, onSearchQueryChange, getPopupContainer, virtualised, disabled, asChild, hideOnItemClick, itemMatchesSearchQuery, footer, overlayStyle, overlayClassName, overlayHTMLAttributes, popoverProps, popoverTriggerProps, }: DropdownMenuProps<ItemType>) => React.JSX.Element;
|
|
@@ -1,132 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { useTheme } from
|
|
4
|
-
import Icon, { SearchM } from
|
|
5
|
-
import SearchBar from
|
|
6
|
-
import { DEFAULT_MATCHING_FUNCTION, MAX_VISIBLE_ITEMS } from
|
|
7
|
-
import { useDefaultTexts } from
|
|
8
|
-
import { DropdownFooter } from
|
|
9
|
-
import { DropdownMenuList } from
|
|
10
|
-
import { DropdownPopover } from
|
|
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
|
-
setActiveIndex = _useState[1];
|
|
45
|
-
var _useState2 = useState(''),
|
|
46
|
-
searchQuery = _useState2[0],
|
|
47
|
-
setSearchQuery = _useState2[1];
|
|
48
|
-
var _useState3 = useState(open),
|
|
49
|
-
isOpen = _useState3[0],
|
|
50
|
-
setIsOpen = _useState3[1];
|
|
51
|
-
var allTexts = useDefaultTexts(texts);
|
|
52
|
-
var theme = useTheme();
|
|
53
|
-
var toggleOpen = useCallback(function (openState) {
|
|
54
|
-
onOpenChange == null || onOpenChange(openState);
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback, useEffect, useMemo } from "react";
|
|
3
|
+
import { useTheme } from "@synerise/ds-core";
|
|
4
|
+
import Icon, { SearchM } from "@synerise/ds-icon";
|
|
5
|
+
import SearchBar from "@synerise/ds-search-bar";
|
|
6
|
+
import { DEFAULT_MATCHING_FUNCTION, MAX_VISIBLE_ITEMS } from "../../Dropdown.const.js";
|
|
7
|
+
import { useDefaultTexts } from "../../hooks/useDefaultTexts.js";
|
|
8
|
+
import { DropdownFooter } from "../DropdownFooter/DropdownFooter.js";
|
|
9
|
+
import { DropdownMenuList } from "../DropdownMenuList/DropdownMenuList.js";
|
|
10
|
+
import { DropdownPopover } from "../DropdownPopover/DropdownPopover.js";
|
|
11
|
+
const DropdownMenu = ({
|
|
12
|
+
dataSource,
|
|
13
|
+
withSearch,
|
|
14
|
+
texts,
|
|
15
|
+
children,
|
|
16
|
+
trigger = "click",
|
|
17
|
+
placement = "bottomLeft",
|
|
18
|
+
maxVisibleItems = MAX_VISIBLE_ITEMS,
|
|
19
|
+
size = "auto",
|
|
20
|
+
open,
|
|
21
|
+
onOpenChange,
|
|
22
|
+
onDismiss,
|
|
23
|
+
onSearchQueryChange,
|
|
24
|
+
getPopupContainer,
|
|
25
|
+
virtualised,
|
|
26
|
+
disabled,
|
|
27
|
+
asChild,
|
|
28
|
+
hideOnItemClick = true,
|
|
29
|
+
itemMatchesSearchQuery = DEFAULT_MATCHING_FUNCTION,
|
|
30
|
+
footer,
|
|
31
|
+
overlayStyle,
|
|
32
|
+
overlayClassName,
|
|
33
|
+
overlayHTMLAttributes,
|
|
34
|
+
popoverProps,
|
|
35
|
+
popoverTriggerProps
|
|
36
|
+
}) => {
|
|
37
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
38
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
39
|
+
const [isOpen, setIsOpen] = useState(open);
|
|
40
|
+
const allTexts = useDefaultTexts(texts);
|
|
41
|
+
const theme = useTheme();
|
|
42
|
+
const toggleOpen = useCallback((openState) => {
|
|
43
|
+
onOpenChange?.(openState);
|
|
55
44
|
setIsOpen(openState);
|
|
56
45
|
}, [onOpenChange]);
|
|
57
|
-
useEffect(
|
|
58
|
-
if (open !==
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (open !== void 0) {
|
|
59
48
|
setIsOpen(open);
|
|
60
49
|
}
|
|
61
50
|
}, [open, toggleOpen]);
|
|
62
|
-
|
|
63
|
-
onSearchQueryChange
|
|
51
|
+
const handleSearchChange = useCallback((query) => {
|
|
52
|
+
onSearchQueryChange?.(query);
|
|
64
53
|
setSearchQuery(query);
|
|
65
54
|
}, [onSearchQueryChange]);
|
|
66
|
-
|
|
67
|
-
return searchQuery ? dataSource.filter(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var props = _extends({}, item, {
|
|
55
|
+
const filteredItems = useMemo(() => {
|
|
56
|
+
return searchQuery ? dataSource.filter((item) => itemMatchesSearchQuery(item, searchQuery)).map((item) => {
|
|
57
|
+
const props = {
|
|
58
|
+
...item,
|
|
71
59
|
highlight: searchQuery
|
|
72
|
-
}
|
|
60
|
+
};
|
|
73
61
|
return props;
|
|
74
62
|
}) : dataSource;
|
|
75
63
|
}, [dataSource, itemMatchesSearchQuery, searchQuery]);
|
|
76
|
-
|
|
77
|
-
setTimeout(
|
|
78
|
-
|
|
79
|
-
activeIndex != null ? activeIndex : ref == null || (_ref$current = ref.current) == null ? void 0 : _ref$current.focus();
|
|
64
|
+
const handleSearchFocus = useCallback((ref) => {
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
activeIndex ?? ref?.current?.focus();
|
|
80
67
|
}, 10);
|
|
81
68
|
}, [activeIndex]);
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
-
placeholder: allTexts.searchPlaceholder,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
iconLeft: /*#__PURE__*/React.createElement(Icon, {
|
|
89
|
-
component: /*#__PURE__*/React.createElement(SearchM, null),
|
|
90
|
-
color: theme.palette['grey-600']
|
|
91
|
-
}),
|
|
92
|
-
onClearInput: function onClearInput() {
|
|
93
|
-
return setSearchQuery('');
|
|
94
|
-
},
|
|
95
|
-
clearTooltip: allTexts.searchClearTooltip
|
|
96
|
-
}), /*#__PURE__*/React.createElement(DropdownMenuList, {
|
|
97
|
-
maxVisibleItems: maxVisibleItems,
|
|
98
|
-
hideOnItemClick: hideOnItemClick,
|
|
99
|
-
dataSource: filteredItems,
|
|
100
|
-
closeOverlay: function closeOverlay() {
|
|
101
|
-
return toggleOpen(false);
|
|
102
|
-
},
|
|
103
|
-
texts: allTexts,
|
|
104
|
-
virtualised: virtualised
|
|
105
|
-
}), footer && /*#__PURE__*/React.createElement(DropdownFooter, {
|
|
106
|
-
footer: footer
|
|
107
|
-
}));
|
|
69
|
+
const overlay = useMemo(() => {
|
|
70
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
71
|
+
withSearch && /* @__PURE__ */ jsx(SearchBar, { placeholder: allTexts.searchPlaceholder, value: searchQuery, handleInputRef: handleSearchFocus, onSearchChange: handleSearchChange, iconLeft: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(SearchM, {}), color: theme.palette["grey-600"] }), onClearInput: () => setSearchQuery(""), clearTooltip: allTexts.searchClearTooltip }),
|
|
72
|
+
/* @__PURE__ */ jsx(DropdownMenuList, { maxVisibleItems, hideOnItemClick, dataSource: filteredItems, closeOverlay: () => toggleOpen(false), texts: allTexts, virtualised }),
|
|
73
|
+
footer && /* @__PURE__ */ jsx(DropdownFooter, { footer })
|
|
74
|
+
] });
|
|
108
75
|
}, [withSearch, allTexts, searchQuery, handleSearchFocus, handleSearchChange, theme.palette, maxVisibleItems, hideOnItemClick, filteredItems, virtualised, footer, toggleOpen]);
|
|
109
|
-
return disabled || dataSource.length === 0 ?
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
onDismiss: onDismiss,
|
|
120
|
-
overlay: overlay,
|
|
121
|
-
handleOpenChange: toggleOpen,
|
|
122
|
-
handleTriggerClick: function handleTriggerClick() {
|
|
123
|
-
toggleOpen(!isOpen);
|
|
124
|
-
},
|
|
125
|
-
activeIndex: activeIndex,
|
|
126
|
-
setActiveIndex: setActiveIndex,
|
|
127
|
-
popoverProps: _extends({}, popoverProps, {
|
|
128
|
-
componentId: 'dropdown-menu'
|
|
129
|
-
}),
|
|
130
|
-
popoverTriggerProps: popoverTriggerProps
|
|
131
|
-
}, children);
|
|
132
|
-
};
|
|
76
|
+
return disabled || dataSource.length === 0 ? /* @__PURE__ */ jsx(Fragment, { children }) : /* @__PURE__ */ jsx(DropdownPopover, { getPopupContainer, overlayHTMLAttributes, overlayStyle, overlayClassName, trigger, open: isOpen, size, placement, asChild, onDismiss, overlay, handleOpenChange: toggleOpen, handleTriggerClick: () => {
|
|
77
|
+
toggleOpen(!isOpen);
|
|
78
|
+
}, activeIndex, setActiveIndex, popoverProps: {
|
|
79
|
+
...popoverProps,
|
|
80
|
+
componentId: "dropdown-menu"
|
|
81
|
+
}, popoverTriggerProps, children });
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
DropdownMenu
|
|
85
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ListItemProps } from '@synerise/ds-list-item';
|
|
3
|
+
import { DropdownSharedProps } from '../../Dropdown.types';
|
|
4
4
|
export type DropdownMenuTexts = {
|
|
5
5
|
searchPlaceholder: string;
|
|
6
6
|
noSearchResults: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ListItemProps } from '@synerise/ds-list-item';
|
|
3
|
+
import { DropdownMenuListProps } from './DropdownMenuList.types';
|
|
4
4
|
export declare const DropdownMenuList: <ItemType extends ListItemProps>({ dataSource, maxVisibleItems, hideOnItemClick, virtualised, closeOverlay, texts, }: DropdownMenuListProps<ItemType>) => React.JSX.Element;
|
|
@@ -1,84 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { VariableSizeList } from
|
|
4
|
-
import { SearchNoResultsL } from
|
|
5
|
-
import { LIST_ITEM_SIZE_MAPPING } from
|
|
6
|
-
import Scrollbar from
|
|
7
|
-
import { MAX_VISIBLE_ITEMS, SCROLLBAR_OFFSET } from
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return dataSource[index].type ===
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { VariableSizeList } from "react-window";
|
|
4
|
+
import { SearchNoResultsL } from "@synerise/ds-icon";
|
|
5
|
+
import { LIST_ITEM_SIZE_MAPPING } from "@synerise/ds-list-item";
|
|
6
|
+
import Scrollbar from "@synerise/ds-scrollbar";
|
|
7
|
+
import { MAX_VISIBLE_ITEMS, SCROLLBAR_OFFSET } from "../../Dropdown.const.js";
|
|
8
|
+
import { ScrollableMenuWrapper, DropdownMenuList as DropdownMenuList$1, DropdownMenuListItem, EmptyStates } from "./DropdownMenuList.styles.js";
|
|
9
|
+
const DropdownMenuList = ({
|
|
10
|
+
dataSource,
|
|
11
|
+
maxVisibleItems = MAX_VISIBLE_ITEMS,
|
|
12
|
+
hideOnItemClick,
|
|
13
|
+
virtualised,
|
|
14
|
+
closeOverlay,
|
|
15
|
+
texts
|
|
16
|
+
}) => {
|
|
17
|
+
const getItemSize = useCallback((index) => {
|
|
18
|
+
return dataSource[index].type === "divider" ? 17 : LIST_ITEM_SIZE_MAPPING[dataSource[index].size || "default"];
|
|
19
19
|
}, [dataSource]);
|
|
20
|
-
|
|
20
|
+
const handleItemClick = useCallback(() => {
|
|
21
21
|
if (hideOnItemClick) {
|
|
22
|
-
setTimeout(
|
|
22
|
+
setTimeout(() => {
|
|
23
23
|
closeOverlay();
|
|
24
24
|
}, 10);
|
|
25
25
|
}
|
|
26
26
|
}, [hideOnItemClick, closeOverlay]);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return {
|
|
42
|
-
listHeight: height,
|
|
43
|
-
listMaxHeight: maxHeight
|
|
44
|
-
};
|
|
45
|
-
}, [dataSource, getItemSize, maxVisibleItems]),
|
|
46
|
-
listHeight = _useMemo.listHeight,
|
|
47
|
-
listMaxHeight = _useMemo.listMaxHeight;
|
|
48
|
-
return /*#__PURE__*/React.createElement(S.ScrollableMenuWrapper, null, dataSource.length ? /*#__PURE__*/React.createElement(Scrollbar, {
|
|
49
|
-
absolute: true,
|
|
50
|
-
maxHeight: listMaxHeight + SCROLLBAR_OFFSET
|
|
51
|
-
}, /*#__PURE__*/React.createElement(S.DropdownMenuList, null, virtualised ? /*#__PURE__*/React.createElement(VariableSizeList, {
|
|
52
|
-
height: listHeight,
|
|
53
|
-
itemData: dataSource,
|
|
54
|
-
itemCount: dataSource.length,
|
|
55
|
-
itemSize: getItemSize,
|
|
56
|
-
width: "100%",
|
|
57
|
-
style: {
|
|
58
|
-
paddingRight: '8px'
|
|
59
|
-
}
|
|
60
|
-
}, function (listItemData) {
|
|
61
|
-
var data = listItemData.data,
|
|
62
|
-
index = listItemData.index;
|
|
63
|
-
var item = data[index];
|
|
64
|
-
return item.type === 'divider' ? /*#__PURE__*/React.createElement(S.DropdownMenuListItem, item) : /*#__PURE__*/React.createElement(S.DropdownMenuListItem, _extends({}, item, {
|
|
65
|
-
itemKey: item.key,
|
|
66
|
-
onClick: function onClick(itemData) {
|
|
67
|
-
item.onClick == null || item.onClick(itemData);
|
|
68
|
-
handleItemClick();
|
|
27
|
+
const {
|
|
28
|
+
listHeight,
|
|
29
|
+
listMaxHeight
|
|
30
|
+
} = useMemo(() => {
|
|
31
|
+
let height = 0;
|
|
32
|
+
let maxHeight = 0;
|
|
33
|
+
let visibleItems = 0;
|
|
34
|
+
dataSource.forEach((item, index) => {
|
|
35
|
+
const itemHeight = getItemSize(index);
|
|
36
|
+
height += itemHeight;
|
|
37
|
+
if (visibleItems < maxVisibleItems) {
|
|
38
|
+
maxHeight += itemHeight;
|
|
69
39
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return item.type === 'divider' ? /*#__PURE__*/React.createElement(S.DropdownMenuListItem, item) : /*#__PURE__*/React.createElement(S.DropdownMenuListItem, _extends({}, item, {
|
|
73
|
-
itemKey: item.key,
|
|
74
|
-
onClick: function onClick(itemData) {
|
|
75
|
-
item.onClick == null || item.onClick(itemData);
|
|
76
|
-
handleItemClick();
|
|
40
|
+
if (item.type !== "divider") {
|
|
41
|
+
visibleItems += 1;
|
|
77
42
|
}
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
84
|
-
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
listHeight: height,
|
|
46
|
+
listMaxHeight: maxHeight
|
|
47
|
+
};
|
|
48
|
+
}, [dataSource, getItemSize, maxVisibleItems]);
|
|
49
|
+
return /* @__PURE__ */ jsx(ScrollableMenuWrapper, { children: dataSource.length ? /* @__PURE__ */ jsx(Scrollbar, { absolute: true, maxHeight: listMaxHeight + SCROLLBAR_OFFSET, children: /* @__PURE__ */ jsx(DropdownMenuList$1, { children: virtualised ? /* @__PURE__ */ jsx(VariableSizeList, { height: listHeight, itemData: dataSource, itemCount: dataSource.length, itemSize: getItemSize, width: "100%", style: {
|
|
50
|
+
paddingRight: "8px"
|
|
51
|
+
}, children: (listItemData) => {
|
|
52
|
+
const {
|
|
53
|
+
data,
|
|
54
|
+
index
|
|
55
|
+
} = listItemData;
|
|
56
|
+
const item = data[index];
|
|
57
|
+
return item.type === "divider" ? /* @__PURE__ */ jsx(DropdownMenuListItem, { ...item }) : /* @__PURE__ */ jsx(DropdownMenuListItem, { ...item, itemKey: item.key, onClick: (itemData) => {
|
|
58
|
+
item.onClick?.(itemData);
|
|
59
|
+
handleItemClick();
|
|
60
|
+
} });
|
|
61
|
+
} }) : /* @__PURE__ */ jsx(Fragment, { children: dataSource.map((item) => {
|
|
62
|
+
return item.type === "divider" ? /* @__PURE__ */ jsx(DropdownMenuListItem, { ...item }) : /* @__PURE__ */ jsx(DropdownMenuListItem, { ...item, itemKey: item.key, onClick: (itemData) => {
|
|
63
|
+
item.onClick?.(itemData);
|
|
64
|
+
handleItemClick();
|
|
65
|
+
} });
|
|
66
|
+
}) }) }) }) : /* @__PURE__ */ jsx(EmptyStates, { iconPosition: "top", customIcon: /* @__PURE__ */ jsx(SearchNoResultsL, {}), label: texts.noSearchResults }) });
|
|
67
|
+
};
|
|
68
|
+
export {
|
|
69
|
+
DropdownMenuList
|
|
70
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const ScrollableMenuWrapper: import(
|
|
3
|
-
export declare const MenuWrapper: import(
|
|
4
|
-
export declare const EmptyStates: import(
|
|
1
|
+
import { StyledListItem } from '@synerise/ds-list-item';
|
|
2
|
+
export declare const ScrollableMenuWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const MenuWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export declare const EmptyStates: import('styled-components').StyledComponent<({ size, label, text, button, fontSize, customIcon, className, mode, iconPosition, textAlign, }: import('@synerise/ds-empty-states').EmptyStatesProps) => React.JSX.Element, any, {}, never>;
|
|
5
5
|
export declare const DropdownMenuListItem: StyledListItem;
|
|
6
|
-
export declare const DropdownMenuList: import(
|
|
6
|
+
export declare const DropdownMenuList: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
import EmptyStatesBase from
|
|
3
|
-
import ListItemBase from
|
|
4
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import EmptyStatesBase from "@synerise/ds-empty-states";
|
|
3
|
+
import ListItemBase from "@synerise/ds-list-item";
|
|
4
|
+
const ScrollableMenuWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
5
5
|
displayName: "DropdownMenuListstyles__ScrollableMenuWrapper",
|
|
6
6
|
componentId: "sc-1lf08nj-0"
|
|
7
7
|
})(["padding:8px 0 8px 8px;"]);
|
|
8
|
-
|
|
8
|
+
const MenuWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
9
9
|
displayName: "DropdownMenuListstyles__MenuWrapper",
|
|
10
10
|
componentId: "sc-1lf08nj-1"
|
|
11
11
|
})(["padding:8px;"]);
|
|
12
|
-
|
|
12
|
+
const EmptyStates = /* @__PURE__ */ styled(EmptyStatesBase).withConfig({
|
|
13
13
|
displayName: "DropdownMenuListstyles__EmptyStates",
|
|
14
14
|
componentId: "sc-1lf08nj-2"
|
|
15
15
|
})(["margin:48px 0;"]);
|
|
16
|
-
|
|
16
|
+
const DropdownMenuListItem = /* @__PURE__ */ styled(ListItemBase).withConfig({
|
|
17
17
|
displayName: "DropdownMenuListstyles__DropdownMenuListItem",
|
|
18
18
|
componentId: "sc-1lf08nj-3"
|
|
19
19
|
})(["min-width:0;"]);
|
|
20
|
-
|
|
20
|
+
const DropdownMenuList = /* @__PURE__ */ styled.div.withConfig({
|
|
21
21
|
displayName: "DropdownMenuListstyles__DropdownMenuList",
|
|
22
22
|
componentId: "sc-1lf08nj-4"
|
|
23
|
-
})(["padding-right:8px;"]);
|
|
23
|
+
})(["padding-right:8px;"]);
|
|
24
|
+
export {
|
|
25
|
+
DropdownMenuList,
|
|
26
|
+
DropdownMenuListItem,
|
|
27
|
+
EmptyStates,
|
|
28
|
+
MenuWrapper,
|
|
29
|
+
ScrollableMenuWrapper
|
|
30
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ListItemProps } from '@synerise/ds-list-item';
|
|
2
|
+
import { DropdownMenuProps, DropdownMenuTexts } from '../DropdownMenu/DropdownMenu.types';
|
|
3
3
|
export type DropdownMenuListItemProps = ListItemProps;
|
|
4
4
|
export type DropdownMenuListProps<ItemType extends DropdownMenuListItemProps> = Pick<DropdownMenuProps<ItemType>, 'dataSource' | 'hideOnItemClick' | 'virtualised' | 'maxVisibleItems'> & {
|
|
5
5
|
closeOverlay: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export declare const DropdownOverlay: React.ForwardRefExoticComponent<Pick<import(
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export declare const DropdownOverlay: React.ForwardRefExoticComponent<Pick<import('../..').DropdownProps, "size" | "overlayStyle" | "overlayClassName" | "hideOnItemClick"> & {
|
|
3
3
|
content: React.ReactNode;
|
|
4
4
|
triggerRef: React.RefObject<HTMLElement>;
|
|
5
5
|
htmlAttributes?: React.HTMLAttributes<HTMLDivElement>;
|