@rescui/input 0.9.9 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/input.js CHANGED
@@ -18,7 +18,7 @@ import * as React from 'react';
18
18
  import PropTypes from 'prop-types';
19
19
  import { CloseIcon } from '@rescui/icons';
20
20
  import cn from 'classnames';
21
- import { useTheme } from '@rescui/ui-contexts';
21
+ import { useThemeWithUndefined } from '@rescui/ui-contexts';
22
22
  import styles from './input.p.module.css.js';
23
23
  import { RightIcons } from './parts/right-icons.js';
24
24
  import { CustomIcon } from './parts/custom-icon.js';
@@ -65,7 +65,7 @@ function (_ref, ref) {
65
65
  boldLabel = _ref.boldLabel,
66
66
  restProps = _objectWithoutProperties(_ref, _excluded);
67
67
 
68
- var theme = useTheme(themeFromProps); // replace with :focus-within when ie11 is not supported anymore
68
+ var theme = useThemeWithUndefined(themeFromProps); // replace with :focus-within when ie11 is not supported anymore
69
69
 
70
70
  var _useState = useState(false),
71
71
  _useState2 = _slicedToArray(_useState, 2),
@@ -98,11 +98,12 @@ function (_ref, ref) {
98
98
  var renderLeftCustomIcon = icon && iconType === 'left';
99
99
  var renderRightCustomIcon = icon && (iconType === 'right' || iconType === 'rightAction' || iconType === 'rightActionFocusable');
100
100
  return /*#__PURE__*/React.createElement("div", {
101
- className: cn(styles.container, styles[theme], styles[mode], sizeStyles[size], (_cn = {}, _defineProperty(_cn, styles.focused, focused), _defineProperty(_cn, styles.filled, filled), _defineProperty(_cn, styles.enabled, enabled), _defineProperty(_cn, styles.error, Boolean(error)), _defineProperty(_cn, styles.disabled, disabled), _defineProperty(_cn, styles.offSystemMicroelements, offSystemMicroelements), _defineProperty(_cn, styles.boldLabel, boldLabel), _cn), className),
101
+ className: cn(styles.container, styles[theme], styles[mode], sizeStyles[size], (_cn = {}, _defineProperty(_cn, styles.focused, focused), _defineProperty(_cn, styles.filled, filled), _defineProperty(_cn, styles.enabled, enabled), _defineProperty(_cn, styles.error, Boolean(error)), _defineProperty(_cn, styles.disabled, disabled), _defineProperty(_cn, styles.offSystemMicroelements, offSystemMicroelements), _cn), className),
102
102
  style: style,
103
103
  "data-test": "input"
104
104
  }, /*#__PURE__*/React.createElement("label", null, label && /*#__PURE__*/React.createElement("div", {
105
- className: styles.label
105
+ className: styles.label,
106
+ "data-rs-internal": boldLabel ? 'input__bold-label' : 'input__label'
106
107
  }, label), /*#__PURE__*/React.createElement("div", {
107
108
  className: styles.wrapper,
108
109
  onFocus: function onFocus() {
@@ -141,8 +142,7 @@ function (_ref, ref) {
141
142
  icon: icon,
142
143
  iconIsAction: false,
143
144
  iconIsFocusable: false,
144
- iconPosition: "left",
145
- size: size
145
+ iconPosition: "left"
146
146
  }), /*#__PURE__*/React.createElement("input", _objectSpread(_objectSpread({}, restProps), {}, {
147
147
  id: id,
148
148
  className: styles.inner,
@@ -162,12 +162,12 @@ function (_ref, ref) {
162
162
  value: value,
163
163
  ref: ref,
164
164
  "aria-invalid": Boolean(error),
165
- "data-test": "input__inner"
165
+ "data-test": "input__inner",
166
+ "data-rs-internal": "input__inner"
166
167
  })), /*#__PURE__*/React.createElement(RightIcons, {
167
168
  icon: renderRightCustomIcon && icon,
168
169
  iconIsAction: iconType === 'rightAction' || iconType === 'rightActionFocusable',
169
170
  iconIsFocusable: iconType === 'rightActionFocusable',
170
- size: size,
171
171
  clearIcon: clearIcon,
172
172
  onClear: onClear,
173
173
  empty: empty,
@@ -176,12 +176,15 @@ function (_ref, ref) {
176
176
  className: styles.divider
177
177
  }), /*#__PURE__*/React.createElement("div", {
178
178
  className: styles.suffix,
179
- "data-test": "input__suffix"
179
+ "data-test": "input__suffix",
180
+ "data-rs-internal": "input__suffix"
180
181
  }, suffix)))), error && typeof error !== 'boolean' && /*#__PURE__*/React.createElement("div", {
181
182
  className: styles.errorMessage,
182
- "data-test": "input__error-message"
183
+ "data-test": "input__error-message",
184
+ "data-rs-internal": "input__error-message"
183
185
  }, error), note && /*#__PURE__*/React.createElement("div", {
184
- className: styles.note
186
+ className: styles.note,
187
+ "data-rs-internal": "input__note"
185
188
  }, note));
186
189
  });
187
190
  Input.displayName = 'Input';
@@ -1,31 +1,30 @@
1
1
  var styles = {
2
- "container": "_container_1xc6iin_10",
3
- "wrapper": "_wrapper_1xc6iin_14",
4
- "light": "_light_1xc6iin_21",
5
- "enabled": "_enabled_1xc6iin_27",
6
- "filled": "_filled_1xc6iin_27",
7
- "focused": "_focused_1xc6iin_39",
8
- "classic": "_classic_1xc6iin_44",
9
- "rock": "_rock_1xc6iin_48",
10
- "dark": "_dark_1xc6iin_52",
11
- "error": "_error_1xc6iin_83",
12
- "disabled": "_disabled_1xc6iin_103",
13
- "field": "_field_1xc6iin_161",
14
- "sizeL": "_sizeL_1xc6iin_121",
15
- "sizeM": "_sizeM_1xc6iin_125",
16
- "sizeS": "_sizeS_1xc6iin_129",
17
- "inner": "_inner_1xc6iin_171",
18
- "rs-reset-letter-spacing": "_rs-reset-letter-spacing_1xc6iin_1",
19
- "offSystemMicroelements": "_offSystemMicroelements_1xc6iin_345",
20
- "icon": "_icon_1xc6iin_356",
21
- "action": "_action_1xc6iin_360",
22
- "right": "_right_1xc6iin_441",
23
- "left": "_left_1xc6iin_453",
24
- "divider": "_divider_1xc6iin_523",
25
- "suffix": "_suffix_1xc6iin_558",
26
- "errorMessage": "_errorMessage_1xc6iin_596",
27
- "note": "_note_1xc6iin_614",
28
- "label": "_label_1xc6iin_646",
29
- "boldLabel": "_boldLabel_1xc6iin_661"
2
+ "light": "_light_6gddzg_8",
3
+ "dark": "_dark_6gddzg_11",
4
+ "sizeS": "_sizeS_6gddzg_15",
5
+ "sizeM": "_sizeM_6gddzg_18",
6
+ "sizeL": "_sizeL_6gddzg_21",
7
+ "classic": "_classic_6gddzg_25",
8
+ "rock": "_rock_6gddzg_28",
9
+ "container": "_container_6gddzg_32",
10
+ "wrapper": "_wrapper_6gddzg_39",
11
+ "disabled": "_disabled_6gddzg_51",
12
+ "error": "_error_6gddzg_57",
13
+ "enabled": "_enabled_6gddzg_63",
14
+ "filled": "_filled_6gddzg_63",
15
+ "focused": "_focused_6gddzg_75",
16
+ "field": "_field_6gddzg_101",
17
+ "inner": "_inner_6gddzg_114",
18
+ "offSystemMicroelements": "_offSystemMicroelements_6gddzg_229",
19
+ "iconWrapper": "_iconWrapper_6gddzg_239",
20
+ "action": "_action_6gddzg_254",
21
+ "right": "_right_6gddzg_292",
22
+ "left": "_left_6gddzg_296",
23
+ "icon": "_icon_6gddzg_239",
24
+ "divider": "_divider_6gddzg_342",
25
+ "suffix": "_suffix_6gddzg_356",
26
+ "errorMessage": "_errorMessage_6gddzg_376",
27
+ "note": "_note_6gddzg_383",
28
+ "label": "_label_6gddzg_396"
30
29
  };
31
30
  export { styles as default };
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import { InputSize } from '../input';
3
2
  interface MouseInteractiveProps {
4
3
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
5
4
  onContextMenu?: React.MouseEventHandler<HTMLButtonElement>;
@@ -18,7 +17,6 @@ export declare function transferInteractiveProps(iconProps: MouseInteractiveProp
18
17
  icon: MouseInteractiveProps;
19
18
  };
20
19
  declare type CustomIconProps = {
21
- size?: InputSize;
22
20
  icon: React.ReactNode;
23
21
  iconIsAction?: boolean;
24
22
  iconIsFocusable?: boolean;
@@ -38,19 +38,18 @@ function transferInteractiveProps(iconProps) {
38
38
 
39
39
  var CustomIcon = function CustomIcon(_ref) {
40
40
  var icon = _ref.icon,
41
- size = _ref.size,
42
41
  iconPosition = _ref.iconPosition,
43
42
  iconIsAction = _ref.iconIsAction,
44
43
  iconIsFocusable = _ref.iconIsFocusable;
45
44
  var mouseEvents = transferInteractiveProps(icon.props);
46
45
  var iconJsx = /*#__PURE__*/React.cloneElement(icon, _objectSpread({
47
- size: size,
48
- focusable: false
46
+ focusable: false,
47
+ className: cn(icon.props.className, styles.icon)
49
48
  }, mouseEvents.icon));
50
49
  return /*#__PURE__*/React.createElement("span", _objectSpread(_objectSpread({
51
50
  role: iconIsAction ? 'button' : null,
52
51
  key: "icon",
53
- className: cn(styles.icon, styles[iconPosition], iconIsAction && styles.action)
52
+ className: cn(styles.iconWrapper, styles[iconPosition], iconIsAction && styles.action)
54
53
  }, mouseEvents.button), {}, {
55
54
  "data-test": "input__icon",
56
55
  tabIndex: iconIsAction && iconIsFocusable ? 0 : -1
@@ -8,7 +8,6 @@ import { CustomIcon } from './custom-icon.js'; // eslint-disable-next-line compl
8
8
  var RightIcons = function RightIcons(_ref) {
9
9
  var icon = _ref.icon,
10
10
  busy = _ref.busy,
11
- size = _ref.size,
12
11
  onClear = _ref.onClear,
13
12
  clearIcon = _ref.clearIcon,
14
13
  iconIsAction = _ref.iconIsAction,
@@ -23,21 +22,19 @@ var RightIcons = function RightIcons(_ref) {
23
22
  React.createElement("span", {
24
23
  role: "button",
25
24
  key: "clear",
26
- className: cn(styles.icon, styles.right, styles.action),
25
+ className: cn(styles.iconWrapper, styles.right, styles.action),
27
26
  onClick: onClear,
28
27
  "data-test": "input__clear-icon",
29
28
  tabIndex: -1
30
29
  }, /*#__PURE__*/React.cloneElement(clearIcon, {
31
- size: size,
32
30
  focusable: false,
33
- className: clearIcon.props.className
31
+ className: cn(clearIcon.props.className, styles.icon)
34
32
  })));
35
33
  }
36
34
 
37
35
  if (icon) {
38
36
  icons.push( /*#__PURE__*/React.createElement(CustomIcon, {
39
37
  key: "custom-icon",
40
- size: size,
41
38
  iconPosition: 'right',
42
39
  iconIsFocusable: iconIsFocusable,
43
40
  iconIsAction: iconIsAction,
@@ -47,10 +44,10 @@ var RightIcons = function RightIcons(_ref) {
47
44
 
48
45
  return /*#__PURE__*/React.createElement(React.Fragment, null, _sliceInstanceProperty(icons).call(icons, 0, busy ? -1 : icons.length), busy && /*#__PURE__*/React.createElement("span", {
49
46
  key: "loading",
50
- className: cn(styles.icon, styles.right)
47
+ className: cn(styles.iconWrapper, styles.right)
51
48
  }, /*#__PURE__*/React.createElement(LoadingIcon, {
52
- size: size,
53
- "data-test": "input__busy-icon"
49
+ "data-test": "input__busy-icon",
50
+ className: styles.icon
54
51
  })));
55
52
  };
56
53