@synerise/ds-operators 0.14.2 → 0.14.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
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.14.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-operators@0.14.2...@synerise/ds-operators@0.14.3) (2024-11-28)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-operators
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [0.14.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-operators@0.14.1...@synerise/ds-operators@0.14.2) (2024-11-21)
|
|
7
15
|
|
|
8
16
|
|
package/dist/Operators.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
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; }
|
|
6
|
-
|
|
7
4
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
8
|
-
|
|
9
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); }
|
|
10
|
-
|
|
11
6
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
12
7
|
import { useIntl } from 'react-intl';
|
|
13
8
|
import Button from '@synerise/ds-button';
|
|
@@ -18,39 +13,33 @@ import Tooltip from '@synerise/ds-tooltip';
|
|
|
18
13
|
import OperatorsDropdown from './OperatorsDropdown/OperatorsDropdown';
|
|
19
14
|
import * as S from './Operators.style';
|
|
20
15
|
import { DROPDOWN_HEIGHT, DROPDOWN_HEIGHT_BELOW_THRESHOLD, DROPDOWN_HEIGHT_THRESHOLD } from './constants';
|
|
21
|
-
|
|
22
16
|
var Operators = function Operators(_ref) {
|
|
23
17
|
var value = _ref.value,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
onChange = _ref.onChange,
|
|
19
|
+
groups = _ref.groups,
|
|
20
|
+
items = _ref.items,
|
|
21
|
+
texts = _ref.texts,
|
|
22
|
+
opened = _ref.opened,
|
|
23
|
+
getPopupContainerOverride = _ref.getPopupContainerOverride,
|
|
24
|
+
onActivate = _ref.onActivate,
|
|
25
|
+
onDeactivate = _ref.onDeactivate,
|
|
26
|
+
_ref$readOnly = _ref.readOnly,
|
|
27
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
28
|
+
errorText = _ref.errorText,
|
|
29
|
+
dropdownDimensionsConfig = _ref.dropdownDimensionsConfig;
|
|
37
30
|
var dimensionsConfig = _objectSpread({
|
|
38
31
|
defaultHeight: DROPDOWN_HEIGHT,
|
|
39
32
|
lowerHeight: DROPDOWN_HEIGHT_BELOW_THRESHOLD,
|
|
40
33
|
threshold: DROPDOWN_HEIGHT_THRESHOLD
|
|
41
34
|
}, dropdownDimensionsConfig);
|
|
42
|
-
|
|
43
35
|
var _useIntl = useIntl(),
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
formatMessage = _useIntl.formatMessage;
|
|
46
37
|
var _useState = useState(false),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
dropdownVisible = _useState[0],
|
|
39
|
+
setDropdownVisible = _useState[1];
|
|
50
40
|
var _useState2 = useState(dimensionsConfig.defaultHeight),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
outerHeight = _useState2[0],
|
|
42
|
+
setOuterHeight = _useState2[1];
|
|
54
43
|
var text = useMemo(function () {
|
|
55
44
|
return _objectSpread({
|
|
56
45
|
buttonLabel: formatMessage({
|
|
@@ -72,7 +61,6 @@ var Operators = function Operators(_ref) {
|
|
|
72
61
|
}, [onChange]);
|
|
73
62
|
useEffect(function () {
|
|
74
63
|
setDropdownVisible(Boolean(opened));
|
|
75
|
-
|
|
76
64
|
if (opened) {
|
|
77
65
|
onActivate && onActivate();
|
|
78
66
|
}
|
|
@@ -89,7 +77,6 @@ var Operators = function Operators(_ref) {
|
|
|
89
77
|
if (value) {
|
|
90
78
|
return readOnly ? 'icon-label' : 'two-icons';
|
|
91
79
|
}
|
|
92
|
-
|
|
93
80
|
return readOnly ? 'simple' : 'label-icon';
|
|
94
81
|
}, [value, readOnly]);
|
|
95
82
|
var dropdownTrigger = /*#__PURE__*/React.createElement(Tooltip, {
|
|
@@ -111,7 +98,6 @@ var Operators = function Operators(_ref) {
|
|
|
111
98
|
var checkViewportHeight = function checkViewportHeight() {
|
|
112
99
|
return setOuterHeight(window.innerHeight < dimensionsConfig.threshold ? dimensionsConfig.lowerHeight : dimensionsConfig.defaultHeight);
|
|
113
100
|
};
|
|
114
|
-
|
|
115
101
|
checkViewportHeight();
|
|
116
102
|
window.addEventListener('resize', checkViewportHeight);
|
|
117
103
|
return function () {
|
|
@@ -134,5 +120,4 @@ var Operators = function Operators(_ref) {
|
|
|
134
120
|
}, dropdownTrigger);
|
|
135
121
|
return content;
|
|
136
122
|
};
|
|
137
|
-
|
|
138
123
|
export default Operators;
|
|
@@ -12,34 +12,28 @@ import OperatorsDropdownGroupName from './OperatorsDropdownGroupName';
|
|
|
12
12
|
import * as S from '../Operators.style';
|
|
13
13
|
import { groupByGroupName } from '../utils';
|
|
14
14
|
import { NO_GROUP_NAME, DROPDOWN_HEIGHT, TABS_HEIGHT, PADDING, DEFAULT_TAB_INDEX, SEARCH_HEIGHT } from '../constants';
|
|
15
|
-
|
|
16
15
|
var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
17
16
|
var texts = _ref.texts,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
setSelected = _ref.setSelected,
|
|
18
|
+
groups = _ref.groups,
|
|
19
|
+
items = _ref.items,
|
|
20
|
+
setDropdownVisible = _ref.setDropdownVisible,
|
|
21
|
+
value = _ref.value,
|
|
22
|
+
_ref$outerHeight = _ref.outerHeight,
|
|
23
|
+
outerHeight = _ref$outerHeight === void 0 ? DROPDOWN_HEIGHT : _ref$outerHeight;
|
|
25
24
|
var overlayRef = useRef(null);
|
|
26
|
-
|
|
27
25
|
var _useState = useState(''),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
searchQuery = _useState[0],
|
|
27
|
+
setSearchQuery = _useState[1];
|
|
31
28
|
var _useState2 = useState(DEFAULT_TAB_INDEX),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
activeTab = _useState2[0],
|
|
30
|
+
setActiveTab = _useState2[1];
|
|
35
31
|
var _useState3 = useState(undefined),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
activeGroup = _useState3[0],
|
|
33
|
+
setActiveGroup = _useState3[1];
|
|
39
34
|
var _useState4 = useState(true),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
searchInputCanBeFocused = _useState4[0],
|
|
36
|
+
setSearchInputFocus = _useState4[1];
|
|
43
37
|
useEffect(function () {
|
|
44
38
|
var defaultIndex = groups == null ? void 0 : groups.findIndex(function (group) {
|
|
45
39
|
return group.defaultGroup || value && group.id === value.groupId;
|
|
@@ -57,14 +51,13 @@ var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
|
57
51
|
var renderedItems = [];
|
|
58
52
|
Object.keys(groupedItems).forEach(function (key) {
|
|
59
53
|
if (key !== NO_GROUP_NAME) {
|
|
60
|
-
renderedItems.push(
|
|
54
|
+
renderedItems.push(/*#__PURE__*/React.createElement(OperatorsDropdownGroupName, {
|
|
61
55
|
"data-testid": "operator-group-title",
|
|
62
56
|
name: key
|
|
63
57
|
}));
|
|
64
58
|
}
|
|
65
|
-
|
|
66
59
|
groupedItems[key].forEach(function (item) {
|
|
67
|
-
return renderedItems.push(
|
|
60
|
+
return renderedItems.push(/*#__PURE__*/React.createElement(OperatorsDropdownItem, {
|
|
68
61
|
className: classNames,
|
|
69
62
|
key: uuid(),
|
|
70
63
|
item: item,
|
|
@@ -108,12 +101,9 @@ var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
|
108
101
|
if (searchQuery) {
|
|
109
102
|
return filteredItems;
|
|
110
103
|
}
|
|
111
|
-
|
|
112
104
|
var hasSubgroups = Boolean(currentTabItems == null ? void 0 : currentTabItems.subGroups);
|
|
113
|
-
|
|
114
105
|
if (hasSubgroups && !activeGroup) {
|
|
115
106
|
var _currentTabItems$subG;
|
|
116
|
-
|
|
117
107
|
return currentTabItems == null || (_currentTabItems$subG = currentTabItems.subGroups) == null ? void 0 : _currentTabItems$subG.map(function (subGroup) {
|
|
118
108
|
return /*#__PURE__*/React.createElement(OperatorsDropdownItem, {
|
|
119
109
|
className: classNames,
|
|
@@ -124,16 +114,13 @@ var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
|
124
114
|
});
|
|
125
115
|
});
|
|
126
116
|
}
|
|
127
|
-
|
|
128
117
|
if (activeGroup != null && activeGroup.id) {
|
|
129
118
|
return renderGroupedItems(items == null ? void 0 : items.filter(function (item) {
|
|
130
119
|
return item.groupId === activeGroup.id;
|
|
131
120
|
}));
|
|
132
121
|
}
|
|
133
|
-
|
|
134
122
|
return renderGroupedItems(items == null ? void 0 : items.filter(function (item) {
|
|
135
123
|
var _groups$activeTab;
|
|
136
|
-
|
|
137
124
|
return item.groupId === ((_groups$activeTab = groups[activeTab]) == null ? void 0 : _groups$activeTab.id);
|
|
138
125
|
}));
|
|
139
126
|
}, [currentTabItems, items, groups, searchQuery, activeTab, filteredItems, activeGroup, renderGroupedItems, classNames]);
|
|
@@ -160,8 +147,8 @@ var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
|
160
147
|
},
|
|
161
148
|
ref: overlayRef,
|
|
162
149
|
onKeyDown: function onKeyDown(e) {
|
|
163
|
-
setSearchInputFocus(false);
|
|
164
|
-
|
|
150
|
+
setSearchInputFocus(false);
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
165
152
|
searchQuery && focusWithArrowKeys(e, classNames.split(' ')[1], function () {
|
|
166
153
|
setSearchInputFocus(true);
|
|
167
154
|
});
|
|
@@ -201,5 +188,4 @@ var OperatorsDropdown = function OperatorsDropdown(_ref) {
|
|
|
201
188
|
description: texts.noResults
|
|
202
189
|
}))));
|
|
203
190
|
};
|
|
204
|
-
|
|
205
191
|
export default OperatorsDropdown;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import * as S from '../Operators.style';
|
|
3
|
-
|
|
4
3
|
var OperatorsDropdownGroupName = function OperatorsDropdownGroupName(_ref) {
|
|
5
4
|
var name = _ref.name;
|
|
6
5
|
return /*#__PURE__*/React.createElement(S.Title, {
|
|
7
6
|
"data-testid": "operator-group-title"
|
|
8
7
|
}, name);
|
|
9
8
|
};
|
|
10
|
-
|
|
11
9
|
export default OperatorsDropdownGroupName;
|
|
@@ -2,15 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import Icon, { CheckS } from '@synerise/ds-icon';
|
|
3
3
|
import ListItem from '@synerise/ds-list-item';
|
|
4
4
|
import { theme } from '@synerise/ds-core';
|
|
5
|
-
|
|
6
5
|
var OperatorsDropdownItem = function OperatorsDropdownItem(_ref) {
|
|
7
6
|
var item = _ref.item,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
clearSearch = _ref.clearSearch,
|
|
8
|
+
searchQuery = _ref.searchQuery,
|
|
9
|
+
hideDropdown = _ref.hideDropdown,
|
|
10
|
+
select = _ref.select,
|
|
11
|
+
selected = _ref.selected,
|
|
12
|
+
className = _ref.className;
|
|
14
13
|
return /*#__PURE__*/React.createElement(ListItem, {
|
|
15
14
|
className: className,
|
|
16
15
|
key: item.name + item.id,
|
|
@@ -29,5 +28,4 @@ var OperatorsDropdownItem = function OperatorsDropdownItem(_ref) {
|
|
|
29
28
|
}
|
|
30
29
|
}, item.name);
|
|
31
30
|
};
|
|
32
|
-
|
|
33
31
|
export default OperatorsDropdownItem;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-operators",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
4
|
"description": "Operators UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
],
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@synerise/ds-button": "^0.21.
|
|
38
|
-
"@synerise/ds-dropdown": "^0.18.
|
|
39
|
-
"@synerise/ds-icon": "^0.67.
|
|
40
|
-
"@synerise/ds-list-item": "^0.
|
|
41
|
-
"@synerise/ds-result": "^0.7.
|
|
42
|
-
"@synerise/ds-scrollbar": "^0.11.
|
|
43
|
-
"@synerise/ds-tabs": "^0.17.
|
|
44
|
-
"@synerise/ds-tooltip": "^0.14.
|
|
37
|
+
"@synerise/ds-button": "^0.21.20",
|
|
38
|
+
"@synerise/ds-dropdown": "^0.18.25",
|
|
39
|
+
"@synerise/ds-icon": "^0.67.1",
|
|
40
|
+
"@synerise/ds-list-item": "^0.5.0",
|
|
41
|
+
"@synerise/ds-result": "^0.7.15",
|
|
42
|
+
"@synerise/ds-scrollbar": "^0.11.20",
|
|
43
|
+
"@synerise/ds-tabs": "^0.17.8",
|
|
44
|
+
"@synerise/ds-tooltip": "^0.14.50",
|
|
45
45
|
"@synerise/ds-utils": "^0.31.2",
|
|
46
46
|
"uuid": "^8.3.2"
|
|
47
47
|
},
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
52
52
|
"styled-components": "5.0.1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "4a56ee7ef816c22341ce704154dc7aa65b7d1dcc"
|
|
55
55
|
}
|