carbon-react 104.58.0 → 104.58.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.
@@ -1,7 +1,7 @@
1
1
  export default SelectText;
2
2
  declare function SelectText({ disabled, formattedValue, onClick, onKeyDown, onFocus, onBlur, onMouseDown, placeholder, readOnly, textId, transparent, }: {
3
3
  disabled: any;
4
- formattedValue: any;
4
+ formattedValue?: string | undefined;
5
5
  onClick: any;
6
6
  onKeyDown: any;
7
7
  onFocus: any;
@@ -1,12 +1,11 @@
1
1
  import React, { useContext } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import StyledSelectText from "./select-text.style";
4
- import useLocale from "../../../../hooks/__internal__/useLocale";
5
4
  import { InputContext } from "../../../../__internal__/input-behaviour";
6
5
 
7
6
  const SelectText = ({
8
7
  disabled,
9
- formattedValue,
8
+ formattedValue = "",
10
9
  onClick,
11
10
  onKeyDown,
12
11
  onFocus,
@@ -17,10 +16,8 @@ const SelectText = ({
17
16
  textId,
18
17
  transparent
19
18
  }) => {
20
- const l = useLocale();
21
19
  const inputContext = useContext(InputContext);
22
20
  const hasPlaceholder = !disabled && !readOnly && !formattedValue;
23
- const placeholderText = hasPlaceholder ? placeholder || l.select.placeholder() : "";
24
21
 
25
22
  function handleFocus(event) {
26
23
  inputContext.onFocus(event);
@@ -53,7 +50,7 @@ const SelectText = ({
53
50
  role: "button",
54
51
  tabIndex: "-1",
55
52
  transparent: transparent
56
- }, formattedValue || placeholderText);
53
+ }, hasPlaceholder ? placeholder : formattedValue);
57
54
  };
58
55
 
59
56
  SelectText.propTypes = {
@@ -119,7 +119,6 @@ const SelectTextbox = ({
119
119
 
120
120
  function getTextboxProps() {
121
121
  return {
122
- placeholder: hasTextCursor ? placeholder || l.select.placeholder() : undefined,
123
122
  disabled,
124
123
  readOnly,
125
124
  required,
@@ -147,14 +146,11 @@ const SelectTextbox = ({
147
146
  }
148
147
 
149
148
  function renderSelectText() {
150
- if (hasTextCursor) {
151
- return null;
152
- }
153
-
154
149
  return /*#__PURE__*/React.createElement(SelectText, _extends({
155
150
  textId: textId.current,
156
151
  transparent: transparent,
157
- onKeyDown: handleSelectTextKeydown
152
+ onKeyDown: handleSelectTextKeydown,
153
+ placeholder: placeholder || l.select.placeholder()
158
154
  }, getTextboxProps()));
159
155
  }
160
156
 
@@ -174,8 +170,9 @@ const SelectTextbox = ({
174
170
  autoComplete: "off",
175
171
  size: size,
176
172
  onChange: onChange,
177
- value: selectedValue
178
- }, getInputAriaAttributes(), getTextboxProps()), renderSelectText());
173
+ value: selectedValue,
174
+ placeholder: hasTextCursor ? placeholder || l.select.placeholder() : undefined
175
+ }, getInputAriaAttributes(), getTextboxProps()), !hasTextCursor && renderSelectText());
179
176
  };
180
177
 
181
178
  const formInputPropTypes = {
@@ -1,7 +1,7 @@
1
1
  export default SelectText;
2
2
  declare function SelectText({ disabled, formattedValue, onClick, onKeyDown, onFocus, onBlur, onMouseDown, placeholder, readOnly, textId, transparent, }: {
3
3
  disabled: any;
4
- formattedValue: any;
4
+ formattedValue?: string | undefined;
5
5
  onClick: any;
6
6
  onKeyDown: any;
7
7
  onFocus: any;
@@ -11,8 +11,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _selectText = _interopRequireDefault(require("./select-text.style"));
13
13
 
14
- var _useLocale = _interopRequireDefault(require("../../../../hooks/__internal__/useLocale"));
15
-
16
14
  var _inputBehaviour = require("../../../../__internal__/input-behaviour");
17
15
 
18
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -23,7 +21,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
23
21
 
24
22
  const SelectText = ({
25
23
  disabled,
26
- formattedValue,
24
+ formattedValue = "",
27
25
  onClick,
28
26
  onKeyDown,
29
27
  onFocus,
@@ -34,10 +32,8 @@ const SelectText = ({
34
32
  textId,
35
33
  transparent
36
34
  }) => {
37
- const l = (0, _useLocale.default)();
38
35
  const inputContext = (0, _react.useContext)(_inputBehaviour.InputContext);
39
36
  const hasPlaceholder = !disabled && !readOnly && !formattedValue;
40
- const placeholderText = hasPlaceholder ? placeholder || l.select.placeholder() : "";
41
37
 
42
38
  function handleFocus(event) {
43
39
  inputContext.onFocus(event);
@@ -70,7 +66,7 @@ const SelectText = ({
70
66
  role: "button",
71
67
  tabIndex: "-1",
72
68
  transparent: transparent
73
- }, formattedValue || placeholderText);
69
+ }, hasPlaceholder ? placeholder : formattedValue);
74
70
  };
75
71
 
76
72
  SelectText.propTypes = {
@@ -140,7 +140,6 @@ const SelectTextbox = ({
140
140
 
141
141
  function getTextboxProps() {
142
142
  return {
143
- placeholder: hasTextCursor ? placeholder || l.select.placeholder() : undefined,
144
143
  disabled,
145
144
  readOnly,
146
145
  required,
@@ -168,14 +167,11 @@ const SelectTextbox = ({
168
167
  }
169
168
 
170
169
  function renderSelectText() {
171
- if (hasTextCursor) {
172
- return null;
173
- }
174
-
175
170
  return /*#__PURE__*/_react.default.createElement(_selectText.default, _extends({
176
171
  textId: textId.current,
177
172
  transparent: transparent,
178
- onKeyDown: handleSelectTextKeydown
173
+ onKeyDown: handleSelectTextKeydown,
174
+ placeholder: placeholder || l.select.placeholder()
179
175
  }, getTextboxProps()));
180
176
  }
181
177
 
@@ -195,8 +191,9 @@ const SelectTextbox = ({
195
191
  autoComplete: "off",
196
192
  size: size,
197
193
  onChange: onChange,
198
- value: selectedValue
199
- }, getInputAriaAttributes(), getTextboxProps()), renderSelectText());
194
+ value: selectedValue,
195
+ placeholder: hasTextCursor ? placeholder || l.select.placeholder() : undefined
196
+ }, getInputAriaAttributes(), getTextboxProps()), !hasTextCursor && renderSelectText());
200
197
  };
201
198
 
202
199
  const formInputPropTypes = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "104.58.0",
3
+ "version": "104.58.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {