@synerise/ds-input 0.19.19 → 0.20.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
+ ## [0.20.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@0.20.0...@synerise/ds-input@0.20.1) (2024-03-18)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-input
9
+
10
+
11
+
12
+
13
+
14
+ # [0.20.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@0.19.19...@synerise/ds-input@0.20.0) (2024-03-05)
15
+
16
+
17
+ ### Features
18
+
19
+ * **input:** support autoresize to stretch to parent ([329c866](https://github.com/synerise/synerise-design/commit/329c866cb54921ad1260ae217cb8c471e43b986e))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.19.19](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@0.19.18...@synerise/ds-input@0.19.19) (2024-02-21)
7
26
 
8
27
  **Note:** Version bump only for package @synerise/ds-input
package/README.md CHANGED
@@ -19,7 +19,7 @@ Input UI Component
19
19
 
20
20
  ## API
21
21
 
22
- #### Input
22
+ ### Input
23
23
 
24
24
  | Property | Description | Type | Default |
25
25
  | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- | --------- |
@@ -46,9 +46,32 @@ Input UI Component
46
46
  | tooltipConfig | Config of tooltip | [TooltipProps](https://design.synerise.com/docs/components/tooltip#api) | - |
47
47
  | type | The type of input, see: [MDN](https://developer.mozilla.org/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types)(use `Input.TextArea` instead of `type="textarea"`) | string | `text` |
48
48
  | value | The input content value | string | |
49
- | autoResize | 'resize' width of the input based on width of the text in input | boolean | `false` |
49
+ | autoResize | 'resize' width of the input based on width of the text in input | AutoResizeProp (see below) | `undefined` |
50
50
 
51
- #### MaskedInput
51
+ #### AutoResizeProp
52
+
53
+ ```
54
+ type AutoResizeProp = `boolean` | {
55
+ minWidth: string;
56
+ maxWidth?: string;
57
+ stretchToFit?: boolean
58
+ };
59
+ ```
60
+
61
+ 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.
62
+ **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).
63
+
64
+ ```css
65
+ $flexItemSurroundingTheInput {
66
+ min-width: 0;
67
+ flex-grow: 1
68
+ }
69
+ ```
70
+
71
+ See https://css-tricks.com/flexbox-truncated-text/ for more details.
72
+
73
+
74
+ ### MaskedInput
52
75
 
53
76
  Same as Input api with additional props:
54
77
 
@@ -58,7 +81,7 @@ Same as Input api with additional props:
58
81
  | placeholderChar | Customized placeholder character used to fill in editable parts of the pattern. | string | '\_' |
59
82
  | formatCharacters | Customized format character definitions for use in the pattern. | Object (https://github.com/insin/inputmask-core#formatcharacters) | - |
60
83
 
61
- #### InputGroup
84
+ ### InputGroup
62
85
 
63
86
  | Property | Description | Type | Default |
64
87
  | -------- | ------------------------------------------------------------------------------------------------------- | ------- | ------- |
package/dist/Input.d.ts CHANGED
@@ -1,26 +1,30 @@
1
1
  import React, { ReactElement } from 'react';
2
+ import { StyledComponent } from 'styled-components';
3
+ import { InputProps as AntdInputProps } from 'antd/lib/input';
4
+ import AntdMaskedInput from 'antd-mask-input';
2
5
  import '@synerise/ds-core/dist/js/style';
3
- import { InputProps, TextAreaProps } from 'antd/lib/input';
4
6
  import './style/index.less';
5
- import { StyledComponent } from 'styled-components';
6
- import { EnhancedProps, Props } from './Input.types';
7
- export declare const TextArea: React.ComponentType<object & EnhancedProps> & {
8
- displayName: string;
9
- };
10
- export declare const Input: React.ComponentType<object & EnhancedProps> & {
11
- displayName: string;
12
- };
13
- export declare const MaskedInput: React.ComponentType<object & EnhancedProps> & {
14
- displayName: string;
15
- };
16
- export declare const RawMaskedInput: StyledComponent<React.ForwardRefExoticComponent<{
17
- error?: boolean | undefined;
7
+ import { BaseProps, InputProps as DSInputProps, TextareaProps } from './Input.types';
8
+ export declare const Input: React.ComponentType<BaseProps<HTMLInputElement> & AntdInputProps>;
9
+ export declare const MaskedInput: React.ComponentType<BaseProps<HTMLInputElement> & AntdInputProps & {
18
10
  mask: string;
19
- } & React.RefAttributes<import("antd-mask-input/build/main/lib/MaskedInput").default>>, any, {
11
+ formatCharacters?: object | undefined;
12
+ placeholderChar?: string | undefined;
13
+ value?: string | undefined;
14
+ }>;
15
+ export declare const TextArea: ({ className, errorText, label, description, counterLimit, tooltip, tooltipConfig, icon1, icon1Tooltip, autoResize, icon2, icon2Tooltip, resetMargin, handleInputRef, prefixel, suffixel, error, ...antdTextareaProps }: TextareaProps) => JSX.Element;
16
+ export declare const RawMaskedInput: StyledComponent<React.ForwardRefExoticComponent<AntdInputProps & {
17
+ mask: string;
18
+ formatCharacters?: object | undefined;
19
+ placeholderChar?: string | undefined;
20
+ value?: string | undefined;
21
+ } & {
22
+ error?: boolean | undefined;
23
+ } & React.RefAttributes<AntdMaskedInput>>, any, {
20
24
  error?: boolean | undefined;
21
25
  }, never>;
22
26
  export { default as InputGroup } from './InputGroup';
23
- export declare const RawInput: (props: Props & (InputProps | TextAreaProps)) => ReactElement;
27
+ export declare const RawInput: (props: DSInputProps) => ReactElement;
24
28
  export declare const RawTextArea: StyledComponent<React.ForwardRefExoticComponent<{
25
29
  error?: boolean | undefined;
26
30
  } & React.RefAttributes<import("antd/lib/input/TextArea").default>>, any, {
package/dist/Input.js CHANGED
@@ -1,163 +1,245 @@
1
- var _excluded = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "autoResize", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error"];
2
-
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4
-
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
-
7
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1
+ var _excluded = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "autoResize", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error"],
2
+ _excluded2 = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "autoResize", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error"];
8
3
 
9
4
  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); }
10
5
 
11
6
  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; }
12
7
 
13
- import React, { cloneElement, useState, useEffect, useRef, useCallback, useMemo } from 'react';
14
- import '@synerise/ds-core/dist/js/style';
8
+ import React, { useEffect, useRef, useCallback, useMemo } from 'react';
15
9
  import { v4 as uuid } from 'uuid';
10
+ import '@synerise/ds-core/dist/js/style';
16
11
  import "./style/index.css";
17
- import Tooltip from '@synerise/ds-tooltip/dist/Tooltip';
12
+ import { useResizeToFit } from '@synerise/ds-utils';
18
13
  import * as S from './Input.styles';
19
- import Label from './Label/Label';
14
+ import { ContentAboveElement, ContentBelowElement, ElementIcons } from './components';
20
15
  import Textarea from './Textarea/Textarea';
21
16
  import AutosizeInput from './autosize/autosize';
17
+ import { useInputAddonHeight, useElementFocus } from './hooks';
18
+ import { getCharCount } from './utils';
22
19
  var VERTICAL_BORDER_OFFSET = 2;
23
20
 
24
- var enhancedInput = function enhancedInput(WrappedComponent, _ref) {
25
- var type = _ref.type;
26
- return function (_ref2) {
27
- var className = _ref2.className,
28
- errorText = _ref2.errorText,
29
- label = _ref2.label,
30
- description = _ref2.description,
31
- counterLimit = _ref2.counterLimit,
32
- tooltip = _ref2.tooltip,
33
- tooltipConfig = _ref2.tooltipConfig,
34
- icon1 = _ref2.icon1,
35
- icon1Tooltip = _ref2.icon1Tooltip,
36
- autoResize = _ref2.autoResize,
37
- icon2 = _ref2.icon2,
38
- icon2Tooltip = _ref2.icon2Tooltip,
39
- resetMargin = _ref2.resetMargin,
40
- handleInputRef = _ref2.handleInputRef,
41
- prefixel = _ref2.prefixel,
42
- suffixel = _ref2.suffixel,
43
- error = _ref2.error,
44
- antdInputProps = _objectWithoutPropertiesLoose(_ref2, _excluded);
45
-
46
- var _useState = useState(0),
47
- charCount = _useState[0],
48
- setCharCount = _useState[1];
21
+ var createInputComponent = function createInputComponent(WrappedComponent) {
22
+ return function (_ref) {
23
+ var className = _ref.className,
24
+ errorText = _ref.errorText,
25
+ label = _ref.label,
26
+ description = _ref.description,
27
+ counterLimit = _ref.counterLimit,
28
+ tooltip = _ref.tooltip,
29
+ tooltipConfig = _ref.tooltipConfig,
30
+ icon1 = _ref.icon1,
31
+ icon1Tooltip = _ref.icon1Tooltip,
32
+ autoResize = _ref.autoResize,
33
+ icon2 = _ref.icon2,
34
+ icon2Tooltip = _ref.icon2Tooltip,
35
+ resetMargin = _ref.resetMargin,
36
+ handleInputRef = _ref.handleInputRef,
37
+ prefixel = _ref.prefixel,
38
+ suffixel = _ref.suffixel,
39
+ error = _ref.error,
40
+ antdInputProps = _objectWithoutPropertiesLoose(_ref, _excluded);
49
41
 
50
- var hasErrorMessage = Boolean(errorText);
51
42
  var id = useMemo(function () {
52
43
  return uuid();
53
44
  }, []);
54
- var inputRef = useRef();
45
+ var charCount = getCharCount(antdInputProps.value, counterLimit);
46
+ var InputComponent = autoResize ? AutosizeInput : WrappedComponent;
47
+ var hasErrorMessage = Boolean(errorText);
48
+ var inputRef = useRef(null);
49
+ var externalRef = useRef(null);
50
+ var handleIconsClick = useElementFocus(inputRef);
55
51
 
56
- var _useState2 = useState(0),
57
- inputAddonHeight = _useState2[0],
58
- setInputAddonHeight = _useState2[1];
52
+ var _useInputAddonHeight = useInputAddonHeight(inputRef),
53
+ inputAddonHeight = _useInputAddonHeight.inputAddonHeight;
59
54
 
60
55
  useEffect(function () {
61
- handleInputRef && handleInputRef(inputRef);
56
+ if (inputRef && inputRef.current) {
57
+ externalRef.current = inputRef.current.input;
58
+ }
59
+
60
+ handleInputRef && handleInputRef(externalRef);
62
61
  }, [inputRef, handleInputRef]);
63
62
  var handleChange = useCallback(function (e) {
64
63
  var newValue = e.currentTarget.value;
65
64
  if (counterLimit && newValue.length > counterLimit) return;
66
65
  antdInputProps.onChange && antdInputProps.onChange(e);
67
66
  }, [antdInputProps, counterLimit]);
68
- var handleIconsClick = useCallback(function () {
69
- inputRef.current && inputRef.current.focus();
70
- }, [inputRef]);
67
+
68
+ var renderInputComponent = function renderInputComponent() {
69
+ return /*#__PURE__*/React.createElement(InputComponent, _extends({}, antdInputProps, autoResize ? {
70
+ renderInput: WrappedComponent,
71
+ autoResize: autoResize
72
+ } : {}, {
73
+ className: hasErrorMessage || error ? 'error' : undefined,
74
+ addonBefore: !!prefixel && /*#__PURE__*/React.createElement(S.AddonWrapper, {
75
+ className: "ds-input-prefix",
76
+ height: inputAddonHeight - VERTICAL_BORDER_OFFSET
77
+ }, prefixel),
78
+ addonAfter: !!suffixel && /*#__PURE__*/React.createElement(S.AddonWrapper, {
79
+ className: "ds-input-suffix",
80
+ height: inputAddonHeight - VERTICAL_BORDER_OFFSET
81
+ }, suffixel),
82
+ error: hasErrorMessage || error,
83
+ onChange: handleChange,
84
+ value: antdInputProps.value,
85
+ id: id,
86
+ ref: inputRef,
87
+ autoComplete: "off"
88
+ }));
89
+ };
90
+
91
+ var stretchToFit = typeof autoResize === 'object' && Boolean(autoResize.stretchToFit);
92
+ var paddingDiff = useRef();
93
+
94
+ var _useResizeToFit = useResizeToFit({
95
+ onResize: function onResize(width) {
96
+ if (inputRef.current && paddingDiff.current) {
97
+ // @ts-ignore
98
+ inputRef.current.input.style.maxWidth = width - paddingDiff.current + "px";
99
+ }
100
+ },
101
+ autoObserve: true
102
+ }),
103
+ observe = _useResizeToFit.observe,
104
+ disconnect = _useResizeToFit.disconnect,
105
+ elementRef = _useResizeToFit.elementRef;
106
+
71
107
  useEffect(function () {
72
- if (counterLimit && antdInputProps.value && antdInputProps.value.toString().length > counterLimit) return;
73
- setCharCount(antdInputProps.value ? antdInputProps.value.toString().length : 0);
74
- }, [antdInputProps.value, counterLimit]);
108
+ if (inputRef.current) {
109
+ // @ts-ignore
110
+ var _getComputedStyle = getComputedStyle(inputRef.current.input),
111
+ paddingLeft = _getComputedStyle.paddingLeft,
112
+ paddingRight = _getComputedStyle.paddingRight;
113
+
114
+ paddingDiff.current = parseFloat(paddingLeft) + parseFloat(paddingRight);
115
+ }
116
+ }, [paddingDiff]);
75
117
  useEffect(function () {
76
- var _inputRef$current, _inputRef$current$inp;
118
+ if (elementRef.current) {
119
+ if (stretchToFit) {
120
+ observe();
121
+ } else {
122
+ disconnect(); // @ts-ignore
123
+
124
+ if (inputRef.current && inputRef.current.input) {
125
+ // @ts-ignore
126
+ inputRef.current.input.style.removeProperty('max-width');
127
+ }
128
+ }
129
+ }
77
130
 
78
- // @ts-ignore
79
- inputRef.current && setInputAddonHeight(inputRef == null ? void 0 : (_inputRef$current = inputRef.current) == null ? void 0 : (_inputRef$current$inp = _inputRef$current.input) == null ? void 0 : _inputRef$current$inp.offsetHeight);
80
- }, [inputRef]);
81
- var renderInputComponent = useMemo(function () {
82
131
  return function () {
83
- var Component = autoResize ? AutosizeInput : WrappedComponent;
84
- return /*#__PURE__*/React.createElement(Component, _extends({}, antdInputProps, autoResize ? {
85
- renderInput: WrappedComponent,
86
- autoResize: autoResize
87
- } : {}, {
88
- className: hasErrorMessage || error ? 'error' : undefined,
89
- addonBefore: !!prefixel && /*#__PURE__*/React.createElement(S.AddonWrapper, {
90
- className: "ds-input-prefix",
91
- height: inputAddonHeight - VERTICAL_BORDER_OFFSET
92
- }, prefixel),
93
- addonAfter: !!suffixel && /*#__PURE__*/React.createElement(S.AddonWrapper, {
94
- className: "ds-input-suffix",
95
- height: inputAddonHeight - VERTICAL_BORDER_OFFSET
96
- }, suffixel),
97
- error: hasErrorMessage || error,
98
- onChange: handleChange,
99
- value: antdInputProps.value,
100
- id: id,
101
- ref: inputRef,
102
- autoComplete: "off"
103
- }));
132
+ disconnect();
104
133
  };
105
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
106
- [antdInputProps, handleChange]);
134
+ }, [disconnect, observe, stretchToFit, elementRef]);
107
135
  return /*#__PURE__*/React.createElement(S.OuterWrapper, {
108
136
  autoResize: autoResize,
109
137
  className: className,
110
138
  resetMargin: resetMargin
111
- }, (label || counterLimit) && /*#__PURE__*/React.createElement(S.ContentAbove, null, /*#__PURE__*/React.createElement(Label, {
139
+ }, /*#__PURE__*/React.createElement(ContentAboveElement, {
112
140
  label: label,
141
+ counterLimit: counterLimit,
113
142
  id: id,
114
143
  tooltip: tooltip,
115
- tooltipConfig: tooltipConfig
116
- }), counterLimit && /*#__PURE__*/React.createElement(S.Counter, {
117
- "data-testid": "counter"
118
- }, charCount, "/", counterLimit)), /*#__PURE__*/React.createElement(S.InputWrapper, {
144
+ tooltipConfig: tooltipConfig,
145
+ charCount: charCount
146
+ }), /*#__PURE__*/React.createElement(S.InputWrapper, {
147
+ ref: elementRef,
119
148
  icon1: Boolean(icon1),
120
149
  icon2: Boolean(icon2)
121
- }, (icon1 || icon2) && /*#__PURE__*/React.createElement(S.IconsWrapper, {
122
- onClick: handleIconsClick,
123
- disabled: antdInputProps.disabled
124
- }, /*#__PURE__*/React.createElement(S.IconsFlexContainer, {
125
- type: type
126
- }, /*#__PURE__*/React.createElement(Tooltip, {
127
- title: icon1Tooltip
128
- }, /*#__PURE__*/React.createElement(S.IconWrapper, {
129
- className: className
130
- }, icon1 && cloneElement(icon1, _objectSpread({
131
- className: 'icon icon1'
132
- }, icon2 && {
133
- style: {
134
- marginRight: '4px'
135
- }
136
- })))), /*#__PURE__*/React.createElement(Tooltip, {
137
- title: icon2Tooltip
138
- }, /*#__PURE__*/React.createElement(S.IconWrapper, {
139
- className: className
140
- }, icon2 && cloneElement(icon2, {
141
- className: 'icon icon2'
142
- }))))), renderInputComponent()), (hasErrorMessage || description) && /*#__PURE__*/React.createElement(S.ContentBelow, null, hasErrorMessage && /*#__PURE__*/React.createElement(S.ErrorText, null, errorText), description && /*#__PURE__*/React.createElement(S.Description, null, description)));
150
+ }, /*#__PURE__*/React.createElement(ElementIcons, {
151
+ handleIconsClick: handleIconsClick,
152
+ disabled: antdInputProps.disabled,
153
+ icon1: icon1,
154
+ icon2: icon2,
155
+ icon1Tooltip: icon1Tooltip,
156
+ icon2Tooltip: icon2Tooltip,
157
+ className: className,
158
+ type: "input"
159
+ }), renderInputComponent()), /*#__PURE__*/React.createElement(ContentBelowElement, {
160
+ description: description,
161
+ errorText: errorText
162
+ }));
143
163
  };
144
164
  };
145
165
 
146
- export var TextArea = Object.assign(enhancedInput(Textarea, {
147
- type: 'textArea'
148
- }), {
149
- displayName: 'TextArea'
150
- });
151
- export var Input = Object.assign(enhancedInput(S.AntdInput, {
152
- type: 'input'
153
- }), {
154
- displayName: 'Input'
155
- });
156
- export var MaskedInput = Object.assign(enhancedInput(S.AntdMaskedInput, {
157
- type: 'input'
158
- }), {
159
- displayName: 'MaskedInput'
160
- });
166
+ export var Input = createInputComponent(S.AntdInput);
167
+ export var MaskedInput = createInputComponent(S.AntdMaskedInput);
168
+ export var TextArea = function TextArea(_ref2) {
169
+ var className = _ref2.className,
170
+ errorText = _ref2.errorText,
171
+ label = _ref2.label,
172
+ description = _ref2.description,
173
+ counterLimit = _ref2.counterLimit,
174
+ tooltip = _ref2.tooltip,
175
+ tooltipConfig = _ref2.tooltipConfig,
176
+ icon1 = _ref2.icon1,
177
+ icon1Tooltip = _ref2.icon1Tooltip,
178
+ autoResize = _ref2.autoResize,
179
+ icon2 = _ref2.icon2,
180
+ icon2Tooltip = _ref2.icon2Tooltip,
181
+ resetMargin = _ref2.resetMargin,
182
+ handleInputRef = _ref2.handleInputRef,
183
+ prefixel = _ref2.prefixel,
184
+ suffixel = _ref2.suffixel,
185
+ error = _ref2.error,
186
+ antdTextareaProps = _objectWithoutPropertiesLoose(_ref2, _excluded2);
187
+
188
+ var id = useMemo(function () {
189
+ return uuid();
190
+ }, []);
191
+ var charCount = getCharCount(antdTextareaProps.value, counterLimit);
192
+ var hasErrorMessage = Boolean(errorText);
193
+ var ref = useRef(null);
194
+ var handleIconsClick = useElementFocus(ref);
195
+ useEffect(function () {
196
+ handleInputRef && handleInputRef(ref);
197
+ }, [ref, handleInputRef]);
198
+ var handleChange = useCallback(function (e) {
199
+ var newValue = e.currentTarget.value;
200
+
201
+ if (counterLimit && newValue.length > counterLimit) {
202
+ return;
203
+ }
204
+
205
+ antdTextareaProps.onChange && antdTextareaProps.onChange(e);
206
+ }, [antdTextareaProps, counterLimit]);
207
+ return /*#__PURE__*/React.createElement(S.OuterWrapper, {
208
+ autoResize: autoResize,
209
+ className: className,
210
+ resetMargin: resetMargin
211
+ }, /*#__PURE__*/React.createElement(ContentAboveElement, {
212
+ label: label,
213
+ counterLimit: counterLimit,
214
+ id: id,
215
+ tooltip: tooltip,
216
+ tooltipConfig: tooltipConfig,
217
+ charCount: charCount
218
+ }), /*#__PURE__*/React.createElement(S.InputWrapper, {
219
+ icon1: Boolean(icon1),
220
+ icon2: Boolean(icon2)
221
+ }, /*#__PURE__*/React.createElement(ElementIcons, {
222
+ handleIconsClick: handleIconsClick,
223
+ disabled: antdTextareaProps.disabled,
224
+ icon1Tooltip: icon1Tooltip,
225
+ icon1: icon1,
226
+ icon2: icon2,
227
+ icon2Tooltip: icon2Tooltip,
228
+ className: className,
229
+ type: "textArea"
230
+ }), /*#__PURE__*/React.createElement(Textarea, _extends({}, antdTextareaProps, {
231
+ className: hasErrorMessage || error ? 'error' : undefined,
232
+ error: hasErrorMessage || error,
233
+ onChange: handleChange,
234
+ value: antdTextareaProps.value,
235
+ id: id // ref={ref}
236
+ ,
237
+ autoComplete: "off"
238
+ }))), /*#__PURE__*/React.createElement(ContentBelowElement, {
239
+ description: description,
240
+ errorText: errorText
241
+ }));
242
+ };
161
243
  export var RawMaskedInput = S.AntdMaskedInput;
162
244
  export { default as InputGroup } from './InputGroup';
163
245
  export var RawInput = function RawInput(props) {
@@ -1,29 +1,28 @@
1
- import BaseAntInput from 'antd/lib/input';
1
+ import React, { MutableRefObject, ReactNode } from 'react';
2
+ import BaseAntInput, { InputProps } from 'antd/lib/input';
2
3
  import TextArea from 'antd/lib/input/TextArea';
3
- import * as React from 'react';
4
4
  import MaskedInput from 'antd-mask-input';
5
5
  import { SizeType } from 'antd/es/config-provider/SizeContext';
6
+ import type { AutoResizeProp } from './Input.types';
6
7
  export type AutoResizeInputProps = {
7
- autoResize?: boolean | {
8
- minWidth: string;
9
- maxWidth: string;
10
- };
11
- suffixel?: boolean | React.ReactNode;
12
- prefixel?: boolean | React.ReactNode;
13
- icon1?: boolean | React.ReactNode;
14
- icon2?: boolean | React.ReactNode;
8
+ autoResize?: AutoResizeProp;
9
+ suffixel?: ReactNode;
10
+ prefixel?: ReactNode;
11
+ icon1?: ReactNode;
12
+ icon2?: ReactNode;
15
13
  };
14
+ export declare function autoresizeConfObjToCss({ autoResize }: {
15
+ autoResize?: AutoResizeProp;
16
+ }): string;
16
17
  export declare const OuterWrapper: import("styled-components").StyledComponent<"div", any, {
17
18
  resetMargin?: boolean | undefined;
18
- autoResize?: boolean | {
19
- minWidth: string;
20
- maxWidth: string;
21
- } | undefined;
19
+ autoResize?: AutoResizeProp | undefined;
22
20
  }, never>;
23
21
  export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
24
22
  interface InputWrapperProps {
25
23
  icon1: boolean;
26
24
  icon2: boolean;
25
+ ref?: MutableRefObject<HTMLDivElement | null>;
27
26
  }
28
27
  export declare const InputWrapper: import("styled-components").StyledComponent<"div", any, InputWrapperProps, never>;
29
28
  export declare const IconsWrapper: import("styled-components").StyledComponent<"div", any, {
@@ -33,16 +32,20 @@ export declare const IconsFlexContainer: import("styled-components").StyledCompo
33
32
  type: string;
34
33
  }, never>;
35
34
  export declare const IconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
36
- export declare const AntdInput: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<{
35
+ export declare const AntdInput: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<InputProps & {
37
36
  error?: boolean | undefined;
38
37
  size?: SizeType;
39
38
  } & React.RefAttributes<BaseAntInput>>, any, {
40
39
  error?: boolean | undefined;
41
40
  readOnly?: boolean | undefined;
42
41
  }, never>;
43
- export declare const AntdMaskedInput: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<{
44
- error?: boolean | undefined;
42
+ export declare const AntdMaskedInput: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<InputProps & {
45
43
  mask: string;
44
+ formatCharacters?: object | undefined;
45
+ placeholderChar?: string | undefined;
46
+ value?: string | undefined;
47
+ } & {
48
+ error?: boolean | undefined;
46
49
  } & React.RefAttributes<MaskedInput>>, any, {
47
50
  error?: boolean | undefined;
48
51
  }, never>;
@@ -53,10 +56,7 @@ export declare const AntdTextArea: import("styled-components").StyledComponent<R
53
56
  }, never>;
54
57
  export declare const ContentBelow: import("styled-components").StyledComponent<"div", any, {}, never>;
55
58
  export declare const WrapperAutoResize: import("styled-components").StyledComponent<"div", any, {
56
- autoResize?: boolean | {
57
- minWidth: string;
58
- maxWidth: string;
59
- } | undefined;
59
+ autoResize?: AutoResizeProp | undefined;
60
60
  }, never>;
61
61
  export declare const AutoResize: import("styled-components").StyledComponent<"div", any, AutoResizeInputProps, never>;
62
62
  export declare const ErrorText: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,14 +1,14 @@
1
1
  var _excluded = ["error"],
2
- _excluded2 = ["error", "mask"],
2
+ _excluded2 = ["error"],
3
3
  _excluded3 = ["error"];
4
4
 
5
5
  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); }
6
6
 
7
7
  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; }
8
8
 
9
+ import React, { forwardRef } from 'react';
9
10
  import styled, { css } from 'styled-components';
10
11
  import BaseAntInput from 'antd/lib/input';
11
- import * as React from 'react';
12
12
  import MaskedInput from 'antd-mask-input';
13
13
 
14
14
  var errorInputStyle = function errorInputStyle(props) {
@@ -27,17 +27,16 @@ var getPaddingAutoResize = function getPaddingAutoResize(props) {
27
27
  return '0 13px';
28
28
  };
29
29
 
30
- function autoresizeConfObjToCss(_ref) {
30
+ export function autoresizeConfObjToCss(_ref) {
31
31
  var autoResize = _ref.autoResize;
32
32
  if (!autoResize) return '';
33
33
 
34
34
  if (typeof autoResize === 'object') {
35
- return "max-width: " + autoResize.maxWidth + "; min-width: " + autoResize.minWidth;
35
+ return "\n " + (autoResize.maxWidth !== undefined ? "max-width: " + autoResize.maxWidth + ";" : '') + "\n min-width: " + autoResize.minWidth + ";\n ";
36
36
  }
37
37
 
38
38
  return "max-width: 400px; min-width: 150px;";
39
39
  }
40
-
41
40
  export var OuterWrapper = styled.div.withConfig({
42
41
  displayName: "Inputstyles__OuterWrapper",
43
42
  componentId: "dc57an-0"
@@ -88,20 +87,16 @@ export var IconWrapper = styled.div.withConfig({
88
87
  })([".icon:hover{svg{fill:", ";cursor:pointer;}}"], function (props) {
89
88
  return props.theme.palette['blue-600'];
90
89
  });
91
- export var AntdInput = styled(React.forwardRef( // eslint-disable-next-line
90
+ export var AntdInput = styled(forwardRef( // eslint-disable-next-line
92
91
  function (_ref2, ref) {
93
92
  var error = _ref2.error,
94
93
  props = _objectWithoutPropertiesLoose(_ref2, _excluded);
95
94
 
96
- return (
97
- /*#__PURE__*/
98
- // eslint-disable-next-line
99
- React.createElement(BaseAntInput, _extends({
100
- autoComplete: "off"
101
- }, props, {
102
- ref: ref
103
- }))
104
- );
95
+ return /*#__PURE__*/React.createElement(BaseAntInput, _extends({
96
+ autoComplete: "off"
97
+ }, props, {
98
+ ref: ref
99
+ }));
105
100
  })).withConfig({
106
101
  displayName: "Inputstyles__AntdInput",
107
102
  componentId: "dc57an-6"
@@ -118,22 +113,16 @@ function (_ref2, ref) {
118
113
  theme = _ref3.theme;
119
114
  return readOnly ? "\n &:hover {\n border-color: " + theme.palette['grey-300'] + ";\n }\n &:focus {\n border-color: " + theme.palette['grey-300'] + ";\n box-shadow: none;\n background: #fff;\n }\n " : '';
120
115
  });
121
- export var AntdMaskedInput = styled(React.forwardRef( // eslint-disable-next-line
116
+ export var AntdMaskedInput = styled(forwardRef( // eslint-disable-next-line
122
117
  function (_ref4, ref) {
123
118
  var error = _ref4.error,
124
- mask = _ref4.mask,
125
119
  props = _objectWithoutPropertiesLoose(_ref4, _excluded2);
126
120
 
127
- return (
128
- /*#__PURE__*/
129
- // eslint-disable-next-line
130
- React.createElement(MaskedInput, _extends({
131
- autoComplete: "off"
132
- }, props, {
133
- ref: ref,
134
- mask: mask
135
- }))
136
- );
121
+ return /*#__PURE__*/React.createElement(MaskedInput, _extends({
122
+ autoComplete: "off"
123
+ }, props, {
124
+ ref: ref
125
+ }));
137
126
  })).withConfig({
138
127
  displayName: "Inputstyles__AntdMaskedInput",
139
128
  componentId: "dc57an-7"
@@ -144,20 +133,16 @@ function (_ref4, ref) {
144
133
  }, function (props) {
145
134
  return props.theme.palette['grey-700'];
146
135
  });
147
- export var AntdTextArea = styled(React.forwardRef( // eslint-disable-next-line
136
+ export var AntdTextArea = styled(forwardRef( // eslint-disable-next-line
148
137
  function (_ref5, ref) {
149
138
  var error = _ref5.error,
150
139
  props = _objectWithoutPropertiesLoose(_ref5, _excluded3);
151
140
 
152
- return (
153
- /*#__PURE__*/
154
- // eslint-disable-next-line
155
- React.createElement(BaseAntInput.TextArea, _extends({
156
- autoComplete: "off"
157
- }, props, {
158
- ref: ref
159
- }))
160
- );
141
+ return /*#__PURE__*/React.createElement(BaseAntInput.TextArea, _extends({
142
+ autoComplete: "off"
143
+ }, props, {
144
+ ref: ref
145
+ }));
161
146
  })).withConfig({
162
147
  displayName: "Inputstyles__AntdTextArea",
163
148
  componentId: "dc57an-8"
@@ -1,28 +1,37 @@
1
- import * as React from 'react';
2
- import { InputProps, TextAreaProps } from 'antd/lib/input';
3
- import { MaskedInputProps } from 'antd-mask-input/build/main/lib/MaskedInput';
4
- import TooltipExtendedProps from '@synerise/ds-tooltip/dist/Tooltip.types';
1
+ import { ReactNode, ReactElement, MutableRefObject } from 'react';
2
+ import { InputProps as AntdInputProps, TextAreaProps as AntdTextAreaProps } from 'antd/lib/input';
3
+ import { MaskedInputProps as AntdMaskedInputProps } from 'antd-mask-input/build/main/lib/MaskedInput';
5
4
  import { TooltipProps } from 'antd/lib/tooltip';
6
- export interface Props {
5
+ import TooltipExtendedProps from '@synerise/ds-tooltip/dist/Tooltip.types';
6
+ import { TextAreaProps } from './Textarea/Textarea.types';
7
+ export type AutoResizeProp = boolean | {
8
+ minWidth: string;
9
+ maxWidth?: string;
10
+ stretchToFit?: boolean;
11
+ };
12
+ export interface BaseProps<RefElementType extends HTMLTextAreaElement | HTMLInputElement = HTMLInputElement> {
7
13
  error?: boolean;
8
14
  className?: string;
9
- tooltip?: React.ReactNode;
15
+ tooltip?: ReactNode;
10
16
  tooltipConfig?: TooltipExtendedProps & TooltipProps;
11
- errorText?: React.ReactNode | string;
12
- label?: React.ReactNode | string;
13
- description?: React.ReactNode | string;
17
+ errorText?: ReactNode;
18
+ label?: ReactNode;
19
+ description?: ReactNode;
14
20
  counterLimit?: number;
15
- icon1?: React.ReactElement;
16
- icon1Tooltip?: React.ReactElement;
17
- icon2?: React.ReactElement;
18
- icon2Tooltip?: React.ReactElement;
21
+ icon1?: ReactElement;
22
+ icon1Tooltip?: ReactElement;
23
+ icon2?: ReactElement;
24
+ icon2Tooltip?: ReactElement;
19
25
  resetMargin?: boolean;
20
- handleInputRef?: (ref: React.MutableRefObject<HTMLInputElement | HTMLTextAreaElement | undefined>) => void;
21
- prefixel?: React.ReactNode;
22
- suffixel?: React.ReactNode;
23
- autoResize?: boolean | {
24
- minWidth: string;
25
- maxWidth: string;
26
- };
26
+ handleInputRef?: (ref: MutableRefObject<RefElementType | null>) => void;
27
+ prefixel?: ReactNode;
28
+ suffixel?: ReactNode;
29
+ autoResize?: AutoResizeProp;
27
30
  }
28
- export type EnhancedProps = Props & (InputProps | TextAreaProps | MaskedInputProps);
31
+ /**
32
+ * @deprecated use `InputProps`, `TextareaProps` or `MaskedInputProps` instead
33
+ */
34
+ export type EnhancedProps = BaseProps<HTMLInputElement | HTMLTextAreaElement> & (AntdInputProps | AntdTextAreaProps | AntdMaskedInputProps);
35
+ export type InputProps = BaseProps & AntdInputProps;
36
+ export type TextareaProps = BaseProps<HTMLTextAreaElement> & TextAreaProps;
37
+ export type MaskedInputProps = BaseProps & AntdMaskedInputProps;
@@ -25,8 +25,10 @@ var InputGroup = function InputGroup(_ref) {
25
25
  tooltip: tooltip
26
26
  })), /*#__PURE__*/React.createElement(Input.Group, antdInputGroupProps, /*#__PURE__*/React.createElement(S.InputGroupWrapper, {
27
27
  compact: antdInputGroupProps.compact
28
- }, Children.map(childrenArray, function (child) {
29
- return /*#__PURE__*/React.createElement(S.InputGroupItem, null, child);
28
+ }, Children.map(childrenArray, function (child, index) {
29
+ return /*#__PURE__*/React.createElement(S.InputGroupItem, {
30
+ className: "ds-input-group-item ds-input-group-item-" + index
31
+ }, child);
30
32
  }))), (errors && errors.length > 0 || description) && /*#__PURE__*/React.createElement(InputStyles.ContentBelow, null, errors && errors.map(function (error) {
31
33
  return /*#__PURE__*/React.createElement(InputStyles.ErrorText, {
32
34
  key: "error"
@@ -6,8 +6,8 @@ export var InputGroupItem = styled.div.withConfig({
6
6
  export var InputGroupWrapper = styled.div.withConfig({
7
7
  displayName: "InputGroupstyles__InputGroupWrapper",
8
8
  componentId: "sc-1cn2cc5-1"
9
- })(["&&&{display:flex;align-items:", ";", "}"], function (props) {
10
- return props.compact ? '' : 'stretch';
9
+ })(["&&&{display:flex;min-width:0;", ";", "}"], function (props) {
10
+ return props.compact ? '' : 'align-items: stretch';
11
11
  }, function (props) {
12
12
  return props.compact ? css(["", "{&:only-child{flex-grow:1;}&:not(:only-child){&:not(:last-child){margin-right:-1px;.ant-input,.ant-input-number,.ant-select-selector{border-top-right-radius:0px;border-bottom-right-radius:0px;}}&:last-child{.ant-input,.ant-input-number,.ant-select-selector{border-top-left-radius:0px;border-bottom-left-radius:0px;}flex:auto;}}"], InputGroupItem) : css(["", ":last-child{flex-grow:1;}", ":not(:last-child){margin-right:12px;}"], InputGroupItem, InputGroupItem);
13
13
  });
@@ -8,7 +8,7 @@ declare class AutosizeInput extends Component {
8
8
  componentDidMount(): void;
9
9
  componentDidUpdate(prevProps: any, prevState: any): void;
10
10
  componentWillUnmount(): void;
11
- inputRef: (el: any) => void;
11
+ inputRef: (el: any, originalElement: any) => void;
12
12
  placeHolderSizerRef: (el: any) => void;
13
13
  sizerRef: (el: any) => void;
14
14
  copyInputStyles(): void;
@@ -27,7 +27,7 @@ var sizerStyle = {
27
27
  overflow: 'scroll',
28
28
  whiteSpace: 'pre'
29
29
  };
30
- var INPUT_PROPS_BLACKLIST = ['extraWidth', 'injectStyles', 'inputClassName', 'inputRef', 'inputStyle', 'minWidth', 'onAutosize', 'placeholderIsMinWidth', 'autoResize'];
30
+ var INPUT_PROPS_BLACKLIST = ['extraWidth', 'injectStyles', 'inputClassName', 'inputRef', 'inputStyle', 'minWidth', 'onAutosize', 'placeholderIsMinWidth', 'autoResize', 'refPropName'];
31
31
 
32
32
  var cleanInputProps = function cleanInputProps(inputProps) {
33
33
  INPUT_PROPS_BLACKLIST.forEach(function (field) {
@@ -69,11 +69,11 @@ var AutosizeInput = /*#__PURE__*/function (_Component) {
69
69
 
70
70
  _this = _Component.call(this, props) || this;
71
71
 
72
- _defineProperty(_assertThisInitialized(_this), "inputRef", function (el) {
72
+ _defineProperty(_assertThisInitialized(_this), "inputRef", function (el, originalElement) {
73
73
  _this.input = el;
74
74
 
75
75
  if (typeof _this.props.inputRef === 'function') {
76
- _this.props.inputRef(el);
76
+ _this.props.inputRef(el, originalElement);
77
77
  }
78
78
  });
79
79
 
@@ -91,7 +91,7 @@ var AutosizeInput = /*#__PURE__*/function (_Component) {
91
91
  var input = el.previousElementSibling;
92
92
  var ref = transformRef(input);
93
93
 
94
- _this.inputRef(ref);
94
+ _this.inputRef(ref, input);
95
95
 
96
96
  _this.copyInputStyles();
97
97
  });
@@ -218,7 +218,8 @@ var AutosizeInput = /*#__PURE__*/function (_Component) {
218
218
  var inputStyle = _objectSpread({
219
219
  boxSizing: 'content-box',
220
220
  width: this.state.inputWidth + "px",
221
- minHeight: 30 - 12 * 2 + "px"
221
+ minHeight: 30 - 12 * 2 + "px",
222
+ transition: 'width 0s ease 0s'
222
223
  }, this.props.inputStyle);
223
224
 
224
225
  var defaultRenderInput = function defaultRenderInput(props) {
@@ -0,0 +1,8 @@
1
+ import { BaseProps } from '../Input.types';
2
+ type ContentAboveProps = Pick<BaseProps, 'tooltip' | 'tooltipConfig' | 'label'> & {
3
+ counterLimit?: number;
4
+ charCount?: number;
5
+ id: string;
6
+ };
7
+ export declare const ContentAboveElement: ({ label, counterLimit, id, tooltip, tooltipConfig, charCount, }: ContentAboveProps) => JSX.Element;
8
+ export {};
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import Label from '../Label/Label';
3
+ import * as S from '../Input.styles';
4
+ export var ContentAboveElement = function ContentAboveElement(_ref) {
5
+ var label = _ref.label,
6
+ counterLimit = _ref.counterLimit,
7
+ id = _ref.id,
8
+ tooltip = _ref.tooltip,
9
+ tooltipConfig = _ref.tooltipConfig,
10
+ charCount = _ref.charCount;
11
+ return label || counterLimit ? /*#__PURE__*/React.createElement(S.ContentAbove, null, /*#__PURE__*/React.createElement(Label, {
12
+ label: label,
13
+ id: id,
14
+ tooltip: tooltip,
15
+ tooltipConfig: tooltipConfig
16
+ }), counterLimit && /*#__PURE__*/React.createElement(S.Counter, {
17
+ "data-testid": "counter"
18
+ }, charCount, "/", counterLimit)) : /*#__PURE__*/React.createElement(React.Fragment, null);
19
+ };
@@ -0,0 +1,4 @@
1
+ import { BaseProps } from '../Input.types';
2
+ type ContentBelowProps = Pick<BaseProps, 'description' | 'errorText'>;
3
+ export declare const ContentBelowElement: ({ description, errorText }: ContentBelowProps) => JSX.Element | null;
4
+ export {};
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import * as S from '../Input.styles';
3
+ export var ContentBelowElement = function ContentBelowElement(_ref) {
4
+ var description = _ref.description,
5
+ errorText = _ref.errorText;
6
+
7
+ if (!errorText && !description) {
8
+ return null;
9
+ }
10
+
11
+ var hasErrorMessage = Boolean(errorText);
12
+ return /*#__PURE__*/React.createElement(S.ContentBelow, null, hasErrorMessage && /*#__PURE__*/React.createElement(S.ErrorText, null, errorText), description && /*#__PURE__*/React.createElement(S.Description, null, description));
13
+ };
@@ -0,0 +1,8 @@
1
+ import { BaseProps } from '../Input.types';
2
+ type IconProps = Pick<BaseProps, 'icon1' | 'icon1Tooltip' | 'icon2' | 'icon2Tooltip' | 'className'> & {
3
+ disabled?: boolean;
4
+ handleIconsClick: () => void;
5
+ type: string;
6
+ };
7
+ export declare const ElementIcons: ({ handleIconsClick, disabled, icon1Tooltip, icon1, icon2, icon2Tooltip, className, type, }: IconProps) => JSX.Element | null;
8
+ export {};
@@ -0,0 +1,46 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ import React, { cloneElement } from 'react';
8
+ import Tooltip from '@synerise/ds-tooltip/dist/Tooltip';
9
+ import * as S from '../Input.styles';
10
+ export var ElementIcons = function ElementIcons(_ref) {
11
+ var handleIconsClick = _ref.handleIconsClick,
12
+ disabled = _ref.disabled,
13
+ icon1Tooltip = _ref.icon1Tooltip,
14
+ icon1 = _ref.icon1,
15
+ icon2 = _ref.icon2,
16
+ icon2Tooltip = _ref.icon2Tooltip,
17
+ className = _ref.className,
18
+ type = _ref.type;
19
+
20
+ if (!icon1 && !icon2) {
21
+ return null;
22
+ }
23
+
24
+ return /*#__PURE__*/React.createElement(S.IconsWrapper, {
25
+ onClick: handleIconsClick,
26
+ disabled: disabled
27
+ }, /*#__PURE__*/React.createElement(S.IconsFlexContainer, {
28
+ type: type
29
+ }, /*#__PURE__*/React.createElement(Tooltip, {
30
+ title: icon1Tooltip
31
+ }, /*#__PURE__*/React.createElement(S.IconWrapper, {
32
+ className: className
33
+ }, icon1 && cloneElement(icon1, _objectSpread({
34
+ className: 'icon icon1'
35
+ }, icon2 && {
36
+ style: {
37
+ marginRight: '4px'
38
+ }
39
+ })))), /*#__PURE__*/React.createElement(Tooltip, {
40
+ title: icon2Tooltip
41
+ }, /*#__PURE__*/React.createElement(S.IconWrapper, {
42
+ className: className
43
+ }, icon2 && cloneElement(icon2, {
44
+ className: 'icon icon2'
45
+ })))));
46
+ };
@@ -0,0 +1,3 @@
1
+ export { ContentAboveElement } from './ContentAboveElement';
2
+ export { ContentBelowElement } from './ContentBelowElement';
3
+ export { ElementIcons } from './ElementIcons';
@@ -0,0 +1,3 @@
1
+ export { ContentAboveElement } from './ContentAboveElement';
2
+ export { ContentBelowElement } from './ContentBelowElement';
3
+ export { ElementIcons } from './ElementIcons';
@@ -0,0 +1,2 @@
1
+ export { useElementFocus } from './useElementFocus';
2
+ export { useInputAddonHeight } from './useInputAddonHeight';
@@ -0,0 +1,2 @@
1
+ export { useElementFocus } from './useElementFocus';
2
+ export { useInputAddonHeight } from './useInputAddonHeight';
@@ -0,0 +1,4 @@
1
+ import { MutableRefObject } from 'react';
2
+ import AntdInput from 'antd/lib/input';
3
+ import AntdMaskedInput from 'antd-mask-input';
4
+ export declare const useElementFocus: (ref: MutableRefObject<HTMLInputElement | HTMLTextAreaElement | AntdMaskedInput | AntdInput | null>) => () => void;
@@ -0,0 +1,5 @@
1
+ export var useElementFocus = function useElementFocus(ref) {
2
+ return function () {
3
+ ref.current && ref.current.focus();
4
+ };
5
+ };
@@ -0,0 +1,6 @@
1
+ import { MutableRefObject } from 'react';
2
+ import AntdInput from 'antd/lib/input';
3
+ import AntdMaskedInput from 'antd-mask-input';
4
+ export declare const useInputAddonHeight: (inputRef: MutableRefObject<AntdInput | AntdMaskedInput | null>) => {
5
+ inputAddonHeight: number;
6
+ };
@@ -0,0 +1,15 @@
1
+ import { useState, useEffect } from 'react';
2
+ export var useInputAddonHeight = function useInputAddonHeight(inputRef) {
3
+ var _useState = useState(0),
4
+ inputAddonHeight = _useState[0],
5
+ setInputAddonHeight = _useState[1];
6
+
7
+ useEffect(function () {
8
+ var _inputRef$current$inp;
9
+
10
+ inputRef.current && setInputAddonHeight((_inputRef$current$inp = inputRef.current.input) == null ? void 0 : _inputRef$current$inp.offsetHeight);
11
+ }, [inputRef]);
12
+ return {
13
+ inputAddonHeight: inputAddonHeight
14
+ };
15
+ };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import type { EnhancedProps } from './Input.types';
2
1
  export { default as Label } from './Label/Label';
3
2
  export { Input, TextArea, RawInput, RawTextArea, InputGroup, MaskedInput, InputMultivalue, RawMaskedInput, AutoResize, WrapperAutoResize, } from './Input';
4
3
  export * as InputStyles from './Input.styles';
5
- export type { EnhancedProps };
6
- export type { Props as InputProps } from './Input.types';
4
+ export type { BaseProps, EnhancedProps, InputProps, TextareaProps, MaskedInputProps, AutoResizeProp, } from './Input.types';
7
5
  export { default as AutosizeInput } from './autosize/autosize';
@@ -0,0 +1,3 @@
1
+ import { InputProps as AntdInputProps } from 'antd/lib/input';
2
+ import { TextareaProps } from '../Input.types';
3
+ export declare const getCharCount: (value?: AntdInputProps['value'] | TextareaProps['value'], limit?: number) => number | undefined;
@@ -0,0 +1,4 @@
1
+ export var getCharCount = function getCharCount(value, limit) {
2
+ if (limit && value && value.toString().length > limit) return undefined;
3
+ return value ? value.toString().length : 0;
4
+ };
@@ -0,0 +1 @@
1
+ export { getCharCount } from './getCharCount';
@@ -0,0 +1 @@
1
+ export { getCharCount } from './getCharCount';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-input",
3
- "version": "0.19.19",
3
+ "version": "0.20.1",
4
4
  "description": "Input UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -33,11 +33,11 @@
33
33
  ],
34
34
  "types": "dist/index.d.ts",
35
35
  "dependencies": {
36
- "@synerise/ds-icon": "^0.60.2",
37
- "@synerise/ds-scrollbar": "^0.8.2",
38
- "@synerise/ds-tooltip": "^0.14.19",
36
+ "@synerise/ds-icon": "^0.60.3",
37
+ "@synerise/ds-scrollbar": "^0.8.3",
38
+ "@synerise/ds-tooltip": "^0.14.20",
39
39
  "@synerise/ds-typography": "^0.14.3",
40
- "@synerise/ds-utils": "^0.24.26",
40
+ "@synerise/ds-utils": "^0.25.0",
41
41
  "antd-mask-input": "^0.1.13",
42
42
  "csstype": "2.6.9",
43
43
  "uuid": "^8.3.2"
@@ -51,5 +51,5 @@
51
51
  "devDependencies": {
52
52
  "@testing-library/react": "10.0.1"
53
53
  },
54
- "gitHead": "673df74b628304300c09f0d7e26279b5901cd925"
54
+ "gitHead": "914ce4be2e0e1fe145edeca838ab04eaa1aec1bf"
55
55
  }