@synerise/ds-input 0.18.51 → 0.19.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 +18 -0
- package/dist/Input.d.ts +2 -2
- package/dist/Input.js +44 -47
- package/dist/autosize/autosize.d.ts +23 -0
- package/dist/autosize/autosize.js +259 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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.19.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@0.18.51...@synerise/ds-input@0.19.0) (2023-09-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **input:** deps missing in autocomplete + input exports ([4a1439b](https://github.com/synerise/synerise-design/commit/4a1439b70856f24b1c4500c97956c7ff8b97468a))
|
|
12
|
+
* **input:** fixed autosize imports/exports ([4fbebfa](https://github.com/synerise/synerise-design/commit/4fbebfa9b5c13dc92b81cf1e6ee3639f54d3145b))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **input:** autosize input, filter ([c507a67](https://github.com/synerise/synerise-design/commit/c507a672b2705da82e8bebe589495caf5d509e71))
|
|
18
|
+
* react-input-autosize@3.0.0 ([ebc6fb0](https://github.com/synerise/synerise-design/commit/ebc6fb0d883b48754714075bb1005081a735cf48))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [0.18.51](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@0.18.50...@synerise/ds-input@0.18.51) (2023-09-08)
|
|
7
25
|
|
|
8
26
|
|
package/dist/Input.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
2
|
import '@synerise/ds-core/dist/js/style';
|
|
3
3
|
import { InputProps, TextAreaProps } from 'antd/lib/input';
|
|
4
4
|
import './style/index.less';
|
|
@@ -56,7 +56,7 @@ export declare const RawMaskedInput: StyledComponent<React.ForwardRefExoticCompo
|
|
|
56
56
|
error?: boolean | undefined;
|
|
57
57
|
}, never>;
|
|
58
58
|
export { default as InputGroup } from './InputGroup';
|
|
59
|
-
export declare const RawInput: (props: Props & (InputProps | TextAreaProps)) =>
|
|
59
|
+
export declare const RawInput: (props: Props & (InputProps | TextAreaProps)) => ReactElement;
|
|
60
60
|
export declare const RawTextArea: StyledComponent<React.ForwardRefExoticComponent<{
|
|
61
61
|
error?: boolean | undefined;
|
|
62
62
|
} & React.RefAttributes<import("antd/lib/input/TextArea").default>>, any, {
|
package/dist/Input.js
CHANGED
|
@@ -10,7 +10,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
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
|
|
13
|
+
import React, { cloneElement, useState, useEffect, useRef, useCallback, useMemo } from 'react';
|
|
14
14
|
import '@synerise/ds-core/dist/js/style';
|
|
15
15
|
import { v4 as uuid } from 'uuid';
|
|
16
16
|
import "./style/index.css";
|
|
@@ -18,6 +18,7 @@ import Tooltip from '@synerise/ds-tooltip/dist/Tooltip';
|
|
|
18
18
|
import * as S from './Input.styles';
|
|
19
19
|
import Label from './Label/Label';
|
|
20
20
|
import Textarea from './Textarea/Textarea';
|
|
21
|
+
import AutosizeInput from './autosize/autosize';
|
|
21
22
|
var VERTICAL_BORDER_OFFSET = 2;
|
|
22
23
|
|
|
23
24
|
var enhancedInput = function enhancedInput(WrappedComponent, _ref) {
|
|
@@ -42,64 +43,68 @@ var enhancedInput = function enhancedInput(WrappedComponent, _ref) {
|
|
|
42
43
|
error = _ref2.error,
|
|
43
44
|
antdInputProps = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
44
45
|
|
|
45
|
-
var
|
|
46
|
-
charCount =
|
|
47
|
-
setCharCount =
|
|
46
|
+
var _useState = useState(0),
|
|
47
|
+
charCount = _useState[0],
|
|
48
|
+
setCharCount = _useState[1];
|
|
48
49
|
|
|
49
50
|
var hasErrorMessage = Boolean(errorText);
|
|
50
|
-
var id =
|
|
51
|
+
var id = useMemo(function () {
|
|
51
52
|
return uuid();
|
|
52
53
|
}, []);
|
|
53
|
-
var inputRef =
|
|
54
|
+
var inputRef = useRef();
|
|
54
55
|
|
|
55
|
-
var
|
|
56
|
-
inputAddonHeight =
|
|
57
|
-
setInputAddonHeight =
|
|
56
|
+
var _useState2 = useState(0),
|
|
57
|
+
inputAddonHeight = _useState2[0],
|
|
58
|
+
setInputAddonHeight = _useState2[1];
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
useEffect(function () {
|
|
60
61
|
handleInputRef && handleInputRef(inputRef);
|
|
61
62
|
}, [inputRef, handleInputRef]);
|
|
62
|
-
var handleChange =
|
|
63
|
+
var handleChange = useCallback(function (e) {
|
|
63
64
|
var newValue = e.currentTarget.value;
|
|
64
65
|
if (counterLimit && newValue.length > counterLimit) return;
|
|
65
66
|
antdInputProps.onChange && antdInputProps.onChange(e);
|
|
66
67
|
}, [antdInputProps, counterLimit]);
|
|
67
|
-
var handleIconsClick =
|
|
68
|
+
var handleIconsClick = useCallback(function () {
|
|
68
69
|
inputRef.current && inputRef.current.focus();
|
|
69
70
|
}, [inputRef]);
|
|
70
|
-
|
|
71
|
+
useEffect(function () {
|
|
71
72
|
if (counterLimit && antdInputProps.value && antdInputProps.value.toString().length > counterLimit) return;
|
|
72
73
|
setCharCount(antdInputProps.value ? antdInputProps.value.toString().length : 0);
|
|
73
74
|
}, [antdInputProps.value, counterLimit]);
|
|
74
|
-
|
|
75
|
+
useEffect(function () {
|
|
75
76
|
var _inputRef$current, _inputRef$current$inp;
|
|
76
77
|
|
|
77
78
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
78
79
|
// @ts-ignore
|
|
79
80
|
inputRef.current && setInputAddonHeight(inputRef == null ? void 0 : (_inputRef$current = inputRef.current) == null ? void 0 : (_inputRef$current$inp = _inputRef$current.input) == null ? void 0 : _inputRef$current$inp.offsetHeight);
|
|
80
81
|
}, [inputRef]);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
autoResize
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
82
|
+
var renderInputComponent = useMemo(function () {
|
|
83
|
+
return function () {
|
|
84
|
+
var Component = autoResize ? AutosizeInput : WrappedComponent;
|
|
85
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, antdInputProps, autoResize ? {
|
|
86
|
+
renderInput: WrappedComponent,
|
|
87
|
+
autoResize: autoResize
|
|
88
|
+
} : {}, {
|
|
89
|
+
className: hasErrorMessage || error ? 'error' : undefined,
|
|
90
|
+
addonBefore: !!prefixel && /*#__PURE__*/React.createElement(S.AddonWrapper, {
|
|
91
|
+
className: "ds-input-prefix",
|
|
92
|
+
height: inputAddonHeight - VERTICAL_BORDER_OFFSET
|
|
93
|
+
}, prefixel),
|
|
94
|
+
addonAfter: !!suffixel && /*#__PURE__*/React.createElement(S.AddonWrapper, {
|
|
95
|
+
className: "ds-input-suffix",
|
|
96
|
+
height: inputAddonHeight - VERTICAL_BORDER_OFFSET
|
|
97
|
+
}, suffixel),
|
|
98
|
+
error: hasErrorMessage || error,
|
|
99
|
+
onChange: handleChange,
|
|
100
|
+
value: antdInputProps.value,
|
|
101
|
+
id: id,
|
|
102
|
+
ref: inputRef,
|
|
103
|
+
autoComplete: "off"
|
|
104
|
+
}));
|
|
105
|
+
};
|
|
106
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
107
|
+
[antdInputProps, handleChange]);
|
|
103
108
|
return /*#__PURE__*/React.createElement(S.OuterWrapper, {
|
|
104
109
|
autoResize: autoResize,
|
|
105
110
|
className: className,
|
|
@@ -123,7 +128,7 @@ var enhancedInput = function enhancedInput(WrappedComponent, _ref) {
|
|
|
123
128
|
title: icon1Tooltip
|
|
124
129
|
}, /*#__PURE__*/React.createElement(S.IconWrapper, {
|
|
125
130
|
className: className
|
|
126
|
-
}, icon1 &&
|
|
131
|
+
}, icon1 && cloneElement(icon1, _objectSpread({
|
|
127
132
|
className: 'icon icon1'
|
|
128
133
|
}, icon2 && {
|
|
129
134
|
style: {
|
|
@@ -133,17 +138,9 @@ var enhancedInput = function enhancedInput(WrappedComponent, _ref) {
|
|
|
133
138
|
title: icon2Tooltip
|
|
134
139
|
}, /*#__PURE__*/React.createElement(S.IconWrapper, {
|
|
135
140
|
className: className
|
|
136
|
-
}, icon2 &&
|
|
141
|
+
}, icon2 && cloneElement(icon2, {
|
|
137
142
|
className: 'icon icon2'
|
|
138
|
-
}))))),
|
|
139
|
-
autoResize: autoResize
|
|
140
|
-
}, renderInputComponent(), /*#__PURE__*/React.createElement(S.AutoResize, {
|
|
141
|
-
icon1: icon1,
|
|
142
|
-
icon2: icon2,
|
|
143
|
-
suffixel: suffixel,
|
|
144
|
-
prefixel: prefixel,
|
|
145
|
-
autoResize: autoResize
|
|
146
|
-
}, antdInputProps.value)) : 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)));
|
|
143
|
+
}))))), 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)));
|
|
147
144
|
};
|
|
148
145
|
};
|
|
149
146
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
declare class AutosizeInput extends Component {
|
|
3
|
+
static getDerivedStateFromProps(props: any, state: any): {
|
|
4
|
+
inputId: any;
|
|
5
|
+
prevId: any;
|
|
6
|
+
} | null;
|
|
7
|
+
constructor(props: any);
|
|
8
|
+
componentDidMount(): void;
|
|
9
|
+
componentDidUpdate(prevProps: any, prevState: any): void;
|
|
10
|
+
componentWillUnmount(): void;
|
|
11
|
+
inputRef: (el: any) => void;
|
|
12
|
+
placeHolderSizerRef: (el: any) => void;
|
|
13
|
+
sizerRef: (el: any) => void;
|
|
14
|
+
copyInputStyles(): void;
|
|
15
|
+
updateInputWidth(): void;
|
|
16
|
+
getInput(): any;
|
|
17
|
+
focus(): void;
|
|
18
|
+
blur(): void;
|
|
19
|
+
select(): void;
|
|
20
|
+
renderStyles(): JSX.Element | null;
|
|
21
|
+
render(): JSX.Element;
|
|
22
|
+
}
|
|
23
|
+
export default AutosizeInput;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
var _excluded = ["renderInput"];
|
|
2
|
+
|
|
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
|
+
|
|
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
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
12
|
+
|
|
13
|
+
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
|
14
|
+
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
// @ts-nocheck
|
|
18
|
+
|
|
19
|
+
/* eslint-disable */
|
|
20
|
+
import React, { Component } from 'react';
|
|
21
|
+
var sizerStyle = {
|
|
22
|
+
position: 'absolute',
|
|
23
|
+
top: 0,
|
|
24
|
+
left: 0,
|
|
25
|
+
visibility: 'hidden',
|
|
26
|
+
height: 0,
|
|
27
|
+
overflow: 'scroll',
|
|
28
|
+
whiteSpace: 'pre'
|
|
29
|
+
};
|
|
30
|
+
var INPUT_PROPS_BLACKLIST = ['extraWidth', 'injectStyles', 'inputClassName', 'inputRef', 'inputStyle', 'minWidth', 'onAutosize', 'placeholderIsMinWidth', 'autoResize'];
|
|
31
|
+
|
|
32
|
+
var cleanInputProps = function cleanInputProps(inputProps) {
|
|
33
|
+
INPUT_PROPS_BLACKLIST.forEach(function (field) {
|
|
34
|
+
return delete inputProps[field];
|
|
35
|
+
});
|
|
36
|
+
return inputProps;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var copyStyles = function copyStyles(styles, node) {
|
|
40
|
+
node.style.fontSize = styles.fontSize;
|
|
41
|
+
node.style.fontFamily = styles.fontFamily;
|
|
42
|
+
node.style.fontWeight = styles.fontWeight;
|
|
43
|
+
node.style.fontStyle = styles.fontStyle;
|
|
44
|
+
node.style.letterSpacing = styles.letterSpacing;
|
|
45
|
+
node.style.textTransform = styles.textTransform;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var isIE = typeof window !== 'undefined' && window.navigator ? /MSIE |Trident\/|Edge\//.test(window.navigator.userAgent) : false;
|
|
49
|
+
|
|
50
|
+
var generateId = function generateId() {
|
|
51
|
+
// we only need an auto-generated ID for stylesheet injection, which is only
|
|
52
|
+
// used for IE. so if the browser is not IE, this should return undefined.
|
|
53
|
+
return isIE ? '_' + Math.random().toString(36).substr(2, 12) : undefined;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
var AutosizeInput = /*#__PURE__*/function (_Component) {
|
|
57
|
+
_inheritsLoose(AutosizeInput, _Component);
|
|
58
|
+
|
|
59
|
+
AutosizeInput.getDerivedStateFromProps = function getDerivedStateFromProps(props, state) {
|
|
60
|
+
var id = props.id;
|
|
61
|
+
return id !== state.prevId ? {
|
|
62
|
+
inputId: id || generateId(),
|
|
63
|
+
prevId: id
|
|
64
|
+
} : null;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function AutosizeInput(props) {
|
|
68
|
+
var _this;
|
|
69
|
+
|
|
70
|
+
_this = _Component.call(this, props) || this;
|
|
71
|
+
|
|
72
|
+
_defineProperty(_assertThisInitialized(_this), "inputRef", function (el) {
|
|
73
|
+
_this.input = el;
|
|
74
|
+
|
|
75
|
+
if (typeof _this.props.inputRef === 'function') {
|
|
76
|
+
_this.props.inputRef(el);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
_defineProperty(_assertThisInitialized(_this), "placeHolderSizerRef", function (el) {
|
|
81
|
+
_this.placeHolderSizer = el;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
_defineProperty(_assertThisInitialized(_this), "sizerRef", function (el) {
|
|
85
|
+
var _this$props$transform = _this.props.transformRef,
|
|
86
|
+
transformRef = _this$props$transform === void 0 ? function (el) {
|
|
87
|
+
return el;
|
|
88
|
+
} : _this$props$transform;
|
|
89
|
+
_this.sizer = el;
|
|
90
|
+
if (!el) return;
|
|
91
|
+
var input = el.previousElementSibling;
|
|
92
|
+
var ref = transformRef(input);
|
|
93
|
+
|
|
94
|
+
_this.inputRef(ref);
|
|
95
|
+
|
|
96
|
+
_this.copyInputStyles();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
_this.state = {
|
|
100
|
+
inputWidth: props.minWidth,
|
|
101
|
+
inputId: props.id || generateId(),
|
|
102
|
+
prevId: props.id
|
|
103
|
+
};
|
|
104
|
+
return _this;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
var _proto = AutosizeInput.prototype;
|
|
108
|
+
|
|
109
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
110
|
+
this.mounted = true;
|
|
111
|
+
this.copyInputStyles();
|
|
112
|
+
this.updateInputWidth();
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
|
116
|
+
if (prevState.inputWidth !== this.state.inputWidth) {
|
|
117
|
+
if (typeof this.props.onAutosize === 'function') {
|
|
118
|
+
this.props.onAutosize(this.state.inputWidth);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
this.updateInputWidth();
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
126
|
+
this.mounted = false;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
_proto.copyInputStyles = function copyInputStyles() {
|
|
130
|
+
if (!this.mounted || !window.getComputedStyle) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
var inputStyles = this.input && window.getComputedStyle(this.input);
|
|
135
|
+
|
|
136
|
+
if (!inputStyles) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
copyStyles(inputStyles, this.sizer);
|
|
141
|
+
|
|
142
|
+
if (this.placeHolderSizer) {
|
|
143
|
+
copyStyles(inputStyles, this.placeHolderSizer);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
_proto.updateInputWidth = function updateInputWidth() {
|
|
148
|
+
if (!this.mounted || !this.sizer || typeof this.sizer.scrollWidth === 'undefined') {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
var newInputWidth;
|
|
153
|
+
|
|
154
|
+
if (this.props.placeholder && (!this.props.value || this.props.value && this.props.placeholderIsMinWidth)) {
|
|
155
|
+
newInputWidth = Math.max(this.sizer.scrollWidth, this.placeHolderSizer.scrollWidth) + 2;
|
|
156
|
+
} else {
|
|
157
|
+
newInputWidth = this.sizer.scrollWidth + 2;
|
|
158
|
+
} // add extraWidth to the detected width. for number types, this defaults to 16 to allow for the stepper UI
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
var extraWidth = this.props.type === 'number' && this.props.extraWidth === undefined ? 16 : parseInt(this.props.extraWidth) || 0;
|
|
162
|
+
newInputWidth += extraWidth;
|
|
163
|
+
|
|
164
|
+
if (newInputWidth < this.props.minWidth) {
|
|
165
|
+
newInputWidth = this.props.minWidth;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (newInputWidth !== this.state.inputWidth) {
|
|
169
|
+
this.setState({
|
|
170
|
+
inputWidth: newInputWidth
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
_proto.getInput = function getInput() {
|
|
176
|
+
return this.input;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
_proto.focus = function focus() {
|
|
180
|
+
this.input.focus();
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
_proto.blur = function blur() {
|
|
184
|
+
this.input.blur();
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
_proto.select = function select() {
|
|
188
|
+
this.input.select();
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
_proto.renderStyles = function renderStyles() {
|
|
192
|
+
// this method injects styles to hide IE's clear indicator, which messes
|
|
193
|
+
// with input size detection. the stylesheet is only injected when the
|
|
194
|
+
// browser is IE, and can also be disabled by the `injectStyles` prop.
|
|
195
|
+
var injectStyles = this.props.injectStyles;
|
|
196
|
+
return isIE && injectStyles ? /*#__PURE__*/React.createElement("style", {
|
|
197
|
+
dangerouslySetInnerHTML: {
|
|
198
|
+
__html: "input#" + this.state.inputId + "::-ms-clear {display: none;}"
|
|
199
|
+
}
|
|
200
|
+
}) : null;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
_proto.render = function render() {
|
|
204
|
+
var _this$props$refPropNa, _ref;
|
|
205
|
+
|
|
206
|
+
var sizerValue = [this.props.defaultValue, this.props.value, ''].reduce(function (previousValue, currentValue) {
|
|
207
|
+
if (previousValue !== null && previousValue !== undefined) {
|
|
208
|
+
return previousValue;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return currentValue;
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
var wrapperStyle = _objectSpread({}, this.props.style);
|
|
215
|
+
|
|
216
|
+
if (!wrapperStyle.display) wrapperStyle.display = 'inline-block';
|
|
217
|
+
|
|
218
|
+
var inputStyle = _objectSpread({
|
|
219
|
+
boxSizing: 'content-box',
|
|
220
|
+
width: this.state.inputWidth + "px",
|
|
221
|
+
minHeight: 30 - 12 * 2 + "px"
|
|
222
|
+
}, this.props.inputStyle);
|
|
223
|
+
|
|
224
|
+
var defaultRenderInput = function defaultRenderInput(props) {
|
|
225
|
+
return /*#__PURE__*/React.createElement("input", props);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
var _this$props = this.props,
|
|
229
|
+
_this$props$renderInp = _this$props.renderInput,
|
|
230
|
+
RenderInput = _this$props$renderInp === void 0 ? defaultRenderInput : _this$props$renderInp,
|
|
231
|
+
inputProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
232
|
+
|
|
233
|
+
cleanInputProps(inputProps);
|
|
234
|
+
inputProps.className = this.props.inputClassName;
|
|
235
|
+
inputProps.id = this.state.inputId;
|
|
236
|
+
inputProps.style = inputStyle;
|
|
237
|
+
this.copyInputStyles();
|
|
238
|
+
var name = (_this$props$refPropNa = this.props.refPropName) != null ? _this$props$refPropNa : 'ref';
|
|
239
|
+
var input = /*#__PURE__*/React.createElement(RenderInput, _extends({
|
|
240
|
+
"data-testid": "autosize-input"
|
|
241
|
+
}, inputProps, (_ref = {}, _ref[name] = this.inputRef, _ref)));
|
|
242
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
243
|
+
className: this.props.className,
|
|
244
|
+
style: wrapperStyle
|
|
245
|
+
}, this.renderStyles(), input, /*#__PURE__*/React.createElement("div", {
|
|
246
|
+
"data-testid": "autosize-sizer",
|
|
247
|
+
ref: this.sizerRef,
|
|
248
|
+
style: sizerStyle
|
|
249
|
+
}, sizerValue), this.props.placeholder ? /*#__PURE__*/React.createElement("div", {
|
|
250
|
+
"data-testid": "autosize-placeholder",
|
|
251
|
+
ref: this.placeHolderSizerRef,
|
|
252
|
+
style: sizerStyle
|
|
253
|
+
}, this.props.placeholder) : null);
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
return AutosizeInput;
|
|
257
|
+
}(Component);
|
|
258
|
+
|
|
259
|
+
export default AutosizeInput;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { EnhancedProps } from './Input.types';
|
|
2
2
|
export { default as Label } from './Label/Label';
|
|
3
3
|
export { Input, TextArea, RawInput, RawTextArea, InputGroup, MaskedInput, InputMultivalue, RawMaskedInput, AutoResize, WrapperAutoResize, } from './Input';
|
|
4
|
+
export * as InputStyles from './Input.styles';
|
|
4
5
|
export type { EnhancedProps };
|
|
5
6
|
export type { Props as InputProps } from './Input.types';
|
|
7
|
+
export { default as AutosizeInput } from './autosize/autosize';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { default as Label } from './Label/Label';
|
|
2
|
-
export { Input, TextArea, RawInput, RawTextArea, InputGroup, MaskedInput, InputMultivalue, RawMaskedInput, AutoResize, WrapperAutoResize } from './Input';
|
|
2
|
+
export { Input, TextArea, RawInput, RawTextArea, InputGroup, MaskedInput, InputMultivalue, RawMaskedInput, AutoResize, WrapperAutoResize } from './Input';
|
|
3
|
+
import * as _InputStyles from './Input.styles';
|
|
4
|
+
export { _InputStyles as InputStyles };
|
|
5
|
+
export { default as AutosizeInput } from './autosize/autosize';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-input",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Input UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "synerise/synerise-design",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@testing-library/react": "10.0.1"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "ef59143e0ab93cee5b9a738fa1fa9c60748ddffc"
|
|
54
54
|
}
|