@synerise/ds-autocomplete 1.0.4 → 1.1.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 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.1.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-autocomplete@1.1.0...@synerise/ds-autocomplete@1.1.1) (2025-04-24)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-autocomplete
9
+
10
+
11
+
12
+
13
+
14
+ # [1.1.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-autocomplete@1.0.4...@synerise/ds-autocomplete@1.1.0) (2025-04-16)
15
+
16
+
17
+ ### Features
18
+
19
+ * **form-field:** add form-field component ([7f6b191](https://github.com/Synerise/synerise-design/commit/7f6b191132a3b0d694c21fb4d649f4deea6acb89))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [1.0.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-autocomplete@1.0.3...@synerise/ds-autocomplete@1.0.4) (2025-04-02)
7
26
 
8
27
  **Note:** Version bump only for package @synerise/ds-autocomplete
package/README.md CHANGED
@@ -30,18 +30,18 @@ import Autocomplete from '@synerise/ds-autocomplete'
30
30
 
31
31
  | Property | Description | Type | Default |
32
32
  | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
33
- | allowClear | Show clear button, effective in multiple mode only. | boolean |`false` |
34
- | autoFocus | get focus when component mounted | boolean |`false` |
35
- | backfill | backfill selected item the input when using keyboard | boolean |`false` |
36
- | children (for customize input element) | customize input element | `HTMLInputElement HTMLTextAreaElement React.ReactElement<InputProps>` | <Input /> |
37
- | children (for dataSource) | Data source to auto complete | `React.ReactElement<OptionProps> Array<React.ReactElement<OptionProps>>` | - |
33
+ | allowClear | Show clear button, effective in multiple mode only. | boolean | `false` |
34
+ | autoFocus | get focus when component mounted | boolean | `false` |
35
+ | backfill | backfill selected item the input when using keyboard | boolean | `false` |
36
+ | children (for customize input element) | customize input element | `HTMLInputElement HTMLTextAreaElement React.ReactElement<InputProps>` | <Input /> |
37
+ | children (for dataSource) | Data source to auto complete | `React.ReactElement<OptionProps> Array<React.ReactElement<OptionProps>>` | - |
38
38
  | dataSource | Data source for autocomplete | DataSourceItemType[] | - |
39
39
  | dropdownMenuStyle | additional style applied to dropdown menu | object | |
40
- | defaultActiveFirstOption | Whether active first option by default | boolean | `true` |
40
+ | defaultActiveFirstOption | Whether active first option by default | boolean | `true` |
41
41
  | defaultValue | Initial selected option. | string or string[] | - |
42
- | disabled | Whether disabled select | boolean |- |
43
- | readonly | Whether disabled select with readonly styles applied | boolean | - |
44
- | filterOption | If true, filter options by input, if function, filter options against it. The function will receive two arguments, inputValue and option, if the function returns true, the option will be included in the filtered set; Otherwise, it will be excluded. | boolean or function(inputValue, option) | `true` |
42
+ | disabled | Whether disabled select | boolean | - |
43
+ | readonly | Whether disabled select with readonly styles applied | boolean | - |
44
+ | filterOption | If true, filter options by input, if function, filter options against it. The function will receive two arguments, inputValue and option, if the function returns true, the option will be included in the filtered set; Otherwise, it will be excluded. | boolean or function(inputValue, option) | `true` |
45
45
  | optionLabelProp | Which prop value of option will render as content of select. | string | children |
46
46
  | placeholder | placeholder of input | string | - |
47
47
  | value | selected option | string or string[] or { key: string, label: string or ReactNode } or Array<{ key: string, label: string or ReactNode }> | - |
@@ -54,29 +54,30 @@ import Autocomplete from '@synerise/ds-autocomplete'
54
54
  | open | Controlled open state of dropdown | boolean | - |
55
55
  | onDropdownVisibleChange | Call when dropdown open | function(open) | - |
56
56
  | getPopupContainer | Parent Node which the selector should be rendered to. Default to body. When position issues happen, try to modify it into scrollable content and position it relative. | function(triggerNode) | document.querySelector(`.ant-select-auto-complete`) |
57
- | errorText | error message, if provided input will be set in error state | string | - |
58
- | label | input label | string | - |
59
- | description | input description | string | - |
60
- | autoResize | 'resize' width of the input based on width of the text in input | AutoResizeProp | undefined |
61
-
57
+ | errorText | error message, if provided input will be set in error state | ReactNode | - |
58
+ | label | input label | ReactNode | - |
59
+ | tooltip | label tooltip text | ReactNode | - |
60
+ | tooltipConfig | label tooltip additional config | TooltipProps see ds-tooltip | - |
61
+ | description | input description | ReactNode | - |
62
+ | autoResize | 'resize' width of the input based on width of the text in input | AutoResizeProp | undefined |
62
63
 
63
64
  #### AutoResizeProp
64
65
 
65
66
  ```
66
67
  type AutoResizeProp = `boolean` | {
67
- minWidth: string;
68
- maxWidth?: string;
69
- stretchToFit?: boolean
68
+ minWidth: string;
69
+ maxWidth?: string;
70
+ stretchToFit?: boolean
70
71
  };
71
72
  ```
72
73
 
73
74
  Setting `stretchToFit: true` will make the field stretch to fit the containing element. The component observes the width of the wrapper and adjusts the maxWidth accordingly.
74
- **Important** if the Input is within a flex-item then there is necessary CSS that needs to be applied to the flex-item containers in order for the flex-item to grow to fill the allowed space, but at the same time not stretch the flex container (identical issue happens when text-overflow needs to happen inside a flex-item).
75
+ **Important** if the Input is within a flex-item then there is necessary CSS that needs to be applied to the flex-item containers in order for the flex-item to grow to fill the allowed space, but at the same time not stretch the flex container (identical issue happens when text-overflow needs to happen inside a flex-item).
75
76
 
76
77
  ```css
77
78
  $flexItemSurroundingTheInput {
78
- min-width: 0;
79
- flex-grow: 1
79
+ min-width: 0;
80
+ flex-grow: 1;
80
81
  }
81
82
  ```
82
83
 
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import './style/index.less';
3
3
  import { AutocompleteProps } from './Autocomplete.types';
4
4
  declare const Autocomplete: {
5
- (props: AutocompleteProps): React.JSX.Element;
5
+ ({ className, label, description, errorText, disabled, error, handleInputRef, getPopupContainer, autoResize, readOnly, tooltip, tooltipConfig, ...rest }: AutocompleteProps): React.JSX.Element;
6
6
  Option: import("rc-select/lib/Option").OptionFC;
7
7
  };
8
8
  export default Autocomplete;
@@ -1,26 +1,28 @@
1
- var _excluded = ["className", "label", "description", "errorText", "disabled", "error", "handleInputRef", "getPopupContainer", "autoResize", "readOnly"];
2
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
1
+ var _excluded = ["className", "label", "description", "errorText", "disabled", "error", "handleInputRef", "getPopupContainer", "autoResize", "readOnly", "tooltip", "tooltipConfig"];
2
+ 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); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
4
  import React, { useRef, useEffect, useCallback } from 'react';
5
5
  import "./style/index.css";
6
6
  import AntdAutoComplete from 'antd/lib/auto-complete';
7
- import { ErrorText, Description, Label } from '@synerise/ds-typography';
7
+ import FormField from '@synerise/ds-form-field';
8
8
  import { AutosizeWrapper } from '@synerise/ds-input';
9
9
  import { useResizeObserver } from '@synerise/ds-utils';
10
10
  import * as S from './Autocomplete.styles';
11
11
  var AUTOSIZE_EXTRA_WIDTH = 27;
12
- var Autocomplete = function Autocomplete(props) {
13
- var className = props.className,
14
- label = props.label,
15
- description = props.description,
16
- errorText = props.errorText,
17
- disabled = props.disabled,
18
- error = props.error,
19
- handleInputRef = props.handleInputRef,
20
- getPopupContainer = props.getPopupContainer,
21
- autoResize = props.autoResize,
22
- readOnly = props.readOnly,
23
- rest = _objectWithoutPropertiesLoose(props, _excluded);
12
+ var Autocomplete = function Autocomplete(_ref) {
13
+ var className = _ref.className,
14
+ label = _ref.label,
15
+ description = _ref.description,
16
+ errorText = _ref.errorText,
17
+ disabled = _ref.disabled,
18
+ error = _ref.error,
19
+ handleInputRef = _ref.handleInputRef,
20
+ getPopupContainer = _ref.getPopupContainer,
21
+ autoResize = _ref.autoResize,
22
+ readOnly = _ref.readOnly,
23
+ tooltip = _ref.tooltip,
24
+ tooltipConfig = _ref.tooltipConfig,
25
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
24
26
  var scrollLeftRef = useRef(0);
25
27
  var antSelectRef = useRef(null);
26
28
  var inputRef = useRef(null);
@@ -40,7 +42,7 @@ var Autocomplete = function Autocomplete(props) {
40
42
  return triggerNode.parentNode;
41
43
  };
42
44
  var stretchToFit = autoResize && autoResize !== true && Boolean(autoResize.stretchToFit);
43
- var placeholder = typeof rest.placeholder === 'string' ? rest.placeholder : undefined;
45
+ var placeholderString = typeof rest.placeholder === 'string' ? rest.placeholder : undefined;
44
46
  var handlePreAutosize = useCallback(function () {
45
47
  var _inputRef$current;
46
48
  scrollLeftRef.current = ((_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.scrollLeft) || 0;
@@ -66,13 +68,19 @@ var Autocomplete = function Autocomplete(props) {
66
68
  ref: elementRef,
67
69
  autoResize: autoResize,
68
70
  className: "ds-autocomplete " + (className || '')
69
- }, label && /*#__PURE__*/React.createElement(S.LabelWrapper, null, /*#__PURE__*/React.createElement(Label, null, label)), /*#__PURE__*/React.createElement(S.ComponentWrapper, {
71
+ }, /*#__PURE__*/React.createElement(FormField, {
72
+ label: label,
73
+ tooltip: tooltip,
74
+ tooltipConfig: tooltipConfig,
75
+ description: description,
76
+ errorText: errorText
77
+ }, /*#__PURE__*/React.createElement(S.ComponentWrapper, {
70
78
  readOnly: readOnly,
71
79
  error: !!errorText || error
72
80
  }, /*#__PURE__*/React.createElement(AutosizeWrapper, {
73
81
  autoResize: !!autoResize,
74
82
  value: rest.value,
75
- placeholder: placeholder,
83
+ placeholder: placeholderString,
76
84
  transformRef: transformRef,
77
85
  ref: autosizeRef,
78
86
  extraWidth: AUTOSIZE_EXTRA_WIDTH,
@@ -84,9 +92,7 @@ var Autocomplete = function Autocomplete(props) {
84
92
  getPopupContainer: getPopupContainer || getParentNode,
85
93
  ref: antSelectRef,
86
94
  "data-testid": "autocomplete-autosize-input"
87
- })))), errorText && /*#__PURE__*/React.createElement(S.ErrorWrapper, null, /*#__PURE__*/React.createElement(ErrorText, null, errorText)), description && /*#__PURE__*/React.createElement(S.DescWrapper, null, description && /*#__PURE__*/React.createElement(Description, {
88
- disabled: disabled
89
- }, description)));
95
+ }))))));
90
96
  };
91
97
  Autocomplete.Option = AntdAutoComplete.Option;
92
98
  export default Autocomplete;
@@ -1,8 +1,4 @@
1
1
  import { AutoResizeProp } from '@synerise/ds-input';
2
- export declare const LabelWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- export declare const ErrorWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
4
- export declare const DescWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
5
- export declare const LoaderWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
6
2
  export declare const AutocompleteWrapper: import("styled-components").StyledComponent<"div", any, {
7
3
  autoResize?: AutoResizeProp | undefined;
8
4
  }, never>;
@@ -1,22 +1,6 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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 styled, { css } from 'styled-components';
3
3
  import { autoresizeConfObjToCss } from '@synerise/ds-input/dist/Input.styles';
4
- export var LabelWrapper = styled.div.withConfig({
5
- displayName: "Autocompletestyles__LabelWrapper",
6
- componentId: "sc-10de6ms-0"
7
- })(["margin:0px 0px 8px 0px;"]);
8
- export var ErrorWrapper = styled.div.withConfig({
9
- displayName: "Autocompletestyles__ErrorWrapper",
10
- componentId: "sc-10de6ms-1"
11
- })(["margin:8px 0px 4px 0px;"]);
12
- export var DescWrapper = styled.div.withConfig({
13
- displayName: "Autocompletestyles__DescWrapper",
14
- componentId: "sc-10de6ms-2"
15
- })(["margin:8px 0px 0px 0px;"]);
16
- export var LoaderWrapper = styled.div.withConfig({
17
- displayName: "Autocompletestyles__LoaderWrapper",
18
- componentId: "sc-10de6ms-3"
19
- })(["margin-right:10px;"]);
20
4
  var active = function active() {
21
5
  return css(["transition:ease-in-out all 0.2s,width 0s,min-width 0s,max-width 0s;box-shadow:inset 0 0 0 1px ", ";border:1px solid ", ";background-color:", ";"], function (props) {
22
6
  return props.theme.palette['blue-600'];
@@ -44,7 +28,7 @@ var readonly = function readonly() {
44
28
  };
45
29
  export var AutocompleteWrapper = styled.div.withConfig({
46
30
  displayName: "Autocompletestyles__AutocompleteWrapper",
47
- componentId: "sc-10de6ms-4"
31
+ componentId: "sc-10de6ms-0"
48
32
  })(["input{font-feature-settings:'tnum';}.ant-select-auto-complete{width:", ";", ";grid-area:1 / 1;}.ant-select > span{position:absolute;left:0;top:0;}.ant-select-dropdown{.ant-select-selection__rendered{margin:0;}.ant-select-selection:hover .ant-select-selection__rendered{margin-right:10px;}.ant-select-selection__clear{font-size:15px;color:", ";width:16px;height:16px;margin-top:-7px;}&.ant-select:not(.ant-select-no-arrow) .ant-select-selection__clear{right:12px;&:hover{color:", ";}}.ant-select-dropdown-menu-item{font-weight:normal;strong{font-weight:500;}}}.ant-select-selection-search-input{padding:0;}"], function (props) {
49
33
  return props.autoResize ? '100%' : '200px';
50
34
  }, function (props) {
@@ -58,7 +42,7 @@ export var AutocompleteWrapper = styled.div.withConfig({
58
42
  });
59
43
  export var ComponentWrapper = styled.div.withConfig({
60
44
  displayName: "Autocompletestyles__ComponentWrapper",
61
- componentId: "sc-10de6ms-5"
45
+ componentId: "sc-10de6ms-1"
62
46
  })(["&&&{.ant-select-auto-complete{", "}}}"], function (props) {
63
47
  if (props.readOnly) {
64
48
  return css([".ant-select-selector{&:hover{", "}", "}"], readonly(), readonly());
@@ -1,17 +1,14 @@
1
- import type { ReactNode, MutableRefObject } from 'react';
1
+ import type { MutableRefObject } from 'react';
2
2
  import type { AutoCompleteProps as OriginalProps } from 'antd/lib/auto-complete';
3
3
  import type { RefSelectProps } from 'antd/lib/select';
4
4
  import type { AutoResizeProp } from '@synerise/ds-input';
5
- export type OverrideProps = {
5
+ import type { FormFieldCommonProps } from '@synerise/ds-form-field';
6
+ export type OverrideProps = FormFieldCommonProps & {
6
7
  className?: string;
7
- errorText?: ReactNode;
8
- label?: ReactNode;
9
- description?: ReactNode;
10
8
  error?: boolean;
11
9
  getPopupContainer?: (node: HTMLElement) => HTMLElement;
12
10
  readOnly?: boolean;
13
11
  handleInputRef?: (ref: MutableRefObject<RefSelectProps | null>) => void;
14
12
  autoResize?: AutoResizeProp;
15
- placeholder?: ReactNode;
16
13
  };
17
- export type AutocompleteProps = OverrideProps & OriginalProps;
14
+ export type AutocompleteProps = OverrideProps & Omit<OriginalProps, 'tagRender' | 'fieldNames' | 'filterSort' | 'filterOption' | 'tokenSeparators' | 'transitionName' | 'showArrow' | 'animation' | 'searchValue' | 'showArrow' | 'listItemHeight' | 'menuItemSelectedIcon' | 'maxTagCount' | 'maxTagPlaceholder' | 'maxTagTextLength' | 'fieldNames' | 'filterOption' | 'backfill' | 'bordered' | 'choiceTransitionName' | 'showSearch'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-autocomplete",
3
- "version": "1.0.4",
3
+ "version": "1.1.1",
4
4
  "description": "Autocomplete UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -34,8 +34,8 @@
34
34
  ],
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
- "@synerise/ds-input": "^1.0.4",
38
- "@synerise/ds-typography": "^1.0.4",
37
+ "@synerise/ds-form-field": "^1.1.1",
38
+ "@synerise/ds-input": "^1.1.1",
39
39
  "@synerise/ds-utils": "^1.0.1"
40
40
  },
41
41
  "peerDependencies": {
@@ -44,5 +44,5 @@
44
44
  "react": ">=16.9.0 <= 18.3.1",
45
45
  "styled-components": "^5.3.3"
46
46
  },
47
- "gitHead": "dc78b03be09e793ec84f1dafc59c5616e77f1196"
47
+ "gitHead": "fc601270d3c84a5a52b62473a01f1b3c1c7014a7"
48
48
  }