@rescui/input 0.11.8 → 0.11.10
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/lib/_virtual/close.js +8 -9
- package/lib/_virtual/index.css.js +7 -7
- package/lib/_virtual/loading.js +8 -9
- package/lib/_virtual/warning.js +8 -9
- package/lib/index.css +139 -599
- package/lib/index.js +1 -1
- package/lib/input.js +72 -91
- package/lib/input.p.module.css.js +28 -28
- package/lib/parts/custom-icon.js +25 -42
- package/lib/parts/right-icons.js +12 -11
- package/lib/public-api.p.css +0 -336
- package/lib/public-api.pcss +0 -336
- package/package.json +9 -10
package/lib/index.js
CHANGED
package/lib/input.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
import "core-js/modules/es.object.to-string.js";
|
|
2
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
3
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
4
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
5
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
6
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
7
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
8
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
9
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
10
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
11
|
-
var _excluded = ["id", "className", "placeholder", "disabled", "error", "busy", "onChange", "onFocus", "onBlur", "onClear", "mode", "size", "theme", "type", "value", "icon", "iconType", "label", "note", "clearIcon", "suffix", "offSystemMicroelements", "style", "boldLabel"];
|
|
12
|
-
|
|
13
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
-
|
|
15
|
-
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; }
|
|
16
|
-
|
|
17
1
|
import * as React from 'react';
|
|
18
2
|
import PropTypes from 'prop-types';
|
|
19
3
|
import cn from 'classnames';
|
|
@@ -23,83 +7,80 @@ import WarningIcon from './_virtual/warning.js';
|
|
|
23
7
|
import styles from './input.p.module.css.js';
|
|
24
8
|
import { RightIcons } from './parts/right-icons.js';
|
|
25
9
|
import { CustomIcon } from './parts/custom-icon.js';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
const {
|
|
11
|
+
useEffect,
|
|
12
|
+
useRef,
|
|
13
|
+
useState
|
|
14
|
+
} = React;
|
|
15
|
+
const sizeStyles = {
|
|
30
16
|
l: styles.sizeL,
|
|
31
17
|
m: styles.sizeM,
|
|
32
18
|
s: styles.sizeS
|
|
33
19
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
offSystemMicroelements = _ref.offSystemMicroelements,
|
|
65
|
-
style = _ref.style,
|
|
66
|
-
boldLabel = _ref.boldLabel,
|
|
67
|
-
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
68
|
-
|
|
69
|
-
var theme = useThemeWithUndefined(themeFromProps); // replace with :focus-within when ie11 is not supported anymore
|
|
20
|
+
const Input = /*#__PURE__*/React.forwardRef( // eslint-disable-next-line complexity
|
|
21
|
+
(_ref, ref) => {
|
|
22
|
+
let {
|
|
23
|
+
id,
|
|
24
|
+
className,
|
|
25
|
+
placeholder,
|
|
26
|
+
disabled,
|
|
27
|
+
error,
|
|
28
|
+
busy,
|
|
29
|
+
onChange,
|
|
30
|
+
onFocus,
|
|
31
|
+
onBlur,
|
|
32
|
+
onClear,
|
|
33
|
+
mode = 'classic',
|
|
34
|
+
size = 'm',
|
|
35
|
+
theme: themeFromProps,
|
|
36
|
+
type = 'text',
|
|
37
|
+
value,
|
|
38
|
+
icon,
|
|
39
|
+
iconType = 'right',
|
|
40
|
+
label,
|
|
41
|
+
note,
|
|
42
|
+
clearIcon = /*#__PURE__*/React.createElement(CloseIcon, null),
|
|
43
|
+
suffix,
|
|
44
|
+
offSystemMicroelements,
|
|
45
|
+
style,
|
|
46
|
+
boldLabel,
|
|
47
|
+
...restProps
|
|
48
|
+
} = _ref;
|
|
49
|
+
const theme = useThemeWithUndefined(themeFromProps); // replace with :focus-within when ie11 is not supported anymore
|
|
70
50
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
51
|
+
const [focused, setFocused] = useState(false);
|
|
52
|
+
const empty = !value;
|
|
53
|
+
const filled = !empty;
|
|
54
|
+
const enabled = !disabled;
|
|
55
|
+
const inputMouseDown = useRef(false);
|
|
56
|
+
const activeRef = useRef(false); // run effect only on unmount with final props
|
|
75
57
|
|
|
76
|
-
|
|
77
|
-
var filled = !empty;
|
|
78
|
-
var enabled = !disabled;
|
|
79
|
-
var inputMouseDown = useRef(false);
|
|
80
|
-
var activeRef = useRef(false); // run effect only on unmount with final props
|
|
81
|
-
|
|
82
|
-
var unmountPropsRef = useRef({});
|
|
58
|
+
const unmountPropsRef = useRef({});
|
|
83
59
|
unmountPropsRef.current = {
|
|
84
|
-
type
|
|
85
|
-
onChange
|
|
60
|
+
type,
|
|
61
|
+
onChange
|
|
86
62
|
};
|
|
87
|
-
useEffect(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
};
|
|
63
|
+
useEffect(() => () => {
|
|
64
|
+
if (unmountPropsRef.current.type === 'file' && unmountPropsRef.current.onChange) {
|
|
65
|
+
unmountPropsRef.current.onChange({
|
|
66
|
+
target: {
|
|
67
|
+
type: 'file',
|
|
68
|
+
files: null
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
98
72
|
}, []);
|
|
99
|
-
|
|
100
|
-
|
|
73
|
+
const renderLeftCustomIcon = icon && iconType === 'left';
|
|
74
|
+
const renderRightCustomIcon = icon && (iconType === 'right' || iconType === 'rightAction' || iconType === 'rightActionFocusable');
|
|
101
75
|
return /*#__PURE__*/React.createElement("div", {
|
|
102
|
-
className: cn(styles.container, styles[theme], styles[mode], sizeStyles[size],
|
|
76
|
+
className: cn(styles.container, styles[theme], styles[mode], sizeStyles[size], {
|
|
77
|
+
[styles.focused]: focused,
|
|
78
|
+
[styles.filled]: filled,
|
|
79
|
+
[styles.enabled]: enabled,
|
|
80
|
+
[styles.error]: Boolean(error),
|
|
81
|
+
[styles.disabled]: disabled,
|
|
82
|
+
[styles.offSystemMicroelements]: offSystemMicroelements
|
|
83
|
+
}, className),
|
|
103
84
|
style: style,
|
|
104
85
|
"data-test": "input"
|
|
105
86
|
}, /*#__PURE__*/React.createElement("label", null, label && /*#__PURE__*/React.createElement("div", {
|
|
@@ -107,17 +88,17 @@ function (_ref, ref) {
|
|
|
107
88
|
"data-rs-internal": boldLabel ? 'input__bold-label' : 'input__label'
|
|
108
89
|
}, label), /*#__PURE__*/React.createElement("div", {
|
|
109
90
|
className: styles.wrapper,
|
|
110
|
-
onFocus:
|
|
91
|
+
onFocus: () => {
|
|
111
92
|
setFocused(true);
|
|
112
93
|
},
|
|
113
|
-
onMouseUp:
|
|
94
|
+
onMouseUp: () => {
|
|
114
95
|
if (activeRef.current) {
|
|
115
96
|
setFocused(false);
|
|
116
97
|
}
|
|
117
98
|
|
|
118
99
|
activeRef.current = false;
|
|
119
100
|
},
|
|
120
|
-
onMouseDown:
|
|
101
|
+
onMouseDown: () => {
|
|
121
102
|
if (inputMouseDown.current) {
|
|
122
103
|
inputMouseDown.current = false;
|
|
123
104
|
return;
|
|
@@ -125,14 +106,14 @@ function (_ref, ref) {
|
|
|
125
106
|
|
|
126
107
|
activeRef.current = true;
|
|
127
108
|
},
|
|
128
|
-
onMouseLeave:
|
|
109
|
+
onMouseLeave: () => {
|
|
129
110
|
if (activeRef.current) {
|
|
130
111
|
setFocused(false);
|
|
131
112
|
}
|
|
132
113
|
|
|
133
114
|
activeRef.current = false;
|
|
134
115
|
},
|
|
135
|
-
onBlur:
|
|
116
|
+
onBlur: () => {
|
|
136
117
|
if (!activeRef.current) {
|
|
137
118
|
setFocused(false);
|
|
138
119
|
}
|
|
@@ -144,7 +125,7 @@ function (_ref, ref) {
|
|
|
144
125
|
iconIsAction: false,
|
|
145
126
|
iconIsFocusable: false,
|
|
146
127
|
iconPosition: "left"
|
|
147
|
-
}), /*#__PURE__*/React.createElement("input",
|
|
128
|
+
}), /*#__PURE__*/React.createElement("input", { ...restProps,
|
|
148
129
|
id: id,
|
|
149
130
|
className: styles.inner,
|
|
150
131
|
type: type,
|
|
@@ -153,7 +134,7 @@ function (_ref, ref) {
|
|
|
153
134
|
onChange: onChange,
|
|
154
135
|
onFocus: onFocus,
|
|
155
136
|
onBlur: onBlur,
|
|
156
|
-
onMouseDown:
|
|
137
|
+
onMouseDown: e => {
|
|
157
138
|
inputMouseDown.current = true;
|
|
158
139
|
|
|
159
140
|
if (restProps.onMouseDown) {
|
|
@@ -165,7 +146,7 @@ function (_ref, ref) {
|
|
|
165
146
|
"aria-invalid": Boolean(error),
|
|
166
147
|
"data-test": "input__inner",
|
|
167
148
|
"data-rs-internal": "input__inner"
|
|
168
|
-
})
|
|
149
|
+
}), /*#__PURE__*/React.createElement(RightIcons, {
|
|
169
150
|
icon: renderRightCustomIcon && icon,
|
|
170
151
|
iconIsAction: iconType === 'rightAction' || iconType === 'rightActionFocusable',
|
|
171
152
|
iconIsFocusable: iconType === 'rightActionFocusable',
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"light": "
|
|
3
|
-
"dark": "
|
|
4
|
-
"sizeS": "
|
|
5
|
-
"sizeM": "
|
|
6
|
-
"sizeL": "
|
|
7
|
-
"classic": "
|
|
8
|
-
"rock": "
|
|
9
|
-
"container": "
|
|
10
|
-
"wrapper": "
|
|
11
|
-
"disabled": "
|
|
12
|
-
"error": "
|
|
13
|
-
"enabled": "
|
|
14
|
-
"filled": "
|
|
15
|
-
"focused": "
|
|
16
|
-
"field": "
|
|
17
|
-
"inner": "
|
|
18
|
-
"offSystemMicroelements": "
|
|
19
|
-
"iconWrapper": "
|
|
20
|
-
"action": "
|
|
21
|
-
"right": "
|
|
22
|
-
"left": "
|
|
23
|
-
"icon": "
|
|
24
|
-
"divider": "
|
|
25
|
-
"suffix": "
|
|
26
|
-
"errorMessage": "
|
|
27
|
-
"errorIcon": "
|
|
28
|
-
"note": "
|
|
29
|
-
"label": "
|
|
2
|
+
"light": "_light_tb5lyv_8",
|
|
3
|
+
"dark": "_dark_tb5lyv_11",
|
|
4
|
+
"sizeS": "_sizeS_tb5lyv_15",
|
|
5
|
+
"sizeM": "_sizeM_tb5lyv_18",
|
|
6
|
+
"sizeL": "_sizeL_tb5lyv_21",
|
|
7
|
+
"classic": "_classic_tb5lyv_25",
|
|
8
|
+
"rock": "_rock_tb5lyv_28",
|
|
9
|
+
"container": "_container_tb5lyv_32",
|
|
10
|
+
"wrapper": "_wrapper_tb5lyv_39",
|
|
11
|
+
"disabled": "_disabled_tb5lyv_51",
|
|
12
|
+
"error": "_error_tb5lyv_57",
|
|
13
|
+
"enabled": "_enabled_tb5lyv_63",
|
|
14
|
+
"filled": "_filled_tb5lyv_63",
|
|
15
|
+
"focused": "_focused_tb5lyv_75",
|
|
16
|
+
"field": "_field_tb5lyv_101",
|
|
17
|
+
"inner": "_inner_tb5lyv_114",
|
|
18
|
+
"offSystemMicroelements": "_offSystemMicroelements_tb5lyv_229",
|
|
19
|
+
"iconWrapper": "_iconWrapper_tb5lyv_239",
|
|
20
|
+
"action": "_action_tb5lyv_254",
|
|
21
|
+
"right": "_right_tb5lyv_292",
|
|
22
|
+
"left": "_left_tb5lyv_296",
|
|
23
|
+
"icon": "_icon_tb5lyv_239",
|
|
24
|
+
"divider": "_divider_tb5lyv_342",
|
|
25
|
+
"suffix": "_suffix_tb5lyv_356",
|
|
26
|
+
"errorMessage": "_errorMessage_tb5lyv_376",
|
|
27
|
+
"errorIcon": "_errorIcon_tb5lyv_388",
|
|
28
|
+
"note": "_note_tb5lyv_394",
|
|
29
|
+
"label": "_label_tb5lyv_405"
|
|
30
30
|
};
|
|
31
31
|
export { styles as default };
|
package/lib/parts/custom-icon.js
CHANGED
|
@@ -1,59 +1,42 @@
|
|
|
1
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
2
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
3
|
-
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
|
-
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; }
|
|
7
|
-
|
|
8
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
9
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
10
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
11
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
12
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
13
|
-
import "core-js/modules/es.object.to-string.js";
|
|
14
1
|
import * as React from 'react';
|
|
15
2
|
import cn from 'classnames';
|
|
16
3
|
import styles from '../input.p.module.css.js';
|
|
17
4
|
|
|
18
5
|
function transferInteractiveProps(iconProps) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
return _objectSpread(_objectSpread({}, obj), {}, _defineProperty({}, key, iconProps[key]));
|
|
27
|
-
}, {});
|
|
28
|
-
|
|
29
|
-
var icon = _Object$keys(button).reduce(function (obj, key) {
|
|
30
|
-
return _objectSpread(_objectSpread({}, obj), {}, _defineProperty({}, key, null));
|
|
31
|
-
}, {});
|
|
32
|
-
|
|
6
|
+
const props = ['onClick', 'onContextMenu', 'onDoubleClick', 'onMouseDown', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp', 'aria-label'];
|
|
7
|
+
const button = Object.keys(iconProps).filter(key => props.indexOf(key) > -1).reduce((obj, key) => ({ ...obj,
|
|
8
|
+
[key]: iconProps[key]
|
|
9
|
+
}), {});
|
|
10
|
+
const icon = Object.keys(button).reduce((obj, key) => ({ ...obj,
|
|
11
|
+
[key]: null
|
|
12
|
+
}), {});
|
|
33
13
|
return {
|
|
34
|
-
button
|
|
35
|
-
icon
|
|
14
|
+
button,
|
|
15
|
+
icon
|
|
36
16
|
};
|
|
37
17
|
}
|
|
38
18
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
19
|
+
const CustomIcon = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
icon,
|
|
22
|
+
iconPosition,
|
|
23
|
+
iconIsAction,
|
|
24
|
+
iconIsFocusable
|
|
25
|
+
} = _ref;
|
|
26
|
+
const mouseEvents = transferInteractiveProps(icon.props);
|
|
27
|
+
const iconJsx = /*#__PURE__*/React.cloneElement(icon, {
|
|
46
28
|
focusable: false,
|
|
47
|
-
className: cn(icon.props.className, styles.icon)
|
|
48
|
-
|
|
49
|
-
|
|
29
|
+
className: cn(icon.props.className, styles.icon),
|
|
30
|
+
...mouseEvents.icon
|
|
31
|
+
});
|
|
32
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
50
33
|
role: iconIsAction ? 'button' : null,
|
|
51
34
|
key: "icon",
|
|
52
|
-
className: cn(styles.iconWrapper, styles[iconPosition], iconIsAction && styles.action)
|
|
53
|
-
|
|
35
|
+
className: cn(styles.iconWrapper, styles[iconPosition], iconIsAction && styles.action),
|
|
36
|
+
...mouseEvents.button,
|
|
54
37
|
"data-test": "input__icon",
|
|
55
38
|
tabIndex: iconIsAction && iconIsFocusable ? 0 : -1
|
|
56
|
-
}
|
|
39
|
+
}, iconJsx);
|
|
57
40
|
};
|
|
58
41
|
|
|
59
42
|
export { CustomIcon, transferInteractiveProps };
|
package/lib/parts/right-icons.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import cn from 'classnames';
|
|
4
3
|
import LoadingIcon from '../_virtual/loading.js';
|
|
5
4
|
import styles from '../input.p.module.css.js';
|
|
6
5
|
import { CustomIcon } from './custom-icon.js'; // eslint-disable-next-line complexity
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
const RightIcons = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
icon,
|
|
10
|
+
busy,
|
|
11
|
+
onClear,
|
|
12
|
+
clearIcon,
|
|
13
|
+
iconIsAction,
|
|
14
|
+
iconIsFocusable,
|
|
15
|
+
empty
|
|
16
|
+
} = _ref;
|
|
17
|
+
const icons = [];
|
|
17
18
|
|
|
18
19
|
if (onClear && !empty) {
|
|
19
20
|
icons.push(
|
|
@@ -42,7 +43,7 @@ var RightIcons = function RightIcons(_ref) {
|
|
|
42
43
|
}));
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
46
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, icons.slice(0, busy ? -1 : icons.length), busy && /*#__PURE__*/React.createElement("span", {
|
|
46
47
|
key: "loading",
|
|
47
48
|
className: cn(styles.iconWrapper, styles.right)
|
|
48
49
|
}, /*#__PURE__*/React.createElement(LoadingIcon, {
|