@synerise/ds-context-selector 0.8.2 → 0.8.6
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,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.6](https://github.com/Synerise/synerise-design/compare/@synerise/ds-context-selector@0.8.5...@synerise/ds-context-selector@0.8.6) (2021-12-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-context-selector
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.8.5](https://github.com/Synerise/synerise-design/compare/@synerise/ds-context-selector@0.8.4...@synerise/ds-context-selector@0.8.5) (2021-12-20)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @synerise/ds-context-selector
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [0.8.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-context-selector@0.8.3...@synerise/ds-context-selector@0.8.4) (2021-11-23)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @synerise/ds-context-selector
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [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)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @synerise/ds-context-selector
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [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)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @synerise/ds-context-selector
|
package/dist/ContextSelector.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
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(o); 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) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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
3
|
import Icon, { AngleDownS, Add3M } from '@synerise/ds-icon';
|
|
@@ -44,9 +32,8 @@ var ContextSelector = function ContextSelector(_ref) {
|
|
|
44
32
|
type = _ref.type;
|
|
45
33
|
|
|
46
34
|
var _React$useState = React.useState(false),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
setDropdownVisible = _React$useState2[1];
|
|
35
|
+
dropdownVisible = _React$useState[0],
|
|
36
|
+
setDropdownVisible = _React$useState[1];
|
|
50
37
|
|
|
51
38
|
var handleChange = React.useCallback(function (val) {
|
|
52
39
|
setDropdownVisible(false);
|
|
@@ -120,7 +107,7 @@ var ContextSelector = function ContextSelector(_ref) {
|
|
|
120
107
|
hasMoreItems: hasMoreItems,
|
|
121
108
|
onFetchData: onFetchData
|
|
122
109
|
})
|
|
123
|
-
}, customTriggerComponent
|
|
110
|
+
}, customTriggerComponent != null ? customTriggerComponent : triggerButton));
|
|
124
111
|
};
|
|
125
112
|
|
|
126
113
|
export default ContextSelector;
|
|
@@ -1,31 +1,11 @@
|
|
|
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
|
|
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" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
-
|
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
|
|
11
|
-
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; }
|
|
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(o); 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) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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
11
|
import Icon, { SearchM } from '@synerise/ds-icon';
|
|
@@ -62,13 +42,13 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
62
42
|
onSearch = _ref.onSearch,
|
|
63
43
|
onFetchData = _ref.onFetchData,
|
|
64
44
|
hasMoreItems = _ref.hasMoreItems;
|
|
65
|
-
var listRef =
|
|
45
|
+
var listRef = React.createRef();
|
|
66
46
|
var listStyle = {
|
|
67
47
|
overflowX: 'unset',
|
|
68
48
|
overflowY: 'unset'
|
|
69
49
|
};
|
|
70
50
|
var defaultTab = React.useMemo(function () {
|
|
71
|
-
var defaultIndex = groups
|
|
51
|
+
var defaultIndex = groups == null ? void 0 : groups.findIndex(function (group) {
|
|
72
52
|
return group.defaultGroup;
|
|
73
53
|
});
|
|
74
54
|
return defaultIndex || 0;
|
|
@@ -76,27 +56,23 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
76
56
|
var overlayRef = React.useRef(null);
|
|
77
57
|
|
|
78
58
|
var _React$useState = React.useState(''),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
setSearchQuery = _React$useState2[1];
|
|
59
|
+
searchQuery = _React$useState[0],
|
|
60
|
+
setSearchQuery = _React$useState[1];
|
|
82
61
|
|
|
83
|
-
var _React$
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
setActiveTab = _React$useState4[1];
|
|
62
|
+
var _React$useState2 = React.useState(defaultTab),
|
|
63
|
+
activeTab = _React$useState2[0],
|
|
64
|
+
setActiveTab = _React$useState2[1];
|
|
87
65
|
|
|
88
|
-
var _React$
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
setActiveGroup = _React$useState6[1];
|
|
66
|
+
var _React$useState3 = React.useState(undefined),
|
|
67
|
+
activeGroup = _React$useState3[0],
|
|
68
|
+
setActiveGroup = _React$useState3[1];
|
|
92
69
|
|
|
93
|
-
var _React$
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
setSearchInputFocus = _React$useState8[1];
|
|
70
|
+
var _React$useState4 = React.useState(true),
|
|
71
|
+
searchInputCanBeFocused = _React$useState4[0],
|
|
72
|
+
setSearchInputFocus = _React$useState4[1];
|
|
97
73
|
|
|
98
74
|
var classNames = React.useMemo(function () {
|
|
99
|
-
return "ds-context-item ds-context-item-"
|
|
75
|
+
return "ds-context-item ds-context-item-" + uuid();
|
|
100
76
|
}, []);
|
|
101
77
|
var handleOnSetGroup = React.useCallback(function (item) {
|
|
102
78
|
onSetGroup && onSetGroup(item);
|
|
@@ -113,7 +89,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
113
89
|
setDropdownVisible(false);
|
|
114
90
|
}, [setDropdownVisible]);
|
|
115
91
|
var currentTabItems = React.useMemo(function () {
|
|
116
|
-
return groups
|
|
92
|
+
return groups == null ? void 0 : groups.find(function (group, index) {
|
|
117
93
|
return activeTab === index;
|
|
118
94
|
});
|
|
119
95
|
}, [groups, activeTab]);
|
|
@@ -151,7 +127,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
151
127
|
searchQuery: searchQuery,
|
|
152
128
|
hideDropdown: hideDropdown,
|
|
153
129
|
select: setSelected,
|
|
154
|
-
selected: Boolean(value) && item.id === (value
|
|
130
|
+
selected: Boolean(value) && item.id === (value == null ? void 0 : value.id),
|
|
155
131
|
menuItemHeight: menuItemHeight
|
|
156
132
|
};
|
|
157
133
|
resultItems.push(resultItem);
|
|
@@ -175,7 +151,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
175
151
|
clearSearch: clearSearch,
|
|
176
152
|
hideDropdown: hideDropdown,
|
|
177
153
|
select: setSelected,
|
|
178
|
-
selected: Boolean(value) && item.id === (value
|
|
154
|
+
selected: Boolean(value) && item.id === (value == null ? void 0 : value.id),
|
|
179
155
|
menuItemHeight: menuItemHeight
|
|
180
156
|
});
|
|
181
157
|
}
|
|
@@ -184,7 +160,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
184
160
|
return result;
|
|
185
161
|
}, [classNames, clearSearch, hideDropdown, items, menuItemHeight, searchQuery, setSelected, value]);
|
|
186
162
|
var hasSubgroups = React.useMemo(function () {
|
|
187
|
-
return Boolean(currentTabItems
|
|
163
|
+
return Boolean(currentTabItems == null ? void 0 : currentTabItems.subGroups);
|
|
188
164
|
}, [currentTabItems]);
|
|
189
165
|
var activeItems = React.useMemo(function () {
|
|
190
166
|
if (!onSearch && searchQuery) {
|
|
@@ -194,31 +170,31 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
194
170
|
if (hasSubgroups && !activeGroup) {
|
|
195
171
|
var _currentTabItems$subG;
|
|
196
172
|
|
|
197
|
-
var subGroups = currentTabItems
|
|
198
|
-
return _objectSpread(
|
|
173
|
+
var subGroups = currentTabItems != null && currentTabItems.subGroups ? currentTabItems == null ? void 0 : (_currentTabItems$subG = currentTabItems.subGroups) == null ? void 0 : _currentTabItems$subG.map(function (group) {
|
|
174
|
+
return _objectSpread({}, group, {
|
|
199
175
|
isGroup: true
|
|
200
176
|
});
|
|
201
177
|
}) : [];
|
|
202
|
-
var subItems = items
|
|
203
|
-
if (curr.groupId === (currentTabItems
|
|
204
|
-
prev.push(_objectSpread(
|
|
178
|
+
var subItems = items == null ? void 0 : items.reduce(function (prev, curr) {
|
|
179
|
+
if (curr.groupId === (currentTabItems == null ? void 0 : currentTabItems.id)) {
|
|
180
|
+
prev.push(_objectSpread({}, curr, {
|
|
205
181
|
isGroup: false
|
|
206
182
|
}));
|
|
207
183
|
}
|
|
208
184
|
|
|
209
185
|
return prev;
|
|
210
186
|
}, []);
|
|
211
|
-
return groupByGroupName([].concat(
|
|
187
|
+
return groupByGroupName([].concat(subGroups, subItems));
|
|
212
188
|
}
|
|
213
189
|
|
|
214
190
|
if (activeGroup) {
|
|
215
|
-
return groupByGroupName(items
|
|
191
|
+
return groupByGroupName(items == null ? void 0 : items.filter(function (item) {
|
|
216
192
|
return activeGroup && item.groupId === activeGroup.id;
|
|
217
193
|
}));
|
|
218
194
|
}
|
|
219
195
|
|
|
220
196
|
if (activeTab && groups && groups[activeTab]) {
|
|
221
|
-
return groupByGroupName(items
|
|
197
|
+
return groupByGroupName(items == null ? void 0 : items.filter(function (item) {
|
|
222
198
|
return item.groupId === groups[activeTab].id;
|
|
223
199
|
}));
|
|
224
200
|
}
|
|
@@ -230,7 +206,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
230
206
|
onSearch && onSearch(val);
|
|
231
207
|
}, [onSearch]);
|
|
232
208
|
var getTabs = React.useMemo(function () {
|
|
233
|
-
return (groups
|
|
209
|
+
return (groups == null ? void 0 : groups.map(function (group) {
|
|
234
210
|
return {
|
|
235
211
|
label: group.name
|
|
236
212
|
};
|
|
@@ -295,7 +271,7 @@ var ContextSelectorDropdown = function ContextSelectorDropdown(_ref) {
|
|
|
295
271
|
}), loading ? /*#__PURE__*/React.createElement(S.LoaderWrapper, null, /*#__PURE__*/React.createElement(Loader, {
|
|
296
272
|
label: texts.loadingResults,
|
|
297
273
|
labelPosition: "bottom"
|
|
298
|
-
})) : /*#__PURE__*/React.createElement(S.ItemsList, null, activeItems
|
|
274
|
+
})) : /*#__PURE__*/React.createElement(S.ItemsList, null, activeItems != null && activeItems.length ? /*#__PURE__*/React.createElement(Scrollbar, {
|
|
299
275
|
absolute: true,
|
|
300
276
|
style: {
|
|
301
277
|
padding: 8
|
|
@@ -21,7 +21,7 @@ var ContextSelectorDropdownItem = function ContextSelectorDropdownItem(_ref) {
|
|
|
21
21
|
component: item.icon
|
|
22
22
|
}),
|
|
23
23
|
highlight: searchQuery,
|
|
24
|
-
suffixel: item
|
|
24
|
+
suffixel: item != null && item.customSuffix ? item.customSuffix : selected && /*#__PURE__*/React.createElement(Icon, {
|
|
25
25
|
component: /*#__PURE__*/React.createElement(CheckS, null),
|
|
26
26
|
color: theme.palette['green-600']
|
|
27
27
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-context-selector",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
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": "a89cd14cdbe25b06949b3b9763e58a080111c160",
|
|
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.16.
|
|
37
|
-
"@synerise/ds-dropdown": "^0.17.
|
|
38
|
-
"@synerise/ds-icon": "^0.46.
|
|
39
|
-
"@synerise/ds-menu": "^0.11.
|
|
40
|
-
"@synerise/ds-result": "^0.6.
|
|
41
|
-
"@synerise/ds-scrollbar": "^0.4.
|
|
42
|
-
"@synerise/ds-tabs": "^0.12.
|
|
36
|
+
"@synerise/ds-button": "^0.16.3",
|
|
37
|
+
"@synerise/ds-dropdown": "^0.17.5",
|
|
38
|
+
"@synerise/ds-icon": "^0.46.2",
|
|
39
|
+
"@synerise/ds-menu": "^0.11.4",
|
|
40
|
+
"@synerise/ds-result": "^0.6.3",
|
|
41
|
+
"@synerise/ds-scrollbar": "^0.4.2",
|
|
42
|
+
"@synerise/ds-tabs": "^0.12.6",
|
|
43
43
|
"@synerise/ds-utils": "^0.19.0",
|
|
44
44
|
"classnames": "^2.2.6",
|
|
45
45
|
"react-window": "1.8.5"
|