@synerise/ds-collector 1.2.1 → 1.3.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/README.md CHANGED
@@ -41,6 +41,7 @@ import Collector from '@synerise/ds-collector'
41
41
  | addButtonProps | Props object applied to primary button | ButtonProps | - |
42
42
  | cancelButtonProps | Props object applied to secondary button | ButtonProps | - |
43
43
  | allowCustomValue | Enables an option to add value not included in the suggestions array | boolean | `false` |
44
+ | buttonPanelPrefix | content to render to the left of the add / cancel buttons | ReactNode | --- |
44
45
  | className | Class added to the parent container | string | --- |
45
46
  | description | Description rendered below the main component | string / React.ReactNode | --- |
46
47
  | disabled | Whether the component is disabled. | boolean | `false` |
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { CollectorProps } from './Collector.types';
2
+ import { type 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: 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, }: CollectorProps): React.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>;
@@ -49,8 +49,8 @@ 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: ({ values, onDeselect, disabled, focused, displayLookupKey }: import("./Elements/Values/Values.types").ValuesProps) => React.JSX.Element;
53
- ButtonPanel: React.FC<import("./Elements/ButtonPanel/ButtonPanel.types").ButtonPanelProps>;
52
+ Values: ({ values, onDeselect, disabled, focused, displayLookupKey, }: import("./Elements/Values/Values.types").ValuesProps) => React.JSX.Element;
53
+ ButtonPanel: ({ onConfirm, onCancel, disabled, showCancel, texts, addButtonProps, cancelButtonProps, buttonPanelPrefix, }: import("./Elements/ButtonPanel/ButtonPanel.types").ButtonPanelProps) => React.JSX.Element;
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>;
56
56
  };
package/dist/Collector.js CHANGED
@@ -1,15 +1,15 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useEffect, useMemo, useCallback, useRef, useState } from 'react';
3
2
  import classNames from 'classnames';
3
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import { FormattedMessage } from 'react-intl';
5
5
  import { focusWithArrowKeys, useOnClickOutside } from '@synerise/ds-utils';
6
6
  import * as S from './Collector.styles';
7
7
  import ButtonPanel from './Elements/ButtonPanel/ButtonPanel';
8
+ import NavigationHint from './Elements/NavigationHint/NavigationHint';
8
9
  import OptionsDropdown from './Elements/OptionsDropdown/OptionsDropdown';
9
- import { filterOutNullishArrayItems, filterValueSuggestions, isOverflown, scrollWithHorizontalArrow } from './utils';
10
10
  import Values from './Elements/Values/Values';
11
- import NavigationHint from './Elements/NavigationHint/NavigationHint';
12
11
  import { useTranslations } from './hooks/useTranslations';
12
+ import { 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 = ';';
@@ -18,6 +18,7 @@ var Collector = function Collector(_ref) {
18
18
  var allowCustomValue = _ref.allowCustomValue,
19
19
  allowMultipleValues = _ref.allowMultipleValues,
20
20
  addButtonProps = _ref.addButtonProps,
21
+ buttonPanelPrefix = _ref.buttonPanelPrefix,
21
22
  cancelButtonProps = _ref.cancelButtonProps,
22
23
  keepSearchQueryOnSelect = _ref.keepSearchQueryOnSelect,
23
24
  error = _ref.error,
@@ -153,7 +154,9 @@ var Collector = function Collector(_ref) {
153
154
  }
154
155
  }, [selectedValues, mainContentRef, fixedHeight]);
155
156
  useEffect(function () {
156
- if (!enableCustomFilteringSuggestions) filterSuggestions(value);
157
+ if (!enableCustomFilteringSuggestions) {
158
+ filterSuggestions(value);
159
+ }
157
160
  }, [value, selectedValues, filterSuggestions, enableCustomFilteringSuggestions]);
158
161
  useEffect(function () {
159
162
  setIsAddActive(Boolean(selected.length) || canCreateItemFromValue());
@@ -235,7 +238,7 @@ var Collector = function Collector(_ref) {
235
238
  var suggestionsIncludesCurrentValue = suggestionsIncludesItem(value);
236
239
  if (allowCustomValue || suggestionsIncludesCurrentValue) {
237
240
  var newValue = onItemAdd && onItemAdd(value);
238
- newValue && onConfirm && onConfirm([newValue]);
241
+ newValue && onConfirm([newValue]);
239
242
  clear();
240
243
  }
241
244
  }, [allowMultipleValues, suggestionsIncludesItem, value, allowCustomValue, createItem, selectedValues, onConfirm, clear, onItemAdd]);
@@ -260,7 +263,9 @@ var Collector = function Collector(_ref) {
260
263
  if (!isPasteEvent) {
261
264
  onSearchValueChange && onSearchValueChange(event.target.value);
262
265
  setValue(event.target.value);
263
- if (!enableCustomFilteringSuggestions) filterSuggestions(event.target.value);
266
+ if (!enableCustomFilteringSuggestions) {
267
+ filterSuggestions(event.target.value);
268
+ }
264
269
  }
265
270
  };
266
271
  useOnClickOutside(containerRef, function () {
@@ -343,7 +348,8 @@ var Collector = function Collector(_ref) {
343
348
  addButtonProps: _extends({
344
349
  disabled: !isAddActive
345
350
  }, addButtonProps),
346
- cancelButtonProps: cancelButtonProps
351
+ cancelButtonProps: cancelButtonProps,
352
+ buttonPanelPrefix: buttonPanelPrefix
347
353
  }))), /*#__PURE__*/React.createElement(OptionsDropdown, {
348
354
  options: filteredSuggestions,
349
355
  onItemAdd: addItem,
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { ContentAbove, Label, ContentBelow, Description, ErrorText, ValueText } from '@synerise/ds-input/dist/InputMultivalue/InputMultivalue.styles';
3
2
  import Button from '@synerise/ds-button';
3
+ import { ContentAbove, ContentBelow, Description, ErrorText, Label, ValueText } from '@synerise/ds-input/dist/InputMultivalue/InputMultivalue.styles';
4
4
  export declare const Container: import("styled-components").StyledComponent<"div", any, {}, never>;
5
5
  export declare const CollectorInput: import("styled-components").StyledComponent<"div", any, import("@synerise/ds-input/dist/InputMultivalue/InputMultivalue.styles").InputWrapperProps & {
6
6
  error?: boolean | undefined;
@@ -1,8 +1,8 @@
1
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
- import Value from '@synerise/ds-input/dist/InputMultivalue/Elements/Value';
5
2
  import Button from '@synerise/ds-button';
3
+ import Value from '@synerise/ds-input/dist/InputMultivalue/Elements/Value';
4
+ import { BorderLessInput, ContentAbove, ContentBelow, Description, ErrorText, IconWrapper, InputWrapper, Label, ValueText } from '@synerise/ds-input/dist/InputMultivalue/InputMultivalue.styles';
5
+ import DSScrollbar from '@synerise/ds-scrollbar';
6
6
  export var Container = styled.div.withConfig({
7
7
  displayName: "Collectorstyles__Container",
8
8
  componentId: "sc-14aly5p-0"
@@ -41,7 +41,7 @@ export var MainContent = styled.div.withConfig({
41
41
  export var RightSide = styled.div.withConfig({
42
42
  displayName: "Collectorstyles__RightSide",
43
43
  componentId: "sc-14aly5p-4"
44
- })(["display:flex;margin:0 4px;position:relative;.ds-button:not(:last-child){margin-right:8px;}&::before{content:", ";", " background-image:", ";position:absolute;left:-102px;}"], function (props) {
44
+ })(["display:flex;margin:0 4px;gap:8px;position:relative;&::before{content:", ";", " background-image:", ";position:absolute;left:-102px;}"], function (props) {
45
45
  return props.gradientOverlap ? "''" : 'none';
46
46
  }, gradientOverlayStyles(), function (props) {
47
47
  return "-webkit-linear-gradient( right,\n " + (props.focus ? props.theme.palette['blue-050'] : props.theme.palette.white) + " 0%,\n rgba(255,255,255,0) 100%\n )";
@@ -1,9 +1,10 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { ButtonProps } from '@synerise/ds-button';
3
3
  import type { ScrollbarAdditionalProps } from '@synerise/ds-scrollbar';
4
- import { DataAttributes } from '@synerise/ds-utils';
4
+ import type { DataAttributes } from '@synerise/ds-utils';
5
5
  export type CollectorProps = {
6
6
  addButtonProps?: Partial<ButtonProps & DataAttributes>;
7
+ buttonPanelPrefix?: ReactNode;
7
8
  allowCustomValue?: boolean;
8
9
  allowMultipleValues?: boolean;
9
10
  cancelButtonProps?: Partial<ButtonProps & DataAttributes>;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { ButtonPanelProps } from './ButtonPanel.types';
3
- declare const ButtonPanel: React.FC<ButtonPanelProps>;
2
+ import { type ButtonPanelProps } from './ButtonPanel.types';
3
+ declare const ButtonPanel: ({ onConfirm, onCancel, disabled, showCancel, texts, addButtonProps, cancelButtonProps, buttonPanelPrefix, }: ButtonPanelProps) => React.JSX.Element;
4
4
  export default ButtonPanel;
@@ -1,6 +1,7 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React from 'react';
3
3
  import Button from '@synerise/ds-button';
4
+ import * as S from './ButtonPanel.styles';
4
5
  var ButtonPanel = function ButtonPanel(_ref) {
5
6
  var onConfirm = _ref.onConfirm,
6
7
  onCancel = _ref.onCancel,
@@ -8,8 +9,13 @@ var ButtonPanel = function ButtonPanel(_ref) {
8
9
  showCancel = _ref.showCancel,
9
10
  texts = _ref.texts,
10
11
  addButtonProps = _ref.addButtonProps,
11
- cancelButtonProps = _ref.cancelButtonProps;
12
- return /*#__PURE__*/React.createElement(React.Fragment, null, showCancel && /*#__PURE__*/React.createElement(Button, _extends({
12
+ cancelButtonProps = _ref.cancelButtonProps,
13
+ buttonPanelPrefix = _ref.buttonPanelPrefix;
14
+ return /*#__PURE__*/React.createElement(React.Fragment, null, buttonPanelPrefix && /*#__PURE__*/React.createElement(S.ButtonPanelPrefix, {
15
+ onFocus: function onFocus(event) {
16
+ return event.stopPropagation();
17
+ }
18
+ }, buttonPanelPrefix), showCancel && /*#__PURE__*/React.createElement(Button, _extends({
13
19
  type: "ghost",
14
20
  disabled: disabled,
15
21
  onClick: onCancel,
@@ -0,0 +1 @@
1
+ export declare const ButtonPanelPrefix: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,5 @@
1
+ import styled from 'styled-components';
2
+ export var ButtonPanelPrefix = styled.div.withConfig({
3
+ displayName: "ButtonPanelstyles__ButtonPanelPrefix",
4
+ componentId: "sc-myq72p-0"
5
+ })([""]);
@@ -1,8 +1,10 @@
1
- import { CollectorTexts, CollectorProps } from '../../Collector.types';
1
+ import type { ReactNode } from 'react';
2
+ import type { CollectorProps, CollectorTexts } from '../../Collector.types';
2
3
  export type ButtonPanelProps = {
3
4
  onCancel: () => void;
4
5
  onConfirm: () => void;
5
6
  disabled: boolean;
6
7
  showCancel: boolean;
7
8
  texts: CollectorTexts;
9
+ buttonPanelPrefix?: ReactNode;
8
10
  } & Pick<CollectorProps, 'addButtonProps' | 'cancelButtonProps'>;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { NavigationHintProps } from './NavigationHint.types';
2
+ import { type NavigationHintProps } from './NavigationHint.types';
3
3
  declare const NavigationHint: React.FC<NavigationHintProps>;
4
4
  export default NavigationHint;
@@ -1,4 +1,4 @@
1
- import { CollectorTexts } from '../../Collector.types';
1
+ import { type CollectorTexts } from '../../Collector.types';
2
2
  export type NavigationHintProps = {
3
3
  texts: CollectorTexts;
4
4
  };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { OptionsDropdownProps } from './OptionsDropdown.types';
2
+ import { type OptionsDropdownProps } from './OptionsDropdown.types';
3
3
  declare const OptionsDropdown: ({ showAddButton, options, visible, value, onSelect, onClick, width, onItemAdd, showNavigationHints, lookupKey, texts, customContent, renderItem, dropdownItemHeight, scrollbarProps, listHeader, }: OptionsDropdownProps) => React.JSX.Element;
4
4
  export default OptionsDropdown;
@@ -1,14 +1,16 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useEffect, useState, useCallback } from 'react';
3
- import Scrollbar from '@synerise/ds-scrollbar';
4
- import SearchItems from '@synerise/ds-search/dist/Elements/SearchItems/SearchItems';
5
- import Icon, { Add3M } from '@synerise/ds-icon';
2
+ import React, { useCallback, useEffect, useState } from 'react';
6
3
  import Divider from '@synerise/ds-divider';
4
+ import Icon, { Add3M } from '@synerise/ds-icon';
7
5
  import ListItem from '@synerise/ds-list-item';
6
+ import Scrollbar from '@synerise/ds-scrollbar';
7
+ import SearchItems from '@synerise/ds-search/dist/Elements/SearchItems/SearchItems';
8
8
  import * as S from '../../Collector.styles';
9
9
  import NavigationHint from '../NavigationHint/NavigationHint';
10
10
  var getRowHeight = function getRowHeight(size) {
11
- if (size === 'large') return 54;
11
+ if (size === 'large') {
12
+ return 54;
13
+ }
12
14
  return 32;
13
15
  };
14
16
  var OptionsDropdown = function OptionsDropdown(_ref) {
@@ -1,6 +1,6 @@
1
- import React from 'react';
2
- import { ScrollbarAdditionalProps } from '@synerise/ds-scrollbar';
3
- import { CollectorTexts, CollectorValue } from '../../Collector.types';
1
+ import type React from 'react';
2
+ import { type ScrollbarAdditionalProps } from '@synerise/ds-scrollbar';
3
+ import { type CollectorTexts, type CollectorValue } from '../../Collector.types';
4
4
  export type OptionsDropdownProps = {
5
5
  showAddButton?: boolean;
6
6
  options: CollectorValue[];
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { ValuesProps } from './Values.types';
3
- export declare const Values: ({ values, onDeselect, disabled, focused, displayLookupKey }: ValuesProps) => React.JSX.Element;
2
+ import { type ValuesProps } from './Values.types';
3
+ 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
- export var Values = function Values(_ref) {
3
+ var Values = function Values(_ref) {
4
4
  var values = _ref.values,
5
5
  onDeselect = _ref.onDeselect,
6
6
  disabled = _ref.disabled,
@@ -8,7 +8,6 @@ export var Values = function Values(_ref) {
8
8
  displayLookupKey = _ref.displayLookupKey;
9
9
  return /*#__PURE__*/React.createElement(React.Fragment, null, values.map(function (val, index) {
10
10
  return /*#__PURE__*/React.createElement(S.CollectorValue, {
11
- // eslint-disable-next-line react/no-array-index-key
12
11
  key: val + "-" + index,
13
12
  onRemoveClick: function onRemoveClick() {
14
13
  onDeselect && onDeselect(val);
@@ -1,4 +1,4 @@
1
- import { CollectorValue } from '../../Collector.types';
1
+ import { type CollectorValue } from '../../Collector.types';
2
2
  export type ValuesProps = {
3
3
  values: CollectorValue[];
4
4
  onDeselect?: (value: CollectorValue) => void;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { default } from './Collector';
2
- export type { CollectorValue, CollectorProps, CollectorValuesSeparator, CollectorTexts } from './Collector.types';
2
+ export type { CollectorValue, CollectorProps, CollectorValuesSeparator, CollectorTexts, } from './Collector.types';
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import React from 'react';
2
- import { CollectorValue } from './Collector.types';
1
+ import type React from 'react';
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 filterOutNullishArrayItems: <T extends unknown>(array: ("" | T | null | undefined)[]) => T[];
4
+ export declare const filterOutNullishArrayItems: <T>(array: ("" | T | null | undefined)[]) => T[];
5
5
  export declare const isOverflown: (elementRef: React.RefObject<HTMLDivElement>) => boolean;
6
6
  export declare const filterValueSuggestions: (suggestions: CollectorValue[], selected: CollectorValue[], searchValue: string, lookupKey: string) => CollectorValue[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-collector",
3
- "version": "1.2.1",
3
+ "version": "1.3.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.4.1",
38
- "@synerise/ds-divider": "^1.0.12",
39
- "@synerise/ds-icon": "^1.5.3",
40
- "@synerise/ds-input": "^1.3.1",
41
- "@synerise/ds-list-item": "^1.0.12",
42
- "@synerise/ds-scrollbar": "^1.1.1",
43
- "@synerise/ds-search": "^1.2.1",
44
- "@synerise/ds-utils": "^1.3.0",
37
+ "@synerise/ds-button": "^1.4.2",
38
+ "@synerise/ds-divider": "^1.0.13",
39
+ "@synerise/ds-icon": "^1.5.4",
40
+ "@synerise/ds-input": "^1.3.2",
41
+ "@synerise/ds-list-item": "^1.0.13",
42
+ "@synerise/ds-scrollbar": "^1.1.2",
43
+ "@synerise/ds-search": "^1.2.2",
44
+ "@synerise/ds-utils": "^1.3.1",
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": "11fe1d29b2ac23e70c3d5e6ce8ae20201a619a34"
58
+ "gitHead": "2161bdb04f3db0f79b7d0465ce6b41121f1543ef"
59
59
  }