@synerise/ds-collector 1.1.3 → 1.2.0

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
+ # [1.2.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@1.1.4...@synerise/ds-collector@1.2.0) (2025-06-24)
7
+
8
+
9
+ ### Features
10
+
11
+ * **factors:** array factor type ([195d328](https://github.com/Synerise/synerise-design/commit/195d3286e98b5f07fc9c1e56001e6ae844b7a080))
12
+
13
+
14
+
15
+
16
+
17
+ ## [1.1.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@1.1.3...@synerise/ds-collector@1.1.4) (2025-06-12)
18
+
19
+ **Note:** Version bump only for package @synerise/ds-collector
20
+
21
+
22
+
23
+
24
+
6
25
  ## [1.1.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-collector@1.1.2...@synerise/ds-collector@1.1.3) (2025-06-05)
7
26
 
8
27
  **Note:** Version bump only for package @synerise/ds-collector
@@ -49,7 +49,7 @@ declare const Collector: {
49
49
  }, never>;
50
50
  Counter: import("styled-components").StyledComponent<"div", any, {}, never>;
51
51
  Label: import("styled-components").StyledComponent<"label", any, {}, never>;
52
- Values: React.FC<import("./Elements/Values/Values.types").ValuesProps>;
52
+ Values: ({ values, onDeselect, disabled, focused, displayLookupKey }: import("./Elements/Values/Values.types").ValuesProps) => React.JSX.Element;
53
53
  ButtonPanel: React.FC<import("./Elements/ButtonPanel/ButtonPanel.types").ButtonPanelProps>;
54
54
  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;
55
55
  NavigationHint: React.FC<import("./Elements/NavigationHint/NavigationHint.types").NavigationHintProps>;
package/dist/Collector.js CHANGED
@@ -188,8 +188,8 @@ var Collector = function Collector(_ref) {
188
188
  if (allowMultipleValues) {
189
189
  onItemSelect(newValue);
190
190
  setValue('');
191
- } else {
192
- onConfirm && onConfirm([newValue]);
191
+ } else if (onConfirm) {
192
+ onConfirm([newValue]);
193
193
  !keepSearchQueryOnSelect && clear();
194
194
  }
195
195
  };
@@ -203,10 +203,18 @@ var Collector = function Collector(_ref) {
203
203
  };
204
204
  var handleKeyPress = function handleKeyPress(event) {
205
205
  if (event.key === 'Enter') {
206
- addItem();
206
+ if (value) {
207
+ addItem();
208
+ } else if (selectedValues.length) {
209
+ onConfirmCallback();
210
+ }
211
+ return;
207
212
  }
208
- if (allowPaste && event.key === valuesSeparator) {
209
- value.trim() ? addItem() : event.preventDefault();
213
+ if (allowCustomValue && event.key === valuesSeparator) {
214
+ event.preventDefault();
215
+ if (value.trim()) {
216
+ addItem();
217
+ }
210
218
  }
211
219
  };
212
220
  var onCancelCallback = useCallback(function () {
@@ -214,10 +222,13 @@ var Collector = function Collector(_ref) {
214
222
  onCancel && onCancel();
215
223
  }, [onCancel, clear]);
216
224
  var onConfirmCallback = useCallback(function () {
225
+ if (!onConfirm) {
226
+ return;
227
+ }
217
228
  if (allowMultipleValues) {
218
229
  var createdItem = value && createItem(value);
219
230
  var finalItems = createdItem ? [].concat(selectedValues, [createdItem]) : selectedValues;
220
- onConfirm && onConfirm(finalItems);
231
+ onConfirm(finalItems);
221
232
  clear();
222
233
  return;
223
234
  }
@@ -296,7 +307,8 @@ var Collector = function Collector(_ref) {
296
307
  transparent: !!disableSearch,
297
308
  hidden: !!disableSearch && !!selectedValues.length,
298
309
  placeholder: selectedValues && selectedValues.length ? undefined : texts == null ? void 0 : texts.placeholder,
299
- hasValues: !!(selectedValues != null && selectedValues.length)
310
+ hasValues: !!(selectedValues != null && selectedValues.length),
311
+ "data-testid": "ds-collector-input"
300
312
  })));
301
313
  var innerContent = fixedHeight ? valuesContainer : /*#__PURE__*/React.createElement(S.Scrollbar, {
302
314
  absolute: true,
@@ -328,9 +340,9 @@ var Collector = function Collector(_ref) {
328
340
  disabled: !!disabled,
329
341
  showCancel: !!value || !!(selectedValues != null && selectedValues.length),
330
342
  texts: texts,
331
- addButtonProps: _extends({}, addButtonProps, {
343
+ addButtonProps: _extends({
332
344
  disabled: !isAddActive
333
- }),
345
+ }, addButtonProps),
334
346
  cancelButtonProps: cancelButtonProps
335
347
  }))), /*#__PURE__*/React.createElement(OptionsDropdown, {
336
348
  options: filteredSuggestions,
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { ContentAbove, Label, ContentBelow, Description, ErrorText, ValueText } from '@synerise/ds-input/dist/InputMultivalue/InputMultivalue.styles';
3
- import Value from '@synerise/ds-input/dist/InputMultivalue/Elements/Value';
4
3
  import Button from '@synerise/ds-button';
5
4
  export declare const Container: import("styled-components").StyledComponent<"div", any, {}, never>;
6
5
  export declare const CollectorInput: import("styled-components").StyledComponent<"div", any, import("@synerise/ds-input/dist/InputMultivalue/InputMultivalue.styles").InputWrapperProps & {
@@ -45,7 +44,9 @@ export declare const Input: import("styled-components").StyledComponent<"input",
45
44
  hidden: boolean;
46
45
  }, never>;
47
46
  export declare const SearchWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
48
- export { Value as CollectorValue };
47
+ export declare const CollectorValue: import("styled-components").StyledComponent<({ disabled, key, onRemoveClick, value, focused, className, ...rest }: import("@synerise/ds-input/dist/InputMultivalue/Elements/Value.types").ValueProps) => import("react").JSX.Element, any, {
48
+ hasError?: boolean | undefined;
49
+ }, never>;
49
50
  export { ContentAbove };
50
51
  export { Label };
51
52
  export { ContentBelow };
@@ -1,6 +1,6 @@
1
- import { InputWrapper, BorderLessInput, ContentAbove, Label, ContentBelow, Description, ErrorText, ValueText } from '@synerise/ds-input/dist/InputMultivalue/InputMultivalue.styles';
2
- import DSScrollbar from '@synerise/ds-scrollbar';
3
1
  import styled, { css } from 'styled-components';
2
+ import { InputWrapper, IconWrapper, BorderLessInput, ContentAbove, Label, ContentBelow, Description, ErrorText, ValueText } from '@synerise/ds-input/dist/InputMultivalue/InputMultivalue.styles';
3
+ import DSScrollbar from '@synerise/ds-scrollbar';
4
4
  import Value from '@synerise/ds-input/dist/InputMultivalue/Elements/Value';
5
5
  import Button from '@synerise/ds-button';
6
6
  export var Container = styled.div.withConfig({
@@ -60,7 +60,12 @@ export var SearchWrapper = styled.div.withConfig({
60
60
  displayName: "Collectorstyles__SearchWrapper",
61
61
  componentId: "sc-14aly5p-6"
62
62
  })(["flex:1 0 auto;"]);
63
- export { Value as CollectorValue };
63
+ export var CollectorValue = styled(Value).withConfig({
64
+ displayName: "Collectorstyles__CollectorValue",
65
+ componentId: "sc-14aly5p-7"
66
+ })(["", ""], function (props) {
67
+ return props.hasError && css(["&&{background:", ";color:", ";", "{color:", ";}}"], props.theme.palette['red-600'], props.theme.palette.white, IconWrapper, props.theme.palette.white);
68
+ });
64
69
  export { ContentAbove };
65
70
  export { Label };
66
71
  export { ContentBelow };
@@ -69,33 +74,33 @@ export { ErrorText };
69
74
  export { ValueText };
70
75
  export var DropdownWrapper = styled.div.withConfig({
71
76
  displayName: "Collectorstyles__DropdownWrapper",
72
- componentId: "sc-14aly5p-7"
77
+ componentId: "sc-14aly5p-8"
73
78
  })(["position:relative;user-select:none;"]);
74
79
  export var CustomContentWrapper = styled.div.withConfig({
75
80
  displayName: "Collectorstyles__CustomContentWrapper",
76
- componentId: "sc-14aly5p-8"
81
+ componentId: "sc-14aly5p-9"
77
82
  })(["position:absolute;z-index:99;"]);
78
83
  export var DropdownContent = styled.div.withConfig({
79
84
  displayName: "Collectorstyles__DropdownContent",
80
- componentId: "sc-14aly5p-9"
85
+ componentId: "sc-14aly5p-10"
81
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) {
82
87
  return props.theme.palette.white;
83
88
  });
84
89
  export var DropdownAddButton = styled(Button).withConfig({
85
90
  displayName: "Collectorstyles__DropdownAddButton",
86
- componentId: "sc-14aly5p-10"
91
+ componentId: "sc-14aly5p-11"
87
92
  })(["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;}"]);
88
93
  export var DropdownTop = styled.div.withConfig({
89
94
  displayName: "Collectorstyles__DropdownTop",
90
- componentId: "sc-14aly5p-11"
95
+ componentId: "sc-14aly5p-12"
91
96
  })(["padding-right:8px;"]);
92
97
  export var DividerContainer = styled.div.withConfig({
93
98
  displayName: "Collectorstyles__DividerContainer",
94
- componentId: "sc-14aly5p-12"
99
+ componentId: "sc-14aly5p-13"
95
100
  })(["padding:8px 12px;"]);
96
101
  export var NavigationWrapper = styled.div.withConfig({
97
102
  displayName: "Collectorstyles__NavigationWrapper",
98
- componentId: "sc-14aly5p-13"
103
+ componentId: "sc-14aly5p-14"
99
104
  })(["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) {
100
105
  return props.theme.palette['grey-100'];
101
106
  }, function (props) {
@@ -107,5 +112,5 @@ export var NavigationWrapper = styled.div.withConfig({
107
112
  });
108
113
  export var Counter = styled.div.withConfig({
109
114
  displayName: "Collectorstyles__Counter",
110
- componentId: "sc-14aly5p-14"
115
+ componentId: "sc-14aly5p-15"
111
116
  })(["display:flex;height:26px;align-items:center;column-gap:4px;"]);
@@ -1,11 +1,12 @@
1
1
  import type { ReactNode } from 'react';
2
- import { ButtonProps } from '@synerise/ds-button';
3
- import { ScrollbarAdditionalProps } from '@synerise/ds-scrollbar';
2
+ import type { ButtonProps } from '@synerise/ds-button';
3
+ import type { ScrollbarAdditionalProps } from '@synerise/ds-scrollbar';
4
+ import { DataAttributes } from '@synerise/ds-utils';
4
5
  export type CollectorProps = {
5
- addButtonProps?: Partial<ButtonProps>;
6
+ addButtonProps?: Partial<ButtonProps & DataAttributes>;
6
7
  allowCustomValue?: boolean;
7
8
  allowMultipleValues?: boolean;
8
- cancelButtonProps?: Partial<ButtonProps>;
9
+ cancelButtonProps?: Partial<ButtonProps & DataAttributes>;
9
10
  className?: string;
10
11
  description?: ReactNode;
11
12
  disabled?: boolean;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { ValuesProps } from './Values.types';
3
- declare const Values: React.FC<ValuesProps>;
3
+ export declare const Values: ({ values, onDeselect, disabled, focused, displayLookupKey }: ValuesProps) => React.JSX.Element;
4
4
  export default Values;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import * as S from '../../Collector.styles';
3
- var Values = function Values(_ref) {
3
+ export var Values = function Values(_ref) {
4
4
  var values = _ref.values,
5
5
  onDeselect = _ref.onDeselect,
6
6
  disabled = _ref.disabled,
@@ -15,7 +15,8 @@ var Values = function Values(_ref) {
15
15
  },
16
16
  value: val[displayLookupKey],
17
17
  focused: focused,
18
- disabled: disabled
18
+ disabled: disabled,
19
+ hasError: val.hasError
19
20
  });
20
21
  }));
21
22
  };
@@ -4,5 +4,6 @@ export type ValuesProps = {
4
4
  onDeselect?: (value: CollectorValue) => void;
5
5
  focused: boolean;
6
6
  disabled: boolean;
7
+ hasError?: boolean;
7
8
  displayLookupKey: string;
8
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-collector",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "description": "Collector UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -34,14 +34,14 @@
34
34
  ],
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
- "@synerise/ds-button": "^1.3.3",
38
- "@synerise/ds-divider": "^1.0.10",
39
- "@synerise/ds-icon": "^1.5.2",
40
- "@synerise/ds-input": "^1.2.0",
41
- "@synerise/ds-list-item": "^1.0.10",
42
- "@synerise/ds-scrollbar": "^1.0.10",
43
- "@synerise/ds-search": "^1.1.8",
44
- "@synerise/ds-utils": "^1.2.0",
37
+ "@synerise/ds-button": "^1.4.0",
38
+ "@synerise/ds-divider": "^1.0.11",
39
+ "@synerise/ds-icon": "^1.5.3",
40
+ "@synerise/ds-input": "^1.3.0",
41
+ "@synerise/ds-list-item": "^1.0.11",
42
+ "@synerise/ds-scrollbar": "^1.1.0",
43
+ "@synerise/ds-search": "^1.2.0",
44
+ "@synerise/ds-utils": "^1.3.0",
45
45
  "classnames": "2.3.2",
46
46
  "lodash.isequal": "^4.5.0"
47
47
  },
@@ -55,5 +55,5 @@
55
55
  "devDependencies": {
56
56
  "@types/lodash.isequal": "^4.5.8"
57
57
  },
58
- "gitHead": "93bc81d59d20bc8f3bc80c5d56ae7f7c0838380d"
58
+ "gitHead": "f2713cd35cfe22f63a159f05144585834897a132"
59
59
  }