@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.
Files changed (68) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +17 -10
  3. package/dist/Dropdown.const.d.ts +4 -4
  4. package/dist/Dropdown.const.js +31 -21
  5. package/dist/Dropdown.d.ts +3 -3
  6. package/dist/Dropdown.js +64 -81
  7. package/dist/Dropdown.styles.d.ts +1 -1
  8. package/dist/Dropdown.styles.js +7 -6
  9. package/dist/Dropdown.types.d.ts +4 -4
  10. package/dist/Dropdown.types.js +1 -1
  11. package/dist/components/BackAction/BackAction.d.ts +2 -2
  12. package/dist/components/BackAction/BackAction.js +20 -25
  13. package/dist/components/BackAction/BackAction.styles.d.ts +4 -4
  14. package/dist/components/BackAction/BackAction.styles.js +15 -17
  15. package/dist/components/BackAction/BackAction.types.d.ts +2 -2
  16. package/dist/components/BackAction/BackAction.types.js +1 -1
  17. package/dist/components/BottomAction/BottomAction.d.ts +2 -2
  18. package/dist/components/BottomAction/BottomAction.js +15 -17
  19. package/dist/components/BottomAction/BottomAction.styles.d.ts +3 -3
  20. package/dist/components/BottomAction/BottomAction.styles.js +11 -18
  21. package/dist/components/BottomAction/BottomAction.types.d.ts +2 -2
  22. package/dist/components/BottomAction/BottomAction.types.js +1 -1
  23. package/dist/components/DropdownFooter/DropdownFooter.d.ts +2 -2
  24. package/dist/components/DropdownFooter/DropdownFooter.js +15 -10
  25. package/dist/components/DropdownFooter/DropdownFooter.styles.d.ts +3 -3
  26. package/dist/components/DropdownFooter/DropdownFooter.styles.js +11 -10
  27. package/dist/components/DropdownFooter/DropdownFooter.types.d.ts +1 -1
  28. package/dist/components/DropdownFooter/DropdownFooter.types.js +1 -1
  29. package/dist/components/DropdownMenu/DropdownMenu.d.ts +3 -3
  30. package/dist/components/DropdownMenu/DropdownMenu.js +71 -118
  31. package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +3 -3
  32. package/dist/components/DropdownMenu/DropdownMenu.types.js +1 -1
  33. package/dist/components/DropdownMenuList/DropdownMenuList.d.ts +3 -3
  34. package/dist/components/DropdownMenuList/DropdownMenuList.js +62 -76
  35. package/dist/components/DropdownMenuList/DropdownMenuList.styles.d.ts +5 -5
  36. package/dist/components/DropdownMenuList/DropdownMenuList.styles.js +16 -9
  37. package/dist/components/DropdownMenuList/DropdownMenuList.types.d.ts +2 -2
  38. package/dist/components/DropdownMenuList/DropdownMenuList.types.js +1 -1
  39. package/dist/components/DropdownOverlay/DropdownOverlay.d.ts +2 -2
  40. package/dist/components/DropdownOverlay/DropdownOverlay.js +45 -53
  41. package/dist/components/DropdownOverlay/DropdownOverlay.styles.d.ts +1 -1
  42. package/dist/components/DropdownOverlay/DropdownOverlay.styles.js +7 -10
  43. package/dist/components/DropdownOverlay/DropdownOverlay.types.d.ts +2 -2
  44. package/dist/components/DropdownOverlay/DropdownOverlay.types.js +1 -1
  45. package/dist/components/DropdownPopover/DropdownPopover.d.ts +2 -2
  46. package/dist/components/DropdownPopover/DropdownPopover.js +44 -74
  47. package/dist/components/DropdownPopover/DropdownPopover.types.d.ts +1 -1
  48. package/dist/components/DropdownPopover/DropdownPopover.types.js +1 -1
  49. package/dist/components/TextTrigger/TextTrigger.d.ts +2 -2
  50. package/dist/components/TextTrigger/TextTrigger.js +24 -31
  51. package/dist/components/TextTrigger/TextTrigger.styles.d.ts +3 -3
  52. package/dist/components/TextTrigger/TextTrigger.styles.js +9 -23
  53. package/dist/components/TextTrigger/TextTrigger.types.d.ts +1 -1
  54. package/dist/components/TextTrigger/TextTrigger.types.js +1 -1
  55. package/dist/hooks/useDefaultTexts.d.ts +1 -1
  56. package/dist/hooks/useDefaultTexts.js +18 -20
  57. package/dist/hooks/useDropdownVisibility.js +19 -21
  58. package/dist/index.js +15 -6
  59. package/dist/modules.d.js +1 -1
  60. package/dist/modules.d.ts +0 -0
  61. package/dist/utils/getDropdownWidth.d.ts +1 -1
  62. package/dist/utils/getDropdownWidth.js +12 -9
  63. package/dist/utils/getTransitionConfig.d.ts +1 -1
  64. package/dist/utils/getTransitionConfig.js +11 -7
  65. package/dist/utils/index.js +8 -3
  66. package/dist/utils/isSplitFooter.d.ts +1 -1
  67. package/dist/utils/isSplitFooter.js +6 -3
  68. package/package.json +16 -16
@@ -1,5 +1,5 @@
1
- export declare const DropdownFooterWrapper: import("styled-components").StyledComponent<"div", any, {
1
+ export declare const DropdownFooterWrapper: import('styled-components').StyledComponent<"div", any, {
2
2
  split?: boolean;
3
3
  }, never>;
4
- export declare const DropdownFooterLeft: import("styled-components").StyledComponent<"div", any, {}, never>;
5
- export declare const DropdownFooterRight: import("styled-components").StyledComponent<"div", any, {}, never>;
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 'styled-components';
2
- export var DropdownFooterWrapper = styled.div.withConfig({
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:", ";"], function (props) {
6
- return props.theme.palette['grey-100'];
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
- export var DropdownFooterRight = styled.div.withConfig({
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,4 +1,4 @@
1
- import { type ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  export type DropdownFooterSplit = {
3
3
  left?: ReactNode;
4
4
  right?: ReactNode;
@@ -1 +1 @@
1
- export {};
1
+
@@ -1,4 +1,4 @@
1
- import React from 'react';
2
- import { type ListItemProps } from '@synerise/ds-list-item';
3
- import { type DropdownMenuProps } from './DropdownMenu.types';
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
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useEffect, useMemo, useState } 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';
7
- import { useDefaultTexts } from '../../hooks/useDefaultTexts';
8
- import { DropdownFooter } from '../DropdownFooter/DropdownFooter';
9
- import { DropdownMenuList } from '../DropdownMenuList/DropdownMenuList';
10
- import { DropdownPopover } from '../DropdownPopover/DropdownPopover';
11
- export var DropdownMenu = function DropdownMenu(_ref) {
12
- var dataSource = _ref.dataSource,
13
- withSearch = _ref.withSearch,
14
- texts = _ref.texts,
15
- children = _ref.children,
16
- _ref$trigger = _ref.trigger,
17
- trigger = _ref$trigger === void 0 ? 'click' : _ref$trigger,
18
- _ref$placement = _ref.placement,
19
- placement = _ref$placement === void 0 ? 'bottomLeft' : _ref$placement,
20
- _ref$maxVisibleItems = _ref.maxVisibleItems,
21
- maxVisibleItems = _ref$maxVisibleItems === void 0 ? MAX_VISIBLE_ITEMS : _ref$maxVisibleItems,
22
- _ref$size = _ref.size,
23
- size = _ref$size === void 0 ? 'auto' : _ref$size,
24
- open = _ref.open,
25
- onOpenChange = _ref.onOpenChange,
26
- onDismiss = _ref.onDismiss,
27
- onSearchQueryChange = _ref.onSearchQueryChange,
28
- getPopupContainer = _ref.getPopupContainer,
29
- virtualised = _ref.virtualised,
30
- disabled = _ref.disabled,
31
- asChild = _ref.asChild,
32
- _ref$hideOnItemClick = _ref.hideOnItemClick,
33
- hideOnItemClick = _ref$hideOnItemClick === void 0 ? true : _ref$hideOnItemClick,
34
- _ref$itemMatchesSearc = _ref.itemMatchesSearchQuery,
35
- itemMatchesSearchQuery = _ref$itemMatchesSearc === void 0 ? DEFAULT_MATCHING_FUNCTION : _ref$itemMatchesSearc,
36
- footer = _ref.footer,
37
- overlayStyle = _ref.overlayStyle,
38
- overlayClassName = _ref.overlayClassName,
39
- overlayHTMLAttributes = _ref.overlayHTMLAttributes,
40
- popoverProps = _ref.popoverProps,
41
- popoverTriggerProps = _ref.popoverTriggerProps;
42
- var _useState = useState(null),
43
- activeIndex = _useState[0],
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(function () {
58
- if (open !== undefined) {
46
+ useEffect(() => {
47
+ if (open !== void 0) {
59
48
  setIsOpen(open);
60
49
  }
61
50
  }, [open, toggleOpen]);
62
- var handleSearchChange = useCallback(function (query) {
63
- onSearchQueryChange == null || onSearchQueryChange(query);
51
+ const handleSearchChange = useCallback((query) => {
52
+ onSearchQueryChange?.(query);
64
53
  setSearchQuery(query);
65
54
  }, [onSearchQueryChange]);
66
- var filteredItems = useMemo(function () {
67
- return searchQuery ? dataSource.filter(function (item) {
68
- return itemMatchesSearchQuery(item, searchQuery);
69
- }).map(function (item) {
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
- var handleSearchFocus = useCallback(function (ref) {
77
- setTimeout(function () {
78
- var _ref$current;
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
- var overlay = useMemo(function () {
83
- return /*#__PURE__*/React.createElement(React.Fragment, null, withSearch && /*#__PURE__*/React.createElement(SearchBar, {
84
- placeholder: allTexts.searchPlaceholder,
85
- value: searchQuery,
86
- handleInputRef: handleSearchFocus,
87
- onSearchChange: handleSearchChange,
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 ? /*#__PURE__*/React.createElement(React.Fragment, null, children) : /*#__PURE__*/React.createElement(DropdownPopover, {
110
- getPopupContainer: getPopupContainer,
111
- overlayHTMLAttributes: overlayHTMLAttributes,
112
- overlayStyle: overlayStyle,
113
- overlayClassName: overlayClassName,
114
- trigger: trigger,
115
- open: isOpen,
116
- size: size,
117
- placement: placement,
118
- asChild: asChild,
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 type { ReactNode } from 'react';
2
- import type { ListItemProps } from '@synerise/ds-list-item';
3
- import { type DropdownSharedProps } from '../../Dropdown.types';
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
- export {};
1
+
@@ -1,4 +1,4 @@
1
- import React from 'react';
2
- import { type ListItemProps } from '@synerise/ds-list-item';
3
- import { type DropdownMenuListProps } from './DropdownMenuList.types';
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
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, 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';
8
- import * as S from './DropdownMenuList.styles';
9
- export var DropdownMenuList = function DropdownMenuList(_ref) {
10
- var dataSource = _ref.dataSource,
11
- _ref$maxVisibleItems = _ref.maxVisibleItems,
12
- maxVisibleItems = _ref$maxVisibleItems === void 0 ? MAX_VISIBLE_ITEMS : _ref$maxVisibleItems,
13
- hideOnItemClick = _ref.hideOnItemClick,
14
- virtualised = _ref.virtualised,
15
- closeOverlay = _ref.closeOverlay,
16
- texts = _ref.texts;
17
- var getItemSize = useCallback(function (index) {
18
- return dataSource[index].type === 'divider' ? 17 : LIST_ITEM_SIZE_MAPPING[dataSource[index].size || 'default'];
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
- var handleItemClick = useCallback(function () {
20
+ const handleItemClick = useCallback(() => {
21
21
  if (hideOnItemClick) {
22
- setTimeout(function () {
22
+ setTimeout(() => {
23
23
  closeOverlay();
24
24
  }, 10);
25
25
  }
26
26
  }, [hideOnItemClick, closeOverlay]);
27
- var _useMemo = useMemo(function () {
28
- var height = 0;
29
- var maxHeight = 0;
30
- var visibleItems = 0;
31
- dataSource.forEach(function (item, index) {
32
- var itemHeight = getItemSize(index);
33
- height += itemHeight;
34
- if (visibleItems < maxVisibleItems) {
35
- maxHeight += itemHeight;
36
- }
37
- if (item.type !== 'divider') {
38
- visibleItems += 1;
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
- }) : /*#__PURE__*/React.createElement(React.Fragment, null, dataSource.map(function (item) {
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
- })))) : /*#__PURE__*/React.createElement(S.EmptyStates, {
80
- iconPosition: "top",
81
- customIcon: /*#__PURE__*/React.createElement(SearchNoResultsL, null),
82
- label: texts.noSearchResults
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 { type 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>;
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("styled-components").StyledComponent<"div", any, {}, never>;
6
+ export declare const DropdownMenuList: import('styled-components').StyledComponent<"div", any, {}, never>;
@@ -1,23 +1,30 @@
1
- import styled from 'styled-components';
2
- import EmptyStatesBase from '@synerise/ds-empty-states';
3
- import ListItemBase from '@synerise/ds-list-item';
4
- export var ScrollableMenuWrapper = styled.div.withConfig({
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
- export var MenuWrapper = styled.div.withConfig({
8
+ const MenuWrapper = /* @__PURE__ */ styled.div.withConfig({
9
9
  displayName: "DropdownMenuListstyles__MenuWrapper",
10
10
  componentId: "sc-1lf08nj-1"
11
11
  })(["padding:8px;"]);
12
- export var EmptyStates = styled(EmptyStatesBase).withConfig({
12
+ const EmptyStates = /* @__PURE__ */ styled(EmptyStatesBase).withConfig({
13
13
  displayName: "DropdownMenuListstyles__EmptyStates",
14
14
  componentId: "sc-1lf08nj-2"
15
15
  })(["margin:48px 0;"]);
16
- export var DropdownMenuListItem = styled(ListItemBase).withConfig({
16
+ const DropdownMenuListItem = /* @__PURE__ */ styled(ListItemBase).withConfig({
17
17
  displayName: "DropdownMenuListstyles__DropdownMenuListItem",
18
18
  componentId: "sc-1lf08nj-3"
19
19
  })(["min-width:0;"]);
20
- export var DropdownMenuList = styled.div.withConfig({
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 { type ListItemProps } from '@synerise/ds-list-item';
2
- import { type DropdownMenuProps, type DropdownMenuTexts } from '../DropdownMenu/DropdownMenu.types';
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
- export {};
1
+
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- export declare const DropdownOverlay: React.ForwardRefExoticComponent<Pick<import("../..").DropdownProps, "overlayStyle" | "overlayClassName" | "size" | "hideOnItemClick"> & {
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>;