@synerise/ds-collector 0.6.27 → 0.6.29
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 +19 -0
- package/dist/Collector.js +38 -36
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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.29](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.6.28...@synerise/ds-collector@0.6.29) (2023-10-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-collector
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.6.28](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.6.27...@synerise/ds-collector@0.6.28) (2023-10-19)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **collector:** added event capture for "add" ([ce1ec7f](https://github.com/Synerise/synerise-design/commit/ce1ec7f145133b820d5a03dbe0542d74a4b27119))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [0.6.27](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.6.26...@synerise/ds-collector@0.6.27) (2023-10-18)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @synerise/ds-collector
|
package/dist/Collector.js
CHANGED
|
@@ -95,6 +95,13 @@ var Collector = function Collector(_ref) {
|
|
|
95
95
|
var displayLookupKey = useMemo(function () {
|
|
96
96
|
return (lookupConfig == null ? void 0 : lookupConfig.display) || 'text';
|
|
97
97
|
}, [lookupConfig]);
|
|
98
|
+
var focusInput = useCallback(function () {
|
|
99
|
+
if (inputRef != null && inputRef.current) {
|
|
100
|
+
inputRef.current.focus({
|
|
101
|
+
preventScroll: true
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}, [inputRef]);
|
|
98
105
|
var suggestionsIncludesItem = useCallback(function (item) {
|
|
99
106
|
return filteredSuggestions.some(function (suggestion) {
|
|
100
107
|
var _suggestion$filterLoo, _suggestion$filterLoo2;
|
|
@@ -114,16 +121,12 @@ var Collector = function Collector(_ref) {
|
|
|
114
121
|
var onFocusCallback = useCallback(function (event) {
|
|
115
122
|
event.preventDefault();
|
|
116
123
|
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
preventScroll: true
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
+
if (event.target.classList.contains(COLLECTOR_CLASSNAME)) {
|
|
125
|
+
focusInput();
|
|
126
|
+
} else {
|
|
124
127
|
setFocused(true);
|
|
125
128
|
}
|
|
126
|
-
}, [
|
|
129
|
+
}, [focusInput]);
|
|
127
130
|
var filterSuggestions = useCallback(function (val) {
|
|
128
131
|
var filtered = filterValueSuggestions(suggestions, selectedValues, val, filterLookupKey);
|
|
129
132
|
setFilteredSuggestions(filtered);
|
|
@@ -147,14 +150,17 @@ var Collector = function Collector(_ref) {
|
|
|
147
150
|
if (!enableCustomFilteringSuggestions) {
|
|
148
151
|
setFilteredSuggestions([]);
|
|
149
152
|
}
|
|
150
|
-
|
|
151
|
-
!searchValue && allowMultipleValues && setValue(''); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
152
153
|
}, [allowMultipleValues, allowCustomValue, selected, enableCustomFilteringSuggestions]);
|
|
153
154
|
useEffect(function () {
|
|
155
|
+
if (!searchValue && allowMultipleValues) {
|
|
156
|
+
setValue('');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
154
160
|
if (searchValue !== undefined && searchValue !== null) {
|
|
155
161
|
setValue(searchValue);
|
|
156
162
|
}
|
|
157
|
-
}, [searchValue]);
|
|
163
|
+
}, [allowMultipleValues, searchValue]);
|
|
158
164
|
useEffect(function () {
|
|
159
165
|
if (fixedHeight) {
|
|
160
166
|
setShowGradient(isOverflown(mainContentRef));
|
|
@@ -195,11 +201,13 @@ var Collector = function Collector(_ref) {
|
|
|
195
201
|
var newValue = createItem(value);
|
|
196
202
|
|
|
197
203
|
if (!newValue) {
|
|
204
|
+
setValue('');
|
|
198
205
|
return;
|
|
199
206
|
}
|
|
200
207
|
|
|
201
208
|
if (allowMultipleValues) {
|
|
202
209
|
onItemSelect(newValue);
|
|
210
|
+
setValue('');
|
|
203
211
|
} else {
|
|
204
212
|
onConfirm && onConfirm([newValue]);
|
|
205
213
|
!keepSearchQueryOnSelect && clear();
|
|
@@ -258,19 +266,27 @@ var Collector = function Collector(_ref) {
|
|
|
258
266
|
return Number((_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.offsetWidth) - DROPDOWN_PADDING;
|
|
259
267
|
}, [containerRef]);
|
|
260
268
|
|
|
261
|
-
var
|
|
262
|
-
|
|
263
|
-
inputRef.current.focus({
|
|
264
|
-
preventScroll: true
|
|
265
|
-
});
|
|
266
|
-
}
|
|
269
|
+
var handleDropdownClick = function handleDropdownClick() {
|
|
270
|
+
focusInput();
|
|
267
271
|
};
|
|
268
272
|
|
|
269
|
-
var
|
|
273
|
+
var handleDropdownSelect = function handleDropdownSelect(item) {
|
|
274
|
+
onItemSelect && onItemSelect(item);
|
|
275
|
+
|
|
276
|
+
if (!allowMultipleValues && !keepSearchQueryOnSelect && item[filterLookupKey]) {
|
|
277
|
+
setValue(item[filterLookupKey]);
|
|
278
|
+
} else {
|
|
279
|
+
clear();
|
|
280
|
+
}
|
|
281
|
+
|
|
270
282
|
focusInput();
|
|
271
283
|
};
|
|
272
284
|
|
|
273
|
-
var
|
|
285
|
+
var handleInput = disableSearch ? undefined : function (event) {
|
|
286
|
+
if ('inputType' in event.nativeEvent && event.nativeEvent.inputType === 'insertFromPaste' && allowMultipleValues && allowPaste) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
274
290
|
onSearchValueChange && onSearchValueChange(event.target.value);
|
|
275
291
|
setValue(event.target.value);
|
|
276
292
|
if (!enableCustomFilteringSuggestions) filterSuggestions(event.target.value);
|
|
@@ -317,7 +333,7 @@ var Collector = function Collector(_ref) {
|
|
|
317
333
|
onKeyDown: handleKeyDown,
|
|
318
334
|
ref: inputRef,
|
|
319
335
|
value: value,
|
|
320
|
-
|
|
336
|
+
onInput: handleInput,
|
|
321
337
|
disabled: disabled,
|
|
322
338
|
transparent: !!disableSearch,
|
|
323
339
|
hidden: !!disableSearch && !!selectedValues.length,
|
|
@@ -331,11 +347,7 @@ var Collector = function Collector(_ref) {
|
|
|
331
347
|
return /*#__PURE__*/React.createElement(S.Container, {
|
|
332
348
|
ref: containerRef,
|
|
333
349
|
onKeyDown: function onKeyDown(event) {
|
|
334
|
-
focusWithArrowKeys(event, 'ds-search-item',
|
|
335
|
-
(inputRef == null ? void 0 : inputRef.current) && inputRef.current.focus({
|
|
336
|
-
preventScroll: true
|
|
337
|
-
});
|
|
338
|
-
});
|
|
350
|
+
focusWithArrowKeys(event, 'ds-search-item', focusInput);
|
|
339
351
|
!value && scrollWithHorizontalArrow(mainContentRef, event);
|
|
340
352
|
}
|
|
341
353
|
}, (label || showCount) && /*#__PURE__*/React.createElement(S.ContentAbove, null, label && /*#__PURE__*/React.createElement(S.Label, null, label), showCount && renderCountLabel()), /*#__PURE__*/React.createElement(S.CollectorInput, {
|
|
@@ -369,17 +381,7 @@ var Collector = function Collector(_ref) {
|
|
|
369
381
|
dropdownItemHeight: dropdownItemHeight,
|
|
370
382
|
value: value,
|
|
371
383
|
visible: isFocused && !disabled && (filteredSuggestions.length > 0 || !!value && allowMultipleValues && allowCustomValue),
|
|
372
|
-
onSelect:
|
|
373
|
-
onItemSelect && onItemSelect(item);
|
|
374
|
-
|
|
375
|
-
if (!keepSearchQueryOnSelect && item[filterLookupKey]) {
|
|
376
|
-
setValue(item[filterLookupKey]);
|
|
377
|
-
} else {
|
|
378
|
-
clear();
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
focusInput();
|
|
382
|
-
},
|
|
384
|
+
onSelect: handleDropdownSelect,
|
|
383
385
|
onClick: handleDropdownClick,
|
|
384
386
|
renderItem: renderItem,
|
|
385
387
|
showAddButton: allowCustomValue && allowMultipleValues,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-collector",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.29",
|
|
4
4
|
"description": "Collector UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
],
|
|
34
34
|
"types": "dist/index.d.ts",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@synerise/ds-button": "^0.18.
|
|
37
|
-
"@synerise/ds-divider": "^0.6.
|
|
38
|
-
"@synerise/ds-icon": "^0.58.
|
|
39
|
-
"@synerise/ds-input": "^0.19.
|
|
40
|
-
"@synerise/ds-menu": "^0.18.
|
|
41
|
-
"@synerise/ds-scrollbar": "^0.6.
|
|
42
|
-
"@synerise/ds-search": "^0.8.
|
|
43
|
-
"@synerise/ds-utils": "^0.24.
|
|
36
|
+
"@synerise/ds-button": "^0.18.7",
|
|
37
|
+
"@synerise/ds-divider": "^0.6.4",
|
|
38
|
+
"@synerise/ds-icon": "^0.58.7",
|
|
39
|
+
"@synerise/ds-input": "^0.19.7",
|
|
40
|
+
"@synerise/ds-menu": "^0.18.4",
|
|
41
|
+
"@synerise/ds-scrollbar": "^0.6.12",
|
|
42
|
+
"@synerise/ds-search": "^0.8.71",
|
|
43
|
+
"@synerise/ds-utils": "^0.24.21",
|
|
44
44
|
"classnames": "2.3.2",
|
|
45
45
|
"lodash": "^4.17.19"
|
|
46
46
|
},
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"@testing-library/jest-dom": "5.1.1",
|
|
55
55
|
"@testing-library/react": "^11"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "854aa713ea3fb1e9348fd351888da807f761a3f4"
|
|
58
58
|
}
|