@synerise/ds-input 0.21.4 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +28 -26
- package/dist/Input.d.ts +2 -2
- package/dist/Input.js +119 -36
- package/dist/Input.styles.d.ts +9 -5
- package/dist/Input.styles.js +39 -23
- package/dist/Input.types.d.ts +6 -2
- package/dist/InputGroup.d.ts +2 -1
- package/dist/InputMultivalue/InputMultivalue.js +2 -1
- package/dist/Label/Label.d.ts +2 -1
- package/dist/Label/Label.styles.d.ts +1 -1
- package/dist/TextArea.d.ts +2 -2
- package/dist/TextArea.js +4 -2
- package/dist/Textarea/Textarea.d.ts +8 -3
- package/dist/Textarea/Textarea.js +11 -12
- package/dist/Textarea/Textarea.styles.js +0 -1
- package/dist/components/ContentAboveElement.d.ts +4 -3
- package/dist/components/ContentAboveElement.js +5 -2
- package/dist/components/ContentBelowElement.d.ts +2 -1
- package/dist/components/ElementIcons.d.ts +5 -2
- package/dist/components/ElementIcons.js +17 -8
- package/dist/components/ExpandableWrapper.d.ts +9 -0
- package/dist/components/ExpandableWrapper.js +23 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/getCharCount.d.ts +1 -1
- package/dist/utils/getCharCount.js +1 -1
- package/package.json +6 -6
- /package/dist/{AutosizeWrapper → components}/AutosizeWrapper.d.ts +0 -0
- /package/dist/{AutosizeWrapper → components}/AutosizeWrapper.js +0 -0
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.22.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@0.21.5...@synerise/ds-input@0.22.0) (2024-06-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **input:** adds custom counter render prop ([761da40](https://github.com/synerise/synerise-design/commit/761da40bb7f40d1215ae36382dd57d083c8b4baf))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.21.5](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@0.21.4...@synerise/ds-input@0.21.5) (2024-05-29)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @synerise/ds-input
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [0.21.4](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@0.21.3...@synerise/ds-input@0.21.4) (2024-05-23)
|
|
7
26
|
|
|
8
27
|
|
package/README.md
CHANGED
|
@@ -21,32 +21,34 @@ Input UI Component
|
|
|
21
21
|
|
|
22
22
|
### Input
|
|
23
23
|
|
|
24
|
-
| Property
|
|
25
|
-
|
|
|
26
|
-
| addonAfter
|
|
27
|
-
| addonBefore
|
|
28
|
-
| allowClear
|
|
29
|
-
| counterLimit
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
24
|
+
| Property | Description | Type | Default |
|
|
25
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- | ----------- |
|
|
26
|
+
| addonAfter | The label text displayed after (on the right side of) the input field. | string\ReactNode | |
|
|
27
|
+
| addonBefore | The label text displayed before (on the left side of) the input field. | string\ReactNode | |
|
|
28
|
+
| allowClear | Allow to remove input content with clear icon | boolean | |
|
|
29
|
+
| counterLimit | Maximum input length, if provided counter will be shown | number | - |
|
|
30
|
+
| renderCustomCounter | render function to display custom char counter instead of counterLimit. counterLimit (max alowed chars) does not have to be defined. | `(count: number) => ReactNode` | - |
|
|
31
|
+
| defaultValue | The initial input content | string | |
|
|
32
|
+
| description | input description | string | - |
|
|
33
|
+
| disabled | Whether the input is disabled. | boolean | `false` |
|
|
34
|
+
| errorText | Error message, if provided input will be set in error state | string | - |
|
|
35
|
+
| error | If provided input will be set in error state, without error message | boolean | - |
|
|
36
|
+
| expandable | If true then user can switch to a multiline field if text overflows the input | boolean | - |
|
|
37
|
+
| handleInputRef | The callback function that is triggered when Component is mounted. | function(ref) | - |
|
|
38
|
+
| id | The ID for input | string | |
|
|
39
|
+
| label | Input label | string | - |
|
|
40
|
+
| onChange | Callback when user input | function(e) | |
|
|
41
|
+
| onPressEnter | The callback function that is triggered when Enter key is pressed. | function(e) | |
|
|
42
|
+
| prefix | The prefix icon for the Input. | string\ReactNode | |
|
|
43
|
+
| resetMargin | Whether input should have margin reset | boolean | - |
|
|
44
|
+
| resize | 'resize' CSS property passed to the input component | `none` / `both` / `horizontal` / `vertical` / `initial` / `inherit` | - |
|
|
45
|
+
| size | The size of the input box. Note: in the context of a form, the `large` size is used. Available: `large` `default` `small` | string | `default` |
|
|
46
|
+
| suffix | The suffix icon for the Input. | string\ReactNode | |
|
|
47
|
+
| tooltip | Tooltip content | ReactNode | - |
|
|
48
|
+
| tooltipConfig | Config of tooltip | [TooltipProps](https://design.synerise.com/docs/components/tooltip#api) | - |
|
|
49
|
+
| 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` |
|
|
50
|
+
| value | The input content value | string | |
|
|
51
|
+
| autoResize | 'resize' width of the input based on width of the text in input | AutoResizeProp (see below) | `undefined` |
|
|
50
52
|
|
|
51
53
|
#### AutoResizeProp
|
|
52
54
|
|
package/dist/Input.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { InputProps as AntdInputProps } from 'antd/lib/input';
|
|
|
4
4
|
import AntdMaskedInput from 'antd-mask-input';
|
|
5
5
|
import '@synerise/ds-core/dist/js/style';
|
|
6
6
|
import './style/index.less';
|
|
7
|
-
import { BaseProps, InputProps as DSInputProps } from './Input.types';
|
|
7
|
+
import type { BaseProps, InputProps as DSInputProps } from './Input.types';
|
|
8
8
|
export declare const Input: React.ComponentType<BaseProps<HTMLInputElement> & AntdInputProps>;
|
|
9
9
|
export declare const MaskedInput: React.ComponentType<BaseProps<HTMLInputElement> & AntdInputProps & {
|
|
10
10
|
mask: string;
|
|
@@ -23,7 +23,7 @@ export declare const RawMaskedInput: StyledComponent<React.ForwardRefExoticCompo
|
|
|
23
23
|
error?: boolean | undefined;
|
|
24
24
|
autoResize?: import("./Input.types").AutoResizeProp | undefined;
|
|
25
25
|
}, never>;
|
|
26
|
-
export declare const RawInput: (props: DSInputProps) => JSX.Element;
|
|
26
|
+
export declare const RawInput: (props: DSInputProps) => React.JSX.Element;
|
|
27
27
|
export { default as InputGroup } from './InputGroup';
|
|
28
28
|
export { default as InputMultivalue } from './InputMultivalue/InputMultivalue';
|
|
29
29
|
export declare const AutoResize: any;
|
package/dist/Input.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
var _excluded = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "autoResize", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error"];
|
|
1
|
+
var _excluded = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "autoResize", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error", "expandable", "expandableTooltip", "renderCustomCounter"];
|
|
2
2
|
|
|
3
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); }
|
|
4
4
|
|
|
5
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
6
|
|
|
7
|
-
import React, { useEffect, useRef,
|
|
7
|
+
import React, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
|
|
8
8
|
import { v4 as uuid } from 'uuid';
|
|
9
|
-
import '@synerise/ds-core/dist/js/style';
|
|
10
9
|
import { useResizeObserver } from '@synerise/ds-utils';
|
|
10
|
+
import '@synerise/ds-core/dist/js/style';
|
|
11
11
|
import "./style/index.css";
|
|
12
12
|
import * as S from './Input.styles';
|
|
13
|
-
import { ContentAboveElement, ContentBelowElement, ElementIcons } from './components';
|
|
13
|
+
import { ContentAboveElement, ContentBelowElement, ElementIcons, AutosizeWrapper, ExpandableWrapper } from './components';
|
|
14
14
|
import { useInputAddonHeight, useElementFocus } from './hooks';
|
|
15
15
|
import { getCharCount } from './utils';
|
|
16
|
-
import { AutosizeWrapper } from './AutosizeWrapper/AutosizeWrapper';
|
|
17
16
|
var VERTICAL_BORDER_OFFSET = 2;
|
|
18
17
|
|
|
19
18
|
var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
@@ -35,12 +34,25 @@ var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
|
35
34
|
prefixel = _ref.prefixel,
|
|
36
35
|
suffixel = _ref.suffixel,
|
|
37
36
|
error = _ref.error,
|
|
37
|
+
expandable = _ref.expandable,
|
|
38
|
+
expandableTooltip = _ref.expandableTooltip,
|
|
39
|
+
renderCustomCounter = _ref.renderCustomCounter,
|
|
38
40
|
antdInputProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
39
41
|
|
|
40
42
|
var id = useMemo(function () {
|
|
41
43
|
return uuid();
|
|
42
44
|
}, []);
|
|
43
45
|
var charCount = getCharCount(antdInputProps.value, counterLimit);
|
|
46
|
+
var expandableTextAreaRef = useRef(null);
|
|
47
|
+
|
|
48
|
+
var _useState = useState(false),
|
|
49
|
+
expanded = _useState[0],
|
|
50
|
+
setExpanded = _useState[1];
|
|
51
|
+
|
|
52
|
+
var _useState2 = useState(false),
|
|
53
|
+
overflown = _useState2[0],
|
|
54
|
+
setOverflown = _useState2[1];
|
|
55
|
+
|
|
44
56
|
var scrollLeftRef = useRef(0);
|
|
45
57
|
var hasErrorMessage = Boolean(errorText);
|
|
46
58
|
var paddingDiff = useRef();
|
|
@@ -76,11 +88,62 @@ var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
|
76
88
|
paddingDiff.current = parseFloat(paddingLeft) + parseFloat(paddingRight);
|
|
77
89
|
}
|
|
78
90
|
});
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
useEffect(function () {
|
|
92
|
+
if (!autoResize && expandable && inputRef && inputRef.current) {
|
|
93
|
+
setOverflown(inputRef.current.input.scrollWidth > inputRef.current.input.clientWidth);
|
|
94
|
+
}
|
|
95
|
+
}, [autoResize, expandable, expanded]);
|
|
96
|
+
|
|
97
|
+
var handleTextareaChange = function handleTextareaChange(event) {
|
|
98
|
+
var newValue = event.currentTarget.value;
|
|
99
|
+
|
|
100
|
+
if (counterLimit && newValue.length > counterLimit) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
antdInputProps.onChange && antdInputProps.onChange(event);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
var handleExpandableTextareaBlur = function handleExpandableTextareaBlur(event) {
|
|
108
|
+
setExpanded(false);
|
|
109
|
+
|
|
110
|
+
if (inputRef.current) {
|
|
111
|
+
inputRef.current.input.value = event.target.value;
|
|
112
|
+
inputRef.current.input.focus();
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
var handleExpandIconClick = function handleExpandIconClick(event) {
|
|
117
|
+
event.stopPropagation();
|
|
118
|
+
|
|
119
|
+
if (inputRef.current && expandableTextAreaRef.current) {
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
expandableTextAreaRef.current.value = inputRef.current.input.value;
|
|
122
|
+
expandableTextAreaRef.current.focus();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
setExpanded(true);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
useEffect(function () {
|
|
129
|
+
if (expanded) {
|
|
130
|
+
expandableTextAreaRef.current && expandableTextAreaRef.current.focus();
|
|
131
|
+
}
|
|
132
|
+
}, [expandableTextAreaRef, expanded]);
|
|
133
|
+
var handleChange = useCallback(function (event) {
|
|
134
|
+
var _event$currentTarget = event.currentTarget,
|
|
135
|
+
newValue = _event$currentTarget.value,
|
|
136
|
+
scrollWidth = _event$currentTarget.scrollWidth,
|
|
137
|
+
clientWidth = _event$currentTarget.clientWidth;
|
|
138
|
+
var isNowOverflown = scrollWidth > clientWidth;
|
|
139
|
+
|
|
140
|
+
if (!autoResize && expandable && isNowOverflown !== overflown) {
|
|
141
|
+
setOverflown(isNowOverflown);
|
|
142
|
+
}
|
|
143
|
+
|
|
81
144
|
if (counterLimit && newValue.length > counterLimit) return;
|
|
82
|
-
antdInputProps.onChange && antdInputProps.onChange(
|
|
83
|
-
}, [antdInputProps, counterLimit]);
|
|
145
|
+
antdInputProps.onChange && antdInputProps.onChange(event);
|
|
146
|
+
}, [antdInputProps, autoResize, counterLimit, expandable, overflown]);
|
|
84
147
|
var stretchToFit = autoResize && autoResize !== true && Boolean(autoResize.stretchToFit);
|
|
85
148
|
|
|
86
149
|
var preAutosize = function preAutosize() {
|
|
@@ -90,15 +153,46 @@ var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
|
90
153
|
inputRef.current && inputRef.current.input.style.removeProperty('max-width');
|
|
91
154
|
};
|
|
92
155
|
|
|
93
|
-
var onAutosize = function onAutosize() {
|
|
156
|
+
var onAutosize = function onAutosize(newWidth) {
|
|
94
157
|
var parentRect = elementRef.current && elementRef.current.getBoundingClientRect();
|
|
95
158
|
|
|
96
159
|
if (stretchToFit && inputRef.current && parentRect != null && parentRect.width && paddingDiff.current) {
|
|
97
160
|
inputRef.current.input.style.maxWidth = (parentRect == null ? void 0 : parentRect.width) - paddingDiff.current + "px";
|
|
98
161
|
inputRef.current.input.scrollLeft = scrollLeftRef.current;
|
|
99
162
|
}
|
|
163
|
+
|
|
164
|
+
if (autoResize && inputRef.current && expandable) {
|
|
165
|
+
var style = window.getComputedStyle(inputRef.current.input);
|
|
166
|
+
var minWidth = parseInt(style.minWidth, 10);
|
|
167
|
+
setOverflown(newWidth > minWidth);
|
|
168
|
+
}
|
|
100
169
|
};
|
|
101
170
|
|
|
171
|
+
var autoSizedComponent = /*#__PURE__*/React.createElement(AutosizeWrapper, {
|
|
172
|
+
preAutosize: preAutosize,
|
|
173
|
+
onAutosize: onAutosize,
|
|
174
|
+
value: antdInputProps.value,
|
|
175
|
+
autoResize: !!autoResize
|
|
176
|
+
}, /*#__PURE__*/React.createElement(WrappedComponent, _extends({
|
|
177
|
+
autoResize: autoResize,
|
|
178
|
+
"data-testid": "input-autosize-input"
|
|
179
|
+
}, antdInputProps, {
|
|
180
|
+
className: hasErrorMessage || error ? 'error' : undefined,
|
|
181
|
+
addonBefore: !!prefixel && /*#__PURE__*/React.createElement(S.AddonWrapper, {
|
|
182
|
+
className: "ds-input-prefix",
|
|
183
|
+
height: inputAddonHeight - VERTICAL_BORDER_OFFSET
|
|
184
|
+
}, prefixel),
|
|
185
|
+
addonAfter: !!suffixel && /*#__PURE__*/React.createElement(S.AddonWrapper, {
|
|
186
|
+
className: "ds-input-suffix",
|
|
187
|
+
height: inputAddonHeight - VERTICAL_BORDER_OFFSET
|
|
188
|
+
}, suffixel),
|
|
189
|
+
error: hasErrorMessage || error,
|
|
190
|
+
onChange: handleChange,
|
|
191
|
+
value: antdInputProps.value,
|
|
192
|
+
autoComplete: "off",
|
|
193
|
+
id: id,
|
|
194
|
+
ref: inputRef
|
|
195
|
+
})));
|
|
102
196
|
return /*#__PURE__*/React.createElement(S.OuterWrapper, {
|
|
103
197
|
ref: elementRef,
|
|
104
198
|
autoResize: autoResize,
|
|
@@ -110,10 +204,12 @@ var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
|
110
204
|
id: id,
|
|
111
205
|
tooltip: tooltip,
|
|
112
206
|
tooltipConfig: tooltipConfig,
|
|
113
|
-
charCount: charCount
|
|
207
|
+
charCount: charCount,
|
|
208
|
+
renderCustomCounter: renderCustomCounter
|
|
114
209
|
}), /*#__PURE__*/React.createElement(S.InputWrapper, {
|
|
115
210
|
icon1: Boolean(icon1),
|
|
116
|
-
icon2: Boolean(icon2)
|
|
211
|
+
icon2: Boolean(icon2),
|
|
212
|
+
icon3: !!expandable
|
|
117
213
|
}, /*#__PURE__*/React.createElement(ElementIcons, {
|
|
118
214
|
handleIconsClick: handleIconsClick,
|
|
119
215
|
disabled: antdInputProps.disabled,
|
|
@@ -122,31 +218,18 @@ var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
|
122
218
|
icon1Tooltip: icon1Tooltip,
|
|
123
219
|
icon2Tooltip: icon2Tooltip,
|
|
124
220
|
className: className,
|
|
125
|
-
type: "input"
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
221
|
+
type: "input",
|
|
222
|
+
expandable: expandable,
|
|
223
|
+
overflown: overflown,
|
|
224
|
+
handleExpandIconClick: handleExpandIconClick,
|
|
225
|
+
expandableTooltip: expandableTooltip
|
|
226
|
+
}), expandable ? /*#__PURE__*/React.createElement(ExpandableWrapper, {
|
|
227
|
+
onChange: handleTextareaChange,
|
|
228
|
+
onBlur: handleExpandableTextareaBlur,
|
|
229
|
+
ref: expandableTextAreaRef,
|
|
129
230
|
value: antdInputProps.value,
|
|
130
|
-
|
|
131
|
-
}, /*#__PURE__*/React.createElement(
|
|
132
|
-
autoResize: autoResize
|
|
133
|
-
}, antdInputProps, {
|
|
134
|
-
className: hasErrorMessage || error ? 'error' : undefined,
|
|
135
|
-
addonBefore: !!prefixel && /*#__PURE__*/React.createElement(S.AddonWrapper, {
|
|
136
|
-
className: "ds-input-prefix",
|
|
137
|
-
height: inputAddonHeight - VERTICAL_BORDER_OFFSET
|
|
138
|
-
}, prefixel),
|
|
139
|
-
addonAfter: !!suffixel && /*#__PURE__*/React.createElement(S.AddonWrapper, {
|
|
140
|
-
className: "ds-input-suffix",
|
|
141
|
-
height: inputAddonHeight - VERTICAL_BORDER_OFFSET
|
|
142
|
-
}, suffixel),
|
|
143
|
-
error: hasErrorMessage || error,
|
|
144
|
-
onChange: handleChange,
|
|
145
|
-
value: antdInputProps.value,
|
|
146
|
-
autoComplete: "off",
|
|
147
|
-
id: id,
|
|
148
|
-
ref: inputRef
|
|
149
|
-
})))), /*#__PURE__*/React.createElement(ContentBelowElement, {
|
|
231
|
+
expanded: expanded
|
|
232
|
+
}, autoSizedComponent) : autoSizedComponent), /*#__PURE__*/React.createElement(ContentBelowElement, {
|
|
150
233
|
description: description,
|
|
151
234
|
errorText: errorText
|
|
152
235
|
}));
|
package/dist/Input.styles.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import BaseAntInput, { InputProps } from 'antd/lib/input';
|
|
3
|
-
import TextArea from 'antd/lib/input/TextArea';
|
|
3
|
+
import TextArea, { TextAreaProps } from 'antd/lib/input/TextArea';
|
|
4
4
|
import MaskedInput from 'antd-mask-input';
|
|
5
5
|
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
6
6
|
import type { AutoResizeProp } from './Input.types';
|
|
@@ -14,15 +14,16 @@ export type AutoResizeInputProps = {
|
|
|
14
14
|
export declare function autoresizeConfObjToCss({ autoResize }: {
|
|
15
15
|
autoResize?: AutoResizeProp;
|
|
16
16
|
}): string;
|
|
17
|
+
export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
17
18
|
export declare const InputWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
18
|
-
icon1
|
|
19
|
-
icon2
|
|
19
|
+
icon1?: boolean | undefined;
|
|
20
|
+
icon2?: boolean | undefined;
|
|
21
|
+
icon3?: boolean | undefined;
|
|
20
22
|
}, never>;
|
|
21
23
|
export declare const OuterWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
22
24
|
resetMargin?: boolean | undefined;
|
|
23
25
|
autoResize?: AutoResizeProp | undefined;
|
|
24
26
|
}, never>;
|
|
25
|
-
export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
26
27
|
export declare const IconsWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
27
28
|
disabled?: boolean | undefined;
|
|
28
29
|
}, never>;
|
|
@@ -49,11 +50,14 @@ export declare const AntdMaskedInput: import("styled-components").StyledComponen
|
|
|
49
50
|
error?: boolean | undefined;
|
|
50
51
|
autoResize?: AutoResizeProp | undefined;
|
|
51
52
|
}, never>;
|
|
52
|
-
export declare const AntdTextArea: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<{
|
|
53
|
+
export declare const AntdTextArea: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<TextAreaProps & {
|
|
53
54
|
error?: boolean | undefined;
|
|
54
55
|
} & React.RefAttributes<TextArea>>, any, {
|
|
55
56
|
error?: boolean | undefined;
|
|
56
57
|
}, never>;
|
|
58
|
+
export declare const ExpandableWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
59
|
+
expanded: boolean;
|
|
60
|
+
}, never>;
|
|
57
61
|
export declare const ContentBelow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
58
62
|
export declare const WrapperAutoResize: import("styled-components").StyledComponent<"div", any, {
|
|
59
63
|
autoResize?: AutoResizeProp | undefined;
|
package/dist/Input.styles.js
CHANGED
|
@@ -9,7 +9,9 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
9
9
|
import React, { forwardRef } from 'react';
|
|
10
10
|
import styled, { css } from 'styled-components';
|
|
11
11
|
import BaseAntInput from 'antd/lib/input';
|
|
12
|
+
import TextArea from 'antd/lib/input/TextArea';
|
|
12
13
|
import MaskedInput from 'antd-mask-input';
|
|
14
|
+
import { TextareaWrapper } from './Textarea/Textarea.styles';
|
|
13
15
|
|
|
14
16
|
var errorInputStyle = function errorInputStyle(props) {
|
|
15
17
|
return "\n &&&, && .ant-input {\n border-color: " + props.theme.palette['red-600'] + ";\n box-shadow: inset 0 0 0 1px " + props.theme.palette['red-600'] + ";\n background: " + props.theme.palette['red-050'] + ";\n }\n";
|
|
@@ -37,18 +39,24 @@ export function autoresizeConfObjToCss(_ref) {
|
|
|
37
39
|
|
|
38
40
|
return "max-width: 400px; min-width: 150px;";
|
|
39
41
|
}
|
|
42
|
+
export var Wrapper = styled.div.withConfig({
|
|
43
|
+
displayName: "Inputstyles__Wrapper",
|
|
44
|
+
componentId: "dc57an-0"
|
|
45
|
+
})(["margin-bottom:24px;"]);
|
|
40
46
|
export var InputWrapper = styled.div.withConfig({
|
|
41
47
|
displayName: "Inputstyles__InputWrapper",
|
|
42
|
-
componentId: "dc57an-
|
|
48
|
+
componentId: "dc57an-1"
|
|
43
49
|
})(["position:relative;&& .ant-input{padding-right:", ";&::placeholder{line-height:1.29;}}.ant-input-group-addon{height:100%;}"], function (props) {
|
|
44
|
-
|
|
45
|
-
if (
|
|
50
|
+
var iconsCount = Number(props.icon1) + Number(props.icon2) + Number(props.icon3);
|
|
51
|
+
if (iconsCount === 3) return '92px;';
|
|
52
|
+
if (iconsCount === 2) return '64px;';
|
|
53
|
+
if (iconsCount === 1) return '36px;';
|
|
46
54
|
return '12px';
|
|
47
55
|
});
|
|
48
56
|
export var OuterWrapper = styled.div.withConfig({
|
|
49
57
|
displayName: "Inputstyles__OuterWrapper",
|
|
50
|
-
componentId: "dc57an-
|
|
51
|
-
})(["margin:", ";&.active{&&{input{box-shadow:inset 0 0 0 1px ", ";border-color:", ";background-color:", ";}}}input{", "}", "
|
|
58
|
+
componentId: "dc57an-2"
|
|
59
|
+
})(["margin:", ";&.active{&&{input{box-shadow:inset 0 0 0 1px ", ";border-color:", ";background-color:", ";}}}input{", "}", ""], function (props) {
|
|
52
60
|
return props.resetMargin ? '0' : '0 0 16px 0';
|
|
53
61
|
}, function (props) {
|
|
54
62
|
return props.theme.palette['blue-600'];
|
|
@@ -58,13 +66,9 @@ export var OuterWrapper = styled.div.withConfig({
|
|
|
58
66
|
return props.theme.palette['blue-050'];
|
|
59
67
|
}, function (props) {
|
|
60
68
|
return autoresizeConfObjToCss(props);
|
|
61
|
-
},
|
|
62
|
-
return props.autoResize && "\n display: inline-block;\n ";
|
|
69
|
+
}, function (props) {
|
|
70
|
+
return props.autoResize && "\n " + InputWrapper + " {\n display: inline-block;\n }";
|
|
63
71
|
});
|
|
64
|
-
export var Wrapper = styled.div.withConfig({
|
|
65
|
-
displayName: "Inputstyles__Wrapper",
|
|
66
|
-
componentId: "dc57an-2"
|
|
67
|
-
})(["margin-bottom:24px;"]);
|
|
68
72
|
export var IconsWrapper = styled.div.withConfig({
|
|
69
73
|
displayName: "Inputstyles__IconsWrapper",
|
|
70
74
|
componentId: "dc57an-3"
|
|
@@ -139,12 +143,12 @@ function (_ref4, ref) {
|
|
|
139
143
|
}, function (props) {
|
|
140
144
|
return props.theme.palette['grey-700'];
|
|
141
145
|
});
|
|
142
|
-
export var AntdTextArea = styled(forwardRef( // eslint-disable-next-line
|
|
146
|
+
export var AntdTextArea = styled(forwardRef( // eslint-disable-next-line
|
|
143
147
|
function (_ref5, ref) {
|
|
144
148
|
var error = _ref5.error,
|
|
145
149
|
props = _objectWithoutPropertiesLoose(_ref5, _excluded3);
|
|
146
150
|
|
|
147
|
-
return /*#__PURE__*/React.createElement(
|
|
151
|
+
return /*#__PURE__*/React.createElement(TextArea, _extends({
|
|
148
152
|
autoComplete: "off"
|
|
149
153
|
}, props, {
|
|
150
154
|
ref: ref
|
|
@@ -157,19 +161,29 @@ function (_ref5, ref) {
|
|
|
157
161
|
}, function (props) {
|
|
158
162
|
return props.theme.palette['grey-700'];
|
|
159
163
|
});
|
|
164
|
+
export var ExpandableWrapper = styled.div.withConfig({
|
|
165
|
+
displayName: "Inputstyles__ExpandableWrapper",
|
|
166
|
+
componentId: "dc57an-9"
|
|
167
|
+
})(["position:relative;overflow:visible;", "{position:absolute;top:0;left:0;right:0;z-index:999;resize:none;max-height:124px;min-width:282px;", "}"], TextareaWrapper, function (props) {
|
|
168
|
+
if (props.expanded) {
|
|
169
|
+
return css(["pointer-events:initial;display:block;"]);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return css(["pointer-events:none;display:none;"]);
|
|
173
|
+
});
|
|
160
174
|
export var ContentBelow = styled.div.withConfig({
|
|
161
175
|
displayName: "Inputstyles__ContentBelow",
|
|
162
|
-
componentId: "dc57an-
|
|
176
|
+
componentId: "dc57an-10"
|
|
163
177
|
})(["margin-top:8px;"]);
|
|
164
178
|
export var WrapperAutoResize = styled.div.withConfig({
|
|
165
179
|
displayName: "Inputstyles__WrapperAutoResize",
|
|
166
|
-
componentId: "dc57an-
|
|
180
|
+
componentId: "dc57an-11"
|
|
167
181
|
})(["display:inline-grid;align-items:center justify-items:start;", ""], function (props) {
|
|
168
182
|
return autoresizeConfObjToCss(props);
|
|
169
183
|
});
|
|
170
184
|
export var AutoResize = styled.div.withConfig({
|
|
171
185
|
displayName: "Inputstyles__AutoResize",
|
|
172
|
-
componentId: "dc57an-
|
|
186
|
+
componentId: "dc57an-12"
|
|
173
187
|
})(["max-height:32px;grid-area:1 / 1;visibility:hidden;white-space:pre;padding:", ";", ";@media (max-width:1420px){max-width:300px;}@media (max-width:1150px){max-width:200px;}@media (max-width:1100px){max-width:150px;}"], function (props) {
|
|
174
188
|
return getPaddingAutoResize(props);
|
|
175
189
|
}, function (props) {
|
|
@@ -177,33 +191,35 @@ export var AutoResize = styled.div.withConfig({
|
|
|
177
191
|
});
|
|
178
192
|
export var ErrorText = styled.div.withConfig({
|
|
179
193
|
displayName: "Inputstyles__ErrorText",
|
|
180
|
-
componentId: "dc57an-
|
|
194
|
+
componentId: "dc57an-13"
|
|
181
195
|
})(["color:", ";margin-bottom:4px;"], function (props) {
|
|
182
196
|
return props.theme.palette['red-600'];
|
|
183
197
|
});
|
|
184
198
|
export var Label = styled.label.withConfig({
|
|
185
199
|
displayName: "Inputstyles__Label",
|
|
186
|
-
componentId: "dc57an-
|
|
200
|
+
componentId: "dc57an-14"
|
|
187
201
|
})(["color:", ";font-weight:500;display:block;"], function (props) {
|
|
188
202
|
return props.theme.palette['grey-800'];
|
|
189
203
|
});
|
|
190
204
|
export var Counter = styled.div.withConfig({
|
|
191
205
|
displayName: "Inputstyles__Counter",
|
|
192
|
-
componentId: "dc57an-
|
|
193
|
-
})(["font-weight:500;"])
|
|
206
|
+
componentId: "dc57an-15"
|
|
207
|
+
})(["font-weight:500;color:", ";"], function (props) {
|
|
208
|
+
return props.theme.palette['grey-500'];
|
|
209
|
+
});
|
|
194
210
|
export var Description = styled.div.withConfig({
|
|
195
211
|
displayName: "Inputstyles__Description",
|
|
196
|
-
componentId: "dc57an-
|
|
212
|
+
componentId: "dc57an-16"
|
|
197
213
|
})(["color:", ";"], function (props) {
|
|
198
214
|
return props.theme.palette['grey-600'];
|
|
199
215
|
});
|
|
200
216
|
export var ContentAbove = styled.div.withConfig({
|
|
201
217
|
displayName: "Inputstyles__ContentAbove",
|
|
202
|
-
componentId: "dc57an-
|
|
218
|
+
componentId: "dc57an-17"
|
|
203
219
|
})(["display:flex;justify-content:space-between;margin-bottom:8px;min-height:18px;"]);
|
|
204
220
|
export var AddonWrapper = styled.div.withConfig({
|
|
205
221
|
displayName: "Inputstyles__AddonWrapper",
|
|
206
|
-
componentId: "dc57an-
|
|
222
|
+
componentId: "dc57an-18"
|
|
207
223
|
})(["background:", ";display:flex;align-items:center;height:", ";"], function (props) {
|
|
208
224
|
return props.theme.palette['grey-050'];
|
|
209
225
|
}, function (props) {
|
package/dist/Input.types.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ export type AutoResizeProp = boolean | {
|
|
|
8
8
|
maxWidth?: string;
|
|
9
9
|
stretchToFit?: boolean;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type Props = BaseProps<HTMLInputElement | HTMLTextAreaElement>;
|
|
12
|
+
export type BaseProps<RefElementType extends HTMLTextAreaElement | HTMLInputElement = HTMLInputElement> = {
|
|
12
13
|
error?: boolean;
|
|
13
14
|
className?: string;
|
|
14
15
|
tooltip?: ReactNode;
|
|
@@ -17,6 +18,7 @@ export interface BaseProps<RefElementType extends HTMLTextAreaElement | HTMLInpu
|
|
|
17
18
|
label?: ReactNode;
|
|
18
19
|
description?: ReactNode;
|
|
19
20
|
counterLimit?: number;
|
|
21
|
+
renderCustomCounter?: (count: number) => ReactNode;
|
|
20
22
|
icon1?: ReactElement;
|
|
21
23
|
icon1Tooltip?: ReactElement;
|
|
22
24
|
icon2?: ReactElement;
|
|
@@ -26,7 +28,9 @@ export interface BaseProps<RefElementType extends HTMLTextAreaElement | HTMLInpu
|
|
|
26
28
|
prefixel?: ReactNode;
|
|
27
29
|
suffixel?: ReactNode;
|
|
28
30
|
autoResize?: AutoResizeProp;
|
|
29
|
-
|
|
31
|
+
expandable?: boolean;
|
|
32
|
+
expandableTooltip?: ReactNode;
|
|
33
|
+
};
|
|
30
34
|
/**
|
|
31
35
|
* @deprecated use `InputProps`, `TextareaProps` or `MaskedInputProps` instead
|
|
32
36
|
*/
|
package/dist/InputGroup.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { Props } from './InputGroup.types';
|
|
2
|
-
declare const InputGroup: ({ children, label, errors, description, resetMargin, tooltip, ...antdInputGroupProps }: Props) => JSX.Element;
|
|
3
|
+
declare const InputGroup: ({ children, label, errors, description, resetMargin, tooltip, ...antdInputGroupProps }: Props) => React.JSX.Element;
|
|
3
4
|
export default InputGroup;
|
|
@@ -97,7 +97,8 @@ var InputMultivalue = function InputMultivalue(props) {
|
|
|
97
97
|
},
|
|
98
98
|
onFocus: onFocus,
|
|
99
99
|
disabled: disabled,
|
|
100
|
-
maxLength: maxLength
|
|
100
|
+
maxLength: maxLength,
|
|
101
|
+
"data-testid": "input-multivalue"
|
|
101
102
|
})), (showError || description) && /*#__PURE__*/React.createElement(S.ContentBelow, null, showError && /*#__PURE__*/React.createElement(S.ErrorText, null, errorText), description && /*#__PURE__*/React.createElement(S.Description, null, description)));
|
|
102
103
|
};
|
|
103
104
|
|
package/dist/Label/Label.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { LabelProps } from './Label.types';
|
|
2
|
-
declare const Label: ({ id, className, label, tooltip, tooltipConfig, style }: LabelProps) => JSX.Element;
|
|
3
|
+
declare const Label: ({ id, className, label, tooltip, tooltipConfig, style }: LabelProps) => React.JSX.Element;
|
|
3
4
|
export default Label;
|
|
@@ -6,4 +6,4 @@ export declare const LabelText: import("styled-components").StyledComponent<({ s
|
|
|
6
6
|
ellipsis?: import("@synerise/ds-typography/dist/Ellipsis").EllipsisProps | undefined;
|
|
7
7
|
children?: import("react").ReactNode;
|
|
8
8
|
className?: string | undefined;
|
|
9
|
-
}) => JSX.Element, any, {}, never>;
|
|
9
|
+
}) => import("react").JSX.Element, any, {}, never>;
|
package/dist/TextArea.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import '@synerise/ds-core/dist/js/style';
|
|
3
3
|
import './style/index.less';
|
|
4
4
|
import { TextareaProps } from './TextArea.types';
|
|
5
|
-
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;
|
|
6
|
-
export declare const RawTextArea: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<{
|
|
5
|
+
export declare const TextArea: ({ className, errorText, label, description, counterLimit, tooltip, tooltipConfig, icon1, icon1Tooltip, autoResize, icon2, icon2Tooltip, resetMargin, handleInputRef, prefixel, suffixel, error, renderCustomCounter, ...antdTextareaProps }: TextareaProps) => React.JSX.Element;
|
|
6
|
+
export declare const RawTextArea: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<import("antd/lib/input").TextAreaProps & {
|
|
7
7
|
error?: boolean | undefined;
|
|
8
8
|
} & React.RefAttributes<import("antd/lib/input/TextArea").default>>, any, {
|
|
9
9
|
error?: boolean | undefined;
|
package/dist/TextArea.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "autoResize", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error"];
|
|
1
|
+
var _excluded = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "autoResize", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error", "renderCustomCounter"];
|
|
2
2
|
|
|
3
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); }
|
|
4
4
|
|
|
@@ -31,6 +31,7 @@ export var TextArea = function TextArea(_ref) {
|
|
|
31
31
|
prefixel = _ref.prefixel,
|
|
32
32
|
suffixel = _ref.suffixel,
|
|
33
33
|
error = _ref.error,
|
|
34
|
+
renderCustomCounter = _ref.renderCustomCounter,
|
|
34
35
|
antdTextareaProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
35
36
|
|
|
36
37
|
var id = useMemo(function () {
|
|
@@ -62,7 +63,8 @@ export var TextArea = function TextArea(_ref) {
|
|
|
62
63
|
id: id,
|
|
63
64
|
tooltip: tooltip,
|
|
64
65
|
tooltipConfig: tooltipConfig,
|
|
65
|
-
charCount: charCount
|
|
66
|
+
charCount: charCount,
|
|
67
|
+
renderCustomCounter: renderCustomCounter
|
|
66
68
|
}), /*#__PURE__*/React.createElement(S.InputWrapper, {
|
|
67
69
|
icon1: Boolean(icon1),
|
|
68
70
|
icon2: Boolean(icon2)
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
declare const Textarea: React.
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import TextArea from 'antd/lib/input/TextArea';
|
|
3
|
+
declare const Textarea: React.ForwardRefExoticComponent<import("antd/lib/input/TextArea").TextAreaProps & {
|
|
4
|
+
error?: boolean | undefined;
|
|
5
|
+
errorText?: React.ReactNode;
|
|
6
|
+
wrapperStyle?: React.CSSProperties | undefined;
|
|
7
|
+
resize?: import("csstype").ResizeProperty | undefined;
|
|
8
|
+
} & React.RefAttributes<TextArea>>;
|
|
4
9
|
export default Textarea;
|
|
@@ -10,12 +10,11 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
10
10
|
|
|
11
11
|
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
12
|
|
|
13
|
-
import
|
|
14
|
-
import Input from 'antd/lib/input';
|
|
13
|
+
import React, { forwardRef, useState } from 'react';
|
|
15
14
|
import Scrollbar from '@synerise/ds-scrollbar';
|
|
16
15
|
import * as S from './Textarea.styles';
|
|
17
|
-
|
|
18
|
-
var Textarea = function
|
|
16
|
+
import * as InputStyles from '../Input.styles';
|
|
17
|
+
var Textarea = forwardRef(function (_ref, ref) {
|
|
19
18
|
var disabled = _ref.disabled,
|
|
20
19
|
error = _ref.error,
|
|
21
20
|
_ref$rows = _ref.rows,
|
|
@@ -28,26 +27,27 @@ var Textarea = function Textarea(_ref) {
|
|
|
28
27
|
readOnly = _ref.readOnly,
|
|
29
28
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
30
29
|
|
|
31
|
-
var
|
|
32
|
-
focus =
|
|
33
|
-
setFocus =
|
|
30
|
+
var _useState = useState(false),
|
|
31
|
+
focus = _useState[0],
|
|
32
|
+
setFocus = _useState[1];
|
|
34
33
|
|
|
35
34
|
return /*#__PURE__*/React.createElement(S.TextareaWrapper, {
|
|
36
35
|
className: "ds-textarea",
|
|
37
36
|
isDisabled: Boolean(disabled),
|
|
38
37
|
isFocused: focus,
|
|
38
|
+
isReadOnly: readOnly,
|
|
39
39
|
hasError: Boolean(error),
|
|
40
40
|
resize: resize,
|
|
41
41
|
style: _objectSpread({
|
|
42
42
|
height: autoSize ? 'auto' : rows * 17 + "px"
|
|
43
|
-
}, wrapperStyle)
|
|
44
|
-
isReadOnly: readOnly
|
|
43
|
+
}, wrapperStyle)
|
|
45
44
|
}, /*#__PURE__*/React.createElement(Scrollbar, {
|
|
46
45
|
absolute: true,
|
|
47
46
|
classes: "textarea-scrollbar"
|
|
48
|
-
}, /*#__PURE__*/React.createElement(
|
|
47
|
+
}, /*#__PURE__*/React.createElement(InputStyles.AntdTextArea, _extends({
|
|
49
48
|
autoSize: autoSize
|
|
50
49
|
}, props, {
|
|
50
|
+
ref: ref,
|
|
51
51
|
disabled: disabled,
|
|
52
52
|
readOnly: readOnly,
|
|
53
53
|
onFocus: function onFocus(e) {
|
|
@@ -59,6 +59,5 @@ var Textarea = function Textarea(_ref) {
|
|
|
59
59
|
setFocus(false);
|
|
60
60
|
}
|
|
61
61
|
}))));
|
|
62
|
-
};
|
|
63
|
-
|
|
62
|
+
});
|
|
64
63
|
export default Textarea;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { BaseProps } from '../Input.types';
|
|
2
|
-
type ContentAboveProps = Pick<BaseProps, 'tooltip' | 'tooltipConfig' | 'label'> & {
|
|
3
|
+
type ContentAboveProps = Pick<BaseProps, 'tooltip' | 'tooltipConfig' | 'label' | 'renderCustomCounter'> & {
|
|
3
4
|
counterLimit?: number;
|
|
4
|
-
charCount
|
|
5
|
+
charCount: number;
|
|
5
6
|
id: string;
|
|
6
7
|
};
|
|
7
|
-
export declare const ContentAboveElement: ({ label, counterLimit, id, tooltip, tooltipConfig, charCount, }: ContentAboveProps) => JSX.Element;
|
|
8
|
+
export declare const ContentAboveElement: ({ label, counterLimit, id, tooltip, tooltipConfig, charCount, renderCustomCounter, }: ContentAboveProps) => React.JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -7,13 +7,16 @@ export var ContentAboveElement = function ContentAboveElement(_ref) {
|
|
|
7
7
|
id = _ref.id,
|
|
8
8
|
tooltip = _ref.tooltip,
|
|
9
9
|
tooltipConfig = _ref.tooltipConfig,
|
|
10
|
-
charCount = _ref.charCount
|
|
10
|
+
charCount = _ref.charCount,
|
|
11
|
+
renderCustomCounter = _ref.renderCustomCounter;
|
|
11
12
|
return label || counterLimit ? /*#__PURE__*/React.createElement(S.ContentAbove, null, /*#__PURE__*/React.createElement(Label, {
|
|
12
13
|
label: label,
|
|
13
14
|
id: id,
|
|
14
15
|
tooltip: tooltip,
|
|
15
16
|
tooltipConfig: tooltipConfig
|
|
16
|
-
}),
|
|
17
|
+
}), renderCustomCounter ? /*#__PURE__*/React.createElement(S.Counter, {
|
|
18
|
+
"data-testid": "custom-counter"
|
|
19
|
+
}, renderCustomCounter(charCount)) : counterLimit && /*#__PURE__*/React.createElement(S.Counter, {
|
|
17
20
|
"data-testid": "counter"
|
|
18
21
|
}, charCount, "/", counterLimit)) : /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
19
22
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { BaseProps } from '../Input.types';
|
|
2
3
|
type ContentBelowProps = Pick<BaseProps, 'description' | 'errorText'>;
|
|
3
|
-
export declare const ContentBelowElement: ({ description, errorText }: ContentBelowProps) => JSX.Element | null;
|
|
4
|
+
export declare const ContentBelowElement: ({ description, errorText }: ContentBelowProps) => React.JSX.Element | null;
|
|
4
5
|
export {};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import React, { MouseEvent } from 'react';
|
|
1
2
|
import { BaseProps } from '../Input.types';
|
|
2
|
-
type IconProps = Pick<BaseProps, 'icon1' | 'icon1Tooltip' | 'icon2' | 'icon2Tooltip' | 'className'> & {
|
|
3
|
+
type IconProps = Pick<BaseProps, 'icon1' | 'icon1Tooltip' | 'icon2' | 'icon2Tooltip' | 'className' | 'expandable' | 'expandableTooltip'> & {
|
|
3
4
|
disabled?: boolean;
|
|
4
5
|
handleIconsClick: () => void;
|
|
5
6
|
type: string;
|
|
7
|
+
overflown?: boolean;
|
|
8
|
+
handleExpandIconClick?: (event: MouseEvent<HTMLDivElement>) => void;
|
|
6
9
|
};
|
|
7
|
-
export declare const ElementIcons: ({ handleIconsClick, disabled, icon1Tooltip, icon1, icon2, icon2Tooltip, className, type, }: IconProps) => JSX.Element
|
|
10
|
+
export declare const ElementIcons: ({ handleIconsClick, disabled, icon1Tooltip, icon1, icon2, icon2Tooltip, className, type, expandable, overflown, expandableTooltip, handleExpandIconClick, }: IconProps) => React.JSX.Element;
|
|
8
11
|
export {};
|
|
@@ -6,6 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
6
6
|
|
|
7
7
|
import React, { cloneElement } from 'react';
|
|
8
8
|
import Tooltip from '@synerise/ds-tooltip/dist/Tooltip';
|
|
9
|
+
import Icon, { ResizeArrowM } from '@synerise/ds-icon';
|
|
9
10
|
import * as S from '../Input.styles';
|
|
10
11
|
export var ElementIcons = function ElementIcons(_ref) {
|
|
11
12
|
var handleIconsClick = _ref.handleIconsClick,
|
|
@@ -15,18 +16,26 @@ export var ElementIcons = function ElementIcons(_ref) {
|
|
|
15
16
|
icon2 = _ref.icon2,
|
|
16
17
|
icon2Tooltip = _ref.icon2Tooltip,
|
|
17
18
|
className = _ref.className,
|
|
18
|
-
type = _ref.type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return /*#__PURE__*/React.createElement(S.IconsWrapper, {
|
|
19
|
+
type = _ref.type,
|
|
20
|
+
expandable = _ref.expandable,
|
|
21
|
+
overflown = _ref.overflown,
|
|
22
|
+
expandableTooltip = _ref.expandableTooltip,
|
|
23
|
+
handleExpandIconClick = _ref.handleExpandIconClick;
|
|
24
|
+
return icon1 || icon2 || expandable ? /*#__PURE__*/React.createElement(S.IconsWrapper, {
|
|
25
25
|
onClick: handleIconsClick,
|
|
26
26
|
disabled: disabled
|
|
27
27
|
}, /*#__PURE__*/React.createElement(S.IconsFlexContainer, {
|
|
28
28
|
type: type
|
|
29
29
|
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
30
|
+
title: expandableTooltip
|
|
31
|
+
}, /*#__PURE__*/React.createElement(S.IconWrapper, {
|
|
32
|
+
"data-testid": "inputExpandIcon",
|
|
33
|
+
onClick: handleExpandIconClick,
|
|
34
|
+
className: className
|
|
35
|
+
}, expandable && overflown && /*#__PURE__*/React.createElement(Icon, {
|
|
36
|
+
className: "icon icon3",
|
|
37
|
+
component: /*#__PURE__*/React.createElement(ResizeArrowM, null)
|
|
38
|
+
}))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
30
39
|
title: icon1Tooltip
|
|
31
40
|
}, /*#__PURE__*/React.createElement(S.IconWrapper, {
|
|
32
41
|
className: className
|
|
@@ -42,5 +51,5 @@ export var ElementIcons = function ElementIcons(_ref) {
|
|
|
42
51
|
className: className
|
|
43
52
|
}, icon2 && cloneElement(icon2, {
|
|
44
53
|
className: 'icon icon2'
|
|
45
|
-
})))));
|
|
54
|
+
}))))) : /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
46
55
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { ChangeEvent, FocusEvent, ReactNode } from 'react';
|
|
2
|
+
import type TextArea from 'antd/lib/input/TextArea';
|
|
3
|
+
import { InputProps } from '../Input.types';
|
|
4
|
+
export declare const ExpandableWrapper: React.ForwardRefExoticComponent<Pick<InputProps, "value"> & {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
expanded: boolean;
|
|
7
|
+
onChange: (Event: ChangeEvent<HTMLInputElement> & ChangeEvent<HTMLTextAreaElement>) => void;
|
|
8
|
+
onBlur: (event: FocusEvent<HTMLTextAreaElement>) => void;
|
|
9
|
+
} & React.RefAttributes<TextArea>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import Textarea from '../Textarea/Textarea';
|
|
3
|
+
import * as S from '../Input.styles';
|
|
4
|
+
export var ExpandableWrapper = forwardRef(function (_ref, expandableTextAreaRef) {
|
|
5
|
+
var children = _ref.children,
|
|
6
|
+
value = _ref.value,
|
|
7
|
+
expanded = _ref.expanded,
|
|
8
|
+
onChange = _ref.onChange,
|
|
9
|
+
onBlur = _ref.onBlur;
|
|
10
|
+
return /*#__PURE__*/React.createElement(S.ExpandableWrapper, {
|
|
11
|
+
expanded: expanded
|
|
12
|
+
}, children, /*#__PURE__*/React.createElement(Textarea, {
|
|
13
|
+
"data-testid": "inputExpandTextarea",
|
|
14
|
+
onChange: onChange,
|
|
15
|
+
autoSize: {
|
|
16
|
+
minRows: 2,
|
|
17
|
+
maxRows: 6
|
|
18
|
+
},
|
|
19
|
+
onBlur: onBlur,
|
|
20
|
+
ref: expandableTextAreaRef,
|
|
21
|
+
value: value
|
|
22
|
+
}));
|
|
23
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { ContentAboveElement } from './ContentAboveElement';
|
|
2
2
|
export { ContentBelowElement } from './ContentBelowElement';
|
|
3
3
|
export { ElementIcons } from './ElementIcons';
|
|
4
|
+
export { ExpandableWrapper } from './ExpandableWrapper';
|
|
5
|
+
export { AutosizeWrapper } from './AutosizeWrapper';
|
package/dist/components/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { ContentAboveElement } from './ContentAboveElement';
|
|
2
2
|
export { ContentBelowElement } from './ContentBelowElement';
|
|
3
|
-
export { ElementIcons } from './ElementIcons';
|
|
3
|
+
export { ElementIcons } from './ElementIcons';
|
|
4
|
+
export { ExpandableWrapper } from './ExpandableWrapper';
|
|
5
|
+
export { AutosizeWrapper } from './AutosizeWrapper';
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export * as InputStyles from './Input.styles';
|
|
|
6
6
|
export type { BaseProps, EnhancedProps, InputProps, MaskedInputProps, AutoResizeProp } from './Input.types';
|
|
7
7
|
export { default as AutosizeInput } from './AutosizeInput/AutosizeInput';
|
|
8
8
|
export type { AutosizeInputProps, AutosizeWrapperProps, AutosizeInputRefType, } from './AutosizeInput/AutosizeInput.types';
|
|
9
|
-
export { AutosizeWrapper } from './
|
|
9
|
+
export { AutosizeWrapper } from './components/AutosizeWrapper';
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,4 @@ export { TextArea, RawTextArea } from './TextArea';
|
|
|
4
4
|
import * as _InputStyles from './Input.styles';
|
|
5
5
|
export { _InputStyles as InputStyles };
|
|
6
6
|
export { default as AutosizeInput } from './AutosizeInput/AutosizeInput';
|
|
7
|
-
export { AutosizeWrapper } from './
|
|
7
|
+
export { AutosizeWrapper } from './components/AutosizeWrapper';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { InputProps as AntdInputProps } from 'antd/lib/input';
|
|
2
2
|
import { TextareaProps } from '../TextArea.types';
|
|
3
|
-
export declare const getCharCount: (value?: AntdInputProps['value'] | TextareaProps['value'], limit?: number) => number
|
|
3
|
+
export declare const getCharCount: (value?: AntdInputProps['value'] | TextareaProps['value'], limit?: number) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-input",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
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.
|
|
37
|
-
"@synerise/ds-scrollbar": "^0.
|
|
38
|
-
"@synerise/ds-tooltip": "^0.14.
|
|
36
|
+
"@synerise/ds-icon": "^0.62.1",
|
|
37
|
+
"@synerise/ds-scrollbar": "^0.11.1",
|
|
38
|
+
"@synerise/ds-tooltip": "^0.14.30",
|
|
39
39
|
"@synerise/ds-typography": "^0.15.0",
|
|
40
|
-
"@synerise/ds-utils": "^0.
|
|
40
|
+
"@synerise/ds-utils": "^0.27.0",
|
|
41
41
|
"antd-mask-input": "^0.1.13",
|
|
42
42
|
"csstype": "2.6.9",
|
|
43
43
|
"uuid": "^8.3.2"
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"@testing-library/react": "10.0.1",
|
|
53
53
|
"@testing-library/user-event": "10.3.1"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "ef835e848d4f02cca258130baa6c9f44dfa15dd0"
|
|
56
56
|
}
|
|
File without changes
|
|
File without changes
|