@synerise/ds-items-roll 0.7.16 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
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
+ # [0.8.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-items-roll@0.7.16...@synerise/ds-items-roll@0.8.0) (2024-11-28)
7
+
8
+
9
+ ### Features
10
+
11
+ * **items-roll:** add renderCount prop ([ec61af1](https://github.com/Synerise/synerise-design/commit/ec61af19b812608c1f12a736eeceaf32c85722e7))
12
+ * **items-roll:** isDisabled prop added ([e7eec53](https://github.com/Synerise/synerise-design/commit/e7eec53b482981a424c5b5ab80899407e660999b))
13
+ * **items-roll:** replaced Menu.Item with ListItem ([2cfcbdc](https://github.com/Synerise/synerise-design/commit/2cfcbdc501c0ad21557372c0f9d9cb76b3d034cb))
14
+
15
+
16
+
17
+
18
+
6
19
  ## [0.7.16](https://github.com/Synerise/synerise-design/compare/@synerise/ds-items-roll@0.7.15...@synerise/ds-items-roll@0.7.16) (2024-11-22)
7
20
 
8
21
  **Note:** Version bump only for package @synerise/ds-items-roll
package/README.md CHANGED
@@ -34,7 +34,7 @@ import ItemsRoll from '@synerise/ds-items-roll';
34
34
  ## API
35
35
 
36
36
  | Property | Description | Type | Default |
37
- | ---------------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ------- |
37
+ |------------------------------|-------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|---------|
38
38
  | actions | ItemRollElement array with configuration for action dropdown menu | ItemRollElement[] | - |
39
39
  | changeSelectionIcon | The custom changeSelection icon | `(props: React.SVGProps<SVGSVGElement>) => JSX.Element` | EditM |
40
40
  | changeSelectionDropdownProps | Object with ds-dropdown props | DropdownProps | |
@@ -42,6 +42,7 @@ import ItemsRoll from '@synerise/ds-items-roll';
42
42
  | customSidebarActions | Allow put developer sidebar actions that are not defined | React.ReactNode | - |
43
43
  | groups | Array of strings where each one corresponds to a group prop in ItemRollElement | string[] | - |
44
44
  | hideSearch | Hide search component in itemsroll | booleam | - |
45
+ | isDisabled | prevents rendering 'remove' / 'clear all' buttons | booleam | - |
45
46
  | items | ItemRollElement array for list | ItemRollElement[] | - |
46
47
  | maxToShowItems | Amount of initial ItemsRollElement to render. Note that if number is greater than 20, list will becoma scrollable | number | 10 |
47
48
  | onClearAll | Callback function that is fired when click on clearAll button | () => void | - |
@@ -54,12 +55,14 @@ import ItemsRoll from '@synerise/ds-items-roll';
54
55
  | searchValue | Value of search input component | string | - |
55
56
  | showMoreStep | Amount of items to load on show more button click | number | 10 |
56
57
  | style | Object with CSS properties | React.CSSProperties | - |
58
+ | renderCount | Custom items count renderer | (count: number) => ReactNode | - |
57
59
  | texts | Object contains texts for buttons, title etc. | Texts | - |
58
60
  | useFooter | Whether the footer is visibile | boolean | - |
59
61
  | useVirtualizedList | Whether to use react-virtualized for list | boolean | `false` |
60
62
  | virtualizedRowHeight | Height of virtualizedlist row | number | 32px |
61
63
  | virtualizedRowWidth | Width of virtualized list | number | - |
62
64
 
65
+
63
66
  #### ItemRollElement
64
67
 
65
68
  | Property | Description | Type | Default |
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- import { ItemRollElement } from '../ItemsRoll.types';
2
+ import { MenuItemProps } from '@synerise/ds-menu';
3
+ import type { ItemRollElement } from '../ItemsRoll.types';
3
4
  export type ExtrasProps = {
4
- actions: ItemRollElement[];
5
+ actions: ItemRollElement<MenuItemProps>[];
5
6
  };
6
- declare const Extras: React.FC<ExtrasProps>;
7
+ declare const Extras: ({ actions }: ExtrasProps) => React.JSX.Element;
7
8
  export default Extras;
@@ -1,4 +1,3 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
1
  import React from 'react';
3
2
  import styled from 'styled-components';
4
3
  import Dropdown from '@synerise/ds-dropdown';
@@ -14,12 +13,10 @@ var Extras = function Extras(_ref) {
14
13
  return /*#__PURE__*/React.createElement(Dropdown, {
15
14
  trigger: ['click'],
16
15
  placement: "bottomRight",
17
- overlay: /*#__PURE__*/React.createElement(ItemMenu, {
16
+ overlay: /*#__PURE__*/React.createElement("div", {
18
17
  "data-testid": "items-roll-action-menu"
19
- }, actions.map(function (action) {
20
- return /*#__PURE__*/React.createElement(Menu.Item, _extends({}, action, {
21
- key: action.id
22
- }), action.text);
18
+ }, /*#__PURE__*/React.createElement(ItemMenu, {
19
+ dataSource: actions
23
20
  }))
24
21
  }, /*#__PURE__*/React.createElement(Button, {
25
22
  type: "ghost",
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { ItemsRollProps } from './ItemsRoll.types';
3
- export declare const ItemsRoll: ({ actions, changeSelectionIcon, changeSelectionDropdownProps, className, customSidebarActions, groups, hideSearch, items, maxToShowItems, onClearAll, onChangeSelection, onItemClick, onItemRemove, onSearchClear, onSearch, searchValue, searchPlaceholder, showMoreStep, style, texts, useFooter, useVirtualizedList, virtualizedRowWidth, virtualizedRowHeight, }: ItemsRollProps) => React.JSX.Element;
3
+ export declare const ItemsRoll: ({ actions, changeSelectionIcon, changeSelectionDropdownProps, className, customSidebarActions, groups, hideSearch, isDisabled, items, maxToShowItems, onClearAll, onChangeSelection, onItemClick, onItemRemove, onSearchClear, onSearch, renderCount, searchValue, searchPlaceholder, showMoreStep, style, texts, useFooter, useVirtualizedList, virtualizedRowWidth, virtualizedRowHeight, }: ItemsRollProps) => React.JSX.Element;
4
4
  export default ItemsRoll;
package/dist/ItemsRoll.js CHANGED
@@ -3,7 +3,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
3
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
5
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
- import React from 'react';
6
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
7
7
  import { useIntl } from 'react-intl';
8
8
  import { Footer, Header, List } from './ItemsRollComponents';
9
9
  import * as S from './ItemsRoll.styles';
@@ -15,6 +15,7 @@ export var ItemsRoll = function ItemsRoll(_ref) {
15
15
  customSidebarActions = _ref.customSidebarActions,
16
16
  groups = _ref.groups,
17
17
  hideSearch = _ref.hideSearch,
18
+ isDisabled = _ref.isDisabled,
18
19
  items = _ref.items,
19
20
  _ref$maxToShowItems = _ref.maxToShowItems,
20
21
  maxToShowItems = _ref$maxToShowItems === void 0 ? 10 : _ref$maxToShowItems,
@@ -24,6 +25,7 @@ export var ItemsRoll = function ItemsRoll(_ref) {
24
25
  onItemRemove = _ref.onItemRemove,
25
26
  onSearchClear = _ref.onSearchClear,
26
27
  onSearch = _ref.onSearch,
28
+ renderCount = _ref.renderCount,
27
29
  searchValue = _ref.searchValue,
28
30
  searchPlaceholder = _ref.searchPlaceholder,
29
31
  _ref$showMoreStep = _ref.showMoreStep,
@@ -74,25 +76,28 @@ export var ItemsRoll = function ItemsRoll(_ref) {
74
76
  })
75
77
  };
76
78
  var allTexts = texts ? _objectSpread({}, defaultTexts, {}, texts) : defaultTexts;
77
- var _React$useState = React.useState(maxToShowItems),
78
- visibleItemsAmount = _React$useState[0],
79
- setVisibleItemsAmount = _React$useState[1];
80
- React.useEffect(function () {
79
+ var _useState = useState(maxToShowItems),
80
+ visibleItemsAmount = _useState[0],
81
+ setVisibleItemsAmount = _useState[1];
82
+ useEffect(function () {
81
83
  setVisibleItemsAmount(maxToShowItems);
82
84
  }, [maxToShowItems]);
83
- var showAdditionalItems = React.useCallback(function () {
85
+ var showAdditionalItems = useCallback(function () {
84
86
  if (visibleItemsAmount + showMoreStep < items.length) {
85
87
  setVisibleItemsAmount(visibleItemsAmount + showMoreStep);
86
88
  } else {
87
89
  setVisibleItemsAmount(items.length);
88
90
  }
89
91
  }, [items.length, visibleItemsAmount, showMoreStep]);
90
- var visibleItems = React.useMemo(function () {
92
+ var visibleItems = useMemo(function () {
91
93
  return visibleItemsAmount === items.length ? items : items.slice(0, visibleItemsAmount);
92
94
  }, [items, visibleItemsAmount]);
93
- var showDefaultItemsAmount = React.useCallback(function () {
95
+ var showDefaultItemsAmount = useCallback(function () {
94
96
  setVisibleItemsAmount(maxToShowItems);
95
97
  }, [maxToShowItems]);
98
+ var itemsCount = useMemo(function () {
99
+ return renderCount ? renderCount(items.length) : /*#__PURE__*/React.createElement(React.Fragment, null, allTexts.itemsLabel, ": ", /*#__PURE__*/React.createElement(S.Bold, null, items.length));
100
+ }, [allTexts.itemsLabel, items.length, renderCount]);
96
101
  return /*#__PURE__*/React.createElement(S.Wrapper, {
97
102
  style: style || {},
98
103
  className: className || '',
@@ -104,7 +109,7 @@ export var ItemsRoll = function ItemsRoll(_ref) {
104
109
  changeSelectionDropdownProps: changeSelectionDropdownProps,
105
110
  customSidebarActions: customSidebarActions,
106
111
  hideSearch: hideSearch,
107
- itemsCount: items.length,
112
+ itemsCount: itemsCount,
108
113
  onChangeSelection: onChangeSelection,
109
114
  onSearch: onSearch,
110
115
  onSearchClear: onSearchClear,
@@ -116,7 +121,7 @@ export var ItemsRoll = function ItemsRoll(_ref) {
116
121
  groups: groups,
117
122
  items: items,
118
123
  onItemClick: onItemClick,
119
- onItemRemove: onItemRemove,
124
+ onItemRemove: !isDisabled ? onItemRemove : undefined,
120
125
  noResultsLabel: allTexts.noResultsLabel,
121
126
  removeTooltipLabel: allTexts.removeTooltipLabel,
122
127
  searchValue: searchValue,
@@ -129,7 +134,7 @@ export var ItemsRoll = function ItemsRoll(_ref) {
129
134
  allTexts: allTexts,
130
135
  itemsCount: items.length,
131
136
  maxToShowItems: maxToShowItems,
132
- onClearAll: onClearAll,
137
+ onClearAll: !isDisabled ? onClearAll : undefined,
133
138
  showAdditionalItems: showAdditionalItems,
134
139
  showDefaultItemsAmount: showDefaultItemsAmount,
135
140
  showMoreStep: showMoreStep,
@@ -1,8 +1,9 @@
1
- import { ReactNode, CSSProperties, SVGProps } from 'react';
2
- import { IntlShape } from 'react-intl';
3
- import { MenuItemProps } from '@synerise/ds-menu/dist/Elements/Item/MenuItem.types';
4
- import { DropdownProps } from '@synerise/ds-dropdown/dist/Dropdown';
5
- export type ItemRollElement = MenuItemProps & {
1
+ import type { ReactNode, CSSProperties, SVGProps } from 'react';
2
+ import type { IntlShape } from 'react-intl';
3
+ import type { MenuItemProps } from '@synerise/ds-menu';
4
+ import type { ListItemProps } from '@synerise/ds-list-item';
5
+ import type { DropdownProps } from '@synerise/ds-dropdown/dist/Dropdown';
6
+ export type ItemRollElement<BaseType extends ListItemProps | MenuItemProps = ListItemProps> = BaseType & {
6
7
  id: string;
7
8
  group?: string;
8
9
  };
@@ -10,12 +11,14 @@ export type Texts = 'changeSelectionLabel' | 'clearAllLabel' | 'itemsLabel' | 'm
10
11
  export type ItemsRollGroup = string;
11
12
  export type ItemsRollProps = {
12
13
  intl?: IntlShape;
14
+ isDisabled?: boolean;
13
15
  items: ItemRollElement[];
14
16
  onSearch?: (value: string) => void;
17
+ renderCount?: (count: number) => ReactNode;
15
18
  onSearchClear?: () => void;
16
19
  searchValue?: string;
17
20
  searchPlaceholder?: string;
18
- actions?: ItemRollElement[];
21
+ actions?: ItemRollElement<MenuItemProps>[];
19
22
  changeSelectionIcon?: (props: SVGProps<SVGSVGElement>) => JSX.Element;
20
23
  changeSelectionDropdownProps?: DropdownProps;
21
24
  customSidebarActions?: ReactNode;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { FooterProps } from './Footer.types';
3
- declare const Footer: React.FC<FooterProps>;
3
+ declare const Footer: ({ allTexts, itemsCount, maxToShowItems, onClearAll, showAdditionalItems, showDefaultItemsAmount, showMoreStep, visibleItemsCount, searchMode, }: FooterProps) => React.JSX.Element | null;
4
4
  export default Footer;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import Popconfirm from '@synerise/ds-popconfirm';
3
3
  import Icon, { ArrowDownCircleM, ArrowUpCircleM, CloseS, WarningFillM } from '@synerise/ds-icon';
4
4
  import * as S from '../ItemsRoll.styles';
@@ -44,13 +44,13 @@ var Footer = function Footer(_ref3) {
44
44
  showMoreStep = _ref3$showMoreStep === void 0 ? 10 : _ref3$showMoreStep,
45
45
  visibleItemsCount = _ref3.visibleItemsCount,
46
46
  searchMode = _ref3.searchMode;
47
- var getShowMoreNumber = React.useMemo(function () {
47
+ var getShowMoreNumber = useMemo(function () {
48
48
  return visibleItemsCount + showMoreStep < itemsCount ? showMoreStep : itemsCount - visibleItemsCount;
49
49
  }, [itemsCount, showMoreStep, visibleItemsCount]);
50
- var showDivider = React.useMemo(function () {
50
+ var showDivider = useMemo(function () {
51
51
  return !searchMode || searchMode && itemsCount > maxToShowItems;
52
52
  }, [searchMode, maxToShowItems, itemsCount]);
53
- var buttonsConfiguration = React.useMemo(function () {
53
+ var buttonsConfiguration = useMemo(function () {
54
54
  if (visibleItemsCount === itemsCount) return /*#__PURE__*/React.createElement(ShowLessButton, {
55
55
  showLessLabel: allTexts.showLessLabel,
56
56
  showDefaultItemsAmount: showDefaultItemsAmount
@@ -1,8 +1,8 @@
1
- /// <reference types="react" />
2
- import { Texts, ItemsRollProps } from '../ItemsRoll.types';
1
+ import type { ReactNode } from 'react';
2
+ import type { Texts, ItemsRollProps } from '../ItemsRoll.types';
3
3
  export type FooterProps = Pick<ItemsRollProps, 'onClearAll' | 'maxToShowItems' | 'showMoreStep'> & {
4
4
  allTexts: {
5
- [k in Texts]: string | React.ReactNode;
5
+ [k in Texts]: ReactNode;
6
6
  };
7
7
  itemsCount: number;
8
8
  showAdditionalItems: () => void;
@@ -12,11 +12,11 @@ export type FooterProps = Pick<ItemsRollProps, 'onClearAll' | 'maxToShowItems' |
12
12
  };
13
13
  export type ShowLessButtonProps = {
14
14
  showDefaultItemsAmount: () => void;
15
- showLessLabel: string | React.ReactNode;
15
+ showLessLabel: ReactNode;
16
16
  };
17
17
  export type ShowMoreButtonProps = {
18
18
  getShowMoreNumber: number;
19
- moreLabel: string | React.ReactNode;
19
+ moreLabel: ReactNode;
20
20
  showAdditionalItems: () => void;
21
- showLabel: string | React.ReactNode;
21
+ showLabel: ReactNode;
22
22
  };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { HeaderProps } from './Header.types';
3
- declare const Header: React.FC<HeaderProps>;
3
+ declare const Header: ({ actions, allTexts, changeSelectionIcon: ChangeSelectionIcon, changeSelectionDropdownProps, customSidebarActions, hideSearch, itemsCount, onChangeSelection, onSearch, searchValue, onSearchClear, searchPlaceholder, }: HeaderProps) => React.JSX.Element;
4
4
  export default Header;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { SearchInput } from '@synerise/ds-search/dist/Elements';
3
3
  import Icon, { EditM } from '@synerise/ds-icon';
4
4
  import Dropdown from '@synerise/ds-dropdown';
@@ -19,7 +19,7 @@ var Header = function Header(_ref) {
19
19
  searchValue = _ref.searchValue,
20
20
  onSearchClear = _ref.onSearchClear,
21
21
  searchPlaceholder = _ref.searchPlaceholder;
22
- var ChangeSelectionButton = React.useMemo(function () {
22
+ var ChangeSelectionButton = useMemo(function () {
23
23
  return /*#__PURE__*/React.createElement(S.ChangeSelection, {
24
24
  type: "ghost",
25
25
  mode: "icon-label",
@@ -29,7 +29,7 @@ var Header = function Header(_ref) {
29
29
  size: 24
30
30
  }), allTexts.changeSelectionLabel);
31
31
  }, [ChangeSelectionIcon, onChangeSelection, allTexts.changeSelectionLabel]);
32
- return /*#__PURE__*/React.createElement(S.ContainerSpaceBetween, null, /*#__PURE__*/React.createElement(S.HeaderLeft, null, allTexts.itemsLabel, ": ", /*#__PURE__*/React.createElement(S.Bold, null, itemsCount)), /*#__PURE__*/React.createElement(S.HeaderRight, null, onChangeSelection && (changeSelectionDropdownProps ? /*#__PURE__*/React.createElement(Dropdown, changeSelectionDropdownProps, ChangeSelectionButton) : ChangeSelectionButton), !hideSearch && /*#__PURE__*/React.createElement(S.SearchWrapper, null, /*#__PURE__*/React.createElement(SearchInput, {
32
+ return /*#__PURE__*/React.createElement(S.ContainerSpaceBetween, null, /*#__PURE__*/React.createElement(S.HeaderLeft, null, itemsCount), /*#__PURE__*/React.createElement(S.HeaderRight, null, onChangeSelection && (changeSelectionDropdownProps ? /*#__PURE__*/React.createElement(Dropdown, changeSelectionDropdownProps, ChangeSelectionButton) : ChangeSelectionButton), !hideSearch && /*#__PURE__*/React.createElement(S.SearchWrapper, null, /*#__PURE__*/React.createElement(SearchInput, {
33
33
  clearTooltip: allTexts.searchClearTooltipLabel,
34
34
  onClear: onSearchClear || NOOP,
35
35
  onChange: onSearch || NOOP,
@@ -1,8 +1,8 @@
1
- import React from 'react';
2
- import { ItemsRollProps, Texts } from '../ItemsRoll.types';
1
+ import type { ReactNode } from 'react';
2
+ import type { ItemsRollProps, Texts } from '../ItemsRoll.types';
3
3
  export type HeaderProps = Pick<ItemsRollProps, 'actions' | 'changeSelectionIcon' | 'changeSelectionDropdownProps' | 'onChangeSelection' | 'onSearch' | 'onSearchClear' | 'searchValue' | 'searchPlaceholder' | 'hideSearch' | 'customSidebarActions'> & {
4
4
  allTexts: {
5
- [k in Texts]: string | React.ReactNode;
5
+ [k in Texts]: ReactNode;
6
6
  };
7
- itemsCount: number;
7
+ itemsCount: ReactNode;
8
8
  };
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { RemoveIconProps } from './ItemRemoveIcon.types';
3
- export declare const RemoveIcon: React.FC<RemoveIconProps>;
3
+ export declare const RemoveIcon: ({ id, handleRemove, tooltipLabel, group }: RemoveIconProps) => React.JSX.Element;
@@ -3,7 +3,6 @@ import Icon, { CloseS } from '@synerise/ds-icon';
3
3
  import Tooltip from '@synerise/ds-tooltip';
4
4
  import { theme } from '@synerise/ds-core';
5
5
  import { RemoveIconWrapper } from './ItemRemoveIcon.styles';
6
- // eslint-disable-next-line import/prefer-default-export
7
6
  export var RemoveIcon = function RemoveIcon(_ref) {
8
7
  var id = _ref.id,
9
8
  handleRemove = _ref.handleRemove,
@@ -11,10 +10,12 @@ export var RemoveIcon = function RemoveIcon(_ref) {
11
10
  group = _ref.group;
12
11
  return /*#__PURE__*/React.createElement(Tooltip, {
13
12
  title: tooltipLabel
14
- }, /*#__PURE__*/React.createElement(RemoveIconWrapper, null, /*#__PURE__*/React.createElement(Icon, {
13
+ }, /*#__PURE__*/React.createElement(RemoveIconWrapper, {
14
+ "data-testid": "items-roll-remove-icon"
15
+ }, /*#__PURE__*/React.createElement(Icon, {
15
16
  className: "element-remove-icon",
16
- onClick: function onClick(e) {
17
- e.stopPropagation();
17
+ onClick: function onClick(event) {
18
+ event.stopPropagation();
18
19
  handleRemove(id, group);
19
20
  },
20
21
  component: /*#__PURE__*/React.createElement(CloseS, null),
@@ -1,6 +1,4 @@
1
1
  import styled from 'styled-components';
2
-
3
- // eslint-disable-next-line import/prefer-default-export
4
2
  export var RemoveIconWrapper = styled.div.withConfig({
5
3
  displayName: "ItemRemoveIconstyles__RemoveIconWrapper",
6
4
  componentId: "sc-1uw1dzt-0"
@@ -1,8 +1,8 @@
1
- import React from 'react';
2
- import { ItemsRollGroup } from '../ItemsRoll.types';
1
+ import type { ReactNode } from 'react';
2
+ import type { ItemsRollGroup } from '../ItemsRoll.types';
3
3
  export type RemoveIconProps = {
4
4
  id: string;
5
5
  group?: ItemsRollGroup;
6
6
  handleRemove: (id: string, group?: ItemsRollGroup) => void;
7
- tooltipLabel: string | React.ReactNode;
7
+ tooltipLabel: ReactNode;
8
8
  };
@@ -2,5 +2,5 @@ import React from 'react';
2
2
  import { ItemRollElement } from '../ItemsRoll.types';
3
3
  import { ListProps } from './List.types';
4
4
  export declare const itemsInGroup: (group: string, items: ItemRollElement[]) => ItemRollElement[];
5
- declare const List: React.FC<ListProps>;
5
+ declare const List: ({ groups, items, onItemClick, onItemRemove, noResultsLabel, removeTooltipLabel, searchValue, useVirtualizedList, visibleItems, virtualizedRowHeight, virtualizedRowWidth, }: ListProps) => React.JSX.Element;
6
6
  export default List;
@@ -1,7 +1,7 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { FixedSizeList } from 'react-window';
3
3
  import Icon, { SearchNoResultsM } from '@synerise/ds-icon';
4
- import Menu from '@synerise/ds-menu';
4
+ import { GroupItem } from '@synerise/ds-list-item';
5
5
  import ItemElement from './ListItem';
6
6
  import ItemRenderer from './VirtualizedListItem';
7
7
  import * as S from '../ItemsRoll.styles';
@@ -23,10 +23,45 @@ var List = function List(_ref) {
23
23
  _ref$virtualizedRowHe = _ref.virtualizedRowHeight,
24
24
  virtualizedRowHeight = _ref$virtualizedRowHe === void 0 ? 32 : _ref$virtualizedRowHe,
25
25
  virtualizedRowWidth = _ref.virtualizedRowWidth;
26
+ var groupedList = useMemo(function () {
27
+ return /*#__PURE__*/React.createElement(React.Fragment, null, groups == null ? void 0 : groups.map(function (group) {
28
+ var groupItems = itemsInGroup(group, visibleItems);
29
+ return groupItems.length > 0 ?
30
+ /*#__PURE__*/
31
+ // @ts-ignore
32
+ React.createElement(GroupItem, {
33
+ key: group,
34
+ title: group
35
+ }, groupItems.map(function (item) {
36
+ return /*#__PURE__*/React.createElement(ItemElement, {
37
+ group: group,
38
+ key: item.id,
39
+ highlight: searchValue,
40
+ onItemClick: onItemClick,
41
+ onItemRemove: onItemRemove,
42
+ item: item,
43
+ removeTooltipLabel: removeTooltipLabel
44
+ });
45
+ })) : null;
46
+ }));
47
+ }, [groups, onItemClick, onItemRemove, removeTooltipLabel, searchValue, visibleItems]);
48
+ var standardList = useMemo(function () {
49
+ return /*#__PURE__*/React.createElement(React.Fragment, null, visibleItems.map(function (item) {
50
+ return /*#__PURE__*/React.createElement(ItemElement, {
51
+ key: item.id,
52
+ highlight: searchValue,
53
+ item: item,
54
+ onItemClick: onItemClick,
55
+ onItemRemove: onItemRemove,
56
+ removeTooltipLabel: removeTooltipLabel
57
+ });
58
+ }));
59
+ }, [onItemClick, onItemRemove, removeTooltipLabel, searchValue, visibleItems]);
60
+ var finalItems = groups ? groupedList : standardList;
26
61
  return visibleItems.length === 0 ? /*#__PURE__*/React.createElement(S.NoResults, null, /*#__PURE__*/React.createElement(S.NoResultIconWrapper, null, /*#__PURE__*/React.createElement(Icon, {
27
62
  component: /*#__PURE__*/React.createElement(SearchNoResultsM, null),
28
63
  size: 25
29
- })), noResultsLabel) : /*#__PURE__*/React.createElement(S.ListWrapper, null, useVirtualizedList && !groups ? /*#__PURE__*/React.createElement(Menu, {
64
+ })), noResultsLabel) : /*#__PURE__*/React.createElement(S.ListWrapper, null, useVirtualizedList && !groups ? /*#__PURE__*/React.createElement("div", {
30
65
  "data-testid": "items-roll-virtualized-list"
31
66
  }, /*#__PURE__*/React.createElement(FixedSizeList, {
32
67
  height: visibleItems.length * virtualizedRowHeight,
@@ -39,34 +74,6 @@ var List = function List(_ref) {
39
74
  onItemClick: onItemClick,
40
75
  onItemRemove: onItemRemove,
41
76
  tooltipLabel: removeTooltipLabel
42
- }))) : /*#__PURE__*/React.createElement(Menu, null, groups ? groups.map(function (group) {
43
- var groupItems = itemsInGroup(group, visibleItems);
44
- return groupItems.length > 0 ?
45
- /*#__PURE__*/
46
- // @ts-ignore
47
- React.createElement(Menu.ItemGroup, {
48
- key: group,
49
- title: group
50
- }, groupItems.map(function (item) {
51
- return /*#__PURE__*/React.createElement(ItemElement, {
52
- group: group,
53
- key: item.id,
54
- highlight: searchValue,
55
- onItemClick: onItemClick,
56
- onItemRemove: onItemRemove,
57
- item: item,
58
- removeTooltipLabel: removeTooltipLabel
59
- });
60
- })) : null;
61
- }) : visibleItems.map(function (item) {
62
- return /*#__PURE__*/React.createElement(ItemElement, {
63
- key: item.id,
64
- highlight: searchValue,
65
- item: item,
66
- onItemClick: onItemClick,
67
- onItemRemove: onItemRemove,
68
- removeTooltipLabel: removeTooltipLabel
69
- });
70
- })));
77
+ }))) : finalItems);
71
78
  };
72
79
  export default List;
@@ -1,7 +1,7 @@
1
- import React from 'react';
2
- import { ItemRollElement, ItemsRollProps } from '../ItemsRoll.types';
1
+ import type { ReactNode } from 'react';
2
+ import type { ItemRollElement, ItemsRollProps } from '../ItemsRoll.types';
3
3
  export type ListProps = Pick<ItemsRollProps, 'groups' | 'items' | 'onItemClick' | 'onItemRemove' | 'searchValue' | 'useVirtualizedList' | 'virtualizedRowHeight' | 'virtualizedRowWidth'> & {
4
- noResultsLabel: string | React.ReactNode;
5
- removeTooltipLabel: string | React.ReactNode;
4
+ noResultsLabel: ReactNode;
5
+ removeTooltipLabel: ReactNode;
6
6
  visibleItems: ItemRollElement[];
7
7
  };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { ItemElementProps } from './ListItem.types';
3
- declare const ItemElement: React.FC<ItemElementProps>;
3
+ declare const ItemElement: ({ item, group, highlight, onItemClick, onItemRemove, removeTooltipLabel }: ItemElementProps) => React.JSX.Element;
4
4
  export default ItemElement;
@@ -1,6 +1,5 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import React from 'react';
3
- import { NOOP } from '@synerise/ds-utils';
2
+ import React, { useCallback } from 'react';
4
3
  import { RemoveIcon } from './ItemRemoveIcon';
5
4
  import * as S from './ListItem.styles';
6
5
  var ItemElement = function ItemElement(_ref) {
@@ -10,7 +9,7 @@ var ItemElement = function ItemElement(_ref) {
10
9
  onItemClick = _ref.onItemClick,
11
10
  onItemRemove = _ref.onItemRemove,
12
11
  removeTooltipLabel = _ref.removeTooltipLabel;
13
- var onClick = React.useCallback(function () {
12
+ var onClick = useCallback(function () {
14
13
  return onItemClick && onItemClick(item.id, group);
15
14
  }, [onItemClick, item.id, group]);
16
15
  var renderSuffixElement = function renderSuffixElement(hovered) {
@@ -19,7 +18,6 @@ var ItemElement = function ItemElement(_ref) {
19
18
  return /*#__PURE__*/React.createElement(S.ListItem, _extends({}, item, {
20
19
  className: "items-roll-list-item",
21
20
  highlight: highlight,
22
- onItemHover: NOOP,
23
21
  suffixel: function suffixel(hovered) {
24
22
  return /*#__PURE__*/React.createElement(S.SuffixelWrapper, null, renderSuffixElement(hovered) || null, onItemRemove && /*#__PURE__*/React.createElement(RemoveIcon, {
25
23
  id: item.id,
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- export declare const ListItem: import("styled-components").StyledComponent<import("react").FC<import("@synerise/ds-menu/dist/Elements/SubMenu/SubMenu.types").SubMenuProps & import("@synerise/ds-menu").MenuItemProps>, any, {}, never>;
2
+ export declare const ListItem: import("styled-components").StyledComponent<(props: import("@synerise/ds-list-item").ListItemProps) => import("react").JSX.Element, any, {}, never>;
3
3
  export declare const SuffixelWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,7 +1,7 @@
1
1
  import styled from 'styled-components';
2
- import Menu from '@synerise/ds-menu';
2
+ import DSListItem from '@synerise/ds-list-item';
3
3
  import { RemoveIconWrapper } from './ItemRemoveIcon.styles';
4
- export var ListItem = styled(Menu.Item).withConfig({
4
+ export var ListItem = styled(DSListItem).withConfig({
5
5
  displayName: "ListItemstyles__ListItem",
6
6
  componentId: "x6qavm-0"
7
7
  })(["&{", "{opacity:0;display:none;}}&:hover{", "{opacity:1;display:flex;}}"], RemoveIconWrapper, RemoveIconWrapper);
@@ -1,10 +1,10 @@
1
- import React from 'react';
2
- import { ItemRollElement, ItemsRollGroup } from '../ItemsRoll.types';
1
+ import type { ReactNode } from 'react';
2
+ import type { ItemRollElement, ItemsRollGroup } from '../ItemsRoll.types';
3
3
  export type ItemElementProps = {
4
4
  highlight?: string;
5
5
  item: ItemRollElement;
6
6
  group?: ItemsRollGroup;
7
7
  onItemClick?: (id: string, group?: ItemsRollGroup) => void;
8
8
  onItemRemove?: (id: string, group?: ItemsRollGroup) => void;
9
- removeTooltipLabel: string | React.ReactNode;
9
+ removeTooltipLabel: ReactNode;
10
10
  };
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { ListChildComponentProps } from 'react-window';
3
3
  import { ItemRendererProps } from './VirtualizedListItem.types';
4
- declare const ItemRenderer: ({ highlight, onItemClick, onItemRemove, tooltipLabel, group }: ItemRendererProps) => ({ index, style, data }: ListChildComponentProps) => JSX.Element;
4
+ declare const ItemRenderer: ({ highlight, onItemClick, onItemRemove, tooltipLabel, group }: ItemRendererProps) => ({ index, style, data }: ListChildComponentProps) => React.JSX.Element;
5
5
  export default ItemRenderer;
@@ -1,8 +1,6 @@
1
1
  var _excluded = ["suffixel"];
2
2
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
3
- import React from 'react';
4
- import Menu from '@synerise/ds-menu';
5
- import { NOOP } from '@synerise/ds-utils';
3
+ import React, { useCallback } from 'react';
6
4
  import * as S from './ListItem.styles';
7
5
  import { RemoveIcon } from './ItemRemoveIcon';
8
6
  var ItemRenderer = function ItemRenderer(_ref) {
@@ -21,22 +19,21 @@ var ItemRenderer = function ItemRenderer(_ref) {
21
19
  item = _objectWithoutPropertiesLoose(_ref3, _excluded);
22
20
 
23
21
  // eslint-disable-next-line react-hooks/rules-of-hooks
24
- var onClick = React.useCallback(function () {
22
+ var onClick = useCallback(function () {
25
23
  return onItemClick && onItemClick(item.id, group);
26
24
  }, [item.id]);
27
- return /*#__PURE__*/React.createElement(S.ListItem, null, /*#__PURE__*/React.createElement(Menu.Item, {
25
+ return /*#__PURE__*/React.createElement(S.ListItem, {
28
26
  className: "items-roll-list-item",
29
27
  highlight: highlight,
30
- onItemHover: NOOP,
31
28
  onClick: onClick,
32
29
  style: style,
33
- suffixel: /*#__PURE__*/React.createElement(S.SuffixelWrapper, null, suffixel, !!onItemRemove && /*#__PURE__*/React.createElement(RemoveIcon, {
30
+ suffixel: /*#__PURE__*/React.createElement(S.SuffixelWrapper, null, /*#__PURE__*/React.createElement(React.Fragment, null, suffixel, !!onItemRemove && /*#__PURE__*/React.createElement(RemoveIcon, {
34
31
  id: item.id,
35
32
  handleRemove: onItemRemove,
36
33
  tooltipLabel: tooltipLabel,
37
34
  group: group
38
- }))
39
- }, item.text));
35
+ })))
36
+ }, item.text);
40
37
  };
41
38
  };
42
39
  export default ItemRenderer;
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
- import { ItemsRollGroup } from '../ItemsRoll.types';
1
+ import type { ReactNode } from 'react';
2
+ import type { ItemsRollGroup } from '../ItemsRoll.types';
3
3
  export type ItemRendererProps = {
4
4
  highlight?: string;
5
5
  group?: ItemsRollGroup;
6
6
  onItemClick?: (id: string, group?: ItemsRollGroup) => void;
7
7
  onItemRemove?: (id: string, group?: ItemsRollGroup) => void;
8
- tooltipLabel: string | React.ReactNode;
8
+ tooltipLabel: ReactNode;
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-items-roll",
3
- "version": "0.7.16",
3
+ "version": "0.8.0",
4
4
  "description": "ItemsRoll UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -34,14 +34,15 @@
34
34
  ],
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
- "@synerise/ds-button": "^0.21.19",
38
- "@synerise/ds-divider": "^0.7.15",
39
- "@synerise/ds-dropdown": "^0.18.24",
40
- "@synerise/ds-icon": "^0.67.0",
41
- "@synerise/ds-menu": "^0.20.6",
42
- "@synerise/ds-popconfirm": "^0.10.61",
43
- "@synerise/ds-search": "^0.9.19",
44
- "@synerise/ds-tooltip": "^0.14.49",
37
+ "@synerise/ds-button": "^0.21.20",
38
+ "@synerise/ds-divider": "^0.7.16",
39
+ "@synerise/ds-dropdown": "^0.18.25",
40
+ "@synerise/ds-icon": "^0.67.1",
41
+ "@synerise/ds-list-item": "^0.5.0",
42
+ "@synerise/ds-menu": "^0.20.7",
43
+ "@synerise/ds-popconfirm": "^0.10.62",
44
+ "@synerise/ds-search": "^0.9.20",
45
+ "@synerise/ds-tooltip": "^0.14.50",
45
46
  "@synerise/ds-utils": "^0.31.2",
46
47
  "react-window": "^1.8.5"
47
48
  },
@@ -50,5 +51,5 @@
50
51
  "react": ">=16.9.0 <= 17.0.2",
51
52
  "styled-components": "5.0.1"
52
53
  },
53
- "gitHead": "e9897e5ecb13a9c022f5ed002db76e4ab78318c5"
54
+ "gitHead": "4a56ee7ef816c22341ce704154dc7aa65b7d1dcc"
54
55
  }