@synerise/ds-autocomplete 0.4.29 → 0.4.30
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 +14 -0
- package/README.md +1 -0
- package/dist/Autocomplete.js +29 -9
- package/dist/Autocomplete.styles.d.ts +12 -1
- package/dist/Autocomplete.styles.js +16 -1
- package/dist/Autocomplete.types.d.ts +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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.4.30](https://github.com/Synerise/synerise-design/compare/@synerise/ds-autocomplete@0.4.29...@synerise/ds-autocomplete@0.4.30) (2022-11-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **autocomplete:** add autoresize to autocomplete ([83d19db](https://github.com/Synerise/synerise-design/commit/83d19dbd0d2e764c84ec7a6337c7f7a8b0264e56))
|
|
12
|
+
* **autocomplete:** fix width of autocomplete ([2dd5aa3](https://github.com/Synerise/synerise-design/commit/2dd5aa3a6e694b341b17c40fcf2ebd605944fb3a))
|
|
13
|
+
* **autocomplete:** fixes to styles and add new story with AutoResize ([aae1581](https://github.com/Synerise/synerise-design/commit/aae15810b4ecab281382f094c203778c99c77f15))
|
|
14
|
+
* **autocomplete:** new prop to control width of autocomplete ([dc60e3b](https://github.com/Synerise/synerise-design/commit/dc60e3b774ee6144201a5c5f9c4911fbeb1b0954))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
6
20
|
## [0.4.29](https://github.com/Synerise/synerise-design/compare/@synerise/ds-autocomplete@0.4.28...@synerise/ds-autocomplete@0.4.29) (2022-10-24)
|
|
7
21
|
|
|
8
22
|
**Note:** Version bump only for package @synerise/ds-autocomplete
|
package/README.md
CHANGED
|
@@ -56,3 +56,4 @@ import Autocomplete from '@synerise/ds-autocomplete'
|
|
|
56
56
|
| errorText | error message, if provided input will be set in error state | string | - |
|
|
57
57
|
| label | input label | string | - |
|
|
58
58
|
| description | input description | string | - |
|
|
59
|
+
| autoResize | 'resize' width of the input based on width of the text in input | boolean / { minWidth: string; maxWidth: string } | `false` | minWidth: '', maxWidth: '' |
|
package/dist/Autocomplete.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
var _excluded = ["className", "label", "description", "errorText", "disabled", "error", "handleInputRef", "autoResize"];
|
|
2
|
+
|
|
1
3
|
function _extends() { _extends = Object.assign || 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); }
|
|
2
4
|
|
|
5
|
+
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; }
|
|
6
|
+
|
|
3
7
|
import * as React from 'react';
|
|
4
8
|
import '@synerise/ds-core/dist/js/style';
|
|
5
9
|
import "./style/index.css";
|
|
6
10
|
import AntdAutoComplete from 'antd/lib/auto-complete';
|
|
7
11
|
import { ErrorText, Description, Label } from '@synerise/ds-typography';
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
import { AutoResize, WrapperAutoResize } from '@synerise/ds-input';
|
|
8
15
|
import * as S from './Autocomplete.styles';
|
|
9
16
|
|
|
10
17
|
var Autocomplete = function Autocomplete(props) {
|
|
@@ -14,21 +21,34 @@ var Autocomplete = function Autocomplete(props) {
|
|
|
14
21
|
errorText = props.errorText,
|
|
15
22
|
disabled = props.disabled,
|
|
16
23
|
error = props.error,
|
|
17
|
-
handleInputRef = props.handleInputRef
|
|
24
|
+
handleInputRef = props.handleInputRef,
|
|
25
|
+
autoResize = props.autoResize,
|
|
26
|
+
antdAutocompleteProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
27
|
+
|
|
18
28
|
var inputRef = React.useRef(undefined);
|
|
19
29
|
React.useEffect(function () {
|
|
20
30
|
handleInputRef && handleInputRef(inputRef);
|
|
21
31
|
}, [inputRef, handleInputRef]);
|
|
32
|
+
|
|
33
|
+
var renderAutoCompleteComponent = function renderAutoCompleteComponent() {
|
|
34
|
+
return /*#__PURE__*/React.createElement(AntdAutoComplete // eslint-disable-next-line react/jsx-props-no-spreading
|
|
35
|
+
, _extends({}, props, {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
ref: inputRef,
|
|
39
|
+
dropdownClassName: "ds-autocomplete-dropdown",
|
|
40
|
+
className: !!errorText || error ? 'error' : undefined
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
|
|
22
44
|
return /*#__PURE__*/React.createElement(S.AutocompleteWrapper, {
|
|
45
|
+
autoResize: autoResize,
|
|
23
46
|
className: "ds-autocomplete " + (className || '')
|
|
24
|
-
}, label && /*#__PURE__*/React.createElement(S.LabelWrapper, null, /*#__PURE__*/React.createElement(Label, null, label)), /*#__PURE__*/React.createElement(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
dropdownClassName: "ds-autocomplete-dropdown",
|
|
30
|
-
className: !!errorText || error ? 'error' : undefined
|
|
31
|
-
})), 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, {
|
|
47
|
+
}, label && /*#__PURE__*/React.createElement(S.LabelWrapper, null, /*#__PURE__*/React.createElement(Label, null, label)), autoResize ? /*#__PURE__*/React.createElement(WrapperAutoResize, {
|
|
48
|
+
autoResize: autoResize
|
|
49
|
+
}, renderAutoCompleteComponent(), /*#__PURE__*/React.createElement(AutoResize, {
|
|
50
|
+
autoResize: autoResize
|
|
51
|
+
}, antdAutocompleteProps.value)) : renderAutoCompleteComponent(), 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, {
|
|
32
52
|
disabled: disabled
|
|
33
53
|
}, description)));
|
|
34
54
|
};
|
|
@@ -2,4 +2,15 @@ export declare const LabelWrapper: import("styled-components").StyledComponent<"
|
|
|
2
2
|
export declare const ErrorWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
3
|
export declare const DescWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
4
|
export declare const LoaderWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
-
export declare
|
|
5
|
+
export declare type AutoResizeProps = {
|
|
6
|
+
autoResize?: boolean | {
|
|
7
|
+
minWidth: string;
|
|
8
|
+
maxWidth: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const AutocompleteWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
12
|
+
autoResize?: boolean | {
|
|
13
|
+
minWidth: string;
|
|
14
|
+
maxWidth: string;
|
|
15
|
+
} | undefined;
|
|
16
|
+
}, never>;
|
|
@@ -36,10 +36,25 @@ var error = function error() {
|
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
function autoresizeConfObjToCss(_ref) {
|
|
40
|
+
var autoResize = _ref.autoResize;
|
|
41
|
+
if (!autoResize) return '';
|
|
42
|
+
|
|
43
|
+
if (typeof autoResize === 'object') {
|
|
44
|
+
return "max-width: " + autoResize.maxWidth + "; min-width: " + autoResize.minWidth;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return "max-width: 400px; min-width: 150px;";
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
export var AutocompleteWrapper = styled.div.withConfig({
|
|
40
51
|
displayName: "Autocompletestyles__AutocompleteWrapper",
|
|
41
52
|
componentId: "sc-10de6ms-4"
|
|
42
|
-
})([".ant-select-dropdown{&.ant-select{.ant-input{transition:ease-in-out all 0.3s;&:focus{", " &:hover{", "}}}}&.error{.ant-select-selector{&:hover{", "}", "}}.ant-select-selection__rendered{margin:0;}.ant-select-selection:hover .ant-select-selection__rendered{margin-right:10px;}&.ant-select .ant-input{padding:8px 12px;}.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-selection-placeholder{padding-left:3px;}.ant-select-dropdown{padding:8px;}.ant-select-dropdown-menu-item{font-weight:normal;strong{font-weight:500;}}}.ant-select-selection-search-input{padding:0;}"],
|
|
53
|
+
})([".ant-select-auto-complete{width:", ";", ";grid-area:1 / 1;}.ant-select-dropdown{&.ant-select{.ant-input{transition:ease-in-out all 0.3s;&:focus{", " &:hover{", "}}}}&.error{.ant-select-selector{&:hover{", "}", "}}.ant-select-selection__rendered{margin:0;}.ant-select-selection:hover .ant-select-selection__rendered{margin-right:10px;}&.ant-select .ant-input{padding:8px 12px;}.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-selection-placeholder{padding-left:3px;}.ant-select-dropdown{padding:8px;}.ant-select-dropdown-menu-item{font-weight:normal;strong{font-weight:500;}}}.ant-select-selection-search-input{padding:0;}"], function (props) {
|
|
54
|
+
return props.autoResize ? '100%' : '200px';
|
|
55
|
+
}, function (props) {
|
|
56
|
+
return autoresizeConfObjToCss(props);
|
|
57
|
+
}, active(), active(), error(), error(), function (props) {
|
|
43
58
|
return props.theme.palette['grey-600'];
|
|
44
59
|
}, function (props) {
|
|
45
60
|
return props.theme.palette['grey-700'];
|
|
@@ -8,6 +8,10 @@ export declare type OverrideProps = {
|
|
|
8
8
|
description?: React.ReactNode | string;
|
|
9
9
|
error?: boolean;
|
|
10
10
|
handleInputRef?: (ref: React.MutableRefObject<Select | undefined>) => void;
|
|
11
|
+
autoResize?: boolean | {
|
|
12
|
+
minWidth: string;
|
|
13
|
+
maxWidth: string;
|
|
14
|
+
};
|
|
11
15
|
};
|
|
12
16
|
export interface StaticComponents {
|
|
13
17
|
Option: typeof AntdAutoComplete.Option;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-autocomplete",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.30",
|
|
4
4
|
"description": "Autocomplete UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@synerise/ds-utils": "^0.23.2"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "c1fdb8f769bf8c3a529d877a6bd9942a380c3e17"
|
|
45
45
|
}
|