@synerise/ds-collector 0.3.23 → 0.4.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/dist/Collector.js +42 -60
- package/dist/Collector.styles.js +2 -2
- package/dist/Collector.types.js +1 -0
- package/dist/Elements/ButtonPanel/ButtonPanel.js +3 -3
- package/dist/Elements/ButtonPanel/ButtonPanel.types.js +1 -0
- package/dist/Elements/NavigationHint/NavigationHint.js +6 -7
- package/dist/Elements/NavigationHint/NavigationHint.types.js +1 -0
- package/dist/Elements/OptionsDropdown/OptionsDropdown.js +14 -28
- package/dist/Elements/OptionsDropdown/OptionsDropdown.types.js +1 -0
- package/dist/Elements/Values/Values.js +3 -3
- package/dist/Elements/Values/Values.types.js +1 -0
- package/dist/utils.js +14 -8
- package/package.json +5 -5
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.4.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.4.2...@synerise/ds-collector@0.4.3) (2021-11-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-collector
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.4.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.4.1...@synerise/ds-collector@0.4.2) (2021-11-16)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @synerise/ds-collector
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [0.4.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.3.23...@synerise/ds-collector@0.4.1) (2021-11-09)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @synerise/ds-collector
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [0.4.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.3.23...@synerise/ds-collector@0.4.0) (2021-11-09)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @synerise/ds-collector
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [0.3.23](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.3.22...@synerise/ds-collector@0.3.23) (2021-11-05)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @synerise/ds-collector
|
package/dist/Collector.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
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; }
|
|
2
|
-
|
|
3
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
-
|
|
5
|
-
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."); }
|
|
6
|
-
|
|
7
|
-
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); }
|
|
8
|
-
|
|
9
|
-
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; }
|
|
10
|
-
|
|
11
|
-
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; }
|
|
12
|
-
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
|
|
15
1
|
import * as React from 'react';
|
|
16
2
|
import classNames from 'classnames';
|
|
17
3
|
import { focusWithArrowKeys, useOnClickOutside } from '@synerise/ds-utils';
|
|
@@ -24,6 +10,8 @@ var DROPDOWN_PADDING = 2 * 8;
|
|
|
24
10
|
var COLLECTOR_CLASSNAME = 'ds-collector';
|
|
25
11
|
|
|
26
12
|
var Collector = function Collector(_ref) {
|
|
13
|
+
var _classNames;
|
|
14
|
+
|
|
27
15
|
var allowCustomValue = _ref.allowCustomValue,
|
|
28
16
|
allowMultipleValues = _ref.allowMultipleValues,
|
|
29
17
|
addButtonProps = _ref.addButtonProps,
|
|
@@ -59,46 +47,40 @@ var Collector = function Collector(_ref) {
|
|
|
59
47
|
var mainContentRef = React.useRef(null);
|
|
60
48
|
|
|
61
49
|
var _React$useState = React.useState(false),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
setFocused = _React$useState2[1];
|
|
50
|
+
isFocused = _React$useState[0],
|
|
51
|
+
setFocused = _React$useState[1];
|
|
65
52
|
|
|
66
|
-
var _React$
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
setShowGradient = _React$useState4[1];
|
|
53
|
+
var _React$useState2 = React.useState(false),
|
|
54
|
+
showGradient = _React$useState2[0],
|
|
55
|
+
setShowGradient = _React$useState2[1];
|
|
70
56
|
|
|
71
|
-
var _React$
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
setScrollLeft = _React$useState6[1];
|
|
57
|
+
var _React$useState3 = React.useState(0),
|
|
58
|
+
scrollLeft = _React$useState3[0],
|
|
59
|
+
setScrollLeft = _React$useState3[1];
|
|
75
60
|
|
|
76
|
-
var _React$
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
setValue = _React$useState8[1];
|
|
61
|
+
var _React$useState4 = React.useState(searchValue || ''),
|
|
62
|
+
value = _React$useState4[0],
|
|
63
|
+
setValue = _React$useState4[1];
|
|
80
64
|
|
|
81
|
-
var _React$
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
setSelectedValues = _React$useState10[1];
|
|
65
|
+
var _React$useState5 = React.useState(selected && allowMultipleValues ? selected : []),
|
|
66
|
+
selectedValues = _React$useState5[0],
|
|
67
|
+
setSelectedValues = _React$useState5[1];
|
|
85
68
|
|
|
86
|
-
var _React$
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
setFilteredSuggestions = _React$useState12[1];
|
|
69
|
+
var _React$useState6 = React.useState(suggestions || []),
|
|
70
|
+
filteredSuggestions = _React$useState6[0],
|
|
71
|
+
setFilteredSuggestions = _React$useState6[1];
|
|
90
72
|
|
|
91
73
|
var filterLookupKey = React.useMemo(function () {
|
|
92
|
-
return (lookupConfig
|
|
74
|
+
return (lookupConfig == null ? void 0 : lookupConfig.filter) || 'text';
|
|
93
75
|
}, [lookupConfig]);
|
|
94
76
|
var displayLookupKey = React.useMemo(function () {
|
|
95
|
-
return (lookupConfig
|
|
77
|
+
return (lookupConfig == null ? void 0 : lookupConfig.display) || 'text';
|
|
96
78
|
}, [lookupConfig]);
|
|
97
79
|
var onFocusCallback = React.useCallback(function (e) {
|
|
98
80
|
e.preventDefault();
|
|
99
81
|
|
|
100
82
|
if (!e.target.classList.contains(COLLECTOR_CLASSNAME)) {
|
|
101
|
-
if (!!inputRef && !!(inputRef
|
|
83
|
+
if (!!inputRef && !!(inputRef != null && inputRef.current)) {
|
|
102
84
|
inputRef.current.focus({
|
|
103
85
|
preventScroll: true
|
|
104
86
|
});
|
|
@@ -135,7 +117,7 @@ var Collector = function Collector(_ref) {
|
|
|
135
117
|
setSelectedValues([]);
|
|
136
118
|
setValue('');
|
|
137
119
|
setFocused(false);
|
|
138
|
-
(inputRef
|
|
120
|
+
(inputRef == null ? void 0 : inputRef.current) && inputRef.current.blur();
|
|
139
121
|
}, []);
|
|
140
122
|
|
|
141
123
|
var handleKeyDown = function handleKeyDown(e) {
|
|
@@ -163,7 +145,7 @@ var Collector = function Collector(_ref) {
|
|
|
163
145
|
}
|
|
164
146
|
}
|
|
165
147
|
|
|
166
|
-
if (allowMultipleValues && e.key === 'Backspace' && !value && !!(selectedValues
|
|
148
|
+
if (allowMultipleValues && e.key === 'Backspace' && !value && !!(selectedValues != null && selectedValues.length)) {
|
|
167
149
|
var lastElement = selected.pop();
|
|
168
150
|
|
|
169
151
|
if (lastElement && onItemDeselect) {
|
|
@@ -186,7 +168,7 @@ var Collector = function Collector(_ref) {
|
|
|
186
168
|
var suggestionsIncludesCurrentValue = filteredSuggestions.some(function (suggestion) {
|
|
187
169
|
var _suggestion$filterLoo, _suggestion$filterLoo2;
|
|
188
170
|
|
|
189
|
-
return ((_suggestion$filterLoo = suggestion[filterLookupKey])
|
|
171
|
+
return ((_suggestion$filterLoo = suggestion[filterLookupKey]) == null ? void 0 : (_suggestion$filterLoo2 = _suggestion$filterLoo.trim()) == null ? void 0 : _suggestion$filterLoo2.toLowerCase()) === value.trim().toLowerCase();
|
|
190
172
|
});
|
|
191
173
|
|
|
192
174
|
if (allowCustomValue || suggestionsIncludesCurrentValue) {
|
|
@@ -198,10 +180,10 @@ var Collector = function Collector(_ref) {
|
|
|
198
180
|
var getContainerWidth = React.useCallback(function () {
|
|
199
181
|
var _containerRef$current;
|
|
200
182
|
|
|
201
|
-
return Number((_containerRef$current = containerRef.current)
|
|
183
|
+
return Number((_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.offsetWidth) - DROPDOWN_PADDING;
|
|
202
184
|
}, [containerRef]);
|
|
203
185
|
var handleDropdownClick = React.useCallback(function () {
|
|
204
|
-
if (inputRef
|
|
186
|
+
if (inputRef != null && inputRef.current) {
|
|
205
187
|
inputRef.current.focus({
|
|
206
188
|
preventScroll: true
|
|
207
189
|
});
|
|
@@ -211,24 +193,24 @@ var Collector = function Collector(_ref) {
|
|
|
211
193
|
setFocused(false);
|
|
212
194
|
});
|
|
213
195
|
var showError = error || !!errorText;
|
|
214
|
-
return React.createElement(S.Container, {
|
|
196
|
+
return /*#__PURE__*/React.createElement(S.Container, {
|
|
215
197
|
ref: containerRef,
|
|
216
198
|
onKeyDown: function onKeyDown(e) {
|
|
217
199
|
focusWithArrowKeys(e, 'ds-search-item', function () {
|
|
218
|
-
(inputRef
|
|
200
|
+
(inputRef == null ? void 0 : inputRef.current) && inputRef.current.focus({
|
|
219
201
|
preventScroll: true
|
|
220
202
|
});
|
|
221
203
|
});
|
|
222
204
|
!value && scrollWithHorizontalArrow(mainContentRef, e);
|
|
223
205
|
}
|
|
224
|
-
}, label && React.createElement(S.ContentAbove, null, React.createElement(S.Label, null, label)), React.createElement(S.CollectorInput, {
|
|
225
|
-
className: classNames(COLLECTOR_CLASSNAME,
|
|
206
|
+
}, label && /*#__PURE__*/React.createElement(S.ContentAbove, null, /*#__PURE__*/React.createElement(S.Label, null, label)), /*#__PURE__*/React.createElement(S.CollectorInput, {
|
|
207
|
+
className: classNames(COLLECTOR_CLASSNAME, (_classNames = {}, _classNames[className] = !!className, _classNames)),
|
|
226
208
|
tabIndex: 0,
|
|
227
209
|
focus: isFocused,
|
|
228
210
|
onFocus: onFocusCallback,
|
|
229
211
|
error: showError,
|
|
230
212
|
disabled: disabled
|
|
231
|
-
}, React.createElement(S.MainContent, {
|
|
213
|
+
}, /*#__PURE__*/React.createElement(S.MainContent, {
|
|
232
214
|
wrap: !fixedHeight,
|
|
233
215
|
onScroll: function onScroll(_ref2) {
|
|
234
216
|
var currentTarget = _ref2.currentTarget;
|
|
@@ -237,17 +219,17 @@ var Collector = function Collector(_ref) {
|
|
|
237
219
|
setScrollLeft(currentTarget.scrollLeft);
|
|
238
220
|
}
|
|
239
221
|
},
|
|
240
|
-
hasValues: !!(selectedValues
|
|
222
|
+
hasValues: !!(selectedValues != null && selectedValues.length),
|
|
241
223
|
ref: mainContentRef,
|
|
242
224
|
gradientOverlap: showGradient && scrollLeft > 0,
|
|
243
225
|
focus: isFocused
|
|
244
|
-
}, React.createElement(Values, {
|
|
226
|
+
}, /*#__PURE__*/React.createElement(Values, {
|
|
245
227
|
values: selectedValues,
|
|
246
228
|
onDeselect: onItemDeselect,
|
|
247
229
|
focused: isFocused,
|
|
248
230
|
disabled: !!disabled,
|
|
249
231
|
displayLookupKey: displayLookupKey
|
|
250
|
-
}), React.createElement(S.Input, {
|
|
232
|
+
}), /*#__PURE__*/React.createElement(S.Input, {
|
|
251
233
|
onKeyDown: handleKeyDown,
|
|
252
234
|
ref: inputRef,
|
|
253
235
|
value: value,
|
|
@@ -259,20 +241,20 @@ var Collector = function Collector(_ref) {
|
|
|
259
241
|
disabled: disabled,
|
|
260
242
|
transparent: !!disableSearch,
|
|
261
243
|
hidden: !!disableSearch && !!selectedValues.length,
|
|
262
|
-
placeholder: selectedValues && selectedValues.length ? undefined : texts
|
|
263
|
-
hasValues: !!(selectedValues
|
|
264
|
-
})), !disableButtonPanel && React.createElement(S.RightSide, {
|
|
244
|
+
placeholder: selectedValues && selectedValues.length ? undefined : texts == null ? void 0 : texts.placeholder,
|
|
245
|
+
hasValues: !!(selectedValues != null && selectedValues.length)
|
|
246
|
+
})), !disableButtonPanel && /*#__PURE__*/React.createElement(S.RightSide, {
|
|
265
247
|
gradientOverlap: showGradient && !value,
|
|
266
248
|
focus: isFocused
|
|
267
|
-
}, React.createElement(ButtonPanel, {
|
|
249
|
+
}, /*#__PURE__*/React.createElement(ButtonPanel, {
|
|
268
250
|
onCancel: onCancelCallback,
|
|
269
251
|
onConfirm: onConfirmCallback,
|
|
270
252
|
disabled: !!disabled,
|
|
271
|
-
showCancel: !!value || !!(selectedValues
|
|
253
|
+
showCancel: !!value || !!(selectedValues != null && selectedValues.length),
|
|
272
254
|
texts: texts,
|
|
273
255
|
addButtonProps: addButtonProps,
|
|
274
256
|
cancelButtonProps: cancelButtonProps
|
|
275
|
-
}))), React.createElement(OptionsDropdown, {
|
|
257
|
+
}))), /*#__PURE__*/React.createElement(OptionsDropdown, {
|
|
276
258
|
options: filteredSuggestions,
|
|
277
259
|
onItemAdd: onItemAdd,
|
|
278
260
|
lookupKey: displayLookupKey,
|
|
@@ -290,7 +272,7 @@ var Collector = function Collector(_ref) {
|
|
|
290
272
|
width: getContainerWidth(),
|
|
291
273
|
customContent: dropdownContent,
|
|
292
274
|
texts: texts
|
|
293
|
-
}), (showError || description) && React.createElement(S.ContentBelow, null, showError && React.createElement(S.ErrorText, null, errorText), description && React.createElement(S.Description, null, description)));
|
|
275
|
+
}), (showError || description) && /*#__PURE__*/React.createElement(S.ContentBelow, null, showError && /*#__PURE__*/React.createElement(S.ErrorText, null, errorText), description && /*#__PURE__*/React.createElement(S.Description, null, description)));
|
|
294
276
|
};
|
|
295
277
|
|
|
296
278
|
export default Collector;
|
package/dist/Collector.styles.js
CHANGED
|
@@ -27,7 +27,7 @@ export var MainContent = styled.div.withConfig({
|
|
|
27
27
|
}, function (props) {
|
|
28
28
|
return props.gradientOverlap ? "1" : '0';
|
|
29
29
|
}, gradientOverlayStyles(), function (props) {
|
|
30
|
-
return "-webkit-linear-gradient( left,\n "
|
|
30
|
+
return "-webkit-linear-gradient( left,\n " + (props.focus ? props.theme.palette['blue-050'] : props.theme.palette.white) + " 0%,\n rgba(255,255,255,0) 100%\n )";
|
|
31
31
|
});
|
|
32
32
|
export var RightSide = styled.div.withConfig({
|
|
33
33
|
displayName: "Collectorstyles__RightSide",
|
|
@@ -35,7 +35,7 @@ export var RightSide = styled.div.withConfig({
|
|
|
35
35
|
})(["display:flex;margin:0 4px;position:relative;.ds-button:not(:last-child){margin-right:8px;}&::before{content:", ";", " background-image:", ";position:absolute;left:-102px;}"], function (props) {
|
|
36
36
|
return props.gradientOverlap ? "''" : 'none';
|
|
37
37
|
}, gradientOverlayStyles(), function (props) {
|
|
38
|
-
return "-webkit-linear-gradient( right,\n "
|
|
38
|
+
return "-webkit-linear-gradient( right,\n " + (props.focus ? props.theme.palette['blue-050'] : props.theme.palette.white) + " 0%,\n rgba(255,255,255,0) 100%\n )";
|
|
39
39
|
});
|
|
40
40
|
export var Input = styled(BorderLessInput).withConfig({
|
|
41
41
|
displayName: "Collectorstyles__Input",
|
package/dist/Collector.types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -11,21 +11,21 @@ var ButtonPanel = function ButtonPanel(_ref) {
|
|
|
11
11
|
texts = _ref.texts,
|
|
12
12
|
addButtonProps = _ref.addButtonProps,
|
|
13
13
|
cancelButtonProps = _ref.cancelButtonProps;
|
|
14
|
-
return React.createElement(React.Fragment, null, showCancel && React.createElement(Button, _extends({
|
|
14
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, showCancel && /*#__PURE__*/React.createElement(Button, _extends({
|
|
15
15
|
type: "ghost",
|
|
16
16
|
disabled: disabled,
|
|
17
17
|
onClick: onCancel,
|
|
18
18
|
onFocus: function onFocus(e) {
|
|
19
19
|
return e.stopPropagation();
|
|
20
20
|
}
|
|
21
|
-
}, cancelButtonProps), texts
|
|
21
|
+
}, cancelButtonProps), texts == null ? void 0 : texts.cancel), /*#__PURE__*/React.createElement(Button, _extends({
|
|
22
22
|
type: "primary",
|
|
23
23
|
disabled: disabled,
|
|
24
24
|
onClick: onConfirm,
|
|
25
25
|
onFocus: function onFocus(e) {
|
|
26
26
|
return e.stopPropagation();
|
|
27
27
|
}
|
|
28
|
-
}, addButtonProps), texts
|
|
28
|
+
}, addButtonProps), texts == null ? void 0 : texts.add));
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export default ButtonPanel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import Icon from '@synerise/ds-icon';
|
|
3
|
-
import { KeyboardEnterM, KeyboardKeysM } from '@synerise/ds-icon/dist/icons';
|
|
2
|
+
import Icon, { KeyboardEnterM, KeyboardKeysM } from '@synerise/ds-icon';
|
|
4
3
|
import * as S from '../../Collector.styles';
|
|
5
4
|
|
|
6
5
|
var NavigationHint = function NavigationHint(_ref) {
|
|
7
6
|
var texts = _ref.texts;
|
|
8
|
-
return React.createElement(S.NavigationWrapper, null, React.createElement(Icon, {
|
|
9
|
-
component: React.createElement(KeyboardKeysM, null)
|
|
10
|
-
}), React.createElement("span", null, texts
|
|
11
|
-
component: React.createElement(KeyboardEnterM, null)
|
|
12
|
-
}), React.createElement("span", null, texts
|
|
7
|
+
return /*#__PURE__*/React.createElement(S.NavigationWrapper, null, /*#__PURE__*/React.createElement(Icon, {
|
|
8
|
+
component: /*#__PURE__*/React.createElement(KeyboardKeysM, null)
|
|
9
|
+
}), /*#__PURE__*/React.createElement("span", null, texts == null ? void 0 : texts.toNavigate), /*#__PURE__*/React.createElement(Icon, {
|
|
10
|
+
component: /*#__PURE__*/React.createElement(KeyboardEnterM, null)
|
|
11
|
+
}), /*#__PURE__*/React.createElement("span", null, texts == null ? void 0 : texts.toSelect));
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
export default NavigationHint;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,21 +1,8 @@
|
|
|
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 Scrollbar from '@synerise/ds-scrollbar';
|
|
15
3
|
import SearchItems from '@synerise/ds-search/dist/Elements/SearchItems/SearchItems';
|
|
16
4
|
import Menu from '@synerise/ds-menu';
|
|
17
|
-
import { Add3M } from '@synerise/ds-icon
|
|
18
|
-
import Icon from '@synerise/ds-icon';
|
|
5
|
+
import Icon, { Add3M } from '@synerise/ds-icon';
|
|
19
6
|
import Divider from '@synerise/ds-divider';
|
|
20
7
|
import * as S from '../../Collector.styles';
|
|
21
8
|
import NavigationHint from '../NavigationHint/NavigationHint';
|
|
@@ -42,40 +29,39 @@ var OptionsDropdown = function OptionsDropdown(_ref) {
|
|
|
42
29
|
dropdownItemHeight = _ref.dropdownItemHeight;
|
|
43
30
|
|
|
44
31
|
var _React$useState = React.useState(0),
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
setScrollTop = _React$useState2[1];
|
|
32
|
+
scrollTop = _React$useState[0],
|
|
33
|
+
setScrollTop = _React$useState[1];
|
|
48
34
|
|
|
49
35
|
React.useEffect(function () {
|
|
50
36
|
setScrollTop(0);
|
|
51
37
|
}, [visible]);
|
|
52
38
|
var renderItemFn = React.useCallback(function (itemValue) {
|
|
53
|
-
return renderItem ? renderItem(itemValue) : React.createElement(Menu.Item, {
|
|
39
|
+
return renderItem ? renderItem(itemValue) : /*#__PURE__*/React.createElement(Menu.Item, {
|
|
54
40
|
tabIndex: -1,
|
|
55
41
|
size: dropdownItemHeight,
|
|
56
|
-
key: ""
|
|
42
|
+
key: "" + itemValue
|
|
57
43
|
}, itemValue[lookupKey]);
|
|
58
44
|
}, [lookupKey, renderItem, dropdownItemHeight]);
|
|
59
|
-
var shouldRenderList = !!(options
|
|
60
|
-
return React.createElement(S.DropdownWrapper, {
|
|
45
|
+
var shouldRenderList = !!(options != null && options.length);
|
|
46
|
+
return /*#__PURE__*/React.createElement(S.DropdownWrapper, {
|
|
61
47
|
onClick: onClick
|
|
62
|
-
}, visible && (customContent ? React.createElement(S.CustomContentWrapper, null, customContent) : React.createElement(S.DropdownContent, null, React.createElement(Scrollbar, {
|
|
48
|
+
}, visible && (customContent ? /*#__PURE__*/React.createElement(S.CustomContentWrapper, null, customContent) : /*#__PURE__*/React.createElement(S.DropdownContent, null, /*#__PURE__*/React.createElement(Scrollbar, {
|
|
63
49
|
absolute: true,
|
|
64
50
|
onScroll: function onScroll(_ref2) {
|
|
65
51
|
var currentTarget = _ref2.currentTarget;
|
|
66
52
|
setScrollTop(currentTarget.scrollTop);
|
|
67
53
|
}
|
|
68
|
-
}, showAddButton && onItemAdd && !!value && React.createElement(S.DropdownTop, null, React.createElement(S.DropdownAddButton, {
|
|
54
|
+
}, showAddButton && onItemAdd && !!value && /*#__PURE__*/React.createElement(S.DropdownTop, null, /*#__PURE__*/React.createElement(S.DropdownAddButton, {
|
|
69
55
|
onClick: function onClick() {
|
|
70
56
|
onItemAdd && onItemAdd(value);
|
|
71
57
|
},
|
|
72
58
|
type: "ghost",
|
|
73
59
|
mode: "icon-label"
|
|
74
|
-
}, React.createElement(Icon, {
|
|
75
|
-
component: React.createElement(Add3M, null)
|
|
76
|
-
}), React.createElement("span", null, texts
|
|
60
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
61
|
+
component: /*#__PURE__*/React.createElement(Add3M, null)
|
|
62
|
+
}), /*#__PURE__*/React.createElement("span", null, texts == null ? void 0 : texts.add), /*#__PURE__*/React.createElement("strong", null, value)), shouldRenderList && /*#__PURE__*/React.createElement(S.DividerContainer, null, /*#__PURE__*/React.createElement(Divider, {
|
|
77
63
|
dashed: true
|
|
78
|
-
}))), shouldRenderList && React.createElement(SearchItems, {
|
|
64
|
+
}))), shouldRenderList && /*#__PURE__*/React.createElement(SearchItems, {
|
|
79
65
|
data: options,
|
|
80
66
|
highlight: value,
|
|
81
67
|
visibleRows: 6,
|
|
@@ -86,7 +72,7 @@ var OptionsDropdown = function OptionsDropdown(_ref) {
|
|
|
86
72
|
listProps: {
|
|
87
73
|
scrollTop: scrollTop
|
|
88
74
|
}
|
|
89
|
-
})), showNavigationHints && React.createElement(NavigationHint, {
|
|
75
|
+
})), showNavigationHints && /*#__PURE__*/React.createElement(NavigationHint, {
|
|
90
76
|
texts: texts
|
|
91
77
|
}))));
|
|
92
78
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,10 +7,10 @@ var Values = function Values(_ref) {
|
|
|
7
7
|
disabled = _ref.disabled,
|
|
8
8
|
focused = _ref.focused,
|
|
9
9
|
displayLookupKey = _ref.displayLookupKey;
|
|
10
|
-
return React.createElement(React.Fragment, null, values.map(function (val, index) {
|
|
11
|
-
return React.createElement(S.CollectorValue, {
|
|
10
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, values.map(function (val, index) {
|
|
11
|
+
return /*#__PURE__*/React.createElement(S.CollectorValue, {
|
|
12
12
|
// eslint-disable-next-line react/no-array-index-key
|
|
13
|
-
key:
|
|
13
|
+
key: val + "-" + index,
|
|
14
14
|
onRemoveClick: function onRemoveClick() {
|
|
15
15
|
onDeselect && onDeselect(val);
|
|
16
16
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.js
CHANGED
|
@@ -5,25 +5,31 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
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
7
|
var INPUT_MIN_WIDTH = 150;
|
|
8
|
-
export var arrayToLowerCase = function arrayToLowerCase() {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export var arrayToLowerCase = function arrayToLowerCase(array, lookupKey) {
|
|
9
|
+
if (array === void 0) {
|
|
10
|
+
array = [];
|
|
11
|
+
}
|
|
12
|
+
|
|
11
13
|
return array.map(function (element) {
|
|
12
|
-
|
|
14
|
+
var _objectSpread2;
|
|
15
|
+
|
|
16
|
+
return _objectSpread({}, element, (_objectSpread2 = {}, _objectSpread2[lookupKey] = element[lookupKey] && element[lookupKey].toLowerCase(), _objectSpread2));
|
|
13
17
|
});
|
|
14
18
|
};
|
|
15
|
-
export var scrollWithHorizontalArrow = function scrollWithHorizontalArrow(ref, event) {
|
|
16
|
-
|
|
19
|
+
export var scrollWithHorizontalArrow = function scrollWithHorizontalArrow(ref, event, scrollStep) {
|
|
20
|
+
if (scrollStep === void 0) {
|
|
21
|
+
scrollStep = 200;
|
|
22
|
+
}
|
|
17
23
|
|
|
18
24
|
if (event.key === 'ArrowLeft') {
|
|
19
|
-
(ref
|
|
25
|
+
(ref == null ? void 0 : ref.current) && ref.current.scrollBy({
|
|
20
26
|
left: -scrollStep,
|
|
21
27
|
behavior: 'smooth'
|
|
22
28
|
});
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
if (event.key === 'ArrowRight') {
|
|
26
|
-
(ref
|
|
32
|
+
(ref == null ? void 0 : ref.current) && ref.current.scrollBy({
|
|
27
33
|
left: scrollStep,
|
|
28
34
|
behavior: 'smooth'
|
|
29
35
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-collector",
|
|
3
|
-
"version": "0.3
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Collector UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
],
|
|
33
33
|
"types": "dist/index.d.ts",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@synerise/ds-button": "^0.
|
|
36
|
-
"@synerise/ds-input": "^0.
|
|
37
|
-
"@synerise/ds-search": "^0.
|
|
35
|
+
"@synerise/ds-button": "^0.16.2",
|
|
36
|
+
"@synerise/ds-input": "^0.18.2",
|
|
37
|
+
"@synerise/ds-search": "^0.6.3",
|
|
38
38
|
"classnames": "^2.2.6"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@synerise/ds-core": "*",
|
|
42
42
|
"react": ">=16.9.0 < 17.0.0"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "2468359677783819939fb9f1ef5acc36667ecd1a"
|
|
45
45
|
}
|