@synerise/ds-input 0.24.14 → 0.24.16
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 +16 -0
- package/dist/AutosizeInput/AutosizeInput.js +24 -49
- package/dist/AutosizeInput/utils/calculateInputWidth.js +5 -10
- package/dist/Input.js +34 -62
- package/dist/Input.styles.js +12 -24
- package/dist/InputGroup.js +6 -11
- package/dist/InputMultivalue/Elements/Value.js +6 -10
- package/dist/InputMultivalue/InputMultivalue.js +19 -34
- package/dist/InputMultivalue/InputMultivalue.styles.js +0 -6
- package/dist/Label/Label.js +5 -8
- package/dist/TextArea.js +18 -24
- package/dist/Textarea/Textarea.js +12 -22
- package/dist/components/AutosizeWrapper.js +4 -9
- package/dist/components/ContentAboveElement.js +6 -6
- package/dist/components/ContentBelowElement.js +1 -3
- package/dist/components/ElementIcons.js +11 -16
- package/dist/components/ExpandableWrapper.js +4 -4
- package/dist/hooks/useInputAddonHeight.js +2 -4
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.24.16](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@0.24.15...@synerise/ds-input@0.24.16) (2024-11-29)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-input
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.24.15](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@0.24.14...@synerise/ds-input@0.24.15) (2024-11-28)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @synerise/ds-input
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [0.24.14](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@0.24.13...@synerise/ds-input@0.24.14) (2024-11-21)
|
|
7
23
|
|
|
8
24
|
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
var _excluded = ["extraWidth", "wrapperClassName", "wrapperStyle", "onAutosize", "preAutosize", "placeholderIsMinWidth", "minWidth", "handleInputRef", "children", "transformWrapperRef", "transformRef"];
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
|
|
9
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
10
|
-
|
|
11
6
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
-
|
|
13
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; }
|
|
14
|
-
|
|
15
8
|
import React, { useState, useEffect, useRef, useLayoutEffect, forwardRef, useImperativeHandle, useCallback } from 'react';
|
|
16
9
|
import { useResizeObserver } from '@synerise/ds-utils';
|
|
17
10
|
import { calculateInputWidth } from './utils';
|
|
@@ -26,50 +19,42 @@ var sizerStyle = {
|
|
|
26
19
|
};
|
|
27
20
|
var AutosizeInput = forwardRef(function (_ref, forwardedRef) {
|
|
28
21
|
var _ref2, _props$value, _props$style$display, _props$style;
|
|
29
|
-
|
|
30
22
|
var _ref$extraWidth = _ref.extraWidth,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
23
|
+
extraWidth = _ref$extraWidth === void 0 ? 16 : _ref$extraWidth,
|
|
24
|
+
wrapperClassName = _ref.wrapperClassName,
|
|
25
|
+
wrapperStyleProp = _ref.wrapperStyle,
|
|
26
|
+
onAutosize = _ref.onAutosize,
|
|
27
|
+
preAutosize = _ref.preAutosize,
|
|
28
|
+
placeholderIsMinWidth = _ref.placeholderIsMinWidth,
|
|
29
|
+
_ref$minWidth = _ref.minWidth,
|
|
30
|
+
minWidth = _ref$minWidth === void 0 ? 0 : _ref$minWidth,
|
|
31
|
+
handleInputRef = _ref.handleInputRef,
|
|
32
|
+
children = _ref.children,
|
|
33
|
+
_ref$transformWrapper = _ref.transformWrapperRef,
|
|
34
|
+
transformWrapperRef = _ref$transformWrapper === void 0 ? function (element) {
|
|
35
|
+
return element;
|
|
36
|
+
} : _ref$transformWrapper,
|
|
37
|
+
_ref$transformRef = _ref.transformRef,
|
|
38
|
+
transformRef = _ref$transformRef === void 0 ? function (element) {
|
|
39
|
+
return element;
|
|
40
|
+
} : _ref$transformRef,
|
|
41
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
51
42
|
var inputRef = useRef(null);
|
|
52
43
|
var inputWrapperRef = useRef(null);
|
|
53
44
|
var sizerRef = useRef(null);
|
|
54
45
|
var placeholderSizerRef = useRef(null);
|
|
55
46
|
var wrapperRef = useRef(null);
|
|
56
|
-
|
|
57
47
|
var _useState = useState(0),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
inputWidth = _useState[0],
|
|
49
|
+
setInputWidth = _useState[1];
|
|
61
50
|
var _useResizeObserver = useResizeObserver(sizerRef),
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
updatedSizerWidth = _useResizeObserver.width;
|
|
64
52
|
var _useResizeObserver2 = useResizeObserver(placeholderSizerRef),
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
updatedPlaceholderWidth = _useResizeObserver2.width;
|
|
67
54
|
var usedValue = (_ref2 = (_props$value = props.value) != null ? _props$value : props.defaultValue) != null ? _ref2 : '';
|
|
68
|
-
|
|
69
55
|
var copyInputStyles = function copyInputStyles() {
|
|
70
56
|
if (inputRef.current) {
|
|
71
57
|
var computedStyle = window.getComputedStyle(inputRef.current);
|
|
72
|
-
|
|
73
58
|
if (sizerRef.current) {
|
|
74
59
|
sizerRef.current.style.fontSize = computedStyle.fontSize;
|
|
75
60
|
sizerRef.current.style.fontFamily = computedStyle.fontFamily;
|
|
@@ -78,7 +63,6 @@ var AutosizeInput = forwardRef(function (_ref, forwardedRef) {
|
|
|
78
63
|
sizerRef.current.style.letterSpacing = computedStyle.letterSpacing;
|
|
79
64
|
sizerRef.current.style.textTransform = computedStyle.textTransform;
|
|
80
65
|
}
|
|
81
|
-
|
|
82
66
|
if (placeholderSizerRef.current) {
|
|
83
67
|
placeholderSizerRef.current.style.fontSize = computedStyle.fontSize;
|
|
84
68
|
placeholderSizerRef.current.style.fontFamily = computedStyle.fontFamily;
|
|
@@ -89,16 +73,13 @@ var AutosizeInput = forwardRef(function (_ref, forwardedRef) {
|
|
|
89
73
|
}
|
|
90
74
|
}
|
|
91
75
|
};
|
|
92
|
-
|
|
93
76
|
var resize = useCallback(function (width) {
|
|
94
77
|
preAutosize && preAutosize(width);
|
|
95
78
|
setInputWidth(width + +extraWidth);
|
|
96
79
|
onAutosize && onAutosize(width);
|
|
97
80
|
}, [extraWidth, onAutosize, preAutosize]);
|
|
98
|
-
|
|
99
81
|
var updateInputWidth = function updateInputWidth() {
|
|
100
82
|
var _sizerRef$current, _placeholderSizerRef$;
|
|
101
|
-
|
|
102
83
|
var sizerWidth = (_sizerRef$current = sizerRef.current) == null ? void 0 : _sizerRef$current.scrollWidth;
|
|
103
84
|
var placeholderWidth = (_placeholderSizerRef$ = placeholderSizerRef.current) == null ? void 0 : _placeholderSizerRef$.scrollWidth;
|
|
104
85
|
var calculatedWidth = calculateInputWidth({
|
|
@@ -109,14 +90,12 @@ var AutosizeInput = forwardRef(function (_ref, forwardedRef) {
|
|
|
109
90
|
minWidth: +minWidth,
|
|
110
91
|
placeholder: props.placeholder
|
|
111
92
|
});
|
|
112
|
-
|
|
113
93
|
if (sizerWidth && usedValue && calculatedWidth || props.placeholder && placeholderWidth || sizerRef.current) {
|
|
114
94
|
resize(calculatedWidth);
|
|
115
95
|
}
|
|
116
96
|
};
|
|
117
|
-
/* Copy styles of the input field to the sizer, ensuring that the width of the input adjusts accordingly */
|
|
118
|
-
|
|
119
97
|
|
|
98
|
+
/* Copy styles of the input field to the sizer, ensuring that the width of the input adjusts accordingly */
|
|
120
99
|
useLayoutEffect(function () {
|
|
121
100
|
copyInputStyles();
|
|
122
101
|
}, []);
|
|
@@ -130,11 +109,9 @@ var AutosizeInput = forwardRef(function (_ref, forwardedRef) {
|
|
|
130
109
|
var sizerSibling = sizerRef.current.nextElementSibling;
|
|
131
110
|
var inputElement = sizerSibling instanceof HTMLElement && transformRef(sizerSibling);
|
|
132
111
|
var inputWrapperElement = sizerSibling instanceof HTMLElement && transformWrapperRef(sizerSibling);
|
|
133
|
-
|
|
134
112
|
if (inputWrapperElement && inputWrapperElement instanceof HTMLElement) {
|
|
135
113
|
inputWrapperRef.current = inputWrapperElement;
|
|
136
114
|
}
|
|
137
|
-
|
|
138
115
|
if (inputElement) {
|
|
139
116
|
if (inputElement && inputElement instanceof HTMLInputElement) {
|
|
140
117
|
inputRef.current = inputElement;
|
|
@@ -156,12 +133,10 @@ var AutosizeInput = forwardRef(function (_ref, forwardedRef) {
|
|
|
156
133
|
updateInputWidth: updateInputWidth
|
|
157
134
|
};
|
|
158
135
|
});
|
|
159
|
-
|
|
160
136
|
var wrapperStyle = _objectSpread({}, wrapperStyleProp, {
|
|
161
137
|
position: 'relative',
|
|
162
138
|
display: (_props$style$display = (_props$style = props.style) == null ? void 0 : _props$style.display) != null ? _props$style$display : 'inline-block'
|
|
163
139
|
});
|
|
164
|
-
|
|
165
140
|
return /*#__PURE__*/React.createElement("div", {
|
|
166
141
|
ref: wrapperRef,
|
|
167
142
|
className: wrapperClassName,
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
var calculateInputWidth = function calculateInputWidth(_ref) {
|
|
2
2
|
var sizerWidth = _ref.sizerWidth,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
usedValue = _ref.usedValue,
|
|
4
|
+
placeholderIsMinWidth = _ref.placeholderIsMinWidth,
|
|
5
|
+
placeholderWidth = _ref.placeholderWidth,
|
|
6
|
+
minWidth = _ref.minWidth,
|
|
7
|
+
placeholder = _ref.placeholder;
|
|
8
8
|
var width = 0;
|
|
9
|
-
|
|
10
9
|
if (sizerWidth && usedValue) {
|
|
11
10
|
/* If the input field has content, update the sizer to match its width */
|
|
12
11
|
width = sizerWidth;
|
|
13
|
-
|
|
14
12
|
if (placeholderIsMinWidth && placeholderWidth && sizerWidth < placeholderWidth) {
|
|
15
13
|
width = placeholderWidth;
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
if (minWidth !== undefined && width < minWidth) {
|
|
19
16
|
width = minWidth;
|
|
20
17
|
}
|
|
@@ -23,8 +20,6 @@ var calculateInputWidth = function calculateInputWidth(_ref) {
|
|
|
23
20
|
} else {
|
|
24
21
|
width = minWidth || 0;
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
return width;
|
|
28
24
|
};
|
|
29
|
-
|
|
30
25
|
export default calculateInputWidth;
|
package/dist/Input.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
var _excluded = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "autoResize", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error", "expandable", "expandableTooltip", "renderCustomCounter"];
|
|
2
|
-
|
|
3
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
-
|
|
7
4
|
import React, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
|
|
8
5
|
import { v4 as uuid } from 'uuid';
|
|
9
6
|
import { useResizeObserver } from '@synerise/ds-utils';
|
|
@@ -14,45 +11,40 @@ import { ContentAboveElement, ContentBelowElement, ElementIcons, AutosizeWrapper
|
|
|
14
11
|
import { useInputAddonHeight, useElementFocus } from './hooks';
|
|
15
12
|
import { getCharCount } from './utils';
|
|
16
13
|
var VERTICAL_BORDER_OFFSET = 2;
|
|
17
|
-
|
|
18
14
|
var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
19
15
|
return function (_ref) {
|
|
20
16
|
var className = _ref.className,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
errorText = _ref.errorText,
|
|
18
|
+
label = _ref.label,
|
|
19
|
+
description = _ref.description,
|
|
20
|
+
counterLimit = _ref.counterLimit,
|
|
21
|
+
tooltip = _ref.tooltip,
|
|
22
|
+
tooltipConfig = _ref.tooltipConfig,
|
|
23
|
+
icon1 = _ref.icon1,
|
|
24
|
+
icon1Tooltip = _ref.icon1Tooltip,
|
|
25
|
+
autoResize = _ref.autoResize,
|
|
26
|
+
icon2 = _ref.icon2,
|
|
27
|
+
icon2Tooltip = _ref.icon2Tooltip,
|
|
28
|
+
resetMargin = _ref.resetMargin,
|
|
29
|
+
handleInputRef = _ref.handleInputRef,
|
|
30
|
+
prefixel = _ref.prefixel,
|
|
31
|
+
suffixel = _ref.suffixel,
|
|
32
|
+
error = _ref.error,
|
|
33
|
+
expandable = _ref.expandable,
|
|
34
|
+
expandableTooltip = _ref.expandableTooltip,
|
|
35
|
+
renderCustomCounter = _ref.renderCustomCounter,
|
|
36
|
+
antdInputProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
42
37
|
var id = useMemo(function () {
|
|
43
38
|
return uuid();
|
|
44
39
|
}, []);
|
|
45
40
|
var charCount = getCharCount(antdInputProps.value, counterLimit);
|
|
46
41
|
var expandableTextAreaRef = useRef(null);
|
|
47
|
-
|
|
48
42
|
var _useState = useState(false),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
expanded = _useState[0],
|
|
44
|
+
setExpanded = _useState[1];
|
|
52
45
|
var _useState2 = useState(false),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
overflown = _useState2[0],
|
|
47
|
+
setOverflown = _useState2[1];
|
|
56
48
|
var scrollLeftRef = useRef(0);
|
|
57
49
|
var hasErrorMessage = Boolean(errorText);
|
|
58
50
|
var paddingDiff = useRef();
|
|
@@ -61,16 +53,13 @@ var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
|
61
53
|
var externalRef = useRef(null);
|
|
62
54
|
var elementRef = useRef(null);
|
|
63
55
|
var handleIconsClick = useElementFocus(inputRef);
|
|
64
|
-
|
|
65
56
|
var _useInputAddonHeight = useInputAddonHeight(inputRef),
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
inputAddonHeight = _useInputAddonHeight.inputAddonHeight;
|
|
68
58
|
useResizeObserver(elementRef);
|
|
69
59
|
useEffect(function () {
|
|
70
60
|
if (inputRef.current) {
|
|
71
61
|
externalRef.current = inputRef.current.input;
|
|
72
62
|
}
|
|
73
|
-
|
|
74
63
|
handleInputRef && handleInputRef(externalRef);
|
|
75
64
|
}, [handleInputRef]);
|
|
76
65
|
useEffect(function () {
|
|
@@ -82,9 +71,8 @@ var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
|
82
71
|
useEffect(function () {
|
|
83
72
|
if (inputRef.current) {
|
|
84
73
|
var _getComputedStyle = getComputedStyle(inputRef.current.input),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
74
|
+
paddingLeft = _getComputedStyle.paddingLeft,
|
|
75
|
+
paddingRight = _getComputedStyle.paddingRight;
|
|
88
76
|
paddingDiff.current = parseFloat(paddingLeft) + parseFloat(paddingRight);
|
|
89
77
|
}
|
|
90
78
|
});
|
|
@@ -93,38 +81,29 @@ var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
|
93
81
|
setOverflown(inputRef.current.input.scrollWidth > inputRef.current.input.clientWidth);
|
|
94
82
|
}
|
|
95
83
|
}, [autoResize, expandable, expanded]);
|
|
96
|
-
|
|
97
84
|
var handleTextareaChange = function handleTextareaChange(event) {
|
|
98
85
|
var newValue = event.currentTarget.value;
|
|
99
|
-
|
|
100
86
|
if (counterLimit && newValue.length > counterLimit) {
|
|
101
87
|
return;
|
|
102
88
|
}
|
|
103
|
-
|
|
104
89
|
antdInputProps.onChange && antdInputProps.onChange(event);
|
|
105
90
|
};
|
|
106
|
-
|
|
107
91
|
var handleExpandableTextareaBlur = function handleExpandableTextareaBlur(event) {
|
|
108
92
|
setExpanded(false);
|
|
109
|
-
|
|
110
93
|
if (inputRef.current) {
|
|
111
94
|
inputRef.current.input.value = event.target.value;
|
|
112
95
|
inputRef.current.input.focus();
|
|
113
96
|
}
|
|
114
97
|
};
|
|
115
|
-
|
|
116
98
|
var handleExpandIconClick = function handleExpandIconClick(event) {
|
|
117
99
|
event.stopPropagation();
|
|
118
|
-
|
|
119
100
|
if (inputRef.current && expandableTextAreaRef.current) {
|
|
120
101
|
// @ts-ignore
|
|
121
102
|
expandableTextAreaRef.current.value = inputRef.current.input.value;
|
|
122
103
|
expandableTextAreaRef.current.focus();
|
|
123
104
|
}
|
|
124
|
-
|
|
125
105
|
setExpanded(true);
|
|
126
106
|
};
|
|
127
|
-
|
|
128
107
|
useEffect(function () {
|
|
129
108
|
if (expanded) {
|
|
130
109
|
expandableTextAreaRef.current && expandableTextAreaRef.current.focus();
|
|
@@ -132,42 +111,34 @@ var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
|
132
111
|
}, [expandableTextAreaRef, expanded]);
|
|
133
112
|
var handleChange = useCallback(function (event) {
|
|
134
113
|
var _event$currentTarget = event.currentTarget,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
114
|
+
newValue = _event$currentTarget.value,
|
|
115
|
+
scrollWidth = _event$currentTarget.scrollWidth,
|
|
116
|
+
clientWidth = _event$currentTarget.clientWidth;
|
|
138
117
|
var isNowOverflown = scrollWidth > clientWidth;
|
|
139
|
-
|
|
140
118
|
if (!autoResize && expandable && isNowOverflown !== overflown) {
|
|
141
119
|
setOverflown(isNowOverflown);
|
|
142
120
|
}
|
|
143
|
-
|
|
144
121
|
if (counterLimit && newValue.length > counterLimit) return;
|
|
145
122
|
antdInputProps.onChange && antdInputProps.onChange(event);
|
|
146
123
|
}, [antdInputProps, autoResize, counterLimit, expandable, overflown]);
|
|
147
124
|
var stretchToFit = autoResize && autoResize !== true && Boolean(autoResize.stretchToFit);
|
|
148
|
-
|
|
149
125
|
var preAutosize = function preAutosize() {
|
|
150
126
|
var _inputRef$current;
|
|
151
|
-
|
|
152
127
|
scrollLeftRef.current = ((_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.input.scrollLeft) || 0;
|
|
153
128
|
inputRef.current && inputRef.current.input.style.removeProperty('max-width');
|
|
154
129
|
};
|
|
155
|
-
|
|
156
130
|
var onAutosize = function onAutosize(newWidth) {
|
|
157
131
|
var parentRect = elementRef.current && elementRef.current.getBoundingClientRect();
|
|
158
|
-
|
|
159
132
|
if (stretchToFit && inputRef.current && parentRect != null && parentRect.width && paddingDiff.current) {
|
|
160
133
|
inputRef.current.input.style.maxWidth = (parentRect == null ? void 0 : parentRect.width) - paddingDiff.current + "px";
|
|
161
134
|
inputRef.current.input.scrollLeft = scrollLeftRef.current;
|
|
162
135
|
}
|
|
163
|
-
|
|
164
136
|
if (autoResize && inputRef.current && expandable) {
|
|
165
137
|
var style = window.getComputedStyle(inputRef.current.input);
|
|
166
138
|
var minWidth = parseInt(style.minWidth, 10);
|
|
167
139
|
setOverflown(newWidth > minWidth);
|
|
168
140
|
}
|
|
169
141
|
};
|
|
170
|
-
|
|
171
142
|
var autoSizedComponent = /*#__PURE__*/React.createElement(AutosizeWrapper, {
|
|
172
143
|
preAutosize: preAutosize,
|
|
173
144
|
onAutosize: onAutosize,
|
|
@@ -235,7 +206,6 @@ var createInputComponent = function createInputComponent(WrappedComponent) {
|
|
|
235
206
|
}));
|
|
236
207
|
};
|
|
237
208
|
};
|
|
238
|
-
|
|
239
209
|
export var Input = createInputComponent(S.AntdInput);
|
|
240
210
|
export var MaskedInput = createInputComponent(S.AntdMaskedInput);
|
|
241
211
|
export var RawMaskedInput = S.AntdMaskedInput;
|
|
@@ -246,8 +216,10 @@ export var RawInput = function RawInput(props) {
|
|
|
246
216
|
}, props));
|
|
247
217
|
};
|
|
248
218
|
export { default as InputGroup } from './InputGroup';
|
|
249
|
-
export { default as InputMultivalue } from './InputMultivalue/InputMultivalue';
|
|
219
|
+
export { default as InputMultivalue } from './InputMultivalue/InputMultivalue';
|
|
250
220
|
|
|
251
|
-
|
|
221
|
+
// @deprecated
|
|
222
|
+
export var AutoResize = Object.assign(S.AutoResize);
|
|
252
223
|
|
|
224
|
+
// @deprecated
|
|
253
225
|
export var WrapperAutoResize = Object.assign(S.WrapperAutoResize);
|
package/dist/Input.styles.js
CHANGED
|
@@ -1,42 +1,32 @@
|
|
|
1
1
|
var _excluded = ["error"],
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
_excluded2 = ["error"],
|
|
3
|
+
_excluded3 = ["error"];
|
|
5
4
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
6
|
-
|
|
7
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; }
|
|
8
|
-
|
|
9
6
|
import React, { forwardRef } from 'react';
|
|
10
7
|
import styled, { css } from 'styled-components';
|
|
11
8
|
import BaseAntInput from 'antd/lib/input';
|
|
12
9
|
import TextArea from 'antd/lib/input/TextArea';
|
|
13
10
|
import MaskedInput from 'antd-mask-input';
|
|
14
11
|
import { TextareaWrapper } from './Textarea/Textarea.styles';
|
|
15
|
-
|
|
16
12
|
var errorInputStyle = function errorInputStyle(props) {
|
|
17
13
|
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";
|
|
18
14
|
};
|
|
19
|
-
|
|
20
15
|
var getPaddingAutoResize = function getPaddingAutoResize(props) {
|
|
21
16
|
if (props.prefixel || props.suffixel) {
|
|
22
17
|
return '0 43px';
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
if (props.icon1 || props.icon2) {
|
|
26
20
|
return '0 25px';
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
return '0 13px';
|
|
30
23
|
};
|
|
31
|
-
|
|
32
24
|
export function autoresizeConfObjToCss(_ref) {
|
|
33
25
|
var autoResize = _ref.autoResize;
|
|
34
26
|
if (!autoResize) return '';
|
|
35
|
-
|
|
36
27
|
if (typeof autoResize === 'object') {
|
|
37
28
|
return "\n " + (autoResize.maxWidth ? "max-width: " + autoResize.maxWidth + ";" : '') + "\n min-width: " + autoResize.minWidth + ";\n ";
|
|
38
29
|
}
|
|
39
|
-
|
|
40
30
|
return "max-width: 400px; min-width: 150px;";
|
|
41
31
|
}
|
|
42
32
|
export var Wrapper = styled.div.withConfig({
|
|
@@ -84,7 +74,6 @@ export var IconsFlexContainer = styled.div.withConfig({
|
|
|
84
74
|
if (props.type === 'input') {
|
|
85
75
|
return css(["display:flex;align-items:center;height:100%;"]);
|
|
86
76
|
}
|
|
87
|
-
|
|
88
77
|
return css(["display:flex;align-items:flex-end;height:100%;padding-bottom:8px;"]);
|
|
89
78
|
});
|
|
90
79
|
export var IconWrapper = styled.div.withConfig({
|
|
@@ -93,11 +82,11 @@ export var IconWrapper = styled.div.withConfig({
|
|
|
93
82
|
})([".icon:hover{svg{fill:", ";cursor:pointer;}}"], function (props) {
|
|
94
83
|
return props.theme.palette['blue-600'];
|
|
95
84
|
});
|
|
96
|
-
export var AntdInput = styled(forwardRef(
|
|
85
|
+
export var AntdInput = styled(forwardRef(
|
|
86
|
+
// eslint-disable-next-line
|
|
97
87
|
function (_ref2, ref) {
|
|
98
88
|
var error = _ref2.error,
|
|
99
|
-
|
|
100
|
-
|
|
89
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
101
90
|
return /*#__PURE__*/React.createElement(BaseAntInput, _extends({
|
|
102
91
|
autoComplete: "off"
|
|
103
92
|
}, props, {
|
|
@@ -118,14 +107,14 @@ function (_ref2, ref) {
|
|
|
118
107
|
return props.size === 'large' ? "2.49" : "1.29";
|
|
119
108
|
}, function (_ref3) {
|
|
120
109
|
var readOnly = _ref3.readOnly,
|
|
121
|
-
|
|
110
|
+
theme = _ref3.theme;
|
|
122
111
|
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 " : '';
|
|
123
112
|
});
|
|
124
|
-
export var AntdMaskedInput = styled(forwardRef(
|
|
113
|
+
export var AntdMaskedInput = styled(forwardRef(
|
|
114
|
+
// eslint-disable-next-line
|
|
125
115
|
function (_ref4, ref) {
|
|
126
116
|
var error = _ref4.error,
|
|
127
|
-
|
|
128
|
-
|
|
117
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
129
118
|
return /*#__PURE__*/React.createElement(MaskedInput, _extends({
|
|
130
119
|
autoComplete: "off"
|
|
131
120
|
}, props, {
|
|
@@ -143,11 +132,11 @@ function (_ref4, ref) {
|
|
|
143
132
|
}, function (props) {
|
|
144
133
|
return props.theme.palette['grey-700'];
|
|
145
134
|
});
|
|
146
|
-
export var AntdTextArea = styled(forwardRef(
|
|
135
|
+
export var AntdTextArea = styled(forwardRef(
|
|
136
|
+
// eslint-disable-next-line
|
|
147
137
|
function (_ref5, ref) {
|
|
148
138
|
var error = _ref5.error,
|
|
149
|
-
|
|
150
|
-
|
|
139
|
+
props = _objectWithoutPropertiesLoose(_ref5, _excluded3);
|
|
151
140
|
return /*#__PURE__*/React.createElement(TextArea, _extends({
|
|
152
141
|
autoComplete: "off"
|
|
153
142
|
}, props, {
|
|
@@ -168,7 +157,6 @@ export var ExpandableWrapper = styled.div.withConfig({
|
|
|
168
157
|
if (props.expanded) {
|
|
169
158
|
return css(["pointer-events:initial;display:block;"]);
|
|
170
159
|
}
|
|
171
|
-
|
|
172
160
|
return css(["pointer-events:none;display:none;"]);
|
|
173
161
|
});
|
|
174
162
|
export var ContentBelow = styled.div.withConfig({
|
package/dist/InputGroup.js
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
var _excluded = ["children", "label", "errors", "description", "resetMargin", "tooltip"];
|
|
2
|
-
|
|
3
2
|
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; }
|
|
4
|
-
|
|
5
3
|
import React, { Children } from 'react';
|
|
6
4
|
import Input from 'antd/lib/input';
|
|
7
5
|
import * as InputStyles from './Input.styles';
|
|
8
6
|
import * as S from './InputGroup.styles';
|
|
9
7
|
import Label from './Label/Label';
|
|
10
|
-
|
|
11
8
|
var InputGroup = function InputGroup(_ref) {
|
|
12
9
|
var children = _ref.children,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
label = _ref.label,
|
|
11
|
+
errors = _ref.errors,
|
|
12
|
+
description = _ref.description,
|
|
13
|
+
resetMargin = _ref.resetMargin,
|
|
14
|
+
tooltip = _ref.tooltip,
|
|
15
|
+
antdInputGroupProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
20
16
|
var childrenArray = Children.toArray(children);
|
|
21
17
|
return /*#__PURE__*/React.createElement(InputStyles.OuterWrapper, {
|
|
22
18
|
className: "ds-input-group-outer-wrapper",
|
|
@@ -36,5 +32,4 @@ var InputGroup = function InputGroup(_ref) {
|
|
|
36
32
|
}, error);
|
|
37
33
|
}), description && /*#__PURE__*/React.createElement(InputStyles.Description, null, description)));
|
|
38
34
|
};
|
|
39
|
-
|
|
40
35
|
export default InputGroup;
|
|
@@ -2,18 +2,15 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import Icon, { CloseS } from '@synerise/ds-icon';
|
|
3
3
|
import Tooltip from '@synerise/ds-tooltip';
|
|
4
4
|
import * as S from '../InputMultivalue.styles';
|
|
5
|
-
|
|
6
5
|
var Value = function Value(_ref) {
|
|
7
6
|
var disabled = _ref.disabled,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
key = _ref.key,
|
|
8
|
+
onRemoveClick = _ref.onRemoveClick,
|
|
9
|
+
value = _ref.value,
|
|
10
|
+
focused = _ref.focused;
|
|
13
11
|
var _useState = useState(false),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
hovered = _useState[0],
|
|
13
|
+
setHovered = _useState[1];
|
|
17
14
|
return (
|
|
18
15
|
/*#__PURE__*/
|
|
19
16
|
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
@@ -47,5 +44,4 @@ var Value = function Value(_ref) {
|
|
|
47
44
|
})))
|
|
48
45
|
);
|
|
49
46
|
};
|
|
50
|
-
|
|
51
47
|
export default Value;
|
|
@@ -1,56 +1,44 @@
|
|
|
1
1
|
var _excluded = ["className", "errorText", "label", "description", "values", "onChange", "onBlur", "onFocus", "disabled", "maxLength", "error"];
|
|
2
|
-
|
|
3
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
-
|
|
7
4
|
import React from 'react';
|
|
8
5
|
import * as S from './InputMultivalue.styles';
|
|
9
6
|
import Value from './Elements/Value';
|
|
10
7
|
var emptyValue = '';
|
|
11
|
-
|
|
12
8
|
var InputMultivalue = function InputMultivalue(props) {
|
|
13
9
|
var className = props.className,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
errorText = props.errorText,
|
|
11
|
+
label = props.label,
|
|
12
|
+
description = props.description,
|
|
13
|
+
values = props.values,
|
|
14
|
+
onChange = props.onChange,
|
|
15
|
+
_onBlur = props.onBlur,
|
|
16
|
+
onFocus = props.onFocus,
|
|
17
|
+
disabled = props.disabled,
|
|
18
|
+
maxLength = props.maxLength,
|
|
19
|
+
error = props.error,
|
|
20
|
+
antdProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
26
21
|
var showError = error || !!errorText;
|
|
27
|
-
|
|
28
22
|
var _React$useState = React.useState(emptyValue),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
value = _React$useState[0],
|
|
24
|
+
setValue = _React$useState[1];
|
|
32
25
|
var _React$useState2 = React.useState(false),
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
isFocused = _React$useState2[0],
|
|
27
|
+
setFocused = _React$useState2[1];
|
|
36
28
|
var inputRef = React.useRef(null);
|
|
37
|
-
|
|
38
29
|
var _React$useState3 = React.useState(values),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
selectedValues = _React$useState3[0],
|
|
31
|
+
setSelectedValues = _React$useState3[1];
|
|
42
32
|
var handleNewValue = function handleNewValue(selected) {
|
|
43
33
|
onChange && onChange(selected);
|
|
44
34
|
setSelectedValues(selected);
|
|
45
35
|
};
|
|
46
|
-
|
|
47
36
|
var handleKeyDown = function handleKeyDown(e) {
|
|
48
37
|
if (e.key === 'Enter') {
|
|
49
38
|
handleNewValue([].concat(selectedValues, [value]));
|
|
50
39
|
setValue(emptyValue);
|
|
51
40
|
}
|
|
52
41
|
};
|
|
53
|
-
|
|
54
42
|
return /*#__PURE__*/React.createElement(React.Fragment, null, label && /*#__PURE__*/React.createElement(S.ContentAbove, null, /*#__PURE__*/React.createElement(S.Label, null, label)), /*#__PURE__*/React.createElement(S.InputWrapper, _extends({
|
|
55
43
|
tabIndex: 0
|
|
56
44
|
}, antdProps, {
|
|
@@ -60,14 +48,14 @@ var InputMultivalue = function InputMultivalue(props) {
|
|
|
60
48
|
if (inputRef && inputRef.current && inputRef.current !== null) {
|
|
61
49
|
inputRef.current.focus();
|
|
62
50
|
}
|
|
63
|
-
|
|
64
51
|
setFocused(true);
|
|
65
52
|
},
|
|
66
53
|
focus: isFocused && !disabled,
|
|
67
54
|
disabled: disabled
|
|
68
55
|
}), selectedValues.map(function (val, index) {
|
|
69
56
|
return /*#__PURE__*/React.createElement(Value, {
|
|
70
|
-
disabled: disabled
|
|
57
|
+
disabled: disabled
|
|
58
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
71
59
|
,
|
|
72
60
|
key: val + "-" + index,
|
|
73
61
|
onRemoveClick: function onRemoveClick() {
|
|
@@ -88,11 +76,9 @@ var InputMultivalue = function InputMultivalue(props) {
|
|
|
88
76
|
ref: inputRef,
|
|
89
77
|
onBlur: function onBlur() {
|
|
90
78
|
_onBlur && _onBlur();
|
|
91
|
-
|
|
92
79
|
if (inputRef && inputRef.current && inputRef.current !== null) {
|
|
93
80
|
inputRef.current.blur();
|
|
94
81
|
}
|
|
95
|
-
|
|
96
82
|
setFocused(false);
|
|
97
83
|
},
|
|
98
84
|
onFocus: onFocus,
|
|
@@ -101,5 +87,4 @@ var InputMultivalue = function InputMultivalue(props) {
|
|
|
101
87
|
"data-testid": "input-multivalue"
|
|
102
88
|
})), (showError || description) && /*#__PURE__*/React.createElement(S.ContentBelow, null, showError && /*#__PURE__*/React.createElement(S.ErrorText, null, errorText), description && /*#__PURE__*/React.createElement(S.Description, null, description)));
|
|
103
89
|
};
|
|
104
|
-
|
|
105
90
|
export default InputMultivalue;
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
|
-
|
|
3
2
|
var errorInputStyle = function errorInputStyle(props) {
|
|
4
3
|
return "\n &&, .ant-input {\n border-color: " + props.theme.palette['red-600'] + ";\n box-shadow: inset 0 0 0 2px " + props.theme.palette['red-600'] + ";\n background: " + props.theme.palette['red-050'] + ";\n border-radius: 4px;\n }\n";
|
|
5
4
|
};
|
|
6
|
-
|
|
7
5
|
var focusStyle = function focusStyle(props) {
|
|
8
6
|
return "\n && {\n box-shadow: inset 0 0 0 2px " + props.theme.palette['blue-600'] + ";\n border-color: " + props.theme.palette['blue-600'] + ";\n background: " + props.theme.palette['blue-050'] + ";\n }\n";
|
|
9
7
|
};
|
|
10
|
-
|
|
11
8
|
var contentShrinkStyle = function contentShrinkStyle() {
|
|
12
9
|
return css(["&&{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}"]);
|
|
13
10
|
};
|
|
14
|
-
|
|
15
11
|
var disabledStyled = function disabledStyled(props) {
|
|
16
12
|
return css(["&:hover,&,&& > *{cursor:not-allowed;}opacity:0.8;color:", ";background:", ";"], props.theme.palette["grey-600"], props.theme.palette['grey-050']);
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
var hoverStyle = function hoverStyle(props) {
|
|
20
15
|
return css(["&:hover{border-color:", ";box-shadow:inset 0 0 0 1px ", ";}"], props.theme.palette['grey-200'], props.theme.palette['grey-400']);
|
|
21
16
|
};
|
|
22
|
-
|
|
23
17
|
export var ContentBelow = styled.div.withConfig({
|
|
24
18
|
displayName: "InputMultivaluestyles__ContentBelow",
|
|
25
19
|
componentId: "sc-1vmqtuf-0"
|
package/dist/Label/Label.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import Tooltip from '@synerise/ds-tooltip';
|
|
5
4
|
import Icon, { InfoFillS } from '@synerise/ds-icon';
|
|
6
5
|
import * as S from './Label.styles';
|
|
7
|
-
|
|
8
6
|
var Label = function Label(_ref) {
|
|
9
7
|
var id = _ref.id,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
className = _ref.className,
|
|
9
|
+
label = _ref.label,
|
|
10
|
+
tooltip = _ref.tooltip,
|
|
11
|
+
tooltipConfig = _ref.tooltipConfig,
|
|
12
|
+
style = _ref.style;
|
|
15
13
|
return /*#__PURE__*/React.createElement(React.Fragment, null, label && /*#__PURE__*/React.createElement(S.Label, {
|
|
16
14
|
style: style,
|
|
17
15
|
htmlFor: id,
|
|
@@ -30,5 +28,4 @@ var Label = function Label(_ref) {
|
|
|
30
28
|
component: /*#__PURE__*/React.createElement(InfoFillS, null)
|
|
31
29
|
})))));
|
|
32
30
|
};
|
|
33
|
-
|
|
34
31
|
export default Label;
|
package/dist/TextArea.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
var _excluded = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "autoResize", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error", "renderCustomCounter"];
|
|
2
|
-
|
|
3
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
-
|
|
7
4
|
import React, { useEffect, useRef, useCallback, useMemo } from 'react';
|
|
8
5
|
import { v4 as uuid } from 'uuid';
|
|
9
6
|
import '@synerise/ds-core/dist/js/style';
|
|
@@ -15,25 +12,24 @@ import { useElementFocus } from './hooks';
|
|
|
15
12
|
import { getCharCount } from './utils';
|
|
16
13
|
export var TextArea = function TextArea(_ref) {
|
|
17
14
|
var className = _ref.className,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
errorText = _ref.errorText,
|
|
16
|
+
label = _ref.label,
|
|
17
|
+
description = _ref.description,
|
|
18
|
+
counterLimit = _ref.counterLimit,
|
|
19
|
+
tooltip = _ref.tooltip,
|
|
20
|
+
tooltipConfig = _ref.tooltipConfig,
|
|
21
|
+
icon1 = _ref.icon1,
|
|
22
|
+
icon1Tooltip = _ref.icon1Tooltip,
|
|
23
|
+
autoResize = _ref.autoResize,
|
|
24
|
+
icon2 = _ref.icon2,
|
|
25
|
+
icon2Tooltip = _ref.icon2Tooltip,
|
|
26
|
+
resetMargin = _ref.resetMargin,
|
|
27
|
+
handleInputRef = _ref.handleInputRef,
|
|
28
|
+
prefixel = _ref.prefixel,
|
|
29
|
+
suffixel = _ref.suffixel,
|
|
30
|
+
error = _ref.error,
|
|
31
|
+
renderCustomCounter = _ref.renderCustomCounter,
|
|
32
|
+
antdTextareaProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
37
33
|
var id = useMemo(function () {
|
|
38
34
|
return uuid();
|
|
39
35
|
}, []);
|
|
@@ -46,11 +42,9 @@ export var TextArea = function TextArea(_ref) {
|
|
|
46
42
|
}, [ref, handleInputRef]);
|
|
47
43
|
var handleChange = useCallback(function (e) {
|
|
48
44
|
var newValue = e.currentTarget.value;
|
|
49
|
-
|
|
50
45
|
if (counterLimit && newValue.length > counterLimit) {
|
|
51
46
|
return;
|
|
52
47
|
}
|
|
53
|
-
|
|
54
48
|
antdTextareaProps.onChange && antdTextareaProps.onChange(e);
|
|
55
49
|
}, [antdTextareaProps, counterLimit]);
|
|
56
50
|
return /*#__PURE__*/React.createElement(S.OuterWrapper, {
|
|
@@ -1,40 +1,30 @@
|
|
|
1
1
|
var _excluded = ["disabled", "error", "rows", "wrapperStyle", "onBlur", "onFocus", "resize", "autoSize", "readOnly"];
|
|
2
|
-
|
|
3
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
|
|
9
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
-
|
|
11
6
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
-
|
|
13
7
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
|
-
|
|
15
8
|
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; }
|
|
16
|
-
|
|
17
9
|
import React, { forwardRef, useState } from 'react';
|
|
18
10
|
import Scrollbar from '@synerise/ds-scrollbar';
|
|
19
11
|
import * as S from './Textarea.styles';
|
|
20
12
|
import * as InputStyles from '../Input.styles';
|
|
21
13
|
var Textarea = forwardRef(function (_ref, ref) {
|
|
22
14
|
var disabled = _ref.disabled,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
error = _ref.error,
|
|
16
|
+
_ref$rows = _ref.rows,
|
|
17
|
+
rows = _ref$rows === void 0 ? 4 : _ref$rows,
|
|
18
|
+
wrapperStyle = _ref.wrapperStyle,
|
|
19
|
+
_onBlur = _ref.onBlur,
|
|
20
|
+
_onFocus = _ref.onFocus,
|
|
21
|
+
resize = _ref.resize,
|
|
22
|
+
autoSize = _ref.autoSize,
|
|
23
|
+
readOnly = _ref.readOnly,
|
|
24
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
34
25
|
var _useState = useState(false),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
focus = _useState[0],
|
|
27
|
+
setFocus = _useState[1];
|
|
38
28
|
return /*#__PURE__*/React.createElement(S.TextareaWrapper, {
|
|
39
29
|
className: "ds-textarea",
|
|
40
30
|
isDisabled: Boolean(disabled),
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
var _excluded = ["autoResize", "extraWidth", "children"];
|
|
2
|
-
|
|
3
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
-
|
|
5
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
-
|
|
7
4
|
import React, { forwardRef } from 'react';
|
|
8
5
|
import AutosizeInput from '../AutosizeInput/AutosizeInput';
|
|
9
6
|
var AUTOSIZE_EXTRA_WIDTH = 2;
|
|
10
7
|
export var AutosizeWrapper = forwardRef(function (_ref, ref) {
|
|
11
8
|
var autoResize = _ref.autoResize,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
_ref$extraWidth = _ref.extraWidth,
|
|
10
|
+
extraWidth = _ref$extraWidth === void 0 ? AUTOSIZE_EXTRA_WIDTH : _ref$extraWidth,
|
|
11
|
+
children = _ref.children,
|
|
12
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
17
13
|
if (autoResize) {
|
|
18
14
|
return /*#__PURE__*/React.createElement(AutosizeInput, _extends({
|
|
19
15
|
ref: ref,
|
|
20
16
|
extraWidth: extraWidth
|
|
21
17
|
}, props), children);
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
25
20
|
});
|
|
@@ -3,12 +3,12 @@ import Label from '../Label/Label';
|
|
|
3
3
|
import * as S from '../Input.styles';
|
|
4
4
|
export var ContentAboveElement = function ContentAboveElement(_ref) {
|
|
5
5
|
var label = _ref.label,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
counterLimit = _ref.counterLimit,
|
|
7
|
+
id = _ref.id,
|
|
8
|
+
tooltip = _ref.tooltip,
|
|
9
|
+
tooltipConfig = _ref.tooltipConfig,
|
|
10
|
+
charCount = _ref.charCount,
|
|
11
|
+
renderCustomCounter = _ref.renderCustomCounter;
|
|
12
12
|
return label || counterLimit ? /*#__PURE__*/React.createElement(S.ContentAbove, null, /*#__PURE__*/React.createElement(Label, {
|
|
13
13
|
label: label,
|
|
14
14
|
id: id,
|
|
@@ -2,12 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import * as S from '../Input.styles';
|
|
3
3
|
export var ContentBelowElement = function ContentBelowElement(_ref) {
|
|
4
4
|
var description = _ref.description,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
errorText = _ref.errorText;
|
|
7
6
|
if (!errorText && !description) {
|
|
8
7
|
return null;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
var hasErrorMessage = Boolean(errorText);
|
|
12
10
|
return /*#__PURE__*/React.createElement(S.ContentBelow, null, hasErrorMessage && /*#__PURE__*/React.createElement(S.ErrorText, null, errorText), description && /*#__PURE__*/React.createElement(S.Description, null, description));
|
|
13
11
|
};
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
3
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
4
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
8
|
-
|
|
9
5
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
10
|
-
|
|
11
6
|
import React, { cloneElement } from 'react';
|
|
12
7
|
import Tooltip from '@synerise/ds-tooltip/dist/Tooltip';
|
|
13
8
|
import Icon, { ResizeArrowM } from '@synerise/ds-icon';
|
|
14
9
|
import * as S from '../Input.styles';
|
|
15
10
|
export var ElementIcons = function ElementIcons(_ref) {
|
|
16
11
|
var handleIconsClick = _ref.handleIconsClick,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
+
expandable = _ref.expandable,
|
|
20
|
+
overflown = _ref.overflown,
|
|
21
|
+
expandableTooltip = _ref.expandableTooltip,
|
|
22
|
+
handleExpandIconClick = _ref.handleExpandIconClick;
|
|
28
23
|
return icon1 || icon2 || expandable ? /*#__PURE__*/React.createElement(S.IconsWrapper, {
|
|
29
24
|
onClick: handleIconsClick,
|
|
30
25
|
disabled: disabled
|
|
@@ -3,10 +3,10 @@ import Textarea from '../Textarea/Textarea';
|
|
|
3
3
|
import * as S from '../Input.styles';
|
|
4
4
|
export var ExpandableWrapper = forwardRef(function (_ref, expandableTextAreaRef) {
|
|
5
5
|
var children = _ref.children,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
value = _ref.value,
|
|
7
|
+
expanded = _ref.expanded,
|
|
8
|
+
onChange = _ref.onChange,
|
|
9
|
+
onBlur = _ref.onBlur;
|
|
10
10
|
return /*#__PURE__*/React.createElement(S.ExpandableWrapper, {
|
|
11
11
|
expanded: expanded
|
|
12
12
|
}, children, /*#__PURE__*/React.createElement(Textarea, {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
export var useInputAddonHeight = function useInputAddonHeight(inputRef) {
|
|
3
3
|
var _useState = useState(0),
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
inputAddonHeight = _useState[0],
|
|
5
|
+
setInputAddonHeight = _useState[1];
|
|
7
6
|
useEffect(function () {
|
|
8
7
|
var _inputRef$current$inp;
|
|
9
|
-
|
|
10
8
|
inputRef.current && setInputAddonHeight((_inputRef$current$inp = inputRef.current.input) == null ? void 0 : _inputRef$current$inp.offsetHeight);
|
|
11
9
|
}, [inputRef]);
|
|
12
10
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-input",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.16",
|
|
4
4
|
"description": "Input UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "synerise/synerise-design",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
],
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@synerise/ds-icon": "^0.
|
|
38
|
-
"@synerise/ds-scrollbar": "^0.11.
|
|
39
|
-
"@synerise/ds-tooltip": "^0.14.
|
|
40
|
-
"@synerise/ds-typography": "^0.16.
|
|
37
|
+
"@synerise/ds-icon": "^0.68.0",
|
|
38
|
+
"@synerise/ds-scrollbar": "^0.11.21",
|
|
39
|
+
"@synerise/ds-tooltip": "^0.14.51",
|
|
40
|
+
"@synerise/ds-typography": "^0.16.8",
|
|
41
41
|
"@synerise/ds-utils": "^0.31.2",
|
|
42
42
|
"antd-mask-input": "^0.1.13",
|
|
43
43
|
"csstype": "2.6.9",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"react": ">=16.9.0 <= 17.0.2",
|
|
50
50
|
"styled-components": "5.0.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "9ebd107163650754a5f55680d62d30812d740084"
|
|
53
53
|
}
|