@synerise/ds-context-selector 0.25.9 → 0.25.11

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,22 @@
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.25.11](https://github.com/Synerise/synerise-design/compare/@synerise/ds-context-selector@0.25.10...@synerise/ds-context-selector@0.25.11) (2024-10-28)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-context-selector
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.25.10](https://github.com/Synerise/synerise-design/compare/@synerise/ds-context-selector@0.25.9...@synerise/ds-context-selector@0.25.10) (2024-10-24)
15
+
16
+ **Note:** Version bump only for package @synerise/ds-context-selector
17
+
18
+
19
+
20
+
21
+
6
22
  ## [0.25.9](https://github.com/Synerise/synerise-design/compare/@synerise/ds-context-selector@0.25.8...@synerise/ds-context-selector@0.25.9) (2024-10-23)
7
23
 
8
24
  **Note:** Version bump only for package @synerise/ds-context-selector
@@ -24,6 +24,8 @@ export type ContextItem = Pick<ListItemProps, 'renderHoverTooltip' | 'hoverToolt
24
24
  subGroups?: ContextGroup[];
25
25
  useCustomIcon?: boolean;
26
26
  subtitle?: string;
27
+ value?: ReactText | null;
28
+ excludeFromSearchResults?: boolean;
27
29
  informationCardProps?: Partial<InformationCardProps>;
28
30
  renderAdditionalDescription?: () => ReactNode;
29
31
  };
@@ -119,4 +121,7 @@ export type ListTitle = {
119
121
  title?: string;
120
122
  type?: string;
121
123
  };
124
+ export type ListDivider = {
125
+ type: 'divider';
126
+ };
122
127
  export type DropdownItemProps = ListTitle | ContextSelectorDropdownItemProps;
@@ -1,3 +1,5 @@
1
+ var _ITEM_SIZE;
2
+
1
3
  function _extends() { _extends = Object.assign || 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
4
 
3
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
@@ -15,12 +17,18 @@ import Tabs from '@synerise/ds-tabs';
15
17
  import { focusWithArrowKeys, getClosest, useOnClickOutside, useSearchResults, getActiveTabGroup, getGroupName } from '@synerise/ds-utils';
16
18
  import Result from '@synerise/ds-result';
17
19
  import Scrollbar from '@synerise/ds-scrollbar';
20
+ import Divider from '@synerise/ds-divider';
18
21
  import { theme } from '@synerise/ds-core';
19
22
  import { itemSizes } from '@synerise/ds-list-item';
20
23
  import * as S from '../ContextSelector.styles';
21
24
  import ContextSelectorDropdownItem from './ContextSelectorDropdownItem';
22
- import { NO_GROUP_NAME, ITEM_SIZE, DROPDOWN_HEIGHT, TABS_HEIGHT, SUBGROUP_HEADER_HEIGHT, SEARCH_HEIGHT } from '../constants';
25
+ import { NO_GROUP_NAME, DROPDOWN_HEIGHT, TABS_HEIGHT, SUBGROUP_HEADER_HEIGHT, SEARCH_HEIGHT } from '../constants';
23
26
  import { isGroup, isListTitle } from './utils';
27
+ var ITEM_SIZE = (_ITEM_SIZE = {}, _ITEM_SIZE[itemSizes.LARGE] = 50, _ITEM_SIZE[itemSizes.DEFAULT] = 32, _ITEM_SIZE.title = 32, _ITEM_SIZE.divider = 16, _ITEM_SIZE);
28
+
29
+ function isDivider(element) {
30
+ return element.type === 'divider';
31
+ }
24
32
 
25
33
  var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
26
34
  var texts = _ref.texts,
@@ -83,21 +91,29 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
83
91
  var classNames = useMemo(function () {
84
92
  return "ds-context-item ds-context-item-" + uuid();
85
93
  }, []);
94
+ var resetList = useCallback(function () {
95
+ if (listRef.current) {
96
+ listRef.current.resetAfterIndex(0, false);
97
+ }
98
+ }, [listRef]);
86
99
  var handleOnSetGroup = useCallback(function (item) {
87
100
  if (isGroup(item)) {
88
101
  onSetGroup && onSetGroup(item);
89
102
  setActiveGroup(item);
103
+ resetList();
90
104
  }
91
- }, [onSetGroup]);
105
+ }, [onSetGroup, setActiveGroup, resetList]);
92
106
  useOnClickOutside(overlayRef, function (event) {
93
107
  if (getClosest(event.target, '.ds-info-card') === null) {
94
108
  onClickOutside && onClickOutside();
95
109
  setDropdownVisible(false);
110
+ resetList();
96
111
  }
97
112
  }, onClickOutsideEvents);
98
113
  var clearSearch = useCallback(function () {
99
114
  setSearchQuery('');
100
- }, []);
115
+ resetList();
116
+ }, [setSearchQuery, resetList]);
101
117
  var hideDropdown = useCallback(function () {
102
118
  setDropdownVisible(false);
103
119
  }, [setDropdownVisible]);
@@ -123,7 +139,13 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
123
139
  }
124
140
 
125
141
  var resultItems = [];
126
- Object.keys(groupedItems).forEach(function (key) {
142
+ Object.keys(groupedItems).forEach(function (key, index) {
143
+ if (index > 0) {
144
+ resultItems.push({
145
+ type: 'divider'
146
+ });
147
+ }
148
+
127
149
  if (key !== NO_GROUP_NAME && !activeGroup) {
128
150
  resultItems.push({
129
151
  type: 'title',
@@ -239,8 +261,9 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
239
261
  }, [activeItems, listRef]);
240
262
  var handleSearch = useCallback(function (val) {
241
263
  setSearchQuery(val);
264
+ resetList();
242
265
  onSearch && onSearch(val);
243
- }, [onSearch]);
266
+ }, [setSearchQuery, resetList, onSearch]);
244
267
  var getTabs = useMemo(function () {
245
268
  return (groups == null ? void 0 : groups.map(function (group) {
246
269
  return {
@@ -269,6 +292,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
269
292
  var getItemSize = function getItemSize(index) {
270
293
  var item = activeItems[index];
271
294
  if (isListTitle(item)) return ITEM_SIZE.title;
295
+ if (isDivider(item)) return ITEM_SIZE.divider;
272
296
  return menuItemHeight ? ITEM_SIZE[menuItemHeight] : ITEM_SIZE[itemSizes.DEFAULT];
273
297
  };
274
298
 
@@ -304,6 +328,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
304
328
  onClearInput: function onClearInput() {
305
329
  handleSearch('');
306
330
  onSearch && onSearch('');
331
+ resetList();
307
332
  },
308
333
  placeholder: texts.searchPlaceholder,
309
334
  value: searchQuery,
@@ -323,6 +348,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
323
348
  handleTabClick: function handleTabClick(index) {
324
349
  setActiveTab(index);
325
350
  setActiveGroup(undefined);
351
+ resetList();
326
352
  },
327
353
  visible: visible
328
354
  })), activeGroup && /*#__PURE__*/React.createElement(Dropdown.BackAction, {
@@ -359,6 +385,16 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
359
385
  var index = _ref3.index,
360
386
  style = _ref3.style;
361
387
  var item = activeItems[index];
388
+
389
+ if (item && isDivider(item)) {
390
+ return /*#__PURE__*/React.createElement("div", {
391
+ style: style
392
+ }, /*#__PURE__*/React.createElement(Divider, {
393
+ marginTop: 8,
394
+ marginBottom: 8
395
+ }));
396
+ }
397
+
362
398
  return item && isListTitle(item) ? /*#__PURE__*/React.createElement(S.Title, {
363
399
  style: style
364
400
  }, item.title) : /*#__PURE__*/React.createElement(ContextSelectorDropdownItem, _extends({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-context-selector",
3
- "version": "0.25.9",
3
+ "version": "0.25.11",
4
4
  "description": "ContextSelector UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -28,25 +28,26 @@
28
28
  "types": "tsc --noEmit",
29
29
  "upgrade:ds": "ncu -f \"@synerise/ds-*\" -u"
30
30
  },
31
- "gitHead": "c45f411bd0eac69ae70b6c948da1c530539b01d6",
31
+ "gitHead": "fbadaa2299668c527b52ecc66d61fc2165528bff",
32
32
  "sideEffects": [
33
33
  "dist/style/*",
34
34
  "*.less"
35
35
  ],
36
36
  "types": "dist/index.d.ts",
37
37
  "dependencies": {
38
- "@synerise/ds-button": "^0.21.14",
39
- "@synerise/ds-dropdown": "^0.18.19",
40
- "@synerise/ds-factors": "^0.26.2",
41
- "@synerise/ds-icon": "^0.66.0",
42
- "@synerise/ds-information-card": "^0.5.15",
43
- "@synerise/ds-list-item": "^0.4.14",
44
- "@synerise/ds-menu": "^0.20.1",
45
- "@synerise/ds-result": "^0.7.9",
46
- "@synerise/ds-scrollbar": "^0.11.14",
47
- "@synerise/ds-skeleton": "^0.6.13",
48
- "@synerise/ds-tabs": "^0.17.2",
49
- "@synerise/ds-utils": "^0.30.0",
38
+ "@synerise/ds-button": "^0.21.15",
39
+ "@synerise/ds-divider": "^0.7.11",
40
+ "@synerise/ds-dropdown": "^0.18.20",
41
+ "@synerise/ds-factors": "^0.26.4",
42
+ "@synerise/ds-icon": "^0.66.1",
43
+ "@synerise/ds-information-card": "^0.5.16",
44
+ "@synerise/ds-list-item": "^0.4.15",
45
+ "@synerise/ds-menu": "^0.20.2",
46
+ "@synerise/ds-result": "^0.7.10",
47
+ "@synerise/ds-scrollbar": "^0.11.15",
48
+ "@synerise/ds-skeleton": "^0.6.14",
49
+ "@synerise/ds-tabs": "^0.17.3",
50
+ "@synerise/ds-utils": "^0.30.1",
50
51
  "react-window": "1.8.5",
51
52
  "uuid": "^8.3.2"
52
53
  },