@synerise/ds-collector 1.4.6 → 1.4.8

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
+ ## [1.4.8](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@1.4.7...@synerise/ds-collector@1.4.8) (2026-01-07)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-collector
9
+
10
+ ## [1.4.7](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@1.4.6...@synerise/ds-collector@1.4.7) (2025-12-16)
11
+
12
+ **Note:** Version bump only for package @synerise/ds-collector
13
+
6
14
  ## [1.4.6](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@1.4.5...@synerise/ds-collector@1.4.6) (2025-12-15)
7
15
 
8
16
  **Note:** Version bump only for package @synerise/ds-collector
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type CollectorProps } from './Collector.types';
3
3
  declare const Collector: {
4
- ({ allowCustomValue, allowMultipleValues, addButtonProps, buttonPanelPrefix, cancelButtonProps, keepSearchQueryOnSelect, error, className, description, enableCustomFilteringSuggestions, selected, suggestions, showNavigationHints, onConfirm, onCancel, label, errorText, disabled, fixedHeight, texts: defaultTexts, lookupConfig, onItemAdd, onItemDeselect, onItemSelect, onMultipleItemsSelect, dropdownContent, disableButtonPanel, disableSearch, dropdownItemHeight, searchValue, renderItem, onSearchValueChange, allowPaste, showCount, listHeader, hideDropdownOnClickOutside, valuesSeparator, }: CollectorProps): React.JSX.Element;
4
+ ({ allowCustomValue, allowMultipleValues, addButtonProps, buttonPanelPrefix, cancelButtonProps, keepSearchQueryOnSelect, error, className, description, enableCustomFilteringSuggestions, selected, suggestions, showNavigationHints, onConfirm, onCancel, label, errorText, disabled, fixedHeight, texts: defaultTexts, lookupConfig, onItemAdd, onItemDeselect, onItemSelect, onMultipleItemsSelect, dropdownContent, disableButtonPanel, disableSearch, dropdownItemHeight, searchValue, renderItem, onSearchValueChange, allowPaste, showCount, listHeader, hideDropdownOnClickOutside, valuesSeparator, valuesEscapeOpenTag, valuesEscapeCloseTag, }: CollectorProps): React.JSX.Element;
5
5
  Values: ({ values, onDeselect, disabled, focused, displayLookupKey, }: import("./Elements/Values/Values.types").ValuesProps) => React.JSX.Element;
6
6
  ButtonPanel: ({ onConfirm, onCancel, disabled, showCancel, texts, addButtonProps, cancelButtonProps, buttonPanelPrefix, }: import("./Elements/ButtonPanel/ButtonPanel.types").ButtonPanelProps) => React.JSX.Element;
7
7
  OptionsDropdown: ({ showAddButton, options, visible, value, onSelect, onClick, width, onItemAdd, showNavigationHints, lookupKey, texts, customContent, renderItem, dropdownItemHeight, scrollbarProps, listHeader, }: import("./Elements/OptionsDropdown/OptionsDropdown.types").OptionsDropdownProps) => React.JSX.Element;
package/dist/Collector.js CHANGED
@@ -2,17 +2,19 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
2
2
  import classNames from 'classnames';
3
3
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import { FormattedMessage } from 'react-intl';
5
- import { focusWithArrowKeys, useOnClickOutside } from '@synerise/ds-utils';
5
+ import { focusWithArrowKeys, useDelimiterEscape, useOnClickOutside } from '@synerise/ds-utils';
6
6
  import * as S from './Collector.styles';
7
7
  import ButtonPanel from './Elements/ButtonPanel/ButtonPanel';
8
8
  import NavigationHint from './Elements/NavigationHint/NavigationHint';
9
9
  import OptionsDropdown from './Elements/OptionsDropdown/OptionsDropdown';
10
10
  import Values from './Elements/Values/Values';
11
11
  import { useTranslations } from './hooks/useTranslations';
12
- import { filterOutNullishArrayItems, filterValueSuggestions, isOverflown, scrollWithHorizontalArrow } from './utils';
12
+ import { filterOutEmptyStrings, filterOutNullishArrayItems, filterValueSuggestions, isOverflown, scrollWithHorizontalArrow } from './utils';
13
13
  var DROPDOWN_PADDING = 2 * 8;
14
14
  var COLLECTOR_CLASSNAME = 'ds-collector';
15
15
  var DEFAULT_VALUES_SEPARATOR = ';';
16
+ var DEFAULT_VALUES_ESCAPE_OPEN_TAG = '```';
17
+ var DEFAULT_VALUES_ESCAPE_CLOSE_TAG = '```';
16
18
  var Collector = function Collector(_ref) {
17
19
  var _classNames;
18
20
  var allowCustomValue = _ref.allowCustomValue,
@@ -53,7 +55,18 @@ var Collector = function Collector(_ref) {
53
55
  _ref$hideDropdownOnCl = _ref.hideDropdownOnClickOutside,
54
56
  hideDropdownOnClickOutside = _ref$hideDropdownOnCl === void 0 ? true : _ref$hideDropdownOnCl,
55
57
  _ref$valuesSeparator = _ref.valuesSeparator,
56
- valuesSeparator = _ref$valuesSeparator === void 0 ? DEFAULT_VALUES_SEPARATOR : _ref$valuesSeparator;
58
+ valuesSeparator = _ref$valuesSeparator === void 0 ? DEFAULT_VALUES_SEPARATOR : _ref$valuesSeparator,
59
+ _ref$valuesEscapeOpen = _ref.valuesEscapeOpenTag,
60
+ valuesEscapeOpenTag = _ref$valuesEscapeOpen === void 0 ? DEFAULT_VALUES_ESCAPE_OPEN_TAG : _ref$valuesEscapeOpen,
61
+ _ref$valuesEscapeClos = _ref.valuesEscapeCloseTag,
62
+ valuesEscapeCloseTag = _ref$valuesEscapeClos === void 0 ? DEFAULT_VALUES_ESCAPE_CLOSE_TAG : _ref$valuesEscapeClos;
63
+ var _useDelimiterEscape = useDelimiterEscape({
64
+ openTag: valuesEscapeOpenTag,
65
+ closeTag: valuesEscapeCloseTag,
66
+ delimiter: valuesSeparator
67
+ }),
68
+ isValidEscapedString = _useDelimiterEscape.isValidEscapedString,
69
+ splitWithEscape = _useDelimiterEscape.splitWithEscape;
57
70
  var texts = useTranslations(defaultTexts);
58
71
  var inputRef = useRef(null);
59
72
  var containerRef = useRef(null);
@@ -172,9 +185,9 @@ var Collector = function Collector(_ref) {
172
185
  var handlePaste = function handlePaste(event) {
173
186
  if (allowMultipleValues && onItemAdd) {
174
187
  var pastedText = event.clipboardData.getData('text');
175
- if (pastedText.includes(valuesSeparator)) {
176
- var pastedItems = allowMultipleValues ? pastedText.split(valuesSeparator) : [pastedText];
177
- var newValues = filterOutNullishArrayItems(pastedItems.map(createItem));
188
+ if (pastedText.includes(valuesSeparator) && isValidEscapedString(pastedText)) {
189
+ var pastedItems = splitWithEscape(pastedText);
190
+ var newValues = filterOutNullishArrayItems(filterOutEmptyStrings(pastedItems).map(createItem));
178
191
  if (newValues.length) {
179
192
  onMultipleItemsSelect && onMultipleItemsSelect(newValues);
180
193
  }
@@ -185,7 +198,8 @@ var Collector = function Collector(_ref) {
185
198
  if (!value.trim()) {
186
199
  return;
187
200
  }
188
- var newValue = createItem(value);
201
+ var trimmedValue = value.startsWith(valuesEscapeOpenTag) ? value.slice(valuesEscapeOpenTag.length) : value;
202
+ var newValue = createItem(trimmedValue);
189
203
  if (!newValue) {
190
204
  setValue('');
191
205
  return;
@@ -208,18 +222,29 @@ var Collector = function Collector(_ref) {
208
222
  };
209
223
  var handleKeyPress = function handleKeyPress(event) {
210
224
  if (event.key === 'Enter') {
225
+ event.preventDefault();
211
226
  if (value) {
212
227
  addItem();
213
228
  } else if (selectedValues.length) {
214
229
  onConfirmCallback();
215
230
  }
216
- return;
217
231
  }
218
- if (allowCustomValue && event.key === valuesSeparator) {
219
- event.preventDefault();
220
- if (value.trim()) {
221
- addItem();
232
+ };
233
+ var handleKeyUp = function handleKeyUp(event) {
234
+ var currentValue = event.target.value;
235
+ var isEscaped = currentValue.startsWith(valuesEscapeOpenTag);
236
+ var isClosedEscape = currentValue.endsWith(valuesEscapeCloseTag) && isEscaped && currentValue.length > valuesEscapeOpenTag.length + valuesEscapeCloseTag.length;
237
+ var tempItems = splitWithEscape(currentValue);
238
+ var containsSeparator = currentValue.includes(valuesSeparator);
239
+ if (isClosedEscape || containsSeparator && !isEscaped || tempItems.length > 1) {
240
+ var isValid = isClosedEscape ? isValidEscapedString(currentValue) : currentValue.endsWith(valuesSeparator);
241
+ var finalItems = isValid ? tempItems.slice() : tempItems.slice(0, -1);
242
+ var finalQuery = isValid ? '' : tempItems.at(-1) || '';
243
+ var newValues = filterOutNullishArrayItems(filterOutEmptyStrings(finalItems).map(createItem));
244
+ if (newValues.length) {
245
+ onMultipleItemsSelect && onMultipleItemsSelect(newValues);
222
246
  }
247
+ setValue(finalQuery);
223
248
  }
224
249
  };
225
250
  var onCancelCallback = useCallback(function () {
@@ -303,17 +328,17 @@ var Collector = function Collector(_ref) {
303
328
  focused: isFocused,
304
329
  disabled: !!disabled,
305
330
  displayLookupKey: displayLookupKey
306
- }), /*#__PURE__*/React.createElement(S.SearchWrapper, null, /*#__PURE__*/React.createElement(S.Input, {
331
+ }), /*#__PURE__*/React.createElement(S.SearchWrapper, null, !(selectedValues != null && selectedValues.length) && !value && /*#__PURE__*/React.createElement(S.Placeholder, null, texts == null ? void 0 : texts.placeholder), /*#__PURE__*/React.createElement(S.Input, {
307
332
  onPaste: handlePaste,
308
333
  onKeyPress: handleKeyPress,
309
334
  onKeyDown: handleKeyDown,
335
+ onKeyUp: handleKeyUp,
310
336
  ref: inputRef,
311
337
  value: value,
312
338
  onInput: handleInput,
313
339
  disabled: disabled,
314
340
  transparent: !!disableSearch,
315
341
  hidden: !!disableSearch && !!selectedValues.length,
316
- placeholder: selectedValues && selectedValues.length ? undefined : texts == null ? void 0 : texts.placeholder,
317
342
  hasValues: !!(selectedValues != null && selectedValues.length),
318
343
  "data-testid": "ds-collector-input"
319
344
  })));
@@ -40,6 +40,7 @@ export declare const CustomContentWrapper: import("styled-components").StyledCom
40
40
  export declare const DropdownContent: import("styled-components").StyledComponent<"div", any, {
41
41
  visible?: boolean;
42
42
  }, never>;
43
+ export declare const Placeholder: import("styled-components").StyledComponent<"div", any, {}, never>;
43
44
  export declare const DropdownAddButton: StyledButton;
44
45
  export declare const DropdownTop: import("styled-components").StyledComponent<"div", any, {}, never>;
45
46
  export declare const DividerContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -59,7 +59,7 @@ export var Input = styled(BorderLessInput).withConfig({
59
59
  export var SearchWrapper = styled.div.withConfig({
60
60
  displayName: "Collectorstyles__SearchWrapper",
61
61
  componentId: "sc-14aly5p-6"
62
- })(["flex:1 0 auto;"]);
62
+ })(["flex:1 0 auto;position:relative;"]);
63
63
  export var CollectorValue = styled(Value).withConfig({
64
64
  displayName: "Collectorstyles__CollectorValue",
65
65
  componentId: "sc-14aly5p-7"
@@ -86,21 +86,27 @@ export var DropdownContent = styled.div.withConfig({
86
86
  })(["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) {
87
87
  return props.theme.palette.white;
88
88
  });
89
+ export var Placeholder = styled.div.withConfig({
90
+ displayName: "Collectorstyles__Placeholder",
91
+ componentId: "sc-14aly5p-11"
92
+ })(["position:absolute;ppointer-events:none;top:0;bottom:0;left:12px;right:0;display:flex;align-items:center;gap:4px;color:", ";"], function (props) {
93
+ return props.theme.palette['grey-500'];
94
+ });
89
95
  export var DropdownAddButton = styled(Button).withConfig({
90
96
  displayName: "Collectorstyles__DropdownAddButton",
91
- componentId: "sc-14aly5p-11"
97
+ componentId: "sc-14aly5p-12"
92
98
  })(["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;}"]);
93
99
  export var DropdownTop = styled.div.withConfig({
94
100
  displayName: "Collectorstyles__DropdownTop",
95
- componentId: "sc-14aly5p-12"
101
+ componentId: "sc-14aly5p-13"
96
102
  })(["padding-right:8px;"]);
97
103
  export var DividerContainer = styled.div.withConfig({
98
104
  displayName: "Collectorstyles__DividerContainer",
99
- componentId: "sc-14aly5p-13"
105
+ componentId: "sc-14aly5p-14"
100
106
  })(["padding:8px 12px;"]);
101
107
  export var NavigationWrapper = styled.div.withConfig({
102
108
  displayName: "Collectorstyles__NavigationWrapper",
103
- componentId: "sc-14aly5p-14"
109
+ componentId: "sc-14aly5p-15"
104
110
  })(["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) {
105
111
  return props.theme.palette['grey-100'];
106
112
  }, function (props) {
@@ -112,5 +118,5 @@ export var NavigationWrapper = styled.div.withConfig({
112
118
  });
113
119
  export var Counter = styled.div.withConfig({
114
120
  displayName: "Collectorstyles__Counter",
115
- componentId: "sc-14aly5p-15"
121
+ componentId: "sc-14aly5p-16"
116
122
  })(["display:flex;height:26px;align-items:center;column-gap:4px;"]);
@@ -39,6 +39,8 @@ export type CollectorProps = {
39
39
  allowPaste?: boolean;
40
40
  showCount?: boolean;
41
41
  valuesSeparator?: CollectorValuesSeparator;
42
+ valuesEscapeOpenTag?: string;
43
+ valuesEscapeCloseTag?: string;
42
44
  listHeader?: ReactNode;
43
45
  hideDropdownOnClickOutside?: boolean;
44
46
  };
@@ -46,7 +48,7 @@ export type CollectorValuesSeparator = ';' | ',' | '|';
46
48
  export type CollectorTexts = {
47
49
  add: ReactNode;
48
50
  cancel: ReactNode;
49
- placeholder: string;
51
+ placeholder: ReactNode;
50
52
  toNavigate: ReactNode;
51
53
  toSelect: ReactNode;
52
54
  };
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type React from 'react';
2
2
  import { type CollectorValue } from './Collector.types';
3
3
  export declare const scrollWithHorizontalArrow: (ref: React.RefObject<HTMLElement>, event: React.KeyboardEvent<HTMLElement>, scrollStep?: number | undefined) => void;
4
+ export declare const filterOutEmptyStrings: (items: string[]) => string[];
4
5
  export declare const filterOutNullishArrayItems: <T>(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
@@ -17,6 +17,11 @@ export var scrollWithHorizontalArrow = function scrollWithHorizontalArrow(ref, e
17
17
  });
18
18
  }
19
19
  };
20
+ export var filterOutEmptyStrings = function filterOutEmptyStrings(items) {
21
+ return items.filter(function (val) {
22
+ return Boolean(val.trim());
23
+ });
24
+ };
20
25
  export var filterOutNullishArrayItems = function filterOutNullishArrayItems(array) {
21
26
  var filtered = array.filter(function (val) {
22
27
  return Boolean(val);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-collector",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "description": "Collector UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -35,14 +35,14 @@
35
35
  ],
36
36
  "types": "dist/index.d.ts",
37
37
  "dependencies": {
38
- "@synerise/ds-button": "^1.5.2",
39
- "@synerise/ds-divider": "^1.2.3",
40
- "@synerise/ds-icon": "^1.9.1",
41
- "@synerise/ds-input": "^1.5.2",
42
- "@synerise/ds-list-item": "^1.2.2",
43
- "@synerise/ds-scrollbar": "^1.2.2",
44
- "@synerise/ds-search": "^1.3.12",
45
- "@synerise/ds-utils": "^1.5.1",
38
+ "@synerise/ds-button": "^1.5.3",
39
+ "@synerise/ds-divider": "^1.2.4",
40
+ "@synerise/ds-icon": "^1.9.2",
41
+ "@synerise/ds-input": "^1.5.4",
42
+ "@synerise/ds-list-item": "^1.2.4",
43
+ "@synerise/ds-scrollbar": "^1.2.3",
44
+ "@synerise/ds-search": "^1.3.13",
45
+ "@synerise/ds-utils": "^1.5.2",
46
46
  "classnames": "^2.5.1",
47
47
  "lodash.isequal": "^4.5.0"
48
48
  },
@@ -56,5 +56,5 @@
56
56
  "devDependencies": {
57
57
  "@types/lodash.isequal": "^4.5.8"
58
58
  },
59
- "gitHead": "b1279d5354132a2bf0b6f0cfa343db4c6c928f72"
59
+ "gitHead": "f38e4b2dca1d43c39af0b189c93808de62c11e9b"
60
60
  }