@synerise/ds-operators 0.6.2 → 0.6.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 +8 -0
- package/dist/Operators.js +4 -17
- package/dist/OperatorsDropdown/OperatorsDropdown.js +23 -39
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.6.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-operators@0.6.2...@synerise/ds-operators@0.6.3) (2021-11-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-operators
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [0.6.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-operators@0.6.1...@synerise/ds-operators@0.6.2) (2021-11-16)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-operators
|
package/dist/Operators.js
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly)
|
|
1
|
+
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; }
|
|
2
2
|
|
|
3
3
|
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; }
|
|
4
4
|
|
|
5
5
|
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; }
|
|
6
6
|
|
|
7
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
|
|
9
|
-
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."); }
|
|
10
|
-
|
|
11
|
-
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); }
|
|
12
|
-
|
|
13
|
-
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; }
|
|
14
|
-
|
|
15
|
-
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; }
|
|
16
|
-
|
|
17
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
|
|
19
7
|
import * as React from 'react';
|
|
20
8
|
import { useIntl } from 'react-intl';
|
|
21
9
|
import Button from '@synerise/ds-button';
|
|
@@ -40,9 +28,8 @@ var Operators = function Operators(_ref) {
|
|
|
40
28
|
formatMessage = _useIntl.formatMessage;
|
|
41
29
|
|
|
42
30
|
var _React$useState = React.useState(false),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
setDropdownVisible = _React$useState2[1];
|
|
31
|
+
dropdownVisible = _React$useState[0],
|
|
32
|
+
setDropdownVisible = _React$useState[1];
|
|
46
33
|
|
|
47
34
|
var text = React.useMemo(function () {
|
|
48
35
|
return _objectSpread({
|
|
@@ -91,7 +78,7 @@ var Operators = function Operators(_ref) {
|
|
|
91
78
|
})
|
|
92
79
|
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
93
80
|
getPopupContainer: getPopupContainerOverride || getPopupContainer,
|
|
94
|
-
title: (value
|
|
81
|
+
title: (value == null ? void 0 : value.name) || '',
|
|
95
82
|
trigger: ['hover']
|
|
96
83
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
97
84
|
type: "secondary",
|
|
@@ -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 { v4 as uuid } from 'uuid';
|
|
15
3
|
import Dropdown from '@synerise/ds-dropdown';
|
|
@@ -31,7 +19,7 @@ var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
|
31
19
|
setDropdownVisible = _ref.setDropdownVisible,
|
|
32
20
|
value = _ref.value;
|
|
33
21
|
var defaultTab = React.useMemo(function () {
|
|
34
|
-
var defaultIndex = groups
|
|
22
|
+
var defaultIndex = groups == null ? void 0 : groups.findIndex(function (group) {
|
|
35
23
|
return group.defaultGroup;
|
|
36
24
|
});
|
|
37
25
|
return defaultIndex || 0;
|
|
@@ -39,27 +27,23 @@ var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
|
39
27
|
var overlayRef = React.useRef(null);
|
|
40
28
|
|
|
41
29
|
var _React$useState = React.useState(''),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
setSearchQuery = _React$useState2[1];
|
|
30
|
+
searchQuery = _React$useState[0],
|
|
31
|
+
setSearchQuery = _React$useState[1];
|
|
45
32
|
|
|
46
|
-
var _React$
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
setActiveTab = _React$useState4[1];
|
|
33
|
+
var _React$useState2 = React.useState(defaultTab),
|
|
34
|
+
activeTab = _React$useState2[0],
|
|
35
|
+
setActiveTab = _React$useState2[1];
|
|
50
36
|
|
|
51
|
-
var _React$
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
setActiveGroup = _React$useState6[1];
|
|
37
|
+
var _React$useState3 = React.useState(undefined),
|
|
38
|
+
activeGroup = _React$useState3[0],
|
|
39
|
+
setActiveGroup = _React$useState3[1];
|
|
55
40
|
|
|
56
|
-
var _React$
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
setSearchInputFocus = _React$useState8[1];
|
|
41
|
+
var _React$useState4 = React.useState(true),
|
|
42
|
+
searchInputCanBeFocused = _React$useState4[0],
|
|
43
|
+
setSearchInputFocus = _React$useState4[1];
|
|
60
44
|
|
|
61
45
|
var classNames = React.useMemo(function () {
|
|
62
|
-
return "ds-operator-item ds-operator-item-"
|
|
46
|
+
return "ds-operator-item ds-operator-item-" + uuid();
|
|
63
47
|
}, []);
|
|
64
48
|
useOnClickOutside(overlayRef, function () {
|
|
65
49
|
setDropdownVisible(false);
|
|
@@ -92,14 +76,14 @@ var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
|
92
76
|
return setDropdownVisible(false);
|
|
93
77
|
},
|
|
94
78
|
select: setSelected,
|
|
95
|
-
selected: Boolean(value) && item.id === (value
|
|
79
|
+
selected: Boolean(value) && item.id === (value == null ? void 0 : value.id)
|
|
96
80
|
}));
|
|
97
81
|
});
|
|
98
82
|
});
|
|
99
83
|
return resultItems;
|
|
100
84
|
}, [searchQuery, setDropdownVisible, setSelected, value, classNames]);
|
|
101
85
|
var currentTabItems = React.useMemo(function () {
|
|
102
|
-
return groups
|
|
86
|
+
return groups == null ? void 0 : groups.find(function (group, index) {
|
|
103
87
|
return activeTab === index;
|
|
104
88
|
});
|
|
105
89
|
}, [groups, activeTab]);
|
|
@@ -119,7 +103,7 @@ var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
|
119
103
|
return setDropdownVisible(false);
|
|
120
104
|
},
|
|
121
105
|
select: setSelected,
|
|
122
|
-
selected: Boolean(value) && item.id === (value
|
|
106
|
+
selected: Boolean(value) && item.id === (value == null ? void 0 : value.id)
|
|
123
107
|
});
|
|
124
108
|
});
|
|
125
109
|
}, [items, searchQuery, setDropdownVisible, setSelected, value, classNames]);
|
|
@@ -128,12 +112,12 @@ var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
|
128
112
|
return filteredItems;
|
|
129
113
|
}
|
|
130
114
|
|
|
131
|
-
var hasSubgroups = Boolean(currentTabItems
|
|
115
|
+
var hasSubgroups = Boolean(currentTabItems == null ? void 0 : currentTabItems.subGroups);
|
|
132
116
|
|
|
133
117
|
if (hasSubgroups && !activeGroup) {
|
|
134
118
|
var _currentTabItems$subG;
|
|
135
119
|
|
|
136
|
-
return currentTabItems
|
|
120
|
+
return currentTabItems == null ? void 0 : (_currentTabItems$subG = currentTabItems.subGroups) == null ? void 0 : _currentTabItems$subG.map(function (subGroup) {
|
|
137
121
|
return /*#__PURE__*/React.createElement(OperatorsDropdownItem, {
|
|
138
122
|
className: classNames,
|
|
139
123
|
key: subGroup.name + subGroup.id,
|
|
@@ -144,23 +128,23 @@ var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
|
144
128
|
});
|
|
145
129
|
}
|
|
146
130
|
|
|
147
|
-
if (activeGroup
|
|
148
|
-
return groupByGroupName(items
|
|
131
|
+
if (activeGroup != null && activeGroup.id) {
|
|
132
|
+
return groupByGroupName(items == null ? void 0 : items.filter(function (item) {
|
|
149
133
|
return item.groupId === activeGroup.id;
|
|
150
134
|
}));
|
|
151
135
|
}
|
|
152
136
|
|
|
153
|
-
return groupByGroupName(items
|
|
137
|
+
return groupByGroupName(items == null ? void 0 : items.filter(function (item) {
|
|
154
138
|
var _groups$activeTab;
|
|
155
139
|
|
|
156
|
-
return item.groupId === ((_groups$activeTab = groups[activeTab])
|
|
140
|
+
return item.groupId === ((_groups$activeTab = groups[activeTab]) == null ? void 0 : _groups$activeTab.id);
|
|
157
141
|
}));
|
|
158
142
|
}, [currentTabItems, items, groups, searchQuery, activeTab, filteredItems, activeGroup, groupByGroupName, classNames]);
|
|
159
143
|
var handleSearch = React.useCallback(function (val) {
|
|
160
144
|
setSearchQuery(val);
|
|
161
145
|
}, [setSearchQuery]);
|
|
162
146
|
var getTabs = React.useMemo(function () {
|
|
163
|
-
return (groups
|
|
147
|
+
return (groups == null ? void 0 : groups.map(function (group) {
|
|
164
148
|
return {
|
|
165
149
|
icon: group.icon
|
|
166
150
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-operators",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Operators UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
],
|
|
33
33
|
"types": "dist/index.d.ts",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@synerise/ds-button": "^0.16.
|
|
36
|
-
"@synerise/ds-dropdown": "^0.17.
|
|
37
|
-
"@synerise/ds-icon": "^0.46.
|
|
38
|
-
"@synerise/ds-menu": "^0.11.
|
|
39
|
-
"@synerise/ds-result": "^0.6.
|
|
40
|
-
"@synerise/ds-scrollbar": "^0.4.
|
|
41
|
-
"@synerise/ds-tabs": "^0.12.
|
|
35
|
+
"@synerise/ds-button": "^0.16.2",
|
|
36
|
+
"@synerise/ds-dropdown": "^0.17.3",
|
|
37
|
+
"@synerise/ds-icon": "^0.46.2",
|
|
38
|
+
"@synerise/ds-menu": "^0.11.2",
|
|
39
|
+
"@synerise/ds-result": "^0.6.2",
|
|
40
|
+
"@synerise/ds-scrollbar": "^0.4.2",
|
|
41
|
+
"@synerise/ds-tabs": "^0.12.3",
|
|
42
42
|
"@synerise/ds-utils": "^0.19.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@synerise/ds-core": "*",
|
|
46
46
|
"react": ">=16.9.0 < 17.0.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "2468359677783819939fb9f1ef5acc36667ecd1a"
|
|
49
49
|
}
|