@synerise/ds-context-selector 0.7.3 → 0.8.3
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 +32 -0
- package/README.md +19 -18
- package/dist/ContextSelector.js +22 -30
- package/dist/ContextSelector.types.d.ts +2 -0
- package/dist/ContextSelector.types.js +1 -0
- package/dist/ContextSelectorDropdown/ContextSelectorDropdown.js +37 -62
- package/dist/ContextSelectorDropdown/ContextSelectorDropdownItem.js +5 -6
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
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.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-context-selector@0.8.2...@synerise/ds-context-selector@0.8.3) (2021-11-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-context-selector
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.8.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-context-selector@0.8.1...@synerise/ds-context-selector@0.8.2) (2021-11-16)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @synerise/ds-context-selector
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [0.8.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-context-selector@0.7.3...@synerise/ds-context-selector@0.8.1) (2021-11-09)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @synerise/ds-context-selector
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [0.8.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-context-selector@0.7.3...@synerise/ds-context-selector@0.8.0) (2021-11-09)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @synerise/ds-context-selector
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [0.7.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-context-selector@0.7.2...@synerise/ds-context-selector@0.7.3) (2021-11-05)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @synerise/ds-context-selector
|
package/README.md
CHANGED
|
@@ -84,24 +84,25 @@ import ContextSelector from '@synerise/ds-context-selector'
|
|
|
84
84
|
|
|
85
85
|
## API
|
|
86
86
|
|
|
87
|
-
| Property
|
|
88
|
-
| ---
|
|
89
|
-
| groups
|
|
90
|
-
| items
|
|
91
|
-
| onSelectItem
|
|
92
|
-
| opened
|
|
93
|
-
| texts
|
|
94
|
-
| selectedItem
|
|
95
|
-
| addMode
|
|
96
|
-
| customTriggerComponent
|
|
97
|
-
| trigger
|
|
98
|
-
| menuItemHeight
|
|
99
|
-
| dropdownWrapperStyles
|
|
100
|
-
| onClickOutsideEvents
|
|
101
|
-
| onClickOutside
|
|
102
|
-
| onSearch
|
|
103
|
-
| onFetchData
|
|
104
|
-
| hasMoreItems
|
|
87
|
+
| Property | Description | Type | Default |
|
|
88
|
+
| --- | --- | --- | --- |
|
|
89
|
+
| groups | Groups of items | ContextGroup[] | [] |
|
|
90
|
+
| items | Array of items | ContextItem[] | [] |
|
|
91
|
+
| onSelectItem | Callback called when user selects item | (item: ContextItem \ ContextGroup \ undefined) => void | - |
|
|
92
|
+
| opened | Whether if dropdown should opens from outside of component | boolean | false |
|
|
93
|
+
| texts | Translations object | ContextSelectorTexts | - |
|
|
94
|
+
| selectedItem | Selected item | ContextItem \ undefined | undefined |
|
|
95
|
+
| addMode | If true trigger doesn't change style when value is set | ContextItem \ undefined | undefined |
|
|
96
|
+
| customTriggerComponent | Add custom trigger | React.ReactNode | undefined |
|
|
97
|
+
| trigger | Add custom trigger to modal | 'click' \ 'hover' \ 'contextMenu' | 'click |
|
|
98
|
+
| menuItemHeight | Set component Menu.Item height | 'large' \ 'default' | - |
|
|
99
|
+
| dropdownWrapperStyles | Apply custom styles to dropdown wrapper | CSSProperties \ undefined | - |
|
|
100
|
+
| onClickOutsideEvents | Overwrite default events for document listener | HandledEventsType[] \ undefined | - |
|
|
101
|
+
| onClickOutside | Callback called when user click outside dropdown | () => void \ undefined | - |
|
|
102
|
+
| onSearch | Callback called when user enter any char in search input | (query: string) => void | - |
|
|
103
|
+
| onFetchData | Callback called when user scrolls to the end of dropdown list | () => void | - |
|
|
104
|
+
| hasMoreItems | Whether if onFetchData should be called | boolean | - |
|
|
105
|
+
| getPopupContainerOverride | Popup container function for child tooltips and dropdowns | (trigger: HTMLElement | null) => HTMLElement; | - |
|
|
105
106
|
|
|
106
107
|
|
|
107
108
|
### ContextGroup
|
package/dist/ContextSelector.js
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
-
|
|
9
|
-
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
-
|
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
1
|
import * as React from 'react';
|
|
14
2
|
import Button from '@synerise/ds-button';
|
|
15
|
-
import Icon from '@synerise/ds-icon';
|
|
16
|
-
import { AngleDownS, Add3M } from '@synerise/ds-icon/dist/icons';
|
|
3
|
+
import Icon, { AngleDownS, Add3M } from '@synerise/ds-icon';
|
|
17
4
|
import Dropdown from '@synerise/ds-dropdown';
|
|
18
5
|
import Tooltip from '@synerise/ds-tooltip';
|
|
19
6
|
import { getPopupContainer } from '@synerise/ds-utils';
|
|
@@ -39,13 +26,14 @@ var ContextSelector = function ContextSelector(_ref) {
|
|
|
39
26
|
onSearch = _ref.onSearch,
|
|
40
27
|
hasMoreItems = _ref.hasMoreItems,
|
|
41
28
|
onFetchData = _ref.onFetchData,
|
|
29
|
+
onActivate = _ref.onActivate,
|
|
42
30
|
onOpen = _ref.onOpen,
|
|
31
|
+
getPopupContainerOverride = _ref.getPopupContainerOverride,
|
|
43
32
|
type = _ref.type;
|
|
44
33
|
|
|
45
34
|
var _React$useState = React.useState(false),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
setDropdownVisible = _React$useState2[1];
|
|
35
|
+
dropdownVisible = _React$useState[0],
|
|
36
|
+
setDropdownVisible = _React$useState[1];
|
|
49
37
|
|
|
50
38
|
var handleChange = React.useCallback(function (val) {
|
|
51
39
|
setDropdownVisible(false);
|
|
@@ -72,32 +60,36 @@ var ContextSelector = function ContextSelector(_ref) {
|
|
|
72
60
|
}, [onOpen]);
|
|
73
61
|
var triggerButton = React.useMemo(function () {
|
|
74
62
|
var buttonLabel = texts.buttonLabel;
|
|
75
|
-
return addMode && !selectedItem ? React.createElement(Button, {
|
|
63
|
+
return addMode && !selectedItem ? /*#__PURE__*/React.createElement(Button, {
|
|
76
64
|
type: "primary",
|
|
77
65
|
mode: "icon-label",
|
|
78
66
|
onClick: handleClick
|
|
79
|
-
}, React.createElement(Icon, {
|
|
80
|
-
component: React.createElement(Add3M, null)
|
|
81
|
-
}), buttonLabel) : React.createElement(Button, {
|
|
67
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
68
|
+
component: /*#__PURE__*/React.createElement(Add3M, null)
|
|
69
|
+
}), buttonLabel) : /*#__PURE__*/React.createElement(Button, {
|
|
82
70
|
type: "custom-color",
|
|
83
71
|
color: triggerColor,
|
|
84
72
|
mode: triggerMode,
|
|
85
73
|
onClick: handleClick
|
|
86
|
-
}, selectedItem ? React.createElement(Icon, {
|
|
74
|
+
}, selectedItem ? /*#__PURE__*/React.createElement(Icon, {
|
|
87
75
|
component: selectedItem.icon
|
|
88
|
-
}) : null, React.createElement(ItemWrapper, null, React.createElement(Tooltip, {
|
|
76
|
+
}) : null, /*#__PURE__*/React.createElement(ItemWrapper, null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
89
77
|
title: selectedItem ? selectedItem.name : undefined
|
|
90
|
-
}, selectedItem ? selectedItem.name : buttonLabel)), React.createElement(Icon, {
|
|
91
|
-
component: React.createElement(AngleDownS, null)
|
|
78
|
+
}, selectedItem ? selectedItem.name : buttonLabel)), /*#__PURE__*/React.createElement(Icon, {
|
|
79
|
+
component: /*#__PURE__*/React.createElement(AngleDownS, null)
|
|
92
80
|
}));
|
|
93
81
|
}, [addMode, handleClick, texts, triggerColor, triggerMode, selectedItem]);
|
|
94
|
-
|
|
82
|
+
var onDropdownVisibilityChange = React.useCallback(function (value) {
|
|
83
|
+
return value && onActivate && onActivate();
|
|
84
|
+
}, [onActivate]);
|
|
85
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
95
86
|
"data-popup-container": true
|
|
96
|
-
}, React.createElement(Dropdown, {
|
|
97
|
-
getPopupContainer: getPopupContainer,
|
|
87
|
+
}, /*#__PURE__*/React.createElement(Dropdown, {
|
|
88
|
+
getPopupContainer: getPopupContainerOverride || getPopupContainer,
|
|
89
|
+
onVisibleChange: onDropdownVisibilityChange,
|
|
98
90
|
trigger: trigger,
|
|
99
91
|
visible: dropdownVisible,
|
|
100
|
-
overlay: React.createElement(ContextSelectorDropdown, {
|
|
92
|
+
overlay: /*#__PURE__*/React.createElement(ContextSelectorDropdown, {
|
|
101
93
|
value: selectedItem,
|
|
102
94
|
setDropdownVisible: setDropdownVisible,
|
|
103
95
|
setSelected: handleChange,
|
|
@@ -115,7 +107,7 @@ var ContextSelector = function ContextSelector(_ref) {
|
|
|
115
107
|
hasMoreItems: hasMoreItems,
|
|
116
108
|
onFetchData: onFetchData
|
|
117
109
|
})
|
|
118
|
-
}, customTriggerComponent
|
|
110
|
+
}, customTriggerComponent != null ? customTriggerComponent : triggerButton));
|
|
119
111
|
};
|
|
120
112
|
|
|
121
113
|
export default ContextSelector;
|
|
@@ -35,10 +35,12 @@ export declare type ContextItemsInSubGroup = ContextItem & {
|
|
|
35
35
|
};
|
|
36
36
|
export declare type ContextProps = {
|
|
37
37
|
selectedItem?: ContextItem | undefined;
|
|
38
|
+
onActivate?: () => void;
|
|
38
39
|
onSelectItem: (item: ContextItem | ContextGroup | undefined) => void;
|
|
39
40
|
groups: ContextGroup[];
|
|
40
41
|
items: ContextItem[];
|
|
41
42
|
texts: ContextTexts;
|
|
43
|
+
getPopupContainerOverride?: (trigger: HTMLElement | null) => HTMLElement;
|
|
42
44
|
onSetGroup?: (item: ContextItem | ContextGroup | undefined) => void;
|
|
43
45
|
opened?: boolean;
|
|
44
46
|
addMode?: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,35 +1,14 @@
|
|
|
1
1
|
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
2
|
|
|
3
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
-
|
|
5
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
|
|
7
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
8
|
-
|
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
|
|
11
3
|
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; }
|
|
12
4
|
|
|
13
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
6
|
|
|
15
7
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
8
|
|
|
17
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
-
|
|
19
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
|
-
|
|
21
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
22
|
-
|
|
23
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
24
|
-
|
|
25
|
-
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
26
|
-
|
|
27
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
28
|
-
|
|
29
9
|
import * as React from 'react';
|
|
30
10
|
import Dropdown from '@synerise/ds-dropdown';
|
|
31
|
-
import Icon from '@synerise/ds-icon';
|
|
32
|
-
import SearchM from '@synerise/ds-icon/dist/icons/SearchM';
|
|
11
|
+
import Icon, { SearchM } from '@synerise/ds-icon';
|
|
33
12
|
import Tabs from '@synerise/ds-tabs';
|
|
34
13
|
import { focusWithArrowKeys, useOnClickOutside } from '@synerise/ds-utils';
|
|
35
14
|
import Result from '@synerise/ds-result';
|
|
@@ -69,7 +48,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
69
48
|
overflowY: 'unset'
|
|
70
49
|
};
|
|
71
50
|
var defaultTab = React.useMemo(function () {
|
|
72
|
-
var defaultIndex = groups
|
|
51
|
+
var defaultIndex = groups == null ? void 0 : groups.findIndex(function (group) {
|
|
73
52
|
return group.defaultGroup;
|
|
74
53
|
});
|
|
75
54
|
return defaultIndex || 0;
|
|
@@ -77,27 +56,23 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
77
56
|
var overlayRef = React.useRef(null);
|
|
78
57
|
|
|
79
58
|
var _React$useState = React.useState(''),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
setSearchQuery = _React$useState2[1];
|
|
59
|
+
searchQuery = _React$useState[0],
|
|
60
|
+
setSearchQuery = _React$useState[1];
|
|
83
61
|
|
|
84
|
-
var _React$
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
setActiveTab = _React$useState4[1];
|
|
62
|
+
var _React$useState2 = React.useState(defaultTab),
|
|
63
|
+
activeTab = _React$useState2[0],
|
|
64
|
+
setActiveTab = _React$useState2[1];
|
|
88
65
|
|
|
89
|
-
var _React$
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
setActiveGroup = _React$useState6[1];
|
|
66
|
+
var _React$useState3 = React.useState(undefined),
|
|
67
|
+
activeGroup = _React$useState3[0],
|
|
68
|
+
setActiveGroup = _React$useState3[1];
|
|
93
69
|
|
|
94
|
-
var _React$
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
setSearchInputFocus = _React$useState8[1];
|
|
70
|
+
var _React$useState4 = React.useState(true),
|
|
71
|
+
searchInputCanBeFocused = _React$useState4[0],
|
|
72
|
+
setSearchInputFocus = _React$useState4[1];
|
|
98
73
|
|
|
99
74
|
var classNames = React.useMemo(function () {
|
|
100
|
-
return "ds-context-item ds-context-item-"
|
|
75
|
+
return "ds-context-item ds-context-item-" + uuid();
|
|
101
76
|
}, []);
|
|
102
77
|
var handleOnSetGroup = React.useCallback(function (item) {
|
|
103
78
|
onSetGroup && onSetGroup(item);
|
|
@@ -114,7 +89,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
114
89
|
setDropdownVisible(false);
|
|
115
90
|
}, [setDropdownVisible]);
|
|
116
91
|
var currentTabItems = React.useMemo(function () {
|
|
117
|
-
return groups
|
|
92
|
+
return groups == null ? void 0 : groups.find(function (group, index) {
|
|
118
93
|
return activeTab === index;
|
|
119
94
|
});
|
|
120
95
|
}, [groups, activeTab]);
|
|
@@ -152,7 +127,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
152
127
|
searchQuery: searchQuery,
|
|
153
128
|
hideDropdown: hideDropdown,
|
|
154
129
|
select: setSelected,
|
|
155
|
-
selected: Boolean(value) && item.id === (value
|
|
130
|
+
selected: Boolean(value) && item.id === (value == null ? void 0 : value.id),
|
|
156
131
|
menuItemHeight: menuItemHeight
|
|
157
132
|
};
|
|
158
133
|
resultItems.push(resultItem);
|
|
@@ -176,7 +151,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
176
151
|
clearSearch: clearSearch,
|
|
177
152
|
hideDropdown: hideDropdown,
|
|
178
153
|
select: setSelected,
|
|
179
|
-
selected: Boolean(value) && item.id === (value
|
|
154
|
+
selected: Boolean(value) && item.id === (value == null ? void 0 : value.id),
|
|
180
155
|
menuItemHeight: menuItemHeight
|
|
181
156
|
});
|
|
182
157
|
}
|
|
@@ -185,7 +160,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
185
160
|
return result;
|
|
186
161
|
}, [classNames, clearSearch, hideDropdown, items, menuItemHeight, searchQuery, setSelected, value]);
|
|
187
162
|
var hasSubgroups = React.useMemo(function () {
|
|
188
|
-
return Boolean(currentTabItems
|
|
163
|
+
return Boolean(currentTabItems == null ? void 0 : currentTabItems.subGroups);
|
|
189
164
|
}, [currentTabItems]);
|
|
190
165
|
var activeItems = React.useMemo(function () {
|
|
191
166
|
if (!onSearch && searchQuery) {
|
|
@@ -195,13 +170,13 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
195
170
|
if (hasSubgroups && !activeGroup) {
|
|
196
171
|
var _currentTabItems$subG;
|
|
197
172
|
|
|
198
|
-
var subGroups =
|
|
173
|
+
var subGroups = currentTabItems != null && currentTabItems.subGroups ? currentTabItems == null ? void 0 : (_currentTabItems$subG = currentTabItems.subGroups) == null ? void 0 : _currentTabItems$subG.map(function (group) {
|
|
199
174
|
return _objectSpread({}, group, {
|
|
200
175
|
isGroup: true
|
|
201
176
|
});
|
|
202
177
|
}) : [];
|
|
203
|
-
var subItems = items
|
|
204
|
-
if (curr.groupId === (currentTabItems
|
|
178
|
+
var subItems = items == null ? void 0 : items.reduce(function (prev, curr) {
|
|
179
|
+
if (curr.groupId === (currentTabItems == null ? void 0 : currentTabItems.id)) {
|
|
205
180
|
prev.push(_objectSpread({}, curr, {
|
|
206
181
|
isGroup: false
|
|
207
182
|
}));
|
|
@@ -209,17 +184,17 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
209
184
|
|
|
210
185
|
return prev;
|
|
211
186
|
}, []);
|
|
212
|
-
return groupByGroupName([].concat(
|
|
187
|
+
return groupByGroupName([].concat(subGroups, subItems));
|
|
213
188
|
}
|
|
214
189
|
|
|
215
190
|
if (activeGroup) {
|
|
216
|
-
return groupByGroupName(items
|
|
191
|
+
return groupByGroupName(items == null ? void 0 : items.filter(function (item) {
|
|
217
192
|
return activeGroup && item.groupId === activeGroup.id;
|
|
218
193
|
}));
|
|
219
194
|
}
|
|
220
195
|
|
|
221
196
|
if (activeTab && groups && groups[activeTab]) {
|
|
222
|
-
return groupByGroupName(items
|
|
197
|
+
return groupByGroupName(items == null ? void 0 : items.filter(function (item) {
|
|
223
198
|
return item.groupId === groups[activeTab].id;
|
|
224
199
|
}));
|
|
225
200
|
}
|
|
@@ -231,14 +206,14 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
231
206
|
onSearch && onSearch(val);
|
|
232
207
|
}, [onSearch]);
|
|
233
208
|
var getTabs = React.useMemo(function () {
|
|
234
|
-
return (groups
|
|
209
|
+
return (groups == null ? void 0 : groups.map(function (group) {
|
|
235
210
|
return {
|
|
236
211
|
label: group.name
|
|
237
212
|
};
|
|
238
213
|
})) || [];
|
|
239
214
|
}, [groups]);
|
|
240
215
|
var getNoResultContainer = React.useMemo(function () {
|
|
241
|
-
return React.createElement(Result, {
|
|
216
|
+
return /*#__PURE__*/React.createElement(Result, {
|
|
242
217
|
noSearchResults: true,
|
|
243
218
|
type: "no-results",
|
|
244
219
|
description: texts.noResults
|
|
@@ -254,7 +229,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
254
229
|
}
|
|
255
230
|
};
|
|
256
231
|
|
|
257
|
-
return React.createElement(Dropdown.Wrapper, {
|
|
232
|
+
return /*#__PURE__*/React.createElement(Dropdown.Wrapper, {
|
|
258
233
|
style: _objectSpread({
|
|
259
234
|
width: '300px'
|
|
260
235
|
}, dropdownWrapperStyles),
|
|
@@ -265,7 +240,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
265
240
|
setSearchInputFocus(true);
|
|
266
241
|
});
|
|
267
242
|
}
|
|
268
|
-
}, React.createElement(Dropdown.SearchInput, {
|
|
243
|
+
}, /*#__PURE__*/React.createElement(Dropdown.SearchInput, {
|
|
269
244
|
onSearchChange: handleSearch,
|
|
270
245
|
onClearInput: function onClearInput() {
|
|
271
246
|
handleSearch('');
|
|
@@ -275,11 +250,11 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
275
250
|
value: searchQuery,
|
|
276
251
|
autofocus: !searchQuery || searchInputCanBeFocused,
|
|
277
252
|
autofocusDelay: 50,
|
|
278
|
-
iconLeft: React.createElement(Icon, {
|
|
279
|
-
component: React.createElement(SearchM, null),
|
|
253
|
+
iconLeft: /*#__PURE__*/React.createElement(Icon, {
|
|
254
|
+
component: /*#__PURE__*/React.createElement(SearchM, null),
|
|
280
255
|
color: theme.palette['grey-600']
|
|
281
256
|
})
|
|
282
|
-
}), searchQuery === '' && getTabs.length > 1 && React.createElement(S.TabsWrapper, null, React.createElement(Tabs, {
|
|
257
|
+
}), searchQuery === '' && getTabs.length > 1 && /*#__PURE__*/React.createElement(S.TabsWrapper, null, /*#__PURE__*/React.createElement(Tabs, {
|
|
283
258
|
block: true,
|
|
284
259
|
tabs: getTabs,
|
|
285
260
|
activeTab: activeTab,
|
|
@@ -288,15 +263,15 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
288
263
|
setActiveGroup(undefined);
|
|
289
264
|
},
|
|
290
265
|
visible: visible
|
|
291
|
-
})), activeGroup && !searchQuery && React.createElement(Dropdown.BackAction, {
|
|
266
|
+
})), activeGroup && !searchQuery && /*#__PURE__*/React.createElement(Dropdown.BackAction, {
|
|
292
267
|
label: activeGroup.name,
|
|
293
268
|
onClick: function onClick() {
|
|
294
269
|
return setActiveGroup(undefined);
|
|
295
270
|
}
|
|
296
|
-
}), loading ? React.createElement(S.LoaderWrapper, null, React.createElement(Loader, {
|
|
271
|
+
}), loading ? /*#__PURE__*/React.createElement(S.LoaderWrapper, null, /*#__PURE__*/React.createElement(Loader, {
|
|
297
272
|
label: texts.loadingResults,
|
|
298
273
|
labelPosition: "bottom"
|
|
299
|
-
})) : React.createElement(S.ItemsList, null,
|
|
274
|
+
})) : /*#__PURE__*/React.createElement(S.ItemsList, null, activeItems != null && activeItems.length ? /*#__PURE__*/React.createElement(Scrollbar, {
|
|
300
275
|
absolute: true,
|
|
301
276
|
style: {
|
|
302
277
|
padding: 8
|
|
@@ -305,7 +280,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
305
280
|
hasMore: hasMoreItems,
|
|
306
281
|
onYReachEnd: onFetchData,
|
|
307
282
|
onScroll: handleScroll
|
|
308
|
-
}, React.createElement(List, {
|
|
283
|
+
}, /*#__PURE__*/React.createElement(List, {
|
|
309
284
|
width: "100%",
|
|
310
285
|
height: 300,
|
|
311
286
|
itemCount: activeItems.length,
|
|
@@ -316,9 +291,9 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
316
291
|
var index = _ref3.index,
|
|
317
292
|
style = _ref3.style;
|
|
318
293
|
var item = activeItems[index];
|
|
319
|
-
return item && isListTitle(item) ? React.createElement(S.Title, {
|
|
294
|
+
return item && isListTitle(item) ? /*#__PURE__*/React.createElement(S.Title, {
|
|
320
295
|
style: style
|
|
321
|
-
}, item.title) : React.createElement(ContextSelectorDropdownItem, _extends({
|
|
296
|
+
}, item.title) : /*#__PURE__*/React.createElement(ContextSelectorDropdownItem, _extends({
|
|
322
297
|
style: style
|
|
323
298
|
}, item));
|
|
324
299
|
})) : getNoResultContainer));
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import Icon from '@synerise/ds-icon';
|
|
2
|
+
import Icon, { CheckS } from '@synerise/ds-icon';
|
|
3
3
|
import Menu from '@synerise/ds-menu';
|
|
4
4
|
import theme from '@synerise/ds-core/dist/js/DSProvider/ThemeProvider/theme';
|
|
5
|
-
import { CheckS } from '@synerise/ds-icon/dist/icons';
|
|
6
5
|
|
|
7
6
|
var ContextSelectorDropdownItem = function ContextSelectorDropdownItem(_ref) {
|
|
8
7
|
var item = _ref.item,
|
|
@@ -14,16 +13,16 @@ var ContextSelectorDropdownItem = function ContextSelectorDropdownItem(_ref) {
|
|
|
14
13
|
className = _ref.className,
|
|
15
14
|
menuItemHeight = _ref.menuItemHeight,
|
|
16
15
|
style = _ref.style;
|
|
17
|
-
return React.createElement(Menu.Item, {
|
|
16
|
+
return /*#__PURE__*/React.createElement(Menu.Item, {
|
|
18
17
|
style: style,
|
|
19
18
|
className: className,
|
|
20
19
|
key: item.name + item.id,
|
|
21
|
-
prefixel: item.useCustomIcon ? item.icon : React.createElement(Icon, {
|
|
20
|
+
prefixel: item.useCustomIcon ? item.icon : /*#__PURE__*/React.createElement(Icon, {
|
|
22
21
|
component: item.icon
|
|
23
22
|
}),
|
|
24
23
|
highlight: searchQuery,
|
|
25
|
-
suffixel:
|
|
26
|
-
component: React.createElement(CheckS, null),
|
|
24
|
+
suffixel: item != null && item.customSuffix ? item.customSuffix : selected && /*#__PURE__*/React.createElement(Icon, {
|
|
25
|
+
component: /*#__PURE__*/React.createElement(CheckS, null),
|
|
27
26
|
color: theme.palette['green-600']
|
|
28
27
|
}),
|
|
29
28
|
onClick: function onClick() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-context-selector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "ContextSelector UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -26,20 +26,20 @@
|
|
|
26
26
|
"test:watch": "npm run test -- --watchAll",
|
|
27
27
|
"types": "tsc --noEmit"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "2468359677783819939fb9f1ef5acc36667ecd1a",
|
|
30
30
|
"sideEffects": [
|
|
31
31
|
"dist/style/*",
|
|
32
32
|
"*.less"
|
|
33
33
|
],
|
|
34
34
|
"types": "dist/index.d.ts",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@synerise/ds-button": "^0.
|
|
37
|
-
"@synerise/ds-dropdown": "^0.
|
|
38
|
-
"@synerise/ds-icon": "^0.
|
|
39
|
-
"@synerise/ds-menu": "^0.
|
|
40
|
-
"@synerise/ds-result": "^0.
|
|
41
|
-
"@synerise/ds-scrollbar": "^0.
|
|
42
|
-
"@synerise/ds-tabs": "^0.
|
|
36
|
+
"@synerise/ds-button": "^0.16.2",
|
|
37
|
+
"@synerise/ds-dropdown": "^0.17.3",
|
|
38
|
+
"@synerise/ds-icon": "^0.46.2",
|
|
39
|
+
"@synerise/ds-menu": "^0.11.2",
|
|
40
|
+
"@synerise/ds-result": "^0.6.2",
|
|
41
|
+
"@synerise/ds-scrollbar": "^0.4.2",
|
|
42
|
+
"@synerise/ds-tabs": "^0.12.3",
|
|
43
43
|
"@synerise/ds-utils": "^0.19.0",
|
|
44
44
|
"classnames": "^2.2.6",
|
|
45
45
|
"react-window": "1.8.5"
|