@synerise/ds-input 0.20.0 → 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 +8 -0
- package/dist/Input.d.ts +20 -16
- package/dist/Input.js +158 -122
- package/dist/Input.styles.d.ts +8 -4
- package/dist/Input.styles.js +16 -30
- package/dist/Input.types.d.ts +12 -5
- package/dist/components/ContentAboveElement.d.ts +8 -0
- package/dist/components/ContentAboveElement.js +19 -0
- package/dist/components/ContentBelowElement.d.ts +4 -0
- package/dist/components/ContentBelowElement.js +13 -0
- package/dist/components/ElementIcons.d.ts +8 -0
- package/dist/components/ElementIcons.js +46 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useElementFocus.d.ts +4 -0
- package/dist/hooks/useElementFocus.js +5 -0
- package/dist/hooks/useInputAddonHeight.d.ts +6 -0
- package/dist/hooks/useInputAddonHeight.js +15 -0
- package/dist/index.d.ts +1 -3
- package/dist/utils/getCharCount.d.ts +3 -0
- package/dist/utils/getCharCount.js +4 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
|
|
6
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)
|
|
7
15
|
|
|
8
16
|
|
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 {
|
|
6
|
-
|
|
7
|
-
export declare const
|
|
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
|
-
|
|
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:
|
|
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,110 +1,93 @@
|
|
|
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, {
|
|
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
12
|
import { useResizeToFit } from '@synerise/ds-utils';
|
|
18
|
-
import Tooltip from '@synerise/ds-tooltip/dist/Tooltip';
|
|
19
13
|
import * as S from './Input.styles';
|
|
20
|
-
import
|
|
14
|
+
import { ContentAboveElement, ContentBelowElement, ElementIcons } from './components';
|
|
21
15
|
import Textarea from './Textarea/Textarea';
|
|
22
16
|
import AutosizeInput from './autosize/autosize';
|
|
17
|
+
import { useInputAddonHeight, useElementFocus } from './hooks';
|
|
18
|
+
import { getCharCount } from './utils';
|
|
23
19
|
var VERTICAL_BORDER_OFFSET = 2;
|
|
24
20
|
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
antdInputProps = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
46
|
-
|
|
47
|
-
var _useState = useState(0),
|
|
48
|
-
charCount = _useState[0],
|
|
49
|
-
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);
|
|
50
41
|
|
|
51
|
-
var hasErrorMessage = Boolean(errorText);
|
|
52
42
|
var id = useMemo(function () {
|
|
53
43
|
return uuid();
|
|
54
44
|
}, []);
|
|
55
|
-
var
|
|
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);
|
|
56
51
|
|
|
57
|
-
var
|
|
58
|
-
inputAddonHeight =
|
|
59
|
-
setInputAddonHeight = _useState2[1];
|
|
52
|
+
var _useInputAddonHeight = useInputAddonHeight(inputRef),
|
|
53
|
+
inputAddonHeight = _useInputAddonHeight.inputAddonHeight;
|
|
60
54
|
|
|
61
55
|
useEffect(function () {
|
|
62
|
-
|
|
56
|
+
if (inputRef && inputRef.current) {
|
|
57
|
+
externalRef.current = inputRef.current.input;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
handleInputRef && handleInputRef(externalRef);
|
|
63
61
|
}, [inputRef, handleInputRef]);
|
|
64
62
|
var handleChange = useCallback(function (e) {
|
|
65
63
|
var newValue = e.currentTarget.value;
|
|
66
64
|
if (counterLimit && newValue.length > counterLimit) return;
|
|
67
65
|
antdInputProps.onChange && antdInputProps.onChange(e);
|
|
68
66
|
}, [antdInputProps, counterLimit]);
|
|
69
|
-
var handleIconsClick = useCallback(function () {
|
|
70
|
-
inputRef.current && inputRef.current.focus();
|
|
71
|
-
}, [inputRef]);
|
|
72
|
-
useEffect(function () {
|
|
73
|
-
if (counterLimit && antdInputProps.value && antdInputProps.value.toString().length > counterLimit) return;
|
|
74
|
-
setCharCount(antdInputProps.value ? antdInputProps.value.toString().length : 0);
|
|
75
|
-
}, [antdInputProps.value, counterLimit]);
|
|
76
|
-
useEffect(function () {
|
|
77
|
-
var _inputRef$current, _inputRef$current$inp;
|
|
78
67
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
ref: inputRef,
|
|
103
|
-
autoComplete: "off"
|
|
104
|
-
}));
|
|
105
|
-
};
|
|
106
|
-
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
107
|
-
[antdInputProps, handleChange]);
|
|
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
|
+
|
|
108
91
|
var stretchToFit = typeof autoResize === 'object' && Boolean(autoResize.stretchToFit);
|
|
109
92
|
var paddingDiff = useRef();
|
|
110
93
|
|
|
@@ -153,57 +136,110 @@ var enhancedInput = function enhancedInput(WrappedComponent, _ref) {
|
|
|
153
136
|
autoResize: autoResize,
|
|
154
137
|
className: className,
|
|
155
138
|
resetMargin: resetMargin
|
|
156
|
-
},
|
|
139
|
+
}, /*#__PURE__*/React.createElement(ContentAboveElement, {
|
|
157
140
|
label: label,
|
|
141
|
+
counterLimit: counterLimit,
|
|
158
142
|
id: id,
|
|
159
143
|
tooltip: tooltip,
|
|
160
|
-
tooltipConfig: tooltipConfig
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}, charCount, "/", counterLimit)), /*#__PURE__*/React.createElement(S.InputWrapper, {
|
|
144
|
+
tooltipConfig: tooltipConfig,
|
|
145
|
+
charCount: charCount
|
|
146
|
+
}), /*#__PURE__*/React.createElement(S.InputWrapper, {
|
|
164
147
|
ref: elementRef,
|
|
165
148
|
icon1: Boolean(icon1),
|
|
166
149
|
icon2: Boolean(icon2)
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
disabled: antdInputProps.disabled
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
marginRight: '4px'
|
|
181
|
-
}
|
|
182
|
-
})))), /*#__PURE__*/React.createElement(Tooltip, {
|
|
183
|
-
title: icon2Tooltip
|
|
184
|
-
}, /*#__PURE__*/React.createElement(S.IconWrapper, {
|
|
185
|
-
className: className
|
|
186
|
-
}, icon2 && cloneElement(icon2, {
|
|
187
|
-
className: 'icon icon2'
|
|
188
|
-
}))))), 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
|
+
}));
|
|
189
163
|
};
|
|
190
164
|
};
|
|
191
165
|
|
|
192
|
-
export var
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
+
};
|
|
207
243
|
export var RawMaskedInput = S.AntdMaskedInput;
|
|
208
244
|
export { default as InputGroup } from './InputGroup';
|
|
209
245
|
export var RawInput = function RawInput(props) {
|
package/dist/Input.styles.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { MutableRefObject, ReactNode } from 'react';
|
|
2
|
-
import BaseAntInput from 'antd/lib/input';
|
|
2
|
+
import BaseAntInput, { InputProps } from 'antd/lib/input';
|
|
3
3
|
import TextArea from 'antd/lib/input/TextArea';
|
|
4
4
|
import MaskedInput from 'antd-mask-input';
|
|
5
5
|
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
@@ -32,16 +32,20 @@ export declare const IconsFlexContainer: import("styled-components").StyledCompo
|
|
|
32
32
|
type: string;
|
|
33
33
|
}, never>;
|
|
34
34
|
export declare const IconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
35
|
-
export declare const AntdInput: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<{
|
|
35
|
+
export declare const AntdInput: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<InputProps & {
|
|
36
36
|
error?: boolean | undefined;
|
|
37
37
|
size?: SizeType;
|
|
38
38
|
} & React.RefAttributes<BaseAntInput>>, any, {
|
|
39
39
|
error?: boolean | undefined;
|
|
40
40
|
readOnly?: boolean | undefined;
|
|
41
41
|
}, never>;
|
|
42
|
-
export declare const AntdMaskedInput: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<{
|
|
43
|
-
error?: boolean | undefined;
|
|
42
|
+
export declare const AntdMaskedInput: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<InputProps & {
|
|
44
43
|
mask: string;
|
|
44
|
+
formatCharacters?: object | undefined;
|
|
45
|
+
placeholderChar?: string | undefined;
|
|
46
|
+
value?: string | undefined;
|
|
47
|
+
} & {
|
|
48
|
+
error?: boolean | undefined;
|
|
45
49
|
} & React.RefAttributes<MaskedInput>>, any, {
|
|
46
50
|
error?: boolean | undefined;
|
|
47
51
|
}, never>;
|
package/dist/Input.styles.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var _excluded = ["error"],
|
|
2
|
-
_excluded2 = ["error"
|
|
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); }
|
|
@@ -92,15 +92,11 @@ function (_ref2, ref) {
|
|
|
92
92
|
var error = _ref2.error,
|
|
93
93
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
94
94
|
|
|
95
|
-
return (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}, props, {
|
|
101
|
-
ref: ref
|
|
102
|
-
}))
|
|
103
|
-
);
|
|
95
|
+
return /*#__PURE__*/React.createElement(BaseAntInput, _extends({
|
|
96
|
+
autoComplete: "off"
|
|
97
|
+
}, props, {
|
|
98
|
+
ref: ref
|
|
99
|
+
}));
|
|
104
100
|
})).withConfig({
|
|
105
101
|
displayName: "Inputstyles__AntdInput",
|
|
106
102
|
componentId: "dc57an-6"
|
|
@@ -120,19 +116,13 @@ function (_ref2, ref) {
|
|
|
120
116
|
export var AntdMaskedInput = styled(forwardRef( // eslint-disable-next-line
|
|
121
117
|
function (_ref4, ref) {
|
|
122
118
|
var error = _ref4.error,
|
|
123
|
-
mask = _ref4.mask,
|
|
124
119
|
props = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
125
120
|
|
|
126
|
-
return (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}, props, {
|
|
132
|
-
ref: ref,
|
|
133
|
-
mask: mask
|
|
134
|
-
}))
|
|
135
|
-
);
|
|
121
|
+
return /*#__PURE__*/React.createElement(MaskedInput, _extends({
|
|
122
|
+
autoComplete: "off"
|
|
123
|
+
}, props, {
|
|
124
|
+
ref: ref
|
|
125
|
+
}));
|
|
136
126
|
})).withConfig({
|
|
137
127
|
displayName: "Inputstyles__AntdMaskedInput",
|
|
138
128
|
componentId: "dc57an-7"
|
|
@@ -148,15 +138,11 @@ function (_ref5, ref) {
|
|
|
148
138
|
var error = _ref5.error,
|
|
149
139
|
props = _objectWithoutPropertiesLoose(_ref5, _excluded3);
|
|
150
140
|
|
|
151
|
-
return (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}, props, {
|
|
157
|
-
ref: ref
|
|
158
|
-
}))
|
|
159
|
-
);
|
|
141
|
+
return /*#__PURE__*/React.createElement(BaseAntInput.TextArea, _extends({
|
|
142
|
+
autoComplete: "off"
|
|
143
|
+
}, props, {
|
|
144
|
+
ref: ref
|
|
145
|
+
}));
|
|
160
146
|
})).withConfig({
|
|
161
147
|
displayName: "Inputstyles__AntdTextArea",
|
|
162
148
|
componentId: "dc57an-8"
|
package/dist/Input.types.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { ReactNode, ReactElement, MutableRefObject } from 'react';
|
|
2
|
-
import { InputProps, TextAreaProps } from 'antd/lib/input';
|
|
3
|
-
import { MaskedInputProps } from 'antd-mask-input/build/main/lib/MaskedInput';
|
|
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';
|
|
4
4
|
import { TooltipProps } from 'antd/lib/tooltip';
|
|
5
5
|
import TooltipExtendedProps from '@synerise/ds-tooltip/dist/Tooltip.types';
|
|
6
|
+
import { TextAreaProps } from './Textarea/Textarea.types';
|
|
6
7
|
export type AutoResizeProp = boolean | {
|
|
7
8
|
minWidth: string;
|
|
8
9
|
maxWidth?: string;
|
|
9
10
|
stretchToFit?: boolean;
|
|
10
11
|
};
|
|
11
|
-
export interface
|
|
12
|
+
export interface BaseProps<RefElementType extends HTMLTextAreaElement | HTMLInputElement = HTMLInputElement> {
|
|
12
13
|
error?: boolean;
|
|
13
14
|
className?: string;
|
|
14
15
|
tooltip?: ReactNode;
|
|
@@ -22,9 +23,15 @@ export interface Props {
|
|
|
22
23
|
icon2?: ReactElement;
|
|
23
24
|
icon2Tooltip?: ReactElement;
|
|
24
25
|
resetMargin?: boolean;
|
|
25
|
-
handleInputRef?: (ref: MutableRefObject<
|
|
26
|
+
handleInputRef?: (ref: MutableRefObject<RefElementType | null>) => void;
|
|
26
27
|
prefixel?: ReactNode;
|
|
27
28
|
suffixel?: ReactNode;
|
|
28
29
|
autoResize?: AutoResizeProp;
|
|
29
30
|
}
|
|
30
|
-
|
|
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;
|
|
@@ -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,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,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,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, AutoResizeProp } 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 @@
|
|
|
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.20.
|
|
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",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@testing-library/react": "10.0.1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "914ce4be2e0e1fe145edeca838ab04eaa1aec1bf"
|
|
55
55
|
}
|