@synerise/ds-collector 0.8.4 → 0.9.1
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/README.md +1 -0
- package/dist/Collector.d.ts +1 -1
- package/dist/Collector.js +9 -9
- package/dist/Collector.types.d.ts +1 -0
- package/package.json +3 -3
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.9.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.9.0...@synerise/ds-collector@0.9.1) (2024-04-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-collector
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.9.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.8.4...@synerise/ds-collector@0.9.0) (2024-04-22)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **collector:** improve custom filtering suggestions ([72956dd](https://github.com/Synerise/synerise-design/commit/72956dd85332649a338973e282ece6a77ae8ffdf))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [0.8.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.8.3...@synerise/ds-collector@0.8.4) (2024-04-15)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @synerise/ds-collector
|
package/README.md
CHANGED
|
@@ -73,6 +73,7 @@ import Collector from '@synerise/ds-collector'
|
|
|
73
73
|
| showCount | Display item counter above collector | boolean | - |
|
|
74
74
|
| valuesSeparator | Multi-value paste delimiter (separator) | CollectorValuesSeparator `;`, `/` or `,` | `;` |
|
|
75
75
|
| listHeader | Custom header displayed at the top of the dropdown list | React.ReactNode | - |
|
|
76
|
+
| hideDropdownOnClickOutside | Specify whether dropdown should be closed on click outside | boolean | `true` |
|
|
76
77
|
|
|
77
78
|
`CollectorValue = {[key:string]: any}`
|
|
78
79
|
|
package/dist/Collector.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CollectorProps } from './Collector.types';
|
|
3
3
|
declare const Collector: {
|
|
4
|
-
({ allowCustomValue, allowMultipleValues, addButtonProps, cancelButtonProps, keepSearchQueryOnSelect, error, className, description, enableCustomFilteringSuggestions, selected, suggestions, showNavigationHints, onConfirm, onCancel, label, errorText, disabled, fixedHeight, texts, lookupConfig, onItemAdd, onItemDeselect, onItemSelect, onMultipleItemsSelect, dropdownContent, disableButtonPanel, disableSearch, dropdownItemHeight, searchValue, renderItem, onSearchValueChange, allowPaste, showCount, listHeader, valuesSeparator, }: CollectorProps): JSX.Element;
|
|
4
|
+
({ allowCustomValue, allowMultipleValues, addButtonProps, cancelButtonProps, keepSearchQueryOnSelect, error, className, description, enableCustomFilteringSuggestions, selected, suggestions, showNavigationHints, onConfirm, onCancel, label, errorText, disabled, fixedHeight, texts, lookupConfig, onItemAdd, onItemDeselect, onItemSelect, onMultipleItemsSelect, dropdownContent, disableButtonPanel, disableSearch, dropdownItemHeight, searchValue, renderItem, onSearchValueChange, allowPaste, showCount, listHeader, hideDropdownOnClickOutside, valuesSeparator, }: CollectorProps): JSX.Element;
|
|
5
5
|
Container: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
6
|
ContentBelow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
7
|
Description: import("styled-components").StyledComponent<"div", any, {}, never>;
|
package/dist/Collector.js
CHANGED
|
@@ -55,6 +55,8 @@ var Collector = function Collector(_ref) {
|
|
|
55
55
|
allowPaste = _ref.allowPaste,
|
|
56
56
|
showCount = _ref.showCount,
|
|
57
57
|
listHeader = _ref.listHeader,
|
|
58
|
+
_ref$hideDropdownOnCl = _ref.hideDropdownOnClickOutside,
|
|
59
|
+
hideDropdownOnClickOutside = _ref$hideDropdownOnCl === void 0 ? true : _ref$hideDropdownOnCl,
|
|
58
60
|
_ref$valuesSeparator = _ref.valuesSeparator,
|
|
59
61
|
valuesSeparator = _ref$valuesSeparator === void 0 ? DEFAULT_VALUES_SEPARATOR : _ref$valuesSeparator;
|
|
60
62
|
var inputRef = useRef(null);
|
|
@@ -104,9 +106,9 @@ var Collector = function Collector(_ref) {
|
|
|
104
106
|
}, [inputRef]);
|
|
105
107
|
var suggestionsIncludesItem = useCallback(function (item) {
|
|
106
108
|
return filteredSuggestions.some(function (suggestion) {
|
|
107
|
-
var _suggestion$filterLoo
|
|
109
|
+
var _suggestion$filterLoo;
|
|
108
110
|
|
|
109
|
-
return ((_suggestion$filterLoo = suggestion[filterLookupKey]) == null
|
|
111
|
+
return ((_suggestion$filterLoo = suggestion[filterLookupKey]) == null || (_suggestion$filterLoo = _suggestion$filterLoo.trim()) == null ? void 0 : _suggestion$filterLoo.toLowerCase()) === item.trim().toLowerCase();
|
|
110
112
|
});
|
|
111
113
|
}, [filterLookupKey, filteredSuggestions]);
|
|
112
114
|
var createItem = useCallback(function (text) {
|
|
@@ -144,6 +146,9 @@ var Collector = function Collector(_ref) {
|
|
|
144
146
|
|
|
145
147
|
return false;
|
|
146
148
|
}, [createItem, value]);
|
|
149
|
+
useEffect(function () {
|
|
150
|
+
enableCustomFilteringSuggestions && setFilteredSuggestions(suggestions); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
151
|
+
}, [suggestions]);
|
|
147
152
|
useEffect(function () {
|
|
148
153
|
setSelectedValues(selected && allowMultipleValues ? selected : []);
|
|
149
154
|
|
|
@@ -251,18 +256,13 @@ var Collector = function Collector(_ref) {
|
|
|
251
256
|
}
|
|
252
257
|
|
|
253
258
|
var suggestionsIncludesCurrentValue = suggestionsIncludesItem(value);
|
|
254
|
-
filteredSuggestions.some(function (suggestion) {
|
|
255
|
-
var _suggestion$filterLoo3, _suggestion$filterLoo4;
|
|
256
|
-
|
|
257
|
-
return ((_suggestion$filterLoo3 = suggestion[filterLookupKey]) == null ? void 0 : (_suggestion$filterLoo4 = _suggestion$filterLoo3.trim()) == null ? void 0 : _suggestion$filterLoo4.toLowerCase()) === value.trim().toLowerCase();
|
|
258
|
-
});
|
|
259
259
|
|
|
260
260
|
if (allowCustomValue || suggestionsIncludesCurrentValue) {
|
|
261
261
|
var newValue = onItemAdd && onItemAdd(value);
|
|
262
262
|
newValue && onConfirm && onConfirm([newValue]);
|
|
263
263
|
clear();
|
|
264
264
|
}
|
|
265
|
-
}, [allowMultipleValues, suggestionsIncludesItem, value,
|
|
265
|
+
}, [allowMultipleValues, suggestionsIncludesItem, value, allowCustomValue, createItem, selectedValues, onConfirm, clear, onItemAdd]);
|
|
266
266
|
var getContainerWidth = useCallback(function () {
|
|
267
267
|
var _containerRef$current;
|
|
268
268
|
|
|
@@ -295,7 +295,7 @@ var Collector = function Collector(_ref) {
|
|
|
295
295
|
}
|
|
296
296
|
};
|
|
297
297
|
useOnClickOutside(containerRef, function () {
|
|
298
|
-
setFocused(false);
|
|
298
|
+
hideDropdownOnClickOutside && setFocused(false);
|
|
299
299
|
});
|
|
300
300
|
var showError = error || !!errorText;
|
|
301
301
|
|
|
@@ -38,6 +38,7 @@ export type CollectorProps = {
|
|
|
38
38
|
showCount?: boolean;
|
|
39
39
|
valuesSeparator?: CollectorValuesSeparator;
|
|
40
40
|
listHeader?: React.ReactNode;
|
|
41
|
+
hideDropdownOnClickOutside?: boolean;
|
|
41
42
|
};
|
|
42
43
|
export type CollectorValuesSeparator = ';' | ',' | '|';
|
|
43
44
|
export type CollectorTexts = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-collector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Collector UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@synerise/ds-list-item": "^0.0.19",
|
|
41
41
|
"@synerise/ds-menu": "^0.18.20",
|
|
42
42
|
"@synerise/ds-scrollbar": "^0.10.2",
|
|
43
|
-
"@synerise/ds-search": "^0.8.
|
|
43
|
+
"@synerise/ds-search": "^0.8.88",
|
|
44
44
|
"@synerise/ds-utils": "^0.26.3",
|
|
45
45
|
"classnames": "2.3.2"
|
|
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": "161a021c19407a11c92822eb2647907cdce5c516"
|
|
58
58
|
}
|