@synerise/ds-collector 0.6.30 → 0.6.32

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,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.32](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.6.31...@synerise/ds-collector@0.6.32) (2023-11-16)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-collector
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.6.31](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.6.30...@synerise/ds-collector@0.6.31) (2023-11-16)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **collector:** support pasting search string ([b614580](https://github.com/Synerise/synerise-design/commit/b61458017d4f61df3e993199e65a30808b1825c5))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.6.30](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@0.6.29...@synerise/ds-collector@0.6.30) (2023-11-09)
7
26
 
8
27
  **Note:** Version bump only for package @synerise/ds-collector
package/dist/Collector.js CHANGED
@@ -6,13 +6,12 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
 
7
7
  import React, { useEffect, useMemo, useCallback, useRef, useState } from 'react';
8
8
  import classNames from 'classnames';
9
- import { compact } from 'lodash';
10
9
  import { FormattedMessage } from 'react-intl';
11
10
  import { focusWithArrowKeys, useOnClickOutside } from '@synerise/ds-utils';
12
11
  import * as S from './Collector.styles';
13
12
  import ButtonPanel from './Elements/ButtonPanel/ButtonPanel';
14
13
  import OptionsDropdown from './Elements/OptionsDropdown/OptionsDropdown';
15
- import { filterValueSuggestions, isOverflown, scrollWithHorizontalArrow } from './utils';
14
+ import { filterOutNullishArrayItems, filterValueSuggestions, isOverflown, scrollWithHorizontalArrow } from './utils';
16
15
  import Values from './Elements/Values/Values';
17
16
  import NavigationHint from './Elements/NavigationHint/NavigationHint';
18
17
  var DROPDOWN_PADDING = 2 * 8;
@@ -184,11 +183,14 @@ var Collector = function Collector(_ref) {
184
183
  var handlePaste = function handlePaste(event) {
185
184
  if (allowMultipleValues && onItemAdd) {
186
185
  var pastedText = event.clipboardData.getData('text');
187
- var pastedItems = allowMultipleValues ? pastedText.split(valuesSeparator) : [pastedText];
188
- var newValues = compact(pastedItems.map(createItem));
189
186
 
190
- if (newValues.length) {
191
- onMultipleItemsSelect && onMultipleItemsSelect(newValues);
187
+ if (pastedText.includes(valuesSeparator)) {
188
+ var pastedItems = allowMultipleValues ? pastedText.split(valuesSeparator) : [pastedText];
189
+ var newValues = filterOutNullishArrayItems(pastedItems.map(createItem));
190
+
191
+ if (newValues.length) {
192
+ onMultipleItemsSelect && onMultipleItemsSelect(newValues);
193
+ }
192
194
  }
193
195
  }
194
196
  };
@@ -283,13 +285,13 @@ var Collector = function Collector(_ref) {
283
285
  };
284
286
 
285
287
  var handleInput = disableSearch ? undefined : function (event) {
286
- if ('inputType' in event.nativeEvent && event.nativeEvent.inputType === 'insertFromPaste' && allowMultipleValues && allowPaste) {
287
- return;
288
- }
288
+ var isPasteEvent = 'inputType' in event.nativeEvent && event.nativeEvent.inputType === 'insertFromPaste' && allowMultipleValues && allowPaste && event.target.value.includes(valuesSeparator);
289
289
 
290
- onSearchValueChange && onSearchValueChange(event.target.value);
291
- setValue(event.target.value);
292
- if (!enableCustomFilteringSuggestions) filterSuggestions(event.target.value);
290
+ if (!isPasteEvent) {
291
+ onSearchValueChange && onSearchValueChange(event.target.value);
292
+ setValue(event.target.value);
293
+ if (!enableCustomFilteringSuggestions) filterSuggestions(event.target.value);
294
+ }
293
295
  };
294
296
  useOnClickOutside(containerRef, function () {
295
297
  setFocused(false);
@@ -327,7 +329,7 @@ var Collector = function Collector(_ref) {
327
329
  focused: isFocused,
328
330
  disabled: !!disabled,
329
331
  displayLookupKey: displayLookupKey
330
- }), /*#__PURE__*/React.createElement(S.Input, {
332
+ }), /*#__PURE__*/React.createElement(S.SearchWrapper, null, /*#__PURE__*/React.createElement(S.Input, {
331
333
  onPaste: handlePaste,
332
334
  onKeyPress: handleKeyPress,
333
335
  onKeyDown: handleKeyDown,
@@ -339,7 +341,7 @@ var Collector = function Collector(_ref) {
339
341
  hidden: !!disableSearch && !!selectedValues.length,
340
342
  placeholder: selectedValues && selectedValues.length ? undefined : texts == null ? void 0 : texts.placeholder,
341
343
  hasValues: !!(selectedValues != null && selectedValues.length)
342
- }));
344
+ })));
343
345
  var innerContent = fixedHeight ? valuesContainer : /*#__PURE__*/React.createElement(S.Scrollbar, {
344
346
  absolute: true,
345
347
  maxHeight: 160
@@ -31,6 +31,7 @@ export declare const Input: import("styled-components").StyledComponent<"input",
31
31
  transparent: boolean;
32
32
  hidden: boolean;
33
33
  }, never>;
34
+ export declare const SearchWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
34
35
  export { Value as CollectorValue };
35
36
  export { ContentAbove };
36
37
  export { Label };
@@ -19,7 +19,7 @@ export var CollectorInput = styled(InputWrapper).withConfig({
19
19
  export var Scrollbar = styled(DSScrollbar).withConfig({
20
20
  displayName: "Collectorstyles__Scrollbar",
21
21
  componentId: "sc-14aly5p-2"
22
- })([""]);
22
+ })(["width:100%;"]);
23
23
  export var MainContent = styled.div.withConfig({
24
24
  displayName: "Collectorstyles__MainContent",
25
25
  componentId: "sc-14aly5p-3"
@@ -51,13 +51,17 @@ export var RightSide = styled.div.withConfig({
51
51
  export var Input = styled(BorderLessInput).withConfig({
52
52
  displayName: "Collectorstyles__Input",
53
53
  componentId: "sc-14aly5p-5"
54
- })(["margin:", ";padding:1px 0;min-width:unset;line-height:18px;", " ", ""], function (props) {
54
+ })(["margin:", ";padding:1px 0;min-width:unset;line-height:18px;width:calc(100% - 12px);", " ", ""], function (props) {
55
55
  return props.hasValues ? '6px 0 6px 12px' : '4px 0 4px 12px';
56
56
  }, function (props) {
57
57
  return props.hidden && css(["display:none;"]);
58
58
  }, function (props) {
59
59
  return props.transparent && css(["color:transparent;"]);
60
60
  });
61
+ export var SearchWrapper = styled.div.withConfig({
62
+ displayName: "Collectorstyles__SearchWrapper",
63
+ componentId: "sc-14aly5p-6"
64
+ })(["flex:1 0 auto;"]);
61
65
  export { Value as CollectorValue };
62
66
  export { ContentAbove };
63
67
  export { Label };
@@ -67,33 +71,33 @@ export { ErrorText };
67
71
  export { ValueText };
68
72
  export var DropdownWrapper = styled.div.withConfig({
69
73
  displayName: "Collectorstyles__DropdownWrapper",
70
- componentId: "sc-14aly5p-6"
74
+ componentId: "sc-14aly5p-7"
71
75
  })(["position:relative;user-select:none;"]);
72
76
  export var CustomContentWrapper = styled.div.withConfig({
73
77
  displayName: "Collectorstyles__CustomContentWrapper",
74
- componentId: "sc-14aly5p-7"
78
+ componentId: "sc-14aly5p-8"
75
79
  })(["position:absolute;z-index:99;"]);
76
80
  export var DropdownContent = styled.div.withConfig({
77
81
  displayName: "Collectorstyles__DropdownContent",
78
- componentId: "sc-14aly5p-8"
82
+ componentId: "sc-14aly5p-9"
79
83
  })(["background:", ";border-radius:3px;padding:8px 0 8px 8px;position:absolute;width:100%;top:4px;left:0;box-shadow:0 16px 32px 0 rgba(35,41,54,0.12);z-index:99;"], function (props) {
80
84
  return props.theme.palette.white;
81
85
  });
82
86
  export var DropdownAddButton = styled(Button).withConfig({
83
87
  displayName: "Collectorstyles__DropdownAddButton",
84
- componentId: "sc-14aly5p-9"
88
+ componentId: "sc-14aly5p-10"
85
89
  })(["white-space:nowrap;overflow:hidden;width:100%;text-overflow:ellipsis;&&{display:flex;justify-content:flex-start;align-items:center;font-weight:400;text-align:left;}.ds-icon{margin-left:16px;margin-right:8px;}strong{font-weight:500;margin:0 0 0 3px;display:block;overflow:hidden;text-overflow:ellipsis;}"]);
86
90
  export var DropdownTop = styled.div.withConfig({
87
91
  displayName: "Collectorstyles__DropdownTop",
88
- componentId: "sc-14aly5p-10"
92
+ componentId: "sc-14aly5p-11"
89
93
  })(["padding-right:8px;"]);
90
94
  export var DividerContainer = styled.div.withConfig({
91
95
  displayName: "Collectorstyles__DividerContainer",
92
- componentId: "sc-14aly5p-11"
96
+ componentId: "sc-14aly5p-12"
93
97
  })(["padding:8px 12px;"]);
94
98
  export var NavigationWrapper = styled.div.withConfig({
95
99
  displayName: "Collectorstyles__NavigationWrapper",
96
- componentId: "sc-14aly5p-12"
100
+ componentId: "sc-14aly5p-13"
97
101
  })(["margin-top:8px;border-top:1px solid ", ";background:", ";padding:12px 16px;margin-left:-8px;margin-bottom:-8px;color:", ";display:flex;align-items:center;.ds-icon > svg{fill:", ";}span{margin-left:2px;margin-right:8px;font-weight:500;}"], function (props) {
98
102
  return props.theme.palette['grey-100'];
99
103
  }, function (props) {
@@ -105,5 +109,5 @@ export var NavigationWrapper = styled.div.withConfig({
105
109
  });
106
110
  export var Counter = styled.div.withConfig({
107
111
  displayName: "Collectorstyles__Counter",
108
- componentId: "sc-14aly5p-13"
112
+ componentId: "sc-14aly5p-14"
109
113
  })(["display:flex;height:26px;align-items:center;column-gap:4px;"]);
@@ -3,9 +3,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
3
3
  import * as React from 'react';
4
4
  import Scrollbar from '@synerise/ds-scrollbar';
5
5
  import SearchItems from '@synerise/ds-search/dist/Elements/SearchItems/SearchItems';
6
- import Menu from '@synerise/ds-menu';
7
6
  import Icon, { Add3M } from '@synerise/ds-icon';
8
7
  import Divider from '@synerise/ds-divider';
8
+ import ListItem from '@synerise/ds-list-item';
9
9
  import * as S from '../../Collector.styles';
10
10
  import NavigationHint from '../NavigationHint/NavigationHint';
11
11
 
@@ -39,7 +39,7 @@ var OptionsDropdown = function OptionsDropdown(_ref) {
39
39
  setScrollTop(0);
40
40
  }, [visible]);
41
41
  var renderItemFn = React.useCallback(function (itemValue) {
42
- return renderItem ? renderItem(itemValue) : /*#__PURE__*/React.createElement(Menu.Item, {
42
+ return renderItem ? renderItem(itemValue) : /*#__PURE__*/React.createElement(ListItem, {
43
43
  tabIndex: -1,
44
44
  size: dropdownItemHeight,
45
45
  key: "" + itemValue
package/dist/utils.d.ts CHANGED
@@ -2,5 +2,6 @@ import * as React from 'react';
2
2
  import { CollectorValue } from './Collector.types';
3
3
  export declare const arrayToLowerCase: (array: CollectorValue[] | undefined, lookupKey: string) => CollectorValue[];
4
4
  export declare const scrollWithHorizontalArrow: (ref: React.RefObject<HTMLElement>, event: React.KeyboardEvent<HTMLElement>, scrollStep?: number | undefined) => void;
5
+ export declare const filterOutNullishArrayItems: <T extends unknown>(array: ("" | T | null | undefined)[]) => T[];
5
6
  export declare const isOverflown: (elementRef: React.RefObject<HTMLDivElement>) => boolean;
6
7
  export declare const filterValueSuggestions: (suggestions: CollectorValue[], selected: CollectorValue[], searchValue: string, lookupKey: string) => CollectorValue[];
package/dist/utils.js CHANGED
@@ -35,6 +35,12 @@ export var scrollWithHorizontalArrow = function scrollWithHorizontalArrow(ref, e
35
35
  });
36
36
  }
37
37
  };
38
+ export var filterOutNullishArrayItems = function filterOutNullishArrayItems(array) {
39
+ var filtered = array.filter(function (val) {
40
+ return Boolean(val);
41
+ });
42
+ return filtered;
43
+ };
38
44
  export var isOverflown = function isOverflown(elementRef) {
39
45
  if (elementRef !== null && elementRef.current !== null) {
40
46
  var element = elementRef.current;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-collector",
3
- "version": "0.6.30",
3
+ "version": "0.6.32",
4
4
  "description": "Collector UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -36,13 +36,12 @@
36
36
  "@synerise/ds-button": "^0.18.7",
37
37
  "@synerise/ds-divider": "^0.6.4",
38
38
  "@synerise/ds-icon": "^0.58.7",
39
- "@synerise/ds-input": "^0.19.8",
40
- "@synerise/ds-menu": "^0.18.4",
41
- "@synerise/ds-scrollbar": "^0.6.12",
42
- "@synerise/ds-search": "^0.8.71",
39
+ "@synerise/ds-input": "^0.19.9",
40
+ "@synerise/ds-menu": "^0.18.5",
41
+ "@synerise/ds-scrollbar": "^0.6.13",
42
+ "@synerise/ds-search": "^0.8.72",
43
43
  "@synerise/ds-utils": "^0.24.21",
44
- "classnames": "2.3.2",
45
- "lodash": "^4.17.19"
44
+ "classnames": "2.3.2"
46
45
  },
47
46
  "peerDependencies": {
48
47
  "@synerise/ds-core": "*",
@@ -54,5 +53,5 @@
54
53
  "@testing-library/jest-dom": "5.1.1",
55
54
  "@testing-library/react": "^11"
56
55
  },
57
- "gitHead": "88f117b388bae43df3daf3be6ca725ff0355e54b"
56
+ "gitHead": "ed5f01de295110e936cd4818944fcbf168c9ac09"
58
57
  }